[RFC weston 08/14] compositor-drm: Add universal plane awareness

Pekka Paalanen ppaalanen at gmail.com
Thu May 21 04:16:35 PDT 2015


On Thu, 21 May 2015 08:29:05 +0100
Daniel Stone <daniels at collabora.com> wrote:

> Add awareness of, rather than support for, universal planes. Activate
> the client cap when we start if possible, and if this is activated,
> studiously ignore non-overlay planes. For now.
> 
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> ---
>  src/compositor-drm.c | 384 ++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 381 insertions(+), 3 deletions(-)
> 
> diff --git a/src/compositor-drm.c b/src/compositor-drm.c
> index 5d07955..2a70728 100644
> --- a/src/compositor-drm.c
> +++ b/src/compositor-drm.c

> +static uint32_t
> +drm_property_get_enum_map(const struct property_item *item, uint64_t *map,
> +			  const char * const *enum_names, int nenums)
> +{
> +	drmModePropertyRes *prop = item->drm_prop;
> +	uint32_t valid_mask = 0;
> +	int seen = 0;
> +	int i, j;

+	assert(nenums <= 32 && "update return type");

Since this is now using a mask too.

> +
> +	memset(map, 0, nenums * sizeof *map);
> +
> +	if (!prop) {
> +		weston_log("DRM warning: attempting to init property enum, "
> +			   "that was not found. (e.g. '%s')\n",
> +			   enum_names[0]);
> +		return 0;
> +	}
> +
> +	if (!(prop->flags & DRM_MODE_PROP_ENUM) || prop->count_enums < 1) {
> +		weston_log("DRM error: property %d '%s' is not an enum.\n",
> +			   prop->prop_id, prop->name);
> +		return 0;
> +	}
> +
> +	for (i = 0; i < prop->count_enums; i++) {
> +		struct drm_mode_property_enum *en = &prop->enums[i];
> +
> +		for (j = 0; j < nenums; j++) {
> +			if (!strcmp(en->name, enum_names[j]))
> +				break;
> +		}
> +
> +		if (j == nenums) {
> +			weston_log("DRM debug: property %d '%s' "
> +				   "has unrecognized enum %#" PRIx64 " '%s'\n",
> +				   prop->prop_id, prop->name,
> +				   (uint64_t)en->value, en->name);
> +			break;
> +		}
> +
> +		map[j] = en->value;
> +		valid_mask |= (1U << j);
> +		seen++;
> +	}
> +
> +	if (seen != nenums)
> +		weston_log("DRM debug: property %d '%s' has %u of %u "
> +			   "expected enum values.\n",
> +			   prop->prop_id, prop->name, seen, nenums);
> +
> +	return valid_mask;
> +}

> +static bool
> +plane_properties_init(struct drm_plane *plane)
> +{
> +	static const char * const plane_property_names[] = {
> +		[WDRM_PLANE_TYPE] = "type",
> +	};
> +	static const char * const plane_type_names[] = {
> +		[WDRM_PLANE_TYPE_PRIMARY] = "Primary",
> +		[WDRM_PLANE_TYPE_OVERLAY] = "Overlay",
> +		[WDRM_PLANE_TYPE_CURSOR] = "Cursor",
> +	};
> +	uint32_t type_mask;
> +	uint32_t required_mask;
> +
> +	static_assert(ARRAY_LENGTH(plane_property_names) == WDRM_PLANE__COUNT,
> +		      "plane_property_names mismatch with the enum");
> +	static_assert(ARRAY_LENGTH(plane_type_names) == WDRM_PLANE_TYPE__COUNT,
> +		      "plane_type_names mismatch with the enum");
> +	static_assert(WDRM_PLANE__COUNT <= 32,
> +		      "need more bits for plane item_valid_mask");

Adding use of static_assert(), but what is providing the definition of
static_assert()?


> @@ -1393,6 +1750,11 @@ init_drm(struct drm_compositor *ec, struct udev_device *device)
>  	else
>  		ec->cursor_height = 64;
>  
> +	ret = drmSetClientCap(fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
> +	ec->universal_planes = (ret == 0);
> +	weston_log("DRM: %s universal planes\n",
> +		   ec->universal_planes ? "supports" : "does not support");
> +
>  	return 0;
>  }
>  
> @@ -2321,6 +2683,14 @@ drm_plane_create(struct drm_compositor *ec, const drmModePlane *kplane)
>  	memcpy(plane->formats, kplane->formats,
>  	       kplane->count_formats * sizeof(kplane->formats[0]));
>  
> +	if (!plane_properties_init(plane)) {

Forgot weston_plane_release(), because...

> +		free(plane);
> +		return NULL;
> +	}
> +
> +	weston_plane_init(&plane->base, &ec->base, 0, 0);

...there is already a weston_plane_init() above in this function. I
mean, there are two inits.

> +	wl_list_insert(&ec->sprite_list, &plane->link);

This makes the wl_list_init() above redundant.

> +
>  	return plane;
>  }

Thanks,
pq


More information about the wayland-devel mailing list