aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/via/dvi.c
diff options
context:
space:
mode:
authorFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2010-03-10 18:21:30 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-12 18:52:33 -0500
commitc5f06f5cddd6681b978ffdb53755e28eefccb1bb (patch)
treecf195fe5b85a03fbb4be13b905e3e4b8faed21a9 /drivers/video/via/dvi.c
parent9b24b00c364bb3bfa717ba2ead258a527b20cc5f (diff)
viafb: some dvi cleanup
Remove some unused variables, move some dvi code around and store the detected maximum resolution for later use. The vertical resolution is handled as the old code did it but I hope it can be read from the hardware some day. No runtime change expected. Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de> Cc: Joseph Chan <JosephChan@via.com.tw> Cc: Scott Fang <ScottFang@viatech.com.cn> Cc: Krzysztof Helt <krzysztof.h1@poczta.fm> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/via/dvi.c')
-rw-r--r--drivers/video/via/dvi.c107
1 files changed, 49 insertions, 58 deletions
diff --git a/drivers/video/via/dvi.c b/drivers/video/via/dvi.c
index 9cb261ce6e35..0e0852e6df26 100644
--- a/drivers/video/via/dvi.c
+++ b/drivers/video/via/dvi.c
@@ -23,9 +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 void dvi_get_panel_size_from_DDCv1(void); 26static void dvi_get_panel_size_from_DDCv1(struct tmds_chip_information
27static void dvi_get_panel_size_from_DDCv2(void); 27 *tmds_chip, struct tmds_setting_information *tmds_setting);
28static void dvi_get_panel_info(void); 28static void dvi_get_panel_size_from_DDCv2(struct tmds_chip_information
29 *tmds_chip, struct tmds_setting_information *tmds_setting);
29static int viafb_dvi_query_EDID(void); 30static int viafb_dvi_query_EDID(void);
30 31
31static int check_tmds_chip(int device_id_subaddr, int device_id) 32static int check_tmds_chip(int device_id_subaddr, int device_id)
@@ -36,23 +37,24 @@ static int check_tmds_chip(int device_id_subaddr, int device_id)
36 return FAIL; 37 return FAIL;
37} 38}
38 39
39void viafb_init_dvi_size(void) 40void viafb_init_dvi_size(struct tmds_chip_information *tmds_chip,
41 struct tmds_setting_information *tmds_setting)
40{ 42{
41 DEBUG_MSG(KERN_INFO "viafb_init_dvi_size()\n"); 43 DEBUG_MSG(KERN_INFO "viafb_init_dvi_size()\n");
42 DEBUG_MSG(KERN_INFO
43 "viaparinfo->tmds_setting_info->get_dvi_size_method %d\n",
44 viaparinfo->tmds_setting_info->get_dvi_size_method);
45 44
46 switch (viaparinfo->tmds_setting_info->get_dvi_size_method) { 45 viafb_dvi_sense();
47 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);
48 break; 49 break;
49 case GET_DVI_SZIE_BY_HW_STRAPPING: 50 case 2:
51 dvi_get_panel_size_from_DDCv2(tmds_chip, tmds_setting);
50 break; 52 break;
51 case GET_DVI_SIZE_BY_VGA_BIOS:
52 default: 53 default:
53 dvi_get_panel_info(); 54 printk(KERN_WARNING "viafb_init_dvi_size: DVI panel size undetected!\n");
54 break; 55 break;
55 } 56 }
57
56 return; 58 return;
57} 59}
58 60
@@ -314,11 +316,9 @@ static int viafb_dvi_query_EDID(void)
314 return false; 316 return false;
315} 317}
316 318
317/* void dvi_get_panel_size_from_DDCv1(void) 319/* Get Panel Size Using EDID1 Table */
318 * 320static void dvi_get_panel_size_from_DDCv1(struct tmds_chip_information
319 * - Get Panel Size Using EDID1 Table 321 *tmds_chip, struct tmds_setting_information *tmds_setting)
320 */
321static void dvi_get_panel_size_from_DDCv1(void)
322{ 322{
323 int i, max_h = 0, tmp, restore; 323 int i, max_h = 0, tmp, restore;
324 unsigned char rData; 324 unsigned char rData;
@@ -326,8 +326,8 @@ static void dvi_get_panel_size_from_DDCv1(void)
326 326
327 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");
328 328
329 restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr; 329 restore = tmds_chip->tmds_chip_slave_addr;
330 viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA0; 330 tmds_chip->tmds_chip_slave_addr = 0xA0;
331 331
332 rData = tmds_register_read(0x23); 332 rData = tmds_register_read(0x23);
333 if (rData & 0x3C) 333 if (rData & 0x3C)
@@ -373,8 +373,8 @@ static void dvi_get_panel_size_from_DDCv1(void)
373 /* The first two byte must be zero. */ 373 /* The first two byte must be zero. */
374 if (EDID_DATA[3] == 0xFD) { 374 if (EDID_DATA[3] == 0xFD) {
375 /* To get max pixel clock. */ 375 /* To get max pixel clock. */
376 viaparinfo->tmds_setting_info-> 376 tmds_setting->max_pixel_clock =
377 max_pixel_clock = EDID_DATA[9] * 10; 377 EDID_DATA[9] * 10;
378 } 378 }
379 } 379 }
380 break; 380 break;
@@ -384,23 +384,31 @@ static void dvi_get_panel_size_from_DDCv1(void)
384 } 384 }
385 } 385 }
386 386
387 tmds_setting->max_hres = max_h;
387 switch (max_h) { 388 switch (max_h) {
388 case 640: 389 case 640:
390 tmds_setting->max_vres = 480;
389 break; 391 break;
390 case 800: 392 case 800:
393 tmds_setting->max_vres = 600;
391 break; 394 break;
392 case 1024: 395 case 1024:
396 tmds_setting->max_vres = 768;
393 break; 397 break;
394 case 1280: 398 case 1280:
399 tmds_setting->max_vres = 1024;
395 break; 400 break;
396 case 1400: 401 case 1400:
402 tmds_setting->max_vres = 1050;
397 break; 403 break;
398 case 1440: 404 case 1440:
405 tmds_setting->max_vres = 1050;
399 break; 406 break;
400 case 1600: 407 case 1600:
408 tmds_setting->max_vres = 1200;
401 break; 409 break;
402 case 1920: 410 case 1920:
403 411 tmds_setting->max_vres = 1080;
404 break; 412 break;
405 default: 413 default:
406 DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d !\ 414 DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d !\
@@ -409,72 +417,55 @@ static void dvi_get_panel_size_from_DDCv1(void)
409 } 417 }
410 418
411 DEBUG_MSG(KERN_INFO "DVI max pixelclock = %d\n", 419 DEBUG_MSG(KERN_INFO "DVI max pixelclock = %d\n",
412 viaparinfo->tmds_setting_info->max_pixel_clock); 420 tmds_setting->max_pixel_clock);
413 viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore; 421 tmds_chip->tmds_chip_slave_addr = restore;
414} 422}
415 423
416/* void dvi_get_panel_size_from_DDCv2(void) 424/* Get Panel Size Using EDID2 Table */
417 * 425static void dvi_get_panel_size_from_DDCv2(struct tmds_chip_information
418 * - Get Panel Size Using EDID2 Table 426 *tmds_chip, struct tmds_setting_information *tmds_setting)
419 */
420static void dvi_get_panel_size_from_DDCv2(void)
421{ 427{
422 int HSize = 0, restore; 428 int restore;
423 unsigned char R_Buffer[2]; 429 unsigned char R_Buffer[2];
424 430
425 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");
426 432
427 restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr; 433 restore = tmds_chip->tmds_chip_slave_addr;
428 viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA2; 434 tmds_chip->tmds_chip_slave_addr = 0xA2;
429 435
430 /* Horizontal: 0x76, 0x77 */ 436 /* Horizontal: 0x76, 0x77 */
431 tmds_register_read_bytes(0x76, R_Buffer, 2); 437 tmds_register_read_bytes(0x76, R_Buffer, 2);
432 HSize = R_Buffer[0]; 438 tmds_setting->max_hres = R_Buffer[0] + (R_Buffer[1] << 8);
433 HSize += R_Buffer[1] << 8;
434 439
435 switch (HSize) { 440 switch (tmds_setting->max_hres) {
436 case 640: 441 case 640:
442 tmds_setting->max_vres = 480;
437 break; 443 break;
438 case 800: 444 case 800:
445 tmds_setting->max_vres = 600;
439 break; 446 break;
440 case 1024: 447 case 1024:
448 tmds_setting->max_vres = 768;
441 break; 449 break;
442 case 1280: 450 case 1280:
451 tmds_setting->max_vres = 1024;
443 break; 452 break;
444 case 1400: 453 case 1400:
454 tmds_setting->max_vres = 1050;
445 break; 455 break;
446 case 1440: 456 case 1440:
457 tmds_setting->max_vres = 1050;
447 break; 458 break;
448 case 1600: 459 case 1600:
460 tmds_setting->max_vres = 1200;
449 break; 461 break;
450 default: 462 default:
451 DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d!\ 463 DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d!\
452 set default panel size.\n", HSize); 464 set default panel size.\n", tmds_setting->max_hres);
453 break; 465 break;
454 } 466 }
455 467
456 viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore; 468 tmds_chip->tmds_chip_slave_addr = restore;
457}
458
459/* unsigned char dvi_get_panel_info(void)
460 *
461 * - Get Panel Size
462 */
463static void dvi_get_panel_info(void)
464{
465 DEBUG_MSG(KERN_INFO "dvi_get_panel_info! \n");
466
467 viafb_dvi_sense();
468 switch (viafb_dvi_query_EDID()) {
469 case 1:
470 dvi_get_panel_size_from_DDCv1();
471 break;
472 case 2:
473 dvi_get_panel_size_from_DDCv2();
474 break;
475 default:
476 break;
477 }
478} 469}
479 470
480/* If Disable DVI, turn off pad */ 471/* If Disable DVI, turn off pad */