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_offset
;
42 static int viafb_second_size
;
44 static int viafb_accel
= 1;
46 /* Added for specifying active devices.*/
47 static char *viafb_active_dev
;
49 /*Added for specify lcd output port*/
50 static char *viafb_lcd_port
= "";
51 static char *viafb_dvi_port
= "";
53 static void retrieve_device_setting(struct viafb_ioctl_setting
55 static int viafb_pan_display(struct fb_var_screeninfo
*var
,
56 struct fb_info
*info
);
58 static struct fb_ops viafb_ops
;
60 /* supported output devices on each IGP
61 * only CX700, VX800, VX855, VX900 were documented
62 * VIA_CRT should be everywhere
63 * VIA_6C can be onle pre-CX700 (probably only on CLE266) as 6C is used for PLL
64 * source selection on CX700 and later
65 * K400 seems to support VIA_96, VIA_DVP1, VIA_LVDS{1,2} as in viamode.c
67 static const u32 supported_odev_map
[] = {
68 [UNICHROME_CLE266
] = VIA_CRT
| VIA_LDVP0
| VIA_LDVP1
,
69 [UNICHROME_K400
] = VIA_CRT
| VIA_DVP0
| VIA_DVP1
| VIA_LVDS1
71 [UNICHROME_K800
] = VIA_CRT
| VIA_DVP0
| VIA_DVP1
| VIA_LVDS1
73 [UNICHROME_PM800
] = VIA_CRT
| VIA_DVP0
| VIA_DVP1
| VIA_LVDS1
75 [UNICHROME_CN700
] = VIA_CRT
| VIA_DVP0
| VIA_DVP1
| VIA_LVDS1
77 [UNICHROME_CX700
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
78 [UNICHROME_CN750
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
79 [UNICHROME_K8M890
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
80 [UNICHROME_P4M890
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
81 [UNICHROME_P4M900
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
82 [UNICHROME_VX800
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
83 [UNICHROME_VX855
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
84 [UNICHROME_VX900
] = VIA_CRT
| VIA_DVP1
| VIA_LVDS1
| VIA_LVDS2
,
87 static void viafb_fill_var_color_info(struct fb_var_screeninfo
*var
, u8 depth
)
90 var
->red
.msb_right
= 0;
91 var
->green
.msb_right
= 0;
92 var
->blue
.msb_right
= 0;
93 var
->transp
.offset
= 0;
94 var
->transp
.length
= 0;
95 var
->transp
.msb_right
= 0;
99 var
->bits_per_pixel
= 8;
101 var
->green
.offset
= 0;
102 var
->blue
.offset
= 0;
104 var
->green
.length
= 8;
105 var
->blue
.length
= 8;
108 var
->bits_per_pixel
= 16;
109 var
->red
.offset
= 10;
110 var
->green
.offset
= 5;
111 var
->blue
.offset
= 0;
113 var
->green
.length
= 5;
114 var
->blue
.length
= 5;
117 var
->bits_per_pixel
= 16;
118 var
->red
.offset
= 11;
119 var
->green
.offset
= 5;
120 var
->blue
.offset
= 0;
122 var
->green
.length
= 6;
123 var
->blue
.length
= 5;
126 var
->bits_per_pixel
= 32;
127 var
->red
.offset
= 16;
128 var
->green
.offset
= 8;
129 var
->blue
.offset
= 0;
131 var
->green
.length
= 8;
132 var
->blue
.length
= 8;
135 var
->bits_per_pixel
= 32;
136 var
->red
.offset
= 20;
137 var
->green
.offset
= 10;
138 var
->blue
.offset
= 0;
139 var
->red
.length
= 10;
140 var
->green
.length
= 10;
141 var
->blue
.length
= 10;
146 static void viafb_update_fix(struct fb_info
*info
)
148 u32 bpp
= info
->var
.bits_per_pixel
;
151 bpp
== 8 ? FB_VISUAL_PSEUDOCOLOR
: FB_VISUAL_TRUECOLOR
;
152 info
->fix
.line_length
= ALIGN(info
->var
.xres_virtual
* bpp
/ 8,
156 static void viafb_setup_fixinfo(struct fb_fix_screeninfo
*fix
,
157 struct viafb_par
*viaparinfo
)
159 memset(fix
, 0, sizeof(struct fb_fix_screeninfo
));
160 strcpy(fix
->id
, viafb_name
);
162 fix
->smem_start
= viaparinfo
->fbmem
;
163 fix
->smem_len
= viaparinfo
->fbmem_free
;
165 fix
->type
= FB_TYPE_PACKED_PIXELS
;
167 fix
->visual
= FB_VISUAL_TRUECOLOR
;
169 fix
->xpanstep
= fix
->ywrapstep
= 0;
172 /* Just tell the accel name */
173 viafbinfo
->fix
.accel
= FB_ACCEL_VIA_UNICHROME
;
175 static int viafb_open(struct fb_info
*info
, int user
)
177 DEBUG_MSG(KERN_INFO
"viafb_open!\n");
181 static int viafb_release(struct fb_info
*info
, int user
)
183 DEBUG_MSG(KERN_INFO
"viafb_release!\n");
187 static inline int get_var_refresh(struct fb_var_screeninfo
*var
)
191 htotal
= var
->left_margin
+ var
->xres
+ var
->right_margin
193 vtotal
= var
->upper_margin
+ var
->yres
+ var
->lower_margin
195 return PICOS2KHZ(var
->pixclock
) * 1000 / (htotal
* vtotal
);
198 static int viafb_check_var(struct fb_var_screeninfo
*var
,
199 struct fb_info
*info
)
202 struct viafb_par
*ppar
= info
->par
;
205 DEBUG_MSG(KERN_INFO
"viafb_check_var!\n");
207 /* HW neither support interlacte nor double-scaned mode */
208 if (var
->vmode
& FB_VMODE_INTERLACED
|| var
->vmode
& FB_VMODE_DOUBLE
)
211 /* the refresh rate is not important here, as we only want to know
212 * whether the resolution exists
214 if (!viafb_get_best_mode(var
->xres
, var
->yres
, 60)) {
216 "viafb: Mode %dx%dx%d not supported!!\n",
217 var
->xres
, var
->yres
, var
->bits_per_pixel
);
221 depth
= fb_get_color_depth(var
, &info
->fix
);
223 depth
= var
->bits_per_pixel
;
225 if (depth
< 0 || depth
> 32)
229 else if (depth
== 15 && viafb_dual_fb
&& ppar
->iga_path
== IGA1
)
231 else if (depth
== 30)
235 else if (depth
<= 16)
240 viafb_fill_var_color_info(var
, depth
);
241 if (var
->xres_virtual
< var
->xres
)
242 var
->xres_virtual
= var
->xres
;
244 line
= ALIGN(var
->xres_virtual
* var
->bits_per_pixel
/ 8,
246 if (line
> VIA_PITCH_MAX
|| line
* var
->yres_virtual
> ppar
->memsize
)
249 /* Based on var passed in to calculate the refresh,
250 * because our driver use some modes special.
252 refresh
= viafb_get_refresh(var
->xres
, var
->yres
,
253 get_var_refresh(var
));
255 /* Adjust var according to our driver's own table */
256 viafb_fill_var_timing_info(var
,
257 viafb_get_best_mode(var
->xres
, var
->yres
, refresh
));
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
;
269 DEBUG_MSG(KERN_INFO
"viafb_set_par!\n");
271 viafb_update_fix(info
);
272 viapar
->depth
= fb_get_color_depth(&info
->var
, &info
->fix
);
273 viafb_update_device_setting(viafbinfo
->var
.xres
, viafbinfo
->var
.yres
,
274 viafbinfo
->var
.bits_per_pixel
, 0);
277 viafb_update_device_setting(viafbinfo1
->var
.xres
,
278 viafbinfo1
->var
.yres
, viafbinfo1
->var
.bits_per_pixel
,
280 } else if (viafb_SAMM_ON
== 1) {
282 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
283 viafb_second_xres
, viafb_second_yres
, viafb_bpp1
);
285 viafb_update_device_setting(viafb_second_xres
,
286 viafb_second_yres
, viafb_bpp1
, 1);
289 refresh
= viafb_get_refresh(info
->var
.xres
, info
->var
.yres
,
290 get_var_refresh(&info
->var
));
291 if (viafb_get_best_mode(viafbinfo
->var
.xres
, viafbinfo
->var
.yres
,
293 if (viafb_dual_fb
&& viapar
->iga_path
== IGA2
) {
294 viafb_bpp1
= info
->var
.bits_per_pixel
;
295 viafb_refresh1
= refresh
;
297 viafb_bpp
= info
->var
.bits_per_pixel
;
298 viafb_refresh
= refresh
;
301 if (info
->var
.accel_flags
& FB_ACCELF_TEXT
)
302 info
->flags
&= ~FBINFO_HWACCEL_DISABLED
;
304 info
->flags
|= FBINFO_HWACCEL_DISABLED
;
305 viafb_setmode(info
->var
.bits_per_pixel
, viafb_bpp1
);
306 viafb_pan_display(&info
->var
, info
);
312 /* Set one color register */
313 static int viafb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
314 unsigned blue
, unsigned transp
, struct fb_info
*info
)
316 struct viafb_par
*viapar
= info
->par
;
319 if (info
->fix
.visual
== FB_VISUAL_PSEUDOCOLOR
) {
323 if (!viafb_dual_fb
|| viapar
->iga_path
== IGA1
)
324 viafb_set_primary_color_register(regno
, red
>> 8,
325 green
>> 8, blue
>> 8);
327 if (!viafb_dual_fb
|| viapar
->iga_path
== IGA2
)
328 viafb_set_secondary_color_register(regno
, red
>> 8,
329 green
>> 8, blue
>> 8);
334 r
= (red
>> (16 - info
->var
.red
.length
))
335 << info
->var
.red
.offset
;
336 b
= (blue
>> (16 - info
->var
.blue
.length
))
337 << info
->var
.blue
.offset
;
338 g
= (green
>> (16 - info
->var
.green
.length
))
339 << info
->var
.green
.offset
;
340 ((u32
*) info
->pseudo_palette
)[regno
] = r
| g
| b
;
346 static int viafb_pan_display(struct fb_var_screeninfo
*var
,
347 struct fb_info
*info
)
349 struct viafb_par
*viapar
= info
->par
;
350 u32 vram_addr
= viapar
->vram_addr
351 + var
->yoffset
* info
->fix
.line_length
352 + var
->xoffset
* info
->var
.bits_per_pixel
/ 8;
354 DEBUG_MSG(KERN_DEBUG
"viafb_pan_display, address = %d\n", vram_addr
);
355 if (!viafb_dual_fb
) {
356 via_set_primary_address(vram_addr
);
357 via_set_secondary_address(vram_addr
);
358 } else if (viapar
->iga_path
== IGA1
)
359 via_set_primary_address(vram_addr
);
361 via_set_secondary_address(vram_addr
);
366 static int viafb_blank(int blank_mode
, struct fb_info
*info
)
368 DEBUG_MSG(KERN_INFO
"viafb_blank!\n");
369 /* clear DPMS setting */
371 switch (blank_mode
) {
372 case FB_BLANK_UNBLANK
:
373 /* Screen: On, HSync: On, VSync: On */
374 /* control CRT monitor power management */
375 via_set_state(VIA_CRT
, VIA_STATE_ON
);
377 case FB_BLANK_HSYNC_SUSPEND
:
378 /* Screen: Off, HSync: Off, VSync: On */
379 /* control CRT monitor power management */
380 via_set_state(VIA_CRT
, VIA_STATE_STANDBY
);
382 case FB_BLANK_VSYNC_SUSPEND
:
383 /* Screen: Off, HSync: On, VSync: Off */
384 /* control CRT monitor power management */
385 via_set_state(VIA_CRT
, VIA_STATE_SUSPEND
);
387 case FB_BLANK_POWERDOWN
:
388 /* Screen: Off, HSync: Off, VSync: Off */
389 /* control CRT monitor power management */
390 via_set_state(VIA_CRT
, VIA_STATE_OFF
);
397 static int viafb_ioctl(struct fb_info
*info
, u_int cmd
, u_long arg
)
400 struct viafb_ioctl_mode viamode
;
401 struct viafb_ioctl_samm viasamm
;
402 struct viafb_driver_version driver_version
;
403 struct fb_var_screeninfo sec_var
;
404 struct _panel_size_pos_info panel_pos_size_para
;
405 struct viafb_ioctl_setting viafb_setting
;
406 struct device_t active_dev
;
409 u32
*viafb_gamma_table
;
410 char driver_name
[] = "viafb";
412 u32 __user
*argp
= (u32 __user
*) arg
;
415 DEBUG_MSG(KERN_INFO
"viafb_ioctl: 0x%X !!\n", cmd
);
416 printk(KERN_WARNING
"viafb_ioctl: Please avoid this interface as it is unstable and might change or vanish at any time!\n");
417 memset(&u
, 0, sizeof(u
));
420 case VIAFB_GET_CHIP_INFO
:
421 if (copy_to_user(argp
, viaparinfo
->chip_info
,
422 sizeof(struct chip_information
)))
425 case VIAFB_GET_INFO_SIZE
:
426 return put_user((u32
)sizeof(struct viafb_ioctl_info
), argp
);
428 return viafb_ioctl_get_viafb_info(arg
);
430 return put_user(viafb_ioctl_hotplug(info
->var
.xres
,
432 info
->var
.bits_per_pixel
), argp
);
433 case VIAFB_SET_HOTPLUG_FLAG
:
434 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
436 viafb_hotplug
= (gpu32
) ? 1 : 0;
438 case VIAFB_GET_RESOLUTION
:
439 u
.viamode
.xres
= (u32
) viafb_hotplug_Xres
;
440 u
.viamode
.yres
= (u32
) viafb_hotplug_Yres
;
441 u
.viamode
.refresh
= (u32
) viafb_hotplug_refresh
;
442 u
.viamode
.bpp
= (u32
) viafb_hotplug_bpp
;
443 if (viafb_SAMM_ON
== 1) {
444 u
.viamode
.xres_sec
= viafb_second_xres
;
445 u
.viamode
.yres_sec
= viafb_second_yres
;
446 u
.viamode
.virtual_xres_sec
= viafb_dual_fb
? viafbinfo1
->var
.xres_virtual
: viafbinfo
->var
.xres_virtual
;
447 u
.viamode
.virtual_yres_sec
= viafb_dual_fb
? viafbinfo1
->var
.yres_virtual
: viafbinfo
->var
.yres_virtual
;
448 u
.viamode
.refresh_sec
= viafb_refresh1
;
449 u
.viamode
.bpp_sec
= viafb_bpp1
;
451 u
.viamode
.xres_sec
= 0;
452 u
.viamode
.yres_sec
= 0;
453 u
.viamode
.virtual_xres_sec
= 0;
454 u
.viamode
.virtual_yres_sec
= 0;
455 u
.viamode
.refresh_sec
= 0;
456 u
.viamode
.bpp_sec
= 0;
458 if (copy_to_user(argp
, &u
.viamode
, sizeof(u
.viamode
)))
461 case VIAFB_GET_SAMM_INFO
:
462 u
.viasamm
.samm_status
= viafb_SAMM_ON
;
464 if (viafb_SAMM_ON
== 1) {
466 u
.viasamm
.size_prim
= viaparinfo
->fbmem_free
;
467 u
.viasamm
.size_sec
= viaparinfo1
->fbmem_free
;
469 if (viafb_second_size
) {
470 u
.viasamm
.size_prim
=
471 viaparinfo
->fbmem_free
-
472 viafb_second_size
* 1024 * 1024;
474 viafb_second_size
* 1024 * 1024;
476 u
.viasamm
.size_prim
=
477 viaparinfo
->fbmem_free
>> 1;
479 (viaparinfo
->fbmem_free
>> 1);
482 u
.viasamm
.mem_base
= viaparinfo
->fbmem
;
483 u
.viasamm
.offset_sec
= viafb_second_offset
;
485 u
.viasamm
.size_prim
=
486 viaparinfo
->memsize
- viaparinfo
->fbmem_used
;
487 u
.viasamm
.size_sec
= 0;
488 u
.viasamm
.mem_base
= viaparinfo
->fbmem
;
489 u
.viasamm
.offset_sec
= 0;
492 if (copy_to_user(argp
, &u
.viasamm
, sizeof(u
.viasamm
)))
496 case VIAFB_TURN_ON_OUTPUT_DEVICE
:
497 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
499 if (gpu32
& CRT_Device
)
500 via_set_state(VIA_CRT
, VIA_STATE_ON
);
501 if (gpu32
& DVI_Device
)
503 if (gpu32
& LCD_Device
)
506 case VIAFB_TURN_OFF_OUTPUT_DEVICE
:
507 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
509 if (gpu32
& CRT_Device
)
510 via_set_state(VIA_CRT
, VIA_STATE_OFF
);
511 if (gpu32
& DVI_Device
)
513 if (gpu32
& LCD_Device
)
516 case VIAFB_GET_DEVICE
:
517 u
.active_dev
.crt
= viafb_CRT_ON
;
518 u
.active_dev
.dvi
= viafb_DVI_ON
;
519 u
.active_dev
.lcd
= viafb_LCD_ON
;
520 u
.active_dev
.samm
= viafb_SAMM_ON
;
521 u
.active_dev
.primary_dev
= viafb_primary_dev
;
523 u
.active_dev
.lcd_dsp_cent
= viafb_lcd_dsp_method
;
524 u
.active_dev
.lcd_panel_id
= viafb_lcd_panel_id
;
525 u
.active_dev
.lcd_mode
= viafb_lcd_mode
;
527 u
.active_dev
.xres
= viafb_hotplug_Xres
;
528 u
.active_dev
.yres
= viafb_hotplug_Yres
;
530 u
.active_dev
.xres1
= viafb_second_xres
;
531 u
.active_dev
.yres1
= viafb_second_yres
;
533 u
.active_dev
.bpp
= viafb_bpp
;
534 u
.active_dev
.bpp1
= viafb_bpp1
;
535 u
.active_dev
.refresh
= viafb_refresh
;
536 u
.active_dev
.refresh1
= viafb_refresh1
;
538 u
.active_dev
.epia_dvi
= viafb_platform_epia_dvi
;
539 u
.active_dev
.lcd_dual_edge
= viafb_device_lcd_dualedge
;
540 u
.active_dev
.bus_width
= viafb_bus_width
;
542 if (copy_to_user(argp
, &u
.active_dev
, sizeof(u
.active_dev
)))
546 case VIAFB_GET_DRIVER_VERSION
:
547 u
.driver_version
.iMajorNum
= VERSION_MAJOR
;
548 u
.driver_version
.iKernelNum
= VERSION_KERNEL
;
549 u
.driver_version
.iOSNum
= VERSION_OS
;
550 u
.driver_version
.iMinorNum
= VERSION_MINOR
;
552 if (copy_to_user(argp
, &u
.driver_version
,
553 sizeof(u
.driver_version
)))
558 case VIAFB_GET_DEVICE_INFO
:
560 retrieve_device_setting(&u
.viafb_setting
);
562 if (copy_to_user(argp
, &u
.viafb_setting
,
563 sizeof(u
.viafb_setting
)))
568 case VIAFB_GET_DEVICE_SUPPORT
:
569 viafb_get_device_support_state(&state_info
);
570 if (put_user(state_info
, argp
))
574 case VIAFB_GET_DEVICE_CONNECT
:
575 viafb_get_device_connect_state(&state_info
);
576 if (put_user(state_info
, argp
))
580 case VIAFB_GET_PANEL_SUPPORT_EXPAND
:
582 viafb_lcd_get_support_expand_state(info
->var
.xres
,
584 if (put_user(state_info
, argp
))
588 case VIAFB_GET_DRIVER_NAME
:
589 if (copy_to_user(argp
, driver_name
, sizeof(driver_name
)))
593 case VIAFB_SET_GAMMA_LUT
:
594 viafb_gamma_table
= memdup_user(argp
, 256 * sizeof(u32
));
595 if (IS_ERR(viafb_gamma_table
))
596 return PTR_ERR(viafb_gamma_table
);
597 viafb_set_gamma_table(viafb_bpp
, viafb_gamma_table
);
598 kfree(viafb_gamma_table
);
601 case VIAFB_GET_GAMMA_LUT
:
602 viafb_gamma_table
= kmalloc(256 * sizeof(u32
), GFP_KERNEL
);
603 if (!viafb_gamma_table
)
605 viafb_get_gamma_table(viafb_gamma_table
);
606 if (copy_to_user(argp
, viafb_gamma_table
,
607 256 * sizeof(u32
))) {
608 kfree(viafb_gamma_table
);
611 kfree(viafb_gamma_table
);
614 case VIAFB_GET_GAMMA_SUPPORT_STATE
:
615 viafb_get_gamma_support_state(viafb_bpp
, &state_info
);
616 if (put_user(state_info
, argp
))
619 case VIAFB_SYNC_SURFACE
:
620 DEBUG_MSG(KERN_INFO
"lobo VIAFB_SYNC_SURFACE\n");
622 case VIAFB_GET_DRIVER_CAPS
:
625 case VIAFB_GET_PANEL_MAX_SIZE
:
626 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
627 sizeof(u
.panel_pos_size_para
)))
629 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
630 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
631 sizeof(u
.panel_pos_size_para
)))
634 case VIAFB_GET_PANEL_MAX_POSITION
:
635 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
636 sizeof(u
.panel_pos_size_para
)))
638 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
639 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
640 sizeof(u
.panel_pos_size_para
)))
644 case VIAFB_GET_PANEL_POSITION
:
645 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
646 sizeof(u
.panel_pos_size_para
)))
648 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
649 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
650 sizeof(u
.panel_pos_size_para
)))
653 case VIAFB_GET_PANEL_SIZE
:
654 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
655 sizeof(u
.panel_pos_size_para
)))
657 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
658 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
659 sizeof(u
.panel_pos_size_para
)))
663 case VIAFB_SET_PANEL_POSITION
:
664 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
665 sizeof(u
.panel_pos_size_para
)))
668 case VIAFB_SET_PANEL_SIZE
:
669 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
670 sizeof(u
.panel_pos_size_para
)))
681 static void viafb_fillrect(struct fb_info
*info
,
682 const struct fb_fillrect
*rect
)
684 struct viafb_par
*viapar
= info
->par
;
685 struct viafb_shared
*shared
= viapar
->shared
;
689 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
) {
690 cfb_fillrect(info
, rect
);
694 if (!rect
->width
|| !rect
->height
)
697 if (info
->fix
.visual
== FB_VISUAL_TRUECOLOR
)
698 fg_color
= ((u32
*)info
->pseudo_palette
)[rect
->color
];
700 fg_color
= rect
->color
;
702 if (rect
->rop
== ROP_XOR
)
707 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: fillrect\n");
708 if (shared
->hw_bitblt(shared
->vdev
->engine_mmio
, VIA_BITBLT_FILL
,
709 rect
->width
, rect
->height
, info
->var
.bits_per_pixel
,
710 viapar
->vram_addr
, info
->fix
.line_length
, rect
->dx
, rect
->dy
,
711 NULL
, 0, 0, 0, 0, fg_color
, 0, rop
))
712 cfb_fillrect(info
, rect
);
715 static void viafb_copyarea(struct fb_info
*info
,
716 const struct fb_copyarea
*area
)
718 struct viafb_par
*viapar
= info
->par
;
719 struct viafb_shared
*shared
= viapar
->shared
;
721 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
) {
722 cfb_copyarea(info
, area
);
726 if (!area
->width
|| !area
->height
)
729 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: copyarea\n");
730 if (shared
->hw_bitblt(shared
->vdev
->engine_mmio
, VIA_BITBLT_COLOR
,
731 area
->width
, area
->height
, info
->var
.bits_per_pixel
,
732 viapar
->vram_addr
, info
->fix
.line_length
, area
->dx
, area
->dy
,
733 NULL
, viapar
->vram_addr
, info
->fix
.line_length
,
734 area
->sx
, area
->sy
, 0, 0, 0))
735 cfb_copyarea(info
, area
);
738 static void viafb_imageblit(struct fb_info
*info
,
739 const struct fb_image
*image
)
741 struct viafb_par
*viapar
= info
->par
;
742 struct viafb_shared
*shared
= viapar
->shared
;
743 u32 fg_color
= 0, bg_color
= 0;
746 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
||
747 (image
->depth
!= 1 && image
->depth
!= viapar
->depth
)) {
748 cfb_imageblit(info
, image
);
752 if (image
->depth
== 1) {
753 op
= VIA_BITBLT_MONO
;
754 if (info
->fix
.visual
== FB_VISUAL_TRUECOLOR
) {
756 ((u32
*)info
->pseudo_palette
)[image
->fg_color
];
758 ((u32
*)info
->pseudo_palette
)[image
->bg_color
];
760 fg_color
= image
->fg_color
;
761 bg_color
= image
->bg_color
;
764 op
= VIA_BITBLT_COLOR
;
766 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: imageblit\n");
767 if (shared
->hw_bitblt(shared
->vdev
->engine_mmio
, op
,
768 image
->width
, image
->height
, info
->var
.bits_per_pixel
,
769 viapar
->vram_addr
, info
->fix
.line_length
, image
->dx
, image
->dy
,
770 (u32
*)image
->data
, 0, 0, 0, 0, fg_color
, bg_color
, 0))
771 cfb_imageblit(info
, image
);
774 static int viafb_cursor(struct fb_info
*info
, struct fb_cursor
*cursor
)
776 struct viafb_par
*viapar
= info
->par
;
777 void __iomem
*engine
= viapar
->shared
->vdev
->engine_mmio
;
778 u32 temp
, xx
, yy
, bg_color
= 0, fg_color
= 0,
779 chip_name
= viapar
->shared
->chip_info
.gfx_chip_name
;
780 int i
, j
= 0, cur_size
= 64;
782 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| info
!= viafbinfo
)
785 /* LCD ouput does not support hw cursors (at least on VN896) */
786 if ((chip_name
== UNICHROME_CLE266
&& viapar
->iga_path
== IGA2
) ||
790 viafb_show_hw_cursor(info
, HW_Cursor_OFF
);
792 if (cursor
->set
& FB_CUR_SETHOT
) {
793 temp
= (cursor
->hot
.x
<< 16) + cursor
->hot
.y
;
794 writel(temp
, engine
+ VIA_REG_CURSOR_ORG
);
797 if (cursor
->set
& FB_CUR_SETPOS
) {
798 yy
= cursor
->image
.dy
- info
->var
.yoffset
;
799 xx
= cursor
->image
.dx
- info
->var
.xoffset
;
802 writel(temp
, engine
+ VIA_REG_CURSOR_POS
);
805 if (cursor
->image
.width
<= 32 && cursor
->image
.height
<= 32)
807 else if (cursor
->image
.width
<= 64 && cursor
->image
.height
<= 64)
810 printk(KERN_WARNING
"viafb_cursor: The cursor is too large "
811 "%dx%d", cursor
->image
.width
, cursor
->image
.height
);
815 if (cursor
->set
& FB_CUR_SETSIZE
) {
816 temp
= readl(engine
+ VIA_REG_CURSOR_MODE
);
822 writel(temp
, engine
+ VIA_REG_CURSOR_MODE
);
825 if (cursor
->set
& FB_CUR_SETCMAP
) {
826 fg_color
= cursor
->image
.fg_color
;
827 bg_color
= cursor
->image
.bg_color
;
828 if (chip_name
== UNICHROME_CX700
||
829 chip_name
== UNICHROME_VX800
||
830 chip_name
== UNICHROME_VX855
||
831 chip_name
== UNICHROME_VX900
) {
833 ((info
->cmap
.red
[fg_color
] & 0xFFC0) << 14) |
834 ((info
->cmap
.green
[fg_color
] & 0xFFC0) << 4) |
835 ((info
->cmap
.blue
[fg_color
] & 0xFFC0) >> 6);
837 ((info
->cmap
.red
[bg_color
] & 0xFFC0) << 14) |
838 ((info
->cmap
.green
[bg_color
] & 0xFFC0) << 4) |
839 ((info
->cmap
.blue
[bg_color
] & 0xFFC0) >> 6);
842 ((info
->cmap
.red
[fg_color
] & 0xFF00) << 8) |
843 (info
->cmap
.green
[fg_color
] & 0xFF00) |
844 ((info
->cmap
.blue
[fg_color
] & 0xFF00) >> 8);
846 ((info
->cmap
.red
[bg_color
] & 0xFF00) << 8) |
847 (info
->cmap
.green
[bg_color
] & 0xFF00) |
848 ((info
->cmap
.blue
[bg_color
] & 0xFF00) >> 8);
851 writel(bg_color
, engine
+ VIA_REG_CURSOR_BG
);
852 writel(fg_color
, engine
+ VIA_REG_CURSOR_FG
);
855 if (cursor
->set
& FB_CUR_SETSHAPE
) {
857 u8 data
[CURSOR_SIZE
];
858 u32 bak
[CURSOR_SIZE
/ 4];
859 } *cr_data
= kzalloc(sizeof(*cr_data
), GFP_ATOMIC
);
860 int size
= ((cursor
->image
.width
+ 7) >> 3) *
861 cursor
->image
.height
;
866 if (cur_size
== 32) {
867 for (i
= 0; i
< (CURSOR_SIZE
/ 4); i
++) {
868 cr_data
->bak
[i
] = 0x0;
869 cr_data
->bak
[i
+ 1] = 0xFFFFFFFF;
873 for (i
= 0; i
< (CURSOR_SIZE
/ 4); i
++) {
874 cr_data
->bak
[i
] = 0x0;
875 cr_data
->bak
[i
+ 1] = 0x0;
876 cr_data
->bak
[i
+ 2] = 0xFFFFFFFF;
877 cr_data
->bak
[i
+ 3] = 0xFFFFFFFF;
882 switch (cursor
->rop
) {
884 for (i
= 0; i
< size
; i
++)
885 cr_data
->data
[i
] = cursor
->mask
[i
];
889 for (i
= 0; i
< size
; i
++)
890 cr_data
->data
[i
] = cursor
->mask
[i
];
896 if (cur_size
== 32) {
897 for (i
= 0; i
< size
; i
++) {
898 cr_data
->bak
[j
] = (u32
) cr_data
->data
[i
];
899 cr_data
->bak
[j
+ 1] = ~cr_data
->bak
[j
];
903 for (i
= 0; i
< size
; i
++) {
904 cr_data
->bak
[j
] = (u32
) cr_data
->data
[i
];
905 cr_data
->bak
[j
+ 1] = 0x0;
906 cr_data
->bak
[j
+ 2] = ~cr_data
->bak
[j
];
907 cr_data
->bak
[j
+ 3] = ~cr_data
->bak
[j
+ 1];
912 memcpy_toio(viafbinfo
->screen_base
+ viapar
->shared
->
913 cursor_vram_addr
, cr_data
->bak
, CURSOR_SIZE
);
918 viafb_show_hw_cursor(info
, HW_Cursor_ON
);
923 static int viafb_sync(struct fb_info
*info
)
925 if (!(info
->flags
& FBINFO_HWACCEL_DISABLED
))
926 viafb_wait_engine_idle(info
);
930 static int get_primary_device(void)
932 int primary_device
= 0;
933 /* Rule: device on iga1 path are the primary device. */
936 if (viaparinfo
->shared
->iga1_devices
& VIA_CRT
) {
937 DEBUG_MSG(KERN_INFO
"CRT IGA Path:%d\n", IGA1
);
938 primary_device
= CRT_Device
;
942 if (viaparinfo
->tmds_setting_info
->iga_path
== IGA1
) {
943 DEBUG_MSG(KERN_INFO
"DVI IGA Path:%d\n",
945 tmds_setting_info
->iga_path
);
946 primary_device
= DVI_Device
;
950 if (viaparinfo
->lvds_setting_info
->iga_path
== IGA1
) {
951 DEBUG_MSG(KERN_INFO
"LCD IGA Path:%d\n",
953 lvds_setting_info
->iga_path
);
954 primary_device
= LCD_Device
;
958 if (viaparinfo
->lvds_setting_info2
->iga_path
== IGA1
) {
959 DEBUG_MSG(KERN_INFO
"LCD2 IGA Path:%d\n",
961 lvds_setting_info2
->iga_path
);
962 primary_device
= LCD2_Device
;
966 return primary_device
;
969 static void retrieve_device_setting(struct viafb_ioctl_setting
973 /* get device status */
974 if (viafb_CRT_ON
== 1)
975 setting_info
->device_status
= CRT_Device
;
976 if (viafb_DVI_ON
== 1)
977 setting_info
->device_status
|= DVI_Device
;
978 if (viafb_LCD_ON
== 1)
979 setting_info
->device_status
|= LCD_Device
;
980 if (viafb_LCD2_ON
== 1)
981 setting_info
->device_status
|= LCD2_Device
;
983 setting_info
->samm_status
= viafb_SAMM_ON
;
984 setting_info
->primary_device
= get_primary_device();
986 setting_info
->first_dev_bpp
= viafb_bpp
;
987 setting_info
->second_dev_bpp
= viafb_bpp1
;
989 setting_info
->first_dev_refresh
= viafb_refresh
;
990 setting_info
->second_dev_refresh
= viafb_refresh1
;
992 setting_info
->first_dev_hor_res
= viafb_hotplug_Xres
;
993 setting_info
->first_dev_ver_res
= viafb_hotplug_Yres
;
994 setting_info
->second_dev_hor_res
= viafb_second_xres
;
995 setting_info
->second_dev_ver_res
= viafb_second_yres
;
997 /* Get lcd attributes */
998 setting_info
->lcd_attributes
.display_center
= viafb_lcd_dsp_method
;
999 setting_info
->lcd_attributes
.panel_id
= viafb_lcd_panel_id
;
1000 setting_info
->lcd_attributes
.lcd_mode
= viafb_lcd_mode
;
1003 static int __init
parse_active_dev(void)
1005 viafb_CRT_ON
= STATE_OFF
;
1006 viafb_DVI_ON
= STATE_OFF
;
1007 viafb_LCD_ON
= STATE_OFF
;
1008 viafb_LCD2_ON
= STATE_OFF
;
1009 /* 1. Modify the active status of devices. */
1010 /* 2. Keep the order of devices, so we can set corresponding
1011 IGA path to devices in SAMM case. */
1012 /* Note: The previous of active_dev is primary device,
1013 and the following is secondary device. */
1014 if (!viafb_active_dev
) {
1015 if (machine_is_olpc()) { /* LCD only */
1016 viafb_LCD_ON
= STATE_ON
;
1017 viafb_SAMM_ON
= STATE_OFF
;
1019 viafb_CRT_ON
= STATE_ON
;
1020 viafb_SAMM_ON
= STATE_OFF
;
1022 } else if (!strcmp(viafb_active_dev
, "CRT+DVI")) {
1024 viafb_CRT_ON
= STATE_ON
;
1025 viafb_DVI_ON
= STATE_ON
;
1026 viafb_primary_dev
= CRT_Device
;
1027 } else if (!strcmp(viafb_active_dev
, "DVI+CRT")) {
1029 viafb_CRT_ON
= STATE_ON
;
1030 viafb_DVI_ON
= STATE_ON
;
1031 viafb_primary_dev
= DVI_Device
;
1032 } else if (!strcmp(viafb_active_dev
, "CRT+LCD")) {
1034 viafb_CRT_ON
= STATE_ON
;
1035 viafb_LCD_ON
= STATE_ON
;
1036 viafb_primary_dev
= CRT_Device
;
1037 } else if (!strcmp(viafb_active_dev
, "LCD+CRT")) {
1039 viafb_CRT_ON
= STATE_ON
;
1040 viafb_LCD_ON
= STATE_ON
;
1041 viafb_primary_dev
= LCD_Device
;
1042 } else if (!strcmp(viafb_active_dev
, "DVI+LCD")) {
1044 viafb_DVI_ON
= STATE_ON
;
1045 viafb_LCD_ON
= STATE_ON
;
1046 viafb_primary_dev
= DVI_Device
;
1047 } else if (!strcmp(viafb_active_dev
, "LCD+DVI")) {
1049 viafb_DVI_ON
= STATE_ON
;
1050 viafb_LCD_ON
= STATE_ON
;
1051 viafb_primary_dev
= LCD_Device
;
1052 } else if (!strcmp(viafb_active_dev
, "LCD+LCD2")) {
1053 viafb_LCD_ON
= STATE_ON
;
1054 viafb_LCD2_ON
= STATE_ON
;
1055 viafb_primary_dev
= LCD_Device
;
1056 } else if (!strcmp(viafb_active_dev
, "LCD2+LCD")) {
1057 viafb_LCD_ON
= STATE_ON
;
1058 viafb_LCD2_ON
= STATE_ON
;
1059 viafb_primary_dev
= LCD2_Device
;
1060 } else if (!strcmp(viafb_active_dev
, "CRT")) {
1062 viafb_CRT_ON
= STATE_ON
;
1063 viafb_SAMM_ON
= STATE_OFF
;
1064 } else if (!strcmp(viafb_active_dev
, "DVI")) {
1066 viafb_DVI_ON
= STATE_ON
;
1067 viafb_SAMM_ON
= STATE_OFF
;
1068 } else if (!strcmp(viafb_active_dev
, "LCD")) {
1070 viafb_LCD_ON
= STATE_ON
;
1071 viafb_SAMM_ON
= STATE_OFF
;
1078 static int __devinit
parse_port(char *opt_str
, int *output_interface
)
1080 if (!strncmp(opt_str
, "DVP0", 4))
1081 *output_interface
= INTERFACE_DVP0
;
1082 else if (!strncmp(opt_str
, "DVP1", 4))
1083 *output_interface
= INTERFACE_DVP1
;
1084 else if (!strncmp(opt_str
, "DFP_HIGHLOW", 11))
1085 *output_interface
= INTERFACE_DFP
;
1086 else if (!strncmp(opt_str
, "DFP_HIGH", 8))
1087 *output_interface
= INTERFACE_DFP_HIGH
;
1088 else if (!strncmp(opt_str
, "DFP_LOW", 7))
1089 *output_interface
= INTERFACE_DFP_LOW
;
1091 *output_interface
= INTERFACE_NONE
;
1095 static void __devinit
parse_lcd_port(void)
1097 parse_port(viafb_lcd_port
, &viaparinfo
->chip_info
->lvds_chip_info
.
1099 /*Initialize to avoid unexpected behavior */
1100 viaparinfo
->chip_info
->lvds_chip_info2
.output_interface
=
1103 DEBUG_MSG(KERN_INFO
"parse_lcd_port: viafb_lcd_port:%s,interface:%d\n",
1104 viafb_lcd_port
, viaparinfo
->chip_info
->lvds_chip_info
.
1108 static void __devinit
parse_dvi_port(void)
1110 parse_port(viafb_dvi_port
, &viaparinfo
->chip_info
->tmds_chip_info
.
1113 DEBUG_MSG(KERN_INFO
"parse_dvi_port: viafb_dvi_port:%s,interface:%d\n",
1114 viafb_dvi_port
, viaparinfo
->chip_info
->tmds_chip_info
.
1118 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1121 * The proc filesystem read/write function, a simple proc implement to
1122 * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
1123 * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2],
1124 * CR9B, SR65, CR97, CR99
1126 static int viafb_dvp0_proc_show(struct seq_file
*m
, void *v
)
1128 u8 dvp0_data_dri
= 0, dvp0_clk_dri
= 0, dvp0
= 0;
1130 (viafb_read_reg(VIASR
, SR2A
) & BIT5
) >> 4 |
1131 (viafb_read_reg(VIASR
, SR1B
) & BIT1
) >> 1;
1133 (viafb_read_reg(VIASR
, SR2A
) & BIT4
) >> 3 |
1134 (viafb_read_reg(VIASR
, SR1E
) & BIT2
) >> 2;
1135 dvp0
= viafb_read_reg(VIACR
, CR96
) & 0x0f;
1136 seq_printf(m
, "%x %x %x\n", dvp0
, dvp0_data_dri
, dvp0_clk_dri
);
1140 static int viafb_dvp0_proc_open(struct inode
*inode
, struct file
*file
)
1142 return single_open(file
, viafb_dvp0_proc_show
, NULL
);
1145 static ssize_t
viafb_dvp0_proc_write(struct file
*file
,
1146 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1148 char buf
[20], *value
, *pbuf
;
1150 unsigned long length
, i
;
1153 length
= count
> 20 ? 20 : count
;
1154 if (copy_from_user(&buf
[0], buffer
, length
))
1156 buf
[length
- 1] = '\0'; /*Ensure end string */
1158 for (i
= 0; i
< 3; i
++) {
1159 value
= strsep(&pbuf
, " ");
1160 if (value
!= NULL
) {
1161 if (kstrtou8(value
, 0, ®_val
) < 0)
1163 DEBUG_MSG(KERN_INFO
"DVP0:reg_val[%l]=:%x\n", i
,
1167 viafb_write_reg_mask(CR96
, VIACR
,
1171 viafb_write_reg_mask(SR2A
, VIASR
,
1172 reg_val
<< 4, BIT5
);
1173 viafb_write_reg_mask(SR1B
, VIASR
,
1174 reg_val
<< 1, BIT1
);
1177 viafb_write_reg_mask(SR2A
, VIASR
,
1178 reg_val
<< 3, BIT4
);
1179 viafb_write_reg_mask(SR1E
, VIASR
,
1180 reg_val
<< 2, BIT2
);
1192 static const struct file_operations viafb_dvp0_proc_fops
= {
1193 .owner
= THIS_MODULE
,
1194 .open
= viafb_dvp0_proc_open
,
1196 .llseek
= seq_lseek
,
1197 .release
= single_release
,
1198 .write
= viafb_dvp0_proc_write
,
1201 static int viafb_dvp1_proc_show(struct seq_file
*m
, void *v
)
1203 u8 dvp1
= 0, dvp1_data_dri
= 0, dvp1_clk_dri
= 0;
1204 dvp1
= viafb_read_reg(VIACR
, CR9B
) & 0x0f;
1205 dvp1_data_dri
= (viafb_read_reg(VIASR
, SR65
) & 0x0c) >> 2;
1206 dvp1_clk_dri
= viafb_read_reg(VIASR
, SR65
) & 0x03;
1207 seq_printf(m
, "%x %x %x\n", dvp1
, dvp1_data_dri
, dvp1_clk_dri
);
1211 static int viafb_dvp1_proc_open(struct inode
*inode
, struct file
*file
)
1213 return single_open(file
, viafb_dvp1_proc_show
, NULL
);
1216 static ssize_t
viafb_dvp1_proc_write(struct file
*file
,
1217 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1219 char buf
[20], *value
, *pbuf
;
1221 unsigned long length
, i
;
1224 length
= count
> 20 ? 20 : count
;
1225 if (copy_from_user(&buf
[0], buffer
, length
))
1227 buf
[length
- 1] = '\0'; /*Ensure end string */
1229 for (i
= 0; i
< 3; i
++) {
1230 value
= strsep(&pbuf
, " ");
1231 if (value
!= NULL
) {
1232 if (kstrtou8(value
, 0, ®_val
) < 0)
1236 viafb_write_reg_mask(CR9B
, VIACR
,
1240 viafb_write_reg_mask(SR65
, VIASR
,
1241 reg_val
<< 2, 0x0c);
1244 viafb_write_reg_mask(SR65
, VIASR
,
1257 static const struct file_operations viafb_dvp1_proc_fops
= {
1258 .owner
= THIS_MODULE
,
1259 .open
= viafb_dvp1_proc_open
,
1261 .llseek
= seq_lseek
,
1262 .release
= single_release
,
1263 .write
= viafb_dvp1_proc_write
,
1266 static int viafb_dfph_proc_show(struct seq_file
*m
, void *v
)
1269 dfp_high
= viafb_read_reg(VIACR
, CR97
) & 0x0f;
1270 seq_printf(m
, "%x\n", dfp_high
);
1274 static int viafb_dfph_proc_open(struct inode
*inode
, struct file
*file
)
1276 return single_open(file
, viafb_dfph_proc_show
, NULL
);
1279 static ssize_t
viafb_dfph_proc_write(struct file
*file
,
1280 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1284 unsigned long length
;
1287 length
= count
> 20 ? 20 : count
;
1288 if (copy_from_user(&buf
[0], buffer
, length
))
1290 buf
[length
- 1] = '\0'; /*Ensure end string */
1291 if (kstrtou8(buf
, 0, ®_val
) < 0)
1293 viafb_write_reg_mask(CR97
, VIACR
, reg_val
, 0x0f);
1297 static const struct file_operations viafb_dfph_proc_fops
= {
1298 .owner
= THIS_MODULE
,
1299 .open
= viafb_dfph_proc_open
,
1301 .llseek
= seq_lseek
,
1302 .release
= single_release
,
1303 .write
= viafb_dfph_proc_write
,
1306 static int viafb_dfpl_proc_show(struct seq_file
*m
, void *v
)
1309 dfp_low
= viafb_read_reg(VIACR
, CR99
) & 0x0f;
1310 seq_printf(m
, "%x\n", dfp_low
);
1314 static int viafb_dfpl_proc_open(struct inode
*inode
, struct file
*file
)
1316 return single_open(file
, viafb_dfpl_proc_show
, NULL
);
1319 static ssize_t
viafb_dfpl_proc_write(struct file
*file
,
1320 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1324 unsigned long length
;
1327 length
= count
> 20 ? 20 : count
;
1328 if (copy_from_user(&buf
[0], buffer
, length
))
1330 buf
[length
- 1] = '\0'; /*Ensure end string */
1331 if (kstrtou8(buf
, 0, ®_val
) < 0)
1333 viafb_write_reg_mask(CR99
, VIACR
, reg_val
, 0x0f);
1337 static const struct file_operations viafb_dfpl_proc_fops
= {
1338 .owner
= THIS_MODULE
,
1339 .open
= viafb_dfpl_proc_open
,
1341 .llseek
= seq_lseek
,
1342 .release
= single_release
,
1343 .write
= viafb_dfpl_proc_write
,
1346 static int viafb_vt1636_proc_show(struct seq_file
*m
, void *v
)
1348 u8 vt1636_08
= 0, vt1636_09
= 0;
1349 switch (viaparinfo
->chip_info
->lvds_chip_info
.lvds_chip_name
) {
1352 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info
,
1353 &viaparinfo
->chip_info
->lvds_chip_info
, 0x08) & 0x0f;
1355 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info
,
1356 &viaparinfo
->chip_info
->lvds_chip_info
, 0x09) & 0x1f;
1357 seq_printf(m
, "%x %x\n", vt1636_08
, vt1636_09
);
1362 switch (viaparinfo
->chip_info
->lvds_chip_info2
.lvds_chip_name
) {
1365 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info2
,
1366 &viaparinfo
->chip_info
->lvds_chip_info2
, 0x08) & 0x0f;
1368 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info2
,
1369 &viaparinfo
->chip_info
->lvds_chip_info2
, 0x09) & 0x1f;
1370 seq_printf(m
, " %x %x\n", vt1636_08
, vt1636_09
);
1378 static int viafb_vt1636_proc_open(struct inode
*inode
, struct file
*file
)
1380 return single_open(file
, viafb_vt1636_proc_show
, NULL
);
1383 static ssize_t
viafb_vt1636_proc_write(struct file
*file
,
1384 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1386 char buf
[30], *value
, *pbuf
;
1387 struct IODATA reg_val
;
1388 unsigned long length
, i
;
1391 length
= count
> 30 ? 30 : count
;
1392 if (copy_from_user(&buf
[0], buffer
, length
))
1394 buf
[length
- 1] = '\0'; /*Ensure end string */
1396 switch (viaparinfo
->chip_info
->lvds_chip_info
.lvds_chip_name
) {
1398 for (i
= 0; i
< 2; i
++) {
1399 value
= strsep(&pbuf
, " ");
1400 if (value
!= NULL
) {
1401 if (kstrtou8(value
, 0, ®_val
.Data
) < 0)
1405 reg_val
.Index
= 0x08;
1406 reg_val
.Mask
= 0x0f;
1407 viafb_gpio_i2c_write_mask_lvds
1408 (viaparinfo
->lvds_setting_info
,
1410 chip_info
->lvds_chip_info
,
1414 reg_val
.Index
= 0x09;
1415 reg_val
.Mask
= 0x1f;
1416 viafb_gpio_i2c_write_mask_lvds
1417 (viaparinfo
->lvds_setting_info
,
1419 chip_info
->lvds_chip_info
,
1433 switch (viaparinfo
->chip_info
->lvds_chip_info2
.lvds_chip_name
) {
1435 for (i
= 0; i
< 2; i
++) {
1436 value
= strsep(&pbuf
, " ");
1437 if (value
!= NULL
) {
1438 if (kstrtou8(value
, 0, ®_val
.Data
) < 0)
1442 reg_val
.Index
= 0x08;
1443 reg_val
.Mask
= 0x0f;
1444 viafb_gpio_i2c_write_mask_lvds
1445 (viaparinfo
->lvds_setting_info2
,
1447 chip_info
->lvds_chip_info2
,
1451 reg_val
.Index
= 0x09;
1452 reg_val
.Mask
= 0x1f;
1453 viafb_gpio_i2c_write_mask_lvds
1454 (viaparinfo
->lvds_setting_info2
,
1456 chip_info
->lvds_chip_info2
,
1473 static const struct file_operations viafb_vt1636_proc_fops
= {
1474 .owner
= THIS_MODULE
,
1475 .open
= viafb_vt1636_proc_open
,
1477 .llseek
= seq_lseek
,
1478 .release
= single_release
,
1479 .write
= viafb_vt1636_proc_write
,
1482 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
1484 static int viafb_sup_odev_proc_show(struct seq_file
*m
, void *v
)
1486 via_odev_to_seq(m
, supported_odev_map
[
1487 viaparinfo
->shared
->chip_info
.gfx_chip_name
]);
1491 static int viafb_sup_odev_proc_open(struct inode
*inode
, struct file
*file
)
1493 return single_open(file
, viafb_sup_odev_proc_show
, NULL
);
1496 static const struct file_operations viafb_sup_odev_proc_fops
= {
1497 .owner
= THIS_MODULE
,
1498 .open
= viafb_sup_odev_proc_open
,
1500 .llseek
= seq_lseek
,
1501 .release
= single_release
,
1504 static ssize_t
odev_update(const char __user
*buffer
, size_t count
, u32
*odev
)
1506 char buf
[64], *ptr
= buf
;
1510 if (count
< 1 || count
> 63)
1512 if (copy_from_user(&buf
[0], buffer
, count
))
1515 add
= buf
[0] == '+';
1516 sub
= buf
[0] == '-';
1519 devices
= via_parse_odev(ptr
, &ptr
);
1533 static int viafb_iga1_odev_proc_show(struct seq_file
*m
, void *v
)
1535 via_odev_to_seq(m
, viaparinfo
->shared
->iga1_devices
);
1539 static int viafb_iga1_odev_proc_open(struct inode
*inode
, struct file
*file
)
1541 return single_open(file
, viafb_iga1_odev_proc_show
, NULL
);
1544 static ssize_t
viafb_iga1_odev_proc_write(struct file
*file
,
1545 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1547 u32 dev_on
, dev_off
, dev_old
, dev_new
;
1550 dev_old
= dev_new
= viaparinfo
->shared
->iga1_devices
;
1551 res
= odev_update(buffer
, count
, &dev_new
);
1554 dev_off
= dev_old
& ~dev_new
;
1555 dev_on
= dev_new
& ~dev_old
;
1556 viaparinfo
->shared
->iga1_devices
= dev_new
;
1557 viaparinfo
->shared
->iga2_devices
&= ~dev_new
;
1558 via_set_state(dev_off
, VIA_STATE_OFF
);
1559 via_set_source(dev_new
, IGA1
);
1560 via_set_state(dev_on
, VIA_STATE_ON
);
1564 static const struct file_operations viafb_iga1_odev_proc_fops
= {
1565 .owner
= THIS_MODULE
,
1566 .open
= viafb_iga1_odev_proc_open
,
1568 .llseek
= seq_lseek
,
1569 .release
= single_release
,
1570 .write
= viafb_iga1_odev_proc_write
,
1573 static int viafb_iga2_odev_proc_show(struct seq_file
*m
, void *v
)
1575 via_odev_to_seq(m
, viaparinfo
->shared
->iga2_devices
);
1579 static int viafb_iga2_odev_proc_open(struct inode
*inode
, struct file
*file
)
1581 return single_open(file
, viafb_iga2_odev_proc_show
, NULL
);
1584 static ssize_t
viafb_iga2_odev_proc_write(struct file
*file
,
1585 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1587 u32 dev_on
, dev_off
, dev_old
, dev_new
;
1590 dev_old
= dev_new
= viaparinfo
->shared
->iga2_devices
;
1591 res
= odev_update(buffer
, count
, &dev_new
);
1594 dev_off
= dev_old
& ~dev_new
;
1595 dev_on
= dev_new
& ~dev_old
;
1596 viaparinfo
->shared
->iga2_devices
= dev_new
;
1597 viaparinfo
->shared
->iga1_devices
&= ~dev_new
;
1598 via_set_state(dev_off
, VIA_STATE_OFF
);
1599 via_set_source(dev_new
, IGA2
);
1600 via_set_state(dev_on
, VIA_STATE_ON
);
1604 static const struct file_operations viafb_iga2_odev_proc_fops
= {
1605 .owner
= THIS_MODULE
,
1606 .open
= viafb_iga2_odev_proc_open
,
1608 .llseek
= seq_lseek
,
1609 .release
= single_release
,
1610 .write
= viafb_iga2_odev_proc_write
,
1613 #define IS_VT1636(lvds_chip) ((lvds_chip).lvds_chip_name == VT1636_LVDS)
1614 static void viafb_init_proc(struct viafb_shared
*shared
)
1616 struct proc_dir_entry
*iga1_entry
, *iga2_entry
,
1617 *viafb_entry
= proc_mkdir("viafb", NULL
);
1619 shared
->proc_entry
= viafb_entry
;
1621 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1622 proc_create("dvp0", 0, viafb_entry
, &viafb_dvp0_proc_fops
);
1623 proc_create("dvp1", 0, viafb_entry
, &viafb_dvp1_proc_fops
);
1624 proc_create("dfph", 0, viafb_entry
, &viafb_dfph_proc_fops
);
1625 proc_create("dfpl", 0, viafb_entry
, &viafb_dfpl_proc_fops
);
1626 if (IS_VT1636(shared
->chip_info
.lvds_chip_info
)
1627 || IS_VT1636(shared
->chip_info
.lvds_chip_info2
))
1628 proc_create("vt1636", 0, viafb_entry
,
1629 &viafb_vt1636_proc_fops
);
1630 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
1632 proc_create("supported_output_devices", 0, viafb_entry
,
1633 &viafb_sup_odev_proc_fops
);
1634 iga1_entry
= proc_mkdir("iga1", viafb_entry
);
1635 shared
->iga1_proc_entry
= iga1_entry
;
1636 proc_create("output_devices", 0, iga1_entry
,
1637 &viafb_iga1_odev_proc_fops
);
1638 iga2_entry
= proc_mkdir("iga2", viafb_entry
);
1639 shared
->iga2_proc_entry
= iga2_entry
;
1640 proc_create("output_devices", 0, iga2_entry
,
1641 &viafb_iga2_odev_proc_fops
);
1644 static void viafb_remove_proc(struct viafb_shared
*shared
)
1646 struct proc_dir_entry
*viafb_entry
= shared
->proc_entry
,
1647 *iga1_entry
= shared
->iga1_proc_entry
,
1648 *iga2_entry
= shared
->iga2_proc_entry
;
1653 remove_proc_entry("output_devices", iga2_entry
);
1654 remove_proc_entry("iga2", viafb_entry
);
1655 remove_proc_entry("output_devices", iga1_entry
);
1656 remove_proc_entry("iga1", viafb_entry
);
1657 remove_proc_entry("supported_output_devices", viafb_entry
);
1659 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1660 remove_proc_entry("dvp0", viafb_entry
);/* parent dir */
1661 remove_proc_entry("dvp1", viafb_entry
);
1662 remove_proc_entry("dfph", viafb_entry
);
1663 remove_proc_entry("dfpl", viafb_entry
);
1664 if (IS_VT1636(shared
->chip_info
.lvds_chip_info
)
1665 || IS_VT1636(shared
->chip_info
.lvds_chip_info2
))
1666 remove_proc_entry("vt1636", viafb_entry
);
1667 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
1669 remove_proc_entry("viafb", NULL
);
1673 static int parse_mode(const char *str
, u32
*xres
, u32
*yres
)
1678 if (machine_is_olpc()) {
1688 *xres
= simple_strtoul(str
, &ptr
, 10);
1692 *yres
= simple_strtoul(&ptr
[1], &ptr
, 10);
1701 static int viafb_suspend(void *unused
)
1704 fb_set_suspend(viafbinfo
, 1);
1705 viafb_sync(viafbinfo
);
1711 static int viafb_resume(void *unused
)
1714 if (viaparinfo
->shared
->vdev
->engine_mmio
)
1715 viafb_reset_engine(viaparinfo
);
1716 viafb_set_par(viafbinfo
);
1718 viafb_set_par(viafbinfo1
);
1719 fb_set_suspend(viafbinfo
, 0);
1725 static struct viafb_pm_hooks viafb_fb_pm_hooks
= {
1726 .suspend
= viafb_suspend
,
1727 .resume
= viafb_resume
1733 int __devinit
via_fb_pci_probe(struct viafb_dev
*vdev
)
1735 u32 default_xres
, default_yres
;
1736 struct fb_var_screeninfo default_var
;
1738 u32 viafb_par_length
;
1740 DEBUG_MSG(KERN_INFO
"VIAFB PCI Probe!!\n");
1741 memset(&default_var
, 0, sizeof(default_var
));
1742 viafb_par_length
= ALIGN(sizeof(struct viafb_par
), BITS_PER_LONG
/8);
1744 /* Allocate fb_info and ***_par here, also including some other needed
1747 viafbinfo
= framebuffer_alloc(viafb_par_length
+
1748 ALIGN(sizeof(struct viafb_shared
), BITS_PER_LONG
/8),
1751 printk(KERN_ERR
"Could not allocate memory for viafb_info.\n");
1755 viaparinfo
= (struct viafb_par
*)viafbinfo
->par
;
1756 viaparinfo
->shared
= viafbinfo
->par
+ viafb_par_length
;
1757 viaparinfo
->shared
->vdev
= vdev
;
1758 viaparinfo
->vram_addr
= 0;
1759 viaparinfo
->tmds_setting_info
= &viaparinfo
->shared
->tmds_setting_info
;
1760 viaparinfo
->lvds_setting_info
= &viaparinfo
->shared
->lvds_setting_info
;
1761 viaparinfo
->lvds_setting_info2
=
1762 &viaparinfo
->shared
->lvds_setting_info2
;
1763 viaparinfo
->chip_info
= &viaparinfo
->shared
->chip_info
;
1770 viafb_init_chip_info(vdev
->chip_type
);
1772 * The framebuffer will have been successfully mapped by
1773 * the core (or we'd not be here), but we still need to
1774 * set up our own accounting.
1776 viaparinfo
->fbmem
= vdev
->fbmem_start
;
1777 viaparinfo
->memsize
= vdev
->fbmem_len
;
1778 viaparinfo
->fbmem_free
= viaparinfo
->memsize
;
1779 viaparinfo
->fbmem_used
= 0;
1780 viafbinfo
->screen_base
= vdev
->fbmem
;
1782 viafbinfo
->fix
.mmio_start
= vdev
->engine_start
;
1783 viafbinfo
->fix
.mmio_len
= vdev
->engine_len
;
1784 viafbinfo
->node
= 0;
1785 viafbinfo
->fbops
= &viafb_ops
;
1786 viafbinfo
->flags
= FBINFO_DEFAULT
| FBINFO_HWACCEL_YPAN
;
1788 viafbinfo
->pseudo_palette
= pseudo_pal
;
1789 if (viafb_accel
&& !viafb_setup_engine(viafbinfo
)) {
1790 viafbinfo
->flags
|= FBINFO_HWACCEL_COPYAREA
|
1791 FBINFO_HWACCEL_FILLRECT
| FBINFO_HWACCEL_IMAGEBLIT
;
1792 default_var
.accel_flags
= FB_ACCELF_TEXT
;
1794 viafbinfo
->flags
|= FBINFO_HWACCEL_DISABLED
;
1795 default_var
.accel_flags
= 0;
1798 if (viafb_second_size
&& (viafb_second_size
< 8)) {
1799 viafb_second_offset
= viaparinfo
->fbmem_free
-
1800 viafb_second_size
* 1024 * 1024;
1802 viafb_second_size
= 8;
1803 viafb_second_offset
= viaparinfo
->fbmem_free
-
1804 viafb_second_size
* 1024 * 1024;
1807 parse_mode(viafb_mode
, &default_xres
, &default_yres
);
1808 if (viafb_SAMM_ON
== 1)
1809 parse_mode(viafb_mode1
, &viafb_second_xres
,
1810 &viafb_second_yres
);
1812 default_var
.xres
= default_xres
;
1813 default_var
.yres
= default_yres
;
1814 default_var
.xres_virtual
= default_xres
;
1815 default_var
.yres_virtual
= default_yres
;
1816 default_var
.bits_per_pixel
= viafb_bpp
;
1817 viafb_fill_var_timing_info(&default_var
, viafb_get_best_mode(
1818 default_var
.xres
, default_var
.yres
, viafb_refresh
));
1819 viafb_setup_fixinfo(&viafbinfo
->fix
, viaparinfo
);
1820 viafbinfo
->var
= default_var
;
1822 if (viafb_dual_fb
) {
1823 viafbinfo1
= framebuffer_alloc(viafb_par_length
,
1827 "allocate the second framebuffer struct error\n");
1829 goto out_fb_release
;
1831 viaparinfo1
= viafbinfo1
->par
;
1832 memcpy(viaparinfo1
, viaparinfo
, viafb_par_length
);
1833 viaparinfo1
->vram_addr
= viafb_second_offset
;
1834 viaparinfo1
->memsize
= viaparinfo
->memsize
-
1835 viafb_second_offset
;
1836 viaparinfo
->memsize
= viafb_second_offset
;
1837 viaparinfo1
->fbmem
= viaparinfo
->fbmem
+ viafb_second_offset
;
1839 viaparinfo1
->fbmem_used
= viaparinfo
->fbmem_used
;
1840 viaparinfo1
->fbmem_free
= viaparinfo1
->memsize
-
1841 viaparinfo1
->fbmem_used
;
1842 viaparinfo
->fbmem_free
= viaparinfo
->memsize
;
1843 viaparinfo
->fbmem_used
= 0;
1845 viaparinfo
->iga_path
= IGA1
;
1846 viaparinfo1
->iga_path
= IGA2
;
1847 memcpy(viafbinfo1
, viafbinfo
, sizeof(struct fb_info
));
1848 viafbinfo1
->par
= viaparinfo1
;
1849 viafbinfo1
->screen_base
= viafbinfo
->screen_base
+
1850 viafb_second_offset
;
1852 default_var
.xres
= viafb_second_xres
;
1853 default_var
.yres
= viafb_second_yres
;
1854 default_var
.xres_virtual
= viafb_second_xres
;
1855 default_var
.yres_virtual
= viafb_second_yres
;
1856 default_var
.bits_per_pixel
= viafb_bpp1
;
1857 viafb_fill_var_timing_info(&default_var
, viafb_get_best_mode(
1858 default_var
.xres
, default_var
.yres
, viafb_refresh1
));
1860 viafb_setup_fixinfo(&viafbinfo1
->fix
, viaparinfo1
);
1861 viafb_check_var(&default_var
, viafbinfo1
);
1862 viafbinfo1
->var
= default_var
;
1863 viafb_update_fix(viafbinfo1
);
1864 viaparinfo1
->depth
= fb_get_color_depth(&viafbinfo1
->var
,
1868 viafb_check_var(&viafbinfo
->var
, viafbinfo
);
1869 viafb_update_fix(viafbinfo
);
1870 viaparinfo
->depth
= fb_get_color_depth(&viafbinfo
->var
,
1872 default_var
.activate
= FB_ACTIVATE_NOW
;
1873 rc
= fb_alloc_cmap(&viafbinfo
->cmap
, 256, 0);
1875 goto out_fb1_release
;
1877 if (viafb_dual_fb
&& (viafb_primary_dev
== LCD_Device
)
1878 && (viaparinfo
->chip_info
->gfx_chip_name
== UNICHROME_CLE266
)) {
1879 rc
= register_framebuffer(viafbinfo1
);
1881 goto out_dealloc_cmap
;
1883 rc
= register_framebuffer(viafbinfo
);
1885 goto out_fb1_unreg_lcd_cle266
;
1887 if (viafb_dual_fb
&& ((viafb_primary_dev
!= LCD_Device
)
1888 || (viaparinfo
->chip_info
->gfx_chip_name
!=
1889 UNICHROME_CLE266
))) {
1890 rc
= register_framebuffer(viafbinfo1
);
1894 DEBUG_MSG(KERN_INFO
"fb%d: %s frame buffer device %dx%d-%dbpp\n",
1895 viafbinfo
->node
, viafbinfo
->fix
.id
, default_var
.xres
,
1896 default_var
.yres
, default_var
.bits_per_pixel
);
1898 viafb_init_proc(viaparinfo
->shared
);
1899 viafb_init_dac(IGA2
);
1902 viafb_pm_register(&viafb_fb_pm_hooks
);
1907 unregister_framebuffer(viafbinfo
);
1908 out_fb1_unreg_lcd_cle266
:
1909 if (viafb_dual_fb
&& (viafb_primary_dev
== LCD_Device
)
1910 && (viaparinfo
->chip_info
->gfx_chip_name
== UNICHROME_CLE266
))
1911 unregister_framebuffer(viafbinfo1
);
1913 fb_dealloc_cmap(&viafbinfo
->cmap
);
1916 framebuffer_release(viafbinfo1
);
1918 framebuffer_release(viafbinfo
);
1922 void __devexit
via_fb_pci_remove(struct pci_dev
*pdev
)
1924 DEBUG_MSG(KERN_INFO
"via_pci_remove!\n");
1925 fb_dealloc_cmap(&viafbinfo
->cmap
);
1926 unregister_framebuffer(viafbinfo
);
1928 unregister_framebuffer(viafbinfo1
);
1929 viafb_remove_proc(viaparinfo
->shared
);
1930 framebuffer_release(viafbinfo
);
1932 framebuffer_release(viafbinfo1
);
1936 static int __init
viafb_setup(void)
1941 DEBUG_MSG(KERN_INFO
"viafb_setup!\n");
1943 if (fb_get_options("viafb", &options
))
1946 if (!options
|| !*options
)
1949 while ((this_opt
= strsep(&options
, ",")) != NULL
) {
1953 if (!strncmp(this_opt
, "viafb_mode1=", 12)) {
1954 viafb_mode1
= kstrdup(this_opt
+ 12, GFP_KERNEL
);
1955 } else if (!strncmp(this_opt
, "viafb_mode=", 11)) {
1956 viafb_mode
= kstrdup(this_opt
+ 11, GFP_KERNEL
);
1957 } else if (!strncmp(this_opt
, "viafb_bpp1=", 11)) {
1958 if (kstrtouint(this_opt
+ 11, 0, &viafb_bpp1
) < 0)
1960 } else if (!strncmp(this_opt
, "viafb_bpp=", 10)) {
1961 if (kstrtouint(this_opt
+ 10, 0, &viafb_bpp
) < 0)
1963 } else if (!strncmp(this_opt
, "viafb_refresh1=", 15)) {
1964 if (kstrtoint(this_opt
+ 15, 0, &viafb_refresh1
) < 0)
1966 } else if (!strncmp(this_opt
, "viafb_refresh=", 14)) {
1967 if (kstrtoint(this_opt
+ 14, 0, &viafb_refresh
) < 0)
1969 } else if (!strncmp(this_opt
, "viafb_lcd_dsp_method=", 21)) {
1970 if (kstrtoint(this_opt
+ 21, 0,
1971 &viafb_lcd_dsp_method
) < 0)
1973 } else if (!strncmp(this_opt
, "viafb_lcd_panel_id=", 19)) {
1974 if (kstrtoint(this_opt
+ 19, 0,
1975 &viafb_lcd_panel_id
) < 0)
1977 } else if (!strncmp(this_opt
, "viafb_accel=", 12)) {
1978 if (kstrtoint(this_opt
+ 12, 0, &viafb_accel
) < 0)
1980 } else if (!strncmp(this_opt
, "viafb_SAMM_ON=", 14)) {
1981 if (kstrtoint(this_opt
+ 14, 0, &viafb_SAMM_ON
) < 0)
1983 } else if (!strncmp(this_opt
, "viafb_active_dev=", 17)) {
1984 viafb_active_dev
= kstrdup(this_opt
+ 17, GFP_KERNEL
);
1985 } else if (!strncmp(this_opt
,
1986 "viafb_display_hardware_layout=", 30)) {
1987 if (kstrtoint(this_opt
+ 30, 0,
1988 &viafb_display_hardware_layout
) < 0)
1990 } else if (!strncmp(this_opt
, "viafb_second_size=", 18)) {
1991 if (kstrtoint(this_opt
+ 18, 0, &viafb_second_size
) < 0)
1993 } else if (!strncmp(this_opt
,
1994 "viafb_platform_epia_dvi=", 24)) {
1995 if (kstrtoint(this_opt
+ 24, 0,
1996 &viafb_platform_epia_dvi
) < 0)
1998 } else if (!strncmp(this_opt
,
1999 "viafb_device_lcd_dualedge=", 26)) {
2000 if (kstrtoint(this_opt
+ 26, 0,
2001 &viafb_device_lcd_dualedge
) < 0)
2003 } else if (!strncmp(this_opt
, "viafb_bus_width=", 16)) {
2004 if (kstrtoint(this_opt
+ 16, 0, &viafb_bus_width
) < 0)
2006 } else if (!strncmp(this_opt
, "viafb_lcd_mode=", 15)) {
2007 if (kstrtoint(this_opt
+ 15, 0, &viafb_lcd_mode
) < 0)
2009 } else if (!strncmp(this_opt
, "viafb_lcd_port=", 15)) {
2010 viafb_lcd_port
= kstrdup(this_opt
+ 15, GFP_KERNEL
);
2011 } else if (!strncmp(this_opt
, "viafb_dvi_port=", 15)) {
2012 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_best_mode(dummy_x
, dummy_y
, viafb_refresh
)
2038 || parse_mode(viafb_mode1
, &dummy_x
, &dummy_y
)
2039 || !viafb_get_best_mode(dummy_x
, dummy_y
, viafb_refresh1
)
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");