aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJani Nikula <jani.nikula@intel.com>2022-04-11 17:00:31 +0300
committerJani Nikula <jani.nikula@intel.com>2022-04-14 16:51:45 +0300
commitc12561ce43358ce59fc0f2275fc1853e24980908 (patch)
treecb282e6b236b8210fbecf9bc43bc002dadf12ccc
parentdrm/edid: abstract an EDID block read helper (diff)
downloadwireguard-linux-c12561ce43358ce59fc0f2275fc1853e24980908.tar.xz
wireguard-linux-c12561ce43358ce59fc0f2275fc1853e24980908.zip
drm/edid: use EDID block read helper in drm_do_get_edid()
Convert drm_do_get_edit() from the base block read helper to the generic block read helper. There's quite a bit going on here, as the corrupt and null EDID information is moved back to the caller. As we see, they were not all that clear to begin with, and this change underlines that. Signed-off-by: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/3bcf98453770757ee93386da0cfbc6552d42a312.1649685475.git.jani.nikula@intel.com
-rw-r--r--drivers/gpu/drm/drm_edid.c62
1 files changed, 23 insertions, 39 deletions
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 11276d226b37..d3951ac44f8f 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2076,44 +2076,6 @@ static enum edid_block_status edid_block_read(void *block, unsigned int block_nu
return status;
}
-static struct edid *drm_do_get_edid_base_block(struct drm_connector *connector,
- read_block_fn read_block,
- void *context)
-{
- int *null_edid_counter = connector ? &connector->null_edid_counter : NULL;
- bool *edid_corrupt = connector ? &connector->edid_corrupt : NULL;
- void *edid;
- int try;
-
- edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
- if (edid == NULL)
- return NULL;
-
- /* base block fetch */
- for (try = 0; try < 4; try++) {
- if (read_block(context, edid, 0, EDID_LENGTH))
- goto out;
- if (drm_edid_block_valid(edid, 0, false, edid_corrupt))
- break;
- if (try == 0 && edid_block_is_zero(edid)) {
- if (null_edid_counter)
- (*null_edid_counter)++;
- goto carp;
- }
- }
- if (try == 4)
- goto carp;
-
- return edid;
-
-carp:
- if (connector)
- connector_bad_edid(connector, edid, 1);
-out:
- kfree(edid);
- return NULL;
-}
-
/**
* drm_do_get_edid - get EDID data using a custom EDID block read function
* @connector: connector we're probing
@@ -2138,6 +2100,7 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
read_block_fn read_block,
void *context)
{
+ enum edid_block_status status;
int j, invalid_blocks = 0;
struct edid *edid, *new, *override;
@@ -2145,10 +2108,31 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
if (override)
return override;
- edid = drm_do_get_edid_base_block(connector, read_block, context);
+ edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
if (!edid)
return NULL;
+ status = edid_block_read(edid, 0, read_block, context);
+
+ edid_block_status_print(status, edid, 0);
+
+ if (status == EDID_BLOCK_READ_FAIL)
+ goto out;
+
+ /* FIXME: Clarify what a corrupt EDID actually means. */
+ if (status == EDID_BLOCK_OK || status == EDID_BLOCK_VERSION)
+ connector->edid_corrupt = false;
+ else
+ connector->edid_corrupt = true;
+
+ if (!edid_block_status_valid(status, edid_block_tag(edid))) {
+ if (status == EDID_BLOCK_ZERO)
+ connector->null_edid_counter++;
+
+ connector_bad_edid(connector, edid, 1);
+ goto out;
+ }
+
if (edid->extensions == 0)
return edid;