Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/pmax/dev Initial import of `PX' driver.



details:   https://anonhg.NetBSD.org/src/rev/8e95e2fa9c8d
branches:  trunk
changeset: 471841:8e95e2fa9c8d
user:      ad <ad%NetBSD.org@localhost>
date:      Tue Apr 13 00:30:08 1999 +0000

description:
Initial import of `PX' driver.

diffstat:

 sys/arch/pmax/dev/px.c    |  1833 +++++++++++++++++++++++++++++++++++++++++++++
 sys/arch/pmax/dev/pxreg.h |   372 +++++++++
 sys/arch/pmax/dev/pxvar.h |   142 +++
 3 files changed, 2347 insertions(+), 0 deletions(-)

diffs (truncated from 2359 to 300 lines):

diff -r b6ce49b6ce53 -r 8e95e2fa9c8d sys/arch/pmax/dev/px.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/pmax/dev/px.c    Tue Apr 13 00:30:08 1999 +0000
@@ -0,0 +1,1833 @@
+/* $NetBSD: px.c,v 1.1 1999/04/13 00:30:08 ad Exp $ */
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jonathan Stone <jonathan%NetBSD.org@localhost> and Andy Doran <ad%NetBSD.org@localhost>.
+ *
+ * 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 NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+#include "px.h"
+
+#if NPX > 1
+#error Multiboard px support not in-tree right now.
+#endif
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: px.c,v 1.1 1999/04/13 00:30:08 ad Exp $");
+
+/*
+ * px.c: driver for the DEC TURBOchannel 2D and 3D accelerated framebuffers 
+ * with PixelStamp blitter asics (and i860 accelerators, on the higher end
+ * cards).
+ */
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/poll.h>
+#include <sys/time.h>
+#include <sys/kernel.h>
+#include <sys/ioctl.h>
+#include <sys/file.h>
+#include <sys/vnode.h>
+#include <sys/errno.h>
+#include <sys/proc.h>
+#include <sys/mman.h>
+
+#include <vm/vm.h>
+#include <miscfs/specfs/specdev.h>
+
+#include <dev/cons.h>
+#include <dev/tc/tcvar.h>
+#include <dev/ic/bt459reg.h>
+#include <dev/rcons/rcons.h>
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/wscons/wsconsio.h>
+#include <dev/wsfont/wsfont.h>
+
+#include <mips/cpuregs.h>
+#include <machine/autoconf.h>
+#include <machine/cpu.h>
+#include <machine/bus.h>
+#include <machine/pmioctl.h>
+#include <machine/fbio.h>
+#include <machine/fbvar.h>
+
+#include <pmax/dev/fbreg.h>
+#include <pmax/dev/pxreg.h>
+#include <pmax/dev/pxvar.h>
+#include <pmax/dev/rconsvar.h>
+#include <pmax/dev/qvssvar.h>
+
+struct px_softc {
+       struct  device px_dv;
+       struct  px_info *px_info;
+};
+
+/* Called externally */
+int    px_match __P((struct device *, struct cfdata *, void *));
+void   px_attach __P((struct device *, struct device *, void *));
+int    px_intr __P((void *xxx_sc));
+
+/* Our cdev interface */
+int    pxopen __P((dev_t, int, int, struct proc *));
+int    pxclose __P((dev_t, int, int, struct proc *));
+int    pxioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
+int    pxpoll __P((dev_t, int, struct proc *));
+int    pxmmap __P((dev_t, int, int));
+
+/* Stuff that we use internally */
+static int32_t *px_alloc_pbuf __P((struct px_info *));
+static int     px_send_packet __P((struct px_info *, int *buf));
+static void    px_init_stic __P((struct px_info *, int));
+static void    px_bt459_init __P((struct px_info *));
+static int     px_probe_planes __P((struct px_info *, int));
+static void    px_load_cursor __P((struct px_info *));
+static void    px_conv_cursor __P((struct px_info *, u_short *));
+static void    px_load_cmap __P((struct px_info *, int, int));
+static void    px_load_cursor_data __P((struct px_info *, int, int));
+static void    px_make_cursor __P((struct px_info *));
+static int     px_rect __P((struct px_info *, int, int, int, int, int));
+static void    px_qvss_init __P((struct px_info *));
+static int     px_mmap_info  __P((struct proc *, dev_t, vm_offset_t *));
+static void    px_cursor_hack __P((struct fbinfo *, int, int));
+
+struct cfattach px_ca = {
+       sizeof(struct px_softc), 
+       px_match, 
+       px_attach,
+};
+
+/* The different types of card that we support, for px_match(). */
+static const char *px_types[] = {
+       "PMAG-CA ",
+       "PMAG-DA ", /* XXX should this be PMAGB-DA? */
+       "PMAG-E  ", /* XXX should this be PMAGB-EA? */
+       "PMAG-EA ",
+       "PMAG-F  ", /* XXX always -FA? */
+       "PMAG-FA ",
+};
+
+#define NUM_PX_TYPES (sizeof(px_types) / sizeof(px_types[0]))
+
+/* wscons emulator operations */
+static void    px_cursor __P((void *, int, int, int));
+static void    px_putchar __P((void *, int, int, u_int, long));
+static void    px_copycols __P((void *, int, int, int, int));
+static void    px_copyrows __P((void *, int, int, int num));
+static void    px_erasecols __P((void *, int, int, int num, long));
+static void    px_eraserows __P((void *, int, int, long));
+static int     px_alloc_attr __P((void *, int, int, int, long *));
+static int     px_mapchar __P((void *, int, unsigned int *));
+
+static struct wsdisplay_emulops px_emulops = {
+       px_cursor,
+       px_mapchar,
+       px_putchar,
+       px_copycols,
+       px_erasecols,
+       px_copyrows,
+       px_eraserows,
+       px_alloc_attr
+};
+
+/* Colormap for wscons, matching WSCOL_*. Upper 8 are high-intensity */
+#define FGCOLOR(a)     ((a) & 255)
+#define BGCOLOR(a)     (((a) >> 8) & 255)
+
+static const u_char px_cmap[16*3] = {
+       0x00, 0x00, 0x00, /* black */
+       0x7f, 0x00, 0x00, /* red */
+       0x00, 0x7f, 0x00, /* green */
+       0x7f, 0x7f, 0x00, /* brown */
+       0x00, 0x00, 0x7f, /* blue */
+       0x7f, 0x00, 0x7f, /* magenta */
+       0x00, 0x7f, 0x7f, /* cyan */
+       0xc7, 0xc7, 0xc7, /* white - XXX too dim? */
+
+       0x7f, 0x7f, 0x7f, /* black */
+       0xff, 0x00, 0x00, /* red */
+       0x00, 0xff, 0x00, /* green */
+       0xff, 0xff, 0x00, /* brown */
+       0x00, 0x00, 0xff, /* blue */
+       0xff, 0x00, 0xff, /* magenta */
+       0x00, 0xff, 0xff, /* cyan */
+       0xff, 0xff, 0xff, /* white */
+};
+
+/*
+ * Compose 2 bit/pixel cursor image.  Bit order will be reversed.
+ *   M M M M I I I I           M I M I M I M I
+ *     [ before ]                 [ after ]
+ *   3 2 1 0 3 2 1 0           0 0 1 1 2 2 3 3
+ *   7 6 5 4 7 6 5 4           4 4 5 5 6 6 7 7
+ *
+ * XXX duplicated in sfb.c, cfb.c, mfb.c
+ */
+static const u_char px_shuffle[256] = {
+       0x00, 0x40, 0x10, 0x50, 0x04, 0x44, 0x14, 0x54,
+       0x01, 0x41, 0x11, 0x51, 0x05, 0x45, 0x15, 0x55,
+       0x80, 0xc0, 0x90, 0xd0, 0x84, 0xc4, 0x94, 0xd4,
+       0x81, 0xc1, 0x91, 0xd1, 0x85, 0xc5, 0x95, 0xd5,
+       0x20, 0x60, 0x30, 0x70, 0x24, 0x64, 0x34, 0x74,
+       0x21, 0x61, 0x31, 0x71, 0x25, 0x65, 0x35, 0x75,
+       0xa0, 0xe0, 0xb0, 0xf0, 0xa4, 0xe4, 0xb4, 0xf4,
+       0xa1, 0xe1, 0xb1, 0xf1, 0xa5, 0xe5, 0xb5, 0xf5,
+       0x08, 0x48, 0x18, 0x58, 0x0c, 0x4c, 0x1c, 0x5c,
+       0x09, 0x49, 0x19, 0x59, 0x0d, 0x4d, 0x1d, 0x5d,
+       0x88, 0xc8, 0x98, 0xd8, 0x8c, 0xcc, 0x9c, 0xdc,
+       0x89, 0xc9, 0x99, 0xd9, 0x8d, 0xcd, 0x9d, 0xdd,
+       0x28, 0x68, 0x38, 0x78, 0x2c, 0x6c, 0x3c, 0x7c,
+       0x29, 0x69, 0x39, 0x79, 0x2d, 0x6d, 0x3d, 0x7d,
+       0xa8, 0xe8, 0xb8, 0xf8, 0xac, 0xec, 0xbc, 0xfc,
+       0xa9, 0xe9, 0xb9, 0xf9, 0xad, 0xed, 0xbd, 0xfd,
+       0x02, 0x42, 0x12, 0x52, 0x06, 0x46, 0x16, 0x56,
+       0x03, 0x43, 0x13, 0x53, 0x07, 0x47, 0x17, 0x57,
+       0x82, 0xc2, 0x92, 0xd2, 0x86, 0xc6, 0x96, 0xd6,
+       0x83, 0xc3, 0x93, 0xd3, 0x87, 0xc7, 0x97, 0xd7,
+       0x22, 0x62, 0x32, 0x72, 0x26, 0x66, 0x36, 0x76,
+       0x23, 0x63, 0x33, 0x73, 0x27, 0x67, 0x37, 0x77,
+       0xa2, 0xe2, 0xb2, 0xf2, 0xa6, 0xe6, 0xb6, 0xf6,
+       0xa3, 0xe3, 0xb3, 0xf3, 0xa7, 0xe7, 0xb7, 0xf7,
+       0x0a, 0x4a, 0x1a, 0x5a, 0x0e, 0x4e, 0x1e, 0x5e,
+       0x0b, 0x4b, 0x1b, 0x5b, 0x0f, 0x4f, 0x1f, 0x5f,
+       0x8a, 0xca, 0x9a, 0xda, 0x8e, 0xce, 0x9e, 0xde,
+       0x8b, 0xcb, 0x9b, 0xdb, 0x8f, 0xcf, 0x9f, 0xdf,
+       0x2a, 0x6a, 0x3a, 0x7a, 0x2e, 0x6e, 0x3e, 0x7e,
+       0x2b, 0x6b, 0x3b, 0x7b, 0x2f, 0x6f, 0x3f, 0x7f,
+       0xaa, 0xea, 0xba, 0xfa, 0xae, 0xee, 0xbe, 0xfe,
+       0xab, 0xeb, 0xbb, 0xfb, 0xaf, 0xef, 0xbf, 0xff,
+};
+
+#define PXMAP_INFO_SIZE        (NBPG)
+#define PXMAP_RBUF_SIZE        (4096 * 16 + 8192 * 2)
+
+/* Need alignment to 8kB here... */
+static u_char  px_cons_rbuf[PXMAP_INFO_SIZE + PXMAP_RBUF_SIZE + 8192];
+static u_int   px_cons_rbuf_use;
+struct px_info *px_cons_info;
+struct px_info *px_unit[NPX];
+
+/* bt459 gunk. XXX should be done with driver independant interface */
+struct bt459_regs {
+        volatile int32_t lo;
+        volatile int32_t hi;
+        volatile int32_t reg;
+        volatile int32_t cmap;
+};
+
+#define        BT459_SELECT(vdac, regno) do {          \
+       (vdac)->lo = (regno) & 0x00ff;          \
+       (vdac)->hi = ((regno) & 0x0f00) >> 8;   \
+       tc_wmb();                               \
+   } while(0);
+
+#define        BT459_WRITE_REG(vdac, data) \
+       (vdac)->reg = (data) & 0xffffff, tc_wmb();
+
+#define        BT459_WRITE_CMAP(vdac, data) \
+       (vdac)->cmap = (data) & 0xffffff, tc_wmb();
+
+#define BT459_READ_REG(vdac)   ((vdac)->reg)
+
+/* We have to support 3 VDACs on the 24-bit cards */
+#define DUPBYTE0(x) ((((x)&0xff)<<16) | (((x)&0xff)<<8) | ((x)&0xff))
+#define DUPBYTE1(x) ((((x)<<8)&0xff00) | ((x)&0xff00) | (((x)>>8)&0xff))
+#define DUPBYTE2(x) (((x)&0xff0000) | (((x)>>8)&0xff00) | (((x)>>16)&0xff))
+
+#define PACK_WORD(p, o) ((p)[(o)] | ((p)[(o)+1] << 16))
+
+/*
+ * Match a supported board.
+ */
+int
+px_match(parent, match, aux)
+       struct  device *parent;
+       struct  cfdata *match;
+       void    *aux;
+{
+       struct tc_attach_args *ta = (struct tc_attach_args *)aux;
+       int i;
+       
+       for (i = 0; i < NUM_PX_TYPES; i++)
+               if (!strncmp(px_types[i], ta->ta_modname, TC_ROM_LLEN))
+                       break;
+                       
+       return (px_types[i] != NULL);
+}
+
+
+/*
+ * Attach the graphics board.
+ */
+void
+px_attach(parent, self, aux)
+       struct device *parent, *self;
+       void *aux;
+{



Home | Main Index | Thread Index | Old Index