info: add di_info_get_supported_signal_colorimetry()

Add a high-level function to get the supported additional signal
colorimetries. This is only an interesting sub-set of the CTA-861-H
defined colorimetries, for driving WCG and HDR displays.

Wayland compositors will be interested in this.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen 2023-07-06 16:09:33 +03:00
parent 6bc398e6db
commit af7d091dc9
3 changed files with 71 additions and 0 deletions

View file

@ -14,6 +14,7 @@
struct di_derived_info {
struct di_hdr_static_metadata hdr_static_metadata;
struct di_color_primaries color_primaries;
struct di_supported_signal_colorimetry supported_signal_colorimetry;
};
struct di_info {

View file

@ -194,4 +194,44 @@ struct di_color_primaries {
const struct di_color_primaries *
di_info_get_default_color_primaries(const struct di_info *info);
/** Additional signal colorimetry encodings supported by the display */
struct di_supported_signal_colorimetry {
/* Rec. ITU-R BT.2020 constant luminance YCbCr */
bool bt2020_cycc;
/* Rec. ITU-R BT.2020 non-constant luminance YCbCr */
bool bt2020_ycc;
/* Rec. ITU-R BT.2020 RGB */
bool bt2020_rgb;
/* SMPTE ST 2113 RGB: P3D65 and P3DCI */
bool st2113_rgb;
/* Rec. ITU-R BT.2100 ICtCp HDR (with PQ and/or HLG) */
bool ictcp;
};
/**
* Get signal colorimetry encodings supported by the display
*
* These signal colorimetry encodings are supported in addition to the
* display's default RGB colorimetry. When you wish to use one of the additional
* encodings, they need to be explicitly enabled in the video signal. How to
* do that is specific to the signalling used, e.g. HDMI.
*
* Signal colorimetry encoding provides the color space that the signal is
* encoded for. This includes primary and white point chromaticities, and the
* YCbCr-RGB conversion if necessary. Also the transfer function is implied
* unless explicitly set otherwise, e.g. with HDR static metadata.
* See ANSI/CTA-861-H for details.
*
* The signal color volume can be considerably larger than the physically
* displayable color volume.
*
* The returned pointer is owned by the struct di_info passed in. It remains
* valid only as long as the di_info exists, and must not be freed by the
* caller.
*
* This function does not return NULL.
*/
const struct di_supported_signal_colorimetry *
di_info_get_supported_signal_colorimetry(const struct di_info *info);
#endif

30
info.c
View file

@ -146,6 +146,29 @@ derive_edid_color_primaries(const struct di_edid *edid,
}
}
static void
derive_edid_supported_signal_colorimetry(const struct di_edid *edid,
struct di_supported_signal_colorimetry *ssc)
{
const struct di_cta_data_block *block;
const struct di_cta_colorimetry_block *cm;
/* Defaults to all unsupported. */
block = di_edid_get_cta_data_block(edid, DI_CTA_DATA_BLOCK_COLORIMETRY);
if (!block)
return;
cm = di_cta_data_block_get_colorimetry(block);
assert(cm);
ssc->bt2020_cycc = cm->bt2020_cycc;
ssc->bt2020_ycc = cm->bt2020_ycc;
ssc->bt2020_rgb = cm->bt2020_rgb;
ssc->st2113_rgb = cm->st2113_rgb;
ssc->ictcp = cm->ictcp;
}
struct di_info *
di_info_parse_edid(const void *data, size_t size)
{
@ -175,6 +198,7 @@ di_info_parse_edid(const void *data, size_t size)
derive_edid_hdr_static_metadata(info->edid, &info->derived.hdr_static_metadata);
derive_edid_color_primaries(info->edid, &info->derived.color_primaries);
derive_edid_supported_signal_colorimetry(info->edid, &info->derived.supported_signal_colorimetry);
return info;
@ -344,3 +368,9 @@ di_info_get_default_color_primaries(const struct di_info *info)
{
return &info->derived.color_primaries;
}
const struct di_supported_signal_colorimetry *
di_info_get_supported_signal_colorimetry(const struct di_info *info)
{
return &info->derived.supported_signal_colorimetry;
}