Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Florian Tobias Schandinat and committed by
Linus Torvalds
c5f06f5c 9b24b00c

+55 -75
+2 -7
drivers/video/via/chip.h
··· 107 107 struct tmds_chip_information { 108 108 int tmds_chip_name; 109 109 int tmds_chip_slave_addr; 110 - int dvi_panel_id; 111 110 int data_mode; 112 111 int output_interface; 113 112 int i2c_port; ··· 141 142 int iga_path; 142 143 int h_active; 143 144 int v_active; 144 - int bpp; 145 - int refresh_rate; 146 - int get_dvi_size_method; 147 145 int max_pixel_clock; 148 - int dvi_panel_hres; 149 - int dvi_panel_vres; 150 - int native_size; 146 + int max_hres; 147 + int max_vres; 151 148 }; 152 149 153 150 struct lvds_setting_information {
+49 -58
drivers/video/via/dvi.c
··· 23 23 static void tmds_register_write(int index, u8 data); 24 24 static int tmds_register_read(int index); 25 25 static int tmds_register_read_bytes(int index, u8 *buff, int buff_len); 26 - static void dvi_get_panel_size_from_DDCv1(void); 27 - static void dvi_get_panel_size_from_DDCv2(void); 28 - static void dvi_get_panel_info(void); 26 + static void dvi_get_panel_size_from_DDCv1(struct tmds_chip_information 27 + *tmds_chip, struct tmds_setting_information *tmds_setting); 28 + static void dvi_get_panel_size_from_DDCv2(struct tmds_chip_information 29 + *tmds_chip, struct tmds_setting_information *tmds_setting); 29 30 static int viafb_dvi_query_EDID(void); 30 31 31 32 static int check_tmds_chip(int device_id_subaddr, int device_id) ··· 37 36 return FAIL; 38 37 } 39 38 40 - void viafb_init_dvi_size(void) 39 + void viafb_init_dvi_size(struct tmds_chip_information *tmds_chip, 40 + struct tmds_setting_information *tmds_setting) 41 41 { 42 42 DEBUG_MSG(KERN_INFO "viafb_init_dvi_size()\n"); 43 - DEBUG_MSG(KERN_INFO 44 - "viaparinfo->tmds_setting_info->get_dvi_size_method %d\n", 45 - viaparinfo->tmds_setting_info->get_dvi_size_method); 46 43 47 - switch (viaparinfo->tmds_setting_info->get_dvi_size_method) { 48 - case GET_DVI_SIZE_BY_SYSTEM_BIOS: 44 + viafb_dvi_sense(); 45 + switch (viafb_dvi_query_EDID()) { 46 + case 1: 47 + dvi_get_panel_size_from_DDCv1(tmds_chip, tmds_setting); 49 48 break; 50 - case GET_DVI_SZIE_BY_HW_STRAPPING: 49 + case 2: 50 + dvi_get_panel_size_from_DDCv2(tmds_chip, tmds_setting); 51 51 break; 52 - case GET_DVI_SIZE_BY_VGA_BIOS: 53 52 default: 54 - dvi_get_panel_info(); 53 + printk(KERN_WARNING "viafb_init_dvi_size: DVI panel size undetected!\n"); 55 54 break; 56 55 } 56 + 57 57 return; 58 58 } 59 59 ··· 316 314 return false; 317 315 } 318 316 319 - /* void dvi_get_panel_size_from_DDCv1(void) 320 - * 321 - * - Get Panel Size Using EDID1 Table 322 - */ 323 - static void dvi_get_panel_size_from_DDCv1(void) 317 + /* Get Panel Size Using EDID1 Table */ 318 + static void dvi_get_panel_size_from_DDCv1(struct tmds_chip_information 319 + *tmds_chip, struct tmds_setting_information *tmds_setting) 324 320 { 325 321 int i, max_h = 0, tmp, restore; 326 322 unsigned char rData; ··· 326 326 327 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; 330 - viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA0; 329 + restore = tmds_chip->tmds_chip_slave_addr; 330 + tmds_chip->tmds_chip_slave_addr = 0xA0; 331 331 332 332 rData = tmds_register_read(0x23); 333 333 if (rData & 0x3C) ··· 373 373 /* The first two byte must be zero. */ 374 374 if (EDID_DATA[3] == 0xFD) { 375 375 /* To get max pixel clock. */ 376 - viaparinfo->tmds_setting_info-> 377 - max_pixel_clock = EDID_DATA[9] * 10; 376 + tmds_setting->max_pixel_clock = 377 + EDID_DATA[9] * 10; 378 378 } 379 379 } 380 380 break; ··· 384 384 } 385 385 } 386 386 387 + tmds_setting->max_hres = max_h; 387 388 switch (max_h) { 388 389 case 640: 390 + tmds_setting->max_vres = 480; 389 391 break; 390 392 case 800: 393 + tmds_setting->max_vres = 600; 391 394 break; 392 395 case 1024: 396 + tmds_setting->max_vres = 768; 393 397 break; 394 398 case 1280: 399 + tmds_setting->max_vres = 1024; 395 400 break; 396 401 case 1400: 402 + tmds_setting->max_vres = 1050; 397 403 break; 398 404 case 1440: 405 + tmds_setting->max_vres = 1050; 399 406 break; 400 407 case 1600: 408 + tmds_setting->max_vres = 1200; 401 409 break; 402 410 case 1920: 403 - 411 + tmds_setting->max_vres = 1080; 404 412 break; 405 413 default: 406 414 DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d !\ ··· 417 409 } 418 410 419 411 DEBUG_MSG(KERN_INFO "DVI max pixelclock = %d\n", 420 - viaparinfo->tmds_setting_info->max_pixel_clock); 421 - viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore; 412 + tmds_setting->max_pixel_clock); 413 + tmds_chip->tmds_chip_slave_addr = restore; 422 414 } 423 415 424 - /* void dvi_get_panel_size_from_DDCv2(void) 425 - * 426 - * - Get Panel Size Using EDID2 Table 427 - */ 428 - static void dvi_get_panel_size_from_DDCv2(void) 416 + /* Get Panel Size Using EDID2 Table */ 417 + static void dvi_get_panel_size_from_DDCv2(struct tmds_chip_information 418 + *tmds_chip, struct tmds_setting_information *tmds_setting) 429 419 { 430 - int HSize = 0, restore; 420 + int restore; 431 421 unsigned char R_Buffer[2]; 432 422 433 423 DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv2 \n"); 434 424 435 - restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr; 436 - viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA2; 425 + restore = tmds_chip->tmds_chip_slave_addr; 426 + tmds_chip->tmds_chip_slave_addr = 0xA2; 437 427 438 428 /* Horizontal: 0x76, 0x77 */ 439 429 tmds_register_read_bytes(0x76, R_Buffer, 2); 440 - HSize = R_Buffer[0]; 441 - HSize += R_Buffer[1] << 8; 430 + tmds_setting->max_hres = R_Buffer[0] + (R_Buffer[1] << 8); 442 431 443 - switch (HSize) { 432 + switch (tmds_setting->max_hres) { 444 433 case 640: 434 + tmds_setting->max_vres = 480; 445 435 break; 446 436 case 800: 437 + tmds_setting->max_vres = 600; 447 438 break; 448 439 case 1024: 440 + tmds_setting->max_vres = 768; 449 441 break; 450 442 case 1280: 443 + tmds_setting->max_vres = 1024; 451 444 break; 452 445 case 1400: 446 + tmds_setting->max_vres = 1050; 453 447 break; 454 448 case 1440: 449 + tmds_setting->max_vres = 1050; 455 450 break; 456 451 case 1600: 452 + tmds_setting->max_vres = 1200; 457 453 break; 458 454 default: 459 455 DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d!\ 460 - set default panel size.\n", HSize); 456 + set default panel size.\n", tmds_setting->max_hres); 461 457 break; 462 458 } 463 459 464 - viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore; 465 - } 466 - 467 - /* unsigned char dvi_get_panel_info(void) 468 - * 469 - * - Get Panel Size 470 - */ 471 - static void dvi_get_panel_info(void) 472 - { 473 - DEBUG_MSG(KERN_INFO "dvi_get_panel_info! \n"); 474 - 475 - viafb_dvi_sense(); 476 - switch (viafb_dvi_query_EDID()) { 477 - case 1: 478 - dvi_get_panel_size_from_DDCv1(); 479 - break; 480 - case 2: 481 - dvi_get_panel_size_from_DDCv2(); 482 - break; 483 - default: 484 - break; 485 - } 460 + tmds_chip->tmds_chip_slave_addr = restore; 486 461 } 487 462 488 463 /* If Disable DVI, turn off pad */
+2 -1
drivers/video/via/dvi.h
··· 57 57 void viafb_dvi_disable(void); 58 58 void viafb_dvi_enable(void); 59 59 int viafb_tmds_trasmitter_identify(void); 60 - void viafb_init_dvi_size(void); 60 + void viafb_init_dvi_size(struct tmds_chip_information *tmds_chip, 61 + struct tmds_setting_information *tmds_setting); 61 62 void viafb_dvi_set_mode(struct VideoModeTable *videoMode, int mode_bpp, 62 63 int set_iga); 63 64
+2 -9
drivers/video/via/hw.c
··· 1911 1911 1912 1912 viaparinfo->tmds_setting_info->h_active = hres; 1913 1913 viaparinfo->tmds_setting_info->v_active = vres; 1914 - viaparinfo->tmds_setting_info->bpp = bpp; 1915 - viaparinfo->tmds_setting_info->refresh_rate = 1916 - vmode_refresh; 1917 1914 1918 1915 viaparinfo->lvds_setting_info->h_active = hres; 1919 1916 viaparinfo->lvds_setting_info->v_active = vres; ··· 1927 1930 if (viaparinfo->tmds_setting_info->iga_path == IGA2) { 1928 1931 viaparinfo->tmds_setting_info->h_active = hres; 1929 1932 viaparinfo->tmds_setting_info->v_active = vres; 1930 - viaparinfo->tmds_setting_info->bpp = bpp; 1931 - viaparinfo->tmds_setting_info->refresh_rate = 1932 - vmode_refresh; 1933 1933 } 1934 1934 1935 1935 if (viaparinfo->lvds_setting_info->iga_path == IGA2) { ··· 2025 2031 2026 2032 DEBUG_MSG(KERN_INFO "TMDS Chip = %d\n", 2027 2033 viaparinfo->chip_info->tmds_chip_info.tmds_chip_name); 2028 - viaparinfo->tmds_setting_info->get_dvi_size_method = 2029 - GET_DVI_SIZE_BY_VGA_BIOS; 2030 - viafb_init_dvi_size(); 2034 + viafb_init_dvi_size(&viaparinfo->shared->chip_info.tmds_chip_info, 2035 + &viaparinfo->shared->tmds_setting_info); 2031 2036 } 2032 2037 2033 2038 static void init_lvds_chip_info(void)