On Mon,  9 Jul 2018 14:23:11 +0100
Daniel Stone <[email protected]> wrote:

> From: Sergi Granell <[email protected]>
> 
> 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 <[email protected]>
> Reviewed-by: Daniel Stone <[email protected]>
> Tested-by: Emre Ucan <[email protected]>
> ---
>  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 <[email protected]>


Thanks,
pq

Attachment: pgpL0LnFmqeIO.pgp
Description: OpenPGP digital signature

_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to