dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Kevin Strasser <kevin.strasser@intel.com>
Cc: David Airlie <airlied@linux.ie>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/3] drm: Add optional PIXEL_NORMALIZE_RANGE property to drm_plane
Date: Thu, 29 Nov 2018 20:45:45 +0200	[thread overview]
Message-ID: <20181129184545.GO9144@intel.com> (raw)
In-Reply-To: <1543473493-30973-3-git-send-email-kevin.strasser@intel.com>

On Wed, Nov 28, 2018 at 10:38:12PM -0800, Kevin Strasser wrote:
> Add an optional property to allow applications to indicate what range their
> floating point pixel data is normalized to. Drivers are free to choose what
> ranges they want to support and can attach this property to each plane that
> actually supports floating point formats

Do we have a plan to actually use this? Earlier platforms didn't have
anything like this IIRC.

> 
> Signed-off-by: Kevin Strasser <kevin.strasser@intel.com>
> Cc: Uma Shankar <uma.shankar@intel.com>
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: dri-devel@lists.freedesktop.org
> ---
>  drivers/gpu/drm/drm_atomic.c        |  2 ++
>  drivers/gpu/drm/drm_atomic_uapi.c   |  4 +++
>  drivers/gpu/drm/drm_color_mgmt.c    | 68 +++++++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/drm_crtc_internal.h |  1 +
>  include/drm/drm_color_mgmt.h        |  9 +++++
>  include/drm/drm_plane.h             | 14 ++++++++
>  6 files changed, 98 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 1706ed1..1f520ef 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -624,6 +624,8 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,
>  		   drm_get_color_encoding_name(state->color_encoding));
>  	drm_printf(p, "\tcolor-range=%s\n",
>  		   drm_get_color_range_name(state->color_range));
> +	drm_printf(p, "\tpixel-normalize-range=%s\n",
> +		   drm_get_pixel_normalize_range_name(state->pixel_normalize_range));
>  
>  	if (plane->funcs->atomic_print_state)
>  		plane->funcs->atomic_print_state(p, state);
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index 86ac339..e79a23cd 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> @@ -566,6 +566,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
>  		state->color_encoding = val;
>  	} else if (property == plane->color_range_property) {
>  		state->color_range = val;
> +	} else if (property == plane->pixel_normalize_range_property) {
> +		state->pixel_normalize_range = val;
>  	} else if (plane->funcs->atomic_set_property) {
>  		return plane->funcs->atomic_set_property(plane, state,
>  				property, val);
> @@ -621,6 +623,8 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
>  		*val = state->color_encoding;
>  	} else if (property == plane->color_range_property) {
>  		*val = state->color_range;
> +	} else if (property == plane->pixel_normalize_range_property) {
> +		*val = state->pixel_normalize_range;
>  	} else if (plane->funcs->atomic_get_property) {
>  		return plane->funcs->atomic_get_property(plane, state, property, val);
>  	} else {
> diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c
> index 581cc37..b1e2a0a 100644
> --- a/drivers/gpu/drm/drm_color_mgmt.c
> +++ b/drivers/gpu/drm/drm_color_mgmt.c
> @@ -472,3 +472,71 @@ int drm_plane_create_color_properties(struct drm_plane *plane,
>  	return 0;
>  }
>  EXPORT_SYMBOL(drm_plane_create_color_properties);
> +
> +static const char * const pixel_normalize_range_name[] = {
> +	[DRM_PIXEL_NORMALIZE_RANGE_0_1] = "0.0 - 1.0",
> +	[DRM_PIXEL_NORMALIZE_RANGE_0_255] = "0.0 - 255.0",
> +};
> +
> +/**
> + * drm_get_pixel_normalize_range_name - return a string for pixel normalize
> + * range
> + * @range: pixel normalize range to compute name of
> + *
> + * In contrast to the other drm_get_*_name functions this one here returns a
> + * const pointer and hence is threadsafe.
> + */
> +const char *drm_get_pixel_normalize_range_name(enum drm_pixel_normalize_range range)
> +{
> +	if (WARN_ON(range >= ARRAY_SIZE(pixel_normalize_range_name)))
> +		return "unknown";
> +
> +	return pixel_normalize_range_name[range];
> +}
> +
> +/**
> + * drm_plane_create_pixel_normalize_range_property - pixel normalize range
> + * property
> + * @plane: plane object
> + * @supported_ranges: bitfield indicating supported normalize ranges
> + * @default_range: default normalize range
> + *
> + * Create and attach plane specific PIXEL_NORMALIZE_RANGE property to @plane.
> + * The supported ranges should be provided in supported_ranges bitmask. Eeach
> + * bit set in the bitmask indicates that its number as enum value is supported.
> + */
> +int drm_plane_create_pixel_normalize_range_property(struct drm_plane *plane,
> +	u32 supported_ranges, enum drm_pixel_normalize_range default_range)
> +{
> +	struct drm_property *prop;
> +	struct drm_prop_enum_list enum_list[DRM_PIXEL_NORMALIZE_RANGE_MAX];
> +	int i, len = 0;
> +
> +	if (WARN_ON(supported_ranges == 0 ||
> +		    (supported_ranges & -BIT(DRM_PIXEL_NORMALIZE_RANGE_MAX)) != 0 ||
> +		    (supported_ranges & BIT(default_range)) == 0))
> +		return -EINVAL;
> +
> +	for (i = 0; i < DRM_PIXEL_NORMALIZE_RANGE_MAX; i++) {
> +		if ((supported_ranges & BIT(i)) == 0)
> +			continue;
> +
> +		enum_list[len].type = i;
> +		enum_list[len].name = pixel_normalize_range_name[i];
> +		len++;
> +	}
> +
> +	prop = drm_property_create_enum(plane->dev, 0, "PIXEL_NORMALIZE_RANGE",
> +					enum_list, len);
> +	if (!prop)
> +		return -ENOMEM;
> +
> +	plane->pixel_normalize_range_property = prop;
> +	drm_object_attach_property(&plane->base, prop, default_range);
> +
> +	if (plane->state)
> +		plane->state->pixel_normalize_range = default_range;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_plane_create_pixel_normalize_range_property);
> diff --git a/drivers/gpu/drm/drm_crtc_internal.h b/drivers/gpu/drm/drm_crtc_internal.h
> index 8689344..82ddc50 100644
> --- a/drivers/gpu/drm/drm_crtc_internal.h
> +++ b/drivers/gpu/drm/drm_crtc_internal.h
> @@ -90,6 +90,7 @@ int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
>  /* drm_color_mgmt.c */
>  const char *drm_get_color_encoding_name(enum drm_color_encoding encoding);
>  const char *drm_get_color_range_name(enum drm_color_range range);
> +const char *drm_get_pixel_normalize_range_name(enum drm_pixel_normalize_range range);
>  
>  /* IOCTLs */
>  int drm_mode_gamma_get_ioctl(struct drm_device *dev,
> diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
> index 90ef999..460e31c 100644
> --- a/include/drm/drm_color_mgmt.h
> +++ b/include/drm/drm_color_mgmt.h
> @@ -64,9 +64,18 @@ enum drm_color_range {
>  	DRM_COLOR_RANGE_MAX,
>  };
>  
> +enum drm_pixel_normalize_range {
> +	DRM_PIXEL_NORMALIZE_RANGE_0_1,
> +	DRM_PIXEL_NORMALIZE_RANGE_0_255,
> +	DRM_PIXEL_NORMALIZE_RANGE_MAX
> +};
> +
>  int drm_plane_create_color_properties(struct drm_plane *plane,
>  				      u32 supported_encodings,
>  				      u32 supported_ranges,
>  				      enum drm_color_encoding default_encoding,
>  				      enum drm_color_range default_range);
> +int drm_plane_create_pixel_normalize_range_property(struct drm_plane *plane,
> +				u32 supported_ranges,
> +				enum drm_pixel_normalize_range default_range);
>  #endif
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 3701f56..11f5be4 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -130,6 +130,13 @@ struct drm_plane_state {
>  	uint16_t pixel_blend_mode;
>  
>  	/**
> +	 * @pixel_normalize_range:
> +	 * The range to use for floating point pixel data normalization. See
> +	 * drm_plane_create_pixel_normalize_range_property() for more details.
> +	 */
> +	enum drm_pixel_normalize_range pixel_normalize_range;
> +
> +	/**
>  	 * @rotation:
>  	 * Rotation of the plane. See drm_plane_create_rotation_property() for
>  	 * more details.
> @@ -680,6 +687,13 @@ struct drm_plane {
>  	struct drm_property *blend_mode_property;
>  
>  	/**
> +	 * @pixel_normalize_range_property:
> +	 * Optional "PIXEL_NORMALIZE_RANGE" property for this plane. See
> +	 * drm_plane_create_pixel_normalize_range_property().
> +	 */
> +	struct drm_property *pixel_normalize_range_property;
> +
> +	/**
>  	 * @color_encoding_property:
>  	 *
>  	 * Optional "COLOR_ENCODING" enum property for specifying
> -- 
> 2.7.4

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2018-11-29 18:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-29  6:38 [PATCH 0/3] Support 64 bpp half float formats Kevin Strasser
2018-11-29  6:38 ` [PATCH 1/3] drm/fourcc: Add " Kevin Strasser
2018-11-29 18:42   ` Ville Syrjälä
2018-11-29 21:38     ` Strasser, Kevin
2018-11-29  6:38 ` [PATCH 2/3] drm: Add optional PIXEL_NORMALIZE_RANGE property to drm_plane Kevin Strasser
2018-11-29 18:45   ` Ville Syrjälä [this message]
2018-11-29 21:38     ` Strasser, Kevin
2018-11-29  6:38 ` [PATCH 3/3] drm/i915: Implement half float formats and pixel normalize property Kevin Strasser
2018-11-29  9:18   ` Daniel Vetter
2018-11-29 17:52     ` Strasser, Kevin
2018-11-30  9:42       ` Daniel Vetter
2018-11-29 18:52   ` Ville Syrjälä
2018-11-29 21:39     ` Strasser, Kevin
2018-11-29 19:26 ` [Intel-gfx] [PATCH 0/3] Support 64 bpp half float formats Ville Syrjälä
2018-11-29 21:39   ` Strasser, Kevin
2018-11-30 14:15     ` Ville Syrjälä

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181129184545.GO9144@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=airlied@linux.ie \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=kevin.strasser@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox