apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 1 | /* |
| 2 | * XGI 300/630/730/540/315/550/650/740 frame buffer driver |
| 3 | * for Linux kernels 2.4.x and 2.5.x |
| 4 | * |
| 5 | * 2D acceleration part |
| 6 | * |
| 7 | * Based on the X driver's XGI300_accel.c which is |
| 8 | * Copyright Xavier Ducoin <x.ducoin@lectra.com> |
| 9 | * Copyright 2002 by Thomas Winischhofer, Vienna, Austria |
| 10 | * and XGI310_accel.c which is |
| 11 | * Copyright 2002 by Thomas Winischhofer, Vienna, Austria |
| 12 | * |
| 13 | * Author: Thomas Winischhofer <thomas@winischhofer.net> |
| 14 | * (see http://www.winischhofer.net/ |
| 15 | * for more information and updates) |
| 16 | */ |
| 17 | |
| 18 | //#include <linux/config.h> |
| 19 | #include <linux/version.h> |
| 20 | #include <linux/module.h> |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/errno.h> |
| 23 | #include <linux/string.h> |
| 24 | #include <linux/mm.h> |
| 25 | #include <linux/tty.h> |
| 26 | #include <linux/slab.h> |
| 27 | #include <linux/delay.h> |
| 28 | #include <linux/fb.h> |
| 29 | #include <linux/console.h> |
| 30 | #include <linux/selection.h> |
| 31 | #include <linux/ioport.h> |
| 32 | #include <linux/init.h> |
| 33 | #include <linux/pci.h> |
| 34 | #include <linux/vt_kern.h> |
| 35 | #include <linux/capability.h> |
| 36 | #include <linux/fs.h> |
| 37 | #include <linux/agp_backend.h> |
| 38 | |
| 39 | #include <linux/types.h> |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 40 | #include <asm/io.h> |
| 41 | |
| 42 | #ifdef CONFIG_MTRR |
| 43 | #include <asm/mtrr.h> |
| 44 | #endif |
| 45 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 46 | #include "vgatypes.h" |
| 47 | #include "vb_struct.h" |
| 48 | #include "XGIfb.h" |
| 49 | #include "XGI_accel.h" |
| 50 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 51 | static const int XGIALUConv[] = |
| 52 | { |
| 53 | 0x00, /* dest = 0; 0, GXclear, 0 */ |
| 54 | 0x88, /* dest &= src; DSa, GXand, 0x1 */ |
| 55 | 0x44, /* dest = src & ~dest; SDna, GXandReverse, 0x2 */ |
| 56 | 0xCC, /* dest = src; S, GXcopy, 0x3 */ |
| 57 | 0x22, /* dest &= ~src; DSna, GXandInverted, 0x4 */ |
| 58 | 0xAA, /* dest = dest; D, GXnoop, 0x5 */ |
| 59 | 0x66, /* dest = ^src; DSx, GXxor, 0x6 */ |
| 60 | 0xEE, /* dest |= src; DSo, GXor, 0x7 */ |
| 61 | 0x11, /* dest = ~src & ~dest; DSon, GXnor, 0x8 */ |
| 62 | 0x99, /* dest ^= ~src ; DSxn, GXequiv, 0x9 */ |
| 63 | 0x55, /* dest = ~dest; Dn, GXInvert, 0xA */ |
| 64 | 0xDD, /* dest = src|~dest ; SDno, GXorReverse, 0xB */ |
| 65 | 0x33, /* dest = ~src; Sn, GXcopyInverted, 0xC */ |
| 66 | 0xBB, /* dest |= ~src; DSno, GXorInverted, 0xD */ |
| 67 | 0x77, /* dest = ~src|~dest; DSan, GXnand, 0xE */ |
| 68 | 0xFF, /* dest = 0xFF; 1, GXset, 0xF */ |
| 69 | }; |
| 70 | /* same ROP but with Pattern as Source */ |
| 71 | static const int XGIPatALUConv[] = |
| 72 | { |
| 73 | 0x00, /* dest = 0; 0, GXclear, 0 */ |
| 74 | 0xA0, /* dest &= src; DPa, GXand, 0x1 */ |
| 75 | 0x50, /* dest = src & ~dest; PDna, GXandReverse, 0x2 */ |
| 76 | 0xF0, /* dest = src; P, GXcopy, 0x3 */ |
| 77 | 0x0A, /* dest &= ~src; DPna, GXandInverted, 0x4 */ |
| 78 | 0xAA, /* dest = dest; D, GXnoop, 0x5 */ |
| 79 | 0x5A, /* dest = ^src; DPx, GXxor, 0x6 */ |
| 80 | 0xFA, /* dest |= src; DPo, GXor, 0x7 */ |
| 81 | 0x05, /* dest = ~src & ~dest; DPon, GXnor, 0x8 */ |
| 82 | 0xA5, /* dest ^= ~src ; DPxn, GXequiv, 0x9 */ |
| 83 | 0x55, /* dest = ~dest; Dn, GXInvert, 0xA */ |
| 84 | 0xF5, /* dest = src|~dest ; PDno, GXorReverse, 0xB */ |
| 85 | 0x0F, /* dest = ~src; Pn, GXcopyInverted, 0xC */ |
| 86 | 0xAF, /* dest |= ~src; DPno, GXorInverted, 0xD */ |
| 87 | 0x5F, /* dest = ~src|~dest; DPan, GXnand, 0xE */ |
| 88 | 0xFF, /* dest = 0xFF; 1, GXset, 0xF */ |
| 89 | }; |
| 90 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 91 | static const unsigned char myrops[] = { |
| 92 | 3, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 |
| 93 | }; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 94 | |
| 95 | /* 300 series */ |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 96 | static void |
| 97 | XGI310Sync(void) |
| 98 | { |
| 99 | XGI310Idle |
| 100 | } |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 101 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 102 | /* --------------------------------------------------------------------- */ |
| 103 | |
| 104 | /* The exported routines */ |
| 105 | |
| 106 | int XGIfb_initaccel(void) |
| 107 | { |
| 108 | #ifdef XGIFB_USE_SPINLOCKS |
| 109 | spin_lock_init(&xgi_video_info.lockaccel); |
| 110 | #endif |
| 111 | return(0); |
| 112 | } |
| 113 | |
| 114 | void XGIfb_syncaccel(void) |
| 115 | { |
| 116 | |
| 117 | XGI310Sync(); |
| 118 | |
| 119 | } |
| 120 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 121 | int fbcon_XGI_sync(struct fb_info *info) |
| 122 | { |
Javier Martinez Canillas | cfd6ea0 | 2011-02-21 10:09:05 +0100 | [diff] [blame] | 123 | return 0; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | void fbcon_XGI_fillrect(struct fb_info *info, const struct fb_fillrect *rect) |
| 127 | { |
Javier Martinez Canillas | cfd6ea0 | 2011-02-21 10:09:05 +0100 | [diff] [blame] | 128 | if (!rect->width || !rect->height) |
| 129 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 130 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 131 | cfb_fillrect(info, rect); |
| 132 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | void fbcon_XGI_copyarea(struct fb_info *info, const struct fb_copyarea *area) |
| 136 | { |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 137 | cfb_copyarea(info, area); |
| 138 | return; |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 139 | } |
| 140 | |
apatard@mandriva.com | d7636e0 | 2010-05-19 10:44:14 +0200 | [diff] [blame] | 141 | |
| 142 | |