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/slab.h>
25 #include <linux/stat.h>
26 #include <linux/via-core.h>
31 static char *viafb_name
= "Via";
32 static u32 pseudo_pal
[17];
35 static char *viafb_mode
;
36 static char *viafb_mode1
;
37 static int viafb_bpp
= 32;
38 static int viafb_bpp1
= 32;
40 static unsigned int viafb_second_offset
;
41 static int viafb_second_size
;
43 static int viafb_accel
= 1;
45 /* Added for specifying active devices.*/
46 static char *viafb_active_dev
;
48 /*Added for specify lcd output port*/
49 static char *viafb_lcd_port
= "";
50 static char *viafb_dvi_port
= "";
52 static void retrieve_device_setting(struct viafb_ioctl_setting
54 static int viafb_pan_display(struct fb_var_screeninfo
*var
,
55 struct fb_info
*info
);
57 static struct fb_ops viafb_ops
;
59 /* supported output devices on each IGP
60 * only CX700, VX800, VX855, VX900 were documented
61 * VIA_CRT should be everywhere
62 * VIA_6C can be onle pre-CX700 (probably only on CLE266) as 6C is used for PLL
63 * source selection on CX700 and later
64 * K400 seems to support VIA_96, VIA_DVP1, VIA_LVDS{1,2} as in viamode.c
66 static const u32 supported_odev_map
[] = {
67 [UNICHROME_CLE266
] = VIA_CRT
| VIA_LDVP0
| VIA_LDVP1
,
68 [UNICHROME_K400
] = VIA_CRT
| VIA_DVP0
| VIA_DVP1
| VIA_LVDS1
70 [UNICHROME_K800
] = VIA_CRT
| VIA_DVP0
| VIA_DVP1
| VIA_LVDS1
72 [UNICHROME_PM800
] = VIA_CRT
| VIA_DVP0
| VIA_DVP1
| VIA_LVDS1
74 [UNICHROME_CN700
] = VIA_CRT
| VIA_DVP0
| VIA_DVP1
| VIA_LVDS1
76 [UNICHROME_CX700
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
77 [UNICHROME_CN750
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
78 [UNICHROME_K8M890
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
79 [UNICHROME_P4M890
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
80 [UNICHROME_P4M900
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
81 [UNICHROME_VX800
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
82 [UNICHROME_VX855
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
83 [UNICHROME_VX900
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
86 static void viafb_fill_var_color_info(struct fb_var_screeninfo
*var
, u8 depth
)
89 var
->red
.msb_right
= 0;
90 var
->green
.msb_right
= 0;
91 var
->blue
.msb_right
= 0;
92 var
->transp
.offset
= 0;
93 var
->transp
.length
= 0;
94 var
->transp
.msb_right
= 0;
98 var
->bits_per_pixel
= 8;
100 var
->green
.offset
= 0;
101 var
->blue
.offset
= 0;
103 var
->green
.length
= 8;
104 var
->blue
.length
= 8;
107 var
->bits_per_pixel
= 16;
108 var
->red
.offset
= 10;
109 var
->green
.offset
= 5;
110 var
->blue
.offset
= 0;
112 var
->green
.length
= 5;
113 var
->blue
.length
= 5;
116 var
->bits_per_pixel
= 16;
117 var
->red
.offset
= 11;
118 var
->green
.offset
= 5;
119 var
->blue
.offset
= 0;
121 var
->green
.length
= 6;
122 var
->blue
.length
= 5;
125 var
->bits_per_pixel
= 32;
126 var
->red
.offset
= 16;
127 var
->green
.offset
= 8;
128 var
->blue
.offset
= 0;
130 var
->green
.length
= 8;
131 var
->blue
.length
= 8;
134 var
->bits_per_pixel
= 32;
135 var
->red
.offset
= 20;
136 var
->green
.offset
= 10;
137 var
->blue
.offset
= 0;
138 var
->red
.length
= 10;
139 var
->green
.length
= 10;
140 var
->blue
.length
= 10;
145 static void viafb_update_fix(struct fb_info
*info
)
147 u32 bpp
= info
->var
.bits_per_pixel
;
150 bpp
== 8 ? FB_VISUAL_PSEUDOCOLOR
: FB_VISUAL_TRUECOLOR
;
151 info
->fix
.line_length
= (info
->var
.xres_virtual
* bpp
/ 8 + 7) & ~7;
154 static void viafb_setup_fixinfo(struct fb_fix_screeninfo
*fix
,
155 struct viafb_par
*viaparinfo
)
157 memset(fix
, 0, sizeof(struct fb_fix_screeninfo
));
158 strcpy(fix
->id
, viafb_name
);
160 fix
->smem_start
= viaparinfo
->fbmem
;
161 fix
->smem_len
= viaparinfo
->fbmem_free
;
163 fix
->type
= FB_TYPE_PACKED_PIXELS
;
165 fix
->visual
= FB_VISUAL_TRUECOLOR
;
167 fix
->xpanstep
= fix
->ywrapstep
= 0;
170 /* Just tell the accel name */
171 viafbinfo
->fix
.accel
= FB_ACCEL_VIA_UNICHROME
;
173 static int viafb_open(struct fb_info
*info
, int user
)
175 DEBUG_MSG(KERN_INFO
"viafb_open!\n");
179 static int viafb_release(struct fb_info
*info
, int user
)
181 DEBUG_MSG(KERN_INFO
"viafb_release!\n");
185 static inline int get_var_refresh(struct fb_var_screeninfo
*var
)
189 htotal
= var
->left_margin
+ var
->xres
+ var
->right_margin
191 vtotal
= var
->upper_margin
+ var
->yres
+ var
->lower_margin
193 return PICOS2KHZ(var
->pixclock
) * 1000 / (htotal
* vtotal
);
196 static int viafb_check_var(struct fb_var_screeninfo
*var
,
197 struct fb_info
*info
)
200 struct VideoModeTable
*vmode_entry
;
201 struct viafb_par
*ppar
= info
->par
;
204 DEBUG_MSG(KERN_INFO
"viafb_check_var!\n");
206 /* HW neither support interlacte nor double-scaned mode */
207 if (var
->vmode
& FB_VMODE_INTERLACED
|| var
->vmode
& FB_VMODE_DOUBLE
)
210 vmode_entry
= viafb_get_mode(var
->xres
, var
->yres
);
213 "viafb: Mode %dx%dx%d not supported!!\n",
214 var
->xres
, var
->yres
, var
->bits_per_pixel
);
218 depth
= fb_get_color_depth(var
, &info
->fix
);
220 depth
= var
->bits_per_pixel
;
222 if (depth
< 0 || depth
> 32)
226 else if (depth
== 15 && viafb_dual_fb
&& ppar
->iga_path
== IGA1
)
228 else if (depth
== 30)
232 else if (depth
<= 16)
237 viafb_fill_var_color_info(var
, depth
);
238 line
= (var
->xres_virtual
* var
->bits_per_pixel
/ 8 + 7) & ~7;
239 if (line
* var
->yres_virtual
> ppar
->memsize
)
242 /* Based on var passed in to calculate the refresh,
243 * because our driver use some modes special.
245 refresh
= viafb_get_refresh(var
->xres
, var
->yres
,
246 get_var_refresh(var
));
248 /* Adjust var according to our driver's own table */
249 viafb_fill_var_timing_info(var
, refresh
, vmode_entry
);
250 if (var
->accel_flags
& FB_ACCELF_TEXT
&&
251 !ppar
->shared
->vdev
->engine_mmio
)
252 var
->accel_flags
= 0;
257 static int viafb_set_par(struct fb_info
*info
)
259 struct viafb_par
*viapar
= info
->par
;
260 struct VideoModeTable
*vmode_entry
, *vmode_entry1
= NULL
;
262 DEBUG_MSG(KERN_INFO
"viafb_set_par!\n");
264 viafb_update_fix(info
);
265 viapar
->depth
= fb_get_color_depth(&info
->var
, &info
->fix
);
266 viafb_update_device_setting(viafbinfo
->var
.xres
, viafbinfo
->var
.yres
,
267 viafbinfo
->var
.bits_per_pixel
, 0);
269 vmode_entry
= viafb_get_mode(viafbinfo
->var
.xres
, viafbinfo
->var
.yres
);
271 vmode_entry1
= viafb_get_mode(viafbinfo1
->var
.xres
,
272 viafbinfo1
->var
.yres
);
273 viafb_update_device_setting(viafbinfo1
->var
.xres
,
274 viafbinfo1
->var
.yres
, viafbinfo1
->var
.bits_per_pixel
,
276 } else if (viafb_SAMM_ON
== 1) {
278 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
279 viafb_second_xres
, viafb_second_yres
, viafb_bpp1
);
280 vmode_entry1
= viafb_get_mode(viafb_second_xres
,
283 viafb_update_device_setting(viafb_second_xres
,
284 viafb_second_yres
, viafb_bpp1
, 1);
287 refresh
= viafb_get_refresh(info
->var
.xres
, info
->var
.yres
,
288 get_var_refresh(&info
->var
));
290 if (viafb_dual_fb
&& viapar
->iga_path
== IGA2
) {
291 viafb_bpp1
= info
->var
.bits_per_pixel
;
292 viafb_refresh1
= refresh
;
294 viafb_bpp
= info
->var
.bits_per_pixel
;
295 viafb_refresh
= refresh
;
298 if (info
->var
.accel_flags
& FB_ACCELF_TEXT
)
299 info
->flags
&= ~FBINFO_HWACCEL_DISABLED
;
301 info
->flags
|= FBINFO_HWACCEL_DISABLED
;
302 viafb_setmode(vmode_entry
, info
->var
.bits_per_pixel
,
303 vmode_entry1
, viafb_bpp1
);
304 viafb_pan_display(&info
->var
, info
);
310 /* Set one color register */
311 static int viafb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
312 unsigned blue
, unsigned transp
, struct fb_info
*info
)
314 struct viafb_par
*viapar
= info
->par
;
317 if (info
->fix
.visual
== FB_VISUAL_PSEUDOCOLOR
) {
321 if (!viafb_dual_fb
|| viapar
->iga_path
== IGA1
)
322 viafb_set_primary_color_register(regno
, red
>> 8,
323 green
>> 8, blue
>> 8);
325 if (!viafb_dual_fb
|| viapar
->iga_path
== IGA2
)
326 viafb_set_secondary_color_register(regno
, red
>> 8,
327 green
>> 8, blue
>> 8);
332 r
= (red
>> (16 - info
->var
.red
.length
))
333 << info
->var
.red
.offset
;
334 b
= (blue
>> (16 - info
->var
.blue
.length
))
335 << info
->var
.blue
.offset
;
336 g
= (green
>> (16 - info
->var
.green
.length
))
337 << info
->var
.green
.offset
;
338 ((u32
*) info
->pseudo_palette
)[regno
] = r
| g
| b
;
344 static int viafb_pan_display(struct fb_var_screeninfo
*var
,
345 struct fb_info
*info
)
347 struct viafb_par
*viapar
= info
->par
;
348 u32 vram_addr
= (var
->yoffset
* var
->xres_virtual
+ var
->xoffset
)
349 * (var
->bits_per_pixel
/ 8) + viapar
->vram_addr
;
351 DEBUG_MSG(KERN_DEBUG
"viafb_pan_display, address = %d\n", vram_addr
);
352 if (!viafb_dual_fb
) {
353 via_set_primary_address(vram_addr
);
354 via_set_secondary_address(vram_addr
);
355 } else if (viapar
->iga_path
== IGA1
)
356 via_set_primary_address(vram_addr
);
358 via_set_secondary_address(vram_addr
);
363 static int viafb_blank(int blank_mode
, struct fb_info
*info
)
365 DEBUG_MSG(KERN_INFO
"viafb_blank!\n");
366 /* clear DPMS setting */
368 switch (blank_mode
) {
369 case FB_BLANK_UNBLANK
:
370 /* Screen: On, HSync: On, VSync: On */
371 /* control CRT monitor power management */
372 via_set_state(VIA_CRT
, VIA_STATE_ON
);
374 case FB_BLANK_HSYNC_SUSPEND
:
375 /* Screen: Off, HSync: Off, VSync: On */
376 /* control CRT monitor power management */
377 via_set_state(VIA_CRT
, VIA_STATE_STANDBY
);
379 case FB_BLANK_VSYNC_SUSPEND
:
380 /* Screen: Off, HSync: On, VSync: Off */
381 /* control CRT monitor power management */
382 via_set_state(VIA_CRT
, VIA_STATE_SUSPEND
);
384 case FB_BLANK_POWERDOWN
:
385 /* Screen: Off, HSync: Off, VSync: Off */
386 /* control CRT monitor power management */
387 via_set_state(VIA_CRT
, VIA_STATE_OFF
);
394 static int viafb_ioctl(struct fb_info
*info
, u_int cmd
, u_long arg
)
397 struct viafb_ioctl_mode viamode
;
398 struct viafb_ioctl_samm viasamm
;
399 struct viafb_driver_version driver_version
;
400 struct fb_var_screeninfo sec_var
;
401 struct _panel_size_pos_info panel_pos_size_para
;
402 struct viafb_ioctl_setting viafb_setting
;
403 struct device_t active_dev
;
406 u32
*viafb_gamma_table
;
407 char driver_name
[] = "viafb";
409 u32 __user
*argp
= (u32 __user
*) arg
;
412 DEBUG_MSG(KERN_INFO
"viafb_ioctl: 0x%X !!\n", cmd
);
413 printk(KERN_WARNING
"viafb_ioctl: Please avoid this interface as it is unstable and might change or vanish at any time!\n");
414 memset(&u
, 0, sizeof(u
));
417 case VIAFB_GET_CHIP_INFO
:
418 if (copy_to_user(argp
, viaparinfo
->chip_info
,
419 sizeof(struct chip_information
)))
422 case VIAFB_GET_INFO_SIZE
:
423 return put_user((u32
)sizeof(struct viafb_ioctl_info
), argp
);
425 return viafb_ioctl_get_viafb_info(arg
);
427 return put_user(viafb_ioctl_hotplug(info
->var
.xres
,
429 info
->var
.bits_per_pixel
), argp
);
430 case VIAFB_SET_HOTPLUG_FLAG
:
431 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
433 viafb_hotplug
= (gpu32
) ? 1 : 0;
435 case VIAFB_GET_RESOLUTION
:
436 u
.viamode
.xres
= (u32
) viafb_hotplug_Xres
;
437 u
.viamode
.yres
= (u32
) viafb_hotplug_Yres
;
438 u
.viamode
.refresh
= (u32
) viafb_hotplug_refresh
;
439 u
.viamode
.bpp
= (u32
) viafb_hotplug_bpp
;
440 if (viafb_SAMM_ON
== 1) {
441 u
.viamode
.xres_sec
= viafb_second_xres
;
442 u
.viamode
.yres_sec
= viafb_second_yres
;
443 u
.viamode
.virtual_xres_sec
= viafb_second_virtual_xres
;
444 u
.viamode
.virtual_yres_sec
= viafb_second_virtual_yres
;
445 u
.viamode
.refresh_sec
= viafb_refresh1
;
446 u
.viamode
.bpp_sec
= viafb_bpp1
;
448 u
.viamode
.xres_sec
= 0;
449 u
.viamode
.yres_sec
= 0;
450 u
.viamode
.virtual_xres_sec
= 0;
451 u
.viamode
.virtual_yres_sec
= 0;
452 u
.viamode
.refresh_sec
= 0;
453 u
.viamode
.bpp_sec
= 0;
455 if (copy_to_user(argp
, &u
.viamode
, sizeof(u
.viamode
)))
458 case VIAFB_GET_SAMM_INFO
:
459 u
.viasamm
.samm_status
= viafb_SAMM_ON
;
461 if (viafb_SAMM_ON
== 1) {
463 u
.viasamm
.size_prim
= viaparinfo
->fbmem_free
;
464 u
.viasamm
.size_sec
= viaparinfo1
->fbmem_free
;
466 if (viafb_second_size
) {
467 u
.viasamm
.size_prim
=
468 viaparinfo
->fbmem_free
-
469 viafb_second_size
* 1024 * 1024;
471 viafb_second_size
* 1024 * 1024;
473 u
.viasamm
.size_prim
=
474 viaparinfo
->fbmem_free
>> 1;
476 (viaparinfo
->fbmem_free
>> 1);
479 u
.viasamm
.mem_base
= viaparinfo
->fbmem
;
480 u
.viasamm
.offset_sec
= viafb_second_offset
;
482 u
.viasamm
.size_prim
=
483 viaparinfo
->memsize
- viaparinfo
->fbmem_used
;
484 u
.viasamm
.size_sec
= 0;
485 u
.viasamm
.mem_base
= viaparinfo
->fbmem
;
486 u
.viasamm
.offset_sec
= 0;
489 if (copy_to_user(argp
, &u
.viasamm
, sizeof(u
.viasamm
)))
493 case VIAFB_TURN_ON_OUTPUT_DEVICE
:
494 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
496 if (gpu32
& CRT_Device
)
497 via_set_state(VIA_CRT
, VIA_STATE_ON
);
498 if (gpu32
& DVI_Device
)
500 if (gpu32
& LCD_Device
)
503 case VIAFB_TURN_OFF_OUTPUT_DEVICE
:
504 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
506 if (gpu32
& CRT_Device
)
507 via_set_state(VIA_CRT
, VIA_STATE_OFF
);
508 if (gpu32
& DVI_Device
)
510 if (gpu32
& LCD_Device
)
513 case VIAFB_GET_DEVICE
:
514 u
.active_dev
.crt
= viafb_CRT_ON
;
515 u
.active_dev
.dvi
= viafb_DVI_ON
;
516 u
.active_dev
.lcd
= viafb_LCD_ON
;
517 u
.active_dev
.samm
= viafb_SAMM_ON
;
518 u
.active_dev
.primary_dev
= viafb_primary_dev
;
520 u
.active_dev
.lcd_dsp_cent
= viafb_lcd_dsp_method
;
521 u
.active_dev
.lcd_panel_id
= viafb_lcd_panel_id
;
522 u
.active_dev
.lcd_mode
= viafb_lcd_mode
;
524 u
.active_dev
.xres
= viafb_hotplug_Xres
;
525 u
.active_dev
.yres
= viafb_hotplug_Yres
;
527 u
.active_dev
.xres1
= viafb_second_xres
;
528 u
.active_dev
.yres1
= viafb_second_yres
;
530 u
.active_dev
.bpp
= viafb_bpp
;
531 u
.active_dev
.bpp1
= viafb_bpp1
;
532 u
.active_dev
.refresh
= viafb_refresh
;
533 u
.active_dev
.refresh1
= viafb_refresh1
;
535 u
.active_dev
.epia_dvi
= viafb_platform_epia_dvi
;
536 u
.active_dev
.lcd_dual_edge
= viafb_device_lcd_dualedge
;
537 u
.active_dev
.bus_width
= viafb_bus_width
;
539 if (copy_to_user(argp
, &u
.active_dev
, sizeof(u
.active_dev
)))
543 case VIAFB_GET_DRIVER_VERSION
:
544 u
.driver_version
.iMajorNum
= VERSION_MAJOR
;
545 u
.driver_version
.iKernelNum
= VERSION_KERNEL
;
546 u
.driver_version
.iOSNum
= VERSION_OS
;
547 u
.driver_version
.iMinorNum
= VERSION_MINOR
;
549 if (copy_to_user(argp
, &u
.driver_version
,
550 sizeof(u
.driver_version
)))
555 case VIAFB_GET_DEVICE_INFO
:
557 retrieve_device_setting(&u
.viafb_setting
);
559 if (copy_to_user(argp
, &u
.viafb_setting
,
560 sizeof(u
.viafb_setting
)))
565 case VIAFB_GET_DEVICE_SUPPORT
:
566 viafb_get_device_support_state(&state_info
);
567 if (put_user(state_info
, argp
))
571 case VIAFB_GET_DEVICE_CONNECT
:
572 viafb_get_device_connect_state(&state_info
);
573 if (put_user(state_info
, argp
))
577 case VIAFB_GET_PANEL_SUPPORT_EXPAND
:
579 viafb_lcd_get_support_expand_state(info
->var
.xres
,
581 if (put_user(state_info
, argp
))
585 case VIAFB_GET_DRIVER_NAME
:
586 if (copy_to_user(argp
, driver_name
, sizeof(driver_name
)))
590 case VIAFB_SET_GAMMA_LUT
:
591 viafb_gamma_table
= memdup_user(argp
, 256 * sizeof(u32
));
592 if (IS_ERR(viafb_gamma_table
))
593 return PTR_ERR(viafb_gamma_table
);
594 viafb_set_gamma_table(viafb_bpp
, viafb_gamma_table
);
595 kfree(viafb_gamma_table
);
598 case VIAFB_GET_GAMMA_LUT
:
599 viafb_gamma_table
= kmalloc(256 * sizeof(u32
), GFP_KERNEL
);
600 if (!viafb_gamma_table
)
602 viafb_get_gamma_table(viafb_gamma_table
);
603 if (copy_to_user(argp
, viafb_gamma_table
,
604 256 * sizeof(u32
))) {
605 kfree(viafb_gamma_table
);
608 kfree(viafb_gamma_table
);
611 case VIAFB_GET_GAMMA_SUPPORT_STATE
:
612 viafb_get_gamma_support_state(viafb_bpp
, &state_info
);
613 if (put_user(state_info
, argp
))
616 case VIAFB_SYNC_SURFACE
:
617 DEBUG_MSG(KERN_INFO
"lobo VIAFB_SYNC_SURFACE\n");
619 case VIAFB_GET_DRIVER_CAPS
:
622 case VIAFB_GET_PANEL_MAX_SIZE
:
623 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
624 sizeof(u
.panel_pos_size_para
)))
626 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
627 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
628 sizeof(u
.panel_pos_size_para
)))
631 case VIAFB_GET_PANEL_MAX_POSITION
:
632 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
633 sizeof(u
.panel_pos_size_para
)))
635 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
636 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
637 sizeof(u
.panel_pos_size_para
)))
641 case VIAFB_GET_PANEL_POSITION
:
642 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
643 sizeof(u
.panel_pos_size_para
)))
645 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
646 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
647 sizeof(u
.panel_pos_size_para
)))
650 case VIAFB_GET_PANEL_SIZE
:
651 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
652 sizeof(u
.panel_pos_size_para
)))
654 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
655 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
656 sizeof(u
.panel_pos_size_para
)))
660 case VIAFB_SET_PANEL_POSITION
:
661 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
662 sizeof(u
.panel_pos_size_para
)))
665 case VIAFB_SET_PANEL_SIZE
:
666 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
667 sizeof(u
.panel_pos_size_para
)))
678 static void viafb_fillrect(struct fb_info
*info
,
679 const struct fb_fillrect
*rect
)
681 struct viafb_par
*viapar
= info
->par
;
682 struct viafb_shared
*shared
= viapar
->shared
;
686 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
) {
687 cfb_fillrect(info
, rect
);
691 if (!rect
->width
|| !rect
->height
)
694 if (info
->fix
.visual
== FB_VISUAL_TRUECOLOR
)
695 fg_color
= ((u32
*)info
->pseudo_palette
)[rect
->color
];
697 fg_color
= rect
->color
;
699 if (rect
->rop
== ROP_XOR
)
704 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: fillrect\n");
705 if (shared
->hw_bitblt(shared
->vdev
->engine_mmio
, VIA_BITBLT_FILL
,
706 rect
->width
, rect
->height
, info
->var
.bits_per_pixel
,
707 viapar
->vram_addr
, info
->fix
.line_length
, rect
->dx
, rect
->dy
,
708 NULL
, 0, 0, 0, 0, fg_color
, 0, rop
))
709 cfb_fillrect(info
, rect
);
712 static void viafb_copyarea(struct fb_info
*info
,
713 const struct fb_copyarea
*area
)
715 struct viafb_par
*viapar
= info
->par
;
716 struct viafb_shared
*shared
= viapar
->shared
;
718 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
) {
719 cfb_copyarea(info
, area
);
723 if (!area
->width
|| !area
->height
)
726 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: copyarea\n");
727 if (shared
->hw_bitblt(shared
->vdev
->engine_mmio
, VIA_BITBLT_COLOR
,
728 area
->width
, area
->height
, info
->var
.bits_per_pixel
,
729 viapar
->vram_addr
, info
->fix
.line_length
, area
->dx
, area
->dy
,
730 NULL
, viapar
->vram_addr
, info
->fix
.line_length
,
731 area
->sx
, area
->sy
, 0, 0, 0))
732 cfb_copyarea(info
, area
);
735 static void viafb_imageblit(struct fb_info
*info
,
736 const struct fb_image
*image
)
738 struct viafb_par
*viapar
= info
->par
;
739 struct viafb_shared
*shared
= viapar
->shared
;
740 u32 fg_color
= 0, bg_color
= 0;
743 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
||
744 (image
->depth
!= 1 && image
->depth
!= viapar
->depth
)) {
745 cfb_imageblit(info
, image
);
749 if (image
->depth
== 1) {
750 op
= VIA_BITBLT_MONO
;
751 if (info
->fix
.visual
== FB_VISUAL_TRUECOLOR
) {
753 ((u32
*)info
->pseudo_palette
)[image
->fg_color
];
755 ((u32
*)info
->pseudo_palette
)[image
->bg_color
];
757 fg_color
= image
->fg_color
;
758 bg_color
= image
->bg_color
;
761 op
= VIA_BITBLT_COLOR
;
763 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: imageblit\n");
764 if (shared
->hw_bitblt(shared
->vdev
->engine_mmio
, op
,
765 image
->width
, image
->height
, info
->var
.bits_per_pixel
,
766 viapar
->vram_addr
, info
->fix
.line_length
, image
->dx
, image
->dy
,
767 (u32
*)image
->data
, 0, 0, 0, 0, fg_color
, bg_color
, 0))
768 cfb_imageblit(info
, image
);
771 static int viafb_cursor(struct fb_info
*info
, struct fb_cursor
*cursor
)
773 struct viafb_par
*viapar
= info
->par
;
774 void __iomem
*engine
= viapar
->shared
->vdev
->engine_mmio
;
775 u32 temp
, xx
, yy
, bg_color
= 0, fg_color
= 0,
776 chip_name
= viapar
->shared
->chip_info
.gfx_chip_name
;
777 int i
, j
= 0, cur_size
= 64;
779 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| info
!= viafbinfo
)
782 /* LCD ouput does not support hw cursors (at least on VN896) */
783 if ((chip_name
== UNICHROME_CLE266
&& viapar
->iga_path
== IGA2
) ||
787 viafb_show_hw_cursor(info
, HW_Cursor_OFF
);
789 if (cursor
->set
& FB_CUR_SETHOT
) {
790 temp
= (cursor
->hot
.x
<< 16) + cursor
->hot
.y
;
791 writel(temp
, engine
+ VIA_REG_CURSOR_ORG
);
794 if (cursor
->set
& FB_CUR_SETPOS
) {
795 yy
= cursor
->image
.dy
- info
->var
.yoffset
;
796 xx
= cursor
->image
.dx
- info
->var
.xoffset
;
799 writel(temp
, engine
+ VIA_REG_CURSOR_POS
);
802 if (cursor
->image
.width
<= 32 && cursor
->image
.height
<= 32)
804 else if (cursor
->image
.width
<= 64 && cursor
->image
.height
<= 64)
807 printk(KERN_WARNING
"viafb_cursor: The cursor is too large "
808 "%dx%d", cursor
->image
.width
, cursor
->image
.height
);
812 if (cursor
->set
& FB_CUR_SETSIZE
) {
813 temp
= readl(engine
+ VIA_REG_CURSOR_MODE
);
819 writel(temp
, engine
+ VIA_REG_CURSOR_MODE
);
822 if (cursor
->set
& FB_CUR_SETCMAP
) {
823 fg_color
= cursor
->image
.fg_color
;
824 bg_color
= cursor
->image
.bg_color
;
825 if (chip_name
== UNICHROME_CX700
||
826 chip_name
== UNICHROME_VX800
||
827 chip_name
== UNICHROME_VX855
||
828 chip_name
== UNICHROME_VX900
) {
830 ((info
->cmap
.red
[fg_color
] & 0xFFC0) << 14) |
831 ((info
->cmap
.green
[fg_color
] & 0xFFC0) << 4) |
832 ((info
->cmap
.blue
[fg_color
] & 0xFFC0) >> 6);
834 ((info
->cmap
.red
[bg_color
] & 0xFFC0) << 14) |
835 ((info
->cmap
.green
[bg_color
] & 0xFFC0) << 4) |
836 ((info
->cmap
.blue
[bg_color
] & 0xFFC0) >> 6);
839 ((info
->cmap
.red
[fg_color
] & 0xFF00) << 8) |
840 (info
->cmap
.green
[fg_color
] & 0xFF00) |
841 ((info
->cmap
.blue
[fg_color
] & 0xFF00) >> 8);
843 ((info
->cmap
.red
[bg_color
] & 0xFF00) << 8) |
844 (info
->cmap
.green
[bg_color
] & 0xFF00) |
845 ((info
->cmap
.blue
[bg_color
] & 0xFF00) >> 8);
848 writel(bg_color
, engine
+ VIA_REG_CURSOR_BG
);
849 writel(fg_color
, engine
+ VIA_REG_CURSOR_FG
);
852 if (cursor
->set
& FB_CUR_SETSHAPE
) {
854 u8 data
[CURSOR_SIZE
];
855 u32 bak
[CURSOR_SIZE
/ 4];
856 } *cr_data
= kzalloc(sizeof(*cr_data
), GFP_ATOMIC
);
857 int size
= ((cursor
->image
.width
+ 7) >> 3) *
858 cursor
->image
.height
;
863 if (cur_size
== 32) {
864 for (i
= 0; i
< (CURSOR_SIZE
/ 4); i
++) {
865 cr_data
->bak
[i
] = 0x0;
866 cr_data
->bak
[i
+ 1] = 0xFFFFFFFF;
870 for (i
= 0; i
< (CURSOR_SIZE
/ 4); i
++) {
871 cr_data
->bak
[i
] = 0x0;
872 cr_data
->bak
[i
+ 1] = 0x0;
873 cr_data
->bak
[i
+ 2] = 0xFFFFFFFF;
874 cr_data
->bak
[i
+ 3] = 0xFFFFFFFF;
879 switch (cursor
->rop
) {
881 for (i
= 0; i
< size
; i
++)
882 cr_data
->data
[i
] = cursor
->mask
[i
];
886 for (i
= 0; i
< size
; i
++)
887 cr_data
->data
[i
] = cursor
->mask
[i
];
893 if (cur_size
== 32) {
894 for (i
= 0; i
< size
; i
++) {
895 cr_data
->bak
[j
] = (u32
) cr_data
->data
[i
];
896 cr_data
->bak
[j
+ 1] = ~cr_data
->bak
[j
];
900 for (i
= 0; i
< size
; i
++) {
901 cr_data
->bak
[j
] = (u32
) cr_data
->data
[i
];
902 cr_data
->bak
[j
+ 1] = 0x0;
903 cr_data
->bak
[j
+ 2] = ~cr_data
->bak
[j
];
904 cr_data
->bak
[j
+ 3] = ~cr_data
->bak
[j
+ 1];
909 memcpy_toio(viafbinfo
->screen_base
+ viapar
->shared
->
910 cursor_vram_addr
, cr_data
->bak
, CURSOR_SIZE
);
915 viafb_show_hw_cursor(info
, HW_Cursor_ON
);
920 static int viafb_sync(struct fb_info
*info
)
922 if (!(info
->flags
& FBINFO_HWACCEL_DISABLED
))
923 viafb_wait_engine_idle(info
);
927 static int get_primary_device(void)
929 int primary_device
= 0;
930 /* Rule: device on iga1 path are the primary device. */
933 if (viaparinfo
->crt_setting_info
->iga_path
== IGA1
) {
934 DEBUG_MSG(KERN_INFO
"CRT IGA Path:%d\n",
936 crt_setting_info
->iga_path
);
937 primary_device
= CRT_Device
;
941 if (viaparinfo
->tmds_setting_info
->iga_path
== IGA1
) {
942 DEBUG_MSG(KERN_INFO
"DVI IGA Path:%d\n",
944 tmds_setting_info
->iga_path
);
945 primary_device
= DVI_Device
;
949 if (viaparinfo
->lvds_setting_info
->iga_path
== IGA1
) {
950 DEBUG_MSG(KERN_INFO
"LCD IGA Path:%d\n",
952 lvds_setting_info
->iga_path
);
953 primary_device
= LCD_Device
;
957 if (viaparinfo
->lvds_setting_info2
->iga_path
== IGA1
) {
958 DEBUG_MSG(KERN_INFO
"LCD2 IGA Path:%d\n",
960 lvds_setting_info2
->iga_path
);
961 primary_device
= LCD2_Device
;
965 return primary_device
;
968 static void retrieve_device_setting(struct viafb_ioctl_setting
972 /* get device status */
973 if (viafb_CRT_ON
== 1)
974 setting_info
->device_status
= CRT_Device
;
975 if (viafb_DVI_ON
== 1)
976 setting_info
->device_status
|= DVI_Device
;
977 if (viafb_LCD_ON
== 1)
978 setting_info
->device_status
|= LCD_Device
;
979 if (viafb_LCD2_ON
== 1)
980 setting_info
->device_status
|= LCD2_Device
;
982 setting_info
->samm_status
= viafb_SAMM_ON
;
983 setting_info
->primary_device
= get_primary_device();
985 setting_info
->first_dev_bpp
= viafb_bpp
;
986 setting_info
->second_dev_bpp
= viafb_bpp1
;
988 setting_info
->first_dev_refresh
= viafb_refresh
;
989 setting_info
->second_dev_refresh
= viafb_refresh1
;
991 setting_info
->first_dev_hor_res
= viafb_hotplug_Xres
;
992 setting_info
->first_dev_ver_res
= viafb_hotplug_Yres
;
993 setting_info
->second_dev_hor_res
= viafb_second_xres
;
994 setting_info
->second_dev_ver_res
= viafb_second_yres
;
996 /* Get lcd attributes */
997 setting_info
->lcd_attributes
.display_center
= viafb_lcd_dsp_method
;
998 setting_info
->lcd_attributes
.panel_id
= viafb_lcd_panel_id
;
999 setting_info
->lcd_attributes
.lcd_mode
= viafb_lcd_mode
;
1002 static int __init
parse_active_dev(void)
1004 viafb_CRT_ON
= STATE_OFF
;
1005 viafb_DVI_ON
= STATE_OFF
;
1006 viafb_LCD_ON
= STATE_OFF
;
1007 viafb_LCD2_ON
= STATE_OFF
;
1008 /* 1. Modify the active status of devices. */
1009 /* 2. Keep the order of devices, so we can set corresponding
1010 IGA path to devices in SAMM case. */
1011 /* Note: The previous of active_dev is primary device,
1012 and the following is secondary device. */
1013 if (!viafb_active_dev
) {
1014 viafb_CRT_ON
= STATE_ON
;
1015 viafb_SAMM_ON
= STATE_OFF
;
1016 } else if (!strcmp(viafb_active_dev
, "CRT+DVI")) {
1018 viafb_CRT_ON
= STATE_ON
;
1019 viafb_DVI_ON
= STATE_ON
;
1020 viafb_primary_dev
= CRT_Device
;
1021 } else if (!strcmp(viafb_active_dev
, "DVI+CRT")) {
1023 viafb_CRT_ON
= STATE_ON
;
1024 viafb_DVI_ON
= STATE_ON
;
1025 viafb_primary_dev
= DVI_Device
;
1026 } else if (!strcmp(viafb_active_dev
, "CRT+LCD")) {
1028 viafb_CRT_ON
= STATE_ON
;
1029 viafb_LCD_ON
= STATE_ON
;
1030 viafb_primary_dev
= CRT_Device
;
1031 } else if (!strcmp(viafb_active_dev
, "LCD+CRT")) {
1033 viafb_CRT_ON
= STATE_ON
;
1034 viafb_LCD_ON
= STATE_ON
;
1035 viafb_primary_dev
= LCD_Device
;
1036 } else if (!strcmp(viafb_active_dev
, "DVI+LCD")) {
1038 viafb_DVI_ON
= STATE_ON
;
1039 viafb_LCD_ON
= STATE_ON
;
1040 viafb_primary_dev
= DVI_Device
;
1041 } else if (!strcmp(viafb_active_dev
, "LCD+DVI")) {
1043 viafb_DVI_ON
= STATE_ON
;
1044 viafb_LCD_ON
= STATE_ON
;
1045 viafb_primary_dev
= LCD_Device
;
1046 } else if (!strcmp(viafb_active_dev
, "LCD+LCD2")) {
1047 viafb_LCD_ON
= STATE_ON
;
1048 viafb_LCD2_ON
= STATE_ON
;
1049 viafb_primary_dev
= LCD_Device
;
1050 } else if (!strcmp(viafb_active_dev
, "LCD2+LCD")) {
1051 viafb_LCD_ON
= STATE_ON
;
1052 viafb_LCD2_ON
= STATE_ON
;
1053 viafb_primary_dev
= LCD2_Device
;
1054 } else if (!strcmp(viafb_active_dev
, "CRT")) {
1056 viafb_CRT_ON
= STATE_ON
;
1057 viafb_SAMM_ON
= STATE_OFF
;
1058 } else if (!strcmp(viafb_active_dev
, "DVI")) {
1060 viafb_DVI_ON
= STATE_ON
;
1061 viafb_SAMM_ON
= STATE_OFF
;
1062 } else if (!strcmp(viafb_active_dev
, "LCD")) {
1064 viafb_LCD_ON
= STATE_ON
;
1065 viafb_SAMM_ON
= STATE_OFF
;
1072 static int __devinit
parse_port(char *opt_str
, int *output_interface
)
1074 if (!strncmp(opt_str
, "DVP0", 4))
1075 *output_interface
= INTERFACE_DVP0
;
1076 else if (!strncmp(opt_str
, "DVP1", 4))
1077 *output_interface
= INTERFACE_DVP1
;
1078 else if (!strncmp(opt_str
, "DFP_HIGHLOW", 11))
1079 *output_interface
= INTERFACE_DFP
;
1080 else if (!strncmp(opt_str
, "DFP_HIGH", 8))
1081 *output_interface
= INTERFACE_DFP_HIGH
;
1082 else if (!strncmp(opt_str
, "DFP_LOW", 7))
1083 *output_interface
= INTERFACE_DFP_LOW
;
1085 *output_interface
= INTERFACE_NONE
;
1089 static void __devinit
parse_lcd_port(void)
1091 parse_port(viafb_lcd_port
, &viaparinfo
->chip_info
->lvds_chip_info
.
1093 /*Initialize to avoid unexpected behavior */
1094 viaparinfo
->chip_info
->lvds_chip_info2
.output_interface
=
1097 DEBUG_MSG(KERN_INFO
"parse_lcd_port: viafb_lcd_port:%s,interface:%d\n",
1098 viafb_lcd_port
, viaparinfo
->chip_info
->lvds_chip_info
.
1102 static void __devinit
parse_dvi_port(void)
1104 parse_port(viafb_dvi_port
, &viaparinfo
->chip_info
->tmds_chip_info
.
1107 DEBUG_MSG(KERN_INFO
"parse_dvi_port: viafb_dvi_port:%s,interface:%d\n",
1108 viafb_dvi_port
, viaparinfo
->chip_info
->tmds_chip_info
.
1112 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1115 * The proc filesystem read/write function, a simple proc implement to
1116 * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
1117 * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2],
1118 * CR9B, SR65, CR97, CR99
1120 static int viafb_dvp0_proc_show(struct seq_file
*m
, void *v
)
1122 u8 dvp0_data_dri
= 0, dvp0_clk_dri
= 0, dvp0
= 0;
1124 (viafb_read_reg(VIASR
, SR2A
) & BIT5
) >> 4 |
1125 (viafb_read_reg(VIASR
, SR1B
) & BIT1
) >> 1;
1127 (viafb_read_reg(VIASR
, SR2A
) & BIT4
) >> 3 |
1128 (viafb_read_reg(VIASR
, SR1E
) & BIT2
) >> 2;
1129 dvp0
= viafb_read_reg(VIACR
, CR96
) & 0x0f;
1130 seq_printf(m
, "%x %x %x\n", dvp0
, dvp0_data_dri
, dvp0_clk_dri
);
1134 static int viafb_dvp0_proc_open(struct inode
*inode
, struct file
*file
)
1136 return single_open(file
, viafb_dvp0_proc_show
, NULL
);
1139 static ssize_t
viafb_dvp0_proc_write(struct file
*file
,
1140 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1142 char buf
[20], *value
, *pbuf
;
1144 unsigned long length
, i
;
1147 length
= count
> 20 ? 20 : count
;
1148 if (copy_from_user(&buf
[0], buffer
, length
))
1150 buf
[length
- 1] = '\0'; /*Ensure end string */
1152 for (i
= 0; i
< 3; i
++) {
1153 value
= strsep(&pbuf
, " ");
1154 if (value
!= NULL
) {
1155 strict_strtoul(value
, 0, (unsigned long *)®_val
);
1156 DEBUG_MSG(KERN_INFO
"DVP0:reg_val[%l]=:%x\n", i
,
1160 viafb_write_reg_mask(CR96
, VIACR
,
1164 viafb_write_reg_mask(SR2A
, VIASR
,
1165 reg_val
<< 4, BIT5
);
1166 viafb_write_reg_mask(SR1B
, VIASR
,
1167 reg_val
<< 1, BIT1
);
1170 viafb_write_reg_mask(SR2A
, VIASR
,
1171 reg_val
<< 3, BIT4
);
1172 viafb_write_reg_mask(SR1E
, VIASR
,
1173 reg_val
<< 2, BIT2
);
1185 static const struct file_operations viafb_dvp0_proc_fops
= {
1186 .owner
= THIS_MODULE
,
1187 .open
= viafb_dvp0_proc_open
,
1189 .llseek
= seq_lseek
,
1190 .release
= single_release
,
1191 .write
= viafb_dvp0_proc_write
,
1194 static int viafb_dvp1_proc_show(struct seq_file
*m
, void *v
)
1196 u8 dvp1
= 0, dvp1_data_dri
= 0, dvp1_clk_dri
= 0;
1197 dvp1
= viafb_read_reg(VIACR
, CR9B
) & 0x0f;
1198 dvp1_data_dri
= (viafb_read_reg(VIASR
, SR65
) & 0x0c) >> 2;
1199 dvp1_clk_dri
= viafb_read_reg(VIASR
, SR65
) & 0x03;
1200 seq_printf(m
, "%x %x %x\n", dvp1
, dvp1_data_dri
, dvp1_clk_dri
);
1204 static int viafb_dvp1_proc_open(struct inode
*inode
, struct file
*file
)
1206 return single_open(file
, viafb_dvp1_proc_show
, NULL
);
1209 static ssize_t
viafb_dvp1_proc_write(struct file
*file
,
1210 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1212 char buf
[20], *value
, *pbuf
;
1214 unsigned long length
, i
;
1217 length
= count
> 20 ? 20 : count
;
1218 if (copy_from_user(&buf
[0], buffer
, length
))
1220 buf
[length
- 1] = '\0'; /*Ensure end string */
1222 for (i
= 0; i
< 3; i
++) {
1223 value
= strsep(&pbuf
, " ");
1224 if (value
!= NULL
) {
1225 strict_strtoul(value
, 0, (unsigned long *)®_val
);
1228 viafb_write_reg_mask(CR9B
, VIACR
,
1232 viafb_write_reg_mask(SR65
, VIASR
,
1233 reg_val
<< 2, 0x0c);
1236 viafb_write_reg_mask(SR65
, VIASR
,
1249 static const struct file_operations viafb_dvp1_proc_fops
= {
1250 .owner
= THIS_MODULE
,
1251 .open
= viafb_dvp1_proc_open
,
1253 .llseek
= seq_lseek
,
1254 .release
= single_release
,
1255 .write
= viafb_dvp1_proc_write
,
1258 static int viafb_dfph_proc_show(struct seq_file
*m
, void *v
)
1261 dfp_high
= viafb_read_reg(VIACR
, CR97
) & 0x0f;
1262 seq_printf(m
, "%x\n", dfp_high
);
1266 static int viafb_dfph_proc_open(struct inode
*inode
, struct file
*file
)
1268 return single_open(file
, viafb_dfph_proc_show
, NULL
);
1271 static ssize_t
viafb_dfph_proc_write(struct file
*file
,
1272 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1276 unsigned long length
;
1279 length
= count
> 20 ? 20 : count
;
1280 if (copy_from_user(&buf
[0], buffer
, length
))
1282 buf
[length
- 1] = '\0'; /*Ensure end string */
1283 strict_strtoul(&buf
[0], 0, (unsigned long *)®_val
);
1284 viafb_write_reg_mask(CR97
, VIACR
, reg_val
, 0x0f);
1288 static const struct file_operations viafb_dfph_proc_fops
= {
1289 .owner
= THIS_MODULE
,
1290 .open
= viafb_dfph_proc_open
,
1292 .llseek
= seq_lseek
,
1293 .release
= single_release
,
1294 .write
= viafb_dfph_proc_write
,
1297 static int viafb_dfpl_proc_show(struct seq_file
*m
, void *v
)
1300 dfp_low
= viafb_read_reg(VIACR
, CR99
) & 0x0f;
1301 seq_printf(m
, "%x\n", dfp_low
);
1305 static int viafb_dfpl_proc_open(struct inode
*inode
, struct file
*file
)
1307 return single_open(file
, viafb_dfpl_proc_show
, NULL
);
1310 static ssize_t
viafb_dfpl_proc_write(struct file
*file
,
1311 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1315 unsigned long length
;
1318 length
= count
> 20 ? 20 : count
;
1319 if (copy_from_user(&buf
[0], buffer
, length
))
1321 buf
[length
- 1] = '\0'; /*Ensure end string */
1322 strict_strtoul(&buf
[0], 0, (unsigned long *)®_val
);
1323 viafb_write_reg_mask(CR99
, VIACR
, reg_val
, 0x0f);
1327 static const struct file_operations viafb_dfpl_proc_fops
= {
1328 .owner
= THIS_MODULE
,
1329 .open
= viafb_dfpl_proc_open
,
1331 .llseek
= seq_lseek
,
1332 .release
= single_release
,
1333 .write
= viafb_dfpl_proc_write
,
1336 static int viafb_vt1636_proc_show(struct seq_file
*m
, void *v
)
1338 u8 vt1636_08
= 0, vt1636_09
= 0;
1339 switch (viaparinfo
->chip_info
->lvds_chip_info
.lvds_chip_name
) {
1342 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info
,
1343 &viaparinfo
->chip_info
->lvds_chip_info
, 0x08) & 0x0f;
1345 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info
,
1346 &viaparinfo
->chip_info
->lvds_chip_info
, 0x09) & 0x1f;
1347 seq_printf(m
, "%x %x\n", vt1636_08
, vt1636_09
);
1352 switch (viaparinfo
->chip_info
->lvds_chip_info2
.lvds_chip_name
) {
1355 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info2
,
1356 &viaparinfo
->chip_info
->lvds_chip_info2
, 0x08) & 0x0f;
1358 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info2
,
1359 &viaparinfo
->chip_info
->lvds_chip_info2
, 0x09) & 0x1f;
1360 seq_printf(m
, " %x %x\n", vt1636_08
, vt1636_09
);
1368 static int viafb_vt1636_proc_open(struct inode
*inode
, struct file
*file
)
1370 return single_open(file
, viafb_vt1636_proc_show
, NULL
);
1373 static ssize_t
viafb_vt1636_proc_write(struct file
*file
,
1374 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1376 char buf
[30], *value
, *pbuf
;
1377 struct IODATA reg_val
;
1378 unsigned long length
, i
;
1381 length
= count
> 30 ? 30 : count
;
1382 if (copy_from_user(&buf
[0], buffer
, length
))
1384 buf
[length
- 1] = '\0'; /*Ensure end string */
1386 switch (viaparinfo
->chip_info
->lvds_chip_info
.lvds_chip_name
) {
1388 for (i
= 0; i
< 2; i
++) {
1389 value
= strsep(&pbuf
, " ");
1390 if (value
!= NULL
) {
1391 strict_strtoul(value
, 0,
1392 (unsigned long *)®_val
.Data
);
1395 reg_val
.Index
= 0x08;
1396 reg_val
.Mask
= 0x0f;
1397 viafb_gpio_i2c_write_mask_lvds
1398 (viaparinfo
->lvds_setting_info
,
1400 chip_info
->lvds_chip_info
,
1404 reg_val
.Index
= 0x09;
1405 reg_val
.Mask
= 0x1f;
1406 viafb_gpio_i2c_write_mask_lvds
1407 (viaparinfo
->lvds_setting_info
,
1409 chip_info
->lvds_chip_info
,
1423 switch (viaparinfo
->chip_info
->lvds_chip_info2
.lvds_chip_name
) {
1425 for (i
= 0; i
< 2; i
++) {
1426 value
= strsep(&pbuf
, " ");
1427 if (value
!= NULL
) {
1428 strict_strtoul(value
, 0,
1429 (unsigned long *)®_val
.Data
);
1432 reg_val
.Index
= 0x08;
1433 reg_val
.Mask
= 0x0f;
1434 viafb_gpio_i2c_write_mask_lvds
1435 (viaparinfo
->lvds_setting_info2
,
1437 chip_info
->lvds_chip_info2
,
1441 reg_val
.Index
= 0x09;
1442 reg_val
.Mask
= 0x1f;
1443 viafb_gpio_i2c_write_mask_lvds
1444 (viaparinfo
->lvds_setting_info2
,
1446 chip_info
->lvds_chip_info2
,
1463 static const struct file_operations viafb_vt1636_proc_fops
= {
1464 .owner
= THIS_MODULE
,
1465 .open
= viafb_vt1636_proc_open
,
1467 .llseek
= seq_lseek
,
1468 .release
= single_release
,
1469 .write
= viafb_vt1636_proc_write
,
1472 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
1474 static int viafb_sup_odev_proc_show(struct seq_file
*m
, void *v
)
1476 via_odev_to_seq(m
, supported_odev_map
[
1477 viaparinfo
->shared
->chip_info
.gfx_chip_name
]);
1481 static int viafb_sup_odev_proc_open(struct inode
*inode
, struct file
*file
)
1483 return single_open(file
, viafb_sup_odev_proc_show
, NULL
);
1486 static const struct file_operations viafb_sup_odev_proc_fops
= {
1487 .owner
= THIS_MODULE
,
1488 .open
= viafb_sup_odev_proc_open
,
1490 .llseek
= seq_lseek
,
1491 .release
= single_release
,
1494 static ssize_t
odev_update(const char __user
*buffer
, size_t count
, u32
*odev
)
1496 char buf
[64], *ptr
= buf
;
1500 if (count
< 1 || count
> 63)
1502 if (copy_from_user(&buf
[0], buffer
, count
))
1505 add
= buf
[0] == '+';
1506 sub
= buf
[0] == '-';
1509 devices
= via_parse_odev(ptr
, &ptr
);
1523 static int viafb_iga1_odev_proc_show(struct seq_file
*m
, void *v
)
1525 via_odev_to_seq(m
, viaparinfo
->shared
->iga1_devices
);
1529 static int viafb_iga1_odev_proc_open(struct inode
*inode
, struct file
*file
)
1531 return single_open(file
, viafb_iga1_odev_proc_show
, NULL
);
1534 static ssize_t
viafb_iga1_odev_proc_write(struct file
*file
,
1535 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1537 u32 dev_on
, dev_off
, dev_old
, dev_new
;
1540 dev_old
= dev_new
= viaparinfo
->shared
->iga1_devices
;
1541 res
= odev_update(buffer
, count
, &dev_new
);
1544 dev_off
= dev_old
& ~dev_new
;
1545 dev_on
= dev_new
& ~dev_old
;
1546 viaparinfo
->shared
->iga1_devices
= dev_new
;
1547 viaparinfo
->shared
->iga2_devices
&= ~dev_new
;
1548 via_set_state(dev_off
, VIA_STATE_OFF
);
1549 via_set_source(dev_new
, IGA1
);
1550 via_set_state(dev_on
, VIA_STATE_ON
);
1554 static const struct file_operations viafb_iga1_odev_proc_fops
= {
1555 .owner
= THIS_MODULE
,
1556 .open
= viafb_iga1_odev_proc_open
,
1558 .llseek
= seq_lseek
,
1559 .release
= single_release
,
1560 .write
= viafb_iga1_odev_proc_write
,
1563 static int viafb_iga2_odev_proc_show(struct seq_file
*m
, void *v
)
1565 via_odev_to_seq(m
, viaparinfo
->shared
->iga2_devices
);
1569 static int viafb_iga2_odev_proc_open(struct inode
*inode
, struct file
*file
)
1571 return single_open(file
, viafb_iga2_odev_proc_show
, NULL
);
1574 static ssize_t
viafb_iga2_odev_proc_write(struct file
*file
,
1575 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1577 u32 dev_on
, dev_off
, dev_old
, dev_new
;
1580 dev_old
= dev_new
= viaparinfo
->shared
->iga2_devices
;
1581 res
= odev_update(buffer
, count
, &dev_new
);
1584 dev_off
= dev_old
& ~dev_new
;
1585 dev_on
= dev_new
& ~dev_old
;
1586 viaparinfo
->shared
->iga2_devices
= dev_new
;
1587 viaparinfo
->shared
->iga1_devices
&= ~dev_new
;
1588 via_set_state(dev_off
, VIA_STATE_OFF
);
1589 via_set_source(dev_new
, IGA2
);
1590 via_set_state(dev_on
, VIA_STATE_ON
);
1594 static const struct file_operations viafb_iga2_odev_proc_fops
= {
1595 .owner
= THIS_MODULE
,
1596 .open
= viafb_iga2_odev_proc_open
,
1598 .llseek
= seq_lseek
,
1599 .release
= single_release
,
1600 .write
= viafb_iga2_odev_proc_write
,
1603 #define IS_VT1636(lvds_chip) ((lvds_chip).lvds_chip_name == VT1636_LVDS)
1604 static void viafb_init_proc(struct viafb_shared
*shared
)
1606 struct proc_dir_entry
*iga1_entry
, *iga2_entry
,
1607 *viafb_entry
= proc_mkdir("viafb", NULL
);
1609 shared
->proc_entry
= viafb_entry
;
1611 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1612 proc_create("dvp0", 0, viafb_entry
, &viafb_dvp0_proc_fops
);
1613 proc_create("dvp1", 0, viafb_entry
, &viafb_dvp1_proc_fops
);
1614 proc_create("dfph", 0, viafb_entry
, &viafb_dfph_proc_fops
);
1615 proc_create("dfpl", 0, viafb_entry
, &viafb_dfpl_proc_fops
);
1616 if (IS_VT1636(shared
->chip_info
.lvds_chip_info
)
1617 || IS_VT1636(shared
->chip_info
.lvds_chip_info2
))
1618 proc_create("vt1636", 0, viafb_entry
,
1619 &viafb_vt1636_proc_fops
);
1620 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
1622 proc_create("supported_output_devices", 0, viafb_entry
,
1623 &viafb_sup_odev_proc_fops
);
1624 iga1_entry
= proc_mkdir("iga1", viafb_entry
);
1625 shared
->iga1_proc_entry
= iga1_entry
;
1626 proc_create("output_devices", 0, iga1_entry
,
1627 &viafb_iga1_odev_proc_fops
);
1628 iga2_entry
= proc_mkdir("iga2", viafb_entry
);
1629 shared
->iga2_proc_entry
= iga2_entry
;
1630 proc_create("output_devices", 0, iga2_entry
,
1631 &viafb_iga2_odev_proc_fops
);
1634 static void viafb_remove_proc(struct viafb_shared
*shared
)
1636 struct proc_dir_entry
*viafb_entry
= shared
->proc_entry
,
1637 *iga1_entry
= shared
->iga1_proc_entry
,
1638 *iga2_entry
= shared
->iga2_proc_entry
;
1643 remove_proc_entry("output_devices", iga2_entry
);
1644 remove_proc_entry("iga2", viafb_entry
);
1645 remove_proc_entry("output_devices", iga1_entry
);
1646 remove_proc_entry("iga1", viafb_entry
);
1647 remove_proc_entry("supported_output_devices", viafb_entry
);
1649 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1650 remove_proc_entry("dvp0", viafb_entry
);/* parent dir */
1651 remove_proc_entry("dvp1", viafb_entry
);
1652 remove_proc_entry("dfph", viafb_entry
);
1653 remove_proc_entry("dfpl", viafb_entry
);
1654 if (IS_VT1636(shared
->chip_info
.lvds_chip_info
)
1655 || IS_VT1636(shared
->chip_info
.lvds_chip_info2
))
1656 remove_proc_entry("vt1636", viafb_entry
);
1657 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
1659 remove_proc_entry("viafb", NULL
);
1663 static int parse_mode(const char *str
, u32
*xres
, u32
*yres
)
1673 *xres
= simple_strtoul(str
, &ptr
, 10);
1677 *yres
= simple_strtoul(&ptr
[1], &ptr
, 10);
1686 static int viafb_suspend(void *unused
)
1689 fb_set_suspend(viafbinfo
, 1);
1690 viafb_sync(viafbinfo
);
1696 static int viafb_resume(void *unused
)
1699 if (viaparinfo
->shared
->vdev
->engine_mmio
)
1700 viafb_reset_engine(viaparinfo
);
1701 viafb_set_par(viafbinfo
);
1703 viafb_set_par(viafbinfo1
);
1704 fb_set_suspend(viafbinfo
, 0);
1710 static struct viafb_pm_hooks viafb_fb_pm_hooks
= {
1711 .suspend
= viafb_suspend
,
1712 .resume
= viafb_resume
1718 int __devinit
via_fb_pci_probe(struct viafb_dev
*vdev
)
1720 u32 default_xres
, default_yres
;
1721 struct VideoModeTable
*vmode_entry
;
1722 struct fb_var_screeninfo default_var
;
1724 u32 viafb_par_length
;
1726 DEBUG_MSG(KERN_INFO
"VIAFB PCI Probe!!\n");
1727 memset(&default_var
, 0, sizeof(default_var
));
1728 viafb_par_length
= ALIGN(sizeof(struct viafb_par
), BITS_PER_LONG
/8);
1730 /* Allocate fb_info and ***_par here, also including some other needed
1733 viafbinfo
= framebuffer_alloc(viafb_par_length
+
1734 ALIGN(sizeof(struct viafb_shared
), BITS_PER_LONG
/8),
1737 printk(KERN_ERR
"Could not allocate memory for viafb_info.\n");
1741 viaparinfo
= (struct viafb_par
*)viafbinfo
->par
;
1742 viaparinfo
->shared
= viafbinfo
->par
+ viafb_par_length
;
1743 viaparinfo
->shared
->vdev
= vdev
;
1744 viaparinfo
->vram_addr
= 0;
1745 viaparinfo
->tmds_setting_info
= &viaparinfo
->shared
->tmds_setting_info
;
1746 viaparinfo
->lvds_setting_info
= &viaparinfo
->shared
->lvds_setting_info
;
1747 viaparinfo
->lvds_setting_info2
=
1748 &viaparinfo
->shared
->lvds_setting_info2
;
1749 viaparinfo
->crt_setting_info
= &viaparinfo
->shared
->crt_setting_info
;
1750 viaparinfo
->chip_info
= &viaparinfo
->shared
->chip_info
;
1757 viafb_init_chip_info(vdev
->chip_type
);
1759 * The framebuffer will have been successfully mapped by
1760 * the core (or we'd not be here), but we still need to
1761 * set up our own accounting.
1763 viaparinfo
->fbmem
= vdev
->fbmem_start
;
1764 viaparinfo
->memsize
= vdev
->fbmem_len
;
1765 viaparinfo
->fbmem_free
= viaparinfo
->memsize
;
1766 viaparinfo
->fbmem_used
= 0;
1767 viafbinfo
->screen_base
= vdev
->fbmem
;
1769 viafbinfo
->fix
.mmio_start
= vdev
->engine_start
;
1770 viafbinfo
->fix
.mmio_len
= vdev
->engine_len
;
1771 viafbinfo
->node
= 0;
1772 viafbinfo
->fbops
= &viafb_ops
;
1773 viafbinfo
->flags
= FBINFO_DEFAULT
| FBINFO_HWACCEL_YPAN
;
1775 viafbinfo
->pseudo_palette
= pseudo_pal
;
1776 if (viafb_accel
&& !viafb_setup_engine(viafbinfo
)) {
1777 viafbinfo
->flags
|= FBINFO_HWACCEL_COPYAREA
|
1778 FBINFO_HWACCEL_FILLRECT
| FBINFO_HWACCEL_IMAGEBLIT
;
1779 default_var
.accel_flags
= FB_ACCELF_TEXT
;
1781 viafbinfo
->flags
|= FBINFO_HWACCEL_DISABLED
;
1782 default_var
.accel_flags
= 0;
1785 if (viafb_second_size
&& (viafb_second_size
< 8)) {
1786 viafb_second_offset
= viaparinfo
->fbmem_free
-
1787 viafb_second_size
* 1024 * 1024;
1789 viafb_second_size
= 8;
1790 viafb_second_offset
= viaparinfo
->fbmem_free
-
1791 viafb_second_size
* 1024 * 1024;
1794 parse_mode(viafb_mode
, &default_xres
, &default_yres
);
1795 vmode_entry
= viafb_get_mode(default_xres
, default_yres
);
1796 if (viafb_SAMM_ON
== 1) {
1797 parse_mode(viafb_mode1
, &viafb_second_xres
,
1798 &viafb_second_yres
);
1800 viafb_second_virtual_xres
= viafb_second_xres
;
1801 viafb_second_virtual_yres
= viafb_second_yres
;
1804 default_var
.xres
= default_xres
;
1805 default_var
.yres
= default_yres
;
1806 default_var
.xres_virtual
= default_xres
;
1807 default_var
.yres_virtual
= default_yres
;
1808 default_var
.bits_per_pixel
= viafb_bpp
;
1809 viafb_fill_var_timing_info(&default_var
, viafb_get_refresh(
1810 default_var
.xres
, default_var
.yres
, viafb_refresh
),
1811 viafb_get_mode(default_var
.xres
, default_var
.yres
));
1812 viafb_setup_fixinfo(&viafbinfo
->fix
, viaparinfo
);
1813 viafbinfo
->var
= default_var
;
1815 if (viafb_dual_fb
) {
1816 viafbinfo1
= framebuffer_alloc(viafb_par_length
,
1820 "allocate the second framebuffer struct error\n");
1822 goto out_fb_release
;
1824 viaparinfo1
= viafbinfo1
->par
;
1825 memcpy(viaparinfo1
, viaparinfo
, viafb_par_length
);
1826 viaparinfo1
->vram_addr
= viafb_second_offset
;
1827 viaparinfo1
->memsize
= viaparinfo
->memsize
-
1828 viafb_second_offset
;
1829 viaparinfo
->memsize
= viafb_second_offset
;
1830 viaparinfo1
->fbmem
= viaparinfo
->fbmem
+ viafb_second_offset
;
1832 viaparinfo1
->fbmem_used
= viaparinfo
->fbmem_used
;
1833 viaparinfo1
->fbmem_free
= viaparinfo1
->memsize
-
1834 viaparinfo1
->fbmem_used
;
1835 viaparinfo
->fbmem_free
= viaparinfo
->memsize
;
1836 viaparinfo
->fbmem_used
= 0;
1838 viaparinfo
->iga_path
= IGA1
;
1839 viaparinfo1
->iga_path
= IGA2
;
1840 memcpy(viafbinfo1
, viafbinfo
, sizeof(struct fb_info
));
1841 viafbinfo1
->par
= viaparinfo1
;
1842 viafbinfo1
->screen_base
= viafbinfo
->screen_base
+
1843 viafb_second_offset
;
1845 default_var
.xres
= viafb_second_xres
;
1846 default_var
.yres
= viafb_second_yres
;
1847 default_var
.xres_virtual
= viafb_second_virtual_xres
;
1848 default_var
.yres_virtual
= viafb_second_virtual_yres
;
1849 default_var
.bits_per_pixel
= viafb_bpp1
;
1850 viafb_fill_var_timing_info(&default_var
, viafb_get_refresh(
1851 default_var
.xres
, default_var
.yres
, viafb_refresh1
),
1852 viafb_get_mode(default_var
.xres
, default_var
.yres
));
1854 viafb_setup_fixinfo(&viafbinfo1
->fix
, viaparinfo1
);
1855 viafb_check_var(&default_var
, viafbinfo1
);
1856 viafbinfo1
->var
= default_var
;
1857 viafb_update_fix(viafbinfo1
);
1858 viaparinfo1
->depth
= fb_get_color_depth(&viafbinfo1
->var
,
1862 viafb_check_var(&viafbinfo
->var
, viafbinfo
);
1863 viafb_update_fix(viafbinfo
);
1864 viaparinfo
->depth
= fb_get_color_depth(&viafbinfo
->var
,
1866 default_var
.activate
= FB_ACTIVATE_NOW
;
1867 rc
= fb_alloc_cmap(&viafbinfo
->cmap
, 256, 0);
1869 goto out_fb1_release
;
1871 if (viafb_dual_fb
&& (viafb_primary_dev
== LCD_Device
)
1872 && (viaparinfo
->chip_info
->gfx_chip_name
== UNICHROME_CLE266
)) {
1873 rc
= register_framebuffer(viafbinfo1
);
1875 goto out_dealloc_cmap
;
1877 rc
= register_framebuffer(viafbinfo
);
1879 goto out_fb1_unreg_lcd_cle266
;
1881 if (viafb_dual_fb
&& ((viafb_primary_dev
!= LCD_Device
)
1882 || (viaparinfo
->chip_info
->gfx_chip_name
!=
1883 UNICHROME_CLE266
))) {
1884 rc
= register_framebuffer(viafbinfo1
);
1888 DEBUG_MSG(KERN_INFO
"fb%d: %s frame buffer device %dx%d-%dbpp\n",
1889 viafbinfo
->node
, viafbinfo
->fix
.id
, default_var
.xres
,
1890 default_var
.yres
, default_var
.bits_per_pixel
);
1892 viafb_init_proc(viaparinfo
->shared
);
1893 viafb_init_dac(IGA2
);
1896 viafb_pm_register(&viafb_fb_pm_hooks
);
1901 unregister_framebuffer(viafbinfo
);
1902 out_fb1_unreg_lcd_cle266
:
1903 if (viafb_dual_fb
&& (viafb_primary_dev
== LCD_Device
)
1904 && (viaparinfo
->chip_info
->gfx_chip_name
== UNICHROME_CLE266
))
1905 unregister_framebuffer(viafbinfo1
);
1907 fb_dealloc_cmap(&viafbinfo
->cmap
);
1910 framebuffer_release(viafbinfo1
);
1912 framebuffer_release(viafbinfo
);
1916 void __devexit
via_fb_pci_remove(struct pci_dev
*pdev
)
1918 DEBUG_MSG(KERN_INFO
"via_pci_remove!\n");
1919 fb_dealloc_cmap(&viafbinfo
->cmap
);
1920 unregister_framebuffer(viafbinfo
);
1922 unregister_framebuffer(viafbinfo1
);
1923 viafb_remove_proc(viaparinfo
->shared
);
1924 framebuffer_release(viafbinfo
);
1926 framebuffer_release(viafbinfo1
);
1930 static int __init
viafb_setup(char *options
)
1933 DEBUG_MSG(KERN_INFO
"viafb_setup!\n");
1935 if (!options
|| !*options
)
1938 while ((this_opt
= strsep(&options
, ",")) != NULL
) {
1942 if (!strncmp(this_opt
, "viafb_mode1=", 12))
1943 viafb_mode1
= kstrdup(this_opt
+ 12, GFP_KERNEL
);
1944 else if (!strncmp(this_opt
, "viafb_mode=", 11))
1945 viafb_mode
= kstrdup(this_opt
+ 11, GFP_KERNEL
);
1946 else if (!strncmp(this_opt
, "viafb_bpp1=", 11))
1947 strict_strtoul(this_opt
+ 11, 0,
1948 (unsigned long *)&viafb_bpp1
);
1949 else if (!strncmp(this_opt
, "viafb_bpp=", 10))
1950 strict_strtoul(this_opt
+ 10, 0,
1951 (unsigned long *)&viafb_bpp
);
1952 else if (!strncmp(this_opt
, "viafb_refresh1=", 15))
1953 strict_strtoul(this_opt
+ 15, 0,
1954 (unsigned long *)&viafb_refresh1
);
1955 else if (!strncmp(this_opt
, "viafb_refresh=", 14))
1956 strict_strtoul(this_opt
+ 14, 0,
1957 (unsigned long *)&viafb_refresh
);
1958 else if (!strncmp(this_opt
, "viafb_lcd_dsp_method=", 21))
1959 strict_strtoul(this_opt
+ 21, 0,
1960 (unsigned long *)&viafb_lcd_dsp_method
);
1961 else if (!strncmp(this_opt
, "viafb_lcd_panel_id=", 19))
1962 strict_strtoul(this_opt
+ 19, 0,
1963 (unsigned long *)&viafb_lcd_panel_id
);
1964 else if (!strncmp(this_opt
, "viafb_accel=", 12))
1965 strict_strtoul(this_opt
+ 12, 0,
1966 (unsigned long *)&viafb_accel
);
1967 else if (!strncmp(this_opt
, "viafb_SAMM_ON=", 14))
1968 strict_strtoul(this_opt
+ 14, 0,
1969 (unsigned long *)&viafb_SAMM_ON
);
1970 else if (!strncmp(this_opt
, "viafb_active_dev=", 17))
1971 viafb_active_dev
= kstrdup(this_opt
+ 17, GFP_KERNEL
);
1972 else if (!strncmp(this_opt
,
1973 "viafb_display_hardware_layout=", 30))
1974 strict_strtoul(this_opt
+ 30, 0,
1975 (unsigned long *)&viafb_display_hardware_layout
);
1976 else if (!strncmp(this_opt
, "viafb_second_size=", 18))
1977 strict_strtoul(this_opt
+ 18, 0,
1978 (unsigned long *)&viafb_second_size
);
1979 else if (!strncmp(this_opt
,
1980 "viafb_platform_epia_dvi=", 24))
1981 strict_strtoul(this_opt
+ 24, 0,
1982 (unsigned long *)&viafb_platform_epia_dvi
);
1983 else if (!strncmp(this_opt
,
1984 "viafb_device_lcd_dualedge=", 26))
1985 strict_strtoul(this_opt
+ 26, 0,
1986 (unsigned long *)&viafb_device_lcd_dualedge
);
1987 else if (!strncmp(this_opt
, "viafb_bus_width=", 16))
1988 strict_strtoul(this_opt
+ 16, 0,
1989 (unsigned long *)&viafb_bus_width
);
1990 else if (!strncmp(this_opt
, "viafb_lcd_mode=", 15))
1991 strict_strtoul(this_opt
+ 15, 0,
1992 (unsigned long *)&viafb_lcd_mode
);
1993 else if (!strncmp(this_opt
, "viafb_lcd_port=", 15))
1994 viafb_lcd_port
= kstrdup(this_opt
+ 15, GFP_KERNEL
);
1995 else if (!strncmp(this_opt
, "viafb_dvi_port=", 15))
1996 viafb_dvi_port
= kstrdup(this_opt
+ 15, GFP_KERNEL
);
2003 * These are called out of via-core for now.
2005 int __init
viafb_init(void)
2007 u32 dummy_x
, dummy_y
;
2009 char *option
= NULL
;
2010 if (fb_get_options("viafb", &option
))
2012 viafb_setup(option
);
2014 if (parse_mode(viafb_mode
, &dummy_x
, &dummy_y
)
2015 || !viafb_get_mode(dummy_x
, dummy_y
)
2016 || parse_mode(viafb_mode1
, &dummy_x
, &dummy_y
)
2017 || !viafb_get_mode(dummy_x
, dummy_y
)
2018 || viafb_bpp
< 0 || viafb_bpp
> 32
2019 || viafb_bpp1
< 0 || viafb_bpp1
> 32
2020 || parse_active_dev())
2024 "VIA Graphics Integration Chipset framebuffer %d.%d initializing\n",
2025 VERSION_MAJOR
, VERSION_MINOR
);
2029 void __exit
viafb_exit(void)
2031 DEBUG_MSG(KERN_INFO
"viafb_exit!\n");
2034 static struct fb_ops viafb_ops
= {
2035 .owner
= THIS_MODULE
,
2036 .fb_open
= viafb_open
,
2037 .fb_release
= viafb_release
,
2038 .fb_check_var
= viafb_check_var
,
2039 .fb_set_par
= viafb_set_par
,
2040 .fb_setcolreg
= viafb_setcolreg
,
2041 .fb_pan_display
= viafb_pan_display
,
2042 .fb_blank
= viafb_blank
,
2043 .fb_fillrect
= viafb_fillrect
,
2044 .fb_copyarea
= viafb_copyarea
,
2045 .fb_imageblit
= viafb_imageblit
,
2046 .fb_cursor
= viafb_cursor
,
2047 .fb_ioctl
= viafb_ioctl
,
2048 .fb_sync
= viafb_sync
,
2053 module_param(viafb_mode
, charp
, S_IRUSR
);
2054 MODULE_PARM_DESC(viafb_mode
, "Set resolution (default=640x480)");
2056 module_param(viafb_mode1
, charp
, S_IRUSR
);
2057 MODULE_PARM_DESC(viafb_mode1
, "Set resolution (default=640x480)");
2059 module_param(viafb_bpp
, int, S_IRUSR
);
2060 MODULE_PARM_DESC(viafb_bpp
, "Set color depth (default=32bpp)");
2062 module_param(viafb_bpp1
, int, S_IRUSR
);
2063 MODULE_PARM_DESC(viafb_bpp1
, "Set color depth (default=32bpp)");
2065 module_param(viafb_refresh
, int, S_IRUSR
);
2066 MODULE_PARM_DESC(viafb_refresh
,
2067 "Set CRT viafb_refresh rate (default = 60)");
2069 module_param(viafb_refresh1
, int, S_IRUSR
);
2070 MODULE_PARM_DESC(viafb_refresh1
,
2071 "Set CRT refresh rate (default = 60)");
2073 module_param(viafb_lcd_panel_id
, int, S_IRUSR
);
2074 MODULE_PARM_DESC(viafb_lcd_panel_id
,
2075 "Set Flat Panel type(Default=1024x768)");
2077 module_param(viafb_lcd_dsp_method
, int, S_IRUSR
);
2078 MODULE_PARM_DESC(viafb_lcd_dsp_method
,
2079 "Set Flat Panel display scaling method.(Default=Expandsion)");
2081 module_param(viafb_SAMM_ON
, int, S_IRUSR
);
2082 MODULE_PARM_DESC(viafb_SAMM_ON
,
2083 "Turn on/off flag of SAMM(Default=OFF)");
2085 module_param(viafb_accel
, int, S_IRUSR
);
2086 MODULE_PARM_DESC(viafb_accel
,
2087 "Set 2D Hardware Acceleration: 0 = OFF, 1 = ON (default)");
2089 module_param(viafb_active_dev
, charp
, S_IRUSR
);
2090 MODULE_PARM_DESC(viafb_active_dev
, "Specify active devices.");
2092 module_param(viafb_display_hardware_layout
, int, S_IRUSR
);
2093 MODULE_PARM_DESC(viafb_display_hardware_layout
,
2094 "Display Hardware Layout (LCD Only, DVI Only...,etc)");
2096 module_param(viafb_second_size
, int, S_IRUSR
);
2097 MODULE_PARM_DESC(viafb_second_size
,
2098 "Set secondary device memory size");
2100 module_param(viafb_dual_fb
, int, S_IRUSR
);
2101 MODULE_PARM_DESC(viafb_dual_fb
,
2102 "Turn on/off flag of dual framebuffer devices.(Default = OFF)");
2104 module_param(viafb_platform_epia_dvi
, int, S_IRUSR
);
2105 MODULE_PARM_DESC(viafb_platform_epia_dvi
,
2106 "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)");
2108 module_param(viafb_device_lcd_dualedge
, int, S_IRUSR
);
2109 MODULE_PARM_DESC(viafb_device_lcd_dualedge
,
2110 "Turn on/off flag of dual edge panel.(Default = OFF)");
2112 module_param(viafb_bus_width
, int, S_IRUSR
);
2113 MODULE_PARM_DESC(viafb_bus_width
,
2114 "Set bus width of panel.(Default = 12)");
2116 module_param(viafb_lcd_mode
, int, S_IRUSR
);
2117 MODULE_PARM_DESC(viafb_lcd_mode
,
2118 "Set Flat Panel mode(Default=OPENLDI)");
2120 module_param(viafb_lcd_port
, charp
, S_IRUSR
);
2121 MODULE_PARM_DESC(viafb_lcd_port
, "Specify LCD output port.");
2123 module_param(viafb_dvi_port
, charp
, S_IRUSR
);
2124 MODULE_PARM_DESC(viafb_dvi_port
, "Specify DVI output port.");
2126 MODULE_LICENSE("GPL");