[Intel-gfx] [PATCH] drm: Add aux plane verification in addFB2

Thulasimani, Sivakumar sivakumar.thulasimani at intel.com
Mon Nov 2 08:41:33 PST 2015



On 11/2/2015 3:20 PM, Vandana Kannan wrote:
> For render compression, userspace passes aux stride and offset values as an
> additional entry in the fb structure. This should not be treated as garbage
> and discarded as data belonging to no plane.
> This patch introduces a check related to AUX plane to support the
> scenario of render compression.
>
> Suggested-by: Daniel Vetter <daniel at ffwll.ch>
> Signed-off-by: Vandana Kannan <vandana.kannan at intel.com>
> ---
>   drivers/gpu/drm/drm_crtc.c  | 16 +++++++++++++++-
>   drivers/gpu/drm/drm_ioctl.c |  3 +++
>   include/drm/drm_crtc.h      |  3 +++
>   include/uapi/drm/drm.h      |  1 +
>   include/uapi/drm/drm_mode.h |  1 +
>   5 files changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 24c5434..7dbc0f0 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -3204,6 +3204,13 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
>   		}
>   	}
>   
> +	if (r->flags & DRM_MODE_FB_AUX_PLANE) {
> +		if (num_planes == 4)
how can num_planes be 4 since the max it can get seems to be 3.

regards,
Sivakumar
> +			return -EINVAL;
> +
> +		num_planes++;
> +	}
> +
>   	for (i = num_planes; i < 4; i++) {
>   		if (r->modifier[i]) {
>   			DRM_DEBUG_KMS("non-zero modifier for unused plane %d\n", i);
> @@ -3242,7 +3249,8 @@ internal_framebuffer_create(struct drm_device *dev,
>   	struct drm_framebuffer *fb;
>   	int ret;
>   
> -	if (r->flags & ~(DRM_MODE_FB_INTERLACED | DRM_MODE_FB_MODIFIERS)) {
> +	if (r->flags & ~(DRM_MODE_FB_INTERLACED | DRM_MODE_FB_MODIFIERS |
> +		DRM_MODE_FB_AUX_PLANE)) {
>   		DRM_DEBUG_KMS("bad framebuffer flags 0x%08x\n", r->flags);
>   		return ERR_PTR(-EINVAL);
>   	}
> @@ -3264,6 +3272,12 @@ internal_framebuffer_create(struct drm_device *dev,
>   		return ERR_PTR(-EINVAL);
>   	}
>   
> +	if (r->flags & DRM_MODE_FB_AUX_PLANE &&
> +	    !dev->mode_config.allow_aux_plane) {
> +		DRM_DEBUG_KMS("driver does not support render compression\n");
> +		return ERR_PTR(-EINVAL);
> +	}
> +
>   	ret = framebuffer_check(r);
>   	if (ret)
>   		return ERR_PTR(ret);
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index 8ce2a0c..ee00782 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -312,6 +312,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
>   	case DRM_CAP_ADDFB2_MODIFIERS:
>   		req->value = dev->mode_config.allow_fb_modifiers;
>   		break;
> +	case DRM_CAP_RENDER_COMPRESSION:
> +		req->value = dev->mode_config.allow_aux_plane;
> +		break;
>   	default:
>   		return -EINVAL;
>   	}
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 3f0c690..a5a9da2 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -1152,6 +1152,9 @@ struct drm_mode_config {
>   	/* whether the driver supports fb modifiers */
>   	bool allow_fb_modifiers;
>   
> +	/* whether the driver supports render compression */
> +	bool allow_aux_plane;
> +
>   	/* cursor size */
>   	uint32_t cursor_width, cursor_height;
>   };
> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
> index 3801584..0834bf7 100644
> --- a/include/uapi/drm/drm.h
> +++ b/include/uapi/drm/drm.h
> @@ -631,6 +631,7 @@ struct drm_gem_open {
>   #define DRM_CAP_CURSOR_WIDTH		0x8
>   #define DRM_CAP_CURSOR_HEIGHT		0x9
>   #define DRM_CAP_ADDFB2_MODIFIERS	0x10
> +#define DRM_CAP_RENDER_COMPRESSION	0x11
>   
>   /** DRM_IOCTL_GET_CAP ioctl argument type */
>   struct drm_get_cap {
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 6c11ca4..de59ace 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -354,6 +354,7 @@ struct drm_mode_fb_cmd {
>   
>   #define DRM_MODE_FB_INTERLACED	(1<<0) /* for interlaced framebuffers */
>   #define DRM_MODE_FB_MODIFIERS	(1<<1) /* enables ->modifer[] */
> +#define DRM_MODE_FB_AUX_PLANE   (1<<2) /* for compressed buffer */
>   
>   struct drm_mode_fb_cmd2 {
>   	__u32 fb_id;



More information about the Intel-gfx mailing list