2 * Copyright (c) 2006 Luc Verhaegen (quirks list)
3 * Copyright (c) 2007-2008 Intel Corporation
4 * Jesse Barnes <jesse.barnes@intel.com>
5 * Copyright 2010 Red Hat, Inc.
7 * DDC probing routines (drm_ddc_read & drm_do_probe_ddc_edid) originally from
9 * Copyright (C) 2006 Dennis Munsie <dmunsie@cecropia.com>
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sub license,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice (including the
19 * next paragraph) shall be included in all copies or substantial portions
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE.
31 #include <linux/bitfield.h>
32 #include <linux/hdmi.h>
33 #include <linux/i2c.h>
34 #include <linux/kernel.h>
35 #include <linux/module.h>
36 #include <linux/pci.h>
37 #include <linux/slab.h>
38 #include <linux/vga_switcheroo.h>
40 #include <drm/drm_displayid.h>
41 #include <drm/drm_drv.h>
42 #include <drm/drm_edid.h>
43 #include <drm/drm_encoder.h>
44 #include <drm/drm_print.h>
46 #include "drm_crtc_internal.h"
48 #define version_greater(edid, maj, min) \
49 (((edid)->version > (maj)) || \
50 ((edid)->version == (maj) && (edid)->revision > (min)))
52 static int oui(u8 first, u8 second, u8 third)
54 return (first << 16) | (second << 8) | third;
57 #define EDID_EST_TIMINGS 16
58 #define EDID_STD_TIMINGS 8
59 #define EDID_DETAILED_TIMINGS 4
62 * EDID blocks out in the wild have a variety of bugs, try to collect
63 * them here (note that userspace may work around broken monitors first,
64 * but fixes should make their way here so that the kernel "just works"
65 * on as many displays as possible).
68 /* First detailed mode wrong, use largest 60Hz mode */
69 #define EDID_QUIRK_PREFER_LARGE_60 (1 << 0)
70 /* Reported 135MHz pixel clock is too high, needs adjustment */
71 #define EDID_QUIRK_135_CLOCK_TOO_HIGH (1 << 1)
72 /* Prefer the largest mode at 75 Hz */
73 #define EDID_QUIRK_PREFER_LARGE_75 (1 << 2)
74 /* Detail timing is in cm not mm */
75 #define EDID_QUIRK_DETAILED_IN_CM (1 << 3)
76 /* Detailed timing descriptors have bogus size values, so just take the
77 * maximum size and use that.
79 #define EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE (1 << 4)
80 /* use +hsync +vsync for detailed mode */
81 #define EDID_QUIRK_DETAILED_SYNC_PP (1 << 6)
82 /* Force reduced-blanking timings for detailed modes */
83 #define EDID_QUIRK_FORCE_REDUCED_BLANKING (1 << 7)
85 #define EDID_QUIRK_FORCE_8BPC (1 << 8)
87 #define EDID_QUIRK_FORCE_12BPC (1 << 9)
89 #define EDID_QUIRK_FORCE_6BPC (1 << 10)
91 #define EDID_QUIRK_FORCE_10BPC (1 << 11)
92 /* Non desktop display (i.e. HMD) */
93 #define EDID_QUIRK_NON_DESKTOP (1 << 12)
95 #define MICROSOFT_IEEE_OUI 0xca125c
97 struct detailed_mode_closure {
98 struct drm_connector *connector;
99 const struct edid *edid;
110 #define EDID_QUIRK(vend_chr_0, vend_chr_1, vend_chr_2, product_id, _quirks) \
112 .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \
117 static const struct edid_quirk {
120 } edid_quirk_list[] = {
122 EDID_QUIRK('A', 'C', 'R', 44358, EDID_QUIRK_PREFER_LARGE_60),
124 EDID_QUIRK('A', 'P', 'I', 0x7602, EDID_QUIRK_PREFER_LARGE_60),
126 /* AEO model 0 reports 8 bpc, but is a 6 bpc panel */
127 EDID_QUIRK('A', 'E', 'O', 0, EDID_QUIRK_FORCE_6BPC),
129 /* BOE model on HP Pavilion 15-n233sl reports 8 bpc, but is a 6 bpc panel */
130 EDID_QUIRK('B', 'O', 'E', 0x78b, EDID_QUIRK_FORCE_6BPC),
132 /* CPT panel of Asus UX303LA reports 8 bpc, but is a 6 bpc panel */
133 EDID_QUIRK('C', 'P', 'T', 0x17df, EDID_QUIRK_FORCE_6BPC),
135 /* SDC panel of Lenovo B50-80 reports 8 bpc, but is a 6 bpc panel */
136 EDID_QUIRK('S', 'D', 'C', 0x3652, EDID_QUIRK_FORCE_6BPC),
138 /* BOE model 0x0771 reports 8 bpc, but is a 6 bpc panel */
139 EDID_QUIRK('B', 'O', 'E', 0x0771, EDID_QUIRK_FORCE_6BPC),
141 /* Belinea 10 15 55 */
142 EDID_QUIRK('M', 'A', 'X', 1516, EDID_QUIRK_PREFER_LARGE_60),
143 EDID_QUIRK('M', 'A', 'X', 0x77e, EDID_QUIRK_PREFER_LARGE_60),
145 /* Envision Peripherals, Inc. EN-7100e */
146 EDID_QUIRK('E', 'P', 'I', 59264, EDID_QUIRK_135_CLOCK_TOO_HIGH),
147 /* Envision EN2028 */
148 EDID_QUIRK('E', 'P', 'I', 8232, EDID_QUIRK_PREFER_LARGE_60),
150 /* Funai Electronics PM36B */
151 EDID_QUIRK('F', 'C', 'M', 13600, EDID_QUIRK_PREFER_LARGE_75 |
152 EDID_QUIRK_DETAILED_IN_CM),
154 /* LGD panel of HP zBook 17 G2, eDP 10 bpc, but reports unknown bpc */
155 EDID_QUIRK('L', 'G', 'D', 764, EDID_QUIRK_FORCE_10BPC),
157 /* LG Philips LCD LP154W01-A5 */
158 EDID_QUIRK('L', 'P', 'L', 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE),
159 EDID_QUIRK('L', 'P', 'L', 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE),
161 /* Samsung SyncMaster 205BW. Note: irony */
162 EDID_QUIRK('S', 'A', 'M', 541, EDID_QUIRK_DETAILED_SYNC_PP),
163 /* Samsung SyncMaster 22[5-6]BW */
164 EDID_QUIRK('S', 'A', 'M', 596, EDID_QUIRK_PREFER_LARGE_60),
165 EDID_QUIRK('S', 'A', 'M', 638, EDID_QUIRK_PREFER_LARGE_60),
167 /* Sony PVM-2541A does up to 12 bpc, but only reports max 8 bpc */
168 EDID_QUIRK('S', 'N', 'Y', 0x2541, EDID_QUIRK_FORCE_12BPC),
170 /* ViewSonic VA2026w */
171 EDID_QUIRK('V', 'S', 'C', 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING),
173 /* Medion MD 30217 PG */
174 EDID_QUIRK('M', 'E', 'D', 0x7b8, EDID_QUIRK_PREFER_LARGE_75),
177 EDID_QUIRK('S', 'D', 'C', 18514, EDID_QUIRK_FORCE_6BPC),
179 /* Panel in Samsung NP700G7A-S01PL notebook reports 6bpc */
180 EDID_QUIRK('S', 'E', 'C', 0xd033, EDID_QUIRK_FORCE_8BPC),
182 /* Rotel RSX-1058 forwards sink's EDID but only does HDMI 1.1*/
183 EDID_QUIRK('E', 'T', 'R', 13896, EDID_QUIRK_FORCE_8BPC),
185 /* Valve Index Headset */
186 EDID_QUIRK('V', 'L', 'V', 0x91a8, EDID_QUIRK_NON_DESKTOP),
187 EDID_QUIRK('V', 'L', 'V', 0x91b0, EDID_QUIRK_NON_DESKTOP),
188 EDID_QUIRK('V', 'L', 'V', 0x91b1, EDID_QUIRK_NON_DESKTOP),
189 EDID_QUIRK('V', 'L', 'V', 0x91b2, EDID_QUIRK_NON_DESKTOP),
190 EDID_QUIRK('V', 'L', 'V', 0x91b3, EDID_QUIRK_NON_DESKTOP),
191 EDID_QUIRK('V', 'L', 'V', 0x91b4, EDID_QUIRK_NON_DESKTOP),
192 EDID_QUIRK('V', 'L', 'V', 0x91b5, EDID_QUIRK_NON_DESKTOP),
193 EDID_QUIRK('V', 'L', 'V', 0x91b6, EDID_QUIRK_NON_DESKTOP),
194 EDID_QUIRK('V', 'L', 'V', 0x91b7, EDID_QUIRK_NON_DESKTOP),
195 EDID_QUIRK('V', 'L', 'V', 0x91b8, EDID_QUIRK_NON_DESKTOP),
196 EDID_QUIRK('V', 'L', 'V', 0x91b9, EDID_QUIRK_NON_DESKTOP),
197 EDID_QUIRK('V', 'L', 'V', 0x91ba, EDID_QUIRK_NON_DESKTOP),
198 EDID_QUIRK('V', 'L', 'V', 0x91bb, EDID_QUIRK_NON_DESKTOP),
199 EDID_QUIRK('V', 'L', 'V', 0x91bc, EDID_QUIRK_NON_DESKTOP),
200 EDID_QUIRK('V', 'L', 'V', 0x91bd, EDID_QUIRK_NON_DESKTOP),
201 EDID_QUIRK('V', 'L', 'V', 0x91be, EDID_QUIRK_NON_DESKTOP),
202 EDID_QUIRK('V', 'L', 'V', 0x91bf, EDID_QUIRK_NON_DESKTOP),
204 /* HTC Vive and Vive Pro VR Headsets */
205 EDID_QUIRK('H', 'V', 'R', 0xaa01, EDID_QUIRK_NON_DESKTOP),
206 EDID_QUIRK('H', 'V', 'R', 0xaa02, EDID_QUIRK_NON_DESKTOP),
208 /* Oculus Rift DK1, DK2, CV1 and Rift S VR Headsets */
209 EDID_QUIRK('O', 'V', 'R', 0x0001, EDID_QUIRK_NON_DESKTOP),
210 EDID_QUIRK('O', 'V', 'R', 0x0003, EDID_QUIRK_NON_DESKTOP),
211 EDID_QUIRK('O', 'V', 'R', 0x0004, EDID_QUIRK_NON_DESKTOP),
212 EDID_QUIRK('O', 'V', 'R', 0x0012, EDID_QUIRK_NON_DESKTOP),
214 /* Windows Mixed Reality Headsets */
215 EDID_QUIRK('A', 'C', 'R', 0x7fce, EDID_QUIRK_NON_DESKTOP),
216 EDID_QUIRK('L', 'E', 'N', 0x0408, EDID_QUIRK_NON_DESKTOP),
217 EDID_QUIRK('F', 'U', 'J', 0x1970, EDID_QUIRK_NON_DESKTOP),
218 EDID_QUIRK('D', 'E', 'L', 0x7fce, EDID_QUIRK_NON_DESKTOP),
219 EDID_QUIRK('S', 'E', 'C', 0x144a, EDID_QUIRK_NON_DESKTOP),
220 EDID_QUIRK('A', 'U', 'S', 0xc102, EDID_QUIRK_NON_DESKTOP),
222 /* Sony PlayStation VR Headset */
223 EDID_QUIRK('S', 'N', 'Y', 0x0704, EDID_QUIRK_NON_DESKTOP),
225 /* Sensics VR Headsets */
226 EDID_QUIRK('S', 'E', 'N', 0x1019, EDID_QUIRK_NON_DESKTOP),
228 /* OSVR HDK and HDK2 VR Headsets */
229 EDID_QUIRK('S', 'V', 'R', 0x1019, EDID_QUIRK_NON_DESKTOP),
233 * Autogenerated from the DMT spec.
234 * This table is copied from xfree86/modes/xf86EdidModes.c.
236 static const struct drm_display_mode drm_dmt_modes[] = {
237 /* 0x01 - 640x350@85Hz */
238 { DRM_MODE("640x350", DRM_MODE_TYPE_DRIVER, 31500, 640, 672,
239 736, 832, 0, 350, 382, 385, 445, 0,
240 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
241 /* 0x02 - 640x400@85Hz */
242 { DRM_MODE("640x400", DRM_MODE_TYPE_DRIVER, 31500, 640, 672,
243 736, 832, 0, 400, 401, 404, 445, 0,
244 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
245 /* 0x03 - 720x400@85Hz */
246 { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 35500, 720, 756,
247 828, 936, 0, 400, 401, 404, 446, 0,
248 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
249 /* 0x04 - 640x480@60Hz */
250 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656,
251 752, 800, 0, 480, 490, 492, 525, 0,
252 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
253 /* 0x05 - 640x480@72Hz */
254 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664,
255 704, 832, 0, 480, 489, 492, 520, 0,
256 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
257 /* 0x06 - 640x480@75Hz */
258 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 656,
259 720, 840, 0, 480, 481, 484, 500, 0,
260 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
261 /* 0x07 - 640x480@85Hz */
262 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 36000, 640, 696,
263 752, 832, 0, 480, 481, 484, 509, 0,
264 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
265 /* 0x08 - 800x600@56Hz */
266 { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 36000, 800, 824,
267 896, 1024, 0, 600, 601, 603, 625, 0,
268 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
269 /* 0x09 - 800x600@60Hz */
270 { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 40000, 800, 840,
271 968, 1056, 0, 600, 601, 605, 628, 0,
272 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
273 /* 0x0a - 800x600@72Hz */
274 { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 50000, 800, 856,
275 976, 1040, 0, 600, 637, 643, 666, 0,
276 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
277 /* 0x0b - 800x600@75Hz */
278 { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 49500, 800, 816,
279 896, 1056, 0, 600, 601, 604, 625, 0,
280 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
281 /* 0x0c - 800x600@85Hz */
282 { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 56250, 800, 832,
283 896, 1048, 0, 600, 601, 604, 631, 0,
284 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
285 /* 0x0d - 800x600@120Hz RB */
286 { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 73250, 800, 848,
287 880, 960, 0, 600, 603, 607, 636, 0,
288 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
289 /* 0x0e - 848x480@60Hz */
290 { DRM_MODE("848x480", DRM_MODE_TYPE_DRIVER, 33750, 848, 864,
291 976, 1088, 0, 480, 486, 494, 517, 0,
292 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
293 /* 0x0f - 1024x768@43Hz, interlace */
294 { DRM_MODE("1024x768i", DRM_MODE_TYPE_DRIVER, 44900, 1024, 1032,
295 1208, 1264, 0, 768, 768, 776, 817, 0,
296 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC |
297 DRM_MODE_FLAG_INTERLACE) },
298 /* 0x10 - 1024x768@60Hz */
299 { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 1048,
300 1184, 1344, 0, 768, 771, 777, 806, 0,
301 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
302 /* 0x11 - 1024x768@70Hz */
303 { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 75000, 1024, 1048,
304 1184, 1328, 0, 768, 771, 777, 806, 0,
305 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
306 /* 0x12 - 1024x768@75Hz */
307 { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 78750, 1024, 1040,
308 1136, 1312, 0, 768, 769, 772, 800, 0,
309 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
310 /* 0x13 - 1024x768@85Hz */
311 { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 94500, 1024, 1072,
312 1168, 1376, 0, 768, 769, 772, 808, 0,
313 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
314 /* 0x14 - 1024x768@120Hz RB */
315 { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 115500, 1024, 1072,
316 1104, 1184, 0, 768, 771, 775, 813, 0,
317 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
318 /* 0x15 - 1152x864@75Hz */
319 { DRM_MODE("1152x864", DRM_MODE_TYPE_DRIVER, 108000, 1152, 1216,
320 1344, 1600, 0, 864, 865, 868, 900, 0,
321 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
322 /* 0x55 - 1280x720@60Hz */
323 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1390,
324 1430, 1650, 0, 720, 725, 730, 750, 0,
325 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
326 /* 0x16 - 1280x768@60Hz RB */
327 { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 68250, 1280, 1328,
328 1360, 1440, 0, 768, 771, 778, 790, 0,
329 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
330 /* 0x17 - 1280x768@60Hz */
331 { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 79500, 1280, 1344,
332 1472, 1664, 0, 768, 771, 778, 798, 0,
333 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
334 /* 0x18 - 1280x768@75Hz */
335 { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 102250, 1280, 1360,
336 1488, 1696, 0, 768, 771, 778, 805, 0,
337 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
338 /* 0x19 - 1280x768@85Hz */
339 { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 117500, 1280, 1360,
340 1496, 1712, 0, 768, 771, 778, 809, 0,
341 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
342 /* 0x1a - 1280x768@120Hz RB */
343 { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 140250, 1280, 1328,
344 1360, 1440, 0, 768, 771, 778, 813, 0,
345 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
346 /* 0x1b - 1280x800@60Hz RB */
347 { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 71000, 1280, 1328,
348 1360, 1440, 0, 800, 803, 809, 823, 0,
349 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
350 /* 0x1c - 1280x800@60Hz */
351 { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 83500, 1280, 1352,
352 1480, 1680, 0, 800, 803, 809, 831, 0,
353 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
354 /* 0x1d - 1280x800@75Hz */
355 { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 106500, 1280, 1360,
356 1488, 1696, 0, 800, 803, 809, 838, 0,
357 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
358 /* 0x1e - 1280x800@85Hz */
359 { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 122500, 1280, 1360,
360 1496, 1712, 0, 800, 803, 809, 843, 0,
361 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
362 /* 0x1f - 1280x800@120Hz RB */
363 { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 146250, 1280, 1328,
364 1360, 1440, 0, 800, 803, 809, 847, 0,
365 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
366 /* 0x20 - 1280x960@60Hz */
367 { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1376,
368 1488, 1800, 0, 960, 961, 964, 1000, 0,
369 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
370 /* 0x21 - 1280x960@85Hz */
371 { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1344,
372 1504, 1728, 0, 960, 961, 964, 1011, 0,
373 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
374 /* 0x22 - 1280x960@120Hz RB */
375 { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 175500, 1280, 1328,
376 1360, 1440, 0, 960, 963, 967, 1017, 0,
377 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
378 /* 0x23 - 1280x1024@60Hz */
379 { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1328,
380 1440, 1688, 0, 1024, 1025, 1028, 1066, 0,
381 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
382 /* 0x24 - 1280x1024@75Hz */
383 { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 135000, 1280, 1296,
384 1440, 1688, 0, 1024, 1025, 1028, 1066, 0,
385 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
386 /* 0x25 - 1280x1024@85Hz */
387 { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 157500, 1280, 1344,
388 1504, 1728, 0, 1024, 1025, 1028, 1072, 0,
389 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
390 /* 0x26 - 1280x1024@120Hz RB */
391 { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 187250, 1280, 1328,
392 1360, 1440, 0, 1024, 1027, 1034, 1084, 0,
393 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
394 /* 0x27 - 1360x768@60Hz */
395 { DRM_MODE("1360x768", DRM_MODE_TYPE_DRIVER, 85500, 1360, 1424,
396 1536, 1792, 0, 768, 771, 777, 795, 0,
397 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
398 /* 0x28 - 1360x768@120Hz RB */
399 { DRM_MODE("1360x768", DRM_MODE_TYPE_DRIVER, 148250, 1360, 1408,
400 1440, 1520, 0, 768, 771, 776, 813, 0,
401 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
402 /* 0x51 - 1366x768@60Hz */
403 { DRM_MODE("1366x768", DRM_MODE_TYPE_DRIVER, 85500, 1366, 1436,
404 1579, 1792, 0, 768, 771, 774, 798, 0,
405 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
406 /* 0x56 - 1366x768@60Hz */
407 { DRM_MODE("1366x768", DRM_MODE_TYPE_DRIVER, 72000, 1366, 1380,
408 1436, 1500, 0, 768, 769, 772, 800, 0,
409 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
410 /* 0x29 - 1400x1050@60Hz RB */
411 { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 101000, 1400, 1448,
412 1480, 1560, 0, 1050, 1053, 1057, 1080, 0,
413 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
414 /* 0x2a - 1400x1050@60Hz */
415 { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 121750, 1400, 1488,
416 1632, 1864, 0, 1050, 1053, 1057, 1089, 0,
417 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
418 /* 0x2b - 1400x1050@75Hz */
419 { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 156000, 1400, 1504,
420 1648, 1896, 0, 1050, 1053, 1057, 1099, 0,
421 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
422 /* 0x2c - 1400x1050@85Hz */
423 { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 179500, 1400, 1504,
424 1656, 1912, 0, 1050, 1053, 1057, 1105, 0,
425 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
426 /* 0x2d - 1400x1050@120Hz RB */
427 { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 208000, 1400, 1448,
428 1480, 1560, 0, 1050, 1053, 1057, 1112, 0,
429 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
430 /* 0x2e - 1440x900@60Hz RB */
431 { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 88750, 1440, 1488,
432 1520, 1600, 0, 900, 903, 909, 926, 0,
433 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
434 /* 0x2f - 1440x900@60Hz */
435 { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 106500, 1440, 1520,
436 1672, 1904, 0, 900, 903, 909, 934, 0,
437 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
438 /* 0x30 - 1440x900@75Hz */
439 { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 136750, 1440, 1536,
440 1688, 1936, 0, 900, 903, 909, 942, 0,
441 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
442 /* 0x31 - 1440x900@85Hz */
443 { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 157000, 1440, 1544,
444 1696, 1952, 0, 900, 903, 909, 948, 0,
445 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
446 /* 0x32 - 1440x900@120Hz RB */
447 { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 182750, 1440, 1488,
448 1520, 1600, 0, 900, 903, 909, 953, 0,
449 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
450 /* 0x53 - 1600x900@60Hz */
451 { DRM_MODE("1600x900", DRM_MODE_TYPE_DRIVER, 108000, 1600, 1624,
452 1704, 1800, 0, 900, 901, 904, 1000, 0,
453 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
454 /* 0x33 - 1600x1200@60Hz */
455 { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 162000, 1600, 1664,
456 1856, 2160, 0, 1200, 1201, 1204, 1250, 0,
457 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
458 /* 0x34 - 1600x1200@65Hz */
459 { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 175500, 1600, 1664,
460 1856, 2160, 0, 1200, 1201, 1204, 1250, 0,
461 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
462 /* 0x35 - 1600x1200@70Hz */
463 { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 189000, 1600, 1664,
464 1856, 2160, 0, 1200, 1201, 1204, 1250, 0,
465 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
466 /* 0x36 - 1600x1200@75Hz */
467 { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 202500, 1600, 1664,
468 1856, 2160, 0, 1200, 1201, 1204, 1250, 0,
469 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
470 /* 0x37 - 1600x1200@85Hz */
471 { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 229500, 1600, 1664,
472 1856, 2160, 0, 1200, 1201, 1204, 1250, 0,
473 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
474 /* 0x38 - 1600x1200@120Hz RB */
475 { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 268250, 1600, 1648,
476 1680, 1760, 0, 1200, 1203, 1207, 1271, 0,
477 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
478 /* 0x39 - 1680x1050@60Hz RB */
479 { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 119000, 1680, 1728,
480 1760, 1840, 0, 1050, 1053, 1059, 1080, 0,
481 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
482 /* 0x3a - 1680x1050@60Hz */
483 { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 146250, 1680, 1784,
484 1960, 2240, 0, 1050, 1053, 1059, 1089, 0,
485 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
486 /* 0x3b - 1680x1050@75Hz */
487 { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 187000, 1680, 1800,
488 1976, 2272, 0, 1050, 1053, 1059, 1099, 0,
489 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
490 /* 0x3c - 1680x1050@85Hz */
491 { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 214750, 1680, 1808,
492 1984, 2288, 0, 1050, 1053, 1059, 1105, 0,
493 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
494 /* 0x3d - 1680x1050@120Hz RB */
495 { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 245500, 1680, 1728,
496 1760, 1840, 0, 1050, 1053, 1059, 1112, 0,
497 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
498 /* 0x3e - 1792x1344@60Hz */
499 { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 204750, 1792, 1920,
500 2120, 2448, 0, 1344, 1345, 1348, 1394, 0,
501 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
502 /* 0x3f - 1792x1344@75Hz */
503 { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 261000, 1792, 1888,
504 2104, 2456, 0, 1344, 1345, 1348, 1417, 0,
505 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
506 /* 0x40 - 1792x1344@120Hz RB */
507 { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 333250, 1792, 1840,
508 1872, 1952, 0, 1344, 1347, 1351, 1423, 0,
509 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
510 /* 0x41 - 1856x1392@60Hz */
511 { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 218250, 1856, 1952,
512 2176, 2528, 0, 1392, 1393, 1396, 1439, 0,
513 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
514 /* 0x42 - 1856x1392@75Hz */
515 { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 288000, 1856, 1984,
516 2208, 2560, 0, 1392, 1393, 1396, 1500, 0,
517 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
518 /* 0x43 - 1856x1392@120Hz RB */
519 { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 356500, 1856, 1904,
520 1936, 2016, 0, 1392, 1395, 1399, 1474, 0,
521 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
522 /* 0x52 - 1920x1080@60Hz */
523 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2008,
524 2052, 2200, 0, 1080, 1084, 1089, 1125, 0,
525 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
526 /* 0x44 - 1920x1200@60Hz RB */
527 { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 154000, 1920, 1968,
528 2000, 2080, 0, 1200, 1203, 1209, 1235, 0,
529 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
530 /* 0x45 - 1920x1200@60Hz */
531 { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 193250, 1920, 2056,
532 2256, 2592, 0, 1200, 1203, 1209, 1245, 0,
533 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
534 /* 0x46 - 1920x1200@75Hz */
535 { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 245250, 1920, 2056,
536 2264, 2608, 0, 1200, 1203, 1209, 1255, 0,
537 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
538 /* 0x47 - 1920x1200@85Hz */
539 { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 281250, 1920, 2064,
540 2272, 2624, 0, 1200, 1203, 1209, 1262, 0,
541 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
542 /* 0x48 - 1920x1200@120Hz RB */
543 { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 317000, 1920, 1968,
544 2000, 2080, 0, 1200, 1203, 1209, 1271, 0,
545 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
546 /* 0x49 - 1920x1440@60Hz */
547 { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 234000, 1920, 2048,
548 2256, 2600, 0, 1440, 1441, 1444, 1500, 0,
549 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
550 /* 0x4a - 1920x1440@75Hz */
551 { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2064,
552 2288, 2640, 0, 1440, 1441, 1444, 1500, 0,
553 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
554 /* 0x4b - 1920x1440@120Hz RB */
555 { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 380500, 1920, 1968,
556 2000, 2080, 0, 1440, 1443, 1447, 1525, 0,
557 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
558 /* 0x54 - 2048x1152@60Hz */
559 { DRM_MODE("2048x1152", DRM_MODE_TYPE_DRIVER, 162000, 2048, 2074,
560 2154, 2250, 0, 1152, 1153, 1156, 1200, 0,
561 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
562 /* 0x4c - 2560x1600@60Hz RB */
563 { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 268500, 2560, 2608,
564 2640, 2720, 0, 1600, 1603, 1609, 1646, 0,
565 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
566 /* 0x4d - 2560x1600@60Hz */
567 { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 348500, 2560, 2752,
568 3032, 3504, 0, 1600, 1603, 1609, 1658, 0,
569 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
570 /* 0x4e - 2560x1600@75Hz */
571 { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 443250, 2560, 2768,
572 3048, 3536, 0, 1600, 1603, 1609, 1672, 0,
573 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
574 /* 0x4f - 2560x1600@85Hz */
575 { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 505250, 2560, 2768,
576 3048, 3536, 0, 1600, 1603, 1609, 1682, 0,
577 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
578 /* 0x50 - 2560x1600@120Hz RB */
579 { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 552750, 2560, 2608,
580 2640, 2720, 0, 1600, 1603, 1609, 1694, 0,
581 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
582 /* 0x57 - 4096x2160@60Hz RB */
583 { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 556744, 4096, 4104,
584 4136, 4176, 0, 2160, 2208, 2216, 2222, 0,
585 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
586 /* 0x58 - 4096x2160@59.94Hz RB */
587 { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 556188, 4096, 4104,
588 4136, 4176, 0, 2160, 2208, 2216, 2222, 0,
589 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
593 * These more or less come from the DMT spec. The 720x400 modes are
594 * inferred from historical 80x25 practice. The 640x480@67 and 832x624@75
595 * modes are old-school Mac modes. The EDID spec says the 1152x864@75 mode
596 * should be 1152x870, again for the Mac, but instead we use the x864 DMT
599 * The DMT modes have been fact-checked; the rest are mild guesses.
601 static const struct drm_display_mode edid_est_modes[] = {
602 { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 40000, 800, 840,
603 968, 1056, 0, 600, 601, 605, 628, 0,
604 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@60Hz */
605 { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 36000, 800, 824,
606 896, 1024, 0, 600, 601, 603, 625, 0,
607 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@56Hz */
608 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 656,
609 720, 840, 0, 480, 481, 484, 500, 0,
610 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@75Hz */
611 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664,
612 704, 832, 0, 480, 489, 492, 520, 0,
613 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@72Hz */
614 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 30240, 640, 704,
615 768, 864, 0, 480, 483, 486, 525, 0,
616 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@67Hz */
617 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656,
618 752, 800, 0, 480, 490, 492, 525, 0,
619 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@60Hz */
620 { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 35500, 720, 738,
621 846, 900, 0, 400, 421, 423, 449, 0,
622 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 720x400@88Hz */
623 { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 28320, 720, 738,
624 846, 900, 0, 400, 412, 414, 449, 0,
625 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 720x400@70Hz */
626 { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 135000, 1280, 1296,
627 1440, 1688, 0, 1024, 1025, 1028, 1066, 0,
628 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1280x1024@75Hz */
629 { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 78750, 1024, 1040,
630 1136, 1312, 0, 768, 769, 772, 800, 0,
631 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1024x768@75Hz */
632 { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 75000, 1024, 1048,
633 1184, 1328, 0, 768, 771, 777, 806, 0,
634 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 1024x768@70Hz */
635 { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 1048,
636 1184, 1344, 0, 768, 771, 777, 806, 0,
637 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 1024x768@60Hz */
638 { DRM_MODE("1024x768i", DRM_MODE_TYPE_DRIVER,44900, 1024, 1032,
639 1208, 1264, 0, 768, 768, 776, 817, 0,
640 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_INTERLACE) }, /* 1024x768@43Hz */
641 { DRM_MODE("832x624", DRM_MODE_TYPE_DRIVER, 57284, 832, 864,
642 928, 1152, 0, 624, 625, 628, 667, 0,
643 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 832x624@75Hz */
644 { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 49500, 800, 816,
645 896, 1056, 0, 600, 601, 604, 625, 0,
646 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@75Hz */
647 { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 50000, 800, 856,
648 976, 1040, 0, 600, 637, 643, 666, 0,
649 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 800x600@72Hz */
650 { DRM_MODE("1152x864", DRM_MODE_TYPE_DRIVER, 108000, 1152, 1216,
651 1344, 1600, 0, 864, 865, 868, 900, 0,
652 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1152x864@75Hz */
662 static const struct minimode est3_modes[] = {
670 { 1024, 768, 85, 0 },
671 { 1152, 864, 75, 0 },
673 { 1280, 768, 60, 1 },
674 { 1280, 768, 60, 0 },
675 { 1280, 768, 75, 0 },
676 { 1280, 768, 85, 0 },
677 { 1280, 960, 60, 0 },
678 { 1280, 960, 85, 0 },
679 { 1280, 1024, 60, 0 },
680 { 1280, 1024, 85, 0 },
682 { 1360, 768, 60, 0 },
683 { 1440, 900, 60, 1 },
684 { 1440, 900, 60, 0 },
685 { 1440, 900, 75, 0 },
686 { 1440, 900, 85, 0 },
687 { 1400, 1050, 60, 1 },
688 { 1400, 1050, 60, 0 },
689 { 1400, 1050, 75, 0 },
691 { 1400, 1050, 85, 0 },
692 { 1680, 1050, 60, 1 },
693 { 1680, 1050, 60, 0 },
694 { 1680, 1050, 75, 0 },
695 { 1680, 1050, 85, 0 },
696 { 1600, 1200, 60, 0 },
697 { 1600, 1200, 65, 0 },
698 { 1600, 1200, 70, 0 },
700 { 1600, 1200, 75, 0 },
701 { 1600, 1200, 85, 0 },
702 { 1792, 1344, 60, 0 },
703 { 1792, 1344, 75, 0 },
704 { 1856, 1392, 60, 0 },
705 { 1856, 1392, 75, 0 },
706 { 1920, 1200, 60, 1 },
707 { 1920, 1200, 60, 0 },
709 { 1920, 1200, 75, 0 },
710 { 1920, 1200, 85, 0 },
711 { 1920, 1440, 60, 0 },
712 { 1920, 1440, 75, 0 },
715 static const struct minimode extra_modes[] = {
716 { 1024, 576, 60, 0 },
717 { 1366, 768, 60, 0 },
718 { 1600, 900, 60, 0 },
719 { 1680, 945, 60, 0 },
720 { 1920, 1080, 60, 0 },
721 { 2048, 1152, 60, 0 },
722 { 2048, 1536, 60, 0 },
726 * From CEA/CTA-861 spec.
728 * Do not access directly, instead always use cea_mode_for_vic().
730 static const struct drm_display_mode edid_cea_modes_1[] = {
731 /* 1 - 640x480@60Hz 4:3 */
732 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656,
733 752, 800, 0, 480, 490, 492, 525, 0,
734 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
735 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
736 /* 2 - 720x480@60Hz 4:3 */
737 { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 27000, 720, 736,
738 798, 858, 0, 480, 489, 495, 525, 0,
739 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
740 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
741 /* 3 - 720x480@60Hz 16:9 */
742 { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 27000, 720, 736,
743 798, 858, 0, 480, 489, 495, 525, 0,
744 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
745 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
746 /* 4 - 1280x720@60Hz 16:9 */
747 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1390,
748 1430, 1650, 0, 720, 725, 730, 750, 0,
749 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
750 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
751 /* 5 - 1920x1080i@60Hz 16:9 */
752 { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2008,
753 2052, 2200, 0, 1080, 1084, 1094, 1125, 0,
754 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC |
755 DRM_MODE_FLAG_INTERLACE),
756 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
757 /* 6 - 720(1440)x480i@60Hz 4:3 */
758 { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 13500, 720, 739,
759 801, 858, 0, 480, 488, 494, 525, 0,
760 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
761 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
762 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
763 /* 7 - 720(1440)x480i@60Hz 16:9 */
764 { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 13500, 720, 739,
765 801, 858, 0, 480, 488, 494, 525, 0,
766 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
767 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
768 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
769 /* 8 - 720(1440)x240@60Hz 4:3 */
770 { DRM_MODE("720x240", DRM_MODE_TYPE_DRIVER, 13500, 720, 739,
771 801, 858, 0, 240, 244, 247, 262, 0,
772 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
773 DRM_MODE_FLAG_DBLCLK),
774 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
775 /* 9 - 720(1440)x240@60Hz 16:9 */
776 { DRM_MODE("720x240", DRM_MODE_TYPE_DRIVER, 13500, 720, 739,
777 801, 858, 0, 240, 244, 247, 262, 0,
778 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
779 DRM_MODE_FLAG_DBLCLK),
780 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
781 /* 10 - 2880x480i@60Hz 4:3 */
782 { DRM_MODE("2880x480i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2956,
783 3204, 3432, 0, 480, 488, 494, 525, 0,
784 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
785 DRM_MODE_FLAG_INTERLACE),
786 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
787 /* 11 - 2880x480i@60Hz 16:9 */
788 { DRM_MODE("2880x480i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2956,
789 3204, 3432, 0, 480, 488, 494, 525, 0,
790 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
791 DRM_MODE_FLAG_INTERLACE),
792 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
793 /* 12 - 2880x240@60Hz 4:3 */
794 { DRM_MODE("2880x240", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2956,
795 3204, 3432, 0, 240, 244, 247, 262, 0,
796 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
797 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
798 /* 13 - 2880x240@60Hz 16:9 */
799 { DRM_MODE("2880x240", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2956,
800 3204, 3432, 0, 240, 244, 247, 262, 0,
801 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
802 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
803 /* 14 - 1440x480@60Hz 4:3 */
804 { DRM_MODE("1440x480", DRM_MODE_TYPE_DRIVER, 54000, 1440, 1472,
805 1596, 1716, 0, 480, 489, 495, 525, 0,
806 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
807 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
808 /* 15 - 1440x480@60Hz 16:9 */
809 { DRM_MODE("1440x480", DRM_MODE_TYPE_DRIVER, 54000, 1440, 1472,
810 1596, 1716, 0, 480, 489, 495, 525, 0,
811 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
812 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
813 /* 16 - 1920x1080@60Hz 16:9 */
814 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2008,
815 2052, 2200, 0, 1080, 1084, 1089, 1125, 0,
816 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
817 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
818 /* 17 - 720x576@50Hz 4:3 */
819 { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 27000, 720, 732,
820 796, 864, 0, 576, 581, 586, 625, 0,
821 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
822 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
823 /* 18 - 720x576@50Hz 16:9 */
824 { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 27000, 720, 732,
825 796, 864, 0, 576, 581, 586, 625, 0,
826 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
827 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
828 /* 19 - 1280x720@50Hz 16:9 */
829 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1720,
830 1760, 1980, 0, 720, 725, 730, 750, 0,
831 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
832 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
833 /* 20 - 1920x1080i@50Hz 16:9 */
834 { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2448,
835 2492, 2640, 0, 1080, 1084, 1094, 1125, 0,
836 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC |
837 DRM_MODE_FLAG_INTERLACE),
838 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
839 /* 21 - 720(1440)x576i@50Hz 4:3 */
840 { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 13500, 720, 732,
841 795, 864, 0, 576, 580, 586, 625, 0,
842 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
843 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
844 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
845 /* 22 - 720(1440)x576i@50Hz 16:9 */
846 { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 13500, 720, 732,
847 795, 864, 0, 576, 580, 586, 625, 0,
848 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
849 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
850 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
851 /* 23 - 720(1440)x288@50Hz 4:3 */
852 { DRM_MODE("720x288", DRM_MODE_TYPE_DRIVER, 13500, 720, 732,
853 795, 864, 0, 288, 290, 293, 312, 0,
854 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
855 DRM_MODE_FLAG_DBLCLK),
856 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
857 /* 24 - 720(1440)x288@50Hz 16:9 */
858 { DRM_MODE("720x288", DRM_MODE_TYPE_DRIVER, 13500, 720, 732,
859 795, 864, 0, 288, 290, 293, 312, 0,
860 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
861 DRM_MODE_FLAG_DBLCLK),
862 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
863 /* 25 - 2880x576i@50Hz 4:3 */
864 { DRM_MODE("2880x576i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2928,
865 3180, 3456, 0, 576, 580, 586, 625, 0,
866 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
867 DRM_MODE_FLAG_INTERLACE),
868 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
869 /* 26 - 2880x576i@50Hz 16:9 */
870 { DRM_MODE("2880x576i", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2928,
871 3180, 3456, 0, 576, 580, 586, 625, 0,
872 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
873 DRM_MODE_FLAG_INTERLACE),
874 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
875 /* 27 - 2880x288@50Hz 4:3 */
876 { DRM_MODE("2880x288", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2928,
877 3180, 3456, 0, 288, 290, 293, 312, 0,
878 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
879 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
880 /* 28 - 2880x288@50Hz 16:9 */
881 { DRM_MODE("2880x288", DRM_MODE_TYPE_DRIVER, 54000, 2880, 2928,
882 3180, 3456, 0, 288, 290, 293, 312, 0,
883 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
884 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
885 /* 29 - 1440x576@50Hz 4:3 */
886 { DRM_MODE("1440x576", DRM_MODE_TYPE_DRIVER, 54000, 1440, 1464,
887 1592, 1728, 0, 576, 581, 586, 625, 0,
888 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
889 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
890 /* 30 - 1440x576@50Hz 16:9 */
891 { DRM_MODE("1440x576", DRM_MODE_TYPE_DRIVER, 54000, 1440, 1464,
892 1592, 1728, 0, 576, 581, 586, 625, 0,
893 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
894 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
895 /* 31 - 1920x1080@50Hz 16:9 */
896 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2448,
897 2492, 2640, 0, 1080, 1084, 1089, 1125, 0,
898 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
899 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
900 /* 32 - 1920x1080@24Hz 16:9 */
901 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2558,
902 2602, 2750, 0, 1080, 1084, 1089, 1125, 0,
903 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
904 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
905 /* 33 - 1920x1080@25Hz 16:9 */
906 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2448,
907 2492, 2640, 0, 1080, 1084, 1089, 1125, 0,
908 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
909 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
910 /* 34 - 1920x1080@30Hz 16:9 */
911 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2008,
912 2052, 2200, 0, 1080, 1084, 1089, 1125, 0,
913 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
914 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
915 /* 35 - 2880x480@60Hz 4:3 */
916 { DRM_MODE("2880x480", DRM_MODE_TYPE_DRIVER, 108000, 2880, 2944,
917 3192, 3432, 0, 480, 489, 495, 525, 0,
918 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
919 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
920 /* 36 - 2880x480@60Hz 16:9 */
921 { DRM_MODE("2880x480", DRM_MODE_TYPE_DRIVER, 108000, 2880, 2944,
922 3192, 3432, 0, 480, 489, 495, 525, 0,
923 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
924 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
925 /* 37 - 2880x576@50Hz 4:3 */
926 { DRM_MODE("2880x576", DRM_MODE_TYPE_DRIVER, 108000, 2880, 2928,
927 3184, 3456, 0, 576, 581, 586, 625, 0,
928 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
929 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
930 /* 38 - 2880x576@50Hz 16:9 */
931 { DRM_MODE("2880x576", DRM_MODE_TYPE_DRIVER, 108000, 2880, 2928,
932 3184, 3456, 0, 576, 581, 586, 625, 0,
933 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
934 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
935 /* 39 - 1920x1080i@50Hz 16:9 */
936 { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 72000, 1920, 1952,
937 2120, 2304, 0, 1080, 1126, 1136, 1250, 0,
938 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC |
939 DRM_MODE_FLAG_INTERLACE),
940 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
941 /* 40 - 1920x1080i@100Hz 16:9 */
942 { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2448,
943 2492, 2640, 0, 1080, 1084, 1094, 1125, 0,
944 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC |
945 DRM_MODE_FLAG_INTERLACE),
946 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
947 /* 41 - 1280x720@100Hz 16:9 */
948 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1720,
949 1760, 1980, 0, 720, 725, 730, 750, 0,
950 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
951 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
952 /* 42 - 720x576@100Hz 4:3 */
953 { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 54000, 720, 732,
954 796, 864, 0, 576, 581, 586, 625, 0,
955 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
956 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
957 /* 43 - 720x576@100Hz 16:9 */
958 { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 54000, 720, 732,
959 796, 864, 0, 576, 581, 586, 625, 0,
960 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
961 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
962 /* 44 - 720(1440)x576i@100Hz 4:3 */
963 { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 27000, 720, 732,
964 795, 864, 0, 576, 580, 586, 625, 0,
965 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
966 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
967 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
968 /* 45 - 720(1440)x576i@100Hz 16:9 */
969 { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 27000, 720, 732,
970 795, 864, 0, 576, 580, 586, 625, 0,
971 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
972 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
973 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
974 /* 46 - 1920x1080i@120Hz 16:9 */
975 { DRM_MODE("1920x1080i", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2008,
976 2052, 2200, 0, 1080, 1084, 1094, 1125, 0,
977 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC |
978 DRM_MODE_FLAG_INTERLACE),
979 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
980 /* 47 - 1280x720@120Hz 16:9 */
981 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1390,
982 1430, 1650, 0, 720, 725, 730, 750, 0,
983 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
984 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
985 /* 48 - 720x480@120Hz 4:3 */
986 { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 54000, 720, 736,
987 798, 858, 0, 480, 489, 495, 525, 0,
988 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
989 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
990 /* 49 - 720x480@120Hz 16:9 */
991 { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 54000, 720, 736,
992 798, 858, 0, 480, 489, 495, 525, 0,
993 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
994 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
995 /* 50 - 720(1440)x480i@120Hz 4:3 */
996 { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 27000, 720, 739,
997 801, 858, 0, 480, 488, 494, 525, 0,
998 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
999 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
1000 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
1001 /* 51 - 720(1440)x480i@120Hz 16:9 */
1002 { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 27000, 720, 739,
1003 801, 858, 0, 480, 488, 494, 525, 0,
1004 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
1005 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
1006 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1007 /* 52 - 720x576@200Hz 4:3 */
1008 { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 108000, 720, 732,
1009 796, 864, 0, 576, 581, 586, 625, 0,
1010 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
1011 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
1012 /* 53 - 720x576@200Hz 16:9 */
1013 { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 108000, 720, 732,
1014 796, 864, 0, 576, 581, 586, 625, 0,
1015 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
1016 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1017 /* 54 - 720(1440)x576i@200Hz 4:3 */
1018 { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 54000, 720, 732,
1019 795, 864, 0, 576, 580, 586, 625, 0,
1020 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
1021 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
1022 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
1023 /* 55 - 720(1440)x576i@200Hz 16:9 */
1024 { DRM_MODE("720x576i", DRM_MODE_TYPE_DRIVER, 54000, 720, 732,
1025 795, 864, 0, 576, 580, 586, 625, 0,
1026 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
1027 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
1028 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1029 /* 56 - 720x480@240Hz 4:3 */
1030 { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 108000, 720, 736,
1031 798, 858, 0, 480, 489, 495, 525, 0,
1032 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
1033 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
1034 /* 57 - 720x480@240Hz 16:9 */
1035 { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 108000, 720, 736,
1036 798, 858, 0, 480, 489, 495, 525, 0,
1037 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC),
1038 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1039 /* 58 - 720(1440)x480i@240Hz 4:3 */
1040 { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 54000, 720, 739,
1041 801, 858, 0, 480, 488, 494, 525, 0,
1042 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
1043 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
1044 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_4_3, },
1045 /* 59 - 720(1440)x480i@240Hz 16:9 */
1046 { DRM_MODE("720x480i", DRM_MODE_TYPE_DRIVER, 54000, 720, 739,
1047 801, 858, 0, 480, 488, 494, 525, 0,
1048 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
1049 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_DBLCLK),
1050 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1051 /* 60 - 1280x720@24Hz 16:9 */
1052 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 59400, 1280, 3040,
1053 3080, 3300, 0, 720, 725, 730, 750, 0,
1054 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1055 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1056 /* 61 - 1280x720@25Hz 16:9 */
1057 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 3700,
1058 3740, 3960, 0, 720, 725, 730, 750, 0,
1059 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1060 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1061 /* 62 - 1280x720@30Hz 16:9 */
1062 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 3040,
1063 3080, 3300, 0, 720, 725, 730, 750, 0,
1064 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1065 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1066 /* 63 - 1920x1080@120Hz 16:9 */
1067 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2008,
1068 2052, 2200, 0, 1080, 1084, 1089, 1125, 0,
1069 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1070 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1071 /* 64 - 1920x1080@100Hz 16:9 */
1072 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2448,
1073 2492, 2640, 0, 1080, 1084, 1089, 1125, 0,
1074 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1075 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1076 /* 65 - 1280x720@24Hz 64:27 */
1077 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 59400, 1280, 3040,
1078 3080, 3300, 0, 720, 725, 730, 750, 0,
1079 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1080 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1081 /* 66 - 1280x720@25Hz 64:27 */
1082 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 3700,
1083 3740, 3960, 0, 720, 725, 730, 750, 0,
1084 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1085 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1086 /* 67 - 1280x720@30Hz 64:27 */
1087 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 3040,
1088 3080, 3300, 0, 720, 725, 730, 750, 0,
1089 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1090 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1091 /* 68 - 1280x720@50Hz 64:27 */
1092 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1720,
1093 1760, 1980, 0, 720, 725, 730, 750, 0,
1094 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1095 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1096 /* 69 - 1280x720@60Hz 64:27 */
1097 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 74250, 1280, 1390,
1098 1430, 1650, 0, 720, 725, 730, 750, 0,
1099 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1100 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1101 /* 70 - 1280x720@100Hz 64:27 */
1102 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1720,
1103 1760, 1980, 0, 720, 725, 730, 750, 0,
1104 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1105 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1106 /* 71 - 1280x720@120Hz 64:27 */
1107 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 148500, 1280, 1390,
1108 1430, 1650, 0, 720, 725, 730, 750, 0,
1109 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1110 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1111 /* 72 - 1920x1080@24Hz 64:27 */
1112 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2558,
1113 2602, 2750, 0, 1080, 1084, 1089, 1125, 0,
1114 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1115 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1116 /* 73 - 1920x1080@25Hz 64:27 */
1117 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2448,
1118 2492, 2640, 0, 1080, 1084, 1089, 1125, 0,
1119 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1120 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1121 /* 74 - 1920x1080@30Hz 64:27 */
1122 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 74250, 1920, 2008,
1123 2052, 2200, 0, 1080, 1084, 1089, 1125, 0,
1124 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1125 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1126 /* 75 - 1920x1080@50Hz 64:27 */
1127 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2448,
1128 2492, 2640, 0, 1080, 1084, 1089, 1125, 0,
1129 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1130 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1131 /* 76 - 1920x1080@60Hz 64:27 */
1132 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2008,
1133 2052, 2200, 0, 1080, 1084, 1089, 1125, 0,
1134 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1135 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1136 /* 77 - 1920x1080@100Hz 64:27 */
1137 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2448,
1138 2492, 2640, 0, 1080, 1084, 1089, 1125, 0,
1139 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1140 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1141 /* 78 - 1920x1080@120Hz 64:27 */
1142 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2008,
1143 2052, 2200, 0, 1080, 1084, 1089, 1125, 0,
1144 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1145 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1146 /* 79 - 1680x720@24Hz 64:27 */
1147 { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 59400, 1680, 3040,
1148 3080, 3300, 0, 720, 725, 730, 750, 0,
1149 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1150 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1151 /* 80 - 1680x720@25Hz 64:27 */
1152 { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 59400, 1680, 2908,
1153 2948, 3168, 0, 720, 725, 730, 750, 0,
1154 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1155 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1156 /* 81 - 1680x720@30Hz 64:27 */
1157 { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 59400, 1680, 2380,
1158 2420, 2640, 0, 720, 725, 730, 750, 0,
1159 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1160 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1161 /* 82 - 1680x720@50Hz 64:27 */
1162 { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 82500, 1680, 1940,
1163 1980, 2200, 0, 720, 725, 730, 750, 0,
1164 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1165 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1166 /* 83 - 1680x720@60Hz 64:27 */
1167 { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 99000, 1680, 1940,
1168 1980, 2200, 0, 720, 725, 730, 750, 0,
1169 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1170 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1171 /* 84 - 1680x720@100Hz 64:27 */
1172 { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 165000, 1680, 1740,
1173 1780, 2000, 0, 720, 725, 730, 825, 0,
1174 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1175 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1176 /* 85 - 1680x720@120Hz 64:27 */
1177 { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 198000, 1680, 1740,
1178 1780, 2000, 0, 720, 725, 730, 825, 0,
1179 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1180 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1181 /* 86 - 2560x1080@24Hz 64:27 */
1182 { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 99000, 2560, 3558,
1183 3602, 3750, 0, 1080, 1084, 1089, 1100, 0,
1184 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1185 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1186 /* 87 - 2560x1080@25Hz 64:27 */
1187 { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 90000, 2560, 3008,
1188 3052, 3200, 0, 1080, 1084, 1089, 1125, 0,
1189 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1190 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1191 /* 88 - 2560x1080@30Hz 64:27 */
1192 { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 118800, 2560, 3328,
1193 3372, 3520, 0, 1080, 1084, 1089, 1125, 0,
1194 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1195 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1196 /* 89 - 2560x1080@50Hz 64:27 */
1197 { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 185625, 2560, 3108,
1198 3152, 3300, 0, 1080, 1084, 1089, 1125, 0,
1199 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1200 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1201 /* 90 - 2560x1080@60Hz 64:27 */
1202 { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 198000, 2560, 2808,
1203 2852, 3000, 0, 1080, 1084, 1089, 1100, 0,
1204 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1205 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1206 /* 91 - 2560x1080@100Hz 64:27 */
1207 { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 371250, 2560, 2778,
1208 2822, 2970, 0, 1080, 1084, 1089, 1250, 0,
1209 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1210 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1211 /* 92 - 2560x1080@120Hz 64:27 */
1212 { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 495000, 2560, 3108,
1213 3152, 3300, 0, 1080, 1084, 1089, 1250, 0,
1214 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1215 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1216 /* 93 - 3840x2160@24Hz 16:9 */
1217 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 5116,
1218 5204, 5500, 0, 2160, 2168, 2178, 2250, 0,
1219 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1220 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1221 /* 94 - 3840x2160@25Hz 16:9 */
1222 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 4896,
1223 4984, 5280, 0, 2160, 2168, 2178, 2250, 0,
1224 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1225 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1226 /* 95 - 3840x2160@30Hz 16:9 */
1227 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 4016,
1228 4104, 4400, 0, 2160, 2168, 2178, 2250, 0,
1229 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1230 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1231 /* 96 - 3840x2160@50Hz 16:9 */
1232 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4896,
1233 4984, 5280, 0, 2160, 2168, 2178, 2250, 0,
1234 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1235 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1236 /* 97 - 3840x2160@60Hz 16:9 */
1237 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4016,
1238 4104, 4400, 0, 2160, 2168, 2178, 2250, 0,
1239 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1240 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1241 /* 98 - 4096x2160@24Hz 256:135 */
1242 { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000, 4096, 5116,
1243 5204, 5500, 0, 2160, 2168, 2178, 2250, 0,
1244 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1245 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
1246 /* 99 - 4096x2160@25Hz 256:135 */
1247 { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000, 4096, 5064,
1248 5152, 5280, 0, 2160, 2168, 2178, 2250, 0,
1249 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1250 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
1251 /* 100 - 4096x2160@30Hz 256:135 */
1252 { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000, 4096, 4184,
1253 4272, 4400, 0, 2160, 2168, 2178, 2250, 0,
1254 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1255 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
1256 /* 101 - 4096x2160@50Hz 256:135 */
1257 { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 594000, 4096, 5064,
1258 5152, 5280, 0, 2160, 2168, 2178, 2250, 0,
1259 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1260 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
1261 /* 102 - 4096x2160@60Hz 256:135 */
1262 { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 594000, 4096, 4184,
1263 4272, 4400, 0, 2160, 2168, 2178, 2250, 0,
1264 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1265 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
1266 /* 103 - 3840x2160@24Hz 64:27 */
1267 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 5116,
1268 5204, 5500, 0, 2160, 2168, 2178, 2250, 0,
1269 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1270 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1271 /* 104 - 3840x2160@25Hz 64:27 */
1272 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 4896,
1273 4984, 5280, 0, 2160, 2168, 2178, 2250, 0,
1274 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1275 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1276 /* 105 - 3840x2160@30Hz 64:27 */
1277 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000, 3840, 4016,
1278 4104, 4400, 0, 2160, 2168, 2178, 2250, 0,
1279 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1280 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1281 /* 106 - 3840x2160@50Hz 64:27 */
1282 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4896,
1283 4984, 5280, 0, 2160, 2168, 2178, 2250, 0,
1284 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1285 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1286 /* 107 - 3840x2160@60Hz 64:27 */
1287 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4016,
1288 4104, 4400, 0, 2160, 2168, 2178, 2250, 0,
1289 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1290 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1291 /* 108 - 1280x720@48Hz 16:9 */
1292 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 90000, 1280, 2240,
1293 2280, 2500, 0, 720, 725, 730, 750, 0,
1294 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1295 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1296 /* 109 - 1280x720@48Hz 64:27 */
1297 { DRM_MODE("1280x720", DRM_MODE_TYPE_DRIVER, 90000, 1280, 2240,
1298 2280, 2500, 0, 720, 725, 730, 750, 0,
1299 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1300 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1301 /* 110 - 1680x720@48Hz 64:27 */
1302 { DRM_MODE("1680x720", DRM_MODE_TYPE_DRIVER, 99000, 1680, 2490,
1303 2530, 2750, 0, 720, 725, 730, 750, 0,
1304 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1305 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1306 /* 111 - 1920x1080@48Hz 16:9 */
1307 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2558,
1308 2602, 2750, 0, 1080, 1084, 1089, 1125, 0,
1309 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1310 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1311 /* 112 - 1920x1080@48Hz 64:27 */
1312 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 148500, 1920, 2558,
1313 2602, 2750, 0, 1080, 1084, 1089, 1125, 0,
1314 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1315 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1316 /* 113 - 2560x1080@48Hz 64:27 */
1317 { DRM_MODE("2560x1080", DRM_MODE_TYPE_DRIVER, 198000, 2560, 3558,
1318 3602, 3750, 0, 1080, 1084, 1089, 1100, 0,
1319 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1320 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1321 /* 114 - 3840x2160@48Hz 16:9 */
1322 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 5116,
1323 5204, 5500, 0, 2160, 2168, 2178, 2250, 0,
1324 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1325 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1326 /* 115 - 4096x2160@48Hz 256:135 */
1327 { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 594000, 4096, 5116,
1328 5204, 5500, 0, 2160, 2168, 2178, 2250, 0,
1329 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1330 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
1331 /* 116 - 3840x2160@48Hz 64:27 */
1332 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 5116,
1333 5204, 5500, 0, 2160, 2168, 2178, 2250, 0,
1334 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1335 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1336 /* 117 - 3840x2160@100Hz 16:9 */
1337 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 1188000, 3840, 4896,
1338 4984, 5280, 0, 2160, 2168, 2178, 2250, 0,
1339 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1340 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1341 /* 118 - 3840x2160@120Hz 16:9 */
1342 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 1188000, 3840, 4016,
1343 4104, 4400, 0, 2160, 2168, 2178, 2250, 0,
1344 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1345 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1346 /* 119 - 3840x2160@100Hz 64:27 */
1347 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 1188000, 3840, 4896,
1348 4984, 5280, 0, 2160, 2168, 2178, 2250, 0,
1349 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1350 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1351 /* 120 - 3840x2160@120Hz 64:27 */
1352 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 1188000, 3840, 4016,
1353 4104, 4400, 0, 2160, 2168, 2178, 2250, 0,
1354 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1355 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1356 /* 121 - 5120x2160@24Hz 64:27 */
1357 { DRM_MODE("5120x2160", DRM_MODE_TYPE_DRIVER, 396000, 5120, 7116,
1358 7204, 7500, 0, 2160, 2168, 2178, 2200, 0,
1359 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1360 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1361 /* 122 - 5120x2160@25Hz 64:27 */
1362 { DRM_MODE("5120x2160", DRM_MODE_TYPE_DRIVER, 396000, 5120, 6816,
1363 6904, 7200, 0, 2160, 2168, 2178, 2200, 0,
1364 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1365 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1366 /* 123 - 5120x2160@30Hz 64:27 */
1367 { DRM_MODE("5120x2160", DRM_MODE_TYPE_DRIVER, 396000, 5120, 5784,
1368 5872, 6000, 0, 2160, 2168, 2178, 2200, 0,
1369 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1370 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1371 /* 124 - 5120x2160@48Hz 64:27 */
1372 { DRM_MODE("5120x2160", DRM_MODE_TYPE_DRIVER, 742500, 5120, 5866,
1373 5954, 6250, 0, 2160, 2168, 2178, 2475, 0,
1374 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1375 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1376 /* 125 - 5120x2160@50Hz 64:27 */
1377 { DRM_MODE("5120x2160", DRM_MODE_TYPE_DRIVER, 742500, 5120, 6216,
1378 6304, 6600, 0, 2160, 2168, 2178, 2250, 0,
1379 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1380 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1381 /* 126 - 5120x2160@60Hz 64:27 */
1382 { DRM_MODE("5120x2160", DRM_MODE_TYPE_DRIVER, 742500, 5120, 5284,
1383 5372, 5500, 0, 2160, 2168, 2178, 2250, 0,
1384 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1385 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1386 /* 127 - 5120x2160@100Hz 64:27 */
1387 { DRM_MODE("5120x2160", DRM_MODE_TYPE_DRIVER, 1485000, 5120, 6216,
1388 6304, 6600, 0, 2160, 2168, 2178, 2250, 0,
1389 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1390 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1394 * From CEA/CTA-861 spec.
1396 * Do not access directly, instead always use cea_mode_for_vic().
1398 static const struct drm_display_mode edid_cea_modes_193[] = {
1399 /* 193 - 5120x2160@120Hz 64:27 */
1400 { DRM_MODE("5120x2160", DRM_MODE_TYPE_DRIVER, 1485000, 5120, 5284,
1401 5372, 5500, 0, 2160, 2168, 2178, 2250, 0,
1402 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1403 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1404 /* 194 - 7680x4320@24Hz 16:9 */
1405 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 1188000, 7680, 10232,
1406 10408, 11000, 0, 4320, 4336, 4356, 4500, 0,
1407 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1408 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1409 /* 195 - 7680x4320@25Hz 16:9 */
1410 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 1188000, 7680, 10032,
1411 10208, 10800, 0, 4320, 4336, 4356, 4400, 0,
1412 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1413 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1414 /* 196 - 7680x4320@30Hz 16:9 */
1415 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 1188000, 7680, 8232,
1416 8408, 9000, 0, 4320, 4336, 4356, 4400, 0,
1417 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1418 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1419 /* 197 - 7680x4320@48Hz 16:9 */
1420 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 2376000, 7680, 10232,
1421 10408, 11000, 0, 4320, 4336, 4356, 4500, 0,
1422 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1423 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1424 /* 198 - 7680x4320@50Hz 16:9 */
1425 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 2376000, 7680, 10032,
1426 10208, 10800, 0, 4320, 4336, 4356, 4400, 0,
1427 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1428 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1429 /* 199 - 7680x4320@60Hz 16:9 */
1430 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 2376000, 7680, 8232,
1431 8408, 9000, 0, 4320, 4336, 4356, 4400, 0,
1432 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1433 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1434 /* 200 - 7680x4320@100Hz 16:9 */
1435 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 4752000, 7680, 9792,
1436 9968, 10560, 0, 4320, 4336, 4356, 4500, 0,
1437 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1438 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1439 /* 201 - 7680x4320@120Hz 16:9 */
1440 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 4752000, 7680, 8032,
1441 8208, 8800, 0, 4320, 4336, 4356, 4500, 0,
1442 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1443 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1444 /* 202 - 7680x4320@24Hz 64:27 */
1445 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 1188000, 7680, 10232,
1446 10408, 11000, 0, 4320, 4336, 4356, 4500, 0,
1447 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1448 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1449 /* 203 - 7680x4320@25Hz 64:27 */
1450 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 1188000, 7680, 10032,
1451 10208, 10800, 0, 4320, 4336, 4356, 4400, 0,
1452 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1453 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1454 /* 204 - 7680x4320@30Hz 64:27 */
1455 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 1188000, 7680, 8232,
1456 8408, 9000, 0, 4320, 4336, 4356, 4400, 0,
1457 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1458 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1459 /* 205 - 7680x4320@48Hz 64:27 */
1460 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 2376000, 7680, 10232,
1461 10408, 11000, 0, 4320, 4336, 4356, 4500, 0,
1462 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1463 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1464 /* 206 - 7680x4320@50Hz 64:27 */
1465 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 2376000, 7680, 10032,
1466 10208, 10800, 0, 4320, 4336, 4356, 4400, 0,
1467 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1468 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1469 /* 207 - 7680x4320@60Hz 64:27 */
1470 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 2376000, 7680, 8232,
1471 8408, 9000, 0, 4320, 4336, 4356, 4400, 0,
1472 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1473 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1474 /* 208 - 7680x4320@100Hz 64:27 */
1475 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 4752000, 7680, 9792,
1476 9968, 10560, 0, 4320, 4336, 4356, 4500, 0,
1477 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1478 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1479 /* 209 - 7680x4320@120Hz 64:27 */
1480 { DRM_MODE("7680x4320", DRM_MODE_TYPE_DRIVER, 4752000, 7680, 8032,
1481 8208, 8800, 0, 4320, 4336, 4356, 4500, 0,
1482 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1483 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1484 /* 210 - 10240x4320@24Hz 64:27 */
1485 { DRM_MODE("10240x4320", DRM_MODE_TYPE_DRIVER, 1485000, 10240, 11732,
1486 11908, 12500, 0, 4320, 4336, 4356, 4950, 0,
1487 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1488 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1489 /* 211 - 10240x4320@25Hz 64:27 */
1490 { DRM_MODE("10240x4320", DRM_MODE_TYPE_DRIVER, 1485000, 10240, 12732,
1491 12908, 13500, 0, 4320, 4336, 4356, 4400, 0,
1492 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1493 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1494 /* 212 - 10240x4320@30Hz 64:27 */
1495 { DRM_MODE("10240x4320", DRM_MODE_TYPE_DRIVER, 1485000, 10240, 10528,
1496 10704, 11000, 0, 4320, 4336, 4356, 4500, 0,
1497 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1498 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1499 /* 213 - 10240x4320@48Hz 64:27 */
1500 { DRM_MODE("10240x4320", DRM_MODE_TYPE_DRIVER, 2970000, 10240, 11732,
1501 11908, 12500, 0, 4320, 4336, 4356, 4950, 0,
1502 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1503 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1504 /* 214 - 10240x4320@50Hz 64:27 */
1505 { DRM_MODE("10240x4320", DRM_MODE_TYPE_DRIVER, 2970000, 10240, 12732,
1506 12908, 13500, 0, 4320, 4336, 4356, 4400, 0,
1507 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1508 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1509 /* 215 - 10240x4320@60Hz 64:27 */
1510 { DRM_MODE("10240x4320", DRM_MODE_TYPE_DRIVER, 2970000, 10240, 10528,
1511 10704, 11000, 0, 4320, 4336, 4356, 4500, 0,
1512 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1513 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1514 /* 216 - 10240x4320@100Hz 64:27 */
1515 { DRM_MODE("10240x4320", DRM_MODE_TYPE_DRIVER, 5940000, 10240, 12432,
1516 12608, 13200, 0, 4320, 4336, 4356, 4500, 0,
1517 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1518 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1519 /* 217 - 10240x4320@120Hz 64:27 */
1520 { DRM_MODE("10240x4320", DRM_MODE_TYPE_DRIVER, 5940000, 10240, 10528,
1521 10704, 11000, 0, 4320, 4336, 4356, 4500, 0,
1522 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1523 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
1524 /* 218 - 4096x2160@100Hz 256:135 */
1525 { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 1188000, 4096, 4896,
1526 4984, 5280, 0, 2160, 2168, 2178, 2250, 0,
1527 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1528 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
1529 /* 219 - 4096x2160@120Hz 256:135 */
1530 { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 1188000, 4096, 4184,
1531 4272, 4400, 0, 2160, 2168, 2178, 2250, 0,
1532 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1533 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
1537 * HDMI 1.4 4k modes. Index using the VIC.
1539 static const struct drm_display_mode edid_4k_modes[] = {
1540 /* 0 - dummy, VICs start at 1 */
1542 /* 1 - 3840x2160@30Hz */
1543 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
1544 3840, 4016, 4104, 4400, 0,
1545 2160, 2168, 2178, 2250, 0,
1546 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1547 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1548 /* 2 - 3840x2160@25Hz */
1549 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
1550 3840, 4896, 4984, 5280, 0,
1551 2160, 2168, 2178, 2250, 0,
1552 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1553 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1554 /* 3 - 3840x2160@24Hz */
1555 { DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 297000,
1556 3840, 5116, 5204, 5500, 0,
1557 2160, 2168, 2178, 2250, 0,
1558 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1559 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, },
1560 /* 4 - 4096x2160@24Hz (SMPTE) */
1561 { DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 297000,
1562 4096, 5116, 5204, 5500, 0,
1563 2160, 2168, 2178, 2250, 0,
1564 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
1565 .picture_aspect_ratio = HDMI_PICTURE_ASPECT_256_135, },
1568 /*** DDC fetch and block validation ***/
1570 static int edid_extension_block_count(const struct edid *edid)
1572 return edid->extensions;
1575 static int edid_block_count(const struct edid *edid)
1577 return edid_extension_block_count(edid) + 1;
1580 static int edid_size_by_blocks(int num_blocks)
1582 return num_blocks * EDID_LENGTH;
1585 static int edid_size(const struct edid *edid)
1587 return edid_size_by_blocks(edid_block_count(edid));
1590 static const void *edid_block_data(const struct edid *edid, int index)
1592 BUILD_BUG_ON(sizeof(*edid) != EDID_LENGTH);
1594 return edid + index;
1597 static const void *edid_extension_block_data(const struct edid *edid, int index)
1599 return edid_block_data(edid, index + 1);
1602 static const u8 edid_header[] = {
1603 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00
1606 static void edid_header_fix(void *edid)
1608 memcpy(edid, edid_header, sizeof(edid_header));
1612 * drm_edid_header_is_valid - sanity check the header of the base EDID block
1613 * @_edid: pointer to raw base EDID block
1615 * Sanity check the header of the base EDID block.
1617 * Return: 8 if the header is perfect, down to 0 if it's totally wrong.
1619 int drm_edid_header_is_valid(const void *_edid)
1621 const struct edid *edid = _edid;
1624 for (i = 0; i < sizeof(edid_header); i++) {
1625 if (edid->header[i] == edid_header[i])
1631 EXPORT_SYMBOL(drm_edid_header_is_valid);
1633 static int edid_fixup __read_mostly = 6;
1634 module_param_named(edid_fixup, edid_fixup, int, 0400);
1635 MODULE_PARM_DESC(edid_fixup,
1636 "Minimum number of valid EDID header bytes (0-8, default 6)");
1638 static int edid_block_compute_checksum(const void *_block)
1640 const u8 *block = _block;
1642 u8 csum = 0, crc = 0;
1644 for (i = 0; i < EDID_LENGTH - 1; i++)
1652 static int edid_block_get_checksum(const void *_block)
1654 const struct edid *block = _block;
1656 return block->checksum;
1659 static int edid_block_tag(const void *_block)
1661 const u8 *block = _block;
1666 static bool edid_block_is_zero(const void *edid)
1668 return !memchr_inv(edid, 0, EDID_LENGTH);
1672 * drm_edid_are_equal - compare two edid blobs.
1673 * @edid1: pointer to first blob
1674 * @edid2: pointer to second blob
1675 * This helper can be used during probing to determine if
1678 bool drm_edid_are_equal(const struct edid *edid1, const struct edid *edid2)
1680 int edid1_len, edid2_len;
1681 bool edid1_present = edid1 != NULL;
1682 bool edid2_present = edid2 != NULL;
1684 if (edid1_present != edid2_present)
1688 edid1_len = edid_size(edid1);
1689 edid2_len = edid_size(edid2);
1691 if (edid1_len != edid2_len)
1694 if (memcmp(edid1, edid2, edid1_len))
1700 EXPORT_SYMBOL(drm_edid_are_equal);
1702 enum edid_block_status {
1704 EDID_BLOCK_READ_FAIL,
1707 EDID_BLOCK_HEADER_CORRUPT,
1708 EDID_BLOCK_HEADER_REPAIR,
1709 EDID_BLOCK_HEADER_FIXED,
1710 EDID_BLOCK_CHECKSUM,
1714 static enum edid_block_status edid_block_check(const void *_block,
1717 const struct edid *block = _block;
1720 return EDID_BLOCK_NULL;
1722 if (is_base_block) {
1723 int score = drm_edid_header_is_valid(block);
1725 if (score < clamp(edid_fixup, 0, 8)) {
1726 if (edid_block_is_zero(block))
1727 return EDID_BLOCK_ZERO;
1729 return EDID_BLOCK_HEADER_CORRUPT;
1733 return EDID_BLOCK_HEADER_REPAIR;
1736 if (edid_block_compute_checksum(block) != edid_block_get_checksum(block)) {
1737 if (edid_block_is_zero(block))
1738 return EDID_BLOCK_ZERO;
1740 return EDID_BLOCK_CHECKSUM;
1743 if (is_base_block) {
1744 if (block->version != 1)
1745 return EDID_BLOCK_VERSION;
1748 return EDID_BLOCK_OK;
1751 static bool edid_block_status_valid(enum edid_block_status status, int tag)
1753 return status == EDID_BLOCK_OK ||
1754 status == EDID_BLOCK_HEADER_FIXED ||
1755 (status == EDID_BLOCK_CHECKSUM && tag == CEA_EXT);
1758 static bool edid_block_valid(const void *block, bool base)
1760 return edid_block_status_valid(edid_block_check(block, base),
1761 edid_block_tag(block));
1764 static void edid_block_status_print(enum edid_block_status status,
1765 const struct edid *block,
1771 case EDID_BLOCK_READ_FAIL:
1772 pr_debug("EDID block %d read failed\n", block_num);
1774 case EDID_BLOCK_NULL:
1775 pr_debug("EDID block %d pointer is NULL\n", block_num);
1777 case EDID_BLOCK_ZERO:
1778 pr_notice("EDID block %d is all zeroes\n", block_num);
1780 case EDID_BLOCK_HEADER_CORRUPT:
1781 pr_notice("EDID has corrupt header\n");
1783 case EDID_BLOCK_HEADER_REPAIR:
1784 pr_debug("EDID corrupt header needs repair\n");
1786 case EDID_BLOCK_HEADER_FIXED:
1787 pr_debug("EDID corrupt header fixed\n");
1789 case EDID_BLOCK_CHECKSUM:
1790 if (edid_block_status_valid(status, edid_block_tag(block))) {
1791 pr_debug("EDID block %d (tag 0x%02x) checksum is invalid, remainder is %d, ignoring\n",
1792 block_num, edid_block_tag(block),
1793 edid_block_compute_checksum(block));
1795 pr_notice("EDID block %d (tag 0x%02x) checksum is invalid, remainder is %d\n",
1796 block_num, edid_block_tag(block),
1797 edid_block_compute_checksum(block));
1800 case EDID_BLOCK_VERSION:
1801 pr_notice("EDID has major version %d, instead of 1\n",
1805 WARN(1, "EDID block %d unknown edid block status code %d\n",
1811 static void edid_block_dump(const char *level, const void *block, int block_num)
1813 enum edid_block_status status;
1816 status = edid_block_check(block, block_num == 0);
1817 if (status == EDID_BLOCK_ZERO)
1818 sprintf(prefix, "\t[%02x] ZERO ", block_num);
1819 else if (!edid_block_status_valid(status, edid_block_tag(block)))
1820 sprintf(prefix, "\t[%02x] BAD ", block_num);
1822 sprintf(prefix, "\t[%02x] GOOD ", block_num);
1824 print_hex_dump(level, prefix, DUMP_PREFIX_NONE, 16, 1,
1825 block, EDID_LENGTH, false);
1829 * drm_edid_block_valid - Sanity check the EDID block (base or extension)
1830 * @_block: pointer to raw EDID block
1831 * @block_num: type of block to validate (0 for base, extension otherwise)
1832 * @print_bad_edid: if true, dump bad EDID blocks to the console
1833 * @edid_corrupt: if true, the header or checksum is invalid
1835 * Validate a base or extension EDID block and optionally dump bad blocks to
1838 * Return: True if the block is valid, false otherwise.
1840 bool drm_edid_block_valid(u8 *_block, int block_num, bool print_bad_edid,
1843 struct edid *block = (struct edid *)_block;
1844 enum edid_block_status status;
1845 bool is_base_block = block_num == 0;
1848 if (WARN_ON(!block))
1851 status = edid_block_check(block, is_base_block);
1852 if (status == EDID_BLOCK_HEADER_REPAIR) {
1853 DRM_DEBUG("Fixing EDID header, your hardware may be failing\n");
1854 edid_header_fix(block);
1856 /* Retry with fixed header, update status if that worked. */
1857 status = edid_block_check(block, is_base_block);
1858 if (status == EDID_BLOCK_OK)
1859 status = EDID_BLOCK_HEADER_FIXED;
1864 * Unknown major version isn't corrupt but we can't use it. Only
1865 * the base block can reset edid_corrupt to false.
1867 if (is_base_block &&
1868 (status == EDID_BLOCK_OK || status == EDID_BLOCK_VERSION))
1869 *edid_corrupt = false;
1870 else if (status != EDID_BLOCK_OK)
1871 *edid_corrupt = true;
1874 edid_block_status_print(status, block, block_num);
1876 /* Determine whether we can use this block with this status. */
1877 valid = edid_block_status_valid(status, edid_block_tag(block));
1879 if (!valid && print_bad_edid && status != EDID_BLOCK_ZERO) {
1880 pr_notice("Raw EDID:\n");
1881 edid_block_dump(KERN_NOTICE, block, block_num);
1886 EXPORT_SYMBOL(drm_edid_block_valid);
1889 * drm_edid_is_valid - sanity check EDID data
1892 * Sanity-check an entire EDID record (including extensions)
1894 * Return: True if the EDID data is valid, false otherwise.
1896 bool drm_edid_is_valid(struct edid *edid)
1903 for (i = 0; i < edid_block_count(edid); i++) {
1904 void *block = (void *)edid_block_data(edid, i);
1906 if (!drm_edid_block_valid(block, i, true, NULL))
1912 EXPORT_SYMBOL(drm_edid_is_valid);
1914 static struct edid *edid_filter_invalid_blocks(const struct edid *edid,
1917 struct edid *new, *dest_block;
1918 int valid_extensions = edid->extensions - invalid_blocks;
1921 new = kmalloc(edid_size_by_blocks(valid_extensions + 1), GFP_KERNEL);
1926 for (i = 0; i < edid_block_count(edid); i++) {
1927 const void *block = edid_block_data(edid, i);
1929 if (edid_block_valid(block, i == 0))
1930 memcpy(dest_block++, block, EDID_LENGTH);
1933 new->extensions = valid_extensions;
1934 new->checksum = edid_block_compute_checksum(new);
1942 #define DDC_SEGMENT_ADDR 0x30
1944 * drm_do_probe_ddc_edid() - get EDID information via I2C
1945 * @data: I2C device adapter
1946 * @buf: EDID data buffer to be filled
1947 * @block: 128 byte EDID block to start fetching from
1948 * @len: EDID data buffer length to fetch
1950 * Try to fetch EDID information by calling I2C driver functions.
1952 * Return: 0 on success or -1 on failure.
1955 drm_do_probe_ddc_edid(void *data, u8 *buf, unsigned int block, size_t len)
1957 struct i2c_adapter *adapter = data;
1958 unsigned char start = block * EDID_LENGTH;
1959 unsigned char segment = block >> 1;
1960 unsigned char xfers = segment ? 3 : 2;
1961 int ret, retries = 5;
1964 * The core I2C driver will automatically retry the transfer if the
1965 * adapter reports EAGAIN. However, we find that bit-banging transfers
1966 * are susceptible to errors under a heavily loaded machine and
1967 * generate spurious NAKs and timeouts. Retrying the transfer
1968 * of the individual block a few times seems to overcome this.
1971 struct i2c_msg msgs[] = {
1973 .addr = DDC_SEGMENT_ADDR,
1991 * Avoid sending the segment addr to not upset non-compliant
1994 ret = i2c_transfer(adapter, &msgs[3 - xfers], xfers);
1996 if (ret == -ENXIO) {
1997 DRM_DEBUG_KMS("drm: skipping non-existent adapter %s\n",
2001 } while (ret != xfers && --retries);
2003 return ret == xfers ? 0 : -1;
2006 static void connector_bad_edid(struct drm_connector *connector,
2007 const struct edid *edid, int num_blocks)
2013 * 0x7e in the EDID is the number of extension blocks. The EDID
2014 * is 1 (base block) + num_ext_blocks big. That means we can think
2015 * of 0x7e in the EDID of the _index_ of the last block in the
2016 * combined chunk of memory.
2018 last_block = edid->extensions;
2020 /* Calculate real checksum for the last edid extension block data */
2021 if (last_block < num_blocks)
2022 connector->real_edid_checksum =
2023 edid_block_compute_checksum(edid + last_block);
2025 if (connector->bad_edid_counter++ && !drm_debug_enabled(DRM_UT_KMS))
2028 drm_dbg_kms(connector->dev, "%s: EDID is invalid:\n", connector->name);
2029 for (i = 0; i < num_blocks; i++)
2030 edid_block_dump(KERN_DEBUG, edid + i, i);
2033 /* Get override or firmware EDID */
2034 static struct edid *drm_get_override_edid(struct drm_connector *connector)
2036 struct edid *override = NULL;
2038 if (connector->override_edid)
2039 override = drm_edid_duplicate(connector->edid_blob_ptr->data);
2042 override = drm_load_edid_firmware(connector);
2044 return IS_ERR(override) ? NULL : override;
2048 * drm_add_override_edid_modes - add modes from override/firmware EDID
2049 * @connector: connector we're probing
2051 * Add modes from the override/firmware EDID, if available. Only to be used from
2052 * drm_helper_probe_single_connector_modes() as a fallback for when DDC probe
2053 * failed during drm_get_edid() and caused the override/firmware EDID to be
2056 * Return: The number of modes added or 0 if we couldn't find any.
2058 int drm_add_override_edid_modes(struct drm_connector *connector)
2060 struct edid *override;
2063 override = drm_get_override_edid(connector);
2065 drm_connector_update_edid_property(connector, override);
2066 num_modes = drm_add_edid_modes(connector, override);
2069 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] adding %d modes via fallback override/firmware EDID\n",
2070 connector->base.id, connector->name, num_modes);
2075 EXPORT_SYMBOL(drm_add_override_edid_modes);
2077 typedef int read_block_fn(void *context, u8 *buf, unsigned int block, size_t len);
2079 static enum edid_block_status edid_block_read(void *block, unsigned int block_num,
2080 read_block_fn read_block,
2083 enum edid_block_status status;
2084 bool is_base_block = block_num == 0;
2087 for (try = 0; try < 4; try++) {
2088 if (read_block(context, block, block_num, EDID_LENGTH))
2089 return EDID_BLOCK_READ_FAIL;
2091 status = edid_block_check(block, is_base_block);
2092 if (status == EDID_BLOCK_HEADER_REPAIR) {
2093 edid_header_fix(block);
2095 /* Retry with fixed header, update status if that worked. */
2096 status = edid_block_check(block, is_base_block);
2097 if (status == EDID_BLOCK_OK)
2098 status = EDID_BLOCK_HEADER_FIXED;
2101 if (edid_block_status_valid(status, edid_block_tag(block)))
2104 /* Fail early for unrepairable base block all zeros. */
2105 if (try == 0 && is_base_block && status == EDID_BLOCK_ZERO)
2113 * drm_do_get_edid - get EDID data using a custom EDID block read function
2114 * @connector: connector we're probing
2115 * @read_block: EDID block read function
2116 * @context: private data passed to the block read function
2118 * When the I2C adapter connected to the DDC bus is hidden behind a device that
2119 * exposes a different interface to read EDID blocks this function can be used
2120 * to get EDID data using a custom block read function.
2122 * As in the general case the DDC bus is accessible by the kernel at the I2C
2123 * level, drivers must make all reasonable efforts to expose it as an I2C
2124 * adapter and use drm_get_edid() instead of abusing this function.
2126 * The EDID may be overridden using debugfs override_edid or firmware EDID
2127 * (drm_load_edid_firmware() and drm.edid_firmware parameter), in this priority
2128 * order. Having either of them bypasses actual EDID reads.
2130 * Return: Pointer to valid EDID or NULL if we couldn't find any.
2132 struct edid *drm_do_get_edid(struct drm_connector *connector,
2133 read_block_fn read_block,
2136 enum edid_block_status status;
2137 int i, invalid_blocks = 0;
2138 struct edid *edid, *new;
2140 edid = drm_get_override_edid(connector);
2144 edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
2148 status = edid_block_read(edid, 0, read_block, context);
2150 edid_block_status_print(status, edid, 0);
2152 if (status == EDID_BLOCK_READ_FAIL)
2155 /* FIXME: Clarify what a corrupt EDID actually means. */
2156 if (status == EDID_BLOCK_OK || status == EDID_BLOCK_VERSION)
2157 connector->edid_corrupt = false;
2159 connector->edid_corrupt = true;
2161 if (!edid_block_status_valid(status, edid_block_tag(edid))) {
2162 if (status == EDID_BLOCK_ZERO)
2163 connector->null_edid_counter++;
2165 connector_bad_edid(connector, edid, 1);
2169 if (!edid_extension_block_count(edid))
2172 new = krealloc(edid, edid_size(edid), GFP_KERNEL);
2177 for (i = 1; i < edid_block_count(edid); i++) {
2178 void *block = (void *)edid_block_data(edid, i);
2180 status = edid_block_read(block, i, read_block, context);
2182 edid_block_status_print(status, block, i);
2184 if (!edid_block_status_valid(status, edid_block_tag(block))) {
2185 if (status == EDID_BLOCK_READ_FAIL)
2191 if (invalid_blocks) {
2192 connector_bad_edid(connector, edid, edid_block_count(edid));
2194 edid = edid_filter_invalid_blocks(edid, invalid_blocks);
2204 EXPORT_SYMBOL_GPL(drm_do_get_edid);
2207 * drm_probe_ddc() - probe DDC presence
2208 * @adapter: I2C adapter to probe
2210 * Return: True on success, false on failure.
2213 drm_probe_ddc(struct i2c_adapter *adapter)
2217 return (drm_do_probe_ddc_edid(adapter, &out, 0, 1) == 0);
2219 EXPORT_SYMBOL(drm_probe_ddc);
2222 * drm_get_edid - get EDID data, if available
2223 * @connector: connector we're probing
2224 * @adapter: I2C adapter to use for DDC
2226 * Poke the given I2C channel to grab EDID data if possible. If found,
2227 * attach it to the connector.
2229 * Return: Pointer to valid EDID or NULL if we couldn't find any.
2231 struct edid *drm_get_edid(struct drm_connector *connector,
2232 struct i2c_adapter *adapter)
2236 if (connector->force == DRM_FORCE_OFF)
2239 if (connector->force == DRM_FORCE_UNSPECIFIED && !drm_probe_ddc(adapter))
2242 edid = drm_do_get_edid(connector, drm_do_probe_ddc_edid, adapter);
2243 drm_connector_update_edid_property(connector, edid);
2246 EXPORT_SYMBOL(drm_get_edid);
2248 static u32 edid_extract_panel_id(const struct edid *edid)
2251 * We represent the ID as a 32-bit number so it can easily be compared
2254 * NOTE that we deal with endianness differently for the top half
2255 * of this ID than for the bottom half. The bottom half (the product
2256 * id) gets decoded as little endian by the EDID_PRODUCT_ID because
2257 * that's how everyone seems to interpret it. The top half (the mfg_id)
2258 * gets stored as big endian because that makes
2259 * drm_edid_encode_panel_id() and drm_edid_decode_panel_id() easier
2260 * to write (it's easier to extract the ASCII). It doesn't really
2261 * matter, though, as long as the number here is unique.
2263 return (u32)edid->mfg_id[0] << 24 |
2264 (u32)edid->mfg_id[1] << 16 |
2265 (u32)EDID_PRODUCT_ID(edid);
2269 * drm_edid_get_panel_id - Get a panel's ID through DDC
2270 * @adapter: I2C adapter to use for DDC
2272 * This function reads the first block of the EDID of a panel and (assuming
2273 * that the EDID is valid) extracts the ID out of it. The ID is a 32-bit value
2274 * (16 bits of manufacturer ID and 16 bits of per-manufacturer ID) that's
2275 * supposed to be different for each different modem of panel.
2277 * This function is intended to be used during early probing on devices where
2278 * more than one panel might be present. Because of its intended use it must
2279 * assume that the EDID of the panel is correct, at least as far as the ID
2280 * is concerned (in other words, we don't process any overrides here).
2282 * NOTE: it's expected that this function and drm_do_get_edid() will both
2283 * be read the EDID, but there is no caching between them. Since we're only
2284 * reading the first block, hopefully this extra overhead won't be too big.
2286 * Return: A 32-bit ID that should be different for each make/model of panel.
2287 * See the functions drm_edid_encode_panel_id() and
2288 * drm_edid_decode_panel_id() for some details on the structure of this
2292 u32 drm_edid_get_panel_id(struct i2c_adapter *adapter)
2294 enum edid_block_status status;
2299 * There are no manufacturer IDs of 0, so if there is a problem reading
2300 * the EDID then we'll just return 0.
2303 base_block = kmalloc(EDID_LENGTH, GFP_KERNEL);
2307 status = edid_block_read(base_block, 0, drm_do_probe_ddc_edid, adapter);
2309 edid_block_status_print(status, base_block, 0);
2311 if (edid_block_status_valid(status, edid_block_tag(base_block)))
2312 panel_id = edid_extract_panel_id(base_block);
2318 EXPORT_SYMBOL(drm_edid_get_panel_id);
2321 * drm_get_edid_switcheroo - get EDID data for a vga_switcheroo output
2322 * @connector: connector we're probing
2323 * @adapter: I2C adapter to use for DDC
2325 * Wrapper around drm_get_edid() for laptops with dual GPUs using one set of
2326 * outputs. The wrapper adds the requisite vga_switcheroo calls to temporarily
2327 * switch DDC to the GPU which is retrieving EDID.
2329 * Return: Pointer to valid EDID or %NULL if we couldn't find any.
2331 struct edid *drm_get_edid_switcheroo(struct drm_connector *connector,
2332 struct i2c_adapter *adapter)
2334 struct drm_device *dev = connector->dev;
2335 struct pci_dev *pdev = to_pci_dev(dev->dev);
2338 if (drm_WARN_ON_ONCE(dev, !dev_is_pci(dev->dev)))
2341 vga_switcheroo_lock_ddc(pdev);
2342 edid = drm_get_edid(connector, adapter);
2343 vga_switcheroo_unlock_ddc(pdev);
2347 EXPORT_SYMBOL(drm_get_edid_switcheroo);
2350 * drm_edid_duplicate - duplicate an EDID and the extensions
2351 * @edid: EDID to duplicate
2353 * Return: Pointer to duplicated EDID or NULL on allocation failure.
2355 struct edid *drm_edid_duplicate(const struct edid *edid)
2357 return kmemdup(edid, edid_size(edid), GFP_KERNEL);
2359 EXPORT_SYMBOL(drm_edid_duplicate);
2361 /*** EDID parsing ***/
2364 * edid_get_quirks - return quirk flags for a given EDID
2365 * @edid: EDID to process
2367 * This tells subsequent routines what fixes they need to apply.
2369 static u32 edid_get_quirks(const struct edid *edid)
2371 u32 panel_id = edid_extract_panel_id(edid);
2372 const struct edid_quirk *quirk;
2375 for (i = 0; i < ARRAY_SIZE(edid_quirk_list); i++) {
2376 quirk = &edid_quirk_list[i];
2377 if (quirk->panel_id == panel_id)
2378 return quirk->quirks;
2384 #define MODE_SIZE(m) ((m)->hdisplay * (m)->vdisplay)
2385 #define MODE_REFRESH_DIFF(c,t) (abs((c) - (t)))
2388 * Walk the mode list for connector, clearing the preferred status on existing
2389 * modes and setting it anew for the right mode ala quirks.
2391 static void edid_fixup_preferred(struct drm_connector *connector,
2394 struct drm_display_mode *t, *cur_mode, *preferred_mode;
2395 int target_refresh = 0;
2396 int cur_vrefresh, preferred_vrefresh;
2398 if (list_empty(&connector->probed_modes))
2401 if (quirks & EDID_QUIRK_PREFER_LARGE_60)
2402 target_refresh = 60;
2403 if (quirks & EDID_QUIRK_PREFER_LARGE_75)
2404 target_refresh = 75;
2406 preferred_mode = list_first_entry(&connector->probed_modes,
2407 struct drm_display_mode, head);
2409 list_for_each_entry_safe(cur_mode, t, &connector->probed_modes, head) {
2410 cur_mode->type &= ~DRM_MODE_TYPE_PREFERRED;
2412 if (cur_mode == preferred_mode)
2415 /* Largest mode is preferred */
2416 if (MODE_SIZE(cur_mode) > MODE_SIZE(preferred_mode))
2417 preferred_mode = cur_mode;
2419 cur_vrefresh = drm_mode_vrefresh(cur_mode);
2420 preferred_vrefresh = drm_mode_vrefresh(preferred_mode);
2421 /* At a given size, try to get closest to target refresh */
2422 if ((MODE_SIZE(cur_mode) == MODE_SIZE(preferred_mode)) &&
2423 MODE_REFRESH_DIFF(cur_vrefresh, target_refresh) <
2424 MODE_REFRESH_DIFF(preferred_vrefresh, target_refresh)) {
2425 preferred_mode = cur_mode;
2429 preferred_mode->type |= DRM_MODE_TYPE_PREFERRED;
2433 mode_is_rb(const struct drm_display_mode *mode)
2435 return (mode->htotal - mode->hdisplay == 160) &&
2436 (mode->hsync_end - mode->hdisplay == 80) &&
2437 (mode->hsync_end - mode->hsync_start == 32) &&
2438 (mode->vsync_start - mode->vdisplay == 3);
2442 * drm_mode_find_dmt - Create a copy of a mode if present in DMT
2443 * @dev: Device to duplicate against
2444 * @hsize: Mode width
2445 * @vsize: Mode height
2446 * @fresh: Mode refresh rate
2447 * @rb: Mode reduced-blanking-ness
2449 * Walk the DMT mode list looking for a match for the given parameters.
2451 * Return: A newly allocated copy of the mode, or NULL if not found.
2453 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
2454 int hsize, int vsize, int fresh,
2459 for (i = 0; i < ARRAY_SIZE(drm_dmt_modes); i++) {
2460 const struct drm_display_mode *ptr = &drm_dmt_modes[i];
2462 if (hsize != ptr->hdisplay)
2464 if (vsize != ptr->vdisplay)
2466 if (fresh != drm_mode_vrefresh(ptr))
2468 if (rb != mode_is_rb(ptr))
2471 return drm_mode_duplicate(dev, ptr);
2476 EXPORT_SYMBOL(drm_mode_find_dmt);
2478 static bool is_display_descriptor(const struct detailed_timing *descriptor, u8 type)
2480 BUILD_BUG_ON(offsetof(typeof(*descriptor), pixel_clock) != 0);
2481 BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.pad1) != 2);
2482 BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.type) != 3);
2484 return descriptor->pixel_clock == 0 &&
2485 descriptor->data.other_data.pad1 == 0 &&
2486 descriptor->data.other_data.type == type;
2489 static bool is_detailed_timing_descriptor(const struct detailed_timing *descriptor)
2491 BUILD_BUG_ON(offsetof(typeof(*descriptor), pixel_clock) != 0);
2493 return descriptor->pixel_clock != 0;
2496 typedef void detailed_cb(const struct detailed_timing *timing, void *closure);
2499 cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
2503 const u8 *det_base = ext + d;
2505 if (d < 4 || d > 127)
2509 for (i = 0; i < n; i++)
2510 cb((const struct detailed_timing *)(det_base + 18 * i), closure);
2514 vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
2516 unsigned int i, n = min((int)ext[0x02], 6);
2517 const u8 *det_base = ext + 5;
2520 return; /* unknown version */
2522 for (i = 0; i < n; i++)
2523 cb((const struct detailed_timing *)(det_base + 18 * i), closure);
2527 drm_for_each_detailed_block(const struct edid *edid, detailed_cb *cb, void *closure)
2534 for (i = 0; i < EDID_DETAILED_TIMINGS; i++)
2535 cb(&(edid->detailed_timings[i]), closure);
2537 for (i = 0; i < edid_extension_block_count(edid); i++) {
2538 const u8 *ext = edid_extension_block_data(edid, i);
2542 cea_for_each_detailed_block(ext, cb, closure);
2545 vtb_for_each_detailed_block(ext, cb, closure);
2554 is_rb(const struct detailed_timing *descriptor, void *data)
2558 if (!is_display_descriptor(descriptor, EDID_DETAIL_MONITOR_RANGE))
2561 BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.flags) != 10);
2562 BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.cvt.flags) != 15);
2564 if (descriptor->data.other_data.data.range.flags == DRM_EDID_CVT_SUPPORT_FLAG &&
2565 descriptor->data.other_data.data.range.formula.cvt.flags & 0x10)
2569 /* EDID 1.4 defines this explicitly. For EDID 1.3, we guess, badly. */
2571 drm_monitor_supports_rb(const struct edid *edid)
2573 if (edid->revision >= 4) {
2576 drm_for_each_detailed_block(edid, is_rb, &ret);
2580 return ((edid->input & DRM_EDID_INPUT_DIGITAL) != 0);
2584 find_gtf2(const struct detailed_timing *descriptor, void *data)
2586 const struct detailed_timing **res = data;
2588 if (!is_display_descriptor(descriptor, EDID_DETAIL_MONITOR_RANGE))
2591 BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.flags) != 10);
2593 if (descriptor->data.other_data.data.range.flags == 0x02)
2597 /* Secondary GTF curve kicks in above some break frequency */
2599 drm_gtf2_hbreak(const struct edid *edid)
2601 const struct detailed_timing *descriptor = NULL;
2603 drm_for_each_detailed_block(edid, find_gtf2, &descriptor);
2605 BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.hfreq_start_khz) != 12);
2607 return descriptor ? descriptor->data.other_data.data.range.formula.gtf2.hfreq_start_khz * 2 : 0;
2611 drm_gtf2_2c(const struct edid *edid)
2613 const struct detailed_timing *descriptor = NULL;
2615 drm_for_each_detailed_block(edid, find_gtf2, &descriptor);
2617 BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.c) != 13);
2619 return descriptor ? descriptor->data.other_data.data.range.formula.gtf2.c : 0;
2623 drm_gtf2_m(const struct edid *edid)
2625 const struct detailed_timing *descriptor = NULL;
2627 drm_for_each_detailed_block(edid, find_gtf2, &descriptor);
2629 BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.m) != 14);
2631 return descriptor ? le16_to_cpu(descriptor->data.other_data.data.range.formula.gtf2.m) : 0;
2635 drm_gtf2_k(const struct edid *edid)
2637 const struct detailed_timing *descriptor = NULL;
2639 drm_for_each_detailed_block(edid, find_gtf2, &descriptor);
2641 BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.k) != 16);
2643 return descriptor ? descriptor->data.other_data.data.range.formula.gtf2.k : 0;
2647 drm_gtf2_2j(const struct edid *edid)
2649 const struct detailed_timing *descriptor = NULL;
2651 drm_for_each_detailed_block(edid, find_gtf2, &descriptor);
2653 BUILD_BUG_ON(offsetof(typeof(*descriptor), data.other_data.data.range.formula.gtf2.j) != 17);
2655 return descriptor ? descriptor->data.other_data.data.range.formula.gtf2.j : 0;
2658 /* Get standard timing level (CVT/GTF/DMT). */
2659 static int standard_timing_level(const struct edid *edid)
2661 if (edid->revision >= 2) {
2662 if (edid->revision >= 4 && (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF))
2664 if (drm_gtf2_hbreak(edid))
2666 if (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF)
2673 * 0 is reserved. The spec says 0x01 fill for unused timings. Some old
2674 * monitors fill with ascii space (0x20) instead.
2677 bad_std_timing(u8 a, u8 b)
2679 return (a == 0x00 && b == 0x00) ||
2680 (a == 0x01 && b == 0x01) ||
2681 (a == 0x20 && b == 0x20);
2684 static int drm_mode_hsync(const struct drm_display_mode *mode)
2686 if (mode->htotal <= 0)
2689 return DIV_ROUND_CLOSEST(mode->clock, mode->htotal);
2693 * Take the standard timing params (in this case width, aspect, and refresh)
2694 * and convert them into a real mode using CVT/GTF/DMT.
2696 static struct drm_display_mode *
2697 drm_mode_std(struct drm_connector *connector, const struct edid *edid,
2698 const struct std_timing *t)
2700 struct drm_device *dev = connector->dev;
2701 struct drm_display_mode *m, *mode = NULL;
2704 unsigned aspect_ratio = (t->vfreq_aspect & EDID_TIMING_ASPECT_MASK)
2705 >> EDID_TIMING_ASPECT_SHIFT;
2706 unsigned vfreq = (t->vfreq_aspect & EDID_TIMING_VFREQ_MASK)
2707 >> EDID_TIMING_VFREQ_SHIFT;
2708 int timing_level = standard_timing_level(edid);
2710 if (bad_std_timing(t->hsize, t->vfreq_aspect))
2713 /* According to the EDID spec, the hdisplay = hsize * 8 + 248 */
2714 hsize = t->hsize * 8 + 248;
2715 /* vrefresh_rate = vfreq + 60 */
2716 vrefresh_rate = vfreq + 60;
2717 /* the vdisplay is calculated based on the aspect ratio */
2718 if (aspect_ratio == 0) {
2719 if (edid->revision < 3)
2722 vsize = (hsize * 10) / 16;
2723 } else if (aspect_ratio == 1)
2724 vsize = (hsize * 3) / 4;
2725 else if (aspect_ratio == 2)
2726 vsize = (hsize * 4) / 5;
2728 vsize = (hsize * 9) / 16;
2730 /* HDTV hack, part 1 */
2731 if (vrefresh_rate == 60 &&
2732 ((hsize == 1360 && vsize == 765) ||
2733 (hsize == 1368 && vsize == 769))) {
2739 * If this connector already has a mode for this size and refresh
2740 * rate (because it came from detailed or CVT info), use that
2741 * instead. This way we don't have to guess at interlace or
2744 list_for_each_entry(m, &connector->probed_modes, head)
2745 if (m->hdisplay == hsize && m->vdisplay == vsize &&
2746 drm_mode_vrefresh(m) == vrefresh_rate)
2749 /* HDTV hack, part 2 */
2750 if (hsize == 1366 && vsize == 768 && vrefresh_rate == 60) {
2751 mode = drm_cvt_mode(dev, 1366, 768, vrefresh_rate, 0, 0,
2755 mode->hdisplay = 1366;
2756 mode->hsync_start = mode->hsync_start - 1;
2757 mode->hsync_end = mode->hsync_end - 1;
2761 /* check whether it can be found in default mode table */
2762 if (drm_monitor_supports_rb(edid)) {
2763 mode = drm_mode_find_dmt(dev, hsize, vsize, vrefresh_rate,
2768 mode = drm_mode_find_dmt(dev, hsize, vsize, vrefresh_rate, false);
2772 /* okay, generate it */
2773 switch (timing_level) {
2777 mode = drm_gtf_mode(dev, hsize, vsize, vrefresh_rate, 0, 0);
2781 * This is potentially wrong if there's ever a monitor with
2782 * more than one ranges section, each claiming a different
2783 * secondary GTF curve. Please don't do that.
2785 mode = drm_gtf_mode(dev, hsize, vsize, vrefresh_rate, 0, 0);
2788 if (drm_mode_hsync(mode) > drm_gtf2_hbreak(edid)) {
2789 drm_mode_destroy(dev, mode);
2790 mode = drm_gtf_mode_complex(dev, hsize, vsize,
2791 vrefresh_rate, 0, 0,
2799 mode = drm_cvt_mode(dev, hsize, vsize, vrefresh_rate, 0, 0,
2807 * EDID is delightfully ambiguous about how interlaced modes are to be
2808 * encoded. Our internal representation is of frame height, but some
2809 * HDTV detailed timings are encoded as field height.
2811 * The format list here is from CEA, in frame size. Technically we
2812 * should be checking refresh rate too. Whatever.
2815 drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
2816 const struct detailed_pixel_timing *pt)
2819 static const struct {
2821 } cea_interlaced[] = {
2831 if (!(pt->misc & DRM_EDID_PT_INTERLACED))
2834 for (i = 0; i < ARRAY_SIZE(cea_interlaced); i++) {
2835 if ((mode->hdisplay == cea_interlaced[i].w) &&
2836 (mode->vdisplay == cea_interlaced[i].h / 2)) {
2837 mode->vdisplay *= 2;
2838 mode->vsync_start *= 2;
2839 mode->vsync_end *= 2;
2845 mode->flags |= DRM_MODE_FLAG_INTERLACE;
2849 * Create a new mode from an EDID detailed timing section. An EDID detailed
2850 * timing block contains enough info for us to create and return a new struct
2853 static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
2854 const struct edid *edid,
2855 const struct detailed_timing *timing,
2858 struct drm_display_mode *mode;
2859 const struct detailed_pixel_timing *pt = &timing->data.pixel_data;
2860 unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo;
2861 unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo;
2862 unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo;
2863 unsigned vblank = (pt->vactive_vblank_hi & 0xf) << 8 | pt->vblank_lo;
2864 unsigned hsync_offset = (pt->hsync_vsync_offset_pulse_width_hi & 0xc0) << 2 | pt->hsync_offset_lo;
2865 unsigned hsync_pulse_width = (pt->hsync_vsync_offset_pulse_width_hi & 0x30) << 4 | pt->hsync_pulse_width_lo;
2866 unsigned vsync_offset = (pt->hsync_vsync_offset_pulse_width_hi & 0xc) << 2 | pt->vsync_offset_pulse_width_lo >> 4;
2867 unsigned vsync_pulse_width = (pt->hsync_vsync_offset_pulse_width_hi & 0x3) << 4 | (pt->vsync_offset_pulse_width_lo & 0xf);
2869 /* ignore tiny modes */
2870 if (hactive < 64 || vactive < 64)
2873 if (pt->misc & DRM_EDID_PT_STEREO) {
2874 DRM_DEBUG_KMS("stereo mode not supported\n");
2877 if (!(pt->misc & DRM_EDID_PT_SEPARATE_SYNC)) {
2878 DRM_DEBUG_KMS("composite sync not supported\n");
2881 /* it is incorrect if hsync/vsync width is zero */
2882 if (!hsync_pulse_width || !vsync_pulse_width) {
2883 DRM_DEBUG_KMS("Incorrect Detailed timing. "
2884 "Wrong Hsync/Vsync pulse width\n");
2888 if (quirks & EDID_QUIRK_FORCE_REDUCED_BLANKING) {
2889 mode = drm_cvt_mode(dev, hactive, vactive, 60, true, false, false);
2896 mode = drm_mode_create(dev);
2900 if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH)
2901 mode->clock = 1088 * 10;
2903 mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
2905 mode->hdisplay = hactive;
2906 mode->hsync_start = mode->hdisplay + hsync_offset;
2907 mode->hsync_end = mode->hsync_start + hsync_pulse_width;
2908 mode->htotal = mode->hdisplay + hblank;
2910 mode->vdisplay = vactive;
2911 mode->vsync_start = mode->vdisplay + vsync_offset;
2912 mode->vsync_end = mode->vsync_start + vsync_pulse_width;
2913 mode->vtotal = mode->vdisplay + vblank;
2915 /* Some EDIDs have bogus h/vtotal values */
2916 if (mode->hsync_end > mode->htotal)
2917 mode->htotal = mode->hsync_end + 1;
2918 if (mode->vsync_end > mode->vtotal)
2919 mode->vtotal = mode->vsync_end + 1;
2921 drm_mode_do_interlace_quirk(mode, pt);
2923 if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) {
2924 mode->flags |= DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC;
2926 mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
2927 DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
2928 mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
2929 DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
2933 mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4;
2934 mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi & 0xf) << 8;
2936 if (quirks & EDID_QUIRK_DETAILED_IN_CM) {
2937 mode->width_mm *= 10;
2938 mode->height_mm *= 10;
2941 if (quirks & EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE) {
2942 mode->width_mm = edid->width_cm * 10;
2943 mode->height_mm = edid->height_cm * 10;
2946 mode->type = DRM_MODE_TYPE_DRIVER;
2947 drm_mode_set_name(mode);
2953 mode_in_hsync_range(const struct drm_display_mode *mode,
2954 const struct edid *edid, const u8 *t)
2956 int hsync, hmin, hmax;
2959 if (edid->revision >= 4)
2960 hmin += ((t[4] & 0x04) ? 255 : 0);
2962 if (edid->revision >= 4)
2963 hmax += ((t[4] & 0x08) ? 255 : 0);
2964 hsync = drm_mode_hsync(mode);
2966 return (hsync <= hmax && hsync >= hmin);
2970 mode_in_vsync_range(const struct drm_display_mode *mode,
2971 const struct edid *edid, const u8 *t)
2973 int vsync, vmin, vmax;
2976 if (edid->revision >= 4)
2977 vmin += ((t[4] & 0x01) ? 255 : 0);
2979 if (edid->revision >= 4)
2980 vmax += ((t[4] & 0x02) ? 255 : 0);
2981 vsync = drm_mode_vrefresh(mode);
2983 return (vsync <= vmax && vsync >= vmin);
2987 range_pixel_clock(const struct edid *edid, const u8 *t)
2990 if (t[9] == 0 || t[9] == 255)
2993 /* 1.4 with CVT support gives us real precision, yay */
2994 if (edid->revision >= 4 && t[10] == 0x04)
2995 return (t[9] * 10000) - ((t[12] >> 2) * 250);
2997 /* 1.3 is pathetic, so fuzz up a bit */
2998 return t[9] * 10000 + 5001;
3002 mode_in_range(const struct drm_display_mode *mode, const struct edid *edid,
3003 const struct detailed_timing *timing)
3006 const u8 *t = (const u8 *)timing;
3008 if (!mode_in_hsync_range(mode, edid, t))
3011 if (!mode_in_vsync_range(mode, edid, t))
3014 if ((max_clock = range_pixel_clock(edid, t)))
3015 if (mode->clock > max_clock)
3018 /* 1.4 max horizontal check */
3019 if (edid->revision >= 4 && t[10] == 0x04)
3020 if (t[13] && mode->hdisplay > 8 * (t[13] + (256 * (t[12]&0x3))))
3023 if (mode_is_rb(mode) && !drm_monitor_supports_rb(edid))
3029 static bool valid_inferred_mode(const struct drm_connector *connector,
3030 const struct drm_display_mode *mode)
3032 const struct drm_display_mode *m;
3035 list_for_each_entry(m, &connector->probed_modes, head) {
3036 if (mode->hdisplay == m->hdisplay &&
3037 mode->vdisplay == m->vdisplay &&
3038 drm_mode_vrefresh(mode) == drm_mode_vrefresh(m))
3039 return false; /* duplicated */
3040 if (mode->hdisplay <= m->hdisplay &&
3041 mode->vdisplay <= m->vdisplay)
3048 drm_dmt_modes_for_range(struct drm_connector *connector, const struct edid *edid,
3049 const struct detailed_timing *timing)
3052 struct drm_display_mode *newmode;
3053 struct drm_device *dev = connector->dev;
3055 for (i = 0; i < ARRAY_SIZE(drm_dmt_modes); i++) {
3056 if (mode_in_range(drm_dmt_modes + i, edid, timing) &&
3057 valid_inferred_mode(connector, drm_dmt_modes + i)) {
3058 newmode = drm_mode_duplicate(dev, &drm_dmt_modes[i]);
3060 drm_mode_probed_add(connector, newmode);
3069 /* fix up 1366x768 mode from 1368x768;
3070 * GFT/CVT can't express 1366 width which isn't dividable by 8
3072 void drm_mode_fixup_1366x768(struct drm_display_mode *mode)
3074 if (mode->hdisplay == 1368 && mode->vdisplay == 768) {
3075 mode->hdisplay = 1366;
3076 mode->hsync_start--;
3078 drm_mode_set_name(mode);
3083 drm_gtf_modes_for_range(struct drm_connector *connector, const struct edid *edid,
3084 const struct detailed_timing *timing)
3087 struct drm_display_mode *newmode;
3088 struct drm_device *dev = connector->dev;
3090 for (i = 0; i < ARRAY_SIZE(extra_modes); i++) {
3091 const struct minimode *m = &extra_modes[i];
3093 newmode = drm_gtf_mode(dev, m->w, m->h, m->r, 0, 0);
3097 drm_mode_fixup_1366x768(newmode);
3098 if (!mode_in_range(newmode, edid, timing) ||
3099 !valid_inferred_mode(connector, newmode)) {
3100 drm_mode_destroy(dev, newmode);
3104 drm_mode_probed_add(connector, newmode);
3112 drm_cvt_modes_for_range(struct drm_connector *connector, const struct edid *edid,
3113 const struct detailed_timing *timing)
3116 struct drm_display_mode *newmode;
3117 struct drm_device *dev = connector->dev;
3118 bool rb = drm_monitor_supports_rb(edid);
3120 for (i = 0; i < ARRAY_SIZE(extra_modes); i++) {
3121 const struct minimode *m = &extra_modes[i];
3123 newmode = drm_cvt_mode(dev, m->w, m->h, m->r, rb, 0, 0);
3127 drm_mode_fixup_1366x768(newmode);
3128 if (!mode_in_range(newmode, edid, timing) ||
3129 !valid_inferred_mode(connector, newmode)) {
3130 drm_mode_destroy(dev, newmode);
3134 drm_mode_probed_add(connector, newmode);
3142 do_inferred_modes(const struct detailed_timing *timing, void *c)
3144 struct detailed_mode_closure *closure = c;
3145 const struct detailed_non_pixel *data = &timing->data.other_data;
3146 const struct detailed_data_monitor_range *range = &data->data.range;
3148 if (!is_display_descriptor(timing, EDID_DETAIL_MONITOR_RANGE))
3151 closure->modes += drm_dmt_modes_for_range(closure->connector,
3155 if (!version_greater(closure->edid, 1, 1))
3156 return; /* GTF not defined yet */
3158 switch (range->flags) {
3159 case 0x02: /* secondary gtf, XXX could do more */
3160 case 0x00: /* default gtf */
3161 closure->modes += drm_gtf_modes_for_range(closure->connector,
3165 case 0x04: /* cvt, only in 1.4+ */
3166 if (!version_greater(closure->edid, 1, 3))
3169 closure->modes += drm_cvt_modes_for_range(closure->connector,
3173 case 0x01: /* just the ranges, no formula */
3180 add_inferred_modes(struct drm_connector *connector, const struct edid *edid)
3182 struct detailed_mode_closure closure = {
3183 .connector = connector,
3187 if (version_greater(edid, 1, 0))
3188 drm_for_each_detailed_block(edid, do_inferred_modes, &closure);
3190 return closure.modes;
3194 drm_est3_modes(struct drm_connector *connector, const struct detailed_timing *timing)
3196 int i, j, m, modes = 0;
3197 struct drm_display_mode *mode;
3198 const u8 *est = ((const u8 *)timing) + 6;
3200 for (i = 0; i < 6; i++) {
3201 for (j = 7; j >= 0; j--) {
3202 m = (i * 8) + (7 - j);
3203 if (m >= ARRAY_SIZE(est3_modes))
3205 if (est[i] & (1 << j)) {
3206 mode = drm_mode_find_dmt(connector->dev,
3212 drm_mode_probed_add(connector, mode);
3223 do_established_modes(const struct detailed_timing *timing, void *c)
3225 struct detailed_mode_closure *closure = c;
3227 if (!is_display_descriptor(timing, EDID_DETAIL_EST_TIMINGS))
3230 closure->modes += drm_est3_modes(closure->connector, timing);
3234 * Get established modes from EDID and add them. Each EDID block contains a
3235 * bitmap of the supported "established modes" list (defined above). Tease them
3236 * out and add them to the global modes list.
3239 add_established_modes(struct drm_connector *connector, const struct edid *edid)
3241 struct drm_device *dev = connector->dev;
3242 unsigned long est_bits = edid->established_timings.t1 |
3243 (edid->established_timings.t2 << 8) |
3244 ((edid->established_timings.mfg_rsvd & 0x80) << 9);
3246 struct detailed_mode_closure closure = {
3247 .connector = connector,
3251 for (i = 0; i <= EDID_EST_TIMINGS; i++) {
3252 if (est_bits & (1<<i)) {
3253 struct drm_display_mode *newmode;
3255 newmode = drm_mode_duplicate(dev, &edid_est_modes[i]);
3257 drm_mode_probed_add(connector, newmode);
3263 if (version_greater(edid, 1, 0))
3264 drm_for_each_detailed_block(edid, do_established_modes,
3267 return modes + closure.modes;
3271 do_standard_modes(const struct detailed_timing *timing, void *c)
3273 struct detailed_mode_closure *closure = c;
3274 const struct detailed_non_pixel *data = &timing->data.other_data;
3275 struct drm_connector *connector = closure->connector;
3276 const struct edid *edid = closure->edid;
3279 if (!is_display_descriptor(timing, EDID_DETAIL_STD_MODES))
3282 for (i = 0; i < 6; i++) {
3283 const struct std_timing *std = &data->data.timings[i];
3284 struct drm_display_mode *newmode;
3286 newmode = drm_mode_std(connector, edid, std);
3288 drm_mode_probed_add(connector, newmode);
3295 * Get standard modes from EDID and add them. Standard modes can be calculated
3296 * using the appropriate standard (DMT, GTF, or CVT). Grab them from EDID and
3297 * add them to the list.
3300 add_standard_modes(struct drm_connector *connector, const struct edid *edid)
3303 struct detailed_mode_closure closure = {
3304 .connector = connector,
3308 for (i = 0; i < EDID_STD_TIMINGS; i++) {
3309 struct drm_display_mode *newmode;
3311 newmode = drm_mode_std(connector, edid,
3312 &edid->standard_timings[i]);
3314 drm_mode_probed_add(connector, newmode);
3319 if (version_greater(edid, 1, 0))
3320 drm_for_each_detailed_block(edid, do_standard_modes,
3323 /* XXX should also look for standard codes in VTB blocks */
3325 return modes + closure.modes;
3328 static int drm_cvt_modes(struct drm_connector *connector,
3329 const struct detailed_timing *timing)
3331 int i, j, modes = 0;
3332 struct drm_display_mode *newmode;
3333 struct drm_device *dev = connector->dev;
3334 const struct cvt_timing *cvt;
3335 const int rates[] = { 60, 85, 75, 60, 50 };
3336 const u8 empty[3] = { 0, 0, 0 };
3338 for (i = 0; i < 4; i++) {
3341 cvt = &(timing->data.other_data.data.cvt[i]);
3343 if (!memcmp(cvt->code, empty, 3))
3346 height = (cvt->code[0] + ((cvt->code[1] & 0xf0) << 4) + 1) * 2;
3347 switch (cvt->code[1] & 0x0c) {
3348 /* default - because compiler doesn't see that we've enumerated all cases */
3351 width = height * 4 / 3;
3354 width = height * 16 / 9;
3357 width = height * 16 / 10;
3360 width = height * 15 / 9;
3364 for (j = 1; j < 5; j++) {
3365 if (cvt->code[2] & (1 << j)) {
3366 newmode = drm_cvt_mode(dev, width, height,
3370 drm_mode_probed_add(connector, newmode);
3381 do_cvt_mode(const struct detailed_timing *timing, void *c)
3383 struct detailed_mode_closure *closure = c;
3385 if (!is_display_descriptor(timing, EDID_DETAIL_CVT_3BYTE))
3388 closure->modes += drm_cvt_modes(closure->connector, timing);
3392 add_cvt_modes(struct drm_connector *connector, const struct edid *edid)
3394 struct detailed_mode_closure closure = {
3395 .connector = connector,
3399 if (version_greater(edid, 1, 2))
3400 drm_for_each_detailed_block(edid, do_cvt_mode, &closure);
3402 /* XXX should also look for CVT codes in VTB blocks */
3404 return closure.modes;
3407 static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode);
3410 do_detailed_mode(const struct detailed_timing *timing, void *c)
3412 struct detailed_mode_closure *closure = c;
3413 struct drm_display_mode *newmode;
3415 if (!is_detailed_timing_descriptor(timing))
3418 newmode = drm_mode_detailed(closure->connector->dev,
3419 closure->edid, timing,
3424 if (closure->preferred)
3425 newmode->type |= DRM_MODE_TYPE_PREFERRED;
3428 * Detailed modes are limited to 10kHz pixel clock resolution,
3429 * so fix up anything that looks like CEA/HDMI mode, but the clock
3430 * is just slightly off.
3432 fixup_detailed_cea_mode_clock(newmode);
3434 drm_mode_probed_add(closure->connector, newmode);
3436 closure->preferred = false;
3440 * add_detailed_modes - Add modes from detailed timings
3441 * @connector: attached connector
3442 * @edid: EDID block to scan
3443 * @quirks: quirks to apply
3446 add_detailed_modes(struct drm_connector *connector, const struct edid *edid,
3449 struct detailed_mode_closure closure = {
3450 .connector = connector,
3456 if (closure.preferred && !version_greater(edid, 1, 3))
3458 (edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING);
3460 drm_for_each_detailed_block(edid, do_detailed_mode, &closure);
3462 return closure.modes;
3465 #define AUDIO_BLOCK 0x01
3466 #define VIDEO_BLOCK 0x02
3467 #define VENDOR_BLOCK 0x03
3468 #define SPEAKER_BLOCK 0x04
3469 #define HDR_STATIC_METADATA_BLOCK 0x6
3470 #define USE_EXTENDED_TAG 0x07
3471 #define EXT_VIDEO_CAPABILITY_BLOCK 0x00
3472 #define EXT_VIDEO_DATA_BLOCK_420 0x0E
3473 #define EXT_VIDEO_CAP_BLOCK_Y420CMDB 0x0F
3474 #define EDID_BASIC_AUDIO (1 << 6)
3475 #define EDID_CEA_YCRCB444 (1 << 5)
3476 #define EDID_CEA_YCRCB422 (1 << 4)
3477 #define EDID_CEA_VCDB_QS (1 << 6)
3480 * Search EDID for CEA extension block.
3482 const u8 *drm_find_edid_extension(const struct edid *edid,
3483 int ext_id, int *ext_index)
3485 const u8 *edid_ext = NULL;
3488 /* No EDID or EDID extensions */
3489 if (!edid || !edid_extension_block_count(edid))
3492 /* Find CEA extension */
3493 for (i = *ext_index; i < edid_extension_block_count(edid); i++) {
3494 edid_ext = edid_extension_block_data(edid, i);
3495 if (edid_block_tag(edid_ext) == ext_id)
3499 if (i >= edid_extension_block_count(edid))
3507 static const u8 *drm_find_cea_extension(const struct edid *edid)
3509 const struct displayid_block *block;
3510 struct displayid_iter iter;
3514 /* Look for a top level CEA extension block */
3515 /* FIXME: make callers iterate through multiple CEA ext blocks? */
3516 cea = drm_find_edid_extension(edid, CEA_EXT, &ext_index);
3520 /* CEA blocks can also be found embedded in a DisplayID block */
3521 displayid_iter_edid_begin(edid, &iter);
3522 displayid_iter_for_each(block, &iter) {
3523 if (block->tag == DATA_BLOCK_CTA) {
3524 cea = (const u8 *)block;
3528 displayid_iter_end(&iter);
3533 static __always_inline const struct drm_display_mode *cea_mode_for_vic(u8 vic)
3535 BUILD_BUG_ON(1 + ARRAY_SIZE(edid_cea_modes_1) - 1 != 127);
3536 BUILD_BUG_ON(193 + ARRAY_SIZE(edid_cea_modes_193) - 1 != 219);
3538 if (vic >= 1 && vic < 1 + ARRAY_SIZE(edid_cea_modes_1))
3539 return &edid_cea_modes_1[vic - 1];
3540 if (vic >= 193 && vic < 193 + ARRAY_SIZE(edid_cea_modes_193))
3541 return &edid_cea_modes_193[vic - 193];
3545 static u8 cea_num_vics(void)
3547 return 193 + ARRAY_SIZE(edid_cea_modes_193);
3550 static u8 cea_next_vic(u8 vic)
3552 if (++vic == 1 + ARRAY_SIZE(edid_cea_modes_1))
3558 * Calculate the alternate clock for the CEA mode
3559 * (60Hz vs. 59.94Hz etc.)
3562 cea_mode_alternate_clock(const struct drm_display_mode *cea_mode)
3564 unsigned int clock = cea_mode->clock;
3566 if (drm_mode_vrefresh(cea_mode) % 6 != 0)
3570 * edid_cea_modes contains the 59.94Hz
3571 * variant for 240 and 480 line modes,
3572 * and the 60Hz variant otherwise.
3574 if (cea_mode->vdisplay == 240 || cea_mode->vdisplay == 480)
3575 clock = DIV_ROUND_CLOSEST(clock * 1001, 1000);
3577 clock = DIV_ROUND_CLOSEST(clock * 1000, 1001);
3583 cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode)
3586 * For certain VICs the spec allows the vertical
3587 * front porch to vary by one or two lines.
3589 * cea_modes[] stores the variant with the shortest
3590 * vertical front porch. We can adjust the mode to
3591 * get the other variants by simply increasing the
3592 * vertical front porch length.
3594 BUILD_BUG_ON(cea_mode_for_vic(8)->vtotal != 262 ||
3595 cea_mode_for_vic(9)->vtotal != 262 ||
3596 cea_mode_for_vic(12)->vtotal != 262 ||
3597 cea_mode_for_vic(13)->vtotal != 262 ||
3598 cea_mode_for_vic(23)->vtotal != 312 ||
3599 cea_mode_for_vic(24)->vtotal != 312 ||
3600 cea_mode_for_vic(27)->vtotal != 312 ||
3601 cea_mode_for_vic(28)->vtotal != 312);
3603 if (((vic == 8 || vic == 9 ||
3604 vic == 12 || vic == 13) && mode->vtotal < 263) ||
3605 ((vic == 23 || vic == 24 ||
3606 vic == 27 || vic == 28) && mode->vtotal < 314)) {
3607 mode->vsync_start++;
3617 static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_match,
3618 unsigned int clock_tolerance)
3620 unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS;
3623 if (!to_match->clock)
3626 if (to_match->picture_aspect_ratio)
3627 match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
3629 for (vic = 1; vic < cea_num_vics(); vic = cea_next_vic(vic)) {
3630 struct drm_display_mode cea_mode;
3631 unsigned int clock1, clock2;
3633 drm_mode_init(&cea_mode, cea_mode_for_vic(vic));
3635 /* Check both 60Hz and 59.94Hz */
3636 clock1 = cea_mode.clock;
3637 clock2 = cea_mode_alternate_clock(&cea_mode);
3639 if (abs(to_match->clock - clock1) > clock_tolerance &&
3640 abs(to_match->clock - clock2) > clock_tolerance)
3644 if (drm_mode_match(to_match, &cea_mode, match_flags))
3646 } while (cea_mode_alternate_timings(vic, &cea_mode));
3653 * drm_match_cea_mode - look for a CEA mode matching given mode
3654 * @to_match: display mode
3656 * Return: The CEA Video ID (VIC) of the mode or 0 if it isn't a CEA-861
3659 u8 drm_match_cea_mode(const struct drm_display_mode *to_match)
3661 unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS;
3664 if (!to_match->clock)
3667 if (to_match->picture_aspect_ratio)
3668 match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
3670 for (vic = 1; vic < cea_num_vics(); vic = cea_next_vic(vic)) {
3671 struct drm_display_mode cea_mode;
3672 unsigned int clock1, clock2;
3674 drm_mode_init(&cea_mode, cea_mode_for_vic(vic));
3676 /* Check both 60Hz and 59.94Hz */
3677 clock1 = cea_mode.clock;
3678 clock2 = cea_mode_alternate_clock(&cea_mode);
3680 if (KHZ2PICOS(to_match->clock) != KHZ2PICOS(clock1) &&
3681 KHZ2PICOS(to_match->clock) != KHZ2PICOS(clock2))
3685 if (drm_mode_match(to_match, &cea_mode, match_flags))
3687 } while (cea_mode_alternate_timings(vic, &cea_mode));
3692 EXPORT_SYMBOL(drm_match_cea_mode);
3694 static bool drm_valid_cea_vic(u8 vic)
3696 return cea_mode_for_vic(vic) != NULL;
3699 static enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code)
3701 const struct drm_display_mode *mode = cea_mode_for_vic(video_code);
3704 return mode->picture_aspect_ratio;
3706 return HDMI_PICTURE_ASPECT_NONE;
3709 static enum hdmi_picture_aspect drm_get_hdmi_aspect_ratio(const u8 video_code)
3711 return edid_4k_modes[video_code].picture_aspect_ratio;
3715 * Calculate the alternate clock for HDMI modes (those from the HDMI vendor
3719 hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)
3721 return cea_mode_alternate_clock(hdmi_mode);
3724 static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_match,
3725 unsigned int clock_tolerance)
3727 unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS;
3730 if (!to_match->clock)
3733 if (to_match->picture_aspect_ratio)
3734 match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
3736 for (vic = 1; vic < ARRAY_SIZE(edid_4k_modes); vic++) {
3737 const struct drm_display_mode *hdmi_mode = &edid_4k_modes[vic];
3738 unsigned int clock1, clock2;
3740 /* Make sure to also match alternate clocks */
3741 clock1 = hdmi_mode->clock;
3742 clock2 = hdmi_mode_alternate_clock(hdmi_mode);
3744 if (abs(to_match->clock - clock1) > clock_tolerance &&
3745 abs(to_match->clock - clock2) > clock_tolerance)
3748 if (drm_mode_match(to_match, hdmi_mode, match_flags))
3756 * drm_match_hdmi_mode - look for a HDMI mode matching given mode
3757 * @to_match: display mode
3759 * An HDMI mode is one defined in the HDMI vendor specific block.
3761 * Returns the HDMI Video ID (VIC) of the mode or 0 if it isn't one.
3763 static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)
3765 unsigned int match_flags = DRM_MODE_MATCH_TIMINGS | DRM_MODE_MATCH_FLAGS;
3768 if (!to_match->clock)
3771 if (to_match->picture_aspect_ratio)
3772 match_flags |= DRM_MODE_MATCH_ASPECT_RATIO;
3774 for (vic = 1; vic < ARRAY_SIZE(edid_4k_modes); vic++) {
3775 const struct drm_display_mode *hdmi_mode = &edid_4k_modes[vic];
3776 unsigned int clock1, clock2;
3778 /* Make sure to also match alternate clocks */
3779 clock1 = hdmi_mode->clock;
3780 clock2 = hdmi_mode_alternate_clock(hdmi_mode);
3782 if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
3783 KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
3784 drm_mode_match(to_match, hdmi_mode, match_flags))
3790 static bool drm_valid_hdmi_vic(u8 vic)
3792 return vic > 0 && vic < ARRAY_SIZE(edid_4k_modes);
3796 add_alternate_cea_modes(struct drm_connector *connector, const struct edid *edid)
3798 struct drm_device *dev = connector->dev;
3799 struct drm_display_mode *mode, *tmp;
3803 /* Don't add CEA modes if the CEA extension block is missing */
3804 if (!drm_find_cea_extension(edid))
3808 * Go through all probed modes and create a new mode
3809 * with the alternate clock for certain CEA modes.
3811 list_for_each_entry(mode, &connector->probed_modes, head) {
3812 const struct drm_display_mode *cea_mode = NULL;
3813 struct drm_display_mode *newmode;
3814 u8 vic = drm_match_cea_mode(mode);
3815 unsigned int clock1, clock2;
3817 if (drm_valid_cea_vic(vic)) {
3818 cea_mode = cea_mode_for_vic(vic);
3819 clock2 = cea_mode_alternate_clock(cea_mode);
3821 vic = drm_match_hdmi_mode(mode);
3822 if (drm_valid_hdmi_vic(vic)) {
3823 cea_mode = &edid_4k_modes[vic];
3824 clock2 = hdmi_mode_alternate_clock(cea_mode);
3831 clock1 = cea_mode->clock;
3833 if (clock1 == clock2)
3836 if (mode->clock != clock1 && mode->clock != clock2)
3839 newmode = drm_mode_duplicate(dev, cea_mode);
3843 /* Carry over the stereo flags */
3844 newmode->flags |= mode->flags & DRM_MODE_FLAG_3D_MASK;
3847 * The current mode could be either variant. Make
3848 * sure to pick the "other" clock for the new mode.
3850 if (mode->clock != clock1)
3851 newmode->clock = clock1;
3853 newmode->clock = clock2;
3855 list_add_tail(&newmode->head, &list);
3858 list_for_each_entry_safe(mode, tmp, &list, head) {
3859 list_del(&mode->head);
3860 drm_mode_probed_add(connector, mode);
3867 static u8 svd_to_vic(u8 svd)
3869 /* 0-6 bit vic, 7th bit native mode indicator */
3870 if ((svd >= 1 && svd <= 64) || (svd >= 129 && svd <= 192))
3876 static struct drm_display_mode *
3877 drm_display_mode_from_vic_index(struct drm_connector *connector,
3878 const u8 *video_db, u8 video_len,
3881 struct drm_device *dev = connector->dev;
3882 struct drm_display_mode *newmode;
3885 if (video_db == NULL || video_index >= video_len)
3888 /* CEA modes are numbered 1..127 */
3889 vic = svd_to_vic(video_db[video_index]);
3890 if (!drm_valid_cea_vic(vic))
3893 newmode = drm_mode_duplicate(dev, cea_mode_for_vic(vic));
3901 * do_y420vdb_modes - Parse YCBCR 420 only modes
3902 * @connector: connector corresponding to the HDMI sink
3903 * @svds: start of the data block of CEA YCBCR 420 VDB
3904 * @len: length of the CEA YCBCR 420 VDB
3906 * Parse the CEA-861-F YCBCR 420 Video Data Block (Y420VDB)
3907 * which contains modes which can be supported in YCBCR 420
3908 * output format only.
3910 static int do_y420vdb_modes(struct drm_connector *connector,
3911 const u8 *svds, u8 svds_len)
3914 struct drm_device *dev = connector->dev;
3915 struct drm_display_info *info = &connector->display_info;
3916 struct drm_hdmi_info *hdmi = &info->hdmi;
3918 for (i = 0; i < svds_len; i++) {
3919 u8 vic = svd_to_vic(svds[i]);
3920 struct drm_display_mode *newmode;
3922 if (!drm_valid_cea_vic(vic))
3925 newmode = drm_mode_duplicate(dev, cea_mode_for_vic(vic));
3928 bitmap_set(hdmi->y420_vdb_modes, vic, 1);
3929 drm_mode_probed_add(connector, newmode);
3934 info->color_formats |= DRM_COLOR_FORMAT_YCBCR420;
3939 * drm_add_cmdb_modes - Add a YCBCR 420 mode into bitmap
3940 * @connector: connector corresponding to the HDMI sink
3941 * @vic: CEA vic for the video mode to be added in the map
3943 * Makes an entry for a videomode in the YCBCR 420 bitmap
3946 drm_add_cmdb_modes(struct drm_connector *connector, u8 svd)
3948 u8 vic = svd_to_vic(svd);
3949 struct drm_hdmi_info *hdmi = &connector->display_info.hdmi;
3951 if (!drm_valid_cea_vic(vic))
3954 bitmap_set(hdmi->y420_cmdb_modes, vic, 1);
3958 * drm_display_mode_from_cea_vic() - return a mode for CEA VIC
3960 * @video_code: CEA VIC of the mode
3962 * Creates a new mode matching the specified CEA VIC.
3964 * Returns: A new drm_display_mode on success or NULL on failure
3966 struct drm_display_mode *
3967 drm_display_mode_from_cea_vic(struct drm_device *dev,
3970 const struct drm_display_mode *cea_mode;
3971 struct drm_display_mode *newmode;
3973 cea_mode = cea_mode_for_vic(video_code);
3977 newmode = drm_mode_duplicate(dev, cea_mode);
3983 EXPORT_SYMBOL(drm_display_mode_from_cea_vic);
3986 do_cea_modes(struct drm_connector *connector, const u8 *db, u8 len)
3989 struct drm_hdmi_info *hdmi = &connector->display_info.hdmi;
3991 for (i = 0; i < len; i++) {
3992 struct drm_display_mode *mode;
3994 mode = drm_display_mode_from_vic_index(connector, db, len, i);
3997 * YCBCR420 capability block contains a bitmap which
3998 * gives the index of CEA modes from CEA VDB, which
3999 * can support YCBCR 420 sampling output also (apart
4000 * from RGB/YCBCR444 etc).
4001 * For example, if the bit 0 in bitmap is set,
4002 * first mode in VDB can support YCBCR420 output too.
4003 * Add YCBCR420 modes only if sink is HDMI 2.0 capable.
4005 if (i < 64 && hdmi->y420_cmdb_map & (1ULL << i))
4006 drm_add_cmdb_modes(connector, db[i]);
4008 drm_mode_probed_add(connector, mode);
4016 struct stereo_mandatory_mode {
4017 int width, height, vrefresh;
4021 static const struct stereo_mandatory_mode stereo_mandatory_modes[] = {
4022 { 1920, 1080, 24, DRM_MODE_FLAG_3D_TOP_AND_BOTTOM },
4023 { 1920, 1080, 24, DRM_MODE_FLAG_3D_FRAME_PACKING },
4025 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF },
4027 DRM_MODE_FLAG_INTERLACE | DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF },
4028 { 1280, 720, 50, DRM_MODE_FLAG_3D_TOP_AND_BOTTOM },
4029 { 1280, 720, 50, DRM_MODE_FLAG_3D_FRAME_PACKING },
4030 { 1280, 720, 60, DRM_MODE_FLAG_3D_TOP_AND_BOTTOM },
4031 { 1280, 720, 60, DRM_MODE_FLAG_3D_FRAME_PACKING }
4035 stereo_match_mandatory(const struct drm_display_mode *mode,
4036 const struct stereo_mandatory_mode *stereo_mode)
4038 unsigned int interlaced = mode->flags & DRM_MODE_FLAG_INTERLACE;
4040 return mode->hdisplay == stereo_mode->width &&
4041 mode->vdisplay == stereo_mode->height &&
4042 interlaced == (stereo_mode->flags & DRM_MODE_FLAG_INTERLACE) &&
4043 drm_mode_vrefresh(mode) == stereo_mode->vrefresh;
4046 static int add_hdmi_mandatory_stereo_modes(struct drm_connector *connector)
4048 struct drm_device *dev = connector->dev;
4049 const struct drm_display_mode *mode;
4050 struct list_head stereo_modes;
4053 INIT_LIST_HEAD(&stereo_modes);
4055 list_for_each_entry(mode, &connector->probed_modes, head) {
4056 for (i = 0; i < ARRAY_SIZE(stereo_mandatory_modes); i++) {
4057 const struct stereo_mandatory_mode *mandatory;
4058 struct drm_display_mode *new_mode;
4060 if (!stereo_match_mandatory(mode,
4061 &stereo_mandatory_modes[i]))
4064 mandatory = &stereo_mandatory_modes[i];
4065 new_mode = drm_mode_duplicate(dev, mode);
4069 new_mode->flags |= mandatory->flags;
4070 list_add_tail(&new_mode->head, &stereo_modes);
4075 list_splice_tail(&stereo_modes, &connector->probed_modes);
4080 static int add_hdmi_mode(struct drm_connector *connector, u8 vic)
4082 struct drm_device *dev = connector->dev;
4083 struct drm_display_mode *newmode;
4085 if (!drm_valid_hdmi_vic(vic)) {
4086 DRM_ERROR("Unknown HDMI VIC: %d\n", vic);
4090 newmode = drm_mode_duplicate(dev, &edid_4k_modes[vic]);
4094 drm_mode_probed_add(connector, newmode);
4099 static int add_3d_struct_modes(struct drm_connector *connector, u16 structure,
4100 const u8 *video_db, u8 video_len, u8 video_index)
4102 struct drm_display_mode *newmode;
4105 if (structure & (1 << 0)) {
4106 newmode = drm_display_mode_from_vic_index(connector, video_db,
4110 newmode->flags |= DRM_MODE_FLAG_3D_FRAME_PACKING;
4111 drm_mode_probed_add(connector, newmode);
4115 if (structure & (1 << 6)) {
4116 newmode = drm_display_mode_from_vic_index(connector, video_db,
4120 newmode->flags |= DRM_MODE_FLAG_3D_TOP_AND_BOTTOM;
4121 drm_mode_probed_add(connector, newmode);
4125 if (structure & (1 << 8)) {
4126 newmode = drm_display_mode_from_vic_index(connector, video_db,
4130 newmode->flags |= DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF;
4131 drm_mode_probed_add(connector, newmode);
4140 * do_hdmi_vsdb_modes - Parse the HDMI Vendor Specific data block
4141 * @connector: connector corresponding to the HDMI sink
4142 * @db: start of the CEA vendor specific block
4143 * @len: length of the CEA block payload, ie. one can access up to db[len]
4145 * Parses the HDMI VSDB looking for modes to add to @connector. This function
4146 * also adds the stereo 3d modes when applicable.
4149 do_hdmi_vsdb_modes(struct drm_connector *connector, const u8 *db, u8 len,
4150 const u8 *video_db, u8 video_len)
4152 struct drm_display_info *info = &connector->display_info;
4153 int modes = 0, offset = 0, i, multi_present = 0, multi_len;
4154 u8 vic_len, hdmi_3d_len = 0;
4161 /* no HDMI_Video_Present */
4162 if (!(db[8] & (1 << 5)))
4165 /* Latency_Fields_Present */
4166 if (db[8] & (1 << 7))
4169 /* I_Latency_Fields_Present */
4170 if (db[8] & (1 << 6))
4173 /* the declared length is not long enough for the 2 first bytes
4174 * of additional video format capabilities */
4175 if (len < (8 + offset + 2))
4180 if (db[8 + offset] & (1 << 7)) {
4181 modes += add_hdmi_mandatory_stereo_modes(connector);
4183 /* 3D_Multi_present */
4184 multi_present = (db[8 + offset] & 0x60) >> 5;
4188 vic_len = db[8 + offset] >> 5;
4189 hdmi_3d_len = db[8 + offset] & 0x1f;
4191 for (i = 0; i < vic_len && len >= (9 + offset + i); i++) {
4194 vic = db[9 + offset + i];
4195 modes += add_hdmi_mode(connector, vic);
4197 offset += 1 + vic_len;
4199 if (multi_present == 1)
4201 else if (multi_present == 2)
4206 if (len < (8 + offset + hdmi_3d_len - 1))
4209 if (hdmi_3d_len < multi_len)
4212 if (multi_present == 1 || multi_present == 2) {
4213 /* 3D_Structure_ALL */
4214 structure_all = (db[8 + offset] << 8) | db[9 + offset];
4216 /* check if 3D_MASK is present */
4217 if (multi_present == 2)
4218 mask = (db[10 + offset] << 8) | db[11 + offset];
4222 for (i = 0; i < 16; i++) {
4223 if (mask & (1 << i))
4224 modes += add_3d_struct_modes(connector,
4231 offset += multi_len;
4233 for (i = 0; i < (hdmi_3d_len - multi_len); i++) {
4235 struct drm_display_mode *newmode = NULL;
4236 unsigned int newflag = 0;
4237 bool detail_present;
4239 detail_present = ((db[8 + offset + i] & 0x0f) > 7);
4241 if (detail_present && (i + 1 == hdmi_3d_len - multi_len))
4244 /* 2D_VIC_order_X */
4245 vic_index = db[8 + offset + i] >> 4;
4247 /* 3D_Structure_X */
4248 switch (db[8 + offset + i] & 0x0f) {
4250 newflag = DRM_MODE_FLAG_3D_FRAME_PACKING;
4253 newflag = DRM_MODE_FLAG_3D_TOP_AND_BOTTOM;
4257 if ((db[9 + offset + i] >> 4) == 1)
4258 newflag = DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF;
4263 newmode = drm_display_mode_from_vic_index(connector,
4269 newmode->flags |= newflag;
4270 drm_mode_probed_add(connector, newmode);
4281 info->has_hdmi_infoframe = true;
4286 cea_db_payload_len(const u8 *db)
4288 return db[0] & 0x1f;
4292 cea_db_extended_tag(const u8 *db)
4298 cea_db_tag(const u8 *db)
4304 cea_revision(const u8 *cea)
4307 * FIXME is this correct for the DispID variant?
4308 * The DispID spec doesn't really specify whether
4309 * this is the revision of the CEA extension or
4310 * the DispID CEA data block. And the only value
4311 * given as an example is 0.
4317 cea_db_offsets(const u8 *cea, int *start, int *end)
4319 /* DisplayID CTA extension blocks and top-level CEA EDID
4320 * block header definitions differ in the following bytes:
4321 * 1) Byte 2 of the header specifies length differently,
4322 * 2) Byte 3 is only present in the CEA top level block.
4324 * The different definitions for byte 2 follow.
4326 * DisplayID CTA extension block defines byte 2 as:
4327 * Number of payload bytes
4329 * CEA EDID block defines byte 2 as:
4330 * Byte number (decimal) within this block where the 18-byte
4331 * DTDs begin. If no non-DTD data is present in this extension
4332 * block, the value should be set to 04h (the byte after next).
4333 * If set to 00h, there are no DTDs present in this block and
4336 if (cea[0] == DATA_BLOCK_CTA) {
4338 * for_each_displayid_db() has already verified
4339 * that these stay within expected bounds.
4342 *end = *start + cea[2];
4343 } else if (cea[0] == CEA_EXT) {
4344 /* Data block offset in CEA extension block */
4349 if (*end < 4 || *end > 127)
4358 static bool cea_db_is_hdmi_vsdb(const u8 *db)
4360 if (cea_db_tag(db) != VENDOR_BLOCK)
4363 if (cea_db_payload_len(db) < 5)
4366 return oui(db[3], db[2], db[1]) == HDMI_IEEE_OUI;
4369 static bool cea_db_is_hdmi_forum_vsdb(const u8 *db)
4371 if (cea_db_tag(db) != VENDOR_BLOCK)
4374 if (cea_db_payload_len(db) < 7)
4377 return oui(db[3], db[2], db[1]) == HDMI_FORUM_IEEE_OUI;
4380 static bool cea_db_is_microsoft_vsdb(const u8 *db)
4382 if (cea_db_tag(db) != VENDOR_BLOCK)
4385 if (cea_db_payload_len(db) != 21)
4388 return oui(db[3], db[2], db[1]) == MICROSOFT_IEEE_OUI;
4391 static bool cea_db_is_vcdb(const u8 *db)
4393 if (cea_db_tag(db) != USE_EXTENDED_TAG)
4396 if (cea_db_payload_len(db) != 2)
4399 if (cea_db_extended_tag(db) != EXT_VIDEO_CAPABILITY_BLOCK)
4405 static bool cea_db_is_y420cmdb(const u8 *db)
4407 if (cea_db_tag(db) != USE_EXTENDED_TAG)
4410 if (!cea_db_payload_len(db))
4413 if (cea_db_extended_tag(db) != EXT_VIDEO_CAP_BLOCK_Y420CMDB)
4419 static bool cea_db_is_y420vdb(const u8 *db)
4421 if (cea_db_tag(db) != USE_EXTENDED_TAG)
4424 if (!cea_db_payload_len(db))
4427 if (cea_db_extended_tag(db) != EXT_VIDEO_DATA_BLOCK_420)
4433 #define for_each_cea_db(cea, i, start, end) \
4434 for ((i) = (start); (i) < (end) && (i) + cea_db_payload_len(&(cea)[(i)]) < (end); (i) += cea_db_payload_len(&(cea)[(i)]) + 1)
4436 static void drm_parse_y420cmdb_bitmap(struct drm_connector *connector,
4439 struct drm_display_info *info = &connector->display_info;
4440 struct drm_hdmi_info *hdmi = &info->hdmi;
4441 u8 map_len = cea_db_payload_len(db) - 1;
4446 /* All CEA modes support ycbcr420 sampling also.*/
4447 hdmi->y420_cmdb_map = U64_MAX;
4448 info->color_formats |= DRM_COLOR_FORMAT_YCBCR420;
4453 * This map indicates which of the existing CEA block modes
4454 * from VDB can support YCBCR420 output too. So if bit=0 is
4455 * set, first mode from VDB can support YCBCR420 output too.
4456 * We will parse and keep this map, before parsing VDB itself
4457 * to avoid going through the same block again and again.
4459 * Spec is not clear about max possible size of this block.
4460 * Clamping max bitmap block size at 8 bytes. Every byte can
4461 * address 8 CEA modes, in this way this map can address
4462 * 8*8 = first 64 SVDs.
4464 if (WARN_ON_ONCE(map_len > 8))
4467 for (count = 0; count < map_len; count++)
4468 map |= (u64)db[2 + count] << (8 * count);
4471 info->color_formats |= DRM_COLOR_FORMAT_YCBCR420;
4473 hdmi->y420_cmdb_map = map;
4477 add_cea_modes(struct drm_connector *connector, const struct edid *edid)
4479 const u8 *cea = drm_find_cea_extension(edid);
4480 const u8 *db, *hdmi = NULL, *video = NULL;
4481 u8 dbl, hdmi_len, video_len = 0;
4484 if (cea && cea_revision(cea) >= 3) {
4487 if (cea_db_offsets(cea, &start, &end))
4490 for_each_cea_db(cea, i, start, end) {
4492 dbl = cea_db_payload_len(db);
4494 if (cea_db_tag(db) == VIDEO_BLOCK) {
4497 modes += do_cea_modes(connector, video, dbl);
4498 } else if (cea_db_is_hdmi_vsdb(db)) {
4501 } else if (cea_db_is_y420vdb(db)) {
4502 const u8 *vdb420 = &db[2];
4504 /* Add 4:2:0(only) modes present in EDID */
4505 modes += do_y420vdb_modes(connector,
4513 * We parse the HDMI VSDB after having added the cea modes as we will
4514 * be patching their flags when the sink supports stereo 3D.
4517 modes += do_hdmi_vsdb_modes(connector, hdmi, hdmi_len, video,
4523 static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode)
4525 const struct drm_display_mode *cea_mode;
4526 int clock1, clock2, clock;
4531 * allow 5kHz clock difference either way to account for
4532 * the 10kHz clock resolution limit of detailed timings.
4534 vic = drm_match_cea_mode_clock_tolerance(mode, 5);
4535 if (drm_valid_cea_vic(vic)) {
4537 cea_mode = cea_mode_for_vic(vic);
4538 clock1 = cea_mode->clock;
4539 clock2 = cea_mode_alternate_clock(cea_mode);
4541 vic = drm_match_hdmi_mode_clock_tolerance(mode, 5);
4542 if (drm_valid_hdmi_vic(vic)) {
4544 cea_mode = &edid_4k_modes[vic];
4545 clock1 = cea_mode->clock;
4546 clock2 = hdmi_mode_alternate_clock(cea_mode);
4552 /* pick whichever is closest */
4553 if (abs(mode->clock - clock1) < abs(mode->clock - clock2))
4558 if (mode->clock == clock)
4561 DRM_DEBUG("detailed mode matches %s VIC %d, adjusting clock %d -> %d\n",
4562 type, vic, mode->clock, clock);
4563 mode->clock = clock;
4566 static bool cea_db_is_hdmi_hdr_metadata_block(const u8 *db)
4568 if (cea_db_tag(db) != USE_EXTENDED_TAG)
4571 if (db[1] != HDR_STATIC_METADATA_BLOCK)
4574 if (cea_db_payload_len(db) < 3)
4580 static uint8_t eotf_supported(const u8 *edid_ext)
4582 return edid_ext[2] &
4583 (BIT(HDMI_EOTF_TRADITIONAL_GAMMA_SDR) |
4584 BIT(HDMI_EOTF_TRADITIONAL_GAMMA_HDR) |
4585 BIT(HDMI_EOTF_SMPTE_ST2084) |
4586 BIT(HDMI_EOTF_BT_2100_HLG));
4589 static uint8_t hdr_metadata_type(const u8 *edid_ext)
4591 return edid_ext[3] &
4592 BIT(HDMI_STATIC_METADATA_TYPE1);
4596 drm_parse_hdr_metadata_block(struct drm_connector *connector, const u8 *db)
4600 len = cea_db_payload_len(db);
4602 connector->hdr_sink_metadata.hdmi_type1.eotf =
4604 connector->hdr_sink_metadata.hdmi_type1.metadata_type =
4605 hdr_metadata_type(db);
4608 connector->hdr_sink_metadata.hdmi_type1.max_cll = db[4];
4610 connector->hdr_sink_metadata.hdmi_type1.max_fall = db[5];
4612 connector->hdr_sink_metadata.hdmi_type1.min_cll = db[6];
4616 drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
4618 u8 len = cea_db_payload_len(db);
4620 if (len >= 6 && (db[6] & (1 << 7)))
4621 connector->eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= DRM_ELD_SUPPORTS_AI;
4623 connector->latency_present[0] = db[8] >> 7;
4624 connector->latency_present[1] = (db[8] >> 6) & 1;
4627 connector->video_latency[0] = db[9];
4629 connector->audio_latency[0] = db[10];
4631 connector->video_latency[1] = db[11];
4633 connector->audio_latency[1] = db[12];
4635 DRM_DEBUG_KMS("HDMI: latency present %d %d, "
4636 "video latency %d %d, "
4637 "audio latency %d %d\n",
4638 connector->latency_present[0],
4639 connector->latency_present[1],
4640 connector->video_latency[0],
4641 connector->video_latency[1],
4642 connector->audio_latency[0],
4643 connector->audio_latency[1]);
4647 monitor_name(const struct detailed_timing *timing, void *data)
4649 const char **res = data;
4651 if (!is_display_descriptor(timing, EDID_DETAIL_MONITOR_NAME))
4654 *res = timing->data.other_data.data.str.str;
4657 static int get_monitor_name(const struct edid *edid, char name[13])
4659 const char *edid_name = NULL;
4665 drm_for_each_detailed_block(edid, monitor_name, &edid_name);
4666 for (mnl = 0; edid_name && mnl < 13; mnl++) {
4667 if (edid_name[mnl] == 0x0a)
4670 name[mnl] = edid_name[mnl];
4677 * drm_edid_get_monitor_name - fetch the monitor name from the edid
4678 * @edid: monitor EDID information
4679 * @name: pointer to a character array to hold the name of the monitor
4680 * @bufsize: The size of the name buffer (should be at least 14 chars.)
4683 void drm_edid_get_monitor_name(const struct edid *edid, char *name, int bufsize)
4691 name_length = min(get_monitor_name(edid, buf), bufsize - 1);
4692 memcpy(name, buf, name_length);
4693 name[name_length] = '\0';
4695 EXPORT_SYMBOL(drm_edid_get_monitor_name);
4697 static void clear_eld(struct drm_connector *connector)
4699 memset(connector->eld, 0, sizeof(connector->eld));
4701 connector->latency_present[0] = false;
4702 connector->latency_present[1] = false;
4703 connector->video_latency[0] = 0;
4704 connector->audio_latency[0] = 0;
4705 connector->video_latency[1] = 0;
4706 connector->audio_latency[1] = 0;
4710 * drm_edid_to_eld - build ELD from EDID
4711 * @connector: connector corresponding to the HDMI/DP sink
4712 * @edid: EDID to parse
4714 * Fill the ELD (EDID-Like Data) buffer for passing to the audio driver. The
4715 * HDCP and Port_ID ELD fields are left for the graphics driver to fill in.
4717 static void drm_edid_to_eld(struct drm_connector *connector,
4718 const struct edid *edid)
4720 uint8_t *eld = connector->eld;
4723 int total_sad_count = 0;
4727 clear_eld(connector);
4732 cea = drm_find_cea_extension(edid);
4734 DRM_DEBUG_KMS("ELD: no CEA Extension found\n");
4738 mnl = get_monitor_name(edid, &eld[DRM_ELD_MONITOR_NAME_STRING]);
4739 DRM_DEBUG_KMS("ELD monitor %s\n", &eld[DRM_ELD_MONITOR_NAME_STRING]);
4741 eld[DRM_ELD_CEA_EDID_VER_MNL] = cea[1] << DRM_ELD_CEA_EDID_VER_SHIFT;
4742 eld[DRM_ELD_CEA_EDID_VER_MNL] |= mnl;
4744 eld[DRM_ELD_VER] = DRM_ELD_VER_CEA861D;
4746 eld[DRM_ELD_MANUFACTURER_NAME0] = edid->mfg_id[0];
4747 eld[DRM_ELD_MANUFACTURER_NAME1] = edid->mfg_id[1];
4748 eld[DRM_ELD_PRODUCT_CODE0] = edid->prod_code[0];
4749 eld[DRM_ELD_PRODUCT_CODE1] = edid->prod_code[1];
4751 if (cea_revision(cea) >= 3) {
4755 if (cea_db_offsets(cea, &start, &end)) {
4760 for_each_cea_db(cea, i, start, end) {
4762 dbl = cea_db_payload_len(db);
4764 switch (cea_db_tag(db)) {
4766 /* Audio Data Block, contains SADs */
4767 sad_count = min(dbl / 3, 15 - total_sad_count);
4769 memcpy(&eld[DRM_ELD_CEA_SAD(mnl, total_sad_count)],
4770 &db[1], sad_count * 3);
4771 total_sad_count += sad_count;
4774 /* Speaker Allocation Data Block */
4776 eld[DRM_ELD_SPEAKER] = db[1];
4779 /* HDMI Vendor-Specific Data Block */
4780 if (cea_db_is_hdmi_vsdb(db))
4781 drm_parse_hdmi_vsdb_audio(connector, db);
4788 eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= total_sad_count << DRM_ELD_SAD_COUNT_SHIFT;
4790 if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
4791 connector->connector_type == DRM_MODE_CONNECTOR_eDP)
4792 eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= DRM_ELD_CONN_TYPE_DP;
4794 eld[DRM_ELD_SAD_COUNT_CONN_TYPE] |= DRM_ELD_CONN_TYPE_HDMI;
4796 eld[DRM_ELD_BASELINE_ELD_LEN] =
4797 DIV_ROUND_UP(drm_eld_calc_baseline_block_size(eld), 4);
4799 DRM_DEBUG_KMS("ELD size %d, SAD count %d\n",
4800 drm_eld_size(eld), total_sad_count);
4804 * drm_edid_to_sad - extracts SADs from EDID
4805 * @edid: EDID to parse
4806 * @sads: pointer that will be set to the extracted SADs
4808 * Looks for CEA EDID block and extracts SADs (Short Audio Descriptors) from it.
4810 * Note: The returned pointer needs to be freed using kfree().
4812 * Return: The number of found SADs or negative number on error.
4814 int drm_edid_to_sad(const struct edid *edid, struct cea_sad **sads)
4817 int i, start, end, dbl;
4820 cea = drm_find_cea_extension(edid);
4822 DRM_DEBUG_KMS("SAD: no CEA Extension found\n");
4826 if (cea_revision(cea) < 3) {
4827 DRM_DEBUG_KMS("SAD: wrong CEA revision\n");
4831 if (cea_db_offsets(cea, &start, &end)) {
4832 DRM_DEBUG_KMS("SAD: invalid data block offsets\n");
4836 for_each_cea_db(cea, i, start, end) {
4837 const u8 *db = &cea[i];
4839 if (cea_db_tag(db) == AUDIO_BLOCK) {
4842 dbl = cea_db_payload_len(db);
4844 count = dbl / 3; /* SAD is 3B */
4845 *sads = kcalloc(count, sizeof(**sads), GFP_KERNEL);
4848 for (j = 0; j < count; j++) {
4849 const u8 *sad = &db[1 + j * 3];
4851 (*sads)[j].format = (sad[0] & 0x78) >> 3;
4852 (*sads)[j].channels = sad[0] & 0x7;
4853 (*sads)[j].freq = sad[1] & 0x7F;
4854 (*sads)[j].byte2 = sad[2];
4862 EXPORT_SYMBOL(drm_edid_to_sad);
4865 * drm_edid_to_speaker_allocation - extracts Speaker Allocation Data Blocks from EDID
4866 * @edid: EDID to parse
4867 * @sadb: pointer to the speaker block
4869 * Looks for CEA EDID block and extracts the Speaker Allocation Data Block from it.
4871 * Note: The returned pointer needs to be freed using kfree().
4873 * Return: The number of found Speaker Allocation Blocks or negative number on
4876 int drm_edid_to_speaker_allocation(const struct edid *edid, u8 **sadb)
4879 int i, start, end, dbl;
4882 cea = drm_find_cea_extension(edid);
4884 DRM_DEBUG_KMS("SAD: no CEA Extension found\n");
4888 if (cea_revision(cea) < 3) {
4889 DRM_DEBUG_KMS("SAD: wrong CEA revision\n");
4893 if (cea_db_offsets(cea, &start, &end)) {
4894 DRM_DEBUG_KMS("SAD: invalid data block offsets\n");
4898 for_each_cea_db(cea, i, start, end) {
4899 const u8 *db = &cea[i];
4901 if (cea_db_tag(db) == SPEAKER_BLOCK) {
4902 dbl = cea_db_payload_len(db);
4904 /* Speaker Allocation Data Block */
4906 *sadb = kmemdup(&db[1], dbl, GFP_KERNEL);
4917 EXPORT_SYMBOL(drm_edid_to_speaker_allocation);
4920 * drm_av_sync_delay - compute the HDMI/DP sink audio-video sync delay
4921 * @connector: connector associated with the HDMI/DP sink
4922 * @mode: the display mode
4924 * Return: The HDMI/DP sink's audio-video sync delay in milliseconds or 0 if
4925 * the sink doesn't support audio or video.
4927 int drm_av_sync_delay(struct drm_connector *connector,
4928 const struct drm_display_mode *mode)
4930 int i = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);
4933 if (!connector->latency_present[0])
4935 if (!connector->latency_present[1])
4938 a = connector->audio_latency[i];
4939 v = connector->video_latency[i];
4942 * HDMI/DP sink doesn't support audio or video?
4944 if (a == 255 || v == 255)
4948 * Convert raw EDID values to millisecond.
4949 * Treat unknown latency as 0ms.
4952 a = min(2 * (a - 1), 500);
4954 v = min(2 * (v - 1), 500);
4956 return max(v - a, 0);
4958 EXPORT_SYMBOL(drm_av_sync_delay);
4961 * drm_detect_hdmi_monitor - detect whether monitor is HDMI
4962 * @edid: monitor EDID information
4964 * Parse the CEA extension according to CEA-861-B.
4966 * Drivers that have added the modes parsed from EDID to drm_display_info
4967 * should use &drm_display_info.is_hdmi instead of calling this function.
4969 * Return: True if the monitor is HDMI, false if not or unknown.
4971 bool drm_detect_hdmi_monitor(const struct edid *edid)
4975 int start_offset, end_offset;
4977 edid_ext = drm_find_cea_extension(edid);
4981 if (cea_db_offsets(edid_ext, &start_offset, &end_offset))
4985 * Because HDMI identifier is in Vendor Specific Block,
4986 * search it from all data blocks of CEA extension.
4988 for_each_cea_db(edid_ext, i, start_offset, end_offset) {
4989 if (cea_db_is_hdmi_vsdb(&edid_ext[i]))
4995 EXPORT_SYMBOL(drm_detect_hdmi_monitor);
4998 * drm_detect_monitor_audio - check monitor audio capability
4999 * @edid: EDID block to scan
5001 * Monitor should have CEA extension block.
5002 * If monitor has 'basic audio', but no CEA audio blocks, it's 'basic
5003 * audio' only. If there is any audio extension block and supported
5004 * audio format, assume at least 'basic audio' support, even if 'basic
5005 * audio' is not defined in EDID.
5007 * Return: True if the monitor supports audio, false otherwise.
5009 bool drm_detect_monitor_audio(const struct edid *edid)
5013 bool has_audio = false;
5014 int start_offset, end_offset;
5016 edid_ext = drm_find_cea_extension(edid);
5020 has_audio = (edid_ext[0] == CEA_EXT &&
5021 (edid_ext[3] & EDID_BASIC_AUDIO) != 0);
5024 DRM_DEBUG_KMS("Monitor has basic audio support\n");
5028 if (cea_db_offsets(edid_ext, &start_offset, &end_offset))
5031 for_each_cea_db(edid_ext, i, start_offset, end_offset) {
5032 if (cea_db_tag(&edid_ext[i]) == AUDIO_BLOCK) {
5034 for (j = 1; j < cea_db_payload_len(&edid_ext[i]) + 1; j += 3)
5035 DRM_DEBUG_KMS("CEA audio format %d\n",
5036 (edid_ext[i + j] >> 3) & 0xf);
5043 EXPORT_SYMBOL(drm_detect_monitor_audio);
5047 * drm_default_rgb_quant_range - default RGB quantization range
5048 * @mode: display mode
5050 * Determine the default RGB quantization range for the mode,
5051 * as specified in CEA-861.
5053 * Return: The default RGB quantization range for the mode
5055 enum hdmi_quantization_range
5056 drm_default_rgb_quant_range(const struct drm_display_mode *mode)
5058 /* All CEA modes other than VIC 1 use limited quantization range. */
5059 return drm_match_cea_mode(mode) > 1 ?
5060 HDMI_QUANTIZATION_RANGE_LIMITED :
5061 HDMI_QUANTIZATION_RANGE_FULL;
5063 EXPORT_SYMBOL(drm_default_rgb_quant_range);
5065 static void drm_parse_vcdb(struct drm_connector *connector, const u8 *db)
5067 struct drm_display_info *info = &connector->display_info;
5069 DRM_DEBUG_KMS("CEA VCDB 0x%02x\n", db[2]);
5071 if (db[2] & EDID_CEA_VCDB_QS)
5072 info->rgb_quant_range_selectable = true;
5076 void drm_get_max_frl_rate(int max_frl_rate, u8 *max_lanes, u8 *max_rate_per_lane)
5078 switch (max_frl_rate) {
5081 *max_rate_per_lane = 3;
5085 *max_rate_per_lane = 6;
5089 *max_rate_per_lane = 6;
5093 *max_rate_per_lane = 8;
5097 *max_rate_per_lane = 10;
5101 *max_rate_per_lane = 12;
5106 *max_rate_per_lane = 0;
5110 static void drm_parse_ycbcr420_deep_color_info(struct drm_connector *connector,
5114 struct drm_hdmi_info *hdmi = &connector->display_info.hdmi;
5116 dc_mask = db[7] & DRM_EDID_YCBCR420_DC_MASK;
5117 hdmi->y420_dc_modes = dc_mask;
5120 static void drm_parse_hdmi_forum_vsdb(struct drm_connector *connector,
5123 struct drm_display_info *display = &connector->display_info;
5124 struct drm_hdmi_info *hdmi = &display->hdmi;
5126 display->has_hdmi_infoframe = true;
5128 if (hf_vsdb[6] & 0x80) {
5129 hdmi->scdc.supported = true;
5130 if (hf_vsdb[6] & 0x40)
5131 hdmi->scdc.read_request = true;
5135 * All HDMI 2.0 monitors must support scrambling at rates > 340 MHz.
5136 * And as per the spec, three factors confirm this:
5137 * * Availability of a HF-VSDB block in EDID (check)
5138 * * Non zero Max_TMDS_Char_Rate filed in HF-VSDB (let's check)
5139 * * SCDC support available (let's check)
5140 * Lets check it out.
5144 /* max clock is 5000 KHz times block value */
5145 u32 max_tmds_clock = hf_vsdb[5] * 5000;
5146 struct drm_scdc *scdc = &hdmi->scdc;
5148 if (max_tmds_clock > 340000) {
5149 display->max_tmds_clock = max_tmds_clock;
5150 DRM_DEBUG_KMS("HF-VSDB: max TMDS clock %d kHz\n",
5151 display->max_tmds_clock);
5154 if (scdc->supported) {
5155 scdc->scrambling.supported = true;
5157 /* Few sinks support scrambling for clocks < 340M */
5158 if ((hf_vsdb[6] & 0x8))
5159 scdc->scrambling.low_rates = true;
5165 u8 dsc_max_frl_rate;
5167 struct drm_hdmi_dsc_cap *hdmi_dsc = &hdmi->dsc_cap;
5169 DRM_DEBUG_KMS("hdmi_21 sink detected. parsing edid\n");
5170 max_frl_rate = (hf_vsdb[7] & DRM_EDID_MAX_FRL_RATE_MASK) >> 4;
5171 drm_get_max_frl_rate(max_frl_rate, &hdmi->max_lanes,
5172 &hdmi->max_frl_rate_per_lane);
5173 hdmi_dsc->v_1p2 = hf_vsdb[11] & DRM_EDID_DSC_1P2;
5175 if (hdmi_dsc->v_1p2) {
5176 hdmi_dsc->native_420 = hf_vsdb[11] & DRM_EDID_DSC_NATIVE_420;
5177 hdmi_dsc->all_bpp = hf_vsdb[11] & DRM_EDID_DSC_ALL_BPP;
5179 if (hf_vsdb[11] & DRM_EDID_DSC_16BPC)
5180 hdmi_dsc->bpc_supported = 16;
5181 else if (hf_vsdb[11] & DRM_EDID_DSC_12BPC)
5182 hdmi_dsc->bpc_supported = 12;
5183 else if (hf_vsdb[11] & DRM_EDID_DSC_10BPC)
5184 hdmi_dsc->bpc_supported = 10;
5186 hdmi_dsc->bpc_supported = 0;
5188 dsc_max_frl_rate = (hf_vsdb[12] & DRM_EDID_DSC_MAX_FRL_RATE_MASK) >> 4;
5189 drm_get_max_frl_rate(dsc_max_frl_rate, &hdmi_dsc->max_lanes,
5190 &hdmi_dsc->max_frl_rate_per_lane);
5191 hdmi_dsc->total_chunk_kbytes = hf_vsdb[13] & DRM_EDID_DSC_TOTAL_CHUNK_KBYTES;
5193 dsc_max_slices = hf_vsdb[12] & DRM_EDID_DSC_MAX_SLICES;
5194 switch (dsc_max_slices) {
5196 hdmi_dsc->max_slices = 1;
5197 hdmi_dsc->clk_per_slice = 340;
5200 hdmi_dsc->max_slices = 2;
5201 hdmi_dsc->clk_per_slice = 340;
5204 hdmi_dsc->max_slices = 4;
5205 hdmi_dsc->clk_per_slice = 340;
5208 hdmi_dsc->max_slices = 8;
5209 hdmi_dsc->clk_per_slice = 340;
5212 hdmi_dsc->max_slices = 8;
5213 hdmi_dsc->clk_per_slice = 400;
5216 hdmi_dsc->max_slices = 12;
5217 hdmi_dsc->clk_per_slice = 400;
5220 hdmi_dsc->max_slices = 16;
5221 hdmi_dsc->clk_per_slice = 400;
5225 hdmi_dsc->max_slices = 0;
5226 hdmi_dsc->clk_per_slice = 0;
5231 drm_parse_ycbcr420_deep_color_info(connector, hf_vsdb);
5234 static void drm_parse_hdmi_deep_color_info(struct drm_connector *connector,
5237 struct drm_display_info *info = &connector->display_info;
5238 unsigned int dc_bpc = 0;
5240 /* HDMI supports at least 8 bpc */
5243 if (cea_db_payload_len(hdmi) < 6)
5246 if (hdmi[6] & DRM_EDID_HDMI_DC_30) {
5248 info->edid_hdmi_rgb444_dc_modes |= DRM_EDID_HDMI_DC_30;
5249 DRM_DEBUG("%s: HDMI sink does deep color 30.\n",
5253 if (hdmi[6] & DRM_EDID_HDMI_DC_36) {
5255 info->edid_hdmi_rgb444_dc_modes |= DRM_EDID_HDMI_DC_36;
5256 DRM_DEBUG("%s: HDMI sink does deep color 36.\n",
5260 if (hdmi[6] & DRM_EDID_HDMI_DC_48) {
5262 info->edid_hdmi_rgb444_dc_modes |= DRM_EDID_HDMI_DC_48;
5263 DRM_DEBUG("%s: HDMI sink does deep color 48.\n",
5268 DRM_DEBUG("%s: No deep color support on this HDMI sink.\n",
5273 DRM_DEBUG("%s: Assigning HDMI sink color depth as %d bpc.\n",
5274 connector->name, dc_bpc);
5277 /* YCRCB444 is optional according to spec. */
5278 if (hdmi[6] & DRM_EDID_HDMI_DC_Y444) {
5279 info->edid_hdmi_ycbcr444_dc_modes = info->edid_hdmi_rgb444_dc_modes;
5280 DRM_DEBUG("%s: HDMI sink does YCRCB444 in deep color.\n",
5285 * Spec says that if any deep color mode is supported at all,
5286 * then deep color 36 bit must be supported.
5288 if (!(hdmi[6] & DRM_EDID_HDMI_DC_36)) {
5289 DRM_DEBUG("%s: HDMI sink should do DC_36, but does not!\n",
5295 drm_parse_hdmi_vsdb_video(struct drm_connector *connector, const u8 *db)
5297 struct drm_display_info *info = &connector->display_info;
5298 u8 len = cea_db_payload_len(db);
5300 info->is_hdmi = true;
5303 info->dvi_dual = db[6] & 1;
5305 info->max_tmds_clock = db[7] * 5000;
5307 DRM_DEBUG_KMS("HDMI: DVI dual %d, "
5308 "max TMDS clock %d kHz\n",
5310 info->max_tmds_clock);
5312 drm_parse_hdmi_deep_color_info(connector, db);
5316 * See EDID extension for head-mounted and specialized monitors, specified at:
5317 * https://docs.microsoft.com/en-us/windows-hardware/drivers/display/specialized-monitors-edid-extension
5319 static void drm_parse_microsoft_vsdb(struct drm_connector *connector,
5322 struct drm_display_info *info = &connector->display_info;
5324 bool desktop_usage = db[5] & BIT(6);
5326 /* Version 1 and 2 for HMDs, version 3 flags desktop usage explicitly */
5327 if (version == 1 || version == 2 || (version == 3 && !desktop_usage))
5328 info->non_desktop = true;
5330 drm_dbg_kms(connector->dev, "HMD or specialized display VSDB version %u: 0x%02x\n",
5334 static void drm_parse_cea_ext(struct drm_connector *connector,
5335 const struct edid *edid)
5337 struct drm_display_info *info = &connector->display_info;
5341 edid_ext = drm_find_cea_extension(edid);
5345 info->cea_rev = edid_ext[1];
5347 /* The existence of a CEA block should imply RGB support */
5348 info->color_formats = DRM_COLOR_FORMAT_RGB444;
5350 /* CTA DisplayID Data Block does not have byte #3 */
5351 if (edid_ext[0] == CEA_EXT) {
5352 if (edid_ext[3] & EDID_CEA_YCRCB444)
5353 info->color_formats |= DRM_COLOR_FORMAT_YCBCR444;
5354 if (edid_ext[3] & EDID_CEA_YCRCB422)
5355 info->color_formats |= DRM_COLOR_FORMAT_YCBCR422;
5358 if (cea_db_offsets(edid_ext, &start, &end))
5361 for_each_cea_db(edid_ext, i, start, end) {
5362 const u8 *db = &edid_ext[i];
5364 if (cea_db_is_hdmi_vsdb(db))
5365 drm_parse_hdmi_vsdb_video(connector, db);
5366 if (cea_db_is_hdmi_forum_vsdb(db))
5367 drm_parse_hdmi_forum_vsdb(connector, db);
5368 if (cea_db_is_microsoft_vsdb(db))
5369 drm_parse_microsoft_vsdb(connector, db);
5370 if (cea_db_is_y420cmdb(db))
5371 drm_parse_y420cmdb_bitmap(connector, db);
5372 if (cea_db_is_vcdb(db))
5373 drm_parse_vcdb(connector, db);
5374 if (cea_db_is_hdmi_hdr_metadata_block(db))
5375 drm_parse_hdr_metadata_block(connector, db);
5380 void get_monitor_range(const struct detailed_timing *timing,
5381 void *info_monitor_range)
5383 struct drm_monitor_range_info *monitor_range = info_monitor_range;
5384 const struct detailed_non_pixel *data = &timing->data.other_data;
5385 const struct detailed_data_monitor_range *range = &data->data.range;
5387 if (!is_display_descriptor(timing, EDID_DETAIL_MONITOR_RANGE))
5391 * Check for flag range limits only. If flag == 1 then
5392 * no additional timing information provided.
5393 * Default GTF, GTF Secondary curve and CVT are not
5396 if (range->flags != DRM_EDID_RANGE_LIMITS_ONLY_FLAG)
5399 monitor_range->min_vfreq = range->min_vfreq;
5400 monitor_range->max_vfreq = range->max_vfreq;
5404 void drm_get_monitor_range(struct drm_connector *connector,
5405 const struct edid *edid)
5407 struct drm_display_info *info = &connector->display_info;
5409 if (!version_greater(edid, 1, 1))
5412 drm_for_each_detailed_block(edid, get_monitor_range,
5413 &info->monitor_range);
5415 DRM_DEBUG_KMS("Supported Monitor Refresh rate range is %d Hz - %d Hz\n",
5416 info->monitor_range.min_vfreq,
5417 info->monitor_range.max_vfreq);
5420 static void drm_parse_vesa_mso_data(struct drm_connector *connector,
5421 const struct displayid_block *block)
5423 struct displayid_vesa_vendor_specific_block *vesa =
5424 (struct displayid_vesa_vendor_specific_block *)block;
5425 struct drm_display_info *info = &connector->display_info;
5427 if (block->num_bytes < 3) {
5428 drm_dbg_kms(connector->dev, "Unexpected vendor block size %u\n",
5433 if (oui(vesa->oui[0], vesa->oui[1], vesa->oui[2]) != VESA_IEEE_OUI)
5436 if (sizeof(*vesa) != sizeof(*block) + block->num_bytes) {
5437 drm_dbg_kms(connector->dev, "Unexpected VESA vendor block size\n");
5441 switch (FIELD_GET(DISPLAYID_VESA_MSO_MODE, vesa->mso)) {
5443 drm_dbg_kms(connector->dev, "Reserved MSO mode value\n");
5446 info->mso_stream_count = 0;
5449 info->mso_stream_count = 2; /* 2 or 4 links */
5452 info->mso_stream_count = 4; /* 4 links */
5456 if (!info->mso_stream_count) {
5457 info->mso_pixel_overlap = 0;
5461 info->mso_pixel_overlap = FIELD_GET(DISPLAYID_VESA_MSO_OVERLAP, vesa->mso);
5462 if (info->mso_pixel_overlap > 8) {
5463 drm_dbg_kms(connector->dev, "Reserved MSO pixel overlap value %u\n",
5464 info->mso_pixel_overlap);
5465 info->mso_pixel_overlap = 8;
5468 drm_dbg_kms(connector->dev, "MSO stream count %u, pixel overlap %u\n",
5469 info->mso_stream_count, info->mso_pixel_overlap);
5472 static void drm_update_mso(struct drm_connector *connector, const struct edid *edid)
5474 const struct displayid_block *block;
5475 struct displayid_iter iter;
5477 displayid_iter_edid_begin(edid, &iter);
5478 displayid_iter_for_each(block, &iter) {
5479 if (block->tag == DATA_BLOCK_2_VENDOR_SPECIFIC)
5480 drm_parse_vesa_mso_data(connector, block);
5482 displayid_iter_end(&iter);
5485 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
5486 * all of the values which would have been set from EDID
5489 drm_reset_display_info(struct drm_connector *connector)
5491 struct drm_display_info *info = &connector->display_info;
5494 info->height_mm = 0;
5497 info->color_formats = 0;
5499 info->max_tmds_clock = 0;
5500 info->dvi_dual = false;
5501 info->is_hdmi = false;
5502 info->has_hdmi_infoframe = false;
5503 info->rgb_quant_range_selectable = false;
5504 memset(&info->hdmi, 0, sizeof(info->hdmi));
5506 info->edid_hdmi_rgb444_dc_modes = 0;
5507 info->edid_hdmi_ycbcr444_dc_modes = 0;
5509 info->non_desktop = 0;
5510 memset(&info->monitor_range, 0, sizeof(info->monitor_range));
5512 info->mso_stream_count = 0;
5513 info->mso_pixel_overlap = 0;
5516 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
5518 struct drm_display_info *info = &connector->display_info;
5520 u32 quirks = edid_get_quirks(edid);
5522 drm_reset_display_info(connector);
5524 info->width_mm = edid->width_cm * 10;
5525 info->height_mm = edid->height_cm * 10;
5527 drm_get_monitor_range(connector, edid);
5529 if (edid->revision < 3)
5532 if (!(edid->input & DRM_EDID_INPUT_DIGITAL))
5535 info->color_formats |= DRM_COLOR_FORMAT_RGB444;
5536 drm_parse_cea_ext(connector, edid);
5539 * Digital sink with "DFP 1.x compliant TMDS" according to EDID 1.3?
5541 * For such displays, the DFP spec 1.0, section 3.10 "EDID support"
5542 * tells us to assume 8 bpc color depth if the EDID doesn't have
5543 * extensions which tell otherwise.
5545 if (info->bpc == 0 && edid->revision == 3 &&
5546 edid->input & DRM_EDID_DIGITAL_DFP_1_X) {
5548 DRM_DEBUG("%s: Assigning DFP sink color depth as %d bpc.\n",
5549 connector->name, info->bpc);
5552 /* Only defined for 1.4 with digital displays */
5553 if (edid->revision < 4)
5556 switch (edid->input & DRM_EDID_DIGITAL_DEPTH_MASK) {
5557 case DRM_EDID_DIGITAL_DEPTH_6:
5560 case DRM_EDID_DIGITAL_DEPTH_8:
5563 case DRM_EDID_DIGITAL_DEPTH_10:
5566 case DRM_EDID_DIGITAL_DEPTH_12:
5569 case DRM_EDID_DIGITAL_DEPTH_14:
5572 case DRM_EDID_DIGITAL_DEPTH_16:
5575 case DRM_EDID_DIGITAL_DEPTH_UNDEF:
5581 DRM_DEBUG("%s: Assigning EDID-1.4 digital sink color depth as %d bpc.\n",
5582 connector->name, info->bpc);
5584 if (edid->features & DRM_EDID_FEATURE_RGB_YCRCB444)
5585 info->color_formats |= DRM_COLOR_FORMAT_YCBCR444;
5586 if (edid->features & DRM_EDID_FEATURE_RGB_YCRCB422)
5587 info->color_formats |= DRM_COLOR_FORMAT_YCBCR422;
5589 drm_update_mso(connector, edid);
5592 if (quirks & EDID_QUIRK_NON_DESKTOP) {
5593 drm_dbg_kms(connector->dev, "Non-desktop display%s\n",
5594 info->non_desktop ? " (redundant quirk)" : "");
5595 info->non_desktop = true;
5601 static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *dev,
5602 struct displayid_detailed_timings_1 *timings,
5605 struct drm_display_mode *mode;
5606 unsigned pixel_clock = (timings->pixel_clock[0] |
5607 (timings->pixel_clock[1] << 8) |
5608 (timings->pixel_clock[2] << 16)) + 1;
5609 unsigned hactive = (timings->hactive[0] | timings->hactive[1] << 8) + 1;
5610 unsigned hblank = (timings->hblank[0] | timings->hblank[1] << 8) + 1;
5611 unsigned hsync = (timings->hsync[0] | (timings->hsync[1] & 0x7f) << 8) + 1;
5612 unsigned hsync_width = (timings->hsw[0] | timings->hsw[1] << 8) + 1;
5613 unsigned vactive = (timings->vactive[0] | timings->vactive[1] << 8) + 1;
5614 unsigned vblank = (timings->vblank[0] | timings->vblank[1] << 8) + 1;
5615 unsigned vsync = (timings->vsync[0] | (timings->vsync[1] & 0x7f) << 8) + 1;
5616 unsigned vsync_width = (timings->vsw[0] | timings->vsw[1] << 8) + 1;
5617 bool hsync_positive = (timings->hsync[1] >> 7) & 0x1;
5618 bool vsync_positive = (timings->vsync[1] >> 7) & 0x1;
5620 mode = drm_mode_create(dev);
5624 /* resolution is kHz for type VII, and 10 kHz for type I */
5625 mode->clock = type_7 ? pixel_clock : pixel_clock * 10;
5626 mode->hdisplay = hactive;
5627 mode->hsync_start = mode->hdisplay + hsync;
5628 mode->hsync_end = mode->hsync_start + hsync_width;
5629 mode->htotal = mode->hdisplay + hblank;
5631 mode->vdisplay = vactive;
5632 mode->vsync_start = mode->vdisplay + vsync;
5633 mode->vsync_end = mode->vsync_start + vsync_width;
5634 mode->vtotal = mode->vdisplay + vblank;
5637 mode->flags |= hsync_positive ? DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
5638 mode->flags |= vsync_positive ? DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
5639 mode->type = DRM_MODE_TYPE_DRIVER;
5641 if (timings->flags & 0x80)
5642 mode->type |= DRM_MODE_TYPE_PREFERRED;
5643 drm_mode_set_name(mode);
5648 static int add_displayid_detailed_1_modes(struct drm_connector *connector,
5649 const struct displayid_block *block)
5651 struct displayid_detailed_timing_block *det = (struct displayid_detailed_timing_block *)block;
5654 struct drm_display_mode *newmode;
5656 bool type_7 = block->tag == DATA_BLOCK_2_TYPE_7_DETAILED_TIMING;
5657 /* blocks must be multiple of 20 bytes length */
5658 if (block->num_bytes % 20)
5661 num_timings = block->num_bytes / 20;
5662 for (i = 0; i < num_timings; i++) {
5663 struct displayid_detailed_timings_1 *timings = &det->timings[i];
5665 newmode = drm_mode_displayid_detailed(connector->dev, timings, type_7);
5669 drm_mode_probed_add(connector, newmode);
5675 static int add_displayid_detailed_modes(struct drm_connector *connector,
5676 const struct edid *edid)
5678 const struct displayid_block *block;
5679 struct displayid_iter iter;
5682 displayid_iter_edid_begin(edid, &iter);
5683 displayid_iter_for_each(block, &iter) {
5684 if (block->tag == DATA_BLOCK_TYPE_1_DETAILED_TIMING ||
5685 block->tag == DATA_BLOCK_2_TYPE_7_DETAILED_TIMING)
5686 num_modes += add_displayid_detailed_1_modes(connector, block);
5688 displayid_iter_end(&iter);
5693 static int drm_edid_connector_update(struct drm_connector *connector,
5694 const struct edid *edid)
5700 clear_eld(connector);
5704 drm_edid_to_eld(connector, edid);
5707 * CEA-861-F adds ycbcr capability map block, for HDMI 2.0 sinks.
5708 * To avoid multiple parsing of same block, lets parse that map
5709 * from sink info, before parsing CEA modes.
5711 quirks = drm_add_display_info(connector, edid);
5714 * EDID spec says modes should be preferred in this order:
5715 * - preferred detailed mode
5716 * - other detailed modes from base block
5717 * - detailed modes from extension blocks
5718 * - CVT 3-byte code modes
5719 * - standard timing codes
5720 * - established timing codes
5721 * - modes inferred from GTF or CVT range information
5723 * We get this pretty much right.
5725 * XXX order for additional mode types in extension blocks?
5727 num_modes += add_detailed_modes(connector, edid, quirks);
5728 num_modes += add_cvt_modes(connector, edid);
5729 num_modes += add_standard_modes(connector, edid);
5730 num_modes += add_established_modes(connector, edid);
5731 num_modes += add_cea_modes(connector, edid);
5732 num_modes += add_alternate_cea_modes(connector, edid);
5733 num_modes += add_displayid_detailed_modes(connector, edid);
5734 if (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF)
5735 num_modes += add_inferred_modes(connector, edid);
5737 if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
5738 edid_fixup_preferred(connector, quirks);
5740 if (quirks & EDID_QUIRK_FORCE_6BPC)
5741 connector->display_info.bpc = 6;
5743 if (quirks & EDID_QUIRK_FORCE_8BPC)
5744 connector->display_info.bpc = 8;
5746 if (quirks & EDID_QUIRK_FORCE_10BPC)
5747 connector->display_info.bpc = 10;
5749 if (quirks & EDID_QUIRK_FORCE_12BPC)
5750 connector->display_info.bpc = 12;
5756 * drm_add_edid_modes - add modes from EDID data, if available
5757 * @connector: connector we're probing
5760 * Add the specified modes to the connector's mode list. Also fills out the
5761 * &drm_display_info structure and ELD in @connector with any information which
5762 * can be derived from the edid.
5764 * Return: The number of modes added or 0 if we couldn't find any.
5766 int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
5768 if (edid && !drm_edid_is_valid(edid)) {
5769 drm_warn(connector->dev, "%s: EDID invalid.\n",
5774 return drm_edid_connector_update(connector, edid);
5776 EXPORT_SYMBOL(drm_add_edid_modes);
5779 * drm_add_modes_noedid - add modes for the connectors without EDID
5780 * @connector: connector we're probing
5781 * @hdisplay: the horizontal display limit
5782 * @vdisplay: the vertical display limit
5784 * Add the specified modes to the connector's mode list. Only when the
5785 * hdisplay/vdisplay is not beyond the given limit, it will be added.
5787 * Return: The number of modes added or 0 if we couldn't find any.
5789 int drm_add_modes_noedid(struct drm_connector *connector,
5790 int hdisplay, int vdisplay)
5792 int i, count, num_modes = 0;
5793 struct drm_display_mode *mode;
5794 struct drm_device *dev = connector->dev;
5796 count = ARRAY_SIZE(drm_dmt_modes);
5802 for (i = 0; i < count; i++) {
5803 const struct drm_display_mode *ptr = &drm_dmt_modes[i];
5805 if (hdisplay && vdisplay) {
5807 * Only when two are valid, they will be used to check
5808 * whether the mode should be added to the mode list of
5811 if (ptr->hdisplay > hdisplay ||
5812 ptr->vdisplay > vdisplay)
5815 if (drm_mode_vrefresh(ptr) > 61)
5817 mode = drm_mode_duplicate(dev, ptr);
5819 drm_mode_probed_add(connector, mode);
5825 EXPORT_SYMBOL(drm_add_modes_noedid);
5828 * drm_set_preferred_mode - Sets the preferred mode of a connector
5829 * @connector: connector whose mode list should be processed
5830 * @hpref: horizontal resolution of preferred mode
5831 * @vpref: vertical resolution of preferred mode
5833 * Marks a mode as preferred if it matches the resolution specified by @hpref
5836 void drm_set_preferred_mode(struct drm_connector *connector,
5837 int hpref, int vpref)
5839 struct drm_display_mode *mode;
5841 list_for_each_entry(mode, &connector->probed_modes, head) {
5842 if (mode->hdisplay == hpref &&
5843 mode->vdisplay == vpref)
5844 mode->type |= DRM_MODE_TYPE_PREFERRED;
5847 EXPORT_SYMBOL(drm_set_preferred_mode);
5849 static bool is_hdmi2_sink(const struct drm_connector *connector)
5852 * FIXME: sil-sii8620 doesn't have a connector around when
5853 * we need one, so we have to be prepared for a NULL connector.
5858 return connector->display_info.hdmi.scdc.supported ||
5859 connector->display_info.color_formats & DRM_COLOR_FORMAT_YCBCR420;
5862 static u8 drm_mode_hdmi_vic(const struct drm_connector *connector,
5863 const struct drm_display_mode *mode)
5865 bool has_hdmi_infoframe = connector ?
5866 connector->display_info.has_hdmi_infoframe : false;
5868 if (!has_hdmi_infoframe)
5871 /* No HDMI VIC when signalling 3D video format */
5872 if (mode->flags & DRM_MODE_FLAG_3D_MASK)
5875 return drm_match_hdmi_mode(mode);
5878 static u8 drm_mode_cea_vic(const struct drm_connector *connector,
5879 const struct drm_display_mode *mode)
5884 * HDMI spec says if a mode is found in HDMI 1.4b 4K modes
5885 * we should send its VIC in vendor infoframes, else send the
5886 * VIC in AVI infoframes. Lets check if this mode is present in
5887 * HDMI 1.4b 4K modes
5889 if (drm_mode_hdmi_vic(connector, mode))
5892 vic = drm_match_cea_mode(mode);
5895 * HDMI 1.4 VIC range: 1 <= VIC <= 64 (CEA-861-D) but
5896 * HDMI 2.0 VIC range: 1 <= VIC <= 107 (CEA-861-F). So we
5897 * have to make sure we dont break HDMI 1.4 sinks.
5899 if (!is_hdmi2_sink(connector) && vic > 64)
5906 * drm_hdmi_avi_infoframe_from_display_mode() - fill an HDMI AVI infoframe with
5907 * data from a DRM display mode
5908 * @frame: HDMI AVI infoframe
5909 * @connector: the connector
5910 * @mode: DRM display mode
5912 * Return: 0 on success or a negative error code on failure.
5915 drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
5916 const struct drm_connector *connector,
5917 const struct drm_display_mode *mode)
5919 enum hdmi_picture_aspect picture_aspect;
5922 if (!frame || !mode)
5925 hdmi_avi_infoframe_init(frame);
5927 if (mode->flags & DRM_MODE_FLAG_DBLCLK)
5928 frame->pixel_repeat = 1;
5930 vic = drm_mode_cea_vic(connector, mode);
5931 hdmi_vic = drm_mode_hdmi_vic(connector, mode);
5933 frame->picture_aspect = HDMI_PICTURE_ASPECT_NONE;
5936 * As some drivers don't support atomic, we can't use connector state.
5937 * So just initialize the frame with default values, just the same way
5938 * as it's done with other properties here.
5940 frame->content_type = HDMI_CONTENT_TYPE_GRAPHICS;
5944 * Populate picture aspect ratio from either
5945 * user input (if specified) or from the CEA/HDMI mode lists.
5947 picture_aspect = mode->picture_aspect_ratio;
5948 if (picture_aspect == HDMI_PICTURE_ASPECT_NONE) {
5950 picture_aspect = drm_get_cea_aspect_ratio(vic);
5952 picture_aspect = drm_get_hdmi_aspect_ratio(hdmi_vic);
5956 * The infoframe can't convey anything but none, 4:3
5957 * and 16:9, so if the user has asked for anything else
5958 * we can only satisfy it by specifying the right VIC.
5960 if (picture_aspect > HDMI_PICTURE_ASPECT_16_9) {
5962 if (picture_aspect != drm_get_cea_aspect_ratio(vic))
5964 } else if (hdmi_vic) {
5965 if (picture_aspect != drm_get_hdmi_aspect_ratio(hdmi_vic))
5971 picture_aspect = HDMI_PICTURE_ASPECT_NONE;
5974 frame->video_code = vic;
5975 frame->picture_aspect = picture_aspect;
5976 frame->active_aspect = HDMI_ACTIVE_ASPECT_PICTURE;
5977 frame->scan_mode = HDMI_SCAN_MODE_UNDERSCAN;
5981 EXPORT_SYMBOL(drm_hdmi_avi_infoframe_from_display_mode);
5984 * drm_hdmi_avi_infoframe_quant_range() - fill the HDMI AVI infoframe
5985 * quantization range information
5986 * @frame: HDMI AVI infoframe
5987 * @connector: the connector
5988 * @mode: DRM display mode
5989 * @rgb_quant_range: RGB quantization range (Q)
5992 drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
5993 const struct drm_connector *connector,
5994 const struct drm_display_mode *mode,
5995 enum hdmi_quantization_range rgb_quant_range)
5997 const struct drm_display_info *info = &connector->display_info;
6001 * "A Source shall not send a non-zero Q value that does not correspond
6002 * to the default RGB Quantization Range for the transmitted Picture
6003 * unless the Sink indicates support for the Q bit in a Video
6004 * Capabilities Data Block."
6006 * HDMI 2.0 recommends sending non-zero Q when it does match the
6007 * default RGB quantization range for the mode, even when QS=0.
6009 if (info->rgb_quant_range_selectable ||
6010 rgb_quant_range == drm_default_rgb_quant_range(mode))
6011 frame->quantization_range = rgb_quant_range;
6013 frame->quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT;
6017 * "When transmitting any RGB colorimetry, the Source should set the
6018 * YQ-field to match the RGB Quantization Range being transmitted
6019 * (e.g., when Limited Range RGB, set YQ=0 or when Full Range RGB,
6020 * set YQ=1) and the Sink shall ignore the YQ-field."
6022 * Unfortunate certain sinks (eg. VIZ Model 67/E261VA) get confused
6023 * by non-zero YQ when receiving RGB. There doesn't seem to be any
6024 * good way to tell which version of CEA-861 the sink supports, so
6025 * we limit non-zero YQ to HDMI 2.0 sinks only as HDMI 2.0 is based
6028 if (!is_hdmi2_sink(connector) ||
6029 rgb_quant_range == HDMI_QUANTIZATION_RANGE_LIMITED)
6030 frame->ycc_quantization_range =
6031 HDMI_YCC_QUANTIZATION_RANGE_LIMITED;
6033 frame->ycc_quantization_range =
6034 HDMI_YCC_QUANTIZATION_RANGE_FULL;
6036 EXPORT_SYMBOL(drm_hdmi_avi_infoframe_quant_range);
6038 static enum hdmi_3d_structure
6039 s3d_structure_from_display_mode(const struct drm_display_mode *mode)
6041 u32 layout = mode->flags & DRM_MODE_FLAG_3D_MASK;
6044 case DRM_MODE_FLAG_3D_FRAME_PACKING:
6045 return HDMI_3D_STRUCTURE_FRAME_PACKING;
6046 case DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE:
6047 return HDMI_3D_STRUCTURE_FIELD_ALTERNATIVE;
6048 case DRM_MODE_FLAG_3D_LINE_ALTERNATIVE:
6049 return HDMI_3D_STRUCTURE_LINE_ALTERNATIVE;
6050 case DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL:
6051 return HDMI_3D_STRUCTURE_SIDE_BY_SIDE_FULL;
6052 case DRM_MODE_FLAG_3D_L_DEPTH:
6053 return HDMI_3D_STRUCTURE_L_DEPTH;
6054 case DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH:
6055 return HDMI_3D_STRUCTURE_L_DEPTH_GFX_GFX_DEPTH;
6056 case DRM_MODE_FLAG_3D_TOP_AND_BOTTOM:
6057 return HDMI_3D_STRUCTURE_TOP_AND_BOTTOM;
6058 case DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF:
6059 return HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF;
6061 return HDMI_3D_STRUCTURE_INVALID;
6066 * drm_hdmi_vendor_infoframe_from_display_mode() - fill an HDMI infoframe with
6067 * data from a DRM display mode
6068 * @frame: HDMI vendor infoframe
6069 * @connector: the connector
6070 * @mode: DRM display mode
6072 * Note that there's is a need to send HDMI vendor infoframes only when using a
6073 * 4k or stereoscopic 3D mode. So when giving any other mode as input this
6074 * function will return -EINVAL, error that can be safely ignored.
6076 * Return: 0 on success or a negative error code on failure.
6079 drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
6080 const struct drm_connector *connector,
6081 const struct drm_display_mode *mode)
6084 * FIXME: sil-sii8620 doesn't have a connector around when
6085 * we need one, so we have to be prepared for a NULL connector.
6087 bool has_hdmi_infoframe = connector ?
6088 connector->display_info.has_hdmi_infoframe : false;
6091 if (!frame || !mode)
6094 if (!has_hdmi_infoframe)
6097 err = hdmi_vendor_infoframe_init(frame);
6102 * Even if it's not absolutely necessary to send the infoframe
6103 * (ie.vic==0 and s3d_struct==0) we will still send it if we
6104 * know that the sink can handle it. This is based on a
6105 * suggestion in HDMI 2.0 Appendix F. Apparently some sinks
6106 * have trouble realizing that they should switch from 3D to 2D
6107 * mode if the source simply stops sending the infoframe when
6108 * it wants to switch from 3D to 2D.
6110 frame->vic = drm_mode_hdmi_vic(connector, mode);
6111 frame->s3d_struct = s3d_structure_from_display_mode(mode);
6115 EXPORT_SYMBOL(drm_hdmi_vendor_infoframe_from_display_mode);
6117 static void drm_parse_tiled_block(struct drm_connector *connector,
6118 const struct displayid_block *block)
6120 const struct displayid_tiled_block *tile = (struct displayid_tiled_block *)block;
6122 u8 tile_v_loc, tile_h_loc;
6123 u8 num_v_tile, num_h_tile;
6124 struct drm_tile_group *tg;
6126 w = tile->tile_size[0] | tile->tile_size[1] << 8;
6127 h = tile->tile_size[2] | tile->tile_size[3] << 8;
6129 num_v_tile = (tile->topo[0] & 0xf) | (tile->topo[2] & 0x30);
6130 num_h_tile = (tile->topo[0] >> 4) | ((tile->topo[2] >> 2) & 0x30);
6131 tile_v_loc = (tile->topo[1] & 0xf) | ((tile->topo[2] & 0x3) << 4);
6132 tile_h_loc = (tile->topo[1] >> 4) | (((tile->topo[2] >> 2) & 0x3) << 4);
6134 connector->has_tile = true;
6135 if (tile->tile_cap & 0x80)
6136 connector->tile_is_single_monitor = true;
6138 connector->num_h_tile = num_h_tile + 1;
6139 connector->num_v_tile = num_v_tile + 1;
6140 connector->tile_h_loc = tile_h_loc;
6141 connector->tile_v_loc = tile_v_loc;
6142 connector->tile_h_size = w + 1;
6143 connector->tile_v_size = h + 1;
6145 DRM_DEBUG_KMS("tile cap 0x%x\n", tile->tile_cap);
6146 DRM_DEBUG_KMS("tile_size %d x %d\n", w + 1, h + 1);
6147 DRM_DEBUG_KMS("topo num tiles %dx%d, location %dx%d\n",
6148 num_h_tile + 1, num_v_tile + 1, tile_h_loc, tile_v_loc);
6149 DRM_DEBUG_KMS("vend %c%c%c\n", tile->topology_id[0], tile->topology_id[1], tile->topology_id[2]);
6151 tg = drm_mode_get_tile_group(connector->dev, tile->topology_id);
6153 tg = drm_mode_create_tile_group(connector->dev, tile->topology_id);
6157 if (connector->tile_group != tg) {
6158 /* if we haven't got a pointer,
6159 take the reference, drop ref to old tile group */
6160 if (connector->tile_group)
6161 drm_mode_put_tile_group(connector->dev, connector->tile_group);
6162 connector->tile_group = tg;
6164 /* if same tile group, then release the ref we just took. */
6165 drm_mode_put_tile_group(connector->dev, tg);
6169 void drm_update_tile_info(struct drm_connector *connector,
6170 const struct edid *edid)
6172 const struct displayid_block *block;
6173 struct displayid_iter iter;
6175 connector->has_tile = false;
6177 displayid_iter_edid_begin(edid, &iter);
6178 displayid_iter_for_each(block, &iter) {
6179 if (block->tag == DATA_BLOCK_TILED_DISPLAY)
6180 drm_parse_tiled_block(connector, block);
6182 displayid_iter_end(&iter);
6184 if (!connector->has_tile && connector->tile_group) {
6185 drm_mode_put_tile_group(connector->dev, connector->tile_group);
6186 connector->tile_group = NULL;