2 * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
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.
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
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
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #include <linux/module.h>
27 static int MAX_CURS = 32;
28 static struct fb_var_screeninfo default_var;
29 static char *viafb_name = "Via";
30 static u32 pseudo_pal[17];
33 static char *viafb_mode = "640x480";
34 static char *viafb_mode1 = "640x480";
36 /* Added for specifying active devices.*/
37 char *viafb_active_dev = "";
39 /*Added for specify lcd output port*/
40 char *viafb_lcd_port = "";
41 char *viafb_dvi_port = "";
43 static void viafb_set_device(struct device_t active_dev);
44 static int apply_device_setting(struct viafb_ioctl_setting setting_info,
45 struct fb_info *info);
46 static void apply_second_mode_setting(struct fb_var_screeninfo
48 static void retrieve_device_setting(struct viafb_ioctl_setting
51 static struct fb_ops viafb_ops;
54 static void viafb_update_fix(struct fb_info *info)
56 u32 bpp = info->var.bits_per_pixel;
59 bpp == 8 ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
60 info->fix.line_length =
61 ((info->var.xres_virtual + 7) & ~7) * bpp / 8;
64 static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix,
65 struct viafb_par *viaparinfo)
67 memset(fix, 0, sizeof(struct fb_fix_screeninfo));
68 strcpy(fix->id, viafb_name);
70 fix->smem_start = viaparinfo->fbmem;
71 fix->smem_len = viaparinfo->fbmem_free;
73 fix->type = FB_TYPE_PACKED_PIXELS;
76 fix->xpanstep = fix->ywrapstep = 0;
79 /* Just tell the accel name */
80 viafbinfo->fix.accel = FB_ACCEL_VIA_UNICHROME;
82 static int viafb_open(struct fb_info *info, int user)
84 DEBUG_MSG(KERN_INFO "viafb_open!\n");
88 static int viafb_release(struct fb_info *info, int user)
90 DEBUG_MSG(KERN_INFO "viafb_release!\n");
94 static int viafb_check_var(struct fb_var_screeninfo *var,
97 int vmode_index, htotal, vtotal;
98 struct viafb_par *ppar;
100 struct viafb_par *p_viafb_par;
104 DEBUG_MSG(KERN_INFO "viafb_check_var!\n");
106 /* HW neither support interlacte nor double-scaned mode */
107 if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE)
110 vmode_index = viafb_get_mode_index(var->xres, var->yres);
111 if (vmode_index == VIA_RES_INVALID) {
113 "viafb: Mode %dx%dx%d not supported!!\n",
114 var->xres, var->yres, var->bits_per_pixel);
118 if (24 == var->bits_per_pixel)
119 var->bits_per_pixel = 32;
121 if (var->bits_per_pixel != 8 && var->bits_per_pixel != 16 &&
122 var->bits_per_pixel != 32)
125 if ((var->xres_virtual * (var->bits_per_pixel >> 3)) & 0x1F)
126 /*32 pixel alignment */
127 var->xres_virtual = (var->xres_virtual + 31) & ~31;
128 if (var->xres_virtual * var->yres_virtual * var->bits_per_pixel / 8 >
132 /* Based on var passed in to calculate the refresh,
133 * because our driver use some modes special.
135 htotal = var->xres + var->left_margin +
136 var->right_margin + var->hsync_len;
137 vtotal = var->yres + var->upper_margin +
138 var->lower_margin + var->vsync_len;
139 long_refresh = 1000000000UL / var->pixclock * 1000;
140 long_refresh /= (htotal * vtotal);
142 viafb_refresh = viafb_get_refresh(var->xres, var->yres, long_refresh);
144 /* Adjust var according to our driver's own table */
145 viafb_fill_var_timing_info(var, viafb_refresh, vmode_index);
147 /* This is indeed a patch for VT3353 */
150 p_viafb_par = (struct viafb_par *)info->par;
151 if (p_viafb_par->chip_info->gfx_chip_name == UNICHROME_VX800)
152 var->accel_flags = 0;
157 static int viafb_set_par(struct fb_info *info)
160 int vmode_index1 = 0;
161 DEBUG_MSG(KERN_INFO "viafb_set_par!\n");
163 viafb_update_device_setting(info->var.xres, info->var.yres,
164 info->var.bits_per_pixel, viafb_refresh, 0);
166 vmode_index = viafb_get_mode_index(info->var.xres, info->var.yres);
168 if (viafb_SAMM_ON == 1) {
170 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
171 viafb_second_xres, viafb_second_yres, viafb_bpp1);
172 vmode_index1 = viafb_get_mode_index(viafb_second_xres,
174 DEBUG_MSG(KERN_INFO "->viafb_SAMM_ON: index=%d\n",
177 viafb_update_device_setting(viafb_second_xres,
178 viafb_second_yres, viafb_bpp1, viafb_refresh1, 1);
181 if (vmode_index != VIA_RES_INVALID) {
182 viafb_setmode(vmode_index, info->var.xres, info->var.yres,
183 info->var.bits_per_pixel, vmode_index1,
184 viafb_second_xres, viafb_second_yres, viafb_bpp1);
186 /*We should set memory offset according virtual_x */
187 /*Fix me:put this function into viafb_setmode */
188 viafb_memory_pitch_patch(info);
189 viafb_update_fix(info);
190 viafb_bpp = info->var.bits_per_pixel;
191 /* Update viafb_accel, it is necessary to our 2D accelerate */
192 viafb_accel = info->var.accel_flags;
195 viafb_set_2d_color_depth(info->var.bits_per_pixel);
201 /* Set one color register */
202 static int viafb_setcolreg(unsigned regno, unsigned red, unsigned green,
203 unsigned blue, unsigned transp, struct fb_info *info)
205 u8 sr1a, sr1b, cr67, cr6a, rev = 0, shift = 10;
206 unsigned cmap_entries = (info->var.bits_per_pixel == 8) ? 256 : 16;
207 DEBUG_MSG(KERN_INFO "viafb_setcolreg!\n");
208 if (regno >= cmap_entries)
210 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name) {
212 * Read PCI bus 0,dev 0,function 0,index 0xF6 to get chip rev.
214 outl(0x80000000 | (0xf6 & ~3), (unsigned long)0xCF8);
215 rev = (inl((unsigned long)0xCFC) >> ((0xf6 & 3) * 8)) & 0xff;
217 switch (info->var.bits_per_pixel) {
228 /* Map the 3C6/7/8/9 to the IGA2 */
230 outb(sr1a | 0x01, 0x3C5);
231 /* Second Display Engine colck always on */
233 outb(sr1b | 0x80, 0x3C5);
234 /* Second Display Color Depth 8 */
236 outb(cr67 & 0x3F, 0x3D5);
238 /* Second Display Channel Reset CR6A[6]) */
239 outb(cr6a & 0xBF, 0x3D5);
240 /* Second Display Channel Enable CR6A[7] */
241 outb(cr6a | 0x80, 0x3D5);
242 /* Second Display Channel stop reset) */
243 outb(cr6a | 0x40, 0x3D5);
245 /* Bit mask of palette */
247 /* Write one register of IGA2 */
249 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name &&
252 viafb_write_reg_mask(CR6A, VIACR, BIT5, BIT5);
253 viafb_write_reg_mask(SR15, VIASR, BIT7, BIT7);
256 viafb_write_reg_mask(CR6A, VIACR, 0, BIT5);
257 viafb_write_reg_mask(SR15, VIASR, 0, BIT7);
259 outb(red >> shift, 0x3C9);
260 outb(green >> shift, 0x3C9);
261 outb(blue >> shift, 0x3C9);
263 /* Map the 3C6/7/8/9 to the IGA1 */
265 outb(sr1a & 0xFE, 0x3C5);
266 /* Bit mask of palette */
268 /* Write one register of IGA1 */
270 outb(red >> shift, 0x3C9);
271 outb(green >> shift, 0x3C9);
272 outb(blue >> shift, 0x3C9);
284 ((u32 *) info->pseudo_palette)[regno] = (red & 0xF800) |
285 ((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11);
288 ((u32 *) info->pseudo_palette)[regno] =
289 ((transp & 0xFF00) << 16) |
290 ((red & 0xFF00) << 8) |
291 ((green & 0xFF00)) | ((blue & 0xFF00) >> 8);
299 /*CALLED BY: fb_set_cmap */
300 /* fb_set_var, pass 256 colors */
301 /*CALLED BY: fb_set_cmap */
302 /* fbcon_set_palette, pass 16 colors */
303 static int viafb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
307 u16 *pred = cmap->red;
308 u16 *pgreen = cmap->green;
309 u16 *pblue = cmap->blue;
310 u16 *ptransp = cmap->transp;
311 u8 sr1a, sr1b, cr67, cr6a, rev = 0, shift = 10;
314 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name) {
316 * Read PCI bus 0, dev 0, function 0, index 0xF6 to get chip
319 outl(0x80000000 | (0xf6 & ~3), (unsigned long)0xCF8);
320 rev = (inl((unsigned long)0xCFC) >> ((0xf6 & 3) * 8)) & 0xff;
322 switch (info->var.bits_per_pixel) {
332 /* Map the 3C6/7/8/9 to the IGA2 */
334 outb(sr1a | 0x01, 0x3C5);
336 /* Second Display Engine colck always on */
337 outb(sr1b | 0x80, 0x3C5);
339 /* Second Display Color Depth 8 */
340 outb(cr67 & 0x3F, 0x3D5);
342 /* Second Display Channel Reset CR6A[6]) */
343 outb(cr6a & 0xBF, 0x3D5);
344 /* Second Display Channel Enable CR6A[7] */
345 outb(cr6a | 0x80, 0x3D5);
346 /* Second Display Channel stop reset) */
347 outb(cr6a | 0xC0, 0x3D5);
349 /* Bit mask of palette */
352 if (UNICHROME_CLE266 == viaparinfo->chip_info->gfx_chip_name &&
355 viafb_write_reg_mask(CR6A, VIACR, BIT5, BIT5);
356 viafb_write_reg_mask(SR15, VIASR, BIT7, BIT7);
359 viafb_write_reg_mask(CR6A, VIACR, 0, BIT5);
360 viafb_write_reg_mask(SR15, VIASR, 0, BIT7);
362 for (i = 0; i < len; i++) {
363 outb((*(pred + i)) >> shift, 0x3C9);
364 outb((*(pgreen + i)) >> shift, 0x3C9);
365 outb((*(pblue + i)) >> shift, 0x3C9);
369 /* Map the 3C6/7/8/9 to the IGA1 */
370 outb(sr1a & 0xFE, 0x3C5);
371 /* Bit mask of palette */
374 for (i = 0; i < len; i++) {
375 outb((*(pred + i)) >> shift, 0x3C9);
376 outb((*(pgreen + i)) >> shift, 0x3C9);
377 outb((*(pblue + i)) >> shift, 0x3C9);
391 return 0; /* Because static u32 pseudo_pal[17]; */
392 for (i = 0; i < len; i++)
393 ((u32 *) info->pseudo_palette)[i] =
394 (*(pred + i) & 0xF800) |
395 ((*(pgreen + i) & 0xFC00) >> 5) |
396 ((*(pblue + i) & 0xF800) >> 11);
402 for (i = 0; i < len; i++)
403 ((u32 *) info->pseudo_palette)[i] =
404 ((*(ptransp + i) & 0xFF00) << 16) |
405 ((*(pred + i) & 0xFF00) << 8) |
406 ((*(pgreen + i) & 0xFF00)) |
407 ((*(pblue + i) & 0xFF00) >> 8);
409 for (i = 0; i < len; i++)
410 ((u32 *) info->pseudo_palette)[i] =
412 ((*(pred + i) & 0xFF00) << 8) |
413 ((*(pgreen + i) & 0xFF00)) |
414 ((*(pblue + i) & 0xFF00) >> 8);
421 static int viafb_pan_display(struct fb_var_screeninfo *var,
422 struct fb_info *info)
426 DEBUG_MSG(KERN_INFO "viafb_pan_display!\n");
428 offset = (var->xoffset + (var->yoffset * var->xres_virtual)) *
429 var->bits_per_pixel / 16;
431 DEBUG_MSG(KERN_INFO "\nviafb_pan_display,offset =%d ", offset);
432 viafb_set_primary_address(offset);
436 static int viafb_blank(int blank_mode, struct fb_info *info)
438 DEBUG_MSG(KERN_INFO "viafb_blank!\n");
439 /* clear DPMS setting */
441 switch (blank_mode) {
442 case FB_BLANK_UNBLANK:
443 /* Screen: On, HSync: On, VSync: On */
444 /* control CRT monitor power management */
445 viafb_write_reg_mask(CR36, VIACR, 0x00, BIT4 + BIT5);
447 case FB_BLANK_HSYNC_SUSPEND:
448 /* Screen: Off, HSync: Off, VSync: On */
449 /* control CRT monitor power management */
450 viafb_write_reg_mask(CR36, VIACR, 0x10, BIT4 + BIT5);
452 case FB_BLANK_VSYNC_SUSPEND:
453 /* Screen: Off, HSync: On, VSync: Off */
454 /* control CRT monitor power management */
455 viafb_write_reg_mask(CR36, VIACR, 0x20, BIT4 + BIT5);
457 case FB_BLANK_POWERDOWN:
458 /* Screen: Off, HSync: Off, VSync: Off */
459 /* control CRT monitor power management */
460 viafb_write_reg_mask(CR36, VIACR, 0x30, BIT4 + BIT5);
467 static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
470 struct viafb_ioctl_mode viamode;
471 struct viafb_ioctl_samm viasamm;
472 struct viafb_driver_version driver_version;
473 struct fb_var_screeninfo sec_var;
474 struct _panel_size_pos_info panel_pos_size_para;
475 struct viafb_ioctl_setting viafb_setting;
476 struct device_t active_dev;
479 u32 *viafb_gamma_table;
480 char driver_name[] = "viafb";
482 u32 __user *argp = (u32 __user *) arg;
485 DEBUG_MSG(KERN_INFO "viafb_ioctl: 0x%X !!\n", cmd);
486 memset(&u, 0, sizeof(u));
489 case VIAFB_GET_CHIP_INFO:
490 if (copy_to_user(argp, viaparinfo->chip_info,
491 sizeof(struct chip_information)))
494 case VIAFB_GET_INFO_SIZE:
495 return put_user((u32)sizeof(struct viafb_ioctl_info), argp);
497 return viafb_ioctl_get_viafb_info(arg);
499 return put_user(viafb_ioctl_hotplug(info->var.xres,
501 info->var.bits_per_pixel), argp);
502 case VIAFB_SET_HOTPLUG_FLAG:
503 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
505 viafb_hotplug = (gpu32) ? 1 : 0;
507 case VIAFB_GET_RESOLUTION:
508 u.viamode.xres = (u32) viafb_hotplug_Xres;
509 u.viamode.yres = (u32) viafb_hotplug_Yres;
510 u.viamode.refresh = (u32) viafb_hotplug_refresh;
511 u.viamode.bpp = (u32) viafb_hotplug_bpp;
512 if (viafb_SAMM_ON == 1) {
513 u.viamode.xres_sec = viafb_second_xres;
514 u.viamode.yres_sec = viafb_second_yres;
515 u.viamode.virtual_xres_sec = viafb_second_virtual_xres;
516 u.viamode.virtual_yres_sec = viafb_second_virtual_yres;
517 u.viamode.refresh_sec = viafb_refresh1;
518 u.viamode.bpp_sec = viafb_bpp1;
520 u.viamode.xres_sec = 0;
521 u.viamode.yres_sec = 0;
522 u.viamode.virtual_xres_sec = 0;
523 u.viamode.virtual_yres_sec = 0;
524 u.viamode.refresh_sec = 0;
525 u.viamode.bpp_sec = 0;
527 if (copy_to_user(argp, &u.viamode, sizeof(u.viamode)))
530 case VIAFB_GET_SAMM_INFO:
531 u.viasamm.samm_status = viafb_SAMM_ON;
533 if (viafb_SAMM_ON == 1) {
535 u.viasamm.size_prim = viaparinfo->fbmem_free;
536 u.viasamm.size_sec = viaparinfo1->fbmem_free;
538 if (viafb_second_size) {
539 u.viasamm.size_prim =
540 viaparinfo->fbmem_free -
541 viafb_second_size * 1024 * 1024;
543 viafb_second_size * 1024 * 1024;
545 u.viasamm.size_prim =
546 viaparinfo->fbmem_free >> 1;
548 (viaparinfo->fbmem_free >> 1);
551 u.viasamm.mem_base = viaparinfo->fbmem;
552 u.viasamm.offset_sec = viafb_second_offset;
554 u.viasamm.size_prim =
555 viaparinfo->memsize - viaparinfo->fbmem_used;
556 u.viasamm.size_sec = 0;
557 u.viasamm.mem_base = viaparinfo->fbmem;
558 u.viasamm.offset_sec = 0;
561 if (copy_to_user(argp, &u.viasamm, sizeof(u.viasamm)))
565 case VIAFB_TURN_ON_OUTPUT_DEVICE:
566 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
568 if (gpu32 & CRT_Device)
570 if (gpu32 & DVI_Device)
572 if (gpu32 & LCD_Device)
575 case VIAFB_TURN_OFF_OUTPUT_DEVICE:
576 if (copy_from_user(&gpu32, argp, sizeof(gpu32)))
578 if (gpu32 & CRT_Device)
580 if (gpu32 & DVI_Device)
582 if (gpu32 & LCD_Device)
585 case VIAFB_SET_DEVICE:
586 if (copy_from_user(&u.active_dev, (void *)argp,
587 sizeof(u.active_dev)))
589 viafb_set_device(u.active_dev);
592 case VIAFB_GET_DEVICE:
593 u.active_dev.crt = viafb_CRT_ON;
594 u.active_dev.dvi = viafb_DVI_ON;
595 u.active_dev.lcd = viafb_LCD_ON;
596 u.active_dev.samm = viafb_SAMM_ON;
597 u.active_dev.primary_dev = viafb_primary_dev;
599 u.active_dev.lcd_dsp_cent = viafb_lcd_dsp_method;
600 u.active_dev.lcd_panel_id = viafb_lcd_panel_id;
601 u.active_dev.lcd_mode = viafb_lcd_mode;
603 u.active_dev.xres = viafb_hotplug_Xres;
604 u.active_dev.yres = viafb_hotplug_Yres;
606 u.active_dev.xres1 = viafb_second_xres;
607 u.active_dev.yres1 = viafb_second_yres;
609 u.active_dev.bpp = viafb_bpp;
610 u.active_dev.bpp1 = viafb_bpp1;
611 u.active_dev.refresh = viafb_refresh;
612 u.active_dev.refresh1 = viafb_refresh1;
614 u.active_dev.epia_dvi = viafb_platform_epia_dvi;
615 u.active_dev.lcd_dual_edge = viafb_device_lcd_dualedge;
616 u.active_dev.bus_width = viafb_bus_width;
618 if (copy_to_user(argp, &u.active_dev, sizeof(u.active_dev)))
622 case VIAFB_GET_DRIVER_VERSION:
623 u.driver_version.iMajorNum = VERSION_MAJOR;
624 u.driver_version.iKernelNum = VERSION_KERNEL;
625 u.driver_version.iOSNum = VERSION_OS;
626 u.driver_version.iMinorNum = VERSION_MINOR;
628 if (copy_to_user(argp, &u.driver_version,
629 sizeof(u.driver_version)))
634 case VIAFB_SET_DEVICE_INFO:
635 if (copy_from_user(&u.viafb_setting,
636 argp, sizeof(u.viafb_setting)))
638 if (apply_device_setting(u.viafb_setting, info) < 0)
643 case VIAFB_SET_SECOND_MODE:
644 if (copy_from_user(&u.sec_var, argp, sizeof(u.sec_var)))
646 apply_second_mode_setting(&u.sec_var);
649 case VIAFB_GET_DEVICE_INFO:
651 retrieve_device_setting(&u.viafb_setting);
653 if (copy_to_user(argp, &u.viafb_setting,
654 sizeof(u.viafb_setting)))
659 case VIAFB_GET_DEVICE_SUPPORT:
660 viafb_get_device_support_state(&state_info);
661 if (put_user(state_info, argp))
665 case VIAFB_GET_DEVICE_CONNECT:
666 viafb_get_device_connect_state(&state_info);
667 if (put_user(state_info, argp))
671 case VIAFB_GET_PANEL_SUPPORT_EXPAND:
673 viafb_lcd_get_support_expand_state(info->var.xres,
675 if (put_user(state_info, argp))
679 case VIAFB_GET_DRIVER_NAME:
680 if (copy_to_user(argp, driver_name, sizeof(driver_name)))
684 case VIAFB_SET_GAMMA_LUT:
685 viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
686 if (!viafb_gamma_table)
688 if (copy_from_user(viafb_gamma_table, argp,
689 sizeof(viafb_gamma_table))) {
690 kfree(viafb_gamma_table);
693 viafb_set_gamma_table(viafb_bpp, viafb_gamma_table);
694 kfree(viafb_gamma_table);
697 case VIAFB_GET_GAMMA_LUT:
698 viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
699 if (!viafb_gamma_table)
701 viafb_get_gamma_table(viafb_gamma_table);
702 if (copy_to_user(argp, viafb_gamma_table,
703 sizeof(viafb_gamma_table))) {
704 kfree(viafb_gamma_table);
707 kfree(viafb_gamma_table);
710 case VIAFB_GET_GAMMA_SUPPORT_STATE:
711 viafb_get_gamma_support_state(viafb_bpp, &state_info);
712 if (put_user(state_info, argp))
715 case VIAFB_SYNC_SURFACE:
716 DEBUG_MSG(KERN_INFO "lobo VIAFB_SYNC_SURFACE\n");
718 case VIAFB_GET_DRIVER_CAPS:
721 case VIAFB_GET_PANEL_MAX_SIZE:
722 if (copy_from_user(&u.panel_pos_size_para, argp,
723 sizeof(u.panel_pos_size_para)))
725 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
726 if (copy_to_user(argp, &u.panel_pos_size_para,
727 sizeof(u.panel_pos_size_para)))
730 case VIAFB_GET_PANEL_MAX_POSITION:
731 if (copy_from_user(&u.panel_pos_size_para, argp,
732 sizeof(u.panel_pos_size_para)))
734 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)))
740 case VIAFB_GET_PANEL_POSITION:
741 if (copy_from_user(&u.panel_pos_size_para, argp,
742 sizeof(u.panel_pos_size_para)))
744 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
745 if (copy_to_user(argp, &u.panel_pos_size_para,
746 sizeof(u.panel_pos_size_para)))
749 case VIAFB_GET_PANEL_SIZE:
750 if (copy_from_user(&u.panel_pos_size_para, argp,
751 sizeof(u.panel_pos_size_para)))
753 u.panel_pos_size_para.x = u.panel_pos_size_para.y = 0;
754 if (copy_to_user(argp, &u.panel_pos_size_para,
755 sizeof(u.panel_pos_size_para)))
759 case VIAFB_SET_PANEL_POSITION:
760 if (copy_from_user(&u.panel_pos_size_para, argp,
761 sizeof(u.panel_pos_size_para)))
764 case VIAFB_SET_PANEL_SIZE:
765 if (copy_from_user(&u.panel_pos_size_para, argp,
766 sizeof(u.panel_pos_size_para)))
777 static void viafb_fillrect(struct fb_info *info,
778 const struct fb_fillrect *rect)
780 u32 col = 0, rop = 0;
784 cfb_fillrect(info, rect);
788 if (!rect->width || !rect->height)
801 switch (info->var.bits_per_pixel) {
806 col = ((u32 *) (info->pseudo_palette))[rect->color];
809 col = ((u32 *) (info->pseudo_palette))[rect->color];
813 /* BitBlt Source Address */
814 writel(0x0, viaparinfo->io_virt + VIA_REG_SRCPOS);
815 /* Source Base Address */
816 writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE);
817 /* Destination Base Address */
818 writel((info->fix.smem_start - viafbinfo->fix.smem_start) >> 3,
819 viaparinfo->io_virt + VIA_REG_DSTBASE);
821 pitch = (info->var.xres_virtual + 7) & ~7;
822 writel(VIA_PITCH_ENABLE |
824 info->var.bits_per_pixel >> 3) >> 3) |
826 var.bits_per_pixel >> 3) >> 3) << 16)),
827 viaparinfo->io_virt + VIA_REG_PITCH);
828 /* BitBlt Destination Address */
829 writel(((rect->dy << 16) | rect->dx),
830 viaparinfo->io_virt + VIA_REG_DSTPOS);
831 /* Dimension: width & height */
832 writel((((rect->height - 1) << 16) | (rect->width - 1)),
833 viaparinfo->io_virt + VIA_REG_DIMENSION);
834 /* Forground color or Destination color */
835 writel(col, viaparinfo->io_virt + VIA_REG_FGCOLOR);
837 writel((0x01 | 0x2000 | (rop << 24)),
838 viaparinfo->io_virt + VIA_REG_GECMD);
842 static void viafb_copyarea(struct fb_info *info,
843 const struct fb_copyarea *area)
845 u32 dy = area->dy, sy = area->sy, direction = 0x0;
846 u32 sx = area->sx, dx = area->dx, width = area->width;
849 DEBUG_MSG(KERN_INFO "viafb_copyarea!!\n");
852 cfb_copyarea(info, area);
856 if (!area->width || !area->height)
860 dy += area->height - 1;
861 sy += area->height - 1;
871 /* Source Base Address */
872 writel((info->fix.smem_start - viafbinfo->fix.smem_start) >> 3,
873 viaparinfo->io_virt + VIA_REG_SRCBASE);
874 /* Destination Base Address */
875 writel((info->fix.smem_start - viafbinfo->fix.smem_start) >> 3,
876 viaparinfo->io_virt + VIA_REG_DSTBASE);
878 pitch = (info->var.xres_virtual + 7) & ~7;
879 /* VIA_PITCH_ENABLE can be omitted now. */
880 writel(VIA_PITCH_ENABLE |
882 info->var.bits_per_pixel >> 3) >> 3) | (((pitch *
887 viaparinfo->io_virt + VIA_REG_PITCH);
888 /* BitBlt Source Address */
889 writel(((sy << 16) | sx), viaparinfo->io_virt + VIA_REG_SRCPOS);
890 /* BitBlt Destination Address */
891 writel(((dy << 16) | dx), viaparinfo->io_virt + VIA_REG_DSTPOS);
892 /* Dimension: width & height */
893 writel((((area->height - 1) << 16) | (area->width - 1)),
894 viaparinfo->io_virt + VIA_REG_DIMENSION);
896 writel((0x01 | direction | (0xCC << 24)),
897 viaparinfo->io_virt + VIA_REG_GECMD);
901 static void viafb_imageblit(struct fb_info *info,
902 const struct fb_image *image)
904 u32 size, bg_col = 0, fg_col = 0, *udata;
909 cfb_imageblit(info, image);
913 udata = (u32 *) image->data;
915 switch (info->var.bits_per_pixel) {
917 bg_col = image->bg_color;
918 fg_col = image->fg_color;
921 bg_col = ((u32 *) (info->pseudo_palette))[image->bg_color];
922 fg_col = ((u32 *) (info->pseudo_palette))[image->fg_color];
925 bg_col = ((u32 *) (info->pseudo_palette))[image->bg_color];
926 fg_col = ((u32 *) (info->pseudo_palette))[image->fg_color];
929 size = image->width * image->height;
931 /* Source Base Address */
932 writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE);
933 /* Destination Base Address */
934 writel((info->fix.smem_start - viafbinfo->fix.smem_start) >> 3,
935 viaparinfo->io_virt + VIA_REG_DSTBASE);
937 pitch = (info->var.xres_virtual + 7) & ~7;
938 writel(VIA_PITCH_ENABLE |
940 info->var.bits_per_pixel >> 3) >> 3) | (((pitch *
945 viaparinfo->io_virt + VIA_REG_PITCH);
946 /* BitBlt Source Address */
947 writel(0x0, viaparinfo->io_virt + VIA_REG_SRCPOS);
948 /* BitBlt Destination Address */
949 writel(((image->dy << 16) | image->dx),
950 viaparinfo->io_virt + VIA_REG_DSTPOS);
951 /* Dimension: width & height */
952 writel((((image->height - 1) << 16) | (image->width - 1)),
953 viaparinfo->io_virt + VIA_REG_DIMENSION);
955 writel(fg_col, viaparinfo->io_virt + VIA_REG_FGCOLOR);
957 writel(bg_col, viaparinfo->io_virt + VIA_REG_BGCOLOR);
959 writel(0xCC020142, viaparinfo->io_virt + VIA_REG_GECMD);
961 for (i = 0; i < size / 4; i++) {
962 writel(*udata, viaparinfo->io_virt + VIA_MMIO_BLTBASE);
968 static int viafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
970 u32 temp, xx, yy, bg_col = 0, fg_col = 0;
972 static int hw_cursor;
973 struct viafb_par *p_viafb_par;
980 viafb_show_hw_cursor(info, HW_Cursor_OFF);
986 if ((((struct viafb_par *)(info->par))->iga_path == IGA2)
987 && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266))
990 /* When duoview and using lcd , use soft cursor */
991 if (viafb_LCD_ON || (!viafb_SAMM_ON &&
992 viafb_LCD2_ON + viafb_DVI_ON + viafb_CRT_ON == 2))
995 viafb_show_hw_cursor(info, HW_Cursor_OFF);
998 if (cursor->set & FB_CUR_SETHOT) {
999 viacursor.hot = cursor->hot;
1000 temp = ((viacursor.hot.x) << 16) + viacursor.hot.y;
1001 writel(temp, viaparinfo->io_virt + VIA_REG_CURSOR_ORG);
1004 if (cursor->set & FB_CUR_SETPOS) {
1005 viacursor.image.dx = cursor->image.dx;
1006 viacursor.image.dy = cursor->image.dy;
1007 yy = cursor->image.dy - info->var.yoffset;
1008 xx = cursor->image.dx - info->var.xoffset;
1011 writel(temp, viaparinfo->io_virt + VIA_REG_CURSOR_POS);
1014 if (cursor->set & FB_CUR_SETSIZE) {
1015 temp = readl(viaparinfo->io_virt + VIA_REG_CURSOR_MODE);
1017 if ((cursor->image.width <= 32)
1018 && (cursor->image.height <= 32)) {
1021 } else if ((cursor->image.width <= 64)
1022 && (cursor->image.height <= 64)) {
1027 "The cursor image is biger than 64x64 bits...\n");
1030 writel(temp, viaparinfo->io_virt + VIA_REG_CURSOR_MODE);
1032 viacursor.image.height = cursor->image.height;
1033 viacursor.image.width = cursor->image.width;
1036 if (cursor->set & FB_CUR_SETCMAP) {
1037 viacursor.image.fg_color = cursor->image.fg_color;
1038 viacursor.image.bg_color = cursor->image.bg_color;
1040 switch (info->var.bits_per_pixel) {
1046 (((info->cmap.red)[viacursor.image.bg_color] &
1048 ((info->cmap.green)[viacursor.image.bg_color] &
1050 (((info->cmap.blue)[viacursor.image.bg_color] &
1054 (((info->cmap.red)[viacursor.image.fg_color] &
1056 ((info->cmap.green)[viacursor.image.fg_color] &
1058 (((info->cmap.blue)[viacursor.image.fg_color] &
1065 /* This is indeed a patch for VT3324/VT3353 */
1068 p_viafb_par = (struct viafb_par *)info->par;
1070 if ((p_viafb_par->chip_info->gfx_chip_name ==
1072 ((p_viafb_par->chip_info->gfx_chip_name ==
1073 UNICHROME_VX800))) {
1075 (((info->cmap.red)[viacursor.image.bg_color] &
1077 (((info->cmap.green)[viacursor.image.bg_color] &
1079 (((info->cmap.blue)[viacursor.image.bg_color] &
1082 (((info->cmap.red)[viacursor.image.fg_color] &
1084 (((info->cmap.green)[viacursor.image.fg_color] &
1086 (((info->cmap.blue)[viacursor.image.fg_color] &
1090 writel(bg_col, viaparinfo->io_virt + VIA_REG_CURSOR_BG);
1091 writel(fg_col, viaparinfo->io_virt + VIA_REG_CURSOR_FG);
1094 if (cursor->set & FB_CUR_SETSHAPE) {
1096 u8 data[CURSOR_SIZE / 8];
1097 u32 bak[CURSOR_SIZE / 32];
1098 } *cr_data = kzalloc(sizeof(*cr_data), GFP_ATOMIC);
1100 ((viacursor.image.width + 7) >> 3) *
1101 viacursor.image.height;
1103 if (cr_data == NULL)
1106 if (MAX_CURS == 32) {
1107 for (i = 0; i < (CURSOR_SIZE / 32); i++) {
1108 cr_data->bak[i] = 0x0;
1109 cr_data->bak[i + 1] = 0xFFFFFFFF;
1112 } else if (MAX_CURS == 64) {
1113 for (i = 0; i < (CURSOR_SIZE / 32); i++) {
1114 cr_data->bak[i] = 0x0;
1115 cr_data->bak[i + 1] = 0x0;
1116 cr_data->bak[i + 2] = 0xFFFFFFFF;
1117 cr_data->bak[i + 3] = 0xFFFFFFFF;
1122 switch (viacursor.rop) {
1124 for (i = 0; i < size; i++)
1125 cr_data->data[i] = viacursor.mask[i];
1129 for (i = 0; i < size; i++)
1130 cr_data->data[i] = viacursor.mask[i];
1136 if (MAX_CURS == 32) {
1137 for (i = 0; i < size; i++) {
1138 cr_data->bak[j] = (u32) cr_data->data[i];
1139 cr_data->bak[j + 1] = ~cr_data->bak[j];
1142 } else if (MAX_CURS == 64) {
1143 for (i = 0; i < size; i++) {
1144 cr_data->bak[j] = (u32) cr_data->data[i];
1145 cr_data->bak[j + 1] = 0x0;
1146 cr_data->bak[j + 2] = ~cr_data->bak[j];
1147 cr_data->bak[j + 3] = ~cr_data->bak[j + 1];
1152 memcpy(viafbinfo->screen_base +
1153 ((struct viafb_par *)(info->par))->cursor_start,
1154 cr_data->bak, CURSOR_SIZE);
1159 if (viacursor.enable)
1160 viafb_show_hw_cursor(info, HW_Cursor_ON);
1165 static int viafb_sync(struct fb_info *info)
1168 viafb_wait_engine_idle();
1172 int viafb_get_mode_index(int hres, int vres)
1175 DEBUG_MSG(KERN_INFO "viafb_get_mode_index!\n");
1177 for (i = 0; i < NUM_TOTAL_MODETABLE; i++)
1178 if (CLE266Modes[i].mode_array &&
1179 CLE266Modes[i].crtc[0].crtc.hor_addr == hres &&
1180 CLE266Modes[i].crtc[0].crtc.ver_addr == vres)
1183 if (i == NUM_TOTAL_MODETABLE)
1184 return VIA_RES_INVALID;
1186 return CLE266Modes[i].ModeIndex;
1189 static void check_available_device_to_enable(int device_id)
1194 viafb_CRT_ON = STATE_OFF;
1195 viafb_DVI_ON = STATE_OFF;
1196 viafb_LCD_ON = STATE_OFF;
1197 viafb_LCD2_ON = STATE_OFF;
1198 viafb_DeviceStatus = None_Device;
1200 if ((device_id & CRT_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1201 viafb_CRT_ON = STATE_ON;
1203 viafb_DeviceStatus |= CRT_Device;
1206 if ((device_id & DVI_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1207 viafb_DVI_ON = STATE_ON;
1209 viafb_DeviceStatus |= DVI_Device;
1212 if ((device_id & LCD_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1213 viafb_LCD_ON = STATE_ON;
1215 viafb_DeviceStatus |= LCD_Device;
1218 if ((device_id & LCD2_Device) && (device_num < MAX_ACTIVE_DEV_NUM)) {
1219 viafb_LCD2_ON = STATE_ON;
1221 viafb_DeviceStatus |= LCD2_Device;
1224 if (viafb_DeviceStatus == None_Device) {
1225 /* Use CRT as default active device: */
1226 viafb_CRT_ON = STATE_ON;
1227 viafb_DeviceStatus = CRT_Device;
1229 DEBUG_MSG(KERN_INFO "Device Status:%x", viafb_DeviceStatus);
1232 static void viafb_set_device(struct device_t active_dev)
1234 /* Check available device to enable: */
1235 int device_id = None_Device;
1237 device_id |= CRT_Device;
1239 device_id |= DVI_Device;
1241 device_id |= LCD_Device;
1243 check_available_device_to_enable(device_id);
1245 /* Check property of LCD: */
1247 if (active_dev.lcd_dsp_cent) {
1248 viaparinfo->lvds_setting_info->display_method =
1249 viafb_lcd_dsp_method = LCD_CENTERING;
1251 viaparinfo->lvds_setting_info->display_method =
1252 viafb_lcd_dsp_method = LCD_EXPANDSION;
1255 if (active_dev.lcd_mode == LCD_SPWG) {
1256 viaparinfo->lvds_setting_info->lcd_mode =
1257 viafb_lcd_mode = LCD_SPWG;
1259 viaparinfo->lvds_setting_info->lcd_mode =
1260 viafb_lcd_mode = LCD_OPENLDI;
1263 if (active_dev.lcd_panel_id <= LCD_PANEL_ID_MAXIMUM) {
1264 viafb_lcd_panel_id = active_dev.lcd_panel_id;
1265 viafb_init_lcd_size();
1269 /* Check property of mode: */
1270 if (!active_dev.xres1)
1271 viafb_second_xres = 640;
1273 viafb_second_xres = active_dev.xres1;
1274 if (!active_dev.yres1)
1275 viafb_second_yres = 480;
1277 viafb_second_yres = active_dev.yres1;
1278 if (active_dev.bpp != 0)
1279 viafb_bpp = active_dev.bpp;
1280 if (active_dev.bpp1 != 0)
1281 viafb_bpp1 = active_dev.bpp1;
1282 if (active_dev.refresh != 0)
1283 viafb_refresh = active_dev.refresh;
1284 if (active_dev.refresh1 != 0)
1285 viafb_refresh1 = active_dev.refresh1;
1286 if ((active_dev.samm == STATE_OFF) || (active_dev.samm == STATE_ON))
1287 viafb_SAMM_ON = active_dev.samm;
1288 viafb_primary_dev = active_dev.primary_dev;
1290 viafb_set_primary_address(0);
1291 viafb_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0);
1292 viafb_set_iga_path();
1295 static int get_primary_device(void)
1297 int primary_device = 0;
1298 /* Rule: device on iga1 path are the primary device. */
1299 if (viafb_SAMM_ON) {
1301 if (viaparinfo->crt_setting_info->iga_path == IGA1) {
1302 DEBUG_MSG(KERN_INFO "CRT IGA Path:%d\n",
1304 crt_setting_info->iga_path);
1305 primary_device = CRT_Device;
1309 if (viaparinfo->tmds_setting_info->iga_path == IGA1) {
1310 DEBUG_MSG(KERN_INFO "DVI IGA Path:%d\n",
1312 tmds_setting_info->iga_path);
1313 primary_device = DVI_Device;
1317 if (viaparinfo->lvds_setting_info->iga_path == IGA1) {
1318 DEBUG_MSG(KERN_INFO "LCD IGA Path:%d\n",
1320 lvds_setting_info->iga_path);
1321 primary_device = LCD_Device;
1324 if (viafb_LCD2_ON) {
1325 if (viaparinfo->lvds_setting_info2->iga_path == IGA1) {
1326 DEBUG_MSG(KERN_INFO "LCD2 IGA Path:%d\n",
1328 lvds_setting_info2->iga_path);
1329 primary_device = LCD2_Device;
1333 return primary_device;
1336 static void apply_second_mode_setting(struct fb_var_screeninfo
1339 u32 htotal, vtotal, long_refresh;
1341 htotal = sec_var->xres + sec_var->left_margin +
1342 sec_var->right_margin + sec_var->hsync_len;
1343 vtotal = sec_var->yres + sec_var->upper_margin +
1344 sec_var->lower_margin + sec_var->vsync_len;
1345 if ((sec_var->xres_virtual * (sec_var->bits_per_pixel >> 3)) & 0x1F) {
1346 /*Is 32 bytes alignment? */
1347 /*32 pixel alignment */
1348 sec_var->xres_virtual = (sec_var->xres_virtual + 31) & ~31;
1351 htotal = sec_var->xres + sec_var->left_margin +
1352 sec_var->right_margin + sec_var->hsync_len;
1353 vtotal = sec_var->yres + sec_var->upper_margin +
1354 sec_var->lower_margin + sec_var->vsync_len;
1355 long_refresh = 1000000000UL / sec_var->pixclock * 1000;
1356 long_refresh /= (htotal * vtotal);
1358 viafb_second_xres = sec_var->xres;
1359 viafb_second_yres = sec_var->yres;
1360 viafb_second_virtual_xres = sec_var->xres_virtual;
1361 viafb_second_virtual_yres = sec_var->yres_virtual;
1362 viafb_bpp1 = sec_var->bits_per_pixel;
1363 viafb_refresh1 = viafb_get_refresh(sec_var->xres, sec_var->yres,
1367 static int apply_device_setting(struct viafb_ioctl_setting setting_info,
1368 struct fb_info *info)
1370 int need_set_mode = 0;
1371 DEBUG_MSG(KERN_INFO "apply_device_setting\n");
1373 if (setting_info.device_flag) {
1375 check_available_device_to_enable(setting_info.device_status);
1378 /* Unlock LCD's operation according to LCD flag
1379 and check if the setting value is valid. */
1380 /* If the value is valid, apply the new setting value to the device. */
1382 if (setting_info.lcd_operation_flag & OP_LCD_CENTERING) {
1384 if (setting_info.lcd_attributes.display_center) {
1386 viaparinfo->lvds_setting_info->display_method =
1388 viafb_lcd_dsp_method = LCD_CENTERING;
1389 viaparinfo->lvds_setting_info2->display_method =
1390 viafb_lcd_dsp_method = LCD_CENTERING;
1393 viaparinfo->lvds_setting_info->display_method =
1395 viafb_lcd_dsp_method = LCD_EXPANDSION;
1396 viaparinfo->lvds_setting_info2->display_method =
1398 viafb_lcd_dsp_method = LCD_EXPANDSION;
1402 if (setting_info.lcd_operation_flag & OP_LCD_MODE) {
1404 if (setting_info.lcd_attributes.lcd_mode ==
1406 viaparinfo->lvds_setting_info->lcd_mode =
1407 viafb_lcd_mode = LCD_SPWG;
1409 viaparinfo->lvds_setting_info->lcd_mode =
1410 viafb_lcd_mode = LCD_OPENLDI;
1412 viaparinfo->lvds_setting_info2->lcd_mode =
1413 viaparinfo->lvds_setting_info->lcd_mode;
1416 if (setting_info.lcd_operation_flag & OP_LCD_PANEL_ID) {
1418 if (setting_info.lcd_attributes.panel_id <=
1419 LCD_PANEL_ID_MAXIMUM) {
1420 viafb_lcd_panel_id =
1421 setting_info.lcd_attributes.panel_id;
1422 viafb_init_lcd_size();
1427 if (0 != (setting_info.samm_status & OP_SAMM)) {
1428 setting_info.samm_status =
1429 setting_info.samm_status & (~OP_SAMM);
1430 if (setting_info.samm_status == 0
1431 || setting_info.samm_status == 1) {
1432 viafb_SAMM_ON = setting_info.samm_status;
1435 viafb_primary_dev = setting_info.primary_device;
1437 viafb_set_primary_address(0);
1438 viafb_set_secondary_address(viafb_SAMM_ON ? viafb_second_offset : 0);
1439 viafb_set_iga_path();
1444 if (!need_set_mode) {
1447 viafb_set_iga_path();
1448 viafb_set_par(info);
1453 static void retrieve_device_setting(struct viafb_ioctl_setting
1457 /* get device status */
1458 if (viafb_CRT_ON == 1)
1459 setting_info->device_status = CRT_Device;
1460 if (viafb_DVI_ON == 1)
1461 setting_info->device_status |= DVI_Device;
1462 if (viafb_LCD_ON == 1)
1463 setting_info->device_status |= LCD_Device;
1464 if (viafb_LCD2_ON == 1)
1465 setting_info->device_status |= LCD2_Device;
1467 setting_info->samm_status = viafb_SAMM_ON;
1468 setting_info->primary_device = get_primary_device();
1470 setting_info->first_dev_bpp = viafb_bpp;
1471 setting_info->second_dev_bpp = viafb_bpp1;
1473 setting_info->first_dev_refresh = viafb_refresh;
1474 setting_info->second_dev_refresh = viafb_refresh1;
1476 setting_info->first_dev_hor_res = viafb_hotplug_Xres;
1477 setting_info->first_dev_ver_res = viafb_hotplug_Yres;
1478 setting_info->second_dev_hor_res = viafb_second_xres;
1479 setting_info->second_dev_ver_res = viafb_second_yres;
1481 /* Get lcd attributes */
1482 setting_info->lcd_attributes.display_center = viafb_lcd_dsp_method;
1483 setting_info->lcd_attributes.panel_id = viafb_lcd_panel_id;
1484 setting_info->lcd_attributes.lcd_mode = viafb_lcd_mode;
1487 static void parse_active_dev(void)
1489 viafb_CRT_ON = STATE_OFF;
1490 viafb_DVI_ON = STATE_OFF;
1491 viafb_LCD_ON = STATE_OFF;
1492 viafb_LCD2_ON = STATE_OFF;
1493 /* 1. Modify the active status of devices. */
1494 /* 2. Keep the order of devices, so we can set corresponding
1495 IGA path to devices in SAMM case. */
1496 /* Note: The previous of active_dev is primary device,
1497 and the following is secondary device. */
1498 if (!strncmp(viafb_active_dev, "CRT+DVI", 7)) {
1500 viafb_CRT_ON = STATE_ON;
1501 viafb_DVI_ON = STATE_ON;
1502 viafb_primary_dev = CRT_Device;
1503 } else if (!strncmp(viafb_active_dev, "DVI+CRT", 7)) {
1505 viafb_CRT_ON = STATE_ON;
1506 viafb_DVI_ON = STATE_ON;
1507 viafb_primary_dev = DVI_Device;
1508 } else if (!strncmp(viafb_active_dev, "CRT+LCD", 7)) {
1510 viafb_CRT_ON = STATE_ON;
1511 viafb_LCD_ON = STATE_ON;
1512 viafb_primary_dev = CRT_Device;
1513 } else if (!strncmp(viafb_active_dev, "LCD+CRT", 7)) {
1515 viafb_CRT_ON = STATE_ON;
1516 viafb_LCD_ON = STATE_ON;
1517 viafb_primary_dev = LCD_Device;
1518 } else if (!strncmp(viafb_active_dev, "DVI+LCD", 7)) {
1520 viafb_DVI_ON = STATE_ON;
1521 viafb_LCD_ON = STATE_ON;
1522 viafb_primary_dev = DVI_Device;
1523 } else if (!strncmp(viafb_active_dev, "LCD+DVI", 7)) {
1525 viafb_DVI_ON = STATE_ON;
1526 viafb_LCD_ON = STATE_ON;
1527 viafb_primary_dev = LCD_Device;
1528 } else if (!strncmp(viafb_active_dev, "LCD+LCD2", 8)) {
1529 viafb_LCD_ON = STATE_ON;
1530 viafb_LCD2_ON = STATE_ON;
1531 viafb_primary_dev = LCD_Device;
1532 } else if (!strncmp(viafb_active_dev, "LCD2+LCD", 8)) {
1533 viafb_LCD_ON = STATE_ON;
1534 viafb_LCD2_ON = STATE_ON;
1535 viafb_primary_dev = LCD2_Device;
1536 } else if (!strncmp(viafb_active_dev, "CRT", 3)) {
1538 viafb_CRT_ON = STATE_ON;
1539 viafb_SAMM_ON = STATE_OFF;
1540 } else if (!strncmp(viafb_active_dev, "DVI", 3)) {
1542 viafb_DVI_ON = STATE_ON;
1543 viafb_SAMM_ON = STATE_OFF;
1544 } else if (!strncmp(viafb_active_dev, "LCD", 3)) {
1546 viafb_LCD_ON = STATE_ON;
1547 viafb_SAMM_ON = STATE_OFF;
1549 viafb_CRT_ON = STATE_ON;
1550 viafb_SAMM_ON = STATE_OFF;
1554 static int parse_port(char *opt_str, int *output_interface)
1556 if (!strncmp(opt_str, "DVP0", 4))
1557 *output_interface = INTERFACE_DVP0;
1558 else if (!strncmp(opt_str, "DVP1", 4))
1559 *output_interface = INTERFACE_DVP1;
1560 else if (!strncmp(opt_str, "DFP_HIGHLOW", 11))
1561 *output_interface = INTERFACE_DFP;
1562 else if (!strncmp(opt_str, "DFP_HIGH", 8))
1563 *output_interface = INTERFACE_DFP_HIGH;
1564 else if (!strncmp(opt_str, "DFP_LOW", 7))
1565 *output_interface = INTERFACE_DFP_LOW;
1567 *output_interface = INTERFACE_NONE;
1571 static void parse_lcd_port(void)
1573 parse_port(viafb_lcd_port, &viaparinfo->chip_info->lvds_chip_info.
1575 /*Initialize to avoid unexpected behavior */
1576 viaparinfo->chip_info->lvds_chip_info2.output_interface =
1579 DEBUG_MSG(KERN_INFO "parse_lcd_port: viafb_lcd_port:%s,interface:%d\n",
1580 viafb_lcd_port, viaparinfo->chip_info->lvds_chip_info.
1584 static void parse_dvi_port(void)
1586 parse_port(viafb_dvi_port, &viaparinfo->chip_info->tmds_chip_info.
1589 DEBUG_MSG(KERN_INFO "parse_dvi_port: viafb_dvi_port:%s,interface:%d\n",
1590 viafb_dvi_port, viaparinfo->chip_info->tmds_chip_info.
1595 * The proc filesystem read/write function, a simple proc implement to
1596 * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
1597 * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2],
1598 * CR9B, SR65, CR97, CR99
1600 static int viafb_dvp0_proc_read(char *buf, char **start, off_t offset,
1601 int count, int *eof, void *data)
1604 u8 dvp0_data_dri = 0, dvp0_clk_dri = 0, dvp0 = 0;
1606 (viafb_read_reg(VIASR, SR2A) & BIT5) >> 4 |
1607 (viafb_read_reg(VIASR, SR1B) & BIT1) >> 1;
1609 (viafb_read_reg(VIASR, SR2A) & BIT4) >> 3 |
1610 (viafb_read_reg(VIASR, SR1E) & BIT2) >> 2;
1611 dvp0 = viafb_read_reg(VIACR, CR96) & 0x0f;
1613 sprintf(buf + len, "%x %x %x\n", dvp0, dvp0_data_dri, dvp0_clk_dri);
1614 *eof = 1; /*Inform kernel end of data */
1617 static int viafb_dvp0_proc_write(struct file *file,
1618 const char __user *buffer, unsigned long count, void *data)
1620 char buf[20], *value, *pbuf;
1622 unsigned long length, i;
1625 length = count > 20 ? 20 : count;
1626 if (copy_from_user(&buf[0], buffer, length))
1628 buf[length - 1] = '\0'; /*Ensure end string */
1630 for (i = 0; i < 3; i++) {
1631 value = strsep(&pbuf, " ");
1632 if (value != NULL) {
1633 strict_strtoul(value, 0, (unsigned long *)®_val);
1634 DEBUG_MSG(KERN_INFO "DVP0:reg_val[%l]=:%x\n", i,
1638 viafb_write_reg_mask(CR96, VIACR,
1642 viafb_write_reg_mask(SR2A, VIASR,
1643 reg_val << 4, BIT5);
1644 viafb_write_reg_mask(SR1B, VIASR,
1645 reg_val << 1, BIT1);
1648 viafb_write_reg_mask(SR2A, VIASR,
1649 reg_val << 3, BIT4);
1650 viafb_write_reg_mask(SR1E, VIASR,
1651 reg_val << 2, BIT2);
1662 static int viafb_dvp1_proc_read(char *buf, char **start, off_t offset,
1663 int count, int *eof, void *data)
1666 u8 dvp1 = 0, dvp1_data_dri = 0, dvp1_clk_dri = 0;
1667 dvp1 = viafb_read_reg(VIACR, CR9B) & 0x0f;
1668 dvp1_data_dri = (viafb_read_reg(VIASR, SR65) & 0x0c) >> 2;
1669 dvp1_clk_dri = viafb_read_reg(VIASR, SR65) & 0x03;
1671 sprintf(buf + len, "%x %x %x\n", dvp1, dvp1_data_dri, dvp1_clk_dri);
1672 *eof = 1; /*Inform kernel end of data */
1675 static int viafb_dvp1_proc_write(struct file *file,
1676 const char __user *buffer, unsigned long count, void *data)
1678 char buf[20], *value, *pbuf;
1680 unsigned long length, i;
1683 length = count > 20 ? 20 : count;
1684 if (copy_from_user(&buf[0], buffer, length))
1686 buf[length - 1] = '\0'; /*Ensure end string */
1688 for (i = 0; i < 3; i++) {
1689 value = strsep(&pbuf, " ");
1690 if (value != NULL) {
1691 strict_strtoul(value, 0, (unsigned long *)®_val);
1694 viafb_write_reg_mask(CR9B, VIACR,
1698 viafb_write_reg_mask(SR65, VIASR,
1699 reg_val << 2, 0x0c);
1702 viafb_write_reg_mask(SR65, VIASR,
1715 static int viafb_dfph_proc_read(char *buf, char **start, off_t offset,
1716 int count, int *eof, void *data)
1720 dfp_high = viafb_read_reg(VIACR, CR97) & 0x0f;
1721 len += sprintf(buf + len, "%x\n", dfp_high);
1722 *eof = 1; /*Inform kernel end of data */
1725 static int viafb_dfph_proc_write(struct file *file,
1726 const char __user *buffer, unsigned long count, void *data)
1730 unsigned long length;
1733 length = count > 20 ? 20 : count;
1734 if (copy_from_user(&buf[0], buffer, length))
1736 buf[length - 1] = '\0'; /*Ensure end string */
1737 strict_strtoul(&buf[0], 0, (unsigned long *)®_val);
1738 viafb_write_reg_mask(CR97, VIACR, reg_val, 0x0f);
1741 static int viafb_dfpl_proc_read(char *buf, char **start, off_t offset,
1742 int count, int *eof, void *data)
1746 dfp_low = viafb_read_reg(VIACR, CR99) & 0x0f;
1747 len += sprintf(buf + len, "%x\n", dfp_low);
1748 *eof = 1; /*Inform kernel end of data */
1751 static int viafb_dfpl_proc_write(struct file *file,
1752 const char __user *buffer, unsigned long count, void *data)
1756 unsigned long length;
1759 length = count > 20 ? 20 : count;
1760 if (copy_from_user(&buf[0], buffer, length))
1762 buf[length - 1] = '\0'; /*Ensure end string */
1763 strict_strtoul(&buf[0], 0, (unsigned long *)®_val);
1764 viafb_write_reg_mask(CR99, VIACR, reg_val, 0x0f);
1767 static int viafb_vt1636_proc_read(char *buf, char **start,
1768 off_t offset, int count, int *eof, void *data)
1771 u8 vt1636_08 = 0, vt1636_09 = 0;
1772 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1775 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
1776 &viaparinfo->chip_info->lvds_chip_info, 0x08) & 0x0f;
1778 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info,
1779 &viaparinfo->chip_info->lvds_chip_info, 0x09) & 0x1f;
1780 len += sprintf(buf + len, "%x %x\n", vt1636_08, vt1636_09);
1785 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
1788 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
1789 &viaparinfo->chip_info->lvds_chip_info2, 0x08) & 0x0f;
1791 viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2,
1792 &viaparinfo->chip_info->lvds_chip_info2, 0x09) & 0x1f;
1793 len += sprintf(buf + len, " %x %x\n", vt1636_08, vt1636_09);
1798 *eof = 1; /*Inform kernel end of data */
1801 static int viafb_vt1636_proc_write(struct file *file,
1802 const char __user *buffer, unsigned long count, void *data)
1804 char buf[30], *value, *pbuf;
1805 struct IODATA reg_val;
1806 unsigned long length, i;
1809 length = count > 30 ? 30 : count;
1810 if (copy_from_user(&buf[0], buffer, length))
1812 buf[length - 1] = '\0'; /*Ensure end string */
1814 switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) {
1816 for (i = 0; i < 2; i++) {
1817 value = strsep(&pbuf, " ");
1818 if (value != NULL) {
1819 strict_strtoul(value, 0,
1820 (unsigned long *)®_val.Data);
1823 reg_val.Index = 0x08;
1824 reg_val.Mask = 0x0f;
1825 viafb_gpio_i2c_write_mask_lvds
1826 (viaparinfo->lvds_setting_info,
1828 chip_info->lvds_chip_info,
1832 reg_val.Index = 0x09;
1833 reg_val.Mask = 0x1f;
1834 viafb_gpio_i2c_write_mask_lvds
1835 (viaparinfo->lvds_setting_info,
1837 chip_info->lvds_chip_info,
1851 switch (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
1853 for (i = 0; i < 2; i++) {
1854 value = strsep(&pbuf, " ");
1855 if (value != NULL) {
1856 strict_strtoul(value, 0,
1857 (unsigned long *)®_val.Data);
1860 reg_val.Index = 0x08;
1861 reg_val.Mask = 0x0f;
1862 viafb_gpio_i2c_write_mask_lvds
1863 (viaparinfo->lvds_setting_info2,
1865 chip_info->lvds_chip_info2,
1869 reg_val.Index = 0x09;
1870 reg_val.Mask = 0x1f;
1871 viafb_gpio_i2c_write_mask_lvds
1872 (viaparinfo->lvds_setting_info2,
1874 chip_info->lvds_chip_info2,
1891 static void viafb_init_proc(struct proc_dir_entry **viafb_entry)
1893 struct proc_dir_entry *entry;
1894 *viafb_entry = proc_mkdir("viafb", NULL);
1896 entry = create_proc_entry("dvp0", 0, *viafb_entry);
1898 entry->read_proc = viafb_dvp0_proc_read;
1899 entry->write_proc = viafb_dvp0_proc_write;
1901 entry = create_proc_entry("dvp1", 0, *viafb_entry);
1903 entry->read_proc = viafb_dvp1_proc_read;
1904 entry->write_proc = viafb_dvp1_proc_write;
1906 entry = create_proc_entry("dfph", 0, *viafb_entry);
1908 entry->read_proc = viafb_dfph_proc_read;
1909 entry->write_proc = viafb_dfph_proc_write;
1911 entry = create_proc_entry("dfpl", 0, *viafb_entry);
1913 entry->read_proc = viafb_dfpl_proc_read;
1914 entry->write_proc = viafb_dfpl_proc_write;
1916 if (VT1636_LVDS == viaparinfo->chip_info->lvds_chip_info.
1917 lvds_chip_name || VT1636_LVDS ==
1918 viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) {
1919 entry = create_proc_entry("vt1636", 0, *viafb_entry);
1921 entry->read_proc = viafb_vt1636_proc_read;
1922 entry->write_proc = viafb_vt1636_proc_write;
1928 static void viafb_remove_proc(struct proc_dir_entry *viafb_entry)
1930 /* no problem if it was not registered */
1931 remove_proc_entry("dvp0", viafb_entry);/* parent dir */
1932 remove_proc_entry("dvp1", viafb_entry);
1933 remove_proc_entry("dfph", viafb_entry);
1934 remove_proc_entry("dfpl", viafb_entry);
1935 remove_proc_entry("vt1636", viafb_entry);
1936 remove_proc_entry("vt1625", viafb_entry);
1937 remove_proc_entry("viafb", NULL);
1940 static int __devinit via_pci_probe(void)
1942 unsigned long default_xres, default_yres;
1944 char *tmpc_sec, *tmpm_sec;
1946 u32 tmds_length, lvds_length, crt_length, chip_length, viafb_par_length;
1948 DEBUG_MSG(KERN_INFO "VIAFB PCI Probe!!\n");
1950 viafb_par_length = ALIGN(sizeof(struct viafb_par), BITS_PER_LONG/8);
1951 tmds_length = ALIGN(sizeof(struct tmds_setting_information),
1953 lvds_length = ALIGN(sizeof(struct lvds_setting_information),
1955 crt_length = ALIGN(sizeof(struct lvds_setting_information),
1957 chip_length = ALIGN(sizeof(struct chip_information), BITS_PER_LONG/8);
1959 /* Allocate fb_info and ***_par here, also including some other needed
1962 viafbinfo = framebuffer_alloc(viafb_par_length + 2 * lvds_length +
1963 tmds_length + crt_length + chip_length, NULL);
1965 printk(KERN_ERR"Could not allocate memory for viafb_info.\n");
1969 viaparinfo = (struct viafb_par *)viafbinfo->par;
1970 viaparinfo->tmds_setting_info = (struct tmds_setting_information *)
1971 ((unsigned long)viaparinfo + viafb_par_length);
1972 viaparinfo->lvds_setting_info = (struct lvds_setting_information *)
1973 ((unsigned long)viaparinfo->tmds_setting_info + tmds_length);
1974 viaparinfo->lvds_setting_info2 = (struct lvds_setting_information *)
1975 ((unsigned long)viaparinfo->lvds_setting_info + lvds_length);
1976 viaparinfo->crt_setting_info = (struct crt_setting_information *)
1977 ((unsigned long)viaparinfo->lvds_setting_info2 + lvds_length);
1978 viaparinfo->chip_info = (struct chip_information *)
1979 ((unsigned long)viaparinfo->crt_setting_info + crt_length);
1987 /* for dual-fb must viafb_SAMM_ON=1 and viafb_dual_fb=1 */
1991 /* Set up I2C bus stuff */
1992 viafb_create_i2c_bus(viaparinfo);
1994 viafb_init_chip_info();
1995 viafb_get_fb_info(&viaparinfo->fbmem, &viaparinfo->memsize);
1996 viaparinfo->fbmem_free = viaparinfo->memsize;
1997 viaparinfo->fbmem_used = 0;
1998 viafbinfo->screen_base = ioremap_nocache(viaparinfo->fbmem,
1999 viaparinfo->memsize);
2000 if (!viafbinfo->screen_base) {
2001 printk(KERN_INFO "ioremap failed\n");
2005 viafb_get_mmio_info(&viafbinfo->fix.mmio_start,
2006 &viafbinfo->fix.mmio_len);
2007 viaparinfo->io_virt = ioremap_nocache(viafbinfo->fix.mmio_start,
2008 viafbinfo->fix.mmio_len);
2009 if (!viaparinfo->io_virt) {
2010 printk(KERN_WARNING "ioremap failed: hardware acceleration disabled\n");
2014 viafbinfo->node = 0;
2015 viafbinfo->fbops = &viafb_ops;
2016 viafbinfo->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
2018 viafbinfo->pseudo_palette = pseudo_pal;
2021 viafb_init_2d_engine();
2022 viafb_hw_cursor_init();
2025 if (viafb_second_size && (viafb_second_size < 8)) {
2026 viafb_second_offset = viaparinfo->fbmem_free -
2027 viafb_second_size * 1024 * 1024;
2029 viafb_second_size = 8;
2030 viafb_second_offset = viaparinfo->fbmem_free -
2031 viafb_second_size * 1024 * 1024;
2035 tmpc = strsep(&tmpm, "x");
2036 strict_strtoul(tmpc, 0, &default_xres);
2037 strict_strtoul(tmpm, 0, &default_yres);
2039 vmode_index = viafb_get_mode_index(default_xres, default_yres);
2040 DEBUG_MSG(KERN_INFO "0->index=%d\n", vmode_index);
2042 if (viafb_SAMM_ON == 1) {
2043 if (strcmp(viafb_mode, viafb_mode1)) {
2044 tmpm_sec = viafb_mode1;
2045 tmpc_sec = strsep(&tmpm_sec, "x");
2046 strict_strtoul(tmpc_sec, 0,
2047 (unsigned long *)&viafb_second_xres);
2048 strict_strtoul(tmpm_sec, 0,
2049 (unsigned long *)&viafb_second_yres);
2051 viafb_second_xres = default_xres;
2052 viafb_second_yres = default_yres;
2054 if (0 == viafb_second_virtual_xres) {
2055 switch (viafb_second_xres) {
2057 viafb_second_virtual_xres = 1408;
2060 viafb_second_virtual_xres = viafb_second_xres;
2064 if (0 == viafb_second_virtual_yres)
2065 viafb_second_virtual_yres = viafb_second_yres;
2068 switch (viafb_bpp) {
2081 default_var.xres = default_xres;
2082 default_var.yres = default_yres;
2083 switch (default_xres) {
2085 default_var.xres_virtual = 1408;
2088 default_var.xres_virtual = default_xres;
2091 default_var.yres_virtual = default_yres;
2092 default_var.bits_per_pixel = viafb_bpp;
2093 if (default_var.bits_per_pixel == 15)
2094 default_var.bits_per_pixel = 16;
2095 default_var.pixclock =
2096 viafb_get_pixclock(default_xres, default_yres, viafb_refresh);
2097 default_var.left_margin = (default_xres >> 3) & 0xf8;
2098 default_var.right_margin = 32;
2099 default_var.upper_margin = 16;
2100 default_var.lower_margin = 4;
2101 default_var.hsync_len = default_var.left_margin;
2102 default_var.vsync_len = 4;
2103 default_var.accel_flags = 0;
2107 (FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT |
2108 FBINFO_HWACCEL_IMAGEBLIT);
2109 default_var.accel_flags |= FB_ACCELF_TEXT;
2111 viafbinfo->flags |= FBINFO_HWACCEL_DISABLED;
2113 if (viafb_dual_fb) {
2114 viafbinfo1 = framebuffer_alloc(viafb_par_length, NULL);
2117 "allocate the second framebuffer struct error\n");
2118 framebuffer_release(viafbinfo);
2121 viaparinfo1 = viafbinfo1->par;
2122 memcpy(viaparinfo1, viaparinfo, viafb_par_length);
2123 viaparinfo1->memsize = viaparinfo->memsize -
2124 viafb_second_offset;
2125 viaparinfo->memsize = viafb_second_offset;
2126 viaparinfo1->fbmem = viaparinfo->fbmem + viafb_second_offset;
2128 viaparinfo1->fbmem_used = viaparinfo->fbmem_used;
2129 viaparinfo1->fbmem_free = viaparinfo1->memsize -
2130 viaparinfo1->fbmem_used;
2131 viaparinfo->fbmem_free = viaparinfo->memsize;
2132 viaparinfo->fbmem_used = 0;
2134 viaparinfo1->cursor_start =
2135 viaparinfo->cursor_start - viafb_second_offset;
2136 viaparinfo1->VQ_start = viaparinfo->VQ_start -
2137 viafb_second_offset;
2138 viaparinfo1->VQ_end = viaparinfo->VQ_end -
2139 viafb_second_offset;
2142 viaparinfo->iga_path = IGA1;
2143 viaparinfo1->iga_path = IGA2;
2144 memcpy(viafbinfo1, viafbinfo, sizeof(struct fb_info));
2145 viafbinfo1->screen_base = viafbinfo->screen_base +
2146 viafb_second_offset;
2148 default_var.xres = viafb_second_xres;
2149 default_var.yres = viafb_second_yres;
2150 default_var.xres_virtual = viafb_second_virtual_xres;
2151 default_var.yres_virtual = viafb_second_virtual_yres;
2152 if (viafb_bpp1 != viafb_bpp)
2153 viafb_bpp1 = viafb_bpp;
2154 default_var.bits_per_pixel = viafb_bpp1;
2155 default_var.pixclock =
2156 viafb_get_pixclock(viafb_second_xres, viafb_second_yres,
2158 default_var.left_margin = (viafb_second_xres >> 3) & 0xf8;
2159 default_var.right_margin = 32;
2160 default_var.upper_margin = 16;
2161 default_var.lower_margin = 4;
2162 default_var.hsync_len = default_var.left_margin;
2163 default_var.vsync_len = 4;
2165 viafb_setup_fixinfo(&viafbinfo1->fix, viaparinfo1);
2166 viafb_check_var(&default_var, viafbinfo1);
2167 viafbinfo1->var = default_var;
2168 viafb_update_fix(viafbinfo1);
2171 viafb_setup_fixinfo(&viafbinfo->fix, viaparinfo);
2172 viafb_check_var(&default_var, viafbinfo);
2173 viafbinfo->var = default_var;
2174 viafb_update_fix(viafbinfo);
2175 default_var.activate = FB_ACTIVATE_NOW;
2176 fb_alloc_cmap(&viafbinfo->cmap, 256, 0);
2178 if (viafb_dual_fb && (viafb_primary_dev == LCD_Device)
2179 && (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)) {
2180 if (register_framebuffer(viafbinfo1) < 0)
2183 if (register_framebuffer(viafbinfo) < 0)
2186 if (viafb_dual_fb && ((viafb_primary_dev != LCD_Device)
2187 || (viaparinfo->chip_info->gfx_chip_name !=
2188 UNICHROME_CLE266))) {
2189 if (register_framebuffer(viafbinfo1) < 0)
2192 DEBUG_MSG(KERN_INFO "fb%d: %s frame buffer device %dx%d-%dbpp\n",
2193 viafbinfo->node, viafbinfo->fix.id, default_var.xres,
2194 default_var.yres, default_var.bits_per_pixel);
2196 viafb_init_proc(&viaparinfo->proc_entry);
2197 viafb_init_dac(IGA2);
2201 static void __devexit via_pci_remove(void)
2203 DEBUG_MSG(KERN_INFO "via_pci_remove!\n");
2204 fb_dealloc_cmap(&viafbinfo->cmap);
2205 unregister_framebuffer(viafbinfo);
2207 unregister_framebuffer(viafbinfo1);
2208 iounmap((void *)viafbinfo->screen_base);
2209 iounmap(viaparinfo->io_virt);
2211 viafb_delete_i2c_buss(viaparinfo);
2213 framebuffer_release(viafbinfo);
2215 framebuffer_release(viafbinfo1);
2217 viafb_remove_proc(viaparinfo->proc_entry);
2221 static int __init viafb_setup(char *options)
2224 DEBUG_MSG(KERN_INFO "viafb_setup!\n");
2226 if (!options || !*options)
2229 while ((this_opt = strsep(&options, ",")) != NULL) {
2233 if (!strncmp(this_opt, "viafb_mode1=", 12))
2234 viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL);
2235 else if (!strncmp(this_opt, "viafb_mode=", 11))
2236 viafb_mode = kstrdup(this_opt + 11, GFP_KERNEL);
2237 else if (!strncmp(this_opt, "viafb_bpp1=", 11))
2238 strict_strtoul(this_opt + 11, 0,
2239 (unsigned long *)&viafb_bpp1);
2240 else if (!strncmp(this_opt, "viafb_bpp=", 10))
2241 strict_strtoul(this_opt + 10, 0,
2242 (unsigned long *)&viafb_bpp);
2243 else if (!strncmp(this_opt, "viafb_refresh1=", 15))
2244 strict_strtoul(this_opt + 15, 0,
2245 (unsigned long *)&viafb_refresh1);
2246 else if (!strncmp(this_opt, "viafb_refresh=", 14))
2247 strict_strtoul(this_opt + 14, 0,
2248 (unsigned long *)&viafb_refresh);
2249 else if (!strncmp(this_opt, "viafb_lcd_dsp_method=", 21))
2250 strict_strtoul(this_opt + 21, 0,
2251 (unsigned long *)&viafb_lcd_dsp_method);
2252 else if (!strncmp(this_opt, "viafb_lcd_panel_id=", 19))
2253 strict_strtoul(this_opt + 19, 0,
2254 (unsigned long *)&viafb_lcd_panel_id);
2255 else if (!strncmp(this_opt, "viafb_accel=", 12))
2256 strict_strtoul(this_opt + 12, 0,
2257 (unsigned long *)&viafb_accel);
2258 else if (!strncmp(this_opt, "viafb_SAMM_ON=", 14))
2259 strict_strtoul(this_opt + 14, 0,
2260 (unsigned long *)&viafb_SAMM_ON);
2261 else if (!strncmp(this_opt, "viafb_active_dev=", 17))
2262 viafb_active_dev = kstrdup(this_opt + 17, GFP_KERNEL);
2263 else if (!strncmp(this_opt,
2264 "viafb_display_hardware_layout=", 30))
2265 strict_strtoul(this_opt + 30, 0,
2266 (unsigned long *)&viafb_display_hardware_layout);
2267 else if (!strncmp(this_opt, "viafb_second_size=", 18))
2268 strict_strtoul(this_opt + 18, 0,
2269 (unsigned long *)&viafb_second_size);
2270 else if (!strncmp(this_opt,
2271 "viafb_platform_epia_dvi=", 24))
2272 strict_strtoul(this_opt + 24, 0,
2273 (unsigned long *)&viafb_platform_epia_dvi);
2274 else if (!strncmp(this_opt,
2275 "viafb_device_lcd_dualedge=", 26))
2276 strict_strtoul(this_opt + 26, 0,
2277 (unsigned long *)&viafb_device_lcd_dualedge);
2278 else if (!strncmp(this_opt, "viafb_bus_width=", 16))
2279 strict_strtoul(this_opt + 16, 0,
2280 (unsigned long *)&viafb_bus_width);
2281 else if (!strncmp(this_opt, "viafb_lcd_mode=", 15))
2282 strict_strtoul(this_opt + 15, 0,
2283 (unsigned long *)&viafb_lcd_mode);
2284 else if (!strncmp(this_opt, "viafb_lcd_port=", 15))
2285 viafb_lcd_port = kstrdup(this_opt + 15, GFP_KERNEL);
2286 else if (!strncmp(this_opt, "viafb_dvi_port=", 15))
2287 viafb_dvi_port = kstrdup(this_opt + 15, GFP_KERNEL);
2293 static int __init viafb_init(void)
2296 char *option = NULL;
2297 if (fb_get_options("viafb", &option))
2299 viafb_setup(option);
2302 "VIA Graphics Intergration Chipset framebuffer %d.%d initializing\n",
2303 VERSION_MAJOR, VERSION_MINOR);
2304 return via_pci_probe();
2307 static void __exit viafb_exit(void)
2309 DEBUG_MSG(KERN_INFO "viafb_exit!\n");
2313 static struct fb_ops viafb_ops = {
2314 .owner = THIS_MODULE,
2315 .fb_open = viafb_open,
2316 .fb_release = viafb_release,
2317 .fb_check_var = viafb_check_var,
2318 .fb_set_par = viafb_set_par,
2319 .fb_setcolreg = viafb_setcolreg,
2320 .fb_pan_display = viafb_pan_display,
2321 .fb_blank = viafb_blank,
2322 .fb_fillrect = viafb_fillrect,
2323 .fb_copyarea = viafb_copyarea,
2324 .fb_imageblit = viafb_imageblit,
2325 .fb_cursor = viafb_cursor,
2326 .fb_ioctl = viafb_ioctl,
2327 .fb_sync = viafb_sync,
2328 .fb_setcmap = viafb_setcmap,
2331 module_init(viafb_init);
2332 module_exit(viafb_exit);
2335 module_param(viafb_memsize, int, 0);
2337 module_param(viafb_mode, charp, 0);
2338 MODULE_PARM_DESC(viafb_mode, "Set resolution (default=640x480)");
2340 module_param(viafb_mode1, charp, 0);
2341 MODULE_PARM_DESC(viafb_mode1, "Set resolution (default=640x480)");
2343 module_param(viafb_bpp, int, 0);
2344 MODULE_PARM_DESC(viafb_bpp, "Set color depth (default=32bpp)");
2346 module_param(viafb_bpp1, int, 0);
2347 MODULE_PARM_DESC(viafb_bpp1, "Set color depth (default=32bpp)");
2349 module_param(viafb_refresh, int, 0);
2350 MODULE_PARM_DESC(viafb_refresh,
2351 "Set CRT viafb_refresh rate (default = 60)");
2353 module_param(viafb_refresh1, int, 0);
2354 MODULE_PARM_DESC(viafb_refresh1,
2355 "Set CRT refresh rate (default = 60)");
2357 module_param(viafb_lcd_panel_id, int, 0);
2358 MODULE_PARM_DESC(viafb_lcd_panel_id,
2359 "Set Flat Panel type(Default=1024x768)");
2361 module_param(viafb_lcd_dsp_method, int, 0);
2362 MODULE_PARM_DESC(viafb_lcd_dsp_method,
2363 "Set Flat Panel display scaling method.(Default=Expandsion)");
2365 module_param(viafb_SAMM_ON, int, 0);
2366 MODULE_PARM_DESC(viafb_SAMM_ON,
2367 "Turn on/off flag of SAMM(Default=OFF)");
2369 module_param(viafb_accel, int, 0);
2370 MODULE_PARM_DESC(viafb_accel,
2371 "Set 2D Hardware Acceleration.(Default = OFF)");
2373 module_param(viafb_active_dev, charp, 0);
2374 MODULE_PARM_DESC(viafb_active_dev, "Specify active devices.");
2376 module_param(viafb_display_hardware_layout, int, 0);
2377 MODULE_PARM_DESC(viafb_display_hardware_layout,
2378 "Display Hardware Layout (LCD Only, DVI Only...,etc)");
2380 module_param(viafb_second_size, int, 0);
2381 MODULE_PARM_DESC(viafb_second_size,
2382 "Set secondary device memory size");
2384 module_param(viafb_dual_fb, int, 0);
2385 MODULE_PARM_DESC(viafb_dual_fb,
2386 "Turn on/off flag of dual framebuffer devices.(Default = OFF)");
2388 module_param(viafb_platform_epia_dvi, int, 0);
2389 MODULE_PARM_DESC(viafb_platform_epia_dvi,
2390 "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)");
2392 module_param(viafb_device_lcd_dualedge, int, 0);
2393 MODULE_PARM_DESC(viafb_device_lcd_dualedge,
2394 "Turn on/off flag of dual edge panel.(Default = OFF)");
2396 module_param(viafb_bus_width, int, 0);
2397 MODULE_PARM_DESC(viafb_bus_width,
2398 "Set bus width of panel.(Default = 12)");
2400 module_param(viafb_lcd_mode, int, 0);
2401 MODULE_PARM_DESC(viafb_lcd_mode,
2402 "Set Flat Panel mode(Default=OPENLDI)");
2404 module_param(viafb_lcd_port, charp, 0);
2405 MODULE_PARM_DESC(viafb_lcd_port, "Specify LCD output port.");
2407 module_param(viafb_dvi_port, charp, 0);
2408 MODULE_PARM_DESC(viafb_dvi_port, "Specify DVI output port.");
2410 MODULE_LICENSE("GPL");