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

This commit is contained in:
takemura 2000-03-12 05:04:44 +00:00
parent 9f8cac1f16
commit e9619d5d21
9 changed files with 1111 additions and 20 deletions

View File

@ -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 @@ vrdsu* at vrip? addr 0x0b0000e0 size 0x08
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

View File

@ -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 @@ device fb: wsemuldisplaydev, rasops1, rasops2, rasops8, rasops15, rasops16
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
#

View File

@ -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;
fb->hf_class_data_length = sizeof(struct hf_rgb_tag);
fb->hf_u.hf_rgb.hf_flags = 0; /* reserved for future use */
fb->hf_u.hf_rgb.hf_red_width = 5;
fb->hf_u.hf_rgb.hf_red_shift = 11;
fb->hf_u.hf_rgb.hf_green_width = 6;
fb->hf_u.hf_rgb.hf_green_shift = 5;
fb->hf_u.hf_rgb.hf_blue_width = 5;
fb->hf_u.hf_rgb.hf_blue_shift = 0;
fb->hf_u.hf_rgb.hf_alpha_width = 0;
fb->hf_u.hf_rgb.hf_alpha_shift = 0;
break;
default:
printf("unknown type (=%d).\n", bootinfo->fb_type);
return (-1);
break;
}
return (0); /* no error */
}
int
bivideo_ioctl(v, cmd, data, flag, p)
void *v;
u_long cmd;
caddr_t data;
int flag;
struct proc *p;
{
struct bivideo_softc *sc = (struct bivideo_softc *)v;
struct hpcfb_fbconf *fbconf;
struct hpcfb_dspconf *dspconf;
switch (cmd) {
case HPCFBIO_GCONF:
fbconf = (struct hpcfb_fbconf *)data;
if (fbconf->hf_conf_index != 0 &&
fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
return (EINVAL);
}
*fbconf = sc->sc_fbconf; /* structure assignment */
return (0);
case HPCFBIO_SCONF:
fbconf = (struct hpcfb_fbconf *)data;
if (fbconf->hf_conf_index != 0 &&
fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) {
return (EINVAL);
}
/*
* nothing to do because we have only one configration
*/
return (0);
case HPCFBIO_GDSPCONF:
dspconf = (struct hpcfb_dspconf *)data;
if ((dspconf->hd_unit_index != 0 &&
dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
(dspconf->hd_conf_index != 0 &&
dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
return (EINVAL);
}
*dspconf = sc->sc_dspconf; /* structure assignment */
return (0);
case HPCFBIO_SDSPCONF:
dspconf = (struct hpcfb_dspconf *)data;
if ((dspconf->hd_unit_index != 0 &&
dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) ||
(dspconf->hd_conf_index != 0 &&
dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) {
return (EINVAL);
}
/*
* nothing to do
* because we have only one unit and one configration
*/
return (0);
case HPCFBIO_GOP:
case HPCFBIO_SOP:
/*
* curently not implemented...
*/
return (EINVAL);
}
return (ENOTTY);
}
int
bivideo_mmap(ctx, offset, prot)
void *ctx;
off_t offset;
int prot;
{
struct bivideo_softc *sc = (struct bivideo_softc *)ctx;
if (offset < 0 ||
(sc->sc_fbconf.hf_bytes_per_plane +
sc->sc_fbconf.hf_offset) < offset)
return -1;
return mips_btop(sc->sc_fbconf.hf_baseaddr + offset);
}

View File

@ -0,0 +1 @@
int bivideo_getcnfb __P((struct hpcfb_fbconf* fb));

View File

@ -0,0 +1,437 @@
/* $NetBSD: hpcfb.c,v 1.1 2000/03/12 05:04:46 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: hpcfb.c,v 1.1 2000/03/12 05:04:46 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 <dev/wscons/wsconsio.h>
#include <dev/wscons/wsdisplayvar.h>
#include <dev/wsfont/wsfont.h>
#include <dev/rasops/rasops.h>
#include <arch/hpcmips/dev/hpcfbvar.h>
#include <arch/hpcmips/dev/hpcfbio.h>
#include "bivideo.h"
#if NBIVIDEO > 0
#include <arch/hpcmips/dev/bivideovar.h>
#endif
#ifdef FBDEBUG
int hpcfb_debug = 0;
#define DPRINTF(arg) if (hpcfb_debug) printf arg;
#else
#define DPRINTF(arg)
#endif
struct hpcfb_devconfig {
struct rasops_info dc_rinfo; /* rasops infomation */
int dc_blanked; /* currently had video disabled */
};
struct hpcfb_softc {
struct device sc_dev;
struct hpcfb_devconfig *sc_dc; /* device configuration */
const struct hpcfb_accessops *sc_accessops;
void *sc_accessctx;
int nscreens;
};
/*
* function prototypes
*/
int hpcfbmatch __P((struct device *, struct cfdata *, void *));
void hpcfbattach __P((struct device *, struct device *, void *));
int hpcfbprint __P((void *aux, const char *pnp));
int hpcfb_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
int hpcfb_mmap __P((void *, off_t, int));
static int hpcfb_init __P((struct hpcfb_fbconf *fbconf,
struct hpcfb_devconfig *dc));
static int hpcfb_alloc_screen __P((void *, const struct wsscreen_descr *,
void **, int *, int *, long *));
static void hpcfb_free_screen __P((void *, void *));
static int hpcfb_show_screen __P((void *, void *, int,
void (*) (void *, int, int), void *));
static int pow __P((int, int));
/*
* static variables
*/
struct cfattach hpcfb_ca = {
sizeof(struct hpcfb_softc), hpcfbmatch, hpcfbattach,
};
struct wsscreen_descr hpcfb_stdscreen = {
"std",
0, 0, /* will be filled in -- XXX shouldn't, it's global */
0,
0, 0,
WSSCREEN_REVERSE
};
const struct wsscreen_descr *_hpcfb_scrlist[] = {
&hpcfb_stdscreen,
/* XXX other formats, graphics screen? */
};
struct wsscreen_list hpcfb_screenlist = {
sizeof(_hpcfb_scrlist) / sizeof(struct wsscreen_descr *),
_hpcfb_scrlist
};
struct wsdisplay_accessops hpcfb_accessops = {
hpcfb_ioctl,
hpcfb_mmap,
hpcfb_alloc_screen,
hpcfb_free_screen,
hpcfb_show_screen,
0 /* load_font */
};
static int hpcfbconsole, hpcfb_console_type;
struct hpcfb_devconfig hpcfb_console_dc;
struct wsscreen_descr hpcfb_console_screen;
/*
* function bodies
*/
static int
pow(int x, int n)
{
int res = 1;
while (0 < n--) {
res *= x;
}
return (res);
}
int
hpcfbmatch(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
{
#if 0
struct hpcfb_attach_args *fap = aux;
#endif
return (1);
}
void
hpcfbattach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct hpcfb_softc *sc = (struct hpcfb_softc *)self;
struct hpcfb_attach_args *ha = aux;
struct wsemuldisplaydev_attach_args wa;
sc->sc_accessops = ha->ha_accessops;
sc->sc_accessctx = ha->ha_accessctx;
if (hpcfbconsole) {
sc->sc_dc = &hpcfb_console_dc;
sc->nscreens = 1;
} else {
sc->sc_dc = (struct hpcfb_devconfig *)
malloc(sizeof(struct hpcfb_devconfig), M_DEVBUF, M_WAITOK);
bzero(sc->sc_dc, sizeof(struct hpcfb_devconfig));
if (hpcfb_init(&ha->ha_fbconflist[0], sc->sc_dc) != 0) {
return;
}
}
hpcfb_stdscreen.textops = &sc->sc_dc->dc_rinfo.ri_ops;
hpcfb_stdscreen.nrows = sc->sc_dc->dc_rinfo.ri_rows;
hpcfb_stdscreen.ncols = sc->sc_dc->dc_rinfo.ri_cols;
hpcfb_stdscreen.capabilities = sc->sc_dc->dc_rinfo.ri_caps;
printf(": rasops %dx%d pixels, %d colors, %dx%d chars",
sc->sc_dc->dc_rinfo.ri_width,
sc->sc_dc->dc_rinfo.ri_height,
pow(2, sc->sc_dc->dc_rinfo.ri_depth),
sc->sc_dc->dc_rinfo.ri_cols,
sc->sc_dc->dc_rinfo.ri_rows);
printf("\n");
wa.console = hpcfbconsole;
wa.scrdata = &hpcfb_screenlist;
wa.accessops = &hpcfb_accessops;
wa.accesscookie = sc;
config_found(self, &wa, wsemuldisplaydevprint);
}
/* Print function (for parent devices). */
int
hpcfbprint(aux, pnp)
void *aux;
const char *pnp;
{
#if 0
struct hpchpcfb_attach_args *fap = aux;
#endif
if (pnp)
printf("hpcfb at %s", pnp);
return (UNCONF);
}
int
hpcfb_cnattach(iot, iobase, type, check)
bus_space_tag_t iot;
int iobase;
int type, check;
{
long defattr;
int found;
struct hpcfb_fbconf fbconf;
found = 0;
bzero(&fbconf, sizeof(struct hpcfb_fbconf));
#if NBIVIDEO > 0
if (!found) found = (bivideo_getcnfb(&fbconf) == 0);
#endif
bzero(&hpcfb_console_dc, sizeof(struct hpcfb_devconfig));
if (!found || hpcfb_init(&fbconf, &hpcfb_console_dc) != 0) {
return (ENXIO);
}
hpcfb_console_screen = hpcfb_stdscreen;
hpcfb_console_screen.textops = &hpcfb_console_dc.dc_rinfo.ri_ops;
hpcfb_console_screen.nrows = hpcfb_console_dc.dc_rinfo.ri_rows;
hpcfb_console_screen.ncols = hpcfb_console_dc.dc_rinfo.ri_cols;
hpcfb_console_screen.capabilities = hpcfb_console_dc.dc_rinfo.ri_caps;
hpcfb_console_dc.dc_rinfo.ri_ops.alloc_attr(&hpcfb_console_dc.dc_rinfo,
7, 0, 0, &defattr);
wsdisplay_cnattach(&hpcfb_console_screen, &hpcfb_console_dc.dc_rinfo,
0, 0, defattr);
hpcfbconsole = 1;
hpcfb_console_type = type;
return (0);
}
int
hpcfb_init(fbconf, dc)
struct hpcfb_fbconf *fbconf;
struct hpcfb_devconfig *dc;
{
int i;
int32_t fg, bg;
struct rasops_info *ri;
vaddr_t fbaddr;
fbaddr = (vaddr_t)fbconf->hf_baseaddr + fbconf->hf_offset;
/*
* Set forground and background so that the screen
* looks black on white.
* Normally, black = 00 and white = ff.
* HPCFB_ACCESS_REVERSE means black = ff and white = 00.
*/
if (fbconf->hf_access_flags & HPCFB_ACCESS_REVERSE) {
bg = 0;
fg = ~0;
} else {
bg = ~0;
fg = 0;
}
/* clear the screen */
for (i = 0;
i < fbconf->hf_height * fbconf->hf_bytes_per_line;
i += sizeof(u_int32_t)) {
*(u_int32_t *)(fbaddr + i) = bg;
}
ri = &dc->dc_rinfo;
bzero(ri, sizeof(struct rasops_info));
ri->ri_depth = fbconf->hf_pixel_width;
ri->ri_bits = (caddr_t)fbaddr;
ri->ri_width = fbconf->hf_width;
ri->ri_height = fbconf->hf_height;
ri->ri_stride = fbconf->hf_bytes_per_line;
ri->ri_flg = RI_FORCEMONO | RI_CURSOR;
if (rasops_init(ri, 200, 200)) {
panic("%s(%d): rasops_init() failed!", __FILE__, __LINE__);
}
/*
* setup color map
* overriding rasops.c: rasops_init_devcmap().
*/
ri->ri_devcmap[0] = bg;
for (i = 1; i < 16; i++) {
ri->ri_devcmap[i] = fg;
}
return (0);
}
int
hpcfb_ioctl(v, cmd, data, flag, p)
void *v;
u_long cmd;
caddr_t data;
int flag;
struct proc *p;
{
struct hpcfb_softc *sc = v;
struct hpcfb_devconfig *dc = sc->sc_dc;
struct wsdisplay_fbinfo *wdf;
switch (cmd) {
case WSKBDIO_BELL:
return (0);
break;
case WSDISPLAYIO_GTYPE:
*(u_int *)data = WSDISPLAY_TYPE_HPCFB;
return 0;
case WSDISPLAYIO_GINFO:
wdf = (void *)data;
wdf->height = dc->dc_rinfo.ri_height;
wdf->width = dc->dc_rinfo.ri_width;
wdf->depth = dc->dc_rinfo.ri_depth;
wdf->cmsize = 256; /* XXXX */
return 0;
case HPCFBIO_GCONF:
case HPCFBIO_SCONF:
case HPCFBIO_GDSPCONF:
case HPCFBIO_SDSPCONF:
case HPCFBIO_GOP:
case HPCFBIO_SOP:
return (*sc->sc_accessops->ioctl)(sc->sc_accessctx,
cmd, data, flag, p);
default:
if (IOCGROUP(cmd) != 't')
DPRINTF(("%s(%d): hpcfb_ioctl(%lx, %lx) grp=%c num=%ld\n",
__FILE__, __LINE__,
cmd, (u_long)data, (char)IOCGROUP(cmd), cmd&0xff));
break;
}
return (ENOTTY); /* Inappropriate ioctl for device */
}
int
hpcfb_mmap(v, offset, prot)
void *v;
off_t offset;
int prot;
{
struct hpcfb_softc *sc = v;
return (*sc->sc_accessops->mmap)(sc->sc_accessctx, offset, prot);
}
int
hpcfb_alloc_screen(v, type, cookiep, curxp, curyp, attrp)
void *v;
const struct wsscreen_descr *type;
void **cookiep;
int *curxp, *curyp;
long *attrp;
{
struct hpcfb_softc *sc = v;
DPRINTF(("%s(%d): hpcfb_alloc_screen()\n", __FILE__, __LINE__));
if (sc->nscreens > 0)
return (ENOMEM);
*curxp = 0;
*curyp = 0;
*cookiep = &sc->sc_dc->dc_rinfo;
sc->sc_dc->dc_rinfo.ri_ops.alloc_attr(&sc->sc_dc->dc_rinfo,
7, 0, 0, attrp);
sc->nscreens++;
return (0);
}
void
hpcfb_free_screen(v, cookie)
void *v;
void *cookie;
{
struct hpcfb_softc *sc = v;
if (sc->sc_dc == &hpcfb_console_dc)
panic("hpcfb_free_screen: console");
sc->nscreens--;
}
int
hpcfb_show_screen(v, cookie, waitok, cb, cbarg)
void *v;
void *cookie;
int waitok;
void (*cb) __P((void *, int, int));
void *cbarg;
{
DPRINTF(("%s(%d): hpcfb_show_screen()\n", __FILE__, __LINE__));
return (0);
}

View File

@ -0,0 +1,240 @@
/* $NetBSD: hpcfbio.h,v 1.1 2000/03/12 05:04:46 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.
*
*/
#ifndef H_HPCFBIO
#define H_HPCFBIO
#include <sys/types.h>
#include <sys/ioccom.h>
#define HPCFB_MAXNAMELEN 32
#define HPCFB_DEFAULT_CONFIG 0
#define HPCFB_CURRENT_CONFIG -1
#define HPCFB_DEFAULT_UNIT 0
#define HPCFB_CURRENT_UNIT -1
#define HPCFB_CLASS_UNKNOWN 0 /* unknown class */
#define HPCFB_CLASS_GRAYSCALE 1 /* gray scale (maybe monochrome)*/
#define HPCFB_CLASS_INDEXCOLOR 2 /* index color */
#define HPCFB_CLASS_RGBCOLOR 3 /* RGB color */
#define HPCFB_ACCESS_CACHEABLE (1<<0) /* cacheable */
#define HPCFB_ACCESS_BYTE (1<<1) /* permit 8 bit access */
#define HPCFB_ACCESS_WORD (1<<2) /* permit 16 bit access */
#define HPCFB_ACCESS_3BYTE (1<<3) /* permit 3 bytes access */
#define HPCFB_ACCESS_DWORD (1<<4) /* permit 32 bit access */
#define HPCFB_ACCESS_5BYTE (1<<5) /* permit 5 bytes access */
#define HPCFB_ACCESS_6BYTE (1<<6) /* permit 6 bytes access */
#define HPCFB_ACCESS_7BYTE (1<<7) /* permit 7 bytes access */
#define HPCFB_ACCESS_QWORD (1<<8) /* permit 64 bit access */
#define HPCFB_ACCESS_9BYTE (1<<9) /* permit 9 bytes access */
#define HPCFB_ACCESS_10BYTE (1<<10) /* permit 10 bytes access */
#define HPCFB_ACCESS_11BYTE (1<<11) /* permit 11 bytes access */
#define HPCFB_ACCESS_12BYTE (1<<12) /* permit 12 bytes access */
#define HPCFB_ACCESS_13BYTE (1<<13) /* permit 13 bytes access */
#define HPCFB_ACCESS_14BYTE (1<<14) /* permit 14 bytes access */
#define HPCFB_ACCESS_15BYTE (1<<15) /* permit 15 bytes access */
#define HPCFB_ACCESS_OWORD (1<<16) /* permit 128 bit access */
#define HPCFB_ACCESS_LSB_TO_MSB (1<<17) /* first pixel is at LSB side */
#define HPCFB_ACCESS_R_TO_L (1<<18) /* pixel order is right to left */
#define HPCFB_ACCESS_B_TO_T (1<<19) /* pixel order is bottom to top */
#define HPCFB_ACCESS_Y_TO_X (1<<20) /* pixel ordef is Y to X */
#define HPCFB_ACCESS_STATIC (1<<21) /* no translation table */
#define HPCFB_ACCESS_REVERSE (1<<22) /* value 0 means white */
#define HPCFB_ACCESS_PACK_BLANK (1<<23) /* pack has a blank at MSB */
#define HPCFB_ACCESS_PIXEL_BLANK (1<<24)/* pixel has a blank at MSB */
#define HPCFB_ACCESS_ALPHA_REVERSE (1<<25) /* alpha value 0 means thick */
#define HPCFB_SWAP_BYTE (1<<0)
#define HPCFB_SWAP_WORD (1<<1)
#define HPCFB_SWAP_DWORD (1<<2)
#define HPCFB_SWAP_QWORD (1<<3)
struct hpcfb_fbconf {
short hf_conf_index; /* configuration index */
short hf_nconfs; /* how many configurations */
short hf_class; /* HPCFB_CLASS_* */
char hf_name[HPCFB_MAXNAMELEN];
/* frame buffer name, null terminated*/
char hf_conf_name[HPCFB_MAXNAMELEN];
/* config name, null terminated */
short hf_height; /* how many lines */
short hf_width; /* how many pixels in a line */
u_long hf_baseaddr; /* frame buffer start address */
u_long hf_offset; /* frame buffer start offset */
short hf_bytes_per_line; /**/
short hf_nplanes; /**/
long hf_bytes_per_plane; /**/
short hf_pack_width; /* how many bits in a pack */
short hf_pixels_per_pack; /* how many pixels in a pack */
short hf_pixel_width; /* effective bits width */
u_long hf_access_flags; /* HPCFB_ACCESS_* */
u_long hf_swap_flags; /* HPCFB_SWAP_* */
u_long hf_accel_flags; /* this value is 0 */
u_long hf_reserved[3];
/*
* class dependend data
*/
short hf_class_data_length;
union {
char hf_place_holder[128];
struct hf_gray_tag {
u_long hf_flags; /* reserved for future use */
} hf_gray;
struct hf_indexed_tag {
u_long hf_flags; /* reserved for future use */
} hf_indexed;
struct hf_rgb_tag {
u_long hf_flags; /* reserved for future use */
short hf_red_width;
short hf_red_shift;
short hf_green_width;
short hf_green_shift;
short hf_blue_width;
short hf_blue_shift;
short hf_alpha_width;
short hf_alpha_shift;
} hf_rgb;
} hf_u;
/*
* extended data for future use
*/
int hf_ext_size; /* this value is 0 */
void *hf_ext_data; /* this value is NULL */
};
#define HPCFB_DSP_CLASS_UNKNOWN 0 /* unknown display type */
#define HPCFB_DSP_CLASS_COLORCRT 1 /* color CRT */
#define HPCFB_DSP_CLASS_COLORLCD 2 /* color LCD */
#define HPCFB_DSP_CLASS_GRAYCRT 3 /* gray or mono CRT */
#define HPCFB_DSP_CLASS_GRAYLCD 4 /* gray or mono LCD */
#define HPCFB_DSP_CLASS_EXTERNAL 5 /* external output */
#define HPCFB_DSP_CLASS_VIDEO 6 /* external video output*/
#define HPCFB_DSP_DPI_UNKNOWN 0
struct hpcfb_dspconf {
short hd_unit_index; /* display unit index */
short hd_nunits; /* how many display units */
short hd_class; /* HPCFB_DSP_CLASS_* */
char hd_name[HPCFB_MAXNAMELEN];
/* display name */
unsigned long hd_op_flags;
unsigned long hd_reserved[3];
short hd_conf_index; /* configuration index */
short hd_nconfs; /* how many configurations */
char hd_conf_name[HPCFB_MAXNAMELEN];
/* configuration name */
short hd_width;
short hd_height;
short hd_xdpi;
short hd_ydpi;
};
struct hpcfb_dsp_op {
short op;
long args[4];
short ext_size;
void *ext_arg;
};
/*
* view port postion
* arg0 is x_offset
* arg1 is y_offset
*/
#define HPCFB_DSP_OP_VIEW 0
/*
* display settings
* arg0 is bright;
* arg1 is contrast;
*/
#define HPCFB_DSP_OP_BRIGHT 1
/*
* power state
* arg0 is power state
*/
#define HPCFB_DSP_OP_POWER 2
#define HPCFB_DSP_PW_ON 0 /* full power */
#define HPCFB_DSP_PW_SAVE 10 /* power save mode, but not blank */
#define HPCFB_DSP_PW_CUT 20 /* power save mode, screen is blank */
#define HPCFB_DSP_PW_OFF 30 /* power off */
/*
* output signal settings
* ext_arg is struct hpcfb_dsp_signal
*/
#define HPCFB_DSP_OP_SIGNAL 3
#define HPCFB_DSP_SIG_H_SYNC_HIGH (1<<0)
#define HPCFB_DSP_SIG_V_SYNC_HIGH (1<<1)
#define HPCFB_DSP_SIG_C_SYNC_HIGH (1<<2)
#define HPCFB_DSP_SIG_SYNC_EXT (1<<3)
#define HPCFB_DSP_SIG_SYNC_GREEN (1<<4)
struct hpcfb_dsp_signal {
unsigned long flags;
long pixclock; /* pixel clock in pico seconds */
long left_margin; /* time from H sync to picture */
long right_margin; /* time from picture to H sync */
long upper_margin; /* time from V sync to picture */
long lower_margin; /* time from picture to V sync */
long hsync_len; /* length of H sync */
long vsync_len; /* length of V sync */
};
#define HPCFBIO_GCONF _IOWR('H', 0, struct hpcfb_fbconf)
#define HPCFBIO_SCONF _IOW('H', 1, struct hpcfb_fbconf)
#define HPCFBIO_GDSPCONF _IOWR('H', 2, struct hpcfb_dspconf)
#define HPCFBIO_SDSPCONF _IOW('H', 3, struct hpcfb_dspconf)
#define HPCFBIO_GOP _IOR('H', 4, struct hpcfb_dsp_op)
#define HPCFBIO_SOP _IOWR('H', 5, struct hpcfb_dsp_op)
#endif /* H_HPCFBIO */

View File

@ -0,0 +1,64 @@
/* $NetBSD: hpcfbvar.h,v 1.1 2000/03/12 05:04:46 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.
*
*/
/*
* video access functions (must be provided by all keyboards).
*/
struct hpcfb_accessops {
int (*ioctl) __P((void *v, u_long cmd, caddr_t data, int flag,
struct proc *p));
int (*mmap) __P((void *v, off_t off, int prot));
};
/*
* hpcfb attach arguments
*/
struct hpcfb_attach_args {
int ha_console;
const struct hpcfb_accessops *ha_accessops; /* access ops */
void *ha_accessctx; /* access cookie */
int ha_curfbconf;
int ha_nfbconf;
struct hpcfb_fbconf *ha_fbconflist;
int ha_curdspconf;
int ha_ndspconf;
struct hpcfb_dspconf *ha_dspconflist;
};
int hpcfb_cnattach __P((bus_space_tag_t iot, int iobase,
int type, int check));
int hpcfbprint __P((void *aux, const char *pnp));

View File

@ -1,4 +1,4 @@
/* $NetBSD: mainbus.c,v 1.2 1999/11/21 07:04:33 uch Exp $ */
/* $NetBSD: mainbus.c,v 1.3 2000/03/12 05:04:47 takemura Exp $ */
/*-
* Copyright (c) 1999
@ -114,7 +114,7 @@ mbattach(parent, self, aux)
#error misconfiguration
#elif defined VR41X1
/* Attach frame buffer */
ma.ma_name = "fb";
ma.ma_name = "bivideo";
config_found(mb, &ma, mbprint);
/* Attach Vr41x1 integrated peripherals (if configured). */

View File

@ -1,4 +1,4 @@
/* $NetBSD: vr.c,v 1.14 2000/02/25 11:20:20 shin Exp $ */
/* $NetBSD: vr.c,v 1.15 2000/03/12 05:04:47 takemura Exp $ */
/*-
* Copyright (c) 1999
@ -87,18 +87,18 @@
#endif
#endif
#include "fb.h"
#include "hpcfb.h"
#include "vrkiu.h"
#if NFB > 0 || NVRKIU > 0
#include <dev/rcons/raster.h>
#if NVRKIU > 0
#include <dev/wscons/wsdisplayvar.h>
#include <dev/rasops/rasops.h>
#endif
#if NFB > 0
#include <arch/hpcmips/dev/fbvar.h>
#if NHPCFB > 0
#include <arch/hpcmips/dev/hpcfbvar.h>
#endif
#if NFB > 0
#if NVRKIU > 0
#include <arch/hpcmips/vr/vrkiuvar.h>
#endif
@ -297,7 +297,7 @@ vr_bus_reset()
void
vr_cons_init()
{
#if NCOM > 0 || NFB > 0 || NVRKIU > 0
#if NCOM > 0 || NHPCFB > 0 || NVRKIU > 0
extern bus_space_tag_t system_bus_iot;
extern bus_space_tag_t mb_bus_space_init __P((void));
#endif
@ -316,9 +316,9 @@ vr_cons_init()
}
#endif
#if NFB > 0
#if NHPCFB > 0
mb_bus_space_init(); /* At this time, not initialized yet */
if(fb_cnattach(system_bus_iot, 0x0c000000, 0, 0)) {
if(hpcfb_cnattach(system_bus_iot, 0x0c000000, 0, 0)) {
printf("%s(%d): can't init fb console", __FILE__, __LINE__);
} else {
goto find_keyboard;