37 #include <linux/module.h>
38 #include <linux/kernel.h>
39 #include <linux/errno.h>
40 #include <linux/string.h>
45 #include <asm/pgtable.h>
51 #include <linux/pci.h>
56 #ifdef CONFIG_PPC_PREP
57 #include <asm/machdep.h>
58 #define isPReP machine_is(prep)
76 #ifndef CIRRUSFB_NDEBUG
77 #define assert(expr) \
79 printk("Assertion failed! %s,%s,%s,line=%d\n", \
80 #expr, __FILE__, __func__, __LINE__); \
86 #define MB_ (1024 * 1024)
117 static const struct cirrusfb_board_info_rec {
124 bool scrn_start_bit19 : 1;
128 unsigned char sr07_1bpp;
129 unsigned char sr07_1bpp_mux;
130 unsigned char sr07_8bpp;
131 unsigned char sr07_8bpp_mux;
134 } cirrusfb_board_info[] = {
140 135100, 135100, 85500, 85500, 0
144 .scrn_start_bit19 =
true,
147 .sr07_1bpp_mux = 0xF6,
149 .sr07_8bpp_mux = 0xF7,
153 .name =
"CL Piccolo",
156 90000, 90000, 90000, 90000, 90000
160 .scrn_start_bit19 =
false,
167 .name =
"CL Picasso",
170 90000, 90000, 90000, 90000, 90000
174 .scrn_start_bit19 =
false,
181 .name =
"CL Spectrum",
184 90000, 90000, 90000, 90000, 90000
188 .scrn_start_bit19 =
false,
195 .name =
"CL Picasso4",
197 135100, 135100, 85500, 85500, 0
201 .scrn_start_bit19 =
true,
204 .sr07_1bpp_mux = 0xA6,
206 .sr07_8bpp_mux = 0xA7,
213 85500, 85500, 50000, 28500, 0
217 .scrn_start_bit19 =
true,
220 .sr07_1bpp_mux = 0xA6,
222 .sr07_8bpp_mux = 0xA7,
228 135100, 200000, 200000, 135100, 135100
232 .scrn_start_bit19 =
true,
242 170000, 170000, 170000, 170000, 135100,
246 .scrn_start_bit19 =
true,
249 .name =
"CL Laguna AGP",
252 170000, 250000, 170000, 170000, 135100,
256 .scrn_start_bit19 =
true,
261 #define CHIP(id, btype) \
262 { PCI_VENDOR_ID_CIRRUS, id, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (btype) }
298 static const struct zorrocl zcl_piccolo __devinitconst = {
303 static const struct zorrocl zcl_picasso __devinitconst = {
308 static const struct zorrocl zcl_spectrum __devinitconst = {
313 static const struct zorrocl zcl_picasso4_z3 __devinitconst = {
315 .regoffset = 0x00600000,
317 .ramoffset = 0x01000000,
320 static const struct zorrocl zcl_picasso4_z2 __devinitconst = {
322 .regoffset = 0x10000,
328 static const struct zorro_device_id cirrusfb_zorro_table[] __devinitconst = {
331 .driver_data = (
unsigned long)&zcl_sd64,
334 .driver_data = (
unsigned long)&zcl_piccolo,
337 .driver_data = (
unsigned long)&zcl_picasso,
340 .driver_data = (
unsigned long)&zcl_spectrum,
343 .driver_data = (
unsigned long)&zcl_picasso4_z3,
346 .driver_data = (
unsigned long)&zcl_picasso4_z2,
353 #ifdef CIRRUSFB_DEBUG
354 enum cirrusfb_dbg_reg_class {
376 static char *mode_option __devinitdata =
"640x480@60";
387 static void switch_monitor(
struct cirrusfb_info *cinfo,
int on);
389 int regnum,
unsigned char val);
390 static unsigned char RGen(
const struct cirrusfb_info *cinfo,
int regnum);
395 static void WClut(
struct cirrusfb_info *cinfo,
unsigned char regnum,
396 unsigned char red,
unsigned char green,
unsigned char blue);
398 static void RClut(
struct cirrusfb_info *cinfo,
unsigned char regnum,
399 unsigned char *
red,
unsigned char *
green,
400 unsigned char *
blue);
402 static void cirrusfb_WaitBLT(
u8 __iomem *regbase);
411 u32 fg_color,
u32 bg_color,
414 static void bestclock(
long freq,
int *nom,
int *
den,
int *
div);
416 #ifdef CIRRUSFB_DEBUG
418 static void cirrusfb_dbg_print_regs(
struct fb_info *
info,
420 enum cirrusfb_dbg_reg_class
reg_class, ...);
427 static inline int is_laguna(
const struct cirrusfb_info *cinfo)
432 static int opencount;
437 if (opencount++ == 0)
438 switch_monitor(info->
par, 1);
443 static int cirrusfb_release(
struct fb_info *info,
int user)
445 if (--opencount == 0)
446 switch_monitor(info->
par, 0);
455 static int cirrusfb_check_mclk(
struct fb_info *info,
long freq)
461 mclk = (14318 *
mclk) >> 3;
468 if (
abs(freq - mclk) < 250) {
471 }
else if (
abs(freq - (mclk / 2)) < 250) {
492 maxclock = cirrusfb_board_info[cinfo->
btype].maxclock[maxclockidx];
497 if (freq > maxclock) {
499 "Frequency greater than maxclock (%ld kHz)\n",
508 switch (cinfo->
btype) {
562 var->
green.offset = -3;
563 var->
blue.offset = 8;
565 var->
red.offset = 11;
566 var->
green.offset = 5;
567 var->
blue.offset = 0;
570 var->
green.length = 6;
571 var->
blue.length = 5;
577 var->
green.offset = 8;
578 var->
blue.offset = 16;
580 var->
red.offset = 16;
581 var->
green.offset = 8;
582 var->
blue.offset = 0;
585 var->
green.length = 8;
586 var->
blue.length = 8;
602 "virtual resolution set to maximum of %dx%d\n",
610 "virtual resolution too high to fit into video memory!\n",
628 var->
green.msb_right =
629 var->
blue.msb_right =
632 var->
transp.msb_right = 0;
638 yres = (yres + 1) / 2;
642 "special treatment required! (TODO)\n");
646 if (cirrusfb_check_pixclock(var, info))
649 if (!is_laguna(cinfo))
655 static void cirrusfb_set_mclk_as_source(
const struct fb_info *info,
int div)
658 unsigned char old1f, old1e;
665 (div == 2) ?
"MCLK/2" :
"MCLK");
681 static int cirrusfb_set_par_foo(
struct fb_info *info)
688 const struct cirrusfb_board_info_rec *
bi;
689 int hdispend, hsyncstart, hsyncend, htotal;
690 int yres, vdispend, vsyncstart, vsyncend, vtotal;
720 bi = &cirrusfb_board_info[cinfo->
btype];
725 hdispend = var->
xres / 8;
726 hsyncstart = hsyncstart / 8;
727 hsyncend = hsyncend / 8;
729 vdispend = var->
yres;
740 vdispend = (vdispend + 1) / 2;
741 vsyncstart = (vsyncstart + 1) / 2;
742 vsyncend = (vsyncend + 1) / 2;
743 vtotal = (vtotal + 1) / 2;
786 128 + ((htotal + 5) % 32));
792 if ((htotal + 5) & 32)
805 if (vsyncstart & 256)
807 if ((vdispend + 1) & 256)
813 if (vsyncstart & 512)
819 if ((vdispend + 1) & 512)
847 if ((htotal + 5) & 64)
849 if ((htotal + 5) & 128)
868 bestclock(freq, &nom, &den, &div);
870 dev_dbg(info->
device,
"VCLK freq: %ld kHz nom: %d den: %d div: %d\n",
871 freq, nom, den, div);
883 int divMCLK = cirrusfb_check_mclk(info, freq);
886 cirrusfb_set_mclk_as_source(info, divMCLK);
888 if (is_laguna(cinfo)) {
891 unsigned short tile_control;
895 tile_control &= ~0x80;
918 if (is_laguna(cinfo)) {
968 switch (cinfo->
btype) {
978 bi->sr07_1bpp_mux : bi->sr07_1bpp);
984 vga_rseq(regbase,
CL_SEQR7) & ~0x01);
993 switch (cinfo->
btype) {
1041 dev_dbg(info->
device,
"preparing for 8 bit deep display\n");
1042 switch (cinfo->
btype) {
1052 bi->sr07_8bpp_mux : bi->sr07_8bpp);
1058 vga_rseq(regbase,
CL_SEQR7) | 0x01);
1067 switch (cinfo->
btype) {
1110 dev_dbg(info->
device,
"preparing for 16 bit deep display\n");
1111 switch (cinfo->
btype) {
1141 vga_rseq(regbase,
CL_SEQR7) & ~0x01);
1155 WHDR(cinfo, cinfo->
doubleVCLK ? 0xe1 : 0xc1);
1156 #elif defined(CONFIG_ZORRO)
1169 dev_dbg(info->
device,
"preparing for 24 bit deep display\n");
1170 switch (cinfo->
btype) {
1199 vga_rseq(regbase,
CL_SEQR7) & ~0x01);
1224 "What's this? requested color depth == %d.\n",
1227 pitch = info->
fix.line_length >> 3;
1237 if (cirrusfb_board_info[cinfo->
btype].scrn_start_bit19)
1238 vga_wcrt(regbase,
CL_CRT1D, (pitch >> 9) & 1);
1240 if (is_laguna(cinfo)) {
1242 if ((htotal + 5) & 256)
1246 if (hsyncstart & 256)
1250 if (vdispend & 1024)
1252 if (vsyncstart & 1024)
1260 vga_wattr(regbase,
CL_AR33, 0);
1266 if (is_laguna(cinfo)) {
1284 #ifdef CIRRUSFB_DEBUG
1285 cirrusfb_dbg_reg_dump(info,
NULL);
1293 static int cirrusfb_set_par(
struct fb_info *info)
1295 cirrusfb_set_par_foo(info);
1296 return cirrusfb_set_par_foo(info);
1299 static int cirrusfb_setcolreg(
unsigned regno,
unsigned red,
unsigned green,
1310 red >>= (16 - info->
var.red.length);
1311 green >>= (16 - info->
var.green.length);
1312 blue >>= (16 - info->
var.blue.length);
1316 v = (red << info->
var.red.offset) |
1317 (green << info->
var.green.offset) |
1318 (blue << info->
var.blue.offset);
1324 if (info->
var.bits_per_pixel == 8)
1325 WClut(cinfo, regno, red >> 10, green >> 10, blue >> 10);
1341 unsigned char tmp, xpix;
1349 xoffset = var->
xoffset * info->
var.bits_per_pixel / 8;
1351 base = var->
yoffset * info->
fix.line_length + xoffset;
1353 if (info->
var.bits_per_pixel == 1) {
1358 xpix = (
unsigned char) ((xoffset % 4) * 2);
1361 if (!is_laguna(cinfo))
1362 cirrusfb_WaitBLT(cinfo->
regbase);
1381 if (cirrusfb_board_info[cinfo->
btype].scrn_start_bit19) {
1383 if (is_laguna(cinfo))
1384 tmp = (tmp & ~0x18) | ((base >> 16) & 0x18);
1386 tmp = (tmp & ~0x80) | ((base >> 12) & 0x80);
1394 if (info->
var.bits_per_pixel == 1)
1417 dev_dbg(info->
device,
"ENTER, blank mode = %d\n", blank_mode);
1420 current_mode == blank_mode) {
1437 switch (blank_mode) {
1469 static void init_vgachip(
struct fb_info *info)
1472 const struct cirrusfb_board_info_rec *
bi;
1476 bi = &cirrusfb_board_info[cinfo->
btype];
1479 switch (cinfo->
btype) {
1547 switch (cinfo->
btype) {
1689 static void switch_monitor(
struct cirrusfb_info *cinfo,
int on)
1692 static int IsOn = 0;
1701 if ((on && !IsOn) || (!on && IsOn))
1706 switch (cinfo->
btype) {
1708 WSFR(cinfo, cinfo->
SFR | 0x21);
1711 WSFR(cinfo, cinfo->
SFR | 0x28);
1719 switch (cinfo->
btype) {
1721 WSFR(cinfo, cinfo->
SFR & 0xde);
1724 WSFR(cinfo, cinfo->
SFR & 0xd7);
1740 static int cirrusfb_sync(
struct fb_info *info)
1744 if (!is_laguna(cinfo)) {
1751 static void cirrusfb_fillrect(
struct fb_info *info,
1757 int m = info->
var.bits_per_pixel;
1768 vxres = info->
var.xres_virtual;
1769 vyres = info->
var.yres_virtual;
1773 if (!modded.width || !modded.height ||
1774 modded.dx >= vxres || modded.dy >= vyres)
1777 if (modded.dx + modded.width > vxres)
1778 modded.width = vxres - modded.dx;
1779 if (modded.dy + modded.height > vyres)
1780 modded.height = vyres - modded.dy;
1782 cirrusfb_RectFill(cinfo->
regbase,
1783 info->
var.bits_per_pixel,
1784 (region->
dx * m) / 8, region->
dy,
1787 info->
fix.line_length, 0x40);
1790 static void cirrusfb_copyarea(
struct fb_info *info,
1796 int m = info->
var.bits_per_pixel;
1805 vxres = info->
var.xres_virtual;
1806 vyres = info->
var.yres_virtual;
1809 if (!modded.width || !modded.height ||
1810 modded.sx >= vxres || modded.sy >= vyres ||
1811 modded.dx >= vxres || modded.dy >= vyres)
1814 if (modded.sx + modded.width > vxres)
1815 modded.width = vxres - modded.sx;
1816 if (modded.dx + modded.width > vxres)
1817 modded.width = vxres - modded.dx;
1818 if (modded.sy + modded.height > vyres)
1819 modded.height = vyres - modded.sy;
1820 if (modded.dy + modded.height > vyres)
1821 modded.height = vyres - modded.dy;
1823 cirrusfb_BitBLT(cinfo->
regbase, info->
var.bits_per_pixel,
1824 (area->
sx * m) / 8, area->
sy,
1825 (area->
dx * m) / 8, area->
dy,
1827 info->
fix.line_length);
1831 static void cirrusfb_imageblit(
struct fb_info *info,
1835 unsigned char op = (info->
var.bits_per_pixel == 24) ? 0
xc : 0x4;
1847 int m = info->
var.bits_per_pixel;
1850 if (info->
var.bits_per_pixel == 8) {
1857 if (info->
var.bits_per_pixel == 24) {
1859 cirrusfb_RectFill(cinfo->
regbase,
1860 info->
var.bits_per_pixel,
1861 (image->
dx * m) / 8, image->
dy,
1862 (image->
width * m) / 8,
1865 info->
fix.line_length, 0x40);
1867 cirrusfb_RectFill(cinfo->
regbase,
1868 info->
var.bits_per_pixel,
1869 (image->
dx * m) / 8, image->
dy,
1872 info->
fix.line_length, op);
1877 #ifdef CONFIG_PPC_PREP
1878 #define PREP_VIDEO_BASE ((volatile unsigned long) 0xC0000000)
1879 #define PREP_IO_BASE ((volatile unsigned char *) 0x80000000)
1880 static void get_prep_addrs(
unsigned long *
display,
unsigned long *
registers)
1882 *display = PREP_VIDEO_BASE;
1883 *registers = (
unsigned long) PREP_IO_BASE;
1889 static int release_io_ports;
1901 if (is_laguna(cinfo)) {
1902 unsigned char SR14 = vga_rseq(regbase,
CL_SEQR14);
1904 mem = ((SR14 & 7) + 1) << 20;
1906 unsigned char SRF = vga_rseq(regbase,
CL_SEQRF);
1907 switch ((SRF & 0x18)) {
1935 static void get_pci_addrs(
const struct pci_dev *pdev,
1958 static void cirrusfb_pci_unmap(
struct fb_info *info)
1969 if (release_io_ports)
1976 static void cirrusfb_zorro_unmap(
struct fb_info *info)
1979 struct zorro_dev *zdev = to_zorro_dev(info->
device);
1981 if (info->
fix.smem_start > 16 *
MB_)
1983 if (info->
fix.mmio_start > 16 *
MB_)
1986 zorro_release_device(zdev);
1991 static struct fb_ops cirrusfb_ops = {
1993 .fb_open = cirrusfb_open,
1994 .fb_release = cirrusfb_release,
1995 .fb_setcolreg = cirrusfb_setcolreg,
1996 .fb_check_var = cirrusfb_check_var,
1997 .fb_set_par = cirrusfb_set_par,
1998 .fb_pan_display = cirrusfb_pan_display,
1999 .fb_blank = cirrusfb_blank,
2000 .fb_fillrect = cirrusfb_fillrect,
2001 .fb_copyarea = cirrusfb_copyarea,
2002 .fb_sync = cirrusfb_sync,
2003 .fb_imageblit = cirrusfb_imageblit,
2018 if (noaccel || is_laguna(cinfo)) {
2024 info->
fbops = &cirrusfb_ops;
2035 sizeof(info->
fix.id));
2041 info->
fix.smem_len /= 4;
2042 info->
fix.type_aux = 0;
2043 info->
fix.xpanstep = 1;
2044 info->
fix.ypanstep = 1;
2045 info->
fix.ywrapstep = 0;
2048 info->
fix.mmio_len = 0;
2064 cirrusfb_set_fbinfo(info);
2072 goto err_dealloc_cmap;
2077 err = cirrusfb_check_var(&info->
var, info);
2081 "choking on default var... umm, no good.\n");
2082 goto err_dealloc_cmap;
2088 "could not register fb device; err = %d!\n", err);
2089 goto err_dealloc_cmap;
2103 switch_monitor(cinfo, 0);
2117 unsigned long board_addr, board_size;
2137 " Found PCI device, base address 0 is 0x%Lx, btype set to %d\n",
2140 (
unsigned long long)pdev->
resource[1].start);
2144 #ifdef CONFIG_PPC_PREP
2145 get_prep_addrs(&board_addr, &info->
fix.mmio_start);
2151 "Attempt to get PCI info for Cirrus Graphics Card\n");
2152 get_pci_addrs(pdev, &board_addr, &info->
fix.mmio_start);
2158 dev_dbg(info->
device,
"Board address: 0x%lx, register address: 0x%lx\n",
2159 board_addr, info->
fix.mmio_start);
2162 32 *
MB_ : cirrusfb_get_memsize(info, cinfo->
regbase);
2166 dev_err(info->
device,
"cannot reserve region 0x%lx, abort\n",
2168 goto err_release_fb;
2172 dev_err(info->
device,
"cannot reserve region 0x%lx, abort\n",
2175 goto err_release_regions;
2179 release_io_ports = 1;
2184 goto err_release_legacy;
2187 info->
fix.smem_start = board_addr;
2189 cinfo->
unmap = cirrusfb_pci_unmap;
2192 "Cirrus Logic chipset on PCI bus, RAM (%lu kB) at 0x%lx\n",
2194 pci_set_drvdata(pdev, info);
2196 ret = cirrusfb_register(info);
2200 pci_set_drvdata(pdev,
NULL);
2203 if (release_io_ports)
2207 err_release_regions:
2220 struct fb_info *info = pci_get_drvdata(pdev);
2222 cirrusfb_cleanup(info);
2225 static struct pci_driver cirrusfb_pci_driver = {
2227 .id_table = cirrusfb_pci_table,
2228 .probe = cirrusfb_pci_register,
2232 .suspend = cirrusfb_pci_suspend,
2233 .resume = cirrusfb_pci_resume,
2240 static int __devinit cirrusfb_zorro_register(
struct zorro_dev *z,
2245 const struct zorrocl *zcl;
2247 unsigned long regbase, ramsize, rambase;
2258 regbase = zorro_resource_start(z) + zcl->regoffset;
2259 ramsize = zcl->ramsize;
2261 rambase = zorro_resource_start(z) + zcl->ramoffset;
2262 if (zorro_resource_len(z) == 64 *
MB_) {
2264 rambase += zcl->ramoffset;
2268 if (!ram || !zorro_resource_len(ram)) {
2271 goto err_release_fb;
2273 rambase = zorro_resource_start(ram);
2274 ramsize = zorro_resource_len(ram);
2277 if (zorro_resource_start(ram) != rambase + ramsize) {
2279 "Skipping non-contiguous RAM at %pR\n",
2282 ramsize += zorro_resource_len(ram);
2288 "%s board detected, REG at 0x%lx, %lu MiB RAM at 0x%lx\n",
2289 cirrusfb_board_info[btype].name, regbase, ramsize /
MB_,
2292 if (!zorro_request_device(z,
"cirrusfb")) {
2293 dev_err(info->
device,
"Cannot reserve %pR\n", &z->resource);
2295 goto err_release_fb;
2299 cinfo->
btype = btype;
2301 info->
fix.mmio_start = regbase;
2307 goto err_release_dev;
2310 info->
fix.smem_start = rambase;
2320 cinfo->
unmap = cirrusfb_zorro_unmap;
2323 "Cirrus Logic chipset on Zorro bus, RAM (%lu MiB) at 0x%lx\n",
2324 ramsize /
MB_, rambase);
2327 if (cirrusfb_board_info[btype].init_sr1f)
2329 cirrusfb_board_info[btype].sr1f);
2331 error = cirrusfb_register(info);
2333 dev_err(info->
device,
"Failed to register device, error %d\n",
2338 zorro_set_drvdata(z, info);
2342 if (rambase > 16 *
MB_)
2346 if (regbase > 16 *
MB_)
2349 zorro_release_device(z);
2355 void __devexit cirrusfb_zorro_unregister(
struct zorro_dev *z)
2357 struct fb_info *info = zorro_get_drvdata(z);
2359 cirrusfb_cleanup(info);
2360 zorro_set_drvdata(z,
NULL);
2363 static struct zorro_driver cirrusfb_zorro_driver = {
2365 .id_table = cirrusfb_zorro_table,
2366 .probe = cirrusfb_zorro_register,
2376 if (!options || !*options)
2379 while ((this_opt =
strsep(&options,
",")) !=
NULL) {
2383 if (!
strcmp(this_opt,
"noaccel"))
2385 else if (!
strncmp(this_opt,
"mode:", 5))
2386 mode_option = this_opt + 5;
2388 mode_option = this_opt;
2402 static int __init cirrusfb_init(
void)
2411 cirrusfb_setup(option);
2418 error |= pci_register_driver(&cirrusfb_pci_driver);
2423 static void __exit cirrusfb_exit(
void)
2453 int regnum,
unsigned char val)
2455 unsigned long regofs = 0;
2465 vga_w(cinfo->
regbase, regofs + regnum, val);
2469 static unsigned char RGen(
const struct cirrusfb_info *cinfo,
int regnum)
2471 unsigned long regofs = 0;
2481 return vga_r(cinfo->
regbase, regofs + regnum);
2509 static void WHDR(
const struct cirrusfb_info *cinfo,
unsigned char val)
2511 unsigned char dummy;
2513 if (is_laguna(cinfo))
2551 static void WSFR(
struct cirrusfb_info *cinfo,
unsigned char val)
2561 static void WSFR2(
struct cirrusfb_info *cinfo,
unsigned char val)
2573 static void WClut(
struct cirrusfb_info *cinfo,
unsigned char regnum,
unsigned char red,
2574 unsigned char green,
unsigned char blue)
2587 vga_w(cinfo->
regbase, data, red);
2588 vga_w(cinfo->
regbase, data, green);
2589 vga_w(cinfo->
regbase, data, blue);
2591 vga_w(cinfo->
regbase, data, blue);
2592 vga_w(cinfo->
regbase, data, green);
2593 vga_w(cinfo->
regbase, data, red);
2599 static void RClut(
struct cirrusfb_info *cinfo,
unsigned char regnum,
unsigned char *red,
2600 unsigned char *green,
unsigned char *blue)
2610 *red = vga_r(cinfo->
regbase, data);
2611 *green = vga_r(cinfo->
regbase, data);
2612 *blue = vga_r(cinfo->
regbase, data);
2614 *blue = vga_r(cinfo->
regbase, data);
2615 *green = vga_r(cinfo->
regbase, data);
2616 *red = vga_r(cinfo->
regbase, data);
2628 static void cirrusfb_WaitBLT(
u8 __iomem *regbase)
2630 while (vga_rgfx(regbase,
CL_GR31) & 0x08)
2640 static void cirrusfb_set_blitter(
u8 __iomem *regbase,
2648 vga_wgfx(regbase,
CL_GR24, line_length & 0xff);
2650 vga_wgfx(regbase,
CL_GR25, line_length >> 8);
2652 vga_wgfx(regbase,
CL_GR26, line_length & 0xff);
2654 vga_wgfx(regbase,
CL_GR27, line_length >> 8);
2658 vga_wgfx(regbase,
CL_GR20, nwidth & 0xff);
2660 vga_wgfx(regbase,
CL_GR21, nwidth >> 8);
2664 vga_wgfx(regbase,
CL_GR22, nheight & 0xff);
2666 vga_wgfx(regbase,
CL_GR23, nheight >> 8);
2685 vga_wgfx(regbase,
CL_GR30, bltmode);
2688 vga_wgfx(regbase,
CL_GR32, 0x0d);
2691 vga_wgfx(regbase,
CL_GR31, 0x02);
2713 if (cury <= desty) {
2714 if (cury == desty) {
2722 nsrc = (cury * line_length) + curx;
2723 ndest = (desty * line_length) + destx;
2728 nsrc += nheight * line_length + nwidth;
2729 ndest += nheight * line_length + nwidth;
2732 cirrusfb_WaitBLT(regbase);
2734 cirrusfb_set_blitter(regbase, nwidth, nheight,
2735 nsrc, ndest, bltmode, line_length);
2744 static void cirrusfb_RectFill(
u8 __iomem *regbase,
int bits_per_pixel,
2749 u_long ndest = (y * line_length) + x;
2752 cirrusfb_WaitBLT(regbase);
2760 if (bits_per_pixel >= 16) {
2761 vga_wgfx(regbase,
CL_GR10, bg_color >> 8);
2762 vga_wgfx(regbase,
CL_GR11, fg_color >> 8);
2765 if (bits_per_pixel >= 24) {
2766 vga_wgfx(regbase,
CL_GR12, bg_color >> 16);
2767 vga_wgfx(regbase,
CL_GR13, fg_color >> 16);
2770 if (bits_per_pixel == 32) {
2771 vga_wgfx(regbase,
CL_GR14, bg_color >> 24);
2772 vga_wgfx(regbase,
CL_GR15, fg_color >> 24);
2775 cirrusfb_set_blitter(regbase, width - 1, height - 1,
2776 0, ndest, op | blitmode, line_length);
2783 static void bestclock(
long freq,
int *nom,
int *den,
int *div)
2801 for (n = 32; n < 128; n++) {
2804 d = (14318 *
n) / freq;
2805 if ((d >= 7) && (d <= 63)) {
2812 h = ((14318 *
n) / temp) >>
s;
2813 h = h > freq ? h - freq : freq -
h;
2822 if ((d >= 7) && (d <= 63)) {
2827 h = ((14318 *
n) / d) >>
s;
2828 h = h > freq ? h - freq : freq -
h;
2846 #ifdef CIRRUSFB_DEBUG
2859 static void cirrusfb_dbg_print_regs(
struct fb_info *info,
2861 enum cirrusfb_dbg_reg_class
reg_class, ...)
2864 unsigned char val = 0;
2870 name =
va_arg(list,
char *);
2871 while (name !=
NULL) {
2874 switch (reg_class) {
2876 val = vga_rcrt(regbase, (
unsigned char) reg);
2879 val = vga_rseq(regbase, (
unsigned char) reg);
2889 name =
va_arg(list,
char *);
2905 static void cirrusfb_dbg_reg_dump(
struct fb_info *info,
caddr_t regbase)
2909 cirrusfb_dbg_print_regs(info, regbase, CRT,
2963 cirrusfb_dbg_print_regs(info, regbase,
SEQ,