From: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 1/2] igt_eld: Add eld_is_igt
Date: Fri, 20 Sep 2019 13:47:29 +0300 [thread overview]
Message-ID: <20190920104730.3958-1-arkadiusz.hiler@intel.com> (raw)
From: Simon Ser <simon.ser@intel.com>
This function parses the monitor name from an ELD blob and checks whether it
comes from an IGT EDID.
v2: replace a bunch of random numbers with constants (Chris, Andi)
v3: rabase and fix subject (Arek)
Signed-off-by: Simon Ser <simon.ser@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Andi Shyti <andi.shyti@intel.com>
Cc: Martin Peres <martin.peres@linux.intel.com>
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
lib/igt_eld.c | 29 +++++++++++++++++++++++++++++
lib/igt_eld.h | 1 +
2 files changed, 30 insertions(+)
diff --git a/lib/igt_eld.c b/lib/igt_eld.c
index 23ebf630..ef6625df 100644
--- a/lib/igt_eld.c
+++ b/lib/igt_eld.c
@@ -283,3 +283,32 @@ bool eld_is_supported(void)
return has_elds;
}
+
+#define ELD_MAX_SIZE 256
+#define MONITOR_NAME_OFFSET 20
+#define MONITOR_NAME_MAX_SIZE 16
+
+/** 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[MONITOR_NAME_MAX_SIZE + 1];
+ int name_size;
+
+ igt_assert_f(eld_size >= MONITOR_NAME_OFFSET &&
+ eld_size <= ELD_MAX_SIZE,
+ "Invalid ELD size: %zu\n", eld_size);
+
+ name_size = eld[4] & 0x1F;
+ igt_assert_f(name_size <= MONITOR_NAME_MAX_SIZE &&
+ MONITOR_NAME_OFFSET + 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[MONITOR_NAME_OFFSET], 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 4b917a62..30d7012d 100644
--- a/lib/igt_eld.h
+++ b/lib/igt_eld.h
@@ -52,5 +52,6 @@ struct eld_entry {
bool eld_is_supported(void);
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.21.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next reply other threads:[~2019-09-20 10:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-20 10:47 Arkadiusz Hiler [this message]
2019-09-20 10:47 ` [igt-dev] [PATCH i-g-t 2/2] lib/igt_alsa: Check that ELD comes from IGT Arkadiusz Hiler
2019-09-20 12:06 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] igt_eld: Add eld_is_igt Patchwork
2019-09-21 4:48 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190920104730.3958-1-arkadiusz.hiler@intel.com \
--to=arkadiusz.hiler@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox