Add xf86DoInterpretHDRMetadata(), which walks the EDID's CTA/CEA
extension data blocks and fills in a new struct monitor_hdr_data
(tail-appended field xf86Monitor::hdr) from the two blocks a display
uses to advertise HDR support:
- the Colorimetry Data Block (tag 5): which extended gamuts/transfer
spaces the display accepts (BT.2020 RGB/YCC/cYCC, opRGB, xvYCC,
ICtCp, ...), exposed via is_CTA_CDB_*() bit-test macros.
- the HDR Static Metadata Data Block (tag 6): supported EOTFs
(traditional SDR/HDR gamma, SMPTE ST.2084/PQ, HLG) plus the
desired content min/max/max-frame-average luminance, decoded with
the CTA-861-G power-law formulas.
Covered by a new EDID unit test (test/ddc-tests.c) using real captured
EDIDs from four displays (Samsung Q800T, MSI MAG321CURV, HP 27 QD, and
a QEMU virtual display as the "no HDR block present" negative case),
asserting the parsed colorimetry/luminance values match known-good
figures for each.
This is a standalone prerequisite for HDR support, independent of any
particular rendering-pipeline design: cepelinas9000's HDR work
(https://github.com/cepelinas9000/xserver/tree/wip/x11hdrV2) needs to
know a display's HDR/colorimetry capabilities before doing anything
else, and this is useful on its own for any HDR/wide-gamut detection
regardless of how the rest of the pipeline ends up looking.
Extracted (with typo/whitespace cleanup, no logic changes) from
cepelinas9000's wip/x11hdrV2 branch, commit 159a6f484a, for standalone
review ahead of the larger HDR effort.
Note for review: struct monitor_hdr_data is added as a new field at
the tail of the public xf86Monitor struct (include/edid.h) - additive
only, no existing field shifts.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Add regression tests for xorg_list operations on a *zero-initialized*
list head (next == prev == NULL), i.e. a head embedded in a calloc()'d
struct that was never run through xorg_list_init().
Covers the paths hardened in the preceding commit, so the gap found while
repairing #1639 (a never-init'd client->saveSets crashing
DeleteWindowFromAnySaveSet() via xorg_list_for_each_entry_safe()) cannot
silently regress:
- xorg_list_del() on a zeroed head (the documented "reset to empty list")
- xorg_list_for_each_entry_safe() over a zeroed/empty head
- add + safe-delete drain starting from a zeroed head
Without the macro fix these dereference NULL and crash; run_test_in_child()
forks per test, so the crash surfaces as a unit-test failure (verified: the
test fails at both -O0 and -O2 on the pre-fix tree, passes with the fix).
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Simple confirmation of known values, not exhaustive testing.
Tested with SHA-1 implementations from:
- libcrypto (OpenSSL 3)
- libgcrypt
- libnettle
- Solaris libmd
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2066>
This cleans up some of the mess this code was in. Functions we need to
wrap can now have a standard implementation using WRAP_FUNCTION - that
macro declares the __real and __wrap functions and a wrapped_$func
global variable.
Tests can set that variable to their desired functions and it will be
then be called on demand.
The tests have inadvertent dependencies on each other so let's avoid
those by changing to a system that returns a null-terminated list of
test functions and our test runner iterates over those and forks off one
process per function.