Map the ffb's DAC register space and add support for video "blanking"

(aka WSDISPLAYIO_{S,G}VIDEO).
This commit is contained in:
heas 2004-05-21 21:45:04 +00:00
parent 4f01003841
commit a60b59cc89
4 changed files with 80 additions and 14 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffb.c,v 1.6 2004/05/21 19:21:31 heas Exp $ */
/* $NetBSD: ffb.c,v 1.7 2004/05/21 21:45:04 heas Exp $ */
/* $OpenBSD: creator.c,v 1.20 2002/07/30 19:48:15 jason Exp $ */
/*
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffb.c,v 1.6 2004/05/21 19:21:31 heas Exp $");
__KERNEL_RCSID(0, "$NetBSD: ffb.c,v 1.7 2004/05/21 21:45:04 heas Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -75,6 +75,7 @@ struct wsscreen_list ffb_screenlist = {
int ffb_ioctl(void *, u_long, caddr_t, int, struct proc *);
int ffb_alloc_screen(void *, const struct wsscreen_descr *, void **,
int *, int *, long *);
static int ffb_blank(struct ffb_softc *, u_long, u_int *);
void ffb_free_screen(void *, void *);
int ffb_show_screen(void *, void *, int, void (*cb)(void *, int, int),
void *);
@ -108,6 +109,7 @@ ffb_attach(struct ffb_softc *sc)
char *model;
int btype;
int maxrow, maxcol;
u_int blank = WSDISPLAYIO_VIDEO_ON;
char buf[6+1];
printf(":");
@ -164,6 +166,8 @@ ffb_attach(struct ffb_softc *sc)
ffb_stdscreen.ncols = sc->sc_rasops.ri_cols;
ffb_stdscreen.textops = &sc->sc_rasops.ri_ops;
ffb_blank(sc, WSDISPLAYIO_SVIDEO, &blank);
if (sc->sc_console) {
int *ccolp, *crowp;
long defattr;
@ -234,6 +238,8 @@ ffb_ioctl(v, cmd, data, flags, p)
case WSDISPLAYIO_SVIDEO:
case WSDISPLAYIO_GVIDEO:
return(ffb_blank(sc, cmd, (u_int *)data));
break;
case WSDISPLAYIO_GCURPOS:
case WSDISPLAYIO_SCURPOS:
case WSDISPLAYIO_GCURMAX:
@ -269,6 +275,38 @@ ffb_alloc_screen(v, type, cookiep, curxp, curyp, attrp)
return (0);
}
/* blank/unblank the screen */
static int
ffb_blank(struct ffb_softc *sc, u_long cmd, u_int *data)
{
u_int val;
DAC_WRITE(sc, FFB_DAC_TYPE, FFB_DAC_GSBLANK);
val = DAC_READ(sc, FFB_DAC_VALUE);
switch (cmd) {
case WSDISPLAYIO_GVIDEO:
*data = val & 1;
return(0);
break;
case WSDISPLAYIO_SVIDEO:
if (*data == WSDISPLAYIO_VIDEO_OFF)
val &= ~1;
else if (*data == WSDISPLAYIO_VIDEO_ON)
val |= 1;
else
return(EINVAL);
break;
default:
return(EINVAL);
}
DAC_WRITE(sc, FFB_DAC_TYPE, FFB_DAC_GSBLANK);
DAC_WRITE(sc, FFB_DAC_VALUE, val);
return(0);
}
void
ffb_free_screen(v, cookie)
void *v;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffb_mainbus.c,v 1.3 2004/03/19 21:10:31 petrov Exp $ */
/* $NetBSD: ffb_mainbus.c,v 1.4 2004/05/21 21:45:04 heas Exp $ */
/* $OpenBSD: creator_mainbus.c,v 1.4 2002/07/26 16:39:04 jason Exp $ */
/*
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ffb_mainbus.c,v 1.3 2004/03/19 21:10:31 petrov Exp $");
__KERNEL_RCSID(0, "$NetBSD: ffb_mainbus.c,v 1.4 2004/05/21 21:45:04 heas Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -104,7 +104,14 @@ ffb_mainbus_attach(parent, self, aux)
if (bus_space_map(sc->sc_bt, ma->ma_reg[FFB_REG_FBC].ur_paddr,
ma->ma_reg[FFB_REG_FBC].ur_len, 0, &sc->sc_fbc_h)) {
printf(": failed to map fbc\n");
goto fail;
goto unmap_dfb24;
}
if (bus_space_map(sc->sc_bt, ma->ma_reg[FFB_REG_DAC].ur_paddr,
ma->ma_reg[FFB_REG_DAC].ur_len, BUS_SPACE_MAP_LINEAR,
&sc->sc_dac_h)) {
printf(": failed to map dac\n");
goto unmap_fbc;
}
for (i = 0; i < nregs; i++) {
@ -123,14 +130,16 @@ ffb_mainbus_attach(parent, self, aux)
return;
fail:
#if 0
if (sc->sc_fbc_h != 0)
bus_space_unmap(sc->sc_bt, sc->sc_fbc_h,
ma->ma_reg[FFB_REG_FBC].ur_len);
#if notyet
unmap_dac:
bus_space_unmap(sc->sc_bt, sc->sc_dac_h,
ma->ma_reg[FFB_REG_DAC].ur_len);
#endif
/* if (sc->sc_pixel_h != 0) */
bus_space_unmap(sc->sc_bt, sc->sc_pixel_h,
unmap_fbc:
bus_space_unmap(sc->sc_bt, sc->sc_fbc_h,
ma->ma_reg[FFB_REG_FBC].ur_len);
unmap_dfb24:
bus_space_unmap(sc->sc_bt, sc->sc_pixel_h,
ma->ma_reg[FFB_REG_DFB24].ur_len);
fail1:
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffbreg.h,v 1.2 2004/05/20 01:50:43 heas Exp $ */
/* $NetBSD: ffbreg.h,v 1.3 2004/05/21 21:45:04 heas Exp $ */
/* $OpenBSD: creatorreg.h,v 1.5 2002/07/29 06:21:45 jason Exp $ */
/*
@ -58,6 +58,20 @@
#define FFB_DAC_TYPE2 0x8
#define FFB_DAC_VALUE2 0xc
/* DAC "TYPE" commands */
#define FFB_DAC_SCMAP 0x2000 /* set (load) cmap */
#define FFB_DAC_GSBLANK 0x6000 /* get/set blanking */
#define FFB_DAC_GVERS 0x8000 /* get DAC version */
#define FFB_DAC_BLANK_OFF 0x1
#define FFB_DAC_BLANK_HSYNC_DISABLE 0x4
#define FFB_DAC_BLANK_VSYNC_DISABLE 0x8
/* DAC "TYPE2" commands */
#define FFB_DAC_CURSENAB 0x100 /* cursor enable */
#define FFB_DAC_CURSECMAP 0x102 /* set cursor colormap */
#define FFB_DAC_CURSEPOS 0x104 /* set cursor position */
#define FFB_FBC_ALPHA 0x00c
#define FFB_FBC_RED 0x010
#define FFB_FBC_GREEN 0x014

View File

@ -1,4 +1,4 @@
/* $NetBSD: ffbvar.h,v 1.1 2003/05/23 06:51:16 petrov Exp $ */
/* $NetBSD: ffbvar.h,v 1.2 2004/05/21 21:45:04 heas Exp $ */
/* $OpenBSD: creatorvar.h,v 1.6 2002/07/30 19:48:15 jason Exp $ */
/*
@ -42,6 +42,7 @@ struct ffb_softc {
struct device sc_dv;
bus_space_tag_t sc_bt;
bus_space_handle_t sc_pixel_h;
bus_space_handle_t sc_dac_h;
bus_space_handle_t sc_fbc_h;
bus_addr_t sc_addrs[FFB_NREGS];
bus_size_t sc_sizes[FFB_NREGS];
@ -55,6 +56,10 @@ struct ffb_softc {
int32_t sc_fifo_cache, sc_fg_cache;
};
#define DAC_WRITE(sc,r,v) \
bus_space_write_4((sc)->sc_bt, (sc)->sc_dac_h, (r), (v))
#define DAC_READ(sc,r) \
bus_space_read_4((sc)->sc_bt, (sc)->sc_dac_h, (r))
#define FBC_WRITE(sc,r,v) \
bus_space_write_4((sc)->sc_bt, (sc)->sc_fbc_h, (r), (v))
#define FBC_READ(sc,r) \