Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Permedia2 framebuffer driver. |
| 3 | * |
| 4 | * 2.5/2.6 driver: |
| 5 | * Copyright (c) 2003 Jim Hague (jim.hague@acm.org) |
| 6 | * |
| 7 | * based on 2.4 driver: |
| 8 | * Copyright (c) 1998-2000 Ilario Nardinocchi (nardinoc@CS.UniBO.IT) |
| 9 | * Copyright (c) 1999 Jakub Jelinek (jakub@redhat.com) |
| 10 | * |
| 11 | * and additional input from James Simmon's port of Hannu Mallat's tdfx |
| 12 | * driver. |
| 13 | * |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 14 | * I have a Creative Graphics Blaster Exxtreme card - pm2fb on x86. I |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | * have no access to other pm2fb implementations. Sparc (and thus |
| 16 | * hopefully other big-endian) devices now work, thanks to a lot of |
| 17 | * testing work by Ron Murray. I have no access to CVision hardware, |
| 18 | * and therefore for now I am omitting the CVision code. |
| 19 | * |
| 20 | * Multiple boards support has been on the TODO list for ages. |
| 21 | * Don't expect this to change. |
| 22 | * |
| 23 | * This file is subject to the terms and conditions of the GNU General Public |
| 24 | * License. See the file COPYING in the main directory of this archive for |
| 25 | * more details. |
| 26 | * |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 27 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | */ |
| 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <linux/module.h> |
| 31 | #include <linux/moduleparam.h> |
| 32 | #include <linux/kernel.h> |
| 33 | #include <linux/errno.h> |
| 34 | #include <linux/string.h> |
| 35 | #include <linux/mm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <linux/slab.h> |
| 37 | #include <linux/delay.h> |
| 38 | #include <linux/fb.h> |
| 39 | #include <linux/init.h> |
| 40 | #include <linux/pci.h> |
Krzysztof Helt | d5383fc | 2007-10-16 01:28:33 -0700 | [diff] [blame] | 41 | #ifdef CONFIG_MTRR |
| 42 | #include <asm/mtrr.h> |
| 43 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | #include <video/permedia2.h> |
| 46 | #include <video/cvisionppc.h> |
| 47 | |
| 48 | #if !defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN) |
| 49 | #error "The endianness of the target host has not been defined." |
| 50 | #endif |
| 51 | |
| 52 | #if !defined(CONFIG_PCI) |
| 53 | #error "Only generic PCI cards supported." |
| 54 | #endif |
| 55 | |
| 56 | #undef PM2FB_MASTER_DEBUG |
| 57 | #ifdef PM2FB_MASTER_DEBUG |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 58 | #define DPRINTK(a, b...) \ |
| 59 | printk(KERN_DEBUG "pm2fb: %s: " a, __FUNCTION__ , ## b) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | #else |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 61 | #define DPRINTK(a, b...) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | #endif |
| 63 | |
Krzysztof Helt | 91b3a6f | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 64 | #define PM2_PIXMAP_SIZE (1600 * 4) |
| 65 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | /* |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 67 | * Driver data |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | */ |
Krzysztof Helt | 1ddc28d | 2007-10-16 01:29:16 -0700 | [diff] [blame] | 69 | static int hwcursor = 1; |
Krzysztof Helt | 5eb81e80 | 2008-04-28 02:15:05 -0700 | [diff] [blame] | 70 | static char *mode_option __devinitdata; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
| 72 | /* |
| 73 | * The XFree GLINT driver will (I think to implement hardware cursor |
| 74 | * support on TVP4010 and similar where there is no RAMDAC - see |
| 75 | * comment in set_video) always request +ve sync regardless of what |
| 76 | * the mode requires. This screws me because I have a Sun |
| 77 | * fixed-frequency monitor which absolutely has to have -ve sync. So |
| 78 | * these flags allow the user to specify that requests for +ve sync |
| 79 | * should be silently turned in -ve sync. |
| 80 | */ |
Darren Jenkins | c16c556 | 2006-04-20 02:43:13 -0700 | [diff] [blame] | 81 | static int lowhsync; |
| 82 | static int lowvsync; |
Krzysztof Helt | d5383fc | 2007-10-16 01:28:33 -0700 | [diff] [blame] | 83 | static int noaccel __devinitdata; |
| 84 | /* mtrr option */ |
| 85 | #ifdef CONFIG_MTRR |
| 86 | static int nomtrr __devinitdata; |
| 87 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
| 89 | /* |
| 90 | * The hardware state of the graphics card that isn't part of the |
| 91 | * screeninfo. |
| 92 | */ |
| 93 | struct pm2fb_par |
| 94 | { |
| 95 | pm2type_t type; /* Board type */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | unsigned char __iomem *v_regs;/* virtual address of p_regs */ |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 97 | u32 memclock; /* memclock */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | u32 video; /* video flags before blanking */ |
| 99 | u32 mem_config; /* MemConfig reg at probe */ |
| 100 | u32 mem_control; /* MemControl reg at probe */ |
| 101 | u32 boot_address; /* BootAddress reg at probe */ |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 102 | u32 palette[16]; |
Krzysztof Helt | d5383fc | 2007-10-16 01:28:33 -0700 | [diff] [blame] | 103 | int mtrr_handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | /* |
| 107 | * Here we define the default structs fb_fix_screeninfo and fb_var_screeninfo |
| 108 | * if we don't use modedb. |
| 109 | */ |
| 110 | static struct fb_fix_screeninfo pm2fb_fix __devinitdata = { |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 111 | .id = "", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | .type = FB_TYPE_PACKED_PIXELS, |
| 113 | .visual = FB_VISUAL_PSEUDOCOLOR, |
| 114 | .xpanstep = 1, |
| 115 | .ypanstep = 1, |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 116 | .ywrapstep = 0, |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 117 | .accel = FB_ACCEL_3DLABS_PERMEDIA2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | }; |
| 119 | |
| 120 | /* |
| 121 | * Default video mode. In case the modedb doesn't work. |
| 122 | */ |
| 123 | static struct fb_var_screeninfo pm2fb_var __devinitdata = { |
| 124 | /* "640x480, 8 bpp @ 60 Hz */ |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 125 | .xres = 640, |
| 126 | .yres = 480, |
| 127 | .xres_virtual = 640, |
| 128 | .yres_virtual = 480, |
| 129 | .bits_per_pixel = 8, |
| 130 | .red = {0, 8, 0}, |
| 131 | .blue = {0, 8, 0}, |
| 132 | .green = {0, 8, 0}, |
| 133 | .activate = FB_ACTIVATE_NOW, |
| 134 | .height = -1, |
| 135 | .width = -1, |
| 136 | .accel_flags = 0, |
| 137 | .pixclock = 39721, |
| 138 | .left_margin = 40, |
| 139 | .right_margin = 24, |
| 140 | .upper_margin = 32, |
| 141 | .lower_margin = 11, |
| 142 | .hsync_len = 96, |
| 143 | .vsync_len = 2, |
| 144 | .vmode = FB_VMODE_NONINTERLACED |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | }; |
| 146 | |
| 147 | /* |
| 148 | * Utility functions |
| 149 | */ |
| 150 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 151 | static inline u32 pm2_RD(struct pm2fb_par *p, s32 off) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | { |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 153 | return fb_readl(p->v_regs + off); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | } |
| 155 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 156 | static inline void pm2_WR(struct pm2fb_par *p, s32 off, u32 v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | { |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 158 | fb_writel(v, p->v_regs + off); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | } |
| 160 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 161 | static inline u32 pm2_RDAC_RD(struct pm2fb_par *p, s32 idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | { |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 163 | pm2_WR(p, PM2R_RD_PALETTE_WRITE_ADDRESS, idx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | mb(); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 165 | return pm2_RD(p, PM2R_RD_INDEXED_DATA); |
| 166 | } |
| 167 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 168 | static inline u32 pm2v_RDAC_RD(struct pm2fb_par *p, s32 idx) |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 169 | { |
| 170 | pm2_WR(p, PM2VR_RD_INDEX_LOW, idx & 0xff); |
| 171 | mb(); |
| 172 | return pm2_RD(p, PM2VR_RD_INDEXED_DATA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | } |
| 174 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 175 | static inline void pm2_RDAC_WR(struct pm2fb_par *p, s32 idx, u32 v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | { |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 177 | pm2_WR(p, PM2R_RD_PALETTE_WRITE_ADDRESS, idx); |
Krzysztof Helt | 11d1a62 | 2007-05-23 13:57:47 -0700 | [diff] [blame] | 178 | wmb(); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 179 | pm2_WR(p, PM2R_RD_INDEXED_DATA, v); |
Krzysztof Helt | 11d1a62 | 2007-05-23 13:57:47 -0700 | [diff] [blame] | 180 | wmb(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | } |
| 182 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 183 | static inline void pm2v_RDAC_WR(struct pm2fb_par *p, s32 idx, u32 v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | { |
| 185 | pm2_WR(p, PM2VR_RD_INDEX_LOW, idx & 0xff); |
Krzysztof Helt | 11d1a62 | 2007-05-23 13:57:47 -0700 | [diff] [blame] | 186 | wmb(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | pm2_WR(p, PM2VR_RD_INDEXED_DATA, v); |
Krzysztof Helt | 11d1a62 | 2007-05-23 13:57:47 -0700 | [diff] [blame] | 188 | wmb(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | #ifdef CONFIG_FB_PM2_FIFO_DISCONNECT |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 192 | #define WAIT_FIFO(p, a) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | #else |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 194 | static inline void WAIT_FIFO(struct pm2fb_par *p, u32 a) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | { |
Krzysztof Helt | 6416ad7 | 2007-10-16 01:29:27 -0700 | [diff] [blame] | 196 | while (pm2_RD(p, PM2R_IN_FIFO_SPACE) < a) |
| 197 | cpu_relax(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | } |
| 199 | #endif |
| 200 | |
| 201 | /* |
| 202 | * partial products for the supported horizontal resolutions. |
| 203 | */ |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 204 | #define PACKPP(p0, p1, p2) (((p2) << 6) | ((p1) << 3) | (p0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | static const struct { |
| 206 | u16 width; |
| 207 | u16 pp; |
| 208 | } pp_table[] = { |
| 209 | { 32, PACKPP(1, 0, 0) }, { 64, PACKPP(1, 1, 0) }, |
| 210 | { 96, PACKPP(1, 1, 1) }, { 128, PACKPP(2, 1, 1) }, |
| 211 | { 160, PACKPP(2, 2, 1) }, { 192, PACKPP(2, 2, 2) }, |
| 212 | { 224, PACKPP(3, 2, 1) }, { 256, PACKPP(3, 2, 2) }, |
| 213 | { 288, PACKPP(3, 3, 1) }, { 320, PACKPP(3, 3, 2) }, |
| 214 | { 384, PACKPP(3, 3, 3) }, { 416, PACKPP(4, 3, 1) }, |
| 215 | { 448, PACKPP(4, 3, 2) }, { 512, PACKPP(4, 3, 3) }, |
| 216 | { 544, PACKPP(4, 4, 1) }, { 576, PACKPP(4, 4, 2) }, |
| 217 | { 640, PACKPP(4, 4, 3) }, { 768, PACKPP(4, 4, 4) }, |
| 218 | { 800, PACKPP(5, 4, 1) }, { 832, PACKPP(5, 4, 2) }, |
| 219 | { 896, PACKPP(5, 4, 3) }, { 1024, PACKPP(5, 4, 4) }, |
| 220 | { 1056, PACKPP(5, 5, 1) }, { 1088, PACKPP(5, 5, 2) }, |
| 221 | { 1152, PACKPP(5, 5, 3) }, { 1280, PACKPP(5, 5, 4) }, |
| 222 | { 1536, PACKPP(5, 5, 5) }, { 1568, PACKPP(6, 5, 1) }, |
| 223 | { 1600, PACKPP(6, 5, 2) }, { 1664, PACKPP(6, 5, 3) }, |
| 224 | { 1792, PACKPP(6, 5, 4) }, { 2048, PACKPP(6, 5, 5) }, |
| 225 | { 0, 0 } }; |
| 226 | |
| 227 | static u32 partprod(u32 xres) |
| 228 | { |
| 229 | int i; |
| 230 | |
| 231 | for (i = 0; pp_table[i].width && pp_table[i].width != xres; i++) |
| 232 | ; |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 233 | if (pp_table[i].width == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | DPRINTK("invalid width %u\n", xres); |
| 235 | return pp_table[i].pp; |
| 236 | } |
| 237 | |
| 238 | static u32 to3264(u32 timing, int bpp, int is64) |
| 239 | { |
| 240 | switch (bpp) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | case 24: |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 242 | timing *= 3; |
| 243 | case 8: |
| 244 | timing >>= 1; |
| 245 | case 16: |
| 246 | timing >>= 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | case 32: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | break; |
| 249 | } |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 250 | if (is64) |
| 251 | timing >>= 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | return timing; |
| 253 | } |
| 254 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 255 | static void pm2_mnp(u32 clk, unsigned char *mm, unsigned char *nn, |
| 256 | unsigned char *pp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | { |
| 258 | unsigned char m; |
| 259 | unsigned char n; |
| 260 | unsigned char p; |
| 261 | u32 f; |
| 262 | s32 curr; |
| 263 | s32 delta = 100000; |
| 264 | |
| 265 | *mm = *nn = *pp = 0; |
| 266 | for (n = 2; n < 15; n++) { |
| 267 | for (m = 2; m; m++) { |
| 268 | f = PM2_REFERENCE_CLOCK * m / n; |
| 269 | if (f >= 150000 && f <= 300000) { |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 270 | for (p = 0; p < 5; p++, f >>= 1) { |
| 271 | curr = (clk > f) ? clk - f : f - clk; |
| 272 | if (curr < delta) { |
| 273 | delta = curr; |
| 274 | *mm = m; |
| 275 | *nn = n; |
| 276 | *pp = p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | } |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 284 | static void pm2v_mnp(u32 clk, unsigned char *mm, unsigned char *nn, |
| 285 | unsigned char *pp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | { |
| 287 | unsigned char m; |
| 288 | unsigned char n; |
| 289 | unsigned char p; |
| 290 | u32 f; |
| 291 | s32 delta = 1000; |
| 292 | |
| 293 | *mm = *nn = *pp = 0; |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 294 | for (m = 1; m < 128; m++) { |
Krzysztof Helt | d4a96b5 | 2007-05-08 00:39:33 -0700 | [diff] [blame] | 295 | for (n = 2 * m + 1; n; n++) { |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 296 | for (p = 0; p < 2; p++) { |
| 297 | f = (PM2_REFERENCE_CLOCK >> (p + 1)) * n / m; |
| 298 | if (clk > f - delta && clk < f + delta) { |
| 299 | delta = (clk > f) ? clk - f : f - clk; |
| 300 | *mm = m; |
| 301 | *nn = n; |
| 302 | *pp = p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | } |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | } |
| 308 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 309 | static void clear_palette(struct pm2fb_par *p) |
| 310 | { |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 311 | int i = 256; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | |
| 313 | WAIT_FIFO(p, 1); |
| 314 | pm2_WR(p, PM2R_RD_PALETTE_WRITE_ADDRESS, 0); |
| 315 | wmb(); |
| 316 | while (i--) { |
| 317 | WAIT_FIFO(p, 3); |
| 318 | pm2_WR(p, PM2R_RD_PALETTE_DATA, 0); |
| 319 | pm2_WR(p, PM2R_RD_PALETTE_DATA, 0); |
| 320 | pm2_WR(p, PM2R_RD_PALETTE_DATA, 0); |
| 321 | } |
| 322 | } |
| 323 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 324 | static void reset_card(struct pm2fb_par *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | { |
| 326 | if (p->type == PM2_TYPE_PERMEDIA2V) |
| 327 | pm2_WR(p, PM2VR_RD_INDEX_HIGH, 0); |
| 328 | pm2_WR(p, PM2R_RESET_STATUS, 0); |
| 329 | mb(); |
| 330 | while (pm2_RD(p, PM2R_RESET_STATUS) & PM2F_BEING_RESET) |
Krzysztof Helt | 6416ad7 | 2007-10-16 01:29:27 -0700 | [diff] [blame] | 331 | cpu_relax(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | mb(); |
| 333 | #ifdef CONFIG_FB_PM2_FIFO_DISCONNECT |
| 334 | DPRINTK("FIFO disconnect enabled\n"); |
| 335 | pm2_WR(p, PM2R_FIFO_DISCON, 1); |
| 336 | mb(); |
| 337 | #endif |
| 338 | |
| 339 | /* Restore stashed memory config information from probe */ |
| 340 | WAIT_FIFO(p, 3); |
| 341 | pm2_WR(p, PM2R_MEM_CONTROL, p->mem_control); |
| 342 | pm2_WR(p, PM2R_BOOT_ADDRESS, p->boot_address); |
| 343 | wmb(); |
| 344 | pm2_WR(p, PM2R_MEM_CONFIG, p->mem_config); |
| 345 | } |
| 346 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 347 | static void reset_config(struct pm2fb_par *p) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | { |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 349 | WAIT_FIFO(p, 53); |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 350 | pm2_WR(p, PM2R_CHIP_CONFIG, pm2_RD(p, PM2R_CHIP_CONFIG) & |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 351 | ~(PM2F_VGA_ENABLE | PM2F_VGA_FIXED)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | pm2_WR(p, PM2R_BYPASS_WRITE_MASK, ~(0L)); |
| 353 | pm2_WR(p, PM2R_FRAMEBUFFER_WRITE_MASK, ~(0L)); |
| 354 | pm2_WR(p, PM2R_FIFO_CONTROL, 0); |
| 355 | pm2_WR(p, PM2R_APERTURE_ONE, 0); |
| 356 | pm2_WR(p, PM2R_APERTURE_TWO, 0); |
| 357 | pm2_WR(p, PM2R_RASTERIZER_MODE, 0); |
| 358 | pm2_WR(p, PM2R_DELTA_MODE, PM2F_DELTA_ORDER_RGB); |
| 359 | pm2_WR(p, PM2R_LB_READ_FORMAT, 0); |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 360 | pm2_WR(p, PM2R_LB_WRITE_FORMAT, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | pm2_WR(p, PM2R_LB_READ_MODE, 0); |
| 362 | pm2_WR(p, PM2R_LB_SOURCE_OFFSET, 0); |
| 363 | pm2_WR(p, PM2R_FB_SOURCE_OFFSET, 0); |
| 364 | pm2_WR(p, PM2R_FB_PIXEL_OFFSET, 0); |
| 365 | pm2_WR(p, PM2R_FB_WINDOW_BASE, 0); |
| 366 | pm2_WR(p, PM2R_LB_WINDOW_BASE, 0); |
| 367 | pm2_WR(p, PM2R_FB_SOFT_WRITE_MASK, ~(0L)); |
| 368 | pm2_WR(p, PM2R_FB_HARD_WRITE_MASK, ~(0L)); |
| 369 | pm2_WR(p, PM2R_FB_READ_PIXEL, 0); |
| 370 | pm2_WR(p, PM2R_DITHER_MODE, 0); |
| 371 | pm2_WR(p, PM2R_AREA_STIPPLE_MODE, 0); |
| 372 | pm2_WR(p, PM2R_DEPTH_MODE, 0); |
| 373 | pm2_WR(p, PM2R_STENCIL_MODE, 0); |
| 374 | pm2_WR(p, PM2R_TEXTURE_ADDRESS_MODE, 0); |
| 375 | pm2_WR(p, PM2R_TEXTURE_READ_MODE, 0); |
| 376 | pm2_WR(p, PM2R_TEXEL_LUT_MODE, 0); |
| 377 | pm2_WR(p, PM2R_YUV_MODE, 0); |
| 378 | pm2_WR(p, PM2R_COLOR_DDA_MODE, 0); |
| 379 | pm2_WR(p, PM2R_TEXTURE_COLOR_MODE, 0); |
| 380 | pm2_WR(p, PM2R_FOG_MODE, 0); |
| 381 | pm2_WR(p, PM2R_ALPHA_BLEND_MODE, 0); |
| 382 | pm2_WR(p, PM2R_LOGICAL_OP_MODE, 0); |
| 383 | pm2_WR(p, PM2R_STATISTICS_MODE, 0); |
| 384 | pm2_WR(p, PM2R_SCISSOR_MODE, 0); |
| 385 | pm2_WR(p, PM2R_FILTER_MODE, PM2F_SYNCHRONIZATION); |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 386 | pm2_WR(p, PM2R_RD_PIXEL_MASK, 0xff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | switch (p->type) { |
| 388 | case PM2_TYPE_PERMEDIA2: |
| 389 | pm2_RDAC_WR(p, PM2I_RD_MODE_CONTROL, 0); /* no overlay */ |
| 390 | pm2_RDAC_WR(p, PM2I_RD_CURSOR_CONTROL, 0); |
| 391 | pm2_RDAC_WR(p, PM2I_RD_MISC_CONTROL, PM2F_RD_PALETTE_WIDTH_8); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 392 | pm2_RDAC_WR(p, PM2I_RD_COLOR_KEY_CONTROL, 0); |
| 393 | pm2_RDAC_WR(p, PM2I_RD_OVERLAY_KEY, 0); |
| 394 | pm2_RDAC_WR(p, PM2I_RD_RED_KEY, 0); |
| 395 | pm2_RDAC_WR(p, PM2I_RD_GREEN_KEY, 0); |
| 396 | pm2_RDAC_WR(p, PM2I_RD_BLUE_KEY, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | break; |
| 398 | case PM2_TYPE_PERMEDIA2V: |
| 399 | pm2v_RDAC_WR(p, PM2VI_RD_MISC_CONTROL, 1); /* 8bit */ |
| 400 | break; |
| 401 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | } |
| 403 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 404 | static void set_aperture(struct pm2fb_par *p, u32 depth) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | { |
| 406 | /* |
| 407 | * The hardware is little-endian. When used in big-endian |
| 408 | * hosts, the on-chip aperture settings are used where |
| 409 | * possible to translate from host to card byte order. |
| 410 | */ |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 411 | WAIT_FIFO(p, 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | #ifdef __LITTLE_ENDIAN |
| 413 | pm2_WR(p, PM2R_APERTURE_ONE, PM2F_APERTURE_STANDARD); |
| 414 | #else |
| 415 | switch (depth) { |
| 416 | case 24: /* RGB->BGR */ |
| 417 | /* |
| 418 | * We can't use the aperture to translate host to |
| 419 | * card byte order here, so we switch to BGR mode |
| 420 | * in pm2fb_set_par(). |
| 421 | */ |
| 422 | case 8: /* B->B */ |
| 423 | pm2_WR(p, PM2R_APERTURE_ONE, PM2F_APERTURE_STANDARD); |
| 424 | break; |
| 425 | case 16: /* HL->LH */ |
| 426 | pm2_WR(p, PM2R_APERTURE_ONE, PM2F_APERTURE_HALFWORDSWAP); |
| 427 | break; |
| 428 | case 32: /* RGBA->ABGR */ |
| 429 | pm2_WR(p, PM2R_APERTURE_ONE, PM2F_APERTURE_BYTESWAP); |
| 430 | break; |
| 431 | } |
| 432 | #endif |
| 433 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 434 | /* We don't use aperture two, so this may be superflous */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | pm2_WR(p, PM2R_APERTURE_TWO, PM2F_APERTURE_STANDARD); |
| 436 | } |
| 437 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 438 | static void set_color(struct pm2fb_par *p, unsigned char regno, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | unsigned char r, unsigned char g, unsigned char b) |
| 440 | { |
| 441 | WAIT_FIFO(p, 4); |
| 442 | pm2_WR(p, PM2R_RD_PALETTE_WRITE_ADDRESS, regno); |
| 443 | wmb(); |
| 444 | pm2_WR(p, PM2R_RD_PALETTE_DATA, r); |
| 445 | wmb(); |
| 446 | pm2_WR(p, PM2R_RD_PALETTE_DATA, g); |
| 447 | wmb(); |
| 448 | pm2_WR(p, PM2R_RD_PALETTE_DATA, b); |
| 449 | } |
| 450 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 451 | static void set_memclock(struct pm2fb_par *par, u32 clk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | { |
| 453 | int i; |
| 454 | unsigned char m, n, p; |
| 455 | |
Krzysztof Helt | e5d809d | 2007-05-08 00:39:32 -0700 | [diff] [blame] | 456 | switch (par->type) { |
| 457 | case PM2_TYPE_PERMEDIA2V: |
| 458 | pm2v_mnp(clk/2, &m, &n, &p); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 459 | WAIT_FIFO(par, 12); |
Krzysztof Helt | e5d809d | 2007-05-08 00:39:32 -0700 | [diff] [blame] | 460 | pm2_WR(par, PM2VR_RD_INDEX_HIGH, PM2VI_RD_MCLK_CONTROL >> 8); |
| 461 | pm2v_RDAC_WR(par, PM2VI_RD_MCLK_CONTROL, 0); |
Krzysztof Helt | e5d809d | 2007-05-08 00:39:32 -0700 | [diff] [blame] | 462 | pm2v_RDAC_WR(par, PM2VI_RD_MCLK_PRESCALE, m); |
| 463 | pm2v_RDAC_WR(par, PM2VI_RD_MCLK_FEEDBACK, n); |
| 464 | pm2v_RDAC_WR(par, PM2VI_RD_MCLK_POSTSCALE, p); |
Krzysztof Helt | e5d809d | 2007-05-08 00:39:32 -0700 | [diff] [blame] | 465 | pm2v_RDAC_WR(par, PM2VI_RD_MCLK_CONTROL, 1); |
| 466 | rmb(); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 467 | for (i = 256; i; i--) |
| 468 | if (pm2v_RDAC_RD(par, PM2VI_RD_MCLK_CONTROL) & 2) |
| 469 | break; |
Krzysztof Helt | e5d809d | 2007-05-08 00:39:32 -0700 | [diff] [blame] | 470 | pm2_WR(par, PM2VR_RD_INDEX_HIGH, 0); |
| 471 | break; |
| 472 | case PM2_TYPE_PERMEDIA2: |
| 473 | pm2_mnp(clk, &m, &n, &p); |
| 474 | WAIT_FIFO(par, 10); |
| 475 | pm2_RDAC_WR(par, PM2I_RD_MEMORY_CLOCK_3, 6); |
Krzysztof Helt | e5d809d | 2007-05-08 00:39:32 -0700 | [diff] [blame] | 476 | pm2_RDAC_WR(par, PM2I_RD_MEMORY_CLOCK_1, m); |
| 477 | pm2_RDAC_WR(par, PM2I_RD_MEMORY_CLOCK_2, n); |
Krzysztof Helt | e5d809d | 2007-05-08 00:39:32 -0700 | [diff] [blame] | 478 | pm2_RDAC_WR(par, PM2I_RD_MEMORY_CLOCK_3, 8|p); |
Krzysztof Helt | e5d809d | 2007-05-08 00:39:32 -0700 | [diff] [blame] | 479 | pm2_RDAC_RD(par, PM2I_RD_MEMORY_CLOCK_STATUS); |
| 480 | rmb(); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 481 | for (i = 256; i; i--) |
| 482 | if (pm2_RD(par, PM2R_RD_INDEXED_DATA) & PM2F_PLL_LOCKED) |
| 483 | break; |
Krzysztof Helt | e5d809d | 2007-05-08 00:39:32 -0700 | [diff] [blame] | 484 | break; |
| 485 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | } |
| 487 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 488 | static void set_pixclock(struct pm2fb_par *par, u32 clk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | { |
| 490 | int i; |
| 491 | unsigned char m, n, p; |
| 492 | |
| 493 | switch (par->type) { |
| 494 | case PM2_TYPE_PERMEDIA2: |
| 495 | pm2_mnp(clk, &m, &n, &p); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 496 | WAIT_FIFO(par, 10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | pm2_RDAC_WR(par, PM2I_RD_PIXEL_CLOCK_A3, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | pm2_RDAC_WR(par, PM2I_RD_PIXEL_CLOCK_A1, m); |
| 499 | pm2_RDAC_WR(par, PM2I_RD_PIXEL_CLOCK_A2, n); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | pm2_RDAC_WR(par, PM2I_RD_PIXEL_CLOCK_A3, 8|p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | pm2_RDAC_RD(par, PM2I_RD_PIXEL_CLOCK_STATUS); |
| 502 | rmb(); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 503 | for (i = 256; i; i--) |
| 504 | if (pm2_RD(par, PM2R_RD_INDEXED_DATA) & PM2F_PLL_LOCKED) |
| 505 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | break; |
| 507 | case PM2_TYPE_PERMEDIA2V: |
| 508 | pm2v_mnp(clk/2, &m, &n, &p); |
| 509 | WAIT_FIFO(par, 8); |
| 510 | pm2_WR(par, PM2VR_RD_INDEX_HIGH, PM2VI_RD_CLK0_PRESCALE >> 8); |
| 511 | pm2v_RDAC_WR(par, PM2VI_RD_CLK0_PRESCALE, m); |
| 512 | pm2v_RDAC_WR(par, PM2VI_RD_CLK0_FEEDBACK, n); |
| 513 | pm2v_RDAC_WR(par, PM2VI_RD_CLK0_POSTSCALE, p); |
| 514 | pm2_WR(par, PM2VR_RD_INDEX_HIGH, 0); |
| 515 | break; |
| 516 | } |
| 517 | } |
| 518 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 519 | static void set_video(struct pm2fb_par *p, u32 video) |
| 520 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | u32 tmp; |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 522 | u32 vsync = video; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | |
| 524 | DPRINTK("video = 0x%x\n", video); |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 525 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | /* |
| 527 | * The hardware cursor needs +vsync to recognise vert retrace. |
| 528 | * We may not be using the hardware cursor, but the X Glint |
| 529 | * driver may well. So always set +hsync/+vsync and then set |
| 530 | * the RAMDAC to invert the sync if necessary. |
| 531 | */ |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 532 | vsync &= ~(PM2F_HSYNC_MASK | PM2F_VSYNC_MASK); |
| 533 | vsync |= PM2F_HSYNC_ACT_HIGH | PM2F_VSYNC_ACT_HIGH; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 535 | WAIT_FIFO(p, 3); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | pm2_WR(p, PM2R_VIDEO_CONTROL, vsync); |
| 537 | |
| 538 | switch (p->type) { |
| 539 | case PM2_TYPE_PERMEDIA2: |
| 540 | tmp = PM2F_RD_PALETTE_WIDTH_8; |
| 541 | if ((video & PM2F_HSYNC_MASK) == PM2F_HSYNC_ACT_LOW) |
| 542 | tmp |= 4; /* invert hsync */ |
| 543 | if ((video & PM2F_VSYNC_MASK) == PM2F_VSYNC_ACT_LOW) |
| 544 | tmp |= 8; /* invert vsync */ |
| 545 | pm2_RDAC_WR(p, PM2I_RD_MISC_CONTROL, tmp); |
| 546 | break; |
| 547 | case PM2_TYPE_PERMEDIA2V: |
| 548 | tmp = 0; |
| 549 | if ((video & PM2F_HSYNC_MASK) == PM2F_HSYNC_ACT_LOW) |
| 550 | tmp |= 1; /* invert hsync */ |
| 551 | if ((video & PM2F_VSYNC_MASK) == PM2F_VSYNC_ACT_LOW) |
| 552 | tmp |= 4; /* invert vsync */ |
| 553 | pm2v_RDAC_WR(p, PM2VI_RD_SYNC_CONTROL, tmp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | break; |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | /* |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 559 | * pm2fb_check_var - Optional function. Validates a var passed in. |
| 560 | * @var: frame buffer variable screen structure |
| 561 | * @info: frame buffer structure that represents a single frame buffer |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | * |
| 563 | * Checks to see if the hardware supports the state requested by |
| 564 | * var passed in. |
| 565 | * |
| 566 | * Returns negative errno on error, or zero on success. |
| 567 | */ |
| 568 | static int pm2fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) |
| 569 | { |
| 570 | u32 lpitch; |
| 571 | |
| 572 | if (var->bits_per_pixel != 8 && var->bits_per_pixel != 16 && |
| 573 | var->bits_per_pixel != 24 && var->bits_per_pixel != 32) { |
| 574 | DPRINTK("depth not supported: %u\n", var->bits_per_pixel); |
| 575 | return -EINVAL; |
| 576 | } |
| 577 | |
| 578 | if (var->xres != var->xres_virtual) { |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 579 | DPRINTK("virtual x resolution != " |
| 580 | "physical x resolution not supported\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | return -EINVAL; |
| 582 | } |
| 583 | |
| 584 | if (var->yres > var->yres_virtual) { |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 585 | DPRINTK("virtual y resolution < " |
| 586 | "physical y resolution not possible\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | return -EINVAL; |
| 588 | } |
| 589 | |
Krzysztof Helt | 1ddc28d | 2007-10-16 01:29:16 -0700 | [diff] [blame] | 590 | /* permedia cannot blit over 2048 */ |
| 591 | if (var->yres_virtual > 2047) { |
| 592 | var->yres_virtual = 2047; |
| 593 | } |
| 594 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | if (var->xoffset) { |
| 596 | DPRINTK("xoffset not supported\n"); |
| 597 | return -EINVAL; |
| 598 | } |
| 599 | |
| 600 | if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { |
| 601 | DPRINTK("interlace not supported\n"); |
| 602 | return -EINVAL; |
| 603 | } |
| 604 | |
| 605 | var->xres = (var->xres + 15) & ~15; /* could sometimes be 8 */ |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 606 | lpitch = var->xres * ((var->bits_per_pixel + 7) >> 3); |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 607 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | if (var->xres < 320 || var->xres > 1600) { |
| 609 | DPRINTK("width not supported: %u\n", var->xres); |
| 610 | return -EINVAL; |
| 611 | } |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 612 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | if (var->yres < 200 || var->yres > 1200) { |
| 614 | DPRINTK("height not supported: %u\n", var->yres); |
| 615 | return -EINVAL; |
| 616 | } |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 617 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | if (lpitch * var->yres_virtual > info->fix.smem_len) { |
| 619 | DPRINTK("no memory for screen (%ux%ux%u)\n", |
| 620 | var->xres, var->yres_virtual, var->bits_per_pixel); |
| 621 | return -EINVAL; |
| 622 | } |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 623 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | if (PICOS2KHZ(var->pixclock) > PM2_MAX_PIXCLOCK) { |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 625 | DPRINTK("pixclock too high (%ldKHz)\n", |
| 626 | PICOS2KHZ(var->pixclock)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | return -EINVAL; |
| 628 | } |
| 629 | |
krzysztof.h1@wp.pl | 76c7d3f | 2007-05-08 00:39:56 -0700 | [diff] [blame] | 630 | var->transp.offset = 0; |
| 631 | var->transp.length = 0; |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 632 | switch (var->bits_per_pixel) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | case 8: |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 634 | var->red.length = 8; |
| 635 | var->green.length = 8; |
| 636 | var->blue.length = 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | break; |
| 638 | case 16: |
| 639 | var->red.offset = 11; |
| 640 | var->red.length = 5; |
| 641 | var->green.offset = 5; |
| 642 | var->green.length = 6; |
| 643 | var->blue.offset = 0; |
| 644 | var->blue.length = 5; |
| 645 | break; |
| 646 | case 32: |
| 647 | var->transp.offset = 24; |
| 648 | var->transp.length = 8; |
| 649 | var->red.offset = 16; |
| 650 | var->green.offset = 8; |
| 651 | var->blue.offset = 0; |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 652 | var->red.length = 8; |
| 653 | var->green.length = 8; |
| 654 | var->blue.length = 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | break; |
| 656 | case 24: |
| 657 | #ifdef __BIG_ENDIAN |
| 658 | var->red.offset = 0; |
| 659 | var->blue.offset = 16; |
| 660 | #else |
| 661 | var->red.offset = 16; |
| 662 | var->blue.offset = 0; |
| 663 | #endif |
| 664 | var->green.offset = 8; |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 665 | var->red.length = 8; |
| 666 | var->green.length = 8; |
| 667 | var->blue.length = 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | break; |
| 669 | } |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 670 | var->height = -1; |
| 671 | var->width = -1; |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 672 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | var->accel_flags = 0; /* Can't mmap if this is on */ |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 674 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | DPRINTK("Checking graphics mode at %dx%d depth %d\n", |
| 676 | var->xres, var->yres, var->bits_per_pixel); |
| 677 | return 0; |
| 678 | } |
| 679 | |
| 680 | /** |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 681 | * pm2fb_set_par - Alters the hardware state. |
| 682 | * @info: frame buffer structure that represents a single frame buffer |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | * |
| 684 | * Using the fb_var_screeninfo in fb_info we set the resolution of the |
| 685 | * this particular framebuffer. |
| 686 | */ |
| 687 | static int pm2fb_set_par(struct fb_info *info) |
| 688 | { |
Antonino A. Daplas | 6772a2e | 2006-01-09 20:53:10 -0800 | [diff] [blame] | 689 | struct pm2fb_par *par = info->par; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | u32 pixclock; |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 691 | u32 width = (info->var.xres_virtual + 7) & ~7; |
| 692 | u32 height = info->var.yres_virtual; |
| 693 | u32 depth = (info->var.bits_per_pixel + 7) & ~7; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | u32 hsstart, hsend, hbend, htotal; |
| 695 | u32 vsstart, vsend, vbend, vtotal; |
| 696 | u32 stride; |
| 697 | u32 base; |
| 698 | u32 video = 0; |
| 699 | u32 clrmode = PM2F_RD_COLOR_MODE_RGB | PM2F_RD_GUI_ACTIVE; |
| 700 | u32 txtmap = 0; |
| 701 | u32 pixsize = 0; |
| 702 | u32 clrformat = 0; |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 703 | u32 misc = 1; /* 8-bit DAC */ |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 704 | u32 xres = (info->var.xres + 31) & ~31; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | int data64; |
| 706 | |
| 707 | reset_card(par); |
| 708 | reset_config(par); |
| 709 | clear_palette(par); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 710 | if (par->memclock) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | set_memclock(par, par->memclock); |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 712 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | depth = (depth > 32) ? 32 : depth; |
| 714 | data64 = depth > 8 || par->type == PM2_TYPE_PERMEDIA2V; |
| 715 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | pixclock = PICOS2KHZ(info->var.pixclock); |
| 717 | if (pixclock > PM2_MAX_PIXCLOCK) { |
| 718 | DPRINTK("pixclock too high (%uKHz)\n", pixclock); |
| 719 | return -EINVAL; |
| 720 | } |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 721 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | hsstart = to3264(info->var.right_margin, depth, data64); |
| 723 | hsend = hsstart + to3264(info->var.hsync_len, depth, data64); |
| 724 | hbend = hsend + to3264(info->var.left_margin, depth, data64); |
| 725 | htotal = to3264(xres, depth, data64) + hbend - 1; |
| 726 | vsstart = (info->var.lower_margin) |
| 727 | ? info->var.lower_margin - 1 |
| 728 | : 0; /* FIXME! */ |
| 729 | vsend = info->var.lower_margin + info->var.vsync_len - 1; |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 730 | vbend = info->var.lower_margin + info->var.vsync_len + |
| 731 | info->var.upper_margin; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 732 | vtotal = info->var.yres + vbend - 1; |
| 733 | stride = to3264(width, depth, 1); |
| 734 | base = to3264(info->var.yoffset * xres + info->var.xoffset, depth, 1); |
| 735 | if (data64) |
| 736 | video |= PM2F_DATA_64_ENABLE; |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 737 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | if (info->var.sync & FB_SYNC_HOR_HIGH_ACT) { |
| 739 | if (lowhsync) { |
| 740 | DPRINTK("ignoring +hsync, using -hsync.\n"); |
| 741 | video |= PM2F_HSYNC_ACT_LOW; |
| 742 | } else |
| 743 | video |= PM2F_HSYNC_ACT_HIGH; |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 744 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | video |= PM2F_HSYNC_ACT_LOW; |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 746 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 747 | if (info->var.sync & FB_SYNC_VERT_HIGH_ACT) { |
| 748 | if (lowvsync) { |
| 749 | DPRINTK("ignoring +vsync, using -vsync.\n"); |
| 750 | video |= PM2F_VSYNC_ACT_LOW; |
| 751 | } else |
| 752 | video |= PM2F_VSYNC_ACT_HIGH; |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 753 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | video |= PM2F_VSYNC_ACT_LOW; |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 755 | |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 756 | if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | DPRINTK("interlaced not supported\n"); |
| 758 | return -EINVAL; |
| 759 | } |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 760 | if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | video |= PM2F_LINE_DOUBLE; |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 762 | if ((info->var.activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | video |= PM2F_VIDEO_ENABLE; |
| 764 | par->video = video; |
| 765 | |
| 766 | info->fix.visual = |
| 767 | (depth == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; |
| 768 | info->fix.line_length = info->var.xres * depth / 8; |
| 769 | info->cmap.len = 256; |
| 770 | |
| 771 | /* |
| 772 | * Settings calculated. Now write them out. |
| 773 | */ |
| 774 | if (par->type == PM2_TYPE_PERMEDIA2V) { |
| 775 | WAIT_FIFO(par, 1); |
| 776 | pm2_WR(par, PM2VR_RD_INDEX_HIGH, 0); |
| 777 | } |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 778 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | set_aperture(par, depth); |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 780 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | mb(); |
| 782 | WAIT_FIFO(par, 19); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | switch (depth) { |
| 784 | case 8: |
| 785 | pm2_WR(par, PM2R_FB_READ_PIXEL, 0); |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 786 | clrformat = 0x2e; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | break; |
| 788 | case 16: |
| 789 | pm2_WR(par, PM2R_FB_READ_PIXEL, 1); |
| 790 | clrmode |= PM2F_RD_TRUECOLOR | PM2F_RD_PIXELFORMAT_RGB565; |
| 791 | txtmap = PM2F_TEXTEL_SIZE_16; |
| 792 | pixsize = 1; |
| 793 | clrformat = 0x70; |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 794 | misc |= 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 795 | break; |
| 796 | case 32: |
| 797 | pm2_WR(par, PM2R_FB_READ_PIXEL, 2); |
| 798 | clrmode |= PM2F_RD_TRUECOLOR | PM2F_RD_PIXELFORMAT_RGBA8888; |
| 799 | txtmap = PM2F_TEXTEL_SIZE_32; |
| 800 | pixsize = 2; |
| 801 | clrformat = 0x20; |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 802 | misc |= 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 803 | break; |
| 804 | case 24: |
| 805 | pm2_WR(par, PM2R_FB_READ_PIXEL, 4); |
| 806 | clrmode |= PM2F_RD_TRUECOLOR | PM2F_RD_PIXELFORMAT_RGB888; |
| 807 | txtmap = PM2F_TEXTEL_SIZE_24; |
| 808 | pixsize = 4; |
| 809 | clrformat = 0x20; |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 810 | misc |= 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | break; |
| 812 | } |
| 813 | pm2_WR(par, PM2R_FB_WRITE_MODE, PM2F_FB_WRITE_ENABLE); |
| 814 | pm2_WR(par, PM2R_FB_READ_MODE, partprod(xres)); |
| 815 | pm2_WR(par, PM2R_LB_READ_MODE, partprod(xres)); |
| 816 | pm2_WR(par, PM2R_TEXTURE_MAP_FORMAT, txtmap | partprod(xres)); |
| 817 | pm2_WR(par, PM2R_H_TOTAL, htotal); |
| 818 | pm2_WR(par, PM2R_HS_START, hsstart); |
| 819 | pm2_WR(par, PM2R_HS_END, hsend); |
| 820 | pm2_WR(par, PM2R_HG_END, hbend); |
| 821 | pm2_WR(par, PM2R_HB_END, hbend); |
| 822 | pm2_WR(par, PM2R_V_TOTAL, vtotal); |
| 823 | pm2_WR(par, PM2R_VS_START, vsstart); |
| 824 | pm2_WR(par, PM2R_VS_END, vsend); |
| 825 | pm2_WR(par, PM2R_VB_END, vbend); |
| 826 | pm2_WR(par, PM2R_SCREEN_STRIDE, stride); |
| 827 | wmb(); |
| 828 | pm2_WR(par, PM2R_WINDOW_ORIGIN, 0); |
| 829 | pm2_WR(par, PM2R_SCREEN_SIZE, (height << 16) | width); |
| 830 | pm2_WR(par, PM2R_SCISSOR_MODE, PM2F_SCREEN_SCISSOR_ENABLE); |
| 831 | wmb(); |
| 832 | pm2_WR(par, PM2R_SCREEN_BASE, base); |
| 833 | wmb(); |
| 834 | set_video(par, video); |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 835 | WAIT_FIFO(par, 10); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | switch (par->type) { |
| 837 | case PM2_TYPE_PERMEDIA2: |
| 838 | pm2_RDAC_WR(par, PM2I_RD_COLOR_MODE, clrmode); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 839 | pm2_RDAC_WR(par, PM2I_RD_COLOR_KEY_CONTROL, |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 840 | (depth == 8) ? 0 : PM2F_COLOR_KEY_TEST_OFF); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | break; |
| 842 | case PM2_TYPE_PERMEDIA2V: |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 843 | pm2v_RDAC_WR(par, PM2VI_RD_DAC_CONTROL, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 844 | pm2v_RDAC_WR(par, PM2VI_RD_PIXEL_SIZE, pixsize); |
| 845 | pm2v_RDAC_WR(par, PM2VI_RD_COLOR_FORMAT, clrformat); |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 846 | pm2v_RDAC_WR(par, PM2VI_RD_MISC_CONTROL, misc); |
| 847 | pm2v_RDAC_WR(par, PM2VI_RD_OVERLAY_KEY, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | break; |
| 849 | } |
| 850 | set_pixclock(par, pixclock); |
| 851 | DPRINTK("Setting graphics mode at %dx%d depth %d\n", |
| 852 | info->var.xres, info->var.yres, info->var.bits_per_pixel); |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 853 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | /** |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 857 | * pm2fb_setcolreg - Sets a color register. |
| 858 | * @regno: boolean, 0 copy local, 1 get_user() function |
| 859 | * @red: frame buffer colormap structure |
| 860 | * @green: The green value which can be up to 16 bits wide |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | * @blue: The blue value which can be up to 16 bits wide. |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 862 | * @transp: If supported the alpha value which can be up to 16 bits wide. |
| 863 | * @info: frame buffer info structure |
| 864 | * |
| 865 | * Set a single color register. The values supplied have a 16 bit |
| 866 | * magnitude which needs to be scaled in this function for the hardware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | * Pretty much a direct lift from tdfxfb.c. |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 868 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | * Returns negative errno on error, or zero on success. |
| 870 | */ |
| 871 | static int pm2fb_setcolreg(unsigned regno, unsigned red, unsigned green, |
| 872 | unsigned blue, unsigned transp, |
| 873 | struct fb_info *info) |
| 874 | { |
Antonino A. Daplas | 6772a2e | 2006-01-09 20:53:10 -0800 | [diff] [blame] | 875 | struct pm2fb_par *par = info->par; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | |
| 877 | if (regno >= info->cmap.len) /* no. of hw registers */ |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 878 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | /* |
| 880 | * Program hardware... do anything you want with transp |
| 881 | */ |
| 882 | |
| 883 | /* grayscale works only partially under directcolor */ |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 884 | /* grayscale = 0.30*R + 0.59*G + 0.11*B */ |
| 885 | if (info->var.grayscale) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 886 | red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | |
| 888 | /* Directcolor: |
| 889 | * var->{color}.offset contains start of bitfield |
| 890 | * var->{color}.length contains length of bitfield |
| 891 | * {hardwarespecific} contains width of DAC |
| 892 | * cmap[X] is programmed to |
| 893 | * (X << red.offset) | (X << green.offset) | (X << blue.offset) |
| 894 | * RAMDAC[X] is programmed to (red, green, blue) |
| 895 | * |
| 896 | * Pseudocolor: |
| 897 | * uses offset = 0 && length = DAC register width. |
| 898 | * var->{color}.offset is 0 |
| 899 | * var->{color}.length contains widht of DAC |
| 900 | * cmap is not used |
| 901 | * DAC[X] is programmed to (red, green, blue) |
| 902 | * Truecolor: |
| 903 | * does not use RAMDAC (usually has 3 of them). |
| 904 | * var->{color}.offset contains start of bitfield |
| 905 | * var->{color}.length contains length of bitfield |
| 906 | * cmap is programmed to |
| 907 | * (red << red.offset) | (green << green.offset) | |
| 908 | * (blue << blue.offset) | (transp << transp.offset) |
| 909 | * RAMDAC does not exist |
| 910 | */ |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 911 | #define CNVT_TOHW(val, width) ((((val) << (width)) + 0x7FFF -(val)) >> 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 912 | switch (info->fix.visual) { |
| 913 | case FB_VISUAL_TRUECOLOR: |
| 914 | case FB_VISUAL_PSEUDOCOLOR: |
| 915 | red = CNVT_TOHW(red, info->var.red.length); |
| 916 | green = CNVT_TOHW(green, info->var.green.length); |
| 917 | blue = CNVT_TOHW(blue, info->var.blue.length); |
| 918 | transp = CNVT_TOHW(transp, info->var.transp.length); |
| 919 | break; |
| 920 | case FB_VISUAL_DIRECTCOLOR: |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 921 | /* example here assumes 8 bit DAC. Might be different |
| 922 | * for your hardware */ |
| 923 | red = CNVT_TOHW(red, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | green = CNVT_TOHW(green, 8); |
| 925 | blue = CNVT_TOHW(blue, 8); |
| 926 | /* hey, there is bug in transp handling... */ |
| 927 | transp = CNVT_TOHW(transp, 8); |
| 928 | break; |
| 929 | } |
| 930 | #undef CNVT_TOHW |
| 931 | /* Truecolor has hardware independent palette */ |
| 932 | if (info->fix.visual == FB_VISUAL_TRUECOLOR) { |
| 933 | u32 v; |
| 934 | |
| 935 | if (regno >= 16) |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 936 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 937 | |
| 938 | v = (red << info->var.red.offset) | |
| 939 | (green << info->var.green.offset) | |
| 940 | (blue << info->var.blue.offset) | |
| 941 | (transp << info->var.transp.offset); |
| 942 | |
| 943 | switch (info->var.bits_per_pixel) { |
| 944 | case 8: |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 945 | break; |
| 946 | case 16: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | case 24: |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 948 | case 32: |
| 949 | par->palette[regno] = v; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | break; |
| 951 | } |
| 952 | return 0; |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 953 | } else if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 954 | set_color(par, regno, red, green, blue); |
| 955 | |
| 956 | return 0; |
| 957 | } |
| 958 | |
| 959 | /** |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 960 | * pm2fb_pan_display - Pans the display. |
| 961 | * @var: frame buffer variable screen structure |
| 962 | * @info: frame buffer structure that represents a single frame buffer |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 963 | * |
| 964 | * Pan (or wrap, depending on the `vmode' field) the display using the |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 965 | * `xoffset' and `yoffset' fields of the `var' structure. |
| 966 | * If the values don't fit, return -EINVAL. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | * |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 968 | * Returns negative errno on error, or zero on success. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 969 | * |
| 970 | */ |
| 971 | static int pm2fb_pan_display(struct fb_var_screeninfo *var, |
| 972 | struct fb_info *info) |
| 973 | { |
Antonino A. Daplas | 6772a2e | 2006-01-09 20:53:10 -0800 | [diff] [blame] | 974 | struct pm2fb_par *p = info->par; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | u32 base; |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 976 | u32 depth = (var->bits_per_pixel + 7) & ~7; |
| 977 | u32 xres = (var->xres + 31) & ~31; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 978 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | depth = (depth > 32) ? 32 : depth; |
| 980 | base = to3264(var->yoffset * xres + var->xoffset, depth, 1); |
| 981 | WAIT_FIFO(p, 1); |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 982 | pm2_WR(p, PM2R_SCREEN_BASE, base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | return 0; |
| 984 | } |
| 985 | |
| 986 | /** |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 987 | * pm2fb_blank - Blanks the display. |
| 988 | * @blank_mode: the blank mode we want. |
| 989 | * @info: frame buffer structure that represents a single frame buffer |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | * |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 991 | * Blank the screen if blank_mode != 0, else unblank. Return 0 if |
| 992 | * blanking succeeded, != 0 if un-/blanking failed due to e.g. a |
| 993 | * video mode which doesn't support it. Implements VESA suspend |
| 994 | * and powerdown modes on hardware that supports disabling hsync/vsync: |
| 995 | * blank_mode == 2: suspend vsync |
| 996 | * blank_mode == 3: suspend hsync |
| 997 | * blank_mode == 4: powerdown |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | * |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 999 | * Returns negative errno on error, or zero on success. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1000 | * |
| 1001 | */ |
| 1002 | static int pm2fb_blank(int blank_mode, struct fb_info *info) |
| 1003 | { |
Antonino A. Daplas | 6772a2e | 2006-01-09 20:53:10 -0800 | [diff] [blame] | 1004 | struct pm2fb_par *par = info->par; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | u32 video = par->video; |
| 1006 | |
| 1007 | DPRINTK("blank_mode %d\n", blank_mode); |
| 1008 | |
| 1009 | switch (blank_mode) { |
| 1010 | case FB_BLANK_UNBLANK: |
| 1011 | /* Screen: On */ |
| 1012 | video |= PM2F_VIDEO_ENABLE; |
| 1013 | break; |
| 1014 | case FB_BLANK_NORMAL: |
| 1015 | /* Screen: Off */ |
| 1016 | video &= ~PM2F_VIDEO_ENABLE; |
| 1017 | break; |
| 1018 | case FB_BLANK_VSYNC_SUSPEND: |
| 1019 | /* VSync: Off */ |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1020 | video &= ~(PM2F_VSYNC_MASK | PM2F_BLANK_LOW); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1021 | break; |
| 1022 | case FB_BLANK_HSYNC_SUSPEND: |
| 1023 | /* HSync: Off */ |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1024 | video &= ~(PM2F_HSYNC_MASK | PM2F_BLANK_LOW); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1025 | break; |
| 1026 | case FB_BLANK_POWERDOWN: |
| 1027 | /* HSync: Off, VSync: Off */ |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1028 | video &= ~(PM2F_VSYNC_MASK | PM2F_HSYNC_MASK | PM2F_BLANK_LOW); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | break; |
| 1030 | } |
| 1031 | set_video(par, video); |
| 1032 | return 0; |
| 1033 | } |
| 1034 | |
Antonino A. Daplas | 03b9ae4 | 2007-05-10 22:23:29 -0700 | [diff] [blame] | 1035 | static int pm2fb_sync(struct fb_info *info) |
| 1036 | { |
| 1037 | struct pm2fb_par *par = info->par; |
| 1038 | |
| 1039 | WAIT_FIFO(par, 1); |
| 1040 | pm2_WR(par, PM2R_SYNC, 0); |
| 1041 | mb(); |
| 1042 | do { |
| 1043 | while (pm2_RD(par, PM2R_OUT_FIFO_WORDS) == 0) |
Krzysztof Helt | 6416ad7 | 2007-10-16 01:29:27 -0700 | [diff] [blame] | 1044 | cpu_relax(); |
Antonino A. Daplas | 03b9ae4 | 2007-05-10 22:23:29 -0700 | [diff] [blame] | 1045 | } while (pm2_RD(par, PM2R_OUT_FIFO) != PM2TAG(PM2R_SYNC)); |
| 1046 | |
| 1047 | return 0; |
| 1048 | } |
| 1049 | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1050 | static void pm2fb_fillrect(struct fb_info *info, |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1051 | const struct fb_fillrect *region) |
| 1052 | { |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1053 | struct pm2fb_par *par = info->par; |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1054 | struct fb_fillrect modded; |
| 1055 | int vxres, vyres; |
| 1056 | u32 color = (info->fix.visual == FB_VISUAL_TRUECOLOR) ? |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1057 | ((u32 *)info->pseudo_palette)[region->color] : region->color; |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1058 | |
| 1059 | if (info->state != FBINFO_STATE_RUNNING) |
| 1060 | return; |
| 1061 | if ((info->flags & FBINFO_HWACCEL_DISABLED) || |
| 1062 | region->rop != ROP_COPY ) { |
| 1063 | cfb_fillrect(info, region); |
| 1064 | return; |
| 1065 | } |
| 1066 | |
| 1067 | vxres = info->var.xres_virtual; |
| 1068 | vyres = info->var.yres_virtual; |
| 1069 | |
| 1070 | memcpy(&modded, region, sizeof(struct fb_fillrect)); |
| 1071 | |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1072 | if (!modded.width || !modded.height || |
| 1073 | modded.dx >= vxres || modded.dy >= vyres) |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1074 | return; |
| 1075 | |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1076 | if (modded.dx + modded.width > vxres) |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1077 | modded.width = vxres - modded.dx; |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1078 | if (modded.dy + modded.height > vyres) |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1079 | modded.height = vyres - modded.dy; |
| 1080 | |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1081 | if (info->var.bits_per_pixel == 8) |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1082 | color |= color << 8; |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1083 | if (info->var.bits_per_pixel <= 16) |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1084 | color |= color << 16; |
| 1085 | |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1086 | WAIT_FIFO(par, 3); |
| 1087 | pm2_WR(par, PM2R_CONFIG, PM2F_CONFIG_FB_WRITE_ENABLE); |
| 1088 | pm2_WR(par, PM2R_RECTANGLE_ORIGIN, (modded.dy << 16) | modded.dx); |
| 1089 | pm2_WR(par, PM2R_RECTANGLE_SIZE, (modded.height << 16) | modded.width); |
| 1090 | if (info->var.bits_per_pixel != 24) { |
| 1091 | WAIT_FIFO(par, 2); |
| 1092 | pm2_WR(par, PM2R_FB_BLOCK_COLOR, color); |
| 1093 | wmb(); |
| 1094 | pm2_WR(par, PM2R_RENDER, |
| 1095 | PM2F_RENDER_RECTANGLE | PM2F_RENDER_FASTFILL); |
| 1096 | } else { |
Krzysztof Helt | 30dcc90 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 1097 | WAIT_FIFO(par, 4); |
| 1098 | pm2_WR(par, PM2R_COLOR_DDA_MODE, 1); |
| 1099 | pm2_WR(par, PM2R_CONSTANT_COLOR, color); |
| 1100 | wmb(); |
| 1101 | pm2_WR(par, PM2R_RENDER, |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1102 | PM2F_RENDER_RECTANGLE | |
| 1103 | PM2F_INCREASE_X | PM2F_INCREASE_Y ); |
Krzysztof Helt | 30dcc90 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 1104 | pm2_WR(par, PM2R_COLOR_DDA_MODE, 0); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1105 | } |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1106 | } |
| 1107 | |
| 1108 | static void pm2fb_copyarea(struct fb_info *info, |
| 1109 | const struct fb_copyarea *area) |
| 1110 | { |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1111 | struct pm2fb_par *par = info->par; |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1112 | struct fb_copyarea modded; |
| 1113 | u32 vxres, vyres; |
| 1114 | |
| 1115 | if (info->state != FBINFO_STATE_RUNNING) |
| 1116 | return; |
| 1117 | if (info->flags & FBINFO_HWACCEL_DISABLED) { |
| 1118 | cfb_copyarea(info, area); |
| 1119 | return; |
| 1120 | } |
| 1121 | |
| 1122 | memcpy(&modded, area, sizeof(struct fb_copyarea)); |
| 1123 | |
| 1124 | vxres = info->var.xres_virtual; |
| 1125 | vyres = info->var.yres_virtual; |
| 1126 | |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1127 | if (!modded.width || !modded.height || |
| 1128 | modded.sx >= vxres || modded.sy >= vyres || |
| 1129 | modded.dx >= vxres || modded.dy >= vyres) |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1130 | return; |
| 1131 | |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1132 | if (modded.sx + modded.width > vxres) |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1133 | modded.width = vxres - modded.sx; |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1134 | if (modded.dx + modded.width > vxres) |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1135 | modded.width = vxres - modded.dx; |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1136 | if (modded.sy + modded.height > vyres) |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1137 | modded.height = vyres - modded.sy; |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1138 | if (modded.dy + modded.height > vyres) |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1139 | modded.height = vyres - modded.dy; |
| 1140 | |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1141 | WAIT_FIFO(par, 5); |
| 1142 | pm2_WR(par, PM2R_CONFIG, PM2F_CONFIG_FB_WRITE_ENABLE | |
| 1143 | PM2F_CONFIG_FB_READ_SOURCE_ENABLE); |
| 1144 | pm2_WR(par, PM2R_FB_SOURCE_DELTA, |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1145 | ((modded.sy - modded.dy) & 0xfff) << 16 | |
| 1146 | ((modded.sx - modded.dx) & 0xfff)); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1147 | pm2_WR(par, PM2R_RECTANGLE_ORIGIN, (modded.dy << 16) | modded.dx); |
| 1148 | pm2_WR(par, PM2R_RECTANGLE_SIZE, (modded.height << 16) | modded.width); |
| 1149 | wmb(); |
| 1150 | pm2_WR(par, PM2R_RENDER, PM2F_RENDER_RECTANGLE | |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1151 | (modded.dx < modded.sx ? PM2F_INCREASE_X : 0) | |
| 1152 | (modded.dy < modded.sy ? PM2F_INCREASE_Y : 0)); |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1153 | } |
| 1154 | |
Krzysztof Helt | 91b3a6f | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1155 | static void pm2fb_imageblit(struct fb_info *info, const struct fb_image *image) |
| 1156 | { |
| 1157 | struct pm2fb_par *par = info->par; |
| 1158 | u32 height = image->height; |
| 1159 | u32 fgx, bgx; |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1160 | const u32 *src = (const u32 *)image->data; |
Krzysztof Helt | 91b3a6f | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1161 | u32 xres = (info->var.xres + 31) & ~31; |
Krzysztof Helt | bc9c6a1 | 2008-02-06 01:39:37 -0800 | [diff] [blame] | 1162 | int raster_mode = 1; /* invert bits */ |
| 1163 | |
| 1164 | #ifdef __LITTLE_ENDIAN |
| 1165 | raster_mode |= 3 << 7; /* reverse byte order */ |
| 1166 | #endif |
Krzysztof Helt | 91b3a6f | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1167 | |
| 1168 | if (info->state != FBINFO_STATE_RUNNING) |
| 1169 | return; |
| 1170 | if (info->flags & FBINFO_HWACCEL_DISABLED || image->depth != 1) { |
| 1171 | cfb_imageblit(info, image); |
| 1172 | return; |
| 1173 | } |
| 1174 | switch (info->fix.visual) { |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1175 | case FB_VISUAL_PSEUDOCOLOR: |
| 1176 | fgx = image->fg_color; |
| 1177 | bgx = image->bg_color; |
| 1178 | break; |
| 1179 | case FB_VISUAL_TRUECOLOR: |
| 1180 | default: |
| 1181 | fgx = par->palette[image->fg_color]; |
| 1182 | bgx = par->palette[image->bg_color]; |
| 1183 | break; |
Krzysztof Helt | 91b3a6f | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1184 | } |
| 1185 | if (info->var.bits_per_pixel == 8) { |
| 1186 | fgx |= fgx << 8; |
| 1187 | bgx |= bgx << 8; |
| 1188 | } |
| 1189 | if (info->var.bits_per_pixel <= 16) { |
| 1190 | fgx |= fgx << 16; |
| 1191 | bgx |= bgx << 16; |
| 1192 | } |
| 1193 | |
| 1194 | WAIT_FIFO(par, 13); |
| 1195 | pm2_WR(par, PM2R_FB_READ_MODE, partprod(xres)); |
| 1196 | pm2_WR(par, PM2R_SCISSOR_MIN_XY, |
| 1197 | ((image->dy & 0xfff) << 16) | (image->dx & 0x0fff)); |
| 1198 | pm2_WR(par, PM2R_SCISSOR_MAX_XY, |
| 1199 | (((image->dy + image->height) & 0x0fff) << 16) | |
| 1200 | ((image->dx + image->width) & 0x0fff)); |
| 1201 | pm2_WR(par, PM2R_SCISSOR_MODE, 1); |
| 1202 | /* GXcopy & UNIT_ENABLE */ |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1203 | pm2_WR(par, PM2R_LOGICAL_OP_MODE, (0x3 << 1) | 1); |
Krzysztof Helt | 91b3a6f | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1204 | pm2_WR(par, PM2R_RECTANGLE_ORIGIN, |
| 1205 | ((image->dy & 0xfff) << 16) | (image->dx & 0x0fff)); |
| 1206 | pm2_WR(par, PM2R_RECTANGLE_SIZE, |
| 1207 | ((image->height & 0x0fff) << 16) | |
| 1208 | ((image->width) & 0x0fff)); |
| 1209 | if (info->var.bits_per_pixel == 24) { |
| 1210 | pm2_WR(par, PM2R_COLOR_DDA_MODE, 1); |
| 1211 | /* clear area */ |
| 1212 | pm2_WR(par, PM2R_CONSTANT_COLOR, bgx); |
| 1213 | pm2_WR(par, PM2R_RENDER, |
| 1214 | PM2F_RENDER_RECTANGLE | |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1215 | PM2F_INCREASE_X | PM2F_INCREASE_Y); |
Krzysztof Helt | bc9c6a1 | 2008-02-06 01:39:37 -0800 | [diff] [blame] | 1216 | /* BitMapPackEachScanline */ |
| 1217 | pm2_WR(par, PM2R_RASTERIZER_MODE, raster_mode | (1 << 9)); |
Krzysztof Helt | 91b3a6f | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1218 | pm2_WR(par, PM2R_CONSTANT_COLOR, fgx); |
| 1219 | pm2_WR(par, PM2R_RENDER, |
| 1220 | PM2F_RENDER_RECTANGLE | |
| 1221 | PM2F_INCREASE_X | PM2F_INCREASE_Y | |
| 1222 | PM2F_RENDER_SYNC_ON_BIT_MASK); |
| 1223 | } else { |
| 1224 | pm2_WR(par, PM2R_COLOR_DDA_MODE, 0); |
| 1225 | /* clear area */ |
| 1226 | pm2_WR(par, PM2R_FB_BLOCK_COLOR, bgx); |
| 1227 | pm2_WR(par, PM2R_RENDER, |
| 1228 | PM2F_RENDER_RECTANGLE | |
| 1229 | PM2F_RENDER_FASTFILL | |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1230 | PM2F_INCREASE_X | PM2F_INCREASE_Y); |
Krzysztof Helt | bc9c6a1 | 2008-02-06 01:39:37 -0800 | [diff] [blame] | 1231 | pm2_WR(par, PM2R_RASTERIZER_MODE, raster_mode); |
Krzysztof Helt | 91b3a6f | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1232 | pm2_WR(par, PM2R_FB_BLOCK_COLOR, fgx); |
| 1233 | pm2_WR(par, PM2R_RENDER, |
| 1234 | PM2F_RENDER_RECTANGLE | |
| 1235 | PM2F_INCREASE_X | PM2F_INCREASE_Y | |
| 1236 | PM2F_RENDER_FASTFILL | |
| 1237 | PM2F_RENDER_SYNC_ON_BIT_MASK); |
| 1238 | } |
| 1239 | |
| 1240 | while (height--) { |
| 1241 | int width = ((image->width + 7) >> 3) |
| 1242 | + info->pixmap.scan_align - 1; |
| 1243 | width >>= 2; |
| 1244 | WAIT_FIFO(par, width); |
| 1245 | while (width--) { |
| 1246 | pm2_WR(par, PM2R_BIT_MASK_PATTERN, *src); |
| 1247 | src++; |
| 1248 | } |
| 1249 | } |
| 1250 | WAIT_FIFO(par, 3); |
| 1251 | pm2_WR(par, PM2R_RASTERIZER_MODE, 0); |
| 1252 | pm2_WR(par, PM2R_COLOR_DDA_MODE, 0); |
| 1253 | pm2_WR(par, PM2R_SCISSOR_MODE, 0); |
| 1254 | } |
| 1255 | |
Krzysztof Helt | 8f5d050 | 2007-10-16 01:28:53 -0700 | [diff] [blame] | 1256 | /* |
| 1257 | * Hardware cursor support. |
| 1258 | */ |
| 1259 | static const u8 cursor_bits_lookup[16] = { |
| 1260 | 0x00, 0x40, 0x10, 0x50, 0x04, 0x44, 0x14, 0x54, |
| 1261 | 0x01, 0x41, 0x11, 0x51, 0x05, 0x45, 0x15, 0x55 |
| 1262 | }; |
| 1263 | |
| 1264 | static int pm2vfb_cursor(struct fb_info *info, struct fb_cursor *cursor) |
| 1265 | { |
| 1266 | struct pm2fb_par *par = info->par; |
Krzysztof Helt | 2a36f9c | 2007-10-16 01:29:16 -0700 | [diff] [blame] | 1267 | u8 mode = PM2F_CURSORMODE_TYPE_X; |
Krzysztof Helt | 1ddc28d | 2007-10-16 01:29:16 -0700 | [diff] [blame] | 1268 | int x = cursor->image.dx - info->var.xoffset; |
| 1269 | int y = cursor->image.dy - info->var.yoffset; |
Krzysztof Helt | 8f5d050 | 2007-10-16 01:28:53 -0700 | [diff] [blame] | 1270 | |
Krzysztof Helt | 8f5d050 | 2007-10-16 01:28:53 -0700 | [diff] [blame] | 1271 | if (cursor->enable) |
| 1272 | mode |= PM2F_CURSORMODE_CURSOR_ENABLE; |
| 1273 | |
| 1274 | pm2v_RDAC_WR(par, PM2VI_RD_CURSOR_MODE, mode); |
| 1275 | |
Krzysztof Helt | 1ddc28d | 2007-10-16 01:29:16 -0700 | [diff] [blame] | 1276 | if (!cursor->enable) |
| 1277 | x = 2047; /* push it outside display */ |
| 1278 | pm2v_RDAC_WR(par, PM2VI_RD_CURSOR_X_LOW, x & 0xff); |
| 1279 | pm2v_RDAC_WR(par, PM2VI_RD_CURSOR_X_HIGH, (x >> 8) & 0xf); |
| 1280 | pm2v_RDAC_WR(par, PM2VI_RD_CURSOR_Y_LOW, y & 0xff); |
| 1281 | pm2v_RDAC_WR(par, PM2VI_RD_CURSOR_Y_HIGH, (y >> 8) & 0xf); |
| 1282 | |
Krzysztof Helt | 8f5d050 | 2007-10-16 01:28:53 -0700 | [diff] [blame] | 1283 | /* |
| 1284 | * If the cursor is not be changed this means either we want the |
| 1285 | * current cursor state (if enable is set) or we want to query what |
| 1286 | * we can do with the cursor (if enable is not set) |
| 1287 | */ |
| 1288 | if (!cursor->set) |
| 1289 | return 0; |
| 1290 | |
Krzysztof Helt | 8f5d050 | 2007-10-16 01:28:53 -0700 | [diff] [blame] | 1291 | if (cursor->set & FB_CUR_SETHOT) { |
| 1292 | pm2v_RDAC_WR(par, PM2VI_RD_CURSOR_X_HOT, |
| 1293 | cursor->hot.x & 0x3f); |
| 1294 | pm2v_RDAC_WR(par, PM2VI_RD_CURSOR_Y_HOT, |
| 1295 | cursor->hot.y & 0x3f); |
| 1296 | } |
| 1297 | |
| 1298 | if (cursor->set & FB_CUR_SETCMAP) { |
| 1299 | u32 fg_idx = cursor->image.fg_color; |
| 1300 | u32 bg_idx = cursor->image.bg_color; |
| 1301 | struct fb_cmap cmap = info->cmap; |
| 1302 | |
| 1303 | /* the X11 driver says one should use these color registers */ |
| 1304 | pm2_WR(par, PM2VR_RD_INDEX_HIGH, PM2VI_RD_CURSOR_PALETTE >> 8); |
| 1305 | pm2v_RDAC_WR(par, PM2VI_RD_CURSOR_PALETTE + 0, |
| 1306 | cmap.red[bg_idx] >> 8 ); |
| 1307 | pm2v_RDAC_WR(par, PM2VI_RD_CURSOR_PALETTE + 1, |
| 1308 | cmap.green[bg_idx] >> 8 ); |
| 1309 | pm2v_RDAC_WR(par, PM2VI_RD_CURSOR_PALETTE + 2, |
| 1310 | cmap.blue[bg_idx] >> 8 ); |
| 1311 | |
| 1312 | pm2v_RDAC_WR(par, PM2VI_RD_CURSOR_PALETTE + 3, |
| 1313 | cmap.red[fg_idx] >> 8 ); |
| 1314 | pm2v_RDAC_WR(par, PM2VI_RD_CURSOR_PALETTE + 4, |
| 1315 | cmap.green[fg_idx] >> 8 ); |
| 1316 | pm2v_RDAC_WR(par, PM2VI_RD_CURSOR_PALETTE + 5, |
| 1317 | cmap.blue[fg_idx] >> 8 ); |
| 1318 | pm2_WR(par, PM2VR_RD_INDEX_HIGH, 0); |
| 1319 | } |
| 1320 | |
| 1321 | if (cursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE)) { |
| 1322 | u8 *bitmap = (u8 *)cursor->image.data; |
| 1323 | u8 *mask = (u8 *)cursor->mask; |
| 1324 | int i; |
| 1325 | int pos = PM2VI_RD_CURSOR_PATTERN; |
| 1326 | |
| 1327 | for (i = 0; i < cursor->image.height; i++) { |
| 1328 | int j = (cursor->image.width + 7) >> 3; |
| 1329 | int k = 8 - j; |
| 1330 | |
| 1331 | pm2_WR(par, PM2VR_RD_INDEX_HIGH, pos >> 8); |
| 1332 | |
| 1333 | for (; j > 0; j--) { |
| 1334 | u8 data = *bitmap ^ *mask; |
| 1335 | |
| 1336 | if (cursor->rop == ROP_COPY) |
| 1337 | data = *mask & *bitmap; |
| 1338 | /* Upper 4 bits of bitmap data */ |
| 1339 | pm2v_RDAC_WR(par, pos++, |
| 1340 | cursor_bits_lookup[data >> 4] | |
| 1341 | (cursor_bits_lookup[*mask >> 4] << 1)); |
| 1342 | /* Lower 4 bits of bitmap */ |
| 1343 | pm2v_RDAC_WR(par, pos++, |
| 1344 | cursor_bits_lookup[data & 0xf] | |
| 1345 | (cursor_bits_lookup[*mask & 0xf] << 1)); |
| 1346 | bitmap++; |
| 1347 | mask++; |
| 1348 | } |
| 1349 | for (; k > 0; k--) { |
| 1350 | pm2v_RDAC_WR(par, pos++, 0); |
| 1351 | pm2v_RDAC_WR(par, pos++, 0); |
| 1352 | } |
| 1353 | } |
| 1354 | |
| 1355 | while (pos < (1024 + PM2VI_RD_CURSOR_PATTERN)) { |
| 1356 | pm2_WR(par, PM2VR_RD_INDEX_HIGH, pos >> 8); |
| 1357 | pm2v_RDAC_WR(par, pos++, 0); |
| 1358 | } |
| 1359 | |
| 1360 | pm2_WR(par, PM2VR_RD_INDEX_HIGH, 0); |
| 1361 | } |
| 1362 | return 0; |
| 1363 | } |
| 1364 | |
| 1365 | static int pm2fb_cursor(struct fb_info *info, struct fb_cursor *cursor) |
| 1366 | { |
| 1367 | struct pm2fb_par *par = info->par; |
Krzysztof Helt | 2a36f9c | 2007-10-16 01:29:16 -0700 | [diff] [blame] | 1368 | u8 mode; |
| 1369 | |
| 1370 | if (!hwcursor) |
| 1371 | return -EINVAL; /* just to force soft_cursor() call */ |
| 1372 | |
| 1373 | /* Too large of a cursor or wrong bpp :-( */ |
| 1374 | if (cursor->image.width > 64 || |
| 1375 | cursor->image.height > 64 || |
| 1376 | cursor->image.depth > 1) |
| 1377 | return -EINVAL; |
Krzysztof Helt | 8f5d050 | 2007-10-16 01:28:53 -0700 | [diff] [blame] | 1378 | |
| 1379 | if (par->type == PM2_TYPE_PERMEDIA2V) |
| 1380 | return pm2vfb_cursor(info, cursor); |
| 1381 | |
Krzysztof Helt | 1ddc28d | 2007-10-16 01:29:16 -0700 | [diff] [blame] | 1382 | mode = 0x40; |
Krzysztof Helt | 2a36f9c | 2007-10-16 01:29:16 -0700 | [diff] [blame] | 1383 | if (cursor->enable) |
| 1384 | mode = 0x43; |
| 1385 | |
| 1386 | pm2_RDAC_WR(par, PM2I_RD_CURSOR_CONTROL, mode); |
| 1387 | |
| 1388 | /* |
| 1389 | * If the cursor is not be changed this means either we want the |
| 1390 | * current cursor state (if enable is set) or we want to query what |
| 1391 | * we can do with the cursor (if enable is not set) |
| 1392 | */ |
| 1393 | if (!cursor->set) |
| 1394 | return 0; |
| 1395 | |
| 1396 | if (cursor->set & FB_CUR_SETPOS) { |
Krzysztof Helt | 1ddc28d | 2007-10-16 01:29:16 -0700 | [diff] [blame] | 1397 | int x = cursor->image.dx - info->var.xoffset + 63; |
| 1398 | int y = cursor->image.dy - info->var.yoffset + 63; |
Krzysztof Helt | 2a36f9c | 2007-10-16 01:29:16 -0700 | [diff] [blame] | 1399 | |
Krzysztof Helt | 2a36f9c | 2007-10-16 01:29:16 -0700 | [diff] [blame] | 1400 | WAIT_FIFO(par, 4); |
| 1401 | pm2_WR(par, PM2R_RD_CURSOR_X_LSB, x & 0xff); |
| 1402 | pm2_WR(par, PM2R_RD_CURSOR_X_MSB, (x >> 8) & 0x7); |
| 1403 | pm2_WR(par, PM2R_RD_CURSOR_Y_LSB, y & 0xff); |
| 1404 | pm2_WR(par, PM2R_RD_CURSOR_Y_MSB, (y >> 8) & 0x7); |
| 1405 | } |
| 1406 | |
| 1407 | if (cursor->set & FB_CUR_SETCMAP) { |
| 1408 | u32 fg_idx = cursor->image.fg_color; |
| 1409 | u32 bg_idx = cursor->image.bg_color; |
| 1410 | |
| 1411 | WAIT_FIFO(par, 7); |
| 1412 | pm2_WR(par, PM2R_RD_CURSOR_COLOR_ADDRESS, 1); |
| 1413 | pm2_WR(par, PM2R_RD_CURSOR_COLOR_DATA, |
| 1414 | info->cmap.red[bg_idx] >> 8); |
| 1415 | pm2_WR(par, PM2R_RD_CURSOR_COLOR_DATA, |
| 1416 | info->cmap.green[bg_idx] >> 8); |
| 1417 | pm2_WR(par, PM2R_RD_CURSOR_COLOR_DATA, |
| 1418 | info->cmap.blue[bg_idx] >> 8); |
| 1419 | |
| 1420 | pm2_WR(par, PM2R_RD_CURSOR_COLOR_DATA, |
| 1421 | info->cmap.red[fg_idx] >> 8); |
| 1422 | pm2_WR(par, PM2R_RD_CURSOR_COLOR_DATA, |
| 1423 | info->cmap.green[fg_idx] >> 8); |
| 1424 | pm2_WR(par, PM2R_RD_CURSOR_COLOR_DATA, |
| 1425 | info->cmap.blue[fg_idx] >> 8); |
| 1426 | } |
| 1427 | |
| 1428 | if (cursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE)) { |
| 1429 | u8 *bitmap = (u8 *)cursor->image.data; |
| 1430 | u8 *mask = (u8 *)cursor->mask; |
| 1431 | int i; |
| 1432 | |
| 1433 | WAIT_FIFO(par, 1); |
| 1434 | pm2_WR(par, PM2R_RD_PALETTE_WRITE_ADDRESS, 0); |
| 1435 | |
| 1436 | for (i = 0; i < cursor->image.height; i++) { |
| 1437 | int j = (cursor->image.width + 7) >> 3; |
| 1438 | int k = 8 - j; |
| 1439 | |
| 1440 | WAIT_FIFO(par, 8); |
| 1441 | for (; j > 0; j--) { |
| 1442 | u8 data = *bitmap ^ *mask; |
| 1443 | |
| 1444 | if (cursor->rop == ROP_COPY) |
| 1445 | data = *mask & *bitmap; |
| 1446 | /* bitmap data */ |
| 1447 | pm2_WR(par, PM2R_RD_CURSOR_DATA, data); |
| 1448 | bitmap++; |
| 1449 | mask++; |
| 1450 | } |
| 1451 | for (; k > 0; k--) |
| 1452 | pm2_WR(par, PM2R_RD_CURSOR_DATA, 0); |
| 1453 | } |
| 1454 | for (; i < 64; i++) { |
| 1455 | int j = 8; |
| 1456 | WAIT_FIFO(par, 8); |
| 1457 | while (j-- > 0) |
| 1458 | pm2_WR(par, PM2R_RD_CURSOR_DATA, 0); |
| 1459 | } |
| 1460 | |
| 1461 | mask = (u8 *)cursor->mask; |
| 1462 | for (i = 0; i < cursor->image.height; i++) { |
| 1463 | int j = (cursor->image.width + 7) >> 3; |
| 1464 | int k = 8 - j; |
| 1465 | |
| 1466 | WAIT_FIFO(par, 8); |
| 1467 | for (; j > 0; j--) { |
| 1468 | /* mask */ |
| 1469 | pm2_WR(par, PM2R_RD_CURSOR_DATA, *mask); |
| 1470 | mask++; |
| 1471 | } |
| 1472 | for (; k > 0; k--) |
| 1473 | pm2_WR(par, PM2R_RD_CURSOR_DATA, 0); |
| 1474 | } |
| 1475 | for (; i < 64; i++) { |
| 1476 | int j = 8; |
| 1477 | WAIT_FIFO(par, 8); |
| 1478 | while (j-- > 0) |
| 1479 | pm2_WR(par, PM2R_RD_CURSOR_DATA, 0); |
| 1480 | } |
| 1481 | } |
| 1482 | return 0; |
Krzysztof Helt | 8f5d050 | 2007-10-16 01:28:53 -0700 | [diff] [blame] | 1483 | } |
| 1484 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1485 | /* ------------ Hardware Independent Functions ------------ */ |
| 1486 | |
| 1487 | /* |
| 1488 | * Frame buffer operations |
| 1489 | */ |
| 1490 | |
| 1491 | static struct fb_ops pm2fb_ops = { |
| 1492 | .owner = THIS_MODULE, |
| 1493 | .fb_check_var = pm2fb_check_var, |
| 1494 | .fb_set_par = pm2fb_set_par, |
| 1495 | .fb_setcolreg = pm2fb_setcolreg, |
| 1496 | .fb_blank = pm2fb_blank, |
| 1497 | .fb_pan_display = pm2fb_pan_display, |
Krzysztof Helt | 87a7cc6 | 2007-05-08 00:40:02 -0700 | [diff] [blame] | 1498 | .fb_fillrect = pm2fb_fillrect, |
| 1499 | .fb_copyarea = pm2fb_copyarea, |
Krzysztof Helt | 91b3a6f | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1500 | .fb_imageblit = pm2fb_imageblit, |
Antonino A. Daplas | 03b9ae4 | 2007-05-10 22:23:29 -0700 | [diff] [blame] | 1501 | .fb_sync = pm2fb_sync, |
Krzysztof Helt | 8f5d050 | 2007-10-16 01:28:53 -0700 | [diff] [blame] | 1502 | .fb_cursor = pm2fb_cursor, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1503 | }; |
| 1504 | |
| 1505 | /* |
| 1506 | * PCI stuff |
| 1507 | */ |
| 1508 | |
| 1509 | |
| 1510 | /** |
| 1511 | * Device initialisation |
| 1512 | * |
| 1513 | * Initialise and allocate resource for PCI device. |
| 1514 | * |
| 1515 | * @param pdev PCI device. |
| 1516 | * @param id PCI device ID. |
| 1517 | */ |
| 1518 | static int __devinit pm2fb_probe(struct pci_dev *pdev, |
| 1519 | const struct pci_device_id *id) |
| 1520 | { |
| 1521 | struct pm2fb_par *default_par; |
| 1522 | struct fb_info *info; |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1523 | int err; |
| 1524 | int retval = -ENXIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1525 | |
| 1526 | err = pci_enable_device(pdev); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1527 | if (err) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1528 | printk(KERN_WARNING "pm2fb: Can't enable pdev: %d\n", err); |
| 1529 | return err; |
| 1530 | } |
| 1531 | |
Antonino A. Daplas | 6772a2e | 2006-01-09 20:53:10 -0800 | [diff] [blame] | 1532 | info = framebuffer_alloc(sizeof(struct pm2fb_par), &pdev->dev); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1533 | if (!info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1534 | return -ENOMEM; |
Antonino A. Daplas | 6772a2e | 2006-01-09 20:53:10 -0800 | [diff] [blame] | 1535 | default_par = info->par; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1536 | |
| 1537 | switch (pdev->device) { |
| 1538 | case PCI_DEVICE_ID_TI_TVP4020: |
| 1539 | strcpy(pm2fb_fix.id, "TVP4020"); |
| 1540 | default_par->type = PM2_TYPE_PERMEDIA2; |
| 1541 | break; |
| 1542 | case PCI_DEVICE_ID_3DLABS_PERMEDIA2: |
| 1543 | strcpy(pm2fb_fix.id, "Permedia2"); |
| 1544 | default_par->type = PM2_TYPE_PERMEDIA2; |
| 1545 | break; |
| 1546 | case PCI_DEVICE_ID_3DLABS_PERMEDIA2V: |
| 1547 | strcpy(pm2fb_fix.id, "Permedia2v"); |
| 1548 | default_par->type = PM2_TYPE_PERMEDIA2V; |
| 1549 | break; |
| 1550 | } |
| 1551 | |
| 1552 | pm2fb_fix.mmio_start = pci_resource_start(pdev, 0); |
| 1553 | pm2fb_fix.mmio_len = PM2_REGS_SIZE; |
| 1554 | |
| 1555 | #if defined(__BIG_ENDIAN) |
| 1556 | /* |
| 1557 | * PM2 has a 64k register file, mapped twice in 128k. Lower |
| 1558 | * map is little-endian, upper map is big-endian. |
| 1559 | */ |
| 1560 | pm2fb_fix.mmio_start += PM2_REGS_SIZE; |
| 1561 | DPRINTK("Adjusting register base for big-endian.\n"); |
| 1562 | #endif |
| 1563 | DPRINTK("Register base at 0x%lx\n", pm2fb_fix.mmio_start); |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 1564 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1565 | /* Registers - request region and map it. */ |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1566 | if (!request_mem_region(pm2fb_fix.mmio_start, pm2fb_fix.mmio_len, |
| 1567 | "pm2fb regbase")) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1568 | printk(KERN_WARNING "pm2fb: Can't reserve regbase.\n"); |
| 1569 | goto err_exit_neither; |
| 1570 | } |
| 1571 | default_par->v_regs = |
| 1572 | ioremap_nocache(pm2fb_fix.mmio_start, pm2fb_fix.mmio_len); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1573 | if (!default_par->v_regs) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1574 | printk(KERN_WARNING "pm2fb: Can't remap %s register area.\n", |
| 1575 | pm2fb_fix.id); |
| 1576 | release_mem_region(pm2fb_fix.mmio_start, pm2fb_fix.mmio_len); |
| 1577 | goto err_exit_neither; |
| 1578 | } |
| 1579 | |
| 1580 | /* Stash away memory register info for use when we reset the board */ |
| 1581 | default_par->mem_control = pm2_RD(default_par, PM2R_MEM_CONTROL); |
| 1582 | default_par->boot_address = pm2_RD(default_par, PM2R_BOOT_ADDRESS); |
| 1583 | default_par->mem_config = pm2_RD(default_par, PM2R_MEM_CONFIG); |
| 1584 | DPRINTK("MemControl 0x%x BootAddress 0x%x MemConfig 0x%x\n", |
| 1585 | default_par->mem_control, default_par->boot_address, |
| 1586 | default_par->mem_config); |
| 1587 | |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1588 | if (default_par->mem_control == 0 && |
Peter 'p2' De Schrijver | 9127fa2 | 2005-11-07 01:00:42 -0800 | [diff] [blame] | 1589 | default_par->boot_address == 0x31 && |
Krzysztof Helt | f1c15f9 | 2007-05-08 00:39:30 -0700 | [diff] [blame] | 1590 | default_par->mem_config == 0x259fffff) { |
Krzysztof Helt | 9a31f0f | 2007-05-08 00:39:57 -0700 | [diff] [blame] | 1591 | default_par->memclock = CVPPC_MEMCLOCK; |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1592 | default_par->mem_control = 0; |
| 1593 | default_par->boot_address = 0x20; |
| 1594 | default_par->mem_config = 0xe6002021; |
Krzysztof Helt | f1c15f9 | 2007-05-08 00:39:30 -0700 | [diff] [blame] | 1595 | if (pdev->subsystem_vendor == 0x1048 && |
| 1596 | pdev->subsystem_device == 0x0a31) { |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1597 | DPRINTK("subsystem_vendor: %04x, " |
| 1598 | "subsystem_device: %04x\n", |
Krzysztof Helt | f1c15f9 | 2007-05-08 00:39:30 -0700 | [diff] [blame] | 1599 | pdev->subsystem_vendor, pdev->subsystem_device); |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1600 | DPRINTK("We have not been initialized by VGA BIOS and " |
| 1601 | "are running on an Elsa Winner 2000 Office\n"); |
Krzysztof Helt | f1c15f9 | 2007-05-08 00:39:30 -0700 | [diff] [blame] | 1602 | DPRINTK("Initializing card timings manually...\n"); |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 1603 | default_par->memclock = 100000; |
Krzysztof Helt | f1c15f9 | 2007-05-08 00:39:30 -0700 | [diff] [blame] | 1604 | } |
| 1605 | if (pdev->subsystem_vendor == 0x3d3d && |
| 1606 | pdev->subsystem_device == 0x0100) { |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1607 | DPRINTK("subsystem_vendor: %04x, " |
| 1608 | "subsystem_device: %04x\n", |
Krzysztof Helt | f1c15f9 | 2007-05-08 00:39:30 -0700 | [diff] [blame] | 1609 | pdev->subsystem_vendor, pdev->subsystem_device); |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1610 | DPRINTK("We have not been initialized by VGA BIOS and " |
| 1611 | "are running on an 3dlabs reference board\n"); |
Krzysztof Helt | f1c15f9 | 2007-05-08 00:39:30 -0700 | [diff] [blame] | 1612 | DPRINTK("Initializing card timings manually...\n"); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1613 | default_par->memclock = 74894; |
Krzysztof Helt | f1c15f9 | 2007-05-08 00:39:30 -0700 | [diff] [blame] | 1614 | } |
Peter 'p2' De Schrijver | 9127fa2 | 2005-11-07 01:00:42 -0800 | [diff] [blame] | 1615 | } |
| 1616 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1617 | /* Now work out how big lfb is going to be. */ |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1618 | switch (default_par->mem_config & PM2F_MEM_CONFIG_RAM_MASK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1619 | case PM2F_MEM_BANKS_1: |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1620 | pm2fb_fix.smem_len = 0x200000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1621 | break; |
| 1622 | case PM2F_MEM_BANKS_2: |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1623 | pm2fb_fix.smem_len = 0x400000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1624 | break; |
| 1625 | case PM2F_MEM_BANKS_3: |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1626 | pm2fb_fix.smem_len = 0x600000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1627 | break; |
| 1628 | case PM2F_MEM_BANKS_4: |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1629 | pm2fb_fix.smem_len = 0x800000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1630 | break; |
| 1631 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1632 | pm2fb_fix.smem_start = pci_resource_start(pdev, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1633 | |
| 1634 | /* Linear frame buffer - request region and map it. */ |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1635 | if (!request_mem_region(pm2fb_fix.smem_start, pm2fb_fix.smem_len, |
| 1636 | "pm2fb smem")) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1637 | printk(KERN_WARNING "pm2fb: Can't reserve smem.\n"); |
| 1638 | goto err_exit_mmio; |
| 1639 | } |
Krzysztof Helt | 4560daa | 2007-05-08 00:40:12 -0700 | [diff] [blame] | 1640 | info->screen_base = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1641 | ioremap_nocache(pm2fb_fix.smem_start, pm2fb_fix.smem_len); |
Krzysztof Helt | 45f169e | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1642 | if (!info->screen_base) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1643 | printk(KERN_WARNING "pm2fb: Can't ioremap smem area.\n"); |
| 1644 | release_mem_region(pm2fb_fix.smem_start, pm2fb_fix.smem_len); |
| 1645 | goto err_exit_mmio; |
| 1646 | } |
| 1647 | |
Krzysztof Helt | d5383fc | 2007-10-16 01:28:33 -0700 | [diff] [blame] | 1648 | #ifdef CONFIG_MTRR |
| 1649 | default_par->mtrr_handle = -1; |
| 1650 | if (!nomtrr) |
| 1651 | default_par->mtrr_handle = |
| 1652 | mtrr_add(pm2fb_fix.smem_start, |
| 1653 | pm2fb_fix.smem_len, |
| 1654 | MTRR_TYPE_WRCOMB, 1); |
| 1655 | #endif |
| 1656 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1657 | info->fbops = &pm2fb_ops; |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 1658 | info->fix = pm2fb_fix; |
Antonino A. Daplas | 6772a2e | 2006-01-09 20:53:10 -0800 | [diff] [blame] | 1659 | info->pseudo_palette = default_par->palette; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1660 | info->flags = FBINFO_DEFAULT | |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 1661 | FBINFO_HWACCEL_YPAN | |
| 1662 | FBINFO_HWACCEL_COPYAREA | |
Krzysztof Helt | 91b3a6f | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1663 | FBINFO_HWACCEL_IMAGEBLIT | |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 1664 | FBINFO_HWACCEL_FILLRECT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1665 | |
Krzysztof Helt | 91b3a6f | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1666 | info->pixmap.addr = kmalloc(PM2_PIXMAP_SIZE, GFP_KERNEL); |
| 1667 | if (!info->pixmap.addr) { |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1668 | retval = -ENOMEM; |
Krzysztof Helt | 91b3a6f | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1669 | goto err_exit_pixmap; |
| 1670 | } |
| 1671 | info->pixmap.size = PM2_PIXMAP_SIZE; |
| 1672 | info->pixmap.buf_align = 4; |
| 1673 | info->pixmap.scan_align = 4; |
| 1674 | info->pixmap.access_align = 32; |
| 1675 | info->pixmap.flags = FB_PIXMAP_SYSTEM; |
| 1676 | |
Krzysztof Helt | d5383fc | 2007-10-16 01:28:33 -0700 | [diff] [blame] | 1677 | if (noaccel) { |
Krzysztof Helt | 91b3a6f | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1678 | printk(KERN_DEBUG "disabling acceleration\n"); |
| 1679 | info->flags |= FBINFO_HWACCEL_DISABLED; |
| 1680 | info->pixmap.scan_align = 1; |
Krzysztof Helt | d5383fc | 2007-10-16 01:28:33 -0700 | [diff] [blame] | 1681 | } |
| 1682 | |
Krzysztof Helt | 5eb81e80 | 2008-04-28 02:15:05 -0700 | [diff] [blame] | 1683 | if (!mode_option) |
| 1684 | mode_option = "640x480@60"; |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 1685 | |
Krzysztof Helt | 5eb81e80 | 2008-04-28 02:15:05 -0700 | [diff] [blame] | 1686 | err = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1687 | if (!err || err == 4) |
| 1688 | info->var = pm2fb_var; |
| 1689 | |
Krzysztof Helt | 2ae09f0 | 2008-04-28 02:14:51 -0700 | [diff] [blame] | 1690 | retval = fb_alloc_cmap(&info->cmap, 256, 0); |
| 1691 | if (retval < 0) |
Krzysztof Helt | 435d56f | 2007-05-08 00:40:16 -0700 | [diff] [blame] | 1692 | goto err_exit_both; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1693 | |
Krzysztof Helt | 2ae09f0 | 2008-04-28 02:14:51 -0700 | [diff] [blame] | 1694 | retval = register_framebuffer(info); |
| 1695 | if (retval < 0) |
Krzysztof Helt | 435d56f | 2007-05-08 00:40:16 -0700 | [diff] [blame] | 1696 | goto err_exit_all; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1697 | |
| 1698 | printk(KERN_INFO "fb%d: %s frame buffer device, memory = %dK.\n", |
Krzysztof Helt | 4560daa | 2007-05-08 00:40:12 -0700 | [diff] [blame] | 1699 | info->node, info->fix.id, pm2fb_fix.smem_len / 1024); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1700 | |
| 1701 | /* |
| 1702 | * Our driver data |
| 1703 | */ |
| 1704 | pci_set_drvdata(pdev, info); |
| 1705 | |
| 1706 | return 0; |
| 1707 | |
| 1708 | err_exit_all: |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 1709 | fb_dealloc_cmap(&info->cmap); |
| 1710 | err_exit_both: |
Krzysztof Helt | 91b3a6f | 2007-10-16 01:28:34 -0700 | [diff] [blame] | 1711 | kfree(info->pixmap.addr); |
| 1712 | err_exit_pixmap: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1713 | iounmap(info->screen_base); |
| 1714 | release_mem_region(pm2fb_fix.smem_start, pm2fb_fix.smem_len); |
| 1715 | err_exit_mmio: |
| 1716 | iounmap(default_par->v_regs); |
| 1717 | release_mem_region(pm2fb_fix.mmio_start, pm2fb_fix.mmio_len); |
| 1718 | err_exit_neither: |
| 1719 | framebuffer_release(info); |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1720 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1721 | } |
| 1722 | |
| 1723 | /** |
| 1724 | * Device removal. |
| 1725 | * |
| 1726 | * Release all device resources. |
| 1727 | * |
| 1728 | * @param pdev PCI device to clean up. |
| 1729 | */ |
| 1730 | static void __devexit pm2fb_remove(struct pci_dev *pdev) |
| 1731 | { |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1732 | struct fb_info *info = pci_get_drvdata(pdev); |
| 1733 | struct fb_fix_screeninfo *fix = &info->fix; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1734 | struct pm2fb_par *par = info->par; |
| 1735 | |
| 1736 | unregister_framebuffer(info); |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 1737 | |
Krzysztof Helt | d5383fc | 2007-10-16 01:28:33 -0700 | [diff] [blame] | 1738 | #ifdef CONFIG_MTRR |
| 1739 | if (par->mtrr_handle >= 0) |
| 1740 | mtrr_del(par->mtrr_handle, info->fix.smem_start, |
| 1741 | info->fix.smem_len); |
| 1742 | #endif /* CONFIG_MTRR */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1743 | iounmap(info->screen_base); |
| 1744 | release_mem_region(fix->smem_start, fix->smem_len); |
| 1745 | iounmap(par->v_regs); |
| 1746 | release_mem_region(fix->mmio_start, fix->mmio_len); |
| 1747 | |
| 1748 | pci_set_drvdata(pdev, NULL); |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1749 | kfree(info->pixmap.addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1750 | kfree(info); |
| 1751 | } |
| 1752 | |
| 1753 | static struct pci_device_id pm2fb_id_table[] = { |
| 1754 | { PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_TVP4020, |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 1755 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1756 | { PCI_VENDOR_ID_3DLABS, PCI_DEVICE_ID_3DLABS_PERMEDIA2, |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 1757 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1758 | { PCI_VENDOR_ID_3DLABS, PCI_DEVICE_ID_3DLABS_PERMEDIA2V, |
Krzysztof Helt | 138a451 | 2007-10-16 01:28:36 -0700 | [diff] [blame] | 1759 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1760 | { 0, } |
| 1761 | }; |
| 1762 | |
| 1763 | static struct pci_driver pm2fb_driver = { |
| 1764 | .name = "pm2fb", |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 1765 | .id_table = pm2fb_id_table, |
| 1766 | .probe = pm2fb_probe, |
| 1767 | .remove = __devexit_p(pm2fb_remove), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1768 | }; |
| 1769 | |
| 1770 | MODULE_DEVICE_TABLE(pci, pm2fb_id_table); |
| 1771 | |
| 1772 | |
| 1773 | #ifndef MODULE |
| 1774 | /** |
| 1775 | * Parse user speficied options. |
| 1776 | * |
| 1777 | * This is, comma-separated options following `video=pm2fb:'. |
| 1778 | */ |
| 1779 | static int __init pm2fb_setup(char *options) |
| 1780 | { |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1781 | char *this_opt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1782 | |
| 1783 | if (!options || !*options) |
| 1784 | return 0; |
| 1785 | |
Krzysztof Helt | 2f7bb99 | 2007-07-17 04:05:31 -0700 | [diff] [blame] | 1786 | while ((this_opt = strsep(&options, ",")) != NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1787 | if (!*this_opt) |
| 1788 | continue; |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1789 | if (!strcmp(this_opt, "lowhsync")) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1790 | lowhsync = 1; |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1791 | else if (!strcmp(this_opt, "lowvsync")) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1792 | lowvsync = 1; |
Krzysztof Helt | 8f5d050 | 2007-10-16 01:28:53 -0700 | [diff] [blame] | 1793 | else if (!strncmp(this_opt, "hwcursor=", 9)) |
| 1794 | hwcursor = simple_strtoul(this_opt + 9, NULL, 0); |
Krzysztof Helt | d5383fc | 2007-10-16 01:28:33 -0700 | [diff] [blame] | 1795 | #ifdef CONFIG_MTRR |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1796 | else if (!strncmp(this_opt, "nomtrr", 6)) |
Krzysztof Helt | d5383fc | 2007-10-16 01:28:33 -0700 | [diff] [blame] | 1797 | nomtrr = 1; |
| 1798 | #endif |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1799 | else if (!strncmp(this_opt, "noaccel", 7)) |
Krzysztof Helt | d5383fc | 2007-10-16 01:28:33 -0700 | [diff] [blame] | 1800 | noaccel = 1; |
Krzysztof Helt | 3843faa | 2007-10-16 01:28:50 -0700 | [diff] [blame] | 1801 | else |
Krzysztof Helt | 5eb81e80 | 2008-04-28 02:15:05 -0700 | [diff] [blame] | 1802 | mode_option = this_opt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1803 | } |
| 1804 | return 0; |
| 1805 | } |
| 1806 | #endif |
| 1807 | |
| 1808 | |
| 1809 | static int __init pm2fb_init(void) |
| 1810 | { |
| 1811 | #ifndef MODULE |
| 1812 | char *option = NULL; |
| 1813 | |
| 1814 | if (fb_get_options("pm2fb", &option)) |
| 1815 | return -ENODEV; |
| 1816 | pm2fb_setup(option); |
| 1817 | #endif |
| 1818 | |
| 1819 | return pci_register_driver(&pm2fb_driver); |
| 1820 | } |
| 1821 | |
| 1822 | module_init(pm2fb_init); |
| 1823 | |
| 1824 | #ifdef MODULE |
| 1825 | /* |
| 1826 | * Cleanup |
| 1827 | */ |
| 1828 | |
| 1829 | static void __exit pm2fb_exit(void) |
| 1830 | { |
| 1831 | pci_unregister_driver(&pm2fb_driver); |
| 1832 | } |
| 1833 | #endif |
| 1834 | |
| 1835 | #ifdef MODULE |
| 1836 | module_exit(pm2fb_exit); |
| 1837 | |
Krzysztof Helt | 5eb81e80 | 2008-04-28 02:15:05 -0700 | [diff] [blame] | 1838 | module_param(mode_option, charp, 0); |
| 1839 | MODULE_PARM_DESC(mode_option, "Initial video mode e.g. '648x480-8@60'"); |
Krzysztof Helt | 9e3f0ca | 2008-04-28 02:15:10 -0700 | [diff] [blame^] | 1840 | module_param_named(mode, mode_option, charp, 0); |
| 1841 | MODULE_PARM_DESC(mode, "Initial video mode e.g. '648x480-8@60' (deprecated)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1842 | module_param(lowhsync, bool, 0); |
| 1843 | MODULE_PARM_DESC(lowhsync, "Force horizontal sync low regardless of mode"); |
| 1844 | module_param(lowvsync, bool, 0); |
| 1845 | MODULE_PARM_DESC(lowvsync, "Force vertical sync low regardless of mode"); |
Krzysztof Helt | d5383fc | 2007-10-16 01:28:33 -0700 | [diff] [blame] | 1846 | module_param(noaccel, bool, 0); |
| 1847 | MODULE_PARM_DESC(noaccel, "Disable acceleration"); |
Krzysztof Helt | 8f5d050 | 2007-10-16 01:28:53 -0700 | [diff] [blame] | 1848 | module_param(hwcursor, int, 0644); |
| 1849 | MODULE_PARM_DESC(hwcursor, "Enable hardware cursor " |
Krzysztof Helt | 1ddc28d | 2007-10-16 01:29:16 -0700 | [diff] [blame] | 1850 | "(1=enable, 0=disable, default=1)"); |
Krzysztof Helt | d5383fc | 2007-10-16 01:28:33 -0700 | [diff] [blame] | 1851 | #ifdef CONFIG_MTRR |
| 1852 | module_param(nomtrr, bool, 0); |
| 1853 | MODULE_PARM_DESC(nomtrr, "Disable MTRR support (0 or 1=disabled) (default=0)"); |
| 1854 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1855 | |
| 1856 | MODULE_AUTHOR("Jim Hague <jim.hague@acm.org>"); |
| 1857 | MODULE_DESCRIPTION("Permedia2 framebuffer device driver"); |
| 1858 | MODULE_LICENSE("GPL"); |
| 1859 | #endif |