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/aperture.h>
13 #include <linux/module.h>
14 #include <linux/types.h>
15 #include <linux/kernel.h>
17 #include <linux/errno.h>
18 #include <linux/string.h>
19 #include <linux/delay.h>
21 #include <linux/ioctl.h>
22 #include <linux/init.h>
23 #include <linux/pci.h>
25 #include <linux/uaccess.h>
27 #include <video/kyro.h>
29 #include "STG4000Reg.h"
30 #include "STG4000Interface.h"
35 #define PCI_VENDOR_ID_ST 0x104a
36 #define PCI_DEVICE_ID_STG4000 0x0010
38 #define KHZ2PICOS(a) (1000000000UL/(a))
40 /****************************************************************************/
41 static struct fb_fix_screeninfo kyro_fix
= {
43 .type
= FB_TYPE_PACKED_PIXELS
,
44 .visual
= FB_VISUAL_TRUECOLOR
,
45 .accel
= FB_ACCEL_NONE
,
48 static const struct fb_var_screeninfo kyro_var
= {
49 /* 640x480, 16bpp @ 60 Hz */
58 .activate
= FB_ACTIVATE_NOW
,
61 .pixclock
= KHZ2PICOS(25175),
68 .vmode
= FB_VMODE_NONINTERLACED
,
72 STG4000REG __iomem
*pSTGReg
; /* Virtual address of PCI register region */
73 u32 ulNextFreeVidMem
; /* Offset from start of vid mem to next free region */
74 u32 ulOverlayOffset
; /* Offset from start of vid mem to overlay */
75 u32 ulOverlayStride
; /* Interleaved YUV and 422 mode Y stride */
76 u32 ulOverlayUVStride
; /* 422 mode U & V stride */
79 /* global graphics card info structure (one per card) */
80 static device_info_t deviceInfo
;
82 static char *mode_option
= NULL
;
84 static int nowrap
= 1;
85 static int nomtrr
= 0;
87 /* PCI driver prototypes */
88 static int kyrofb_probe(struct pci_dev
*pdev
, const struct pci_device_id
*ent
);
89 static void kyrofb_remove(struct pci_dev
*pdev
);
91 static struct fb_videomode kyro_modedb
[] = {
94 NULL
, 85, 640, 350, KHZ2PICOS(31500),
95 96, 32, 60, 32, 64, 3,
96 FB_SYNC_HOR_HIGH_ACT
, FB_VMODE_NONINTERLACED
99 NULL
, 85, 640, 400, KHZ2PICOS(31500),
100 96, 32, 41, 1, 64, 3,
101 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
104 NULL
, 85, 720, 400, KHZ2PICOS(35500),
105 108, 36, 42, 1, 72, 3,
106 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
109 NULL
, 60, 640, 480, KHZ2PICOS(25175),
110 48, 16, 33, 10, 96, 2,
111 0, FB_VMODE_NONINTERLACED
114 NULL
, 72, 640, 480, KHZ2PICOS(31500),
115 128, 24, 28, 9, 40, 3,
116 0, FB_VMODE_NONINTERLACED
119 NULL
, 75, 640, 480, KHZ2PICOS(31500),
120 120, 16, 16, 1, 64, 3,
121 0, FB_VMODE_NONINTERLACED
124 NULL
, 85, 640, 480, KHZ2PICOS(36000),
125 80, 56, 25, 1, 56, 3,
126 0, FB_VMODE_NONINTERLACED
129 NULL
, 56, 800, 600, KHZ2PICOS(36000),
130 128, 24, 22, 1, 72, 2,
131 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
134 NULL
, 60, 800, 600, KHZ2PICOS(40000),
135 88, 40, 23, 1, 128, 4,
136 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
139 NULL
, 72, 800, 600, KHZ2PICOS(50000),
140 64, 56, 23, 37, 120, 6,
141 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
144 NULL
, 75, 800, 600, KHZ2PICOS(49500),
145 160, 16, 21, 1, 80, 3,
146 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
149 NULL
, 85, 800, 600, KHZ2PICOS(56250),
150 152, 32, 27, 1, 64, 3,
151 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
153 /* 1024x768 @ 60Hz */
154 NULL
, 60, 1024, 768, KHZ2PICOS(65000),
155 160, 24, 29, 3, 136, 6,
156 0, FB_VMODE_NONINTERLACED
158 /* 1024x768 @ 70Hz */
159 NULL
, 70, 1024, 768, KHZ2PICOS(75000),
160 144, 24, 29, 3, 136, 6,
161 0, FB_VMODE_NONINTERLACED
163 /* 1024x768 @ 75Hz */
164 NULL
, 75, 1024, 768, KHZ2PICOS(78750),
165 176, 16, 28, 1, 96, 3,
166 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
168 /* 1024x768 @ 85Hz */
169 NULL
, 85, 1024, 768, KHZ2PICOS(94500),
170 208, 48, 36, 1, 96, 3,
171 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
173 /* 1152x864 @ 75Hz */
174 NULL
, 75, 1152, 864, KHZ2PICOS(108000),
175 256, 64, 32, 1, 128, 3,
176 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
178 /* 1280x960 @ 60Hz */
179 NULL
, 60, 1280, 960, KHZ2PICOS(108000),
180 312, 96, 36, 1, 112, 3,
181 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
183 /* 1280x960 @ 85Hz */
184 NULL
, 85, 1280, 960, KHZ2PICOS(148500),
185 224, 64, 47, 1, 160, 3,
186 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
188 /* 1280x1024 @ 60Hz */
189 NULL
, 60, 1280, 1024, KHZ2PICOS(108000),
190 248, 48, 38, 1, 112, 3,
191 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
193 /* 1280x1024 @ 75Hz */
194 NULL
, 75, 1280, 1024, KHZ2PICOS(135000),
195 248, 16, 38, 1, 144, 3,
196 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
198 /* 1280x1024 @ 85Hz */
199 NULL
, 85, 1280, 1024, KHZ2PICOS(157500),
200 224, 64, 44, 1, 160, 3,
201 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
203 /* 1600x1200 @ 60Hz */
204 NULL
, 60, 1600, 1200, KHZ2PICOS(162000),
205 304, 64, 46, 1, 192, 3,
206 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
208 /* 1600x1200 @ 65Hz */
209 NULL
, 65, 1600, 1200, KHZ2PICOS(175500),
210 304, 64, 46, 1, 192, 3,
211 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
213 /* 1600x1200 @ 70Hz */
214 NULL
, 70, 1600, 1200, KHZ2PICOS(189000),
215 304, 64, 46, 1, 192, 3,
216 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
218 /* 1600x1200 @ 75Hz */
219 NULL
, 75, 1600, 1200, KHZ2PICOS(202500),
220 304, 64, 46, 1, 192, 3,
221 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
223 /* 1600x1200 @ 85Hz */
224 NULL
, 85, 1600, 1200, KHZ2PICOS(229500),
225 304, 64, 46, 1, 192, 3,
226 FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
228 /* 1792x1344 @ 60Hz */
229 NULL
, 60, 1792, 1344, KHZ2PICOS(204750),
230 328, 128, 46, 1, 200, 3,
231 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
233 /* 1792x1344 @ 75Hz */
234 NULL
, 75, 1792, 1344, KHZ2PICOS(261000),
235 352, 96, 69, 1, 216, 3,
236 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
238 /* 1856x1392 @ 60Hz */
239 NULL
, 60, 1856, 1392, KHZ2PICOS(218250),
240 352, 96, 43, 1, 224, 3,
241 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
243 /* 1856x1392 @ 75Hz */
244 NULL
, 75, 1856, 1392, KHZ2PICOS(288000),
245 352, 128, 104, 1, 224, 3,
246 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
248 /* 1920x1440 @ 60Hz */
249 NULL
, 60, 1920, 1440, KHZ2PICOS(234000),
250 344, 128, 56, 1, 208, 3,
251 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
253 /* 1920x1440 @ 75Hz */
254 NULL
, 75, 1920, 1440, KHZ2PICOS(297000),
255 352, 144, 56, 1, 224, 3,
256 FB_SYNC_VERT_HIGH_ACT
, FB_VMODE_NONINTERLACED
259 #define NUM_TOTAL_MODES ARRAY_SIZE(kyro_modedb)
262 * This needs to be kept ordered corresponding to kyro_modedb.
301 static int kyro_dev_video_mode_set(struct fb_info
*info
)
303 struct kyrofb_info
*par
= info
->par
;
305 /* Turn off display */
306 StopVTG(deviceInfo
.pSTGReg
);
307 DisableRamdacOutput(deviceInfo
.pSTGReg
);
309 /* Bring us out of VGA and into Hi-Res mode, if not already. */
310 DisableVGA(deviceInfo
.pSTGReg
);
312 if (InitialiseRamdac(deviceInfo
.pSTGReg
,
313 info
->var
.bits_per_pixel
,
314 info
->var
.xres
, info
->var
.yres
,
315 par
->HSP
, par
->VSP
, &par
->PIXCLK
) < 0)
318 SetupVTG(deviceInfo
.pSTGReg
, par
);
320 ResetOverlayRegisters(deviceInfo
.pSTGReg
);
322 /* Turn on display in new mode */
323 EnableRamdacOutput(deviceInfo
.pSTGReg
);
324 StartVTG(deviceInfo
.pSTGReg
);
326 deviceInfo
.ulNextFreeVidMem
= info
->var
.xres
* info
->var
.yres
*
327 info
->var
.bits_per_pixel
;
328 deviceInfo
.ulOverlayOffset
= 0;
333 static int kyro_dev_overlay_create(u32 ulWidth
,
334 u32 ulHeight
, int bLinear
)
337 u32 stride
, uvStride
;
339 if (deviceInfo
.ulOverlayOffset
!= 0)
341 * Can only create one overlay without resetting the card or
342 * changing display mode
346 ResetOverlayRegisters(deviceInfo
.pSTGReg
);
348 /* Overlays are addressed in multiples of 16bytes or 32bytes, so make
349 * sure the start offset is on an appropriate boundary.
351 offset
= deviceInfo
.ulNextFreeVidMem
;
352 if ((offset
& 0x1f) != 0) {
353 offset
= (offset
+ 32L) & 0xffffffE0L
;
356 if (CreateOverlaySurface(deviceInfo
.pSTGReg
, ulWidth
, ulHeight
,
357 bLinear
, offset
, &stride
, &uvStride
) < 0)
360 deviceInfo
.ulOverlayOffset
= offset
;
361 deviceInfo
.ulOverlayStride
= stride
;
362 deviceInfo
.ulOverlayUVStride
= uvStride
;
363 deviceInfo
.ulNextFreeVidMem
= offset
+ (ulHeight
* stride
) + (ulHeight
* 2 * uvStride
);
365 SetOverlayBlendMode(deviceInfo
.pSTGReg
, GLOBAL_ALPHA
, 0xf, 0x0);
370 static int kyro_dev_overlay_viewport_set(u32 x
, u32 y
, u32 ulWidth
, u32 ulHeight
)
372 if (deviceInfo
.ulOverlayOffset
== 0)
373 /* probably haven't called CreateOverlay yet */
376 if (ulWidth
== 0 || ulWidth
== 0xffffffff ||
377 ulHeight
== 0 || ulHeight
== 0xffffffff ||
378 (x
< 2 && ulWidth
+ 2 == 0))
381 /* Stop Ramdac Output */
382 DisableRamdacOutput(deviceInfo
.pSTGReg
);
384 SetOverlayViewPort(deviceInfo
.pSTGReg
,
385 x
, y
, x
+ ulWidth
- 1, y
+ ulHeight
- 1);
387 EnableOverlayPlane(deviceInfo
.pSTGReg
);
388 /* Start Ramdac Output */
389 EnableRamdacOutput(deviceInfo
.pSTGReg
);
394 static inline unsigned long get_line_length(int x
, int bpp
)
396 return (unsigned long)((((x
*bpp
)+31)&~31) >> 3);
399 static int kyrofb_check_var(struct fb_var_screeninfo
*var
, struct fb_info
*info
)
401 struct kyrofb_info
*par
= info
->par
;
406 if (var
->bits_per_pixel
!= 16 && var
->bits_per_pixel
!= 32) {
407 printk(KERN_WARNING
"kyrofb: depth not supported: %u\n", var
->bits_per_pixel
);
411 switch (var
->bits_per_pixel
) {
413 var
->red
.offset
= 11;
415 var
->green
.offset
= 5;
416 var
->green
.length
= 6;
417 var
->blue
.length
= 5;
420 var
->transp
.offset
= 24;
421 var
->red
.offset
= 16;
422 var
->green
.offset
= 8;
423 var
->blue
.offset
= 0;
426 var
->green
.length
= 8;
427 var
->blue
.length
= 8;
428 var
->transp
.length
= 8;
432 /* Height/Width of picture in mm */
433 var
->height
= var
->width
= -1;
435 /* Timing information. All values are in picoseconds */
437 /* par->PIXCLK is in 100Hz units. Convert to picoseconds -
438 * ensuring we do not exceed 32 bit precision
441 * XXX: Enabling this really screws over the pixclock value when we
442 * read it back with fbset. As such, leaving this commented out appears
443 * to do the right thing (at least for now) .. bearing in mind that we
444 * have infact already done the KHZ2PICOS conversion in both the modedb
445 * and kyro_var. -- PFM.
447 // var->pixclock = 1000000000 / (par->PIXCLK / 10);
449 /* the header file claims we should use picoseconds
450 * - nobody else does though, the all use pixels and lines
451 * of h and v sizes. Both options here.
455 * If we're being called by __fb_try_mode(), then we don't want to
456 * override any of the var settings that we've already parsed
457 * from our modedb. -- PFM.
459 if ((var
->activate
& FB_ACTIVATE_MASK
) == FB_ACTIVATE_TEST
)
462 var
->left_margin
= par
->HBP
;
463 var
->hsync_len
= par
->HST
;
464 var
->right_margin
= par
->HFP
;
466 var
->upper_margin
= par
->VBP
;
467 var
->vsync_len
= par
->VST
;
468 var
->lower_margin
= par
->VFP
;
471 var
->sync
|= FB_SYNC_HOR_HIGH_ACT
;
473 var
->sync
|= FB_SYNC_VERT_HIGH_ACT
;
478 static int kyrofb_set_par(struct fb_info
*info
)
480 struct kyrofb_info
*par
= info
->par
;
481 unsigned long lineclock
;
482 unsigned long frameclock
;
484 /* Actual resolution */
485 par
->XRES
= info
->var
.xres
;
486 par
->YRES
= info
->var
.yres
;
489 par
->PIXDEPTH
= info
->var
.bits_per_pixel
;
492 /* time for a line in ns */
493 lineclock
= (info
->var
.pixclock
* (info
->var
.xres
+
494 info
->var
.right_margin
+
495 info
->var
.hsync_len
+
496 info
->var
.left_margin
)) / 1000;
501 /* time for a frame in ns (precision in 32bpp) */
502 frameclock
= lineclock
* (info
->var
.yres
+
503 info
->var
.lower_margin
+
504 info
->var
.vsync_len
+
505 info
->var
.upper_margin
);
507 /* Calculate refresh rate and horrizontal clocks */
508 par
->VFREQ
= (1000000000 + (frameclock
/ 2)) / frameclock
;
509 par
->HCLK
= (1000000000 + (lineclock
/ 2)) / lineclock
;
510 par
->PIXCLK
= ((1000000000 + (info
->var
.pixclock
/ 2))
511 / info
->var
.pixclock
) * 10;
513 /* calculate horizontal timings */
514 par
->HFP
= info
->var
.right_margin
;
515 par
->HST
= info
->var
.hsync_len
;
516 par
->HBP
= info
->var
.left_margin
;
517 par
->HTot
= par
->XRES
+ par
->HBP
+ par
->HST
+ par
->HFP
;
519 /* calculate vertical timings */
520 par
->VFP
= info
->var
.lower_margin
;
521 par
->VST
= info
->var
.vsync_len
;
522 par
->VBP
= info
->var
.upper_margin
;
523 par
->VTot
= par
->YRES
+ par
->VBP
+ par
->VST
+ par
->VFP
;
525 par
->HSP
= (info
->var
.sync
& FB_SYNC_HOR_HIGH_ACT
) ? 1 : 0;
526 par
->VSP
= (info
->var
.sync
& FB_SYNC_VERT_HIGH_ACT
) ? 1 : 0;
528 kyro_dev_video_mode_set(info
);
530 /* length of a line in bytes */
531 info
->fix
.line_length
= get_line_length(par
->XRES
, par
->PIXDEPTH
);
532 info
->fix
.visual
= FB_VISUAL_TRUECOLOR
;
537 static int kyrofb_setcolreg(u_int regno
, u_int red
, u_int green
,
538 u_int blue
, u_int transp
, struct fb_info
*info
)
540 struct kyrofb_info
*par
= info
->par
;
543 return 1; /* Invalid register */
546 switch (info
->var
.bits_per_pixel
) {
548 par
->palette
[regno
] =
550 ((green
& 0xfc00) >> 5) |
551 ((blue
& 0xf800) >> 11);
554 red
>>= 8; green
>>= 8; blue
>>= 8; transp
>>= 8;
555 par
->palette
[regno
] =
556 (transp
<< 24) | (red
<< 16) | (green
<< 8) | blue
;
565 static int __init
kyrofb_setup(char *options
)
569 if (!options
|| !*options
)
572 while ((this_opt
= strsep(&options
, ","))) {
575 if (strcmp(this_opt
, "nopan") == 0) {
577 } else if (strcmp(this_opt
, "nowrap") == 0) {
579 } else if (strcmp(this_opt
, "nomtrr") == 0) {
582 mode_option
= this_opt
;
590 static int kyrofb_ioctl(struct fb_info
*info
,
591 unsigned int cmd
, unsigned long arg
)
593 overlay_create ol_create
;
594 overlay_viewport_set ol_viewport_set
;
595 void __user
*argp
= (void __user
*)arg
;
598 case KYRO_IOCTL_OVERLAY_CREATE
:
599 if (copy_from_user(&ol_create
, argp
, sizeof(overlay_create
)))
602 if (kyro_dev_overlay_create(ol_create
.ulWidth
,
603 ol_create
.ulHeight
, 0) < 0) {
604 printk(KERN_ERR
"Kyro FB: failed to create overlay surface.\n");
609 case KYRO_IOCTL_OVERLAY_VIEWPORT_SET
:
610 if (copy_from_user(&ol_viewport_set
, argp
,
611 sizeof(overlay_viewport_set
)))
614 if (kyro_dev_overlay_viewport_set(ol_viewport_set
.xOrgin
,
615 ol_viewport_set
.yOrgin
,
616 ol_viewport_set
.xSize
,
617 ol_viewport_set
.ySize
) != 0)
619 printk(KERN_ERR
"Kyro FB: failed to create overlay viewport.\n");
623 case KYRO_IOCTL_SET_VIDEO_MODE
:
625 printk(KERN_ERR
"Kyro FB: KYRO_IOCTL_SET_VIDEO_MODE is"
626 "obsolete, use the appropriate fb_ioctl()"
627 "command instead.\n");
630 case KYRO_IOCTL_UVSTRIDE
:
631 if (copy_to_user(argp
, &deviceInfo
.ulOverlayUVStride
, sizeof(deviceInfo
.ulOverlayUVStride
)))
634 case KYRO_IOCTL_STRIDE
:
635 if (copy_to_user(argp
, &deviceInfo
.ulOverlayStride
, sizeof(deviceInfo
.ulOverlayStride
)))
638 case KYRO_IOCTL_OVERLAY_OFFSET
:
639 if (copy_to_user(argp
, &deviceInfo
.ulOverlayOffset
, sizeof(deviceInfo
.ulOverlayOffset
)))
647 static const struct pci_device_id kyrofb_pci_tbl
[] = {
648 { PCI_VENDOR_ID_ST
, PCI_DEVICE_ID_STG4000
,
649 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
653 MODULE_DEVICE_TABLE(pci
, kyrofb_pci_tbl
);
655 static struct pci_driver kyrofb_pci_driver
= {
657 .id_table
= kyrofb_pci_tbl
,
658 .probe
= kyrofb_probe
,
659 .remove
= kyrofb_remove
,
662 static const struct fb_ops kyrofb_ops
= {
663 .owner
= THIS_MODULE
,
664 FB_DEFAULT_IOMEM_OPS
,
665 .fb_check_var
= kyrofb_check_var
,
666 .fb_set_par
= kyrofb_set_par
,
667 .fb_setcolreg
= kyrofb_setcolreg
,
668 .fb_ioctl
= kyrofb_ioctl
,
671 static int kyrofb_probe(struct pci_dev
*pdev
, const struct pci_device_id
*ent
)
673 struct fb_info
*info
;
674 struct kyrofb_info
*currentpar
;
678 err
= aperture_remove_conflicting_pci_devices(pdev
, "kyrofb");
682 if ((err
= pci_enable_device(pdev
))) {
683 printk(KERN_WARNING
"kyrofb: Can't enable pdev: %d\n", err
);
687 info
= framebuffer_alloc(sizeof(struct kyrofb_info
), &pdev
->dev
);
691 currentpar
= info
->par
;
693 kyro_fix
.smem_start
= pci_resource_start(pdev
, 0);
694 kyro_fix
.smem_len
= pci_resource_len(pdev
, 0);
695 kyro_fix
.mmio_start
= pci_resource_start(pdev
, 1);
696 kyro_fix
.mmio_len
= pci_resource_len(pdev
, 1);
698 currentpar
->regbase
= deviceInfo
.pSTGReg
=
699 ioremap(kyro_fix
.mmio_start
, kyro_fix
.mmio_len
);
700 if (!currentpar
->regbase
)
703 info
->screen_base
= pci_ioremap_wc_bar(pdev
, 0);
704 if (!info
->screen_base
)
708 currentpar
->wc_cookie
= arch_phys_wc_add(kyro_fix
.smem_start
,
711 kyro_fix
.ypanstep
= nopan
? 0 : 1;
712 kyro_fix
.ywrapstep
= nowrap
? 0 : 1;
714 info
->fbops
= &kyrofb_ops
;
715 info
->fix
= kyro_fix
;
716 info
->pseudo_palette
= currentpar
->palette
;
718 SetCoreClockPLL(deviceInfo
.pSTGReg
, pdev
);
720 deviceInfo
.ulNextFreeVidMem
= 0;
721 deviceInfo
.ulOverlayOffset
= 0;
723 /* This should give a reasonable default video mode */
724 if (!fb_find_mode(&info
->var
, info
, mode_option
, kyro_modedb
,
725 NUM_TOTAL_MODES
, &kyro_modedb
[VMODE_1024_768_75
], 32))
726 info
->var
= kyro_var
;
728 fb_alloc_cmap(&info
->cmap
, 256, 0);
730 kyrofb_set_par(info
);
731 kyrofb_check_var(&info
->var
, info
);
733 size
= get_line_length(info
->var
.xres_virtual
,
734 info
->var
.bits_per_pixel
);
735 size
*= info
->var
.yres_virtual
;
737 fb_memset_io(info
->screen_base
, 0, size
);
739 if (register_framebuffer(info
) < 0)
742 fb_info(info
, "%s frame buffer device, at %dx%d@%d using %ldk/%ldk of VRAM\n",
744 info
->var
.xres
, info
->var
.yres
, info
->var
.bits_per_pixel
,
745 size
>> 10, (unsigned long)info
->fix
.smem_len
>> 10);
747 pci_set_drvdata(pdev
, info
);
752 iounmap(info
->screen_base
);
754 iounmap(currentpar
->regbase
);
756 framebuffer_release(info
);
761 static void kyrofb_remove(struct pci_dev
*pdev
)
763 struct fb_info
*info
= pci_get_drvdata(pdev
);
764 struct kyrofb_info
*par
= info
->par
;
766 /* Reset the board */
767 StopVTG(deviceInfo
.pSTGReg
);
768 DisableRamdacOutput(deviceInfo
.pSTGReg
);
770 /* Sync up the PLL */
771 SetCoreClockPLL(deviceInfo
.pSTGReg
, pdev
);
773 deviceInfo
.ulNextFreeVidMem
= 0;
774 deviceInfo
.ulOverlayOffset
= 0;
776 iounmap(info
->screen_base
);
777 iounmap(par
->regbase
);
779 arch_phys_wc_del(par
->wc_cookie
);
781 unregister_framebuffer(info
);
782 framebuffer_release(info
);
785 static int __init
kyrofb_init(void)
791 if (fb_modesetting_disabled("kyrofb"))
795 if (fb_get_options("kyrofb", &option
))
797 kyrofb_setup(option
);
799 return pci_register_driver(&kyrofb_pci_driver
);
802 static void __exit
kyrofb_exit(void)
804 pci_unregister_driver(&kyrofb_pci_driver
);
807 module_init(kyrofb_init
);
810 module_exit(kyrofb_exit
);
813 MODULE_AUTHOR("STMicroelectronics; Paul Mundt <lethal@linux-sh.org>");
814 MODULE_DESCRIPTION("STG4000/Kyro/PowerVR 3 driver");
815 MODULE_LICENSE("GPL");