public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Christoph Manszewski <c.manszewski@samsung.com>
Cc: intel-gfx@lists.freedesktop.org,
	Russell King - ARM Linux <linux@armlinux.org.uk>,
	dri-devel@lists.freedesktop.org,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Harry Wentland <harry.wentland@amd.com>,
	Ilia Mirkin <imirkin@alum.mit.edu>
Subject: Re: [v2, 1/8] drm: Add optional COLOR_ENCODING and COLOR_RANGE properties to drm_plane
Date: Fri, 30 Nov 2018 15:25:12 +0200	[thread overview]
Message-ID: <20181130132512.GR9144@intel.com> (raw)
In-Reply-To: <2a1074ba-e2a7-83fc-8a13-c785dc8da2f9@samsung.com>

On Fri, Nov 30, 2018 at 02:08:11PM +0100, Christoph Manszewski wrote:
> Hi,
> 
> I am looking for a way to export the color encoding and range selection
> to user space. I came across those properties and am wondering, why
> they are meant only for non RGB color encodings. Would it be okay, to
> modify them and use with RGB formats as well?

What you trying to do? Input limited range RGB data and expand to full
range?

> 
> Regards,
> Chris
> 
> 
> On 02/19/2018 09:28 PM, Ville Syrjala wrote:
> > From: Jyri Sarha <jsarha@ti.com>
> >
> > Add a standard optional properties to support different non RGB color
> > encodings in DRM planes. COLOR_ENCODING select the supported non RGB
> > color encoding, for instance ITU-R BT.709 YCbCr. COLOR_RANGE selects
> > the value ranges within the selected color encoding. The properties
> > are stored to drm_plane object to allow different set of supported
> > encoding for different planes on the device.
> >
> > v2: Add/fix kerneldocs, verify bitmasks (danvet)
> >
> > Cc: Harry Wentland <harry.wentland@amd.com>
> > Cc: Daniel Vetter <daniel@ffwll.ch>
> > Cc: Daniel Stone <daniel@fooishbar.org>
> > Cc: Russell King - ARM Linux <linux@armlinux.org.uk>
> > Cc: Ilia Mirkin <imirkin@alum.mit.edu>
> > Cc: Hans Verkuil <hverkuil@xs4all.nl>
> > Cc: Uma Shankar <uma.shankar@intel.com>
> > Cc: Shashank Sharma <shashank.sharma@intel.com>
> > Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > Signed-off-by: Jyri Sarha <jsarha@ti.com>
> > [vsyrjala v2: Add/fix kerneldocs, verify bitmasks]
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > ---
> >   drivers/gpu/drm/drm_atomic.c     |   8 +++
> >   drivers/gpu/drm/drm_color_mgmt.c | 103 +++++++++++++++++++++++++++++++++++++++
> >   include/drm/drm_color_mgmt.h     |  19 ++++++++
> >   include/drm/drm_plane.h          |  32 ++++++++++++
> >   4 files changed, 162 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> > index 46733d534587..452a0b0bafbc 100644
> > --- a/drivers/gpu/drm/drm_atomic.c
> > +++ b/drivers/gpu/drm/drm_atomic.c
> > @@ -759,6 +759,10 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
> >   		state->rotation = val;
> >   	} else if (property == plane->zpos_property) {
> >   		state->zpos = val;
> > +	} else if (property == plane->color_encoding_property) {
> > +		state->color_encoding = val;
> > +	} else if (property == plane->color_range_property) {
> > +		state->color_range = val;
> >   	} else if (plane->funcs->atomic_set_property) {
> >   		return plane->funcs->atomic_set_property(plane, state,
> >   				property, val);
> > @@ -818,6 +822,10 @@ drm_atomic_plane_get_property(struct drm_plane *plane,
> >   		*val = state->rotation;
> >   	} else if (property == plane->zpos_property) {
> >   		*val = state->zpos;
> > +	} else if (property == plane->color_encoding_property) {
> > +		*val = state->color_encoding;
> > +	} else if (property == plane->color_range_property) {
> > +		*val = state->color_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 0d002b045bd2..4b83e078d3e9 100644
> > --- a/drivers/gpu/drm/drm_color_mgmt.c
> > +++ b/drivers/gpu/drm/drm_color_mgmt.c
> > @@ -88,6 +88,20 @@
> >    * drm_mode_crtc_set_gamma_size(). Drivers which support both should use
> >    * drm_atomic_helper_legacy_gamma_set() to alias the legacy gamma ramp with the
> >    * "GAMMA_LUT" property above.
> > + *
> > + * Support for different non RGB color encodings is controlled through
> > + * &drm_plane specific COLOR_ENCODING and COLOR_RANGE properties. They
> > + * are set up by calling drm_plane_create_color_properties().
> > + *
> > + * "COLOR_ENCODING"
> > + * 	Optional plane enum property to support different non RGB
> > + * 	color encodings. The driver can provide a subset of standard
> > + * 	enum values supported by the DRM plane.
> > + *
> > + * "COLOR_RANGE"
> > + * 	Optional plane enum property to support different non RGB
> > + * 	color parameter ranges. The driver can provide a subset of
> > + * 	standard enum values supported by the DRM plane.
> >    */
> >   
> >   /**
> > @@ -339,3 +353,92 @@ int drm_mode_gamma_get_ioctl(struct drm_device *dev,
> >   	drm_modeset_unlock(&crtc->mutex);
> >   	return ret;
> >   }
> > +
> > +static const char * const color_encoding_name[] = {
> > +	[DRM_COLOR_YCBCR_BT601] = "ITU-R BT.601 YCbCr",
> > +	[DRM_COLOR_YCBCR_BT709] = "ITU-R BT.709 YCbCr",
> > +	[DRM_COLOR_YCBCR_BT2020] = "ITU-R BT.2020 YCbCr",
> > +};
> > +
> > +static const char * const color_range_name[] = {
> > +	[DRM_COLOR_YCBCR_FULL_RANGE] = "YCbCr full range",
> > +	[DRM_COLOR_YCBCR_LIMITED_RANGE] = "YCbCr limited range",
> > +};
> > +
> > +/**
> > + * drm_plane_create_color_properties - color encoding related plane properties
> > + * @plane: plane object
> > + * @supported_encodings: bitfield indicating supported color encodings
> > + * @supported_ranges: bitfileld indicating supported color ranges
> > + * @default_encoding: default color encoding
> > + * @default_range: default color range
> > + *
> > + * Create and attach plane specific COLOR_ENCODING and COLOR_RANGE
> > + * properties to @plane. The supported encodings and ranges should
> > + * be provided in supported_encodings and supported_ranges bitmasks.
> > + * Each bit set in the bitmask indicates that its number as enum
> > + * value is supported.
> > + */
> > +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)
> > +{
> > +	struct drm_device *dev = plane->dev;
> > +	struct drm_property *prop;
> > +	struct drm_prop_enum_list enum_list[max(DRM_COLOR_ENCODING_MAX,
> > +						DRM_COLOR_RANGE_MAX)];
> > +	int i, len;
> > +
> > +	if (WARN_ON(supported_encodings == 0 ||
> > +		    (supported_encodings & -BIT(DRM_COLOR_ENCODING_MAX)) != 0 ||
> > +		    (supported_encodings & BIT(default_encoding)) == 0))
> > +		return -EINVAL;
> > +
> > +	if (WARN_ON(supported_ranges == 0 ||
> > +		    (supported_ranges & -BIT(DRM_COLOR_RANGE_MAX)) != 0 ||
> > +		    (supported_ranges & BIT(default_range)) == 0))
> > +		return -EINVAL;
> > +
> > +	len = 0;
> > +	for (i = 0; i < DRM_COLOR_ENCODING_MAX; i++) {
> > +		if ((supported_encodings & BIT(i)) == 0)
> > +			continue;
> > +
> > +		enum_list[len].type = i;
> > +		enum_list[len].name = color_encoding_name[i];
> > +		len++;
> > +	}
> > +
> > +	prop = drm_property_create_enum(dev, 0, "COLOR_ENCODING",
> > +					enum_list, len);
> > +	if (!prop)
> > +		return -ENOMEM;
> > +	plane->color_encoding_property = prop;
> > +	drm_object_attach_property(&plane->base, prop, default_encoding);
> > +	if (plane->state)
> > +		plane->state->color_encoding = default_encoding;
> > +
> > +	len = 0;
> > +	for (i = 0; i < DRM_COLOR_RANGE_MAX; i++) {
> > +		if ((supported_ranges & BIT(i)) == 0)
> > +			continue;
> > +
> > +		enum_list[len].type = i;
> > +		enum_list[len].name = color_range_name[i];
> > +		len++;
> > +	}
> > +
> > +	prop = drm_property_create_enum(dev, 0,	"COLOR_RANGE",
> > +					enum_list, len);
> > +	if (!prop)
> > +		return -ENOMEM;
> > +	plane->color_range_property = prop;
> > +	drm_object_attach_property(&plane->base, prop, default_range);
> > +	if (plane->state)
> > +		plane->state->color_range = default_range;
> > +
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL(drm_plane_create_color_properties);
> > diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h
> > index 03a59cbce621..b3b6d302ca8c 100644
> > --- a/include/drm/drm_color_mgmt.h
> > +++ b/include/drm/drm_color_mgmt.h
> > @@ -26,6 +26,7 @@
> >   #include <linux/ctype.h>
> >   
> >   struct drm_crtc;
> > +struct drm_plane;
> >   
> >   uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision);
> >   
> > @@ -37,4 +38,22 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
> >   int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
> >   				 int gamma_size);
> >   
> > +enum drm_color_encoding {
> > +	DRM_COLOR_YCBCR_BT601,
> > +	DRM_COLOR_YCBCR_BT709,
> > +	DRM_COLOR_YCBCR_BT2020,
> > +	DRM_COLOR_ENCODING_MAX,
> > +};
> > +
> > +enum drm_color_range {
> > +	DRM_COLOR_YCBCR_LIMITED_RANGE,
> > +	DRM_COLOR_YCBCR_FULL_RANGE,
> > +	DRM_COLOR_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);
> >   #endif
> > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > index 8185e3468a23..f7bf4a48b1c3 100644
> > --- a/include/drm/drm_plane.h
> > +++ b/include/drm/drm_plane.h
> > @@ -26,6 +26,7 @@
> >   #include <linux/list.h>
> >   #include <linux/ctype.h>
> >   #include <drm/drm_mode_object.h>
> > +#include <drm/drm_color_mgmt.h>
> >   
> >   struct drm_crtc;
> >   struct drm_printer;
> > @@ -112,6 +113,20 @@ struct drm_plane_state {
> >   	unsigned int zpos;
> >   	unsigned int normalized_zpos;
> >   
> > +	/**
> > +	 * @color_encoding:
> > +	 *
> > +	 * Color encoding for non RGB formats
> > +	 */
> > +	enum drm_color_encoding color_encoding;
> > +
> > +	/**
> > +	 * @color_range:
> > +	 *
> > +	 * Color range for non RGB formats
> > +	 */
> > +	enum drm_color_range color_range;
> > +
> >   	/* Clipped coordinates */
> >   	struct drm_rect src, dst;
> >   
> > @@ -558,6 +573,23 @@ struct drm_plane {
> >   
> >   	struct drm_property *zpos_property;
> >   	struct drm_property *rotation_property;
> > +
> > +	/**
> > +	 * @color_encoding_property:
> > +	 *
> > +	 * Optional "COLOR_ENCODING" enum property for specifying
> > +	 * color encoding for non RGB formats.
> > +	 * See drm_plane_create_color_properties().
> > +	 */
> > +	struct drm_property *color_encoding_property;
> > +	/**
> > +	 * @color_range_property:
> > +	 *
> > +	 * Optional "COLOR_RANGE" enum property for specifying
> > +	 * color range for non RGB formats.
> > +	 * See drm_plane_create_color_properties().
> > +	 */
> > +	struct drm_property *color_range_property;
> >   };
> >   
> >   #define obj_to_plane(x) container_of(x, struct drm_plane, base)

-- 
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-30 13:25 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 19:23 [PATCH 0/8] drm: Add COLOR_ENCODING and COLOR_RANGE plane properties Ville Syrjala
2018-02-14 19:23 ` [PATCH 1/8] drm: Add optional COLOR_ENCODING and COLOR_RANGE properties to drm_plane Ville Syrjala
2018-02-19 15:04   ` Daniel Vetter
2018-02-19 20:19     ` Ville Syrjälä
2018-02-19 20:38       ` Jyri Sarha
2018-02-19 22:38         ` Daniel Vetter
2018-02-19 20:28   ` [PATCH v2 " Ville Syrjala
2018-02-20 11:24     ` Daniel Vetter
2018-11-30 13:08     ` [v2, " Christoph Manszewski
2018-11-30 13:25       ` Ville Syrjälä [this message]
2018-11-30 14:20         ` Andrzej Hajda
2018-11-30 14:29           ` Ville Syrjälä
2018-11-30 14:48             ` Hans Verkuil
2018-11-30 15:16               ` Ville Syrjälä
2018-11-30 15:34                 ` Hans Verkuil
2018-11-30 16:22                   ` Brian Starkey
2018-12-03 11:23               ` Andrzej Hajda
2018-12-03 11:52                 ` Hans Verkuil
2018-12-03 12:51                   ` Andrzej Hajda
2018-11-30 14:40           ` Hans Verkuil
2018-02-14 19:23 ` [PATCH 2/8] drm: Add BT.2020 constant luminance enum value for the COLOR_ENCODING property Ville Syrjala
2018-03-02 12:40   ` Ville Syrjälä
2018-02-14 19:23 ` [PATCH 3/8] drm/atomic: Include color encoding/range in plane state dump Ville Syrjala
2018-02-19 15:08   ` Daniel Vetter
2018-02-19 20:28   ` [PATCH v2 " Ville Syrjala
2018-02-20 11:25     ` Daniel Vetter
2018-02-20 15:57     ` Harry Wentland
2018-02-14 19:23 ` [PATCH 4/8] drm/i915: Correctly handle limited range YCbCr data on VLV/CHV Ville Syrjala
2018-02-14 19:23 ` [PATCH 5/8] drm/i915: Fix plane YCbCr->RGB conversion for GLK Ville Syrjala
2018-02-28 20:43   ` Imre Deak
2018-02-14 19:23 ` [PATCH 6/8] drm/i915: Add support for the YCbCr COLOR_ENCODING property Ville Syrjala
2018-02-14 19:23 ` [PATCH 7/8] drm/i915: Change the COLOR_ENCODING prop default value to BT.709 Ville Syrjala
2018-02-14 19:23 ` [PATCH 8/8] drm/i915: Add support for the YCbCr COLOR_RANGE property Ville Syrjala
2018-02-14 20:53 ` ✗ Fi.CI.CHECKPATCH: warning for drm: Add COLOR_ENCODING and COLOR_RANGE plane properties Patchwork
2018-02-14 20:56 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-02-14 21:09 ` ✓ Fi.CI.BAT: success " Patchwork
2018-02-15  5:34 ` ✓ Fi.CI.IGT: " Patchwork
2018-02-19 15:00 ` [PATCH 0/8] " Daniel Vetter
2018-02-19 15:09 ` Daniel Vetter
2018-02-19 15:52   ` Ville Syrjälä
2018-02-19 20:41 ` ✗ Fi.CI.CHECKPATCH: warning for drm: Add COLOR_ENCODING and COLOR_RANGE plane properties (rev3) Patchwork
2018-02-19 20:43 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-02-19 20:59 ` ✓ Fi.CI.BAT: success " Patchwork
2018-02-20  0:20 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-02-20 11:26 ` [PATCH 0/8] drm: Add COLOR_ENCODING and COLOR_RANGE plane properties Daniel Vetter
2018-02-20 13:42   ` Ville Syrjälä
2018-03-02 13:06 ` 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=20181130132512.GR9144@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=c.manszewski@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=harry.wentland@amd.com \
    --cc=hverkuil@xs4all.nl \
    --cc=imirkin@alum.mit.edu \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linux@armlinux.org.uk \
    /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