Skip to content

Commit 97b779a

Browse files
committed
Monitor (Linux): try detecting HDR support
1 parent 46b0c6e commit 97b779a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/detection/monitor/monitor_linux.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
#include "common/io/io.h"
44
#include "util/edidHelper.h"
55
#include "util/stringUtils.h"
6+
#include "util/mallocHelper.h"
67

78
#include <dirent.h>
9+
#include <sys/stat.h>
810

911
const char* ffDetectMonitor(FFlist* results)
1012
{
@@ -28,7 +30,14 @@ const char* ffDetectMonitor(FFlist* results)
2830
ffStrbufAppendS(&drmDir, entry->d_name);
2931
ffStrbufAppendS(&drmDir, "/edid");
3032

31-
uint8_t edidData[128];
33+
struct stat fileStat;
34+
if (stat(drmDir.chars, &fileStat) < 0 || fileStat.st_size == 0 || fileStat.st_size % 128 != 0)
35+
{
36+
ffStrbufSubstrBefore(&drmDir, drmDirLength);
37+
continue;
38+
}
39+
40+
FF_AUTO_FREE uint8_t* edidData = malloc((size_t) fileStat.st_size);
3241
if(ffReadFileData(drmDir.chars, sizeof(edidData), edidData) != sizeof(edidData))
3342
{
3443
ffStrbufSubstrBefore(&drmDir, drmDirLength);
@@ -45,6 +54,7 @@ const char* ffDetectMonitor(FFlist* results)
4554
ffStrbufInit(&display->name);
4655
ffEdidGetName(edidData, &display->name);
4756
ffEdidGetPhysicalSize(edidData, &display->physicalWidth, &display->physicalHeight);
57+
display->hdrCompatible = ffEdidGetHdrCompatible(edidData, (uint32_t) fileStat.st_size);
4858
}
4959

5060
ffStrbufSubstrBefore(&drmDir, drmDirLength);

0 commit comments

Comments
 (0)