Skip to contentSkip to conversation

Color Management for DRM

PATCH In review Shashank Sharma 8 participants 65 messages Sep 16, 2015 – Sep 30, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Color Management for DRM

This patch set adds Color Manager implementation in DRM layer. Color Manager is an extension in DRM framework to support color correction/enhancement.

Various Hardware platforms can support several color correction capabilities. Color Manager provides abstraction of these capabilities and allows a user space UI agent to correct/enhance the display using the DRM property interface.

How is this going to work?
==========================
1. This patch series adds a few new properties in DRM framework. These properties are:
a. color_capabilities property (type blob)
b. Color Transformation Matrix property for corrections like CSC (called CTM, type blob)
c. Palette correction properties for corrections like gamma fixup (called palette_correction, type blob)
2. Also, this patch series adds few structures to indicate specifications of a property like size, no_of_samples for correction etc.
3. These properties are present in mode_config.
4. When the platform's display driver loads, it fills up the values of color_capabilities property using the standard structures (added in step 2). For example, Intel's I915 driver adds following color correction capabilities:
a. gamma correction capability as palette correction property, with 257 correction coefficients and a max/min value b. csc correction capability as CTM correction property, with 3x3 transformation matrix values and max/min values
5. Now when userspace comes up, it queries the platform's color capabilities by doing a get_property() on color_capabilities DRM property
6. Reading the blob, the userspace understands the color capabilities of the platform.
For example, userspace will understand it can support:
a. palette_correction with 257 coefficients
b. CSC correction with 3x3 = 9 values
7. To set color correction values, userspace:
a. creates a blob using the create_blob_ioctl in standard palette_correction structure format, with the correction values b. calls the set_property_ioctl with the blob_id as value for the property
8. Driver refers to the blob, gets the correction values and applies the correction in HW.
9. To get currently applied color correction values, userspace:
a. calls a get_property_ioctl on that color property
b. gets the blob_id for the currently applied correction from DRM infrastructure
c. gets the blob using get_blob_ioctl and hence the currently applied values

That's all! :)

About the patch series:
=======================
The patch series first adds the color management support in DRM layer. Then it adds the color management framework in I915 layer. After that, it implements platform specific core color correction functios.

Intel color manager registers color correction with DRM color manager in this way:
- CSC transformation is registered as CTM DRM property
- Gamma correction is registered as palette_after_ctm DRM property
- Degamma correction is registered as palette_before_ctm DRM property

Our thanks to all the reviewers who have given valuable comments in terms of design and implementation to our previous sets of patches. Special mention of thanks should go to Matt Roper for all his inputs/suggestions in implementation of this module, using DRM atomic CRTC commit path.

V2: Worked on review comments from Matt, Jim, Thierry, Rob.
V3: Worked on review comments from Matt, Jim, Rob:
- Jim, Rob:
========
Re-arranged the whole patch series in the sequence of features, currently:
First 5 patches add color management support in DRM layer
Next 7 patches add Intel color management framework in I915 driver
Next 5 patches add color correction for CHV (gamma, degamma and CSC)
Next 2 patches enable color management, by attaching the properties to CRTC(Matt) Next 4 patches add color correction for BDW (gamma, degamma)
- Matt:
=====
Patch 3: Added refernce/unreference for blob
Patch 7: return -EINVAL and added debug message
Patch 8: check for valid blob, from create blob
moved call to intel_crtc_attach_color_prop in the end of full implementation (CHV)
Patch 9: DRM_ERROR->DRM_DEBUG for NULL blob case
Patch 13: Added static for internal functions
Patch 20-24: renamed gen9_* functions to bdw_*
Added new variables in device_info structure num_samples_after_ctm and num_samples_before_ctm Added new function in patch 8 to load capabilities based on device_info across all platforms

Shashank Sharma (23):
drm: Create Color Management DRM properties
drm: Add structure for querying palette color capabilities
drm: Add color correction blobs in CRTC state
drm: Add drm structures for palette color property
drm: Add structure to set/get a CTM color property drm/i915: Add atomic set property interface for CRTC drm/i915: Add atomic get property interface for CRTC drm/i915: Create color management files drm/i915: Register pipe color capabilities drm/i915: Add gamma correction handlers drm/i915: Add pipe deGamma correction handlers drm/i915: Add pipe CSC correction handlers drm/i915: CHV: Load gamma color correction values drm/i915: CHV: Pipe level Gamma correction drm/i915: CHV: Load degamma color correction values drm/i915: CHV: Pipe level degamma correction drm/i915: CHV: Pipe level CSC correction drm/i915: Commit color changes to CRTC
drm/i915: Attach color properties to CRTC drm/i915: BDW: Load gamma correction values drm/i915: BDW: Pipe level Gamma correction drm/i915: BDW: Load degamma correction values drm/i915: BDW: Pipe level degamma correction

 drivers/gpu/drm/drm_atomic_helper.c        |  12 +
 drivers/gpu/drm/drm_crtc.c                 |  26 +
 drivers/gpu/drm/i915/Makefile              |   3 +-
 drivers/gpu/drm/i915/i915_drv.c            |  17 +
 drivers/gpu/drm/i915/i915_drv.h            |   2 +
 drivers/gpu/drm/i915/i915_reg.h            |  41 +-
 drivers/gpu/drm/i915/intel_atomic.c        |  56 ++
 drivers/gpu/drm/i915/intel_color_manager.c | 852 +++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_color_manager.h |  99 ++++
 drivers/gpu/drm/i915/intel_display.c       |   6 +
 drivers/gpu/drm/i915/intel_drv.h           |  22 +
 include/drm/drm_crtc.h                     |  11 +
 include/uapi/drm/drm.h                     |  50 ++
 13 files changed, 1195 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_color_manager.c
 create mode 100644 drivers/gpu/drm/i915/intel_color_manager.h
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 1/23 drm: Create Color Management DRM properties

From: Kausal Malladi <[email protected]>

Color Management is an extension to Kernel display framework. It allows abstraction of hardware color correction and enhancement capabilities by virtue of DRM properties.

This patch initializes color management framework by :
1. Introducing new pointers in DRM mode_config structure to carry CTM and Palette color correction properties.
2. Creating these DRM properties in DRM standard properties creation sequence.

---
 drivers/gpu/drm/drm_crtc.c | 26 ++++++++++++++++++++++++++
 include/drm/drm_crtc.h     |  6 ++++++
 2 files changed, 32 insertions(+)
drivers/gpu/drm/drm_crtc.c +26 -0
index 9b9c4b4..d809c67 100644
@@ -1472,6 +1472,32 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
 		return -ENOMEM;
 	dev->mode_config.prop_mode_id = prop;
 
+	/* Color Management properties */
+	prop = drm_property_create(dev,
+			DRM_MODE_PROP_BLOB | DRM_MODE_PROP_IMMUTABLE,
+			"CRTC_PALETTE_CAPABILITIES", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.cm_crtc_palette_capabilities_property = prop;
+
+	prop = drm_property_create(dev,
+			DRM_MODE_PROP_BLOB, "PALETTE_AFTER_CTM", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.cm_palette_after_ctm_property = prop;
+
+	prop = drm_property_create(dev,
+			DRM_MODE_PROP_BLOB, "PALETTE_BEFORE_CTM", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.cm_palette_before_ctm_property = prop;
+
+	prop = drm_property_create(dev,
+			DRM_MODE_PROP_BLOB, "CTM", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.cm_ctm_property = prop;
+
 	return 0;
 }
 
include/drm/drm_crtc.h +6 -0
index c0366e9..c35531e 100644
@@ -1153,6 +1153,12 @@ struct drm_mode_config {
 	struct drm_property *suggested_x_property;
 	struct drm_property *suggested_y_property;
 
+	/* Color Management Properties */
+	struct drm_property *cm_crtc_palette_capabilities_property;
+	struct drm_property *cm_palette_before_ctm_property;
+	struct drm_property *cm_palette_after_ctm_property;
+	struct drm_property *cm_ctm_property;
+
 	/* dumb ioctl parameters */
 	uint32_t preferred_depth, prefer_shadow;
 
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Re: [PATCH 01/23] drm: Create Color Management DRM properties

Quoted 6 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

Color Management is an extension to Kernel display framework. It allows abstraction of hardware color correction and enhancement capabilities by virtue of DRM properties.

Quoted 8 lines

This patch initializes color management framework by :
1. Introducing new pointers in DRM mode_config structure to carry CTM and Palette color correction properties.
2. Creating these DRM properties in DRM standard properties creation sequence.

We should probably update the property section of Documentation/DocBook/drm.tmpl with this patch as well to include these new properties in the table (that docbook ultimately generates documentation that looks like
https://kernel.org/doc/htmldocs/drm/drm-kms-properties.html ).

One minor note: people not involved in color management probably won't immediately figure out what "CTM" stands for, so you might want to just add a comment somewhere that spells out the full "color transformation matrix" term.

Matt

Quoted 62 lines
---
 drivers/gpu/drm/drm_crtc.c | 26 ++++++++++++++++++++++++++
 include/drm/drm_crtc.h     |  6 ++++++
 2 files changed, 32 insertions(+)
drivers/gpu/drm/drm_crtc.c +26 -0
index 9b9c4b4..d809c67 100644
@@ -1472,6 +1472,32 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
 		return -ENOMEM;
 	dev->mode_config.prop_mode_id = prop;
 
+	/* Color Management properties */
+	prop = drm_property_create(dev,
+			DRM_MODE_PROP_BLOB | DRM_MODE_PROP_IMMUTABLE,
+			"CRTC_PALETTE_CAPABILITIES", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.cm_crtc_palette_capabilities_property = prop;
+
+	prop = drm_property_create(dev,
+			DRM_MODE_PROP_BLOB, "PALETTE_AFTER_CTM", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.cm_palette_after_ctm_property = prop;
+
+	prop = drm_property_create(dev,
+			DRM_MODE_PROP_BLOB, "PALETTE_BEFORE_CTM", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.cm_palette_before_ctm_property = prop;
+
+	prop = drm_property_create(dev,
+			DRM_MODE_PROP_BLOB, "CTM", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.cm_ctm_property = prop;
+
 	return 0;
 }
 
include/drm/drm_crtc.h +6 -0
index c0366e9..c35531e 100644
@@ -1153,6 +1153,12 @@ struct drm_mode_config {
 	struct drm_property *suggested_x_property;
 	struct drm_property *suggested_y_property;
 
+	/* Color Management Properties */
+	struct drm_property *cm_crtc_palette_capabilities_property;
+	struct drm_property *cm_palette_before_ctm_property;
+	struct drm_property *cm_palette_after_ctm_property;
+	struct drm_property *cm_ctm_property;
+
 	/* dumb ioctl parameters */
 	uint32_t preferred_depth, prefer_shadow;
 
Signature · 1 line
1.9.1
Signature · 9 lines
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

Re: [PATCH 01/23] drm: Create Color Management DRM properties

Sure Matt,
We are planning to add documentation for color properties, as suggested by you and Daniel.

Regards
Shashank
-----Original Message-----
From: Roper, Matthew D
Sent: Wednesday, September 16, 2015 11:21 PM
To: Sharma, Shashank
Cc: Bish, Jim; Bradford, Robert; Smith, Gary K; [email protected]; [email protected]; Vetter, Daniel; Matheson, Annie J; Mukherjee, Indranil; Palleti, Avinash Reddy; [email protected]
Subject: Re: [PATCH 01/23] drm: Create Color Management DRM properties

Quoted 6 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

Color Management is an extension to Kernel display framework. It allows abstraction of hardware color correction and enhancement capabilities by virtue of DRM properties.

Quoted 8 lines

This patch initializes color management framework by :
1. Introducing new pointers in DRM mode_config structure to carry CTM and Palette color correction properties.
2. Creating these DRM properties in DRM standard properties creation sequence.

We should probably update the property section of Documentation/DocBook/drm.tmpl with this patch as well to include these new properties in the table (that docbook ultimately generates documentation that looks like https://kernel.org/doc/htmldocs/drm/drm-kms-properties.html ).

One minor note: people not involved in color management probably won't immediately figure out what "CTM" stands for, so you might want to just add a comment somewhere that spells out the full "color transformation matrix" term.

Matt

Quoted 62 lines
---
 drivers/gpu/drm/drm_crtc.c | 26 ++++++++++++++++++++++++++
 include/drm/drm_crtc.h     |  6 ++++++
 2 files changed, 32 insertions(+)
drivers/gpu/drm/drm_crtc.c +26 -0
index 9b9c4b4..d809c67 100644
@@ -1472,6 +1472,32 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
 		return -ENOMEM;
 	dev->mode_config.prop_mode_id = prop;
 
+	/* Color Management properties */
+	prop = drm_property_create(dev,
+			DRM_MODE_PROP_BLOB | DRM_MODE_PROP_IMMUTABLE,
+			"CRTC_PALETTE_CAPABILITIES", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.cm_crtc_palette_capabilities_property = prop;
+
+	prop = drm_property_create(dev,
+			DRM_MODE_PROP_BLOB, "PALETTE_AFTER_CTM", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.cm_palette_after_ctm_property = prop;
+
+	prop = drm_property_create(dev,
+			DRM_MODE_PROP_BLOB, "PALETTE_BEFORE_CTM", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.cm_palette_before_ctm_property = prop;
+
+	prop = drm_property_create(dev,
+			DRM_MODE_PROP_BLOB, "CTM", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.cm_ctm_property = prop;
+
 	return 0;
 }
 
include/drm/drm_crtc.h index renamed from include/drm/drm_crtc.h +0 -0

c0366e9..c35531e 100644

include/drm/drm_crtc.h +6 -1
@@ -1153,6 +1153,12 @@ struct drm_mode_config {
 	struct drm_property *suggested_x_property;
 	struct drm_property *suggested_y_property;
 
+	/* Color Management Properties */
+	struct drm_property *cm_crtc_palette_capabilities_property;
+	struct drm_property *cm_palette_before_ctm_property;
+	struct drm_property *cm_palette_after_ctm_property;
+	struct drm_property *cm_ctm_property;
+
 	/* dumb ioctl parameters */
 	uint32_t preferred_depth, prefer_shadow;
 
--

1.9.1

Signature · 9 lines
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

PATCH 2/23 drm: Add structure for querying palette color capabilities

In reply to Shashank Sharma

From: Kausal Malladi <[email protected]>

The DRM color management framework is targeting various hardware platforms and drivers. Different platforms can have different color correction and enhancement capabilities.

A commom user space application can query these capabilities using the DRM property interface. Each driver can fill this property with its platform's palette color capabilities.

This patch adds new structure in DRM layer for querying palette color capabilities. This structure will be used by all user space agents to configure appropriate color configurations.

---
 include/uapi/drm/drm.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
include/uapi/drm/drm.h +11 -0
index 3801584..e3c642f 100644
@@ -829,6 +829,17 @@ struct drm_event_vblank {
 	__u32 reserved;
 };
 
+struct drm_palette_caps {
+	/* Structure version. Should be 1 currently */
+	__u32 version;
+	/* For padding and future use */
+	__u32 reserved;
+	/* This may be 0 if not supported. e.g. plane palette or VLV pipe */
+	__u32 num_samples_before_ctm;
+	/* This will be non-zero for pipe. May be zero for planes on some HW */
+	__u32 num_samples_after_ctm;
+};
+
 /* typedef area */
 #ifndef __KERNEL__
 typedef struct drm_clip_rect drm_clip_rect_t;
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

Re: [PATCH 02/23] drm: Add structure for querying palette color capabilities

Quoted 10 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

The DRM color management framework is targeting various hardware platforms and drivers. Different platforms can have different color correction and enhancement capabilities.

A commom user space application can query these capabilities using the DRM property interface. Each driver can fill this property with its platform's palette color capabilities.

Quoted 6 lines

This patch adds new structure in DRM layer for querying palette color capabilities. This structure will be used by all user space agents to configure appropriate color configurations.

I think you provided an explanation on a previous code review cycle, but I forget the details now...what's the benefit to using a blob for caps rather than having these be individual properties? Individual properties seems more natural to me, but I think you had a justification for blobbing them together; that reasoning would be good to include in the commit message.

Matt

Quoted 29 lines
---
 include/uapi/drm/drm.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
include/uapi/drm/drm.h +11 -0
index 3801584..e3c642f 100644
@@ -829,6 +829,17 @@ struct drm_event_vblank {
 	__u32 reserved;
 };
 
+struct drm_palette_caps {
+	/* Structure version. Should be 1 currently */
+	__u32 version;
+	/* For padding and future use */
+	__u32 reserved;
+	/* This may be 0 if not supported. e.g. plane palette or VLV pipe */
+	__u32 num_samples_before_ctm;
+	/* This will be non-zero for pipe. May be zero for planes on some HW */
+	__u32 num_samples_after_ctm;
+};
+
 /* typedef area */
 #ifndef __KERNEL__
 typedef struct drm_clip_rect drm_clip_rect_t;
Signature · 1 line
1.9.1
Signature · 9 lines
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

Re: [PATCH 02/23] drm: Add structure for querying palette color capabilities

Quoted 18 lines · Matt Roper
Quoted 10 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

The DRM color management framework is targeting various hardware platforms and drivers. Different platforms can have different color correction and enhancement capabilities.

A commom user space application can query these capabilities using the DRM property interface. Each driver can fill this property with its platform's palette color capabilities.

Quoted 6 lines

This patch adds new structure in DRM layer for querying palette color capabilities. This structure will be used by all user space agents to configure appropriate color configurations.

Quoted 6 lines

I think you provided an explanation on a previous code review cycle, but I forget the details now...what's the benefit to using a blob for caps rather than having these be individual properties? Individual properties seems more natural to me, but I think you had a justification for blobbing them together; that reasoning would be good to include in the commit message.

Yeah I'm leaning slightly towards individual props too, that would give us a bit more freedom with placing them (e.g. if someone comes up with funky hw where before_ctm and ctm are per-plane and after_ctm is on the crtc, with only some planes support the before_ctm gamma table).

Also if you do per-prop properties instead of the blob you can drop the version/reserved fields, since properties are inheritedly designed to be extendible. So no need to revision them again (it only leads to more code that might break).
-Daniel

Quoted 44 lines

Matt

Quoted 29 lines
---
 include/uapi/drm/drm.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
include/uapi/drm/drm.h +11 -0
index 3801584..e3c642f 100644
@@ -829,6 +829,17 @@ struct drm_event_vblank {
 	__u32 reserved;
 };
 
+struct drm_palette_caps {
+	/* Structure version. Should be 1 currently */
+	__u32 version;
+	/* For padding and future use */
+	__u32 reserved;
+	/* This may be 0 if not supported. e.g. plane palette or VLV pipe */
+	__u32 num_samples_before_ctm;
+	/* This will be non-zero for pipe. May be zero for planes on some HW */
+	__u32 num_samples_after_ctm;
+};
+
 /* typedef area */
 #ifndef __KERNEL__
 typedef struct drm_clip_rect drm_clip_rect_t;
Signature · 1 line
1.9.1
Signature · 9 lines
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

Re: [PATCH 02/23] drm: Add structure for querying palette color capabilities

Hi Matt, Daniel
Addressing the review comments from both of you here.

Regards
Shashank

Quoted 26 lines · Daniel Vetter
Quoted 18 lines · Matt Roper
Quoted 10 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

The DRM color management framework is targeting various hardware platforms and drivers. Different platforms can have different color correction and enhancement capabilities.

A commom user space application can query these capabilities using the DRM property interface. Each driver can fill this property with its platform's palette color capabilities.

Quoted 6 lines

This patch adds new structure in DRM layer for querying palette color capabilities. This structure will be used by all user space agents to configure appropriate color configurations.

Quoted 6 lines

I think you provided an explanation on a previous code review cycle, but I forget the details now...what's the benefit to using a blob for caps rather than having these be individual properties? Individual properties seems more natural to me, but I think you had a justification for blobbing them together; that reasoning would be good to include in the commit message.

Quoted 4 lines

Yeah I'm leaning slightly towards individual props too, that would give us a bit more freedom with placing them (e.g. if someone comes up with funky hw where before_ctm and ctm are per-plane and after_ctm is on the crtc, with only some planes support the before_ctm gamma table).

This was the part where we spent most of the time during the design review, and the reason we came up for this was:
- This is a read only property, which userspace would like to read only once, and cache the information. It was also Gary's opinion to keep this as single blob for all.
- Making individual property needs more information to be provided to
user space.
- This is a blob only for pipe level capabilities, the plane level blob will be separate from this.
- We can handle this HW also, by loading proper plane and pipe level capability blob. This is more convenient to have all the capabilities together at the same place, than keep on querying the same.

Quoted 7 lines

Also if you do per-prop properties instead of the blob you can drop the version/reserved fields, since properties are inheritedly designed to be extendible. So no need to revision them again (it only leads to more code that might break).
-Daniel

We are anyways planning to drop the version, as per Ville's comment.
- Shashank

Quoted 36 lines
Quoted 36 lines

Matt

Quoted 27 lines
---
  include/uapi/drm/drm.h | 11 +++++++++++
  1 file changed, 11 insertions(+)
include/uapi/drm/drm.h +11 -1
index 3801584..e3c642f 100644
@@ -829,6 +829,17 @@ struct drm_event_vblank {
  	__u32 reserved;
  };
 
+struct drm_palette_caps {
+	/* Structure version. Should be 1 currently */
+	__u32 version;
+	/* For padding and future use */
+	__u32 reserved;
+	/* This may be 0 if not supported. e.g. plane palette or VLV pipe */
+	__u32 num_samples_before_ctm;
+	/* This will be non-zero for pipe. May be zero for planes on some HW */
+	__u32 num_samples_after_ctm;
+};
+
  /* typedef area */
  #ifndef __KERNEL__
  typedef struct drm_clip_rect drm_clip_rect_t;
--
Quoted 2 lines

1.9.1

--
Matt Roper

Quoted 9 lines
Quoted 8 lines

Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

Re: [PATCH 02/23] drm: Add structure for querying palette color capabilities

Given that its only one word of info per LUT, I'm OK with it being two separate properties.
I believe it was much more complex previously with a lot more info per LUT, which is probably why I preferred a blob.

Thanks
Gary

-----Original Message-----
From: Sharma, Shashank
Sent: Wednesday, September 23, 2015 9:10 AM
To: Daniel Vetter; Roper, Matthew D
Cc: Matheson, Annie J; Bradford, Robert; Palleti, Avinash Reddy; [email protected]; [email protected]; Mukherjee, Indranil; Bish, Jim; Smith, Gary K; [email protected]; Vetter, Daniel
Subject: Re: [PATCH 02/23] drm: Add structure for querying palette color capabilities

Hi Matt, Daniel
Addressing the review comments from both of you here.

Regards
Shashank

Quoted 26 lines · Daniel Vetter
Quoted 18 lines · Matt Roper
Quoted 10 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

The DRM color management framework is targeting various hardware platforms and drivers. Different platforms can have different color correction and enhancement capabilities.

A commom user space application can query these capabilities using the DRM property interface. Each driver can fill this property with its platform's palette color capabilities.

Quoted 6 lines

This patch adds new structure in DRM layer for querying palette color capabilities. This structure will be used by all user space agents to configure appropriate color configurations.

Quoted 6 lines

I think you provided an explanation on a previous code review cycle, but I forget the details now...what's the benefit to using a blob for caps rather than having these be individual properties? Individual properties seems more natural to me, but I think you had a justification for blobbing them together; that reasoning would be good to include in the commit message.

Quoted 4 lines

Yeah I'm leaning slightly towards individual props too, that would give us a bit more freedom with placing them (e.g. if someone comes up with funky hw where before_ctm and ctm are per-plane and after_ctm is on the crtc, with only some planes support the before_ctm gamma table).

This was the part where we spent most of the time during the design review, and the reason we came up for this was:
- This is a read only property, which userspace would like to read only once, and cache the information. It was also Gary's opinion to keep this as single blob for all.
- Making individual property needs more information to be provided to user space.
- This is a blob only for pipe level capabilities, the plane level blob will be separate from this.
- We can handle this HW also, by loading proper plane and pipe level capability blob. This is more convenient to have all the capabilities together at the same place, than keep on querying the same.

Quoted 7 lines

Also if you do per-prop properties instead of the blob you can drop the version/reserved fields, since properties are inheritedly designed to be extendible. So no need to revision them again (it only leads to more code that might break).
-Daniel

We are anyways planning to drop the version, as per Ville's comment.
- Shashank

Quoted 36 lines
Quoted 36 lines

Matt

Quoted 27 lines
---
  include/uapi/drm/drm.h | 11 +++++++++++
  1 file changed, 11 insertions(+)
include/uapi/drm/drm.h index renamed from include/uapi/drm/drm.h +0 -0

3801584..e3c642f 100644

include/uapi/drm/drm.h +11 -1
@@ -829,6 +829,17 @@ struct drm_event_vblank {
  	__u32 reserved;
  };
 
+struct drm_palette_caps {
+	/* Structure version. Should be 1 currently */
+	__u32 version;
+	/* For padding and future use */
+	__u32 reserved;
+	/* This may be 0 if not supported. e.g. plane palette or VLV pipe */
+	__u32 num_samples_before_ctm;
+	/* This will be non-zero for pipe. May be zero for planes on some HW */
+	__u32 num_samples_after_ctm;
+};
+
  /* typedef area */
  #ifndef __KERNEL__
  typedef struct drm_clip_rect drm_clip_rect_t;
--
Quoted 2 lines

1.9.1

--
Matt Roper

Quoted 9 lines
Quoted 8 lines

Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#9 lore raw

Re: [PATCH 02/23] drm: Add structure for querying palette color capabilities

This would be an interface/design change, to change from one blob of correction property, to split into multiple query properties for palette_before_blob and palette_after_blob. Please let me know if this is really required ?

Regards
Shashank
-----Original Message-----
From: Smith, Gary K
Sent: Wednesday, September 23, 2015 3:17 PM
To: Sharma, Shashank; Daniel Vetter; Roper, Matthew D
Cc: Matheson, Annie J; Bradford, Robert; Palleti, Avinash Reddy; [email protected]; [email protected]; Mukherjee, Indranil; Bish, Jim; [email protected]; Vetter, Daniel
Subject: RE: [PATCH 02/23] drm: Add structure for querying palette color capabilities

Given that its only one word of info per LUT, I'm OK with it being two separate properties.
I believe it was much more complex previously with a lot more info per LUT, which is probably why I preferred a blob.

Thanks
Gary

-----Original Message-----
From: Sharma, Shashank
Sent: Wednesday, September 23, 2015 9:10 AM
To: Daniel Vetter; Roper, Matthew D
Cc: Matheson, Annie J; Bradford, Robert; Palleti, Avinash Reddy; [email protected]; [email protected]; Mukherjee, Indranil; Bish, Jim; Smith, Gary K; [email protected]; Vetter, Daniel
Subject: Re: [PATCH 02/23] drm: Add structure for querying palette color capabilities

Hi Matt, Daniel
Addressing the review comments from both of you here.

Regards
Shashank

Quoted 26 lines · Daniel Vetter
Quoted 18 lines · Matt Roper
Quoted 10 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

The DRM color management framework is targeting various hardware platforms and drivers. Different platforms can have different color correction and enhancement capabilities.

A commom user space application can query these capabilities using the DRM property interface. Each driver can fill this property with its platform's palette color capabilities.

Quoted 6 lines

This patch adds new structure in DRM layer for querying palette color capabilities. This structure will be used by all user space agents to configure appropriate color configurations.

Quoted 6 lines

I think you provided an explanation on a previous code review cycle, but I forget the details now...what's the benefit to using a blob for caps rather than having these be individual properties? Individual properties seems more natural to me, but I think you had a justification for blobbing them together; that reasoning would be good to include in the commit message.

Quoted 4 lines

Yeah I'm leaning slightly towards individual props too, that would give us a bit more freedom with placing them (e.g. if someone comes up with funky hw where before_ctm and ctm are per-plane and after_ctm is on the crtc, with only some planes support the before_ctm gamma table).

This was the part where we spent most of the time during the design review, and the reason we came up for this was:
- This is a read only property, which userspace would like to read only once, and cache the information. It was also Gary's opinion to keep this as single blob for all.
- Making individual property needs more information to be provided to user space.
- This is a blob only for pipe level capabilities, the plane level blob will be separate from this.
- We can handle this HW also, by loading proper plane and pipe level capability blob. This is more convenient to have all the capabilities together at the same place, than keep on querying the same.

Quoted 7 lines

Also if you do per-prop properties instead of the blob you can drop the version/reserved fields, since properties are inheritedly designed to be extendible. So no need to revision them again (it only leads to more code that might break).
-Daniel

We are anyways planning to drop the version, as per Ville's comment.
- Shashank

Quoted 36 lines
Quoted 36 lines

Matt

Quoted 27 lines
---
  include/uapi/drm/drm.h | 11 +++++++++++
  1 file changed, 11 insertions(+)
include/uapi/drm/drm.h index renamed from include/uapi/drm/drm.h +0 -0

3801584..e3c642f 100644

include/uapi/drm/drm.h +11 -1
@@ -829,6 +829,17 @@ struct drm_event_vblank {
  	__u32 reserved;
  };
 
+struct drm_palette_caps {
+	/* Structure version. Should be 1 currently */
+	__u32 version;
+	/* For padding and future use */
+	__u32 reserved;
+	/* This may be 0 if not supported. e.g. plane palette or VLV pipe */
+	__u32 num_samples_before_ctm;
+	/* This will be non-zero for pipe. May be zero for planes on some HW */
+	__u32 num_samples_after_ctm;
+};
+
  /* typedef area */
  #ifndef __KERNEL__
  typedef struct drm_clip_rect drm_clip_rect_t;
--
Quoted 2 lines

1.9.1

--
Matt Roper

Quoted 9 lines
Quoted 8 lines

Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#10 lore raw

Re: [PATCH 02/23] drm: Add structure for querying palette color capabilities

Quoted 4 lines · Shashank

This would be an interface/design change, to change from one blob of correction property, to split into multiple query properties for palette_before_blob and palette_after_blob. Please let me know if this is really required ?

Yes I think splitting this up into one property per value is the right approach. That's also why we split the before/after gamma tables and the ctm each into it's own property.

And I don't think this is a design change of the interface - we still exchange the exact same values with the exact semantics between kernel and userspace, there's just a small difference in the actual transport protocol. Those kinds of minor changes happen all the time when upstreaming features. And that's the reason why we absolutely _must_ have a close collaboration between the kernel and userspace side. Which unfortunately on this feature here took a few months to get going, but hopefully with shared git trees and talking on irc now that should be easier.
-Daniel

Quoted 119 lines

Regards
Shashank
-----Original Message-----
From: Smith, Gary K
Sent: Wednesday, September 23, 2015 3:17 PM
To: Sharma, Shashank; Daniel Vetter; Roper, Matthew D
Cc: Matheson, Annie J; Bradford, Robert; Palleti, Avinash Reddy; [email protected]; [email protected]; Mukherjee, Indranil; Bish, Jim; [email protected]; Vetter, Daniel
Subject: RE: [PATCH 02/23] drm: Add structure for querying palette color capabilities

Given that its only one word of info per LUT, I'm OK with it being two separate properties.
I believe it was much more complex previously with a lot more info per LUT, which is probably why I preferred a blob.

Thanks
Gary

-----Original Message-----
From: Sharma, Shashank
Sent: Wednesday, September 23, 2015 9:10 AM
To: Daniel Vetter; Roper, Matthew D
Cc: Matheson, Annie J; Bradford, Robert; Palleti, Avinash Reddy; [email protected]; [email protected]; Mukherjee, Indranil; Bish, Jim; Smith, Gary K; [email protected]; Vetter, Daniel
Subject: Re: [PATCH 02/23] drm: Add structure for querying palette color capabilities

Hi Matt, Daniel
Addressing the review comments from both of you here.

Regards
Shashank

Quoted 26 lines · Daniel Vetter
Quoted 18 lines · Matt Roper
Quoted 10 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

The DRM color management framework is targeting various hardware platforms and drivers. Different platforms can have different color correction and enhancement capabilities.

A commom user space application can query these capabilities using the DRM property interface. Each driver can fill this property with its platform's palette color capabilities.

Quoted 6 lines

This patch adds new structure in DRM layer for querying palette color capabilities. This structure will be used by all user space agents to configure appropriate color configurations.

Quoted 6 lines

I think you provided an explanation on a previous code review cycle, but I forget the details now...what's the benefit to using a blob for caps rather than having these be individual properties? Individual properties seems more natural to me, but I think you had a justification for blobbing them together; that reasoning would be good to include in the commit message.

Quoted 4 lines

Yeah I'm leaning slightly towards individual props too, that would give us a bit more freedom with placing them (e.g. if someone comes up with funky hw where before_ctm and ctm are per-plane and after_ctm is on the crtc, with only some planes support the before_ctm gamma table).

This was the part where we spent most of the time during the design review, and the reason we came up for this was:
- This is a read only property, which userspace would like to read only once, and cache the information. It was also Gary's opinion to keep this as single blob for all.
- Making individual property needs more information to be provided to user space.
- This is a blob only for pipe level capabilities, the plane level blob will be separate from this.
- We can handle this HW also, by loading proper plane and pipe level capability blob. This is more convenient to have all the capabilities together at the same place, than keep on querying the same.

Quoted 7 lines

Also if you do per-prop properties instead of the blob you can drop the version/reserved fields, since properties are inheritedly designed to be extendible. So no need to revision them again (it only leads to more code that might break).
-Daniel

We are anyways planning to drop the version, as per Ville's comment.
- Shashank

Quoted 45 lines
Quoted 44 lines

Matt

Quoted 27 lines
---
  include/uapi/drm/drm.h | 11 +++++++++++
  1 file changed, 11 insertions(+)
include/uapi/drm/drm.h index renamed from include/uapi/drm/drm.h +0 -0

3801584..e3c642f 100644

include/uapi/drm/drm.h +11 -1
@@ -829,6 +829,17 @@ struct drm_event_vblank {
  	__u32 reserved;
  };
 
+struct drm_palette_caps {
+	/* Structure version. Should be 1 currently */
+	__u32 version;
+	/* For padding and future use */
+	__u32 reserved;
+	/* This may be 0 if not supported. e.g. plane palette or VLV pipe */
+	__u32 num_samples_before_ctm;
+	/* This will be non-zero for pipe. May be zero for planes on some HW */
+	__u32 num_samples_after_ctm;
+};
+
  /* typedef area */
  #ifndef __KERNEL__
  typedef struct drm_clip_rect drm_clip_rect_t;
--
Quoted 2 lines

1.9.1

--
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw

PATCH 3/23 drm: Add color correction blobs in CRTC state

In reply to Shashank Sharma

From: Kausal Malladi <[email protected]>

This patch adds new variables in CRTC state, to hold respective color correction blobs. These blobs will be required during the atomic commit for writing the color correction values in correction registers.

---
 drivers/gpu/drm/drm_atomic_helper.c | 12 ++++++++++++
 include/drm/drm_crtc.h              |  5 +++++
 2 files changed, 17 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +12 -0
index 94d6c8e..1fe91ee 100644
@@ -2168,6 +2168,12 @@ void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc,
 
 	if (state->mode_blob)
 		drm_property_reference_blob(state->mode_blob);
+	if (state->ctm_blob)
+		drm_property_reference_blob(state->ctm_blob);
+	if (state->palette_after_ctm_blob)
+		drm_property_reference_blob(state->palette_after_ctm_blob);
+	if (state->palette_before_ctm_blob)
+		drm_property_reference_blob(state->palette_before_ctm_blob);
 	state->mode_changed = false;
 	state->active_changed = false;
 	state->planes_changed = false;
@@ -2213,6 +2219,12 @@ void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc *crtc,
 {
 	if (state->mode_blob)
 		drm_property_unreference_blob(state->mode_blob);
+	if (state->ctm_blob)
+		drm_property_unreference_blob(state->ctm_blob);
+	if (state->palette_after_ctm_blob)
+		drm_property_unreference_blob(state->palette_after_ctm_blob);
+	if (state->palette_before_ctm_blob)
+		drm_property_unreference_blob(state->palette_before_ctm_blob);
 }
 EXPORT_SYMBOL(__drm_atomic_helper_crtc_destroy_state);
 
include/drm/drm_crtc.h +5 -0
index c35531e..fcbe682 100644
@@ -302,6 +302,11 @@ struct drm_crtc_state {
 	/* blob property to expose current mode to atomic userspace */
 	struct drm_property_blob *mode_blob;
 
+	/* blob properties to hold the color properties' blobs */
+	struct drm_property_blob *palette_before_ctm_blob;
+	struct drm_property_blob *palette_after_ctm_blob;
+	struct drm_property_blob *ctm_blob;
+
 	struct drm_pending_vblank_event *event;
 
 	struct drm_atomic_state *state;
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#12 lore raw

PATCH 4/23 drm: Add drm structures for palette color property

In reply to Shashank Sharma

From: Kausal Malladi <[email protected]>

This patch adds new structures in DRM layer for Palette color correction.These structures will be used by user space agents to configure appropriate number of samples and Palette LUT for a platform.

---
 include/uapi/drm/drm.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
include/uapi/drm/drm.h +27 -0
index e3c642f..f72b916 100644
@@ -840,6 +840,33 @@ struct drm_palette_caps {
 	__u32 num_samples_after_ctm;
 };
 
+struct drm_r32g32b32 {
+	/*
+	 * Data is in U8.24 fixed point format.
+	 * All platforms support values within [0, 1.0] range,
+	 * for Red, Green and Blue colors.
+	 */
+	__u32 r32;
+	__u32 g32;
+	__u32 b32;
+};
+
+struct drm_palette {
+	/* Structure version. Should be 1 currently */
+	__u32 version;
+	/*
+	 * This has to be a supported value during get call.
+	 * Feature will be disabled if this is 0 while set
+	 */
+	__u32 num_samples;
+	/*
+	 * Starting of palette LUT in R32G32B32 format.
+	 * Each of RGB value is in U8.24 fixed point format.
+	 * Actual number of samples will depend upon num_samples
+	 */
+	struct drm_r32g32b32 lut[0];
+};
+
 /* typedef area */
 #ifndef __KERNEL__
 typedef struct drm_clip_rect drm_clip_rect_t;
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw

Re: [PATCH 04/23] drm: Add drm structures for palette color property

Quoted 25 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

This patch adds new structures in DRM layer for Palette color correction.These structures will be used by user space agents to configure appropriate number of samples and Palette LUT for a platform.

---
 include/uapi/drm/drm.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
include/uapi/drm/drm.h +4 -0
index e3c642f..f72b916 100644
@@ -840,6 +840,33 @@ struct drm_palette_caps {
 	__u32 num_samples_after_ctm;
 };
 
+struct drm_r32g32b32 {
+	/*
+	 * Data is in U8.24 fixed point format.
+	 * All platforms support values within [0, 1.0] range,

include/uapi/drm/drm.h struct drm_palette_caps { · line 856

Quoted 10 lines
include/uapi/drm/drm.h +10 -0
+	 * for Red, Green and Blue colors.
+	 */
+	__u32 r32;
+	__u32 g32;
+	__u32 b32;
+};
+
+struct drm_palette {
+	/* Structure version. Should be 1 currently */
+	__u32 version;

I don't think we want to version the blobs. For one, we don't have a way for userspace to ask for a specific version, so the kernel wouldn't know which version it should return to each client.

If we ever need to come up with new version of a specific blob, I think we just have to define another property for it. Either that or we'd some kind of client cap stuff to negotiate the used version between the kernel and a specific client.

Well, I suppose we migth be able to borrow the "flags+extend at the end" trick we sometimes use for ioctl parameters to work for blobs too. But I have a feeling we don't want to go there.

So yeah, I think we should go with the "blob layout is fixed for each property" approach. Versioning then happens by introducing new versions of the same property if needed.

Quoted 23 lines
include/uapi/drm/drm.h +13 -0
+	/*
+	 * This has to be a supported value during get call.
+	 * Feature will be disabled if this is 0 while set
+	 */
+	__u32 num_samples;
+	/*
+	 * Starting of palette LUT in R32G32B32 format.
+	 * Each of RGB value is in U8.24 fixed point format.
+	 * Actual number of samples will depend upon num_samples
+	 */
+	struct drm_r32g32b32 lut[0];
+};
+
 /* typedef area */
 #ifndef __KERNEL__
 typedef struct drm_clip_rect drm_clip_rect_t;
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw

Re: [PATCH 04/23] drm: Add drm structures for palette color property

Regards
Shashank

Quoted 46 lines · Ville Syrjälä
Quoted 25 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

This patch adds new structures in DRM layer for Palette color correction.These structures will be used by user space agents to configure appropriate number of samples and Palette LUT for a platform.

---
  include/uapi/drm/drm.h | 27 +++++++++++++++++++++++++++
  1 file changed, 27 insertions(+)
include/uapi/drm/drm.h +4 -0
index e3c642f..f72b916 100644
@@ -840,6 +840,33 @@ struct drm_palette_caps {
  	__u32 num_samples_after_ctm;
  };
 
+struct drm_r32g32b32 {
+	/*
+	 * Data is in U8.24 fixed point format.
+	 * All platforms support values within [0, 1.0] range,

include/uapi/drm/drm.h struct drm_palette_caps { · line 856

Quoted 10 lines
include/uapi/drm/drm.h +10 -0
+	 * for Red, Green and Blue colors.
+	 */
+	__u32 r32;
+	__u32 g32;
+	__u32 b32;
+};
+
+struct drm_palette {
+	/* Structure version. Should be 1 currently */
+	__u32 version;

I don't think we want to version the blobs. For one, we don't have a way for userspace to ask for a specific version, so the kernel wouldn't know which version it should return to each client.

If we ever need to come up with new version of a specific blob, I think we just have to define another property for it. Either that or we'd some kind of client cap stuff to negotiate the used version between the kernel and a specific client.

Quoted 8 lines

Well, I suppose we migth be able to borrow the "flags+extend at the end" trick we sometimes use for ioctl parameters to work for blobs too. But I have a feeling we don't want to go there.

So yeah, I think we should go with the "blob layout is fixed for each property" approach. Versioning then happens by introducing new versions of the same property if needed.

Well, reason behind adding this version was, as this framework was a new development, we wanted to keep scope for further changes on request from other drivers/modules. But yes, I agree, its kind of overhead, so we can also remove it. Will do that in next patch set.

Quoted 19 lines
Quoted 19 lines
include/uapi/drm/drm.h +13 -1
+	/*
+	 * This has to be a supported value during get call.
+	 * Feature will be disabled if this is 0 while set
+	 */
+	__u32 num_samples;
+	/*
+	 * Starting of palette LUT in R32G32B32 format.
+	 * Each of RGB value is in U8.24 fixed point format.
+	 * Actual number of samples will depend upon num_samples
+	 */
+	struct drm_r32g32b32 lut[0];
+};
+
  /* typedef area */
  #ifndef __KERNEL__
  typedef struct drm_clip_rect drm_clip_rect_t;
--

1.9.1

Quoted 5 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#15 lore raw

Re: [PATCH 04/23] drm: Add drm structures for palette color property

In reply to Shashank Sharma
Quoted 20 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

This patch adds new structures in DRM layer for Palette color correction.These structures will be used by user space agents to configure appropriate number of samples and Palette LUT for a platform.

---
 include/uapi/drm/drm.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
include/uapi/drm/drm.h +0 -0
index e3c642f..f72b916 100644
@@ -840,6 +840,33 @@ struct drm_palette_caps {
 	__u32 num_samples_after_ctm;
 };

include/uapi/drm/drm.h struct drm_palette_caps { · line 851

Quoted 10 lines
include/uapi/drm/drm.h +9 -0
 
+struct drm_r32g32b32 {
+	/*
+	 * Data is in U8.24 fixed point format.
+	 * All platforms support values within [0, 1.0] range,
+	 * for Red, Green and Blue colors.
+	 */
+	__u32 r32;
+	__u32 g32;
+	__u32 b32;

It's not strictly required, but adding a __u32 reserved here to align the struct to 64 bits seems good imo. Slight overhead but meh about that.

include/uapi/drm/drm.h struct drm_palette_caps { · line 856

Quoted 5 lines
include/uapi/drm/drm.h +5 -0
+};
+
+struct drm_palette {
+	/* Structure version. Should be 1 currently */
+	__u32 version;

Definitely great practice to take compat into account and definitely needed for the first design using ioctls but I don't think we need this here. Properties are already extinsible themselves: We can just greate a "ctm-v2", "ctm-v3" if the layout changes, and since the actual ctm matrix is stored in the drm_crtc_state any compat code on the kernel will be shared.

Aside: For an ioctl the recommended way to handle backwards compat and extensions in drm is with a flags bitfield. That's more flexible than a linear version field, and extending the ioctl struct at the end is already handled by the drm core in a transparent fashion (it 0-fills either kernel or userspace side).

include/uapi/drm/drm.h struct drm_palette_caps { · line 861

Quoted 5 lines
include/uapi/drm/drm.h +5 -0
+	/*
+	 * This has to be a supported value during get call.
+	 * Feature will be disabled if this is 0 while set
+	 */
+	__u32 num_samples;

blob properties already have a size, storing it again in the blob is redundnant. Instead I think a small helper to get the number of samples for a given gamma table blob would be needed.

Cheers, Daniel

Quoted 18 lines
include/uapi/drm/drm.h +8 -0
+	/*
+	 * Starting of palette LUT in R32G32B32 format.
+	 * Each of RGB value is in U8.24 fixed point format.
+	 * Actual number of samples will depend upon num_samples
+	 */
+	struct drm_r32g32b32 lut[0];
+};
+
 /* typedef area */
 #ifndef __KERNEL__
 typedef struct drm_clip_rect drm_clip_rect_t;
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#16 lore raw

Re: [PATCH 04/23] drm: Add drm structures for palette color property

Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

This patch adds new structures in DRM layer for Palette color correction.These structures will be used by user space agents to configure appropriate number of samples and Palette LUT for a platform.

---
 include/uapi/drm/drm.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
include/uapi/drm/drm.h +0 -0
index e3c642f..f72b916 100644

[snip]

Quoted 1 line
Quoted 1 line

+struct drm_palette {

[snip]

Quoted 1 line

... extending the ioctl struct at the end ...

Is this really going to work, considering that we currently have a zero sized drm_r32g32b32 array at the end ?

Iirc someone mentioned that using a pointer to the data (over an array) has drawbacks, although for the sake of me I cannot think of any. Can anyone care to enlighten me, please ?

Thanks
Emil
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#17 lore raw

Re: [PATCH 04/23] drm: Add drm structures for palette color property

Quoted 20 lines · Emil Velikov
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

This patch adds new structures in DRM layer for Palette color correction.These structures will be used by user space agents to configure appropriate number of samples and Palette LUT for a platform.

---
 include/uapi/drm/drm.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
include/uapi/drm/drm.h +0 -0
index e3c642f..f72b916 100644

[snip]

Quoted 5 lines
Quoted 1 line
Quoted 1 line

+struct drm_palette {

[snip]

Quoted 1 line

... extending the ioctl struct at the end ...

Is this really going to work, considering that we currently have a zero sized drm_r32g32b32 array at the end ?

Well in this particular case it would be ugly. Sure, it can be done, but we couldn't actually define the struct for it using C. Would be a neat feature though. Someone should propose it for the next C standard :)

In any case, for blobs I think we shouldn't extend them like ioctls. In this case the blob is just an array of something, so the blob size can of course vary depending how many elements are required for the particual platform.

Quoted 3 lines

Iirc someone mentioned that using a pointer to the data (over an array) has drawbacks, although for the sake of me I cannot think of any. Can anyone care to enlighten me, please ?

I guess an extensible array at the end of the struct is simply a nice fit sometimes. Also makes it more obvious how much junk gets copied over I suppose.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#18 lore raw

Re: [PATCH 04/23] drm: Add drm structures for palette color property

Hi Ville,

Quoted 32 lines · Ville Syrjälä
Quoted 20 lines · Emil Velikov
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

This patch adds new structures in DRM layer for Palette color correction.These structures will be used by user space agents to configure appropriate number of samples and Palette LUT for a platform.

---
 include/uapi/drm/drm.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
include/uapi/drm/drm.h +0 -0
index e3c642f..f72b916 100644

[snip]

Quoted 5 lines
Quoted 1 line
Quoted 1 line

+struct drm_palette {

[snip]

Quoted 1 line

... extending the ioctl struct at the end ...

Is this really going to work, considering that we currently have a zero sized drm_r32g32b32 array at the end ?

Well in this particular case it would be ugly. Sure, it can be done, but we couldn't actually define the struct for it using C. Would be a neat feature though. Someone should propose it for the next C standard :)

Quoted 5 lines

In any case, for blobs I think we shouldn't extend them like ioctls. In this case the blob is just an array of something, so the blob size can of course vary depending how many elements are required for the particual platform.

Sure it makes sense on its own. I'm curious how likely it will be for people to get confused/carried away and miss that part. Just a food for thought.

Quoted 8 lines
Quoted 3 lines

Iirc someone mentioned that using a pointer to the data (over an array) has drawbacks, although for the sake of me I cannot think of any. Can anyone care to enlighten me, please ?

I guess an extensible array at the end of the struct is simply a nice fit sometimes. Also makes it more obvious how much junk gets copied over I suppose.

So no serious 'issues' there, but it's mostly done for convenience. Thanks for clarifying.

Regards,
Emil
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#19 lore raw

Re: [PATCH 04/23] drm: Add drm structures for palette color property

In reply to Daniel Vetter

Regards
Shashank

Quoted 22 lines · Daniel Vetter
Quoted 21 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

This patch adds new structures in DRM layer for Palette color correction.These structures will be used by user space agents to configure appropriate number of samples and Palette LUT for a platform.

---
  include/uapi/drm/drm.h | 27 +++++++++++++++++++++++++++
  1 file changed, 27 insertions(+)
include/uapi/drm/drm.h +0 -0
index e3c642f..f72b916 100644
@@ -840,6 +840,33 @@ struct drm_palette_caps {
  	__u32 num_samples_after_ctm;
  };
 
Quoted 12 lines

include/uapi/drm/drm.h struct drm_palette_caps { · line 851

Quoted 9 lines
include/uapi/drm/drm.h +9 -0
+struct drm_r32g32b32 {
+	/*
+	 * Data is in U8.24 fixed point format.
+	 * All platforms support values within [0, 1.0] range,
+	 * for Red, Green and Blue colors.
+	 */
+	__u32 r32;
+	__u32 g32;
+	__u32 b32;

It's not strictly required, but adding a __u32 reserved here to align the struct to 64 bits seems good imo. Slight overhead but meh about that.

Humm, ok, we can check this out.

Quoted 14 lines

include/uapi/drm/drm.h struct drm_palette_caps { · line 856

Quoted 6 lines
include/uapi/drm/drm.h +5 -0
+};
+
+struct drm_palette {
+	/* Structure version. Should be 1 currently */
+	__u32 version;

Definitely great practice to take compat into account and definitely needed for the first design using ioctls but I don't think we need this here. Properties are already extinsible themselves: We can just greate a "ctm-v2", "ctm-v3" if the layout changes, and since the actual ctm matrix is stored in the drm_crtc_state any compat code on the kernel will be shared.

Quoted 6 lines

Aside: For an ioctl the recommended way to handle backwards compat and extensions in drm is with a flags bitfield. That's more flexible than a linear version field, and extending the ioctl struct at the end is already handled by the drm core in a transparent fashion (it 0-fills either kernel or userspace side).

Agree, we will drop this. Do you think we should add a flags field, or is it ok without it ?

Quoted 11 lines

include/uapi/drm/drm.h struct drm_palette_caps { · line 861

Quoted 5 lines
include/uapi/drm/drm.h +5 -0
+	/*
+	 * This has to be a supported value during get call.
+	 * Feature will be disabled if this is 0 while set
+	 */
+	__u32 num_samples;

blob properties already have a size, storing it again in the blob is redundnant. Instead I think a small helper to get the number of samples for a given gamma table blob would be needed.

Cheers, Daniel

Please note that they are different. One is the size of blob and other one is the num_samples supported by the property, in the current correction mode. If you check the design doc, num_sample serves the purpose of deciding which correction mode to be applied also. fox ex, for gamma, num_samples=0 indicates disable gamma, whereas num_samples=512 indicates split gamma mode.

Shashank

Quoted 15 lines
Quoted 15 lines
include/uapi/drm/drm.h +8 -1
+	/*
+	 * Starting of palette LUT in R32G32B32 format.
+	 * Each of RGB value is in U8.24 fixed point format.
+	 * Actual number of samples will depend upon num_samples
+	 */
+	struct drm_r32g32b32 lut[0];
+};
+
  /* typedef area */
  #ifndef __KERNEL__
  typedef struct drm_clip_rect drm_clip_rect_t;
--

1.9.1

Quoted 5 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#20 lore raw

Re: [PATCH 04/23] drm: Add drm structures for palette color property

Quoted 53 lines · Shashank

Regards
Shashank

Quoted 22 lines · Daniel Vetter
Quoted 21 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

This patch adds new structures in DRM layer for Palette color correction.These structures will be used by user space agents to configure appropriate number of samples and Palette LUT for a platform.

---
 include/uapi/drm/drm.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
include/uapi/drm/drm.h +0 -0
index e3c642f..f72b916 100644
@@ -840,6 +840,33 @@ struct drm_palette_caps {
 	__u32 num_samples_after_ctm;
 };
 
Quoted 12 lines

include/uapi/drm/drm.h struct drm_palette_caps { · line 851

Quoted 9 lines
include/uapi/drm/drm.h +9 -0
+struct drm_r32g32b32 {
+	/*
+	 * Data is in U8.24 fixed point format.
+	 * All platforms support values within [0, 1.0] range,
+	 * for Red, Green and Blue colors.
+	 */
+	__u32 r32;
+	__u32 g32;
+	__u32 b32;

It's not strictly required, but adding a __u32 reserved here to align the struct to 64 bits seems good imo. Slight overhead but meh about that.

Humm, ok, we can check this out.

Quoted 14 lines

include/uapi/drm/drm.h struct drm_palette_caps { · line 856

Quoted 6 lines
include/uapi/drm/drm.h +5 -0
+};
+
+struct drm_palette {
+	/* Structure version. Should be 1 currently */
+	__u32 version;

Definitely great practice to take compat into account and definitely needed for the first design using ioctls but I don't think we need this here. Properties are already extinsible themselves: We can just greate a "ctm-v2", "ctm-v3" if the layout changes, and since the actual ctm matrix is stored in the drm_crtc_state any compat code on the kernel will be shared.

Quoted 8 lines
Quoted 6 lines

Aside: For an ioctl the recommended way to handle backwards compat and extensions in drm is with a flags bitfield. That's more flexible than a linear version field, and extending the ioctl struct at the end is already handled by the drm core in a transparent fashion (it 0-fills either kernel or userspace side).

Agree, we will drop this. Do you think we should add a flags field, or is it ok without it ?

No need for a flag field since this is not an ioctl struct. That "Aside:" was really meant as a comment aside and not relevant for properties.

Quoted 10 lines
Quoted 10 lines

include/uapi/drm/drm.h struct drm_palette_caps { · line 861

Quoted 5 lines
include/uapi/drm/drm.h +5 -0
+	/*
+	 * This has to be a supported value during get call.
+	 * Feature will be disabled if this is 0 while set
+	 */
+	__u32 num_samples;

blob properties already have a size, storing it again in the blob is redundnant. Instead I think a small helper to get the number of samples for a given gamma table blob would be needed.

Quoted 6 lines
Quoted 1 line

Cheers, Daniel

Please note that they are different. One is the size of blob and other one is the num_samples supported by the property, in the current correction mode. If you check the design doc, num_sample serves the purpose of deciding which correction mode to be applied also. fox ex, for gamma, num_samples=0 indicates disable gamma, whereas num_samples=512 indicates split gamma mode.

num_samples = blob_size/(sizeof(drm_r32g32b32));

I just think that this information is redundant and if userspace supplies a gamma table with the wrong size we should just reject it. There's really no reason for userspace to create a blob property where the size doesn't exactly match the gamma table.

I guess again that this was needed for the ioctl where there's no sideband for the size. But properties _are_ sized.

Also, you need to make sure that the property size is aligned and reject the gamma table property if that's not the case, i.e.

	if (blob_size % sizeof(drm_r32g32b32))
		return -EINVAL;

Plus then driver-specific code to reject anything that's not one of the supported sizes too.

Of course that also needs igt test coverage.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#21 lore raw

Re: [PATCH 04/23] drm: Add drm structures for palette color property

Regards
Shashank

Quoted 85 lines · Daniel Vetter
Quoted 53 lines · Shashank

Regards
Shashank

Quoted 22 lines · Daniel Vetter
Quoted 21 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

This patch adds new structures in DRM layer for Palette color correction.These structures will be used by user space agents to configure appropriate number of samples and Palette LUT for a platform.

---
  include/uapi/drm/drm.h | 27 +++++++++++++++++++++++++++
  1 file changed, 27 insertions(+)
include/uapi/drm/drm.h +0 -0
index e3c642f..f72b916 100644
@@ -840,6 +840,33 @@ struct drm_palette_caps {
  	__u32 num_samples_after_ctm;
  };
 
Quoted 12 lines

include/uapi/drm/drm.h struct drm_palette_caps { · line 851

Quoted 9 lines
include/uapi/drm/drm.h +9 -0
+struct drm_r32g32b32 {
+	/*
+	 * Data is in U8.24 fixed point format.
+	 * All platforms support values within [0, 1.0] range,
+	 * for Red, Green and Blue colors.
+	 */
+	__u32 r32;
+	__u32 g32;
+	__u32 b32;

It's not strictly required, but adding a __u32 reserved here to align the struct to 64 bits seems good imo. Slight overhead but meh about that.

Humm, ok, we can check this out.

Quoted 14 lines

include/uapi/drm/drm.h struct drm_palette_caps { · line 856

Quoted 6 lines
include/uapi/drm/drm.h +5 -0
+};
+
+struct drm_palette {
+	/* Structure version. Should be 1 currently */
+	__u32 version;

Definitely great practice to take compat into account and definitely needed for the first design using ioctls but I don't think we need this here. Properties are already extinsible themselves: We can just greate a "ctm-v2", "ctm-v3" if the layout changes, and since the actual ctm matrix is stored in the drm_crtc_state any compat code on the kernel will be shared.

Quoted 8 lines
Quoted 6 lines

Aside: For an ioctl the recommended way to handle backwards compat and extensions in drm is with a flags bitfield. That's more flexible than a linear version field, and extending the ioctl struct at the end is already handled by the drm core in a transparent fashion (it 0-fills either kernel or userspace side).

Agree, we will drop this. Do you think we should add a flags field, or is it ok without it ?

No need for a flag field since this is not an ioctl struct. That "Aside:" was really meant as a comment aside and not relevant for properties.

Quoted 10 lines
Quoted 10 lines

include/uapi/drm/drm.h struct drm_palette_caps { · line 861

Quoted 5 lines
include/uapi/drm/drm.h +5 -0
+	/*
+	 * This has to be a supported value during get call.
+	 * Feature will be disabled if this is 0 while set
+	 */
+	__u32 num_samples;

blob properties already have a size, storing it again in the blob is redundnant. Instead I think a small helper to get the number of samples for a given gamma table blob would be needed.

Quoted 6 lines
Quoted 1 line

Cheers, Daniel

Please note that they are different. One is the size of blob and other one is the num_samples supported by the property, in the current correction mode. If you check the design doc, num_sample serves the purpose of deciding which correction mode to be applied also. fox ex, for gamma, num_samples=0 indicates disable gamma, whereas num_samples=512 indicates split gamma mode.

num_samples = blob_size/(sizeof(drm_r32g32b32));

Quoted 7 lines

I just think that this information is redundant and if userspace supplies a gamma table with the wrong size we should just reject it. There's really no reason for userspace to create a blob property where the size doesn't exactly match the gamma table.

I guess again that this was needed for the ioctl where there's no sideband for the size. But properties _are_ sized.

Again, this is what we decided in the design discussion. The driver will showcase the best option for property, but that doesn't stop a user space with more knowledge of HW to send other supported options. for example, in case of gamma, the driver supports all 3 possible modes:
- 8 bit legacy gamma (256 coeff)
- 10 bit split gamma (1024 coeff (512 + 512))
- 12 bit interpolated gamma (coeff 513)
So here, we have used the no of coeff to define which type of gamma we want to apply. So in the core gamma function you will find 4 cases:
switch(no_coeff)
case 0: disable gamma;
case 256: enable legacy gamma;
case 512: enable 10 bit split gamma;
case 513: enable 12 bit interpolated gamma;

This is the simplest implementation, and there is no need for any additional variable.

Quoted 8 lines

Also, you need to make sure that the property size is aligned and reject the gamma table property if that's not the case, i.e.

	if (blob_size % sizeof(drm_r32g32b32))
		return -EINVAL;
Quoted 6 lines

Plus then driver-specific code to reject anything that's not one of the supported sizes too.

Of course that also needs igt test coverage.
-Daniel

Shashank
_______________________________________________
dri-devel mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#22 lore raw

Re: [PATCH 04/23] drm: Add drm structures for palette color property

Quoted 111 lines · Shashank

Regards
Shashank

Quoted 85 lines · Daniel Vetter
Quoted 53 lines · Shashank

Regards
Shashank

Quoted 22 lines · Daniel Vetter
Quoted 21 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

This patch adds new structures in DRM layer for Palette color correction.These structures will be used by user space agents to configure appropriate number of samples and Palette LUT for a platform.

---
 include/uapi/drm/drm.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
include/uapi/drm/drm.h +0 -0
index e3c642f..f72b916 100644
@@ -840,6 +840,33 @@ struct drm_palette_caps {
 	__u32 num_samples_after_ctm;
 };
 
Quoted 12 lines

include/uapi/drm/drm.h struct drm_palette_caps { · line 851

Quoted 9 lines
include/uapi/drm/drm.h +9 -0
+struct drm_r32g32b32 {
+	/*
+	 * Data is in U8.24 fixed point format.
+	 * All platforms support values within [0, 1.0] range,
+	 * for Red, Green and Blue colors.
+	 */
+	__u32 r32;
+	__u32 g32;
+	__u32 b32;

It's not strictly required, but adding a __u32 reserved here to align the struct to 64 bits seems good imo. Slight overhead but meh about that.

Humm, ok, we can check this out.

Quoted 14 lines

include/uapi/drm/drm.h struct drm_palette_caps { · line 856

Quoted 6 lines
include/uapi/drm/drm.h +5 -0
+};
+
+struct drm_palette {
+	/* Structure version. Should be 1 currently */
+	__u32 version;

Definitely great practice to take compat into account and definitely needed for the first design using ioctls but I don't think we need this here. Properties are already extinsible themselves: We can just greate a "ctm-v2", "ctm-v3" if the layout changes, and since the actual ctm matrix is stored in the drm_crtc_state any compat code on the kernel will be shared.

Quoted 8 lines
Quoted 6 lines

Aside: For an ioctl the recommended way to handle backwards compat and extensions in drm is with a flags bitfield. That's more flexible than a linear version field, and extending the ioctl struct at the end is already handled by the drm core in a transparent fashion (it 0-fills either kernel or userspace side).

Agree, we will drop this. Do you think we should add a flags field, or is it ok without it ?

No need for a flag field since this is not an ioctl struct. That "Aside:" was really meant as a comment aside and not relevant for properties.

Quoted 10 lines
Quoted 10 lines

include/uapi/drm/drm.h struct drm_palette_caps { · line 861

Quoted 5 lines
include/uapi/drm/drm.h +5 -0
+	/*
+	 * This has to be a supported value during get call.
+	 * Feature will be disabled if this is 0 while set
+	 */
+	__u32 num_samples;

blob properties already have a size, storing it again in the blob is redundnant. Instead I think a small helper to get the number of samples for a given gamma table blob would be needed.

Quoted 6 lines
Quoted 1 line

Cheers, Daniel

Please note that they are different. One is the size of blob and other one is the num_samples supported by the property, in the current correction mode. If you check the design doc, num_sample serves the purpose of deciding which correction mode to be applied also. fox ex, for gamma, num_samples=0 indicates disable gamma, whereas num_samples=512 indicates split gamma mode.

num_samples = blob_size/(sizeof(drm_r32g32b32));

Quoted 7 lines

I just think that this information is redundant and if userspace supplies a gamma table with the wrong size we should just reject it. There's really no reason for userspace to create a blob property where the size doesn't exactly match the gamma table.

I guess again that this was needed for the ioctl where there's no sideband for the size. But properties _are_ sized.

Again, this is what we decided in the design discussion. The driver will showcase the best option for property, but that doesn't stop a user space with more knowledge of HW to send other supported options. for example, in case of gamma, the driver supports all 3 possible modes:
- 8 bit legacy gamma (256 coeff)
- 10 bit split gamma (1024 coeff (512 + 512))
- 12 bit interpolated gamma (coeff 513)
So here, we have used the no of coeff to define which type of gamma we want to apply. So in the core gamma function you will find 4 cases:
switch(no_coeff)
case 0: disable gamma;
case 256: enable legacy gamma;
case 512: enable 10 bit split gamma;
case 513: enable 12 bit interpolated gamma;

Quoted 2 lines

This is the simplest implementation, and there is no need for any additional variable.

I'm confused, since this is exactly what I'm suggesting. My only observation is that we don't need a separate num_samples field in the blob structure itself since userspace already needs to tell the kernel the size of the blob property separately. And we can derive num_samples from the size of the blob easily (which means it'll make the necessary overflow checks simpler).

You _must_ check drm_property_blob->length anyway (atm that seems to be missing, but I didn't check with a full search), so might as well use that to compute num_samples instead of just making sure they match. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#23 lore raw

PATCH 5/23 drm: Add structure to set/get a CTM color property

In reply to Shashank Sharma

From: Kausal Malladi <[email protected]>

Color Manager framework defines a color correction property for color space transformation and Gamut mapping. This property is called CTM (Color Transformation Matrix).

This patch adds a new structure in DRM layer for CTM. This structure can be used by all user space agents to configure CTM coefficients for color correction.

---
 include/uapi/drm/drm.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/uapi/drm/drm.h +12 -0
index f72b916..9580772 100644
@@ -867,6 +867,18 @@ struct drm_palette {
 	struct drm_r32g32b32 lut[0];
 };
 
+struct drm_ctm {
+	/* Structure version. Should be 1 currently */
+	__u32 version;
+	/*
+	 * Each value is in S31.32 format.
+	 * This is 3x3 matrix in row major format.
+	 * Integer part will be clipped to nearest
+	 * max/min boundary as supported by the HW platform.
+	 */
+	__s64 ctm_coeff[9];
+};
+
 /* typedef area */
 #ifndef __KERNEL__
 typedef struct drm_clip_rect drm_clip_rect_t;
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#24 lore raw

Re: [PATCH 05/23] drm: Add structure to set/get a CTM color property

Quoted 21 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

Color Manager framework defines a color correction property for color space transformation and Gamut mapping. This property is called CTM (Color Transformation Matrix).

This patch adds a new structure in DRM layer for CTM. This structure can be used by all user space agents to configure CTM coefficients for color correction.

---
 include/uapi/drm/drm.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/uapi/drm/drm.h +0 -0
index f72b916..9580772 100644

include/uapi/drm/drm.h struct drm_palette { · line 872

Quoted 6 lines
include/uapi/drm/drm.h +3 -0
@@ -867,6 +867,18 @@ struct drm_palette {
 	struct drm_r32g32b32 lut[0];
 };
 
+struct drm_ctm {
+	/* Structure version. Should be 1 currently */
+	__u32 version;

Same thing here, no version needed for properties.

Quoted 19 lines
include/uapi/drm/drm.h +9 -0
+	/*
+	 * Each value is in S31.32 format.
+	 * This is 3x3 matrix in row major format.
+	 * Integer part will be clipped to nearest
+	 * max/min boundary as supported by the HW platform.
+	 */
+	__s64 ctm_coeff[9];
+};
+
 /* typedef area */
 #ifndef __KERNEL__
 typedef struct drm_clip_rect drm_clip_rect_t;
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#25 lore raw

Re: [PATCH 05/23] drm: Add structure to set/get a CTM color property

Regards
Shashank

Quoted 25 lines · Daniel Vetter
Quoted 24 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

Color Manager framework defines a color correction property for color space transformation and Gamut mapping. This property is called CTM (Color Transformation Matrix).

This patch adds a new structure in DRM layer for CTM. This structure can be used by all user space agents to configure CTM coefficients for color correction.

---
  include/uapi/drm/drm.h | 12 ++++++++++++
  1 file changed, 12 insertions(+)
include/uapi/drm/drm.h +0 -0
index f72b916..9580772 100644
@@ -867,6 +867,18 @@ struct drm_palette {
  	struct drm_r32g32b32 lut[0];
  };
 
Quoted 5 lines

include/uapi/drm/drm.h struct drm_palette { · line 872

Quoted 3 lines
include/uapi/drm/drm.h +3 -0
+struct drm_ctm {
+	/* Structure version. Should be 1 currently */
+	__u32 version;

Same thing here, no version needed for properties.

Agree.
-Shashank

Quoted 16 lines
Quoted 16 lines
include/uapi/drm/drm.h +9 -1
+	/*
+	 * Each value is in S31.32 format.
+	 * This is 3x3 matrix in row major format.
+	 * Integer part will be clipped to nearest
+	 * max/min boundary as supported by the HW platform.
+	 */
+	__s64 ctm_coeff[9];
+};
+
  /* typedef area */
  #ifndef __KERNEL__
  typedef struct drm_clip_rect drm_clip_rect_t;
--

1.9.1

Quoted 5 lines
Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#26 lore raw

Re: [PATCH 05/23] drm: Add structure to set/get a CTM color property

In reply to Shashank Sharma
Quoted 21 lines · Shashank Sharma

From: Kausal Malladi <[email protected]>

Color Manager framework defines a color correction property for color space transformation and Gamut mapping. This property is called CTM (Color Transformation Matrix).

This patch adds a new structure in DRM layer for CTM. This structure can be used by all user space agents to configure CTM coefficients for color correction.

---
 include/uapi/drm/drm.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/uapi/drm/drm.h +0 -0
index f72b916..9580772 100644

include/uapi/drm/drm.h struct drm_palette { · line 875

Quoted 9 lines
include/uapi/drm/drm.h +6 -0
@@ -867,6 +867,18 @@ struct drm_palette {
 	struct drm_r32g32b32 lut[0];
 };
 
+struct drm_ctm {
+	/* Structure version. Should be 1 currently */
+	__u32 version;
+	/*
+	 * Each value is in S31.32 format.
+	 * This is 3x3 matrix in row major format.

I'm not sure that exlains things. Maybe sketch the math equation here (something like what I put in i915_reg.h for the CHV sprite CSC). Which reminds me: what are we going to do about the pre/post offset stuff? I was sort of expecting to see it here, but maybe you put those into separate properties?

include/uapi/drm/drm.h struct drm_palette { · line 879

Quoted 4 lines
include/uapi/drm/drm.h +4 -0
+	 * Integer part will be clipped to nearest
+	 * max/min boundary as supported by the HW platform.
+	 */
+	__s64 ctm_coeff[9];

ctm_ prefix seems superfluous. Also could maybe use some comment explaining what ctm is?

Quoted 12 lines
include/uapi/drm/drm.h +2 -0
+};
+
 /* typedef area */
 #ifndef __KERNEL__
 typedef struct drm_clip_rect drm_clip_rect_t;
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#27 lore raw

PATCH 6/23 drm/i915: Add atomic set property interface for CRTC

In reply to Shashank Sharma

From: Kausal Malladi <[email protected]>

This patch adds atomic set property interface for Intel CRTC. This interface will be used for set operation on any DRM properties.

---
 drivers/gpu/drm/i915/intel_atomic.c  | 9 +++++++++
 drivers/gpu/drm/i915/intel_display.c | 2 ++
 drivers/gpu/drm/i915/intel_drv.h     | 4 ++++
 3 files changed, 15 insertions(+)
drivers/gpu/drm/i915/intel_atomic.c +9 -0
index f1975f2..d5b7eb1 100644
@@ -309,3 +309,12 @@ void intel_atomic_state_clear(struct drm_atomic_state *s)
 	drm_atomic_state_default_clear(&state->base);
 	state->dpll_set = false;
 }
+
+int intel_crtc_atomic_set_property(struct drm_crtc *crtc,
+				   struct drm_crtc_state *state,
+				   struct drm_property *property,
+				   uint64_t val)
+{
+	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
+	return -EINVAL;
+}
drivers/gpu/drm/i915/intel_display.c +2 -0
index fc00867..444ea30 100644
@@ -13192,6 +13192,8 @@ static const struct drm_crtc_funcs intel_crtc_funcs = {
 	.set_config = drm_atomic_helper_set_config,
 	.destroy = intel_crtc_destroy,
 	.page_flip = intel_crtc_page_flip,
+	.set_property = drm_atomic_helper_crtc_set_property,
+	.atomic_set_property = intel_crtc_atomic_set_property,
 	.atomic_duplicate_state = intel_crtc_duplicate_state,
 	.atomic_destroy_state = intel_crtc_destroy_state,
 };
drivers/gpu/drm/i915/intel_drv.h +4 -0
index 02a755a..510f559 100644
@@ -1450,6 +1450,10 @@ intel_atomic_get_crtc_state(struct drm_atomic_state *state,
 int intel_atomic_setup_scalers(struct drm_device *dev,
 	struct intel_crtc *intel_crtc,
 	struct intel_crtc_state *crtc_state);
+int intel_crtc_atomic_set_property(struct drm_crtc *plane,
+				   struct drm_crtc_state *state,
+				   struct drm_property *property,
+				   uint64_t val);
 
 /* intel_atomic_plane.c */
 struct intel_plane_state *intel_create_plane_state(struct drm_plane *plane);
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#28 lore raw

PATCH 7/23 drm/i915: Add atomic get property interface for CRTC

In reply to Shashank Sharma

From: Kausal Malladi <[email protected]>

This patch adds atomic get property interface for Intel CRTC. This interface will be used for get operation on any non-core DRM properties.

---
 drivers/gpu/drm/i915/intel_atomic.c  | 9 +++++++++
 drivers/gpu/drm/i915/intel_display.c | 1 +
 drivers/gpu/drm/i915/intel_drv.h     | 4 ++++
 3 files changed, 14 insertions(+)
drivers/gpu/drm/i915/intel_atomic.c +9 -0
index d5b7eb1..500d2998 100644
@@ -318,3 +318,12 @@ int intel_crtc_atomic_set_property(struct drm_crtc *crtc,
 	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
 	return -EINVAL;
 }
+
+int intel_crtc_atomic_get_property(struct drm_crtc *crtc,
+				   const struct drm_crtc_state *state,
+				   struct drm_property *property,
+				   uint64_t *val)
+{
+	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
+	return -EINVAL;
+}
drivers/gpu/drm/i915/intel_display.c +1 -0
index 444ea30..010acca 100644
@@ -13194,6 +13194,7 @@ static const struct drm_crtc_funcs intel_crtc_funcs = {
 	.page_flip = intel_crtc_page_flip,
 	.set_property = drm_atomic_helper_crtc_set_property,
 	.atomic_set_property = intel_crtc_atomic_set_property,
+	.atomic_get_property = intel_crtc_atomic_get_property,
 	.atomic_duplicate_state = intel_crtc_duplicate_state,
 	.atomic_destroy_state = intel_crtc_destroy_state,
 };
drivers/gpu/drm/i915/intel_drv.h +4 -0
index 510f559..e27e754 100644
@@ -1454,6 +1454,10 @@ int intel_crtc_atomic_set_property(struct drm_crtc *plane,
 				   struct drm_crtc_state *state,
 				   struct drm_property *property,
 				   uint64_t val);
+int intel_crtc_atomic_get_property(struct drm_crtc *plane,
+				   const struct drm_crtc_state *state,
+				   struct drm_property *property,
+				   uint64_t *val);
 
 /* intel_atomic_plane.c */
 struct intel_plane_state *intel_create_plane_state(struct drm_plane *plane);
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#29 lore raw

PATCH 8/23 drm/i915: Create color management files

In reply to Shashank Sharma

From: Kausal Malladi <[email protected]>

This patch create new files intel_color_manager.c which will contain the core color correction code for I915 driver and its header intel_color_manager.h

The per color property patches coming up in this patch series will fill the appropriate functions in this file.

---
 drivers/gpu/drm/i915/Makefile              |  3 ++-
 drivers/gpu/drm/i915/intel_color_manager.c | 33 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_color_manager.h | 29 ++++++++++++++++++++++++++
 3 files changed, 64 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
drivers/gpu/drm/i915/Makefile +2 -1
index 44d290a..56caf9e 100644
@@ -64,7 +64,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_FBDEV_EMULATION)	+= intel_fbdev.o
 
drivers/gpu/drm/i915/intel_color_manager.c new file +33 -0
new file mode 100644
index 0000000..7357d99
@@ -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 <[email protected]>
+ * Kausal Malladi <[email protected]>
+ */
+
+#include "intel_color_manager.h"
+
+void intel_attach_color_properties_to_crtc(struct drm_device *dev,
+		struct drm_mode_object *mode_obj)
+{
+}
drivers/gpu/drm/i915/intel_color_manager.h new file +29 -0
new file mode 100644
index 0000000..04c921d
@@ -0,0 +1,29 @@
+/*
+ * 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 <[email protected]>
+ * Kausal Malladi <[email protected]>
+ */
+#include <drm/drmP.h>
+#include <drm/drm_crtc_helper.h>
+#include "i915_drv.h"
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#30 lore raw

PATCH 9/23 drm/i915: Register pipe color capabilities

In reply to Shashank Sharma

DRM color manager contains these color properties:

1. "crtc_palette_capabilities_property": to allow a core driver to load and showcase its color correction capabilities to user space.
2. "ctm": Color transformation matrix property, where a color transformation matrix of 9 correction values gets applied as correction.
3. "palette_before_ctm": for corrections which get applied beore color transformation matrix correction.
4. "palette_after_ctm": for corrections which get applied after color transformation matrix correction.

Intel color manager registers:
1. Gamma correction property as "palette_after_ctm" property
2. Degamma correction capability as "palette_bafore_ctm" property capability as "palette_after_ctm" DRM color property hook.
3. CSC as "ctm" property.

This patch does the following:
1. Add a function which loads the platform's color correction capabilities in the cm_crtc_palette_capabilities_property structure.
2. Attaches the cm_crtc_palette_capabilities_property to every CRTC getting initiaized.
3. Adds two new parameters "num_samples_after_ctm" and "num_samples_before_ctm" in intel_device_info as gamma and degamma coefficients vary per platform basis.

---
 drivers/gpu/drm/i915/i915_drv.h            |  2 ++
 drivers/gpu/drm/i915/intel_color_manager.c | 45 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_color_manager.h |  2 ++
 3 files changed, 49 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 3bf8a9b..22de2cb 100644
@@ -798,6 +798,8 @@ struct intel_device_info {
 	u8 num_sprites[I915_MAX_PIPES];
 	u8 gen;
 	u8 ring_mask; /* Rings supported by the HW */
+	u16 num_samples_after_ctm;
+	u16 num_samples_before_ctm;
 	DEV_INFO_FOR_EACH_FLAG(DEFINE_FLAG, SEP_SEMICOLON);
 	/* Register offsets for the various display pipes and transcoders */
 	int pipe_offsets[I915_MAX_TRANSCODERS];
drivers/gpu/drm/i915/intel_color_manager.c +45 -0

52 lines not on this page · raw message

drivers/gpu/drm/i915/intel_color_manager.h +2 -0
index 04c921d..1a42244 100644
@@ -27,3 +27,5 @@
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
 #include "i915_drv.h"
+
+#define COLOR_STRUCT_VERSION			1
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#31 lore raw

Re: [PATCH 09/23] drm/i915: Register pipe color capabilities

Quoted 90 lines · Shashank Sharma

DRM color manager contains these color properties:

1. "crtc_palette_capabilities_property": to allow a core driver to load and showcase its color correction capabilities to user space.
2. "ctm": Color transformation matrix property, where a color transformation matrix of 9 correction values gets applied as correction.
3. "palette_before_ctm": for corrections which get applied beore color transformation matrix correction.
4. "palette_after_ctm": for corrections which get applied after color transformation matrix correction.

Intel color manager registers:
1. Gamma correction property as "palette_after_ctm" property
2. Degamma correction capability as "palette_bafore_ctm" property capability as "palette_after_ctm" DRM color property hook.
3. CSC as "ctm" property.

This patch does the following:
1. Add a function which loads the platform's color correction capabilities in the cm_crtc_palette_capabilities_property structure.
2. Attaches the cm_crtc_palette_capabilities_property to every CRTC getting initiaized.
3. Adds two new parameters "num_samples_after_ctm" and "num_samples_before_ctm" in intel_device_info as gamma and degamma coefficients vary per platform basis.

---
 drivers/gpu/drm/i915/i915_drv.h            |  2 ++
 drivers/gpu/drm/i915/intel_color_manager.c | 45 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_color_manager.h |  2 ++
 3 files changed, 49 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 3bf8a9b..22de2cb 100644
@@ -798,6 +798,8 @@ struct intel_device_info {
 	u8 num_sprites[I915_MAX_PIPES];
 	u8 gen;
 	u8 ring_mask; /* Rings supported by the HW */
+	u16 num_samples_after_ctm;
+	u16 num_samples_before_ctm;
 	DEV_INFO_FOR_EACH_FLAG(DEFINE_FLAG, SEP_SEMICOLON);
 	/* Register offsets for the various display pipes and transcoders */
 	int pipe_offsets[I915_MAX_TRANSCODERS];
drivers/gpu/drm/i915/intel_color_manager.c +31 -0
index 7357d99..77f58f2 100644
@@ -27,7 +27,52 @@
 
 #include "intel_color_manager.h"
 
+int get_pipe_capabilities(struct drm_device *dev,
+		struct drm_palette_caps *palette_caps, struct drm_crtc *crtc)
+{
+	struct drm_property_blob *blob;
+
+	/*
+	 * This function loads best capability for gamma correction
+	 * For example:
+	 * CHV best Gamma correction (CGM unit, 10 bit)
+	 * has 257 entries, best degamma is 65 entries
+	 */
+	palette_caps->version = COLOR_STRUCT_VERSION;
+	palette_caps->num_samples_after_ctm =
+				INTEL_INFO(dev)->num_samples_after_ctm;
+	palette_caps->num_samples_before_ctm =
+				INTEL_INFO(dev)->num_samples_before_ctm;
+	blob = drm_property_create_blob(dev, sizeof(struct drm_palette_caps),
+			(const void *) palette_caps);
+	if (IS_ERR_OR_NULL(blob)) {
+		DRM_ERROR("Create blob for capabilities failed\n");
+		return PTR_ERR(blob);
+	}
+
+	return blob->base.id;
+}
+
 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;
+

drivers/gpu/drm/i915/intel_color_manager.c line 73

Quoted 10 lines
drivers/gpu/drm/i915/intel_color_manager.c +10 -0
+	crtc = obj_to_crtc(mode_obj);
+	palette_caps = kzalloc(sizeof(struct drm_palette_caps),
+			GFP_KERNEL);
+	capabilities_blob_id = get_pipe_capabilities(dev,
+						palette_caps, crtc);
+
+	if (config->cm_crtc_palette_capabilities_property) {
+		drm_object_attach_property(mode_obj,
+			config->cm_crtc_palette_capabilities_property,
+			capabilities_blob_id);

I didn't find any code to attach the before/after_ctm gamma properties and the ctm property. Also I think a small helper would be really nice here in the drm core:

drm_crtc_attach_cc_properties(struct drm_crtc *crtc,
int gamma_before_ctm, bool ctm,
int gamm_after_ctm)

And then that directly constructs the palette caps from the given values (if they're non-0) and also attaches the properties to the crtc (if they're non-0 for gamma, treu for the ctm).

If that attach_property code really isn't there I wonder a bit how this all works, we /should/ be filtering out properties which aren't attached to the object.
-Daniel

Quoted 22 lines
drivers/gpu/drm/i915/intel_color_manager.c +4 -0
+		DRM_DEBUG_DRIVER("Capabilities attached to CRTC\n");
+	}
+
+	kfree(palette_caps);
 }
drivers/gpu/drm/i915/intel_color_manager.h +2 -0
index 04c921d..1a42244 100644
@@ -27,3 +27,5 @@
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
 #include "i915_drv.h"
+
+#define COLOR_STRUCT_VERSION			1
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#32 lore raw

Re: [PATCH 09/23] drm/i915: Register pipe color capabilities

Regards
Shashank

Quoted 97 lines · Daniel Vetter
Quoted 96 lines · Shashank Sharma

DRM color manager contains these color properties:

1. "crtc_palette_capabilities_property": to allow a core driver to load and showcase its color correction capabilities to user space.
2. "ctm": Color transformation matrix property, where a color transformation matrix of 9 correction values gets applied as correction.
3. "palette_before_ctm": for corrections which get applied beore color transformation matrix correction.
4. "palette_after_ctm": for corrections which get applied after color transformation matrix correction.

Intel color manager registers:
1. Gamma correction property as "palette_after_ctm" property
2. Degamma correction capability as "palette_bafore_ctm" property capability as "palette_after_ctm" DRM color property hook.
3. CSC as "ctm" property.

This patch does the following:
1. Add a function which loads the platform's color correction capabilities in the cm_crtc_palette_capabilities_property structure.
2. Attaches the cm_crtc_palette_capabilities_property to every CRTC getting initiaized.
3. Adds two new parameters "num_samples_after_ctm" and "num_samples_before_ctm" in intel_device_info as gamma and degamma coefficients vary per platform basis.

---
  drivers/gpu/drm/i915/i915_drv.h            |  2 ++
  drivers/gpu/drm/i915/intel_color_manager.c | 45 ++++++++++++++++++++++++++++++
  drivers/gpu/drm/i915/intel_color_manager.h |  2 ++
  3 files changed, 49 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 3bf8a9b..22de2cb 100644
@@ -798,6 +798,8 @@ struct intel_device_info {
  	u8 num_sprites[I915_MAX_PIPES];
  	u8 gen;
  	u8 ring_mask; /* Rings supported by the HW */
+	u16 num_samples_after_ctm;
+	u16 num_samples_before_ctm;
  	DEV_INFO_FOR_EACH_FLAG(DEFINE_FLAG, SEP_SEMICOLON);
  	/* Register offsets for the various display pipes and transcoders */
  	int pipe_offsets[I915_MAX_TRANSCODERS];
drivers/gpu/drm/i915/intel_color_manager.c +37 -0
index 7357d99..77f58f2 100644
@@ -27,7 +27,52 @@
 
  #include "intel_color_manager.h"
 
+int get_pipe_capabilities(struct drm_device *dev,
+		struct drm_palette_caps *palette_caps, struct drm_crtc *crtc)
+{
+	struct drm_property_blob *blob;
+
+	/*
+	 * This function loads best capability for gamma correction
+	 * For example:
+	 * CHV best Gamma correction (CGM unit, 10 bit)
+	 * has 257 entries, best degamma is 65 entries
+	 */
+	palette_caps->version = COLOR_STRUCT_VERSION;
+	palette_caps->num_samples_after_ctm =
+				INTEL_INFO(dev)->num_samples_after_ctm;
+	palette_caps->num_samples_before_ctm =
+				INTEL_INFO(dev)->num_samples_before_ctm;
+	blob = drm_property_create_blob(dev, sizeof(struct drm_palette_caps),
+			(const void *) palette_caps);
+	if (IS_ERR_OR_NULL(blob)) {
+		DRM_ERROR("Create blob for capabilities failed\n");
+		return PTR_ERR(blob);
+	}
+
+	return blob->base.id;
+}
+
  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;
+
+	crtc = obj_to_crtc(mode_obj);
+	palette_caps = kzalloc(sizeof(struct drm_palette_caps),
+			GFP_KERNEL);
+	capabilities_blob_id = get_pipe_capabilities(dev,
+						palette_caps, crtc);
+
Quoted 9 lines

drivers/gpu/drm/i915/intel_color_manager.c line 73

Quoted 4 lines
drivers/gpu/drm/i915/intel_color_manager.c +4 -0
+	if (config->cm_crtc_palette_capabilities_property) {
+		drm_object_attach_property(mode_obj,
+			config->cm_crtc_palette_capabilities_property,
+			capabilities_blob_id);

I didn't find any code to attach the before/after_ctm gamma properties and the ctm property. Also I think a small helper would be really nice here in the drm core:

Patch 15,16,17 adds those for gamma, degamma and CSC. This is just for the capabilities property.

Quoted 5 lines

drm_crtc_attach_cc_properties(struct drm_crtc *crtc,
int gamma_before_ctm, bool ctm,
int gamm_after_ctm)

Quoted 7 lines

And then that directly constructs the palette caps from the given values (if they're non-0) and also attaches the properties to the crtc (if they're non-0 for gamma, treu for the ctm).

If that attach_property code really isn't there I wonder a bit how this all works, we /should/ be filtering out properties which aren't attached to the object.

As I mentioned in the cover-letter, here is the sequence:
First 5 patches add color management support in DRM layer
Next 7 patches add Intel color management framework in I915 driver (This is still the framework part) Next 5 patches add color correction for CHV (gamma, degamma and CSC)
(Here comes the core property and enabling part)
Next 2 patches enable color management, by attaching the properties to
CRTC(Matt's comment on enable property code only when the job is done)
Next 4 patches add color correction for BDW (gamma, degamma)

Quoted 20 lines

-Daniel

Quoted 18 lines
drivers/gpu/drm/i915/intel_color_manager.c +4 -0
+		DRM_DEBUG_DRIVER("Capabilities attached to CRTC\n");
+	}
+
+	kfree(palette_caps);
  }
drivers/gpu/drm/i915/intel_color_manager.h +2 -1
index 04c921d..1a42244 100644
@@ -27,3 +27,5 @@
  #include <drm/drmP.h>
  #include <drm/drm_crtc_helper.h>
  #include "i915_drv.h"
+
+#define COLOR_STRUCT_VERSION			1
--

1.9.1

Quoted 5 lines
Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#33 lore raw

Re: [Intel-gfx] [PATCH 09/23] drm/i915: Register pipe color capabilities

Quoted 110 lines · Shashank

Regards
Shashank

Quoted 97 lines · Daniel Vetter
Quoted 96 lines · Shashank Sharma

DRM color manager contains these color properties:

1. "crtc_palette_capabilities_property": to allow a core driver to load and showcase its color correction capabilities to user space.
2. "ctm": Color transformation matrix property, where a color transformation matrix of 9 correction values gets applied as correction.
3. "palette_before_ctm": for corrections which get applied beore color transformation matrix correction.
4. "palette_after_ctm": for corrections which get applied after color transformation matrix correction.

Intel color manager registers:
1. Gamma correction property as "palette_after_ctm" property
2. Degamma correction capability as "palette_bafore_ctm" property capability as "palette_after_ctm" DRM color property hook.
3. CSC as "ctm" property.

This patch does the following:
1. Add a function which loads the platform's color correction capabilities in the cm_crtc_palette_capabilities_property structure.
2. Attaches the cm_crtc_palette_capabilities_property to every CRTC getting initiaized.
3. Adds two new parameters "num_samples_after_ctm" and "num_samples_before_ctm" in intel_device_info as gamma and degamma coefficients vary per platform basis.

---
 drivers/gpu/drm/i915/i915_drv.h            |  2 ++
 drivers/gpu/drm/i915/intel_color_manager.c | 45 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_color_manager.h |  2 ++
 3 files changed, 49 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 3bf8a9b..22de2cb 100644
@@ -798,6 +798,8 @@ struct intel_device_info {
 	u8 num_sprites[I915_MAX_PIPES];
 	u8 gen;
 	u8 ring_mask; /* Rings supported by the HW */
+	u16 num_samples_after_ctm;
+	u16 num_samples_before_ctm;
 	DEV_INFO_FOR_EACH_FLAG(DEFINE_FLAG, SEP_SEMICOLON);
 	/* Register offsets for the various display pipes and transcoders */
 	int pipe_offsets[I915_MAX_TRANSCODERS];
drivers/gpu/drm/i915/intel_color_manager.c +37 -0
index 7357d99..77f58f2 100644
@@ -27,7 +27,52 @@
 
 #include "intel_color_manager.h"
 
+int get_pipe_capabilities(struct drm_device *dev,
+		struct drm_palette_caps *palette_caps, struct drm_crtc *crtc)
+{
+	struct drm_property_blob *blob;
+
+	/*
+	 * This function loads best capability for gamma correction
+	 * For example:
+	 * CHV best Gamma correction (CGM unit, 10 bit)
+	 * has 257 entries, best degamma is 65 entries
+	 */
+	palette_caps->version = COLOR_STRUCT_VERSION;
+	palette_caps->num_samples_after_ctm =
+				INTEL_INFO(dev)->num_samples_after_ctm;
+	palette_caps->num_samples_before_ctm =
+				INTEL_INFO(dev)->num_samples_before_ctm;
+	blob = drm_property_create_blob(dev, sizeof(struct drm_palette_caps),
+			(const void *) palette_caps);
+	if (IS_ERR_OR_NULL(blob)) {
+		DRM_ERROR("Create blob for capabilities failed\n");
+		return PTR_ERR(blob);
+	}
+
+	return blob->base.id;
+}
+
 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;
+
+	crtc = obj_to_crtc(mode_obj);
+	palette_caps = kzalloc(sizeof(struct drm_palette_caps),
+			GFP_KERNEL);
+	capabilities_blob_id = get_pipe_capabilities(dev,
+						palette_caps, crtc);
+
Quoted 9 lines

drivers/gpu/drm/i915/intel_color_manager.c line 73

Quoted 4 lines
drivers/gpu/drm/i915/intel_color_manager.c +4 -0
+	if (config->cm_crtc_palette_capabilities_property) {
+		drm_object_attach_property(mode_obj,
+			config->cm_crtc_palette_capabilities_property,
+			capabilities_blob_id);

I didn't find any code to attach the before/after_ctm gamma properties and the ctm property. Also I think a small helper would be really nice here in the drm core:

Quoted 2 lines

Patch 15,16,17 adds those for gamma, degamma and CSC. This is just for the capabilities property.

Indeed, my mail search failed me.

Quoted 12 lines
Quoted 5 lines

drm_crtc_attach_cc_properties(struct drm_crtc *crtc,
int gamma_before_ctm, bool ctm,
int gamm_after_ctm)

Quoted 7 lines

And then that directly constructs the palette caps from the given values (if they're non-0) and also attaches the properties to the crtc (if they're non-0 for gamma, treu for the ctm).

If that attach_property code really isn't there I wonder a bit how this all works, we /should/ be filtering out properties which aren't attached to the object.

Quoted 9 lines

As I mentioned in the cover-letter, here is the sequence:
First 5 patches add color management support in DRM layer
Next 7 patches add Intel color management framework in I915 driver (This is still the framework part)
Next 5 patches add color correction for CHV (gamma, degamma and CSC) (Here comes the core property and enabling part)
Next 2 patches enable color management, by attaching the properties to
CRTC(Matt's comment on enable property code only when the job is done)
Next 4 patches add color correction for BDW (gamma, degamma)

Yeah I just missed this, no idea why the search in my mail client didn't turn up patches 15-17. I still think drm_crtc_attach_cc_properties in the drm core would be good, instead of splitting part of the color manager core support around the properties between the driver and core like you do here.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#34 lore raw

PATCH 10/23 drm/i915: Add gamma correction handlers

In reply to Shashank Sharma

I915 driver registers gamma correction as palette correction property with DRM layer. This patch adds set_property() and get_property() handlers for pipe level gamma correction.

The set function attaches the Gamma correction blob to CRTC state, these values will be committed during atomic commit.

---
 drivers/gpu/drm/i915/intel_atomic.c        | 20 ++++++++++++++++++++
 drivers/gpu/drm/i915/intel_color_manager.c | 21 +++++++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h           |  5 +++++
 3 files changed, 46 insertions(+)
drivers/gpu/drm/i915/intel_atomic.c +20 -0
index 500d2998..0b61fef 100644
@@ -315,6 +315,13 @@ int intel_crtc_atomic_set_property(struct drm_crtc *crtc,
 				   struct drm_property *property,
 				   uint64_t val)
 {
+	struct drm_device *dev = crtc->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+
+	if (property == config->cm_palette_after_ctm_property)
+		return intel_color_manager_set_pipe_gamma(dev, state,
+				&crtc->base, val);
+
 	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
 	return -EINVAL;
 }
@@ -324,6 +331,19 @@ int intel_crtc_atomic_get_property(struct drm_crtc *crtc,
 				   struct drm_property *property,
 				   uint64_t *val)
 {
+	struct drm_device *dev = crtc->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+
+	if (property == config->cm_palette_after_ctm_property) {
+		*val = (state->palette_after_ctm_blob) ?
+			state->palette_after_ctm_blob->base.id : 0;
+		goto found;
+	}
+
 	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
 	return -EINVAL;
+
+found:
+	DRM_DEBUG_KMS("Found property %s\n", property->name);
+	return 0;
 }
drivers/gpu/drm/i915/intel_color_manager.c +21 -0
index 77f58f2..9421bb6 100644
@@ -27,6 +27,27 @@
 
 #include "intel_color_manager.h"
 
+int intel_color_manager_set_pipe_gamma(struct drm_device *dev,
+		struct drm_crtc_state *crtc_state,
+		struct drm_mode_object *obj, uint32_t blob_id)
+{
+	struct drm_property_blob *blob;
+
+	blob = drm_property_lookup_blob(dev, blob_id);
+	if (!blob) {
+		DRM_DEBUG_KMS("Invalid Blob ID\n");
+		return -EINVAL;
+	}
+
+	if (crtc_state->palette_after_ctm_blob)
+		drm_property_unreference_blob(
+			crtc_state->palette_after_ctm_blob);
+
+	/* Attach the blob to be committed in state */
+	crtc_state->palette_after_ctm_blob = blob;
+	return 0;
+}
+
 int get_pipe_capabilities(struct drm_device *dev,
 		struct drm_palette_caps *palette_caps, struct drm_crtc *crtc)
 {
drivers/gpu/drm/i915/intel_drv.h +5 -0
index e27e754..d0193e2 100644
@@ -1466,4 +1466,9 @@ 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 */
+int intel_color_manager_set_pipe_gamma(struct drm_device *dev,
+		struct drm_crtc_state *crtc_state,
+		struct drm_mode_object *obj, uint32_t blob_id);
+
 #endif /* __INTEL_DRV_H__ */
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#35 lore raw

Re: [Intel-gfx] [PATCH 10/23] drm/i915: Add gamma correction handlers

Quoted 35 lines · Shashank Sharma

I915 driver registers gamma correction as palette correction property with DRM layer. This patch adds set_property() and get_property() handlers for pipe level gamma correction.

The set function attaches the Gamma correction blob to CRTC state, these values will be committed during atomic commit.

---
 drivers/gpu/drm/i915/intel_atomic.c        | 20 ++++++++++++++++++++
 drivers/gpu/drm/i915/intel_color_manager.c | 21 +++++++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h           |  5 +++++
 3 files changed, 46 insertions(+)
drivers/gpu/drm/i915/intel_atomic.c +7 -0
index 500d2998..0b61fef 100644
@@ -315,6 +315,13 @@ int intel_crtc_atomic_set_property(struct drm_crtc *crtc,
 				   struct drm_property *property,
 				   uint64_t val)
 {
+	struct drm_device *dev = crtc->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+
+	if (property == config->cm_palette_after_ctm_property)
+		return intel_color_manager_set_pipe_gamma(dev, state,
+				&crtc->base, val);
+
 	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
 	return -EINVAL;
 }
@@ -324,6 +331,19 @@ int intel_crtc_atomic_get_property(struct drm_crtc *crtc,
 				   struct drm_property *property,

drivers/gpu/drm/i915/intel_atomic.c int intel_crtc_atomic_get_property(struct drm_crtc *crtc, · line 341

Quoted 10 lines
drivers/gpu/drm/i915/intel_atomic.c +8 -0
 				   uint64_t *val)
 {
+	struct drm_device *dev = crtc->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+
+	if (property == config->cm_palette_after_ctm_property) {
+		*val = (state->palette_after_ctm_blob) ?
+			state->palette_after_ctm_blob->base.id : 0;
+		goto found;
+	}

Since color manager properties are meant as a new standardize KMS extension (we put them into the core drm_crtc_state) the get/set support should also be in the core. See e.g. how the rotation property is handled in drm_atomic_plane_get/set_property. So all this code should be added to drm_atomic_crtc_get/set_property.

Quoted 26 lines
drivers/gpu/drm/i915/intel_atomic.c +5 -0
+
 	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
 	return -EINVAL;
+
+found:
+	DRM_DEBUG_KMS("Found property %s\n", property->name);
+	return 0;
 }
drivers/gpu/drm/i915/intel_color_manager.c +10 -0
index 77f58f2..9421bb6 100644
@@ -27,6 +27,27 @@
 
 #include "intel_color_manager.h"
 
+int intel_color_manager_set_pipe_gamma(struct drm_device *dev,
+		struct drm_crtc_state *crtc_state,
+		struct drm_mode_object *obj, uint32_t blob_id)
+{
+	struct drm_property_blob *blob;
+
+	blob = drm_property_lookup_blob(dev, blob_id);
+	if (!blob) {
+		DRM_DEBUG_KMS("Invalid Blob ID\n");
+		return -EINVAL;

drivers/gpu/drm/i915/intel_color_manager.c line 49

Quoted 10 lines
drivers/gpu/drm/i915/intel_color_manager.c +10 -0
+	}
+
+	if (crtc_state->palette_after_ctm_blob)
+		drm_property_unreference_blob(
+			crtc_state->palette_after_ctm_blob);
+
+	/* Attach the blob to be committed in state */
+	crtc_state->palette_after_ctm_blob = blob;
+	return 0;
+}

What is this used for? It looks a bit like legacy property code, and we have a generic helper to make that happen (drm_atomic_helper_crtc_set_property).

Generally please don't add functions/structs without also adding a user, it means that reviewers have to constantly jump around in your patch series to figure out how something is used. Instead if you want to split things up really fine add a stub function frist (but including relevant callers) and then fill out the bits separately.
-Daniel

Quoted 25 lines
drivers/gpu/drm/i915/intel_color_manager.c +1 -0
+
 int get_pipe_capabilities(struct drm_device *dev,
 		struct drm_palette_caps *palette_caps, struct drm_crtc *crtc)
 {
drivers/gpu/drm/i915/intel_drv.h +5 -0
index e27e754..d0193e2 100644
@@ -1466,4 +1466,9 @@ 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 */
+int intel_color_manager_set_pipe_gamma(struct drm_device *dev,
+		struct drm_crtc_state *crtc_state,
+		struct drm_mode_object *obj, uint32_t blob_id);
+
 #endif /* __INTEL_DRV_H__ */
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#36 lore raw

Re: [PATCH 10/23] drm/i915: Add gamma correction handlers

Quoted 44 lines · Daniel Vetter
Quoted 43 lines · Shashank Sharma

I915 driver registers gamma correction as palette correction property with DRM layer. This patch adds set_property() and get_property() handlers for pipe level gamma correction.

The set function attaches the Gamma correction blob to CRTC state, these values will be committed during atomic commit.

---
 drivers/gpu/drm/i915/intel_atomic.c        | 20 ++++++++++++++++++++
 drivers/gpu/drm/i915/intel_color_manager.c | 21 +++++++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h           |  5 +++++
 3 files changed, 46 insertions(+)
drivers/gpu/drm/i915/intel_atomic.c +13 -0
index 500d2998..0b61fef 100644
@@ -315,6 +315,13 @@ int intel_crtc_atomic_set_property(struct drm_crtc *crtc,
 				   struct drm_property *property,
 				   uint64_t val)
 {
+	struct drm_device *dev = crtc->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+
+	if (property == config->cm_palette_after_ctm_property)
+		return intel_color_manager_set_pipe_gamma(dev, state,
+				&crtc->base, val);
+
 	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
 	return -EINVAL;
 }
@@ -324,6 +331,19 @@ int intel_crtc_atomic_get_property(struct drm_crtc *crtc,
 				   struct drm_property *property,
 				   uint64_t *val)
 {
+	struct drm_device *dev = crtc->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+
+	if (property == config->cm_palette_after_ctm_property) {
+		*val = (state->palette_after_ctm_blob) ?
+			state->palette_after_ctm_blob->base.id : 0;
Quoted 8 lines

drivers/gpu/drm/i915/intel_atomic.c int intel_crtc_atomic_get_property(struct drm_crtc *crtc, · line 341

Quoted 2 lines
drivers/gpu/drm/i915/intel_atomic.c +2 -0
+		goto found;
+	}

Since color manager properties are meant as a new standardize KMS extension (we put them into the core drm_crtc_state) the get/set support should also be in the core. See e.g. how the rotation property is handled in drm_atomic_plane_get/set_property. So all this code should be added to drm_atomic_crtc_get/set_property.

I've forgotten to explain how drivers can then opt-in KMS extensions if we have the decode support unconditionally there and also register the props
unconditionally: That's done by only attaching these standardized props to a crtc/plane if the corresponding object supports it.
-Daniel

Quoted 80 lines
Quoted 28 lines
drivers/gpu/drm/i915/intel_atomic.c +5 -0
+
 	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
 	return -EINVAL;
+
+found:
+	DRM_DEBUG_KMS("Found property %s\n", property->name);
+	return 0;
 }
drivers/gpu/drm/i915/intel_color_manager.c +10 -0
index 77f58f2..9421bb6 100644
@@ -27,6 +27,27 @@
 
 #include "intel_color_manager.h"
 
+int intel_color_manager_set_pipe_gamma(struct drm_device *dev,
+		struct drm_crtc_state *crtc_state,
+		struct drm_mode_object *obj, uint32_t blob_id)
+{
+	struct drm_property_blob *blob;
+
+	blob = drm_property_lookup_blob(dev, blob_id);
+	if (!blob) {
+		DRM_DEBUG_KMS("Invalid Blob ID\n");
+		return -EINVAL;

drivers/gpu/drm/i915/intel_color_manager.c line 49

Quoted 10 lines
drivers/gpu/drm/i915/intel_color_manager.c +10 -0
+	}
+
+	if (crtc_state->palette_after_ctm_blob)
+		drm_property_unreference_blob(
+			crtc_state->palette_after_ctm_blob);
+
+	/* Attach the blob to be committed in state */
+	crtc_state->palette_after_ctm_blob = blob;
+	return 0;
+}

What is this used for? It looks a bit like legacy property code, and we have a generic helper to make that happen (drm_atomic_helper_crtc_set_property).

Generally please don't add functions/structs without also adding a user, it means that reviewers have to constantly jump around in your patch series to figure out how something is used. Instead if you want to split things up really fine add a stub function frist (but including relevant callers) and then fill out the bits separately.
-Daniel

Quoted 25 lines
drivers/gpu/drm/i915/intel_color_manager.c +1 -0
+
 int get_pipe_capabilities(struct drm_device *dev,
 		struct drm_palette_caps *palette_caps, struct drm_crtc *crtc)
 {
drivers/gpu/drm/i915/intel_drv.h +5 -0
index e27e754..d0193e2 100644
@@ -1466,4 +1466,9 @@ 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 */
+int intel_color_manager_set_pipe_gamma(struct drm_device *dev,
+		struct drm_crtc_state *crtc_state,
+		struct drm_mode_object *obj, uint32_t blob_id);
+
 #endif /* __INTEL_DRV_H__ */
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#37 lore raw

Re: [Intel-gfx] [PATCH 10/23] drm/i915: Add gamma correction handlers

In reply to Daniel Vetter

Regards
Shashank

Quoted 44 lines · Daniel Vetter
Quoted 43 lines · Shashank Sharma

I915 driver registers gamma correction as palette correction property with DRM layer. This patch adds set_property() and get_property() handlers for pipe level gamma correction.

The set function attaches the Gamma correction blob to CRTC state, these values will be committed during atomic commit.

---
  drivers/gpu/drm/i915/intel_atomic.c        | 20 ++++++++++++++++++++
  drivers/gpu/drm/i915/intel_color_manager.c | 21 +++++++++++++++++++++
  drivers/gpu/drm/i915/intel_drv.h           |  5 +++++
  3 files changed, 46 insertions(+)
drivers/gpu/drm/i915/intel_atomic.c +13 -0
index 500d2998..0b61fef 100644
@@ -315,6 +315,13 @@ int intel_crtc_atomic_set_property(struct drm_crtc *crtc,
  				   struct drm_property *property,
  				   uint64_t val)
  {
+	struct drm_device *dev = crtc->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+
+	if (property == config->cm_palette_after_ctm_property)
+		return intel_color_manager_set_pipe_gamma(dev, state,
+				&crtc->base, val);
+
  	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
  	return -EINVAL;
  }
@@ -324,6 +331,19 @@ int intel_crtc_atomic_get_property(struct drm_crtc *crtc,
  				   struct drm_property *property,
  				   uint64_t *val)
  {
+	struct drm_device *dev = crtc->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+
+	if (property == config->cm_palette_after_ctm_property) {
+		*val = (state->palette_after_ctm_blob) ?
+			state->palette_after_ctm_blob->base.id : 0;
Quoted 8 lines

drivers/gpu/drm/i915/intel_atomic.c int intel_crtc_atomic_get_property(struct drm_crtc *crtc, · line 341

Quoted 2 lines
drivers/gpu/drm/i915/intel_atomic.c +2 -0
+		goto found;
+	}

Since color manager properties are meant as a new standardize KMS extension (we put them into the core drm_crtc_state) the get/set support should also be in the core. See e.g. how the rotation property is handled in drm_atomic_plane_get/set_property. So all this code should be added to drm_atomic_crtc_get/set_property.

Thanks, sounds like a good one. Will move this.

Quoted 34 lines
Quoted 34 lines
drivers/gpu/drm/i915/intel_atomic.c +5 -0
+
  	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
  	return -EINVAL;
+
+found:
+	DRM_DEBUG_KMS("Found property %s\n", property->name);
+	return 0;
  }
drivers/gpu/drm/i915/intel_color_manager.c +16 -0
index 77f58f2..9421bb6 100644
@@ -27,6 +27,27 @@
 
  #include "intel_color_manager.h"
 
+int intel_color_manager_set_pipe_gamma(struct drm_device *dev,
+		struct drm_crtc_state *crtc_state,
+		struct drm_mode_object *obj, uint32_t blob_id)
+{
+	struct drm_property_blob *blob;
+
+	blob = drm_property_lookup_blob(dev, blob_id);
+	if (!blob) {
+		DRM_DEBUG_KMS("Invalid Blob ID\n");
+		return -EINVAL;
+	}
+
+	if (crtc_state->palette_after_ctm_blob)
+		drm_property_unreference_blob(
+			crtc_state->palette_after_ctm_blob);
+
Quoted 9 lines

drivers/gpu/drm/i915/intel_color_manager.c line 49

Quoted 4 lines
drivers/gpu/drm/i915/intel_color_manager.c +4 -0
+	/* Attach the blob to be committed in state */
+	crtc_state->palette_after_ctm_blob = blob;
+	return 0;
+}

What is this used for? It looks a bit like legacy property code, and we have a generic helper to make that happen (drm_atomic_helper_crtc_set_property).

No Daniel, its not the legacy part. Please check atomic_begin() part in the next patches. This is like the top half of atomic set_property for CRTC and will be applicable for any property. As you already know, to set a property:
- userspace creates a blob, and sends the blob id via set_property() interface
- set_property() saves the blob_id in the corresponding pointer space in the crtc_state()
- From the atomic_commit_begin() we will extract the values from blob and start committing to the registers. Its kind of bottom_half() of atomic set_property for CRTC.

Quoted 5 lines

Generally please don't add functions/structs without also adding a user, it means that reviewers have to constantly jump around in your patch series to figure out how something is used. Instead if you want to split things up really fine add a stub function frist (but including relevant callers) and then fill out the bits separately.

I think the above explanation should make it clear.

Quoted 23 lines

-Daniel

Quoted 21 lines
drivers/gpu/drm/i915/intel_color_manager.c +1 -0
+
  int get_pipe_capabilities(struct drm_device *dev,
  		struct drm_palette_caps *palette_caps, struct drm_crtc *crtc)
  {
drivers/gpu/drm/i915/intel_drv.h +5 -1
index e27e754..d0193e2 100644
@@ -1466,4 +1466,9 @@ 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 */
+int intel_color_manager_set_pipe_gamma(struct drm_device *dev,
+		struct drm_crtc_state *crtc_state,
+		struct drm_mode_object *obj, uint32_t blob_id);
+
  #endif /* __INTEL_DRV_H__ */
--

1.9.1

Quoted 5 lines
Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#38 lore raw

Re: [PATCH 10/23] drm/i915: Add gamma correction handlers

Quoted 56 lines · Shashank

Regards
Shashank

Quoted 44 lines · Daniel Vetter
Quoted 43 lines · Shashank Sharma

I915 driver registers gamma correction as palette correction property with DRM layer. This patch adds set_property() and get_property() handlers for pipe level gamma correction.

The set function attaches the Gamma correction blob to CRTC state, these values will be committed during atomic commit.

---
 drivers/gpu/drm/i915/intel_atomic.c        | 20 ++++++++++++++++++++
 drivers/gpu/drm/i915/intel_color_manager.c | 21 +++++++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h           |  5 +++++
 3 files changed, 46 insertions(+)
drivers/gpu/drm/i915/intel_atomic.c +13 -0
index 500d2998..0b61fef 100644
@@ -315,6 +315,13 @@ int intel_crtc_atomic_set_property(struct drm_crtc *crtc,
 				   struct drm_property *property,
 				   uint64_t val)
 {
+	struct drm_device *dev = crtc->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+
+	if (property == config->cm_palette_after_ctm_property)
+		return intel_color_manager_set_pipe_gamma(dev, state,
+				&crtc->base, val);
+
 	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
 	return -EINVAL;
 }
@@ -324,6 +331,19 @@ int intel_crtc_atomic_get_property(struct drm_crtc *crtc,
 				   struct drm_property *property,
 				   uint64_t *val)
 {
+	struct drm_device *dev = crtc->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+
+	if (property == config->cm_palette_after_ctm_property) {
+		*val = (state->palette_after_ctm_blob) ?
+			state->palette_after_ctm_blob->base.id : 0;
Quoted 8 lines

drivers/gpu/drm/i915/intel_atomic.c int intel_crtc_atomic_get_property(struct drm_crtc *crtc, · line 341

Quoted 2 lines
drivers/gpu/drm/i915/intel_atomic.c +2 -0
+		goto found;
+	}

Since color manager properties are meant as a new standardize KMS extension (we put them into the core drm_crtc_state) the get/set support should also be in the core. See e.g. how the rotation property is handled in drm_atomic_plane_get/set_property. So all this code should be added to drm_atomic_crtc_get/set_property.

Quoted 1 line

Thanks, sounds like a good one. Will move this.

When moving this please don't forget to add the blob->length sanity checks mentioned in another thread in this discussion.

Quoted 53 lines
Quoted 34 lines
Quoted 34 lines
drivers/gpu/drm/i915/intel_atomic.c +5 -0
+
 	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
 	return -EINVAL;
+
+found:
+	DRM_DEBUG_KMS("Found property %s\n", property->name);
+	return 0;
 }
drivers/gpu/drm/i915/intel_color_manager.c +16 -0
index 77f58f2..9421bb6 100644
@@ -27,6 +27,27 @@
 
 #include "intel_color_manager.h"
 
+int intel_color_manager_set_pipe_gamma(struct drm_device *dev,
+		struct drm_crtc_state *crtc_state,
+		struct drm_mode_object *obj, uint32_t blob_id)
+{
+	struct drm_property_blob *blob;
+
+	blob = drm_property_lookup_blob(dev, blob_id);
+	if (!blob) {
+		DRM_DEBUG_KMS("Invalid Blob ID\n");
+		return -EINVAL;
+	}
+
+	if (crtc_state->palette_after_ctm_blob)
+		drm_property_unreference_blob(
+			crtc_state->palette_after_ctm_blob);
+
Quoted 9 lines

drivers/gpu/drm/i915/intel_color_manager.c line 49

Quoted 4 lines
drivers/gpu/drm/i915/intel_color_manager.c +4 -0
+	/* Attach the blob to be committed in state */
+	crtc_state->palette_after_ctm_blob = blob;
+	return 0;
+}

What is this used for? It looks a bit like legacy property code, and we have a generic helper to make that happen (drm_atomic_helper_crtc_set_property).

No Daniel, its not the legacy part. Please check atomic_begin() part in the next patches. This is like the top half of atomic set_property for CRTC and will be applicable for any property. As you already know, to set a property:
- userspace creates a blob, and sends the blob id via set_property() interface
- set_property() saves the blob_id in the corresponding pointer space in the crtc_state()
- From the atomic_commit_begin() we will extract the values from blob and start committing to the registers. Its kind of bottom_half() of atomic set_property for CRTC.

Quoted 6 lines
Quoted 5 lines

Generally please don't add functions/structs without also adding a user, it means that reviewers have to constantly jump around in your patch series to figure out how something is used. Instead if you want to split things up really fine add a stub function frist (but including relevant callers) and then fill out the bits separately.

I think the above explanation should make it clear.

In my defence I'd like to say that I was still jetlagged ;-) Reading things now again it all looks good.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#39 lore raw

Re: [PATCH 10/23] drm/i915: Add gamma correction handlers

In reply to Sharma, Shashank
Quoted 6 lines · Shashank
Quoted 5 lines

Since color manager properties are meant as a new standardize KMS extension (we put them into the core drm_crtc_state) the get/set support should also be in the core. See e.g. how the rotation property is handled in drm_atomic_plane_get/set_property. So all this code should be added to drm_atomic_crtc_get/set_property.

Thanks, sounds like a good one. Will move this.

Actually, while implementing this, I realized that this change is not required. What we want to do in drm_atomic_crtc_get/set code is:
if (prop == config->cm_palette_after_ctm_property || prop ==

	config->cm_palette_before_ctm_property) {
	crtc->funcs->atomic_get_property();
}

Which is already being done in the current code:
else if (crtc->funcs->atomic_get_property)

	return crtc->funcs->atomic_get_property(crtc, state, property, val);

so I dont really think we need this change.

Regards
Shashank

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#40 lore raw

Re: [Intel-gfx] [PATCH 10/23] drm/i915: Add gamma correction handlers

Quoted 11 lines · Shashank
Quoted 6 lines · Shashank
Quoted 5 lines

Since color manager properties are meant as a new standardize KMS extension (we put them into the core drm_crtc_state) the get/set support should also be in the core. See e.g. how the rotation property is handled in drm_atomic_plane_get/set_property. So all this code should be added to drm_atomic_crtc_get/set_property.

Thanks, sounds like a good one. Will move this.

Actually, while implementing this, I realized that this change is not required.
What we want to do in drm_atomic_crtc_get/set code is:
if (prop == config->cm_palette_after_ctm_property || prop ==

Quoted 7 lines
	config->cm_palette_before_ctm_property) {
	crtc->funcs->atomic_get_property();
}

Which is already being done in the current code:
else if (crtc->funcs->atomic_get_property)

	return crtc->funcs->atomic_get_property(crtc, state, property, val);

This code is to pass any property unknown to the drm core into the driver. But since we want this to be a new drm core property set (that's why it's in drm_crtc_state) the decoding should be done in the core too.

Note that atomic_get/set_property _only_ map between the property as seen by userspace and the state structures. They're not allowed to do anything else like compute derived state, check constraints or put the state into the hw. That's for the atomic_check and atomic_commit callbacks. So for this patchset here you should move all the code in the atomic_get/set_property callbacks you add in i915 into the drm core. Like it is doen for the rotation property.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#41 lore raw

RE: [Intel-gfx] [PATCH 10/23] drm/i915: Add gamma correction handlers

Matt, your opinion about this ?

Regards
Shashank
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, September 28, 2015 12:14 PM
To: Sharma, Shashank
Cc: Daniel Vetter; Roper, Matthew D; Bish, Jim; Bradford, Robert; Smith, Gary K; [email protected]; [email protected]; Matheson, Annie J; [email protected]; Vetter, Daniel
Subject: Re: [Intel-gfx] [PATCH 10/23] drm/i915: Add gamma correction handlers

Quoted 11 lines · Shashank
Quoted 6 lines · Shashank
Quoted 5 lines

Since color manager properties are meant as a new standardize KMS extension (we put them into the core drm_crtc_state) the get/set support should also be in the core. See e.g. how the rotation property is handled in drm_atomic_plane_get/set_property. So all this code should be added to drm_atomic_crtc_get/set_property.

Thanks, sounds like a good one. Will move this.

Actually, while implementing this, I realized that this change is not required.
What we want to do in drm_atomic_crtc_get/set code is:
if (prop == config->cm_palette_after_ctm_property || prop ==

Quoted 7 lines
	config->cm_palette_before_ctm_property) {
	crtc->funcs->atomic_get_property();
}

Which is already being done in the current code:
else if (crtc->funcs->atomic_get_property)

	return crtc->funcs->atomic_get_property(crtc, state, property, val);

This code is to pass any property unknown to the drm core into the driver.
But since we want this to be a new drm core property set (that's why it's in drm_crtc_state) the decoding should be done in the core too.

Note that atomic_get/set_property _only_ map between the property as seen by userspace and the state structures. They're not allowed to do anything else like compute derived state, check constraints or put the state into the hw. That's for the atomic_check and atomic_commit callbacks. So for this patchset here you should move all the code in the atomic_get/set_property callbacks you add in i915 into the drm core. Like it is doen for the rotation property. -Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#42 lore raw

Re: [Intel-gfx] [PATCH 10/23] drm/i915: Add gamma correction handlers

Yep, Daniel's right; for properties that are not specific to the driver, the core core should take care of stuffing the values provided by userspace into the state structures so that every driver that wants to use these doesn't need to replicate that logic. My bad for not catching this in my earlier reviews; sorry about that. Basically the change required is to add another else clause to drm_atomic_crtc_{get,set}_property(), before the core tries to call into the driver-specific handler. You'll notice that what you're doing with color management blobs here is actually very similar to what's already done for the existing mode blob, so you can take a look at that case for an example.

Also, the functions like intel_color_manager_set_pipe_gamma() will get moved into the DRM core and the "intel_" prefix will switch to "drm_" since there's really nothing Intel-specific about what they're doing.

Sorry again for not noticing this and bringing it up on the earlier reviews. Fortunately the changes required should be pretty small.

Matt

Quoted 40 lines · Shashank

Matt, your opinion about this ?

Regards
Shashank
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, September 28, 2015 12:14 PM
To: Sharma, Shashank
Cc: Daniel Vetter; Roper, Matthew D; Bish, Jim; Bradford, Robert; Smith, Gary K; [email protected]; [email protected]; Matheson, Annie J; [email protected]; Vetter, Daniel
Subject: Re: [Intel-gfx] [PATCH 10/23] drm/i915: Add gamma correction handlers

Quoted 11 lines · Shashank
Quoted 6 lines · Shashank
Quoted 5 lines

Since color manager properties are meant as a new standardize KMS extension (we put them into the core drm_crtc_state) the get/set support should also be in the core. See e.g. how the rotation property is handled in drm_atomic_plane_get/set_property. So all this code should be added to drm_atomic_crtc_get/set_property.

Thanks, sounds like a good one. Will move this.

Actually, while implementing this, I realized that this change is not required.
What we want to do in drm_atomic_crtc_get/set code is:
if (prop == config->cm_palette_after_ctm_property || prop ==

Quoted 7 lines
	config->cm_palette_before_ctm_property) {
	crtc->funcs->atomic_get_property();
}

Which is already being done in the current code:
else if (crtc->funcs->atomic_get_property)

	return crtc->funcs->atomic_get_property(crtc, state, property, val);

This code is to pass any property unknown to the drm core into the driver.
But since we want this to be a new drm core property set (that's why it's in drm_crtc_state) the decoding should be done in the core too.

Note that atomic_get/set_property _only_ map between the property as seen by userspace and the state structures. They're not allowed to do anything else like compute derived state, check constraints or put the state into the hw. That's for the atomic_check and atomic_commit callbacks. So for this patchset here you should move all the code in the atomic_get/set_property callbacks you add in i915 into the drm core. Like it is doen for the rotation property. -Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Signature · 9 lines
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#43 lore raw

RE: [Intel-gfx] [PATCH 10/23] drm/i915: Add gamma correction handlers

Ok, anyways it was sounding like a good idea.
Will do the changes accordingly.

Regards
Shashank
-----Original Message-----
From: Roper, Matthew D
Sent: Tuesday, September 29, 2015 3:13 AM
To: Sharma, Shashank
Cc: Daniel Vetter; Bish, Jim; Bradford, Robert; Smith, Gary K; [email protected]; [email protected]; Matheson, Annie J; [email protected]; Vetter, Daniel
Subject: Re: [Intel-gfx] [PATCH 10/23] drm/i915: Add gamma correction handlers

Yep, Daniel's right; for properties that are not specific to the driver, the core core should take care of stuffing the values provided by userspace into the state structures so that every driver that wants to use these doesn't need to replicate that logic. My bad for not catching this in my earlier reviews; sorry about that. Basically the change required is to add another else clause to drm_atomic_crtc_{get,set}_property(), before the core tries to call into the driver-specific handler. You'll notice that what you're doing with color management blobs here is actually very similar to what's already done for the existing mode blob, so you can take a look at that case for an example.

Also, the functions like intel_color_manager_set_pipe_gamma() will get moved into the DRM core and the "intel_" prefix will switch to "drm_" since there's really nothing Intel-specific about what they're doing.

Sorry again for not noticing this and bringing it up on the earlier reviews. Fortunately the changes required should be pretty small.

Matt

Quoted 40 lines · Shashank

Matt, your opinion about this ?

Regards
Shashank
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, September 28, 2015 12:14 PM
To: Sharma, Shashank
Cc: Daniel Vetter; Roper, Matthew D; Bish, Jim; Bradford, Robert; Smith, Gary K; [email protected]; [email protected]; Matheson, Annie J; [email protected]; Vetter, Daniel
Subject: Re: [Intel-gfx] [PATCH 10/23] drm/i915: Add gamma correction handlers

Quoted 11 lines · Shashank
Quoted 6 lines · Shashank
Quoted 5 lines

Since color manager properties are meant as a new standardize KMS extension (we put them into the core drm_crtc_state) the get/set support should also be in the core. See e.g. how the rotation property is handled in drm_atomic_plane_get/set_property. So all this code should be added to drm_atomic_crtc_get/set_property.

Thanks, sounds like a good one. Will move this.

Actually, while implementing this, I realized that this change is not required.
What we want to do in drm_atomic_crtc_get/set code is:
if (prop == config->cm_palette_after_ctm_property || prop ==

Quoted 8 lines
	config->cm_palette_before_ctm_property) {
	crtc->funcs->atomic_get_property();
}

Which is already being done in the current code:
else if (crtc->funcs->atomic_get_property)

	return crtc->funcs->atomic_get_property(crtc, state, property, 

val);

This code is to pass any property unknown to the drm core into the driver.
But since we want this to be a new drm core property set (that's why it's in drm_crtc_state) the decoding should be done in the core too.

Quoted 6 lines

Note that atomic_get/set_property _only_ map between the property as seen by userspace and the state structures. They're not allowed to do anything else like compute derived state, check constraints or put the state into the hw. That's for the atomic_check and atomic_commit callbacks. So for this patchset here you should move all the code in the atomic_get/set_property callbacks you add in i915 into the drm core. Like it is doen for the rotation property. -Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

--
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#44 lore raw

Re: [PATCH 10/23] drm/i915: Add gamma correction handlers

Thank you Shashank!

Annie Matheson

Quoted 72 lines · Shashank

Ok, anyways it was sounding like a good idea.
Will do the changes accordingly.

Regards
Shashank
-----Original Message-----
From: Roper, Matthew D
Sent: Tuesday, September 29, 2015 3:13 AM
To: Sharma, Shashank
Cc: Daniel Vetter; Bish, Jim; Bradford, Robert; Smith, Gary K; [email protected]; [email protected]; Matheson, Annie J; [email protected]; Vetter, Daniel
Subject: Re: [Intel-gfx] [PATCH 10/23] drm/i915: Add gamma correction handlers

Yep, Daniel's right; for properties that are not specific to the driver, the core core should take care of stuffing the values provided by userspace into the state structures so that every driver that wants to use these doesn't need to replicate that logic. My bad for not catching this in my earlier reviews; sorry about that. Basically the change required is to add another else clause to drm_atomic_crtc_{get,set}_property(), before the core tries to call into the driver-specific handler. You'll notice that what you're doing with color management blobs here is actually very similar to what's already done for the existing mode blob, so you can take a look at that case for an example.

Also, the functions like intel_color_manager_set_pipe_gamma() will get moved into the DRM core and the "intel_" prefix will switch to "drm_" since there's really nothing Intel-specific about what they're doing.

Sorry again for not noticing this and bringing it up on the earlier reviews. Fortunately the changes required should be pretty small.

Matt

Quoted 41 lines · Shashank

Matt, your opinion about this ?

Regards
Shashank
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, September 28, 2015 12:14 PM
To: Sharma, Shashank
Cc: Daniel Vetter; Roper, Matthew D; Bish, Jim; Bradford, Robert; Smith, Gary K; [email protected]; [email protected]; Matheson, Annie J; [email protected]; Vetter, Daniel
Subject: Re: [Intel-gfx] [PATCH 10/23] drm/i915: Add gamma correction handlers

Quoted 12 lines · Shashank
Quoted 6 lines · Shashank
Quoted 5 lines

Since color manager properties are meant as a new standardize KMS extension (we put them into the core drm_crtc_state) the get/set support should also be in the core. See e.g. how the rotation property is handled in drm_atomic_plane_get/set_property. So all this code should be added to drm_atomic_crtc_get/set_property.

Thanks, sounds like a good one. Will move this.

Actually, while implementing this, I realized that this change is not required.
What we want to do in drm_atomic_crtc_get/set code is:
if (prop == config->cm_palette_after_ctm_property || prop ==

Quoted 8 lines
   config->cm_palette_before_ctm_property) {
   crtc->funcs->atomic_get_property();
}

Which is already being done in the current code:
else if (crtc->funcs->atomic_get_property)
return crtc->funcs->atomic_get_property(crtc, state, property,
val);

This code is to pass any property unknown to the drm core into the driver.
But since we want this to be a new drm core property set (that's why it's in drm_crtc_state) the decoding should be done in the core too.

Quoted 6 lines

Note that atomic_get/set_property _only_ map between the property as seen by userspace and the state structures. They're not allowed to do anything else like compute derived state, check constraints or put the state into the hw. That's for the atomic_check and atomic_commit callbacks. So for this patchset here you should move all the code in the atomic_get/set_property callbacks you add in i915 into the drm core. Like it is doen for the rotation property. -Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Quoted 6 lines

--
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#45 lore raw

PATCH 11/23 drm/i915: Add pipe deGamma correction handlers

In reply to Shashank Sharma

This patch adds set_property and get_property handlers for deGamma color correction capability at Pipe level.

Set function just attaches the deGamma correction blob to CRTC state, which will be later committed in the atomic commit path.

---
 drivers/gpu/drm/i915/intel_atomic.c        | 10 ++++++++++
 drivers/gpu/drm/i915/intel_color_manager.c | 20 ++++++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h           |  4 +++-
 3 files changed, 33 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_atomic.c +10 -0
index 0b61fef..b504b4f 100644
@@ -322,6 +322,10 @@ int intel_crtc_atomic_set_property(struct drm_crtc *crtc,
 		return intel_color_manager_set_pipe_gamma(dev, state,
 				&crtc->base, val);
 
+	if (property == config->cm_palette_before_ctm_property)
+		return intel_color_manager_set_pipe_degamma(dev, state,
+				&crtc->base, val);
+
 	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
 	return -EINVAL;
 }
@@ -340,6 +344,12 @@ int intel_crtc_atomic_get_property(struct drm_crtc *crtc,
 		goto found;
 	}
 
+	if (property == config->cm_palette_before_ctm_property) {
+		*val = (state->palette_before_ctm_blob) ?
+			state->palette_before_ctm_blob->base.id : 0;
+		goto found;
+	}
+
 	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
 	return -EINVAL;
 
drivers/gpu/drm/i915/intel_color_manager.c +20 -0
index 9421bb6..8890b09 100644
@@ -27,6 +27,26 @@
 
 #include "intel_color_manager.h"
 
+int intel_color_manager_set_pipe_degamma(struct drm_device *dev,
+		struct drm_crtc_state *crtc_state,
+		struct drm_mode_object *obj, uint32_t blob_id)
+{
+	struct drm_property_blob *blob;
+
+	blob = drm_property_lookup_blob(dev, blob_id);
+	if (!blob) {
+		DRM_ERROR("Invalid Blob ID\n");
+		return -EINVAL;
+	}
+
+	if (crtc_state->palette_before_ctm_blob)
+		drm_property_unreference_blob(
+			crtc_state->palette_before_ctm_blob);
+
+	crtc_state->palette_before_ctm_blob = blob;
+	return 0;
+}
+
 int intel_color_manager_set_pipe_gamma(struct drm_device *dev,
 		struct drm_crtc_state *crtc_state,
 		struct drm_mode_object *obj, uint32_t blob_id)
drivers/gpu/drm/i915/intel_drv.h +3 -1
index d0193e2..0298dd0 100644
@@ -1470,5 +1470,7 @@ extern const struct drm_plane_helper_funcs intel_plane_helper_funcs;
 int intel_color_manager_set_pipe_gamma(struct drm_device *dev,
 		struct drm_crtc_state *crtc_state,
 		struct drm_mode_object *obj, uint32_t blob_id);
-
+int intel_color_manager_set_pipe_degamma(struct drm_device *dev,
+		struct drm_crtc_state *crtc_state,
+		struct drm_mode_object *obj, uint32_t blob_id);
 #endif /* __INTEL_DRV_H__ */
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#46 lore raw

PATCH 12/23 drm/i915: Add pipe CSC correction handlers

In reply to Shashank Sharma

This patch adds set_property and get_property handlers for pipe level CSC color correction for CHV/BSW platform. The set function just attaches the CSC blob to CRTC state, that later gets committed using atomic path.

---
 drivers/gpu/drm/i915/intel_atomic.c        |  8 ++++++++
 drivers/gpu/drm/i915/intel_color_manager.c | 19 +++++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h           |  3 +++
 3 files changed, 30 insertions(+)
drivers/gpu/drm/i915/intel_atomic.c +8 -0
index b504b4f..57eafca 100644
@@ -325,6 +325,9 @@ int intel_crtc_atomic_set_property(struct drm_crtc *crtc,
 	if (property == config->cm_palette_before_ctm_property)
 		return intel_color_manager_set_pipe_degamma(dev, state,
 				&crtc->base, val);
+	if (property == config->cm_ctm_property)
+		return intel_color_manager_set_pipe_csc(dev, state,
+				&crtc->base, val);
 
 	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
 	return -EINVAL;
@@ -350,6 +353,11 @@ int intel_crtc_atomic_get_property(struct drm_crtc *crtc,
 		goto found;
 	}
 
+	if (property == config->cm_ctm_property) {
+		*val = (state->ctm_blob) ? state->ctm_blob->base.id : 0;
+		goto found;
+	}
+
 	DRM_DEBUG_KMS("Unknown crtc property '%s'\n", property->name);
 	return -EINVAL;
 
drivers/gpu/drm/i915/intel_color_manager.c +19 -0
index 8890b09..2ba3fd7 100644
@@ -27,6 +27,25 @@
 
 #include "intel_color_manager.h"
 
+int intel_color_manager_set_pipe_csc(struct drm_device *dev,
+		struct drm_crtc_state *crtc_state,
+		struct drm_mode_object *obj, uint32_t blob_id)
+{
+	struct drm_property_blob *blob;
+
+	blob = drm_property_lookup_blob(dev, blob_id);
+	if (!blob) {
+		DRM_ERROR("Invalid Blob ID\n");
+		return -EINVAL;
+	}
+
+	if (crtc_state->ctm_blob)
+		drm_property_unreference_blob(crtc_state->ctm_blob);
+
+	crtc_state->ctm_blob = blob;
+	return 0;
+}
+
 int intel_color_manager_set_pipe_degamma(struct drm_device *dev,
 		struct drm_crtc_state *crtc_state,
 		struct drm_mode_object *obj, uint32_t blob_id)
drivers/gpu/drm/i915/intel_drv.h +3 -0
index 0298dd0..4d571a2f 100644
@@ -1473,4 +1473,7 @@ int intel_color_manager_set_pipe_gamma(struct drm_device *dev,
 int intel_color_manager_set_pipe_degamma(struct drm_device *dev,
 		struct drm_crtc_state *crtc_state,
 		struct drm_mode_object *obj, uint32_t blob_id);
+int intel_color_manager_set_pipe_csc(struct drm_device *dev,
+		struct drm_crtc_state *crtc_state,
+		struct drm_mode_object *obj, uint32_t blob_id);
 #endif /* __INTEL_DRV_H__ */
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#47 lore raw

PATCH 13/23 drm/i915: CHV: Load gamma color correction values

In reply to Shashank Sharma

DRM color manager allows the driver to showcase its best color correction capabilities using the cm_crtc_palette_capabilities_property. Driver loads the no. of coefficients for various color correction as per the platform, during the init time.

This patch adds no of coefficitents for best gamma color correction modes possible in CHV, in device info structure, which is:
Gamma(10 bit, CGM HW unit):- 257 coeff
These values will be loaded in cm_crtc_palette_capabilities_property during the CRTC init section, by color manager's attach function.

---
 drivers/gpu/drm/i915/i915_drv.c            | 2 ++
 drivers/gpu/drm/i915/intel_color_manager.h | 1 +
 2 files changed, 3 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
index bdec64c..04a8e45 100644
@@ -34,6 +34,7 @@
 #include "i915_drv.h"
 #include "i915_trace.h"
 #include "intel_drv.h"
+#include "intel_color_manager.h"
 
 #include <linux/console.h>
 #include <linux/module.h>
@@ -349,6 +350,7 @@ static const struct intel_device_info intel_cherryview_info = {
 	.gen = 8, .num_pipes = 3,
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
+	.num_samples_after_ctm = CHV_10BIT_GAMMA_MAX_VALS,
 	.is_valleyview = 1,
 	.display_mmio_offset = VLV_DISPLAY_BASE,
 	GEN_CHV_PIPEOFFSETS,
drivers/gpu/drm/i915/intel_color_manager.h +1 -0
index 1a42244..99ef646 100644
@@ -29,3 +29,4 @@
 #include "i915_drv.h"
 
 #define COLOR_STRUCT_VERSION			1
+#define CHV_10BIT_GAMMA_MAX_VALS		257
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#48 lore raw

PATCH 14/23 drm/i915: CHV: Load degamma color correction values

In reply to Shashank Sharma

DRM color manager allows the driver to showcase its best color correction capabilities using the cm_crtc_palette_capabilities_property.

This patch adds no of coefficitents for degamma color correction modes possible in CHV, in device info structure, which is:
CGM Degamma(10 bit, CGM HW unit):- 65 coeff

These values will be loaded in cm_crtc_palette_capabilities_property during the CRTC init section, by color manager's attach function.

---
 drivers/gpu/drm/i915/i915_drv.c            | 1 +
 drivers/gpu/drm/i915/intel_color_manager.h | 1 +
 2 files changed, 2 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +1 -0
index 04a8e45..03db841 100644
@@ -351,6 +351,7 @@ static const struct intel_device_info intel_cherryview_info = {
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
 	.num_samples_after_ctm = CHV_10BIT_GAMMA_MAX_VALS,
+	.num_samples_before_ctm = CHV_DEGAMMA_MAX_VALS,
 	.is_valleyview = 1,
 	.display_mmio_offset = VLV_DISPLAY_BASE,
 	GEN_CHV_PIPEOFFSETS,
drivers/gpu/drm/i915/intel_color_manager.h +1 -0
index 99ef646..402b825 100644
@@ -30,3 +30,4 @@
 
 #define COLOR_STRUCT_VERSION			1
 #define CHV_10BIT_GAMMA_MAX_VALS		257
+#define CHV_DEGAMMA_MAX_VALS			65
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#49 lore raw

PATCH 15/23 drm/i915: CHV: Pipe level Gamma correction

In reply to Shashank Sharma

From: Kausal Malladi <[email protected]>

CHV/BSW platform supports two different pipe level gamma correction modes, which are:
1. Legacy 8-bit mode
2. 10-bit CGM (Color Gamut Mapping) mode

This patch does the following:
1. Attaches Gamma property to CRTC
3. Adds the core Gamma correction function for CHV/BSW
4. Adds Gamma correction macros

---
 drivers/gpu/drm/i915/i915_reg.h            |  12 +++
 drivers/gpu/drm/i915/intel_color_manager.c | 127 +++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_color_manager.h |  21 +++++
 3 files changed, 160 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +12 -0
index 67bf205..93aa1f9 100644
@@ -7977,4 +7977,16 @@ enum skl_disp_power_wells {
 #define GEN9_VEBOX_MOCS_0	0xcb00	/* Video MOCS base register*/
 #define GEN9_BLT_MOCS_0		0xcc00	/* Blitter MOCS base register*/
 
+/* Color Management */
+#define PIPEA_CGM_CONTROL			(VLV_DISPLAY_BASE + 0x67A00)
+#define PIPEB_CGM_CONTROL			(VLV_DISPLAY_BASE + 0x69A00)
+#define PIPEC_CGM_CONTROL			(VLV_DISPLAY_BASE + 0x6BA00)
+#define PIPEA_CGM_GAMMA			(VLV_DISPLAY_BASE + 0x67000)
+#define PIPEB_CGM_GAMMA			(VLV_DISPLAY_BASE + 0x69000)
+#define PIPEC_CGM_GAMMA			(VLV_DISPLAY_BASE + 0x6B000)
+#define _PIPE_CGM_CONTROL(pipe) \
+	(_PIPE3(pipe, PIPEA_CGM_CONTROL, PIPEB_CGM_CONTROL, PIPEC_CGM_CONTROL))
+#define _PIPE_GAMMA_BASE(pipe) \
+	(_PIPE3(pipe, PIPEA_CGM_GAMMA, PIPEB_CGM_GAMMA, PIPEC_CGM_GAMMA))
+
 #endif /* _I915_REG_H_ */
drivers/gpu/drm/i915/intel_color_manager.c +127 -0

138 lines not on this page · raw message

drivers/gpu/drm/i915/intel_color_manager.h +21 -0
index 402b825..5f800c9 100644
@@ -28,6 +28,27 @@
 #include <drm/drm_crtc_helper.h>
 #include "i915_drv.h"
 
+#define _GAMMA_INT_PART(value)			(value >> GAMMA_INT_SHIFT)
+#define _GAMMA_FRACT_PART(value)		(value >> GAMMA_FRACT_SHIFT)
+
 #define COLOR_STRUCT_VERSION			1
 #define CHV_10BIT_GAMMA_MAX_VALS		257
 #define CHV_DEGAMMA_MAX_VALS			65
+
+/* Gamma correction */
+#define GAMMA_DATA_STRUCT_VERSION		1
+#define CHV_10BIT_GAMMA_MAX_VALS		257
+#define CHV_8BIT_GAMMA_MAX_VALS		256
+#define CHV_10BIT_GAMMA_MSB_SHIFT		6
+#define CHV_GAMMA_SHIFT_GREEN			16
+
+/* Gamma values are u8.24 format */
+#define GAMMA_INT_SHIFT			24
+#define GAMMA_FRACT_SHIFT			8
+/* Max int value for Gamma is 1 */
+#define GAMMA_INT_MAX				1
+/* Max value for Gamma on CHV */
+#define CHV_MAX_GAMMA				0x10000
+
+/* CHV CGM Block */
+#define CGM_GAMMA_EN				(1 << 2)
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#50 lore raw

PATCH 16/23 drm/i915: CHV: Pipe level degamma correction

In reply to Shashank Sharma

CHV/BSW supports DeGamma color correction, which linearizes all the non-linear color values. This will be applied before Color Transformation.

This patch does the following:
1. Attach deGamma property to CRTC
2. Add the core function to program DeGamma correction values for CHV/BSW platform
2. Add DeGamma correction macros/defines

---
 drivers/gpu/drm/i915/i915_reg.h            |   6 ++
 drivers/gpu/drm/i915/intel_color_manager.c | 111 +++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_color_manager.h |   6 ++
 3 files changed, 123 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +6 -0
index 93aa1f9..3dde6a8 100644
@@ -7989,4 +7989,10 @@ enum skl_disp_power_wells {
 #define _PIPE_GAMMA_BASE(pipe) \
 	(_PIPE3(pipe, PIPEA_CGM_GAMMA, PIPEB_CGM_GAMMA, PIPEC_CGM_GAMMA))
 
+#define PIPEA_CGM_DEGAMMA                      (VLV_DISPLAY_BASE + 0x66000)
+#define PIPEB_CGM_DEGAMMA                      (VLV_DISPLAY_BASE + 0x68000)
+#define PIPEC_CGM_DEGAMMA                      (VLV_DISPLAY_BASE + 0x6A000)
+#define _PIPE_DEGAMMA_BASE(pipe) \
+	(_PIPE3(pipe, PIPEA_CGM_DEGAMMA, PIPEB_CGM_DEGAMMA, PIPEC_CGM_DEGAMMA))
+
 #endif /* _I915_REG_H_ */
drivers/gpu/drm/i915/intel_color_manager.c +111 -0

122 lines not on this page · raw message

drivers/gpu/drm/i915/intel_color_manager.h +6 -0
index 5f800c9..5eaa0f3 100644
@@ -50,5 +50,11 @@
 /* Max value for Gamma on CHV */
 #define CHV_MAX_GAMMA				0x10000
 
+/* DeGamma correction */
+#define DEGAMMA_DATA_STRUCT_VERSION        1
+#define CHV_DEGAMMA_MSB_SHIFT                  2
+#define CHV_DEGAMMA_GREEN_SHIFT                16
+
 /* CHV CGM Block */
 #define CGM_GAMMA_EN				(1 << 2)
+#define CGM_DEGAMMA_EN                         (1 << 0)
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#51 lore raw

PATCH 17/23 drm/i915: CHV: Pipe level CSC correction

In reply to Shashank Sharma

CHV/BSW supports Color Space Conversion (CSC) using a 3x3 matrix that needs to be programmed into CGM (Color Gamut Mapping) registers.

This patch does the following:
1. Attaches CSC property to CRTC
2. Adds the core function to program CSC correction values
3. Adds CSC correction macros

---
 drivers/gpu/drm/i915/i915_reg.h            |  8 +++
 drivers/gpu/drm/i915/intel_color_manager.c | 99 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_color_manager.h | 20 ++++++
 3 files changed, 127 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +8 -0
index 3dde6a8..5c7759d 100644
@@ -7995,4 +7995,12 @@ enum skl_disp_power_wells {
 #define _PIPE_DEGAMMA_BASE(pipe) \
 	(_PIPE3(pipe, PIPEA_CGM_DEGAMMA, PIPEB_CGM_DEGAMMA, PIPEC_CGM_DEGAMMA))
 
+#define PIPEA_CGM_CSC				(VLV_DISPLAY_BASE + 0x67900)
+#define PIPEB_CGM_CSC				(VLV_DISPLAY_BASE + 0x69900)
+#define PIPEC_CGM_CSC				(VLV_DISPLAY_BASE + 0x6B900)
+#define _PIPE_CSC_BASE(pipe) \
+	(_PIPE3(pipe, PIPEA_CGM_CSC, PIPEB_CGM_CSC, PIPEC_CGM_CSC))
+
+
+
 #endif /* _I915_REG_H_ */
drivers/gpu/drm/i915/intel_color_manager.c +99 -0

110 lines not on this page · raw message

drivers/gpu/drm/i915/intel_color_manager.h +20 -0
index 5eaa0f3..6e5158e 100644
@@ -55,6 +55,26 @@
 #define CHV_DEGAMMA_MSB_SHIFT                  2
 #define CHV_DEGAMMA_GREEN_SHIFT                16
 
+/* CSC correction */
+#define CSC_DATA_STRUCT_VERSION		1
+/*
+ * Fractional part is 32 bit, and we need only 12 MSBs for programming
+ * into registers. ROUNDOFF is required to minimize loss of precision.
+ */
+#define CHV_CSC_FRACT_ROUNDOFF			(1 << 19)
+/*
+ * CSC values are 64-bit values. For CHV, the maximum CSC value that
+ * user can program is 7.99999..., which can be represented in fixed point
+ * S31.32 format like this, with all fractional bits as 1
+ */
+#define CHV_CSC_COEFF_MAX			0x00000007FFFFFFFF
+#define CHV_CSC_COEFF_SHIFT			32
+#define CHV_CSC_COEFF_INT_SHIFT		28
+#define CSC_COEFF_SIGN				(1 << 31)
+#define CHV_CSC_COEFF_FRACT_SHIFT		20
+#define CSC_MAX_VALS				9
+
 /* CHV CGM Block */
 #define CGM_GAMMA_EN				(1 << 2)
+#define CGM_CSC_EN                             (1 << 1)
 #define CGM_DEGAMMA_EN                         (1 << 0)
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#52 lore raw

PATCH 18/23 drm/i915: Commit color changes to CRTC

In reply to Shashank Sharma

The color correction blob values are loaded during set_property calls. This patch adds a function to find the blob and apply the correction values to the display registers, during the atomic commit call.

---
 drivers/gpu/drm/i915/intel_color_manager.c | 46 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_display.c       |  2 ++
 drivers/gpu/drm/i915/intel_drv.h           |  2 ++
 3 files changed, 50 insertions(+)
drivers/gpu/drm/i915/intel_color_manager.c +46 -0
index 22b708f..d33a2be 100644
@@ -406,6 +406,52 @@ int intel_color_manager_set_pipe_gamma(struct drm_device *dev,
 	return 0;
 }
 
+void intel_color_manager_crtc_commit(struct drm_device *dev,
+		struct drm_crtc_state *crtc_state)
+{
+	struct drm_property_blob *blob;
+	struct drm_crtc *crtc = crtc_state->crtc;
+	int ret = -EINVAL;
+
+	blob = crtc_state->palette_after_ctm_blob;
+	if (blob) {
+		/* Gamma correction is platform specific */
+		if (IS_CHERRYVIEW(dev))
+			ret = chv_set_gamma(dev, blob, crtc);
+
+		if (ret)
+			DRM_ERROR("set Gamma correction failed\n");
+		else
+			DRM_DEBUG_DRIVER("Gamma correction success\n");
+	}
+
+	blob = crtc_state->palette_before_ctm_blob;
+	if (blob) {
+		/* degamma correction */
+		if (IS_CHERRYVIEW(dev))
+			ret = chv_set_degamma(dev, blob, crtc);
+
+		if (ret)
+			DRM_ERROR("set degamma correction failed\n");
+		else
+			DRM_DEBUG_DRIVER("degamma correction success\n");
+	}
+
+	blob = crtc_state->ctm_blob;
+	if (blob) {
+		/* CSC correction */
+		if (IS_CHERRYVIEW(dev))
+			ret = chv_set_csc(dev, blob, crtc);
+
+		if (ret)
+			DRM_ERROR("set CSC correction failed\n");
+		else
+			DRM_DEBUG_DRIVER("CSC correction success\n");
+	}
+
+}
+
+
 int get_pipe_capabilities(struct drm_device *dev,
 		struct drm_palette_caps *palette_caps, struct drm_crtc *crtc)
 {
drivers/gpu/drm/i915/intel_display.c +2 -0
index 010acca..9b9d267 100644
@@ -13487,6 +13487,8 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
 		intel_update_pipe_config(intel_crtc, old_intel_state);
 	else if (INTEL_INFO(dev)->gen >= 9)
 		skl_detach_scalers(intel_crtc);
+
+	intel_color_manager_crtc_commit(dev, crtc->state);
 }
 
 static void intel_finish_crtc_commit(struct drm_crtc *crtc,
drivers/gpu/drm/i915/intel_drv.h +2 -0
index 4d571a2f..f87a99d 100644
@@ -1476,4 +1476,6 @@ int intel_color_manager_set_pipe_degamma(struct drm_device *dev,
 int intel_color_manager_set_pipe_csc(struct drm_device *dev,
 		struct drm_crtc_state *crtc_state,
 		struct drm_mode_object *obj, uint32_t blob_id);
+void intel_color_manager_crtc_commit(struct drm_device *dev,
+		struct drm_crtc_state *crtc_state);
 #endif /* __INTEL_DRV_H__ */
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#53 lore raw

PATCH 19/23 drm/i915: Attach color properties to CRTC

In reply to Shashank Sharma

Function intel_attach_color_properties_to_crtc attaches a color property to its CRTC object. This patch calls this function from crtc initialization sequence.

---
 drivers/gpu/drm/i915/intel_display.c | 1 +
 drivers/gpu/drm/i915/intel_drv.h     | 2 ++
 2 files changed, 3 insertions(+)
drivers/gpu/drm/i915/intel_display.c +1 -0
index 9b9d267..8b5f266 100644
@@ -13818,6 +13818,7 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
 	intel_crtc->cursor_size = ~0;
 
 	intel_crtc->wm.cxsr_allowed = true;
+	intel_attach_color_properties_to_crtc(dev, &intel_crtc->base.base);
 
 	BUG_ON(pipe >= ARRAY_SIZE(dev_priv->plane_to_crtc_mapping) ||
 	       dev_priv->plane_to_crtc_mapping[intel_crtc->plane] != NULL);
drivers/gpu/drm/i915/intel_drv.h +2 -0
index f87a99d..f992345 100644
@@ -1478,4 +1478,6 @@ int intel_color_manager_set_pipe_csc(struct drm_device *dev,
 		struct drm_mode_object *obj, uint32_t blob_id);
 void intel_color_manager_crtc_commit(struct drm_device *dev,
 		struct drm_crtc_state *crtc_state);
+void intel_attach_color_properties_to_crtc(struct drm_device *dev,
+		struct drm_mode_object *mode_obj);
 #endif /* __INTEL_DRV_H__ */
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#54 lore raw

PATCH 20/23 drm/i915: BDW: Load gamma correction values

In reply to Shashank Sharma

I915 color manager registers pipe gamma correction as palette correction after CTM property.

For BDW and higher platforms, split gamma correction is the best gamma correction. This patch adds the no of coefficients(512) for split gamma correction as "num_samples_after_ctm" parameter in device info structures, for all of those.

---
 drivers/gpu/drm/i915/i915_drv.c            | 7 +++++++
 drivers/gpu/drm/i915/intel_color_manager.h | 2 ++
 2 files changed, 9 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +7 -0
index 03db841..69afed3 100644
@@ -302,6 +302,7 @@ static const struct intel_device_info intel_broadwell_d_info = {
 	.gen = 8, .num_pipes = 3,
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
+	.num_samples_after_ctm = BDW_SPLITGAMMA_MAX_VALS,
 	.has_llc = 1,
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
@@ -314,6 +315,7 @@ static const struct intel_device_info intel_broadwell_m_info = {
 	.gen = 8, .is_mobile = 1, .num_pipes = 3,
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
+	.num_samples_after_ctm = BDW_SPLITGAMMA_MAX_VALS,
 	.has_llc = 1,
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
@@ -326,6 +328,7 @@ static const struct intel_device_info intel_broadwell_gt3d_info = {
 	.gen = 8, .num_pipes = 3,
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
+	.num_samples_after_ctm = BDW_SPLITGAMMA_MAX_VALS,
 	.has_llc = 1,
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
@@ -338,6 +341,7 @@ static const struct intel_device_info intel_broadwell_gt3m_info = {
 	.gen = 8, .is_mobile = 1, .num_pipes = 3,
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
+	.num_samples_after_ctm = BDW_SPLITGAMMA_MAX_VALS,
 	.has_llc = 1,
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
@@ -363,6 +367,7 @@ static const struct intel_device_info intel_skylake_info = {
 	.gen = 9, .num_pipes = 3,
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
+	.num_samples_after_ctm = BDW_SPLITGAMMA_MAX_VALS,
 	.has_llc = 1,
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
@@ -376,6 +381,7 @@ static const struct intel_device_info intel_skylake_gt3_info = {
 	.gen = 9, .num_pipes = 3,
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
+	.num_samples_after_ctm = BDW_SPLITGAMMA_MAX_VALS,
 	.has_llc = 1,
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
@@ -389,6 +395,7 @@ static const struct intel_device_info intel_broxton_info = {
 	.gen = 9,
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
+	.num_samples_after_ctm = BDW_SPLITGAMMA_MAX_VALS,
 	.num_pipes = 3,
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
drivers/gpu/drm/i915/intel_color_manager.h +2 -0
index 6e5158e..3687989 100644
@@ -42,6 +42,8 @@
 #define CHV_10BIT_GAMMA_MSB_SHIFT		6
 #define CHV_GAMMA_SHIFT_GREEN			16
 
+#define BDW_SPLITGAMMA_MAX_VALS		512
+
 /* Gamma values are u8.24 format */
 #define GAMMA_INT_SHIFT			24
 #define GAMMA_FRACT_SHIFT			8
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#55 lore raw

PATCH 21/23 drm/i915: BDW: Pipe level Gamma correction

In reply to Shashank Sharma

BDW/SKL/BXT platforms support various Gamma correction modes which are:
1. Legacy 8-bit mode
2. 10-bit mode
3. 10-bit Split Gamma mode
4. 12-bit mode

This patch does the following:
1. Adds the core function to program Gamma correction values for BDW/SKL/BXT platforms
2. Adds Gamma correction macros/defines

---
 drivers/gpu/drm/i915/i915_reg.h            |  17 +-
 drivers/gpu/drm/i915/intel_color_manager.c | 270 +++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_color_manager.h |  15 ++
 3 files changed, 300 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +15 -2
index 5c7759d..88f4e41 100644
@@ -5634,7 +5634,9 @@ enum skl_disp_power_wells {
 
 #define _GAMMA_MODE_A		0x4a480
 #define _GAMMA_MODE_B		0x4ac80
-#define GAMMA_MODE(pipe) _PIPE(pipe, _GAMMA_MODE_A, _GAMMA_MODE_B)
+#define _GAMMA_MODE_C		0x4b480
+#define GAMMA_MODE(pipe) \
+	_PIPE3(pipe, _GAMMA_MODE_A, _GAMMA_MODE_B, _GAMMA_MODE_C)
 #define GAMMA_MODE_MODE_MASK	(3 << 0)
 #define GAMMA_MODE_MODE_8BIT	(0 << 0)
 #define GAMMA_MODE_MODE_10BIT	(1 << 0)
@@ -8001,6 +8003,17 @@ enum skl_disp_power_wells {
 #define _PIPE_CSC_BASE(pipe) \
 	(_PIPE3(pipe, PIPEA_CGM_CSC, PIPEB_CGM_CSC, PIPEC_CGM_CSC))
 
-
+/* BDW gamma correction */
+#define PAL_PREC_INDEX_A                       0x4A400
+#define PAL_PREC_INDEX_B                       0x4AC00
+#define PAL_PREC_INDEX_C                       0x4B400
+#define PAL_PREC_DATA_A                                0x4A404
+#define PAL_PREC_DATA_B                                0x4AC04
+#define PAL_PREC_DATA_C                                0x4B404
+
+#define _PREC_PAL_INDEX(pipe) \
+	(_PIPE3(pipe, PAL_PREC_INDEX_A, PAL_PREC_INDEX_B, PAL_PREC_INDEX_C))
+#define _PREC_PAL_DATA(pipe) \
+	(_PIPE3(pipe, PAL_PREC_DATA_A, PAL_PREC_DATA_B, PAL_PREC_DATA_C))
 
 #endif /* _I915_REG_H_ */
drivers/gpu/drm/i915/intel_color_manager.c +270 -0

282 lines not on this page · raw message

drivers/gpu/drm/i915/intel_color_manager.h +15 -0
index 3687989..17fcf3d 100644
@@ -43,6 +43,9 @@
 #define CHV_GAMMA_SHIFT_GREEN			16
 
 #define BDW_SPLITGAMMA_MAX_VALS		512
+#define BDW_8BIT_GAMMA_MAX_VALS               256
+#define BDW_10BIT_GAMMA_MAX_VALS              1024
+#define BDW_12BIT_GAMMA_MAX_VALS              513
 
 /* Gamma values are u8.24 format */
 #define GAMMA_INT_SHIFT			24
@@ -52,6 +55,18 @@
 /* Max value for Gamma on CHV */
 #define CHV_MAX_GAMMA				0x10000
 
+/* Gen 9 */
+#define BDW_MAX_GAMMA				0x10000
+#define BDW_10BIT_GAMMA_MSB_SHIFT		6
+#define BDW_GAMMA_SHIFT			10
+#define BDW_INDEX_AUTO_INCREMENT		(1 << 15)
+#define BDW_INDEX_SPLIT_MODE			(1 << 31)
+#define BDW_8BIT_GAMMA_MSB_SHIFT		8
+#define BDW_8BIT_GAMMA_SHIFT			8
+#define BDW_12BIT_GAMMA_ODD_SHIFT		6
+#define BDW_12BIT_GAMMA_EVEN_SHIFT1		10
+#define BDW_12BIT_GAMMA_EVEN_SHIFT2		6
+
 /* DeGamma correction */
 #define DEGAMMA_DATA_STRUCT_VERSION        1
 #define CHV_DEGAMMA_MSB_SHIFT                  2
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#56 lore raw

Re: [PATCH 21/23] drm/i915: BDW: Pipe level Gamma correction

Hi Shashank, some feedback below that you would be great to get addressed before your next version.

Quoted 12 lines · Shashank Sharma

BDW/SKL/BXT platforms support various Gamma correction modes which are:
1. Legacy 8-bit mode
2. 10-bit mode
3. 10-bit Split Gamma mode
4. 12-bit mode

This patch does the following:
1. Adds the core function to program Gamma correction values for BDW/SKL/BXT platforms
2. Adds Gamma correction macros/defines

Quoted 6 lines
---
 drivers/gpu/drm/i915/i915_reg.h            |  17 +-
 drivers/gpu/drm/i915/intel_color_manager.c | 270

+++++++++++++++++++++++++++++

*snip*

Quoted 27 lines

+static u32 bdw_write_10bit_gamma_precision(u32 red, u32 green, u32 blue)

drivers/gpu/drm/i915/intel_color_manager.c +25 -0
+{
+	u32 word;
+	u8 blue_int, green_int, red_int;
+	u16 blue_fract, green_fract, red_fract;
+
+	blue_int = _GAMMA_INT_PART(blue);
+	if (blue_int > GAMMA_INT_MAX)
+		blue = BDW_MAX_GAMMA;
+
+	green_int = _GAMMA_INT_PART(green);
+	if (green_int > GAMMA_INT_MAX)
+		green = BDW_MAX_GAMMA;
+
+	red_int = _GAMMA_INT_PART(red);
+	if (red_int > GAMMA_INT_MAX)
+		red = BDW_MAX_GAMMA;
+
+	blue_fract = _GAMMA_FRACT_PART(blue);
+	green_fract = _GAMMA_FRACT_PART(green);
+	red_fract = _GAMMA_FRACT_PART(red);
+
+	blue_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
+	green_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
+	red_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
+

drivers/gpu/drm/i915/intel_color_manager.c static int chv_set_degamma(struct drm_device *dev, · line 302

Quoted 10 lines
drivers/gpu/drm/i915/intel_color_manager.c +10 -0
+	/* Red (29:20) Green (19:10) and Blue (9:0) */
+	word = red_fract;
+	word <<= BDW_GAMMA_SHIFT;
+	word = word | green_fract;
+	word <<= BDW_GAMMA_SHIFT;
+	word = word | blue_fract;
+
+	return word;
+}
+

I think the above function, and perhaps others in this series have the same flaw with respect to maximum colour value.

In our discussions we agreed that we would follow the "GL style" where maximum colour (i.e. 255 in 8-bit) would be represented by 1.0f. 1.0f when converted to fixed point 8.24 notation is 1 << 24.

I observed that with my test code that a linear ramp (where the last entry is set to 1.0) gives me black for white. I tracked it down to this function.

In order to map 1.0 to the maximum value for the table entry in the hardware this function needs to be changed. One way to achieve this would be change the test "blue_int > GAMMA_INT_MAX" to be "blue_int >= GAMMA_INT_MAX" but since GAMMA_INT_MAX = 1 then it might be clearer to say blue_int > 0.

BDW_MAX_GAMMA also looks wrong. I think it should be (1 << 24) - 1 not the 0x10000 (see below). As well as correct clamping it is also necessary to scale as Daniel suggested on IRC:

"
13:54 < danvet> robster, so we'd need to rescale in the kernel from 1.0 to 0.1111111111b ?
13:55 < danvet> well substract 0.0000000001b for all values > 0.5 probably since float math in the kernel is evil
13:56 < danvet> also this probably needs an igt - check that all black with an all 1.0 gamma table is the same as
all white with a linear one
"

You won't see this with your test program (color-correction.c) as the largest value you program in appears to be 0.ff

*snip*

drivers/gpu/drm/i915/intel_color_manager.h line 59

Quoted 3 lines
drivers/gpu/drm/i915/intel_color_manager.h +2 -0
+/* Gen 9 */
+#define BDW_MAX_GAMMA				0x10000

*snip*

I look forward to testing against your next version.

Rob
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#57 lore raw

RE: [PATCH 21/23] drm/i915: BDW: Pipe level Gamma correction

Hey Rob,

Thanks for the feedback, and the testing efforts.
I will check into your suggestions and get back.

Regards
Shashank
-----Original Message-----
From: Bradford, Robert
Sent: Wednesday, September 30, 2015 8:02 PM
To: Sharma, Shashank; Roper, Matthew D; Bish, Jim; Smith, Gary K; [email protected]; [email protected]
Cc: Vetter, Daniel; Matheson, Annie J; Mukherjee, Indranil; Palleti, Avinash Reddy; [email protected]
Subject: Re: [PATCH 21/23] drm/i915: BDW: Pipe level Gamma correction

Hi Shashank, some feedback below that you would be great to get addressed before your next version.

Quoted 12 lines · Shashank Sharma

BDW/SKL/BXT platforms support various Gamma correction modes which are:
1. Legacy 8-bit mode
2. 10-bit mode
3. 10-bit Split Gamma mode
4. 12-bit mode

This patch does the following:
1. Adds the core function to program Gamma correction values for BDW/SKL/BXT platforms
2. Adds Gamma correction macros/defines

Quoted 6 lines
---
 drivers/gpu/drm/i915/i915_reg.h            |  17 +-
 drivers/gpu/drm/i915/intel_color_manager.c | 270

+++++++++++++++++++++++++++++

*snip*

Quoted 27 lines

+static u32 bdw_write_10bit_gamma_precision(u32 red, u32 green, u32 blue)

drivers/gpu/drm/i915/intel_color_manager.c +25 -0
+{
+	u32 word;
+	u8 blue_int, green_int, red_int;
+	u16 blue_fract, green_fract, red_fract;
+
+	blue_int = _GAMMA_INT_PART(blue);
+	if (blue_int > GAMMA_INT_MAX)
+		blue = BDW_MAX_GAMMA;
+
+	green_int = _GAMMA_INT_PART(green);
+	if (green_int > GAMMA_INT_MAX)
+		green = BDW_MAX_GAMMA;
+
+	red_int = _GAMMA_INT_PART(red);
+	if (red_int > GAMMA_INT_MAX)
+		red = BDW_MAX_GAMMA;
+
+	blue_fract = _GAMMA_FRACT_PART(blue);
+	green_fract = _GAMMA_FRACT_PART(green);
+	red_fract = _GAMMA_FRACT_PART(red);
+
+	blue_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
+	green_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
+	red_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
+

drivers/gpu/drm/i915/intel_color_manager.c static int chv_set_degamma(struct drm_device *dev, · line 302

Quoted 10 lines
drivers/gpu/drm/i915/intel_color_manager.c +10 -0
+	/* Red (29:20) Green (19:10) and Blue (9:0) */
+	word = red_fract;
+	word <<= BDW_GAMMA_SHIFT;
+	word = word | green_fract;
+	word <<= BDW_GAMMA_SHIFT;
+	word = word | blue_fract;
+
+	return word;
+}
+

I think the above function, and perhaps others in this series have the same flaw with respect to maximum colour value.

In our discussions we agreed that we would follow the "GL style" where maximum colour (i.e. 255 in 8-bit) would be represented by 1.0f. 1.0f when converted to fixed point 8.24 notation is 1 << 24.

I observed that with my test code that a linear ramp (where the last entry is set to 1.0) gives me black for white. I tracked it down to this function.

In order to map 1.0 to the maximum value for the table entry in the hardware this function needs to be changed. One way to achieve this would be change the test "blue_int > GAMMA_INT_MAX" to be "blue_int >= GAMMA_INT_MAX" but since GAMMA_INT_MAX = 1 then it might be clearer to say blue_int > 0.

BDW_MAX_GAMMA also looks wrong. I think it should be (1 << 24) - 1 not the 0x10000 (see below). As well as correct clamping it is also necessary to scale as Daniel suggested on IRC:

"
13:54 < danvet> robster, so we'd need to rescale in the kernel from 1.0 to 0.1111111111b ? 13:55 < danvet> well substract 0.0000000001b for all values > 0.5 probably since float math in the kernel is evil 13:56 < danvet> also this probably needs an igt - check that all black with an all 1.0 gamma table is the same as
all white with a linear one "

You won't see this with your test program (color-correction.c) as the largest value you program in appears to be 0.ff

*snip*

drivers/gpu/drm/i915/intel_color_manager.h line 59

Quoted 3 lines
drivers/gpu/drm/i915/intel_color_manager.h +2 -0
+/* Gen 9 */
+#define BDW_MAX_GAMMA				0x10000

*snip*

I look forward to testing against your next version.

Rob
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#58 lore raw

Re: [PATCH 21/23] drm/i915: BDW: Pipe level Gamma correction

Shashank,

Please let us know when the next patch series would be ready assuming you incorporate the feedback from Rob.

I would like to hope we're done with feedback at this point.

Thanks.

Annie Matheson

Quoted 98 lines · Shashank

Hey Rob,

Thanks for the feedback, and the testing efforts.
I will check into your suggestions and get back.

Regards
Shashank
-----Original Message-----
From: Bradford, Robert
Sent: Wednesday, September 30, 2015 8:02 PM
To: Sharma, Shashank; Roper, Matthew D; Bish, Jim; Smith, Gary K; [email protected]; [email protected]
Cc: Vetter, Daniel; Matheson, Annie J; Mukherjee, Indranil; Palleti, Avinash Reddy; [email protected]
Subject: Re: [PATCH 21/23] drm/i915: BDW: Pipe level Gamma correction

Hi Shashank, some feedback below that you would be great to get addressed before your next version.

Quoted 13 lines · Shashank Sharma

BDW/SKL/BXT platforms support various Gamma correction modes which are:
1. Legacy 8-bit mode
2. 10-bit mode
3. 10-bit Split Gamma mode
4. 12-bit mode

This patch does the following:
1. Adds the core function to program Gamma correction values for BDW/SKL/BXT platforms
2. Adds Gamma correction macros/defines

Quoted 6 lines

---
drivers/gpu/drm/i915/i915_reg.h | 17 +-
drivers/gpu/drm/i915/intel_color_manager.c | 270
+++++++++++++++++++++++++++++

*snip*

Quoted 27 lines

+static u32 bdw_write_10bit_gamma_precision(u32 red, u32 green, u32 blue)

drivers/gpu/drm/i915/intel_color_manager.c +25 -0
+{
+    u32 word;
+    u8 blue_int, green_int, red_int;
+    u16 blue_fract, green_fract, red_fract;
+
+    blue_int = _GAMMA_INT_PART(blue);
+    if (blue_int > GAMMA_INT_MAX)
+        blue = BDW_MAX_GAMMA;
+
+    green_int = _GAMMA_INT_PART(green);
+    if (green_int > GAMMA_INT_MAX)
+        green = BDW_MAX_GAMMA;
+
+    red_int = _GAMMA_INT_PART(red);
+    if (red_int > GAMMA_INT_MAX)
+        red = BDW_MAX_GAMMA;
+
+    blue_fract = _GAMMA_FRACT_PART(blue);
+    green_fract = _GAMMA_FRACT_PART(green);
+    red_fract = _GAMMA_FRACT_PART(red);
+
+    blue_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
+    green_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
+    red_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
+

drivers/gpu/drm/i915/intel_color_manager.c static int chv_set_degamma(struct drm_device *dev, · line 302

Quoted 10 lines
drivers/gpu/drm/i915/intel_color_manager.c +10 -0
+    /* Red (29:20) Green (19:10) and Blue (9:0) */
+    word = red_fract;
+    word <<= BDW_GAMMA_SHIFT;
+    word = word | green_fract;
+    word <<= BDW_GAMMA_SHIFT;
+    word = word | blue_fract;
+
+    return word;
+}
+

I think the above function, and perhaps others in this series have the same flaw with respect to maximum colour value.

In our discussions we agreed that we would follow the "GL style" where maximum colour (i.e. 255 in 8-bit) would be represented by 1.0f. 1.0f when converted to fixed point 8.24 notation is 1 << 24.

I observed that with my test code that a linear ramp (where the last entry is set to 1.0) gives me black for white. I tracked it down to this function.

In order to map 1.0 to the maximum value for the table entry in the hardware this function needs to be changed. One way to achieve this would be change the test "blue_int > GAMMA_INT_MAX" to be "blue_int >= GAMMA_INT_MAX" but since GAMMA_INT_MAX = 1 then it might be clearer to say blue_int > 0.

BDW_MAX_GAMMA also looks wrong. I think it should be (1 << 24) - 1 not the 0x10000 (see below). As well as correct clamping it is also necessary to scale as Daniel suggested on IRC:

"
13:54 < danvet> robster, so we'd need to rescale in the kernel from 1.0 to 0.1111111111b ? 13:55 < danvet> well substract 0.0000000001b for all values > 0.5 probably since float math in the kernel is evil 13:56 < danvet> also this probably needs an igt - check that all black with an all 1.0 gamma table is the same as
all white with a linear one "

You won't see this with your test program (color-correction.c) as the largest value you program in appears to be 0.ff

*snip*

Quoted 8 lines

drivers/gpu/drm/i915/intel_color_manager.h line 59

Quoted 2 lines
drivers/gpu/drm/i915/intel_color_manager.h +2 -0
+/* Gen 9 */
+#define BDW_MAX_GAMMA                0x10000

*snip*

I look forward to testing against your next version.

Rob

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#59 lore raw

RE: [PATCH 21/23] drm/i915: BDW: Pipe level Gamma correction

Hi Annie,
This might add a day or two, but considering this is a long weekend in India, you can expect the patches by mid next week.

Regards
Shashank
-----Original Message-----
From: Matheson, Annie J
Sent: Wednesday, September 30, 2015 10:01 PM
To: Sharma, Shashank
Cc: Bradford, Robert; Roper, Matthew D; Bish, Jim; Smith, Gary K; [email protected]; [email protected]; Vetter, Daniel; Mukherjee, Indranil; Palleti, Avinash Reddy; [email protected]
Subject: Re: [PATCH 21/23] drm/i915: BDW: Pipe level Gamma correction

Shashank,

Please let us know when the next patch series would be ready assuming you incorporate the feedback from Rob.

I would like to hope we're done with feedback at this point.

Thanks.

Annie Matheson

Quoted 98 lines · Shashank

Hey Rob,

Thanks for the feedback, and the testing efforts.
I will check into your suggestions and get back.

Regards
Shashank
-----Original Message-----
From: Bradford, Robert
Sent: Wednesday, September 30, 2015 8:02 PM
To: Sharma, Shashank; Roper, Matthew D; Bish, Jim; Smith, Gary K; [email protected]; [email protected]
Cc: Vetter, Daniel; Matheson, Annie J; Mukherjee, Indranil; Palleti, Avinash Reddy; [email protected]
Subject: Re: [PATCH 21/23] drm/i915: BDW: Pipe level Gamma correction

Hi Shashank, some feedback below that you would be great to get addressed before your next version.

Quoted 13 lines · Shashank Sharma

BDW/SKL/BXT platforms support various Gamma correction modes which are:
1. Legacy 8-bit mode
2. 10-bit mode
3. 10-bit Split Gamma mode
4. 12-bit mode

This patch does the following:
1. Adds the core function to program Gamma correction values for BDW/SKL/BXT platforms
2. Adds Gamma correction macros/defines

Quoted 6 lines

---
drivers/gpu/drm/i915/i915_reg.h | 17 +-
drivers/gpu/drm/i915/intel_color_manager.c | 270
+++++++++++++++++++++++++++++

*snip*

Quoted 27 lines

+static u32 bdw_write_10bit_gamma_precision(u32 red, u32 green, u32 blue)

drivers/gpu/drm/i915/intel_color_manager.c +25 -0
+{
+    u32 word;
+    u8 blue_int, green_int, red_int;
+    u16 blue_fract, green_fract, red_fract;
+
+    blue_int = _GAMMA_INT_PART(blue);
+    if (blue_int > GAMMA_INT_MAX)
+        blue = BDW_MAX_GAMMA;
+
+    green_int = _GAMMA_INT_PART(green);
+    if (green_int > GAMMA_INT_MAX)
+        green = BDW_MAX_GAMMA;
+
+    red_int = _GAMMA_INT_PART(red);
+    if (red_int > GAMMA_INT_MAX)
+        red = BDW_MAX_GAMMA;
+
+    blue_fract = _GAMMA_FRACT_PART(blue);
+    green_fract = _GAMMA_FRACT_PART(green);
+    red_fract = _GAMMA_FRACT_PART(red);
+
+    blue_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
+    green_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
+    red_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
+

drivers/gpu/drm/i915/intel_color_manager.c static int chv_set_degamma(struct drm_device *dev, · line 302

Quoted 10 lines
drivers/gpu/drm/i915/intel_color_manager.c +10 -0
+    /* Red (29:20) Green (19:10) and Blue (9:0) */
+    word = red_fract;
+    word <<= BDW_GAMMA_SHIFT;
+    word = word | green_fract;
+    word <<= BDW_GAMMA_SHIFT;
+    word = word | blue_fract;
+
+    return word;
+}
+

I think the above function, and perhaps others in this series have the same flaw with respect to maximum colour value.

In our discussions we agreed that we would follow the "GL style" where maximum colour (i.e. 255 in 8-bit) would be represented by 1.0f. 1.0f when converted to fixed point 8.24 notation is 1 << 24.

I observed that with my test code that a linear ramp (where the last entry is set to 1.0) gives me black for white. I tracked it down to this function.

In order to map 1.0 to the maximum value for the table entry in the hardware this function needs to be changed. One way to achieve this would be change the test "blue_int > GAMMA_INT_MAX" to be "blue_int >= GAMMA_INT_MAX" but since GAMMA_INT_MAX = 1 then it might be clearer to say blue_int > 0.

BDW_MAX_GAMMA also looks wrong. I think it should be (1 << 24) - 1 not the 0x10000 (see below). As well as correct clamping it is also necessary to scale as Daniel suggested on IRC:

"
13:54 < danvet> robster, so we'd need to rescale in the kernel from 1.0 to 0.1111111111b ? 13:55 < danvet> well substract 0.0000000001b for all values > 0.5 probably since float math in the kernel is evil 13:56 < danvet> also this probably needs an igt - check that all black with an all 1.0 gamma table is the same as
all white with a linear one "

You won't see this with your test program (color-correction.c) as the largest value you program in appears to be 0.ff

*snip*

Quoted 8 lines

drivers/gpu/drm/i915/intel_color_manager.h line 59

Quoted 2 lines
drivers/gpu/drm/i915/intel_color_manager.h +2 -0
+/* Gen 9 */
+#define BDW_MAX_GAMMA                0x10000

*snip*

I look forward to testing against your next version.

Rob

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#60 lore raw

Re: [PATCH 21/23] drm/i915: BDW: Pipe level Gamma correction

In reply to Rob Bradford
Quoted 84 lines · Rob Bradford

Hi Shashank, some feedback below that you would be great to get addressed before your next version.

Quoted 12 lines · Shashank Sharma

BDW/SKL/BXT platforms support various Gamma correction modes which are:
1. Legacy 8-bit mode
2. 10-bit mode
3. 10-bit Split Gamma mode
4. 12-bit mode

This patch does the following:
1. Adds the core function to program Gamma correction values for BDW/SKL/BXT platforms
2. Adds Gamma correction macros/defines

Quoted 6 lines
---
 drivers/gpu/drm/i915/i915_reg.h            |  17 +-
 drivers/gpu/drm/i915/intel_color_manager.c | 270

+++++++++++++++++++++++++++++

*snip*

Quoted 27 lines

+static u32 bdw_write_10bit_gamma_precision(u32 red, u32 green, u32 blue)

drivers/gpu/drm/i915/intel_color_manager.c +25 -0
+{
+	u32 word;
+	u8 blue_int, green_int, red_int;
+	u16 blue_fract, green_fract, red_fract;
+
+	blue_int = _GAMMA_INT_PART(blue);
+	if (blue_int > GAMMA_INT_MAX)
+		blue = BDW_MAX_GAMMA;
+
+	green_int = _GAMMA_INT_PART(green);
+	if (green_int > GAMMA_INT_MAX)
+		green = BDW_MAX_GAMMA;
+
+	red_int = _GAMMA_INT_PART(red);
+	if (red_int > GAMMA_INT_MAX)
+		red = BDW_MAX_GAMMA;
+
+	blue_fract = _GAMMA_FRACT_PART(blue);
+	green_fract = _GAMMA_FRACT_PART(green);
+	red_fract = _GAMMA_FRACT_PART(red);
+
+	blue_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
+	green_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
+	red_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
+

drivers/gpu/drm/i915/intel_color_manager.c static int chv_set_degamma(struct drm_device *dev, · line 302

Quoted 10 lines
drivers/gpu/drm/i915/intel_color_manager.c +10 -0
+	/* Red (29:20) Green (19:10) and Blue (9:0) */
+	word = red_fract;
+	word <<= BDW_GAMMA_SHIFT;
+	word = word | green_fract;
+	word <<= BDW_GAMMA_SHIFT;
+	word = word | blue_fract;
+
+	return word;
+}
+

I think the above function, and perhaps others in this series have the same flaw with respect to maximum colour value.

In our discussions we agreed that we would follow the "GL style" where maximum colour (i.e. 255 in 8-bit) would be represented by 1.0f. 1.0f when converted to fixed point 8.24 notation is 1 << 24.

I observed that with my test code that a linear ramp (where the last entry is set to 1.0) gives me black for white. I tracked it down to this function.

In order to map 1.0 to the maximum value for the table entry in the hardware this function needs to be changed. One way to achieve this would be change the test "blue_int > GAMMA_INT_MAX" to be "blue_int >= GAMMA_INT_MAX" but since GAMMA_INT_MAX = 1 then it might be clearer to say blue_int > 0.

BDW_MAX_GAMMA also looks wrong. I think it should be (1 << 24) - 1 not the 0x10000 (see below). As well as correct clamping it is also necessary to scale as Daniel suggested on IRC:

Quoted 5 lines

"
13:54 < danvet> robster, so we'd need to rescale in the kernel from 1.0 to 0.1111111111b ?
13:55 < danvet> well substract 0.0000000001b for all values > 0.5 probably since float math in the kernel is evil

Or just clamp to '(1<<bits)-1'. I think the end result is the same actually.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#61 lore raw

PATCH 22/23 drm/i915: BDW: Load degamma correction values

In reply to Shashank Sharma

I915 color manager registers pipe degamma correction as palette correction before CTM, DRM property.

This patch adds the no of coefficients(65) for degamma correction as "num_samples_before_ctm" parameter in device info structures, for BDW and higher platforms.

---
 drivers/gpu/drm/i915/i915_drv.c            | 7 +++++++
 drivers/gpu/drm/i915/intel_color_manager.h | 2 ++
 2 files changed, 9 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +7 -0
index 69afed3..23ad2cc 100644
@@ -303,6 +303,7 @@ static const struct intel_device_info intel_broadwell_d_info = {
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
 	.num_samples_after_ctm = BDW_SPLITGAMMA_MAX_VALS,
+	.num_samples_before_ctm = BDW_DEGAMMA_MAX_VALS,
 	.has_llc = 1,
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
@@ -316,6 +317,7 @@ static const struct intel_device_info intel_broadwell_m_info = {
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
 	.num_samples_after_ctm = BDW_SPLITGAMMA_MAX_VALS,
+	.num_samples_before_ctm = BDW_DEGAMMA_MAX_VALS,
 	.has_llc = 1,
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
@@ -329,6 +331,7 @@ static const struct intel_device_info intel_broadwell_gt3d_info = {
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
 	.num_samples_after_ctm = BDW_SPLITGAMMA_MAX_VALS,
+	.num_samples_before_ctm = BDW_DEGAMMA_MAX_VALS,
 	.has_llc = 1,
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
@@ -342,6 +345,7 @@ static const struct intel_device_info intel_broadwell_gt3m_info = {
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
 	.num_samples_after_ctm = BDW_SPLITGAMMA_MAX_VALS,
+	.num_samples_before_ctm = BDW_DEGAMMA_MAX_VALS,
 	.has_llc = 1,
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
@@ -368,6 +372,7 @@ static const struct intel_device_info intel_skylake_info = {
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
 	.num_samples_after_ctm = BDW_SPLITGAMMA_MAX_VALS,
+	.num_samples_before_ctm = BDW_DEGAMMA_MAX_VALS,
 	.has_llc = 1,
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
@@ -382,6 +387,7 @@ static const struct intel_device_info intel_skylake_gt3_info = {
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING | BSD2_RING,
 	.num_samples_after_ctm = BDW_SPLITGAMMA_MAX_VALS,
+	.num_samples_before_ctm = BDW_DEGAMMA_MAX_VALS,
 	.has_llc = 1,
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
@@ -396,6 +402,7 @@ static const struct intel_device_info intel_broxton_info = {
 	.need_gfx_hws = 1, .has_hotplug = 1,
 	.ring_mask = RENDER_RING | BSD_RING | BLT_RING | VEBOX_RING,
 	.num_samples_after_ctm = BDW_SPLITGAMMA_MAX_VALS,
+	.num_samples_before_ctm = BDW_DEGAMMA_MAX_VALS,
 	.num_pipes = 3,
 	.has_ddi = 1,
 	.has_fpga_dbg = 1,
drivers/gpu/drm/i915/intel_color_manager.h +2 -0
index 17fcf3d..a428825 100644
@@ -72,6 +72,8 @@
 #define CHV_DEGAMMA_MSB_SHIFT                  2
 #define CHV_DEGAMMA_GREEN_SHIFT                16
 
+#define BDW_DEGAMMA_MAX_VALS			512
+
 /* CSC correction */
 #define CSC_DATA_STRUCT_VERSION		1
 /*
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#62 lore raw

PATCH 23/23 drm/i915: BDW: Pipe level degamma correction

In reply to Shashank Sharma

BDW/SKL/BXT supports Degamma color correction feature, which linearizes the non-linearity due to gamma encoded color values. This will be applied before Color Transformation.

This patch does the following:
1. Adds the core function to program DeGamma correction values for BDW/SKL/BXT platform
2. Adds DeGamma correction macros/defines

---
 drivers/gpu/drm/i915/intel_color_manager.c | 61 ++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
drivers/gpu/drm/i915/intel_color_manager.c +61 -0
index d935fd8..46f880d 100644
@@ -532,6 +532,65 @@ static int bdw_set_gamma(struct drm_device *dev, struct drm_property_blob *blob,
 	return 0;
 }
 
+static int bdw_set_degamma(struct drm_device *dev,
+	struct drm_property_blob *blob, struct drm_crtc *crtc)
+{
+	enum pipe pipe;
+	int num_samples, length;
+	int count = 0;
+	u32 index, word;
+	u32 blue, green, red;
+	u32 mode, pal_prec_index, pal_prec_data;
+	struct drm_palette *degamma_data;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_r32g32b32 *correction_values = NULL;
+
+	if (WARN_ON(!blob))
+		return -EINVAL;
+
+	degamma_data = (struct drm_palette *)blob->data;
+	if (degamma_data->version != DEGAMMA_DATA_STRUCT_VERSION) {
+		DRM_ERROR("Invalid DeGamma Data struct version\n");
+		return -EINVAL;
+	}
+
+	pipe = to_intel_crtc(crtc)->pipe;
+	num_samples = degamma_data->num_samples;
+	if (num_samples != BDW_SPLITGAMMA_MAX_VALS) {
+		DRM_ERROR("Invalid number of samples\n");
+		return -EINVAL;
+	}
+
+	length = num_samples * sizeof(struct drm_r32g32b32);
+	mode = I915_READ(GAMMA_MODE(pipe));
+	pal_prec_index = _PREC_PAL_INDEX(pipe);
+	pal_prec_data = _PREC_PAL_DATA(pipe);
+
+	correction_values = (struct drm_r32g32b32 *)&degamma_data->lut;
+	index = I915_READ(pal_prec_index);
+	index |= BDW_INDEX_AUTO_INCREMENT | BDW_INDEX_SPLIT_MODE;
+	I915_WRITE(pal_prec_index, index);
+
+	while (count < num_samples) {
+		blue = correction_values[count].b32;
+		green = correction_values[count].g32;
+		red = correction_values[count].r32;
+
+		word = bdw_write_10bit_gamma_precision(red, green, blue);
+		I915_WRITE(pal_prec_data, word);
+		count++;
+	}
+
+	/* Enable DeGamma on Pipe */
+	mode &= ~GAMMA_MODE_MODE_MASK;
+	I915_WRITE(GAMMA_MODE(pipe), mode | GAMMA_MODE_MODE_SPLIT);
+
+	DRM_DEBUG_DRIVER("DeGamma correction enabled on Pipe %c\n",
+			pipe_name(pipe));
+
+	return 0;
+}
+
 static int chv_set_gamma(struct drm_device *dev, struct drm_property_blob *blob,
 		  struct drm_crtc *crtc)
 {
@@ -700,6 +759,8 @@ void intel_color_manager_crtc_commit(struct drm_device *dev,
 		/* degamma correction */
 		if (IS_CHERRYVIEW(dev))
 			ret = chv_set_degamma(dev, blob, crtc);
+		else if (IS_BROADWELL(dev) || IS_GEN9(dev))
+			ret = bdw_set_degamma(dev, blob, crtc);
 
 		if (ret)
 			DRM_ERROR("set degamma correction failed\n");
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#63 lore raw
In reply to Shashank Sharma
Quoted 64 lines · Shashank Sharma

This patch set adds Color Manager implementation in DRM layer. Color Manager is an extension in DRM framework to support color correction/enhancement.

Various Hardware platforms can support several color correction capabilities. Color Manager provides abstraction of these capabilities and allows a user space UI agent to correct/enhance the display using the DRM property interface.

How is this going to work?
==========================
1. This patch series adds a few new properties in DRM framework. These properties are:
a. color_capabilities property (type blob)
b. Color Transformation Matrix property for corrections like CSC (called CTM, type blob)
c. Palette correction properties for corrections like gamma fixup (called palette_correction, type blob)
2. Also, this patch series adds few structures to indicate specifications of a property like size, no_of_samples for correction etc.
3. These properties are present in mode_config.
4. When the platform's display driver loads, it fills up the values of color_capabilities property using the standard structures (added in step 2). For example, Intel's I915 driver adds following color correction capabilities:
a. gamma correction capability as palette correction property, with 257 correction coefficients and a max/min value b. csc correction capability as CTM correction property, with 3x3 transformation matrix values and max/min values
5. Now when userspace comes up, it queries the platform's color capabilities by doing a get_property() on color_capabilities DRM property
6. Reading the blob, the userspace understands the color capabilities of the platform.
For example, userspace will understand it can support:
a. palette_correction with 257 coefficients
b. CSC correction with 3x3 = 9 values
7. To set color correction values, userspace:
a. creates a blob using the create_blob_ioctl in standard palette_correction structure format, with the correction values b. calls the set_property_ioctl with the blob_id as value for the property
8. Driver refers to the blob, gets the correction values and applies the correction in HW.
9. To get currently applied color correction values, userspace:
a. calls a get_property_ioctl on that color property
b. gets the blob_id for the currently applied correction from DRM infrastructure
c. gets the blob using get_blob_ioctl and hence the currently applied values

That's all! :)

About the patch series:
=======================
The patch series first adds the color management support in DRM layer. Then it adds the color management framework in I915 layer. After that, it implements platform specific core color correction functios.

Intel color manager registers color correction with DRM color manager in this way:
- CSC transformation is registered as CTM DRM property
- Gamma correction is registered as palette_after_ctm DRM property
- Degamma correction is registered as palette_before_ctm DRM property

Our thanks to all the reviewers who have given valuable comments in terms of design and implementation to our previous sets of patches. Special mention of thanks should go to Matt Roper for all his inputs/suggestions in implementation of this module, using DRM atomic CRTC commit path.

V2: Worked on review comments from Matt, Jim, Thierry, Rob.
V3: Worked on review comments from Matt, Jim, Rob:
- Jim, Rob:
========
Re-arranged the whole patch series in the sequence of features, currently:
First 5 patches add color management support in DRM layer
Next 7 patches add Intel color management framework in I915 driver Next 5 patches add color correction for CHV (gamma, degamma and CSC) Next 2 patches enable color management, by attaching the properties to CRTC(Matt) Next 4 patches add color correction for BDW (gamma, degamma)
- Matt:
=====
Patch 3: Added refernce/unreference for blob

Quoted 8 lines

Patch 7: return -EINVAL and added debug message
Patch 8: check for valid blob, from create blob
moved call to intel_crtc_attach_color_prop in the end of full implementation (CHV)
Patch 9: DRM_ERROR->DRM_DEBUG for NULL blob case
Patch 13: Added static for internal functions
Patch 20-24: renamed gen9_* functions to bdw_*
Added new variables in device_info structure num_samples_after_ctm and num_samples_before_ctm Added new function in patch 8 to load capabilities based on device_info across all platforms

Ok I finally got around to look at the kernel/userspace and drm core parts in detail. There's a few minor bits to polish but nothing serious I think, looks good overall (but I didn't really look at the i915 side).

One thing though is the kerneldoc part. You have some great detailed comments in the structs about how this is all supposed to be used, but afaict they're not pulled into the kerneldoc anywhere. Also we don't have an overview section, but if you add the drm_crtc_attach_cc_properties function like I suggested we could add that there (with links to all the various structures).

There's also the giant drm props table but that one is a mess. My suggestion would be to start a new DOC: section just for color correction, with an integrated markdown table. Then add that as a subsection to KMS property documentation. That way we'll have solid docs for this KMS extension (something we should have for all the other stuff like rotation or zpos too).

Thanks, Daniel

Quoted 50 lines

Shashank Sharma (23):
drm: Create Color Management DRM properties
drm: Add structure for querying palette color capabilities
drm: Add color correction blobs in CRTC state
drm: Add drm structures for palette color property
drm: Add structure to set/get a CTM color property drm/i915: Add atomic set property interface for CRTC drm/i915: Add atomic get property interface for CRTC drm/i915: Create color management files drm/i915: Register pipe color capabilities drm/i915: Add gamma correction handlers drm/i915: Add pipe deGamma correction handlers drm/i915: Add pipe CSC correction handlers drm/i915: CHV: Load gamma color correction values drm/i915: CHV: Pipe level Gamma correction drm/i915: CHV: Load degamma color correction values drm/i915: CHV: Pipe level degamma correction drm/i915: CHV: Pipe level CSC correction drm/i915: Commit color changes to CRTC
drm/i915: Attach color properties to CRTC drm/i915: BDW: Load gamma correction values drm/i915: BDW: Pipe level Gamma correction drm/i915: BDW: Load degamma correction values drm/i915: BDW: Pipe level degamma correction

 drivers/gpu/drm/drm_atomic_helper.c        |  12 +
 drivers/gpu/drm/drm_crtc.c                 |  26 +
 drivers/gpu/drm/i915/Makefile              |   3 +-
 drivers/gpu/drm/i915/i915_drv.c            |  17 +
 drivers/gpu/drm/i915/i915_drv.h            |   2 +
 drivers/gpu/drm/i915/i915_reg.h            |  41 +-
 drivers/gpu/drm/i915/intel_atomic.c        |  56 ++
 drivers/gpu/drm/i915/intel_color_manager.c | 852 +++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_color_manager.h |  99 ++++
 drivers/gpu/drm/i915/intel_display.c       |   6 +
 drivers/gpu/drm/i915/intel_drv.h           |  22 +
 include/drm/drm_crtc.h                     |  11 +
 include/uapi/drm/drm.h                     |  50 ++
 13 files changed, 1195 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_color_manager.c
 create mode 100644 drivers/gpu/drm/i915/intel_color_manager.h
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#64 lore raw

Regards
Shashank

Quoted 78 lines · Daniel Vetter
Quoted 64 lines · Shashank Sharma

This patch set adds Color Manager implementation in DRM layer. Color Manager is an extension in DRM framework to support color correction/enhancement.

Various Hardware platforms can support several color correction capabilities. Color Manager provides abstraction of these capabilities and allows a user space UI agent to correct/enhance the display using the DRM property interface.

How is this going to work?
==========================
1. This patch series adds a few new properties in DRM framework. These properties are:
a. color_capabilities property (type blob)
b. Color Transformation Matrix property for corrections like CSC (called CTM, type blob)
c. Palette correction properties for corrections like gamma fixup (called palette_correction, type blob)
2. Also, this patch series adds few structures to indicate specifications of a property like size, no_of_samples for correction etc.
3. These properties are present in mode_config.
4. When the platform's display driver loads, it fills up the values of color_capabilities property using the standard structures (added in step 2). For example, Intel's I915 driver adds following color correction capabilities:
a. gamma correction capability as palette correction property, with 257 correction coefficients and a max/min value b. csc correction capability as CTM correction property, with 3x3 transformation matrix values and max/min values
5. Now when userspace comes up, it queries the platform's color capabilities by doing a get_property() on color_capabilities DRM property
6. Reading the blob, the userspace understands the color capabilities of the platform.
For example, userspace will understand it can support:
a. palette_correction with 257 coefficients
b. CSC correction with 3x3 = 9 values
7. To set color correction values, userspace:
a. creates a blob using the create_blob_ioctl in standard palette_correction structure format, with the correction values b. calls the set_property_ioctl with the blob_id as value for the property
8. Driver refers to the blob, gets the correction values and applies the correction in HW.
9. To get currently applied color correction values, userspace:
a. calls a get_property_ioctl on that color property
b. gets the blob_id for the currently applied correction from DRM infrastructure
c. gets the blob using get_blob_ioctl and hence the currently applied values

That's all! :)

About the patch series:
=======================
The patch series first adds the color management support in DRM layer. Then it adds the color management framework in I915 layer. After that, it implements platform specific core color correction functios.

Intel color manager registers color correction with DRM color manager in this way:
- CSC transformation is registered as CTM DRM property
- Gamma correction is registered as palette_after_ctm DRM property
- Degamma correction is registered as palette_before_ctm DRM property

Our thanks to all the reviewers who have given valuable comments in terms of design and implementation to our previous sets of patches. Special mention of thanks should go to Matt Roper for all his inputs/suggestions in implementation of this module, using DRM atomic CRTC commit path.

V2: Worked on review comments from Matt, Jim, Thierry, Rob.
V3: Worked on review comments from Matt, Jim, Rob:
- Jim, Rob:
========
Re-arranged the whole patch series in the sequence of features, currently:
First 5 patches add color management support in DRM layer
Next 7 patches add Intel color management framework in I915 driver Next 5 patches add color correction for CHV (gamma, degamma and CSC) Next 2 patches enable color management, by attaching the properties to CRTC(Matt) Next 4 patches add color correction for BDW (gamma, degamma)
- Matt:
=====
Patch 3: Added refernce/unreference for blob

Quoted 8 lines

Patch 7: return -EINVAL and added debug message
Patch 8: check for valid blob, from create blob
moved call to intel_crtc_attach_color_prop in the end of full implementation (CHV)
Patch 9: DRM_ERROR->DRM_DEBUG for NULL blob case
Patch 13: Added static for internal functions
Patch 20-24: renamed gen9_* functions to bdw_*
Added new variables in device_info structure num_samples_after_ctm and num_samples_before_ctm Added new function in patch 8 to load capabilities based on device_info across all platforms

Ok I finally got around to look at the kernel/userspace and drm core parts in detail. There's a few minor bits to polish but nothing serious I think, looks good overall (but I didn't really look at the i915 side).

Quoted 7 lines

One thing though is the kerneldoc part. You have some great detailed comments in the structs about how this is all supposed to be used, but afaict they're not pulled into the kerneldoc anywhere. Also we don't have an overview section, but if you add the drm_crtc_attach_cc_properties function like I suggested we could add that there (with links to all the various structures).

Now, after the explanation in the corresponding patch, do you still find a need for the function ?

Quoted 7 lines

There's also the giant drm props table but that one is a mess. My suggestion would be to start a new DOC: section just for color correction, with an integrated markdown table. Then add that as a subsection to KMS property documentation. That way we'll have solid docs for this KMS extension (something we should have for all the other stuff like rotation or zpos too).

Yes, sure, I will do this.

Quoted 53 lines

Thanks, Daniel

Quoted 50 lines

Shashank Sharma (23):
drm: Create Color Management DRM properties
drm: Add structure for querying palette color capabilities
drm: Add color correction blobs in CRTC state
drm: Add drm structures for palette color property
drm: Add structure to set/get a CTM color property drm/i915: Add atomic set property interface for CRTC drm/i915: Add atomic get property interface for CRTC drm/i915: Create color management files drm/i915: Register pipe color capabilities drm/i915: Add gamma correction handlers drm/i915: Add pipe deGamma correction handlers drm/i915: Add pipe CSC correction handlers drm/i915: CHV: Load gamma color correction values drm/i915: CHV: Pipe level Gamma correction drm/i915: CHV: Load degamma color correction values drm/i915: CHV: Pipe level degamma correction drm/i915: CHV: Pipe level CSC correction drm/i915: Commit color changes to CRTC
drm/i915: Attach color properties to CRTC drm/i915: BDW: Load gamma correction values drm/i915: BDW: Pipe level Gamma correction drm/i915: BDW: Load degamma correction values drm/i915: BDW: Pipe level degamma correction

  drivers/gpu/drm/drm_atomic_helper.c        |  12 +
  drivers/gpu/drm/drm_crtc.c                 |  26 +
  drivers/gpu/drm/i915/Makefile              |   3 +-
  drivers/gpu/drm/i915/i915_drv.c            |  17 +
  drivers/gpu/drm/i915/i915_drv.h            |   2 +
  drivers/gpu/drm/i915/i915_reg.h            |  41 +-
  drivers/gpu/drm/i915/intel_atomic.c        |  56 ++
  drivers/gpu/drm/i915/intel_color_manager.c | 852 +++++++++++++++++++++++++++++
  drivers/gpu/drm/i915/intel_color_manager.h |  99 ++++
  drivers/gpu/drm/i915/intel_display.c       |   6 +
  drivers/gpu/drm/i915/intel_drv.h           |  22 +
  include/drm/drm_crtc.h                     |  11 +
  include/uapi/drm/drm.h                     |  50 ++
  13 files changed, 1195 insertions(+), 2 deletions(-)

create mode 100644 drivers/gpu/drm/i915/intel_color_manager.c create mode 100644 drivers/gpu/drm/i915/intel_color_manager.h

--
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel