byte-mode STI sync-up with word-mode STI
Hi,
I've just checked in a large patch (see attachment), which mostly syncs byte-mode STI up with word-mode STI.
You should note, that I can't currently test any of theese changes, since I don't have such a machine. If your machine has byte-mode STI ROM and you test this code, please send me some feedback.
The other parts of this patch just remove an unused parameter from sti_rom_copy() and fixes a compiler-warning in stifb.c.
btw, stifb will still not work :-(
Greetings,
Helge
? xxx
Index: sticon-bmode.c
===================================================================
RCS file: /home/cvs/parisc/linux/drivers/video/sti/sticon-bmode.c,v retrieving revision 1.3
sticon-bmode.c +51 -89
@@ -106,62 +106,67 @@return virt_to_phys (ret); } + +static int __init +bmode_sti_search_font (struct sti_cooked_rom *rom,int height,int width) +{ +struct sti_cooked_font *font; +int i =0 ; -/* address is a pointer to a byte mode or pci rom */ -struct sti_struct *__init -bmode_sti_read_rom (unsigned long address) +for (font = rom->font_start; font; font = font->next_font, i++) { +if ((STI_U8 (font->raw->width) == width) && (STI_U8 (font->raw->height) == height)) +return i; + } +return 0 ; +} + + +struct sti_struct *__init +bmode_sti_read_rom (struct sti_struct *sti,unsigned long address,unsigned long hpa) { -struct sti_struct *ret =NULL ; -struct sti_cooked_rom *cooked =NULL ; +struct sti_cooked_rom *cooked;struct sti_rom *raw =NULL ;unsigned long size; - - ret = &default_sti; - -if (!ret) - goto out_err; - +sti_u32 sizetmp; + cooked =kmalloc (sizeof *cooked,GFP_KERNEL ); - raw =kmalloc (sizeof *raw,GFP_KERNEL ); - -if (!(raw && cooked)) +if (!cooked) goto out_err; - -/* reallocate raw */ -sti_rom_copy (address,0 ,sizeof *raw, raw); + +sti_rom_copy (address + offsetof(struct sti_rom ,last_addr), +sizeof (sizetmp), &sizetmp); + size =STI_U32 (sizetmp); -bmode_sti_dump_rom (raw); +// bmode_sti_dump_rom(raw); // NO DATA.... - size =STI_U32 (raw->last_addr) +1 ; - size =128 *1024 ; -// DPRINTK(("size %08lx\n", size)); // DPRINTK(("font_start %08x\n", STI_U32(raw->font_start))); -// kfree(raw); raw =kmalloc (size,GFP_KERNEL );if (!raw) goto out_err; -sti_rom_copy (address,0 , size-1 , raw); +sti_rom_copy (address, size, raw);bmode_sti_cook_fonts (cooked, raw); + sti->regions[0 ] = hpa;/* ?? */ +if (STI_U32 (raw->region_list)) {struct sti_rom_region *region = ((void *)raw) +STI_U32 (raw->region_list) -3 ;// DPRINTK(("region_list %08x\n", STI_U32(raw->region_list))); - ret->regions[1 ] =STI_U32 (region[1 ].region); - ret->regions[2 ] =STI_U32 (region[2 ].region); - ret->regions[3 ] =STI_U32 (region[3 ].region); - ret->regions[4 ] =STI_U32 (region[4 ].region); - ret->regions[5 ] =STI_U32 (region[5 ].region); - ret->regions[6 ] =STI_U32 (region[6 ].region); - ret->regions[7 ] =STI_U32 (region[7 ].region); + sti->regions[1 ] =STI_U32 (region[1 ].region); + sti->regions[2 ] =STI_U32 (region[2 ].region); + sti->regions[3 ] =STI_U32 (region[3 ].region); + sti->regions[4 ] =STI_U32 (region[4 ].region); + sti->regions[5 ] =STI_U32 (region[5 ].region); + sti->regions[6 ] =STI_U32 (region[6 ].region); + sti->regions[7 ] =STI_U32 (region[7 ].region); } address =virt_to_phys (raw); -#if 0 +#if 1 DPRINTK(("init_graph %08x %08x\n" "state_mgmt %08x %08x\n" "font_unpmv %08x %08x\n"
@@ -192,31 +197,36 @@ STI_U32(raw->end_addr), STI_U32(raw->end_addr_m68k) ) );#endif - ret->init_graph =bmode_sti_cook_function (((void *)raw)+STI_U32 (raw->init_graph)-3 , + sti->init_graph =bmode_sti_cook_function (((void *)raw)+STI_U32 (raw->init_graph)-3 , (STI_U32 (raw->state_mgmt) -STI_U32 (raw->init_graph))/4 ); - ret->font_unpmv =bmode_sti_cook_function (((void *)raw)+STI_U32 (raw->font_unpmv)-3 , + sti->font_unpmv =bmode_sti_cook_function (((void *)raw)+STI_U32 (raw->font_unpmv)-3 , (STI_U32 (raw->block_move) -STI_U32 (raw->font_unpmv))/4 ); - ret->block_move =bmode_sti_cook_function (((void *)raw)+STI_U32 (raw->block_move)-3 , + sti->block_move =bmode_sti_cook_function (((void *)raw)+STI_U32 (raw->block_move)-3 , (STI_U32 (raw->self_test) -STI_U32 (raw->block_move))/4 ); - ret->inq_conf =bmode_sti_cook_function (((void *)raw)+STI_U32 (raw->inq_conf), + sti->inq_conf =bmode_sti_cook_function (((void *)raw)+STI_U32 (raw->inq_conf),STI_U32 (raw->set_cm_entry) -STI_U32 (raw->inq_conf)); - ret->rom = cooked; - ret->rom->raw = raw; + sti->rom = cooked; + sti->rom->raw = raw; -/* XXXXX -ret->font = (struct sti_rom_font *) virt_to_phys(sti_select_font(ret->rom)->raw); -*/ -return ret; + sti->font =sti_select_font (sti->rom, bmode_sti_search_font)->raw; + sti->font_width =STI_U8 (sti->font->width); + sti->font_height =STI_U8 (sti->font->height); + sti->font = (struct sti_rom_font *)virt_to_phys (sti->font); + +printk ("Using font at %08lx, w=%d, h=%d\n" , + (unsigned long )sti->font, sti->font_width, sti->font_height); +return sti; + out_err:if (raw)kfree (raw);
@@ -224,52 +234,4 @@kfree (cooked);return NULL ; -} - - -struct sti_struct *__init -bmode_sti_try_rom (unsigned long address,unsigned long hpa) -{ -struct sti_struct *sti =NULL ; -u16 sig; - -/* if we can't read the ROM, bail out early. Not being able -* to read the hpa is okay, for romless sti */ -if (pdc_add_valid ((void *)address)) -return NULL ; - -printk ("found potential STI ROM at %08lx\n" , address); - - sig =le16_to_cpu (gsc_readw (address)); - -if ((sig&0xff ) ==0x01 ) { - sti =bmode_sti_read_rom (address); - } - -if (sig ==0x0303 ) { -printk ("STI word mode ROM at %08lx, ignored\n" , - address); - - sti =NULL ; - } - -if (!sti) -return NULL ; - -sti_init_glob_cfg (sti, hpa, address); - -sti_init_graph (sti); - -//sti_inq_conf(sti); -#if !defined(SERIAL_CONSOLE ) - { -extern void pdc_console_die (void ); -pdc_console_die (); - } -#endif - -/* XXXXXX -take_over_console(&sti_con, 0, MAX_NR_CONSOLES-1, 1); -*/ -return sti; }
Index: sticon-wmode.c
===================================================================
RCS file: /home/cvs/parisc/linux/drivers/video/sti/sticon-wmode.c,v retrieving revision 1.5
sticon-wmode.c +3 -26
@@ -71,41 +71,18 @@static int __init -sti_search_font (struct sti_cooked_rom *rom, -int height,int width) +wmode_sti_search_font (struct sti_cooked_rom *rom,int height,int width) {struct sti_cooked_font *font;int i =0 ;for (font = rom->font_start; font; font = font->next_font, i++) { -#warning use STI_U8() with byte-mode ROMs !!if ((font->raw->width == width) && (font->raw->height == height))return i; }return 0 ; } - -struct sti_cooked_font *__init -sti_select_font (struct sti_cooked_rom *rom) -{ -struct sti_cooked_font *font; -int i; - -if (font_width && font_height) - font_index =sti_search_font (rom, font_height, font_width); - -for (font = rom->font_start, i = font_index; - font && (i >0 ); - font = font->next_font, i--); - -if (font) -return font; -else -return rom->font_start; -} - -struct sti_struct *__init wmode_sti_read_rom (struct sti_struct *sti,unsigned long address,unsigned long hpa) {
@@ -124,7 +101,7 @@if (!raw) goto out_err; -sti_rom_copy (address,0 , size, raw); +sti_rom_copy (address, size, raw);if (!wmode_sti_cook_fonts (cooked, raw)) {printk ("No font found for STI at %08lx\n" , address);
@@ -144,7 +121,7 @@ sti->rom = cooked; sti->rom->raw = raw; - sti->font =sti_select_font (sti->rom)->raw; + sti->font =sti_select_font (sti->rom, wmode_sti_search_font)->raw; sti->font_width = sti->font->width; sti->font_height = sti->font->height; sti->font = (struct sti_rom_font *)virt_to_phys (sti->font);
Index: sticore.c
===================================================================
RCS file: /home/cvs/parisc/linux/drivers/video/sti/sticore.c,v retrieving revision 1.4
sticore.c +27 -10
@@ -216,15 +216,11 @@void __init -sti_rom_copy (unsigned long base,unsigned long offset, -unsigned long count,void *dest) +sti_rom_copy (unsigned long base,unsigned long count,void *dest) { -unsigned long orgcount; - orgcount = count; +unsigned long orgcount = count;/* this still needs to be revisited (see arch/parisc/mm/init.c:246 ! */ - base += offset; -while (count >=4 ) { count -=4 ; *(u32 *)dest =gsc_readl (base);
@@ -349,6 +345,27 @@ } +struct sti_cooked_font *__init +sti_select_font (struct sti_cooked_rom *rom, +int (*search_font_fnc) (struct sti_cooked_rom *,int ,int ) ) +{ +struct sti_cooked_font *font; +int i; + +if (font_width && font_height) + font_index =search_font_fnc (rom, font_height, font_width); + +for (font = rom->font_start, i = font_index; + font && (i >0 ); + font = font->next_font, i--); + +if (font) +return font; +else +return rom->font_start; +} + +/* static unsigned long sti_address; static unsigned long sti_hpa;
@@ -415,10 +432,10 @@ sti = &sti_rom[num_sti_roms]; sti->lock =SPIN_LOCK_UNLOCKED ; -if ((sig&0xff ) ==0x01 ) { -printk ("STI byte mode ROM at %08lx ignored\n" , - address); -return NULL ;/* XXX STILL TODO XXX */ +if ((sig &0xff ) ==0x01 ) { +printk ("STI byte mode ROM at %08lx, hpa=%08lx\n" , + address, hpa); + sti =bmode_sti_read_rom (sti, address, hpa); }if (sig ==0x0303 ) {
Index: sticore.h
===================================================================
RCS file: /home/cvs/parisc/linux/drivers/video/sti/sticore.h,v retrieving revision 1.4
sticore.h +7 -4
@@ -279,16 +279,19 @@/* helper functions */ struct sti_struct *sti_init_roms (void ); -void sti_rom_copy (unsigned long base,unsigned long offset, -unsigned long count,void *dest); +void sti_rom_copy (unsigned long base,unsigned long count,void *dest);int sti_init_glob_cfg (struct sti_struct *sti,unsigned long rom_address,unsigned long hpa);void sti_dump_globcfg (struct sti_glob_cfg *glob_cfg); +struct sti_cooked_font *sti_select_font (struct sti_cooked_rom *rom, +int (*search_font_fnc) (struct sti_cooked_rom *,int ,int ) ); -/* sti-wmode.c: */ -struct sti_struct *wmode_sti_read_rom (struct sti_struct *sti, +struct sti_struct *wmode_sti_read_rom (struct sti_struct *sti,unsigned long address,unsigned long hpa); +/* sti-bmode.c: */ +struct sti_struct *bmode_sti_read_rom (struct sti_struct *sti, +unsigned long address,unsigned long hpa);#endif /* STICORE_H */
Index: stifb.c
===================================================================
RCS file: /home/cvs/parisc/linux/drivers/video/sti/stifb.c,v retrieving revision 1.4
stifb.c +2 -2
@@ -131,7 +131,7 @@ }static int -sti_blank (int blank_mode,const struct fb_info *info) +sti_blank (int blank_mode,struct fb_info_gen *info) {return 0 ; }
@@ -147,7 +147,6 @@ set_par: sti_set_par, getcolreg: sti_getcolreg, setcolreg: sti_setcolreg, - pan_display: NULL, blank: sti_blank, set_disp: sti_set_disp };
@@ -191,6 +190,7 @@printk (KERN_INFO "fb%d: %s frame buffer device\n" ,GET_FB_IDX (fb_info.gen.info.node), fb_info.gen.info.modename); +printk ("%s: FINISHED\n" , __FUNCTION__);return 0 ; }