On Wed, 25 Nov 2026, Ville Syrjala <[email protected]> wrote: > From: Ville Syrjälä <[email protected]> > > Add drm_displayid_get_product_id() as the DisplayID based > counterpart to the already existing EDID base block based > drm_edid_get_product_id(). > > In DisplayID the information is stored in the "Product ID" > block (0x00 or 0x20). The layout is slightly different to the > EDID one as the vendor ID is a three byte OUI isntead of > the compressed ASCII EISA/PNPID of EDID. The "year of > manufacture" is now relative to the year 2000, as opposed > to 1990 for EDID. > > There is also a product ID string, but I decided to leave that > out from the user visible struct because the variable length > would just complicate things.
Seems fine, can be updated later. > > Signed-off-by: Ville Syrjälä <[email protected]> > --- > drivers/gpu/drm/drm_displayid_internal.h | 11 ++++++ > drivers/gpu/drm/drm_edid.c | 49 ++++++++++++++++++++++++ > include/drm/drm_edid.h | 10 +++++ > 3 files changed, 70 insertions(+) > > diff --git a/drivers/gpu/drm/drm_displayid_internal.h > b/drivers/gpu/drm/drm_displayid_internal.h > index ef7e6c9bd4db..2177c19cae4c 100644 > --- a/drivers/gpu/drm/drm_displayid_internal.h > +++ b/drivers/gpu/drm/drm_displayid_internal.h > @@ -103,6 +103,17 @@ struct displayid_block { > u8 num_bytes; > } __packed; > > +struct displayid_product_id_block { > + struct displayid_block base; > + u8 vendor_id[3]; > + __le16 product_code; > + __le32 serial_number; > + u8 week_of_manufacture; > + u8 year_of_manufacture; > + u8 size_of_product_id_string; > + u8 product_id_string[]; > +} __packed; > + > struct displayid_tiled_block { > struct displayid_block base; > u8 tile_cap; > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c > index b8f882a17c8f..8bde2a9cebb4 100644 > --- a/drivers/gpu/drm/drm_edid.c > +++ b/drivers/gpu/drm/drm_edid.c > @@ -2791,6 +2791,55 @@ void drm_edid_get_product_id(const struct drm_edid > *drm_edid, > } > EXPORT_SYMBOL(drm_edid_get_product_id); > > +static bool displayid_is_product_id_block(const struct displayid_iter *iter, > + const struct displayid_block *block) > +{ > + return (displayid_version(iter) < DISPLAY_ID_STRUCTURE_VER_20 && > + block->tag == DATA_BLOCK_PRODUCT_ID) || > + (displayid_version(iter) == DISPLAY_ID_STRUCTURE_VER_20 && > + block->tag == DATA_BLOCK_2_PRODUCT_ID); > +} I'm sure I have a branch somewhere adding a generic function for matching the data blocks... need to find and post it one of these days... > + > +/** > + * drm_displayid_get_product_id - Get the vendor and product identification > from DisplayID > + * @drm_edid: EDID > + * @id: Where to place the product id > + */ > +void drm_displayid_get_product_id(const struct drm_edid *drm_edid, > + struct drm_displayid_product_id *id) > +{ > + const struct displayid_block *block; > + struct displayid_iter iter; > + > + memset(id, 0, sizeof(*id)); > + > + if (!drm_edid) > + return; > + > + displayid_iter_edid_begin(drm_edid, &iter); > + displayid_iter_for_each(block, &iter) { > + const struct displayid_product_id_block *prod_id = > + (struct displayid_product_id_block *)block; > + > + if (!displayid_is_product_id_block(&iter, block)) > + continue; > + > + if (block->num_bytes < sizeof(*prod_id) - sizeof(prod_id->base)) > + continue; > + > + id->vendor_id[0] = prod_id->vendor_id[0]; > + id->vendor_id[1] = prod_id->vendor_id[1]; > + id->vendor_id[2] = prod_id->vendor_id[2]; > + id->product_code = prod_id->product_code; > + id->serial_number = prod_id->serial_number; > + id->week_of_manufacture = prod_id->week_of_manufacture; > + id->year_of_manufacture = prod_id->year_of_manufacture; > + break; > + } > + displayid_iter_end(&iter); Pedantically the spec says the product id block needs to be the first data block in the base section. But I think it's not a big deal to just pick the first, wherever it is. The function naming aside, Reviewed-by: Jani Nikula <[email protected]> > +} > +EXPORT_SYMBOL(drm_displayid_get_product_id); > + > static void decode_date(struct seq_buf *s, const struct drm_edid_product_id > *id) > { > int week = id->week_of_manufacture; > diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h > index a2617aa34edf..b44c26d42217 100644 > --- a/include/drm/drm_edid.h > +++ b/include/drm/drm_edid.h > @@ -288,6 +288,14 @@ struct drm_edid_product_id { > u8 year_of_manufacture; > } __packed; > > +struct drm_displayid_product_id { > + u8 vendor_id[3]; > + __le16 product_code; > + __le32 serial_number; > + u8 week_of_manufacture; > + u8 year_of_manufacture; > +} __packed; > + > struct edid { > u8 header[8]; > /* Vendor & product info */ > @@ -484,6 +492,8 @@ int drm_edid_connector_add_modes(struct drm_connector > *connector); > bool drm_edid_is_digital(const struct drm_edid *drm_edid); > void drm_edid_get_product_id(const struct drm_edid *drm_edid, > struct drm_edid_product_id *id); > +void drm_displayid_get_product_id(const struct drm_edid *drm_edid, > + struct drm_displayid_product_id *id); > void drm_edid_print_product_id(struct drm_printer *p, > const struct drm_edid_product_id *id, bool raw); > u32 drm_edid_get_panel_id(const struct drm_edid *drm_edid); -- Jani Nikula, Intel
