2 * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public
7 * License as published by the Free Software Foundation;
8 * either version 2, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
12 * the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE.See the GNU General Public License
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #include <linux/module.h>
23 #include <linux/seq_file.h>
24 #include <linux/stat.h>
30 static char *viafb_name
= "Via";
31 static u32 pseudo_pal
[17];
34 static char *viafb_mode
;
35 static char *viafb_mode1
;
36 static int viafb_bpp
= 32;
37 static int viafb_bpp1
= 32;
39 static unsigned int viafb_second_offset
;
40 static int viafb_second_size
;
42 static int viafb_accel
= 1;
44 /* Added for specifying active devices.*/
45 char *viafb_active_dev
;
47 /*Added for specify lcd output port*/
48 char *viafb_lcd_port
= "";
49 char *viafb_dvi_port
= "";
51 static void viafb_set_device(struct device_t active_dev
);
52 static int apply_device_setting(struct viafb_ioctl_setting setting_info
,
53 struct fb_info
*info
);
54 static void apply_second_mode_setting(struct fb_var_screeninfo
56 static void retrieve_device_setting(struct viafb_ioctl_setting
58 static int viafb_pan_display(struct fb_var_screeninfo
*var
,
59 struct fb_info
*info
);
61 static struct fb_ops viafb_ops
;
64 static void viafb_fill_var_color_info(struct fb_var_screeninfo
*var
, u8 depth
)
67 var
->red
.msb_right
= 0;
68 var
->green
.msb_right
= 0;
69 var
->blue
.msb_right
= 0;
70 var
->transp
.offset
= 0;
71 var
->transp
.length
= 0;
72 var
->transp
.msb_right
= 0;
76 var
->bits_per_pixel
= 8;
78 var
->green
.offset
= 0;
81 var
->green
.length
= 8;
85 var
->bits_per_pixel
= 16;
87 var
->green
.offset
= 5;
90 var
->green
.length
= 5;
94 var
->bits_per_pixel
= 16;
96 var
->green
.offset
= 5;
99 var
->green
.length
= 6;
100 var
->blue
.length
= 5;
103 var
->bits_per_pixel
= 32;
104 var
->red
.offset
= 16;
105 var
->green
.offset
= 8;
106 var
->blue
.offset
= 0;
108 var
->green
.length
= 8;
109 var
->blue
.length
= 8;
112 var
->bits_per_pixel
= 32;
113 var
->red
.offset
= 20;
114 var
->green
.offset
= 10;
115 var
->blue
.offset
= 0;
116 var
->red
.length
= 10;
117 var
->green
.length
= 10;
118 var
->blue
.length
= 10;
123 static void viafb_update_fix(struct fb_info
*info
)
125 u32 bpp
= info
->var
.bits_per_pixel
;
128 bpp
== 8 ? FB_VISUAL_PSEUDOCOLOR
: FB_VISUAL_TRUECOLOR
;
129 info
->fix
.line_length
= (info
->var
.xres_virtual
* bpp
/ 8 + 7) & ~7;
132 static void viafb_setup_fixinfo(struct fb_fix_screeninfo
*fix
,
133 struct viafb_par
*viaparinfo
)
135 memset(fix
, 0, sizeof(struct fb_fix_screeninfo
));
136 strcpy(fix
->id
, viafb_name
);
138 fix
->smem_start
= viaparinfo
->fbmem
;
139 fix
->smem_len
= viaparinfo
->fbmem_free
;
141 fix
->type
= FB_TYPE_PACKED_PIXELS
;
143 fix
->visual
= FB_VISUAL_TRUECOLOR
;
145 fix
->xpanstep
= fix
->ywrapstep
= 0;
148 /* Just tell the accel name */
149 viafbinfo
->fix
.accel
= FB_ACCEL_VIA_UNICHROME
;
151 static int viafb_open(struct fb_info
*info
, int user
)
153 DEBUG_MSG(KERN_INFO
"viafb_open!\n");
157 static int viafb_release(struct fb_info
*info
, int user
)
159 DEBUG_MSG(KERN_INFO
"viafb_release!\n");
163 static int viafb_check_var(struct fb_var_screeninfo
*var
,
164 struct fb_info
*info
)
166 int htotal
, vtotal
, depth
;
167 struct VideoModeTable
*vmode_entry
;
168 struct viafb_par
*ppar
= info
->par
;
169 u32 long_refresh
, line
;
171 DEBUG_MSG(KERN_INFO
"viafb_check_var!\n");
173 /* HW neither support interlacte nor double-scaned mode */
174 if (var
->vmode
& FB_VMODE_INTERLACED
|| var
->vmode
& FB_VMODE_DOUBLE
)
177 vmode_entry
= viafb_get_mode(var
->xres
, var
->yres
);
180 "viafb: Mode %dx%dx%d not supported!!\n",
181 var
->xres
, var
->yres
, var
->bits_per_pixel
);
185 depth
= fb_get_color_depth(var
, &info
->fix
);
187 depth
= var
->bits_per_pixel
;
189 if (depth
< 0 || depth
> 32)
193 else if (depth
== 15 && viafb_dual_fb
&& ppar
->iga_path
== IGA1
)
195 else if (depth
== 30)
199 else if (depth
<= 16)
204 viafb_fill_var_color_info(var
, depth
);
205 line
= (var
->xres_virtual
* var
->bits_per_pixel
/ 8 + 7) & ~7;
206 if (line
* var
->yres_virtual
> ppar
->memsize
)
209 /* Based on var passed in to calculate the refresh,
210 * because our driver use some modes special.
212 htotal
= var
->xres
+ var
->left_margin
+
213 var
->right_margin
+ var
->hsync_len
;
214 vtotal
= var
->yres
+ var
->upper_margin
+
215 var
->lower_margin
+ var
->vsync_len
;
216 long_refresh
= 1000000000UL / var
->pixclock
* 1000;
217 long_refresh
/= (htotal
* vtotal
);
219 viafb_refresh
= viafb_get_refresh(var
->xres
, var
->yres
, long_refresh
);
221 /* Adjust var according to our driver's own table */
222 viafb_fill_var_timing_info(var
, viafb_refresh
, vmode_entry
);
223 if (info
->var
.accel_flags
& FB_ACCELF_TEXT
&&
224 !ppar
->shared
->vdev
->engine_mmio
)
225 info
->var
.accel_flags
= 0;
230 static int viafb_set_par(struct fb_info
*info
)
232 struct viafb_par
*viapar
= info
->par
;
233 struct VideoModeTable
*vmode_entry
, *vmode_entry1
= NULL
;
234 DEBUG_MSG(KERN_INFO
"viafb_set_par!\n");
236 viapar
->depth
= fb_get_color_depth(&info
->var
, &info
->fix
);
237 viafb_update_device_setting(viafbinfo
->var
.xres
, viafbinfo
->var
.yres
,
238 viafbinfo
->var
.bits_per_pixel
, viafb_refresh
, 0);
240 vmode_entry
= viafb_get_mode(viafbinfo
->var
.xres
, viafbinfo
->var
.yres
);
242 vmode_entry1
= viafb_get_mode(viafbinfo1
->var
.xres
,
243 viafbinfo1
->var
.yres
);
244 viafb_update_device_setting(viafbinfo1
->var
.xres
,
245 viafbinfo1
->var
.yres
, viafbinfo1
->var
.bits_per_pixel
,
247 } else if (viafb_SAMM_ON
== 1) {
249 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
250 viafb_second_xres
, viafb_second_yres
, viafb_bpp1
);
251 vmode_entry1
= viafb_get_mode(viafb_second_xres
,
254 viafb_update_device_setting(viafb_second_xres
,
255 viafb_second_yres
, viafb_bpp1
, viafb_refresh1
, 1);
259 viafb_update_fix(info
);
260 if (viafb_dual_fb
&& viapar
->iga_path
== IGA2
)
261 viafb_bpp1
= info
->var
.bits_per_pixel
;
263 viafb_bpp
= info
->var
.bits_per_pixel
;
265 if (info
->var
.accel_flags
& FB_ACCELF_TEXT
)
266 info
->flags
&= ~FBINFO_HWACCEL_DISABLED
;
268 info
->flags
|= FBINFO_HWACCEL_DISABLED
;
269 viafb_setmode(vmode_entry
, info
->var
.bits_per_pixel
,
270 vmode_entry1
, viafb_bpp1
);
271 viafb_pan_display(&info
->var
, info
);
277 /* Set one color register */
278 static int viafb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
279 unsigned blue
, unsigned transp
, struct fb_info
*info
)
281 struct viafb_par
*viapar
= info
->par
;
284 if (info
->fix
.visual
== FB_VISUAL_PSEUDOCOLOR
) {
288 if (!viafb_dual_fb
|| viapar
->iga_path
== IGA1
)
289 viafb_set_primary_color_register(regno
, red
>> 8,
290 green
>> 8, blue
>> 8);
292 if (!viafb_dual_fb
|| viapar
->iga_path
== IGA2
)
293 viafb_set_secondary_color_register(regno
, red
>> 8,
294 green
>> 8, blue
>> 8);
299 r
= (red
>> (16 - info
->var
.red
.length
))
300 << info
->var
.red
.offset
;
301 b
= (blue
>> (16 - info
->var
.blue
.length
))
302 << info
->var
.blue
.offset
;
303 g
= (green
>> (16 - info
->var
.green
.length
))
304 << info
->var
.green
.offset
;
305 ((u32
*) info
->pseudo_palette
)[regno
] = r
| g
| b
;
311 static int viafb_pan_display(struct fb_var_screeninfo
*var
,
312 struct fb_info
*info
)
314 struct viafb_par
*viapar
= info
->par
;
315 u32 vram_addr
= (var
->yoffset
* var
->xres_virtual
+ var
->xoffset
)
316 * (var
->bits_per_pixel
/ 8) + viapar
->vram_addr
;
318 DEBUG_MSG(KERN_DEBUG
"viafb_pan_display, address = %d\n", vram_addr
);
319 if (!viafb_dual_fb
) {
320 via_set_primary_address(vram_addr
);
321 via_set_secondary_address(vram_addr
);
322 } else if (viapar
->iga_path
== IGA1
)
323 via_set_primary_address(vram_addr
);
325 via_set_secondary_address(vram_addr
);
330 static int viafb_blank(int blank_mode
, struct fb_info
*info
)
332 DEBUG_MSG(KERN_INFO
"viafb_blank!\n");
333 /* clear DPMS setting */
335 switch (blank_mode
) {
336 case FB_BLANK_UNBLANK
:
337 /* Screen: On, HSync: On, VSync: On */
338 /* control CRT monitor power management */
339 viafb_write_reg_mask(CR36
, VIACR
, 0x00, BIT4
+ BIT5
);
341 case FB_BLANK_HSYNC_SUSPEND
:
342 /* Screen: Off, HSync: Off, VSync: On */
343 /* control CRT monitor power management */
344 viafb_write_reg_mask(CR36
, VIACR
, 0x10, BIT4
+ BIT5
);
346 case FB_BLANK_VSYNC_SUSPEND
:
347 /* Screen: Off, HSync: On, VSync: Off */
348 /* control CRT monitor power management */
349 viafb_write_reg_mask(CR36
, VIACR
, 0x20, BIT4
+ BIT5
);
351 case FB_BLANK_POWERDOWN
:
352 /* Screen: Off, HSync: Off, VSync: Off */
353 /* control CRT monitor power management */
354 viafb_write_reg_mask(CR36
, VIACR
, 0x30, BIT4
+ BIT5
);
361 static int viafb_ioctl(struct fb_info
*info
, u_int cmd
, u_long arg
)
364 struct viafb_ioctl_mode viamode
;
365 struct viafb_ioctl_samm viasamm
;
366 struct viafb_driver_version driver_version
;
367 struct fb_var_screeninfo sec_var
;
368 struct _panel_size_pos_info panel_pos_size_para
;
369 struct viafb_ioctl_setting viafb_setting
;
370 struct device_t active_dev
;
373 u32
*viafb_gamma_table
;
374 char driver_name
[] = "viafb";
376 u32 __user
*argp
= (u32 __user
*) arg
;
379 DEBUG_MSG(KERN_INFO
"viafb_ioctl: 0x%X !!\n", cmd
);
380 printk(KERN_WARNING
"viafb_ioctl: Please avoid this interface as it is unstable and might change or vanish at any time!\n");
381 memset(&u
, 0, sizeof(u
));
384 case VIAFB_GET_CHIP_INFO
:
385 if (copy_to_user(argp
, viaparinfo
->chip_info
,
386 sizeof(struct chip_information
)))
389 case VIAFB_GET_INFO_SIZE
:
390 return put_user((u32
)sizeof(struct viafb_ioctl_info
), argp
);
392 return viafb_ioctl_get_viafb_info(arg
);
394 return put_user(viafb_ioctl_hotplug(info
->var
.xres
,
396 info
->var
.bits_per_pixel
), argp
);
397 case VIAFB_SET_HOTPLUG_FLAG
:
398 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
400 viafb_hotplug
= (gpu32
) ? 1 : 0;
402 case VIAFB_GET_RESOLUTION
:
403 u
.viamode
.xres
= (u32
) viafb_hotplug_Xres
;
404 u
.viamode
.yres
= (u32
) viafb_hotplug_Yres
;
405 u
.viamode
.refresh
= (u32
) viafb_hotplug_refresh
;
406 u
.viamode
.bpp
= (u32
) viafb_hotplug_bpp
;
407 if (viafb_SAMM_ON
== 1) {
408 u
.viamode
.xres_sec
= viafb_second_xres
;
409 u
.viamode
.yres_sec
= viafb_second_yres
;
410 u
.viamode
.virtual_xres_sec
= viafb_second_virtual_xres
;
411 u
.viamode
.virtual_yres_sec
= viafb_second_virtual_yres
;
412 u
.viamode
.refresh_sec
= viafb_refresh1
;
413 u
.viamode
.bpp_sec
= viafb_bpp1
;
415 u
.viamode
.xres_sec
= 0;
416 u
.viamode
.yres_sec
= 0;
417 u
.viamode
.virtual_xres_sec
= 0;
418 u
.viamode
.virtual_yres_sec
= 0;
419 u
.viamode
.refresh_sec
= 0;
420 u
.viamode
.bpp_sec
= 0;
422 if (copy_to_user(argp
, &u
.viamode
, sizeof(u
.viamode
)))
425 case VIAFB_GET_SAMM_INFO
:
426 u
.viasamm
.samm_status
= viafb_SAMM_ON
;
428 if (viafb_SAMM_ON
== 1) {
430 u
.viasamm
.size_prim
= viaparinfo
->fbmem_free
;
431 u
.viasamm
.size_sec
= viaparinfo1
->fbmem_free
;
433 if (viafb_second_size
) {
434 u
.viasamm
.size_prim
=
435 viaparinfo
->fbmem_free
-
436 viafb_second_size
* 1024 * 1024;
438 viafb_second_size
* 1024 * 1024;
440 u
.viasamm
.size_prim
=
441 viaparinfo
->fbmem_free
>> 1;
443 (viaparinfo
->fbmem_free
>> 1);
446 u
.viasamm
.mem_base
= viaparinfo
->fbmem
;
447 u
.viasamm
.offset_sec
= viafb_second_offset
;
449 u
.viasamm
.size_prim
=
450 viaparinfo
->memsize
- viaparinfo
->fbmem_used
;
451 u
.viasamm
.size_sec
= 0;
452 u
.viasamm
.mem_base
= viaparinfo
->fbmem
;
453 u
.viasamm
.offset_sec
= 0;
456 if (copy_to_user(argp
, &u
.viasamm
, sizeof(u
.viasamm
)))
460 case VIAFB_TURN_ON_OUTPUT_DEVICE
:
461 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
463 if (gpu32
& CRT_Device
)
465 if (gpu32
& DVI_Device
)
467 if (gpu32
& LCD_Device
)
470 case VIAFB_TURN_OFF_OUTPUT_DEVICE
:
471 if (copy_from_user(&gpu32
, argp
, sizeof(gpu32
)))
473 if (gpu32
& CRT_Device
)
475 if (gpu32
& DVI_Device
)
477 if (gpu32
& LCD_Device
)
480 case VIAFB_SET_DEVICE
:
481 if (copy_from_user(&u
.active_dev
, (void *)argp
,
482 sizeof(u
.active_dev
)))
484 viafb_set_device(u
.active_dev
);
487 case VIAFB_GET_DEVICE
:
488 u
.active_dev
.crt
= viafb_CRT_ON
;
489 u
.active_dev
.dvi
= viafb_DVI_ON
;
490 u
.active_dev
.lcd
= viafb_LCD_ON
;
491 u
.active_dev
.samm
= viafb_SAMM_ON
;
492 u
.active_dev
.primary_dev
= viafb_primary_dev
;
494 u
.active_dev
.lcd_dsp_cent
= viafb_lcd_dsp_method
;
495 u
.active_dev
.lcd_panel_id
= viafb_lcd_panel_id
;
496 u
.active_dev
.lcd_mode
= viafb_lcd_mode
;
498 u
.active_dev
.xres
= viafb_hotplug_Xres
;
499 u
.active_dev
.yres
= viafb_hotplug_Yres
;
501 u
.active_dev
.xres1
= viafb_second_xres
;
502 u
.active_dev
.yres1
= viafb_second_yres
;
504 u
.active_dev
.bpp
= viafb_bpp
;
505 u
.active_dev
.bpp1
= viafb_bpp1
;
506 u
.active_dev
.refresh
= viafb_refresh
;
507 u
.active_dev
.refresh1
= viafb_refresh1
;
509 u
.active_dev
.epia_dvi
= viafb_platform_epia_dvi
;
510 u
.active_dev
.lcd_dual_edge
= viafb_device_lcd_dualedge
;
511 u
.active_dev
.bus_width
= viafb_bus_width
;
513 if (copy_to_user(argp
, &u
.active_dev
, sizeof(u
.active_dev
)))
517 case VIAFB_GET_DRIVER_VERSION
:
518 u
.driver_version
.iMajorNum
= VERSION_MAJOR
;
519 u
.driver_version
.iKernelNum
= VERSION_KERNEL
;
520 u
.driver_version
.iOSNum
= VERSION_OS
;
521 u
.driver_version
.iMinorNum
= VERSION_MINOR
;
523 if (copy_to_user(argp
, &u
.driver_version
,
524 sizeof(u
.driver_version
)))
529 case VIAFB_SET_DEVICE_INFO
:
530 if (copy_from_user(&u
.viafb_setting
,
531 argp
, sizeof(u
.viafb_setting
)))
533 if (apply_device_setting(u
.viafb_setting
, info
) < 0)
538 case VIAFB_SET_SECOND_MODE
:
539 if (copy_from_user(&u
.sec_var
, argp
, sizeof(u
.sec_var
)))
541 apply_second_mode_setting(&u
.sec_var
);
544 case VIAFB_GET_DEVICE_INFO
:
546 retrieve_device_setting(&u
.viafb_setting
);
548 if (copy_to_user(argp
, &u
.viafb_setting
,
549 sizeof(u
.viafb_setting
)))
554 case VIAFB_GET_DEVICE_SUPPORT
:
555 viafb_get_device_support_state(&state_info
);
556 if (put_user(state_info
, argp
))
560 case VIAFB_GET_DEVICE_CONNECT
:
561 viafb_get_device_connect_state(&state_info
);
562 if (put_user(state_info
, argp
))
566 case VIAFB_GET_PANEL_SUPPORT_EXPAND
:
568 viafb_lcd_get_support_expand_state(info
->var
.xres
,
570 if (put_user(state_info
, argp
))
574 case VIAFB_GET_DRIVER_NAME
:
575 if (copy_to_user(argp
, driver_name
, sizeof(driver_name
)))
579 case VIAFB_SET_GAMMA_LUT
:
580 viafb_gamma_table
= kmalloc(256 * sizeof(u32
), GFP_KERNEL
);
581 if (!viafb_gamma_table
)
583 if (copy_from_user(viafb_gamma_table
, argp
,
584 256 * sizeof(u32
))) {
585 kfree(viafb_gamma_table
);
588 viafb_set_gamma_table(viafb_bpp
, viafb_gamma_table
);
589 kfree(viafb_gamma_table
);
592 case VIAFB_GET_GAMMA_LUT
:
593 viafb_gamma_table
= kmalloc(256 * sizeof(u32
), GFP_KERNEL
);
594 if (!viafb_gamma_table
)
596 viafb_get_gamma_table(viafb_gamma_table
);
597 if (copy_to_user(argp
, viafb_gamma_table
,
598 256 * sizeof(u32
))) {
599 kfree(viafb_gamma_table
);
602 kfree(viafb_gamma_table
);
605 case VIAFB_GET_GAMMA_SUPPORT_STATE
:
606 viafb_get_gamma_support_state(viafb_bpp
, &state_info
);
607 if (put_user(state_info
, argp
))
610 case VIAFB_SYNC_SURFACE
:
611 DEBUG_MSG(KERN_INFO
"lobo VIAFB_SYNC_SURFACE\n");
613 case VIAFB_GET_DRIVER_CAPS
:
616 case VIAFB_GET_PANEL_MAX_SIZE
:
617 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
618 sizeof(u
.panel_pos_size_para
)))
620 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
621 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
622 sizeof(u
.panel_pos_size_para
)))
625 case VIAFB_GET_PANEL_MAX_POSITION
:
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
)))
635 case VIAFB_GET_PANEL_POSITION
:
636 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
637 sizeof(u
.panel_pos_size_para
)))
639 u
.panel_pos_size_para
.x
= u
.panel_pos_size_para
.y
= 0;
640 if (copy_to_user(argp
, &u
.panel_pos_size_para
,
641 sizeof(u
.panel_pos_size_para
)))
644 case VIAFB_GET_PANEL_SIZE
:
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
)))
654 case VIAFB_SET_PANEL_POSITION
:
655 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
656 sizeof(u
.panel_pos_size_para
)))
659 case VIAFB_SET_PANEL_SIZE
:
660 if (copy_from_user(&u
.panel_pos_size_para
, argp
,
661 sizeof(u
.panel_pos_size_para
)))
672 static void viafb_fillrect(struct fb_info
*info
,
673 const struct fb_fillrect
*rect
)
675 struct viafb_par
*viapar
= info
->par
;
676 struct viafb_shared
*shared
= viapar
->shared
;
680 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
) {
681 cfb_fillrect(info
, rect
);
685 if (!rect
->width
|| !rect
->height
)
688 if (info
->fix
.visual
== FB_VISUAL_TRUECOLOR
)
689 fg_color
= ((u32
*)info
->pseudo_palette
)[rect
->color
];
691 fg_color
= rect
->color
;
693 if (rect
->rop
== ROP_XOR
)
698 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: fillrect\n");
699 if (shared
->hw_bitblt(shared
->vdev
->engine_mmio
, VIA_BITBLT_FILL
,
700 rect
->width
, rect
->height
, info
->var
.bits_per_pixel
,
701 viapar
->vram_addr
, info
->fix
.line_length
, rect
->dx
, rect
->dy
,
702 NULL
, 0, 0, 0, 0, fg_color
, 0, rop
))
703 cfb_fillrect(info
, rect
);
706 static void viafb_copyarea(struct fb_info
*info
,
707 const struct fb_copyarea
*area
)
709 struct viafb_par
*viapar
= info
->par
;
710 struct viafb_shared
*shared
= viapar
->shared
;
712 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
) {
713 cfb_copyarea(info
, area
);
717 if (!area
->width
|| !area
->height
)
720 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: copyarea\n");
721 if (shared
->hw_bitblt(shared
->vdev
->engine_mmio
, VIA_BITBLT_COLOR
,
722 area
->width
, area
->height
, info
->var
.bits_per_pixel
,
723 viapar
->vram_addr
, info
->fix
.line_length
, area
->dx
, area
->dy
,
724 NULL
, viapar
->vram_addr
, info
->fix
.line_length
,
725 area
->sx
, area
->sy
, 0, 0, 0))
726 cfb_copyarea(info
, area
);
729 static void viafb_imageblit(struct fb_info
*info
,
730 const struct fb_image
*image
)
732 struct viafb_par
*viapar
= info
->par
;
733 struct viafb_shared
*shared
= viapar
->shared
;
734 u32 fg_color
= 0, bg_color
= 0;
737 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| !shared
->hw_bitblt
||
738 (image
->depth
!= 1 && image
->depth
!= viapar
->depth
)) {
739 cfb_imageblit(info
, image
);
743 if (image
->depth
== 1) {
744 op
= VIA_BITBLT_MONO
;
745 if (info
->fix
.visual
== FB_VISUAL_TRUECOLOR
) {
747 ((u32
*)info
->pseudo_palette
)[image
->fg_color
];
749 ((u32
*)info
->pseudo_palette
)[image
->bg_color
];
751 fg_color
= image
->fg_color
;
752 bg_color
= image
->bg_color
;
755 op
= VIA_BITBLT_COLOR
;
757 DEBUG_MSG(KERN_DEBUG
"viafb 2D engine: imageblit\n");
758 if (shared
->hw_bitblt(shared
->vdev
->engine_mmio
, op
,
759 image
->width
, image
->height
, info
->var
.bits_per_pixel
,
760 viapar
->vram_addr
, info
->fix
.line_length
, image
->dx
, image
->dy
,
761 (u32
*)image
->data
, 0, 0, 0, 0, fg_color
, bg_color
, 0))
762 cfb_imageblit(info
, image
);
765 static int viafb_cursor(struct fb_info
*info
, struct fb_cursor
*cursor
)
767 struct viafb_par
*viapar
= info
->par
;
768 void __iomem
*engine
= viapar
->shared
->vdev
->engine_mmio
;
769 u32 temp
, xx
, yy
, bg_color
= 0, fg_color
= 0,
770 chip_name
= viapar
->shared
->chip_info
.gfx_chip_name
;
771 int i
, j
= 0, cur_size
= 64;
773 if (info
->flags
& FBINFO_HWACCEL_DISABLED
|| info
!= viafbinfo
)
776 /* LCD ouput does not support hw cursors (at least on VN896) */
777 if ((chip_name
== UNICHROME_CLE266
&& viapar
->iga_path
== IGA2
) ||
781 viafb_show_hw_cursor(info
, HW_Cursor_OFF
);
783 if (cursor
->set
& FB_CUR_SETHOT
) {
784 temp
= (cursor
->hot
.x
<< 16) + cursor
->hot
.y
;
785 writel(temp
, engine
+ VIA_REG_CURSOR_ORG
);
788 if (cursor
->set
& FB_CUR_SETPOS
) {
789 yy
= cursor
->image
.dy
- info
->var
.yoffset
;
790 xx
= cursor
->image
.dx
- info
->var
.xoffset
;
793 writel(temp
, engine
+ VIA_REG_CURSOR_POS
);
796 if (cursor
->image
.width
<= 32 && cursor
->image
.height
<= 32)
798 else if (cursor
->image
.width
<= 64 && cursor
->image
.height
<= 64)
801 printk(KERN_WARNING
"viafb_cursor: The cursor is too large "
802 "%dx%d", cursor
->image
.width
, cursor
->image
.height
);
806 if (cursor
->set
& FB_CUR_SETSIZE
) {
807 temp
= readl(engine
+ VIA_REG_CURSOR_MODE
);
813 writel(temp
, engine
+ VIA_REG_CURSOR_MODE
);
816 if (cursor
->set
& FB_CUR_SETCMAP
) {
817 fg_color
= cursor
->image
.fg_color
;
818 bg_color
= cursor
->image
.bg_color
;
819 if (chip_name
== UNICHROME_CX700
||
820 chip_name
== UNICHROME_VX800
||
821 chip_name
== UNICHROME_VX855
) {
823 ((info
->cmap
.red
[fg_color
] & 0xFFC0) << 14) |
824 ((info
->cmap
.green
[fg_color
] & 0xFFC0) << 4) |
825 ((info
->cmap
.blue
[fg_color
] & 0xFFC0) >> 6);
827 ((info
->cmap
.red
[bg_color
] & 0xFFC0) << 14) |
828 ((info
->cmap
.green
[bg_color
] & 0xFFC0) << 4) |
829 ((info
->cmap
.blue
[bg_color
] & 0xFFC0) >> 6);
832 ((info
->cmap
.red
[fg_color
] & 0xFF00) << 8) |
833 (info
->cmap
.green
[fg_color
] & 0xFF00) |
834 ((info
->cmap
.blue
[fg_color
] & 0xFF00) >> 8);
836 ((info
->cmap
.red
[bg_color
] & 0xFF00) << 8) |
837 (info
->cmap
.green
[bg_color
] & 0xFF00) |
838 ((info
->cmap
.blue
[bg_color
] & 0xFF00) >> 8);
841 writel(bg_color
, engine
+ VIA_REG_CURSOR_BG
);
842 writel(fg_color
, engine
+ VIA_REG_CURSOR_FG
);
845 if (cursor
->set
& FB_CUR_SETSHAPE
) {
847 u8 data
[CURSOR_SIZE
];
848 u32 bak
[CURSOR_SIZE
/ 4];
849 } *cr_data
= kzalloc(sizeof(*cr_data
), GFP_ATOMIC
);
850 int size
= ((cursor
->image
.width
+ 7) >> 3) *
851 cursor
->image
.height
;
856 if (cur_size
== 32) {
857 for (i
= 0; i
< (CURSOR_SIZE
/ 4); i
++) {
858 cr_data
->bak
[i
] = 0x0;
859 cr_data
->bak
[i
+ 1] = 0xFFFFFFFF;
863 for (i
= 0; i
< (CURSOR_SIZE
/ 4); i
++) {
864 cr_data
->bak
[i
] = 0x0;
865 cr_data
->bak
[i
+ 1] = 0x0;
866 cr_data
->bak
[i
+ 2] = 0xFFFFFFFF;
867 cr_data
->bak
[i
+ 3] = 0xFFFFFFFF;
872 switch (cursor
->rop
) {
874 for (i
= 0; i
< size
; i
++)
875 cr_data
->data
[i
] = cursor
->mask
[i
];
879 for (i
= 0; i
< size
; i
++)
880 cr_data
->data
[i
] = cursor
->mask
[i
];
886 if (cur_size
== 32) {
887 for (i
= 0; i
< size
; i
++) {
888 cr_data
->bak
[j
] = (u32
) cr_data
->data
[i
];
889 cr_data
->bak
[j
+ 1] = ~cr_data
->bak
[j
];
893 for (i
= 0; i
< size
; i
++) {
894 cr_data
->bak
[j
] = (u32
) cr_data
->data
[i
];
895 cr_data
->bak
[j
+ 1] = 0x0;
896 cr_data
->bak
[j
+ 2] = ~cr_data
->bak
[j
];
897 cr_data
->bak
[j
+ 3] = ~cr_data
->bak
[j
+ 1];
902 memcpy_toio(viafbinfo
->screen_base
+ viapar
->shared
->
903 cursor_vram_addr
, cr_data
->bak
, CURSOR_SIZE
);
908 viafb_show_hw_cursor(info
, HW_Cursor_ON
);
913 static int viafb_sync(struct fb_info
*info
)
915 if (!(info
->flags
& FBINFO_HWACCEL_DISABLED
))
916 viafb_wait_engine_idle(info
);
920 static void check_available_device_to_enable(int device_id
)
925 viafb_CRT_ON
= STATE_OFF
;
926 viafb_DVI_ON
= STATE_OFF
;
927 viafb_LCD_ON
= STATE_OFF
;
928 viafb_LCD2_ON
= STATE_OFF
;
929 viafb_DeviceStatus
= None_Device
;
931 if ((device_id
& CRT_Device
) && (device_num
< MAX_ACTIVE_DEV_NUM
)) {
932 viafb_CRT_ON
= STATE_ON
;
934 viafb_DeviceStatus
|= CRT_Device
;
937 if ((device_id
& DVI_Device
) && (device_num
< MAX_ACTIVE_DEV_NUM
)) {
938 viafb_DVI_ON
= STATE_ON
;
940 viafb_DeviceStatus
|= DVI_Device
;
943 if ((device_id
& LCD_Device
) && (device_num
< MAX_ACTIVE_DEV_NUM
)) {
944 viafb_LCD_ON
= STATE_ON
;
946 viafb_DeviceStatus
|= LCD_Device
;
949 if ((device_id
& LCD2_Device
) && (device_num
< MAX_ACTIVE_DEV_NUM
)) {
950 viafb_LCD2_ON
= STATE_ON
;
952 viafb_DeviceStatus
|= LCD2_Device
;
955 if (viafb_DeviceStatus
== None_Device
) {
956 /* Use CRT as default active device: */
957 viafb_CRT_ON
= STATE_ON
;
958 viafb_DeviceStatus
= CRT_Device
;
960 DEBUG_MSG(KERN_INFO
"Device Status:%x", viafb_DeviceStatus
);
963 static void viafb_set_device(struct device_t active_dev
)
965 /* Check available device to enable: */
966 int device_id
= None_Device
;
968 device_id
|= CRT_Device
;
970 device_id
|= DVI_Device
;
972 device_id
|= LCD_Device
;
974 check_available_device_to_enable(device_id
);
976 /* Check property of LCD: */
978 if (active_dev
.lcd_dsp_cent
) {
979 viaparinfo
->lvds_setting_info
->display_method
=
980 viafb_lcd_dsp_method
= LCD_CENTERING
;
982 viaparinfo
->lvds_setting_info
->display_method
=
983 viafb_lcd_dsp_method
= LCD_EXPANDSION
;
986 if (active_dev
.lcd_mode
== LCD_SPWG
) {
987 viaparinfo
->lvds_setting_info
->lcd_mode
=
988 viafb_lcd_mode
= LCD_SPWG
;
990 viaparinfo
->lvds_setting_info
->lcd_mode
=
991 viafb_lcd_mode
= LCD_OPENLDI
;
994 if (active_dev
.lcd_panel_id
<= LCD_PANEL_ID_MAXIMUM
) {
995 viafb_lcd_panel_id
= active_dev
.lcd_panel_id
;
996 viafb_init_lcd_size();
1000 /* Check property of mode: */
1001 if (!active_dev
.xres1
)
1002 viafb_second_xres
= 640;
1004 viafb_second_xres
= active_dev
.xres1
;
1005 if (!active_dev
.yres1
)
1006 viafb_second_yres
= 480;
1008 viafb_second_yres
= active_dev
.yres1
;
1009 if (active_dev
.bpp
!= 0)
1010 viafb_bpp
= active_dev
.bpp
;
1011 if (active_dev
.bpp1
!= 0)
1012 viafb_bpp1
= active_dev
.bpp1
;
1013 if (active_dev
.refresh
!= 0)
1014 viafb_refresh
= active_dev
.refresh
;
1015 if (active_dev
.refresh1
!= 0)
1016 viafb_refresh1
= active_dev
.refresh1
;
1017 if ((active_dev
.samm
== STATE_OFF
) || (active_dev
.samm
== STATE_ON
))
1018 viafb_SAMM_ON
= active_dev
.samm
;
1019 viafb_primary_dev
= active_dev
.primary_dev
;
1021 via_set_primary_address(0);
1022 via_set_secondary_address(viafb_SAMM_ON
? viafb_second_offset
: 0);
1023 viafb_set_iga_path();
1026 static int get_primary_device(void)
1028 int primary_device
= 0;
1029 /* Rule: device on iga1 path are the primary device. */
1030 if (viafb_SAMM_ON
) {
1032 if (viaparinfo
->crt_setting_info
->iga_path
== IGA1
) {
1033 DEBUG_MSG(KERN_INFO
"CRT IGA Path:%d\n",
1035 crt_setting_info
->iga_path
);
1036 primary_device
= CRT_Device
;
1040 if (viaparinfo
->tmds_setting_info
->iga_path
== IGA1
) {
1041 DEBUG_MSG(KERN_INFO
"DVI IGA Path:%d\n",
1043 tmds_setting_info
->iga_path
);
1044 primary_device
= DVI_Device
;
1048 if (viaparinfo
->lvds_setting_info
->iga_path
== IGA1
) {
1049 DEBUG_MSG(KERN_INFO
"LCD IGA Path:%d\n",
1051 lvds_setting_info
->iga_path
);
1052 primary_device
= LCD_Device
;
1055 if (viafb_LCD2_ON
) {
1056 if (viaparinfo
->lvds_setting_info2
->iga_path
== IGA1
) {
1057 DEBUG_MSG(KERN_INFO
"LCD2 IGA Path:%d\n",
1059 lvds_setting_info2
->iga_path
);
1060 primary_device
= LCD2_Device
;
1064 return primary_device
;
1067 static void apply_second_mode_setting(struct fb_var_screeninfo
1070 u32 htotal
, vtotal
, long_refresh
;
1072 htotal
= sec_var
->xres
+ sec_var
->left_margin
+
1073 sec_var
->right_margin
+ sec_var
->hsync_len
;
1074 vtotal
= sec_var
->yres
+ sec_var
->upper_margin
+
1075 sec_var
->lower_margin
+ sec_var
->vsync_len
;
1076 if ((sec_var
->xres_virtual
* (sec_var
->bits_per_pixel
>> 3)) & 0x1F) {
1077 /*Is 32 bytes alignment? */
1078 /*32 pixel alignment */
1079 sec_var
->xres_virtual
= (sec_var
->xres_virtual
+ 31) & ~31;
1082 htotal
= sec_var
->xres
+ sec_var
->left_margin
+
1083 sec_var
->right_margin
+ sec_var
->hsync_len
;
1084 vtotal
= sec_var
->yres
+ sec_var
->upper_margin
+
1085 sec_var
->lower_margin
+ sec_var
->vsync_len
;
1086 long_refresh
= 1000000000UL / sec_var
->pixclock
* 1000;
1087 long_refresh
/= (htotal
* vtotal
);
1089 viafb_second_xres
= sec_var
->xres
;
1090 viafb_second_yres
= sec_var
->yres
;
1091 viafb_second_virtual_xres
= sec_var
->xres_virtual
;
1092 viafb_second_virtual_yres
= sec_var
->yres_virtual
;
1093 viafb_bpp1
= sec_var
->bits_per_pixel
;
1094 viafb_refresh1
= viafb_get_refresh(sec_var
->xres
, sec_var
->yres
,
1098 static int apply_device_setting(struct viafb_ioctl_setting setting_info
,
1099 struct fb_info
*info
)
1101 int need_set_mode
= 0;
1102 DEBUG_MSG(KERN_INFO
"apply_device_setting\n");
1104 if (setting_info
.device_flag
) {
1106 check_available_device_to_enable(setting_info
.device_status
);
1109 /* Unlock LCD's operation according to LCD flag
1110 and check if the setting value is valid. */
1111 /* If the value is valid, apply the new setting value to the device. */
1113 if (setting_info
.lcd_operation_flag
& OP_LCD_CENTERING
) {
1115 if (setting_info
.lcd_attributes
.display_center
) {
1117 viaparinfo
->lvds_setting_info
->display_method
=
1119 viafb_lcd_dsp_method
= LCD_CENTERING
;
1120 viaparinfo
->lvds_setting_info2
->display_method
=
1121 viafb_lcd_dsp_method
= LCD_CENTERING
;
1124 viaparinfo
->lvds_setting_info
->display_method
=
1126 viafb_lcd_dsp_method
= LCD_EXPANDSION
;
1127 viaparinfo
->lvds_setting_info2
->display_method
=
1129 viafb_lcd_dsp_method
= LCD_EXPANDSION
;
1133 if (setting_info
.lcd_operation_flag
& OP_LCD_MODE
) {
1135 if (setting_info
.lcd_attributes
.lcd_mode
==
1137 viaparinfo
->lvds_setting_info
->lcd_mode
=
1138 viafb_lcd_mode
= LCD_SPWG
;
1140 viaparinfo
->lvds_setting_info
->lcd_mode
=
1141 viafb_lcd_mode
= LCD_OPENLDI
;
1143 viaparinfo
->lvds_setting_info2
->lcd_mode
=
1144 viaparinfo
->lvds_setting_info
->lcd_mode
;
1147 if (setting_info
.lcd_operation_flag
& OP_LCD_PANEL_ID
) {
1149 if (setting_info
.lcd_attributes
.panel_id
<=
1150 LCD_PANEL_ID_MAXIMUM
) {
1151 viafb_lcd_panel_id
=
1152 setting_info
.lcd_attributes
.panel_id
;
1153 viafb_init_lcd_size();
1158 if (0 != (setting_info
.samm_status
& OP_SAMM
)) {
1159 setting_info
.samm_status
=
1160 setting_info
.samm_status
& (~OP_SAMM
);
1161 if (setting_info
.samm_status
== 0
1162 || setting_info
.samm_status
== 1) {
1163 viafb_SAMM_ON
= setting_info
.samm_status
;
1166 viafb_primary_dev
= setting_info
.primary_device
;
1168 via_set_primary_address(0);
1169 via_set_secondary_address(viafb_SAMM_ON
?
1170 viafb_second_offset
: 0);
1171 viafb_set_iga_path();
1176 if (!need_set_mode
) {
1179 viafb_set_iga_path();
1180 viafb_set_par(info
);
1185 static void retrieve_device_setting(struct viafb_ioctl_setting
1189 /* get device status */
1190 if (viafb_CRT_ON
== 1)
1191 setting_info
->device_status
= CRT_Device
;
1192 if (viafb_DVI_ON
== 1)
1193 setting_info
->device_status
|= DVI_Device
;
1194 if (viafb_LCD_ON
== 1)
1195 setting_info
->device_status
|= LCD_Device
;
1196 if (viafb_LCD2_ON
== 1)
1197 setting_info
->device_status
|= LCD2_Device
;
1199 setting_info
->samm_status
= viafb_SAMM_ON
;
1200 setting_info
->primary_device
= get_primary_device();
1202 setting_info
->first_dev_bpp
= viafb_bpp
;
1203 setting_info
->second_dev_bpp
= viafb_bpp1
;
1205 setting_info
->first_dev_refresh
= viafb_refresh
;
1206 setting_info
->second_dev_refresh
= viafb_refresh1
;
1208 setting_info
->first_dev_hor_res
= viafb_hotplug_Xres
;
1209 setting_info
->first_dev_ver_res
= viafb_hotplug_Yres
;
1210 setting_info
->second_dev_hor_res
= viafb_second_xres
;
1211 setting_info
->second_dev_ver_res
= viafb_second_yres
;
1213 /* Get lcd attributes */
1214 setting_info
->lcd_attributes
.display_center
= viafb_lcd_dsp_method
;
1215 setting_info
->lcd_attributes
.panel_id
= viafb_lcd_panel_id
;
1216 setting_info
->lcd_attributes
.lcd_mode
= viafb_lcd_mode
;
1219 static int parse_active_dev(void)
1221 viafb_CRT_ON
= STATE_OFF
;
1222 viafb_DVI_ON
= STATE_OFF
;
1223 viafb_LCD_ON
= STATE_OFF
;
1224 viafb_LCD2_ON
= STATE_OFF
;
1225 /* 1. Modify the active status of devices. */
1226 /* 2. Keep the order of devices, so we can set corresponding
1227 IGA path to devices in SAMM case. */
1228 /* Note: The previous of active_dev is primary device,
1229 and the following is secondary device. */
1230 if (!viafb_active_dev
) {
1231 viafb_CRT_ON
= STATE_ON
;
1232 viafb_SAMM_ON
= STATE_OFF
;
1233 } else if (!strcmp(viafb_active_dev
, "CRT+DVI")) {
1235 viafb_CRT_ON
= STATE_ON
;
1236 viafb_DVI_ON
= STATE_ON
;
1237 viafb_primary_dev
= CRT_Device
;
1238 } else if (!strcmp(viafb_active_dev
, "DVI+CRT")) {
1240 viafb_CRT_ON
= STATE_ON
;
1241 viafb_DVI_ON
= STATE_ON
;
1242 viafb_primary_dev
= DVI_Device
;
1243 } else if (!strcmp(viafb_active_dev
, "CRT+LCD")) {
1245 viafb_CRT_ON
= STATE_ON
;
1246 viafb_LCD_ON
= STATE_ON
;
1247 viafb_primary_dev
= CRT_Device
;
1248 } else if (!strcmp(viafb_active_dev
, "LCD+CRT")) {
1250 viafb_CRT_ON
= STATE_ON
;
1251 viafb_LCD_ON
= STATE_ON
;
1252 viafb_primary_dev
= LCD_Device
;
1253 } else if (!strcmp(viafb_active_dev
, "DVI+LCD")) {
1255 viafb_DVI_ON
= STATE_ON
;
1256 viafb_LCD_ON
= STATE_ON
;
1257 viafb_primary_dev
= DVI_Device
;
1258 } else if (!strcmp(viafb_active_dev
, "LCD+DVI")) {
1260 viafb_DVI_ON
= STATE_ON
;
1261 viafb_LCD_ON
= STATE_ON
;
1262 viafb_primary_dev
= LCD_Device
;
1263 } else if (!strcmp(viafb_active_dev
, "LCD+LCD2")) {
1264 viafb_LCD_ON
= STATE_ON
;
1265 viafb_LCD2_ON
= STATE_ON
;
1266 viafb_primary_dev
= LCD_Device
;
1267 } else if (!strcmp(viafb_active_dev
, "LCD2+LCD")) {
1268 viafb_LCD_ON
= STATE_ON
;
1269 viafb_LCD2_ON
= STATE_ON
;
1270 viafb_primary_dev
= LCD2_Device
;
1271 } else if (!strcmp(viafb_active_dev
, "CRT")) {
1273 viafb_CRT_ON
= STATE_ON
;
1274 viafb_SAMM_ON
= STATE_OFF
;
1275 } else if (!strcmp(viafb_active_dev
, "DVI")) {
1277 viafb_DVI_ON
= STATE_ON
;
1278 viafb_SAMM_ON
= STATE_OFF
;
1279 } else if (!strcmp(viafb_active_dev
, "LCD")) {
1281 viafb_LCD_ON
= STATE_ON
;
1282 viafb_SAMM_ON
= STATE_OFF
;
1289 static int parse_port(char *opt_str
, int *output_interface
)
1291 if (!strncmp(opt_str
, "DVP0", 4))
1292 *output_interface
= INTERFACE_DVP0
;
1293 else if (!strncmp(opt_str
, "DVP1", 4))
1294 *output_interface
= INTERFACE_DVP1
;
1295 else if (!strncmp(opt_str
, "DFP_HIGHLOW", 11))
1296 *output_interface
= INTERFACE_DFP
;
1297 else if (!strncmp(opt_str
, "DFP_HIGH", 8))
1298 *output_interface
= INTERFACE_DFP_HIGH
;
1299 else if (!strncmp(opt_str
, "DFP_LOW", 7))
1300 *output_interface
= INTERFACE_DFP_LOW
;
1302 *output_interface
= INTERFACE_NONE
;
1306 static void parse_lcd_port(void)
1308 parse_port(viafb_lcd_port
, &viaparinfo
->chip_info
->lvds_chip_info
.
1310 /*Initialize to avoid unexpected behavior */
1311 viaparinfo
->chip_info
->lvds_chip_info2
.output_interface
=
1314 DEBUG_MSG(KERN_INFO
"parse_lcd_port: viafb_lcd_port:%s,interface:%d\n",
1315 viafb_lcd_port
, viaparinfo
->chip_info
->lvds_chip_info
.
1319 static void parse_dvi_port(void)
1321 parse_port(viafb_dvi_port
, &viaparinfo
->chip_info
->tmds_chip_info
.
1324 DEBUG_MSG(KERN_INFO
"parse_dvi_port: viafb_dvi_port:%s,interface:%d\n",
1325 viafb_dvi_port
, viaparinfo
->chip_info
->tmds_chip_info
.
1329 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1332 * The proc filesystem read/write function, a simple proc implement to
1333 * get/set the value of DPA DVP0, DVP0DataDriving, DVP0ClockDriving, DVP1,
1334 * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2],
1335 * CR9B, SR65, CR97, CR99
1337 static int viafb_dvp0_proc_show(struct seq_file
*m
, void *v
)
1339 u8 dvp0_data_dri
= 0, dvp0_clk_dri
= 0, dvp0
= 0;
1341 (viafb_read_reg(VIASR
, SR2A
) & BIT5
) >> 4 |
1342 (viafb_read_reg(VIASR
, SR1B
) & BIT1
) >> 1;
1344 (viafb_read_reg(VIASR
, SR2A
) & BIT4
) >> 3 |
1345 (viafb_read_reg(VIASR
, SR1E
) & BIT2
) >> 2;
1346 dvp0
= viafb_read_reg(VIACR
, CR96
) & 0x0f;
1347 seq_printf(m
, "%x %x %x\n", dvp0
, dvp0_data_dri
, dvp0_clk_dri
);
1351 static int viafb_dvp0_proc_open(struct inode
*inode
, struct file
*file
)
1353 return single_open(file
, viafb_dvp0_proc_show
, NULL
);
1356 static ssize_t
viafb_dvp0_proc_write(struct file
*file
,
1357 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1359 char buf
[20], *value
, *pbuf
;
1361 unsigned long length
, i
;
1364 length
= count
> 20 ? 20 : count
;
1365 if (copy_from_user(&buf
[0], buffer
, length
))
1367 buf
[length
- 1] = '\0'; /*Ensure end string */
1369 for (i
= 0; i
< 3; i
++) {
1370 value
= strsep(&pbuf
, " ");
1371 if (value
!= NULL
) {
1372 strict_strtoul(value
, 0, (unsigned long *)®_val
);
1373 DEBUG_MSG(KERN_INFO
"DVP0:reg_val[%l]=:%x\n", i
,
1377 viafb_write_reg_mask(CR96
, VIACR
,
1381 viafb_write_reg_mask(SR2A
, VIASR
,
1382 reg_val
<< 4, BIT5
);
1383 viafb_write_reg_mask(SR1B
, VIASR
,
1384 reg_val
<< 1, BIT1
);
1387 viafb_write_reg_mask(SR2A
, VIASR
,
1388 reg_val
<< 3, BIT4
);
1389 viafb_write_reg_mask(SR1E
, VIASR
,
1390 reg_val
<< 2, BIT2
);
1402 static const struct file_operations viafb_dvp0_proc_fops
= {
1403 .owner
= THIS_MODULE
,
1404 .open
= viafb_dvp0_proc_open
,
1406 .llseek
= seq_lseek
,
1407 .release
= single_release
,
1408 .write
= viafb_dvp0_proc_write
,
1411 static int viafb_dvp1_proc_show(struct seq_file
*m
, void *v
)
1413 u8 dvp1
= 0, dvp1_data_dri
= 0, dvp1_clk_dri
= 0;
1414 dvp1
= viafb_read_reg(VIACR
, CR9B
) & 0x0f;
1415 dvp1_data_dri
= (viafb_read_reg(VIASR
, SR65
) & 0x0c) >> 2;
1416 dvp1_clk_dri
= viafb_read_reg(VIASR
, SR65
) & 0x03;
1417 seq_printf(m
, "%x %x %x\n", dvp1
, dvp1_data_dri
, dvp1_clk_dri
);
1421 static int viafb_dvp1_proc_open(struct inode
*inode
, struct file
*file
)
1423 return single_open(file
, viafb_dvp1_proc_show
, NULL
);
1426 static ssize_t
viafb_dvp1_proc_write(struct file
*file
,
1427 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1429 char buf
[20], *value
, *pbuf
;
1431 unsigned long length
, i
;
1434 length
= count
> 20 ? 20 : count
;
1435 if (copy_from_user(&buf
[0], buffer
, length
))
1437 buf
[length
- 1] = '\0'; /*Ensure end string */
1439 for (i
= 0; i
< 3; i
++) {
1440 value
= strsep(&pbuf
, " ");
1441 if (value
!= NULL
) {
1442 strict_strtoul(value
, 0, (unsigned long *)®_val
);
1445 viafb_write_reg_mask(CR9B
, VIACR
,
1449 viafb_write_reg_mask(SR65
, VIASR
,
1450 reg_val
<< 2, 0x0c);
1453 viafb_write_reg_mask(SR65
, VIASR
,
1466 static const struct file_operations viafb_dvp1_proc_fops
= {
1467 .owner
= THIS_MODULE
,
1468 .open
= viafb_dvp1_proc_open
,
1470 .llseek
= seq_lseek
,
1471 .release
= single_release
,
1472 .write
= viafb_dvp1_proc_write
,
1475 static int viafb_dfph_proc_show(struct seq_file
*m
, void *v
)
1478 dfp_high
= viafb_read_reg(VIACR
, CR97
) & 0x0f;
1479 seq_printf(m
, "%x\n", dfp_high
);
1483 static int viafb_dfph_proc_open(struct inode
*inode
, struct file
*file
)
1485 return single_open(file
, viafb_dfph_proc_show
, NULL
);
1488 static ssize_t
viafb_dfph_proc_write(struct file
*file
,
1489 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1493 unsigned long length
;
1496 length
= count
> 20 ? 20 : count
;
1497 if (copy_from_user(&buf
[0], buffer
, length
))
1499 buf
[length
- 1] = '\0'; /*Ensure end string */
1500 strict_strtoul(&buf
[0], 0, (unsigned long *)®_val
);
1501 viafb_write_reg_mask(CR97
, VIACR
, reg_val
, 0x0f);
1505 static const struct file_operations viafb_dfph_proc_fops
= {
1506 .owner
= THIS_MODULE
,
1507 .open
= viafb_dfph_proc_open
,
1509 .llseek
= seq_lseek
,
1510 .release
= single_release
,
1511 .write
= viafb_dfph_proc_write
,
1514 static int viafb_dfpl_proc_show(struct seq_file
*m
, void *v
)
1517 dfp_low
= viafb_read_reg(VIACR
, CR99
) & 0x0f;
1518 seq_printf(m
, "%x\n", dfp_low
);
1522 static int viafb_dfpl_proc_open(struct inode
*inode
, struct file
*file
)
1524 return single_open(file
, viafb_dfpl_proc_show
, NULL
);
1527 static ssize_t
viafb_dfpl_proc_write(struct file
*file
,
1528 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1532 unsigned long length
;
1535 length
= count
> 20 ? 20 : count
;
1536 if (copy_from_user(&buf
[0], buffer
, length
))
1538 buf
[length
- 1] = '\0'; /*Ensure end string */
1539 strict_strtoul(&buf
[0], 0, (unsigned long *)®_val
);
1540 viafb_write_reg_mask(CR99
, VIACR
, reg_val
, 0x0f);
1544 static const struct file_operations viafb_dfpl_proc_fops
= {
1545 .owner
= THIS_MODULE
,
1546 .open
= viafb_dfpl_proc_open
,
1548 .llseek
= seq_lseek
,
1549 .release
= single_release
,
1550 .write
= viafb_dfpl_proc_write
,
1553 static int viafb_vt1636_proc_show(struct seq_file
*m
, void *v
)
1555 u8 vt1636_08
= 0, vt1636_09
= 0;
1556 switch (viaparinfo
->chip_info
->lvds_chip_info
.lvds_chip_name
) {
1559 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info
,
1560 &viaparinfo
->chip_info
->lvds_chip_info
, 0x08) & 0x0f;
1562 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info
,
1563 &viaparinfo
->chip_info
->lvds_chip_info
, 0x09) & 0x1f;
1564 seq_printf(m
, "%x %x\n", vt1636_08
, vt1636_09
);
1569 switch (viaparinfo
->chip_info
->lvds_chip_info2
.lvds_chip_name
) {
1572 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info2
,
1573 &viaparinfo
->chip_info
->lvds_chip_info2
, 0x08) & 0x0f;
1575 viafb_gpio_i2c_read_lvds(viaparinfo
->lvds_setting_info2
,
1576 &viaparinfo
->chip_info
->lvds_chip_info2
, 0x09) & 0x1f;
1577 seq_printf(m
, " %x %x\n", vt1636_08
, vt1636_09
);
1585 static int viafb_vt1636_proc_open(struct inode
*inode
, struct file
*file
)
1587 return single_open(file
, viafb_vt1636_proc_show
, NULL
);
1590 static ssize_t
viafb_vt1636_proc_write(struct file
*file
,
1591 const char __user
*buffer
, size_t count
, loff_t
*pos
)
1593 char buf
[30], *value
, *pbuf
;
1594 struct IODATA reg_val
;
1595 unsigned long length
, i
;
1598 length
= count
> 30 ? 30 : count
;
1599 if (copy_from_user(&buf
[0], buffer
, length
))
1601 buf
[length
- 1] = '\0'; /*Ensure end string */
1603 switch (viaparinfo
->chip_info
->lvds_chip_info
.lvds_chip_name
) {
1605 for (i
= 0; i
< 2; i
++) {
1606 value
= strsep(&pbuf
, " ");
1607 if (value
!= NULL
) {
1608 strict_strtoul(value
, 0,
1609 (unsigned long *)®_val
.Data
);
1612 reg_val
.Index
= 0x08;
1613 reg_val
.Mask
= 0x0f;
1614 viafb_gpio_i2c_write_mask_lvds
1615 (viaparinfo
->lvds_setting_info
,
1617 chip_info
->lvds_chip_info
,
1621 reg_val
.Index
= 0x09;
1622 reg_val
.Mask
= 0x1f;
1623 viafb_gpio_i2c_write_mask_lvds
1624 (viaparinfo
->lvds_setting_info
,
1626 chip_info
->lvds_chip_info
,
1640 switch (viaparinfo
->chip_info
->lvds_chip_info2
.lvds_chip_name
) {
1642 for (i
= 0; i
< 2; i
++) {
1643 value
= strsep(&pbuf
, " ");
1644 if (value
!= NULL
) {
1645 strict_strtoul(value
, 0,
1646 (unsigned long *)®_val
.Data
);
1649 reg_val
.Index
= 0x08;
1650 reg_val
.Mask
= 0x0f;
1651 viafb_gpio_i2c_write_mask_lvds
1652 (viaparinfo
->lvds_setting_info2
,
1654 chip_info
->lvds_chip_info2
,
1658 reg_val
.Index
= 0x09;
1659 reg_val
.Mask
= 0x1f;
1660 viafb_gpio_i2c_write_mask_lvds
1661 (viaparinfo
->lvds_setting_info2
,
1663 chip_info
->lvds_chip_info2
,
1680 static const struct file_operations viafb_vt1636_proc_fops
= {
1681 .owner
= THIS_MODULE
,
1682 .open
= viafb_vt1636_proc_open
,
1684 .llseek
= seq_lseek
,
1685 .release
= single_release
,
1686 .write
= viafb_vt1636_proc_write
,
1689 static void viafb_init_proc(struct proc_dir_entry
**viafb_entry
)
1691 *viafb_entry
= proc_mkdir("viafb", NULL
);
1693 proc_create("dvp0", 0, *viafb_entry
, &viafb_dvp0_proc_fops
);
1694 proc_create("dvp1", 0, *viafb_entry
, &viafb_dvp1_proc_fops
);
1695 proc_create("dfph", 0, *viafb_entry
, &viafb_dfph_proc_fops
);
1696 proc_create("dfpl", 0, *viafb_entry
, &viafb_dfpl_proc_fops
);
1697 if (VT1636_LVDS
== viaparinfo
->chip_info
->lvds_chip_info
.
1698 lvds_chip_name
|| VT1636_LVDS
==
1699 viaparinfo
->chip_info
->lvds_chip_info2
.lvds_chip_name
) {
1700 proc_create("vt1636", 0, *viafb_entry
, &viafb_vt1636_proc_fops
);
1705 static void viafb_remove_proc(struct proc_dir_entry
*viafb_entry
)
1707 struct chip_information
*chip_info
= &viaparinfo
->shared
->chip_info
;
1709 remove_proc_entry("dvp0", viafb_entry
);/* parent dir */
1710 remove_proc_entry("dvp1", viafb_entry
);
1711 remove_proc_entry("dfph", viafb_entry
);
1712 remove_proc_entry("dfpl", viafb_entry
);
1713 if (chip_info
->lvds_chip_info
.lvds_chip_name
== VT1636_LVDS
1714 || chip_info
->lvds_chip_info2
.lvds_chip_name
== VT1636_LVDS
)
1715 remove_proc_entry("vt1636", viafb_entry
);
1717 remove_proc_entry("viafb", NULL
);
1720 #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
1722 static int parse_mode(const char *str
, u32
*xres
, u32
*yres
)
1732 *xres
= simple_strtoul(str
, &ptr
, 10);
1736 *yres
= simple_strtoul(&ptr
[1], &ptr
, 10);
1744 int __devinit
via_fb_pci_probe(struct viafb_dev
*vdev
)
1746 u32 default_xres
, default_yres
;
1747 struct VideoModeTable
*vmode_entry
;
1748 struct fb_var_screeninfo default_var
;
1750 u32 viafb_par_length
;
1752 DEBUG_MSG(KERN_INFO
"VIAFB PCI Probe!!\n");
1753 memset(&default_var
, 0, sizeof(default_var
));
1754 viafb_par_length
= ALIGN(sizeof(struct viafb_par
), BITS_PER_LONG
/8);
1756 /* Allocate fb_info and ***_par here, also including some other needed
1759 viafbinfo
= framebuffer_alloc(viafb_par_length
+
1760 ALIGN(sizeof(struct viafb_shared
), BITS_PER_LONG
/8),
1763 printk(KERN_ERR
"Could not allocate memory for viafb_info.\n");
1767 viaparinfo
= (struct viafb_par
*)viafbinfo
->par
;
1768 viaparinfo
->shared
= viafbinfo
->par
+ viafb_par_length
;
1769 viaparinfo
->shared
->vdev
= vdev
;
1770 viaparinfo
->vram_addr
= 0;
1771 viaparinfo
->tmds_setting_info
= &viaparinfo
->shared
->tmds_setting_info
;
1772 viaparinfo
->lvds_setting_info
= &viaparinfo
->shared
->lvds_setting_info
;
1773 viaparinfo
->lvds_setting_info2
=
1774 &viaparinfo
->shared
->lvds_setting_info2
;
1775 viaparinfo
->crt_setting_info
= &viaparinfo
->shared
->crt_setting_info
;
1776 viaparinfo
->chip_info
= &viaparinfo
->shared
->chip_info
;
1783 /* for dual-fb must viafb_SAMM_ON=1 and viafb_dual_fb=1 */
1787 viafb_init_chip_info(vdev
->chip_type
);
1789 * The framebuffer will have been successfully mapped by
1790 * the core (or we'd not be here), but we still need to
1791 * set up our own accounting.
1793 viaparinfo
->fbmem
= vdev
->fbmem_start
;
1794 viaparinfo
->memsize
= vdev
->fbmem_len
;
1795 viaparinfo
->fbmem_free
= viaparinfo
->memsize
;
1796 viaparinfo
->fbmem_used
= 0;
1797 viafbinfo
->screen_base
= vdev
->fbmem
;
1799 viafbinfo
->fix
.mmio_start
= vdev
->engine_start
;
1800 viafbinfo
->fix
.mmio_len
= vdev
->engine_len
;
1801 viafbinfo
->node
= 0;
1802 viafbinfo
->fbops
= &viafb_ops
;
1803 viafbinfo
->flags
= FBINFO_DEFAULT
| FBINFO_HWACCEL_YPAN
;
1805 viafbinfo
->pseudo_palette
= pseudo_pal
;
1806 if (viafb_accel
&& !viafb_init_engine(viafbinfo
)) {
1807 viafbinfo
->flags
|= FBINFO_HWACCEL_COPYAREA
|
1808 FBINFO_HWACCEL_FILLRECT
| FBINFO_HWACCEL_IMAGEBLIT
;
1809 default_var
.accel_flags
= FB_ACCELF_TEXT
;
1811 viafbinfo
->flags
|= FBINFO_HWACCEL_DISABLED
;
1812 default_var
.accel_flags
= 0;
1815 if (viafb_second_size
&& (viafb_second_size
< 8)) {
1816 viafb_second_offset
= viaparinfo
->fbmem_free
-
1817 viafb_second_size
* 1024 * 1024;
1819 viafb_second_size
= 8;
1820 viafb_second_offset
= viaparinfo
->fbmem_free
-
1821 viafb_second_size
* 1024 * 1024;
1824 parse_mode(viafb_mode
, &default_xres
, &default_yres
);
1825 vmode_entry
= viafb_get_mode(default_xres
, default_yres
);
1826 if (viafb_SAMM_ON
== 1) {
1827 parse_mode(viafb_mode1
, &viafb_second_xres
,
1828 &viafb_second_yres
);
1830 if (0 == viafb_second_virtual_xres
) {
1831 switch (viafb_second_xres
) {
1833 viafb_second_virtual_xres
= 1408;
1836 viafb_second_virtual_xres
= viafb_second_xres
;
1840 if (0 == viafb_second_virtual_yres
)
1841 viafb_second_virtual_yres
= viafb_second_yres
;
1844 default_var
.xres
= default_xres
;
1845 default_var
.yres
= default_yres
;
1846 switch (default_xres
) {
1848 default_var
.xres_virtual
= 1408;
1851 default_var
.xres_virtual
= default_xres
;
1854 default_var
.yres_virtual
= default_yres
;
1855 default_var
.bits_per_pixel
= viafb_bpp
;
1856 default_var
.pixclock
=
1857 viafb_get_pixclock(default_xres
, default_yres
, viafb_refresh
);
1858 default_var
.left_margin
= (default_xres
>> 3) & 0xf8;
1859 default_var
.right_margin
= 32;
1860 default_var
.upper_margin
= 16;
1861 default_var
.lower_margin
= 4;
1862 default_var
.hsync_len
= default_var
.left_margin
;
1863 default_var
.vsync_len
= 4;
1864 viafb_setup_fixinfo(&viafbinfo
->fix
, viaparinfo
);
1865 viafbinfo
->var
= default_var
;
1867 if (viafb_dual_fb
) {
1868 viafbinfo1
= framebuffer_alloc(viafb_par_length
,
1872 "allocate the second framebuffer struct error\n");
1874 goto out_fb_release
;
1876 viaparinfo1
= viafbinfo1
->par
;
1877 memcpy(viaparinfo1
, viaparinfo
, viafb_par_length
);
1878 viaparinfo1
->vram_addr
= viafb_second_offset
;
1879 viaparinfo1
->memsize
= viaparinfo
->memsize
-
1880 viafb_second_offset
;
1881 viaparinfo
->memsize
= viafb_second_offset
;
1882 viaparinfo1
->fbmem
= viaparinfo
->fbmem
+ viafb_second_offset
;
1884 viaparinfo1
->fbmem_used
= viaparinfo
->fbmem_used
;
1885 viaparinfo1
->fbmem_free
= viaparinfo1
->memsize
-
1886 viaparinfo1
->fbmem_used
;
1887 viaparinfo
->fbmem_free
= viaparinfo
->memsize
;
1888 viaparinfo
->fbmem_used
= 0;
1890 viaparinfo
->iga_path
= IGA1
;
1891 viaparinfo1
->iga_path
= IGA2
;
1892 memcpy(viafbinfo1
, viafbinfo
, sizeof(struct fb_info
));
1893 viafbinfo1
->par
= viaparinfo1
;
1894 viafbinfo1
->screen_base
= viafbinfo
->screen_base
+
1895 viafb_second_offset
;
1897 default_var
.xres
= viafb_second_xres
;
1898 default_var
.yres
= viafb_second_yres
;
1899 default_var
.xres_virtual
= viafb_second_virtual_xres
;
1900 default_var
.yres_virtual
= viafb_second_virtual_yres
;
1901 default_var
.bits_per_pixel
= viafb_bpp1
;
1902 default_var
.pixclock
=
1903 viafb_get_pixclock(viafb_second_xres
, viafb_second_yres
,
1905 default_var
.left_margin
= (viafb_second_xres
>> 3) & 0xf8;
1906 default_var
.right_margin
= 32;
1907 default_var
.upper_margin
= 16;
1908 default_var
.lower_margin
= 4;
1909 default_var
.hsync_len
= default_var
.left_margin
;
1910 default_var
.vsync_len
= 4;
1912 viafb_setup_fixinfo(&viafbinfo1
->fix
, viaparinfo1
);
1913 viafb_check_var(&default_var
, viafbinfo1
);
1914 viafbinfo1
->var
= default_var
;
1915 viafb_update_fix(viafbinfo1
);
1916 viaparinfo1
->depth
= fb_get_color_depth(&viafbinfo1
->var
,
1920 viafb_check_var(&viafbinfo
->var
, viafbinfo
);
1921 viafb_update_fix(viafbinfo
);
1922 viaparinfo
->depth
= fb_get_color_depth(&viafbinfo
->var
,
1924 default_var
.activate
= FB_ACTIVATE_NOW
;
1925 rc
= fb_alloc_cmap(&viafbinfo
->cmap
, 256, 0);
1927 goto out_fb1_release
;
1929 if (viafb_dual_fb
&& (viafb_primary_dev
== LCD_Device
)
1930 && (viaparinfo
->chip_info
->gfx_chip_name
== UNICHROME_CLE266
)) {
1931 rc
= register_framebuffer(viafbinfo1
);
1933 goto out_dealloc_cmap
;
1935 rc
= register_framebuffer(viafbinfo
);
1937 goto out_fb1_unreg_lcd_cle266
;
1939 if (viafb_dual_fb
&& ((viafb_primary_dev
!= LCD_Device
)
1940 || (viaparinfo
->chip_info
->gfx_chip_name
!=
1941 UNICHROME_CLE266
))) {
1942 rc
= register_framebuffer(viafbinfo1
);
1946 DEBUG_MSG(KERN_INFO
"fb%d: %s frame buffer device %dx%d-%dbpp\n",
1947 viafbinfo
->node
, viafbinfo
->fix
.id
, default_var
.xres
,
1948 default_var
.yres
, default_var
.bits_per_pixel
);
1950 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1951 viafb_init_proc(&viaparinfo
->shared
->proc_entry
);
1953 viafb_init_dac(IGA2
);
1957 unregister_framebuffer(viafbinfo
);
1958 out_fb1_unreg_lcd_cle266
:
1959 if (viafb_dual_fb
&& (viafb_primary_dev
== LCD_Device
)
1960 && (viaparinfo
->chip_info
->gfx_chip_name
== UNICHROME_CLE266
))
1961 unregister_framebuffer(viafbinfo1
);
1963 fb_dealloc_cmap(&viafbinfo
->cmap
);
1966 framebuffer_release(viafbinfo1
);
1968 framebuffer_release(viafbinfo
);
1972 void __devexit
via_fb_pci_remove(struct pci_dev
*pdev
)
1974 DEBUG_MSG(KERN_INFO
"via_pci_remove!\n");
1975 fb_dealloc_cmap(&viafbinfo
->cmap
);
1976 unregister_framebuffer(viafbinfo
);
1978 unregister_framebuffer(viafbinfo1
);
1979 #ifdef CONFIG_FB_VIA_DIRECT_PROCFS
1980 viafb_remove_proc(viaparinfo
->shared
->proc_entry
);
1982 framebuffer_release(viafbinfo
);
1984 framebuffer_release(viafbinfo1
);
1988 static int __init
viafb_setup(char *options
)
1991 DEBUG_MSG(KERN_INFO
"viafb_setup!\n");
1993 if (!options
|| !*options
)
1996 while ((this_opt
= strsep(&options
, ",")) != NULL
) {
2000 if (!strncmp(this_opt
, "viafb_mode1=", 12))
2001 viafb_mode1
= kstrdup(this_opt
+ 12, GFP_KERNEL
);
2002 else if (!strncmp(this_opt
, "viafb_mode=", 11))
2003 viafb_mode
= kstrdup(this_opt
+ 11, GFP_KERNEL
);
2004 else if (!strncmp(this_opt
, "viafb_bpp1=", 11))
2005 strict_strtoul(this_opt
+ 11, 0,
2006 (unsigned long *)&viafb_bpp1
);
2007 else if (!strncmp(this_opt
, "viafb_bpp=", 10))
2008 strict_strtoul(this_opt
+ 10, 0,
2009 (unsigned long *)&viafb_bpp
);
2010 else if (!strncmp(this_opt
, "viafb_refresh1=", 15))
2011 strict_strtoul(this_opt
+ 15, 0,
2012 (unsigned long *)&viafb_refresh1
);
2013 else if (!strncmp(this_opt
, "viafb_refresh=", 14))
2014 strict_strtoul(this_opt
+ 14, 0,
2015 (unsigned long *)&viafb_refresh
);
2016 else if (!strncmp(this_opt
, "viafb_lcd_dsp_method=", 21))
2017 strict_strtoul(this_opt
+ 21, 0,
2018 (unsigned long *)&viafb_lcd_dsp_method
);
2019 else if (!strncmp(this_opt
, "viafb_lcd_panel_id=", 19))
2020 strict_strtoul(this_opt
+ 19, 0,
2021 (unsigned long *)&viafb_lcd_panel_id
);
2022 else if (!strncmp(this_opt
, "viafb_accel=", 12))
2023 strict_strtoul(this_opt
+ 12, 0,
2024 (unsigned long *)&viafb_accel
);
2025 else if (!strncmp(this_opt
, "viafb_SAMM_ON=", 14))
2026 strict_strtoul(this_opt
+ 14, 0,
2027 (unsigned long *)&viafb_SAMM_ON
);
2028 else if (!strncmp(this_opt
, "viafb_active_dev=", 17))
2029 viafb_active_dev
= kstrdup(this_opt
+ 17, GFP_KERNEL
);
2030 else if (!strncmp(this_opt
,
2031 "viafb_display_hardware_layout=", 30))
2032 strict_strtoul(this_opt
+ 30, 0,
2033 (unsigned long *)&viafb_display_hardware_layout
);
2034 else if (!strncmp(this_opt
, "viafb_second_size=", 18))
2035 strict_strtoul(this_opt
+ 18, 0,
2036 (unsigned long *)&viafb_second_size
);
2037 else if (!strncmp(this_opt
,
2038 "viafb_platform_epia_dvi=", 24))
2039 strict_strtoul(this_opt
+ 24, 0,
2040 (unsigned long *)&viafb_platform_epia_dvi
);
2041 else if (!strncmp(this_opt
,
2042 "viafb_device_lcd_dualedge=", 26))
2043 strict_strtoul(this_opt
+ 26, 0,
2044 (unsigned long *)&viafb_device_lcd_dualedge
);
2045 else if (!strncmp(this_opt
, "viafb_bus_width=", 16))
2046 strict_strtoul(this_opt
+ 16, 0,
2047 (unsigned long *)&viafb_bus_width
);
2048 else if (!strncmp(this_opt
, "viafb_lcd_mode=", 15))
2049 strict_strtoul(this_opt
+ 15, 0,
2050 (unsigned long *)&viafb_lcd_mode
);
2051 else if (!strncmp(this_opt
, "viafb_lcd_port=", 15))
2052 viafb_lcd_port
= kstrdup(this_opt
+ 15, GFP_KERNEL
);
2053 else if (!strncmp(this_opt
, "viafb_dvi_port=", 15))
2054 viafb_dvi_port
= kstrdup(this_opt
+ 15, GFP_KERNEL
);
2061 * These are called out of via-core for now.
2063 int __init
viafb_init(void)
2067 char *option
= NULL
;
2068 if (fb_get_options("viafb", &option
))
2070 viafb_setup(option
);
2072 if (parse_mode(viafb_mode
, &dummy
, &dummy
)
2073 || parse_mode(viafb_mode1
, &dummy
, &dummy
)
2074 || viafb_bpp
< 0 || viafb_bpp
> 32
2075 || viafb_bpp1
< 0 || viafb_bpp1
> 32
2076 || parse_active_dev())
2080 "VIA Graphics Intergration Chipset framebuffer %d.%d initializing\n",
2081 VERSION_MAJOR
, VERSION_MINOR
);
2085 void __exit
viafb_exit(void)
2087 DEBUG_MSG(KERN_INFO
"viafb_exit!\n");
2090 static struct fb_ops viafb_ops
= {
2091 .owner
= THIS_MODULE
,
2092 .fb_open
= viafb_open
,
2093 .fb_release
= viafb_release
,
2094 .fb_check_var
= viafb_check_var
,
2095 .fb_set_par
= viafb_set_par
,
2096 .fb_setcolreg
= viafb_setcolreg
,
2097 .fb_pan_display
= viafb_pan_display
,
2098 .fb_blank
= viafb_blank
,
2099 .fb_fillrect
= viafb_fillrect
,
2100 .fb_copyarea
= viafb_copyarea
,
2101 .fb_imageblit
= viafb_imageblit
,
2102 .fb_cursor
= viafb_cursor
,
2103 .fb_ioctl
= viafb_ioctl
,
2104 .fb_sync
= viafb_sync
,
2109 module_param(viafb_mode
, charp
, S_IRUSR
);
2110 MODULE_PARM_DESC(viafb_mode
, "Set resolution (default=640x480)");
2112 module_param(viafb_mode1
, charp
, S_IRUSR
);
2113 MODULE_PARM_DESC(viafb_mode1
, "Set resolution (default=640x480)");
2115 module_param(viafb_bpp
, int, S_IRUSR
);
2116 MODULE_PARM_DESC(viafb_bpp
, "Set color depth (default=32bpp)");
2118 module_param(viafb_bpp1
, int, S_IRUSR
);
2119 MODULE_PARM_DESC(viafb_bpp1
, "Set color depth (default=32bpp)");
2121 module_param(viafb_refresh
, int, S_IRUSR
);
2122 MODULE_PARM_DESC(viafb_refresh
,
2123 "Set CRT viafb_refresh rate (default = 60)");
2125 module_param(viafb_refresh1
, int, S_IRUSR
);
2126 MODULE_PARM_DESC(viafb_refresh1
,
2127 "Set CRT refresh rate (default = 60)");
2129 module_param(viafb_lcd_panel_id
, int, S_IRUSR
);
2130 MODULE_PARM_DESC(viafb_lcd_panel_id
,
2131 "Set Flat Panel type(Default=1024x768)");
2133 module_param(viafb_lcd_dsp_method
, int, S_IRUSR
);
2134 MODULE_PARM_DESC(viafb_lcd_dsp_method
,
2135 "Set Flat Panel display scaling method.(Default=Expandsion)");
2137 module_param(viafb_SAMM_ON
, int, S_IRUSR
);
2138 MODULE_PARM_DESC(viafb_SAMM_ON
,
2139 "Turn on/off flag of SAMM(Default=OFF)");
2141 module_param(viafb_accel
, int, S_IRUSR
);
2142 MODULE_PARM_DESC(viafb_accel
,
2143 "Set 2D Hardware Acceleration: 0 = OFF, 1 = ON (default)");
2145 module_param(viafb_active_dev
, charp
, S_IRUSR
);
2146 MODULE_PARM_DESC(viafb_active_dev
, "Specify active devices.");
2148 module_param(viafb_display_hardware_layout
, int, S_IRUSR
);
2149 MODULE_PARM_DESC(viafb_display_hardware_layout
,
2150 "Display Hardware Layout (LCD Only, DVI Only...,etc)");
2152 module_param(viafb_second_size
, int, S_IRUSR
);
2153 MODULE_PARM_DESC(viafb_second_size
,
2154 "Set secondary device memory size");
2156 module_param(viafb_dual_fb
, int, S_IRUSR
);
2157 MODULE_PARM_DESC(viafb_dual_fb
,
2158 "Turn on/off flag of dual framebuffer devices.(Default = OFF)");
2160 module_param(viafb_platform_epia_dvi
, int, S_IRUSR
);
2161 MODULE_PARM_DESC(viafb_platform_epia_dvi
,
2162 "Turn on/off flag of DVI devices on EPIA board.(Default = OFF)");
2164 module_param(viafb_device_lcd_dualedge
, int, S_IRUSR
);
2165 MODULE_PARM_DESC(viafb_device_lcd_dualedge
,
2166 "Turn on/off flag of dual edge panel.(Default = OFF)");
2168 module_param(viafb_bus_width
, int, S_IRUSR
);
2169 MODULE_PARM_DESC(viafb_bus_width
,
2170 "Set bus width of panel.(Default = 12)");
2172 module_param(viafb_lcd_mode
, int, S_IRUSR
);
2173 MODULE_PARM_DESC(viafb_lcd_mode
,
2174 "Set Flat Panel mode(Default=OPENLDI)");
2176 module_param(viafb_lcd_port
, charp
, S_IRUSR
);
2177 MODULE_PARM_DESC(viafb_lcd_port
, "Specify LCD output port.");
2179 module_param(viafb_dvi_port
, charp
, S_IRUSR
);
2180 MODULE_PARM_DESC(viafb_dvi_port
, "Specify DVI output port.");
2182 MODULE_LICENSE("GPL");