[PATCH xserver 2/5] xfree86/modes: Add use_hw_cursor(_argb) CRTC hooks

Keith Packard keithp at keithp.com
Wed Dec 23 17:38:37 PST 2015


Michel Dänzer <michel at daenzer.net> writes:

> From: Michel Dänzer <michel.daenzer at amd.com>
>
> Allows drivers to report whether or not the HW cursor can be used on a
> per-CRTC basis. If the driver reports that the HW cursor cannot be used
> on any CRTC, SW cursor has to be used for the screen.
>
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
> ---
>  hw/xfree86/modes/xf86Crtc.h    | 11 ++++++++++-
>  hw/xfree86/modes/xf86Cursors.c | 22 ++++++++++++++++++++++
>  2 files changed, 32 insertions(+), 1 deletion(-)
>
> diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
> index 8b01608..40650d3 100644
> --- a/hw/xfree86/modes/xf86Crtc.h
> +++ b/hw/xfree86/modes/xf86Crtc.h
> @@ -235,9 +235,18 @@ typedef struct _xf86CrtcFuncs {
>      Bool
>      (*set_scanout_pixmap)(xf86CrtcPtr crtc, PixmapPtr pixmap);
>  
> +    /**
> +     * Check if the CRTC can use the hardware cursor
> +     * Added in ABI version 7
> +     */
> +    Bool
> +     (*use_hw_cursor) (xf86CrtcPtr crtc, CursorPtr cursor);
> +    Bool
> +     (*use_hw_cursor_argb) (xf86CrtcPtr crtc, CursorPtr cursor);
> +
>  } xf86CrtcFuncsRec, *xf86CrtcFuncsPtr;
>  
> -#define XF86_CRTC_VERSION 6
> +#define XF86_CRTC_VERSION 7
>  
>  struct _xf86Crtc {
>      /**
> diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
> index 321cde7..3d49533 100644
> --- a/hw/xfree86/modes/xf86Cursors.c
> +++ b/hw/xfree86/modes/xf86Cursors.c
> @@ -515,6 +515,7 @@ xf86_use_hw_cursor(ScreenPtr screen, CursorPtr cursor)
>      ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
>      xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
>      xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
> +    int c;
>  
>      cursor = RefCursor(cursor);
>      if (xf86_config->cursor)
> @@ -525,6 +526,18 @@ xf86_use_hw_cursor(ScreenPtr screen, CursorPtr cursor)
>          cursor->bits->height > cursor_info->MaxHeight)
>          return FALSE;
>  
> +    for (c = 0; c < xf86_config->num_crtc; c++) {
> +        xf86CrtcPtr crtc = xf86_config->crtc[c];
> +
> +        if (xf86_driver_has_load_cursor_image(crtc) &&
> +            crtc->funcs->use_hw_cursor) {
> +            if (!crtc->funcs->use_hw_cursor(crtc, cursor))
> +                return FALSE;
> +        } else if (crtc->funcs->use_hw_cursor_argb &&
> +                   !crtc->funcs->use_hw_cursor_argb(crtc, cursor))
> +            return FALSE;
> +    }

These should check crtc->enabled and skip crtcs which aren't actually
displaying anything.

Why is this checking to see if an argb cursor could be loaded here?
It should only check whether a two color cursor can be loaded as it only
gets called when the cursor does not have argb bits.

>      cursor = RefCursor(cursor);
>      if (xf86_config->cursor)
> @@ -548,6 +562,14 @@ xf86_use_hw_cursor_argb(ScreenPtr screen, CursorPtr cursor)
>          cursor->bits->height > cursor_info->MaxHeight)
>          return FALSE;
>  
> +    for (c = 0; c < xf86_config->num_crtc; c++) {
> +        xf86CrtcPtr crtc = xf86_config->crtc[c];
> +
> +        if (crtc->funcs->use_hw_cursor_argb &&
> +            !crtc->funcs->use_hw_cursor_argb(crtc, cursor))
> +            return FALSE;
> +    }

Same here -- check crtc->enabled before anything else.

Add a check for xf86_driver_has_load_cursor_image_argb here to match the
above test

-- 
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 810 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20151223/6fbcfe4b/attachment.sig>


More information about the xorg-devel mailing list