[PATCH] drm/edid: Try harder to fix up broken headers

Tormod Volden lists.tormod at gmail.com
Thu Dec 8 03:24:50 PST 2011


On Thu, Dec 8, 2011 at 12:26 AM, Adam Jackson <ajax at redhat.com> wrote:
> There's no reason to force the first byte to be correct if we're already
> scoring how correct the header is.
>
> See also: https://bugzilla.redhat.com/show_bug.cgi?id=722909
>
> Signed-off-by: Adam Jackson <ajax at redhat.com>
> ---
>  drivers/gpu/drm/drm_edid.c |   18 ++++++++----------
>  1 files changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 3e927ce..5fc3597 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -155,16 +155,14 @@ drm_edid_block_valid(u8 *raw_edid)
>        int i;
>        u8 csum = 0;
>        struct edid *edid = (struct edid *)raw_edid;
> -
> -       if (raw_edid[0] == 0x00) {
> -               int score = drm_edid_header_is_valid(raw_edid);
> -               if (score == 8) ;
> -               else if (score >= 6) {
> -                       DRM_DEBUG("Fixing EDID header, your hardware may be failing\n");
> -                       memcpy(raw_edid, edid_header, sizeof(edid_header));
> -               } else {
> -                       goto bad;
> -               }
> +       int score = drm_edid_header_is_valid(raw_edid);
> +
> +       if (score == 8) ;
> +       else if (score >= 6) {
> +               DRM_DEBUG("Fixing EDID header, your hardware may be failing\n");
> +               memcpy(raw_edid, edid_header, sizeof(edid_header));
> +       } else {
> +               goto bad;
>        }
>
>        for (i = 0; i < EDID_LENGTH; i++)
> --
> 1.7.6.4

Acked by: Tormod Volden <debian.tormod at gmail.com>

Also, I don't find the empty "if" statement very elegant. And the 8 is
not so magic, is it? What about:

+       if (score < 6)
+               goto bad;
+       else if (score < sizeof(edid_header)) {
+               DRM_DEBUG("Fixing EDID header, your hardware may be failing\n");
+               memcpy(raw_edid, edid_header, sizeof(edid_header));
        }

Or would the extra comparison in the good case be unacceptable?

One could think about demagifying 6 somewhat also, but I am not sure
it makes it more readable.

Cheers,
Tormod
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-drm-edid-Try-harder-to-fix-up-broken-headers.patch
Type: text/x-patch
Size: 1522 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/dri-devel/attachments/20111208/c3d89dd6/attachment.bin>


More information about the dri-devel mailing list