patch-2.3.9 linux/drivers/video/newport_con.c
Next file: linux/drivers/video/sbusfb.c
Previous file: linux/drivers/video/g364fb.c
Back to the patch index
Back to the overall index
- Lines: 421
- Date:
Fri Jun 25 17:37:52 1999
- Orig file:
v2.3.8/linux/drivers/video/newport_con.c
- Orig date:
Thu Feb 25 10:02:12 1999
diff -u --recursive --new-file v2.3.8/linux/drivers/video/newport_con.c linux/drivers/video/newport_con.c
@@ -1,8 +1,9 @@
-/* $Id: newport_con.c,v 1.3 1998/09/01 21:43:18 tsbogend Exp $
+/* $Id: newport_con.c,v 1.13 1999/04/11 10:37:08 ulfc Exp $
*
* newport_con.c: Abscon for newport hardware
*
* (C) 1998 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
+ * (C) 1999 Ulf Carlsson (ulfc@bun.falkenberg.se)
*
* This driver is based on sgicons.c and cons_newport.
*
@@ -19,19 +20,27 @@
#include <linux/console_struct.h>
#include <linux/vt_kern.h>
#include <linux/mm.h>
+#include <linux/module.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/page.h>
#include <asm/pgtable.h>
#include <asm/newport.h>
+#define INCLUDE_LINUX_LOGO_DATA
+#include <asm/linux_logo.h>
-struct newport_regs *npregs;
-int newport_num_lines;
-int newport_num_columns;
-int topscan;
+#define LOGO_W 80
+#define LOGO_H 80
extern unsigned char vga_font[];
+extern struct newport_regs *npregs;
+
+static int logo_active;
+static int topscan;
+static int xcurs_correction = 29;
+static int newport_xsize;
+static int newport_ysize;
#define BMASK(c) (c << 24)
@@ -49,7 +58,8 @@
#define TESTVAL 0xdeadbeef
#define XSTI_TO_FXSTART(val) (((val) & 0xffff) << 11)
-static inline void newport_render_background(int xpos, int ypos, int ci)
+static inline void newport_render_background(int xstart, int ystart,
+ int xend, int yend, int ci)
{
newport_wait();
npregs->set.wrmask = 0xffffffff;
@@ -57,8 +67,8 @@
NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX |
NPORT_DMODE0_STOPY);
npregs->set.colori = ci;
- npregs->set.xystarti = (xpos << 16) | ((ypos + topscan) & 0x3ff);
- npregs->go.xyendi = ((xpos + 7) << 16) | ((ypos + topscan + 15) & 0x3ff);
+ npregs->set.xystarti = (xstart << 16) | ((ystart + topscan) & 0x3ff);
+ npregs->go.xyendi = ((xend + 7) << 16) | ((yend + topscan + 15) & 0x3ff);
}
static inline void newport_init_cmap(void)
@@ -75,23 +85,51 @@
}
}
-static inline void newport_clear_screen(int xstart, int ystart, int xend, int yend)
+static inline void newport_show_logo(void)
{
+ unsigned long i;
+
+ for(i = 0; i < LINUX_LOGO_COLORS; i++) {
+ newport_bfwait();
+ newport_cmap_setaddr(npregs, i + 0x20);
+ newport_cmap_setrgb(npregs,
+ linux_logo_red[i],
+ linux_logo_green[i],
+ linux_logo_blue[i]);
+ }
+
+ newport_wait();
+ npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
+ NPORT_DMODE0_CHOST);
+
+ npregs->set.xystarti = ((newport_xsize - LOGO_W) << 16) | (0);
+ npregs->set.xyendi = ((newport_xsize - 1) << 16);
+ newport_wait();
+
+ for (i = 0; i < LOGO_W * LOGO_H; i++)
+ npregs->go.hostrw0 = linux_logo[i] << 24;
+}
+
+static inline void newport_clear_screen(int xstart, int ystart, int xend,
+ int yend, int ci) {
+ if (logo_active)
+ return;
+
newport_wait();
npregs->set.wrmask = 0xffffffff;
npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
NPORT_DMODE0_DOSETUP | NPORT_DMODE0_STOPX |
NPORT_DMODE0_STOPY);
- npregs->set.colori = 0;
+ npregs->set.colori = ci;
npregs->set.xystarti = (xstart << 16) | ystart;
npregs->go.xyendi = (xend << 16) | yend;
}
-static inline void newport_clear_lines(int ystart, int yend)
+static inline void newport_clear_lines(int ystart, int yend, int ci)
{
ystart = ((ystart << 4) + topscan) & 0x3ff;
yend = ((yend << 4) + topscan + 15) & 0x3ff;
- newport_clear_screen (0, ystart, 1279, yend);
+ newport_clear_screen (0, ystart, 1280+63, yend, ci);
}
void newport_reset (void)
@@ -116,13 +154,121 @@
}
newport_init_cmap();
- npregs->cset.topscan = topscan = 0;
+
+ /* turn off popup plane */
+ npregs->set.dcbmode = (DCB_XMAP0 | R_DCB_XMAP9_PROTOCOL |
+ XM9_CRS_CONFIG | NPORT_DMODE_W1);
+ npregs->set.dcbdata0.bytes.b3 &= ~XM9_PUPMODE;
+ npregs->set.dcbmode = (DCB_XMAP1 | R_DCB_XMAP9_PROTOCOL |
+ XM9_CRS_CONFIG | NPORT_DMODE_W1);
+ npregs->set.dcbdata0.bytes.b3 &= ~XM9_PUPMODE;
+
+ topscan = 0;
+ npregs->cset.topscan = 0x3ff;
npregs->cset.xywin = (4096 << 16) | 4096;
+
/* Clear the screen. */
- newport_clear_screen(0,0,1280+63,1024);
+ newport_clear_screen(0,0,1280+63,1024,0);
}
+/*
+ * calculate the actual screen size by reading
+ * the video timing out of the VC2
+ */
+void newport_get_screensize(void)
+{
+ int i,cols;
+ unsigned short ventry,treg;
+ unsigned short linetable[128]; /* should be enough */
+
+ ventry = newport_vc2_get (npregs, VC2_IREG_VENTRY);
+ newport_vc2_set(npregs, VC2_IREG_RADDR, ventry);
+ npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM |
+ NPORT_DMODE_W2 | VC2_PROTOCOL);
+ for(i = 0; i < 128; i++) {
+ newport_bfwait();
+ linetable[i] = npregs->set.dcbdata0.hwords.s1;
+ }
+
+ newport_xsize = newport_ysize = 0;
+ for (i = 0; linetable[i+1] && (i < sizeof(linetable)); i+=2) {
+ cols = 0;
+ newport_vc2_set(npregs, VC2_IREG_RADDR, linetable[i]);
+ npregs->set.dcbmode = (NPORT_DMODE_AVC2 | VC2_REGADDR_RAM |
+ NPORT_DMODE_W2 | VC2_PROTOCOL);
+ do {
+ newport_bfwait();
+ treg = npregs->set.dcbdata0.hwords.s1;
+ if ((treg & 1) == 0)
+ cols += (treg >> 7) & 0xfe;
+ if ((treg & 0x80) == 0) {
+ newport_bfwait();
+ treg = npregs->set.dcbdata0.hwords.s1;
+ }
+ } while ((treg & 0x8000) == 0);
+ if (cols) {
+ if (cols > newport_xsize)
+ newport_xsize = cols;
+ newport_ysize += linetable[i+1];
+ }
+ }
+ printk ("NG1: Screensize %dx%d\n",newport_xsize,newport_ysize);
+}
+
+static void newport_get_revisions(void)
+{
+ unsigned int tmp;
+ unsigned int board_rev;
+ unsigned int rex3_rev;
+ unsigned int vc2_rev;
+ unsigned int cmap_rev;
+ unsigned int xmap9_rev;
+ unsigned int bt445_rev;
+ unsigned int bitplanes;
+
+ rex3_rev = npregs->cset.stat & NPORT_STAT_VERS;
+
+ npregs->set.dcbmode = (DCB_CMAP0 | NCMAP_PROTOCOL |
+ NCMAP_REGADDR_RREG | NPORT_DMODE_W1);
+ tmp = npregs->set.dcbdata0.bytes.b3;
+ cmap_rev = tmp & 7;
+ board_rev = (tmp >> 4) & 7;
+ bitplanes = ((board_rev > 1) && (tmp & 0x80)) ? 8 : 24;
+
+ npregs->set.dcbmode = (DCB_CMAP1 | NCMAP_PROTOCOL |
+ NCMAP_REGADDR_RREG | NPORT_DMODE_W1);
+ tmp = npregs->set.dcbdata0.bytes.b3;
+ if ((tmp & 7) < cmap_rev)
+ cmap_rev = (tmp & 7);
+
+ vc2_rev = (newport_vc2_get(npregs, VC2_IREG_CONFIG) >> 5) & 7;
+
+ npregs->set.dcbmode = (DCB_XMAP0 | R_DCB_XMAP9_PROTOCOL |
+ XM9_CRS_REVISION | NPORT_DMODE_W1);
+ xmap9_rev = npregs->set.dcbdata0.bytes.b3 & 7;
+
+ npregs->set.dcbmode = (DCB_BT445 | BT445_PROTOCOL |
+ BT445_CSR_ADDR_REG | NPORT_DMODE_W1);
+ npregs->set.dcbdata0.bytes.b3 = BT445_REVISION_REG;
+ npregs->set.dcbmode = (DCB_BT445 | BT445_PROTOCOL |
+ BT445_CSR_REVISION | NPORT_DMODE_W1);
+ bt445_rev = (npregs->set.dcbdata0.bytes.b3 >> 4) - 0x0a;
+
+#define L(a) (char)('A'+(a))
+ printk ("NG1: Revision %d, %d bitplanes, REX3 revision %c, VC2 revision %c, xmap9 revision %c, cmap revision %c, bt445 revision %c\n",
+ board_rev,bitplanes,L(rex3_rev),L(vc2_rev), L(xmap9_rev),
+ L(cmap_rev ? (cmap_rev+1):0),L(bt445_rev));
+#undef L
+
+ if (board_rev == 3) /* I don't know all affected revisions */
+ xcurs_correction = 21;
+}
+
+#ifdef MODULE
+static const char *newport_startup(void)
+#else
__initfunc(static const char *newport_startup(void))
+#endif
{
struct newport_regs *p;
@@ -140,18 +286,18 @@
}
newport_reset ();
+ newport_get_revisions();
+ newport_get_screensize();
// gfx_init (display_desc);
- newport_num_lines = ORIG_VIDEO_LINES;
- newport_num_columns = ORIG_VIDEO_COLS;
return "SGI Newport";
}
static void newport_init(struct vc_data *vc, int init)
{
- vc->vc_cols = newport_num_columns;
- vc->vc_rows = newport_num_lines;
+ vc->vc_cols = newport_xsize / 8;
+ vc->vc_rows = newport_ysize / 16;
vc->vc_can_do_color = 1;
}
@@ -160,12 +306,18 @@
int xend = ((sx + width) << 3) - 1;
int ystart = ((sy << 4) + topscan) & 0x3ff;
int yend = (((sy + height) << 4) + topscan - 1) & 0x3ff;
+
+ if (logo_active)
+ return;
if (ystart < yend) {
- newport_clear_screen(sx << 3, ystart, xend, yend);
+ newport_clear_screen(sx << 3, ystart, xend, yend,
+ (vc->vc_color & 0xf0) >> 4);
} else {
- newport_clear_screen(sx << 3, ystart, xend, 1023);
- newport_clear_screen(sx << 3, 0, xend, yend);
+ newport_clear_screen(sx << 3, ystart, xend, 1023,
+ (vc->vc_color & 0xf0) >> 4);
+ newport_clear_screen(sx << 3, 0, xend, yend,
+ (vc->vc_color & 0xf0) >> 4);
}
}
@@ -178,7 +330,7 @@
xpos <<= 3;
ypos <<= 4;
- newport_render_background(xpos, ypos, (charattr & 0xf0) >> 4);
+ newport_render_background(xpos, ypos, xpos, ypos, (charattr & 0xf0) >> 4);
/* Set the color and drawing mode. */
newport_wait();
@@ -196,11 +348,43 @@
RENDER(npregs, p);
}
-static void newport_putcs(struct vc_data *vc, const unsigned short *s, int count,
- int ypos, int xpos)
+static void newport_putcs(struct vc_data *vc, const unsigned short *s,
+ int count, int ypos, int xpos)
{
- while (count--)
- newport_putc (vc, scr_readw(s++), ypos, xpos++);
+ int i;
+ int charattr;
+ unsigned char *p;
+
+ charattr = (*s >> 8) & 0xff;
+
+ xpos <<= 3;
+ ypos <<= 4;
+
+ if (!logo_active)
+ /* Clear the area behing the string */
+ newport_render_background(xpos, ypos, xpos + ((count-1) << 3), ypos,
+ (charattr & 0xf0) >> 4);
+
+ newport_wait();
+
+ /* Set the color and drawing mode. */
+ npregs->set.colori = charattr & 0xf;
+ npregs->set.drawmode0 = (NPORT_DMODE0_DRAW | NPORT_DMODE0_BLOCK |
+ NPORT_DMODE0_STOPX | NPORT_DMODE0_ZPENAB |
+ NPORT_DMODE0_L32);
+
+ for (i = 0; i < count; i++, xpos += 8) {
+ p = &vga_font[(s[i] & 0xff) << 4];
+
+ newport_wait();
+
+ /* Set coordinates for bitmap operation. */
+ npregs->set.xystarti = (xpos << 16) | ((ypos + topscan) & 0x3ff);
+ npregs->set.xyendi = ((xpos + 7) << 16);
+
+ /* Go, baby, go... */
+ RENDER(npregs, p);
+ }
}
static void newport_cursor(struct vc_data *vc, int mode)
@@ -220,7 +404,7 @@
newport_vc2_set(npregs, VC2_IREG_CONTROL, (treg | VC2_CTRL_ECDISP));
xcurs = (vc->vc_pos - vc->vc_visible_origin) / 2;
ycurs = ((xcurs / vc->vc_cols) << 4) + 31;
- xcurs = ((xcurs % vc->vc_cols) << 3) + 21;
+ xcurs = ((xcurs % vc->vc_cols) << 3) + xcurs_correction;
newport_vc2_set(npregs, VC2_IREG_CURSX, xcurs);
newport_vc2_set(npregs, VC2_IREG_CURSY, ycurs);
}
@@ -228,7 +412,17 @@
static int newport_switch(struct vc_data *vc)
{
- npregs->cset.topscan = topscan = 0;
+ static int logo_drawn = 0;
+
+ topscan = 0;
+ npregs->cset.topscan = 0x3ff;
+
+ if (!logo_drawn) {
+ newport_show_logo();
+ logo_drawn = 1;
+ logo_active = 1;
+ }
+
return 1;
}
@@ -270,14 +464,18 @@
unsigned short *s, *d;
unsigned short chattr;
+ logo_active = 0; /* it's time to disable the logo now.. */
+
if (t == 0 && b == vc->vc_rows) {
if (dir == SM_UP) {
- npregs->cset.topscan = topscan = (topscan + (lines << 4)) & 0x3ff;
- newport_clear_lines (vc->vc_rows-lines,vc->vc_rows-1);
+ topscan = (topscan + (lines << 4)) & 0x3ff;
+ newport_clear_lines (vc->vc_rows-lines,vc->vc_rows-1,
+ (vc->vc_color & 0xf0) >> 4);
} else {
- npregs->cset.topscan = topscan = (topscan + (-lines << 4)) & 0x3ff;
- newport_clear_lines (0,lines-1);
+ topscan = (topscan + (-lines << 4)) & 0x3ff;
+ newport_clear_lines (0,lines-1, (vc->vc_color & 0xf0) >> 4);
}
+ npregs->cset.topscan = (topscan - 1) & 0x3ff;
return 0;
}
@@ -392,3 +590,23 @@
NULL, /* newport_build_attr */
NULL /* newport_invert_region */
};
+
+#ifdef MODULE
+
+int init_module(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;
+}
+
+int cleanup_module(void) {
+ printk("Unloading SGI Newport Console Driver\n");
+ return 0;
+}
+
+#endif
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)