Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/hp300 Add dumb framebuffer (no acceleration, no col...



details:   https://anonhg.NetBSD.org/src/rev/8985d43af036
branches:  trunk
changeset: 761954:8985d43af036
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Feb 12 05:08:40 2011 +0000

description:
Add dumb framebuffer (no acceleration, no colormap) support
for HP362 and HP382.

Tested on A1473-69510 (HP362 VGA-res) and A1474-69511 (HP382 mid-res).

diffstat:

 sys/arch/hp300/conf/GENERIC             |    7 +-
 sys/arch/hp300/conf/INSTALL             |    5 +-
 sys/arch/hp300/conf/files.hp300         |    6 +-
 sys/arch/hp300/dev/diofbreg.h           |    4 +-
 sys/arch/hp300/dev/diofbvar.h           |    3 +-
 sys/arch/hp300/dev/gendiofb.c           |  277 ++++++++++++++++++++++++++++++++
 sys/arch/hp300/hp300/autoconf.c         |    9 +-
 sys/arch/hp300/stand/Makefile.buildboot |    6 +-
 sys/arch/hp300/stand/common/grfreg.h    |    4 +-
 sys/arch/hp300/stand/common/ite.c       |   10 +-
 sys/arch/hp300/stand/common/ite_dumb.c  |  251 ++++++++++++++++++++++++++++
 sys/arch/hp300/stand/common/ite_subr.c  |    8 +-
 sys/arch/hp300/stand/common/itevar.h    |   13 +-
 13 files changed, 582 insertions(+), 21 deletions(-)

diffs (truncated from 790 to 300 lines):

diff -r da9da70da2f1 -r 8985d43af036 sys/arch/hp300/conf/GENERIC
--- a/sys/arch/hp300/conf/GENERIC       Sat Feb 12 04:52:28 2011 +0000
+++ b/sys/arch/hp300/conf/GENERIC       Sat Feb 12 05:08:40 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.161 2011/02/06 18:40:55 tsutsui Exp $
+# $NetBSD: GENERIC,v 1.162 2011/02/12 05:08:40 tsutsui Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.161 $"
+#ident                 "GENERIC-$Revision: 1.162 $"
 
 maxusers       32              # estimated number of users
 
@@ -236,6 +236,9 @@
 tvrx*          at dio? scode ?         # TurboVRX framebuffer
 wsdisplay*     at tvrx?
 
+gendiofb*      at dio? scode ?         # dumb framebuffer support for 362/382
+wsdisplay*     at gendiofb?
+
 com0           at dio0 scode 9         # DCA serial interfaces
 com*           at dio? scode ?
 
diff -r da9da70da2f1 -r 8985d43af036 sys/arch/hp300/conf/INSTALL
--- a/sys/arch/hp300/conf/INSTALL       Sat Feb 12 04:52:28 2011 +0000
+++ b/sys/arch/hp300/conf/INSTALL       Sat Feb 12 05:08:40 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.42 2011/02/06 18:26:53 tsutsui Exp $
+# $NetBSD: INSTALL,v 1.43 2011/02/12 05:08:40 tsutsui Exp $
 #
 # INSTALL machine description file
 #
@@ -183,6 +183,9 @@
 tvrx*          at dio? scode ?
 wsdisplay*     at tvrx?
 
+gendiofb*      at dio? scode ?
+wsdisplay*     at gendiofb?
+
 com*           at dio0 scode 9         # DCA serial interfaces
 com*           at dio? scode ?
 
diff -r da9da70da2f1 -r 8985d43af036 sys/arch/hp300/conf/files.hp300
--- a/sys/arch/hp300/conf/files.hp300   Sat Feb 12 04:52:28 2011 +0000
+++ b/sys/arch/hp300/conf/files.hp300   Sat Feb 12 05:08:40 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.hp300,v 1.79 2011/02/06 18:26:53 tsutsui Exp $
+#      $NetBSD: files.hp300,v 1.80 2011/02/12 05:08:40 tsutsui Exp $
 #
 # hp300-specific configuration info
 
@@ -113,6 +113,10 @@
 attach tvrx at dio
 file   arch/hp300/dev/tvrx.c                   tvrx    needs-flag
 
+device gendiofb: wsemuldisplaydev, diofb, rasops8
+attach gendiofb at dio
+file   arch/hp300/dev/gendiofb.c               gendiofb        needs-flag
+
 #
 # Devices on the DIO bus
 #
diff -r da9da70da2f1 -r 8985d43af036 sys/arch/hp300/dev/diofbreg.h
--- a/sys/arch/hp300/dev/diofbreg.h     Sat Feb 12 04:52:28 2011 +0000
+++ b/sys/arch/hp300/dev/diofbreg.h     Sat Feb 12 05:08:40 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: diofbreg.h,v 1.1 2011/02/06 18:26:51 tsutsui Exp $     */
+/*     $NetBSD: diofbreg.h,v 1.2 2011/02/12 05:08:40 tsutsui Exp $     */
 /*     $OpenBSD: diofbreg.h,v 1.3 2007/01/07 15:13:52 miod Exp $       */
 
 /*
@@ -58,6 +58,8 @@
 #define GID_TIGER      12
 #define GID_YGENESIS   13
 #define GID_HYPERION   14
+#define GID_A1474MID   16
+#define GID_A147xVGA   17
 
 #ifndef        _LOCORE
 struct diofbreg {
diff -r da9da70da2f1 -r 8985d43af036 sys/arch/hp300/dev/diofbvar.h
--- a/sys/arch/hp300/dev/diofbvar.h     Sat Feb 12 04:52:28 2011 +0000
+++ b/sys/arch/hp300/dev/diofbvar.h     Sat Feb 12 05:08:40 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: diofbvar.h,v 1.1 2011/02/06 18:26:51 tsutsui Exp $     */
+/*     $NetBSD: diofbvar.h,v 1.2 2011/02/12 05:08:40 tsutsui Exp $     */
 /*     $OpenBSD: diofbvar.h,v 1.10 2006/08/11 18:33:13 miod Exp $      */
 
 /*
@@ -140,6 +140,7 @@
 int    rboxcnattach(bus_space_tag_t, bus_addr_t, int);
 int    topcatcnattach(bus_space_tag_t, bus_addr_t, int);
 int    tvrxcnattach(bus_space_tag_t, bus_addr_t, int);
+int    gendiofbcnattach(bus_space_tag_t, bus_addr_t, int);
 extern struct diofb diofb_cn;          /* struct diofb for console device */
 
 #endif
diff -r da9da70da2f1 -r 8985d43af036 sys/arch/hp300/dev/gendiofb.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hp300/dev/gendiofb.c     Sat Feb 12 05:08:40 2011 +0000
@@ -0,0 +1,277 @@
+/*     $NetBSD: gendiofb.c,v 1.1 2011/02/12 05:08:40 tsutsui Exp $     */
+/*     $OpenBSD: tvrx.c,v 1.1 2006/04/14 21:05:43 miod Exp $   */
+
+/*
+ * Copyright (c) 2006, Miodrag Vallat.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/*
+ * dumb graphics routines for frame buffer on HP362 and HP382 based on tvrx.c
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/device.h>
+#include <sys/proc.h>
+#include <sys/ioctl.h>
+#include <sys/bus.h>
+#include <sys/cpu.h>
+
+#include <machine/autoconf.h>
+
+#include <hp300/dev/dioreg.h>
+#include <hp300/dev/diovar.h>
+#include <hp300/dev/diodevs.h>
+
+#include <dev/cons.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/rasops/rasops.h>
+
+#include <hp300/dev/diofbreg.h>
+#include <hp300/dev/diofbvar.h>
+
+struct gendiofb_softc {
+       device_t        sc_dev;
+       struct diofb    *sc_fb;
+       struct diofb    sc_fb_store;
+       int             sc_scode;
+};
+
+static int gendiofb_match(device_t, cfdata_t, void *);
+static void gendiofb_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(gendiofb, sizeof(struct gendiofb_softc),
+    gendiofb_match, gendiofb_attach, NULL, NULL);
+
+static int gendiofb_reset(struct diofb *, int, struct diofbreg *);
+
+static int gendiofb_ioctl(void *, void *, u_long, void *, int, struct lwp *);
+
+static struct wsdisplay_accessops gendiofb_accessops = {
+       gendiofb_ioctl,
+       diofb_mmap,
+       diofb_alloc_screen,
+       diofb_free_screen,
+       diofb_show_screen,
+       NULL,   /* load_font */
+};
+
+/*
+ * Attachment glue
+ */
+
+static int
+gendiofb_match(device_t parent, cfdata_t cf, void *aux)
+{
+       struct dio_attach_args *da = aux;
+
+       if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER) {
+               switch (da->da_secid) {
+               case DIO_DEVICE_SECID_A147xVGA:
+               case DIO_DEVICE_SECID_A1474MID:
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
+static void
+gendiofb_attach(device_t parent, device_t self, void *aux)
+{
+       struct gendiofb_softc *sc = device_private(self);
+       struct dio_attach_args *da = aux;
+       bus_space_handle_t bsh;
+       struct diofbreg *fbr;
+       bus_size_t size;
+
+       sc->sc_dev = self;
+       sc->sc_scode = da->da_scode;
+       if (sc->sc_scode == conscode) {
+               fbr = (struct diofbreg *)conaddr;       /* already mapped */
+               sc->sc_fb = &diofb_cn;
+       } else {
+               sc->sc_fb = &sc->sc_fb_store;
+               size = da->da_size;
+               if (size > DIOII_DEVSIZE)       /* XXX */
+                       size = DIOII_DEVSIZE;
+               if (bus_space_map(da->da_bst, da->da_addr, size, 0,
+                   &bsh)) {
+                       aprint_error(": can't map framebuffer\n");
+                       return;
+               }
+               fbr = bus_space_vaddr(da->da_bst, bsh);
+               if (gendiofb_reset(sc->sc_fb, sc->sc_scode, fbr) != 0) {
+                       aprint_error(": failed to reset\n");
+                       return;
+               }
+       }
+
+       diofb_end_attach(self, &gendiofb_accessops, sc->sc_fb,
+           sc->sc_scode == conscode, NULL);
+}
+
+/*
+ * Initialize hardware and display routines.
+ */
+static int
+gendiofb_reset(struct diofb *fb, int scode, struct diofbreg *fbr)
+{
+       int rc;
+       struct rasops_info *ri = &fb->ri;
+
+       if ((rc = diofb_fbinquire(fb, scode, fbr)) != 0)
+               return (rc);
+
+       /*
+        * We rely on the PROM to initialize the frame buffer in the mode
+        * we expect it: cleared, overlay plane enabled and accessible
+        * at the beginning of the video memory.
+        *
+        * This is NOT the mode we would end up by simply resetting the
+        * board.
+        */
+
+       ri->ri_depth = 8;
+       ri->ri_stride = (fb->fbwidth * ri->ri_depth) / 8;
+
+       ri->ri_flg = RI_CENTER | RI_FULLCLEAR;
+       if (fb == &diofb_cn)
+               ri->ri_flg |= RI_NO_AUTO;       /* XXX */
+       ri->ri_bits = fb->fbkva;
+       ri->ri_width = fb->dwidth;
+       ri->ri_height = fb->dheight;
+       ri->ri_hw = fb;
+
+       /*
+        * Ask for an unholy big display, rasops will trim this to more
+        * reasonable values.
+        */
+       rasops_init(ri, 160, 160);
+       ri->ri_flg |= RI_FORCEMONO;     /* no colormap */
+
+       diofb_resetcmap(fb);
+
+       fb->wsd.name = fb->wsdname;
+       fb->wsd.ncols = ri->ri_cols;
+       fb->wsd.nrows = ri->ri_rows;
+       fb->wsd.textops = &ri->ri_ops;
+       fb->wsd.fontwidth = ri->ri_font->fontwidth;
+       fb->wsd.fontheight = ri->ri_font->fontheight;
+       fb->wsd.capabilities = ri->ri_caps;
+       strlcpy(fb->wsdname, "std", sizeof(fb->wsdname));
+
+       return 0;
+}
+
+static int
+gendiofb_ioctl(void *v, void *vs, u_long cmd, void *data, int flags,



Home | Main Index | Thread Index | Old Index