Merge tag 'drm-misc-next-2022-06-08' of git://anongit.freedesktop.org/drm/drm-misc...
[sfrench/cifs-2.6.git] / include / drm / drm_edid.h
index b2756753370b77c1f522ccbe729f96cd4ef35535..95ac09ef41b26df32b16050692362a7cd6a9a258 100644 (file)
@@ -28,6 +28,7 @@
 #include <drm/drm_mode.h>
 
 struct drm_device;
+struct drm_edid;
 struct i2c_adapter;
 
 #define EDID_LENGTH 128
@@ -496,6 +497,22 @@ static inline u8 drm_eld_get_conn_type(const uint8_t *eld)
        return eld[DRM_ELD_SAD_COUNT_CONN_TYPE] & DRM_ELD_CONN_TYPE_MASK;
 }
 
+/**
+ * drm_edid_decode_mfg_id - Decode the manufacturer ID
+ * @mfg_id: The manufacturer ID
+ * @vend: A 4-byte buffer to store the 3-letter vendor string plus a '\0'
+ *       termination
+ */
+static inline const char *drm_edid_decode_mfg_id(u16 mfg_id, char vend[4])
+{
+       vend[0] = '@' + ((mfg_id >> 10) & 0x1f);
+       vend[1] = '@' + ((mfg_id >> 5) & 0x1f);
+       vend[2] = '@' + ((mfg_id >> 0) & 0x1f);
+       vend[3] = '\0';
+
+       return vend;
+}
+
 /**
  * drm_edid_encode_panel_id - Encode an ID for matching against drm_edid_get_panel_id()
  * @vend_chr_0: First character of the vendor string.
@@ -536,10 +553,7 @@ static inline u8 drm_eld_get_conn_type(const uint8_t *eld)
 static inline void drm_edid_decode_panel_id(u32 panel_id, char vend[4], u16 *product_id)
 {
        *product_id = (u16)(panel_id & 0xffff);
-       vend[0] = '@' + ((panel_id >> 26) & 0x1f);
-       vend[1] = '@' + ((panel_id >> 21) & 0x1f);
-       vend[2] = '@' + ((panel_id >> 16) & 0x1f);
-       vend[3] = '\0';
+       drm_edid_decode_mfg_id(panel_id >> 16, vend);
 }
 
 bool drm_probe_ddc(struct i2c_adapter *adapter);
@@ -578,8 +592,9 @@ struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 struct drm_display_mode *
 drm_display_mode_from_cea_vic(struct drm_device *dev,
                              u8 video_code);
-const u8 *drm_find_edid_extension(const struct edid *edid,
-                                 int ext_id, int *ext_index);
 
+/* Interface based on struct drm_edid */
+const u8 *drm_find_edid_extension(const struct drm_edid *drm_edid,
+                                 int ext_id, int *ext_index);
 
 #endif /* __DRM_EDID_H__ */