Skip to content

Commit

Permalink
Support for Raspberry Pi hardware cursor
Browse files Browse the repository at this point in the history
Requires firmware changes but will detect at
run time if the firmware supports the HW cursor
and enabled/disable as necessary.

The required firmware has been in the wild for some
time so most will already have it.
  • Loading branch information
jamesh authored and jnahughes committed Nov 16, 2014
1 parent 8dec039 commit 08b084c
Show file tree
Hide file tree
Showing 7 changed files with 953 additions and 22 deletions.
6 changes: 5 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ fbturbo_drv_la_SOURCES = \
sunxi_video.c \
sunxi_video.h \
sunxi_disp_ioctl.h \
g2d_driver.h
g2d_driver.h \
raspi_hwcursor.c \
raspi_hwcursor.h \
raspi_mailbox.c \
raspi_mailbox.h

if HAVE_LIBUMP
fbturbo_drv_la_SOURCES += \
Expand Down
62 changes: 41 additions & 21 deletions src/fbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
#include "backing_store_tuner.h"
#include "sunxi_video.h"

#include "raspi_hwcursor.h"

#ifdef HAVE_LIBUMP
#include "sunxi_mali_ump_dri2.h"
#endif
Expand Down Expand Up @@ -241,7 +243,7 @@ FBDevGetRec(ScrnInfoPtr pScrn)
{
if (pScrn->driverPrivate != NULL)
return TRUE;

pScrn->driverPrivate = xnfcalloc(sizeof(FBDevRec), 1);
return TRUE;
}
Expand Down Expand Up @@ -278,11 +280,11 @@ static Bool FBDevPciProbe(DriverPtr drv, int entity_num,

if (!xf86LoadDrvSubModule(drv, "fbdevhw"))
return FALSE;

pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, NULL, NULL,
NULL, NULL, NULL, NULL);
if (pScrn) {
char *device;
char *device;
GDevPtr devSection = xf86GetDevFromEntity(pScrn->entityList[0],
pScrn->entityInstanceList[0]);

Expand All @@ -301,7 +303,7 @@ static Bool FBDevPciProbe(DriverPtr drv, int entity_num,
pScrn->ValidMode = fbdevHWValidModeWeak();

xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"claimed PCI slot %d@%d:%d:%d\n",
"claimed PCI slot %d@%d:%d:%d\n",
dev->bus, dev->domain, dev->dev, dev->func);
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"using %s\n", device ? device : "default device");
Expand Down Expand Up @@ -335,12 +337,12 @@ FBDevProbe(DriverPtr drv, int flags)
if (flags & PROBE_DETECT)
return FALSE;

if ((numDevSections = xf86MatchDevice(FBDEV_DRIVER_NAME, &devSections)) <= 0)
if ((numDevSections = xf86MatchDevice(FBDEV_DRIVER_NAME, &devSections)) <= 0)
return FALSE;

if (!xf86LoadDrvSubModule(drv, "fbdevhw"))
return FALSE;

for (i = 0; i < numDevSections; i++) {
Bool isIsa = FALSE;
Bool isPci = FALSE;
Expand All @@ -361,15 +363,15 @@ FBDevProbe(DriverPtr drv, int flags)
else
#endif
0;

}
if (fbdevHWProbe(NULL,dev,NULL)) {
pScrn = NULL;
if (isPci) {
#ifndef XSERVER_LIBPCIACCESS
/* XXX what about when there's no busID set? */
int entity;

entity = xf86ClaimPciSlot(bus,device,func,drv,
0,devSections[i],
TRUE);
Expand All @@ -386,7 +388,7 @@ FBDevProbe(DriverPtr drv, int flags)
} else if (isIsa) {
#ifdef HAVE_ISA
int entity;

entity = xf86ClaimIsaSlot(drv, 0,
devSections[i], TRUE);
pScrn = xf86ConfigIsaEntity(pScrn,0,entity,
Expand All @@ -400,11 +402,11 @@ FBDevProbe(DriverPtr drv, int flags)
devSections[i], TRUE);
pScrn = xf86ConfigFbEntity(pScrn,0,entity,
NULL,NULL,NULL,NULL);

}
if (pScrn) {
foundScreen = TRUE;

pScrn->driverVersion = FBDEV_VERSION;
pScrn->driverName = FBDEV_DRIVER_NAME;
pScrn->name = FBDEV_NAME;
Expand All @@ -416,7 +418,7 @@ FBDevProbe(DriverPtr drv, int flags)
pScrn->EnterVT = fbdevHWEnterVTWeak();
pScrn->LeaveVT = fbdevHWLeaveVTWeak();
pScrn->ValidMode = fbdevHWValidModeWeak();

xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"using %s\n", dev ? dev : "default device");
}
Expand Down Expand Up @@ -464,7 +466,7 @@ FBDevPreInit(ScrnInfoPtr pScrn, int flags)
}
#endif
/* open device */
if (!fbdevHWInit(pScrn,NULL,xf86FindOptionValue(fPtr->pEnt->device->options,"fbdev")))
if (!fbdevHWInit(pScrn, NULL, xf86FindOptionValue(fPtr->pEnt->device->options,"fbdev")))
return FALSE;
default_depth = fbdevHWGetDepth(pScrn,&fbbpp);
if (!xf86SetDepthBpp(pScrn, default_depth, default_depth, fbbpp,
Expand Down Expand Up @@ -575,7 +577,7 @@ FBDevPreInit(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "checking modes against monitor...\n");
{
DisplayModePtr mode, first = mode = pScrn->modes;

if (mode != NULL) do {
mode->status = xf86CheckModeForMonitor(mode, pScrn->monitor);
mode = mode->next;
Expand Down Expand Up @@ -688,7 +690,7 @@ FBDevShadowInit(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
FBDevPtr fPtr = FBDEVPTR(pScrn);

if (!shadowSetup(pScreen)) {
return FALSE;
}
Expand Down Expand Up @@ -1025,7 +1027,7 @@ FBDevScreenInit(SCREEN_INIT_ARGS_DECL)
return FALSE;
}
flags = CMAP_PALETTED_TRUECOLOR;
if(!xf86HandleColormaps(pScreen, 256, 8, fbdevHWLoadPaletteWeak(),
if(!xf86HandleColormaps(pScreen, 256, 8, fbdevHWLoadPaletteWeak(),
NULL, flags))
return FALSE;

Expand Down Expand Up @@ -1066,8 +1068,22 @@ FBDevScreenInit(SCREEN_INIT_ARGS_DECL)
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"using hardware cursor\n");
else
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"failed to enable hardware cursor\n");
{
// Try the raspi cursor code
fPtr->raspi_cursor = 0;

xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Detecting Raspi HW cursor...\n");

fPtr->SunxiDispHardwareCursor_private = raspberry_cursor_init(pScreen);

if (fPtr->SunxiDispHardwareCursor_private)
{
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "using Raspi hardware cursor\n");
fPtr->raspi_cursor = 1;
}
else
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "failed to enable hardware cursor\n");
}
}

#ifdef HAVE_LIBUMP
Expand Down Expand Up @@ -1121,7 +1137,11 @@ FBDevCloseScreen(CLOSE_SCREEN_ARGS_DECL)
#endif

if (fPtr->SunxiDispHardwareCursor_private) {
SunxiDispHardwareCursor_Close(pScreen);
if (fPtr->raspi_cursor)
raspberry_cursor_close(pScreen);
else
SunxiDispHardwareCursor_Close(pScreen);

free(fPtr->SunxiDispHardwareCursor_private);
fPtr->SunxiDispHardwareCursor_private = NULL;
}
Expand Down Expand Up @@ -1392,7 +1412,7 @@ static Bool
FBDevDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer ptr)
{
xorgHWFlags *flag;

switch (op) {
case GET_REQUIRED_HW_INTERFACES:
flag = (CARD32*)ptr;
Expand Down
4 changes: 4 additions & 0 deletions src/fbdev_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ typedef struct {
int nDGAMode;
OptionInfoPtr Options;

int raspi_cursor; // true if using the raspberry pi HW cursor.

void *cpu_backend_private;
void *backing_store_tuner_private;
void *sunxi_disp_private;
Expand Down Expand Up @@ -83,3 +85,5 @@ typedef struct {

#define SUNXI_VIDEO(p) ((SunxiVideo *) \
(FBDEVPTR(p)->SunxiVideo_private))

#define RASPI_DISP_HWC(p) ((raspberry_cursor_state_s *) (FBDEVPTR(p)->SunxiDispHardwareCursor_private))
Loading

0 comments on commit 08b084c

Please sign in to comment.