| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * linux/drivers/video/console/sticore.c - |
|---|
| 3 | 4 | * core code for console driver using HP's STI firmware |
|---|
| 4 | 5 | * |
|---|
| 5 | 6 | * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org> |
|---|
| 6 | | - * Copyright (C) 2001-2013 Helge Deller <deller@gmx.de> |
|---|
| 7 | + * Copyright (C) 2001-2020 Helge Deller <deller@gmx.de> |
|---|
| 7 | 8 | * Copyright (C) 2001-2002 Thomas Bogendoerfer <tsbogend@alpha.franken.de> |
|---|
| 8 | 9 | * |
|---|
| 9 | 10 | * TODO: |
|---|
| .. | .. |
|---|
| 12 | 13 | * - try to make it work on m68k hp workstations ;) |
|---|
| 13 | 14 | * |
|---|
| 14 | 15 | */ |
|---|
| 16 | + |
|---|
| 17 | +#define pr_fmt(fmt) "%s: " fmt, KBUILD_MODNAME |
|---|
| 15 | 18 | |
|---|
| 16 | 19 | #include <linux/module.h> |
|---|
| 17 | 20 | #include <linux/types.h> |
|---|
| .. | .. |
|---|
| 27 | 30 | #include <asm/pdc.h> |
|---|
| 28 | 31 | #include <asm/cacheflush.h> |
|---|
| 29 | 32 | #include <asm/grfioctl.h> |
|---|
| 33 | +#include <asm/fb.h> |
|---|
| 30 | 34 | |
|---|
| 31 | 35 | #include "../fbdev/sticore.h" |
|---|
| 32 | 36 | |
|---|
| .. | .. |
|---|
| 132 | 136 | }; |
|---|
| 133 | 137 | |
|---|
| 134 | 138 | void |
|---|
| 135 | | -sti_putc(struct sti_struct *sti, int c, int y, int x) |
|---|
| 139 | +sti_putc(struct sti_struct *sti, int c, int y, int x, |
|---|
| 140 | + struct sti_cooked_font *font) |
|---|
| 136 | 141 | { |
|---|
| 137 | 142 | struct sti_font_inptr *inptr = &sti->sti_data->font_inptr; |
|---|
| 138 | 143 | struct sti_font_inptr inptr_default = { |
|---|
| 139 | | - .font_start_addr= STI_PTR(sti->font->raw), |
|---|
| 144 | + .font_start_addr = STI_PTR(font->raw), |
|---|
| 140 | 145 | .index = c_index(sti, c), |
|---|
| 141 | 146 | .fg_color = c_fg(sti, c), |
|---|
| 142 | 147 | .bg_color = c_bg(sti, c), |
|---|
| 143 | | - .dest_x = x * sti->font_width, |
|---|
| 144 | | - .dest_y = y * sti->font_height, |
|---|
| 148 | + .dest_x = x * font->width, |
|---|
| 149 | + .dest_y = y * font->height, |
|---|
| 145 | 150 | }; |
|---|
| 146 | 151 | struct sti_font_outptr *outptr = &sti->sti_data->font_outptr; |
|---|
| 147 | 152 | s32 ret; |
|---|
| .. | .. |
|---|
| 192 | 197 | |
|---|
| 193 | 198 | void |
|---|
| 194 | 199 | sti_clear(struct sti_struct *sti, int src_y, int src_x, |
|---|
| 195 | | - int height, int width, int c) |
|---|
| 200 | + int height, int width, int c, struct sti_cooked_font *font) |
|---|
| 196 | 201 | { |
|---|
| 197 | 202 | struct sti_blkmv_inptr *inptr = &sti->sti_data->blkmv_inptr; |
|---|
| 198 | 203 | struct sti_blkmv_inptr inptr_default = { |
|---|
| 199 | 204 | .fg_color = c_fg(sti, c), |
|---|
| 200 | 205 | .bg_color = c_bg(sti, c), |
|---|
| 201 | | - .src_x = src_x * sti->font_width, |
|---|
| 202 | | - .src_y = src_y * sti->font_height, |
|---|
| 203 | | - .dest_x = src_x * sti->font_width, |
|---|
| 204 | | - .dest_y = src_y * sti->font_height, |
|---|
| 205 | | - .width = width * sti->font_width, |
|---|
| 206 | | - .height = height* sti->font_height, |
|---|
| 206 | + .src_x = src_x * font->width, |
|---|
| 207 | + .src_y = src_y * font->height, |
|---|
| 208 | + .dest_x = src_x * font->width, |
|---|
| 209 | + .dest_y = src_y * font->height, |
|---|
| 210 | + .width = width * font->width, |
|---|
| 211 | + .height = height * font->height, |
|---|
| 207 | 212 | }; |
|---|
| 208 | 213 | struct sti_blkmv_outptr *outptr = &sti->sti_data->blkmv_outptr; |
|---|
| 209 | 214 | s32 ret; |
|---|
| .. | .. |
|---|
| 224 | 229 | |
|---|
| 225 | 230 | void |
|---|
| 226 | 231 | sti_bmove(struct sti_struct *sti, int src_y, int src_x, |
|---|
| 227 | | - int dst_y, int dst_x, int height, int width) |
|---|
| 232 | + int dst_y, int dst_x, int height, int width, |
|---|
| 233 | + struct sti_cooked_font *font) |
|---|
| 228 | 234 | { |
|---|
| 229 | 235 | struct sti_blkmv_inptr *inptr = &sti->sti_data->blkmv_inptr; |
|---|
| 230 | 236 | struct sti_blkmv_inptr inptr_default = { |
|---|
| 231 | | - .src_x = src_x * sti->font_width, |
|---|
| 232 | | - .src_y = src_y * sti->font_height, |
|---|
| 233 | | - .dest_x = dst_x * sti->font_width, |
|---|
| 234 | | - .dest_y = dst_y * sti->font_height, |
|---|
| 235 | | - .width = width * sti->font_width, |
|---|
| 236 | | - .height = height* sti->font_height, |
|---|
| 237 | + .src_x = src_x * font->width, |
|---|
| 238 | + .src_y = src_y * font->height, |
|---|
| 239 | + .dest_x = dst_x * font->width, |
|---|
| 240 | + .dest_y = dst_y * font->height, |
|---|
| 241 | + .width = width * font->width, |
|---|
| 242 | + .height = height * font->height, |
|---|
| 237 | 243 | }; |
|---|
| 238 | 244 | struct sti_blkmv_outptr *outptr = &sti->sti_data->blkmv_outptr; |
|---|
| 239 | 245 | s32 ret; |
|---|
| .. | .. |
|---|
| 300 | 306 | |
|---|
| 301 | 307 | |
|---|
| 302 | 308 | |
|---|
| 303 | | -static char *font_name[MAX_STI_ROMS]; |
|---|
| 304 | | -static int font_index[MAX_STI_ROMS], |
|---|
| 305 | | - font_height[MAX_STI_ROMS], |
|---|
| 306 | | - font_width[MAX_STI_ROMS]; |
|---|
| 309 | +static char *font_name; |
|---|
| 310 | +static int font_index, |
|---|
| 311 | + font_height, |
|---|
| 312 | + font_width; |
|---|
| 307 | 313 | #ifndef MODULE |
|---|
| 308 | 314 | static int sti_font_setup(char *str) |
|---|
| 309 | 315 | { |
|---|
| 310 | | - char *x; |
|---|
| 311 | | - int i = 0; |
|---|
| 316 | + /* |
|---|
| 317 | + * The default font can be selected in various ways. |
|---|
| 318 | + * a) sti_font=VGA8x16, sti_font=10x20, sti_font=10*20 selects |
|---|
| 319 | + * an built-in Linux framebuffer font. |
|---|
| 320 | + * b) sti_font=<index>, where index is (1..x) with 1 selecting |
|---|
| 321 | + * the first HP STI ROM built-in font.. |
|---|
| 322 | + */ |
|---|
| 312 | 323 | |
|---|
| 313 | | - /* we accept sti_font=VGA8x16, sti_font=10x20, sti_font=10*20 |
|---|
| 314 | | - * or sti_font=7 style command lines. */ |
|---|
| 324 | + if (*str >= '0' && *str <= '9') { |
|---|
| 325 | + char *x; |
|---|
| 315 | 326 | |
|---|
| 316 | | - while (i<MAX_STI_ROMS && str && *str) { |
|---|
| 317 | | - if (*str>='0' && *str<='9') { |
|---|
| 318 | | - if ((x = strchr(str, 'x')) || (x = strchr(str, '*'))) { |
|---|
| 319 | | - font_height[i] = simple_strtoul(str, NULL, 0); |
|---|
| 320 | | - font_width[i] = simple_strtoul(x+1, NULL, 0); |
|---|
| 321 | | - } else { |
|---|
| 322 | | - font_index[i] = simple_strtoul(str, NULL, 0); |
|---|
| 323 | | - } |
|---|
| 327 | + if ((x = strchr(str, 'x')) || (x = strchr(str, '*'))) { |
|---|
| 328 | + font_height = simple_strtoul(str, NULL, 0); |
|---|
| 329 | + font_width = simple_strtoul(x+1, NULL, 0); |
|---|
| 324 | 330 | } else { |
|---|
| 325 | | - font_name[i] = str; /* fb font name */ |
|---|
| 331 | + font_index = simple_strtoul(str, NULL, 0); |
|---|
| 326 | 332 | } |
|---|
| 327 | | - |
|---|
| 328 | | - if ((x = strchr(str, ','))) |
|---|
| 329 | | - *x++ = 0; |
|---|
| 330 | | - str = x; |
|---|
| 331 | | - |
|---|
| 332 | | - i++; |
|---|
| 333 | + } else { |
|---|
| 334 | + font_name = str; /* fb font name */ |
|---|
| 333 | 335 | } |
|---|
| 334 | 336 | |
|---|
| 335 | 337 | return 1; |
|---|
| .. | .. |
|---|
| 343 | 345 | * framebuffer font names (e.g. VGA8x16, SUN22x18). |
|---|
| 344 | 346 | * This is only available if the fonts have been statically compiled |
|---|
| 345 | 347 | * in with e.g. the CONFIG_FONT_8x16 or CONFIG_FONT_SUN12x22 options. |
|---|
| 346 | | - * - sti_font=<number> |
|---|
| 348 | + * - sti_font=<number> (<number> = 1,2,3,...) |
|---|
| 347 | 349 | * most STI ROMs have built-in HP specific fonts, which can be selected |
|---|
| 348 | 350 | * by giving the desired number to the sticon driver. |
|---|
| 349 | 351 | * NOTE: This number is machine and STI ROM dependend. |
|---|
| .. | .. |
|---|
| 363 | 365 | { |
|---|
| 364 | 366 | struct sti_glob_cfg_ext *cfg; |
|---|
| 365 | 367 | |
|---|
| 366 | | - DPRINTK((KERN_INFO |
|---|
| 367 | | - "%d text planes\n" |
|---|
| 368 | + pr_debug("%d text planes\n" |
|---|
| 368 | 369 | "%4d x %4d screen resolution\n" |
|---|
| 369 | 370 | "%4d x %4d offscreen\n" |
|---|
| 370 | 371 | "%4d x %4d layout\n" |
|---|
| .. | .. |
|---|
| 381 | 382 | glob_cfg->region_ptrs[4], glob_cfg->region_ptrs[5], |
|---|
| 382 | 383 | glob_cfg->region_ptrs[6], glob_cfg->region_ptrs[7], |
|---|
| 383 | 384 | glob_cfg->reent_lvl, |
|---|
| 384 | | - glob_cfg->save_addr)); |
|---|
| 385 | + glob_cfg->save_addr); |
|---|
| 385 | 386 | |
|---|
| 386 | 387 | /* dump extended cfg */ |
|---|
| 387 | 388 | cfg = PTR_STI((unsigned long)glob_cfg->ext_ptr); |
|---|
| 388 | | - DPRINTK(( KERN_INFO |
|---|
| 389 | | - "monitor %d\n" |
|---|
| 389 | + pr_debug("monitor %d\n" |
|---|
| 390 | 390 | "in friendly mode: %d\n" |
|---|
| 391 | 391 | "power consumption %d watts\n" |
|---|
| 392 | 392 | "freq ref %d\n" |
|---|
| .. | .. |
|---|
| 395 | 395 | cfg->friendly_boot, |
|---|
| 396 | 396 | cfg->power, |
|---|
| 397 | 397 | cfg->freq_ref, |
|---|
| 398 | | - cfg->sti_mem_addr, sti_mem_request)); |
|---|
| 398 | + cfg->sti_mem_addr, sti_mem_request); |
|---|
| 399 | 399 | } |
|---|
| 400 | 400 | |
|---|
| 401 | 401 | static void sti_dump_outptr(struct sti_struct *sti) |
|---|
| 402 | 402 | { |
|---|
| 403 | | - DPRINTK((KERN_INFO |
|---|
| 404 | | - "%d bits per pixel\n" |
|---|
| 403 | + pr_debug("%d bits per pixel\n" |
|---|
| 405 | 404 | "%d used bits\n" |
|---|
| 406 | 405 | "%d planes\n" |
|---|
| 407 | 406 | "attributes %08x\n", |
|---|
| 408 | 407 | sti->sti_data->inq_outptr.bits_per_pixel, |
|---|
| 409 | 408 | sti->sti_data->inq_outptr.bits_used, |
|---|
| 410 | 409 | sti->sti_data->inq_outptr.planes, |
|---|
| 411 | | - sti->sti_data->inq_outptr.attributes)); |
|---|
| 410 | + sti->sti_data->inq_outptr.attributes); |
|---|
| 412 | 411 | } |
|---|
| 413 | 412 | |
|---|
| 414 | 413 | static int sti_init_glob_cfg(struct sti_struct *sti, unsigned long rom_address, |
|---|
| .. | .. |
|---|
| 447 | 446 | if (offs != PCI_ROM_ADDRESS && |
|---|
| 448 | 447 | (offs < PCI_BASE_ADDRESS_0 || |
|---|
| 449 | 448 | offs > PCI_BASE_ADDRESS_5)) { |
|---|
| 450 | | - printk (KERN_WARNING |
|---|
| 451 | | - "STI pci region mapping for region %d (%02x) can't be mapped\n", |
|---|
| 449 | + pr_warn("STI pci region mapping for region %d (%02x) can't be mapped\n", |
|---|
| 452 | 450 | i,sti->rm_entry[i]); |
|---|
| 453 | 451 | continue; |
|---|
| 454 | 452 | } |
|---|
| .. | .. |
|---|
| 463 | 461 | if (len) |
|---|
| 464 | 462 | glob_cfg->region_ptrs[i] = sti->regions_phys[i]; |
|---|
| 465 | 463 | |
|---|
| 466 | | - DPRINTK(("region #%d: phys %08lx, region_ptr %08x, len=%lukB, " |
|---|
| 464 | + pr_debug("region #%d: phys %08lx, region_ptr %08x, len=%lukB, " |
|---|
| 467 | 465 | "btlb=%d, sysonly=%d, cache=%d, last=%d\n", |
|---|
| 468 | 466 | i, sti->regions_phys[i], glob_cfg->region_ptrs[i], |
|---|
| 469 | 467 | len/1024, |
|---|
| 470 | 468 | sti->regions[i].region_desc.btlb, |
|---|
| 471 | 469 | sti->regions[i].region_desc.sys_only, |
|---|
| 472 | 470 | sti->regions[i].region_desc.cache, |
|---|
| 473 | | - sti->regions[i].region_desc.last)); |
|---|
| 471 | + sti->regions[i].region_desc.last); |
|---|
| 474 | 472 | |
|---|
| 475 | 473 | /* last entry reached ? */ |
|---|
| 476 | 474 | if (sti->regions[i].region_desc.last) |
|---|
| .. | .. |
|---|
| 478 | 476 | } |
|---|
| 479 | 477 | |
|---|
| 480 | 478 | if (++i<8 && sti->regions[i].region) |
|---|
| 481 | | - printk(KERN_WARNING "%s: *future ptr (0x%8x) not yet supported !\n", |
|---|
| 482 | | - __FILE__, sti->regions[i].region); |
|---|
| 479 | + pr_warn("future ptr (0x%8x) not yet supported !\n", |
|---|
| 480 | + sti->regions[i].region); |
|---|
| 483 | 481 | |
|---|
| 484 | 482 | glob_cfg_ext->sti_mem_addr = STI_PTR(sti_mem_addr); |
|---|
| 485 | 483 | |
|---|
| .. | .. |
|---|
| 537 | 535 | } |
|---|
| 538 | 536 | |
|---|
| 539 | 537 | cooked_font->raw = nf; |
|---|
| 538 | + cooked_font->raw_ptr = nf; |
|---|
| 540 | 539 | cooked_font->next_font = NULL; |
|---|
| 541 | 540 | |
|---|
| 542 | 541 | cooked_rom->font_start = cooked_font; |
|---|
| .. | .. |
|---|
| 551 | 550 | } |
|---|
| 552 | 551 | #endif |
|---|
| 553 | 552 | |
|---|
| 554 | | -static struct sti_cooked_font *sti_select_font(struct sti_cooked_rom *rom, |
|---|
| 555 | | - int (*search_font_fnc)(struct sti_cooked_rom *, int, int)) |
|---|
| 553 | +static int sti_search_font(struct sti_cooked_rom *rom, int height, int width) |
|---|
| 554 | +{ |
|---|
| 555 | + struct sti_cooked_font *font; |
|---|
| 556 | + int i = 0; |
|---|
| 557 | + |
|---|
| 558 | + for (font = rom->font_start; font; font = font->next_font, i++) { |
|---|
| 559 | + if ((font->raw->width == width) && |
|---|
| 560 | + (font->raw->height == height)) |
|---|
| 561 | + return i; |
|---|
| 562 | + } |
|---|
| 563 | + return 0; |
|---|
| 564 | +} |
|---|
| 565 | + |
|---|
| 566 | +static struct sti_cooked_font *sti_select_font(struct sti_cooked_rom *rom) |
|---|
| 556 | 567 | { |
|---|
| 557 | 568 | struct sti_cooked_font *font; |
|---|
| 558 | 569 | int i; |
|---|
| 559 | | - int index = num_sti_roms; |
|---|
| 560 | 570 | |
|---|
| 561 | 571 | /* check for framebuffer-font first */ |
|---|
| 562 | | - if ((font = sti_select_fbfont(rom, font_name[index]))) |
|---|
| 563 | | - return font; |
|---|
| 572 | + if (!font_index) { |
|---|
| 573 | + font = sti_select_fbfont(rom, font_name); |
|---|
| 574 | + if (font) |
|---|
| 575 | + return font; |
|---|
| 576 | + } |
|---|
| 564 | 577 | |
|---|
| 565 | | - if (font_width[index] && font_height[index]) |
|---|
| 566 | | - font_index[index] = search_font_fnc(rom, |
|---|
| 567 | | - font_height[index], font_width[index]); |
|---|
| 578 | + if (font_width && font_height) |
|---|
| 579 | + font_index = sti_search_font(rom, |
|---|
| 580 | + font_height, font_width); |
|---|
| 568 | 581 | |
|---|
| 569 | | - for (font = rom->font_start, i = font_index[index]; |
|---|
| 570 | | - font && (i > 0); |
|---|
| 571 | | - font = font->next_font, i--); |
|---|
| 582 | + for (font = rom->font_start, i = font_index - 1; |
|---|
| 583 | + font && (i > 0); |
|---|
| 584 | + font = font->next_font, i--); |
|---|
| 572 | 585 | |
|---|
| 573 | 586 | if (font) |
|---|
| 574 | 587 | return font; |
|---|
| .. | .. |
|---|
| 577 | 590 | } |
|---|
| 578 | 591 | |
|---|
| 579 | 592 | |
|---|
| 580 | | -static void sti_dump_rom(struct sti_rom *rom) |
|---|
| 593 | +static void sti_dump_rom(struct sti_struct *sti) |
|---|
| 581 | 594 | { |
|---|
| 582 | | - printk(KERN_INFO " id %04x-%04x, conforms to spec rev. %d.%02x\n", |
|---|
| 595 | + struct sti_rom *rom = sti->rom->raw; |
|---|
| 596 | + struct sti_cooked_font *font_start; |
|---|
| 597 | + int nr; |
|---|
| 598 | + |
|---|
| 599 | + pr_info(" id %04x-%04x, conforms to spec rev. %d.%02x\n", |
|---|
| 583 | 600 | rom->graphics_id[0], |
|---|
| 584 | 601 | rom->graphics_id[1], |
|---|
| 585 | 602 | rom->revno[0] >> 4, |
|---|
| 586 | 603 | rom->revno[0] & 0x0f); |
|---|
| 587 | | - DPRINTK((" supports %d monitors\n", rom->num_mons)); |
|---|
| 588 | | - DPRINTK((" font start %08x\n", rom->font_start)); |
|---|
| 589 | | - DPRINTK((" region list %08x\n", rom->region_list)); |
|---|
| 590 | | - DPRINTK((" init_graph %08x\n", rom->init_graph)); |
|---|
| 591 | | - DPRINTK((" bus support %02x\n", rom->bus_support)); |
|---|
| 592 | | - DPRINTK((" ext bus support %02x\n", rom->ext_bus_support)); |
|---|
| 593 | | - DPRINTK((" alternate code type %d\n", rom->alt_code_type)); |
|---|
| 604 | + pr_debug(" supports %d monitors\n", rom->num_mons); |
|---|
| 605 | + pr_debug(" font start %08x\n", rom->font_start); |
|---|
| 606 | + pr_debug(" region list %08x\n", rom->region_list); |
|---|
| 607 | + pr_debug(" init_graph %08x\n", rom->init_graph); |
|---|
| 608 | + pr_debug(" bus support %02x\n", rom->bus_support); |
|---|
| 609 | + pr_debug(" ext bus support %02x\n", rom->ext_bus_support); |
|---|
| 610 | + pr_debug(" alternate code type %d\n", rom->alt_code_type); |
|---|
| 611 | + |
|---|
| 612 | + font_start = sti->rom->font_start; |
|---|
| 613 | + nr = 0; |
|---|
| 614 | + while (font_start) { |
|---|
| 615 | + struct sti_rom_font *f = font_start->raw; |
|---|
| 616 | + |
|---|
| 617 | + pr_info(" built-in font #%d: size %dx%d, chars %d-%d, bpc %d\n", ++nr, |
|---|
| 618 | + f->width, f->height, |
|---|
| 619 | + f->first_char, f->last_char, f->bytes_per_char); |
|---|
| 620 | + font_start = font_start->next_font; |
|---|
| 621 | + } |
|---|
| 594 | 622 | } |
|---|
| 595 | 623 | |
|---|
| 596 | 624 | |
|---|
| .. | .. |
|---|
| 627 | 655 | return 1; |
|---|
| 628 | 656 | } |
|---|
| 629 | 657 | |
|---|
| 630 | | - |
|---|
| 631 | | -static int sti_search_font(struct sti_cooked_rom *rom, int height, int width) |
|---|
| 632 | | -{ |
|---|
| 633 | | - struct sti_cooked_font *font; |
|---|
| 634 | | - int i = 0; |
|---|
| 635 | | - |
|---|
| 636 | | - for (font = rom->font_start; font; font = font->next_font, i++) { |
|---|
| 637 | | - if ((font->raw->width == width) && |
|---|
| 638 | | - (font->raw->height == height)) |
|---|
| 639 | | - return i; |
|---|
| 640 | | - } |
|---|
| 641 | | - return 0; |
|---|
| 642 | | -} |
|---|
| 643 | | - |
|---|
| 644 | 658 | #define BMODE_RELOCATE(offset) offset = (offset) / 4; |
|---|
| 645 | 659 | #define BMODE_LAST_ADDR_OFFS 0x50 |
|---|
| 646 | 660 | |
|---|
| 647 | | -static void *sti_bmode_font_raw(struct sti_cooked_font *f) |
|---|
| 661 | +void sti_font_convert_bytemode(struct sti_struct *sti, struct sti_cooked_font *f) |
|---|
| 648 | 662 | { |
|---|
| 649 | 663 | unsigned char *n, *p, *q; |
|---|
| 650 | | - int size = f->raw->bytes_per_char*256+sizeof(struct sti_rom_font); |
|---|
| 651 | | - |
|---|
| 664 | + int size = f->raw->bytes_per_char * 256 + sizeof(struct sti_rom_font); |
|---|
| 665 | + struct sti_rom_font *old_font; |
|---|
| 666 | + |
|---|
| 667 | + if (sti->wordmode) |
|---|
| 668 | + return; |
|---|
| 669 | + |
|---|
| 670 | + old_font = f->raw_ptr; |
|---|
| 652 | 671 | n = kcalloc(4, size, STI_LOWMEM); |
|---|
| 672 | + f->raw_ptr = n; |
|---|
| 653 | 673 | if (!n) |
|---|
| 654 | | - return NULL; |
|---|
| 674 | + return; |
|---|
| 655 | 675 | p = n + 3; |
|---|
| 656 | | - q = (unsigned char *)f->raw; |
|---|
| 676 | + q = (unsigned char *) f->raw; |
|---|
| 657 | 677 | while (size--) { |
|---|
| 658 | 678 | *p = *q++; |
|---|
| 659 | | - p+=4; |
|---|
| 679 | + p += 4; |
|---|
| 660 | 680 | } |
|---|
| 661 | | - return n + 3; |
|---|
| 681 | + /* store new ptr to byte-mode font and delete old font */ |
|---|
| 682 | + f->raw = (struct sti_rom_font *) (n + 3); |
|---|
| 683 | + kfree(old_font); |
|---|
| 662 | 684 | } |
|---|
| 685 | +EXPORT_SYMBOL(sti_font_convert_bytemode); |
|---|
| 663 | 686 | |
|---|
| 664 | 687 | static void sti_bmode_rom_copy(unsigned long base, unsigned long count, |
|---|
| 665 | 688 | void *dest) |
|---|
| .. | .. |
|---|
| 746 | 769 | goto out_err; |
|---|
| 747 | 770 | |
|---|
| 748 | 771 | if (!sti_cook_fonts(cooked, raw)) { |
|---|
| 749 | | - printk(KERN_ERR "No font found for STI at %08lx\n", address); |
|---|
| 772 | + pr_warn("No font found for STI at %08lx\n", address); |
|---|
| 750 | 773 | goto out_err; |
|---|
| 751 | 774 | } |
|---|
| 752 | 775 | |
|---|
| .. | .. |
|---|
| 755 | 778 | |
|---|
| 756 | 779 | address = (unsigned long) STI_PTR(raw); |
|---|
| 757 | 780 | |
|---|
| 758 | | - pr_info("STI ROM supports 32 %sbit firmware functions.\n", |
|---|
| 781 | + pr_info("STI %s ROM supports 32 %sbit firmware functions.\n", |
|---|
| 782 | + wordmode ? "word mode" : "byte mode", |
|---|
| 759 | 783 | raw->alt_code_type == ALT_CODE_TYPE_PA_RISC_64 |
|---|
| 760 | 784 | ? "and 64 " : ""); |
|---|
| 761 | 785 | |
|---|
| .. | .. |
|---|
| 766 | 790 | |
|---|
| 767 | 791 | sti->rom = cooked; |
|---|
| 768 | 792 | sti->rom->raw = raw; |
|---|
| 769 | | - |
|---|
| 770 | | - sti->font = sti_select_font(sti->rom, sti_search_font); |
|---|
| 771 | | - sti->font_width = sti->font->raw->width; |
|---|
| 772 | | - sti->font_height = sti->font->raw->height; |
|---|
| 773 | | - if (!wordmode) |
|---|
| 774 | | - sti->font->raw = sti_bmode_font_raw(sti->font); |
|---|
| 793 | + sti_dump_rom(sti); |
|---|
| 794 | + |
|---|
| 795 | + sti->wordmode = wordmode; |
|---|
| 796 | + sti->font = sti_select_font(sti->rom); |
|---|
| 797 | + sti->font->width = sti->font->raw->width; |
|---|
| 798 | + sti->font->height = sti->font->raw->height; |
|---|
| 799 | + sti_font_convert_bytemode(sti, sti->font); |
|---|
| 775 | 800 | |
|---|
| 776 | 801 | sti->sti_mem_request = raw->sti_mem_req; |
|---|
| 777 | 802 | sti->graphics_id[0] = raw->graphics_id[0]; |
|---|
| 778 | 803 | sti->graphics_id[1] = raw->graphics_id[1]; |
|---|
| 779 | | - |
|---|
| 780 | | - sti_dump_rom(raw); |
|---|
| 781 | 804 | |
|---|
| 782 | 805 | /* check if the ROM routines in this card are compatible */ |
|---|
| 783 | 806 | if (wordmode || sti->graphics_id[1] != 0x09A02587) |
|---|
| .. | .. |
|---|
| 803 | 826 | return 1; |
|---|
| 804 | 827 | |
|---|
| 805 | 828 | msg_not_supported: |
|---|
| 806 | | - printk(KERN_ERR "Sorry, this GSC/STI card is not yet supported.\n"); |
|---|
| 807 | | - printk(KERN_ERR "Please see http://parisc-linux.org/faq/" |
|---|
| 808 | | - "graphics-howto.html for more info.\n"); |
|---|
| 829 | + pr_warn("Sorry, this GSC/STI card is not yet supported.\n"); |
|---|
| 830 | + pr_warn("Please see https://parisc.wiki.kernel.org/" |
|---|
| 831 | + "index.php/Graphics_howto for more info.\n"); |
|---|
| 809 | 832 | /* fall through */ |
|---|
| 810 | 833 | out_err: |
|---|
| 811 | 834 | kfree(raw); |
|---|
| .. | .. |
|---|
| 822 | 845 | u32 sig; |
|---|
| 823 | 846 | |
|---|
| 824 | 847 | if (num_sti_roms >= MAX_STI_ROMS) { |
|---|
| 825 | | - printk(KERN_WARNING "maximum number of STI ROMS reached !\n"); |
|---|
| 848 | + pr_warn("maximum number of STI ROMS reached !\n"); |
|---|
| 826 | 849 | return NULL; |
|---|
| 827 | 850 | } |
|---|
| 828 | 851 | |
|---|
| .. | .. |
|---|
| 848 | 871 | if (i != 1) { |
|---|
| 849 | 872 | /* The ROM could have multiple architecture |
|---|
| 850 | 873 | * dependent images (e.g. i386, parisc,...) */ |
|---|
| 851 | | - printk(KERN_WARNING |
|---|
| 852 | | - "PCI ROM is not a STI ROM type image (0x%8x)\n", i); |
|---|
| 874 | + pr_warn("PCI ROM is not a STI ROM type image (0x%8x)\n", i); |
|---|
| 853 | 875 | goto out_err; |
|---|
| 854 | 876 | } |
|---|
| 855 | 877 | |
|---|
| 856 | 878 | sti->pd = pd; |
|---|
| 857 | 879 | |
|---|
| 858 | 880 | i = gsc_readl(address+0x0c); |
|---|
| 859 | | - DPRINTK(("PCI ROM size (from header) = %d kB\n", |
|---|
| 860 | | - le16_to_cpu(i>>16)*512/1024)); |
|---|
| 881 | + pr_debug("PCI ROM size (from header) = %d kB\n", |
|---|
| 882 | + le16_to_cpu(i>>16)*512/1024); |
|---|
| 861 | 883 | rm_offset = le16_to_cpu(i & 0xffff); |
|---|
| 862 | 884 | if (rm_offset) { |
|---|
| 863 | 885 | /* read 16 bytes from the pci region mapper array */ |
|---|
| .. | .. |
|---|
| 866 | 888 | *rm++ = gsc_readl(address+rm_offset+0x04); |
|---|
| 867 | 889 | *rm++ = gsc_readl(address+rm_offset+0x08); |
|---|
| 868 | 890 | *rm++ = gsc_readl(address+rm_offset+0x0c); |
|---|
| 869 | | - DPRINTK(("PCI region Mapper offset = %08x: ", |
|---|
| 870 | | - rm_offset)); |
|---|
| 871 | | - for (i=0; i<16; i++) |
|---|
| 872 | | - DPRINTK(("%02x ", sti->rm_entry[i])); |
|---|
| 873 | | - DPRINTK(("\n")); |
|---|
| 874 | 891 | } |
|---|
| 875 | 892 | |
|---|
| 876 | 893 | address += le32_to_cpu(gsc_readl(address+8)); |
|---|
| 877 | | - DPRINTK(("sig %04x, PCI STI ROM at %08lx\n", sig, address)); |
|---|
| 894 | + pr_debug("sig %04x, PCI STI ROM at %08lx\n", sig, address); |
|---|
| 878 | 895 | goto test_rom; |
|---|
| 879 | 896 | } |
|---|
| 880 | 897 | |
|---|
| 881 | 898 | ok = 0; |
|---|
| 882 | 899 | |
|---|
| 883 | 900 | if ((sig & 0xff) == 0x01) { |
|---|
| 884 | | - DPRINTK((" byte mode ROM at %08lx, hpa at %08lx\n", |
|---|
| 885 | | - address, hpa)); |
|---|
| 901 | + pr_debug(" byte mode ROM at %08lx, hpa at %08lx\n", |
|---|
| 902 | + address, hpa); |
|---|
| 886 | 903 | ok = sti_read_rom(0, sti, address); |
|---|
| 887 | 904 | } |
|---|
| 888 | 905 | |
|---|
| 889 | 906 | if ((sig & 0xffff) == 0x0303) { |
|---|
| 890 | | - DPRINTK((" word mode ROM at %08lx, hpa at %08lx\n", |
|---|
| 891 | | - address, hpa)); |
|---|
| 907 | + pr_debug(" word mode ROM at %08lx, hpa at %08lx\n", |
|---|
| 908 | + address, hpa); |
|---|
| 892 | 909 | ok = sti_read_rom(1, sti, address); |
|---|
| 893 | 910 | } |
|---|
| 894 | 911 | |
|---|
| .. | .. |
|---|
| 905 | 922 | unsigned long rom_base; |
|---|
| 906 | 923 | rom_base = pci_resource_start(sti->pd, PCI_ROM_RESOURCE); |
|---|
| 907 | 924 | pci_write_config_dword(sti->pd, PCI_ROM_ADDRESS, rom_base & ~PCI_ROM_ADDRESS_ENABLE); |
|---|
| 908 | | - DPRINTK((KERN_DEBUG "STI PCI ROM disabled\n")); |
|---|
| 925 | + pr_debug("STI PCI ROM disabled\n"); |
|---|
| 909 | 926 | } |
|---|
| 910 | 927 | |
|---|
| 911 | 928 | if (sti_init_graph(sti)) |
|---|
| .. | .. |
|---|
| 980 | 997 | rom_len = pci_resource_len(pd, PCI_ROM_RESOURCE); |
|---|
| 981 | 998 | if (rom_base) { |
|---|
| 982 | 999 | pci_write_config_dword(pd, PCI_ROM_ADDRESS, rom_base | PCI_ROM_ADDRESS_ENABLE); |
|---|
| 983 | | - DPRINTK((KERN_DEBUG "STI PCI ROM enabled at 0x%08lx\n", rom_base)); |
|---|
| 1000 | + pr_debug("STI PCI ROM enabled at 0x%08lx\n", rom_base); |
|---|
| 984 | 1001 | } |
|---|
| 985 | 1002 | |
|---|
| 986 | | - printk(KERN_INFO "STI PCI graphic ROM found at %08lx (%u kB), fb at %08lx (%u MB)\n", |
|---|
| 1003 | + pr_info("STI PCI graphic ROM found at %08lx (%u kB), fb at %08lx (%u MB)\n", |
|---|
| 987 | 1004 | rom_base, rom_len/1024, fb_base, fb_len/1024/1024); |
|---|
| 988 | 1005 | |
|---|
| 989 | | - DPRINTK((KERN_DEBUG "Trying PCI STI ROM at %08lx, PCI hpa at %08lx\n", |
|---|
| 990 | | - rom_base, fb_base)); |
|---|
| 1006 | + pr_debug("Trying PCI STI ROM at %08lx, PCI hpa at %08lx\n", |
|---|
| 1007 | + rom_base, fb_base); |
|---|
| 991 | 1008 | |
|---|
| 992 | 1009 | sti = sti_try_rom_generic(rom_base, fb_base, pd); |
|---|
| 993 | 1010 | if (sti) { |
|---|
| .. | .. |
|---|
| 997 | 1014 | } |
|---|
| 998 | 1015 | |
|---|
| 999 | 1016 | if (!sti) { |
|---|
| 1000 | | - printk(KERN_WARNING "Unable to handle STI device '%s'\n", |
|---|
| 1001 | | - pci_name(pd)); |
|---|
| 1017 | + pr_warn("Unable to handle STI device '%s'\n", pci_name(pd)); |
|---|
| 1002 | 1018 | return -ENODEV; |
|---|
| 1003 | 1019 | } |
|---|
| 1004 | 1020 | #endif /* CONFIG_PCI */ |
|---|
| .. | .. |
|---|
| 1057 | 1073 | |
|---|
| 1058 | 1074 | sticore_initialized = 1; |
|---|
| 1059 | 1075 | |
|---|
| 1060 | | - printk(KERN_INFO "STI GSC/PCI core graphics driver " |
|---|
| 1076 | + pr_info("STI GSC/PCI core graphics driver " |
|---|
| 1061 | 1077 | STI_DRIVERVERSION "\n"); |
|---|
| 1062 | 1078 | |
|---|
| 1063 | 1079 | /* Register drivers for native & PCI cards */ |
|---|
| .. | .. |
|---|
| 1112 | 1128 | return ret; |
|---|
| 1113 | 1129 | } |
|---|
| 1114 | 1130 | |
|---|
| 1131 | +#if defined(CONFIG_FB_STI) |
|---|
| 1132 | +/* check if given fb_info is the primary device */ |
|---|
| 1133 | +int fb_is_primary_device(struct fb_info *info) |
|---|
| 1134 | +{ |
|---|
| 1135 | + struct sti_struct *sti; |
|---|
| 1136 | + |
|---|
| 1137 | + sti = sti_get_rom(0); |
|---|
| 1138 | + |
|---|
| 1139 | + /* if no built-in graphics card found, allow any fb driver as default */ |
|---|
| 1140 | + if (!sti) |
|---|
| 1141 | + return true; |
|---|
| 1142 | + |
|---|
| 1143 | + /* return true if it's the default built-in framebuffer driver */ |
|---|
| 1144 | + return (sti->info == info); |
|---|
| 1145 | +} |
|---|
| 1146 | +EXPORT_SYMBOL(fb_is_primary_device); |
|---|
| 1147 | +#endif |
|---|
| 1148 | + |
|---|
| 1115 | 1149 | MODULE_AUTHOR("Philipp Rumpf, Helge Deller, Thomas Bogendoerfer"); |
|---|
| 1116 | 1150 | MODULE_DESCRIPTION("Core STI driver for HP's NGLE series graphics cards in HP PARISC machines"); |
|---|
| 1117 | 1151 | MODULE_LICENSE("GPL v2"); |
|---|