[PATCH i-g-t 1/2] tests/kms_color_helper: Read deep-color capability from EDID

Bhanuprakash Modem bhanuprakash.modem at intel.com
Fri Jan 7 12:00:30 UTC 2022


Add a helper function to read the panel's deep-color capability
from EDID.

https://glenwing.github.io/docs/VESA-EEDID-A2.pdf
(3.6.1 Video Input Definition: 1 Byte)

-----------------------------------------------------------------
| 7 | 6 5 4 3 2 1 0 | Video Signal Interface: Bit 7             |
|---|---------------|-------------------------------------------|
| 1 | x x x x x x x | Input is a Digital Video Signal Interface |
-----------------------------------------------------------------

-----------------------------------------------------
| 7 | 6 5 4 | 3 2 1 0 | Color Bit Depth: Bits 6 → 4 |
|---|-------|---------|-----------------------------|
| 1 | 0 0 0 | x x x x | Color Bit Depth is undefined|
| 1 | 0 0 1 | x x x x | 6 Bits per Primary Color    |
| 1 | 0 1 0 | x x x x | 8 Bits per Primary Color    |
| 1 | 0 1 1 | x x x x | 10 Bits per Primary Color   |
| 1 | 1 0 0 | x x x x | 12 Bits per Primary Color   |
| 1 | 1 0 1 | x x x x | 14 Bits per Primary Color   |
| 1 | 1 1 0 | x x x x | 16 Bits per Primary Color   |
| 1 | 1 1 1 | x x x x | Reserved (Do Not Use)       |
|---|-------|---------|-----------------------------|

For deep-color we need atleast 10-bits.

Cc: Uma Shankar <uma.shankar at intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
---
 tests/kms_color_helper.c | 57 ++++++++++++++++++++++++++++++++++++++++
 tests/kms_color_helper.h |  3 +++
 2 files changed, 60 insertions(+)

diff --git a/tests/kms_color_helper.c b/tests/kms_color_helper.c
index d71e7bb2e6..9ca266dd3a 100644
--- a/tests/kms_color_helper.c
+++ b/tests/kms_color_helper.c
@@ -24,6 +24,63 @@
 
 #include "kms_color_helper.h"
 
+bool
+is_panel_supports_deep_color(int fd, drmModeConnector *connector)
+{
+	uint64_t edid_blob_id;
+	const struct edid *edid;
+	uint8_t bit_depth;
+	drmModePropertyBlobPtr edid_blob = NULL;
+
+	igt_assert(kmstest_get_property(fd, connector->connector_id,
+					DRM_MODE_OBJECT_CONNECTOR, "EDID", NULL,
+					&edid_blob_id, NULL));
+	igt_assert(edid_blob = drmModeGetPropertyBlob(fd, edid_blob_id));
+
+	edid = (const struct edid *) edid_blob->data;
+	bit_depth = edid->input;
+	drmModeFreePropertyBlob(edid_blob);
+
+	/*
+	 * https://glenwing.github.io/docs/VESA-EEDID-A2.pdf
+	 * (3.6.1 Video Input Definition: 1 Byte)
+	 *
+	 * -----------------------------------------------------------------
+	 * | 7 | 6 5 4 3 2 1 0 | Video Signal Interface: Bit 7             |
+	 * |---|---------------|-------------------------------------------|
+	 * | 1 | x x x x x x x | Input is a Digital Video Signal Interface |
+	 * -----------------------------------------------------------------
+	 *
+	 * -----------------------------------------------------
+	 * | 7 | 6 5 4 | 3 2 1 0 | Color Bit Depth: Bits 6 → 4 |
+	 * |---|-------|---------|-----------------------------|
+	 * | 1 | 0 0 0 | x x x x | Color Bit Depth is undefined|
+	 * | 1 | 0 0 1 | x x x x | 6 Bits per Primary Color    |
+	 * | 1 | 0 1 0 | x x x x | 8 Bits per Primary Color    |
+	 * | 1 | 0 1 1 | x x x x | 10 Bits per Primary Color   |
+	 * | 1 | 1 0 0 | x x x x | 12 Bits per Primary Color   |
+	 * | 1 | 1 0 1 | x x x x | 14 Bits per Primary Color   |
+	 * | 1 | 1 1 0 | x x x x | 16 Bits per Primary Color   |
+	 * | 1 | 1 1 1 | x x x x | Reserved (Do Not Use)       |
+	 * -----------------------------------------------------
+	 *
+	 * For deep-color we need atleast 10-bits.
+	 */
+
+	if (!(bit_depth & (1 << 7)))
+		return false;
+	if (((bit_depth & (7 << 4)) >> 4) >= 3)
+		return true;
+
+	return false;
+}
+
+bool is_max_bpc_supported(igt_output_t *output)
+{
+	return igt_output_has_prop(output, IGT_CONNECTOR_MAX_BPC) &&
+		igt_output_get_prop(output, IGT_CONNECTOR_MAX_BPC);
+}
+
 void paint_gradient_rectangles(data_t *data,
 			       drmModeModeInfo *mode,
 			       color_t *colors,
diff --git a/tests/kms_color_helper.h b/tests/kms_color_helper.h
index bb6f0054f3..992087ac9c 100644
--- a/tests/kms_color_helper.h
+++ b/tests/kms_color_helper.h
@@ -36,6 +36,7 @@
 #include "drm.h"
 #include "drmtest.h"
 #include "igt.h"
+#include "igt_edid.h"
 
 
 /* Internal */
@@ -64,6 +65,8 @@ typedef struct {
 	color_t coeffs[];
 } gamma_lut_t;
 
+bool is_panel_supports_deep_color(int fd, drmModeConnector *connector);
+bool is_max_bpc_supported(igt_output_t *output);
 void paint_gradient_rectangles(data_t *data,
 			       drmModeModeInfo *mode,
 			       color_t *colors,
-- 
2.32.0



More information about the Intel-gfx-trybot mailing list