[PATCH v17 05/14] compositor-drm: Support plane IN_FORMATS

Pekka Paalanen ppaalanen at gmail.com
Mon Jul 9 14:17:53 UTC 2018


On Mon,  9 Jul 2018 14:23:11 +0100
Daniel Stone <daniels at collabora.com> wrote:

> From: Sergi Granell <xerpi.g.12 at gmail.com>
> 
> The per-plane IN_FORMATS KMS property describes the format/modifier
> combinations supported for display on this plane. Read and parse this
> format, storing the data in each plane, so we can know which
> combinations might work, and which combinations definitely will not
> work.
> 
> Similarly to f11ec02cad40 ("compositor-drm: Extract overlay FB import to
> helper"), we now use this when considering promoting a view to overlay
> planes. If the framebuffer's modifier is definitely not supported by the
> plane, we do not attempt to use that plane for that view.
> 
> This will also be used in a follow-patch, passing the list of modifiers
> to GBM surface allocation to allow it to allocate more optimal buffers.
> 
> Signed-off-by: Sergi Granell <xerpi.g.12 at gmail.com>
> Reviewed-by: Daniel Stone <daniels at collabora.com>
> Tested-by: Emre Ucan <eucan at de.adit-jv.com>
> ---
>  configure.ac               |   3 +
>  libweston/compositor-drm.c | 134 ++++++++++++++++++++++++++++++++++---
>  2 files changed, 128 insertions(+), 9 deletions(-)

> +#ifdef HAVE_DRM_FORMATS_BLOB
> +static inline uint32_t *
> +formats_ptr(struct drm_format_modifier_blob *blob)
> +{
> +	return (uint32_t *)(((char *)blob) + blob->formats_offset);
> +}
> +
> +static inline struct drm_format_modifier *
> +modifiers_ptr(struct drm_format_modifier_blob *blob)
> +{
> +	return (struct drm_format_modifier *)
> +		(((char *)blob) + blob->modifiers_offset);
> +}
> +#endif
> +
> +/**
> + * Populates the plane's formats array, using either the IN_FORMATS blob
> + * property (if available), or the plane's format list if not.
> + */
> +static int
> +drm_plane_populate_formats(struct drm_plane *plane, const drmModePlane *kplane,
> +			   const drmModeObjectProperties *props)
> +{
> +	unsigned i;
> +#ifdef HAVE_DRM_FORMATS_BLOB
> +	drmModePropertyBlobRes *blob;
> +	struct drm_format_modifier_blob *fmt_mod_blob;
> +	struct drm_format_modifier *blob_modifiers;
> +	uint32_t *blob_formats;
> +	uint32_t blob_id;
> +
> +	blob_id = drm_property_get_value(&plane->props[WDRM_PLANE_IN_FORMATS],
> +				         props,
> +				         0);
> +	if (blob_id == 0)
> +		goto fallback;
> +
> +	blob = drmModeGetPropertyBlob(plane->backend->drm.fd, blob_id);
> +	if (!blob)
> +		goto fallback;
> +
> +	fmt_mod_blob = blob->data;
> +	blob_formats = formats_ptr(fmt_mod_blob);
> +	blob_modifiers = modifiers_ptr(fmt_mod_blob);
> +
> +	if (plane->count_formats != fmt_mod_blob->count_formats) {
> +		weston_log("DRM backend: format count differs between "
> +		           "plane (%d) and IN_FORMATS (%d)\n",
> +			   plane->count_formats,
> +			   fmt_mod_blob->count_formats);
> +		weston_log("This represents a kernel bug; Weston is "
> +			   "unable to continue.\n");
> +		abort();
> +	}

Awesome.

Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>


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/20180709/b7fa5aeb/attachment.sig>


More information about the wayland-devel mailing list