blob: 743eed48a5f707976c6f9e38ff6aa5eb963a289f [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>
23#define _MASTER_FILE
24
25#include "global.h"
26
27static int MAX_CURS = 32;
28static struct fb_var_screeninfo default_var;
29static char *viafb_name = "Via";
30static u32 pseudo_pal[17];
31
32/* video mode */
33static char *viafb_mode = "640x480";
34static char *viafb_mode1 = "640x480";
Joseph Chan29b619f2008-10-15 22:03:27 -070035
36/* Added for specifying active devices.*/
37char *viafb_active_dev = "";
38
39/* Added for specifying video on devices.*/
40char *viafb_video_dev = "";
41
42/*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);
53static void viafb_set_video_device(u32 video_dev_info);
54static void viafb_get_video_device(u32 *video_dev_info);
55
56/* Mode information */
57static const struct viafb_modeinfo viafb_modentry[] = {
Florian Tobias Schandinat52159442009-08-06 15:07:34 -070058 {480, 640, VIA_RES_480X640},
59 {640, 480, VIA_RES_640X480},
60 {800, 480, VIA_RES_800X480},
61 {800, 600, VIA_RES_800X600},
62 {1024, 768, VIA_RES_1024X768},
63 {1152, 864, VIA_RES_1152X864},
64 {1280, 1024, VIA_RES_1280X1024},
65 {1600, 1200, VIA_RES_1600X1200},
66 {1440, 1050, VIA_RES_1440X1050},
67 {1280, 768, VIA_RES_1280X768,},
68 {1280, 800, VIA_RES_1280X800},
69 {1280, 960, VIA_RES_1280X960},
70 {1920, 1440, VIA_RES_1920X1440},
71 {848, 480, VIA_RES_848X480},
72 {1400, 1050, VIA_RES_1400X1050},
73 {720, 480, VIA_RES_720X480},
74 {720, 576, VIA_RES_720X576},
75 {1024, 512, VIA_RES_1024X512},
76 {1024, 576, VIA_RES_1024X576},
77 {1024, 600, VIA_RES_1024X600},
78 {1280, 720, VIA_RES_1280X720},
79 {1920, 1080, VIA_RES_1920X1080},
80 {1366, 768, VIA_RES_1368X768},
81 {1680, 1050, VIA_RES_1680X1050},
82 {960, 600, VIA_RES_960X600},
83 {1000, 600, VIA_RES_1000X600},
84 {1024, 576, VIA_RES_1024X576},
85 {1024, 600, VIA_RES_1024X600},
86 {1088, 612, VIA_RES_1088X612},
87 {1152, 720, VIA_RES_1152X720},
88 {1200, 720, VIA_RES_1200X720},
89 {1280, 600, VIA_RES_1280X600},
90 {1360, 768, VIA_RES_1360X768},
91 {1440, 900, VIA_RES_1440X900},
92 {1600, 900, VIA_RES_1600X900},
93 {1600, 1024, VIA_RES_1600X1024},
94 {1792, 1344, VIA_RES_1792X1344},
95 {1856, 1392, VIA_RES_1856X1392},
96 {1920, 1200, VIA_RES_1920X1200},
97 {2048, 1536, VIA_RES_2048X1536},
98 {0, 0, VIA_RES_INVALID}
Joseph Chan29b619f2008-10-15 22:03:27 -070099};
100
101static struct fb_ops viafb_ops;
102
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -0700103
104static void viafb_update_fix(struct fb_info *info)
Joseph Chan29b619f2008-10-15 22:03:27 -0700105{
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -0700106 u32 bpp = info->var.bits_per_pixel;
Joseph Chan29b619f2008-10-15 22:03:27 -0700107
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -0700108 info->fix.visual =
109 bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
110 info->fix.line_length =
111 ((info->var.xres_virtual + 7) & ~7) * bpp / 8;
Joseph Chan29b619f2008-10-15 22:03:27 -0700112}
113
Joseph Chan29b619f2008-10-15 22:03:27 -0700114static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix,
115 struct viafb_par *viaparinfo)
116{
117 memset(fix, 0, sizeof(struct fb_fix_screeninfo));
118 strcpy(fix->id, viafb_name);
119
120 fix->smem_start = viaparinfo->fbmem;
121 fix->smem_len = viaparinfo->fbmem_free;
122 fix->mmio_start = viaparinfo->mmio_base;
123 fix->mmio_len = viaparinfo->mmio_len;
124
125 fix->type = FB_TYPE_PACKED_PIXELS;
126 fix->type_aux = 0;
127
128 fix->xpanstep = fix->ywrapstep = 0;
129 fix->ypanstep = 1;
130
131 /* Just tell the accel name */
132 viafbinfo->fix.accel = FB_ACCEL_VIA_UNICHROME;
133}
134static int viafb_open(struct fb_info *info, int user)
135{
136 DEBUG_MSG(KERN_INFO "viafb_open!\n");
137 return 0;
138}
139
140static int viafb_release(struct fb_info *info, int user)
141{
142 DEBUG_MSG(KERN_INFO "viafb_release!\n");
143 return 0;
144}
145
Joseph Chan29b619f2008-10-15 22:03:27 -0700146static int viafb_check_var(struct fb_var_screeninfo *var,
147 struct fb_info *info)
148{
149 int vmode_index, htotal, vtotal;
150 struct viafb_par *ppar;
151 u32 long_refresh;
152 struct viafb_par *p_viafb_par;
153 ppar = info->par;
154
155
156 DEBUG_MSG(KERN_INFO "viafb_check_var!\n");
157 /* Sanity check */
158 /* HW neither support interlacte nor double-scaned mode */
159 if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE)
160 return -EINVAL;
161
Florian Tobias Schandinat52159442009-08-06 15:07:34 -0700162 vmode_index = viafb_get_mode_index(var->xres, var->yres);
Joseph Chan29b619f2008-10-15 22:03:27 -0700163 if (vmode_index == VIA_RES_INVALID) {
164 DEBUG_MSG(KERN_INFO
165 "viafb: Mode %dx%dx%d not supported!!\n",
166 var->xres, var->yres, var->bits_per_pixel);
167 return -EINVAL;
168 }
169
170 if (24 == var->bits_per_pixel)
171 var->bits_per_pixel = 32;
172
173 if (var->bits_per_pixel != 8 && var->bits_per_pixel != 16 &&
174 var->bits_per_pixel != 32)
175 return -EINVAL;
176
177 if ((var->xres_virtual * (var->bits_per_pixel >> 3)) & 0x1F)
178 /*32 pixel alignment */
179 var->xres_virtual = (var->xres_virtual + 31) & ~31;
180 if (var->xres_virtual * var->yres_virtual * var->bits_per_pixel / 8 >
181 ppar->memsize)
182 return -EINVAL;
183
184 /* Based on var passed in to calculate the refresh,
185 * because our driver use some modes special.
186 */
187 htotal = var->xres + var->left_margin +
188 var->right_margin + var->hsync_len;
189 vtotal = var->yres + var->upper_margin +
190 var->lower_margin + var->vsync_len;
191 long_refresh = 1000000000UL / var->pixclock * 1000;
192 long_refresh /= (htotal * vtotal);
193
194 viafb_refresh = viafb_get_refresh(var->xres, var->yres, long_refresh);
195
196 /* Adjust var according to our driver's own table */
197 viafb_fill_var_timing_info(var, viafb_refresh, vmode_index);
198
199 /* This is indeed a patch for VT3353 */
200 if (!info->par)
201 return -1;
202 p_viafb_par = (struct viafb_par *)info->par;
203 if (p_viafb_par->chip_info->gfx_chip_name == UNICHROME_VX800)
204 var->accel_flags = 0;
205
206 return 0;
207}
208
209static int viafb_set_par(struct fb_info *info)
210{
211 int vmode_index;
212 int vmode_index1 = 0;
213 DEBUG_MSG(KERN_INFO "viafb_set_par!\n");
214
215 viafb_update_device_setting(info->var.xres, info->var.yres,
216 info->var.bits_per_pixel, viafb_refresh, 0);
217
Florian Tobias Schandinat52159442009-08-06 15:07:34 -0700218 vmode_index = viafb_get_mode_index(info->var.xres, info->var.yres);
Joseph Chan29b619f2008-10-15 22:03:27 -0700219
220 if (viafb_SAMM_ON == 1) {
221 DEBUG_MSG(KERN_INFO
222 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
223 viafb_second_xres, viafb_second_yres, viafb_bpp1);
224 vmode_index1 = viafb_get_mode_index(viafb_second_xres,
Florian Tobias Schandinat52159442009-08-06 15:07:34 -0700225 viafb_second_yres);
Joseph Chan29b619f2008-10-15 22:03:27 -0700226 DEBUG_MSG(KERN_INFO "->viafb_SAMM_ON: index=%d\n",
227 vmode_index1);
228
229 viafb_update_device_setting(viafb_second_xres,
230 viafb_second_yres, viafb_bpp1, viafb_refresh1, 1);
231 }
232
233 if (vmode_index != VIA_RES_INVALID) {
234 viafb_setmode(vmode_index, info->var.xres, info->var.yres,
235 info->var.bits_per_pixel, vmode_index1,
236 viafb_second_xres, viafb_second_yres, viafb_bpp1);
237
238 /*We should set memory offset according virtual_x */
239 /*Fix me:put this function into viafb_setmode */
240 viafb_memory_pitch_patch(info);
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -0700241 viafb_update_fix(info);
Joseph Chan29b619f2008-10-15 22:03:27 -0700242 viafb_bpp = info->var.bits_per_pixel;
243 /* Update viafb_accel, it is necessary to our 2D accelerate */
244 viafb_accel = info->var.accel_flags;
245
246 if (viafb_accel)
247 viafb_set_2d_color_depth(info->var.bits_per_pixel);
248 }
249
250 return 0;
251}
252
253/* Set one color register */
254static int viafb_setcolreg(unsigned regno, unsigned red, unsigned green,
255unsigned blue, unsigned transp, struct fb_info *info)
256{
257 u8 sr1a, sr1b, cr67, cr6a, rev = 0, shift = 10;
258 unsigned cmap_entries = (info->var.bits_per_pixel == 8) ? 256 : 16;
259 DEBUG_MSG(KERN_INFO "viafb_setcolreg!\n");
260 if (regno >= cmap_entries)
261 return 1;
262 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name) {
263 /*
264 * Read PCI bus 0,dev 0,function 0,index 0xF6 to get chip rev.
265 */
266 outl(0x80000000 | (0xf6 & ~3), (unsigned long)0xCF8);
267 rev = (inl((unsigned long)0xCFC) >> ((0xf6 & 3) * 8)) & 0xff;
268 }
269 switch (info->var.bits_per_pixel) {
270 case 8:
271 outb(0x1A, 0x3C4);
272 sr1a = inb(0x3C5);
273 outb(0x1B, 0x3C4);
274 sr1b = inb(0x3C5);
275 outb(0x67, 0x3D4);
276 cr67 = inb(0x3D5);
277 outb(0x6A, 0x3D4);
278 cr6a = inb(0x3D5);
279
280 /* Map the 3C6/7/8/9 to the IGA2 */
281 outb(0x1A, 0x3C4);
282 outb(sr1a | 0x01, 0x3C5);
283 /* Second Display Engine colck always on */
284 outb(0x1B, 0x3C4);
285 outb(sr1b | 0x80, 0x3C5);
286 /* Second Display Color Depth 8 */
287 outb(0x67, 0x3D4);
288 outb(cr67 & 0x3F, 0x3D5);
289 outb(0x6A, 0x3D4);
290 /* Second Display Channel Reset CR6A[6]) */
291 outb(cr6a & 0xBF, 0x3D5);
292 /* Second Display Channel Enable CR6A[7] */
293 outb(cr6a | 0x80, 0x3D5);
294 /* Second Display Channel stop reset) */
295 outb(cr6a | 0x40, 0x3D5);
296
297 /* Bit mask of palette */
298 outb(0xFF, 0x3c6);
299 /* Write one register of IGA2 */
300 outb(regno, 0x3C8);
301 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name &&
302 rev >= 15) {
303 shift = 8;
304 viafb_write_reg_mask(CR6A, VIACR, BIT5, BIT5);
305 viafb_write_reg_mask(SR15, VIASR, BIT7, BIT7);
306 } else {
307 shift = 10;
308 viafb_write_reg_mask(CR6A, VIACR, 0, BIT5);
309 viafb_write_reg_mask(SR15, VIASR, 0, BIT7);
310 }
311 outb(red >> shift, 0x3C9);
312 outb(green >> shift, 0x3C9);
313 outb(blue >> shift, 0x3C9);
314
315 /* Map the 3C6/7/8/9 to the IGA1 */
316 outb(0x1A, 0x3C4);
317 outb(sr1a & 0xFE, 0x3C5);
318 /* Bit mask of palette */
319 outb(0xFF, 0x3c6);
320 /* Write one register of IGA1 */
321 outb(regno, 0x3C8);
322 outb(red >> shift, 0x3C9);
323 outb(green >> shift, 0x3C9);
324 outb(blue >> shift, 0x3C9);
325
326 outb(0x1A, 0x3C4);
327 outb(sr1a, 0x3C5);
328 outb(0x1B, 0x3C4);
329 outb(sr1b, 0x3C5);
330 outb(0x67, 0x3D4);
331 outb(cr67, 0x3D5);
332 outb(0x6A, 0x3D4);
333 outb(cr6a, 0x3D5);
334 break;
335 case 16:
336 ((u32 *) info->pseudo_palette)[regno] = (red & 0xF800) |
337 ((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11);
338 break;
339 case 32:
340 ((u32 *) info->pseudo_palette)[regno] =
341 ((transp & 0xFF00) << 16) |
342 ((red & 0xFF00) << 8) |
343 ((green & 0xFF00)) | ((blue & 0xFF00) >> 8);
344 break;
345 }
346
347 return 0;
348
349}
350
351/*CALLED BY: fb_set_cmap */
352/* fb_set_var, pass 256 colors */
353/*CALLED BY: fb_set_cmap */
354/* fbcon_set_palette, pass 16 colors */
355static int viafb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
356{
357 u32 len = cmap->len;
358 u32 i;
359 u16 *pred = cmap->red;
360 u16 *pgreen = cmap->green;
361 u16 *pblue = cmap->blue;
362 u16 *ptransp = cmap->transp;
363 u8 sr1a, sr1b, cr67, cr6a, rev = 0, shift = 10;
364 if (len > 256)
365 return 1;
366 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name) {
367 /*
368 * Read PCI bus 0, dev 0, function 0, index 0xF6 to get chip
369 * rev.
370 */
371 outl(0x80000000 | (0xf6 & ~3), (unsigned long)0xCF8);
372 rev = (inl((unsigned long)0xCFC) >> ((0xf6 & 3) * 8)) & 0xff;
373 }
374 switch (info->var.bits_per_pixel) {
375 case 8:
376 outb(0x1A, 0x3C4);
377 sr1a = inb(0x3C5);
378 outb(0x1B, 0x3C4);
379 sr1b = inb(0x3C5);
380 outb(0x67, 0x3D4);
381 cr67 = inb(0x3D5);
382 outb(0x6A, 0x3D4);
383 cr6a = inb(0x3D5);
384 /* Map the 3C6/7/8/9 to the IGA2 */
385 outb(0x1A, 0x3C4);
386 outb(sr1a | 0x01, 0x3C5);
387 outb(0x1B, 0x3C4);
388 /* Second Display Engine colck always on */
389 outb(sr1b | 0x80, 0x3C5);
390 outb(0x67, 0x3D4);
391 /* Second Display Color Depth 8 */
392 outb(cr67 & 0x3F, 0x3D5);
393 outb(0x6A, 0x3D4);
394 /* Second Display Channel Reset CR6A[6]) */
395 outb(cr6a & 0xBF, 0x3D5);
396 /* Second Display Channel Enable CR6A[7] */
397 outb(cr6a | 0x80, 0x3D5);
398 /* Second Display Channel stop reset) */
399 outb(cr6a | 0xC0, 0x3D5);
400
401 /* Bit mask of palette */
402 outb(0xFF, 0x3c6);
403 outb(0x00, 0x3C8);
404 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name &&
405 rev >= 15) {
406 shift = 8;
407 viafb_write_reg_mask(CR6A, VIACR, BIT5, BIT5);
408 viafb_write_reg_mask(SR15, VIASR, BIT7, BIT7);
409 } else {
410 shift = 10;
411 viafb_write_reg_mask(CR6A, VIACR, 0, BIT5);
412 viafb_write_reg_mask(SR15, VIASR, 0, BIT7);
413 }
414 for (i = 0; i < len; i++) {
415 outb((*(pred + i)) >> shift, 0x3C9);
416 outb((*(pgreen + i)) >> shift, 0x3C9);
417 outb((*(pblue + i)) >> shift, 0x3C9);
418 }
419
420 outb(0x1A, 0x3C4);
421 /* Map the 3C6/7/8/9 to the IGA1 */
422 outb(sr1a & 0xFE, 0x3C5);
423 /* Bit mask of palette */
424 outb(0xFF, 0x3c6);
425 outb(0x00, 0x3C8);
426 for (i = 0; i < len; i++) {
427 outb((*(pred + i)) >> shift, 0x3C9);
428 outb((*(pgreen + i)) >> shift, 0x3C9);
429 outb((*(pblue + i)) >> shift, 0x3C9);
430 }
431
432 outb(0x1A, 0x3C4);
433 outb(sr1a, 0x3C5);
434 outb(0x1B, 0x3C4);
435 outb(sr1b, 0x3C5);
436 outb(0x67, 0x3D4);
437 outb(cr67, 0x3D5);
438 outb(0x6A, 0x3D4);
439 outb(cr6a, 0x3D5);
440 break;
441 case 16:
442 if (len > 17)
443 return 0; /* Because static u32 pseudo_pal[17]; */
444 for (i = 0; i < len; i++)
445 ((u32 *) info->pseudo_palette)[i] =
446 (*(pred + i) & 0xF800) |
447 ((*(pgreen + i) & 0xFC00) >> 5) |
448 ((*(pblue + i) & 0xF800) >> 11);
449 break;
450 case 32:
451 if (len > 17)
452 return 0;
453 if (ptransp) {
454 for (i = 0; i < len; i++)
455 ((u32 *) info->pseudo_palette)[i] =
456 ((*(ptransp + i) & 0xFF00) << 16) |
457 ((*(pred + i) & 0xFF00) << 8) |
458 ((*(pgreen + i) & 0xFF00)) |
459 ((*(pblue + i) & 0xFF00) >> 8);
460 } else {
461 for (i = 0; i < len; i++)
462 ((u32 *) info->pseudo_palette)[i] =
463 0x00000000 |
464 ((*(pred + i) & 0xFF00) << 8) |
465 ((*(pgreen + i) & 0xFF00)) |
466 ((*(pblue + i) & 0xFF00) >> 8);
467 }
468 break;
469 }
470 return 0;
471}
472
473static int viafb_pan_display(struct fb_var_screeninfo *var,
474 struct fb_info *info)
475{
476 unsigned int offset;
477
478 DEBUG_MSG(KERN_INFO "viafb_pan_display!\n");
479
480 offset = (var->xoffset + (var->yoffset * var->xres_virtual)) *
481 var->bits_per_pixel / 16;
482
483 DEBUG_MSG(KERN_INFO "\nviafb_pan_display,offset =%d ", offset);
Florian Tobias Schandinat09cf1182009-09-22 16:47:14 -0700484 viafb_set_primary_address(offset);
Joseph Chan29b619f2008-10-15 22:03:27 -0700485 return 0;
486}
487
488static int viafb_blank(int blank_mode, struct fb_info *info)
489{
490 DEBUG_MSG(KERN_INFO "viafb_blank!\n");
491 /* clear DPMS setting */
492
493 switch (blank_mode) {
494 case FB_BLANK_UNBLANK:
495 /* Screen: On, HSync: On, VSync: On */
496 /* control CRT monitor power management */
497 viafb_write_reg_mask(CR36, VIACR, 0x00, BIT4 + BIT5);
498 break;
499 case FB_BLANK_HSYNC_SUSPEND:
500 /* Screen: Off, HSync: Off, VSync: On */
501 /* control CRT monitor power management */
502 viafb_write_reg_mask(CR36, VIACR, 0x10, BIT4 + BIT5);
503 break;
504 case FB_BLANK_VSYNC_SUSPEND:
505 /* Screen: Off, HSync: On, VSync: Off */
506 /* control CRT monitor power management */
507 viafb_write_reg_mask(CR36, VIACR, 0x20, BIT4 + BIT5);
508 break;
509 case FB_BLANK_POWERDOWN:
510 /* Screen: Off, HSync: Off, VSync: Off */
511 /* control CRT monitor power management */
512 viafb_write_reg_mask(CR36, VIACR, 0x30, BIT4 + BIT5);
513 break;
514 }
515
516 return 0;
517}
518
519static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
520{
Bruno Prémonte687d692009-01-04 13:11:54 -0800521 union {
522 struct viafb_ioctl_mode viamode;
523 struct viafb_ioctl_samm viasamm;
524 struct viafb_driver_version driver_version;
525 struct fb_var_screeninfo sec_var;
526 struct _panel_size_pos_info panel_pos_size_para;
527 struct viafb_ioctl_setting viafb_setting;
528 struct device_t active_dev;
529 } u;
Joseph Chan29b619f2008-10-15 22:03:27 -0700530 u32 state_info = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700531 u32 *viafb_gamma_table;
532 char driver_name[] = "viafb";
533
534 u32 __user *argp = (u32 __user *) arg;
535 u32 gpu32;
536 u32 video_dev_info = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700537
538 DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd);
Bruno Prémonte687d692009-01-04 13:11:54 -0800539 memset(&u, 0, sizeof(u));
Joseph Chan29b619f2008-10-15 22:03:27 -0700540
541 switch (cmd) {
542 case VIAFB_GET_CHIP_INFO:
543 if (copy_to_user(argp, viaparinfo->chip_info,
544 sizeof(struct chip_information)))
545 return -EFAULT;
546 break;
547 case VIAFB_GET_INFO_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800548 return put_user((u32)sizeof(struct viafb_ioctl_info), argp);
Joseph Chan29b619f2008-10-15 22:03:27 -0700549 case VIAFB_GET_INFO:
550 return viafb_ioctl_get_viafb_info(arg);
551 case VIAFB_HOTPLUG:
552 return put_user(viafb_ioctl_hotplug(info->var.xres,
553 info->var.yres,
554 info->var.bits_per_pixel), argp);
555 case VIAFB_SET_HOTPLUG_FLAG:
556 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
557 return -EFAULT;
558 viafb_hotplug = (gpu32) ? 1 : 0;
559 break;
560 case VIAFB_GET_RESOLUTION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800561 u.viamode.xres = (u32) viafb_hotplug_Xres;
562 u.viamode.yres = (u32) viafb_hotplug_Yres;
563 u.viamode.refresh = (u32) viafb_hotplug_refresh;
564 u.viamode.bpp = (u32) viafb_hotplug_bpp;
Joseph Chan29b619f2008-10-15 22:03:27 -0700565 if (viafb_SAMM_ON == 1) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800566 u.viamode.xres_sec = viafb_second_xres;
567 u.viamode.yres_sec = viafb_second_yres;
568 u.viamode.virtual_xres_sec = viafb_second_virtual_xres;
569 u.viamode.virtual_yres_sec = viafb_second_virtual_yres;
570 u.viamode.refresh_sec = viafb_refresh1;
571 u.viamode.bpp_sec = viafb_bpp1;
Joseph Chan29b619f2008-10-15 22:03:27 -0700572 } else {
Bruno Prémonte687d692009-01-04 13:11:54 -0800573 u.viamode.xres_sec = 0;
574 u.viamode.yres_sec = 0;
575 u.viamode.virtual_xres_sec = 0;
576 u.viamode.virtual_yres_sec = 0;
577 u.viamode.refresh_sec = 0;
578 u.viamode.bpp_sec = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700579 }
Bruno Prémonte687d692009-01-04 13:11:54 -0800580 if (copy_to_user(argp, &u.viamode, sizeof(u.viamode)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700581 return -EFAULT;
582 break;
583 case VIAFB_GET_SAMM_INFO:
Bruno Prémonte687d692009-01-04 13:11:54 -0800584 u.viasamm.samm_status = viafb_SAMM_ON;
Joseph Chan29b619f2008-10-15 22:03:27 -0700585
586 if (viafb_SAMM_ON == 1) {
587 if (viafb_dual_fb) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800588 u.viasamm.size_prim = viaparinfo->fbmem_free;
589 u.viasamm.size_sec = viaparinfo1->fbmem_free;
Joseph Chan29b619f2008-10-15 22:03:27 -0700590 } else {
591 if (viafb_second_size) {
Bruno Prémonte687d692009-01-04 13:11:54 -0800592 u.viasamm.size_prim =
Joseph Chan29b619f2008-10-15 22:03:27 -0700593 viaparinfo->fbmem_free -
594 viafb_second_size * 1024 * 1024;
Bruno Prémonte687d692009-01-04 13:11:54 -0800595 u.viasamm.size_sec =
Joseph Chan29b619f2008-10-15 22:03:27 -0700596 viafb_second_size * 1024 * 1024;
597 } else {
Bruno Prémonte687d692009-01-04 13:11:54 -0800598 u.viasamm.size_prim =
Joseph Chan29b619f2008-10-15 22:03:27 -0700599 viaparinfo->fbmem_free >> 1;
Bruno Prémonte687d692009-01-04 13:11:54 -0800600 u.viasamm.size_sec =
Joseph Chan29b619f2008-10-15 22:03:27 -0700601 (viaparinfo->fbmem_free >> 1);
602 }
603 }
Bruno Prémonte687d692009-01-04 13:11:54 -0800604 u.viasamm.mem_base = viaparinfo->fbmem;
605 u.viasamm.offset_sec = viafb_second_offset;
Joseph Chan29b619f2008-10-15 22:03:27 -0700606 } else {
Bruno Prémonte687d692009-01-04 13:11:54 -0800607 u.viasamm.size_prim =
Joseph Chan29b619f2008-10-15 22:03:27 -0700608 viaparinfo->memsize - viaparinfo->fbmem_used;
Bruno Prémonte687d692009-01-04 13:11:54 -0800609 u.viasamm.size_sec = 0;
610 u.viasamm.mem_base = viaparinfo->fbmem;
611 u.viasamm.offset_sec = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -0700612 }
613
Bruno Prémonte687d692009-01-04 13:11:54 -0800614 if (copy_to_user(argp, &u.viasamm, sizeof(u.viasamm)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700615 return -EFAULT;
616
617 break;
618 case VIAFB_TURN_ON_OUTPUT_DEVICE:
619 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
620 return -EFAULT;
621 if (gpu32 & CRT_Device)
622 viafb_crt_enable();
623 if (gpu32 & DVI_Device)
624 viafb_dvi_enable();
625 if (gpu32 & LCD_Device)
626 viafb_lcd_enable();
627 break;
628 case VIAFB_TURN_OFF_OUTPUT_DEVICE:
629 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
630 return -EFAULT;
631 if (gpu32 & CRT_Device)
632 viafb_crt_disable();
633 if (gpu32 & DVI_Device)
634 viafb_dvi_disable();
635 if (gpu32 & LCD_Device)
636 viafb_lcd_disable();
637 break;
638 case VIAFB_SET_DEVICE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800639 if (copy_from_user(&u.active_dev, (void *)argp,
640 sizeof(u.active_dev)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700641 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800642 viafb_set_device(u.active_dev);
Joseph Chan29b619f2008-10-15 22:03:27 -0700643 viafb_set_par(info);
644 break;
645 case VIAFB_GET_DEVICE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800646 u.active_dev.crt = viafb_CRT_ON;
647 u.active_dev.dvi = viafb_DVI_ON;
648 u.active_dev.lcd = viafb_LCD_ON;
649 u.active_dev.samm = viafb_SAMM_ON;
650 u.active_dev.primary_dev = viafb_primary_dev;
Joseph Chan29b619f2008-10-15 22:03:27 -0700651
Bruno Prémonte687d692009-01-04 13:11:54 -0800652 u.active_dev.lcd_dsp_cent = viafb_lcd_dsp_method;
653 u.active_dev.lcd_panel_id = viafb_lcd_panel_id;
654 u.active_dev.lcd_mode = viafb_lcd_mode;
Joseph Chan29b619f2008-10-15 22:03:27 -0700655
Bruno Prémonte687d692009-01-04 13:11:54 -0800656 u.active_dev.xres = viafb_hotplug_Xres;
657 u.active_dev.yres = viafb_hotplug_Yres;
Joseph Chan29b619f2008-10-15 22:03:27 -0700658
Bruno Prémonte687d692009-01-04 13:11:54 -0800659 u.active_dev.xres1 = viafb_second_xres;
660 u.active_dev.yres1 = viafb_second_yres;
Joseph Chan29b619f2008-10-15 22:03:27 -0700661
Bruno Prémonte687d692009-01-04 13:11:54 -0800662 u.active_dev.bpp = viafb_bpp;
663 u.active_dev.bpp1 = viafb_bpp1;
664 u.active_dev.refresh = viafb_refresh;
665 u.active_dev.refresh1 = viafb_refresh1;
Joseph Chan29b619f2008-10-15 22:03:27 -0700666
Bruno Prémonte687d692009-01-04 13:11:54 -0800667 u.active_dev.epia_dvi = viafb_platform_epia_dvi;
668 u.active_dev.lcd_dual_edge = viafb_device_lcd_dualedge;
669 u.active_dev.bus_width = viafb_bus_width;
Joseph Chan29b619f2008-10-15 22:03:27 -0700670
Bruno Prémonte687d692009-01-04 13:11:54 -0800671 if (copy_to_user(argp, &u.active_dev, sizeof(u.active_dev)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700672 return -EFAULT;
673 break;
674
675 case VIAFB_GET_DRIVER_VERSION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800676 u.driver_version.iMajorNum = VERSION_MAJOR;
677 u.driver_version.iKernelNum = VERSION_KERNEL;
678 u.driver_version.iOSNum = VERSION_OS;
679 u.driver_version.iMinorNum = VERSION_MINOR;
Joseph Chan29b619f2008-10-15 22:03:27 -0700680
Bruno Prémonte687d692009-01-04 13:11:54 -0800681 if (copy_to_user(argp, &u.driver_version,
682 sizeof(u.driver_version)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700683 return -EFAULT;
684
685 break;
686
687 case VIAFB_SET_DEVICE_INFO:
Bruno Prémonte687d692009-01-04 13:11:54 -0800688 if (copy_from_user(&u.viafb_setting,
689 argp, sizeof(u.viafb_setting)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700690 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800691 if (apply_device_setting(u.viafb_setting, info) < 0)
Joseph Chan29b619f2008-10-15 22:03:27 -0700692 return -EINVAL;
693
694 break;
695
696 case VIAFB_SET_SECOND_MODE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800697 if (copy_from_user(&u.sec_var, argp, sizeof(u.sec_var)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700698 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800699 apply_second_mode_setting(&u.sec_var);
Joseph Chan29b619f2008-10-15 22:03:27 -0700700 break;
701
702 case VIAFB_GET_DEVICE_INFO:
703
Bruno Prémonte687d692009-01-04 13:11:54 -0800704 retrieve_device_setting(&u.viafb_setting);
Joseph Chan29b619f2008-10-15 22:03:27 -0700705
Bruno Prémonte687d692009-01-04 13:11:54 -0800706 if (copy_to_user(argp, &u.viafb_setting,
707 sizeof(u.viafb_setting)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700708 return -EFAULT;
709
710 break;
711
712 case VIAFB_GET_DEVICE_SUPPORT:
713 viafb_get_device_support_state(&state_info);
714 if (put_user(state_info, argp))
715 return -EFAULT;
716 break;
717
718 case VIAFB_GET_DEVICE_CONNECT:
719 viafb_get_device_connect_state(&state_info);
720 if (put_user(state_info, argp))
721 return -EFAULT;
722 break;
723
724 case VIAFB_GET_PANEL_SUPPORT_EXPAND:
725 state_info =
726 viafb_lcd_get_support_expand_state(info->var.xres,
727 info->var.yres);
728 if (put_user(state_info, argp))
729 return -EFAULT;
730 break;
731
732 case VIAFB_GET_DRIVER_NAME:
733 if (copy_to_user(argp, driver_name, sizeof(driver_name)))
734 return -EFAULT;
735 break;
736
737 case VIAFB_SET_GAMMA_LUT:
738 viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
739 if (!viafb_gamma_table)
740 return -ENOMEM;
741 if (copy_from_user(viafb_gamma_table, argp,
742 sizeof(viafb_gamma_table))) {
743 kfree(viafb_gamma_table);
744 return -EFAULT;
745 }
746 viafb_set_gamma_table(viafb_bpp, viafb_gamma_table);
747 kfree(viafb_gamma_table);
748 break;
749
750 case VIAFB_GET_GAMMA_LUT:
751 viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
752 if (!viafb_gamma_table)
753 return -ENOMEM;
754 viafb_get_gamma_table(viafb_gamma_table);
755 if (copy_to_user(argp, viafb_gamma_table,
756 sizeof(viafb_gamma_table))) {
757 kfree(viafb_gamma_table);
758 return -EFAULT;
759 }
760 kfree(viafb_gamma_table);
761 break;
762
763 case VIAFB_GET_GAMMA_SUPPORT_STATE:
764 viafb_get_gamma_support_state(viafb_bpp, &state_info);
765 if (put_user(state_info, argp))
766 return -EFAULT;
767 break;
768 case VIAFB_SET_VIDEO_DEVICE:
769 get_user(video_dev_info, argp);
770 viafb_set_video_device(video_dev_info);
771 break;
772 case VIAFB_GET_VIDEO_DEVICE:
773 viafb_get_video_device(&video_dev_info);
774 if (put_user(video_dev_info, argp))
775 return -EFAULT;
776 break;
777 case VIAFB_SYNC_SURFACE:
778 DEBUG_MSG(KERN_INFO "lobo VIAFB_SYNC_SURFACE\n");
779 break;
780 case VIAFB_GET_DRIVER_CAPS:
781 break;
782
783 case VIAFB_GET_PANEL_MAX_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800784 if (copy_from_user(&u.panel_pos_size_para, argp,
785 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700786 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800787 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
788 if (copy_to_user(argp, &u.panel_pos_size_para,
789 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700790 return -EFAULT;
791 break;
792 case VIAFB_GET_PANEL_MAX_POSITION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800793 if (copy_from_user(&u.panel_pos_size_para, argp,
794 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700795 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800796 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
797 if (copy_to_user(argp, &u.panel_pos_size_para,
798 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700799 return -EFAULT;
800 break;
801
802 case VIAFB_GET_PANEL_POSITION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800803 if (copy_from_user(&u.panel_pos_size_para, argp,
804 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700805 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800806 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
807 if (copy_to_user(argp, &u.panel_pos_size_para,
808 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700809 return -EFAULT;
810 break;
811 case VIAFB_GET_PANEL_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800812 if (copy_from_user(&u.panel_pos_size_para, argp,
813 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700814 return -EFAULT;
Bruno Prémonte687d692009-01-04 13:11:54 -0800815 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
816 if (copy_to_user(argp, &u.panel_pos_size_para,
817 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700818 return -EFAULT;
819 break;
820
821 case VIAFB_SET_PANEL_POSITION:
Bruno Prémonte687d692009-01-04 13:11:54 -0800822 if (copy_from_user(&u.panel_pos_size_para, argp,
823 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700824 return -EFAULT;
825 break;
826 case VIAFB_SET_PANEL_SIZE:
Bruno Prémonte687d692009-01-04 13:11:54 -0800827 if (copy_from_user(&u.panel_pos_size_para, argp,
828 sizeof(u.panel_pos_size_para)))
Joseph Chan29b619f2008-10-15 22:03:27 -0700829 return -EFAULT;
830 break;
831
832 default:
833 return -EINVAL;
834 }
835
836 return 0;
837}
838
839static void viafb_fillrect(struct fb_info *info,
840 const struct fb_fillrect *rect)
841{
842 u32 col = 0, rop = 0;
843 int pitch;
844
Hannes Eder2899bb02009-01-06 14:42:32 -0800845 if (!viafb_accel) {
846 cfb_fillrect(info, rect);
847 return;
848 }
Joseph Chan29b619f2008-10-15 22:03:27 -0700849
850 if (!rect->width || !rect->height)
851 return;
852
853 switch (rect->rop) {
854 case ROP_XOR:
855 rop = 0x5A;
856 break;
857 case ROP_COPY:
858 default:
859 rop = 0xF0;
860 break;
861 }
862
863 switch (info->var.bits_per_pixel) {
864 case 8:
865 col = rect->color;
866 break;
867 case 16:
868 col = ((u32 *) (info->pseudo_palette))[rect->color];
869 break;
870 case 32:
871 col = ((u32 *) (info->pseudo_palette))[rect->color];
872 break;
873 }
874
875 /* BitBlt Source Address */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700876 writel(0x0, viaparinfo->io_virt + VIA_REG_SRCPOS);
Joseph Chan29b619f2008-10-15 22:03:27 -0700877 /* Source Base Address */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700878 writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE);
Joseph Chan29b619f2008-10-15 22:03:27 -0700879 /* Destination Base Address */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700880 writel(((unsigned long) (info->screen_base) -
881 (unsigned long) viafb_FB_MM) >> 3,
882 viaparinfo->io_virt + VIA_REG_DSTBASE);
Joseph Chan29b619f2008-10-15 22:03:27 -0700883 /* Pitch */
884 pitch = (info->var.xres_virtual + 7) & ~7;
Joseph Chanb3a45d82008-10-15 22:03:29 -0700885 writel(VIA_PITCH_ENABLE |
Joseph Chan29b619f2008-10-15 22:03:27 -0700886 (((pitch *
887 info->var.bits_per_pixel >> 3) >> 3) |
888 (((pitch * info->
Joseph Chanb3a45d82008-10-15 22:03:29 -0700889 var.bits_per_pixel >> 3) >> 3) << 16)),
890 viaparinfo->io_virt + VIA_REG_PITCH);
Joseph Chan29b619f2008-10-15 22:03:27 -0700891 /* BitBlt Destination Address */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700892 writel(((rect->dy << 16) | rect->dx),
893 viaparinfo->io_virt + VIA_REG_DSTPOS);
Joseph Chan29b619f2008-10-15 22:03:27 -0700894 /* Dimension: width & height */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700895 writel((((rect->height - 1) << 16) | (rect->width - 1)),
896 viaparinfo->io_virt + VIA_REG_DIMENSION);
Joseph Chan29b619f2008-10-15 22:03:27 -0700897 /* Forground color or Destination color */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700898 writel(col, viaparinfo->io_virt + VIA_REG_FGCOLOR);
Joseph Chan29b619f2008-10-15 22:03:27 -0700899 /* GE Command */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700900 writel((0x01 | 0x2000 | (rop << 24)),
901 viaparinfo->io_virt + VIA_REG_GECMD);
Joseph Chan29b619f2008-10-15 22:03:27 -0700902
903}
904
905static void viafb_copyarea(struct fb_info *info,
906 const struct fb_copyarea *area)
907{
908 u32 dy = area->dy, sy = area->sy, direction = 0x0;
909 u32 sx = area->sx, dx = area->dx, width = area->width;
910 int pitch;
911
912 DEBUG_MSG(KERN_INFO "viafb_copyarea!!\n");
913
Hannes Eder2899bb02009-01-06 14:42:32 -0800914 if (!viafb_accel) {
915 cfb_copyarea(info, area);
916 return;
917 }
Joseph Chan29b619f2008-10-15 22:03:27 -0700918
919 if (!area->width || !area->height)
920 return;
921
922 if (sy < dy) {
923 dy += area->height - 1;
924 sy += area->height - 1;
925 direction |= 0x4000;
926 }
927
928 if (sx < dx) {
929 dx += width - 1;
930 sx += width - 1;
931 direction |= 0x8000;
932 }
933
934 /* Source Base Address */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700935 writel(((unsigned long) (info->screen_base) -
936 (unsigned long) viafb_FB_MM) >> 3,
937 viaparinfo->io_virt + VIA_REG_SRCBASE);
Joseph Chan29b619f2008-10-15 22:03:27 -0700938 /* Destination Base Address */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700939 writel(((unsigned long) (info->screen_base) -
940 (unsigned long) viafb_FB_MM) >> 3,
941 viaparinfo->io_virt + VIA_REG_DSTBASE);
Joseph Chan29b619f2008-10-15 22:03:27 -0700942 /* Pitch */
943 pitch = (info->var.xres_virtual + 7) & ~7;
944 /* VIA_PITCH_ENABLE can be omitted now. */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700945 writel(VIA_PITCH_ENABLE |
Joseph Chan29b619f2008-10-15 22:03:27 -0700946 (((pitch *
947 info->var.bits_per_pixel >> 3) >> 3) | (((pitch *
948 info->var.
949 bits_per_pixel
950 >> 3) >> 3)
Joseph Chanb3a45d82008-10-15 22:03:29 -0700951 << 16)),
952 viaparinfo->io_virt + VIA_REG_PITCH);
Joseph Chan29b619f2008-10-15 22:03:27 -0700953 /* BitBlt Source Address */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700954 writel(((sy << 16) | sx), viaparinfo->io_virt + VIA_REG_SRCPOS);
Joseph Chan29b619f2008-10-15 22:03:27 -0700955 /* BitBlt Destination Address */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700956 writel(((dy << 16) | dx), viaparinfo->io_virt + VIA_REG_DSTPOS);
Joseph Chan29b619f2008-10-15 22:03:27 -0700957 /* Dimension: width & height */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700958 writel((((area->height - 1) << 16) | (area->width - 1)),
959 viaparinfo->io_virt + VIA_REG_DIMENSION);
Joseph Chan29b619f2008-10-15 22:03:27 -0700960 /* GE Command */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700961 writel((0x01 | direction | (0xCC << 24)),
962 viaparinfo->io_virt + VIA_REG_GECMD);
Joseph Chan29b619f2008-10-15 22:03:27 -0700963
964}
965
966static void viafb_imageblit(struct fb_info *info,
967 const struct fb_image *image)
968{
969 u32 size, bg_col = 0, fg_col = 0, *udata;
970 int i;
971 int pitch;
972
Hannes Eder2899bb02009-01-06 14:42:32 -0800973 if (!viafb_accel) {
974 cfb_imageblit(info, image);
975 return;
976 }
Joseph Chan29b619f2008-10-15 22:03:27 -0700977
978 udata = (u32 *) image->data;
979
980 switch (info->var.bits_per_pixel) {
981 case 8:
982 bg_col = image->bg_color;
983 fg_col = image->fg_color;
984 break;
985 case 16:
986 bg_col = ((u32 *) (info->pseudo_palette))[image->bg_color];
987 fg_col = ((u32 *) (info->pseudo_palette))[image->fg_color];
988 break;
989 case 32:
990 bg_col = ((u32 *) (info->pseudo_palette))[image->bg_color];
991 fg_col = ((u32 *) (info->pseudo_palette))[image->fg_color];
992 break;
993 }
994 size = image->width * image->height;
995
996 /* Source Base Address */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700997 writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE);
Joseph Chan29b619f2008-10-15 22:03:27 -0700998 /* Destination Base Address */
Joseph Chanb3a45d82008-10-15 22:03:29 -0700999 writel(((unsigned long) (info->screen_base) -
1000 (unsigned long) viafb_FB_MM) >> 3,
1001 viaparinfo->io_virt + VIA_REG_DSTBASE);
Joseph Chan29b619f2008-10-15 22:03:27 -07001002 /* Pitch */
1003 pitch = (info->var.xres_virtual + 7) & ~7;
Joseph Chanb3a45d82008-10-15 22:03:29 -07001004 writel(VIA_PITCH_ENABLE |
Joseph Chan29b619f2008-10-15 22:03:27 -07001005 (((pitch *
1006 info->var.bits_per_pixel >> 3) >> 3) | (((pitch *
1007 info->var.
1008 bits_per_pixel
1009 >> 3) >> 3)
Joseph Chanb3a45d82008-10-15 22:03:29 -07001010 << 16)),
1011 viaparinfo->io_virt + VIA_REG_PITCH);
Joseph Chan29b619f2008-10-15 22:03:27 -07001012 /* BitBlt Source Address */
Joseph Chanb3a45d82008-10-15 22:03:29 -07001013 writel(0x0, viaparinfo->io_virt + VIA_REG_SRCPOS);
Joseph Chan29b619f2008-10-15 22:03:27 -07001014 /* BitBlt Destination Address */
Joseph Chanb3a45d82008-10-15 22:03:29 -07001015 writel(((image->dy << 16) | image->dx),
1016 viaparinfo->io_virt + VIA_REG_DSTPOS);
Joseph Chan29b619f2008-10-15 22:03:27 -07001017 /* Dimension: width & height */
Joseph Chanb3a45d82008-10-15 22:03:29 -07001018 writel((((image->height - 1) << 16) | (image->width - 1)),
1019 viaparinfo->io_virt + VIA_REG_DIMENSION);
Joseph Chan29b619f2008-10-15 22:03:27 -07001020 /* fb color */
Joseph Chanb3a45d82008-10-15 22:03:29 -07001021 writel(fg_col, viaparinfo->io_virt + VIA_REG_FGCOLOR);
Joseph Chan29b619f2008-10-15 22:03:27 -07001022 /* bg color */
Joseph Chanb3a45d82008-10-15 22:03:29 -07001023 writel(bg_col, viaparinfo->io_virt + VIA_REG_BGCOLOR);
Joseph Chan29b619f2008-10-15 22:03:27 -07001024 /* GE Command */
Joseph Chanb3a45d82008-10-15 22:03:29 -07001025 writel(0xCC020142, viaparinfo->io_virt + VIA_REG_GECMD);
Joseph Chan29b619f2008-10-15 22:03:27 -07001026
1027 for (i = 0; i < size / 4; i++) {
Joseph Chanb3a45d82008-10-15 22:03:29 -07001028 writel(*udata, viaparinfo->io_virt + VIA_MMIO_BLTBASE);
Joseph Chan29b619f2008-10-15 22:03:27 -07001029 udata++;
1030 }
1031
1032}
1033
1034static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1035{
Joseph Chan29b619f2008-10-15 22:03:27 -07001036 u32 temp, xx, yy, bg_col = 0, fg_col = 0;
Bruno Prémonte687d692009-01-04 13:11:54 -08001037 int i, j = 0;
Joseph Chan29b619f2008-10-15 22:03:27 -07001038 static int hw_cursor;
1039 struct viafb_par *p_viafb_par;
1040
1041 if (viafb_accel)
1042 hw_cursor = 1;
1043
1044 if (!viafb_accel) {
1045 if (hw_cursor) {
1046 viafb_show_hw_cursor(info, HW_Cursor_OFF);
1047 hw_cursor = 0;
1048 }
1049 return -ENODEV;
1050 }
1051
1052 if ((((struct viafb_par *)(info->par))->iga_path == IGA2)
1053 && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266))
1054 return -ENODEV;
1055
1056 /* When duoview and using lcd , use soft cursor */
1057 if (viafb_LCD_ON || ((struct viafb_par *)(info->par))->duoview)
1058 return -ENODEV;
1059
1060 viafb_show_hw_cursor(info, HW_Cursor_OFF);
1061 viacursor = *cursor;
1062
1063 if (cursor->set & FB_CUR_SETHOT) {
1064 viacursor.hot = cursor->hot;
1065 temp = ((viacursor.hot.x) << 16) + viacursor.hot.y;
Joseph Chanb3a45d82008-10-15 22:03:29 -07001066 writel(temp, viaparinfo->io_virt + VIA_REG_CURSOR_ORG);
Joseph Chan29b619f2008-10-15 22:03:27 -07001067 }
1068
1069 if (cursor->set & FB_CUR_SETPOS) {
1070 viacursor.image.dx = cursor->image.dx;
1071 viacursor.image.dy = cursor->image.dy;
1072 yy = cursor->image.dy - info->var.yoffset;
1073 xx = cursor->image.dx - info->var.xoffset;
1074 temp = yy & 0xFFFF;
1075 temp |= (xx << 16);
Joseph Chanb3a45d82008-10-15 22:03:29 -07001076 writel(temp, viaparinfo->io_virt + VIA_REG_CURSOR_POS);
Joseph Chan29b619f2008-10-15 22:03:27 -07001077 }
1078
1079 if (cursor->set & FB_CUR_SETSIZE) {
Joseph Chanb3a45d82008-10-15 22:03:29 -07001080 temp = readl(viaparinfo->io_virt + VIA_REG_CURSOR_MODE);
Joseph Chan29b619f2008-10-15 22:03:27 -07001081
1082 if ((cursor->image.width <= 32)
1083 && (cursor->image.height <= 32)) {
1084 MAX_CURS = 32;
1085 temp |= 0x2;
1086 } else if ((cursor->image.width <= 64)
1087 && (cursor->image.height <= 64)) {
1088 MAX_CURS = 64;
1089 temp &= 0xFFFFFFFD;
1090 } else {
1091 DEBUG_MSG(KERN_INFO
1092 "The cursor image is biger than 64x64 bits...\n");
1093 return -ENXIO;
1094 }
Joseph Chanb3a45d82008-10-15 22:03:29 -07001095 writel(temp, viaparinfo->io_virt + VIA_REG_CURSOR_MODE);
Joseph Chan29b619f2008-10-15 22:03:27 -07001096
1097 viacursor.image.height = cursor->image.height;
1098 viacursor.image.width = cursor->image.width;
1099 }
1100
1101 if (cursor->set & FB_CUR_SETCMAP) {
1102 viacursor.image.fg_color = cursor->image.fg_color;
1103 viacursor.image.bg_color = cursor->image.bg_color;
1104
1105 switch (info->var.bits_per_pixel) {
1106 case 8:
1107 case 16:
1108 case 32:
1109 bg_col =
1110 (0xFF << 24) |
1111 (((info->cmap.red)[viacursor.image.bg_color] &
1112 0xFF00) << 8) |
1113 ((info->cmap.green)[viacursor.image.bg_color] &
1114 0xFF00) |
1115 (((info->cmap.blue)[viacursor.image.bg_color] &
1116 0xFF00) >> 8);
1117 fg_col =
1118 (0xFF << 24) |
1119 (((info->cmap.red)[viacursor.image.fg_color] &
1120 0xFF00) << 8) |
1121 ((info->cmap.green)[viacursor.image.fg_color] &
1122 0xFF00) |
1123 (((info->cmap.blue)[viacursor.image.fg_color] &
1124 0xFF00) >> 8);
1125 break;
1126 default:
1127 return 0;
1128 }
1129
1130 /* This is indeed a patch for VT3324/VT3353 */
1131 if (!info->par)
1132 return 0;
1133 p_viafb_par = (struct viafb_par *)info->par;
1134
1135 if ((p_viafb_par->chip_info->gfx_chip_name ==
1136 UNICHROME_CX700) ||
1137 ((p_viafb_par->chip_info->gfx_chip_name ==
1138 UNICHROME_VX800))) {
1139 bg_col =
1140 (((info->cmap.red)[viacursor.image.bg_color] &
1141 0xFFC0) << 14) |
1142 (((info->cmap.green)[viacursor.image.bg_color] &
1143 0xFFC0) << 4) |
1144 (((info->cmap.blue)[viacursor.image.bg_color] &
1145 0xFFC0) >> 6);
1146 fg_col =
1147 (((info->cmap.red)[viacursor.image.fg_color] &
1148 0xFFC0) << 14) |
1149 (((info->cmap.green)[viacursor.image.fg_color] &
1150 0xFFC0) << 4) |
1151 (((info->cmap.blue)[viacursor.image.fg_color] &
1152 0xFFC0) >> 6);
1153 }
1154
Joseph Chanb3a45d82008-10-15 22:03:29 -07001155 writel(bg_col, viaparinfo->io_virt + VIA_REG_CURSOR_BG);
1156 writel(fg_col, viaparinfo->io_virt + VIA_REG_CURSOR_FG);
Joseph Chan29b619f2008-10-15 22:03:27 -07001157 }
1158
1159 if (cursor->set & FB_CUR_SETSHAPE) {
Bruno Prémonte687d692009-01-04 13:11:54 -08001160 struct {
1161 u8 data[CURSOR_SIZE / 8];
1162 u32 bak[CURSOR_SIZE / 32];
1163 } *cr_data = kzalloc(sizeof(*cr_data), GFP_ATOMIC);
1164 int size =
Joseph Chan29b619f2008-10-15 22:03:27 -07001165 ((viacursor.image.width + 7) >> 3) *
1166 viacursor.image.height;
1167
Bruno Prémonte687d692009-01-04 13:11:54 -08001168 if (cr_data == NULL)
1169 goto out;
1170
Joseph Chan29b619f2008-10-15 22:03:27 -07001171 if (MAX_CURS == 32) {
1172 for (i = 0; i < (CURSOR_SIZE / 32); i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -08001173 cr_data->bak[i] = 0x0;
1174 cr_data->bak[i + 1] = 0xFFFFFFFF;
Joseph Chan29b619f2008-10-15 22:03:27 -07001175 i += 1;
1176 }
1177 } else if (MAX_CURS == 64) {
1178 for (i = 0; i < (CURSOR_SIZE / 32); i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -08001179 cr_data->bak[i] = 0x0;
1180 cr_data->bak[i + 1] = 0x0;
1181 cr_data->bak[i + 2] = 0xFFFFFFFF;
1182 cr_data->bak[i + 3] = 0xFFFFFFFF;
Joseph Chan29b619f2008-10-15 22:03:27 -07001183 i += 3;
1184 }
1185 }
1186
1187 switch (viacursor.rop) {
1188 case ROP_XOR:
1189 for (i = 0; i < size; i++)
Bruno Prémonte687d692009-01-04 13:11:54 -08001190 cr_data->data[i] = viacursor.mask[i];
Joseph Chan29b619f2008-10-15 22:03:27 -07001191 break;
1192 case ROP_COPY:
1193
1194 for (i = 0; i < size; i++)
Bruno Prémonte687d692009-01-04 13:11:54 -08001195 cr_data->data[i] = viacursor.mask[i];
Joseph Chan29b619f2008-10-15 22:03:27 -07001196 break;
1197 default:
1198 break;
1199 }
1200
1201 if (MAX_CURS == 32) {
1202 for (i = 0; i < size; i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -08001203 cr_data->bak[j] = (u32) cr_data->data[i];
1204 cr_data->bak[j + 1] = ~cr_data->bak[j];
Joseph Chan29b619f2008-10-15 22:03:27 -07001205 j += 2;
1206 }
1207 } else if (MAX_CURS == 64) {
1208 for (i = 0; i < size; i++) {
Bruno Prémonte687d692009-01-04 13:11:54 -08001209 cr_data->bak[j] = (u32) cr_data->data[i];
1210 cr_data->bak[j + 1] = 0x0;
1211 cr_data->bak[j + 2] = ~cr_data->bak[j];
1212 cr_data->bak[j + 3] = ~cr_data->bak[j + 1];
Joseph Chan29b619f2008-10-15 22:03:27 -07001213 j += 4;
1214 }
1215 }
1216
1217 memcpy(((struct viafb_par *)(info->par))->fbmem_virt +
1218 ((struct viafb_par *)(info->par))->cursor_start,
Bruno Prémonte687d692009-01-04 13:11:54 -08001219 cr_data->bak, CURSOR_SIZE);
1220out:
1221 kfree(cr_data);
Joseph Chan29b619f2008-10-15 22:03:27 -07001222 }
1223
1224 if (viacursor.enable)
1225 viafb_show_hw_cursor(info, HW_Cursor_ON);
1226
1227 return 0;
1228}
1229
1230static int viafb_sync(struct fb_info *info)
1231{
1232 if (viafb_accel)
1233 viafb_wait_engine_idle();
1234 return 0;
1235}
1236
Florian Tobias Schandinat52159442009-08-06 15:07:34 -07001237int viafb_get_mode_index(int hres, int vres)
Joseph Chan29b619f2008-10-15 22:03:27 -07001238{
1239 u32 i;
1240 DEBUG_MSG(KERN_INFO "viafb_get_mode_index!\n");
1241
1242 for (i = 0; viafb_modentry[i].mode_index != VIA_RES_INVALID; i++)
1243 if (viafb_modentry[i].xres == hres &&
1244 viafb_modentry[i].yres == vres)
1245 break;
1246
Florian Tobias Schandinat52159442009-08-06 15:07:34 -07001247 return viafb_modentry[i].mode_index;
Joseph Chan29b619f2008-10-15 22:03:27 -07001248}
1249
1250static void check_available_device_to_enable(int device_id)
1251{
1252 int device_num = 0;
1253
1254 /* Initialize: */
1255 viafb_CRT_ON = STATE_OFF;
1256 viafb_DVI_ON = STATE_OFF;
1257 viafb_LCD_ON = STATE_OFF;
1258 viafb_LCD2_ON = STATE_OFF;
1259 viafb_DeviceStatus = None_Device;
1260
1261 if ((device_id & CRT_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1262 viafb_CRT_ON = STATE_ON;
1263 device_num++;
1264 viafb_DeviceStatus |= CRT_Device;
1265 }
1266
1267 if ((device_id & DVI_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1268 viafb_DVI_ON = STATE_ON;
1269 device_num++;
1270 viafb_DeviceStatus |= DVI_Device;
1271 }
1272
1273 if ((device_id & LCD_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1274 viafb_LCD_ON = STATE_ON;
1275 device_num++;
1276 viafb_DeviceStatus |= LCD_Device;
1277 }
1278
1279 if ((device_id & LCD2_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1280 viafb_LCD2_ON = STATE_ON;
1281 device_num++;
1282 viafb_DeviceStatus |= LCD2_Device;
1283 }
1284
1285 if (viafb_DeviceStatus == None_Device) {
1286 /* Use CRT as default active device: */
1287 viafb_CRT_ON = STATE_ON;
1288 viafb_DeviceStatus = CRT_Device;
1289 }
1290 DEBUG_MSG(KERN_INFO "Device Status:%x", viafb_DeviceStatus);
1291}
1292
1293static void viafb_set_device(struct device_t active_dev)
1294{
1295 /* Check available device to enable: */
1296 int device_id = None_Device;
1297 if (active_dev.crt)
1298 device_id |= CRT_Device;
1299 if (active_dev.dvi)
1300 device_id |= DVI_Device;
1301 if (active_dev.lcd)
1302 device_id |= LCD_Device;
1303
1304 check_available_device_to_enable(device_id);
1305
1306 /* Check property of LCD: */
1307 if (viafb_LCD_ON) {
1308 if (active_dev.lcd_dsp_cent) {
1309 viaparinfo->lvds_setting_info->display_method =
1310 viafb_lcd_dsp_method = LCD_CENTERING;
1311 } else {
1312 viaparinfo->lvds_setting_info->display_method =
1313 viafb_lcd_dsp_method = LCD_EXPANDSION;
1314 }
1315
1316 if (active_dev.lcd_mode == LCD_SPWG) {
1317 viaparinfo->lvds_setting_info->lcd_mode =
1318 viafb_lcd_mode = LCD_SPWG;
1319 } else {
1320 viaparinfo->lvds_setting_info->lcd_mode =
1321 viafb_lcd_mode = LCD_OPENLDI;
1322 }
1323
1324 if (active_dev.lcd_panel_id <= LCD_PANEL_ID_MAXIMUM) {
1325 viafb_lcd_panel_id = active_dev.lcd_panel_id;
1326 viafb_init_lcd_size();
1327 }
1328 }
1329
1330 /* Check property of mode: */
1331 if (!active_dev.xres1)
1332 viafb_second_xres = 640;
1333 else
1334 viafb_second_xres = active_dev.xres1;
1335 if (!active_dev.yres1)
1336 viafb_second_yres = 480;
1337 else
1338 viafb_second_yres = active_dev.yres1;
1339 if (active_dev.bpp != 0)
1340 viafb_bpp = active_dev.bpp;
1341 if (active_dev.bpp1 != 0)
1342 viafb_bpp1 = active_dev.bpp1;
1343 if (active_dev.refresh != 0)
1344 viafb_refresh = active_dev.refresh;
1345 if (active_dev.refresh1 != 0)
1346 viafb_refresh1 = active_dev.refresh1;
1347 if ((active_dev.samm == STATE_OFF) || (active_dev.samm == STATE_ON))
1348 viafb_SAMM_ON = active_dev.samm;
1349 viafb_primary_dev = active_dev.primary_dev;
1350
Florian Tobias Schandinat09cf1182009-09-22 16:47:14 -07001351 viafb_set_primary_address(0);
1352 viafb_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0);
Joseph Chan29b619f2008-10-15 22:03:27 -07001353 viafb_set_iga_path();
1354}
1355
1356static void viafb_set_video_device(u32 video_dev_info)
1357{
1358 viaparinfo->video_on_crt = STATE_OFF;
1359 viaparinfo->video_on_dvi = STATE_OFF;
1360 viaparinfo->video_on_lcd = STATE_OFF;
1361
1362 /* Check available device to enable: */
1363 if ((video_dev_info & CRT_Device) == CRT_Device)
1364 viaparinfo->video_on_crt = STATE_ON;
1365 else if ((video_dev_info & DVI_Device) == DVI_Device)
1366 viaparinfo->video_on_dvi = STATE_ON;
1367 else if ((video_dev_info & LCD_Device) == LCD_Device)
1368 viaparinfo->video_on_lcd = STATE_ON;
1369}
1370
1371static void viafb_get_video_device(u32 *video_dev_info)
1372{
1373 *video_dev_info = None_Device;
1374 if (viaparinfo->video_on_crt == STATE_ON)
1375 *video_dev_info |= CRT_Device;
1376 else if (viaparinfo->video_on_dvi == STATE_ON)
1377 *video_dev_info |= DVI_Device;
1378 else if (viaparinfo->video_on_lcd == STATE_ON)
1379 *video_dev_info |= LCD_Device;
1380}
1381
1382static int get_primary_device(void)
1383{
1384 int primary_device = 0;
1385 /* Rule: device on iga1 path are the primary device. */
1386 if (viafb_SAMM_ON) {
1387 if (viafb_CRT_ON) {
1388 if (viaparinfo->crt_setting_info->iga_path == IGA1) {
1389 DEBUG_MSG(KERN_INFO "CRT IGA Path:%d\n",
1390 viaparinfo->
1391 crt_setting_info->iga_path);
1392 primary_device = CRT_Device;
1393 }
1394 }
1395 if (viafb_DVI_ON) {
1396 if (viaparinfo->tmds_setting_info->iga_path == IGA1) {
1397 DEBUG_MSG(KERN_INFO "DVI IGA Path:%d\n",
1398 viaparinfo->
1399 tmds_setting_info->iga_path);
1400 primary_device = DVI_Device;
1401 }
1402 }
1403 if (viafb_LCD_ON) {
1404 if (viaparinfo->lvds_setting_info->iga_path == IGA1) {
1405 DEBUG_MSG(KERN_INFO "LCD IGA Path:%d\n",
1406 viaparinfo->
1407 lvds_setting_info->iga_path);
1408 primary_device = LCD_Device;
1409 }
1410 }
1411 if (viafb_LCD2_ON) {
1412 if (viaparinfo->lvds_setting_info2->iga_path == IGA1) {
1413 DEBUG_MSG(KERN_INFO "LCD2 IGA Path:%d\n",
1414 viaparinfo->
1415 lvds_setting_info2->iga_path);
1416 primary_device = LCD2_Device;
1417 }
1418 }
1419 }
1420 return primary_device;
1421}
1422
1423static u8 is_duoview(void)
1424{
1425 if (0 == viafb_SAMM_ON) {
1426 if (viafb_LCD_ON + viafb_LCD2_ON +
1427 viafb_DVI_ON + viafb_CRT_ON == 2)
1428 return true;
1429 return false;
1430 } else {
1431 return false;
1432 }
1433}
1434
1435static void apply_second_mode_setting(struct fb_var_screeninfo
1436 *sec_var)
1437{
1438 u32 htotal, vtotal, long_refresh;
1439
1440 htotal = sec_var->xres + sec_var->left_margin +
1441 sec_var->right_margin + sec_var->hsync_len;
1442 vtotal = sec_var->yres + sec_var->upper_margin +
1443 sec_var->lower_margin + sec_var->vsync_len;
1444 if ((sec_var->xres_virtual * (sec_var->bits_per_pixel >> 3)) & 0x1F) {
1445 /*Is 32 bytes alignment? */
1446 /*32 pixel alignment */
1447 sec_var->xres_virtual = (sec_var->xres_virtual + 31) & ~31;
1448 }
1449
1450 htotal = sec_var->xres + sec_var->left_margin +
1451 sec_var->right_margin + sec_var->hsync_len;
1452 vtotal = sec_var->yres + sec_var->upper_margin +
1453 sec_var->lower_margin + sec_var->vsync_len;
1454 long_refresh = 1000000000UL / sec_var->pixclock * 1000;
1455 long_refresh /= (htotal * vtotal);
1456
1457 viafb_second_xres = sec_var->xres;
1458 viafb_second_yres = sec_var->yres;
1459 viafb_second_virtual_xres = sec_var->xres_virtual;
1460 viafb_second_virtual_yres = sec_var->yres_virtual;
1461 viafb_bpp1 = sec_var->bits_per_pixel;
1462 viafb_refresh1 = viafb_get_refresh(sec_var->xres, sec_var->yres,
1463 long_refresh);
1464}
1465
1466static int apply_device_setting(struct viafb_ioctl_setting setting_info,
1467 struct fb_info *info)
1468{
1469 int need_set_mode = 0;
1470 DEBUG_MSG(KERN_INFO "apply_device_setting\n");
1471
1472 if (setting_info.device_flag) {
1473 need_set_mode = 1;
1474 check_available_device_to_enable(setting_info.device_status);
1475 }
1476
1477 /* Unlock LCD's operation according to LCD flag
1478 and check if the setting value is valid. */
1479 /* If the value is valid, apply the new setting value to the device. */
1480 if (viafb_LCD_ON) {
1481 if (setting_info.lcd_operation_flag & OP_LCD_CENTERING) {
1482 need_set_mode = 1;
1483 if (setting_info.lcd_attributes.display_center) {
1484 /* Centering */
1485 viaparinfo->lvds_setting_info->display_method =
1486 LCD_CENTERING;
1487 viafb_lcd_dsp_method = LCD_CENTERING;
1488 viaparinfo->lvds_setting_info2->display_method =
1489 viafb_lcd_dsp_method = LCD_CENTERING;
1490 } else {
1491 /* expandsion */
1492 viaparinfo->lvds_setting_info->display_method =
1493 LCD_EXPANDSION;
1494 viafb_lcd_dsp_method = LCD_EXPANDSION;
1495 viaparinfo->lvds_setting_info2->display_method =
1496 LCD_EXPANDSION;
1497 viafb_lcd_dsp_method = LCD_EXPANDSION;
1498 }
1499 }
1500
1501 if (setting_info.lcd_operation_flag & OP_LCD_MODE) {
1502 need_set_mode = 1;
1503 if (setting_info.lcd_attributes.lcd_mode ==
1504 LCD_SPWG) {
1505 viaparinfo->lvds_setting_info->lcd_mode =
1506 viafb_lcd_mode = LCD_SPWG;
1507 } else {
1508 viaparinfo->lvds_setting_info->lcd_mode =
1509 viafb_lcd_mode = LCD_OPENLDI;
1510 }
1511 viaparinfo->lvds_setting_info2->lcd_mode =
1512 viaparinfo->lvds_setting_info->lcd_mode;
1513 }
1514
1515 if (setting_info.lcd_operation_flag & OP_LCD_PANEL_ID) {
1516 need_set_mode = 1;
1517 if (setting_info.lcd_attributes.panel_id <=
1518 LCD_PANEL_ID_MAXIMUM) {
1519 viafb_lcd_panel_id =
1520 setting_info.lcd_attributes.panel_id;
1521 viafb_init_lcd_size();
1522 }
1523 }
1524 }
1525
1526 if (0 != (setting_info.samm_status & OP_SAMM)) {
1527 setting_info.samm_status =
1528 setting_info.samm_status & (~OP_SAMM);
1529 if (setting_info.samm_status == 0
1530 || setting_info.samm_status == 1) {
1531 viafb_SAMM_ON = setting_info.samm_status;
1532
1533 if (viafb_SAMM_ON)
1534 viafb_primary_dev = setting_info.primary_device;
1535
Florian Tobias Schandinat09cf1182009-09-22 16:47:14 -07001536 viafb_set_primary_address(0);
1537 viafb_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0);
Joseph Chan29b619f2008-10-15 22:03:27 -07001538 viafb_set_iga_path();
1539 }
1540 need_set_mode = 1;
1541 }
1542
1543 viaparinfo->duoview = is_duoview();
1544
1545 if (!need_set_mode) {
1546 ;
1547 } else {
1548 viafb_set_iga_path();
1549 viafb_set_par(info);
1550 }
1551 return true;
1552}
1553
1554static void retrieve_device_setting(struct viafb_ioctl_setting
1555 *setting_info)
1556{
1557
1558 /* get device status */
1559 if (viafb_CRT_ON == 1)
1560 setting_info->device_status = CRT_Device;
1561 if (viafb_DVI_ON == 1)
1562 setting_info->device_status |= DVI_Device;
1563 if (viafb_LCD_ON == 1)
1564 setting_info->device_status |= LCD_Device;
1565 if (viafb_LCD2_ON == 1)
1566 setting_info->device_status |= LCD2_Device;
1567 if ((viaparinfo->video_on_crt == 1) && (viafb_CRT_ON == 1)) {
1568 setting_info->video_device_status =
1569 viaparinfo->crt_setting_info->iga_path;
1570 } else if ((viaparinfo->video_on_dvi == 1) && (viafb_DVI_ON == 1)) {
1571 setting_info->video_device_status =
1572 viaparinfo->tmds_setting_info->iga_path;
1573 } else if ((viaparinfo->video_on_lcd == 1) && (viafb_LCD_ON == 1)) {
1574 setting_info->video_device_status =
1575 viaparinfo->lvds_setting_info->iga_path;
1576 } else {
1577 setting_info->video_device_status = 0;
1578 }
1579
1580 setting_info->samm_status = viafb_SAMM_ON;
1581 setting_info->primary_device = get_primary_device();
1582
1583 setting_info->first_dev_bpp = viafb_bpp;
1584 setting_info->second_dev_bpp = viafb_bpp1;
1585
1586 setting_info->first_dev_refresh = viafb_refresh;
1587 setting_info->second_dev_refresh = viafb_refresh1;
1588
1589 setting_info->first_dev_hor_res = viafb_hotplug_Xres;
1590 setting_info->first_dev_ver_res = viafb_hotplug_Yres;
1591 setting_info->second_dev_hor_res = viafb_second_xres;
1592 setting_info->second_dev_ver_res = viafb_second_yres;
1593
1594 /* Get lcd attributes */
1595 setting_info->lcd_attributes.display_center = viafb_lcd_dsp_method;
1596 setting_info->lcd_attributes.panel_id = viafb_lcd_panel_id;
1597 setting_info->lcd_attributes.lcd_mode = viafb_lcd_mode;
1598}
1599
1600static void parse_active_dev(void)
1601{
1602 viafb_CRT_ON = STATE_OFF;
1603 viafb_DVI_ON = STATE_OFF;
1604 viafb_LCD_ON = STATE_OFF;
1605 viafb_LCD2_ON = STATE_OFF;
1606 /* 1. Modify the active status of devices. */
1607 /* 2. Keep the order of devices, so we can set corresponding
1608 IGA path to devices in SAMM case. */
1609 /* Note: The previous of active_dev is primary device,
1610 and the following is secondary device. */
1611 if (!strncmp(viafb_active_dev, "CRT+DVI", 7)) {
1612 /* CRT+DVI */
1613 viafb_CRT_ON = STATE_ON;
1614 viafb_DVI_ON = STATE_ON;
1615 viafb_primary_dev = CRT_Device;
1616 } else if (!strncmp(viafb_active_dev, "DVI+CRT", 7)) {
1617 /* DVI+CRT */
1618 viafb_CRT_ON = STATE_ON;
1619 viafb_DVI_ON = STATE_ON;
1620 viafb_primary_dev = DVI_Device;
1621 } else if (!strncmp(viafb_active_dev, "CRT+LCD", 7)) {
1622 /* CRT+LCD */
1623 viafb_CRT_ON = STATE_ON;
1624 viafb_LCD_ON = STATE_ON;
1625 viafb_primary_dev = CRT_Device;
1626 } else if (!strncmp(viafb_active_dev, "LCD+CRT", 7)) {
1627 /* LCD+CRT */
1628 viafb_CRT_ON = STATE_ON;
1629 viafb_LCD_ON = STATE_ON;
1630 viafb_primary_dev = LCD_Device;
1631 } else if (!strncmp(viafb_active_dev, "DVI+LCD", 7)) {
1632 /* DVI+LCD */
1633 viafb_DVI_ON = STATE_ON;
1634 viafb_LCD_ON = STATE_ON;
1635 viafb_primary_dev = DVI_Device;
1636 } else if (!strncmp(viafb_active_dev, "LCD+DVI", 7)) {
1637 /* LCD+DVI */
1638 viafb_DVI_ON = STATE_ON;
1639 viafb_LCD_ON = STATE_ON;
1640 viafb_primary_dev = LCD_Device;
1641 } else if (!strncmp(viafb_active_dev, "LCD+LCD2", 8)) {
1642 viafb_LCD_ON = STATE_ON;
1643 viafb_LCD2_ON = STATE_ON;
1644 viafb_primary_dev = LCD_Device;
1645 } else if (!strncmp(viafb_active_dev, "LCD2+LCD", 8)) {
1646 viafb_LCD_ON = STATE_ON;
1647 viafb_LCD2_ON = STATE_ON;
1648 viafb_primary_dev = LCD2_Device;
1649 } else if (!strncmp(viafb_active_dev, "CRT", 3)) {
1650 /* CRT only */
1651 viafb_CRT_ON = STATE_ON;
1652 viafb_SAMM_ON = STATE_OFF;
1653 } else if (!strncmp(viafb_active_dev, "DVI", 3)) {
1654 /* DVI only */
1655 viafb_DVI_ON = STATE_ON;
1656 viafb_SAMM_ON = STATE_OFF;
1657 } else if (!strncmp(viafb_active_dev, "LCD", 3)) {
1658 /* LCD only */
1659 viafb_LCD_ON = STATE_ON;
1660 viafb_SAMM_ON = STATE_OFF;
1661 } else {
1662 viafb_CRT_ON = STATE_ON;
1663 viafb_SAMM_ON = STATE_OFF;
1664 }
1665 viaparinfo->duoview = is_duoview();
1666}
1667
1668static void parse_video_dev(void)
1669{
1670 viaparinfo->video_on_crt = STATE_OFF;
1671 viaparinfo->video_on_dvi = STATE_OFF;
1672 viaparinfo->video_on_lcd = STATE_OFF;
1673
1674 if (!strncmp(viafb_video_dev, "CRT", 3)) {
1675 /* Video on CRT */
1676 viaparinfo->video_on_crt = STATE_ON;
1677 } else if (!strncmp(viafb_video_dev, "DVI", 3)) {
1678 /* Video on DVI */
1679 viaparinfo->video_on_dvi = STATE_ON;
1680 } else if (!strncmp(viafb_video_dev, "LCD", 3)) {
1681 /* Video on LCD */
1682 viaparinfo->video_on_lcd = STATE_ON;
1683 }
1684}
1685
1686static int parse_port(char *opt_str, int *output_interface)
1687{
1688 if (!strncmp(opt_str, "DVP0", 4))
1689 *output_interface = INTERFACE_DVP0;
1690 else if (!strncmp(opt_str, "DVP1", 4))
1691 *output_interface = INTERFACE_DVP1;
1692 else if (!strncmp(opt_str, "DFP_HIGHLOW", 11))
1693 *output_interface = INTERFACE_DFP;
1694 else if (!strncmp(opt_str, "DFP_HIGH", 8))
1695 *output_interface = INTERFACE_DFP_HIGH;
1696 else if (!strncmp(opt_str, "DFP_LOW", 7))
1697 *output_interface = INTERFACE_DFP_LOW;
1698 else
1699 *output_interface = INTERFACE_NONE;
1700 return 0;
1701}
1702
1703static void parse_lcd_port(void)
1704{
1705 parse_port(viafb_lcd_port, &viaparinfo->chip_info->lvds_chip_info.
1706 output_interface);
1707 /*Initialize to avoid unexpected behavior */
1708 viaparinfo->chip_info->lvds_chip_info2.output_interface =
1709 INTERFACE_NONE;
1710
1711 DEBUG_MSG(KERN_INFO "parse_lcd_port: viafb_lcd_port:%s,interface:%d\n",
1712 viafb_lcd_port, viaparinfo->chip_info->lvds_chip_info.
1713 output_interface);
1714}
1715
1716static void parse_dvi_port(void)
1717{
1718 parse_port(viafb_dvi_port, &viaparinfo->chip_info->tmds_chip_info.
1719 output_interface);
1720
1721 DEBUG_MSG(KERN_INFO "parse_dvi_port: viafb_dvi_port:%s,interface:%d\n",
1722 viafb_dvi_port, viaparinfo->chip_info->tmds_chip_info.
1723 output_interface);
1724}
1725
1726/*
1727 * The proc filesystem read/write function, a simple proc implement to
1728 * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
1729 * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2],
1730 * CR9B, SR65, CR97, CR99
1731 */
1732static int viafb_dvp0_proc_read(char *buf, char **start, off_t offset,
1733int count, int *eof, void *data)
1734{
1735 int len = 0;
1736 u8 dvp0_data_dri = 0, dvp0_clk_dri = 0, dvp0 = 0;
1737 dvp0_data_dri =
1738 (viafb_read_reg(VIASR, SR2A) & BIT5) >> 4 |
1739 (viafb_read_reg(VIASR, SR1B) & BIT1) >> 1;
1740 dvp0_clk_dri =
1741 (viafb_read_reg(VIASR, SR2A) & BIT4) >> 3 |
1742 (viafb_read_reg(VIASR, SR1E) & BIT2) >> 2;
1743 dvp0 = viafb_read_reg(VIACR, CR96) & 0x0f;
1744 len +=
1745 sprintf(buf + len, "%x %x %x\n", dvp0, dvp0_data_dri, dvp0_clk_dri);
1746 *eof = 1; /*Inform kernel end of data */
1747 return len;
1748}
1749static int viafb_dvp0_proc_write(struct file *file,
1750 const char __user *buffer, unsigned long count, void *data)
1751{
1752 char buf[20], *value, *pbuf;
1753 u8 reg_val = 0;
1754 unsigned long length, i;
1755 if (count < 1)
1756 return -EINVAL;
1757 length = count > 20 ? 20 : count;
1758 if (copy_from_user(&buf[0], buffer, length))
1759 return -EFAULT;
1760 buf[length - 1] = '\0'; /*Ensure end string */
1761 pbuf = &buf[0];
1762 for (i = 0; i < 3; i++) {
1763 value = strsep(&pbuf, " ");
1764 if (value != NULL) {
1765 strict_strtoul(value, 0, (unsigned long *)&reg_val);
1766 DEBUG_MSG(KERN_INFO "DVP0:reg_val[%l]=:%x\n", i,
1767 reg_val);
1768 switch (i) {
1769 case 0:
1770 viafb_write_reg_mask(CR96, VIACR,
1771 reg_val, 0x0f);
1772 break;
1773 case 1:
1774 viafb_write_reg_mask(SR2A, VIASR,
1775 reg_val << 4, BIT5);
1776 viafb_write_reg_mask(SR1B, VIASR,
1777 reg_val << 1, BIT1);
1778 break;
1779 case 2:
1780 viafb_write_reg_mask(SR2A, VIASR,
1781 reg_val << 3, BIT4);
1782 viafb_write_reg_mask(SR1E, VIASR,
1783 reg_val << 2, BIT2);
1784 break;
1785 default:
1786 break;
1787 }
1788 } else {
1789 break;
1790 }
1791 }
1792 return count;
1793}
1794static int viafb_dvp1_proc_read(char *buf, char **start, off_t offset,
1795 int count, int *eof, void *data)
1796{
1797 int len = 0;
1798 u8 dvp1 = 0, dvp1_data_dri = 0, dvp1_clk_dri = 0;
1799 dvp1 = viafb_read_reg(VIACR, CR9B) & 0x0f;
1800 dvp1_data_dri = (viafb_read_reg(VIASR, SR65) & 0x0c) >> 2;
1801 dvp1_clk_dri = viafb_read_reg(VIASR, SR65) & 0x03;
1802 len +=
1803 sprintf(buf + len, "%x %x %x\n", dvp1, dvp1_data_dri, dvp1_clk_dri);
1804 *eof = 1; /*Inform kernel end of data */
1805 return len;
1806}
1807static int viafb_dvp1_proc_write(struct file *file,
1808 const char __user *buffer, unsigned long count, void *data)
1809{
1810 char buf[20], *value, *pbuf;
1811 u8 reg_val = 0;
1812 unsigned long length, i;
1813 if (count < 1)
1814 return -EINVAL;
1815 length = count > 20 ? 20 : count;
1816 if (copy_from_user(&buf[0], buffer, length))
1817 return -EFAULT;
1818 buf[length - 1] = '\0'; /*Ensure end string */
1819 pbuf = &buf[0];
1820 for (i = 0; i < 3; i++) {
1821 value = strsep(&pbuf, " ");
1822 if (value != NULL) {
1823 strict_strtoul(value, 0, (unsigned long *)&reg_val);
1824 switch (i) {
1825 case 0:
1826 viafb_write_reg_mask(CR9B, VIACR,
1827 reg_val, 0x0f);
1828 break;
1829 case 1:
1830 viafb_write_reg_mask(SR65, VIASR,
1831 reg_val << 2, 0x0c);
1832 break;
1833 case 2:
1834 viafb_write_reg_mask(SR65, VIASR,
1835 reg_val, 0x03);
1836 break;
1837 default:
1838 break;
1839 }
1840 } else {
1841 break;
1842 }
1843 }
1844 return count;
1845}
1846
1847static int viafb_dfph_proc_read(char *buf, char **start, off_t offset,
1848 int count, int *eof, void *data)
1849{
1850 int len = 0;
1851 u8 dfp_high = 0;
1852 dfp_high = viafb_read_reg(VIACR, CR97) & 0x0f;
1853 len += sprintf(buf + len, "%x\n", dfp_high);
1854 *eof = 1; /*Inform kernel end of data */
1855 return len;
1856}
1857static int viafb_dfph_proc_write(struct file *file,
1858 const char __user *buffer, unsigned long count, void *data)
1859{
1860 char buf[20];
1861 u8 reg_val = 0;
1862 unsigned long length;
1863 if (count < 1)
1864 return -EINVAL;
1865 length = count > 20 ? 20 : count;
1866 if (copy_from_user(&buf[0], buffer, length))
1867 return -EFAULT;
1868 buf[length - 1] = '\0'; /*Ensure end string */
1869 strict_strtoul(&buf[0], 0, (unsigned long *)&reg_val);
1870 viafb_write_reg_mask(CR97, VIACR, reg_val, 0x0f);
1871 return count;
1872}
1873static int viafb_dfpl_proc_read(char *buf, char **start, off_t offset,
1874 int count, int *eof, void *data)
1875{
1876 int len = 0;
1877 u8 dfp_low = 0;
1878 dfp_low = viafb_read_reg(VIACR, CR99) & 0x0f;
1879 len += sprintf(buf + len, "%x\n", dfp_low);
1880 *eof = 1; /*Inform kernel end of data */
1881 return len;
1882}
1883static int viafb_dfpl_proc_write(struct file *file,
1884 const char __user *buffer, unsigned long count, void *data)
1885{
1886 char buf[20];
1887 u8 reg_val = 0;
1888 unsigned long length;
1889 if (count < 1)
1890 return -EINVAL;
1891 length = count > 20 ? 20 : count;
1892 if (copy_from_user(&buf[0], buffer, length))
1893 return -EFAULT;
1894 buf[length - 1] = '\0'; /*Ensure end string */
1895 strict_strtoul(&buf[0], 0, (unsigned long *)&reg_val);
1896 viafb_write_reg_mask(CR99, VIACR, reg_val, 0x0f);
1897 return count;
1898}
1899static int viafb_vt1636_proc_read(char *buf, char **start,
1900 off_t offset, int count, int *eof, void *data)
1901{
1902 int len = 0;
1903 u8 vt1636_08 = 0, vt1636_09 = 0;
1904 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1905 case VT1636_LVDS:
1906 vt1636_08 =
1907 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
1908 &viaparinfo->chip_info->lvds_chip_info, 0x08) & 0x0f;
1909 vt1636_09 =
1910 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
1911 &viaparinfo->chip_info->lvds_chip_info, 0x09) & 0x1f;
1912 len += sprintf(buf + len, "%x %x\n", vt1636_08, vt1636_09);
1913 break;
1914 default:
1915 break;
1916 }
1917 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
1918 case VT1636_LVDS:
1919 vt1636_08 =
1920 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
1921 &viaparinfo->chip_info->lvds_chip_info2, 0x08) & 0x0f;
1922 vt1636_09 =
1923 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
1924 &viaparinfo->chip_info->lvds_chip_info2, 0x09) & 0x1f;
1925 len += sprintf(buf + len, " %x %x\n", vt1636_08, vt1636_09);
1926 break;
1927 default:
1928 break;
1929 }
1930 *eof = 1; /*Inform kernel end of data */
1931 return len;
1932}
1933static int viafb_vt1636_proc_write(struct file *file,
1934 const char __user *buffer, unsigned long count, void *data)
1935{
1936 char buf[30], *value, *pbuf;
1937 struct IODATA reg_val;
1938 unsigned long length, i;
1939 if (count < 1)
1940 return -EINVAL;
1941 length = count > 30 ? 30 : count;
1942 if (copy_from_user(&buf[0], buffer, length))
1943 return -EFAULT;
1944 buf[length - 1] = '\0'; /*Ensure end string */
1945 pbuf = &buf[0];
1946 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1947 case VT1636_LVDS:
1948 for (i = 0; i < 2; i++) {
1949 value = strsep(&pbuf, " ");
1950 if (value != NULL) {
1951 strict_strtoul(value, 0,
1952 (unsigned long *)&reg_val.Data);
1953 switch (i) {
1954 case 0:
1955 reg_val.Index = 0x08;
1956 reg_val.Mask = 0x0f;
1957 viafb_gpio_i2c_write_mask_lvds
1958 (viaparinfo->lvds_setting_info,
1959 &viaparinfo->
1960 chip_info->lvds_chip_info,
1961 reg_val);
1962 break;
1963 case 1:
1964 reg_val.Index = 0x09;
1965 reg_val.Mask = 0x1f;
1966 viafb_gpio_i2c_write_mask_lvds
1967 (viaparinfo->lvds_setting_info,
1968 &viaparinfo->
1969 chip_info->lvds_chip_info,
1970 reg_val);
1971 break;
1972 default:
1973 break;
1974 }
1975 } else {
1976 break;
1977 }
1978 }
1979 break;
1980 default:
1981 break;
1982 }
1983 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
1984 case VT1636_LVDS:
1985 for (i = 0; i < 2; i++) {
1986 value = strsep(&pbuf, " ");
1987 if (value != NULL) {
1988 strict_strtoul(value, 0,
1989 (unsigned long *)&reg_val.Data);
1990 switch (i) {
1991 case 0:
1992 reg_val.Index = 0x08;
1993 reg_val.Mask = 0x0f;
1994 viafb_gpio_i2c_write_mask_lvds
1995 (viaparinfo->lvds_setting_info2,
1996 &viaparinfo->
1997 chip_info->lvds_chip_info2,
1998 reg_val);
1999 break;
2000 case 1:
2001 reg_val.Index = 0x09;
2002 reg_val.Mask = 0x1f;
2003 viafb_gpio_i2c_write_mask_lvds
2004 (viaparinfo->lvds_setting_info2,
2005 &viaparinfo->
2006 chip_info->lvds_chip_info2,
2007 reg_val);
2008 break;
2009 default:
2010 break;
2011 }
2012 } else {
2013 break;
2014 }
2015 }
2016 break;
2017 default:
2018 break;
2019 }
2020 return count;
2021}
2022
Bruno Prémontc267fd72008-11-19 15:36:23 -08002023static void viafb_init_proc(struct proc_dir_entry **viafb_entry)
Joseph Chan29b619f2008-10-15 22:03:27 -07002024{
2025 struct proc_dir_entry *entry;
Bruno Prémontc267fd72008-11-19 15:36:23 -08002026 *viafb_entry = proc_mkdir("viafb", NULL);
Joseph Chan29b619f2008-10-15 22:03:27 -07002027 if (viafb_entry) {
Bruno Prémontc267fd72008-11-19 15:36:23 -08002028 entry = create_proc_entry("dvp0", 0, *viafb_entry);
Joseph Chan29b619f2008-10-15 22:03:27 -07002029 if (entry) {
Joseph Chan29b619f2008-10-15 22:03:27 -07002030 entry->read_proc = viafb_dvp0_proc_read;
2031 entry->write_proc = viafb_dvp0_proc_write;
2032 }
Bruno Prémontc267fd72008-11-19 15:36:23 -08002033 entry = create_proc_entry("dvp1", 0, *viafb_entry);
Joseph Chan29b619f2008-10-15 22:03:27 -07002034 if (entry) {
Joseph Chan29b619f2008-10-15 22:03:27 -07002035 entry->read_proc = viafb_dvp1_proc_read;
2036 entry->write_proc = viafb_dvp1_proc_write;
2037 }
Bruno Prémontc267fd72008-11-19 15:36:23 -08002038 entry = create_proc_entry("dfph", 0, *viafb_entry);
Joseph Chan29b619f2008-10-15 22:03:27 -07002039 if (entry) {
Joseph Chan29b619f2008-10-15 22:03:27 -07002040 entry->read_proc = viafb_dfph_proc_read;
2041 entry->write_proc = viafb_dfph_proc_write;
2042 }
Bruno Prémontc267fd72008-11-19 15:36:23 -08002043 entry = create_proc_entry("dfpl", 0, *viafb_entry);
Joseph Chan29b619f2008-10-15 22:03:27 -07002044 if (entry) {
Joseph Chan29b619f2008-10-15 22:03:27 -07002045 entry->read_proc = viafb_dfpl_proc_read;
2046 entry->write_proc = viafb_dfpl_proc_write;
2047 }
2048 if (VT1636_LVDS == viaparinfo->chip_info->lvds_chip_info.
2049 lvds_chip_name || VT1636_LVDS ==
2050 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
Bruno Prémontc267fd72008-11-19 15:36:23 -08002051 entry = create_proc_entry("vt1636", 0, *viafb_entry);
Joseph Chan29b619f2008-10-15 22:03:27 -07002052 if (entry) {
Joseph Chan29b619f2008-10-15 22:03:27 -07002053 entry->read_proc = viafb_vt1636_proc_read;
2054 entry->write_proc = viafb_vt1636_proc_write;
2055 }
2056 }
2057
2058 }
2059}
2060static void viafb_remove_proc(struct proc_dir_entry *viafb_entry)
2061{
2062 /* no problem if it was not registered */
2063 remove_proc_entry("dvp0", viafb_entry);/* parent dir */
2064 remove_proc_entry("dvp1", viafb_entry);
2065 remove_proc_entry("dfph", viafb_entry);
2066 remove_proc_entry("dfpl", viafb_entry);
2067 remove_proc_entry("vt1636", viafb_entry);
2068 remove_proc_entry("vt1625", viafb_entry);
Bruno Prémontc267fd72008-11-19 15:36:23 -08002069 remove_proc_entry("viafb", NULL);
Joseph Chan29b619f2008-10-15 22:03:27 -07002070}
2071
2072static int __devinit via_pci_probe(void)
2073{
Harald Welteee1ef822009-05-12 13:19:42 -07002074 unsigned long default_xres, default_yres;
Joseph Chan29b619f2008-10-15 22:03:27 -07002075 char *tmpc, *tmpm;
2076 char *tmpc_sec, *tmpm_sec;
2077 int vmode_index;
2078 u32 tmds_length, lvds_length, crt_length, chip_length, viafb_par_length;
2079
2080 DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n");
2081
2082 viafb_par_length = ALIGN(sizeof(struct viafb_par), BITS_PER_LONG/8);
2083 tmds_length = ALIGN(sizeof(struct tmds_setting_information),
2084 BITS_PER_LONG/8);
2085 lvds_length = ALIGN(sizeof(struct lvds_setting_information),
2086 BITS_PER_LONG/8);
2087 crt_length = ALIGN(sizeof(struct lvds_setting_information),
2088 BITS_PER_LONG/8);
2089 chip_length = ALIGN(sizeof(struct chip_information), BITS_PER_LONG/8);
2090
2091 /* Allocate fb_info and ***_par here, also including some other needed
2092 * variables
2093 */
2094 viafbinfo = framebuffer_alloc(viafb_par_length + 2 * lvds_length +
2095 tmds_length + crt_length + chip_length, NULL);
2096 if (!viafbinfo) {
2097 printk(KERN_ERR"Could not allocate memory for viafb_info.\n");
2098 return -ENODEV;
2099 }
2100
2101 viaparinfo = (struct viafb_par *)viafbinfo->par;
2102 viaparinfo->tmds_setting_info = (struct tmds_setting_information *)
Joseph Chanb3a45d82008-10-15 22:03:29 -07002103 ((unsigned long)viaparinfo + viafb_par_length);
Joseph Chan29b619f2008-10-15 22:03:27 -07002104 viaparinfo->lvds_setting_info = (struct lvds_setting_information *)
Joseph Chanb3a45d82008-10-15 22:03:29 -07002105 ((unsigned long)viaparinfo->tmds_setting_info + tmds_length);
Joseph Chan29b619f2008-10-15 22:03:27 -07002106 viaparinfo->lvds_setting_info2 = (struct lvds_setting_information *)
Joseph Chanb3a45d82008-10-15 22:03:29 -07002107 ((unsigned long)viaparinfo->lvds_setting_info + lvds_length);
Joseph Chan29b619f2008-10-15 22:03:27 -07002108 viaparinfo->crt_setting_info = (struct crt_setting_information *)
Joseph Chanb3a45d82008-10-15 22:03:29 -07002109 ((unsigned long)viaparinfo->lvds_setting_info2 + lvds_length);
Joseph Chan29b619f2008-10-15 22:03:27 -07002110 viaparinfo->chip_info = (struct chip_information *)
Joseph Chanb3a45d82008-10-15 22:03:29 -07002111 ((unsigned long)viaparinfo->crt_setting_info + crt_length);
Joseph Chan29b619f2008-10-15 22:03:27 -07002112
2113 if (viafb_dual_fb)
2114 viafb_SAMM_ON = 1;
2115 parse_active_dev();
2116 parse_video_dev();
2117 parse_lcd_port();
2118 parse_dvi_port();
2119
2120 /* for dual-fb must viafb_SAMM_ON=1 and viafb_dual_fb=1 */
2121 if (!viafb_SAMM_ON)
2122 viafb_dual_fb = 0;
2123
2124 /* Set up I2C bus stuff */
2125 viafb_create_i2c_bus(viaparinfo);
2126
2127 viafb_init_chip_info();
2128 viafb_get_fb_info(&viaparinfo->fbmem, &viaparinfo->memsize);
2129 viaparinfo->fbmem_free = viaparinfo->memsize;
2130 viaparinfo->fbmem_used = 0;
2131 viaparinfo->fbmem_virt = ioremap_nocache(viaparinfo->fbmem,
2132 viaparinfo->memsize);
2133 viafbinfo->screen_base = (char *)viaparinfo->fbmem_virt;
2134
2135 if (!viaparinfo->fbmem_virt) {
2136 printk(KERN_INFO "ioremap failed\n");
2137 return -1;
2138 }
2139
2140 viafb_get_mmio_info(&viaparinfo->mmio_base, &viaparinfo->mmio_len);
2141 viaparinfo->io_virt = ioremap_nocache(viaparinfo->mmio_base,
2142 viaparinfo->mmio_len);
2143
2144 viafbinfo->node = 0;
2145 viafbinfo->fbops = &viafb_ops;
2146 viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
2147
2148 viafbinfo->pseudo_palette = pseudo_pal;
2149 if (viafb_accel) {
2150 viafb_init_accel();
2151 viafb_init_2d_engine();
2152 viafb_hw_cursor_init();
2153 }
2154
2155 if (viafb_second_size && (viafb_second_size < 8)) {
2156 viafb_second_offset = viaparinfo->fbmem_free -
2157 viafb_second_size * 1024 * 1024;
2158 } else {
2159 viafb_second_size = 8;
2160 viafb_second_offset = viaparinfo->fbmem_free -
2161 viafb_second_size * 1024 * 1024;
2162 }
2163
2164 viafb_FB_MM = viaparinfo->fbmem_virt;
2165 tmpm = viafb_mode;
2166 tmpc = strsep(&tmpm, "x");
Harald Welteee1ef822009-05-12 13:19:42 -07002167 strict_strtoul(tmpc, 0, &default_xres);
2168 strict_strtoul(tmpm, 0, &default_yres);
Joseph Chan29b619f2008-10-15 22:03:27 -07002169
Florian Tobias Schandinat52159442009-08-06 15:07:34 -07002170 vmode_index = viafb_get_mode_index(default_xres, default_yres);
Joseph Chan29b619f2008-10-15 22:03:27 -07002171 DEBUG_MSG(KERN_INFO "0->index=%d\n", vmode_index);
2172
2173 if (viafb_SAMM_ON == 1) {
2174 if (strcmp(viafb_mode, viafb_mode1)) {
2175 tmpm_sec = viafb_mode1;
2176 tmpc_sec = strsep(&tmpm_sec, "x");
2177 strict_strtoul(tmpc_sec, 0,
2178 (unsigned long *)&viafb_second_xres);
2179 strict_strtoul(tmpm_sec, 0,
2180 (unsigned long *)&viafb_second_yres);
2181 } else {
2182 viafb_second_xres = default_xres;
2183 viafb_second_yres = default_yres;
2184 }
2185 if (0 == viafb_second_virtual_xres) {
2186 switch (viafb_second_xres) {
2187 case 1400:
2188 viafb_second_virtual_xres = 1408;
2189 break;
2190 default:
2191 viafb_second_virtual_xres = viafb_second_xres;
2192 break;
2193 }
2194 }
2195 if (0 == viafb_second_virtual_yres)
2196 viafb_second_virtual_yres = viafb_second_yres;
2197 }
2198
2199 switch (viafb_bpp) {
2200 case 0 ... 8:
2201 viafb_bpp = 8;
2202 break;
2203 case 9 ... 16:
2204 viafb_bpp = 16;
2205 break;
2206 case 17 ... 32:
2207 viafb_bpp = 32;
2208 break;
2209 default:
2210 viafb_bpp = 8;
2211 }
2212 default_var.xres = default_xres;
2213 default_var.yres = default_yres;
2214 switch (default_xres) {
2215 case 1400:
2216 default_var.xres_virtual = 1408;
2217 break;
2218 default:
2219 default_var.xres_virtual = default_xres;
2220 break;
2221 }
2222 default_var.yres_virtual = default_yres;
2223 default_var.bits_per_pixel = viafb_bpp;
2224 if (default_var.bits_per_pixel == 15)
2225 default_var.bits_per_pixel = 16;
2226 default_var.pixclock =
2227 viafb_get_pixclock(default_xres, default_yres, viafb_refresh);
2228 default_var.left_margin = (default_xres >> 3) & 0xf8;
2229 default_var.right_margin = 32;
2230 default_var.upper_margin = 16;
2231 default_var.lower_margin = 4;
2232 default_var.hsync_len = default_var.left_margin;
2233 default_var.vsync_len = 4;
2234 default_var.accel_flags = 0;
2235
2236 if (viafb_accel) {
2237 viafbinfo->flags |=
2238 (FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT |
2239 FBINFO_HWACCEL_IMAGEBLIT);
2240 default_var.accel_flags |= FB_ACCELF_TEXT;
2241 } else
2242 viafbinfo->flags |= FBINFO_HWACCEL_DISABLED;
2243
2244 if (viafb_dual_fb) {
2245 viafbinfo1 = framebuffer_alloc(viafb_par_length, NULL);
2246 if (!viafbinfo1) {
2247 printk(KERN_ERR
2248 "allocate the second framebuffer struct error\n");
2249 framebuffer_release(viafbinfo);
2250 return -ENOMEM;
2251 }
2252 viaparinfo1 = viafbinfo1->par;
2253 memcpy(viaparinfo1, viaparinfo, viafb_par_length);
2254 viaparinfo1->memsize = viaparinfo->memsize -
2255 viafb_second_offset;
2256 viaparinfo->memsize = viafb_second_offset;
2257 viaparinfo1->fbmem_virt = viaparinfo->fbmem_virt +
2258 viafb_second_offset;
2259 viaparinfo1->fbmem = viaparinfo->fbmem + viafb_second_offset;
2260
2261 viaparinfo1->fbmem_used = viaparinfo->fbmem_used;
2262 viaparinfo1->fbmem_free = viaparinfo1->memsize -
2263 viaparinfo1->fbmem_used;
2264 viaparinfo->fbmem_free = viaparinfo->memsize;
2265 viaparinfo->fbmem_used = 0;
2266 if (viafb_accel) {
2267 viaparinfo1->cursor_start =
2268 viaparinfo->cursor_start - viafb_second_offset;
2269 viaparinfo1->VQ_start = viaparinfo->VQ_start -
2270 viafb_second_offset;
2271 viaparinfo1->VQ_end = viaparinfo->VQ_end -
2272 viafb_second_offset;
2273 }
2274
Florian Tobias Schandinat09cf1182009-09-22 16:47:14 -07002275 viaparinfo->iga_path = IGA1;
2276 viaparinfo1->iga_path = IGA2;
Joseph Chan29b619f2008-10-15 22:03:27 -07002277 memcpy(viafbinfo1, viafbinfo, sizeof(struct fb_info));
2278 viafbinfo1->screen_base = viafbinfo->screen_base +
2279 viafb_second_offset;
2280 viafbinfo1->fix.smem_start = viaparinfo1->fbmem;
2281 viafbinfo1->fix.smem_len = viaparinfo1->fbmem_free;
2282
2283 default_var.xres = viafb_second_xres;
2284 default_var.yres = viafb_second_yres;
2285 default_var.xres_virtual = viafb_second_virtual_xres;
2286 default_var.yres_virtual = viafb_second_virtual_yres;
2287 if (viafb_bpp1 != viafb_bpp)
2288 viafb_bpp1 = viafb_bpp;
2289 default_var.bits_per_pixel = viafb_bpp1;
2290 default_var.pixclock =
2291 viafb_get_pixclock(viafb_second_xres, viafb_second_yres,
2292 viafb_refresh);
2293 default_var.left_margin = (viafb_second_xres >> 3) & 0xf8;
2294 default_var.right_margin = 32;
2295 default_var.upper_margin = 16;
2296 default_var.lower_margin = 4;
2297 default_var.hsync_len = default_var.left_margin;
2298 default_var.vsync_len = 4;
2299
2300 viafb_setup_fixinfo(&viafbinfo1->fix, viaparinfo1);
2301 viafb_check_var(&default_var, viafbinfo1);
2302 viafbinfo1->var = default_var;
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -07002303 viafb_update_fix(viafbinfo1);
Joseph Chan29b619f2008-10-15 22:03:27 -07002304 }
2305
2306 viafb_setup_fixinfo(&viafbinfo->fix, viaparinfo);
2307 viafb_check_var(&default_var, viafbinfo);
2308 viafbinfo->var = default_var;
Florian Tobias Schandinat81228a32009-09-22 16:47:13 -07002309 viafb_update_fix(viafbinfo);
Joseph Chan29b619f2008-10-15 22:03:27 -07002310 default_var.activate = FB_ACTIVATE_NOW;
2311 fb_alloc_cmap(&viafbinfo->cmap, 256, 0);
2312
2313 if (viafb_dual_fb && (viafb_primary_dev == LCD_Device)
2314 && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) {
2315 if (register_framebuffer(viafbinfo1) < 0)
2316 return -EINVAL;
2317 }
2318 if (register_framebuffer(viafbinfo) < 0)
2319 return -EINVAL;
2320
2321 if (viafb_dual_fb && ((viafb_primary_dev != LCD_Device)
2322 || (viaparinfo->chip_info->gfx_chip_name !=
2323 UNICHROME_CLE266))) {
2324 if (register_framebuffer(viafbinfo1) < 0)
2325 return -EINVAL;
2326 }
2327 DEBUG_MSG(KERN_INFO "fb%d: %s frame buffer device %dx%d-%dbpp\n",
2328 viafbinfo->node, viafbinfo->fix.id, default_var.xres,
2329 default_var.yres, default_var.bits_per_pixel);
2330
Bruno Prémontc267fd72008-11-19 15:36:23 -08002331 viafb_init_proc(&viaparinfo->proc_entry);
Joseph Chan29b619f2008-10-15 22:03:27 -07002332 viafb_init_dac(IGA2);
2333 return 0;
2334}
2335
2336static void __devexit via_pci_remove(void)
2337{
2338 DEBUG_MSG(KERN_INFO "via_pci_remove!\n");
2339 fb_dealloc_cmap(&viafbinfo->cmap);
2340 unregister_framebuffer(viafbinfo);
2341 if (viafb_dual_fb)
2342 unregister_framebuffer(viafbinfo1);
2343 iounmap((void *)viaparinfo->fbmem_virt);
2344 iounmap(viaparinfo->io_virt);
2345
2346 viafb_delete_i2c_buss(viaparinfo);
2347
2348 framebuffer_release(viafbinfo);
2349 if (viafb_dual_fb)
2350 framebuffer_release(viafbinfo1);
2351
2352 viafb_remove_proc(viaparinfo->proc_entry);
2353}
2354
2355#ifndef MODULE
2356static int __init viafb_setup(char *options)
2357{
2358 char *this_opt;
2359 DEBUG_MSG(KERN_INFO "viafb_setup!\n");
2360
2361 if (!options || !*options)
2362 return 0;
2363
2364 while ((this_opt = strsep(&options, ",")) != NULL) {
2365 if (!*this_opt)
2366 continue;
2367
2368 if (!strncmp(this_opt, "viafb_mode1=", 12))
2369 viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL);
2370 else if (!strncmp(this_opt, "viafb_mode=", 11))
2371 viafb_mode = kstrdup(this_opt + 11, GFP_KERNEL);
2372 else if (!strncmp(this_opt, "viafb_bpp1=", 11))
2373 strict_strtoul(this_opt + 11, 0,
2374 (unsigned long *)&viafb_bpp1);
2375 else if (!strncmp(this_opt, "viafb_bpp=", 10))
2376 strict_strtoul(this_opt + 10, 0,
2377 (unsigned long *)&viafb_bpp);
2378 else if (!strncmp(this_opt, "viafb_refresh1=", 15))
2379 strict_strtoul(this_opt + 15, 0,
2380 (unsigned long *)&viafb_refresh1);
2381 else if (!strncmp(this_opt, "viafb_refresh=", 14))
2382 strict_strtoul(this_opt + 14, 0,
2383 (unsigned long *)&viafb_refresh);
2384 else if (!strncmp(this_opt, "viafb_lcd_dsp_method=", 21))
2385 strict_strtoul(this_opt + 21, 0,
2386 (unsigned long *)&viafb_lcd_dsp_method);
2387 else if (!strncmp(this_opt, "viafb_lcd_panel_id=", 19))
2388 strict_strtoul(this_opt + 19, 0,
2389 (unsigned long *)&viafb_lcd_panel_id);
2390 else if (!strncmp(this_opt, "viafb_accel=", 12))
2391 strict_strtoul(this_opt + 12, 0,
2392 (unsigned long *)&viafb_accel);
2393 else if (!strncmp(this_opt, "viafb_SAMM_ON=", 14))
2394 strict_strtoul(this_opt + 14, 0,
2395 (unsigned long *)&viafb_SAMM_ON);
2396 else if (!strncmp(this_opt, "viafb_active_dev=", 17))
2397 viafb_active_dev = kstrdup(this_opt + 17, GFP_KERNEL);
2398 else if (!strncmp(this_opt,
2399 "viafb_display_hardware_layout=", 30))
2400 strict_strtoul(this_opt + 30, 0,
2401 (unsigned long *)&viafb_display_hardware_layout);
2402 else if (!strncmp(this_opt, "viafb_second_size=", 18))
2403 strict_strtoul(this_opt + 18, 0,
2404 (unsigned long *)&viafb_second_size);
2405 else if (!strncmp(this_opt,
2406 "viafb_platform_epia_dvi=", 24))
2407 strict_strtoul(this_opt + 24, 0,
2408 (unsigned long *)&viafb_platform_epia_dvi);
2409 else if (!strncmp(this_opt,
2410 "viafb_device_lcd_dualedge=", 26))
2411 strict_strtoul(this_opt + 26, 0,
2412 (unsigned long *)&viafb_device_lcd_dualedge);
2413 else if (!strncmp(this_opt, "viafb_bus_width=", 16))
2414 strict_strtoul(this_opt + 16, 0,
2415 (unsigned long *)&viafb_bus_width);
2416 else if (!strncmp(this_opt, "viafb_lcd_mode=", 15))
2417 strict_strtoul(this_opt + 15, 0,
2418 (unsigned long *)&viafb_lcd_mode);
2419 else if (!strncmp(this_opt, "viafb_video_dev=", 16))
2420 viafb_video_dev = kstrdup(this_opt + 16, GFP_KERNEL);
2421 else if (!strncmp(this_opt, "viafb_lcd_port=", 15))
2422 viafb_lcd_port = kstrdup(this_opt + 15, GFP_KERNEL);
2423 else if (!strncmp(this_opt, "viafb_dvi_port=", 15))
2424 viafb_dvi_port = kstrdup(this_opt + 15, GFP_KERNEL);
2425 }
2426 return 0;
2427}
2428#endif
2429
2430static int __init viafb_init(void)
2431{
2432#ifndef MODULE
2433 char *option = NULL;
2434 if (fb_get_options("viafb", &option))
2435 return -ENODEV;
2436 viafb_setup(option);
2437#endif
2438 printk(KERN_INFO
2439 "VIA Graphics Intergration Chipset framebuffer %d.%d initializing\n",
2440 VERSION_MAJOR, VERSION_MINOR);
2441 return via_pci_probe();
2442}
2443
2444static void __exit viafb_exit(void)
2445{
2446 DEBUG_MSG(KERN_INFO "viafb_exit!\n");
2447 via_pci_remove();
2448}
2449
2450static struct fb_ops viafb_ops = {
2451 .owner = THIS_MODULE,
2452 .fb_open = viafb_open,
2453 .fb_release = viafb_release,
2454 .fb_check_var = viafb_check_var,
2455 .fb_set_par = viafb_set_par,
2456 .fb_setcolreg = viafb_setcolreg,
2457 .fb_pan_display = viafb_pan_display,
2458 .fb_blank = viafb_blank,
2459 .fb_fillrect = viafb_fillrect,
2460 .fb_copyarea = viafb_copyarea,
2461 .fb_imageblit = viafb_imageblit,
2462 .fb_cursor = viafb_cursor,
2463 .fb_ioctl = viafb_ioctl,
2464 .fb_sync = viafb_sync,
2465 .fb_setcmap = viafb_setcmap,
2466};
2467
2468module_init(viafb_init);
2469module_exit(viafb_exit);
2470
2471#ifdef MODULE
2472module_param(viafb_memsize, int, 0);
2473
2474module_param(viafb_mode, charp, 0);
2475MODULE_PARM_DESC(viafb_mode, "Set resolution (default=640x480)");
2476
2477module_param(viafb_mode1, charp, 0);
2478MODULE_PARM_DESC(viafb_mode1, "Set resolution (default=640x480)");
2479
2480module_param(viafb_bpp, int, 0);
2481MODULE_PARM_DESC(viafb_bpp, "Set color depth (default=32bpp)");
2482
2483module_param(viafb_bpp1, int, 0);
2484MODULE_PARM_DESC(viafb_bpp1, "Set color depth (default=32bpp)");
2485
2486module_param(viafb_refresh, int, 0);
2487MODULE_PARM_DESC(viafb_refresh,
2488 "Set CRT viafb_refresh rate (default = 60)");
2489
2490module_param(viafb_refresh1, int, 0);
2491MODULE_PARM_DESC(viafb_refresh1,
2492 "Set CRT refresh rate (default = 60)");
2493
2494module_param(viafb_lcd_panel_id, int, 0);
2495MODULE_PARM_DESC(viafb_lcd_panel_id,
2496 "Set Flat Panel type(Default=1024x768)");
2497
2498module_param(viafb_lcd_dsp_method, int, 0);
2499MODULE_PARM_DESC(viafb_lcd_dsp_method,
2500 "Set Flat Panel display scaling method.(Default=Expandsion)");
2501
2502module_param(viafb_SAMM_ON, int, 0);
2503MODULE_PARM_DESC(viafb_SAMM_ON,
2504 "Turn on/off flag of SAMM(Default=OFF)");
2505
2506module_param(viafb_accel, int, 0);
2507MODULE_PARM_DESC(viafb_accel,
2508 "Set 2D Hardware Acceleration.(Default = OFF)");
2509
2510module_param(viafb_active_dev, charp, 0);
2511MODULE_PARM_DESC(viafb_active_dev, "Specify active devices.");
2512
2513module_param(viafb_display_hardware_layout, int, 0);
2514MODULE_PARM_DESC(viafb_display_hardware_layout,
2515 "Display Hardware Layout (LCD Only, DVI Only...,etc)");
2516
2517module_param(viafb_second_size, int, 0);
2518MODULE_PARM_DESC(viafb_second_size,
2519 "Set secondary device memory size");
2520
2521module_param(viafb_dual_fb, int, 0);
2522MODULE_PARM_DESC(viafb_dual_fb,
2523 "Turn on/off flag of dual framebuffer devices.(Default = OFF)");
2524
2525module_param(viafb_platform_epia_dvi, int, 0);
2526MODULE_PARM_DESC(viafb_platform_epia_dvi,
2527 "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)");
2528
2529module_param(viafb_device_lcd_dualedge, int, 0);
2530MODULE_PARM_DESC(viafb_device_lcd_dualedge,
2531 "Turn on/off flag of dual edge panel.(Default = OFF)");
2532
2533module_param(viafb_bus_width, int, 0);
2534MODULE_PARM_DESC(viafb_bus_width,
2535 "Set bus width of panel.(Default = 12)");
2536
2537module_param(viafb_lcd_mode, int, 0);
2538MODULE_PARM_DESC(viafb_lcd_mode,
2539 "Set Flat Panel mode(Default=OPENLDI)");
2540
2541module_param(viafb_video_dev, charp, 0);
2542MODULE_PARM_DESC(viafb_video_dev, "Specify video devices.");
2543
2544module_param(viafb_lcd_port, charp, 0);
2545MODULE_PARM_DESC(viafb_lcd_port, "Specify LCD output port.");
2546
2547module_param(viafb_dvi_port, charp, 0);
2548MODULE_PARM_DESC(viafb_dvi_port, "Specify DVI output port.");
2549
2550MODULE_LICENSE("GPL");
2551#endif