From d6a4c58f07d70077460c40673b7ddce95aeebe1b Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 13 Oct 2022 12:50:26 +0300 Subject: [PATCH] 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 --- libweston/backend-drm/meson.build | 12 +++++++++++ libweston/backend-drm/modes.c | 36 +++++++++++++++++++++++++++++++ subprojects/.gitignore | 2 ++ subprojects/display-info.wrap | 5 +++++ 4 files changed, 55 insertions(+) create mode 100644 subprojects/.gitignore create mode 100644 subprojects/display-info.wrap 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 #include +#if HAVE_LIBDISPLAY_INFO +#include +#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 +