[i-g-t 2/5] lib/igt_edid: Helper to read monitor range from EDID

Bhanuprakash Modem bhanuprakash.modem at intel.com
Fri Mar 4 05:08:05 UTC 2022


Add a helper function to read Monitor's range capability
from EDID.

V2:
* Check for flag range limits only.
V3:
* Add documentation
* Return from single place

Cc: Manasi Navare <manasi.d.navare at intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
---
 lib/igt_edid.c | 40 ++++++++++++++++++++++++++++++++++++++++
 lib/igt_edid.h |  2 ++
 2 files changed, 42 insertions(+)

diff --git a/lib/igt_edid.c b/lib/igt_edid.c
index df346c4c8c..a3c1baf11f 100644
--- a/lib/igt_edid.c
+++ b/lib/igt_edid.c
@@ -160,6 +160,46 @@ void detailed_timing_set_monitor_range_mode(struct detailed_timing *dt,
 	       sizeof(monitor_range_padding));
 }
 
+struct detailed_data_monitor_range
+detailed_timing_get_monitor_range(const struct edid *edid)
+{
+	uint8_t i;
+	struct detailed_data_monitor_range mr = {0, 0};
+
+	for (i = 0; i < DETAILED_TIMINGS_LEN; i++) {
+		struct detailed_non_pixel *other_data;
+		struct detailed_timing timings = edid->detailed_timings[i];
+
+		/*
+		 * From EDID Display Range Limits Descriptor specs:
+		 *
+		 * Bytes	Description
+		 *  0–1		00 00 = Display Descriptor
+		 *   2		00 = reserved
+		 *   3		FD = Display Range Limits Descriptor
+		 *   10		01 = No timing information.
+		 *
+		 */
+		if (timings.pixel_clock[0] != 0x00 &&
+		    timings.pixel_clock[1] != 0x00)
+			continue;
+
+		other_data = &timings.data.other_data;
+		if (other_data->pad1 != 0x00 ||
+		    other_data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+
+		/* Check for flag range limits only. */
+		if (other_data->data.range.flags != 0x01)
+			continue;
+
+		mr = other_data->data.range;
+		break;
+	}
+
+	return mr;
+}
+
 /**
  * detailed_timing_set_string: set a detailed timing to be a string
  */
diff --git a/lib/igt_edid.h b/lib/igt_edid.h
index aac2f4a208..e412479d84 100644
--- a/lib/igt_edid.h
+++ b/lib/igt_edid.h
@@ -381,6 +381,8 @@ void detailed_timing_set_mode(struct detailed_timing *dt, drmModeModeInfo *mode,
 			      int width_mm, int height_mm);
 void detailed_timing_set_monitor_range_mode(struct detailed_timing *dt,
 					    drmModeModeInfo *mode);
+struct detailed_data_monitor_range detailed_timing_get_monitor_range(
+				const struct edid *edid);
 void detailed_timing_set_string(struct detailed_timing *dt,
 				enum detailed_non_pixel_type type,
 				const char *str);
-- 
2.35.1



More information about the Intel-gfx-trybot mailing list