Skip to content

Commit 51796de

Browse files
authored
Display (Linux): detect all enabled or connected connectors (fastfetch-cli#1301)
DRM connectors have two properties, "enabled" and "status", standing for "enabled by userspace" and "a display has been connected". Connector status cannot be reliably detected sometimes, in this case status will be set to unknown and it is still okay to enable it. Some drivers are also able to enable disconnected connectors. So it is both meaningful to detect connectors in two states, - An enabled connector, where it must have been operating in some configuration required by userspace - A connected connector, where driver is sure a display has been connected to the port, this is the obvious case. In the original implementation, only information of connected connectors are detected and an enabled connector without hotplug detection capability, like a Composite video connector, will be silently ignored. Switch to the new strategy to detect these connectors correctly. References: https://github.com/torvalds/linux/blob/3efc57369a0ce8f76bf0804f7e673982384e4ac9/include/drm/drm_connector.h#L58-L89 Signed-off-by: Yao Zi <[email protected]>
1 parent 140b983 commit 51796de

File tree

1 file changed

+11
-5
lines changed
  • src/detection/displayserver/linux

1 file changed

+11
-5
lines changed

src/detection/displayserver/linux/drm.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,19 @@ static const char* drmParseSysfs(FFDisplayServerResult* result)
2828
ffStrbufAppendS(&drmDir, entry->d_name);
2929
uint32_t drmDirWithDnameLength = drmDir.length;
3030

31-
ffStrbufAppendS(&drmDir, "/status");
32-
char status = 'd'; // disconnected
33-
ffReadFileData(drmDir.chars, sizeof(status), &status);
34-
if (status != 'c') // connected
35-
{
31+
char buf;
32+
ffStrbufAppendS(&drmDir, "/enabled");
33+
if (!ffReadFileData(drmDir.chars, sizeof(buf), &buf) || buf != 'e') {
34+
/* read failed or enabled != "enabled" */
35+
ffStrbufSubstrBefore(&drmDir, drmDirWithDnameLength);
36+
ffStrbufAppendS(&drmDir, "/status");
37+
buf = 'd';
38+
ffReadFileData(drmDir.chars, sizeof(buf), &buf);
39+
if (buf != 'c') {
40+
/* read failed or status != "connected" */
3641
ffStrbufSubstrBefore(&drmDir, drmDirLength);
3742
continue;
43+
}
3844
}
3945

4046
unsigned width = 0, height = 0, physicalWidth = 0, physicalHeight = 0;

0 commit comments

Comments
 (0)