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 <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen 2023-05-16 16:25:44 +03:00 committed by Daniel Stone
parent f23e511ec7
commit 85593d2e4a
2 changed files with 42 additions and 2 deletions

View file

@ -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',

View file

@ -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;
}