diff options
author | Joseph Chan <JosephChan@via.com.tw> | 2008-10-16 01:03:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-16 14:21:42 -0400 |
commit | 23966d5b52e6ee1f90bb343766a9703dafceae83 (patch) | |
tree | d78d665ce5fde4b68f55d7139837d53f7527e19a | |
parent | 9f291634aa2d79dee2d8a61c5bdffe166001c580 (diff) |
viafb: via_utility.c, via_utility.h, vt1636.c, vt1636.h
via_utility.c, via_utility.h: support user mode application with
additional information vt1636.c, vt1636.h: setting for chip vt1636
Signed-off-by: Joseph Chan <josephchan@via.com.tw>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/video/via/via_utility.c | 253 | ||||
-rw-r--r-- | drivers/video/via/via_utility.h | 35 | ||||
-rw-r--r-- | drivers/video/via/vt1636.c | 306 | ||||
-rw-r--r-- | drivers/video/via/vt1636.h | 44 |
4 files changed, 638 insertions, 0 deletions
diff --git a/drivers/video/via/via_utility.c b/drivers/video/via/via_utility.c new file mode 100644 index 00000000000..d53c3d54ed8 --- /dev/null +++ b/drivers/video/via/via_utility.c | |||
@@ -0,0 +1,253 @@ | |||
1 | /* | ||
2 | * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. | ||
3 | * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. | ||
4 | |||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public | ||
7 | * License as published by the Free Software Foundation; | ||
8 | * either version 2, or (at your option) any later version. | ||
9 | |||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even | ||
12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
13 | * A PARTICULAR PURPOSE.See the GNU General Public License | ||
14 | * for more details. | ||
15 | |||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., | ||
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #include "global.h" | ||
23 | |||
24 | void viafb_get_device_support_state(u32 *support_state) | ||
25 | { | ||
26 | *support_state = CRT_Device; | ||
27 | |||
28 | if (viaparinfo->chip_info->tmds_chip_info.tmds_chip_name == VT1632_TMDS) | ||
29 | *support_state |= DVI_Device; | ||
30 | |||
31 | if (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name == VT1631_LVDS) | ||
32 | *support_state |= LCD_Device; | ||
33 | } | ||
34 | |||
35 | void viafb_get_device_connect_state(u32 *connect_state) | ||
36 | { | ||
37 | bool mobile = false; | ||
38 | |||
39 | *connect_state = CRT_Device; | ||
40 | |||
41 | if (viafb_dvi_sense()) | ||
42 | *connect_state |= DVI_Device; | ||
43 | |||
44 | viafb_lcd_get_mobile_state(&mobile); | ||
45 | if (mobile) | ||
46 | *connect_state |= LCD_Device; | ||
47 | } | ||
48 | |||
49 | bool viafb_lcd_get_support_expand_state(u32 xres, u32 yres) | ||
50 | { | ||
51 | unsigned int support_state = 0; | ||
52 | |||
53 | switch (viafb_lcd_panel_id) { | ||
54 | case LCD_PANEL_ID0_640X480: | ||
55 | if ((xres < 640) && (yres < 480)) | ||
56 | support_state = true; | ||
57 | break; | ||
58 | |||
59 | case LCD_PANEL_ID1_800X600: | ||
60 | if ((xres < 800) && (yres < 600)) | ||
61 | support_state = true; | ||
62 | break; | ||
63 | |||
64 | case LCD_PANEL_ID2_1024X768: | ||
65 | if ((xres < 1024) && (yres < 768)) | ||
66 | support_state = true; | ||
67 | break; | ||
68 | |||
69 | case LCD_PANEL_ID3_1280X768: | ||
70 | if ((xres < 1280) && (yres < 768)) | ||
71 | support_state = true; | ||
72 | break; | ||
73 | |||
74 | case LCD_PANEL_ID4_1280X1024: | ||
75 | if ((xres < 1280) && (yres < 1024)) | ||
76 | support_state = true; | ||
77 | break; | ||
78 | |||
79 | case LCD_PANEL_ID5_1400X1050: | ||
80 | if ((xres < 1400) && (yres < 1050)) | ||
81 | support_state = true; | ||
82 | break; | ||
83 | |||
84 | case LCD_PANEL_ID6_1600X1200: | ||
85 | if ((xres < 1600) && (yres < 1200)) | ||
86 | support_state = true; | ||
87 | break; | ||
88 | |||
89 | case LCD_PANEL_ID7_1366X768: | ||
90 | if ((xres < 1366) && (yres < 768)) | ||
91 | support_state = true; | ||
92 | break; | ||
93 | |||
94 | case LCD_PANEL_ID8_1024X600: | ||
95 | if ((xres < 1024) && (yres < 600)) | ||
96 | support_state = true; | ||
97 | break; | ||
98 | |||
99 | case LCD_PANEL_ID9_1280X800: | ||
100 | if ((xres < 1280) && (yres < 800)) | ||
101 | support_state = true; | ||
102 | break; | ||
103 | |||
104 | case LCD_PANEL_IDA_800X480: | ||
105 | if ((xres < 800) && (yres < 480)) | ||
106 | support_state = true; | ||
107 | break; | ||
108 | |||
109 | case LCD_PANEL_IDB_1360X768: | ||
110 | if ((xres < 1360) && (yres < 768)) | ||
111 | support_state = true; | ||
112 | break; | ||
113 | |||
114 | case LCD_PANEL_IDC_480X640: | ||
115 | if ((xres < 480) && (yres < 640)) | ||
116 | support_state = true; | ||
117 | break; | ||
118 | |||
119 | default: | ||
120 | support_state = false; | ||
121 | break; | ||
122 | } | ||
123 | |||
124 | return support_state; | ||
125 | } | ||
126 | |||
127 | /*====================================================================*/ | ||
128 | /* Gamma Function Implementation*/ | ||
129 | /*====================================================================*/ | ||
130 | |||
131 | void viafb_set_gamma_table(int bpp, unsigned int *gamma_table) | ||
132 | { | ||
133 | int i, sr1a; | ||
134 | int active_device_amount = 0; | ||
135 | int device_status = viafb_DeviceStatus; | ||
136 | |||
137 | for (i = 0; i < sizeof(viafb_DeviceStatus) * 8; i++) { | ||
138 | if (device_status & 1) | ||
139 | active_device_amount++; | ||
140 | device_status >>= 1; | ||
141 | } | ||
142 | |||
143 | /* 8 bpp mode can't adjust gamma */ | ||
144 | if (bpp == 8) | ||
145 | return ; | ||
146 | |||
147 | /* Enable Gamma */ | ||
148 | switch (viaparinfo->chip_info->gfx_chip_name) { | ||
149 | case UNICHROME_CLE266: | ||
150 | case UNICHROME_K400: | ||
151 | viafb_write_reg_mask(SR16, VIASR, 0x80, BIT7); | ||
152 | break; | ||
153 | |||
154 | case UNICHROME_K800: | ||
155 | case UNICHROME_PM800: | ||
156 | case UNICHROME_CN700: | ||
157 | case UNICHROME_CX700: | ||
158 | case UNICHROME_K8M890: | ||
159 | case UNICHROME_P4M890: | ||
160 | case UNICHROME_P4M900: | ||
161 | viafb_write_reg_mask(CR33, VIACR, 0x80, BIT7); | ||
162 | break; | ||
163 | } | ||
164 | sr1a = (unsigned int)viafb_read_reg(VIASR, SR1A); | ||
165 | viafb_write_reg_mask(SR1A, VIASR, 0x0, BIT0); | ||
166 | |||
167 | /* Fill IGA1 Gamma Table */ | ||
168 | outb(0, LUT_INDEX_WRITE); | ||
169 | for (i = 0; i < 256; i++) { | ||
170 | outb(gamma_table[i] >> 16, LUT_DATA); | ||
171 | outb(gamma_table[i] >> 8 & 0xFF, LUT_DATA); | ||
172 | outb(gamma_table[i] & 0xFF, LUT_DATA); | ||
173 | } | ||
174 | |||
175 | /* If adjust Gamma value in SAMM, fill IGA1, | ||
176 | IGA2 Gamma table simultanous. */ | ||
177 | /* Switch to IGA2 Gamma Table */ | ||
178 | if ((active_device_amount > 1) && | ||
179 | !((viaparinfo->chip_info->gfx_chip_name == | ||
180 | UNICHROME_CLE266) && | ||
181 | (viaparinfo->chip_info->gfx_chip_revision < 15))) { | ||
182 | viafb_write_reg_mask(SR1A, VIASR, 0x01, BIT0); | ||
183 | viafb_write_reg_mask(CR6A, VIACR, 0x02, BIT1); | ||
184 | |||
185 | /* Fill IGA2 Gamma Table */ | ||
186 | outb(0, LUT_INDEX_WRITE); | ||
187 | for (i = 0; i < 256; i++) { | ||
188 | outb(gamma_table[i] >> 16, LUT_DATA); | ||
189 | outb(gamma_table[i] >> 8 & 0xFF, LUT_DATA); | ||
190 | outb(gamma_table[i] & 0xFF, LUT_DATA); | ||
191 | } | ||
192 | } | ||
193 | viafb_write_reg(SR1A, VIASR, sr1a); | ||
194 | } | ||
195 | |||
196 | void viafb_get_gamma_table(unsigned int *gamma_table) | ||
197 | { | ||
198 | unsigned char color_r, color_g, color_b; | ||
199 | unsigned char sr1a = 0; | ||
200 | int i; | ||
201 | |||
202 | /* Enable Gamma */ | ||
203 | switch (viaparinfo->chip_info->gfx_chip_name) { | ||
204 | case UNICHROME_CLE266: | ||
205 | case UNICHROME_K400: | ||
206 | viafb_write_reg_mask(SR16, VIASR, 0x80, BIT7); | ||
207 | break; | ||
208 | |||
209 | case UNICHROME_K800: | ||
210 | case UNICHROME_PM800: | ||
211 | case UNICHROME_CN700: | ||
212 | case UNICHROME_CX700: | ||
213 | case UNICHROME_K8M890: | ||
214 | case UNICHROME_P4M890: | ||
215 | case UNICHROME_P4M900: | ||
216 | viafb_write_reg_mask(CR33, VIACR, 0x80, BIT7); | ||
217 | break; | ||
218 | } | ||
219 | sr1a = viafb_read_reg(VIASR, SR1A); | ||
220 | viafb_write_reg_mask(SR1A, VIASR, 0x0, BIT0); | ||
221 | |||
222 | /* Reading gamma table to get color value */ | ||
223 | outb(0, LUT_INDEX_READ); | ||
224 | for (i = 0; i < 256; i++) { | ||
225 | color_r = inb(LUT_DATA); | ||
226 | color_g = inb(LUT_DATA); | ||
227 | color_b = inb(LUT_DATA); | ||
228 | gamma_table[i] = | ||
229 | ((((u32) color_r) << 16) | | ||
230 | (((u16) color_g) << 8)) | color_b; | ||
231 | } | ||
232 | viafb_write_reg(SR1A, VIASR, sr1a); | ||
233 | } | ||
234 | |||
235 | void viafb_get_gamma_support_state(int bpp, unsigned int *support_state) | ||
236 | { | ||
237 | if (bpp == 8) | ||
238 | *support_state = None_Device; | ||
239 | else | ||
240 | *support_state = CRT_Device | DVI_Device | LCD_Device; | ||
241 | } | ||
242 | |||
243 | int viafb_input_parameter_converter(int parameter_value) | ||
244 | { | ||
245 | int result; | ||
246 | |||
247 | if (parameter_value >= 1 && parameter_value <= 9) | ||
248 | result = 1 << (parameter_value - 1); | ||
249 | else | ||
250 | result = 1; | ||
251 | |||
252 | return result; | ||
253 | } | ||
diff --git a/drivers/video/via/via_utility.h b/drivers/video/via/via_utility.h new file mode 100644 index 00000000000..2fd455202eb --- /dev/null +++ b/drivers/video/via/via_utility.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. | ||
3 | * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. | ||
4 | |||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public | ||
7 | * License as published by the Free Software Foundation; | ||
8 | * either version 2, or (at your option) any later version. | ||
9 | |||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even | ||
12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
13 | * A PARTICULAR PURPOSE.See the GNU General Public License | ||
14 | * for more details. | ||
15 | |||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., | ||
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | #ifndef __VIAUTILITY_H__ | ||
22 | #define __VIAUTILITY_H__ | ||
23 | |||
24 | /* These functions are used to get infomation about device's state */ | ||
25 | void viafb_get_device_support_state(u32 *support_state); | ||
26 | void viafb_get_device_connect_state(u32 *connect_state); | ||
27 | bool viafb_lcd_get_support_expand_state(u32 xres, u32 yres); | ||
28 | |||
29 | /* These function are used to access gamma table */ | ||
30 | void viafb_set_gamma_table(int bpp, unsigned int *gamma_table); | ||
31 | void viafb_get_gamma_table(unsigned int *gamma_table); | ||
32 | void viafb_get_gamma_support_state(int bpp, unsigned int *support_state); | ||
33 | int viafb_input_parameter_converter(int parameter_value); | ||
34 | |||
35 | #endif /* __VIAUTILITY_H__ */ | ||
diff --git a/drivers/video/via/vt1636.c b/drivers/video/via/vt1636.c new file mode 100644 index 00000000000..322a9f99355 --- /dev/null +++ b/drivers/video/via/vt1636.c | |||
@@ -0,0 +1,306 @@ | |||
1 | /* | ||
2 | * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. | ||
3 | * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. | ||
4 | |||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public | ||
7 | * License as published by the Free Software Foundation; | ||
8 | * either version 2, or (at your option) any later version. | ||
9 | |||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even | ||
12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
13 | * A PARTICULAR PURPOSE.See the GNU General Public License | ||
14 | * for more details. | ||
15 | |||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., | ||
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #include "global.h" | ||
23 | |||
24 | u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information | ||
25 | *plvds_setting_info, struct lvds_chip_information *plvds_chip_info, | ||
26 | u8 index) | ||
27 | { | ||
28 | u8 data; | ||
29 | |||
30 | viaparinfo->i2c_stuff.i2c_port = plvds_chip_info->i2c_port; | ||
31 | viafb_i2c_readbyte(plvds_chip_info->lvds_chip_slave_addr, index, &data); | ||
32 | |||
33 | return data; | ||
34 | } | ||
35 | |||
36 | void viafb_gpio_i2c_write_mask_lvds(struct lvds_setting_information | ||
37 | *plvds_setting_info, struct lvds_chip_information | ||
38 | *plvds_chip_info, struct IODATA io_data) | ||
39 | { | ||
40 | int index, data; | ||
41 | |||
42 | viaparinfo->i2c_stuff.i2c_port = plvds_chip_info->i2c_port; | ||
43 | |||
44 | index = io_data.Index; | ||
45 | data = viafb_gpio_i2c_read_lvds(plvds_setting_info, plvds_chip_info, | ||
46 | index); | ||
47 | data = (data & (~io_data.Mask)) | io_data.Data; | ||
48 | |||
49 | viafb_i2c_writebyte(plvds_chip_info->lvds_chip_slave_addr, index, data); | ||
50 | } | ||
51 | |||
52 | void viafb_init_lvds_vt1636(struct lvds_setting_information | ||
53 | *plvds_setting_info, struct lvds_chip_information *plvds_chip_info) | ||
54 | { | ||
55 | int reg_num, i; | ||
56 | |||
57 | /* Common settings: */ | ||
58 | reg_num = ARRAY_SIZE(COMMON_INIT_TBL_VT1636); | ||
59 | |||
60 | for (i = 0; i < reg_num; i++) { | ||
61 | viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, | ||
62 | plvds_chip_info, | ||
63 | COMMON_INIT_TBL_VT1636[i]); | ||
64 | } | ||
65 | |||
66 | /* Input Data Mode Select */ | ||
67 | if (plvds_setting_info->device_lcd_dualedge) { | ||
68 | viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, | ||
69 | plvds_chip_info, | ||
70 | DUAL_CHANNEL_ENABLE_TBL_VT1636[0]); | ||
71 | } else { | ||
72 | viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, | ||
73 | plvds_chip_info, | ||
74 | SINGLE_CHANNEL_ENABLE_TBL_VT1636[0]); | ||
75 | } | ||
76 | |||
77 | if (plvds_setting_info->LCDDithering) { | ||
78 | viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, | ||
79 | plvds_chip_info, | ||
80 | DITHERING_ENABLE_TBL_VT1636[0]); | ||
81 | } else { | ||
82 | viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, | ||
83 | plvds_chip_info, | ||
84 | DITHERING_DISABLE_TBL_VT1636[0]); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | void viafb_enable_lvds_vt1636(struct lvds_setting_information | ||
89 | *plvds_setting_info, | ||
90 | struct lvds_chip_information *plvds_chip_info) | ||
91 | { | ||
92 | |||
93 | viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, plvds_chip_info, | ||
94 | VDD_ON_TBL_VT1636[0]); | ||
95 | |||
96 | /* Pad on: */ | ||
97 | switch (plvds_chip_info->output_interface) { | ||
98 | case INTERFACE_DVP0: | ||
99 | { | ||
100 | viafb_write_reg_mask(SR1E, VIASR, 0xC0, 0xC0); | ||
101 | break; | ||
102 | } | ||
103 | |||
104 | case INTERFACE_DVP1: | ||
105 | { | ||
106 | viafb_write_reg_mask(SR1E, VIASR, 0x30, 0x30); | ||
107 | break; | ||
108 | } | ||
109 | |||
110 | case INTERFACE_DFP_LOW: | ||
111 | { | ||
112 | viafb_write_reg_mask(SR2A, VIASR, 0x03, 0x03); | ||
113 | break; | ||
114 | } | ||
115 | |||
116 | case INTERFACE_DFP_HIGH: | ||
117 | { | ||
118 | viafb_write_reg_mask(SR2A, VIASR, 0x03, 0x0C); | ||
119 | break; | ||
120 | } | ||
121 | |||
122 | } | ||
123 | } | ||
124 | |||
125 | void viafb_disable_lvds_vt1636(struct lvds_setting_information | ||
126 | *plvds_setting_info, | ||
127 | struct lvds_chip_information *plvds_chip_info) | ||
128 | { | ||
129 | |||
130 | viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, plvds_chip_info, | ||
131 | VDD_OFF_TBL_VT1636[0]); | ||
132 | |||
133 | /* Pad off: */ | ||
134 | switch (plvds_chip_info->output_interface) { | ||
135 | case INTERFACE_DVP0: | ||
136 | { | ||
137 | viafb_write_reg_mask(SR1E, VIASR, 0x00, 0xC0); | ||
138 | break; | ||
139 | } | ||
140 | |||
141 | case INTERFACE_DVP1: | ||
142 | { | ||
143 | viafb_write_reg_mask(SR1E, VIASR, 0x00, 0x30); | ||
144 | break; | ||
145 | } | ||
146 | |||
147 | case INTERFACE_DFP_LOW: | ||
148 | { | ||
149 | viafb_write_reg_mask(SR2A, VIASR, 0x00, 0x03); | ||
150 | break; | ||
151 | } | ||
152 | |||
153 | case INTERFACE_DFP_HIGH: | ||
154 | { | ||
155 | viafb_write_reg_mask(SR2A, VIASR, 0x00, 0x0C); | ||
156 | break; | ||
157 | } | ||
158 | |||
159 | } | ||
160 | } | ||
161 | |||
162 | bool viafb_lvds_identify_vt1636(void) | ||
163 | { | ||
164 | u8 Buffer[2]; | ||
165 | |||
166 | DEBUG_MSG(KERN_INFO "viafb_lvds_identify_vt1636.\n"); | ||
167 | |||
168 | /* Sense VT1636 LVDS Transmiter */ | ||
169 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr = | ||
170 | VT1636_LVDS_I2C_ADDR; | ||
171 | |||
172 | /* Check vendor ID first: */ | ||
173 | viafb_i2c_readbyte((u8) viaparinfo->chip_info->lvds_chip_info. | ||
174 | lvds_chip_slave_addr, | ||
175 | 0x00, &Buffer[0]); | ||
176 | viafb_i2c_readbyte((u8) viaparinfo->chip_info->lvds_chip_info. | ||
177 | lvds_chip_slave_addr, | ||
178 | 0x01, &Buffer[1]); | ||
179 | |||
180 | if (!((Buffer[0] == 0x06) && (Buffer[1] == 0x11))) | ||
181 | return false; | ||
182 | |||
183 | /* Check Chip ID: */ | ||
184 | viafb_i2c_readbyte((u8) viaparinfo->chip_info->lvds_chip_info. | ||
185 | lvds_chip_slave_addr, | ||
186 | 0x02, &Buffer[0]); | ||
187 | viafb_i2c_readbyte((u8) viaparinfo->chip_info->lvds_chip_info. | ||
188 | lvds_chip_slave_addr, | ||
189 | 0x03, &Buffer[1]); | ||
190 | if ((Buffer[0] == 0x45) && (Buffer[1] == 0x33)) { | ||
191 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = | ||
192 | VT1636_LVDS; | ||
193 | return true; | ||
194 | } | ||
195 | |||
196 | return false; | ||
197 | } | ||
198 | |||
199 | static int get_clk_range_index(u32 Clk) | ||
200 | { | ||
201 | if (Clk < DPA_CLK_30M) | ||
202 | return DPA_CLK_RANGE_30M; | ||
203 | else if (Clk < DPA_CLK_50M) | ||
204 | return DPA_CLK_RANGE_30_50M; | ||
205 | else if (Clk < DPA_CLK_70M) | ||
206 | return DPA_CLK_RANGE_50_70M; | ||
207 | else if (Clk < DPA_CLK_100M) | ||
208 | return DPA_CLK_RANGE_70_100M; | ||
209 | else if (Clk < DPA_CLK_150M) | ||
210 | return DPA_CLK_RANGE_100_150M; | ||
211 | else | ||
212 | return DPA_CLK_RANGE_150M; | ||
213 | } | ||
214 | |||
215 | static int get_lvds_dpa_setting_index(int panel_size_id, | ||
216 | struct VT1636_DPA_SETTING *p_vt1636_dpasetting_tbl, | ||
217 | int tbl_size) | ||
218 | { | ||
219 | int i; | ||
220 | |||
221 | for (i = 0; i < tbl_size; i++) { | ||
222 | if (panel_size_id == p_vt1636_dpasetting_tbl->PanelSizeID) | ||
223 | return i; | ||
224 | |||
225 | p_vt1636_dpasetting_tbl++; | ||
226 | } | ||
227 | |||
228 | return 0; | ||
229 | } | ||
230 | |||
231 | static void set_dpa_vt1636(struct lvds_setting_information | ||
232 | *plvds_setting_info, struct lvds_chip_information *plvds_chip_info, | ||
233 | struct VT1636_DPA_SETTING *p_vt1636_dpa_setting) | ||
234 | { | ||
235 | struct IODATA io_data; | ||
236 | |||
237 | io_data.Index = 0x09; | ||
238 | io_data.Mask = 0x1F; | ||
239 | io_data.Data = p_vt1636_dpa_setting->CLK_SEL_ST1; | ||
240 | viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, | ||
241 | plvds_chip_info, io_data); | ||
242 | |||
243 | io_data.Index = 0x08; | ||
244 | io_data.Mask = 0x0F; | ||
245 | io_data.Data = p_vt1636_dpa_setting->CLK_SEL_ST2; | ||
246 | viafb_gpio_i2c_write_mask_lvds(plvds_setting_info, plvds_chip_info, | ||
247 | io_data); | ||
248 | } | ||
249 | |||
250 | void viafb_vt1636_patch_skew_on_vt3324( | ||
251 | struct lvds_setting_information *plvds_setting_info, | ||
252 | struct lvds_chip_information *plvds_chip_info) | ||
253 | { | ||
254 | int index, size; | ||
255 | |||
256 | DEBUG_MSG(KERN_INFO "viafb_vt1636_patch_skew_on_vt3324.\n"); | ||
257 | |||
258 | /* Graphics DPA settings: */ | ||
259 | index = get_clk_range_index(plvds_setting_info->vclk); | ||
260 | viafb_set_dpa_gfx(plvds_chip_info->output_interface, | ||
261 | &GFX_DPA_SETTING_TBL_VT3324[index]); | ||
262 | |||
263 | /* LVDS Transmitter DPA settings: */ | ||
264 | size = ARRAY_SIZE(VT1636_DPA_SETTING_TBL_VT3324); | ||
265 | index = | ||
266 | get_lvds_dpa_setting_index(plvds_setting_info->lcd_panel_id, | ||
267 | VT1636_DPA_SETTING_TBL_VT3324, size); | ||
268 | set_dpa_vt1636(plvds_setting_info, plvds_chip_info, | ||
269 | &VT1636_DPA_SETTING_TBL_VT3324[index]); | ||
270 | } | ||
271 | |||
272 | void viafb_vt1636_patch_skew_on_vt3327( | ||
273 | struct lvds_setting_information *plvds_setting_info, | ||
274 | struct lvds_chip_information *plvds_chip_info) | ||
275 | { | ||
276 | int index, size; | ||
277 | |||
278 | DEBUG_MSG(KERN_INFO "viafb_vt1636_patch_skew_on_vt3327.\n"); | ||
279 | |||
280 | /* Graphics DPA settings: */ | ||
281 | index = get_clk_range_index(plvds_setting_info->vclk); | ||
282 | viafb_set_dpa_gfx(plvds_chip_info->output_interface, | ||
283 | &GFX_DPA_SETTING_TBL_VT3327[index]); | ||
284 | |||
285 | /* LVDS Transmitter DPA settings: */ | ||
286 | size = ARRAY_SIZE(VT1636_DPA_SETTING_TBL_VT3327); | ||
287 | index = | ||
288 | get_lvds_dpa_setting_index(plvds_setting_info->lcd_panel_id, | ||
289 | VT1636_DPA_SETTING_TBL_VT3327, size); | ||
290 | set_dpa_vt1636(plvds_setting_info, plvds_chip_info, | ||
291 | &VT1636_DPA_SETTING_TBL_VT3327[index]); | ||
292 | } | ||
293 | |||
294 | void viafb_vt1636_patch_skew_on_vt3364( | ||
295 | struct lvds_setting_information *plvds_setting_info, | ||
296 | struct lvds_chip_information *plvds_chip_info) | ||
297 | { | ||
298 | int index; | ||
299 | |||
300 | DEBUG_MSG(KERN_INFO "viafb_vt1636_patch_skew_on_vt3364.\n"); | ||
301 | |||
302 | /* Graphics DPA settings: */ | ||
303 | index = get_clk_range_index(plvds_setting_info->vclk); | ||
304 | viafb_set_dpa_gfx(plvds_chip_info->output_interface, | ||
305 | &GFX_DPA_SETTING_TBL_VT3364[index]); | ||
306 | } | ||
diff --git a/drivers/video/via/vt1636.h b/drivers/video/via/vt1636.h new file mode 100644 index 00000000000..2a150c58c7e --- /dev/null +++ b/drivers/video/via/vt1636.h | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. | ||
3 | * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. | ||
4 | |||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public | ||
7 | * License as published by the Free Software Foundation; | ||
8 | * either version 2, or (at your option) any later version. | ||
9 | |||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even | ||
12 | * the implied warranty of MERCHANTABILITY or FITNESS FOR | ||
13 | * A PARTICULAR PURPOSE.See the GNU General Public License | ||
14 | * for more details. | ||
15 | |||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., | ||
19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef _VT1636_H_ | ||
23 | #define _VT1636_H_ | ||
24 | #include "chip.h" | ||
25 | bool viafb_lvds_identify_vt1636(void); | ||
26 | void viafb_init_lvds_vt1636(struct lvds_setting_information | ||
27 | *plvds_setting_info, struct lvds_chip_information *plvds_chip_info); | ||
28 | void viafb_enable_lvds_vt1636(struct lvds_setting_information | ||
29 | *plvds_setting_info, | ||
30 | struct lvds_chip_information *plvds_chip_info); | ||
31 | void viafb_disable_lvds_vt1636(struct lvds_setting_information | ||
32 | *plvds_setting_info, | ||
33 | struct lvds_chip_information *plvds_chip_info); | ||
34 | void viafb_vt1636_patch_skew_on_vt3324( | ||
35 | struct lvds_setting_information *plvds_setting_info, | ||
36 | struct lvds_chip_information *plvds_chip_info); | ||
37 | void viafb_vt1636_patch_skew_on_vt3327( | ||
38 | struct lvds_setting_information *plvds_setting_info, | ||
39 | struct lvds_chip_information *plvds_chip_info); | ||
40 | void viafb_vt1636_patch_skew_on_vt3364( | ||
41 | struct lvds_setting_information *plvds_setting_info, | ||
42 | struct lvds_chip_information *plvds_chip_info); | ||
43 | |||
44 | #endif | ||