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>
This commit is contained in:
Pekka Paalanen 2022-10-13 12:50:26 +03:00
parent 1605a6a747
commit d6a4c58f07
4 changed files with 55 additions and 0 deletions

View File

@ -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
]

View File

@ -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.

2
subprojects/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/display-info

View File

@ -0,0 +1,5 @@
[wrap-git]
directory = display-info
url = https://gitlab.freedesktop.org/emersion/libdisplay-info.git
revision = 0.1.1