1
0
mirror of synced 2026-02-09 17:21:16 +00:00

forward port HW cursor from cg6, still some issues (sw or hw???) + untested sw fix

This commit is contained in:
Romain Dolbeau
2022-03-20 09:24:48 +01:00
parent 938d931e51
commit f5822c8385
10 changed files with 195 additions and 7 deletions

View File

@@ -308,6 +308,25 @@ goblinattach(struct goblin_softc *sc, const char *name, int isconsole)
/* Initialize the default color map. */
gobo_setup_palette(sc);
/* reset the HW cursor */
{
volatile struct goblin_fbcontrol *sc_fbc = sc->sc_fbc;
sc_fbc->cursor_xy = 0xFFE0FFE0;
sc_fbc->lut_addr = 0;
sc_fbc->cursor_lut = 0;
sc_fbc->cursor_lut = 0;
sc_fbc->cursor_lut = 0;
sc_fbc->cursor_lut = 0xFF; // bg color
sc_fbc->cursor_lut = 0xFF;
sc_fbc->cursor_lut = 0xFF;
sc_fbc->cursor_lut = 0;
sc_fbc->cursor_lut = 0;
sc_fbc->cursor_lut = 0;
sc_fbc->cursor_lut = 0; // fb color
sc_fbc->cursor_lut = 0;
sc_fbc->cursor_lut = 0;
}
aa.scrdata = &goblin_screenlist;
aa.console = isconsole;
aa.accessops = &goblin_accessops;

View File

@@ -37,9 +37,14 @@
#define GOBOFB_VBL_MASK 0x4
#define GOBOFB_VIDEOCTRL 0x8
#define GOBOFB_INTR_CLEAR 0xc
#define GOBOFB_RESET 0x10
#define GOBOFB_RESET 0x10 /* unused */
#define GOBOFB_LUT_ADDR 0x14
#define GOBOFB_LUT 0x18
#define GOBOFB_DEBUG 0x1c /* SW only */
#define GOBOFB_CURSOR_LUT 0x20
#define GOBOFB_CURSOR_XY 0x24
#define GOBOFB_MASK_BASE 0x80
#define GOBOFB_BITS_BASE 0x100
#define GOBOFB_MODE_1BIT 0x0
#define GOBOFB_MODE_2BIT 0x1

View File

@@ -34,13 +34,20 @@
*/
struct goblin_fbcontrol {
uint32_t mode;
uint32_t mode; /* 0 */
uint32_t vbl_mask;
uint32_t videoctrl;
uint32_t intr_clear;
uint32_t reset;
uint32_t reset; /* 4 */
uint32_t lut_addr;
uint32_t lut;
uint32_t debug;
uint32_t cursor_lut; /* 8 */
uint32_t cursor_xy;
uint32_t padding[6]; /* 0xa..0xf */
uint32_t padding2[16]; /* 0x10 .. 0x1f */
uint32_t curmask[32]; /* 0x20 .. 0x3f */
uint32_t curbits[32]; /* 0x40 .. 0x5f */
};
/* per-display variables */

View File

@@ -31,6 +31,7 @@ goblin_drv_ladir = @moduledir@/drivers
goblin_drv_la_SOURCES = \
goblin_driver.c \
goblin_cursor.c \
goblin.h \
goblin_regs.h \
compat-api.h

View File

@@ -111,7 +111,7 @@ am__uninstall_files_from_dir = { \
am__installdirs = "$(DESTDIR)$(goblin_drv_ladir)"
LTLIBRARIES = $(goblin_drv_la_LTLIBRARIES)
goblin_drv_la_LIBADD =
am_goblin_drv_la_OBJECTS = goblin_driver.lo
am_goblin_drv_la_OBJECTS = goblin_driver.lo goblin_cursor.lo
goblin_drv_la_OBJECTS = $(am_goblin_drv_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -317,6 +317,7 @@ goblin_drv_la_LDFLAGS = -module -avoid-version
goblin_drv_ladir = @moduledir@/drivers
goblin_drv_la_SOURCES = \
goblin_driver.c \
goblin_cursor.c \
goblin.h \
goblin_regs.h \
compat-api.h

View File

@@ -80,6 +80,11 @@ typedef struct {
int fillrop_off, fillrop_len;
int copy_off, copy_len;
int copyrev_off, copyrev_len;
xf86CursorInfoPtr CursorInfoRec;
unsigned int CursorXY;
int CursorBg, CursorFg;
Bool CursorEnabled;
} GoblinRec, *GoblinPtr;
extern int GoblinScreenPrivateIndex;
@@ -100,6 +105,9 @@ extern int GoblinWindowPrivateIndex;
#define GoblinSetWindowPrivate(w,p) \
((w)->devPrivates[GoblinWindowPrivateIndex].ptr = (pointer) p)
Bool GOBLINHWCursorInit(ScreenPtr pScreen);
extern int goblinRopTable[];
int GOBLINAccelInit(ScrnInfoPtr);

View File

@@ -0,0 +1,137 @@
/*
* Hardware cursor support for Goblin
*
* Copyright 2000 by Jakub Jelinek <jakub@redhat.com>.
* Copyright 2022 by Jakub Jelinek <romain@Êolbeau.org>
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of Jakub
* Jelinek not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior
* permission. Jakub Jelinek makes no representations about the
* suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* JAKUB JELINEK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL JAKUB JELINEK BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "goblin.h"
static void GOBLINLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src);
static void GOBLINShowCursor(ScrnInfoPtr pScrn);
static void GOBLINHideCursor(ScrnInfoPtr pScrn);
static void GOBLINSetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
static void GOBLINSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg);
static void
GOBLINLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
{
GoblinPtr pGoblin = GET_GOBLIN_FROM_SCRN(pScrn);
int i;
unsigned int *data = (unsigned int *)src;
for (i = 0; i < 32; i++)
pGoblin->fbc->curmask[i] = *data++;
for (i = 0; i < 32; i++)
pGoblin->fbc->curbits[i] = *data++;
}
static void
GOBLINShowCursor(ScrnInfoPtr pScrn)
{
GoblinPtr pGoblin = GET_GOBLIN_FROM_SCRN(pScrn);
pGoblin->fbc->cursor_xy = pGoblin->CursorXY;
pGoblin->CursorEnabled = TRUE;
}
static void
GOBLINHideCursor(ScrnInfoPtr pScrn)
{
GoblinPtr pGoblin = GET_GOBLIN_FROM_SCRN(pScrn);
pGoblin->fbc->cursor_xy = ((65536 - 32) << 16) | (65536 - 32);
pGoblin->fbc->cursor_xy = pGoblin->CursorXY;
pGoblin->CursorEnabled = FALSE;
}
static void
GOBLINSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
{
GoblinPtr pGoblin = GET_GOBLIN_FROM_SCRN(pScrn);
pGoblin->CursorXY = ((x & 0xffff) << 16) | (y & 0xffff);
if (pGoblin->CursorEnabled)
pGoblin->fbc->cursor_xy = pGoblin->CursorXY;
}
static void
GOBLINSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
{
GoblinPtr pGoblin = GET_GOBLIN_FROM_SCRN(pScrn);
if (bg != pGoblin->CursorBg || fg != pGoblin->CursorFg) {
pGoblin->fbc->lut_addr = 1; // bg color
pGoblin->fbc->cursor_lut = (bg>>16)&0xFF;
pGoblin->fbc->cursor_lut = (bg>> 8)&0xFF;
pGoblin->fbc->cursor_lut = (bg>> 0)&0xFF;
pGoblin->fbc->lut_addr = 3; // fg color
pGoblin->fbc->cursor_lut = (fg>>16)&0xFF;
pGoblin->fbc->cursor_lut = (fg>> 8)&0xFF;
pGoblin->fbc->cursor_lut = (fg>> 0)&0xFF;
xf86Msg(X_INFO, "Goblin: fg set to 0x%08x, bg set to 0x%08x\n", fg, bg);
pGoblin->CursorBg = bg;
pGoblin->CursorFg = fg;
}
}
Bool
GOBLINHWCursorInit(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
GoblinPtr pGoblin;
xf86CursorInfoPtr infoPtr;
pGoblin = GET_GOBLIN_FROM_SCRN(pScrn);
pGoblin->CursorXY = 0;
pGoblin->CursorBg = 0;
pGoblin->CursorFg = 0;
pGoblin->CursorEnabled = FALSE;
infoPtr = xf86CreateCursorInfoRec();
if(!infoPtr) return FALSE;
pGoblin->CursorInfoRec = infoPtr;
infoPtr->MaxWidth = 32;
infoPtr->MaxHeight = 32;
infoPtr->Flags = HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK |
HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED |
HARDWARE_CURSOR_TRUECOLOR_AT_8BPP;
infoPtr->SetCursorColors = GOBLINSetCursorColors;
infoPtr->SetCursorPosition = GOBLINSetCursorPosition;
infoPtr->LoadCursorImage = GOBLINLoadCursorImage;
infoPtr->HideCursor = GOBLINHideCursor;
infoPtr->ShowCursor = GOBLINShowCursor;
infoPtr->UseHWCursor = NULL;
return xf86InitCursor(pScreen, infoPtr);
}

View File

@@ -691,6 +691,9 @@ GOBLINScreenInit(SCREEN_INIT_ARGS_DECL)
/* Initialise cursor functions */
miDCInitialize (pScreen, xf86GetPointerScreenFuncs());
/* hw cursor */
GOBLINHWCursorInit(pScreen);
/* Initialise default colourmap */
if (!miCreateDefColormap(pScreen))
return FALSE;

View File

@@ -50,13 +50,20 @@
#define GOBOFB_INTR_CLEAR_CLEAR 0x0
typedef struct goblin_fbc {
volatile uint32_t mode;
volatile uint32_t mode; /* 0 */
volatile uint32_t vbl_mask;
volatile uint32_t videoctrl;
volatile uint32_t intr_clear;
volatile uint32_t reset;
volatile uint32_t reset; /* 4 */
volatile uint32_t lut_addr;
volatile uint32_t lut;
volatile uint32_t debug;
volatile uint32_t cursor_lut; /* 8 */
volatile uint32_t cursor_xy;
uint32_t padding[6]; /* 0xa..0xf */
uint32_t padding2[16]; /* 0x10 .. 0x1f */
volatile uint32_t curmask[32]; /* 0x20 .. 0x3f */
volatile uint32_t curbits[32]; /* 0x40 .. 0x5f */
} GoblinFbc, *GoblinFbcPtr;
typedef struct jareth_reg {

View File

@@ -15,7 +15,7 @@
;
sbusfpga_regionaddr_goblin_bt constant goblin-off-dac
h# 20 constant /goblin-off-dac
h# 200 constant /goblin-off-dac
h# 1000000 constant goblin-off-fb
h# SBUSFPGA_CG3_BUFSIZE constant /goblin-off-fb