2 * linux/drivers/video/kyro/fbdev.c
4 * Copyright (C) 2002 STMicroelectronics
5 * Copyright (C) 2003, 2004 Paul Mundt
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file COPYING in the main directory of this archive
12 #include <linux/module.h>
13 #include <linux/types.h>
14 #include <linux/kernel.h>
16 #include <linux/errno.h>
17 #include <linux/string.h>
18 #include <linux/delay.h>
20 #include <linux/ioctl.h>
21 #include <linux/init.h>
22 #include <linux/pci.h>
24 #include <linux/uaccess.h>
26 #include <video/kyro.h>
28 #include "STG4000Reg.h"
29 #include "STG4000Interface.h"
34 #define PCI_VENDOR_ID_ST 0x104a
35 #define PCI_DEVICE_ID_STG4000 0x0010
37 #define KHZ2PICOS(a) (1000000000UL/(a))
39 /****************************************************************************/
40 static struct fb_fix_screeninfo kyro_fix
= {
42 .type
= FB_TYPE_PACKED_PIXELS
,
43 .visual
= FB_VISUAL_TRUECOLOR
,
44 .accel
= FB_ACCEL_NONE
,
47 static const struct fb_var_screeninfo kyro_var
= {
48 /* 640x480, 16bpp @ 60 Hz */
57 .activate
= FB_ACTIVATE_NOW
,
60 .pixclock
= KHZ2PICOS(25175),
67 .vmode
= FB_VMODE_NONINTERLACED
,
71 STG4000REG __iomem
*pSTGReg
; /* Virtual address of PCI register region */
72 u32 ulNextFreeVidMem
; /* Offset from start of vid mem to next free region */
73 u32 ulOverlayOffset
; /* Offset from start of vid mem to overlay */
74 u32 ulOverlayStride
; /* Interleaved YUV and 422 mode Y stride */
75 u32 ulOverlayUVStride
; /* 422 mode U & V stride */
78 /* global graphics card info structure (one per card) */
79 static device_info_t deviceInfo
;
81 static char *mode_option
= NULL
;
83 static int nowrap
= 1;
84 static int nomtrr
= 0;
86 /* PCI driver prototypes */
87 static int kyrofb_probe(struct pci_dev
*pdev
, const struct pci_device_id
*ent
);
88 static void kyrofb_remove(struct pci_dev
*pdev
);
90 static struct fb_videomode kyro_modedb
[] = {
93 NULL
, 85, 640, 350, KHZ2PICOS(31500),
94 96, 32, 60, 32, 64, 3,
95 FB_SYNC_HOR_HIGH_ACT
, FB_VMODE_NONINTERLACED
98 NULL
, 85, 640, 400, KHZ2PICOS(31500),
100 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
103 NULL
, 85, 720, 400, KHZ2PICOS(35500),
104 108, 36, 42, 1, 72, 3,
105 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
108 NULL
, 60, 640, 480, KHZ2PICOS(25175),
109 48, 16, 33, 10, 96, 2,
110 0, FB_VMODE_NONINTERLACED
113 NULL
, 72, 640, 480, KHZ2PICOS(31500),
114 128, 24, 28, 9, 40, 3,
115 0, FB_VMODE_NONINTERLACED
118 NULL
, 75, 640, 480, KHZ2PICOS(31500),
119 120, 16, 16, 1, 64, 3,
120 0, FB_VMODE_NONINTERLACED
123 NULL
, 85, 640, 480, KHZ2PICOS(36000),
124 80, 56, 25, 1, 56, 3,
125 0, FB_VMODE_NONINTERLACED
128 NULL
, 56, 800, 600, KHZ2PICOS(36000),
129 128, 24, 22, 1, 72, 2,
130 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
133 NULL
, 60, 800, 600, KHZ2PICOS(40000),
134 88, 40, 23, 1, 128, 4,
135 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
138 NULL
, 72, 800, 600, KHZ2PICOS(50000),
139 64, 56, 23, 37, 120, 6,
140 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
143 NULL
, 75, 800, 600, KHZ2PICOS(49500),
144 160, 16, 21, 1, 80, 3,
145 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
148 NULL
, 85, 800, 600, KHZ2PICOS(56250),
149 152, 32, 27, 1, 64, 3,
150 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
152 /* 1024x768 @ 60Hz */
153 NULL
, 60, 1024, 768, KHZ2PICOS(65000),
154 160, 24, 29, 3, 136, 6,
155 0, FB_VMODE_NONINTERLACED
157 /* 1024x768 @ 70Hz */
158 NULL
, 70, 1024, 768, KHZ2PICOS(75000),
159 144, 24, 29, 3, 136, 6,
160 0, FB_VMODE_NONINTERLACED
162 /* 1024x768 @ 75Hz */
163 NULL
, 75, 1024, 768, KHZ2PICOS(78750),
164 176, 16, 28, 1, 96, 3,
165 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
167 /* 1024x768 @ 85Hz */
168 NULL
, 85, 1024, 768, KHZ2PICOS(94500),
169 208, 48, 36, 1, 96, 3,
170 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
172 /* 1152x864 @ 75Hz */
173 NULL
, 75, 1152, 864, KHZ2PICOS(108000),
174 256, 64, 32, 1, 128, 3,
175 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
177 /* 1280x960 @ 60Hz */
178 NULL
, 60, 1280, 960, KHZ2PICOS(108000),
179 312, 96, 36, 1, 112, 3,
180 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
182 /* 1280x960 @ 85Hz */
183 NULL
, 85, 1280, 960, KHZ2PICOS(148500),
184 224, 64, 47, 1, 160, 3,
185 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
187 /* 1280x1024 @ 60Hz */
188 NULL
, 60, 1280, 1024, KHZ2PICOS(108000),
189 248, 48, 38, 1, 112, 3,
190 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
192 /* 1280x1024 @ 75Hz */
193 NULL
, 75, 1280, 1024, KHZ2PICOS(135000),
194 248, 16, 38, 1, 144, 3,
195 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
197 /* 1280x1024 @ 85Hz */
198 NULL
, 85, 1280, 1024, KHZ2PICOS(157500),
199 224, 64, 44, 1, 160, 3,
200 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
202 /* 1600x1200 @ 60Hz */
203 NULL
, 60, 1600, 1200, KHZ2PICOS(162000),
204 304, 64, 46, 1, 192, 3,
205 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
207 /* 1600x1200 @ 65Hz */
208 NULL
, 65, 1600, 1200, KHZ2PICOS(175500),
209 304, 64, 46, 1, 192, 3,
210 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
212 /* 1600x1200 @ 70Hz */
213 NULL
, 70, 1600, 1200, KHZ2PICOS(189000),
214 304, 64, 46, 1, 192, 3,
215 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
217 /* 1600x1200 @ 75Hz */
218 NULL
, 75, 1600, 1200, KHZ2PICOS(202500),
219 304, 64, 46, 1, 192, 3,
220 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
222 /* 1600x1200 @ 85Hz */
223 NULL
, 85, 1600, 1200, KHZ2PICOS(229500),
224 304, 64, 46, 1, 192, 3,
225 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
227 /* 1792x1344 @ 60Hz */
228 NULL
, 60, 1792, 1344, KHZ2PICOS(204750),
229 328, 128, 46, 1, 200, 3,
230 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
232 /* 1792x1344 @ 75Hz */
233 NULL
, 75, 1792, 1344, KHZ2PICOS(261000),
234 352, 96, 69, 1, 216, 3,
235 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
237 /* 1856x1392 @ 60Hz */
238 NULL
, 60, 1856, 1392, KHZ2PICOS(218250),
239 352, 96, 43, 1, 224, 3,
240 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
242 /* 1856x1392 @ 75Hz */
243 NULL
, 75, 1856, 1392, KHZ2PICOS(288000),
244 352, 128, 104, 1, 224, 3,
245 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
247 /* 1920x1440 @ 60Hz */
248 NULL
, 60, 1920, 1440, KHZ2PICOS(234000),
249 344, 128, 56, 1, 208, 3,
250 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
252 /* 1920x1440 @ 75Hz */
253 NULL
, 75, 1920, 1440, KHZ2PICOS(297000),
254 352, 144, 56, 1, 224, 3,
255 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
258 #define NUM_TOTAL_MODES ARRAY_SIZE(kyro_modedb)
261 * This needs to be kept ordered corresponding to kyro_modedb.
300 static int kyro_dev_video_mode_set(struct fb_info
*info
)
302 struct kyrofb_info
*par
= info
->par
;
304 /* Turn off display */
305 StopVTG(deviceInfo
.pSTGReg
);
306 DisableRamdacOutput(deviceInfo
.pSTGReg
);
308 /* Bring us out of VGA and into Hi-Res mode, if not already. */
309 DisableVGA(deviceInfo
.pSTGReg
);
311 if (InitialiseRamdac(deviceInfo
.pSTGReg
,
312 info
->var
.bits_per_pixel
,
313 info
->var
.xres
, info
->var
.yres
,
314 par
->HSP
, par
->VSP
, &par
->PIXCLK
) < 0)
317 SetupVTG(deviceInfo
.pSTGReg
, par
);
319 ResetOverlayRegisters(deviceInfo
.pSTGReg
);
321 /* Turn on display in new mode */
322 EnableRamdacOutput(deviceInfo
.pSTGReg
);
323 StartVTG(deviceInfo
.pSTGReg
);
325 deviceInfo
.ulNextFreeVidMem
= info
->var
.xres
* info
->var
.yres
*
326 info
->var
.bits_per_pixel
;
327 deviceInfo
.ulOverlayOffset
= 0;
332 static int kyro_dev_overlay_create(u32 ulWidth
,
333 u32 ulHeight
, int bLinear
)
336 u32 stride
, uvStride
;
338 if (deviceInfo
.ulOverlayOffset
!= 0)
340 * Can only create one overlay without resetting the card or
341 * changing display mode
345 ResetOverlayRegisters(deviceInfo
.pSTGReg
);
347 /* Overlays are addressed in multiples of 16bytes or 32bytes, so make
348 * sure the start offset is on an appropriate boundary.
350 offset
= deviceInfo
.ulNextFreeVidMem
;
351 if ((offset
& 0x1f) != 0) {
352 offset
= (offset
+ 32L) & 0xffffffE0L
;
355 if (CreateOverlaySurface(deviceInfo
.pSTGReg
, ulWidth
, ulHeight
,
356 bLinear
, offset
, &stride
, &uvStride
) < 0)
359 deviceInfo
.ulOverlayOffset
= offset
;
360 deviceInfo
.ulOverlayStride
= stride
;
361 deviceInfo
.ulOverlayUVStride
= uvStride
;
362 deviceInfo
.ulNextFreeVidMem
= offset
+ (ulHeight
* stride
) + (ulHeight
* 2 * uvStride
);
364 SetOverlayBlendMode(deviceInfo
.pSTGReg
, GLOBAL_ALPHA
, 0xf, 0x0);
369 static int kyro_dev_overlay_viewport_set(u32 x
, u32 y
, u32 ulWidth
, u32 ulHeight
)
371 if (deviceInfo
.ulOverlayOffset
== 0)
372 /* probably haven't called CreateOverlay yet */
375 /* Stop Ramdac Output */
376 DisableRamdacOutput(deviceInfo
.pSTGReg
);
378 SetOverlayViewPort(deviceInfo
.pSTGReg
,
379 x
, y
, x
+ ulWidth
- 1, y
+ ulHeight
- 1);
381 EnableOverlayPlane(deviceInfo
.pSTGReg
);
382 /* Start Ramdac Output */
383 EnableRamdacOutput(deviceInfo
.pSTGReg
);
388 static inline unsigned long get_line_length(int x
, int bpp
)
390 return (unsigned long)((((x
*bpp
)+31)&~31) >> 3);
393 static int kyrofb_check_var(struct fb_var_screeninfo
*var
, struct fb_info
*info
)
395 struct kyrofb_info
*par
= info
->par
;
397 if (var
->bits_per_pixel
!= 16 && var
->bits_per_pixel
!= 32) {
398 printk(KERN_WARNING
"kyrofb: depth not supported: %u\n", var
->bits_per_pixel
);
402 switch (var
->bits_per_pixel
) {
404 var
->red
.offset
= 11;
406 var
->green
.offset
= 5;
407 var
->green
.length
= 6;
408 var
->blue
.length
= 5;
411 var
->transp
.offset
= 24;
412 var
->red
.offset
= 16;
413 var
->green
.offset
= 8;
414 var
->blue
.offset
= 0;
417 var
->green
.length
= 8;
418 var
->blue
.length
= 8;
419 var
->transp
.length
= 8;
423 /* Height/Width of picture in mm */
424 var
->height
= var
->width
= -1;
426 /* Timing information. All values are in picoseconds */
428 /* par->PIXCLK is in 100Hz units. Convert to picoseconds -
429 * ensuring we do not exceed 32 bit precision
432 * XXX: Enabling this really screws over the pixclock value when we
433 * read it back with fbset. As such, leaving this commented out appears
434 * to do the right thing (at least for now) .. bearing in mind that we
435 * have infact already done the KHZ2PICOS conversion in both the modedb
436 * and kyro_var. -- PFM.
438 // var->pixclock = 1000000000 / (par->PIXCLK / 10);
440 /* the header file claims we should use picoseconds
441 * - nobody else does though, the all use pixels and lines
442 * of h and v sizes. Both options here.
446 * If we're being called by __fb_try_mode(), then we don't want to
447 * override any of the var settings that we've already parsed
448 * from our modedb. -- PFM.
450 if ((var
->activate
& FB_ACTIVATE_MASK
) == FB_ACTIVATE_TEST
)
453 var
->left_margin
= par
->HBP
;
454 var
->hsync_len
= par
->HST
;
455 var
->right_margin
= par
->HFP
;
457 var
->upper_margin
= par
->VBP
;
458 var
->vsync_len
= par
->VST
;
459 var
->lower_margin
= par
->VFP
;
462 var
->sync
|= FB_SYNC_HOR_HIGH_ACT
;
464 var
->sync
|= FB_SYNC_VERT_HIGH_ACT
;
469 static int kyrofb_set_par(struct fb_info
*info
)
471 struct kyrofb_info
*par
= info
->par
;
472 unsigned long lineclock
;
473 unsigned long frameclock
;
475 /* Actual resolution */
476 par
->XRES
= info
->var
.xres
;
477 par
->YRES
= info
->var
.yres
;
480 par
->PIXDEPTH
= info
->var
.bits_per_pixel
;
483 /* time for a line in ns */
484 lineclock
= (info
->var
.pixclock
* (info
->var
.xres
+
485 info
->var
.right_margin
+
486 info
->var
.hsync_len
+
487 info
->var
.left_margin
)) / 1000;
490 /* time for a frame in ns (precision in 32bpp) */
491 frameclock
= lineclock
* (info
->var
.yres
+
492 info
->var
.lower_margin
+
493 info
->var
.vsync_len
+
494 info
->var
.upper_margin
);
496 /* Calculate refresh rate and horrizontal clocks */
497 par
->VFREQ
= (1000000000 + (frameclock
/ 2)) / frameclock
;
498 par
->HCLK
= (1000000000 + (lineclock
/ 2)) / lineclock
;
499 par
->PIXCLK
= ((1000000000 + (info
->var
.pixclock
/ 2))
500 / info
->var
.pixclock
) * 10;
502 /* calculate horizontal timings */
503 par
->HFP
= info
->var
.right_margin
;
504 par
->HST
= info
->var
.hsync_len
;
505 par
->HBP
= info
->var
.left_margin
;
506 par
->HTot
= par
->XRES
+ par
->HBP
+ par
->HST
+ par
->HFP
;
508 /* calculate vertical timings */
509 par
->VFP
= info
->var
.lower_margin
;
510 par
->VST
= info
->var
.vsync_len
;
511 par
->VBP
= info
->var
.upper_margin
;
512 par
->VTot
= par
->YRES
+ par
->VBP
+ par
->VST
+ par
->VFP
;
514 par
->HSP
= (info
->var
.sync
& FB_SYNC_HOR_HIGH_ACT
) ? 1 : 0;
515 par
->VSP
= (info
->var
.sync
& FB_SYNC_VERT_HIGH_ACT
) ? 1 : 0;
517 kyro_dev_video_mode_set(info
);
519 /* length of a line in bytes */
520 info
->fix
.line_length
= get_line_length(par
->XRES
, par
->PIXDEPTH
);
521 info
->fix
.visual
= FB_VISUAL_TRUECOLOR
;
526 static int kyrofb_setcolreg(u_int regno
, u_int red
, u_int green
,
527 u_int blue
, u_int transp
, struct fb_info
*info
)
529 struct kyrofb_info
*par
= info
->par
;
532 return 1; /* Invalid register */
535 switch (info
->var
.bits_per_pixel
) {
537 par
->palette
[regno
] =
539 ((green
& 0xfc00) >> 5) |
540 ((blue
& 0xf800) >> 11);
543 red
>>= 8; green
>>= 8; blue
>>= 8; transp
>>= 8;
544 par
->palette
[regno
] =
545 (transp
<< 24) | (red
<< 16) | (green
<< 8) | blue
;
554 static int __init
kyrofb_setup(char *options
)
558 if (!options
|| !*options
)
561 while ((this_opt
= strsep(&options
, ","))) {
564 if (strcmp(this_opt
, "nopan") == 0) {
566 } else if (strcmp(this_opt
, "nowrap") == 0) {
568 } else if (strcmp(this_opt
, "nomtrr") == 0) {
571 mode_option
= this_opt
;
579 static int kyrofb_ioctl(struct fb_info
*info
,
580 unsigned int cmd
, unsigned long arg
)
582 overlay_create ol_create
;
583 overlay_viewport_set ol_viewport_set
;
584 void __user
*argp
= (void __user
*)arg
;
587 case KYRO_IOCTL_OVERLAY_CREATE
:
588 if (copy_from_user(&ol_create
, argp
, sizeof(overlay_create
)))
591 if (kyro_dev_overlay_create(ol_create
.ulWidth
,
592 ol_create
.ulHeight
, 0) < 0) {
593 printk(KERN_ERR
"Kyro FB: failed to create overlay surface.\n");
598 case KYRO_IOCTL_OVERLAY_VIEWPORT_SET
:
599 if (copy_from_user(&ol_viewport_set
, argp
,
600 sizeof(overlay_viewport_set
)))
603 if (kyro_dev_overlay_viewport_set(ol_viewport_set
.xOrgin
,
604 ol_viewport_set
.yOrgin
,
605 ol_viewport_set
.xSize
,
606 ol_viewport_set
.ySize
) != 0)
608 printk(KERN_ERR
"Kyro FB: failed to create overlay viewport.\n");
612 case KYRO_IOCTL_SET_VIDEO_MODE
:
614 printk(KERN_ERR
"Kyro FB: KYRO_IOCTL_SET_VIDEO_MODE is"
615 "obsolete, use the appropriate fb_ioctl()"
616 "command instead.\n");
619 case KYRO_IOCTL_UVSTRIDE
:
620 if (copy_to_user(argp
, &deviceInfo
.ulOverlayUVStride
, sizeof(deviceInfo
.ulOverlayUVStride
)))
623 case KYRO_IOCTL_STRIDE
:
624 if (copy_to_user(argp
, &deviceInfo
.ulOverlayStride
, sizeof(deviceInfo
.ulOverlayStride
)))
627 case KYRO_IOCTL_OVERLAY_OFFSET
:
628 if (copy_to_user(argp
, &deviceInfo
.ulOverlayOffset
, sizeof(deviceInfo
.ulOverlayOffset
)))
636 static struct pci_device_id kyrofb_pci_tbl
[] = {
637 { PCI_VENDOR_ID_ST
, PCI_DEVICE_ID_STG4000
,
638 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
642 MODULE_DEVICE_TABLE(pci
, kyrofb_pci_tbl
);
644 static struct pci_driver kyrofb_pci_driver
= {
646 .id_table
= kyrofb_pci_tbl
,
647 .probe
= kyrofb_probe
,
648 .remove
= kyrofb_remove
,
651 static struct fb_ops kyrofb_ops
= {
652 .owner
= THIS_MODULE
,
653 .fb_check_var
= kyrofb_check_var
,
654 .fb_set_par
= kyrofb_set_par
,
655 .fb_setcolreg
= kyrofb_setcolreg
,
656 .fb_ioctl
= kyrofb_ioctl
,
657 .fb_fillrect
= cfb_fillrect
,
658 .fb_copyarea
= cfb_copyarea
,
659 .fb_imageblit
= cfb_imageblit
,
662 static int kyrofb_probe(struct pci_dev
*pdev
, const struct pci_device_id
*ent
)
664 struct fb_info
*info
;
665 struct kyrofb_info
*currentpar
;
669 if ((err
= pci_enable_device(pdev
))) {
670 printk(KERN_WARNING
"kyrofb: Can't enable pdev: %d\n", err
);
674 info
= framebuffer_alloc(sizeof(struct kyrofb_info
), &pdev
->dev
);
678 currentpar
= info
->par
;
680 kyro_fix
.smem_start
= pci_resource_start(pdev
, 0);
681 kyro_fix
.smem_len
= pci_resource_len(pdev
, 0);
682 kyro_fix
.mmio_start
= pci_resource_start(pdev
, 1);
683 kyro_fix
.mmio_len
= pci_resource_len(pdev
, 1);
685 currentpar
->regbase
= deviceInfo
.pSTGReg
=
686 ioremap_nocache(kyro_fix
.mmio_start
, kyro_fix
.mmio_len
);
687 if (!currentpar
->regbase
)
690 info
->screen_base
= pci_ioremap_wc_bar(pdev
, 0);
691 if (!info
->screen_base
)
695 currentpar
->wc_cookie
= arch_phys_wc_add(kyro_fix
.smem_start
,
698 kyro_fix
.ypanstep
= nopan
? 0 : 1;
699 kyro_fix
.ywrapstep
= nowrap
? 0 : 1;
701 info
->fbops
= &kyrofb_ops
;
702 info
->fix
= kyro_fix
;
703 info
->pseudo_palette
= currentpar
->palette
;
704 info
->flags
= FBINFO_DEFAULT
;
706 SetCoreClockPLL(deviceInfo
.pSTGReg
, pdev
);
708 deviceInfo
.ulNextFreeVidMem
= 0;
709 deviceInfo
.ulOverlayOffset
= 0;
711 /* This should give a reasonable default video mode */
712 if (!fb_find_mode(&info
->var
, info
, mode_option
, kyro_modedb
,
713 NUM_TOTAL_MODES
, &kyro_modedb
[VMODE_1024_768_75
], 32))
714 info
->var
= kyro_var
;
716 fb_alloc_cmap(&info
->cmap
, 256, 0);
718 kyrofb_set_par(info
);
719 kyrofb_check_var(&info
->var
, info
);
721 size
= get_line_length(info
->var
.xres_virtual
,
722 info
->var
.bits_per_pixel
);
723 size
*= info
->var
.yres_virtual
;
725 fb_memset(info
->screen_base
, 0, size
);
727 if (register_framebuffer(info
) < 0)
730 fb_info(info
, "%s frame buffer device, at %dx%d@%d using %ldk/%ldk of VRAM\n",
732 info
->var
.xres
, info
->var
.yres
, info
->var
.bits_per_pixel
,
733 size
>> 10, (unsigned long)info
->fix
.smem_len
>> 10);
735 pci_set_drvdata(pdev
, info
);
740 iounmap(info
->screen_base
);
742 iounmap(currentpar
->regbase
);
744 framebuffer_release(info
);
749 static void kyrofb_remove(struct pci_dev
*pdev
)
751 struct fb_info
*info
= pci_get_drvdata(pdev
);
752 struct kyrofb_info
*par
= info
->par
;
754 /* Reset the board */
755 StopVTG(deviceInfo
.pSTGReg
);
756 DisableRamdacOutput(deviceInfo
.pSTGReg
);
758 /* Sync up the PLL */
759 SetCoreClockPLL(deviceInfo
.pSTGReg
, pdev
);
761 deviceInfo
.ulNextFreeVidMem
= 0;
762 deviceInfo
.ulOverlayOffset
= 0;
764 iounmap(info
->screen_base
);
765 iounmap(par
->regbase
);
767 arch_phys_wc_del(par
->wc_cookie
);
769 unregister_framebuffer(info
);
770 framebuffer_release(info
);
773 static int __init
kyrofb_init(void)
778 if (fb_get_options("kyrofb", &option
))
780 kyrofb_setup(option
);
782 return pci_register_driver(&kyrofb_pci_driver
);
785 static void __exit
kyrofb_exit(void)
787 pci_unregister_driver(&kyrofb_pci_driver
);
790 module_init(kyrofb_init
);
793 module_exit(kyrofb_exit
);
796 MODULE_AUTHOR("STMicroelectronics; Paul Mundt <lethal@linux-sh.org>");
797 MODULE_LICENSE("GPL");