[PATCH 1/4] drm/edid: add drm_edid_get_product_id()
Jani Nikula
jani.nikula at intel.com
Tue Apr 9 07:42:15 UTC 2024
On Mon, 08 Apr 2024, Ville Syrjälä <ville.syrjala at linux.intel.com> wrote:
> On Thu, Mar 21, 2024 at 12:05:09PM +0200, Jani Nikula wrote:
>> Add a struct drm_edid based function to get the vendor and product ID
>> from an EDID. Add a separate struct for defining this part of the EDID,
>> with defined byte order for product code and serial number.
>>
>> Signed-off-by: Jani Nikula <jani.nikula at intel.com>
>> ---
>> drivers/gpu/drm/drm_edid.c | 15 +++++++++++++++
>> include/drm/drm_edid.h | 25 ++++++++++++++++++++-----
>> 2 files changed, 35 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
>> index ea77577a3786..626a0e24e66a 100644
>> --- a/drivers/gpu/drm/drm_edid.c
>> +++ b/drivers/gpu/drm/drm_edid.c
>> @@ -2756,6 +2756,21 @@ const struct drm_edid *drm_edid_read(struct drm_connector *connector)
>> }
>> EXPORT_SYMBOL(drm_edid_read);
>>
>> +/**
>> + * drm_edid_get_product_id - Get the vendor and product identification
>> + * @drm_edid: EDID
>> + * @id: Where to place the product id
>> + */
>> +void drm_edid_get_product_id(const struct drm_edid *drm_edid,
>> + struct drm_edid_product_id *id)
>> +{
>> + if (drm_edid && drm_edid->edid && drm_edid->size >= EDID_LENGTH)
>> + memcpy(id, &drm_edid->edid->product_id, sizeof(*id));
>> + else
>> + memset(id, 0, sizeof(*id));
>> +}
>> +EXPORT_SYMBOL(drm_edid_get_product_id);
>> +
>> /**
>> * drm_edid_get_panel_id - Get a panel's ID from EDID
>> * @drm_edid: EDID that contains panel ID.
>> diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
>> index 6f65bbf655a1..7911a2f8a672 100644
>> --- a/include/drm/drm_edid.h
>> +++ b/include/drm/drm_edid.h
>> @@ -272,14 +272,27 @@ struct detailed_timing {
>> #define DRM_EDID_DSC_MAX_SLICES 0xf
>> #define DRM_EDID_DSC_TOTAL_CHUNK_KBYTES 0x3f
>>
>> +struct drm_edid_product_id {
>> + u8 manufacturer_name[2];
>
> __be16?
Yeah, why not.
BR,
Jani.
>
>> + __le16 product_code;
>> + __le32 serial_number;
>> + u8 week_of_manufacture;
>> + u8 year_of_manufacture;
>> +} __packed;
>> +
>> struct edid {
>> u8 header[8];
>> /* Vendor & product info */
>> - u8 mfg_id[2];
>> - u8 prod_code[2];
>> - u32 serial; /* FIXME: byte order */
>> - u8 mfg_week;
>> - u8 mfg_year;
>> + union {
>> + struct drm_edid_product_id product_id;
>> + struct {
>> + u8 mfg_id[2];
>> + u8 prod_code[2];
>> + u32 serial; /* FIXME: byte order */
>> + u8 mfg_week;
>> + u8 mfg_year;
>> + } __packed;
>> + } __packed;
>> /* EDID version */
>> u8 version;
>> u8 revision;
>> @@ -466,6 +479,8 @@ int drm_edid_connector_update(struct drm_connector *connector,
>> const struct drm_edid *edid);
>> 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);
>>
>> const u8 *drm_find_edid_extension(const struct drm_edid *drm_edid,
>> int ext_id, int *ext_index);
>> --
>> 2.39.2
--
Jani Nikula, Intel
More information about the Intel-gfx
mailing list