X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fvideo%2Fconsole%2Fnewport_con.c;h=762c7a593141f76f26f3d5721fc793439540c0df;hb=987b0145d94eecf292d8b301228356f44611ab7c;hp=69916019cbaf4db80c80056a8f1752e296d8b137;hpb=daddc0d38b3571bed170afa273a49a0eba090c1e;p=linux-2.6.git diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index 69916019c..762c7a593 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -31,7 +32,7 @@ #include -extern struct font_desc font_vga_8x16; +extern unsigned long sgi_gfxaddr; #define FONT_DATA ((unsigned char *)font_vga_8x16.data) @@ -43,7 +44,7 @@ extern struct font_desc font_vga_8x16; static unsigned char *font_data[MAX_NR_CONSOLES]; -extern struct newport_regs *npregs; +static struct newport_regs *npregs; static int logo_active; static int topscan; @@ -51,6 +52,8 @@ static int xcurs_correction = 29; static int newport_xsize; static int newport_ysize; +static int newport_set_def_font(int unit, struct console_font *op); + #define BMASK(c) (c << 24) #define RENDER(regs, cp) do { \ @@ -70,7 +73,7 @@ static int newport_ysize; static inline void newport_render_background(int xstart, int ystart, int xend, int yend, int ci) { - newport_wait(); + newport_wait(npregs); npregs->set.wrmask = 0xffffffff; npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK | NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX @@ -87,7 +90,7 @@ static inline void newport_init_cmap(void) unsigned short i; for (i = 0; i < 16; i++) { - newport_bfwait(); + newport_bfwait(npregs); newport_cmap_setaddr(npregs, color_table[i]); newport_cmap_setrgb(npregs, default_red[i], @@ -95,11 +98,33 @@ static inline void newport_init_cmap(void) } } +static void newport_show_logo(void) +{ #ifdef CONFIG_LOGO_SGI_CLUT224 -static void newport_show_logo(void); -#else -#define newport_show_logo() do { } while (0) -#endif + const struct linux_logo *logo = fb_find_logo(8); + const unsigned char *clut = logo->clut; + const unsigned char *data = logo->data; + unsigned long i; + + for (i = 0; i < logo->clutsize; i++) { + newport_bfwait(npregs); + newport_cmap_setaddr(npregs, i + 0x20); + newport_cmap_setrgb(npregs, clut[0], clut[1], clut[2]); + clut += 3; + } + + newport_wait(npregs); + npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK | + NPORT_DMODE0_CHOST); + + npregs->set.xystarti = ((newport_xsize - logo->width) << 16) | (0); + npregs->set.xyendi = ((newport_xsize - 1) << 16); + newport_wait(npregs); + + for (i = 0; i < logo->width*logo->height; i++) + npregs->go.hostrw0 = *data++ << 24; +#endif /* CONFIG_LOGO_SGI_CLUT224 */ +} static inline void newport_clear_screen(int xstart, int ystart, int xend, int yend, int ci) @@ -107,7 +132,7 @@ static inline void newport_clear_screen(int xstart, int ystart, int xend, if (logo_active) return; - newport_wait(); + newport_wait(npregs); npregs->set.wrmask = 0xffffffff; npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK | NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX @@ -129,7 +154,7 @@ void newport_reset(void) unsigned short treg; int i; - newport_wait(); + newport_wait(npregs); treg = newport_vc2_get(npregs, VC2_IREG_CONTROL); newport_vc2_set(npregs, VC2_IREG_CONTROL, (treg | VC2_CTRL_EVIDEO)); @@ -139,7 +164,7 @@ void newport_reset(void) npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM | NPORT_DMODE_W2 | VC2_PROTOCOL); for (i = 0; i < 128; i++) { - newport_bfwait(); + newport_bfwait(npregs); if (i == 92 || i == 94) npregs->set.dcbdata0.byshort.s1 = 0xff00; else @@ -179,7 +204,7 @@ void newport_get_screensize(void) npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM | NPORT_DMODE_W2 | VC2_PROTOCOL); for (i = 0; i < 128; i++) { - newport_bfwait(); + newport_bfwait(npregs); linetable[i] = npregs->set.dcbdata0.byshort.s1; } @@ -190,12 +215,12 @@ void newport_get_screensize(void) npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM | NPORT_DMODE_W2 | VC2_PROTOCOL); do { - newport_bfwait(); + newport_bfwait(npregs); treg = npregs->set.dcbdata0.byshort.s1; if ((treg & 1) == 0) cols += (treg >> 7) & 0xfe; if ((treg & 0x80) == 0) { - newport_bfwait(); + newport_bfwait(npregs); treg = npregs->set.dcbdata0.byshort.s1; } } while ((treg & 0x8000) == 0); @@ -258,27 +283,23 @@ static void newport_get_revisions(void) xcurs_correction = 21; } -#ifdef MODULE +/* Can't be __init, take_over_console may call it later */ static const char *newport_startup(void) -#else -static const char *__init newport_startup(void) -#endif { int i; - struct newport_regs *p; - - npregs = (struct newport_regs *) (KSEG1 + 0x1f0f0000); - - p = npregs; - p->cset.config = NPORT_CFG_GD0; - if (newport_wait()) { + if (!sgi_gfxaddr) return NULL; - } + npregs = (struct newport_regs *) /* ioremap cannot fail */ + ioremap(sgi_gfxaddr, sizeof(struct newport_regs)); + npregs->cset.config = NPORT_CFG_GD0; - p->set.xstarti = TESTVAL; - if (p->set._xstart.word != XSTI_TO_FXSTART(TESTVAL)) - return NULL; + if (newport_wait(npregs)) + goto out_unmap; + + npregs->set.xstarti = TESTVAL; + if (npregs->set._xstart.word != XSTI_TO_FXSTART(TESTVAL)) + goto out_unmap; for (i = 0; i < MAX_NR_CONSOLES; i++) font_data[i] = FONT_DATA; @@ -287,9 +308,11 @@ static const char *__init newport_startup(void) newport_get_revisions(); newport_get_screensize(); - /* gfx_init (display_desc); */ - return "SGI Newport"; + +out_unmap: + iounmap((void *)npregs); + return NULL; } static void newport_init(struct vc_data *vc, int init) @@ -299,6 +322,15 @@ static void newport_init(struct vc_data *vc, int init) vc->vc_can_do_color = 1; } +static void newport_deinit(struct vc_data *c) +{ + int i; + + /* free memory used by user font */ + for (i = 0; i < MAX_NR_CONSOLES; i++) + newport_set_def_font(i, NULL); +} + static void newport_clear(struct vc_data *vc, int sy, int sx, int height, int width) { @@ -334,7 +366,7 @@ static void newport_putc(struct vc_data *vc, int charattr, int ypos, (charattr & 0xf0) >> 4); /* Set the color and drawing mode. */ - newport_wait(); + newport_wait(npregs); npregs->set.colori = charattr & 0xf; npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK | NPORT_DMODE0_STOPX | NPORT_DMODE0_ZPENAB | @@ -343,7 +375,7 @@ static void newport_putc(struct vc_data *vc, int charattr, int ypos, /* Set coordinates for bitmap operation. */ npregs->set.xystarti = (xpos << 16) | ((ypos + topscan) & 0x3ff); npregs->set.xyendi = ((xpos + 7) << 16); - newport_wait(); + newport_wait(npregs); /* Go, baby, go... */ RENDER(npregs, p); @@ -367,7 +399,7 @@ static void newport_putcs(struct vc_data *vc, const unsigned short *s, xpos + ((count - 1) << 3), ypos, (charattr & 0xf0) >> 4); - newport_wait(); + newport_wait(npregs); /* Set the color and drawing mode. */ npregs->set.colori = charattr & 0xf; @@ -378,7 +410,7 @@ static void newport_putcs(struct vc_data *vc, const unsigned short *s, for (i = 0; i < count; i++, xpos += 8) { p = &font_data[vc->vc_num][(scr_readw(s++) & 0xff) << 4]; - newport_wait(); + newport_wait(npregs); /* Set coordinates for bitmap operation. */ npregs->set.xystarti = @@ -431,7 +463,7 @@ static int newport_switch(struct vc_data *vc) return 1; } -static int newport_blank(struct vc_data *c, int blank) +static int newport_blank(struct vc_data *c, int blank, int mode_switch) { unsigned short treg; @@ -449,7 +481,7 @@ static int newport_blank(struct vc_data *c, int blank) return 1; } -static int newport_set_font(int unit, struct console_font_op *op) +static int newport_set_font(int unit, struct console_font *op) { int w = op->width; int h = op->height; @@ -503,7 +535,7 @@ static int newport_set_font(int unit, struct console_font_op *op) return 0; } -static int newport_set_def_font(int unit, struct console_font_op *op) +static int newport_set_def_font(int unit, struct console_font *op) { if (font_data[unit] != FONT_DATA) { if (--REFCOUNT(font_data[unit]) == 0) @@ -515,18 +547,14 @@ static int newport_set_def_font(int unit, struct console_font_op *op) return 0; } -static int newport_font_op(struct vc_data *vc, struct console_font_op *op) +static int newport_font_default(struct vc_data *vc, struct console_font *op, char *name) { - int unit = vc->vc_num; - - switch (op->op) { - case KD_FONT_OP_SET: - return newport_set_font(unit, op); - case KD_FONT_OP_SET_DEFAULT: - return newport_set_def_font(unit, op); - default: - return -ENOSYS; - } + return newport_set_def_font(vc->vc_num, op); +} + +static int newport_font_set(struct vc_data *vc, struct console_font *font, unsigned flags) +{ + return newport_set_font(vc->vc_num, font); } static int newport_set_palette(struct vc_data *vc, unsigned char *table) @@ -660,7 +688,7 @@ static void newport_bmove(struct vc_data *vc, int sy, int sx, int dy, xe = xs; xs = tmp; } - newport_wait(); + newport_wait(npregs); npregs->set.drawmode0 = (NPORT_DMODE0_S2S | NPORT_DMODE0_BLOCK | NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX | NPORT_DMODE0_STOPY); @@ -677,82 +705,40 @@ static int newport_dummy(struct vc_data *c) #define DUMMY (void *) newport_dummy const struct consw newport_con = { - .con_startup = newport_startup, - .con_init = newport_init, - .con_deinit = DUMMY, - .con_clear = newport_clear, - .con_putc = newport_putc, - .con_putcs = newport_putcs, - .con_cursor = newport_cursor, - .con_scroll = newport_scroll, - .con_bmove = newport_bmove, - .con_switch = newport_switch, - .con_blank = newport_blank, - .con_font_op = newport_font_op, - .con_set_palette = newport_set_palette, - .con_scrolldelta = newport_scrolldelta, - .con_set_origin = DUMMY, - .con_save_screen = DUMMY + .owner = THIS_MODULE, + .con_startup = newport_startup, + .con_init = newport_init, + .con_deinit = newport_deinit, + .con_clear = newport_clear, + .con_putc = newport_putc, + .con_putcs = newport_putcs, + .con_cursor = newport_cursor, + .con_scroll = newport_scroll, + .con_bmove = newport_bmove, + .con_switch = newport_switch, + .con_blank = newport_blank, + .con_font_set = newport_font_set, + .con_font_default = newport_font_default, + .con_set_palette = newport_set_palette, + .con_scrolldelta = newport_scrolldelta, + .con_set_origin = DUMMY, + .con_save_screen = DUMMY }; #ifdef MODULE -MODULE_LICENSE("GPL"); - -int init_module(void) +static int __init newport_console_init(void) { - if (!newport_startup()) - printk("Error loading SGI Newport Console driver\n"); - else - printk("Loading SGI Newport Console Driver\n"); - take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1); - - return 0; + return take_over_console(&newport_con, 0, MAX_NR_CONSOLES - 1, 1); } -int cleanup_module(void) +static void __exit newport_console_exit(void) { - int i; - - printk("Unloading SGI Newport Console Driver\n"); - /* free memory used by user font */ - for (i = 0; i < MAX_NR_CONSOLES; i++) - newport_set_def_font(i, NULL); - - return 0; + give_up_console(&newport_con); + iounmap((void *)npregs); } -#endif - - -#ifdef CONFIG_LOGO_SGI_CLUT224 - -#undef __initdata -#define __initdata -#include "../logo/logo_sgi_clut224.c" - -static void newport_show_logo(void) -{ - const struct linux_logo *logo = &logo_sgi_clut224; - const unsigned char *clut = logo->clut; - const unsigned char *data = logo->data; - unsigned long i; - for (i = 0; i < logo->clutsize; i++) { - newport_bfwait(); - newport_cmap_setaddr(npregs, i + 0x20); - newport_cmap_setrgb(npregs, clut[0], clut[1], clut[2]); - clut += 3; - } - - newport_wait(); - npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK | - NPORT_DMODE0_CHOST); - - npregs->set.xystarti = ((newport_xsize - logo->width) << 16) | (0); - npregs->set.xyendi = ((newport_xsize - 1) << 16); - newport_wait(); - - for (i = 0; i < logo->width*logo->height; i++) - npregs->go.hostrw0 = *data++ << 24; -} -#endif /* CONFIG_LOGO_SGI_CLUT224 */ +module_init(newport_console_init); +module_exit(newport_console_exit); +#endif +MODULE_LICENSE("GPL");