2018-01-24 08:35:58 +03:00
|
|
|
/* $NetBSD: tcx.c,v 1.58 2018/01/24 05:35:58 riastradh Exp $ */
|
2000-08-21 02:27:07 +04:00
|
|
|
|
|
|
|
/*
|
2009-08-20 00:51:47 +04:00
|
|
|
* Copyright (c) 1996, 1998, 2009 The NetBSD Foundation, Inc.
|
2000-08-21 02:27:07 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
2009-08-19 00:45:42 +04:00
|
|
|
* by Paul Kranenburg and Michael Lorenz.
|
2000-08-21 02:27:07 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* color display (TCX) driver.
|
|
|
|
*
|
|
|
|
* Does not handle interrupts, even though they can occur.
|
|
|
|
*
|
|
|
|
* XXX should defer colormap updates to vertical retrace interrupts
|
|
|
|
*/
|
|
|
|
|
2001-11-13 09:54:32 +03:00
|
|
|
#include <sys/cdefs.h>
|
2018-01-24 08:35:58 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: tcx.c,v 1.58 2018/01/24 05:35:58 riastradh Exp $");
|
2001-11-13 09:54:32 +03:00
|
|
|
|
2000-08-21 02:27:07 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/tty.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#endif
|
|
|
|
|
2007-10-19 15:59:34 +04:00
|
|
|
#include <sys/bus.h>
|
2000-08-21 02:27:07 +04:00
|
|
|
#include <machine/autoconf.h>
|
|
|
|
|
|
|
|
#include <dev/sun/fbio.h>
|
|
|
|
#include <dev/sun/fbvar.h>
|
|
|
|
#include <dev/sun/btreg.h>
|
|
|
|
#include <dev/sun/btvar.h>
|
2000-08-23 01:18:57 +04:00
|
|
|
|
|
|
|
#include <dev/sbus/sbusvar.h>
|
|
|
|
#include <dev/sbus/tcxreg.h>
|
2000-08-21 02:27:07 +04:00
|
|
|
|
2009-08-06 22:26:03 +04:00
|
|
|
#include <dev/wscons/wsdisplayvar.h>
|
|
|
|
#include <dev/wscons/wsconsio.h>
|
|
|
|
#include <dev/wsfont/wsfont.h>
|
|
|
|
#include <dev/rasops/rasops.h>
|
|
|
|
|
|
|
|
#include <dev/wscons/wsdisplay_vconsvar.h>
|
|
|
|
|
|
|
|
#include "opt_wsemul.h"
|
|
|
|
|
2009-09-17 20:39:48 +04:00
|
|
|
#include "ioconf.h"
|
|
|
|
|
2000-08-21 02:27:07 +04:00
|
|
|
/* per-display variables */
|
|
|
|
struct tcx_softc {
|
2009-08-19 00:45:42 +04:00
|
|
|
device_t sc_dev; /* base device */
|
2000-08-21 02:27:07 +04:00
|
|
|
struct fbdevice sc_fb; /* frame buffer device */
|
|
|
|
bus_space_tag_t sc_bustag;
|
2009-08-19 07:35:32 +04:00
|
|
|
struct openprom_addr sc_physaddr[TCX_NREG];/* phys addr of h/w */
|
2000-08-21 02:27:07 +04:00
|
|
|
|
2009-08-06 22:26:03 +04:00
|
|
|
bus_space_handle_t sc_bt; /* Brooktree registers */
|
|
|
|
bus_space_handle_t sc_thc; /* THC registers */
|
2014-06-17 18:25:17 +04:00
|
|
|
uint8_t *sc_fbaddr; /* framebuffer */
|
2016-09-23 20:45:25 +03:00
|
|
|
volatile uint64_t *sc_rblit; /* blitspace */
|
|
|
|
volatile uint64_t *sc_rstip; /* stipple space */
|
2014-06-17 18:25:17 +04:00
|
|
|
|
|
|
|
short sc_8bit; /* true if 8-bit hardware */
|
|
|
|
short sc_blanked; /* true if blanked */
|
|
|
|
uint32_t sc_fbsize; /* size of the 8bit fb */
|
|
|
|
u_char sc_cmap_red[256];
|
|
|
|
u_char sc_cmap_green[256];
|
|
|
|
u_char sc_cmap_blue[256];
|
|
|
|
int sc_mode, sc_bg;
|
|
|
|
int sc_cursor_x, sc_cursor_y;
|
|
|
|
int sc_hotspot_x, sc_hotspot_y;
|
2009-08-06 22:26:03 +04:00
|
|
|
struct vcons_data vd;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct vcons_screen tcx_console_screen;
|
|
|
|
|
|
|
|
extern const u_char rasops_cmap[768];
|
|
|
|
|
|
|
|
struct wsscreen_descr tcx_defscreendesc = {
|
|
|
|
"default",
|
|
|
|
0, 0,
|
|
|
|
NULL,
|
|
|
|
8, 16,
|
|
|
|
WSSCREEN_WSCOLORS,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct wsscreen_descr *_tcx_scrlist[] = {
|
|
|
|
&tcx_defscreendesc,
|
|
|
|
/* XXX other formats, graphics screen? */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct wsscreen_list tcx_screenlist = {
|
|
|
|
sizeof(_tcx_scrlist) / sizeof(struct wsscreen_descr *),
|
|
|
|
_tcx_scrlist
|
2000-08-21 02:27:07 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* autoconfiguration driver */
|
2009-05-12 18:38:26 +04:00
|
|
|
static void tcxattach(device_t, device_t, void *);
|
|
|
|
static int tcxmatch(device_t, cfdata_t, void *);
|
|
|
|
static void tcx_unblank(device_t);
|
2000-08-21 02:27:07 +04:00
|
|
|
|
2009-08-19 00:45:42 +04:00
|
|
|
CFATTACH_DECL_NEW(tcx, sizeof(struct tcx_softc),
|
2002-10-02 20:51:16 +04:00
|
|
|
tcxmatch, tcxattach, NULL, NULL);
|
2000-08-21 02:27:07 +04:00
|
|
|
|
2002-09-06 17:18:43 +04:00
|
|
|
dev_type_open(tcxopen);
|
|
|
|
dev_type_close(tcxclose);
|
|
|
|
dev_type_ioctl(tcxioctl);
|
|
|
|
dev_type_mmap(tcxmmap);
|
|
|
|
|
|
|
|
const struct cdevsw tcx_cdevsw = {
|
2014-03-16 09:20:22 +04:00
|
|
|
.d_open = tcxopen,
|
|
|
|
.d_close = tcxclose,
|
|
|
|
.d_read = noread,
|
|
|
|
.d_write = nowrite,
|
|
|
|
.d_ioctl = tcxioctl,
|
|
|
|
.d_stop = nostop,
|
|
|
|
.d_tty = notty,
|
|
|
|
.d_poll = nopoll,
|
|
|
|
.d_mmap = tcxmmap,
|
|
|
|
.d_kqfilter = nokqfilter,
|
2014-07-25 12:10:31 +04:00
|
|
|
.d_discard = nodiscard,
|
2014-03-16 09:20:22 +04:00
|
|
|
.d_flag = 0
|
2002-09-06 17:18:43 +04:00
|
|
|
};
|
|
|
|
|
2000-08-21 02:27:07 +04:00
|
|
|
/* frame buffer generic driver */
|
|
|
|
static struct fbdriver tcx_fbdriver = {
|
2002-10-23 13:10:23 +04:00
|
|
|
tcx_unblank, tcxopen, tcxclose, tcxioctl, nopoll, tcxmmap,
|
|
|
|
nokqfilter
|
2000-08-21 02:27:07 +04:00
|
|
|
};
|
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
static void tcx_reset(struct tcx_softc *);
|
|
|
|
static void tcx_loadcmap(struct tcx_softc *, int, int);
|
2000-08-21 02:27:07 +04:00
|
|
|
|
2009-08-06 22:26:03 +04:00
|
|
|
static int tcx_ioctl(void *, void *, u_long, void *, int, struct lwp *);
|
|
|
|
static paddr_t tcx_mmap(void *, void *, off_t, int);
|
|
|
|
|
2014-07-22 08:55:51 +04:00
|
|
|
static void tcx_init_cmap(struct tcx_softc *);
|
2009-08-06 22:26:03 +04:00
|
|
|
static void tcx_init_screen(void *, struct vcons_screen *, int, long *);
|
2009-08-20 00:51:47 +04:00
|
|
|
static void tcx_clearscreen(struct tcx_softc *, int);
|
2009-08-06 22:26:03 +04:00
|
|
|
static void tcx_copyrows(void *, int, int, int);
|
|
|
|
static void tcx_eraserows(void *, int, int, long);
|
|
|
|
static void tcx_putchar(void *, int, int, u_int, long);
|
2009-08-19 07:45:51 +04:00
|
|
|
static void tcx_set_video(struct tcx_softc *, int);
|
2009-08-20 04:59:28 +04:00
|
|
|
static int tcx_do_cursor(struct tcx_softc *, struct wsdisplay_cursor *);
|
|
|
|
static void tcx_set_cursor(struct tcx_softc *);
|
2009-08-06 22:26:03 +04:00
|
|
|
|
|
|
|
struct wsdisplay_accessops tcx_accessops = {
|
|
|
|
tcx_ioctl,
|
|
|
|
tcx_mmap,
|
|
|
|
NULL, /* vcons_alloc_screen */
|
|
|
|
NULL, /* vcons_free_screen */
|
|
|
|
NULL, /* vcons_show_screen */
|
|
|
|
NULL, /* load_font */
|
|
|
|
NULL, /* polls */
|
|
|
|
NULL, /* scroll */
|
|
|
|
};
|
|
|
|
|
2000-08-21 02:27:07 +04:00
|
|
|
#define OBPNAME "SUNW,tcx"
|
2002-03-27 13:14:17 +03:00
|
|
|
|
2000-08-21 02:27:07 +04:00
|
|
|
/*
|
|
|
|
* Match a tcx.
|
|
|
|
*/
|
|
|
|
int
|
2009-05-12 18:38:26 +04:00
|
|
|
tcxmatch(device_t parent, cfdata_t cf, void *aux)
|
2000-08-21 02:27:07 +04:00
|
|
|
{
|
|
|
|
struct sbus_attach_args *sa = aux;
|
|
|
|
|
2014-04-29 15:16:25 +04:00
|
|
|
if (strcmp(sa->sa_name, OBPNAME) == 0)
|
|
|
|
return 100; /* beat genfb */
|
|
|
|
return 0;
|
2000-08-21 02:27:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attach a display.
|
|
|
|
*/
|
|
|
|
void
|
2009-05-12 18:38:26 +04:00
|
|
|
tcxattach(device_t parent, device_t self, void *args)
|
2000-08-21 02:27:07 +04:00
|
|
|
{
|
2008-06-12 01:25:31 +04:00
|
|
|
struct tcx_softc *sc = device_private(self);
|
2000-08-21 02:27:07 +04:00
|
|
|
struct sbus_attach_args *sa = args;
|
2009-08-06 22:26:03 +04:00
|
|
|
struct wsemuldisplaydev_attach_args aa;
|
|
|
|
struct rasops_info *ri;
|
|
|
|
unsigned long defattr;
|
2014-06-17 18:25:17 +04:00
|
|
|
int node;
|
2000-08-21 02:27:07 +04:00
|
|
|
struct fbdevice *fb = &sc->sc_fb;
|
|
|
|
bus_space_handle_t bh;
|
2014-07-22 08:55:51 +04:00
|
|
|
int isconsole;
|
2009-08-06 22:26:03 +04:00
|
|
|
uint32_t confreg;
|
2000-08-21 02:27:07 +04:00
|
|
|
|
2009-08-19 00:45:42 +04:00
|
|
|
sc->sc_dev = self;
|
2000-08-21 02:27:07 +04:00
|
|
|
sc->sc_bustag = sa->sa_bustag;
|
|
|
|
node = sa->sa_node;
|
|
|
|
|
2009-08-20 04:59:28 +04:00
|
|
|
sc->sc_cursor_x = 0x7fff;
|
|
|
|
sc->sc_cursor_y = 0x7fff;
|
|
|
|
sc->sc_hotspot_x = 0;
|
|
|
|
sc->sc_hotspot_y = 0;
|
|
|
|
|
2000-08-21 02:27:07 +04:00
|
|
|
fb->fb_driver = &tcx_fbdriver;
|
2009-08-19 00:45:42 +04:00
|
|
|
fb->fb_device = sc->sc_dev;
|
2000-08-21 02:27:07 +04:00
|
|
|
/* Mask out invalid flags from the user. */
|
2009-08-19 00:45:42 +04:00
|
|
|
fb->fb_flags = device_cfdata(sc->sc_dev)->cf_flags & FB_USERMASK;
|
2002-03-27 13:14:17 +03:00
|
|
|
/*
|
|
|
|
* The onboard framebuffer on the SS4 supports only 8-bit mode;
|
|
|
|
* it can be distinguished from the S24 card for the SS5 by the
|
|
|
|
* presence of the "tcx-8-bit" attribute on the SS4 version.
|
|
|
|
*/
|
|
|
|
sc->sc_8bit = node_has_property(node, "tcx-8-bit");
|
2009-08-06 22:26:03 +04:00
|
|
|
fb->fb_type.fb_depth = 8;
|
|
|
|
fb_setsize_obp(fb, fb->fb_type.fb_depth, 1152, 900, node);
|
|
|
|
|
2014-06-17 18:25:17 +04:00
|
|
|
/*
|
|
|
|
* actual FB size ( of the 8bit region )
|
2014-07-16 21:58:35 +04:00
|
|
|
* no reason to restrict userland mappings to the visible VRAM
|
2014-06-17 18:25:17 +04:00
|
|
|
*/
|
2002-03-27 13:14:17 +03:00
|
|
|
if (sc->sc_8bit) {
|
2014-06-17 18:25:17 +04:00
|
|
|
aprint_normal(" (8-bit only TCX)\n");
|
|
|
|
/* at least the SS4 can have 2MB with a VSIMM */
|
|
|
|
sc->sc_fbsize = 0x100000 * prom_getpropint(node, "vram", 1);
|
2002-03-27 13:14:17 +03:00
|
|
|
} else {
|
2014-06-17 18:25:17 +04:00
|
|
|
aprint_normal(" (S24)\n");
|
|
|
|
/* all S24 I know of have 4MB, non-expandable */
|
|
|
|
sc->sc_fbsize = 0x100000;
|
2002-03-27 13:14:17 +03:00
|
|
|
}
|
2009-08-06 22:26:03 +04:00
|
|
|
|
2000-08-21 02:27:07 +04:00
|
|
|
fb->fb_type.fb_cmsize = 256;
|
2014-06-17 18:25:17 +04:00
|
|
|
fb->fb_type.fb_size = sc->sc_fbsize; /* later code assumes 8bit */
|
|
|
|
aprint_normal_dev(self, "%s, %d x %d\n", OBPNAME,
|
2000-08-21 02:27:07 +04:00
|
|
|
fb->fb_type.fb_width,
|
|
|
|
fb->fb_type.fb_height);
|
|
|
|
|
2009-08-27 02:36:07 +04:00
|
|
|
fb->fb_type.fb_type = FBTYPE_TCXCOLOR;
|
2000-08-21 02:27:07 +04:00
|
|
|
|
|
|
|
if (sa->sa_nreg != TCX_NREG) {
|
2014-05-13 09:30:38 +04:00
|
|
|
aprint_error("\n");
|
|
|
|
aprint_error_dev(self, "only %d register sets\n",
|
|
|
|
sa->sa_nreg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (sa->sa_reg[TCX_REG_STIP].oa_size < 0x1000) {
|
|
|
|
aprint_error("\n");
|
|
|
|
aprint_error_dev(self, "STIP register too small (0x%x)\n",
|
|
|
|
sa->sa_reg[TCX_REG_STIP].oa_size);
|
2000-08-21 02:27:07 +04:00
|
|
|
return;
|
|
|
|
}
|
2014-05-13 09:30:38 +04:00
|
|
|
|
2009-08-19 07:35:32 +04:00
|
|
|
memcpy(sc->sc_physaddr, sa->sa_reg,
|
2002-08-23 06:53:10 +04:00
|
|
|
sa->sa_nreg * sizeof(struct openprom_addr));
|
2000-08-21 02:27:07 +04:00
|
|
|
|
|
|
|
/* Map the register banks we care about */
|
|
|
|
if (sbus_bus_map(sa->sa_bustag,
|
2009-08-19 07:35:32 +04:00
|
|
|
sc->sc_physaddr[TCX_REG_THC].oa_space,
|
|
|
|
sc->sc_physaddr[TCX_REG_THC].oa_base,
|
2009-08-06 22:26:03 +04:00
|
|
|
0x1000,
|
|
|
|
BUS_SPACE_MAP_LINEAR, &sc->sc_thc) != 0) {
|
2014-06-17 18:25:17 +04:00
|
|
|
aprint_error_dev(self,
|
|
|
|
"tcxattach: cannot map thc registers\n");
|
2000-08-21 02:27:07 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sbus_bus_map(sa->sa_bustag,
|
2009-08-19 07:35:32 +04:00
|
|
|
sc->sc_physaddr[TCX_REG_CMAP].oa_space,
|
|
|
|
sc->sc_physaddr[TCX_REG_CMAP].oa_base,
|
2009-08-06 22:26:03 +04:00
|
|
|
0x1000,
|
|
|
|
BUS_SPACE_MAP_LINEAR, &sc->sc_bt) != 0) {
|
2014-06-17 18:25:17 +04:00
|
|
|
aprint_error_dev(self, "tcxattach: cannot map DAC registers\n");
|
2000-08-21 02:27:07 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-08-06 22:26:03 +04:00
|
|
|
/* map the 8bit dumb FB for the console */
|
|
|
|
if (sbus_bus_map(sa->sa_bustag,
|
2009-08-19 07:35:32 +04:00
|
|
|
sc->sc_physaddr[TCX_REG_DFB8].oa_space,
|
|
|
|
sc->sc_physaddr[TCX_REG_DFB8].oa_base,
|
2014-06-17 18:25:17 +04:00
|
|
|
sc->sc_fbsize,
|
2002-03-27 13:14:17 +03:00
|
|
|
BUS_SPACE_MAP_LINEAR,
|
2004-07-14 23:07:29 +04:00
|
|
|
&bh) != 0) {
|
2014-06-17 18:25:17 +04:00
|
|
|
aprint_error_dev(self, "tcxattach: cannot map framebuffer\n");
|
2009-08-06 22:26:03 +04:00
|
|
|
return;
|
2002-03-27 13:14:17 +03:00
|
|
|
}
|
2009-08-06 22:26:03 +04:00
|
|
|
sc->sc_fbaddr = bus_space_vaddr(sa->sa_bustag, bh);
|
|
|
|
|
2014-06-24 09:04:14 +04:00
|
|
|
/*
|
|
|
|
* 8bit tcx has the RSTIP and RBLIT ranges set to size 0.
|
|
|
|
* On Real Hardware they work anyway ( on my SS4 at least ) but
|
|
|
|
* emulators may not be so forgiving.
|
|
|
|
*/
|
|
|
|
if (sc->sc_8bit) {
|
|
|
|
/* BLIT space */
|
|
|
|
if (sbus_bus_map(sa->sa_bustag,
|
|
|
|
sc->sc_physaddr[TCX_REG_BLIT].oa_space,
|
|
|
|
sc->sc_physaddr[TCX_REG_BLIT].oa_base,
|
|
|
|
sc->sc_fbsize << 3,
|
|
|
|
BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_LARGE,
|
|
|
|
&bh) != 0) {
|
|
|
|
aprint_error_dev(self,
|
|
|
|
"tcxattach: cannot map BLIT space\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sc->sc_rblit = bus_space_vaddr(sa->sa_bustag, bh);
|
|
|
|
|
|
|
|
/* STIP space */
|
|
|
|
if (sbus_bus_map(sa->sa_bustag,
|
|
|
|
sc->sc_physaddr[TCX_REG_STIP].oa_space,
|
|
|
|
sc->sc_physaddr[TCX_REG_STIP].oa_base,
|
|
|
|
sc->sc_fbsize << 3,
|
|
|
|
BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_LARGE,
|
|
|
|
&bh) != 0) {
|
|
|
|
aprint_error_dev(self,
|
|
|
|
"tcxattach: cannot map STIP space\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sc->sc_rstip = bus_space_vaddr(sa->sa_bustag, bh);
|
|
|
|
} else {
|
|
|
|
/* RBLIT space */
|
|
|
|
if (sbus_bus_map(sa->sa_bustag,
|
|
|
|
sc->sc_physaddr[TCX_REG_RBLIT].oa_space,
|
|
|
|
sc->sc_physaddr[TCX_REG_RBLIT].oa_base,
|
|
|
|
sc->sc_fbsize << 3,
|
|
|
|
BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_LARGE,
|
|
|
|
&bh) != 0) {
|
|
|
|
aprint_error_dev(self,
|
|
|
|
"tcxattach: cannot map RBLIT space\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sc->sc_rblit = bus_space_vaddr(sa->sa_bustag, bh);
|
|
|
|
|
|
|
|
/* RSTIP space */
|
|
|
|
if (sbus_bus_map(sa->sa_bustag,
|
|
|
|
sc->sc_physaddr[TCX_REG_RSTIP].oa_space,
|
|
|
|
sc->sc_physaddr[TCX_REG_RSTIP].oa_base,
|
|
|
|
sc->sc_fbsize << 3,
|
|
|
|
BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_LARGE,
|
|
|
|
&bh) != 0) {
|
|
|
|
aprint_error_dev(self,
|
|
|
|
"tcxattach: cannot map RSTIP space\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sc->sc_rstip = bus_space_vaddr(sa->sa_bustag, bh);
|
2009-08-06 22:26:03 +04:00
|
|
|
}
|
2000-08-21 02:27:07 +04:00
|
|
|
isconsole = fb_is_console(node);
|
|
|
|
|
2009-08-06 22:26:03 +04:00
|
|
|
confreg = bus_space_read_4(sa->sa_bustag, sc->sc_thc, THC_CONFIG);
|
2014-06-17 18:25:17 +04:00
|
|
|
aprint_normal_dev(self, "id %d, rev %d, sense %d\n",
|
2009-08-06 22:26:03 +04:00
|
|
|
(confreg & THC_CFG_FBID) >> THC_CFG_FBID_SHIFT,
|
|
|
|
(confreg & THC_CFG_REV) >> THC_CFG_REV_SHIFT,
|
|
|
|
(confreg & THC_CFG_SENSE) >> THC_CFG_SENSE_SHIFT
|
2000-08-21 02:27:07 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
/* reset cursor & frame buffer controls */
|
|
|
|
tcx_reset(sc);
|
|
|
|
|
2014-06-18 08:54:09 +04:00
|
|
|
if (!sc->sc_8bit)
|
|
|
|
tcx_set_cursor(sc);
|
|
|
|
|
2000-08-21 02:27:07 +04:00
|
|
|
/* enable video */
|
2009-08-06 22:26:03 +04:00
|
|
|
confreg = bus_space_read_4(sa->sa_bustag, sc->sc_thc, THC_MISC);
|
|
|
|
confreg |= THC_MISC_VIDEN;
|
|
|
|
bus_space_write_4(sa->sa_bustag, sc->sc_thc, THC_MISC, confreg);
|
2000-08-21 02:27:07 +04:00
|
|
|
|
|
|
|
if (isconsole) {
|
2014-06-17 18:25:17 +04:00
|
|
|
aprint_error_dev(self, "(console)\n");
|
|
|
|
}
|
2000-08-21 02:27:07 +04:00
|
|
|
|
|
|
|
fb_attach(&sc->sc_fb, isconsole);
|
2009-08-06 22:26:03 +04:00
|
|
|
|
|
|
|
sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
|
|
|
|
wsfont_init();
|
|
|
|
|
|
|
|
vcons_init(&sc->vd, sc, &tcx_defscreendesc, &tcx_accessops);
|
|
|
|
sc->vd.init_screen = tcx_init_screen;
|
|
|
|
|
|
|
|
vcons_init_screen(&sc->vd, &tcx_console_screen, 1, &defattr);
|
|
|
|
tcx_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
|
|
|
|
|
|
|
|
ri = &tcx_console_screen.scr_ri;
|
|
|
|
|
2014-06-17 18:25:17 +04:00
|
|
|
sc->sc_bg = ri->ri_devcmap[(defattr >> 16) & 0xff];
|
|
|
|
tcx_clearscreen(sc, 0);
|
2014-07-22 08:55:51 +04:00
|
|
|
tcx_init_cmap(sc);
|
2014-06-17 18:25:17 +04:00
|
|
|
|
2009-08-06 22:26:03 +04:00
|
|
|
tcx_defscreendesc.nrows = ri->ri_rows;
|
|
|
|
tcx_defscreendesc.ncols = ri->ri_cols;
|
|
|
|
tcx_defscreendesc.textops = &ri->ri_ops;
|
|
|
|
tcx_defscreendesc.capabilities = ri->ri_caps;
|
|
|
|
|
|
|
|
if(isconsole) {
|
|
|
|
wsdisplay_cnattach(&tcx_defscreendesc, ri, 0, 0, defattr);
|
2009-08-20 06:29:16 +04:00
|
|
|
vcons_replay_msgbuf(&tcx_console_screen);
|
2009-08-06 22:26:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
aa.console = isconsole;
|
|
|
|
aa.scrdata = &tcx_screenlist;
|
|
|
|
aa.accessops = &tcx_accessops;
|
|
|
|
aa.accesscookie = &sc->vd;
|
|
|
|
|
|
|
|
config_found(self, &aa, wsemuldisplaydevprint);
|
|
|
|
/*
|
|
|
|
* we need to do this again - something overwrites a handful
|
|
|
|
* palette registers and we end up with white in reg. 0
|
|
|
|
*/
|
|
|
|
tcx_loadcmap(sc, 0, 256);
|
2000-08-21 02:27:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2009-03-15 00:04:01 +03:00
|
|
|
tcxopen(dev_t dev, int flags, int mode, struct lwp *l)
|
2000-08-21 02:27:07 +04:00
|
|
|
{
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2009-03-15 00:04:01 +03:00
|
|
|
tcxclose(dev_t dev, int flags, int mode, struct lwp *l)
|
2000-08-21 02:27:07 +04:00
|
|
|
{
|
2008-06-12 01:25:31 +04:00
|
|
|
struct tcx_softc *sc = device_lookup_private(&tcx_cd, minor(dev));
|
2000-08-21 02:27:07 +04:00
|
|
|
|
|
|
|
tcx_reset(sc);
|
2009-08-19 07:35:32 +04:00
|
|
|
/* we may want to clear and redraw the console here */
|
2000-08-21 02:27:07 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2009-03-14 18:35:58 +03:00
|
|
|
tcxioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l)
|
2000-08-21 02:27:07 +04:00
|
|
|
{
|
2008-06-12 01:25:31 +04:00
|
|
|
struct tcx_softc *sc = device_lookup_private(&tcx_cd, minor(dev));
|
2000-08-21 02:27:07 +04:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
|
|
|
|
case FBIOGTYPE:
|
|
|
|
*(struct fbtype *)data = sc->sc_fb.fb_type;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FBIOGATTR:
|
|
|
|
#define fba ((struct fbgattr *)data)
|
|
|
|
fba->real_type = sc->sc_fb.fb_type.fb_type;
|
|
|
|
fba->owner = 0; /* XXX ??? */
|
|
|
|
fba->fbtype = sc->sc_fb.fb_type;
|
|
|
|
fba->sattr.flags = 0;
|
|
|
|
fba->sattr.emu_type = sc->sc_fb.fb_type.fb_type;
|
|
|
|
fba->sattr.dev_specific[0] = -1;
|
|
|
|
fba->emu_types[0] = sc->sc_fb.fb_type.fb_type;
|
|
|
|
fba->emu_types[1] = FBTYPE_SUN3COLOR;
|
|
|
|
fba->emu_types[2] = -1;
|
|
|
|
#undef fba
|
|
|
|
break;
|
2009-08-19 07:35:32 +04:00
|
|
|
|
2000-08-21 02:27:07 +04:00
|
|
|
case FBIOGETCMAP:
|
|
|
|
#define p ((struct fbcmap *)data)
|
2018-01-24 08:35:58 +03:00
|
|
|
if (p->index > 256 || p->count > 256 - p->index)
|
|
|
|
return EINVAL;
|
2009-08-19 07:35:32 +04:00
|
|
|
if (copyout(&sc->sc_cmap_red[p->index], p->red, p->count) != 0)
|
|
|
|
return EINVAL;
|
|
|
|
if (copyout(&sc->sc_cmap_green[p->index], p->green, p->count)
|
|
|
|
!= 0)
|
|
|
|
return EINVAL;
|
|
|
|
if (copyout(&sc->sc_cmap_blue[p->index], p->blue, p->count)
|
|
|
|
!= 0)
|
|
|
|
return EINVAL;
|
|
|
|
return 0;
|
2000-08-21 02:27:07 +04:00
|
|
|
|
|
|
|
case FBIOPUTCMAP:
|
|
|
|
/* copy to software map */
|
2018-01-24 08:35:58 +03:00
|
|
|
if (p->index > 256 || p->count > 256 - p->index)
|
|
|
|
return EINVAL;
|
2009-08-19 07:35:32 +04:00
|
|
|
if (copyin(p->red, &sc->sc_cmap_red[p->index], p->count) != 0)
|
|
|
|
return EINVAL;
|
|
|
|
if (copyin(p->green, &sc->sc_cmap_green[p->index], p->count)
|
|
|
|
!= 0)
|
|
|
|
return EINVAL;
|
|
|
|
if (copyin(p->blue, &sc->sc_cmap_blue[p->index], p->count) != 0)
|
|
|
|
return EINVAL;
|
2000-08-21 02:27:07 +04:00
|
|
|
tcx_loadcmap(sc, p->index, p->count);
|
|
|
|
#undef p
|
|
|
|
break;
|
|
|
|
case FBIOGVIDEO:
|
|
|
|
*(int *)data = sc->sc_blanked;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FBIOSVIDEO:
|
2009-08-19 07:45:51 +04:00
|
|
|
tcx_set_video(sc, *(int *)data);
|
2000-08-21 02:27:07 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
#ifdef DEBUG
|
|
|
|
log(LOG_NOTICE, "tcxioctl(0x%lx) (%s[%d])\n", cmd,
|
2007-01-07 15:32:29 +03:00
|
|
|
l->l_proc->p_comm, l->l_proc->p_pid);
|
2000-08-21 02:27:07 +04:00
|
|
|
#endif
|
|
|
|
return (ENOTTY);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean up hardware state (e.g., after bootup or after X crashes).
|
|
|
|
*/
|
|
|
|
static void
|
2009-03-14 18:35:58 +03:00
|
|
|
tcx_reset(struct tcx_softc *sc)
|
2000-08-21 02:27:07 +04:00
|
|
|
{
|
2009-08-20 04:59:28 +04:00
|
|
|
uint32_t reg;
|
2000-08-21 02:27:07 +04:00
|
|
|
|
2009-08-20 04:59:28 +04:00
|
|
|
reg = bus_space_read_4(sc->sc_bustag, sc->sc_thc, THC_MISC);
|
|
|
|
reg |= THC_MISC_CURSRES;
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_thc, THC_MISC, reg);
|
2000-08-21 02:27:07 +04:00
|
|
|
}
|
|
|
|
|
2014-07-22 08:55:51 +04:00
|
|
|
static void
|
|
|
|
tcx_init_cmap(struct tcx_softc *sc)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
/* Initialize the default color map. */
|
|
|
|
j = 0;
|
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
|
|
|
|
sc->sc_cmap_red[i] = rasops_cmap[j];
|
|
|
|
sc->sc_cmap_green[i] = rasops_cmap[j + 1];
|
|
|
|
sc->sc_cmap_blue[i] = rasops_cmap[j + 2];
|
|
|
|
j += 3;
|
|
|
|
}
|
|
|
|
tcx_loadcmap(sc, 0, 256);
|
|
|
|
}
|
|
|
|
|
2000-08-21 02:27:07 +04:00
|
|
|
static void
|
2009-03-15 00:04:01 +03:00
|
|
|
tcx_loadcmap(struct tcx_softc *sc, int start, int ncolors)
|
2000-08-21 02:27:07 +04:00
|
|
|
{
|
2009-08-06 22:26:03 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ncolors; i++) {
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_bt, DAC_ADDRESS,
|
|
|
|
(start + i) << 24);
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_bt, DAC_FB_LUT,
|
|
|
|
sc->sc_cmap_red[i + start] << 24);
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_bt, DAC_FB_LUT,
|
|
|
|
sc->sc_cmap_green[i + start] << 24);
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_bt, DAC_FB_LUT,
|
|
|
|
sc->sc_cmap_blue[i + start] << 24);
|
2000-08-21 02:27:07 +04:00
|
|
|
}
|
2009-08-06 22:26:03 +04:00
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_bt, DAC_ADDRESS, 0);
|
2000-08-21 02:27:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-05-12 18:38:26 +04:00
|
|
|
tcx_unblank(device_t dev)
|
2000-08-21 02:27:07 +04:00
|
|
|
{
|
2008-06-12 01:25:31 +04:00
|
|
|
struct tcx_softc *sc = device_private(dev);
|
2000-08-21 02:27:07 +04:00
|
|
|
|
|
|
|
if (sc->sc_blanked) {
|
2009-08-19 07:35:32 +04:00
|
|
|
uint32_t reg;
|
2000-08-21 02:27:07 +04:00
|
|
|
sc->sc_blanked = 0;
|
2009-08-19 07:35:32 +04:00
|
|
|
reg = bus_space_read_4(sc->sc_bustag, sc->sc_thc, THC_MISC);
|
|
|
|
reg &= ~THC_MISC_VSYNC_DISABLE;
|
|
|
|
reg &= ~THC_MISC_HSYNC_DISABLE;
|
|
|
|
reg |= THC_MISC_VIDEN;
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_thc, THC_MISC, reg);
|
2000-08-21 02:27:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-19 07:45:51 +04:00
|
|
|
static void
|
|
|
|
tcx_set_video(struct tcx_softc *sc, int unblank)
|
|
|
|
{
|
|
|
|
uint32_t reg;
|
|
|
|
if (unblank) {
|
|
|
|
sc->sc_blanked = 0;
|
|
|
|
reg = bus_space_read_4(sc->sc_bustag, sc->sc_thc, THC_MISC);
|
|
|
|
reg &= ~THC_MISC_VSYNC_DISABLE;
|
|
|
|
reg &= ~THC_MISC_HSYNC_DISABLE;
|
|
|
|
reg |= THC_MISC_VIDEN;
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_thc, THC_MISC, reg);
|
|
|
|
} else {
|
|
|
|
sc->sc_blanked = 1;
|
|
|
|
reg = bus_space_read_4(sc->sc_bustag, sc->sc_thc, THC_MISC);
|
|
|
|
reg |= THC_MISC_VSYNC_DISABLE;
|
|
|
|
reg |= THC_MISC_HSYNC_DISABLE;
|
|
|
|
reg &= ~THC_MISC_VIDEN;
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_thc, THC_MISC, reg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-21 02:27:07 +04:00
|
|
|
/*
|
|
|
|
* Base addresses at which users can mmap() the various pieces of a tcx.
|
|
|
|
*/
|
|
|
|
#define TCX_USER_RAM 0x00000000
|
|
|
|
#define TCX_USER_RAM24 0x01000000
|
|
|
|
#define TCX_USER_RAM_COMPAT 0x04000000 /* cg3 emulation */
|
|
|
|
#define TCX_USER_STIP 0x10000000
|
|
|
|
#define TCX_USER_BLIT 0x20000000
|
|
|
|
#define TCX_USER_RDFB32 0x28000000
|
|
|
|
#define TCX_USER_RSTIP 0x30000000
|
|
|
|
#define TCX_USER_RBLIT 0x38000000
|
|
|
|
#define TCX_USER_TEC 0x70001000
|
|
|
|
#define TCX_USER_BTREGS 0x70002000
|
|
|
|
#define TCX_USER_THC 0x70004000
|
|
|
|
#define TCX_USER_DHC 0x70008000
|
|
|
|
#define TCX_USER_ALT 0x7000a000
|
|
|
|
#define TCX_USER_UART 0x7000c000
|
|
|
|
#define TCX_USER_VRT 0x7000e000
|
|
|
|
#define TCX_USER_ROM 0x70010000
|
|
|
|
|
|
|
|
struct mmo {
|
|
|
|
u_int mo_uaddr; /* user (virtual) address */
|
|
|
|
u_int mo_size; /* size, or 0 for video ram size */
|
|
|
|
u_int mo_bank; /* register bank number */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the address that would map the given device at the given
|
|
|
|
* offset, allowing for the given protection, or return -1 for error.
|
|
|
|
*
|
|
|
|
* XXX needs testing against `demanding' applications (e.g., aviator)
|
|
|
|
*/
|
|
|
|
paddr_t
|
2009-03-14 18:35:58 +03:00
|
|
|
tcxmmap(dev_t dev, off_t off, int prot)
|
2000-08-21 02:27:07 +04:00
|
|
|
{
|
2008-06-12 01:25:31 +04:00
|
|
|
struct tcx_softc *sc = device_lookup_private(&tcx_cd, minor(dev));
|
2009-08-19 07:35:32 +04:00
|
|
|
struct openprom_addr *rr = sc->sc_physaddr;
|
2002-03-27 13:14:17 +03:00
|
|
|
struct mmo *mo, *mo_end;
|
2000-08-21 02:27:07 +04:00
|
|
|
u_int u, sz;
|
|
|
|
static struct mmo mmo[] = {
|
|
|
|
{ TCX_USER_RAM, 0, TCX_REG_DFB8 },
|
|
|
|
{ TCX_USER_RAM24, 0, TCX_REG_DFB24 },
|
|
|
|
{ TCX_USER_RAM_COMPAT, 0, TCX_REG_DFB8 },
|
|
|
|
|
|
|
|
{ TCX_USER_STIP, 1, TCX_REG_STIP },
|
|
|
|
{ TCX_USER_BLIT, 1, TCX_REG_BLIT },
|
2002-03-27 13:14:17 +03:00
|
|
|
{ TCX_USER_RDFB32, 0, TCX_REG_RDFB32 },
|
2000-08-21 02:27:07 +04:00
|
|
|
{ TCX_USER_RSTIP, 1, TCX_REG_RSTIP },
|
|
|
|
{ TCX_USER_RBLIT, 1, TCX_REG_RBLIT },
|
|
|
|
{ TCX_USER_TEC, 1, TCX_REG_TEC },
|
|
|
|
{ TCX_USER_BTREGS, 8192 /* XXX */, TCX_REG_CMAP },
|
2009-08-27 02:36:07 +04:00
|
|
|
{ TCX_USER_THC, 0x2000, TCX_REG_THC },
|
2000-08-21 02:27:07 +04:00
|
|
|
{ TCX_USER_DHC, 1, TCX_REG_DHC },
|
|
|
|
{ TCX_USER_ALT, 1, TCX_REG_ALT },
|
|
|
|
{ TCX_USER_ROM, 65536, TCX_REG_ROM },
|
|
|
|
};
|
|
|
|
#define NMMO (sizeof mmo / sizeof *mmo)
|
|
|
|
|
|
|
|
if (off & PGOFSET)
|
|
|
|
panic("tcxmmap");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Entries with size 0 map video RAM (i.e., the size in fb data).
|
2002-03-27 13:14:17 +03:00
|
|
|
* Entries that map 32-bit deep regions are adjusted for their
|
|
|
|
* depth (fb_size gives the size of the 8-bit-deep region).
|
2000-08-21 02:27:07 +04:00
|
|
|
*
|
|
|
|
* Since we work in pages, the fact that the map offset table's
|
|
|
|
* sizes are sometimes bizarre (e.g., 1) is effectively ignored:
|
|
|
|
* one byte is as good as one page.
|
|
|
|
*/
|
2009-08-19 07:35:32 +04:00
|
|
|
|
2002-03-27 13:14:17 +03:00
|
|
|
mo = mmo;
|
|
|
|
mo_end = &mmo[NMMO];
|
2009-08-19 07:35:32 +04:00
|
|
|
|
2002-03-27 13:14:17 +03:00
|
|
|
for (; mo < mo_end; mo++) {
|
2000-08-21 02:27:07 +04:00
|
|
|
if ((u_int)off < mo->mo_uaddr)
|
|
|
|
continue;
|
2009-08-27 02:36:07 +04:00
|
|
|
|
2000-08-21 02:27:07 +04:00
|
|
|
u = off - mo->mo_uaddr;
|
2002-03-27 13:14:17 +03:00
|
|
|
sz = mo->mo_size;
|
2009-08-27 02:36:07 +04:00
|
|
|
|
2002-03-27 13:14:17 +03:00
|
|
|
if (sz == 0) {
|
|
|
|
sz = sc->sc_fb.fb_type.fb_size;
|
|
|
|
/*
|
|
|
|
* check for the 32-bit-deep regions and adjust
|
|
|
|
* accordingly
|
|
|
|
*/
|
|
|
|
if (mo->mo_uaddr == TCX_USER_RAM24 ||
|
|
|
|
mo->mo_uaddr == TCX_USER_RDFB32) {
|
|
|
|
if (sc->sc_8bit) {
|
|
|
|
/*
|
|
|
|
* not present on 8-bit hardware
|
|
|
|
*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
sz *= 4;
|
|
|
|
}
|
|
|
|
}
|
2009-08-27 02:36:07 +04:00
|
|
|
if (sz == 1)
|
|
|
|
sz = rr[mo->mo_bank].oa_size;
|
|
|
|
|
2000-08-21 02:27:07 +04:00
|
|
|
if (u < sz) {
|
2001-09-25 03:49:31 +04:00
|
|
|
return (bus_space_mmap(sc->sc_bustag,
|
2002-08-23 06:53:10 +04:00
|
|
|
BUS_ADDR(rr[mo->mo_bank].oa_space,
|
|
|
|
rr[mo->mo_bank].oa_base),
|
2001-09-25 03:49:31 +04:00
|
|
|
u,
|
|
|
|
prot,
|
|
|
|
BUS_SPACE_MAP_LINEAR));
|
2000-08-21 02:27:07 +04:00
|
|
|
}
|
|
|
|
}
|
2001-09-25 03:49:31 +04:00
|
|
|
return (-1);
|
2000-08-21 02:27:07 +04:00
|
|
|
}
|
2009-08-06 22:26:03 +04:00
|
|
|
|
|
|
|
int
|
|
|
|
tcx_ioctl(void *v, void *vs, u_long cmd, void *data, int flag,
|
|
|
|
struct lwp *l)
|
|
|
|
{
|
|
|
|
struct vcons_data *vd = v;
|
|
|
|
struct tcx_softc *sc = vd->cookie;
|
|
|
|
struct wsdisplay_fbinfo *wdf;
|
|
|
|
struct vcons_screen *ms = vd->active;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case WSDISPLAYIO_GTYPE:
|
|
|
|
*(u_int *)data = WSDISPLAY_TYPE_SUNTCX;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case FBIOGVIDEO:
|
|
|
|
case WSDISPLAYIO_GVIDEO:
|
2009-08-19 07:45:51 +04:00
|
|
|
*(int *)data = !sc->sc_blanked;
|
2009-08-06 22:26:03 +04:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WSDISPLAYIO_SVIDEO:
|
|
|
|
case FBIOSVIDEO:
|
|
|
|
tcx_set_video(sc, *(int *)data);
|
|
|
|
return 0;
|
2009-08-19 07:45:51 +04:00
|
|
|
|
2009-08-06 22:26:03 +04:00
|
|
|
case WSDISPLAYIO_GINFO:
|
|
|
|
wdf = (void *)data;
|
|
|
|
wdf->height = ms->scr_ri.ri_height;
|
|
|
|
wdf->width = ms->scr_ri.ri_width;
|
2009-08-19 07:35:32 +04:00
|
|
|
if (sc->sc_8bit) {
|
|
|
|
wdf->depth = 8;
|
|
|
|
} else {
|
|
|
|
wdf->depth = 32;
|
|
|
|
}
|
2009-08-06 22:26:03 +04:00
|
|
|
wdf->cmsize = 256;
|
|
|
|
return 0;
|
2009-08-19 07:35:32 +04:00
|
|
|
case WSDISPLAYIO_LINEBYTES:
|
|
|
|
{
|
|
|
|
int *ret = (int *)data;
|
|
|
|
*ret = sc->sc_8bit ? ms->scr_ri.ri_width :
|
|
|
|
ms->scr_ri.ri_width << 2;
|
|
|
|
}
|
|
|
|
return 0;
|
2009-08-06 22:26:03 +04:00
|
|
|
#if 0
|
|
|
|
case WSDISPLAYIO_GETCMAP:
|
|
|
|
return tcx_getcmap(sc, (struct wsdisplay_cmap *)data);
|
|
|
|
|
|
|
|
case WSDISPLAYIO_PUTCMAP:
|
|
|
|
return tcx_putcmap(sc, (struct wsdisplay_cmap *)data);
|
|
|
|
#endif
|
|
|
|
case WSDISPLAYIO_SMODE:
|
|
|
|
{
|
|
|
|
int new_mode = *(int*)data;
|
|
|
|
if (new_mode != sc->sc_mode)
|
|
|
|
{
|
|
|
|
sc->sc_mode = new_mode;
|
|
|
|
if (new_mode == WSDISPLAYIO_MODE_EMUL)
|
|
|
|
{
|
2014-07-22 08:55:51 +04:00
|
|
|
tcx_init_cmap(sc);
|
2009-08-20 00:51:47 +04:00
|
|
|
tcx_clearscreen(sc, 0);
|
2009-08-06 22:26:03 +04:00
|
|
|
vcons_redraw_screen(ms);
|
2009-08-20 00:51:47 +04:00
|
|
|
} else if (!sc->sc_8bit)
|
|
|
|
tcx_clearscreen(sc, 3);
|
2009-08-06 22:26:03 +04:00
|
|
|
}
|
|
|
|
}
|
2014-06-18 08:54:09 +04:00
|
|
|
return 0;
|
|
|
|
|
2009-08-20 04:59:28 +04:00
|
|
|
case WSDISPLAYIO_GCURPOS:
|
2014-06-18 08:54:09 +04:00
|
|
|
if (sc->sc_8bit) {
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
} else {
|
2009-08-20 04:59:28 +04:00
|
|
|
struct wsdisplay_curpos *cp = (void *)data;
|
|
|
|
|
|
|
|
cp->x = sc->sc_cursor_x;
|
|
|
|
cp->y = sc->sc_cursor_y;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WSDISPLAYIO_SCURPOS:
|
2014-06-18 08:54:09 +04:00
|
|
|
if (sc->sc_8bit) {
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
} else {
|
2009-08-20 04:59:28 +04:00
|
|
|
struct wsdisplay_curpos *cp = (void *)data;
|
|
|
|
|
|
|
|
sc->sc_cursor_x = cp->x;
|
|
|
|
sc->sc_cursor_y = cp->y;
|
|
|
|
tcx_set_cursor(sc);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WSDISPLAYIO_GCURMAX:
|
2014-06-18 08:54:09 +04:00
|
|
|
if (sc->sc_8bit) {
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
} else {
|
2009-08-20 04:59:28 +04:00
|
|
|
struct wsdisplay_curpos *cp = (void *)data;
|
|
|
|
|
|
|
|
cp->x = 32;
|
|
|
|
cp->y = 32;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case WSDISPLAYIO_SCURSOR:
|
2014-06-18 08:54:09 +04:00
|
|
|
if (sc->sc_8bit) {
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
} else {
|
2009-08-20 04:59:28 +04:00
|
|
|
struct wsdisplay_cursor *cursor = (void *)data;
|
|
|
|
|
|
|
|
return tcx_do_cursor(sc, cursor);
|
|
|
|
}
|
2009-08-06 22:26:03 +04:00
|
|
|
}
|
|
|
|
return EPASSTHROUGH;
|
|
|
|
}
|
|
|
|
|
|
|
|
static paddr_t
|
|
|
|
tcx_mmap(void *v, void *vs, off_t offset, int prot)
|
|
|
|
{
|
|
|
|
struct vcons_data *vd = v;
|
|
|
|
struct tcx_softc *sc = vd->cookie;
|
|
|
|
|
|
|
|
/* 'regular' framebuffer mmap()ing */
|
2009-08-19 07:35:32 +04:00
|
|
|
if (sc->sc_8bit) {
|
|
|
|
/* on 8Bit boards hand over the 8 bit aperture */
|
2014-06-17 18:25:17 +04:00
|
|
|
if (offset > sc->sc_fbsize)
|
2009-08-19 07:35:32 +04:00
|
|
|
return -1;
|
|
|
|
return bus_space_mmap(sc->sc_bustag,
|
|
|
|
sc->sc_physaddr[TCX_REG_DFB8].oa_base + offset, 0, prot,
|
2009-08-06 22:26:03 +04:00
|
|
|
BUS_SPACE_MAP_LINEAR);
|
2009-08-19 07:35:32 +04:00
|
|
|
} else {
|
|
|
|
/* ... but if we have a 24bit aperture we use it */
|
2014-06-17 18:25:17 +04:00
|
|
|
if (offset > sc->sc_fbsize * 4)
|
2009-08-19 07:35:32 +04:00
|
|
|
return -1;
|
|
|
|
return bus_space_mmap(sc->sc_bustag,
|
|
|
|
sc->sc_physaddr[TCX_REG_DFB24].oa_base + offset, 0, prot,
|
2009-08-06 22:26:03 +04:00
|
|
|
BUS_SPACE_MAP_LINEAR);
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tcx_init_screen(void *cookie, struct vcons_screen *scr,
|
|
|
|
int existing, long *defattr)
|
|
|
|
{
|
|
|
|
struct tcx_softc *sc = cookie;
|
|
|
|
struct rasops_info *ri = &scr->scr_ri;
|
|
|
|
|
|
|
|
ri->ri_depth = 8;
|
|
|
|
ri->ri_width = sc->sc_fb.fb_type.fb_width;
|
|
|
|
ri->ri_height = sc->sc_fb.fb_type.fb_height;
|
|
|
|
ri->ri_stride = sc->sc_fb.fb_linebytes;
|
|
|
|
ri->ri_flg = RI_CENTER | RI_FULLCLEAR;
|
|
|
|
|
|
|
|
ri->ri_bits = sc->sc_fbaddr;
|
|
|
|
|
2012-01-11 20:08:57 +04:00
|
|
|
rasops_init(ri, 0, 0);
|
2009-08-06 22:26:03 +04:00
|
|
|
ri->ri_caps = WSSCREEN_WSCOLORS;
|
|
|
|
rasops_reconfig(ri, ri->ri_height / ri->ri_font->fontheight,
|
|
|
|
ri->ri_width / ri->ri_font->fontwidth);
|
|
|
|
|
|
|
|
/* enable acceleration */
|
|
|
|
ri->ri_ops.copyrows = tcx_copyrows;
|
|
|
|
ri->ri_ops.eraserows = tcx_eraserows;
|
|
|
|
ri->ri_ops.putchar = tcx_putchar;
|
|
|
|
#if 0
|
|
|
|
ri->ri_ops.cursor = tcx_cursor;
|
|
|
|
ri->ri_ops.copycols = tcx_copycols;
|
|
|
|
ri->ri_ops.erasecols = tcx_erasecols;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-20 00:51:47 +04:00
|
|
|
tcx_clearscreen(struct tcx_softc *sc, int spc)
|
2009-08-06 22:26:03 +04:00
|
|
|
{
|
2014-06-17 18:25:17 +04:00
|
|
|
/* ROP in the upper 4bit is necessary, tcx actually uses it */
|
2016-09-23 20:45:25 +03:00
|
|
|
volatile uint64_t bg = 0x30000000ffffffffLL;
|
|
|
|
volatile uint64_t spc64;
|
2014-06-17 18:25:17 +04:00
|
|
|
int i, len;
|
2009-08-06 22:26:03 +04:00
|
|
|
|
2016-09-23 20:45:25 +03:00
|
|
|
spc64 = ((spc & 3) << 24);
|
2014-07-07 19:22:07 +04:00
|
|
|
bg |= (spc64 << 32);
|
2009-08-20 00:51:47 +04:00
|
|
|
|
2014-06-17 18:25:17 +04:00
|
|
|
len = sc->sc_fb.fb_type.fb_width * sc->sc_fb.fb_type.fb_height;
|
|
|
|
for (i = 0; i < len; i += 32)
|
|
|
|
sc->sc_rstip[i] = bg;
|
2009-08-06 22:26:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tcx_copyrows(void *cookie, int srcrow, int dstrow, int nrows)
|
|
|
|
{
|
|
|
|
struct rasops_info *ri = cookie;
|
|
|
|
struct vcons_screen *scr = ri->ri_hw;
|
|
|
|
struct tcx_softc *sc = scr->scr_cookie;
|
|
|
|
int i, last, first, len, dest, leftover;
|
|
|
|
|
|
|
|
i = ri->ri_width * ri->ri_font->fontheight * nrows;
|
|
|
|
len = i & 0xffffe0;
|
|
|
|
leftover = i & 0x1f;
|
|
|
|
if (srcrow < dstrow) {
|
|
|
|
/* we must go bottom to top */
|
|
|
|
first = ri->ri_width *
|
|
|
|
(ri->ri_font->fontheight * srcrow + ri->ri_yorigin);
|
|
|
|
last = first + len;
|
|
|
|
dest = ri->ri_width *
|
|
|
|
(ri->ri_font->fontheight * dstrow + ri->ri_yorigin) + len;
|
|
|
|
if (leftover > 0) {
|
|
|
|
sc->sc_rblit[dest + 32] =
|
|
|
|
(uint64_t)((leftover - 1) << 24) |
|
|
|
|
(uint64_t)(i + 32);
|
|
|
|
}
|
|
|
|
for (i = last; i >= first; i -= 32) {
|
|
|
|
sc->sc_rblit[dest] = 0x300000001f000000LL | (uint64_t)i;
|
|
|
|
dest -= 32;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* top to bottom */
|
|
|
|
first = ri->ri_width *
|
|
|
|
(ri->ri_font->fontheight * srcrow + ri->ri_yorigin);
|
|
|
|
dest = ri->ri_width *
|
|
|
|
(ri->ri_font->fontheight * dstrow + ri->ri_yorigin);
|
|
|
|
last = first + len;
|
|
|
|
for (i = first; i <= last; i+= 32) {
|
|
|
|
sc->sc_rblit[dest] = 0x300000001f000000LL | (uint64_t)i;
|
|
|
|
dest += 32;
|
|
|
|
}
|
|
|
|
if (leftover > 0) {
|
|
|
|
sc->sc_rblit[dest] =
|
|
|
|
(uint64_t)((leftover - 1) << 24) | (uint64_t)i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tcx_eraserows(void *cookie, int start, int nrows, long attr)
|
|
|
|
{
|
|
|
|
struct rasops_info *ri = cookie;
|
|
|
|
struct vcons_screen *scr = ri->ri_hw;
|
|
|
|
struct tcx_softc *sc = scr->scr_cookie;
|
2016-09-23 20:45:25 +03:00
|
|
|
volatile uint64_t temp;
|
2009-08-06 22:26:03 +04:00
|
|
|
int i, last, first, len, leftover;
|
|
|
|
|
|
|
|
i = ri->ri_width * ri->ri_font->fontheight * nrows;
|
|
|
|
len = i & 0xffffe0;
|
|
|
|
leftover = i & 0x1f;
|
|
|
|
first = ri->ri_width *
|
|
|
|
(ri->ri_font->fontheight * start + ri->ri_yorigin);
|
|
|
|
last = first + len;
|
|
|
|
temp = 0x30000000ffffffffLL |
|
2016-09-23 20:45:25 +03:00
|
|
|
((uint64_t)((ri->ri_devcmap[(attr >> 16) & 0xff]) & 0xff) << 32);
|
2009-08-06 22:26:03 +04:00
|
|
|
|
2016-09-23 20:45:25 +03:00
|
|
|
for (i = first; i < last; i+= 32)
|
|
|
|
sc->sc_rstip[i] = temp;
|
2009-08-06 22:26:03 +04:00
|
|
|
|
|
|
|
if (leftover > 0) {
|
|
|
|
temp &= 0xffffffffffffffffLL << (32 - leftover);
|
2016-09-23 20:45:25 +03:00
|
|
|
sc->sc_rstip[i] = temp;
|
2009-08-06 22:26:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* The stipple engine is 100% retarded. All drawing operations have to start
|
|
|
|
* at 32 pixel boundaries so we'll have to deal with characters being split.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
tcx_putchar(void *cookie, int row, int col, u_int c, long attr)
|
|
|
|
{
|
|
|
|
struct rasops_info *ri = cookie;
|
2010-05-04 09:10:25 +04:00
|
|
|
struct wsdisplay_font *font = PICK_FONT(ri, c);
|
2009-08-06 22:26:03 +04:00
|
|
|
struct vcons_screen *scr = ri->ri_hw;
|
|
|
|
struct tcx_softc *sc = scr->scr_cookie;
|
2016-09-23 20:45:25 +03:00
|
|
|
volatile uint64_t bg, fg, temp, mask;
|
2009-08-06 22:26:03 +04:00
|
|
|
int addr, i, uc, shift;
|
|
|
|
uint32_t fmask;
|
|
|
|
uint8_t *cdata;
|
|
|
|
uint16_t *wdata;
|
|
|
|
|
2010-05-04 09:10:25 +04:00
|
|
|
addr = ri->ri_xorigin + col * font->fontwidth +
|
|
|
|
(ri->ri_yorigin + row * font->fontheight) * ri->ri_width;
|
2009-08-06 22:26:03 +04:00
|
|
|
|
|
|
|
/* check if the character is crossing a 32 pixel boundary */
|
|
|
|
if ((addr & 0xffffe0) ==
|
2010-05-04 09:10:25 +04:00
|
|
|
((addr + font->fontwidth - 1) & 0xffffe0)) {
|
2009-08-06 22:26:03 +04:00
|
|
|
/* phew, not split */
|
|
|
|
shift = addr & 0x1f;
|
|
|
|
addr &= 0xffffe0;
|
2010-05-04 09:10:25 +04:00
|
|
|
fmask = 0xffffffff >> (32 - font->fontwidth);
|
|
|
|
fmask = fmask << (32 - font->fontwidth - shift);
|
2009-08-06 22:26:03 +04:00
|
|
|
mask = fmask;
|
|
|
|
bg = 0x3000000000000000LL |
|
|
|
|
((uint64_t)ri->ri_devcmap[(attr >> 16) & 0xff] &
|
|
|
|
0xff) << 32;
|
|
|
|
bg |= mask;
|
|
|
|
temp = 0x3000000000000000LL |
|
|
|
|
((uint64_t)ri->ri_devcmap[(attr >> 24) & 0xff] & 0xff) <<
|
|
|
|
32;
|
2010-05-04 09:10:25 +04:00
|
|
|
uc = c - font->firstchar;
|
|
|
|
cdata = (uint8_t *)font->data + uc * ri->ri_fontscale;
|
2009-08-06 22:26:03 +04:00
|
|
|
|
2010-05-04 09:10:25 +04:00
|
|
|
if (font->fontwidth < 9) {
|
2009-08-06 22:26:03 +04:00
|
|
|
/* byte by byte */
|
2010-05-04 09:10:25 +04:00
|
|
|
for (i = 0; i < font->fontheight; i++) {
|
2009-08-06 22:26:03 +04:00
|
|
|
sc->sc_rstip[addr] = bg;
|
|
|
|
if (*cdata != 0) {
|
|
|
|
if (shift > 24) {
|
|
|
|
fg = (uint64_t)*cdata >>
|
|
|
|
(shift - 24);
|
|
|
|
} else {
|
|
|
|
fg = (uint64_t)*cdata <<
|
|
|
|
(24 - shift);
|
|
|
|
}
|
|
|
|
sc->sc_rstip[addr] = fg | temp;
|
|
|
|
}
|
|
|
|
cdata++;
|
|
|
|
addr += ri->ri_width;
|
|
|
|
}
|
2010-05-04 09:10:25 +04:00
|
|
|
} else if (font->fontwidth < 17) {
|
2009-08-06 22:26:03 +04:00
|
|
|
/* short by short */
|
|
|
|
wdata = (uint16_t *)cdata;
|
2010-05-04 09:10:25 +04:00
|
|
|
for (i = 0; i < font->fontheight; i++) {
|
2009-08-06 22:26:03 +04:00
|
|
|
sc->sc_rstip[addr] = bg;
|
|
|
|
if (*wdata != 0) {
|
|
|
|
if (shift > 16) {
|
|
|
|
fg = temp | (uint64_t)*wdata >>
|
|
|
|
(shift - 16);
|
|
|
|
} else {
|
|
|
|
fg = temp | (uint64_t)*wdata <<
|
|
|
|
(16 - shift);
|
|
|
|
}
|
|
|
|
sc->sc_rstip[addr] = fg;
|
|
|
|
}
|
|
|
|
wdata++;
|
|
|
|
addr += ri->ri_width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* and now the split case ( man this hardware is dumb ) */
|
2016-09-23 20:45:25 +03:00
|
|
|
volatile uint64_t bgr, maskr, fgr;
|
2009-08-06 22:26:03 +04:00
|
|
|
uint32_t bork;
|
|
|
|
|
|
|
|
shift = addr & 0x1f;
|
|
|
|
addr &= 0xffffe0;
|
|
|
|
mask = 0xffffffff >> shift;
|
|
|
|
maskr = (uint64_t)(0xffffffffUL <<
|
2010-05-04 09:10:25 +04:00
|
|
|
(32 - (font->fontwidth + shift - 32)));
|
2009-08-06 22:26:03 +04:00
|
|
|
bg = 0x3000000000000000LL |
|
|
|
|
((uint64_t)ri->ri_devcmap[(attr >> 16) & 0xff] &
|
|
|
|
0xff) << 32;
|
|
|
|
bgr = bg | maskr;
|
|
|
|
bg |= mask;
|
|
|
|
temp = 0x3000000000000000LL |
|
|
|
|
((uint64_t)ri->ri_devcmap[(attr >> 24) & 0xff] & 0xff) <<
|
|
|
|
32;
|
|
|
|
|
2010-05-04 09:10:25 +04:00
|
|
|
uc = c - font->firstchar;
|
|
|
|
cdata = (uint8_t *)font->data + uc * ri->ri_fontscale;
|
2009-08-06 22:26:03 +04:00
|
|
|
|
2010-05-04 09:10:25 +04:00
|
|
|
if (font->fontwidth < 9) {
|
2009-08-06 22:26:03 +04:00
|
|
|
/* byte by byte */
|
2010-05-04 09:10:25 +04:00
|
|
|
for (i = 0; i < font->fontheight; i++) {
|
2009-08-06 22:26:03 +04:00
|
|
|
sc->sc_rstip[addr] = bg;
|
|
|
|
sc->sc_rstip[addr + 32] = bgr;
|
|
|
|
bork = *cdata;
|
|
|
|
if (bork != 0) {
|
|
|
|
fg = (uint64_t)bork >> (shift - 24);
|
|
|
|
sc->sc_rstip[addr] = fg | temp;
|
|
|
|
fgr = (uint64_t)(bork << (52 - shift));
|
|
|
|
sc->sc_rstip[addr] = fgr | temp;
|
|
|
|
}
|
|
|
|
cdata++;
|
|
|
|
addr += ri->ri_width;
|
|
|
|
}
|
2010-05-04 09:10:25 +04:00
|
|
|
} else if (font->fontwidth < 17) {
|
2009-08-06 22:26:03 +04:00
|
|
|
/* short by short */
|
|
|
|
wdata = (uint16_t *)cdata;
|
2010-05-04 09:10:25 +04:00
|
|
|
for (i = 0; i < font->fontheight; i++) {
|
2009-08-06 22:26:03 +04:00
|
|
|
sc->sc_rstip[addr] = bg;
|
|
|
|
sc->sc_rstip[addr + 32] = bgr;
|
|
|
|
bork = *wdata;
|
|
|
|
if (bork != 0) {
|
|
|
|
fg = (uint64_t)bork >> (shift - 16);
|
|
|
|
sc->sc_rstip[addr] = fg | temp;
|
|
|
|
fgr = (uint64_t)(bork << (48 - shift));
|
|
|
|
sc->sc_rstip[addr + 32] = fgr | temp;
|
|
|
|
}
|
|
|
|
wdata++;
|
|
|
|
addr += ri->ri_width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-20 04:59:28 +04:00
|
|
|
static int
|
|
|
|
tcx_do_cursor(struct tcx_softc *sc, struct wsdisplay_cursor *cur)
|
|
|
|
{
|
2014-06-18 08:54:09 +04:00
|
|
|
if (sc->sc_8bit) {
|
|
|
|
/* hw cursor is not implemented on tcx */
|
|
|
|
return -1;
|
|
|
|
}
|
2009-08-20 04:59:28 +04:00
|
|
|
if (cur->which & WSDISPLAY_CURSOR_DOCUR) {
|
|
|
|
|
|
|
|
if (cur->enable) {
|
|
|
|
tcx_set_cursor(sc);
|
|
|
|
} else {
|
|
|
|
/* move the cursor out of sight */
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_thc,
|
|
|
|
THC_CURSOR_POS, 0x7fff7fff);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cur->which & WSDISPLAY_CURSOR_DOHOT) {
|
|
|
|
|
|
|
|
sc->sc_hotspot_x = cur->hot.x;
|
|
|
|
sc->sc_hotspot_y = cur->hot.y;
|
|
|
|
tcx_set_cursor(sc);
|
|
|
|
}
|
|
|
|
if (cur->which & WSDISPLAY_CURSOR_DOPOS) {
|
|
|
|
|
|
|
|
sc->sc_cursor_x = cur->pos.x;
|
|
|
|
sc->sc_cursor_y = cur->pos.y;
|
|
|
|
tcx_set_cursor(sc);
|
|
|
|
}
|
|
|
|
if (cur->which & WSDISPLAY_CURSOR_DOCMAP) {
|
|
|
|
#if 0
|
2009-08-20 06:01:55 +04:00
|
|
|
/*
|
|
|
|
* apparently we're not writing in the right register here - if we do
|
|
|
|
* this the screen goes all funky
|
|
|
|
*/
|
2009-08-20 04:59:28 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < cur->cmap.count; i++) {
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_bt, DAC_ADDRESS,
|
|
|
|
(cur->cmap.index + i + 2) << 24);
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_bt,
|
|
|
|
DAC_CURSOR_LUT, cur->cmap.red[i] << 24);
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_bt,
|
|
|
|
DAC_CURSOR_LUT, cur->cmap.green[i] << 24);
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_bt,
|
|
|
|
DAC_CURSOR_LUT, cur->cmap.blue[i] << 24);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
if (cur->which & WSDISPLAY_CURSOR_DOSHAPE) {
|
|
|
|
int i;
|
|
|
|
uint32_t temp, poof;
|
|
|
|
|
|
|
|
for (i = 0; i < 128; i += 4) {
|
|
|
|
memcpy(&temp, &cur->mask[i], 4);
|
|
|
|
printf("%08x -> ", temp);
|
|
|
|
poof = ((temp & 0x80808080) >> 7) |
|
|
|
|
((temp & 0x40404040) >> 5) |
|
|
|
|
((temp & 0x20202020) >> 3) |
|
|
|
|
((temp & 0x10101010) >> 1) |
|
|
|
|
((temp & 0x08080808) << 1) |
|
|
|
|
((temp & 0x04040404) << 3) |
|
|
|
|
((temp & 0x02020202) << 5) |
|
|
|
|
((temp & 0x01010101) << 7);
|
|
|
|
printf("%08x\n", poof);
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_thc,
|
|
|
|
THC_CURSOR_1 + i, poof);
|
|
|
|
memcpy(&temp, &cur->image[i], 4);
|
|
|
|
poof = ((temp & 0x80808080) >> 7) |
|
|
|
|
((temp & 0x40404040) >> 5) |
|
|
|
|
((temp & 0x20202020) >> 3) |
|
|
|
|
((temp & 0x10101010) >> 1) |
|
|
|
|
((temp & 0x08080808) << 1) |
|
|
|
|
((temp & 0x04040404) << 3) |
|
|
|
|
((temp & 0x02020202) << 5) |
|
|
|
|
((temp & 0x01010101) << 7);
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_thc,
|
|
|
|
THC_CURSOR_0 + i, poof);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tcx_set_cursor(struct tcx_softc *sc)
|
|
|
|
{
|
|
|
|
uint32_t reg;
|
|
|
|
|
|
|
|
reg = (sc->sc_cursor_x - sc->sc_hotspot_x) << 16 |
|
|
|
|
((sc->sc_cursor_y - sc->sc_hotspot_y) & 0xffff);
|
|
|
|
bus_space_write_4(sc->sc_bustag, sc->sc_thc, THC_CURSOR_POS, reg);
|
|
|
|
}
|
|
|
|
|