aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2010-03-10 18:21:28 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-12 18:52:33 -0500
commitdd73d6868b9ecb4841def0c6ff0a25da27db33ba (patch)
tree353558254ac6ad9561beb6f3bac7b5254301c95c /drivers/video
parent2365dfe99495159b3395dd0eddece2f0d58f527a (diff)
viafb: split global index up
This is the first step to remove an artificial global index that was used in two ways: 1. As a pseudo index in the mode table. Pseudo as you had to search through the table to find the referenced entry. This was replaced by using a pointer to the entry. 2. As a shortcut to compare a combination of horizontal and vertical resolution at the same time. This was replaced by a "(hres<<16) | vres" which is good enough for now and the near future. If vres or hres become greater than 2^16 this might indeed cause problems but this solution allows to split this indexing mess up without the requirement to do even more code changes. This is a big change that will allow more clean ups. It should be a bit faster but that is probably not relevant for normal operation. No regressions expected but as this is a relatively big step heavy testing is appreciated. Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de> Cc: Joseph Chan <JosephChan@via.com.tw> Cc: Scott Fang <ScottFang@viatech.com.cn> Cc: Krzysztof Helt <krzysztof.h1@poczta.fm> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/via/dvi.c56
-rw-r--r--drivers/video/via/dvi.h4
-rw-r--r--drivers/video/via/hw.c151
-rw-r--r--drivers/video/via/hw.h12
-rw-r--r--drivers/video/via/lcd.c148
-rw-r--r--drivers/video/via/viafbdev.c49
-rw-r--r--drivers/video/via/viafbdev.h3
-rw-r--r--drivers/video/via/viamode.c180
-rw-r--r--drivers/video/via/viamode.h8
9 files changed, 225 insertions, 386 deletions
diff --git a/drivers/video/via/dvi.c b/drivers/video/via/dvi.c
index 67b36932212b..92f75934e124 100644
--- a/drivers/video/via/dvi.c
+++ b/drivers/video/via/dvi.c
@@ -23,8 +23,6 @@
23static void tmds_register_write(int index, u8 data); 23static void tmds_register_write(int index, u8 data);
24static int tmds_register_read(int index); 24static int tmds_register_read(int index);
25static int tmds_register_read_bytes(int index, u8 *buff, int buff_len); 25static int tmds_register_read_bytes(int index, u8 *buff, int buff_len);
26static int check_reduce_blanking_mode(int mode_index,
27 int refresh_rate);
28static int dvi_get_panel_size_from_DDCv1(void); 26static int dvi_get_panel_size_from_DDCv1(void);
29static int dvi_get_panel_size_from_DDCv2(void); 27static int dvi_get_panel_size_from_DDCv2(void);
30static unsigned char dvi_get_panel_info(void); 28static unsigned char dvi_get_panel_info(void);
@@ -189,42 +187,14 @@ static int tmds_register_read_bytes(int index, u8 *buff, int buff_len)
189 return 0; 187 return 0;
190} 188}
191 189
192static int check_reduce_blanking_mode(int mode_index,
193 int refresh_rate)
194{
195 if (refresh_rate != 60)
196 return false;
197
198 switch (mode_index) {
199 /* Following modes have reduce blanking mode. */
200 case VIA_RES_1360X768:
201 case VIA_RES_1400X1050:
202 case VIA_RES_1440X900:
203 case VIA_RES_1600X900:
204 case VIA_RES_1680X1050:
205 case VIA_RES_1920X1080:
206 case VIA_RES_1920X1200:
207 break;
208
209 default:
210 DEBUG_MSG(KERN_INFO
211 "This dvi mode %d have no reduce blanking mode!\n",
212 mode_index);
213 return false;
214 }
215
216 return true;
217}
218
219/* DVI Set Mode */ 190/* DVI Set Mode */
220void viafb_dvi_set_mode(int video_index, int mode_bpp, int set_iga) 191void viafb_dvi_set_mode(struct VideoModeTable *mode, int mode_bpp,
192 int set_iga)
221{ 193{
222 struct VideoModeTable *videoMode = NULL; 194 struct VideoModeTable *rb_mode;
223 struct crt_mode_table *pDviTiming; 195 struct crt_mode_table *pDviTiming;
224 unsigned long desirePixelClock, maxPixelClock; 196 unsigned long desirePixelClock, maxPixelClock;
225 int status = 0; 197 pDviTiming = mode->crtc;
226 videoMode = viafb_get_modetbl_pointer(video_index);
227 pDviTiming = videoMode->crtc;
228 desirePixelClock = pDviTiming->clk / 1000000; 198 desirePixelClock = pDviTiming->clk / 1000000;
229 maxPixelClock = (unsigned long)viaparinfo-> 199 maxPixelClock = (unsigned long)viaparinfo->
230 tmds_setting_info->max_pixel_clock; 200 tmds_setting_info->max_pixel_clock;
@@ -232,20 +202,14 @@ void viafb_dvi_set_mode(int video_index, int mode_bpp, int set_iga)
232 DEBUG_MSG(KERN_INFO "\nDVI_set_mode!!\n"); 202 DEBUG_MSG(KERN_INFO "\nDVI_set_mode!!\n");
233 203
234 if ((maxPixelClock != 0) && (desirePixelClock > maxPixelClock)) { 204 if ((maxPixelClock != 0) && (desirePixelClock > maxPixelClock)) {
235 /*Check if reduce-blanking mode is exist */ 205 rb_mode = viafb_get_rb_mode(mode->crtc[0].crtc.hor_addr,
236 status = 206 mode->crtc[0].crtc.ver_addr);
237 check_reduce_blanking_mode(video_index, 207 if (rb_mode) {
238 pDviTiming->refresh_rate); 208 mode = rb_mode;
239 if (status) { 209 pDviTiming = rb_mode->crtc;
240 video_index += 100; /*Use reduce-blanking mode */
241 videoMode = viafb_get_modetbl_pointer(video_index);
242 pDviTiming = videoMode->crtc;
243 DEBUG_MSG(KERN_INFO
244 "DVI use reduce blanking mode %d!!\n",
245 video_index);
246 } 210 }
247 } 211 }
248 viafb_fill_crtc_timing(pDviTiming, video_index, mode_bpp / 8, set_iga); 212 viafb_fill_crtc_timing(pDviTiming, mode, mode_bpp / 8, set_iga);
249 viafb_set_output_path(DEVICE_DVI, set_iga, 213 viafb_set_output_path(DEVICE_DVI, set_iga,
250 viaparinfo->chip_info->tmds_chip_info.output_interface); 214 viaparinfo->chip_info->tmds_chip_info.output_interface);
251} 215}
diff --git a/drivers/video/via/dvi.h b/drivers/video/via/dvi.h
index e1ec37fb0dc3..5ca2ffc15a3f 100644
--- a/drivers/video/via/dvi.h
+++ b/drivers/video/via/dvi.h
@@ -53,12 +53,12 @@
53#define DEV_CONNECT_DVI 0x01 53#define DEV_CONNECT_DVI 0x01
54#define DEV_CONNECT_HDMI 0x02 54#define DEV_CONNECT_HDMI 0x02
55 55
56struct VideoModeTable *viafb_get_cea_mode_tbl_pointer(int Index);
57int viafb_dvi_sense(void); 56int viafb_dvi_sense(void);
58void viafb_dvi_disable(void); 57void viafb_dvi_disable(void);
59void viafb_dvi_enable(void); 58void viafb_dvi_enable(void);
60int viafb_tmds_trasmitter_identify(void); 59int viafb_tmds_trasmitter_identify(void);
61void viafb_init_dvi_size(void); 60void viafb_init_dvi_size(void);
62void viafb_dvi_set_mode(int video_index, int mode_bpp, int set_iga); 61void viafb_dvi_set_mode(struct VideoModeTable *videoMode, int mode_bpp,
62 int set_iga);
63 63
64#endif /* __DVI_H__ */ 64#endif /* __DVI_H__ */
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c
index 3e083ff67ae2..726fbd115979 100644
--- a/drivers/video/via/hw.c
+++ b/drivers/video/via/hw.c
@@ -524,7 +524,6 @@ static void dvi_patch_skew_dvp1(void);
524static void dvi_patch_skew_dvp_low(void); 524static void dvi_patch_skew_dvp_low(void);
525static void set_dvi_output_path(int set_iga, int output_interface); 525static void set_dvi_output_path(int set_iga, int output_interface);
526static void set_lcd_output_path(int set_iga, int output_interface); 526static void set_lcd_output_path(int set_iga, int output_interface);
527static int search_mode_setting(int ModeInfoIndex);
528static void load_fix_bit_crtc_reg(void); 527static void load_fix_bit_crtc_reg(void);
529static void init_gfx_chip_info(struct pci_dev *pdev, 528static void init_gfx_chip_info(struct pci_dev *pdev,
530 const struct pci_device_id *pdi); 529 const struct pci_device_id *pdi);
@@ -987,49 +986,6 @@ static void set_lcd_output_path(int set_iga, int output_interface)
987 } 986 }
988} 987}
989 988
990/* Search Mode Index */
991static int search_mode_setting(int ModeInfoIndex)
992{
993 int i = 0;
994
995 while ((i < NUM_TOTAL_MODETABLE) &&
996 (ModeInfoIndex != CLE266Modes[i].ModeIndex))
997 i++;
998 if (i >= NUM_TOTAL_MODETABLE)
999 i = 0;
1000 return i;
1001
1002}
1003
1004struct VideoModeTable *viafb_get_modetbl_pointer(int Index)
1005{
1006 struct VideoModeTable *TmpTbl = NULL;
1007 TmpTbl = &CLE266Modes[search_mode_setting(Index)];
1008 return TmpTbl;
1009}
1010
1011struct VideoModeTable *viafb_get_cea_mode_tbl_pointer(int Index)
1012{
1013 struct VideoModeTable *TmpTbl = NULL;
1014 int i = 0;
1015 while ((i < NUM_TOTAL_CEA_MODES) &&
1016 (Index != CEA_HDMI_Modes[i].ModeIndex))
1017 i++;
1018 if ((i < NUM_TOTAL_CEA_MODES))
1019 TmpTbl = &CEA_HDMI_Modes[i];
1020 else {
1021 /*Still use general timing if don't find CEA timing */
1022 i = 0;
1023 while ((i < NUM_TOTAL_MODETABLE) &&
1024 (Index != CLE266Modes[i].ModeIndex))
1025 i++;
1026 if (i >= NUM_TOTAL_MODETABLE)
1027 i = 0;
1028 TmpTbl = &CLE266Modes[i];
1029 }
1030 return TmpTbl;
1031}
1032
1033static void load_fix_bit_crtc_reg(void) 989static void load_fix_bit_crtc_reg(void)
1034{ 990{
1035 /* always set to 1 */ 991 /* always set to 1 */
@@ -1835,17 +1791,14 @@ void viafb_set_color_depth(int bpp_byte, int set_iga)
1835} 1791}
1836 1792
1837void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, 1793void viafb_fill_crtc_timing(struct crt_mode_table *crt_table,
1838 int mode_index, int bpp_byte, int set_iga) 1794 struct VideoModeTable *video_mode, int bpp_byte, int set_iga)
1839{ 1795{
1840 struct VideoModeTable *video_mode;
1841 struct display_timing crt_reg; 1796 struct display_timing crt_reg;
1842 int i; 1797 int i;
1843 int index = 0; 1798 int index = 0;
1844 int h_addr, v_addr; 1799 int h_addr, v_addr;
1845 u32 pll_D_N; 1800 u32 pll_D_N;
1846 1801
1847 video_mode = &CLE266Modes[search_mode_setting(mode_index)];
1848
1849 for (i = 0; i < video_mode->mode_array; i++) { 1802 for (i = 0; i < video_mode->mode_array; i++) {
1850 index = i; 1803 index = i;
1851 1804
@@ -1858,8 +1811,10 @@ void viafb_fill_crtc_timing(struct crt_mode_table *crt_table,
1858 1811
1859 /* Mode 640x480 has border, but LCD/DFP didn't have border. */ 1812 /* Mode 640x480 has border, but LCD/DFP didn't have border. */
1860 /* So we would delete border. */ 1813 /* So we would delete border. */
1861 if ((viafb_LCD_ON | viafb_DVI_ON) && (mode_index == VIA_RES_640X480) 1814 if ((viafb_LCD_ON | viafb_DVI_ON)
1862 && (viaparinfo->crt_setting_info->refresh_rate == 60)) { 1815 && video_mode->crtc[0].crtc.hor_addr == 640
1816 && video_mode->crtc[0].crtc.ver_addr == 480
1817 && viaparinfo->crt_setting_info->refresh_rate == 60) {
1863 /* The border is 8 pixels. */ 1818 /* The border is 8 pixels. */
1864 crt_reg.hor_blank_start = crt_reg.hor_blank_start - 8; 1819 crt_reg.hor_blank_start = crt_reg.hor_blank_start - 8;
1865 1820
@@ -2195,28 +2150,19 @@ static void set_display_channel(void)
2195 } 2150 }
2196} 2151}
2197 2152
2198int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp, 2153int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
2199 int vmode_index1, int hor_res1, int ver_res1, int video_bpp1) 2154 struct VideoModeTable *vmode_tbl1, int video_bpp1)
2200{ 2155{
2201 int i, j; 2156 int i, j;
2202 int port; 2157 int port;
2203 u8 value, index, mask; 2158 u8 value, index, mask;
2204 struct VideoModeTable *vmode_tbl;
2205 struct crt_mode_table *crt_timing; 2159 struct crt_mode_table *crt_timing;
2206 struct VideoModeTable *vmode_tbl1 = NULL;
2207 struct crt_mode_table *crt_timing1 = NULL; 2160 struct crt_mode_table *crt_timing1 = NULL;
2208 2161
2209 DEBUG_MSG(KERN_INFO "Set Mode!!\n");
2210 DEBUG_MSG(KERN_INFO
2211 "vmode_index=%d hor_res=%d ver_res=%d video_bpp=%d\n",
2212 vmode_index, hor_res, ver_res, video_bpp);
2213
2214 device_screen_off(); 2162 device_screen_off();
2215 vmode_tbl = &CLE266Modes[search_mode_setting(vmode_index)];
2216 crt_timing = vmode_tbl->crtc; 2163 crt_timing = vmode_tbl->crtc;
2217 2164
2218 if (viafb_SAMM_ON == 1) { 2165 if (viafb_SAMM_ON == 1) {
2219 vmode_tbl1 = &CLE266Modes[search_mode_setting(vmode_index1)];
2220 crt_timing1 = vmode_tbl1->crtc; 2166 crt_timing1 = vmode_tbl1->crtc;
2221 } 2167 }
2222 2168
@@ -2272,7 +2218,7 @@ int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp,
2272 viafb_set_iga_path(); 2218 viafb_set_iga_path();
2273 2219
2274 /* Write CRTC */ 2220 /* Write CRTC */
2275 viafb_fill_crtc_timing(crt_timing, vmode_index, video_bpp / 8, IGA1); 2221 viafb_fill_crtc_timing(crt_timing, vmode_tbl, video_bpp / 8, IGA1);
2276 2222
2277 /* Write Graphic Controller */ 2223 /* Write Graphic Controller */
2278 for (i = 0; i < StdGR; i++) { 2224 for (i = 0; i < StdGR; i++) {
@@ -2292,59 +2238,16 @@ int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp,
2292 2238
2293 /* Update Patch Register */ 2239 /* Update Patch Register */
2294 2240
2295 if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) 2241 if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266
2296 || (viaparinfo->chip_info->gfx_chip_name == UNICHROME_K400)) { 2242 || viaparinfo->chip_info->gfx_chip_name == UNICHROME_K400)
2297 for (i = 0; i < NUM_TOTAL_PATCH_MODE; i++) { 2243 && vmode_tbl->crtc[0].crtc.hor_addr == 1024
2298 if (res_patch_table[i].mode_index == vmode_index) { 2244 && vmode_tbl->crtc[0].crtc.ver_addr == 768) {
2299 for (j = 0; 2245 for (j = 0; j < res_patch_table[0].table_length; j++) {
2300 j < res_patch_table[i].table_length; j++) { 2246 index = res_patch_table[0].io_reg_table[j].index;
2301 index = 2247 port = res_patch_table[0].io_reg_table[j].port;
2302 res_patch_table[i]. 2248 value = res_patch_table[0].io_reg_table[j].value;
2303 io_reg_table[j].index; 2249 mask = res_patch_table[0].io_reg_table[j].mask;
2304 port = 2250 viafb_write_reg_mask(index, port, value, mask);
2305 res_patch_table[i].
2306 io_reg_table[j].port;
2307 value =
2308 res_patch_table[i].
2309 io_reg_table[j].value;
2310 mask =
2311 res_patch_table[i].
2312 io_reg_table[j].mask;
2313 viafb_write_reg_mask(index, port, value,
2314 mask);
2315 }
2316 }
2317 }
2318 }
2319
2320 if (viafb_SAMM_ON == 1) {
2321 if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
2322 || (viaparinfo->chip_info->gfx_chip_name ==
2323 UNICHROME_K400)) {
2324 for (i = 0; i < NUM_TOTAL_PATCH_MODE; i++) {
2325 if (res_patch_table[i].mode_index ==
2326 vmode_index1) {
2327 for (j = 0;
2328 j <
2329 res_patch_table[i].
2330 table_length; j++) {
2331 index =
2332 res_patch_table[i].
2333 io_reg_table[j].index;
2334 port =
2335 res_patch_table[i].
2336 io_reg_table[j].port;
2337 value =
2338 res_patch_table[i].
2339 io_reg_table[j].value;
2340 mask =
2341 res_patch_table[i].
2342 io_reg_table[j].mask;
2343 viafb_write_reg_mask(index,
2344 port, value, mask);
2345 }
2346 }
2347 }
2348 } 2251 }
2349 } 2252 }
2350 2253
@@ -2359,11 +2262,11 @@ int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp,
2359 if (viafb_CRT_ON) { 2262 if (viafb_CRT_ON) {
2360 if (viafb_SAMM_ON && (viaparinfo->crt_setting_info->iga_path == 2263 if (viafb_SAMM_ON && (viaparinfo->crt_setting_info->iga_path ==
2361 IGA2)) { 2264 IGA2)) {
2362 viafb_fill_crtc_timing(crt_timing1, vmode_index1, 2265 viafb_fill_crtc_timing(crt_timing1, vmode_tbl1,
2363 video_bpp1 / 8, 2266 video_bpp1 / 8,
2364 viaparinfo->crt_setting_info->iga_path); 2267 viaparinfo->crt_setting_info->iga_path);
2365 } else { 2268 } else {
2366 viafb_fill_crtc_timing(crt_timing, vmode_index, 2269 viafb_fill_crtc_timing(crt_timing, vmode_tbl,
2367 video_bpp / 8, 2270 video_bpp / 8,
2368 viaparinfo->crt_setting_info->iga_path); 2271 viaparinfo->crt_setting_info->iga_path);
2369 } 2272 }
@@ -2373,7 +2276,7 @@ int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp,
2373 /* Patch if set_hres is not 8 alignment (1366) to viafb_setmode 2276 /* Patch if set_hres is not 8 alignment (1366) to viafb_setmode
2374 to 8 alignment (1368),there is several pixels (2 pixels) 2277 to 8 alignment (1368),there is several pixels (2 pixels)
2375 on right side of screen. */ 2278 on right side of screen. */
2376 if (hor_res % 8) { 2279 if (vmode_tbl->crtc[0].crtc.hor_addr % 8) {
2377 viafb_unlock_crt(); 2280 viafb_unlock_crt();
2378 viafb_write_reg(CR02, VIACR, 2281 viafb_write_reg(CR02, VIACR,
2379 viafb_read_reg(VIACR, CR02) - 1); 2282 viafb_read_reg(VIACR, CR02) - 1);
@@ -2384,14 +2287,14 @@ int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp,
2384 if (viafb_DVI_ON) { 2287 if (viafb_DVI_ON) {
2385 if (viafb_SAMM_ON && 2288 if (viafb_SAMM_ON &&
2386 (viaparinfo->tmds_setting_info->iga_path == IGA2)) { 2289 (viaparinfo->tmds_setting_info->iga_path == IGA2)) {
2387 viafb_dvi_set_mode(viafb_get_mode_index 2290 viafb_dvi_set_mode(viafb_get_mode
2388 (viaparinfo->tmds_setting_info->h_active, 2291 (viaparinfo->tmds_setting_info->h_active,
2389 viaparinfo->tmds_setting_info-> 2292 viaparinfo->tmds_setting_info->
2390 v_active), 2293 v_active),
2391 video_bpp1, viaparinfo-> 2294 video_bpp1, viaparinfo->
2392 tmds_setting_info->iga_path); 2295 tmds_setting_info->iga_path);
2393 } else { 2296 } else {
2394 viafb_dvi_set_mode(viafb_get_mode_index 2297 viafb_dvi_set_mode(viafb_get_mode
2395 (viaparinfo->tmds_setting_info->h_active, 2298 (viaparinfo->tmds_setting_info->h_active,
2396 viaparinfo-> 2299 viaparinfo->
2397 tmds_setting_info->v_active), 2300 tmds_setting_info->v_active),
@@ -2445,8 +2348,8 @@ int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp,
2445 2348
2446 /* If set mode normally, save resolution information for hot-plug . */ 2349 /* If set mode normally, save resolution information for hot-plug . */
2447 if (!viafb_hotplug) { 2350 if (!viafb_hotplug) {
2448 viafb_hotplug_Xres = hor_res; 2351 viafb_hotplug_Xres = vmode_tbl->crtc[0].crtc.hor_addr;
2449 viafb_hotplug_Yres = ver_res; 2352 viafb_hotplug_Yres = vmode_tbl->crtc[0].crtc.ver_addr;
2450 viafb_hotplug_bpp = video_bpp; 2353 viafb_hotplug_bpp = video_bpp;
2451 viafb_hotplug_refresh = viafb_refresh; 2354 viafb_hotplug_refresh = viafb_refresh;
2452 2355
@@ -2706,13 +2609,11 @@ void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\
2706 2609
2707/*According var's xres, yres fill var's other timing information*/ 2610/*According var's xres, yres fill var's other timing information*/
2708void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh, 2611void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh,
2709 int mode_index) 2612 struct VideoModeTable *vmode_tbl)
2710{ 2613{
2711 struct VideoModeTable *vmode_tbl = NULL;
2712 struct crt_mode_table *crt_timing = NULL; 2614 struct crt_mode_table *crt_timing = NULL;
2713 struct display_timing crt_reg; 2615 struct display_timing crt_reg;
2714 int i = 0, index = 0; 2616 int i = 0, index = 0;
2715 vmode_tbl = &CLE266Modes[search_mode_setting(mode_index)];
2716 crt_timing = vmode_tbl->crtc; 2617 crt_timing = vmode_tbl->crtc;
2717 for (i = 0; i < vmode_tbl->mode_array; i++) { 2618 for (i = 0; i < vmode_tbl->mode_array; i++) {
2718 index = i; 2619 index = i;
diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h
index b874d952b446..789c58a7bab3 100644
--- a/drivers/video/via/hw.h
+++ b/drivers/video/via/hw.h
@@ -22,6 +22,7 @@
22#ifndef __HW_H__ 22#ifndef __HW_H__
23#define __HW_H__ 23#define __HW_H__
24 24
25#include "viamode.h"
25#include "global.h" 26#include "global.h"
26 27
27/*************************************************** 28/***************************************************
@@ -874,8 +875,9 @@ extern int viafb_hotplug;
874void viafb_write_reg_mask(u8 index, int io_port, u8 data, u8 mask); 875void viafb_write_reg_mask(u8 index, int io_port, u8 data, u8 mask);
875void viafb_set_output_path(int device, int set_iga, 876void viafb_set_output_path(int device, int set_iga,
876 int output_interface); 877 int output_interface);
878
877void viafb_fill_crtc_timing(struct crt_mode_table *crt_table, 879void viafb_fill_crtc_timing(struct crt_mode_table *crt_table,
878 int mode_index, int bpp_byte, int set_iga); 880 struct VideoModeTable *video_mode, int bpp_byte, int set_iga);
879 881
880void viafb_set_vclock(u32 CLK, int set_iga); 882void viafb_set_vclock(u32 CLK, int set_iga);
881void viafb_load_reg(int timing_value, int viafb_load_reg_num, 883void viafb_load_reg(int timing_value, int viafb_load_reg_num,
@@ -891,16 +893,16 @@ void viafb_lock_crt(void);
891void viafb_unlock_crt(void); 893void viafb_unlock_crt(void);
892void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga); 894void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga);
893void viafb_write_regx(struct io_reg RegTable[], int ItemNum); 895void viafb_write_regx(struct io_reg RegTable[], int ItemNum);
894struct VideoModeTable *viafb_get_modetbl_pointer(int Index);
895u32 viafb_get_clk_value(int clk); 896u32 viafb_get_clk_value(int clk);
896void viafb_load_FIFO_reg(int set_iga, int hor_active, int ver_active); 897void viafb_load_FIFO_reg(int set_iga, int hor_active, int ver_active);
897void viafb_set_color_depth(int bpp_byte, int set_iga); 898void viafb_set_color_depth(int bpp_byte, int set_iga);
898void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\ 899void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\
899 *p_gfx_dpa_setting); 900 *p_gfx_dpa_setting);
900 901
901int viafb_setmode(int vmode_index, int hor_res, int ver_res, 902int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
902 int video_bpp, int vmode_index1, int hor_res1, 903 struct VideoModeTable *vmode_tbl1, int video_bpp1);
903 int ver_res1, int video_bpp1); 904void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh,
905 struct VideoModeTable *vmode_tbl);
904void viafb_init_chip_info(struct pci_dev *pdev, 906void viafb_init_chip_info(struct pci_dev *pdev,
905 const struct pci_device_id *pdi); 907 const struct pci_device_id *pdi);
906void viafb_init_dac(int set_iga); 908void viafb_init_dac(int set_iga);
diff --git a/drivers/video/via/lcd.c b/drivers/video/via/lcd.c
index 09353e2b92f6..e0ab605f0170 100644
--- a/drivers/video/via/lcd.c
+++ b/drivers/video/via/lcd.c
@@ -22,6 +22,8 @@
22#include "global.h" 22#include "global.h"
23#include "lcdtbl.h" 23#include "lcdtbl.h"
24 24
25#define viafb_compact_res(x, y) (((x)<<16)|(y))
26
25static struct iga2_shadow_crtc_timing iga2_shadow_crtc_reg = { 27static struct iga2_shadow_crtc_timing iga2_shadow_crtc_reg = {
26 /* IGA2 Shadow Horizontal Total */ 28 /* IGA2 Shadow Horizontal Total */
27 {IGA2_SHADOW_HOR_TOTAL_REG_NUM, {{CR6D, 0, 7}, {CR71, 3, 3} } }, 29 {IGA2_SHADOW_HOR_TOTAL_REG_NUM, {{CR6D, 0, 7}, {CR71, 3, 3} } },
@@ -576,22 +578,21 @@ static void load_lcd_scaling(int set_hres, int set_vres, int panel_hres,
576static void load_lcd_k400_patch_tbl(int set_hres, int set_vres, 578static void load_lcd_k400_patch_tbl(int set_hres, int set_vres,
577 int panel_id) 579 int panel_id)
578{ 580{
579 int vmode_index; 581 u32 compact_mode = viafb_compact_res(set_hres, set_vres);
580 int reg_num = 0; 582 int reg_num = 0;
581 struct io_reg *lcd_patch_reg = NULL; 583 struct io_reg *lcd_patch_reg = NULL;
582 584
583 vmode_index = viafb_get_mode_index(set_hres, set_vres);
584 switch (panel_id) { 585 switch (panel_id) {
585 /* LCD 800x600 */ 586 /* LCD 800x600 */
586 case LCD_PANEL_ID1_800X600: 587 case LCD_PANEL_ID1_800X600:
587 switch (vmode_index) { 588 switch (compact_mode) {
588 case VIA_RES_640X400: 589 case viafb_compact_res(640, 400):
589 case VIA_RES_640X480: 590 case viafb_compact_res(640, 480):
590 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_8X6; 591 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_8X6;
591 lcd_patch_reg = K400_LCD_RES_6X4_8X6; 592 lcd_patch_reg = K400_LCD_RES_6X4_8X6;
592 break; 593 break;
593 case VIA_RES_720X480: 594 case viafb_compact_res(720, 480):
594 case VIA_RES_720X576: 595 case viafb_compact_res(720, 576):
595 reg_num = NUM_TOTAL_K400_LCD_RES_7X4_8X6; 596 reg_num = NUM_TOTAL_K400_LCD_RES_7X4_8X6;
596 lcd_patch_reg = K400_LCD_RES_7X4_8X6; 597 lcd_patch_reg = K400_LCD_RES_7X4_8X6;
597 break; 598 break;
@@ -600,18 +601,18 @@ static void load_lcd_k400_patch_tbl(int set_hres, int set_vres,
600 601
601 /* LCD 1024x768 */ 602 /* LCD 1024x768 */
602 case LCD_PANEL_ID2_1024X768: 603 case LCD_PANEL_ID2_1024X768:
603 switch (vmode_index) { 604 switch (compact_mode) {
604 case VIA_RES_640X400: 605 case viafb_compact_res(640, 400):
605 case VIA_RES_640X480: 606 case viafb_compact_res(640, 480):
606 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_10X7; 607 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_10X7;
607 lcd_patch_reg = K400_LCD_RES_6X4_10X7; 608 lcd_patch_reg = K400_LCD_RES_6X4_10X7;
608 break; 609 break;
609 case VIA_RES_720X480: 610 case viafb_compact_res(720, 480):
610 case VIA_RES_720X576: 611 case viafb_compact_res(720, 576):
611 reg_num = NUM_TOTAL_K400_LCD_RES_7X4_10X7; 612 reg_num = NUM_TOTAL_K400_LCD_RES_7X4_10X7;
612 lcd_patch_reg = K400_LCD_RES_7X4_10X7; 613 lcd_patch_reg = K400_LCD_RES_7X4_10X7;
613 break; 614 break;
614 case VIA_RES_800X600: 615 case viafb_compact_res(800, 600):
615 reg_num = NUM_TOTAL_K400_LCD_RES_8X6_10X7; 616 reg_num = NUM_TOTAL_K400_LCD_RES_8X6_10X7;
616 lcd_patch_reg = K400_LCD_RES_8X6_10X7; 617 lcd_patch_reg = K400_LCD_RES_8X6_10X7;
617 break; 618 break;
@@ -620,22 +621,22 @@ static void load_lcd_k400_patch_tbl(int set_hres, int set_vres,
620 621
621 /* LCD 1280x1024 */ 622 /* LCD 1280x1024 */
622 case LCD_PANEL_ID4_1280X1024: 623 case LCD_PANEL_ID4_1280X1024:
623 switch (vmode_index) { 624 switch (compact_mode) {
624 case VIA_RES_640X400: 625 case viafb_compact_res(640, 400):
625 case VIA_RES_640X480: 626 case viafb_compact_res(640, 480):
626 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_12X10; 627 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_12X10;
627 lcd_patch_reg = K400_LCD_RES_6X4_12X10; 628 lcd_patch_reg = K400_LCD_RES_6X4_12X10;
628 break; 629 break;
629 case VIA_RES_720X480: 630 case viafb_compact_res(720, 480):
630 case VIA_RES_720X576: 631 case viafb_compact_res(720, 576):
631 reg_num = NUM_TOTAL_K400_LCD_RES_7X4_12X10; 632 reg_num = NUM_TOTAL_K400_LCD_RES_7X4_12X10;
632 lcd_patch_reg = K400_LCD_RES_7X4_12X10; 633 lcd_patch_reg = K400_LCD_RES_7X4_12X10;
633 break; 634 break;
634 case VIA_RES_800X600: 635 case viafb_compact_res(800, 600):
635 reg_num = NUM_TOTAL_K400_LCD_RES_8X6_12X10; 636 reg_num = NUM_TOTAL_K400_LCD_RES_8X6_12X10;
636 lcd_patch_reg = K400_LCD_RES_8X6_12X10; 637 lcd_patch_reg = K400_LCD_RES_8X6_12X10;
637 break; 638 break;
638 case VIA_RES_1024X768: 639 case viafb_compact_res(1024, 768):
639 reg_num = NUM_TOTAL_K400_LCD_RES_10X7_12X10; 640 reg_num = NUM_TOTAL_K400_LCD_RES_10X7_12X10;
640 lcd_patch_reg = K400_LCD_RES_10X7_12X10; 641 lcd_patch_reg = K400_LCD_RES_10X7_12X10;
641 break; 642 break;
@@ -645,23 +646,23 @@ static void load_lcd_k400_patch_tbl(int set_hres, int set_vres,
645 646
646 /* LCD 1400x1050 */ 647 /* LCD 1400x1050 */
647 case LCD_PANEL_ID5_1400X1050: 648 case LCD_PANEL_ID5_1400X1050:
648 switch (vmode_index) { 649 switch (compact_mode) {
649 case VIA_RES_640X480: 650 case viafb_compact_res(640, 480):
650 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_14X10; 651 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_14X10;
651 lcd_patch_reg = K400_LCD_RES_6X4_14X10; 652 lcd_patch_reg = K400_LCD_RES_6X4_14X10;
652 break; 653 break;
653 case VIA_RES_800X600: 654 case viafb_compact_res(800, 600):
654 reg_num = NUM_TOTAL_K400_LCD_RES_8X6_14X10; 655 reg_num = NUM_TOTAL_K400_LCD_RES_8X6_14X10;
655 lcd_patch_reg = K400_LCD_RES_8X6_14X10; 656 lcd_patch_reg = K400_LCD_RES_8X6_14X10;
656 break; 657 break;
657 case VIA_RES_1024X768: 658 case viafb_compact_res(1024, 768):
658 reg_num = NUM_TOTAL_K400_LCD_RES_10X7_14X10; 659 reg_num = NUM_TOTAL_K400_LCD_RES_10X7_14X10;
659 lcd_patch_reg = K400_LCD_RES_10X7_14X10; 660 lcd_patch_reg = K400_LCD_RES_10X7_14X10;
660 break; 661 break;
661 case VIA_RES_1280X768: 662 case viafb_compact_res(1280, 768):
662 case VIA_RES_1280X800: 663 case viafb_compact_res(1280, 800):
663 case VIA_RES_1280X960: 664 case viafb_compact_res(1280, 960):
664 case VIA_RES_1280X1024: 665 case viafb_compact_res(1280, 1024):
665 reg_num = NUM_TOTAL_K400_LCD_RES_12X10_14X10; 666 reg_num = NUM_TOTAL_K400_LCD_RES_12X10_14X10;
666 lcd_patch_reg = K400_LCD_RES_12X10_14X10; 667 lcd_patch_reg = K400_LCD_RES_12X10_14X10;
667 break; 668 break;
@@ -670,29 +671,29 @@ static void load_lcd_k400_patch_tbl(int set_hres, int set_vres,
670 671
671 /* LCD 1600x1200 */ 672 /* LCD 1600x1200 */
672 case LCD_PANEL_ID6_1600X1200: 673 case LCD_PANEL_ID6_1600X1200:
673 switch (vmode_index) { 674 switch (compact_mode) {
674 case VIA_RES_640X400: 675 case viafb_compact_res(640, 400):
675 case VIA_RES_640X480: 676 case viafb_compact_res(640, 480):
676 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_16X12; 677 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_16X12;
677 lcd_patch_reg = K400_LCD_RES_6X4_16X12; 678 lcd_patch_reg = K400_LCD_RES_6X4_16X12;
678 break; 679 break;
679 case VIA_RES_720X480: 680 case viafb_compact_res(720, 480):
680 case VIA_RES_720X576: 681 case viafb_compact_res(720, 576):
681 reg_num = NUM_TOTAL_K400_LCD_RES_7X4_16X12; 682 reg_num = NUM_TOTAL_K400_LCD_RES_7X4_16X12;
682 lcd_patch_reg = K400_LCD_RES_7X4_16X12; 683 lcd_patch_reg = K400_LCD_RES_7X4_16X12;
683 break; 684 break;
684 case VIA_RES_800X600: 685 case viafb_compact_res(800, 600):
685 reg_num = NUM_TOTAL_K400_LCD_RES_8X6_16X12; 686 reg_num = NUM_TOTAL_K400_LCD_RES_8X6_16X12;
686 lcd_patch_reg = K400_LCD_RES_8X6_16X12; 687 lcd_patch_reg = K400_LCD_RES_8X6_16X12;
687 break; 688 break;
688 case VIA_RES_1024X768: 689 case viafb_compact_res(1024, 768):
689 reg_num = NUM_TOTAL_K400_LCD_RES_10X7_16X12; 690 reg_num = NUM_TOTAL_K400_LCD_RES_10X7_16X12;
690 lcd_patch_reg = K400_LCD_RES_10X7_16X12; 691 lcd_patch_reg = K400_LCD_RES_10X7_16X12;
691 break; 692 break;
692 case VIA_RES_1280X768: 693 case viafb_compact_res(1280, 768):
693 case VIA_RES_1280X800: 694 case viafb_compact_res(1280, 800):
694 case VIA_RES_1280X960: 695 case viafb_compact_res(1280, 960):
695 case VIA_RES_1280X1024: 696 case viafb_compact_res(1280, 1024):
696 reg_num = NUM_TOTAL_K400_LCD_RES_12X10_16X12; 697 reg_num = NUM_TOTAL_K400_LCD_RES_12X10_16X12;
697 lcd_patch_reg = K400_LCD_RES_12X10_16X12; 698 lcd_patch_reg = K400_LCD_RES_12X10_16X12;
698 break; 699 break;
@@ -701,28 +702,28 @@ static void load_lcd_k400_patch_tbl(int set_hres, int set_vres,
701 702
702 /* LCD 1366x768 */ 703 /* LCD 1366x768 */
703 case LCD_PANEL_ID7_1366X768: 704 case LCD_PANEL_ID7_1366X768:
704 switch (vmode_index) { 705 switch (compact_mode) {
705 case VIA_RES_640X480: 706 case viafb_compact_res(640, 480):
706 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_1366X7; 707 reg_num = NUM_TOTAL_K400_LCD_RES_6X4_1366X7;
707 lcd_patch_reg = K400_LCD_RES_6X4_1366X7; 708 lcd_patch_reg = K400_LCD_RES_6X4_1366X7;
708 break; 709 break;
709 case VIA_RES_720X480: 710 case viafb_compact_res(720, 480):
710 case VIA_RES_720X576: 711 case viafb_compact_res(720, 576):
711 reg_num = NUM_TOTAL_K400_LCD_RES_7X4_1366X7; 712 reg_num = NUM_TOTAL_K400_LCD_RES_7X4_1366X7;
712 lcd_patch_reg = K400_LCD_RES_7X4_1366X7; 713 lcd_patch_reg = K400_LCD_RES_7X4_1366X7;
713 break; 714 break;
714 case VIA_RES_800X600: 715 case viafb_compact_res(800, 600):
715 reg_num = NUM_TOTAL_K400_LCD_RES_8X6_1366X7; 716 reg_num = NUM_TOTAL_K400_LCD_RES_8X6_1366X7;
716 lcd_patch_reg = K400_LCD_RES_8X6_1366X7; 717 lcd_patch_reg = K400_LCD_RES_8X6_1366X7;
717 break; 718 break;
718 case VIA_RES_1024X768: 719 case viafb_compact_res(1024, 768):
719 reg_num = NUM_TOTAL_K400_LCD_RES_10X7_1366X7; 720 reg_num = NUM_TOTAL_K400_LCD_RES_10X7_1366X7;
720 lcd_patch_reg = K400_LCD_RES_10X7_1366X7; 721 lcd_patch_reg = K400_LCD_RES_10X7_1366X7;
721 break; 722 break;
722 case VIA_RES_1280X768: 723 case viafb_compact_res(1280, 768):
723 case VIA_RES_1280X800: 724 case viafb_compact_res(1280, 800):
724 case VIA_RES_1280X960: 725 case viafb_compact_res(1280, 960):
725 case VIA_RES_1280X1024: 726 case viafb_compact_res(1280, 1024):
726 reg_num = NUM_TOTAL_K400_LCD_RES_12X10_1366X7; 727 reg_num = NUM_TOTAL_K400_LCD_RES_12X10_1366X7;
727 lcd_patch_reg = K400_LCD_RES_12X10_1366X7; 728 lcd_patch_reg = K400_LCD_RES_12X10_1366X7;
728 break; 729 break;
@@ -754,48 +755,46 @@ static void load_lcd_k400_patch_tbl(int set_hres, int set_vres,
754static void load_lcd_p880_patch_tbl(int set_hres, int set_vres, 755static void load_lcd_p880_patch_tbl(int set_hres, int set_vres,
755 int panel_id) 756 int panel_id)
756{ 757{
757 int vmode_index; 758 u32 compact_mode = viafb_compact_res(set_hres, set_vres);
758 int reg_num = 0; 759 int reg_num = 0;
759 struct io_reg *lcd_patch_reg = NULL; 760 struct io_reg *lcd_patch_reg = NULL;
760 761
761 vmode_index = viafb_get_mode_index(set_hres, set_vres);
762
763 switch (panel_id) { 762 switch (panel_id) {
764 case LCD_PANEL_ID5_1400X1050: 763 case LCD_PANEL_ID5_1400X1050:
765 switch (vmode_index) { 764 switch (compact_mode) {
766 case VIA_RES_640X480: 765 case viafb_compact_res(640, 480):
767 reg_num = NUM_TOTAL_P880_LCD_RES_6X4_14X10; 766 reg_num = NUM_TOTAL_P880_LCD_RES_6X4_14X10;
768 lcd_patch_reg = P880_LCD_RES_6X4_14X10; 767 lcd_patch_reg = P880_LCD_RES_6X4_14X10;
769 break; 768 break;
770 case VIA_RES_800X600: 769 case viafb_compact_res(800, 600):
771 reg_num = NUM_TOTAL_P880_LCD_RES_8X6_14X10; 770 reg_num = NUM_TOTAL_P880_LCD_RES_8X6_14X10;
772 lcd_patch_reg = P880_LCD_RES_8X6_14X10; 771 lcd_patch_reg = P880_LCD_RES_8X6_14X10;
773 break; 772 break;
774 } 773 }
775 break; 774 break;
776 case LCD_PANEL_ID6_1600X1200: 775 case LCD_PANEL_ID6_1600X1200:
777 switch (vmode_index) { 776 switch (compact_mode) {
778 case VIA_RES_640X400: 777 case viafb_compact_res(640, 400):
779 case VIA_RES_640X480: 778 case viafb_compact_res(640, 480):
780 reg_num = NUM_TOTAL_P880_LCD_RES_6X4_16X12; 779 reg_num = NUM_TOTAL_P880_LCD_RES_6X4_16X12;
781 lcd_patch_reg = P880_LCD_RES_6X4_16X12; 780 lcd_patch_reg = P880_LCD_RES_6X4_16X12;
782 break; 781 break;
783 case VIA_RES_720X480: 782 case viafb_compact_res(720, 480):
784 case VIA_RES_720X576: 783 case viafb_compact_res(720, 576):
785 reg_num = NUM_TOTAL_P880_LCD_RES_7X4_16X12; 784 reg_num = NUM_TOTAL_P880_LCD_RES_7X4_16X12;
786 lcd_patch_reg = P880_LCD_RES_7X4_16X12; 785 lcd_patch_reg = P880_LCD_RES_7X4_16X12;
787 break; 786 break;
788 case VIA_RES_800X600: 787 case viafb_compact_res(800, 600):
789 reg_num = NUM_TOTAL_P880_LCD_RES_8X6_16X12; 788 reg_num = NUM_TOTAL_P880_LCD_RES_8X6_16X12;
790 lcd_patch_reg = P880_LCD_RES_8X6_16X12; 789 lcd_patch_reg = P880_LCD_RES_8X6_16X12;
791 break; 790 break;
792 case VIA_RES_1024X768: 791 case viafb_compact_res(1024, 768):
793 reg_num = NUM_TOTAL_P880_LCD_RES_10X7_16X12; 792 reg_num = NUM_TOTAL_P880_LCD_RES_10X7_16X12;
794 lcd_patch_reg = P880_LCD_RES_10X7_16X12; 793 lcd_patch_reg = P880_LCD_RES_10X7_16X12;
795 break; 794 break;
796 case VIA_RES_1280X768: 795 case viafb_compact_res(1280, 768):
797 case VIA_RES_1280X960: 796 case viafb_compact_res(1280, 960):
798 case VIA_RES_1280X1024: 797 case viafb_compact_res(1280, 1024):
799 reg_num = NUM_TOTAL_P880_LCD_RES_12X10_16X12; 798 reg_num = NUM_TOTAL_P880_LCD_RES_12X10_16X12;
800 lcd_patch_reg = P880_LCD_RES_12X10_16X12; 799 lcd_patch_reg = P880_LCD_RES_12X10_16X12;
801 break; 800 break;
@@ -824,10 +823,6 @@ static void load_lcd_p880_patch_tbl(int set_hres, int set_vres,
824static void load_lcd_patch_regs(int set_hres, int set_vres, 823static void load_lcd_patch_regs(int set_hres, int set_vres,
825 int panel_id, int set_iga) 824 int panel_id, int set_iga)
826{ 825{
827 int vmode_index;
828
829 vmode_index = viafb_get_mode_index(set_hres, set_vres);
830
831 viafb_unlock_crt(); 826 viafb_unlock_crt();
832 827
833 /* Patch for simultaneous & Expansion */ 828 /* Patch for simultaneous & Expansion */
@@ -949,29 +944,26 @@ void viafb_lcd_set_mode(struct crt_mode_table *mode_crt_table,
949 struct lvds_setting_information *plvds_setting_info, 944 struct lvds_setting_information *plvds_setting_info,
950 struct lvds_chip_information *plvds_chip_info) 945 struct lvds_chip_information *plvds_chip_info)
951{ 946{
952 int video_index = plvds_setting_info->lcd_panel_size;
953 int set_iga = plvds_setting_info->iga_path; 947 int set_iga = plvds_setting_info->iga_path;
954 int mode_bpp = plvds_setting_info->bpp; 948 int mode_bpp = plvds_setting_info->bpp;
955 int set_hres, set_vres; 949 int set_hres = plvds_setting_info->h_active;
956 int panel_hres, panel_vres; 950 int set_vres = plvds_setting_info->v_active;
951 int panel_hres = plvds_setting_info->lcd_panel_hres;
952 int panel_vres = plvds_setting_info->lcd_panel_vres;
957 u32 pll_D_N; 953 u32 pll_D_N;
958 int offset; 954 int offset;
959 struct display_timing mode_crt_reg, panel_crt_reg; 955 struct display_timing mode_crt_reg, panel_crt_reg;
960 struct crt_mode_table *panel_crt_table = NULL; 956 struct crt_mode_table *panel_crt_table = NULL;
961 struct VideoModeTable *vmode_tbl = NULL; 957 struct VideoModeTable *vmode_tbl = viafb_get_mode(panel_hres,
958 panel_vres);
962 959
963 DEBUG_MSG(KERN_INFO "viafb_lcd_set_mode!!\n"); 960 DEBUG_MSG(KERN_INFO "viafb_lcd_set_mode!!\n");
964 /* Get mode table */ 961 /* Get mode table */
965 mode_crt_reg = mode_crt_table->crtc; 962 mode_crt_reg = mode_crt_table->crtc;
966 /* Get panel table Pointer */ 963 /* Get panel table Pointer */
967 vmode_tbl = viafb_get_modetbl_pointer(video_index);
968 panel_crt_table = vmode_tbl->crtc; 964 panel_crt_table = vmode_tbl->crtc;
969 panel_crt_reg = panel_crt_table->crtc; 965 panel_crt_reg = panel_crt_table->crtc;
970 DEBUG_MSG(KERN_INFO "bellow viafb_lcd_set_mode!!\n"); 966 DEBUG_MSG(KERN_INFO "bellow viafb_lcd_set_mode!!\n");
971 set_hres = plvds_setting_info->h_active;
972 set_vres = plvds_setting_info->v_active;
973 panel_hres = plvds_setting_info->lcd_panel_hres;
974 panel_vres = plvds_setting_info->lcd_panel_vres;
975 if (VT1636_LVDS == plvds_chip_info->lvds_chip_name) 967 if (VT1636_LVDS == plvds_chip_info->lvds_chip_name)
976 viafb_init_lvds_vt1636(plvds_setting_info, plvds_chip_info); 968 viafb_init_lvds_vt1636(plvds_setting_info, plvds_chip_info);
977 plvds_setting_info->vclk = panel_crt_table->clk; 969 plvds_setting_info->vclk = panel_crt_table->clk;
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 156a900aa884..98e3bd11ae17 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -97,7 +97,8 @@ static int viafb_release(struct fb_info *info, int user)
97static int viafb_check_var(struct fb_var_screeninfo *var, 97static int viafb_check_var(struct fb_var_screeninfo *var,
98 struct fb_info *info) 98 struct fb_info *info)
99{ 99{
100 int vmode_index, htotal, vtotal; 100 int htotal, vtotal;
101 struct VideoModeTable *vmode_entry;
101 struct viafb_par *ppar = info->par; 102 struct viafb_par *ppar = info->par;
102 u32 long_refresh; 103 u32 long_refresh;
103 104
@@ -107,8 +108,8 @@ static int viafb_check_var(struct fb_var_screeninfo *var,
107 if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE) 108 if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE)
108 return -EINVAL; 109 return -EINVAL;
109 110
110 vmode_index = viafb_get_mode_index(var->xres, var->yres); 111 vmode_entry = viafb_get_mode(var->xres, var->yres);
111 if (vmode_index == VIA_RES_INVALID) { 112 if (!vmode_entry) {
112 DEBUG_MSG(KERN_INFO 113 DEBUG_MSG(KERN_INFO
113 "viafb: Mode %dx%dx%d not supported!!\n", 114 "viafb: Mode %dx%dx%d not supported!!\n",
114 var->xres, var->yres, var->bits_per_pixel); 115 var->xres, var->yres, var->bits_per_pixel);
@@ -142,7 +143,7 @@ static int viafb_check_var(struct fb_var_screeninfo *var,
142 viafb_refresh = viafb_get_refresh(var->xres, var->yres, long_refresh); 143 viafb_refresh = viafb_get_refresh(var->xres, var->yres, long_refresh);
143 144
144 /* Adjust var according to our driver's own table */ 145 /* Adjust var according to our driver's own table */
145 viafb_fill_var_timing_info(var, viafb_refresh, vmode_index); 146 viafb_fill_var_timing_info(var, viafb_refresh, vmode_entry);
146 if (info->var.accel_flags & FB_ACCELF_TEXT && 147 if (info->var.accel_flags & FB_ACCELF_TEXT &&
147 !ppar->shared->engine_mmio) 148 !ppar->shared->engine_mmio)
148 info->var.accel_flags = 0; 149 info->var.accel_flags = 0;
@@ -153,39 +154,34 @@ static int viafb_check_var(struct fb_var_screeninfo *var,
153static int viafb_set_par(struct fb_info *info) 154static int viafb_set_par(struct fb_info *info)
154{ 155{
155 struct viafb_par *viapar = info->par; 156 struct viafb_par *viapar = info->par;
156 int vmode_index; 157 struct VideoModeTable *vmode_entry, *vmode_entry1 = NULL;
157 int vmode_index1 = 0;
158 DEBUG_MSG(KERN_INFO "viafb_set_par!\n"); 158 DEBUG_MSG(KERN_INFO "viafb_set_par!\n");
159 159
160 viapar->depth = fb_get_color_depth(&info->var, &info->fix); 160 viapar->depth = fb_get_color_depth(&info->var, &info->fix);
161 viafb_update_device_setting(info->var.xres, info->var.yres, 161 viafb_update_device_setting(info->var.xres, info->var.yres,
162 info->var.bits_per_pixel, viafb_refresh, 0); 162 info->var.bits_per_pixel, viafb_refresh, 0);
163 163
164 vmode_index = viafb_get_mode_index(info->var.xres, info->var.yres); 164 vmode_entry = viafb_get_mode(info->var.xres, info->var.yres);
165
166 if (viafb_SAMM_ON == 1) { 165 if (viafb_SAMM_ON == 1) {
167 DEBUG_MSG(KERN_INFO 166 DEBUG_MSG(KERN_INFO
168 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n", 167 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
169 viafb_second_xres, viafb_second_yres, viafb_bpp1); 168 viafb_second_xres, viafb_second_yres, viafb_bpp1);
170 vmode_index1 = viafb_get_mode_index(viafb_second_xres, 169 vmode_entry1 = viafb_get_mode(viafb_second_xres,
171 viafb_second_yres); 170 viafb_second_yres);
172 DEBUG_MSG(KERN_INFO "->viafb_SAMM_ON: index=%d\n",
173 vmode_index1);
174 171
175 viafb_update_device_setting(viafb_second_xres, 172 viafb_update_device_setting(viafb_second_xres,
176 viafb_second_yres, viafb_bpp1, viafb_refresh1, 1); 173 viafb_second_yres, viafb_bpp1, viafb_refresh1, 1);
177 } 174 }
178 175
179 if (vmode_index != VIA_RES_INVALID) { 176 if (vmode_entry) {
180 viafb_update_fix(info); 177 viafb_update_fix(info);
181 viafb_bpp = info->var.bits_per_pixel; 178 viafb_bpp = info->var.bits_per_pixel;
182 if (info->var.accel_flags & FB_ACCELF_TEXT) 179 if (info->var.accel_flags & FB_ACCELF_TEXT)
183 info->flags &= ~FBINFO_HWACCEL_DISABLED; 180 info->flags &= ~FBINFO_HWACCEL_DISABLED;
184 else 181 else
185 info->flags |= FBINFO_HWACCEL_DISABLED; 182 info->flags |= FBINFO_HWACCEL_DISABLED;
186 viafb_setmode(vmode_index, info->var.xres, info->var.yres, 183 viafb_setmode(vmode_entry, info->var.bits_per_pixel,
187 info->var.bits_per_pixel, vmode_index1, 184 vmode_entry1, viafb_bpp1);
188 viafb_second_xres, viafb_second_yres, viafb_bpp1);
189 } 185 }
190 186
191 return 0; 187 return 0;
@@ -1016,23 +1012,6 @@ static int viafb_sync(struct fb_info *info)
1016 return 0; 1012 return 0;
1017} 1013}
1018 1014
1019int viafb_get_mode_index(int hres, int vres)
1020{
1021 u32 i;
1022 DEBUG_MSG(KERN_INFO "viafb_get_mode_index!\n");
1023
1024 for (i = 0; i < NUM_TOTAL_MODETABLE; i++)
1025 if (CLE266Modes[i].mode_array &&
1026 CLE266Modes[i].crtc[0].crtc.hor_addr == hres &&
1027 CLE266Modes[i].crtc[0].crtc.ver_addr == vres)
1028 break;
1029
1030 if (i == NUM_TOTAL_MODETABLE)
1031 return VIA_RES_INVALID;
1032
1033 return CLE266Modes[i].ModeIndex;
1034}
1035
1036static void check_available_device_to_enable(int device_id) 1015static void check_available_device_to_enable(int device_id)
1037{ 1016{
1038 int device_num = 0; 1017 int device_num = 0;
@@ -1848,7 +1827,7 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
1848 const struct pci_device_id *ent) 1827 const struct pci_device_id *ent)
1849{ 1828{
1850 u32 default_xres, default_yres; 1829 u32 default_xres, default_yres;
1851 int vmode_index; 1830 struct VideoModeTable *vmode_entry;
1852 u32 viafb_par_length; 1831 u32 viafb_par_length;
1853 1832
1854 DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n"); 1833 DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n");
@@ -1927,9 +1906,7 @@ static int __devinit via_pci_probe(struct pci_dev *pdev,
1927 } 1906 }
1928 1907
1929 parse_mode(viafb_mode, &default_xres, &default_yres); 1908 parse_mode(viafb_mode, &default_xres, &default_yres);
1930 vmode_index = viafb_get_mode_index(default_xres, default_yres); 1909 vmode_entry = viafb_get_mode(default_xres, default_yres);
1931 DEBUG_MSG(KERN_INFO "0->index=%d\n", vmode_index);
1932
1933 if (viafb_SAMM_ON == 1) { 1910 if (viafb_SAMM_ON == 1) {
1934 parse_mode(viafb_mode1, &viafb_second_xres, 1911 parse_mode(viafb_mode1, &viafb_second_xres,
1935 &viafb_second_yres); 1912 &viafb_second_yres);
diff --git a/drivers/video/via/viafbdev.h b/drivers/video/via/viafbdev.h
index 0c94d2441922..85aa20ea67e9 100644
--- a/drivers/video/via/viafbdev.h
+++ b/drivers/video/via/viafbdev.h
@@ -96,9 +96,6 @@ extern int viafb_memsize;
96extern int strict_strtoul(const char *cp, unsigned int base, 96extern int strict_strtoul(const char *cp, unsigned int base,
97 unsigned long *res); 97 unsigned long *res);
98 98
99void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh,
100 int mode_index);
101int viafb_get_mode_index(int hres, int vres);
102u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information 99u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information
103 *plvds_setting_info, struct lvds_chip_information 100 *plvds_setting_info, struct lvds_chip_information
104 *plvds_chip_info, u8 index); 101 *plvds_chip_info, u8 index);
diff --git a/drivers/video/via/viamode.c b/drivers/video/via/viamode.c
index b74f8a67923c..af50e244016c 100644
--- a/drivers/video/via/viamode.c
+++ b/drivers/video/via/viamode.c
@@ -412,7 +412,7 @@ struct io_reg PM1024x768[] = { {VIASR, 0x16, 0xBF, 0x0C},
412}; 412};
413 413
414struct patch_table res_patch_table[] = { 414struct patch_table res_patch_table[] = {
415 {VIA_RES_1024X768, ARRAY_SIZE(PM1024x768), PM1024x768} 415 {ARRAY_SIZE(PM1024x768), PM1024x768}
416}; 416};
417 417
418/* struct VPITTable { 418/* struct VPITTable {
@@ -879,169 +879,151 @@ struct crt_mode_table CRTM2048x1536[] = {
879 {2800, 2048, 2048, 752, 2200, 224, 1592, 1536, 1536, 56, 1539, 4} } 879 {2800, 2048, 2048, 752, 2200, 224, 1592, 1536, 1536, 56, 1539, 4} }
880}; 880};
881 881
882/* Video Mode Table */ 882struct VideoModeTable viafb_modes[] = {
883/* struct VideoModeTable {*/
884/* int ModeIndex;*/
885/* struct crt_mode_table *crtc;*/
886/* int mode_array;*/
887/* };*/
888struct VideoModeTable CLE266Modes[] = {
889 /* Display : 480x640 (GTF) */ 883 /* Display : 480x640 (GTF) */
890 {VIA_RES_480X640, CRTM480x640, ARRAY_SIZE(CRTM480x640)}, 884 {CRTM480x640, ARRAY_SIZE(CRTM480x640)},
891 885
892 /* Display : 640x480 */ 886 /* Display : 640x480 */
893 {VIA_RES_640X480, CRTM640x480, ARRAY_SIZE(CRTM640x480)}, 887 {CRTM640x480, ARRAY_SIZE(CRTM640x480)},
894 888
895 /* Display : 720x480 (GTF) */ 889 /* Display : 720x480 (GTF) */
896 {VIA_RES_720X480, CRTM720x480, ARRAY_SIZE(CRTM720x480)}, 890 {CRTM720x480, ARRAY_SIZE(CRTM720x480)},
897 891
898 /* Display : 720x576 (GTF) */ 892 /* Display : 720x576 (GTF) */
899 {VIA_RES_720X576, CRTM720x576, ARRAY_SIZE(CRTM720x576)}, 893 {CRTM720x576, ARRAY_SIZE(CRTM720x576)},
900 894
901 /* Display : 800x600 */ 895 /* Display : 800x600 */
902 {VIA_RES_800X600, CRTM800x600, ARRAY_SIZE(CRTM800x600)}, 896 {CRTM800x600, ARRAY_SIZE(CRTM800x600)},
903 897
904 /* Display : 800x480 (CVT) */ 898 /* Display : 800x480 (CVT) */
905 {VIA_RES_800X480, CRTM800x480, ARRAY_SIZE(CRTM800x480)}, 899 {CRTM800x480, ARRAY_SIZE(CRTM800x480)},
906 900
907 /* Display : 848x480 (CVT) */ 901 /* Display : 848x480 (CVT) */
908 {VIA_RES_848X480, CRTM848x480, ARRAY_SIZE(CRTM848x480)}, 902 {CRTM848x480, ARRAY_SIZE(CRTM848x480)},
909 903
910 /* Display : 852x480 (GTF) */ 904 /* Display : 852x480 (GTF) */
911 {VIA_RES_856X480, CRTM852x480, ARRAY_SIZE(CRTM852x480)}, 905 {CRTM852x480, ARRAY_SIZE(CRTM852x480)},
912 906
913 /* Display : 1024x512 (GTF) */ 907 /* Display : 1024x512 (GTF) */
914 {VIA_RES_1024X512, CRTM1024x512, ARRAY_SIZE(CRTM1024x512)}, 908 {CRTM1024x512, ARRAY_SIZE(CRTM1024x512)},
915 909
916 /* Display : 1024x600 */ 910 /* Display : 1024x600 */
917 {VIA_RES_1024X600, CRTM1024x600, ARRAY_SIZE(CRTM1024x600)}, 911 {CRTM1024x600, ARRAY_SIZE(CRTM1024x600)},
918
919 /* Display : 1024x576 (GTF) */
920 /*{ VIA_RES_1024X576, CRTM1024x576, ARRAY_SIZE(CRTM1024x576)}, */
921 912
922 /* Display : 1024x768 */ 913 /* Display : 1024x768 */
923 {VIA_RES_1024X768, CRTM1024x768, ARRAY_SIZE(CRTM1024x768)}, 914 {CRTM1024x768, ARRAY_SIZE(CRTM1024x768)},
924 915
925 /* Display : 1152x864 */ 916 /* Display : 1152x864 */
926 {VIA_RES_1152X864, CRTM1152x864, ARRAY_SIZE(CRTM1152x864)}, 917 {CRTM1152x864, ARRAY_SIZE(CRTM1152x864)},
927 918
928 /* Display : 1280x768 (GTF) */ 919 /* Display : 1280x768 (GTF) */
929 {VIA_RES_1280X768, CRTM1280x768, ARRAY_SIZE(CRTM1280x768)}, 920 {CRTM1280x768, ARRAY_SIZE(CRTM1280x768)},
930 921
931 /* Display : 960x600 (CVT) */ 922 /* Display : 960x600 (CVT) */
932 {VIA_RES_960X600, CRTM960x600, ARRAY_SIZE(CRTM960x600)}, 923 {CRTM960x600, ARRAY_SIZE(CRTM960x600)},
933 924
934 /* Display : 1000x600 (GTF) */ 925 /* Display : 1000x600 (GTF) */
935 {VIA_RES_1000X600, CRTM1000x600, ARRAY_SIZE(CRTM1000x600)}, 926 {CRTM1000x600, ARRAY_SIZE(CRTM1000x600)},
936 927
937 /* Display : 1024x576 (GTF) */ 928 /* Display : 1024x576 (GTF) */
938 {VIA_RES_1024X576, CRTM1024x576, ARRAY_SIZE(CRTM1024x576)}, 929 {CRTM1024x576, ARRAY_SIZE(CRTM1024x576)},
939 930
940 /* Display : 1088x612 (GTF) */ 931 /* Display : 1088x612 (GTF) */
941 {VIA_RES_1088X612, CRTM1088x612, ARRAY_SIZE(CRTM1088x612)}, 932 {CRTM1088x612, ARRAY_SIZE(CRTM1088x612)},
942 933
943 /* Display : 1152x720 (CVT) */ 934 /* Display : 1152x720 (CVT) */
944 {VIA_RES_1152X720, CRTM1152x720, ARRAY_SIZE(CRTM1152x720)}, 935 {CRTM1152x720, ARRAY_SIZE(CRTM1152x720)},
945 936
946 /* Display : 1200x720 (GTF) */ 937 /* Display : 1200x720 (GTF) */
947 {VIA_RES_1200X720, CRTM1200x720, ARRAY_SIZE(CRTM1200x720)}, 938 {CRTM1200x720, ARRAY_SIZE(CRTM1200x720)},
948 939
949 /* Display : 1280x600 (GTF) */ 940 /* Display : 1280x600 (GTF) */
950 {VIA_RES_1280X600, CRTM1280x600, ARRAY_SIZE(CRTM1280x600)}, 941 {CRTM1280x600, ARRAY_SIZE(CRTM1280x600)},
951 942
952 /* Display : 1280x800 (CVT) */ 943 /* Display : 1280x800 (CVT) */
953 {VIA_RES_1280X800, CRTM1280x800, ARRAY_SIZE(CRTM1280x800)}, 944 {CRTM1280x800, ARRAY_SIZE(CRTM1280x800)},
954
955 /* Display : 1280x800 (GTF) */
956 /*{ M1280x800, CRTM1280x800, ARRAY_SIZE(CRTM1280x800)}, */
957 945
958 /* Display : 1280x960 */ 946 /* Display : 1280x960 */
959 {VIA_RES_1280X960, CRTM1280x960, ARRAY_SIZE(CRTM1280x960)}, 947 {CRTM1280x960, ARRAY_SIZE(CRTM1280x960)},
960 948
961 /* Display : 1280x1024 */ 949 /* Display : 1280x1024 */
962 {VIA_RES_1280X1024, CRTM1280x1024, ARRAY_SIZE(CRTM1280x1024)}, 950 {CRTM1280x1024, ARRAY_SIZE(CRTM1280x1024)},
963 951
964 /* Display : 1360x768 (CVT) */ 952 /* Display : 1360x768 (CVT) */
965 {VIA_RES_1360X768, CRTM1360x768, ARRAY_SIZE(CRTM1360x768)}, 953 {CRTM1360x768, ARRAY_SIZE(CRTM1360x768)},
966
967 /* Display : 1360x768 (CVT Reduce Blanking) */
968 {VIA_RES_1360X768_RB, CRTM1360x768_RB,
969 ARRAY_SIZE(CRTM1360x768_RB)},
970 954
971 /* Display : 1366x768 */ 955 /* Display : 1366x768 */
972 {VIA_RES_1366X768, CRTM1366x768, ARRAY_SIZE(CRTM1366x768)}, 956 {CRTM1366x768, ARRAY_SIZE(CRTM1366x768)},
973 957
974 /* Display : 1368x768 (GTF) */ 958 /* Display : 1368x768 (GTF) */
975 /*{ M1368x768,CRTM1368x768,ARRAY_SIZE(CRTM1368x768)}, */ 959 {CRTM1368x768, ARRAY_SIZE(CRTM1368x768)},
976 /* Display : 1368x768 (GTF) */
977 {VIA_RES_1368X768, CRTM1368x768, ARRAY_SIZE(CRTM1368x768)},
978 960
979 /* Display : 1440x900 (CVT) */ 961 /* Display : 1440x900 (CVT) */
980 {VIA_RES_1440X900, CRTM1440x900, ARRAY_SIZE(CRTM1440x900)}, 962 {CRTM1440x900, ARRAY_SIZE(CRTM1440x900)},
981
982 /* Display : 1440x900 (CVT Reduce Blanking) */
983 {VIA_RES_1440X900_RB, CRTM1440x900_RB,
984 ARRAY_SIZE(CRTM1440x900_RB)},
985 963
986 /* Display : 1440x1050 (GTF) */ 964 /* Display : 1440x1050 (GTF) */
987 {VIA_RES_1440X1050, CRTM1440x1050, ARRAY_SIZE(CRTM1440x1050)}, 965 {CRTM1440x1050, ARRAY_SIZE(CRTM1440x1050)},
988
989 /* Display : 1400x1050 (CVT Reduce Blanking) */
990 {VIA_RES_1400X1050_RB, CRTM1400x1050_RB,
991 ARRAY_SIZE(CRTM1400x1050_RB)},
992 966
993 /* Display : 1600x900 (CVT) */ 967 /* Display : 1600x900 (CVT) */
994 {VIA_RES_1600X900, CRTM1600x900, ARRAY_SIZE(CRTM1600x900)}, 968 {CRTM1600x900, ARRAY_SIZE(CRTM1600x900)},
995
996 /* Display : 1600x900 (CVT Reduce Blanking) */
997 {VIA_RES_1600X900_RB, CRTM1600x900_RB,
998 ARRAY_SIZE(CRTM1600x900_RB)},
999 969
1000 /* Display : 1600x1024 (GTF) */ 970 /* Display : 1600x1024 (GTF) */
1001 {VIA_RES_1600X1024, CRTM1600x1024, ARRAY_SIZE(CRTM1600x1024)}, 971 {CRTM1600x1024, ARRAY_SIZE(CRTM1600x1024)},
1002 972
1003 /* Display : 1600x1200 */ 973 /* Display : 1600x1200 */
1004 {VIA_RES_1600X1200, CRTM1600x1200, ARRAY_SIZE(CRTM1600x1200)}, 974 {CRTM1600x1200, ARRAY_SIZE(CRTM1600x1200)},
1005 975
1006 /* Display : 1680x1050 (CVT) */ 976 /* Display : 1680x1050 (CVT) */
1007 {VIA_RES_1680X1050, CRTM1680x1050, ARRAY_SIZE(CRTM1680x1050)}, 977 {CRTM1680x1050, ARRAY_SIZE(CRTM1680x1050)},
1008
1009 /* Display : 1680x1050 (CVT Reduce Blanking) */
1010 {VIA_RES_1680X1050_RB, CRTM1680x1050_RB,
1011 ARRAY_SIZE(CRTM1680x1050_RB)},
1012 978
1013 /* Display : 1792x1344 (DMT) */ 979 /* Display : 1792x1344 (DMT) */
1014 {VIA_RES_1792X1344, CRTM1792x1344, ARRAY_SIZE(CRTM1792x1344)}, 980 {CRTM1792x1344, ARRAY_SIZE(CRTM1792x1344)},
1015 981
1016 /* Display : 1856x1392 (DMT) */ 982 /* Display : 1856x1392 (DMT) */
1017 {VIA_RES_1856X1392, CRTM1856x1392, ARRAY_SIZE(CRTM1856x1392)}, 983 {CRTM1856x1392, ARRAY_SIZE(CRTM1856x1392)},
1018 984
1019 /* Display : 1920x1440 */ 985 /* Display : 1920x1440 */
1020 {VIA_RES_1920X1440, CRTM1920x1440, ARRAY_SIZE(CRTM1920x1440)}, 986 {CRTM1920x1440, ARRAY_SIZE(CRTM1920x1440)},
1021 987
1022 /* Display : 2048x1536 */ 988 /* Display : 2048x1536 */
1023 {VIA_RES_2048X1536, CRTM2048x1536, ARRAY_SIZE(CRTM2048x1536)}, 989 {CRTM2048x1536, ARRAY_SIZE(CRTM2048x1536)},
1024 990
1025 /* Display : 1280x720 */ 991 /* Display : 1280x720 */
1026 {VIA_RES_1280X720, CRTM1280x720, ARRAY_SIZE(CRTM1280x720)}, 992 {CRTM1280x720, ARRAY_SIZE(CRTM1280x720)},
1027 993
1028 /* Display : 1920x1080 (CVT) */ 994 /* Display : 1920x1080 (CVT) */
1029 {VIA_RES_1920X1080, CRTM1920x1080, ARRAY_SIZE(CRTM1920x1080)}, 995 {CRTM1920x1080, ARRAY_SIZE(CRTM1920x1080)},
1030
1031 /* Display : 1920x1080 (CVT Reduce Blanking) */
1032 {VIA_RES_1920X1080_RB, CRTM1920x1080_RB,
1033 ARRAY_SIZE(CRTM1920x1080_RB)},
1034 996
1035 /* Display : 1920x1200 (CVT) */ 997 /* Display : 1920x1200 (CVT) */
1036 {VIA_RES_1920X1200, CRTM1920x1200, ARRAY_SIZE(CRTM1920x1200)}, 998 {CRTM1920x1200, ARRAY_SIZE(CRTM1920x1200)},
1037
1038 /* Display : 1920x1200 (CVT Reduce Blanking) */
1039 {VIA_RES_1920X1200_RB, CRTM1920x1200_RB,
1040 ARRAY_SIZE(CRTM1920x1200_RB)},
1041 999
1042 /* Display : 1400x1050 (CVT) */ 1000 /* Display : 1400x1050 (CVT) */
1043 {VIA_RES_1400X1050, CRTM1400x1050, ARRAY_SIZE(CRTM1400x1050)} 1001 {CRTM1400x1050, ARRAY_SIZE(CRTM1400x1050)}
1044}; 1002};
1003
1004struct VideoModeTable viafb_rb_modes[] = {
1005 /* Display : 1360x768 (CVT Reduce Blanking) */
1006 {CRTM1360x768_RB, ARRAY_SIZE(CRTM1360x768_RB)},
1007
1008 /* Display : 1440x900 (CVT Reduce Blanking) */
1009 {CRTM1440x900_RB, ARRAY_SIZE(CRTM1440x900_RB)},
1010
1011 /* Display : 1400x1050 (CVT Reduce Blanking) */
1012 {CRTM1400x1050_RB, ARRAY_SIZE(CRTM1400x1050_RB)},
1013
1014 /* Display : 1600x900 (CVT Reduce Blanking) */
1015 {CRTM1600x900_RB, ARRAY_SIZE(CRTM1600x900_RB)},
1016
1017 /* Display : 1680x1050 (CVT Reduce Blanking) */
1018 {CRTM1680x1050_RB, ARRAY_SIZE(CRTM1680x1050_RB)},
1019
1020 /* Display : 1920x1080 (CVT Reduce Blanking) */
1021 {CRTM1920x1080_RB, ARRAY_SIZE(CRTM1920x1080_RB)},
1022
1023 /* Display : 1920x1200 (CVT Reduce Blanking) */
1024 {CRTM1920x1200_RB, ARRAY_SIZE(CRTM1920x1200_RB)}
1025};
1026
1045struct crt_mode_table CEAM1280x720[] = { 1027struct crt_mode_table CEAM1280x720[] = {
1046 {REFRESH_60, CLK_74_270M, M1280X720_CEA_R60_HSP, 1028 {REFRESH_60, CLK_74_270M, M1280X720_CEA_R60_HSP,
1047 M1280X720_CEA_R60_VSP, 1029 M1280X720_CEA_R60_VSP,
@@ -1056,8 +1038,8 @@ struct crt_mode_table CEAM1920x1080[] = {
1056}; 1038};
1057struct VideoModeTable CEA_HDMI_Modes[] = { 1039struct VideoModeTable CEA_HDMI_Modes[] = {
1058 /* Display : 1280x720 */ 1040 /* Display : 1280x720 */
1059 {VIA_RES_1280X720, CEAM1280x720, ARRAY_SIZE(CEAM1280x720)}, 1041 {CEAM1280x720, ARRAY_SIZE(CEAM1280x720)},
1060 {VIA_RES_1920X1080, CEAM1920x1080, ARRAY_SIZE(CEAM1920x1080)} 1042 {CEAM1920x1080, ARRAY_SIZE(CEAM1920x1080)}
1061}; 1043};
1062 1044
1063int NUM_TOTAL_RES_MAP_REFRESH = ARRAY_SIZE(res_map_refresh_tbl); 1045int NUM_TOTAL_RES_MAP_REFRESH = ARRAY_SIZE(res_map_refresh_tbl);
@@ -1069,4 +1051,28 @@ int NUM_TOTAL_CX700_ModeXregs = ARRAY_SIZE(CX700_ModeXregs);
1069int NUM_TOTAL_VX855_ModeXregs = ARRAY_SIZE(VX855_ModeXregs); 1051int NUM_TOTAL_VX855_ModeXregs = ARRAY_SIZE(VX855_ModeXregs);
1070int NUM_TOTAL_CLE266_ModeXregs = ARRAY_SIZE(CLE266_ModeXregs); 1052int NUM_TOTAL_CLE266_ModeXregs = ARRAY_SIZE(CLE266_ModeXregs);
1071int NUM_TOTAL_PATCH_MODE = ARRAY_SIZE(res_patch_table); 1053int NUM_TOTAL_PATCH_MODE = ARRAY_SIZE(res_patch_table);
1072int NUM_TOTAL_MODETABLE = ARRAY_SIZE(CLE266Modes); 1054
1055
1056struct VideoModeTable *viafb_get_mode(int hres, int vres)
1057{
1058 u32 i;
1059 for (i = 0; i < ARRAY_SIZE(viafb_modes); i++)
1060 if (viafb_modes[i].mode_array &&
1061 viafb_modes[i].crtc[0].crtc.hor_addr == hres &&
1062 viafb_modes[i].crtc[0].crtc.ver_addr == vres)
1063 return &viafb_modes[i];
1064
1065 return NULL;
1066}
1067
1068struct VideoModeTable *viafb_get_rb_mode(int hres, int vres)
1069{
1070 u32 i;
1071 for (i = 0; i < ARRAY_SIZE(viafb_rb_modes); i++)
1072 if (viafb_rb_modes[i].mode_array &&
1073 viafb_rb_modes[i].crtc[0].crtc.hor_addr == hres &&
1074 viafb_rb_modes[i].crtc[0].crtc.ver_addr == vres)
1075 return &viafb_rb_modes[i];
1076
1077 return NULL;
1078}
diff --git a/drivers/video/via/viamode.h b/drivers/video/via/viamode.h
index a9d6554fabdf..5b1ced86514b 100644
--- a/drivers/video/via/viamode.h
+++ b/drivers/video/via/viamode.h
@@ -32,13 +32,11 @@ struct VPITTable {
32}; 32};
33 33
34struct VideoModeTable { 34struct VideoModeTable {
35 int ModeIndex;
36 struct crt_mode_table *crtc; 35 struct crt_mode_table *crtc;
37 int mode_array; 36 int mode_array;
38}; 37};
39 38
40struct patch_table { 39struct patch_table {
41 int mode_index;
42 int table_length; 40 int table_length;
43 struct io_reg *io_reg_table; 41 struct io_reg *io_reg_table;
44}; 42};
@@ -59,13 +57,11 @@ extern int NUM_TOTAL_CX700_ModeXregs;
59extern int NUM_TOTAL_VX855_ModeXregs; 57extern int NUM_TOTAL_VX855_ModeXregs;
60extern int NUM_TOTAL_CLE266_ModeXregs; 58extern int NUM_TOTAL_CLE266_ModeXregs;
61extern int NUM_TOTAL_PATCH_MODE; 59extern int NUM_TOTAL_PATCH_MODE;
62extern int NUM_TOTAL_MODETABLE;
63 60
64/********************/ 61/********************/
65/* Mode Table */ 62/* Mode Table */
66/********************/ 63/********************/
67 64
68extern struct VideoModeTable CLE266Modes[];
69extern struct crt_mode_table CEAM1280x720[]; 65extern struct crt_mode_table CEAM1280x720[];
70extern struct crt_mode_table CEAM1920x1080[]; 66extern struct crt_mode_table CEAM1920x1080[];
71extern struct VideoModeTable CEA_HDMI_Modes[]; 67extern struct VideoModeTable CEA_HDMI_Modes[];
@@ -81,4 +77,8 @@ extern struct io_reg CLE266_ModeXregs[];
81extern struct io_reg PM1024x768[]; 77extern struct io_reg PM1024x768[];
82extern struct patch_table res_patch_table[]; 78extern struct patch_table res_patch_table[];
83extern struct VPITTable VPIT; 79extern struct VPITTable VPIT;
80
81struct VideoModeTable *viafb_get_mode(int hres, int vres);
82struct VideoModeTable *viafb_get_rb_mode(int hres, int vres);
83
84#endif /* __VIAMODE_H__ */ 84#endif /* __VIAMODE_H__ */