[PATCH v14 28/41] compositor-drm: Support modifiers for drm_fb
Pekka Paalanen
ppaalanen at gmail.com
Fri Jan 26 09:58:56 UTC 2018
On Wed, 20 Dec 2017 12:26:45 +0000
Daniel Stone <daniels at collabora.com> wrote:
> Use the new drmModeAddFB2WithModifiers interface to import buffers with
> modifiers.
>
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> ---
> configure.ac | 3 +++
> libweston/compositor-drm.c | 26 +++++++++++++++++++++++++-
> 2 files changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/configure.ac b/configure.ac
> index ba9247773..1f3cc28aa 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -206,6 +206,9 @@ AM_CONDITIONAL(ENABLE_DRM_COMPOSITOR, test x$enable_drm_compositor = xyes)
> if test x$enable_drm_compositor = xyes; then
> AC_DEFINE([BUILD_DRM_COMPOSITOR], [1], [Build the DRM compositor])
> PKG_CHECK_MODULES(DRM_COMPOSITOR, [libudev >= 136 libdrm >= 2.4.30 gbm])
> + PKG_CHECK_MODULES(DRM_COMPOSITOR_MODIFIERS, [libdrm >= 2.4.71],
> + [AC_DEFINE([HAVE_DRM_ADDFB2_MODIFIERS], 1, [libdrm supports modifiers])],
> + [AC_MSG_WARN([libdrm does not support AddFB2 with modifiers])])
> PKG_CHECK_MODULES(DRM_COMPOSITOR_ATOMIC, [libdrm >= 2.4.78],
> [AC_DEFINE([HAVE_DRM_ATOMIC], 1, [libdrm supports atomic API])],
> [AC_MSG_WARN([libdrm does not support atomic modesetting, will omit that capability])])
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 09fa10f5f..713bbabdd 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -293,6 +293,7 @@ struct drm_fb {
> uint32_t strides[4];
> uint32_t offsets[4];
> const struct pixel_format_info *format;
> + uint64_t modifier;
> int width, height;
> int fd;
> struct weston_buffer_reference buffer_ref;
> @@ -843,7 +844,28 @@ drm_fb_destroy_gbm(struct gbm_bo *bo, void *data)
> static int
> drm_fb_addfb(struct drm_fb *fb)
> {
> - int ret;
> + int ret = -EINVAL;
> +#ifdef HAVE_DRM_ADDFB2_MODIFIERS
> + uint64_t mods[4] = { };
> + int i;
> +#endif
> +
> + /* 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) {
> + /* KMS demands that if a modifier is set, it must be the same
> + * for all planes. */
> +#ifdef HAVE_DRM_ADDFB2_MODIFIERS
> + for (i = 0; fb->handles[i]; i++)
This will overflow if all four planes are set.
> + mods[i] = fb->modifier;
> + ret = drmModeAddFB2WithModifiers(fb->fd, fb->width, fb->height,
> + fb->format->format,
> + fb->handles, fb->strides,
> + fb->offsets, mods, &fb->fb_id,
> + DRM_MODE_FB_MODIFIERS);
> +#endif
> + return ret;
> + }
>
> ret = drmModeAddFB2(fb->fd, fb->width, fb->height, fb->format->format,
> fb->handles, fb->strides, fb->offsets, &fb->fb_id,
> @@ -905,6 +927,7 @@ drm_fb_create_dumb(struct drm_backend *b, int width, int height,
> goto err_fb;
>
> fb->type = BUFFER_PIXMAN_DUMB;
> + fb->modifier = DRM_FORMAT_MOD_INVALID;
> fb->handles[0] = create_arg.handle;
> fb->strides[0] = create_arg.pitch;
> fb->size = create_arg.size;
> @@ -972,6 +995,7 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend,
> fb->strides[0] = gbm_bo_get_stride(bo);
> fb->handles[0] = gbm_bo_get_handle(bo).u32;
> fb->format = pixel_format_get_info(gbm_bo_get_format(bo));
> + fb->modifier = DRM_FORMAT_MOD_INVALID;
> fb->size = fb->strides[0] * fb->height;
> fb->fd = backend->drm.fd;
>
Otherwise looks good.
Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20180126/4d2261a0/attachment.sig>
More information about the wayland-devel
mailing list