Commit 36881184 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/edid: Remove idx==1 assumptions from all over the DispID parsing

The fact that the DispID starts at byte offset 1 is due to
the DispID coming from and EDID extension block (the first byte
being the extesion block tag). Instead of hadrdocoding that idx==1
assumptions all over let's just have drm_find_displayid_extension()
return it since it actually knows what it's talking about.

If at some point someone comes across a DispID which is not embedded
inside an EDID the function that returns the new type of DispID
can return it's own byte offset without having to updated all the
code.

TODO: should probably just get rid of that idx thing altogether
      and just return the thing we want directly.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200313162054.16009-4-ville.syrjala@linux.intel.comReviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent bf5e4a86
...@@ -3212,15 +3212,22 @@ static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id) ...@@ -3212,15 +3212,22 @@ static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
} }
static u8 *drm_find_displayid_extension(const struct edid *edid) static u8 *drm_find_displayid_extension(const struct edid *edid, int *idx)
{ {
return drm_find_edid_extension(edid, DISPLAYID_EXT); u8 *displayid = drm_find_edid_extension(edid, DISPLAYID_EXT);
if (!displayid)
return NULL;
*idx = 1;
return displayid;
} }
static u8 *drm_find_cea_extension(const struct edid *edid) static u8 *drm_find_cea_extension(const struct edid *edid)
{ {
int ret; int ret;
int idx = 1; int idx;
int length = EDID_LENGTH; int length = EDID_LENGTH;
struct displayid_block *block; struct displayid_block *block;
u8 *cea; u8 *cea;
...@@ -3232,7 +3239,7 @@ static u8 *drm_find_cea_extension(const struct edid *edid) ...@@ -3232,7 +3239,7 @@ static u8 *drm_find_cea_extension(const struct edid *edid)
return cea; return cea;
/* CEA blocks can also be found embedded in a DisplayID block */ /* CEA blocks can also be found embedded in a DisplayID block */
displayid = drm_find_displayid_extension(edid); displayid = drm_find_displayid_extension(edid, &idx);
if (!displayid) if (!displayid)
return NULL; return NULL;
...@@ -5181,12 +5188,12 @@ static int add_displayid_detailed_modes(struct drm_connector *connector, ...@@ -5181,12 +5188,12 @@ static int add_displayid_detailed_modes(struct drm_connector *connector,
{ {
u8 *displayid; u8 *displayid;
int ret; int ret;
int idx = 1; int idx;
int length = EDID_LENGTH; int length = EDID_LENGTH;
struct displayid_block *block; struct displayid_block *block;
int num_modes = 0; int num_modes = 0;
displayid = drm_find_displayid_extension(edid); displayid = drm_find_displayid_extension(edid, &idx);
if (!displayid) if (!displayid)
return 0; return 0;
...@@ -5836,17 +5843,11 @@ static int drm_parse_tiled_block(struct drm_connector *connector, ...@@ -5836,17 +5843,11 @@ static int drm_parse_tiled_block(struct drm_connector *connector,
} }
static int drm_parse_display_id(struct drm_connector *connector, static int drm_parse_display_id(struct drm_connector *connector,
u8 *displayid, int length, u8 *displayid, int length, int idx)
bool is_edid_extension)
{ {
/* if this is an EDID extension the first byte will be 0x70 */
int idx = 0;
struct displayid_block *block; struct displayid_block *block;
int ret; int ret;
if (is_edid_extension)
idx = 1;
ret = validate_displayid(displayid, length, idx); ret = validate_displayid(displayid, length, idx);
if (ret) if (ret)
return ret; return ret;
...@@ -5880,15 +5881,17 @@ static void drm_get_displayid(struct drm_connector *connector, ...@@ -5880,15 +5881,17 @@ static void drm_get_displayid(struct drm_connector *connector,
struct edid *edid) struct edid *edid)
{ {
void *displayid = NULL; void *displayid = NULL;
int idx;
int ret; int ret;
connector->has_tile = false; connector->has_tile = false;
displayid = drm_find_displayid_extension(edid); displayid = drm_find_displayid_extension(edid, &idx);
if (!displayid) { if (!displayid) {
/* drop reference to any tile group we had */ /* drop reference to any tile group we had */
goto out_drop_ref; goto out_drop_ref;
} }
ret = drm_parse_display_id(connector, displayid, EDID_LENGTH, true); ret = drm_parse_display_id(connector, displayid, EDID_LENGTH, idx);
if (ret < 0) if (ret < 0)
goto out_drop_ref; goto out_drop_ref;
if (!connector->has_tile) if (!connector->has_tile)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment