aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/via/hw.c
diff options
context:
space:
mode:
authorFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2011-04-24 09:17:09 -0400
committerFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2011-04-24 09:17:09 -0400
commit75ec72f8c53b9f981e68704432a2e425a01f79b7 (patch)
tree6099769be8e9c8b22e365768757564c211e5c811 /drivers/video/via/hw.c
parent567b99f84ea8efe979e020bd382dd735746b526b (diff)
parentcd00b1154d3c7d711e83c3c17b831aafe6377532 (diff)
Merge branch 'viafb-cleanup' into viafb-next
Diffstat (limited to 'drivers/video/via/hw.c')
-rw-r--r--drivers/video/via/hw.c88
1 files changed, 55 insertions, 33 deletions
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c
index 56ad185b7b22..3308f471b68a 100644
--- a/drivers/video/via/hw.c
+++ b/drivers/video/via/hw.c
@@ -309,6 +309,42 @@ static struct io_reg scaling_parameters[] = {
309 {VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */ 309 {VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */
310}; 310};
311 311
312static struct io_reg common_vga[] = {
313 {VIACR, CR07, 0x10, 0x10}, /* [0] vertical total (bit 8)
314 [1] vertical display end (bit 8)
315 [2] vertical retrace start (bit 8)
316 [3] start vertical blanking (bit 8)
317 [4] line compare (bit 8)
318 [5] vertical total (bit 9)
319 [6] vertical display end (bit 9)
320 [7] vertical retrace start (bit 9) */
321 {VIACR, CR08, 0xFF, 0x00}, /* [0-4] preset row scan
322 [5-6] byte panning */
323 {VIACR, CR09, 0xDF, 0x40}, /* [0-4] max scan line
324 [5] start vertical blanking (bit 9)
325 [6] line compare (bit 9)
326 [7] scan doubling */
327 {VIACR, CR0A, 0xFF, 0x1E}, /* [0-4] cursor start
328 [5] cursor disable */
329 {VIACR, CR0B, 0xFF, 0x00}, /* [0-4] cursor end
330 [5-6] cursor skew */
331 {VIACR, CR0E, 0xFF, 0x00}, /* [0-7] cursor location (high) */
332 {VIACR, CR0F, 0xFF, 0x00}, /* [0-7] cursor location (low) */
333 {VIACR, CR11, 0xF0, 0x80}, /* [0-3] vertical retrace end
334 [6] memory refresh bandwidth
335 [7] CRTC register protect enable */
336 {VIACR, CR14, 0xFF, 0x00}, /* [0-4] underline location
337 [5] divide memory address clock by 4
338 [6] double word addressing */
339 {VIACR, CR17, 0xFF, 0x63}, /* [0-1] mapping of display address 13-14
340 [2] divide scan line clock by 2
341 [3] divide memory address clock by 2
342 [5] address wrap
343 [6] byte mode select
344 [7] sync enable */
345 {VIACR, CR18, 0xFF, 0xFF}, /* [0-7] line compare */
346};
347
312static struct fifo_depth_select display_fifo_depth_reg = { 348static struct fifo_depth_select display_fifo_depth_reg = {
313 /* IGA1 FIFO Depth_Select */ 349 /* IGA1 FIFO Depth_Select */
314 {IGA1_FIFO_DEPTH_SELECT_REG_NUM, {{SR17, 0, 7} } }, 350 {IGA1_FIFO_DEPTH_SELECT_REG_NUM, {{SR17, 0, 7} } },
@@ -771,13 +807,14 @@ static u32 get_lcd_devices(int output_interface)
771/*Set IGA path for each device*/ 807/*Set IGA path for each device*/
772void viafb_set_iga_path(void) 808void viafb_set_iga_path(void)
773{ 809{
810 int crt_iga_path = 0;
774 811
775 if (viafb_SAMM_ON == 1) { 812 if (viafb_SAMM_ON == 1) {
776 if (viafb_CRT_ON) { 813 if (viafb_CRT_ON) {
777 if (viafb_primary_dev == CRT_Device) 814 if (viafb_primary_dev == CRT_Device)
778 viaparinfo->crt_setting_info->iga_path = IGA1; 815 crt_iga_path = IGA1;
779 else 816 else
780 viaparinfo->crt_setting_info->iga_path = IGA2; 817 crt_iga_path = IGA2;
781 } 818 }
782 819
783 if (viafb_DVI_ON) { 820 if (viafb_DVI_ON) {
@@ -794,8 +831,7 @@ void viafb_set_iga_path(void)
794 UNICHROME_CLE266)) { 831 UNICHROME_CLE266)) {
795 viaparinfo-> 832 viaparinfo->
796 lvds_setting_info->iga_path = IGA2; 833 lvds_setting_info->iga_path = IGA2;
797 viaparinfo-> 834 crt_iga_path = IGA1;
798 crt_setting_info->iga_path = IGA1;
799 viaparinfo-> 835 viaparinfo->
800 tmds_setting_info->iga_path = IGA1; 836 tmds_setting_info->iga_path = IGA1;
801 } else 837 } else
@@ -815,10 +851,10 @@ void viafb_set_iga_path(void)
815 viafb_SAMM_ON = 0; 851 viafb_SAMM_ON = 0;
816 852
817 if (viafb_CRT_ON && viafb_LCD_ON) { 853 if (viafb_CRT_ON && viafb_LCD_ON) {
818 viaparinfo->crt_setting_info->iga_path = IGA1; 854 crt_iga_path = IGA1;
819 viaparinfo->lvds_setting_info->iga_path = IGA2; 855 viaparinfo->lvds_setting_info->iga_path = IGA2;
820 } else if (viafb_CRT_ON && viafb_DVI_ON) { 856 } else if (viafb_CRT_ON && viafb_DVI_ON) {
821 viaparinfo->crt_setting_info->iga_path = IGA1; 857 crt_iga_path = IGA1;
822 viaparinfo->tmds_setting_info->iga_path = IGA2; 858 viaparinfo->tmds_setting_info->iga_path = IGA2;
823 } else if (viafb_LCD_ON && viafb_DVI_ON) { 859 } else if (viafb_LCD_ON && viafb_DVI_ON) {
824 viaparinfo->tmds_setting_info->iga_path = IGA1; 860 viaparinfo->tmds_setting_info->iga_path = IGA1;
@@ -827,7 +863,7 @@ void viafb_set_iga_path(void)
827 viaparinfo->lvds_setting_info->iga_path = IGA2; 863 viaparinfo->lvds_setting_info->iga_path = IGA2;
828 viaparinfo->lvds_setting_info2->iga_path = IGA2; 864 viaparinfo->lvds_setting_info2->iga_path = IGA2;
829 } else if (viafb_CRT_ON) { 865 } else if (viafb_CRT_ON) {
830 viaparinfo->crt_setting_info->iga_path = IGA1; 866 crt_iga_path = IGA1;
831 } else if (viafb_LCD_ON) { 867 } else if (viafb_LCD_ON) {
832 viaparinfo->lvds_setting_info->iga_path = IGA2; 868 viaparinfo->lvds_setting_info->iga_path = IGA2;
833 } else if (viafb_DVI_ON) { 869 } else if (viafb_DVI_ON) {
@@ -838,7 +874,7 @@ void viafb_set_iga_path(void)
838 viaparinfo->shared->iga1_devices = 0; 874 viaparinfo->shared->iga1_devices = 0;
839 viaparinfo->shared->iga2_devices = 0; 875 viaparinfo->shared->iga2_devices = 0;
840 if (viafb_CRT_ON) { 876 if (viafb_CRT_ON) {
841 if (viaparinfo->crt_setting_info->iga_path == IGA1) 877 if (crt_iga_path == IGA1)
842 viaparinfo->shared->iga1_devices |= VIA_CRT; 878 viaparinfo->shared->iga1_devices |= VIA_CRT;
843 else 879 else
844 viaparinfo->shared->iga2_devices |= VIA_CRT; 880 viaparinfo->shared->iga2_devices |= VIA_CRT;
@@ -1167,25 +1203,17 @@ void via_odev_to_seq(struct seq_file *m, u32 odev)
1167 1203
1168static void load_fix_bit_crtc_reg(void) 1204static void load_fix_bit_crtc_reg(void)
1169{ 1205{
1206 viafb_unlock_crt();
1207
1170 /* always set to 1 */ 1208 /* always set to 1 */
1171 viafb_write_reg_mask(CR03, VIACR, 0x80, BIT7); 1209 viafb_write_reg_mask(CR03, VIACR, 0x80, BIT7);
1172 /* line compare should set all bits = 1 (extend modes) */ 1210 /* line compare should set all bits = 1 (extend modes) */
1173 viafb_write_reg(CR18, VIACR, 0xff);
1174 /* line compare should set all bits = 1 (extend modes) */
1175 viafb_write_reg_mask(CR07, VIACR, 0x10, BIT4);
1176 /* line compare should set all bits = 1 (extend modes) */
1177 viafb_write_reg_mask(CR09, VIACR, 0x40, BIT6);
1178 /* line compare should set all bits = 1 (extend modes) */
1179 viafb_write_reg_mask(CR35, VIACR, 0x10, BIT4); 1211 viafb_write_reg_mask(CR35, VIACR, 0x10, BIT4);
1180 /* line compare should set all bits = 1 (extend modes) */ 1212 /* line compare should set all bits = 1 (extend modes) */
1181 viafb_write_reg_mask(CR33, VIACR, 0x06, BIT0 + BIT1 + BIT2); 1213 viafb_write_reg_mask(CR33, VIACR, 0x06, BIT0 + BIT1 + BIT2);
1182 /*viafb_write_reg_mask(CR32, VIACR, 0x01, BIT0); */ 1214 /*viafb_write_reg_mask(CR32, VIACR, 0x01, BIT0); */
1183 /* extend mode always set to e3h */ 1215
1184 viafb_write_reg(CR17, VIACR, 0xe3); 1216 viafb_lock_crt();
1185 /* extend mode always set to 0h */
1186 viafb_write_reg(CR08, VIACR, 0x00);
1187 /* extend mode always set to 0h */
1188 viafb_write_reg(CR14, VIACR, 0x00);
1189 1217
1190 /* If K8M800, enable Prefetch Mode. */ 1218 /* If K8M800, enable Prefetch Mode. */
1191 if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_K800) 1219 if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_K800)
@@ -2038,8 +2066,6 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table,
2038 v_addr = crt_reg.ver_addr; 2066 v_addr = crt_reg.ver_addr;
2039 if (set_iga == IGA1) { 2067 if (set_iga == IGA1) {
2040 viafb_unlock_crt(); 2068 viafb_unlock_crt();
2041 viafb_write_reg(CR09, VIACR, 0x00); /*initial CR09=0 */
2042 viafb_write_reg_mask(CR11, VIACR, 0x00, BIT4 + BIT5 + BIT6);
2043 viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7); 2069 viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7);
2044 } 2070 }
2045 2071
@@ -2052,7 +2078,6 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table,
2052 break; 2078 break;
2053 } 2079 }
2054 2080
2055 load_fix_bit_crtc_reg();
2056 viafb_lock_crt(); 2081 viafb_lock_crt();
2057 viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7); 2082 viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7);
2058 viafb_load_fetch_count_reg(h_addr, bpp_byte, set_iga); 2083 viafb_load_fetch_count_reg(h_addr, bpp_byte, set_iga);
@@ -2076,8 +2101,6 @@ void __devinit viafb_init_chip_info(int chip_type)
2076 init_tmds_chip_info(); 2101 init_tmds_chip_info();
2077 init_lvds_chip_info(); 2102 init_lvds_chip_info();
2078 2103
2079 viaparinfo->crt_setting_info->iga_path = IGA1;
2080
2081 /*Set IGA path for each device */ 2104 /*Set IGA path for each device */
2082 viafb_set_iga_path(); 2105 viafb_set_iga_path();
2083 2106
@@ -2359,6 +2382,7 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
2359 outb(0x00, VIAAR); 2382 outb(0x00, VIAAR);
2360 2383
2361 /* Write Common Setting for Video Mode */ 2384 /* Write Common Setting for Video Mode */
2385 viafb_write_regx(common_vga, ARRAY_SIZE(common_vga));
2362 switch (viaparinfo->chip_info->gfx_chip_name) { 2386 switch (viaparinfo->chip_info->gfx_chip_name) {
2363 case UNICHROME_CLE266: 2387 case UNICHROME_CLE266:
2364 viafb_write_regx(CLE266_ModeXregs, NUM_TOTAL_CLE266_ModeXregs); 2388 viafb_write_regx(CLE266_ModeXregs, NUM_TOTAL_CLE266_ModeXregs);
@@ -2405,9 +2429,6 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
2405 2429
2406 viafb_write_reg_mask(0x15, VIASR, 0xA2, 0xA2); 2430 viafb_write_reg_mask(0x15, VIASR, 0xA2, 0xA2);
2407 2431
2408 /* Write CRTC */
2409 viafb_fill_crtc_timing(crt_timing, vmode_tbl, video_bpp / 8, IGA1);
2410
2411 /* Write Graphic Controller */ 2432 /* Write Graphic Controller */
2412 for (i = 0; i < StdGR; i++) 2433 for (i = 0; i < StdGR; i++)
2413 via_write_reg(VIAGR, i, VPIT.GR[i]); 2434 via_write_reg(VIAGR, i, VPIT.GR[i]);
@@ -2437,6 +2458,7 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
2437 } 2458 }
2438 } 2459 }
2439 2460
2461 load_fix_bit_crtc_reg();
2440 via_set_primary_pitch(viafbinfo->fix.line_length); 2462 via_set_primary_pitch(viafbinfo->fix.line_length);
2441 via_set_secondary_pitch(viafb_dual_fb ? viafbinfo1->fix.line_length 2463 via_set_secondary_pitch(viafb_dual_fb ? viafbinfo1->fix.line_length
2442 : viafbinfo->fix.line_length); 2464 : viafbinfo->fix.line_length);
@@ -2456,15 +2478,15 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
2456 2478
2457 /* CRT set mode */ 2479 /* CRT set mode */
2458 if (viafb_CRT_ON) { 2480 if (viafb_CRT_ON) {
2459 if (viafb_SAMM_ON && (viaparinfo->crt_setting_info->iga_path == 2481 if (viafb_SAMM_ON &&
2460 IGA2)) { 2482 viaparinfo->shared->iga2_devices & VIA_CRT) {
2461 viafb_fill_crtc_timing(crt_timing1, vmode_tbl1, 2483 viafb_fill_crtc_timing(crt_timing1, vmode_tbl1,
2462 video_bpp1 / 8, 2484 video_bpp1 / 8, IGA2);
2463 viaparinfo->crt_setting_info->iga_path);
2464 } else { 2485 } else {
2465 viafb_fill_crtc_timing(crt_timing, vmode_tbl, 2486 viafb_fill_crtc_timing(crt_timing, vmode_tbl,
2466 video_bpp / 8, 2487 video_bpp / 8,
2467 viaparinfo->crt_setting_info->iga_path); 2488 (viaparinfo->shared->iga1_devices & VIA_CRT)
2489 ? IGA1 : IGA2);
2468 } 2490 }
2469 2491
2470 /* Patch if set_hres is not 8 alignment (1366) to viafb_setmode 2492 /* Patch if set_hres is not 8 alignment (1366) to viafb_setmode