aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/via/hw.c
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/via/hw.c
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/via/hw.c')
-rw-r--r--drivers/video/via/hw.c151
1 files changed, 26 insertions, 125 deletions
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;