blob: 17a874f6ea1c27f035afdbb57dd1ce242cfdd97d [file] [log] [blame]
Joseph Chan29b619f2008-10-15 22:03:27 -07001/*
Harald Welte109771a2009-05-19 17:12:58 +08002 * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved.
Joseph Chan29b619f2008-10-15 22:03:27 -07003 * 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 <linux/module.h>
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -070023#include <linux/seq_file.h>
Harald Welte93967be2009-09-22 16:47:32 -070024#include <linux/stat.h>
Joseph Chan29b619f2008-10-15 22:03:27 -070025#define _MASTER_FILE
26
27#include "global.h"
28
Joseph Chan29b619f2008-10-15 22:03:27 -070029static char *viafb_name = "Via";
30static u32 pseudo_pal[17];
31
32/* video mode */
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -080033static char *viafb_mode;
34static char *viafb_mode1;
Florian Tobias Schandinatdba77f82010-03-10 15:21:37 -080035static int viafb_bpp = 32;
36static int viafb_bpp1 = 32;
37
38static unsigned int viafb_second_offset;
39static int viafb_second_size;
Joseph Chan29b619f2008-10-15 22:03:27 -070040
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -070041static int viafb_accel = 1;
42
Joseph Chan29b619f2008-10-15 22:03:27 -070043/* Added for specifying active devices.*/
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -080044char *viafb_active_dev;
Joseph Chan29b619f2008-10-15 22:03:27 -070045
Joseph Chan29b619f2008-10-15 22:03:27 -070046/*Added for specify lcd output port*/
47char *viafb_lcd_port = "";
48char *viafb_dvi_port = "";
49
50static void viafb_set_device(struct device_t active_dev);
51static int apply_device_setting(struct viafb_ioctl_setting setting_info,
52 struct fb_info *info);
53static void apply_second_mode_setting(struct fb_var_screeninfo
54 *sec_var);
55static void retrieve_device_setting(struct viafb_ioctl_setting
56 *setting_info);
Florian Tobias Schandinatee79d542010-03-10 15:21:32 -080057static int viafb_pan_display(struct fb_var_screeninfo *var,
58 struct fb_info *info);
Joseph Chan29b619f2008-10-15 22:03:27 -070059
Joseph Chan29b619f2008-10-15 22:03:27 -070060static struct fb_ops viafb_ops;
61
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -070062
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -080063static void viafb_fill_var_color_info(struct fb_var_screeninfo *var, u8 depth)
64{
65 var->grayscale = 0;
66 var->red.msb_right = 0;
67 var->green.msb_right = 0;
68 var->blue.msb_right = 0;
69 var->transp.offset = 0;
70 var->transp.length = 0;
71 var->transp.msb_right = 0;
72 var->nonstd = 0;
73 switch (depth) {
74 case 8:
75 var->bits_per_pixel = 8;
76 var->red.offset = 0;
77 var->green.offset = 0;
78 var->blue.offset = 0;
Florian Tobias Schandinat415559f2010-03-10 15:21:40 -080079 var->red.length = 8;
80 var->green.length = 8;
81 var->blue.length = 8;
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -080082 break;
Florian Tobias Schandinate17cea32010-03-10 15:21:41 -080083 case 15:
84 var->bits_per_pixel = 16;
85 var->red.offset = 10;
86 var->green.offset = 5;
87 var->blue.offset = 0;
88 var->red.length = 5;
89 var->green.length = 5;
90 var->blue.length = 5;
91 break;
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -080092 case 16:
93 var->bits_per_pixel = 16;
94 var->red.offset = 11;
95 var->green.offset = 5;
96 var->blue.offset = 0;
97 var->red.length = 5;
98 var->green.length = 6;
99 var->blue.length = 5;
100 break;
101 case 24:
102 var->bits_per_pixel = 32;
103 var->red.offset = 16;
104 var->green.offset = 8;
105 var->blue.offset = 0;
106 var->red.length = 8;
107 var->green.length = 8;
108 var->blue.length = 8;
109 break;
Florian Tobias Schandinate17cea32010-03-10 15:21:41 -0800110 case 30:
111 var->bits_per_pixel = 32;
112 var->red.offset = 20;
113 var->green.offset = 10;
114 var->blue.offset = 0;
115 var->red.length = 10;
116 var->green.length = 10;
117 var->blue.length = 10;
118 break;
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800119 }
120}
121
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -0700122static void viafb_update_fix(struct fb_info *info)
Joseph Chan29b619f2008-10-15 22:03:27 -0700123{
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -0700124 u32 bpp = info->var.bits_per_pixel;
Joseph Chan29b619f2008-10-15 22:03:27 -0700125
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -0700126 info->fix.visual =
127 bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
Florian Tobias Schandinatdbb78842010-03-10 15:21:39 -0800128 info->fix.line_length = (info->var.xres_virtual * bpp / 8 + 7) & ~7;
Joseph Chan29b619f2008-10-15 22:03:27 -0700129}
130
Joseph Chan29b619f2008-10-15 22:03:27 -0700131static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix,
132 struct viafb_par *viaparinfo)
133{
134 memset(fix, 0, sizeof(struct fb_fix_screeninfo));
135 strcpy(fix->id, viafb_name);
136
137 fix->smem_start = viaparinfo->fbmem;
138 fix->smem_len = viaparinfo->fbmem_free;
Joseph Chan29b619f2008-10-15 22:03:27 -0700139
140 fix->type = FB_TYPE_PACKED_PIXELS;
141 fix->type_aux = 0;
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800142 fix->visual = FB_VISUAL_TRUECOLOR;
Joseph Chan29b619f2008-10-15 22:03:27 -0700143
144 fix->xpanstep = fix->ywrapstep = 0;
145 fix->ypanstep = 1;
146
147 /* Just tell the accel name */
148 viafbinfo->fix.accel = FB_ACCEL_VIA_UNICHROME;
149}
150static int viafb_open(struct fb_info *info, int user)
151{
152 DEBUG_MSG(KERN_INFO "viafb_open!\n");
153 return 0;
154}
155
156static int viafb_release(struct fb_info *info, int user)
157{
158 DEBUG_MSG(KERN_INFO "viafb_release!\n");
159 return 0;
160}
161
Joseph Chan29b619f2008-10-15 22:03:27 -0700162static int viafb_check_var(struct fb_var_screeninfo *var,
163 struct fb_info *info)
164{
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800165 int htotal, vtotal, depth;
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800166 struct VideoModeTable *vmode_entry;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700167 struct viafb_par *ppar = info->par;
Florian Tobias Schandinatdbb78842010-03-10 15:21:39 -0800168 u32 long_refresh, line;
Joseph Chan29b619f2008-10-15 22:03:27 -0700169
170 DEBUG_MSG(KERN_INFO "viafb_check_var!\n");
171 /* Sanity check */
172 /* HW neither support interlacte nor double-scaned mode */
173 if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE)
174 return -EINVAL;
175
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800176 vmode_entry = viafb_get_mode(var->xres, var->yres);
177 if (!vmode_entry) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700178 DEBUG_MSG(KERN_INFO
179 "viafb: Mode %dx%dx%d not supported!!\n",
180 var->xres, var->yres, var->bits_per_pixel);
181 return -EINVAL;
182 }
183
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800184 depth = fb_get_color_depth(var, &info->fix);
185 if (!depth)
186 depth = var->bits_per_pixel;
Joseph Chan29b619f2008-10-15 22:03:27 -0700187
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800188 if (depth < 0 || depth > 32)
Joseph Chan29b619f2008-10-15 22:03:27 -0700189 return -EINVAL;
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800190 else if (!depth)
191 depth = 24;
Florian Tobias Schandinate17cea32010-03-10 15:21:41 -0800192 else if (depth == 15 && viafb_dual_fb && ppar->iga_path == IGA1)
193 depth = 15;
194 else if (depth == 30)
195 depth = 30;
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800196 else if (depth <= 8)
197 depth = 8;
198 else if (depth <= 16)
199 depth = 16;
200 else
201 depth = 24;
Joseph Chan29b619f2008-10-15 22:03:27 -0700202
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800203 viafb_fill_var_color_info(var, depth);
Florian Tobias Schandinatdbb78842010-03-10 15:21:39 -0800204 line = (var->xres_virtual * var->bits_per_pixel / 8 + 7) & ~7;
205 if (line * var->yres_virtual > ppar->memsize)
Joseph Chan29b619f2008-10-15 22:03:27 -0700206 return -EINVAL;
207
208 /* Based on var passed in to calculate the refresh,
209 * because our driver use some modes special.
210 */
211 htotal = var->xres + var->left_margin +
212 var->right_margin + var->hsync_len;
213 vtotal = var->yres + var->upper_margin +
214 var->lower_margin + var->vsync_len;
215 long_refresh = 1000000000UL / var->pixclock * 1000;
216 long_refresh /= (htotal * vtotal);
217
218 viafb_refresh = viafb_get_refresh(var->xres, var->yres, long_refresh);
219
220 /* Adjust var according to our driver's own table */
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800221 viafb_fill_var_timing_info(var, viafb_refresh, vmode_entry);
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700222 if (info->var.accel_flags & FB_ACCELF_TEXT &&
223 !ppar->shared->engine_mmio)
224 info->var.accel_flags = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700225
Joseph Chan29b619f2008-10-15 22:03:27 -0700226 return 0;
227}
228
229static int viafb_set_par(struct fb_info *info)
230{
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700231 struct viafb_par *viapar = info->par;
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800232 struct VideoModeTable *vmode_entry, *vmode_entry1 = NULL;
Joseph Chan29b619f2008-10-15 22:03:27 -0700233 DEBUG_MSG(KERN_INFO "viafb_set_par!\n");
234
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700235 viapar->depth = fb_get_color_depth(&info->var, &info->fix);
Florian Tobias Schandinat5c9443e2010-03-10 15:21:34 -0800236 viafb_update_device_setting(viafbinfo->var.xres, viafbinfo->var.yres,
237 viafbinfo->var.bits_per_pixel, viafb_refresh, 0);
Joseph Chan29b619f2008-10-15 22:03:27 -0700238
Florian Tobias Schandinat5c9443e2010-03-10 15:21:34 -0800239 vmode_entry = viafb_get_mode(viafbinfo->var.xres, viafbinfo->var.yres);
240 if (viafb_dual_fb) {
241 vmode_entry1 = viafb_get_mode(viafbinfo1->var.xres,
242 viafbinfo1->var.yres);
243 viafb_update_device_setting(viafbinfo1->var.xres,
244 viafbinfo1->var.yres, viafbinfo1->var.bits_per_pixel,
245 viafb_refresh1, 1);
246 } else if (viafb_SAMM_ON == 1) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700247 DEBUG_MSG(KERN_INFO
248 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
249 viafb_second_xres, viafb_second_yres, viafb_bpp1);
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800250 vmode_entry1 = viafb_get_mode(viafb_second_xres,
Florian Tobias Schandinat52159442009-08-06 15:07:34 -0700251 viafb_second_yres);
Joseph Chan29b619f2008-10-15 22:03:27 -0700252
253 viafb_update_device_setting(viafb_second_xres,
254 viafb_second_yres, viafb_bpp1, viafb_refresh1, 1);
255 }
256
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800257 if (vmode_entry) {
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -0700258 viafb_update_fix(info);
Florian Tobias Schandinat5c9443e2010-03-10 15:21:34 -0800259 if (viafb_dual_fb && viapar->iga_path == IGA2)
260 viafb_bpp1 = info->var.bits_per_pixel;
261 else
262 viafb_bpp = info->var.bits_per_pixel;
263
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700264 if (info->var.accel_flags & FB_ACCELF_TEXT)
265 info->flags &= ~FBINFO_HWACCEL_DISABLED;
266 else
267 info->flags |= FBINFO_HWACCEL_DISABLED;
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800268 viafb_setmode(vmode_entry, info->var.bits_per_pixel,
269 vmode_entry1, viafb_bpp1);
Florian Tobias Schandinatee79d542010-03-10 15:21:32 -0800270 viafb_pan_display(&info->var, info);
Joseph Chan29b619f2008-10-15 22:03:27 -0700271 }
272
273 return 0;
274}
275
276/* Set one color register */
277static int viafb_setcolreg(unsigned regno, unsigned red, unsigned green,
278unsigned blue, unsigned transp, struct fb_info *info)
279{
Florian Tobias Schandinat415559f2010-03-10 15:21:40 -0800280 struct viafb_par *viapar = info->par;
281 u32 r, g, b;
Joseph Chan29b619f2008-10-15 22:03:27 -0700282
Florian Tobias Schandinat415559f2010-03-10 15:21:40 -0800283 if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) {
284 if (regno > 255)
285 return -EINVAL;
Joseph Chan29b619f2008-10-15 22:03:27 -0700286
Florian Tobias Schandinat415559f2010-03-10 15:21:40 -0800287 if (!viafb_dual_fb || viapar->iga_path == IGA1)
288 viafb_set_primary_color_register(regno, red >> 8,
289 green >> 8, blue >> 8);
Joseph Chan29b619f2008-10-15 22:03:27 -0700290
Florian Tobias Schandinat415559f2010-03-10 15:21:40 -0800291 if (!viafb_dual_fb || viapar->iga_path == IGA2)
292 viafb_set_secondary_color_register(regno, red >> 8,
293 green >> 8, blue >> 8);
294 } else {
295 if (regno > 15)
296 return -EINVAL;
Joseph Chan29b619f2008-10-15 22:03:27 -0700297
Florian Tobias Schandinat415559f2010-03-10 15:21:40 -0800298 r = (red >> (16 - info->var.red.length))
299 << info->var.red.offset;
300 b = (blue >> (16 - info->var.blue.length))
301 << info->var.blue.offset;
302 g = (green >> (16 - info->var.green.length))
303 << info->var.green.offset;
304 ((u32 *) info->pseudo_palette)[regno] = r | g | b;
Joseph Chan29b619f2008-10-15 22:03:27 -0700305 }
306
307 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700308}
309
310static int viafb_pan_display(struct fb_var_screeninfo *var,
311 struct fb_info *info)
312{
Florian Tobias Schandinatee79d542010-03-10 15:21:32 -0800313 struct viafb_par *viapar = info->par;
314 u32 vram_addr = (var->yoffset * var->xres_virtual + var->xoffset)
315 * (var->bits_per_pixel / 8) + viapar->vram_addr;
Joseph Chan29b619f2008-10-15 22:03:27 -0700316
Florian Tobias Schandinatee79d542010-03-10 15:21:32 -0800317 DEBUG_MSG(KERN_DEBUG "viafb_pan_display, address = %d\n", vram_addr);
318 if (!viafb_dual_fb) {
319 viafb_set_primary_address(vram_addr);
320 viafb_set_secondary_address(vram_addr);
321 } else if (viapar->iga_path == IGA1)
322 viafb_set_primary_address(vram_addr);
323 else
324 viafb_set_secondary_address(vram_addr);
Joseph Chan29b619f2008-10-15 22:03:27 -0700325
Joseph Chan29b619f2008-10-15 22:03:27 -0700326 return 0;
327}
328
329static int viafb_blank(int blank_mode, struct fb_info *info)
330{
331 DEBUG_MSG(KERN_INFO "viafb_blank!\n");
332 /* clear DPMS setting */
333
334 switch (blank_mode) {
335 case FB_BLANK_UNBLANK:
336 /* Screen: On, HSync: On, VSync: On */
337 /* control CRT monitor power management */
338 viafb_write_reg_mask(CR36, VIACR, 0x00, BIT4 + BIT5);
339 break;
340 case FB_BLANK_HSYNC_SUSPEND:
341 /* Screen: Off, HSync: Off, VSync: On */
342 /* control CRT monitor power management */
343 viafb_write_reg_mask(CR36, VIACR, 0x10, BIT4 + BIT5);
344 break;
345 case FB_BLANK_VSYNC_SUSPEND:
346 /* Screen: Off, HSync: On, VSync: Off */
347 /* control CRT monitor power management */
348 viafb_write_reg_mask(CR36, VIACR, 0x20, BIT4 + BIT5);
349 break;
350 case FB_BLANK_POWERDOWN:
351 /* Screen: Off, HSync: Off, VSync: Off */
352 /* control CRT monitor power management */
353 viafb_write_reg_mask(CR36, VIACR, 0x30, BIT4 + BIT5);
354 break;
355 }
356
357 return 0;
358}
359
360static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
361{
Bruno Prémonte687d692009-01-04 13:11:54 -0800362 union {
363 struct viafb_ioctl_mode viamode;
364 struct viafb_ioctl_samm viasamm;
365 struct viafb_driver_version driver_version;
366 struct fb_var_screeninfo sec_var;
367 struct _panel_size_pos_info panel_pos_size_para;
368 struct viafb_ioctl_setting viafb_setting;
369 struct device_t active_dev;
370 } u;
Joseph Chan29b619f2008-10-15 22:03:27 -0700371 u32 state_info = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700372 u32 *viafb_gamma_table;
373 char driver_name[] = "viafb";
374
375 u32 __user *argp = (u32 __user *) arg;
376 u32 gpu32;
Joseph Chan29b619f2008-10-15 22:03:27 -0700377
378 DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd);
Florian Tobias Schandinatcc8b82f2010-03-10 15:21:26 -0800379 printk(KERN_WARNING "viafb_ioctl: Please avoid this interface as it is unstable and might change or vanish at any time!\n");
Bruno Prémonte687d692009-01-04 13:11:54 -0800380 memset(&u, 0, sizeof(u));
Joseph Chan29b619f2008-10-15 22:03:27 -0700381
382 switch (cmd) {
383 case VIAFB_GET_CHIP_INFO:
384 if (copy_to_user(argp, viaparinfo->chip_info,
385 sizeof(struct chip_information)))
386 return -EFAULT;
387 break;
388 case VIAFB_GET_INFO_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800389 return put_user((u32)sizeof(struct viafb_ioctl_info), argp);
Joseph Chan29b619f2008-10-15 22:03:27 -0700390 case VIAFB_GET_INFO:
391 return viafb_ioctl_get_viafb_info(arg);
392 case VIAFB_HOTPLUG:
393 return put_user(viafb_ioctl_hotplug(info->var.xres,
394 info->var.yres,
395 info->var.bits_per_pixel), argp);
396 case VIAFB_SET_HOTPLUG_FLAG:
397 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
398 return -EFAULT;
399 viafb_hotplug = (gpu32) ? 1 : 0;
400 break;
401 case VIAFB_GET_RESOLUTION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800402 u.viamode.xres = (u32) viafb_hotplug_Xres;
403 u.viamode.yres = (u32) viafb_hotplug_Yres;
404 u.viamode.refresh = (u32) viafb_hotplug_refresh;
405 u.viamode.bpp = (u32) viafb_hotplug_bpp;
Joseph Chan29b619f2008-10-15 22:03:27 -0700406 if (viafb_SAMM_ON == 1) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800407 u.viamode.xres_sec = viafb_second_xres;
408 u.viamode.yres_sec = viafb_second_yres;
409 u.viamode.virtual_xres_sec = viafb_second_virtual_xres;
410 u.viamode.virtual_yres_sec = viafb_second_virtual_yres;
411 u.viamode.refresh_sec = viafb_refresh1;
412 u.viamode.bpp_sec = viafb_bpp1;
Joseph Chan29b619f2008-10-15 22:03:27 -0700413 } else {
Bruno Prémonte687d692009-01-04 13:11:54 -0800414 u.viamode.xres_sec = 0;
415 u.viamode.yres_sec = 0;
416 u.viamode.virtual_xres_sec = 0;
417 u.viamode.virtual_yres_sec = 0;
418 u.viamode.refresh_sec = 0;
419 u.viamode.bpp_sec = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700420 }
Bruno Prémonte687d692009-01-04 13:11:54 -0800421 if (copy_to_user(argp, &u.viamode, sizeof(u.viamode)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700422 return -EFAULT;
423 break;
424 case VIAFB_GET_SAMM_INFO:
Bruno Prémonte687d692009-01-04 13:11:54 -0800425 u.viasamm.samm_status = viafb_SAMM_ON;
Joseph Chan29b619f2008-10-15 22:03:27 -0700426
427 if (viafb_SAMM_ON == 1) {
428 if (viafb_dual_fb) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800429 u.viasamm.size_prim = viaparinfo->fbmem_free;
430 u.viasamm.size_sec = viaparinfo1->fbmem_free;
Joseph Chan29b619f2008-10-15 22:03:27 -0700431 } else {
432 if (viafb_second_size) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800433 u.viasamm.size_prim =
Joseph Chan29b619f2008-10-15 22:03:27 -0700434 viaparinfo->fbmem_free -
435 viafb_second_size * 1024 * 1024;
Bruno Prémonte687d692009-01-04 13:11:54 -0800436 u.viasamm.size_sec =
Joseph Chan29b619f2008-10-15 22:03:27 -0700437 viafb_second_size * 1024 * 1024;
438 } else {
Bruno Prémonte687d692009-01-04 13:11:54 -0800439 u.viasamm.size_prim =
Joseph Chan29b619f2008-10-15 22:03:27 -0700440 viaparinfo->fbmem_free >> 1;
Bruno Prémonte687d692009-01-04 13:11:54 -0800441 u.viasamm.size_sec =
Joseph Chan29b619f2008-10-15 22:03:27 -0700442 (viaparinfo->fbmem_free >> 1);
443 }
444 }
Bruno Prémonte687d692009-01-04 13:11:54 -0800445 u.viasamm.mem_base = viaparinfo->fbmem;
446 u.viasamm.offset_sec = viafb_second_offset;
Joseph Chan29b619f2008-10-15 22:03:27 -0700447 } else {
Bruno Prémonte687d692009-01-04 13:11:54 -0800448 u.viasamm.size_prim =
Joseph Chan29b619f2008-10-15 22:03:27 -0700449 viaparinfo->memsize - viaparinfo->fbmem_used;
Bruno Prémonte687d692009-01-04 13:11:54 -0800450 u.viasamm.size_sec = 0;
451 u.viasamm.mem_base = viaparinfo->fbmem;
452 u.viasamm.offset_sec = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700453 }
454
Bruno Prémonte687d692009-01-04 13:11:54 -0800455 if (copy_to_user(argp, &u.viasamm, sizeof(u.viasamm)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700456 return -EFAULT;
457
458 break;
459 case VIAFB_TURN_ON_OUTPUT_DEVICE:
460 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
461 return -EFAULT;
462 if (gpu32 & CRT_Device)
463 viafb_crt_enable();
464 if (gpu32 & DVI_Device)
465 viafb_dvi_enable();
466 if (gpu32 & LCD_Device)
467 viafb_lcd_enable();
468 break;
469 case VIAFB_TURN_OFF_OUTPUT_DEVICE:
470 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
471 return -EFAULT;
472 if (gpu32 & CRT_Device)
473 viafb_crt_disable();
474 if (gpu32 & DVI_Device)
475 viafb_dvi_disable();
476 if (gpu32 & LCD_Device)
477 viafb_lcd_disable();
478 break;
479 case VIAFB_SET_DEVICE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800480 if (copy_from_user(&u.active_dev, (void *)argp,
481 sizeof(u.active_dev)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700482 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800483 viafb_set_device(u.active_dev);
Joseph Chan29b619f2008-10-15 22:03:27 -0700484 viafb_set_par(info);
485 break;
486 case VIAFB_GET_DEVICE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800487 u.active_dev.crt = viafb_CRT_ON;
488 u.active_dev.dvi = viafb_DVI_ON;
489 u.active_dev.lcd = viafb_LCD_ON;
490 u.active_dev.samm = viafb_SAMM_ON;
491 u.active_dev.primary_dev = viafb_primary_dev;
Joseph Chan29b619f2008-10-15 22:03:27 -0700492
Bruno Prémonte687d692009-01-04 13:11:54 -0800493 u.active_dev.lcd_dsp_cent = viafb_lcd_dsp_method;
494 u.active_dev.lcd_panel_id = viafb_lcd_panel_id;
495 u.active_dev.lcd_mode = viafb_lcd_mode;
Joseph Chan29b619f2008-10-15 22:03:27 -0700496
Bruno Prémonte687d692009-01-04 13:11:54 -0800497 u.active_dev.xres = viafb_hotplug_Xres;
498 u.active_dev.yres = viafb_hotplug_Yres;
Joseph Chan29b619f2008-10-15 22:03:27 -0700499
Bruno Prémonte687d692009-01-04 13:11:54 -0800500 u.active_dev.xres1 = viafb_second_xres;
501 u.active_dev.yres1 = viafb_second_yres;
Joseph Chan29b619f2008-10-15 22:03:27 -0700502
Bruno Prémonte687d692009-01-04 13:11:54 -0800503 u.active_dev.bpp = viafb_bpp;
504 u.active_dev.bpp1 = viafb_bpp1;
505 u.active_dev.refresh = viafb_refresh;
506 u.active_dev.refresh1 = viafb_refresh1;
Joseph Chan29b619f2008-10-15 22:03:27 -0700507
Bruno Prémonte687d692009-01-04 13:11:54 -0800508 u.active_dev.epia_dvi = viafb_platform_epia_dvi;
509 u.active_dev.lcd_dual_edge = viafb_device_lcd_dualedge;
510 u.active_dev.bus_width = viafb_bus_width;
Joseph Chan29b619f2008-10-15 22:03:27 -0700511
Bruno Prémonte687d692009-01-04 13:11:54 -0800512 if (copy_to_user(argp, &u.active_dev, sizeof(u.active_dev)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700513 return -EFAULT;
514 break;
515
516 case VIAFB_GET_DRIVER_VERSION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800517 u.driver_version.iMajorNum = VERSION_MAJOR;
518 u.driver_version.iKernelNum = VERSION_KERNEL;
519 u.driver_version.iOSNum = VERSION_OS;
520 u.driver_version.iMinorNum = VERSION_MINOR;
Joseph Chan29b619f2008-10-15 22:03:27 -0700521
Bruno Prémonte687d692009-01-04 13:11:54 -0800522 if (copy_to_user(argp, &u.driver_version,
523 sizeof(u.driver_version)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700524 return -EFAULT;
525
526 break;
527
528 case VIAFB_SET_DEVICE_INFO:
Bruno Prémonte687d692009-01-04 13:11:54 -0800529 if (copy_from_user(&u.viafb_setting,
530 argp, sizeof(u.viafb_setting)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700531 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800532 if (apply_device_setting(u.viafb_setting, info) < 0)
Joseph Chan29b619f2008-10-15 22:03:27 -0700533 return -EINVAL;
534
535 break;
536
537 case VIAFB_SET_SECOND_MODE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800538 if (copy_from_user(&u.sec_var, argp, sizeof(u.sec_var)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700539 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800540 apply_second_mode_setting(&u.sec_var);
Joseph Chan29b619f2008-10-15 22:03:27 -0700541 break;
542
543 case VIAFB_GET_DEVICE_INFO:
544
Bruno Prémonte687d692009-01-04 13:11:54 -0800545 retrieve_device_setting(&u.viafb_setting);
Joseph Chan29b619f2008-10-15 22:03:27 -0700546
Bruno Prémonte687d692009-01-04 13:11:54 -0800547 if (copy_to_user(argp, &u.viafb_setting,
548 sizeof(u.viafb_setting)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700549 return -EFAULT;
550
551 break;
552
553 case VIAFB_GET_DEVICE_SUPPORT:
554 viafb_get_device_support_state(&state_info);
555 if (put_user(state_info, argp))
556 return -EFAULT;
557 break;
558
559 case VIAFB_GET_DEVICE_CONNECT:
560 viafb_get_device_connect_state(&state_info);
561 if (put_user(state_info, argp))
562 return -EFAULT;
563 break;
564
565 case VIAFB_GET_PANEL_SUPPORT_EXPAND:
566 state_info =
567 viafb_lcd_get_support_expand_state(info->var.xres,
568 info->var.yres);
569 if (put_user(state_info, argp))
570 return -EFAULT;
571 break;
572
573 case VIAFB_GET_DRIVER_NAME:
574 if (copy_to_user(argp, driver_name, sizeof(driver_name)))
575 return -EFAULT;
576 break;
577
578 case VIAFB_SET_GAMMA_LUT:
579 viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
580 if (!viafb_gamma_table)
581 return -ENOMEM;
582 if (copy_from_user(viafb_gamma_table, argp,
Julia Lawall0f050582009-12-17 15:27:09 -0800583 256 * sizeof(u32))) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700584 kfree(viafb_gamma_table);
585 return -EFAULT;
586 }
587 viafb_set_gamma_table(viafb_bpp, viafb_gamma_table);
588 kfree(viafb_gamma_table);
589 break;
590
591 case VIAFB_GET_GAMMA_LUT:
592 viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
593 if (!viafb_gamma_table)
594 return -ENOMEM;
595 viafb_get_gamma_table(viafb_gamma_table);
596 if (copy_to_user(argp, viafb_gamma_table,
Julia Lawall0f050582009-12-17 15:27:09 -0800597 256 * sizeof(u32))) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700598 kfree(viafb_gamma_table);
599 return -EFAULT;
600 }
601 kfree(viafb_gamma_table);
602 break;
603
604 case VIAFB_GET_GAMMA_SUPPORT_STATE:
605 viafb_get_gamma_support_state(viafb_bpp, &state_info);
606 if (put_user(state_info, argp))
607 return -EFAULT;
608 break;
Joseph Chan29b619f2008-10-15 22:03:27 -0700609 case VIAFB_SYNC_SURFACE:
610 DEBUG_MSG(KERN_INFO "lobo VIAFB_SYNC_SURFACE\n");
611 break;
612 case VIAFB_GET_DRIVER_CAPS:
613 break;
614
615 case VIAFB_GET_PANEL_MAX_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800616 if (copy_from_user(&u.panel_pos_size_para, argp,
617 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700618 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800619 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
620 if (copy_to_user(argp, &u.panel_pos_size_para,
621 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700622 return -EFAULT;
623 break;
624 case VIAFB_GET_PANEL_MAX_POSITION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800625 if (copy_from_user(&u.panel_pos_size_para, argp,
626 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700627 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800628 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
629 if (copy_to_user(argp, &u.panel_pos_size_para,
630 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700631 return -EFAULT;
632 break;
633
634 case VIAFB_GET_PANEL_POSITION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800635 if (copy_from_user(&u.panel_pos_size_para, argp,
636 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700637 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800638 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
639 if (copy_to_user(argp, &u.panel_pos_size_para,
640 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700641 return -EFAULT;
642 break;
643 case VIAFB_GET_PANEL_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800644 if (copy_from_user(&u.panel_pos_size_para, argp,
645 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700646 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800647 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
648 if (copy_to_user(argp, &u.panel_pos_size_para,
649 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700650 return -EFAULT;
651 break;
652
653 case VIAFB_SET_PANEL_POSITION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800654 if (copy_from_user(&u.panel_pos_size_para, argp,
655 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700656 return -EFAULT;
657 break;
658 case VIAFB_SET_PANEL_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800659 if (copy_from_user(&u.panel_pos_size_para, argp,
660 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700661 return -EFAULT;
662 break;
663
664 default:
665 return -EINVAL;
666 }
667
668 return 0;
669}
670
671static void viafb_fillrect(struct fb_info *info,
672 const struct fb_fillrect *rect)
673{
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700674 struct viafb_par *viapar = info->par;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700675 struct viafb_shared *shared = viapar->shared;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700676 u32 fg_color;
677 u8 rop;
Joseph Chan29b619f2008-10-15 22:03:27 -0700678
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700679 if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) {
Hannes Eder2899bb02009-01-06 14:42:32 -0800680 cfb_fillrect(info, rect);
681 return;
682 }
Joseph Chan29b619f2008-10-15 22:03:27 -0700683
684 if (!rect->width || !rect->height)
685 return;
686
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700687 if (info->fix.visual == FB_VISUAL_TRUECOLOR)
688 fg_color = ((u32 *)info->pseudo_palette)[rect->color];
689 else
690 fg_color = rect->color;
691
692 if (rect->rop == ROP_XOR)
Joseph Chan29b619f2008-10-15 22:03:27 -0700693 rop = 0x5A;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700694 else
Joseph Chan29b619f2008-10-15 22:03:27 -0700695 rop = 0xF0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700696
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700697 DEBUG_MSG(KERN_DEBUG "viafb 2D engine: fillrect\n");
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700698 if (shared->hw_bitblt(shared->engine_mmio, VIA_BITBLT_FILL,
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700699 rect->width, rect->height, info->var.bits_per_pixel,
700 viapar->vram_addr, info->fix.line_length, rect->dx, rect->dy,
701 NULL, 0, 0, 0, 0, fg_color, 0, rop))
702 cfb_fillrect(info, rect);
Joseph Chan29b619f2008-10-15 22:03:27 -0700703}
704
705static void viafb_copyarea(struct fb_info *info,
706 const struct fb_copyarea *area)
707{
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700708 struct viafb_par *viapar = info->par;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700709 struct viafb_shared *shared = viapar->shared;
Joseph Chan29b619f2008-10-15 22:03:27 -0700710
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700711 if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) {
Hannes Eder2899bb02009-01-06 14:42:32 -0800712 cfb_copyarea(info, area);
713 return;
714 }
Joseph Chan29b619f2008-10-15 22:03:27 -0700715
716 if (!area->width || !area->height)
717 return;
718
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700719 DEBUG_MSG(KERN_DEBUG "viafb 2D engine: copyarea\n");
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700720 if (shared->hw_bitblt(shared->engine_mmio, VIA_BITBLT_COLOR,
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700721 area->width, area->height, info->var.bits_per_pixel,
722 viapar->vram_addr, info->fix.line_length, area->dx, area->dy,
723 NULL, viapar->vram_addr, info->fix.line_length,
724 area->sx, area->sy, 0, 0, 0))
725 cfb_copyarea(info, area);
Joseph Chan29b619f2008-10-15 22:03:27 -0700726}
727
728static void viafb_imageblit(struct fb_info *info,
729 const struct fb_image *image)
730{
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700731 struct viafb_par *viapar = info->par;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700732 struct viafb_shared *shared = viapar->shared;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700733 u32 fg_color = 0, bg_color = 0;
734 u8 op;
Joseph Chan29b619f2008-10-15 22:03:27 -0700735
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700736 if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt ||
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700737 (image->depth != 1 && image->depth != viapar->depth)) {
Hannes Eder2899bb02009-01-06 14:42:32 -0800738 cfb_imageblit(info, image);
739 return;
740 }
Joseph Chan29b619f2008-10-15 22:03:27 -0700741
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700742 if (image->depth == 1) {
743 op = VIA_BITBLT_MONO;
744 if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
745 fg_color =
746 ((u32 *)info->pseudo_palette)[image->fg_color];
747 bg_color =
748 ((u32 *)info->pseudo_palette)[image->bg_color];
749 } else {
750 fg_color = image->fg_color;
751 bg_color = image->bg_color;
752 }
753 } else
754 op = VIA_BITBLT_COLOR;
Joseph Chan29b619f2008-10-15 22:03:27 -0700755
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700756 DEBUG_MSG(KERN_DEBUG "viafb 2D engine: imageblit\n");
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700757 if (shared->hw_bitblt(shared->engine_mmio, op,
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700758 image->width, image->height, info->var.bits_per_pixel,
759 viapar->vram_addr, info->fix.line_length, image->dx, image->dy,
760 (u32 *)image->data, 0, 0, 0, 0, fg_color, bg_color, 0))
761 cfb_imageblit(info, image);
Joseph Chan29b619f2008-10-15 22:03:27 -0700762}
763
764static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
765{
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700766 struct viafb_par *viapar = info->par;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700767 void __iomem *engine = viapar->shared->engine_mmio;
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700768 u32 temp, xx, yy, bg_color = 0, fg_color = 0,
769 chip_name = viapar->shared->chip_info.gfx_chip_name;
770 int i, j = 0, cur_size = 64;
Joseph Chan29b619f2008-10-15 22:03:27 -0700771
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700772 if (info->flags & FBINFO_HWACCEL_DISABLED || info != viafbinfo)
Joseph Chan29b619f2008-10-15 22:03:27 -0700773 return -ENODEV;
774
Florian Tobias Schandinat0b941902010-01-15 17:01:03 -0800775 /* LCD ouput does not support hw cursors (at least on VN896) */
776 if ((chip_name == UNICHROME_CLE266 && viapar->iga_path == IGA2) ||
777 viafb_LCD_ON)
Joseph Chan29b619f2008-10-15 22:03:27 -0700778 return -ENODEV;
779
780 viafb_show_hw_cursor(info, HW_Cursor_OFF);
Joseph Chan29b619f2008-10-15 22:03:27 -0700781
782 if (cursor->set & FB_CUR_SETHOT) {
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700783 temp = (cursor->hot.x << 16) + cursor->hot.y;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700784 writel(temp, engine + VIA_REG_CURSOR_ORG);
Joseph Chan29b619f2008-10-15 22:03:27 -0700785 }
786
787 if (cursor->set & FB_CUR_SETPOS) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700788 yy = cursor->image.dy - info->var.yoffset;
789 xx = cursor->image.dx - info->var.xoffset;
790 temp = yy & 0xFFFF;
791 temp |= (xx << 16);
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700792 writel(temp, engine + VIA_REG_CURSOR_POS);
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700793 }
794
795 if (cursor->image.width <= 32 && cursor->image.height <= 32)
796 cur_size = 32;
797 else if (cursor->image.width <= 64 && cursor->image.height <= 64)
798 cur_size = 64;
799 else {
800 printk(KERN_WARNING "viafb_cursor: The cursor is too large "
801 "%dx%d", cursor->image.width, cursor->image.height);
802 return -ENXIO;
Joseph Chan29b619f2008-10-15 22:03:27 -0700803 }
804
805 if (cursor->set & FB_CUR_SETSIZE) {
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700806 temp = readl(engine + VIA_REG_CURSOR_MODE);
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700807 if (cur_size == 32)
Joseph Chan29b619f2008-10-15 22:03:27 -0700808 temp |= 0x2;
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700809 else
810 temp &= ~0x2;
Joseph Chan29b619f2008-10-15 22:03:27 -0700811
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700812 writel(temp, engine + VIA_REG_CURSOR_MODE);
Joseph Chan29b619f2008-10-15 22:03:27 -0700813 }
814
815 if (cursor->set & FB_CUR_SETCMAP) {
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700816 fg_color = cursor->image.fg_color;
817 bg_color = cursor->image.bg_color;
818 if (chip_name == UNICHROME_CX700 ||
Harald Welte0306ab12009-09-22 16:47:35 -0700819 chip_name == UNICHROME_VX800 ||
820 chip_name == UNICHROME_VX855) {
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700821 fg_color =
822 ((info->cmap.red[fg_color] & 0xFFC0) << 14) |
823 ((info->cmap.green[fg_color] & 0xFFC0) << 4) |
824 ((info->cmap.blue[fg_color] & 0xFFC0) >> 6);
825 bg_color =
826 ((info->cmap.red[bg_color] & 0xFFC0) << 14) |
827 ((info->cmap.green[bg_color] & 0xFFC0) << 4) |
828 ((info->cmap.blue[bg_color] & 0xFFC0) >> 6);
829 } else {
830 fg_color =
831 ((info->cmap.red[fg_color] & 0xFF00) << 8) |
832 (info->cmap.green[fg_color] & 0xFF00) |
833 ((info->cmap.blue[fg_color] & 0xFF00) >> 8);
834 bg_color =
835 ((info->cmap.red[bg_color] & 0xFF00) << 8) |
836 (info->cmap.green[bg_color] & 0xFF00) |
837 ((info->cmap.blue[bg_color] & 0xFF00) >> 8);
Joseph Chan29b619f2008-10-15 22:03:27 -0700838 }
839
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700840 writel(bg_color, engine + VIA_REG_CURSOR_BG);
841 writel(fg_color, engine + VIA_REG_CURSOR_FG);
Joseph Chan29b619f2008-10-15 22:03:27 -0700842 }
843
844 if (cursor->set & FB_CUR_SETSHAPE) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800845 struct {
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700846 u8 data[CURSOR_SIZE];
847 u32 bak[CURSOR_SIZE / 4];
Bruno Prémonte687d692009-01-04 13:11:54 -0800848 } *cr_data = kzalloc(sizeof(*cr_data), GFP_ATOMIC);
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700849 int size = ((cursor->image.width + 7) >> 3) *
850 cursor->image.height;
Joseph Chan29b619f2008-10-15 22:03:27 -0700851
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700852 if (!cr_data)
853 return -ENOMEM;
Bruno Prémonte687d692009-01-04 13:11:54 -0800854
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700855 if (cur_size == 32) {
856 for (i = 0; i < (CURSOR_SIZE / 4); i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800857 cr_data->bak[i] = 0x0;
858 cr_data->bak[i + 1] = 0xFFFFFFFF;
Joseph Chan29b619f2008-10-15 22:03:27 -0700859 i += 1;
860 }
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700861 } else {
862 for (i = 0; i < (CURSOR_SIZE / 4); i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800863 cr_data->bak[i] = 0x0;
864 cr_data->bak[i + 1] = 0x0;
865 cr_data->bak[i + 2] = 0xFFFFFFFF;
866 cr_data->bak[i + 3] = 0xFFFFFFFF;
Joseph Chan29b619f2008-10-15 22:03:27 -0700867 i += 3;
868 }
869 }
870
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700871 switch (cursor->rop) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700872 case ROP_XOR:
873 for (i = 0; i < size; i++)
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700874 cr_data->data[i] = cursor->mask[i];
Joseph Chan29b619f2008-10-15 22:03:27 -0700875 break;
876 case ROP_COPY:
877
878 for (i = 0; i < size; i++)
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700879 cr_data->data[i] = cursor->mask[i];
Joseph Chan29b619f2008-10-15 22:03:27 -0700880 break;
881 default:
882 break;
883 }
884
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700885 if (cur_size == 32) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700886 for (i = 0; i < size; i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800887 cr_data->bak[j] = (u32) cr_data->data[i];
888 cr_data->bak[j + 1] = ~cr_data->bak[j];
Joseph Chan29b619f2008-10-15 22:03:27 -0700889 j += 2;
890 }
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700891 } else {
Joseph Chan29b619f2008-10-15 22:03:27 -0700892 for (i = 0; i < size; i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800893 cr_data->bak[j] = (u32) cr_data->data[i];
894 cr_data->bak[j + 1] = 0x0;
895 cr_data->bak[j + 2] = ~cr_data->bak[j];
896 cr_data->bak[j + 3] = ~cr_data->bak[j + 1];
Joseph Chan29b619f2008-10-15 22:03:27 -0700897 j += 4;
898 }
899 }
900
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700901 memcpy_toio(viafbinfo->screen_base + viapar->shared->
902 cursor_vram_addr, cr_data->bak, CURSOR_SIZE);
Bruno Prémonte687d692009-01-04 13:11:54 -0800903 kfree(cr_data);
Joseph Chan29b619f2008-10-15 22:03:27 -0700904 }
905
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700906 if (cursor->enable)
Joseph Chan29b619f2008-10-15 22:03:27 -0700907 viafb_show_hw_cursor(info, HW_Cursor_ON);
908
909 return 0;
910}
911
912static int viafb_sync(struct fb_info *info)
913{
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700914 if (!(info->flags & FBINFO_HWACCEL_DISABLED))
915 viafb_wait_engine_idle(info);
Joseph Chan29b619f2008-10-15 22:03:27 -0700916 return 0;
917}
918
Joseph Chan29b619f2008-10-15 22:03:27 -0700919static void check_available_device_to_enable(int device_id)
920{
921 int device_num = 0;
922
923 /* Initialize: */
924 viafb_CRT_ON = STATE_OFF;
925 viafb_DVI_ON = STATE_OFF;
926 viafb_LCD_ON = STATE_OFF;
927 viafb_LCD2_ON = STATE_OFF;
928 viafb_DeviceStatus = None_Device;
929
930 if ((device_id & CRT_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
931 viafb_CRT_ON = STATE_ON;
932 device_num++;
933 viafb_DeviceStatus |= CRT_Device;
934 }
935
936 if ((device_id & DVI_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
937 viafb_DVI_ON = STATE_ON;
938 device_num++;
939 viafb_DeviceStatus |= DVI_Device;
940 }
941
942 if ((device_id & LCD_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
943 viafb_LCD_ON = STATE_ON;
944 device_num++;
945 viafb_DeviceStatus |= LCD_Device;
946 }
947
948 if ((device_id & LCD2_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
949 viafb_LCD2_ON = STATE_ON;
950 device_num++;
951 viafb_DeviceStatus |= LCD2_Device;
952 }
953
954 if (viafb_DeviceStatus == None_Device) {
955 /* Use CRT as default active device: */
956 viafb_CRT_ON = STATE_ON;
957 viafb_DeviceStatus = CRT_Device;
958 }
959 DEBUG_MSG(KERN_INFO "Device Status:%x", viafb_DeviceStatus);
960}
961
962static void viafb_set_device(struct device_t active_dev)
963{
964 /* Check available device to enable: */
965 int device_id = None_Device;
966 if (active_dev.crt)
967 device_id |= CRT_Device;
968 if (active_dev.dvi)
969 device_id |= DVI_Device;
970 if (active_dev.lcd)
971 device_id |= LCD_Device;
972
973 check_available_device_to_enable(device_id);
974
975 /* Check property of LCD: */
976 if (viafb_LCD_ON) {
977 if (active_dev.lcd_dsp_cent) {
978 viaparinfo->lvds_setting_info->display_method =
979 viafb_lcd_dsp_method = LCD_CENTERING;
980 } else {
981 viaparinfo->lvds_setting_info->display_method =
982 viafb_lcd_dsp_method = LCD_EXPANDSION;
983 }
984
985 if (active_dev.lcd_mode == LCD_SPWG) {
986 viaparinfo->lvds_setting_info->lcd_mode =
987 viafb_lcd_mode = LCD_SPWG;
988 } else {
989 viaparinfo->lvds_setting_info->lcd_mode =
990 viafb_lcd_mode = LCD_OPENLDI;
991 }
992
993 if (active_dev.lcd_panel_id <= LCD_PANEL_ID_MAXIMUM) {
994 viafb_lcd_panel_id = active_dev.lcd_panel_id;
995 viafb_init_lcd_size();
996 }
997 }
998
999 /* Check property of mode: */
1000 if (!active_dev.xres1)
1001 viafb_second_xres = 640;
1002 else
1003 viafb_second_xres = active_dev.xres1;
1004 if (!active_dev.yres1)
1005 viafb_second_yres = 480;
1006 else
1007 viafb_second_yres = active_dev.yres1;
1008 if (active_dev.bpp != 0)
1009 viafb_bpp = active_dev.bpp;
1010 if (active_dev.bpp1 != 0)
1011 viafb_bpp1 = active_dev.bpp1;
1012 if (active_dev.refresh != 0)
1013 viafb_refresh = active_dev.refresh;
1014 if (active_dev.refresh1 != 0)
1015 viafb_refresh1 = active_dev.refresh1;
1016 if ((active_dev.samm == STATE_OFF) || (active_dev.samm == STATE_ON))
1017 viafb_SAMM_ON = active_dev.samm;
1018 viafb_primary_dev = active_dev.primary_dev;
1019
Florian Tobias Schandinat09cf1182009-09-22 16:47:14 -07001020 viafb_set_primary_address(0);
1021 viafb_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0);
Joseph Chan29b619f2008-10-15 22:03:27 -07001022 viafb_set_iga_path();
1023}
1024
Joseph Chan29b619f2008-10-15 22:03:27 -07001025static int get_primary_device(void)
1026{
1027 int primary_device = 0;
1028 /* Rule: device on iga1 path are the primary device. */
1029 if (viafb_SAMM_ON) {
1030 if (viafb_CRT_ON) {
1031 if (viaparinfo->crt_setting_info->iga_path == IGA1) {
1032 DEBUG_MSG(KERN_INFO "CRT IGA Path:%d\n",
1033 viaparinfo->
1034 crt_setting_info->iga_path);
1035 primary_device = CRT_Device;
1036 }
1037 }
1038 if (viafb_DVI_ON) {
1039 if (viaparinfo->tmds_setting_info->iga_path == IGA1) {
1040 DEBUG_MSG(KERN_INFO "DVI IGA Path:%d\n",
1041 viaparinfo->
1042 tmds_setting_info->iga_path);
1043 primary_device = DVI_Device;
1044 }
1045 }
1046 if (viafb_LCD_ON) {
1047 if (viaparinfo->lvds_setting_info->iga_path == IGA1) {
1048 DEBUG_MSG(KERN_INFO "LCD IGA Path:%d\n",
1049 viaparinfo->
1050 lvds_setting_info->iga_path);
1051 primary_device = LCD_Device;
1052 }
1053 }
1054 if (viafb_LCD2_ON) {
1055 if (viaparinfo->lvds_setting_info2->iga_path == IGA1) {
1056 DEBUG_MSG(KERN_INFO "LCD2 IGA Path:%d\n",
1057 viaparinfo->
1058 lvds_setting_info2->iga_path);
1059 primary_device = LCD2_Device;
1060 }
1061 }
1062 }
1063 return primary_device;
1064}
1065
Joseph Chan29b619f2008-10-15 22:03:27 -07001066static void apply_second_mode_setting(struct fb_var_screeninfo
1067 *sec_var)
1068{
1069 u32 htotal, vtotal, long_refresh;
1070
1071 htotal = sec_var->xres + sec_var->left_margin +
1072 sec_var->right_margin + sec_var->hsync_len;
1073 vtotal = sec_var->yres + sec_var->upper_margin +
1074 sec_var->lower_margin + sec_var->vsync_len;
1075 if ((sec_var->xres_virtual * (sec_var->bits_per_pixel >> 3)) & 0x1F) {
1076 /*Is 32 bytes alignment? */
1077 /*32 pixel alignment */
1078 sec_var->xres_virtual = (sec_var->xres_virtual + 31) & ~31;
1079 }
1080
1081 htotal = sec_var->xres + sec_var->left_margin +
1082 sec_var->right_margin + sec_var->hsync_len;
1083 vtotal = sec_var->yres + sec_var->upper_margin +
1084 sec_var->lower_margin + sec_var->vsync_len;
1085 long_refresh = 1000000000UL / sec_var->pixclock * 1000;
1086 long_refresh /= (htotal * vtotal);
1087
1088 viafb_second_xres = sec_var->xres;
1089 viafb_second_yres = sec_var->yres;
1090 viafb_second_virtual_xres = sec_var->xres_virtual;
1091 viafb_second_virtual_yres = sec_var->yres_virtual;
1092 viafb_bpp1 = sec_var->bits_per_pixel;
1093 viafb_refresh1 = viafb_get_refresh(sec_var->xres, sec_var->yres,
1094 long_refresh);
1095}
1096
1097static int apply_device_setting(struct viafb_ioctl_setting setting_info,
1098 struct fb_info *info)
1099{
1100 int need_set_mode = 0;
1101 DEBUG_MSG(KERN_INFO "apply_device_setting\n");
1102
1103 if (setting_info.device_flag) {
1104 need_set_mode = 1;
1105 check_available_device_to_enable(setting_info.device_status);
1106 }
1107
1108 /* Unlock LCD's operation according to LCD flag
1109 and check if the setting value is valid. */
1110 /* If the value is valid, apply the new setting value to the device. */
1111 if (viafb_LCD_ON) {
1112 if (setting_info.lcd_operation_flag & OP_LCD_CENTERING) {
1113 need_set_mode = 1;
1114 if (setting_info.lcd_attributes.display_center) {
1115 /* Centering */
1116 viaparinfo->lvds_setting_info->display_method =
1117 LCD_CENTERING;
1118 viafb_lcd_dsp_method = LCD_CENTERING;
1119 viaparinfo->lvds_setting_info2->display_method =
1120 viafb_lcd_dsp_method = LCD_CENTERING;
1121 } else {
1122 /* expandsion */
1123 viaparinfo->lvds_setting_info->display_method =
1124 LCD_EXPANDSION;
1125 viafb_lcd_dsp_method = LCD_EXPANDSION;
1126 viaparinfo->lvds_setting_info2->display_method =
1127 LCD_EXPANDSION;
1128 viafb_lcd_dsp_method = LCD_EXPANDSION;
1129 }
1130 }
1131
1132 if (setting_info.lcd_operation_flag & OP_LCD_MODE) {
1133 need_set_mode = 1;
1134 if (setting_info.lcd_attributes.lcd_mode ==
1135 LCD_SPWG) {
1136 viaparinfo->lvds_setting_info->lcd_mode =
1137 viafb_lcd_mode = LCD_SPWG;
1138 } else {
1139 viaparinfo->lvds_setting_info->lcd_mode =
1140 viafb_lcd_mode = LCD_OPENLDI;
1141 }
1142 viaparinfo->lvds_setting_info2->lcd_mode =
1143 viaparinfo->lvds_setting_info->lcd_mode;
1144 }
1145
1146 if (setting_info.lcd_operation_flag & OP_LCD_PANEL_ID) {
1147 need_set_mode = 1;
1148 if (setting_info.lcd_attributes.panel_id <=
1149 LCD_PANEL_ID_MAXIMUM) {
1150 viafb_lcd_panel_id =
1151 setting_info.lcd_attributes.panel_id;
1152 viafb_init_lcd_size();
1153 }
1154 }
1155 }
1156
1157 if (0 != (setting_info.samm_status & OP_SAMM)) {
1158 setting_info.samm_status =
1159 setting_info.samm_status & (~OP_SAMM);
1160 if (setting_info.samm_status == 0
1161 || setting_info.samm_status == 1) {
1162 viafb_SAMM_ON = setting_info.samm_status;
1163
1164 if (viafb_SAMM_ON)
1165 viafb_primary_dev = setting_info.primary_device;
1166
Florian Tobias Schandinat09cf1182009-09-22 16:47:14 -07001167 viafb_set_primary_address(0);
1168 viafb_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0);
Joseph Chan29b619f2008-10-15 22:03:27 -07001169 viafb_set_iga_path();
1170 }
1171 need_set_mode = 1;
1172 }
1173
Joseph Chan29b619f2008-10-15 22:03:27 -07001174 if (!need_set_mode) {
1175 ;
1176 } else {
1177 viafb_set_iga_path();
1178 viafb_set_par(info);
1179 }
1180 return true;
1181}
1182
1183static void retrieve_device_setting(struct viafb_ioctl_setting
1184 *setting_info)
1185{
1186
1187 /* get device status */
1188 if (viafb_CRT_ON == 1)
1189 setting_info->device_status = CRT_Device;
1190 if (viafb_DVI_ON == 1)
1191 setting_info->device_status |= DVI_Device;
1192 if (viafb_LCD_ON == 1)
1193 setting_info->device_status |= LCD_Device;
1194 if (viafb_LCD2_ON == 1)
1195 setting_info->device_status |= LCD2_Device;
Joseph Chan29b619f2008-10-15 22:03:27 -07001196
1197 setting_info->samm_status = viafb_SAMM_ON;
1198 setting_info->primary_device = get_primary_device();
1199
1200 setting_info->first_dev_bpp = viafb_bpp;
1201 setting_info->second_dev_bpp = viafb_bpp1;
1202
1203 setting_info->first_dev_refresh = viafb_refresh;
1204 setting_info->second_dev_refresh = viafb_refresh1;
1205
1206 setting_info->first_dev_hor_res = viafb_hotplug_Xres;
1207 setting_info->first_dev_ver_res = viafb_hotplug_Yres;
1208 setting_info->second_dev_hor_res = viafb_second_xres;
1209 setting_info->second_dev_ver_res = viafb_second_yres;
1210
1211 /* Get lcd attributes */
1212 setting_info->lcd_attributes.display_center = viafb_lcd_dsp_method;
1213 setting_info->lcd_attributes.panel_id = viafb_lcd_panel_id;
1214 setting_info->lcd_attributes.lcd_mode = viafb_lcd_mode;
1215}
1216
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001217static int parse_active_dev(void)
Joseph Chan29b619f2008-10-15 22:03:27 -07001218{
1219 viafb_CRT_ON = STATE_OFF;
1220 viafb_DVI_ON = STATE_OFF;
1221 viafb_LCD_ON = STATE_OFF;
1222 viafb_LCD2_ON = STATE_OFF;
1223 /* 1. Modify the active status of devices. */
1224 /* 2. Keep the order of devices, so we can set corresponding
1225 IGA path to devices in SAMM case. */
1226 /* Note: The previous of active_dev is primary device,
1227 and the following is secondary device. */
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001228 if (!viafb_active_dev) {
1229 viafb_CRT_ON = STATE_ON;
1230 viafb_SAMM_ON = STATE_OFF;
1231 } else if (!strcmp(viafb_active_dev, "CRT+DVI")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001232 /* CRT+DVI */
1233 viafb_CRT_ON = STATE_ON;
1234 viafb_DVI_ON = STATE_ON;
1235 viafb_primary_dev = CRT_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001236 } else if (!strcmp(viafb_active_dev, "DVI+CRT")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001237 /* DVI+CRT */
1238 viafb_CRT_ON = STATE_ON;
1239 viafb_DVI_ON = STATE_ON;
1240 viafb_primary_dev = DVI_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001241 } else if (!strcmp(viafb_active_dev, "CRT+LCD")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001242 /* CRT+LCD */
1243 viafb_CRT_ON = STATE_ON;
1244 viafb_LCD_ON = STATE_ON;
1245 viafb_primary_dev = CRT_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001246 } else if (!strcmp(viafb_active_dev, "LCD+CRT")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001247 /* LCD+CRT */
1248 viafb_CRT_ON = STATE_ON;
1249 viafb_LCD_ON = STATE_ON;
1250 viafb_primary_dev = LCD_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001251 } else if (!strcmp(viafb_active_dev, "DVI+LCD")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001252 /* DVI+LCD */
1253 viafb_DVI_ON = STATE_ON;
1254 viafb_LCD_ON = STATE_ON;
1255 viafb_primary_dev = DVI_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001256 } else if (!strcmp(viafb_active_dev, "LCD+DVI")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001257 /* LCD+DVI */
1258 viafb_DVI_ON = STATE_ON;
1259 viafb_LCD_ON = STATE_ON;
1260 viafb_primary_dev = LCD_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001261 } else if (!strcmp(viafb_active_dev, "LCD+LCD2")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001262 viafb_LCD_ON = STATE_ON;
1263 viafb_LCD2_ON = STATE_ON;
1264 viafb_primary_dev = LCD_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001265 } else if (!strcmp(viafb_active_dev, "LCD2+LCD")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001266 viafb_LCD_ON = STATE_ON;
1267 viafb_LCD2_ON = STATE_ON;
1268 viafb_primary_dev = LCD2_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001269 } else if (!strcmp(viafb_active_dev, "CRT")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001270 /* CRT only */
1271 viafb_CRT_ON = STATE_ON;
1272 viafb_SAMM_ON = STATE_OFF;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001273 } else if (!strcmp(viafb_active_dev, "DVI")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001274 /* DVI only */
1275 viafb_DVI_ON = STATE_ON;
1276 viafb_SAMM_ON = STATE_OFF;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001277 } else if (!strcmp(viafb_active_dev, "LCD")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001278 /* LCD only */
1279 viafb_LCD_ON = STATE_ON;
1280 viafb_SAMM_ON = STATE_OFF;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001281 } else
1282 return -EINVAL;
1283
1284 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001285}
1286
Joseph Chan29b619f2008-10-15 22:03:27 -07001287static int parse_port(char *opt_str, int *output_interface)
1288{
1289 if (!strncmp(opt_str, "DVP0", 4))
1290 *output_interface = INTERFACE_DVP0;
1291 else if (!strncmp(opt_str, "DVP1", 4))
1292 *output_interface = INTERFACE_DVP1;
1293 else if (!strncmp(opt_str, "DFP_HIGHLOW", 11))
1294 *output_interface = INTERFACE_DFP;
1295 else if (!strncmp(opt_str, "DFP_HIGH", 8))
1296 *output_interface = INTERFACE_DFP_HIGH;
1297 else if (!strncmp(opt_str, "DFP_LOW", 7))
1298 *output_interface = INTERFACE_DFP_LOW;
1299 else
1300 *output_interface = INTERFACE_NONE;
1301 return 0;
1302}
1303
1304static void parse_lcd_port(void)
1305{
1306 parse_port(viafb_lcd_port, &viaparinfo->chip_info->lvds_chip_info.
1307 output_interface);
1308 /*Initialize to avoid unexpected behavior */
1309 viaparinfo->chip_info->lvds_chip_info2.output_interface =
1310 INTERFACE_NONE;
1311
1312 DEBUG_MSG(KERN_INFO "parse_lcd_port: viafb_lcd_port:%s,interface:%d\n",
1313 viafb_lcd_port, viaparinfo->chip_info->lvds_chip_info.
1314 output_interface);
1315}
1316
1317static void parse_dvi_port(void)
1318{
1319 parse_port(viafb_dvi_port, &viaparinfo->chip_info->tmds_chip_info.
1320 output_interface);
1321
1322 DEBUG_MSG(KERN_INFO "parse_dvi_port: viafb_dvi_port:%s,interface:%d\n",
1323 viafb_dvi_port, viaparinfo->chip_info->tmds_chip_info.
1324 output_interface);
1325}
1326
1327/*
1328 * The proc filesystem read/write function, a simple proc implement to
1329 * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
1330 * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2],
1331 * CR9B, SR65, CR97, CR99
1332 */
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001333static int viafb_dvp0_proc_show(struct seq_file *m, void *v)
Joseph Chan29b619f2008-10-15 22:03:27 -07001334{
Joseph Chan29b619f2008-10-15 22:03:27 -07001335 u8 dvp0_data_dri = 0, dvp0_clk_dri = 0, dvp0 = 0;
1336 dvp0_data_dri =
1337 (viafb_read_reg(VIASR, SR2A) & BIT5) >> 4 |
1338 (viafb_read_reg(VIASR, SR1B) & BIT1) >> 1;
1339 dvp0_clk_dri =
1340 (viafb_read_reg(VIASR, SR2A) & BIT4) >> 3 |
1341 (viafb_read_reg(VIASR, SR1E) & BIT2) >> 2;
1342 dvp0 = viafb_read_reg(VIACR, CR96) & 0x0f;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001343 seq_printf(m, "%x %x %x\n", dvp0, dvp0_data_dri, dvp0_clk_dri);
1344 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001345}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001346
1347static int viafb_dvp0_proc_open(struct inode *inode, struct file *file)
1348{
1349 return single_open(file, viafb_dvp0_proc_show, NULL);
1350}
1351
1352static ssize_t viafb_dvp0_proc_write(struct file *file,
1353 const char __user *buffer, size_t count, loff_t *pos)
Joseph Chan29b619f2008-10-15 22:03:27 -07001354{
1355 char buf[20], *value, *pbuf;
1356 u8 reg_val = 0;
1357 unsigned long length, i;
1358 if (count < 1)
1359 return -EINVAL;
1360 length = count > 20 ? 20 : count;
1361 if (copy_from_user(&buf[0], buffer, length))
1362 return -EFAULT;
1363 buf[length - 1] = '\0'; /*Ensure end string */
1364 pbuf = &buf[0];
1365 for (i = 0; i < 3; i++) {
1366 value = strsep(&pbuf, " ");
1367 if (value != NULL) {
1368 strict_strtoul(value, 0, (unsigned long *)&reg_val);
1369 DEBUG_MSG(KERN_INFO "DVP0:reg_val[%l]=:%x\n", i,
1370 reg_val);
1371 switch (i) {
1372 case 0:
1373 viafb_write_reg_mask(CR96, VIACR,
1374 reg_val, 0x0f);
1375 break;
1376 case 1:
1377 viafb_write_reg_mask(SR2A, VIASR,
1378 reg_val << 4, BIT5);
1379 viafb_write_reg_mask(SR1B, VIASR,
1380 reg_val << 1, BIT1);
1381 break;
1382 case 2:
1383 viafb_write_reg_mask(SR2A, VIASR,
1384 reg_val << 3, BIT4);
1385 viafb_write_reg_mask(SR1E, VIASR,
1386 reg_val << 2, BIT2);
1387 break;
1388 default:
1389 break;
1390 }
1391 } else {
1392 break;
1393 }
1394 }
1395 return count;
1396}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001397
1398static const struct file_operations viafb_dvp0_proc_fops = {
1399 .owner = THIS_MODULE,
1400 .open = viafb_dvp0_proc_open,
1401 .read = seq_read,
1402 .llseek = seq_lseek,
1403 .release = single_release,
1404 .write = viafb_dvp0_proc_write,
1405};
1406
1407static int viafb_dvp1_proc_show(struct seq_file *m, void *v)
Joseph Chan29b619f2008-10-15 22:03:27 -07001408{
Joseph Chan29b619f2008-10-15 22:03:27 -07001409 u8 dvp1 = 0, dvp1_data_dri = 0, dvp1_clk_dri = 0;
1410 dvp1 = viafb_read_reg(VIACR, CR9B) & 0x0f;
1411 dvp1_data_dri = (viafb_read_reg(VIASR, SR65) & 0x0c) >> 2;
1412 dvp1_clk_dri = viafb_read_reg(VIASR, SR65) & 0x03;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001413 seq_printf(m, "%x %x %x\n", dvp1, dvp1_data_dri, dvp1_clk_dri);
1414 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001415}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001416
1417static int viafb_dvp1_proc_open(struct inode *inode, struct file *file)
1418{
1419 return single_open(file, viafb_dvp1_proc_show, NULL);
1420}
1421
1422static ssize_t viafb_dvp1_proc_write(struct file *file,
1423 const char __user *buffer, size_t count, loff_t *pos)
Joseph Chan29b619f2008-10-15 22:03:27 -07001424{
1425 char buf[20], *value, *pbuf;
1426 u8 reg_val = 0;
1427 unsigned long length, i;
1428 if (count < 1)
1429 return -EINVAL;
1430 length = count > 20 ? 20 : count;
1431 if (copy_from_user(&buf[0], buffer, length))
1432 return -EFAULT;
1433 buf[length - 1] = '\0'; /*Ensure end string */
1434 pbuf = &buf[0];
1435 for (i = 0; i < 3; i++) {
1436 value = strsep(&pbuf, " ");
1437 if (value != NULL) {
1438 strict_strtoul(value, 0, (unsigned long *)&reg_val);
1439 switch (i) {
1440 case 0:
1441 viafb_write_reg_mask(CR9B, VIACR,
1442 reg_val, 0x0f);
1443 break;
1444 case 1:
1445 viafb_write_reg_mask(SR65, VIASR,
1446 reg_val << 2, 0x0c);
1447 break;
1448 case 2:
1449 viafb_write_reg_mask(SR65, VIASR,
1450 reg_val, 0x03);
1451 break;
1452 default:
1453 break;
1454 }
1455 } else {
1456 break;
1457 }
1458 }
1459 return count;
1460}
1461
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001462static const struct file_operations viafb_dvp1_proc_fops = {
1463 .owner = THIS_MODULE,
1464 .open = viafb_dvp1_proc_open,
1465 .read = seq_read,
1466 .llseek = seq_lseek,
1467 .release = single_release,
1468 .write = viafb_dvp1_proc_write,
1469};
1470
1471static int viafb_dfph_proc_show(struct seq_file *m, void *v)
Joseph Chan29b619f2008-10-15 22:03:27 -07001472{
Joseph Chan29b619f2008-10-15 22:03:27 -07001473 u8 dfp_high = 0;
1474 dfp_high = viafb_read_reg(VIACR, CR97) & 0x0f;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001475 seq_printf(m, "%x\n", dfp_high);
1476 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001477}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001478
1479static int viafb_dfph_proc_open(struct inode *inode, struct file *file)
1480{
1481 return single_open(file, viafb_dfph_proc_show, NULL);
1482}
1483
1484static ssize_t viafb_dfph_proc_write(struct file *file,
1485 const char __user *buffer, size_t count, loff_t *pos)
Joseph Chan29b619f2008-10-15 22:03:27 -07001486{
1487 char buf[20];
1488 u8 reg_val = 0;
1489 unsigned long length;
1490 if (count < 1)
1491 return -EINVAL;
1492 length = count > 20 ? 20 : count;
1493 if (copy_from_user(&buf[0], buffer, length))
1494 return -EFAULT;
1495 buf[length - 1] = '\0'; /*Ensure end string */
1496 strict_strtoul(&buf[0], 0, (unsigned long *)&reg_val);
1497 viafb_write_reg_mask(CR97, VIACR, reg_val, 0x0f);
1498 return count;
1499}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001500
1501static const struct file_operations viafb_dfph_proc_fops = {
1502 .owner = THIS_MODULE,
1503 .open = viafb_dfph_proc_open,
1504 .read = seq_read,
1505 .llseek = seq_lseek,
1506 .release = single_release,
1507 .write = viafb_dfph_proc_write,
1508};
1509
1510static int viafb_dfpl_proc_show(struct seq_file *m, void *v)
Joseph Chan29b619f2008-10-15 22:03:27 -07001511{
Joseph Chan29b619f2008-10-15 22:03:27 -07001512 u8 dfp_low = 0;
1513 dfp_low = viafb_read_reg(VIACR, CR99) & 0x0f;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001514 seq_printf(m, "%x\n", dfp_low);
1515 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001516}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001517
1518static int viafb_dfpl_proc_open(struct inode *inode, struct file *file)
1519{
1520 return single_open(file, viafb_dfpl_proc_show, NULL);
1521}
1522
1523static ssize_t viafb_dfpl_proc_write(struct file *file,
1524 const char __user *buffer, size_t count, loff_t *pos)
Joseph Chan29b619f2008-10-15 22:03:27 -07001525{
1526 char buf[20];
1527 u8 reg_val = 0;
1528 unsigned long length;
1529 if (count < 1)
1530 return -EINVAL;
1531 length = count > 20 ? 20 : count;
1532 if (copy_from_user(&buf[0], buffer, length))
1533 return -EFAULT;
1534 buf[length - 1] = '\0'; /*Ensure end string */
1535 strict_strtoul(&buf[0], 0, (unsigned long *)&reg_val);
1536 viafb_write_reg_mask(CR99, VIACR, reg_val, 0x0f);
1537 return count;
1538}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001539
1540static const struct file_operations viafb_dfpl_proc_fops = {
1541 .owner = THIS_MODULE,
1542 .open = viafb_dfpl_proc_open,
1543 .read = seq_read,
1544 .llseek = seq_lseek,
1545 .release = single_release,
1546 .write = viafb_dfpl_proc_write,
1547};
1548
1549static int viafb_vt1636_proc_show(struct seq_file *m, void *v)
Joseph Chan29b619f2008-10-15 22:03:27 -07001550{
Joseph Chan29b619f2008-10-15 22:03:27 -07001551 u8 vt1636_08 = 0, vt1636_09 = 0;
1552 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1553 case VT1636_LVDS:
1554 vt1636_08 =
1555 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
1556 &viaparinfo->chip_info->lvds_chip_info, 0x08) & 0x0f;
1557 vt1636_09 =
1558 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
1559 &viaparinfo->chip_info->lvds_chip_info, 0x09) & 0x1f;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001560 seq_printf(m, "%x %x\n", vt1636_08, vt1636_09);
Joseph Chan29b619f2008-10-15 22:03:27 -07001561 break;
1562 default:
1563 break;
1564 }
1565 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
1566 case VT1636_LVDS:
1567 vt1636_08 =
1568 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
1569 &viaparinfo->chip_info->lvds_chip_info2, 0x08) & 0x0f;
1570 vt1636_09 =
1571 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
1572 &viaparinfo->chip_info->lvds_chip_info2, 0x09) & 0x1f;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001573 seq_printf(m, " %x %x\n", vt1636_08, vt1636_09);
Joseph Chan29b619f2008-10-15 22:03:27 -07001574 break;
1575 default:
1576 break;
1577 }
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001578 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001579}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001580
1581static int viafb_vt1636_proc_open(struct inode *inode, struct file *file)
1582{
1583 return single_open(file, viafb_vt1636_proc_show, NULL);
1584}
1585
1586static ssize_t viafb_vt1636_proc_write(struct file *file,
1587 const char __user *buffer, size_t count, loff_t *pos)
Joseph Chan29b619f2008-10-15 22:03:27 -07001588{
1589 char buf[30], *value, *pbuf;
1590 struct IODATA reg_val;
1591 unsigned long length, i;
1592 if (count < 1)
1593 return -EINVAL;
1594 length = count > 30 ? 30 : count;
1595 if (copy_from_user(&buf[0], buffer, length))
1596 return -EFAULT;
1597 buf[length - 1] = '\0'; /*Ensure end string */
1598 pbuf = &buf[0];
1599 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1600 case VT1636_LVDS:
1601 for (i = 0; i < 2; i++) {
1602 value = strsep(&pbuf, " ");
1603 if (value != NULL) {
1604 strict_strtoul(value, 0,
1605 (unsigned long *)&reg_val.Data);
1606 switch (i) {
1607 case 0:
1608 reg_val.Index = 0x08;
1609 reg_val.Mask = 0x0f;
1610 viafb_gpio_i2c_write_mask_lvds
1611 (viaparinfo->lvds_setting_info,
1612 &viaparinfo->
1613 chip_info->lvds_chip_info,
1614 reg_val);
1615 break;
1616 case 1:
1617 reg_val.Index = 0x09;
1618 reg_val.Mask = 0x1f;
1619 viafb_gpio_i2c_write_mask_lvds
1620 (viaparinfo->lvds_setting_info,
1621 &viaparinfo->
1622 chip_info->lvds_chip_info,
1623 reg_val);
1624 break;
1625 default:
1626 break;
1627 }
1628 } else {
1629 break;
1630 }
1631 }
1632 break;
1633 default:
1634 break;
1635 }
1636 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
1637 case VT1636_LVDS:
1638 for (i = 0; i < 2; i++) {
1639 value = strsep(&pbuf, " ");
1640 if (value != NULL) {
1641 strict_strtoul(value, 0,
1642 (unsigned long *)&reg_val.Data);
1643 switch (i) {
1644 case 0:
1645 reg_val.Index = 0x08;
1646 reg_val.Mask = 0x0f;
1647 viafb_gpio_i2c_write_mask_lvds
1648 (viaparinfo->lvds_setting_info2,
1649 &viaparinfo->
1650 chip_info->lvds_chip_info2,
1651 reg_val);
1652 break;
1653 case 1:
1654 reg_val.Index = 0x09;
1655 reg_val.Mask = 0x1f;
1656 viafb_gpio_i2c_write_mask_lvds
1657 (viaparinfo->lvds_setting_info2,
1658 &viaparinfo->
1659 chip_info->lvds_chip_info2,
1660 reg_val);
1661 break;
1662 default:
1663 break;
1664 }
1665 } else {
1666 break;
1667 }
1668 }
1669 break;
1670 default:
1671 break;
1672 }
1673 return count;
1674}
1675
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001676static const struct file_operations viafb_vt1636_proc_fops = {
1677 .owner = THIS_MODULE,
1678 .open = viafb_vt1636_proc_open,
1679 .read = seq_read,
1680 .llseek = seq_lseek,
1681 .release = single_release,
1682 .write = viafb_vt1636_proc_write,
1683};
1684
Bruno Prémontc267fd72008-11-19 15:36:23 -08001685static void viafb_init_proc(struct proc_dir_entry **viafb_entry)
Joseph Chan29b619f2008-10-15 22:03:27 -07001686{
Bruno Prémontc267fd72008-11-19 15:36:23 -08001687 *viafb_entry = proc_mkdir("viafb", NULL);
Dan Carpenter8130b3b2009-12-15 16:46:36 -08001688 if (*viafb_entry) {
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001689 proc_create("dvp0", 0, *viafb_entry, &viafb_dvp0_proc_fops);
1690 proc_create("dvp1", 0, *viafb_entry, &viafb_dvp1_proc_fops);
1691 proc_create("dfph", 0, *viafb_entry, &viafb_dfph_proc_fops);
1692 proc_create("dfpl", 0, *viafb_entry, &viafb_dfpl_proc_fops);
Joseph Chan29b619f2008-10-15 22:03:27 -07001693 if (VT1636_LVDS == viaparinfo->chip_info->lvds_chip_info.
1694 lvds_chip_name || VT1636_LVDS ==
1695 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001696 proc_create("vt1636", 0, *viafb_entry, &viafb_vt1636_proc_fops);
Joseph Chan29b619f2008-10-15 22:03:27 -07001697 }
1698
1699 }
1700}
1701static void viafb_remove_proc(struct proc_dir_entry *viafb_entry)
1702{
1703 /* no problem if it was not registered */
1704 remove_proc_entry("dvp0", viafb_entry);/* parent dir */
1705 remove_proc_entry("dvp1", viafb_entry);
1706 remove_proc_entry("dfph", viafb_entry);
1707 remove_proc_entry("dfpl", viafb_entry);
1708 remove_proc_entry("vt1636", viafb_entry);
1709 remove_proc_entry("vt1625", viafb_entry);
Bruno Prémontc267fd72008-11-19 15:36:23 -08001710 remove_proc_entry("viafb", NULL);
Joseph Chan29b619f2008-10-15 22:03:27 -07001711}
1712
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001713static int parse_mode(const char *str, u32 *xres, u32 *yres)
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001714{
1715 char *ptr;
1716
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001717 if (!str) {
1718 *xres = 640;
1719 *yres = 480;
1720 return 0;
1721 }
1722
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001723 *xres = simple_strtoul(str, &ptr, 10);
1724 if (ptr[0] != 'x')
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001725 return -EINVAL;
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001726
1727 *yres = simple_strtoul(&ptr[1], &ptr, 10);
1728 if (ptr[0])
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001729 return -EINVAL;
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001730
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001731 return 0;
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001732}
1733
Jonathan Corbetf045f772009-12-01 20:29:39 -07001734
1735int __devinit via_fb_pci_probe(struct pci_dev *pdev,
1736 const struct pci_device_id *ent)
Joseph Chan29b619f2008-10-15 22:03:27 -07001737{
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001738 u32 default_xres, default_yres;
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -08001739 struct VideoModeTable *vmode_entry;
Florian Tobias Schandinatdba77f82010-03-10 15:21:37 -08001740 struct fb_var_screeninfo default_var;
Harald Welte109771a2009-05-19 17:12:58 +08001741 int rc;
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001742 u32 viafb_par_length;
Joseph Chan29b619f2008-10-15 22:03:27 -07001743
1744 DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n");
Florian Tobias Schandinatdba77f82010-03-10 15:21:37 -08001745 memset(&default_var, 0, sizeof(default_var));
Joseph Chan29b619f2008-10-15 22:03:27 -07001746 viafb_par_length = ALIGN(sizeof(struct viafb_par), BITS_PER_LONG/8);
Joseph Chan29b619f2008-10-15 22:03:27 -07001747
1748 /* Allocate fb_info and ***_par here, also including some other needed
1749 * variables
1750 */
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001751 viafbinfo = framebuffer_alloc(viafb_par_length +
Harald Weltedb8df7b2009-09-22 16:47:38 -07001752 ALIGN(sizeof(struct viafb_shared), BITS_PER_LONG/8),
1753 &pdev->dev);
Joseph Chan29b619f2008-10-15 22:03:27 -07001754 if (!viafbinfo) {
1755 printk(KERN_ERR"Could not allocate memory for viafb_info.\n");
Harald Welte109771a2009-05-19 17:12:58 +08001756 return -ENOMEM;
Joseph Chan29b619f2008-10-15 22:03:27 -07001757 }
1758
1759 viaparinfo = (struct viafb_par *)viafbinfo->par;
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001760 viaparinfo->shared = viafbinfo->par + viafb_par_length;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -07001761 viaparinfo->vram_addr = 0;
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001762 viaparinfo->tmds_setting_info = &viaparinfo->shared->tmds_setting_info;
1763 viaparinfo->lvds_setting_info = &viaparinfo->shared->lvds_setting_info;
1764 viaparinfo->lvds_setting_info2 =
1765 &viaparinfo->shared->lvds_setting_info2;
1766 viaparinfo->crt_setting_info = &viaparinfo->shared->crt_setting_info;
1767 viaparinfo->chip_info = &viaparinfo->shared->chip_info;
Jonathan Corbetf045f772009-12-01 20:29:39 -07001768 spin_lock_init(&viaparinfo->reg_lock);
Joseph Chan29b619f2008-10-15 22:03:27 -07001769
1770 if (viafb_dual_fb)
1771 viafb_SAMM_ON = 1;
Joseph Chan29b619f2008-10-15 22:03:27 -07001772 parse_lcd_port();
1773 parse_dvi_port();
1774
1775 /* for dual-fb must viafb_SAMM_ON=1 and viafb_dual_fb=1 */
1776 if (!viafb_SAMM_ON)
1777 viafb_dual_fb = 0;
1778
Harald Welte2d280f72009-09-22 16:47:37 -07001779 viafb_init_chip_info(pdev, ent);
1780 viaparinfo->fbmem = pci_resource_start(pdev, 0);
1781 viaparinfo->memsize = viafb_get_fb_size_from_pci();
Harald Welteb72a5072009-05-19 15:50:58 +08001782 if (viaparinfo->memsize < 0) {
1783 rc = viaparinfo->memsize;
Jonathan Corbetf045f772009-12-01 20:29:39 -07001784 goto out_fb_release;
Harald Welteb72a5072009-05-19 15:50:58 +08001785 }
Joseph Chan29b619f2008-10-15 22:03:27 -07001786 viaparinfo->fbmem_free = viaparinfo->memsize;
1787 viaparinfo->fbmem_used = 0;
Florian Tobias Schandinatdb88e382009-09-22 16:47:20 -07001788 viafbinfo->screen_base = ioremap_nocache(viaparinfo->fbmem,
Joseph Chan29b619f2008-10-15 22:03:27 -07001789 viaparinfo->memsize);
Florian Tobias Schandinatdb88e382009-09-22 16:47:20 -07001790 if (!viafbinfo->screen_base) {
Jonathan Corbetf045f772009-12-01 20:29:39 -07001791 printk(KERN_ERR "ioremap of fbmem failed\n");
Harald Welte109771a2009-05-19 17:12:58 +08001792 rc = -ENOMEM;
Jonathan Corbetf045f772009-12-01 20:29:39 -07001793 goto out_fb_release;
Joseph Chan29b619f2008-10-15 22:03:27 -07001794 }
1795
Harald Welte2d280f72009-09-22 16:47:37 -07001796 viafbinfo->fix.mmio_start = pci_resource_start(pdev, 1);
1797 viafbinfo->fix.mmio_len = pci_resource_len(pdev, 1);
Joseph Chan29b619f2008-10-15 22:03:27 -07001798 viafbinfo->node = 0;
1799 viafbinfo->fbops = &viafb_ops;
1800 viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
1801
1802 viafbinfo->pseudo_palette = pseudo_pal;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -07001803 if (viafb_accel && !viafb_init_engine(viafbinfo)) {
1804 viafbinfo->flags |= FBINFO_HWACCEL_COPYAREA |
1805 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_IMAGEBLIT;
1806 default_var.accel_flags = FB_ACCELF_TEXT;
1807 } else {
1808 viafbinfo->flags |= FBINFO_HWACCEL_DISABLED;
1809 default_var.accel_flags = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001810 }
1811
1812 if (viafb_second_size && (viafb_second_size < 8)) {
1813 viafb_second_offset = viaparinfo->fbmem_free -
1814 viafb_second_size * 1024 * 1024;
1815 } else {
1816 viafb_second_size = 8;
1817 viafb_second_offset = viaparinfo->fbmem_free -
1818 viafb_second_size * 1024 * 1024;
1819 }
1820
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001821 parse_mode(viafb_mode, &default_xres, &default_yres);
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -08001822 vmode_entry = viafb_get_mode(default_xres, default_yres);
Joseph Chan29b619f2008-10-15 22:03:27 -07001823 if (viafb_SAMM_ON == 1) {
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001824 parse_mode(viafb_mode1, &viafb_second_xres,
1825 &viafb_second_yres);
1826
Joseph Chan29b619f2008-10-15 22:03:27 -07001827 if (0 == viafb_second_virtual_xres) {
1828 switch (viafb_second_xres) {
1829 case 1400:
1830 viafb_second_virtual_xres = 1408;
1831 break;
1832 default:
1833 viafb_second_virtual_xres = viafb_second_xres;
1834 break;
1835 }
1836 }
1837 if (0 == viafb_second_virtual_yres)
1838 viafb_second_virtual_yres = viafb_second_yres;
1839 }
1840
Joseph Chan29b619f2008-10-15 22:03:27 -07001841 default_var.xres = default_xres;
1842 default_var.yres = default_yres;
1843 switch (default_xres) {
1844 case 1400:
1845 default_var.xres_virtual = 1408;
1846 break;
1847 default:
1848 default_var.xres_virtual = default_xres;
1849 break;
1850 }
1851 default_var.yres_virtual = default_yres;
1852 default_var.bits_per_pixel = viafb_bpp;
Joseph Chan29b619f2008-10-15 22:03:27 -07001853 default_var.pixclock =
1854 viafb_get_pixclock(default_xres, default_yres, viafb_refresh);
1855 default_var.left_margin = (default_xres >> 3) & 0xf8;
1856 default_var.right_margin = 32;
1857 default_var.upper_margin = 16;
1858 default_var.lower_margin = 4;
1859 default_var.hsync_len = default_var.left_margin;
1860 default_var.vsync_len = 4;
Florian Tobias Schandinat7cf60792010-03-10 15:21:31 -08001861 viafb_setup_fixinfo(&viafbinfo->fix, viaparinfo);
Florian Tobias Schandinat7cf60792010-03-10 15:21:31 -08001862 viafbinfo->var = default_var;
Joseph Chan29b619f2008-10-15 22:03:27 -07001863
1864 if (viafb_dual_fb) {
Harald Weltedb8df7b2009-09-22 16:47:38 -07001865 viafbinfo1 = framebuffer_alloc(viafb_par_length, &pdev->dev);
Joseph Chan29b619f2008-10-15 22:03:27 -07001866 if (!viafbinfo1) {
1867 printk(KERN_ERR
1868 "allocate the second framebuffer struct error\n");
Harald Welte109771a2009-05-19 17:12:58 +08001869 rc = -ENOMEM;
Jonathan Corbet1b1f8cd2010-03-26 15:45:39 -06001870 goto out_unmap_screen;
Joseph Chan29b619f2008-10-15 22:03:27 -07001871 }
1872 viaparinfo1 = viafbinfo1->par;
1873 memcpy(viaparinfo1, viaparinfo, viafb_par_length);
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -07001874 viaparinfo1->vram_addr = viafb_second_offset;
Joseph Chan29b619f2008-10-15 22:03:27 -07001875 viaparinfo1->memsize = viaparinfo->memsize -
1876 viafb_second_offset;
1877 viaparinfo->memsize = viafb_second_offset;
Joseph Chan29b619f2008-10-15 22:03:27 -07001878 viaparinfo1->fbmem = viaparinfo->fbmem + viafb_second_offset;
1879
1880 viaparinfo1->fbmem_used = viaparinfo->fbmem_used;
1881 viaparinfo1->fbmem_free = viaparinfo1->memsize -
1882 viaparinfo1->fbmem_used;
1883 viaparinfo->fbmem_free = viaparinfo->memsize;
1884 viaparinfo->fbmem_used = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001885
Florian Tobias Schandinat09cf1182009-09-22 16:47:14 -07001886 viaparinfo->iga_path = IGA1;
1887 viaparinfo1->iga_path = IGA2;
Joseph Chan29b619f2008-10-15 22:03:27 -07001888 memcpy(viafbinfo1, viafbinfo, sizeof(struct fb_info));
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001889 viafbinfo1->par = viaparinfo1;
Joseph Chan29b619f2008-10-15 22:03:27 -07001890 viafbinfo1->screen_base = viafbinfo->screen_base +
1891 viafb_second_offset;
Joseph Chan29b619f2008-10-15 22:03:27 -07001892
1893 default_var.xres = viafb_second_xres;
1894 default_var.yres = viafb_second_yres;
1895 default_var.xres_virtual = viafb_second_virtual_xres;
1896 default_var.yres_virtual = viafb_second_virtual_yres;
Joseph Chan29b619f2008-10-15 22:03:27 -07001897 default_var.bits_per_pixel = viafb_bpp1;
1898 default_var.pixclock =
1899 viafb_get_pixclock(viafb_second_xres, viafb_second_yres,
1900 viafb_refresh);
1901 default_var.left_margin = (viafb_second_xres >> 3) & 0xf8;
1902 default_var.right_margin = 32;
1903 default_var.upper_margin = 16;
1904 default_var.lower_margin = 4;
1905 default_var.hsync_len = default_var.left_margin;
1906 default_var.vsync_len = 4;
1907
1908 viafb_setup_fixinfo(&viafbinfo1->fix, viaparinfo1);
1909 viafb_check_var(&default_var, viafbinfo1);
1910 viafbinfo1->var = default_var;
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -07001911 viafb_update_fix(viafbinfo1);
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -07001912 viaparinfo1->depth = fb_get_color_depth(&viafbinfo1->var,
1913 &viafbinfo1->fix);
Joseph Chan29b619f2008-10-15 22:03:27 -07001914 }
1915
Florian Tobias Schandinate17cea32010-03-10 15:21:41 -08001916 viafb_check_var(&viafbinfo->var, viafbinfo);
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -07001917 viafb_update_fix(viafbinfo);
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -07001918 viaparinfo->depth = fb_get_color_depth(&viafbinfo->var,
1919 &viafbinfo->fix);
Joseph Chan29b619f2008-10-15 22:03:27 -07001920 default_var.activate = FB_ACTIVATE_NOW;
Harald Welte109771a2009-05-19 17:12:58 +08001921 rc = fb_alloc_cmap(&viafbinfo->cmap, 256, 0);
1922 if (rc)
1923 goto out_fb1_release;
Joseph Chan29b619f2008-10-15 22:03:27 -07001924
1925 if (viafb_dual_fb && (viafb_primary_dev == LCD_Device)
1926 && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) {
Harald Welte109771a2009-05-19 17:12:58 +08001927 rc = register_framebuffer(viafbinfo1);
1928 if (rc)
1929 goto out_dealloc_cmap;
Joseph Chan29b619f2008-10-15 22:03:27 -07001930 }
Harald Welte109771a2009-05-19 17:12:58 +08001931 rc = register_framebuffer(viafbinfo);
1932 if (rc)
1933 goto out_fb1_unreg_lcd_cle266;
Joseph Chan29b619f2008-10-15 22:03:27 -07001934
1935 if (viafb_dual_fb && ((viafb_primary_dev != LCD_Device)
1936 || (viaparinfo->chip_info->gfx_chip_name !=
1937 UNICHROME_CLE266))) {
Harald Welte109771a2009-05-19 17:12:58 +08001938 rc = register_framebuffer(viafbinfo1);
1939 if (rc)
1940 goto out_fb_unreg;
Joseph Chan29b619f2008-10-15 22:03:27 -07001941 }
1942 DEBUG_MSG(KERN_INFO "fb%d: %s frame buffer device %dx%d-%dbpp\n",
1943 viafbinfo->node, viafbinfo->fix.id, default_var.xres,
1944 default_var.yres, default_var.bits_per_pixel);
1945
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001946 viafb_init_proc(&viaparinfo->shared->proc_entry);
Joseph Chan29b619f2008-10-15 22:03:27 -07001947 viafb_init_dac(IGA2);
1948 return 0;
Harald Welte109771a2009-05-19 17:12:58 +08001949
1950out_fb_unreg:
1951 unregister_framebuffer(viafbinfo);
1952out_fb1_unreg_lcd_cle266:
1953 if (viafb_dual_fb && (viafb_primary_dev == LCD_Device)
1954 && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266))
1955 unregister_framebuffer(viafbinfo1);
1956out_dealloc_cmap:
1957 fb_dealloc_cmap(&viafbinfo->cmap);
1958out_fb1_release:
1959 if (viafbinfo1)
1960 framebuffer_release(viafbinfo1);
Jonathan Corbet1b1f8cd2010-03-26 15:45:39 -06001961out_unmap_screen:
1962 iounmap(viafbinfo->screen_base);
Harald Welte109771a2009-05-19 17:12:58 +08001963out_fb_release:
1964 framebuffer_release(viafbinfo);
1965 return rc;
Joseph Chan29b619f2008-10-15 22:03:27 -07001966}
1967
Jonathan Corbetf045f772009-12-01 20:29:39 -07001968void __devexit via_fb_pci_remove(struct pci_dev *pdev)
Joseph Chan29b619f2008-10-15 22:03:27 -07001969{
1970 DEBUG_MSG(KERN_INFO "via_pci_remove!\n");
1971 fb_dealloc_cmap(&viafbinfo->cmap);
1972 unregister_framebuffer(viafbinfo);
1973 if (viafb_dual_fb)
1974 unregister_framebuffer(viafbinfo1);
Florian Tobias Schandinatdb88e382009-09-22 16:47:20 -07001975 iounmap((void *)viafbinfo->screen_base);
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -07001976 iounmap(viaparinfo->shared->engine_mmio);
Joseph Chan29b619f2008-10-15 22:03:27 -07001977
Joseph Chan29b619f2008-10-15 22:03:27 -07001978 framebuffer_release(viafbinfo);
1979 if (viafb_dual_fb)
1980 framebuffer_release(viafbinfo1);
1981
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001982 viafb_remove_proc(viaparinfo->shared->proc_entry);
Joseph Chan29b619f2008-10-15 22:03:27 -07001983}
1984
1985#ifndef MODULE
1986static int __init viafb_setup(char *options)
1987{
1988 char *this_opt;
1989 DEBUG_MSG(KERN_INFO "viafb_setup!\n");
1990
1991 if (!options || !*options)
1992 return 0;
1993
1994 while ((this_opt = strsep(&options, ",")) != NULL) {
1995 if (!*this_opt)
1996 continue;
1997
1998 if (!strncmp(this_opt, "viafb_mode1=", 12))
1999 viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL);
2000 else if (!strncmp(this_opt, "viafb_mode=", 11))
2001 viafb_mode = kstrdup(this_opt + 11, GFP_KERNEL);
2002 else if (!strncmp(this_opt, "viafb_bpp1=", 11))
2003 strict_strtoul(this_opt + 11, 0,
2004 (unsigned long *)&viafb_bpp1);
2005 else if (!strncmp(this_opt, "viafb_bpp=", 10))
2006 strict_strtoul(this_opt + 10, 0,
2007 (unsigned long *)&viafb_bpp);
2008 else if (!strncmp(this_opt, "viafb_refresh1=", 15))
2009 strict_strtoul(this_opt + 15, 0,
2010 (unsigned long *)&viafb_refresh1);
2011 else if (!strncmp(this_opt, "viafb_refresh=", 14))
2012 strict_strtoul(this_opt + 14, 0,
2013 (unsigned long *)&viafb_refresh);
2014 else if (!strncmp(this_opt, "viafb_lcd_dsp_method=", 21))
2015 strict_strtoul(this_opt + 21, 0,
2016 (unsigned long *)&viafb_lcd_dsp_method);
2017 else if (!strncmp(this_opt, "viafb_lcd_panel_id=", 19))
2018 strict_strtoul(this_opt + 19, 0,
2019 (unsigned long *)&viafb_lcd_panel_id);
2020 else if (!strncmp(this_opt, "viafb_accel=", 12))
2021 strict_strtoul(this_opt + 12, 0,
2022 (unsigned long *)&viafb_accel);
2023 else if (!strncmp(this_opt, "viafb_SAMM_ON=", 14))
2024 strict_strtoul(this_opt + 14, 0,
2025 (unsigned long *)&viafb_SAMM_ON);
2026 else if (!strncmp(this_opt, "viafb_active_dev=", 17))
2027 viafb_active_dev = kstrdup(this_opt + 17, GFP_KERNEL);
2028 else if (!strncmp(this_opt,
2029 "viafb_display_hardware_layout=", 30))
2030 strict_strtoul(this_opt + 30, 0,
2031 (unsigned long *)&viafb_display_hardware_layout);
2032 else if (!strncmp(this_opt, "viafb_second_size=", 18))
2033 strict_strtoul(this_opt + 18, 0,
2034 (unsigned long *)&viafb_second_size);
2035 else if (!strncmp(this_opt,
2036 "viafb_platform_epia_dvi=", 24))
2037 strict_strtoul(this_opt + 24, 0,
2038 (unsigned long *)&viafb_platform_epia_dvi);
2039 else if (!strncmp(this_opt,
2040 "viafb_device_lcd_dualedge=", 26))
2041 strict_strtoul(this_opt + 26, 0,
2042 (unsigned long *)&viafb_device_lcd_dualedge);
2043 else if (!strncmp(this_opt, "viafb_bus_width=", 16))
2044 strict_strtoul(this_opt + 16, 0,
2045 (unsigned long *)&viafb_bus_width);
2046 else if (!strncmp(this_opt, "viafb_lcd_mode=", 15))
2047 strict_strtoul(this_opt + 15, 0,
2048 (unsigned long *)&viafb_lcd_mode);
Joseph Chan29b619f2008-10-15 22:03:27 -07002049 else if (!strncmp(this_opt, "viafb_lcd_port=", 15))
2050 viafb_lcd_port = kstrdup(this_opt + 15, GFP_KERNEL);
2051 else if (!strncmp(this_opt, "viafb_dvi_port=", 15))
2052 viafb_dvi_port = kstrdup(this_opt + 15, GFP_KERNEL);
2053 }
2054 return 0;
2055}
2056#endif
2057
Jonathan Corbetf045f772009-12-01 20:29:39 -07002058/*
2059 * These are called out of via-core for now.
2060 */
2061int __init viafb_init(void)
Joseph Chan29b619f2008-10-15 22:03:27 -07002062{
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08002063 u32 dummy;
Joseph Chan29b619f2008-10-15 22:03:27 -07002064#ifndef MODULE
2065 char *option = NULL;
2066 if (fb_get_options("viafb", &option))
2067 return -ENODEV;
2068 viafb_setup(option);
2069#endif
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08002070 if (parse_mode(viafb_mode, &dummy, &dummy)
2071 || parse_mode(viafb_mode1, &dummy, &dummy)
Florian Tobias Schandinate17cea32010-03-10 15:21:41 -08002072 || viafb_bpp < 0 || viafb_bpp > 32
2073 || viafb_bpp1 < 0 || viafb_bpp1 > 32
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08002074 || parse_active_dev())
2075 return -EINVAL;
2076
Joseph Chan29b619f2008-10-15 22:03:27 -07002077 printk(KERN_INFO
2078 "VIA Graphics Intergration Chipset framebuffer %d.%d initializing\n",
2079 VERSION_MAJOR, VERSION_MINOR);
Jonathan Corbetf045f772009-12-01 20:29:39 -07002080 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07002081}
2082
Jonathan Corbetf045f772009-12-01 20:29:39 -07002083void __exit viafb_exit(void)
Joseph Chan29b619f2008-10-15 22:03:27 -07002084{
2085 DEBUG_MSG(KERN_INFO "viafb_exit!\n");
Joseph Chan29b619f2008-10-15 22:03:27 -07002086}
2087
2088static struct fb_ops viafb_ops = {
2089 .owner = THIS_MODULE,
2090 .fb_open = viafb_open,
2091 .fb_release = viafb_release,
2092 .fb_check_var = viafb_check_var,
2093 .fb_set_par = viafb_set_par,
2094 .fb_setcolreg = viafb_setcolreg,
2095 .fb_pan_display = viafb_pan_display,
2096 .fb_blank = viafb_blank,
2097 .fb_fillrect = viafb_fillrect,
2098 .fb_copyarea = viafb_copyarea,
2099 .fb_imageblit = viafb_imageblit,
2100 .fb_cursor = viafb_cursor,
2101 .fb_ioctl = viafb_ioctl,
2102 .fb_sync = viafb_sync,
Joseph Chan29b619f2008-10-15 22:03:27 -07002103};
2104
Joseph Chan29b619f2008-10-15 22:03:27 -07002105
2106#ifdef MODULE
Harald Welte93967be2009-09-22 16:47:32 -07002107module_param(viafb_mode, charp, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002108MODULE_PARM_DESC(viafb_mode, "Set resolution (default=640x480)");
2109
Harald Welte93967be2009-09-22 16:47:32 -07002110module_param(viafb_mode1, charp, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002111MODULE_PARM_DESC(viafb_mode1, "Set resolution (default=640x480)");
2112
Harald Welte93967be2009-09-22 16:47:32 -07002113module_param(viafb_bpp, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002114MODULE_PARM_DESC(viafb_bpp, "Set color depth (default=32bpp)");
2115
Harald Welte93967be2009-09-22 16:47:32 -07002116module_param(viafb_bpp1, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002117MODULE_PARM_DESC(viafb_bpp1, "Set color depth (default=32bpp)");
2118
Harald Welte93967be2009-09-22 16:47:32 -07002119module_param(viafb_refresh, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002120MODULE_PARM_DESC(viafb_refresh,
2121 "Set CRT viafb_refresh rate (default = 60)");
2122
Harald Welte93967be2009-09-22 16:47:32 -07002123module_param(viafb_refresh1, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002124MODULE_PARM_DESC(viafb_refresh1,
2125 "Set CRT refresh rate (default = 60)");
2126
Harald Welte93967be2009-09-22 16:47:32 -07002127module_param(viafb_lcd_panel_id, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002128MODULE_PARM_DESC(viafb_lcd_panel_id,
2129 "Set Flat Panel type(Default=1024x768)");
2130
Harald Welte93967be2009-09-22 16:47:32 -07002131module_param(viafb_lcd_dsp_method, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002132MODULE_PARM_DESC(viafb_lcd_dsp_method,
2133 "Set Flat Panel display scaling method.(Default=Expandsion)");
2134
Harald Welte93967be2009-09-22 16:47:32 -07002135module_param(viafb_SAMM_ON, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002136MODULE_PARM_DESC(viafb_SAMM_ON,
2137 "Turn on/off flag of SAMM(Default=OFF)");
2138
Harald Welte93967be2009-09-22 16:47:32 -07002139module_param(viafb_accel, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002140MODULE_PARM_DESC(viafb_accel,
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -07002141 "Set 2D Hardware Acceleration: 0 = OFF, 1 = ON (default)");
Joseph Chan29b619f2008-10-15 22:03:27 -07002142
Harald Welte93967be2009-09-22 16:47:32 -07002143module_param(viafb_active_dev, charp, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002144MODULE_PARM_DESC(viafb_active_dev, "Specify active devices.");
2145
Harald Welte93967be2009-09-22 16:47:32 -07002146module_param(viafb_display_hardware_layout, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002147MODULE_PARM_DESC(viafb_display_hardware_layout,
2148 "Display Hardware Layout (LCD Only, DVI Only...,etc)");
2149
Harald Welte93967be2009-09-22 16:47:32 -07002150module_param(viafb_second_size, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002151MODULE_PARM_DESC(viafb_second_size,
2152 "Set secondary device memory size");
2153
Harald Welte93967be2009-09-22 16:47:32 -07002154module_param(viafb_dual_fb, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002155MODULE_PARM_DESC(viafb_dual_fb,
2156 "Turn on/off flag of dual framebuffer devices.(Default = OFF)");
2157
Harald Welte93967be2009-09-22 16:47:32 -07002158module_param(viafb_platform_epia_dvi, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002159MODULE_PARM_DESC(viafb_platform_epia_dvi,
2160 "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)");
2161
Harald Welte93967be2009-09-22 16:47:32 -07002162module_param(viafb_device_lcd_dualedge, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002163MODULE_PARM_DESC(viafb_device_lcd_dualedge,
2164 "Turn on/off flag of dual edge panel.(Default = OFF)");
2165
Harald Welte93967be2009-09-22 16:47:32 -07002166module_param(viafb_bus_width, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002167MODULE_PARM_DESC(viafb_bus_width,
2168 "Set bus width of panel.(Default = 12)");
2169
Harald Welte93967be2009-09-22 16:47:32 -07002170module_param(viafb_lcd_mode, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002171MODULE_PARM_DESC(viafb_lcd_mode,
2172 "Set Flat Panel mode(Default=OPENLDI)");
2173
Harald Welte93967be2009-09-22 16:47:32 -07002174module_param(viafb_lcd_port, charp, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002175MODULE_PARM_DESC(viafb_lcd_port, "Specify LCD output port.");
2176
Harald Welte93967be2009-09-22 16:47:32 -07002177module_param(viafb_dvi_port, charp, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002178MODULE_PARM_DESC(viafb_dvi_port, "Specify DVI output port.");
2179
2180MODULE_LICENSE("GPL");
2181#endif