blob: 777b38a06d40b2390a0cc8778ba5212546ff74f5 [file] [log] [blame]
Joseph Chan29b619f2008-10-15 22:03:27 -07001/*
2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
4
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
9
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE.See the GNU General Public License
14 * for more details.
15
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#include <linux/module.h>
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -070023#include <linux/seq_file.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090024#include <linux/slab.h>
Harald Welte93967be2009-09-22 16:47:32 -070025#include <linux/stat.h>
Joseph Chan29b619f2008-10-15 22:03:27 -070026#define _MASTER_FILE
27
28#include "global.h"
29
Joseph Chan29b619f2008-10-15 22:03:27 -070030static char *viafb_name = "Via";
31static u32 pseudo_pal[17];
32
33/* video mode */
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -080034static char *viafb_mode;
35static char *viafb_mode1;
Florian Tobias Schandinatdba77f82010-03-10 15:21:37 -080036static int viafb_bpp = 32;
37static int viafb_bpp1 = 32;
38
39static unsigned int viafb_second_offset;
40static int viafb_second_size;
Joseph Chan29b619f2008-10-15 22:03:27 -070041
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -070042static int viafb_accel = 1;
43
Joseph Chan29b619f2008-10-15 22:03:27 -070044/* Added for specifying active devices.*/
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -080045char *viafb_active_dev;
Joseph Chan29b619f2008-10-15 22:03:27 -070046
Joseph Chan29b619f2008-10-15 22:03:27 -070047/*Added for specify lcd output port*/
48char *viafb_lcd_port = "";
49char *viafb_dvi_port = "";
50
51static void viafb_set_device(struct device_t active_dev);
52static int apply_device_setting(struct viafb_ioctl_setting setting_info,
53 struct fb_info *info);
54static void apply_second_mode_setting(struct fb_var_screeninfo
55 *sec_var);
56static void retrieve_device_setting(struct viafb_ioctl_setting
57 *setting_info);
Florian Tobias Schandinatee79d542010-03-10 15:21:32 -080058static int viafb_pan_display(struct fb_var_screeninfo *var,
59 struct fb_info *info);
Joseph Chan29b619f2008-10-15 22:03:27 -070060
Joseph Chan29b619f2008-10-15 22:03:27 -070061static struct fb_ops viafb_ops;
62
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -070063
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -080064static void viafb_fill_var_color_info(struct fb_var_screeninfo *var, u8 depth)
65{
66 var->grayscale = 0;
67 var->red.msb_right = 0;
68 var->green.msb_right = 0;
69 var->blue.msb_right = 0;
70 var->transp.offset = 0;
71 var->transp.length = 0;
72 var->transp.msb_right = 0;
73 var->nonstd = 0;
74 switch (depth) {
75 case 8:
76 var->bits_per_pixel = 8;
77 var->red.offset = 0;
78 var->green.offset = 0;
79 var->blue.offset = 0;
Florian Tobias Schandinat415559f2010-03-10 15:21:40 -080080 var->red.length = 8;
81 var->green.length = 8;
82 var->blue.length = 8;
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -080083 break;
Florian Tobias Schandinate17cea32010-03-10 15:21:41 -080084 case 15:
85 var->bits_per_pixel = 16;
86 var->red.offset = 10;
87 var->green.offset = 5;
88 var->blue.offset = 0;
89 var->red.length = 5;
90 var->green.length = 5;
91 var->blue.length = 5;
92 break;
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -080093 case 16:
94 var->bits_per_pixel = 16;
95 var->red.offset = 11;
96 var->green.offset = 5;
97 var->blue.offset = 0;
98 var->red.length = 5;
99 var->green.length = 6;
100 var->blue.length = 5;
101 break;
102 case 24:
103 var->bits_per_pixel = 32;
104 var->red.offset = 16;
105 var->green.offset = 8;
106 var->blue.offset = 0;
107 var->red.length = 8;
108 var->green.length = 8;
109 var->blue.length = 8;
110 break;
Florian Tobias Schandinate17cea32010-03-10 15:21:41 -0800111 case 30:
112 var->bits_per_pixel = 32;
113 var->red.offset = 20;
114 var->green.offset = 10;
115 var->blue.offset = 0;
116 var->red.length = 10;
117 var->green.length = 10;
118 var->blue.length = 10;
119 break;
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800120 }
121}
122
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -0700123static void viafb_update_fix(struct fb_info *info)
Joseph Chan29b619f2008-10-15 22:03:27 -0700124{
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -0700125 u32 bpp = info->var.bits_per_pixel;
Joseph Chan29b619f2008-10-15 22:03:27 -0700126
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -0700127 info->fix.visual =
128 bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
Florian Tobias Schandinatdbb78842010-03-10 15:21:39 -0800129 info->fix.line_length = (info->var.xres_virtual * bpp / 8 + 7) & ~7;
Joseph Chan29b619f2008-10-15 22:03:27 -0700130}
131
Joseph Chan29b619f2008-10-15 22:03:27 -0700132static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix,
133 struct viafb_par *viaparinfo)
134{
135 memset(fix, 0, sizeof(struct fb_fix_screeninfo));
136 strcpy(fix->id, viafb_name);
137
138 fix->smem_start = viaparinfo->fbmem;
139 fix->smem_len = viaparinfo->fbmem_free;
Joseph Chan29b619f2008-10-15 22:03:27 -0700140
141 fix->type = FB_TYPE_PACKED_PIXELS;
142 fix->type_aux = 0;
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800143 fix->visual = FB_VISUAL_TRUECOLOR;
Joseph Chan29b619f2008-10-15 22:03:27 -0700144
145 fix->xpanstep = fix->ywrapstep = 0;
146 fix->ypanstep = 1;
147
148 /* Just tell the accel name */
149 viafbinfo->fix.accel = FB_ACCEL_VIA_UNICHROME;
150}
151static int viafb_open(struct fb_info *info, int user)
152{
153 DEBUG_MSG(KERN_INFO "viafb_open!\n");
154 return 0;
155}
156
157static int viafb_release(struct fb_info *info, int user)
158{
159 DEBUG_MSG(KERN_INFO "viafb_release!\n");
160 return 0;
161}
162
Joseph Chan29b619f2008-10-15 22:03:27 -0700163static int viafb_check_var(struct fb_var_screeninfo *var,
164 struct fb_info *info)
165{
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800166 int htotal, vtotal, depth;
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800167 struct VideoModeTable *vmode_entry;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700168 struct viafb_par *ppar = info->par;
Florian Tobias Schandinatdbb78842010-03-10 15:21:39 -0800169 u32 long_refresh, line;
Joseph Chan29b619f2008-10-15 22:03:27 -0700170
171 DEBUG_MSG(KERN_INFO "viafb_check_var!\n");
172 /* Sanity check */
173 /* HW neither support interlacte nor double-scaned mode */
174 if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE)
175 return -EINVAL;
176
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800177 vmode_entry = viafb_get_mode(var->xres, var->yres);
178 if (!vmode_entry) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700179 DEBUG_MSG(KERN_INFO
180 "viafb: Mode %dx%dx%d not supported!!\n",
181 var->xres, var->yres, var->bits_per_pixel);
182 return -EINVAL;
183 }
184
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800185 depth = fb_get_color_depth(var, &info->fix);
186 if (!depth)
187 depth = var->bits_per_pixel;
Joseph Chan29b619f2008-10-15 22:03:27 -0700188
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800189 if (depth < 0 || depth > 32)
Joseph Chan29b619f2008-10-15 22:03:27 -0700190 return -EINVAL;
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800191 else if (!depth)
192 depth = 24;
Florian Tobias Schandinate17cea32010-03-10 15:21:41 -0800193 else if (depth == 15 && viafb_dual_fb && ppar->iga_path == IGA1)
194 depth = 15;
195 else if (depth == 30)
196 depth = 30;
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800197 else if (depth <= 8)
198 depth = 8;
199 else if (depth <= 16)
200 depth = 16;
201 else
202 depth = 24;
Joseph Chan29b619f2008-10-15 22:03:27 -0700203
Florian Tobias Schandinatbd140692010-03-10 15:21:38 -0800204 viafb_fill_var_color_info(var, depth);
Florian Tobias Schandinatdbb78842010-03-10 15:21:39 -0800205 line = (var->xres_virtual * var->bits_per_pixel / 8 + 7) & ~7;
206 if (line * var->yres_virtual > ppar->memsize)
Joseph Chan29b619f2008-10-15 22:03:27 -0700207 return -EINVAL;
208
209 /* Based on var passed in to calculate the refresh,
210 * because our driver use some modes special.
211 */
212 htotal = var->xres + var->left_margin +
213 var->right_margin + var->hsync_len;
214 vtotal = var->yres + var->upper_margin +
215 var->lower_margin + var->vsync_len;
216 long_refresh = 1000000000UL / var->pixclock * 1000;
217 long_refresh /= (htotal * vtotal);
218
219 viafb_refresh = viafb_get_refresh(var->xres, var->yres, long_refresh);
220
221 /* Adjust var according to our driver's own table */
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800222 viafb_fill_var_timing_info(var, viafb_refresh, vmode_entry);
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700223 if (info->var.accel_flags & FB_ACCELF_TEXT &&
224 !ppar->shared->engine_mmio)
225 info->var.accel_flags = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700226
Joseph Chan29b619f2008-10-15 22:03:27 -0700227 return 0;
228}
229
230static int viafb_set_par(struct fb_info *info)
231{
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700232 struct viafb_par *viapar = info->par;
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800233 struct VideoModeTable *vmode_entry, *vmode_entry1 = NULL;
Joseph Chan29b619f2008-10-15 22:03:27 -0700234 DEBUG_MSG(KERN_INFO "viafb_set_par!\n");
235
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700236 viapar->depth = fb_get_color_depth(&info->var, &info->fix);
Florian Tobias Schandinat5c9443e2010-03-10 15:21:34 -0800237 viafb_update_device_setting(viafbinfo->var.xres, viafbinfo->var.yres,
238 viafbinfo->var.bits_per_pixel, viafb_refresh, 0);
Joseph Chan29b619f2008-10-15 22:03:27 -0700239
Florian Tobias Schandinat5c9443e2010-03-10 15:21:34 -0800240 vmode_entry = viafb_get_mode(viafbinfo->var.xres, viafbinfo->var.yres);
241 if (viafb_dual_fb) {
242 vmode_entry1 = viafb_get_mode(viafbinfo1->var.xres,
243 viafbinfo1->var.yres);
244 viafb_update_device_setting(viafbinfo1->var.xres,
245 viafbinfo1->var.yres, viafbinfo1->var.bits_per_pixel,
246 viafb_refresh1, 1);
247 } else if (viafb_SAMM_ON == 1) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700248 DEBUG_MSG(KERN_INFO
249 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
250 viafb_second_xres, viafb_second_yres, viafb_bpp1);
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800251 vmode_entry1 = viafb_get_mode(viafb_second_xres,
Florian Tobias Schandinat52159442009-08-06 15:07:34 -0700252 viafb_second_yres);
Joseph Chan29b619f2008-10-15 22:03:27 -0700253
254 viafb_update_device_setting(viafb_second_xres,
255 viafb_second_yres, viafb_bpp1, viafb_refresh1, 1);
256 }
257
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800258 if (vmode_entry) {
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -0700259 viafb_update_fix(info);
Florian Tobias Schandinat5c9443e2010-03-10 15:21:34 -0800260 if (viafb_dual_fb && viapar->iga_path == IGA2)
261 viafb_bpp1 = info->var.bits_per_pixel;
262 else
263 viafb_bpp = info->var.bits_per_pixel;
264
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700265 if (info->var.accel_flags & FB_ACCELF_TEXT)
266 info->flags &= ~FBINFO_HWACCEL_DISABLED;
267 else
268 info->flags |= FBINFO_HWACCEL_DISABLED;
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800269 viafb_setmode(vmode_entry, info->var.bits_per_pixel,
270 vmode_entry1, viafb_bpp1);
Florian Tobias Schandinatee79d542010-03-10 15:21:32 -0800271 viafb_pan_display(&info->var, info);
Joseph Chan29b619f2008-10-15 22:03:27 -0700272 }
273
274 return 0;
275}
276
277/* Set one color register */
278static int viafb_setcolreg(unsigned regno, unsigned red, unsigned green,
279unsigned blue, unsigned transp, struct fb_info *info)
280{
Florian Tobias Schandinat415559f2010-03-10 15:21:40 -0800281 struct viafb_par *viapar = info->par;
282 u32 r, g, b;
Joseph Chan29b619f2008-10-15 22:03:27 -0700283
Florian Tobias Schandinat415559f2010-03-10 15:21:40 -0800284 if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) {
285 if (regno > 255)
286 return -EINVAL;
Joseph Chan29b619f2008-10-15 22:03:27 -0700287
Florian Tobias Schandinat415559f2010-03-10 15:21:40 -0800288 if (!viafb_dual_fb || viapar->iga_path == IGA1)
289 viafb_set_primary_color_register(regno, red >> 8,
290 green >> 8, blue >> 8);
Joseph Chan29b619f2008-10-15 22:03:27 -0700291
Florian Tobias Schandinat415559f2010-03-10 15:21:40 -0800292 if (!viafb_dual_fb || viapar->iga_path == IGA2)
293 viafb_set_secondary_color_register(regno, red >> 8,
294 green >> 8, blue >> 8);
295 } else {
296 if (regno > 15)
297 return -EINVAL;
Joseph Chan29b619f2008-10-15 22:03:27 -0700298
Florian Tobias Schandinat415559f2010-03-10 15:21:40 -0800299 r = (red >> (16 - info->var.red.length))
300 << info->var.red.offset;
301 b = (blue >> (16 - info->var.blue.length))
302 << info->var.blue.offset;
303 g = (green >> (16 - info->var.green.length))
304 << info->var.green.offset;
305 ((u32 *) info->pseudo_palette)[regno] = r | g | b;
Joseph Chan29b619f2008-10-15 22:03:27 -0700306 }
307
308 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700309}
310
311static int viafb_pan_display(struct fb_var_screeninfo *var,
312 struct fb_info *info)
313{
Florian Tobias Schandinatee79d542010-03-10 15:21:32 -0800314 struct viafb_par *viapar = info->par;
315 u32 vram_addr = (var->yoffset * var->xres_virtual + var->xoffset)
316 * (var->bits_per_pixel / 8) + viapar->vram_addr;
Joseph Chan29b619f2008-10-15 22:03:27 -0700317
Florian Tobias Schandinatee79d542010-03-10 15:21:32 -0800318 DEBUG_MSG(KERN_DEBUG "viafb_pan_display, address = %d\n", vram_addr);
319 if (!viafb_dual_fb) {
320 viafb_set_primary_address(vram_addr);
321 viafb_set_secondary_address(vram_addr);
322 } else if (viapar->iga_path == IGA1)
323 viafb_set_primary_address(vram_addr);
324 else
325 viafb_set_secondary_address(vram_addr);
Joseph Chan29b619f2008-10-15 22:03:27 -0700326
Joseph Chan29b619f2008-10-15 22:03:27 -0700327 return 0;
328}
329
330static int viafb_blank(int blank_mode, struct fb_info *info)
331{
332 DEBUG_MSG(KERN_INFO "viafb_blank!\n");
333 /* clear DPMS setting */
334
335 switch (blank_mode) {
336 case FB_BLANK_UNBLANK:
337 /* Screen: On, HSync: On, VSync: On */
338 /* control CRT monitor power management */
339 viafb_write_reg_mask(CR36, VIACR, 0x00, BIT4 + BIT5);
340 break;
341 case FB_BLANK_HSYNC_SUSPEND:
342 /* Screen: Off, HSync: Off, VSync: On */
343 /* control CRT monitor power management */
344 viafb_write_reg_mask(CR36, VIACR, 0x10, BIT4 + BIT5);
345 break;
346 case FB_BLANK_VSYNC_SUSPEND:
347 /* Screen: Off, HSync: On, VSync: Off */
348 /* control CRT monitor power management */
349 viafb_write_reg_mask(CR36, VIACR, 0x20, BIT4 + BIT5);
350 break;
351 case FB_BLANK_POWERDOWN:
352 /* Screen: Off, HSync: Off, VSync: Off */
353 /* control CRT monitor power management */
354 viafb_write_reg_mask(CR36, VIACR, 0x30, BIT4 + BIT5);
355 break;
356 }
357
358 return 0;
359}
360
361static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
362{
Bruno Prémonte687d692009-01-04 13:11:54 -0800363 union {
364 struct viafb_ioctl_mode viamode;
365 struct viafb_ioctl_samm viasamm;
366 struct viafb_driver_version driver_version;
367 struct fb_var_screeninfo sec_var;
368 struct _panel_size_pos_info panel_pos_size_para;
369 struct viafb_ioctl_setting viafb_setting;
370 struct device_t active_dev;
371 } u;
Joseph Chan29b619f2008-10-15 22:03:27 -0700372 u32 state_info = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700373 u32 *viafb_gamma_table;
374 char driver_name[] = "viafb";
375
376 u32 __user *argp = (u32 __user *) arg;
377 u32 gpu32;
Joseph Chan29b619f2008-10-15 22:03:27 -0700378
379 DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd);
Florian Tobias Schandinatcc8b82f2010-03-10 15:21:26 -0800380 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 -0800381 memset(&u, 0, sizeof(u));
Joseph Chan29b619f2008-10-15 22:03:27 -0700382
383 switch (cmd) {
384 case VIAFB_GET_CHIP_INFO:
385 if (copy_to_user(argp, viaparinfo->chip_info,
386 sizeof(struct chip_information)))
387 return -EFAULT;
388 break;
389 case VIAFB_GET_INFO_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800390 return put_user((u32)sizeof(struct viafb_ioctl_info), argp);
Joseph Chan29b619f2008-10-15 22:03:27 -0700391 case VIAFB_GET_INFO:
392 return viafb_ioctl_get_viafb_info(arg);
393 case VIAFB_HOTPLUG:
394 return put_user(viafb_ioctl_hotplug(info->var.xres,
395 info->var.yres,
396 info->var.bits_per_pixel), argp);
397 case VIAFB_SET_HOTPLUG_FLAG:
398 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
399 return -EFAULT;
400 viafb_hotplug = (gpu32) ? 1 : 0;
401 break;
402 case VIAFB_GET_RESOLUTION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800403 u.viamode.xres = (u32) viafb_hotplug_Xres;
404 u.viamode.yres = (u32) viafb_hotplug_Yres;
405 u.viamode.refresh = (u32) viafb_hotplug_refresh;
406 u.viamode.bpp = (u32) viafb_hotplug_bpp;
Joseph Chan29b619f2008-10-15 22:03:27 -0700407 if (viafb_SAMM_ON == 1) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800408 u.viamode.xres_sec = viafb_second_xres;
409 u.viamode.yres_sec = viafb_second_yres;
410 u.viamode.virtual_xres_sec = viafb_second_virtual_xres;
411 u.viamode.virtual_yres_sec = viafb_second_virtual_yres;
412 u.viamode.refresh_sec = viafb_refresh1;
413 u.viamode.bpp_sec = viafb_bpp1;
Joseph Chan29b619f2008-10-15 22:03:27 -0700414 } else {
Bruno Prémonte687d692009-01-04 13:11:54 -0800415 u.viamode.xres_sec = 0;
416 u.viamode.yres_sec = 0;
417 u.viamode.virtual_xres_sec = 0;
418 u.viamode.virtual_yres_sec = 0;
419 u.viamode.refresh_sec = 0;
420 u.viamode.bpp_sec = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700421 }
Bruno Prémonte687d692009-01-04 13:11:54 -0800422 if (copy_to_user(argp, &u.viamode, sizeof(u.viamode)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700423 return -EFAULT;
424 break;
425 case VIAFB_GET_SAMM_INFO:
Bruno Prémonte687d692009-01-04 13:11:54 -0800426 u.viasamm.samm_status = viafb_SAMM_ON;
Joseph Chan29b619f2008-10-15 22:03:27 -0700427
428 if (viafb_SAMM_ON == 1) {
429 if (viafb_dual_fb) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800430 u.viasamm.size_prim = viaparinfo->fbmem_free;
431 u.viasamm.size_sec = viaparinfo1->fbmem_free;
Joseph Chan29b619f2008-10-15 22:03:27 -0700432 } else {
433 if (viafb_second_size) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800434 u.viasamm.size_prim =
Joseph Chan29b619f2008-10-15 22:03:27 -0700435 viaparinfo->fbmem_free -
436 viafb_second_size * 1024 * 1024;
Bruno Prémonte687d692009-01-04 13:11:54 -0800437 u.viasamm.size_sec =
Joseph Chan29b619f2008-10-15 22:03:27 -0700438 viafb_second_size * 1024 * 1024;
439 } else {
Bruno Prémonte687d692009-01-04 13:11:54 -0800440 u.viasamm.size_prim =
Joseph Chan29b619f2008-10-15 22:03:27 -0700441 viaparinfo->fbmem_free >> 1;
Bruno Prémonte687d692009-01-04 13:11:54 -0800442 u.viasamm.size_sec =
Joseph Chan29b619f2008-10-15 22:03:27 -0700443 (viaparinfo->fbmem_free >> 1);
444 }
445 }
Bruno Prémonte687d692009-01-04 13:11:54 -0800446 u.viasamm.mem_base = viaparinfo->fbmem;
447 u.viasamm.offset_sec = viafb_second_offset;
Joseph Chan29b619f2008-10-15 22:03:27 -0700448 } else {
Bruno Prémonte687d692009-01-04 13:11:54 -0800449 u.viasamm.size_prim =
Joseph Chan29b619f2008-10-15 22:03:27 -0700450 viaparinfo->memsize - viaparinfo->fbmem_used;
Bruno Prémonte687d692009-01-04 13:11:54 -0800451 u.viasamm.size_sec = 0;
452 u.viasamm.mem_base = viaparinfo->fbmem;
453 u.viasamm.offset_sec = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700454 }
455
Bruno Prémonte687d692009-01-04 13:11:54 -0800456 if (copy_to_user(argp, &u.viasamm, sizeof(u.viasamm)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700457 return -EFAULT;
458
459 break;
460 case VIAFB_TURN_ON_OUTPUT_DEVICE:
461 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
462 return -EFAULT;
463 if (gpu32 & CRT_Device)
464 viafb_crt_enable();
465 if (gpu32 & DVI_Device)
466 viafb_dvi_enable();
467 if (gpu32 & LCD_Device)
468 viafb_lcd_enable();
469 break;
470 case VIAFB_TURN_OFF_OUTPUT_DEVICE:
471 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
472 return -EFAULT;
473 if (gpu32 & CRT_Device)
474 viafb_crt_disable();
475 if (gpu32 & DVI_Device)
476 viafb_dvi_disable();
477 if (gpu32 & LCD_Device)
478 viafb_lcd_disable();
479 break;
480 case VIAFB_SET_DEVICE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800481 if (copy_from_user(&u.active_dev, (void *)argp,
482 sizeof(u.active_dev)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700483 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800484 viafb_set_device(u.active_dev);
Joseph Chan29b619f2008-10-15 22:03:27 -0700485 viafb_set_par(info);
486 break;
487 case VIAFB_GET_DEVICE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800488 u.active_dev.crt = viafb_CRT_ON;
489 u.active_dev.dvi = viafb_DVI_ON;
490 u.active_dev.lcd = viafb_LCD_ON;
491 u.active_dev.samm = viafb_SAMM_ON;
492 u.active_dev.primary_dev = viafb_primary_dev;
Joseph Chan29b619f2008-10-15 22:03:27 -0700493
Bruno Prémonte687d692009-01-04 13:11:54 -0800494 u.active_dev.lcd_dsp_cent = viafb_lcd_dsp_method;
495 u.active_dev.lcd_panel_id = viafb_lcd_panel_id;
496 u.active_dev.lcd_mode = viafb_lcd_mode;
Joseph Chan29b619f2008-10-15 22:03:27 -0700497
Bruno Prémonte687d692009-01-04 13:11:54 -0800498 u.active_dev.xres = viafb_hotplug_Xres;
499 u.active_dev.yres = viafb_hotplug_Yres;
Joseph Chan29b619f2008-10-15 22:03:27 -0700500
Bruno Prémonte687d692009-01-04 13:11:54 -0800501 u.active_dev.xres1 = viafb_second_xres;
502 u.active_dev.yres1 = viafb_second_yres;
Joseph Chan29b619f2008-10-15 22:03:27 -0700503
Bruno Prémonte687d692009-01-04 13:11:54 -0800504 u.active_dev.bpp = viafb_bpp;
505 u.active_dev.bpp1 = viafb_bpp1;
506 u.active_dev.refresh = viafb_refresh;
507 u.active_dev.refresh1 = viafb_refresh1;
Joseph Chan29b619f2008-10-15 22:03:27 -0700508
Bruno Prémonte687d692009-01-04 13:11:54 -0800509 u.active_dev.epia_dvi = viafb_platform_epia_dvi;
510 u.active_dev.lcd_dual_edge = viafb_device_lcd_dualedge;
511 u.active_dev.bus_width = viafb_bus_width;
Joseph Chan29b619f2008-10-15 22:03:27 -0700512
Bruno Prémonte687d692009-01-04 13:11:54 -0800513 if (copy_to_user(argp, &u.active_dev, sizeof(u.active_dev)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700514 return -EFAULT;
515 break;
516
517 case VIAFB_GET_DRIVER_VERSION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800518 u.driver_version.iMajorNum = VERSION_MAJOR;
519 u.driver_version.iKernelNum = VERSION_KERNEL;
520 u.driver_version.iOSNum = VERSION_OS;
521 u.driver_version.iMinorNum = VERSION_MINOR;
Joseph Chan29b619f2008-10-15 22:03:27 -0700522
Bruno Prémonte687d692009-01-04 13:11:54 -0800523 if (copy_to_user(argp, &u.driver_version,
524 sizeof(u.driver_version)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700525 return -EFAULT;
526
527 break;
528
529 case VIAFB_SET_DEVICE_INFO:
Bruno Prémonte687d692009-01-04 13:11:54 -0800530 if (copy_from_user(&u.viafb_setting,
531 argp, sizeof(u.viafb_setting)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700532 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800533 if (apply_device_setting(u.viafb_setting, info) < 0)
Joseph Chan29b619f2008-10-15 22:03:27 -0700534 return -EINVAL;
535
536 break;
537
538 case VIAFB_SET_SECOND_MODE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800539 if (copy_from_user(&u.sec_var, argp, sizeof(u.sec_var)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700540 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800541 apply_second_mode_setting(&u.sec_var);
Joseph Chan29b619f2008-10-15 22:03:27 -0700542 break;
543
544 case VIAFB_GET_DEVICE_INFO:
545
Bruno Prémonte687d692009-01-04 13:11:54 -0800546 retrieve_device_setting(&u.viafb_setting);
Joseph Chan29b619f2008-10-15 22:03:27 -0700547
Bruno Prémonte687d692009-01-04 13:11:54 -0800548 if (copy_to_user(argp, &u.viafb_setting,
549 sizeof(u.viafb_setting)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700550 return -EFAULT;
551
552 break;
553
554 case VIAFB_GET_DEVICE_SUPPORT:
555 viafb_get_device_support_state(&state_info);
556 if (put_user(state_info, argp))
557 return -EFAULT;
558 break;
559
560 case VIAFB_GET_DEVICE_CONNECT:
561 viafb_get_device_connect_state(&state_info);
562 if (put_user(state_info, argp))
563 return -EFAULT;
564 break;
565
566 case VIAFB_GET_PANEL_SUPPORT_EXPAND:
567 state_info =
568 viafb_lcd_get_support_expand_state(info->var.xres,
569 info->var.yres);
570 if (put_user(state_info, argp))
571 return -EFAULT;
572 break;
573
574 case VIAFB_GET_DRIVER_NAME:
575 if (copy_to_user(argp, driver_name, sizeof(driver_name)))
576 return -EFAULT;
577 break;
578
579 case VIAFB_SET_GAMMA_LUT:
580 viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
581 if (!viafb_gamma_table)
582 return -ENOMEM;
583 if (copy_from_user(viafb_gamma_table, argp,
Julia Lawall0f050582009-12-17 15:27:09 -0800584 256 * sizeof(u32))) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700585 kfree(viafb_gamma_table);
586 return -EFAULT;
587 }
588 viafb_set_gamma_table(viafb_bpp, viafb_gamma_table);
589 kfree(viafb_gamma_table);
590 break;
591
592 case VIAFB_GET_GAMMA_LUT:
593 viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
594 if (!viafb_gamma_table)
595 return -ENOMEM;
596 viafb_get_gamma_table(viafb_gamma_table);
597 if (copy_to_user(argp, viafb_gamma_table,
Julia Lawall0f050582009-12-17 15:27:09 -0800598 256 * sizeof(u32))) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700599 kfree(viafb_gamma_table);
600 return -EFAULT;
601 }
602 kfree(viafb_gamma_table);
603 break;
604
605 case VIAFB_GET_GAMMA_SUPPORT_STATE:
606 viafb_get_gamma_support_state(viafb_bpp, &state_info);
607 if (put_user(state_info, argp))
608 return -EFAULT;
609 break;
Joseph Chan29b619f2008-10-15 22:03:27 -0700610 case VIAFB_SYNC_SURFACE:
611 DEBUG_MSG(KERN_INFO "lobo VIAFB_SYNC_SURFACE\n");
612 break;
613 case VIAFB_GET_DRIVER_CAPS:
614 break;
615
616 case VIAFB_GET_PANEL_MAX_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800617 if (copy_from_user(&u.panel_pos_size_para, argp,
618 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700619 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800620 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
621 if (copy_to_user(argp, &u.panel_pos_size_para,
622 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700623 return -EFAULT;
624 break;
625 case VIAFB_GET_PANEL_MAX_POSITION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800626 if (copy_from_user(&u.panel_pos_size_para, argp,
627 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700628 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800629 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
630 if (copy_to_user(argp, &u.panel_pos_size_para,
631 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700632 return -EFAULT;
633 break;
634
635 case VIAFB_GET_PANEL_POSITION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800636 if (copy_from_user(&u.panel_pos_size_para, argp,
637 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700638 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800639 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
640 if (copy_to_user(argp, &u.panel_pos_size_para,
641 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700642 return -EFAULT;
643 break;
644 case VIAFB_GET_PANEL_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800645 if (copy_from_user(&u.panel_pos_size_para, argp,
646 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700647 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800648 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
649 if (copy_to_user(argp, &u.panel_pos_size_para,
650 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700651 return -EFAULT;
652 break;
653
654 case VIAFB_SET_PANEL_POSITION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800655 if (copy_from_user(&u.panel_pos_size_para, argp,
656 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700657 return -EFAULT;
658 break;
659 case VIAFB_SET_PANEL_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800660 if (copy_from_user(&u.panel_pos_size_para, argp,
661 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700662 return -EFAULT;
663 break;
664
665 default:
666 return -EINVAL;
667 }
668
669 return 0;
670}
671
672static void viafb_fillrect(struct fb_info *info,
673 const struct fb_fillrect *rect)
674{
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700675 struct viafb_par *viapar = info->par;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700676 struct viafb_shared *shared = viapar->shared;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700677 u32 fg_color;
678 u8 rop;
Joseph Chan29b619f2008-10-15 22:03:27 -0700679
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700680 if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) {
Hannes Eder2899bb02009-01-06 14:42:32 -0800681 cfb_fillrect(info, rect);
682 return;
683 }
Joseph Chan29b619f2008-10-15 22:03:27 -0700684
685 if (!rect->width || !rect->height)
686 return;
687
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700688 if (info->fix.visual == FB_VISUAL_TRUECOLOR)
689 fg_color = ((u32 *)info->pseudo_palette)[rect->color];
690 else
691 fg_color = rect->color;
692
693 if (rect->rop == ROP_XOR)
Joseph Chan29b619f2008-10-15 22:03:27 -0700694 rop = 0x5A;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700695 else
Joseph Chan29b619f2008-10-15 22:03:27 -0700696 rop = 0xF0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700697
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700698 DEBUG_MSG(KERN_DEBUG "viafb 2D engine: fillrect\n");
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700699 if (shared->hw_bitblt(shared->engine_mmio, VIA_BITBLT_FILL,
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700700 rect->width, rect->height, info->var.bits_per_pixel,
701 viapar->vram_addr, info->fix.line_length, rect->dx, rect->dy,
702 NULL, 0, 0, 0, 0, fg_color, 0, rop))
703 cfb_fillrect(info, rect);
Joseph Chan29b619f2008-10-15 22:03:27 -0700704}
705
706static void viafb_copyarea(struct fb_info *info,
707 const struct fb_copyarea *area)
708{
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700709 struct viafb_par *viapar = info->par;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700710 struct viafb_shared *shared = viapar->shared;
Joseph Chan29b619f2008-10-15 22:03:27 -0700711
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700712 if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) {
Hannes Eder2899bb02009-01-06 14:42:32 -0800713 cfb_copyarea(info, area);
714 return;
715 }
Joseph Chan29b619f2008-10-15 22:03:27 -0700716
717 if (!area->width || !area->height)
718 return;
719
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700720 DEBUG_MSG(KERN_DEBUG "viafb 2D engine: copyarea\n");
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700721 if (shared->hw_bitblt(shared->engine_mmio, VIA_BITBLT_COLOR,
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700722 area->width, area->height, info->var.bits_per_pixel,
723 viapar->vram_addr, info->fix.line_length, area->dx, area->dy,
724 NULL, viapar->vram_addr, info->fix.line_length,
725 area->sx, area->sy, 0, 0, 0))
726 cfb_copyarea(info, area);
Joseph Chan29b619f2008-10-15 22:03:27 -0700727}
728
729static void viafb_imageblit(struct fb_info *info,
730 const struct fb_image *image)
731{
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700732 struct viafb_par *viapar = info->par;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700733 struct viafb_shared *shared = viapar->shared;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700734 u32 fg_color = 0, bg_color = 0;
735 u8 op;
Joseph Chan29b619f2008-10-15 22:03:27 -0700736
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700737 if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt ||
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700738 (image->depth != 1 && image->depth != viapar->depth)) {
Hannes Eder2899bb02009-01-06 14:42:32 -0800739 cfb_imageblit(info, image);
740 return;
741 }
Joseph Chan29b619f2008-10-15 22:03:27 -0700742
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700743 if (image->depth == 1) {
744 op = VIA_BITBLT_MONO;
745 if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
746 fg_color =
747 ((u32 *)info->pseudo_palette)[image->fg_color];
748 bg_color =
749 ((u32 *)info->pseudo_palette)[image->bg_color];
750 } else {
751 fg_color = image->fg_color;
752 bg_color = image->bg_color;
753 }
754 } else
755 op = VIA_BITBLT_COLOR;
Joseph Chan29b619f2008-10-15 22:03:27 -0700756
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700757 DEBUG_MSG(KERN_DEBUG "viafb 2D engine: imageblit\n");
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700758 if (shared->hw_bitblt(shared->engine_mmio, op,
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700759 image->width, image->height, info->var.bits_per_pixel,
760 viapar->vram_addr, info->fix.line_length, image->dx, image->dy,
761 (u32 *)image->data, 0, 0, 0, 0, fg_color, bg_color, 0))
762 cfb_imageblit(info, image);
Joseph Chan29b619f2008-10-15 22:03:27 -0700763}
764
765static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
766{
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700767 struct viafb_par *viapar = info->par;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700768 void __iomem *engine = viapar->shared->engine_mmio;
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700769 u32 temp, xx, yy, bg_color = 0, fg_color = 0,
770 chip_name = viapar->shared->chip_info.gfx_chip_name;
771 int i, j = 0, cur_size = 64;
Joseph Chan29b619f2008-10-15 22:03:27 -0700772
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700773 if (info->flags & FBINFO_HWACCEL_DISABLED || info != viafbinfo)
Joseph Chan29b619f2008-10-15 22:03:27 -0700774 return -ENODEV;
775
Florian Tobias Schandinat0b941902010-01-15 17:01:03 -0800776 /* LCD ouput does not support hw cursors (at least on VN896) */
777 if ((chip_name == UNICHROME_CLE266 && viapar->iga_path == IGA2) ||
778 viafb_LCD_ON)
Joseph Chan29b619f2008-10-15 22:03:27 -0700779 return -ENODEV;
780
781 viafb_show_hw_cursor(info, HW_Cursor_OFF);
Joseph Chan29b619f2008-10-15 22:03:27 -0700782
783 if (cursor->set & FB_CUR_SETHOT) {
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700784 temp = (cursor->hot.x << 16) + cursor->hot.y;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700785 writel(temp, engine + VIA_REG_CURSOR_ORG);
Joseph Chan29b619f2008-10-15 22:03:27 -0700786 }
787
788 if (cursor->set & FB_CUR_SETPOS) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700789 yy = cursor->image.dy - info->var.yoffset;
790 xx = cursor->image.dx - info->var.xoffset;
791 temp = yy & 0xFFFF;
792 temp |= (xx << 16);
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700793 writel(temp, engine + VIA_REG_CURSOR_POS);
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700794 }
795
796 if (cursor->image.width <= 32 && cursor->image.height <= 32)
797 cur_size = 32;
798 else if (cursor->image.width <= 64 && cursor->image.height <= 64)
799 cur_size = 64;
800 else {
801 printk(KERN_WARNING "viafb_cursor: The cursor is too large "
802 "%dx%d", cursor->image.width, cursor->image.height);
803 return -ENXIO;
Joseph Chan29b619f2008-10-15 22:03:27 -0700804 }
805
806 if (cursor->set & FB_CUR_SETSIZE) {
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700807 temp = readl(engine + VIA_REG_CURSOR_MODE);
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700808 if (cur_size == 32)
Joseph Chan29b619f2008-10-15 22:03:27 -0700809 temp |= 0x2;
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700810 else
811 temp &= ~0x2;
Joseph Chan29b619f2008-10-15 22:03:27 -0700812
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700813 writel(temp, engine + VIA_REG_CURSOR_MODE);
Joseph Chan29b619f2008-10-15 22:03:27 -0700814 }
815
816 if (cursor->set & FB_CUR_SETCMAP) {
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700817 fg_color = cursor->image.fg_color;
818 bg_color = cursor->image.bg_color;
819 if (chip_name == UNICHROME_CX700 ||
Harald Welte0306ab12009-09-22 16:47:35 -0700820 chip_name == UNICHROME_VX800 ||
821 chip_name == UNICHROME_VX855) {
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700822 fg_color =
823 ((info->cmap.red[fg_color] & 0xFFC0) << 14) |
824 ((info->cmap.green[fg_color] & 0xFFC0) << 4) |
825 ((info->cmap.blue[fg_color] & 0xFFC0) >> 6);
826 bg_color =
827 ((info->cmap.red[bg_color] & 0xFFC0) << 14) |
828 ((info->cmap.green[bg_color] & 0xFFC0) << 4) |
829 ((info->cmap.blue[bg_color] & 0xFFC0) >> 6);
830 } else {
831 fg_color =
832 ((info->cmap.red[fg_color] & 0xFF00) << 8) |
833 (info->cmap.green[fg_color] & 0xFF00) |
834 ((info->cmap.blue[fg_color] & 0xFF00) >> 8);
835 bg_color =
836 ((info->cmap.red[bg_color] & 0xFF00) << 8) |
837 (info->cmap.green[bg_color] & 0xFF00) |
838 ((info->cmap.blue[bg_color] & 0xFF00) >> 8);
Joseph Chan29b619f2008-10-15 22:03:27 -0700839 }
840
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700841 writel(bg_color, engine + VIA_REG_CURSOR_BG);
842 writel(fg_color, engine + VIA_REG_CURSOR_FG);
Joseph Chan29b619f2008-10-15 22:03:27 -0700843 }
844
845 if (cursor->set & FB_CUR_SETSHAPE) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800846 struct {
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700847 u8 data[CURSOR_SIZE];
848 u32 bak[CURSOR_SIZE / 4];
Bruno Prémonte687d692009-01-04 13:11:54 -0800849 } *cr_data = kzalloc(sizeof(*cr_data), GFP_ATOMIC);
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700850 int size = ((cursor->image.width + 7) >> 3) *
851 cursor->image.height;
Joseph Chan29b619f2008-10-15 22:03:27 -0700852
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700853 if (!cr_data)
854 return -ENOMEM;
Bruno Prémonte687d692009-01-04 13:11:54 -0800855
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700856 if (cur_size == 32) {
857 for (i = 0; i < (CURSOR_SIZE / 4); i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800858 cr_data->bak[i] = 0x0;
859 cr_data->bak[i + 1] = 0xFFFFFFFF;
Joseph Chan29b619f2008-10-15 22:03:27 -0700860 i += 1;
861 }
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700862 } else {
863 for (i = 0; i < (CURSOR_SIZE / 4); i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800864 cr_data->bak[i] = 0x0;
865 cr_data->bak[i + 1] = 0x0;
866 cr_data->bak[i + 2] = 0xFFFFFFFF;
867 cr_data->bak[i + 3] = 0xFFFFFFFF;
Joseph Chan29b619f2008-10-15 22:03:27 -0700868 i += 3;
869 }
870 }
871
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700872 switch (cursor->rop) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700873 case ROP_XOR:
874 for (i = 0; i < size; i++)
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700875 cr_data->data[i] = cursor->mask[i];
Joseph Chan29b619f2008-10-15 22:03:27 -0700876 break;
877 case ROP_COPY:
878
879 for (i = 0; i < size; i++)
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700880 cr_data->data[i] = cursor->mask[i];
Joseph Chan29b619f2008-10-15 22:03:27 -0700881 break;
882 default:
883 break;
884 }
885
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700886 if (cur_size == 32) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700887 for (i = 0; i < size; i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800888 cr_data->bak[j] = (u32) cr_data->data[i];
889 cr_data->bak[j + 1] = ~cr_data->bak[j];
Joseph Chan29b619f2008-10-15 22:03:27 -0700890 j += 2;
891 }
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700892 } else {
Joseph Chan29b619f2008-10-15 22:03:27 -0700893 for (i = 0; i < size; i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800894 cr_data->bak[j] = (u32) cr_data->data[i];
895 cr_data->bak[j + 1] = 0x0;
896 cr_data->bak[j + 2] = ~cr_data->bak[j];
897 cr_data->bak[j + 3] = ~cr_data->bak[j + 1];
Joseph Chan29b619f2008-10-15 22:03:27 -0700898 j += 4;
899 }
900 }
901
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700902 memcpy_toio(viafbinfo->screen_base + viapar->shared->
903 cursor_vram_addr, cr_data->bak, CURSOR_SIZE);
Bruno Prémonte687d692009-01-04 13:11:54 -0800904 kfree(cr_data);
Joseph Chan29b619f2008-10-15 22:03:27 -0700905 }
906
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700907 if (cursor->enable)
Joseph Chan29b619f2008-10-15 22:03:27 -0700908 viafb_show_hw_cursor(info, HW_Cursor_ON);
909
910 return 0;
911}
912
913static int viafb_sync(struct fb_info *info)
914{
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700915 if (!(info->flags & FBINFO_HWACCEL_DISABLED))
916 viafb_wait_engine_idle(info);
Joseph Chan29b619f2008-10-15 22:03:27 -0700917 return 0;
918}
919
Joseph Chan29b619f2008-10-15 22:03:27 -0700920static void check_available_device_to_enable(int device_id)
921{
922 int device_num = 0;
923
924 /* Initialize: */
925 viafb_CRT_ON = STATE_OFF;
926 viafb_DVI_ON = STATE_OFF;
927 viafb_LCD_ON = STATE_OFF;
928 viafb_LCD2_ON = STATE_OFF;
929 viafb_DeviceStatus = None_Device;
930
931 if ((device_id & CRT_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
932 viafb_CRT_ON = STATE_ON;
933 device_num++;
934 viafb_DeviceStatus |= CRT_Device;
935 }
936
937 if ((device_id & DVI_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
938 viafb_DVI_ON = STATE_ON;
939 device_num++;
940 viafb_DeviceStatus |= DVI_Device;
941 }
942
943 if ((device_id & LCD_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
944 viafb_LCD_ON = STATE_ON;
945 device_num++;
946 viafb_DeviceStatus |= LCD_Device;
947 }
948
949 if ((device_id & LCD2_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
950 viafb_LCD2_ON = STATE_ON;
951 device_num++;
952 viafb_DeviceStatus |= LCD2_Device;
953 }
954
955 if (viafb_DeviceStatus == None_Device) {
956 /* Use CRT as default active device: */
957 viafb_CRT_ON = STATE_ON;
958 viafb_DeviceStatus = CRT_Device;
959 }
960 DEBUG_MSG(KERN_INFO "Device Status:%x", viafb_DeviceStatus);
961}
962
963static void viafb_set_device(struct device_t active_dev)
964{
965 /* Check available device to enable: */
966 int device_id = None_Device;
967 if (active_dev.crt)
968 device_id |= CRT_Device;
969 if (active_dev.dvi)
970 device_id |= DVI_Device;
971 if (active_dev.lcd)
972 device_id |= LCD_Device;
973
974 check_available_device_to_enable(device_id);
975
976 /* Check property of LCD: */
977 if (viafb_LCD_ON) {
978 if (active_dev.lcd_dsp_cent) {
979 viaparinfo->lvds_setting_info->display_method =
980 viafb_lcd_dsp_method = LCD_CENTERING;
981 } else {
982 viaparinfo->lvds_setting_info->display_method =
983 viafb_lcd_dsp_method = LCD_EXPANDSION;
984 }
985
986 if (active_dev.lcd_mode == LCD_SPWG) {
987 viaparinfo->lvds_setting_info->lcd_mode =
988 viafb_lcd_mode = LCD_SPWG;
989 } else {
990 viaparinfo->lvds_setting_info->lcd_mode =
991 viafb_lcd_mode = LCD_OPENLDI;
992 }
993
994 if (active_dev.lcd_panel_id <= LCD_PANEL_ID_MAXIMUM) {
995 viafb_lcd_panel_id = active_dev.lcd_panel_id;
996 viafb_init_lcd_size();
997 }
998 }
999
1000 /* Check property of mode: */
1001 if (!active_dev.xres1)
1002 viafb_second_xres = 640;
1003 else
1004 viafb_second_xres = active_dev.xres1;
1005 if (!active_dev.yres1)
1006 viafb_second_yres = 480;
1007 else
1008 viafb_second_yres = active_dev.yres1;
1009 if (active_dev.bpp != 0)
1010 viafb_bpp = active_dev.bpp;
1011 if (active_dev.bpp1 != 0)
1012 viafb_bpp1 = active_dev.bpp1;
1013 if (active_dev.refresh != 0)
1014 viafb_refresh = active_dev.refresh;
1015 if (active_dev.refresh1 != 0)
1016 viafb_refresh1 = active_dev.refresh1;
1017 if ((active_dev.samm == STATE_OFF) || (active_dev.samm == STATE_ON))
1018 viafb_SAMM_ON = active_dev.samm;
1019 viafb_primary_dev = active_dev.primary_dev;
1020
Florian Tobias Schandinat09cf1182009-09-22 16:47:14 -07001021 viafb_set_primary_address(0);
1022 viafb_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0);
Joseph Chan29b619f2008-10-15 22:03:27 -07001023 viafb_set_iga_path();
1024}
1025
Joseph Chan29b619f2008-10-15 22:03:27 -07001026static int get_primary_device(void)
1027{
1028 int primary_device = 0;
1029 /* Rule: device on iga1 path are the primary device. */
1030 if (viafb_SAMM_ON) {
1031 if (viafb_CRT_ON) {
1032 if (viaparinfo->crt_setting_info->iga_path == IGA1) {
1033 DEBUG_MSG(KERN_INFO "CRT IGA Path:%d\n",
1034 viaparinfo->
1035 crt_setting_info->iga_path);
1036 primary_device = CRT_Device;
1037 }
1038 }
1039 if (viafb_DVI_ON) {
1040 if (viaparinfo->tmds_setting_info->iga_path == IGA1) {
1041 DEBUG_MSG(KERN_INFO "DVI IGA Path:%d\n",
1042 viaparinfo->
1043 tmds_setting_info->iga_path);
1044 primary_device = DVI_Device;
1045 }
1046 }
1047 if (viafb_LCD_ON) {
1048 if (viaparinfo->lvds_setting_info->iga_path == IGA1) {
1049 DEBUG_MSG(KERN_INFO "LCD IGA Path:%d\n",
1050 viaparinfo->
1051 lvds_setting_info->iga_path);
1052 primary_device = LCD_Device;
1053 }
1054 }
1055 if (viafb_LCD2_ON) {
1056 if (viaparinfo->lvds_setting_info2->iga_path == IGA1) {
1057 DEBUG_MSG(KERN_INFO "LCD2 IGA Path:%d\n",
1058 viaparinfo->
1059 lvds_setting_info2->iga_path);
1060 primary_device = LCD2_Device;
1061 }
1062 }
1063 }
1064 return primary_device;
1065}
1066
Joseph Chan29b619f2008-10-15 22:03:27 -07001067static void apply_second_mode_setting(struct fb_var_screeninfo
1068 *sec_var)
1069{
1070 u32 htotal, vtotal, long_refresh;
1071
1072 htotal = sec_var->xres + sec_var->left_margin +
1073 sec_var->right_margin + sec_var->hsync_len;
1074 vtotal = sec_var->yres + sec_var->upper_margin +
1075 sec_var->lower_margin + sec_var->vsync_len;
1076 if ((sec_var->xres_virtual * (sec_var->bits_per_pixel >> 3)) & 0x1F) {
1077 /*Is 32 bytes alignment? */
1078 /*32 pixel alignment */
1079 sec_var->xres_virtual = (sec_var->xres_virtual + 31) & ~31;
1080 }
1081
1082 htotal = sec_var->xres + sec_var->left_margin +
1083 sec_var->right_margin + sec_var->hsync_len;
1084 vtotal = sec_var->yres + sec_var->upper_margin +
1085 sec_var->lower_margin + sec_var->vsync_len;
1086 long_refresh = 1000000000UL / sec_var->pixclock * 1000;
1087 long_refresh /= (htotal * vtotal);
1088
1089 viafb_second_xres = sec_var->xres;
1090 viafb_second_yres = sec_var->yres;
1091 viafb_second_virtual_xres = sec_var->xres_virtual;
1092 viafb_second_virtual_yres = sec_var->yres_virtual;
1093 viafb_bpp1 = sec_var->bits_per_pixel;
1094 viafb_refresh1 = viafb_get_refresh(sec_var->xres, sec_var->yres,
1095 long_refresh);
1096}
1097
1098static int apply_device_setting(struct viafb_ioctl_setting setting_info,
1099 struct fb_info *info)
1100{
1101 int need_set_mode = 0;
1102 DEBUG_MSG(KERN_INFO "apply_device_setting\n");
1103
1104 if (setting_info.device_flag) {
1105 need_set_mode = 1;
1106 check_available_device_to_enable(setting_info.device_status);
1107 }
1108
1109 /* Unlock LCD's operation according to LCD flag
1110 and check if the setting value is valid. */
1111 /* If the value is valid, apply the new setting value to the device. */
1112 if (viafb_LCD_ON) {
1113 if (setting_info.lcd_operation_flag & OP_LCD_CENTERING) {
1114 need_set_mode = 1;
1115 if (setting_info.lcd_attributes.display_center) {
1116 /* Centering */
1117 viaparinfo->lvds_setting_info->display_method =
1118 LCD_CENTERING;
1119 viafb_lcd_dsp_method = LCD_CENTERING;
1120 viaparinfo->lvds_setting_info2->display_method =
1121 viafb_lcd_dsp_method = LCD_CENTERING;
1122 } else {
1123 /* expandsion */
1124 viaparinfo->lvds_setting_info->display_method =
1125 LCD_EXPANDSION;
1126 viafb_lcd_dsp_method = LCD_EXPANDSION;
1127 viaparinfo->lvds_setting_info2->display_method =
1128 LCD_EXPANDSION;
1129 viafb_lcd_dsp_method = LCD_EXPANDSION;
1130 }
1131 }
1132
1133 if (setting_info.lcd_operation_flag & OP_LCD_MODE) {
1134 need_set_mode = 1;
1135 if (setting_info.lcd_attributes.lcd_mode ==
1136 LCD_SPWG) {
1137 viaparinfo->lvds_setting_info->lcd_mode =
1138 viafb_lcd_mode = LCD_SPWG;
1139 } else {
1140 viaparinfo->lvds_setting_info->lcd_mode =
1141 viafb_lcd_mode = LCD_OPENLDI;
1142 }
1143 viaparinfo->lvds_setting_info2->lcd_mode =
1144 viaparinfo->lvds_setting_info->lcd_mode;
1145 }
1146
1147 if (setting_info.lcd_operation_flag & OP_LCD_PANEL_ID) {
1148 need_set_mode = 1;
1149 if (setting_info.lcd_attributes.panel_id <=
1150 LCD_PANEL_ID_MAXIMUM) {
1151 viafb_lcd_panel_id =
1152 setting_info.lcd_attributes.panel_id;
1153 viafb_init_lcd_size();
1154 }
1155 }
1156 }
1157
1158 if (0 != (setting_info.samm_status & OP_SAMM)) {
1159 setting_info.samm_status =
1160 setting_info.samm_status & (~OP_SAMM);
1161 if (setting_info.samm_status == 0
1162 || setting_info.samm_status == 1) {
1163 viafb_SAMM_ON = setting_info.samm_status;
1164
1165 if (viafb_SAMM_ON)
1166 viafb_primary_dev = setting_info.primary_device;
1167
Florian Tobias Schandinat09cf1182009-09-22 16:47:14 -07001168 viafb_set_primary_address(0);
1169 viafb_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0);
Joseph Chan29b619f2008-10-15 22:03:27 -07001170 viafb_set_iga_path();
1171 }
1172 need_set_mode = 1;
1173 }
1174
Joseph Chan29b619f2008-10-15 22:03:27 -07001175 if (!need_set_mode) {
1176 ;
1177 } else {
1178 viafb_set_iga_path();
1179 viafb_set_par(info);
1180 }
1181 return true;
1182}
1183
1184static void retrieve_device_setting(struct viafb_ioctl_setting
1185 *setting_info)
1186{
1187
1188 /* get device status */
1189 if (viafb_CRT_ON == 1)
1190 setting_info->device_status = CRT_Device;
1191 if (viafb_DVI_ON == 1)
1192 setting_info->device_status |= DVI_Device;
1193 if (viafb_LCD_ON == 1)
1194 setting_info->device_status |= LCD_Device;
1195 if (viafb_LCD2_ON == 1)
1196 setting_info->device_status |= LCD2_Device;
Joseph Chan29b619f2008-10-15 22:03:27 -07001197
1198 setting_info->samm_status = viafb_SAMM_ON;
1199 setting_info->primary_device = get_primary_device();
1200
1201 setting_info->first_dev_bpp = viafb_bpp;
1202 setting_info->second_dev_bpp = viafb_bpp1;
1203
1204 setting_info->first_dev_refresh = viafb_refresh;
1205 setting_info->second_dev_refresh = viafb_refresh1;
1206
1207 setting_info->first_dev_hor_res = viafb_hotplug_Xres;
1208 setting_info->first_dev_ver_res = viafb_hotplug_Yres;
1209 setting_info->second_dev_hor_res = viafb_second_xres;
1210 setting_info->second_dev_ver_res = viafb_second_yres;
1211
1212 /* Get lcd attributes */
1213 setting_info->lcd_attributes.display_center = viafb_lcd_dsp_method;
1214 setting_info->lcd_attributes.panel_id = viafb_lcd_panel_id;
1215 setting_info->lcd_attributes.lcd_mode = viafb_lcd_mode;
1216}
1217
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001218static int parse_active_dev(void)
Joseph Chan29b619f2008-10-15 22:03:27 -07001219{
1220 viafb_CRT_ON = STATE_OFF;
1221 viafb_DVI_ON = STATE_OFF;
1222 viafb_LCD_ON = STATE_OFF;
1223 viafb_LCD2_ON = STATE_OFF;
1224 /* 1. Modify the active status of devices. */
1225 /* 2. Keep the order of devices, so we can set corresponding
1226 IGA path to devices in SAMM case. */
1227 /* Note: The previous of active_dev is primary device,
1228 and the following is secondary device. */
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001229 if (!viafb_active_dev) {
1230 viafb_CRT_ON = STATE_ON;
1231 viafb_SAMM_ON = STATE_OFF;
1232 } else if (!strcmp(viafb_active_dev, "CRT+DVI")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001233 /* CRT+DVI */
1234 viafb_CRT_ON = STATE_ON;
1235 viafb_DVI_ON = STATE_ON;
1236 viafb_primary_dev = CRT_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001237 } else if (!strcmp(viafb_active_dev, "DVI+CRT")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001238 /* DVI+CRT */
1239 viafb_CRT_ON = STATE_ON;
1240 viafb_DVI_ON = STATE_ON;
1241 viafb_primary_dev = DVI_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001242 } else if (!strcmp(viafb_active_dev, "CRT+LCD")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001243 /* CRT+LCD */
1244 viafb_CRT_ON = STATE_ON;
1245 viafb_LCD_ON = STATE_ON;
1246 viafb_primary_dev = CRT_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001247 } else if (!strcmp(viafb_active_dev, "LCD+CRT")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001248 /* LCD+CRT */
1249 viafb_CRT_ON = STATE_ON;
1250 viafb_LCD_ON = STATE_ON;
1251 viafb_primary_dev = LCD_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001252 } else if (!strcmp(viafb_active_dev, "DVI+LCD")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001253 /* DVI+LCD */
1254 viafb_DVI_ON = STATE_ON;
1255 viafb_LCD_ON = STATE_ON;
1256 viafb_primary_dev = DVI_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001257 } else if (!strcmp(viafb_active_dev, "LCD+DVI")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001258 /* LCD+DVI */
1259 viafb_DVI_ON = STATE_ON;
1260 viafb_LCD_ON = STATE_ON;
1261 viafb_primary_dev = LCD_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001262 } else if (!strcmp(viafb_active_dev, "LCD+LCD2")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001263 viafb_LCD_ON = STATE_ON;
1264 viafb_LCD2_ON = STATE_ON;
1265 viafb_primary_dev = LCD_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001266 } else if (!strcmp(viafb_active_dev, "LCD2+LCD")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001267 viafb_LCD_ON = STATE_ON;
1268 viafb_LCD2_ON = STATE_ON;
1269 viafb_primary_dev = LCD2_Device;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001270 } else if (!strcmp(viafb_active_dev, "CRT")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001271 /* CRT only */
1272 viafb_CRT_ON = STATE_ON;
1273 viafb_SAMM_ON = STATE_OFF;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001274 } else if (!strcmp(viafb_active_dev, "DVI")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001275 /* DVI only */
1276 viafb_DVI_ON = STATE_ON;
1277 viafb_SAMM_ON = STATE_OFF;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001278 } else if (!strcmp(viafb_active_dev, "LCD")) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001279 /* LCD only */
1280 viafb_LCD_ON = STATE_ON;
1281 viafb_SAMM_ON = STATE_OFF;
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001282 } else
1283 return -EINVAL;
1284
1285 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001286}
1287
Joseph Chan29b619f2008-10-15 22:03:27 -07001288static int parse_port(char *opt_str, int *output_interface)
1289{
1290 if (!strncmp(opt_str, "DVP0", 4))
1291 *output_interface = INTERFACE_DVP0;
1292 else if (!strncmp(opt_str, "DVP1", 4))
1293 *output_interface = INTERFACE_DVP1;
1294 else if (!strncmp(opt_str, "DFP_HIGHLOW", 11))
1295 *output_interface = INTERFACE_DFP;
1296 else if (!strncmp(opt_str, "DFP_HIGH", 8))
1297 *output_interface = INTERFACE_DFP_HIGH;
1298 else if (!strncmp(opt_str, "DFP_LOW", 7))
1299 *output_interface = INTERFACE_DFP_LOW;
1300 else
1301 *output_interface = INTERFACE_NONE;
1302 return 0;
1303}
1304
1305static void parse_lcd_port(void)
1306{
1307 parse_port(viafb_lcd_port, &viaparinfo->chip_info->lvds_chip_info.
1308 output_interface);
1309 /*Initialize to avoid unexpected behavior */
1310 viaparinfo->chip_info->lvds_chip_info2.output_interface =
1311 INTERFACE_NONE;
1312
1313 DEBUG_MSG(KERN_INFO "parse_lcd_port: viafb_lcd_port:%s,interface:%d\n",
1314 viafb_lcd_port, viaparinfo->chip_info->lvds_chip_info.
1315 output_interface);
1316}
1317
1318static void parse_dvi_port(void)
1319{
1320 parse_port(viafb_dvi_port, &viaparinfo->chip_info->tmds_chip_info.
1321 output_interface);
1322
1323 DEBUG_MSG(KERN_INFO "parse_dvi_port: viafb_dvi_port:%s,interface:%d\n",
1324 viafb_dvi_port, viaparinfo->chip_info->tmds_chip_info.
1325 output_interface);
1326}
1327
1328/*
1329 * The proc filesystem read/write function, a simple proc implement to
1330 * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
1331 * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2],
1332 * CR9B, SR65, CR97, CR99
1333 */
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001334static int viafb_dvp0_proc_show(struct seq_file *m, void *v)
Joseph Chan29b619f2008-10-15 22:03:27 -07001335{
Joseph Chan29b619f2008-10-15 22:03:27 -07001336 u8 dvp0_data_dri = 0, dvp0_clk_dri = 0, dvp0 = 0;
1337 dvp0_data_dri =
1338 (viafb_read_reg(VIASR, SR2A) & BIT5) >> 4 |
1339 (viafb_read_reg(VIASR, SR1B) & BIT1) >> 1;
1340 dvp0_clk_dri =
1341 (viafb_read_reg(VIASR, SR2A) & BIT4) >> 3 |
1342 (viafb_read_reg(VIASR, SR1E) & BIT2) >> 2;
1343 dvp0 = viafb_read_reg(VIACR, CR96) & 0x0f;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001344 seq_printf(m, "%x %x %x\n", dvp0, dvp0_data_dri, dvp0_clk_dri);
1345 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001346}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001347
1348static int viafb_dvp0_proc_open(struct inode *inode, struct file *file)
1349{
1350 return single_open(file, viafb_dvp0_proc_show, NULL);
1351}
1352
1353static ssize_t viafb_dvp0_proc_write(struct file *file,
1354 const char __user *buffer, size_t count, loff_t *pos)
Joseph Chan29b619f2008-10-15 22:03:27 -07001355{
1356 char buf[20], *value, *pbuf;
1357 u8 reg_val = 0;
1358 unsigned long length, i;
1359 if (count < 1)
1360 return -EINVAL;
1361 length = count > 20 ? 20 : count;
1362 if (copy_from_user(&buf[0], buffer, length))
1363 return -EFAULT;
1364 buf[length - 1] = '\0'; /*Ensure end string */
1365 pbuf = &buf[0];
1366 for (i = 0; i < 3; i++) {
1367 value = strsep(&pbuf, " ");
1368 if (value != NULL) {
1369 strict_strtoul(value, 0, (unsigned long *)&reg_val);
1370 DEBUG_MSG(KERN_INFO "DVP0:reg_val[%l]=:%x\n", i,
1371 reg_val);
1372 switch (i) {
1373 case 0:
1374 viafb_write_reg_mask(CR96, VIACR,
1375 reg_val, 0x0f);
1376 break;
1377 case 1:
1378 viafb_write_reg_mask(SR2A, VIASR,
1379 reg_val << 4, BIT5);
1380 viafb_write_reg_mask(SR1B, VIASR,
1381 reg_val << 1, BIT1);
1382 break;
1383 case 2:
1384 viafb_write_reg_mask(SR2A, VIASR,
1385 reg_val << 3, BIT4);
1386 viafb_write_reg_mask(SR1E, VIASR,
1387 reg_val << 2, BIT2);
1388 break;
1389 default:
1390 break;
1391 }
1392 } else {
1393 break;
1394 }
1395 }
1396 return count;
1397}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001398
1399static const struct file_operations viafb_dvp0_proc_fops = {
1400 .owner = THIS_MODULE,
1401 .open = viafb_dvp0_proc_open,
1402 .read = seq_read,
1403 .llseek = seq_lseek,
1404 .release = single_release,
1405 .write = viafb_dvp0_proc_write,
1406};
1407
1408static int viafb_dvp1_proc_show(struct seq_file *m, void *v)
Joseph Chan29b619f2008-10-15 22:03:27 -07001409{
Joseph Chan29b619f2008-10-15 22:03:27 -07001410 u8 dvp1 = 0, dvp1_data_dri = 0, dvp1_clk_dri = 0;
1411 dvp1 = viafb_read_reg(VIACR, CR9B) & 0x0f;
1412 dvp1_data_dri = (viafb_read_reg(VIASR, SR65) & 0x0c) >> 2;
1413 dvp1_clk_dri = viafb_read_reg(VIASR, SR65) & 0x03;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001414 seq_printf(m, "%x %x %x\n", dvp1, dvp1_data_dri, dvp1_clk_dri);
1415 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001416}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001417
1418static int viafb_dvp1_proc_open(struct inode *inode, struct file *file)
1419{
1420 return single_open(file, viafb_dvp1_proc_show, NULL);
1421}
1422
1423static ssize_t viafb_dvp1_proc_write(struct file *file,
1424 const char __user *buffer, size_t count, loff_t *pos)
Joseph Chan29b619f2008-10-15 22:03:27 -07001425{
1426 char buf[20], *value, *pbuf;
1427 u8 reg_val = 0;
1428 unsigned long length, i;
1429 if (count < 1)
1430 return -EINVAL;
1431 length = count > 20 ? 20 : count;
1432 if (copy_from_user(&buf[0], buffer, length))
1433 return -EFAULT;
1434 buf[length - 1] = '\0'; /*Ensure end string */
1435 pbuf = &buf[0];
1436 for (i = 0; i < 3; i++) {
1437 value = strsep(&pbuf, " ");
1438 if (value != NULL) {
1439 strict_strtoul(value, 0, (unsigned long *)&reg_val);
1440 switch (i) {
1441 case 0:
1442 viafb_write_reg_mask(CR9B, VIACR,
1443 reg_val, 0x0f);
1444 break;
1445 case 1:
1446 viafb_write_reg_mask(SR65, VIASR,
1447 reg_val << 2, 0x0c);
1448 break;
1449 case 2:
1450 viafb_write_reg_mask(SR65, VIASR,
1451 reg_val, 0x03);
1452 break;
1453 default:
1454 break;
1455 }
1456 } else {
1457 break;
1458 }
1459 }
1460 return count;
1461}
1462
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001463static const struct file_operations viafb_dvp1_proc_fops = {
1464 .owner = THIS_MODULE,
1465 .open = viafb_dvp1_proc_open,
1466 .read = seq_read,
1467 .llseek = seq_lseek,
1468 .release = single_release,
1469 .write = viafb_dvp1_proc_write,
1470};
1471
1472static int viafb_dfph_proc_show(struct seq_file *m, void *v)
Joseph Chan29b619f2008-10-15 22:03:27 -07001473{
Joseph Chan29b619f2008-10-15 22:03:27 -07001474 u8 dfp_high = 0;
1475 dfp_high = viafb_read_reg(VIACR, CR97) & 0x0f;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001476 seq_printf(m, "%x\n", dfp_high);
1477 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001478}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001479
1480static int viafb_dfph_proc_open(struct inode *inode, struct file *file)
1481{
1482 return single_open(file, viafb_dfph_proc_show, NULL);
1483}
1484
1485static ssize_t viafb_dfph_proc_write(struct file *file,
1486 const char __user *buffer, size_t count, loff_t *pos)
Joseph Chan29b619f2008-10-15 22:03:27 -07001487{
1488 char buf[20];
1489 u8 reg_val = 0;
1490 unsigned long length;
1491 if (count < 1)
1492 return -EINVAL;
1493 length = count > 20 ? 20 : count;
1494 if (copy_from_user(&buf[0], buffer, length))
1495 return -EFAULT;
1496 buf[length - 1] = '\0'; /*Ensure end string */
1497 strict_strtoul(&buf[0], 0, (unsigned long *)&reg_val);
1498 viafb_write_reg_mask(CR97, VIACR, reg_val, 0x0f);
1499 return count;
1500}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001501
1502static const struct file_operations viafb_dfph_proc_fops = {
1503 .owner = THIS_MODULE,
1504 .open = viafb_dfph_proc_open,
1505 .read = seq_read,
1506 .llseek = seq_lseek,
1507 .release = single_release,
1508 .write = viafb_dfph_proc_write,
1509};
1510
1511static int viafb_dfpl_proc_show(struct seq_file *m, void *v)
Joseph Chan29b619f2008-10-15 22:03:27 -07001512{
Joseph Chan29b619f2008-10-15 22:03:27 -07001513 u8 dfp_low = 0;
1514 dfp_low = viafb_read_reg(VIACR, CR99) & 0x0f;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001515 seq_printf(m, "%x\n", dfp_low);
1516 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001517}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001518
1519static int viafb_dfpl_proc_open(struct inode *inode, struct file *file)
1520{
1521 return single_open(file, viafb_dfpl_proc_show, NULL);
1522}
1523
1524static ssize_t viafb_dfpl_proc_write(struct file *file,
1525 const char __user *buffer, size_t count, loff_t *pos)
Joseph Chan29b619f2008-10-15 22:03:27 -07001526{
1527 char buf[20];
1528 u8 reg_val = 0;
1529 unsigned long length;
1530 if (count < 1)
1531 return -EINVAL;
1532 length = count > 20 ? 20 : count;
1533 if (copy_from_user(&buf[0], buffer, length))
1534 return -EFAULT;
1535 buf[length - 1] = '\0'; /*Ensure end string */
1536 strict_strtoul(&buf[0], 0, (unsigned long *)&reg_val);
1537 viafb_write_reg_mask(CR99, VIACR, reg_val, 0x0f);
1538 return count;
1539}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001540
1541static const struct file_operations viafb_dfpl_proc_fops = {
1542 .owner = THIS_MODULE,
1543 .open = viafb_dfpl_proc_open,
1544 .read = seq_read,
1545 .llseek = seq_lseek,
1546 .release = single_release,
1547 .write = viafb_dfpl_proc_write,
1548};
1549
1550static int viafb_vt1636_proc_show(struct seq_file *m, void *v)
Joseph Chan29b619f2008-10-15 22:03:27 -07001551{
Joseph Chan29b619f2008-10-15 22:03:27 -07001552 u8 vt1636_08 = 0, vt1636_09 = 0;
1553 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1554 case VT1636_LVDS:
1555 vt1636_08 =
1556 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
1557 &viaparinfo->chip_info->lvds_chip_info, 0x08) & 0x0f;
1558 vt1636_09 =
1559 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
1560 &viaparinfo->chip_info->lvds_chip_info, 0x09) & 0x1f;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001561 seq_printf(m, "%x %x\n", vt1636_08, vt1636_09);
Joseph Chan29b619f2008-10-15 22:03:27 -07001562 break;
1563 default:
1564 break;
1565 }
1566 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
1567 case VT1636_LVDS:
1568 vt1636_08 =
1569 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
1570 &viaparinfo->chip_info->lvds_chip_info2, 0x08) & 0x0f;
1571 vt1636_09 =
1572 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
1573 &viaparinfo->chip_info->lvds_chip_info2, 0x09) & 0x1f;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001574 seq_printf(m, " %x %x\n", vt1636_08, vt1636_09);
Joseph Chan29b619f2008-10-15 22:03:27 -07001575 break;
1576 default:
1577 break;
1578 }
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001579 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001580}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001581
1582static int viafb_vt1636_proc_open(struct inode *inode, struct file *file)
1583{
1584 return single_open(file, viafb_vt1636_proc_show, NULL);
1585}
1586
1587static ssize_t viafb_vt1636_proc_write(struct file *file,
1588 const char __user *buffer, size_t count, loff_t *pos)
Joseph Chan29b619f2008-10-15 22:03:27 -07001589{
1590 char buf[30], *value, *pbuf;
1591 struct IODATA reg_val;
1592 unsigned long length, i;
1593 if (count < 1)
1594 return -EINVAL;
1595 length = count > 30 ? 30 : count;
1596 if (copy_from_user(&buf[0], buffer, length))
1597 return -EFAULT;
1598 buf[length - 1] = '\0'; /*Ensure end string */
1599 pbuf = &buf[0];
1600 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1601 case VT1636_LVDS:
1602 for (i = 0; i < 2; i++) {
1603 value = strsep(&pbuf, " ");
1604 if (value != NULL) {
1605 strict_strtoul(value, 0,
1606 (unsigned long *)&reg_val.Data);
1607 switch (i) {
1608 case 0:
1609 reg_val.Index = 0x08;
1610 reg_val.Mask = 0x0f;
1611 viafb_gpio_i2c_write_mask_lvds
1612 (viaparinfo->lvds_setting_info,
1613 &viaparinfo->
1614 chip_info->lvds_chip_info,
1615 reg_val);
1616 break;
1617 case 1:
1618 reg_val.Index = 0x09;
1619 reg_val.Mask = 0x1f;
1620 viafb_gpio_i2c_write_mask_lvds
1621 (viaparinfo->lvds_setting_info,
1622 &viaparinfo->
1623 chip_info->lvds_chip_info,
1624 reg_val);
1625 break;
1626 default:
1627 break;
1628 }
1629 } else {
1630 break;
1631 }
1632 }
1633 break;
1634 default:
1635 break;
1636 }
1637 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
1638 case VT1636_LVDS:
1639 for (i = 0; i < 2; i++) {
1640 value = strsep(&pbuf, " ");
1641 if (value != NULL) {
1642 strict_strtoul(value, 0,
1643 (unsigned long *)&reg_val.Data);
1644 switch (i) {
1645 case 0:
1646 reg_val.Index = 0x08;
1647 reg_val.Mask = 0x0f;
1648 viafb_gpio_i2c_write_mask_lvds
1649 (viaparinfo->lvds_setting_info2,
1650 &viaparinfo->
1651 chip_info->lvds_chip_info2,
1652 reg_val);
1653 break;
1654 case 1:
1655 reg_val.Index = 0x09;
1656 reg_val.Mask = 0x1f;
1657 viafb_gpio_i2c_write_mask_lvds
1658 (viaparinfo->lvds_setting_info2,
1659 &viaparinfo->
1660 chip_info->lvds_chip_info2,
1661 reg_val);
1662 break;
1663 default:
1664 break;
1665 }
1666 } else {
1667 break;
1668 }
1669 }
1670 break;
1671 default:
1672 break;
1673 }
1674 return count;
1675}
1676
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001677static const struct file_operations viafb_vt1636_proc_fops = {
1678 .owner = THIS_MODULE,
1679 .open = viafb_vt1636_proc_open,
1680 .read = seq_read,
1681 .llseek = seq_lseek,
1682 .release = single_release,
1683 .write = viafb_vt1636_proc_write,
1684};
1685
Bruno Prémontc267fd72008-11-19 15:36:23 -08001686static void viafb_init_proc(struct proc_dir_entry **viafb_entry)
Joseph Chan29b619f2008-10-15 22:03:27 -07001687{
Bruno Prémontc267fd72008-11-19 15:36:23 -08001688 *viafb_entry = proc_mkdir("viafb", NULL);
Dan Carpenter8130b3b2009-12-15 16:46:36 -08001689 if (*viafb_entry) {
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001690 proc_create("dvp0", 0, *viafb_entry, &viafb_dvp0_proc_fops);
1691 proc_create("dvp1", 0, *viafb_entry, &viafb_dvp1_proc_fops);
1692 proc_create("dfph", 0, *viafb_entry, &viafb_dfph_proc_fops);
1693 proc_create("dfpl", 0, *viafb_entry, &viafb_dfpl_proc_fops);
Joseph Chan29b619f2008-10-15 22:03:27 -07001694 if (VT1636_LVDS == viaparinfo->chip_info->lvds_chip_info.
1695 lvds_chip_name || VT1636_LVDS ==
1696 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001697 proc_create("vt1636", 0, *viafb_entry, &viafb_vt1636_proc_fops);
Joseph Chan29b619f2008-10-15 22:03:27 -07001698 }
1699
1700 }
1701}
1702static void viafb_remove_proc(struct proc_dir_entry *viafb_entry)
1703{
1704 /* no problem if it was not registered */
1705 remove_proc_entry("dvp0", viafb_entry);/* parent dir */
1706 remove_proc_entry("dvp1", viafb_entry);
1707 remove_proc_entry("dfph", viafb_entry);
1708 remove_proc_entry("dfpl", viafb_entry);
1709 remove_proc_entry("vt1636", viafb_entry);
1710 remove_proc_entry("vt1625", viafb_entry);
Bruno Prémontc267fd72008-11-19 15:36:23 -08001711 remove_proc_entry("viafb", NULL);
Joseph Chan29b619f2008-10-15 22:03:27 -07001712}
1713
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001714static int parse_mode(const char *str, u32 *xres, u32 *yres)
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001715{
1716 char *ptr;
1717
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001718 if (!str) {
1719 *xres = 640;
1720 *yres = 480;
1721 return 0;
1722 }
1723
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001724 *xres = simple_strtoul(str, &ptr, 10);
1725 if (ptr[0] != 'x')
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001726 return -EINVAL;
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001727
1728 *yres = simple_strtoul(&ptr[1], &ptr, 10);
1729 if (ptr[0])
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001730 return -EINVAL;
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001731
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08001732 return 0;
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001733}
1734
Harald Welte2d280f72009-09-22 16:47:37 -07001735static int __devinit via_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;
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001741 u32 viafb_par_length;
Joseph Chan29b619f2008-10-15 22:03:27 -07001742
1743 DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n");
Florian Tobias Schandinatdba77f82010-03-10 15:21:37 -08001744 memset(&default_var, 0, sizeof(default_var));
Joseph Chan29b619f2008-10-15 22:03:27 -07001745 viafb_par_length = ALIGN(sizeof(struct viafb_par), BITS_PER_LONG/8);
Joseph Chan29b619f2008-10-15 22:03:27 -07001746
1747 /* Allocate fb_info and ***_par here, also including some other needed
1748 * variables
1749 */
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001750 viafbinfo = framebuffer_alloc(viafb_par_length +
Harald Weltedb8df7b2009-09-22 16:47:38 -07001751 ALIGN(sizeof(struct viafb_shared), BITS_PER_LONG/8),
1752 &pdev->dev);
Joseph Chan29b619f2008-10-15 22:03:27 -07001753 if (!viafbinfo) {
1754 printk(KERN_ERR"Could not allocate memory for viafb_info.\n");
1755 return -ENODEV;
1756 }
1757
1758 viaparinfo = (struct viafb_par *)viafbinfo->par;
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001759 viaparinfo->shared = viafbinfo->par + viafb_par_length;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -07001760 viaparinfo->vram_addr = 0;
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001761 viaparinfo->tmds_setting_info = &viaparinfo->shared->tmds_setting_info;
1762 viaparinfo->lvds_setting_info = &viaparinfo->shared->lvds_setting_info;
1763 viaparinfo->lvds_setting_info2 =
1764 &viaparinfo->shared->lvds_setting_info2;
1765 viaparinfo->crt_setting_info = &viaparinfo->shared->crt_setting_info;
1766 viaparinfo->chip_info = &viaparinfo->shared->chip_info;
Joseph Chan29b619f2008-10-15 22:03:27 -07001767
1768 if (viafb_dual_fb)
1769 viafb_SAMM_ON = 1;
Joseph Chan29b619f2008-10-15 22:03:27 -07001770 parse_lcd_port();
1771 parse_dvi_port();
1772
1773 /* for dual-fb must viafb_SAMM_ON=1 and viafb_dual_fb=1 */
1774 if (!viafb_SAMM_ON)
1775 viafb_dual_fb = 0;
1776
1777 /* Set up I2C bus stuff */
1778 viafb_create_i2c_bus(viaparinfo);
1779
Harald Welte2d280f72009-09-22 16:47:37 -07001780 viafb_init_chip_info(pdev, ent);
1781 viaparinfo->fbmem = pci_resource_start(pdev, 0);
1782 viaparinfo->memsize = viafb_get_fb_size_from_pci();
Joseph Chan29b619f2008-10-15 22:03:27 -07001783 viaparinfo->fbmem_free = viaparinfo->memsize;
1784 viaparinfo->fbmem_used = 0;
Florian Tobias Schandinatdb88e382009-09-22 16:47:20 -07001785 viafbinfo->screen_base = ioremap_nocache(viaparinfo->fbmem,
Joseph Chan29b619f2008-10-15 22:03:27 -07001786 viaparinfo->memsize);
Florian Tobias Schandinatdb88e382009-09-22 16:47:20 -07001787 if (!viafbinfo->screen_base) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001788 printk(KERN_INFO "ioremap failed\n");
Florian Tobias Schandinatbc6932b2009-09-22 16:47:15 -07001789 return -ENOMEM;
Joseph Chan29b619f2008-10-15 22:03:27 -07001790 }
1791
Harald Welte2d280f72009-09-22 16:47:37 -07001792 viafbinfo->fix.mmio_start = pci_resource_start(pdev, 1);
1793 viafbinfo->fix.mmio_len = pci_resource_len(pdev, 1);
Joseph Chan29b619f2008-10-15 22:03:27 -07001794 viafbinfo->node = 0;
1795 viafbinfo->fbops = &viafb_ops;
1796 viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
1797
1798 viafbinfo->pseudo_palette = pseudo_pal;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -07001799 if (viafb_accel && !viafb_init_engine(viafbinfo)) {
1800 viafbinfo->flags |= FBINFO_HWACCEL_COPYAREA |
1801 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_IMAGEBLIT;
1802 default_var.accel_flags = FB_ACCELF_TEXT;
1803 } else {
1804 viafbinfo->flags |= FBINFO_HWACCEL_DISABLED;
1805 default_var.accel_flags = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001806 }
1807
1808 if (viafb_second_size && (viafb_second_size < 8)) {
1809 viafb_second_offset = viaparinfo->fbmem_free -
1810 viafb_second_size * 1024 * 1024;
1811 } else {
1812 viafb_second_size = 8;
1813 viafb_second_offset = viaparinfo->fbmem_free -
1814 viafb_second_size * 1024 * 1024;
1815 }
1816
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001817 parse_mode(viafb_mode, &default_xres, &default_yres);
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -08001818 vmode_entry = viafb_get_mode(default_xres, default_yres);
Joseph Chan29b619f2008-10-15 22:03:27 -07001819 if (viafb_SAMM_ON == 1) {
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001820 parse_mode(viafb_mode1, &viafb_second_xres,
1821 &viafb_second_yres);
1822
Joseph Chan29b619f2008-10-15 22:03:27 -07001823 if (0 == viafb_second_virtual_xres) {
1824 switch (viafb_second_xres) {
1825 case 1400:
1826 viafb_second_virtual_xres = 1408;
1827 break;
1828 default:
1829 viafb_second_virtual_xres = viafb_second_xres;
1830 break;
1831 }
1832 }
1833 if (0 == viafb_second_virtual_yres)
1834 viafb_second_virtual_yres = viafb_second_yres;
1835 }
1836
Joseph Chan29b619f2008-10-15 22:03:27 -07001837 default_var.xres = default_xres;
1838 default_var.yres = default_yres;
1839 switch (default_xres) {
1840 case 1400:
1841 default_var.xres_virtual = 1408;
1842 break;
1843 default:
1844 default_var.xres_virtual = default_xres;
1845 break;
1846 }
1847 default_var.yres_virtual = default_yres;
1848 default_var.bits_per_pixel = viafb_bpp;
Joseph Chan29b619f2008-10-15 22:03:27 -07001849 default_var.pixclock =
1850 viafb_get_pixclock(default_xres, default_yres, viafb_refresh);
1851 default_var.left_margin = (default_xres >> 3) & 0xf8;
1852 default_var.right_margin = 32;
1853 default_var.upper_margin = 16;
1854 default_var.lower_margin = 4;
1855 default_var.hsync_len = default_var.left_margin;
1856 default_var.vsync_len = 4;
Florian Tobias Schandinat7cf60792010-03-10 15:21:31 -08001857 viafb_setup_fixinfo(&viafbinfo->fix, viaparinfo);
Florian Tobias Schandinat7cf60792010-03-10 15:21:31 -08001858 viafbinfo->var = default_var;
Joseph Chan29b619f2008-10-15 22:03:27 -07001859
1860 if (viafb_dual_fb) {
Harald Weltedb8df7b2009-09-22 16:47:38 -07001861 viafbinfo1 = framebuffer_alloc(viafb_par_length, &pdev->dev);
Joseph Chan29b619f2008-10-15 22:03:27 -07001862 if (!viafbinfo1) {
1863 printk(KERN_ERR
1864 "allocate the second framebuffer struct error\n");
1865 framebuffer_release(viafbinfo);
1866 return -ENOMEM;
1867 }
1868 viaparinfo1 = viafbinfo1->par;
1869 memcpy(viaparinfo1, viaparinfo, viafb_par_length);
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -07001870 viaparinfo1->vram_addr = viafb_second_offset;
Joseph Chan29b619f2008-10-15 22:03:27 -07001871 viaparinfo1->memsize = viaparinfo->memsize -
1872 viafb_second_offset;
1873 viaparinfo->memsize = viafb_second_offset;
Joseph Chan29b619f2008-10-15 22:03:27 -07001874 viaparinfo1->fbmem = viaparinfo->fbmem + viafb_second_offset;
1875
1876 viaparinfo1->fbmem_used = viaparinfo->fbmem_used;
1877 viaparinfo1->fbmem_free = viaparinfo1->memsize -
1878 viaparinfo1->fbmem_used;
1879 viaparinfo->fbmem_free = viaparinfo->memsize;
1880 viaparinfo->fbmem_used = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001881
Florian Tobias Schandinat09cf1182009-09-22 16:47:14 -07001882 viaparinfo->iga_path = IGA1;
1883 viaparinfo1->iga_path = IGA2;
Joseph Chan29b619f2008-10-15 22:03:27 -07001884 memcpy(viafbinfo1, viafbinfo, sizeof(struct fb_info));
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001885 viafbinfo1->par = viaparinfo1;
Joseph Chan29b619f2008-10-15 22:03:27 -07001886 viafbinfo1->screen_base = viafbinfo->screen_base +
1887 viafb_second_offset;
Joseph Chan29b619f2008-10-15 22:03:27 -07001888
1889 default_var.xres = viafb_second_xres;
1890 default_var.yres = viafb_second_yres;
1891 default_var.xres_virtual = viafb_second_virtual_xres;
1892 default_var.yres_virtual = viafb_second_virtual_yres;
Joseph Chan29b619f2008-10-15 22:03:27 -07001893 default_var.bits_per_pixel = viafb_bpp1;
1894 default_var.pixclock =
1895 viafb_get_pixclock(viafb_second_xres, viafb_second_yres,
1896 viafb_refresh);
1897 default_var.left_margin = (viafb_second_xres >> 3) & 0xf8;
1898 default_var.right_margin = 32;
1899 default_var.upper_margin = 16;
1900 default_var.lower_margin = 4;
1901 default_var.hsync_len = default_var.left_margin;
1902 default_var.vsync_len = 4;
1903
1904 viafb_setup_fixinfo(&viafbinfo1->fix, viaparinfo1);
1905 viafb_check_var(&default_var, viafbinfo1);
1906 viafbinfo1->var = default_var;
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -07001907 viafb_update_fix(viafbinfo1);
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -07001908 viaparinfo1->depth = fb_get_color_depth(&viafbinfo1->var,
1909 &viafbinfo1->fix);
Joseph Chan29b619f2008-10-15 22:03:27 -07001910 }
1911
Florian Tobias Schandinate17cea32010-03-10 15:21:41 -08001912 viafb_check_var(&viafbinfo->var, viafbinfo);
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -07001913 viafb_update_fix(viafbinfo);
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -07001914 viaparinfo->depth = fb_get_color_depth(&viafbinfo->var,
1915 &viafbinfo->fix);
Joseph Chan29b619f2008-10-15 22:03:27 -07001916 default_var.activate = FB_ACTIVATE_NOW;
1917 fb_alloc_cmap(&viafbinfo->cmap, 256, 0);
1918
1919 if (viafb_dual_fb && (viafb_primary_dev == LCD_Device)
1920 && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) {
1921 if (register_framebuffer(viafbinfo1) < 0)
1922 return -EINVAL;
1923 }
1924 if (register_framebuffer(viafbinfo) < 0)
1925 return -EINVAL;
1926
1927 if (viafb_dual_fb && ((viafb_primary_dev != LCD_Device)
1928 || (viaparinfo->chip_info->gfx_chip_name !=
1929 UNICHROME_CLE266))) {
1930 if (register_framebuffer(viafbinfo1) < 0)
1931 return -EINVAL;
1932 }
1933 DEBUG_MSG(KERN_INFO "fb%d: %s frame buffer device %dx%d-%dbpp\n",
1934 viafbinfo->node, viafbinfo->fix.id, default_var.xres,
1935 default_var.yres, default_var.bits_per_pixel);
1936
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001937 viafb_init_proc(&viaparinfo->shared->proc_entry);
Joseph Chan29b619f2008-10-15 22:03:27 -07001938 viafb_init_dac(IGA2);
1939 return 0;
1940}
1941
Harald Welte2d280f72009-09-22 16:47:37 -07001942static void __devexit via_pci_remove(struct pci_dev *pdev)
Joseph Chan29b619f2008-10-15 22:03:27 -07001943{
1944 DEBUG_MSG(KERN_INFO "via_pci_remove!\n");
1945 fb_dealloc_cmap(&viafbinfo->cmap);
1946 unregister_framebuffer(viafbinfo);
1947 if (viafb_dual_fb)
1948 unregister_framebuffer(viafbinfo1);
Florian Tobias Schandinatdb88e382009-09-22 16:47:20 -07001949 iounmap((void *)viafbinfo->screen_base);
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -07001950 iounmap(viaparinfo->shared->engine_mmio);
Joseph Chan29b619f2008-10-15 22:03:27 -07001951
1952 viafb_delete_i2c_buss(viaparinfo);
1953
1954 framebuffer_release(viafbinfo);
1955 if (viafb_dual_fb)
1956 framebuffer_release(viafbinfo1);
1957
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001958 viafb_remove_proc(viaparinfo->shared->proc_entry);
Joseph Chan29b619f2008-10-15 22:03:27 -07001959}
1960
1961#ifndef MODULE
1962static int __init viafb_setup(char *options)
1963{
1964 char *this_opt;
1965 DEBUG_MSG(KERN_INFO "viafb_setup!\n");
1966
1967 if (!options || !*options)
1968 return 0;
1969
1970 while ((this_opt = strsep(&options, ",")) != NULL) {
1971 if (!*this_opt)
1972 continue;
1973
1974 if (!strncmp(this_opt, "viafb_mode1=", 12))
1975 viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL);
1976 else if (!strncmp(this_opt, "viafb_mode=", 11))
1977 viafb_mode = kstrdup(this_opt + 11, GFP_KERNEL);
1978 else if (!strncmp(this_opt, "viafb_bpp1=", 11))
1979 strict_strtoul(this_opt + 11, 0,
1980 (unsigned long *)&viafb_bpp1);
1981 else if (!strncmp(this_opt, "viafb_bpp=", 10))
1982 strict_strtoul(this_opt + 10, 0,
1983 (unsigned long *)&viafb_bpp);
1984 else if (!strncmp(this_opt, "viafb_refresh1=", 15))
1985 strict_strtoul(this_opt + 15, 0,
1986 (unsigned long *)&viafb_refresh1);
1987 else if (!strncmp(this_opt, "viafb_refresh=", 14))
1988 strict_strtoul(this_opt + 14, 0,
1989 (unsigned long *)&viafb_refresh);
1990 else if (!strncmp(this_opt, "viafb_lcd_dsp_method=", 21))
1991 strict_strtoul(this_opt + 21, 0,
1992 (unsigned long *)&viafb_lcd_dsp_method);
1993 else if (!strncmp(this_opt, "viafb_lcd_panel_id=", 19))
1994 strict_strtoul(this_opt + 19, 0,
1995 (unsigned long *)&viafb_lcd_panel_id);
1996 else if (!strncmp(this_opt, "viafb_accel=", 12))
1997 strict_strtoul(this_opt + 12, 0,
1998 (unsigned long *)&viafb_accel);
1999 else if (!strncmp(this_opt, "viafb_SAMM_ON=", 14))
2000 strict_strtoul(this_opt + 14, 0,
2001 (unsigned long *)&viafb_SAMM_ON);
2002 else if (!strncmp(this_opt, "viafb_active_dev=", 17))
2003 viafb_active_dev = kstrdup(this_opt + 17, GFP_KERNEL);
2004 else if (!strncmp(this_opt,
2005 "viafb_display_hardware_layout=", 30))
2006 strict_strtoul(this_opt + 30, 0,
2007 (unsigned long *)&viafb_display_hardware_layout);
2008 else if (!strncmp(this_opt, "viafb_second_size=", 18))
2009 strict_strtoul(this_opt + 18, 0,
2010 (unsigned long *)&viafb_second_size);
2011 else if (!strncmp(this_opt,
2012 "viafb_platform_epia_dvi=", 24))
2013 strict_strtoul(this_opt + 24, 0,
2014 (unsigned long *)&viafb_platform_epia_dvi);
2015 else if (!strncmp(this_opt,
2016 "viafb_device_lcd_dualedge=", 26))
2017 strict_strtoul(this_opt + 26, 0,
2018 (unsigned long *)&viafb_device_lcd_dualedge);
2019 else if (!strncmp(this_opt, "viafb_bus_width=", 16))
2020 strict_strtoul(this_opt + 16, 0,
2021 (unsigned long *)&viafb_bus_width);
2022 else if (!strncmp(this_opt, "viafb_lcd_mode=", 15))
2023 strict_strtoul(this_opt + 15, 0,
2024 (unsigned long *)&viafb_lcd_mode);
Joseph Chan29b619f2008-10-15 22:03:27 -07002025 else if (!strncmp(this_opt, "viafb_lcd_port=", 15))
2026 viafb_lcd_port = kstrdup(this_opt + 15, GFP_KERNEL);
2027 else if (!strncmp(this_opt, "viafb_dvi_port=", 15))
2028 viafb_dvi_port = kstrdup(this_opt + 15, GFP_KERNEL);
2029 }
2030 return 0;
2031}
2032#endif
2033
Harald Welte2d280f72009-09-22 16:47:37 -07002034static struct pci_device_id viafb_pci_table[] __devinitdata = {
2035 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CLE266_DID),
2036 .driver_data = UNICHROME_CLE266 },
2037 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_PM800_DID),
2038 .driver_data = UNICHROME_PM800 },
2039 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K400_DID),
2040 .driver_data = UNICHROME_K400 },
2041 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K800_DID),
2042 .driver_data = UNICHROME_K800 },
2043 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_P4M890_DID),
2044 .driver_data = UNICHROME_CN700 },
2045 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K8M890_DID),
2046 .driver_data = UNICHROME_K8M890 },
2047 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CX700_DID),
2048 .driver_data = UNICHROME_CX700 },
2049 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_P4M900_DID),
2050 .driver_data = UNICHROME_P4M900 },
2051 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CN750_DID),
2052 .driver_data = UNICHROME_CN750 },
2053 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX800_DID),
2054 .driver_data = UNICHROME_VX800 },
2055 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX855_DID),
2056 .driver_data = UNICHROME_VX855 },
2057 { }
2058};
2059MODULE_DEVICE_TABLE(pci, viafb_pci_table);
2060
2061static struct pci_driver viafb_driver = {
2062 .name = "viafb",
2063 .id_table = viafb_pci_table,
2064 .probe = via_pci_probe,
2065 .remove = __devexit_p(via_pci_remove),
2066};
2067
Joseph Chan29b619f2008-10-15 22:03:27 -07002068static int __init viafb_init(void)
2069{
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08002070 u32 dummy;
Joseph Chan29b619f2008-10-15 22:03:27 -07002071#ifndef MODULE
2072 char *option = NULL;
2073 if (fb_get_options("viafb", &option))
2074 return -ENODEV;
2075 viafb_setup(option);
2076#endif
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08002077 if (parse_mode(viafb_mode, &dummy, &dummy)
2078 || parse_mode(viafb_mode1, &dummy, &dummy)
Florian Tobias Schandinate17cea32010-03-10 15:21:41 -08002079 || viafb_bpp < 0 || viafb_bpp > 32
2080 || viafb_bpp1 < 0 || viafb_bpp1 > 32
Florian Tobias Schandinatfe9aab82010-03-10 15:21:34 -08002081 || parse_active_dev())
2082 return -EINVAL;
2083
Joseph Chan29b619f2008-10-15 22:03:27 -07002084 printk(KERN_INFO
2085 "VIA Graphics Intergration Chipset framebuffer %d.%d initializing\n",
2086 VERSION_MAJOR, VERSION_MINOR);
Harald Welte2d280f72009-09-22 16:47:37 -07002087 return pci_register_driver(&viafb_driver);
Joseph Chan29b619f2008-10-15 22:03:27 -07002088}
2089
2090static void __exit viafb_exit(void)
2091{
2092 DEBUG_MSG(KERN_INFO "viafb_exit!\n");
Harald Welte2d280f72009-09-22 16:47:37 -07002093 pci_unregister_driver(&viafb_driver);
Joseph Chan29b619f2008-10-15 22:03:27 -07002094}
2095
2096static struct fb_ops viafb_ops = {
2097 .owner = THIS_MODULE,
2098 .fb_open = viafb_open,
2099 .fb_release = viafb_release,
2100 .fb_check_var = viafb_check_var,
2101 .fb_set_par = viafb_set_par,
2102 .fb_setcolreg = viafb_setcolreg,
2103 .fb_pan_display = viafb_pan_display,
2104 .fb_blank = viafb_blank,
2105 .fb_fillrect = viafb_fillrect,
2106 .fb_copyarea = viafb_copyarea,
2107 .fb_imageblit = viafb_imageblit,
2108 .fb_cursor = viafb_cursor,
2109 .fb_ioctl = viafb_ioctl,
2110 .fb_sync = viafb_sync,
Joseph Chan29b619f2008-10-15 22:03:27 -07002111};
2112
2113module_init(viafb_init);
2114module_exit(viafb_exit);
2115
2116#ifdef MODULE
Harald Welte93967be2009-09-22 16:47:32 -07002117module_param(viafb_mode, charp, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002118MODULE_PARM_DESC(viafb_mode, "Set resolution (default=640x480)");
2119
Harald Welte93967be2009-09-22 16:47:32 -07002120module_param(viafb_mode1, charp, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002121MODULE_PARM_DESC(viafb_mode1, "Set resolution (default=640x480)");
2122
Harald Welte93967be2009-09-22 16:47:32 -07002123module_param(viafb_bpp, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002124MODULE_PARM_DESC(viafb_bpp, "Set color depth (default=32bpp)");
2125
Harald Welte93967be2009-09-22 16:47:32 -07002126module_param(viafb_bpp1, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002127MODULE_PARM_DESC(viafb_bpp1, "Set color depth (default=32bpp)");
2128
Harald Welte93967be2009-09-22 16:47:32 -07002129module_param(viafb_refresh, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002130MODULE_PARM_DESC(viafb_refresh,
2131 "Set CRT viafb_refresh rate (default = 60)");
2132
Harald Welte93967be2009-09-22 16:47:32 -07002133module_param(viafb_refresh1, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002134MODULE_PARM_DESC(viafb_refresh1,
2135 "Set CRT refresh rate (default = 60)");
2136
Harald Welte93967be2009-09-22 16:47:32 -07002137module_param(viafb_lcd_panel_id, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002138MODULE_PARM_DESC(viafb_lcd_panel_id,
2139 "Set Flat Panel type(Default=1024x768)");
2140
Harald Welte93967be2009-09-22 16:47:32 -07002141module_param(viafb_lcd_dsp_method, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002142MODULE_PARM_DESC(viafb_lcd_dsp_method,
2143 "Set Flat Panel display scaling method.(Default=Expandsion)");
2144
Harald Welte93967be2009-09-22 16:47:32 -07002145module_param(viafb_SAMM_ON, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002146MODULE_PARM_DESC(viafb_SAMM_ON,
2147 "Turn on/off flag of SAMM(Default=OFF)");
2148
Harald Welte93967be2009-09-22 16:47:32 -07002149module_param(viafb_accel, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002150MODULE_PARM_DESC(viafb_accel,
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -07002151 "Set 2D Hardware Acceleration: 0 = OFF, 1 = ON (default)");
Joseph Chan29b619f2008-10-15 22:03:27 -07002152
Harald Welte93967be2009-09-22 16:47:32 -07002153module_param(viafb_active_dev, charp, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002154MODULE_PARM_DESC(viafb_active_dev, "Specify active devices.");
2155
Harald Welte93967be2009-09-22 16:47:32 -07002156module_param(viafb_display_hardware_layout, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002157MODULE_PARM_DESC(viafb_display_hardware_layout,
2158 "Display Hardware Layout (LCD Only, DVI Only...,etc)");
2159
Harald Welte93967be2009-09-22 16:47:32 -07002160module_param(viafb_second_size, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002161MODULE_PARM_DESC(viafb_second_size,
2162 "Set secondary device memory size");
2163
Harald Welte93967be2009-09-22 16:47:32 -07002164module_param(viafb_dual_fb, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002165MODULE_PARM_DESC(viafb_dual_fb,
2166 "Turn on/off flag of dual framebuffer devices.(Default = OFF)");
2167
Harald Welte93967be2009-09-22 16:47:32 -07002168module_param(viafb_platform_epia_dvi, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002169MODULE_PARM_DESC(viafb_platform_epia_dvi,
2170 "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)");
2171
Harald Welte93967be2009-09-22 16:47:32 -07002172module_param(viafb_device_lcd_dualedge, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002173MODULE_PARM_DESC(viafb_device_lcd_dualedge,
2174 "Turn on/off flag of dual edge panel.(Default = OFF)");
2175
Harald Welte93967be2009-09-22 16:47:32 -07002176module_param(viafb_bus_width, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002177MODULE_PARM_DESC(viafb_bus_width,
2178 "Set bus width of panel.(Default = 12)");
2179
Harald Welte93967be2009-09-22 16:47:32 -07002180module_param(viafb_lcd_mode, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002181MODULE_PARM_DESC(viafb_lcd_mode,
2182 "Set Flat Panel mode(Default=OPENLDI)");
2183
Harald Welte93967be2009-09-22 16:47:32 -07002184module_param(viafb_lcd_port, charp, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002185MODULE_PARM_DESC(viafb_lcd_port, "Specify LCD output port.");
2186
Harald Welte93967be2009-09-22 16:47:32 -07002187module_param(viafb_dvi_port, charp, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002188MODULE_PARM_DESC(viafb_dvi_port, "Specify DVI output port.");
2189
2190MODULE_LICENSE("GPL");
2191#endif