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>
47 * 0 - Black
48 * 1 - White
49 * 2 - Red
50 * 3 - Yellow/Brown
51 * 4 - Green
52 * 5 - Cyan
53 * 6 - Blue
54 * 7 - Magenta
80 struct sti_init_inptr *inptr = &sti->sti_data->init_inptr; in sti_init_graph()
81 struct sti_init_inptr_ext *inptr_ext = &sti->sti_data->init_inptr_ext; in sti_init_graph()
82 struct sti_init_outptr *outptr = &sti->sti_data->init_outptr; in sti_init_graph()
86 spin_lock_irqsave(&sti->lock, flags); in sti_init_graph()
89 inptr->text_planes = 3; /* # of text planes (max 3 for STI) */ in sti_init_graph()
91 inptr->ext_ptr = STI_PTR(inptr_ext); in sti_init_graph()
92 outptr->errno = 0; in sti_init_graph()
94 ret = sti_call(sti, sti->init_graph, &default_init_flags, inptr, in sti_init_graph()
95 outptr, sti->glob_cfg); in sti_init_graph()
98 sti->text_planes = outptr->text_planes; in sti_init_graph()
99 err = outptr->errno; in sti_init_graph()
101 spin_unlock_irqrestore(&sti->lock, flags); in sti_init_graph()
105 return -1; in sti_init_graph()
117 struct sti_conf_inptr *inptr = &sti->sti_data->inq_inptr; in sti_inq_conf()
118 struct sti_conf_outptr *outptr = &sti->sti_data->inq_outptr; in sti_inq_conf()
122 outptr->ext_ptr = STI_PTR(&sti->sti_data->inq_outptr_ext); in sti_inq_conf()
125 spin_lock_irqsave(&sti->lock, flags); in sti_inq_conf()
127 ret = sti_call(sti, sti->inq_conf, &default_conf_flags, in sti_inq_conf()
128 inptr, outptr, sti->glob_cfg); in sti_inq_conf()
129 spin_unlock_irqrestore(&sti->lock, flags); in sti_inq_conf()
142 struct sti_font_inptr *inptr = &sti->sti_data->font_inptr; in sti_putc()
144 .font_start_addr = STI_PTR(font->raw), in sti_putc()
148 .dest_x = x * font->width, in sti_putc()
149 .dest_y = y * font->height, in sti_putc()
151 struct sti_font_outptr *outptr = &sti->sti_data->font_outptr; in sti_putc()
156 spin_lock_irqsave(&sti->lock, flags); in sti_putc()
158 ret = sti_call(sti, sti->font_unpmv, &default_font_flags, in sti_putc()
159 inptr, outptr, sti->glob_cfg); in sti_putc()
160 spin_unlock_irqrestore(&sti->lock, flags); in sti_putc()
172 int height, int width, u8 color) in sti_set() argument
174 struct sti_blkmv_inptr *inptr = &sti->sti_data->blkmv_inptr; in sti_set()
182 .width = width, in sti_set()
185 struct sti_blkmv_outptr *outptr = &sti->sti_data->blkmv_outptr; in sti_set()
190 spin_lock_irqsave(&sti->lock, flags); in sti_set()
192 ret = sti_call(sti, sti->block_move, &clear_blkmv_flags, in sti_set()
193 inptr, outptr, sti->glob_cfg); in sti_set()
194 spin_unlock_irqrestore(&sti->lock, flags); in sti_set()
200 int height, int width, int c, struct sti_cooked_font *font) in sti_clear() argument
202 struct sti_blkmv_inptr *inptr = &sti->sti_data->blkmv_inptr; in sti_clear()
206 .src_x = src_x * font->width, in sti_clear()
207 .src_y = src_y * font->height, in sti_clear()
208 .dest_x = src_x * font->width, in sti_clear()
209 .dest_y = src_y * font->height, in sti_clear()
210 .width = width * font->width, in sti_clear()
211 .height = height * font->height, in sti_clear()
213 struct sti_blkmv_outptr *outptr = &sti->sti_data->blkmv_outptr; in sti_clear()
218 spin_lock_irqsave(&sti->lock, flags); in sti_clear()
220 ret = sti_call(sti, sti->block_move, &clear_blkmv_flags, in sti_clear()
221 inptr, outptr, sti->glob_cfg); in sti_clear()
222 spin_unlock_irqrestore(&sti->lock, flags); in sti_clear()
232 int dst_y, int dst_x, int height, int width, in sti_bmove() argument
235 struct sti_blkmv_inptr *inptr = &sti->sti_data->blkmv_inptr; in sti_bmove()
237 .src_x = src_x * font->width, in sti_bmove()
238 .src_y = src_y * font->height, in sti_bmove()
239 .dest_x = dst_x * font->width, in sti_bmove()
240 .dest_y = dst_y * font->height, in sti_bmove()
241 .width = width * font->width, in sti_bmove()
242 .height = height * font->height, in sti_bmove()
244 struct sti_blkmv_outptr *outptr = &sti->sti_data->blkmv_outptr; in sti_bmove()
249 spin_lock_irqsave(&sti->lock, flags); in sti_bmove()
251 ret = sti_call(sti, sti->block_move, &default_blkmv_flags, in sti_bmove()
252 inptr, outptr, sti->glob_cfg); in sti_bmove()
253 spin_unlock_irqrestore(&sti->lock, flags); in sti_bmove()
269 count -= 4; in sti_rom_copy()
275 count--; in sti_rom_copy()
300 * parameter sti=<x> which of them will be the initial boot-console.
319 * an built-in Linux framebuffer font. in sti_font_setup()
321 * the first HP STI ROM built-in font.. in sti_font_setup()
343 * - sti_font=<fb_fontname>:
344 * <fb_fontname> is the name of one of the linux-kernel built-in
348 * - sti_font=<number> (<number> = 1,2,3,...)
349 * most STI ROMs have built-in HP specific fonts, which can be selected
352 * - sti_font=<height>x<width> (e.g. sti_font=16x8)
353 * <height> and <width> gives hints to the height and width of the
355 * a font with this height and width, but if no suitable font is
376 glob_cfg->text_planes, in sti_dump_globcfg()
377 glob_cfg->onscreen_x, glob_cfg->onscreen_y, in sti_dump_globcfg()
378 glob_cfg->offscreen_x, glob_cfg->offscreen_y, in sti_dump_globcfg()
379 glob_cfg->total_x, glob_cfg->total_y, in sti_dump_globcfg()
380 glob_cfg->region_ptrs[0], glob_cfg->region_ptrs[1], in sti_dump_globcfg()
381 glob_cfg->region_ptrs[2], glob_cfg->region_ptrs[3], in sti_dump_globcfg()
382 glob_cfg->region_ptrs[4], glob_cfg->region_ptrs[5], in sti_dump_globcfg()
383 glob_cfg->region_ptrs[6], glob_cfg->region_ptrs[7], in sti_dump_globcfg()
384 glob_cfg->reent_lvl, in sti_dump_globcfg()
385 glob_cfg->save_addr); in sti_dump_globcfg()
388 cfg = PTR_STI((unsigned long)glob_cfg->ext_ptr); in sti_dump_globcfg()
394 cfg->curr_mon, in sti_dump_globcfg()
395 cfg->friendly_boot, in sti_dump_globcfg()
396 cfg->power, in sti_dump_globcfg()
397 cfg->freq_ref, in sti_dump_globcfg()
398 cfg->sti_mem_addr, sti_mem_request); in sti_dump_globcfg()
407 sti->sti_data->inq_outptr.bits_per_pixel, in sti_dump_outptr()
408 sti->sti_data->inq_outptr.bits_used, in sti_dump_outptr()
409 sti->sti_data->inq_outptr.planes, in sti_dump_outptr()
410 sti->sti_data->inq_outptr.attributes); in sti_dump_outptr()
422 if (sti->sti_mem_request < 256) in sti_init_glob_cfg()
423 sti->sti_mem_request = 256; /* STI default */ in sti_init_glob_cfg()
425 size = sizeof(struct sti_all_data) + sti->sti_mem_request - 256; in sti_init_glob_cfg()
427 sti->sti_data = kzalloc(size, STI_LOWMEM); in sti_init_glob_cfg()
428 if (!sti->sti_data) in sti_init_glob_cfg()
429 return -ENOMEM; in sti_init_glob_cfg()
431 glob_cfg = &sti->sti_data->glob_cfg; in sti_init_glob_cfg()
432 glob_cfg_ext = &sti->sti_data->glob_cfg_ext; in sti_init_glob_cfg()
433 save_addr = &sti->sti_data->save_addr; in sti_init_glob_cfg()
434 sti_mem_addr = &sti->sti_data->sti_mem_addr; in sti_init_glob_cfg()
436 glob_cfg->ext_ptr = STI_PTR(glob_cfg_ext); in sti_init_glob_cfg()
437 glob_cfg->save_addr = STI_PTR(save_addr); in sti_init_glob_cfg()
441 if (sti->pd) { in sti_init_glob_cfg()
442 unsigned char offs = sti->rm_entry[i]; in sti_init_glob_cfg()
450 i,sti->rm_entry[i]); in sti_init_glob_cfg()
453 newhpa = pci_resource_start (sti->pd, (offs - PCI_BASE_ADDRESS_0) / 4); in sti_init_glob_cfg()
457 sti->regions_phys[i] = in sti_init_glob_cfg()
458 REGION_OFFSET_TO_PHYS(sti->regions[i], newhpa); in sti_init_glob_cfg()
460 len = sti->regions[i].region_desc.length * 4096; in sti_init_glob_cfg()
462 glob_cfg->region_ptrs[i] = sti->regions_phys[i]; in sti_init_glob_cfg()
466 i, sti->regions_phys[i], glob_cfg->region_ptrs[i], in sti_init_glob_cfg()
468 sti->regions[i].region_desc.btlb, in sti_init_glob_cfg()
469 sti->regions[i].region_desc.sys_only, in sti_init_glob_cfg()
470 sti->regions[i].region_desc.cache, in sti_init_glob_cfg()
471 sti->regions[i].region_desc.last); in sti_init_glob_cfg()
474 if (sti->regions[i].region_desc.last) in sti_init_glob_cfg()
478 if (++i<8 && sti->regions[i].region) in sti_init_glob_cfg()
480 sti->regions[i].region); in sti_init_glob_cfg()
482 glob_cfg_ext->sti_mem_addr = STI_PTR(sti_mem_addr); in sti_init_glob_cfg()
484 sti->glob_cfg = glob_cfg; in sti_init_glob_cfg()
507 fbfont->width, fbfont->height, fbfont->name); in sti_select_fbfont()
509 bpc = ((fbfont->width+7)/8) * fbfont->height; in sti_select_fbfont()
510 size = bpc * fbfont->charcount; in sti_select_fbfont()
517 nf->first_char = 0; in sti_select_fbfont()
518 nf->last_char = fbfont->charcount - 1; in sti_select_fbfont()
519 nf->width = fbfont->width; in sti_select_fbfont()
520 nf->height = fbfont->height; in sti_select_fbfont()
521 nf->font_type = STI_FONT_HPROMAN8; in sti_select_fbfont()
522 nf->bytes_per_char = bpc; in sti_select_fbfont()
523 nf->next_font = 0; in sti_select_fbfont()
524 nf->underline_height = 1; in sti_select_fbfont()
525 nf->underline_pos = fbfont->height - nf->underline_height; in sti_select_fbfont()
529 memcpy(dest, fbfont->data, bpc * fbfont->charcount); in sti_select_fbfont()
537 cooked_font->raw = nf; in sti_select_fbfont()
538 cooked_font->raw_ptr = nf; in sti_select_fbfont()
539 cooked_font->next_font = NULL; in sti_select_fbfont()
541 cooked_rom->font_start = cooked_font; in sti_select_fbfont()
556 unsigned char *p = (unsigned char *)font->raw; in sti_dump_font()
560 pr_debug(" w %d h %d bpc %d\n", font->width, font->height, in sti_dump_font()
561 font->raw->bytes_per_char); in sti_dump_font()
563 for (n = 0; n < 256 * font->raw->bytes_per_char; n += 16, p += 16) { in sti_dump_font()
573 static int sti_search_font(struct sti_cooked_rom *rom, int height, int width) in sti_search_font() argument
578 for (font = rom->font_start; font; font = font->next_font, i++) { in sti_search_font()
579 if ((font->raw->width == width) && in sti_search_font()
580 (font->raw->height == height)) in sti_search_font()
591 /* check for framebuffer-font first */ in sti_select_font()
602 for (font = rom->font_start, i = font_index - 1; in sti_select_font()
604 font = font->next_font, i--); in sti_select_font()
609 return rom->font_start; in sti_select_font()
615 struct sti_rom *rom = sti->rom->raw; in sti_dump_rom()
619 pr_info(" id %04x-%04x, conforms to spec rev. %d.%02x\n", in sti_dump_rom()
620 rom->graphics_id[0], in sti_dump_rom()
621 rom->graphics_id[1], in sti_dump_rom()
622 rom->revno[0] >> 4, in sti_dump_rom()
623 rom->revno[0] & 0x0f); in sti_dump_rom()
624 pr_debug(" supports %d monitors\n", rom->num_mons); in sti_dump_rom()
625 pr_debug(" font start %08x\n", rom->font_start); in sti_dump_rom()
626 pr_debug(" region list %08x\n", rom->region_list); in sti_dump_rom()
627 pr_debug(" init_graph %08x\n", rom->init_graph); in sti_dump_rom()
628 pr_debug(" bus support %02x\n", rom->bus_support); in sti_dump_rom()
629 pr_debug(" ext bus support %02x\n", rom->ext_bus_support); in sti_dump_rom()
630 pr_debug(" alternate code type %d\n", rom->alt_code_type); in sti_dump_rom()
632 font_start = sti->rom->font_start; in sti_dump_rom()
635 struct sti_rom_font *f = font_start->raw; in sti_dump_rom()
637 pr_info(" built-in font #%d: size %dx%d, chars %d-%d, bpc %d\n", ++nr, in sti_dump_rom()
638 f->width, f->height, in sti_dump_rom()
639 f->first_char, f->last_char, f->bytes_per_char); in sti_dump_rom()
640 font_start = font_start->next_font; in sti_dump_rom()
655 cooked_rom->font_start = cooked_font; in sti_cook_fonts()
657 raw_font = ((void *)raw_rom) + (raw_rom->font_start); in sti_cook_fonts()
660 cooked_font->raw = raw_font; in sti_cook_fonts()
662 while (raw_font->next_font) { in sti_cook_fonts()
663 raw_font = ((void *)font_start) + (raw_font->next_font); in sti_cook_fonts()
665 cooked_font->next_font = kzalloc(sizeof(*cooked_font), GFP_KERNEL); in sti_cook_fonts()
666 if (!cooked_font->next_font) in sti_cook_fonts()
669 cooked_font = cooked_font->next_font; in sti_cook_fonts()
671 cooked_font->raw = raw_font; in sti_cook_fonts()
674 cooked_font->next_font = NULL; in sti_cook_fonts()
684 int size = f->raw->bytes_per_char * (f->raw->last_char + 1) + sizeof(struct sti_rom_font); in sti_font_convert_bytemode()
687 if (sti->wordmode) in sti_font_convert_bytemode()
690 old_font = f->raw_ptr; in sti_font_convert_bytemode()
692 f->raw_ptr = n; in sti_font_convert_bytemode()
696 q = (unsigned char *) f->raw; in sti_font_convert_bytemode()
697 while (size--) { in sti_font_convert_bytemode()
701 /* store new ptr to byte-mode font and delete old font */ in sti_font_convert_bytemode()
702 f->raw = (struct sti_rom_font *) (n + 3); in sti_font_convert_bytemode()
713 count--; in sti_bmode_rom_copy()
722 static struct sti_rom *sti_get_bmode_rom (unsigned long address) in sti_get_bmode_rom() argument
728 sti_bmode_rom_copy(address + BMODE_LAST_ADDR_OFFS, sizeof(size), &size); in sti_get_bmode_rom()
733 sti_bmode_rom_copy(address, size, raw); in sti_get_bmode_rom()
734 memmove (&raw->res004, &raw->type[0], 0x3c); in sti_get_bmode_rom()
735 raw->type[3] = raw->res004; in sti_get_bmode_rom()
737 BMODE_RELOCATE (raw->region_list); in sti_get_bmode_rom()
738 BMODE_RELOCATE (raw->font_start); in sti_get_bmode_rom()
740 BMODE_RELOCATE (raw->init_graph); in sti_get_bmode_rom()
741 BMODE_RELOCATE (raw->state_mgmt); in sti_get_bmode_rom()
742 BMODE_RELOCATE (raw->font_unpmv); in sti_get_bmode_rom()
743 BMODE_RELOCATE (raw->block_move); in sti_get_bmode_rom()
744 BMODE_RELOCATE (raw->inq_conf); in sti_get_bmode_rom()
746 raw_font = ((void *)raw) + raw->font_start; in sti_get_bmode_rom()
749 while (raw_font->next_font) { in sti_get_bmode_rom()
750 BMODE_RELOCATE (raw_font->next_font); in sti_get_bmode_rom()
751 raw_font = ((void *)font_start) + raw_font->next_font; in sti_get_bmode_rom()
757 static struct sti_rom *sti_get_wmode_rom(unsigned long address) in sti_get_wmode_rom() argument
763 size = gsc_readl(address + offsetof(struct sti_rom,last_addr)); in sti_get_wmode_rom()
767 sti_rom_copy(address, size, raw); in sti_get_wmode_rom()
773 unsigned long address) in sti_read_rom() argument
784 raw = sti_get_wmode_rom (address); in sti_read_rom()
786 raw = sti_get_bmode_rom (address); in sti_read_rom()
792 pr_warn("No font found for STI at %08lx\n", address); in sti_read_rom()
796 if (raw->region_list) in sti_read_rom()
797 memcpy(sti->regions, ((void *)raw)+raw->region_list, sizeof(sti->regions)); in sti_read_rom()
799 address = (unsigned long) STI_PTR(raw); in sti_read_rom()
803 raw->alt_code_type == ALT_CODE_TYPE_PA_RISC_64 in sti_read_rom()
806 sti->font_unpmv = address + (raw->font_unpmv & 0x03ffffff); in sti_read_rom()
807 sti->block_move = address + (raw->block_move & 0x03ffffff); in sti_read_rom()
808 sti->init_graph = address + (raw->init_graph & 0x03ffffff); in sti_read_rom()
809 sti->inq_conf = address + (raw->inq_conf & 0x03ffffff); in sti_read_rom()
811 sti->rom = cooked; in sti_read_rom()
812 sti->rom->raw = raw; in sti_read_rom()
815 sti->wordmode = wordmode; in sti_read_rom()
816 sti->font = sti_select_font(sti->rom); in sti_read_rom()
817 sti->font->width = sti->font->raw->width; in sti_read_rom()
818 sti->font->height = sti->font->raw->height; in sti_read_rom()
819 sti_font_convert_bytemode(sti, sti->font); in sti_read_rom()
820 sti_dump_font(sti->font); in sti_read_rom()
822 sti->sti_mem_request = raw->sti_mem_req; in sti_read_rom()
823 sti->graphics_id[0] = raw->graphics_id[0]; in sti_read_rom()
824 sti->graphics_id[1] = raw->graphics_id[1]; in sti_read_rom()
827 if (wordmode || sti->graphics_id[1] != 0x09A02587) in sti_read_rom()
830 revno = (raw->revno[0] << 8) | raw->revno[1]; in sti_read_rom()
832 switch (sti->graphics_id[0]) { in sti_read_rom()
860 static struct sti_struct *sti_try_rom_generic(unsigned long address, in sti_try_rom_generic() argument
877 spin_lock_init(&sti->lock); in sti_try_rom_generic()
882 if (pdc_add_valid(address)) in sti_try_rom_generic()
885 sig = gsc_readl(address); in sti_try_rom_generic()
891 i = gsc_readl(address+0x04); in sti_try_rom_generic()
899 sti->pd = pd; in sti_try_rom_generic()
901 i = gsc_readl(address+0x0c); in sti_try_rom_generic()
907 rm = (u32*) &sti->rm_entry; in sti_try_rom_generic()
908 *rm++ = gsc_readl(address+rm_offset+0x00); in sti_try_rom_generic()
909 *rm++ = gsc_readl(address+rm_offset+0x04); in sti_try_rom_generic()
910 *rm++ = gsc_readl(address+rm_offset+0x08); in sti_try_rom_generic()
911 *rm++ = gsc_readl(address+rm_offset+0x0c); in sti_try_rom_generic()
914 address += le32_to_cpu(gsc_readl(address+8)); in sti_try_rom_generic()
915 pr_debug("sig %04x, PCI STI ROM at %08lx\n", sig, address); in sti_try_rom_generic()
923 address, hpa); in sti_try_rom_generic()
924 ok = sti_read_rom(0, sti, address); in sti_try_rom_generic()
929 address, hpa); in sti_try_rom_generic()
930 ok = sti_read_rom(1, sti, address); in sti_try_rom_generic()
936 if (sti_init_glob_cfg(sti, address, hpa)) in sti_try_rom_generic()
942 if (sti->pd) { in sti_try_rom_generic()
944 rom_base = pci_resource_start(sti->pd, PCI_ROM_RESOURCE); in sti_try_rom_generic()
945 pci_write_config_dword(sti->pd, PCI_ROM_ADDRESS, rom_base & ~PCI_ROM_ADDRESS_ENABLE); in sti_try_rom_generic()
953 sti_dump_globcfg(sti->glob_cfg, sti->sti_mem_request); in sti_try_rom_generic()
957 sti->sti_data->inq_outptr.dev_name); in sti_try_rom_generic()
971 pr_info(" located at [%s]\n", sti->pa_path); in sticore_check_for_default_sti()
977 * on newer systems PDC gives the address of the ROM
978 * in the additional address field addr[1] while on
979 * older Systems the PDC stores it in page0->proc_sti
984 int hpa = dev->hpa.start; in sticore_pa_init()
986 if (dev->num_addrs && dev->addr[0]) in sticore_pa_init()
987 sti = sti_try_rom_generic(dev->addr[0], hpa, NULL); in sticore_pa_init()
991 sti = sti_try_rom_generic(PAGE0->proc_sti, hpa, NULL); in sticore_pa_init()
995 print_pa_hwpath(dev, sti->pa_path); in sticore_pa_init()
996 sticore_check_for_default_sti(sti, sti->pa_path); in sticore_pa_init()
1011 dev_err(&pd->dev, "Cannot enable PCI device\n"); in sticore_pci_init()
1032 print_pci_hwpath(pd, sti->pa_path); in sticore_pci_init()
1033 sticore_check_for_default_sti(sti, sti->pa_path); in sticore_pci_init()
1038 return -ENODEV; in sticore_pci_init()
1084 * sti_init_roms() - detects all STI ROMs and stores them in sti_roms[]
1124 return sti_roms[index-1]; in sti_get_rom()
1142 "Out of 32bit-range pointers!")) in sti_call()
1143 return -1; in sti_call()
1159 /* if no built-in graphics card found, allow any fb driver as default */ in fb_is_primary_device()
1163 /* return true if it's the default built-in framebuffer driver */ in fb_is_primary_device()
1164 return (sti->info == info); in fb_is_primary_device()