[PATCH weston 1/3] compositor-drm: Read FB2_MODIFIERS capability

Sinclair Yeh syeh at vmware.com
Mon Sep 17 17:34:02 UTC 2018


This series, Acked-by: Sinclair Yeh <syeh at vmware.com>

On Wed, Sep 05, 2018 at 05:18:15PM -0700, Deepak Rawat wrote:
> Not all drivers support fb2 modifiers so read the capability before
> using drmModeAddFB2WithModifiers.
> 
> Signed-off-by: Deepak Rawat <drawat at vmware.com>
> ---
>  libweston/compositor-drm.c | 20 +++++++++++++++-----
>  1 file changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 38911763..6a87a296 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -302,6 +302,8 @@ struct drm_backend {
>  	bool shutting_down;
>  
>  	bool aspect_ratio_supported;
> +
> +	bool fb_modifiers;
>  };
>  
>  struct drm_mode {
> @@ -903,7 +905,7 @@ drm_fb_destroy_gbm(struct gbm_bo *bo, void *data)
>  }
>  
>  static int
> -drm_fb_addfb(struct drm_fb *fb)
> +drm_fb_addfb(struct drm_fb *fb, bool fb_modifiers)
>  {
>  	int ret = -EINVAL;
>  #ifdef HAVE_DRM_ADDFB2_MODIFIERS
> @@ -913,7 +915,7 @@ drm_fb_addfb(struct drm_fb *fb)
>  
>  	/* If we have a modifier set, we must only use the WithModifiers
>  	 * entrypoint; we cannot import it through legacy ioctls. */
> -	if (fb->modifier != DRM_FORMAT_MOD_INVALID) {
> +	if (fb_modifiers && fb->modifier != DRM_FORMAT_MOD_INVALID) {
>  		/* KMS demands that if a modifier is set, it must be the same
>  		 * for all planes. */
>  #ifdef HAVE_DRM_ADDFB2_MODIFIERS
> @@ -996,7 +998,7 @@ drm_fb_create_dumb(struct drm_backend *b, int width, int height,
>  	fb->height = height;
>  	fb->fd = b->drm.fd;
>  
> -	if (drm_fb_addfb(fb) != 0) {
> +	if (drm_fb_addfb(fb, b->fb_modifiers) != 0) {
>  		weston_log("failed to create kms fb: %m\n");
>  		goto err_bo;
>  	}
> @@ -1168,7 +1170,7 @@ drm_fb_get_from_dmabuf(struct linux_dmabuf_buffer *dmabuf,
>  			goto err_free;
>  	}
>  
> -	if (drm_fb_addfb(fb) != 0)
> +	if (drm_fb_addfb(fb, backend->fb_modifiers) != 0)
>  		goto err_free;
>  
>  	return fb;
> @@ -1239,7 +1241,7 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend,
>  		goto err_free;
>  	}
>  
> -	if (drm_fb_addfb(fb) != 0) {
> +	if (drm_fb_addfb(fb, backend->fb_modifiers) != 0) {
>  		if (type == BUFFER_GBM_SURFACE)
>  			weston_log("failed to create kms fb: %m\n");
>  		goto err_free;
> @@ -3822,6 +3824,14 @@ init_kms_caps(struct drm_backend *b)
>  	weston_log("DRM: %s atomic modesetting\n",
>  		   b->atomic_modeset ? "supports" : "does not support");
>  
> +#ifdef HAVE_DRM_ADDFB2_MODIFIERS
> +	ret = drmGetCap(b->drm.fd, DRM_CAP_ADDFB2_MODIFIERS, &cap);
> +	if (ret == 0)
> +		b->fb_modifiers = cap;
> +	else
> +#endif
> +		b->fb_modifiers = 0;
> +
>  	/*
>  	 * KMS support for hardware planes cannot properly synchronize
>  	 * without nuclear page flip. Without nuclear/atomic, hw plane
> -- 
> 2.17.1
> 


More information about the wayland-devel mailing list