diff mbox

[RFC,3/4] drm: add generic blob properties for image enhancement

Message ID 1394086334-20967-4-git-send-email-rahul.sharma@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rahul Sharma March 6, 2014, 6:12 a.m. UTC
Add generic KMS blob properties to core drm framework. These
are writable blob properties which can be used to set Image
Enhancement parameters. The properties which are added here
are meant for color reproduction, color saturation and edge
enhancement.

Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
---
 drivers/gpu/drm/drm_crtc.c  |  115 +++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_crtc.h      |   13 +++++
 include/uapi/drm/drm_mode.h |   41 +++++++++++++++
 3 files changed, 169 insertions(+)

Comments

Daniel Vetter March 7, 2014, 8:36 a.m. UTC | #1
On Thu, Mar 06, 2014 at 11:42:13AM +0530, Rahul Sharma wrote:
> Add generic KMS blob properties to core drm framework. These
> are writable blob properties which can be used to set Image
> Enhancement parameters. The properties which are added here
> are meant for color reproduction, color saturation and edge
> enhancement.
> 
> Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
> ---
>  drivers/gpu/drm/drm_crtc.c  |  115 +++++++++++++++++++++++++++++++++++++++++++
>  include/drm/drm_crtc.h      |   13 +++++
>  include/uapi/drm/drm_mode.h |   41 +++++++++++++++
>  3 files changed, 169 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index a2b87a5..8771abf 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -1260,6 +1260,121 @@ int drm_mode_create_dirty_info_property(struct drm_device *dev)
>  }
>  EXPORT_SYMBOL(drm_mode_create_dirty_info_property);
>  
> +/**
> + * drm_mode_create_color_saturation_property - create property for color saturation
> + * @dev: DRM device
> + *
> + */
> +int drm_mode_create_color_saturation_property(
> +			struct drm_device *dev)
> +{
> +	struct drm_mode_color_saturation *params;
> +	struct drm_property *prop;
> +	char prop_name[] = "color saturation";
> +
> +	if (dev->mode_config.color_saturation_property ||
> +		dev->mode_config.color_saturation_blob_ptr)
> +		return -EEXIST;
> +
> +	prop = drm_property_create(dev, DRM_MODE_PROP_BLOB,
> +			prop_name, 0);
> +	if (!prop) {
> +		DRM_ERROR("fail to create %s property.\n", prop_name);
> +		return -ENOMEM;
> +	}
> +
> +	dev->mode_config.color_saturation_blob_ptr =
> +		drm_property_create_blob(dev, sizeof(*params),
> +			NULL);
> +	if (!dev->mode_config.color_saturation_blob_ptr) {
> +		DRM_ERROR("failed to allocate blob for %s.\n", prop_name);
> +		drm_property_destroy(dev, prop);
> +		return -ENOMEM;
> +	}
> +
> +	dev->mode_config.color_saturation_property = prop;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_mode_create_color_saturation_property);
> +
> +/**
> + * drm_mode_create_color_reproduction_property - create property for color reproduction
> + * @dev: DRM device
> + *
> + */
> +int drm_mode_create_color_reproduction_property(
> +			struct drm_device *dev)
> +{
> +	struct drm_mode_color_reproduction *params;
> +	struct drm_property *prop;
> +	char prop_name[] = "color reproduction";
> +
> +	if (dev->mode_config.color_reproduction_property ||
> +		dev->mode_config.color_reproduction_blob_ptr)
> +		return -EEXIST;
> +
> +	prop = drm_property_create(dev, DRM_MODE_PROP_BLOB,
> +			prop_name, 0);
> +	if (!prop) {
> +		DRM_ERROR("fail to create %s property.\n", prop_name);
> +		return -ENOMEM;
> +	}
> +
> +	dev->mode_config.color_reproduction_blob_ptr =
> +		drm_property_create_blob(dev, sizeof(*params),
> +			NULL);
> +	if (!dev->mode_config.color_reproduction_blob_ptr) {
> +		DRM_ERROR("failed to allocate blob for %s\n", prop_name);
> +		drm_property_destroy(dev, prop);
> +		return -ENOMEM;
> +	}
> +
> +	dev->mode_config.color_reproduction_property = prop;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_mode_create_color_reproduction_property);
> +
> +
> +/**
> + * drm_mode_create_edge_enhancement_property - create property for edge enhancement
> + * @dev: DRM device
> + *
> + */
> +int drm_mode_create_edge_enhancement_property(
> +			struct drm_device *dev)
> +{
> +	struct drm_mode_edge_enhancement *params;
> +	struct drm_property *prop;
> +	char prop_name[] = "edge enhancement";
> +
> +	if (dev->mode_config.edge_enhancement_property ||
> +		dev->mode_config.edge_enhancement_blob_ptr)
> +		return -EEXIST;
> +
> +	prop = drm_property_create(dev, DRM_MODE_PROP_BLOB,
> +			prop_name, 0);
> +	if (!prop) {
> +		DRM_ERROR("fail to create %s property.\n", prop_name);
> +		return -ENOMEM;
> +	}
> +
> +	dev->mode_config.edge_enhancement_blob_ptr =
> +		drm_property_create_blob(dev, sizeof(*params),
> +			NULL);
> +	if (!dev->mode_config.edge_enhancement_blob_ptr) {
> +		DRM_ERROR("failed to allocate blob for %s\n", prop_name);
> +		drm_property_destroy(dev, prop);
> +		return -ENOMEM;
> +	}
> +
> +	dev->mode_config.edge_enhancement_property = prop;
> +
> +	return  0;
> +}
> +EXPORT_SYMBOL(drm_mode_create_edge_enhancement_property);
> +
>  static int drm_mode_group_init(struct drm_device *dev, struct drm_mode_group *group)
>  {
>  	uint32_t total_objects = 0;
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 82f2016..df7b178 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -901,6 +901,13 @@ struct drm_mode_config {
>  	/* Optional properties */
>  	struct drm_property *scaling_mode_property;
>  	struct drm_property *dirty_info_property;
> +	struct drm_property *color_saturation_property;
> +	struct drm_property *color_reproduction_property;
> +	struct drm_property *edge_enhancement_property;
> +
> +	struct drm_property_blob *color_saturation_blob_ptr;
> +	struct drm_property_blob *color_reproduction_blob_ptr;
> +	struct drm_property_blob *edge_enhancement_blob_ptr;
>  
>  	/* dumb ioctl parameters */
>  	uint32_t preferred_depth, prefer_shadow;
> @@ -1079,6 +1086,12 @@ extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats
>  extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
>  extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
>  extern const char *drm_get_encoder_name(const struct drm_encoder *encoder);
> +extern int drm_mode_create_color_saturation_property(
> +		struct drm_device *dev);
> +extern int drm_mode_create_color_reproduction_property(
> +		struct drm_device *dev);
> +extern int drm_mode_create_edge_enhancement_property(
> +		struct drm_device *dev);
>  
>  extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
>  					     struct drm_encoder *encoder);
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 1d8216d..d28f82d 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -504,4 +504,45 @@ struct drm_mode_destroy_dumb {
>  	uint32_t handle;
>  };
>  
> +/* set up parameters for finer color saturation */
> +struct drm_mode_color_saturation {
> +	/* hue gain for individual colors */
> +	uint16_t hue_gain_red;
> +	uint16_t hue_gain_green;
> +	uint16_t hue_gain_blue;
> +	uint16_t hue_gain_cyan;
> +	uint16_t hue_gain_magenta;
> +	uint16_t hue_gain_yellow;
> +	/* hue gain for overall display */
> +	uint16_t hue_gain_overall;
> +};
> +
> +/* set up parameters for standard color reproduction */
> +struct drm_mode_color_reproduction {
> +	/* 16 bit rgb value for primary colors */
> +	uint16_t red_rgb[3];
> +	uint16_t green_rgb[3];
> +	uint16_t blue_rgb[3];
> +	uint16_t cyan_rgb[3];
> +	uint16_t magenta_rgb[3];
> +	uint16_t yellow_rgb[3];
> +	uint16_t white_rgb[3];
> +	uint16_t black_rgb[3];
> +};
> +
> +/* set up parameters for edge enhancement */
> +struct drm_mode_edge_enhancement {
> +	/* threshold values for edge and background*/
> +	uint16_t edge_th;
> +	uint16_t background_th;
> +	/* postive gain */
> +	uint16_t pg_edge;
> +	uint16_t pg_flat;
> +	uint16_t pg_background;
> +	/* negative gain */
> +	uint16_t ng_edge;
> +	uint16_t ng_flat;
> +	uint16_t ng_background;
> +};

Tbh I don't really understand why we can't use normal properties for this.
We might want to add a new RBG type of property (or YUV fwiw, both with
and without alpha) to make this standardized (maybe with some fixed point
value for non-normalizes).

If the only reason you group them is to atomically commit them, then the
only thing we need is the atomic ioctl, which can shovel entire groups of
properties over the wire at once.
-Daniel
Rahul Sharma March 7, 2014, 10:20 a.m. UTC | #2
Hi Daniel,

On 7 March 2014 14:06, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Thu, Mar 06, 2014 at 11:42:13AM +0530, Rahul Sharma wrote:
>> Add generic KMS blob properties to core drm framework. These
>> are writable blob properties which can be used to set Image
>> Enhancement parameters. The properties which are added here
>> are meant for color reproduction, color saturation and edge
>> enhancement.
>>
>> Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
>> ---
>>  drivers/gpu/drm/drm_crtc.c  |  115 +++++++++++++++++++++++++++++++++++++++++++
>>  include/drm/drm_crtc.h      |   13 +++++
>>  include/uapi/drm/drm_mode.h |   41 +++++++++++++++
>>  3 files changed, 169 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
>> index a2b87a5..8771abf 100644
>> --- a/drivers/gpu/drm/drm_crtc.c
>> +++ b/drivers/gpu/drm/drm_crtc.c
>> @@ -1260,6 +1260,121 @@ int drm_mode_create_dirty_info_property(struct drm_device *dev)
>>  }
>>  EXPORT_SYMBOL(drm_mode_create_dirty_info_property);
>>
>> +/**
>> + * drm_mode_create_color_saturation_property - create property for color saturation
>> + * @dev: DRM device
>> + *
>> + */
>> +int drm_mode_create_color_saturation_property(
>> +                     struct drm_device *dev)
>> +{
>> +     struct drm_mode_color_saturation *params;
>> +     struct drm_property *prop;
>> +     char prop_name[] = "color saturation";
>> +
>> +     if (dev->mode_config.color_saturation_property ||
>> +             dev->mode_config.color_saturation_blob_ptr)
>> +             return -EEXIST;
>> +
>> +     prop = drm_property_create(dev, DRM_MODE_PROP_BLOB,
>> +                     prop_name, 0);
>> +     if (!prop) {
>> +             DRM_ERROR("fail to create %s property.\n", prop_name);
>> +             return -ENOMEM;
>> +     }
>> +
>> +     dev->mode_config.color_saturation_blob_ptr =
>> +             drm_property_create_blob(dev, sizeof(*params),
>> +                     NULL);
>> +     if (!dev->mode_config.color_saturation_blob_ptr) {
>> +             DRM_ERROR("failed to allocate blob for %s.\n", prop_name);
>> +             drm_property_destroy(dev, prop);
>> +             return -ENOMEM;
>> +     }
>> +
>> +     dev->mode_config.color_saturation_property = prop;
>> +
>> +     return 0;
>> +}
>> +EXPORT_SYMBOL(drm_mode_create_color_saturation_property);
>> +
>> +/**
>> + * drm_mode_create_color_reproduction_property - create property for color reproduction
>> + * @dev: DRM device
>> + *
>> + */
>> +int drm_mode_create_color_reproduction_property(
>> +                     struct drm_device *dev)
>> +{
>> +     struct drm_mode_color_reproduction *params;
>> +     struct drm_property *prop;
>> +     char prop_name[] = "color reproduction";
>> +
>> +     if (dev->mode_config.color_reproduction_property ||
>> +             dev->mode_config.color_reproduction_blob_ptr)
>> +             return -EEXIST;
>> +
>> +     prop = drm_property_create(dev, DRM_MODE_PROP_BLOB,
>> +                     prop_name, 0);
>> +     if (!prop) {
>> +             DRM_ERROR("fail to create %s property.\n", prop_name);
>> +             return -ENOMEM;
>> +     }
>> +
>> +     dev->mode_config.color_reproduction_blob_ptr =
>> +             drm_property_create_blob(dev, sizeof(*params),
>> +                     NULL);
>> +     if (!dev->mode_config.color_reproduction_blob_ptr) {
>> +             DRM_ERROR("failed to allocate blob for %s\n", prop_name);
>> +             drm_property_destroy(dev, prop);
>> +             return -ENOMEM;
>> +     }
>> +
>> +     dev->mode_config.color_reproduction_property = prop;
>> +
>> +     return 0;
>> +}
>> +EXPORT_SYMBOL(drm_mode_create_color_reproduction_property);
>> +
>> +
>> +/**
>> + * drm_mode_create_edge_enhancement_property - create property for edge enhancement
>> + * @dev: DRM device
>> + *
>> + */
>> +int drm_mode_create_edge_enhancement_property(
>> +                     struct drm_device *dev)
>> +{
>> +     struct drm_mode_edge_enhancement *params;
>> +     struct drm_property *prop;
>> +     char prop_name[] = "edge enhancement";
>> +
>> +     if (dev->mode_config.edge_enhancement_property ||
>> +             dev->mode_config.edge_enhancement_blob_ptr)
>> +             return -EEXIST;
>> +
>> +     prop = drm_property_create(dev, DRM_MODE_PROP_BLOB,
>> +                     prop_name, 0);
>> +     if (!prop) {
>> +             DRM_ERROR("fail to create %s property.\n", prop_name);
>> +             return -ENOMEM;
>> +     }
>> +
>> +     dev->mode_config.edge_enhancement_blob_ptr =
>> +             drm_property_create_blob(dev, sizeof(*params),
>> +                     NULL);
>> +     if (!dev->mode_config.edge_enhancement_blob_ptr) {
>> +             DRM_ERROR("failed to allocate blob for %s\n", prop_name);
>> +             drm_property_destroy(dev, prop);
>> +             return -ENOMEM;
>> +     }
>> +
>> +     dev->mode_config.edge_enhancement_property = prop;
>> +
>> +     return  0;
>> +}
>> +EXPORT_SYMBOL(drm_mode_create_edge_enhancement_property);
>> +
>>  static int drm_mode_group_init(struct drm_device *dev, struct drm_mode_group *group)
>>  {
>>       uint32_t total_objects = 0;
>> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
>> index 82f2016..df7b178 100644
>> --- a/include/drm/drm_crtc.h
>> +++ b/include/drm/drm_crtc.h
>> @@ -901,6 +901,13 @@ struct drm_mode_config {
>>       /* Optional properties */
>>       struct drm_property *scaling_mode_property;
>>       struct drm_property *dirty_info_property;
>> +     struct drm_property *color_saturation_property;
>> +     struct drm_property *color_reproduction_property;
>> +     struct drm_property *edge_enhancement_property;
>> +
>> +     struct drm_property_blob *color_saturation_blob_ptr;
>> +     struct drm_property_blob *color_reproduction_blob_ptr;
>> +     struct drm_property_blob *edge_enhancement_blob_ptr;
>>
>>       /* dumb ioctl parameters */
>>       uint32_t preferred_depth, prefer_shadow;
>> @@ -1079,6 +1086,12 @@ extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats
>>  extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
>>  extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
>>  extern const char *drm_get_encoder_name(const struct drm_encoder *encoder);
>> +extern int drm_mode_create_color_saturation_property(
>> +             struct drm_device *dev);
>> +extern int drm_mode_create_color_reproduction_property(
>> +             struct drm_device *dev);
>> +extern int drm_mode_create_edge_enhancement_property(
>> +             struct drm_device *dev);
>>
>>  extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
>>                                            struct drm_encoder *encoder);
>> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
>> index 1d8216d..d28f82d 100644
>> --- a/include/uapi/drm/drm_mode.h
>> +++ b/include/uapi/drm/drm_mode.h
>> @@ -504,4 +504,45 @@ struct drm_mode_destroy_dumb {
>>       uint32_t handle;
>>  };
>>
>> +/* set up parameters for finer color saturation */
>> +struct drm_mode_color_saturation {
>> +     /* hue gain for individual colors */
>> +     uint16_t hue_gain_red;
>> +     uint16_t hue_gain_green;
>> +     uint16_t hue_gain_blue;
>> +     uint16_t hue_gain_cyan;
>> +     uint16_t hue_gain_magenta;
>> +     uint16_t hue_gain_yellow;
>> +     /* hue gain for overall display */
>> +     uint16_t hue_gain_overall;
>> +};
>> +
>> +/* set up parameters for standard color reproduction */
>> +struct drm_mode_color_reproduction {
>> +     /* 16 bit rgb value for primary colors */
>> +     uint16_t red_rgb[3];
>> +     uint16_t green_rgb[3];
>> +     uint16_t blue_rgb[3];
>> +     uint16_t cyan_rgb[3];
>> +     uint16_t magenta_rgb[3];
>> +     uint16_t yellow_rgb[3];
>> +     uint16_t white_rgb[3];
>> +     uint16_t black_rgb[3];
>> +};
>> +
>> +/* set up parameters for edge enhancement */
>> +struct drm_mode_edge_enhancement {
>> +     /* threshold values for edge and background*/
>> +     uint16_t edge_th;
>> +     uint16_t background_th;
>> +     /* postive gain */
>> +     uint16_t pg_edge;
>> +     uint16_t pg_flat;
>> +     uint16_t pg_background;
>> +     /* negative gain */
>> +     uint16_t ng_edge;
>> +     uint16_t ng_flat;
>> +     uint16_t ng_background;
>> +};
>
> Tbh I don't really understand why we can't use normal properties for this.
> We might want to add a new RBG type of property (or YUV fwiw, both with
> and without alpha) to make this standardized (maybe with some fixed point
> value for non-normalizes).

I dropped Normal properties (the ones which accepts 64 bit data)
because there will be too many of them. As you can see the
count is going upto 24 parameters, means 24 such properties, as
each can carry one parameter. This is too much of overhead.
Please correct me if you mean something different.

I am not sure what are RGB type properties? I know only about 64-bit
normal properties which are too compact to carry above structures. Are
you talking about set_gamma type of ioctls. Each "set_gamma" type
ioctl needs a addition in callbacks till down the layer which looks bit
unnecessary, while writable blob properties are using same set_property
and get_property infrastructure.

>
> If the only reason you group them is to atomically commit them, then the
> only thing we need is the atomic ioctl, which can shovel entire groups of
> properties over the wire at once.

Atomic commit is not an explicit requirement. But splitting them to
many small pieces (in case of normal properties) are resulting into
many user-kernel switching overhead, which seems avoidable.

IF we have a reason to keep blobs Readable, I can work on alternate
methods like 3 new ioclts for saturation, reproduction and edge
enhancement. But as if now writable blob properties seems a better
method to me.

Regards,
Rahul Sharma.

> -Daniel
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
Matt Roper March 8, 2014, 12:46 a.m. UTC | #3
On Fri, Mar 07, 2014 at 03:50:54PM +0530, Rahul Sharma wrote:
> Hi Daniel,
> 
> On 7 March 2014 14:06, Daniel Vetter <daniel@ffwll.ch> wrote:
> > On Thu, Mar 06, 2014 at 11:42:13AM +0530, Rahul Sharma wrote:
> >> Add generic KMS blob properties to core drm framework. These
> >> are writable blob properties which can be used to set Image
> >> Enhancement parameters. The properties which are added here
> >> are meant for color reproduction, color saturation and edge
> >> enhancement.
> >>
> >> Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
...
> > Tbh I don't really understand why we can't use normal properties for this.
> > We might want to add a new RBG type of property (or YUV fwiw, both with
> > and without alpha) to make this standardized (maybe with some fixed point
> > value for non-normalizes).
> 
> I dropped Normal properties (the ones which accepts 64 bit data)
> because there will be too many of them. As you can see the
> count is going upto 24 parameters, means 24 such properties, as
> each can carry one parameter. This is too much of overhead.
> Please correct me if you mean something different.
> 
> I am not sure what are RGB type properties? I know only about 64-bit
> normal properties which are too compact to carry above structures. Are
> you talking about set_gamma type of ioctls. Each "set_gamma" type
> ioctl needs a addition in callbacks till down the layer which looks bit
> unnecessary, while writable blob properties are using same set_property
> and get_property infrastructure.
> 
> >
> > If the only reason you group them is to atomically commit them, then the
> > only thing we need is the atomic ioctl, which can shovel entire groups of
> > properties over the wire at once.
> 
> Atomic commit is not an explicit requirement. But splitting them to
> many small pieces (in case of normal properties) are resulting into
> many user-kernel switching overhead, which seems avoidable.

The idea with atomic modeset / nuclear pageflip is that you collect a
whole bunch of individual property updates into a "property set"
container in userspace (libdrm).  When you're done setting all the
values you want and "commit" the property set, all of the values that
you collected get passed to the kernel in one go via a new ioctl (and
are then updated in an atomic manner by the DRM driver).  So performing
your 24 different property updates via the upcoming atomic API's
shouldn't be a problem and shouldn't add any unnecessary overhead.

The kernel-side of atomic modeset / nuclear pageflip is still a WIP, so
it isn't upstream yet, but you can see the userspace-facing API in Rob
Clark's repo here:

        https://github.com/robclark/libdrm/blob/atomic/xf86drmMode.h

Note the drmModePropertySet{Alloc,Add,Commit,Free}() functions near the
bottom.


Matt
Rahul Sharma March 10, 2014, 4:20 a.m. UTC | #4
On 8 March 2014 06:16, Matt Roper <matthew.d.roper@intel.com> wrote:
> On Fri, Mar 07, 2014 at 03:50:54PM +0530, Rahul Sharma wrote:
>> Hi Daniel,
>>
>> On 7 March 2014 14:06, Daniel Vetter <daniel@ffwll.ch> wrote:
>> > On Thu, Mar 06, 2014 at 11:42:13AM +0530, Rahul Sharma wrote:
>> >> Add generic KMS blob properties to core drm framework. These
>> >> are writable blob properties which can be used to set Image
>> >> Enhancement parameters. The properties which are added here
>> >> are meant for color reproduction, color saturation and edge
>> >> enhancement.
>> >>
>> >> Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
> ...
>> > Tbh I don't really understand why we can't use normal properties for this.
>> > We might want to add a new RBG type of property (or YUV fwiw, both with
>> > and without alpha) to make this standardized (maybe with some fixed point
>> > value for non-normalizes).
>>
>> I dropped Normal properties (the ones which accepts 64 bit data)
>> because there will be too many of them. As you can see the
>> count is going upto 24 parameters, means 24 such properties, as
>> each can carry one parameter. This is too much of overhead.
>> Please correct me if you mean something different.
>>
>> I am not sure what are RGB type properties? I know only about 64-bit
>> normal properties which are too compact to carry above structures. Are
>> you talking about set_gamma type of ioctls. Each "set_gamma" type
>> ioctl needs a addition in callbacks till down the layer which looks bit
>> unnecessary, while writable blob properties are using same set_property
>> and get_property infrastructure.
>>
>> >
>> > If the only reason you group them is to atomically commit them, then the
>> > only thing we need is the atomic ioctl, which can shovel entire groups of
>> > properties over the wire at once.
>>
>> Atomic commit is not an explicit requirement. But splitting them to
>> many small pieces (in case of normal properties) are resulting into
>> many user-kernel switching overhead, which seems avoidable.
>
> The idea with atomic modeset / nuclear pageflip is that you collect a
> whole bunch of individual property updates into a "property set"
> container in userspace (libdrm).  When you're done setting all the
> values you want and "commit" the property set, all of the values that
> you collected get passed to the kernel in one go via a new ioctl (and
> are then updated in an atomic manner by the DRM driver).  So performing
> your 24 different property updates via the upcoming atomic API's
> shouldn't be a problem and shouldn't add any unnecessary overhead.
>
> The kernel-side of atomic modeset / nuclear pageflip is still a WIP, so
> it isn't upstream yet, but you can see the userspace-facing API in Rob
> Clark's repo here:
>
>         https://github.com/robclark/libdrm/blob/atomic/xf86drmMode.h
>
> Note the drmModePropertySet{Alloc,Add,Commit,Free}() functions near the
> bottom.
>

Thanks Matt,

I went through the share link. Got the idea of atomic
modeset. It is a good solution for setting 24 properties
in one go. But another issue is still unaddressed. I
mean still need to declare 24 properties which are not
"Really 24 different properties".

These are sub-parameters to 3 properties (color
reproduction, color saturation and edge enhancement).
Splitting them to 24 pieces, just because we don't have a
a provision in KMS, is a work around to get things
working. And, properties like "saturation_hue_gain_red",
"saturation_hue_gain_green" ... will be undoubtedly ugly.

In Rob Clark's tree, I noticed

extern int drmModePropertySetAddBlob(drmModePropertySetPtr set,
    uint32_t object_id,
    uint32_t property_id,
    uint64_t length,
    void *blob);

Seems, already some implementation of writable blobs is
there. I am not able to see the kernel though.

I request experts, to review this solution again. I found it
quite useful and hold good with the idea of Atomic modeset.

Regards,
Rahul Sharma

>
> Matt
>
> --
> Matt Roper
> Graphics Software Engineer
> ISG Platform Enabling & Development
> Intel Corporation
> (916) 356-2795
Daniel Vetter March 10, 2014, 5:16 a.m. UTC | #5
On Mon, Mar 10, 2014 at 09:50:14AM +0530, Rahul Sharma wrote:
> On 8 March 2014 06:16, Matt Roper <matthew.d.roper@intel.com> wrote:
> > On Fri, Mar 07, 2014 at 03:50:54PM +0530, Rahul Sharma wrote:
> >> Hi Daniel,
> >>
> >> On 7 March 2014 14:06, Daniel Vetter <daniel@ffwll.ch> wrote:
> >> > On Thu, Mar 06, 2014 at 11:42:13AM +0530, Rahul Sharma wrote:
> >> >> Add generic KMS blob properties to core drm framework. These
> >> >> are writable blob properties which can be used to set Image
> >> >> Enhancement parameters. The properties which are added here
> >> >> are meant for color reproduction, color saturation and edge
> >> >> enhancement.
> >> >>
> >> >> Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
> > ...
> >> > Tbh I don't really understand why we can't use normal properties for this.
> >> > We might want to add a new RBG type of property (or YUV fwiw, both with
> >> > and without alpha) to make this standardized (maybe with some fixed point
> >> > value for non-normalizes).
> >>
> >> I dropped Normal properties (the ones which accepts 64 bit data)
> >> because there will be too many of them. As you can see the
> >> count is going upto 24 parameters, means 24 such properties, as
> >> each can carry one parameter. This is too much of overhead.
> >> Please correct me if you mean something different.
> >>
> >> I am not sure what are RGB type properties? I know only about 64-bit
> >> normal properties which are too compact to carry above structures. Are
> >> you talking about set_gamma type of ioctls. Each "set_gamma" type
> >> ioctl needs a addition in callbacks till down the layer which looks bit
> >> unnecessary, while writable blob properties are using same set_property
> >> and get_property infrastructure.
> >>
> >> >
> >> > If the only reason you group them is to atomically commit them, then the
> >> > only thing we need is the atomic ioctl, which can shovel entire groups of
> >> > properties over the wire at once.
> >>
> >> Atomic commit is not an explicit requirement. But splitting them to
> >> many small pieces (in case of normal properties) are resulting into
> >> many user-kernel switching overhead, which seems avoidable.
> >
> > The idea with atomic modeset / nuclear pageflip is that you collect a
> > whole bunch of individual property updates into a "property set"
> > container in userspace (libdrm).  When you're done setting all the
> > values you want and "commit" the property set, all of the values that
> > you collected get passed to the kernel in one go via a new ioctl (and
> > are then updated in an atomic manner by the DRM driver).  So performing
> > your 24 different property updates via the upcoming atomic API's
> > shouldn't be a problem and shouldn't add any unnecessary overhead.
> >
> > The kernel-side of atomic modeset / nuclear pageflip is still a WIP, so
> > it isn't upstream yet, but you can see the userspace-facing API in Rob
> > Clark's repo here:
> >
> >         https://github.com/robclark/libdrm/blob/atomic/xf86drmMode.h
> >
> > Note the drmModePropertySet{Alloc,Add,Commit,Free}() functions near the
> > bottom.
> >
> 
> Thanks Matt,
> 
> I went through the share link. Got the idea of atomic
> modeset. It is a good solution for setting 24 properties
> in one go. But another issue is still unaddressed. I
> mean still need to declare 24 properties which are not
> "Really 24 different properties".
> 
> These are sub-parameters to 3 properties (color
> reproduction, color saturation and edge enhancement).
> Splitting them to 24 pieces, just because we don't have a
> a provision in KMS, is a work around to get things
> working. And, properties like "saturation_hue_gain_red",
> "saturation_hue_gain_green" ... will be undoubtedly ugly.
> 
> In Rob Clark's tree, I noticed
> 
> extern int drmModePropertySetAddBlob(drmModePropertySetPtr set,
>     uint32_t object_id,
>     uint32_t property_id,
>     uint64_t length,
>     void *blob);
> 
> Seems, already some implementation of writable blobs is
> there. I am not able to see the kernel though.
> 
> I request experts, to review this solution again. I found it
> quite useful and hold good with the idea of Atomic modeset.

Like I've said I think creating a standard property for RBG and RBGA
values makes sense, to group this stuff a bit. But I don't think we need
to group things further.

Some clear definitions of these properties is needed though - Sagar from
our display group is working on that a bit.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index a2b87a5..8771abf 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1260,6 +1260,121 @@  int drm_mode_create_dirty_info_property(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_mode_create_dirty_info_property);
 
+/**
+ * drm_mode_create_color_saturation_property - create property for color saturation
+ * @dev: DRM device
+ *
+ */
+int drm_mode_create_color_saturation_property(
+			struct drm_device *dev)
+{
+	struct drm_mode_color_saturation *params;
+	struct drm_property *prop;
+	char prop_name[] = "color saturation";
+
+	if (dev->mode_config.color_saturation_property ||
+		dev->mode_config.color_saturation_blob_ptr)
+		return -EEXIST;
+
+	prop = drm_property_create(dev, DRM_MODE_PROP_BLOB,
+			prop_name, 0);
+	if (!prop) {
+		DRM_ERROR("fail to create %s property.\n", prop_name);
+		return -ENOMEM;
+	}
+
+	dev->mode_config.color_saturation_blob_ptr =
+		drm_property_create_blob(dev, sizeof(*params),
+			NULL);
+	if (!dev->mode_config.color_saturation_blob_ptr) {
+		DRM_ERROR("failed to allocate blob for %s.\n", prop_name);
+		drm_property_destroy(dev, prop);
+		return -ENOMEM;
+	}
+
+	dev->mode_config.color_saturation_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_color_saturation_property);
+
+/**
+ * drm_mode_create_color_reproduction_property - create property for color reproduction
+ * @dev: DRM device
+ *
+ */
+int drm_mode_create_color_reproduction_property(
+			struct drm_device *dev)
+{
+	struct drm_mode_color_reproduction *params;
+	struct drm_property *prop;
+	char prop_name[] = "color reproduction";
+
+	if (dev->mode_config.color_reproduction_property ||
+		dev->mode_config.color_reproduction_blob_ptr)
+		return -EEXIST;
+
+	prop = drm_property_create(dev, DRM_MODE_PROP_BLOB,
+			prop_name, 0);
+	if (!prop) {
+		DRM_ERROR("fail to create %s property.\n", prop_name);
+		return -ENOMEM;
+	}
+
+	dev->mode_config.color_reproduction_blob_ptr =
+		drm_property_create_blob(dev, sizeof(*params),
+			NULL);
+	if (!dev->mode_config.color_reproduction_blob_ptr) {
+		DRM_ERROR("failed to allocate blob for %s\n", prop_name);
+		drm_property_destroy(dev, prop);
+		return -ENOMEM;
+	}
+
+	dev->mode_config.color_reproduction_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_color_reproduction_property);
+
+
+/**
+ * drm_mode_create_edge_enhancement_property - create property for edge enhancement
+ * @dev: DRM device
+ *
+ */
+int drm_mode_create_edge_enhancement_property(
+			struct drm_device *dev)
+{
+	struct drm_mode_edge_enhancement *params;
+	struct drm_property *prop;
+	char prop_name[] = "edge enhancement";
+
+	if (dev->mode_config.edge_enhancement_property ||
+		dev->mode_config.edge_enhancement_blob_ptr)
+		return -EEXIST;
+
+	prop = drm_property_create(dev, DRM_MODE_PROP_BLOB,
+			prop_name, 0);
+	if (!prop) {
+		DRM_ERROR("fail to create %s property.\n", prop_name);
+		return -ENOMEM;
+	}
+
+	dev->mode_config.edge_enhancement_blob_ptr =
+		drm_property_create_blob(dev, sizeof(*params),
+			NULL);
+	if (!dev->mode_config.edge_enhancement_blob_ptr) {
+		DRM_ERROR("failed to allocate blob for %s\n", prop_name);
+		drm_property_destroy(dev, prop);
+		return -ENOMEM;
+	}
+
+	dev->mode_config.edge_enhancement_property = prop;
+
+	return  0;
+}
+EXPORT_SYMBOL(drm_mode_create_edge_enhancement_property);
+
 static int drm_mode_group_init(struct drm_device *dev, struct drm_mode_group *group)
 {
 	uint32_t total_objects = 0;
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 82f2016..df7b178 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -901,6 +901,13 @@  struct drm_mode_config {
 	/* Optional properties */
 	struct drm_property *scaling_mode_property;
 	struct drm_property *dirty_info_property;
+	struct drm_property *color_saturation_property;
+	struct drm_property *color_reproduction_property;
+	struct drm_property *edge_enhancement_property;
+
+	struct drm_property_blob *color_saturation_blob_ptr;
+	struct drm_property_blob *color_reproduction_blob_ptr;
+	struct drm_property_blob *edge_enhancement_blob_ptr;
 
 	/* dumb ioctl parameters */
 	uint32_t preferred_depth, prefer_shadow;
@@ -1079,6 +1086,12 @@  extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats
 extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
 extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
 extern const char *drm_get_encoder_name(const struct drm_encoder *encoder);
+extern int drm_mode_create_color_saturation_property(
+		struct drm_device *dev);
+extern int drm_mode_create_color_reproduction_property(
+		struct drm_device *dev);
+extern int drm_mode_create_edge_enhancement_property(
+		struct drm_device *dev);
 
 extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
 					     struct drm_encoder *encoder);
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 1d8216d..d28f82d 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -504,4 +504,45 @@  struct drm_mode_destroy_dumb {
 	uint32_t handle;
 };
 
+/* set up parameters for finer color saturation */
+struct drm_mode_color_saturation {
+	/* hue gain for individual colors */
+	uint16_t hue_gain_red;
+	uint16_t hue_gain_green;
+	uint16_t hue_gain_blue;
+	uint16_t hue_gain_cyan;
+	uint16_t hue_gain_magenta;
+	uint16_t hue_gain_yellow;
+	/* hue gain for overall display */
+	uint16_t hue_gain_overall;
+};
+
+/* set up parameters for standard color reproduction */
+struct drm_mode_color_reproduction {
+	/* 16 bit rgb value for primary colors */
+	uint16_t red_rgb[3];
+	uint16_t green_rgb[3];
+	uint16_t blue_rgb[3];
+	uint16_t cyan_rgb[3];
+	uint16_t magenta_rgb[3];
+	uint16_t yellow_rgb[3];
+	uint16_t white_rgb[3];
+	uint16_t black_rgb[3];
+};
+
+/* set up parameters for edge enhancement */
+struct drm_mode_edge_enhancement {
+	/* threshold values for edge and background*/
+	uint16_t edge_th;
+	uint16_t background_th;
+	/* postive gain */
+	uint16_t pg_edge;
+	uint16_t pg_flat;
+	uint16_t pg_background;
+	/* negative gain */
+	uint16_t ng_edge;
+	uint16_t ng_flat;
+	uint16_t ng_background;
+};
+
 #endif