[parisc-linux-cvs] cleanups and added documentation in sticon
Helge Deller
deller@gmx.de
Fri, 22 Jun 2001 19:17:26 +0200
- EXTRAVERSION -pa36
- cleanups and added documentation in sticon
Index: sticore.c
===================================================================
RCS file: /home/cvs/parisc/linux/drivers/video/sti/sticore.c,v
retrieving revision 1.15
diff -u -r1.15 sticore.c
--- sticore.c 2001/06/20 20:24:36 1.15
+++ sticore.c 2001/06/22 17:11:10
@@ -31,10 +31,9 @@
struct sti_struct *default_sti;
-static struct sti_font_flags default_font_flags = {
- wait: STI_WAIT,
- non_text: 0, /*XXX*/
-};
+static int num_sti_roms; /* # of STI ROMS found */
+static struct sti_struct *sti_roms[MAX_STI_ROMS]; /* ptr to each sti_struct
*/
+
/* The colour indices used by STI are
* 0 - Black
@@ -49,23 +48,23 @@
* So we have the same colours as VGA (basically one bit each for R, G, B),
* but have to translate them, anyway. */
-static u8 col_trans[8] = {
+static const u8 col_trans[8] = {
0, 6, 4, 5,
2, 7, 3, 1
};
#define c_fg(sti, c) col_trans[((c>> 8) & 7)]
#define c_bg(sti, c) col_trans[((c>>11) & 7)]
-#define c_index(sti, c) (c&0xff)
+#define c_index(sti, c) ((c) & 0xff)
-static struct sti_init_flags default_init_flags = {
+static const struct sti_init_flags default_init_flags = {
wait: STI_WAIT,
reset: 1,
text: 1,
nontext:1,
no_chg_bet: 1,
no_chg_bei: 1,
- init_cmap_tx: 1,
+ init_cmap_tx: 1,
};
void
@@ -90,9 +89,9 @@
sti->text_planes = outptr.text_planes;
}
-static struct sti_conf_flags default_conf_flags = {
- wait: STI_WAIT,
-};
+static const struct sti_conf_flags default_conf_flags = {
+ wait: STI_WAIT,
+ };
void
sti_inq_conf(struct sti_struct *sti)
@@ -111,6 +110,11 @@
} while (ret == 1);
}
+static const struct sti_font_flags default_font_flags = {
+ wait: STI_WAIT,
+ non_text: 0,
+};
+
void
sti_putc(struct sti_struct *sti, int c, int y, int x)
{
@@ -118,10 +122,8 @@
(u32) sti->font->raw,
c_index(sti, c), c_fg(sti, c), c_bg(sti, c),
x * sti->font_width, y * sti->font_height, NULL
- };
- struct sti_font_outptr outptr = {
- 0, NULL
};
+ struct sti_font_outptr outptr = { 0, };
s32 ret;
unsigned long flags;
@@ -133,7 +135,7 @@
} while (ret == 1);
}
-static struct sti_blkmv_flags clear_blkmv_flags = {
+static const struct sti_blkmv_flags clear_blkmv_flags = {
wait: STI_WAIT,
color: 1,
clear: 1,
@@ -150,8 +152,8 @@
width, height,
NULL
};
- struct sti_blkmv_outptr outptr = { 0, NULL };
- s32 ret = 0;
+ struct sti_blkmv_outptr outptr = { 0, };
+ s32 ret;
unsigned long flags;
do {
@@ -173,8 +175,8 @@
width * sti->font_width, height* sti->font_height,
NULL
};
- struct sti_blkmv_outptr outptr = { 0, NULL };
- s32 ret = 0;
+ struct sti_blkmv_outptr outptr = { 0, };
+ s32 ret;
unsigned long flags;
do {
@@ -185,7 +187,7 @@
} while (ret == 1);
}
-static struct sti_blkmv_flags default_blkmv_flags = {
+static const struct sti_blkmv_flags default_blkmv_flags = {
wait: STI_WAIT,
};
@@ -200,8 +202,8 @@
width * sti->font_width, height* sti->font_height,
NULL
};
- struct sti_blkmv_outptr outptr = { 0, NULL };
- s32 ret = 0;
+ struct sti_blkmv_outptr outptr = { 0, };
+ s32 ret;
unsigned long flags;
do {
@@ -239,31 +241,33 @@
-static unsigned int sti_index[MAX_STI_ROMS];
+static unsigned int __initdata sti_initial_index;
static int __init
sti_setup(char *str)
{
char *end;
- int i = 0;
-
- while (i<MAX_STI_ROMS && str && *str) {
- sti_index[i] = simple_strtoul(str, &end, 10);
- str = end;
- i++;
- }
+ if (str && *str)
+ sti_initial_index = simple_strtoul(str, &end, 10);
+
return 0;
}
+/* Assuming the machine has multiple STI consoles (=graphic cards) which
+ * all get detected by sticon, the user may define with the linux kernel
+ * parameter sti=<x> which of them will be the initial boot-console.
+ * <x> is a number between 0 and MAX_STI_ROMS, with 0 as the default
+ * STI screen.
+ */
__setup("sti=", sti_setup);
-static char *font_name[MAX_STI_ROMS] = { "VGA8x16", };
-static int font_index[MAX_STI_ROMS],
- font_height[MAX_STI_ROMS],
- font_width[MAX_STI_ROMS];
+static char __initdata *font_name[MAX_STI_ROMS] = { "VGA8x16", };
+static int __initdata font_index[MAX_STI_ROMS],
+ font_height[MAX_STI_ROMS],
+ font_width[MAX_STI_ROMS];
static int __init sti_font_setup(char *str)
{
@@ -295,6 +299,24 @@
return 0;
}
+/* The optional linux kernel parameter "sti_font" defines which font
+ * should be used by the sticon driver to draw characters to the screen.
+ * Possible values are:
+ * - sti_font=<fb_fontname>:
+ * <fb_fontname> is the name of one of the linux-kernel built-in
+ * framebuffer font names (e.g. VGA8x16, SUN22x18).
+ * This is only available if the fonts have been statically compiled
+ * in with e.g. the CONFIG_FONT_8x16 or CONFIG_FONT_SUN12x22 options.
+ * - sti_font=<number>
+ * most STI ROMs have built-in HP specific fonts, which can be selected
+ * by giving the desired number to the sticon driver.
+ * NOTE: This number is machine and STI ROM dependend.
+ * - sti_font=<height>x<width> (e.g. sti_font=16x8)
+ * <height> and <width> gives hints to the height and width of the
+ * font which the user wants. The sticon driver will try to use
+ * a font with this height and width, but if no suitable font is
+ * found, sticon will use the default 8x8 font.
+ */
__setup("sti_font=", sti_font_setup);
@@ -349,13 +371,14 @@
struct sti_glob_cfg_ext *glob_cfg_ext;
void *save_addr;
void *sti_mem_addr;
+ const int save_addr_size = 1024; /* XXX */
if (!sti->sti_mem_request)
sti->sti_mem_request = 256; /* STI default */
glob_cfg = kmalloc(sizeof(*sti->glob_cfg), GFP_KERNEL);
glob_cfg_ext = kmalloc(sizeof(*glob_cfg_ext), GFP_KERNEL);
- save_addr = kmalloc(1024 /*XXX*/, GFP_KERNEL);
+ save_addr = kmalloc(save_addr_size, GFP_KERNEL);
sti_mem_addr = kmalloc(sti->sti_mem_request, GFP_KERNEL);
if (!(glob_cfg && glob_cfg_ext && save_addr && sti_mem_addr))
@@ -363,7 +386,7 @@
memset(glob_cfg, 0, sizeof(*glob_cfg));
memset(glob_cfg_ext, 0, sizeof(*glob_cfg_ext));
- memset(save_addr, 0, 1024);
+ memset(save_addr, 0, save_addr_size);
memset(sti_mem_addr, 0, sti->sti_mem_request);
glob_cfg->ext_ptr = STI_PTR(glob_cfg_ext);
@@ -397,10 +420,8 @@
if (!fbfont_name || !strlen(fbfont_name))
return NULL;
fbfont = fbcon_find_font(fbfont_name);
- /*
if (!fbfont)
- fbfont = fbcon_get_default_font(1280,1024); // XXX
- */
+ fbfont = fbcon_get_default_font(1024,768);
if (!fbfont)
return NULL;
@@ -450,15 +471,17 @@
{
struct sti_cooked_font *font;
int i;
+ int index = num_sti_roms;
/* check for framebuffer-font first */
- if ((font = sti_select_fbfont(rom, font_name[0/*XXX*/])))
+ if ((font = sti_select_fbfont(rom, font_name[index])))
return font;
- if (font_width[0] && font_height[0])
- font_index[0] = search_font_fnc(rom, font_height[0], font_width[0]);
+ if (font_width[index] && font_height[index])
+ font_index[index] = search_font_fnc(rom,
+ font_height[index], font_width[index]);
- for (font = rom->font_start, i = font_index[0];
+ for (font = rom->font_start, i = font_index[index];
font && (i > 0);
font = font->next_font, i--);
@@ -469,9 +492,6 @@
}
-static int num_sti_roms;
-static struct sti_struct *sti_rom[MAX_STI_ROMS];
-
void __init
sti_dump_rom(struct sti_rom *rom)
{
@@ -558,7 +578,7 @@
struct sti_rom * __init
sti_get_bmode_rom (unsigned long address)
{
- struct sti_rom *raw = NULL;
+ struct sti_rom *raw;
unsigned long size;
struct sti_rom_font *raw_font, *font_start;
@@ -594,7 +614,7 @@
struct sti_rom * __init
sti_get_wmode_rom (unsigned long address)
{
- struct sti_rom *raw = NULL;
+ struct sti_rom *raw;
unsigned long size;
/* read the ROM size directly from the struct in ROM */
@@ -603,6 +623,7 @@
raw = kmalloc(size, GFP_KERNEL);
if(raw)
sti_rom_copy(address, size, raw);
+
return raw;
}
@@ -732,7 +753,7 @@
printk(KERN_INFO "STI device: %s\n", sti->outptr.dev_name );
- sti_rom[num_sti_roms] = sti;
+ sti_roms[num_sti_roms] = sti;
num_sti_roms++;
return sti;
@@ -763,7 +784,7 @@
if (!rom)
rom = flash_sti_rom;
if (!rom)
- rom = hpa; /* XXX */
+ rom = hpa;
if (rom) {
DPRINTK((KERN_DEBUG "Trying STI ROM at %08lx, hpa at %08lx\n",
rom, hpa));
@@ -805,10 +826,10 @@
search_sti(flash_rom, (unsigned long) 0xfffffffffa000000);
/* check boot-value from "sti=<index>" */
- if (sti_index[0] >= num_sti_roms)
- sti_index[0] = 0;
+ if (sti_initial_index >= num_sti_roms)
+ sti_initial_index = 0;
- default_sti = sti_rom[sti_index[0]];
+ default_sti = sti_roms[sti_initial_index];
out:
/* return default STI if available */