Initial commit for Xserver support for the wscons interface; it isn't fully
functional yet since the keyboard changes are not committed yet but it should compile and work independently. Initial support for mouse and screen takeovers / screen hardware scroll reset is done.
This commit is contained in:
parent
3f9cc29da9
commit
d7964c6e78
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vidc20config.c,v 1.5 2001/07/28 18:12:45 chris Exp $ */
|
||||
/* $NetBSD: vidc20config.c,v 1.6 2001/08/21 14:48:54 reinoud Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Reinoud Zandijk
|
||||
|
@ -193,9 +193,8 @@ char *cursor_normal;
|
|||
char *cursor_transparent;
|
||||
int p_cursor_normal;
|
||||
int p_cursor_transparent;
|
||||
|
||||
/* XXX static irqhandler_t cursor_ih; */
|
||||
irqhandler_t flash_ih;
|
||||
int cursor_width;
|
||||
int cursor_height;
|
||||
|
||||
|
||||
/*
|
||||
|
@ -467,6 +466,24 @@ void *vidcvideo_hwscroll(int bytes) {
|
|||
}
|
||||
|
||||
|
||||
/* reset the HW scroll to be at the start for the benefit of f.e. X */
|
||||
void *vidcvideo_hwscroll_reset(void) {
|
||||
void *cookie = (void *) dispstart;
|
||||
|
||||
dispstart = dispbase;
|
||||
dispend = dispstart + dispsize;
|
||||
return cookie;
|
||||
}
|
||||
|
||||
|
||||
/* put HW scroll back to where it was */
|
||||
void *vidcvideo_hwscroll_back(void *cookie) {
|
||||
dispstart = (int) cookie;
|
||||
dispend = dispstart + dispsize;
|
||||
return cookie;
|
||||
}
|
||||
|
||||
|
||||
/* this function is to be called at vsync */
|
||||
void vidcvideo_progr_scroll(void) {
|
||||
IOMD_WRITE_WORD(IOMD_VIDINIT, dispstart-ptov);
|
||||
|
@ -503,6 +520,9 @@ vidcvideo_setmode(struct vidc_mode *mode)
|
|||
int best_r, best_v, best_match;
|
||||
#endif
|
||||
|
||||
#ifdef NC
|
||||
return;
|
||||
#endif
|
||||
/*
|
||||
* Find out what bit mask we need to or with the vidc20 control register
|
||||
* in order to generate the desired number of bits per pixel.
|
||||
|
@ -678,6 +698,7 @@ vidcvideo_init(void)
|
|||
|
||||
/* setting a mode goes wrong in 32 bpp ... 8 and 16 seem OK */
|
||||
vidcvideo_setmode(vidc_currentmode);
|
||||
vidcvideo_blank(0); /* display on */
|
||||
|
||||
vidcvideo_textpalette();
|
||||
|
||||
|
@ -685,8 +706,9 @@ vidcvideo_init(void)
|
|||
vidcvideo_write(VIDC_CP1, 0x0);
|
||||
vidcvideo_write(VIDC_CP2, 0x0);
|
||||
vidcvideo_write(VIDC_CP3, 0x0);
|
||||
} else
|
||||
vidcvideo_cursor_init(8, 8); /* XXX HACK HACK XXX */
|
||||
} else {
|
||||
vidcvideo_cursor_init(CURSOR_MAX_WIDTH, CURSOR_MAX_HEIGHT);
|
||||
};
|
||||
|
||||
cold_init=1;
|
||||
return 0;
|
||||
|
@ -722,6 +744,9 @@ vidcvideo_cursor_init(int width, int height)
|
|||
int line;
|
||||
paddr_t pa;
|
||||
|
||||
cursor_width = width;
|
||||
cursor_height = height;
|
||||
|
||||
if (!cursor_data) {
|
||||
/* Allocate cursor memory first time round */
|
||||
cursor_data = (char *)uvm_km_zalloc(kernel_map, NBPG);
|
||||
|
@ -740,13 +765,13 @@ vidcvideo_cursor_init(int width, int height)
|
|||
cursor_normal = cursor_data;
|
||||
cursor_transparent = cursor_data + (height * width);
|
||||
|
||||
cursor_transparent += 32;
|
||||
cursor_transparent += 32; /* ALIGN */
|
||||
cursor_transparent = (char *)((int)cursor_transparent & (~31) );
|
||||
|
||||
for ( line = 0; line<height; ++ line )
|
||||
{
|
||||
for ( counter=0; counter<width/4;counter++ )
|
||||
cursor_normal[line * width + counter]=0x55;
|
||||
cursor_normal[line * width + counter]=0x55; /* why 0x55 ? */
|
||||
for ( ; counter<8; counter++ )
|
||||
cursor_normal[line * width + counter]=0;
|
||||
}
|
||||
|
@ -765,21 +790,45 @@ vidcvideo_cursor_init(int width, int height)
|
|||
(void) pmap_extract(pmap_kernel(), (vaddr_t)cursor_transparent,
|
||||
(paddr_t *)&p_cursor_transparent);
|
||||
|
||||
/*
|
||||
memset ( cursor_normal, 0x55,
|
||||
R_DATA->font->pixel_width*R_DATA->font->pixel_height );
|
||||
memset ( cursor_normal, 0x55, width*height ); /* white? */
|
||||
memset ( cursor_transparent, 0x00, width*height ); /* to see the diffence */
|
||||
|
||||
memset ( cursor_transparent, 0x55,
|
||||
R_DATA->font->pixel_width*R_DATA->font->pixel_height );
|
||||
*/
|
||||
/* Ok, now program the cursor; should be blank */
|
||||
vidcvideo_enablecursor(0);
|
||||
|
||||
/* Ok, now see the cursor */
|
||||
|
||||
vidcvideo_write ( VIDC_CP1, 0xffffff );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
vidcvideo_updatecursor(xcur, ycur)
|
||||
int xcur, ycur;
|
||||
{
|
||||
int frontporch = vidc_currentmode->hswr + vidc_currentmode->hbsr + vidc_currentmode->hdsr;
|
||||
int topporch = vidc_currentmode->vswr + vidc_currentmode->vbsr + vidc_currentmode->vdsr;
|
||||
|
||||
vidcvideo_write(VIDC_HCSR, frontporch -17 + xcur);
|
||||
vidcvideo_write(VIDC_VCSR, topporch -2 + (ycur+1)-2 + 3 - cursor_height);
|
||||
vidcvideo_write(VIDC_VCER, topporch -2 + (ycur+3)+2 + 3 );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
vidcvideo_enablecursor(on)
|
||||
int on;
|
||||
{
|
||||
if (on) {
|
||||
IOMD_WRITE_WORD(IOMD_CURSINIT,p_cursor_normal);
|
||||
} else {
|
||||
IOMD_WRITE_WORD(IOMD_CURSINIT,p_cursor_transparent);
|
||||
};
|
||||
vidcvideo_write ( VIDC_CP1, 0xffffff ); /* enable */
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
vidcvideo_textpalette()
|
||||
{
|
||||
|
@ -804,8 +853,8 @@ vidcvideo_textpalette()
|
|||
}
|
||||
|
||||
int
|
||||
vidcvideo_blank(video_on)
|
||||
int video_on;
|
||||
vidcvideo_blank(video_off)
|
||||
int video_off;
|
||||
{
|
||||
int ereg;
|
||||
|
||||
|
@ -815,7 +864,7 @@ vidcvideo_blank(video_on)
|
|||
if (vidc_currentmode->sync_pol & 0x02)
|
||||
ereg |= 1<<18;
|
||||
|
||||
if (video_on) {
|
||||
if (!video_off) {
|
||||
#ifdef RC7500
|
||||
vidcvideo_write(VIDC_EREG, 0x51<<12);
|
||||
#else
|
||||
|
@ -828,4 +877,3 @@ vidcvideo_blank(video_on)
|
|||
}
|
||||
|
||||
/* end of vidc20config.c */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vidc20config.h,v 1.2 2001/04/01 16:58:05 reinoud Exp $ */
|
||||
/* $NetBSD: vidc20config.h,v 1.3 2001/08/21 14:48:55 reinoud Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -45,21 +45,30 @@
|
|||
#ifndef _VIDC20CONFIG_H_
|
||||
#define _VIDC20CONFIG_H_
|
||||
|
||||
extern int vidcvideo_write __P((u_int reg, int value));
|
||||
extern int vidcvideo_cursor_init __P((int width, int heigth));
|
||||
extern void vidcvideo_setpalette __P((struct vidc_state *vidc));
|
||||
extern int vidcvideo_textpalette __P((void));
|
||||
extern void vidcvideo_stdpalette __P((void));
|
||||
extern void vidcvideo_setstate __P((struct vidc_state *vidc));
|
||||
extern void vidcvideo_getstate __P((struct vidc_state *vidc));
|
||||
extern void vidcvideo_getmode __P((struct vidc_mode *mode));
|
||||
extern void vidcvideo_setmode __P((struct vidc_mode *mode));
|
||||
extern int vidcvideo_init __P((void));
|
||||
extern void vidcvideo_reinit __P((void));
|
||||
extern void vidcvideo_printdetails __P((void));
|
||||
extern int vidcvideo_blank __P((int));
|
||||
extern void *vidcvideo_hwscroll __P((int));
|
||||
extern void vidcvideo_progr_scroll __P((void));
|
||||
extern int vidcvideo_write __P((u_int reg, int value));
|
||||
extern int vidcvideo_cursor_init __P((int width, int heigth));
|
||||
extern void vidcvideo_setpalette __P((struct vidc_state *vidc));
|
||||
extern int vidcvideo_textpalette __P((void));
|
||||
extern void vidcvideo_stdpalette __P((void));
|
||||
extern void vidcvideo_setstate __P((struct vidc_state *vidc));
|
||||
extern void vidcvideo_getstate __P((struct vidc_state *vidc));
|
||||
extern void vidcvideo_getmode __P((struct vidc_mode *mode));
|
||||
extern void vidcvideo_setmode __P((struct vidc_mode *mode));
|
||||
extern int vidcvideo_init __P((void));
|
||||
extern void vidcvideo_reinit __P((void));
|
||||
extern void vidcvideo_printdetails __P((void));
|
||||
extern int vidcvideo_blank __P((int));
|
||||
extern void *vidcvideo_hwscroll __P((int));
|
||||
extern void *vidcvideo_hwscroll_reset __P((void));
|
||||
extern void *vidcvideo_hwscroll_back __P((void *cookie));
|
||||
extern void vidcvideo_progr_scroll __P((void));
|
||||
extern void vidcvideo_updatecursor __P((int, int));
|
||||
extern void vidcvideo_enablecursor __P((int));
|
||||
|
||||
|
||||
#define CURSOR_MAX_WIDTH 32
|
||||
#define CURSOR_MAX_HEIGHT 32 /* for now */
|
||||
#define CURSOR_MAX_COLOURS 4 /* AFAIK */
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vidcvideo.c,v 1.8 2001/08/05 18:07:52 jdolecek Exp $ */
|
||||
/* $NetBSD: vidcvideo.c,v 1.9 2001/08/21 14:48:55 reinoud Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Reinoud Zandijk
|
||||
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: vidcvideo.c,v 1.8 2001/08/05 18:07:52 jdolecek Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vidcvideo.c,v 1.9 2001/08/21 14:48:55 reinoud Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -83,6 +83,7 @@ struct fb_devconfig {
|
|||
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 */
|
||||
void *dc_hwscroll_cookie; /* cookie for hardware scroll */
|
||||
|
||||
struct vidc_mode mode_info;
|
||||
struct rasops_info rinfo;
|
||||
|
@ -96,14 +97,16 @@ struct hwcmap256 {
|
|||
u_int8_t b[CMAP_SIZE];
|
||||
};
|
||||
|
||||
struct hwcursor64 {
|
||||
|
||||
/* XXX for CURSOR_MAX_WIDTH = 32 */
|
||||
struct hwcursor32 {
|
||||
struct wsdisplay_curpos cc_pos;
|
||||
struct wsdisplay_curpos cc_hot;
|
||||
struct wsdisplay_curpos cc_size;
|
||||
struct wsdisplay_curpos cc_magic;
|
||||
#define CURSOR_MAX_SIZE 64
|
||||
u_int8_t cc_color[6];
|
||||
u_int64_t cc_image[64 + 64];
|
||||
u_int8_t cc_color[6]; /* how many? */
|
||||
u_int32_t cc_image[(CURSOR_MAX_WIDTH/4) * CURSOR_MAX_HEIGHT];
|
||||
u_int32_t cc_mask[(CURSOR_MAX_WIDTH/4) * CURSOR_MAX_HEIGHT];
|
||||
};
|
||||
|
||||
|
||||
|
@ -111,7 +114,7 @@ struct vidcvideo_softc {
|
|||
struct device sc_dev;
|
||||
struct fb_devconfig *sc_dc; /* device configuration */
|
||||
struct hwcmap256 sc_cmap; /* software copy of colormap */
|
||||
struct hwcursor64 sc_cursor; /* software copy of cursor */
|
||||
struct hwcursor32 sc_cursor; /* software copy of cursor */
|
||||
int sc_curenb; /* cursor sprite enabled */
|
||||
int sc_changed; /* need update of hardware */
|
||||
#define WSDISPLAY_CMAP_DOLUT 0x20
|
||||
|
@ -324,6 +327,7 @@ vidcvideo_attach(parent, self, aux)
|
|||
const u_int8_t *p;
|
||||
int index;
|
||||
|
||||
vidcvideo_init();
|
||||
if (sc->nscreens == 0) {
|
||||
if (vidcvideo_is_console) {
|
||||
sc->sc_dc = &vidcvideo_console_dc;
|
||||
|
@ -411,12 +415,9 @@ vidcvideoioctl(v, cmd, data, flag, p)
|
|||
|
||||
case WSDISPLAYIO_SVIDEO:
|
||||
state = *(int *)data;
|
||||
if ((dc->dc_blanked != state)) {
|
||||
/* change */
|
||||
dc->dc_blanked = state;
|
||||
sc->sc_changed |= WSDISPLAY_VIDEO_ONOFF;
|
||||
/* done on video blank */
|
||||
};
|
||||
dc->dc_blanked = (state == WSDISPLAYIO_VIDEO_OFF);
|
||||
sc->sc_changed |= WSDISPLAY_VIDEO_ONOFF;
|
||||
/* done on video blank */
|
||||
return (0);
|
||||
|
||||
case WSDISPLAYIO_GVIDEO:
|
||||
|
@ -430,12 +431,12 @@ vidcvideoioctl(v, cmd, data, flag, p)
|
|||
|
||||
case WSDISPLAYIO_SCURPOS:
|
||||
set_curpos(sc, (struct wsdisplay_curpos *)data);
|
||||
sc->sc_changed = WSDISPLAY_CURSOR_DOPOS;
|
||||
sc->sc_changed |= WSDISPLAY_CURSOR_DOPOS;
|
||||
return (0);
|
||||
|
||||
case WSDISPLAYIO_GCURMAX:
|
||||
((struct wsdisplay_curpos *)data)->x =
|
||||
((struct wsdisplay_curpos *)data)->y = CURSOR_MAX_SIZE;
|
||||
((struct wsdisplay_curpos *)data)->x = CURSOR_MAX_WIDTH;
|
||||
((struct wsdisplay_curpos *)data)->y = CURSOR_MAX_HEIGHT;
|
||||
return (0);
|
||||
|
||||
case WSDISPLAYIO_GCURSOR:
|
||||
|
@ -444,17 +445,16 @@ vidcvideoioctl(v, cmd, data, flag, p)
|
|||
case WSDISPLAYIO_SCURSOR:
|
||||
return set_cursor(sc, (struct wsdisplay_cursor *)data);
|
||||
|
||||
#if 0
|
||||
/* XXX There are no way to know framebuffer pa from a user program. */
|
||||
/* XXX imported from macppc fb buffer for X support... dunno if this works yet */
|
||||
case GRFIOCGINFO:
|
||||
gm = (void *)data;
|
||||
bzero(gm, sizeof(struct grfinfo));
|
||||
gm->gd_fbaddr = (caddr_t)dc->dc_paddr;
|
||||
gm->gd_fbrowbytes = dc->dc_ri.ri_stride;
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
case WSDISPLAYIO_SMODE:
|
||||
state = *(int *)data;
|
||||
if (state == WSDISPLAYIO_MODE_MAPPED) {
|
||||
dc->dc_hwscroll_cookie = vidcvideo_hwscroll_reset();
|
||||
};
|
||||
if (state == WSDISPLAYIO_MODE_EMUL) {
|
||||
vidcvideo_hwscroll_back(dc->dc_hwscroll_cookie);
|
||||
};
|
||||
vidcvideo_progr_scroll();
|
||||
return (0);
|
||||
}
|
||||
return ENOTTY;
|
||||
}
|
||||
|
@ -585,6 +585,19 @@ vidcvideointr(arg)
|
|||
vidcvideo_blank(sc->sc_dc->dc_blanked);
|
||||
};
|
||||
|
||||
if (v & (WSDISPLAY_CURSOR_DOPOS | WSDISPLAY_CURSOR_DOHOT)) {
|
||||
int x, y;
|
||||
x = sc->sc_cursor.cc_pos.x - sc->sc_cursor.cc_hot.x;
|
||||
y = sc->sc_cursor.cc_pos.y - sc->sc_cursor.cc_hot.y;
|
||||
|
||||
vidcvideo_updatecursor(x, y);
|
||||
};
|
||||
|
||||
if (v & WSDISPLAY_CURSOR_DOCUR) {
|
||||
vidcvideo_enablecursor(sc->sc_curenb);
|
||||
};
|
||||
|
||||
|
||||
#if 0 /* XXX snip XXX */
|
||||
/* XXX kept here as an archive for now XXX */
|
||||
|
||||
|
@ -627,7 +640,7 @@ vidcvideointr(arg)
|
|||
int bcnt;
|
||||
|
||||
ip = (u_int8_t *)sc->sc_cursor.cc_image;
|
||||
mp = (u_int8_t *)(sc->sc_cursor.cc_image + CURSOR_MAX_SIZE);
|
||||
mp = (u_int8_t *)(sc->sc_cursor.cc_image + CURSOR_MAX_HEIGHT);
|
||||
|
||||
bcnt = 0;
|
||||
SELECT(vdac, BT459_IREG_CRAM_BASE+0);
|
||||
|
@ -650,7 +663,7 @@ vidcvideointr(arg)
|
|||
bcnt += 2;
|
||||
}
|
||||
/* pad unoccupied scan lines */
|
||||
while (bcnt < CURSOR_MAX_SIZE * 16) {
|
||||
while (bcnt < CURSOR_MAX_HEIGHT * 16) {
|
||||
REG(vdac, bt_reg) = 0; tc_wmb();
|
||||
REG(vdac, bt_reg) = 0; tc_wmb();
|
||||
bcnt += 2;
|
||||
|
@ -693,31 +706,6 @@ vidcvideo_colourmap_and_cursor_init(dc)
|
|||
ri->ri_gpos = rgbdat[4];
|
||||
ri->ri_bpos = rgbdat[5];
|
||||
|
||||
|
||||
#if 0 /* XXX snip XXX */
|
||||
/* clear out cursor image */
|
||||
SELECT(vdac, BT459_IREG_CRAM_BASE);
|
||||
for (i = 0; i < 1024; i++)
|
||||
REG(vdac, bt_reg) = 0xff; tc_wmb();
|
||||
|
||||
/*
|
||||
* 2 bit/pixel cursor. Assign MSB for cursor mask and LSB for
|
||||
* cursor image. CCOLOR_2 for mask color, while CCOLOR_3 for
|
||||
* image color. CCOLOR_1 will be never used.
|
||||
*/
|
||||
SELECT(vdac, BT459_IREG_CCOLOR_1);
|
||||
REG(vdac, bt_reg) = 0xff; tc_wmb();
|
||||
REG(vdac, bt_reg) = 0xff; tc_wmb();
|
||||
REG(vdac, bt_reg) = 0xff; tc_wmb();
|
||||
|
||||
REG(vdac, bt_reg) = 0; tc_wmb();
|
||||
REG(vdac, bt_reg) = 0; tc_wmb();
|
||||
REG(vdac, bt_reg) = 0; tc_wmb();
|
||||
|
||||
REG(vdac, bt_reg) = 0xff; tc_wmb();
|
||||
REG(vdac, bt_reg) = 0xff; tc_wmb();
|
||||
REG(vdac, bt_reg) = 0xff; tc_wmb();
|
||||
#endif /* XXX snip XXX */
|
||||
}
|
||||
|
||||
|
||||
|
@ -779,7 +767,7 @@ set_cursor(sc, p)
|
|||
if (v & WSDISPLAY_CURSOR_DOCMAP) {
|
||||
index = p->cmap.index;
|
||||
count = p->cmap.count;
|
||||
if (index >= 2 || (index + count) > 2)
|
||||
if (index >= CURSOR_MAX_COLOURS || (index + count) > CURSOR_MAX_COLOURS)
|
||||
return (EINVAL);
|
||||
if (!uvm_useracc(p->cmap.red, count, B_READ) ||
|
||||
!uvm_useracc(p->cmap.green, count, B_READ) ||
|
||||
|
@ -787,15 +775,15 @@ set_cursor(sc, p)
|
|||
return (EFAULT);
|
||||
}
|
||||
if (v & WSDISPLAY_CURSOR_DOSHAPE) {
|
||||
if (p->size.x > CURSOR_MAX_SIZE || p->size.y > CURSOR_MAX_SIZE)
|
||||
if (p->size.x > CURSOR_MAX_WIDTH || p->size.y > CURSOR_MAX_HEIGHT)
|
||||
return (EINVAL);
|
||||
icount = ((p->size.x < 33) ? 4 : 8) * p->size.y;
|
||||
icount = sizeof(u_int32_t) * p->size.y;
|
||||
if (!uvm_useracc(p->image, icount, B_READ) ||
|
||||
!uvm_useracc(p->mask, icount, B_READ))
|
||||
return (EFAULT);
|
||||
}
|
||||
|
||||
if (v & WSDISPLAY_CURSOR_DOCUR)
|
||||
if (v & WSDISPLAY_CURSOR_DOCUR)
|
||||
sc->sc_curenb = p->enable;
|
||||
if (v & WSDISPLAY_CURSOR_DOPOS)
|
||||
set_curpos(sc, &p->pos);
|
||||
|
@ -809,10 +797,11 @@ set_cursor(sc, p)
|
|||
if (v & WSDISPLAY_CURSOR_DOSHAPE) {
|
||||
cc->cc_size = p->size;
|
||||
memset(cc->cc_image, 0, sizeof cc->cc_image);
|
||||
memset(cc->cc_mask, 0, sizeof cc->cc_mask);
|
||||
copyin(p->image, cc->cc_image, icount);
|
||||
copyin(p->mask, cc->cc_image+CURSOR_MAX_SIZE, icount);
|
||||
copyin(p->mask, cc->cc_mask, icount);
|
||||
}
|
||||
sc->sc_changed = v;
|
||||
sc->sc_changed |= v;
|
||||
|
||||
return (0);
|
||||
#undef cc
|
||||
|
|
Loading…
Reference in New Issue