aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/via/dvi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/via/dvi.c')
-rw-r--r--drivers/video/via/dvi.c233
1 files changed, 63 insertions, 170 deletions
diff --git a/drivers/video/via/dvi.c b/drivers/video/via/dvi.c
index 67b36932212b..abe59b8c7a05 100644
--- a/drivers/video/via/dvi.c
+++ b/drivers/video/via/dvi.c
@@ -23,11 +23,10 @@
23static void tmds_register_write(int index, u8 data); 23static void tmds_register_write(int index, u8 data);
24static int tmds_register_read(int index); 24static int tmds_register_read(int index);
25static int tmds_register_read_bytes(int index, u8 *buff, int buff_len); 25static int tmds_register_read_bytes(int index, u8 *buff, int buff_len);
26static int check_reduce_blanking_mode(int mode_index, 26static void dvi_get_panel_size_from_DDCv1(struct tmds_chip_information
27 int refresh_rate); 27 *tmds_chip, struct tmds_setting_information *tmds_setting);
28static int dvi_get_panel_size_from_DDCv1(void); 28static void dvi_get_panel_size_from_DDCv2(struct tmds_chip_information
29static int dvi_get_panel_size_from_DDCv2(void); 29 *tmds_chip, struct tmds_setting_information *tmds_setting);
30static unsigned char dvi_get_panel_info(void);
31static int viafb_dvi_query_EDID(void); 30static int viafb_dvi_query_EDID(void);
32 31
33static int check_tmds_chip(int device_id_subaddr, int device_id) 32static int check_tmds_chip(int device_id_subaddr, int device_id)
@@ -38,23 +37,24 @@ static int check_tmds_chip(int device_id_subaddr, int device_id)
38 return FAIL; 37 return FAIL;
39} 38}
40 39
41void viafb_init_dvi_size(void) 40void viafb_init_dvi_size(struct tmds_chip_information *tmds_chip,
41 struct tmds_setting_information *tmds_setting)
42{ 42{
43 DEBUG_MSG(KERN_INFO "viafb_init_dvi_size()\n"); 43 DEBUG_MSG(KERN_INFO "viafb_init_dvi_size()\n");
44 DEBUG_MSG(KERN_INFO
45 "viaparinfo->tmds_setting_info->get_dvi_size_method %d\n",
46 viaparinfo->tmds_setting_info->get_dvi_size_method);
47 44
48 switch (viaparinfo->tmds_setting_info->get_dvi_size_method) { 45 viafb_dvi_sense();
49 case GET_DVI_SIZE_BY_SYSTEM_BIOS: 46 switch (viafb_dvi_query_EDID()) {
47 case 1:
48 dvi_get_panel_size_from_DDCv1(tmds_chip, tmds_setting);
50 break; 49 break;
51 case GET_DVI_SZIE_BY_HW_STRAPPING: 50 case 2:
51 dvi_get_panel_size_from_DDCv2(tmds_chip, tmds_setting);
52 break; 52 break;
53 case GET_DVI_SIZE_BY_VGA_BIOS:
54 default: 53 default:
55 dvi_get_panel_info(); 54 printk(KERN_WARNING "viafb_init_dvi_size: DVI panel size undetected!\n");
56 break; 55 break;
57 } 56 }
57
58 return; 58 return;
59} 59}
60 60
@@ -189,42 +189,14 @@ static int tmds_register_read_bytes(int index, u8 *buff, int buff_len)
189 return 0; 189 return 0;
190} 190}
191 191
192static int check_reduce_blanking_mode(int mode_index,
193 int refresh_rate)
194{
195 if (refresh_rate != 60)
196 return false;
197
198 switch (mode_index) {
199 /* Following modes have reduce blanking mode. */
200 case VIA_RES_1360X768:
201 case VIA_RES_1400X1050:
202 case VIA_RES_1440X900:
203 case VIA_RES_1600X900:
204 case VIA_RES_1680X1050:
205 case VIA_RES_1920X1080:
206 case VIA_RES_1920X1200:
207 break;
208
209 default:
210 DEBUG_MSG(KERN_INFO
211 "This dvi mode %d have no reduce blanking mode!\n",
212 mode_index);
213 return false;
214 }
215
216 return true;
217}
218
219/* DVI Set Mode */ 192/* DVI Set Mode */
220void viafb_dvi_set_mode(int video_index, int mode_bpp, int set_iga) 193void viafb_dvi_set_mode(struct VideoModeTable *mode, int mode_bpp,
194 int set_iga)
221{ 195{
222 struct VideoModeTable *videoMode = NULL; 196 struct VideoModeTable *rb_mode;
223 struct crt_mode_table *pDviTiming; 197 struct crt_mode_table *pDviTiming;
224 unsigned long desirePixelClock, maxPixelClock; 198 unsigned long desirePixelClock, maxPixelClock;
225 int status = 0; 199 pDviTiming = mode->crtc;
226 videoMode = viafb_get_modetbl_pointer(video_index);
227 pDviTiming = videoMode->crtc;
228 desirePixelClock = pDviTiming->clk / 1000000; 200 desirePixelClock = pDviTiming->clk / 1000000;
229 maxPixelClock = (unsigned long)viaparinfo-> 201 maxPixelClock = (unsigned long)viaparinfo->
230 tmds_setting_info->max_pixel_clock; 202 tmds_setting_info->max_pixel_clock;
@@ -232,20 +204,14 @@ void viafb_dvi_set_mode(int video_index, int mode_bpp, int set_iga)
232 DEBUG_MSG(KERN_INFO "\nDVI_set_mode!!\n"); 204 DEBUG_MSG(KERN_INFO "\nDVI_set_mode!!\n");
233 205
234 if ((maxPixelClock != 0) && (desirePixelClock > maxPixelClock)) { 206 if ((maxPixelClock != 0) && (desirePixelClock > maxPixelClock)) {
235 /*Check if reduce-blanking mode is exist */ 207 rb_mode = viafb_get_rb_mode(mode->crtc[0].crtc.hor_addr,
236 status = 208 mode->crtc[0].crtc.ver_addr);
237 check_reduce_blanking_mode(video_index, 209 if (rb_mode) {
238 pDviTiming->refresh_rate); 210 mode = rb_mode;
239 if (status) { 211 pDviTiming = rb_mode->crtc;
240 video_index += 100; /*Use reduce-blanking mode */
241 videoMode = viafb_get_modetbl_pointer(video_index);
242 pDviTiming = videoMode->crtc;
243 DEBUG_MSG(KERN_INFO
244 "DVI use reduce blanking mode %d!!\n",
245 video_index);
246 } 212 }
247 } 213 }
248 viafb_fill_crtc_timing(pDviTiming, video_index, mode_bpp / 8, set_iga); 214 viafb_fill_crtc_timing(pDviTiming, mode, mode_bpp / 8, set_iga);
249 viafb_set_output_path(DEVICE_DVI, set_iga, 215 viafb_set_output_path(DEVICE_DVI, set_iga,
250 viaparinfo->chip_info->tmds_chip_info.output_interface); 216 viaparinfo->chip_info->tmds_chip_info.output_interface);
251} 217}
@@ -350,25 +316,18 @@ static int viafb_dvi_query_EDID(void)
350 return false; 316 return false;
351} 317}
352 318
353/* 319/* Get Panel Size Using EDID1 Table */
354 * 320static void dvi_get_panel_size_from_DDCv1(struct tmds_chip_information
355 * int dvi_get_panel_size_from_DDCv1(void) 321 *tmds_chip, struct tmds_setting_information *tmds_setting)
356 *
357 * - Get Panel Size Using EDID1 Table
358 *
359 * Return Type: int
360 *
361 */
362static int dvi_get_panel_size_from_DDCv1(void)
363{ 322{
364 int i, max_h = 0, max_v = 0, tmp, restore; 323 int i, max_h = 0, tmp, restore;
365 unsigned char rData; 324 unsigned char rData;
366 unsigned char EDID_DATA[18]; 325 unsigned char EDID_DATA[18];
367 326
368 DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv1 \n"); 327 DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv1 \n");
369 328
370 restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr; 329 restore = tmds_chip->tmds_chip_slave_addr;
371 viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA0; 330 tmds_chip->tmds_chip_slave_addr = 0xA0;
372 331
373 rData = tmds_register_read(0x23); 332 rData = tmds_register_read(0x23);
374 if (rData & 0x3C) 333 if (rData & 0x3C)
@@ -414,8 +373,8 @@ static int dvi_get_panel_size_from_DDCv1(void)
414 /* The first two byte must be zero. */ 373 /* The first two byte must be zero. */
415 if (EDID_DATA[3] == 0xFD) { 374 if (EDID_DATA[3] == 0xFD) {
416 /* To get max pixel clock. */ 375 /* To get max pixel clock. */
417 viaparinfo->tmds_setting_info-> 376 tmds_setting->max_pixel_clock =
418 max_pixel_clock = EDID_DATA[9] * 10; 377 EDID_DATA[9] * 10;
419 } 378 }
420 } 379 }
421 break; 380 break;
@@ -425,154 +384,88 @@ static int dvi_get_panel_size_from_DDCv1(void)
425 } 384 }
426 } 385 }
427 386
387 tmds_setting->max_hres = max_h;
428 switch (max_h) { 388 switch (max_h) {
429 case 640: 389 case 640:
430 viaparinfo->tmds_setting_info->dvi_panel_size = 390 tmds_setting->max_vres = 480;
431 VIA_RES_640X480;
432 break; 391 break;
433 case 800: 392 case 800:
434 viaparinfo->tmds_setting_info->dvi_panel_size = 393 tmds_setting->max_vres = 600;
435 VIA_RES_800X600;
436 break; 394 break;
437 case 1024: 395 case 1024:
438 viaparinfo->tmds_setting_info->dvi_panel_size = 396 tmds_setting->max_vres = 768;
439 VIA_RES_1024X768;
440 break; 397 break;
441 case 1280: 398 case 1280:
442 viaparinfo->tmds_setting_info->dvi_panel_size = 399 tmds_setting->max_vres = 1024;
443 VIA_RES_1280X1024;
444 break; 400 break;
445 case 1400: 401 case 1400:
446 viaparinfo->tmds_setting_info->dvi_panel_size = 402 tmds_setting->max_vres = 1050;
447 VIA_RES_1400X1050;
448 break; 403 break;
449 case 1440: 404 case 1440:
450 viaparinfo->tmds_setting_info->dvi_panel_size = 405 tmds_setting->max_vres = 1050;
451 VIA_RES_1440X1050;
452 break; 406 break;
453 case 1600: 407 case 1600:
454 viaparinfo->tmds_setting_info->dvi_panel_size = 408 tmds_setting->max_vres = 1200;
455 VIA_RES_1600X1200;
456 break; 409 break;
457 case 1920: 410 case 1920:
458 if (max_v == 1200) { 411 tmds_setting->max_vres = 1080;
459 viaparinfo->tmds_setting_info->dvi_panel_size =
460 VIA_RES_1920X1200;
461 } else {
462 viaparinfo->tmds_setting_info->dvi_panel_size =
463 VIA_RES_1920X1080;
464 }
465
466 break; 412 break;
467 default: 413 default:
468 viaparinfo->tmds_setting_info->dvi_panel_size = 414 DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d ! "
469 VIA_RES_1024X768; 415 "set default panel size.\n", max_h);
470 DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d !\
471 set default panel size.\n", max_h);
472 break; 416 break;
473 } 417 }
474 418
475 DEBUG_MSG(KERN_INFO "DVI max pixelclock = %d\n", 419 DEBUG_MSG(KERN_INFO "DVI max pixelclock = %d\n",
476 viaparinfo->tmds_setting_info->max_pixel_clock); 420 tmds_setting->max_pixel_clock);
477 viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore; 421 tmds_chip->tmds_chip_slave_addr = restore;
478 return viaparinfo->tmds_setting_info->dvi_panel_size;
479} 422}
480 423
481/* 424/* Get Panel Size Using EDID2 Table */
482 * 425static void dvi_get_panel_size_from_DDCv2(struct tmds_chip_information
483 * int dvi_get_panel_size_from_DDCv2(void) 426 *tmds_chip, struct tmds_setting_information *tmds_setting)
484 *
485 * - Get Panel Size Using EDID2 Table
486 *
487 * Return Type: int
488 *
489 */
490static int dvi_get_panel_size_from_DDCv2(void)
491{ 427{
492 int HSize = 0, restore; 428 int restore;
493 unsigned char R_Buffer[2]; 429 unsigned char R_Buffer[2];
494 430
495 DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv2 \n"); 431 DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv2 \n");
496 432
497 restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr; 433 restore = tmds_chip->tmds_chip_slave_addr;
498 viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA2; 434 tmds_chip->tmds_chip_slave_addr = 0xA2;
499 435
500 /* Horizontal: 0x76, 0x77 */ 436 /* Horizontal: 0x76, 0x77 */
501 tmds_register_read_bytes(0x76, R_Buffer, 2); 437 tmds_register_read_bytes(0x76, R_Buffer, 2);
502 HSize = R_Buffer[0]; 438 tmds_setting->max_hres = R_Buffer[0] + (R_Buffer[1] << 8);
503 HSize += R_Buffer[1] << 8;
504 439
505 switch (HSize) { 440 switch (tmds_setting->max_hres) {
506 case 640: 441 case 640:
507 viaparinfo->tmds_setting_info->dvi_panel_size = 442 tmds_setting->max_vres = 480;
508 VIA_RES_640X480;
509 break; 443 break;
510 case 800: 444 case 800:
511 viaparinfo->tmds_setting_info->dvi_panel_size = 445 tmds_setting->max_vres = 600;
512 VIA_RES_800X600;
513 break; 446 break;
514 case 1024: 447 case 1024:
515 viaparinfo->tmds_setting_info->dvi_panel_size = 448 tmds_setting->max_vres = 768;
516 VIA_RES_1024X768;
517 break; 449 break;
518 case 1280: 450 case 1280:
519 viaparinfo->tmds_setting_info->dvi_panel_size = 451 tmds_setting->max_vres = 1024;
520 VIA_RES_1280X1024;
521 break; 452 break;
522 case 1400: 453 case 1400:
523 viaparinfo->tmds_setting_info->dvi_panel_size = 454 tmds_setting->max_vres = 1050;
524 VIA_RES_1400X1050;
525 break; 455 break;
526 case 1440: 456 case 1440:
527 viaparinfo->tmds_setting_info->dvi_panel_size = 457 tmds_setting->max_vres = 1050;
528 VIA_RES_1440X1050;
529 break; 458 break;
530 case 1600: 459 case 1600:
531 viaparinfo->tmds_setting_info->dvi_panel_size = 460 tmds_setting->max_vres = 1200;
532 VIA_RES_1600X1200;
533 break;
534 default:
535 viaparinfo->tmds_setting_info->dvi_panel_size =
536 VIA_RES_1024X768;
537 DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d!\
538 set default panel size.\n", HSize);
539 break;
540 }
541
542 viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore;
543 return viaparinfo->tmds_setting_info->dvi_panel_size;
544}
545
546/*
547 *
548 * unsigned char dvi_get_panel_info(void)
549 *
550 * - Get Panel Size
551 *
552 * Return Type: unsigned char
553 */
554static unsigned char dvi_get_panel_info(void)
555{
556 unsigned char dvipanelsize;
557 DEBUG_MSG(KERN_INFO "dvi_get_panel_info! \n");
558
559 viafb_dvi_sense();
560 switch (viafb_dvi_query_EDID()) {
561 case 1:
562 dvi_get_panel_size_from_DDCv1();
563 break;
564 case 2:
565 dvi_get_panel_size_from_DDCv2();
566 break; 461 break;
567 default: 462 default:
463 DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d! "
464 "set default panel size.\n", tmds_setting->max_hres);
568 break; 465 break;
569 } 466 }
570 467
571 DEBUG_MSG(KERN_INFO "dvi panel size is %2d \n", 468 tmds_chip->tmds_chip_slave_addr = restore;
572 viaparinfo->tmds_setting_info->dvi_panel_size);
573 dvipanelsize = (unsigned char)(viaparinfo->
574 tmds_setting_info->dvi_panel_size);
575 return dvipanelsize;
576} 469}
577 470
578/* If Disable DVI, turn off pad */ 471/* If Disable DVI, turn off pad */