blob: 98e3bd11ae17f6ba32c7cf9933051371e7b042c3 [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>
Harald Welte93967be2009-09-22 16:47:32 -070024#include <linux/stat.h>
Joseph Chan29b619f2008-10-15 22:03:27 -070025#define _MASTER_FILE
26
27#include "global.h"
28
Joseph Chan29b619f2008-10-15 22:03:27 -070029static struct fb_var_screeninfo default_var;
30static char *viafb_name = "Via";
31static u32 pseudo_pal[17];
32
33/* video mode */
34static char *viafb_mode = "640x480";
35static char *viafb_mode1 = "640x480";
Joseph Chan29b619f2008-10-15 22:03:27 -070036
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -070037static int viafb_accel = 1;
38
Joseph Chan29b619f2008-10-15 22:03:27 -070039/* Added for specifying active devices.*/
40char *viafb_active_dev = "";
41
Joseph Chan29b619f2008-10-15 22:03:27 -070042/*Added for specify lcd output port*/
43char *viafb_lcd_port = "";
44char *viafb_dvi_port = "";
45
46static void viafb_set_device(struct device_t active_dev);
47static int apply_device_setting(struct viafb_ioctl_setting setting_info,
48 struct fb_info *info);
49static void apply_second_mode_setting(struct fb_var_screeninfo
50 *sec_var);
51static void retrieve_device_setting(struct viafb_ioctl_setting
52 *setting_info);
Joseph Chan29b619f2008-10-15 22:03:27 -070053
Joseph Chan29b619f2008-10-15 22:03:27 -070054static struct fb_ops viafb_ops;
55
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -070056
57static void viafb_update_fix(struct fb_info *info)
Joseph Chan29b619f2008-10-15 22:03:27 -070058{
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -070059 u32 bpp = info->var.bits_per_pixel;
Joseph Chan29b619f2008-10-15 22:03:27 -070060
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -070061 info->fix.visual =
62 bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
63 info->fix.line_length =
64 ((info->var.xres_virtual + 7) & ~7) * bpp / 8;
Joseph Chan29b619f2008-10-15 22:03:27 -070065}
66
Joseph Chan29b619f2008-10-15 22:03:27 -070067static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix,
68 struct viafb_par *viaparinfo)
69{
70 memset(fix, 0, sizeof(struct fb_fix_screeninfo));
71 strcpy(fix->id, viafb_name);
72
73 fix->smem_start = viaparinfo->fbmem;
74 fix->smem_len = viaparinfo->fbmem_free;
Joseph Chan29b619f2008-10-15 22:03:27 -070075
76 fix->type = FB_TYPE_PACKED_PIXELS;
77 fix->type_aux = 0;
78
79 fix->xpanstep = fix->ywrapstep = 0;
80 fix->ypanstep = 1;
81
82 /* Just tell the accel name */
83 viafbinfo->fix.accel = FB_ACCEL_VIA_UNICHROME;
84}
85static int viafb_open(struct fb_info *info, int user)
86{
87 DEBUG_MSG(KERN_INFO "viafb_open!\n");
88 return 0;
89}
90
91static int viafb_release(struct fb_info *info, int user)
92{
93 DEBUG_MSG(KERN_INFO "viafb_release!\n");
94 return 0;
95}
96
Joseph Chan29b619f2008-10-15 22:03:27 -070097static int viafb_check_var(struct fb_var_screeninfo *var,
98 struct fb_info *info)
99{
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800100 int htotal, vtotal;
101 struct VideoModeTable *vmode_entry;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700102 struct viafb_par *ppar = info->par;
Joseph Chan29b619f2008-10-15 22:03:27 -0700103 u32 long_refresh;
Joseph Chan29b619f2008-10-15 22:03:27 -0700104
105 DEBUG_MSG(KERN_INFO "viafb_check_var!\n");
106 /* Sanity check */
107 /* HW neither support interlacte nor double-scaned mode */
108 if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE)
109 return -EINVAL;
110
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800111 vmode_entry = viafb_get_mode(var->xres, var->yres);
112 if (!vmode_entry) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700113 DEBUG_MSG(KERN_INFO
114 "viafb: Mode %dx%dx%d not supported!!\n",
115 var->xres, var->yres, var->bits_per_pixel);
116 return -EINVAL;
117 }
118
119 if (24 == var->bits_per_pixel)
120 var->bits_per_pixel = 32;
121
122 if (var->bits_per_pixel != 8 && var->bits_per_pixel != 16 &&
123 var->bits_per_pixel != 32)
124 return -EINVAL;
125
126 if ((var->xres_virtual * (var->bits_per_pixel >> 3)) & 0x1F)
127 /*32 pixel alignment */
128 var->xres_virtual = (var->xres_virtual + 31) & ~31;
129 if (var->xres_virtual * var->yres_virtual * var->bits_per_pixel / 8 >
130 ppar->memsize)
131 return -EINVAL;
132
133 /* Based on var passed in to calculate the refresh,
134 * because our driver use some modes special.
135 */
136 htotal = var->xres + var->left_margin +
137 var->right_margin + var->hsync_len;
138 vtotal = var->yres + var->upper_margin +
139 var->lower_margin + var->vsync_len;
140 long_refresh = 1000000000UL / var->pixclock * 1000;
141 long_refresh /= (htotal * vtotal);
142
143 viafb_refresh = viafb_get_refresh(var->xres, var->yres, long_refresh);
144
145 /* Adjust var according to our driver's own table */
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800146 viafb_fill_var_timing_info(var, viafb_refresh, vmode_entry);
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700147 if (info->var.accel_flags & FB_ACCELF_TEXT &&
148 !ppar->shared->engine_mmio)
149 info->var.accel_flags = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700150
Joseph Chan29b619f2008-10-15 22:03:27 -0700151 return 0;
152}
153
154static int viafb_set_par(struct fb_info *info)
155{
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700156 struct viafb_par *viapar = info->par;
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800157 struct VideoModeTable *vmode_entry, *vmode_entry1 = NULL;
Joseph Chan29b619f2008-10-15 22:03:27 -0700158 DEBUG_MSG(KERN_INFO "viafb_set_par!\n");
159
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700160 viapar->depth = fb_get_color_depth(&info->var, &info->fix);
Joseph Chan29b619f2008-10-15 22:03:27 -0700161 viafb_update_device_setting(info->var.xres, info->var.yres,
162 info->var.bits_per_pixel, viafb_refresh, 0);
163
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800164 vmode_entry = viafb_get_mode(info->var.xres, info->var.yres);
Joseph Chan29b619f2008-10-15 22:03:27 -0700165 if (viafb_SAMM_ON == 1) {
166 DEBUG_MSG(KERN_INFO
167 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
168 viafb_second_xres, viafb_second_yres, viafb_bpp1);
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800169 vmode_entry1 = viafb_get_mode(viafb_second_xres,
Florian Tobias Schandinat52159442009-08-06 15:07:34 -0700170 viafb_second_yres);
Joseph Chan29b619f2008-10-15 22:03:27 -0700171
172 viafb_update_device_setting(viafb_second_xres,
173 viafb_second_yres, viafb_bpp1, viafb_refresh1, 1);
174 }
175
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800176 if (vmode_entry) {
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -0700177 viafb_update_fix(info);
Joseph Chan29b619f2008-10-15 22:03:27 -0700178 viafb_bpp = info->var.bits_per_pixel;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700179 if (info->var.accel_flags & FB_ACCELF_TEXT)
180 info->flags &= ~FBINFO_HWACCEL_DISABLED;
181 else
182 info->flags |= FBINFO_HWACCEL_DISABLED;
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -0800183 viafb_setmode(vmode_entry, info->var.bits_per_pixel,
184 vmode_entry1, viafb_bpp1);
Joseph Chan29b619f2008-10-15 22:03:27 -0700185 }
186
187 return 0;
188}
189
190/* Set one color register */
191static int viafb_setcolreg(unsigned regno, unsigned red, unsigned green,
192unsigned blue, unsigned transp, struct fb_info *info)
193{
194 u8 sr1a, sr1b, cr67, cr6a, rev = 0, shift = 10;
195 unsigned cmap_entries = (info->var.bits_per_pixel == 8) ? 256 : 16;
196 DEBUG_MSG(KERN_INFO "viafb_setcolreg!\n");
197 if (regno >= cmap_entries)
198 return 1;
199 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name) {
200 /*
201 * Read PCI bus 0,dev 0,function 0,index 0xF6 to get chip rev.
202 */
203 outl(0x80000000 | (0xf6 & ~3), (unsigned long)0xCF8);
204 rev = (inl((unsigned long)0xCFC) >> ((0xf6 & 3) * 8)) & 0xff;
205 }
206 switch (info->var.bits_per_pixel) {
207 case 8:
208 outb(0x1A, 0x3C4);
209 sr1a = inb(0x3C5);
210 outb(0x1B, 0x3C4);
211 sr1b = inb(0x3C5);
212 outb(0x67, 0x3D4);
213 cr67 = inb(0x3D5);
214 outb(0x6A, 0x3D4);
215 cr6a = inb(0x3D5);
216
217 /* Map the 3C6/7/8/9 to the IGA2 */
218 outb(0x1A, 0x3C4);
219 outb(sr1a | 0x01, 0x3C5);
220 /* Second Display Engine colck always on */
221 outb(0x1B, 0x3C4);
222 outb(sr1b | 0x80, 0x3C5);
223 /* Second Display Color Depth 8 */
224 outb(0x67, 0x3D4);
225 outb(cr67 & 0x3F, 0x3D5);
226 outb(0x6A, 0x3D4);
227 /* Second Display Channel Reset CR6A[6]) */
228 outb(cr6a & 0xBF, 0x3D5);
229 /* Second Display Channel Enable CR6A[7] */
230 outb(cr6a | 0x80, 0x3D5);
231 /* Second Display Channel stop reset) */
232 outb(cr6a | 0x40, 0x3D5);
233
234 /* Bit mask of palette */
235 outb(0xFF, 0x3c6);
236 /* Write one register of IGA2 */
237 outb(regno, 0x3C8);
238 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name &&
239 rev >= 15) {
240 shift = 8;
241 viafb_write_reg_mask(CR6A, VIACR, BIT5, BIT5);
242 viafb_write_reg_mask(SR15, VIASR, BIT7, BIT7);
243 } else {
244 shift = 10;
245 viafb_write_reg_mask(CR6A, VIACR, 0, BIT5);
246 viafb_write_reg_mask(SR15, VIASR, 0, BIT7);
247 }
248 outb(red >> shift, 0x3C9);
249 outb(green >> shift, 0x3C9);
250 outb(blue >> shift, 0x3C9);
251
252 /* Map the 3C6/7/8/9 to the IGA1 */
253 outb(0x1A, 0x3C4);
254 outb(sr1a & 0xFE, 0x3C5);
255 /* Bit mask of palette */
256 outb(0xFF, 0x3c6);
257 /* Write one register of IGA1 */
258 outb(regno, 0x3C8);
259 outb(red >> shift, 0x3C9);
260 outb(green >> shift, 0x3C9);
261 outb(blue >> shift, 0x3C9);
262
263 outb(0x1A, 0x3C4);
264 outb(sr1a, 0x3C5);
265 outb(0x1B, 0x3C4);
266 outb(sr1b, 0x3C5);
267 outb(0x67, 0x3D4);
268 outb(cr67, 0x3D5);
269 outb(0x6A, 0x3D4);
270 outb(cr6a, 0x3D5);
271 break;
272 case 16:
273 ((u32 *) info->pseudo_palette)[regno] = (red & 0xF800) |
274 ((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11);
275 break;
276 case 32:
277 ((u32 *) info->pseudo_palette)[regno] =
278 ((transp & 0xFF00) << 16) |
279 ((red & 0xFF00) << 8) |
280 ((green & 0xFF00)) | ((blue & 0xFF00) >> 8);
281 break;
282 }
283
284 return 0;
285
286}
287
288/*CALLED BY: fb_set_cmap */
289/* fb_set_var, pass 256 colors */
290/*CALLED BY: fb_set_cmap */
291/* fbcon_set_palette, pass 16 colors */
292static int viafb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
293{
294 u32 len = cmap->len;
295 u32 i;
296 u16 *pred = cmap->red;
297 u16 *pgreen = cmap->green;
298 u16 *pblue = cmap->blue;
299 u16 *ptransp = cmap->transp;
300 u8 sr1a, sr1b, cr67, cr6a, rev = 0, shift = 10;
301 if (len > 256)
302 return 1;
303 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name) {
304 /*
305 * Read PCI bus 0, dev 0, function 0, index 0xF6 to get chip
306 * rev.
307 */
308 outl(0x80000000 | (0xf6 & ~3), (unsigned long)0xCF8);
309 rev = (inl((unsigned long)0xCFC) >> ((0xf6 & 3) * 8)) & 0xff;
310 }
311 switch (info->var.bits_per_pixel) {
312 case 8:
313 outb(0x1A, 0x3C4);
314 sr1a = inb(0x3C5);
315 outb(0x1B, 0x3C4);
316 sr1b = inb(0x3C5);
317 outb(0x67, 0x3D4);
318 cr67 = inb(0x3D5);
319 outb(0x6A, 0x3D4);
320 cr6a = inb(0x3D5);
321 /* Map the 3C6/7/8/9 to the IGA2 */
322 outb(0x1A, 0x3C4);
323 outb(sr1a | 0x01, 0x3C5);
324 outb(0x1B, 0x3C4);
325 /* Second Display Engine colck always on */
326 outb(sr1b | 0x80, 0x3C5);
327 outb(0x67, 0x3D4);
328 /* Second Display Color Depth 8 */
329 outb(cr67 & 0x3F, 0x3D5);
330 outb(0x6A, 0x3D4);
331 /* Second Display Channel Reset CR6A[6]) */
332 outb(cr6a & 0xBF, 0x3D5);
333 /* Second Display Channel Enable CR6A[7] */
334 outb(cr6a | 0x80, 0x3D5);
335 /* Second Display Channel stop reset) */
336 outb(cr6a | 0xC0, 0x3D5);
337
338 /* Bit mask of palette */
339 outb(0xFF, 0x3c6);
340 outb(0x00, 0x3C8);
341 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name &&
342 rev >= 15) {
343 shift = 8;
344 viafb_write_reg_mask(CR6A, VIACR, BIT5, BIT5);
345 viafb_write_reg_mask(SR15, VIASR, BIT7, BIT7);
346 } else {
347 shift = 10;
348 viafb_write_reg_mask(CR6A, VIACR, 0, BIT5);
349 viafb_write_reg_mask(SR15, VIASR, 0, BIT7);
350 }
351 for (i = 0; i < len; i++) {
352 outb((*(pred + i)) >> shift, 0x3C9);
353 outb((*(pgreen + i)) >> shift, 0x3C9);
354 outb((*(pblue + i)) >> shift, 0x3C9);
355 }
356
357 outb(0x1A, 0x3C4);
358 /* Map the 3C6/7/8/9 to the IGA1 */
359 outb(sr1a & 0xFE, 0x3C5);
360 /* Bit mask of palette */
361 outb(0xFF, 0x3c6);
362 outb(0x00, 0x3C8);
363 for (i = 0; i < len; i++) {
364 outb((*(pred + i)) >> shift, 0x3C9);
365 outb((*(pgreen + i)) >> shift, 0x3C9);
366 outb((*(pblue + i)) >> shift, 0x3C9);
367 }
368
369 outb(0x1A, 0x3C4);
370 outb(sr1a, 0x3C5);
371 outb(0x1B, 0x3C4);
372 outb(sr1b, 0x3C5);
373 outb(0x67, 0x3D4);
374 outb(cr67, 0x3D5);
375 outb(0x6A, 0x3D4);
376 outb(cr6a, 0x3D5);
377 break;
378 case 16:
379 if (len > 17)
380 return 0; /* Because static u32 pseudo_pal[17]; */
381 for (i = 0; i < len; i++)
382 ((u32 *) info->pseudo_palette)[i] =
383 (*(pred + i) & 0xF800) |
384 ((*(pgreen + i) & 0xFC00) >> 5) |
385 ((*(pblue + i) & 0xF800) >> 11);
386 break;
387 case 32:
388 if (len > 17)
389 return 0;
390 if (ptransp) {
391 for (i = 0; i < len; i++)
392 ((u32 *) info->pseudo_palette)[i] =
393 ((*(ptransp + i) & 0xFF00) << 16) |
394 ((*(pred + i) & 0xFF00) << 8) |
395 ((*(pgreen + i) & 0xFF00)) |
396 ((*(pblue + i) & 0xFF00) >> 8);
397 } else {
398 for (i = 0; i < len; i++)
399 ((u32 *) info->pseudo_palette)[i] =
400 0x00000000 |
401 ((*(pred + i) & 0xFF00) << 8) |
402 ((*(pgreen + i) & 0xFF00)) |
403 ((*(pblue + i) & 0xFF00) >> 8);
404 }
405 break;
406 }
407 return 0;
408}
409
410static int viafb_pan_display(struct fb_var_screeninfo *var,
411 struct fb_info *info)
412{
413 unsigned int offset;
414
415 DEBUG_MSG(KERN_INFO "viafb_pan_display!\n");
416
417 offset = (var->xoffset + (var->yoffset * var->xres_virtual)) *
418 var->bits_per_pixel / 16;
419
420 DEBUG_MSG(KERN_INFO "\nviafb_pan_display,offset =%d ", offset);
Florian Tobias Schandinat09cf1182009-09-22 16:47:14 -0700421 viafb_set_primary_address(offset);
Joseph Chan29b619f2008-10-15 22:03:27 -0700422 return 0;
423}
424
425static int viafb_blank(int blank_mode, struct fb_info *info)
426{
427 DEBUG_MSG(KERN_INFO "viafb_blank!\n");
428 /* clear DPMS setting */
429
430 switch (blank_mode) {
431 case FB_BLANK_UNBLANK:
432 /* Screen: On, HSync: On, VSync: On */
433 /* control CRT monitor power management */
434 viafb_write_reg_mask(CR36, VIACR, 0x00, BIT4 + BIT5);
435 break;
436 case FB_BLANK_HSYNC_SUSPEND:
437 /* Screen: Off, HSync: Off, VSync: On */
438 /* control CRT monitor power management */
439 viafb_write_reg_mask(CR36, VIACR, 0x10, BIT4 + BIT5);
440 break;
441 case FB_BLANK_VSYNC_SUSPEND:
442 /* Screen: Off, HSync: On, VSync: Off */
443 /* control CRT monitor power management */
444 viafb_write_reg_mask(CR36, VIACR, 0x20, BIT4 + BIT5);
445 break;
446 case FB_BLANK_POWERDOWN:
447 /* Screen: Off, HSync: Off, VSync: Off */
448 /* control CRT monitor power management */
449 viafb_write_reg_mask(CR36, VIACR, 0x30, BIT4 + BIT5);
450 break;
451 }
452
453 return 0;
454}
455
456static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
457{
Bruno Prémonte687d692009-01-04 13:11:54 -0800458 union {
459 struct viafb_ioctl_mode viamode;
460 struct viafb_ioctl_samm viasamm;
461 struct viafb_driver_version driver_version;
462 struct fb_var_screeninfo sec_var;
463 struct _panel_size_pos_info panel_pos_size_para;
464 struct viafb_ioctl_setting viafb_setting;
465 struct device_t active_dev;
466 } u;
Joseph Chan29b619f2008-10-15 22:03:27 -0700467 u32 state_info = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700468 u32 *viafb_gamma_table;
469 char driver_name[] = "viafb";
470
471 u32 __user *argp = (u32 __user *) arg;
472 u32 gpu32;
Joseph Chan29b619f2008-10-15 22:03:27 -0700473
474 DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd);
Florian Tobias Schandinatcc8b82f2010-03-10 15:21:26 -0800475 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 -0800476 memset(&u, 0, sizeof(u));
Joseph Chan29b619f2008-10-15 22:03:27 -0700477
478 switch (cmd) {
479 case VIAFB_GET_CHIP_INFO:
480 if (copy_to_user(argp, viaparinfo->chip_info,
481 sizeof(struct chip_information)))
482 return -EFAULT;
483 break;
484 case VIAFB_GET_INFO_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800485 return put_user((u32)sizeof(struct viafb_ioctl_info), argp);
Joseph Chan29b619f2008-10-15 22:03:27 -0700486 case VIAFB_GET_INFO:
487 return viafb_ioctl_get_viafb_info(arg);
488 case VIAFB_HOTPLUG:
489 return put_user(viafb_ioctl_hotplug(info->var.xres,
490 info->var.yres,
491 info->var.bits_per_pixel), argp);
492 case VIAFB_SET_HOTPLUG_FLAG:
493 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
494 return -EFAULT;
495 viafb_hotplug = (gpu32) ? 1 : 0;
496 break;
497 case VIAFB_GET_RESOLUTION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800498 u.viamode.xres = (u32) viafb_hotplug_Xres;
499 u.viamode.yres = (u32) viafb_hotplug_Yres;
500 u.viamode.refresh = (u32) viafb_hotplug_refresh;
501 u.viamode.bpp = (u32) viafb_hotplug_bpp;
Joseph Chan29b619f2008-10-15 22:03:27 -0700502 if (viafb_SAMM_ON == 1) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800503 u.viamode.xres_sec = viafb_second_xres;
504 u.viamode.yres_sec = viafb_second_yres;
505 u.viamode.virtual_xres_sec = viafb_second_virtual_xres;
506 u.viamode.virtual_yres_sec = viafb_second_virtual_yres;
507 u.viamode.refresh_sec = viafb_refresh1;
508 u.viamode.bpp_sec = viafb_bpp1;
Joseph Chan29b619f2008-10-15 22:03:27 -0700509 } else {
Bruno Prémonte687d692009-01-04 13:11:54 -0800510 u.viamode.xres_sec = 0;
511 u.viamode.yres_sec = 0;
512 u.viamode.virtual_xres_sec = 0;
513 u.viamode.virtual_yres_sec = 0;
514 u.viamode.refresh_sec = 0;
515 u.viamode.bpp_sec = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700516 }
Bruno Prémonte687d692009-01-04 13:11:54 -0800517 if (copy_to_user(argp, &u.viamode, sizeof(u.viamode)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700518 return -EFAULT;
519 break;
520 case VIAFB_GET_SAMM_INFO:
Bruno Prémonte687d692009-01-04 13:11:54 -0800521 u.viasamm.samm_status = viafb_SAMM_ON;
Joseph Chan29b619f2008-10-15 22:03:27 -0700522
523 if (viafb_SAMM_ON == 1) {
524 if (viafb_dual_fb) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800525 u.viasamm.size_prim = viaparinfo->fbmem_free;
526 u.viasamm.size_sec = viaparinfo1->fbmem_free;
Joseph Chan29b619f2008-10-15 22:03:27 -0700527 } else {
528 if (viafb_second_size) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800529 u.viasamm.size_prim =
Joseph Chan29b619f2008-10-15 22:03:27 -0700530 viaparinfo->fbmem_free -
531 viafb_second_size * 1024 * 1024;
Bruno Prémonte687d692009-01-04 13:11:54 -0800532 u.viasamm.size_sec =
Joseph Chan29b619f2008-10-15 22:03:27 -0700533 viafb_second_size * 1024 * 1024;
534 } else {
Bruno Prémonte687d692009-01-04 13:11:54 -0800535 u.viasamm.size_prim =
Joseph Chan29b619f2008-10-15 22:03:27 -0700536 viaparinfo->fbmem_free >> 1;
Bruno Prémonte687d692009-01-04 13:11:54 -0800537 u.viasamm.size_sec =
Joseph Chan29b619f2008-10-15 22:03:27 -0700538 (viaparinfo->fbmem_free >> 1);
539 }
540 }
Bruno Prémonte687d692009-01-04 13:11:54 -0800541 u.viasamm.mem_base = viaparinfo->fbmem;
542 u.viasamm.offset_sec = viafb_second_offset;
Joseph Chan29b619f2008-10-15 22:03:27 -0700543 } else {
Bruno Prémonte687d692009-01-04 13:11:54 -0800544 u.viasamm.size_prim =
Joseph Chan29b619f2008-10-15 22:03:27 -0700545 viaparinfo->memsize - viaparinfo->fbmem_used;
Bruno Prémonte687d692009-01-04 13:11:54 -0800546 u.viasamm.size_sec = 0;
547 u.viasamm.mem_base = viaparinfo->fbmem;
548 u.viasamm.offset_sec = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700549 }
550
Bruno Prémonte687d692009-01-04 13:11:54 -0800551 if (copy_to_user(argp, &u.viasamm, sizeof(u.viasamm)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700552 return -EFAULT;
553
554 break;
555 case VIAFB_TURN_ON_OUTPUT_DEVICE:
556 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
557 return -EFAULT;
558 if (gpu32 & CRT_Device)
559 viafb_crt_enable();
560 if (gpu32 & DVI_Device)
561 viafb_dvi_enable();
562 if (gpu32 & LCD_Device)
563 viafb_lcd_enable();
564 break;
565 case VIAFB_TURN_OFF_OUTPUT_DEVICE:
566 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
567 return -EFAULT;
568 if (gpu32 & CRT_Device)
569 viafb_crt_disable();
570 if (gpu32 & DVI_Device)
571 viafb_dvi_disable();
572 if (gpu32 & LCD_Device)
573 viafb_lcd_disable();
574 break;
575 case VIAFB_SET_DEVICE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800576 if (copy_from_user(&u.active_dev, (void *)argp,
577 sizeof(u.active_dev)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700578 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800579 viafb_set_device(u.active_dev);
Joseph Chan29b619f2008-10-15 22:03:27 -0700580 viafb_set_par(info);
581 break;
582 case VIAFB_GET_DEVICE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800583 u.active_dev.crt = viafb_CRT_ON;
584 u.active_dev.dvi = viafb_DVI_ON;
585 u.active_dev.lcd = viafb_LCD_ON;
586 u.active_dev.samm = viafb_SAMM_ON;
587 u.active_dev.primary_dev = viafb_primary_dev;
Joseph Chan29b619f2008-10-15 22:03:27 -0700588
Bruno Prémonte687d692009-01-04 13:11:54 -0800589 u.active_dev.lcd_dsp_cent = viafb_lcd_dsp_method;
590 u.active_dev.lcd_panel_id = viafb_lcd_panel_id;
591 u.active_dev.lcd_mode = viafb_lcd_mode;
Joseph Chan29b619f2008-10-15 22:03:27 -0700592
Bruno Prémonte687d692009-01-04 13:11:54 -0800593 u.active_dev.xres = viafb_hotplug_Xres;
594 u.active_dev.yres = viafb_hotplug_Yres;
Joseph Chan29b619f2008-10-15 22:03:27 -0700595
Bruno Prémonte687d692009-01-04 13:11:54 -0800596 u.active_dev.xres1 = viafb_second_xres;
597 u.active_dev.yres1 = viafb_second_yres;
Joseph Chan29b619f2008-10-15 22:03:27 -0700598
Bruno Prémonte687d692009-01-04 13:11:54 -0800599 u.active_dev.bpp = viafb_bpp;
600 u.active_dev.bpp1 = viafb_bpp1;
601 u.active_dev.refresh = viafb_refresh;
602 u.active_dev.refresh1 = viafb_refresh1;
Joseph Chan29b619f2008-10-15 22:03:27 -0700603
Bruno Prémonte687d692009-01-04 13:11:54 -0800604 u.active_dev.epia_dvi = viafb_platform_epia_dvi;
605 u.active_dev.lcd_dual_edge = viafb_device_lcd_dualedge;
606 u.active_dev.bus_width = viafb_bus_width;
Joseph Chan29b619f2008-10-15 22:03:27 -0700607
Bruno Prémonte687d692009-01-04 13:11:54 -0800608 if (copy_to_user(argp, &u.active_dev, sizeof(u.active_dev)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700609 return -EFAULT;
610 break;
611
612 case VIAFB_GET_DRIVER_VERSION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800613 u.driver_version.iMajorNum = VERSION_MAJOR;
614 u.driver_version.iKernelNum = VERSION_KERNEL;
615 u.driver_version.iOSNum = VERSION_OS;
616 u.driver_version.iMinorNum = VERSION_MINOR;
Joseph Chan29b619f2008-10-15 22:03:27 -0700617
Bruno Prémonte687d692009-01-04 13:11:54 -0800618 if (copy_to_user(argp, &u.driver_version,
619 sizeof(u.driver_version)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700620 return -EFAULT;
621
622 break;
623
624 case VIAFB_SET_DEVICE_INFO:
Bruno Prémonte687d692009-01-04 13:11:54 -0800625 if (copy_from_user(&u.viafb_setting,
626 argp, sizeof(u.viafb_setting)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700627 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800628 if (apply_device_setting(u.viafb_setting, info) < 0)
Joseph Chan29b619f2008-10-15 22:03:27 -0700629 return -EINVAL;
630
631 break;
632
633 case VIAFB_SET_SECOND_MODE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800634 if (copy_from_user(&u.sec_var, argp, sizeof(u.sec_var)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700635 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800636 apply_second_mode_setting(&u.sec_var);
Joseph Chan29b619f2008-10-15 22:03:27 -0700637 break;
638
639 case VIAFB_GET_DEVICE_INFO:
640
Bruno Prémonte687d692009-01-04 13:11:54 -0800641 retrieve_device_setting(&u.viafb_setting);
Joseph Chan29b619f2008-10-15 22:03:27 -0700642
Bruno Prémonte687d692009-01-04 13:11:54 -0800643 if (copy_to_user(argp, &u.viafb_setting,
644 sizeof(u.viafb_setting)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700645 return -EFAULT;
646
647 break;
648
649 case VIAFB_GET_DEVICE_SUPPORT:
650 viafb_get_device_support_state(&state_info);
651 if (put_user(state_info, argp))
652 return -EFAULT;
653 break;
654
655 case VIAFB_GET_DEVICE_CONNECT:
656 viafb_get_device_connect_state(&state_info);
657 if (put_user(state_info, argp))
658 return -EFAULT;
659 break;
660
661 case VIAFB_GET_PANEL_SUPPORT_EXPAND:
662 state_info =
663 viafb_lcd_get_support_expand_state(info->var.xres,
664 info->var.yres);
665 if (put_user(state_info, argp))
666 return -EFAULT;
667 break;
668
669 case VIAFB_GET_DRIVER_NAME:
670 if (copy_to_user(argp, driver_name, sizeof(driver_name)))
671 return -EFAULT;
672 break;
673
674 case VIAFB_SET_GAMMA_LUT:
675 viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
676 if (!viafb_gamma_table)
677 return -ENOMEM;
678 if (copy_from_user(viafb_gamma_table, argp,
Julia Lawall0f050582009-12-17 15:27:09 -0800679 256 * sizeof(u32))) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700680 kfree(viafb_gamma_table);
681 return -EFAULT;
682 }
683 viafb_set_gamma_table(viafb_bpp, viafb_gamma_table);
684 kfree(viafb_gamma_table);
685 break;
686
687 case VIAFB_GET_GAMMA_LUT:
688 viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
689 if (!viafb_gamma_table)
690 return -ENOMEM;
691 viafb_get_gamma_table(viafb_gamma_table);
692 if (copy_to_user(argp, viafb_gamma_table,
Julia Lawall0f050582009-12-17 15:27:09 -0800693 256 * sizeof(u32))) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700694 kfree(viafb_gamma_table);
695 return -EFAULT;
696 }
697 kfree(viafb_gamma_table);
698 break;
699
700 case VIAFB_GET_GAMMA_SUPPORT_STATE:
701 viafb_get_gamma_support_state(viafb_bpp, &state_info);
702 if (put_user(state_info, argp))
703 return -EFAULT;
704 break;
Joseph Chan29b619f2008-10-15 22:03:27 -0700705 case VIAFB_SYNC_SURFACE:
706 DEBUG_MSG(KERN_INFO "lobo VIAFB_SYNC_SURFACE\n");
707 break;
708 case VIAFB_GET_DRIVER_CAPS:
709 break;
710
711 case VIAFB_GET_PANEL_MAX_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800712 if (copy_from_user(&u.panel_pos_size_para, argp,
713 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700714 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800715 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
716 if (copy_to_user(argp, &u.panel_pos_size_para,
717 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700718 return -EFAULT;
719 break;
720 case VIAFB_GET_PANEL_MAX_POSITION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800721 if (copy_from_user(&u.panel_pos_size_para, argp,
722 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700723 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800724 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
725 if (copy_to_user(argp, &u.panel_pos_size_para,
726 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700727 return -EFAULT;
728 break;
729
730 case VIAFB_GET_PANEL_POSITION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800731 if (copy_from_user(&u.panel_pos_size_para, argp,
732 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700733 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800734 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
735 if (copy_to_user(argp, &u.panel_pos_size_para,
736 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700737 return -EFAULT;
738 break;
739 case VIAFB_GET_PANEL_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800740 if (copy_from_user(&u.panel_pos_size_para, argp,
741 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700742 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800743 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
744 if (copy_to_user(argp, &u.panel_pos_size_para,
745 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700746 return -EFAULT;
747 break;
748
749 case VIAFB_SET_PANEL_POSITION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800750 if (copy_from_user(&u.panel_pos_size_para, argp,
751 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700752 return -EFAULT;
753 break;
754 case VIAFB_SET_PANEL_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800755 if (copy_from_user(&u.panel_pos_size_para, argp,
756 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700757 return -EFAULT;
758 break;
759
760 default:
761 return -EINVAL;
762 }
763
764 return 0;
765}
766
767static void viafb_fillrect(struct fb_info *info,
768 const struct fb_fillrect *rect)
769{
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700770 struct viafb_par *viapar = info->par;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700771 struct viafb_shared *shared = viapar->shared;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700772 u32 fg_color;
773 u8 rop;
Joseph Chan29b619f2008-10-15 22:03:27 -0700774
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700775 if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) {
Hannes Eder2899bb02009-01-06 14:42:32 -0800776 cfb_fillrect(info, rect);
777 return;
778 }
Joseph Chan29b619f2008-10-15 22:03:27 -0700779
780 if (!rect->width || !rect->height)
781 return;
782
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700783 if (info->fix.visual == FB_VISUAL_TRUECOLOR)
784 fg_color = ((u32 *)info->pseudo_palette)[rect->color];
785 else
786 fg_color = rect->color;
787
788 if (rect->rop == ROP_XOR)
Joseph Chan29b619f2008-10-15 22:03:27 -0700789 rop = 0x5A;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700790 else
Joseph Chan29b619f2008-10-15 22:03:27 -0700791 rop = 0xF0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700792
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700793 DEBUG_MSG(KERN_DEBUG "viafb 2D engine: fillrect\n");
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700794 if (shared->hw_bitblt(shared->engine_mmio, VIA_BITBLT_FILL,
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700795 rect->width, rect->height, info->var.bits_per_pixel,
796 viapar->vram_addr, info->fix.line_length, rect->dx, rect->dy,
797 NULL, 0, 0, 0, 0, fg_color, 0, rop))
798 cfb_fillrect(info, rect);
Joseph Chan29b619f2008-10-15 22:03:27 -0700799}
800
801static void viafb_copyarea(struct fb_info *info,
802 const struct fb_copyarea *area)
803{
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700804 struct viafb_par *viapar = info->par;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700805 struct viafb_shared *shared = viapar->shared;
Joseph Chan29b619f2008-10-15 22:03:27 -0700806
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700807 if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt) {
Hannes Eder2899bb02009-01-06 14:42:32 -0800808 cfb_copyarea(info, area);
809 return;
810 }
Joseph Chan29b619f2008-10-15 22:03:27 -0700811
812 if (!area->width || !area->height)
813 return;
814
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700815 DEBUG_MSG(KERN_DEBUG "viafb 2D engine: copyarea\n");
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700816 if (shared->hw_bitblt(shared->engine_mmio, VIA_BITBLT_COLOR,
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700817 area->width, area->height, info->var.bits_per_pixel,
818 viapar->vram_addr, info->fix.line_length, area->dx, area->dy,
819 NULL, viapar->vram_addr, info->fix.line_length,
820 area->sx, area->sy, 0, 0, 0))
821 cfb_copyarea(info, area);
Joseph Chan29b619f2008-10-15 22:03:27 -0700822}
823
824static void viafb_imageblit(struct fb_info *info,
825 const struct fb_image *image)
826{
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700827 struct viafb_par *viapar = info->par;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700828 struct viafb_shared *shared = viapar->shared;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700829 u32 fg_color = 0, bg_color = 0;
830 u8 op;
Joseph Chan29b619f2008-10-15 22:03:27 -0700831
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700832 if (info->flags & FBINFO_HWACCEL_DISABLED || !shared->hw_bitblt ||
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700833 (image->depth != 1 && image->depth != viapar->depth)) {
Hannes Eder2899bb02009-01-06 14:42:32 -0800834 cfb_imageblit(info, image);
835 return;
836 }
Joseph Chan29b619f2008-10-15 22:03:27 -0700837
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700838 if (image->depth == 1) {
839 op = VIA_BITBLT_MONO;
840 if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
841 fg_color =
842 ((u32 *)info->pseudo_palette)[image->fg_color];
843 bg_color =
844 ((u32 *)info->pseudo_palette)[image->bg_color];
845 } else {
846 fg_color = image->fg_color;
847 bg_color = image->bg_color;
848 }
849 } else
850 op = VIA_BITBLT_COLOR;
Joseph Chan29b619f2008-10-15 22:03:27 -0700851
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700852 DEBUG_MSG(KERN_DEBUG "viafb 2D engine: imageblit\n");
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700853 if (shared->hw_bitblt(shared->engine_mmio, op,
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -0700854 image->width, image->height, info->var.bits_per_pixel,
855 viapar->vram_addr, info->fix.line_length, image->dx, image->dy,
856 (u32 *)image->data, 0, 0, 0, 0, fg_color, bg_color, 0))
857 cfb_imageblit(info, image);
Joseph Chan29b619f2008-10-15 22:03:27 -0700858}
859
860static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
861{
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700862 struct viafb_par *viapar = info->par;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700863 void __iomem *engine = viapar->shared->engine_mmio;
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700864 u32 temp, xx, yy, bg_color = 0, fg_color = 0,
865 chip_name = viapar->shared->chip_info.gfx_chip_name;
866 int i, j = 0, cur_size = 64;
Joseph Chan29b619f2008-10-15 22:03:27 -0700867
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700868 if (info->flags & FBINFO_HWACCEL_DISABLED || info != viafbinfo)
Joseph Chan29b619f2008-10-15 22:03:27 -0700869 return -ENODEV;
870
Florian Tobias Schandinat0b941902010-01-15 17:01:03 -0800871 /* LCD ouput does not support hw cursors (at least on VN896) */
872 if ((chip_name == UNICHROME_CLE266 && viapar->iga_path == IGA2) ||
873 viafb_LCD_ON)
Joseph Chan29b619f2008-10-15 22:03:27 -0700874 return -ENODEV;
875
876 viafb_show_hw_cursor(info, HW_Cursor_OFF);
Joseph Chan29b619f2008-10-15 22:03:27 -0700877
878 if (cursor->set & FB_CUR_SETHOT) {
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700879 temp = (cursor->hot.x << 16) + cursor->hot.y;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700880 writel(temp, engine + VIA_REG_CURSOR_ORG);
Joseph Chan29b619f2008-10-15 22:03:27 -0700881 }
882
883 if (cursor->set & FB_CUR_SETPOS) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700884 yy = cursor->image.dy - info->var.yoffset;
885 xx = cursor->image.dx - info->var.xoffset;
886 temp = yy & 0xFFFF;
887 temp |= (xx << 16);
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700888 writel(temp, engine + VIA_REG_CURSOR_POS);
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700889 }
890
891 if (cursor->image.width <= 32 && cursor->image.height <= 32)
892 cur_size = 32;
893 else if (cursor->image.width <= 64 && cursor->image.height <= 64)
894 cur_size = 64;
895 else {
896 printk(KERN_WARNING "viafb_cursor: The cursor is too large "
897 "%dx%d", cursor->image.width, cursor->image.height);
898 return -ENXIO;
Joseph Chan29b619f2008-10-15 22:03:27 -0700899 }
900
901 if (cursor->set & FB_CUR_SETSIZE) {
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700902 temp = readl(engine + VIA_REG_CURSOR_MODE);
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700903 if (cur_size == 32)
Joseph Chan29b619f2008-10-15 22:03:27 -0700904 temp |= 0x2;
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700905 else
906 temp &= ~0x2;
Joseph Chan29b619f2008-10-15 22:03:27 -0700907
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700908 writel(temp, engine + VIA_REG_CURSOR_MODE);
Joseph Chan29b619f2008-10-15 22:03:27 -0700909 }
910
911 if (cursor->set & FB_CUR_SETCMAP) {
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700912 fg_color = cursor->image.fg_color;
913 bg_color = cursor->image.bg_color;
914 if (chip_name == UNICHROME_CX700 ||
Harald Welte0306ab12009-09-22 16:47:35 -0700915 chip_name == UNICHROME_VX800 ||
916 chip_name == UNICHROME_VX855) {
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700917 fg_color =
918 ((info->cmap.red[fg_color] & 0xFFC0) << 14) |
919 ((info->cmap.green[fg_color] & 0xFFC0) << 4) |
920 ((info->cmap.blue[fg_color] & 0xFFC0) >> 6);
921 bg_color =
922 ((info->cmap.red[bg_color] & 0xFFC0) << 14) |
923 ((info->cmap.green[bg_color] & 0xFFC0) << 4) |
924 ((info->cmap.blue[bg_color] & 0xFFC0) >> 6);
925 } else {
926 fg_color =
927 ((info->cmap.red[fg_color] & 0xFF00) << 8) |
928 (info->cmap.green[fg_color] & 0xFF00) |
929 ((info->cmap.blue[fg_color] & 0xFF00) >> 8);
930 bg_color =
931 ((info->cmap.red[bg_color] & 0xFF00) << 8) |
932 (info->cmap.green[bg_color] & 0xFF00) |
933 ((info->cmap.blue[bg_color] & 0xFF00) >> 8);
Joseph Chan29b619f2008-10-15 22:03:27 -0700934 }
935
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -0700936 writel(bg_color, engine + VIA_REG_CURSOR_BG);
937 writel(fg_color, engine + VIA_REG_CURSOR_FG);
Joseph Chan29b619f2008-10-15 22:03:27 -0700938 }
939
940 if (cursor->set & FB_CUR_SETSHAPE) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800941 struct {
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700942 u8 data[CURSOR_SIZE];
943 u32 bak[CURSOR_SIZE / 4];
Bruno Prémonte687d692009-01-04 13:11:54 -0800944 } *cr_data = kzalloc(sizeof(*cr_data), GFP_ATOMIC);
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700945 int size = ((cursor->image.width + 7) >> 3) *
946 cursor->image.height;
Joseph Chan29b619f2008-10-15 22:03:27 -0700947
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700948 if (!cr_data)
949 return -ENOMEM;
Bruno Prémonte687d692009-01-04 13:11:54 -0800950
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700951 if (cur_size == 32) {
952 for (i = 0; i < (CURSOR_SIZE / 4); i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800953 cr_data->bak[i] = 0x0;
954 cr_data->bak[i + 1] = 0xFFFFFFFF;
Joseph Chan29b619f2008-10-15 22:03:27 -0700955 i += 1;
956 }
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700957 } else {
958 for (i = 0; i < (CURSOR_SIZE / 4); i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800959 cr_data->bak[i] = 0x0;
960 cr_data->bak[i + 1] = 0x0;
961 cr_data->bak[i + 2] = 0xFFFFFFFF;
962 cr_data->bak[i + 3] = 0xFFFFFFFF;
Joseph Chan29b619f2008-10-15 22:03:27 -0700963 i += 3;
964 }
965 }
966
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700967 switch (cursor->rop) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700968 case ROP_XOR:
969 for (i = 0; i < size; i++)
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700970 cr_data->data[i] = cursor->mask[i];
Joseph Chan29b619f2008-10-15 22:03:27 -0700971 break;
972 case ROP_COPY:
973
974 for (i = 0; i < size; i++)
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700975 cr_data->data[i] = cursor->mask[i];
Joseph Chan29b619f2008-10-15 22:03:27 -0700976 break;
977 default:
978 break;
979 }
980
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700981 if (cur_size == 32) {
Joseph Chan29b619f2008-10-15 22:03:27 -0700982 for (i = 0; i < size; i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800983 cr_data->bak[j] = (u32) cr_data->data[i];
984 cr_data->bak[j + 1] = ~cr_data->bak[j];
Joseph Chan29b619f2008-10-15 22:03:27 -0700985 j += 2;
986 }
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700987 } else {
Joseph Chan29b619f2008-10-15 22:03:27 -0700988 for (i = 0; i < size; i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800989 cr_data->bak[j] = (u32) cr_data->data[i];
990 cr_data->bak[j + 1] = 0x0;
991 cr_data->bak[j + 2] = ~cr_data->bak[j];
992 cr_data->bak[j + 3] = ~cr_data->bak[j + 1];
Joseph Chan29b619f2008-10-15 22:03:27 -0700993 j += 4;
994 }
995 }
996
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -0700997 memcpy_toio(viafbinfo->screen_base + viapar->shared->
998 cursor_vram_addr, cr_data->bak, CURSOR_SIZE);
Bruno Prémonte687d692009-01-04 13:11:54 -0800999 kfree(cr_data);
Joseph Chan29b619f2008-10-15 22:03:27 -07001000 }
1001
Florian Tobias Schandinat5016af532009-09-22 16:47:28 -07001002 if (cursor->enable)
Joseph Chan29b619f2008-10-15 22:03:27 -07001003 viafb_show_hw_cursor(info, HW_Cursor_ON);
1004
1005 return 0;
1006}
1007
1008static int viafb_sync(struct fb_info *info)
1009{
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -07001010 if (!(info->flags & FBINFO_HWACCEL_DISABLED))
1011 viafb_wait_engine_idle(info);
Joseph Chan29b619f2008-10-15 22:03:27 -07001012 return 0;
1013}
1014
Joseph Chan29b619f2008-10-15 22:03:27 -07001015static void check_available_device_to_enable(int device_id)
1016{
1017 int device_num = 0;
1018
1019 /* Initialize: */
1020 viafb_CRT_ON = STATE_OFF;
1021 viafb_DVI_ON = STATE_OFF;
1022 viafb_LCD_ON = STATE_OFF;
1023 viafb_LCD2_ON = STATE_OFF;
1024 viafb_DeviceStatus = None_Device;
1025
1026 if ((device_id & CRT_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1027 viafb_CRT_ON = STATE_ON;
1028 device_num++;
1029 viafb_DeviceStatus |= CRT_Device;
1030 }
1031
1032 if ((device_id & DVI_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1033 viafb_DVI_ON = STATE_ON;
1034 device_num++;
1035 viafb_DeviceStatus |= DVI_Device;
1036 }
1037
1038 if ((device_id & LCD_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1039 viafb_LCD_ON = STATE_ON;
1040 device_num++;
1041 viafb_DeviceStatus |= LCD_Device;
1042 }
1043
1044 if ((device_id & LCD2_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1045 viafb_LCD2_ON = STATE_ON;
1046 device_num++;
1047 viafb_DeviceStatus |= LCD2_Device;
1048 }
1049
1050 if (viafb_DeviceStatus == None_Device) {
1051 /* Use CRT as default active device: */
1052 viafb_CRT_ON = STATE_ON;
1053 viafb_DeviceStatus = CRT_Device;
1054 }
1055 DEBUG_MSG(KERN_INFO "Device Status:%x", viafb_DeviceStatus);
1056}
1057
1058static void viafb_set_device(struct device_t active_dev)
1059{
1060 /* Check available device to enable: */
1061 int device_id = None_Device;
1062 if (active_dev.crt)
1063 device_id |= CRT_Device;
1064 if (active_dev.dvi)
1065 device_id |= DVI_Device;
1066 if (active_dev.lcd)
1067 device_id |= LCD_Device;
1068
1069 check_available_device_to_enable(device_id);
1070
1071 /* Check property of LCD: */
1072 if (viafb_LCD_ON) {
1073 if (active_dev.lcd_dsp_cent) {
1074 viaparinfo->lvds_setting_info->display_method =
1075 viafb_lcd_dsp_method = LCD_CENTERING;
1076 } else {
1077 viaparinfo->lvds_setting_info->display_method =
1078 viafb_lcd_dsp_method = LCD_EXPANDSION;
1079 }
1080
1081 if (active_dev.lcd_mode == LCD_SPWG) {
1082 viaparinfo->lvds_setting_info->lcd_mode =
1083 viafb_lcd_mode = LCD_SPWG;
1084 } else {
1085 viaparinfo->lvds_setting_info->lcd_mode =
1086 viafb_lcd_mode = LCD_OPENLDI;
1087 }
1088
1089 if (active_dev.lcd_panel_id <= LCD_PANEL_ID_MAXIMUM) {
1090 viafb_lcd_panel_id = active_dev.lcd_panel_id;
1091 viafb_init_lcd_size();
1092 }
1093 }
1094
1095 /* Check property of mode: */
1096 if (!active_dev.xres1)
1097 viafb_second_xres = 640;
1098 else
1099 viafb_second_xres = active_dev.xres1;
1100 if (!active_dev.yres1)
1101 viafb_second_yres = 480;
1102 else
1103 viafb_second_yres = active_dev.yres1;
1104 if (active_dev.bpp != 0)
1105 viafb_bpp = active_dev.bpp;
1106 if (active_dev.bpp1 != 0)
1107 viafb_bpp1 = active_dev.bpp1;
1108 if (active_dev.refresh != 0)
1109 viafb_refresh = active_dev.refresh;
1110 if (active_dev.refresh1 != 0)
1111 viafb_refresh1 = active_dev.refresh1;
1112 if ((active_dev.samm == STATE_OFF) || (active_dev.samm == STATE_ON))
1113 viafb_SAMM_ON = active_dev.samm;
1114 viafb_primary_dev = active_dev.primary_dev;
1115
Florian Tobias Schandinat09cf1182009-09-22 16:47:14 -07001116 viafb_set_primary_address(0);
1117 viafb_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0);
Joseph Chan29b619f2008-10-15 22:03:27 -07001118 viafb_set_iga_path();
1119}
1120
Joseph Chan29b619f2008-10-15 22:03:27 -07001121static int get_primary_device(void)
1122{
1123 int primary_device = 0;
1124 /* Rule: device on iga1 path are the primary device. */
1125 if (viafb_SAMM_ON) {
1126 if (viafb_CRT_ON) {
1127 if (viaparinfo->crt_setting_info->iga_path == IGA1) {
1128 DEBUG_MSG(KERN_INFO "CRT IGA Path:%d\n",
1129 viaparinfo->
1130 crt_setting_info->iga_path);
1131 primary_device = CRT_Device;
1132 }
1133 }
1134 if (viafb_DVI_ON) {
1135 if (viaparinfo->tmds_setting_info->iga_path == IGA1) {
1136 DEBUG_MSG(KERN_INFO "DVI IGA Path:%d\n",
1137 viaparinfo->
1138 tmds_setting_info->iga_path);
1139 primary_device = DVI_Device;
1140 }
1141 }
1142 if (viafb_LCD_ON) {
1143 if (viaparinfo->lvds_setting_info->iga_path == IGA1) {
1144 DEBUG_MSG(KERN_INFO "LCD IGA Path:%d\n",
1145 viaparinfo->
1146 lvds_setting_info->iga_path);
1147 primary_device = LCD_Device;
1148 }
1149 }
1150 if (viafb_LCD2_ON) {
1151 if (viaparinfo->lvds_setting_info2->iga_path == IGA1) {
1152 DEBUG_MSG(KERN_INFO "LCD2 IGA Path:%d\n",
1153 viaparinfo->
1154 lvds_setting_info2->iga_path);
1155 primary_device = LCD2_Device;
1156 }
1157 }
1158 }
1159 return primary_device;
1160}
1161
Joseph Chan29b619f2008-10-15 22:03:27 -07001162static void apply_second_mode_setting(struct fb_var_screeninfo
1163 *sec_var)
1164{
1165 u32 htotal, vtotal, long_refresh;
1166
1167 htotal = sec_var->xres + sec_var->left_margin +
1168 sec_var->right_margin + sec_var->hsync_len;
1169 vtotal = sec_var->yres + sec_var->upper_margin +
1170 sec_var->lower_margin + sec_var->vsync_len;
1171 if ((sec_var->xres_virtual * (sec_var->bits_per_pixel >> 3)) & 0x1F) {
1172 /*Is 32 bytes alignment? */
1173 /*32 pixel alignment */
1174 sec_var->xres_virtual = (sec_var->xres_virtual + 31) & ~31;
1175 }
1176
1177 htotal = sec_var->xres + sec_var->left_margin +
1178 sec_var->right_margin + sec_var->hsync_len;
1179 vtotal = sec_var->yres + sec_var->upper_margin +
1180 sec_var->lower_margin + sec_var->vsync_len;
1181 long_refresh = 1000000000UL / sec_var->pixclock * 1000;
1182 long_refresh /= (htotal * vtotal);
1183
1184 viafb_second_xres = sec_var->xres;
1185 viafb_second_yres = sec_var->yres;
1186 viafb_second_virtual_xres = sec_var->xres_virtual;
1187 viafb_second_virtual_yres = sec_var->yres_virtual;
1188 viafb_bpp1 = sec_var->bits_per_pixel;
1189 viafb_refresh1 = viafb_get_refresh(sec_var->xres, sec_var->yres,
1190 long_refresh);
1191}
1192
1193static int apply_device_setting(struct viafb_ioctl_setting setting_info,
1194 struct fb_info *info)
1195{
1196 int need_set_mode = 0;
1197 DEBUG_MSG(KERN_INFO "apply_device_setting\n");
1198
1199 if (setting_info.device_flag) {
1200 need_set_mode = 1;
1201 check_available_device_to_enable(setting_info.device_status);
1202 }
1203
1204 /* Unlock LCD's operation according to LCD flag
1205 and check if the setting value is valid. */
1206 /* If the value is valid, apply the new setting value to the device. */
1207 if (viafb_LCD_ON) {
1208 if (setting_info.lcd_operation_flag & OP_LCD_CENTERING) {
1209 need_set_mode = 1;
1210 if (setting_info.lcd_attributes.display_center) {
1211 /* Centering */
1212 viaparinfo->lvds_setting_info->display_method =
1213 LCD_CENTERING;
1214 viafb_lcd_dsp_method = LCD_CENTERING;
1215 viaparinfo->lvds_setting_info2->display_method =
1216 viafb_lcd_dsp_method = LCD_CENTERING;
1217 } else {
1218 /* expandsion */
1219 viaparinfo->lvds_setting_info->display_method =
1220 LCD_EXPANDSION;
1221 viafb_lcd_dsp_method = LCD_EXPANDSION;
1222 viaparinfo->lvds_setting_info2->display_method =
1223 LCD_EXPANDSION;
1224 viafb_lcd_dsp_method = LCD_EXPANDSION;
1225 }
1226 }
1227
1228 if (setting_info.lcd_operation_flag & OP_LCD_MODE) {
1229 need_set_mode = 1;
1230 if (setting_info.lcd_attributes.lcd_mode ==
1231 LCD_SPWG) {
1232 viaparinfo->lvds_setting_info->lcd_mode =
1233 viafb_lcd_mode = LCD_SPWG;
1234 } else {
1235 viaparinfo->lvds_setting_info->lcd_mode =
1236 viafb_lcd_mode = LCD_OPENLDI;
1237 }
1238 viaparinfo->lvds_setting_info2->lcd_mode =
1239 viaparinfo->lvds_setting_info->lcd_mode;
1240 }
1241
1242 if (setting_info.lcd_operation_flag & OP_LCD_PANEL_ID) {
1243 need_set_mode = 1;
1244 if (setting_info.lcd_attributes.panel_id <=
1245 LCD_PANEL_ID_MAXIMUM) {
1246 viafb_lcd_panel_id =
1247 setting_info.lcd_attributes.panel_id;
1248 viafb_init_lcd_size();
1249 }
1250 }
1251 }
1252
1253 if (0 != (setting_info.samm_status & OP_SAMM)) {
1254 setting_info.samm_status =
1255 setting_info.samm_status & (~OP_SAMM);
1256 if (setting_info.samm_status == 0
1257 || setting_info.samm_status == 1) {
1258 viafb_SAMM_ON = setting_info.samm_status;
1259
1260 if (viafb_SAMM_ON)
1261 viafb_primary_dev = setting_info.primary_device;
1262
Florian Tobias Schandinat09cf1182009-09-22 16:47:14 -07001263 viafb_set_primary_address(0);
1264 viafb_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0);
Joseph Chan29b619f2008-10-15 22:03:27 -07001265 viafb_set_iga_path();
1266 }
1267 need_set_mode = 1;
1268 }
1269
Joseph Chan29b619f2008-10-15 22:03:27 -07001270 if (!need_set_mode) {
1271 ;
1272 } else {
1273 viafb_set_iga_path();
1274 viafb_set_par(info);
1275 }
1276 return true;
1277}
1278
1279static void retrieve_device_setting(struct viafb_ioctl_setting
1280 *setting_info)
1281{
1282
1283 /* get device status */
1284 if (viafb_CRT_ON == 1)
1285 setting_info->device_status = CRT_Device;
1286 if (viafb_DVI_ON == 1)
1287 setting_info->device_status |= DVI_Device;
1288 if (viafb_LCD_ON == 1)
1289 setting_info->device_status |= LCD_Device;
1290 if (viafb_LCD2_ON == 1)
1291 setting_info->device_status |= LCD2_Device;
Joseph Chan29b619f2008-10-15 22:03:27 -07001292
1293 setting_info->samm_status = viafb_SAMM_ON;
1294 setting_info->primary_device = get_primary_device();
1295
1296 setting_info->first_dev_bpp = viafb_bpp;
1297 setting_info->second_dev_bpp = viafb_bpp1;
1298
1299 setting_info->first_dev_refresh = viafb_refresh;
1300 setting_info->second_dev_refresh = viafb_refresh1;
1301
1302 setting_info->first_dev_hor_res = viafb_hotplug_Xres;
1303 setting_info->first_dev_ver_res = viafb_hotplug_Yres;
1304 setting_info->second_dev_hor_res = viafb_second_xres;
1305 setting_info->second_dev_ver_res = viafb_second_yres;
1306
1307 /* Get lcd attributes */
1308 setting_info->lcd_attributes.display_center = viafb_lcd_dsp_method;
1309 setting_info->lcd_attributes.panel_id = viafb_lcd_panel_id;
1310 setting_info->lcd_attributes.lcd_mode = viafb_lcd_mode;
1311}
1312
1313static void parse_active_dev(void)
1314{
1315 viafb_CRT_ON = STATE_OFF;
1316 viafb_DVI_ON = STATE_OFF;
1317 viafb_LCD_ON = STATE_OFF;
1318 viafb_LCD2_ON = STATE_OFF;
1319 /* 1. Modify the active status of devices. */
1320 /* 2. Keep the order of devices, so we can set corresponding
1321 IGA path to devices in SAMM case. */
1322 /* Note: The previous of active_dev is primary device,
1323 and the following is secondary device. */
1324 if (!strncmp(viafb_active_dev, "CRT+DVI", 7)) {
1325 /* CRT+DVI */
1326 viafb_CRT_ON = STATE_ON;
1327 viafb_DVI_ON = STATE_ON;
1328 viafb_primary_dev = CRT_Device;
1329 } else if (!strncmp(viafb_active_dev, "DVI+CRT", 7)) {
1330 /* DVI+CRT */
1331 viafb_CRT_ON = STATE_ON;
1332 viafb_DVI_ON = STATE_ON;
1333 viafb_primary_dev = DVI_Device;
1334 } else if (!strncmp(viafb_active_dev, "CRT+LCD", 7)) {
1335 /* CRT+LCD */
1336 viafb_CRT_ON = STATE_ON;
1337 viafb_LCD_ON = STATE_ON;
1338 viafb_primary_dev = CRT_Device;
1339 } else if (!strncmp(viafb_active_dev, "LCD+CRT", 7)) {
1340 /* LCD+CRT */
1341 viafb_CRT_ON = STATE_ON;
1342 viafb_LCD_ON = STATE_ON;
1343 viafb_primary_dev = LCD_Device;
1344 } else if (!strncmp(viafb_active_dev, "DVI+LCD", 7)) {
1345 /* DVI+LCD */
1346 viafb_DVI_ON = STATE_ON;
1347 viafb_LCD_ON = STATE_ON;
1348 viafb_primary_dev = DVI_Device;
1349 } else if (!strncmp(viafb_active_dev, "LCD+DVI", 7)) {
1350 /* LCD+DVI */
1351 viafb_DVI_ON = STATE_ON;
1352 viafb_LCD_ON = STATE_ON;
1353 viafb_primary_dev = LCD_Device;
1354 } else if (!strncmp(viafb_active_dev, "LCD+LCD2", 8)) {
1355 viafb_LCD_ON = STATE_ON;
1356 viafb_LCD2_ON = STATE_ON;
1357 viafb_primary_dev = LCD_Device;
1358 } else if (!strncmp(viafb_active_dev, "LCD2+LCD", 8)) {
1359 viafb_LCD_ON = STATE_ON;
1360 viafb_LCD2_ON = STATE_ON;
1361 viafb_primary_dev = LCD2_Device;
1362 } else if (!strncmp(viafb_active_dev, "CRT", 3)) {
1363 /* CRT only */
1364 viafb_CRT_ON = STATE_ON;
1365 viafb_SAMM_ON = STATE_OFF;
1366 } else if (!strncmp(viafb_active_dev, "DVI", 3)) {
1367 /* DVI only */
1368 viafb_DVI_ON = STATE_ON;
1369 viafb_SAMM_ON = STATE_OFF;
1370 } else if (!strncmp(viafb_active_dev, "LCD", 3)) {
1371 /* LCD only */
1372 viafb_LCD_ON = STATE_ON;
1373 viafb_SAMM_ON = STATE_OFF;
1374 } else {
1375 viafb_CRT_ON = STATE_ON;
1376 viafb_SAMM_ON = STATE_OFF;
1377 }
Joseph Chan29b619f2008-10-15 22:03:27 -07001378}
1379
Joseph Chan29b619f2008-10-15 22:03:27 -07001380static int parse_port(char *opt_str, int *output_interface)
1381{
1382 if (!strncmp(opt_str, "DVP0", 4))
1383 *output_interface = INTERFACE_DVP0;
1384 else if (!strncmp(opt_str, "DVP1", 4))
1385 *output_interface = INTERFACE_DVP1;
1386 else if (!strncmp(opt_str, "DFP_HIGHLOW", 11))
1387 *output_interface = INTERFACE_DFP;
1388 else if (!strncmp(opt_str, "DFP_HIGH", 8))
1389 *output_interface = INTERFACE_DFP_HIGH;
1390 else if (!strncmp(opt_str, "DFP_LOW", 7))
1391 *output_interface = INTERFACE_DFP_LOW;
1392 else
1393 *output_interface = INTERFACE_NONE;
1394 return 0;
1395}
1396
1397static void parse_lcd_port(void)
1398{
1399 parse_port(viafb_lcd_port, &viaparinfo->chip_info->lvds_chip_info.
1400 output_interface);
1401 /*Initialize to avoid unexpected behavior */
1402 viaparinfo->chip_info->lvds_chip_info2.output_interface =
1403 INTERFACE_NONE;
1404
1405 DEBUG_MSG(KERN_INFO "parse_lcd_port: viafb_lcd_port:%s,interface:%d\n",
1406 viafb_lcd_port, viaparinfo->chip_info->lvds_chip_info.
1407 output_interface);
1408}
1409
1410static void parse_dvi_port(void)
1411{
1412 parse_port(viafb_dvi_port, &viaparinfo->chip_info->tmds_chip_info.
1413 output_interface);
1414
1415 DEBUG_MSG(KERN_INFO "parse_dvi_port: viafb_dvi_port:%s,interface:%d\n",
1416 viafb_dvi_port, viaparinfo->chip_info->tmds_chip_info.
1417 output_interface);
1418}
1419
1420/*
1421 * The proc filesystem read/write function, a simple proc implement to
1422 * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
1423 * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2],
1424 * CR9B, SR65, CR97, CR99
1425 */
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001426static int viafb_dvp0_proc_show(struct seq_file *m, void *v)
Joseph Chan29b619f2008-10-15 22:03:27 -07001427{
Joseph Chan29b619f2008-10-15 22:03:27 -07001428 u8 dvp0_data_dri = 0, dvp0_clk_dri = 0, dvp0 = 0;
1429 dvp0_data_dri =
1430 (viafb_read_reg(VIASR, SR2A) & BIT5) >> 4 |
1431 (viafb_read_reg(VIASR, SR1B) & BIT1) >> 1;
1432 dvp0_clk_dri =
1433 (viafb_read_reg(VIASR, SR2A) & BIT4) >> 3 |
1434 (viafb_read_reg(VIASR, SR1E) & BIT2) >> 2;
1435 dvp0 = viafb_read_reg(VIACR, CR96) & 0x0f;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001436 seq_printf(m, "%x %x %x\n", dvp0, dvp0_data_dri, dvp0_clk_dri);
1437 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001438}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001439
1440static int viafb_dvp0_proc_open(struct inode *inode, struct file *file)
1441{
1442 return single_open(file, viafb_dvp0_proc_show, NULL);
1443}
1444
1445static ssize_t viafb_dvp0_proc_write(struct file *file,
1446 const char __user *buffer, size_t count, loff_t *pos)
Joseph Chan29b619f2008-10-15 22:03:27 -07001447{
1448 char buf[20], *value, *pbuf;
1449 u8 reg_val = 0;
1450 unsigned long length, i;
1451 if (count < 1)
1452 return -EINVAL;
1453 length = count > 20 ? 20 : count;
1454 if (copy_from_user(&buf[0], buffer, length))
1455 return -EFAULT;
1456 buf[length - 1] = '\0'; /*Ensure end string */
1457 pbuf = &buf[0];
1458 for (i = 0; i < 3; i++) {
1459 value = strsep(&pbuf, " ");
1460 if (value != NULL) {
1461 strict_strtoul(value, 0, (unsigned long *)&reg_val);
1462 DEBUG_MSG(KERN_INFO "DVP0:reg_val[%l]=:%x\n", i,
1463 reg_val);
1464 switch (i) {
1465 case 0:
1466 viafb_write_reg_mask(CR96, VIACR,
1467 reg_val, 0x0f);
1468 break;
1469 case 1:
1470 viafb_write_reg_mask(SR2A, VIASR,
1471 reg_val << 4, BIT5);
1472 viafb_write_reg_mask(SR1B, VIASR,
1473 reg_val << 1, BIT1);
1474 break;
1475 case 2:
1476 viafb_write_reg_mask(SR2A, VIASR,
1477 reg_val << 3, BIT4);
1478 viafb_write_reg_mask(SR1E, VIASR,
1479 reg_val << 2, BIT2);
1480 break;
1481 default:
1482 break;
1483 }
1484 } else {
1485 break;
1486 }
1487 }
1488 return count;
1489}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001490
1491static const struct file_operations viafb_dvp0_proc_fops = {
1492 .owner = THIS_MODULE,
1493 .open = viafb_dvp0_proc_open,
1494 .read = seq_read,
1495 .llseek = seq_lseek,
1496 .release = single_release,
1497 .write = viafb_dvp0_proc_write,
1498};
1499
1500static int viafb_dvp1_proc_show(struct seq_file *m, void *v)
Joseph Chan29b619f2008-10-15 22:03:27 -07001501{
Joseph Chan29b619f2008-10-15 22:03:27 -07001502 u8 dvp1 = 0, dvp1_data_dri = 0, dvp1_clk_dri = 0;
1503 dvp1 = viafb_read_reg(VIACR, CR9B) & 0x0f;
1504 dvp1_data_dri = (viafb_read_reg(VIASR, SR65) & 0x0c) >> 2;
1505 dvp1_clk_dri = viafb_read_reg(VIASR, SR65) & 0x03;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001506 seq_printf(m, "%x %x %x\n", dvp1, dvp1_data_dri, dvp1_clk_dri);
1507 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001508}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001509
1510static int viafb_dvp1_proc_open(struct inode *inode, struct file *file)
1511{
1512 return single_open(file, viafb_dvp1_proc_show, NULL);
1513}
1514
1515static ssize_t viafb_dvp1_proc_write(struct file *file,
1516 const char __user *buffer, size_t count, loff_t *pos)
Joseph Chan29b619f2008-10-15 22:03:27 -07001517{
1518 char buf[20], *value, *pbuf;
1519 u8 reg_val = 0;
1520 unsigned long length, i;
1521 if (count < 1)
1522 return -EINVAL;
1523 length = count > 20 ? 20 : count;
1524 if (copy_from_user(&buf[0], buffer, length))
1525 return -EFAULT;
1526 buf[length - 1] = '\0'; /*Ensure end string */
1527 pbuf = &buf[0];
1528 for (i = 0; i < 3; i++) {
1529 value = strsep(&pbuf, " ");
1530 if (value != NULL) {
1531 strict_strtoul(value, 0, (unsigned long *)&reg_val);
1532 switch (i) {
1533 case 0:
1534 viafb_write_reg_mask(CR9B, VIACR,
1535 reg_val, 0x0f);
1536 break;
1537 case 1:
1538 viafb_write_reg_mask(SR65, VIASR,
1539 reg_val << 2, 0x0c);
1540 break;
1541 case 2:
1542 viafb_write_reg_mask(SR65, VIASR,
1543 reg_val, 0x03);
1544 break;
1545 default:
1546 break;
1547 }
1548 } else {
1549 break;
1550 }
1551 }
1552 return count;
1553}
1554
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001555static const struct file_operations viafb_dvp1_proc_fops = {
1556 .owner = THIS_MODULE,
1557 .open = viafb_dvp1_proc_open,
1558 .read = seq_read,
1559 .llseek = seq_lseek,
1560 .release = single_release,
1561 .write = viafb_dvp1_proc_write,
1562};
1563
1564static int viafb_dfph_proc_show(struct seq_file *m, void *v)
Joseph Chan29b619f2008-10-15 22:03:27 -07001565{
Joseph Chan29b619f2008-10-15 22:03:27 -07001566 u8 dfp_high = 0;
1567 dfp_high = viafb_read_reg(VIACR, CR97) & 0x0f;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001568 seq_printf(m, "%x\n", dfp_high);
1569 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001570}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001571
1572static int viafb_dfph_proc_open(struct inode *inode, struct file *file)
1573{
1574 return single_open(file, viafb_dfph_proc_show, NULL);
1575}
1576
1577static ssize_t viafb_dfph_proc_write(struct file *file,
1578 const char __user *buffer, size_t count, loff_t *pos)
Joseph Chan29b619f2008-10-15 22:03:27 -07001579{
1580 char buf[20];
1581 u8 reg_val = 0;
1582 unsigned long length;
1583 if (count < 1)
1584 return -EINVAL;
1585 length = count > 20 ? 20 : count;
1586 if (copy_from_user(&buf[0], buffer, length))
1587 return -EFAULT;
1588 buf[length - 1] = '\0'; /*Ensure end string */
1589 strict_strtoul(&buf[0], 0, (unsigned long *)&reg_val);
1590 viafb_write_reg_mask(CR97, VIACR, reg_val, 0x0f);
1591 return count;
1592}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001593
1594static const struct file_operations viafb_dfph_proc_fops = {
1595 .owner = THIS_MODULE,
1596 .open = viafb_dfph_proc_open,
1597 .read = seq_read,
1598 .llseek = seq_lseek,
1599 .release = single_release,
1600 .write = viafb_dfph_proc_write,
1601};
1602
1603static int viafb_dfpl_proc_show(struct seq_file *m, void *v)
Joseph Chan29b619f2008-10-15 22:03:27 -07001604{
Joseph Chan29b619f2008-10-15 22:03:27 -07001605 u8 dfp_low = 0;
1606 dfp_low = viafb_read_reg(VIACR, CR99) & 0x0f;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001607 seq_printf(m, "%x\n", dfp_low);
1608 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001609}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001610
1611static int viafb_dfpl_proc_open(struct inode *inode, struct file *file)
1612{
1613 return single_open(file, viafb_dfpl_proc_show, NULL);
1614}
1615
1616static ssize_t viafb_dfpl_proc_write(struct file *file,
1617 const char __user *buffer, size_t count, loff_t *pos)
Joseph Chan29b619f2008-10-15 22:03:27 -07001618{
1619 char buf[20];
1620 u8 reg_val = 0;
1621 unsigned long length;
1622 if (count < 1)
1623 return -EINVAL;
1624 length = count > 20 ? 20 : count;
1625 if (copy_from_user(&buf[0], buffer, length))
1626 return -EFAULT;
1627 buf[length - 1] = '\0'; /*Ensure end string */
1628 strict_strtoul(&buf[0], 0, (unsigned long *)&reg_val);
1629 viafb_write_reg_mask(CR99, VIACR, reg_val, 0x0f);
1630 return count;
1631}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001632
1633static const struct file_operations viafb_dfpl_proc_fops = {
1634 .owner = THIS_MODULE,
1635 .open = viafb_dfpl_proc_open,
1636 .read = seq_read,
1637 .llseek = seq_lseek,
1638 .release = single_release,
1639 .write = viafb_dfpl_proc_write,
1640};
1641
1642static int viafb_vt1636_proc_show(struct seq_file *m, void *v)
Joseph Chan29b619f2008-10-15 22:03:27 -07001643{
Joseph Chan29b619f2008-10-15 22:03:27 -07001644 u8 vt1636_08 = 0, vt1636_09 = 0;
1645 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1646 case VT1636_LVDS:
1647 vt1636_08 =
1648 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
1649 &viaparinfo->chip_info->lvds_chip_info, 0x08) & 0x0f;
1650 vt1636_09 =
1651 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
1652 &viaparinfo->chip_info->lvds_chip_info, 0x09) & 0x1f;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001653 seq_printf(m, "%x %x\n", vt1636_08, vt1636_09);
Joseph Chan29b619f2008-10-15 22:03:27 -07001654 break;
1655 default:
1656 break;
1657 }
1658 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
1659 case VT1636_LVDS:
1660 vt1636_08 =
1661 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
1662 &viaparinfo->chip_info->lvds_chip_info2, 0x08) & 0x0f;
1663 vt1636_09 =
1664 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
1665 &viaparinfo->chip_info->lvds_chip_info2, 0x09) & 0x1f;
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001666 seq_printf(m, " %x %x\n", vt1636_08, vt1636_09);
Joseph Chan29b619f2008-10-15 22:03:27 -07001667 break;
1668 default:
1669 break;
1670 }
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001671 return 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001672}
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001673
1674static int viafb_vt1636_proc_open(struct inode *inode, struct file *file)
1675{
1676 return single_open(file, viafb_vt1636_proc_show, NULL);
1677}
1678
1679static ssize_t viafb_vt1636_proc_write(struct file *file,
1680 const char __user *buffer, size_t count, loff_t *pos)
Joseph Chan29b619f2008-10-15 22:03:27 -07001681{
1682 char buf[30], *value, *pbuf;
1683 struct IODATA reg_val;
1684 unsigned long length, i;
1685 if (count < 1)
1686 return -EINVAL;
1687 length = count > 30 ? 30 : count;
1688 if (copy_from_user(&buf[0], buffer, length))
1689 return -EFAULT;
1690 buf[length - 1] = '\0'; /*Ensure end string */
1691 pbuf = &buf[0];
1692 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1693 case VT1636_LVDS:
1694 for (i = 0; i < 2; i++) {
1695 value = strsep(&pbuf, " ");
1696 if (value != NULL) {
1697 strict_strtoul(value, 0,
1698 (unsigned long *)&reg_val.Data);
1699 switch (i) {
1700 case 0:
1701 reg_val.Index = 0x08;
1702 reg_val.Mask = 0x0f;
1703 viafb_gpio_i2c_write_mask_lvds
1704 (viaparinfo->lvds_setting_info,
1705 &viaparinfo->
1706 chip_info->lvds_chip_info,
1707 reg_val);
1708 break;
1709 case 1:
1710 reg_val.Index = 0x09;
1711 reg_val.Mask = 0x1f;
1712 viafb_gpio_i2c_write_mask_lvds
1713 (viaparinfo->lvds_setting_info,
1714 &viaparinfo->
1715 chip_info->lvds_chip_info,
1716 reg_val);
1717 break;
1718 default:
1719 break;
1720 }
1721 } else {
1722 break;
1723 }
1724 }
1725 break;
1726 default:
1727 break;
1728 }
1729 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
1730 case VT1636_LVDS:
1731 for (i = 0; i < 2; i++) {
1732 value = strsep(&pbuf, " ");
1733 if (value != NULL) {
1734 strict_strtoul(value, 0,
1735 (unsigned long *)&reg_val.Data);
1736 switch (i) {
1737 case 0:
1738 reg_val.Index = 0x08;
1739 reg_val.Mask = 0x0f;
1740 viafb_gpio_i2c_write_mask_lvds
1741 (viaparinfo->lvds_setting_info2,
1742 &viaparinfo->
1743 chip_info->lvds_chip_info2,
1744 reg_val);
1745 break;
1746 case 1:
1747 reg_val.Index = 0x09;
1748 reg_val.Mask = 0x1f;
1749 viafb_gpio_i2c_write_mask_lvds
1750 (viaparinfo->lvds_setting_info2,
1751 &viaparinfo->
1752 chip_info->lvds_chip_info2,
1753 reg_val);
1754 break;
1755 default:
1756 break;
1757 }
1758 } else {
1759 break;
1760 }
1761 }
1762 break;
1763 default:
1764 break;
1765 }
1766 return count;
1767}
1768
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001769static const struct file_operations viafb_vt1636_proc_fops = {
1770 .owner = THIS_MODULE,
1771 .open = viafb_vt1636_proc_open,
1772 .read = seq_read,
1773 .llseek = seq_lseek,
1774 .release = single_release,
1775 .write = viafb_vt1636_proc_write,
1776};
1777
Bruno Prémontc267fd72008-11-19 15:36:23 -08001778static void viafb_init_proc(struct proc_dir_entry **viafb_entry)
Joseph Chan29b619f2008-10-15 22:03:27 -07001779{
Bruno Prémontc267fd72008-11-19 15:36:23 -08001780 *viafb_entry = proc_mkdir("viafb", NULL);
Dan Carpenter8130b3b2009-12-15 16:46:36 -08001781 if (*viafb_entry) {
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001782 proc_create("dvp0", 0, *viafb_entry, &viafb_dvp0_proc_fops);
1783 proc_create("dvp1", 0, *viafb_entry, &viafb_dvp1_proc_fops);
1784 proc_create("dfph", 0, *viafb_entry, &viafb_dfph_proc_fops);
1785 proc_create("dfpl", 0, *viafb_entry, &viafb_dfpl_proc_fops);
Joseph Chan29b619f2008-10-15 22:03:27 -07001786 if (VT1636_LVDS == viaparinfo->chip_info->lvds_chip_info.
1787 lvds_chip_name || VT1636_LVDS ==
1788 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
Alexey Dobriyanafbd3c12009-09-22 16:47:27 -07001789 proc_create("vt1636", 0, *viafb_entry, &viafb_vt1636_proc_fops);
Joseph Chan29b619f2008-10-15 22:03:27 -07001790 }
1791
1792 }
1793}
1794static void viafb_remove_proc(struct proc_dir_entry *viafb_entry)
1795{
1796 /* no problem if it was not registered */
1797 remove_proc_entry("dvp0", viafb_entry);/* parent dir */
1798 remove_proc_entry("dvp1", viafb_entry);
1799 remove_proc_entry("dfph", viafb_entry);
1800 remove_proc_entry("dfpl", viafb_entry);
1801 remove_proc_entry("vt1636", viafb_entry);
1802 remove_proc_entry("vt1625", viafb_entry);
Bruno Prémontc267fd72008-11-19 15:36:23 -08001803 remove_proc_entry("viafb", NULL);
Joseph Chan29b619f2008-10-15 22:03:27 -07001804}
1805
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001806static void parse_mode(const char *str, u32 *xres, u32 *yres)
1807{
1808 char *ptr;
1809
1810 *xres = simple_strtoul(str, &ptr, 10);
1811 if (ptr[0] != 'x')
1812 goto out_default;
1813
1814 *yres = simple_strtoul(&ptr[1], &ptr, 10);
1815 if (ptr[0])
1816 goto out_default;
1817
1818 return;
1819
1820out_default:
1821 printk(KERN_WARNING "viafb received invalid mode string: %s\n", str);
1822 *xres = 640;
1823 *yres = 480;
1824}
1825
Harald Welte2d280f72009-09-22 16:47:37 -07001826static int __devinit via_pci_probe(struct pci_dev *pdev,
1827 const struct pci_device_id *ent)
Joseph Chan29b619f2008-10-15 22:03:27 -07001828{
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001829 u32 default_xres, default_yres;
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -08001830 struct VideoModeTable *vmode_entry;
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001831 u32 viafb_par_length;
Joseph Chan29b619f2008-10-15 22:03:27 -07001832
1833 DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n");
1834
1835 viafb_par_length = ALIGN(sizeof(struct viafb_par), BITS_PER_LONG/8);
Joseph Chan29b619f2008-10-15 22:03:27 -07001836
1837 /* Allocate fb_info and ***_par here, also including some other needed
1838 * variables
1839 */
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001840 viafbinfo = framebuffer_alloc(viafb_par_length +
Harald Weltedb8df7b2009-09-22 16:47:38 -07001841 ALIGN(sizeof(struct viafb_shared), BITS_PER_LONG/8),
1842 &pdev->dev);
Joseph Chan29b619f2008-10-15 22:03:27 -07001843 if (!viafbinfo) {
1844 printk(KERN_ERR"Could not allocate memory for viafb_info.\n");
1845 return -ENODEV;
1846 }
1847
1848 viaparinfo = (struct viafb_par *)viafbinfo->par;
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001849 viaparinfo->shared = viafbinfo->par + viafb_par_length;
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -07001850 viaparinfo->vram_addr = 0;
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001851 viaparinfo->tmds_setting_info = &viaparinfo->shared->tmds_setting_info;
1852 viaparinfo->lvds_setting_info = &viaparinfo->shared->lvds_setting_info;
1853 viaparinfo->lvds_setting_info2 =
1854 &viaparinfo->shared->lvds_setting_info2;
1855 viaparinfo->crt_setting_info = &viaparinfo->shared->crt_setting_info;
1856 viaparinfo->chip_info = &viaparinfo->shared->chip_info;
Joseph Chan29b619f2008-10-15 22:03:27 -07001857
1858 if (viafb_dual_fb)
1859 viafb_SAMM_ON = 1;
1860 parse_active_dev();
Joseph Chan29b619f2008-10-15 22:03:27 -07001861 parse_lcd_port();
1862 parse_dvi_port();
1863
1864 /* for dual-fb must viafb_SAMM_ON=1 and viafb_dual_fb=1 */
1865 if (!viafb_SAMM_ON)
1866 viafb_dual_fb = 0;
1867
1868 /* Set up I2C bus stuff */
1869 viafb_create_i2c_bus(viaparinfo);
1870
Harald Welte2d280f72009-09-22 16:47:37 -07001871 viafb_init_chip_info(pdev, ent);
1872 viaparinfo->fbmem = pci_resource_start(pdev, 0);
1873 viaparinfo->memsize = viafb_get_fb_size_from_pci();
Joseph Chan29b619f2008-10-15 22:03:27 -07001874 viaparinfo->fbmem_free = viaparinfo->memsize;
1875 viaparinfo->fbmem_used = 0;
Florian Tobias Schandinatdb88e382009-09-22 16:47:20 -07001876 viafbinfo->screen_base = ioremap_nocache(viaparinfo->fbmem,
Joseph Chan29b619f2008-10-15 22:03:27 -07001877 viaparinfo->memsize);
Florian Tobias Schandinatdb88e382009-09-22 16:47:20 -07001878 if (!viafbinfo->screen_base) {
Joseph Chan29b619f2008-10-15 22:03:27 -07001879 printk(KERN_INFO "ioremap failed\n");
Florian Tobias Schandinatbc6932b2009-09-22 16:47:15 -07001880 return -ENOMEM;
Joseph Chan29b619f2008-10-15 22:03:27 -07001881 }
1882
Harald Welte2d280f72009-09-22 16:47:37 -07001883 viafbinfo->fix.mmio_start = pci_resource_start(pdev, 1);
1884 viafbinfo->fix.mmio_len = pci_resource_len(pdev, 1);
Joseph Chan29b619f2008-10-15 22:03:27 -07001885 viafbinfo->node = 0;
1886 viafbinfo->fbops = &viafb_ops;
1887 viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
1888
1889 viafbinfo->pseudo_palette = pseudo_pal;
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -07001890 if (viafb_accel && !viafb_init_engine(viafbinfo)) {
1891 viafbinfo->flags |= FBINFO_HWACCEL_COPYAREA |
1892 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_IMAGEBLIT;
1893 default_var.accel_flags = FB_ACCELF_TEXT;
1894 } else {
1895 viafbinfo->flags |= FBINFO_HWACCEL_DISABLED;
1896 default_var.accel_flags = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001897 }
1898
1899 if (viafb_second_size && (viafb_second_size < 8)) {
1900 viafb_second_offset = viaparinfo->fbmem_free -
1901 viafb_second_size * 1024 * 1024;
1902 } else {
1903 viafb_second_size = 8;
1904 viafb_second_offset = viaparinfo->fbmem_free -
1905 viafb_second_size * 1024 * 1024;
1906 }
1907
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001908 parse_mode(viafb_mode, &default_xres, &default_yres);
Florian Tobias Schandinatdd73d682010-03-10 15:21:28 -08001909 vmode_entry = viafb_get_mode(default_xres, default_yres);
Joseph Chan29b619f2008-10-15 22:03:27 -07001910 if (viafb_SAMM_ON == 1) {
Florian Tobias Schandinat5ff32f62009-09-22 16:47:34 -07001911 parse_mode(viafb_mode1, &viafb_second_xres,
1912 &viafb_second_yres);
1913
Joseph Chan29b619f2008-10-15 22:03:27 -07001914 if (0 == viafb_second_virtual_xres) {
1915 switch (viafb_second_xres) {
1916 case 1400:
1917 viafb_second_virtual_xres = 1408;
1918 break;
1919 default:
1920 viafb_second_virtual_xres = viafb_second_xres;
1921 break;
1922 }
1923 }
1924 if (0 == viafb_second_virtual_yres)
1925 viafb_second_virtual_yres = viafb_second_yres;
1926 }
1927
1928 switch (viafb_bpp) {
1929 case 0 ... 8:
1930 viafb_bpp = 8;
1931 break;
1932 case 9 ... 16:
1933 viafb_bpp = 16;
1934 break;
1935 case 17 ... 32:
1936 viafb_bpp = 32;
1937 break;
1938 default:
1939 viafb_bpp = 8;
1940 }
1941 default_var.xres = default_xres;
1942 default_var.yres = default_yres;
1943 switch (default_xres) {
1944 case 1400:
1945 default_var.xres_virtual = 1408;
1946 break;
1947 default:
1948 default_var.xres_virtual = default_xres;
1949 break;
1950 }
1951 default_var.yres_virtual = default_yres;
1952 default_var.bits_per_pixel = viafb_bpp;
1953 if (default_var.bits_per_pixel == 15)
1954 default_var.bits_per_pixel = 16;
1955 default_var.pixclock =
1956 viafb_get_pixclock(default_xres, default_yres, viafb_refresh);
1957 default_var.left_margin = (default_xres >> 3) & 0xf8;
1958 default_var.right_margin = 32;
1959 default_var.upper_margin = 16;
1960 default_var.lower_margin = 4;
1961 default_var.hsync_len = default_var.left_margin;
1962 default_var.vsync_len = 4;
Joseph Chan29b619f2008-10-15 22:03:27 -07001963
1964 if (viafb_dual_fb) {
Harald Weltedb8df7b2009-09-22 16:47:38 -07001965 viafbinfo1 = framebuffer_alloc(viafb_par_length, &pdev->dev);
Joseph Chan29b619f2008-10-15 22:03:27 -07001966 if (!viafbinfo1) {
1967 printk(KERN_ERR
1968 "allocate the second framebuffer struct error\n");
1969 framebuffer_release(viafbinfo);
1970 return -ENOMEM;
1971 }
1972 viaparinfo1 = viafbinfo1->par;
1973 memcpy(viaparinfo1, viaparinfo, viafb_par_length);
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -07001974 viaparinfo1->vram_addr = viafb_second_offset;
Joseph Chan29b619f2008-10-15 22:03:27 -07001975 viaparinfo1->memsize = viaparinfo->memsize -
1976 viafb_second_offset;
1977 viaparinfo->memsize = viafb_second_offset;
Joseph Chan29b619f2008-10-15 22:03:27 -07001978 viaparinfo1->fbmem = viaparinfo->fbmem + viafb_second_offset;
1979
1980 viaparinfo1->fbmem_used = viaparinfo->fbmem_used;
1981 viaparinfo1->fbmem_free = viaparinfo1->memsize -
1982 viaparinfo1->fbmem_used;
1983 viaparinfo->fbmem_free = viaparinfo->memsize;
1984 viaparinfo->fbmem_used = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001985
Florian Tobias Schandinat09cf1182009-09-22 16:47:14 -07001986 viaparinfo->iga_path = IGA1;
1987 viaparinfo1->iga_path = IGA2;
Joseph Chan29b619f2008-10-15 22:03:27 -07001988 memcpy(viafbinfo1, viafbinfo, sizeof(struct fb_info));
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07001989 viafbinfo1->par = viaparinfo1;
Joseph Chan29b619f2008-10-15 22:03:27 -07001990 viafbinfo1->screen_base = viafbinfo->screen_base +
1991 viafb_second_offset;
Joseph Chan29b619f2008-10-15 22:03:27 -07001992
1993 default_var.xres = viafb_second_xres;
1994 default_var.yres = viafb_second_yres;
1995 default_var.xres_virtual = viafb_second_virtual_xres;
1996 default_var.yres_virtual = viafb_second_virtual_yres;
1997 if (viafb_bpp1 != viafb_bpp)
1998 viafb_bpp1 = viafb_bpp;
1999 default_var.bits_per_pixel = viafb_bpp1;
2000 default_var.pixclock =
2001 viafb_get_pixclock(viafb_second_xres, viafb_second_yres,
2002 viafb_refresh);
2003 default_var.left_margin = (viafb_second_xres >> 3) & 0xf8;
2004 default_var.right_margin = 32;
2005 default_var.upper_margin = 16;
2006 default_var.lower_margin = 4;
2007 default_var.hsync_len = default_var.left_margin;
2008 default_var.vsync_len = 4;
2009
2010 viafb_setup_fixinfo(&viafbinfo1->fix, viaparinfo1);
2011 viafb_check_var(&default_var, viafbinfo1);
2012 viafbinfo1->var = default_var;
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -07002013 viafb_update_fix(viafbinfo1);
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -07002014 viaparinfo1->depth = fb_get_color_depth(&viafbinfo1->var,
2015 &viafbinfo1->fix);
Joseph Chan29b619f2008-10-15 22:03:27 -07002016 }
2017
2018 viafb_setup_fixinfo(&viafbinfo->fix, viaparinfo);
2019 viafb_check_var(&default_var, viafbinfo);
2020 viafbinfo->var = default_var;
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -07002021 viafb_update_fix(viafbinfo);
Florian Tobias Schandinatc3e25672009-09-22 16:47:26 -07002022 viaparinfo->depth = fb_get_color_depth(&viafbinfo->var,
2023 &viafbinfo->fix);
Joseph Chan29b619f2008-10-15 22:03:27 -07002024 default_var.activate = FB_ACTIVATE_NOW;
2025 fb_alloc_cmap(&viafbinfo->cmap, 256, 0);
2026
2027 if (viafb_dual_fb && (viafb_primary_dev == LCD_Device)
2028 && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) {
2029 if (register_framebuffer(viafbinfo1) < 0)
2030 return -EINVAL;
2031 }
2032 if (register_framebuffer(viafbinfo) < 0)
2033 return -EINVAL;
2034
2035 if (viafb_dual_fb && ((viafb_primary_dev != LCD_Device)
2036 || (viaparinfo->chip_info->gfx_chip_name !=
2037 UNICHROME_CLE266))) {
2038 if (register_framebuffer(viafbinfo1) < 0)
2039 return -EINVAL;
2040 }
2041 DEBUG_MSG(KERN_INFO "fb%d: %s frame buffer device %dx%d-%dbpp\n",
2042 viafbinfo->node, viafbinfo->fix.id, default_var.xres,
2043 default_var.yres, default_var.bits_per_pixel);
2044
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07002045 viafb_init_proc(&viaparinfo->shared->proc_entry);
Joseph Chan29b619f2008-10-15 22:03:27 -07002046 viafb_init_dac(IGA2);
2047 return 0;
2048}
2049
Harald Welte2d280f72009-09-22 16:47:37 -07002050static void __devexit via_pci_remove(struct pci_dev *pdev)
Joseph Chan29b619f2008-10-15 22:03:27 -07002051{
2052 DEBUG_MSG(KERN_INFO "via_pci_remove!\n");
2053 fb_dealloc_cmap(&viafbinfo->cmap);
2054 unregister_framebuffer(viafbinfo);
2055 if (viafb_dual_fb)
2056 unregister_framebuffer(viafbinfo1);
Florian Tobias Schandinatdb88e382009-09-22 16:47:20 -07002057 iounmap((void *)viafbinfo->screen_base);
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -07002058 iounmap(viaparinfo->shared->engine_mmio);
Joseph Chan29b619f2008-10-15 22:03:27 -07002059
2060 viafb_delete_i2c_buss(viaparinfo);
2061
2062 framebuffer_release(viafbinfo);
2063 if (viafb_dual_fb)
2064 framebuffer_release(viafbinfo1);
2065
Florian Tobias Schandinatc4df5482009-09-22 16:47:24 -07002066 viafb_remove_proc(viaparinfo->shared->proc_entry);
Joseph Chan29b619f2008-10-15 22:03:27 -07002067}
2068
2069#ifndef MODULE
2070static int __init viafb_setup(char *options)
2071{
2072 char *this_opt;
2073 DEBUG_MSG(KERN_INFO "viafb_setup!\n");
2074
2075 if (!options || !*options)
2076 return 0;
2077
2078 while ((this_opt = strsep(&options, ",")) != NULL) {
2079 if (!*this_opt)
2080 continue;
2081
2082 if (!strncmp(this_opt, "viafb_mode1=", 12))
2083 viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL);
2084 else if (!strncmp(this_opt, "viafb_mode=", 11))
2085 viafb_mode = kstrdup(this_opt + 11, GFP_KERNEL);
2086 else if (!strncmp(this_opt, "viafb_bpp1=", 11))
2087 strict_strtoul(this_opt + 11, 0,
2088 (unsigned long *)&viafb_bpp1);
2089 else if (!strncmp(this_opt, "viafb_bpp=", 10))
2090 strict_strtoul(this_opt + 10, 0,
2091 (unsigned long *)&viafb_bpp);
2092 else if (!strncmp(this_opt, "viafb_refresh1=", 15))
2093 strict_strtoul(this_opt + 15, 0,
2094 (unsigned long *)&viafb_refresh1);
2095 else if (!strncmp(this_opt, "viafb_refresh=", 14))
2096 strict_strtoul(this_opt + 14, 0,
2097 (unsigned long *)&viafb_refresh);
2098 else if (!strncmp(this_opt, "viafb_lcd_dsp_method=", 21))
2099 strict_strtoul(this_opt + 21, 0,
2100 (unsigned long *)&viafb_lcd_dsp_method);
2101 else if (!strncmp(this_opt, "viafb_lcd_panel_id=", 19))
2102 strict_strtoul(this_opt + 19, 0,
2103 (unsigned long *)&viafb_lcd_panel_id);
2104 else if (!strncmp(this_opt, "viafb_accel=", 12))
2105 strict_strtoul(this_opt + 12, 0,
2106 (unsigned long *)&viafb_accel);
2107 else if (!strncmp(this_opt, "viafb_SAMM_ON=", 14))
2108 strict_strtoul(this_opt + 14, 0,
2109 (unsigned long *)&viafb_SAMM_ON);
2110 else if (!strncmp(this_opt, "viafb_active_dev=", 17))
2111 viafb_active_dev = kstrdup(this_opt + 17, GFP_KERNEL);
2112 else if (!strncmp(this_opt,
2113 "viafb_display_hardware_layout=", 30))
2114 strict_strtoul(this_opt + 30, 0,
2115 (unsigned long *)&viafb_display_hardware_layout);
2116 else if (!strncmp(this_opt, "viafb_second_size=", 18))
2117 strict_strtoul(this_opt + 18, 0,
2118 (unsigned long *)&viafb_second_size);
2119 else if (!strncmp(this_opt,
2120 "viafb_platform_epia_dvi=", 24))
2121 strict_strtoul(this_opt + 24, 0,
2122 (unsigned long *)&viafb_platform_epia_dvi);
2123 else if (!strncmp(this_opt,
2124 "viafb_device_lcd_dualedge=", 26))
2125 strict_strtoul(this_opt + 26, 0,
2126 (unsigned long *)&viafb_device_lcd_dualedge);
2127 else if (!strncmp(this_opt, "viafb_bus_width=", 16))
2128 strict_strtoul(this_opt + 16, 0,
2129 (unsigned long *)&viafb_bus_width);
2130 else if (!strncmp(this_opt, "viafb_lcd_mode=", 15))
2131 strict_strtoul(this_opt + 15, 0,
2132 (unsigned long *)&viafb_lcd_mode);
Joseph Chan29b619f2008-10-15 22:03:27 -07002133 else if (!strncmp(this_opt, "viafb_lcd_port=", 15))
2134 viafb_lcd_port = kstrdup(this_opt + 15, GFP_KERNEL);
2135 else if (!strncmp(this_opt, "viafb_dvi_port=", 15))
2136 viafb_dvi_port = kstrdup(this_opt + 15, GFP_KERNEL);
2137 }
2138 return 0;
2139}
2140#endif
2141
Harald Welte2d280f72009-09-22 16:47:37 -07002142static struct pci_device_id viafb_pci_table[] __devinitdata = {
2143 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CLE266_DID),
2144 .driver_data = UNICHROME_CLE266 },
2145 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_PM800_DID),
2146 .driver_data = UNICHROME_PM800 },
2147 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K400_DID),
2148 .driver_data = UNICHROME_K400 },
2149 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K800_DID),
2150 .driver_data = UNICHROME_K800 },
2151 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_P4M890_DID),
2152 .driver_data = UNICHROME_CN700 },
2153 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K8M890_DID),
2154 .driver_data = UNICHROME_K8M890 },
2155 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CX700_DID),
2156 .driver_data = UNICHROME_CX700 },
2157 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_P4M900_DID),
2158 .driver_data = UNICHROME_P4M900 },
2159 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CN750_DID),
2160 .driver_data = UNICHROME_CN750 },
2161 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX800_DID),
2162 .driver_data = UNICHROME_VX800 },
2163 { PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX855_DID),
2164 .driver_data = UNICHROME_VX855 },
2165 { }
2166};
2167MODULE_DEVICE_TABLE(pci, viafb_pci_table);
2168
2169static struct pci_driver viafb_driver = {
2170 .name = "viafb",
2171 .id_table = viafb_pci_table,
2172 .probe = via_pci_probe,
2173 .remove = __devexit_p(via_pci_remove),
2174};
2175
Joseph Chan29b619f2008-10-15 22:03:27 -07002176static int __init viafb_init(void)
2177{
2178#ifndef MODULE
2179 char *option = NULL;
2180 if (fb_get_options("viafb", &option))
2181 return -ENODEV;
2182 viafb_setup(option);
2183#endif
2184 printk(KERN_INFO
2185 "VIA Graphics Intergration Chipset framebuffer %d.%d initializing\n",
2186 VERSION_MAJOR, VERSION_MINOR);
Harald Welte2d280f72009-09-22 16:47:37 -07002187 return pci_register_driver(&viafb_driver);
Joseph Chan29b619f2008-10-15 22:03:27 -07002188}
2189
2190static void __exit viafb_exit(void)
2191{
2192 DEBUG_MSG(KERN_INFO "viafb_exit!\n");
Harald Welte2d280f72009-09-22 16:47:37 -07002193 pci_unregister_driver(&viafb_driver);
Joseph Chan29b619f2008-10-15 22:03:27 -07002194}
2195
2196static struct fb_ops viafb_ops = {
2197 .owner = THIS_MODULE,
2198 .fb_open = viafb_open,
2199 .fb_release = viafb_release,
2200 .fb_check_var = viafb_check_var,
2201 .fb_set_par = viafb_set_par,
2202 .fb_setcolreg = viafb_setcolreg,
2203 .fb_pan_display = viafb_pan_display,
2204 .fb_blank = viafb_blank,
2205 .fb_fillrect = viafb_fillrect,
2206 .fb_copyarea = viafb_copyarea,
2207 .fb_imageblit = viafb_imageblit,
2208 .fb_cursor = viafb_cursor,
2209 .fb_ioctl = viafb_ioctl,
2210 .fb_sync = viafb_sync,
2211 .fb_setcmap = viafb_setcmap,
2212};
2213
2214module_init(viafb_init);
2215module_exit(viafb_exit);
2216
2217#ifdef MODULE
Harald Welte93967be2009-09-22 16:47:32 -07002218module_param(viafb_memsize, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002219
Harald Welte93967be2009-09-22 16:47:32 -07002220module_param(viafb_mode, charp, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002221MODULE_PARM_DESC(viafb_mode, "Set resolution (default=640x480)");
2222
Harald Welte93967be2009-09-22 16:47:32 -07002223module_param(viafb_mode1, charp, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002224MODULE_PARM_DESC(viafb_mode1, "Set resolution (default=640x480)");
2225
Harald Welte93967be2009-09-22 16:47:32 -07002226module_param(viafb_bpp, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002227MODULE_PARM_DESC(viafb_bpp, "Set color depth (default=32bpp)");
2228
Harald Welte93967be2009-09-22 16:47:32 -07002229module_param(viafb_bpp1, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002230MODULE_PARM_DESC(viafb_bpp1, "Set color depth (default=32bpp)");
2231
Harald Welte93967be2009-09-22 16:47:32 -07002232module_param(viafb_refresh, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002233MODULE_PARM_DESC(viafb_refresh,
2234 "Set CRT viafb_refresh rate (default = 60)");
2235
Harald Welte93967be2009-09-22 16:47:32 -07002236module_param(viafb_refresh1, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002237MODULE_PARM_DESC(viafb_refresh1,
2238 "Set CRT refresh rate (default = 60)");
2239
Harald Welte93967be2009-09-22 16:47:32 -07002240module_param(viafb_lcd_panel_id, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002241MODULE_PARM_DESC(viafb_lcd_panel_id,
2242 "Set Flat Panel type(Default=1024x768)");
2243
Harald Welte93967be2009-09-22 16:47:32 -07002244module_param(viafb_lcd_dsp_method, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002245MODULE_PARM_DESC(viafb_lcd_dsp_method,
2246 "Set Flat Panel display scaling method.(Default=Expandsion)");
2247
Harald Welte93967be2009-09-22 16:47:32 -07002248module_param(viafb_SAMM_ON, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002249MODULE_PARM_DESC(viafb_SAMM_ON,
2250 "Turn on/off flag of SAMM(Default=OFF)");
2251
Harald Welte93967be2009-09-22 16:47:32 -07002252module_param(viafb_accel, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002253MODULE_PARM_DESC(viafb_accel,
Florian Tobias Schandinat31de59d2009-09-22 16:47:31 -07002254 "Set 2D Hardware Acceleration: 0 = OFF, 1 = ON (default)");
Joseph Chan29b619f2008-10-15 22:03:27 -07002255
Harald Welte93967be2009-09-22 16:47:32 -07002256module_param(viafb_active_dev, charp, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002257MODULE_PARM_DESC(viafb_active_dev, "Specify active devices.");
2258
Harald Welte93967be2009-09-22 16:47:32 -07002259module_param(viafb_display_hardware_layout, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002260MODULE_PARM_DESC(viafb_display_hardware_layout,
2261 "Display Hardware Layout (LCD Only, DVI Only...,etc)");
2262
Harald Welte93967be2009-09-22 16:47:32 -07002263module_param(viafb_second_size, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002264MODULE_PARM_DESC(viafb_second_size,
2265 "Set secondary device memory size");
2266
Harald Welte93967be2009-09-22 16:47:32 -07002267module_param(viafb_dual_fb, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002268MODULE_PARM_DESC(viafb_dual_fb,
2269 "Turn on/off flag of dual framebuffer devices.(Default = OFF)");
2270
Harald Welte93967be2009-09-22 16:47:32 -07002271module_param(viafb_platform_epia_dvi, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002272MODULE_PARM_DESC(viafb_platform_epia_dvi,
2273 "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)");
2274
Harald Welte93967be2009-09-22 16:47:32 -07002275module_param(viafb_device_lcd_dualedge, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002276MODULE_PARM_DESC(viafb_device_lcd_dualedge,
2277 "Turn on/off flag of dual edge panel.(Default = OFF)");
2278
Harald Welte93967be2009-09-22 16:47:32 -07002279module_param(viafb_bus_width, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002280MODULE_PARM_DESC(viafb_bus_width,
2281 "Set bus width of panel.(Default = 12)");
2282
Harald Welte93967be2009-09-22 16:47:32 -07002283module_param(viafb_lcd_mode, int, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002284MODULE_PARM_DESC(viafb_lcd_mode,
2285 "Set Flat Panel mode(Default=OPENLDI)");
2286
Harald Welte93967be2009-09-22 16:47:32 -07002287module_param(viafb_lcd_port, charp, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002288MODULE_PARM_DESC(viafb_lcd_port, "Specify LCD output port.");
2289
Harald Welte93967be2009-09-22 16:47:32 -07002290module_param(viafb_dvi_port, charp, S_IRUSR);
Joseph Chan29b619f2008-10-15 22:03:27 -07002291MODULE_PARM_DESC(viafb_dvi_port, "Specify DVI output port.");
2292
2293MODULE_LICENSE("GPL");
2294#endif