aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/via
diff options
context:
space:
mode:
authorFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2010-08-11 18:22:54 -0400
committerFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2010-09-23 22:14:58 -0400
commitcd7e9103e983ff0f518ac0e85cee265027ccbfa4 (patch)
tree3a87b00683aee3adc2c4670b0cb85a15b5d7dbb0 /drivers/video/via
parentbc6848875152f3df860d0f54a2323cc7615527d9 (diff)
viafb: merge the remaining output path with enable functions
This patch merges the remaining functionality of the output path function in the associated enabling functions. This is very natural as most of the remaining code does actually enable the device. Just some more or less intelligent code merge. If no stupid mistakes occured there should be no regressions. Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de> Cc: Joseph Chan <JosephChan@via.com.tw>
Diffstat (limited to 'drivers/video/via')
-rw-r--r--drivers/video/via/dvi.c146
-rw-r--r--drivers/video/via/hw.c164
-rw-r--r--drivers/video/via/hw.h3
-rw-r--r--drivers/video/via/lcd.c28
4 files changed, 136 insertions, 205 deletions
diff --git a/drivers/video/via/dvi.c b/drivers/video/via/dvi.c
index ab6145da1a2f..7c82f6fda918 100644
--- a/drivers/video/via/dvi.c
+++ b/drivers/video/via/dvi.c
@@ -496,38 +496,103 @@ void viafb_dvi_disable(void)
496 viafb_read_reg(VIACR, CRD2) | 0x08); 496 viafb_read_reg(VIACR, CRD2) | 0x08);
497} 497}
498 498
499static void dvi_patch_skew_dvp0(void)
500{
501 /* Reset data driving first: */
502 viafb_write_reg_mask(SR1B, VIASR, 0, BIT1);
503 viafb_write_reg_mask(SR2A, VIASR, 0, BIT4);
504
505 switch (viaparinfo->chip_info->gfx_chip_name) {
506 case UNICHROME_P4M890:
507 {
508 if ((viaparinfo->tmds_setting_info->h_active == 1600) &&
509 (viaparinfo->tmds_setting_info->v_active ==
510 1200))
511 viafb_write_reg_mask(CR96, VIACR, 0x03,
512 BIT0 + BIT1 + BIT2);
513 else
514 viafb_write_reg_mask(CR96, VIACR, 0x07,
515 BIT0 + BIT1 + BIT2);
516 break;
517 }
518
519 case UNICHROME_P4M900:
520 {
521 viafb_write_reg_mask(CR96, VIACR, 0x07,
522 BIT0 + BIT1 + BIT2 + BIT3);
523 viafb_write_reg_mask(SR1B, VIASR, 0x02, BIT1);
524 viafb_write_reg_mask(SR2A, VIASR, 0x10, BIT4);
525 break;
526 }
527
528 default:
529 {
530 break;
531 }
532 }
533}
534
535static void dvi_patch_skew_dvp_low(void)
536{
537 switch (viaparinfo->chip_info->gfx_chip_name) {
538 case UNICHROME_K8M890:
539 {
540 viafb_write_reg_mask(CR99, VIACR, 0x03, BIT0 + BIT1);
541 break;
542 }
543
544 case UNICHROME_P4M900:
545 {
546 viafb_write_reg_mask(CR99, VIACR, 0x08,
547 BIT0 + BIT1 + BIT2 + BIT3);
548 break;
549 }
550
551 case UNICHROME_P4M890:
552 {
553 viafb_write_reg_mask(CR99, VIACR, 0x0F,
554 BIT0 + BIT1 + BIT2 + BIT3);
555 break;
556 }
557
558 default:
559 {
560 break;
561 }
562 }
563}
564
499/* If Enable DVI, turn off pad */ 565/* If Enable DVI, turn off pad */
500void viafb_dvi_enable(void) 566void viafb_dvi_enable(void)
501{ 567{
502 u8 data; 568 u8 data;
503 569
504 if (viaparinfo->chip_info-> 570 switch (viaparinfo->chip_info->tmds_chip_info.output_interface) {
505 tmds_chip_info.output_interface == INTERFACE_DVP0) { 571 case INTERFACE_DVP0:
506 viafb_write_reg(SR1E, VIASR, 572 viafb_write_reg_mask(CR6B, VIACR, 0x01, BIT0);
507 viafb_read_reg(VIASR, SR1E) | 0xC0); 573 viafb_write_reg_mask(CR6C, VIACR, 0x21, BIT0 + BIT5);
574 viafb_write_reg_mask(SR1E, VIASR, 0xC0, BIT7 + BIT6);
575 dvi_patch_skew_dvp0();
508 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) 576 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
509 tmds_register_write(0x88, 0x3b); 577 tmds_register_write(0x88, 0x3b);
510 else 578 else
511 /*clear CR91[5] to direct on display period 579 /*clear CR91[5] to direct on display period
512 in the secondary diplay path */ 580 in the secondary diplay path */
513 viafb_write_reg(CR91, VIACR, 581 via_write_reg_mask(VIACR, 0x91, 0x00, 0x20);
514 viafb_read_reg(VIACR, CR91) & 0xDF); 582 break;
515 }
516 583
517 if (viaparinfo->chip_info-> 584 case INTERFACE_DVP1:
518 tmds_chip_info.output_interface == INTERFACE_DVP1) { 585 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
519 viafb_write_reg(SR1E, VIASR, 586 viafb_write_reg_mask(CR93, VIACR, 0x21, BIT0 + BIT5);
520 viafb_read_reg(VIASR, SR1E) | 0x30);
521 587
588 viafb_write_reg_mask(SR1E, VIASR, 0x30, BIT4 + BIT5);
522 /*fix dvi cann't be enabled with MB VT5718C4 - Al Zhang */ 589 /*fix dvi cann't be enabled with MB VT5718C4 - Al Zhang */
523 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) { 590 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
524 tmds_register_write(0x88, 0x3b); 591 tmds_register_write(0x88, 0x3b);
525 } else { 592 else
526 /*clear CR91[5] to direct on display period 593 /*clear CR91[5] to direct on display period
527 in the secondary diplay path */ 594 in the secondary diplay path */
528 viafb_write_reg(CR91, VIACR, 595 via_write_reg_mask(VIACR, 0x91, 0x00, 0x20);
529 viafb_read_reg(VIACR, CR91) & 0xDF);
530 }
531 596
532 /*fix DVI cannot enable on EPIA-M board */ 597 /*fix DVI cannot enable on EPIA-M board */
533 if (viafb_platform_epia_dvi == 1) { 598 if (viafb_platform_epia_dvi == 1) {
@@ -539,36 +604,41 @@ void viafb_dvi_enable(void)
539 else 604 else
540 data = 0x37; 605 data = 0x37;
541 viafb_i2c_writebyte(viaparinfo->chip_info-> 606 viafb_i2c_writebyte(viaparinfo->chip_info->
542 tmds_chip_info.i2c_port, 607 tmds_chip_info.i2c_port,
543 viaparinfo->chip_info-> 608 viaparinfo->chip_info->
544 tmds_chip_info.tmds_chip_slave_addr, 609 tmds_chip_info.tmds_chip_slave_addr,
545 0x08, data); 610 0x08, data);
546 } 611 }
547 } 612 }
548 } 613 break;
549 614
550 if (viaparinfo->chip_info-> 615 case INTERFACE_DFP_HIGH:
551 tmds_chip_info.output_interface == INTERFACE_DFP_HIGH) { 616 if (viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266)
552 viafb_write_reg(SR2A, VIASR, 617 via_write_reg_mask(VIACR, CR97, 0x03, 0x03);
553 viafb_read_reg(VIASR, SR2A) | 0x0C);
554 viafb_write_reg(CR91, VIACR,
555 viafb_read_reg(VIACR, CR91) & 0xDF);
556 }
557 618
558 if (viaparinfo->chip_info-> 619 viafb_write_reg_mask(SR2A, VIASR, 0x0C, BIT2 + BIT3);
559 tmds_chip_info.output_interface == INTERFACE_DFP_LOW) { 620 via_write_reg_mask(VIACR, 0x91, 0x00, 0x20);
560 viafb_write_reg(SR2A, VIASR, 621 break;
561 viafb_read_reg(VIASR, SR2A) | 0x03); 622
562 viafb_write_reg(CR91, VIACR, 623 case INTERFACE_DFP_LOW:
563 viafb_read_reg(VIACR, CR91) & 0xDF); 624 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
564 } 625 break;
565 if (viaparinfo->chip_info-> 626 viafb_write_reg_mask(SR2A, VIASR, 0x03, BIT0 + BIT1);
566 tmds_chip_info.output_interface == INTERFACE_TMDS) { 627 dvi_patch_skew_dvp_low();
628 via_write_reg_mask(VIACR, 0x91, 0x00, 0x20);
629 break;
630
631 case INTERFACE_TMDS:
567 /* Turn on Display period in the panel path. */ 632 /* Turn on Display period in the panel path. */
568 viafb_write_reg_mask(CR91, VIACR, 0, BIT7); 633 viafb_write_reg_mask(CR91, VIACR, 0, BIT7);
569 634
570 /* Turn on TMDS power. */ 635 /* Turn on TMDS power. */
571 viafb_write_reg_mask(CRD2, VIACR, 0, BIT3); 636 viafb_write_reg_mask(CRD2, VIACR, 0, BIT3);
637 break;
572 } 638 }
573}
574 639
640 if (viaparinfo->tmds_setting_info->iga_path == IGA2) {
641 /* Disable LCD Scaling */
642 viafb_write_reg_mask(CR79, VIACR, 0x00, BIT0);
643 }
644}
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c
index c8f24058c570..03303232e543 100644
--- a/drivers/video/via/hw.c
+++ b/drivers/video/via/hw.c
@@ -718,10 +718,6 @@ static struct rgbLUT palLUT_table[] = {
718 0x00} 718 0x00}
719}; 719};
720 720
721static void dvi_patch_skew_dvp0(void);
722static void dvi_patch_skew_dvp_low(void);
723static void set_dvi_output_path(int set_iga, int output_interface);
724static void set_lcd_output_path(int set_iga, int output_interface);
725static void load_fix_bit_crtc_reg(void); 721static void load_fix_bit_crtc_reg(void);
726static void __devinit init_gfx_chip_info(int chip_type); 722static void __devinit init_gfx_chip_info(int chip_type);
727static void __devinit init_tmds_chip_info(void); 723static void __devinit init_tmds_chip_info(void);
@@ -944,21 +940,6 @@ void viafb_set_secondary_color_register(u8 index, u8 red, u8 green, u8 blue)
944 set_color_register(index, red, green, blue); 940 set_color_register(index, red, green, blue);
945} 941}
946 942
947void viafb_set_output_path(int device, int set_iga, int output_interface)
948{
949 switch (device) {
950 case DEVICE_CRT:
951 viafb_write_reg_mask(CR36, VIACR, 0x00, BIT4 + BIT5);
952 break;
953 case DEVICE_DVI:
954 set_dvi_output_path(set_iga, output_interface);
955 break;
956 case DEVICE_LCD:
957 set_lcd_output_path(set_iga, output_interface);
958 break;
959 }
960}
961
962static void set_source_common(u8 index, u8 offset, u8 iga) 943static void set_source_common(u8 index, u8 offset, u8 iga)
963{ 944{
964 u8 value, mask = 1 << offset; 945 u8 value, mask = 1 << offset;
@@ -1045,134 +1026,6 @@ void via_set_source(u32 devices, u8 iga)
1045 set_lvds2_source(iga); 1026 set_lvds2_source(iga);
1046} 1027}
1047 1028
1048static void dvi_patch_skew_dvp0(void)
1049{
1050 /* Reset data driving first: */
1051 viafb_write_reg_mask(SR1B, VIASR, 0, BIT1);
1052 viafb_write_reg_mask(SR2A, VIASR, 0, BIT4);
1053
1054 switch (viaparinfo->chip_info->gfx_chip_name) {
1055 case UNICHROME_P4M890:
1056 {
1057 if ((viaparinfo->tmds_setting_info->h_active == 1600) &&
1058 (viaparinfo->tmds_setting_info->v_active ==
1059 1200))
1060 viafb_write_reg_mask(CR96, VIACR, 0x03,
1061 BIT0 + BIT1 + BIT2);
1062 else
1063 viafb_write_reg_mask(CR96, VIACR, 0x07,
1064 BIT0 + BIT1 + BIT2);
1065 break;
1066 }
1067
1068 case UNICHROME_P4M900:
1069 {
1070 viafb_write_reg_mask(CR96, VIACR, 0x07,
1071 BIT0 + BIT1 + BIT2 + BIT3);
1072 viafb_write_reg_mask(SR1B, VIASR, 0x02, BIT1);
1073 viafb_write_reg_mask(SR2A, VIASR, 0x10, BIT4);
1074 break;
1075 }
1076
1077 default:
1078 {
1079 break;
1080 }
1081 }
1082}
1083
1084static void dvi_patch_skew_dvp_low(void)
1085{
1086 switch (viaparinfo->chip_info->gfx_chip_name) {
1087 case UNICHROME_K8M890:
1088 {
1089 viafb_write_reg_mask(CR99, VIACR, 0x03, BIT0 + BIT1);
1090 break;
1091 }
1092
1093 case UNICHROME_P4M900:
1094 {
1095 viafb_write_reg_mask(CR99, VIACR, 0x08,
1096 BIT0 + BIT1 + BIT2 + BIT3);
1097 break;
1098 }
1099
1100 case UNICHROME_P4M890:
1101 {
1102 viafb_write_reg_mask(CR99, VIACR, 0x0F,
1103 BIT0 + BIT1 + BIT2 + BIT3);
1104 break;
1105 }
1106
1107 default:
1108 {
1109 break;
1110 }
1111 }
1112}
1113
1114static void set_dvi_output_path(int set_iga, int output_interface)
1115{
1116 switch (output_interface) {
1117 case INTERFACE_DVP0:
1118 viafb_write_reg_mask(CR6B, VIACR, 0x01, BIT0);
1119 viafb_write_reg_mask(CR6C, VIACR, 0x21, BIT0 + BIT5);
1120 viafb_write_reg_mask(SR1E, VIASR, 0xC0, BIT7 + BIT6);
1121 dvi_patch_skew_dvp0();
1122 break;
1123
1124 case INTERFACE_DVP1:
1125 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
1126 viafb_write_reg_mask(CR93, VIACR, 0x21, BIT0 + BIT5);
1127
1128 viafb_write_reg_mask(SR1E, VIASR, 0x30, BIT4 + BIT5);
1129 break;
1130 case INTERFACE_DFP_HIGH:
1131 if (viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266)
1132 via_write_reg_mask(VIACR, CR97, 0x03, 0x03);
1133
1134 viafb_write_reg_mask(SR2A, VIASR, 0x0C, BIT2 + BIT3);
1135 break;
1136
1137 case INTERFACE_DFP_LOW:
1138 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
1139 break;
1140 viafb_write_reg_mask(SR2A, VIASR, 0x03, BIT0 + BIT1);
1141 dvi_patch_skew_dvp_low();
1142 break;
1143 }
1144
1145 if (set_iga == IGA2) {
1146 /* Disable LCD Scaling */
1147 viafb_write_reg_mask(CR79, VIACR, 0x00, BIT0);
1148 }
1149}
1150
1151static void set_lcd_output_path(int set_iga, int output_interface)
1152{
1153 DEBUG_MSG(KERN_INFO
1154 "set_lcd_output_path, iga:%d,out_interface:%d\n",
1155 set_iga, output_interface);
1156
1157 viafb_write_reg_mask(CR6B, VIACR, 0x00, BIT3);
1158 viafb_write_reg_mask(CR6A, VIACR, 0x08, BIT3);
1159 switch (output_interface) {
1160 case INTERFACE_DFP:
1161 if ((UNICHROME_K8M890 == viaparinfo->chip_info->gfx_chip_name)
1162 || (UNICHROME_P4M890 ==
1163 viaparinfo->chip_info->gfx_chip_name))
1164 viafb_write_reg_mask(CR97, VIACR, 0x84,
1165 BIT7 + BIT2 + BIT1 + BIT0);
1166 case INTERFACE_DVP0:
1167 case INTERFACE_DVP1:
1168 case INTERFACE_DFP_HIGH:
1169 case INTERFACE_DFP_LOW:
1170 if (set_iga == IGA2)
1171 viafb_write_reg(CR91, VIACR, 0x00);
1172 break;
1173 }
1174}
1175
1176static void load_fix_bit_crtc_reg(void) 1029static void load_fix_bit_crtc_reg(void)
1177{ 1030{
1178 /* always set to 1 */ 1031 /* always set to 1 */
@@ -2447,9 +2300,6 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
2447 viafb_read_reg(VIACR, CR02) - 1); 2300 viafb_read_reg(VIACR, CR02) - 1);
2448 viafb_lock_crt(); 2301 viafb_lock_crt();
2449 } 2302 }
2450
2451 viafb_set_output_path(DEVICE_CRT,
2452 viaparinfo->crt_setting_info->iga_path, 0);
2453 } 2303 }
2454 2304
2455 if (viafb_DVI_ON) { 2305 if (viafb_DVI_ON) {
@@ -2469,10 +2319,6 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
2469 video_bpp, viaparinfo-> 2319 video_bpp, viaparinfo->
2470 tmds_setting_info->iga_path); 2320 tmds_setting_info->iga_path);
2471 } 2321 }
2472
2473 viafb_set_output_path(DEVICE_DVI,
2474 viaparinfo->tmds_setting_info->iga_path,
2475 viaparinfo->chip_info->tmds_chip_info.output_interface);
2476 } 2322 }
2477 2323
2478 if (viafb_LCD_ON) { 2324 if (viafb_LCD_ON) {
@@ -2493,11 +2339,6 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
2493 lvds_setting_info, 2339 lvds_setting_info,
2494 &viaparinfo->chip_info->lvds_chip_info); 2340 &viaparinfo->chip_info->lvds_chip_info);
2495 } 2341 }
2496
2497 viafb_set_output_path(DEVICE_LCD,
2498 viaparinfo->lvds_setting_info->iga_path,
2499 viaparinfo->chip_info->
2500 lvds_chip_info.output_interface);
2501 } 2342 }
2502 if (viafb_LCD2_ON) { 2343 if (viafb_LCD2_ON) {
2503 if (viafb_SAMM_ON && 2344 if (viafb_SAMM_ON &&
@@ -2517,11 +2358,6 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
2517 lvds_setting_info2, 2358 lvds_setting_info2,
2518 &viaparinfo->chip_info->lvds_chip_info2); 2359 &viaparinfo->chip_info->lvds_chip_info2);
2519 } 2360 }
2520
2521 viafb_set_output_path(DEVICE_LCD,
2522 viaparinfo->lvds_setting_info2->iga_path,
2523 viaparinfo->chip_info->
2524 lvds_chip_info2.output_interface);
2525 } 2361 }
2526 2362
2527 if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) 2363 if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700)
diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h
index c52a1d5f092d..45dee39a8b23 100644
--- a/drivers/video/via/hw.h
+++ b/drivers/video/via/hw.h
@@ -890,9 +890,6 @@ extern int viafb_LCD_ON;
890extern int viafb_DVI_ON; 890extern int viafb_DVI_ON;
891extern int viafb_hotplug; 891extern int viafb_hotplug;
892 892
893void viafb_set_output_path(int device, int set_iga,
894 int output_interface);
895
896void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, 893void viafb_fill_crtc_timing(struct crt_mode_table *crt_table,
897 struct VideoModeTable *video_mode, int bpp_byte, int set_iga); 894 struct VideoModeTable *video_mode, int bpp_byte, int set_iga);
898 895
diff --git a/drivers/video/via/lcd.c b/drivers/video/via/lcd.c
index c7de16430867..e99f933faf19 100644
--- a/drivers/video/via/lcd.c
+++ b/drivers/video/via/lcd.c
@@ -833,8 +833,36 @@ void viafb_lcd_disable(void)
833 833
834} 834}
835 835
836static void set_lcd_output_path(int set_iga, int output_interface)
837{
838 switch (output_interface) {
839 case INTERFACE_DFP:
840 if ((UNICHROME_K8M890 == viaparinfo->chip_info->gfx_chip_name)
841 || (UNICHROME_P4M890 ==
842 viaparinfo->chip_info->gfx_chip_name))
843 viafb_write_reg_mask(CR97, VIACR, 0x84,
844 BIT7 + BIT2 + BIT1 + BIT0);
845 case INTERFACE_DVP0:
846 case INTERFACE_DVP1:
847 case INTERFACE_DFP_HIGH:
848 case INTERFACE_DFP_LOW:
849 if (set_iga == IGA2)
850 viafb_write_reg(CR91, VIACR, 0x00);
851 break;
852 }
853}
854
836void viafb_lcd_enable(void) 855void viafb_lcd_enable(void)
837{ 856{
857 viafb_write_reg_mask(CR6B, VIACR, 0x00, BIT3);
858 viafb_write_reg_mask(CR6A, VIACR, 0x08, BIT3);
859 set_lcd_output_path(viaparinfo->lvds_setting_info->iga_path,
860 viaparinfo->chip_info->lvds_chip_info.output_interface);
861 if (viafb_LCD2_ON)
862 set_lcd_output_path(viaparinfo->lvds_setting_info2->iga_path,
863 viaparinfo->chip_info->
864 lvds_chip_info2.output_interface);
865
838 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) { 866 if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
839 /* DI1 pad on */ 867 /* DI1 pad on */
840 viafb_write_reg_mask(SR1E, VIASR, 0x30, 0x30); 868 viafb_write_reg_mask(SR1E, VIASR, 0x30, 0x30);