[Mesa-dev] [PATCH 2/2] gbm: Add flags to enable creation of rotated scanout buffers (v4)

Dieter Nützel Dieter at nuetzel-hh.de
Fri Nov 6 20:45:10 PST 2015


Am 07.11.2015 04:05, schrieb Vivek Kasireddy:
> For certain platforms that support rotated scanout buffers, currently,
> there is no way to create them with the GBM DRI interface. These flags
> will instruct the DRI driver to create the buffer by setting
> additional requirements such as tiling mode.
> 
> v2: Reserve a bit per angle. (Ville and Michel)
> 
> v3:
> - Combine all GBM_BO_USE_SCANOUT_ROTATION_* flags into
>   GBM_BO_USE_SCANOUT_ANY macro (Michel)
> - Pull the code that updates dri_use based on the rotation flag
>   into a separate function.
> 
> v4:
> - Added a brief comment to explain the rotation orientation.
> - Augmented the helper function gbm_to_dri_flag() introduced in v3
>   to handle GBM_BO_USE_CURSOR and GBM_BO_USE_LINEAR as well. (Michel)
> 
> Cc: Michel Danzer <michel at daenzer.net>
> Cc: Ville Syrjala <ville.syrjala at linux.intel.com>
> Signed-off-by: Vivek Kasireddy <vivek.kasireddy at intel.com>
> ---
>  src/gbm/backends/dri/gbm_dri.c | 35 
> +++++++++++++++++++++++------------
>  src/gbm/main/gbm.h             | 15 +++++++++++++++
>  2 files changed, 38 insertions(+), 12 deletions(-)
> 
> diff --git a/src/gbm/backends/dri/gbm_dri.c 
> b/src/gbm/backends/dri/gbm_dri.c
> index 57cdeac..6616d37 100644
> --- a/src/gbm/backends/dri/gbm_dri.c
> +++ b/src/gbm/backends/dri/gbm_dri.c
> @@ -124,6 +124,24 @@ image_get_buffers(__DRIdrawable *driDrawable,
>  }
> 
>  static void
> +gbm_to_dri_flag(uint32_t usage,
> +                unsigned *dri_use)
> +{
> +   if (usage & GBM_BO_USE_SCANOUT)
> +      *dri_use |= __DRI_IMAGE_USE_SCANOUT;
> +   if (usage & GBM_BO_USE_SCANOUT_ROTATION_90)
> +      *dri_use |= __DRI_IMAGE_USE_SCANOUT_ROTATION_90;
> +   if (usage & GBM_BO_USE_SCANOUT_ROTATION_180)
> +      *dri_use |= __DRI_IMAGE_USE_SCANOUT_ROTATION_180;
> +   if (usage & GBM_BO_USE_SCANOUT_ROTATION_270)
> +      *dri_use |= __DRI_IMAGE_USE_SCANOUT_ROTATION_270;
> +   if (usage & GBM_BO_USE_CURSOR)
> +      *dri_use |= __DRI_IMAGE_USE_CURSOR;
> +   if (usage & GBM_BO_USE_LINEAR)
> +      *dri_use |= __DRI_IMAGE_USE_LINEAR;
> +}
> +
> +static void
>  swrast_get_drawable_info(__DRIdrawable *driDrawable,
>                           int           *x,
>                           int           *y,
> @@ -539,7 +557,7 @@ gbm_dri_is_format_supported(struct gbm_device *gbm,
>        break;
>     case GBM_BO_FORMAT_ARGB8888:
>     case GBM_FORMAT_ARGB8888:
> -      if (usage & GBM_BO_USE_SCANOUT)
> +      if (usage & GBM_BO_USE_SCANOUT_ANY)
>           return 0;
>        break;
>     default:
> @@ -746,10 +764,8 @@ gbm_dri_bo_import(struct gbm_device *gbm,
> 
>     bo->image = image;
> 
> -   if (usage & GBM_BO_USE_SCANOUT)
> -      dri_use |= __DRI_IMAGE_USE_SCANOUT;
> -   if (usage & GBM_BO_USE_CURSOR)
> -      dri_use |= __DRI_IMAGE_USE_CURSOR;
> +   gbm_to_dri_flag(usage, &dri_use);
> +
>     if (dri->image->base.version >= 2 &&
>         !dri->image->validateUsage(bo->image, dri_use)) {
>        errno = EINVAL;
> @@ -786,7 +802,7 @@ create_dumb(struct gbm_device *gbm,
> 
>     is_cursor = (usage & GBM_BO_USE_CURSOR) != 0 &&
>        format == GBM_FORMAT_ARGB8888;
> -   is_scanout = (usage & GBM_BO_USE_SCANOUT) != 0 &&
> +   is_scanout = (usage & GBM_BO_USE_SCANOUT_ANY) != 0 &&
>        format == GBM_FORMAT_XRGB8888;
>     if (!is_cursor && !is_scanout) {
>        errno = EINVAL;
> @@ -878,12 +894,7 @@ gbm_dri_bo_create(struct gbm_device *gbm,
>        goto failed;
>     }
> 
> -   if (usage & GBM_BO_USE_SCANOUT)
> -      dri_use |= __DRI_IMAGE_USE_SCANOUT;
> -   if (usage & GBM_BO_USE_CURSOR)
> -      dri_use |= __DRI_IMAGE_USE_CURSOR;
> -   if (usage & GBM_BO_USE_LINEAR)
> -      dri_use |= __DRI_IMAGE_USE_LINEAR;
> +   gbm_to_dri_flag(usage, &dri_use);
> 
>     /* Gallium drivers requires shared in order to get the 
> handle/stride */
>     dri_use |= __DRI_IMAGE_USE_SHARE;
> diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
> index 8db2153..667fcf7 100644
> --- a/src/gbm/main/gbm.h
> +++ b/src/gbm/main/gbm.h
> @@ -214,8 +214,23 @@ enum gbm_bo_flags {
>      * Buffer is linear, i.e. not tiled.
>      */
>     GBM_BO_USE_LINEAR = (1 << 4),
> +   /**
> +    * Buffer would be rotated and some platforms have additional 
> tiling
> +    * requirements for rotated scanout buffers.
> +    * And, setting a rotation angle of 90 or 270 would result in the
> +    * scanout buffer being rotated in a clounter clockwise manner. 
> This

Spelling: ...counter...

Greetings,
Dieter

> +    * is the expected behavior for ensuring XRandR compliance.
> +    */
> +   GBM_BO_USE_SCANOUT_ROTATION_90 = (1 << 5),
> +   GBM_BO_USE_SCANOUT_ROTATION_180 = (1 << 6),
> +   GBM_BO_USE_SCANOUT_ROTATION_270 = (1 << 7),
>  };
> 
> +#define GBM_BO_USE_SCANOUT_ANY (GBM_BO_USE_SCANOUT |              \
> +                                GBM_BO_USE_SCANOUT_ROTATION_90 |  \
> +                                GBM_BO_USE_SCANOUT_ROTATION_180 | \
> +                                GBM_BO_USE_SCANOUT_ROTATION_270)
> +
>  int
>  gbm_device_get_fd(struct gbm_device *gbm);


More information about the mesa-dev mailing list