Commit 901fbfbb authored by Michael Thayer's avatar Michael Thayer Committed by Keith Packard

Add a return value to load_cursor_argb() to allow it to report failure

load_cursor_argb() may need to be able to fail and have the server fall back
to a software cursor in at least the following circumstances.
1) The hardware can only support some ARGB cursors and this does not just
depend on cursor size.
2) Virtual hardware may not wish to pass through a cursor to the host at a
particular time but may wish to accept the same cursor at another time.
This patch adds a return value to the API and makes the server do the
software fall-back on failure.
Signed-off-by: Michael Thayer's avatarMichael Thayer <michael.thayer@oracle.com>
Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard's avatarKeith Packard <keithp@keithp.com>
parent 62ab4102
...@@ -80,7 +80,7 @@ typedef enum { ...@@ -80,7 +80,7 @@ typedef enum {
* mask is 0xFFFF0000. * mask is 0xFFFF0000.
*/ */
#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4) #define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4)
#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(16, 0) #define ABI_VIDEODRV_VERSION SET_ABI_VERSION(17, 0)
#define ABI_XINPUT_VERSION SET_ABI_VERSION(21, 0) #define ABI_XINPUT_VERSION SET_ABI_VERSION(21, 0)
#define ABI_EXTENSION_VERSION SET_ABI_VERSION(8, 0) #define ABI_EXTENSION_VERSION SET_ABI_VERSION(8, 0)
#define ABI_FONT_VERSION SET_ABI_VERSION(0, 6) #define ABI_FONT_VERSION SET_ABI_VERSION(0, 6)
......
...@@ -186,13 +186,13 @@ typedef struct _xf86CrtcFuncs { ...@@ -186,13 +186,13 @@ typedef struct _xf86CrtcFuncs {
/** /**
* Load monochrome image * Load monochrome image
*/ */
void Bool
(*load_cursor_image) (xf86CrtcPtr crtc, CARD8 *image); (*load_cursor_image) (xf86CrtcPtr crtc, CARD8 *image);
/** /**
* Load ARGB image * Load ARGB image
*/ */
void Bool
(*load_cursor_argb) (xf86CrtcPtr crtc, CARD32 *image); (*load_cursor_argb) (xf86CrtcPtr crtc, CARD32 *image);
/** /**
......
...@@ -211,7 +211,7 @@ set_bit(CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask) ...@@ -211,7 +211,7 @@ set_bit(CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
/* /*
* Load a two color cursor into a driver that supports only ARGB cursors * Load a two color cursor into a driver that supports only ARGB cursors
*/ */
static void static Bool
xf86_crtc_convert_cursor_to_argb(xf86CrtcPtr crtc, unsigned char *src) xf86_crtc_convert_cursor_to_argb(xf86CrtcPtr crtc, unsigned char *src)
{ {
ScrnInfoPtr scrn = crtc->scrn; ScrnInfoPtr scrn = crtc->scrn;
...@@ -244,7 +244,7 @@ xf86_crtc_convert_cursor_to_argb(xf86CrtcPtr crtc, unsigned char *src) ...@@ -244,7 +244,7 @@ xf86_crtc_convert_cursor_to_argb(xf86CrtcPtr crtc, unsigned char *src)
bits = 0; bits = 0;
cursor_image[y * cursor_info->MaxWidth + x] = bits; cursor_image[y * cursor_info->MaxWidth + x] = bits;
} }
crtc->funcs->load_cursor_argb(crtc, cursor_image); return crtc->funcs->load_cursor_argb(crtc, cursor_image);
} }
/* /*
...@@ -415,7 +415,7 @@ xf86_set_cursor_position(ScrnInfoPtr scrn, int x, int y) ...@@ -415,7 +415,7 @@ xf86_set_cursor_position(ScrnInfoPtr scrn, int x, int y)
/* /*
* Load a two-color cursor into a crtc, performing rotation as needed * Load a two-color cursor into a crtc, performing rotation as needed
*/ */
static void static Bool
xf86_crtc_load_cursor_image(xf86CrtcPtr crtc, CARD8 *src) xf86_crtc_load_cursor_image(xf86CrtcPtr crtc, CARD8 *src)
{ {
ScrnInfoPtr scrn = crtc->scrn; ScrnInfoPtr scrn = crtc->scrn;
...@@ -450,13 +450,13 @@ xf86_crtc_load_cursor_image(xf86CrtcPtr crtc, CARD8 *src) ...@@ -450,13 +450,13 @@ xf86_crtc_load_cursor_image(xf86CrtcPtr crtc, CARD8 *src)
set_bit(cursor_image, cursor_info, x, y, TRUE); set_bit(cursor_image, cursor_info, x, y, TRUE);
} }
} }
crtc->funcs->load_cursor_image(crtc, cursor_image); return crtc->funcs->load_cursor_image(crtc, cursor_image);
} }
/* /*
* Load a cursor image into all active CRTCs * Load a cursor image into all active CRTCs
*/ */
static void static Bool
xf86_load_cursor_image(ScrnInfoPtr scrn, unsigned char *src) xf86_load_cursor_image(ScrnInfoPtr scrn, unsigned char *src)
{ {
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
...@@ -466,12 +466,17 @@ xf86_load_cursor_image(ScrnInfoPtr scrn, unsigned char *src) ...@@ -466,12 +466,17 @@ xf86_load_cursor_image(ScrnInfoPtr scrn, unsigned char *src)
xf86CrtcPtr crtc = xf86_config->crtc[c]; xf86CrtcPtr crtc = xf86_config->crtc[c];
if (crtc->enabled) { if (crtc->enabled) {
if (crtc->funcs->load_cursor_image) if (crtc->funcs->load_cursor_image) {
xf86_crtc_load_cursor_image(crtc, src); if (!xf86_crtc_load_cursor_image(crtc, src))
else if (crtc->funcs->load_cursor_argb) return FALSE;
xf86_crtc_convert_cursor_to_argb(crtc, src); } else if (crtc->funcs->load_cursor_argb) {
if (!xf86_crtc_convert_cursor_to_argb(crtc, src))
return FALSE;
} else
return FALSE;
} }
} }
return TRUE;
} }
static Bool static Bool
...@@ -516,7 +521,7 @@ xf86_use_hw_cursor_argb(ScreenPtr screen, CursorPtr cursor) ...@@ -516,7 +521,7 @@ xf86_use_hw_cursor_argb(ScreenPtr screen, CursorPtr cursor)
return TRUE; return TRUE;
} }
static void static Bool
xf86_crtc_load_cursor_argb(xf86CrtcPtr crtc, CursorPtr cursor) xf86_crtc_load_cursor_argb(xf86CrtcPtr crtc, CursorPtr cursor)
{ {
ScrnInfoPtr scrn = crtc->scrn; ScrnInfoPtr scrn = crtc->scrn;
...@@ -544,10 +549,10 @@ xf86_crtc_load_cursor_argb(xf86CrtcPtr crtc, CursorPtr cursor) ...@@ -544,10 +549,10 @@ xf86_crtc_load_cursor_argb(xf86CrtcPtr crtc, CursorPtr cursor)
cursor_image[y * image_width + x] = bits; cursor_image[y * image_width + x] = bits;
} }
crtc->funcs->load_cursor_argb(crtc, cursor_image); return crtc->funcs->load_cursor_argb(crtc, cursor_image);
} }
static void static Bool
xf86_load_cursor_argb(ScrnInfoPtr scrn, CursorPtr cursor) xf86_load_cursor_argb(ScrnInfoPtr scrn, CursorPtr cursor)
{ {
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
...@@ -557,8 +562,10 @@ xf86_load_cursor_argb(ScrnInfoPtr scrn, CursorPtr cursor) ...@@ -557,8 +562,10 @@ xf86_load_cursor_argb(ScrnInfoPtr scrn, CursorPtr cursor)
xf86CrtcPtr crtc = xf86_config->crtc[c]; xf86CrtcPtr crtc = xf86_config->crtc[c];
if (crtc->enabled) if (crtc->enabled)
xf86_crtc_load_cursor_argb(crtc, cursor); if (!xf86_crtc_load_cursor_argb(crtc, cursor))
return FALSE;
} }
return TRUE;
} }
Bool Bool
...@@ -608,6 +615,8 @@ xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags) ...@@ -608,6 +615,8 @@ xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags)
* Called when anything on the screen is reconfigured. * Called when anything on the screen is reconfigured.
* *
* Reloads cursor images as needed, then adjusts cursor positions * Reloads cursor images as needed, then adjusts cursor positions
* @note We assume that all hardware cursors to be loaded have already been
* found to be usable by the hardware.
*/ */
void void
......
...@@ -570,7 +570,7 @@ IBMramdac640SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) ...@@ -570,7 +570,7 @@ IBMramdac640SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
(*ramdacPtr->WriteData) (pScrn, bg); (*ramdacPtr->WriteData) (pScrn, bg);
} }
static void static Bool
IBMramdac526LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) IBMramdac526LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
{ {
RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
...@@ -582,9 +582,10 @@ IBMramdac526LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) ...@@ -582,9 +582,10 @@ IBMramdac526LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
*/ */
for (i = 0; i < 1024; i++) for (i = 0; i < 1024; i++)
(*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_array + i, 0x00, (*src++)); (*ramdacPtr->WriteDAC) (pScrn, IBMRGB_curs_array + i, 0x00, (*src++));
return TRUE;
} }
static void static Bool
IBMramdac640LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) IBMramdac640LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
{ {
RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
...@@ -596,6 +597,7 @@ IBMramdac640LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) ...@@ -596,6 +597,7 @@ IBMramdac640LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
*/ */
for (i = 0; i < 1024; i++) for (i = 0; i < 1024; i++)
(*ramdacPtr->WriteDAC) (pScrn, RGB640_CURS_WRITE + i, 0x00, (*src++)); (*ramdacPtr->WriteDAC) (pScrn, RGB640_CURS_WRITE + i, 0x00, (*src++));
return TRUE;
} }
static Bool static Bool
......
...@@ -642,7 +642,7 @@ TIramdacSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) ...@@ -642,7 +642,7 @@ TIramdacSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
(*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_COLOR, 0, (fg & 0x000000ff)); (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_COLOR, 0, (fg & 0x000000ff));
} }
static void static Bool
TIramdacLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) TIramdacLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
{ {
RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn); RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
...@@ -657,6 +657,7 @@ TIramdacLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) ...@@ -657,6 +657,7 @@ TIramdacLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
/* NOT_DONE: might need a delay here */ /* NOT_DONE: might need a delay here */
(*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_RAM_DATA, 0, *(src++)); (*ramdacPtr->WriteDAC) (pScrn, TIDAC_CURS_RAM_DATA, 0, *(src++));
} }
return TRUE;
} }
static Bool static Bool
......
...@@ -352,12 +352,13 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs, ...@@ -352,12 +352,13 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
(*ScreenPriv->spriteFuncs->SetCursor) (pDev, pScreen, (*ScreenPriv->spriteFuncs->SetCursor) (pDev, pScreen,
NullCursor, x, y); NullCursor, x, y);
xf86SetCursor(pScreen, cursor, x, y); if (xf86SetCursor(pScreen, cursor, x, y)) {
ScreenPriv->SWCursor = FALSE; ScreenPriv->SWCursor = FALSE;
ScreenPriv->isUp = TRUE; ScreenPriv->isUp = TRUE;
miPointerSetWaitForUpdate(pScreen, !infoPtr->pScrn->silkenMouse); miPointerSetWaitForUpdate(pScreen, !infoPtr->pScrn->silkenMouse);
return; return;
}
} }
miPointerSetWaitForUpdate(pScreen, TRUE); miPointerSetWaitForUpdate(pScreen, TRUE);
......
...@@ -12,7 +12,7 @@ typedef struct _xf86CursorInfoRec { ...@@ -12,7 +12,7 @@ typedef struct _xf86CursorInfoRec {
int MaxHeight; int MaxHeight;
void (*SetCursorColors) (ScrnInfoPtr pScrn, int bg, int fg); void (*SetCursorColors) (ScrnInfoPtr pScrn, int bg, int fg);
void (*SetCursorPosition) (ScrnInfoPtr pScrn, int x, int y); void (*SetCursorPosition) (ScrnInfoPtr pScrn, int x, int y);
void (*LoadCursorImage) (ScrnInfoPtr pScrn, unsigned char *bits); Bool (*LoadCursorImage) (ScrnInfoPtr pScrn, unsigned char *bits);
void (*HideCursor) (ScrnInfoPtr pScrn); void (*HideCursor) (ScrnInfoPtr pScrn);
void (*ShowCursor) (ScrnInfoPtr pScrn); void (*ShowCursor) (ScrnInfoPtr pScrn);
unsigned char *(*RealizeCursor) (struct _xf86CursorInfoRec *, CursorPtr); unsigned char *(*RealizeCursor) (struct _xf86CursorInfoRec *, CursorPtr);
...@@ -20,7 +20,7 @@ typedef struct _xf86CursorInfoRec { ...@@ -20,7 +20,7 @@ typedef struct _xf86CursorInfoRec {
#ifdef ARGB_CURSOR #ifdef ARGB_CURSOR
Bool (*UseHWCursorARGB) (ScreenPtr, CursorPtr); Bool (*UseHWCursorARGB) (ScreenPtr, CursorPtr);
void (*LoadCursorARGB) (ScrnInfoPtr, CursorPtr); Bool (*LoadCursorARGB) (ScrnInfoPtr, CursorPtr);
#endif #endif
} xf86CursorInfoRec, *xf86CursorInfoPtr; } xf86CursorInfoRec, *xf86CursorInfoPtr;
......
...@@ -37,7 +37,7 @@ typedef struct { ...@@ -37,7 +37,7 @@ typedef struct {
void *transparentData; void *transparentData;
} xf86CursorScreenRec, *xf86CursorScreenPtr; } xf86CursorScreenRec, *xf86CursorScreenPtr;
void xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y); Bool xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y);
void xf86SetTransparentCursor(ScreenPtr pScreen); void xf86SetTransparentCursor(ScreenPtr pScreen);
void xf86MoveCursor(ScreenPtr pScreen, int x, int y); void xf86MoveCursor(ScreenPtr pScreen, int x, int y);
void xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed); void xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed);
......
...@@ -119,7 +119,7 @@ xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr) ...@@ -119,7 +119,7 @@ xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
return TRUE; return TRUE;
} }
void Bool
xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
{ {
xf86CursorScreenPtr ScreenPriv = xf86CursorScreenPtr ScreenPriv =
...@@ -130,7 +130,7 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) ...@@ -130,7 +130,7 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
if (pCurs == NullCursor) { if (pCurs == NullCursor) {
(*infoPtr->HideCursor) (infoPtr->pScrn); (*infoPtr->HideCursor) (infoPtr->pScrn);
return; return TRUE;
} }
bits = bits =
...@@ -152,18 +152,21 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) ...@@ -152,18 +152,21 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
(*infoPtr->HideCursor) (infoPtr->pScrn); (*infoPtr->HideCursor) (infoPtr->pScrn);
#ifdef ARGB_CURSOR #ifdef ARGB_CURSOR
if (pCurs->bits->argb && infoPtr->LoadCursorARGB) if (pCurs->bits->argb && infoPtr->LoadCursorARGB) {
(*infoPtr->LoadCursorARGB) (infoPtr->pScrn, pCurs); if (!(*infoPtr->LoadCursorARGB) (infoPtr->pScrn, pCurs))
else return FALSE;
} else
#endif #endif
if (bits) if (bits)
(*infoPtr->LoadCursorImage) (infoPtr->pScrn, bits); if (!(*infoPtr->LoadCursorImage) (infoPtr->pScrn, bits))
return FALSE;
xf86RecolorCursor(pScreen, pCurs, 1); xf86RecolorCursor(pScreen, pCurs, 1);
(*infoPtr->SetCursorPosition) (infoPtr->pScrn, x, y); (*infoPtr->SetCursorPosition) (infoPtr->pScrn, x, y);
(*infoPtr->ShowCursor) (infoPtr->pScrn); (*infoPtr->ShowCursor) (infoPtr->pScrn);
return TRUE;
} }
void void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment