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>
32 static char *viafb_name
= "Via";
33 static u32 pseudo_pal
[17];
36 static char *viafb_mode
;
37 static char *viafb_mode1
;
38 static int viafb_bpp
= 32;
39 static int viafb_bpp1
= 32;
41 static unsigned int viafb_second_xres
= 640;
42 static unsigned int viafb_second_yres
= 480;
43 static unsigned int viafb_second_offset
;
44 static int viafb_second_size
;
46 static int viafb_accel
= 1;
48 /* Added for specifying active devices.*/
49 static char *viafb_active_dev
;
51 /*Added for specify lcd output port*/
52 static char *viafb_lcd_port
= "";
53 static char *viafb_dvi_port
= "";
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
;
62 /* supported output devices on each IGP
63 * only CX700, VX800, VX855, VX900 were documented
64 * VIA_CRT should be everywhere
65 * VIA_6C can be onle pre-CX700 (probably only on CLE266) as 6C is used for PLL
66 * source selection on CX700 and later
67 * K400 seems to support VIA_96, VIA_DVP1, VIA_LVDS{1,2} as in viamode.c
69 static const u32 supported_odev_map
[] = {
70 [UNICHROME_CLE266
] = VIA_CRT
| VIA_LDVP0
| VIA_LDVP1
,
71 [UNICHROME_K400
] = VIA_CRT
| VIA_DVP0
| VIA_DVP1
| VIA_LVDS1
73 [UNICHROME_K800
] = VIA_CRT
| VIA_DVP0
| VIA_DVP1
| VIA_LVDS1
75 [UNICHROME_PM800
] = VIA_CRT
| VIA_DVP0
| VIA_DVP1
| VIA_LVDS1
77 [UNICHROME_CN700
] = VIA_CRT
| VIA_DVP0
| VIA_DVP1
| VIA_LVDS1
79 [UNICHROME_CX700
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
80 [UNICHROME_CN750
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
81 [UNICHROME_K8M890
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
82 [UNICHROME_P4M890
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
83 [UNICHROME_P4M900
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
84 [UNICHROME_VX800
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
85 [UNICHROME_VX855
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
86 [UNICHROME_VX900
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
89 static void viafb_fill_var_color_info(struct fb_var_screeninfo
*var
, u8 depth
)
92 var
->red
.msb_right
= 0;
93 var
->green
.msb_right
= 0;
94 var
->blue
.msb_right
= 0;
95 var
->transp
.offset
= 0;
96 var
->transp
.length
= 0;
97 var
->transp
.msb_right
= 0;
101 var
->bits_per_pixel
= 8;
103 var
->green
.offset
= 0;
104 var
->blue
.offset
= 0;
106 var
->green
.length
= 8;
107 var
->blue
.length
= 8;
110 var
->bits_per_pixel
= 16;
111 var
->red
.offset
= 10;
112 var
->green
.offset
= 5;
113 var
->blue
.offset
= 0;
115 var
->green
.length
= 5;
116 var
->blue
.length
= 5;
119 var
->bits_per_pixel
= 16;
120 var
->red
.offset
= 11;
121 var
->green
.offset
= 5;
122 var
->blue
.offset
= 0;
124 var
->green
.length
= 6;
125 var
->blue
.length
= 5;
128 var
->bits_per_pixel
= 32;
129 var
->red
.offset
= 16;
130 var
->green
.offset
= 8;
131 var
->blue
.offset
= 0;
133 var
->green
.length
= 8;
134 var
->blue
.length
= 8;
137 var
->bits_per_pixel
= 32;
138 var
->red
.offset
= 20;
139 var
->green
.offset
= 10;
140 var
->blue
.offset
= 0;
141 var
->red
.length
= 10;
142 var
->green
.length
= 10;
143 var
->blue
.length
= 10;
148 static void viafb_update_fix(struct fb_info
*info
)
150 u32 bpp
= info
->var
.bits_per_pixel
;
153 bpp
== 8 ? FB_VISUAL_PSEUDOCOLOR
: FB_VISUAL_TRUECOLOR
;
154 info
->fix
.line_length
= ALIGN(info
->var
.xres_virtual
* bpp
/ 8,
158 static void viafb_setup_fixinfo(struct fb_fix_screeninfo
*fix
,
159 struct viafb_par
*viaparinfo
)
161 memset(fix
, 0, sizeof(struct fb_fix_screeninfo
));
162 strcpy(fix
->id
, viafb_name
);
164 fix
->smem_start
= viaparinfo
->fbmem
;
165 fix
->smem_len
= viaparinfo
->fbmem_free
;
167 fix
->type
= FB_TYPE_PACKED_PIXELS
;
169 fix
->visual
= FB_VISUAL_TRUECOLOR
;
171 fix
->xpanstep
= fix
->ywrapstep
= 0;
174 /* Just tell the accel name */
175 viafbinfo
->fix
.accel
= FB_ACCEL_VIA_UNICHROME
;
177 static int viafb_open(struct fb_info
*info
, int user
)
179 DEBUG_MSG(KERN_INFO
"viafb_open!\n");
183 static int viafb_release(struct fb_info
*info
, int user
)
185 DEBUG_MSG(KERN_INFO
"viafb_release!\n");
189 static inline int get_var_refresh(struct fb_var_screeninfo
*var
)
193 htotal
= var
->left_margin
+ var
->xres
+ var
->right_margin
195 vtotal
= var
->upper_margin
+ var
->yres
+ var
->lower_margin
197 return PICOS2KHZ(var
->pixclock
) * 1000 / (htotal
* vtotal
);
200 static int viafb_check_var(struct fb_var_screeninfo
*var
,
201 struct fb_info
*info
)
204 struct VideoModeTable
*vmode_entry
;
205 struct viafb_par
*ppar
= info
->par
;
208 DEBUG_MSG(KERN_INFO
"viafb_check_var!\n");
210 /* HW neither support interlacte nor double-scaned mode */
211 if (var
->vmode
& FB_VMODE_INTERLACED
|| var
->vmode
& FB_VMODE_DOUBLE
)
214 vmode_entry
= viafb_get_mode(var
->xres
, var
->yres
);
217 "viafb: Mode %dx%dx%d not supported!!\n",
218 var
->xres
, var
->yres
, var
->bits_per_pixel
);
222 depth
= fb_get_color_depth(var
, &info
->fix
);
224 depth
= var
->bits_per_pixel
;
226 if (depth
< 0 || depth
> 32)
230 else if (depth
== 15 && viafb_dual_fb
&& ppar
->iga_path
== IGA1
)
232 else if (depth
== 30)
236 else if (depth
<= 16)
241 viafb_fill_var_color_info(var
, depth
);
242 if (var
->xres_virtual
< var
->xres
)
243 var
->xres_virtual
= var
->xres
;
245 line
= ALIGN(var
->xres_virtual
* var
->bits_per_pixel
/ 8,
247 if (line
> VIA_PITCH_MAX
|| line
* var
->yres_virtual
> ppar
->memsize
)
250 /* Based on var passed in to calculate the refresh,
251 * because our driver use some modes special.
253 refresh
= viafb_get_refresh(var
->xres
, var
->yres
,
254 get_var_refresh(var
));
256 /* Adjust var according to our driver's own table */
257 viafb_fill_var_timing_info(var
, refresh
, vmode_entry
);
258 if (var
->accel_flags
& FB_ACCELF_TEXT
&&
259 !ppar
->shared
->vdev
->engine_mmio
)
260 var
->accel_flags
= 0;
265 static int viafb_set_par(struct fb_info
*info
)
267 struct viafb_par
*viapar
= info
->par
;
268 struct VideoModeTable
*vmode_entry
, *vmode_entry1
= NULL
;
270 DEBUG_MSG(KERN_INFO
"viafb_set_par!\n");
272 viafb_update_fix(info
);
273 viapar
->depth
= fb_get_color_depth(&info
->var
, &info
->fix
);
274 viafb_update_device_setting(viafbinfo
->var
.xres
, viafbinfo
->var
.yres
,
275 viafbinfo
->var
.bits_per_pixel
, 0);
277 vmode_entry
= viafb_get_mode(viafbinfo
->var
.xres
, viafbinfo
->var
.yres
);
279 vmode_entry1
= viafb_get_mode(viafbinfo1
->var
.xres
,
280 viafbinfo1
->var
.yres
);
281 viafb_update_device_setting(viafbinfo1
->var
.xres
,
282 viafbinfo1
->var
.yres
, viafbinfo1
->var
.bits_per_pixel
,
284 } else if (viafb_SAMM_ON
== 1) {
286 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
287 viafb_second_xres
, viafb_second_yres
, viafb_bpp1
);
288 vmode_entry1
= viafb_get_mode(viafb_second_xres
,
291 viafb_update_device_setting(viafb_second_xres
,
292 viafb_second_yres
, viafb_bpp1
, 1);
295 refresh
= viafb_get_refresh(info
->var
.xres
, info
->var
.yres
,
296 get_var_refresh(&info
->var
));
298 if (viafb_dual_fb
&& viapar
->iga_path
== IGA2
) {
299 viafb_bpp1
= info
->var
.bits_per_pixel
;
300 viafb_refresh1
= refresh
;
302 viafb_bpp
= info
->var
.bits_per_pixel
;
303 viafb_refresh
= refresh
;
306 if (info
->var
.accel_flags
& FB_ACCELF_TEXT
)
307 info
->flags
&= ~FBINFO_HWACCEL_DISABLED
;
309 info
->flags
|= FBINFO_HWACCEL_DISABLED
;
310 viafb_setmode(vmode_entry
, info
->var
.bits_per_pixel
,
311 vmode_entry1
, viafb_bpp1
);
312 viafb_pan_display(&info
->var
, info
);
318 /* Set one color register */
319 static int viafb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
320 unsigned blue
, unsigned transp
, struct fb_info
*info
)
322 struct viafb_par
*viapar
= info
->par
;
325 if (info
->fix
.visual
== FB_VISUAL_PSEUDOCOLOR
) {
329 if (!viafb_dual_fb
|| viapar
->iga_path
== IGA1
)
330 viafb_set_primary_color_register(regno
, red
>> 8,
331 green
>> 8, blue
>> 8);
333 if (!viafb_dual_fb
|| viapar
->iga_path
== IGA2
)
334 viafb_set_secondary_color_register(regno
, red
>> 8,
335 green
>> 8, blue
>> 8);
340 r
= (red
>> (16 - info
->var
.red
.length
))
341 << info
->var
.red
.offset
;
342 b
= (blue
>> (16 - info
->var
.blue
.length
))
343 << info
->var
.blue
.offset
;
344 g
= (green
>> (16 - info
->var
.green
.length
))
345 << info
->var
.green
.offset
;
346 ((u32
*) info
->pseudo_palette
)[regno
] = r
| g
| b
;
352 static int viafb_pan_display(struct fb_var_screeninfo
*var
,
353 struct fb_info
*info
)
355 struct viafb_par
*viapar
= info
->par
;
356 u32 vram_addr
= viapar
->vram_addr
357 + var
->yoffset
* info
->fix
.line_length
358 + var
->xoffset
* info
->var
.bits_per_pixel
/ 8;
360 DEBUG_MSG(KERN_DEBUG
"viafb_pan_display, address = %d\n", vram_addr
);
361 if (!viafb_dual_fb
) {
362 via_set_primary_address(vram_addr
);
363 via_set_secondary_address(vram_addr
);
364 } else if (viapar
->iga_path
== IGA1
)
365 via_set_primary_address(vram_addr
);
367 via_set_secondary_address(vram_addr
);
372 static int viafb_blank(int blank_mode
, struct fb_info
*info
)
374 DEBUG_MSG(KERN_INFO
"viafb_blank!\n");
375 /* clear DPMS setting */
377 switch (blank_mode
) {
378 case FB_BLANK_UNBLANK
:
379 /* Screen: On, HSync: On, VSync: On */
380 /* control CRT monitor power management */
381 via_set_state(VIA_CRT
, VIA_STATE_ON
);
383 case FB_BLANK_HSYNC_SUSPEND
:
384 /* Screen: Off, HSync: Off, VSync: On */
385 /* control CRT monitor power management */
386 via_set_state(VIA_CRT
, VIA_STATE_STANDBY
);
388 case FB_BLANK_VSYNC_SUSPEND
:
389 /* Screen: Off, HSync: On, VSync: Off */
390 /* control CRT monitor power management */
391 via_set_state(VIA_CRT
, VIA_STATE_SUSPEND
);
393 case FB_BLANK_POWERDOWN
:
394 /* Screen: Off, HSync: Off, VSync: Off */
395 /* control CRT monitor power management */
396 via_set_state(VIA_CRT
, VIA_STATE_OFF
);
403 static int viafb_ioctl(struct fb_info
*info
, u_int cmd
, u_long arg
)
406 struct viafb_ioctl_mode viamode
;
407 struct viafb_ioctl_samm viasamm
;
408 struct viafb_driver_version driver_version
;
409 struct fb_var_screeninfo sec_var
;
410 struct _panel_size_pos_info panel_pos_size_para
;
411 struct viafb_ioctl_setting viafb_setting
;
412 struct device_t active_dev
;
415 u32
*viafb_gamma_table
;
416 char driver_name
[] = "viafb";
418 u32 __user
*argp
= (u32 __user
*) arg
;
421 DEBUG_MSG(KERN_INFO
"viafb_ioctl: 0x%X !!\n", cmd
);
422 printk(KERN_WARNING
"viafb_ioctl: Please avoid this interface as it is unstable and might change or vanish at any time!\n");
423 memset(&u
, 0, sizeof(u
));
426 case VIAFB_GET_CHIP_INFO
:
427 if (copy_to_user(argp
, viaparinfo
->chip_info
,
428 sizeof(struct chip_information
)))
431 case VIAFB_GET_INFO_SIZE
:
432 return put_user((u32
)sizeof(struct viafb_ioctl_info
), argp
);
434 return viafb_ioctl_get_viafb_info(arg
);
436 return put_user(viafb_ioctl_hotplug(info
->var
.xres
,
438 info
->var
.bits_per_pixel
), argp
);
439 case VIAFB_SET_HOTPLUG_FLAG
:
440 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
442 viafb_hotplug
= (gpu32
) ? 1 : 0;
444 case VIAFB_GET_RESOLUTION
:
445 u
.viamode
.xres
= (u32
) viafb_hotplug_Xres
;
446 u
.viamode
.yres
= (u32
) viafb_hotplug_Yres
;
447 u
.viamode
.refresh
= (u32
) viafb_hotplug_refresh
;
448 u
.viamode
.bpp
= (u32
) viafb_hotplug_bpp
;
449 if (viafb_SAMM_ON
== 1) {
450 u
.viamode
.xres_sec
= viafb_second_xres
;
451 u
.viamode
.yres_sec
= viafb_second_yres
;
452 u
.viamode
.virtual_xres_sec
= viafb_dual_fb
? viafbinfo1
->var
.xres_virtual
: viafbinfo
->var
.xres_virtual
;
453 u
.viamode
.virtual_yres_sec
= viafb_dual_fb
? viafbinfo1
->var
.yres_virtual
: viafbinfo
->var
.yres_virtual
;
454 u
.viamode
.refresh_sec
= viafb_refresh1
;
455 u
.viamode
.bpp_sec
= viafb_bpp1
;
457 u
.viamode
.xres_sec
= 0;
458 u
.viamode
.yres_sec
= 0;
459 u
.viamode
.virtual_xres_sec
= 0;
460 u
.viamode
.virtual_yres_sec
= 0;
461 u
.viamode
.refresh_sec
= 0;
462 u
.viamode
.bpp_sec
= 0;
464 if (copy_to_user(argp
, &u
.viamode
, sizeof(u
.viamode
)))
467 case VIAFB_GET_SAMM_INFO
:
468 u
.viasamm
.samm_status
= viafb_SAMM_ON
;
470 if (viafb_SAMM_ON
== 1) {
472 u
.viasamm
.size_prim
= viaparinfo
->fbmem_free
;
473 u
.viasamm
.size_sec
= viaparinfo1
->fbmem_free
;
475 if (viafb_second_size
) {
476 u
.viasamm
.size_prim
=
477 viaparinfo
->fbmem_free
-
478 viafb_second_size
* 1024 * 1024;
480 viafb_second_size
* 1024 * 1024;
482 u
.viasamm
.size_prim
=
483 viaparinfo
->fbmem_free
>> 1;
485 (viaparinfo
->fbmem_free
>> 1);
488 u
.viasamm
.mem_base
= viaparinfo
->fbmem
;
489 u
.viasamm
.offset_sec
= viafb_second_offset
;
491 u
.viasamm
.size_prim
=
492 viaparinfo
->memsize
- viaparinfo
->fbmem_used
;
493 u
.viasamm
.size_sec
= 0;
494 u
.viasamm
.mem_base
= viaparinfo
->fbmem
;
495 u
.viasamm
.offset_sec
= 0;
498 if (copy_to_user(argp
, &u
.viasamm
, sizeof(u
.viasamm
)))
502 case VIAFB_TURN_ON_OUTPUT_DEVICE
:
503 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
505 if (gpu32
& CRT_Device
)
506 via_set_state(VIA_CRT
, VIA_STATE_ON
);
507 if (gpu32
& DVI_Device
)
509 if (gpu32
& LCD_Device
)
512 case VIAFB_TURN_OFF_OUTPUT_DEVICE
:
513 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
515 if (gpu32
& CRT_Device
)
516 via_set_state(VIA_CRT
, VIA_STATE_OFF
);
517 if (gpu32
& DVI_Device
)
519 if (gpu32
& LCD_Device
)
522 case VIAFB_GET_DEVICE
:
523 u
.active_dev
.crt
= viafb_CRT_ON
;
524 u
.active_dev
.dvi
= viafb_DVI_ON
;
525 u
.active_dev
.lcd
= viafb_LCD_ON
;
526 u
.active_dev
.samm
= viafb_SAMM_ON
;
527 u
.active_dev
.primary_dev
= viafb_primary_dev
;
529 u
.active_dev
.lcd_dsp_cent
= viafb_lcd_dsp_method
;
530 u
.active_dev
.lcd_panel_id
= viafb_lcd_panel_id
;
531 u
.active_dev
.lcd_mode
= viafb_lcd_mode
;
533 u
.active_dev
.xres
= viafb_hotplug_Xres
;
534 u
.active_dev
.yres
= viafb_hotplug_Yres
;
536 u
.active_dev
.xres1
= viafb_second_xres
;
537 u
.active_dev
.yres1
= viafb_second_yres
;
539 u
.active_dev
.bpp
= viafb_bpp
;
540 u
.active_dev
.bpp1
= viafb_bpp1
;
541 u
.active_dev
.refresh
= viafb_refresh
;
542 u
.active_dev
.refresh1
= viafb_refresh1
;
544 u
.active_dev
.epia_dvi
= viafb_platform_epia_dvi
;
545 u
.active_dev
.lcd_dual_edge
= viafb_device_lcd_dualedge
;
546 u
.active_dev
.bus_width
= viafb_bus_width
;
548 if (copy_to_user(argp
, &u
.active_dev
, sizeof(u
.active_dev
)))
552 case VIAFB_GET_DRIVER_VERSION
:
553 u
.driver_version
.iMajorNum
= VERSION_MAJOR
;
554 u
.driver_version
.iKernelNum
= VERSION_KERNEL
;
555 u
.driver_version
.iOSNum
= VERSION_OS
;
556 u
.driver_version
.iMinorNum
= VERSION_MINOR
;
558 if (copy_to_user(argp
, &u
.driver_version
,
559 sizeof(u
.driver_version
)))
564 case VIAFB_GET_DEVICE_INFO
:
566 retrieve_device_setting(&u
.viafb_setting
);
568 if (copy_to_user(argp
, &u
.viafb_setting
,
569 sizeof(u
.viafb_setting
)))
574 case VIAFB_GET_DEVICE_SUPPORT
:
575 viafb_get_device_support_state(&state_info
);
576 if (put_user(state_info
, argp
))
580 case VIAFB_GET_DEVICE_CONNECT
:
581 viafb_get_device_connect_state(&state_info
);
582 if (put_user(state_info
, argp
))
586 case VIAFB_GET_PANEL_SUPPORT_EXPAND
:
588 viafb_lcd_get_support_expand_state(info
->var
.xres
,
590 if (put_user(state_info
, argp
))
594 case VIAFB_GET_DRIVER_NAME
:
595 if (copy_to_user(argp
, driver_name
, sizeof(driver_name
)))
599 case VIAFB_SET_GAMMA_LUT
:
600 viafb_gamma_table
= memdup_user(argp
, 256 * sizeof(u32
));
601 if (IS_ERR(viafb_gamma_table
))
602 return PTR_ERR(viafb_gamma_table
);
603 viafb_set_gamma_table(viafb_bpp
, viafb_gamma_table
);
604 kfree(viafb_gamma_table
);
607 case VIAFB_GET_GAMMA_LUT
:
608 viafb_gamma_table
= kmalloc(256 * sizeof(u32
), GFP_KERNEL
);
609 if (!viafb_gamma_table
)
611 viafb_get_gamma_table(viafb_gamma_table
);
612 if (copy_to_user(argp
, viafb_gamma_table
,
613 256 * sizeof(u32
))) {
614 kfree(viafb_gamma_table
);
617 kfree(viafb_gamma_table
);
620 case VIAFB_GET_GAMMA_SUPPORT_STATE
:
621 viafb_get_gamma_support_state(viafb_bpp
, &state_info
);
622 if (put_user(state_info
, argp
))
625 case VIAFB_SYNC_SURFACE
:
626 DEBUG_MSG(KERN_INFO
"lobo VIAFB_SYNC_SURFACE\n");
628 case VIAFB_GET_DRIVER_CAPS
:
631 case VIAFB_GET_PANEL_MAX_SIZE
:
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
)))
640 case VIAFB_GET_PANEL_MAX_POSITION
:
641 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
642 sizeof(u
.panel_pos_size_para
)))
644 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
645 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
646 sizeof(u
.panel_pos_size_para
)))
650 case VIAFB_GET_PANEL_POSITION
:
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
)))
659 case VIAFB_GET_PANEL_SIZE
:
660 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
661 sizeof(u
.panel_pos_size_para
)))
663 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
664 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
665 sizeof(u
.panel_pos_size_para
)))
669 case VIAFB_SET_PANEL_POSITION
:
670 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
671 sizeof(u
.panel_pos_size_para
)))
674 case VIAFB_SET_PANEL_SIZE
:
675 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
676 sizeof(u
.panel_pos_size_para
)))
687 static void viafb_fillrect(struct fb_info
*info
,
688 const struct fb_fillrect
*rect
)
690 struct viafb_par
*viapar
= info
->par
;
691 struct viafb_shared
*shared
= viapar
->shared
;
695 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
) {
696 cfb_fillrect(info
, rect
);
700 if (!rect
->width
|| !rect
->height
)
703 if (info
->fix
.visual
== FB_VISUAL_TRUECOLOR
)
704 fg_color
= ((u32
*)info
->pseudo_palette
)[rect
->color
];
706 fg_color
= rect
->color
;
708 if (rect
->rop
== ROP_XOR
)
713 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: fillrect\n");
714 if (shared
->hw_bitblt(shared
->vdev
->engine_mmio
, VIA_BITBLT_FILL
,
715 rect
->width
, rect
->height
, info
->var
.bits_per_pixel
,
716 viapar
->vram_addr
, info
->fix
.line_length
, rect
->dx
, rect
->dy
,
717 NULL
, 0, 0, 0, 0, fg_color
, 0, rop
))
718 cfb_fillrect(info
, rect
);
721 static void viafb_copyarea(struct fb_info
*info
,
722 const struct fb_copyarea
*area
)
724 struct viafb_par
*viapar
= info
->par
;
725 struct viafb_shared
*shared
= viapar
->shared
;
727 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
) {
728 cfb_copyarea(info
, area
);
732 if (!area
->width
|| !area
->height
)
735 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: copyarea\n");
736 if (shared
->hw_bitblt(shared
->vdev
->engine_mmio
, VIA_BITBLT_COLOR
,
737 area
->width
, area
->height
, info
->var
.bits_per_pixel
,
738 viapar
->vram_addr
, info
->fix
.line_length
, area
->dx
, area
->dy
,
739 NULL
, viapar
->vram_addr
, info
->fix
.line_length
,
740 area
->sx
, area
->sy
, 0, 0, 0))
741 cfb_copyarea(info
, area
);
744 static void viafb_imageblit(struct fb_info
*info
,
745 const struct fb_image
*image
)
747 struct viafb_par
*viapar
= info
->par
;
748 struct viafb_shared
*shared
= viapar
->shared
;
749 u32 fg_color
= 0, bg_color
= 0;
752 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
||
753 (image
->depth
!= 1 && image
->depth
!= viapar
->depth
)) {
754 cfb_imageblit(info
, image
);
758 if (image
->depth
== 1) {
759 op
= VIA_BITBLT_MONO
;
760 if (info
->fix
.visual
== FB_VISUAL_TRUECOLOR
) {
762 ((u32
*)info
->pseudo_palette
)[image
->fg_color
];
764 ((u32
*)info
->pseudo_palette
)[image
->bg_color
];
766 fg_color
= image
->fg_color
;
767 bg_color
= image
->bg_color
;
770 op
= VIA_BITBLT_COLOR
;
772 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: imageblit\n");
773 if (shared
->hw_bitblt(shared
->vdev
->engine_mmio
, op
,
774 image
->width
, image
->height
, info
->var
.bits_per_pixel
,
775 viapar
->vram_addr
, info
->fix
.line_length
, image
->dx
, image
->dy
,
776 (u32
*)image
->data
, 0, 0, 0, 0, fg_color
, bg_color
, 0))
777 cfb_imageblit(info
, image
);
780 static int viafb_cursor(struct fb_info
*info
, struct fb_cursor
*cursor
)
782 struct viafb_par
*viapar
= info
->par
;
783 void __iomem
*engine
= viapar
->shared
->vdev
->engine_mmio
;
784 u32 temp
, xx
, yy
, bg_color
= 0, fg_color
= 0,
785 chip_name
= viapar
->shared
->chip_info
.gfx_chip_name
;
786 int i
, j
= 0, cur_size
= 64;
788 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| info
!= viafbinfo
)
791 /* LCD ouput does not support hw cursors (at least on VN896) */
792 if ((chip_name
== UNICHROME_CLE266
&& viapar
->iga_path
== IGA2
) ||
796 viafb_show_hw_cursor(info
, HW_Cursor_OFF
);
798 if (cursor
->set
& FB_CUR_SETHOT
) {
799 temp
= (cursor
->hot
.x
<< 16) + cursor
->hot
.y
;
800 writel(temp
, engine
+ VIA_REG_CURSOR_ORG
);
803 if (cursor
->set
& FB_CUR_SETPOS
) {
804 yy
= cursor
->image
.dy
- info
->var
.yoffset
;
805 xx
= cursor
->image
.dx
- info
->var
.xoffset
;
808 writel(temp
, engine
+ VIA_REG_CURSOR_POS
);
811 if (cursor
->image
.width
<= 32 && cursor
->image
.height
<= 32)
813 else if (cursor
->image
.width
<= 64 && cursor
->image
.height
<= 64)
816 printk(KERN_WARNING
"viafb_cursor: The cursor is too large "
817 "%dx%d", cursor
->image
.width
, cursor
->image
.height
);
821 if (cursor
->set
& FB_CUR_SETSIZE
) {
822 temp
= readl(engine
+ VIA_REG_CURSOR_MODE
);
828 writel(temp
, engine
+ VIA_REG_CURSOR_MODE
);
831 if (cursor
->set
& FB_CUR_SETCMAP
) {
832 fg_color
= cursor
->image
.fg_color
;
833 bg_color
= cursor
->image
.bg_color
;
834 if (chip_name
== UNICHROME_CX700
||
835 chip_name
== UNICHROME_VX800
||
836 chip_name
== UNICHROME_VX855
||
837 chip_name
== UNICHROME_VX900
) {
839 ((info
->cmap
.red
[fg_color
] & 0xFFC0) << 14) |
840 ((info
->cmap
.green
[fg_color
] & 0xFFC0) << 4) |
841 ((info
->cmap
.blue
[fg_color
] & 0xFFC0) >> 6);
843 ((info
->cmap
.red
[bg_color
] & 0xFFC0) << 14) |
844 ((info
->cmap
.green
[bg_color
] & 0xFFC0) << 4) |
845 ((info
->cmap
.blue
[bg_color
] & 0xFFC0) >> 6);
848 ((info
->cmap
.red
[fg_color
] & 0xFF00) << 8) |
849 (info
->cmap
.green
[fg_color
] & 0xFF00) |
850 ((info
->cmap
.blue
[fg_color
] & 0xFF00) >> 8);
852 ((info
->cmap
.red
[bg_color
] & 0xFF00) << 8) |
853 (info
->cmap
.green
[bg_color
] & 0xFF00) |
854 ((info
->cmap
.blue
[bg_color
] & 0xFF00) >> 8);
857 writel(bg_color
, engine
+ VIA_REG_CURSOR_BG
);
858 writel(fg_color
, engine
+ VIA_REG_CURSOR_FG
);
861 if (cursor
->set
& FB_CUR_SETSHAPE
) {
863 u8 data
[CURSOR_SIZE
];
864 u32 bak
[CURSOR_SIZE
/ 4];
865 } *cr_data
= kzalloc(sizeof(*cr_data
), GFP_ATOMIC
);
866 int size
= ((cursor
->image
.width
+ 7) >> 3) *
867 cursor
->image
.height
;
872 if (cur_size
== 32) {
873 for (i
= 0; i
< (CURSOR_SIZE
/ 4); i
++) {
874 cr_data
->bak
[i
] = 0x0;
875 cr_data
->bak
[i
+ 1] = 0xFFFFFFFF;
879 for (i
= 0; i
< (CURSOR_SIZE
/ 4); i
++) {
880 cr_data
->bak
[i
] = 0x0;
881 cr_data
->bak
[i
+ 1] = 0x0;
882 cr_data
->bak
[i
+ 2] = 0xFFFFFFFF;
883 cr_data
->bak
[i
+ 3] = 0xFFFFFFFF;
888 switch (cursor
->rop
) {
890 for (i
= 0; i
< size
; i
++)
891 cr_data
->data
[i
] = cursor
->mask
[i
];
895 for (i
= 0; i
< size
; i
++)
896 cr_data
->data
[i
] = cursor
->mask
[i
];
902 if (cur_size
== 32) {
903 for (i
= 0; i
< size
; i
++) {
904 cr_data
->bak
[j
] = (u32
) cr_data
->data
[i
];
905 cr_data
->bak
[j
+ 1] = ~cr_data
->bak
[j
];
909 for (i
= 0; i
< size
; i
++) {
910 cr_data
->bak
[j
] = (u32
) cr_data
->data
[i
];
911 cr_data
->bak
[j
+ 1] = 0x0;
912 cr_data
->bak
[j
+ 2] = ~cr_data
->bak
[j
];
913 cr_data
->bak
[j
+ 3] = ~cr_data
->bak
[j
+ 1];
918 memcpy_toio(viafbinfo
->screen_base
+ viapar
->shared
->
919 cursor_vram_addr
, cr_data
->bak
, CURSOR_SIZE
);
924 viafb_show_hw_cursor(info
, HW_Cursor_ON
);
929 static int viafb_sync(struct fb_info
*info
)
931 if (!(info
->flags
& FBINFO_HWACCEL_DISABLED
))
932 viafb_wait_engine_idle(info
);
936 static int get_primary_device(void)
938 int primary_device
= 0;
939 /* Rule: device on iga1 path are the primary device. */
942 if (viaparinfo
->shared
->iga1_devices
& VIA_CRT
) {
943 DEBUG_MSG(KERN_INFO
"CRT IGA Path:%d\n", IGA1
);
944 primary_device
= CRT_Device
;
948 if (viaparinfo
->tmds_setting_info
->iga_path
== IGA1
) {
949 DEBUG_MSG(KERN_INFO
"DVI IGA Path:%d\n",
951 tmds_setting_info
->iga_path
);
952 primary_device
= DVI_Device
;
956 if (viaparinfo
->lvds_setting_info
->iga_path
== IGA1
) {
957 DEBUG_MSG(KERN_INFO
"LCD IGA Path:%d\n",
959 lvds_setting_info
->iga_path
);
960 primary_device
= LCD_Device
;
964 if (viaparinfo
->lvds_setting_info2
->iga_path
== IGA1
) {
965 DEBUG_MSG(KERN_INFO
"LCD2 IGA Path:%d\n",
967 lvds_setting_info2
->iga_path
);
968 primary_device
= LCD2_Device
;
972 return primary_device
;
975 static void retrieve_device_setting(struct viafb_ioctl_setting
979 /* get device status */
980 if (viafb_CRT_ON
== 1)
981 setting_info
->device_status
= CRT_Device
;
982 if (viafb_DVI_ON
== 1)
983 setting_info
->device_status
|= DVI_Device
;
984 if (viafb_LCD_ON
== 1)
985 setting_info
->device_status
|= LCD_Device
;
986 if (viafb_LCD2_ON
== 1)
987 setting_info
->device_status
|= LCD2_Device
;
989 setting_info
->samm_status
= viafb_SAMM_ON
;
990 setting_info
->primary_device
= get_primary_device();
992 setting_info
->first_dev_bpp
= viafb_bpp
;
993 setting_info
->second_dev_bpp
= viafb_bpp1
;
995 setting_info
->first_dev_refresh
= viafb_refresh
;
996 setting_info
->second_dev_refresh
= viafb_refresh1
;
998 setting_info
->first_dev_hor_res
= viafb_hotplug_Xres
;
999 setting_info
->first_dev_ver_res
= viafb_hotplug_Yres
;
1000 setting_info
->second_dev_hor_res
= viafb_second_xres
;
1001 setting_info
->second_dev_ver_res
= viafb_second_yres
;
1003 /* Get lcd attributes */
1004 setting_info
->lcd_attributes
.display_center
= viafb_lcd_dsp_method
;
1005 setting_info
->lcd_attributes
.panel_id
= viafb_lcd_panel_id
;
1006 setting_info
->lcd_attributes
.lcd_mode
= viafb_lcd_mode
;
1009 static int __init
parse_active_dev(void)
1011 viafb_CRT_ON
= STATE_OFF
;
1012 viafb_DVI_ON
= STATE_OFF
;
1013 viafb_LCD_ON
= STATE_OFF
;
1014 viafb_LCD2_ON
= STATE_OFF
;
1015 /* 1. Modify the active status of devices. */
1016 /* 2. Keep the order of devices, so we can set corresponding
1017 IGA path to devices in SAMM case. */
1018 /* Note: The previous of active_dev is primary device,
1019 and the following is secondary device. */
1020 if (!viafb_active_dev
) {
1021 if (machine_is_olpc()) { /* LCD only */
1022 viafb_LCD_ON
= STATE_ON
;
1023 viafb_SAMM_ON
= STATE_OFF
;
1025 viafb_CRT_ON
= STATE_ON
;
1026 viafb_SAMM_ON
= STATE_OFF
;
1028 } else if (!strcmp(viafb_active_dev
, "CRT+DVI")) {
1030 viafb_CRT_ON
= STATE_ON
;
1031 viafb_DVI_ON
= STATE_ON
;
1032 viafb_primary_dev
= CRT_Device
;
1033 } else if (!strcmp(viafb_active_dev
, "DVI+CRT")) {
1035 viafb_CRT_ON
= STATE_ON
;
1036 viafb_DVI_ON
= STATE_ON
;
1037 viafb_primary_dev
= DVI_Device
;
1038 } else if (!strcmp(viafb_active_dev
, "CRT+LCD")) {
1040 viafb_CRT_ON
= STATE_ON
;
1041 viafb_LCD_ON
= STATE_ON
;
1042 viafb_primary_dev
= CRT_Device
;
1043 } else if (!strcmp(viafb_active_dev
, "LCD+CRT")) {
1045 viafb_CRT_ON
= STATE_ON
;
1046 viafb_LCD_ON
= STATE_ON
;
1047 viafb_primary_dev
= LCD_Device
;
1048 } else if (!strcmp(viafb_active_dev
, "DVI+LCD")) {
1050 viafb_DVI_ON
= STATE_ON
;
1051 viafb_LCD_ON
= STATE_ON
;
1052 viafb_primary_dev
= DVI_Device
;
1053 } else if (!strcmp(viafb_active_dev
, "LCD+DVI")) {
1055 viafb_DVI_ON
= STATE_ON
;
1056 viafb_LCD_ON
= STATE_ON
;
1057 viafb_primary_dev
= LCD_Device
;
1058 } else if (!strcmp(viafb_active_dev
, "LCD+LCD2")) {
1059 viafb_LCD_ON
= STATE_ON
;
1060 viafb_LCD2_ON
= STATE_ON
;
1061 viafb_primary_dev
= LCD_Device
;
1062 } else if (!strcmp(viafb_active_dev
, "LCD2+LCD")) {
1063 viafb_LCD_ON
= STATE_ON
;
1064 viafb_LCD2_ON
= STATE_ON
;
1065 viafb_primary_dev
= LCD2_Device
;
1066 } else if (!strcmp(viafb_active_dev
, "CRT")) {
1068 viafb_CRT_ON
= STATE_ON
;
1069 viafb_SAMM_ON
= STATE_OFF
;
1070 } else if (!strcmp(viafb_active_dev
, "DVI")) {
1072 viafb_DVI_ON
= STATE_ON
;
1073 viafb_SAMM_ON
= STATE_OFF
;
1074 } else if (!strcmp(viafb_active_dev
, "LCD")) {
1076 viafb_LCD_ON
= STATE_ON
;
1077 viafb_SAMM_ON
= STATE_OFF
;
1084 static int __devinit
parse_port(char *opt_str
, int *output_interface
)
1086 if (!strncmp(opt_str
, "DVP0", 4))
1087 *output_interface
= INTERFACE_DVP0
;
1088 else if (!strncmp(opt_str
, "DVP1", 4))
1089 *output_interface
= INTERFACE_DVP1
;
1090 else if (!strncmp(opt_str
, "DFP_HIGHLOW", 11))
1091 *output_interface
= INTERFACE_DFP
;
1092 else if (!strncmp(opt_str
, "DFP_HIGH", 8))
1093 *output_interface
= INTERFACE_DFP_HIGH
;
1094 else if (!strncmp(opt_str
, "DFP_LOW", 7))
1095 *output_interface
= INTERFACE_DFP_LOW
;
1097 *output_interface
= INTERFACE_NONE
;
1101 static void __devinit
parse_lcd_port(void)
1103 parse_port(viafb_lcd_port
, &viaparinfo
->chip_info
->lvds_chip_info
.
1105 /*Initialize to avoid unexpected behavior */
1106 viaparinfo
->chip_info
->lvds_chip_info2
.output_interface
=
1109 DEBUG_MSG(KERN_INFO
"parse_lcd_port: viafb_lcd_port:%s,interface:%d\n",
1110 viafb_lcd_port
, viaparinfo
->chip_info
->lvds_chip_info
.
1114 static void __devinit
parse_dvi_port(void)
1116 parse_port(viafb_dvi_port
, &viaparinfo
->chip_info
->tmds_chip_info
.
1119 DEBUG_MSG(KERN_INFO
"parse_dvi_port: viafb_dvi_port:%s,interface:%d\n",
1120 viafb_dvi_port
, viaparinfo
->chip_info
->tmds_chip_info
.
1124 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1127 * The proc filesystem read/write function, a simple proc implement to
1128 * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
1129 * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2],
1130 * CR9B, SR65, CR97, CR99
1132 static int viafb_dvp0_proc_show(struct seq_file
*m
, void *v
)
1134 u8 dvp0_data_dri
= 0, dvp0_clk_dri
= 0, dvp0
= 0;
1136 (viafb_read_reg(VIASR
, SR2A
) & BIT5
) >> 4 |
1137 (viafb_read_reg(VIASR
, SR1B
) & BIT1
) >> 1;
1139 (viafb_read_reg(VIASR
, SR2A
) & BIT4
) >> 3 |
1140 (viafb_read_reg(VIASR
, SR1E
) & BIT2
) >> 2;
1141 dvp0
= viafb_read_reg(VIACR
, CR96
) & 0x0f;
1142 seq_printf(m
, "%x %x %x\n", dvp0
, dvp0_data_dri
, dvp0_clk_dri
);
1146 static int viafb_dvp0_proc_open(struct inode
*inode
, struct file
*file
)
1148 return single_open(file
, viafb_dvp0_proc_show
, NULL
);
1151 static ssize_t
viafb_dvp0_proc_write(struct file
*file
,
1152 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1154 char buf
[20], *value
, *pbuf
;
1156 unsigned long length
, i
;
1159 length
= count
> 20 ? 20 : count
;
1160 if (copy_from_user(&buf
[0], buffer
, length
))
1162 buf
[length
- 1] = '\0'; /*Ensure end string */
1164 for (i
= 0; i
< 3; i
++) {
1165 value
= strsep(&pbuf
, " ");
1166 if (value
!= NULL
) {
1167 strict_strtoul(value
, 0, (unsigned long *)®_val
);
1168 DEBUG_MSG(KERN_INFO
"DVP0:reg_val[%l]=:%x\n", i
,
1172 viafb_write_reg_mask(CR96
, VIACR
,
1176 viafb_write_reg_mask(SR2A
, VIASR
,
1177 reg_val
<< 4, BIT5
);
1178 viafb_write_reg_mask(SR1B
, VIASR
,
1179 reg_val
<< 1, BIT1
);
1182 viafb_write_reg_mask(SR2A
, VIASR
,
1183 reg_val
<< 3, BIT4
);
1184 viafb_write_reg_mask(SR1E
, VIASR
,
1185 reg_val
<< 2, BIT2
);
1197 static const struct file_operations viafb_dvp0_proc_fops
= {
1198 .owner
= THIS_MODULE
,
1199 .open
= viafb_dvp0_proc_open
,
1201 .llseek
= seq_lseek
,
1202 .release
= single_release
,
1203 .write
= viafb_dvp0_proc_write
,
1206 static int viafb_dvp1_proc_show(struct seq_file
*m
, void *v
)
1208 u8 dvp1
= 0, dvp1_data_dri
= 0, dvp1_clk_dri
= 0;
1209 dvp1
= viafb_read_reg(VIACR
, CR9B
) & 0x0f;
1210 dvp1_data_dri
= (viafb_read_reg(VIASR
, SR65
) & 0x0c) >> 2;
1211 dvp1_clk_dri
= viafb_read_reg(VIASR
, SR65
) & 0x03;
1212 seq_printf(m
, "%x %x %x\n", dvp1
, dvp1_data_dri
, dvp1_clk_dri
);
1216 static int viafb_dvp1_proc_open(struct inode
*inode
, struct file
*file
)
1218 return single_open(file
, viafb_dvp1_proc_show
, NULL
);
1221 static ssize_t
viafb_dvp1_proc_write(struct file
*file
,
1222 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1224 char buf
[20], *value
, *pbuf
;
1226 unsigned long length
, i
;
1229 length
= count
> 20 ? 20 : count
;
1230 if (copy_from_user(&buf
[0], buffer
, length
))
1232 buf
[length
- 1] = '\0'; /*Ensure end string */
1234 for (i
= 0; i
< 3; i
++) {
1235 value
= strsep(&pbuf
, " ");
1236 if (value
!= NULL
) {
1237 strict_strtoul(value
, 0, (unsigned long *)®_val
);
1240 viafb_write_reg_mask(CR9B
, VIACR
,
1244 viafb_write_reg_mask(SR65
, VIASR
,
1245 reg_val
<< 2, 0x0c);
1248 viafb_write_reg_mask(SR65
, VIASR
,
1261 static const struct file_operations viafb_dvp1_proc_fops
= {
1262 .owner
= THIS_MODULE
,
1263 .open
= viafb_dvp1_proc_open
,
1265 .llseek
= seq_lseek
,
1266 .release
= single_release
,
1267 .write
= viafb_dvp1_proc_write
,
1270 static int viafb_dfph_proc_show(struct seq_file
*m
, void *v
)
1273 dfp_high
= viafb_read_reg(VIACR
, CR97
) & 0x0f;
1274 seq_printf(m
, "%x\n", dfp_high
);
1278 static int viafb_dfph_proc_open(struct inode
*inode
, struct file
*file
)
1280 return single_open(file
, viafb_dfph_proc_show
, NULL
);
1283 static ssize_t
viafb_dfph_proc_write(struct file
*file
,
1284 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1288 unsigned long length
;
1291 length
= count
> 20 ? 20 : count
;
1292 if (copy_from_user(&buf
[0], buffer
, length
))
1294 buf
[length
- 1] = '\0'; /*Ensure end string */
1295 strict_strtoul(&buf
[0], 0, (unsigned long *)®_val
);
1296 viafb_write_reg_mask(CR97
, VIACR
, reg_val
, 0x0f);
1300 static const struct file_operations viafb_dfph_proc_fops
= {
1301 .owner
= THIS_MODULE
,
1302 .open
= viafb_dfph_proc_open
,
1304 .llseek
= seq_lseek
,
1305 .release
= single_release
,
1306 .write
= viafb_dfph_proc_write
,
1309 static int viafb_dfpl_proc_show(struct seq_file
*m
, void *v
)
1312 dfp_low
= viafb_read_reg(VIACR
, CR99
) & 0x0f;
1313 seq_printf(m
, "%x\n", dfp_low
);
1317 static int viafb_dfpl_proc_open(struct inode
*inode
, struct file
*file
)
1319 return single_open(file
, viafb_dfpl_proc_show
, NULL
);
1322 static ssize_t
viafb_dfpl_proc_write(struct file
*file
,
1323 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1327 unsigned long length
;
1330 length
= count
> 20 ? 20 : count
;
1331 if (copy_from_user(&buf
[0], buffer
, length
))
1333 buf
[length
- 1] = '\0'; /*Ensure end string */
1334 strict_strtoul(&buf
[0], 0, (unsigned long *)®_val
);
1335 viafb_write_reg_mask(CR99
, VIACR
, reg_val
, 0x0f);
1339 static const struct file_operations viafb_dfpl_proc_fops
= {
1340 .owner
= THIS_MODULE
,
1341 .open
= viafb_dfpl_proc_open
,
1343 .llseek
= seq_lseek
,
1344 .release
= single_release
,
1345 .write
= viafb_dfpl_proc_write
,
1348 static int viafb_vt1636_proc_show(struct seq_file
*m
, void *v
)
1350 u8 vt1636_08
= 0, vt1636_09
= 0;
1351 switch (viaparinfo
->chip_info
->lvds_chip_info
.lvds_chip_name
) {
1354 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info
,
1355 &viaparinfo
->chip_info
->lvds_chip_info
, 0x08) & 0x0f;
1357 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info
,
1358 &viaparinfo
->chip_info
->lvds_chip_info
, 0x09) & 0x1f;
1359 seq_printf(m
, "%x %x\n", vt1636_08
, vt1636_09
);
1364 switch (viaparinfo
->chip_info
->lvds_chip_info2
.lvds_chip_name
) {
1367 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info2
,
1368 &viaparinfo
->chip_info
->lvds_chip_info2
, 0x08) & 0x0f;
1370 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info2
,
1371 &viaparinfo
->chip_info
->lvds_chip_info2
, 0x09) & 0x1f;
1372 seq_printf(m
, " %x %x\n", vt1636_08
, vt1636_09
);
1380 static int viafb_vt1636_proc_open(struct inode
*inode
, struct file
*file
)
1382 return single_open(file
, viafb_vt1636_proc_show
, NULL
);
1385 static ssize_t
viafb_vt1636_proc_write(struct file
*file
,
1386 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1388 char buf
[30], *value
, *pbuf
;
1389 struct IODATA reg_val
;
1390 unsigned long length
, i
;
1393 length
= count
> 30 ? 30 : count
;
1394 if (copy_from_user(&buf
[0], buffer
, length
))
1396 buf
[length
- 1] = '\0'; /*Ensure end string */
1398 switch (viaparinfo
->chip_info
->lvds_chip_info
.lvds_chip_name
) {
1400 for (i
= 0; i
< 2; i
++) {
1401 value
= strsep(&pbuf
, " ");
1402 if (value
!= NULL
) {
1403 strict_strtoul(value
, 0,
1404 (unsigned long *)®_val
.Data
);
1407 reg_val
.Index
= 0x08;
1408 reg_val
.Mask
= 0x0f;
1409 viafb_gpio_i2c_write_mask_lvds
1410 (viaparinfo
->lvds_setting_info
,
1412 chip_info
->lvds_chip_info
,
1416 reg_val
.Index
= 0x09;
1417 reg_val
.Mask
= 0x1f;
1418 viafb_gpio_i2c_write_mask_lvds
1419 (viaparinfo
->lvds_setting_info
,
1421 chip_info
->lvds_chip_info
,
1435 switch (viaparinfo
->chip_info
->lvds_chip_info2
.lvds_chip_name
) {
1437 for (i
= 0; i
< 2; i
++) {
1438 value
= strsep(&pbuf
, " ");
1439 if (value
!= NULL
) {
1440 strict_strtoul(value
, 0,
1441 (unsigned long *)®_val
.Data
);
1444 reg_val
.Index
= 0x08;
1445 reg_val
.Mask
= 0x0f;
1446 viafb_gpio_i2c_write_mask_lvds
1447 (viaparinfo
->lvds_setting_info2
,
1449 chip_info
->lvds_chip_info2
,
1453 reg_val
.Index
= 0x09;
1454 reg_val
.Mask
= 0x1f;
1455 viafb_gpio_i2c_write_mask_lvds
1456 (viaparinfo
->lvds_setting_info2
,
1458 chip_info
->lvds_chip_info2
,
1475 static const struct file_operations viafb_vt1636_proc_fops
= {
1476 .owner
= THIS_MODULE
,
1477 .open
= viafb_vt1636_proc_open
,
1479 .llseek
= seq_lseek
,
1480 .release
= single_release
,
1481 .write
= viafb_vt1636_proc_write
,
1484 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
1486 static int viafb_sup_odev_proc_show(struct seq_file
*m
, void *v
)
1488 via_odev_to_seq(m
, supported_odev_map
[
1489 viaparinfo
->shared
->chip_info
.gfx_chip_name
]);
1493 static int viafb_sup_odev_proc_open(struct inode
*inode
, struct file
*file
)
1495 return single_open(file
, viafb_sup_odev_proc_show
, NULL
);
1498 static const struct file_operations viafb_sup_odev_proc_fops
= {
1499 .owner
= THIS_MODULE
,
1500 .open
= viafb_sup_odev_proc_open
,
1502 .llseek
= seq_lseek
,
1503 .release
= single_release
,
1506 static ssize_t
odev_update(const char __user
*buffer
, size_t count
, u32
*odev
)
1508 char buf
[64], *ptr
= buf
;
1512 if (count
< 1 || count
> 63)
1514 if (copy_from_user(&buf
[0], buffer
, count
))
1517 add
= buf
[0] == '+';
1518 sub
= buf
[0] == '-';
1521 devices
= via_parse_odev(ptr
, &ptr
);
1535 static int viafb_iga1_odev_proc_show(struct seq_file
*m
, void *v
)
1537 via_odev_to_seq(m
, viaparinfo
->shared
->iga1_devices
);
1541 static int viafb_iga1_odev_proc_open(struct inode
*inode
, struct file
*file
)
1543 return single_open(file
, viafb_iga1_odev_proc_show
, NULL
);
1546 static ssize_t
viafb_iga1_odev_proc_write(struct file
*file
,
1547 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1549 u32 dev_on
, dev_off
, dev_old
, dev_new
;
1552 dev_old
= dev_new
= viaparinfo
->shared
->iga1_devices
;
1553 res
= odev_update(buffer
, count
, &dev_new
);
1556 dev_off
= dev_old
& ~dev_new
;
1557 dev_on
= dev_new
& ~dev_old
;
1558 viaparinfo
->shared
->iga1_devices
= dev_new
;
1559 viaparinfo
->shared
->iga2_devices
&= ~dev_new
;
1560 via_set_state(dev_off
, VIA_STATE_OFF
);
1561 via_set_source(dev_new
, IGA1
);
1562 via_set_state(dev_on
, VIA_STATE_ON
);
1566 static const struct file_operations viafb_iga1_odev_proc_fops
= {
1567 .owner
= THIS_MODULE
,
1568 .open
= viafb_iga1_odev_proc_open
,
1570 .llseek
= seq_lseek
,
1571 .release
= single_release
,
1572 .write
= viafb_iga1_odev_proc_write
,
1575 static int viafb_iga2_odev_proc_show(struct seq_file
*m
, void *v
)
1577 via_odev_to_seq(m
, viaparinfo
->shared
->iga2_devices
);
1581 static int viafb_iga2_odev_proc_open(struct inode
*inode
, struct file
*file
)
1583 return single_open(file
, viafb_iga2_odev_proc_show
, NULL
);
1586 static ssize_t
viafb_iga2_odev_proc_write(struct file
*file
,
1587 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1589 u32 dev_on
, dev_off
, dev_old
, dev_new
;
1592 dev_old
= dev_new
= viaparinfo
->shared
->iga2_devices
;
1593 res
= odev_update(buffer
, count
, &dev_new
);
1596 dev_off
= dev_old
& ~dev_new
;
1597 dev_on
= dev_new
& ~dev_old
;
1598 viaparinfo
->shared
->iga2_devices
= dev_new
;
1599 viaparinfo
->shared
->iga1_devices
&= ~dev_new
;
1600 via_set_state(dev_off
, VIA_STATE_OFF
);
1601 via_set_source(dev_new
, IGA2
);
1602 via_set_state(dev_on
, VIA_STATE_ON
);
1606 static const struct file_operations viafb_iga2_odev_proc_fops
= {
1607 .owner
= THIS_MODULE
,
1608 .open
= viafb_iga2_odev_proc_open
,
1610 .llseek
= seq_lseek
,
1611 .release
= single_release
,
1612 .write
= viafb_iga2_odev_proc_write
,
1615 #define IS_VT1636(lvds_chip) ((lvds_chip).lvds_chip_name == VT1636_LVDS)
1616 static void viafb_init_proc(struct viafb_shared
*shared
)
1618 struct proc_dir_entry
*iga1_entry
, *iga2_entry
,
1619 *viafb_entry
= proc_mkdir("viafb", NULL
);
1621 shared
->proc_entry
= viafb_entry
;
1623 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1624 proc_create("dvp0", 0, viafb_entry
, &viafb_dvp0_proc_fops
);
1625 proc_create("dvp1", 0, viafb_entry
, &viafb_dvp1_proc_fops
);
1626 proc_create("dfph", 0, viafb_entry
, &viafb_dfph_proc_fops
);
1627 proc_create("dfpl", 0, viafb_entry
, &viafb_dfpl_proc_fops
);
1628 if (IS_VT1636(shared
->chip_info
.lvds_chip_info
)
1629 || IS_VT1636(shared
->chip_info
.lvds_chip_info2
))
1630 proc_create("vt1636", 0, viafb_entry
,
1631 &viafb_vt1636_proc_fops
);
1632 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
1634 proc_create("supported_output_devices", 0, viafb_entry
,
1635 &viafb_sup_odev_proc_fops
);
1636 iga1_entry
= proc_mkdir("iga1", viafb_entry
);
1637 shared
->iga1_proc_entry
= iga1_entry
;
1638 proc_create("output_devices", 0, iga1_entry
,
1639 &viafb_iga1_odev_proc_fops
);
1640 iga2_entry
= proc_mkdir("iga2", viafb_entry
);
1641 shared
->iga2_proc_entry
= iga2_entry
;
1642 proc_create("output_devices", 0, iga2_entry
,
1643 &viafb_iga2_odev_proc_fops
);
1646 static void viafb_remove_proc(struct viafb_shared
*shared
)
1648 struct proc_dir_entry
*viafb_entry
= shared
->proc_entry
,
1649 *iga1_entry
= shared
->iga1_proc_entry
,
1650 *iga2_entry
= shared
->iga2_proc_entry
;
1655 remove_proc_entry("output_devices", iga2_entry
);
1656 remove_proc_entry("iga2", viafb_entry
);
1657 remove_proc_entry("output_devices", iga1_entry
);
1658 remove_proc_entry("iga1", viafb_entry
);
1659 remove_proc_entry("supported_output_devices", viafb_entry
);
1661 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1662 remove_proc_entry("dvp0", viafb_entry
);/* parent dir */
1663 remove_proc_entry("dvp1", viafb_entry
);
1664 remove_proc_entry("dfph", viafb_entry
);
1665 remove_proc_entry("dfpl", viafb_entry
);
1666 if (IS_VT1636(shared
->chip_info
.lvds_chip_info
)
1667 || IS_VT1636(shared
->chip_info
.lvds_chip_info2
))
1668 remove_proc_entry("vt1636", viafb_entry
);
1669 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
1671 remove_proc_entry("viafb", NULL
);
1675 static int parse_mode(const char *str
, u32
*xres
, u32
*yres
)
1680 if (machine_is_olpc()) {
1690 *xres
= simple_strtoul(str
, &ptr
, 10);
1694 *yres
= simple_strtoul(&ptr
[1], &ptr
, 10);
1703 static int viafb_suspend(void *unused
)
1706 fb_set_suspend(viafbinfo
, 1);
1707 viafb_sync(viafbinfo
);
1713 static int viafb_resume(void *unused
)
1716 if (viaparinfo
->shared
->vdev
->engine_mmio
)
1717 viafb_reset_engine(viaparinfo
);
1718 viafb_set_par(viafbinfo
);
1720 viafb_set_par(viafbinfo1
);
1721 fb_set_suspend(viafbinfo
, 0);
1727 static struct viafb_pm_hooks viafb_fb_pm_hooks
= {
1728 .suspend
= viafb_suspend
,
1729 .resume
= viafb_resume
1735 int __devinit
via_fb_pci_probe(struct viafb_dev
*vdev
)
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
->shared
->vdev
= vdev
;
1761 viaparinfo
->vram_addr
= 0;
1762 viaparinfo
->tmds_setting_info
= &viaparinfo
->shared
->tmds_setting_info
;
1763 viaparinfo
->lvds_setting_info
= &viaparinfo
->shared
->lvds_setting_info
;
1764 viaparinfo
->lvds_setting_info2
=
1765 &viaparinfo
->shared
->lvds_setting_info2
;
1766 viaparinfo
->chip_info
= &viaparinfo
->shared
->chip_info
;
1773 viafb_init_chip_info(vdev
->chip_type
);
1775 * The framebuffer will have been successfully mapped by
1776 * the core (or we'd not be here), but we still need to
1777 * set up our own accounting.
1779 viaparinfo
->fbmem
= vdev
->fbmem_start
;
1780 viaparinfo
->memsize
= vdev
->fbmem_len
;
1781 viaparinfo
->fbmem_free
= viaparinfo
->memsize
;
1782 viaparinfo
->fbmem_used
= 0;
1783 viafbinfo
->screen_base
= vdev
->fbmem
;
1785 viafbinfo
->fix
.mmio_start
= vdev
->engine_start
;
1786 viafbinfo
->fix
.mmio_len
= vdev
->engine_len
;
1787 viafbinfo
->node
= 0;
1788 viafbinfo
->fbops
= &viafb_ops
;
1789 viafbinfo
->flags
= FBINFO_DEFAULT
| FBINFO_HWACCEL_YPAN
;
1791 viafbinfo
->pseudo_palette
= pseudo_pal
;
1792 if (viafb_accel
&& !viafb_setup_engine(viafbinfo
)) {
1793 viafbinfo
->flags
|= FBINFO_HWACCEL_COPYAREA
|
1794 FBINFO_HWACCEL_FILLRECT
| FBINFO_HWACCEL_IMAGEBLIT
;
1795 default_var
.accel_flags
= FB_ACCELF_TEXT
;
1797 viafbinfo
->flags
|= FBINFO_HWACCEL_DISABLED
;
1798 default_var
.accel_flags
= 0;
1801 if (viafb_second_size
&& (viafb_second_size
< 8)) {
1802 viafb_second_offset
= viaparinfo
->fbmem_free
-
1803 viafb_second_size
* 1024 * 1024;
1805 viafb_second_size
= 8;
1806 viafb_second_offset
= viaparinfo
->fbmem_free
-
1807 viafb_second_size
* 1024 * 1024;
1810 parse_mode(viafb_mode
, &default_xres
, &default_yres
);
1811 vmode_entry
= viafb_get_mode(default_xres
, default_yres
);
1812 if (viafb_SAMM_ON
== 1)
1813 parse_mode(viafb_mode1
, &viafb_second_xres
,
1814 &viafb_second_yres
);
1816 default_var
.xres
= default_xres
;
1817 default_var
.yres
= default_yres
;
1818 default_var
.xres_virtual
= default_xres
;
1819 default_var
.yres_virtual
= default_yres
;
1820 default_var
.bits_per_pixel
= viafb_bpp
;
1821 viafb_fill_var_timing_info(&default_var
, viafb_get_refresh(
1822 default_var
.xres
, default_var
.yres
, viafb_refresh
),
1823 viafb_get_mode(default_var
.xres
, default_var
.yres
));
1824 viafb_setup_fixinfo(&viafbinfo
->fix
, viaparinfo
);
1825 viafbinfo
->var
= default_var
;
1827 if (viafb_dual_fb
) {
1828 viafbinfo1
= framebuffer_alloc(viafb_par_length
,
1832 "allocate the second framebuffer struct error\n");
1834 goto out_fb_release
;
1836 viaparinfo1
= viafbinfo1
->par
;
1837 memcpy(viaparinfo1
, viaparinfo
, viafb_par_length
);
1838 viaparinfo1
->vram_addr
= viafb_second_offset
;
1839 viaparinfo1
->memsize
= viaparinfo
->memsize
-
1840 viafb_second_offset
;
1841 viaparinfo
->memsize
= viafb_second_offset
;
1842 viaparinfo1
->fbmem
= viaparinfo
->fbmem
+ viafb_second_offset
;
1844 viaparinfo1
->fbmem_used
= viaparinfo
->fbmem_used
;
1845 viaparinfo1
->fbmem_free
= viaparinfo1
->memsize
-
1846 viaparinfo1
->fbmem_used
;
1847 viaparinfo
->fbmem_free
= viaparinfo
->memsize
;
1848 viaparinfo
->fbmem_used
= 0;
1850 viaparinfo
->iga_path
= IGA1
;
1851 viaparinfo1
->iga_path
= IGA2
;
1852 memcpy(viafbinfo1
, viafbinfo
, sizeof(struct fb_info
));
1853 viafbinfo1
->par
= viaparinfo1
;
1854 viafbinfo1
->screen_base
= viafbinfo
->screen_base
+
1855 viafb_second_offset
;
1857 default_var
.xres
= viafb_second_xres
;
1858 default_var
.yres
= viafb_second_yres
;
1859 default_var
.xres_virtual
= viafb_second_xres
;
1860 default_var
.yres_virtual
= viafb_second_yres
;
1861 default_var
.bits_per_pixel
= viafb_bpp1
;
1862 viafb_fill_var_timing_info(&default_var
, viafb_get_refresh(
1863 default_var
.xres
, default_var
.yres
, viafb_refresh1
),
1864 viafb_get_mode(default_var
.xres
, default_var
.yres
));
1866 viafb_setup_fixinfo(&viafbinfo1
->fix
, viaparinfo1
);
1867 viafb_check_var(&default_var
, viafbinfo1
);
1868 viafbinfo1
->var
= default_var
;
1869 viafb_update_fix(viafbinfo1
);
1870 viaparinfo1
->depth
= fb_get_color_depth(&viafbinfo1
->var
,
1874 viafb_check_var(&viafbinfo
->var
, viafbinfo
);
1875 viafb_update_fix(viafbinfo
);
1876 viaparinfo
->depth
= fb_get_color_depth(&viafbinfo
->var
,
1878 default_var
.activate
= FB_ACTIVATE_NOW
;
1879 rc
= fb_alloc_cmap(&viafbinfo
->cmap
, 256, 0);
1881 goto out_fb1_release
;
1883 if (viafb_dual_fb
&& (viafb_primary_dev
== LCD_Device
)
1884 && (viaparinfo
->chip_info
->gfx_chip_name
== UNICHROME_CLE266
)) {
1885 rc
= register_framebuffer(viafbinfo1
);
1887 goto out_dealloc_cmap
;
1889 rc
= register_framebuffer(viafbinfo
);
1891 goto out_fb1_unreg_lcd_cle266
;
1893 if (viafb_dual_fb
&& ((viafb_primary_dev
!= LCD_Device
)
1894 || (viaparinfo
->chip_info
->gfx_chip_name
!=
1895 UNICHROME_CLE266
))) {
1896 rc
= register_framebuffer(viafbinfo1
);
1900 DEBUG_MSG(KERN_INFO
"fb%d: %s frame buffer device %dx%d-%dbpp\n",
1901 viafbinfo
->node
, viafbinfo
->fix
.id
, default_var
.xres
,
1902 default_var
.yres
, default_var
.bits_per_pixel
);
1904 viafb_init_proc(viaparinfo
->shared
);
1905 viafb_init_dac(IGA2
);
1908 viafb_pm_register(&viafb_fb_pm_hooks
);
1913 unregister_framebuffer(viafbinfo
);
1914 out_fb1_unreg_lcd_cle266
:
1915 if (viafb_dual_fb
&& (viafb_primary_dev
== LCD_Device
)
1916 && (viaparinfo
->chip_info
->gfx_chip_name
== UNICHROME_CLE266
))
1917 unregister_framebuffer(viafbinfo1
);
1919 fb_dealloc_cmap(&viafbinfo
->cmap
);
1922 framebuffer_release(viafbinfo1
);
1924 framebuffer_release(viafbinfo
);
1928 void __devexit
via_fb_pci_remove(struct pci_dev
*pdev
)
1930 DEBUG_MSG(KERN_INFO
"via_pci_remove!\n");
1931 fb_dealloc_cmap(&viafbinfo
->cmap
);
1932 unregister_framebuffer(viafbinfo
);
1934 unregister_framebuffer(viafbinfo1
);
1935 viafb_remove_proc(viaparinfo
->shared
);
1936 framebuffer_release(viafbinfo
);
1938 framebuffer_release(viafbinfo1
);
1942 static int __init
viafb_setup(void)
1947 DEBUG_MSG(KERN_INFO
"viafb_setup!\n");
1949 if (fb_get_options("viafb", &options
))
1952 if (!options
|| !*options
)
1955 while ((this_opt
= strsep(&options
, ",")) != NULL
) {
1959 if (!strncmp(this_opt
, "viafb_mode1=", 12))
1960 viafb_mode1
= kstrdup(this_opt
+ 12, GFP_KERNEL
);
1961 else if (!strncmp(this_opt
, "viafb_mode=", 11))
1962 viafb_mode
= kstrdup(this_opt
+ 11, GFP_KERNEL
);
1963 else if (!strncmp(this_opt
, "viafb_bpp1=", 11))
1964 strict_strtoul(this_opt
+ 11, 0,
1965 (unsigned long *)&viafb_bpp1
);
1966 else if (!strncmp(this_opt
, "viafb_bpp=", 10))
1967 strict_strtoul(this_opt
+ 10, 0,
1968 (unsigned long *)&viafb_bpp
);
1969 else if (!strncmp(this_opt
, "viafb_refresh1=", 15))
1970 strict_strtoul(this_opt
+ 15, 0,
1971 (unsigned long *)&viafb_refresh1
);
1972 else if (!strncmp(this_opt
, "viafb_refresh=", 14))
1973 strict_strtoul(this_opt
+ 14, 0,
1974 (unsigned long *)&viafb_refresh
);
1975 else if (!strncmp(this_opt
, "viafb_lcd_dsp_method=", 21))
1976 strict_strtoul(this_opt
+ 21, 0,
1977 (unsigned long *)&viafb_lcd_dsp_method
);
1978 else if (!strncmp(this_opt
, "viafb_lcd_panel_id=", 19))
1979 strict_strtoul(this_opt
+ 19, 0,
1980 (unsigned long *)&viafb_lcd_panel_id
);
1981 else if (!strncmp(this_opt
, "viafb_accel=", 12))
1982 strict_strtoul(this_opt
+ 12, 0,
1983 (unsigned long *)&viafb_accel
);
1984 else if (!strncmp(this_opt
, "viafb_SAMM_ON=", 14))
1985 strict_strtoul(this_opt
+ 14, 0,
1986 (unsigned long *)&viafb_SAMM_ON
);
1987 else if (!strncmp(this_opt
, "viafb_active_dev=", 17))
1988 viafb_active_dev
= kstrdup(this_opt
+ 17, GFP_KERNEL
);
1989 else if (!strncmp(this_opt
,
1990 "viafb_display_hardware_layout=", 30))
1991 strict_strtoul(this_opt
+ 30, 0,
1992 (unsigned long *)&viafb_display_hardware_layout
);
1993 else if (!strncmp(this_opt
, "viafb_second_size=", 18))
1994 strict_strtoul(this_opt
+ 18, 0,
1995 (unsigned long *)&viafb_second_size
);
1996 else if (!strncmp(this_opt
,
1997 "viafb_platform_epia_dvi=", 24))
1998 strict_strtoul(this_opt
+ 24, 0,
1999 (unsigned long *)&viafb_platform_epia_dvi
);
2000 else if (!strncmp(this_opt
,
2001 "viafb_device_lcd_dualedge=", 26))
2002 strict_strtoul(this_opt
+ 26, 0,
2003 (unsigned long *)&viafb_device_lcd_dualedge
);
2004 else if (!strncmp(this_opt
, "viafb_bus_width=", 16))
2005 strict_strtoul(this_opt
+ 16, 0,
2006 (unsigned long *)&viafb_bus_width
);
2007 else if (!strncmp(this_opt
, "viafb_lcd_mode=", 15))
2008 strict_strtoul(this_opt
+ 15, 0,
2009 (unsigned long *)&viafb_lcd_mode
);
2010 else if (!strncmp(this_opt
, "viafb_lcd_port=", 15))
2011 viafb_lcd_port
= kstrdup(this_opt
+ 15, GFP_KERNEL
);
2012 else if (!strncmp(this_opt
, "viafb_dvi_port=", 15))
2013 viafb_dvi_port
= kstrdup(this_opt
+ 15, GFP_KERNEL
);
2020 * These are called out of via-core for now.
2022 int __init
viafb_init(void)
2024 u32 dummy_x
, dummy_y
;
2027 if (machine_is_olpc())
2028 /* Apply XO-1.5-specific configuration. */
2029 viafb_lcd_panel_id
= 23;
2036 if (parse_mode(viafb_mode
, &dummy_x
, &dummy_y
)
2037 || !viafb_get_mode(dummy_x
, dummy_y
)
2038 || parse_mode(viafb_mode1
, &dummy_x
, &dummy_y
)
2039 || !viafb_get_mode(dummy_x
, dummy_y
)
2040 || viafb_bpp
< 0 || viafb_bpp
> 32
2041 || viafb_bpp1
< 0 || viafb_bpp1
> 32
2042 || parse_active_dev())
2046 "VIA Graphics Integration Chipset framebuffer %d.%d initializing\n",
2047 VERSION_MAJOR
, VERSION_MINOR
);
2051 void __exit
viafb_exit(void)
2053 DEBUG_MSG(KERN_INFO
"viafb_exit!\n");
2056 static struct fb_ops viafb_ops
= {
2057 .owner
= THIS_MODULE
,
2058 .fb_open
= viafb_open
,
2059 .fb_release
= viafb_release
,
2060 .fb_check_var
= viafb_check_var
,
2061 .fb_set_par
= viafb_set_par
,
2062 .fb_setcolreg
= viafb_setcolreg
,
2063 .fb_pan_display
= viafb_pan_display
,
2064 .fb_blank
= viafb_blank
,
2065 .fb_fillrect
= viafb_fillrect
,
2066 .fb_copyarea
= viafb_copyarea
,
2067 .fb_imageblit
= viafb_imageblit
,
2068 .fb_cursor
= viafb_cursor
,
2069 .fb_ioctl
= viafb_ioctl
,
2070 .fb_sync
= viafb_sync
,
2075 module_param(viafb_mode
, charp
, S_IRUSR
);
2076 MODULE_PARM_DESC(viafb_mode
, "Set resolution (default=640x480)");
2078 module_param(viafb_mode1
, charp
, S_IRUSR
);
2079 MODULE_PARM_DESC(viafb_mode1
, "Set resolution (default=640x480)");
2081 module_param(viafb_bpp
, int, S_IRUSR
);
2082 MODULE_PARM_DESC(viafb_bpp
, "Set color depth (default=32bpp)");
2084 module_param(viafb_bpp1
, int, S_IRUSR
);
2085 MODULE_PARM_DESC(viafb_bpp1
, "Set color depth (default=32bpp)");
2087 module_param(viafb_refresh
, int, S_IRUSR
);
2088 MODULE_PARM_DESC(viafb_refresh
,
2089 "Set CRT viafb_refresh rate (default = 60)");
2091 module_param(viafb_refresh1
, int, S_IRUSR
);
2092 MODULE_PARM_DESC(viafb_refresh1
,
2093 "Set CRT refresh rate (default = 60)");
2095 module_param(viafb_lcd_panel_id
, int, S_IRUSR
);
2096 MODULE_PARM_DESC(viafb_lcd_panel_id
,
2097 "Set Flat Panel type(Default=1024x768)");
2099 module_param(viafb_lcd_dsp_method
, int, S_IRUSR
);
2100 MODULE_PARM_DESC(viafb_lcd_dsp_method
,
2101 "Set Flat Panel display scaling method.(Default=Expandsion)");
2103 module_param(viafb_SAMM_ON
, int, S_IRUSR
);
2104 MODULE_PARM_DESC(viafb_SAMM_ON
,
2105 "Turn on/off flag of SAMM(Default=OFF)");
2107 module_param(viafb_accel
, int, S_IRUSR
);
2108 MODULE_PARM_DESC(viafb_accel
,
2109 "Set 2D Hardware Acceleration: 0 = OFF, 1 = ON (default)");
2111 module_param(viafb_active_dev
, charp
, S_IRUSR
);
2112 MODULE_PARM_DESC(viafb_active_dev
, "Specify active devices.");
2114 module_param(viafb_display_hardware_layout
, int, S_IRUSR
);
2115 MODULE_PARM_DESC(viafb_display_hardware_layout
,
2116 "Display Hardware Layout (LCD Only, DVI Only...,etc)");
2118 module_param(viafb_second_size
, int, S_IRUSR
);
2119 MODULE_PARM_DESC(viafb_second_size
,
2120 "Set secondary device memory size");
2122 module_param(viafb_dual_fb
, int, S_IRUSR
);
2123 MODULE_PARM_DESC(viafb_dual_fb
,
2124 "Turn on/off flag of dual framebuffer devices.(Default = OFF)");
2126 module_param(viafb_platform_epia_dvi
, int, S_IRUSR
);
2127 MODULE_PARM_DESC(viafb_platform_epia_dvi
,
2128 "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)");
2130 module_param(viafb_device_lcd_dualedge
, int, S_IRUSR
);
2131 MODULE_PARM_DESC(viafb_device_lcd_dualedge
,
2132 "Turn on/off flag of dual edge panel.(Default = OFF)");
2134 module_param(viafb_bus_width
, int, S_IRUSR
);
2135 MODULE_PARM_DESC(viafb_bus_width
,
2136 "Set bus width of panel.(Default = 12)");
2138 module_param(viafb_lcd_mode
, int, S_IRUSR
);
2139 MODULE_PARM_DESC(viafb_lcd_mode
,
2140 "Set Flat Panel mode(Default=OPENLDI)");
2142 module_param(viafb_lcd_port
, charp
, S_IRUSR
);
2143 MODULE_PARM_DESC(viafb_lcd_port
, "Specify LCD output port.");
2145 module_param(viafb_dvi_port
, charp
, S_IRUSR
);
2146 MODULE_PARM_DESC(viafb_dvi_port
, "Specify DVI output port.");
2148 MODULE_LICENSE("GPL");