diff options
author | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2010-04-17 15:44:55 -0400 |
---|---|---|
committer | Jonathan Corbet <corbet@lwn.net> | 2010-05-07 19:17:39 -0400 |
commit | 162fc8c0c03d5b8536f14cbd2cdfb399c50c05ec (patch) | |
tree | d62f5f29718844d37075d8f485eaeee55f46ae2a /drivers/video/via | |
parent | 384c3041aeaf77d299b0d4a62481850fed86e53b (diff) |
viafb: improve misc register handling
viafb: improve misc register handling
This patch improves the misc register handling by adding a modify
function for this to via_io.h and moving expanded definitions of the
relevant ports there. The code was changed to use those to improve
readability.
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'drivers/video/via')
-rw-r--r-- | drivers/video/via/hw.c | 27 | ||||
-rw-r--r-- | drivers/video/via/share.h | 2 | ||||
-rw-r--r-- | drivers/video/via/via_io.h | 9 |
3 files changed, 17 insertions, 21 deletions
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c index b2bb24e23f33..e356fe8d8a90 100644 --- a/drivers/video/via/hw.c +++ b/drivers/video/via/hw.c | |||
@@ -1394,8 +1394,6 @@ u32 viafb_get_clk_value(int clk) | |||
1394 | /* Set VCLK*/ | 1394 | /* Set VCLK*/ |
1395 | void viafb_set_vclock(u32 CLK, int set_iga) | 1395 | void viafb_set_vclock(u32 CLK, int set_iga) |
1396 | { | 1396 | { |
1397 | unsigned char RegTemp; | ||
1398 | |||
1399 | /* H.W. Reset : ON */ | 1397 | /* H.W. Reset : ON */ |
1400 | viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7); | 1398 | viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7); |
1401 | 1399 | ||
@@ -1468,8 +1466,7 @@ void viafb_set_vclock(u32 CLK, int set_iga) | |||
1468 | } | 1466 | } |
1469 | 1467 | ||
1470 | /* Fire! */ | 1468 | /* Fire! */ |
1471 | RegTemp = inb(VIARMisc); | 1469 | via_write_misc_reg_mask(0x0C, 0x0C); /* select external clock */ |
1472 | outb(RegTemp | (BIT2 + BIT3), VIAWMisc); | ||
1473 | } | 1470 | } |
1474 | 1471 | ||
1475 | void viafb_load_crtc_timing(struct display_timing device_timing, | 1472 | void viafb_load_crtc_timing(struct display_timing device_timing, |
@@ -1713,6 +1710,7 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, | |||
1713 | int index = 0; | 1710 | int index = 0; |
1714 | int h_addr, v_addr; | 1711 | int h_addr, v_addr; |
1715 | u32 pll_D_N; | 1712 | u32 pll_D_N; |
1713 | u8 polarity = 0; | ||
1716 | 1714 | ||
1717 | for (i = 0; i < video_mode->mode_array; i++) { | 1715 | for (i = 0; i < video_mode->mode_array; i++) { |
1718 | index = i; | 1716 | index = i; |
@@ -1741,20 +1739,11 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, | |||
1741 | v_addr = crt_reg.ver_addr; | 1739 | v_addr = crt_reg.ver_addr; |
1742 | 1740 | ||
1743 | /* update polarity for CRT timing */ | 1741 | /* update polarity for CRT timing */ |
1744 | if (crt_table[index].h_sync_polarity == NEGATIVE) { | 1742 | if (crt_table[index].h_sync_polarity == NEGATIVE) |
1745 | if (crt_table[index].v_sync_polarity == NEGATIVE) | 1743 | polarity |= BIT6; |
1746 | outb((inb(VIARMisc) & (~(BIT6 + BIT7))) | | 1744 | if (crt_table[index].v_sync_polarity == NEGATIVE) |
1747 | (BIT6 + BIT7), VIAWMisc); | 1745 | polarity |= BIT7; |
1748 | else | 1746 | via_write_misc_reg_mask(polarity, BIT6 | BIT7); |
1749 | outb((inb(VIARMisc) & (~(BIT6 + BIT7))) | (BIT6), | ||
1750 | VIAWMisc); | ||
1751 | } else { | ||
1752 | if (crt_table[index].v_sync_polarity == NEGATIVE) | ||
1753 | outb((inb(VIARMisc) & (~(BIT6 + BIT7))) | (BIT7), | ||
1754 | VIAWMisc); | ||
1755 | else | ||
1756 | outb((inb(VIARMisc) & (~(BIT6 + BIT7))), VIAWMisc); | ||
1757 | } | ||
1758 | 1747 | ||
1759 | if (set_iga == IGA1) { | 1748 | if (set_iga == IGA1) { |
1760 | viafb_unlock_crt(); | 1749 | viafb_unlock_crt(); |
@@ -2123,7 +2112,7 @@ int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp, | |||
2123 | 2112 | ||
2124 | /* Fill VPIT Parameters */ | 2113 | /* Fill VPIT Parameters */ |
2125 | /* Write Misc Register */ | 2114 | /* Write Misc Register */ |
2126 | outb(VPIT.Misc, VIAWMisc); | 2115 | outb(VPIT.Misc, VIA_MISC_REG_WRITE); |
2127 | 2116 | ||
2128 | /* Write Sequencer */ | 2117 | /* Write Sequencer */ |
2129 | for (i = 1; i <= StdSR; i++) | 2118 | for (i = 1; i <= StdSR; i++) |
diff --git a/drivers/video/via/share.h b/drivers/video/via/share.h index f974c7333522..861b4142efad 100644 --- a/drivers/video/via/share.h +++ b/drivers/video/via/share.h | |||
@@ -45,8 +45,6 @@ | |||
45 | 45 | ||
46 | /* standard VGA IO port | 46 | /* standard VGA IO port |
47 | */ | 47 | */ |
48 | #define VIARMisc 0x3CC | ||
49 | #define VIAWMisc 0x3C2 | ||
50 | #define VIAStatus 0x3DA | 48 | #define VIAStatus 0x3DA |
51 | #define VIACR 0x3D4 | 49 | #define VIACR 0x3D4 |
52 | #define VIASR 0x3C4 | 50 | #define VIASR 0x3C4 |
diff --git a/drivers/video/via/via_io.h b/drivers/video/via/via_io.h index e1c1093def00..a3d2aca65540 100644 --- a/drivers/video/via/via_io.h +++ b/drivers/video/via/via_io.h | |||
@@ -29,6 +29,9 @@ | |||
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #include <linux/io.h> | 30 | #include <linux/io.h> |
31 | 31 | ||
32 | #define VIA_MISC_REG_READ 0x03CC | ||
33 | #define VIA_MISC_REG_WRITE 0x03C2 | ||
34 | |||
32 | /* | 35 | /* |
33 | * Indexed port operations. Note that these are all multi-op | 36 | * Indexed port operations. Note that these are all multi-op |
34 | * functions; every invocation will be racy if you're not holding | 37 | * functions; every invocation will be racy if you're not holding |
@@ -55,4 +58,10 @@ static inline void via_write_reg_mask(u16 port, u8 index, u8 data, u8 mask) | |||
55 | outb((data & mask) | (old & ~mask), port + 1); | 58 | outb((data & mask) | (old & ~mask), port + 1); |
56 | } | 59 | } |
57 | 60 | ||
61 | static inline void via_write_misc_reg_mask(u8 data, u8 mask) | ||
62 | { | ||
63 | u8 old = inb(VIA_MISC_REG_READ); | ||
64 | outb((data & mask) | (old & ~mask), VIA_MISC_REG_WRITE); | ||
65 | } | ||
66 | |||
58 | #endif /* __VIA_IO_H__ */ | 67 | #endif /* __VIA_IO_H__ */ |