Module Name: src
Committed By: phx
Date: Fri Nov 4 18:06:08 UTC 2016
Modified Files:
src/sys/arch/amiga/conf: WSCONS
src/sys/arch/amiga/dev: grf_et.c
Log Message:
wscons and Xorg support for Tseng ET4000/W32 based boards (grf6).
To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/amiga/conf/WSCONS
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/amiga/dev/grf_et.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amiga/conf/WSCONS
diff -u src/sys/arch/amiga/conf/WSCONS:1.70 src/sys/arch/amiga/conf/WSCONS:1.71
--- src/sys/arch/amiga/conf/WSCONS:1.70 Mon Oct 3 14:26:02 2016
+++ src/sys/arch/amiga/conf/WSCONS Fri Nov 4 18:06:08 2016
@@ -1,4 +1,4 @@
-# $NetBSD: WSCONS,v 1.70 2016/10/03 14:26:02 rkujawa Exp $
+# $NetBSD: WSCONS,v 1.71 2016/11/04 18:06:08 phx Exp $
# GENERIC with wscons(4)
#
@@ -28,12 +28,10 @@ no grfcc0 at mainbus0
no grfrt0 at zbus0
no grfrh0 at zbus0
no grful0 at zbus0
-no grfet* at zbus0
no grf0 at grfcc0
no grf1 at grfrt0
no grf2 at grfrh0
no grf4 at grful0
-no grf6 at grfet?
# Disable ite(4) for all grf(4) drivers.
no ite0 at grf0
Index: src/sys/arch/amiga/dev/grf_et.c
diff -u src/sys/arch/amiga/dev/grf_et.c:1.32 src/sys/arch/amiga/dev/grf_et.c:1.33
--- src/sys/arch/amiga/dev/grf_et.c:1.32 Wed Jan 22 00:25:16 2014
+++ src/sys/arch/amiga/dev/grf_et.c Fri Nov 4 18:06:08 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: grf_et.c,v 1.32 2014/01/22 00:25:16 christos Exp $ */
+/* $NetBSD: grf_et.c,v 1.33 2016/11/04 18:06:08 phx Exp $ */
/*
* Copyright (c) 1997 Klaus Burkert
@@ -37,10 +37,11 @@
#include "opt_amigacons.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: grf_et.c,v 1.32 2014/01/22 00:25:16 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: grf_et.c,v 1.33 2016/11/04 18:06:08 phx Exp $");
#include "grfet.h"
#include "ite.h"
+#include "wsdisplay.h"
#if NGRFET > 0
/*
@@ -72,6 +73,12 @@ __KERNEL_RCSID(0, "$NetBSD: grf_et.c,v 1
#include <machine/cpu.h>
#include <dev/cons.h>
+#if NWSDISPLAY > 0
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/rasops/rasops.h>
+#include <dev/wscons/wsdisplay_vconsvar.h>
+#endif
#ifdef TSENGCONSOLE
#include <amiga/dev/itevar.h>
#endif
@@ -81,34 +88,50 @@ __KERNEL_RCSID(0, "$NetBSD: grf_et.c,v 1
#include <amiga/dev/grf_etreg.h>
#include <amiga/dev/zbusvar.h>
-int et_mondefok(struct grfvideo_mode *gv);
-void et_boardinit(struct grf_softc *gp);
-static void et_CompFQ(u_int fq, u_char *num, u_char *denom);
-int et_getvmode(struct grf_softc *gp, struct grfvideo_mode *vm);
-int et_setvmode(struct grf_softc *gp, unsigned int mode);
-int et_toggle(struct grf_softc *gp, unsigned short);
-int et_getcmap(struct grf_softc *gfp, struct grf_colormap *cmap);
-int et_putcmap(struct grf_softc *gfp, struct grf_colormap *cmap);
+int et_mondefok(struct grfvideo_mode *);
+void et_boardinit(struct grf_softc *);
+static void et_CompFQ(u_int fq, u_char *, u_char *);
+int et_getvmode(struct grf_softc *, struct grfvideo_mode *);
+int et_setvmode(struct grf_softc *, unsigned int);
+int et_toggle(struct grf_softc *, unsigned short);
+int et_getcmap(struct grf_softc *, struct grf_colormap *);
+int et_putcmap(struct grf_softc *, struct grf_colormap *);
#ifndef TSENGCONSOLE
-void et_off(struct grf_softc *gp);
+void et_off(struct grf_softc *);
#endif
-void et_inittextmode(struct grf_softc *gp);
-int et_ioctl(register struct grf_softc *gp, u_long cmd, void *data);
-int et_getmousepos(struct grf_softc *gp, struct grf_position *data);
-void et_writesprpos(volatile char *ba, short x, short y);
-int et_setmousepos(struct grf_softc *gp, struct grf_position *data);
-static int et_setspriteinfo(struct grf_softc *gp, struct grf_spriteinfo *data);
-int et_getspriteinfo(struct grf_softc *gp, struct grf_spriteinfo *data);
-static int et_getspritemax(struct grf_softc *gp, struct grf_position *data);
-int et_setmonitor(struct grf_softc *gp, struct grfvideo_mode *gv);
-int et_blank(struct grf_softc *gp, int *on);
-static int et_getControllerType(struct grf_softc *gp);
-static int et_getDACType(struct grf_softc *gp);
+void et_inittextmode(struct grf_softc *);
+int et_ioctl(register struct grf_softc *, u_long cmd, void *);
+int et_getmousepos(struct grf_softc *, struct grf_position *);
+void et_writesprpos(volatile char *ba, short, short);
+int et_setmousepos(struct grf_softc *, struct grf_position *);
+static int et_setspriteinfo(struct grf_softc *, struct grf_spriteinfo *);
+int et_getspriteinfo(struct grf_softc *, struct grf_spriteinfo *);
+static int et_getspritemax(struct grf_softc *, struct grf_position *);
+int et_setmonitor(struct grf_softc *, struct grfvideo_mode *);
+int et_blank(struct grf_softc *, int);
+int et_isblank(struct grf_softc *);
+static int et_getControllerType(struct grf_softc *);
+static int et_getDACType(struct grf_softc *);
int grfetmatch(device_t, cfdata_t, void *);
void grfetattach(device_t, device_t, void *);
int grfetprint(void *, const char *);
-void et_memset(volatile unsigned char *d, unsigned char c, int l);
+void et_memset(volatile unsigned char *, unsigned char, int);
+
+#if NWSDISPLAY > 0
+/* wsdisplay acessops, emulops */
+static int et_wsioctl(void *, void *, u_long, void *, int, struct lwp *);
+static int et_get_fbinfo(struct grf_softc *, struct wsdisplayio_fbinfo *);
+
+static void et_wscursor(void *, int, int, int);
+static void et_wsputchar(void *, int, int, u_int, long);
+static void et_wscopycols(void *, int, int, int, int);
+static void et_wserasecols(void *, int, int, int, long);
+static void et_wscopyrows(void *, int, int, int);
+static void et_wseraserows(void *, int, int, long);
+static int et_wsallocattr(void *, int, int, int, long *);
+static int et_wsmapchar(void *, int, unsigned int *);
+#endif /* NWSDISPLAY > 0 */
/*
* Graphics display definitions.
@@ -179,6 +202,41 @@ struct grf_spriteinfo et_cursprite;
static unsigned char et_imageptr[8 * 64], et_maskptr[8 * 64];
static unsigned char et_sprred[2], et_sprgreen[2], et_sprblue[2];
+#if NWSDISPLAY > 0
+static struct wsdisplay_accessops et_accessops = {
+ .ioctl = et_wsioctl,
+ .mmap = grf_wsmmap
+};
+
+static struct wsdisplay_emulops et_textops = {
+ .cursor = et_wscursor,
+ .mapchar = et_wsmapchar,
+ .putchar = et_wsputchar,
+ .copycols = et_wscopycols,
+ .erasecols = et_wserasecols,
+ .copyrows = et_wscopyrows,
+ .eraserows = et_wseraserows,
+ .allocattr = et_wsallocattr
+};
+
+static struct wsscreen_descr et_defaultscreen = {
+ .name = "default",
+ .textops = &et_textops,
+ .fontwidth = 8,
+ .fontheight = TSENGFONTY,
+ .capabilities = WSSCREEN_HILIT | WSSCREEN_BLINK |
+ WSSCREEN_REVERSE | WSSCREEN_UNDERLINE
+};
+
+static const struct wsscreen_descr *et_screens[] = {
+ &et_defaultscreen,
+};
+
+static struct wsscreen_list et_screenlist = {
+ sizeof(et_screens) / sizeof(struct wsscreen_descr *), et_screens
+};
+#endif /* NWSDISPLAY > 0 */
+
/* standard driver stuff */
CFATTACH_DECL_NEW(grfet, sizeof(struct grf_softc),
grfetmatch, grfetattach, NULL, NULL);
@@ -312,9 +370,16 @@ grfetattach(device_t parent, device_t se
et_boardinit(gp);
#ifdef TSENGCONSOLE
+#if NWSDISPLAY > 0
+ gp->g_accessops = &et_accessops;
+ gp->g_emulops = &et_textops;
+ gp->g_defaultscr = &et_defaultscreen;
+ gp->g_scrlist = &et_screenlist;
+#else
#if NITE > 0
grfet_iteinit(gp);
#endif
+#endif /* NWSDISPLAY > 0 */
(void) et_load_mon(gp, &etconsole_mode);
#endif
}
@@ -621,10 +686,21 @@ et_off(struct grf_softc *gp)
int
-et_blank(struct grf_softc *gp, int *on)
+et_blank(struct grf_softc *gp, int on)
+{
+
+ WSeq(gp->g_regkva, SEQ_ID_CLOCKING_MODE, on > 0 ? 0x01 : 0x21);
+ return 0;
+}
+
+
+int
+et_isblank(struct grf_softc *gp)
{
- WSeq(gp->g_regkva, SEQ_ID_CLOCKING_MODE, *on > 0 ? 0x01 : 0x21);
- return(0);
+ int r;
+
+ r = RSeq(gp->g_regkva, SEQ_ID_CLOCKING_MODE);
+ return (r & 0x20) != 0;
}
@@ -715,7 +791,7 @@ et_ioctl(register struct grf_softc *gp,
return (et_setmonitor(gp, (struct grfvideo_mode *) data));
case GRFIOCBLANK:
- return (et_blank(gp, (int *)data));
+ return (et_blank(gp, *(int *)data));
}
return (EPASSTHROUGH);
}
@@ -1598,4 +1674,343 @@ et_getDACType(struct grf_softc *gp)
return (SIERRA11483);
}
+
+#if NWSDISPLAY > 0
+static void
+et_wscursor(void *c, int on, int row, int col)
+{
+ struct rasops_info *ri;
+ struct vcons_screen *scr;
+ struct grf_softc *gp;
+ volatile void *ba;
+ int offs;
+
+ ri = c;
+ scr = ri->ri_hw;
+ gp = scr->scr_cookie;
+ ba = gp->g_regkva;
+
+ if ((ri->ri_flg & RI_CURSOR) && !on) {
+ /* cursor was visible, but we want to remove it */
+ /*WCrt(ba, CRT_ID_CURSOR_START, | 0x20);*/
+ ri->ri_flg &= ~RI_CURSOR;
+ }
+
+ ri->ri_crow = row;
+ ri->ri_ccol = col;
+
+ if (on) {
+ /* move cursor to new location */
+ if (!(ri->ri_flg & RI_CURSOR)) {
+ /*WCrt(ba, CRT_ID_CURSOR_START, | 0x20);*/
+ ri->ri_flg |= RI_CURSOR;
+ }
+ offs = gp->g_rowoffset[row] + col;
+ WCrt(ba, CRT_ID_CURSOR_LOC_LOW, offs & 0xff);
+ WCrt(ba, CRT_ID_CURSOR_LOC_HIGH, (offs >> 8) & 0xff);
+ WCrt(ba, CRT_ID_EXT_START, (offs >> (16-2)) & 0x0c);
+ }
+}
+
+static void
+et_wsputchar(void *c, int row, int col, u_int ch, long attr)
+{
+ struct rasops_info *ri;
+ struct vcons_screen *scr;
+ struct grf_softc *gp;
+ volatile unsigned char *ba, *cp;
+
+ ri = c;
+ scr = ri->ri_hw;
+ gp = scr->scr_cookie;
+ ba = gp->g_regkva;
+ cp = gp->g_fbkva;
+
+ cp += gp->g_rowoffset[row] + col;
+ SetTextPlane(ba, 0x00);
+ *cp = ch;
+ SetTextPlane(ba, 0x01);
+ *cp = attr;
+}
+
+static void
+et_wscopycols(void *c, int row, int srccol, int dstcol, int ncols)
+{
+ volatile unsigned char *ba, *dst, *src;
+ struct rasops_info *ri;
+ struct vcons_screen *scr;
+ struct grf_softc *gp;
+ int i;
+
+ KASSERT(ncols > 0);
+ ri = c;
+ scr = ri->ri_hw;
+ gp = scr->scr_cookie;
+ ba = gp->g_regkva;
+ src = gp->g_fbkva;
+
+ src += gp->g_rowoffset[row];
+ dst = src;
+ src += srccol;
+ dst += dstcol;
+ if (srccol < dstcol) {
+ /* need to copy backwards */
+ src += ncols;
+ dst += ncols;
+ SetTextPlane(ba, 0x00);
+ for (i = 0; i < ncols; i++)
+ *(--dst) = *(--src);
+ src += ncols;
+ dst += ncols;
+ SetTextPlane(ba, 0x01);
+ for (i = 0; i < ncols; i++)
+ *(--dst) = *(--src);
+ } else {
+ SetTextPlane(ba, 0x00);
+ for (i = 0; i < ncols; i++)
+ *dst++ = *src++;
+ src -= ncols;
+ dst -= ncols;
+ SetTextPlane(ba, 0x01);
+ for (i = 0; i < ncols; i++)
+ *dst++ = *src++;
+ }
+}
+
+static void
+et_wserasecols(void *c, int row, int startcol, int ncols, long fillattr)
+{
+ volatile unsigned char *ba, *cp;
+ struct rasops_info *ri;
+ struct vcons_screen *scr;
+ struct grf_softc *gp;
+ int i;
+
+ ri = c;
+ scr = ri->ri_hw;
+ gp = scr->scr_cookie;
+ ba = gp->g_regkva;
+ cp = gp->g_fbkva;
+
+ cp += gp->g_rowoffset[row] + startcol;
+ SetTextPlane(ba, 0x00);
+ for (i = 0; i < ncols; i++)
+ *cp++ = 0x20;
+ cp -= ncols;
+ SetTextPlane(ba, 0x01);
+ for (i = 0; i < ncols; i++)
+ *cp++ = 0x07;
+}
+
+static void
+et_wscopyrows(void *c, int srcrow, int dstrow, int nrows)
+{
+ volatile unsigned char *ba, *dst, *src;
+ struct rasops_info *ri;
+ struct vcons_screen *scr;
+ struct grf_softc *gp;
+ int i, n;
+
+ KASSERT(nrows > 0);
+ ri = c;
+ scr = ri->ri_hw;
+ gp = scr->scr_cookie;
+ ba = gp->g_regkva;
+ src = dst = gp->g_fbkva;
+ n = ri->ri_cols * nrows;
+
+ if (srcrow < dstrow) {
+ /* need to copy backwards */
+ src += gp->g_rowoffset[srcrow + nrows];
+ dst += gp->g_rowoffset[dstrow + nrows];
+ SetTextPlane(ba, 0x00);
+ for (i = 0; i < n; i++)
+ *(--dst) = *(--src);
+ src += n;
+ dst += n;
+ SetTextPlane(ba, 0x01);
+ for (i = 0; i < n; i++)
+ *(--dst) = *(--src);
+ } else {
+ src += gp->g_rowoffset[srcrow];
+ dst += gp->g_rowoffset[dstrow];
+ SetTextPlane(ba, 0x00);
+ for (i = 0; i < n; i++)
+ *dst++ = *src++;
+ src -= n;
+ dst -= n;
+ SetTextPlane(ba, 0x01);
+ for (i = 0; i < n; i++)
+ *dst++ = *src++;
+ }
+}
+
+static void
+et_wseraserows(void *c, int row, int nrows, long fillattr)
+{
+ volatile unsigned char *ba, *cp;
+ struct rasops_info *ri;
+ struct vcons_screen *scr;
+ struct grf_softc *gp;
+ int i, n;
+
+ ri = c;
+ scr = ri->ri_hw;
+ gp = scr->scr_cookie;
+ ba = gp->g_regkva;
+ cp = gp->g_fbkva;
+
+ cp += gp->g_rowoffset[row];
+ n = ri->ri_cols * nrows;
+ SetTextPlane(ba, 0x00);
+ for (i = 0; i < n; i++)
+ *cp++ = 0x20;
+ cp -= n;
+ SetTextPlane(ba, 0x01);
+ for (i = 0; i < n; i++)
+ *cp++ = 0x07;
+}
+
+static int
+et_wsallocattr(void *c, int fg, int bg, int flg, long *attr)
+{
+
+ /* XXX color support? */
+ *attr = (flg & WSATTR_REVERSE) ? 0x70 : 0x07;
+ if (flg & WSATTR_UNDERLINE) *attr = 0x01;
+ if (flg & WSATTR_HILIT) *attr |= 0x08;
+ if (flg & WSATTR_BLINK) *attr |= 0x80;
+ return 0;
+}
+
+/* our font does not support unicode extensions */
+static int
+et_wsmapchar(void *c, int ch, unsigned int *cp)
+{
+
+ if (ch > 0 && ch < 256) {
+ *cp = ch;
+ return 5;
+ }
+ *cp = ' ';
+ return 0;
+}
+
+static int
+et_wsioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l)
+{
+ struct vcons_data *vd;
+ struct grf_softc *gp;
+
+ vd = v;
+ gp = vd->cookie;
+
+ switch (cmd) {
+ case WSDISPLAYIO_GETCMAP:
+ /* Note: wsdisplay_cmap and grf_colormap have same format */
+ if (gp->g_display.gd_planes == 8)
+ return et_getcmap(gp, (struct grf_colormap *)data);
+ return EINVAL;
+
+ case WSDISPLAYIO_PUTCMAP:
+ /* Note: wsdisplay_cmap and grf_colormap have same format */
+ if (gp->g_display.gd_planes == 8)
+ return et_putcmap(gp, (struct grf_colormap *)data);
+ return EINVAL;
+
+ case WSDISPLAYIO_GVIDEO:
+ if (et_isblank(gp))
+ *(u_int *)data = WSDISPLAYIO_VIDEO_OFF;
+ else
+ *(u_int *)data = WSDISPLAYIO_VIDEO_ON;
+ return 0;
+
+ case WSDISPLAYIO_SVIDEO:
+ return et_blank(gp, *(u_int *)data == WSDISPLAYIO_VIDEO_ON);
+
+ case WSDISPLAYIO_SMODE:
+ if ((*(int *)data) != gp->g_wsmode) {
+ if (*(int *)data == WSDISPLAYIO_MODE_EMUL) {
+ /* load console text mode, redraw screen */
+ (void)et_load_mon(gp, &etconsole_mode);
+ if (vd->active != NULL)
+ vcons_redraw_screen(vd->active);
+ } else {
+ /* switch to current graphics mode */
+ if (!et_load_mon(gp,
+ (struct grfettext_mode *)monitor_current))
+ return EINVAL;
+ }
+ gp->g_wsmode = *(int *)data;
+ }
+ return 0;
+
+ case WSDISPLAYIO_GET_FBINFO:
+ return et_get_fbinfo(gp, data);
+ }
+
+ /* handle this command hw-independant in grf(4) */
+ return grf_wsioctl(v, vs, cmd, data, flag, l);
+}
+
+/*
+ * Fill the wsdisplayio_fbinfo structure with information from the current
+ * graphics mode. Even when text mode is active.
+ */
+static int
+et_get_fbinfo(struct grf_softc *gp, struct wsdisplayio_fbinfo *fbi)
+{
+ struct grfvideo_mode *md;
+ uint32_t rbits, gbits, bbits;
+
+ md = monitor_current;
+
+ switch (md->depth) {
+ case 8:
+ fbi->fbi_bitsperpixel = 8;
+ rbits = gbits = bbits = 6; /* keep gcc happy */
+ break;
+ case 15:
+ fbi->fbi_bitsperpixel = 16;
+ rbits = gbits = bbits = 5;
+ break;
+ case 16:
+ fbi->fbi_bitsperpixel = 16;
+ rbits = bbits = 5;
+ gbits = 6;
+ break;
+ case 24:
+ fbi->fbi_bitsperpixel = 24;
+ rbits = gbits = bbits = 8;
+ break;
+ default:
+ return EINVAL;
+ }
+
+ fbi->fbi_stride = (fbi->fbi_bitsperpixel / 8) * md->disp_width;
+ fbi->fbi_width = md->disp_width;
+ fbi->fbi_height = md->disp_height;
+
+ if (md->depth > 8) {
+ fbi->fbi_pixeltype = WSFB_RGB;
+ fbi->fbi_subtype.fbi_rgbmasks.red_offset = bbits + gbits;
+ fbi->fbi_subtype.fbi_rgbmasks.red_size = rbits;
+ fbi->fbi_subtype.fbi_rgbmasks.green_offset = bbits;
+ fbi->fbi_subtype.fbi_rgbmasks.green_size = gbits;
+ fbi->fbi_subtype.fbi_rgbmasks.blue_offset = 0;
+ fbi->fbi_subtype.fbi_rgbmasks.blue_size = bbits;
+ fbi->fbi_subtype.fbi_rgbmasks.alpha_offset = 0;
+ fbi->fbi_subtype.fbi_rgbmasks.alpha_size = 0;
+ } else {
+ fbi->fbi_pixeltype = WSFB_CI;
+ fbi->fbi_subtype.fbi_cmapinfo.cmap_entries = 1 << md->depth;
+ }
+
+ fbi->fbi_flags = 0;
+ fbi->fbi_fbsize = fbi->fbi_stride * fbi->fbi_height;
+ fbi->fbi_fboffset = 0;
+ return 0;
+}
+#endif /* NWSDISPLAY > 0 */
+
#endif /* NGRFET */