Advertisement
Dj_Dexter

drm_edid_fixix.patch

Nov 8th, 2011
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.05 KB | None | 0 0
  1. From 9b9e7e5822f45368066eaa9edb8a054446cef4a6 Mon Sep 17 00:00:00 2001
  2. From: Alex Deucher <[email protected]>
  3. Date: Tue, 4 Jan 2011 17:47:40 -0500
  4. Subject: [PATCH] drm/kms: add a module param to disable strict EDID checking
  5.  
  6. Lots of EDIDs have bad checksums or bad version numbers, but
  7. have otherwise good data in them.  The current code rejects
  8. them which results in bad modes or blank screens in some cases.
  9. This patch adds a new module parameter, edid_strict, to drm.ko.
  10. It defaults to 1 (strict conformance, the current behavior),
  11. but if the user sets it to 0, it will bypass the checks and
  12. accept the EDID.
  13.  
  14. Related bugs:
  15. https://bugs.freedesktop.org/show_bug.cgi?id=31943
  16. https://bugs.freedesktop.org/show_bug.cgi?id=27708
  17. https://bugzilla.kernel.org/show_bug.cgi?id=25052
  18.  
  19. Signed-off-by: Alex Deucher <[email protected]>
  20. Cc: Adam Jackson <[email protected]>
  21. ---
  22. drivers/gpu/drm/drm_edid.c |   17 ++++++++++-------
  23.  drivers/gpu/drm/drm_stub.c |    5 +++++
  24.  include/drm/drmP.h         |    2 ++
  25.  3 files changed, 17 insertions(+), 7 deletions(-)
  26.  
  27. diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
  28. index a245d17..4794faa 100644
  29. --- a/drivers/gpu/drm/drm_edid.c
  30. +++ b/drivers/gpu/drm/drm_edid.c
  31. @@ -128,8 +128,8 @@ static const u8 edid_header[] = {
  32.  };
  33.  
  34.  /*
  35. - * Sanity check the EDID block (base or extension).  Return 0 if the block
  36. - * doesn't check out, or 1 if it's valid.
  37. + * Sanity check the EDID block (base or extension).  Return false if the block
  38. + * doesn't check out, or true if it's valid.
  39.   */
  40.  static bool
  41.  drm_edid_block_valid(u8 *raw_edid)
  42. @@ -160,8 +160,10 @@ drm_edid_block_valid(u8 *raw_edid)
  43.         DRM_ERROR("EDID checksum is invalid, remainder is %d\n", csum);
  44.  
  45.         /* allow CEA to slide through, switches mangle this */
  46. -       if (raw_edid[0] != 0x02)
  47. -           goto bad;
  48. +       if (raw_edid[0] != 0x02) {
  49. +           if (drm_edid_strict)
  50. +               goto bad;
  51. +       }
  52.     }
  53.  
  54.     /* per-block-type checks */
  55. @@ -169,7 +171,8 @@ drm_edid_block_valid(u8 *raw_edid)
  56.     case 0: /* base */
  57.         if (edid->version != 1) {
  58.             DRM_ERROR("EDID has major version %d, instead of 1\n", edid->version);
  59. -           goto bad;
  60. +           if (drm_edid_strict)
  61. +               goto bad;
  62.         }
  63.  
  64.         if (edid->revision > 4)
  65. @@ -180,7 +183,7 @@ drm_edid_block_valid(u8 *raw_edid)
  66.         break;
  67.     }
  68.  
  69. -   return 1;
  70. +   return true;
  71.  
  72.  bad:
  73.     if (raw_edid) {
  74. @@ -188,7 +191,7 @@ bad:
  75.         print_hex_dump_bytes(KERN_ERR, DUMP_PREFIX_NONE, raw_edid, EDID_LENGTH);
  76.         printk("\n");
  77.     }
  78. -   return 0;
  79. +   return false;
  80.  }
  81.  
  82.  /**
  83. diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
  84. index d59edc1..8b4530e 100644
  85. --- a/drivers/gpu/drm/drm_stub.c
  86. +++ b/drivers/gpu/drm/drm_stub.c
  87. @@ -46,16 +46,21 @@ EXPORT_SYMBOL(drm_vblank_offdelay);
  88.  unsigned int drm_timestamp_precision = 20;  /* Default to 20 usecs. */
  89.  EXPORT_SYMBOL(drm_timestamp_precision);
  90.  
  91. +int drm_edid_strict = 1;   /* 0 to disable strict edid conformance */
  92. +EXPORT_SYMBOL(drm_edid_strict);
  93. +
  94.  MODULE_AUTHOR(CORE_AUTHOR);
  95.  MODULE_DESCRIPTION(CORE_DESC);
  96.  MODULE_LICENSE("GPL and additional rights");
  97.  MODULE_PARM_DESC(debug, "Enable debug output");
  98.  MODULE_PARM_DESC(vblankoffdelay, "Delay until vblank irq auto-disable [msecs]");
  99.  MODULE_PARM_DESC(timestamp_precision_usec, "Max. error on timestamps [usecs]");
  100. +MODULE_PARM_DESC(edid_strict, "Strict EDID checks (0 = disable)");
  101.  
  102.  module_param_named(debug, drm_debug, int, 0600);
  103.  module_param_named(vblankoffdelay, drm_vblank_offdelay, int, 0600);
  104.  module_param_named(timestamp_precision_usec, drm_timestamp_precision, int, 0600);
  105. +module_param_named(edid_strict, drm_edid_strict, int, 0600);
  106.  
  107.  struct idr drm_minors_idr;
  108.  
  109. diff --git a/include/drm/drmP.h b/include/drm/drmP.h
  110. index 0f14f94..fd99988 100644
  111. --- a/include/drm/drmP.h
  112. +++ b/include/drm/drmP.h
  113. @@ -1430,6 +1430,8 @@ extern unsigned int drm_debug;
  114.  extern unsigned int drm_vblank_offdelay;
  115.  extern unsigned int drm_timestamp_precision;
  116.  
  117. +extern int drm_edid_strict;
  118. +
  119.  extern struct class *drm_class;
  120.  extern struct proc_dir_entry *drm_proc_root;
  121.  extern struct dentry *drm_debugfs_root;
  122.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement