All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/edid: Try harder to fix up broken headers
@ 2011-12-07 23:26 Adam Jackson
  2011-12-08 11:24 ` Tormod Volden
  2011-12-20 20:09 ` Adam Jackson
  0 siblings, 2 replies; 4+ messages in thread
From: Adam Jackson @ 2011-12-07 23:26 UTC (permalink / raw)
  To: dri-devel

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@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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/edid: Try harder to fix up broken headers
  2011-12-07 23:26 [PATCH] drm/edid: Try harder to fix up broken headers Adam Jackson
@ 2011-12-08 11:24 ` Tormod Volden
  2011-12-20 20:09 ` Adam Jackson
  1 sibling, 0 replies; 4+ messages in thread
From: Tormod Volden @ 2011-12-08 11:24 UTC (permalink / raw)
  To: Adam Jackson; +Cc: dri-devel

[-- Attachment #1: Type: text/plain, Size: 2222 bytes --]

On Thu, Dec 8, 2011 at 12:26 AM, Adam Jackson <ajax@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@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@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

[-- Attachment #2: 0001-drm-edid-Try-harder-to-fix-up-broken-headers.patch --]
[-- Type: text/x-patch, Size: 1523 bytes --]

From f67717bed0817b8cfdd4d1bb144f802e28cd866d Mon Sep 17 00:00:00 2001
From: Adam Jackson <ajax@redhat.com>
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

Signed-off-by: Adam Jackson <ajax@redhat.com>
[Tormod: reorder if statements and avoid magic number]
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
---
 drivers/gpu/drm/drm_edid.c |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 7425e5c..1f601cb 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -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++)
-- 
1.7.0.4


[-- Attachment #3: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/edid: Try harder to fix up broken headers
  2011-12-07 23:26 [PATCH] drm/edid: Try harder to fix up broken headers Adam Jackson
  2011-12-08 11:24 ` Tormod Volden
@ 2011-12-20 20:09 ` Adam Jackson
  2011-12-21  9:08   ` Ben Skeggs
  1 sibling, 1 reply; 4+ messages in thread
From: Adam Jackson @ 2011-12-20 20:09 UTC (permalink / raw)
  To: dri-devel

On 12/7/11 6:26 PM, Adam Jackson wrote:
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/edid: Try harder to fix up broken headers
  2011-12-20 20:09 ` Adam Jackson
@ 2011-12-21  9:08   ` Ben Skeggs
  0 siblings, 0 replies; 4+ messages in thread
From: Ben Skeggs @ 2011-12-21  9:08 UTC (permalink / raw)
  To: Adam Jackson; +Cc: dri-devel

On Tue, 2011-12-20 at 15:09 -0500, Adam Jackson wrote:
> On 12/7/11 6:26 PM, Adam Jackson wrote:
> > 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.
> 
> - ajax
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-12-21  9:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-07 23:26 [PATCH] drm/edid: Try harder to fix up broken headers Adam Jackson
2011-12-08 11:24 ` Tormod Volden
2011-12-20 20:09 ` Adam Jackson
2011-12-21  9:08   ` Ben Skeggs

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.