All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Sharma, Shashank" <shashank.sharma@intel.com>
To: Matt Roper <matthew.d.roper@intel.com>
Cc: annie.j.matheson@intel.com, robert.bradford@intel.com,
	kausalmalladi@gmail.com, avinash.reddy.palleti@intel.com,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	vijay.a.purushothaman@intel.com, jesse.barnes@intel.com,
	gary.k.smith@intel.com, jim.bish@intel.com,
	daniel.vetter@intel.com, kiran.s.kumar@intel.com,
	susanta.bhattacharjee@intel.com
Subject: Re: [PATCH 05/18] drm/i915: Initialize color manager and add gamma correction
Date: Sat, 22 Aug 2015 11:38:36 +0530	[thread overview]
Message-ID: <55D811E4.6060003@intel.com> (raw)
In-Reply-To: <20150821224018.GG13406@intel.com>

Regards
Shashank

On 8/22/2015 4:10 AM, Matt Roper wrote:
> On Thu, Aug 06, 2015 at 10:08:14PM +0530, Shashank Sharma wrote:
>> From: Kausal Malladi <kausalmalladi@gmail.com>
>>
>> As per Color Manager design, each driver is responsible to load its
>> palette color correction and enhancement capabilities in the form of
>> a DRM blob property, so that user space can query and read.
>>
>> This patch does the following:
>> 1. Create new files intel_color_manager(.c/.h)
>> 2. Attach CRTC Palette Capabilities property to CRTC
>> 3. Load all CHV platform specific gamma color capabilities
>> for CRTC into a blob that can be accessible by user space to
>> query capabilities via DRM property interface.
>>
>> Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
>> Signed-off-by: Kausal Malladi <kausalmalladi@gmail.com>
>> ---
>>   drivers/gpu/drm/i915/Makefile              |  3 +-
>>   drivers/gpu/drm/i915/intel_color_manager.c | 83 ++++++++++++++++++++++++++++++
>>   drivers/gpu/drm/i915/intel_color_manager.h | 33 ++++++++++++
>>   drivers/gpu/drm/i915/intel_display.c       |  2 +
>>   drivers/gpu/drm/i915/intel_drv.h           |  4 ++
>>   5 files changed, 124 insertions(+), 1 deletion(-)
>>   create mode 100644 drivers/gpu/drm/i915/intel_color_manager.c
>>   create mode 100644 drivers/gpu/drm/i915/intel_color_manager.h
>>
>> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
>> index 41fb8a9..303b903 100644
>> --- a/drivers/gpu/drm/i915/Makefile
>> +++ b/drivers/gpu/drm/i915/Makefile
>> @@ -60,7 +60,8 @@ i915-y += intel_audio.o \
>>   	  intel_overlay.o \
>>   	  intel_psr.o \
>>   	  intel_sideband.o \
>> -	  intel_sprite.o
>> +	  intel_sprite.o \
>> +	  intel_color_manager.o
>>   i915-$(CONFIG_ACPI)		+= intel_acpi.o intel_opregion.o
>>   i915-$(CONFIG_DRM_I915_FBDEV)	+= intel_fbdev.o
>>
>> diff --git a/drivers/gpu/drm/i915/intel_color_manager.c b/drivers/gpu/drm/i915/intel_color_manager.c
>> new file mode 100644
>> index 0000000..1c9c477
>> --- /dev/null
>> +++ b/drivers/gpu/drm/i915/intel_color_manager.c
>> @@ -0,0 +1,83 @@
>> +/*
>> + * Copyright © 2015 Intel Corporation
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining a
>> + * copy of this software and associated documentation files (the "Software"),
>> + * to deal in the Software without restriction, including without limitation
>> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
>> + * and/or sell copies of the Software, and to permit persons to whom the
>> + * Software is furnished to do so, subject to the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the next
>> + * paragraph) shall be included in all copies or substantial portions of the
>> + * Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
>> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
>> + * IN THE SOFTWARE.
>> + *
>> + * Authors:
>> + * Shashank Sharma <shashank.sharma@intel.com>
>> + * Kausal Malladi <Kausal.Malladi@intel.com>
>> + */
>> +
>> +#include "intel_color_manager.h"
>> +
>> +int get_chv_pipe_gamma_capabilities(struct drm_device *dev,
>> +		struct drm_palette_caps *palette_caps, struct drm_crtc *crtc)
>> +{
>> +	struct drm_property_blob *blob;
>> +
>> +	/*
>> +	 * This function exposes best capability for DeGamma and Gamma
>> +	 * For CHV, the DeGamma LUT has 65 entries
>> +	 * and the best Gamma capability has 257 entries (CGM unit)
>> +	 */
>> +	palette_caps->version = CHV_PALETTE_STRUCT_VERSION;
>> +	palette_caps->num_samples_before_ctm =
>> +		CHV_DEGAMMA_MAX_VALS;
>> +	palette_caps->num_samples_after_ctm =
>> +		CHV_10BIT_GAMMA_MAX_VALS;
>> +
>> +	blob = drm_property_create_blob(dev, sizeof(struct drm_palette_caps),
>> +			(const void *) palette_caps);
>> +
>> +	if (blob)
>> +		return blob->base.id;
>
> It's a corner case, but blob could be a non-NULL error code here (e.g.,
> -ENOMEM).  We should probably check for that before we try to
> dereference it.
>
Agree, will check it.
>> +
>> +	return 0;
>> +}
>> +
>> +int get_pipe_gamma_capabilities(struct drm_device *dev,
>> +		struct drm_palette_caps *palette_caps, struct drm_crtc *crtc)
>> +{
>> +	if (IS_CHERRYVIEW(dev))
>> +		return get_chv_pipe_gamma_capabilities(dev, palette_caps, crtc);
>> +	return -EINVAL;
>
> We only call this function in the IS_CHERRYVIEW case at the moment, so I
> realize the EINVAL return is technically dead code, but going forward
> would it make more sense to return a valid capabilities blob that
> explicitly tells userspace we have no capabilities?
This function is more or less a platform check wrapper, which checks if 
color correction is called for a supported platform. In the next patch 
sets, we have IS_GEN9() and IS_BDW() coming here, and if we fail to find 
the right platform, we are returning -EINVAL for invalid platform.
May be a DRM_ERROR("Invalid platform for color correction") will do the 
justice ?
>
>> +}
>> +
>> +void intel_attach_color_properties_to_crtc(struct drm_device *dev,
>> +		struct drm_mode_object *mode_obj)
>> +{
>> +	struct drm_mode_config *config = &dev->mode_config;
>> +	struct drm_palette_caps *palette_caps;
>> +	struct drm_crtc *crtc;
>> +	int capabilities_blob_id;
>> +
>> +	if (IS_CHERRYVIEW(dev)) {
>> +		crtc = obj_to_crtc(mode_obj);
>> +
>> +		palette_caps = kzalloc(sizeof(struct drm_palette_caps),
>> +				GFP_KERNEL);
>> +		capabilities_blob_id = get_pipe_gamma_capabilities(dev, palette_caps, crtc);
>> +		kfree(palette_caps);
>> +		if (config->cm_crtc_palette_capabilities_property)
>> +			drm_object_attach_property(mode_obj,
>> +				config->cm_crtc_palette_capabilities_property,
>> +				capabilities_blob_id);
>> +	}
>> +}
>> diff --git a/drivers/gpu/drm/i915/intel_color_manager.h b/drivers/gpu/drm/i915/intel_color_manager.h
>> new file mode 100644
>> index 0000000..51aeb91
>> --- /dev/null
>> +++ b/drivers/gpu/drm/i915/intel_color_manager.h
>> @@ -0,0 +1,33 @@
>> +/*
>> + * Copyright © 2015 Intel Corporation
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining a
>> + * copy of this software and associated documentation files (the "Software"),
>> + * to deal in the Software without restriction, including without limitation
>> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
>> + * and/or sell copies of the Software, and to permit persons to whom the
>> + * Software is furnished to do so, subject to the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the next
>> + * paragraph) shall be included in all copies or substantial portions of the
>> + * Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
>> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
>> + * IN THE SOFTWARE.
>> + *
>> + * Authors:
>> + * Shashank Sharma <shashank.sharma@intel.com>
>> + * Kausal Malladi <Kausal.Malladi@intel.com>
>> + */
>> +#include <drm/drmP.h>
>> +#include <drm/drm_crtc_helper.h>
>> +#include "i915_drv.h"
>> +
>> +#define CHV_PALETTE_STRUCT_VERSION		1
>> +#define CHV_DEGAMMA_MAX_VALS			65
>> +#define CHV_10BIT_GAMMA_MAX_VALS		257
>> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
>> index 1412e21..349a1c2 100644
>> --- a/drivers/gpu/drm/i915/intel_display.c
>> +++ b/drivers/gpu/drm/i915/intel_display.c
>> @@ -13975,6 +13975,8 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
>>
>>   	intel_crtc->wm.cxsr_allowed = true;
>>
>> +	intel_attach_color_properties_to_crtc(dev, &intel_crtc->base.base);
>> +
>
> I feel like we should hold off on actually calling this function until
> the very end of your patch series.  If someone is bisecting through
> histroy to track down a bug and they land on this commit, we'll be
> advertising some capabilities to userspace that you don't really have
> yet (since they only show up in the later patches of the series).
> If we wait until the end of the series to "flip the switch" and enable
> color management, then we don't have to worry about running partially
> implemented features during a bisect session.
>
>
> Matt
>
I was afraid of getting review comments like "add the function only when 
you are using it" so I added the call here. Also we thought it would be 
preferable to add this in the patch where actually initialize the color 
management. If you still think we should move it, I can do it.
>>   	BUG_ON(pipe >= ARRAY_SIZE(dev_priv->plane_to_crtc_mapping) ||
>>   	       dev_priv->plane_to_crtc_mapping[intel_crtc->plane] != NULL);
>>   	dev_priv->plane_to_crtc_mapping[intel_crtc->plane] = &intel_crtc->base;
>> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
>> index b3dc138..dee5f91 100644
>> --- a/drivers/gpu/drm/i915/intel_drv.h
>> +++ b/drivers/gpu/drm/i915/intel_drv.h
>> @@ -1438,4 +1438,8 @@ void intel_plane_destroy_state(struct drm_plane *plane,
>>   			       struct drm_plane_state *state);
>>   extern const struct drm_plane_helper_funcs intel_plane_helper_funcs;
>>
>> +/* intel_color_manager.c */
>> +void intel_attach_color_properties_to_crtc(struct drm_device *dev,
>> +		struct drm_mode_object *mode_obj);
>> +
>>   #endif /* __INTEL_DRV_H__ */
>> --
>> 1.9.1
>>
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2015-08-22  6:08 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-06 16:38 [PATCH 00/18] Color Management for DRM Shashank Sharma
2015-08-06 16:38 ` [PATCH 01/18] drm: Create Color Management DRM properties Shashank Sharma
2015-08-06 16:38 ` [PATCH 02/18] drm/i915: Add atomic set property interface for CRTC Shashank Sharma
2015-08-06 16:38 ` [PATCH 03/18] drm/i915: Add atomic get " Shashank Sharma
2015-08-21 22:40   ` Matt Roper
2015-08-22  6:00     ` Sharma, Shashank
2015-08-25  7:16       ` Daniel Vetter
2015-08-06 16:38 ` [PATCH 04/18] drm: Add structure for querying palette color capabilities Shashank Sharma
2015-08-06 16:38 ` [PATCH 05/18] drm/i915: Initialize color manager and add gamma correction Shashank Sharma
2015-08-21 22:40   ` Matt Roper
2015-08-22  6:08     ` Sharma, Shashank [this message]
2015-08-06 16:38 ` [PATCH 06/18] drm: Add color correction blobs in CRTC state Shashank Sharma
2015-08-21 22:40   ` Matt Roper
2015-08-22  6:09     ` Sharma, Shashank
2015-08-06 16:38 ` [PATCH 07/18] drm: Add drm structures for palette color property Shashank Sharma
2015-08-06 16:38 ` [PATCH 08/18] drm/i915: Add pipe gamma correction handlers Shashank Sharma
2015-08-21 22:40   ` Matt Roper
2015-08-22  6:11     ` Sharma, Shashank
2015-08-25  7:18       ` Daniel Vetter
2015-08-06 16:38 ` [PATCH 09/18] drm/i915: Pipe level Gamma correction for CHV/BSW Shashank Sharma
2015-08-21 22:41   ` Matt Roper
2015-08-22  6:18     ` Sharma, Shashank
2015-08-06 16:38 ` [PATCH 10/18] drm/i915: Add pipe deGamma correction handlers Shashank Sharma
2015-08-06 16:38 ` [PATCH 11/18] drm/i915: Add DeGamma correction for CHV/BSW Shashank Sharma
2015-08-06 16:38 ` [PATCH 12/18] drm: Add structure for set/get a CTM color property Shashank Sharma
2015-08-06 16:38 ` [PATCH 13/18] drm/i915: Add set/get property handlers for CSC correction Shashank Sharma
2015-08-06 16:38 ` [PATCH 14/18] drm/i915: Add CSC correction for CHV/BSW Shashank Sharma
2015-08-06 16:38 ` [PATCH 15/18] drm/i915: Initialize Gen8 pipe gamma correction Shashank Sharma
2015-08-21 22:41   ` Matt Roper
2015-08-22  6:31     ` Sharma, Shashank
2015-08-06 16:38 ` [PATCH 16/18] drm/i915: Gen8 pipe level Gamma correction Shashank Sharma
2015-08-06 16:38 ` [PATCH 17/18] drm/i915: Add DeGamma correction for BDW/SKL/BXT Shashank Sharma
2015-08-06 16:38 ` [PATCH 18/18] drm/i915: Add CSC " Shashank Sharma
2015-08-13  0:28   ` shuang.he
2015-09-30 17:49   ` Rob Bradford
2015-09-08 10:49 ` [PATCH 00/18] Color Management for DRM Rob Bradford
2015-09-08 11:10   ` Sharma, Shashank

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=55D811E4.6060003@intel.com \
    --to=shashank.sharma@intel.com \
    --cc=annie.j.matheson@intel.com \
    --cc=avinash.reddy.palleti@intel.com \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary.k.smith@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jesse.barnes@intel.com \
    --cc=jim.bish@intel.com \
    --cc=kausalmalladi@gmail.com \
    --cc=kiran.s.kumar@intel.com \
    --cc=matthew.d.roper@intel.com \
    --cc=robert.bradford@intel.com \
    --cc=susanta.bhattacharjee@intel.com \
    --cc=vijay.a.purushothaman@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.