public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Murthy, Arun R" <arun.r.murthy@intel.com>
To: Kunal Joshi <kunal1.joshi@intel.com>, <igt-dev@lists.freedesktop.org>
Subject: Re: [i-g-t,1/6] lib/igt_edid: add EDID serial extraction helpers
Date: Mon, 9 Mar 2026 15:00:03 +0530	[thread overview]
Message-ID: <64b4bad8-09ff-4c5c-81d8-7d6767f4c472@intel.com> (raw)
In-Reply-To: <20260225212859.876713-2-kunal1.joshi@intel.com>

On 26-02-2026 02:58, Kunal Joshi wrote:
> Add helpers to extract serial identification from EDID data.
>
>   - edid_get_serial_string(): extract ASCII serial from descriptor 0xFF
>   - edid_get_serial_number(): extract 32-bit serial from EDID header
>   - edid_get_any_serial(): convenience helper that tries ASCII serial
>     first, then falls back to 32-bit header serial formatted as hex
>
> These are needed by the connector helper and USB4 switch test suite
> for EDID-based display verification after dock/undock events.
>
> Signed-off-by: Kunal Joshi <kunal1.joshi@intel.com>
> ---
>   lib/igt_edid.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++
>   lib/igt_edid.h |  5 +++
>   2 files changed, 96 insertions(+)
>
> diff --git a/lib/igt_edid.c b/lib/igt_edid.c
> index c68ccf671..e7fcbf0b9 100644
> --- a/lib/igt_edid.c
> +++ b/lib/igt_edid.c
> @@ -249,6 +249,97 @@ void edid_get_monitor_name(const struct edid *edid, char *name, size_t name_size
>   	name[0] = '\0';
>   }
>   
> +/**
> + * edid_get_serial_string:
> + * @edid: EDID structure
> + * @serial: buffer to write serial string
> + * @serial_size: size of serial buffer; must be > 1
> + *
> + * Extract the serial string from EDID descriptor block type 0xFF.
> + * The descriptor payload is a 13-byte fixed-width field; trailing
> + * whitespace is stripped and the result is NUL-terminated.
> + * @serial is left empty when no 0xFF descriptor is found.
> + */
> +void edid_get_serial_string(const struct edid *edid,
> +			    char *serial, size_t serial_size)
We are trying to get the timings so rather than a generic name 
serial_string, can this be replaced with get_detailed_timings ?
> +{
> +	size_t copy_len, i, n;
> +
> +	igt_assert(edid);
> +	igt_assert(serial);
> +	igt_assert(serial_size > 1);
> +	serial[0] = '\0';
> +
> +	for (i = 0; i < DETAILED_TIMINGS_LEN; i++) {
> +		const uint8_t *d = (const uint8_t *)&edid->detailed_timings[i];
> +
> +		if (d[0] != 0x00 || d[1] != 0x00 || d[2] != 0x00)
> +			continue;
> +
> +		if (d[3] != EDID_DETAIL_MONITOR_SERIAL || d[4] != 0x00)
> +			continue;
> +
> +		/* Descriptor string payload is 13 bytes starting at d[5] */
> +		copy_len = serial_size - 1 < 13 ? serial_size - 1 : 13;
> +		memcpy(serial, &d[5], copy_len);
Can strncpy() be used instead?
> +		serial[copy_len] = '\0';
> +
> +		for (n = strlen(serial);
> +		     n > 0 && isspace((unsigned char)serial[n - 1]); n--)
> +			serial[n - 1] = '\0';
> +
> +		return;
> +	}
> +}
> +
> +/**
> + * edid_get_serial_number:
> + * @edid: EDID structure
> + *
> + * Extract the 32-bit serial number from the EDID base block header
> + * (bytes 12–15, the manufacturer/product section).  This is different
> + * from the ASCII serial string in descriptor block 0xFF.
> + *
> + * Returns: 32-bit serial number (little-endian), 0 if absent.
> + */
> +uint32_t edid_get_serial_number(const struct edid *edid)
> +{
> +	return (uint32_t)edid->serial[0] |
> +	       ((uint32_t)edid->serial[1] << 8) |
> +	       ((uint32_t)edid->serial[2] << 16) |
> +	       ((uint32_t)edid->serial[3] << 24);
> +}
> +
> +/**
> + * edid_get_any_serial:
No description added?

Thanks and Regards,
Arun R Murthy
--------------------
> + * @edid: EDID structure
> + * @serial: buffer to write serial string
> + * @serial_size: size of serial buffer; must be > 1
> + *
> + * Convenience helper that tries to extract a serial identifier from EDID.
> + * First tries the ASCII serial string descriptor (0xFF). If that is empty,
> + * falls back to the 32-bit header serial number formatted as 8-char hex.
> + * If neither source provides a usable serial (no 0xFF descriptor and the
> + * header serial is 0), @serial is left empty.
> + */
> +void edid_get_any_serial(const struct edid *edid,
> +			 char *serial, size_t serial_size)
> +{
> +	uint32_t serial_num;
> +
> +	igt_assert(edid);
> +	igt_assert(serial);
> +	igt_assert(serial_size > 1);
> +
> +	edid_get_serial_string(edid, serial, serial_size);
> +	if (serial[0])
> +		return;
> +
> +	serial_num = edid_get_serial_number(edid);
> +	if (serial_num != 0)
> +		snprintf(serial, serial_size, "%08X", serial_num);
> +}
> +
>   static void edid_set_mfg(struct edid *edid, const char mfg[static 3])
>   {
>   	edid->mfg_id[0] = (mfg[0] - '@') << 2 | (mfg[1] - '@') >> 3;
> diff --git a/lib/igt_edid.h b/lib/igt_edid.h
> index be0ccf529..d9e396065 100644
> --- a/lib/igt_edid.h
> +++ b/lib/igt_edid.h
> @@ -457,5 +457,10 @@ void *dispid_block_tiled(void *ptr,
>   			 int hsize, int vsize,
>   			 const char *topology_id);
>   void edid_get_monitor_name(const struct edid *edid, char *name, size_t name_size);
> +void edid_get_serial_string(const struct edid *edid,
> +			    char *serial, size_t serial_size);
> +uint32_t edid_get_serial_number(const struct edid *edid);
> +void edid_get_any_serial(const struct edid *edid,
> +			 char *serial, size_t serial_size);
>   
>   #endif

  reply	other threads:[~2026-03-09  9:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 21:28 [PATCH i-g-t 0/6] add test to validate dock/undock and switch Kunal Joshi
2026-02-25 21:28 ` [PATCH i-g-t 1/6] lib/igt_edid: add EDID serial extraction helpers Kunal Joshi
2026-03-09  9:30   ` Murthy, Arun R [this message]
2026-03-09 11:02     ` [i-g-t,1/6] " Joshi, Kunal1
2026-03-16  3:03       ` Murthy, Arun R
2026-02-25 21:28 ` [PATCH i-g-t 2/6] lib/igt_connector_helper: Add generic connector helpers Kunal Joshi
2026-03-09  9:38   ` [i-g-t,2/6] " Murthy, Arun R
2026-03-09 11:06     ` Joshi, Kunal1
2026-03-16  3:17       ` Murthy, Arun R
2026-02-25 21:28 ` [PATCH i-g-t 3/6] lib/igt_serial: add generic serial communication helper Kunal Joshi
2026-03-16  5:40   ` [i-g-t,3/6] " Murthy, Arun R
2026-02-25 21:28 ` [PATCH i-g-t 4/6] lib/igt_usb4_switch: add helper library for USB4 Switch 3141 Kunal Joshi
2026-03-16  8:45   ` [i-g-t,4/6] " Murthy, Arun R
2026-02-25 21:28 ` [PATCH i-g-t 5/6] tests/kms_feature_discovery: add basic usb4 switch discovery Kunal Joshi
2026-03-09 10:05   ` [i-g-t,5/6] " Murthy, Arun R
2026-02-25 21:28 ` [PATCH i-g-t 6/6] tests/intel/kms_usb4_switch: Add USB4 switch test suite Kunal Joshi
2026-03-09 10:03   ` [i-g-t,6/6] " Murthy, Arun R
2026-03-09 11:14     ` Joshi, Kunal1
2026-03-16  3:38       ` Murthy, Arun R
2026-02-26  2:20 ` ✗ Xe.CI.BAT: failure for add test to validate dock/undock and switch (rev3) Patchwork
2026-02-26  3:04 ` ✓ i915.CI.BAT: success " Patchwork
2026-02-26  6:52 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-02-26  7:45 ` ✗ i915.CI.Full: " 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=64b4bad8-09ff-4c5c-81d8-7d6767f4c472@intel.com \
    --to=arun.r.murthy@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kunal1.joshi@intel.com \
    /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