drm_edid.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426
  1. /*
  2. * Copyright (c) 2006 Luc Verhaegen (quirks list)
  3. * Copyright (c) 2007-2008 Intel Corporation
  4. * Jesse Barnes <jesse.barnes@intel.com>
  5. *
  6. * DDC probing routines (drm_ddc_read & drm_do_probe_ddc_edid) originally from
  7. * FB layer.
  8. * Copyright (C) 2006 Dennis Munsie <dmunsie@cecropia.com>
  9. *
  10. * Permission is hereby granted, free of charge, to any person obtaining a
  11. * copy of this software and associated documentation files (the "Software"),
  12. * to deal in the Software without restriction, including without limitation
  13. * the rights to use, copy, modify, merge, publish, distribute, sub license,
  14. * and/or sell copies of the Software, and to permit persons to whom the
  15. * Software is furnished to do so, subject to the following conditions:
  16. *
  17. * The above copyright notice and this permission notice (including the
  18. * next paragraph) shall be included in all copies or substantial portions
  19. * of the Software.
  20. *
  21. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  24. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  26. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  27. * DEALINGS IN THE SOFTWARE.
  28. */
  29. #include <linux/kernel.h>
  30. #include <linux/i2c.h>
  31. #include <linux/i2c-algo-bit.h>
  32. #include "drmP.h"
  33. #include "drm_edid.h"
  34. /*
  35. * TODO:
  36. * - support EDID 1.4 (incl. CE blocks)
  37. */
  38. /*
  39. * EDID blocks out in the wild have a variety of bugs, try to collect
  40. * them here (note that userspace may work around broken monitors first,
  41. * but fixes should make their way here so that the kernel "just works"
  42. * on as many displays as possible).
  43. */
  44. /* First detailed mode wrong, use largest 60Hz mode */
  45. #define EDID_QUIRK_PREFER_LARGE_60 (1 << 0)
  46. /* Reported 135MHz pixel clock is too high, needs adjustment */
  47. #define EDID_QUIRK_135_CLOCK_TOO_HIGH (1 << 1)
  48. /* Prefer the largest mode at 75 Hz */
  49. #define EDID_QUIRK_PREFER_LARGE_75 (1 << 2)
  50. /* Detail timing is in cm not mm */
  51. #define EDID_QUIRK_DETAILED_IN_CM (1 << 3)
  52. /* Detailed timing descriptors have bogus size values, so just take the
  53. * maximum size and use that.
  54. */
  55. #define EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE (1 << 4)
  56. /* Monitor forgot to set the first detailed is preferred bit. */
  57. #define EDID_QUIRK_FIRST_DETAILED_PREFERRED (1 << 5)
  58. /* use +hsync +vsync for detailed mode */
  59. #define EDID_QUIRK_DETAILED_SYNC_PP (1 << 6)
  60. #define LEVEL_DMT 0
  61. #define LEVEL_GTF 1
  62. #define LEVEL_CVT 2
  63. static struct edid_quirk {
  64. char *vendor;
  65. int product_id;
  66. u32 quirks;
  67. } edid_quirk_list[] = {
  68. /* Acer AL1706 */
  69. { "ACR", 44358, EDID_QUIRK_PREFER_LARGE_60 },
  70. /* Acer F51 */
  71. { "API", 0x7602, EDID_QUIRK_PREFER_LARGE_60 },
  72. /* Unknown Acer */
  73. { "ACR", 2423, EDID_QUIRK_FIRST_DETAILED_PREFERRED },
  74. /* Belinea 10 15 55 */
  75. { "MAX", 1516, EDID_QUIRK_PREFER_LARGE_60 },
  76. { "MAX", 0x77e, EDID_QUIRK_PREFER_LARGE_60 },
  77. /* Envision Peripherals, Inc. EN-7100e */
  78. { "EPI", 59264, EDID_QUIRK_135_CLOCK_TOO_HIGH },
  79. /* Envision EN2028 */
  80. { "EPI", 8232, EDID_QUIRK_PREFER_LARGE_60 },
  81. /* Funai Electronics PM36B */
  82. { "FCM", 13600, EDID_QUIRK_PREFER_LARGE_75 |
  83. EDID_QUIRK_DETAILED_IN_CM },
  84. /* LG Philips LCD LP154W01-A5 */
  85. { "LPL", 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
  86. { "LPL", 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE },
  87. /* Philips 107p5 CRT */
  88. { "PHL", 57364, EDID_QUIRK_FIRST_DETAILED_PREFERRED },
  89. /* Proview AY765C */
  90. { "PTS", 765, EDID_QUIRK_FIRST_DETAILED_PREFERRED },
  91. /* Samsung SyncMaster 205BW. Note: irony */
  92. { "SAM", 541, EDID_QUIRK_DETAILED_SYNC_PP },
  93. /* Samsung SyncMaster 22[5-6]BW */
  94. { "SAM", 596, EDID_QUIRK_PREFER_LARGE_60 },
  95. { "SAM", 638, EDID_QUIRK_PREFER_LARGE_60 },
  96. };
  97. /* Valid EDID header has these bytes */
  98. static const u8 edid_header[] = {
  99. 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00
  100. };
  101. /**
  102. * drm_edid_is_valid - sanity check EDID data
  103. * @edid: EDID data
  104. *
  105. * Sanity check the EDID block by looking at the header, the version number
  106. * and the checksum. Return 0 if the EDID doesn't check out, or 1 if it's
  107. * valid.
  108. */
  109. bool drm_edid_is_valid(struct edid *edid)
  110. {
  111. int i, score = 0;
  112. u8 csum = 0;
  113. u8 *raw_edid = (u8 *)edid;
  114. for (i = 0; i < sizeof(edid_header); i++)
  115. if (raw_edid[i] == edid_header[i])
  116. score++;
  117. if (score == 8) ;
  118. else if (score >= 6) {
  119. DRM_DEBUG("Fixing EDID header, your hardware may be failing\n");
  120. memcpy(raw_edid, edid_header, sizeof(edid_header));
  121. } else
  122. goto bad;
  123. for (i = 0; i < EDID_LENGTH; i++)
  124. csum += raw_edid[i];
  125. if (csum) {
  126. DRM_ERROR("EDID checksum is invalid, remainder is %d\n", csum);
  127. goto bad;
  128. }
  129. if (edid->version != 1) {
  130. DRM_ERROR("EDID has major version %d, instead of 1\n", edid->version);
  131. goto bad;
  132. }
  133. if (edid->revision > 4)
  134. DRM_DEBUG("EDID minor > 4, assuming backward compatibility\n");
  135. return 1;
  136. bad:
  137. if (raw_edid) {
  138. DRM_ERROR("Raw EDID:\n");
  139. print_hex_dump_bytes(KERN_ERR, DUMP_PREFIX_NONE, raw_edid, EDID_LENGTH);
  140. printk("\n");
  141. }
  142. return 0;
  143. }
  144. EXPORT_SYMBOL(drm_edid_is_valid);
  145. /**
  146. * edid_vendor - match a string against EDID's obfuscated vendor field
  147. * @edid: EDID to match
  148. * @vendor: vendor string
  149. *
  150. * Returns true if @vendor is in @edid, false otherwise
  151. */
  152. static bool edid_vendor(struct edid *edid, char *vendor)
  153. {
  154. char edid_vendor[3];
  155. edid_vendor[0] = ((edid->mfg_id[0] & 0x7c) >> 2) + '@';
  156. edid_vendor[1] = (((edid->mfg_id[0] & 0x3) << 3) |
  157. ((edid->mfg_id[1] & 0xe0) >> 5)) + '@';
  158. edid_vendor[2] = (edid->mfg_id[1] & 0x1f) + '@';
  159. return !strncmp(edid_vendor, vendor, 3);
  160. }
  161. /**
  162. * edid_get_quirks - return quirk flags for a given EDID
  163. * @edid: EDID to process
  164. *
  165. * This tells subsequent routines what fixes they need to apply.
  166. */
  167. static u32 edid_get_quirks(struct edid *edid)
  168. {
  169. struct edid_quirk *quirk;
  170. int i;
  171. for (i = 0; i < ARRAY_SIZE(edid_quirk_list); i++) {
  172. quirk = &edid_quirk_list[i];
  173. if (edid_vendor(edid, quirk->vendor) &&
  174. (EDID_PRODUCT_ID(edid) == quirk->product_id))
  175. return quirk->quirks;
  176. }
  177. return 0;
  178. }
  179. #define MODE_SIZE(m) ((m)->hdisplay * (m)->vdisplay)
  180. #define MODE_REFRESH_DIFF(m,r) (abs((m)->vrefresh - target_refresh))
  181. /**
  182. * edid_fixup_preferred - set preferred modes based on quirk list
  183. * @connector: has mode list to fix up
  184. * @quirks: quirks list
  185. *
  186. * Walk the mode list for @connector, clearing the preferred status
  187. * on existing modes and setting it anew for the right mode ala @quirks.
  188. */
  189. static void edid_fixup_preferred(struct drm_connector *connector,
  190. u32 quirks)
  191. {
  192. struct drm_display_mode *t, *cur_mode, *preferred_mode;
  193. int target_refresh = 0;
  194. if (list_empty(&connector->probed_modes))
  195. return;
  196. if (quirks & EDID_QUIRK_PREFER_LARGE_60)
  197. target_refresh = 60;
  198. if (quirks & EDID_QUIRK_PREFER_LARGE_75)
  199. target_refresh = 75;
  200. preferred_mode = list_first_entry(&connector->probed_modes,
  201. struct drm_display_mode, head);
  202. list_for_each_entry_safe(cur_mode, t, &connector->probed_modes, head) {
  203. cur_mode->type &= ~DRM_MODE_TYPE_PREFERRED;
  204. if (cur_mode == preferred_mode)
  205. continue;
  206. /* Largest mode is preferred */
  207. if (MODE_SIZE(cur_mode) > MODE_SIZE(preferred_mode))
  208. preferred_mode = cur_mode;
  209. /* At a given size, try to get closest to target refresh */
  210. if ((MODE_SIZE(cur_mode) == MODE_SIZE(preferred_mode)) &&
  211. MODE_REFRESH_DIFF(cur_mode, target_refresh) <
  212. MODE_REFRESH_DIFF(preferred_mode, target_refresh)) {
  213. preferred_mode = cur_mode;
  214. }
  215. }
  216. preferred_mode->type |= DRM_MODE_TYPE_PREFERRED;
  217. }
  218. /*
  219. * Add the Autogenerated from the DMT spec.
  220. * This table is copied from xfree86/modes/xf86EdidModes.c.
  221. * But the mode with Reduced blank feature is deleted.
  222. */
  223. static struct drm_display_mode drm_dmt_modes[] = {
  224. /* 640x350@85Hz */
  225. { DRM_MODE("640x350", DRM_MODE_TYPE_DRIVER, 31500, 640, 672,
  226. 736, 832, 0, 350, 382, 385, 445, 0,
  227. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
  228. /* 640x400@85Hz */
  229. { DRM_MODE("640x400", DRM_MODE_TYPE_DRIVER, 31500, 640, 672,
  230. 736, 832, 0, 400, 401, 404, 445, 0,
  231. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  232. /* 720x400@85Hz */
  233. { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 35500, 720, 756,
  234. 828, 936, 0, 400, 401, 404, 446, 0,
  235. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  236. /* 640x480@60Hz */
  237. { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656,
  238. 752, 800, 0, 480, 489, 492, 525, 0,
  239. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
  240. /* 640x480@72Hz */
  241. { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664,
  242. 704, 832, 0, 480, 489, 492, 520, 0,
  243. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
  244. /* 640x480@75Hz */
  245. { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 656,
  246. 720, 840, 0, 480, 481, 484, 500, 0,
  247. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
  248. /* 640x480@85Hz */
  249. { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 36000, 640, 696,
  250. 752, 832, 0, 480, 481, 484, 509, 0,
  251. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
  252. /* 800x600@56Hz */
  253. { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 36000, 800, 824,
  254. 896, 1024, 0, 600, 601, 603, 625, 0,
  255. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  256. /* 800x600@60Hz */
  257. { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 40000, 800, 840,
  258. 968, 1056, 0, 600, 601, 605, 628, 0,
  259. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  260. /* 800x600@72Hz */
  261. { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 50000, 800, 856,
  262. 976, 1040, 0, 600, 637, 643, 666, 0,
  263. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  264. /* 800x600@75Hz */
  265. { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 49500, 800, 816,
  266. 896, 1056, 0, 600, 601, 604, 625, 0,
  267. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  268. /* 800x600@85Hz */
  269. { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 56250, 800, 832,
  270. 896, 1048, 0, 600, 601, 604, 631, 0,
  271. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  272. /* 848x480@60Hz */
  273. { DRM_MODE("848x480", DRM_MODE_TYPE_DRIVER, 33750, 848, 864,
  274. 976, 1088, 0, 480, 486, 494, 517, 0,
  275. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  276. /* 1024x768@43Hz, interlace */
  277. { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 44900, 1024, 1032,
  278. 1208, 1264, 0, 768, 768, 772, 817, 0,
  279. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC |
  280. DRM_MODE_FLAG_INTERLACE) },
  281. /* 1024x768@60Hz */
  282. { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 1048,
  283. 1184, 1344, 0, 768, 771, 777, 806, 0,
  284. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
  285. /* 1024x768@70Hz */
  286. { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 75000, 1024, 1048,
  287. 1184, 1328, 0, 768, 771, 777, 806, 0,
  288. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
  289. /* 1024x768@75Hz */
  290. { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 78750, 1024, 1040,
  291. 1136, 1312, 0, 768, 769, 772, 800, 0,
  292. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  293. /* 1024x768@85Hz */
  294. { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 94500, 1024, 1072,
  295. 1072, 1376, 0, 768, 769, 772, 808, 0,
  296. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  297. /* 1152x864@75Hz */
  298. { DRM_MODE("1152x864", DRM_MODE_TYPE_DRIVER, 108000, 1152, 1216,
  299. 1344, 1600, 0, 864, 865, 868, 900, 0,
  300. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  301. /* 1280x768@60Hz */
  302. { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 79500, 1280, 1344,
  303. 1472, 1664, 0, 768, 771, 778, 798, 0,
  304. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  305. /* 1280x768@75Hz */
  306. { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 102250, 1280, 1360,
  307. 1488, 1696, 0, 768, 771, 778, 805, 0,
  308. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
  309. /* 1280x768@85Hz */
  310. { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 117500, 1280, 1360,
  311. 1496, 1712, 0, 768, 771, 778, 809, 0,
  312. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  313. /* 1280x800@60Hz */
  314. { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 83500, 1280, 1352,
  315. 1480, 1680, 0, 800, 803, 809, 831, 0,
  316. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
  317. /* 1280x800@75Hz */
  318. { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 106500, 1280, 1360,
  319. 1488, 1696, 0, 800, 803, 809, 838, 0,
  320. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  321. /* 1280x800@85Hz */
  322. { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 122500, 1280, 1360,
  323. 1496, 1712, 0, 800, 803, 809, 843, 0,
  324. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  325. /* 1280x960@60Hz */
  326. { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1376,
  327. 1488, 1800, 0, 960, 961, 964, 1000, 0,
  328. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  329. /* 1280x960@85Hz */
  330. { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1344,
  331. 1504, 1728, 0, 960, 961, 964, 1011, 0,
  332. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  333. /* 1280x1024@60Hz */
  334. { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1328,
  335. 1440, 1688, 0, 1024, 1025, 1028, 1066, 0,
  336. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  337. /* 1280x1024@75Hz */
  338. { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 135000, 1280, 1296,
  339. 1440, 1688, 0, 1024, 1025, 1028, 1066, 0,
  340. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  341. /* 1280x1024@85Hz */
  342. { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 157500, 1280, 1344,
  343. 1504, 1728, 0, 1024, 1025, 1028, 1072, 0,
  344. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  345. /* 1360x768@60Hz */
  346. { DRM_MODE("1360x768", DRM_MODE_TYPE_DRIVER, 85500, 1360, 1424,
  347. 1536, 1792, 0, 768, 771, 777, 795, 0,
  348. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  349. /* 1440x1050@60Hz */
  350. { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 121750, 1400, 1488,
  351. 1632, 1864, 0, 1050, 1053, 1057, 1089, 0,
  352. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  353. /* 1440x1050@75Hz */
  354. { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 156000, 1400, 1504,
  355. 1648, 1896, 0, 1050, 1053, 1057, 1099, 0,
  356. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  357. /* 1440x1050@85Hz */
  358. { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 179500, 1400, 1504,
  359. 1656, 1912, 0, 1050, 1053, 1057, 1105, 0,
  360. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  361. /* 1440x900@60Hz */
  362. { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 106500, 1440, 1520,
  363. 1672, 1904, 0, 900, 903, 909, 934, 0,
  364. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  365. /* 1440x900@75Hz */
  366. { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 136750, 1440, 1536,
  367. 1688, 1936, 0, 900, 903, 909, 942, 0,
  368. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  369. /* 1440x900@85Hz */
  370. { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 157000, 1440, 1544,
  371. 1696, 1952, 0, 900, 903, 909, 948, 0,
  372. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  373. /* 1600x1200@60Hz */
  374. { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 162000, 1600, 1664,
  375. 1856, 2160, 0, 1200, 1201, 1204, 1250, 0,
  376. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  377. /* 1600x1200@65Hz */
  378. { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 175500, 1600, 1664,
  379. 1856, 2160, 0, 1200, 1201, 1204, 1250, 0,
  380. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  381. /* 1600x1200@70Hz */
  382. { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 189000, 1600, 1664,
  383. 1856, 2160, 0, 1200, 1201, 1204, 1250, 0,
  384. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  385. /* 1600x1200@75Hz */
  386. { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 2025000, 1600, 1664,
  387. 1856, 2160, 0, 1200, 1201, 1204, 1250, 0,
  388. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  389. /* 1600x1200@85Hz */
  390. { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 229500, 1600, 1664,
  391. 1856, 2160, 0, 1200, 1201, 1204, 1250, 0,
  392. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  393. /* 1680x1050@60Hz */
  394. { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 146250, 1680, 1784,
  395. 1960, 2240, 0, 1050, 1053, 1059, 1089, 0,
  396. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  397. /* 1680x1050@75Hz */
  398. { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 187000, 1680, 1800,
  399. 1976, 2272, 0, 1050, 1053, 1059, 1099, 0,
  400. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  401. /* 1680x1050@85Hz */
  402. { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 214750, 1680, 1808,
  403. 1984, 2288, 0, 1050, 1053, 1059, 1105, 0,
  404. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  405. /* 1792x1344@60Hz */
  406. { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 204750, 1792, 1920,
  407. 2120, 2448, 0, 1344, 1345, 1348, 1394, 0,
  408. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  409. /* 1729x1344@75Hz */
  410. { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 261000, 1792, 1888,
  411. 2104, 2456, 0, 1344, 1345, 1348, 1417, 0,
  412. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  413. /* 1853x1392@60Hz */
  414. { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 218250, 1856, 1952,
  415. 2176, 2528, 0, 1392, 1393, 1396, 1439, 0,
  416. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  417. /* 1856x1392@75Hz */
  418. { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 288000, 1856, 1984,
  419. 2208, 2560, 0, 1392, 1395, 1399, 1500, 0,
  420. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  421. /* 1920x1200@60Hz */
  422. { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 193250, 1920, 2056,
  423. 2256, 2592, 0, 1200, 1203, 1209, 1245, 0,
  424. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  425. /* 1920x1200@75Hz */
  426. { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 245250, 1920, 2056,
  427. 2264, 2608, 0, 1200, 1203, 1209, 1255, 0,
  428. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  429. /* 1920x1200@85Hz */
  430. { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 281250, 1920, 2064,
  431. 2272, 2624, 0, 1200, 1203, 1209, 1262, 0,
  432. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  433. /* 1920x1440@60Hz */
  434. { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 234000, 1920, 2048,
  435. 2256, 2600, 0, 1440, 1441, 1444, 1500, 0,
  436. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  437. /* 1920x1440@75Hz */
  438. { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2064,
  439. 2288, 2640, 0, 1440, 1441, 1444, 1500, 0,
  440. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  441. /* 2560x1600@60Hz */
  442. { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 348500, 2560, 2752,
  443. 3032, 3504, 0, 1600, 1603, 1609, 1658, 0,
  444. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  445. /* 2560x1600@75HZ */
  446. { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 443250, 2560, 2768,
  447. 3048, 3536, 0, 1600, 1603, 1609, 1672, 0,
  448. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  449. /* 2560x1600@85HZ */
  450. { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 505250, 2560, 2768,
  451. 3048, 3536, 0, 1600, 1603, 1609, 1682, 0,
  452. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  453. };
  454. static const int drm_num_dmt_modes =
  455. sizeof(drm_dmt_modes) / sizeof(struct drm_display_mode);
  456. static struct drm_display_mode *drm_find_dmt(struct drm_device *dev,
  457. int hsize, int vsize, int fresh)
  458. {
  459. int i;
  460. struct drm_display_mode *ptr, *mode;
  461. mode = NULL;
  462. for (i = 0; i < drm_num_dmt_modes; i++) {
  463. ptr = &drm_dmt_modes[i];
  464. if (hsize == ptr->hdisplay &&
  465. vsize == ptr->vdisplay &&
  466. fresh == drm_mode_vrefresh(ptr)) {
  467. /* get the expected default mode */
  468. mode = drm_mode_duplicate(dev, ptr);
  469. break;
  470. }
  471. }
  472. return mode;
  473. }
  474. /*
  475. * 0 is reserved. The spec says 0x01 fill for unused timings. Some old
  476. * monitors fill with ascii space (0x20) instead.
  477. */
  478. static int
  479. bad_std_timing(u8 a, u8 b)
  480. {
  481. return (a == 0x00 && b == 0x00) ||
  482. (a == 0x01 && b == 0x01) ||
  483. (a == 0x20 && b == 0x20);
  484. }
  485. /**
  486. * drm_mode_std - convert standard mode info (width, height, refresh) into mode
  487. * @t: standard timing params
  488. * @timing_level: standard timing level
  489. *
  490. * Take the standard timing params (in this case width, aspect, and refresh)
  491. * and convert them into a real mode using CVT/GTF/DMT.
  492. *
  493. * Punts for now, but should eventually use the FB layer's CVT based mode
  494. * generation code.
  495. */
  496. struct drm_display_mode *drm_mode_std(struct drm_device *dev,
  497. struct std_timing *t,
  498. int revision,
  499. int timing_level)
  500. {
  501. struct drm_display_mode *mode;
  502. int hsize, vsize;
  503. int vrefresh_rate;
  504. unsigned aspect_ratio = (t->vfreq_aspect & EDID_TIMING_ASPECT_MASK)
  505. >> EDID_TIMING_ASPECT_SHIFT;
  506. unsigned vfreq = (t->vfreq_aspect & EDID_TIMING_VFREQ_MASK)
  507. >> EDID_TIMING_VFREQ_SHIFT;
  508. if (bad_std_timing(t->hsize, t->vfreq_aspect))
  509. return NULL;
  510. /* According to the EDID spec, the hdisplay = hsize * 8 + 248 */
  511. hsize = t->hsize * 8 + 248;
  512. /* vrefresh_rate = vfreq + 60 */
  513. vrefresh_rate = vfreq + 60;
  514. /* the vdisplay is calculated based on the aspect ratio */
  515. if (aspect_ratio == 0) {
  516. if (revision < 3)
  517. vsize = hsize;
  518. else
  519. vsize = (hsize * 10) / 16;
  520. } else if (aspect_ratio == 1)
  521. vsize = (hsize * 3) / 4;
  522. else if (aspect_ratio == 2)
  523. vsize = (hsize * 4) / 5;
  524. else
  525. vsize = (hsize * 9) / 16;
  526. /* HDTV hack */
  527. if (hsize == 1360 && vsize == 765 && vrefresh_rate == 60) {
  528. mode = drm_cvt_mode(dev, hsize, vsize, vrefresh_rate, 0, 0,
  529. false);
  530. mode->hdisplay = 1366;
  531. mode->vsync_start = mode->vsync_start - 1;
  532. mode->vsync_end = mode->vsync_end - 1;
  533. return mode;
  534. }
  535. mode = NULL;
  536. /* check whether it can be found in default mode table */
  537. mode = drm_find_dmt(dev, hsize, vsize, vrefresh_rate);
  538. if (mode)
  539. return mode;
  540. switch (timing_level) {
  541. case LEVEL_DMT:
  542. break;
  543. case LEVEL_GTF:
  544. mode = drm_gtf_mode(dev, hsize, vsize, vrefresh_rate, 0, 0);
  545. break;
  546. case LEVEL_CVT:
  547. mode = drm_cvt_mode(dev, hsize, vsize, vrefresh_rate, 0, 0,
  548. false);
  549. break;
  550. }
  551. return mode;
  552. }
  553. /*
  554. * EDID is delightfully ambiguous about how interlaced modes are to be
  555. * encoded. Our internal representation is of frame height, but some
  556. * HDTV detailed timings are encoded as field height.
  557. *
  558. * The format list here is from CEA, in frame size. Technically we
  559. * should be checking refresh rate too. Whatever.
  560. */
  561. static void
  562. drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
  563. struct detailed_pixel_timing *pt)
  564. {
  565. int i;
  566. static const struct {
  567. int w, h;
  568. } cea_interlaced[] = {
  569. { 1920, 1080 },
  570. { 720, 480 },
  571. { 1440, 480 },
  572. { 2880, 480 },
  573. { 720, 576 },
  574. { 1440, 576 },
  575. { 2880, 576 },
  576. };
  577. static const int n_sizes =
  578. sizeof(cea_interlaced)/sizeof(cea_interlaced[0]);
  579. if (!(pt->misc & DRM_EDID_PT_INTERLACED))
  580. return;
  581. for (i = 0; i < n_sizes; i++) {
  582. if ((mode->hdisplay == cea_interlaced[i].w) &&
  583. (mode->vdisplay == cea_interlaced[i].h / 2)) {
  584. mode->vdisplay *= 2;
  585. mode->vsync_start *= 2;
  586. mode->vsync_end *= 2;
  587. mode->vtotal *= 2;
  588. mode->vtotal |= 1;
  589. }
  590. }
  591. mode->flags |= DRM_MODE_FLAG_INTERLACE;
  592. }
  593. /**
  594. * drm_mode_detailed - create a new mode from an EDID detailed timing section
  595. * @dev: DRM device (needed to create new mode)
  596. * @edid: EDID block
  597. * @timing: EDID detailed timing info
  598. * @quirks: quirks to apply
  599. *
  600. * An EDID detailed timing block contains enough info for us to create and
  601. * return a new struct drm_display_mode.
  602. */
  603. static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
  604. struct edid *edid,
  605. struct detailed_timing *timing,
  606. u32 quirks)
  607. {
  608. struct drm_display_mode *mode;
  609. struct detailed_pixel_timing *pt = &timing->data.pixel_data;
  610. unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo;
  611. unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo;
  612. unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo;
  613. unsigned vblank = (pt->vactive_vblank_hi & 0xf) << 8 | pt->vblank_lo;
  614. unsigned hsync_offset = (pt->hsync_vsync_offset_pulse_width_hi & 0xc0) << 2 | pt->hsync_offset_lo;
  615. unsigned hsync_pulse_width = (pt->hsync_vsync_offset_pulse_width_hi & 0x30) << 4 | pt->hsync_pulse_width_lo;
  616. unsigned vsync_offset = (pt->hsync_vsync_offset_pulse_width_hi & 0xc) >> 2 | pt->vsync_offset_pulse_width_lo >> 4;
  617. unsigned vsync_pulse_width = (pt->hsync_vsync_offset_pulse_width_hi & 0x3) << 4 | (pt->vsync_offset_pulse_width_lo & 0xf);
  618. /* ignore tiny modes */
  619. if (hactive < 64 || vactive < 64)
  620. return NULL;
  621. if (pt->misc & DRM_EDID_PT_STEREO) {
  622. printk(KERN_WARNING "stereo mode not supported\n");
  623. return NULL;
  624. }
  625. if (!(pt->misc & DRM_EDID_PT_SEPARATE_SYNC)) {
  626. printk(KERN_WARNING "composite sync not supported\n");
  627. }
  628. /* it is incorrect if hsync/vsync width is zero */
  629. if (!hsync_pulse_width || !vsync_pulse_width) {
  630. DRM_DEBUG_KMS("Incorrect Detailed timing. "
  631. "Wrong Hsync/Vsync pulse width\n");
  632. return NULL;
  633. }
  634. mode = drm_mode_create(dev);
  635. if (!mode)
  636. return NULL;
  637. mode->type = DRM_MODE_TYPE_DRIVER;
  638. if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH)
  639. timing->pixel_clock = cpu_to_le16(1088);
  640. mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
  641. mode->hdisplay = hactive;
  642. mode->hsync_start = mode->hdisplay + hsync_offset;
  643. mode->hsync_end = mode->hsync_start + hsync_pulse_width;
  644. mode->htotal = mode->hdisplay + hblank;
  645. mode->vdisplay = vactive;
  646. mode->vsync_start = mode->vdisplay + vsync_offset;
  647. mode->vsync_end = mode->vsync_start + vsync_pulse_width;
  648. mode->vtotal = mode->vdisplay + vblank;
  649. /* Some EDIDs have bogus h/vtotal values */
  650. if (mode->hsync_end > mode->htotal)
  651. mode->htotal = mode->hsync_end + 1;
  652. if (mode->vsync_end > mode->vtotal)
  653. mode->vtotal = mode->vsync_end + 1;
  654. drm_mode_set_name(mode);
  655. drm_mode_do_interlace_quirk(mode, pt);
  656. if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) {
  657. pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE | DRM_EDID_PT_VSYNC_POSITIVE;
  658. }
  659. mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
  660. DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
  661. mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
  662. DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
  663. mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4;
  664. mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi & 0xf) << 8;
  665. if (quirks & EDID_QUIRK_DETAILED_IN_CM) {
  666. mode->width_mm *= 10;
  667. mode->height_mm *= 10;
  668. }
  669. if (quirks & EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE) {
  670. mode->width_mm = edid->width_cm * 10;
  671. mode->height_mm = edid->height_cm * 10;
  672. }
  673. return mode;
  674. }
  675. /*
  676. * Detailed mode info for the EDID "established modes" data to use.
  677. */
  678. static struct drm_display_mode edid_est_modes[] = {
  679. { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 40000, 800, 840,
  680. 968, 1056, 0, 600, 601, 605, 628, 0,
  681. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@60Hz */
  682. { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 36000, 800, 824,
  683. 896, 1024, 0, 600, 601, 603, 625, 0,
  684. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@56Hz */
  685. { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 656,
  686. 720, 840, 0, 480, 481, 484, 500, 0,
  687. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@75Hz */
  688. { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664,
  689. 704, 832, 0, 480, 489, 491, 520, 0,
  690. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@72Hz */
  691. { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 30240, 640, 704,
  692. 768, 864, 0, 480, 483, 486, 525, 0,
  693. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@67Hz */
  694. { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25200, 640, 656,
  695. 752, 800, 0, 480, 490, 492, 525, 0,
  696. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@60Hz */
  697. { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 35500, 720, 738,
  698. 846, 900, 0, 400, 421, 423, 449, 0,
  699. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 720x400@88Hz */
  700. { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 28320, 720, 738,
  701. 846, 900, 0, 400, 412, 414, 449, 0,
  702. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 720x400@70Hz */
  703. { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 135000, 1280, 1296,
  704. 1440, 1688, 0, 1024, 1025, 1028, 1066, 0,
  705. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1280x1024@75Hz */
  706. { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 78800, 1024, 1040,
  707. 1136, 1312, 0, 768, 769, 772, 800, 0,
  708. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1024x768@75Hz */
  709. { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 75000, 1024, 1048,
  710. 1184, 1328, 0, 768, 771, 777, 806, 0,
  711. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 1024x768@70Hz */
  712. { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 1048,
  713. 1184, 1344, 0, 768, 771, 777, 806, 0,
  714. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 1024x768@60Hz */
  715. { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER,44900, 1024, 1032,
  716. 1208, 1264, 0, 768, 768, 776, 817, 0,
  717. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_INTERLACE) }, /* 1024x768@43Hz */
  718. { DRM_MODE("832x624", DRM_MODE_TYPE_DRIVER, 57284, 832, 864,
  719. 928, 1152, 0, 624, 625, 628, 667, 0,
  720. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 832x624@75Hz */
  721. { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 49500, 800, 816,
  722. 896, 1056, 0, 600, 601, 604, 625, 0,
  723. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@75Hz */
  724. { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 50000, 800, 856,
  725. 976, 1040, 0, 600, 637, 643, 666, 0,
  726. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@72Hz */
  727. { DRM_MODE("1152x864", DRM_MODE_TYPE_DRIVER, 108000, 1152, 1216,
  728. 1344, 1600, 0, 864, 865, 868, 900, 0,
  729. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1152x864@75Hz */
  730. };
  731. #define EDID_EST_TIMINGS 16
  732. #define EDID_STD_TIMINGS 8
  733. #define EDID_DETAILED_TIMINGS 4
  734. /**
  735. * add_established_modes - get est. modes from EDID and add them
  736. * @edid: EDID block to scan
  737. *
  738. * Each EDID block contains a bitmap of the supported "established modes" list
  739. * (defined above). Tease them out and add them to the global modes list.
  740. */
  741. static int add_established_modes(struct drm_connector *connector, struct edid *edid)
  742. {
  743. struct drm_device *dev = connector->dev;
  744. unsigned long est_bits = edid->established_timings.t1 |
  745. (edid->established_timings.t2 << 8) |
  746. ((edid->established_timings.mfg_rsvd & 0x80) << 9);
  747. int i, modes = 0;
  748. for (i = 0; i <= EDID_EST_TIMINGS; i++)
  749. if (est_bits & (1<<i)) {
  750. struct drm_display_mode *newmode;
  751. newmode = drm_mode_duplicate(dev, &edid_est_modes[i]);
  752. if (newmode) {
  753. drm_mode_probed_add(connector, newmode);
  754. modes++;
  755. }
  756. }
  757. return modes;
  758. }
  759. /**
  760. * stanard_timing_level - get std. timing level(CVT/GTF/DMT)
  761. * @edid: EDID block to scan
  762. */
  763. static int standard_timing_level(struct edid *edid)
  764. {
  765. if (edid->revision >= 2) {
  766. if (edid->revision >= 4 && (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF))
  767. return LEVEL_CVT;
  768. return LEVEL_GTF;
  769. }
  770. return LEVEL_DMT;
  771. }
  772. /**
  773. * add_standard_modes - get std. modes from EDID and add them
  774. * @edid: EDID block to scan
  775. *
  776. * Standard modes can be calculated using the CVT standard. Grab them from
  777. * @edid, calculate them, and add them to the list.
  778. */
  779. static int add_standard_modes(struct drm_connector *connector, struct edid *edid)
  780. {
  781. struct drm_device *dev = connector->dev;
  782. int i, modes = 0;
  783. int timing_level;
  784. timing_level = standard_timing_level(edid);
  785. for (i = 0; i < EDID_STD_TIMINGS; i++) {
  786. struct std_timing *t = &edid->standard_timings[i];
  787. struct drm_display_mode *newmode;
  788. /* If std timings bytes are 1, 1 it's empty */
  789. if (t->hsize == 1 && t->vfreq_aspect == 1)
  790. continue;
  791. newmode = drm_mode_std(dev, &edid->standard_timings[i],
  792. edid->revision, timing_level);
  793. if (newmode) {
  794. drm_mode_probed_add(connector, newmode);
  795. modes++;
  796. }
  797. }
  798. return modes;
  799. }
  800. /*
  801. * XXX fix this for:
  802. * - GTF secondary curve formula
  803. * - EDID 1.4 range offsets
  804. * - CVT extended bits
  805. */
  806. static bool
  807. mode_in_range(struct drm_display_mode *mode, struct detailed_timing *timing)
  808. {
  809. struct detailed_data_monitor_range *range;
  810. int hsync, vrefresh;
  811. range = &timing->data.other_data.data.range;
  812. hsync = drm_mode_hsync(mode);
  813. vrefresh = drm_mode_vrefresh(mode);
  814. if (hsync < range->min_hfreq_khz || hsync > range->max_hfreq_khz)
  815. return false;
  816. if (vrefresh < range->min_vfreq || vrefresh > range->max_vfreq)
  817. return false;
  818. if (range->pixel_clock_mhz && range->pixel_clock_mhz != 0xff) {
  819. /* be forgiving since it's in units of 10MHz */
  820. int max_clock = range->pixel_clock_mhz * 10 + 9;
  821. max_clock *= 1000;
  822. if (mode->clock > max_clock)
  823. return false;
  824. }
  825. return true;
  826. }
  827. /*
  828. * XXX If drm_dmt_modes ever regrows the CVT-R modes (and it will) this will
  829. * need to account for them.
  830. */
  831. static int drm_gtf_modes_for_range(struct drm_connector *connector,
  832. struct detailed_timing *timing)
  833. {
  834. int i, modes = 0;
  835. struct drm_display_mode *newmode;
  836. struct drm_device *dev = connector->dev;
  837. for (i = 0; i < drm_num_dmt_modes; i++) {
  838. if (mode_in_range(drm_dmt_modes + i, timing)) {
  839. newmode = drm_mode_duplicate(dev, &drm_dmt_modes[i]);
  840. if (newmode) {
  841. drm_mode_probed_add(connector, newmode);
  842. modes++;
  843. }
  844. }
  845. }
  846. return modes;
  847. }
  848. static int drm_cvt_modes(struct drm_connector *connector,
  849. struct detailed_timing *timing)
  850. {
  851. int i, j, modes = 0;
  852. struct drm_display_mode *newmode;
  853. struct drm_device *dev = connector->dev;
  854. struct cvt_timing *cvt;
  855. const int rates[] = { 60, 85, 75, 60, 50 };
  856. const u8 empty[3] = { 0, 0, 0 };
  857. for (i = 0; i < 4; i++) {
  858. int uninitialized_var(width), height;
  859. cvt = &(timing->data.other_data.data.cvt[i]);
  860. if (!memcmp(cvt->code, empty, 3))
  861. continue;
  862. height = (cvt->code[0] + ((cvt->code[1] & 0xf0) << 4) + 1) * 2;
  863. switch (cvt->code[1] & 0x0c) {
  864. case 0x00:
  865. width = height * 4 / 3;
  866. break;
  867. case 0x04:
  868. width = height * 16 / 9;
  869. break;
  870. case 0x08:
  871. width = height * 16 / 10;
  872. break;
  873. case 0x0c:
  874. width = height * 15 / 9;
  875. break;
  876. }
  877. for (j = 1; j < 5; j++) {
  878. if (cvt->code[2] & (1 << j)) {
  879. newmode = drm_cvt_mode(dev, width, height,
  880. rates[j], j == 0,
  881. false, false);
  882. if (newmode) {
  883. drm_mode_probed_add(connector, newmode);
  884. modes++;
  885. }
  886. }
  887. }
  888. }
  889. return modes;
  890. }
  891. static int add_detailed_modes(struct drm_connector *connector,
  892. struct detailed_timing *timing,
  893. struct edid *edid, u32 quirks, int preferred)
  894. {
  895. int i, modes = 0;
  896. struct detailed_non_pixel *data = &timing->data.other_data;
  897. int timing_level = standard_timing_level(edid);
  898. int gtf = (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF);
  899. struct drm_display_mode *newmode;
  900. struct drm_device *dev = connector->dev;
  901. if (timing->pixel_clock) {
  902. newmode = drm_mode_detailed(dev, edid, timing, quirks);
  903. if (!newmode)
  904. return 0;
  905. if (preferred)
  906. newmode->type |= DRM_MODE_TYPE_PREFERRED;
  907. drm_mode_probed_add(connector, newmode);
  908. return 1;
  909. }
  910. /* other timing types */
  911. switch (data->type) {
  912. case EDID_DETAIL_MONITOR_RANGE:
  913. if (gtf)
  914. modes += drm_gtf_modes_for_range(connector, timing);
  915. break;
  916. case EDID_DETAIL_STD_MODES:
  917. /* Six modes per detailed section */
  918. for (i = 0; i < 6; i++) {
  919. struct std_timing *std;
  920. struct drm_display_mode *newmode;
  921. std = &data->data.timings[i];
  922. newmode = drm_mode_std(dev, std, edid->revision,
  923. timing_level);
  924. if (newmode) {
  925. drm_mode_probed_add(connector, newmode);
  926. modes++;
  927. }
  928. }
  929. break;
  930. case EDID_DETAIL_CVT_3BYTE:
  931. modes += drm_cvt_modes(connector, timing);
  932. break;
  933. default:
  934. break;
  935. }
  936. return modes;
  937. }
  938. /**
  939. * add_detailed_info - get detailed mode info from EDID data
  940. * @connector: attached connector
  941. * @edid: EDID block to scan
  942. * @quirks: quirks to apply
  943. *
  944. * Some of the detailed timing sections may contain mode information. Grab
  945. * it and add it to the list.
  946. */
  947. static int add_detailed_info(struct drm_connector *connector,
  948. struct edid *edid, u32 quirks)
  949. {
  950. int i, modes = 0;
  951. for (i = 0; i < EDID_DETAILED_TIMINGS; i++) {
  952. struct detailed_timing *timing = &edid->detailed_timings[i];
  953. int preferred = (i == 0) && (edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING);
  954. /* In 1.0, only timings are allowed */
  955. if (!timing->pixel_clock && edid->version == 1 &&
  956. edid->revision == 0)
  957. continue;
  958. modes += add_detailed_modes(connector, timing, edid, quirks,
  959. preferred);
  960. }
  961. return modes;
  962. }
  963. /**
  964. * add_detailed_mode_eedid - get detailed mode info from addtional timing
  965. * EDID block
  966. * @connector: attached connector
  967. * @edid: EDID block to scan(It is only to get addtional timing EDID block)
  968. * @quirks: quirks to apply
  969. *
  970. * Some of the detailed timing sections may contain mode information. Grab
  971. * it and add it to the list.
  972. */
  973. static int add_detailed_info_eedid(struct drm_connector *connector,
  974. struct edid *edid, u32 quirks)
  975. {
  976. int i, modes = 0;
  977. char *edid_ext = NULL;
  978. struct detailed_timing *timing;
  979. int edid_ext_num;
  980. int start_offset, end_offset;
  981. int timing_level;
  982. if (edid->version == 1 && edid->revision < 3) {
  983. /* If the EDID version is less than 1.3, there is no
  984. * extension EDID.
  985. */
  986. return 0;
  987. }
  988. if (!edid->extensions) {
  989. /* if there is no extension EDID, it is unnecessary to
  990. * parse the E-EDID to get detailed info
  991. */
  992. return 0;
  993. }
  994. /* Chose real EDID extension number */
  995. edid_ext_num = edid->extensions > DRM_MAX_EDID_EXT_NUM ?
  996. DRM_MAX_EDID_EXT_NUM : edid->extensions;
  997. /* Find CEA extension */
  998. for (i = 0; i < edid_ext_num; i++) {
  999. edid_ext = (char *)edid + EDID_LENGTH * (i + 1);
  1000. /* This block is CEA extension */
  1001. if (edid_ext[0] == 0x02)
  1002. break;
  1003. }
  1004. if (i == edid_ext_num) {
  1005. /* if there is no additional timing EDID block, return */
  1006. return 0;
  1007. }
  1008. /* Get the start offset of detailed timing block */
  1009. start_offset = edid_ext[2];
  1010. if (start_offset == 0) {
  1011. /* If the start_offset is zero, it means that neither detailed
  1012. * info nor data block exist. In such case it is also
  1013. * unnecessary to parse the detailed timing info.
  1014. */
  1015. return 0;
  1016. }
  1017. timing_level = standard_timing_level(edid);
  1018. end_offset = EDID_LENGTH;
  1019. end_offset -= sizeof(struct detailed_timing);
  1020. for (i = start_offset; i < end_offset;
  1021. i += sizeof(struct detailed_timing)) {
  1022. timing = (struct detailed_timing *)(edid_ext + i);
  1023. modes += add_detailed_modes(connector, timing, edid, quirks, 0);
  1024. }
  1025. return modes;
  1026. }
  1027. #define DDC_ADDR 0x50
  1028. /**
  1029. * Get EDID information via I2C.
  1030. *
  1031. * \param adapter : i2c device adaptor
  1032. * \param buf : EDID data buffer to be filled
  1033. * \param len : EDID data buffer length
  1034. * \return 0 on success or -1 on failure.
  1035. *
  1036. * Try to fetch EDID information by calling i2c driver function.
  1037. */
  1038. int drm_do_probe_ddc_edid(struct i2c_adapter *adapter,
  1039. unsigned char *buf, int len)
  1040. {
  1041. unsigned char start = 0x0;
  1042. struct i2c_msg msgs[] = {
  1043. {
  1044. .addr = DDC_ADDR,
  1045. .flags = 0,
  1046. .len = 1,
  1047. .buf = &start,
  1048. }, {
  1049. .addr = DDC_ADDR,
  1050. .flags = I2C_M_RD,
  1051. .len = len,
  1052. .buf = buf,
  1053. }
  1054. };
  1055. if (i2c_transfer(adapter, msgs, 2) == 2)
  1056. return 0;
  1057. return -1;
  1058. }
  1059. EXPORT_SYMBOL(drm_do_probe_ddc_edid);
  1060. static int drm_ddc_read_edid(struct drm_connector *connector,
  1061. struct i2c_adapter *adapter,
  1062. char *buf, int len)
  1063. {
  1064. int i;
  1065. for (i = 0; i < 4; i++) {
  1066. if (drm_do_probe_ddc_edid(adapter, buf, len))
  1067. return -1;
  1068. if (drm_edid_is_valid((struct edid *)buf))
  1069. return 0;
  1070. }
  1071. /* repeated checksum failures; warn, but carry on */
  1072. dev_warn(&connector->dev->pdev->dev, "%s: EDID invalid.\n",
  1073. drm_get_connector_name(connector));
  1074. return -1;
  1075. }
  1076. /**
  1077. * drm_get_edid - get EDID data, if available
  1078. * @connector: connector we're probing
  1079. * @adapter: i2c adapter to use for DDC
  1080. *
  1081. * Poke the given connector's i2c channel to grab EDID data if possible.
  1082. *
  1083. * Return edid data or NULL if we couldn't find any.
  1084. */
  1085. struct edid *drm_get_edid(struct drm_connector *connector,
  1086. struct i2c_adapter *adapter)
  1087. {
  1088. int ret;
  1089. struct edid *edid;
  1090. edid = kmalloc(EDID_LENGTH * (DRM_MAX_EDID_EXT_NUM + 1),
  1091. GFP_KERNEL);
  1092. if (edid == NULL) {
  1093. dev_warn(&connector->dev->pdev->dev,
  1094. "Failed to allocate EDID\n");
  1095. goto end;
  1096. }
  1097. /* Read first EDID block */
  1098. ret = drm_ddc_read_edid(connector, adapter,
  1099. (unsigned char *)edid, EDID_LENGTH);
  1100. if (ret != 0)
  1101. goto clean_up;
  1102. /* There are EDID extensions to be read */
  1103. if (edid->extensions != 0) {
  1104. int edid_ext_num = edid->extensions;
  1105. if (edid_ext_num > DRM_MAX_EDID_EXT_NUM) {
  1106. dev_warn(&connector->dev->pdev->dev,
  1107. "The number of extension(%d) is "
  1108. "over max (%d), actually read number (%d)\n",
  1109. edid_ext_num, DRM_MAX_EDID_EXT_NUM,
  1110. DRM_MAX_EDID_EXT_NUM);
  1111. /* Reset EDID extension number to be read */
  1112. edid_ext_num = DRM_MAX_EDID_EXT_NUM;
  1113. }
  1114. /* Read EDID including extensions too */
  1115. ret = drm_ddc_read_edid(connector, adapter, (char *)edid,
  1116. EDID_LENGTH * (edid_ext_num + 1));
  1117. if (ret != 0)
  1118. goto clean_up;
  1119. }
  1120. connector->display_info.raw_edid = (char *)edid;
  1121. goto end;
  1122. clean_up:
  1123. kfree(edid);
  1124. edid = NULL;
  1125. end:
  1126. return edid;
  1127. }
  1128. EXPORT_SYMBOL(drm_get_edid);
  1129. #define HDMI_IDENTIFIER 0x000C03
  1130. #define VENDOR_BLOCK 0x03
  1131. /**
  1132. * drm_detect_hdmi_monitor - detect whether monitor is hdmi.
  1133. * @edid: monitor EDID information
  1134. *
  1135. * Parse the CEA extension according to CEA-861-B.
  1136. * Return true if HDMI, false if not or unknown.
  1137. */
  1138. bool drm_detect_hdmi_monitor(struct edid *edid)
  1139. {
  1140. char *edid_ext = NULL;
  1141. int i, hdmi_id, edid_ext_num;
  1142. int start_offset, end_offset;
  1143. bool is_hdmi = false;
  1144. /* No EDID or EDID extensions */
  1145. if (edid == NULL || edid->extensions == 0)
  1146. goto end;
  1147. /* Chose real EDID extension number */
  1148. edid_ext_num = edid->extensions > DRM_MAX_EDID_EXT_NUM ?
  1149. DRM_MAX_EDID_EXT_NUM : edid->extensions;
  1150. /* Find CEA extension */
  1151. for (i = 0; i < edid_ext_num; i++) {
  1152. edid_ext = (char *)edid + EDID_LENGTH * (i + 1);
  1153. /* This block is CEA extension */
  1154. if (edid_ext[0] == 0x02)
  1155. break;
  1156. }
  1157. if (i == edid_ext_num)
  1158. goto end;
  1159. /* Data block offset in CEA extension block */
  1160. start_offset = 4;
  1161. end_offset = edid_ext[2];
  1162. /*
  1163. * Because HDMI identifier is in Vendor Specific Block,
  1164. * search it from all data blocks of CEA extension.
  1165. */
  1166. for (i = start_offset; i < end_offset;
  1167. /* Increased by data block len */
  1168. i += ((edid_ext[i] & 0x1f) + 1)) {
  1169. /* Find vendor specific block */
  1170. if ((edid_ext[i] >> 5) == VENDOR_BLOCK) {
  1171. hdmi_id = edid_ext[i + 1] | (edid_ext[i + 2] << 8) |
  1172. edid_ext[i + 3] << 16;
  1173. /* Find HDMI identifier */
  1174. if (hdmi_id == HDMI_IDENTIFIER)
  1175. is_hdmi = true;
  1176. break;
  1177. }
  1178. }
  1179. end:
  1180. return is_hdmi;
  1181. }
  1182. EXPORT_SYMBOL(drm_detect_hdmi_monitor);
  1183. /**
  1184. * drm_add_edid_modes - add modes from EDID data, if available
  1185. * @connector: connector we're probing
  1186. * @edid: edid data
  1187. *
  1188. * Add the specified modes to the connector's mode list.
  1189. *
  1190. * Return number of modes added or 0 if we couldn't find any.
  1191. */
  1192. int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
  1193. {
  1194. int num_modes = 0;
  1195. u32 quirks;
  1196. if (edid == NULL) {
  1197. return 0;
  1198. }
  1199. if (!drm_edid_is_valid(edid)) {
  1200. dev_warn(&connector->dev->pdev->dev, "%s: EDID invalid.\n",
  1201. drm_get_connector_name(connector));
  1202. return 0;
  1203. }
  1204. quirks = edid_get_quirks(edid);
  1205. num_modes += add_established_modes(connector, edid);
  1206. num_modes += add_standard_modes(connector, edid);
  1207. num_modes += add_detailed_info(connector, edid, quirks);
  1208. num_modes += add_detailed_info_eedid(connector, edid, quirks);
  1209. if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
  1210. edid_fixup_preferred(connector, quirks);
  1211. connector->display_info.serration_vsync = (edid->input & DRM_EDID_INPUT_SERRATION_VSYNC) ? 1 : 0;
  1212. connector->display_info.sync_on_green = (edid->input & DRM_EDID_INPUT_SYNC_ON_GREEN) ? 1 : 0;
  1213. connector->display_info.composite_sync = (edid->input & DRM_EDID_INPUT_COMPOSITE_SYNC) ? 1 : 0;
  1214. connector->display_info.separate_syncs = (edid->input & DRM_EDID_INPUT_SEPARATE_SYNCS) ? 1 : 0;
  1215. connector->display_info.blank_to_black = (edid->input & DRM_EDID_INPUT_BLANK_TO_BLACK) ? 1 : 0;
  1216. connector->display_info.video_level = (edid->input & DRM_EDID_INPUT_VIDEO_LEVEL) >> 5;
  1217. connector->display_info.digital = (edid->input & DRM_EDID_INPUT_DIGITAL) ? 1 : 0;
  1218. connector->display_info.width_mm = edid->width_cm * 10;
  1219. connector->display_info.height_mm = edid->height_cm * 10;
  1220. connector->display_info.gamma = edid->gamma;
  1221. connector->display_info.gtf_supported = (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF) ? 1 : 0;
  1222. connector->display_info.standard_color = (edid->features & DRM_EDID_FEATURE_STANDARD_COLOR) ? 1 : 0;
  1223. connector->display_info.display_type = (edid->features & DRM_EDID_FEATURE_DISPLAY_TYPE) >> 3;
  1224. connector->display_info.active_off_supported = (edid->features & DRM_EDID_FEATURE_PM_ACTIVE_OFF) ? 1 : 0;
  1225. connector->display_info.suspend_supported = (edid->features & DRM_EDID_FEATURE_PM_SUSPEND) ? 1 : 0;
  1226. connector->display_info.standby_supported = (edid->features & DRM_EDID_FEATURE_PM_STANDBY) ? 1 : 0;
  1227. connector->display_info.gamma = edid->gamma;
  1228. return num_modes;
  1229. }
  1230. EXPORT_SYMBOL(drm_add_edid_modes);
  1231. /**
  1232. * drm_add_modes_noedid - add modes for the connectors without EDID
  1233. * @connector: connector we're probing
  1234. * @hdisplay: the horizontal display limit
  1235. * @vdisplay: the vertical display limit
  1236. *
  1237. * Add the specified modes to the connector's mode list. Only when the
  1238. * hdisplay/vdisplay is not beyond the given limit, it will be added.
  1239. *
  1240. * Return number of modes added or 0 if we couldn't find any.
  1241. */
  1242. int drm_add_modes_noedid(struct drm_connector *connector,
  1243. int hdisplay, int vdisplay)
  1244. {
  1245. int i, count, num_modes = 0;
  1246. struct drm_display_mode *mode, *ptr;
  1247. struct drm_device *dev = connector->dev;
  1248. count = sizeof(drm_dmt_modes) / sizeof(struct drm_display_mode);
  1249. if (hdisplay < 0)
  1250. hdisplay = 0;
  1251. if (vdisplay < 0)
  1252. vdisplay = 0;
  1253. for (i = 0; i < count; i++) {
  1254. ptr = &drm_dmt_modes[i];
  1255. if (hdisplay && vdisplay) {
  1256. /*
  1257. * Only when two are valid, they will be used to check
  1258. * whether the mode should be added to the mode list of
  1259. * the connector.
  1260. */
  1261. if (ptr->hdisplay > hdisplay ||
  1262. ptr->vdisplay > vdisplay)
  1263. continue;
  1264. }
  1265. if (drm_mode_vrefresh(ptr) > 61)
  1266. continue;
  1267. mode = drm_mode_duplicate(dev, ptr);
  1268. if (mode) {
  1269. drm_mode_probed_add(connector, mode);
  1270. num_modes++;
  1271. }
  1272. }
  1273. return num_modes;
  1274. }
  1275. EXPORT_SYMBOL(drm_add_modes_noedid);