2 * Copyright 1998-2009 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>
23 #include <linux/seq_file.h>
24 #include <linux/stat.h>
29 static char *viafb_name
= "Via";
30 static u32 pseudo_pal
[17];
33 static char *viafb_mode
;
34 static char *viafb_mode1
;
35 static int viafb_bpp
= 32;
36 static int viafb_bpp1
= 32;
38 static unsigned int viafb_second_offset
;
39 static int viafb_second_size
;
41 static int viafb_accel
= 1;
43 /* Added for specifying active devices.*/
44 char *viafb_active_dev
;
46 /*Added for specify lcd output port*/
47 char *viafb_lcd_port
= "";
48 char *viafb_dvi_port
= "";
50 static void viafb_set_device(struct device_t active_dev
);
51 static int apply_device_setting(struct viafb_ioctl_setting setting_info
,
52 struct fb_info
*info
);
53 static void apply_second_mode_setting(struct fb_var_screeninfo
55 static void retrieve_device_setting(struct viafb_ioctl_setting
57 static int viafb_pan_display(struct fb_var_screeninfo
*var
,
58 struct fb_info
*info
);
60 static struct fb_ops viafb_ops
;
63 static void viafb_fill_var_color_info(struct fb_var_screeninfo
*var
, u8 depth
)
66 var
->red
.msb_right
= 0;
67 var
->green
.msb_right
= 0;
68 var
->blue
.msb_right
= 0;
69 var
->transp
.offset
= 0;
70 var
->transp
.length
= 0;
71 var
->transp
.msb_right
= 0;
75 var
->bits_per_pixel
= 8;
77 var
->green
.offset
= 0;
80 var
->green
.length
= 8;
84 var
->bits_per_pixel
= 16;
86 var
->green
.offset
= 5;
89 var
->green
.length
= 5;
93 var
->bits_per_pixel
= 16;
95 var
->green
.offset
= 5;
98 var
->green
.length
= 6;
102 var
->bits_per_pixel
= 32;
103 var
->red
.offset
= 16;
104 var
->green
.offset
= 8;
105 var
->blue
.offset
= 0;
107 var
->green
.length
= 8;
108 var
->blue
.length
= 8;
111 var
->bits_per_pixel
= 32;
112 var
->red
.offset
= 20;
113 var
->green
.offset
= 10;
114 var
->blue
.offset
= 0;
115 var
->red
.length
= 10;
116 var
->green
.length
= 10;
117 var
->blue
.length
= 10;
122 static void viafb_update_fix(struct fb_info
*info
)
124 u32 bpp
= info
->var
.bits_per_pixel
;
127 bpp
== 8 ? FB_VISUAL_PSEUDOCOLOR
: FB_VISUAL_TRUECOLOR
;
128 info
->fix
.line_length
= (info
->var
.xres_virtual
* bpp
/ 8 + 7) & ~7;
131 static void viafb_setup_fixinfo(struct fb_fix_screeninfo
*fix
,
132 struct viafb_par
*viaparinfo
)
134 memset(fix
, 0, sizeof(struct fb_fix_screeninfo
));
135 strcpy(fix
->id
, viafb_name
);
137 fix
->smem_start
= viaparinfo
->fbmem
;
138 fix
->smem_len
= viaparinfo
->fbmem_free
;
140 fix
->type
= FB_TYPE_PACKED_PIXELS
;
142 fix
->visual
= FB_VISUAL_TRUECOLOR
;
144 fix
->xpanstep
= fix
->ywrapstep
= 0;
147 /* Just tell the accel name */
148 viafbinfo
->fix
.accel
= FB_ACCEL_VIA_UNICHROME
;
150 static int viafb_open(struct fb_info
*info
, int user
)
152 DEBUG_MSG(KERN_INFO
"viafb_open!\n");
156 static int viafb_release(struct fb_info
*info
, int user
)
158 DEBUG_MSG(KERN_INFO
"viafb_release!\n");
162 static int viafb_check_var(struct fb_var_screeninfo
*var
,
163 struct fb_info
*info
)
165 int htotal
, vtotal
, depth
;
166 struct VideoModeTable
*vmode_entry
;
167 struct viafb_par
*ppar
= info
->par
;
168 u32 long_refresh
, line
;
170 DEBUG_MSG(KERN_INFO
"viafb_check_var!\n");
172 /* HW neither support interlacte nor double-scaned mode */
173 if (var
->vmode
& FB_VMODE_INTERLACED
|| var
->vmode
& FB_VMODE_DOUBLE
)
176 vmode_entry
= viafb_get_mode(var
->xres
, var
->yres
);
179 "viafb: Mode %dx%dx%d not supported!!\n",
180 var
->xres
, var
->yres
, var
->bits_per_pixel
);
184 depth
= fb_get_color_depth(var
, &info
->fix
);
186 depth
= var
->bits_per_pixel
;
188 if (depth
< 0 || depth
> 32)
192 else if (depth
== 15 && viafb_dual_fb
&& ppar
->iga_path
== IGA1
)
194 else if (depth
== 30)
198 else if (depth
<= 16)
203 viafb_fill_var_color_info(var
, depth
);
204 line
= (var
->xres_virtual
* var
->bits_per_pixel
/ 8 + 7) & ~7;
205 if (line
* var
->yres_virtual
> ppar
->memsize
)
208 /* Based on var passed in to calculate the refresh,
209 * because our driver use some modes special.
211 htotal
= var
->xres
+ var
->left_margin
+
212 var
->right_margin
+ var
->hsync_len
;
213 vtotal
= var
->yres
+ var
->upper_margin
+
214 var
->lower_margin
+ var
->vsync_len
;
215 long_refresh
= 1000000000UL / var
->pixclock
* 1000;
216 long_refresh
/= (htotal
* vtotal
);
218 viafb_refresh
= viafb_get_refresh(var
->xres
, var
->yres
, long_refresh
);
220 /* Adjust var according to our driver's own table */
221 viafb_fill_var_timing_info(var
, viafb_refresh
, vmode_entry
);
222 if (info
->var
.accel_flags
& FB_ACCELF_TEXT
&&
223 !ppar
->shared
->engine_mmio
)
224 info
->var
.accel_flags
= 0;
229 static int viafb_set_par(struct fb_info
*info
)
231 struct viafb_par
*viapar
= info
->par
;
232 struct VideoModeTable
*vmode_entry
, *vmode_entry1
= NULL
;
233 DEBUG_MSG(KERN_INFO
"viafb_set_par!\n");
235 viapar
->depth
= fb_get_color_depth(&info
->var
, &info
->fix
);
236 viafb_update_device_setting(viafbinfo
->var
.xres
, viafbinfo
->var
.yres
,
237 viafbinfo
->var
.bits_per_pixel
, viafb_refresh
, 0);
239 vmode_entry
= viafb_get_mode(viafbinfo
->var
.xres
, viafbinfo
->var
.yres
);
241 vmode_entry1
= viafb_get_mode(viafbinfo1
->var
.xres
,
242 viafbinfo1
->var
.yres
);
243 viafb_update_device_setting(viafbinfo1
->var
.xres
,
244 viafbinfo1
->var
.yres
, viafbinfo1
->var
.bits_per_pixel
,
246 } else if (viafb_SAMM_ON
== 1) {
248 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
249 viafb_second_xres
, viafb_second_yres
, viafb_bpp1
);
250 vmode_entry1
= viafb_get_mode(viafb_second_xres
,
253 viafb_update_device_setting(viafb_second_xres
,
254 viafb_second_yres
, viafb_bpp1
, viafb_refresh1
, 1);
258 viafb_update_fix(info
);
259 if (viafb_dual_fb
&& viapar
->iga_path
== IGA2
)
260 viafb_bpp1
= info
->var
.bits_per_pixel
;
262 viafb_bpp
= info
->var
.bits_per_pixel
;
264 if (info
->var
.accel_flags
& FB_ACCELF_TEXT
)
265 info
->flags
&= ~FBINFO_HWACCEL_DISABLED
;
267 info
->flags
|= FBINFO_HWACCEL_DISABLED
;
268 viafb_setmode(vmode_entry
, info
->var
.bits_per_pixel
,
269 vmode_entry1
, viafb_bpp1
);
270 viafb_pan_display(&info
->var
, info
);
276 /* Set one color register */
277 static int viafb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
278 unsigned blue
, unsigned transp
, struct fb_info
*info
)
280 struct viafb_par
*viapar
= info
->par
;
283 if (info
->fix
.visual
== FB_VISUAL_PSEUDOCOLOR
) {
287 if (!viafb_dual_fb
|| viapar
->iga_path
== IGA1
)
288 viafb_set_primary_color_register(regno
, red
>> 8,
289 green
>> 8, blue
>> 8);
291 if (!viafb_dual_fb
|| viapar
->iga_path
== IGA2
)
292 viafb_set_secondary_color_register(regno
, red
>> 8,
293 green
>> 8, blue
>> 8);
298 r
= (red
>> (16 - info
->var
.red
.length
))
299 << info
->var
.red
.offset
;
300 b
= (blue
>> (16 - info
->var
.blue
.length
))
301 << info
->var
.blue
.offset
;
302 g
= (green
>> (16 - info
->var
.green
.length
))
303 << info
->var
.green
.offset
;
304 ((u32
*) info
->pseudo_palette
)[regno
] = r
| g
| b
;
310 static int viafb_pan_display(struct fb_var_screeninfo
*var
,
311 struct fb_info
*info
)
313 struct viafb_par
*viapar
= info
->par
;
314 u32 vram_addr
= (var
->yoffset
* var
->xres_virtual
+ var
->xoffset
)
315 * (var
->bits_per_pixel
/ 8) + viapar
->vram_addr
;
317 DEBUG_MSG(KERN_DEBUG
"viafb_pan_display, address = %d\n", vram_addr
);
318 if (!viafb_dual_fb
) {
319 viafb_set_primary_address(vram_addr
);
320 viafb_set_secondary_address(vram_addr
);
321 } else if (viapar
->iga_path
== IGA1
)
322 viafb_set_primary_address(vram_addr
);
324 viafb_set_secondary_address(vram_addr
);
329 static int viafb_blank(int blank_mode
, struct fb_info
*info
)
331 DEBUG_MSG(KERN_INFO
"viafb_blank!\n");
332 /* clear DPMS setting */
334 switch (blank_mode
) {
335 case FB_BLANK_UNBLANK
:
336 /* Screen: On, HSync: On, VSync: On */
337 /* control CRT monitor power management */
338 viafb_write_reg_mask(CR36
, VIACR
, 0x00, BIT4
+ BIT5
);
340 case FB_BLANK_HSYNC_SUSPEND
:
341 /* Screen: Off, HSync: Off, VSync: On */
342 /* control CRT monitor power management */
343 viafb_write_reg_mask(CR36
, VIACR
, 0x10, BIT4
+ BIT5
);
345 case FB_BLANK_VSYNC_SUSPEND
:
346 /* Screen: Off, HSync: On, VSync: Off */
347 /* control CRT monitor power management */
348 viafb_write_reg_mask(CR36
, VIACR
, 0x20, BIT4
+ BIT5
);
350 case FB_BLANK_POWERDOWN
:
351 /* Screen: Off, HSync: Off, VSync: Off */
352 /* control CRT monitor power management */
353 viafb_write_reg_mask(CR36
, VIACR
, 0x30, BIT4
+ BIT5
);
360 static int viafb_ioctl(struct fb_info
*info
, u_int cmd
, u_long arg
)
363 struct viafb_ioctl_mode viamode
;
364 struct viafb_ioctl_samm viasamm
;
365 struct viafb_driver_version driver_version
;
366 struct fb_var_screeninfo sec_var
;
367 struct _panel_size_pos_info panel_pos_size_para
;
368 struct viafb_ioctl_setting viafb_setting
;
369 struct device_t active_dev
;
372 u32
*viafb_gamma_table
;
373 char driver_name
[] = "viafb";
375 u32 __user
*argp
= (u32 __user
*) arg
;
378 DEBUG_MSG(KERN_INFO
"viafb_ioctl: 0x%X !!\n", cmd
);
379 printk(KERN_WARNING
"viafb_ioctl: Please avoid this interface as it is unstable and might change or vanish at any time!\n");
380 memset(&u
, 0, sizeof(u
));
383 case VIAFB_GET_CHIP_INFO
:
384 if (copy_to_user(argp
, viaparinfo
->chip_info
,
385 sizeof(struct chip_information
)))
388 case VIAFB_GET_INFO_SIZE
:
389 return put_user((u32
)sizeof(struct viafb_ioctl_info
), argp
);
391 return viafb_ioctl_get_viafb_info(arg
);
393 return put_user(viafb_ioctl_hotplug(info
->var
.xres
,
395 info
->var
.bits_per_pixel
), argp
);
396 case VIAFB_SET_HOTPLUG_FLAG
:
397 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
399 viafb_hotplug
= (gpu32
) ? 1 : 0;
401 case VIAFB_GET_RESOLUTION
:
402 u
.viamode
.xres
= (u32
) viafb_hotplug_Xres
;
403 u
.viamode
.yres
= (u32
) viafb_hotplug_Yres
;
404 u
.viamode
.refresh
= (u32
) viafb_hotplug_refresh
;
405 u
.viamode
.bpp
= (u32
) viafb_hotplug_bpp
;
406 if (viafb_SAMM_ON
== 1) {
407 u
.viamode
.xres_sec
= viafb_second_xres
;
408 u
.viamode
.yres_sec
= viafb_second_yres
;
409 u
.viamode
.virtual_xres_sec
= viafb_second_virtual_xres
;
410 u
.viamode
.virtual_yres_sec
= viafb_second_virtual_yres
;
411 u
.viamode
.refresh_sec
= viafb_refresh1
;
412 u
.viamode
.bpp_sec
= viafb_bpp1
;
414 u
.viamode
.xres_sec
= 0;
415 u
.viamode
.yres_sec
= 0;
416 u
.viamode
.virtual_xres_sec
= 0;
417 u
.viamode
.virtual_yres_sec
= 0;
418 u
.viamode
.refresh_sec
= 0;
419 u
.viamode
.bpp_sec
= 0;
421 if (copy_to_user(argp
, &u
.viamode
, sizeof(u
.viamode
)))
424 case VIAFB_GET_SAMM_INFO
:
425 u
.viasamm
.samm_status
= viafb_SAMM_ON
;
427 if (viafb_SAMM_ON
== 1) {
429 u
.viasamm
.size_prim
= viaparinfo
->fbmem_free
;
430 u
.viasamm
.size_sec
= viaparinfo1
->fbmem_free
;
432 if (viafb_second_size
) {
433 u
.viasamm
.size_prim
=
434 viaparinfo
->fbmem_free
-
435 viafb_second_size
* 1024 * 1024;
437 viafb_second_size
* 1024 * 1024;
439 u
.viasamm
.size_prim
=
440 viaparinfo
->fbmem_free
>> 1;
442 (viaparinfo
->fbmem_free
>> 1);
445 u
.viasamm
.mem_base
= viaparinfo
->fbmem
;
446 u
.viasamm
.offset_sec
= viafb_second_offset
;
448 u
.viasamm
.size_prim
=
449 viaparinfo
->memsize
- viaparinfo
->fbmem_used
;
450 u
.viasamm
.size_sec
= 0;
451 u
.viasamm
.mem_base
= viaparinfo
->fbmem
;
452 u
.viasamm
.offset_sec
= 0;
455 if (copy_to_user(argp
, &u
.viasamm
, sizeof(u
.viasamm
)))
459 case VIAFB_TURN_ON_OUTPUT_DEVICE
:
460 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
462 if (gpu32
& CRT_Device
)
464 if (gpu32
& DVI_Device
)
466 if (gpu32
& LCD_Device
)
469 case VIAFB_TURN_OFF_OUTPUT_DEVICE
:
470 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
472 if (gpu32
& CRT_Device
)
474 if (gpu32
& DVI_Device
)
476 if (gpu32
& LCD_Device
)
479 case VIAFB_SET_DEVICE
:
480 if (copy_from_user(&u
.active_dev
, (void *)argp
,
481 sizeof(u
.active_dev
)))
483 viafb_set_device(u
.active_dev
);
486 case VIAFB_GET_DEVICE
:
487 u
.active_dev
.crt
= viafb_CRT_ON
;
488 u
.active_dev
.dvi
= viafb_DVI_ON
;
489 u
.active_dev
.lcd
= viafb_LCD_ON
;
490 u
.active_dev
.samm
= viafb_SAMM_ON
;
491 u
.active_dev
.primary_dev
= viafb_primary_dev
;
493 u
.active_dev
.lcd_dsp_cent
= viafb_lcd_dsp_method
;
494 u
.active_dev
.lcd_panel_id
= viafb_lcd_panel_id
;
495 u
.active_dev
.lcd_mode
= viafb_lcd_mode
;
497 u
.active_dev
.xres
= viafb_hotplug_Xres
;
498 u
.active_dev
.yres
= viafb_hotplug_Yres
;
500 u
.active_dev
.xres1
= viafb_second_xres
;
501 u
.active_dev
.yres1
= viafb_second_yres
;
503 u
.active_dev
.bpp
= viafb_bpp
;
504 u
.active_dev
.bpp1
= viafb_bpp1
;
505 u
.active_dev
.refresh
= viafb_refresh
;
506 u
.active_dev
.refresh1
= viafb_refresh1
;
508 u
.active_dev
.epia_dvi
= viafb_platform_epia_dvi
;
509 u
.active_dev
.lcd_dual_edge
= viafb_device_lcd_dualedge
;
510 u
.active_dev
.bus_width
= viafb_bus_width
;
512 if (copy_to_user(argp
, &u
.active_dev
, sizeof(u
.active_dev
)))
516 case VIAFB_GET_DRIVER_VERSION
:
517 u
.driver_version
.iMajorNum
= VERSION_MAJOR
;
518 u
.driver_version
.iKernelNum
= VERSION_KERNEL
;
519 u
.driver_version
.iOSNum
= VERSION_OS
;
520 u
.driver_version
.iMinorNum
= VERSION_MINOR
;
522 if (copy_to_user(argp
, &u
.driver_version
,
523 sizeof(u
.driver_version
)))
528 case VIAFB_SET_DEVICE_INFO
:
529 if (copy_from_user(&u
.viafb_setting
,
530 argp
, sizeof(u
.viafb_setting
)))
532 if (apply_device_setting(u
.viafb_setting
, info
) < 0)
537 case VIAFB_SET_SECOND_MODE
:
538 if (copy_from_user(&u
.sec_var
, argp
, sizeof(u
.sec_var
)))
540 apply_second_mode_setting(&u
.sec_var
);
543 case VIAFB_GET_DEVICE_INFO
:
545 retrieve_device_setting(&u
.viafb_setting
);
547 if (copy_to_user(argp
, &u
.viafb_setting
,
548 sizeof(u
.viafb_setting
)))
553 case VIAFB_GET_DEVICE_SUPPORT
:
554 viafb_get_device_support_state(&state_info
);
555 if (put_user(state_info
, argp
))
559 case VIAFB_GET_DEVICE_CONNECT
:
560 viafb_get_device_connect_state(&state_info
);
561 if (put_user(state_info
, argp
))
565 case VIAFB_GET_PANEL_SUPPORT_EXPAND
:
567 viafb_lcd_get_support_expand_state(info
->var
.xres
,
569 if (put_user(state_info
, argp
))
573 case VIAFB_GET_DRIVER_NAME
:
574 if (copy_to_user(argp
, driver_name
, sizeof(driver_name
)))
578 case VIAFB_SET_GAMMA_LUT
:
579 viafb_gamma_table
= kmalloc(256 * sizeof(u32
), GFP_KERNEL
);
580 if (!viafb_gamma_table
)
582 if (copy_from_user(viafb_gamma_table
, argp
,
583 256 * sizeof(u32
))) {
584 kfree(viafb_gamma_table
);
587 viafb_set_gamma_table(viafb_bpp
, viafb_gamma_table
);
588 kfree(viafb_gamma_table
);
591 case VIAFB_GET_GAMMA_LUT
:
592 viafb_gamma_table
= kmalloc(256 * sizeof(u32
), GFP_KERNEL
);
593 if (!viafb_gamma_table
)
595 viafb_get_gamma_table(viafb_gamma_table
);
596 if (copy_to_user(argp
, viafb_gamma_table
,
597 256 * sizeof(u32
))) {
598 kfree(viafb_gamma_table
);
601 kfree(viafb_gamma_table
);
604 case VIAFB_GET_GAMMA_SUPPORT_STATE
:
605 viafb_get_gamma_support_state(viafb_bpp
, &state_info
);
606 if (put_user(state_info
, argp
))
609 case VIAFB_SYNC_SURFACE
:
610 DEBUG_MSG(KERN_INFO
"lobo VIAFB_SYNC_SURFACE\n");
612 case VIAFB_GET_DRIVER_CAPS
:
615 case VIAFB_GET_PANEL_MAX_SIZE
:
616 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
617 sizeof(u
.panel_pos_size_para
)))
619 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
620 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
621 sizeof(u
.panel_pos_size_para
)))
624 case VIAFB_GET_PANEL_MAX_POSITION
:
625 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
626 sizeof(u
.panel_pos_size_para
)))
628 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
629 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
630 sizeof(u
.panel_pos_size_para
)))
634 case VIAFB_GET_PANEL_POSITION
:
635 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
636 sizeof(u
.panel_pos_size_para
)))
638 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
639 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
640 sizeof(u
.panel_pos_size_para
)))
643 case VIAFB_GET_PANEL_SIZE
:
644 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
645 sizeof(u
.panel_pos_size_para
)))
647 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
648 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
649 sizeof(u
.panel_pos_size_para
)))
653 case VIAFB_SET_PANEL_POSITION
:
654 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
655 sizeof(u
.panel_pos_size_para
)))
658 case VIAFB_SET_PANEL_SIZE
:
659 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
660 sizeof(u
.panel_pos_size_para
)))
671 static void viafb_fillrect(struct fb_info
*info
,
672 const struct fb_fillrect
*rect
)
674 struct viafb_par
*viapar
= info
->par
;
675 struct viafb_shared
*shared
= viapar
->shared
;
679 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
) {
680 cfb_fillrect(info
, rect
);
684 if (!rect
->width
|| !rect
->height
)
687 if (info
->fix
.visual
== FB_VISUAL_TRUECOLOR
)
688 fg_color
= ((u32
*)info
->pseudo_palette
)[rect
->color
];
690 fg_color
= rect
->color
;
692 if (rect
->rop
== ROP_XOR
)
697 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: fillrect\n");
698 if (shared
->hw_bitblt(shared
->engine_mmio
, VIA_BITBLT_FILL
,
699 rect
->width
, rect
->height
, info
->var
.bits_per_pixel
,
700 viapar
->vram_addr
, info
->fix
.line_length
, rect
->dx
, rect
->dy
,
701 NULL
, 0, 0, 0, 0, fg_color
, 0, rop
))
702 cfb_fillrect(info
, rect
);
705 static void viafb_copyarea(struct fb_info
*info
,
706 const struct fb_copyarea
*area
)
708 struct viafb_par
*viapar
= info
->par
;
709 struct viafb_shared
*shared
= viapar
->shared
;
711 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
) {
712 cfb_copyarea(info
, area
);
716 if (!area
->width
|| !area
->height
)
719 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: copyarea\n");
720 if (shared
->hw_bitblt(shared
->engine_mmio
, VIA_BITBLT_COLOR
,
721 area
->width
, area
->height
, info
->var
.bits_per_pixel
,
722 viapar
->vram_addr
, info
->fix
.line_length
, area
->dx
, area
->dy
,
723 NULL
, viapar
->vram_addr
, info
->fix
.line_length
,
724 area
->sx
, area
->sy
, 0, 0, 0))
725 cfb_copyarea(info
, area
);
728 static void viafb_imageblit(struct fb_info
*info
,
729 const struct fb_image
*image
)
731 struct viafb_par
*viapar
= info
->par
;
732 struct viafb_shared
*shared
= viapar
->shared
;
733 u32 fg_color
= 0, bg_color
= 0;
736 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
||
737 (image
->depth
!= 1 && image
->depth
!= viapar
->depth
)) {
738 cfb_imageblit(info
, image
);
742 if (image
->depth
== 1) {
743 op
= VIA_BITBLT_MONO
;
744 if (info
->fix
.visual
== FB_VISUAL_TRUECOLOR
) {
746 ((u32
*)info
->pseudo_palette
)[image
->fg_color
];
748 ((u32
*)info
->pseudo_palette
)[image
->bg_color
];
750 fg_color
= image
->fg_color
;
751 bg_color
= image
->bg_color
;
754 op
= VIA_BITBLT_COLOR
;
756 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: imageblit\n");
757 if (shared
->hw_bitblt(shared
->engine_mmio
, op
,
758 image
->width
, image
->height
, info
->var
.bits_per_pixel
,
759 viapar
->vram_addr
, info
->fix
.line_length
, image
->dx
, image
->dy
,
760 (u32
*)image
->data
, 0, 0, 0, 0, fg_color
, bg_color
, 0))
761 cfb_imageblit(info
, image
);
764 static int viafb_cursor(struct fb_info
*info
, struct fb_cursor
*cursor
)
766 struct viafb_par
*viapar
= info
->par
;
767 void __iomem
*engine
= viapar
->shared
->engine_mmio
;
768 u32 temp
, xx
, yy
, bg_color
= 0, fg_color
= 0,
769 chip_name
= viapar
->shared
->chip_info
.gfx_chip_name
;
770 int i
, j
= 0, cur_size
= 64;
772 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| info
!= viafbinfo
)
775 /* LCD ouput does not support hw cursors (at least on VN896) */
776 if ((chip_name
== UNICHROME_CLE266
&& viapar
->iga_path
== IGA2
) ||
780 viafb_show_hw_cursor(info
, HW_Cursor_OFF
);
782 if (cursor
->set
& FB_CUR_SETHOT
) {
783 temp
= (cursor
->hot
.x
<< 16) + cursor
->hot
.y
;
784 writel(temp
, engine
+ VIA_REG_CURSOR_ORG
);
787 if (cursor
->set
& FB_CUR_SETPOS
) {
788 yy
= cursor
->image
.dy
- info
->var
.yoffset
;
789 xx
= cursor
->image
.dx
- info
->var
.xoffset
;
792 writel(temp
, engine
+ VIA_REG_CURSOR_POS
);
795 if (cursor
->image
.width
<= 32 && cursor
->image
.height
<= 32)
797 else if (cursor
->image
.width
<= 64 && cursor
->image
.height
<= 64)
800 printk(KERN_WARNING
"viafb_cursor: The cursor is too large "
801 "%dx%d", cursor
->image
.width
, cursor
->image
.height
);
805 if (cursor
->set
& FB_CUR_SETSIZE
) {
806 temp
= readl(engine
+ VIA_REG_CURSOR_MODE
);
812 writel(temp
, engine
+ VIA_REG_CURSOR_MODE
);
815 if (cursor
->set
& FB_CUR_SETCMAP
) {
816 fg_color
= cursor
->image
.fg_color
;
817 bg_color
= cursor
->image
.bg_color
;
818 if (chip_name
== UNICHROME_CX700
||
819 chip_name
== UNICHROME_VX800
||
820 chip_name
== UNICHROME_VX855
) {
822 ((info
->cmap
.red
[fg_color
] & 0xFFC0) << 14) |
823 ((info
->cmap
.green
[fg_color
] & 0xFFC0) << 4) |
824 ((info
->cmap
.blue
[fg_color
] & 0xFFC0) >> 6);
826 ((info
->cmap
.red
[bg_color
] & 0xFFC0) << 14) |
827 ((info
->cmap
.green
[bg_color
] & 0xFFC0) << 4) |
828 ((info
->cmap
.blue
[bg_color
] & 0xFFC0) >> 6);
831 ((info
->cmap
.red
[fg_color
] & 0xFF00) << 8) |
832 (info
->cmap
.green
[fg_color
] & 0xFF00) |
833 ((info
->cmap
.blue
[fg_color
] & 0xFF00) >> 8);
835 ((info
->cmap
.red
[bg_color
] & 0xFF00) << 8) |
836 (info
->cmap
.green
[bg_color
] & 0xFF00) |
837 ((info
->cmap
.blue
[bg_color
] & 0xFF00) >> 8);
840 writel(bg_color
, engine
+ VIA_REG_CURSOR_BG
);
841 writel(fg_color
, engine
+ VIA_REG_CURSOR_FG
);
844 if (cursor
->set
& FB_CUR_SETSHAPE
) {
846 u8 data
[CURSOR_SIZE
];
847 u32 bak
[CURSOR_SIZE
/ 4];
848 } *cr_data
= kzalloc(sizeof(*cr_data
), GFP_ATOMIC
);
849 int size
= ((cursor
->image
.width
+ 7) >> 3) *
850 cursor
->image
.height
;
855 if (cur_size
== 32) {
856 for (i
= 0; i
< (CURSOR_SIZE
/ 4); i
++) {
857 cr_data
->bak
[i
] = 0x0;
858 cr_data
->bak
[i
+ 1] = 0xFFFFFFFF;
862 for (i
= 0; i
< (CURSOR_SIZE
/ 4); i
++) {
863 cr_data
->bak
[i
] = 0x0;
864 cr_data
->bak
[i
+ 1] = 0x0;
865 cr_data
->bak
[i
+ 2] = 0xFFFFFFFF;
866 cr_data
->bak
[i
+ 3] = 0xFFFFFFFF;
871 switch (cursor
->rop
) {
873 for (i
= 0; i
< size
; i
++)
874 cr_data
->data
[i
] = cursor
->mask
[i
];
878 for (i
= 0; i
< size
; i
++)
879 cr_data
->data
[i
] = cursor
->mask
[i
];
885 if (cur_size
== 32) {
886 for (i
= 0; i
< size
; i
++) {
887 cr_data
->bak
[j
] = (u32
) cr_data
->data
[i
];
888 cr_data
->bak
[j
+ 1] = ~cr_data
->bak
[j
];
892 for (i
= 0; i
< size
; i
++) {
893 cr_data
->bak
[j
] = (u32
) cr_data
->data
[i
];
894 cr_data
->bak
[j
+ 1] = 0x0;
895 cr_data
->bak
[j
+ 2] = ~cr_data
->bak
[j
];
896 cr_data
->bak
[j
+ 3] = ~cr_data
->bak
[j
+ 1];
901 memcpy_toio(viafbinfo
->screen_base
+ viapar
->shared
->
902 cursor_vram_addr
, cr_data
->bak
, CURSOR_SIZE
);
907 viafb_show_hw_cursor(info
, HW_Cursor_ON
);
912 static int viafb_sync(struct fb_info
*info
)
914 if (!(info
->flags
& FBINFO_HWACCEL_DISABLED
))
915 viafb_wait_engine_idle(info
);
919 static void check_available_device_to_enable(int device_id
)
924 viafb_CRT_ON
= STATE_OFF
;
925 viafb_DVI_ON
= STATE_OFF
;
926 viafb_LCD_ON
= STATE_OFF
;
927 viafb_LCD2_ON
= STATE_OFF
;
928 viafb_DeviceStatus
= None_Device
;
930 if ((device_id
& CRT_Device
) && (device_num
< MAX_ACTIVE_DEV_NUM
)) {
931 viafb_CRT_ON
= STATE_ON
;
933 viafb_DeviceStatus
|= CRT_Device
;
936 if ((device_id
& DVI_Device
) && (device_num
< MAX_ACTIVE_DEV_NUM
)) {
937 viafb_DVI_ON
= STATE_ON
;
939 viafb_DeviceStatus
|= DVI_Device
;
942 if ((device_id
& LCD_Device
) && (device_num
< MAX_ACTIVE_DEV_NUM
)) {
943 viafb_LCD_ON
= STATE_ON
;
945 viafb_DeviceStatus
|= LCD_Device
;
948 if ((device_id
& LCD2_Device
) && (device_num
< MAX_ACTIVE_DEV_NUM
)) {
949 viafb_LCD2_ON
= STATE_ON
;
951 viafb_DeviceStatus
|= LCD2_Device
;
954 if (viafb_DeviceStatus
== None_Device
) {
955 /* Use CRT as default active device: */
956 viafb_CRT_ON
= STATE_ON
;
957 viafb_DeviceStatus
= CRT_Device
;
959 DEBUG_MSG(KERN_INFO
"Device Status:%x", viafb_DeviceStatus
);
962 static void viafb_set_device(struct device_t active_dev
)
964 /* Check available device to enable: */
965 int device_id
= None_Device
;
967 device_id
|= CRT_Device
;
969 device_id
|= DVI_Device
;
971 device_id
|= LCD_Device
;
973 check_available_device_to_enable(device_id
);
975 /* Check property of LCD: */
977 if (active_dev
.lcd_dsp_cent
) {
978 viaparinfo
->lvds_setting_info
->display_method
=
979 viafb_lcd_dsp_method
= LCD_CENTERING
;
981 viaparinfo
->lvds_setting_info
->display_method
=
982 viafb_lcd_dsp_method
= LCD_EXPANDSION
;
985 if (active_dev
.lcd_mode
== LCD_SPWG
) {
986 viaparinfo
->lvds_setting_info
->lcd_mode
=
987 viafb_lcd_mode
= LCD_SPWG
;
989 viaparinfo
->lvds_setting_info
->lcd_mode
=
990 viafb_lcd_mode
= LCD_OPENLDI
;
993 if (active_dev
.lcd_panel_id
<= LCD_PANEL_ID_MAXIMUM
) {
994 viafb_lcd_panel_id
= active_dev
.lcd_panel_id
;
995 viafb_init_lcd_size();
999 /* Check property of mode: */
1000 if (!active_dev
.xres1
)
1001 viafb_second_xres
= 640;
1003 viafb_second_xres
= active_dev
.xres1
;
1004 if (!active_dev
.yres1
)
1005 viafb_second_yres
= 480;
1007 viafb_second_yres
= active_dev
.yres1
;
1008 if (active_dev
.bpp
!= 0)
1009 viafb_bpp
= active_dev
.bpp
;
1010 if (active_dev
.bpp1
!= 0)
1011 viafb_bpp1
= active_dev
.bpp1
;
1012 if (active_dev
.refresh
!= 0)
1013 viafb_refresh
= active_dev
.refresh
;
1014 if (active_dev
.refresh1
!= 0)
1015 viafb_refresh1
= active_dev
.refresh1
;
1016 if ((active_dev
.samm
== STATE_OFF
) || (active_dev
.samm
== STATE_ON
))
1017 viafb_SAMM_ON
= active_dev
.samm
;
1018 viafb_primary_dev
= active_dev
.primary_dev
;
1020 viafb_set_primary_address(0);
1021 viafb_set_secondary_address(viafb_SAMM_ON
? viafb_second_offset
: 0);
1022 viafb_set_iga_path();
1025 static int get_primary_device(void)
1027 int primary_device
= 0;
1028 /* Rule: device on iga1 path are the primary device. */
1029 if (viafb_SAMM_ON
) {
1031 if (viaparinfo
->crt_setting_info
->iga_path
== IGA1
) {
1032 DEBUG_MSG(KERN_INFO
"CRT IGA Path:%d\n",
1034 crt_setting_info
->iga_path
);
1035 primary_device
= CRT_Device
;
1039 if (viaparinfo
->tmds_setting_info
->iga_path
== IGA1
) {
1040 DEBUG_MSG(KERN_INFO
"DVI IGA Path:%d\n",
1042 tmds_setting_info
->iga_path
);
1043 primary_device
= DVI_Device
;
1047 if (viaparinfo
->lvds_setting_info
->iga_path
== IGA1
) {
1048 DEBUG_MSG(KERN_INFO
"LCD IGA Path:%d\n",
1050 lvds_setting_info
->iga_path
);
1051 primary_device
= LCD_Device
;
1054 if (viafb_LCD2_ON
) {
1055 if (viaparinfo
->lvds_setting_info2
->iga_path
== IGA1
) {
1056 DEBUG_MSG(KERN_INFO
"LCD2 IGA Path:%d\n",
1058 lvds_setting_info2
->iga_path
);
1059 primary_device
= LCD2_Device
;
1063 return primary_device
;
1066 static void apply_second_mode_setting(struct fb_var_screeninfo
1069 u32 htotal
, vtotal
, long_refresh
;
1071 htotal
= sec_var
->xres
+ sec_var
->left_margin
+
1072 sec_var
->right_margin
+ sec_var
->hsync_len
;
1073 vtotal
= sec_var
->yres
+ sec_var
->upper_margin
+
1074 sec_var
->lower_margin
+ sec_var
->vsync_len
;
1075 if ((sec_var
->xres_virtual
* (sec_var
->bits_per_pixel
>> 3)) & 0x1F) {
1076 /*Is 32 bytes alignment? */
1077 /*32 pixel alignment */
1078 sec_var
->xres_virtual
= (sec_var
->xres_virtual
+ 31) & ~31;
1081 htotal
= sec_var
->xres
+ sec_var
->left_margin
+
1082 sec_var
->right_margin
+ sec_var
->hsync_len
;
1083 vtotal
= sec_var
->yres
+ sec_var
->upper_margin
+
1084 sec_var
->lower_margin
+ sec_var
->vsync_len
;
1085 long_refresh
= 1000000000UL / sec_var
->pixclock
* 1000;
1086 long_refresh
/= (htotal
* vtotal
);
1088 viafb_second_xres
= sec_var
->xres
;
1089 viafb_second_yres
= sec_var
->yres
;
1090 viafb_second_virtual_xres
= sec_var
->xres_virtual
;
1091 viafb_second_virtual_yres
= sec_var
->yres_virtual
;
1092 viafb_bpp1
= sec_var
->bits_per_pixel
;
1093 viafb_refresh1
= viafb_get_refresh(sec_var
->xres
, sec_var
->yres
,
1097 static int apply_device_setting(struct viafb_ioctl_setting setting_info
,
1098 struct fb_info
*info
)
1100 int need_set_mode
= 0;
1101 DEBUG_MSG(KERN_INFO
"apply_device_setting\n");
1103 if (setting_info
.device_flag
) {
1105 check_available_device_to_enable(setting_info
.device_status
);
1108 /* Unlock LCD's operation according to LCD flag
1109 and check if the setting value is valid. */
1110 /* If the value is valid, apply the new setting value to the device. */
1112 if (setting_info
.lcd_operation_flag
& OP_LCD_CENTERING
) {
1114 if (setting_info
.lcd_attributes
.display_center
) {
1116 viaparinfo
->lvds_setting_info
->display_method
=
1118 viafb_lcd_dsp_method
= LCD_CENTERING
;
1119 viaparinfo
->lvds_setting_info2
->display_method
=
1120 viafb_lcd_dsp_method
= LCD_CENTERING
;
1123 viaparinfo
->lvds_setting_info
->display_method
=
1125 viafb_lcd_dsp_method
= LCD_EXPANDSION
;
1126 viaparinfo
->lvds_setting_info2
->display_method
=
1128 viafb_lcd_dsp_method
= LCD_EXPANDSION
;
1132 if (setting_info
.lcd_operation_flag
& OP_LCD_MODE
) {
1134 if (setting_info
.lcd_attributes
.lcd_mode
==
1136 viaparinfo
->lvds_setting_info
->lcd_mode
=
1137 viafb_lcd_mode
= LCD_SPWG
;
1139 viaparinfo
->lvds_setting_info
->lcd_mode
=
1140 viafb_lcd_mode
= LCD_OPENLDI
;
1142 viaparinfo
->lvds_setting_info2
->lcd_mode
=
1143 viaparinfo
->lvds_setting_info
->lcd_mode
;
1146 if (setting_info
.lcd_operation_flag
& OP_LCD_PANEL_ID
) {
1148 if (setting_info
.lcd_attributes
.panel_id
<=
1149 LCD_PANEL_ID_MAXIMUM
) {
1150 viafb_lcd_panel_id
=
1151 setting_info
.lcd_attributes
.panel_id
;
1152 viafb_init_lcd_size();
1157 if (0 != (setting_info
.samm_status
& OP_SAMM
)) {
1158 setting_info
.samm_status
=
1159 setting_info
.samm_status
& (~OP_SAMM
);
1160 if (setting_info
.samm_status
== 0
1161 || setting_info
.samm_status
== 1) {
1162 viafb_SAMM_ON
= setting_info
.samm_status
;
1165 viafb_primary_dev
= setting_info
.primary_device
;
1167 viafb_set_primary_address(0);
1168 viafb_set_secondary_address(viafb_SAMM_ON
? viafb_second_offset
: 0);
1169 viafb_set_iga_path();
1174 if (!need_set_mode
) {
1177 viafb_set_iga_path();
1178 viafb_set_par(info
);
1183 static void retrieve_device_setting(struct viafb_ioctl_setting
1187 /* get device status */
1188 if (viafb_CRT_ON
== 1)
1189 setting_info
->device_status
= CRT_Device
;
1190 if (viafb_DVI_ON
== 1)
1191 setting_info
->device_status
|= DVI_Device
;
1192 if (viafb_LCD_ON
== 1)
1193 setting_info
->device_status
|= LCD_Device
;
1194 if (viafb_LCD2_ON
== 1)
1195 setting_info
->device_status
|= LCD2_Device
;
1197 setting_info
->samm_status
= viafb_SAMM_ON
;
1198 setting_info
->primary_device
= get_primary_device();
1200 setting_info
->first_dev_bpp
= viafb_bpp
;
1201 setting_info
->second_dev_bpp
= viafb_bpp1
;
1203 setting_info
->first_dev_refresh
= viafb_refresh
;
1204 setting_info
->second_dev_refresh
= viafb_refresh1
;
1206 setting_info
->first_dev_hor_res
= viafb_hotplug_Xres
;
1207 setting_info
->first_dev_ver_res
= viafb_hotplug_Yres
;
1208 setting_info
->second_dev_hor_res
= viafb_second_xres
;
1209 setting_info
->second_dev_ver_res
= viafb_second_yres
;
1211 /* Get lcd attributes */
1212 setting_info
->lcd_attributes
.display_center
= viafb_lcd_dsp_method
;
1213 setting_info
->lcd_attributes
.panel_id
= viafb_lcd_panel_id
;
1214 setting_info
->lcd_attributes
.lcd_mode
= viafb_lcd_mode
;
1217 static int parse_active_dev(void)
1219 viafb_CRT_ON
= STATE_OFF
;
1220 viafb_DVI_ON
= STATE_OFF
;
1221 viafb_LCD_ON
= STATE_OFF
;
1222 viafb_LCD2_ON
= STATE_OFF
;
1223 /* 1. Modify the active status of devices. */
1224 /* 2. Keep the order of devices, so we can set corresponding
1225 IGA path to devices in SAMM case. */
1226 /* Note: The previous of active_dev is primary device,
1227 and the following is secondary device. */
1228 if (!viafb_active_dev
) {
1229 viafb_CRT_ON
= STATE_ON
;
1230 viafb_SAMM_ON
= STATE_OFF
;
1231 } else if (!strcmp(viafb_active_dev
, "CRT+DVI")) {
1233 viafb_CRT_ON
= STATE_ON
;
1234 viafb_DVI_ON
= STATE_ON
;
1235 viafb_primary_dev
= CRT_Device
;
1236 } else if (!strcmp(viafb_active_dev
, "DVI+CRT")) {
1238 viafb_CRT_ON
= STATE_ON
;
1239 viafb_DVI_ON
= STATE_ON
;
1240 viafb_primary_dev
= DVI_Device
;
1241 } else if (!strcmp(viafb_active_dev
, "CRT+LCD")) {
1243 viafb_CRT_ON
= STATE_ON
;
1244 viafb_LCD_ON
= STATE_ON
;
1245 viafb_primary_dev
= CRT_Device
;
1246 } else if (!strcmp(viafb_active_dev
, "LCD+CRT")) {
1248 viafb_CRT_ON
= STATE_ON
;
1249 viafb_LCD_ON
= STATE_ON
;
1250 viafb_primary_dev
= LCD_Device
;
1251 } else if (!strcmp(viafb_active_dev
, "DVI+LCD")) {
1253 viafb_DVI_ON
= STATE_ON
;
1254 viafb_LCD_ON
= STATE_ON
;
1255 viafb_primary_dev
= DVI_Device
;
1256 } else if (!strcmp(viafb_active_dev
, "LCD+DVI")) {
1258 viafb_DVI_ON
= STATE_ON
;
1259 viafb_LCD_ON
= STATE_ON
;
1260 viafb_primary_dev
= LCD_Device
;
1261 } else if (!strcmp(viafb_active_dev
, "LCD+LCD2")) {
1262 viafb_LCD_ON
= STATE_ON
;
1263 viafb_LCD2_ON
= STATE_ON
;
1264 viafb_primary_dev
= LCD_Device
;
1265 } else if (!strcmp(viafb_active_dev
, "LCD2+LCD")) {
1266 viafb_LCD_ON
= STATE_ON
;
1267 viafb_LCD2_ON
= STATE_ON
;
1268 viafb_primary_dev
= LCD2_Device
;
1269 } else if (!strcmp(viafb_active_dev
, "CRT")) {
1271 viafb_CRT_ON
= STATE_ON
;
1272 viafb_SAMM_ON
= STATE_OFF
;
1273 } else if (!strcmp(viafb_active_dev
, "DVI")) {
1275 viafb_DVI_ON
= STATE_ON
;
1276 viafb_SAMM_ON
= STATE_OFF
;
1277 } else if (!strcmp(viafb_active_dev
, "LCD")) {
1279 viafb_LCD_ON
= STATE_ON
;
1280 viafb_SAMM_ON
= STATE_OFF
;
1287 static int parse_port(char *opt_str
, int *output_interface
)
1289 if (!strncmp(opt_str
, "DVP0", 4))
1290 *output_interface
= INTERFACE_DVP0
;
1291 else if (!strncmp(opt_str
, "DVP1", 4))
1292 *output_interface
= INTERFACE_DVP1
;
1293 else if (!strncmp(opt_str
, "DFP_HIGHLOW", 11))
1294 *output_interface
= INTERFACE_DFP
;
1295 else if (!strncmp(opt_str
, "DFP_HIGH", 8))
1296 *output_interface
= INTERFACE_DFP_HIGH
;
1297 else if (!strncmp(opt_str
, "DFP_LOW", 7))
1298 *output_interface
= INTERFACE_DFP_LOW
;
1300 *output_interface
= INTERFACE_NONE
;
1304 static void parse_lcd_port(void)
1306 parse_port(viafb_lcd_port
, &viaparinfo
->chip_info
->lvds_chip_info
.
1308 /*Initialize to avoid unexpected behavior */
1309 viaparinfo
->chip_info
->lvds_chip_info2
.output_interface
=
1312 DEBUG_MSG(KERN_INFO
"parse_lcd_port: viafb_lcd_port:%s,interface:%d\n",
1313 viafb_lcd_port
, viaparinfo
->chip_info
->lvds_chip_info
.
1317 static void parse_dvi_port(void)
1319 parse_port(viafb_dvi_port
, &viaparinfo
->chip_info
->tmds_chip_info
.
1322 DEBUG_MSG(KERN_INFO
"parse_dvi_port: viafb_dvi_port:%s,interface:%d\n",
1323 viafb_dvi_port
, viaparinfo
->chip_info
->tmds_chip_info
.
1328 * The proc filesystem read/write function, a simple proc implement to
1329 * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
1330 * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2],
1331 * CR9B, SR65, CR97, CR99
1333 static int viafb_dvp0_proc_show(struct seq_file
*m
, void *v
)
1335 u8 dvp0_data_dri
= 0, dvp0_clk_dri
= 0, dvp0
= 0;
1337 (viafb_read_reg(VIASR
, SR2A
) & BIT5
) >> 4 |
1338 (viafb_read_reg(VIASR
, SR1B
) & BIT1
) >> 1;
1340 (viafb_read_reg(VIASR
, SR2A
) & BIT4
) >> 3 |
1341 (viafb_read_reg(VIASR
, SR1E
) & BIT2
) >> 2;
1342 dvp0
= viafb_read_reg(VIACR
, CR96
) & 0x0f;
1343 seq_printf(m
, "%x %x %x\n", dvp0
, dvp0_data_dri
, dvp0_clk_dri
);
1347 static int viafb_dvp0_proc_open(struct inode
*inode
, struct file
*file
)
1349 return single_open(file
, viafb_dvp0_proc_show
, NULL
);
1352 static ssize_t
viafb_dvp0_proc_write(struct file
*file
,
1353 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1355 char buf
[20], *value
, *pbuf
;
1357 unsigned long length
, i
;
1360 length
= count
> 20 ? 20 : count
;
1361 if (copy_from_user(&buf
[0], buffer
, length
))
1363 buf
[length
- 1] = '\0'; /*Ensure end string */
1365 for (i
= 0; i
< 3; i
++) {
1366 value
= strsep(&pbuf
, " ");
1367 if (value
!= NULL
) {
1368 strict_strtoul(value
, 0, (unsigned long *)®_val
);
1369 DEBUG_MSG(KERN_INFO
"DVP0:reg_val[%l]=:%x\n", i
,
1373 viafb_write_reg_mask(CR96
, VIACR
,
1377 viafb_write_reg_mask(SR2A
, VIASR
,
1378 reg_val
<< 4, BIT5
);
1379 viafb_write_reg_mask(SR1B
, VIASR
,
1380 reg_val
<< 1, BIT1
);
1383 viafb_write_reg_mask(SR2A
, VIASR
,
1384 reg_val
<< 3, BIT4
);
1385 viafb_write_reg_mask(SR1E
, VIASR
,
1386 reg_val
<< 2, BIT2
);
1398 static const struct file_operations viafb_dvp0_proc_fops
= {
1399 .owner
= THIS_MODULE
,
1400 .open
= viafb_dvp0_proc_open
,
1402 .llseek
= seq_lseek
,
1403 .release
= single_release
,
1404 .write
= viafb_dvp0_proc_write
,
1407 static int viafb_dvp1_proc_show(struct seq_file
*m
, void *v
)
1409 u8 dvp1
= 0, dvp1_data_dri
= 0, dvp1_clk_dri
= 0;
1410 dvp1
= viafb_read_reg(VIACR
, CR9B
) & 0x0f;
1411 dvp1_data_dri
= (viafb_read_reg(VIASR
, SR65
) & 0x0c) >> 2;
1412 dvp1_clk_dri
= viafb_read_reg(VIASR
, SR65
) & 0x03;
1413 seq_printf(m
, "%x %x %x\n", dvp1
, dvp1_data_dri
, dvp1_clk_dri
);
1417 static int viafb_dvp1_proc_open(struct inode
*inode
, struct file
*file
)
1419 return single_open(file
, viafb_dvp1_proc_show
, NULL
);
1422 static ssize_t
viafb_dvp1_proc_write(struct file
*file
,
1423 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1425 char buf
[20], *value
, *pbuf
;
1427 unsigned long length
, i
;
1430 length
= count
> 20 ? 20 : count
;
1431 if (copy_from_user(&buf
[0], buffer
, length
))
1433 buf
[length
- 1] = '\0'; /*Ensure end string */
1435 for (i
= 0; i
< 3; i
++) {
1436 value
= strsep(&pbuf
, " ");
1437 if (value
!= NULL
) {
1438 strict_strtoul(value
, 0, (unsigned long *)®_val
);
1441 viafb_write_reg_mask(CR9B
, VIACR
,
1445 viafb_write_reg_mask(SR65
, VIASR
,
1446 reg_val
<< 2, 0x0c);
1449 viafb_write_reg_mask(SR65
, VIASR
,
1462 static const struct file_operations viafb_dvp1_proc_fops
= {
1463 .owner
= THIS_MODULE
,
1464 .open
= viafb_dvp1_proc_open
,
1466 .llseek
= seq_lseek
,
1467 .release
= single_release
,
1468 .write
= viafb_dvp1_proc_write
,
1471 static int viafb_dfph_proc_show(struct seq_file
*m
, void *v
)
1474 dfp_high
= viafb_read_reg(VIACR
, CR97
) & 0x0f;
1475 seq_printf(m
, "%x\n", dfp_high
);
1479 static int viafb_dfph_proc_open(struct inode
*inode
, struct file
*file
)
1481 return single_open(file
, viafb_dfph_proc_show
, NULL
);
1484 static ssize_t
viafb_dfph_proc_write(struct file
*file
,
1485 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1489 unsigned long length
;
1492 length
= count
> 20 ? 20 : count
;
1493 if (copy_from_user(&buf
[0], buffer
, length
))
1495 buf
[length
- 1] = '\0'; /*Ensure end string */
1496 strict_strtoul(&buf
[0], 0, (unsigned long *)®_val
);
1497 viafb_write_reg_mask(CR97
, VIACR
, reg_val
, 0x0f);
1501 static const struct file_operations viafb_dfph_proc_fops
= {
1502 .owner
= THIS_MODULE
,
1503 .open
= viafb_dfph_proc_open
,
1505 .llseek
= seq_lseek
,
1506 .release
= single_release
,
1507 .write
= viafb_dfph_proc_write
,
1510 static int viafb_dfpl_proc_show(struct seq_file
*m
, void *v
)
1513 dfp_low
= viafb_read_reg(VIACR
, CR99
) & 0x0f;
1514 seq_printf(m
, "%x\n", dfp_low
);
1518 static int viafb_dfpl_proc_open(struct inode
*inode
, struct file
*file
)
1520 return single_open(file
, viafb_dfpl_proc_show
, NULL
);
1523 static ssize_t
viafb_dfpl_proc_write(struct file
*file
,
1524 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1528 unsigned long length
;
1531 length
= count
> 20 ? 20 : count
;
1532 if (copy_from_user(&buf
[0], buffer
, length
))
1534 buf
[length
- 1] = '\0'; /*Ensure end string */
1535 strict_strtoul(&buf
[0], 0, (unsigned long *)®_val
);
1536 viafb_write_reg_mask(CR99
, VIACR
, reg_val
, 0x0f);
1540 static const struct file_operations viafb_dfpl_proc_fops
= {
1541 .owner
= THIS_MODULE
,
1542 .open
= viafb_dfpl_proc_open
,
1544 .llseek
= seq_lseek
,
1545 .release
= single_release
,
1546 .write
= viafb_dfpl_proc_write
,
1549 static int viafb_vt1636_proc_show(struct seq_file
*m
, void *v
)
1551 u8 vt1636_08
= 0, vt1636_09
= 0;
1552 switch (viaparinfo
->chip_info
->lvds_chip_info
.lvds_chip_name
) {
1555 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info
,
1556 &viaparinfo
->chip_info
->lvds_chip_info
, 0x08) & 0x0f;
1558 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info
,
1559 &viaparinfo
->chip_info
->lvds_chip_info
, 0x09) & 0x1f;
1560 seq_printf(m
, "%x %x\n", vt1636_08
, vt1636_09
);
1565 switch (viaparinfo
->chip_info
->lvds_chip_info2
.lvds_chip_name
) {
1568 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info2
,
1569 &viaparinfo
->chip_info
->lvds_chip_info2
, 0x08) & 0x0f;
1571 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info2
,
1572 &viaparinfo
->chip_info
->lvds_chip_info2
, 0x09) & 0x1f;
1573 seq_printf(m
, " %x %x\n", vt1636_08
, vt1636_09
);
1581 static int viafb_vt1636_proc_open(struct inode
*inode
, struct file
*file
)
1583 return single_open(file
, viafb_vt1636_proc_show
, NULL
);
1586 static ssize_t
viafb_vt1636_proc_write(struct file
*file
,
1587 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1589 char buf
[30], *value
, *pbuf
;
1590 struct IODATA reg_val
;
1591 unsigned long length
, i
;
1594 length
= count
> 30 ? 30 : count
;
1595 if (copy_from_user(&buf
[0], buffer
, length
))
1597 buf
[length
- 1] = '\0'; /*Ensure end string */
1599 switch (viaparinfo
->chip_info
->lvds_chip_info
.lvds_chip_name
) {
1601 for (i
= 0; i
< 2; i
++) {
1602 value
= strsep(&pbuf
, " ");
1603 if (value
!= NULL
) {
1604 strict_strtoul(value
, 0,
1605 (unsigned long *)®_val
.Data
);
1608 reg_val
.Index
= 0x08;
1609 reg_val
.Mask
= 0x0f;
1610 viafb_gpio_i2c_write_mask_lvds
1611 (viaparinfo
->lvds_setting_info
,
1613 chip_info
->lvds_chip_info
,
1617 reg_val
.Index
= 0x09;
1618 reg_val
.Mask
= 0x1f;
1619 viafb_gpio_i2c_write_mask_lvds
1620 (viaparinfo
->lvds_setting_info
,
1622 chip_info
->lvds_chip_info
,
1636 switch (viaparinfo
->chip_info
->lvds_chip_info2
.lvds_chip_name
) {
1638 for (i
= 0; i
< 2; i
++) {
1639 value
= strsep(&pbuf
, " ");
1640 if (value
!= NULL
) {
1641 strict_strtoul(value
, 0,
1642 (unsigned long *)®_val
.Data
);
1645 reg_val
.Index
= 0x08;
1646 reg_val
.Mask
= 0x0f;
1647 viafb_gpio_i2c_write_mask_lvds
1648 (viaparinfo
->lvds_setting_info2
,
1650 chip_info
->lvds_chip_info2
,
1654 reg_val
.Index
= 0x09;
1655 reg_val
.Mask
= 0x1f;
1656 viafb_gpio_i2c_write_mask_lvds
1657 (viaparinfo
->lvds_setting_info2
,
1659 chip_info
->lvds_chip_info2
,
1676 static const struct file_operations viafb_vt1636_proc_fops
= {
1677 .owner
= THIS_MODULE
,
1678 .open
= viafb_vt1636_proc_open
,
1680 .llseek
= seq_lseek
,
1681 .release
= single_release
,
1682 .write
= viafb_vt1636_proc_write
,
1685 static void viafb_init_proc(struct proc_dir_entry
**viafb_entry
)
1687 *viafb_entry
= proc_mkdir("viafb", NULL
);
1689 proc_create("dvp0", 0, *viafb_entry
, &viafb_dvp0_proc_fops
);
1690 proc_create("dvp1", 0, *viafb_entry
, &viafb_dvp1_proc_fops
);
1691 proc_create("dfph", 0, *viafb_entry
, &viafb_dfph_proc_fops
);
1692 proc_create("dfpl", 0, *viafb_entry
, &viafb_dfpl_proc_fops
);
1693 if (VT1636_LVDS
== viaparinfo
->chip_info
->lvds_chip_info
.
1694 lvds_chip_name
|| VT1636_LVDS
==
1695 viaparinfo
->chip_info
->lvds_chip_info2
.lvds_chip_name
) {
1696 proc_create("vt1636", 0, *viafb_entry
, &viafb_vt1636_proc_fops
);
1701 static void viafb_remove_proc(struct proc_dir_entry
*viafb_entry
)
1703 /* no problem if it was not registered */
1704 remove_proc_entry("dvp0", viafb_entry
);/* parent dir */
1705 remove_proc_entry("dvp1", viafb_entry
);
1706 remove_proc_entry("dfph", viafb_entry
);
1707 remove_proc_entry("dfpl", viafb_entry
);
1708 remove_proc_entry("vt1636", viafb_entry
);
1709 remove_proc_entry("vt1625", viafb_entry
);
1710 remove_proc_entry("viafb", NULL
);
1713 static int parse_mode(const char *str
, u32
*xres
, u32
*yres
)
1723 *xres
= simple_strtoul(str
, &ptr
, 10);
1727 *yres
= simple_strtoul(&ptr
[1], &ptr
, 10);
1734 static int __devinit
via_pci_probe(struct pci_dev
*pdev
,
1735 const struct pci_device_id
*ent
)
1737 u32 default_xres
, default_yres
;
1738 struct VideoModeTable
*vmode_entry
;
1739 struct fb_var_screeninfo default_var
;
1741 u32 viafb_par_length
;
1743 DEBUG_MSG(KERN_INFO
"VIAFB PCI Probe!!\n");
1744 memset(&default_var
, 0, sizeof(default_var
));
1745 viafb_par_length
= ALIGN(sizeof(struct viafb_par
), BITS_PER_LONG
/8);
1747 /* Allocate fb_info and ***_par here, also including some other needed
1750 viafbinfo
= framebuffer_alloc(viafb_par_length
+
1751 ALIGN(sizeof(struct viafb_shared
), BITS_PER_LONG
/8),
1754 printk(KERN_ERR
"Could not allocate memory for viafb_info.\n");
1758 viaparinfo
= (struct viafb_par
*)viafbinfo
->par
;
1759 viaparinfo
->shared
= viafbinfo
->par
+ viafb_par_length
;
1760 viaparinfo
->vram_addr
= 0;
1761 viaparinfo
->tmds_setting_info
= &viaparinfo
->shared
->tmds_setting_info
;
1762 viaparinfo
->lvds_setting_info
= &viaparinfo
->shared
->lvds_setting_info
;
1763 viaparinfo
->lvds_setting_info2
=
1764 &viaparinfo
->shared
->lvds_setting_info2
;
1765 viaparinfo
->crt_setting_info
= &viaparinfo
->shared
->crt_setting_info
;
1766 viaparinfo
->chip_info
= &viaparinfo
->shared
->chip_info
;
1773 /* for dual-fb must viafb_SAMM_ON=1 and viafb_dual_fb=1 */
1777 /* Set up I2C bus stuff */
1778 rc
= viafb_create_i2c_bus(viaparinfo
);
1780 goto out_fb_release
;
1782 viafb_init_chip_info(pdev
, ent
);
1783 viaparinfo
->fbmem
= pci_resource_start(pdev
, 0);
1784 viaparinfo
->memsize
= viafb_get_fb_size_from_pci();
1785 if (viaparinfo
->memsize
< 0) {
1786 rc
= viaparinfo
->memsize
;
1787 goto out_delete_i2c
;
1789 viaparinfo
->fbmem_free
= viaparinfo
->memsize
;
1790 viaparinfo
->fbmem_used
= 0;
1791 viafbinfo
->screen_base
= ioremap_nocache(viaparinfo
->fbmem
,
1792 viaparinfo
->memsize
);
1793 if (!viafbinfo
->screen_base
) {
1794 printk(KERN_INFO
"ioremap failed\n");
1796 goto out_delete_i2c
;
1799 viafbinfo
->fix
.mmio_start
= pci_resource_start(pdev
, 1);
1800 viafbinfo
->fix
.mmio_len
= pci_resource_len(pdev
, 1);
1801 viafbinfo
->node
= 0;
1802 viafbinfo
->fbops
= &viafb_ops
;
1803 viafbinfo
->flags
= FBINFO_DEFAULT
| FBINFO_HWACCEL_YPAN
;
1805 viafbinfo
->pseudo_palette
= pseudo_pal
;
1806 if (viafb_accel
&& !viafb_init_engine(viafbinfo
)) {
1807 viafbinfo
->flags
|= FBINFO_HWACCEL_COPYAREA
|
1808 FBINFO_HWACCEL_FILLRECT
| FBINFO_HWACCEL_IMAGEBLIT
;
1809 default_var
.accel_flags
= FB_ACCELF_TEXT
;
1811 viafbinfo
->flags
|= FBINFO_HWACCEL_DISABLED
;
1812 default_var
.accel_flags
= 0;
1815 if (viafb_second_size
&& (viafb_second_size
< 8)) {
1816 viafb_second_offset
= viaparinfo
->fbmem_free
-
1817 viafb_second_size
* 1024 * 1024;
1819 viafb_second_size
= 8;
1820 viafb_second_offset
= viaparinfo
->fbmem_free
-
1821 viafb_second_size
* 1024 * 1024;
1824 parse_mode(viafb_mode
, &default_xres
, &default_yres
);
1825 vmode_entry
= viafb_get_mode(default_xres
, default_yres
);
1826 if (viafb_SAMM_ON
== 1) {
1827 parse_mode(viafb_mode1
, &viafb_second_xres
,
1828 &viafb_second_yres
);
1830 if (0 == viafb_second_virtual_xres
) {
1831 switch (viafb_second_xres
) {
1833 viafb_second_virtual_xres
= 1408;
1836 viafb_second_virtual_xres
= viafb_second_xres
;
1840 if (0 == viafb_second_virtual_yres
)
1841 viafb_second_virtual_yres
= viafb_second_yres
;
1844 default_var
.xres
= default_xres
;
1845 default_var
.yres
= default_yres
;
1846 switch (default_xres
) {
1848 default_var
.xres_virtual
= 1408;
1851 default_var
.xres_virtual
= default_xres
;
1854 default_var
.yres_virtual
= default_yres
;
1855 default_var
.bits_per_pixel
= viafb_bpp
;
1856 default_var
.pixclock
=
1857 viafb_get_pixclock(default_xres
, default_yres
, viafb_refresh
);
1858 default_var
.left_margin
= (default_xres
>> 3) & 0xf8;
1859 default_var
.right_margin
= 32;
1860 default_var
.upper_margin
= 16;
1861 default_var
.lower_margin
= 4;
1862 default_var
.hsync_len
= default_var
.left_margin
;
1863 default_var
.vsync_len
= 4;
1864 viafb_setup_fixinfo(&viafbinfo
->fix
, viaparinfo
);
1865 viafbinfo
->var
= default_var
;
1867 if (viafb_dual_fb
) {
1868 viafbinfo1
= framebuffer_alloc(viafb_par_length
, &pdev
->dev
);
1871 "allocate the second framebuffer struct error\n");
1873 goto out_delete_i2c
;
1875 viaparinfo1
= viafbinfo1
->par
;
1876 memcpy(viaparinfo1
, viaparinfo
, viafb_par_length
);
1877 viaparinfo1
->vram_addr
= viafb_second_offset
;
1878 viaparinfo1
->memsize
= viaparinfo
->memsize
-
1879 viafb_second_offset
;
1880 viaparinfo
->memsize
= viafb_second_offset
;
1881 viaparinfo1
->fbmem
= viaparinfo
->fbmem
+ viafb_second_offset
;
1883 viaparinfo1
->fbmem_used
= viaparinfo
->fbmem_used
;
1884 viaparinfo1
->fbmem_free
= viaparinfo1
->memsize
-
1885 viaparinfo1
->fbmem_used
;
1886 viaparinfo
->fbmem_free
= viaparinfo
->memsize
;
1887 viaparinfo
->fbmem_used
= 0;
1889 viaparinfo
->iga_path
= IGA1
;
1890 viaparinfo1
->iga_path
= IGA2
;
1891 memcpy(viafbinfo1
, viafbinfo
, sizeof(struct fb_info
));
1892 viafbinfo1
->par
= viaparinfo1
;
1893 viafbinfo1
->screen_base
= viafbinfo
->screen_base
+
1894 viafb_second_offset
;
1896 default_var
.xres
= viafb_second_xres
;
1897 default_var
.yres
= viafb_second_yres
;
1898 default_var
.xres_virtual
= viafb_second_virtual_xres
;
1899 default_var
.yres_virtual
= viafb_second_virtual_yres
;
1900 default_var
.bits_per_pixel
= viafb_bpp1
;
1901 default_var
.pixclock
=
1902 viafb_get_pixclock(viafb_second_xres
, viafb_second_yres
,
1904 default_var
.left_margin
= (viafb_second_xres
>> 3) & 0xf8;
1905 default_var
.right_margin
= 32;
1906 default_var
.upper_margin
= 16;
1907 default_var
.lower_margin
= 4;
1908 default_var
.hsync_len
= default_var
.left_margin
;
1909 default_var
.vsync_len
= 4;
1911 viafb_setup_fixinfo(&viafbinfo1
->fix
, viaparinfo1
);
1912 viafb_check_var(&default_var
, viafbinfo1
);
1913 viafbinfo1
->var
= default_var
;
1914 viafb_update_fix(viafbinfo1
);
1915 viaparinfo1
->depth
= fb_get_color_depth(&viafbinfo1
->var
,
1919 viafb_check_var(&viafbinfo
->var
, viafbinfo
);
1920 viafb_update_fix(viafbinfo
);
1921 viaparinfo
->depth
= fb_get_color_depth(&viafbinfo
->var
,
1923 default_var
.activate
= FB_ACTIVATE_NOW
;
1924 rc
= fb_alloc_cmap(&viafbinfo
->cmap
, 256, 0);
1926 goto out_fb1_release
;
1928 if (viafb_dual_fb
&& (viafb_primary_dev
== LCD_Device
)
1929 && (viaparinfo
->chip_info
->gfx_chip_name
== UNICHROME_CLE266
)) {
1930 rc
= register_framebuffer(viafbinfo1
);
1932 goto out_dealloc_cmap
;
1934 rc
= register_framebuffer(viafbinfo
);
1936 goto out_fb1_unreg_lcd_cle266
;
1938 if (viafb_dual_fb
&& ((viafb_primary_dev
!= LCD_Device
)
1939 || (viaparinfo
->chip_info
->gfx_chip_name
!=
1940 UNICHROME_CLE266
))) {
1941 rc
= register_framebuffer(viafbinfo1
);
1945 DEBUG_MSG(KERN_INFO
"fb%d: %s frame buffer device %dx%d-%dbpp\n",
1946 viafbinfo
->node
, viafbinfo
->fix
.id
, default_var
.xres
,
1947 default_var
.yres
, default_var
.bits_per_pixel
);
1949 viafb_init_proc(&viaparinfo
->shared
->proc_entry
);
1950 viafb_init_dac(IGA2
);
1954 unregister_framebuffer(viafbinfo
);
1955 out_fb1_unreg_lcd_cle266
:
1956 if (viafb_dual_fb
&& (viafb_primary_dev
== LCD_Device
)
1957 && (viaparinfo
->chip_info
->gfx_chip_name
== UNICHROME_CLE266
))
1958 unregister_framebuffer(viafbinfo1
);
1960 fb_dealloc_cmap(&viafbinfo
->cmap
);
1963 framebuffer_release(viafbinfo1
);
1965 viafb_delete_i2c_buss(viaparinfo
);
1967 framebuffer_release(viafbinfo
);
1971 static void __devexit
via_pci_remove(struct pci_dev
*pdev
)
1973 DEBUG_MSG(KERN_INFO
"via_pci_remove!\n");
1974 fb_dealloc_cmap(&viafbinfo
->cmap
);
1975 unregister_framebuffer(viafbinfo
);
1977 unregister_framebuffer(viafbinfo1
);
1978 iounmap((void *)viafbinfo
->screen_base
);
1979 iounmap(viaparinfo
->shared
->engine_mmio
);
1981 viafb_delete_i2c_buss(viaparinfo
);
1983 framebuffer_release(viafbinfo
);
1985 framebuffer_release(viafbinfo1
);
1987 viafb_remove_proc(viaparinfo
->shared
->proc_entry
);
1991 static int __init
viafb_setup(char *options
)
1994 DEBUG_MSG(KERN_INFO
"viafb_setup!\n");
1996 if (!options
|| !*options
)
1999 while ((this_opt
= strsep(&options
, ",")) != NULL
) {
2003 if (!strncmp(this_opt
, "viafb_mode1=", 12))
2004 viafb_mode1
= kstrdup(this_opt
+ 12, GFP_KERNEL
);
2005 else if (!strncmp(this_opt
, "viafb_mode=", 11))
2006 viafb_mode
= kstrdup(this_opt
+ 11, GFP_KERNEL
);
2007 else if (!strncmp(this_opt
, "viafb_bpp1=", 11))
2008 strict_strtoul(this_opt
+ 11, 0,
2009 (unsigned long *)&viafb_bpp1
);
2010 else if (!strncmp(this_opt
, "viafb_bpp=", 10))
2011 strict_strtoul(this_opt
+ 10, 0,
2012 (unsigned long *)&viafb_bpp
);
2013 else if (!strncmp(this_opt
, "viafb_refresh1=", 15))
2014 strict_strtoul(this_opt
+ 15, 0,
2015 (unsigned long *)&viafb_refresh1
);
2016 else if (!strncmp(this_opt
, "viafb_refresh=", 14))
2017 strict_strtoul(this_opt
+ 14, 0,
2018 (unsigned long *)&viafb_refresh
);
2019 else if (!strncmp(this_opt
, "viafb_lcd_dsp_method=", 21))
2020 strict_strtoul(this_opt
+ 21, 0,
2021 (unsigned long *)&viafb_lcd_dsp_method
);
2022 else if (!strncmp(this_opt
, "viafb_lcd_panel_id=", 19))
2023 strict_strtoul(this_opt
+ 19, 0,
2024 (unsigned long *)&viafb_lcd_panel_id
);
2025 else if (!strncmp(this_opt
, "viafb_accel=", 12))
2026 strict_strtoul(this_opt
+ 12, 0,
2027 (unsigned long *)&viafb_accel
);
2028 else if (!strncmp(this_opt
, "viafb_SAMM_ON=", 14))
2029 strict_strtoul(this_opt
+ 14, 0,
2030 (unsigned long *)&viafb_SAMM_ON
);
2031 else if (!strncmp(this_opt
, "viafb_active_dev=", 17))
2032 viafb_active_dev
= kstrdup(this_opt
+ 17, GFP_KERNEL
);
2033 else if (!strncmp(this_opt
,
2034 "viafb_display_hardware_layout=", 30))
2035 strict_strtoul(this_opt
+ 30, 0,
2036 (unsigned long *)&viafb_display_hardware_layout
);
2037 else if (!strncmp(this_opt
, "viafb_second_size=", 18))
2038 strict_strtoul(this_opt
+ 18, 0,
2039 (unsigned long *)&viafb_second_size
);
2040 else if (!strncmp(this_opt
,
2041 "viafb_platform_epia_dvi=", 24))
2042 strict_strtoul(this_opt
+ 24, 0,
2043 (unsigned long *)&viafb_platform_epia_dvi
);
2044 else if (!strncmp(this_opt
,
2045 "viafb_device_lcd_dualedge=", 26))
2046 strict_strtoul(this_opt
+ 26, 0,
2047 (unsigned long *)&viafb_device_lcd_dualedge
);
2048 else if (!strncmp(this_opt
, "viafb_bus_width=", 16))
2049 strict_strtoul(this_opt
+ 16, 0,
2050 (unsigned long *)&viafb_bus_width
);
2051 else if (!strncmp(this_opt
, "viafb_lcd_mode=", 15))
2052 strict_strtoul(this_opt
+ 15, 0,
2053 (unsigned long *)&viafb_lcd_mode
);
2054 else if (!strncmp(this_opt
, "viafb_lcd_port=", 15))
2055 viafb_lcd_port
= kstrdup(this_opt
+ 15, GFP_KERNEL
);
2056 else if (!strncmp(this_opt
, "viafb_dvi_port=", 15))
2057 viafb_dvi_port
= kstrdup(this_opt
+ 15, GFP_KERNEL
);
2063 static struct pci_device_id viafb_pci_table
[] __devinitdata
= {
2064 { PCI_DEVICE(PCI_VENDOR_ID_VIA
, UNICHROME_CLE266_DID
),
2065 .driver_data
= UNICHROME_CLE266
},
2066 { PCI_DEVICE(PCI_VENDOR_ID_VIA
, UNICHROME_PM800_DID
),
2067 .driver_data
= UNICHROME_PM800
},
2068 { PCI_DEVICE(PCI_VENDOR_ID_VIA
, UNICHROME_K400_DID
),
2069 .driver_data
= UNICHROME_K400
},
2070 { PCI_DEVICE(PCI_VENDOR_ID_VIA
, UNICHROME_K800_DID
),
2071 .driver_data
= UNICHROME_K800
},
2072 { PCI_DEVICE(PCI_VENDOR_ID_VIA
, UNICHROME_P4M890_DID
),
2073 .driver_data
= UNICHROME_CN700
},
2074 { PCI_DEVICE(PCI_VENDOR_ID_VIA
, UNICHROME_K8M890_DID
),
2075 .driver_data
= UNICHROME_K8M890
},
2076 { PCI_DEVICE(PCI_VENDOR_ID_VIA
, UNICHROME_CX700_DID
),
2077 .driver_data
= UNICHROME_CX700
},
2078 { PCI_DEVICE(PCI_VENDOR_ID_VIA
, UNICHROME_P4M900_DID
),
2079 .driver_data
= UNICHROME_P4M900
},
2080 { PCI_DEVICE(PCI_VENDOR_ID_VIA
, UNICHROME_CN750_DID
),
2081 .driver_data
= UNICHROME_CN750
},
2082 { PCI_DEVICE(PCI_VENDOR_ID_VIA
, UNICHROME_VX800_DID
),
2083 .driver_data
= UNICHROME_VX800
},
2084 { PCI_DEVICE(PCI_VENDOR_ID_VIA
, UNICHROME_VX855_DID
),
2085 .driver_data
= UNICHROME_VX855
},
2088 MODULE_DEVICE_TABLE(pci
, viafb_pci_table
);
2090 static struct pci_driver viafb_driver
= {
2092 .id_table
= viafb_pci_table
,
2093 .probe
= via_pci_probe
,
2094 .remove
= __devexit_p(via_pci_remove
),
2097 static int __init
viafb_init(void)
2101 char *option
= NULL
;
2102 if (fb_get_options("viafb", &option
))
2104 viafb_setup(option
);
2106 if (parse_mode(viafb_mode
, &dummy
, &dummy
)
2107 || parse_mode(viafb_mode1
, &dummy
, &dummy
)
2108 || viafb_bpp
< 0 || viafb_bpp
> 32
2109 || viafb_bpp1
< 0 || viafb_bpp1
> 32
2110 || parse_active_dev())
2114 "VIA Graphics Intergration Chipset framebuffer %d.%d initializing\n",
2115 VERSION_MAJOR
, VERSION_MINOR
);
2116 return pci_register_driver(&viafb_driver
);
2119 static void __exit
viafb_exit(void)
2121 DEBUG_MSG(KERN_INFO
"viafb_exit!\n");
2122 pci_unregister_driver(&viafb_driver
);
2125 static struct fb_ops viafb_ops
= {
2126 .owner
= THIS_MODULE
,
2127 .fb_open
= viafb_open
,
2128 .fb_release
= viafb_release
,
2129 .fb_check_var
= viafb_check_var
,
2130 .fb_set_par
= viafb_set_par
,
2131 .fb_setcolreg
= viafb_setcolreg
,
2132 .fb_pan_display
= viafb_pan_display
,
2133 .fb_blank
= viafb_blank
,
2134 .fb_fillrect
= viafb_fillrect
,
2135 .fb_copyarea
= viafb_copyarea
,
2136 .fb_imageblit
= viafb_imageblit
,
2137 .fb_cursor
= viafb_cursor
,
2138 .fb_ioctl
= viafb_ioctl
,
2139 .fb_sync
= viafb_sync
,
2142 module_init(viafb_init
);
2143 module_exit(viafb_exit
);
2146 module_param(viafb_mode
, charp
, S_IRUSR
);
2147 MODULE_PARM_DESC(viafb_mode
, "Set resolution (default=640x480)");
2149 module_param(viafb_mode1
, charp
, S_IRUSR
);
2150 MODULE_PARM_DESC(viafb_mode1
, "Set resolution (default=640x480)");
2152 module_param(viafb_bpp
, int, S_IRUSR
);
2153 MODULE_PARM_DESC(viafb_bpp
, "Set color depth (default=32bpp)");
2155 module_param(viafb_bpp1
, int, S_IRUSR
);
2156 MODULE_PARM_DESC(viafb_bpp1
, "Set color depth (default=32bpp)");
2158 module_param(viafb_refresh
, int, S_IRUSR
);
2159 MODULE_PARM_DESC(viafb_refresh
,
2160 "Set CRT viafb_refresh rate (default = 60)");
2162 module_param(viafb_refresh1
, int, S_IRUSR
);
2163 MODULE_PARM_DESC(viafb_refresh1
,
2164 "Set CRT refresh rate (default = 60)");
2166 module_param(viafb_lcd_panel_id
, int, S_IRUSR
);
2167 MODULE_PARM_DESC(viafb_lcd_panel_id
,
2168 "Set Flat Panel type(Default=1024x768)");
2170 module_param(viafb_lcd_dsp_method
, int, S_IRUSR
);
2171 MODULE_PARM_DESC(viafb_lcd_dsp_method
,
2172 "Set Flat Panel display scaling method.(Default=Expandsion)");
2174 module_param(viafb_SAMM_ON
, int, S_IRUSR
);
2175 MODULE_PARM_DESC(viafb_SAMM_ON
,
2176 "Turn on/off flag of SAMM(Default=OFF)");
2178 module_param(viafb_accel
, int, S_IRUSR
);
2179 MODULE_PARM_DESC(viafb_accel
,
2180 "Set 2D Hardware Acceleration: 0 = OFF, 1 = ON (default)");
2182 module_param(viafb_active_dev
, charp
, S_IRUSR
);
2183 MODULE_PARM_DESC(viafb_active_dev
, "Specify active devices.");
2185 module_param(viafb_display_hardware_layout
, int, S_IRUSR
);
2186 MODULE_PARM_DESC(viafb_display_hardware_layout
,
2187 "Display Hardware Layout (LCD Only, DVI Only...,etc)");
2189 module_param(viafb_second_size
, int, S_IRUSR
);
2190 MODULE_PARM_DESC(viafb_second_size
,
2191 "Set secondary device memory size");
2193 module_param(viafb_dual_fb
, int, S_IRUSR
);
2194 MODULE_PARM_DESC(viafb_dual_fb
,
2195 "Turn on/off flag of dual framebuffer devices.(Default = OFF)");
2197 module_param(viafb_platform_epia_dvi
, int, S_IRUSR
);
2198 MODULE_PARM_DESC(viafb_platform_epia_dvi
,
2199 "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)");
2201 module_param(viafb_device_lcd_dualedge
, int, S_IRUSR
);
2202 MODULE_PARM_DESC(viafb_device_lcd_dualedge
,
2203 "Turn on/off flag of dual edge panel.(Default = OFF)");
2205 module_param(viafb_bus_width
, int, S_IRUSR
);
2206 MODULE_PARM_DESC(viafb_bus_width
,
2207 "Set bus width of panel.(Default = 12)");
2209 module_param(viafb_lcd_mode
, int, S_IRUSR
);
2210 MODULE_PARM_DESC(viafb_lcd_mode
,
2211 "Set Flat Panel mode(Default=OPENLDI)");
2213 module_param(viafb_lcd_port
, charp
, S_IRUSR
);
2214 MODULE_PARM_DESC(viafb_lcd_port
, "Specify LCD output port.");
2216 module_param(viafb_dvi_port
, charp
, S_IRUSR
);
2217 MODULE_PARM_DESC(viafb_dvi_port
, "Specify DVI output port.");
2219 MODULE_LICENSE("GPL");