Skip to content

Commit 08b084c

Browse files
jameshjnahughes
authored andcommitted
Support for Raspberry Pi hardware cursor
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.
1 parent 8dec039 commit 08b084c

7 files changed

Lines changed: 953 additions & 22 deletions

File tree

src/Makefile.am

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ fbturbo_drv_la_SOURCES = \
5252
sunxi_video.c \
5353
sunxi_video.h \
5454
sunxi_disp_ioctl.h \
55-
g2d_driver.h
55+
g2d_driver.h \
56+
raspi_hwcursor.c \
57+
raspi_hwcursor.h \
58+
raspi_mailbox.c \
59+
raspi_mailbox.h
5660

5761
if HAVE_LIBUMP
5862
fbturbo_drv_la_SOURCES += \

src/fbdev.c

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
#include "backing_store_tuner.h"
5656
#include "sunxi_video.h"
5757

58+
#include "raspi_hwcursor.h"
59+
5860
#ifdef HAVE_LIBUMP
5961
#include "sunxi_mali_ump_dri2.h"
6062
#endif
@@ -241,7 +243,7 @@ FBDevGetRec(ScrnInfoPtr pScrn)
241243
{
242244
if (pScrn->driverPrivate != NULL)
243245
return TRUE;
244-
246+
245247
pScrn->driverPrivate = xnfcalloc(sizeof(FBDevRec), 1);
246248
return TRUE;
247249
}
@@ -278,11 +280,11 @@ static Bool FBDevPciProbe(DriverPtr drv, int entity_num,
278280

279281
if (!xf86LoadDrvSubModule(drv, "fbdevhw"))
280282
return FALSE;
281-
283+
282284
pScrn = xf86ConfigPciEntity(NULL, 0, entity_num, NULL, NULL,
283285
NULL, NULL, NULL, NULL);
284286
if (pScrn) {
285-
char *device;
287+
char *device;
286288
GDevPtr devSection = xf86GetDevFromEntity(pScrn->entityList[0],
287289
pScrn->entityInstanceList[0]);
288290

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

303305
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
304-
"claimed PCI slot %d@%d:%d:%d\n",
306+
"claimed PCI slot %d@%d:%d:%d\n",
305307
dev->bus, dev->domain, dev->dev, dev->func);
306308
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
307309
"using %s\n", device ? device : "default device");
@@ -335,12 +337,12 @@ FBDevProbe(DriverPtr drv, int flags)
335337
if (flags & PROBE_DETECT)
336338
return FALSE;
337339

338-
if ((numDevSections = xf86MatchDevice(FBDEV_DRIVER_NAME, &devSections)) <= 0)
340+
if ((numDevSections = xf86MatchDevice(FBDEV_DRIVER_NAME, &devSections)) <= 0)
339341
return FALSE;
340-
342+
341343
if (!xf86LoadDrvSubModule(drv, "fbdevhw"))
342344
return FALSE;
343-
345+
344346
for (i = 0; i < numDevSections; i++) {
345347
Bool isIsa = FALSE;
346348
Bool isPci = FALSE;
@@ -361,15 +363,15 @@ FBDevProbe(DriverPtr drv, int flags)
361363
else
362364
#endif
363365
0;
364-
366+
365367
}
366368
if (fbdevHWProbe(NULL,dev,NULL)) {
367369
pScrn = NULL;
368370
if (isPci) {
369371
#ifndef XSERVER_LIBPCIACCESS
370372
/* XXX what about when there's no busID set? */
371373
int entity;
372-
374+
373375
entity = xf86ClaimPciSlot(bus,device,func,drv,
374376
0,devSections[i],
375377
TRUE);
@@ -386,7 +388,7 @@ FBDevProbe(DriverPtr drv, int flags)
386388
} else if (isIsa) {
387389
#ifdef HAVE_ISA
388390
int entity;
389-
391+
390392
entity = xf86ClaimIsaSlot(drv, 0,
391393
devSections[i], TRUE);
392394
pScrn = xf86ConfigIsaEntity(pScrn,0,entity,
@@ -400,11 +402,11 @@ FBDevProbe(DriverPtr drv, int flags)
400402
devSections[i], TRUE);
401403
pScrn = xf86ConfigFbEntity(pScrn,0,entity,
402404
NULL,NULL,NULL,NULL);
403-
405+
404406
}
405407
if (pScrn) {
406408
foundScreen = TRUE;
407-
409+
408410
pScrn->driverVersion = FBDEV_VERSION;
409411
pScrn->driverName = FBDEV_DRIVER_NAME;
410412
pScrn->name = FBDEV_NAME;
@@ -416,7 +418,7 @@ FBDevProbe(DriverPtr drv, int flags)
416418
pScrn->EnterVT = fbdevHWEnterVTWeak();
417419
pScrn->LeaveVT = fbdevHWLeaveVTWeak();
418420
pScrn->ValidMode = fbdevHWValidModeWeak();
419-
421+
420422
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
421423
"using %s\n", dev ? dev : "default device");
422424
}
@@ -464,7 +466,7 @@ FBDevPreInit(ScrnInfoPtr pScrn, int flags)
464466
}
465467
#endif
466468
/* open device */
467-
if (!fbdevHWInit(pScrn,NULL,xf86FindOptionValue(fPtr->pEnt->device->options,"fbdev")))
469+
if (!fbdevHWInit(pScrn, NULL, xf86FindOptionValue(fPtr->pEnt->device->options,"fbdev")))
468470
return FALSE;
469471
default_depth = fbdevHWGetDepth(pScrn,&fbbpp);
470472
if (!xf86SetDepthBpp(pScrn, default_depth, default_depth, fbbpp,
@@ -575,7 +577,7 @@ FBDevPreInit(ScrnInfoPtr pScrn, int flags)
575577
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "checking modes against monitor...\n");
576578
{
577579
DisplayModePtr mode, first = mode = pScrn->modes;
578-
580+
579581
if (mode != NULL) do {
580582
mode->status = xf86CheckModeForMonitor(mode, pScrn->monitor);
581583
mode = mode->next;
@@ -688,7 +690,7 @@ FBDevShadowInit(ScreenPtr pScreen)
688690
{
689691
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
690692
FBDevPtr fPtr = FBDEVPTR(pScrn);
691-
693+
692694
if (!shadowSetup(pScreen)) {
693695
return FALSE;
694696
}
@@ -1025,7 +1027,7 @@ FBDevScreenInit(SCREEN_INIT_ARGS_DECL)
10251027
return FALSE;
10261028
}
10271029
flags = CMAP_PALETTED_TRUECOLOR;
1028-
if(!xf86HandleColormaps(pScreen, 256, 8, fbdevHWLoadPaletteWeak(),
1030+
if(!xf86HandleColormaps(pScreen, 256, 8, fbdevHWLoadPaletteWeak(),
10291031
NULL, flags))
10301032
return FALSE;
10311033

@@ -1066,8 +1068,22 @@ FBDevScreenInit(SCREEN_INIT_ARGS_DECL)
10661068
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
10671069
"using hardware cursor\n");
10681070
else
1069-
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
1070-
"failed to enable hardware cursor\n");
1071+
{
1072+
// Try the raspi cursor code
1073+
fPtr->raspi_cursor = 0;
1074+
1075+
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Detecting Raspi HW cursor...\n");
1076+
1077+
fPtr->SunxiDispHardwareCursor_private = raspberry_cursor_init(pScreen);
1078+
1079+
if (fPtr->SunxiDispHardwareCursor_private)
1080+
{
1081+
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "using Raspi hardware cursor\n");
1082+
fPtr->raspi_cursor = 1;
1083+
}
1084+
else
1085+
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "failed to enable hardware cursor\n");
1086+
}
10711087
}
10721088

10731089
#ifdef HAVE_LIBUMP
@@ -1121,7 +1137,11 @@ FBDevCloseScreen(CLOSE_SCREEN_ARGS_DECL)
11211137
#endif
11221138

11231139
if (fPtr->SunxiDispHardwareCursor_private) {
1124-
SunxiDispHardwareCursor_Close(pScreen);
1140+
if (fPtr->raspi_cursor)
1141+
raspberry_cursor_close(pScreen);
1142+
else
1143+
SunxiDispHardwareCursor_Close(pScreen);
1144+
11251145
free(fPtr->SunxiDispHardwareCursor_private);
11261146
fPtr->SunxiDispHardwareCursor_private = NULL;
11271147
}
@@ -1392,7 +1412,7 @@ static Bool
13921412
FBDevDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer ptr)
13931413
{
13941414
xorgHWFlags *flag;
1395-
1415+
13961416
switch (op) {
13971417
case GET_REQUIRED_HW_INTERFACES:
13981418
flag = (CARD32*)ptr;

src/fbdev_priv.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ typedef struct {
5454
int nDGAMode;
5555
OptionInfoPtr Options;
5656

57+
int raspi_cursor; // true if using the raspberry pi HW cursor.
58+
5759
void *cpu_backend_private;
5860
void *backing_store_tuner_private;
5961
void *sunxi_disp_private;
@@ -83,3 +85,5 @@ typedef struct {
8385

8486
#define SUNXI_VIDEO(p) ((SunxiVideo *) \
8587
(FBDEVPTR(p)->SunxiVideo_private))
88+
89+
#define RASPI_DISP_HWC(p) ((raspberry_cursor_state_s *) (FBDEVPTR(p)->SunxiDispHardwareCursor_private))

0 commit comments

Comments
 (0)