diff options
Diffstat (limited to 'drivers/video/via/lcd.c')
-rw-r--r-- | drivers/video/via/lcd.c | 82 |
1 files changed, 19 insertions, 63 deletions
diff --git a/drivers/video/via/lcd.c b/drivers/video/via/lcd.c index 5f3b4e394e82..165037910536 100644 --- a/drivers/video/via/lcd.c +++ b/drivers/video/via/lcd.c | |||
@@ -53,10 +53,6 @@ static void __devinit fp_id_to_vindex(int panel_id); | |||
53 | static int lvds_register_read(int index); | 53 | static int lvds_register_read(int index); |
54 | static void load_lcd_scaling(int set_hres, int set_vres, int panel_hres, | 54 | static void load_lcd_scaling(int set_hres, int set_vres, int panel_hres, |
55 | int panel_vres); | 55 | int panel_vres); |
56 | static void via_pitch_alignment_patch_lcd( | ||
57 | struct lvds_setting_information *plvds_setting_info, | ||
58 | struct lvds_chip_information | ||
59 | *plvds_chip_info); | ||
60 | static void lcd_patch_skew_dvp0(struct lvds_setting_information | 56 | static void lcd_patch_skew_dvp0(struct lvds_setting_information |
61 | *plvds_setting_info, | 57 | *plvds_setting_info, |
62 | struct lvds_chip_information *plvds_chip_info); | 58 | struct lvds_chip_information *plvds_chip_info); |
@@ -79,9 +75,6 @@ static void check_diport_of_integrated_lvds( | |||
79 | struct lvds_chip_information *plvds_chip_info, | 75 | struct lvds_chip_information *plvds_chip_info, |
80 | struct lvds_setting_information | 76 | struct lvds_setting_information |
81 | *plvds_setting_info); | 77 | *plvds_setting_info); |
82 | static struct display_timing lcd_centering_timging(struct display_timing | ||
83 | mode_crt_reg, | ||
84 | struct display_timing panel_crt_reg); | ||
85 | 78 | ||
86 | static inline bool check_lvds_chip(int device_id_subaddr, int device_id) | 79 | static inline bool check_lvds_chip(int device_id_subaddr, int device_id) |
87 | { | 80 | { |
@@ -454,20 +447,17 @@ static void load_lcd_scaling(int set_hres, int set_vres, int panel_hres, | |||
454 | } | 447 | } |
455 | } | 448 | } |
456 | 449 | ||
457 | static void via_pitch_alignment_patch_lcd( | 450 | static void via_pitch_alignment_patch_lcd(int iga_path, int hres, int bpp) |
458 | struct lvds_setting_information *plvds_setting_info, | ||
459 | struct lvds_chip_information | ||
460 | *plvds_chip_info) | ||
461 | { | 451 | { |
462 | unsigned char cr13, cr35, cr65, cr66, cr67; | 452 | unsigned char cr13, cr35, cr65, cr66, cr67; |
463 | unsigned long dwScreenPitch = 0; | 453 | unsigned long dwScreenPitch = 0; |
464 | unsigned long dwPitch; | 454 | unsigned long dwPitch; |
465 | 455 | ||
466 | dwPitch = plvds_setting_info->h_active * (plvds_setting_info->bpp >> 3); | 456 | dwPitch = hres * (bpp >> 3); |
467 | if (dwPitch & 0x1F) { | 457 | if (dwPitch & 0x1F) { |
468 | dwScreenPitch = ((dwPitch + 31) & ~31) >> 3; | 458 | dwScreenPitch = ((dwPitch + 31) & ~31) >> 3; |
469 | if (plvds_setting_info->iga_path == IGA2) { | 459 | if (iga_path == IGA2) { |
470 | if (plvds_setting_info->bpp > 8) { | 460 | if (bpp > 8) { |
471 | cr66 = (unsigned char)(dwScreenPitch & 0xFF); | 461 | cr66 = (unsigned char)(dwScreenPitch & 0xFF); |
472 | viafb_write_reg(CR66, VIACR, cr66); | 462 | viafb_write_reg(CR66, VIACR, cr66); |
473 | cr67 = viafb_read_reg(VIACR, CR67) & 0xFC; | 463 | cr67 = viafb_read_reg(VIACR, CR67) & 0xFC; |
@@ -485,7 +475,7 @@ static void via_pitch_alignment_patch_lcd( | |||
485 | cr65 += 2; | 475 | cr65 += 2; |
486 | viafb_write_reg(CR65, VIACR, cr65); | 476 | viafb_write_reg(CR65, VIACR, cr65); |
487 | } else { | 477 | } else { |
488 | if (plvds_setting_info->bpp > 8) { | 478 | if (bpp > 8) { |
489 | cr13 = (unsigned char)(dwScreenPitch & 0xFF); | 479 | cr13 = (unsigned char)(dwScreenPitch & 0xFF); |
490 | viafb_write_reg(CR13, VIACR, cr13); | 480 | viafb_write_reg(CR13, VIACR, cr13); |
491 | cr35 = viafb_read_reg(VIACR, CR35) & 0x1F; | 481 | cr35 = viafb_read_reg(VIACR, CR35) & 0x1F; |
@@ -548,49 +538,45 @@ static void lcd_patch_skew(struct lvds_setting_information | |||
548 | } | 538 | } |
549 | 539 | ||
550 | /* LCD Set Mode */ | 540 | /* LCD Set Mode */ |
551 | void viafb_lcd_set_mode(struct lvds_setting_information *plvds_setting_info, | 541 | void viafb_lcd_set_mode(const struct fb_var_screeninfo *var, u16 cxres, |
542 | u16 cyres, struct lvds_setting_information *plvds_setting_info, | ||
552 | struct lvds_chip_information *plvds_chip_info) | 543 | struct lvds_chip_information *plvds_chip_info) |
553 | { | 544 | { |
554 | int set_iga = plvds_setting_info->iga_path; | 545 | int set_iga = plvds_setting_info->iga_path; |
555 | int mode_bpp = plvds_setting_info->bpp; | 546 | int mode_bpp = var->bits_per_pixel; |
556 | int set_hres = plvds_setting_info->h_active; | 547 | int set_hres = cxres ? cxres : var->xres; |
557 | int set_vres = plvds_setting_info->v_active; | 548 | int set_vres = cyres ? cyres : var->yres; |
558 | int panel_hres = plvds_setting_info->lcd_panel_hres; | 549 | int panel_hres = plvds_setting_info->lcd_panel_hres; |
559 | int panel_vres = plvds_setting_info->lcd_panel_vres; | 550 | int panel_vres = plvds_setting_info->lcd_panel_vres; |
560 | u32 clock; | 551 | u32 clock; |
561 | struct display_timing mode_crt_reg, panel_crt_reg, timing; | 552 | struct display_timing timing; |
562 | struct crt_mode_table *mode_crt_table, *panel_crt_table; | 553 | struct fb_var_screeninfo panel_var; |
554 | const struct fb_videomode *mode_crt_table, *panel_crt_table; | ||
563 | 555 | ||
564 | DEBUG_MSG(KERN_INFO "viafb_lcd_set_mode!!\n"); | 556 | DEBUG_MSG(KERN_INFO "viafb_lcd_set_mode!!\n"); |
565 | /* Get mode table */ | 557 | /* Get mode table */ |
566 | mode_crt_table = viafb_get_best_mode(set_hres, set_vres, 60); | 558 | mode_crt_table = viafb_get_best_mode(set_hres, set_vres, 60); |
567 | mode_crt_reg = mode_crt_table->crtc; | ||
568 | /* Get panel table Pointer */ | 559 | /* Get panel table Pointer */ |
569 | panel_crt_table = viafb_get_best_mode(panel_hres, panel_vres, 60); | 560 | panel_crt_table = viafb_get_best_mode(panel_hres, panel_vres, 60); |
570 | panel_crt_reg = panel_crt_table->crtc; | 561 | viafb_fill_var_timing_info(&panel_var, panel_crt_table); |
571 | DEBUG_MSG(KERN_INFO "bellow viafb_lcd_set_mode!!\n"); | 562 | DEBUG_MSG(KERN_INFO "bellow viafb_lcd_set_mode!!\n"); |
572 | if (VT1636_LVDS == plvds_chip_info->lvds_chip_name) | 563 | if (VT1636_LVDS == plvds_chip_info->lvds_chip_name) |
573 | viafb_init_lvds_vt1636(plvds_setting_info, plvds_chip_info); | 564 | viafb_init_lvds_vt1636(plvds_setting_info, plvds_chip_info); |
574 | clock = panel_crt_reg.hor_total * panel_crt_reg.ver_total | 565 | clock = PICOS2KHZ(panel_crt_table->pixclock) * 1000; |
575 | * panel_crt_table->refresh_rate; | ||
576 | plvds_setting_info->vclk = clock; | 566 | plvds_setting_info->vclk = clock; |
577 | 567 | ||
578 | if (set_iga == IGA2 && (set_hres < panel_hres || set_vres < panel_vres) | 568 | if (set_iga == IGA2 && (set_hres < panel_hres || set_vres < panel_vres) |
579 | && plvds_setting_info->display_method == LCD_EXPANDSION) { | 569 | && plvds_setting_info->display_method == LCD_EXPANDSION) { |
580 | timing = panel_crt_reg; | 570 | timing = var_to_timing(&panel_var, panel_hres, panel_vres); |
581 | load_lcd_scaling(set_hres, set_vres, panel_hres, panel_vres); | 571 | load_lcd_scaling(set_hres, set_vres, panel_hres, panel_vres); |
582 | } else { | 572 | } else { |
583 | timing = lcd_centering_timging(mode_crt_reg, panel_crt_reg); | 573 | timing = var_to_timing(&panel_var, set_hres, set_vres); |
584 | if (set_iga == IGA2) | 574 | if (set_iga == IGA2) |
585 | /* disable scaling */ | 575 | /* disable scaling */ |
586 | via_write_reg_mask(VIACR, 0x79, 0x00, | 576 | via_write_reg_mask(VIACR, 0x79, 0x00, |
587 | BIT0 + BIT1 + BIT2); | 577 | BIT0 + BIT1 + BIT2); |
588 | } | 578 | } |
589 | 579 | ||
590 | timing.hor_blank_end += timing.hor_blank_start; | ||
591 | timing.hor_sync_end += timing.hor_sync_start; | ||
592 | timing.ver_blank_end += timing.ver_blank_start; | ||
593 | timing.ver_sync_end += timing.ver_sync_start; | ||
594 | if (set_iga == IGA1) | 580 | if (set_iga == IGA1) |
595 | via_set_primary_timing(&timing); | 581 | via_set_primary_timing(&timing); |
596 | else if (set_iga == IGA2) | 582 | else if (set_iga == IGA2) |
@@ -613,7 +599,8 @@ void viafb_lcd_set_mode(struct lvds_setting_information *plvds_setting_info, | |||
613 | viafb_write_reg_mask(CR6A, VIACR, 0x01, BIT0); | 599 | viafb_write_reg_mask(CR6A, VIACR, 0x01, BIT0); |
614 | 600 | ||
615 | /* Patch for non 32bit alignment mode */ | 601 | /* Patch for non 32bit alignment mode */ |
616 | via_pitch_alignment_patch_lcd(plvds_setting_info, plvds_chip_info); | 602 | via_pitch_alignment_patch_lcd(plvds_setting_info->iga_path, set_hres, |
603 | var->bits_per_pixel); | ||
617 | } | 604 | } |
618 | 605 | ||
619 | static void integrated_lvds_disable(struct lvds_setting_information | 606 | static void integrated_lvds_disable(struct lvds_setting_information |
@@ -973,37 +960,6 @@ void __devinit viafb_init_lvds_output_interface(struct lvds_chip_information | |||
973 | } | 960 | } |
974 | } | 961 | } |
975 | 962 | ||
976 | static struct display_timing lcd_centering_timging(struct display_timing | ||
977 | mode_crt_reg, | ||
978 | struct display_timing panel_crt_reg) | ||
979 | { | ||
980 | struct display_timing crt_reg; | ||
981 | |||
982 | crt_reg.hor_total = panel_crt_reg.hor_total; | ||
983 | crt_reg.hor_addr = mode_crt_reg.hor_addr; | ||
984 | crt_reg.hor_blank_start = | ||
985 | (panel_crt_reg.hor_addr - mode_crt_reg.hor_addr) / 2 + | ||
986 | crt_reg.hor_addr; | ||
987 | crt_reg.hor_blank_end = panel_crt_reg.hor_blank_end; | ||
988 | crt_reg.hor_sync_start = | ||
989 | (panel_crt_reg.hor_sync_start - | ||
990 | panel_crt_reg.hor_blank_start) + crt_reg.hor_blank_start; | ||
991 | crt_reg.hor_sync_end = panel_crt_reg.hor_sync_end; | ||
992 | |||
993 | crt_reg.ver_total = panel_crt_reg.ver_total; | ||
994 | crt_reg.ver_addr = mode_crt_reg.ver_addr; | ||
995 | crt_reg.ver_blank_start = | ||
996 | (panel_crt_reg.ver_addr - mode_crt_reg.ver_addr) / 2 + | ||
997 | crt_reg.ver_addr; | ||
998 | crt_reg.ver_blank_end = panel_crt_reg.ver_blank_end; | ||
999 | crt_reg.ver_sync_start = | ||
1000 | (panel_crt_reg.ver_sync_start - | ||
1001 | panel_crt_reg.ver_blank_start) + crt_reg.ver_blank_start; | ||
1002 | crt_reg.ver_sync_end = panel_crt_reg.ver_sync_end; | ||
1003 | |||
1004 | return crt_reg; | ||
1005 | } | ||
1006 | |||
1007 | bool viafb_lcd_get_mobile_state(bool *mobile) | 963 | bool viafb_lcd_get_mobile_state(bool *mobile) |
1008 | { | 964 | { |
1009 | unsigned char __iomem *romptr, *tableptr, *biosptr; | 965 | unsigned char __iomem *romptr, *tableptr, *biosptr; |