blob: 17ce135a18fda8329391f730ac247752e960bd33 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/drivers/video/fbmon.c
3 *
4 * Copyright (C) 2002 James Simmons <jsimmons@users.sf.net>
5 *
6 * Credits:
Andre Haupt8c85fd82008-02-06 01:39:10 -08007 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * The EDID Parser is a conglomeration from the following sources:
9 *
10 * 1. SciTech SNAP Graphics Architecture
11 * Copyright (C) 1991-2002 SciTech Software, Inc. All rights reserved.
12 *
13 * 2. XFree86 4.3.0, interpret_edid.c
14 * Copyright 1998 by Egbert Eich <Egbert.Eich@Physik.TU-Darmstadt.DE>
Andre Haupt8c85fd82008-02-06 01:39:10 -080015 *
16 * 3. John Fremlin <vii@users.sourceforge.net> and
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 * Ani Joshi <ajoshi@unixbox.com>
Andre Haupt8c85fd82008-02-06 01:39:10 -080018 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 * Generalized Timing Formula is derived from:
20 *
Andre Haupt8c85fd82008-02-06 01:39:10 -080021 * GTF Spreadsheet by Andy Morrish (1/5/97)
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 * available at http://www.vesa.org
23 *
24 * This file is subject to the terms and conditions of the GNU General Public
25 * License. See the file COPYING in the main directory of this archive
26 * for more details.
27 *
28 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/fb.h>
30#include <linux/module.h>
Adrian Bunk22f4a002006-06-26 00:26:28 -070031#include <linux/pci.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090032#include <linux/slab.h>
Antonino A. Daplas5e518d72005-09-09 13:04:34 -070033#include <video/edid.h>
Steffen Trumtrar2db54c72012-11-14 10:55:04 +010034#include <video/videomode.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#ifdef CONFIG_PPC_OF
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <asm/prom.h>
37#include <asm/pci-bridge.h>
38#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include "edid.h"
40
Andre Haupt8c85fd82008-02-06 01:39:10 -080041/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 * EDID parser
43 */
44
45#undef DEBUG /* define this for verbose EDID parsing output */
46
47#ifdef DEBUG
48#define DPRINTK(fmt, args...) printk(fmt,## args)
49#else
50#define DPRINTK(fmt, args...)
51#endif
52
Antonino A. Daplas33a9f642007-05-08 00:37:23 -070053#define FBMON_FIX_HEADER 1
54#define FBMON_FIX_INPUT 2
55#define FBMON_FIX_TIMINGS 3
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57#ifdef CONFIG_FB_MODE_HELPERS
58struct broken_edid {
59 u8 manufacturer[4];
60 u32 model;
61 u32 fix;
62};
63
Helge Dellerd95159c2006-12-08 02:40:28 -080064static const struct broken_edid brokendb[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 /* DEC FR-PCXAV-YZ */
66 {
67 .manufacturer = "DEC",
68 .model = 0x073a,
69 .fix = FBMON_FIX_HEADER,
70 },
71 /* ViewSonic PF775a */
72 {
73 .manufacturer = "VSC",
74 .model = 0x5a44,
75 .fix = FBMON_FIX_INPUT,
76 },
Antonino A. Daplas33a9f642007-05-08 00:37:23 -070077 /* Sharp UXGA? */
78 {
79 .manufacturer = "SHP",
80 .model = 0x138e,
81 .fix = FBMON_FIX_TIMINGS,
82 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070083};
84
85static const unsigned char edid_v1_header[] = { 0x00, 0xff, 0xff, 0xff,
86 0xff, 0xff, 0xff, 0x00
87};
88
89static void copy_string(unsigned char *c, unsigned char *s)
90{
91 int i;
92 c = c + 5;
93 for (i = 0; (i < 13 && *c != 0x0A); i++)
94 *(s++) = *(c++);
95 *s = 0;
96 while (i-- && (*--s == 0x20)) *s = 0;
97}
98
Antonino A. Daplas33a9f642007-05-08 00:37:23 -070099static int edid_is_serial_block(unsigned char *block)
100{
101 if ((block[0] == 0x00) && (block[1] == 0x00) &&
102 (block[2] == 0x00) && (block[3] == 0xff) &&
103 (block[4] == 0x00))
104 return 1;
105 else
106 return 0;
107}
108
109static int edid_is_ascii_block(unsigned char *block)
110{
111 if ((block[0] == 0x00) && (block[1] == 0x00) &&
112 (block[2] == 0x00) && (block[3] == 0xfe) &&
113 (block[4] == 0x00))
114 return 1;
115 else
116 return 0;
117}
118
119static int edid_is_limits_block(unsigned char *block)
120{
121 if ((block[0] == 0x00) && (block[1] == 0x00) &&
122 (block[2] == 0x00) && (block[3] == 0xfd) &&
123 (block[4] == 0x00))
124 return 1;
125 else
126 return 0;
127}
128
129static int edid_is_monitor_block(unsigned char *block)
130{
131 if ((block[0] == 0x00) && (block[1] == 0x00) &&
132 (block[2] == 0x00) && (block[3] == 0xfc) &&
133 (block[4] == 0x00))
134 return 1;
135 else
136 return 0;
137}
138
139static int edid_is_timing_block(unsigned char *block)
140{
141 if ((block[0] != 0x00) || (block[1] != 0x00) ||
142 (block[2] != 0x00) || (block[4] != 0x00))
143 return 1;
144 else
145 return 0;
146}
147
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148static int check_edid(unsigned char *edid)
149{
150 unsigned char *block = edid + ID_MANUFACTURER_NAME, manufacturer[4];
151 unsigned char *b;
152 u32 model;
153 int i, fix = 0, ret = 0;
154
155 manufacturer[0] = ((block[0] & 0x7c) >> 2) + '@';
156 manufacturer[1] = ((block[0] & 0x03) << 3) +
157 ((block[1] & 0xe0) >> 5) + '@';
158 manufacturer[2] = (block[1] & 0x1f) + '@';
159 manufacturer[3] = 0;
160 model = block[2] + (block[3] << 8);
161
162 for (i = 0; i < ARRAY_SIZE(brokendb); i++) {
163 if (!strncmp(manufacturer, brokendb[i].manufacturer, 4) &&
164 brokendb[i].model == model) {
Andre Haupt8c85fd82008-02-06 01:39:10 -0800165 fix = brokendb[i].fix;
166 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 }
168 }
169
170 switch (fix) {
171 case FBMON_FIX_HEADER:
172 for (i = 0; i < 8; i++) {
Antonino A. Daplas33a9f642007-05-08 00:37:23 -0700173 if (edid[i] != edid_v1_header[i]) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 ret = fix;
Antonino A. Daplas33a9f642007-05-08 00:37:23 -0700175 break;
176 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 }
178 break;
179 case FBMON_FIX_INPUT:
180 b = edid + EDID_STRUCT_DISPLAY;
181 /* Only if display is GTF capable will
182 the input type be reset to analog */
183 if (b[4] & 0x01 && b[0] & 0x80)
184 ret = fix;
185 break;
Antonino A. Daplas33a9f642007-05-08 00:37:23 -0700186 case FBMON_FIX_TIMINGS:
187 b = edid + DETAILED_TIMING_DESCRIPTIONS_START;
188 ret = fix;
189
190 for (i = 0; i < 4; i++) {
191 if (edid_is_limits_block(b)) {
192 ret = 0;
193 break;
194 }
195
196 b += DETAILED_TIMING_DESCRIPTION_SIZE;
197 }
198
199 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 }
201
Antonino A. Daplas33a9f642007-05-08 00:37:23 -0700202 if (ret)
203 printk("fbmon: The EDID Block of "
204 "Manufacturer: %s Model: 0x%x is known to "
205 "be broken,\n", manufacturer, model);
206
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 return ret;
208}
209
210static void fix_edid(unsigned char *edid, int fix)
211{
Antonino A. Daplas33a9f642007-05-08 00:37:23 -0700212 int i;
213 unsigned char *b, csum = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
215 switch (fix) {
216 case FBMON_FIX_HEADER:
217 printk("fbmon: trying a header reconstruct\n");
218 memcpy(edid, edid_v1_header, 8);
219 break;
220 case FBMON_FIX_INPUT:
221 printk("fbmon: trying to fix input type\n");
222 b = edid + EDID_STRUCT_DISPLAY;
223 b[0] &= ~0x80;
224 edid[127] += 0x80;
Antonino A. Daplas33a9f642007-05-08 00:37:23 -0700225 break;
226 case FBMON_FIX_TIMINGS:
227 printk("fbmon: trying to fix monitor timings\n");
228 b = edid + DETAILED_TIMING_DESCRIPTIONS_START;
229 for (i = 0; i < 4; i++) {
230 if (!(edid_is_serial_block(b) ||
231 edid_is_ascii_block(b) ||
232 edid_is_monitor_block(b) ||
233 edid_is_timing_block(b))) {
234 b[0] = 0x00;
235 b[1] = 0x00;
236 b[2] = 0x00;
237 b[3] = 0xfd;
238 b[4] = 0x00;
239 b[5] = 60; /* vfmin */
240 b[6] = 60; /* vfmax */
241 b[7] = 30; /* hfmin */
242 b[8] = 75; /* hfmax */
243 b[9] = 17; /* pixclock - 170 MHz*/
244 b[10] = 0; /* GTF */
245 break;
246 }
247
248 b += DETAILED_TIMING_DESCRIPTION_SIZE;
249 }
250
251 for (i = 0; i < EDID_LENGTH - 1; i++)
252 csum += edid[i];
253
254 edid[127] = 256 - csum;
255 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 }
257}
258
259static int edid_checksum(unsigned char *edid)
260{
Linus Torvalds37307932009-07-22 08:49:22 -0700261 unsigned char csum = 0, all_null = 0;
262 int i, err = 0, fix = check_edid(edid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263
264 if (fix)
265 fix_edid(edid, fix);
266
267 for (i = 0; i < EDID_LENGTH; i++) {
268 csum += edid[i];
269 all_null |= edid[i];
270 }
271
272 if (csum == 0x00 && all_null) {
273 /* checksum passed, everything's good */
274 err = 1;
275 }
276
277 return err;
278}
279
280static int edid_check_header(unsigned char *edid)
281{
282 int i, err = 1, fix = check_edid(edid);
283
284 if (fix)
285 fix_edid(edid, fix);
286
287 for (i = 0; i < 8; i++) {
288 if (edid[i] != edid_v1_header[i])
289 err = 0;
290 }
291
292 return err;
293}
294
295static void parse_vendor_block(unsigned char *block, struct fb_monspecs *specs)
296{
297 specs->manufacturer[0] = ((block[0] & 0x7c) >> 2) + '@';
298 specs->manufacturer[1] = ((block[0] & 0x03) << 3) +
299 ((block[1] & 0xe0) >> 5) + '@';
300 specs->manufacturer[2] = (block[1] & 0x1f) + '@';
301 specs->manufacturer[3] = 0;
302 specs->model = block[2] + (block[3] << 8);
303 specs->serial = block[4] + (block[5] << 8) +
304 (block[6] << 16) + (block[7] << 24);
305 specs->year = block[9] + 1990;
306 specs->week = block[8];
307 DPRINTK(" Manufacturer: %s\n", specs->manufacturer);
308 DPRINTK(" Model: %x\n", specs->model);
309 DPRINTK(" Serial#: %u\n", specs->serial);
310 DPRINTK(" Year: %u Week %u\n", specs->year, specs->week);
311}
312
313static void get_dpms_capabilities(unsigned char flags,
314 struct fb_monspecs *specs)
315{
316 specs->dpms = 0;
317 if (flags & DPMS_ACTIVE_OFF)
318 specs->dpms |= FB_DPMS_ACTIVE_OFF;
319 if (flags & DPMS_SUSPEND)
320 specs->dpms |= FB_DPMS_SUSPEND;
321 if (flags & DPMS_STANDBY)
322 specs->dpms |= FB_DPMS_STANDBY;
323 DPRINTK(" DPMS: Active %s, Suspend %s, Standby %s\n",
324 (flags & DPMS_ACTIVE_OFF) ? "yes" : "no",
325 (flags & DPMS_SUSPEND) ? "yes" : "no",
326 (flags & DPMS_STANDBY) ? "yes" : "no");
327}
Andre Haupt8c85fd82008-02-06 01:39:10 -0800328
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329static void get_chroma(unsigned char *block, struct fb_monspecs *specs)
330{
331 int tmp;
332
333 DPRINTK(" Chroma\n");
334 /* Chromaticity data */
335 tmp = ((block[5] & (3 << 6)) >> 6) | (block[0x7] << 2);
336 tmp *= 1000;
337 tmp += 512;
338 specs->chroma.redx = tmp/1024;
339 DPRINTK(" RedX: 0.%03d ", specs->chroma.redx);
340
341 tmp = ((block[5] & (3 << 4)) >> 4) | (block[0x8] << 2);
342 tmp *= 1000;
343 tmp += 512;
344 specs->chroma.redy = tmp/1024;
345 DPRINTK("RedY: 0.%03d\n", specs->chroma.redy);
346
347 tmp = ((block[5] & (3 << 2)) >> 2) | (block[0x9] << 2);
348 tmp *= 1000;
349 tmp += 512;
350 specs->chroma.greenx = tmp/1024;
351 DPRINTK(" GreenX: 0.%03d ", specs->chroma.greenx);
352
353 tmp = (block[5] & 3) | (block[0xa] << 2);
354 tmp *= 1000;
355 tmp += 512;
356 specs->chroma.greeny = tmp/1024;
357 DPRINTK("GreenY: 0.%03d\n", specs->chroma.greeny);
358
359 tmp = ((block[6] & (3 << 6)) >> 6) | (block[0xb] << 2);
360 tmp *= 1000;
361 tmp += 512;
362 specs->chroma.bluex = tmp/1024;
363 DPRINTK(" BlueX: 0.%03d ", specs->chroma.bluex);
364
365 tmp = ((block[6] & (3 << 4)) >> 4) | (block[0xc] << 2);
366 tmp *= 1000;
367 tmp += 512;
368 specs->chroma.bluey = tmp/1024;
369 DPRINTK("BlueY: 0.%03d\n", specs->chroma.bluey);
Andre Haupt8c85fd82008-02-06 01:39:10 -0800370
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 tmp = ((block[6] & (3 << 2)) >> 2) | (block[0xd] << 2);
372 tmp *= 1000;
373 tmp += 512;
374 specs->chroma.whitex = tmp/1024;
375 DPRINTK(" WhiteX: 0.%03d ", specs->chroma.whitex);
376
377 tmp = (block[6] & 3) | (block[0xe] << 2);
378 tmp *= 1000;
379 tmp += 512;
380 specs->chroma.whitey = tmp/1024;
381 DPRINTK("WhiteY: 0.%03d\n", specs->chroma.whitey);
382}
383
Antonino A. Daplas61ab7902005-09-09 13:10:02 -0700384static void calc_mode_timings(int xres, int yres, int refresh,
385 struct fb_videomode *mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386{
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -0800387 struct fb_var_screeninfo *var;
Andre Haupt8c85fd82008-02-06 01:39:10 -0800388
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -0800389 var = kzalloc(sizeof(struct fb_var_screeninfo), GFP_KERNEL);
390
391 if (var) {
392 var->xres = xres;
393 var->yres = yres;
394 fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON,
395 refresh, var, NULL);
396 mode->xres = xres;
397 mode->yres = yres;
398 mode->pixclock = var->pixclock;
399 mode->refresh = refresh;
400 mode->left_margin = var->left_margin;
401 mode->right_margin = var->right_margin;
402 mode->upper_margin = var->upper_margin;
403 mode->lower_margin = var->lower_margin;
404 mode->hsync_len = var->hsync_len;
405 mode->vsync_len = var->vsync_len;
406 mode->vmode = 0;
407 mode->sync = 0;
408 kfree(var);
409 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410}
411
412static int get_est_timing(unsigned char *block, struct fb_videomode *mode)
413{
414 int num = 0;
415 unsigned char c;
416
417 c = block[0];
418 if (c&0x80) {
419 calc_mode_timings(720, 400, 70, &mode[num]);
420 mode[num++].flag = FB_MODE_IS_CALCULATED;
421 DPRINTK(" 720x400@70Hz\n");
422 }
423 if (c&0x40) {
424 calc_mode_timings(720, 400, 88, &mode[num]);
425 mode[num++].flag = FB_MODE_IS_CALCULATED;
426 DPRINTK(" 720x400@88Hz\n");
427 }
428 if (c&0x20) {
429 mode[num++] = vesa_modes[3];
430 DPRINTK(" 640x480@60Hz\n");
431 }
432 if (c&0x10) {
433 calc_mode_timings(640, 480, 67, &mode[num]);
434 mode[num++].flag = FB_MODE_IS_CALCULATED;
435 DPRINTK(" 640x480@67Hz\n");
436 }
437 if (c&0x08) {
438 mode[num++] = vesa_modes[4];
439 DPRINTK(" 640x480@72Hz\n");
440 }
441 if (c&0x04) {
442 mode[num++] = vesa_modes[5];
443 DPRINTK(" 640x480@75Hz\n");
444 }
445 if (c&0x02) {
446 mode[num++] = vesa_modes[7];
447 DPRINTK(" 800x600@56Hz\n");
448 }
449 if (c&0x01) {
450 mode[num++] = vesa_modes[8];
451 DPRINTK(" 800x600@60Hz\n");
452 }
453
454 c = block[1];
455 if (c&0x80) {
Andre Haupt8c85fd82008-02-06 01:39:10 -0800456 mode[num++] = vesa_modes[9];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 DPRINTK(" 800x600@72Hz\n");
458 }
459 if (c&0x40) {
Andre Haupt8c85fd82008-02-06 01:39:10 -0800460 mode[num++] = vesa_modes[10];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 DPRINTK(" 800x600@75Hz\n");
462 }
463 if (c&0x20) {
464 calc_mode_timings(832, 624, 75, &mode[num]);
465 mode[num++].flag = FB_MODE_IS_CALCULATED;
466 DPRINTK(" 832x624@75Hz\n");
467 }
468 if (c&0x10) {
469 mode[num++] = vesa_modes[12];
470 DPRINTK(" 1024x768@87Hz Interlaced\n");
471 }
472 if (c&0x08) {
473 mode[num++] = vesa_modes[13];
474 DPRINTK(" 1024x768@60Hz\n");
475 }
476 if (c&0x04) {
477 mode[num++] = vesa_modes[14];
478 DPRINTK(" 1024x768@70Hz\n");
479 }
480 if (c&0x02) {
481 mode[num++] = vesa_modes[15];
482 DPRINTK(" 1024x768@75Hz\n");
483 }
484 if (c&0x01) {
485 mode[num++] = vesa_modes[21];
486 DPRINTK(" 1280x1024@75Hz\n");
487 }
488 c = block[2];
489 if (c&0x80) {
490 mode[num++] = vesa_modes[17];
491 DPRINTK(" 1152x870@75Hz\n");
492 }
493 DPRINTK(" Manufacturer's mask: %x\n",c&0x7F);
494 return num;
495}
496
Tomi Valkeinen43dcd132011-08-25 15:36:40 +0300497static int get_std_timing(unsigned char *block, struct fb_videomode *mode,
498 int ver, int rev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499{
500 int xres, yres = 0, refresh, ratio, i;
Andre Haupt8c85fd82008-02-06 01:39:10 -0800501
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 xres = (block[0] + 31) * 8;
503 if (xres <= 256)
504 return 0;
505
506 ratio = (block[1] & 0xc0) >> 6;
507 switch (ratio) {
508 case 0:
Tomi Valkeinen43dcd132011-08-25 15:36:40 +0300509 /* in EDID 1.3 the meaning of 0 changed to 16:10 (prior 1:1) */
510 if (ver < 1 || (ver == 1 && rev < 3))
511 yres = xres;
512 else
513 yres = (xres * 10)/16;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 break;
515 case 1:
516 yres = (xres * 3)/4;
517 break;
518 case 2:
519 yres = (xres * 4)/5;
520 break;
521 case 3:
522 yres = (xres * 9)/16;
523 break;
524 }
525 refresh = (block[1] & 0x3f) + 60;
526
527 DPRINTK(" %dx%d@%dHz\n", xres, yres, refresh);
528 for (i = 0; i < VESA_MODEDB_SIZE; i++) {
Andre Haupt8c85fd82008-02-06 01:39:10 -0800529 if (vesa_modes[i].xres == xres &&
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 vesa_modes[i].yres == yres &&
531 vesa_modes[i].refresh == refresh) {
532 *mode = vesa_modes[i];
533 mode->flag |= FB_MODE_IS_STANDARD;
534 return 1;
535 }
536 }
537 calc_mode_timings(xres, yres, refresh, mode);
538 return 1;
539}
540
541static int get_dst_timing(unsigned char *block,
Tomi Valkeinen43dcd132011-08-25 15:36:40 +0300542 struct fb_videomode *mode, int ver, int rev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543{
544 int j, num = 0;
545
Andre Haupt8c85fd82008-02-06 01:39:10 -0800546 for (j = 0; j < 6; j++, block += STD_TIMING_DESCRIPTION_SIZE)
Tomi Valkeinen43dcd132011-08-25 15:36:40 +0300547 num += get_std_timing(block, &mode[num], ver, rev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548
549 return num;
550}
551
Andre Haupt8c85fd82008-02-06 01:39:10 -0800552static void get_detailed_timing(unsigned char *block,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 struct fb_videomode *mode)
554{
555 mode->xres = H_ACTIVE;
556 mode->yres = V_ACTIVE;
557 mode->pixclock = PIXEL_CLOCK;
558 mode->pixclock /= 1000;
559 mode->pixclock = KHZ2PICOS(mode->pixclock);
560 mode->right_margin = H_SYNC_OFFSET;
561 mode->left_margin = (H_ACTIVE + H_BLANKING) -
562 (H_ACTIVE + H_SYNC_OFFSET + H_SYNC_WIDTH);
Andre Haupt8c85fd82008-02-06 01:39:10 -0800563 mode->upper_margin = V_BLANKING - V_SYNC_OFFSET -
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 V_SYNC_WIDTH;
565 mode->lower_margin = V_SYNC_OFFSET;
566 mode->hsync_len = H_SYNC_WIDTH;
567 mode->vsync_len = V_SYNC_WIDTH;
568 if (HSYNC_POSITIVE)
569 mode->sync |= FB_SYNC_HOR_HIGH_ACT;
570 if (VSYNC_POSITIVE)
571 mode->sync |= FB_SYNC_VERT_HIGH_ACT;
572 mode->refresh = PIXEL_CLOCK/((H_ACTIVE + H_BLANKING) *
573 (V_ACTIVE + V_BLANKING));
Jon Dufresne1a3b09d2008-10-15 22:03:49 -0700574 if (INTERLACED) {
575 mode->yres *= 2;
576 mode->upper_margin *= 2;
577 mode->lower_margin *= 2;
578 mode->vsync_len *= 2;
579 mode->vmode |= FB_VMODE_INTERLACED;
580 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 mode->flag = FB_MODE_IS_DETAILED;
582
583 DPRINTK(" %d MHz ", PIXEL_CLOCK/1000000);
584 DPRINTK("%d %d %d %d ", H_ACTIVE, H_ACTIVE + H_SYNC_OFFSET,
585 H_ACTIVE + H_SYNC_OFFSET + H_SYNC_WIDTH, H_ACTIVE + H_BLANKING);
586 DPRINTK("%d %d %d %d ", V_ACTIVE, V_ACTIVE + V_SYNC_OFFSET,
587 V_ACTIVE + V_SYNC_OFFSET + V_SYNC_WIDTH, V_ACTIVE + V_BLANKING);
588 DPRINTK("%sHSync %sVSync\n\n", (HSYNC_POSITIVE) ? "+" : "-",
589 (VSYNC_POSITIVE) ? "+" : "-");
590}
591
592/**
593 * fb_create_modedb - create video mode database
594 * @edid: EDID data
595 * @dbsize: database size
596 *
597 * RETURNS: struct fb_videomode, @dbsize contains length of database
598 *
599 * DESCRIPTION:
600 * This function builds a mode database using the contents of the EDID
601 * data
602 */
603static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize)
604{
605 struct fb_videomode *mode, *m;
606 unsigned char *block;
Geert Uytterhoeven5a258d02007-10-16 01:28:52 -0700607 int num = 0, i, first = 1;
Tomi Valkeinen43dcd132011-08-25 15:36:40 +0300608 int ver, rev;
609
610 ver = edid[EDID_STRUCT_VERSION];
611 rev = edid[EDID_STRUCT_REVISION];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612
Antonino A. Daplasdef1ede2006-01-09 20:53:45 -0800613 mode = kzalloc(50 * sizeof(struct fb_videomode), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 if (mode == NULL)
615 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616
Andre Haupt8c85fd82008-02-06 01:39:10 -0800617 if (edid == NULL || !edid_checksum(edid) ||
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 !edid_check_header(edid)) {
619 kfree(mode);
620 return NULL;
621 }
622
623 *dbsize = 0;
624
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 DPRINTK(" Detailed Timings\n");
626 block = edid + DETAILED_TIMING_DESCRIPTIONS_START;
627 for (i = 0; i < 4; i++, block+= DETAILED_TIMING_DESCRIPTION_SIZE) {
Antonino A. Daplas14c81022005-11-07 01:00:53 -0800628 if (!(block[0] == 0x00 && block[1] == 0x00)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 get_detailed_timing(block, &mode[num]);
630 if (first) {
631 mode[num].flag |= FB_MODE_IS_FIRST;
632 first = 0;
633 }
634 num++;
635 }
636 }
Antonino A. Daplas14c81022005-11-07 01:00:53 -0800637
638 DPRINTK(" Supported VESA Modes\n");
639 block = edid + ESTABLISHED_TIMING_1;
640 num += get_est_timing(block, &mode[num]);
641
642 DPRINTK(" Standard Timings\n");
643 block = edid + STD_TIMING_DESCRIPTIONS_START;
644 for (i = 0; i < STD_TIMING; i++, block += STD_TIMING_DESCRIPTION_SIZE)
Tomi Valkeinen43dcd132011-08-25 15:36:40 +0300645 num += get_std_timing(block, &mode[num], ver, rev);
Antonino A. Daplas14c81022005-11-07 01:00:53 -0800646
647 block = edid + DETAILED_TIMING_DESCRIPTIONS_START;
648 for (i = 0; i < 4; i++, block+= DETAILED_TIMING_DESCRIPTION_SIZE) {
649 if (block[0] == 0x00 && block[1] == 0x00 && block[3] == 0xfa)
Tomi Valkeinen43dcd132011-08-25 15:36:40 +0300650 num += get_dst_timing(block + 5, &mode[num], ver, rev);
Antonino A. Daplas14c81022005-11-07 01:00:53 -0800651 }
Andre Haupt8c85fd82008-02-06 01:39:10 -0800652
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 /* Yikes, EDID data is totally useless */
654 if (!num) {
655 kfree(mode);
656 return NULL;
657 }
658
659 *dbsize = num;
660 m = kmalloc(num * sizeof(struct fb_videomode), GFP_KERNEL);
661 if (!m)
662 return mode;
663 memmove(m, mode, num * sizeof(struct fb_videomode));
664 kfree(mode);
665 return m;
666}
667
668/**
669 * fb_destroy_modedb - destroys mode database
670 * @modedb: mode database to destroy
671 *
672 * DESCRIPTION:
673 * Destroy mode database created by fb_create_modedb
674 */
675void fb_destroy_modedb(struct fb_videomode *modedb)
676{
677 kfree(modedb);
678}
679
680static int fb_get_monitor_limits(unsigned char *edid, struct fb_monspecs *specs)
681{
682 int i, retval = 1;
683 unsigned char *block;
684
685 block = edid + DETAILED_TIMING_DESCRIPTIONS_START;
686
687 DPRINTK(" Monitor Operating Limits: ");
Antonino A. Daplas30076832006-06-26 00:26:29 -0700688
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 for (i = 0; i < 4; i++, block += DETAILED_TIMING_DESCRIPTION_SIZE) {
690 if (edid_is_limits_block(block)) {
691 specs->hfmin = H_MIN_RATE * 1000;
692 specs->hfmax = H_MAX_RATE * 1000;
693 specs->vfmin = V_MIN_RATE;
694 specs->vfmax = V_MAX_RATE;
695 specs->dclkmax = MAX_PIXEL_CLOCK * 1000000;
696 specs->gtf = (GTF_SUPPORT) ? 1 : 0;
697 retval = 0;
698 DPRINTK("From EDID\n");
699 break;
700 }
701 }
Antonino A. Daplas30076832006-06-26 00:26:29 -0700702
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 /* estimate monitor limits based on modes supported */
704 if (retval) {
Antonino A. Daplas30076832006-06-26 00:26:29 -0700705 struct fb_videomode *modes, *mode;
Andre Hauptcb850632008-02-06 01:39:09 -0800706 int num_modes, hz, hscan, pixclock;
Antonino A. Daplas30076832006-06-26 00:26:29 -0700707 int vtotal, htotal;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708
709 modes = fb_create_modedb(edid, &num_modes);
710 if (!modes) {
711 DPRINTK("None Available\n");
712 return 1;
713 }
714
715 retval = 0;
716 for (i = 0; i < num_modes; i++) {
Antonino A. Daplas30076832006-06-26 00:26:29 -0700717 mode = &modes[i];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 pixclock = PICOS2KHZ(modes[i].pixclock) * 1000;
Antonino A. Daplas30076832006-06-26 00:26:29 -0700719 htotal = mode->xres + mode->right_margin + mode->hsync_len
720 + mode->left_margin;
721 vtotal = mode->yres + mode->lower_margin + mode->vsync_len
722 + mode->upper_margin;
723
724 if (mode->vmode & FB_VMODE_INTERLACED)
725 vtotal /= 2;
726
727 if (mode->vmode & FB_VMODE_DOUBLE)
728 vtotal *= 2;
729
730 hscan = (pixclock + htotal / 2) / htotal;
731 hscan = (hscan + 500) / 1000 * 1000;
732 hz = (hscan + vtotal / 2) / vtotal;
Andre Haupt8c85fd82008-02-06 01:39:10 -0800733
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 if (specs->dclkmax == 0 || specs->dclkmax < pixclock)
735 specs->dclkmax = pixclock;
Antonino A. Daplas30076832006-06-26 00:26:29 -0700736
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 if (specs->dclkmin == 0 || specs->dclkmin > pixclock)
738 specs->dclkmin = pixclock;
Antonino A. Daplas30076832006-06-26 00:26:29 -0700739
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 if (specs->hfmax == 0 || specs->hfmax < hscan)
741 specs->hfmax = hscan;
Antonino A. Daplas30076832006-06-26 00:26:29 -0700742
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 if (specs->hfmin == 0 || specs->hfmin > hscan)
744 specs->hfmin = hscan;
Antonino A. Daplas30076832006-06-26 00:26:29 -0700745
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 if (specs->vfmax == 0 || specs->vfmax < hz)
747 specs->vfmax = hz;
Antonino A. Daplas30076832006-06-26 00:26:29 -0700748
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 if (specs->vfmin == 0 || specs->vfmin > hz)
750 specs->vfmin = hz;
751 }
752 DPRINTK("Extrapolated\n");
753 fb_destroy_modedb(modes);
754 }
755 DPRINTK(" H: %d-%dKHz V: %d-%dHz DCLK: %dMHz\n",
756 specs->hfmin/1000, specs->hfmax/1000, specs->vfmin,
757 specs->vfmax, specs->dclkmax/1000000);
758 return retval;
759}
760
761static void get_monspecs(unsigned char *edid, struct fb_monspecs *specs)
762{
763 unsigned char c, *block;
764
765 block = edid + EDID_STRUCT_DISPLAY;
766
767 fb_get_monitor_limits(edid, specs);
768
769 c = block[0] & 0x80;
770 specs->input = 0;
771 if (c) {
772 specs->input |= FB_DISP_DDI;
773 DPRINTK(" Digital Display Input");
774 } else {
775 DPRINTK(" Analog Display Input: Input Voltage - ");
776 switch ((block[0] & 0x60) >> 5) {
777 case 0:
778 DPRINTK("0.700V/0.300V");
779 specs->input |= FB_DISP_ANA_700_300;
780 break;
781 case 1:
782 DPRINTK("0.714V/0.286V");
783 specs->input |= FB_DISP_ANA_714_286;
784 break;
785 case 2:
786 DPRINTK("1.000V/0.400V");
787 specs->input |= FB_DISP_ANA_1000_400;
788 break;
789 case 3:
790 DPRINTK("0.700V/0.000V");
791 specs->input |= FB_DISP_ANA_700_000;
792 break;
793 }
794 }
795 DPRINTK("\n Sync: ");
796 c = block[0] & 0x10;
797 if (c)
798 DPRINTK(" Configurable signal level\n");
799 c = block[0] & 0x0f;
800 specs->signal = 0;
801 if (c & 0x10) {
802 DPRINTK("Blank to Blank ");
803 specs->signal |= FB_SIGNAL_BLANK_BLANK;
804 }
805 if (c & 0x08) {
806 DPRINTK("Separate ");
807 specs->signal |= FB_SIGNAL_SEPARATE;
808 }
809 if (c & 0x04) {
810 DPRINTK("Composite ");
811 specs->signal |= FB_SIGNAL_COMPOSITE;
812 }
813 if (c & 0x02) {
814 DPRINTK("Sync on Green ");
815 specs->signal |= FB_SIGNAL_SYNC_ON_GREEN;
816 }
817 if (c & 0x01) {
818 DPRINTK("Serration on ");
819 specs->signal |= FB_SIGNAL_SERRATION_ON;
820 }
821 DPRINTK("\n");
822 specs->max_x = block[1];
823 specs->max_y = block[2];
824 DPRINTK(" Max H-size in cm: ");
825 if (specs->max_x)
826 DPRINTK("%d\n", specs->max_x);
827 else
828 DPRINTK("variable\n");
829 DPRINTK(" Max V-size in cm: ");
830 if (specs->max_y)
831 DPRINTK("%d\n", specs->max_y);
832 else
833 DPRINTK("variable\n");
834
835 c = block[3];
836 specs->gamma = c+100;
837 DPRINTK(" Gamma: ");
838 DPRINTK("%d.%d\n", specs->gamma/100, specs->gamma % 100);
839
840 get_dpms_capabilities(block[4], specs);
841
842 switch ((block[4] & 0x18) >> 3) {
843 case 0:
844 DPRINTK(" Monochrome/Grayscale\n");
845 specs->input |= FB_DISP_MONO;
846 break;
847 case 1:
848 DPRINTK(" RGB Color Display\n");
849 specs->input |= FB_DISP_RGB;
850 break;
851 case 2:
852 DPRINTK(" Non-RGB Multicolor Display\n");
853 specs->input |= FB_DISP_MULTI;
854 break;
855 default:
856 DPRINTK(" Unknown\n");
857 specs->input |= FB_DISP_UNKNOWN;
858 break;
859 }
860
861 get_chroma(block, specs);
862
863 specs->misc = 0;
864 c = block[4] & 0x7;
865 if (c & 0x04) {
866 DPRINTK(" Default color format is primary\n");
867 specs->misc |= FB_MISC_PRIM_COLOR;
868 }
869 if (c & 0x02) {
870 DPRINTK(" First DETAILED Timing is preferred\n");
871 specs->misc |= FB_MISC_1ST_DETAIL;
872 }
873 if (c & 0x01) {
874 printk(" Display is GTF capable\n");
875 specs->gtf = 1;
876 }
877}
878
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var)
880{
881 int i;
882 unsigned char *block;
883
884 if (edid == NULL || var == NULL)
885 return 1;
886
887 if (!(edid_checksum(edid)))
888 return 1;
889
890 if (!(edid_check_header(edid)))
891 return 1;
892
893 block = edid + DETAILED_TIMING_DESCRIPTIONS_START;
894
895 for (i = 0; i < 4; i++, block += DETAILED_TIMING_DESCRIPTION_SIZE) {
896 if (edid_is_timing_block(block)) {
897 var->xres = var->xres_virtual = H_ACTIVE;
898 var->yres = var->yres_virtual = V_ACTIVE;
Ville Syrjala43a3abc2008-07-23 21:31:27 -0700899 var->height = var->width = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900 var->right_margin = H_SYNC_OFFSET;
901 var->left_margin = (H_ACTIVE + H_BLANKING) -
902 (H_ACTIVE + H_SYNC_OFFSET + H_SYNC_WIDTH);
903 var->upper_margin = V_BLANKING - V_SYNC_OFFSET -
904 V_SYNC_WIDTH;
905 var->lower_margin = V_SYNC_OFFSET;
906 var->hsync_len = H_SYNC_WIDTH;
907 var->vsync_len = V_SYNC_WIDTH;
908 var->pixclock = PIXEL_CLOCK;
909 var->pixclock /= 1000;
910 var->pixclock = KHZ2PICOS(var->pixclock);
911
912 if (HSYNC_POSITIVE)
913 var->sync |= FB_SYNC_HOR_HIGH_ACT;
914 if (VSYNC_POSITIVE)
915 var->sync |= FB_SYNC_VERT_HIGH_ACT;
916 return 0;
917 }
918 }
919 return 1;
920}
921
922void fb_edid_to_monspecs(unsigned char *edid, struct fb_monspecs *specs)
923{
924 unsigned char *block;
Antonino A. Daplas475666d2005-11-07 01:00:46 -0800925 int i, found = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700926
927 if (edid == NULL)
928 return;
929
930 if (!(edid_checksum(edid)))
931 return;
932
933 if (!(edid_check_header(edid)))
934 return;
935
936 memset(specs, 0, sizeof(struct fb_monspecs));
937
938 specs->version = edid[EDID_STRUCT_VERSION];
939 specs->revision = edid[EDID_STRUCT_REVISION];
940
941 DPRINTK("========================================\n");
942 DPRINTK("Display Information (EDID)\n");
943 DPRINTK("========================================\n");
944 DPRINTK(" EDID Version %d.%d\n", (int) specs->version,
945 (int) specs->revision);
946
947 parse_vendor_block(edid + ID_MANUFACTURER_NAME, specs);
948
949 block = edid + DETAILED_TIMING_DESCRIPTIONS_START;
950 for (i = 0; i < 4; i++, block += DETAILED_TIMING_DESCRIPTION_SIZE) {
951 if (edid_is_serial_block(block)) {
952 copy_string(block, specs->serial_no);
953 DPRINTK(" Serial Number: %s\n", specs->serial_no);
954 } else if (edid_is_ascii_block(block)) {
955 copy_string(block, specs->ascii);
956 DPRINTK(" ASCII Block: %s\n", specs->ascii);
957 } else if (edid_is_monitor_block(block)) {
958 copy_string(block, specs->monitor);
959 DPRINTK(" Monitor Name: %s\n", specs->monitor);
960 }
961 }
962
963 DPRINTK(" Display Characteristics:\n");
964 get_monspecs(edid, specs);
965
966 specs->modedb = fb_create_modedb(edid, &specs->modedb_len);
Antonino A. Daplas475666d2005-11-07 01:00:46 -0800967
968 /*
969 * Workaround for buggy EDIDs that sets that the first
970 * detailed timing is preferred but has not detailed
971 * timing specified
972 */
973 for (i = 0; i < specs->modedb_len; i++) {
974 if (specs->modedb[i].flag & FB_MODE_IS_DETAILED) {
975 found = 1;
976 break;
977 }
978 }
979
980 if (!found)
981 specs->misc &= ~FB_MISC_1ST_DETAIL;
982
Linus Torvalds1da177e2005-04-16 15:20:36 -0700983 DPRINTK("========================================\n");
984}
985
Guennadi Liakhovetskie4105112010-11-11 15:44:52 +0100986/**
987 * fb_edid_add_monspecs() - add monitor video modes from E-EDID data
988 * @edid: 128 byte array with an E-EDID block
989 * @spacs: monitor specs to be extended
990 */
Erik Gilling9fbbdde2010-11-11 15:44:43 +0100991void fb_edid_add_monspecs(unsigned char *edid, struct fb_monspecs *specs)
992{
993 unsigned char *block;
Guennadi Liakhovetskie4105112010-11-11 15:44:52 +0100994 struct fb_videomode *m;
995 int num = 0, i;
Guennadi Liakhovetski0ad83f62010-11-11 15:45:04 +0100996 u8 svd[64], edt[(128 - 4) / DETAILED_TIMING_DESCRIPTION_SIZE];
997 u8 pos = 4, svd_n = 0;
Erik Gilling9fbbdde2010-11-11 15:44:43 +0100998
Guennadi Liakhovetskie4105112010-11-11 15:44:52 +0100999 if (!edid)
Erik Gilling9fbbdde2010-11-11 15:44:43 +01001000 return;
1001
1002 if (!edid_checksum(edid))
1003 return;
1004
Guennadi Liakhovetskie4105112010-11-11 15:44:52 +01001005 if (edid[0] != 0x2 ||
1006 edid[2] < 4 || edid[2] > 128 - DETAILED_TIMING_DESCRIPTION_SIZE)
Erik Gilling9fbbdde2010-11-11 15:44:43 +01001007 return;
1008
Guennadi Liakhovetski0ad83f62010-11-11 15:45:04 +01001009 DPRINTK(" Short Video Descriptors\n");
1010
1011 while (pos < edid[2]) {
1012 u8 len = edid[pos] & 0x1f, type = (edid[pos] >> 5) & 7;
1013 pr_debug("Data block %u of %u bytes\n", type, len);
1014 if (type == 2)
1015 for (i = pos; i < pos + len; i++) {
1016 u8 idx = edid[pos + i] & 0x7f;
1017 svd[svd_n++] = idx;
1018 pr_debug("N%sative mode #%d\n",
1019 edid[pos + i] & 0x80 ? "" : "on-n", idx);
1020 }
1021 pos += len + 1;
1022 }
1023
Guennadi Liakhovetskie4105112010-11-11 15:44:52 +01001024 block = edid + edid[2];
Erik Gilling9fbbdde2010-11-11 15:44:43 +01001025
1026 DPRINTK(" Extended Detailed Timings\n");
1027
Guennadi Liakhovetskie4105112010-11-11 15:44:52 +01001028 for (i = 0; i < (128 - edid[2]) / DETAILED_TIMING_DESCRIPTION_SIZE;
1029 i++, block += DETAILED_TIMING_DESCRIPTION_SIZE)
1030 if (PIXEL_CLOCK)
1031 edt[num++] = block - edid;
Erik Gilling9fbbdde2010-11-11 15:44:43 +01001032
1033 /* Yikes, EDID data is totally useless */
Guennadi Liakhovetski0ad83f62010-11-11 15:45:04 +01001034 if (!(num + svd_n))
Erik Gilling9fbbdde2010-11-11 15:44:43 +01001035 return;
Erik Gilling9fbbdde2010-11-11 15:44:43 +01001036
Guennadi Liakhovetski0ad83f62010-11-11 15:45:04 +01001037 m = kzalloc((specs->modedb_len + num + svd_n) *
Erik Gilling9fbbdde2010-11-11 15:44:43 +01001038 sizeof(struct fb_videomode), GFP_KERNEL);
1039
Guennadi Liakhovetskie4105112010-11-11 15:44:52 +01001040 if (!m)
Erik Gilling9fbbdde2010-11-11 15:44:43 +01001041 return;
Guennadi Liakhovetskie4105112010-11-11 15:44:52 +01001042
1043 memcpy(m, specs->modedb, specs->modedb_len * sizeof(struct fb_videomode));
1044
1045 for (i = specs->modedb_len; i < specs->modedb_len + num; i++) {
1046 get_detailed_timing(edid + edt[i - specs->modedb_len], &m[i]);
1047 if (i == specs->modedb_len)
1048 m[i].flag |= FB_MODE_IS_FIRST;
1049 pr_debug("Adding %ux%u@%u\n", m[i].xres, m[i].yres, m[i].refresh);
Erik Gilling9fbbdde2010-11-11 15:44:43 +01001050 }
1051
Guennadi Liakhovetski0ad83f62010-11-11 15:45:04 +01001052 for (i = specs->modedb_len + num; i < specs->modedb_len + num + svd_n; i++) {
1053 int idx = svd[i - specs->modedb_len - num];
1054 if (!idx || idx > 63) {
1055 pr_warning("Reserved SVD code %d\n", idx);
1056 } else if (idx > ARRAY_SIZE(cea_modes) || !cea_modes[idx].xres) {
1057 pr_warning("Unimplemented SVD code %d\n", idx);
1058 } else {
1059 memcpy(&m[i], cea_modes + idx, sizeof(m[i]));
1060 pr_debug("Adding SVD #%d: %ux%u@%u\n", idx,
1061 m[i].xres, m[i].yres, m[i].refresh);
1062 }
1063 }
1064
Erik Gilling9fbbdde2010-11-11 15:44:43 +01001065 kfree(specs->modedb);
1066 specs->modedb = m;
Guennadi Liakhovetski0ad83f62010-11-11 15:45:04 +01001067 specs->modedb_len = specs->modedb_len + num + svd_n;
Erik Gilling9fbbdde2010-11-11 15:44:43 +01001068}
1069
Andre Haupt8c85fd82008-02-06 01:39:10 -08001070/*
1071 * VESA Generalized Timing Formula (GTF)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001072 */
1073
1074#define FLYBACK 550
1075#define V_FRONTPORCH 1
1076#define H_OFFSET 40
1077#define H_SCALEFACTOR 20
1078#define H_BLANKSCALE 128
1079#define H_GRADIENT 600
1080#define C_VAL 30
1081#define M_VAL 300
1082
1083struct __fb_timings {
1084 u32 dclk;
1085 u32 hfreq;
1086 u32 vfreq;
1087 u32 hactive;
1088 u32 vactive;
1089 u32 hblank;
1090 u32 vblank;
1091 u32 htotal;
1092 u32 vtotal;
1093};
1094
1095/**
1096 * fb_get_vblank - get vertical blank time
1097 * @hfreq: horizontal freq
1098 *
1099 * DESCRIPTION:
Andre Haupt8c85fd82008-02-06 01:39:10 -08001100 * vblank = right_margin + vsync_len + left_margin
Linus Torvalds1da177e2005-04-16 15:20:36 -07001101 *
1102 * given: right_margin = 1 (V_FRONTPORCH)
1103 * vsync_len = 3
1104 * flyback = 550
1105 *
1106 * flyback * hfreq
1107 * left_margin = --------------- - vsync_len
1108 * 1000000
1109 */
1110static u32 fb_get_vblank(u32 hfreq)
1111{
1112 u32 vblank;
1113
Andre Haupt8c85fd82008-02-06 01:39:10 -08001114 vblank = (hfreq * FLYBACK)/1000;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115 vblank = (vblank + 500)/1000;
1116 return (vblank + V_FRONTPORCH);
1117}
1118
Andre Haupt8c85fd82008-02-06 01:39:10 -08001119/**
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120 * fb_get_hblank_by_freq - get horizontal blank time given hfreq
1121 * @hfreq: horizontal freq
1122 * @xres: horizontal resolution in pixels
1123 *
1124 * DESCRIPTION:
1125 *
1126 * xres * duty_cycle
1127 * hblank = ------------------
1128 * 100 - duty_cycle
1129 *
1130 * duty cycle = percent of htotal assigned to inactive display
1131 * duty cycle = C - (M/Hfreq)
1132 *
1133 * where: C = ((offset - scale factor) * blank_scale)
1134 * -------------------------------------- + scale factor
Andre Haupt8c85fd82008-02-06 01:39:10 -08001135 * 256
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 * M = blank_scale * gradient
1137 *
1138 */
1139static u32 fb_get_hblank_by_hfreq(u32 hfreq, u32 xres)
1140{
1141 u32 c_val, m_val, duty_cycle, hblank;
1142
Andre Haupt8c85fd82008-02-06 01:39:10 -08001143 c_val = (((H_OFFSET - H_SCALEFACTOR) * H_BLANKSCALE)/256 +
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 H_SCALEFACTOR) * 1000;
1145 m_val = (H_BLANKSCALE * H_GRADIENT)/256;
1146 m_val = (m_val * 1000000)/hfreq;
1147 duty_cycle = c_val - m_val;
1148 hblank = (xres * duty_cycle)/(100000 - duty_cycle);
1149 return (hblank);
1150}
1151
Andre Haupt8c85fd82008-02-06 01:39:10 -08001152/**
Linus Torvalds1da177e2005-04-16 15:20:36 -07001153 * fb_get_hblank_by_dclk - get horizontal blank time given pixelclock
1154 * @dclk: pixelclock in Hz
1155 * @xres: horizontal resolution in pixels
1156 *
1157 * DESCRIPTION:
1158 *
1159 * xres * duty_cycle
1160 * hblank = ------------------
1161 * 100 - duty_cycle
1162 *
1163 * duty cycle = percent of htotal assigned to inactive display
1164 * duty cycle = C - (M * h_period)
Andre Haupt8c85fd82008-02-06 01:39:10 -08001165 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166 * where: h_period = SQRT(100 - C + (0.4 * xres * M)/dclk) + C - 100
1167 * -----------------------------------------------
1168 * 2 * M
1169 * M = 300;
1170 * C = 30;
1171
1172 */
1173static u32 fb_get_hblank_by_dclk(u32 dclk, u32 xres)
1174{
1175 u32 duty_cycle, h_period, hblank;
1176
1177 dclk /= 1000;
1178 h_period = 100 - C_VAL;
1179 h_period *= h_period;
1180 h_period += (M_VAL * xres * 2 * 1000)/(5 * dclk);
Andre Haupt8c85fd82008-02-06 01:39:10 -08001181 h_period *= 10000;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182
1183 h_period = int_sqrt(h_period);
1184 h_period -= (100 - C_VAL) * 100;
Andre Haupt8c85fd82008-02-06 01:39:10 -08001185 h_period *= 1000;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001186 h_period /= 2 * M_VAL;
1187
1188 duty_cycle = C_VAL * 1000 - (M_VAL * h_period)/100;
1189 hblank = (xres * duty_cycle)/(100000 - duty_cycle) + 8;
1190 hblank &= ~15;
1191 return (hblank);
1192}
Andre Haupt8c85fd82008-02-06 01:39:10 -08001193
Linus Torvalds1da177e2005-04-16 15:20:36 -07001194/**
1195 * fb_get_hfreq - estimate hsync
1196 * @vfreq: vertical refresh rate
1197 * @yres: vertical resolution
1198 *
1199 * DESCRIPTION:
1200 *
1201 * (yres + front_port) * vfreq * 1000000
1202 * hfreq = -------------------------------------
1203 * (1000000 - (vfreq * FLYBACK)
Andre Haupt8c85fd82008-02-06 01:39:10 -08001204 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001205 */
1206
1207static u32 fb_get_hfreq(u32 vfreq, u32 yres)
1208{
1209 u32 divisor, hfreq;
Andre Haupt8c85fd82008-02-06 01:39:10 -08001210
Linus Torvalds1da177e2005-04-16 15:20:36 -07001211 divisor = (1000000 - (vfreq * FLYBACK))/1000;
1212 hfreq = (yres + V_FRONTPORCH) * vfreq * 1000;
1213 return (hfreq/divisor);
1214}
1215
1216static void fb_timings_vfreq(struct __fb_timings *timings)
1217{
1218 timings->hfreq = fb_get_hfreq(timings->vfreq, timings->vactive);
1219 timings->vblank = fb_get_vblank(timings->hfreq);
1220 timings->vtotal = timings->vactive + timings->vblank;
Andre Haupt8c85fd82008-02-06 01:39:10 -08001221 timings->hblank = fb_get_hblank_by_hfreq(timings->hfreq,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001222 timings->hactive);
1223 timings->htotal = timings->hactive + timings->hblank;
1224 timings->dclk = timings->htotal * timings->hfreq;
1225}
1226
1227static void fb_timings_hfreq(struct __fb_timings *timings)
1228{
1229 timings->vblank = fb_get_vblank(timings->hfreq);
1230 timings->vtotal = timings->vactive + timings->vblank;
1231 timings->vfreq = timings->hfreq/timings->vtotal;
Andre Haupt8c85fd82008-02-06 01:39:10 -08001232 timings->hblank = fb_get_hblank_by_hfreq(timings->hfreq,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001233 timings->hactive);
1234 timings->htotal = timings->hactive + timings->hblank;
1235 timings->dclk = timings->htotal * timings->hfreq;
1236}
1237
1238static void fb_timings_dclk(struct __fb_timings *timings)
1239{
Andre Haupt8c85fd82008-02-06 01:39:10 -08001240 timings->hblank = fb_get_hblank_by_dclk(timings->dclk,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241 timings->hactive);
1242 timings->htotal = timings->hactive + timings->hblank;
1243 timings->hfreq = timings->dclk/timings->htotal;
1244 timings->vblank = fb_get_vblank(timings->hfreq);
1245 timings->vtotal = timings->vactive + timings->vblank;
1246 timings->vfreq = timings->hfreq/timings->vtotal;
1247}
1248
1249/*
1250 * fb_get_mode - calculates video mode using VESA GTF
1251 * @flags: if: 0 - maximize vertical refresh rate
1252 * 1 - vrefresh-driven calculation;
1253 * 2 - hscan-driven calculation;
1254 * 3 - pixelclock-driven calculation;
1255 * @val: depending on @flags, ignored, vrefresh, hsync or pixelclock
1256 * @var: pointer to fb_var_screeninfo
1257 * @info: pointer to fb_info
1258 *
1259 * DESCRIPTION:
Andre Haupt8c85fd82008-02-06 01:39:10 -08001260 * Calculates video mode based on monitor specs using VESA GTF.
1261 * The GTF is best for VESA GTF compliant monitors but is
Linus Torvalds1da177e2005-04-16 15:20:36 -07001262 * specifically formulated to work for older monitors as well.
1263 *
Andre Haupt8c85fd82008-02-06 01:39:10 -08001264 * If @flag==0, the function will attempt to maximize the
Linus Torvalds1da177e2005-04-16 15:20:36 -07001265 * refresh rate. Otherwise, it will calculate timings based on
Andre Haupt8c85fd82008-02-06 01:39:10 -08001266 * the flag and accompanying value.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001267 *
Andre Haupt8c85fd82008-02-06 01:39:10 -08001268 * If FB_IGNOREMON bit is set in @flags, monitor specs will be
Linus Torvalds1da177e2005-04-16 15:20:36 -07001269 * ignored and @var will be filled with the calculated timings.
1270 *
1271 * All calculations are based on the VESA GTF Spreadsheet
1272 * available at VESA's public ftp (http://www.vesa.org).
Andre Haupt8c85fd82008-02-06 01:39:10 -08001273 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001274 * NOTES:
1275 * The timings generated by the GTF will be different from VESA
1276 * DMT. It might be a good idea to keep a table of standard
1277 * VESA modes as well. The GTF may also not work for some displays,
1278 * such as, and especially, analog TV.
Andre Haupt8c85fd82008-02-06 01:39:10 -08001279 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 * REQUIRES:
1281 * A valid info->monspecs, otherwise 'safe numbers' will be used.
Andre Haupt8c85fd82008-02-06 01:39:10 -08001282 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001283int fb_get_mode(int flags, u32 val, struct fb_var_screeninfo *var, struct fb_info *info)
1284{
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -08001285 struct __fb_timings *timings;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001286 u32 interlace = 1, dscan = 1;
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -08001287 u32 hfmin, hfmax, vfmin, vfmax, dclkmin, dclkmax, err = 0;
1288
1289
1290 timings = kzalloc(sizeof(struct __fb_timings), GFP_KERNEL);
1291
1292 if (!timings)
1293 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294
Andre Haupt8c85fd82008-02-06 01:39:10 -08001295 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -07001296 * If monspecs are invalid, use values that are enough
1297 * for 640x480@60
1298 */
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -08001299 if (!info || !info->monspecs.hfmax || !info->monspecs.vfmax ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300 !info->monspecs.dclkmax ||
1301 info->monspecs.hfmax < info->monspecs.hfmin ||
1302 info->monspecs.vfmax < info->monspecs.vfmin ||
1303 info->monspecs.dclkmax < info->monspecs.dclkmin) {
1304 hfmin = 29000; hfmax = 30000;
1305 vfmin = 60; vfmax = 60;
1306 dclkmin = 0; dclkmax = 25000000;
1307 } else {
1308 hfmin = info->monspecs.hfmin;
1309 hfmax = info->monspecs.hfmax;
1310 vfmin = info->monspecs.vfmin;
1311 vfmax = info->monspecs.vfmax;
1312 dclkmin = info->monspecs.dclkmin;
1313 dclkmax = info->monspecs.dclkmax;
1314 }
1315
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -08001316 timings->hactive = var->xres;
1317 timings->vactive = var->yres;
Andre Haupt8c85fd82008-02-06 01:39:10 -08001318 if (var->vmode & FB_VMODE_INTERLACED) {
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -08001319 timings->vactive /= 2;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320 interlace = 2;
1321 }
1322 if (var->vmode & FB_VMODE_DOUBLE) {
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -08001323 timings->vactive *= 2;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001324 dscan = 2;
1325 }
1326
1327 switch (flags & ~FB_IGNOREMON) {
1328 case FB_MAXTIMINGS: /* maximize refresh rate */
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -08001329 timings->hfreq = hfmax;
1330 fb_timings_hfreq(timings);
1331 if (timings->vfreq > vfmax) {
1332 timings->vfreq = vfmax;
1333 fb_timings_vfreq(timings);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001334 }
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -08001335 if (timings->dclk > dclkmax) {
1336 timings->dclk = dclkmax;
1337 fb_timings_dclk(timings);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001338 }
1339 break;
1340 case FB_VSYNCTIMINGS: /* vrefresh driven */
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -08001341 timings->vfreq = val;
1342 fb_timings_vfreq(timings);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001343 break;
1344 case FB_HSYNCTIMINGS: /* hsync driven */
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -08001345 timings->hfreq = val;
1346 fb_timings_hfreq(timings);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001347 break;
1348 case FB_DCLKTIMINGS: /* pixelclock driven */
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -08001349 timings->dclk = PICOS2KHZ(val) * 1000;
1350 fb_timings_dclk(timings);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001351 break;
1352 default:
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -08001353 err = -EINVAL;
Andre Haupt8c85fd82008-02-06 01:39:10 -08001354
1355 }
1356
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -08001357 if (err || (!(flags & FB_IGNOREMON) &&
1358 (timings->vfreq < vfmin || timings->vfreq > vfmax ||
1359 timings->hfreq < hfmin || timings->hfreq > hfmax ||
1360 timings->dclk < dclkmin || timings->dclk > dclkmax))) {
1361 err = -EINVAL;
1362 } else {
1363 var->pixclock = KHZ2PICOS(timings->dclk/1000);
1364 var->hsync_len = (timings->htotal * 8)/100;
1365 var->right_margin = (timings->hblank/2) - var->hsync_len;
1366 var->left_margin = timings->hblank - var->right_margin -
1367 var->hsync_len;
1368 var->vsync_len = (3 * interlace)/dscan;
1369 var->lower_margin = (1 * interlace)/dscan;
1370 var->upper_margin = (timings->vblank * interlace)/dscan -
1371 (var->vsync_len + var->lower_margin);
1372 }
Andre Haupt8c85fd82008-02-06 01:39:10 -08001373
Antonino A. Daplasaf5d0f72006-01-09 20:53:38 -08001374 kfree(timings);
1375 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001376}
Steffen Trumtrar2db54c72012-11-14 10:55:04 +01001377
1378#if IS_ENABLED(CONFIG_VIDEOMODE)
1379int fb_videomode_from_videomode(const struct videomode *vm,
1380 struct fb_videomode *fbmode)
1381{
1382 unsigned int htotal, vtotal;
1383
1384 fbmode->xres = vm->hactive;
1385 fbmode->left_margin = vm->hback_porch;
1386 fbmode->right_margin = vm->hfront_porch;
1387 fbmode->hsync_len = vm->hsync_len;
1388
1389 fbmode->yres = vm->vactive;
1390 fbmode->upper_margin = vm->vback_porch;
1391 fbmode->lower_margin = vm->vfront_porch;
1392 fbmode->vsync_len = vm->vsync_len;
1393
1394 /* prevent division by zero in KHZ2PICOS macro */
1395 fbmode->pixclock = vm->pixelclock ?
1396 KHZ2PICOS(vm->pixelclock / 1000) : 0;
1397
1398 fbmode->sync = 0;
1399 fbmode->vmode = 0;
1400 if (vm->dmt_flags & VESA_DMT_HSYNC_HIGH)
1401 fbmode->sync |= FB_SYNC_HOR_HIGH_ACT;
1402 if (vm->dmt_flags & VESA_DMT_HSYNC_HIGH)
1403 fbmode->sync |= FB_SYNC_VERT_HIGH_ACT;
1404 if (vm->data_flags & DISPLAY_FLAGS_INTERLACED)
1405 fbmode->vmode |= FB_VMODE_INTERLACED;
1406 if (vm->data_flags & DISPLAY_FLAGS_DOUBLESCAN)
1407 fbmode->vmode |= FB_VMODE_DOUBLE;
1408 fbmode->flag = 0;
1409
1410 htotal = vm->hactive + vm->hfront_porch + vm->hback_porch +
1411 vm->hsync_len;
1412 vtotal = vm->vactive + vm->vfront_porch + vm->vback_porch +
1413 vm->vsync_len;
1414 /* prevent division by zero */
1415 if (htotal && vtotal) {
1416 fbmode->refresh = vm->pixelclock / (htotal * vtotal);
1417 /* a mode must have htotal and vtotal != 0 or it is invalid */
1418 } else {
1419 fbmode->refresh = 0;
1420 return -EINVAL;
1421 }
1422
1423 return 0;
1424}
1425EXPORT_SYMBOL_GPL(fb_videomode_from_videomode);
1426#endif
1427
Linus Torvalds1da177e2005-04-16 15:20:36 -07001428#else
1429int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var)
1430{
1431 return 1;
1432}
1433void fb_edid_to_monspecs(unsigned char *edid, struct fb_monspecs *specs)
1434{
1435 specs = NULL;
1436}
Guennadi Liakhovetskie4105112010-11-11 15:44:52 +01001437void fb_edid_add_monspecs(unsigned char *edid, struct fb_monspecs *specs)
1438{
1439}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001440void fb_destroy_modedb(struct fb_videomode *modedb)
1441{
1442}
1443int fb_get_mode(int flags, u32 val, struct fb_var_screeninfo *var,
1444 struct fb_info *info)
1445{
1446 return -EINVAL;
1447}
1448#endif /* CONFIG_FB_MODE_HELPERS */
Andre Haupt8c85fd82008-02-06 01:39:10 -08001449
Linus Torvalds1da177e2005-04-16 15:20:36 -07001450/*
1451 * fb_validate_mode - validates var against monitor capabilities
1452 * @var: pointer to fb_var_screeninfo
1453 * @info: pointer to fb_info
1454 *
1455 * DESCRIPTION:
1456 * Validates video mode against monitor capabilities specified in
1457 * info->monspecs.
1458 *
1459 * REQUIRES:
1460 * A valid info->monspecs.
1461 */
1462int fb_validate_mode(const struct fb_var_screeninfo *var, struct fb_info *info)
1463{
1464 u32 hfreq, vfreq, htotal, vtotal, pixclock;
1465 u32 hfmin, hfmax, vfmin, vfmax, dclkmin, dclkmax;
1466
Andre Haupt8c85fd82008-02-06 01:39:10 -08001467 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -07001468 * If monspecs are invalid, use values that are enough
1469 * for 640x480@60
1470 */
1471 if (!info->monspecs.hfmax || !info->monspecs.vfmax ||
1472 !info->monspecs.dclkmax ||
1473 info->monspecs.hfmax < info->monspecs.hfmin ||
1474 info->monspecs.vfmax < info->monspecs.vfmin ||
1475 info->monspecs.dclkmax < info->monspecs.dclkmin) {
1476 hfmin = 29000; hfmax = 30000;
1477 vfmin = 60; vfmax = 60;
1478 dclkmin = 0; dclkmax = 25000000;
1479 } else {
1480 hfmin = info->monspecs.hfmin;
1481 hfmax = info->monspecs.hfmax;
1482 vfmin = info->monspecs.vfmin;
1483 vfmax = info->monspecs.vfmax;
1484 dclkmin = info->monspecs.dclkmin;
1485 dclkmax = info->monspecs.dclkmax;
1486 }
1487
1488 if (!var->pixclock)
1489 return -EINVAL;
1490 pixclock = PICOS2KHZ(var->pixclock) * 1000;
Andre Haupt8c85fd82008-02-06 01:39:10 -08001491
1492 htotal = var->xres + var->right_margin + var->hsync_len +
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493 var->left_margin;
Andre Haupt8c85fd82008-02-06 01:39:10 -08001494 vtotal = var->yres + var->lower_margin + var->vsync_len +
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 var->upper_margin;
1496
1497 if (var->vmode & FB_VMODE_INTERLACED)
1498 vtotal /= 2;
1499 if (var->vmode & FB_VMODE_DOUBLE)
1500 vtotal *= 2;
1501
1502 hfreq = pixclock/htotal;
Jon Smirl0a793b72005-07-27 11:46:03 -07001503 hfreq = (hfreq + 500) / 1000 * 1000;
1504
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505 vfreq = hfreq/vtotal;
1506
Andre Haupt8c85fd82008-02-06 01:39:10 -08001507 return (vfreq < vfmin || vfreq > vfmax ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07001508 hfreq < hfmin || hfreq > hfmax ||
1509 pixclock < dclkmin || pixclock > dclkmax) ?
1510 -EINVAL : 0;
1511}
1512
Antonino A. Daplasba707102006-06-26 00:26:37 -07001513#if defined(CONFIG_FIRMWARE_EDID) && defined(CONFIG_X86)
Antonino A. Daplas5e518d72005-09-09 13:04:34 -07001514
1515/*
1516 * We need to ensure that the EDID block is only returned for
1517 * the primary graphics adapter.
1518 */
1519
1520const unsigned char *fb_firmware_edid(struct device *device)
1521{
1522 struct pci_dev *dev = NULL;
1523 struct resource *res = NULL;
1524 unsigned char *edid = NULL;
1525
1526 if (device)
1527 dev = to_pci_dev(device);
1528
1529 if (dev)
1530 res = &dev->resource[PCI_ROM_RESOURCE];
1531
1532 if (res && res->flags & IORESOURCE_ROM_SHADOW)
1533 edid = edid_info.dummy;
1534
1535 return edid;
1536}
1537#else
1538const unsigned char *fb_firmware_edid(struct device *device)
1539{
1540 return NULL;
1541}
Antonino A. Daplas59153f72006-03-27 01:17:29 -08001542#endif
1543EXPORT_SYMBOL(fb_firmware_edid);
Antonino A. Daplas5e518d72005-09-09 13:04:34 -07001544
Linus Torvalds1da177e2005-04-16 15:20:36 -07001545EXPORT_SYMBOL(fb_parse_edid);
1546EXPORT_SYMBOL(fb_edid_to_monspecs);
Guennadi Liakhovetskie4105112010-11-11 15:44:52 +01001547EXPORT_SYMBOL(fb_edid_add_monspecs);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001548EXPORT_SYMBOL(fb_get_mode);
1549EXPORT_SYMBOL(fb_validate_mode);
1550EXPORT_SYMBOL(fb_destroy_modedb);