summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPekka Paalanen <pekka.paalanen@collabora.com>2022-10-13 12:50:26 +0300
committerPekka Paalanen <pekka.paalanen@collabora.com>2023-04-28 16:18:22 +0300
commitd6a4c58f07d70077460c40673b7ddce95aeebe1b (patch)
tree29d2d9d4dd3f69fc051cb26662d600bcce304b80
parent1605a6a747e58c4854196bdd2ebd8d3c1d6a6039 (diff)
downloadweston-d6a4c58f07d70077460c40673b7ddce95aeebe1b.tar.gz
backend-drm: use libdisplay-info
Add libdisplay-info as a better alternative for parsing EDID. This way we do not need to extend Weston's ad hoc parser for new things that especially HDR support requires. Eventually the ad hoc parser will be deleted and libdisplay-info becomes a hard dependency for the drm-backend, reducing our maintenance burden. Unlike the ad hoc code, libdisplay-info has automated CI testing. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
-rw-r--r--libweston/backend-drm/meson.build12
-rw-r--r--libweston/backend-drm/modes.c36
-rw-r--r--subprojects/.gitignore2
-rw-r--r--subprojects/display-info.wrap5
4 files changed, 55 insertions, 0 deletions
diff --git a/libweston/backend-drm/meson.build b/libweston/backend-drm/meson.build
index e15be78b..d52c088e 100644
--- a/libweston/backend-drm/meson.build
+++ b/libweston/backend-drm/meson.build
@@ -2,6 +2,17 @@ if not get_option('backend-drm')
subdir_done()
endif
+dep_libdisplay_info = dependency(
+ 'libdisplay-info',
+ version: ['>= 0.1.1', '< 0.2.0'],
+ fallback: ['display-info', 'di_dep'],
+ default_options: [
+ 'werror=false',
+ ],
+ required: false,
+)
+config_h.set10('HAVE_LIBDISPLAY_INFO', dep_libdisplay_info.found())
+
lib_backlight = static_library(
'backlight',
'libbacklight.c',
@@ -42,6 +53,7 @@ deps_drm = [
dep_libdrm,
dep_libinput_backend,
dependency('libudev', version: '>= 136'),
+ dep_libdisplay_info,
dep_backlight
]
diff --git a/libweston/backend-drm/modes.c b/libweston/backend-drm/modes.c
index e8c9474b..66816572 100644
--- a/libweston/backend-drm/modes.c
+++ b/libweston/backend-drm/modes.c
@@ -32,6 +32,10 @@
#include <xf86drm.h>
#include <xf86drmMode.h>
+#if HAVE_LIBDISPLAY_INFO
+#include <libdisplay-info/info.h>
+#endif
+
#include "drm-internal.h"
#include "shared/weston-drm-fourcc.h"
#include "shared/xalloc.h"
@@ -221,6 +225,36 @@ parse_modeline(const char *s, drmModeModeInfo *mode)
return 0;
}
+#if HAVE_LIBDISPLAY_INFO
+
+static void
+drm_head_info_from_edid(struct drm_head_info *dhi,
+ const uint8_t *data,
+ size_t length)
+{
+ struct di_info *di_ctx;
+ const char *msg;
+
+ di_ctx = di_info_parse_edid(data, length);
+ if (!di_ctx)
+ return;
+
+ msg = di_info_get_failure_msg(di_ctx);
+ if (msg)
+ weston_log("DRM: EDID for the following head fails conformity:\n%s\n", msg);
+
+ dhi->make = di_info_get_make(di_ctx);
+ dhi->model = di_info_get_model(di_ctx);
+ dhi->serial_number = di_info_get_serial(di_ctx);
+
+ di_info_destroy(di_ctx);
+
+ /* TODO: parse this from EDID */
+ dhi->eotf_mask = WESTON_EOTF_MODE_ALL_MASK;
+}
+
+#else /* HAVE_LIBDISPLAY_INFO */
+
struct drm_edid {
char eisa_id[13];
char monitor_name[13];
@@ -348,6 +382,8 @@ drm_head_info_from_edid(struct drm_head_info *dhi,
dhi->eotf_mask = WESTON_EOTF_MODE_ALL_MASK;
}
+#endif /* HAVE_LIBDISPLAY_INFO else */
+
/** Parse monitor make, model and serial from EDID
*
* \param head The head whose \c drm_edid to fill in.
diff --git a/subprojects/.gitignore b/subprojects/.gitignore
new file mode 100644
index 00000000..532b5ce6
--- /dev/null
+++ b/subprojects/.gitignore
@@ -0,0 +1,2 @@
+/display-info
+
diff --git a/subprojects/display-info.wrap b/subprojects/display-info.wrap
new file mode 100644
index 00000000..8787b700
--- /dev/null
+++ b/subprojects/display-info.wrap
@@ -0,0 +1,5 @@
+[wrap-git]
+directory = display-info
+url = https://gitlab.freedesktop.org/emersion/libdisplay-info.git
+revision = 0.1.1
+