Skip to contentSkip to conversation

lib/igt_hdr: switch to libdisplay-info for EDID parsing

PATCH Superseded Simon Ser 5 participants 11 messages Nov 21 – Nov 26

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Simon Ser

author
#0 lore raw

PATCH 1/1 lib/igt_hdr: switch to libdisplay-info for EDID parsing

Replace manual EDID/CTA parsing with libdisplay-info [1].

libdisplay-info is an EDID and DisplayID library. It's widely used across Wayland compositors. It exposes both a high-level API (with information collected across EDID/DisplayID/CTA blocks) and a low-level API (exposing individual parsed fields from the specifications).

Using libdisplay-info will allow IGT to drop all of its custom parsing code. libdisplay-info takes care of the bitshifting and value decoding. libdisplay-info has documentation, a test suite, fuzzing, and a clone of edid-decode which can serve as an example to figure out how to use the low-level API.

IGT has already quite a bit of hand-rolled parsing code, and we need to start somewhere, so here is a patch leveraging libdisplay-info for igt_hdr.

As a bonus, igt_hdr now extracts HDR static metadata from CTA DisplayID blocks for free, because the high-level libdisplay-info helper does this already.

[1]: https://gitlab.freedesktop.org/emersion/libdisplay-info

Cc Gil Dekel <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Swati Sharma <[email protected]>
Cc Karthik B S <[email protected]>
Cc Mark Yacoub <[email protected]>
---
 Dockerfile.build-debian-arm64   |  1 +
 Dockerfile.build-debian-armhf   |  1 +
 Dockerfile.build-debian-minimal |  1 +
 Dockerfile.build-fedora         |  1 +
 lib/igt_hdr.c                   | 63 +++++----------------------------
 lib/meson.build                 |  1 +
 meson.build                     |  1 +
 7 files changed, 15 insertions(+), 54 deletions(-)
Dockerfile.build-debian-arm64 +1 -0
index 114b9760d1f6..7a9cd1915825 100644
@@ -26,6 +26,7 @@ RUN apt-get install -y \
 			libpci-dev:arm64 \
 			libpixman-1-dev:arm64 \
 			libudev-dev:arm64 \
+			libdisplay-info-dev:arm64 \
 			libgsl-dev:arm64 \
 			libasound2-dev:arm64 \
 			libjansson-dev:arm64 \
Dockerfile.build-debian-armhf +1 -0
index c6527ea1eb2f..375f3e185bba 100644
@@ -26,6 +26,7 @@ RUN apt-get install -y \
 			libpci-dev:armhf \
 			libpixman-1-dev:armhf \
 			libudev-dev:armhf \
+			libdisplay-info-dev:armhf \
 			libgsl-dev:armhf \
 			libasound2-dev:armhf \
 			libjansson-dev:armhf \
Dockerfile.build-debian-minimal +1 -0
index 573bb5139ceb..1d326250eef9 100644
@@ -17,6 +17,7 @@ RUN apt-get install -y \
 			libpci-dev \
 			libpixman-1-dev \
 			libudev-dev \
+			libdisplay-info-dev \
 			libxrandr-dev \
 			libxv-dev \
 			x11proto-dri2-dev \
Dockerfile.build-fedora +1 -0
index aacc6a87c844..db7618325a67 100644
@@ -14,6 +14,7 @@ RUN dnf install -y \
 	'pkgconfig(cairo)' \
 	'pkgconfig(libpci)' \
 	'pkgconfig(libudev)' \
+	'pkgconfig(libdisplay-info)' \
 	'pkgconfig(glib-2.0)' \
 	'pkgconfig(gsl)' \
 	'pkgconfig(alsa)' \
lib/igt_hdr.c +9 -54

91 lines not on this page · raw message

lib/meson.build +1 -0
index 3ed1369b53d1..cb861c472808 100644
@@ -156,6 +156,7 @@ lib_deps = [
 	libkmod,
 	libpci,
 	libudev,
+	libdisplay_info,
 	math,
 	pciaccess,
 	pixman,
meson.build +1 -0
index eec131375e06..e7c685116b13 100644
@@ -151,6 +151,7 @@ build_info += 'Valgrind annotations: @0@'.format(valgrind.found())
 cairo = dependency('cairo', version : '>1.12.0', required : true)
 libpci = dependency('libpci', required : true)
 libudev = dependency('libudev', required : true)
+libdisplay_info = dependency('libdisplay-info', required : true)
 glib = dependency('glib-2.0', required : true)
 
 libtsi = cc.find_library('TSI', required : false)
Signature · 1 line
2.56.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · Simon Ser

Replace manual EDID/CTA parsing with libdisplay-info [1].

libdisplay-info is an EDID and DisplayID library. It's widely used across Wayland compositors. It exposes both a high-level API (with information collected across EDID/DisplayID/CTA blocks) and a low-level API (exposing individual parsed fields from the specifications).

Using libdisplay-info will allow IGT to drop all of its custom parsing code. libdisplay-info takes care of the bitshifting and value decoding. libdisplay-info has documentation, a test suite, fuzzing, and a clone of edid-decode which can serve as an example to figure out how to use the low-level API.

IGT has already quite a bit of hand-rolled parsing code, and we need to start somewhere, so here is a patch leveraging libdisplay-info for igt_hdr.

As a bonus, igt_hdr now extracts HDR static metadata from CTA DisplayID blocks for free, because the high-level libdisplay-info helper does this already.

Quoted 8 lines

[1]: https://gitlab.freedesktop.org/emersion/libdisplay-info

Cc Gil Dekel <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Swati Sharma <[email protected]>
Cc Karthik B S <[email protected]>
Cc Mark Yacoub <[email protected]>

I did not check the HDR stuff bit-for-bit, but at the high level this looks really, really good, and a great start for migrating to libdisplay-info.

Thanks a lot for doing this!

Quoted 181 lines
---
 Dockerfile.build-debian-arm64   |  1 +
 Dockerfile.build-debian-armhf   |  1 +
 Dockerfile.build-debian-minimal |  1 +
 Dockerfile.build-fedora         |  1 +
 lib/igt_hdr.c                   | 63 +++++----------------------------
 lib/meson.build                 |  1 +
 meson.build                     |  1 +
 7 files changed, 15 insertions(+), 54 deletions(-)
Dockerfile.build-debian-arm64 +1 -0
index 114b9760d1f6..7a9cd1915825 100644
@@ -26,6 +26,7 @@ RUN apt-get install -y \
 			libpci-dev:arm64 \
 			libpixman-1-dev:arm64 \
 			libudev-dev:arm64 \
+			libdisplay-info-dev:arm64 \
 			libgsl-dev:arm64 \
 			libasound2-dev:arm64 \
 			libjansson-dev:arm64 \
Dockerfile.build-debian-armhf +1 -0
index c6527ea1eb2f..375f3e185bba 100644
@@ -26,6 +26,7 @@ RUN apt-get install -y \
 			libpci-dev:armhf \
 			libpixman-1-dev:armhf \
 			libudev-dev:armhf \
+			libdisplay-info-dev:armhf \
 			libgsl-dev:armhf \
 			libasound2-dev:armhf \
 			libjansson-dev:armhf \
Dockerfile.build-debian-minimal +1 -0
index 573bb5139ceb..1d326250eef9 100644
@@ -17,6 +17,7 @@ RUN apt-get install -y \
 			libpci-dev \
 			libpixman-1-dev \
 			libudev-dev \
+			libdisplay-info-dev \
 			libxrandr-dev \
 			libxv-dev \
 			x11proto-dri2-dev \
Dockerfile.build-fedora +1 -0
index aacc6a87c844..db7618325a67 100644
@@ -14,6 +14,7 @@ RUN dnf install -y \
 	'pkgconfig(cairo)' \
 	'pkgconfig(libpci)' \
 	'pkgconfig(libudev)' \
+	'pkgconfig(libdisplay-info)' \
 	'pkgconfig(glib-2.0)' \
 	'pkgconfig(gsl)' \
 	'pkgconfig(alsa)' \
lib/igt_hdr.c +9 -54
index c0ed9e843163..b8175ceef1f7 100644
@@ -11,6 +11,8 @@
 #include <termios.h>
 #include <unistd.h>
 
+#include <libdisplay-info/info.h>
+
 /**
  * SECTION:igt_hdr
  * @short_description: HDR metadata helpers
@@ -22,33 +24,6 @@
  * output metadata construction, and blob programming utilities.
  */
 
-/* HDR EDID parsing. */
-#define CTA_EXTENSION_VERSION		0x03
-#define HDR_STATIC_METADATA_BLOCK	0x06
-#define USE_EXTENDED_TAG		0x07
-
-static bool cta_block(const char *edid_ext)
-{
-	/*
-	 * Byte 1: 0x07 indicates Extended Tag
-	 * Byte 2: 0x06 indicates HDMI Static Metadata Block
-	 * Byte 3: bits 0 to 5 identify EOTF functions supported by sink
-	 *	       where ET_0: Traditional Gamma - SDR Luminance Range
-	 *	             ET_1: Traditional Gamma - HDR Luminance Range
-	 *	             ET_2: SMPTE ST 2084
-	 *	             ET_3: Hybrid Log-Gamma (HLG)
-	 *	             ET_4 to ET_5: Reserved for future use
-	 */
-
-	if ((((edid_ext[0] & 0xe0) >> 5 == USE_EXTENDED_TAG) &&
-	      (edid_ext[1] == HDR_STATIC_METADATA_BLOCK)) &&
-	     (edid_ext[2] & ((1 << HDMI_EOTF_TRADITIONAL_GAMMA_HDR) |
-			     (1 << HDMI_EOTF_SMPTE_ST2084))))
-			return true;
-
-	return false;
-}
-
 /**
  * igt_is_panel_hdr:
  * @fd: DRM file descriptor
@@ -63,13 +38,10 @@ static bool cta_block(const char *edid_ext)
 bool igt_is_panel_hdr(int fd, igt_output_t *output)
 {
 	bool ok;
-	int i, j, offset;
 	uint64_t edid_blob_id;
 	drmModePropertyBlobRes *edid_blob;
-	const struct edid_ext *edid_ext;
-	const struct edid *edid;
-	const struct edid_cea *edid_cea;
-	const char *cea_data;
+	struct di_info *info;
+	const struct di_hdr_static_metadata *hdr_static_metadata;
 	bool ret = false;
 
 	ok = kmstest_get_property(fd, output->id,
@@ -82,30 +54,13 @@ bool igt_is_panel_hdr(int fd, igt_output_t *output)
 	edid_blob = drmModeGetPropertyBlob(fd, edid_blob_id);
 	igt_assert(edid_blob);
 
-	edid = (const struct edid *) edid_blob->data;
-	igt_assert(edid);
-
-	for (i = 0; i < edid->extensions_len; i++) {
-		edid_ext = &edid->extensions[i];
-		edid_cea = &edid_ext->data.cea;
-
-		/* HDR not defined in CTA Extension Version < 3. */
-		if ((edid_ext->tag != EDID_EXT_CEA) ||
-		    (edid_cea->revision != CTA_EXTENSION_VERSION))
-				continue;
-		else {
-			offset = edid_cea->dtd_start;
-			cea_data = edid_cea->data;
-
-			for (j = 0; j < offset; j += (cea_data[j] & 0x1f) + 1) {
-				ret = cta_block(cea_data + j);
+	info = di_info_parse_edid(edid_blob->data, edid_blob->length);
+	igt_assert(info);
+	hdr_static_metadata = di_info_get_hdr_static_metadata(info);
 
-				if (ret)
-					break;
-			}
-		}
-	}
+	ret = hdr_static_metadata->traditional_hdr || hdr_static_metadata->pq;
 
+	di_info_destroy(info);
 	drmModeFreePropertyBlob(edid_blob);
 
 	return ret;
lib/meson.build +1 -0
index 3ed1369b53d1..cb861c472808 100644
@@ -156,6 +156,7 @@ lib_deps = [
 	libkmod,
 	libpci,
 	libudev,
+	libdisplay_info,
 	math,
 	pciaccess,
 	pixman,
meson.build +1 -0
index eec131375e06..e7c685116b13 100644
@@ -151,6 +151,7 @@ build_info += 'Valgrind annotations: @0@'.format(valgrind.found())
 cairo = dependency('cairo', version : '>1.12.0', required : true)
 libpci = dependency('libpci', required : true)
 libudev = dependency('libudev', required : true)
+libdisplay_info = dependency('libdisplay-info', required : true)
 glib = dependency('glib-2.0', required : true)
 
 libtsi = cc.find_library('TSI', required : false)
Signature · 1 line
Jani Nikula, Intel
#2 lore raw
In reply to Simon Ser

Hi Simon,

Quoted 30 lines · Simon Ser

Replace manual EDID/CTA parsing with libdisplay-info [1].

libdisplay-info is an EDID and DisplayID library. It's widely used across Wayland compositors. It exposes both a high-level API (with information collected across EDID/DisplayID/CTA blocks) and a low-level API (exposing individual parsed fields from the specifications).

Using libdisplay-info will allow IGT to drop all of its custom parsing code. libdisplay-info takes care of the bitshifting and value decoding. libdisplay-info has documentation, a test suite, fuzzing, and a clone of edid-decode which can serve as an example to figure out how to use the low-level API.

IGT has already quite a bit of hand-rolled parsing code, and we need to start somewhere, so here is a patch leveraging libdisplay-info for igt_hdr.

As a bonus, igt_hdr now extracts HDR static metadata from CTA DisplayID blocks for free, because the high-level libdisplay-info helper does this already.

[1]: https://gitlab.freedesktop.org/emersion/libdisplay-info

Cc Gil Dekel <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Swati Sharma <[email protected]>
Cc Karthik B S <[email protected]>
Cc Mark Yacoub <[email protected]>
Quoted 10 lines
---
 Dockerfile.build-debian-arm64   |  1 +
 Dockerfile.build-debian-armhf   |  1 +
 Dockerfile.build-debian-minimal |  1 +
 Dockerfile.build-fedora         |  1 +
 lib/igt_hdr.c                   | 63 +++++----------------------------
 lib/meson.build                 |  1 +
 meson.build                     |  1 +
 7 files changed, 15 insertions(+), 54 deletions(-)

Please wait with merging as now it will not build in CI on Ubuntu 20.04 and 22.04.

+cc Ryszard Knop <[email protected]>

Regards,
Kamil

Quoted 58 lines
Dockerfile.build-debian-arm64 +1 -0
index 114b9760d1f6..7a9cd1915825 100644
@@ -26,6 +26,7 @@ RUN apt-get install -y \
 			libpci-dev:arm64 \
 			libpixman-1-dev:arm64 \
 			libudev-dev:arm64 \
+			libdisplay-info-dev:arm64 \
 			libgsl-dev:arm64 \
 			libasound2-dev:arm64 \
 			libjansson-dev:arm64 \
Dockerfile.build-debian-armhf +1 -0
index c6527ea1eb2f..375f3e185bba 100644
@@ -26,6 +26,7 @@ RUN apt-get install -y \
 			libpci-dev:armhf \
 			libpixman-1-dev:armhf \
 			libudev-dev:armhf \
+			libdisplay-info-dev:armhf \
 			libgsl-dev:armhf \
 			libasound2-dev:armhf \
 			libjansson-dev:armhf \
Dockerfile.build-debian-minimal +1 -0
index 573bb5139ceb..1d326250eef9 100644
@@ -17,6 +17,7 @@ RUN apt-get install -y \
 			libpci-dev \
 			libpixman-1-dev \
 			libudev-dev \
+			libdisplay-info-dev \
 			libxrandr-dev \
 			libxv-dev \
 			x11proto-dri2-dev \
Dockerfile.build-fedora +1 -0
index aacc6a87c844..db7618325a67 100644
@@ -14,6 +14,7 @@ RUN dnf install -y \
 	'pkgconfig(cairo)' \
 	'pkgconfig(libpci)' \
 	'pkgconfig(libudev)' \
+	'pkgconfig(libdisplay-info)' \
 	'pkgconfig(glib-2.0)' \
 	'pkgconfig(gsl)' \
 	'pkgconfig(alsa)' \
lib/igt_hdr.c +2 -0
index c0ed9e843163..b8175ceef1f7 100644
@@ -11,6 +11,8 @@
 #include <termios.h>
 #include <unistd.h>
 
+#include <libdisplay-info/info.h>
+

[cut]

#3 lore raw
Quoted 43 lines · Kamil Konieczny

Hi Simon,

Quoted 30 lines · Simon Ser

Replace manual EDID/CTA parsing with libdisplay-info [1].

libdisplay-info is an EDID and DisplayID library. It's widely used across Wayland compositors. It exposes both a high-level API (with information collected across EDID/DisplayID/CTA blocks) and a low-level API (exposing individual parsed fields from the specifications).

Using libdisplay-info will allow IGT to drop all of its custom parsing code. libdisplay-info takes care of the bitshifting and value decoding. libdisplay-info has documentation, a test suite, fuzzing, and a clone of edid-decode which can serve as an example to figure out how to use the low-level API.

IGT has already quite a bit of hand-rolled parsing code, and we need to start somewhere, so here is a patch leveraging libdisplay-info for igt_hdr.

As a bonus, igt_hdr now extracts HDR static metadata from CTA DisplayID blocks for free, because the high-level libdisplay-info helper does this already.

[1]: https://gitlab.freedesktop.org/emersion/libdisplay-info

Cc Gil Dekel <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Swati Sharma <[email protected]>
Cc Karthik B S <[email protected]>
Cc Mark Yacoub <[email protected]>
Quoted 10 lines
---
 Dockerfile.build-debian-arm64   |  1 +
 Dockerfile.build-debian-armhf   |  1 +
 Dockerfile.build-debian-minimal |  1 +
 Dockerfile.build-fedora         |  1 +
 lib/igt_hdr.c                   | 63 +++++----------------------------
 lib/meson.build                 |  1 +
 meson.build                     |  1 +
 7 files changed, 15 insertions(+), 54 deletions(-)
Quoted 2 lines

Please wait with merging as now it will not build in CI on Ubuntu 20.04 and 22.04.

Hey Simon. Intel CI still runs on Ubuntu 20/22.04 and RHEL 8 where we don't have these libs in the repo - could you make this lib optional for now (old impl and new ifdefed with HAVE_LIBDISPLAY_INFO)?

We will likely drop distros older than 24.04/RHEL 9 in the near future, but it's a pain to maintain a single external lib for those distros :<

Ryszard

Quoted 67 lines

+cc Ryszard Knop <[email protected]>

Regards,
Kamil

Quoted 58 lines
Dockerfile.build-debian-arm64 +1 -0
index 114b9760d1f6..7a9cd1915825 100644
@@ -26,6 +26,7 @@ RUN apt-get install -y \
 			libpci-dev:arm64 \
 			libpixman-1-dev:arm64 \
 			libudev-dev:arm64 \
+			libdisplay-info-dev:arm64 \
 			libgsl-dev:arm64 \
 			libasound2-dev:arm64 \
 			libjansson-dev:arm64 \
Dockerfile.build-debian-armhf +1 -0
index c6527ea1eb2f..375f3e185bba 100644
@@ -26,6 +26,7 @@ RUN apt-get install -y \
 			libpci-dev:armhf \
 			libpixman-1-dev:armhf \
 			libudev-dev:armhf \
+			libdisplay-info-dev:armhf \
 			libgsl-dev:armhf \
 			libasound2-dev:armhf \
 			libjansson-dev:armhf \
Dockerfile.build-debian-minimal +1 -0
index 573bb5139ceb..1d326250eef9 100644
@@ -17,6 +17,7 @@ RUN apt-get install -y \
 			libpci-dev \
 			libpixman-1-dev \
 			libudev-dev \
+			libdisplay-info-dev \
 			libxrandr-dev \
 			libxv-dev \
 			x11proto-dri2-dev \
Dockerfile.build-fedora +1 -0
index aacc6a87c844..db7618325a67 100644
@@ -14,6 +14,7 @@ RUN dnf install -y \
 	'pkgconfig(cairo)' \
 	'pkgconfig(libpci)' \
 	'pkgconfig(libudev)' \
+	'pkgconfig(libdisplay-info)' \
 	'pkgconfig(glib-2.0)' \
 	'pkgconfig(gsl)' \
 	'pkgconfig(alsa)' \
lib/igt_hdr.c +2 -0
index c0ed9e843163..b8175ceef1f7 100644
@@ -11,6 +11,8 @@
 #include <termios.h>
 #include <unistd.h>
 
+#include <libdisplay-info/info.h>
+

[cut]

author
#4 lore raw
Quoted 9 lines · Ryszard
Quoted 2 lines

Please wait with merging as now it will not build in CI on Ubuntu 20.04 and 22.04.

Hey Simon. Intel CI still runs on Ubuntu 20/22.04 and RHEL 8 where we don't have these libs in the repo - could you make this lib optional for now (old impl and new ifdefed with HAVE_LIBDISPLAY_INFO)?

We will likely drop distros older than 24.04/RHEL 9 in the near future, but it's a pain to maintain a single external lib for those distros :<

Maintaining two codepaths is a bit of a pain. Could we instead use Meson subprojects for these old distros?

#5 lore raw
Quoted 9 lines · Simon Ser
Quoted 7 lines · Ryszard
Quoted 2 lines

Please wait with merging as now it will not build in CI on Ubuntu 20.04 and 22.04.

Hey Simon. Intel CI still runs on Ubuntu 20/22.04 and RHEL 8 where we don't have these libs in the repo - could you make this lib optional for now (old impl and new ifdefed with HAVE_LIBDISPLAY_INFO)?

Quoted 5 lines
Quoted 2 lines

We will likely drop distros older than 24.04/RHEL 9 in the near future, but it's a pain to maintain a single external lib for those distros :<

Maintaining two codepaths is a bit of a pain. Could we instead use Meson subprojects for these old distros?

That and a Git submodule? Works for me, although maintaining that is also a bit painful. If you can give me a day or two, I'm trying to figure out if there's anyone who still really needs that 20.04 build, maybe it can be avoided entirely.

Ryszard

author
#6 lore raw
Quoted 10 lines · Ryszard
Quoted 9 lines · Simon Ser
Quoted 7 lines · Ryszard
Quoted 2 lines

Please wait with merging as now it will not build in CI on Ubuntu 20.04 and 22.04.

Hey Simon. Intel CI still runs on Ubuntu 20/22.04 and RHEL 8 where we don't have these libs in the repo - could you make this lib optional for now (old impl and new ifdefed with HAVE_LIBDISPLAY_INFO)?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

We will likely drop distros older than 24.04/RHEL 9 in the near future, but it's a pain to maintain a single external lib for those distros :<

Maintaining two codepaths is a bit of a pain. Could we instead use Meson subprojects for these old distros?

That and a Git submodule? Works for me, although maintaining that is also a bit painful.

Not a Git submodule, but just a matter of dropping this into a subprojects/libdisplay-info.wrap file:

    [wrap-git]
    url = https://gitlab.freedesktop.org/emersion/libdisplay-info.git
    revision = 0.4.0

Then Meson will automatically download it at build time if the system version isn't available (or new enough according to the dependency version requirements, which might be useful if IGT needs a recent libdisplay-info in the future).

Quoted 3 lines

If you can give me a day or two, I'm trying to
figure out if there's anyone who still really needs that 20.04 build, maybe it can be avoided entirely.

I'm perfectly fine waiting for a bit (but maybe Gil Dekel has a deadline?).

#7 lore raw

Hi Simon,

Quoted 24 lines · Simon Ser
Quoted 10 lines · Ryszard
Quoted 9 lines · Simon Ser
Quoted 7 lines · Ryszard
Quoted 2 lines

Please wait with merging as now it will not build in CI on Ubuntu 20.04 and 22.04.

Hey Simon. Intel CI still runs on Ubuntu 20/22.04 and RHEL 8 where we don't have these libs in the repo - could you make this lib optional for now (old impl and new ifdefed with HAVE_LIBDISPLAY_INFO)?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

We will likely drop distros older than 24.04/RHEL 9 in the near future, but it's a pain to maintain a single external lib for those distros :<

Maintaining two codepaths is a bit of a pain. Could we instead use Meson subprojects for these old distros?

That and a Git submodule? Works for me, although maintaining that is also a bit painful.

Not a Git submodule, but just a matter of dropping this into a subprojects/libdisplay-info.wrap file:

Quoted 9 lines
    [wrap-git]
    url = https://gitlab.freedesktop.org/emersion/libdisplay-info.git
    revision = 0.4.0

Then Meson will automatically download it at build time if the system version isn't available (or new enough according to the dependency version requirements, which might be useful if IGT needs a recent libdisplay-info in the future).

There are some distros which disable downloading during build, so this will not work for them.

Regards,
Kamil

Quoted 6 lines
Quoted 3 lines

If you can give me a day or two, I'm trying to
figure out if there's anyone who still really needs that 20.04 build, maybe it can be avoided entirely.

I'm perfectly fine waiting for a bit (but maybe Gil Dekel has a deadline?).

author
#8 lore raw
Quoted 30 lines · Kamil Konieczny

Hi Simon,

Quoted 28 lines · Simon Ser
Quoted 10 lines · Ryszard
Quoted 9 lines · Simon Ser
Quoted 7 lines · Ryszard
Quoted 2 lines

Please wait with merging as now it will not build in CI on Ubuntu 20.04 and 22.04.

Hey Simon. Intel CI still runs on Ubuntu 20/22.04 and RHEL 8 where we don't have these libs in the repo - could you make this lib optional for now (old impl and new ifdefed with HAVE_LIBDISPLAY_INFO)?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

We will likely drop distros older than 24.04/RHEL 9 in the near future, but it's a pain to maintain a single external lib for those distros :<

Maintaining two codepaths is a bit of a pain. Could we instead use Meson subprojects for these old distros?

That and a Git submodule? Works for me, although maintaining that is also a bit painful.

Not a Git submodule, but just a matter of dropping this into a subprojects/libdisplay-info.wrap file:

    [wrap-git]
    url = https://gitlab.freedesktop.org/emersion/libdisplay-info.git
    revision = 0.4.0
Quoted 8 lines
Quoted 5 lines

Then Meson will automatically download it at build time if the system version isn't available (or new enough according to the dependency version requirements, which might be useful if IGT needs a recent libdisplay-info in the future).

There are some distros which disable downloading during build, so this will not work for them.

Subproject downloads are purely optional, and I would indeed expect distros to disable that (ie, always use system deps). This can be done by setting the wrap_mode=nodownload option. We can set that in our meson.build if we want to opt out of Meson's default behavior. "meson subprojects download" can be used to manually download subprojects prior to the build step.

tl;dr the wrap file would be useful for developers and CI, not for distros.

#9 lore raw
In reply to Simon Ser

Hi Simon,

Quoted 1 line · Simon Ser

Replace manual EDID/CTA parsing with libdisplay-info [1].

[...]

Quoted 3 lines

As a bonus, igt_hdr now extracts HDR static metadata from CTA DisplayID blocks for free, because the high-level libdisplay-info helper does this already.

Thanks for putting this together - no deadline on my side, so no rush.

I tested the lib/igt_hdr.c change against libdisplay-info 0.4.0 on the Intel xe eDP OLED panel from my series (HDR static metadata in a DisplayID 2.0 CTA data block, no CTA-861 extension):
- kms_hdr@invalid-hdr: FAIL -> SKIP
- kms_hdr@invalid-metadata-sizes: SKIP -> SUCCESS
- kms_hdr@bpc-switch: SUCCESS -> SUCCESS

I'll drop patches 1/3 and 2/3 of my series in favor of this. A few comments inline below.

[...]

lib/igt_hdr.c line 14

Quoted 9 lines
lib/igt_hdr.c +1 -0
index c0ed9e843163..b8175ceef1f7 100644
@@ -11,6 +11,8 @@
 #include <termios.h>
 #include <unistd.h>
 
+#include <libdisplay-info/info.h>

Nit: #include "igt_edid.h" (at line 7, and in lib/igt_hdr.h) looks unused now.

[...]

lib/igt_hdr.c static bool cta_block(const char *edid_ext) · line 38

Quoted 5 lines
lib/igt_hdr.c +0 -0
 /**
  * igt_is_panel_hdr:
  * @fd: DRM file descriptor
@@ -63,13 +38,10 @@ static bool cta_block(const char *edid_ext)
 bool igt_is_panel_hdr(int fd, igt_output_t *output)

Nit: the doc comment right above igt_is_panel_hdr() still says "in the CTA extension".

[...]

lib/igt_hdr.c bool igt_is_panel_hdr(int fd, igt_output_t *output) · line 58

Quoted 2 lines
lib/igt_hdr.c +2 -0
+	info = di_info_parse_edid(edid_blob->data, edid_blob->length);
+	igt_assert(info);

di_info_parse_edid() returns NULL when an EDID fails its base-block checksum, so igt_assert(info) fails the test where the old code returned false. Would it make sense to warn and return false when !info instead of asserting?

[...]

meson.build build_info += 'Valgrind annotations: @0@'.format(valgrind.found()) · line 154

Quoted 9 lines
meson.build +1 -0
index eec131375e06..e7c685116b13 100644
@@ -151,6 +151,7 @@ build_info += 'Valgrind annotations: @0@'.format(valgrind.found())
 cairo = dependency('cairo', version : '>1.12.0', required : true)
 libpci = dependency('libpci', required : true)
 libudev = dependency('libudev', required : true)
+libdisplay_info = dependency('libdisplay-info', required : true)

DisplayID CTA HDR parsing landed in libdisplay-info 0.4.0; 0.2.0 and 0.3.0 only check CTA-861 extensions (and return pq=0 on this panel's EDID). Since build-fedora currently pulls 0.3.0, could this require version : '>= 0.4.0' so Meson also falls back to your 0.4.0 wrap there?

Happy to add my R-b and T-b once we settle on these.

Thanks,
Gil

author
#10 lore raw
Quoted 2 lines · Gil Dekel

I'll drop patches 1/3 and 2/3 of my series in favor of this. A few comments inline below.

Thanks for the review! I'll be sending v2 shortly.

Quoted 8 lines
Quoted 8 lines
lib/igt_hdr.c +0 -0
index c0ed9e843163..b8175ceef1f7 100644
@@ -11,6 +11,8 @@
 #include <termios.h>
 #include <unistd.h>
 
Quoted 4 lines

lib/igt_hdr.c line 14

Quoted 1 line
lib/igt_hdr.c +1 -0
+#include <libdisplay-info/info.h>

Nit: #include "igt_edid.h" (at line 7, and in lib/igt_hdr.h) looks unused now.

Good catch! Removed both.

Quoted 8 lines

lib/igt_hdr.c static bool cta_block(const char *edid_ext) · line 38

Quoted 5 lines
lib/igt_hdr.c +0 -0
 /**
  * igt_is_panel_hdr:
  * @fd: DRM file descriptor
@@ -63,13 +38,10 @@ static bool cta_block(const char *edid_ext)
 bool igt_is_panel_hdr(int fd, igt_output_t *output)

Nit: the doc comment right above igt_is_panel_hdr() still says "in the CTA extension".

I've reworded this section to be a bit more explicit, explaining that a CTA extension may be inside the base EDID, or nested inside a DisplayID extension).

Quoted 7 lines

lib/igt_hdr.c bool igt_is_panel_hdr(int fd, igt_output_t *output) · line 58

Quoted 2 lines
lib/igt_hdr.c +2 -0
+	info = di_info_parse_edid(edid_blob->data, edid_blob->length);
+	igt_assert(info);

di_info_parse_edid() returns NULL when an EDID fails its base-block checksum, so igt_assert(info) fails the test where the old code returned false. Would it make sense to warn and return false when !info instead of asserting?

Yup, I've done that!

Quoted 6 lines
Quoted 6 lines
meson.build +0 -0
index eec131375e06..e7c685116b13 100644
@@ -151,6 +151,7 @@ build_info += 'Valgrind annotations: @0@'.format(valgrind.found())
 cairo = dependency('cairo', version : '>1.12.0', required : true)
Quoted 8 lines

meson.build build_info += 'Valgrind annotations: @0@'.format(valgrind.found()) · line 154

Quoted 3 lines
meson.build +1 -0
 libpci = dependency('libpci', required : true)
 libudev = dependency('libudev', required : true)
+libdisplay_info = dependency('libdisplay-info', required : true)

DisplayID CTA HDR parsing landed in libdisplay-info 0.4.0; 0.2.0 and 0.3.0 only check CTA-861 extensions (and return pq=0 on this panel's EDID). Since build-fedora currently pulls 0.3.0, could this require version : '>= 0.4.0' so Meson also falls back to your 0.4.0 wrap there?

I've added a patch with the version bump and the wrap file. (Feel free to let me know if you'd rather have it squashed into the previous commit.)

Simon