Blame view
drivers/video/arkfb.c
32.5 KB
681e14730 arkfb: new frameb... |
1 2 3 4 5 6 7 8 9 10 11 12 |
/* * linux/drivers/video/arkfb.c -- Frame buffer device driver for ARK 2000PV * with ICS 5342 dac (it is easy to add support for different dacs). * * Copyright (c) 2007 Ondrej Zajicek <santiago@crfreenet.org> * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive for * more details. * * Code is based on s3fb */ |
681e14730 arkfb: new frameb... |
13 14 15 16 17 18 19 20 21 22 23 24 |
#include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/mm.h> #include <linux/tty.h> #include <linux/slab.h> #include <linux/delay.h> #include <linux/fb.h> #include <linux/svga.h> #include <linux/init.h> #include <linux/pci.h> |
ac751efa6 console: rename a... |
25 |
#include <linux/console.h> /* Why should fb driver call console functions? because console_lock() */ |
681e14730 arkfb: new frameb... |
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
#include <video/vga.h> #ifdef CONFIG_MTRR #include <asm/mtrr.h> #endif struct arkfb_info { int mclk_freq; int mtrr_reg; struct dac_info *dac; struct vgastate state; struct mutex open_lock; unsigned int ref_count; u32 pseudo_palette[16]; }; /* ------------------------------------------------------------------------- */ static const struct svga_fb_format arkfb_formats[] = { { 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, FB_TYPE_TEXT, FB_AUX_TEXT_SVGA_STEP4, FB_VISUAL_PSEUDOCOLOR, 8, 8}, { 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 8, 16}, { 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 1, FB_TYPE_INTERLEAVED_PLANES, 1, FB_VISUAL_PSEUDOCOLOR, 8, 16}, { 8, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0, FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 8, 8}, {16, {10, 5, 0}, {5, 5, 0}, {0, 5, 0}, {0, 0, 0}, 0, FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 4, 4}, {16, {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0}, 0, FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 4, 4}, {24, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0, FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 8, 8}, {32, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0, FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 2, 2}, SVGA_FORMAT_END }; /* CRT timing register sets */ static const struct vga_regset ark_h_total_regs[] = {{0x00, 0, 7}, {0x41, 7, 7}, VGA_REGSET_END}; static const struct vga_regset ark_h_display_regs[] = {{0x01, 0, 7}, {0x41, 6, 6}, VGA_REGSET_END}; static const struct vga_regset ark_h_blank_start_regs[] = {{0x02, 0, 7}, {0x41, 5, 5}, VGA_REGSET_END}; static const struct vga_regset ark_h_blank_end_regs[] = {{0x03, 0, 4}, {0x05, 7, 7 }, VGA_REGSET_END}; static const struct vga_regset ark_h_sync_start_regs[] = {{0x04, 0, 7}, {0x41, 4, 4}, VGA_REGSET_END}; static const struct vga_regset ark_h_sync_end_regs[] = {{0x05, 0, 4}, VGA_REGSET_END}; static const struct vga_regset ark_v_total_regs[] = {{0x06, 0, 7}, {0x07, 0, 0}, {0x07, 5, 5}, {0x40, 7, 7}, VGA_REGSET_END}; static const struct vga_regset ark_v_display_regs[] = {{0x12, 0, 7}, {0x07, 1, 1}, {0x07, 6, 6}, {0x40, 6, 6}, VGA_REGSET_END}; static const struct vga_regset ark_v_blank_start_regs[] = {{0x15, 0, 7}, {0x07, 3, 3}, {0x09, 5, 5}, {0x40, 5, 5}, VGA_REGSET_END}; // const struct vga_regset ark_v_blank_end_regs[] = {{0x16, 0, 6}, VGA_REGSET_END}; static const struct vga_regset ark_v_blank_end_regs[] = {{0x16, 0, 7}, VGA_REGSET_END}; static const struct vga_regset ark_v_sync_start_regs[] = {{0x10, 0, 7}, {0x07, 2, 2}, {0x07, 7, 7}, {0x40, 4, 4}, VGA_REGSET_END}; static const struct vga_regset ark_v_sync_end_regs[] = {{0x11, 0, 3}, VGA_REGSET_END}; static const struct vga_regset ark_line_compare_regs[] = {{0x18, 0, 7}, {0x07, 4, 4}, {0x09, 6, 6}, VGA_REGSET_END}; static const struct vga_regset ark_start_address_regs[] = {{0x0d, 0, 7}, {0x0c, 0, 7}, {0x40, 0, 2}, VGA_REGSET_END}; static const struct vga_regset ark_offset_regs[] = {{0x13, 0, 7}, {0x41, 3, 3}, VGA_REGSET_END}; static const struct svga_timing_regs ark_timing_regs = { ark_h_total_regs, ark_h_display_regs, ark_h_blank_start_regs, ark_h_blank_end_regs, ark_h_sync_start_regs, ark_h_sync_end_regs, ark_v_total_regs, ark_v_display_regs, ark_v_blank_start_regs, ark_v_blank_end_regs, ark_v_sync_start_regs, ark_v_sync_end_regs, }; /* ------------------------------------------------------------------------- */ /* Module parameters */ |
1abf91729 arkfb: add option... |
101 |
static char *mode_option __devinitdata = "640x480-8@60"; |
681e14730 arkfb: new frameb... |
102 103 104 105 106 107 108 109 |
#ifdef CONFIG_MTRR static int mtrr = 1; #endif MODULE_AUTHOR("(c) 2007 Ondrej Zajicek <santiago@crfreenet.org>"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("fbdev driver for ARK 2000PV"); |
1abf91729 arkfb: add option... |
110 111 112 113 |
module_param(mode_option, charp, 0444); MODULE_PARM_DESC(mode_option, "Default video mode ('640x480-8@60', etc)"); module_param_named(mode, mode_option, charp, 0444); MODULE_PARM_DESC(mode, "Default video mode ('640x480-8@60', etc) (deprecated)"); |
681e14730 arkfb: new frameb... |
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
#ifdef CONFIG_MTRR module_param(mtrr, int, 0444); MODULE_PARM_DESC(mtrr, "Enable write-combining with MTRR (1=enable, 0=disable, default=1)"); #endif static int threshold = 4; module_param(threshold, int, 0644); MODULE_PARM_DESC(threshold, "FIFO threshold"); /* ------------------------------------------------------------------------- */ static void arkfb_settile(struct fb_info *info, struct fb_tilemap *map) { const u8 *font = map->data; u8 __iomem *fb = (u8 __iomem *)info->screen_base; int i, c; if ((map->width != 8) || (map->height != 16) || (map->depth != 1) || (map->length != 256)) { printk(KERN_ERR "fb%d: unsupported font parameters: width %d, " "height %d, depth %d, length %d ", info->node, map->width, map->height, map->depth, map->length); return; } fb += 2; for (c = 0; c < map->length; c++) { for (i = 0; i < map->height; i++) { fb_writeb(font[i], &fb[i * 4]); fb_writeb(font[i], &fb[i * 4 + (128 * 8)]); } fb += 128; if ((c % 8) == 7) fb += 128*8; font += map->height; } } |
55db09238 svga: Make svga_t... |
158 159 160 161 162 163 |
static void arkfb_tilecursor(struct fb_info *info, struct fb_tilecursor *cursor) { struct arkfb_info *par = info->par; svga_tilecursor(par->state.vgabase, info, cursor); } |
681e14730 arkfb: new frameb... |
164 165 166 167 168 |
static struct fb_tile_ops arkfb_tile_ops = { .fb_settile = arkfb_settile, .fb_tilecopy = svga_tilecopy, .fb_tilefill = svga_tilefill, .fb_tileblit = svga_tileblit, |
55db09238 svga: Make svga_t... |
169 |
.fb_tilecursor = arkfb_tilecursor, |
681e14730 arkfb: new frameb... |
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 |
.fb_get_tilemax = svga_get_tilemax, }; /* ------------------------------------------------------------------------- */ /* image data is MSB-first, fb structure is MSB-first too */ static inline u32 expand_color(u32 c) { return ((c & 1) | ((c & 2) << 7) | ((c & 4) << 14) | ((c & 8) << 21)) * 0xFF; } /* arkfb_iplan_imageblit silently assumes that almost everything is 8-pixel aligned */ static void arkfb_iplan_imageblit(struct fb_info *info, const struct fb_image *image) { u32 fg = expand_color(image->fg_color); u32 bg = expand_color(image->bg_color); const u8 *src1, *src; u8 __iomem *dst1; u32 __iomem *dst; u32 val; int x, y; src1 = image->data; dst1 = info->screen_base + (image->dy * info->fix.line_length) + ((image->dx / 8) * 4); for (y = 0; y < image->height; y++) { src = src1; dst = (u32 __iomem *) dst1; for (x = 0; x < image->width; x += 8) { val = *(src++) * 0x01010101; val = (val & fg) | (~val & bg); fb_writel(val, dst++); } src1 += image->width / 8; dst1 += info->fix.line_length; } } /* arkfb_iplan_fillrect silently assumes that almost everything is 8-pixel aligned */ static void arkfb_iplan_fillrect(struct fb_info *info, const struct fb_fillrect *rect) { u32 fg = expand_color(rect->color); u8 __iomem *dst1; u32 __iomem *dst; int x, y; dst1 = info->screen_base + (rect->dy * info->fix.line_length) + ((rect->dx / 8) * 4); for (y = 0; y < rect->height; y++) { dst = (u32 __iomem *) dst1; for (x = 0; x < rect->width; x += 8) { fb_writel(fg, dst++); } dst1 += info->fix.line_length; } } /* image data is MSB-first, fb structure is high-nibble-in-low-byte-first */ static inline u32 expand_pixel(u32 c) { return (((c & 1) << 24) | ((c & 2) << 27) | ((c & 4) << 14) | ((c & 8) << 17) | ((c & 16) << 4) | ((c & 32) << 7) | ((c & 64) >> 6) | ((c & 128) >> 3)) * 0xF; } /* arkfb_cfb4_imageblit silently assumes that almost everything is 8-pixel aligned */ static void arkfb_cfb4_imageblit(struct fb_info *info, const struct fb_image *image) { u32 fg = image->fg_color * 0x11111111; u32 bg = image->bg_color * 0x11111111; const u8 *src1, *src; u8 __iomem *dst1; u32 __iomem *dst; u32 val; int x, y; src1 = image->data; dst1 = info->screen_base + (image->dy * info->fix.line_length) + ((image->dx / 8) * 4); for (y = 0; y < image->height; y++) { src = src1; dst = (u32 __iomem *) dst1; for (x = 0; x < image->width; x += 8) { val = expand_pixel(*(src++)); val = (val & fg) | (~val & bg); fb_writel(val, dst++); } src1 += image->width / 8; dst1 += info->fix.line_length; } } static void arkfb_imageblit(struct fb_info *info, const struct fb_image *image) { if ((info->var.bits_per_pixel == 4) && (image->depth == 1) && ((image->width % 8) == 0) && ((image->dx % 8) == 0)) { if (info->fix.type == FB_TYPE_INTERLEAVED_PLANES) arkfb_iplan_imageblit(info, image); else arkfb_cfb4_imageblit(info, image); } else cfb_imageblit(info, image); } static void arkfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) { if ((info->var.bits_per_pixel == 4) && ((rect->width % 8) == 0) && ((rect->dx % 8) == 0) && (info->fix.type == FB_TYPE_INTERLEAVED_PLANES)) arkfb_iplan_fillrect(info, rect); else cfb_fillrect(info, rect); } /* ------------------------------------------------------------------------- */ enum { DAC_PSEUDO8_8, DAC_RGB1555_8, DAC_RGB0565_8, DAC_RGB0888_8, DAC_RGB8888_8, DAC_PSEUDO8_16, DAC_RGB1555_16, DAC_RGB0565_16, DAC_RGB0888_16, DAC_RGB8888_16, DAC_MAX }; struct dac_ops { int (*dac_get_mode)(struct dac_info *info); int (*dac_set_mode)(struct dac_info *info, int mode); int (*dac_get_freq)(struct dac_info *info, int channel); int (*dac_set_freq)(struct dac_info *info, int channel, u32 freq); void (*dac_release)(struct dac_info *info); }; typedef void (*dac_read_regs_t)(void *data, u8 *code, int count); typedef void (*dac_write_regs_t)(void *data, u8 *code, int count); struct dac_info { struct dac_ops *dacops; dac_read_regs_t dac_read_regs; dac_write_regs_t dac_write_regs; void *data; }; static inline u8 dac_read_reg(struct dac_info *info, u8 reg) { u8 code[2] = {reg, 0}; info->dac_read_regs(info->data, code, 1); return code[1]; } static inline void dac_read_regs(struct dac_info *info, u8 *code, int count) { info->dac_read_regs(info->data, code, count); } static inline void dac_write_reg(struct dac_info *info, u8 reg, u8 val) { u8 code[2] = {reg, val}; info->dac_write_regs(info->data, code, 1); } static inline void dac_write_regs(struct dac_info *info, u8 *code, int count) { info->dac_write_regs(info->data, code, count); } static inline int dac_set_mode(struct dac_info *info, int mode) { return info->dacops->dac_set_mode(info, mode); } static inline int dac_set_freq(struct dac_info *info, int channel, u32 freq) { return info->dacops->dac_set_freq(info, channel, freq); } static inline void dac_release(struct dac_info *info) { info->dacops->dac_release(info); } /* ------------------------------------------------------------------------- */ /* ICS5342 DAC */ struct ics5342_info { struct dac_info dac; u8 mode; }; #define DAC_PAR(info) ((struct ics5342_info *) info) /* LSB is set to distinguish unused slots */ static const u8 ics5342_mode_table[DAC_MAX] = { [DAC_PSEUDO8_8] = 0x01, [DAC_RGB1555_8] = 0x21, [DAC_RGB0565_8] = 0x61, [DAC_RGB0888_8] = 0x41, [DAC_PSEUDO8_16] = 0x11, [DAC_RGB1555_16] = 0x31, [DAC_RGB0565_16] = 0x51, [DAC_RGB0888_16] = 0x91, [DAC_RGB8888_16] = 0x71 }; static int ics5342_set_mode(struct dac_info *info, int mode) { u8 code; if (mode >= DAC_MAX) return -EINVAL; code = ics5342_mode_table[mode]; if (! code) return -EINVAL; dac_write_reg(info, 6, code & 0xF0); DAC_PAR(info)->mode = mode; return 0; } static const struct svga_pll ics5342_pll = {3, 129, 3, 33, 0, 3, 60000, 250000, 14318}; /* pd4 - allow only posdivider 4 (r=2) */ static const struct svga_pll ics5342_pll_pd4 = {3, 129, 3, 33, 2, 2, 60000, 335000, 14318}; /* 270 MHz should be upper bound for VCO clock according to specs, but that is too restrictive in pd4 case */ static int ics5342_set_freq(struct dac_info *info, int channel, u32 freq) { u16 m, n, r; /* only postdivider 4 (r=2) is valid in mode DAC_PSEUDO8_16 */ int rv = svga_compute_pll((DAC_PAR(info)->mode == DAC_PSEUDO8_16) ? &ics5342_pll_pd4 : &ics5342_pll, freq, &m, &n, &r, 0); if (rv < 0) { return -EINVAL; } else { u8 code[6] = {4, 3, 5, m-2, 5, (n-2) | (r << 5)}; dac_write_regs(info, code, 3); return 0; } } static void ics5342_release(struct dac_info *info) { ics5342_set_mode(info, DAC_PSEUDO8_8); kfree(info); } static struct dac_ops ics5342_ops = { .dac_set_mode = ics5342_set_mode, .dac_set_freq = ics5342_set_freq, .dac_release = ics5342_release }; static struct dac_info * ics5342_init(dac_read_regs_t drr, dac_write_regs_t dwr, void *data) { struct dac_info *info = kzalloc(sizeof(struct ics5342_info), GFP_KERNEL); if (! info) return NULL; info->dacops = &ics5342_ops; info->dac_read_regs = drr; info->dac_write_regs = dwr; info->data = data; DAC_PAR(info)->mode = DAC_PSEUDO8_8; /* estimation */ return info; } /* ------------------------------------------------------------------------- */ static unsigned short dac_regs[4] = {0x3c8, 0x3c9, 0x3c6, 0x3c7}; static void ark_dac_read_regs(void *data, u8 *code, int count) { |
c5e04633b arkfb: Pass par->... |
472 473 474 |
struct fb_info *info = data; struct arkfb_info *par; u8 regval; |
681e14730 arkfb: new frameb... |
475 |
|
c5e04633b arkfb: Pass par->... |
476 477 |
par = info->par; regval = vga_rseq(par->state.vgabase, 0x1C); |
681e14730 arkfb: new frameb... |
478 479 |
while (count != 0) { |
c5e04633b arkfb: Pass par->... |
480 481 |
vga_wseq(par->state.vgabase, 0x1C, regval | (code[0] & 4 ? 0x80 : 0)); code[1] = vga_r(par->state.vgabase, dac_regs[code[0] & 3]); |
681e14730 arkfb: new frameb... |
482 483 484 |
count--; code += 2; } |
c5e04633b arkfb: Pass par->... |
485 |
vga_wseq(par->state.vgabase, 0x1C, regval); |
681e14730 arkfb: new frameb... |
486 487 488 489 |
} static void ark_dac_write_regs(void *data, u8 *code, int count) { |
c5e04633b arkfb: Pass par->... |
490 491 492 |
struct fb_info *info = data; struct arkfb_info *par; u8 regval; |
681e14730 arkfb: new frameb... |
493 |
|
c5e04633b arkfb: Pass par->... |
494 495 |
par = info->par; regval = vga_rseq(par->state.vgabase, 0x1C); |
681e14730 arkfb: new frameb... |
496 497 |
while (count != 0) { |
c5e04633b arkfb: Pass par->... |
498 499 |
vga_wseq(par->state.vgabase, 0x1C, regval | (code[0] & 4 ? 0x80 : 0)); vga_w(par->state.vgabase, dac_regs[code[0] & 3], code[1]); |
681e14730 arkfb: new frameb... |
500 501 502 |
count--; code += 2; } |
c5e04633b arkfb: Pass par->... |
503 |
vga_wseq(par->state.vgabase, 0x1C, regval); |
681e14730 arkfb: new frameb... |
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
} static void ark_set_pixclock(struct fb_info *info, u32 pixclock) { struct arkfb_info *par = info->par; u8 regval; int rv = dac_set_freq(par->dac, 0, 1000000000 / pixclock); if (rv < 0) { printk(KERN_ERR "fb%d: cannot set requested pixclock, keeping old value ", info->node); return; } /* Set VGA misc register */ |
c5e04633b arkfb: Pass par->... |
520 521 |
regval = vga_r(par->state.vgabase, VGA_MIS_R); vga_w(par->state.vgabase, VGA_MIS_W, regval | VGA_MIS_ENB_PLL_LOAD); |
681e14730 arkfb: new frameb... |
522 523 524 525 526 527 528 529 530 531 532 |
} /* Open framebuffer */ static int arkfb_open(struct fb_info *info, int user) { struct arkfb_info *par = info->par; mutex_lock(&(par->open_lock)); if (par->ref_count == 0) { |
ec70a9435 arkfb: Don't clob... |
533 |
void __iomem *vgabase = par->state.vgabase; |
681e14730 arkfb: new frameb... |
534 |
memset(&(par->state), 0, sizeof(struct vgastate)); |
ec70a9435 arkfb: Don't clob... |
535 |
par->state.vgabase = vgabase; |
681e14730 arkfb: new frameb... |
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 |
par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS | VGA_SAVE_CMAP; par->state.num_crtc = 0x60; par->state.num_seq = 0x30; save_vga(&(par->state)); } par->ref_count++; mutex_unlock(&(par->open_lock)); return 0; } /* Close framebuffer */ static int arkfb_release(struct fb_info *info, int user) { struct arkfb_info *par = info->par; mutex_lock(&(par->open_lock)); if (par->ref_count == 0) { mutex_unlock(&(par->open_lock)); return -EINVAL; } if (par->ref_count == 1) { restore_vga(&(par->state)); dac_set_mode(par->dac, DAC_PSEUDO8_8); } par->ref_count--; mutex_unlock(&(par->open_lock)); return 0; } /* Validate passed in var */ static int arkfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { int rv, mem, step; /* Find appropriate format */ rv = svga_match_format (arkfb_formats, var, NULL); if (rv < 0) { printk(KERN_ERR "fb%d: unsupported mode requested ", info->node); return rv; } /* Do not allow to have real resoulution larger than virtual */ if (var->xres > var->xres_virtual) var->xres_virtual = var->xres; if (var->yres > var->yres_virtual) var->yres_virtual = var->yres; /* Round up xres_virtual to have proper alignment of lines */ step = arkfb_formats[rv].xresstep - 1; var->xres_virtual = (var->xres_virtual+step) & ~step; /* Check whether have enough memory */ mem = ((var->bits_per_pixel * var->xres_virtual) >> 3) * var->yres_virtual; if (mem > info->screen_size) { printk(KERN_ERR "fb%d: not enough framebuffer memory (%d kB requested , %d kB available) ", info->node, mem >> 10, (unsigned int) (info->screen_size >> 10)); return -EINVAL; } rv = svga_check_timings (&ark_timing_regs, var, info->node); if (rv < 0) { printk(KERN_ERR "fb%d: invalid timings requested ", info->node); return rv; } /* Interlaced mode is broken */ if (var->vmode & FB_VMODE_INTERLACED) return -EINVAL; return 0; } /* Set video mode from par */ static int arkfb_set_par(struct fb_info *info) { struct arkfb_info *par = info->par; u32 value, mode, hmul, hdiv, offset_value, screen_size; u32 bpp = info->var.bits_per_pixel; u8 regval; if (bpp != 0) { info->fix.ypanstep = 1; info->fix.line_length = (info->var.xres_virtual * bpp) / 8; info->flags &= ~FBINFO_MISC_TILEBLITTING; info->tileops = NULL; /* in 4bpp supports 8p wide tiles only, any tiles otherwise */ info->pixmap.blit_x = (bpp == 4) ? (1 << (8 - 1)) : (~(u32)0); info->pixmap.blit_y = ~(u32)0; offset_value = (info->var.xres_virtual * bpp) / 64; screen_size = info->var.yres_virtual * info->fix.line_length; } else { info->fix.ypanstep = 16; info->fix.line_length = 0; info->flags |= FBINFO_MISC_TILEBLITTING; info->tileops = &arkfb_tile_ops; /* supports 8x16 tiles only */ info->pixmap.blit_x = 1 << (8 - 1); info->pixmap.blit_y = 1 << (16 - 1); offset_value = info->var.xres_virtual / 16; screen_size = (info->var.xres_virtual * info->var.yres_virtual) / 64; } info->var.xoffset = 0; info->var.yoffset = 0; info->var.activate = FB_ACTIVATE_NOW; /* Unlock registers */ |
ea770789d svga: Make svga_w... |
664 |
svga_wcrt_mask(par->state.vgabase, 0x11, 0x00, 0x80); |
681e14730 arkfb: new frameb... |
665 666 |
/* Blank screen and turn off sync */ |
d907ec04c svga: Make svga_w... |
667 |
svga_wseq_mask(par->state.vgabase, 0x01, 0x20, 0x20); |
ea770789d svga: Make svga_w... |
668 |
svga_wcrt_mask(par->state.vgabase, 0x17, 0x00, 0x80); |
681e14730 arkfb: new frameb... |
669 670 |
/* Set default values */ |
e2fade2c1 svga: Make svga_s... |
671 |
svga_set_default_gfx_regs(par->state.vgabase); |
f51a14dde svga: Make svga_s... |
672 |
svga_set_default_atc_regs(par->state.vgabase); |
a4ade8394 svga: Make svga_s... |
673 |
svga_set_default_seq_regs(par->state.vgabase); |
1d28fcadb svga: Make svga_s... |
674 |
svga_set_default_crt_regs(par->state.vgabase); |
21da386d0 svga: Make svga_w... |
675 676 |
svga_wcrt_multi(par->state.vgabase, ark_line_compare_regs, 0xFFFFFFFF); svga_wcrt_multi(par->state.vgabase, ark_start_address_regs, 0); |
681e14730 arkfb: new frameb... |
677 678 |
/* ARK specific initialization */ |
d907ec04c svga: Make svga_w... |
679 680 |
svga_wseq_mask(par->state.vgabase, 0x10, 0x1F, 0x1F); /* enable linear framebuffer and full memory access */ svga_wseq_mask(par->state.vgabase, 0x12, 0x03, 0x03); /* 4 MB linear framebuffer size */ |
681e14730 arkfb: new frameb... |
681 |
|
c5e04633b arkfb: Pass par->... |
682 683 684 685 |
vga_wseq(par->state.vgabase, 0x13, info->fix.smem_start >> 16); vga_wseq(par->state.vgabase, 0x14, info->fix.smem_start >> 24); vga_wseq(par->state.vgabase, 0x15, 0); vga_wseq(par->state.vgabase, 0x16, 0); |
681e14730 arkfb: new frameb... |
686 687 688 689 |
/* Set the FIFO threshold register */ /* It is fascinating way to store 5-bit value in 8-bit register */ regval = 0x10 | ((threshold & 0x0E) >> 1) | (threshold & 0x01) << 7 | (threshold & 0x10) << 1; |
c5e04633b arkfb: Pass par->... |
690 |
vga_wseq(par->state.vgabase, 0x18, regval); |
681e14730 arkfb: new frameb... |
691 692 693 694 |
/* Set the offset register */ pr_debug("fb%d: offset register : %d ", info->node, offset_value); |
21da386d0 svga: Make svga_w... |
695 |
svga_wcrt_multi(par->state.vgabase, ark_offset_regs, offset_value); |
681e14730 arkfb: new frameb... |
696 697 |
/* fix for hi-res textmode */ |
ea770789d svga: Make svga_w... |
698 |
svga_wcrt_mask(par->state.vgabase, 0x40, 0x08, 0x08); |
681e14730 arkfb: new frameb... |
699 700 |
if (info->var.vmode & FB_VMODE_DOUBLE) |
ea770789d svga: Make svga_w... |
701 |
svga_wcrt_mask(par->state.vgabase, 0x09, 0x80, 0x80); |
681e14730 arkfb: new frameb... |
702 |
else |
ea770789d svga: Make svga_w... |
703 |
svga_wcrt_mask(par->state.vgabase, 0x09, 0x00, 0x80); |
681e14730 arkfb: new frameb... |
704 705 |
if (info->var.vmode & FB_VMODE_INTERLACED) |
ea770789d svga: Make svga_w... |
706 |
svga_wcrt_mask(par->state.vgabase, 0x44, 0x04, 0x04); |
681e14730 arkfb: new frameb... |
707 |
else |
ea770789d svga: Make svga_w... |
708 |
svga_wcrt_mask(par->state.vgabase, 0x44, 0x00, 0x04); |
681e14730 arkfb: new frameb... |
709 710 711 712 713 714 715 716 717 718 |
hmul = 1; hdiv = 1; mode = svga_match_format(arkfb_formats, &(info->var), &(info->fix)); /* Set mode-specific register values */ switch (mode) { case 0: pr_debug("fb%d: text mode ", info->node); |
9c96394bb svga: Make svga_s... |
719 |
svga_set_textmode_vga_regs(par->state.vgabase); |
681e14730 arkfb: new frameb... |
720 |
|
c5e04633b arkfb: Pass par->... |
721 |
vga_wseq(par->state.vgabase, 0x11, 0x10); /* basic VGA mode */ |
ea770789d svga: Make svga_w... |
722 |
svga_wcrt_mask(par->state.vgabase, 0x46, 0x00, 0x04); /* 8bit pixel path */ |
681e14730 arkfb: new frameb... |
723 724 725 726 727 728 |
dac_set_mode(par->dac, DAC_PSEUDO8_8); break; case 1: pr_debug("fb%d: 4 bit pseudocolor ", info->node); |
c5e04633b arkfb: Pass par->... |
729 |
vga_wgfx(par->state.vgabase, VGA_GFX_MODE, 0x40); |
681e14730 arkfb: new frameb... |
730 |
|
c5e04633b arkfb: Pass par->... |
731 |
vga_wseq(par->state.vgabase, 0x11, 0x10); /* basic VGA mode */ |
ea770789d svga: Make svga_w... |
732 |
svga_wcrt_mask(par->state.vgabase, 0x46, 0x00, 0x04); /* 8bit pixel path */ |
681e14730 arkfb: new frameb... |
733 734 735 736 737 |
dac_set_mode(par->dac, DAC_PSEUDO8_8); break; case 2: pr_debug("fb%d: 4 bit pseudocolor, planar ", info->node); |
c5e04633b arkfb: Pass par->... |
738 |
vga_wseq(par->state.vgabase, 0x11, 0x10); /* basic VGA mode */ |
ea770789d svga: Make svga_w... |
739 |
svga_wcrt_mask(par->state.vgabase, 0x46, 0x00, 0x04); /* 8bit pixel path */ |
681e14730 arkfb: new frameb... |
740 741 742 743 744 |
dac_set_mode(par->dac, DAC_PSEUDO8_8); break; case 3: pr_debug("fb%d: 8 bit pseudocolor ", info->node); |
c5e04633b arkfb: Pass par->... |
745 |
vga_wseq(par->state.vgabase, 0x11, 0x16); /* 8bpp accel mode */ |
681e14730 arkfb: new frameb... |
746 747 748 749 |
if (info->var.pixclock > 20000) { pr_debug("fb%d: not using multiplex ", info->node); |
ea770789d svga: Make svga_w... |
750 |
svga_wcrt_mask(par->state.vgabase, 0x46, 0x00, 0x04); /* 8bit pixel path */ |
681e14730 arkfb: new frameb... |
751 752 753 754 |
dac_set_mode(par->dac, DAC_PSEUDO8_8); } else { pr_debug("fb%d: using multiplex ", info->node); |
ea770789d svga: Make svga_w... |
755 |
svga_wcrt_mask(par->state.vgabase, 0x46, 0x04, 0x04); /* 16bit pixel path */ |
681e14730 arkfb: new frameb... |
756 757 758 759 760 761 762 |
dac_set_mode(par->dac, DAC_PSEUDO8_16); hdiv = 2; } break; case 4: pr_debug("fb%d: 5/5/5 truecolor ", info->node); |
c5e04633b arkfb: Pass par->... |
763 |
vga_wseq(par->state.vgabase, 0x11, 0x1A); /* 16bpp accel mode */ |
ea770789d svga: Make svga_w... |
764 |
svga_wcrt_mask(par->state.vgabase, 0x46, 0x04, 0x04); /* 16bit pixel path */ |
681e14730 arkfb: new frameb... |
765 766 767 768 769 |
dac_set_mode(par->dac, DAC_RGB1555_16); break; case 5: pr_debug("fb%d: 5/6/5 truecolor ", info->node); |
c5e04633b arkfb: Pass par->... |
770 |
vga_wseq(par->state.vgabase, 0x11, 0x1A); /* 16bpp accel mode */ |
ea770789d svga: Make svga_w... |
771 |
svga_wcrt_mask(par->state.vgabase, 0x46, 0x04, 0x04); /* 16bit pixel path */ |
681e14730 arkfb: new frameb... |
772 773 774 775 776 |
dac_set_mode(par->dac, DAC_RGB0565_16); break; case 6: pr_debug("fb%d: 8/8/8 truecolor ", info->node); |
c5e04633b arkfb: Pass par->... |
777 |
vga_wseq(par->state.vgabase, 0x11, 0x16); /* 8bpp accel mode ??? */ |
ea770789d svga: Make svga_w... |
778 |
svga_wcrt_mask(par->state.vgabase, 0x46, 0x04, 0x04); /* 16bit pixel path */ |
681e14730 arkfb: new frameb... |
779 780 781 782 783 784 785 |
dac_set_mode(par->dac, DAC_RGB0888_16); hmul = 3; hdiv = 2; break; case 7: pr_debug("fb%d: 8/8/8/8 truecolor ", info->node); |
c5e04633b arkfb: Pass par->... |
786 |
vga_wseq(par->state.vgabase, 0x11, 0x1E); /* 32bpp accel mode */ |
ea770789d svga: Make svga_w... |
787 |
svga_wcrt_mask(par->state.vgabase, 0x46, 0x04, 0x04); /* 16bit pixel path */ |
681e14730 arkfb: new frameb... |
788 789 790 791 792 793 794 795 796 797 |
dac_set_mode(par->dac, DAC_RGB8888_16); hmul = 2; break; default: printk(KERN_ERR "fb%d: unsupported mode - bug ", info->node); return -EINVAL; } ark_set_pixclock(info, (hdiv * info->var.pixclock) / hmul); |
38d2620ea svga: Make svga_s... |
798 |
svga_set_timings(par->state.vgabase, &ark_timing_regs, &(info->var), hmul, hdiv, |
681e14730 arkfb: new frameb... |
799 800 801 802 803 804 805 |
(info->var.vmode & FB_VMODE_DOUBLE) ? 2 : 1, (info->var.vmode & FB_VMODE_INTERLACED) ? 2 : 1, hmul, info->node); /* Set interlaced mode start/end register */ value = info->var.xres + info->var.left_margin + info->var.right_margin + info->var.hsync_len; value = ((value * hmul / hdiv) / 8) - 5; |
c5e04633b arkfb: Pass par->... |
806 |
vga_wcrt(par->state.vgabase, 0x42, (value + 1) / 2); |
681e14730 arkfb: new frameb... |
807 808 809 |
memset_io(info->screen_base, 0x00, screen_size); /* Device and screen back on */ |
ea770789d svga: Make svga_w... |
810 |
svga_wcrt_mask(par->state.vgabase, 0x17, 0x80, 0x80); |
d907ec04c svga: Make svga_w... |
811 |
svga_wseq_mask(par->state.vgabase, 0x01, 0x00, 0x20); |
681e14730 arkfb: new frameb... |
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 |
return 0; } /* Set a colour register */ static int arkfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, u_int transp, struct fb_info *fb) { switch (fb->var.bits_per_pixel) { case 0: case 4: if (regno >= 16) return -EINVAL; if ((fb->var.bits_per_pixel == 4) && (fb->var.nonstd == 0)) { outb(0xF0, VGA_PEL_MSK); outb(regno*16, VGA_PEL_IW); } else { outb(0x0F, VGA_PEL_MSK); outb(regno, VGA_PEL_IW); } outb(red >> 10, VGA_PEL_D); outb(green >> 10, VGA_PEL_D); outb(blue >> 10, VGA_PEL_D); break; case 8: if (regno >= 256) return -EINVAL; outb(0xFF, VGA_PEL_MSK); outb(regno, VGA_PEL_IW); outb(red >> 10, VGA_PEL_D); outb(green >> 10, VGA_PEL_D); outb(blue >> 10, VGA_PEL_D); break; case 16: if (regno >= 16) return 0; if (fb->var.green.length == 5) ((u32*)fb->pseudo_palette)[regno] = ((red & 0xF800) >> 1) | ((green & 0xF800) >> 6) | ((blue & 0xF800) >> 11); else if (fb->var.green.length == 6) ((u32*)fb->pseudo_palette)[regno] = (red & 0xF800) | ((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11); else return -EINVAL; break; case 24: case 32: if (regno >= 16) return 0; ((u32*)fb->pseudo_palette)[regno] = ((red & 0xFF00) << 8) | (green & 0xFF00) | ((blue & 0xFF00) >> 8); break; default: return -EINVAL; } return 0; } /* Set the display blanking state */ static int arkfb_blank(int blank_mode, struct fb_info *info) { |
d907ec04c svga: Make svga_w... |
881 |
struct arkfb_info *par = info->par; |
681e14730 arkfb: new frameb... |
882 883 884 885 |
switch (blank_mode) { case FB_BLANK_UNBLANK: pr_debug("fb%d: unblank ", info->node); |
d907ec04c svga: Make svga_w... |
886 |
svga_wseq_mask(par->state.vgabase, 0x01, 0x00, 0x20); |
ea770789d svga: Make svga_w... |
887 |
svga_wcrt_mask(par->state.vgabase, 0x17, 0x80, 0x80); |
681e14730 arkfb: new frameb... |
888 889 890 891 |
break; case FB_BLANK_NORMAL: pr_debug("fb%d: blank ", info->node); |
d907ec04c svga: Make svga_w... |
892 |
svga_wseq_mask(par->state.vgabase, 0x01, 0x20, 0x20); |
ea770789d svga: Make svga_w... |
893 |
svga_wcrt_mask(par->state.vgabase, 0x17, 0x80, 0x80); |
681e14730 arkfb: new frameb... |
894 895 896 897 898 899 |
break; case FB_BLANK_POWERDOWN: case FB_BLANK_HSYNC_SUSPEND: case FB_BLANK_VSYNC_SUSPEND: pr_debug("fb%d: sync down ", info->node); |
d907ec04c svga: Make svga_w... |
900 |
svga_wseq_mask(par->state.vgabase, 0x01, 0x20, 0x20); |
ea770789d svga: Make svga_w... |
901 |
svga_wcrt_mask(par->state.vgabase, 0x17, 0x00, 0x80); |
681e14730 arkfb: new frameb... |
902 903 904 905 906 907 908 909 910 911 |
break; } return 0; } /* Pan the display */ static int arkfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { |
21da386d0 svga: Make svga_w... |
912 |
struct arkfb_info *par = info->par; |
681e14730 arkfb: new frameb... |
913 914 915 |
unsigned int offset; /* Calculate the offset */ |
a35a9b79d arkfb: use displa... |
916 917 918 |
if (info->var.bits_per_pixel == 0) { offset = (var->yoffset / 16) * (info->var.xres_virtual / 2) + (var->xoffset / 2); |
681e14730 arkfb: new frameb... |
919 920 921 |
offset = offset >> 2; } else { offset = (var->yoffset * info->fix.line_length) + |
a35a9b79d arkfb: use displa... |
922 923 |
(var->xoffset * info->var.bits_per_pixel / 8); offset = offset >> ((info->var.bits_per_pixel == 4) ? 2 : 3); |
681e14730 arkfb: new frameb... |
924 925 926 |
} /* Set the offset */ |
21da386d0 svga: Make svga_w... |
927 |
svga_wcrt_multi(par->state.vgabase, ark_start_address_regs, offset); |
681e14730 arkfb: new frameb... |
928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 |
return 0; } /* ------------------------------------------------------------------------- */ /* Frame buffer operations */ static struct fb_ops arkfb_ops = { .owner = THIS_MODULE, .fb_open = arkfb_open, .fb_release = arkfb_release, .fb_check_var = arkfb_check_var, .fb_set_par = arkfb_set_par, .fb_setcolreg = arkfb_setcolreg, .fb_blank = arkfb_blank, .fb_pan_display = arkfb_pan_display, .fb_fillrect = arkfb_fillrect, .fb_copyarea = cfb_copyarea, .fb_imageblit = arkfb_imageblit, |
5a87ede94 svgalib: move fb_... |
950 |
.fb_get_caps = svga_get_caps, |
681e14730 arkfb: new frameb... |
951 952 953 954 955 956 957 958 959 |
}; /* ------------------------------------------------------------------------- */ /* PCI probe */ static int __devinit ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) { |
892c24ca4 arkfb: Compute VG... |
960 961 |
struct pci_bus_region bus_reg; struct resource vga_res; |
681e14730 arkfb: new frameb... |
962 963 964 965 966 967 968 969 970 971 972 973 974 |
struct fb_info *info; struct arkfb_info *par; int rc; u8 regval; /* Ignore secondary VGA device because there is no VGA arbitration */ if (! svga_primary_device(dev)) { dev_info(&(dev->dev), "ignoring secondary device "); return -ENODEV; } /* Allocate and fill driver data structure */ |
20e061fb7 fbdev: framebuffe... |
975 |
info = framebuffer_alloc(sizeof(struct arkfb_info), &(dev->dev)); |
681e14730 arkfb: new frameb... |
976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 |
if (! info) { dev_err(&(dev->dev), "cannot allocate memory "); return -ENOMEM; } par = info->par; mutex_init(&par->open_lock); info->flags = FBINFO_PARTIAL_PAN_OK | FBINFO_HWACCEL_YPAN; info->fbops = &arkfb_ops; /* Prepare PCI device */ rc = pci_enable_device(dev); if (rc < 0) { |
594a88197 vt8623fb: fix ker... |
991 992 |
dev_err(info->device, "cannot enable PCI device "); |
681e14730 arkfb: new frameb... |
993 994 995 996 997 |
goto err_enable_device; } rc = pci_request_regions(dev, "arkfb"); if (rc < 0) { |
594a88197 vt8623fb: fix ker... |
998 999 |
dev_err(info->device, "cannot reserve framebuffer region "); |
681e14730 arkfb: new frameb... |
1000 1001 1002 1003 1004 1005 |
goto err_request_regions; } par->dac = ics5342_init(ark_dac_read_regs, ark_dac_write_regs, info); if (! par->dac) { rc = -ENOMEM; |
594a88197 vt8623fb: fix ker... |
1006 1007 |
dev_err(info->device, "RAMDAC initialization failed "); |
681e14730 arkfb: new frameb... |
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 |
goto err_dac; } info->fix.smem_start = pci_resource_start(dev, 0); info->fix.smem_len = pci_resource_len(dev, 0); /* Map physical IO memory address into kernel space */ info->screen_base = pci_iomap(dev, 0, 0); if (! info->screen_base) { rc = -ENOMEM; |
594a88197 vt8623fb: fix ker... |
1018 1019 |
dev_err(info->device, "iomap for framebuffer failed "); |
681e14730 arkfb: new frameb... |
1020 1021 |
goto err_iomap; } |
892c24ca4 arkfb: Compute VG... |
1022 1023 1024 1025 1026 1027 1028 1029 |
bus_reg.start = 0; bus_reg.end = 64 * 1024; vga_res.flags = IORESOURCE_IO; pcibios_bus_to_resource(dev, &vga_res, &bus_reg); par->state.vgabase = (void __iomem *) vga_res.start; |
681e14730 arkfb: new frameb... |
1030 |
/* FIXME get memsize */ |
c5e04633b arkfb: Pass par->... |
1031 |
regval = vga_rseq(par->state.vgabase, 0x10); |
681e14730 arkfb: new frameb... |
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 |
info->screen_size = (1 << (regval >> 6)) << 20; info->fix.smem_len = info->screen_size; strcpy(info->fix.id, "ARK 2000PV"); info->fix.mmio_start = 0; info->fix.mmio_len = 0; info->fix.type = FB_TYPE_PACKED_PIXELS; info->fix.visual = FB_VISUAL_PSEUDOCOLOR; info->fix.ypanstep = 0; info->fix.accel = FB_ACCEL_NONE; info->pseudo_palette = (void*) (par->pseudo_palette); /* Prepare startup mode */ |
1abf91729 arkfb: add option... |
1045 |
rc = fb_find_mode(&(info->var), info, mode_option, NULL, 0, NULL, 8); |
681e14730 arkfb: new frameb... |
1046 1047 |
if (! ((rc == 1) || (rc == 2))) { rc = -EINVAL; |
594a88197 vt8623fb: fix ker... |
1048 1049 |
dev_err(info->device, "mode %s not found ", mode_option); |
681e14730 arkfb: new frameb... |
1050 1051 1052 1053 1054 |
goto err_find_mode; } rc = fb_alloc_cmap(&info->cmap, 256, 0); if (rc < 0) { |
594a88197 vt8623fb: fix ker... |
1055 1056 |
dev_err(info->device, "cannot allocate colormap "); |
681e14730 arkfb: new frameb... |
1057 1058 1059 1060 1061 |
goto err_alloc_cmap; } rc = register_framebuffer(info); if (rc < 0) { |
594a88197 vt8623fb: fix ker... |
1062 1063 |
dev_err(info->device, "cannot register framebugger "); |
681e14730 arkfb: new frameb... |
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 |
goto err_reg_fb; } printk(KERN_INFO "fb%d: %s on %s, %d MB RAM ", info->node, info->fix.id, pci_name(dev), info->fix.smem_len >> 20); /* Record a reference to the driver data */ pci_set_drvdata(dev, info); #ifdef CONFIG_MTRR if (mtrr) { par->mtrr_reg = -1; par->mtrr_reg = mtrr_add(info->fix.smem_start, info->fix.smem_len, MTRR_TYPE_WRCOMB, 1); } #endif return 0; /* Error handling */ err_reg_fb: fb_dealloc_cmap(&info->cmap); err_alloc_cmap: err_find_mode: pci_iounmap(dev, info->screen_base); err_iomap: dac_release(par->dac); err_dac: pci_release_regions(dev); err_request_regions: /* pci_disable_device(dev); */ err_enable_device: framebuffer_release(info); return rc; } /* PCI remove */ static void __devexit ark_pci_remove(struct pci_dev *dev) { struct fb_info *info = pci_get_drvdata(dev); |
681e14730 arkfb: new frameb... |
1105 1106 |
if (info) { |
38d473f99 vt8623fb: arkfb: ... |
1107 |
struct arkfb_info *par = info->par; |
681e14730 arkfb: new frameb... |
1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 |
#ifdef CONFIG_MTRR if (par->mtrr_reg >= 0) { mtrr_del(par->mtrr_reg, 0, 0); par->mtrr_reg = -1; } #endif dac_release(par->dac); unregister_framebuffer(info); fb_dealloc_cmap(&info->cmap); pci_iounmap(dev, info->screen_base); pci_release_regions(dev); /* pci_disable_device(dev); */ pci_set_drvdata(dev, NULL); framebuffer_release(info); } } #ifdef CONFIG_PM /* PCI suspend */ static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state) { struct fb_info *info = pci_get_drvdata(dev); struct arkfb_info *par = info->par; |
594a88197 vt8623fb: fix ker... |
1136 1137 |
dev_info(info->device, "suspend "); |
681e14730 arkfb: new frameb... |
1138 |
|
ac751efa6 console: rename a... |
1139 |
console_lock(); |
681e14730 arkfb: new frameb... |
1140 1141 1142 1143 |
mutex_lock(&(par->open_lock)); if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) { mutex_unlock(&(par->open_lock)); |
ac751efa6 console: rename a... |
1144 |
console_unlock(); |
681e14730 arkfb: new frameb... |
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 |
return 0; } fb_set_suspend(info, 1); pci_save_state(dev); pci_disable_device(dev); pci_set_power_state(dev, pci_choose_state(dev, state)); mutex_unlock(&(par->open_lock)); |
ac751efa6 console: rename a... |
1155 |
console_unlock(); |
681e14730 arkfb: new frameb... |
1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 |
return 0; } /* PCI resume */ static int ark_pci_resume (struct pci_dev* dev) { struct fb_info *info = pci_get_drvdata(dev); struct arkfb_info *par = info->par; |
594a88197 vt8623fb: fix ker... |
1167 1168 |
dev_info(info->device, "resume "); |
681e14730 arkfb: new frameb... |
1169 |
|
ac751efa6 console: rename a... |
1170 |
console_lock(); |
681e14730 arkfb: new frameb... |
1171 |
mutex_lock(&(par->open_lock)); |
950d442ad drivers/video: re... |
1172 1173 |
if (par->ref_count == 0) goto fail; |
681e14730 arkfb: new frameb... |
1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 |
pci_set_power_state(dev, PCI_D0); pci_restore_state(dev); if (pci_enable_device(dev)) goto fail; pci_set_master(dev); arkfb_set_par(info); fb_set_suspend(info, 0); |
681e14730 arkfb: new frameb... |
1185 |
fail: |
950d442ad drivers/video: re... |
1186 |
mutex_unlock(&(par->open_lock)); |
ac751efa6 console: rename a... |
1187 |
console_unlock(); |
681e14730 arkfb: new frameb... |
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 |
return 0; } #else #define ark_pci_suspend NULL #define ark_pci_resume NULL #endif /* CONFIG_PM */ /* List of boards that we are trying to support */ static struct pci_device_id ark_devices[] __devinitdata = { {PCI_DEVICE(0xEDD8, 0xA099)}, {0, 0, 0, 0, 0, 0, 0} }; MODULE_DEVICE_TABLE(pci, ark_devices); static struct pci_driver arkfb_pci_driver = { .name = "arkfb", .id_table = ark_devices, .probe = ark_pci_probe, .remove = __devexit_p(ark_pci_remove), .suspend = ark_pci_suspend, .resume = ark_pci_resume, }; /* Cleanup */ static void __exit arkfb_cleanup(void) { pr_debug("arkfb: cleaning up "); pci_unregister_driver(&arkfb_pci_driver); } /* Driver Initialisation */ static int __init arkfb_init(void) { #ifndef MODULE char *option = NULL; if (fb_get_options("arkfb", &option)) return -ENODEV; if (option && *option) |
1abf91729 arkfb: add option... |
1235 |
mode_option = option; |
681e14730 arkfb: new frameb... |
1236 1237 1238 1239 1240 1241 1242 1243 1244 |
#endif pr_debug("arkfb: initializing "); return pci_register_driver(&arkfb_pci_driver); } module_init(arkfb_init); module_exit(arkfb_cleanup); |