From 85593d2e4a46733deafdef97102170a88ead929d Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 16 May 2023 16:25:44 +0300 Subject: [PATCH] backend-drm: get_eotf_mask() from di_info Use libdisplay-info to parse the supported EOTF modes for the sink/monitor. No more guessing. Signed-off-by: Pekka Paalanen --- libweston/backend-drm/meson.build | 3 +++ libweston/backend-drm/modes.c | 41 +++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/libweston/backend-drm/meson.build b/libweston/backend-drm/meson.build index e3e904a70..002669e61 100644 --- a/libweston/backend-drm/meson.build +++ b/libweston/backend-drm/meson.build @@ -12,6 +12,9 @@ dep_libdisplay_info = dependency( required: true, not_found_message: 'Required by DRM-backend.', ) +if dep_libdisplay_info.version().version_compare('>= 0.2.0') + config_h.set('HAVE_LIBDISPLAY_INFO_HIGH_LEVEL_COLORIMETRY', '1') +endif lib_backlight = static_library( 'backlight', diff --git a/libweston/backend-drm/modes.c b/libweston/backend-drm/modes.c index e29369594..0cf61546d 100644 --- a/libweston/backend-drm/modes.c +++ b/libweston/backend-drm/modes.c @@ -1,7 +1,7 @@ /* * Copyright © 2008-2011 Kristian Høgsberg * Copyright © 2011 Intel Corporation - * Copyright © 2017, 2018 Collabora, Ltd. + * Copyright © 2017, 2018, 2024 Collabora, Ltd. * Copyright © 2017, 2018 General Electric Company * Copyright (c) 2018 DisplayLink (UK) Ltd. * @@ -227,6 +227,43 @@ parse_modeline(const char *s, drmModeModeInfo *mode) return 0; } +#ifdef HAVE_LIBDISPLAY_INFO_HIGH_LEVEL_COLORIMETRY + +static uint32_t +get_eotf_mask(const struct di_info *info) +{ + const struct di_hdr_static_metadata *hdr_static; + uint32_t mask = 0; + + hdr_static = di_info_get_hdr_static_metadata(info); + if (!hdr_static->type1) + return WESTON_EOTF_MODE_SDR; + + if (hdr_static->traditional_sdr) + mask |= WESTON_EOTF_MODE_SDR; + + if (hdr_static->traditional_hdr) + mask |= WESTON_EOTF_MODE_TRADITIONAL_HDR; + + if (hdr_static->pq) + mask |= WESTON_EOTF_MODE_ST2084; + + if (hdr_static->hlg) + mask |= WESTON_EOTF_MODE_HLG; + + return mask; +} + +#else /* HAVE_LIBDISPLAY_INFO_HIGH_LEVEL_COLORIMETRY */ + +static uint32_t +get_eotf_mask(const struct di_info *info) +{ + return WESTON_EOTF_MODE_SDR; +} + +#endif /* HAVE_LIBDISPLAY_INFO_HIGH_LEVEL_COLORIMETRY */ + static void drm_head_info_from_edid(struct drm_head_info *dhi, const uint8_t *data, @@ -250,11 +287,11 @@ drm_head_info_from_edid(struct drm_head_info *dhi, 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); + dhi->eotf_mask = get_eotf_mask(di_ctx); di_info_destroy(di_ctx); /* TODO: parse this from EDID */ - dhi->eotf_mask = WESTON_EOTF_MODE_ALL_MASK; dhi->colorimetry_mask = WESTON_COLORIMETRY_MODE_ALL_MASK; }