Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/dreamcast/dev New PowerVR display driver, based on ...
details: https://anonhg.NetBSD.org/src/rev/bb02287856b6
branches: trunk
changeset: 503127:bb02287856b6
user: thorpej <thorpej%NetBSD.org@localhost>
date: Thu Feb 01 01:25:56 2001 +0000
description:
New PowerVR display driver, based on the TURBOchannel "cfb"
driver by Tohru Nisimura (a very good framework for a FB driver,
BTW!), using bits of Marcus's original driver for the hardware
access.
The main advantage of this version is that is uses rasops (which
is faster than the rcons stuff) and wsfont, so you can select the
console font in the kernel config file. Using the BOLD8x16 font,
you get an 80x30 console (vast improvement compared to the Gallant12x22
font).
diffstat:
sys/arch/dreamcast/dev/pvr.c | 565 +++++++++++++++++++++++----------------
sys/arch/dreamcast/dev/pvrvar.h | 14 +-
2 files changed, 338 insertions(+), 241 deletions(-)
diffs (truncated from 703 to 300 lines):
diff -r 3ddf212ec72a -r bb02287856b6 sys/arch/dreamcast/dev/pvr.c
--- a/sys/arch/dreamcast/dev/pvr.c Thu Feb 01 01:09:12 2001 +0000
+++ b/sys/arch/dreamcast/dev/pvr.c Thu Feb 01 01:25:56 2001 +0000
@@ -1,7 +1,8 @@
-/* $NetBSD: pvr.c,v 1.3 2001/01/21 22:46:22 marcus Exp $ */
+/* $NetBSD: pvr.c,v 1.4 2001/02/01 01:25:56 thorpej Exp $ */
/*-
- * Copyright (c) 2001 Marcus Comstedt
+ * Copyright (c) 2001 Marcus Comstedt.
+ * Copyright (c) 2001 Jason R. Thorpe.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,65 +33,104 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+/*
+ * Copyright (c) 1998, 1999 Tohru Nishimura. 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 Tohru Nishimura
+ * for the NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * 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.
+ */
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
+__KERNEL_RCSID(0, "$NetBSD: pvr.c,v 1.4 2001/02/01 01:25:56 thorpej Exp $");
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
-#include <sys/malloc.h>
-#include <sys/conf.h>
+#include <sys/malloc.h>
+#include <sys/buf.h>
+#include <sys/ioctl.h>
#include <machine/cpu.h>
#include <machine/bus.h>
-#include <dev/cons.h>
+#include <dev/cons.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsdisplayvar.h>
+
+#include <dev/wscons/wscons_callbacks.h>
+
+#include <dev/rasops/rasops.h>
+#include <dev/wsfont/wsfont.h>
#include <dreamcast/dev/pvrvar.h>
#include <dreamcast/dev/maple/mkbdvar.h>
-#include <dev/wscons/wsconsio.h>
-
-#include <dev/rcons/raster.h>
-#include <dev/wscons/wscons_raster.h>
-#include <dev/wscons/wsdisplayvar.h>
-#include <dev/wscons/wsconsio.h>
-#include <dev/wscons/wscons_callbacks.h>
#include <sh3/shbvar.h>
-#include "wsdisplay.h"
#include "mkbd.h"
-#if NWSDISPLAY > 0
-cdev_decl(wsdisplay);
-#endif
+struct fb_devconfig {
+ vaddr_t dc_vaddr; /* framebuffer virtual address */
+ vaddr_t dc_paddr; /* framebuffer physical address */
+ int dc_wid; /* width of frame buffer */
+ int dc_ht; /* height of frame buffer */
+ int dc_depth; /* depth, bits per pixel */
+ int dc_rowbytes; /* bytes in a FB scan line */
+ vaddr_t dc_videobase; /* base of flat frame buffer */
+ int dc_blanked; /* currently has video disabled */
-int pvr_match __P((struct device *, struct cfdata *, void *));
-void pvr_attach __P((struct device *, struct device *, void *));
-
-struct cfattach pvr_ca = {
- sizeof(struct pvr_softc),
- pvr_match,
- pvr_attach,
+ struct rasops_info rinfo;
};
-
-const struct wsdisplay_emulops pvr_emulops = {
- rcons_cursor,
- rcons_mapchar,
- rcons_putchar,
- rcons_copycols,
- rcons_erasecols,
- rcons_copyrows,
- rcons_eraserows,
- rcons_alloc_attr
+struct pvr_softc {
+ struct device sc_dev;
+ struct fb_devconfig *sc_dc; /* device configuration */
+ int nscreens;
};
-const struct wsscreen_descr pvr_stdscreen = {
- "52x20", 52, 20,
- &pvr_emulops,
- 12, 24,
+int pvr_match(struct device *, struct cfdata *, void *);
+void pvr_attach(struct device *, struct device *, void *);
+
+struct cfattach pvr_ca = {
+ sizeof(struct pvr_softc), pvr_match, pvr_attach,
+};
+
+void pvr_getdevconfig(struct fb_devconfig *);
+
+struct fb_devconfig pvr_console_dc;
+
+char pvr_stdscreen_textgeom[32] = { "std" }; /* XXX yuck */
+
+struct wsscreen_descr pvr_stdscreen = {
+ pvr_stdscreen_textgeom, 0, 0,
+ 0, /* textops */
+ 0, 0,
WSSCREEN_WSCOLORS,
};
@@ -99,255 +139,321 @@
};
const struct wsscreen_list pvr_screenlist = {
- sizeof(_pvr_scrlist) / sizeof(struct wsscreen_descr *),
- _pvr_scrlist
+ sizeof(_pvr_scrlist) / sizeof(struct wsscreen_descr *), _pvr_scrlist
};
-static int pvr_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
-static paddr_t pvr_mmap __P((void *, off_t, int));
-static int pvr_alloc_screen __P((void *, const struct wsscreen_descr *,
- void **, int *, int *, long *));
-static void pvr_free_screen __P((void *, void *));
-static int pvr_show_screen __P((void *, void *, int,
- void (*)(void *, int, int), void *));
+int pvrioctl(void *, u_long, caddr_t, int, struct proc *);
+paddr_t pvrmmap(void *, off_t, int);
-static void pvr_check_cable __P((int *, int *));
-static void pvr_init_dpy_hardware __P((void));
-
+int pvr_alloc_screen(void *, const struct wsscreen_descr *,
+ void **, int *, int *, long *);
+void pvr_free_screen(void *, void *);
+int pvr_show_screen(void *, void *, int,
+ void (*)(void *, int, int), void *);
const struct wsdisplay_accessops pvr_accessops = {
- pvr_ioctl,
- pvr_mmap,
+ pvrioctl,
+ pvrmmap,
pvr_alloc_screen,
pvr_free_screen,
pvr_show_screen,
- 0 /* load_font */
+ NULL, /* load_font */
};
+void pvrinit(struct fb_devconfig *);
+
+int pvr_is_console;
+
+int
+pvr_match(struct device *parent, struct cfdata *match, void *aux)
+{
+ struct shb_attach_args *sa = aux;
+
+ if (strcmp("pvr", match->cf_driver->cd_name) != 0)
+ return (0);
+
+ sa->ia_iosize = 0; /* 0x1400 */;
+ return (1);
+}
+
+void
+pvr_getdevconfig(struct fb_devconfig *dc)
+{
+ int i, cookie;
+
+ dc->dc_paddr = 0x05000000;
+ dc->dc_vaddr = SH3_PHYS_TO_P2SEG(dc->dc_paddr);
+
+ dc->dc_wid = 640;
+ dc->dc_ht = 480;
+ dc->dc_depth = 16;
+ dc->dc_rowbytes = dc->dc_wid * (dc->dc_depth / 8);
+ dc->dc_videobase = dc->dc_vaddr;
+ dc->dc_blanked = 0;
+
+ /* Clear the screen. */
+ for (i = 0; i < dc->dc_ht * dc->dc_rowbytes; i += sizeof(u_int32_t))
+ *(u_int32_t *)(dc->dc_videobase + i) = 0x0;
+
+ /* Initialize the device. */
+ pvrinit(dc);
+
+ dc->rinfo.ri_flg = 0;
+ dc->rinfo.ri_depth = dc->dc_depth;
+ dc->rinfo.ri_bits = (void *) dc->dc_videobase;
+ dc->rinfo.ri_width = dc->dc_wid;
+ dc->rinfo.ri_height = dc->dc_ht;
+ dc->rinfo.ri_stride = dc->dc_rowbytes;
+
+ wsfont_init();
+ /* prefer 8 pixel wide font */
+ if ((cookie = wsfont_find(NULL, 8, 0, 0)) <= 0)
+ cookie = wsfont_find(NULL, 0, 0, 0);
+ if (cookie <= 0) {
+ printf("pvr: font table is empty\n");
+ return;
+ }
+
+ if (wsfont_lock(cookie, &dc->rinfo.ri_font,
+ WSDISPLAY_FONTORDER_L2R, WSDISPLAY_FONTORDER_L2R) <= 0) {
+ printf("pvr: unable to lock font\n");
+ return;
+ }
+ dc->rinfo.ri_wsfcookie = cookie;
+
+ rasops_init(&dc->rinfo, 500, 500);
+
+ /* XXX shouldn't be global */
+ pvr_stdscreen.nrows = dc->rinfo.ri_rows;
+ pvr_stdscreen.ncols = dc->rinfo.ri_cols;
+ pvr_stdscreen.textops = &dc->rinfo.ri_ops;
+ pvr_stdscreen.capabilities = dc->rinfo.ri_caps;
+
+ /* XXX yuck */
+ sprintf(pvr_stdscreen_textgeom, "%dx%d", pvr_stdscreen.ncols,
+ pvr_stdscreen.nrows);
+}
+
+void
+pvr_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct pvr_softc *sc = (void *) self;
+ struct wsemuldisplaydev_attach_args waa;
+ int console;
+
+ console = pvr_is_console;
+ if (console) {
+ sc->sc_dc = &pvr_console_dc;
+ sc->nscreens = 1;
+ } else {
+ sc->sc_dc = malloc(sizeof(struct fb_devconfig), M_DEVBUF,
+ M_WAITOK);
+ pvr_getdevconfig(sc->sc_dc);
+ }
+ printf(": %d x %d, %dbpp\n", sc->sc_dc->dc_wid, sc->sc_dc->dc_ht,
+ sc->sc_dc->dc_depth);
+
+ /* XXX Colormap initialization? */
+
+ waa.console = console;
+ waa.scrdata = &pvr_screenlist;
+ waa.accessops = &pvr_accessops;
+ waa.accesscookie = sc;
+
+ (void) config_found(self, &waa, wsemuldisplaydevprint);
+}
+
+int
+pvrioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
+{
Home |
Main Index |
Thread Index |
Old Index