Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hpcmips New frame buffer driver 'hpcfb' and built i...



details:   https://anonhg.NetBSD.org/src/rev/71986f02d11d
branches:  trunk
changeset: 483531:71986f02d11d
user:      takemura <takemura%NetBSD.org@localhost>
date:      Sun Mar 12 05:04:44 2000 +0000

description:
New frame buffer driver 'hpcfb' and built in video controller 'bivideo'

diffstat:

 sys/arch/hpcmips/conf/GENERIC       |   14 +-
 sys/arch/hpcmips/conf/files.hpcmips |   11 +-
 sys/arch/hpcmips/dev/bivideo.c      |  340 ++++++++++++++++++++++++++++
 sys/arch/hpcmips/dev/bivideovar.h   |    1 +
 sys/arch/hpcmips/dev/hpcfb.c        |  437 ++++++++++++++++++++++++++++++++++++
 sys/arch/hpcmips/dev/hpcfbio.h      |  240 +++++++++++++++++++
 sys/arch/hpcmips/dev/hpcfbvar.h     |   64 +++++
 sys/arch/hpcmips/hpcmips/mainbus.c  |    4 +-
 sys/arch/hpcmips/vr/vr.c            |   20 +-
 9 files changed, 1111 insertions(+), 20 deletions(-)

diffs (truncated from 1234 to 300 lines):

diff -r 15b906b1cc52 -r 71986f02d11d sys/arch/hpcmips/conf/GENERIC
--- a/sys/arch/hpcmips/conf/GENERIC     Sun Mar 12 05:01:16 2000 +0000
+++ b/sys/arch/hpcmips/conf/GENERIC     Sun Mar 12 05:04:44 2000 +0000
@@ -2,11 +2,11 @@
 # Distribution kernel (any  model) kernel config file
 
 #
-#      $NetBSD: GENERIC,v 1.34 2000/03/11 08:51:55 shin Exp $
+#      $NetBSD: GENERIC,v 1.35 2000/03/12 05:04:44 takemura Exp $
 #
 include                "arch/hpcmips/conf/std.hpcmips"
 
-#ident                 "GENERIC-$Revision: 1.34 $"
+#ident                 "GENERIC-$Revision: 1.35 $"
 
 maxusers       8
 
@@ -119,11 +119,11 @@
 vrpiu* at vrip? addr 0x0b000120 size 0x1a0 intr 5
 
 # Workstation Console attachments
-fb*            at      mainbus0
-wsdisplay*     at      fb?
-#bivideo0      at      mainbus0
-#hpcfb*                at      bivideo0
-#wsdisplay*    at      hpcfb?
+#fb*           at      mainbus0
+#wsdisplay*    at      fb?
+bivideo0       at      mainbus0
+hpcfb*         at      bivideo0
+wsdisplay*     at      hpcfb?
 wskbd*         at      vrkiu? mux 1
 wsmouse*       at      vrpiu? mux 0
 
diff -r 15b906b1cc52 -r 71986f02d11d sys/arch/hpcmips/conf/files.hpcmips
--- a/sys/arch/hpcmips/conf/files.hpcmips       Sun Mar 12 05:01:16 2000 +0000
+++ b/sys/arch/hpcmips/conf/files.hpcmips       Sun Mar 12 05:04:44 2000 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.hpcmips,v 1.24 2000/03/05 08:49:07 takemura Exp $
+#      $NetBSD: files.hpcmips,v 1.25 2000/03/12 05:04:44 takemura Exp $
 
 # maxpartitions must be first item in files.${ARCH}.
 maxpartitions 8
@@ -73,6 +73,15 @@
 attach fb at mainbus
 file   arch/hpcmips/dev/fb.c           fb needs-flag
 
+define hpcfbif {}
+device hpcfb: wsemuldisplaydev, rasops1, rasops2, rasops8, rasops15, rasops16
+attach hpcfb at hpcfbif
+file   arch/hpcmips/dev/hpcfb.c        hpcfb needs-flag
+
+device bivideo: hpcfbif
+file   arch/hpcmips/dev/bivideo.c      bivideo needs-flag
+attach bivideo at mainbus
+
 #
 # ISA bus support
 #
diff -r 15b906b1cc52 -r 71986f02d11d sys/arch/hpcmips/dev/bivideo.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hpcmips/dev/bivideo.c    Sun Mar 12 05:04:44 2000 +0000
@@ -0,0 +1,340 @@
+/*     $NetBSD: bivideo.c,v 1.1 2000/03/12 05:04:45 takemura Exp $     */
+
+/*-
+ * Copyright (c) 1999
+ *         Shin Takemura and PocketBSD Project. 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the PocketBSD project
+ *     and its contributors.
+ * 4. Neither the name of the project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
+ *
+ */
+#define FBDEBUG
+static const char _copyright[] __attribute__ ((unused)) =
+    "Copyright (c) 1999 Shin Takemura.  All rights reserved.";
+static const char _rcsid[] __attribute__ ((unused)) =
+    "$Id: bivideo.c,v 1.1 2000/03/12 05:04:45 takemura Exp $";
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/conf.h>
+#include <sys/malloc.h>
+#include <sys/buf.h>
+#include <sys/ioctl.h>
+
+#include <vm/vm.h>
+
+#include <machine/bus.h>
+#include <machine/autoconf.h>
+#include <machine/bootinfo.h>
+
+#include <arch/hpcmips/dev/hpcfbvar.h>
+#include <arch/hpcmips/dev/hpcfbio.h>
+#include <arch/hpcmips/dev/bivideovar.h>
+
+/*
+ *  function prototypes
+ */
+int    bivideomatch __P((struct device *, struct cfdata *, void *));
+void   bivideoattach __P((struct device *, struct device *, void *));
+int    bivideo_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
+int    bivideo_mmap __P((void *, off_t, int));
+
+struct bivideo_softc {
+       struct device           sc_dev;
+       struct hpcfb_fbconf     sc_fbconf;
+       struct hpcfb_dspconf    sc_dspconf;
+};
+static int bivideo_init __P((struct hpcfb_fbconf *fb));
+
+/*
+ *  static variables
+ */
+struct cfattach bivideo_ca = {
+       sizeof(struct bivideo_softc), bivideomatch, bivideoattach,
+};
+struct hpcfb_accessops bivideo_ha = {
+       bivideo_ioctl, bivideo_mmap
+};
+
+static int console_flag = 0;
+static int attach_flag = 0;
+
+/*
+ *  function bodies
+ */
+int
+bivideomatch(parent, match, aux)
+       struct device *parent;
+       struct cfdata *match;
+       void *aux;
+{
+       struct mainbus_attach_args *ma = aux;
+    
+       if (strcmp(ma->ma_name, match->cf_driver->cd_name))
+               return 0;
+
+       return (1);
+}
+
+void
+bivideoattach(parent, self, aux)
+       struct device *parent, *self;
+       void *aux;
+{
+       struct bivideo_softc *sc = (struct bivideo_softc *)self;
+       struct hpcfb_attach_args ha;
+
+       if (attach_flag) {
+               panic("%s(%d): bivideo attached twice");
+       }
+       attach_flag = 1;
+
+       bivideo_init(&sc->sc_fbconf);
+
+       printf(": pseudo video controller");
+       if (console_flag) {
+               printf(", console");
+       }
+       printf("\n");
+
+       ha.ha_console = console_flag;
+       ha.ha_accessops = &bivideo_ha;
+       ha.ha_accessctx = sc;
+       ha.ha_curfbconf = 0;
+       ha.ha_nfbconf = 1;
+       ha.ha_fbconflist = &sc->sc_fbconf;
+       ha.ha_curdspconf = 0;
+       ha.ha_ndspconf = 1;
+       ha.ha_dspconflist = &sc->sc_dspconf;
+
+       config_found(self, &ha, hpcfbprint);
+}
+
+int
+bivideo_getcnfb(fb)
+       struct hpcfb_fbconf *fb;
+{
+       console_flag = 1;
+
+       return bivideo_init(fb);
+}
+
+static int
+bivideo_init(fb)
+       struct hpcfb_fbconf *fb;
+{
+       /*
+        * get fb settings from bootinfo
+        */
+       if (bootinfo == NULL ||
+           bootinfo->fb_addr == 0 ||
+           bootinfo->fb_line_bytes == 0 ||
+           bootinfo->fb_width == 0 ||
+           bootinfo->fb_height == 0) {
+               printf("no frame buffer infomation.\n");
+               return (-1);
+       }
+
+       /* zero fill */
+       bzero(fb, sizeof(*fb));
+
+       fb->hf_conf_index       = 0;    /* configuration index          */
+       fb->hf_nconfs           = 1;    /* how many configurations      */
+       strcpy(fb->hf_name, "built-in video");
+                                       /* frame buffer name            */
+       strcpy(fb->hf_conf_name, "default");
+                                       /* configuration name           */
+       fb->hf_height           = bootinfo->fb_height;
+       fb->hf_width            = bootinfo->fb_width;
+       fb->hf_baseaddr         = mips_ptob(mips_btop(bootinfo->fb_addr));
+       fb->hf_offset           = (u_long)bootinfo->fb_addr - fb->hf_baseaddr;
+                                       /* frame buffer start offset    */
+       fb->hf_bytes_per_line   = bootinfo->fb_line_bytes;
+       fb->hf_nplanes          = 1;
+       fb->hf_bytes_per_plane  = bootinfo->fb_height *
+                                       bootinfo->fb_line_bytes;
+
+       fb->hf_access_flags |= HPCFB_ACCESS_BYTE;
+       fb->hf_access_flags |= HPCFB_ACCESS_WORD;
+       fb->hf_access_flags |= HPCFB_ACCESS_DWORD;
+
+       switch (bootinfo->fb_type) {
+               /*
+                * gray scale
+                */
+       case BIFB_D2_M2L_3:
+       case BIFB_D2_M2L_3x2:
+               fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
+               /* fall through */
+       case BIFB_D2_M2L_0:
+       case BIFB_D2_M2L_0x2:
+               fb->hf_class = HPCFB_CLASS_GRAYSCALE;
+               fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
+               fb->hf_pack_width = 8;
+               fb->hf_pixels_per_pack = 4;
+               fb->hf_pixel_width = 2;
+               fb->hf_class_data_length = sizeof(struct hf_gray_tag);
+               fb->hf_u.hf_gray.hf_flags = 0;  /* reserved for future use */
+               break;
+
+               /*
+                * indexed color
+                */
+       case BIFB_D8_FF:
+               fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
+               /* fall through */
+       case BIFB_D8_00:
+               fb->hf_class = HPCFB_CLASS_INDEXCOLOR;
+               fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
+               fb->hf_pack_width = 8;
+               fb->hf_pixels_per_pack = 1;
+               fb->hf_pixel_width = 8;
+               fb->hf_class_data_length = sizeof(struct hf_indexed_tag);
+               fb->hf_u.hf_indexed.hf_flags = 0; /* reserved for future use */
+               break;
+
+               /*
+                * RGB color
+                */
+       case BIFB_D16_FFFF:
+               fb->hf_access_flags |= HPCFB_ACCESS_REVERSE;
+               /* fall through */
+       case BIFB_D16_0000:
+               fb->hf_class = HPCFB_CLASS_RGBCOLOR;
+               fb->hf_access_flags |= HPCFB_ACCESS_STATIC;
+#if BYTE_ORDER == LITTLE_ENDIAN
+               fb->hf_swap_flags = HPCFB_SWAP_BYTE;
+#endif
+               fb->hf_pack_width = 16;
+               fb->hf_pixels_per_pack = 1;
+               fb->hf_pixel_width = 16;



Home | Main Index | Thread Index | Old Index