Joseph Chan | ac6c97e | 2008-10-15 22:03:25 -0700 | [diff] [blame] | 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 | #include "lcdtbl.h" |
| 24 | |
| 25 | static struct iga2_shadow_crtc_timing iga2_shadow_crtc_reg = { |
| 26 | /* IGA2 Shadow Horizontal Total */ |
| 27 | {IGA2_SHADOW_HOR_TOTAL_REG_NUM, {{CR6D, 0, 7}, {CR71, 3, 3} } }, |
| 28 | /* IGA2 Shadow Horizontal Blank End */ |
| 29 | {IGA2_SHADOW_HOR_BLANK_END_REG_NUM, {{CR6E, 0, 7} } }, |
| 30 | /* IGA2 Shadow Vertical Total */ |
| 31 | {IGA2_SHADOW_VER_TOTAL_REG_NUM, {{CR6F, 0, 7}, {CR71, 0, 2} } }, |
| 32 | /* IGA2 Shadow Vertical Addressable Video */ |
| 33 | {IGA2_SHADOW_VER_ADDR_REG_NUM, {{CR70, 0, 7}, {CR71, 4, 6} } }, |
| 34 | /* IGA2 Shadow Vertical Blank Start */ |
| 35 | {IGA2_SHADOW_VER_BLANK_START_REG_NUM, |
| 36 | {{CR72, 0, 7}, {CR74, 4, 6} } }, |
| 37 | /* IGA2 Shadow Vertical Blank End */ |
| 38 | {IGA2_SHADOW_VER_BLANK_END_REG_NUM, {{CR73, 0, 7}, {CR74, 0, 2} } }, |
| 39 | /* IGA2 Shadow Vertical Sync Start */ |
| 40 | {IGA2_SHADOW_VER_SYNC_START_REG_NUM, {{CR75, 0, 7}, {CR76, 4, 6} } }, |
| 41 | /* IGA2 Shadow Vertical Sync End */ |
| 42 | {IGA2_SHADOW_VER_SYNC_END_REG_NUM, {{CR76, 0, 3} } } |
| 43 | }; |
| 44 | |
| 45 | static struct _lcd_scaling_factor lcd_scaling_factor = { |
| 46 | /* LCD Horizontal Scaling Factor Register */ |
| 47 | {LCD_HOR_SCALING_FACTOR_REG_NUM, |
| 48 | {{CR9F, 0, 1}, {CR77, 0, 7}, {CR79, 4, 5} } }, |
| 49 | /* LCD Vertical Scaling Factor Register */ |
| 50 | {LCD_VER_SCALING_FACTOR_REG_NUM, |
| 51 | {{CR79, 3, 3}, {CR78, 0, 7}, {CR79, 6, 7} } } |
| 52 | }; |
| 53 | static struct _lcd_scaling_factor lcd_scaling_factor_CLE = { |
| 54 | /* LCD Horizontal Scaling Factor Register */ |
| 55 | {LCD_HOR_SCALING_FACTOR_REG_NUM_CLE, {{CR77, 0, 7}, {CR79, 4, 5} } }, |
| 56 | /* LCD Vertical Scaling Factor Register */ |
| 57 | {LCD_VER_SCALING_FACTOR_REG_NUM_CLE, {{CR78, 0, 7}, {CR79, 6, 7} } } |
| 58 | }; |
| 59 | |
| 60 | static int check_lvds_chip(int device_id_subaddr, int device_id); |
| 61 | static bool lvds_identify_integratedlvds(void); |
| 62 | static int fp_id_to_vindex(int panel_id); |
| 63 | static int lvds_register_read(int index); |
| 64 | static void load_lcd_scaling(int set_hres, int set_vres, int panel_hres, |
| 65 | int panel_vres); |
| 66 | static void load_lcd_k400_patch_tbl(int set_hres, int set_vres, |
| 67 | int panel_id); |
| 68 | static void load_lcd_p880_patch_tbl(int set_hres, int set_vres, |
| 69 | int panel_id); |
| 70 | static void load_lcd_patch_regs(int set_hres, int set_vres, |
| 71 | int panel_id, int set_iga); |
| 72 | static void via_pitch_alignment_patch_lcd( |
| 73 | struct lvds_setting_information *plvds_setting_info, |
| 74 | struct lvds_chip_information |
| 75 | *plvds_chip_info); |
| 76 | static void lcd_patch_skew_dvp0(struct lvds_setting_information |
| 77 | *plvds_setting_info, |
| 78 | struct lvds_chip_information *plvds_chip_info); |
| 79 | static void lcd_patch_skew_dvp1(struct lvds_setting_information |
| 80 | *plvds_setting_info, |
| 81 | struct lvds_chip_information *plvds_chip_info); |
| 82 | static void lcd_patch_skew(struct lvds_setting_information |
| 83 | *plvds_setting_info, struct lvds_chip_information *plvds_chip_info); |
| 84 | |
| 85 | static void integrated_lvds_disable(struct lvds_setting_information |
| 86 | *plvds_setting_info, |
| 87 | struct lvds_chip_information *plvds_chip_info); |
| 88 | static void integrated_lvds_enable(struct lvds_setting_information |
| 89 | *plvds_setting_info, |
| 90 | struct lvds_chip_information *plvds_chip_info); |
| 91 | static void lcd_powersequence_off(void); |
| 92 | static void lcd_powersequence_on(void); |
| 93 | static void fill_lcd_format(void); |
| 94 | static void check_diport_of_integrated_lvds( |
| 95 | struct lvds_chip_information *plvds_chip_info, |
| 96 | struct lvds_setting_information |
| 97 | *plvds_setting_info); |
| 98 | static struct display_timing lcd_centering_timging(struct display_timing |
| 99 | mode_crt_reg, |
| 100 | struct display_timing panel_crt_reg); |
| 101 | static void load_crtc_shadow_timing(struct display_timing mode_timing, |
| 102 | struct display_timing panel_timing); |
| 103 | static void viafb_load_scaling_factor_for_p4m900(int set_hres, |
| 104 | int set_vres, int panel_hres, int panel_vres); |
| 105 | |
| 106 | static int check_lvds_chip(int device_id_subaddr, int device_id) |
| 107 | { |
| 108 | if (lvds_register_read(device_id_subaddr) == device_id) |
| 109 | return OK; |
| 110 | else |
| 111 | return FAIL; |
| 112 | } |
| 113 | |
| 114 | void viafb_init_lcd_size(void) |
| 115 | { |
| 116 | DEBUG_MSG(KERN_INFO "viafb_init_lcd_size()\n"); |
| 117 | DEBUG_MSG(KERN_INFO |
| 118 | "viaparinfo->lvds_setting_info->get_lcd_size_method %d\n", |
| 119 | viaparinfo->lvds_setting_info->get_lcd_size_method); |
| 120 | |
| 121 | switch (viaparinfo->lvds_setting_info->get_lcd_size_method) { |
| 122 | case GET_LCD_SIZE_BY_SYSTEM_BIOS: |
| 123 | break; |
| 124 | case GET_LCD_SZIE_BY_HW_STRAPPING: |
| 125 | break; |
| 126 | case GET_LCD_SIZE_BY_VGA_BIOS: |
| 127 | DEBUG_MSG(KERN_INFO "Get LCD Size method by VGA BIOS !!\n"); |
| 128 | viaparinfo->lvds_setting_info->lcd_panel_size = |
| 129 | fp_id_to_vindex(viafb_lcd_panel_id); |
| 130 | DEBUG_MSG(KERN_INFO "LCD Panel_ID = %d\n", |
| 131 | viaparinfo->lvds_setting_info->lcd_panel_id); |
| 132 | DEBUG_MSG(KERN_INFO "LCD Panel Size = %d\n", |
| 133 | viaparinfo->lvds_setting_info->lcd_panel_size); |
| 134 | break; |
| 135 | case GET_LCD_SIZE_BY_USER_SETTING: |
| 136 | DEBUG_MSG(KERN_INFO "Get LCD Size method by user setting !!\n"); |
| 137 | viaparinfo->lvds_setting_info->lcd_panel_size = |
| 138 | fp_id_to_vindex(viafb_lcd_panel_id); |
| 139 | DEBUG_MSG(KERN_INFO "LCD Panel_ID = %d\n", |
| 140 | viaparinfo->lvds_setting_info->lcd_panel_id); |
| 141 | DEBUG_MSG(KERN_INFO "LCD Panel Size = %d\n", |
| 142 | viaparinfo->lvds_setting_info->lcd_panel_size); |
| 143 | break; |
| 144 | default: |
| 145 | DEBUG_MSG(KERN_INFO "viafb_init_lcd_size fail\n"); |
| 146 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 147 | LCD_PANEL_ID1_800X600; |
| 148 | viaparinfo->lvds_setting_info->lcd_panel_size = |
| 149 | fp_id_to_vindex(LCD_PANEL_ID1_800X600); |
| 150 | } |
| 151 | viaparinfo->lvds_setting_info2->lcd_panel_id = |
| 152 | viaparinfo->lvds_setting_info->lcd_panel_id; |
| 153 | viaparinfo->lvds_setting_info2->lcd_panel_size = |
| 154 | viaparinfo->lvds_setting_info->lcd_panel_size; |
| 155 | viaparinfo->lvds_setting_info2->lcd_panel_hres = |
| 156 | viaparinfo->lvds_setting_info->lcd_panel_hres; |
| 157 | viaparinfo->lvds_setting_info2->lcd_panel_vres = |
| 158 | viaparinfo->lvds_setting_info->lcd_panel_vres; |
| 159 | viaparinfo->lvds_setting_info2->device_lcd_dualedge = |
| 160 | viaparinfo->lvds_setting_info->device_lcd_dualedge; |
| 161 | viaparinfo->lvds_setting_info2->LCDDithering = |
| 162 | viaparinfo->lvds_setting_info->LCDDithering; |
| 163 | } |
| 164 | |
| 165 | static bool lvds_identify_integratedlvds(void) |
| 166 | { |
| 167 | if (viafb_display_hardware_layout == HW_LAYOUT_LCD_EXTERNAL_LCD2) { |
| 168 | /* Two dual channel LCD (Internal LVDS + External LVDS): */ |
| 169 | /* If we have an external LVDS, such as VT1636, we should |
| 170 | have its chip ID already. */ |
| 171 | if (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { |
| 172 | viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name = |
| 173 | INTEGRATED_LVDS; |
| 174 | DEBUG_MSG(KERN_INFO "Support two dual channel LVDS!\ |
| 175 | (Internal LVDS + External LVDS)\n"); |
| 176 | } else { |
| 177 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = |
| 178 | INTEGRATED_LVDS; |
| 179 | DEBUG_MSG(KERN_INFO "Not found external LVDS,\ |
| 180 | so can't support two dual channel LVDS!\n"); |
| 181 | } |
| 182 | } else if (viafb_display_hardware_layout == HW_LAYOUT_LCD1_LCD2) { |
| 183 | /* Two single channel LCD (Internal LVDS + Internal LVDS): */ |
| 184 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = |
| 185 | INTEGRATED_LVDS; |
| 186 | viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name = |
| 187 | INTEGRATED_LVDS; |
| 188 | DEBUG_MSG(KERN_INFO "Support two single channel LVDS!\ |
| 189 | (Internal LVDS + Internal LVDS)\n"); |
| 190 | } else if (viafb_display_hardware_layout != HW_LAYOUT_DVI_ONLY) { |
| 191 | /* If we have found external LVDS, just use it, |
| 192 | otherwise, we will use internal LVDS as default. */ |
| 193 | if (!viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { |
| 194 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = |
| 195 | INTEGRATED_LVDS; |
| 196 | DEBUG_MSG(KERN_INFO "Found Integrated LVDS!\n"); |
| 197 | } |
| 198 | } else { |
| 199 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = |
| 200 | NON_LVDS_TRANSMITTER; |
| 201 | DEBUG_MSG(KERN_INFO "Do not support LVDS!\n"); |
| 202 | return false; |
| 203 | } |
| 204 | |
| 205 | return true; |
| 206 | } |
| 207 | |
| 208 | int viafb_lvds_trasmitter_identify(void) |
| 209 | { |
Florian Tobias Schandinat | c4df548 | 2009-09-22 16:47:24 -0700 | [diff] [blame^] | 210 | viaparinfo->shared->i2c_stuff.i2c_port = I2CPORTINDEX; |
Joseph Chan | ac6c97e | 2008-10-15 22:03:25 -0700 | [diff] [blame] | 211 | if (viafb_lvds_identify_vt1636()) { |
| 212 | viaparinfo->chip_info->lvds_chip_info.i2c_port = I2CPORTINDEX; |
| 213 | DEBUG_MSG(KERN_INFO |
| 214 | "Found VIA VT1636 LVDS on port i2c 0x31 \n"); |
| 215 | } else { |
Florian Tobias Schandinat | c4df548 | 2009-09-22 16:47:24 -0700 | [diff] [blame^] | 216 | viaparinfo->shared->i2c_stuff.i2c_port = GPIOPORTINDEX; |
Joseph Chan | ac6c97e | 2008-10-15 22:03:25 -0700 | [diff] [blame] | 217 | if (viafb_lvds_identify_vt1636()) { |
| 218 | viaparinfo->chip_info->lvds_chip_info.i2c_port = |
| 219 | GPIOPORTINDEX; |
| 220 | DEBUG_MSG(KERN_INFO |
| 221 | "Found VIA VT1636 LVDS on port gpio 0x2c \n"); |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) |
| 226 | lvds_identify_integratedlvds(); |
| 227 | |
| 228 | if (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) |
| 229 | return true; |
| 230 | /* Check for VT1631: */ |
| 231 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = VT1631_LVDS; |
| 232 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr = |
| 233 | VT1631_LVDS_I2C_ADDR; |
| 234 | |
| 235 | if (check_lvds_chip(VT1631_DEVICE_ID_REG, VT1631_DEVICE_ID) != FAIL) { |
| 236 | DEBUG_MSG(KERN_INFO "\n VT1631 LVDS ! \n"); |
| 237 | DEBUG_MSG(KERN_INFO "\n %2d", |
| 238 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_name); |
| 239 | DEBUG_MSG(KERN_INFO "\n %2d", |
| 240 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_name); |
| 241 | return OK; |
| 242 | } |
| 243 | |
| 244 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_name = |
| 245 | NON_LVDS_TRANSMITTER; |
| 246 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr = |
| 247 | VT1631_LVDS_I2C_ADDR; |
| 248 | return FAIL; |
| 249 | } |
| 250 | |
| 251 | static int fp_id_to_vindex(int panel_id) |
| 252 | { |
| 253 | DEBUG_MSG(KERN_INFO "fp_get_panel_id()\n"); |
| 254 | |
| 255 | if (panel_id > LCD_PANEL_ID_MAXIMUM) |
| 256 | viafb_lcd_panel_id = panel_id = |
| 257 | viafb_read_reg(VIACR, CR3F) & 0x0F; |
| 258 | |
| 259 | switch (panel_id) { |
| 260 | case 0x0: |
| 261 | viaparinfo->lvds_setting_info->lcd_panel_hres = 640; |
| 262 | viaparinfo->lvds_setting_info->lcd_panel_vres = 480; |
| 263 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 264 | LCD_PANEL_ID0_640X480; |
| 265 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
| 266 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
| 267 | return VIA_RES_640X480; |
| 268 | break; |
| 269 | case 0x1: |
| 270 | viaparinfo->lvds_setting_info->lcd_panel_hres = 800; |
| 271 | viaparinfo->lvds_setting_info->lcd_panel_vres = 600; |
| 272 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 273 | LCD_PANEL_ID1_800X600; |
| 274 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
| 275 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
| 276 | return VIA_RES_800X600; |
| 277 | break; |
| 278 | case 0x2: |
| 279 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; |
| 280 | viaparinfo->lvds_setting_info->lcd_panel_vres = 768; |
| 281 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 282 | LCD_PANEL_ID2_1024X768; |
| 283 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
| 284 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
| 285 | return VIA_RES_1024X768; |
| 286 | break; |
| 287 | case 0x3: |
| 288 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; |
| 289 | viaparinfo->lvds_setting_info->lcd_panel_vres = 768; |
| 290 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 291 | LCD_PANEL_ID3_1280X768; |
| 292 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
| 293 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
| 294 | return VIA_RES_1280X768; |
| 295 | break; |
| 296 | case 0x4: |
| 297 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; |
| 298 | viaparinfo->lvds_setting_info->lcd_panel_vres = 1024; |
| 299 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 300 | LCD_PANEL_ID4_1280X1024; |
| 301 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
| 302 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
| 303 | return VIA_RES_1280X1024; |
| 304 | break; |
| 305 | case 0x5: |
| 306 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1400; |
| 307 | viaparinfo->lvds_setting_info->lcd_panel_vres = 1050; |
| 308 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 309 | LCD_PANEL_ID5_1400X1050; |
| 310 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
| 311 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
| 312 | return VIA_RES_1400X1050; |
| 313 | break; |
| 314 | case 0x6: |
| 315 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1600; |
| 316 | viaparinfo->lvds_setting_info->lcd_panel_vres = 1200; |
| 317 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 318 | LCD_PANEL_ID6_1600X1200; |
| 319 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
| 320 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
| 321 | return VIA_RES_1600X1200; |
| 322 | break; |
| 323 | case 0x8: |
| 324 | viaparinfo->lvds_setting_info->lcd_panel_hres = 800; |
| 325 | viaparinfo->lvds_setting_info->lcd_panel_vres = 480; |
| 326 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 327 | LCD_PANEL_IDA_800X480; |
| 328 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
| 329 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
| 330 | return VIA_RES_800X480; |
| 331 | break; |
| 332 | case 0x9: |
| 333 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; |
| 334 | viaparinfo->lvds_setting_info->lcd_panel_vres = 768; |
| 335 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 336 | LCD_PANEL_ID2_1024X768; |
| 337 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
| 338 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
| 339 | return VIA_RES_1024X768; |
| 340 | break; |
| 341 | case 0xA: |
| 342 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; |
| 343 | viaparinfo->lvds_setting_info->lcd_panel_vres = 768; |
| 344 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 345 | LCD_PANEL_ID2_1024X768; |
| 346 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
| 347 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
| 348 | return VIA_RES_1024X768; |
| 349 | break; |
| 350 | case 0xB: |
| 351 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; |
| 352 | viaparinfo->lvds_setting_info->lcd_panel_vres = 768; |
| 353 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 354 | LCD_PANEL_ID2_1024X768; |
| 355 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
| 356 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
| 357 | return VIA_RES_1024X768; |
| 358 | break; |
| 359 | case 0xC: |
| 360 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; |
| 361 | viaparinfo->lvds_setting_info->lcd_panel_vres = 768; |
| 362 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 363 | LCD_PANEL_ID3_1280X768; |
| 364 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
| 365 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
| 366 | return VIA_RES_1280X768; |
| 367 | break; |
| 368 | case 0xD: |
| 369 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; |
| 370 | viaparinfo->lvds_setting_info->lcd_panel_vres = 1024; |
| 371 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 372 | LCD_PANEL_ID4_1280X1024; |
| 373 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
| 374 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
| 375 | return VIA_RES_1280X1024; |
| 376 | break; |
| 377 | case 0xE: |
| 378 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1400; |
| 379 | viaparinfo->lvds_setting_info->lcd_panel_vres = 1050; |
| 380 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 381 | LCD_PANEL_ID5_1400X1050; |
| 382 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
| 383 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
| 384 | return VIA_RES_1400X1050; |
| 385 | break; |
| 386 | case 0xF: |
| 387 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1600; |
| 388 | viaparinfo->lvds_setting_info->lcd_panel_vres = 1200; |
| 389 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 390 | LCD_PANEL_ID6_1600X1200; |
| 391 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
| 392 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
| 393 | return VIA_RES_1600X1200; |
| 394 | break; |
| 395 | case 0x10: |
| 396 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1366; |
| 397 | viaparinfo->lvds_setting_info->lcd_panel_vres = 768; |
| 398 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 399 | LCD_PANEL_ID7_1366X768; |
| 400 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
| 401 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
| 402 | return VIA_RES_1368X768; |
| 403 | break; |
| 404 | case 0x11: |
| 405 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1024; |
| 406 | viaparinfo->lvds_setting_info->lcd_panel_vres = 600; |
| 407 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 408 | LCD_PANEL_ID8_1024X600; |
| 409 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
| 410 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
| 411 | return VIA_RES_1024X600; |
| 412 | break; |
| 413 | case 0x12: |
| 414 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; |
| 415 | viaparinfo->lvds_setting_info->lcd_panel_vres = 768; |
| 416 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 417 | LCD_PANEL_ID3_1280X768; |
| 418 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
| 419 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
| 420 | return VIA_RES_1280X768; |
| 421 | break; |
| 422 | case 0x13: |
| 423 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; |
| 424 | viaparinfo->lvds_setting_info->lcd_panel_vres = 800; |
| 425 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 426 | LCD_PANEL_ID9_1280X800; |
| 427 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
| 428 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
| 429 | return VIA_RES_1280X800; |
| 430 | break; |
| 431 | case 0x14: |
| 432 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1360; |
| 433 | viaparinfo->lvds_setting_info->lcd_panel_vres = 768; |
| 434 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 435 | LCD_PANEL_IDB_1360X768; |
| 436 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
| 437 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
| 438 | return VIA_RES_1360X768; |
| 439 | break; |
| 440 | case 0x15: |
| 441 | viaparinfo->lvds_setting_info->lcd_panel_hres = 1280; |
| 442 | viaparinfo->lvds_setting_info->lcd_panel_vres = 768; |
| 443 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 444 | LCD_PANEL_ID3_1280X768; |
| 445 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 1; |
| 446 | viaparinfo->lvds_setting_info->LCDDithering = 0; |
| 447 | return VIA_RES_1280X768; |
| 448 | break; |
| 449 | case 0x16: |
| 450 | viaparinfo->lvds_setting_info->lcd_panel_hres = 480; |
| 451 | viaparinfo->lvds_setting_info->lcd_panel_vres = 640; |
| 452 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 453 | LCD_PANEL_IDC_480X640; |
| 454 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
| 455 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
| 456 | return VIA_RES_480X640; |
| 457 | break; |
| 458 | default: |
| 459 | viaparinfo->lvds_setting_info->lcd_panel_hres = 800; |
| 460 | viaparinfo->lvds_setting_info->lcd_panel_vres = 600; |
| 461 | viaparinfo->lvds_setting_info->lcd_panel_id = |
| 462 | LCD_PANEL_ID1_800X600; |
| 463 | viaparinfo->lvds_setting_info->device_lcd_dualedge = 0; |
| 464 | viaparinfo->lvds_setting_info->LCDDithering = 1; |
| 465 | return VIA_RES_800X600; |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | static int lvds_register_read(int index) |
| 470 | { |
| 471 | u8 data; |
| 472 | |
Florian Tobias Schandinat | c4df548 | 2009-09-22 16:47:24 -0700 | [diff] [blame^] | 473 | viaparinfo->shared->i2c_stuff.i2c_port = GPIOPORTINDEX; |
Joseph Chan | ac6c97e | 2008-10-15 22:03:25 -0700 | [diff] [blame] | 474 | viafb_i2c_readbyte((u8) viaparinfo->chip_info-> |
| 475 | lvds_chip_info.lvds_chip_slave_addr, |
| 476 | (u8) index, &data); |
| 477 | return data; |
| 478 | } |
| 479 | |
| 480 | static void load_lcd_scaling(int set_hres, int set_vres, int panel_hres, |
| 481 | int panel_vres) |
| 482 | { |
| 483 | int reg_value = 0; |
| 484 | int viafb_load_reg_num; |
| 485 | struct io_register *reg = NULL; |
| 486 | |
| 487 | DEBUG_MSG(KERN_INFO "load_lcd_scaling()!!\n"); |
| 488 | |
| 489 | /* LCD Scaling Enable */ |
| 490 | viafb_write_reg_mask(CR79, VIACR, 0x07, BIT0 + BIT1 + BIT2); |
| 491 | if (UNICHROME_P4M900 == viaparinfo->chip_info->gfx_chip_name) { |
| 492 | viafb_load_scaling_factor_for_p4m900(set_hres, set_vres, |
| 493 | panel_hres, panel_vres); |
| 494 | return; |
| 495 | } |
| 496 | |
| 497 | /* Check if expansion for horizontal */ |
| 498 | if (set_hres != panel_hres) { |
| 499 | /* Load Horizontal Scaling Factor */ |
| 500 | switch (viaparinfo->chip_info->gfx_chip_name) { |
| 501 | case UNICHROME_CLE266: |
| 502 | case UNICHROME_K400: |
| 503 | reg_value = |
| 504 | CLE266_LCD_HOR_SCF_FORMULA(set_hres, panel_hres); |
| 505 | viafb_load_reg_num = |
| 506 | lcd_scaling_factor_CLE.lcd_hor_scaling_factor. |
| 507 | reg_num; |
| 508 | reg = lcd_scaling_factor_CLE.lcd_hor_scaling_factor.reg; |
| 509 | viafb_load_reg(reg_value, |
| 510 | viafb_load_reg_num, reg, VIACR); |
| 511 | break; |
| 512 | case UNICHROME_K800: |
| 513 | case UNICHROME_PM800: |
| 514 | case UNICHROME_CN700: |
| 515 | case UNICHROME_CX700: |
| 516 | case UNICHROME_K8M890: |
| 517 | case UNICHROME_P4M890: |
| 518 | reg_value = |
| 519 | K800_LCD_HOR_SCF_FORMULA(set_hres, panel_hres); |
| 520 | /* Horizontal scaling enabled */ |
| 521 | viafb_write_reg_mask(CRA2, VIACR, 0xC0, BIT7 + BIT6); |
| 522 | viafb_load_reg_num = |
| 523 | lcd_scaling_factor.lcd_hor_scaling_factor.reg_num; |
| 524 | reg = lcd_scaling_factor.lcd_hor_scaling_factor.reg; |
| 525 | viafb_load_reg(reg_value, |
| 526 | viafb_load_reg_num, reg, VIACR); |
| 527 | break; |
| 528 | } |
| 529 | |
| 530 | DEBUG_MSG(KERN_INFO "Horizontal Scaling value = %d", reg_value); |
| 531 | } else { |
| 532 | /* Horizontal scaling disabled */ |
| 533 | viafb_write_reg_mask(CRA2, VIACR, 0x00, BIT7); |
| 534 | } |
| 535 | |
| 536 | /* Check if expansion for vertical */ |
| 537 | if (set_vres != panel_vres) { |
| 538 | /* Load Vertical Scaling Factor */ |
| 539 | switch (viaparinfo->chip_info->gfx_chip_name) { |
| 540 | case UNICHROME_CLE266: |
| 541 | case UNICHROME_K400: |
| 542 | reg_value = |
| 543 | CLE266_LCD_VER_SCF_FORMULA(set_vres, panel_vres); |
| 544 | viafb_load_reg_num = |
| 545 | lcd_scaling_factor_CLE.lcd_ver_scaling_factor. |
| 546 | reg_num; |
| 547 | reg = lcd_scaling_factor_CLE.lcd_ver_scaling_factor.reg; |
| 548 | viafb_load_reg(reg_value, |
| 549 | viafb_load_reg_num, reg, VIACR); |
| 550 | break; |
| 551 | case UNICHROME_K800: |
| 552 | case UNICHROME_PM800: |
| 553 | case UNICHROME_CN700: |
| 554 | case UNICHROME_CX700: |
| 555 | case UNICHROME_K8M890: |
| 556 | case UNICHROME_P4M890: |
| 557 | reg_value = |
| 558 | K800_LCD_VER_SCF_FORMULA(set_vres, panel_vres); |
| 559 | /* Vertical scaling enabled */ |
| 560 | viafb_write_reg_mask(CRA2, VIACR, 0x08, BIT3); |
| 561 | viafb_load_reg_num = |
| 562 | lcd_scaling_factor.lcd_ver_scaling_factor.reg_num; |
| 563 | reg = lcd_scaling_factor.lcd_ver_scaling_factor.reg; |
| 564 | viafb_load_reg(reg_value, |
| 565 | viafb_load_reg_num, reg, VIACR); |
| 566 | break; |
| 567 | } |
| 568 | |
| 569 | DEBUG_MSG(KERN_INFO "Vertical Scaling value = %d", reg_value); |
| 570 | } else { |
| 571 | /* Vertical scaling disabled */ |
| 572 | viafb_write_reg_mask(CRA2, VIACR, 0x00, BIT3); |
| 573 | } |
| 574 | } |
| 575 | |
| 576 | static void load_lcd_k400_patch_tbl(int set_hres, int set_vres, |
| 577 | int panel_id) |
| 578 | { |
| 579 | int vmode_index; |
| 580 | int reg_num = 0; |
| 581 | struct io_reg *lcd_patch_reg = NULL; |
| 582 | |
Florian Tobias Schandinat | 5215944 | 2009-08-06 15:07:34 -0700 | [diff] [blame] | 583 | vmode_index = viafb_get_mode_index(set_hres, set_vres); |
Joseph Chan | ac6c97e | 2008-10-15 22:03:25 -0700 | [diff] [blame] | 584 | switch (panel_id) { |
| 585 | /* LCD 800x600 */ |
| 586 | case LCD_PANEL_ID1_800X600: |
| 587 | switch (vmode_index) { |
| 588 | case VIA_RES_640X400: |
| 589 | case VIA_RES_640X480: |
| 590 | reg_num = NUM_TOTAL_K400_LCD_RES_6X4_8X6; |
| 591 | lcd_patch_reg = K400_LCD_RES_6X4_8X6; |
| 592 | break; |
| 593 | case VIA_RES_720X480: |
| 594 | case VIA_RES_720X576: |
| 595 | reg_num = NUM_TOTAL_K400_LCD_RES_7X4_8X6; |
| 596 | lcd_patch_reg = K400_LCD_RES_7X4_8X6; |
| 597 | break; |
| 598 | } |
| 599 | break; |
| 600 | |
| 601 | /* LCD 1024x768 */ |
| 602 | case LCD_PANEL_ID2_1024X768: |
| 603 | switch (vmode_index) { |
| 604 | case VIA_RES_640X400: |
| 605 | case VIA_RES_640X480: |
| 606 | reg_num = NUM_TOTAL_K400_LCD_RES_6X4_10X7; |
| 607 | lcd_patch_reg = K400_LCD_RES_6X4_10X7; |
| 608 | break; |
| 609 | case VIA_RES_720X480: |
| 610 | case VIA_RES_720X576: |
| 611 | reg_num = NUM_TOTAL_K400_LCD_RES_7X4_10X7; |
| 612 | lcd_patch_reg = K400_LCD_RES_7X4_10X7; |
| 613 | break; |
| 614 | case VIA_RES_800X600: |
| 615 | reg_num = NUM_TOTAL_K400_LCD_RES_8X6_10X7; |
| 616 | lcd_patch_reg = K400_LCD_RES_8X6_10X7; |
| 617 | break; |
| 618 | } |
| 619 | break; |
| 620 | |
| 621 | /* LCD 1280x1024 */ |
| 622 | case LCD_PANEL_ID4_1280X1024: |
| 623 | switch (vmode_index) { |
| 624 | case VIA_RES_640X400: |
| 625 | case VIA_RES_640X480: |
| 626 | reg_num = NUM_TOTAL_K400_LCD_RES_6X4_12X10; |
| 627 | lcd_patch_reg = K400_LCD_RES_6X4_12X10; |
| 628 | break; |
| 629 | case VIA_RES_720X480: |
| 630 | case VIA_RES_720X576: |
| 631 | reg_num = NUM_TOTAL_K400_LCD_RES_7X4_12X10; |
| 632 | lcd_patch_reg = K400_LCD_RES_7X4_12X10; |
| 633 | break; |
| 634 | case VIA_RES_800X600: |
| 635 | reg_num = NUM_TOTAL_K400_LCD_RES_8X6_12X10; |
| 636 | lcd_patch_reg = K400_LCD_RES_8X6_12X10; |
| 637 | break; |
| 638 | case VIA_RES_1024X768: |
| 639 | reg_num = NUM_TOTAL_K400_LCD_RES_10X7_12X10; |
| 640 | lcd_patch_reg = K400_LCD_RES_10X7_12X10; |
| 641 | break; |
| 642 | |
| 643 | } |
| 644 | break; |
| 645 | |
| 646 | /* LCD 1400x1050 */ |
| 647 | case LCD_PANEL_ID5_1400X1050: |
| 648 | switch (vmode_index) { |
| 649 | case VIA_RES_640X480: |
| 650 | reg_num = NUM_TOTAL_K400_LCD_RES_6X4_14X10; |
| 651 | lcd_patch_reg = K400_LCD_RES_6X4_14X10; |
| 652 | break; |
| 653 | case VIA_RES_800X600: |
| 654 | reg_num = NUM_TOTAL_K400_LCD_RES_8X6_14X10; |
| 655 | lcd_patch_reg = K400_LCD_RES_8X6_14X10; |
| 656 | break; |
| 657 | case VIA_RES_1024X768: |
| 658 | reg_num = NUM_TOTAL_K400_LCD_RES_10X7_14X10; |
| 659 | lcd_patch_reg = K400_LCD_RES_10X7_14X10; |
| 660 | break; |
| 661 | case VIA_RES_1280X768: |
| 662 | case VIA_RES_1280X800: |
| 663 | case VIA_RES_1280X960: |
| 664 | case VIA_RES_1280X1024: |
| 665 | reg_num = NUM_TOTAL_K400_LCD_RES_12X10_14X10; |
| 666 | lcd_patch_reg = K400_LCD_RES_12X10_14X10; |
| 667 | break; |
| 668 | } |
| 669 | break; |
| 670 | |
| 671 | /* LCD 1600x1200 */ |
| 672 | case LCD_PANEL_ID6_1600X1200: |
| 673 | switch (vmode_index) { |
| 674 | case VIA_RES_640X400: |
| 675 | case VIA_RES_640X480: |
| 676 | reg_num = NUM_TOTAL_K400_LCD_RES_6X4_16X12; |
| 677 | lcd_patch_reg = K400_LCD_RES_6X4_16X12; |
| 678 | break; |
| 679 | case VIA_RES_720X480: |
| 680 | case VIA_RES_720X576: |
| 681 | reg_num = NUM_TOTAL_K400_LCD_RES_7X4_16X12; |
| 682 | lcd_patch_reg = K400_LCD_RES_7X4_16X12; |
| 683 | break; |
| 684 | case VIA_RES_800X600: |
| 685 | reg_num = NUM_TOTAL_K400_LCD_RES_8X6_16X12; |
| 686 | lcd_patch_reg = K400_LCD_RES_8X6_16X12; |
| 687 | break; |
| 688 | case VIA_RES_1024X768: |
| 689 | reg_num = NUM_TOTAL_K400_LCD_RES_10X7_16X12; |
| 690 | lcd_patch_reg = K400_LCD_RES_10X7_16X12; |
| 691 | break; |
| 692 | case VIA_RES_1280X768: |
| 693 | case VIA_RES_1280X800: |
| 694 | case VIA_RES_1280X960: |
| 695 | case VIA_RES_1280X1024: |
| 696 | reg_num = NUM_TOTAL_K400_LCD_RES_12X10_16X12; |
| 697 | lcd_patch_reg = K400_LCD_RES_12X10_16X12; |
| 698 | break; |
| 699 | } |
| 700 | break; |
| 701 | |
| 702 | /* LCD 1366x768 */ |
| 703 | case LCD_PANEL_ID7_1366X768: |
| 704 | switch (vmode_index) { |
| 705 | case VIA_RES_640X480: |
| 706 | reg_num = NUM_TOTAL_K400_LCD_RES_6X4_1366X7; |
| 707 | lcd_patch_reg = K400_LCD_RES_6X4_1366X7; |
| 708 | break; |
| 709 | case VIA_RES_720X480: |
| 710 | case VIA_RES_720X576: |
| 711 | reg_num = NUM_TOTAL_K400_LCD_RES_7X4_1366X7; |
| 712 | lcd_patch_reg = K400_LCD_RES_7X4_1366X7; |
| 713 | break; |
| 714 | case VIA_RES_800X600: |
| 715 | reg_num = NUM_TOTAL_K400_LCD_RES_8X6_1366X7; |
| 716 | lcd_patch_reg = K400_LCD_RES_8X6_1366X7; |
| 717 | break; |
| 718 | case VIA_RES_1024X768: |
| 719 | reg_num = NUM_TOTAL_K400_LCD_RES_10X7_1366X7; |
| 720 | lcd_patch_reg = K400_LCD_RES_10X7_1366X7; |
| 721 | break; |
| 722 | case VIA_RES_1280X768: |
| 723 | case VIA_RES_1280X800: |
| 724 | case VIA_RES_1280X960: |
| 725 | case VIA_RES_1280X1024: |
| 726 | reg_num = NUM_TOTAL_K400_LCD_RES_12X10_1366X7; |
| 727 | lcd_patch_reg = K400_LCD_RES_12X10_1366X7; |
| 728 | break; |
| 729 | } |
| 730 | break; |
| 731 | |
| 732 | /* LCD 1360x768 */ |
| 733 | case LCD_PANEL_IDB_1360X768: |
| 734 | break; |
| 735 | } |
| 736 | if (reg_num != 0) { |
| 737 | /* H.W. Reset : ON */ |
| 738 | viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7); |
| 739 | |
| 740 | viafb_write_regx(lcd_patch_reg, reg_num); |
| 741 | |
| 742 | /* H.W. Reset : OFF */ |
| 743 | viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7); |
| 744 | |
| 745 | /* Reset PLL */ |
| 746 | viafb_write_reg_mask(SR40, VIASR, 0x02, BIT1); |
| 747 | viafb_write_reg_mask(SR40, VIASR, 0x00, BIT1); |
| 748 | |
| 749 | /* Fire! */ |
| 750 | outb(inb(VIARMisc) | (BIT2 + BIT3), VIAWMisc); |
| 751 | } |
| 752 | } |
| 753 | |
| 754 | static void load_lcd_p880_patch_tbl(int set_hres, int set_vres, |
| 755 | int panel_id) |
| 756 | { |
| 757 | int vmode_index; |
| 758 | int reg_num = 0; |
| 759 | struct io_reg *lcd_patch_reg = NULL; |
| 760 | |
Florian Tobias Schandinat | 5215944 | 2009-08-06 15:07:34 -0700 | [diff] [blame] | 761 | vmode_index = viafb_get_mode_index(set_hres, set_vres); |
Joseph Chan | ac6c97e | 2008-10-15 22:03:25 -0700 | [diff] [blame] | 762 | |
| 763 | switch (panel_id) { |
| 764 | case LCD_PANEL_ID5_1400X1050: |
| 765 | switch (vmode_index) { |
| 766 | case VIA_RES_640X480: |
| 767 | reg_num = NUM_TOTAL_P880_LCD_RES_6X4_14X10; |
| 768 | lcd_patch_reg = P880_LCD_RES_6X4_14X10; |
| 769 | break; |
| 770 | case VIA_RES_800X600: |
| 771 | reg_num = NUM_TOTAL_P880_LCD_RES_8X6_14X10; |
| 772 | lcd_patch_reg = P880_LCD_RES_8X6_14X10; |
| 773 | break; |
| 774 | } |
| 775 | break; |
| 776 | case LCD_PANEL_ID6_1600X1200: |
| 777 | switch (vmode_index) { |
| 778 | case VIA_RES_640X400: |
| 779 | case VIA_RES_640X480: |
| 780 | reg_num = NUM_TOTAL_P880_LCD_RES_6X4_16X12; |
| 781 | lcd_patch_reg = P880_LCD_RES_6X4_16X12; |
| 782 | break; |
| 783 | case VIA_RES_720X480: |
| 784 | case VIA_RES_720X576: |
| 785 | reg_num = NUM_TOTAL_P880_LCD_RES_7X4_16X12; |
| 786 | lcd_patch_reg = P880_LCD_RES_7X4_16X12; |
| 787 | break; |
| 788 | case VIA_RES_800X600: |
| 789 | reg_num = NUM_TOTAL_P880_LCD_RES_8X6_16X12; |
| 790 | lcd_patch_reg = P880_LCD_RES_8X6_16X12; |
| 791 | break; |
| 792 | case VIA_RES_1024X768: |
| 793 | reg_num = NUM_TOTAL_P880_LCD_RES_10X7_16X12; |
| 794 | lcd_patch_reg = P880_LCD_RES_10X7_16X12; |
| 795 | break; |
| 796 | case VIA_RES_1280X768: |
| 797 | case VIA_RES_1280X960: |
| 798 | case VIA_RES_1280X1024: |
| 799 | reg_num = NUM_TOTAL_P880_LCD_RES_12X10_16X12; |
| 800 | lcd_patch_reg = P880_LCD_RES_12X10_16X12; |
| 801 | break; |
| 802 | } |
| 803 | break; |
| 804 | |
| 805 | } |
| 806 | if (reg_num != 0) { |
| 807 | /* H.W. Reset : ON */ |
| 808 | viafb_write_reg_mask(CR17, VIACR, 0x00, BIT7); |
| 809 | |
| 810 | viafb_write_regx(lcd_patch_reg, reg_num); |
| 811 | |
| 812 | /* H.W. Reset : OFF */ |
| 813 | viafb_write_reg_mask(CR17, VIACR, 0x80, BIT7); |
| 814 | |
| 815 | /* Reset PLL */ |
| 816 | viafb_write_reg_mask(SR40, VIASR, 0x02, BIT1); |
| 817 | viafb_write_reg_mask(SR40, VIASR, 0x00, BIT1); |
| 818 | |
| 819 | /* Fire! */ |
| 820 | outb(inb(VIARMisc) | (BIT2 + BIT3), VIAWMisc); |
| 821 | } |
| 822 | } |
| 823 | |
| 824 | static void load_lcd_patch_regs(int set_hres, int set_vres, |
| 825 | int panel_id, int set_iga) |
| 826 | { |
| 827 | int vmode_index; |
| 828 | |
Florian Tobias Schandinat | 5215944 | 2009-08-06 15:07:34 -0700 | [diff] [blame] | 829 | vmode_index = viafb_get_mode_index(set_hres, set_vres); |
Joseph Chan | ac6c97e | 2008-10-15 22:03:25 -0700 | [diff] [blame] | 830 | |
| 831 | viafb_unlock_crt(); |
| 832 | |
| 833 | /* Patch for simultaneous & Expansion */ |
| 834 | if ((set_iga == IGA1_IGA2) && |
| 835 | (viaparinfo->lvds_setting_info->display_method == |
| 836 | LCD_EXPANDSION)) { |
| 837 | switch (viaparinfo->chip_info->gfx_chip_name) { |
| 838 | case UNICHROME_CLE266: |
| 839 | case UNICHROME_K400: |
| 840 | load_lcd_k400_patch_tbl(set_hres, set_vres, panel_id); |
| 841 | break; |
| 842 | case UNICHROME_K800: |
| 843 | break; |
| 844 | case UNICHROME_PM800: |
| 845 | case UNICHROME_CN700: |
| 846 | case UNICHROME_CX700: |
| 847 | load_lcd_p880_patch_tbl(set_hres, set_vres, panel_id); |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | viafb_lock_crt(); |
| 852 | } |
| 853 | |
| 854 | static void via_pitch_alignment_patch_lcd( |
| 855 | struct lvds_setting_information *plvds_setting_info, |
| 856 | struct lvds_chip_information |
| 857 | *plvds_chip_info) |
| 858 | { |
| 859 | unsigned char cr13, cr35, cr65, cr66, cr67; |
| 860 | unsigned long dwScreenPitch = 0; |
| 861 | unsigned long dwPitch; |
| 862 | |
| 863 | dwPitch = plvds_setting_info->h_active * (plvds_setting_info->bpp >> 3); |
| 864 | if (dwPitch & 0x1F) { |
| 865 | dwScreenPitch = ((dwPitch + 31) & ~31) >> 3; |
| 866 | if (plvds_setting_info->iga_path == IGA2) { |
| 867 | if (plvds_setting_info->bpp > 8) { |
| 868 | cr66 = (unsigned char)(dwScreenPitch & 0xFF); |
| 869 | viafb_write_reg(CR66, VIACR, cr66); |
| 870 | cr67 = viafb_read_reg(VIACR, CR67) & 0xFC; |
| 871 | cr67 |= |
| 872 | (unsigned |
| 873 | char)((dwScreenPitch & 0x300) >> 8); |
| 874 | viafb_write_reg(CR67, VIACR, cr67); |
| 875 | } |
| 876 | |
| 877 | /* Fetch Count */ |
| 878 | cr67 = viafb_read_reg(VIACR, CR67) & 0xF3; |
| 879 | cr67 |= (unsigned char)((dwScreenPitch & 0x600) >> 7); |
| 880 | viafb_write_reg(CR67, VIACR, cr67); |
| 881 | cr65 = (unsigned char)((dwScreenPitch >> 1) & 0xFF); |
| 882 | cr65 += 2; |
| 883 | viafb_write_reg(CR65, VIACR, cr65); |
| 884 | } else { |
| 885 | if (plvds_setting_info->bpp > 8) { |
| 886 | cr13 = (unsigned char)(dwScreenPitch & 0xFF); |
| 887 | viafb_write_reg(CR13, VIACR, cr13); |
| 888 | cr35 = viafb_read_reg(VIACR, CR35) & 0x1F; |
| 889 | cr35 |= |
| 890 | (unsigned |
| 891 | char)((dwScreenPitch & 0x700) >> 3); |
| 892 | viafb_write_reg(CR35, VIACR, cr35); |
| 893 | } |
| 894 | } |
| 895 | } |
| 896 | } |
| 897 | static void lcd_patch_skew_dvp0(struct lvds_setting_information |
| 898 | *plvds_setting_info, |
| 899 | struct lvds_chip_information *plvds_chip_info) |
| 900 | { |
| 901 | if (VT1636_LVDS == plvds_chip_info->lvds_chip_name) { |
| 902 | switch (viaparinfo->chip_info->gfx_chip_name) { |
| 903 | case UNICHROME_P4M900: |
| 904 | viafb_vt1636_patch_skew_on_vt3364(plvds_setting_info, |
| 905 | plvds_chip_info); |
| 906 | break; |
| 907 | case UNICHROME_P4M890: |
| 908 | viafb_vt1636_patch_skew_on_vt3327(plvds_setting_info, |
| 909 | plvds_chip_info); |
| 910 | break; |
| 911 | } |
| 912 | } |
| 913 | } |
| 914 | static void lcd_patch_skew_dvp1(struct lvds_setting_information |
| 915 | *plvds_setting_info, |
| 916 | struct lvds_chip_information *plvds_chip_info) |
| 917 | { |
| 918 | if (VT1636_LVDS == plvds_chip_info->lvds_chip_name) { |
| 919 | switch (viaparinfo->chip_info->gfx_chip_name) { |
| 920 | case UNICHROME_CX700: |
| 921 | viafb_vt1636_patch_skew_on_vt3324(plvds_setting_info, |
| 922 | plvds_chip_info); |
| 923 | break; |
| 924 | } |
| 925 | } |
| 926 | } |
| 927 | static void lcd_patch_skew(struct lvds_setting_information |
| 928 | *plvds_setting_info, struct lvds_chip_information *plvds_chip_info) |
| 929 | { |
| 930 | DEBUG_MSG(KERN_INFO "lcd_patch_skew\n"); |
| 931 | switch (plvds_chip_info->output_interface) { |
| 932 | case INTERFACE_DVP0: |
| 933 | lcd_patch_skew_dvp0(plvds_setting_info, plvds_chip_info); |
| 934 | break; |
| 935 | case INTERFACE_DVP1: |
| 936 | lcd_patch_skew_dvp1(plvds_setting_info, plvds_chip_info); |
| 937 | break; |
| 938 | case INTERFACE_DFP_LOW: |
| 939 | if (UNICHROME_P4M900 == viaparinfo->chip_info->gfx_chip_name) { |
| 940 | viafb_write_reg_mask(CR99, VIACR, 0x08, |
| 941 | BIT0 + BIT1 + BIT2 + BIT3); |
| 942 | } |
| 943 | break; |
| 944 | } |
| 945 | } |
| 946 | |
| 947 | /* LCD Set Mode */ |
| 948 | void viafb_lcd_set_mode(struct crt_mode_table *mode_crt_table, |
| 949 | struct lvds_setting_information *plvds_setting_info, |
| 950 | struct lvds_chip_information *plvds_chip_info) |
| 951 | { |
| 952 | int video_index = plvds_setting_info->lcd_panel_size; |
| 953 | int set_iga = plvds_setting_info->iga_path; |
| 954 | int mode_bpp = plvds_setting_info->bpp; |
| 955 | int viafb_load_reg_num = 0; |
| 956 | int reg_value = 0; |
| 957 | int set_hres, set_vres; |
| 958 | int panel_hres, panel_vres; |
| 959 | u32 pll_D_N; |
| 960 | int offset; |
| 961 | struct io_register *reg = NULL; |
| 962 | struct display_timing mode_crt_reg, panel_crt_reg; |
| 963 | struct crt_mode_table *panel_crt_table = NULL; |
| 964 | struct VideoModeTable *vmode_tbl = NULL; |
| 965 | |
| 966 | DEBUG_MSG(KERN_INFO "viafb_lcd_set_mode!!\n"); |
| 967 | /* Get mode table */ |
| 968 | mode_crt_reg = mode_crt_table->crtc; |
| 969 | /* Get panel table Pointer */ |
| 970 | vmode_tbl = viafb_get_modetbl_pointer(video_index); |
| 971 | panel_crt_table = vmode_tbl->crtc; |
| 972 | panel_crt_reg = panel_crt_table->crtc; |
| 973 | DEBUG_MSG(KERN_INFO "bellow viafb_lcd_set_mode!!\n"); |
| 974 | set_hres = plvds_setting_info->h_active; |
| 975 | set_vres = plvds_setting_info->v_active; |
| 976 | panel_hres = plvds_setting_info->lcd_panel_hres; |
| 977 | panel_vres = plvds_setting_info->lcd_panel_vres; |
| 978 | if (VT1636_LVDS == plvds_chip_info->lvds_chip_name) |
| 979 | viafb_init_lvds_vt1636(plvds_setting_info, plvds_chip_info); |
| 980 | plvds_setting_info->vclk = panel_crt_table->clk; |
| 981 | if (set_iga == IGA1) { |
| 982 | /* IGA1 doesn't have LCD scaling, so set it as centering. */ |
| 983 | viafb_load_crtc_timing(lcd_centering_timging |
| 984 | (mode_crt_reg, panel_crt_reg), IGA1); |
| 985 | } else { |
| 986 | /* Expansion */ |
| 987 | if ((plvds_setting_info->display_method == |
| 988 | LCD_EXPANDSION) & ((set_hres != panel_hres) |
| 989 | || (set_vres != panel_vres))) { |
| 990 | /* expansion timing IGA2 loaded panel set timing*/ |
| 991 | viafb_load_crtc_timing(panel_crt_reg, IGA2); |
| 992 | DEBUG_MSG(KERN_INFO "viafb_load_crtc_timing!!\n"); |
| 993 | load_lcd_scaling(set_hres, set_vres, panel_hres, |
| 994 | panel_vres); |
| 995 | DEBUG_MSG(KERN_INFO "load_lcd_scaling!!\n"); |
| 996 | } else { /* Centering */ |
| 997 | /* centering timing IGA2 always loaded panel |
| 998 | and mode releative timing */ |
| 999 | viafb_load_crtc_timing(lcd_centering_timging |
| 1000 | (mode_crt_reg, panel_crt_reg), IGA2); |
| 1001 | viafb_write_reg_mask(CR79, VIACR, 0x00, |
| 1002 | BIT0 + BIT1 + BIT2); |
| 1003 | /* LCD scaling disabled */ |
| 1004 | } |
| 1005 | } |
| 1006 | |
| 1007 | if (set_iga == IGA1_IGA2) { |
| 1008 | load_crtc_shadow_timing(mode_crt_reg, panel_crt_reg); |
| 1009 | /* Fill shadow registers */ |
| 1010 | |
| 1011 | switch (plvds_setting_info->lcd_panel_id) { |
| 1012 | case LCD_PANEL_ID0_640X480: |
| 1013 | offset = 80; |
| 1014 | break; |
| 1015 | case LCD_PANEL_ID1_800X600: |
| 1016 | case LCD_PANEL_IDA_800X480: |
| 1017 | offset = 110; |
| 1018 | break; |
| 1019 | case LCD_PANEL_ID2_1024X768: |
| 1020 | offset = 150; |
| 1021 | break; |
| 1022 | case LCD_PANEL_ID3_1280X768: |
| 1023 | case LCD_PANEL_ID4_1280X1024: |
| 1024 | case LCD_PANEL_ID5_1400X1050: |
| 1025 | case LCD_PANEL_ID9_1280X800: |
| 1026 | offset = 190; |
| 1027 | break; |
| 1028 | case LCD_PANEL_ID6_1600X1200: |
| 1029 | offset = 250; |
| 1030 | break; |
| 1031 | case LCD_PANEL_ID7_1366X768: |
| 1032 | case LCD_PANEL_IDB_1360X768: |
| 1033 | offset = 212; |
| 1034 | break; |
| 1035 | default: |
| 1036 | offset = 140; |
| 1037 | break; |
| 1038 | } |
| 1039 | |
| 1040 | /* Offset for simultaneous */ |
| 1041 | reg_value = offset; |
| 1042 | viafb_load_reg_num = offset_reg.iga2_offset_reg.reg_num; |
| 1043 | reg = offset_reg.iga2_offset_reg.reg; |
| 1044 | viafb_load_reg(reg_value, viafb_load_reg_num, reg, VIACR); |
| 1045 | DEBUG_MSG(KERN_INFO "viafb_load_reg!!\n"); |
| 1046 | viafb_load_fetch_count_reg(set_hres, 4, IGA2); |
| 1047 | /* Fetch count for simultaneous */ |
| 1048 | } else { /* SAMM */ |
| 1049 | /* Offset for IGA2 only */ |
| 1050 | viafb_load_offset_reg(set_hres, mode_bpp / 8, set_iga); |
| 1051 | /* Fetch count for IGA2 only */ |
| 1052 | viafb_load_fetch_count_reg(set_hres, mode_bpp / 8, set_iga); |
| 1053 | |
| 1054 | if ((viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266) |
| 1055 | && (viaparinfo->chip_info->gfx_chip_name != UNICHROME_K400)) |
| 1056 | viafb_load_FIFO_reg(set_iga, set_hres, set_vres); |
| 1057 | |
| 1058 | viafb_set_color_depth(mode_bpp / 8, set_iga); |
| 1059 | } |
| 1060 | |
| 1061 | fill_lcd_format(); |
| 1062 | |
| 1063 | pll_D_N = viafb_get_clk_value(panel_crt_table[0].clk); |
| 1064 | DEBUG_MSG(KERN_INFO "PLL=0x%x", pll_D_N); |
| 1065 | viafb_set_vclock(pll_D_N, set_iga); |
| 1066 | |
| 1067 | viafb_set_output_path(DEVICE_LCD, set_iga, |
| 1068 | plvds_chip_info->output_interface); |
| 1069 | lcd_patch_skew(plvds_setting_info, plvds_chip_info); |
| 1070 | |
| 1071 | /* If K8M800, enable LCD Prefetch Mode. */ |
| 1072 | if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_K800) |
| 1073 | || (UNICHROME_K8M890 == viaparinfo->chip_info->gfx_chip_name)) |
| 1074 | viafb_write_reg_mask(CR6A, VIACR, 0x01, BIT0); |
| 1075 | |
| 1076 | load_lcd_patch_regs(set_hres, set_vres, |
| 1077 | plvds_setting_info->lcd_panel_id, set_iga); |
| 1078 | |
| 1079 | DEBUG_MSG(KERN_INFO "load_lcd_patch_regs!!\n"); |
| 1080 | |
| 1081 | /* Patch for non 32bit alignment mode */ |
| 1082 | via_pitch_alignment_patch_lcd(plvds_setting_info, plvds_chip_info); |
| 1083 | } |
| 1084 | |
| 1085 | static void integrated_lvds_disable(struct lvds_setting_information |
| 1086 | *plvds_setting_info, |
| 1087 | struct lvds_chip_information *plvds_chip_info) |
| 1088 | { |
| 1089 | bool turn_off_first_powersequence = false; |
| 1090 | bool turn_off_second_powersequence = false; |
| 1091 | if (INTERFACE_LVDS0LVDS1 == plvds_chip_info->output_interface) |
| 1092 | turn_off_first_powersequence = true; |
| 1093 | if (INTERFACE_LVDS0 == plvds_chip_info->output_interface) |
| 1094 | turn_off_first_powersequence = true; |
| 1095 | if (INTERFACE_LVDS1 == plvds_chip_info->output_interface) |
| 1096 | turn_off_second_powersequence = true; |
| 1097 | if (turn_off_second_powersequence) { |
| 1098 | /* Use second power sequence control: */ |
| 1099 | |
| 1100 | /* Turn off power sequence. */ |
| 1101 | viafb_write_reg_mask(CRD4, VIACR, 0, BIT1); |
| 1102 | |
| 1103 | /* Turn off back light. */ |
| 1104 | viafb_write_reg_mask(CRD3, VIACR, 0xC0, BIT6 + BIT7); |
| 1105 | } |
| 1106 | if (turn_off_first_powersequence) { |
| 1107 | /* Use first power sequence control: */ |
| 1108 | |
| 1109 | /* Turn off power sequence. */ |
| 1110 | viafb_write_reg_mask(CR6A, VIACR, 0, BIT3); |
| 1111 | |
| 1112 | /* Turn off back light. */ |
| 1113 | viafb_write_reg_mask(CR91, VIACR, 0xC0, BIT6 + BIT7); |
| 1114 | } |
| 1115 | |
| 1116 | /* Turn DFP High/Low Pad off. */ |
| 1117 | viafb_write_reg_mask(SR2A, VIASR, 0, BIT0 + BIT1 + BIT2 + BIT3); |
| 1118 | |
| 1119 | /* Power off LVDS channel. */ |
| 1120 | switch (plvds_chip_info->output_interface) { |
| 1121 | case INTERFACE_LVDS0: |
| 1122 | { |
| 1123 | viafb_write_reg_mask(CRD2, VIACR, 0x80, BIT7); |
| 1124 | break; |
| 1125 | } |
| 1126 | |
| 1127 | case INTERFACE_LVDS1: |
| 1128 | { |
| 1129 | viafb_write_reg_mask(CRD2, VIACR, 0x40, BIT6); |
| 1130 | break; |
| 1131 | } |
| 1132 | |
| 1133 | case INTERFACE_LVDS0LVDS1: |
| 1134 | { |
| 1135 | viafb_write_reg_mask(CRD2, VIACR, 0xC0, BIT6 + BIT7); |
| 1136 | break; |
| 1137 | } |
| 1138 | } |
| 1139 | } |
| 1140 | |
| 1141 | static void integrated_lvds_enable(struct lvds_setting_information |
| 1142 | *plvds_setting_info, |
| 1143 | struct lvds_chip_information *plvds_chip_info) |
| 1144 | { |
| 1145 | bool turn_on_first_powersequence = false; |
| 1146 | bool turn_on_second_powersequence = false; |
| 1147 | |
| 1148 | DEBUG_MSG(KERN_INFO "integrated_lvds_enable, out_interface:%d\n", |
| 1149 | plvds_chip_info->output_interface); |
| 1150 | if (plvds_setting_info->lcd_mode == LCD_SPWG) |
| 1151 | viafb_write_reg_mask(CRD2, VIACR, 0x00, BIT0 + BIT1); |
| 1152 | else |
| 1153 | viafb_write_reg_mask(CRD2, VIACR, 0x03, BIT0 + BIT1); |
| 1154 | if (INTERFACE_LVDS0LVDS1 == plvds_chip_info->output_interface) |
| 1155 | turn_on_first_powersequence = true; |
| 1156 | if (INTERFACE_LVDS0 == plvds_chip_info->output_interface) |
| 1157 | turn_on_first_powersequence = true; |
| 1158 | if (INTERFACE_LVDS1 == plvds_chip_info->output_interface) |
| 1159 | turn_on_second_powersequence = true; |
| 1160 | |
| 1161 | if (turn_on_second_powersequence) { |
| 1162 | /* Use second power sequence control: */ |
| 1163 | |
| 1164 | /* Use hardware control power sequence. */ |
| 1165 | viafb_write_reg_mask(CRD3, VIACR, 0, BIT0); |
| 1166 | |
| 1167 | /* Turn on back light. */ |
| 1168 | viafb_write_reg_mask(CRD3, VIACR, 0, BIT6 + BIT7); |
| 1169 | |
| 1170 | /* Turn on hardware power sequence. */ |
| 1171 | viafb_write_reg_mask(CRD4, VIACR, 0x02, BIT1); |
| 1172 | } |
| 1173 | if (turn_on_first_powersequence) { |
| 1174 | /* Use first power sequence control: */ |
| 1175 | |
| 1176 | /* Use hardware control power sequence. */ |
| 1177 | viafb_write_reg_mask(CR91, VIACR, 0, BIT0); |
| 1178 | |
| 1179 | /* Turn on back light. */ |
| 1180 | viafb_write_reg_mask(CR91, VIACR, 0, BIT6 + BIT7); |
| 1181 | |
| 1182 | /* Turn on hardware power sequence. */ |
| 1183 | viafb_write_reg_mask(CR6A, VIACR, 0x08, BIT3); |
| 1184 | } |
| 1185 | |
| 1186 | /* Turn DFP High/Low pad on. */ |
| 1187 | viafb_write_reg_mask(SR2A, VIASR, 0x0F, BIT0 + BIT1 + BIT2 + BIT3); |
| 1188 | |
| 1189 | /* Power on LVDS channel. */ |
| 1190 | switch (plvds_chip_info->output_interface) { |
| 1191 | case INTERFACE_LVDS0: |
| 1192 | { |
| 1193 | viafb_write_reg_mask(CRD2, VIACR, 0, BIT7); |
| 1194 | break; |
| 1195 | } |
| 1196 | |
| 1197 | case INTERFACE_LVDS1: |
| 1198 | { |
| 1199 | viafb_write_reg_mask(CRD2, VIACR, 0, BIT6); |
| 1200 | break; |
| 1201 | } |
| 1202 | |
| 1203 | case INTERFACE_LVDS0LVDS1: |
| 1204 | { |
| 1205 | viafb_write_reg_mask(CRD2, VIACR, 0, BIT6 + BIT7); |
| 1206 | break; |
| 1207 | } |
| 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | void viafb_lcd_disable(void) |
| 1212 | { |
| 1213 | |
| 1214 | if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) { |
| 1215 | lcd_powersequence_off(); |
| 1216 | /* DI1 pad off */ |
| 1217 | viafb_write_reg_mask(SR1E, VIASR, 0x00, 0x30); |
| 1218 | } else if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) { |
| 1219 | if (viafb_LCD2_ON |
| 1220 | && (INTEGRATED_LVDS == |
| 1221 | viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name)) |
| 1222 | integrated_lvds_disable(viaparinfo->lvds_setting_info, |
| 1223 | &viaparinfo->chip_info->lvds_chip_info2); |
| 1224 | if (INTEGRATED_LVDS == |
| 1225 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) |
| 1226 | integrated_lvds_disable(viaparinfo->lvds_setting_info, |
| 1227 | &viaparinfo->chip_info->lvds_chip_info); |
| 1228 | if (VT1636_LVDS == viaparinfo->chip_info-> |
| 1229 | lvds_chip_info.lvds_chip_name) |
| 1230 | viafb_disable_lvds_vt1636(viaparinfo->lvds_setting_info, |
| 1231 | &viaparinfo->chip_info->lvds_chip_info); |
| 1232 | } else if (VT1636_LVDS == |
| 1233 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { |
| 1234 | viafb_disable_lvds_vt1636(viaparinfo->lvds_setting_info, |
| 1235 | &viaparinfo->chip_info->lvds_chip_info); |
| 1236 | } else { |
| 1237 | /* DFP-HL pad off */ |
| 1238 | viafb_write_reg_mask(SR2A, VIASR, 0x00, 0x0F); |
| 1239 | /* Backlight off */ |
| 1240 | viafb_write_reg_mask(SR3D, VIASR, 0x00, 0x20); |
| 1241 | /* 24 bit DI data paht off */ |
| 1242 | viafb_write_reg_mask(CR91, VIACR, 0x80, 0x80); |
| 1243 | /* Simultaneout disabled */ |
| 1244 | viafb_write_reg_mask(CR6B, VIACR, 0x00, 0x08); |
| 1245 | } |
| 1246 | |
| 1247 | /* Disable expansion bit */ |
| 1248 | viafb_write_reg_mask(CR79, VIACR, 0x00, 0x01); |
| 1249 | /* CRT path set to IGA1 */ |
| 1250 | viafb_write_reg_mask(SR16, VIASR, 0x00, 0x40); |
| 1251 | /* Simultaneout disabled */ |
| 1252 | viafb_write_reg_mask(CR6B, VIACR, 0x00, 0x08); |
| 1253 | /* IGA2 path disabled */ |
| 1254 | viafb_write_reg_mask(CR6A, VIACR, 0x00, 0x80); |
| 1255 | |
| 1256 | } |
| 1257 | |
| 1258 | void viafb_lcd_enable(void) |
| 1259 | { |
| 1260 | if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) { |
| 1261 | /* DI1 pad on */ |
| 1262 | viafb_write_reg_mask(SR1E, VIASR, 0x30, 0x30); |
| 1263 | lcd_powersequence_on(); |
| 1264 | } else if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) { |
| 1265 | if (viafb_LCD2_ON && (INTEGRATED_LVDS == |
| 1266 | viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name)) |
| 1267 | integrated_lvds_enable(viaparinfo->lvds_setting_info2, \ |
| 1268 | &viaparinfo->chip_info->lvds_chip_info2); |
| 1269 | if (INTEGRATED_LVDS == |
| 1270 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) |
| 1271 | integrated_lvds_enable(viaparinfo->lvds_setting_info, |
| 1272 | &viaparinfo->chip_info->lvds_chip_info); |
| 1273 | if (VT1636_LVDS == viaparinfo->chip_info-> |
| 1274 | lvds_chip_info.lvds_chip_name) |
| 1275 | viafb_enable_lvds_vt1636(viaparinfo-> |
| 1276 | lvds_setting_info, &viaparinfo->chip_info-> |
| 1277 | lvds_chip_info); |
| 1278 | } else if (VT1636_LVDS == |
| 1279 | viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { |
| 1280 | viafb_enable_lvds_vt1636(viaparinfo->lvds_setting_info, |
| 1281 | &viaparinfo->chip_info->lvds_chip_info); |
| 1282 | } else { |
| 1283 | /* DFP-HL pad on */ |
| 1284 | viafb_write_reg_mask(SR2A, VIASR, 0x0F, 0x0F); |
| 1285 | /* Backlight on */ |
| 1286 | viafb_write_reg_mask(SR3D, VIASR, 0x20, 0x20); |
| 1287 | /* 24 bit DI data paht on */ |
| 1288 | viafb_write_reg_mask(CR91, VIACR, 0x00, 0x80); |
| 1289 | |
| 1290 | /* Set data source selection bit by iga path */ |
| 1291 | if (viaparinfo->lvds_setting_info->iga_path == IGA1) { |
| 1292 | /* DFP-H set to IGA1 */ |
| 1293 | viafb_write_reg_mask(CR97, VIACR, 0x00, 0x10); |
| 1294 | /* DFP-L set to IGA1 */ |
| 1295 | viafb_write_reg_mask(CR99, VIACR, 0x00, 0x10); |
| 1296 | } else { |
| 1297 | /* DFP-H set to IGA2 */ |
| 1298 | viafb_write_reg_mask(CR97, VIACR, 0x10, 0x10); |
| 1299 | /* DFP-L set to IGA2 */ |
| 1300 | viafb_write_reg_mask(CR99, VIACR, 0x10, 0x10); |
| 1301 | } |
| 1302 | /* LCD enabled */ |
| 1303 | viafb_write_reg_mask(CR6A, VIACR, 0x48, 0x48); |
| 1304 | } |
| 1305 | |
| 1306 | if ((viaparinfo->lvds_setting_info->iga_path == IGA1) |
| 1307 | || (viaparinfo->lvds_setting_info->iga_path == IGA1_IGA2)) { |
| 1308 | /* CRT path set to IGA2 */ |
| 1309 | viafb_write_reg_mask(SR16, VIASR, 0x40, 0x40); |
| 1310 | /* IGA2 path disabled */ |
| 1311 | viafb_write_reg_mask(CR6A, VIACR, 0x00, 0x80); |
| 1312 | /* IGA2 path enabled */ |
| 1313 | } else { /* IGA2 */ |
| 1314 | viafb_write_reg_mask(CR6A, VIACR, 0x80, 0x80); |
| 1315 | } |
| 1316 | |
| 1317 | } |
| 1318 | |
| 1319 | static void lcd_powersequence_off(void) |
| 1320 | { |
| 1321 | int i, mask, data; |
| 1322 | |
| 1323 | /* Software control power sequence */ |
| 1324 | viafb_write_reg_mask(CR91, VIACR, 0x11, 0x11); |
| 1325 | |
| 1326 | for (i = 0; i < 3; i++) { |
| 1327 | mask = PowerSequenceOff[0][i]; |
| 1328 | data = PowerSequenceOff[1][i] & mask; |
| 1329 | viafb_write_reg_mask(CR91, VIACR, (u8) data, (u8) mask); |
| 1330 | udelay(PowerSequenceOff[2][i]); |
| 1331 | } |
| 1332 | |
| 1333 | /* Disable LCD */ |
| 1334 | viafb_write_reg_mask(CR6A, VIACR, 0x00, 0x08); |
| 1335 | } |
| 1336 | |
| 1337 | static void lcd_powersequence_on(void) |
| 1338 | { |
| 1339 | int i, mask, data; |
| 1340 | |
| 1341 | /* Software control power sequence */ |
| 1342 | viafb_write_reg_mask(CR91, VIACR, 0x11, 0x11); |
| 1343 | |
| 1344 | /* Enable LCD */ |
| 1345 | viafb_write_reg_mask(CR6A, VIACR, 0x08, 0x08); |
| 1346 | |
| 1347 | for (i = 0; i < 3; i++) { |
| 1348 | mask = PowerSequenceOn[0][i]; |
| 1349 | data = PowerSequenceOn[1][i] & mask; |
| 1350 | viafb_write_reg_mask(CR91, VIACR, (u8) data, (u8) mask); |
| 1351 | udelay(PowerSequenceOn[2][i]); |
| 1352 | } |
| 1353 | |
| 1354 | udelay(1); |
| 1355 | } |
| 1356 | |
| 1357 | static void fill_lcd_format(void) |
| 1358 | { |
| 1359 | u8 bdithering = 0, bdual = 0; |
| 1360 | |
| 1361 | if (viaparinfo->lvds_setting_info->device_lcd_dualedge) |
| 1362 | bdual = BIT4; |
| 1363 | if (viaparinfo->lvds_setting_info->LCDDithering) |
| 1364 | bdithering = BIT0; |
| 1365 | /* Dual & Dithering */ |
| 1366 | viafb_write_reg_mask(CR88, VIACR, (bdithering | bdual), BIT4 + BIT0); |
| 1367 | } |
| 1368 | |
| 1369 | static void check_diport_of_integrated_lvds( |
| 1370 | struct lvds_chip_information *plvds_chip_info, |
| 1371 | struct lvds_setting_information |
| 1372 | *plvds_setting_info) |
| 1373 | { |
| 1374 | /* Determine LCD DI Port by hardware layout. */ |
| 1375 | switch (viafb_display_hardware_layout) { |
| 1376 | case HW_LAYOUT_LCD_ONLY: |
| 1377 | { |
| 1378 | if (plvds_setting_info->device_lcd_dualedge) { |
| 1379 | plvds_chip_info->output_interface = |
| 1380 | INTERFACE_LVDS0LVDS1; |
| 1381 | } else { |
| 1382 | plvds_chip_info->output_interface = |
| 1383 | INTERFACE_LVDS0; |
| 1384 | } |
| 1385 | |
| 1386 | break; |
| 1387 | } |
| 1388 | |
| 1389 | case HW_LAYOUT_DVI_ONLY: |
| 1390 | { |
| 1391 | plvds_chip_info->output_interface = INTERFACE_NONE; |
| 1392 | break; |
| 1393 | } |
| 1394 | |
| 1395 | case HW_LAYOUT_LCD1_LCD2: |
| 1396 | case HW_LAYOUT_LCD_EXTERNAL_LCD2: |
| 1397 | { |
| 1398 | plvds_chip_info->output_interface = |
| 1399 | INTERFACE_LVDS0LVDS1; |
| 1400 | break; |
| 1401 | } |
| 1402 | |
| 1403 | case HW_LAYOUT_LCD_DVI: |
| 1404 | { |
| 1405 | plvds_chip_info->output_interface = INTERFACE_LVDS1; |
| 1406 | break; |
| 1407 | } |
| 1408 | |
| 1409 | default: |
| 1410 | { |
| 1411 | plvds_chip_info->output_interface = INTERFACE_LVDS1; |
| 1412 | break; |
| 1413 | } |
| 1414 | } |
| 1415 | |
| 1416 | DEBUG_MSG(KERN_INFO |
| 1417 | "Display Hardware Layout: 0x%x, LCD DI Port: 0x%x\n", |
| 1418 | viafb_display_hardware_layout, |
| 1419 | plvds_chip_info->output_interface); |
| 1420 | } |
| 1421 | |
| 1422 | void viafb_init_lvds_output_interface(struct lvds_chip_information |
| 1423 | *plvds_chip_info, |
| 1424 | struct lvds_setting_information |
| 1425 | *plvds_setting_info) |
| 1426 | { |
| 1427 | if (INTERFACE_NONE != plvds_chip_info->output_interface) { |
| 1428 | /*Do nothing, lcd port is specified by module parameter */ |
| 1429 | return; |
| 1430 | } |
| 1431 | |
| 1432 | switch (plvds_chip_info->lvds_chip_name) { |
| 1433 | |
| 1434 | case VT1636_LVDS: |
| 1435 | switch (viaparinfo->chip_info->gfx_chip_name) { |
| 1436 | case UNICHROME_CX700: |
| 1437 | plvds_chip_info->output_interface = INTERFACE_DVP1; |
| 1438 | break; |
| 1439 | case UNICHROME_CN700: |
| 1440 | plvds_chip_info->output_interface = INTERFACE_DFP_LOW; |
| 1441 | break; |
| 1442 | default: |
| 1443 | plvds_chip_info->output_interface = INTERFACE_DVP0; |
| 1444 | break; |
| 1445 | } |
| 1446 | break; |
| 1447 | |
| 1448 | case INTEGRATED_LVDS: |
| 1449 | check_diport_of_integrated_lvds(plvds_chip_info, |
| 1450 | plvds_setting_info); |
| 1451 | break; |
| 1452 | |
| 1453 | default: |
| 1454 | switch (viaparinfo->chip_info->gfx_chip_name) { |
| 1455 | case UNICHROME_K8M890: |
| 1456 | case UNICHROME_P4M900: |
| 1457 | case UNICHROME_P4M890: |
| 1458 | plvds_chip_info->output_interface = INTERFACE_DFP_LOW; |
| 1459 | break; |
| 1460 | default: |
| 1461 | plvds_chip_info->output_interface = INTERFACE_DFP; |
| 1462 | break; |
| 1463 | } |
| 1464 | break; |
| 1465 | } |
| 1466 | } |
| 1467 | |
| 1468 | static struct display_timing lcd_centering_timging(struct display_timing |
| 1469 | mode_crt_reg, |
| 1470 | struct display_timing panel_crt_reg) |
| 1471 | { |
| 1472 | struct display_timing crt_reg; |
| 1473 | |
| 1474 | crt_reg.hor_total = panel_crt_reg.hor_total; |
| 1475 | crt_reg.hor_addr = mode_crt_reg.hor_addr; |
| 1476 | crt_reg.hor_blank_start = |
| 1477 | (panel_crt_reg.hor_addr - mode_crt_reg.hor_addr) / 2 + |
| 1478 | crt_reg.hor_addr; |
| 1479 | crt_reg.hor_blank_end = panel_crt_reg.hor_blank_end; |
| 1480 | crt_reg.hor_sync_start = |
| 1481 | (panel_crt_reg.hor_sync_start - |
| 1482 | panel_crt_reg.hor_blank_start) + crt_reg.hor_blank_start; |
| 1483 | crt_reg.hor_sync_end = panel_crt_reg.hor_sync_end; |
| 1484 | |
| 1485 | crt_reg.ver_total = panel_crt_reg.ver_total; |
| 1486 | crt_reg.ver_addr = mode_crt_reg.ver_addr; |
| 1487 | crt_reg.ver_blank_start = |
| 1488 | (panel_crt_reg.ver_addr - mode_crt_reg.ver_addr) / 2 + |
| 1489 | crt_reg.ver_addr; |
| 1490 | crt_reg.ver_blank_end = panel_crt_reg.ver_blank_end; |
| 1491 | crt_reg.ver_sync_start = |
| 1492 | (panel_crt_reg.ver_sync_start - |
| 1493 | panel_crt_reg.ver_blank_start) + crt_reg.ver_blank_start; |
| 1494 | crt_reg.ver_sync_end = panel_crt_reg.ver_sync_end; |
| 1495 | |
| 1496 | return crt_reg; |
| 1497 | } |
| 1498 | |
| 1499 | static void load_crtc_shadow_timing(struct display_timing mode_timing, |
| 1500 | struct display_timing panel_timing) |
| 1501 | { |
| 1502 | struct io_register *reg = NULL; |
| 1503 | int i; |
| 1504 | int viafb_load_reg_Num = 0; |
| 1505 | int reg_value = 0; |
| 1506 | |
| 1507 | if (viaparinfo->lvds_setting_info->display_method == LCD_EXPANDSION) { |
| 1508 | /* Expansion */ |
| 1509 | for (i = 12; i < 20; i++) { |
| 1510 | switch (i) { |
| 1511 | case H_TOTAL_SHADOW_INDEX: |
| 1512 | reg_value = |
| 1513 | IGA2_HOR_TOTAL_SHADOW_FORMULA |
| 1514 | (panel_timing.hor_total); |
| 1515 | viafb_load_reg_Num = |
| 1516 | iga2_shadow_crtc_reg.hor_total_shadow. |
| 1517 | reg_num; |
| 1518 | reg = iga2_shadow_crtc_reg.hor_total_shadow.reg; |
| 1519 | break; |
| 1520 | case H_BLANK_END_SHADOW_INDEX: |
| 1521 | reg_value = |
| 1522 | IGA2_HOR_BLANK_END_SHADOW_FORMULA |
| 1523 | (panel_timing.hor_blank_start, |
| 1524 | panel_timing.hor_blank_end); |
| 1525 | viafb_load_reg_Num = |
| 1526 | iga2_shadow_crtc_reg. |
| 1527 | hor_blank_end_shadow.reg_num; |
| 1528 | reg = |
| 1529 | iga2_shadow_crtc_reg. |
| 1530 | hor_blank_end_shadow.reg; |
| 1531 | break; |
| 1532 | case V_TOTAL_SHADOW_INDEX: |
| 1533 | reg_value = |
| 1534 | IGA2_VER_TOTAL_SHADOW_FORMULA |
| 1535 | (panel_timing.ver_total); |
| 1536 | viafb_load_reg_Num = |
| 1537 | iga2_shadow_crtc_reg.ver_total_shadow. |
| 1538 | reg_num; |
| 1539 | reg = iga2_shadow_crtc_reg.ver_total_shadow.reg; |
| 1540 | break; |
| 1541 | case V_ADDR_SHADOW_INDEX: |
| 1542 | reg_value = |
| 1543 | IGA2_VER_ADDR_SHADOW_FORMULA |
| 1544 | (panel_timing.ver_addr); |
| 1545 | viafb_load_reg_Num = |
| 1546 | iga2_shadow_crtc_reg.ver_addr_shadow. |
| 1547 | reg_num; |
| 1548 | reg = iga2_shadow_crtc_reg.ver_addr_shadow.reg; |
| 1549 | break; |
| 1550 | case V_BLANK_SATRT_SHADOW_INDEX: |
| 1551 | reg_value = |
| 1552 | IGA2_VER_BLANK_START_SHADOW_FORMULA |
| 1553 | (panel_timing.ver_blank_start); |
| 1554 | viafb_load_reg_Num = |
| 1555 | iga2_shadow_crtc_reg. |
| 1556 | ver_blank_start_shadow.reg_num; |
| 1557 | reg = |
| 1558 | iga2_shadow_crtc_reg. |
| 1559 | ver_blank_start_shadow.reg; |
| 1560 | break; |
| 1561 | case V_BLANK_END_SHADOW_INDEX: |
| 1562 | reg_value = |
| 1563 | IGA2_VER_BLANK_END_SHADOW_FORMULA |
| 1564 | (panel_timing.ver_blank_start, |
| 1565 | panel_timing.ver_blank_end); |
| 1566 | viafb_load_reg_Num = |
| 1567 | iga2_shadow_crtc_reg. |
| 1568 | ver_blank_end_shadow.reg_num; |
| 1569 | reg = |
| 1570 | iga2_shadow_crtc_reg. |
| 1571 | ver_blank_end_shadow.reg; |
| 1572 | break; |
| 1573 | case V_SYNC_SATRT_SHADOW_INDEX: |
| 1574 | reg_value = |
| 1575 | IGA2_VER_SYNC_START_SHADOW_FORMULA |
| 1576 | (panel_timing.ver_sync_start); |
| 1577 | viafb_load_reg_Num = |
| 1578 | iga2_shadow_crtc_reg. |
| 1579 | ver_sync_start_shadow.reg_num; |
| 1580 | reg = |
| 1581 | iga2_shadow_crtc_reg. |
| 1582 | ver_sync_start_shadow.reg; |
| 1583 | break; |
| 1584 | case V_SYNC_END_SHADOW_INDEX: |
| 1585 | reg_value = |
| 1586 | IGA2_VER_SYNC_END_SHADOW_FORMULA |
| 1587 | (panel_timing.ver_sync_start, |
| 1588 | panel_timing.ver_sync_end); |
| 1589 | viafb_load_reg_Num = |
| 1590 | iga2_shadow_crtc_reg. |
| 1591 | ver_sync_end_shadow.reg_num; |
| 1592 | reg = |
| 1593 | iga2_shadow_crtc_reg. |
| 1594 | ver_sync_end_shadow.reg; |
| 1595 | break; |
| 1596 | } |
| 1597 | viafb_load_reg(reg_value, |
| 1598 | viafb_load_reg_Num, reg, VIACR); |
| 1599 | } |
| 1600 | } else { /* Centering */ |
| 1601 | for (i = 12; i < 20; i++) { |
| 1602 | switch (i) { |
| 1603 | case H_TOTAL_SHADOW_INDEX: |
| 1604 | reg_value = |
| 1605 | IGA2_HOR_TOTAL_SHADOW_FORMULA |
| 1606 | (panel_timing.hor_total); |
| 1607 | viafb_load_reg_Num = |
| 1608 | iga2_shadow_crtc_reg.hor_total_shadow. |
| 1609 | reg_num; |
| 1610 | reg = iga2_shadow_crtc_reg.hor_total_shadow.reg; |
| 1611 | break; |
| 1612 | case H_BLANK_END_SHADOW_INDEX: |
| 1613 | reg_value = |
| 1614 | IGA2_HOR_BLANK_END_SHADOW_FORMULA |
| 1615 | (panel_timing.hor_blank_start, |
| 1616 | panel_timing.hor_blank_end); |
| 1617 | viafb_load_reg_Num = |
| 1618 | iga2_shadow_crtc_reg. |
| 1619 | hor_blank_end_shadow.reg_num; |
| 1620 | reg = |
| 1621 | iga2_shadow_crtc_reg. |
| 1622 | hor_blank_end_shadow.reg; |
| 1623 | break; |
| 1624 | case V_TOTAL_SHADOW_INDEX: |
| 1625 | reg_value = |
| 1626 | IGA2_VER_TOTAL_SHADOW_FORMULA |
| 1627 | (panel_timing.ver_total); |
| 1628 | viafb_load_reg_Num = |
| 1629 | iga2_shadow_crtc_reg.ver_total_shadow. |
| 1630 | reg_num; |
| 1631 | reg = iga2_shadow_crtc_reg.ver_total_shadow.reg; |
| 1632 | break; |
| 1633 | case V_ADDR_SHADOW_INDEX: |
| 1634 | reg_value = |
| 1635 | IGA2_VER_ADDR_SHADOW_FORMULA |
| 1636 | (mode_timing.ver_addr); |
| 1637 | viafb_load_reg_Num = |
| 1638 | iga2_shadow_crtc_reg.ver_addr_shadow. |
| 1639 | reg_num; |
| 1640 | reg = iga2_shadow_crtc_reg.ver_addr_shadow.reg; |
| 1641 | break; |
| 1642 | case V_BLANK_SATRT_SHADOW_INDEX: |
| 1643 | reg_value = |
| 1644 | IGA2_VER_BLANK_START_SHADOW_FORMULA |
| 1645 | (mode_timing.ver_blank_start); |
| 1646 | viafb_load_reg_Num = |
| 1647 | iga2_shadow_crtc_reg. |
| 1648 | ver_blank_start_shadow.reg_num; |
| 1649 | reg = |
| 1650 | iga2_shadow_crtc_reg. |
| 1651 | ver_blank_start_shadow.reg; |
| 1652 | break; |
| 1653 | case V_BLANK_END_SHADOW_INDEX: |
| 1654 | reg_value = |
| 1655 | IGA2_VER_BLANK_END_SHADOW_FORMULA |
| 1656 | (panel_timing.ver_blank_start, |
| 1657 | panel_timing.ver_blank_end); |
| 1658 | viafb_load_reg_Num = |
| 1659 | iga2_shadow_crtc_reg. |
| 1660 | ver_blank_end_shadow.reg_num; |
| 1661 | reg = |
| 1662 | iga2_shadow_crtc_reg. |
| 1663 | ver_blank_end_shadow.reg; |
| 1664 | break; |
| 1665 | case V_SYNC_SATRT_SHADOW_INDEX: |
| 1666 | reg_value = |
| 1667 | IGA2_VER_SYNC_START_SHADOW_FORMULA( |
| 1668 | (panel_timing.ver_sync_start - |
| 1669 | panel_timing.ver_blank_start) + |
| 1670 | (panel_timing.ver_addr - |
| 1671 | mode_timing.ver_addr) / 2 + |
| 1672 | mode_timing.ver_addr); |
| 1673 | viafb_load_reg_Num = |
| 1674 | iga2_shadow_crtc_reg.ver_sync_start_shadow. |
| 1675 | reg_num; |
| 1676 | reg = |
| 1677 | iga2_shadow_crtc_reg.ver_sync_start_shadow. |
| 1678 | reg; |
| 1679 | break; |
| 1680 | case V_SYNC_END_SHADOW_INDEX: |
| 1681 | reg_value = |
| 1682 | IGA2_VER_SYNC_END_SHADOW_FORMULA( |
| 1683 | (panel_timing.ver_sync_start - |
| 1684 | panel_timing.ver_blank_start) + |
| 1685 | (panel_timing.ver_addr - |
| 1686 | mode_timing.ver_addr) / 2 + |
| 1687 | mode_timing.ver_addr, |
| 1688 | panel_timing.ver_sync_end); |
| 1689 | viafb_load_reg_Num = |
| 1690 | iga2_shadow_crtc_reg.ver_sync_end_shadow. |
| 1691 | reg_num; |
| 1692 | reg = |
| 1693 | iga2_shadow_crtc_reg.ver_sync_end_shadow. |
| 1694 | reg; |
| 1695 | break; |
| 1696 | } |
| 1697 | viafb_load_reg(reg_value, |
| 1698 | viafb_load_reg_Num, reg, VIACR); |
| 1699 | } |
| 1700 | } |
| 1701 | } |
| 1702 | |
| 1703 | bool viafb_lcd_get_mobile_state(bool *mobile) |
| 1704 | { |
| 1705 | unsigned char *romptr, *tableptr; |
| 1706 | u8 core_base; |
| 1707 | unsigned char *biosptr; |
| 1708 | /* Rom address */ |
| 1709 | u32 romaddr = 0x000C0000; |
| 1710 | u16 start_pattern = 0; |
| 1711 | |
| 1712 | biosptr = ioremap(romaddr, 0x10000); |
| 1713 | |
| 1714 | memcpy(&start_pattern, biosptr, 2); |
| 1715 | /* Compare pattern */ |
| 1716 | if (start_pattern == 0xAA55) { |
| 1717 | /* Get the start of Table */ |
| 1718 | /* 0x1B means BIOS offset position */ |
| 1719 | romptr = biosptr + 0x1B; |
| 1720 | tableptr = biosptr + *((u16 *) romptr); |
| 1721 | |
| 1722 | /* Get the start of biosver structure */ |
| 1723 | /* 18 means BIOS version position. */ |
| 1724 | romptr = tableptr + 18; |
| 1725 | romptr = biosptr + *((u16 *) romptr); |
| 1726 | |
| 1727 | /* The offset should be 44, but the |
| 1728 | actual image is less three char. */ |
| 1729 | /* pRom += 44; */ |
| 1730 | romptr += 41; |
| 1731 | |
| 1732 | core_base = *romptr++; |
| 1733 | |
| 1734 | if (core_base & 0x8) |
| 1735 | *mobile = false; |
| 1736 | else |
| 1737 | *mobile = true; |
| 1738 | /* release memory */ |
| 1739 | iounmap(biosptr); |
| 1740 | |
| 1741 | return true; |
| 1742 | } else { |
| 1743 | iounmap(biosptr); |
| 1744 | return false; |
| 1745 | } |
| 1746 | } |
| 1747 | |
| 1748 | static void viafb_load_scaling_factor_for_p4m900(int set_hres, |
| 1749 | int set_vres, int panel_hres, int panel_vres) |
| 1750 | { |
| 1751 | int h_scaling_factor; |
| 1752 | int v_scaling_factor; |
| 1753 | u8 cra2 = 0; |
| 1754 | u8 cr77 = 0; |
| 1755 | u8 cr78 = 0; |
| 1756 | u8 cr79 = 0; |
| 1757 | u8 cr9f = 0; |
| 1758 | /* Check if expansion for horizontal */ |
| 1759 | if (set_hres < panel_hres) { |
| 1760 | /* Load Horizontal Scaling Factor */ |
| 1761 | |
| 1762 | /* For VIA_K8M800 or later chipsets. */ |
| 1763 | h_scaling_factor = |
| 1764 | K800_LCD_HOR_SCF_FORMULA(set_hres, panel_hres); |
| 1765 | /* HSCaleFactor[1:0] at CR9F[1:0] */ |
| 1766 | cr9f = h_scaling_factor & 0x0003; |
| 1767 | /* HSCaleFactor[9:2] at CR77[7:0] */ |
| 1768 | cr77 = (h_scaling_factor & 0x03FC) >> 2; |
| 1769 | /* HSCaleFactor[11:10] at CR79[5:4] */ |
| 1770 | cr79 = (h_scaling_factor & 0x0C00) >> 10; |
| 1771 | cr79 <<= 4; |
| 1772 | |
| 1773 | /* Horizontal scaling enabled */ |
| 1774 | cra2 = 0xC0; |
| 1775 | |
| 1776 | DEBUG_MSG(KERN_INFO "Horizontal Scaling value = %d\n", |
| 1777 | h_scaling_factor); |
| 1778 | } else { |
| 1779 | /* Horizontal scaling disabled */ |
| 1780 | cra2 = 0x00; |
| 1781 | } |
| 1782 | |
| 1783 | /* Check if expansion for vertical */ |
| 1784 | if (set_vres < panel_vres) { |
| 1785 | /* Load Vertical Scaling Factor */ |
| 1786 | |
| 1787 | /* For VIA_K8M800 or later chipsets. */ |
| 1788 | v_scaling_factor = |
| 1789 | K800_LCD_VER_SCF_FORMULA(set_vres, panel_vres); |
| 1790 | |
| 1791 | /* Vertical scaling enabled */ |
| 1792 | cra2 |= 0x08; |
| 1793 | /* VSCaleFactor[0] at CR79[3] */ |
| 1794 | cr79 |= ((v_scaling_factor & 0x0001) << 3); |
| 1795 | /* VSCaleFactor[8:1] at CR78[7:0] */ |
| 1796 | cr78 |= (v_scaling_factor & 0x01FE) >> 1; |
| 1797 | /* VSCaleFactor[10:9] at CR79[7:6] */ |
| 1798 | cr79 |= ((v_scaling_factor & 0x0600) >> 9) << 6; |
| 1799 | |
| 1800 | DEBUG_MSG(KERN_INFO "Vertical Scaling value = %d\n", |
| 1801 | v_scaling_factor); |
| 1802 | } else { |
| 1803 | /* Vertical scaling disabled */ |
| 1804 | cra2 |= 0x00; |
| 1805 | } |
| 1806 | |
| 1807 | viafb_write_reg_mask(CRA2, VIACR, cra2, BIT3 + BIT6 + BIT7); |
| 1808 | viafb_write_reg_mask(CR77, VIACR, cr77, 0xFF); |
| 1809 | viafb_write_reg_mask(CR78, VIACR, cr78, 0xFF); |
| 1810 | viafb_write_reg_mask(CR79, VIACR, cr79, 0xF8); |
| 1811 | viafb_write_reg_mask(CR9F, VIACR, cr9f, BIT0 + BIT1); |
| 1812 | } |