2 * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE.See the GNU General Public License
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #include <linux/module.h>
23 #include <linux/seq_file.h>
24 #include <linux/slab.h>
25 #include <linux/stat.h>
26 #include <linux/via-core.h>
31 static char *viafb_name
= "Via";
32 static u32 pseudo_pal
[17];
35 static char *viafb_mode
;
36 static char *viafb_mode1
;
37 static int viafb_bpp
= 32;
38 static int viafb_bpp1
= 32;
40 static unsigned int viafb_second_offset
;
41 static int viafb_second_size
;
43 static int viafb_accel
= 1;
45 /* Added for specifying active devices.*/
46 char *viafb_active_dev
;
48 /*Added for specify lcd output port*/
49 char *viafb_lcd_port
= "";
50 char *viafb_dvi_port
= "";
52 static void viafb_set_device(struct device_t active_dev
);
53 static int apply_device_setting(struct viafb_ioctl_setting setting_info
,
54 struct fb_info
*info
);
55 static void apply_second_mode_setting(struct fb_var_screeninfo
57 static void retrieve_device_setting(struct viafb_ioctl_setting
59 static int viafb_pan_display(struct fb_var_screeninfo
*var
,
60 struct fb_info
*info
);
62 static struct fb_ops viafb_ops
;
65 static void viafb_fill_var_color_info(struct fb_var_screeninfo
*var
, u8 depth
)
68 var
->red
.msb_right
= 0;
69 var
->green
.msb_right
= 0;
70 var
->blue
.msb_right
= 0;
71 var
->transp
.offset
= 0;
72 var
->transp
.length
= 0;
73 var
->transp
.msb_right
= 0;
77 var
->bits_per_pixel
= 8;
79 var
->green
.offset
= 0;
82 var
->green
.length
= 8;
86 var
->bits_per_pixel
= 16;
88 var
->green
.offset
= 5;
91 var
->green
.length
= 5;
95 var
->bits_per_pixel
= 16;
97 var
->green
.offset
= 5;
100 var
->green
.length
= 6;
101 var
->blue
.length
= 5;
104 var
->bits_per_pixel
= 32;
105 var
->red
.offset
= 16;
106 var
->green
.offset
= 8;
107 var
->blue
.offset
= 0;
109 var
->green
.length
= 8;
110 var
->blue
.length
= 8;
113 var
->bits_per_pixel
= 32;
114 var
->red
.offset
= 20;
115 var
->green
.offset
= 10;
116 var
->blue
.offset
= 0;
117 var
->red
.length
= 10;
118 var
->green
.length
= 10;
119 var
->blue
.length
= 10;
124 static void viafb_update_fix(struct fb_info
*info
)
126 u32 bpp
= info
->var
.bits_per_pixel
;
129 bpp
== 8 ? FB_VISUAL_PSEUDOCOLOR
: FB_VISUAL_TRUECOLOR
;
130 info
->fix
.line_length
= (info
->var
.xres_virtual
* bpp
/ 8 + 7) & ~7;
133 static void viafb_setup_fixinfo(struct fb_fix_screeninfo
*fix
,
134 struct viafb_par
*viaparinfo
)
136 memset(fix
, 0, sizeof(struct fb_fix_screeninfo
));
137 strcpy(fix
->id
, viafb_name
);
139 fix
->smem_start
= viaparinfo
->fbmem
;
140 fix
->smem_len
= viaparinfo
->fbmem_free
;
142 fix
->type
= FB_TYPE_PACKED_PIXELS
;
144 fix
->visual
= FB_VISUAL_TRUECOLOR
;
146 fix
->xpanstep
= fix
->ywrapstep
= 0;
149 /* Just tell the accel name */
150 viafbinfo
->fix
.accel
= FB_ACCEL_VIA_UNICHROME
;
152 static int viafb_open(struct fb_info
*info
, int user
)
154 DEBUG_MSG(KERN_INFO
"viafb_open!\n");
158 static int viafb_release(struct fb_info
*info
, int user
)
160 DEBUG_MSG(KERN_INFO
"viafb_release!\n");
164 static int viafb_check_var(struct fb_var_screeninfo
*var
,
165 struct fb_info
*info
)
167 int htotal
, vtotal
, depth
;
168 struct VideoModeTable
*vmode_entry
;
169 struct viafb_par
*ppar
= info
->par
;
170 u32 long_refresh
, line
;
172 DEBUG_MSG(KERN_INFO
"viafb_check_var!\n");
174 /* HW neither support interlacte nor double-scaned mode */
175 if (var
->vmode
& FB_VMODE_INTERLACED
|| var
->vmode
& FB_VMODE_DOUBLE
)
178 vmode_entry
= viafb_get_mode(var
->xres
, var
->yres
);
181 "viafb: Mode %dx%dx%d not supported!!\n",
182 var
->xres
, var
->yres
, var
->bits_per_pixel
);
186 depth
= fb_get_color_depth(var
, &info
->fix
);
188 depth
= var
->bits_per_pixel
;
190 if (depth
< 0 || depth
> 32)
194 else if (depth
== 15 && viafb_dual_fb
&& ppar
->iga_path
== IGA1
)
196 else if (depth
== 30)
200 else if (depth
<= 16)
205 viafb_fill_var_color_info(var
, depth
);
206 line
= (var
->xres_virtual
* var
->bits_per_pixel
/ 8 + 7) & ~7;
207 if (line
* var
->yres_virtual
> ppar
->memsize
)
210 /* Based on var passed in to calculate the refresh,
211 * because our driver use some modes special.
213 htotal
= var
->xres
+ var
->left_margin
+
214 var
->right_margin
+ var
->hsync_len
;
215 vtotal
= var
->yres
+ var
->upper_margin
+
216 var
->lower_margin
+ var
->vsync_len
;
217 long_refresh
= 1000000000UL / var
->pixclock
* 1000;
218 long_refresh
/= (htotal
* vtotal
);
220 viafb_refresh
= viafb_get_refresh(var
->xres
, var
->yres
, long_refresh
);
222 /* Adjust var according to our driver's own table */
223 viafb_fill_var_timing_info(var
, viafb_refresh
, vmode_entry
);
224 if (info
->var
.accel_flags
& FB_ACCELF_TEXT
&&
225 !ppar
->shared
->vdev
->engine_mmio
)
226 info
->var
.accel_flags
= 0;
231 static int viafb_set_par(struct fb_info
*info
)
233 struct viafb_par
*viapar
= info
->par
;
234 struct VideoModeTable
*vmode_entry
, *vmode_entry1
= NULL
;
235 DEBUG_MSG(KERN_INFO
"viafb_set_par!\n");
237 viapar
->depth
= fb_get_color_depth(&info
->var
, &info
->fix
);
238 viafb_update_device_setting(viafbinfo
->var
.xres
, viafbinfo
->var
.yres
,
239 viafbinfo
->var
.bits_per_pixel
, viafb_refresh
, 0);
241 vmode_entry
= viafb_get_mode(viafbinfo
->var
.xres
, viafbinfo
->var
.yres
);
243 vmode_entry1
= viafb_get_mode(viafbinfo1
->var
.xres
,
244 viafbinfo1
->var
.yres
);
245 viafb_update_device_setting(viafbinfo1
->var
.xres
,
246 viafbinfo1
->var
.yres
, viafbinfo1
->var
.bits_per_pixel
,
248 } else if (viafb_SAMM_ON
== 1) {
250 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
251 viafb_second_xres
, viafb_second_yres
, viafb_bpp1
);
252 vmode_entry1
= viafb_get_mode(viafb_second_xres
,
255 viafb_update_device_setting(viafb_second_xres
,
256 viafb_second_yres
, viafb_bpp1
, viafb_refresh1
, 1);
260 viafb_update_fix(info
);
261 if (viafb_dual_fb
&& viapar
->iga_path
== IGA2
)
262 viafb_bpp1
= info
->var
.bits_per_pixel
;
264 viafb_bpp
= info
->var
.bits_per_pixel
;
266 if (info
->var
.accel_flags
& FB_ACCELF_TEXT
)
267 info
->flags
&= ~FBINFO_HWACCEL_DISABLED
;
269 info
->flags
|= FBINFO_HWACCEL_DISABLED
;
270 viafb_setmode(vmode_entry
, info
->var
.bits_per_pixel
,
271 vmode_entry1
, viafb_bpp1
);
272 viafb_pan_display(&info
->var
, info
);
278 /* Set one color register */
279 static int viafb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
280 unsigned blue
, unsigned transp
, struct fb_info
*info
)
282 struct viafb_par
*viapar
= info
->par
;
285 if (info
->fix
.visual
== FB_VISUAL_PSEUDOCOLOR
) {
289 if (!viafb_dual_fb
|| viapar
->iga_path
== IGA1
)
290 viafb_set_primary_color_register(regno
, red
>> 8,
291 green
>> 8, blue
>> 8);
293 if (!viafb_dual_fb
|| viapar
->iga_path
== IGA2
)
294 viafb_set_secondary_color_register(regno
, red
>> 8,
295 green
>> 8, blue
>> 8);
300 r
= (red
>> (16 - info
->var
.red
.length
))
301 << info
->var
.red
.offset
;
302 b
= (blue
>> (16 - info
->var
.blue
.length
))
303 << info
->var
.blue
.offset
;
304 g
= (green
>> (16 - info
->var
.green
.length
))
305 << info
->var
.green
.offset
;
306 ((u32
*) info
->pseudo_palette
)[regno
] = r
| g
| b
;
312 static int viafb_pan_display(struct fb_var_screeninfo
*var
,
313 struct fb_info
*info
)
315 struct viafb_par
*viapar
= info
->par
;
316 u32 vram_addr
= (var
->yoffset
* var
->xres_virtual
+ var
->xoffset
)
317 * (var
->bits_per_pixel
/ 8) + viapar
->vram_addr
;
319 DEBUG_MSG(KERN_DEBUG
"viafb_pan_display, address = %d\n", vram_addr
);
320 if (!viafb_dual_fb
) {
321 via_set_primary_address(vram_addr
);
322 via_set_secondary_address(vram_addr
);
323 } else if (viapar
->iga_path
== IGA1
)
324 via_set_primary_address(vram_addr
);
326 via_set_secondary_address(vram_addr
);
331 static int viafb_blank(int blank_mode
, struct fb_info
*info
)
333 DEBUG_MSG(KERN_INFO
"viafb_blank!\n");
334 /* clear DPMS setting */
336 switch (blank_mode
) {
337 case FB_BLANK_UNBLANK
:
338 /* Screen: On, HSync: On, VSync: On */
339 /* control CRT monitor power management */
340 viafb_write_reg_mask(CR36
, VIACR
, 0x00, BIT4
+ BIT5
);
342 case FB_BLANK_HSYNC_SUSPEND
:
343 /* Screen: Off, HSync: Off, VSync: On */
344 /* control CRT monitor power management */
345 viafb_write_reg_mask(CR36
, VIACR
, 0x10, BIT4
+ BIT5
);
347 case FB_BLANK_VSYNC_SUSPEND
:
348 /* Screen: Off, HSync: On, VSync: Off */
349 /* control CRT monitor power management */
350 viafb_write_reg_mask(CR36
, VIACR
, 0x20, BIT4
+ BIT5
);
352 case FB_BLANK_POWERDOWN
:
353 /* Screen: Off, HSync: Off, VSync: Off */
354 /* control CRT monitor power management */
355 viafb_write_reg_mask(CR36
, VIACR
, 0x30, BIT4
+ BIT5
);
362 static int viafb_ioctl(struct fb_info
*info
, u_int cmd
, u_long arg
)
365 struct viafb_ioctl_mode viamode
;
366 struct viafb_ioctl_samm viasamm
;
367 struct viafb_driver_version driver_version
;
368 struct fb_var_screeninfo sec_var
;
369 struct _panel_size_pos_info panel_pos_size_para
;
370 struct viafb_ioctl_setting viafb_setting
;
371 struct device_t active_dev
;
374 u32
*viafb_gamma_table
;
375 char driver_name
[] = "viafb";
377 u32 __user
*argp
= (u32 __user
*) arg
;
380 DEBUG_MSG(KERN_INFO
"viafb_ioctl: 0x%X !!\n", cmd
);
381 printk(KERN_WARNING
"viafb_ioctl: Please avoid this interface as it is unstable and might change or vanish at any time!\n");
382 memset(&u
, 0, sizeof(u
));
385 case VIAFB_GET_CHIP_INFO
:
386 if (copy_to_user(argp
, viaparinfo
->chip_info
,
387 sizeof(struct chip_information
)))
390 case VIAFB_GET_INFO_SIZE
:
391 return put_user((u32
)sizeof(struct viafb_ioctl_info
), argp
);
393 return viafb_ioctl_get_viafb_info(arg
);
395 return put_user(viafb_ioctl_hotplug(info
->var
.xres
,
397 info
->var
.bits_per_pixel
), argp
);
398 case VIAFB_SET_HOTPLUG_FLAG
:
399 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
401 viafb_hotplug
= (gpu32
) ? 1 : 0;
403 case VIAFB_GET_RESOLUTION
:
404 u
.viamode
.xres
= (u32
) viafb_hotplug_Xres
;
405 u
.viamode
.yres
= (u32
) viafb_hotplug_Yres
;
406 u
.viamode
.refresh
= (u32
) viafb_hotplug_refresh
;
407 u
.viamode
.bpp
= (u32
) viafb_hotplug_bpp
;
408 if (viafb_SAMM_ON
== 1) {
409 u
.viamode
.xres_sec
= viafb_second_xres
;
410 u
.viamode
.yres_sec
= viafb_second_yres
;
411 u
.viamode
.virtual_xres_sec
= viafb_second_virtual_xres
;
412 u
.viamode
.virtual_yres_sec
= viafb_second_virtual_yres
;
413 u
.viamode
.refresh_sec
= viafb_refresh1
;
414 u
.viamode
.bpp_sec
= viafb_bpp1
;
416 u
.viamode
.xres_sec
= 0;
417 u
.viamode
.yres_sec
= 0;
418 u
.viamode
.virtual_xres_sec
= 0;
419 u
.viamode
.virtual_yres_sec
= 0;
420 u
.viamode
.refresh_sec
= 0;
421 u
.viamode
.bpp_sec
= 0;
423 if (copy_to_user(argp
, &u
.viamode
, sizeof(u
.viamode
)))
426 case VIAFB_GET_SAMM_INFO
:
427 u
.viasamm
.samm_status
= viafb_SAMM_ON
;
429 if (viafb_SAMM_ON
== 1) {
431 u
.viasamm
.size_prim
= viaparinfo
->fbmem_free
;
432 u
.viasamm
.size_sec
= viaparinfo1
->fbmem_free
;
434 if (viafb_second_size
) {
435 u
.viasamm
.size_prim
=
436 viaparinfo
->fbmem_free
-
437 viafb_second_size
* 1024 * 1024;
439 viafb_second_size
* 1024 * 1024;
441 u
.viasamm
.size_prim
=
442 viaparinfo
->fbmem_free
>> 1;
444 (viaparinfo
->fbmem_free
>> 1);
447 u
.viasamm
.mem_base
= viaparinfo
->fbmem
;
448 u
.viasamm
.offset_sec
= viafb_second_offset
;
450 u
.viasamm
.size_prim
=
451 viaparinfo
->memsize
- viaparinfo
->fbmem_used
;
452 u
.viasamm
.size_sec
= 0;
453 u
.viasamm
.mem_base
= viaparinfo
->fbmem
;
454 u
.viasamm
.offset_sec
= 0;
457 if (copy_to_user(argp
, &u
.viasamm
, sizeof(u
.viasamm
)))
461 case VIAFB_TURN_ON_OUTPUT_DEVICE
:
462 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
464 if (gpu32
& CRT_Device
)
466 if (gpu32
& DVI_Device
)
468 if (gpu32
& LCD_Device
)
471 case VIAFB_TURN_OFF_OUTPUT_DEVICE
:
472 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
474 if (gpu32
& CRT_Device
)
476 if (gpu32
& DVI_Device
)
478 if (gpu32
& LCD_Device
)
481 case VIAFB_SET_DEVICE
:
482 if (copy_from_user(&u
.active_dev
, (void *)argp
,
483 sizeof(u
.active_dev
)))
485 viafb_set_device(u
.active_dev
);
488 case VIAFB_GET_DEVICE
:
489 u
.active_dev
.crt
= viafb_CRT_ON
;
490 u
.active_dev
.dvi
= viafb_DVI_ON
;
491 u
.active_dev
.lcd
= viafb_LCD_ON
;
492 u
.active_dev
.samm
= viafb_SAMM_ON
;
493 u
.active_dev
.primary_dev
= viafb_primary_dev
;
495 u
.active_dev
.lcd_dsp_cent
= viafb_lcd_dsp_method
;
496 u
.active_dev
.lcd_panel_id
= viafb_lcd_panel_id
;
497 u
.active_dev
.lcd_mode
= viafb_lcd_mode
;
499 u
.active_dev
.xres
= viafb_hotplug_Xres
;
500 u
.active_dev
.yres
= viafb_hotplug_Yres
;
502 u
.active_dev
.xres1
= viafb_second_xres
;
503 u
.active_dev
.yres1
= viafb_second_yres
;
505 u
.active_dev
.bpp
= viafb_bpp
;
506 u
.active_dev
.bpp1
= viafb_bpp1
;
507 u
.active_dev
.refresh
= viafb_refresh
;
508 u
.active_dev
.refresh1
= viafb_refresh1
;
510 u
.active_dev
.epia_dvi
= viafb_platform_epia_dvi
;
511 u
.active_dev
.lcd_dual_edge
= viafb_device_lcd_dualedge
;
512 u
.active_dev
.bus_width
= viafb_bus_width
;
514 if (copy_to_user(argp
, &u
.active_dev
, sizeof(u
.active_dev
)))
518 case VIAFB_GET_DRIVER_VERSION
:
519 u
.driver_version
.iMajorNum
= VERSION_MAJOR
;
520 u
.driver_version
.iKernelNum
= VERSION_KERNEL
;
521 u
.driver_version
.iOSNum
= VERSION_OS
;
522 u
.driver_version
.iMinorNum
= VERSION_MINOR
;
524 if (copy_to_user(argp
, &u
.driver_version
,
525 sizeof(u
.driver_version
)))
530 case VIAFB_SET_DEVICE_INFO
:
531 if (copy_from_user(&u
.viafb_setting
,
532 argp
, sizeof(u
.viafb_setting
)))
534 if (apply_device_setting(u
.viafb_setting
, info
) < 0)
539 case VIAFB_SET_SECOND_MODE
:
540 if (copy_from_user(&u
.sec_var
, argp
, sizeof(u
.sec_var
)))
542 apply_second_mode_setting(&u
.sec_var
);
545 case VIAFB_GET_DEVICE_INFO
:
547 retrieve_device_setting(&u
.viafb_setting
);
549 if (copy_to_user(argp
, &u
.viafb_setting
,
550 sizeof(u
.viafb_setting
)))
555 case VIAFB_GET_DEVICE_SUPPORT
:
556 viafb_get_device_support_state(&state_info
);
557 if (put_user(state_info
, argp
))
561 case VIAFB_GET_DEVICE_CONNECT
:
562 viafb_get_device_connect_state(&state_info
);
563 if (put_user(state_info
, argp
))
567 case VIAFB_GET_PANEL_SUPPORT_EXPAND
:
569 viafb_lcd_get_support_expand_state(info
->var
.xres
,
571 if (put_user(state_info
, argp
))
575 case VIAFB_GET_DRIVER_NAME
:
576 if (copy_to_user(argp
, driver_name
, sizeof(driver_name
)))
580 case VIAFB_SET_GAMMA_LUT
:
581 viafb_gamma_table
= memdup_user(argp
, 256 * sizeof(u32
));
582 if (IS_ERR(viafb_gamma_table
))
583 return PTR_ERR(viafb_gamma_table
);
584 viafb_set_gamma_table(viafb_bpp
, viafb_gamma_table
);
585 kfree(viafb_gamma_table
);
588 case VIAFB_GET_GAMMA_LUT
:
589 viafb_gamma_table
= kmalloc(256 * sizeof(u32
), GFP_KERNEL
);
590 if (!viafb_gamma_table
)
592 viafb_get_gamma_table(viafb_gamma_table
);
593 if (copy_to_user(argp
, viafb_gamma_table
,
594 256 * sizeof(u32
))) {
595 kfree(viafb_gamma_table
);
598 kfree(viafb_gamma_table
);
601 case VIAFB_GET_GAMMA_SUPPORT_STATE
:
602 viafb_get_gamma_support_state(viafb_bpp
, &state_info
);
603 if (put_user(state_info
, argp
))
606 case VIAFB_SYNC_SURFACE
:
607 DEBUG_MSG(KERN_INFO
"lobo VIAFB_SYNC_SURFACE\n");
609 case VIAFB_GET_DRIVER_CAPS
:
612 case VIAFB_GET_PANEL_MAX_SIZE
:
613 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
614 sizeof(u
.panel_pos_size_para
)))
616 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
617 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
618 sizeof(u
.panel_pos_size_para
)))
621 case VIAFB_GET_PANEL_MAX_POSITION
:
622 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
623 sizeof(u
.panel_pos_size_para
)))
625 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
626 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
627 sizeof(u
.panel_pos_size_para
)))
631 case VIAFB_GET_PANEL_POSITION
:
632 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
633 sizeof(u
.panel_pos_size_para
)))
635 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
636 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
637 sizeof(u
.panel_pos_size_para
)))
640 case VIAFB_GET_PANEL_SIZE
:
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_SET_PANEL_POSITION
:
651 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
652 sizeof(u
.panel_pos_size_para
)))
655 case VIAFB_SET_PANEL_SIZE
:
656 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
657 sizeof(u
.panel_pos_size_para
)))
668 static void viafb_fillrect(struct fb_info
*info
,
669 const struct fb_fillrect
*rect
)
671 struct viafb_par
*viapar
= info
->par
;
672 struct viafb_shared
*shared
= viapar
->shared
;
676 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
) {
677 cfb_fillrect(info
, rect
);
681 if (!rect
->width
|| !rect
->height
)
684 if (info
->fix
.visual
== FB_VISUAL_TRUECOLOR
)
685 fg_color
= ((u32
*)info
->pseudo_palette
)[rect
->color
];
687 fg_color
= rect
->color
;
689 if (rect
->rop
== ROP_XOR
)
694 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: fillrect\n");
695 if (shared
->hw_bitblt(shared
->vdev
->engine_mmio
, VIA_BITBLT_FILL
,
696 rect
->width
, rect
->height
, info
->var
.bits_per_pixel
,
697 viapar
->vram_addr
, info
->fix
.line_length
, rect
->dx
, rect
->dy
,
698 NULL
, 0, 0, 0, 0, fg_color
, 0, rop
))
699 cfb_fillrect(info
, rect
);
702 static void viafb_copyarea(struct fb_info
*info
,
703 const struct fb_copyarea
*area
)
705 struct viafb_par
*viapar
= info
->par
;
706 struct viafb_shared
*shared
= viapar
->shared
;
708 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
) {
709 cfb_copyarea(info
, area
);
713 if (!area
->width
|| !area
->height
)
716 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: copyarea\n");
717 if (shared
->hw_bitblt(shared
->vdev
->engine_mmio
, VIA_BITBLT_COLOR
,
718 area
->width
, area
->height
, info
->var
.bits_per_pixel
,
719 viapar
->vram_addr
, info
->fix
.line_length
, area
->dx
, area
->dy
,
720 NULL
, viapar
->vram_addr
, info
->fix
.line_length
,
721 area
->sx
, area
->sy
, 0, 0, 0))
722 cfb_copyarea(info
, area
);
725 static void viafb_imageblit(struct fb_info
*info
,
726 const struct fb_image
*image
)
728 struct viafb_par
*viapar
= info
->par
;
729 struct viafb_shared
*shared
= viapar
->shared
;
730 u32 fg_color
= 0, bg_color
= 0;
733 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
||
734 (image
->depth
!= 1 && image
->depth
!= viapar
->depth
)) {
735 cfb_imageblit(info
, image
);
739 if (image
->depth
== 1) {
740 op
= VIA_BITBLT_MONO
;
741 if (info
->fix
.visual
== FB_VISUAL_TRUECOLOR
) {
743 ((u32
*)info
->pseudo_palette
)[image
->fg_color
];
745 ((u32
*)info
->pseudo_palette
)[image
->bg_color
];
747 fg_color
= image
->fg_color
;
748 bg_color
= image
->bg_color
;
751 op
= VIA_BITBLT_COLOR
;
753 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: imageblit\n");
754 if (shared
->hw_bitblt(shared
->vdev
->engine_mmio
, op
,
755 image
->width
, image
->height
, info
->var
.bits_per_pixel
,
756 viapar
->vram_addr
, info
->fix
.line_length
, image
->dx
, image
->dy
,
757 (u32
*)image
->data
, 0, 0, 0, 0, fg_color
, bg_color
, 0))
758 cfb_imageblit(info
, image
);
761 static int viafb_cursor(struct fb_info
*info
, struct fb_cursor
*cursor
)
763 struct viafb_par
*viapar
= info
->par
;
764 void __iomem
*engine
= viapar
->shared
->vdev
->engine_mmio
;
765 u32 temp
, xx
, yy
, bg_color
= 0, fg_color
= 0,
766 chip_name
= viapar
->shared
->chip_info
.gfx_chip_name
;
767 int i
, j
= 0, cur_size
= 64;
769 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| info
!= viafbinfo
)
772 /* LCD ouput does not support hw cursors (at least on VN896) */
773 if ((chip_name
== UNICHROME_CLE266
&& viapar
->iga_path
== IGA2
) ||
777 viafb_show_hw_cursor(info
, HW_Cursor_OFF
);
779 if (cursor
->set
& FB_CUR_SETHOT
) {
780 temp
= (cursor
->hot
.x
<< 16) + cursor
->hot
.y
;
781 writel(temp
, engine
+ VIA_REG_CURSOR_ORG
);
784 if (cursor
->set
& FB_CUR_SETPOS
) {
785 yy
= cursor
->image
.dy
- info
->var
.yoffset
;
786 xx
= cursor
->image
.dx
- info
->var
.xoffset
;
789 writel(temp
, engine
+ VIA_REG_CURSOR_POS
);
792 if (cursor
->image
.width
<= 32 && cursor
->image
.height
<= 32)
794 else if (cursor
->image
.width
<= 64 && cursor
->image
.height
<= 64)
797 printk(KERN_WARNING
"viafb_cursor: The cursor is too large "
798 "%dx%d", cursor
->image
.width
, cursor
->image
.height
);
802 if (cursor
->set
& FB_CUR_SETSIZE
) {
803 temp
= readl(engine
+ VIA_REG_CURSOR_MODE
);
809 writel(temp
, engine
+ VIA_REG_CURSOR_MODE
);
812 if (cursor
->set
& FB_CUR_SETCMAP
) {
813 fg_color
= cursor
->image
.fg_color
;
814 bg_color
= cursor
->image
.bg_color
;
815 if (chip_name
== UNICHROME_CX700
||
816 chip_name
== UNICHROME_VX800
||
817 chip_name
== UNICHROME_VX855
) {
819 ((info
->cmap
.red
[fg_color
] & 0xFFC0) << 14) |
820 ((info
->cmap
.green
[fg_color
] & 0xFFC0) << 4) |
821 ((info
->cmap
.blue
[fg_color
] & 0xFFC0) >> 6);
823 ((info
->cmap
.red
[bg_color
] & 0xFFC0) << 14) |
824 ((info
->cmap
.green
[bg_color
] & 0xFFC0) << 4) |
825 ((info
->cmap
.blue
[bg_color
] & 0xFFC0) >> 6);
828 ((info
->cmap
.red
[fg_color
] & 0xFF00) << 8) |
829 (info
->cmap
.green
[fg_color
] & 0xFF00) |
830 ((info
->cmap
.blue
[fg_color
] & 0xFF00) >> 8);
832 ((info
->cmap
.red
[bg_color
] & 0xFF00) << 8) |
833 (info
->cmap
.green
[bg_color
] & 0xFF00) |
834 ((info
->cmap
.blue
[bg_color
] & 0xFF00) >> 8);
837 writel(bg_color
, engine
+ VIA_REG_CURSOR_BG
);
838 writel(fg_color
, engine
+ VIA_REG_CURSOR_FG
);
841 if (cursor
->set
& FB_CUR_SETSHAPE
) {
843 u8 data
[CURSOR_SIZE
];
844 u32 bak
[CURSOR_SIZE
/ 4];
845 } *cr_data
= kzalloc(sizeof(*cr_data
), GFP_ATOMIC
);
846 int size
= ((cursor
->image
.width
+ 7) >> 3) *
847 cursor
->image
.height
;
852 if (cur_size
== 32) {
853 for (i
= 0; i
< (CURSOR_SIZE
/ 4); i
++) {
854 cr_data
->bak
[i
] = 0x0;
855 cr_data
->bak
[i
+ 1] = 0xFFFFFFFF;
859 for (i
= 0; i
< (CURSOR_SIZE
/ 4); i
++) {
860 cr_data
->bak
[i
] = 0x0;
861 cr_data
->bak
[i
+ 1] = 0x0;
862 cr_data
->bak
[i
+ 2] = 0xFFFFFFFF;
863 cr_data
->bak
[i
+ 3] = 0xFFFFFFFF;
868 switch (cursor
->rop
) {
870 for (i
= 0; i
< size
; i
++)
871 cr_data
->data
[i
] = cursor
->mask
[i
];
875 for (i
= 0; i
< size
; i
++)
876 cr_data
->data
[i
] = cursor
->mask
[i
];
882 if (cur_size
== 32) {
883 for (i
= 0; i
< size
; i
++) {
884 cr_data
->bak
[j
] = (u32
) cr_data
->data
[i
];
885 cr_data
->bak
[j
+ 1] = ~cr_data
->bak
[j
];
889 for (i
= 0; i
< size
; i
++) {
890 cr_data
->bak
[j
] = (u32
) cr_data
->data
[i
];
891 cr_data
->bak
[j
+ 1] = 0x0;
892 cr_data
->bak
[j
+ 2] = ~cr_data
->bak
[j
];
893 cr_data
->bak
[j
+ 3] = ~cr_data
->bak
[j
+ 1];
898 memcpy_toio(viafbinfo
->screen_base
+ viapar
->shared
->
899 cursor_vram_addr
, cr_data
->bak
, CURSOR_SIZE
);
904 viafb_show_hw_cursor(info
, HW_Cursor_ON
);
909 static int viafb_sync(struct fb_info
*info
)
911 if (!(info
->flags
& FBINFO_HWACCEL_DISABLED
))
912 viafb_wait_engine_idle(info
);
916 static void check_available_device_to_enable(int device_id
)
921 viafb_CRT_ON
= STATE_OFF
;
922 viafb_DVI_ON
= STATE_OFF
;
923 viafb_LCD_ON
= STATE_OFF
;
924 viafb_LCD2_ON
= STATE_OFF
;
925 viafb_DeviceStatus
= None_Device
;
927 if ((device_id
& CRT_Device
) && (device_num
< MAX_ACTIVE_DEV_NUM
)) {
928 viafb_CRT_ON
= STATE_ON
;
930 viafb_DeviceStatus
|= CRT_Device
;
933 if ((device_id
& DVI_Device
) && (device_num
< MAX_ACTIVE_DEV_NUM
)) {
934 viafb_DVI_ON
= STATE_ON
;
936 viafb_DeviceStatus
|= DVI_Device
;
939 if ((device_id
& LCD_Device
) && (device_num
< MAX_ACTIVE_DEV_NUM
)) {
940 viafb_LCD_ON
= STATE_ON
;
942 viafb_DeviceStatus
|= LCD_Device
;
945 if ((device_id
& LCD2_Device
) && (device_num
< MAX_ACTIVE_DEV_NUM
)) {
946 viafb_LCD2_ON
= STATE_ON
;
948 viafb_DeviceStatus
|= LCD2_Device
;
951 if (viafb_DeviceStatus
== None_Device
) {
952 /* Use CRT as default active device: */
953 viafb_CRT_ON
= STATE_ON
;
954 viafb_DeviceStatus
= CRT_Device
;
956 DEBUG_MSG(KERN_INFO
"Device Status:%x", viafb_DeviceStatus
);
959 static void viafb_set_device(struct device_t active_dev
)
961 /* Check available device to enable: */
962 int device_id
= None_Device
;
964 device_id
|= CRT_Device
;
966 device_id
|= DVI_Device
;
968 device_id
|= LCD_Device
;
970 check_available_device_to_enable(device_id
);
972 /* Check property of LCD: */
974 if (active_dev
.lcd_dsp_cent
) {
975 viaparinfo
->lvds_setting_info
->display_method
=
976 viafb_lcd_dsp_method
= LCD_CENTERING
;
978 viaparinfo
->lvds_setting_info
->display_method
=
979 viafb_lcd_dsp_method
= LCD_EXPANDSION
;
982 if (active_dev
.lcd_mode
== LCD_SPWG
) {
983 viaparinfo
->lvds_setting_info
->lcd_mode
=
984 viafb_lcd_mode
= LCD_SPWG
;
986 viaparinfo
->lvds_setting_info
->lcd_mode
=
987 viafb_lcd_mode
= LCD_OPENLDI
;
990 if (active_dev
.lcd_panel_id
<= LCD_PANEL_ID_MAXIMUM
) {
991 viafb_lcd_panel_id
= active_dev
.lcd_panel_id
;
992 viafb_init_lcd_size();
996 /* Check property of mode: */
997 if (!active_dev
.xres1
)
998 viafb_second_xres
= 640;
1000 viafb_second_xres
= active_dev
.xres1
;
1001 if (!active_dev
.yres1
)
1002 viafb_second_yres
= 480;
1004 viafb_second_yres
= active_dev
.yres1
;
1005 if (active_dev
.bpp
!= 0)
1006 viafb_bpp
= active_dev
.bpp
;
1007 if (active_dev
.bpp1
!= 0)
1008 viafb_bpp1
= active_dev
.bpp1
;
1009 if (active_dev
.refresh
!= 0)
1010 viafb_refresh
= active_dev
.refresh
;
1011 if (active_dev
.refresh1
!= 0)
1012 viafb_refresh1
= active_dev
.refresh1
;
1013 if ((active_dev
.samm
== STATE_OFF
) || (active_dev
.samm
== STATE_ON
))
1014 viafb_SAMM_ON
= active_dev
.samm
;
1015 viafb_primary_dev
= active_dev
.primary_dev
;
1017 via_set_primary_address(0);
1018 via_set_secondary_address(viafb_SAMM_ON
? viafb_second_offset
: 0);
1019 viafb_set_iga_path();
1022 static int get_primary_device(void)
1024 int primary_device
= 0;
1025 /* Rule: device on iga1 path are the primary device. */
1026 if (viafb_SAMM_ON
) {
1028 if (viaparinfo
->crt_setting_info
->iga_path
== IGA1
) {
1029 DEBUG_MSG(KERN_INFO
"CRT IGA Path:%d\n",
1031 crt_setting_info
->iga_path
);
1032 primary_device
= CRT_Device
;
1036 if (viaparinfo
->tmds_setting_info
->iga_path
== IGA1
) {
1037 DEBUG_MSG(KERN_INFO
"DVI IGA Path:%d\n",
1039 tmds_setting_info
->iga_path
);
1040 primary_device
= DVI_Device
;
1044 if (viaparinfo
->lvds_setting_info
->iga_path
== IGA1
) {
1045 DEBUG_MSG(KERN_INFO
"LCD IGA Path:%d\n",
1047 lvds_setting_info
->iga_path
);
1048 primary_device
= LCD_Device
;
1051 if (viafb_LCD2_ON
) {
1052 if (viaparinfo
->lvds_setting_info2
->iga_path
== IGA1
) {
1053 DEBUG_MSG(KERN_INFO
"LCD2 IGA Path:%d\n",
1055 lvds_setting_info2
->iga_path
);
1056 primary_device
= LCD2_Device
;
1060 return primary_device
;
1063 static void apply_second_mode_setting(struct fb_var_screeninfo
1066 u32 htotal
, vtotal
, long_refresh
;
1068 htotal
= sec_var
->xres
+ sec_var
->left_margin
+
1069 sec_var
->right_margin
+ sec_var
->hsync_len
;
1070 vtotal
= sec_var
->yres
+ sec_var
->upper_margin
+
1071 sec_var
->lower_margin
+ sec_var
->vsync_len
;
1072 if ((sec_var
->xres_virtual
* (sec_var
->bits_per_pixel
>> 3)) & 0x1F) {
1073 /*Is 32 bytes alignment? */
1074 /*32 pixel alignment */
1075 sec_var
->xres_virtual
= (sec_var
->xres_virtual
+ 31) & ~31;
1078 htotal
= sec_var
->xres
+ sec_var
->left_margin
+
1079 sec_var
->right_margin
+ sec_var
->hsync_len
;
1080 vtotal
= sec_var
->yres
+ sec_var
->upper_margin
+
1081 sec_var
->lower_margin
+ sec_var
->vsync_len
;
1082 long_refresh
= 1000000000UL / sec_var
->pixclock
* 1000;
1083 long_refresh
/= (htotal
* vtotal
);
1085 viafb_second_xres
= sec_var
->xres
;
1086 viafb_second_yres
= sec_var
->yres
;
1087 viafb_second_virtual_xres
= sec_var
->xres_virtual
;
1088 viafb_second_virtual_yres
= sec_var
->yres_virtual
;
1089 viafb_bpp1
= sec_var
->bits_per_pixel
;
1090 viafb_refresh1
= viafb_get_refresh(sec_var
->xres
, sec_var
->yres
,
1094 static int apply_device_setting(struct viafb_ioctl_setting setting_info
,
1095 struct fb_info
*info
)
1097 int need_set_mode
= 0;
1098 DEBUG_MSG(KERN_INFO
"apply_device_setting\n");
1100 if (setting_info
.device_flag
) {
1102 check_available_device_to_enable(setting_info
.device_status
);
1105 /* Unlock LCD's operation according to LCD flag
1106 and check if the setting value is valid. */
1107 /* If the value is valid, apply the new setting value to the device. */
1109 if (setting_info
.lcd_operation_flag
& OP_LCD_CENTERING
) {
1111 if (setting_info
.lcd_attributes
.display_center
) {
1113 viaparinfo
->lvds_setting_info
->display_method
=
1115 viafb_lcd_dsp_method
= LCD_CENTERING
;
1116 viaparinfo
->lvds_setting_info2
->display_method
=
1117 viafb_lcd_dsp_method
= LCD_CENTERING
;
1120 viaparinfo
->lvds_setting_info
->display_method
=
1122 viafb_lcd_dsp_method
= LCD_EXPANDSION
;
1123 viaparinfo
->lvds_setting_info2
->display_method
=
1125 viafb_lcd_dsp_method
= LCD_EXPANDSION
;
1129 if (setting_info
.lcd_operation_flag
& OP_LCD_MODE
) {
1131 if (setting_info
.lcd_attributes
.lcd_mode
==
1133 viaparinfo
->lvds_setting_info
->lcd_mode
=
1134 viafb_lcd_mode
= LCD_SPWG
;
1136 viaparinfo
->lvds_setting_info
->lcd_mode
=
1137 viafb_lcd_mode
= LCD_OPENLDI
;
1139 viaparinfo
->lvds_setting_info2
->lcd_mode
=
1140 viaparinfo
->lvds_setting_info
->lcd_mode
;
1143 if (setting_info
.lcd_operation_flag
& OP_LCD_PANEL_ID
) {
1145 if (setting_info
.lcd_attributes
.panel_id
<=
1146 LCD_PANEL_ID_MAXIMUM
) {
1147 viafb_lcd_panel_id
=
1148 setting_info
.lcd_attributes
.panel_id
;
1149 viafb_init_lcd_size();
1154 if (0 != (setting_info
.samm_status
& OP_SAMM
)) {
1155 setting_info
.samm_status
=
1156 setting_info
.samm_status
& (~OP_SAMM
);
1157 if (setting_info
.samm_status
== 0
1158 || setting_info
.samm_status
== 1) {
1159 viafb_SAMM_ON
= setting_info
.samm_status
;
1162 viafb_primary_dev
= setting_info
.primary_device
;
1164 via_set_primary_address(0);
1165 via_set_secondary_address(viafb_SAMM_ON
?
1166 viafb_second_offset
: 0);
1167 viafb_set_iga_path();
1172 if (!need_set_mode
) {
1175 viafb_set_iga_path();
1176 viafb_set_par(info
);
1181 static void retrieve_device_setting(struct viafb_ioctl_setting
1185 /* get device status */
1186 if (viafb_CRT_ON
== 1)
1187 setting_info
->device_status
= CRT_Device
;
1188 if (viafb_DVI_ON
== 1)
1189 setting_info
->device_status
|= DVI_Device
;
1190 if (viafb_LCD_ON
== 1)
1191 setting_info
->device_status
|= LCD_Device
;
1192 if (viafb_LCD2_ON
== 1)
1193 setting_info
->device_status
|= LCD2_Device
;
1195 setting_info
->samm_status
= viafb_SAMM_ON
;
1196 setting_info
->primary_device
= get_primary_device();
1198 setting_info
->first_dev_bpp
= viafb_bpp
;
1199 setting_info
->second_dev_bpp
= viafb_bpp1
;
1201 setting_info
->first_dev_refresh
= viafb_refresh
;
1202 setting_info
->second_dev_refresh
= viafb_refresh1
;
1204 setting_info
->first_dev_hor_res
= viafb_hotplug_Xres
;
1205 setting_info
->first_dev_ver_res
= viafb_hotplug_Yres
;
1206 setting_info
->second_dev_hor_res
= viafb_second_xres
;
1207 setting_info
->second_dev_ver_res
= viafb_second_yres
;
1209 /* Get lcd attributes */
1210 setting_info
->lcd_attributes
.display_center
= viafb_lcd_dsp_method
;
1211 setting_info
->lcd_attributes
.panel_id
= viafb_lcd_panel_id
;
1212 setting_info
->lcd_attributes
.lcd_mode
= viafb_lcd_mode
;
1215 static int parse_active_dev(void)
1217 viafb_CRT_ON
= STATE_OFF
;
1218 viafb_DVI_ON
= STATE_OFF
;
1219 viafb_LCD_ON
= STATE_OFF
;
1220 viafb_LCD2_ON
= STATE_OFF
;
1221 /* 1. Modify the active status of devices. */
1222 /* 2. Keep the order of devices, so we can set corresponding
1223 IGA path to devices in SAMM case. */
1224 /* Note: The previous of active_dev is primary device,
1225 and the following is secondary device. */
1226 if (!viafb_active_dev
) {
1227 viafb_CRT_ON
= STATE_ON
;
1228 viafb_SAMM_ON
= STATE_OFF
;
1229 } else if (!strcmp(viafb_active_dev
, "CRT+DVI")) {
1231 viafb_CRT_ON
= STATE_ON
;
1232 viafb_DVI_ON
= STATE_ON
;
1233 viafb_primary_dev
= CRT_Device
;
1234 } else if (!strcmp(viafb_active_dev
, "DVI+CRT")) {
1236 viafb_CRT_ON
= STATE_ON
;
1237 viafb_DVI_ON
= STATE_ON
;
1238 viafb_primary_dev
= DVI_Device
;
1239 } else if (!strcmp(viafb_active_dev
, "CRT+LCD")) {
1241 viafb_CRT_ON
= STATE_ON
;
1242 viafb_LCD_ON
= STATE_ON
;
1243 viafb_primary_dev
= CRT_Device
;
1244 } else if (!strcmp(viafb_active_dev
, "LCD+CRT")) {
1246 viafb_CRT_ON
= STATE_ON
;
1247 viafb_LCD_ON
= STATE_ON
;
1248 viafb_primary_dev
= LCD_Device
;
1249 } else if (!strcmp(viafb_active_dev
, "DVI+LCD")) {
1251 viafb_DVI_ON
= STATE_ON
;
1252 viafb_LCD_ON
= STATE_ON
;
1253 viafb_primary_dev
= DVI_Device
;
1254 } else if (!strcmp(viafb_active_dev
, "LCD+DVI")) {
1256 viafb_DVI_ON
= STATE_ON
;
1257 viafb_LCD_ON
= STATE_ON
;
1258 viafb_primary_dev
= LCD_Device
;
1259 } else if (!strcmp(viafb_active_dev
, "LCD+LCD2")) {
1260 viafb_LCD_ON
= STATE_ON
;
1261 viafb_LCD2_ON
= STATE_ON
;
1262 viafb_primary_dev
= LCD_Device
;
1263 } else if (!strcmp(viafb_active_dev
, "LCD2+LCD")) {
1264 viafb_LCD_ON
= STATE_ON
;
1265 viafb_LCD2_ON
= STATE_ON
;
1266 viafb_primary_dev
= LCD2_Device
;
1267 } else if (!strcmp(viafb_active_dev
, "CRT")) {
1269 viafb_CRT_ON
= STATE_ON
;
1270 viafb_SAMM_ON
= STATE_OFF
;
1271 } else if (!strcmp(viafb_active_dev
, "DVI")) {
1273 viafb_DVI_ON
= STATE_ON
;
1274 viafb_SAMM_ON
= STATE_OFF
;
1275 } else if (!strcmp(viafb_active_dev
, "LCD")) {
1277 viafb_LCD_ON
= STATE_ON
;
1278 viafb_SAMM_ON
= STATE_OFF
;
1285 static int parse_port(char *opt_str
, int *output_interface
)
1287 if (!strncmp(opt_str
, "DVP0", 4))
1288 *output_interface
= INTERFACE_DVP0
;
1289 else if (!strncmp(opt_str
, "DVP1", 4))
1290 *output_interface
= INTERFACE_DVP1
;
1291 else if (!strncmp(opt_str
, "DFP_HIGHLOW", 11))
1292 *output_interface
= INTERFACE_DFP
;
1293 else if (!strncmp(opt_str
, "DFP_HIGH", 8))
1294 *output_interface
= INTERFACE_DFP_HIGH
;
1295 else if (!strncmp(opt_str
, "DFP_LOW", 7))
1296 *output_interface
= INTERFACE_DFP_LOW
;
1298 *output_interface
= INTERFACE_NONE
;
1302 static void parse_lcd_port(void)
1304 parse_port(viafb_lcd_port
, &viaparinfo
->chip_info
->lvds_chip_info
.
1306 /*Initialize to avoid unexpected behavior */
1307 viaparinfo
->chip_info
->lvds_chip_info2
.output_interface
=
1310 DEBUG_MSG(KERN_INFO
"parse_lcd_port: viafb_lcd_port:%s,interface:%d\n",
1311 viafb_lcd_port
, viaparinfo
->chip_info
->lvds_chip_info
.
1315 static void parse_dvi_port(void)
1317 parse_port(viafb_dvi_port
, &viaparinfo
->chip_info
->tmds_chip_info
.
1320 DEBUG_MSG(KERN_INFO
"parse_dvi_port: viafb_dvi_port:%s,interface:%d\n",
1321 viafb_dvi_port
, viaparinfo
->chip_info
->tmds_chip_info
.
1325 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1328 * The proc filesystem read/write function, a simple proc implement to
1329 * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
1330 * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2],
1331 * CR9B, SR65, CR97, CR99
1333 static int viafb_dvp0_proc_show(struct seq_file
*m
, void *v
)
1335 u8 dvp0_data_dri
= 0, dvp0_clk_dri
= 0, dvp0
= 0;
1337 (viafb_read_reg(VIASR
, SR2A
) & BIT5
) >> 4 |
1338 (viafb_read_reg(VIASR
, SR1B
) & BIT1
) >> 1;
1340 (viafb_read_reg(VIASR
, SR2A
) & BIT4
) >> 3 |
1341 (viafb_read_reg(VIASR
, SR1E
) & BIT2
) >> 2;
1342 dvp0
= viafb_read_reg(VIACR
, CR96
) & 0x0f;
1343 seq_printf(m
, "%x %x %x\n", dvp0
, dvp0_data_dri
, dvp0_clk_dri
);
1347 static int viafb_dvp0_proc_open(struct inode
*inode
, struct file
*file
)
1349 return single_open(file
, viafb_dvp0_proc_show
, NULL
);
1352 static ssize_t
viafb_dvp0_proc_write(struct file
*file
,
1353 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1355 char buf
[20], *value
, *pbuf
;
1357 unsigned long length
, i
;
1360 length
= count
> 20 ? 20 : count
;
1361 if (copy_from_user(&buf
[0], buffer
, length
))
1363 buf
[length
- 1] = '\0'; /*Ensure end string */
1365 for (i
= 0; i
< 3; i
++) {
1366 value
= strsep(&pbuf
, " ");
1367 if (value
!= NULL
) {
1368 strict_strtoul(value
, 0, (unsigned long *)®_val
);
1369 DEBUG_MSG(KERN_INFO
"DVP0:reg_val[%l]=:%x\n", i
,
1373 viafb_write_reg_mask(CR96
, VIACR
,
1377 viafb_write_reg_mask(SR2A
, VIASR
,
1378 reg_val
<< 4, BIT5
);
1379 viafb_write_reg_mask(SR1B
, VIASR
,
1380 reg_val
<< 1, BIT1
);
1383 viafb_write_reg_mask(SR2A
, VIASR
,
1384 reg_val
<< 3, BIT4
);
1385 viafb_write_reg_mask(SR1E
, VIASR
,
1386 reg_val
<< 2, BIT2
);
1398 static const struct file_operations viafb_dvp0_proc_fops
= {
1399 .owner
= THIS_MODULE
,
1400 .open
= viafb_dvp0_proc_open
,
1402 .llseek
= seq_lseek
,
1403 .release
= single_release
,
1404 .write
= viafb_dvp0_proc_write
,
1407 static int viafb_dvp1_proc_show(struct seq_file
*m
, void *v
)
1409 u8 dvp1
= 0, dvp1_data_dri
= 0, dvp1_clk_dri
= 0;
1410 dvp1
= viafb_read_reg(VIACR
, CR9B
) & 0x0f;
1411 dvp1_data_dri
= (viafb_read_reg(VIASR
, SR65
) & 0x0c) >> 2;
1412 dvp1_clk_dri
= viafb_read_reg(VIASR
, SR65
) & 0x03;
1413 seq_printf(m
, "%x %x %x\n", dvp1
, dvp1_data_dri
, dvp1_clk_dri
);
1417 static int viafb_dvp1_proc_open(struct inode
*inode
, struct file
*file
)
1419 return single_open(file
, viafb_dvp1_proc_show
, NULL
);
1422 static ssize_t
viafb_dvp1_proc_write(struct file
*file
,
1423 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1425 char buf
[20], *value
, *pbuf
;
1427 unsigned long length
, i
;
1430 length
= count
> 20 ? 20 : count
;
1431 if (copy_from_user(&buf
[0], buffer
, length
))
1433 buf
[length
- 1] = '\0'; /*Ensure end string */
1435 for (i
= 0; i
< 3; i
++) {
1436 value
= strsep(&pbuf
, " ");
1437 if (value
!= NULL
) {
1438 strict_strtoul(value
, 0, (unsigned long *)®_val
);
1441 viafb_write_reg_mask(CR9B
, VIACR
,
1445 viafb_write_reg_mask(SR65
, VIASR
,
1446 reg_val
<< 2, 0x0c);
1449 viafb_write_reg_mask(SR65
, VIASR
,
1462 static const struct file_operations viafb_dvp1_proc_fops
= {
1463 .owner
= THIS_MODULE
,
1464 .open
= viafb_dvp1_proc_open
,
1466 .llseek
= seq_lseek
,
1467 .release
= single_release
,
1468 .write
= viafb_dvp1_proc_write
,
1471 static int viafb_dfph_proc_show(struct seq_file
*m
, void *v
)
1474 dfp_high
= viafb_read_reg(VIACR
, CR97
) & 0x0f;
1475 seq_printf(m
, "%x\n", dfp_high
);
1479 static int viafb_dfph_proc_open(struct inode
*inode
, struct file
*file
)
1481 return single_open(file
, viafb_dfph_proc_show
, NULL
);
1484 static ssize_t
viafb_dfph_proc_write(struct file
*file
,
1485 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1489 unsigned long length
;
1492 length
= count
> 20 ? 20 : count
;
1493 if (copy_from_user(&buf
[0], buffer
, length
))
1495 buf
[length
- 1] = '\0'; /*Ensure end string */
1496 strict_strtoul(&buf
[0], 0, (unsigned long *)®_val
);
1497 viafb_write_reg_mask(CR97
, VIACR
, reg_val
, 0x0f);
1501 static const struct file_operations viafb_dfph_proc_fops
= {
1502 .owner
= THIS_MODULE
,
1503 .open
= viafb_dfph_proc_open
,
1505 .llseek
= seq_lseek
,
1506 .release
= single_release
,
1507 .write
= viafb_dfph_proc_write
,
1510 static int viafb_dfpl_proc_show(struct seq_file
*m
, void *v
)
1513 dfp_low
= viafb_read_reg(VIACR
, CR99
) & 0x0f;
1514 seq_printf(m
, "%x\n", dfp_low
);
1518 static int viafb_dfpl_proc_open(struct inode
*inode
, struct file
*file
)
1520 return single_open(file
, viafb_dfpl_proc_show
, NULL
);
1523 static ssize_t
viafb_dfpl_proc_write(struct file
*file
,
1524 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1528 unsigned long length
;
1531 length
= count
> 20 ? 20 : count
;
1532 if (copy_from_user(&buf
[0], buffer
, length
))
1534 buf
[length
- 1] = '\0'; /*Ensure end string */
1535 strict_strtoul(&buf
[0], 0, (unsigned long *)®_val
);
1536 viafb_write_reg_mask(CR99
, VIACR
, reg_val
, 0x0f);
1540 static const struct file_operations viafb_dfpl_proc_fops
= {
1541 .owner
= THIS_MODULE
,
1542 .open
= viafb_dfpl_proc_open
,
1544 .llseek
= seq_lseek
,
1545 .release
= single_release
,
1546 .write
= viafb_dfpl_proc_write
,
1549 static int viafb_vt1636_proc_show(struct seq_file
*m
, void *v
)
1551 u8 vt1636_08
= 0, vt1636_09
= 0;
1552 switch (viaparinfo
->chip_info
->lvds_chip_info
.lvds_chip_name
) {
1555 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info
,
1556 &viaparinfo
->chip_info
->lvds_chip_info
, 0x08) & 0x0f;
1558 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info
,
1559 &viaparinfo
->chip_info
->lvds_chip_info
, 0x09) & 0x1f;
1560 seq_printf(m
, "%x %x\n", vt1636_08
, vt1636_09
);
1565 switch (viaparinfo
->chip_info
->lvds_chip_info2
.lvds_chip_name
) {
1568 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info2
,
1569 &viaparinfo
->chip_info
->lvds_chip_info2
, 0x08) & 0x0f;
1571 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info2
,
1572 &viaparinfo
->chip_info
->lvds_chip_info2
, 0x09) & 0x1f;
1573 seq_printf(m
, " %x %x\n", vt1636_08
, vt1636_09
);
1581 static int viafb_vt1636_proc_open(struct inode
*inode
, struct file
*file
)
1583 return single_open(file
, viafb_vt1636_proc_show
, NULL
);
1586 static ssize_t
viafb_vt1636_proc_write(struct file
*file
,
1587 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1589 char buf
[30], *value
, *pbuf
;
1590 struct IODATA reg_val
;
1591 unsigned long length
, i
;
1594 length
= count
> 30 ? 30 : count
;
1595 if (copy_from_user(&buf
[0], buffer
, length
))
1597 buf
[length
- 1] = '\0'; /*Ensure end string */
1599 switch (viaparinfo
->chip_info
->lvds_chip_info
.lvds_chip_name
) {
1601 for (i
= 0; i
< 2; i
++) {
1602 value
= strsep(&pbuf
, " ");
1603 if (value
!= NULL
) {
1604 strict_strtoul(value
, 0,
1605 (unsigned long *)®_val
.Data
);
1608 reg_val
.Index
= 0x08;
1609 reg_val
.Mask
= 0x0f;
1610 viafb_gpio_i2c_write_mask_lvds
1611 (viaparinfo
->lvds_setting_info
,
1613 chip_info
->lvds_chip_info
,
1617 reg_val
.Index
= 0x09;
1618 reg_val
.Mask
= 0x1f;
1619 viafb_gpio_i2c_write_mask_lvds
1620 (viaparinfo
->lvds_setting_info
,
1622 chip_info
->lvds_chip_info
,
1636 switch (viaparinfo
->chip_info
->lvds_chip_info2
.lvds_chip_name
) {
1638 for (i
= 0; i
< 2; i
++) {
1639 value
= strsep(&pbuf
, " ");
1640 if (value
!= NULL
) {
1641 strict_strtoul(value
, 0,
1642 (unsigned long *)®_val
.Data
);
1645 reg_val
.Index
= 0x08;
1646 reg_val
.Mask
= 0x0f;
1647 viafb_gpio_i2c_write_mask_lvds
1648 (viaparinfo
->lvds_setting_info2
,
1650 chip_info
->lvds_chip_info2
,
1654 reg_val
.Index
= 0x09;
1655 reg_val
.Mask
= 0x1f;
1656 viafb_gpio_i2c_write_mask_lvds
1657 (viaparinfo
->lvds_setting_info2
,
1659 chip_info
->lvds_chip_info2
,
1676 static const struct file_operations viafb_vt1636_proc_fops
= {
1677 .owner
= THIS_MODULE
,
1678 .open
= viafb_vt1636_proc_open
,
1680 .llseek
= seq_lseek
,
1681 .release
= single_release
,
1682 .write
= viafb_vt1636_proc_write
,
1685 static void viafb_init_proc(struct proc_dir_entry
**viafb_entry
)
1687 *viafb_entry
= proc_mkdir("viafb", NULL
);
1689 proc_create("dvp0", 0, *viafb_entry
, &viafb_dvp0_proc_fops
);
1690 proc_create("dvp1", 0, *viafb_entry
, &viafb_dvp1_proc_fops
);
1691 proc_create("dfph", 0, *viafb_entry
, &viafb_dfph_proc_fops
);
1692 proc_create("dfpl", 0, *viafb_entry
, &viafb_dfpl_proc_fops
);
1693 if (VT1636_LVDS
== viaparinfo
->chip_info
->lvds_chip_info
.
1694 lvds_chip_name
|| VT1636_LVDS
==
1695 viaparinfo
->chip_info
->lvds_chip_info2
.lvds_chip_name
) {
1696 proc_create("vt1636", 0, *viafb_entry
, &viafb_vt1636_proc_fops
);
1701 static void viafb_remove_proc(struct proc_dir_entry
*viafb_entry
)
1703 struct chip_information
*chip_info
= &viaparinfo
->shared
->chip_info
;
1705 remove_proc_entry("dvp0", viafb_entry
);/* parent dir */
1706 remove_proc_entry("dvp1", viafb_entry
);
1707 remove_proc_entry("dfph", viafb_entry
);
1708 remove_proc_entry("dfpl", viafb_entry
);
1709 if (chip_info
->lvds_chip_info
.lvds_chip_name
== VT1636_LVDS
1710 || chip_info
->lvds_chip_info2
.lvds_chip_name
== VT1636_LVDS
)
1711 remove_proc_entry("vt1636", viafb_entry
);
1713 remove_proc_entry("viafb", NULL
);
1716 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
1718 static int parse_mode(const char *str
, u32
*xres
, u32
*yres
)
1728 *xres
= simple_strtoul(str
, &ptr
, 10);
1732 *yres
= simple_strtoul(&ptr
[1], &ptr
, 10);
1740 int __devinit
via_fb_pci_probe(struct viafb_dev
*vdev
)
1742 u32 default_xres
, default_yres
;
1743 struct VideoModeTable
*vmode_entry
;
1744 struct fb_var_screeninfo default_var
;
1746 u32 viafb_par_length
;
1748 DEBUG_MSG(KERN_INFO
"VIAFB PCI Probe!!\n");
1749 memset(&default_var
, 0, sizeof(default_var
));
1750 viafb_par_length
= ALIGN(sizeof(struct viafb_par
), BITS_PER_LONG
/8);
1752 /* Allocate fb_info and ***_par here, also including some other needed
1755 viafbinfo
= framebuffer_alloc(viafb_par_length
+
1756 ALIGN(sizeof(struct viafb_shared
), BITS_PER_LONG
/8),
1759 printk(KERN_ERR
"Could not allocate memory for viafb_info.\n");
1763 viaparinfo
= (struct viafb_par
*)viafbinfo
->par
;
1764 viaparinfo
->shared
= viafbinfo
->par
+ viafb_par_length
;
1765 viaparinfo
->shared
->vdev
= vdev
;
1766 viaparinfo
->vram_addr
= 0;
1767 viaparinfo
->tmds_setting_info
= &viaparinfo
->shared
->tmds_setting_info
;
1768 viaparinfo
->lvds_setting_info
= &viaparinfo
->shared
->lvds_setting_info
;
1769 viaparinfo
->lvds_setting_info2
=
1770 &viaparinfo
->shared
->lvds_setting_info2
;
1771 viaparinfo
->crt_setting_info
= &viaparinfo
->shared
->crt_setting_info
;
1772 viaparinfo
->chip_info
= &viaparinfo
->shared
->chip_info
;
1779 /* for dual-fb must viafb_SAMM_ON=1 and viafb_dual_fb=1 */
1783 viafb_init_chip_info(vdev
->chip_type
);
1785 * The framebuffer will have been successfully mapped by
1786 * the core (or we'd not be here), but we still need to
1787 * set up our own accounting.
1789 viaparinfo
->fbmem
= vdev
->fbmem_start
;
1790 viaparinfo
->memsize
= vdev
->fbmem_len
;
1791 viaparinfo
->fbmem_free
= viaparinfo
->memsize
;
1792 viaparinfo
->fbmem_used
= 0;
1793 viafbinfo
->screen_base
= vdev
->fbmem
;
1795 viafbinfo
->fix
.mmio_start
= vdev
->engine_start
;
1796 viafbinfo
->fix
.mmio_len
= vdev
->engine_len
;
1797 viafbinfo
->node
= 0;
1798 viafbinfo
->fbops
= &viafb_ops
;
1799 viafbinfo
->flags
= FBINFO_DEFAULT
| FBINFO_HWACCEL_YPAN
;
1801 viafbinfo
->pseudo_palette
= pseudo_pal
;
1802 if (viafb_accel
&& !viafb_init_engine(viafbinfo
)) {
1803 viafbinfo
->flags
|= FBINFO_HWACCEL_COPYAREA
|
1804 FBINFO_HWACCEL_FILLRECT
| FBINFO_HWACCEL_IMAGEBLIT
;
1805 default_var
.accel_flags
= FB_ACCELF_TEXT
;
1807 viafbinfo
->flags
|= FBINFO_HWACCEL_DISABLED
;
1808 default_var
.accel_flags
= 0;
1811 if (viafb_second_size
&& (viafb_second_size
< 8)) {
1812 viafb_second_offset
= viaparinfo
->fbmem_free
-
1813 viafb_second_size
* 1024 * 1024;
1815 viafb_second_size
= 8;
1816 viafb_second_offset
= viaparinfo
->fbmem_free
-
1817 viafb_second_size
* 1024 * 1024;
1820 parse_mode(viafb_mode
, &default_xres
, &default_yres
);
1821 vmode_entry
= viafb_get_mode(default_xres
, default_yres
);
1822 if (viafb_SAMM_ON
== 1) {
1823 parse_mode(viafb_mode1
, &viafb_second_xres
,
1824 &viafb_second_yres
);
1826 if (0 == viafb_second_virtual_xres
) {
1827 switch (viafb_second_xres
) {
1829 viafb_second_virtual_xres
= 1408;
1832 viafb_second_virtual_xres
= viafb_second_xres
;
1836 if (0 == viafb_second_virtual_yres
)
1837 viafb_second_virtual_yres
= viafb_second_yres
;
1840 default_var
.xres
= default_xres
;
1841 default_var
.yres
= default_yres
;
1842 switch (default_xres
) {
1844 default_var
.xres_virtual
= 1408;
1847 default_var
.xres_virtual
= default_xres
;
1850 default_var
.yres_virtual
= default_yres
;
1851 default_var
.bits_per_pixel
= viafb_bpp
;
1852 default_var
.pixclock
=
1853 viafb_get_pixclock(default_xres
, default_yres
, viafb_refresh
);
1854 default_var
.left_margin
= (default_xres
>> 3) & 0xf8;
1855 default_var
.right_margin
= 32;
1856 default_var
.upper_margin
= 16;
1857 default_var
.lower_margin
= 4;
1858 default_var
.hsync_len
= default_var
.left_margin
;
1859 default_var
.vsync_len
= 4;
1860 viafb_setup_fixinfo(&viafbinfo
->fix
, viaparinfo
);
1861 viafbinfo
->var
= default_var
;
1863 if (viafb_dual_fb
) {
1864 viafbinfo1
= framebuffer_alloc(viafb_par_length
,
1868 "allocate the second framebuffer struct error\n");
1870 goto out_fb_release
;
1872 viaparinfo1
= viafbinfo1
->par
;
1873 memcpy(viaparinfo1
, viaparinfo
, viafb_par_length
);
1874 viaparinfo1
->vram_addr
= viafb_second_offset
;
1875 viaparinfo1
->memsize
= viaparinfo
->memsize
-
1876 viafb_second_offset
;
1877 viaparinfo
->memsize
= viafb_second_offset
;
1878 viaparinfo1
->fbmem
= viaparinfo
->fbmem
+ viafb_second_offset
;
1880 viaparinfo1
->fbmem_used
= viaparinfo
->fbmem_used
;
1881 viaparinfo1
->fbmem_free
= viaparinfo1
->memsize
-
1882 viaparinfo1
->fbmem_used
;
1883 viaparinfo
->fbmem_free
= viaparinfo
->memsize
;
1884 viaparinfo
->fbmem_used
= 0;
1886 viaparinfo
->iga_path
= IGA1
;
1887 viaparinfo1
->iga_path
= IGA2
;
1888 memcpy(viafbinfo1
, viafbinfo
, sizeof(struct fb_info
));
1889 viafbinfo1
->par
= viaparinfo1
;
1890 viafbinfo1
->screen_base
= viafbinfo
->screen_base
+
1891 viafb_second_offset
;
1893 default_var
.xres
= viafb_second_xres
;
1894 default_var
.yres
= viafb_second_yres
;
1895 default_var
.xres_virtual
= viafb_second_virtual_xres
;
1896 default_var
.yres_virtual
= viafb_second_virtual_yres
;
1897 default_var
.bits_per_pixel
= viafb_bpp1
;
1898 default_var
.pixclock
=
1899 viafb_get_pixclock(viafb_second_xres
, viafb_second_yres
,
1901 default_var
.left_margin
= (viafb_second_xres
>> 3) & 0xf8;
1902 default_var
.right_margin
= 32;
1903 default_var
.upper_margin
= 16;
1904 default_var
.lower_margin
= 4;
1905 default_var
.hsync_len
= default_var
.left_margin
;
1906 default_var
.vsync_len
= 4;
1908 viafb_setup_fixinfo(&viafbinfo1
->fix
, viaparinfo1
);
1909 viafb_check_var(&default_var
, viafbinfo1
);
1910 viafbinfo1
->var
= default_var
;
1911 viafb_update_fix(viafbinfo1
);
1912 viaparinfo1
->depth
= fb_get_color_depth(&viafbinfo1
->var
,
1916 viafb_check_var(&viafbinfo
->var
, viafbinfo
);
1917 viafb_update_fix(viafbinfo
);
1918 viaparinfo
->depth
= fb_get_color_depth(&viafbinfo
->var
,
1920 default_var
.activate
= FB_ACTIVATE_NOW
;
1921 rc
= fb_alloc_cmap(&viafbinfo
->cmap
, 256, 0);
1923 goto out_fb1_release
;
1925 if (viafb_dual_fb
&& (viafb_primary_dev
== LCD_Device
)
1926 && (viaparinfo
->chip_info
->gfx_chip_name
== UNICHROME_CLE266
)) {
1927 rc
= register_framebuffer(viafbinfo1
);
1929 goto out_dealloc_cmap
;
1931 rc
= register_framebuffer(viafbinfo
);
1933 goto out_fb1_unreg_lcd_cle266
;
1935 if (viafb_dual_fb
&& ((viafb_primary_dev
!= LCD_Device
)
1936 || (viaparinfo
->chip_info
->gfx_chip_name
!=
1937 UNICHROME_CLE266
))) {
1938 rc
= register_framebuffer(viafbinfo1
);
1942 DEBUG_MSG(KERN_INFO
"fb%d: %s frame buffer device %dx%d-%dbpp\n",
1943 viafbinfo
->node
, viafbinfo
->fix
.id
, default_var
.xres
,
1944 default_var
.yres
, default_var
.bits_per_pixel
);
1946 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1947 viafb_init_proc(&viaparinfo
->shared
->proc_entry
);
1949 viafb_init_dac(IGA2
);
1953 unregister_framebuffer(viafbinfo
);
1954 out_fb1_unreg_lcd_cle266
:
1955 if (viafb_dual_fb
&& (viafb_primary_dev
== LCD_Device
)
1956 && (viaparinfo
->chip_info
->gfx_chip_name
== UNICHROME_CLE266
))
1957 unregister_framebuffer(viafbinfo1
);
1959 fb_dealloc_cmap(&viafbinfo
->cmap
);
1962 framebuffer_release(viafbinfo1
);
1964 framebuffer_release(viafbinfo
);
1968 void __devexit
via_fb_pci_remove(struct pci_dev
*pdev
)
1970 DEBUG_MSG(KERN_INFO
"via_pci_remove!\n");
1971 fb_dealloc_cmap(&viafbinfo
->cmap
);
1972 unregister_framebuffer(viafbinfo
);
1974 unregister_framebuffer(viafbinfo1
);
1975 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1976 viafb_remove_proc(viaparinfo
->shared
->proc_entry
);
1978 framebuffer_release(viafbinfo
);
1980 framebuffer_release(viafbinfo1
);
1984 static int __init
viafb_setup(char *options
)
1987 DEBUG_MSG(KERN_INFO
"viafb_setup!\n");
1989 if (!options
|| !*options
)
1992 while ((this_opt
= strsep(&options
, ",")) != NULL
) {
1996 if (!strncmp(this_opt
, "viafb_mode1=", 12))
1997 viafb_mode1
= kstrdup(this_opt
+ 12, GFP_KERNEL
);
1998 else if (!strncmp(this_opt
, "viafb_mode=", 11))
1999 viafb_mode
= kstrdup(this_opt
+ 11, GFP_KERNEL
);
2000 else if (!strncmp(this_opt
, "viafb_bpp1=", 11))
2001 strict_strtoul(this_opt
+ 11, 0,
2002 (unsigned long *)&viafb_bpp1
);
2003 else if (!strncmp(this_opt
, "viafb_bpp=", 10))
2004 strict_strtoul(this_opt
+ 10, 0,
2005 (unsigned long *)&viafb_bpp
);
2006 else if (!strncmp(this_opt
, "viafb_refresh1=", 15))
2007 strict_strtoul(this_opt
+ 15, 0,
2008 (unsigned long *)&viafb_refresh1
);
2009 else if (!strncmp(this_opt
, "viafb_refresh=", 14))
2010 strict_strtoul(this_opt
+ 14, 0,
2011 (unsigned long *)&viafb_refresh
);
2012 else if (!strncmp(this_opt
, "viafb_lcd_dsp_method=", 21))
2013 strict_strtoul(this_opt
+ 21, 0,
2014 (unsigned long *)&viafb_lcd_dsp_method
);
2015 else if (!strncmp(this_opt
, "viafb_lcd_panel_id=", 19))
2016 strict_strtoul(this_opt
+ 19, 0,
2017 (unsigned long *)&viafb_lcd_panel_id
);
2018 else if (!strncmp(this_opt
, "viafb_accel=", 12))
2019 strict_strtoul(this_opt
+ 12, 0,
2020 (unsigned long *)&viafb_accel
);
2021 else if (!strncmp(this_opt
, "viafb_SAMM_ON=", 14))
2022 strict_strtoul(this_opt
+ 14, 0,
2023 (unsigned long *)&viafb_SAMM_ON
);
2024 else if (!strncmp(this_opt
, "viafb_active_dev=", 17))
2025 viafb_active_dev
= kstrdup(this_opt
+ 17, GFP_KERNEL
);
2026 else if (!strncmp(this_opt
,
2027 "viafb_display_hardware_layout=", 30))
2028 strict_strtoul(this_opt
+ 30, 0,
2029 (unsigned long *)&viafb_display_hardware_layout
);
2030 else if (!strncmp(this_opt
, "viafb_second_size=", 18))
2031 strict_strtoul(this_opt
+ 18, 0,
2032 (unsigned long *)&viafb_second_size
);
2033 else if (!strncmp(this_opt
,
2034 "viafb_platform_epia_dvi=", 24))
2035 strict_strtoul(this_opt
+ 24, 0,
2036 (unsigned long *)&viafb_platform_epia_dvi
);
2037 else if (!strncmp(this_opt
,
2038 "viafb_device_lcd_dualedge=", 26))
2039 strict_strtoul(this_opt
+ 26, 0,
2040 (unsigned long *)&viafb_device_lcd_dualedge
);
2041 else if (!strncmp(this_opt
, "viafb_bus_width=", 16))
2042 strict_strtoul(this_opt
+ 16, 0,
2043 (unsigned long *)&viafb_bus_width
);
2044 else if (!strncmp(this_opt
, "viafb_lcd_mode=", 15))
2045 strict_strtoul(this_opt
+ 15, 0,
2046 (unsigned long *)&viafb_lcd_mode
);
2047 else if (!strncmp(this_opt
, "viafb_lcd_port=", 15))
2048 viafb_lcd_port
= kstrdup(this_opt
+ 15, GFP_KERNEL
);
2049 else if (!strncmp(this_opt
, "viafb_dvi_port=", 15))
2050 viafb_dvi_port
= kstrdup(this_opt
+ 15, GFP_KERNEL
);
2057 * These are called out of via-core for now.
2059 int __init
viafb_init(void)
2063 char *option
= NULL
;
2064 if (fb_get_options("viafb", &option
))
2066 viafb_setup(option
);
2068 if (parse_mode(viafb_mode
, &dummy
, &dummy
)
2069 || parse_mode(viafb_mode1
, &dummy
, &dummy
)
2070 || viafb_bpp
< 0 || viafb_bpp
> 32
2071 || viafb_bpp1
< 0 || viafb_bpp1
> 32
2072 || parse_active_dev())
2076 "VIA Graphics Intergration Chipset framebuffer %d.%d initializing\n",
2077 VERSION_MAJOR
, VERSION_MINOR
);
2081 void __exit
viafb_exit(void)
2083 DEBUG_MSG(KERN_INFO
"viafb_exit!\n");
2086 static struct fb_ops viafb_ops
= {
2087 .owner
= THIS_MODULE
,
2088 .fb_open
= viafb_open
,
2089 .fb_release
= viafb_release
,
2090 .fb_check_var
= viafb_check_var
,
2091 .fb_set_par
= viafb_set_par
,
2092 .fb_setcolreg
= viafb_setcolreg
,
2093 .fb_pan_display
= viafb_pan_display
,
2094 .fb_blank
= viafb_blank
,
2095 .fb_fillrect
= viafb_fillrect
,
2096 .fb_copyarea
= viafb_copyarea
,
2097 .fb_imageblit
= viafb_imageblit
,
2098 .fb_cursor
= viafb_cursor
,
2099 .fb_ioctl
= viafb_ioctl
,
2100 .fb_sync
= viafb_sync
,
2105 module_param(viafb_mode
, charp
, S_IRUSR
);
2106 MODULE_PARM_DESC(viafb_mode
, "Set resolution (default=640x480)");
2108 module_param(viafb_mode1
, charp
, S_IRUSR
);
2109 MODULE_PARM_DESC(viafb_mode1
, "Set resolution (default=640x480)");
2111 module_param(viafb_bpp
, int, S_IRUSR
);
2112 MODULE_PARM_DESC(viafb_bpp
, "Set color depth (default=32bpp)");
2114 module_param(viafb_bpp1
, int, S_IRUSR
);
2115 MODULE_PARM_DESC(viafb_bpp1
, "Set color depth (default=32bpp)");
2117 module_param(viafb_refresh
, int, S_IRUSR
);
2118 MODULE_PARM_DESC(viafb_refresh
,
2119 "Set CRT viafb_refresh rate (default = 60)");
2121 module_param(viafb_refresh1
, int, S_IRUSR
);
2122 MODULE_PARM_DESC(viafb_refresh1
,
2123 "Set CRT refresh rate (default = 60)");
2125 module_param(viafb_lcd_panel_id
, int, S_IRUSR
);
2126 MODULE_PARM_DESC(viafb_lcd_panel_id
,
2127 "Set Flat Panel type(Default=1024x768)");
2129 module_param(viafb_lcd_dsp_method
, int, S_IRUSR
);
2130 MODULE_PARM_DESC(viafb_lcd_dsp_method
,
2131 "Set Flat Panel display scaling method.(Default=Expandsion)");
2133 module_param(viafb_SAMM_ON
, int, S_IRUSR
);
2134 MODULE_PARM_DESC(viafb_SAMM_ON
,
2135 "Turn on/off flag of SAMM(Default=OFF)");
2137 module_param(viafb_accel
, int, S_IRUSR
);
2138 MODULE_PARM_DESC(viafb_accel
,
2139 "Set 2D Hardware Acceleration: 0 = OFF, 1 = ON (default)");
2141 module_param(viafb_active_dev
, charp
, S_IRUSR
);
2142 MODULE_PARM_DESC(viafb_active_dev
, "Specify active devices.");
2144 module_param(viafb_display_hardware_layout
, int, S_IRUSR
);
2145 MODULE_PARM_DESC(viafb_display_hardware_layout
,
2146 "Display Hardware Layout (LCD Only, DVI Only...,etc)");
2148 module_param(viafb_second_size
, int, S_IRUSR
);
2149 MODULE_PARM_DESC(viafb_second_size
,
2150 "Set secondary device memory size");
2152 module_param(viafb_dual_fb
, int, S_IRUSR
);
2153 MODULE_PARM_DESC(viafb_dual_fb
,
2154 "Turn on/off flag of dual framebuffer devices.(Default = OFF)");
2156 module_param(viafb_platform_epia_dvi
, int, S_IRUSR
);
2157 MODULE_PARM_DESC(viafb_platform_epia_dvi
,
2158 "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)");
2160 module_param(viafb_device_lcd_dualedge
, int, S_IRUSR
);
2161 MODULE_PARM_DESC(viafb_device_lcd_dualedge
,
2162 "Turn on/off flag of dual edge panel.(Default = OFF)");
2164 module_param(viafb_bus_width
, int, S_IRUSR
);
2165 MODULE_PARM_DESC(viafb_bus_width
,
2166 "Set bus width of panel.(Default = 12)");
2168 module_param(viafb_lcd_mode
, int, S_IRUSR
);
2169 MODULE_PARM_DESC(viafb_lcd_mode
,
2170 "Set Flat Panel mode(Default=OPENLDI)");
2172 module_param(viafb_lcd_port
, charp
, S_IRUSR
);
2173 MODULE_PARM_DESC(viafb_lcd_port
, "Specify LCD output port.");
2175 module_param(viafb_dvi_port
, charp
, S_IRUSR
);
2176 MODULE_PARM_DESC(viafb_dvi_port
, "Specify DVI output port.");
2178 MODULE_LICENSE("GPL");