aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/via/via_modesetting.c
diff options
context:
space:
mode:
authorFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2011-05-21 18:46:31 -0400
committerFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2011-08-05 08:46:32 -0400
commitd60defb7b2c05b5c4b187171c09b714b0a00efe9 (patch)
tree4b859ae39154b83207c364bb3da123ec9485c329 /drivers/video/via/via_modesetting.c
parent936a3f770b8de7042d793272f008ef1bb08522e9 (diff)
viafb: use more compact modesetting functions
This patch replaces the old timing setup code with a redesigned one. The new code might be slightly faster as it has no conditinals and does not write the same register multiple times. Also it makes the comparison to the documentation easier. Regressions are unlikely but could happen as a lot of hardware is undocumented. Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'drivers/video/via/via_modesetting.c')
-rw-r--r--drivers/video/via/via_modesetting.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/drivers/video/via/via_modesetting.c b/drivers/video/via/via_modesetting.c
index 3cddcff88ab9..016d457b6681 100644
--- a/drivers/video/via/via_modesetting.c
+++ b/drivers/video/via/via_modesetting.c
@@ -29,6 +29,106 @@
29#include "share.h" 29#include "share.h"
30#include "debug.h" 30#include "debug.h"
31 31
32
33void via_set_primary_timing(const struct display_timing *timing)
34{
35 struct display_timing raw;
36
37 raw.hor_total = timing->hor_total / 8 - 5;
38 raw.hor_addr = timing->hor_addr / 8 - 1;
39 raw.hor_blank_start = timing->hor_blank_start / 8 - 1;
40 raw.hor_blank_end = timing->hor_blank_end / 8 - 1;
41 raw.hor_sync_start = timing->hor_sync_start / 8;
42 raw.hor_sync_end = timing->hor_sync_end / 8;
43 raw.ver_total = timing->ver_total - 2;
44 raw.ver_addr = timing->ver_addr - 1;
45 raw.ver_blank_start = timing->ver_blank_start - 1;
46 raw.ver_blank_end = timing->ver_blank_end - 1;
47 raw.ver_sync_start = timing->ver_sync_start - 1;
48 raw.ver_sync_end = timing->ver_sync_end - 1;
49
50 /* unlock timing registers */
51 via_write_reg_mask(VIACR, 0x11, 0x00, 0x80);
52
53 via_write_reg(VIACR, 0x00, raw.hor_total & 0xFF);
54 via_write_reg(VIACR, 0x01, raw.hor_addr & 0xFF);
55 via_write_reg(VIACR, 0x02, raw.hor_blank_start & 0xFF);
56 via_write_reg_mask(VIACR, 0x03, raw.hor_blank_end & 0x1F, 0x1F);
57 via_write_reg(VIACR, 0x04, raw.hor_sync_start & 0xFF);
58 via_write_reg_mask(VIACR, 0x05, (raw.hor_sync_end & 0x1F)
59 | (raw.hor_blank_end << (7 - 5) & 0x80), 0x9F);
60 via_write_reg(VIACR, 0x06, raw.ver_total & 0xFF);
61 via_write_reg_mask(VIACR, 0x07, (raw.ver_total >> 8 & 0x01)
62 | (raw.ver_addr >> (8 - 1) & 0x02)
63 | (raw.ver_sync_start >> (8 - 2) & 0x04)
64 | (raw.ver_blank_start >> (8 - 3) & 0x08)
65 | (raw.ver_total >> (9 - 5) & 0x20)
66 | (raw.ver_addr >> (9 - 6) & 0x40)
67 | (raw.ver_sync_start >> (9 - 7) & 0x80), 0xEF);
68 via_write_reg_mask(VIACR, 0x09, raw.ver_blank_start >> (9 - 5) & 0x20,
69 0x20);
70 via_write_reg(VIACR, 0x10, raw.ver_sync_start & 0xFF);
71 via_write_reg_mask(VIACR, 0x11, raw.ver_sync_end & 0x0F, 0x0F);
72 via_write_reg(VIACR, 0x12, raw.ver_addr & 0xFF);
73 via_write_reg(VIACR, 0x15, raw.ver_blank_start & 0xFF);
74 via_write_reg(VIACR, 0x16, raw.ver_blank_end & 0xFF);
75 via_write_reg_mask(VIACR, 0x33, (raw.hor_sync_start >> (8 - 4) & 0x10)
76 | (raw.hor_blank_end >> (6 - 5) & 0x20), 0x30);
77 via_write_reg_mask(VIACR, 0x35, (raw.ver_total >> 10 & 0x01)
78 | (raw.ver_sync_start >> (10 - 1) & 0x02)
79 | (raw.ver_addr >> (10 - 2) & 0x04)
80 | (raw.ver_blank_start >> (10 - 3) & 0x08), 0x0F);
81 via_write_reg_mask(VIACR, 0x36, raw.hor_total >> (8 - 3) & 0x08, 0x08);
82
83 /* lock timing registers */
84 via_write_reg_mask(VIACR, 0x11, 0x80, 0x80);
85}
86
87void via_set_secondary_timing(const struct display_timing *timing)
88{
89 struct display_timing raw;
90
91 raw.hor_total = timing->hor_total - 1;
92 raw.hor_addr = timing->hor_addr - 1;
93 raw.hor_blank_start = timing->hor_blank_start - 1;
94 raw.hor_blank_end = timing->hor_blank_end - 1;
95 raw.hor_sync_start = timing->hor_sync_start - 1;
96 raw.hor_sync_end = timing->hor_sync_end - 1;
97 raw.ver_total = timing->ver_total - 1;
98 raw.ver_addr = timing->ver_addr - 1;
99 raw.ver_blank_start = timing->ver_blank_start - 1;
100 raw.ver_blank_end = timing->ver_blank_end - 1;
101 raw.ver_sync_start = timing->ver_sync_start - 1;
102 raw.ver_sync_end = timing->ver_sync_end - 1;
103
104 via_write_reg(VIACR, 0x50, raw.hor_total & 0xFF);
105 via_write_reg(VIACR, 0x51, raw.hor_addr & 0xFF);
106 via_write_reg(VIACR, 0x52, raw.hor_blank_start & 0xFF);
107 via_write_reg(VIACR, 0x53, raw.hor_blank_end & 0xFF);
108 via_write_reg(VIACR, 0x54, (raw.hor_blank_start >> 8 & 0x07)
109 | (raw.hor_blank_end >> (8 - 3) & 0x38)
110 | (raw.hor_sync_start >> (8 - 6) & 0xC0));
111 via_write_reg_mask(VIACR, 0x55, (raw.hor_total >> 8 & 0x0F)
112 | (raw.hor_addr >> (8 - 4) & 0x70), 0x7F);
113 via_write_reg(VIACR, 0x56, raw.hor_sync_start & 0xFF);
114 via_write_reg(VIACR, 0x57, raw.hor_sync_end & 0xFF);
115 via_write_reg(VIACR, 0x58, raw.ver_total & 0xFF);
116 via_write_reg(VIACR, 0x59, raw.ver_addr & 0xFF);
117 via_write_reg(VIACR, 0x5A, raw.ver_blank_start & 0xFF);
118 via_write_reg(VIACR, 0x5B, raw.ver_blank_end & 0xFF);
119 via_write_reg(VIACR, 0x5C, (raw.ver_blank_start >> 8 & 0x07)
120 | (raw.ver_blank_end >> (8 - 3) & 0x38)
121 | (raw.hor_sync_end >> (8 - 6) & 0x40)
122 | (raw.hor_sync_start >> (10 - 7) & 0x80));
123 via_write_reg(VIACR, 0x5D, (raw.ver_total >> 8 & 0x07)
124 | (raw.ver_addr >> (8 - 3) & 0x38)
125 | (raw.hor_blank_end >> (11 - 6) & 0x40)
126 | (raw.hor_sync_start >> (11 - 7) & 0x80));
127 via_write_reg(VIACR, 0x5E, raw.ver_sync_start & 0xFF);
128 via_write_reg(VIACR, 0x5F, (raw.ver_sync_end & 0x1F)
129 | (raw.ver_sync_start >> (8 - 5) & 0xE0));
130}
131
32void via_set_primary_address(u32 addr) 132void via_set_primary_address(u32 addr)
33{ 133{
34 DEBUG_MSG(KERN_DEBUG "via_set_primary_address(0x%08X)\n", addr); 134 DEBUG_MSG(KERN_DEBUG "via_set_primary_address(0x%08X)\n", addr);