2 * linux/drivers/video/kyro/kyrofb.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/config.h>
13 #include <linux/module.h>
14 #include <linux/types.h>
15 #include <linux/kernel.h>
16 #include <linux/sched.h>
18 #include <linux/errno.h>
19 #include <linux/string.h>
20 #include <linux/tty.h>
21 #include <linux/delay.h>
23 #include <linux/ioctl.h>
24 #include <linux/init.h>
25 #include <linux/pci.h>
27 #include <asm/uaccess.h>
32 #include <video/kyro.h>
34 #include "STG4000Reg.h"
35 #include "STG4000Interface.h"
40 #define PCI_VENDOR_ID_ST 0x104a
41 #define PCI_DEVICE_ID_STG4000 0x0010
43 #define KHZ2PICOS(a) (1000000000UL/(a))
45 /****************************************************************************/
46 static struct fb_fix_screeninfo kyro_fix __initdata = {
48 .type = FB_TYPE_PACKED_PIXELS,
49 .visual = FB_VISUAL_TRUECOLOR,
50 .accel = FB_ACCEL_NONE,
53 static struct fb_var_screeninfo kyro_var __initdata = {
54 /* 640x480, 16bpp @ 60 Hz */
63 .activate = FB_ACTIVATE_NOW,
66 .pixclock = KHZ2PICOS(25175),
73 .vmode = FB_VMODE_NONINTERLACED,
76 static struct kyrofb_info *currentpar;
79 STG4000REG *pSTGReg; /* Virtual address of PCI register region */
80 u32 ulNextFreeVidMem; /* Offset from start of vid mem to next free region */
81 u32 ulOverlayOffset; /* Offset from start of vid mem to overlay */
82 u32 ulOverlayStride; /* Interleaved YUV and 422 mode Y stride */
83 u32 ulOverlayUVStride; /* 422 mode U & V stride */
86 /* global graphics card info structure (one per card) */
87 static device_info_t deviceInfo = { 0 };
89 static char *mode_option __initdata = NULL;
90 static int nopan __initdata = 0;
91 static int nowrap __initdata = 1;
93 static int nomtrr __initdata = 0;
96 /* PCI driver prototypes */
97 static int kyrofb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
98 static void kyrofb_remove(struct pci_dev *pdev);
101 static struct fb_videomode kyro_modedb[] __initdata = {
104 NULL, 85, 640, 350, KHZ2PICOS(31500),
105 96, 32, 60, 32, 64, 3,
106 FB_SYNC_HOR_HIGH_ACT, FB_VMODE_NONINTERLACED
109 NULL, 85, 640, 400, KHZ2PICOS(31500),
110 96, 32, 41, 1, 64, 3,
111 FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
114 NULL, 85, 720, 400, KHZ2PICOS(35500),
115 108, 36, 42, 1, 72, 3,
116 FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
119 NULL, 60, 640, 480, KHZ2PICOS(25175),
120 48, 16, 33, 10, 96, 2,
121 0, FB_VMODE_NONINTERLACED
124 NULL, 72, 640, 480, KHZ2PICOS(31500),
125 128, 24, 28, 9, 40, 3,
126 0, FB_VMODE_NONINTERLACED
129 NULL, 75, 640, 480, KHZ2PICOS(31500),
130 120, 16, 16, 1, 64, 3,
131 0, FB_VMODE_NONINTERLACED
134 NULL, 85, 640, 480, KHZ2PICOS(36000),
135 80, 56, 25, 1, 56, 3,
136 0, FB_VMODE_NONINTERLACED
139 NULL, 56, 800, 600, KHZ2PICOS(36000),
140 128, 24, 22, 1, 72, 2,
141 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
144 NULL, 60, 800, 600, KHZ2PICOS(40000),
145 88, 40, 23, 1, 128, 4,
146 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
149 NULL, 72, 800, 600, KHZ2PICOS(50000),
150 64, 56, 23, 37, 120, 6,
151 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
154 NULL, 75, 800, 600, KHZ2PICOS(49500),
155 160, 16, 21, 1, 80, 3,
156 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
159 NULL, 85, 800, 600, KHZ2PICOS(56250),
160 152, 32, 27, 1, 64, 3,
161 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
163 /* 1024x768 @ 60Hz */
164 NULL, 60, 1024, 768, KHZ2PICOS(65000),
165 160, 24, 29, 3, 136, 6,
166 0, FB_VMODE_NONINTERLACED
168 /* 1024x768 @ 70Hz */
169 NULL, 70, 1024, 768, KHZ2PICOS(75000),
170 144, 24, 29, 3, 136, 6,
171 0, FB_VMODE_NONINTERLACED
173 /* 1024x768 @ 75Hz */
174 NULL, 75, 1024, 768, KHZ2PICOS(78750),
175 176, 16, 28, 1, 96, 3,
176 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
178 /* 1024x768 @ 85Hz */
179 NULL, 85, 1024, 768, KHZ2PICOS(94500),
180 208, 48, 36, 1, 96, 3,
181 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
183 /* 1152x864 @ 75Hz */
184 NULL, 75, 1152, 864, KHZ2PICOS(108000),
185 256, 64, 32, 1, 128, 3,
186 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
188 /* 1280x960 @ 60Hz */
189 NULL, 60, 1280, 960, KHZ2PICOS(108000),
190 312, 96, 36, 1, 112, 3,
191 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
193 /* 1280x960 @ 85Hz */
194 NULL, 85, 1280, 960, KHZ2PICOS(148500),
195 224, 64, 47, 1, 160, 3,
196 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
198 /* 1280x1024 @ 60Hz */
199 NULL, 60, 1280, 1024, KHZ2PICOS(108000),
200 248, 48, 38, 1, 112, 3,
201 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
203 /* 1280x1024 @ 75Hz */
204 NULL, 75, 1280, 1024, KHZ2PICOS(135000),
205 248, 16, 38, 1, 144, 3,
206 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
208 /* 1280x1024 @ 85Hz */
209 NULL, 85, 1280, 1024, KHZ2PICOS(157500),
210 224, 64, 44, 1, 160, 3,
211 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
213 /* 1600x1200 @ 60Hz */
214 NULL, 60, 1600, 1200, KHZ2PICOS(162000),
215 304, 64, 46, 1, 192, 3,
216 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
218 /* 1600x1200 @ 65Hz */
219 NULL, 65, 1600, 1200, KHZ2PICOS(175500),
220 304, 64, 46, 1, 192, 3,
221 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
223 /* 1600x1200 @ 70Hz */
224 NULL, 70, 1600, 1200, KHZ2PICOS(189000),
225 304, 64, 46, 1, 192, 3,
226 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
228 /* 1600x1200 @ 75Hz */
229 NULL, 75, 1600, 1200, KHZ2PICOS(202500),
230 304, 64, 46, 1, 192, 3,
231 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
233 /* 1600x1200 @ 85Hz */
234 NULL, 85, 1600, 1200, KHZ2PICOS(229500),
235 304, 64, 46, 1, 192, 3,
236 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
238 /* 1792x1344 @ 60Hz */
239 NULL, 60, 1792, 1344, KHZ2PICOS(204750),
240 328, 128, 46, 1, 200, 3,
241 FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
243 /* 1792x1344 @ 75Hz */
244 NULL, 75, 1792, 1344, KHZ2PICOS(261000),
245 352, 96, 69, 1, 216, 3,
246 FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
248 /* 1856x1392 @ 60Hz */
249 NULL, 60, 1856, 1392, KHZ2PICOS(218250),
250 352, 96, 43, 1, 224, 3,
251 FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
253 /* 1856x1392 @ 75Hz */
254 NULL, 75, 1856, 1392, KHZ2PICOS(288000),
255 352, 128, 104, 1, 224, 3,
256 FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
258 /* 1920x1440 @ 60Hz */
259 NULL, 60, 1920, 1440, KHZ2PICOS(234000),
260 344, 128, 56, 1, 208, 3,
261 FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
263 /* 1920x1440 @ 75Hz */
264 NULL, 75, 1920, 1440, KHZ2PICOS(297000),
265 352, 144, 56, 1, 224, 3,
266 FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
269 #define NUM_TOTAL_MODES ARRAY_SIZE(kyro_modedb)
272 * This needs to be kept ordered corresponding to kyro_modedb.
312 int kyro_dev_video_mode_set(struct fb_info *info)
314 struct kyrofb_info *par = (struct kyrofb_info *)info->par;
316 /* Turn off display */
317 StopVTG(deviceInfo.pSTGReg);
318 DisableRamdacOutput(deviceInfo.pSTGReg);
320 /* Bring us out of VGA and into Hi-Res mode, if not already. */
321 DisableVGA(deviceInfo.pSTGReg);
323 if (InitialiseRamdac(deviceInfo.pSTGReg,
324 info->var.bits_per_pixel,
325 info->var.xres, info->var.yres,
326 par->HSP, par->VSP, &par->PIXCLK) < 0)
329 SetupVTG(deviceInfo.pSTGReg, par);
331 ResetOverlayRegisters(deviceInfo.pSTGReg);
333 /* Turn on display in new mode */
334 EnableRamdacOutput(deviceInfo.pSTGReg);
335 StartVTG(deviceInfo.pSTGReg);
337 deviceInfo.ulNextFreeVidMem = info->var.xres * info->var.yres *
338 info->var.bits_per_pixel;
339 deviceInfo.ulOverlayOffset = 0;
344 int kyro_dev_overlay_create(u32 ulWidth,
345 u32 ulHeight, int bLinear)
348 u32 stride, uvStride;
350 if (deviceInfo.ulOverlayOffset != 0)
352 * Can only create one overlay without resetting the card or
353 * changing display mode
357 ResetOverlayRegisters(deviceInfo.pSTGReg);
359 /* Overlays are addressed in multiples of 16bytes or 32bytes, so make
360 * sure the start offset is on an appropriate boundary.
362 offset = deviceInfo.ulNextFreeVidMem;
363 if ((offset & 0x1f) != 0) {
364 offset = (offset + 32L) & 0xffffffE0L;
367 if (CreateOverlaySurface(deviceInfo.pSTGReg, ulWidth, ulHeight,
368 bLinear, offset, &stride, &uvStride) < 0)
371 deviceInfo.ulOverlayOffset = offset;
372 deviceInfo.ulOverlayStride = stride;
373 deviceInfo.ulOverlayUVStride = uvStride;
374 deviceInfo.ulNextFreeVidMem = offset + (ulHeight * stride) + (ulHeight * 2 * uvStride);
376 SetOverlayBlendMode(deviceInfo.pSTGReg, GLOBAL_ALPHA, 0xf, 0x0);
381 int kyro_dev_overlay_viewport_set(u32 x, u32 y, u32 ulWidth, u32 ulHeight)
383 if (deviceInfo.ulOverlayOffset == 0)
384 /* probably haven't called CreateOverlay yet */
387 /* Stop Ramdac Output */
388 DisableRamdacOutput(deviceInfo.pSTGReg);
390 SetOverlayViewPort(deviceInfo.pSTGReg,
391 x, y, x + ulWidth - 1, y + ulHeight - 1);
393 EnableOverlayPlane(deviceInfo.pSTGReg);
394 /* Start Ramdac Output */
395 EnableRamdacOutput(deviceInfo.pSTGReg);
400 static inline unsigned long get_line_length(int x, int bpp)
402 return (unsigned long)((((x*bpp)+31)&~31) >> 3);
405 static int kyrofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
407 struct kyrofb_info *par = (struct kyrofb_info *)info->par;
409 if (var->bits_per_pixel != 16 && var->bits_per_pixel != 32) {
410 printk(KERN_WARNING "kyrofb: depth not supported: %u\n", var->bits_per_pixel);
414 switch (var->bits_per_pixel) {
416 var->red.offset = 11;
418 var->green.offset = 5;
419 var->green.length = 6;
420 var->blue.length = 5;
423 var->transp.offset = 24;
424 var->red.offset = 16;
425 var->green.offset = 8;
426 var->blue.offset = 0;
429 var->green.length = 8;
430 var->blue.length = 8;
431 var->transp.length = 8;
435 /* Height/Width of picture in mm */
436 var->height = var->width = -1;
438 /* Timing information. All values are in picoseconds */
440 /* par->PIXCLK is in 100Hz units. Convert to picoseconds -
441 * ensuring we do not exceed 32 bit precision
444 * XXX: Enabling this really screws over the pixclock value when we
445 * read it back with fbset. As such, leaving this commented out appears
446 * to do the right thing (at least for now) .. bearing in mind that we
447 * have infact already done the KHZ2PICOS conversion in both the modedb
448 * and kyro_var. -- PFM.
450 // var->pixclock = 1000000000 / (par->PIXCLK / 10);
452 /* the header file claims we should use picoseconds
453 * - nobody else does though, the all use pixels and lines
454 * of h and v sizes. Both options here.
458 * If we're being called by __fb_try_mode(), then we don't want to
459 * override any of the var settings that we've already parsed
460 * from our modedb. -- PFM.
462 if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_TEST)
465 var->left_margin = par->HBP;
466 var->hsync_len = par->HST;
467 var->right_margin = par->HFP;
469 var->upper_margin = par->VBP;
470 var->vsync_len = par->VST;
471 var->lower_margin = par->VFP;
474 var->sync |= FB_SYNC_HOR_HIGH_ACT;
476 var->sync |= FB_SYNC_VERT_HIGH_ACT;
481 static int kyrofb_set_par(struct fb_info *info)
483 struct kyrofb_info *par = (struct kyrofb_info *)info->par;
484 unsigned long lineclock;
485 unsigned long frameclock;
487 /* Actual resolution */
488 par->XRES = info->var.xres;
489 par->YRES = info->var.yres;
492 par->PIXDEPTH = info->var.bits_per_pixel;
495 /* time for a line in ns */
496 lineclock = (info->var.pixclock * (info->var.xres +
497 info->var.right_margin +
498 info->var.hsync_len +
499 info->var.left_margin)) / 1000;
502 /* time for a frame in ns (precision in 32bpp) */
503 frameclock = lineclock * (info->var.yres +
504 info->var.lower_margin +
505 info->var.vsync_len +
506 info->var.upper_margin);
508 /* Calculate refresh rate and horrizontal clocks */
509 par->VFREQ = (1000000000 + (frameclock / 2)) / frameclock;
510 par->HCLK = (1000000000 + (lineclock / 2)) / lineclock;
511 par->PIXCLK = ((1000000000 + (info->var.pixclock / 2))
512 / info->var.pixclock) * 10;
514 /* calculate horizontal timings */
515 par->HFP = info->var.right_margin;
516 par->HST = info->var.hsync_len;
517 par->HBP = info->var.left_margin;
518 par->HTot = par->XRES + par->HBP + par->HST + par->HFP;
520 /* calculate vertical timings */
521 par->VFP = info->var.lower_margin;
522 par->VST = info->var.vsync_len;
523 par->VBP = info->var.upper_margin;
524 par->VTot = par->YRES + par->VBP + par->VST + par->VFP;
526 par->HSP = (info->var.sync & FB_SYNC_HOR_HIGH_ACT) ? 1 : 0;
527 par->VSP = (info->var.sync & FB_SYNC_VERT_HIGH_ACT) ? 1 : 0;
529 kyro_dev_video_mode_set(info);
531 /* length of a line in bytes */
532 info->fix.line_length = get_line_length(par->XRES, par->PIXDEPTH);
533 info->fix.visual = FB_VISUAL_TRUECOLOR;
538 static int kyrofb_setcolreg(u_int regno, u_int red, u_int green,
539 u_int blue, u_int transp, struct fb_info *info)
542 return 1; /* Invalid register */
545 switch (info->var.bits_per_pixel) {
547 ((u16*)(info->pseudo_palette))[regno] =
549 ((green & 0xfc00) >> 5) |
550 ((blue & 0xf800) >> 11);
553 red >>= 8; green >>= 8; blue >>= 8; transp >>= 8;
554 ((u32*)(info->pseudo_palette))[regno] =
555 (transp << 24) | (red << 16) | (green << 8) | blue;
563 int __init kyrofb_setup(char *options)
567 if (!options || !*options)
570 while ((this_opt = strsep(&options, ","))) {
573 if (strcmp(this_opt, "nopan") == 0) {
575 } else if (strcmp(this_opt, "nowrap") == 0) {
578 } else if (strcmp(this_opt, "nomtrr") == 0) {
582 mode_option = this_opt;
589 static int kyrofb_ioctl(struct inode *inode, struct file *file,
590 unsigned int cmd, unsigned long arg,
591 struct fb_info *info)
593 overlay_create ol_create;
594 overlay_viewport_set ol_viewport_set;
597 case KYRO_IOCTL_OVERLAY_CREATE:
598 copy_from_user((void *) &ol_create, (void *) arg,
599 sizeof(overlay_create));
601 if (kyro_dev_overlay_create(ol_create.ulWidth,
602 ol_create.ulHeight, 0) < 0) {
603 printk(KERN_ERR "Kyro FB: failed to create overlay surface.\n");
608 case KYRO_IOCTL_OVERLAY_VIEWPORT_SET:
609 copy_from_user((void *) &ol_viewport_set, (void *) arg,
610 sizeof(overlay_viewport_set));
612 if (kyro_dev_overlay_viewport_set(ol_viewport_set.xOrgin,
613 ol_viewport_set.yOrgin,
614 ol_viewport_set.xSize,
615 ol_viewport_set.ySize) != 0)
617 printk(KERN_ERR "Kyro FB: failed to create overlay viewport.\n");
621 case KYRO_IOCTL_SET_VIDEO_MODE:
623 printk(KERN_ERR "Kyro FB: KYRO_IOCTL_SET_VIDEO_MODE is"
624 "obsolete, use the appropriate fb_ioctl()"
625 "command instead.\n");
629 case KYRO_IOCTL_UVSTRIDE:
630 copy_to_user((void *)arg, (void *)&deviceInfo.ulOverlayUVStride, sizeof(unsigned long));
632 case KYRO_IOCTL_STRIDE:
633 copy_to_user((void *)arg, (void *)&deviceInfo.ulOverlayStride, sizeof(unsigned long));
635 case KYRO_IOCTL_OVERLAY_OFFSET:
636 copy_to_user((void *)arg, (void *)&deviceInfo.ulOverlayOffset, sizeof(unsigned long));
643 static struct pci_device_id kyrofb_pci_tbl[] = {
644 { PCI_VENDOR_ID_ST, PCI_DEVICE_ID_STG4000,
645 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
649 MODULE_DEVICE_TABLE(pci, kyrofb_pci_tbl);
651 static struct pci_driver kyrofb_pci_driver = {
653 .id_table = kyrofb_pci_tbl,
654 .probe = kyrofb_probe,
655 .remove = __devexit_p(kyrofb_remove),
658 static struct fb_ops kyrofb_ops = {
659 .owner = THIS_MODULE,
660 .fb_check_var = kyrofb_check_var,
661 .fb_set_par = kyrofb_set_par,
662 .fb_setcolreg = kyrofb_setcolreg,
663 .fb_ioctl = kyrofb_ioctl,
664 .fb_fillrect = cfb_fillrect,
665 .fb_copyarea = cfb_copyarea,
666 .fb_imageblit = cfb_imageblit,
667 .fb_cursor = soft_cursor,
670 static int __devinit kyrofb_probe(struct pci_dev *pdev,
671 const struct pci_device_id *ent)
673 struct fb_info *info;
677 if ((err = pci_enable_device(pdev))) {
678 printk(KERN_WARNING "kyrofb: Can't enable pdev: %d\n", err);
682 size = sizeof(struct fb_info) + sizeof(struct kyrofb_info) + 16 * sizeof(u32);
683 info = kmalloc(size, GFP_KERNEL);
687 memset(info, 0, size);
689 currentpar = (struct kyrofb_info *)(info + 1);
691 kyro_fix.smem_start = pci_resource_start(pdev, 0);
692 kyro_fix.smem_len = pci_resource_len(pdev, 0);
693 kyro_fix.mmio_start = pci_resource_start(pdev, 1);
694 kyro_fix.mmio_len = pci_resource_len(pdev, 1);
696 currentpar->regbase = deviceInfo.pSTGReg =
697 ioremap_nocache(kyro_fix.mmio_start, kyro_fix.mmio_len);
699 info->screen_base = ioremap_nocache(kyro_fix.smem_start,
704 currentpar->mtrr_handle =
705 mtrr_add(kyro_fix.smem_start,
707 MTRR_TYPE_WRCOMB, 1);
710 kyro_fix.ypanstep = nopan ? 0 : 1;
711 kyro_fix.ywrapstep = nowrap ? 0 : 1;
713 info->fbops = &kyrofb_ops;
714 info->fix = kyro_fix;
715 info->par = currentpar;
716 info->pseudo_palette = (void *)(currentpar + 1);
717 info->flags = FBINFO_FLAG_DEFAULT;
719 SetCoreClockPLL(deviceInfo.pSTGReg, pdev);
721 deviceInfo.ulNextFreeVidMem = 0;
722 deviceInfo.ulOverlayOffset = 0;
724 /* This should give a reasonable default video mode */
726 if (!fb_find_mode(&info->var, info, mode_option, kyro_modedb,
727 NUM_TOTAL_MODES, &kyro_modedb[VMODE_1024_768_75], 32))
729 info->var = kyro_var;
731 fb_alloc_cmap(&info->cmap, 256, 0);
733 kyrofb_set_par(info);
734 kyrofb_check_var(&info->var, info);
736 size = get_line_length(info->var.xres_virtual,
737 info->var.bits_per_pixel);
738 size *= info->var.yres_virtual;
740 memset_io((unsigned long)info->screen_base, 0, size);
742 if (register_framebuffer(info) < 0)
745 printk("fb%d: %s frame buffer device, at %dx%d@%d using %ldk/%ldk of VRAM\n",
746 info->node, info->fix.id, info->var.xres,
747 info->var.yres, info->var.bits_per_pixel, size >> 10,
748 (unsigned long)info->fix.smem_len >> 10);
750 pci_set_drvdata(pdev, info);
755 iounmap(currentpar->regbase);
756 iounmap(info->screen_base);
762 static void __devexit kyrofb_remove(struct pci_dev *pdev)
764 struct fb_info *info = pci_get_drvdata(pdev);
765 struct kyrofb_info *par = (struct kyrofb_info *)info->par;
767 /* Reset the board */
768 StopVTG(deviceInfo.pSTGReg);
769 DisableRamdacOutput(deviceInfo.pSTGReg);
771 /* Sync up the PLL */
772 SetCoreClockPLL(deviceInfo.pSTGReg, pdev);
774 deviceInfo.ulNextFreeVidMem = 0;
775 deviceInfo.ulOverlayOffset = 0;
777 iounmap(info->screen_base);
778 iounmap(par->regbase);
781 if (par->mtrr_handle)
782 mtrr_del(par->mtrr_handle,
783 info->fix.smem_start,
787 unregister_framebuffer(info);
788 pci_set_drvdata(pdev, NULL);
792 int __init kyrofb_init(void)
794 return pci_module_init(&kyrofb_pci_driver);
797 static void __exit kyrofb_exit(void)
799 pci_unregister_driver(&kyrofb_pci_driver);
803 module_init(kyrofb_init);
804 module_exit(kyrofb_exit);
807 MODULE_AUTHOR("STMicroelectronics; Paul Mundt <lethal@linux-sh.org>");
808 MODULE_LICENSE("GPL");