Module Name: src
Committed By: martin
Date: Wed Oct 13 16:07:41 UTC 2021
Modified Files:
src/share/man/man4/man4.amiga [netbsd-9]: amidisplaycc.4
src/sys/arch/amiga/dev [netbsd-9]: amidisplaycc.c
Log Message:
Pull up following revision(s) (requested by abs in ticket #1359):
sys/arch/amiga/dev/amidisplaycc.c: revision 1.33
share/man/man4/man4.amiga/amidisplaycc.4: revision 1.14
sys/arch/amiga/dev/amidisplaycc.c: revision 1.35
sys/arch/amiga/dev/amidisplaycc.c: revision 1.36
Implement the WSDISPLAYIO_GET_FBINFO ioctl, needed by X wsfb driver.
Add support for WSDISPLAYIO_MODE_DUMBFB to WSDISPLAYIO_SMODE.
Remove parentheses from return. No functional changes.
Update documentation to mention current status of X11
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.13.18.1 src/share/man/man4/man4.amiga/amidisplaycc.4
cvs rdiff -u -r1.32 -r1.32.4.1 src/sys/arch/amiga/dev/amidisplaycc.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/share/man/man4/man4.amiga/amidisplaycc.4
diff -u src/share/man/man4/man4.amiga/amidisplaycc.4:1.13 src/share/man/man4/man4.amiga/amidisplaycc.4:1.13.18.1
--- src/share/man/man4/man4.amiga/amidisplaycc.4:1.13 Sun Feb 7 14:06:04 2016
+++ src/share/man/man4/man4.amiga/amidisplaycc.4 Wed Oct 13 16:07:41 2021
@@ -22,7 +22,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $NetBSD: amidisplaycc.4,v 1.13 2016/02/07 14:06:04 wiz Exp $
+.\" $NetBSD: amidisplaycc.4,v 1.13.18.1 2021/10/13 16:07:41 martin Exp $
.Dd November 12, 2003
.Dt AMIDISPLAYCC 4 amiga
.Os
@@ -43,11 +43,9 @@ operate a text terminal with virtual scr
It uses the Amiga abstract graphic driver (grfabs) functions for
the low-level display management.
.Pp
-Currently it does not support running X.
-It can however coexist well enough with grf0 to make possible running
-X the old way, but be warned, you cannot switch screens while
-in X and when quitting it, it seems to hang.
-Switching a screen then will bring up the text console.
+The X11 server works in monochrome mode using the
+.Xr wsfb 4
+driver.
.Pp
It supports foreground and background color, and the hilite (bold),
underline, and reverse text attributes.
Index: src/sys/arch/amiga/dev/amidisplaycc.c
diff -u src/sys/arch/amiga/dev/amidisplaycc.c:1.32 src/sys/arch/amiga/dev/amidisplaycc.c:1.32.4.1
--- src/sys/arch/amiga/dev/amidisplaycc.c:1.32 Mon Sep 3 16:29:22 2018
+++ src/sys/arch/amiga/dev/amidisplaycc.c Wed Oct 13 16:07:41 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: amidisplaycc.c,v 1.32 2018/09/03 16:29:22 riastradh Exp $ */
+/* $NetBSD: amidisplaycc.c,v 1.32.4.1 2021/10/13 16:07:41 martin Exp $ */
/*-
* Copyright (c) 2000 Jukka Andberg.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amidisplaycc.c,v 1.32 2018/09/03 16:29:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amidisplaycc.c,v 1.32.4.1 2021/10/13 16:07:41 martin Exp $");
/*
* wscons interface to amiga custom chips. Contains the necessary functions
@@ -116,7 +116,9 @@ static int amidisplaycc_setemulcmap(stru
static int amidisplaycc_cmapioctl(view_t *, u_long, struct wsdisplay_cmap *);
static int amidisplaycc_setcmap(view_t *, struct wsdisplay_cmap *);
static int amidisplaycc_getcmap(view_t *, struct wsdisplay_cmap *);
-static int amidisplaycc_gfxscreen(struct amidisplaycc_softc *, int);
+static int amidisplaycc_setgfxview(struct amidisplaycc_softc *, int);
+static void amidisplaycc_initgfxview(struct amidisplaycc_softc *);
+static int amidisplaycc_getfbinfo(struct amidisplaycc_softc *, struct wsdisplayio_fbinfo *);
static int amidisplaycc_setfont(struct amidisplaycc_screen *, const char *);
static const struct wsdisplay_font * amidisplaycc_getbuiltinfont(void);
@@ -365,8 +367,6 @@ amidisplaycc_cninit(struct consdev * cd
int x;
int y;
- /* Yeah, we got the console! */
-
/*
* This will do the basic stuff we also need.
*/
@@ -403,11 +403,11 @@ amidisplaycc_match(device_t parent, cfda
char *name = aux;
if (matchname("amidisplaycc", name) == 0)
- return (0);
+ return 0;
/* Allow only one of us. */
if (amidisplaycc_attached)
- return (0);
+ return 0;
return 1;
}
@@ -542,10 +542,10 @@ amidisplaycc_mapchar(void *screen, int c
{
if (ch > 0 && ch < 256) {
*chp = ch;
- return (5);
+ return 5;
}
*chp = ' ';
- return (0);
+ return 0;
}
/*
@@ -1001,7 +1001,7 @@ amidisplaycc_allocattr(void *screen, int
#endif
*attrp = MAKEATTR(newfg, newbg, flags);
- return (0);
+ return 0;
}
int
@@ -1014,7 +1014,7 @@ amidisplaycc_ioctl(void *dp, void *vs, u
if (adp == NULL) {
printf("amidisplaycc_ioctl: adp==NULL\n");
- return (EINVAL);
+ return EINVAL;
}
#define UINTDATA (*(u_int*)data)
@@ -1025,49 +1025,101 @@ amidisplaycc_ioctl(void *dp, void *vs, u
{
case WSDISPLAYIO_GTYPE:
UINTDATA = WSDISPLAY_TYPE_AMIGACC;
- return (0);
+ return 0;
case WSDISPLAYIO_SVIDEO:
dprintf("amidisplaycc: WSDISPLAYIO_SVIDEO %s\n",
UINTDATA ? "On" : "Off");
- return (amidisplaycc_setvideo(adp, UINTDATA));
+ return amidisplaycc_setvideo(adp, UINTDATA);
case WSDISPLAYIO_GVIDEO:
dprintf("amidisplaycc: WSDISPLAYIO_GVIDEO\n");
UINTDATA = adp->ison ?
WSDISPLAYIO_VIDEO_ON : WSDISPLAYIO_VIDEO_OFF;
- return (0);
+ return 0;
case WSDISPLAYIO_SMODE:
- if (INTDATA == WSDISPLAYIO_MODE_EMUL)
- return amidisplaycc_gfxscreen(adp, 0);
- if (INTDATA == WSDISPLAYIO_MODE_MAPPED)
- return amidisplaycc_gfxscreen(adp, 1);
- return (EINVAL);
+ switch (INTDATA) {
+ case WSDISPLAYIO_MODE_EMUL:
+ return amidisplaycc_setgfxview(adp, 0);
+ case WSDISPLAYIO_MODE_MAPPED:
+ case WSDISPLAYIO_MODE_DUMBFB:
+ return amidisplaycc_setgfxview(adp, 1);
+ default:
+ return EINVAL;
+ }
case WSDISPLAYIO_GINFO:
FBINFO.width = adp->gfxwidth;
FBINFO.height = adp->gfxheight;
FBINFO.depth = adp->gfxdepth;
FBINFO.cmsize = 1 << FBINFO.depth;
- return (0);
+ return 0;
case WSDISPLAYIO_PUTCMAP:
case WSDISPLAYIO_GETCMAP:
- return (amidisplaycc_cmapioctl(adp->gfxview,
- cmd,
- (struct wsdisplay_cmap*)data));
+ return amidisplaycc_cmapioctl(adp->gfxview, cmd,
+ (struct wsdisplay_cmap*)data);
+ case WSDISPLAYIO_GET_FBINFO:
+ amidisplaycc_initgfxview(adp);
+ return amidisplaycc_getfbinfo(adp, data);
}
- return (EPASSTHROUGH);
+ return EPASSTHROUGH;
#undef UINTDATA
#undef INTDATA
#undef FBINFO
}
+static int
+amidisplaycc_getfbinfo(struct amidisplaycc_softc *adp, struct wsdisplayio_fbinfo *fbinfo)
+{
+ bmap_t *bm;
+
+ KASSERT(adp);
+
+ if (adp->gfxview == NULL) {
+ return ENOMEM;
+ }
+
+ bm = adp->gfxview->bitmap;
+ KASSERT(bm);
+
+ /* Depth 1 since current X wsfb driver doesn't support multiple bitplanes */
+ memset(fbinfo, 0, sizeof(*fbinfo));
+ fbinfo->fbi_fbsize = bm->bytes_per_row * bm->rows;
+ fbinfo->fbi_fboffset = 0;
+ fbinfo->fbi_width = bm->bytes_per_row * 8;
+ fbinfo->fbi_height = bm->rows;
+ fbinfo->fbi_stride = bm->bytes_per_row;
+ fbinfo->fbi_bitsperpixel = 1;
+ fbinfo->fbi_pixeltype = WSFB_CI;
+ fbinfo->fbi_flags = 0;
+ fbinfo->fbi_subtype.fbi_cmapinfo.cmap_entries = 1 << adp->gfxdepth;
+
+ return 0;
+}
+
+/*
+ * Initialize (but not display) the view used for graphics.
+ */
+static void
+amidisplaycc_initgfxview(struct amidisplaycc_softc *adp)
+{
+ dimen_t dimension;
+
+ if (adp->gfxview == NULL) {
+ /* First time here, create the screen */
+ dimension.width = adp->gfxwidth;
+ dimension.height = adp->gfxheight;
+ adp->gfxview = grf_alloc_view(NULL,
+ &dimension,
+ adp->gfxdepth);
+ }
+}
/*
* Switch to either emulation (text) or mapped (graphics) mode
@@ -1076,18 +1128,15 @@ amidisplaycc_ioctl(void *dp, void *vs, u
*
* Once the extra screen is created, it never goes away.
*/
-
static int
-amidisplaycc_gfxscreen(struct amidisplaycc_softc *adp, int on)
+amidisplaycc_setgfxview(struct amidisplaycc_softc *adp, int on)
{
- dimen_t dimension;
-
dprintf("amidisplaycc: switching to %s mode.\n",
on ? "mapped" : "emul");
/* Current mode same as requested mode? */
if ( (on > 0) == (adp->gfxon > 0) )
- return (0);
+ return 0;
if (!on) {
/*
@@ -1101,26 +1150,11 @@ amidisplaycc_gfxscreen(struct amidisplay
else if (adp->gfxview)
grf_remove_view(adp->gfxview);
- return (0);
+ return 0;
}
/* switch to mapped mode then */
-
- if (adp->gfxview == NULL) {
- /* First time here, create the screen */
-
- dimension.width = adp->gfxwidth;
- dimension.height = adp->gfxheight;
-
- dprintf("amidisplaycc: preparing mapped screen %dx%dx%d\n",
- dimension.width,
- dimension.height,
- adp->gfxdepth);
-
- adp->gfxview = grf_alloc_view(NULL,
- &dimension,
- adp->gfxdepth);
- }
+ amidisplaycc_initgfxview(adp);
if (adp->gfxview) {
adp->gfxon = 1;
@@ -1128,9 +1162,9 @@ amidisplaycc_gfxscreen(struct amidisplay
grf_display_view(adp->gfxview);
} else {
printf("amidisplaycc: failed to make mapped screen\n");
- return (ENOMEM);
+ return ENOMEM;
}
- return (0);
+ return 0;
}
/*
@@ -1212,9 +1246,9 @@ amidisplaycc_alloc_screen(void *dp, cons
/* Sanity checks because of fixed buffers */
if (depth > MAXDEPTH || maxcolor >= MAXCOLORS)
- return (ENOMEM);
+ return ENOMEM;
if (screenp->nrows > MAXROWS)
- return (ENOMEM);
+ return ENOMEM;
fontwidth = screenp->fontwidth;
fontheight = screenp->fontheight;
@@ -1229,7 +1263,7 @@ amidisplaycc_alloc_screen(void *dp, cons
view = grf_alloc_view(NULL, &dimension, depth);
if (view == NULL)
- return (ENOMEM);
+ return ENOMEM;
/*
* First screen gets the statically allocated console screen.
@@ -1348,7 +1382,7 @@ amidisplaycc_alloc_screen(void *dp, cons
scr->wsfont->name);
}
- return (0);
+ return 0;
}
@@ -1404,11 +1438,11 @@ amidisplaycc_show_screen(void *dp, void
if (adp == NULL) {
dprintf("amidisplaycc_show_screen: adp==NULL\n");
- return (EINVAL);
+ return EINVAL;
}
if (scr == NULL) {
dprintf("amidisplaycc_show_screen: scr==NULL\n");
- return (EINVAL);
+ return EINVAL;
}
if (adp->gfxon) {
@@ -1421,7 +1455,7 @@ amidisplaycc_show_screen(void *dp, void
grf_display_view(scr->view);
- return (0);
+ return 0;
}
/*
@@ -1447,7 +1481,7 @@ amidisplaycc_load_font(void *dp, void *c
if (font->data)
{
/* request to load the font, not supported */
- return (EINVAL);
+ return EINVAL;
}
else
{
@@ -1466,11 +1500,11 @@ amidisplaycc_setvideo(struct amidisplayc
if (adp == NULL) {
dprintf("amidisplaycc_setvideo: adp==NULL\n");
- return (EINVAL);
+ return EINVAL;
}
if (adp->currentscreen == NULL) {
dprintf("amidisplaycc_setvideo: adp->currentscreen==NULL\n");
- return (EINVAL);
+ return EINVAL;
}
/* select graphics or emulation screen */
@@ -1494,7 +1528,7 @@ amidisplaycc_setvideo(struct amidisplayc
adp->ison = 0;
}
- return (0);
+ return 0;
}
/*
@@ -1517,10 +1551,10 @@ amidisplaycc_cmapioctl(view_t *view, u_l
if (cmap->index >= MAXCOLORS ||
cmap->count > MAXCOLORS ||
cmap->index + cmap->count > MAXCOLORS)
- return (EINVAL);
+ return EINVAL;
if (cmap->count == 0)
- return (0);
+ return 0;
tmpcmap.index = cmap->index;
tmpcmap.count = cmap->count;
@@ -1533,15 +1567,15 @@ amidisplaycc_cmapioctl(view_t *view, u_l
err = copyin(cmap->red, cmred, cmap->count);
if (err)
- return (err);
+ return err;
err = copyin(cmap->green, cmgrn, cmap->count);
if (err)
- return (err);
+ return err;
err = copyin(cmap->blue, cmblu, cmap->count);
if (err)
- return (err);
+ return err;
return amidisplaycc_setcmap(view, &tmpcmap);
@@ -1549,26 +1583,26 @@ amidisplaycc_cmapioctl(view_t *view, u_l
err = amidisplaycc_getcmap(view, &tmpcmap);
if (err)
- return (err);
+ return err;
/* copy data to user space */
err = copyout(cmred, cmap->red, cmap->count);
if (err)
- return (err);
+ return err;
err = copyout(cmgrn, cmap->green, cmap->count);
if (err)
- return (err);
+ return err;
err = copyout(cmblu, cmap->blue, cmap->count);
if (err)
- return (err);
+ return err;
- return (0);
+ return 0;
} else
- return (EPASSTHROUGH);
+ return EPASSTHROUGH;
}
/*
@@ -1608,7 +1642,7 @@ amidisplaycc_setemulcmap(struct amidispl
rc = amidisplaycc_getcmap(scr->view, &tmpcmap);
if (rc)
- return (rc);
+ return rc;
for (i = cmap->index ; i < cmap->index + cmap->count ; i++) {
@@ -1619,9 +1653,9 @@ amidisplaycc_setemulcmap(struct amidispl
rc = amidisplaycc_setcmap(scr->view, &tmpcmap);
if (rc)
- return (rc);
+ return rc;
- return (0);
+ return 0;
}
@@ -1641,11 +1675,11 @@ amidisplaycc_setcmap(view_t *view, struc
colormap_t cm;
if (view == NULL)
- return (EINVAL);
+ return EINVAL;
if (!cmap || !cmap->red || !cmap->green || !cmap->blue) {
dprintf("amidisplaycc_setcmap: other==NULL\n");
- return (EINVAL);
+ return EINVAL;
}
index = cmap->index;
@@ -1653,10 +1687,10 @@ amidisplaycc_setcmap(view_t *view, struc
colors = (1 << view->bitmap->depth);
if (count > colors || index >= colors || index + count > colors)
- return (EINVAL);
+ return EINVAL;
if (count == 0)
- return (0);
+ return 0;
cm.entry = cmentries;
cm.first = index;
@@ -1669,7 +1703,7 @@ amidisplaycc_setcmap(view_t *view, struc
err = grf_get_colormap(view, &cm);
if (err)
- return (err);
+ return err;
/*
* The palette entries from wscons contain 8 bits per gun.
@@ -1705,7 +1739,7 @@ amidisplaycc_setcmap(view_t *view, struc
cmap->green[c] +
cmap->blue[c]) / 3 / grey_div);
} else
- return (EINVAL); /* Hmhh */
+ return EINVAL; /* Hmhh */
/*
* Now we have a new colormap that contains all the entries. Set
@@ -1716,7 +1750,7 @@ amidisplaycc_setcmap(view_t *view, struc
if (err)
return err;
- return (0);
+ return 0;
}
/*
@@ -1735,20 +1769,20 @@ amidisplaycc_getcmap(view_t *view, struc
colormap_t cm;
if (view == NULL)
- return (EINVAL);
+ return EINVAL;
if (!cmap || !cmap->red || !cmap->green || !cmap->blue)
- return (EINVAL);
+ return EINVAL;
index = cmap->index;
count = cmap->count;
colors = (1 << view->bitmap->depth);
if (count > colors || index >= colors || index + count > colors)
- return (EINVAL);
+ return EINVAL;
if (count == 0)
- return (0);
+ return 0;
cm.entry = cmentries;
cm.first = index;
@@ -1756,7 +1790,7 @@ amidisplaycc_getcmap(view_t *view, struc
err = grf_get_colormap(view, &cm);
if (err)
- return (err);
+ return err;
/*
* Copy color data to wscons-style structure. Translate to
@@ -1791,9 +1825,9 @@ amidisplaycc_getcmap(view_t *view, struc
CM_GET_GREY(cm.entry[index+c]);
}
} else
- return (EINVAL);
+ return EINVAL;
- return (0);
+ return 0;
}
/*
@@ -1823,11 +1857,11 @@ amidisplaycc_setfont(struct amidisplaycc
WSFONT_FIND_BITMAP);
if (wsfontcookie == -1)
- return (EINVAL);
+ return EINVAL;
/* Suitable font found. Now lock it. */
if (wsfont_lock(wsfontcookie, &wsfont))
- return (EINVAL);
+ return EINVAL;
KASSERT(wsfont);
@@ -1837,7 +1871,7 @@ amidisplaycc_setfont(struct amidisplaycc
scr->wsfont = wsfont;
scr->wsfontcookie = wsfontcookie;
- return (0);
+ return 0;
}
/*
@@ -1910,7 +1944,7 @@ amidisplaycc_cnputc(dev_t cd, int ch)
int
amidisplaycc_cngetc(dev_t cd)
{
- return (0);
+ return 0;
}
/* ARGSUSED */