Commit 7f261afd authored by Ville Syrjälä's avatar Ville Syrjälä

drm/edid: Iterate through all DispID ext blocks

Apparently there are EDIDs in the wild with multiple DispID extension
blocks. Iterate through them all.

In one particular case the tile information is specicied in the
second DispID ext block, and since the current parser only looks
at the first DispID ext block we don't notice that we're dealing
with a tiled display.

While at it change a few functions to return void since we have
no use for the errno.

References: https://gitlab.freedesktop.org/drm/intel/-/issues/27Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200527130310.27099-2-ville.syrjala@linux.intel.comReviewed-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
parent 8873cfa3
...@@ -3296,6 +3296,7 @@ static u8 *drm_find_cea_extension(const struct edid *edid) ...@@ -3296,6 +3296,7 @@ static u8 *drm_find_cea_extension(const struct edid *edid)
int ext_index; int ext_index;
/* Look for a top level CEA extension block */ /* Look for a top level CEA extension block */
/* FIXME: make callers iterate through multiple CEA ext blocks? */
ext_index = 0; ext_index = 0;
cea = drm_find_edid_extension(edid, CEA_EXT, &ext_index); cea = drm_find_edid_extension(edid, CEA_EXT, &ext_index);
if (cea) if (cea)
...@@ -3303,20 +3304,20 @@ static u8 *drm_find_cea_extension(const struct edid *edid) ...@@ -3303,20 +3304,20 @@ static u8 *drm_find_cea_extension(const struct edid *edid)
/* CEA blocks can also be found embedded in a DisplayID block */ /* CEA blocks can also be found embedded in a DisplayID block */
ext_index = 0; ext_index = 0;
displayid = drm_find_displayid_extension(edid, &length, &idx, for (;;) {
&ext_index); displayid = drm_find_displayid_extension(edid, &length, &idx,
if (!displayid) &ext_index);
return NULL; if (!displayid)
return NULL;
idx += sizeof(struct displayid_hdr); idx += sizeof(struct displayid_hdr);
for_each_displayid_db(displayid, block, idx, length) { for_each_displayid_db(displayid, block, idx, length) {
if (block->tag == DATA_BLOCK_CTA) { if (block->tag == DATA_BLOCK_CTA)
cea = (u8 *)block; return (u8 *)block;
break;
} }
} }
return cea; return NULL;
} }
static __always_inline const struct drm_display_mode *cea_mode_for_vic(u8 vic) static __always_inline const struct drm_display_mode *cea_mode_for_vic(u8 vic)
...@@ -5256,19 +5257,22 @@ static int add_displayid_detailed_modes(struct drm_connector *connector, ...@@ -5256,19 +5257,22 @@ static int add_displayid_detailed_modes(struct drm_connector *connector,
int num_modes = 0; int num_modes = 0;
int ext_index = 0; int ext_index = 0;
displayid = drm_find_displayid_extension(edid, &length, &idx, for (;;) {
&ext_index); displayid = drm_find_displayid_extension(edid, &length, &idx,
if (!displayid) &ext_index);
return 0; if (!displayid)
idx += sizeof(struct displayid_hdr);
for_each_displayid_db(displayid, block, idx, length) {
switch (block->tag) {
case DATA_BLOCK_TYPE_1_DETAILED_TIMING:
num_modes += add_displayid_detailed_1_modes(connector, block);
break; break;
idx += sizeof(struct displayid_hdr);
for_each_displayid_db(displayid, block, idx, length) {
switch (block->tag) {
case DATA_BLOCK_TYPE_1_DETAILED_TIMING:
num_modes += add_displayid_detailed_1_modes(connector, block);
break;
}
} }
} }
return num_modes; return num_modes;
} }
...@@ -5849,8 +5853,8 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame, ...@@ -5849,8 +5853,8 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
} }
EXPORT_SYMBOL(drm_hdmi_vendor_infoframe_from_display_mode); EXPORT_SYMBOL(drm_hdmi_vendor_infoframe_from_display_mode);
static int drm_parse_tiled_block(struct drm_connector *connector, static void drm_parse_tiled_block(struct drm_connector *connector,
const struct displayid_block *block) const struct displayid_block *block)
{ {
const struct displayid_tiled_block *tile = (struct displayid_tiled_block *)block; const struct displayid_tiled_block *tile = (struct displayid_tiled_block *)block;
u16 w, h; u16 w, h;
...@@ -5888,7 +5892,7 @@ static int drm_parse_tiled_block(struct drm_connector *connector, ...@@ -5888,7 +5892,7 @@ static int drm_parse_tiled_block(struct drm_connector *connector,
tg = drm_mode_create_tile_group(connector->dev, tile->topology_id); tg = drm_mode_create_tile_group(connector->dev, tile->topology_id);
} }
if (!tg) if (!tg)
return -ENOMEM; return;
if (connector->tile_group != tg) { if (connector->tile_group != tg) {
/* if we haven't got a pointer, /* if we haven't got a pointer,
...@@ -5900,14 +5904,12 @@ static int drm_parse_tiled_block(struct drm_connector *connector, ...@@ -5900,14 +5904,12 @@ static int drm_parse_tiled_block(struct drm_connector *connector,
} else } else
/* if same tile group, then release the ref we just took. */ /* if same tile group, then release the ref we just took. */
drm_mode_put_tile_group(connector->dev, tg); drm_mode_put_tile_group(connector->dev, tg);
return 0;
} }
static int drm_displayid_parse_tiled(struct drm_connector *connector, static void drm_displayid_parse_tiled(struct drm_connector *connector,
const u8 *displayid, int length, int idx) const u8 *displayid, int length, int idx)
{ {
const struct displayid_block *block; const struct displayid_block *block;
int ret;
idx += sizeof(struct displayid_hdr); idx += sizeof(struct displayid_hdr);
for_each_displayid_db(displayid, block, idx, length) { for_each_displayid_db(displayid, block, idx, length) {
...@@ -5916,16 +5918,13 @@ static int drm_displayid_parse_tiled(struct drm_connector *connector, ...@@ -5916,16 +5918,13 @@ static int drm_displayid_parse_tiled(struct drm_connector *connector,
switch (block->tag) { switch (block->tag) {
case DATA_BLOCK_TILED_DISPLAY: case DATA_BLOCK_TILED_DISPLAY:
ret = drm_parse_tiled_block(connector, block); drm_parse_tiled_block(connector, block);
if (ret)
return ret;
break; break;
default: default:
DRM_DEBUG_KMS("found DisplayID tag 0x%x, unhandled\n", block->tag); DRM_DEBUG_KMS("found DisplayID tag 0x%x, unhandled\n", block->tag);
break; break;
} }
} }
return 0;
} }
void drm_update_tile_info(struct drm_connector *connector, void drm_update_tile_info(struct drm_connector *connector,
...@@ -5934,26 +5933,19 @@ void drm_update_tile_info(struct drm_connector *connector, ...@@ -5934,26 +5933,19 @@ void drm_update_tile_info(struct drm_connector *connector,
const void *displayid = NULL; const void *displayid = NULL;
int ext_index = 0; int ext_index = 0;
int length, idx; int length, idx;
int ret;
connector->has_tile = false; connector->has_tile = false;
displayid = drm_find_displayid_extension(edid, &length, &idx, for (;;) {
&ext_index); displayid = drm_find_displayid_extension(edid, &length, &idx,
if (!displayid) { &ext_index);
/* drop reference to any tile group we had */ if (!displayid)
goto out_drop_ref; break;
drm_displayid_parse_tiled(connector, displayid, length, idx);
} }
ret = drm_displayid_parse_tiled(connector, displayid, length, idx); if (!connector->has_tile && connector->tile_group) {
if (ret < 0)
goto out_drop_ref;
if (!connector->has_tile)
goto out_drop_ref;
return;
out_drop_ref:
if (connector->tile_group) {
drm_mode_put_tile_group(connector->dev, connector->tile_group); drm_mode_put_tile_group(connector->dev, connector->tile_group);
connector->tile_group = NULL; connector->tile_group = NULL;
} }
return;
} }
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