drm/edid: Try harder to fix up broken headers
Subsystems (2)
PATCH 1/1 drm/edid: Try harder to fix up broken headers
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
--- drivers/gpu/drm/drm_edid.c | 18 ++++++++---------- 1 files changed, 8 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_edid.c +8 -10
@@ -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++)
Signature · 1 line
1.7.6.4
Quoted 40 lines · Adam Jackson
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 <[email protected]>---
drivers/gpu/drm/drm_edid.c | 18 ++++++++----------1 files changed, 8 insertions(+), 10 deletions(-)drivers/gpu/drm/drm_edid.c +8
-11@@ -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++) --
Quoted 1 line
1.7.6.4
Acked by: Tormod Volden <[email protected]>
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
From f67717bed0817b8cfdd4d1bb144f802e28cd866d Mon Sep 17 00:00:00 2001
From: Adam Jackson <[email protected]>
Date: Wed, 7 Dec 2011 18:26:23 -0500
Subject: [PATCH v2] drm/edid: Try harder to fix up broken headers
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
--- drivers/gpu/drm/drm_edid.c | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_edid.c +6 -9
@@ -154,16 +154,13 @@ drm_edid_block_valid(u8 *raw_edid)int i;u8 csum =0 ;struct edid *edid = (struct edid *)raw_edid; +int score =drm_edid_header_is_valid (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; - } +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)); }for (i =0 ; i <EDID_LENGTH ; i++)
Signature · 1 line
1.7.0.4
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 2 lines · Adam Jackson
There's no reason to force the first byte to be correct if we're already scoring how correct the header is.
Don't use this. The 00 check is needed to make sure we only attempt the header fixup on the zeroth block (not extensions).
- ajax
Quoted 6 lines · Adam Jackson
Quoted 2 lines · Adam Jackson
There's no reason to force the first byte to be correct if we're already scoring how correct the header is.
Don't use this. The 00 check is needed to make sure we only attempt the header fixup on the zeroth block (not extensions).
That's also not sufficient however, I have a Fedora bug where it's the first EDID byte that's busted, fixing that made the checksum correct also.
Ben.
Quoted 7 lines
- ajax
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel