public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 1/2] igt_eld: add igt_is_igt
@ 2019-09-12 10:28 Simon Ser
  2019-09-12 10:28 ` [igt-dev] [PATCH i-g-t 2/2] lib/igt_alsa: check ELD comes from IGT Simon Ser
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Simon Ser @ 2019-09-12 10:28 UTC (permalink / raw)
  To: igt-dev

This function parses the monitor name from an ELD blob and checks whether it
comes from an IGT EDID.

Signed-off-by: Simon Ser <simon.ser@intel.com>
---
 lib/igt_eld.c | 23 +++++++++++++++++++++++
 lib/igt_eld.h |  1 +
 2 files changed, 24 insertions(+)

diff --git a/lib/igt_eld.c b/lib/igt_eld.c
index 16c4ac06c6f6..640496b0a160 100644
--- a/lib/igt_eld.c
+++ b/lib/igt_eld.c
@@ -262,3 +262,26 @@ bool eld_has_igt(void)
 	struct eld_entry eld;
 	return eld_get_igt(&eld);
 }
+
+/** eld_is_igt: check whether the ELD blob comes from an IGT EDID */
+bool eld_is_igt(const char *eld, size_t eld_size)
+{
+	char name[17];
+	int name_size;
+
+	igt_assert_f(eld_size >= 20 && eld_size <= 256,
+		     "Invalid ELD size: %zu\n", eld_size);
+
+	name_size = eld[4] & 0x1F;
+	igt_assert_f(name_size <= 16 && 20 + name_size <= eld_size,
+		     "Invalid monitor name size in ELD: %d\n", name_size);
+	if (name_size == 0) {
+		igt_debug("ELD doesn't contain a monitor name\n");
+		return false;
+	}
+
+	memcpy(name, &eld[20], name_size);
+	name[name_size] = '\0';
+	igt_debug("Checking ELD with monitor name: %s\n", name);
+	return strcmp(name, "IGT") == 0;
+}
diff --git a/lib/igt_eld.h b/lib/igt_eld.h
index 7c4489f054f1..36f000abe3f9 100644
--- a/lib/igt_eld.h
+++ b/lib/igt_eld.h
@@ -51,5 +51,6 @@ struct eld_entry {
 
 bool eld_get_igt(struct eld_entry *eld);
 bool eld_has_igt(void);
+bool eld_is_igt(const char *eld, size_t eld_size);
 
 #endif
-- 
2.23.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-09-13 11:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-12 10:28 [igt-dev] [PATCH i-g-t 1/2] igt_eld: add igt_is_igt Simon Ser
2019-09-12 10:28 ` [igt-dev] [PATCH i-g-t 2/2] lib/igt_alsa: check ELD comes from IGT Simon Ser
2019-09-12 10:53 ` [igt-dev] [PATCH i-g-t 1/2] igt_eld: add igt_is_igt Chris Wilson
2019-09-12 11:41 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] " Patchwork
2019-09-12 15:01 ` [igt-dev] [PATCH i-g-t 1/2] " Andi Shyti
2019-09-12 15:44 ` [igt-dev] [PATCH i-g-t v2] " Simon Ser
2019-09-13 11:08   ` Ser, Simon
2019-09-12 16:37 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v2] igt_eld: add igt_is_igt (rev2) Patchwork
2019-09-12 20:11 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/2] igt_eld: add igt_is_igt Patchwork
2019-09-13  5:39 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,v2] igt_eld: add igt_is_igt (rev2) Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox