Lines Matching +full:address +full:- +full:width
1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/drivers/video/console/sticore.c -
7 * Copyright (C) 2001-2020 Helge Deller <deller@gmx.de>
8 * Copyright (C) 2001-2002 Thomas Bogendoerfer <tsbogend@alpha.franken.de>
11 * - call STI in virtual mode rather than in real mode
12 * - screen blanking with state_mgmt() in text mode STI ?
13 * - try to make it work on m68k hp workstations ;)
29 #include <asm/parisc-device.h>
46 * 0 - Black
47 * 1 - White
48 * 2 - Red
49 * 3 - Yellow/Brown
50 * 4 - Green
51 * 5 - Cyan
52 * 6 - Blue
53 * 7 - Magenta
79 struct sti_init_inptr *inptr = &sti->sti_data->init_inptr; in sti_init_graph()
80 struct sti_init_inptr_ext *inptr_ext = &sti->sti_data->init_inptr_ext; in sti_init_graph()
81 struct sti_init_outptr *outptr = &sti->sti_data->init_outptr; in sti_init_graph()
85 spin_lock_irqsave(&sti->lock, flags); in sti_init_graph()
88 inptr->text_planes = 3; /* # of text planes (max 3 for STI) */ in sti_init_graph()
90 inptr->ext_ptr = STI_PTR(inptr_ext); in sti_init_graph()
91 outptr->errno = 0; in sti_init_graph()
93 ret = sti_call(sti, sti->init_graph, &default_init_flags, inptr, in sti_init_graph()
94 outptr, sti->glob_cfg); in sti_init_graph()
97 sti->text_planes = outptr->text_planes; in sti_init_graph()
98 err = outptr->errno; in sti_init_graph()
100 spin_unlock_irqrestore(&sti->lock, flags); in sti_init_graph()
104 return -1; in sti_init_graph()
116 struct sti_conf_inptr *inptr = &sti->sti_data->inq_inptr; in sti_inq_conf()
117 struct sti_conf_outptr *outptr = &sti->sti_data->inq_outptr; in sti_inq_conf()
121 outptr->ext_ptr = STI_PTR(&sti->sti_data->inq_outptr_ext); in sti_inq_conf()
124 spin_lock_irqsave(&sti->lock, flags); in sti_inq_conf()
126 ret = sti_call(sti, sti->inq_conf, &default_conf_flags, in sti_inq_conf()
127 inptr, outptr, sti->glob_cfg); in sti_inq_conf()
128 spin_unlock_irqrestore(&sti->lock, flags); in sti_inq_conf()
141 struct sti_font_inptr *inptr = &sti->sti_data->font_inptr; in sti_putc()
143 .font_start_addr = STI_PTR(font->raw), in sti_putc()
147 .dest_x = x * font->width, in sti_putc()
148 .dest_y = y * font->height, in sti_putc()
150 struct sti_font_outptr *outptr = &sti->sti_data->font_outptr; in sti_putc()
155 spin_lock_irqsave(&sti->lock, flags); in sti_putc()
157 ret = sti_call(sti, sti->font_unpmv, &default_font_flags, in sti_putc()
158 inptr, outptr, sti->glob_cfg); in sti_putc()
159 spin_unlock_irqrestore(&sti->lock, flags); in sti_putc()
171 int height, int width, u8 color) in sti_set() argument
173 struct sti_blkmv_inptr *inptr = &sti->sti_data->blkmv_inptr; in sti_set()
181 .width = width, in sti_set()
184 struct sti_blkmv_outptr *outptr = &sti->sti_data->blkmv_outptr; in sti_set()
189 spin_lock_irqsave(&sti->lock, flags); in sti_set()
191 ret = sti_call(sti, sti->block_move, &clear_blkmv_flags, in sti_set()
192 inptr, outptr, sti->glob_cfg); in sti_set()
193 spin_unlock_irqrestore(&sti->lock, flags); in sti_set()
199 int height, int width, int c, struct sti_cooked_font *font) in sti_clear() argument
201 struct sti_blkmv_inptr *inptr = &sti->sti_data->blkmv_inptr; in sti_clear()
205 .src_x = src_x * font->width, in sti_clear()
206 .src_y = src_y * font->height, in sti_clear()
207 .dest_x = src_x * font->width, in sti_clear()
208 .dest_y = src_y * font->height, in sti_clear()
209 .width = width * font->width, in sti_clear()
210 .height = height * font->height, in sti_clear()
212 struct sti_blkmv_outptr *outptr = &sti->sti_data->blkmv_outptr; in sti_clear()
217 spin_lock_irqsave(&sti->lock, flags); in sti_clear()
219 ret = sti_call(sti, sti->block_move, &clear_blkmv_flags, in sti_clear()
220 inptr, outptr, sti->glob_cfg); in sti_clear()
221 spin_unlock_irqrestore(&sti->lock, flags); in sti_clear()
231 int dst_y, int dst_x, int height, int width, in sti_bmove() argument
234 struct sti_blkmv_inptr *inptr = &sti->sti_data->blkmv_inptr; in sti_bmove()
236 .src_x = src_x * font->width, in sti_bmove()
237 .src_y = src_y * font->height, in sti_bmove()
238 .dest_x = dst_x * font->width, in sti_bmove()
239 .dest_y = dst_y * font->height, in sti_bmove()
240 .width = width * font->width, in sti_bmove()
241 .height = height * font->height, in sti_bmove()
243 struct sti_blkmv_outptr *outptr = &sti->sti_data->blkmv_outptr; in sti_bmove()
248 spin_lock_irqsave(&sti->lock, flags); in sti_bmove()
250 ret = sti_call(sti, sti->block_move, &default_blkmv_flags, in sti_bmove()
251 inptr, outptr, sti->glob_cfg); in sti_bmove()
252 spin_unlock_irqrestore(&sti->lock, flags); in sti_bmove()
268 count -= 4; in sti_rom_copy()
274 count--; in sti_rom_copy()
299 * parameter sti=<x> which of them will be the initial boot-console.
318 * an built-in Linux framebuffer font. in sti_font_setup()
320 * the first HP STI ROM built-in font.. in sti_font_setup()
342 * - sti_font=<fb_fontname>:
343 * <fb_fontname> is the name of one of the linux-kernel built-in
347 * - sti_font=<number> (<number> = 1,2,3,...)
348 * most STI ROMs have built-in HP specific fonts, which can be selected
351 * - sti_font=<height>x<width> (e.g. sti_font=16x8)
352 * <height> and <width> gives hints to the height and width of the
354 * a font with this height and width, but if no suitable font is
375 glob_cfg->text_planes, in sti_dump_globcfg()
376 glob_cfg->onscreen_x, glob_cfg->onscreen_y, in sti_dump_globcfg()
377 glob_cfg->offscreen_x, glob_cfg->offscreen_y, in sti_dump_globcfg()
378 glob_cfg->total_x, glob_cfg->total_y, in sti_dump_globcfg()
379 glob_cfg->region_ptrs[0], glob_cfg->region_ptrs[1], in sti_dump_globcfg()
380 glob_cfg->region_ptrs[2], glob_cfg->region_ptrs[3], in sti_dump_globcfg()
381 glob_cfg->region_ptrs[4], glob_cfg->region_ptrs[5], in sti_dump_globcfg()
382 glob_cfg->region_ptrs[6], glob_cfg->region_ptrs[7], in sti_dump_globcfg()
383 glob_cfg->reent_lvl, in sti_dump_globcfg()
384 glob_cfg->save_addr); in sti_dump_globcfg()
387 cfg = PTR_STI((unsigned long)glob_cfg->ext_ptr); in sti_dump_globcfg()
393 cfg->curr_mon, in sti_dump_globcfg()
394 cfg->friendly_boot, in sti_dump_globcfg()
395 cfg->power, in sti_dump_globcfg()
396 cfg->freq_ref, in sti_dump_globcfg()
397 cfg->sti_mem_addr, sti_mem_request); in sti_dump_globcfg()
406 sti->sti_data->inq_outptr.bits_per_pixel, in sti_dump_outptr()
407 sti->sti_data->inq_outptr.bits_used, in sti_dump_outptr()
408 sti->sti_data->inq_outptr.planes, in sti_dump_outptr()
409 sti->sti_data->inq_outptr.attributes); in sti_dump_outptr()
421 if (sti->sti_mem_request < 256) in sti_init_glob_cfg()
422 sti->sti_mem_request = 256; /* STI default */ in sti_init_glob_cfg()
424 size = sizeof(struct sti_all_data) + sti->sti_mem_request - 256; in sti_init_glob_cfg()
426 sti->sti_data = kzalloc(size, STI_LOWMEM); in sti_init_glob_cfg()
427 if (!sti->sti_data) in sti_init_glob_cfg()
428 return -ENOMEM; in sti_init_glob_cfg()
430 glob_cfg = &sti->sti_data->glob_cfg; in sti_init_glob_cfg()
431 glob_cfg_ext = &sti->sti_data->glob_cfg_ext; in sti_init_glob_cfg()
432 save_addr = &sti->sti_data->save_addr; in sti_init_glob_cfg()
433 sti_mem_addr = &sti->sti_data->sti_mem_addr; in sti_init_glob_cfg()
435 glob_cfg->ext_ptr = STI_PTR(glob_cfg_ext); in sti_init_glob_cfg()
436 glob_cfg->save_addr = STI_PTR(save_addr); in sti_init_glob_cfg()
440 if (sti->pd) { in sti_init_glob_cfg()
441 unsigned char offs = sti->rm_entry[i]; in sti_init_glob_cfg()
449 i,sti->rm_entry[i]); in sti_init_glob_cfg()
452 newhpa = pci_resource_start (sti->pd, (offs - PCI_BASE_ADDRESS_0) / 4); in sti_init_glob_cfg()
456 sti->regions_phys[i] = in sti_init_glob_cfg()
457 REGION_OFFSET_TO_PHYS(sti->regions[i], newhpa); in sti_init_glob_cfg()
459 len = sti->regions[i].region_desc.length * 4096; in sti_init_glob_cfg()
461 glob_cfg->region_ptrs[i] = sti->regions_phys[i]; in sti_init_glob_cfg()
465 i, sti->regions_phys[i], glob_cfg->region_ptrs[i], in sti_init_glob_cfg()
467 sti->regions[i].region_desc.btlb, in sti_init_glob_cfg()
468 sti->regions[i].region_desc.sys_only, in sti_init_glob_cfg()
469 sti->regions[i].region_desc.cache, in sti_init_glob_cfg()
470 sti->regions[i].region_desc.last); in sti_init_glob_cfg()
473 if (sti->regions[i].region_desc.last) in sti_init_glob_cfg()
477 if (++i<8 && sti->regions[i].region) in sti_init_glob_cfg()
479 sti->regions[i].region); in sti_init_glob_cfg()
481 glob_cfg_ext->sti_mem_addr = STI_PTR(sti_mem_addr); in sti_init_glob_cfg()
483 sti->glob_cfg = glob_cfg; in sti_init_glob_cfg()
506 fbfont->width, fbfont->height, fbfont->name); in sti_select_fbfont()
508 bpc = ((fbfont->width+7)/8) * fbfont->height; in sti_select_fbfont()
516 nf->first_char = 0; in sti_select_fbfont()
517 nf->last_char = 255; in sti_select_fbfont()
518 nf->width = fbfont->width; in sti_select_fbfont()
519 nf->height = fbfont->height; in sti_select_fbfont()
520 nf->font_type = STI_FONT_HPROMAN8; in sti_select_fbfont()
521 nf->bytes_per_char = bpc; in sti_select_fbfont()
522 nf->next_font = 0; in sti_select_fbfont()
523 nf->underline_height = 1; in sti_select_fbfont()
524 nf->underline_pos = fbfont->height - nf->underline_height; in sti_select_fbfont()
528 memcpy(dest, fbfont->data, bpc*256); in sti_select_fbfont()
536 cooked_font->raw = nf; in sti_select_fbfont()
537 cooked_font->raw_ptr = nf; in sti_select_fbfont()
538 cooked_font->next_font = NULL; in sti_select_fbfont()
540 cooked_rom->font_start = cooked_font; in sti_select_fbfont()
552 static int sti_search_font(struct sti_cooked_rom *rom, int height, int width) in sti_search_font() argument
557 for (font = rom->font_start; font; font = font->next_font, i++) { in sti_search_font()
558 if ((font->raw->width == width) && in sti_search_font()
559 (font->raw->height == height)) in sti_search_font()
570 /* check for framebuffer-font first */ in sti_select_font()
581 for (font = rom->font_start, i = font_index - 1; in sti_select_font()
583 font = font->next_font, i--); in sti_select_font()
588 return rom->font_start; in sti_select_font()
594 struct sti_rom *rom = sti->rom->raw; in sti_dump_rom()
598 pr_info(" id %04x-%04x, conforms to spec rev. %d.%02x\n", in sti_dump_rom()
599 rom->graphics_id[0], in sti_dump_rom()
600 rom->graphics_id[1], in sti_dump_rom()
601 rom->revno[0] >> 4, in sti_dump_rom()
602 rom->revno[0] & 0x0f); in sti_dump_rom()
603 pr_debug(" supports %d monitors\n", rom->num_mons); in sti_dump_rom()
604 pr_debug(" font start %08x\n", rom->font_start); in sti_dump_rom()
605 pr_debug(" region list %08x\n", rom->region_list); in sti_dump_rom()
606 pr_debug(" init_graph %08x\n", rom->init_graph); in sti_dump_rom()
607 pr_debug(" bus support %02x\n", rom->bus_support); in sti_dump_rom()
608 pr_debug(" ext bus support %02x\n", rom->ext_bus_support); in sti_dump_rom()
609 pr_debug(" alternate code type %d\n", rom->alt_code_type); in sti_dump_rom()
611 font_start = sti->rom->font_start; in sti_dump_rom()
614 struct sti_rom_font *f = font_start->raw; in sti_dump_rom()
616 pr_info(" built-in font #%d: size %dx%d, chars %d-%d, bpc %d\n", ++nr, in sti_dump_rom()
617 f->width, f->height, in sti_dump_rom()
618 f->first_char, f->last_char, f->bytes_per_char); in sti_dump_rom()
619 font_start = font_start->next_font; in sti_dump_rom()
634 cooked_rom->font_start = cooked_font; in sti_cook_fonts()
636 raw_font = ((void *)raw_rom) + (raw_rom->font_start); in sti_cook_fonts()
639 cooked_font->raw = raw_font; in sti_cook_fonts()
641 while (raw_font->next_font) { in sti_cook_fonts()
642 raw_font = ((void *)font_start) + (raw_font->next_font); in sti_cook_fonts()
644 cooked_font->next_font = kzalloc(sizeof(*cooked_font), GFP_KERNEL); in sti_cook_fonts()
645 if (!cooked_font->next_font) in sti_cook_fonts()
648 cooked_font = cooked_font->next_font; in sti_cook_fonts()
650 cooked_font->raw = raw_font; in sti_cook_fonts()
653 cooked_font->next_font = NULL; in sti_cook_fonts()
663 int size = f->raw->bytes_per_char * 256 + sizeof(struct sti_rom_font); in sti_font_convert_bytemode()
666 if (sti->wordmode) in sti_font_convert_bytemode()
669 old_font = f->raw_ptr; in sti_font_convert_bytemode()
671 f->raw_ptr = n; in sti_font_convert_bytemode()
675 q = (unsigned char *) f->raw; in sti_font_convert_bytemode()
676 while (size--) { in sti_font_convert_bytemode()
680 /* store new ptr to byte-mode font and delete old font */ in sti_font_convert_bytemode()
681 f->raw = (struct sti_rom_font *) (n + 3); in sti_font_convert_bytemode()
692 count--; in sti_bmode_rom_copy()
701 static struct sti_rom *sti_get_bmode_rom (unsigned long address) in sti_get_bmode_rom() argument
707 sti_bmode_rom_copy(address + BMODE_LAST_ADDR_OFFS, sizeof(size), &size); in sti_get_bmode_rom()
712 sti_bmode_rom_copy(address, size, raw); in sti_get_bmode_rom()
713 memmove (&raw->res004, &raw->type[0], 0x3c); in sti_get_bmode_rom()
714 raw->type[3] = raw->res004; in sti_get_bmode_rom()
716 BMODE_RELOCATE (raw->region_list); in sti_get_bmode_rom()
717 BMODE_RELOCATE (raw->font_start); in sti_get_bmode_rom()
719 BMODE_RELOCATE (raw->init_graph); in sti_get_bmode_rom()
720 BMODE_RELOCATE (raw->state_mgmt); in sti_get_bmode_rom()
721 BMODE_RELOCATE (raw->font_unpmv); in sti_get_bmode_rom()
722 BMODE_RELOCATE (raw->block_move); in sti_get_bmode_rom()
723 BMODE_RELOCATE (raw->inq_conf); in sti_get_bmode_rom()
725 raw_font = ((void *)raw) + raw->font_start; in sti_get_bmode_rom()
728 while (raw_font->next_font) { in sti_get_bmode_rom()
729 BMODE_RELOCATE (raw_font->next_font); in sti_get_bmode_rom()
730 raw_font = ((void *)font_start) + raw_font->next_font; in sti_get_bmode_rom()
736 static struct sti_rom *sti_get_wmode_rom(unsigned long address) in sti_get_wmode_rom() argument
742 size = gsc_readl(address + offsetof(struct sti_rom,last_addr)); in sti_get_wmode_rom()
746 sti_rom_copy(address, size, raw); in sti_get_wmode_rom()
752 unsigned long address) in sti_read_rom() argument
763 raw = sti_get_wmode_rom (address); in sti_read_rom()
765 raw = sti_get_bmode_rom (address); in sti_read_rom()
771 pr_warn("No font found for STI at %08lx\n", address); in sti_read_rom()
775 if (raw->region_list) in sti_read_rom()
776 memcpy(sti->regions, ((void *)raw)+raw->region_list, sizeof(sti->regions)); in sti_read_rom()
778 address = (unsigned long) STI_PTR(raw); in sti_read_rom()
782 raw->alt_code_type == ALT_CODE_TYPE_PA_RISC_64 in sti_read_rom()
785 sti->font_unpmv = address + (raw->font_unpmv & 0x03ffffff); in sti_read_rom()
786 sti->block_move = address + (raw->block_move & 0x03ffffff); in sti_read_rom()
787 sti->init_graph = address + (raw->init_graph & 0x03ffffff); in sti_read_rom()
788 sti->inq_conf = address + (raw->inq_conf & 0x03ffffff); in sti_read_rom()
790 sti->rom = cooked; in sti_read_rom()
791 sti->rom->raw = raw; in sti_read_rom()
794 sti->wordmode = wordmode; in sti_read_rom()
795 sti->font = sti_select_font(sti->rom); in sti_read_rom()
796 sti->font->width = sti->font->raw->width; in sti_read_rom()
797 sti->font->height = sti->font->raw->height; in sti_read_rom()
798 sti_font_convert_bytemode(sti, sti->font); in sti_read_rom()
800 sti->sti_mem_request = raw->sti_mem_req; in sti_read_rom()
801 sti->graphics_id[0] = raw->graphics_id[0]; in sti_read_rom()
802 sti->graphics_id[1] = raw->graphics_id[1]; in sti_read_rom()
805 if (wordmode || sti->graphics_id[1] != 0x09A02587) in sti_read_rom()
808 revno = (raw->revno[0] << 8) | raw->revno[1]; in sti_read_rom()
810 switch (sti->graphics_id[0]) { in sti_read_rom()
838 static struct sti_struct *sti_try_rom_generic(unsigned long address, in sti_try_rom_generic() argument
855 spin_lock_init(&sti->lock); in sti_try_rom_generic()
860 if (pdc_add_valid(address)) in sti_try_rom_generic()
863 sig = gsc_readl(address); in sti_try_rom_generic()
869 i = gsc_readl(address+0x04); in sti_try_rom_generic()
877 sti->pd = pd; in sti_try_rom_generic()
879 i = gsc_readl(address+0x0c); in sti_try_rom_generic()
885 rm = (u32*) &sti->rm_entry; in sti_try_rom_generic()
886 *rm++ = gsc_readl(address+rm_offset+0x00); in sti_try_rom_generic()
887 *rm++ = gsc_readl(address+rm_offset+0x04); in sti_try_rom_generic()
888 *rm++ = gsc_readl(address+rm_offset+0x08); in sti_try_rom_generic()
889 *rm++ = gsc_readl(address+rm_offset+0x0c); in sti_try_rom_generic()
892 address += le32_to_cpu(gsc_readl(address+8)); in sti_try_rom_generic()
893 pr_debug("sig %04x, PCI STI ROM at %08lx\n", sig, address); in sti_try_rom_generic()
901 address, hpa); in sti_try_rom_generic()
902 ok = sti_read_rom(0, sti, address); in sti_try_rom_generic()
907 address, hpa); in sti_try_rom_generic()
908 ok = sti_read_rom(1, sti, address); in sti_try_rom_generic()
914 if (sti_init_glob_cfg(sti, address, hpa)) in sti_try_rom_generic()
920 if (sti->pd) { in sti_try_rom_generic()
922 rom_base = pci_resource_start(sti->pd, PCI_ROM_RESOURCE); in sti_try_rom_generic()
923 pci_write_config_dword(sti->pd, PCI_ROM_ADDRESS, rom_base & ~PCI_ROM_ADDRESS_ENABLE); in sti_try_rom_generic()
931 sti_dump_globcfg(sti->glob_cfg, sti->sti_mem_request); in sti_try_rom_generic()
935 sti->sti_data->inq_outptr.dev_name); in sti_try_rom_generic()
954 * on newer systems PDC gives the address of the ROM
955 * in the additional address field addr[1] while on
956 * older Systems the PDC stores it in page0->proc_sti
962 int hpa = dev->hpa.start; in sticore_pa_init()
964 if (dev->num_addrs && dev->addr[0]) in sticore_pa_init()
965 sti = sti_try_rom_generic(dev->addr[0], hpa, NULL); in sticore_pa_init()
969 sti = sti_try_rom_generic(PAGE0->proc_sti, hpa, NULL); in sticore_pa_init()
989 dev_err(&pd->dev, "Cannot enable PCI device\n"); in sticore_pci_init()
1017 return -ENODEV; in sticore_pci_init()
1063 * sti_init_roms() - detects all STI ROMs and stores them in sti_roms[]
1103 return sti_roms[index-1]; in sti_get_rom()
1121 "Out of 32bit-range pointers!")) in sti_call()
1122 return -1; in sti_call()