Skip to contentSkip to conversation

Add Colorspace connector property interface

PATCH Superseded Uma Shankar 4 participants 23 messages Feb 5, 2019 – Feb 8, 2019

Subsystems (3)

v11 of 17 Superseded Latest is v17 →

lore
Share & tools
lore
#0 lore raw

v11 cover Add Colorspace connector property interface

This patch series creates a new connector property to program colorspace to sink devices. Modern sink devices support more than 1 type of colorspace like 601, 709, BT2020 etc. This helps to switch based on content type which is to be displayed. The decision lies with compositors as to in which scenarios, a particular colorspace will be picked.

This will be helpful mostly to switch to higher gamut colorspaces like BT2020 when the media content is encoded as BT2020. Thereby giving a good visual experience to users.

The expectation from userspace is that it should parse the EDID and get supported colorspaces. Use this property and switch to the one supported. Sink supported colorspaces should be retrieved by userspace from EDID and driver will not explicitly expose them.

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink colorspace
- Set this new property to let the sink know what it converted the CRTC output to.
- This property is just to inform sink what colorspace source is trying to drive.

Have tested this using xrandr by using below command:
xrandr --output HDMI2 --set "Colorspace" "BT2020_rgb"

v2: Addressed Ville and Maarten's review comments. Merged the 2nd and 3rd patch into one common logical patch.

v3: Removed Adobe references from enum definitions as per Ville, Hans Verkuil and Jonas Karlman suggestions. Changed default to an unset state where driver will assign the colorspace when not chosen by user, suggested by Ville and Maarten. Addressed other misc review comments from Maarten. Split the changes to have separate colorspace property for DP and HDMI.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list

v5: Modified the colorspace property creation helper to take platform specific enum list based on the capabilities of the platform as suggested by Shashank. With this there is no need for segregation between DP and HDMI.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian Starkey's suggestion in order to go with string matching at userspace. Updated the kernel doc as well with more details.

v8: Addressed Maarten's review comments.

v9: Removed macro defines from uapi as per Brian Starkey and Daniel Stone's comments and moved to drm include file. Moved back to older design with exposing all HDMI colorspaces to userspace since infoframe capability is there even on legacy platforms, as per Ville's review comments.

v10: Addressed Maarten' review comment, updated the RB from Maarten and Jani Nikula's ack. Also fixed sparse warnings and checkpatch complaints.

v11: Addressed Ville's review comments. Modified MACRO names, added infoframe helper for colorspace to drm layer. Added DCI-P3 colorspace macro definitions defined in CTA 861.G. Currently linux/hdmi lacks support for ACE formats, will be added as a separate series.

Uma Shankar (4):
drm: Add HDMI colorspace property
drm: Add DP colorspace property
drm: Add colorspace info to AVI Infoframe drm/i915: Attach colorspace property and enable modeset

 drivers/gpu/drm/drm_atomic_uapi.c      |   4 ++
 drivers/gpu/drm/drm_connector.c        | 104 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_edid.c             |  28 +++++++++
 drivers/gpu/drm/i915/intel_atomic.c    |   1 +
 drivers/gpu/drm/i915/intel_connector.c |   8 +++
 drivers/gpu/drm/i915/intel_drv.h       |   1 +
 drivers/gpu/drm/i915/intel_hdmi.c      |  13 +++++
 include/drm/drm_connector.h            |  50 ++++++++++++++++
 include/drm/drm_edid.h                 |   6 ++
 9 files changed, 215 insertions(+)
Signature · 6 lines
1.9.1

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

PATCH v11 1/4 drm: Add HDMI colorspace property

Create a new connector property to program colorspace to sink devices. Modern sink devices support more than 1 type of colorspace like 601, 709, BT2020 etc. This helps to switch based on content type which is to be displayed. The decision lies with compositors as to in which scenarios, a particular colorspace will be picked.

This will be helpful mostly to switch to higher gamut colorspaces like BT2020 when the media content is encoded as BT2020. Thereby giving a good visual experience to users.

The expectation from userspace is that it should parse the EDID and get supported colorspaces. Use this property and switch to the one supported. Sink supported colorspaces should be retrieved by userspace from EDID and driver will not explicitly expose them.

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink colorspace
- Set this new property to let the sink know what it converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments. Enhanced the colorspace enum to incorporate both HDMI and DP supported colorspaces. Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as per Ville, Hans Verkuil and Jonas Karlman suggestions. Changed Default to an unset state where driver will assign the colorspace is not chosen by user, suggested by Ville and Maarten. Addressed other misc review comments from Maarten. Split the changes to have separate colorspace property for DP and HDMI.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list based on the colorspaces supported by the respective protocol standard.

v5: Made the property creation helper accept enum list based on platform capabilties as suggested by Shashank. Consolidated HDMI and DP property creation in the common helper.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian Starkey's suggestion in order to go with string matching at userspace. Updated the commit message to add more details as well kernel docs.

v8: Addressed Maarten's review comments.

v9: Removed macro defines from uapi as per Brian Starkey and Daniel Stone's comments and moved to drm include file. Moved back to older design with exposing all HDMI colorspaces to userspace since infoframe capability is there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten and Jani's ack.

v11: Addressed Ville's review comments. Updated the Macro naming and added DCI-P3 colorspace as well defined in CEA 861.G spec.

---
 drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
 drivers/gpu/drm/drm_connector.c   | 78 +++++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h       | 50 +++++++++++++++++++++++++
 3 files changed, 132 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +4 -0
index 9a1f41a..9b5d44f 100644
@@ -746,6 +746,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
 			return -EINVAL;
 		}
 		state->content_protection = val;
+	} else if (property == connector->colorspace_property) {
+		state->colorspace = val;
 	} else if (property == config->writeback_fb_id_property) {
 		struct drm_framebuffer *fb = drm_framebuffer_lookup(dev, NULL, val);
 		int ret = drm_atomic_set_writeback_fb_for_connector(state, fb);
@@ -814,6 +816,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
 		*val = state->picture_aspect_ratio;
 	} else if (property == config->content_type_property) {
 		*val = state->content_type;
+	} else if (property == connector->colorspace_property) {
+		*val = state->colorspace;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
 	} else if (property == connector->content_protection_property) {
drivers/gpu/drm/drm_connector.c +78 -0

90 lines not on this page · raw message

include/drm/drm_connector.h +50 -0

74 lines not on this page · raw message

Signature · 6 lines
1.9.1

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

Re: [v11 1/4] drm: Add HDMI colorspace property

Quoted 202 lines · Uma Shankar

Create a new connector property to program colorspace to sink devices. Modern sink devices support more than 1 type of colorspace like 601, 709, BT2020 etc. This helps to switch based on content type which is to be displayed. The decision lies with compositors as to in which scenarios, a particular colorspace will be picked.

This will be helpful mostly to switch to higher gamut colorspaces like BT2020 when the media content is encoded as BT2020. Thereby giving a good visual experience to users.

The expectation from userspace is that it should parse the EDID and get supported colorspaces. Use this property and switch to the one supported. Sink supported colorspaces should be retrieved by userspace from EDID and driver will not explicitly expose them.

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink colorspace
- Set this new property to let the sink know what it converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments. Enhanced the colorspace enum to incorporate both HDMI and DP supported colorspaces. Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as per Ville, Hans Verkuil and Jonas Karlman suggestions. Changed Default to an unset state where driver will assign the colorspace is not chosen by user, suggested by Ville and Maarten. Addressed other misc review comments from Maarten. Split the changes to have separate colorspace property for DP and HDMI.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list based on the colorspaces supported by the respective protocol standard.

v5: Made the property creation helper accept enum list based on platform capabilties as suggested by Shashank. Consolidated HDMI and DP property creation in the common helper.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian Starkey's suggestion in order to go with string matching at userspace. Updated the commit message to add more details as well kernel docs.

v8: Addressed Maarten's review comments.

v9: Removed macro defines from uapi as per Brian Starkey and Daniel Stone's comments and moved to drm include file. Moved back to older design with exposing all HDMI colorspaces to userspace since infoframe capability is there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten and Jani's ack.

v11: Addressed Ville's review comments. Updated the Macro naming and added DCI-P3 colorspace as well defined in CEA 861.G spec.

---
 drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
 drivers/gpu/drm/drm_connector.c   | 78 +++++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h       | 50 +++++++++++++++++++++++++
 3 files changed, 132 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +4 -0
index 9a1f41a..9b5d44f 100644
@@ -746,6 +746,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
 			return -EINVAL;
 		}
 		state->content_protection = val;
+	} else if (property == connector->colorspace_property) {
+		state->colorspace = val;
 	} else if (property == config->writeback_fb_id_property) {
 		struct drm_framebuffer *fb = drm_framebuffer_lookup(dev, NULL, val);
 		int ret = drm_atomic_set_writeback_fb_for_connector(state, fb);
@@ -814,6 +816,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
 		*val = state->picture_aspect_ratio;
 	} else if (property == config->content_type_property) {
 		*val = state->content_type;
+	} else if (property == connector->colorspace_property) {
+		*val = state->colorspace;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
 	} else if (property == connector->content_protection_property) {
drivers/gpu/drm/drm_connector.c +78 -0
index 8475396..4309873 100644
@@ -826,6 +826,33 @@ int drm_display_info_set_bus_formats(struct drm_display_info *info,
 };
 DRM_ENUM_NAME_FN(drm_get_content_protection_name, drm_cp_enum_list)
 
+static const struct drm_prop_enum_list hdmi_colorspaces[] = {
+	/* For Default case, driver will set the colorspace */
+	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+	/* Standard Definition Colorimetry based on CEA 861 */
+	{ DRM_MODE_COLORIMETRY_SMPTE_170M, "SMPTE_170M" },
+	{ DRM_MODE_COLORIMETRY_BT709, "BT709" },
+	/* Standard Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+	/* High Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+	/* Colorimetry based on IEC 61966-2-1/Amendment 1 */
+	{ DRM_MODE_COLORIMETRY_SYCC_601, "SYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 [33] */
+	{ DRM_MODE_COLORIMETRY_OPYCC_601, "opYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 */
+	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_CYCC, "BT2020_CYCC" },
+	/* Added as part of Additional Colorimetry Extension in 861.G */
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-P3_RGB_D65" },
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-P3_RGB_Theater" },
+};
+
 /**
  * DOC: standard connector properties
  *
@@ -1548,6 +1575,57 @@ int drm_mode_create_aspect_ratio_property(struct drm_device *dev)
 EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);
 
 /**
+ * DOC: standard connector properties
+ *
+ * Colorspace:
+ *     drm_mode_create_colorspace_property - create colorspace property
+ *     This property helps select a suitable colorspace based on the sink
+ *     capability. Modern sink devices support wider gamut like BT2020.
+ *     This helps switch to BT2020 mode if the BT2020 encoded video stream
+ *     is being played by the user, same for any other colorspace. Thereby
+ *     giving a good visual experience to users.
+ *
+ *     The expectation from userspace is that it should parse the EDID
+ *     and get supported colorspaces. Use this property and switch to the
+ *     one supported. Sink supported colorspaces should be retrieved by
+ *     userspace from EDID and driver will not explicitly expose them.
+ *
+ *     Basically the expectation from userspace is:
+ *      - Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink
+ *        colorspace
+ *      - Set this new property to let the sink know what it
+ *        converted the CRTC output to.
+ *      - This property is just to inform sink what colorspace
+ *        source is trying to drive.
+ *
+ * Called by a driver the first time it's needed, must be attached to desired
+ * connectors.
+ */
+int drm_mode_create_colorspace_property(struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA ||
+	    connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) {
+		prop = drm_property_create_enum(dev, DRM_MODE_PROP_ENUM,
+						"Colorspace",
+						hdmi_colorspaces,
+						ARRAY_SIZE(hdmi_colorspaces));
+		if (!prop)
+			return -ENOMEM;
+	} else {
+		DRM_DEBUG_KMS("Colorspace property not supported\n");
+		return 0;
+	}
+
+	connector->colorspace_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_colorspace_property);
+
+/**
  * drm_mode_create_content_type_property - create content type property
  * @dev: DRM device
  *
include/drm/drm_connector.h +5 -0
index 9941613..58db66e 100644
@@ -253,6 +253,42 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/*
+ * This is a consolidated colorimetry list supported by HDMI and
+ * DP protocol standard. The respective connectors will register
+ * a property with the subset of this list (supported by that
+ * respective protocol). Userspace will set the colorspace through

include/drm/drm_connector.h enum drm_panel_orientation { · line 270

Quoted 10 lines
include/drm/drm_connector.h +10 -0
+ * a colorspace property which will be created and exposed to
+ * userspace.
+ */
+
+/* For Default case, driver will set the colorspace */
+#define DRM_MODE_COLORIMETRY_DEFAULT			0
+/* CEA 861 Normal Colorimetry options */
+#define DRM_MODE_COLORIMETRY_NO_DATA			0
+#define DRM_MODE_COLORIMETRY_SMPTE_170M			1
+#define DRM_MODE_COLORIMETRY_BT709			2

Still missing the YCbCr information in these two.

include/drm/drm_connector.h enum drm_panel_orientation { · line 280

Quoted 10 lines
include/drm/drm_connector.h +10 -0
+/* CEA 861 Extended Colorimetry Options */
+#define DRM_MODE_COLORIMETRY_XVYCC_601			3
+#define DRM_MODE_COLORIMETRY_XVYCC_709			4
+#define DRM_MODE_COLORIMETRY_SYCC_601			5
+#define DRM_MODE_COLORIMETRY_OPYCC_601			6
+#define DRM_MODE_COLORIMETRY_OPRGB			7
+#define DRM_MODE_COLORIMETRY_BT2020_YCC			8
+/* Both BT2020_RGB and BT2020_YCbCbCr have same value */
+#define DRM_MODE_COLORIMETRY_BT2020_RGB			9
+#define DRM_MODE_COLORIMETRY_BT2020_CYCC		9

I though you didn't want these numbers to be based on the spec numbers? This duplicated value seems to go against that idea.

include/drm/drm_connector.h enum drm_panel_orientation { · line 287

Quoted 7 lines
include/drm/drm_connector.h +7 -0
+/* Additional Colorimetry extension added as part of CTA 861.G */
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65		10
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER		11
+
+/* DP MSA Colorimetry Options */
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_601		12
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_709		13

Still inconsistent naming in many places (ITU_ vs. BT, YCBCR vs. YCC, order of the two).

Quoted 49 lines
include/drm/drm_connector.h +18 -0
+#define DRM_MODE_DP_COLORIMETRY_SRGB			14
+#define DRM_MODE_DP_COLORIMETRY_RGB_WIDE_GAMUT		15
+#define DRM_MODE_DP_COLORIMETRY_SCRGB			16
+
 /**
  * struct drm_display_info - runtime data about the connected sink
  *
@@ -503,6 +539,13 @@ struct drm_connector_state {
 	unsigned int content_protection;
 
 	/**
+	 * @colorspace: State variable for Connector property to request
+	 * colorspace change on Sink. This is most commonly used to switch
+	 * to wider color gamuts like BT2020.
+	 */
+	u32 colorspace;
+
+	/**
 	 * @writeback_job: Writeback job for writeback connectors
 	 *
 	 * Holds the framebuffer and out-fence for a writeback connector. As
@@ -995,6 +1038,12 @@ struct drm_connector {
 	struct drm_property *content_protection_property;
 
 	/**
+	 * @colorspace_property: Connector property to set the suitable
+	 * colorspace supported by the sink.
+	 */
+	struct drm_property *colorspace_property;
+
+	/**
 	 * @path_blob_ptr:
 	 *
 	 * DRM blob property data for the DP MST path property. This should only
@@ -1269,6 +1318,7 @@ int drm_connector_attach_vrr_capable_property(
 int drm_connector_attach_content_protection_property(
 		struct drm_connector *connector);
 int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
+int drm_mode_create_colorspace_property(struct drm_connector *connector);
 int drm_mode_create_content_type_property(struct drm_device *dev);
 void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe *frame,
 					 const struct drm_connector_state *conn_state);
Signature · 6 lines
1.9.1

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

Re: [v11 1/4] drm: Add HDMI colorspace property

Quoted 227 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, February 5, 2019 10:02 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 59 lines · Uma Shankar

Create a new connector property to program colorspace to sink devices. Modern sink devices support more than 1 type of colorspace like 601, 709, BT2020 etc. This helps to switch based on content type which is to be displayed. The decision lies with compositors as to in which scenarios, a particular colorspace will be picked.

This will be helpful mostly to switch to higher gamut colorspaces like BT2020 when the media content is encoded as BT2020. Thereby giving a good visual experience to users.

The expectation from userspace is that it should parse the EDID and get supported colorspaces. Use this property and switch to the one supported. Sink supported colorspaces should be retrieved by userspace from EDID and driver will not explicitly expose them.

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink colorspace
- Set this new property to let the sink know what it converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments. Enhanced the colorspace enum to incorporate both HDMI and DP supported colorspaces. Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as per Ville, Hans Verkuil and Jonas Karlman suggestions. Changed Default to an unset state where driver will assign the colorspace is not chosen by user, suggested by Ville and Maarten. Addressed other misc review comments from Maarten. Split the changes to have separate colorspace property for DP and HDMI.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list based on the colorspaces supported by the respective protocol standard.

v5: Made the property creation helper accept enum list based on platform capabilties as suggested by Shashank. Consolidated HDMI and DP property creation in the common helper.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian Starkey's suggestion in order to go with string matching at userspace. Updated the commit message to add more details as well kernel docs.

v8: Addressed Maarten's review comments.

v9: Removed macro defines from uapi as per Brian Starkey and Daniel Stone's comments and moved to drm include file. Moved back to older design with exposing all HDMI colorspaces to userspace since infoframe capability is there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten and Jani's ack.

v11: Addressed Ville's review comments. Updated the Macro naming and added DCI-P3 colorspace as well defined in CEA 861.G spec.

Quoted 7 lines
---
 drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
 drivers/gpu/drm/drm_connector.c   | 78

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

drivers/gpu/drm/drm_atomic_uapi.c static int drm_atomic_connector_set_property(struct

Quoted 9 lines
 include/drm/drm_connector.h       | 50 +++++++++++++++++++++++++
 3 files changed, 132 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +0 -0
index 9a1f41a..9b5d44f 100644
@@ -746,6 +746,8 @@ static int drm_atomic_connector_set_property(struct

drm_connector *connector,

drivers/gpu/drm/drm_atomic_uapi.c static int drm_atomic_connector_set_property(struct drm_connector *connector,

Quoted 7 lines
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
 			return -EINVAL;
 		}
 		state->content_protection = val;
+	} else if (property == connector->colorspace_property) {
+		state->colorspace = val;
 	} else if (property == config->writeback_fb_id_property) {
 		struct drm_framebuffer *fb = drm_framebuffer_lookup(dev,

NULL, val);

drivers/gpu/drm/drm_atomic_uapi.c static int drm_atomic_connector_set_property(struct · line 753

Quoted 1 line
drivers/gpu/drm/drm_atomic_uapi.c +0 -0
 		int ret = drm_atomic_set_writeback_fb_for_connector(state,

fb); @@

Quoted 1 line

-814,6 +816,8 @@ static int drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 13 lines
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
 		*val = state->picture_aspect_ratio;
 	} else if (property == config->content_type_property) {
 		*val = state->content_type;
+	} else if (property == connector->colorspace_property) {
+		*val = state->colorspace;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
 	} else if (property == connector->content_protection_property) {
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_connector.c index 8475396..4309873 100644

drivers/gpu/drm/drm_connector.c int drm_display_info_set_bus_formats(struct · line 827

Quoted 2 lines
drivers/gpu/drm/drm_connector.c +0 -0
@@ -826,6 +826,33 @@ int drm_display_info_set_bus_formats(struct
 drm_display_info *info,  };
 DRM_ENUM_NAME_FN(drm_get_content_protection_name,

drm_cp_enum_list)

Quoted 16 lines
drivers/gpu/drm/drm_connector.c +15 -0
+static const struct drm_prop_enum_list hdmi_colorspaces[] = {
+	/* For Default case, driver will set the colorspace */
+	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+	/* Standard Definition Colorimetry based on CEA 861 */
+	{ DRM_MODE_COLORIMETRY_SMPTE_170M, "SMPTE_170M" },
+	{ DRM_MODE_COLORIMETRY_BT709, "BT709" },
+	/* Standard Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+	/* High Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+	/* Colorimetry based on IEC 61966-2-1/Amendment 1 */
+	{ DRM_MODE_COLORIMETRY_SYCC_601, "SYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 [33] */
+	{ DRM_MODE_COLORIMETRY_OPYCC_601, "opYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 */

drivers/gpu/drm/drm_connector.c int drm_display_info_set_bus_formats(struct drm_display_info *info,

Quoted 10 lines
drivers/gpu/drm/drm_connector.c +10 -0
+	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_CYCC, "BT2020_CYCC" },
+	/* Added as part of Additional Colorimetry Extension in 861.G */
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-P3_RGB_D65" },
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-

P3_RGB_Theater" },

Quoted 35 lines
drivers/gpu/drm/drm_connector.c +27 -0
+};
+
 /**
  * DOC: standard connector properties
  *
@@ -1548,6 +1575,57 @@ int
 drm_mode_create_aspect_ratio_property(struct drm_device *dev)
 EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);
 
 /**
+ * DOC: standard connector properties
+ *
+ * Colorspace:
+ *     drm_mode_create_colorspace_property - create colorspace property
+ *     This property helps select a suitable colorspace based on the sink
+ *     capability. Modern sink devices support wider gamut like BT2020.
+ *     This helps switch to BT2020 mode if the BT2020 encoded video stream
+ *     is being played by the user, same for any other colorspace. Thereby
+ *     giving a good visual experience to users.
+ *
+ *     The expectation from userspace is that it should parse the EDID
+ *     and get supported colorspaces. Use this property and switch to the
+ *     one supported. Sink supported colorspaces should be retrieved by
+ *     userspace from EDID and driver will not explicitly expose them.
+ *
+ *     Basically the expectation from userspace is:
+ *      - Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink
+ *        colorspace
+ *      - Set this new property to let the sink know what it
+ *        converted the CRTC output to.
+ *      - This property is just to inform sink what colorspace
+ *        source is trying to drive.
+ *
+ * Called by a driver the first time it's needed, must be attached to
+desired

drivers/gpu/drm/drm_connector.c int · line 1613

Quoted 10 lines
drivers/gpu/drm/drm_connector.c +10 -0
+ * connectors.
+ */
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA ||
+	    connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) {
+		prop = drm_property_create_enum(dev,

DRM_MODE_PROP_ENUM,

drivers/gpu/drm/drm_connector.c int drm_mode_create_aspect_ratio_property(struct drm_device *dev) · line 1621

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+						"Colorspace",
+						hdmi_colorspaces,
+
	ARRAY_SIZE(hdmi_colorspaces));
Quoted 34 lines
drivers/gpu/drm/drm_connector.c +14 -0
+		if (!prop)
+			return -ENOMEM;
+	} else {
+		DRM_DEBUG_KMS("Colorspace property not supported\n");
+		return 0;
+	}
+
+	connector->colorspace_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_colorspace_property);
+
+/**
  * drm_mode_create_content_type_property - create content type property
  * @dev: DRM device
  *
include/drm/drm_connector.h +9 -0
index 9941613..58db66e 100644
@@ -253,6 +253,42 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/*
+ * This is a consolidated colorimetry list supported by HDMI and
+ * DP protocol standard. The respective connectors will register
+ * a property with the subset of this list (supported by that
+ * respective protocol). Userspace will set the colorspace through
+ * a colorspace property which will be created and exposed to
+ * userspace.
+ */
+
Quoted 8 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 270

Quoted 6 lines
include/drm/drm_connector.h +6 -0
+/* For Default case, driver will set the colorspace */
+#define DRM_MODE_COLORIMETRY_DEFAULT			0
+/* CEA 861 Normal Colorimetry options */
+#define DRM_MODE_COLORIMETRY_NO_DATA			0
+#define DRM_MODE_COLORIMETRY_SMPTE_170M			1
+#define DRM_MODE_COLORIMETRY_BT709			2

Still missing the YCbCr information in these two.

As per CTA 861.G spec, we have these as only SMPTE_170M and ITU-R BT709, with no specific mention of RGB or YCbCr. Hence, kept it as per spec. We seem to have a common field for both as per CTA spec. Correct me if my understanding is wrong.

Quoted 14 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 280

Quoted 11 lines
include/drm/drm_connector.h +10 -0
+/* CEA 861 Extended Colorimetry Options */
+#define DRM_MODE_COLORIMETRY_XVYCC_601			3
+#define DRM_MODE_COLORIMETRY_XVYCC_709			4
+#define DRM_MODE_COLORIMETRY_SYCC_601			5
+#define DRM_MODE_COLORIMETRY_OPYCC_601			6
+#define DRM_MODE_COLORIMETRY_OPRGB			7
+#define DRM_MODE_COLORIMETRY_BT2020_YCC			8
+/* Both BT2020_RGB and BT2020_YCbCbCr have same value */
+#define DRM_MODE_COLORIMETRY_BT2020_RGB			9
+#define DRM_MODE_COLORIMETRY_BT2020_CYCC		9

I though you didn't want these numbers to be based on the spec numbers? This duplicated value seems to go against that idea.

Yeah, for HDMI somehow was trying to utilize the definitions to advantage. But I feel, It's better to de-couple this. Define this as normal enum values sequentially so that userspace get readable serial number kind values.
And use these in encoder files to get proper values to be programmed as per respective spec, while defining those values per encoder separately. Hope this is fine.

Quoted 10 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 287

Quoted 7 lines
include/drm/drm_connector.h +7 -0
+/* Additional Colorimetry extension added as part of CTA 861.G */
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65		10
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER		11
+
+/* DP MSA Colorimetry Options */
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_601		12
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_709		13

Still inconsistent naming in many places (ITU_ vs. BT, YCBCR vs. YCC, order of the two).

Will fix this. Thanks Ville.

Quoted 50 lines
Quoted 43 lines
include/drm/drm_connector.h +17 -0
+#define DRM_MODE_DP_COLORIMETRY_SRGB			14
+#define DRM_MODE_DP_COLORIMETRY_RGB_WIDE_GAMUT		15
+#define DRM_MODE_DP_COLORIMETRY_SCRGB			16
+
 /**
  * struct drm_display_info - runtime data about the connected sink
  *
@@ -503,6 +539,13 @@ struct drm_connector_state {
 	unsigned int content_protection;
 
 	/**
+	 * @colorspace: State variable for Connector property to request
+	 * colorspace change on Sink. This is most commonly used to switch
+	 * to wider color gamuts like BT2020.
+	 */
+	u32 colorspace;
+
+	/**
 	 * @writeback_job: Writeback job for writeback connectors
 	 *
 	 * Holds the framebuffer and out-fence for a writeback connector. As
@@ -995,6 +1038,12 @@ struct drm_connector {
 	struct drm_property *content_protection_property;
 
 	/**
+	 * @colorspace_property: Connector property to set the suitable
+	 * colorspace supported by the sink.
+	 */
+	struct drm_property *colorspace_property;
+
+	/**
 	 * @path_blob_ptr:
 	 *
 	 * DRM blob property data for the DP MST path property. This should

only @@ -1269,6 +1318,7 @@ int drm_connector_attach_vrr_capable_property(
int drm_connector_attach_content_protection_property(

include/drm/drm_connector.h +2 -0
 		struct drm_connector *connector);
 int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector);
 int drm_mode_create_content_type_property(struct drm_device *dev);
Quoted 1 line

void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe

*frame,

Quoted 1 line

const struct drm_connector_state

*conn_state);

Quoted 3 lines

--
1.9.1

Quoted 8 lines
Quoted 4 lines

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

--
Ville Syrjälä
Intel

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

#4 lore raw

Re: [v11 1/4] drm: Add HDMI colorspace property

Quoted 236 lines · Uma
Quoted 227 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, February 5, 2019 10:02 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 59 lines · Uma Shankar

Create a new connector property to program colorspace to sink devices. Modern sink devices support more than 1 type of colorspace like 601, 709, BT2020 etc. This helps to switch based on content type which is to be displayed. The decision lies with compositors as to in which scenarios, a particular colorspace will be picked.

This will be helpful mostly to switch to higher gamut colorspaces like BT2020 when the media content is encoded as BT2020. Thereby giving a good visual experience to users.

The expectation from userspace is that it should parse the EDID and get supported colorspaces. Use this property and switch to the one supported. Sink supported colorspaces should be retrieved by userspace from EDID and driver will not explicitly expose them.

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink colorspace
- Set this new property to let the sink know what it converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments. Enhanced the colorspace enum to incorporate both HDMI and DP supported colorspaces. Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as per Ville, Hans Verkuil and Jonas Karlman suggestions. Changed Default to an unset state where driver will assign the colorspace is not chosen by user, suggested by Ville and Maarten. Addressed other misc review comments from Maarten. Split the changes to have separate colorspace property for DP and HDMI.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list based on the colorspaces supported by the respective protocol standard.

v5: Made the property creation helper accept enum list based on platform capabilties as suggested by Shashank. Consolidated HDMI and DP property creation in the common helper.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian Starkey's suggestion in order to go with string matching at userspace. Updated the commit message to add more details as well kernel docs.

v8: Addressed Maarten's review comments.

v9: Removed macro defines from uapi as per Brian Starkey and Daniel Stone's comments and moved to drm include file. Moved back to older design with exposing all HDMI colorspaces to userspace since infoframe capability is there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten and Jani's ack.

v11: Addressed Ville's review comments. Updated the Macro naming and added DCI-P3 colorspace as well defined in CEA 861.G spec.

Quoted 7 lines
---
 drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
 drivers/gpu/drm/drm_connector.c   | 78

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

drivers/gpu/drm/drm_atomic_uapi.c static int drm_atomic_connector_set_property(struct

Quoted 9 lines
 include/drm/drm_connector.h       | 50 +++++++++++++++++++++++++
 3 files changed, 132 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +0 -0
index 9a1f41a..9b5d44f 100644
@@ -746,6 +746,8 @@ static int drm_atomic_connector_set_property(struct

drm_connector *connector,

drivers/gpu/drm/drm_atomic_uapi.c static int drm_atomic_connector_set_property(struct drm_connector *connector,

Quoted 7 lines
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
 			return -EINVAL;
 		}
 		state->content_protection = val;
+	} else if (property == connector->colorspace_property) {
+		state->colorspace = val;
 	} else if (property == config->writeback_fb_id_property) {
 		struct drm_framebuffer *fb = drm_framebuffer_lookup(dev,

NULL, val);

drivers/gpu/drm/drm_atomic_uapi.c static int drm_atomic_connector_set_property(struct · line 753

Quoted 1 line
drivers/gpu/drm/drm_atomic_uapi.c +0 -0
 		int ret = drm_atomic_set_writeback_fb_for_connector(state,

fb); @@

Quoted 1 line

-814,6 +816,8 @@ static int drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 13 lines
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
 		*val = state->picture_aspect_ratio;
 	} else if (property == config->content_type_property) {
 		*val = state->content_type;
+	} else if (property == connector->colorspace_property) {
+		*val = state->colorspace;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
 	} else if (property == connector->content_protection_property) {
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_connector.c index 8475396..4309873 100644

drivers/gpu/drm/drm_connector.c int drm_display_info_set_bus_formats(struct · line 827

Quoted 2 lines
drivers/gpu/drm/drm_connector.c +0 -0
@@ -826,6 +826,33 @@ int drm_display_info_set_bus_formats(struct
 drm_display_info *info,  };
 DRM_ENUM_NAME_FN(drm_get_content_protection_name,

drm_cp_enum_list)

Quoted 16 lines
drivers/gpu/drm/drm_connector.c +15 -0
+static const struct drm_prop_enum_list hdmi_colorspaces[] = {
+	/* For Default case, driver will set the colorspace */
+	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+	/* Standard Definition Colorimetry based on CEA 861 */
+	{ DRM_MODE_COLORIMETRY_SMPTE_170M, "SMPTE_170M" },
+	{ DRM_MODE_COLORIMETRY_BT709, "BT709" },
+	/* Standard Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+	/* High Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+	/* Colorimetry based on IEC 61966-2-1/Amendment 1 */
+	{ DRM_MODE_COLORIMETRY_SYCC_601, "SYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 [33] */
+	{ DRM_MODE_COLORIMETRY_OPYCC_601, "opYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 */

drivers/gpu/drm/drm_connector.c int drm_display_info_set_bus_formats(struct drm_display_info *info,

Quoted 10 lines
drivers/gpu/drm/drm_connector.c +10 -0
+	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_CYCC, "BT2020_CYCC" },
+	/* Added as part of Additional Colorimetry Extension in 861.G */
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-P3_RGB_D65" },
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-

P3_RGB_Theater" },

Quoted 35 lines
drivers/gpu/drm/drm_connector.c +27 -0
+};
+
 /**
  * DOC: standard connector properties
  *
@@ -1548,6 +1575,57 @@ int
 drm_mode_create_aspect_ratio_property(struct drm_device *dev)
 EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);
 
 /**
+ * DOC: standard connector properties
+ *
+ * Colorspace:
+ *     drm_mode_create_colorspace_property - create colorspace property
+ *     This property helps select a suitable colorspace based on the sink
+ *     capability. Modern sink devices support wider gamut like BT2020.
+ *     This helps switch to BT2020 mode if the BT2020 encoded video stream
+ *     is being played by the user, same for any other colorspace. Thereby
+ *     giving a good visual experience to users.
+ *
+ *     The expectation from userspace is that it should parse the EDID
+ *     and get supported colorspaces. Use this property and switch to the
+ *     one supported. Sink supported colorspaces should be retrieved by
+ *     userspace from EDID and driver will not explicitly expose them.
+ *
+ *     Basically the expectation from userspace is:
+ *      - Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink
+ *        colorspace
+ *      - Set this new property to let the sink know what it
+ *        converted the CRTC output to.
+ *      - This property is just to inform sink what colorspace
+ *        source is trying to drive.
+ *
+ * Called by a driver the first time it's needed, must be attached to
+desired

drivers/gpu/drm/drm_connector.c int · line 1613

Quoted 10 lines
drivers/gpu/drm/drm_connector.c +10 -0
+ * connectors.
+ */
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA ||
+	    connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) {
+		prop = drm_property_create_enum(dev,

DRM_MODE_PROP_ENUM,

drivers/gpu/drm/drm_connector.c int drm_mode_create_aspect_ratio_property(struct drm_device *dev) · line 1621

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+						"Colorspace",
+						hdmi_colorspaces,
+
	ARRAY_SIZE(hdmi_colorspaces));
Quoted 34 lines
drivers/gpu/drm/drm_connector.c +14 -0
+		if (!prop)
+			return -ENOMEM;
+	} else {
+		DRM_DEBUG_KMS("Colorspace property not supported\n");
+		return 0;
+	}
+
+	connector->colorspace_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_colorspace_property);
+
+/**
  * drm_mode_create_content_type_property - create content type property
  * @dev: DRM device
  *
include/drm/drm_connector.h +9 -0
index 9941613..58db66e 100644
@@ -253,6 +253,42 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/*
+ * This is a consolidated colorimetry list supported by HDMI and
+ * DP protocol standard. The respective connectors will register
+ * a property with the subset of this list (supported by that
+ * respective protocol). Userspace will set the colorspace through
+ * a colorspace property which will be created and exposed to
+ * userspace.
+ */
+
Quoted 8 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 270

Quoted 6 lines
include/drm/drm_connector.h +6 -0
+/* For Default case, driver will set the colorspace */
+#define DRM_MODE_COLORIMETRY_DEFAULT			0
+/* CEA 861 Normal Colorimetry options */
+#define DRM_MODE_COLORIMETRY_NO_DATA			0
+#define DRM_MODE_COLORIMETRY_SMPTE_170M			1
+#define DRM_MODE_COLORIMETRY_BT709			2

Still missing the YCbCr information in these two.

Quoted 4 lines

As per CTA 861.G spec, we have these as only SMPTE_170M and ITU-R BT709, with no specific mention of RGB or YCbCr. Hence, kept it as per spec. We seem to have a common field for both as per CTA spec. Correct me if my understanding is wrong.

Check
"Table 14 Picture Colorimetry Indicated by the RGB or YC B C R (Y),
Colorimetry (C) and Extended Colorimetry (EC) Field Settings"

Quoted 93 lines
Quoted 15 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 280

Quoted 12 lines
include/drm/drm_connector.h +10 -0
+/* CEA 861 Extended Colorimetry Options */
+#define DRM_MODE_COLORIMETRY_XVYCC_601			3
+#define DRM_MODE_COLORIMETRY_XVYCC_709			4
+#define DRM_MODE_COLORIMETRY_SYCC_601			5
+#define DRM_MODE_COLORIMETRY_OPYCC_601			6
+#define DRM_MODE_COLORIMETRY_OPRGB			7
+#define DRM_MODE_COLORIMETRY_BT2020_YCC			8
+/* Both BT2020_RGB and BT2020_YCbCbCr have same value */
+#define DRM_MODE_COLORIMETRY_BT2020_RGB			9
+#define DRM_MODE_COLORIMETRY_BT2020_CYCC		9

I though you didn't want these numbers to be based on the spec numbers? This duplicated value seems to go against that idea.

Yeah, for HDMI somehow was trying to utilize the definitions to advantage. But I feel, It's better to de-couple this. Define this as normal enum values sequentially so that userspace get readable serial number kind values.
And use these in encoder files to get proper values to be programmed as per respective spec, while defining those values per encoder separately. Hope this is fine.

Quoted 10 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 287

Quoted 7 lines
include/drm/drm_connector.h +7 -0
+/* Additional Colorimetry extension added as part of CTA 861.G */
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65		10
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER		11
+
+/* DP MSA Colorimetry Options */
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_601		12
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_709		13

Still inconsistent naming in many places (ITU_ vs. BT, YCBCR vs. YCC, order of the two).

Will fix this. Thanks Ville.

Quoted 58 lines
Quoted 43 lines
include/drm/drm_connector.h +17 -0
+#define DRM_MODE_DP_COLORIMETRY_SRGB			14
+#define DRM_MODE_DP_COLORIMETRY_RGB_WIDE_GAMUT		15
+#define DRM_MODE_DP_COLORIMETRY_SCRGB			16
+
 /**
  * struct drm_display_info - runtime data about the connected sink
  *
@@ -503,6 +539,13 @@ struct drm_connector_state {
 	unsigned int content_protection;
 
 	/**
+	 * @colorspace: State variable for Connector property to request
+	 * colorspace change on Sink. This is most commonly used to switch
+	 * to wider color gamuts like BT2020.
+	 */
+	u32 colorspace;
+
+	/**
 	 * @writeback_job: Writeback job for writeback connectors
 	 *
 	 * Holds the framebuffer and out-fence for a writeback connector. As
@@ -995,6 +1038,12 @@ struct drm_connector {
 	struct drm_property *content_protection_property;
 
 	/**
+	 * @colorspace_property: Connector property to set the suitable
+	 * colorspace supported by the sink.
+	 */
+	struct drm_property *colorspace_property;
+
+	/**
 	 * @path_blob_ptr:
 	 *
 	 * DRM blob property data for the DP MST path property. This should

only @@ -1269,6 +1318,7 @@ int drm_connector_attach_vrr_capable_property(
int drm_connector_attach_content_protection_property(

include/drm/drm_connector.h +2 -0
 		struct drm_connector *connector);
 int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector);
 int drm_mode_create_content_type_property(struct drm_device *dev);
Quoted 1 line

void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe

*frame,

Quoted 1 line

const struct drm_connector_state

*conn_state);

Quoted 7 lines

--
1.9.1

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

--
Ville Syrjälä
Intel

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

Re: [v11 1/4] drm: Add HDMI colorspace property

Quoted 254 lines

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Ville Syrjälä
Sent: Tuesday, February 5, 2019 11:43 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>; dri- [email protected]
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 222 lines · Uma
Quoted 222 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, February 5, 2019 10:02 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 60 lines · Uma Shankar

Create a new connector property to program colorspace to sink devices. Modern sink devices support more than 1 type of colorspace like 601, 709, BT2020 etc. This helps to switch based on content type which is to be displayed. The decision lies with compositors as to in which scenarios, a particular colorspace will be picked.

This will be helpful mostly to switch to higher gamut colorspaces like
BT2020 when the media content is encoded as BT2020. Thereby giving a good visual experience to users.

The expectation from userspace is that it should parse the EDID and get supported colorspaces. Use this property and switch to the one supported. Sink supported colorspaces should be retrieved by userspace from EDID and driver will not explicitly expose them.

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink colorspace
- Set this new property to let the sink know what it converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments. Enhanced the colorspace enum to incorporate both HDMI and DP supported colorspaces. Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as per Ville, Hans Verkuil and Jonas Karlman suggestions. Changed Default to an unset state where driver will assign the colorspace is not chosen by user, suggested by Ville and Maarten. Addressed other misc review comments from Maarten. Split the changes to have separate colorspace property for DP and HDMI.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list based on the colorspaces supported by the respective protocol standard.

v5: Made the property creation helper accept enum list based on platform capabilties as suggested by Shashank. Consolidated HDMI and DP property creation in the common helper.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian Starkey's suggestion in order to go with string matching at userspace. Updated the commit message to add more details as well kernel docs.

v8: Addressed Maarten's review comments.

v9: Removed macro defines from uapi as per Brian Starkey and Daniel Stone's comments and moved to drm include file. Moved back to older design with exposing all HDMI colorspaces to userspace since infoframe capability is there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten and Jani's ack.

v11: Addressed Ville's review comments. Updated the Macro naming and added DCI-P3 colorspace as well defined in CEA 861.G spec.

Quoted 7 lines
---
 drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
 drivers/gpu/drm/drm_connector.c   | 78

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

Quoted 10 lines
 include/drm/drm_connector.h       | 50 +++++++++++++++++++++++++
 3 files changed, 132 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +0 -0
index 9a1f41a..9b5d44f 100644
@@ -746,6 +746,8 @@ static int

drm_atomic_connector_set_property(struct

drm_connector *connector,

drivers/gpu/drm/drm_atomic_uapi.c static int drm_atomic_connector_set_property(struct drm_connector *connector,

Quoted 7 lines
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
 			return -EINVAL;
 		}
 		state->content_protection = val;
+	} else if (property == connector->colorspace_property) {
+		state->colorspace = val;
 	} else if (property == config->writeback_fb_id_property) {
 		struct drm_framebuffer *fb = drm_framebuffer_lookup(dev,

NULL, val);

Quoted 1 line

int ret = drm_atomic_set_writeback_fb_for_connector(state,

fb); @@

Quoted 2 lines

-814,6 +816,8 @@ static int
drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 13 lines
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
 		*val = state->picture_aspect_ratio;
 	} else if (property == config->content_type_property) {
 		*val = state->content_type;
+	} else if (property == connector->colorspace_property) {
+		*val = state->colorspace;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
 	} else if (property == connector->content_protection_property) {
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_connector.c index 8475396..4309873 100644

drivers/gpu/drm/drm_connector.c int drm_display_info_set_bus_formats(struct · line 827

Quoted 2 lines
drivers/gpu/drm/drm_connector.c +0 -0
@@ -826,6 +826,33 @@ int drm_display_info_set_bus_formats(struct
 drm_display_info *info,  };
 DRM_ENUM_NAME_FN(drm_get_content_protection_name,

drm_cp_enum_list)

Quoted 16 lines
drivers/gpu/drm/drm_connector.c +15 -0
+static const struct drm_prop_enum_list hdmi_colorspaces[] = {
+	/* For Default case, driver will set the colorspace */
+	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+	/* Standard Definition Colorimetry based on CEA 861 */
+	{ DRM_MODE_COLORIMETRY_SMPTE_170M, "SMPTE_170M" },
+	{ DRM_MODE_COLORIMETRY_BT709, "BT709" },
+	/* Standard Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+	/* High Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+	/* Colorimetry based on IEC 61966-2-1/Amendment 1 */
+	{ DRM_MODE_COLORIMETRY_SYCC_601, "SYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 [33] */
+	{ DRM_MODE_COLORIMETRY_OPYCC_601, "opYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 */

drivers/gpu/drm/drm_connector.c int drm_display_info_set_bus_formats(struct drm_display_info *info,

Quoted 10 lines
drivers/gpu/drm/drm_connector.c +10 -0
+	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_CYCC, "BT2020_CYCC" },
+	/* Added as part of Additional Colorimetry Extension in 861.G */
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-P3_RGB_D65" },
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-

P3_RGB_Theater" },

Quoted 35 lines
drivers/gpu/drm/drm_connector.c +27 -0
+};
+
 /**
  * DOC: standard connector properties
  *
@@ -1548,6 +1575,57 @@ int
 drm_mode_create_aspect_ratio_property(struct drm_device *dev)
 EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);
 
 /**
+ * DOC: standard connector properties
+ *
+ * Colorspace:
+ *     drm_mode_create_colorspace_property - create colorspace property
+ *     This property helps select a suitable colorspace based on the sink
+ *     capability. Modern sink devices support wider gamut like BT2020.
+ *     This helps switch to BT2020 mode if the BT2020 encoded video stream
+ *     is being played by the user, same for any other colorspace. Thereby
+ *     giving a good visual experience to users.
+ *
+ *     The expectation from userspace is that it should parse the EDID
+ *     and get supported colorspaces. Use this property and switch to the
+ *     one supported. Sink supported colorspaces should be retrieved by
+ *     userspace from EDID and driver will not explicitly expose them.
+ *
+ *     Basically the expectation from userspace is:
+ *      - Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink
+ *        colorspace
+ *      - Set this new property to let the sink know what it
+ *        converted the CRTC output to.
+ *      - This property is just to inform sink what colorspace
+ *        source is trying to drive.
+ *
+ * Called by a driver the first time it's needed, must be attached
+to desired

drivers/gpu/drm/drm_connector.c int · line 1613

Quoted 10 lines
drivers/gpu/drm/drm_connector.c +10 -0
+ * connectors.
+ */
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA ||
+	    connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) {
+		prop = drm_property_create_enum(dev,

DRM_MODE_PROP_ENUM,

drivers/gpu/drm/drm_connector.c int drm_mode_create_aspect_ratio_property(struct drm_device *dev) · line 1621

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+						"Colorspace",
+						hdmi_colorspaces,
+
	ARRAY_SIZE(hdmi_colorspaces));
Quoted 25 lines
drivers/gpu/drm/drm_connector.c +14 -0
+		if (!prop)
+			return -ENOMEM;
+	} else {
+		DRM_DEBUG_KMS("Colorspace property not supported\n");
+		return 0;
+	}
+
+	connector->colorspace_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_colorspace_property);
+
+/**
  * drm_mode_create_content_type_property - create content type property
  * @dev: DRM device
  *
(quoted diff) +0 -0

b/include/drm/drm_connector.h index 9941613..58db66e 100644

include/drm/drm_connector.h +0 -0
@@ -253,6 +253,42 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
include/drm/drm_connector.h +6 -0
+/*
+ * This is a consolidated colorimetry list supported by HDMI and
+ * DP protocol standard. The respective connectors will register
+ * a property with the subset of this list (supported by that
+ * respective protocol). Userspace will set the colorspace through
+ * a colorspace property which will be created and exposed to
Quoted 8 lines

include/drm/drm_connector.h enum drm_panel_orientation {

Quoted 8 lines
include/drm/drm_connector.h +8 -0
+ * userspace.
+ */
+
+/* For Default case, driver will set the colorspace */
+#define DRM_MODE_COLORIMETRY_DEFAULT			0
+/* CEA 861 Normal Colorimetry options */
+#define DRM_MODE_COLORIMETRY_NO_DATA			0
+#define DRM_MODE_COLORIMETRY_SMPTE_170M
	1
Quoted 4 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 270

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_BT709			2

Still missing the YCbCr information in these two.

Quoted 8 lines
Quoted 4 lines

As per CTA 861.G spec, we have these as only SMPTE_170M and ITU-R BT709, with no specific mention of RGB or YCbCr. Hence, kept it as per spec. We seem to have a common field for both as per CTA spec. Correct me if my understanding is wrong.

Check
"Table 14 Picture Colorimetry Indicated by the RGB or YC B C R (Y), Colorimetry
(C) and Extended Colorimetry (EC) Field Settings"

These Y2 Y1 Y0 values should be programmed separately and not through the colorspace as they are data formats isn't it. I feel this should get controlled separately independent of colorimetry, or should we add all the YCbCr and RGB versions and program them as part of this property itself ?

My idea was just to update colorimetry fields alone as part of this interface.

Quoted 98 lines
Quoted 16 lines
Quoted 15 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 280

Quoted 12 lines
include/drm/drm_connector.h +10 -0
+/* CEA 861 Extended Colorimetry Options */
+#define DRM_MODE_COLORIMETRY_XVYCC_601			3
+#define DRM_MODE_COLORIMETRY_XVYCC_709			4
+#define DRM_MODE_COLORIMETRY_SYCC_601			5
+#define DRM_MODE_COLORIMETRY_OPYCC_601			6
+#define DRM_MODE_COLORIMETRY_OPRGB			7
+#define DRM_MODE_COLORIMETRY_BT2020_YCC			8
+/* Both BT2020_RGB and BT2020_YCbCbCr have same value */
+#define DRM_MODE_COLORIMETRY_BT2020_RGB			9
+#define DRM_MODE_COLORIMETRY_BT2020_CYCC		9

I though you didn't want these numbers to be based on the spec numbers? This duplicated value seems to go against that idea.

Quoted 3 lines

Yeah, for HDMI somehow was trying to utilize the definitions to advantage. But I feel, It's better to de-couple this. Define this as normal enum values sequentially so that userspace get readable serial number

kind values.

Quoted 2 lines

And use these in encoder files to get proper values to be programmed as per respective spec, while defining those values per encoder separately.

Hope this is fine.

Quoted 4 lines
Quoted 4 lines

include/drm/drm_connector.h enum drm_panel_orientation {

Quoted 4 lines
include/drm/drm_connector.h +3 -0
+/* Additional Colorimetry extension added as part of CTA 861.G */
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65		10
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER
	11
Quoted 8 lines
Quoted 7 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 287

Quoted 4 lines
include/drm/drm_connector.h +4 -0
+
+/* DP MSA Colorimetry Options */
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_601		12
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_709		13

Still inconsistent naming in many places (ITU_ vs. BT, YCBCR vs. YCC, order of the two).

Quoted 5 lines

Will fix this. Thanks Ville.

Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 289

Quoted 3 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_DP_COLORIMETRY_SRGB			14
+#define DRM_MODE_DP_COLORIMETRY_RGB_WIDE_GAMUT
	15
Quoted 47 lines
Quoted 47 lines
Quoted 40 lines
include/drm/drm_connector.h +9 -0
+#define DRM_MODE_DP_COLORIMETRY_SCRGB			16
+
 /**
  * struct drm_display_info - runtime data about the connected sink
  *
@@ -503,6 +539,13 @@ struct drm_connector_state {
 	unsigned int content_protection;
 
 	/**
+	 * @colorspace: State variable for Connector property to request
+	 * colorspace change on Sink. This is most commonly used to switch
+	 * to wider color gamuts like BT2020.
+	 */
+	u32 colorspace;
+
+	/**
 	 * @writeback_job: Writeback job for writeback connectors
 	 *
 	 * Holds the framebuffer and out-fence for a writeback connector.

As @@ -995,6 +1038,12 @@ struct drm_connector {

include/drm/drm_connector.h +6 -0
 	struct drm_property *content_protection_property;
 
 	/**
+	 * @colorspace_property: Connector property to set the suitable
+	 * colorspace supported by the sink.
+	 */
+	struct drm_property *colorspace_property;
+
+	/**
 	 * @path_blob_ptr:
 	 *
 	 * DRM blob property data for the DP MST path property. This

should only @@ -1269,6 +1318,7 @@ int drm_connector_attach_vrr_capable_property(
int drm_connector_attach_content_protection_property(
struct drm_connector *connector); int
drm_mode_create_aspect_ratio_property(struct drm_device *dev);

include/drm/drm_connector.h +2 -0
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector);
 int drm_mode_create_content_type_property(struct drm_device *dev);
Quoted 1 line

void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe

*frame,

Quoted 1 line

const struct drm_connector_state

*conn_state);

Quoted 3 lines

--
1.9.1

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

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

--
Ville Syrjälä
Intel

Quoted 7 lines

--
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

#6 lore raw

Re: [v11 1/4] drm: Add HDMI colorspace property

Quoted 259 lines · Uma
Quoted 259 lines

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Ville Syrjälä
Sent: Tuesday, February 5, 2019 11:43 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>; dri- [email protected]
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 222 lines · Uma
Quoted 222 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, February 5, 2019 10:02 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 60 lines · Uma Shankar

Create a new connector property to program colorspace to sink devices. Modern sink devices support more than 1 type of colorspace like 601, 709, BT2020 etc. This helps to switch based on content type which is to be displayed. The decision lies with compositors as to in which scenarios, a particular colorspace will be picked.

This will be helpful mostly to switch to higher gamut colorspaces like
BT2020 when the media content is encoded as BT2020. Thereby giving a good visual experience to users.

The expectation from userspace is that it should parse the EDID and get supported colorspaces. Use this property and switch to the one supported. Sink supported colorspaces should be retrieved by userspace from EDID and driver will not explicitly expose them.

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink colorspace
- Set this new property to let the sink know what it converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments. Enhanced the colorspace enum to incorporate both HDMI and DP supported colorspaces. Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as per Ville, Hans Verkuil and Jonas Karlman suggestions. Changed Default to an unset state where driver will assign the colorspace is not chosen by user, suggested by Ville and Maarten. Addressed other misc review comments from Maarten. Split the changes to have separate colorspace property for DP and HDMI.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list based on the colorspaces supported by the respective protocol standard.

v5: Made the property creation helper accept enum list based on platform capabilties as suggested by Shashank. Consolidated HDMI and DP property creation in the common helper.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian Starkey's suggestion in order to go with string matching at userspace. Updated the commit message to add more details as well kernel docs.

v8: Addressed Maarten's review comments.

v9: Removed macro defines from uapi as per Brian Starkey and Daniel Stone's comments and moved to drm include file. Moved back to older design with exposing all HDMI colorspaces to userspace since infoframe capability is there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten and Jani's ack.

v11: Addressed Ville's review comments. Updated the Macro naming and added DCI-P3 colorspace as well defined in CEA 861.G spec.

Quoted 7 lines
---
 drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
 drivers/gpu/drm/drm_connector.c   | 78

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

Quoted 10 lines
 include/drm/drm_connector.h       | 50 +++++++++++++++++++++++++
 3 files changed, 132 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +0 -0
index 9a1f41a..9b5d44f 100644
@@ -746,6 +746,8 @@ static int

drm_atomic_connector_set_property(struct

drm_connector *connector,

drivers/gpu/drm/drm_atomic_uapi.c static int drm_atomic_connector_set_property(struct drm_connector *connector,

Quoted 7 lines
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
 			return -EINVAL;
 		}
 		state->content_protection = val;
+	} else if (property == connector->colorspace_property) {
+		state->colorspace = val;
 	} else if (property == config->writeback_fb_id_property) {
 		struct drm_framebuffer *fb = drm_framebuffer_lookup(dev,

NULL, val);

Quoted 1 line

int ret = drm_atomic_set_writeback_fb_for_connector(state,

fb); @@

Quoted 2 lines

-814,6 +816,8 @@ static int
drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 13 lines
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
 		*val = state->picture_aspect_ratio;
 	} else if (property == config->content_type_property) {
 		*val = state->content_type;
+	} else if (property == connector->colorspace_property) {
+		*val = state->colorspace;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
 	} else if (property == connector->content_protection_property) {
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_connector.c index 8475396..4309873 100644

drivers/gpu/drm/drm_connector.c int drm_display_info_set_bus_formats(struct · line 827

Quoted 2 lines
drivers/gpu/drm/drm_connector.c +0 -0
@@ -826,6 +826,33 @@ int drm_display_info_set_bus_formats(struct
 drm_display_info *info,  };
 DRM_ENUM_NAME_FN(drm_get_content_protection_name,

drm_cp_enum_list)

Quoted 16 lines
drivers/gpu/drm/drm_connector.c +15 -0
+static const struct drm_prop_enum_list hdmi_colorspaces[] = {
+	/* For Default case, driver will set the colorspace */
+	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+	/* Standard Definition Colorimetry based on CEA 861 */
+	{ DRM_MODE_COLORIMETRY_SMPTE_170M, "SMPTE_170M" },
+	{ DRM_MODE_COLORIMETRY_BT709, "BT709" },
+	/* Standard Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+	/* High Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+	/* Colorimetry based on IEC 61966-2-1/Amendment 1 */
+	{ DRM_MODE_COLORIMETRY_SYCC_601, "SYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 [33] */
+	{ DRM_MODE_COLORIMETRY_OPYCC_601, "opYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 */

drivers/gpu/drm/drm_connector.c int drm_display_info_set_bus_formats(struct drm_display_info *info,

Quoted 10 lines
drivers/gpu/drm/drm_connector.c +10 -0
+	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_CYCC, "BT2020_CYCC" },
+	/* Added as part of Additional Colorimetry Extension in 861.G */
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-P3_RGB_D65" },
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-

P3_RGB_Theater" },

Quoted 35 lines
drivers/gpu/drm/drm_connector.c +27 -0
+};
+
 /**
  * DOC: standard connector properties
  *
@@ -1548,6 +1575,57 @@ int
 drm_mode_create_aspect_ratio_property(struct drm_device *dev)
 EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);
 
 /**
+ * DOC: standard connector properties
+ *
+ * Colorspace:
+ *     drm_mode_create_colorspace_property - create colorspace property
+ *     This property helps select a suitable colorspace based on the sink
+ *     capability. Modern sink devices support wider gamut like BT2020.
+ *     This helps switch to BT2020 mode if the BT2020 encoded video stream
+ *     is being played by the user, same for any other colorspace. Thereby
+ *     giving a good visual experience to users.
+ *
+ *     The expectation from userspace is that it should parse the EDID
+ *     and get supported colorspaces. Use this property and switch to the
+ *     one supported. Sink supported colorspaces should be retrieved by
+ *     userspace from EDID and driver will not explicitly expose them.
+ *
+ *     Basically the expectation from userspace is:
+ *      - Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink
+ *        colorspace
+ *      - Set this new property to let the sink know what it
+ *        converted the CRTC output to.
+ *      - This property is just to inform sink what colorspace
+ *        source is trying to drive.
+ *
+ * Called by a driver the first time it's needed, must be attached
+to desired

drivers/gpu/drm/drm_connector.c int · line 1613

Quoted 10 lines
drivers/gpu/drm/drm_connector.c +10 -0
+ * connectors.
+ */
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (connector->connector_type == DRM_MODE_CONNECTOR_HDMIA ||
+	    connector->connector_type == DRM_MODE_CONNECTOR_HDMIB) {
+		prop = drm_property_create_enum(dev,

DRM_MODE_PROP_ENUM,

drivers/gpu/drm/drm_connector.c int drm_mode_create_aspect_ratio_property(struct drm_device *dev) · line 1621

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+						"Colorspace",
+						hdmi_colorspaces,
+
	ARRAY_SIZE(hdmi_colorspaces));
Quoted 25 lines
drivers/gpu/drm/drm_connector.c +14 -0
+		if (!prop)
+			return -ENOMEM;
+	} else {
+		DRM_DEBUG_KMS("Colorspace property not supported\n");
+		return 0;
+	}
+
+	connector->colorspace_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_colorspace_property);
+
+/**
  * drm_mode_create_content_type_property - create content type property
  * @dev: DRM device
  *
(quoted diff) +0 -0

b/include/drm/drm_connector.h index 9941613..58db66e 100644

include/drm/drm_connector.h +0 -0
@@ -253,6 +253,42 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
include/drm/drm_connector.h +6 -0
+/*
+ * This is a consolidated colorimetry list supported by HDMI and
+ * DP protocol standard. The respective connectors will register
+ * a property with the subset of this list (supported by that
+ * respective protocol). Userspace will set the colorspace through
+ * a colorspace property which will be created and exposed to
Quoted 8 lines

include/drm/drm_connector.h enum drm_panel_orientation {

Quoted 8 lines
include/drm/drm_connector.h +8 -0
+ * userspace.
+ */
+
+/* For Default case, driver will set the colorspace */
+#define DRM_MODE_COLORIMETRY_DEFAULT			0
+/* CEA 861 Normal Colorimetry options */
+#define DRM_MODE_COLORIMETRY_NO_DATA			0
+#define DRM_MODE_COLORIMETRY_SMPTE_170M
	1
Quoted 8 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 270

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_BT709			2

Still missing the YCbCr information in these two.

As per CTA 861.G spec, we have these as only SMPTE_170M and ITU-R BT709, with no specific mention of RGB or YCbCr. Hence, kept it as per spec. We seem to have a common field for both as per CTA spec. Correct me if my understanding is wrong.

Quoted 8 lines
Quoted 3 lines

Check
"Table 14 Picture Colorimetry Indicated by the RGB or YC B C R (Y), Colorimetry
(C) and Extended Colorimetry (EC) Field Settings"

These Y2 Y1 Y0 values should be programmed separately and not through the colorspace as they are data formats isn't it. I feel this should get controlled separately independent of colorimetry, or should we add all the YCbCr and RGB versions and program them as part of this property itself ?

I don't think we can separate them. The values of the colorimetry bits doesn't mean anything without the Y bits. It would make the uapi kinda crazy if we allow the user to specify BT.2020 RGB but then we actually signal BT.2020 YCbCr in the infoframe, or vice versa. Or we just signal a totally invalid value for all the other cases.

Quoted 108 lines

My idea was just to update colorimetry fields alone as part of this interface.

Quoted 105 lines
Quoted 16 lines
Quoted 15 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 280

Quoted 12 lines
include/drm/drm_connector.h +10 -0
+/* CEA 861 Extended Colorimetry Options */
+#define DRM_MODE_COLORIMETRY_XVYCC_601			3
+#define DRM_MODE_COLORIMETRY_XVYCC_709			4
+#define DRM_MODE_COLORIMETRY_SYCC_601			5
+#define DRM_MODE_COLORIMETRY_OPYCC_601			6
+#define DRM_MODE_COLORIMETRY_OPRGB			7
+#define DRM_MODE_COLORIMETRY_BT2020_YCC			8
+/* Both BT2020_RGB and BT2020_YCbCbCr have same value */
+#define DRM_MODE_COLORIMETRY_BT2020_RGB			9
+#define DRM_MODE_COLORIMETRY_BT2020_CYCC		9

I though you didn't want these numbers to be based on the spec numbers? This duplicated value seems to go against that idea.

Quoted 3 lines

Yeah, for HDMI somehow was trying to utilize the definitions to advantage. But I feel, It's better to de-couple this. Define this as normal enum values sequentially so that userspace get readable serial number

kind values.

Quoted 2 lines

And use these in encoder files to get proper values to be programmed as per respective spec, while defining those values per encoder separately.

Hope this is fine.

Quoted 4 lines
Quoted 4 lines

include/drm/drm_connector.h enum drm_panel_orientation {

Quoted 4 lines
include/drm/drm_connector.h +3 -0
+/* Additional Colorimetry extension added as part of CTA 861.G */
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65		10
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER
	11
Quoted 8 lines
Quoted 7 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 287

Quoted 4 lines
include/drm/drm_connector.h +4 -0
+
+/* DP MSA Colorimetry Options */
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_601		12
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_709		13

Still inconsistent naming in many places (ITU_ vs. BT, YCBCR vs. YCC, order of the two).

Quoted 5 lines

Will fix this. Thanks Ville.

Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 289

Quoted 3 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_DP_COLORIMETRY_SRGB			14
+#define DRM_MODE_DP_COLORIMETRY_RGB_WIDE_GAMUT
	15
Quoted 47 lines
Quoted 47 lines
Quoted 40 lines
include/drm/drm_connector.h +9 -0
+#define DRM_MODE_DP_COLORIMETRY_SCRGB			16
+
 /**
  * struct drm_display_info - runtime data about the connected sink
  *
@@ -503,6 +539,13 @@ struct drm_connector_state {
 	unsigned int content_protection;
 
 	/**
+	 * @colorspace: State variable for Connector property to request
+	 * colorspace change on Sink. This is most commonly used to switch
+	 * to wider color gamuts like BT2020.
+	 */
+	u32 colorspace;
+
+	/**
 	 * @writeback_job: Writeback job for writeback connectors
 	 *
 	 * Holds the framebuffer and out-fence for a writeback connector.

As @@ -995,6 +1038,12 @@ struct drm_connector {

include/drm/drm_connector.h +6 -0
 	struct drm_property *content_protection_property;
 
 	/**
+	 * @colorspace_property: Connector property to set the suitable
+	 * colorspace supported by the sink.
+	 */
+	struct drm_property *colorspace_property;
+
+	/**
 	 * @path_blob_ptr:
 	 *
 	 * DRM blob property data for the DP MST path property. This

should only @@ -1269,6 +1318,7 @@ int drm_connector_attach_vrr_capable_property(
int drm_connector_attach_content_protection_property(
struct drm_connector *connector); int
drm_mode_create_aspect_ratio_property(struct drm_device *dev);

include/drm/drm_connector.h +2 -0
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector);
 int drm_mode_create_content_type_property(struct drm_device *dev);
Quoted 1 line

void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe

*frame,

Quoted 1 line

const struct drm_connector_state

*conn_state);

Quoted 3 lines

--
1.9.1

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

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

--
Ville Syrjälä
Intel

--
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

Re: [v11 1/4] drm: Add HDMI colorspace property

Quoted 270 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, February 5, 2019 10:02 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 11 lines · Uma Shankar

Create a new connector property to program colorspace to sink devices. Modern sink devices support more than 1 type of colorspace like 601, 709, BT2020 etc. This helps to switch based on content type which is to be displayed. The decision lies with compositors as to in which scenarios, a particular colorspace will be picked.

This will be helpful mostly to switch to higher gamut colorspaces like
BT2020 when the media content is encoded as BT2020. Thereby giving a good visual experience to users.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

The expectation from userspace is that it should parse the EDID and get supported colorspaces. Use this property and switch to the one supported. Sink supported colorspaces should be retrieved by userspace from EDID and driver will not explicitly expose

them.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink colorspace
- Set this new property to let the sink know what it converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments. Enhanced the colorspace enum to incorporate both HDMI and DP supported

colorspaces.

Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 36 lines

Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as per Ville, Hans Verkuil and Jonas Karlman suggestions. Changed Default to an unset state where driver will assign the colorspace is not chosen by user, suggested by Ville and Maarten. Addressed other misc review comments from Maarten. Split the changes to have separate colorspace property for DP and HDMI.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list based on the colorspaces supported by the respective protocol standard.

v5: Made the property creation helper accept enum list based on platform capabilties as suggested by Shashank. Consolidated HDMI and DP property creation in the common helper.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian Starkey's suggestion in order to go with string matching at userspace. Updated the commit message to add more details as well kernel docs.

v8: Addressed Maarten's review comments.

v9: Removed macro defines from uapi as per Brian Starkey and Daniel Stone's comments and moved to drm include file. Moved back to older design with exposing all HDMI colorspaces to userspace since infoframe capability is there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten and Jani's ack.

v11: Addressed Ville's review comments. Updated the Macro naming and added DCI-P3 colorspace as well defined in CEA 861.G spec.

Quoted 8 lines

<[email protected]>

---
 drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
 drivers/gpu/drm/drm_connector.c   | 78

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

Quoted 10 lines
 include/drm/drm_connector.h       | 50 +++++++++++++++++++++++++
 3 files changed, 132 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +0 -0
index 9a1f41a..9b5d44f 100644
@@ -746,6 +746,8 @@ static int

drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/drm_atomic_uapi.c static int drm_atomic_connector_set_property(struct drm_connector *connector,

Quoted 7 lines
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
 			return -EINVAL;
 		}
 		state->content_protection = val;
+	} else if (property == connector->colorspace_property) {
+		state->colorspace = val;
 	} else if (property == config->writeback_fb_id_property) {
 		struct drm_framebuffer *fb =

drm_framebuffer_lookup(dev,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

NULL, val);

Quoted 1 line

int ret =

drm_atomic_set_writeback_fb_for_connector(state,

Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines

fb); @@

Quoted 2 lines

-814,6 +816,8 @@ static int
drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 13 lines
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
 		*val = state->picture_aspect_ratio;
 	} else if (property == config->content_type_property) {
 		*val = state->content_type;
+	} else if (property == connector->colorspace_property) {
+		*val = state->colorspace;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
 	} else if (property == connector->content_protection_property)

{ diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 8475396..4309873 100644

drivers/gpu/drm/drm_connector.c int drm_display_info_set_bus_formats(struct · line 827

Quoted 2 lines
drivers/gpu/drm/drm_connector.c +0 -0
@@ -826,6 +826,33 @@ int drm_display_info_set_bus_formats(struct
 drm_display_info *info,  };
 DRM_ENUM_NAME_FN(drm_get_content_protection_name,

drm_cp_enum_list)

Quoted 17 lines
drivers/gpu/drm/drm_connector.c +16 -0
+static const struct drm_prop_enum_list hdmi_colorspaces[] = {
+	/* For Default case, driver will set the colorspace */
+	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+	/* Standard Definition Colorimetry based on CEA 861 */
+	{ DRM_MODE_COLORIMETRY_SMPTE_170M, "SMPTE_170M" },
+	{ DRM_MODE_COLORIMETRY_BT709, "BT709" },
+	/* Standard Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+	/* High Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+	/* Colorimetry based on IEC 61966-2-1/Amendment 1 */
+	{ DRM_MODE_COLORIMETRY_SYCC_601, "SYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 [33] */
+	{ DRM_MODE_COLORIMETRY_OPYCC_601, "opYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 */
+	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_connector.c int drm_display_info_set_bus_formats(struct drm_display_info *info,

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +8 -0
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_CYCC, "BT2020_CYCC" },
+	/* Added as part of Additional Colorimetry Extension in 861.G */
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-

P3_RGB_D65" },

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/drm_connector.c int drm_display_info_set_bus_formats(struct · line 852

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-

P3_RGB_Theater" },

Quoted 9 lines
drivers/gpu/drm/drm_connector.c +2 -0
+};
+
 /**
  * DOC: standard connector properties
  *
@@ -1548,6 +1575,57 @@ int
 drm_mode_create_aspect_ratio_property(struct drm_device *dev)
 EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);
 
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/drm_connector.c int drm_mode_create_aspect_ratio_property(struct drm_device *dev)

Quoted 5 lines
drivers/gpu/drm/drm_connector.c +4 -0
 /**
+ * DOC: standard connector properties
+ *
+ * Colorspace:
+ *     drm_mode_create_colorspace_property - create colorspace

property

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/drm_connector.c int drm_mode_create_aspect_ratio_property(struct drm_device *dev)

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+ *     This property helps select a suitable colorspace based on the sink
+ *     capability. Modern sink devices support wider gamut like BT2020.
+ *     This helps switch to BT2020 mode if the BT2020 encoded video

stream

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/drm_connector.c +18 -0
+ *     is being played by the user, same for any other colorspace. Thereby
+ *     giving a good visual experience to users.
+ *
+ *     The expectation from userspace is that it should parse the EDID
+ *     and get supported colorspaces. Use this property and switch to the
+ *     one supported. Sink supported colorspaces should be retrieved by
+ *     userspace from EDID and driver will not explicitly expose them.
+ *
+ *     Basically the expectation from userspace is:
+ *      - Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink
+ *        colorspace
+ *      - Set this new property to let the sink know what it
+ *        converted the CRTC output to.
+ *      - This property is just to inform sink what colorspace
+ *        source is trying to drive.
+ *
+ * Called by a driver the first time it's needed, must be
+attached to desired
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_connector.c int drm_mode_create_aspect_ratio_property(struct drm_device *dev)

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +8 -0
+ * connectors.
+ */
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIA ||

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/gpu/drm/drm_connector.c int · line 1612

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+	    connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIB) {

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/drm_connector.c int · line 1613

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+		prop = drm_property_create_enum(dev,

DRM_MODE_PROP_ENUM,

drivers/gpu/drm/drm_connector.c int drm_mode_create_aspect_ratio_property(struct drm_device *dev) · line 1621

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+						"Colorspace",
+						hdmi_colorspaces,
+
	ARRAY_SIZE(hdmi_colorspaces));

drivers/gpu/drm/drm_connector.c int drm_mode_create_aspect_ratio_property(struct drm_device *dev)

Quoted 4 lines
drivers/gpu/drm/drm_connector.c +4 -0
+		if (!prop)
+			return -ENOMEM;
+	} else {
+		DRM_DEBUG_KMS("Colorspace property not

supported\n");

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/drm_connector.c int drm_mode_create_aspect_ratio_property(struct drm_device *dev)

Quoted 11 lines
drivers/gpu/drm/drm_connector.c +10 -0
+		return 0;
+	}
+
+	connector->colorspace_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_colorspace_property);
+
+/**
  * drm_mode_create_content_type_property - create content type

property

Quoted 42 lines
Quoted 37 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/drm_connector.c +0 -0
  * @dev: DRM device
  *
(quoted diff) +0 -0

b/include/drm/drm_connector.h index 9941613..58db66e 100644

include/drm/drm_connector.h +9 -0
@@ -253,6 +253,42 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/*
+ * This is a consolidated colorimetry list supported by HDMI
+and
+ * DP protocol standard. The respective connectors will
+register
+ * a property with the subset of this list (supported by that
+ * respective protocol). Userspace will set the colorspace
+through
+ * a colorspace property which will be created and exposed to
Quoted 8 lines
Quoted 8 lines

include/drm/drm_connector.h enum drm_panel_orientation {

Quoted 8 lines
include/drm/drm_connector.h +8 -0
+ * userspace.
+ */
+
+/* For Default case, driver will set the colorspace */
+#define DRM_MODE_COLORIMETRY_DEFAULT			0
+/* CEA 861 Normal Colorimetry options */
+#define DRM_MODE_COLORIMETRY_NO_DATA			0
+#define DRM_MODE_COLORIMETRY_SMPTE_170M
	1
Quoted 8 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 270

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_BT709			2

Still missing the YCbCr information in these two.

As per CTA 861.G spec, we have these as only SMPTE_170M and ITU-R BT709, with no specific mention of RGB or YCbCr. Hence, kept it as per spec. We seem to have a common field for both as per CTA spec. Correct me if my understanding is wrong.

Quoted 4 lines

Check
"Table 14 Picture Colorimetry Indicated by the RGB or YC B C R (Y), Colorimetry
(C) and Extended Colorimetry (EC) Field Settings"

Quoted 4 lines

These Y2 Y1 Y0 values should be programmed separately and not through the colorspace as they are data formats isn't it. I feel this should get controlled separately independent of colorimetry, or should we add all the YCbCr and RGB versions and program them as part of this property itself

Quoted 7 lines

?

I don't think we can separate them. The values of the colorimetry bits doesn't mean anything without the Y bits. It would make the uapi kinda crazy if we allow the user to specify BT.2020 RGB but then we actually signal BT.2020 YCbCr in the infoframe, or vice versa. Or we just signal a totally invalid value for all the other cases.

I agree we need data format also to be send along with colorspace, but they are 2 different things. To handle YCbCr and variants (YUV 444, 420 or 422) and RGB I feel we should expose a different API instead of using this one. We can create an output csc property which does that job for us.

So from a user perspective if we wants to set a colorspace we should use the one in this series and set the data format separately using the other interface. Both will be received in the state variables and later Infoframe packet will be created accordingly. Clubbing both in one may lead to lot of possible combinations exposed as enum which may not look too clean.

What do you say about handling that in the output csc property. I will go with what you recommend .

Regards,
Uma Shankar

Quoted 100 lines
Quoted 7 lines

My idea was just to update colorimetry fields alone as part of this interface.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 275

Quoted 4 lines
include/drm/drm_connector.h +2 -0
+/* CEA 861 Extended Colorimetry Options */
+#define DRM_MODE_COLORIMETRY_XVYCC_601
	3
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

include/drm/drm_connector.h enum drm_panel_orientation { · line 276

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_XVYCC_709
	4
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 278

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_COLORIMETRY_SYCC_601			5
+#define DRM_MODE_COLORIMETRY_OPYCC_601
	6
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 280

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_COLORIMETRY_OPRGB			7
+#define DRM_MODE_COLORIMETRY_BT2020_YCC
	8
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 282

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+/* Both BT2020_RGB and BT2020_YCbCbCr have same value */
+#define DRM_MODE_COLORIMETRY_BT2020_RGB
	9
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 280

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_BT2020_CYCC		9

I though you didn't want these numbers to be based on the spec numbers? This duplicated value seems to go against that idea.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

Yeah, for HDMI somehow was trying to utilize the definitions to advantage. But I feel, It's better to de-couple this. Define this as normal enum values sequentially so that userspace get readable serial number

kind values.

Quoted 2 lines

And use these in encoder files to get proper values to be programmed as per respective spec, while defining those values per encoder

separately.

Quoted 9 lines
Quoted 9 lines

Hope this is fine.

Quoted 4 lines
Quoted 4 lines

include/drm/drm_connector.h enum drm_panel_orientation {

Quoted 4 lines
include/drm/drm_connector.h +3 -0
+/* Additional Colorimetry extension added as part of CTA 861.G */
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65		10
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER
	11
Quoted 3 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation {

Quoted 3 lines
include/drm/drm_connector.h +3 -0
+
+/* DP MSA Colorimetry Options */
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_601
	12
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

include/drm/drm_connector.h enum drm_panel_orientation { · line 290

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_709
	13
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 3 lines

Still inconsistent naming in many places (ITU_ vs. BT, YCBCR vs. YCC, order of the two).

Will fix this. Thanks Ville.

Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 292

Quoted 3 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_DP_COLORIMETRY_SRGB			14
+#define DRM_MODE_DP_COLORIMETRY_RGB_WIDE_GAMUT
	15
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_DP_COLORIMETRY_SCRGB
	16
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

include/drm/drm_connector.h struct drm_connector_state { · line 543

Quoted 10 lines
include/drm/drm_connector.h +3 -0
+
 /**
  * struct drm_display_info - runtime data about the connected sink
  *
@@ -503,6 +539,13 @@ struct drm_connector_state {
 	unsigned int content_protection;
 
 	/**
+	 * @colorspace: State variable for Connector property to request
+	 * colorspace change on Sink. This is most commonly used to

switch

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

include/drm/drm_connector.h struct drm_connector_state {

Quoted 8 lines
include/drm/drm_connector.h +5 -0
+	 * to wider color gamuts like BT2020.
+	 */
+	u32 colorspace;
+
+	/**
 	 * @writeback_job: Writeback job for writeback connectors
 	 *
 	 * Holds the framebuffer and out-fence for a writeback

connector.

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 21 lines

As @@ -995,6 +1038,12 @@ struct drm_connector {

include/drm/drm_connector.h +6 -0
 	struct drm_property *content_protection_property;
 
 	/**
+	 * @colorspace_property: Connector property to set the suitable
+	 * colorspace supported by the sink.
+	 */
+	struct drm_property *colorspace_property;
+
+	/**
 	 * @path_blob_ptr:
 	 *
 	 * DRM blob property data for the DP MST path property. This

should only @@ -1269,6 +1318,7 @@ int drm_connector_attach_vrr_capable_property(
int drm_connector_attach_content_protection_property(
struct drm_connector *connector); int
drm_mode_create_aspect_ratio_property(struct drm_device *dev);

include/drm/drm_connector.h +2 -0
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector);
 int drm_mode_create_content_type_property(struct drm_device
Quoted 2 lines

*dev); void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe

*frame,

Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

const struct

drm_connector_state

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

*conn_state);

Quoted 3 lines

--
1.9.1

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

#8 lore raw

Re: [v11 1/4] drm: Add HDMI colorspace property

Regards
Shashank

Quoted 296 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Shankar, Uma
Sent: Friday, February 8, 2019 5:45 PM
To: Ville Syrjälä <[email protected]>
Cc: [email protected]; Syrjala, Ville <[email protected]>; dri- [email protected]; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 274 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, February 5, 2019 10:02 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 11 lines · Uma Shankar

Create a new connector property to program colorspace to sink devices. Modern sink devices support more than 1 type of colorspace like 601, 709, BT2020 etc. This helps to switch based on content
type which is to be displayed. The decision lies with
compositors as to in which scenarios, a particular colorspace will be picked.

This will be helpful mostly to switch to higher gamut colorspaces like
BT2020 when the media content is encoded as BT2020. Thereby giving a good visual experience to users.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

The expectation from userspace is that it should parse the EDID and get supported colorspaces. Use this property and switch to the one supported. Sink supported colorspaces should be retrieved by userspace from EDID and driver will not explicitly expose

them.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink colorspace
- Set this new property to let the sink know what it converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments. Enhanced the colorspace enum to incorporate both HDMI and DP supported

colorspaces.

Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 36 lines

Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as per Ville, Hans Verkuil and Jonas Karlman suggestions. Changed Default to an unset state where driver will assign the colorspace is not chosen by user, suggested by Ville and Maarten. Addressed other misc review comments from Maarten. Split the changes to have separate colorspace property for DP and HDMI.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list based on the colorspaces supported by the respective protocol standard.

v5: Made the property creation helper accept enum list based on platform capabilties as suggested by Shashank. Consolidated HDMI and DP property creation in the common helper.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian Starkey's suggestion in order to go with string matching at userspace. Updated the commit message to add more details as well kernel docs.

v8: Addressed Maarten's review comments.

v9: Removed macro defines from uapi as per Brian Starkey and Daniel Stone's comments and moved to drm include file. Moved back to older design with exposing all HDMI colorspaces to userspace since infoframe capability is there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten and Jani's ack.

v11: Addressed Ville's review comments. Updated the Macro naming and added DCI-P3 colorspace as well defined in CEA 861.G spec.

Quoted 8 lines

<[email protected]>

---
 drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
 drivers/gpu/drm/drm_connector.c   | 78

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

Quoted 10 lines
 include/drm/drm_connector.h       | 50 +++++++++++++++++++++++++
 3 files changed, 132 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +0 -0
index 9a1f41a..9b5d44f 100644
@@ -746,6 +746,8 @@ static int

drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/drm_atomic_uapi.c

Quoted 7 lines
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
 			return -EINVAL;
 		}
 		state->content_protection = val;
+	} else if (property == connector->colorspace_property) {
+		state->colorspace = val;
 	} else if (property == config->writeback_fb_id_property) {
 		struct drm_framebuffer *fb =

drm_framebuffer_lookup(dev,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

NULL, val);

Quoted 1 line

int ret =

drm_atomic_set_writeback_fb_for_connector(state,

Quoted 39 lines
Quoted 39 lines
Quoted 39 lines
Quoted 39 lines

fb); @@

Quoted 2 lines

-814,6 +816,8 @@ static int
drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 14 lines
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
 		*val = state->picture_aspect_ratio;
 	} else if (property == config->content_type_property) {
 		*val = state->content_type;
+	} else if (property == connector->colorspace_property) {
+		*val = state->colorspace;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
 	} else if (property ==

connector->content_protection_property)
{ diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 8475396..4309873 100644

drivers/gpu/drm/drm_connector.c +0 -0
@@ -826,6 +826,33 @@ int
Quoted 3 lines

drm_display_info_set_bus_formats(struct
drm_display_info *info, };
DRM_ENUM_NAME_FN(drm_get_content_protection_name,

drm_cp_enum_list)

Quoted 17 lines
drivers/gpu/drm/drm_connector.c +16 -0
+static const struct drm_prop_enum_list hdmi_colorspaces[] = {
+	/* For Default case, driver will set the colorspace */
+	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+	/* Standard Definition Colorimetry based on CEA 861 */
+	{ DRM_MODE_COLORIMETRY_SMPTE_170M, "SMPTE_170M" },
+	{ DRM_MODE_COLORIMETRY_BT709, "BT709" },
+	/* Standard Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+	/* High Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+	/* Colorimetry based on IEC 61966-2-1/Amendment 1 */
+	{ DRM_MODE_COLORIMETRY_SYCC_601, "SYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 [33] */
+	{ DRM_MODE_COLORIMETRY_OPYCC_601, "opYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 */
+	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_connector.c

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +8 -0
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_CYCC, "BT2020_CYCC" },
+	/* Added as part of Additional Colorimetry Extension in 861.G */
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-

P3_RGB_D65" },

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/drm_connector.c

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-

P3_RGB_Theater" },

Quoted 9 lines
drivers/gpu/drm/drm_connector.c +2 -0
+};
+
 /**
  * DOC: standard connector properties
  *
@@ -1548,6 +1575,57 @@ int
 drm_mode_create_aspect_ratio_property(struct drm_device *dev)
 EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);
 
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/drm_connector.c int · line 1582

Quoted 5 lines
drivers/gpu/drm/drm_connector.c +4 -0
 /**
+ * DOC: standard connector properties
+ *
+ * Colorspace:
+ *     drm_mode_create_colorspace_property - create colorspace

property

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/drm_connector.c int · line 1585

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+ *     This property helps select a suitable colorspace based on the sink
+ *     capability. Modern sink devices support wider gamut like BT2020.
+ *     This helps switch to BT2020 mode if the BT2020 encoded video

stream

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/drm_connector.c +18 -0
+ *     is being played by the user, same for any other colorspace. Thereby
+ *     giving a good visual experience to users.
+ *
+ *     The expectation from userspace is that it should parse the EDID
+ *     and get supported colorspaces. Use this property and switch to the
+ *     one supported. Sink supported colorspaces should be retrieved by
+ *     userspace from EDID and driver will not explicitly expose them.
+ *
+ *     Basically the expectation from userspace is:
+ *      - Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink
+ *        colorspace
+ *      - Set this new property to let the sink know what it
+ *        converted the CRTC output to.
+ *      - This property is just to inform sink what colorspace
+ *        source is trying to drive.
+ *
+ * Called by a driver the first time it's needed, must be
+attached to desired
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_connector.c int · line 1611

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +8 -0
+ * connectors.
+ */
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIA ||

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/gpu/drm/drm_connector.c int · line 1612

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+	    connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIB) {

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/drm_connector.c int · line 1613

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+		prop = drm_property_create_enum(dev,

DRM_MODE_PROP_ENUM,

drivers/gpu/drm/drm_connector.c int · line 1616

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+						"Colorspace",
+						hdmi_colorspaces,
+
	ARRAY_SIZE(hdmi_colorspaces));

drivers/gpu/drm/drm_connector.c int · line 1620

Quoted 4 lines
drivers/gpu/drm/drm_connector.c +4 -0
+		if (!prop)
+			return -ENOMEM;
+	} else {
+		DRM_DEBUG_KMS("Colorspace property not

supported\n");

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/drm_connector.c int · line 1631

Quoted 11 lines
drivers/gpu/drm/drm_connector.c +10 -0
+		return 0;
+	}
+
+	connector->colorspace_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_colorspace_property);
+
+/**
  * drm_mode_create_content_type_property - create content type

property

Quoted 42 lines
Quoted 37 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/drm_connector.c +0 -0
  * @dev: DRM device
  *
(quoted diff) +0 -0

b/include/drm/drm_connector.h index 9941613..58db66e 100644

include/drm/drm_connector.h +9 -0
@@ -253,6 +253,42 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/*
+ * This is a consolidated colorimetry list supported by HDMI
+and
+ * DP protocol standard. The respective connectors will
+register
+ * a property with the subset of this list (supported by that
+ * respective protocol). Userspace will set the colorspace
+through
+ * a colorspace property which will be created and exposed to
Quoted 8 lines
Quoted 8 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 272

Quoted 8 lines
include/drm/drm_connector.h +8 -0
+ * userspace.
+ */
+
+/* For Default case, driver will set the colorspace */
+#define DRM_MODE_COLORIMETRY_DEFAULT			0
+/* CEA 861 Normal Colorimetry options */
+#define DRM_MODE_COLORIMETRY_NO_DATA			0
+#define DRM_MODE_COLORIMETRY_SMPTE_170M
	1
Quoted 8 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 273

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_BT709			2

Still missing the YCbCr information in these two.

As per CTA 861.G spec, we have these as only SMPTE_170M and ITU-R BT709, with no specific mention of RGB or YCbCr. Hence, kept it as per spec. We seem to have a common field for both as per CTA spec. Correct me if my understanding is wrong.

Quoted 4 lines

Check
"Table 14 Picture Colorimetry Indicated by the RGB or YC B C R (Y), Colorimetry
(C) and Extended Colorimetry (EC) Field Settings"

Quoted 5 lines

These Y2 Y1 Y0 values should be programmed separately and not through the colorspace as they are data formats isn't it. I feel this should get controlled separately independent of colorimetry, or should we add all the YCbCr and RGB versions and program them as part of this property itself

Quoted 7 lines

?

I don't think we can separate them. The values of the colorimetry bits doesn't mean anything without the Y bits. It would make the uapi kinda crazy if we allow the user to specify BT.2020 RGB but then we actually signal BT.2020 YCbCr in the infoframe, or vice versa. Or we just signal a totally invalid value for all the other cases.

I agree we need data format also to be send along with colorspace, but they are 2 different things. To handle YCbCr and variants (YUV 444, 420 or 422) and RGB I feel we should expose a different API instead of using this one. We can create an output csc property which does that job for us.

Quoted 8 lines

So from a user perspective if we wants to set a colorspace we should use the one in this series and set the data format separately using the other interface. Both will be received in the state variables and later Infoframe packet will be created accordingly. Clubbing both in one may lead to lot of possible combinations exposed as enum which may not look too clean.

What do you say about handling that in the output csc property. I will go with what you recommend .

Programming Y2Y1Y0 is already taken care of, when we added support for YCBCR outputs (4:2:0 implementation). In intel_hdmi.c:intel_hdmi_set_avi_infoframe():

if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420)

	frame.avi.colorspace = HDMI_COLORSPACE_YUV420;
else if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR444)
	frame.avi.colorspace = HDMI_COLORSPACE_YUV444;
else
	frame.avi.colorspace = HDMI_COLORSPACE_RGB;

IMO This looks like a better way to handle this, ie while adding support for a new format, add support for corresponding AVI IF fileds. This will also make scope of the property under discussion less complicated.

Quoted 109 lines

Regards,
Uma Shankar

Quoted 103 lines
Quoted 7 lines

My idea was just to update colorimetry fields alone as part of this interface.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 275

Quoted 4 lines
include/drm/drm_connector.h +2 -0
+/* CEA 861 Extended Colorimetry Options */ #define
+DRM_MODE_COLORIMETRY_XVYCC_601
	3
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

include/drm/drm_connector.h enum drm_panel_orientation { · line 276

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_XVYCC_709
	4
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 278

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_COLORIMETRY_SYCC_601			5
+#define DRM_MODE_COLORIMETRY_OPYCC_601
	6
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 280

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_COLORIMETRY_OPRGB			7
+#define DRM_MODE_COLORIMETRY_BT2020_YCC
	8
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 282

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+/* Both BT2020_RGB and BT2020_YCbCbCr have same value */
+#define DRM_MODE_COLORIMETRY_BT2020_RGB
	9
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 283

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_BT2020_CYCC		9

I though you didn't want these numbers to be based on the spec numbers? This duplicated value seems to go against that idea.

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

Yeah, for HDMI somehow was trying to utilize the definitions to advantage. But I feel, It's better to de-couple this. Define this as normal enum values sequentially so that userspace get readable serial number

kind values.

Quoted 3 lines

And use these in encoder files to get proper values to be programmed as per respective spec, while defining those values per encoder

separately.

Quoted 9 lines
Quoted 9 lines

Hope this is fine.

Quoted 4 lines
Quoted 4 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 286

Quoted 4 lines
include/drm/drm_connector.h +3 -0
+/* Additional Colorimetry extension added as part of CTA 861.G */
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65		10
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER
	11
Quoted 3 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 289

Quoted 3 lines
include/drm/drm_connector.h +3 -0
+
+/* DP MSA Colorimetry Options */ #define
+DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_601
	12
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

include/drm/drm_connector.h enum drm_panel_orientation { · line 290

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_709
	13
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 3 lines

Still inconsistent naming in many places (ITU_ vs. BT, YCBCR vs. YCC, order of the two).

Will fix this. Thanks Ville.

Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 292

Quoted 3 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_DP_COLORIMETRY_SRGB			14
+#define DRM_MODE_DP_COLORIMETRY_RGB_WIDE_GAMUT
	15
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_DP_COLORIMETRY_SCRGB
	16
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

include/drm/drm_connector.h struct drm_connector_state { · line 543

Quoted 10 lines
include/drm/drm_connector.h +3 -0
+
 /**
  * struct drm_display_info - runtime data about the connected sink
  *
@@ -503,6 +539,13 @@ struct drm_connector_state {
 	unsigned int content_protection;
 
 	/**
+	 * @colorspace: State variable for Connector property to request
+	 * colorspace change on Sink. This is most commonly used to

switch

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

include/drm/drm_connector.h struct drm_connector_state { · line 551

Quoted 8 lines
include/drm/drm_connector.h +5 -0
+	 * to wider color gamuts like BT2020.
+	 */
+	u32 colorspace;
+
+	/**
 	 * @writeback_job: Writeback job for writeback connectors
 	 *
 	 * Holds the framebuffer and out-fence for a writeback

connector.

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 21 lines

As @@ -995,6 +1038,12 @@ struct drm_connector {

include/drm/drm_connector.h +6 -0
 	struct drm_property *content_protection_property;
 
 	/**
+	 * @colorspace_property: Connector property to set the suitable
+	 * colorspace supported by the sink.
+	 */
+	struct drm_property *colorspace_property;
+
+	/**
 	 * @path_blob_ptr:
 	 *
 	 * DRM blob property data for the DP MST path property. This

should only @@ -1269,6 +1318,7 @@ int drm_connector_attach_vrr_capable_property(
int drm_connector_attach_content_protection_property(
struct drm_connector *connector); int
drm_mode_create_aspect_ratio_property(struct drm_device *dev);

include/drm/drm_connector.h +2 -0
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector);
 int drm_mode_create_content_type_property(struct drm_device
Quoted 2 lines

*dev); void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe

*frame,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

const struct

drm_connector_state

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

*conn_state);

Quoted 3 lines

--
1.9.1

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

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

#9 lore raw

Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 311 lines · Shashank

Regards
Shashank

Quoted 296 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Shankar, Uma
Sent: Friday, February 8, 2019 5:45 PM
To: Ville Syrjälä <[email protected]>
Cc: [email protected]; Syrjala, Ville <[email protected]>; dri- [email protected]; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 274 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, February 5, 2019 10:02 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 11 lines · Uma Shankar

Create a new connector property to program colorspace to sink devices. Modern sink devices support more than 1 type of colorspace like 601, 709, BT2020 etc. This helps to switch based on content
type which is to be displayed. The decision lies with
compositors as to in which scenarios, a particular colorspace will be picked.

This will be helpful mostly to switch to higher gamut colorspaces like
BT2020 when the media content is encoded as BT2020. Thereby giving a good visual experience to users.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

The expectation from userspace is that it should parse the EDID and get supported colorspaces. Use this property and switch to the one supported. Sink supported colorspaces should be retrieved by userspace from EDID and driver will not explicitly expose

them.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink colorspace
- Set this new property to let the sink know what it converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments. Enhanced the colorspace enum to incorporate both HDMI and DP supported

colorspaces.

Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 36 lines

Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as per Ville, Hans Verkuil and Jonas Karlman suggestions. Changed Default to an unset state where driver will assign the colorspace is not chosen by user, suggested by Ville and Maarten. Addressed other misc review comments from Maarten. Split the changes to have separate colorspace property for DP and HDMI.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list based on the colorspaces supported by the respective protocol standard.

v5: Made the property creation helper accept enum list based on platform capabilties as suggested by Shashank. Consolidated HDMI and DP property creation in the common helper.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian Starkey's suggestion in order to go with string matching at userspace. Updated the commit message to add more details as well kernel docs.

v8: Addressed Maarten's review comments.

v9: Removed macro defines from uapi as per Brian Starkey and Daniel Stone's comments and moved to drm include file. Moved back to older design with exposing all HDMI colorspaces to userspace since infoframe capability is there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten and Jani's ack.

v11: Addressed Ville's review comments. Updated the Macro naming and added DCI-P3 colorspace as well defined in CEA 861.G spec.

Quoted 8 lines

<[email protected]>

---
 drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
 drivers/gpu/drm/drm_connector.c   | 78

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

Quoted 10 lines
 include/drm/drm_connector.h       | 50 +++++++++++++++++++++++++
 3 files changed, 132 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +0 -0
index 9a1f41a..9b5d44f 100644
@@ -746,6 +746,8 @@ static int

drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/drm_atomic_uapi.c

Quoted 7 lines
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
 			return -EINVAL;
 		}
 		state->content_protection = val;
+	} else if (property == connector->colorspace_property) {
+		state->colorspace = val;
 	} else if (property == config->writeback_fb_id_property) {
 		struct drm_framebuffer *fb =

drm_framebuffer_lookup(dev,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

NULL, val);

Quoted 1 line

int ret =

drm_atomic_set_writeback_fb_for_connector(state,

Quoted 39 lines
Quoted 39 lines
Quoted 39 lines
Quoted 39 lines

fb); @@

Quoted 2 lines

-814,6 +816,8 @@ static int
drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 14 lines
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
 		*val = state->picture_aspect_ratio;
 	} else if (property == config->content_type_property) {
 		*val = state->content_type;
+	} else if (property == connector->colorspace_property) {
+		*val = state->colorspace;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
 	} else if (property ==

connector->content_protection_property)
{ diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 8475396..4309873 100644

drivers/gpu/drm/drm_connector.c +0 -0
@@ -826,6 +826,33 @@ int
Quoted 3 lines

drm_display_info_set_bus_formats(struct
drm_display_info *info, };
DRM_ENUM_NAME_FN(drm_get_content_protection_name,

drm_cp_enum_list)

Quoted 17 lines
drivers/gpu/drm/drm_connector.c +16 -0
+static const struct drm_prop_enum_list hdmi_colorspaces[] = {
+	/* For Default case, driver will set the colorspace */
+	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+	/* Standard Definition Colorimetry based on CEA 861 */
+	{ DRM_MODE_COLORIMETRY_SMPTE_170M, "SMPTE_170M" },
+	{ DRM_MODE_COLORIMETRY_BT709, "BT709" },
+	/* Standard Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+	/* High Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+	/* Colorimetry based on IEC 61966-2-1/Amendment 1 */
+	{ DRM_MODE_COLORIMETRY_SYCC_601, "SYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 [33] */
+	{ DRM_MODE_COLORIMETRY_OPYCC_601, "opYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 */
+	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_connector.c

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +8 -0
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_CYCC, "BT2020_CYCC" },
+	/* Added as part of Additional Colorimetry Extension in 861.G */
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-

P3_RGB_D65" },

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/drm_connector.c

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-

P3_RGB_Theater" },

Quoted 9 lines
drivers/gpu/drm/drm_connector.c +2 -0
+};
+
 /**
  * DOC: standard connector properties
  *
@@ -1548,6 +1575,57 @@ int
 drm_mode_create_aspect_ratio_property(struct drm_device *dev)
 EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);
 
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/drm_connector.c int · line 1582

Quoted 5 lines
drivers/gpu/drm/drm_connector.c +4 -0
 /**
+ * DOC: standard connector properties
+ *
+ * Colorspace:
+ *     drm_mode_create_colorspace_property - create colorspace

property

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/drm_connector.c int · line 1585

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+ *     This property helps select a suitable colorspace based on the sink
+ *     capability. Modern sink devices support wider gamut like BT2020.
+ *     This helps switch to BT2020 mode if the BT2020 encoded video

stream

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/drm_connector.c +18 -0
+ *     is being played by the user, same for any other colorspace. Thereby
+ *     giving a good visual experience to users.
+ *
+ *     The expectation from userspace is that it should parse the EDID
+ *     and get supported colorspaces. Use this property and switch to the
+ *     one supported. Sink supported colorspaces should be retrieved by
+ *     userspace from EDID and driver will not explicitly expose them.
+ *
+ *     Basically the expectation from userspace is:
+ *      - Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink
+ *        colorspace
+ *      - Set this new property to let the sink know what it
+ *        converted the CRTC output to.
+ *      - This property is just to inform sink what colorspace
+ *        source is trying to drive.
+ *
+ * Called by a driver the first time it's needed, must be
+attached to desired
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_connector.c int · line 1611

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +8 -0
+ * connectors.
+ */
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIA ||

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/gpu/drm/drm_connector.c int · line 1612

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+	    connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIB) {

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/drm_connector.c int · line 1613

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+		prop = drm_property_create_enum(dev,

DRM_MODE_PROP_ENUM,

drivers/gpu/drm/drm_connector.c int · line 1616

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+						"Colorspace",
+						hdmi_colorspaces,
+
	ARRAY_SIZE(hdmi_colorspaces));

drivers/gpu/drm/drm_connector.c int · line 1620

Quoted 4 lines
drivers/gpu/drm/drm_connector.c +4 -0
+		if (!prop)
+			return -ENOMEM;
+	} else {
+		DRM_DEBUG_KMS("Colorspace property not

supported\n");

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/drm_connector.c int · line 1631

Quoted 11 lines
drivers/gpu/drm/drm_connector.c +10 -0
+		return 0;
+	}
+
+	connector->colorspace_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_colorspace_property);
+
+/**
  * drm_mode_create_content_type_property - create content type

property

Quoted 42 lines
Quoted 37 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/drm_connector.c +0 -0
  * @dev: DRM device
  *
(quoted diff) +0 -0

b/include/drm/drm_connector.h index 9941613..58db66e 100644

include/drm/drm_connector.h +9 -0
@@ -253,6 +253,42 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/*
+ * This is a consolidated colorimetry list supported by HDMI
+and
+ * DP protocol standard. The respective connectors will
+register
+ * a property with the subset of this list (supported by that
+ * respective protocol). Userspace will set the colorspace
+through
+ * a colorspace property which will be created and exposed to
Quoted 8 lines
Quoted 8 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 272

Quoted 8 lines
include/drm/drm_connector.h +8 -0
+ * userspace.
+ */
+
+/* For Default case, driver will set the colorspace */
+#define DRM_MODE_COLORIMETRY_DEFAULT			0
+/* CEA 861 Normal Colorimetry options */
+#define DRM_MODE_COLORIMETRY_NO_DATA			0
+#define DRM_MODE_COLORIMETRY_SMPTE_170M
	1
Quoted 8 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 273

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_BT709			2

Still missing the YCbCr information in these two.

As per CTA 861.G spec, we have these as only SMPTE_170M and ITU-R BT709, with no specific mention of RGB or YCbCr. Hence, kept it as per spec. We seem to have a common field for both as per CTA spec. Correct me if my understanding is wrong.

Quoted 4 lines

Check
"Table 14 Picture Colorimetry Indicated by the RGB or YC B C R (Y), Colorimetry
(C) and Extended Colorimetry (EC) Field Settings"

Quoted 5 lines

These Y2 Y1 Y0 values should be programmed separately and not through the colorspace as they are data formats isn't it. I feel this should get controlled separately independent of colorimetry, or should we add all the YCbCr and RGB versions and program them as part of this property itself

Quoted 7 lines

?

I don't think we can separate them. The values of the colorimetry bits doesn't mean anything without the Y bits. It would make the uapi kinda crazy if we allow the user to specify BT.2020 RGB but then we actually signal BT.2020 YCbCr in the infoframe, or vice versa. Or we just signal a totally invalid value for all the other cases.

I agree we need data format also to be send along with colorspace, but they are 2 different things. To handle YCbCr and variants (YUV 444, 420 or 422) and RGB I feel we should expose a different API instead of using this one. We can create an output csc property which does that job for us.

Quoted 8 lines

So from a user perspective if we wants to set a colorspace we should use the one in this series and set the data format separately using the other interface. Both will be received in the state variables and later Infoframe packet will be created accordingly. Clubbing both in one may lead to lot of possible combinations exposed as enum which may not look too clean.

What do you say about handling that in the output csc property. I will go with what you recommend .

Programming Y2Y1Y0 is already taken care of, when we added support for YCBCR outputs (4:2:0 implementation). In intel_hdmi.c:intel_hdmi_set_avi_infoframe():

Quoted 8 lines

if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420)

	frame.avi.colorspace = HDMI_COLORSPACE_YUV420;
else if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR444)
	frame.avi.colorspace = HDMI_COLORSPACE_YUV444;
else
	frame.avi.colorspace = HDMI_COLORSPACE_RGB;

IMO This looks like a better way to handle this, ie while adding support for a new format, add support for corresponding AVI IF fileds. This will also make scope of the property under discussion less complicated.

That's an exceptional case. We're programming the CSC in that case to do the RGB->YCbCr conversion without telling userspace. So we must also configure the Y bits automagically.

What we want is a check like so:

if (prop.colorspace != default && output_format != RGB)

    return -INVAL;

because we can't set up the CSC to make a mess of the user's carefully crafted pixels. The pixels might not even contain RGB data in that case.

We'll need to extend that a little bit once we add the explicit control of the output CSC via another prop. But the same principle should hold.

Quoted 118 lines
Quoted 118 lines

Regards,
Uma Shankar

Quoted 101 lines
Quoted 7 lines

My idea was just to update colorimetry fields alone as part of this interface.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 275

Quoted 4 lines
include/drm/drm_connector.h +2 -0
+/* CEA 861 Extended Colorimetry Options */ #define
+DRM_MODE_COLORIMETRY_XVYCC_601
	3
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

include/drm/drm_connector.h enum drm_panel_orientation { · line 276

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_XVYCC_709
	4
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 278

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_COLORIMETRY_SYCC_601			5
+#define DRM_MODE_COLORIMETRY_OPYCC_601
	6
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 280

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_COLORIMETRY_OPRGB			7
+#define DRM_MODE_COLORIMETRY_BT2020_YCC
	8
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 282

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+/* Both BT2020_RGB and BT2020_YCbCbCr have same value */
+#define DRM_MODE_COLORIMETRY_BT2020_RGB
	9
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 283

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_BT2020_CYCC		9

I though you didn't want these numbers to be based on the spec numbers? This duplicated value seems to go against that idea.

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

Yeah, for HDMI somehow was trying to utilize the definitions to advantage. But I feel, It's better to de-couple this. Define this as normal enum values sequentially so that userspace get readable serial number

kind values.

Quoted 3 lines

And use these in encoder files to get proper values to be programmed as per respective spec, while defining those values per encoder

separately.

Quoted 9 lines
Quoted 9 lines

Hope this is fine.

Quoted 4 lines
Quoted 4 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 286

Quoted 4 lines
include/drm/drm_connector.h +3 -0
+/* Additional Colorimetry extension added as part of CTA 861.G */
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65		10
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER
	11
Quoted 3 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 289

Quoted 3 lines
include/drm/drm_connector.h +3 -0
+
+/* DP MSA Colorimetry Options */ #define
+DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_601
	12
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

include/drm/drm_connector.h enum drm_panel_orientation { · line 290

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_709
	13
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 3 lines

Still inconsistent naming in many places (ITU_ vs. BT, YCBCR vs. YCC, order of the two).

Will fix this. Thanks Ville.

Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 292

Quoted 3 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_DP_COLORIMETRY_SRGB			14
+#define DRM_MODE_DP_COLORIMETRY_RGB_WIDE_GAMUT
	15
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_DP_COLORIMETRY_SCRGB
	16
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

include/drm/drm_connector.h struct drm_connector_state { · line 543

Quoted 10 lines
include/drm/drm_connector.h +3 -0
+
 /**
  * struct drm_display_info - runtime data about the connected sink
  *
@@ -503,6 +539,13 @@ struct drm_connector_state {
 	unsigned int content_protection;
 
 	/**
+	 * @colorspace: State variable for Connector property to request
+	 * colorspace change on Sink. This is most commonly used to

switch

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

include/drm/drm_connector.h struct drm_connector_state { · line 551

Quoted 8 lines
include/drm/drm_connector.h +5 -0
+	 * to wider color gamuts like BT2020.
+	 */
+	u32 colorspace;
+
+	/**
 	 * @writeback_job: Writeback job for writeback connectors
 	 *
 	 * Holds the framebuffer and out-fence for a writeback

connector.

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 21 lines

As @@ -995,6 +1038,12 @@ struct drm_connector {

include/drm/drm_connector.h +6 -0
 	struct drm_property *content_protection_property;
 
 	/**
+	 * @colorspace_property: Connector property to set the suitable
+	 * colorspace supported by the sink.
+	 */
+	struct drm_property *colorspace_property;
+
+	/**
 	 * @path_blob_ptr:
 	 *
 	 * DRM blob property data for the DP MST path property. This

should only @@ -1269,6 +1318,7 @@ int drm_connector_attach_vrr_capable_property(
int drm_connector_attach_content_protection_property(
struct drm_connector *connector); int
drm_mode_create_aspect_ratio_property(struct drm_device *dev);

include/drm/drm_connector.h +2 -0
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector);
 int drm_mode_create_content_type_property(struct drm_device
Quoted 2 lines

*dev); void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe

*frame,

Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

const struct

drm_connector_state

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

*conn_state);

Quoted 3 lines

--
1.9.1

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

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

Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Regards

Shashank

Quoted 321 lines · Ville Syrjälä
Quoted 303 lines · Shashank

Regards
Shashank

Quoted 289 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Shankar, Uma
Sent: Friday, February 8, 2019 5:45 PM
To: Ville Syrjälä <[email protected]>
Cc: [email protected]; Syrjala, Ville <[email protected]>; dri- [email protected]; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 268 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, February 5, 2019 10:02 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 11 lines · Uma Shankar

Create a new connector property to program colorspace to sink devices. Modern sink devices support more than 1 type of colorspace like 601, 709, BT2020 etc. This helps to switch based on content
type which is to be displayed. The decision lies with
compositors as to in which scenarios, a particular colorspace will be picked.

This will be helpful mostly to switch to higher gamut colorspaces like
BT2020 when the media content is encoded as BT2020. Thereby giving a good visual experience to users.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

The expectation from userspace is that it should parse the EDID and get supported colorspaces. Use this property and switch to the one supported. Sink supported colorspaces should be retrieved by userspace from EDID and driver will not explicitly expose

them.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink colorspace
- Set this new property to let the sink know what it converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments. Enhanced the colorspace enum to incorporate both HDMI and DP supported

colorspaces.

Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 36 lines

Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as per Ville, Hans Verkuil and Jonas Karlman suggestions. Changed Default to an unset state where driver will assign the colorspace is not chosen by user, suggested by Ville and Maarten. Addressed other misc review comments from Maarten. Split the changes to have separate colorspace property for DP and HDMI.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list based on the colorspaces supported by the respective protocol standard.

v5: Made the property creation helper accept enum list based on platform capabilties as suggested by Shashank. Consolidated HDMI and DP property creation in the common helper.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian Starkey's suggestion in order to go with string matching at userspace. Updated the commit message to add more details as well kernel docs.

v8: Addressed Maarten's review comments.

v9: Removed macro defines from uapi as per Brian Starkey and Daniel Stone's comments and moved to drm include file. Moved back to older design with exposing all HDMI colorspaces to userspace since infoframe capability is there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten and Jani's ack.

v11: Addressed Ville's review comments. Updated the Macro naming and added DCI-P3 colorspace as well defined in CEA 861.G spec.

Quoted 8 lines

<[email protected]>

---
  drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
  drivers/gpu/drm/drm_connector.c   | 78

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

Quoted 10 lines
  include/drm/drm_connector.h       | 50 +++++++++++++++++++++++++
  3 files changed, 132 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +0 -0
index 9a1f41a..9b5d44f 100644
@@ -746,6 +746,8 @@ static int

drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/drm_atomic_uapi.c

Quoted 7 lines
  			return -EINVAL;
  		}
  		state->content_protection = val;
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
+	} else if (property == connector->colorspace_property) {
+		state->colorspace = val;
  	} else if (property == config->writeback_fb_id_property) {
  		struct drm_framebuffer *fb =

drm_framebuffer_lookup(dev,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

NULL, val);

Quoted 1 line

int ret =

drm_atomic_set_writeback_fb_for_connector(state,

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines

fb); @@

Quoted 2 lines

-814,6 +816,8 @@ static int
drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 14 lines
  		*val = state->picture_aspect_ratio;
  	} else if (property == config->content_type_property) {
  		*val = state->content_type;
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
+	} else if (property == connector->colorspace_property) {
+		*val = state->colorspace;
  	} else if (property == connector->scaling_mode_property) {
  		*val = state->scaling_mode;
  	} else if (property ==

connector->content_protection_property)
{ diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 8475396..4309873 100644

drivers/gpu/drm/drm_connector.c +0 -0
@@ -826,6 +826,33 @@ int
Quoted 3 lines

drm_display_info_set_bus_formats(struct
drm_display_info *info, };
DRM_ENUM_NAME_FN(drm_get_content_protection_name,

drm_cp_enum_list)

Quoted 16 lines
drivers/gpu/drm/drm_connector.c +16 -0
+static const struct drm_prop_enum_list hdmi_colorspaces[] = {
+	/* For Default case, driver will set the colorspace */
+	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+	/* Standard Definition Colorimetry based on CEA 861 */
+	{ DRM_MODE_COLORIMETRY_SMPTE_170M, "SMPTE_170M" },
+	{ DRM_MODE_COLORIMETRY_BT709, "BT709" },
+	/* Standard Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+	/* High Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+	/* Colorimetry based on IEC 61966-2-1/Amendment 1 */
+	{ DRM_MODE_COLORIMETRY_SYCC_601, "SYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 [33] */
+	{ DRM_MODE_COLORIMETRY_OPYCC_601, "opYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 */
+	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_connector.c

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +8 -0
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_CYCC, "BT2020_CYCC" },
+	/* Added as part of Additional Colorimetry Extension in 861.G */
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-

P3_RGB_D65" },

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/drm_connector.c

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-

P3_RGB_Theater" },

Quoted 9 lines
drivers/gpu/drm/drm_connector.c +2 -0
+};
+
  /**
   * DOC: standard connector properties
   *
@@ -1548,6 +1575,57 @@ int
 drm_mode_create_aspect_ratio_property(struct drm_device *dev)
 EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);
 
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/drm_connector.c int · line 1582

Quoted 5 lines
drivers/gpu/drm/drm_connector.c +4 -0
  /**
+ * DOC: standard connector properties
+ *
+ * Colorspace:
+ *     drm_mode_create_colorspace_property - create colorspace

property

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/drm_connector.c int · line 1585

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+ *     This property helps select a suitable colorspace based on the sink
+ *     capability. Modern sink devices support wider gamut like BT2020.
+ *     This helps switch to BT2020 mode if the BT2020 encoded video

stream

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/drm_connector.c +18 -0
+ *     is being played by the user, same for any other colorspace. Thereby
+ *     giving a good visual experience to users.
+ *
+ *     The expectation from userspace is that it should parse the EDID
+ *     and get supported colorspaces. Use this property and switch to the
+ *     one supported. Sink supported colorspaces should be retrieved by
+ *     userspace from EDID and driver will not explicitly expose them.
+ *
+ *     Basically the expectation from userspace is:
+ *      - Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink
+ *        colorspace
+ *      - Set this new property to let the sink know what it
+ *        converted the CRTC output to.
+ *      - This property is just to inform sink what colorspace
+ *        source is trying to drive.
+ *
+ * Called by a driver the first time it's needed, must be
+attached to desired
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_connector.c int · line 1611

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +8 -0
+ * connectors.
+ */
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIA ||

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/gpu/drm/drm_connector.c int · line 1612

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+	    connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIB) {

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/drm_connector.c int · line 1613

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+		prop = drm_property_create_enum(dev,

DRM_MODE_PROP_ENUM,

drivers/gpu/drm/drm_connector.c int · line 1616

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+						"Colorspace",
+						hdmi_colorspaces,
+
	ARRAY_SIZE(hdmi_colorspaces));

drivers/gpu/drm/drm_connector.c int · line 1620

Quoted 4 lines
drivers/gpu/drm/drm_connector.c +4 -0
+		if (!prop)
+			return -ENOMEM;
+	} else {
+		DRM_DEBUG_KMS("Colorspace property not

supported\n");

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/drm_connector.c int · line 1631

Quoted 11 lines
drivers/gpu/drm/drm_connector.c +10 -0
+		return 0;
+	}
+
+	connector->colorspace_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_colorspace_property);
+
+/**
   * drm_mode_create_content_type_property - create content type

property

Quoted 38 lines
Quoted 30 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/drm_connector.c +0 -0
   * @dev: DRM device
   *
(quoted diff) +0 -0

b/include/drm/drm_connector.h index 9941613..58db66e 100644

include/drm/drm_connector.h +9 -0
@@ -253,6 +253,42 @@ enum drm_panel_orientation {
  	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
  };
 
+/*
+ * This is a consolidated colorimetry list supported by HDMI
+and
+ * DP protocol standard. The respective connectors will
+register
+ * a property with the subset of this list (supported by that
+ * respective protocol). Userspace will set the colorspace
+through
+ * a colorspace property which will be created and exposed to
Quoted 8 lines
Quoted 8 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 272

Quoted 8 lines
include/drm/drm_connector.h +8 -0
+ * userspace.
+ */
+
+/* For Default case, driver will set the colorspace */
+#define DRM_MODE_COLORIMETRY_DEFAULT			0
+/* CEA 861 Normal Colorimetry options */
+#define DRM_MODE_COLORIMETRY_NO_DATA			0
+#define DRM_MODE_COLORIMETRY_SMPTE_170M
	1
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 273

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_BT709			2

Still missing the YCbCr information in these two.

Quoted 8 lines
Quoted 4 lines

As per CTA 861.G spec, we have these as only SMPTE_170M and ITU-R BT709, with no specific mention of RGB or YCbCr. Hence, kept it as per spec. We seem to have a common field for both as per CTA spec. Correct me if my understanding is wrong.

Check
"Table 14 Picture Colorimetry Indicated by the RGB or YC B C R (Y), Colorimetry
(C) and Extended Colorimetry (EC) Field Settings"

Quoted 5 lines

These Y2 Y1 Y0 values should be programmed separately and not through the colorspace as they are data formats isn't it. I feel this should get controlled separately independent of colorimetry, or should we add all the YCbCr and RGB versions and program them as part of this property itself

Quoted 7 lines

?

I don't think we can separate them. The values of the colorimetry bits doesn't mean anything without the Y bits. It would make the uapi kinda crazy if we allow the user to specify BT.2020 RGB but then we actually signal BT.2020 YCbCr in the infoframe, or vice versa. Or we just signal a totally invalid value for all the other cases.

I agree we need data format also to be send along with colorspace, but they are 2 different things. To handle YCbCr and variants (YUV 444, 420 or 422) and RGB I feel we should expose a different API instead of using this one. We can create an output csc property which does that job for us.

Quoted 8 lines

So from a user perspective if we wants to set a colorspace we should use the one in this series and set the data format separately using the other interface. Both will be received in the state variables and later Infoframe packet will be created accordingly. Clubbing both in one may lead to lot of possible combinations exposed as enum which may not look too clean.

What do you say about handling that in the output csc property. I will go with what you recommend .

Programming Y2Y1Y0 is already taken care of, when we added support for YCBCR outputs (4:2:0 implementation). In intel_hdmi.c:intel_hdmi_set_avi_infoframe():

Quoted 8 lines

if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420)

	frame.avi.colorspace = HDMI_COLORSPACE_YUV420;
else if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR444)
	frame.avi.colorspace = HDMI_COLORSPACE_YUV444;
else
	frame.avi.colorspace = HDMI_COLORSPACE_RGB;

IMO This looks like a better way to handle this, ie while adding support for a new format, add support for corresponding AVI IF fileds. This will also make scope of the property under discussion less complicated.

That's an exceptional case. We're programming the CSC in that case to do the RGB->YCbCr conversion without telling userspace. So we must also configure the Y bits automagically.

What we want is a check like so:

if (prop.colorspace != default && output_format != RGB)

     return -INVAL;
Quoted 7 lines

because we can't set up the CSC to make a mess of the user's carefully crafted pixels. The pixels might not even contain RGB data in that case.

We'll need to extend that a little bit once we add the explicit control of the output CSC via another prop. But the same principle should hold.

In fact, I remember the reason why we created infrastructure like this, so that, going forward, we could just add a output_format property, for which, we already have the backed and the state variables ready. The consume of this backend can be this drm_property (like output_format), or internal modeset like YCBCR4:2:0 only modes in EDID. It will also be inline with your suggestion of CSC property.

So we can have two properties colorspace (BT2020/SRGB/REC709) and color_model/color_format(RGB/YCBCR444/420), and a combination of both should program the output AVI info-frames. Does it appeal you ?

- Shashank

Quoted 100 lines
Quoted 100 lines
Quoted 100 lines

Regards,
Uma Shankar

Quoted 94 lines
Quoted 4 lines

My idea was just to update colorimetry fields alone as part of this interface.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 275

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+/* CEA 861 Extended Colorimetry Options */ #define
+DRM_MODE_COLORIMETRY_XVYCC_601
	3
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

include/drm/drm_connector.h enum drm_panel_orientation { · line 276

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_XVYCC_709
	4
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 278

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_COLORIMETRY_SYCC_601			5
+#define DRM_MODE_COLORIMETRY_OPYCC_601
	6
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 280

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_COLORIMETRY_OPRGB			7
+#define DRM_MODE_COLORIMETRY_BT2020_YCC
	8
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 282

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+/* Both BT2020_RGB and BT2020_YCbCbCr have same value */
+#define DRM_MODE_COLORIMETRY_BT2020_RGB
	9
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 283

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_BT2020_CYCC		9

I though you didn't want these numbers to be based on the spec numbers? This duplicated value seems to go against that idea.

Yeah, for HDMI somehow was trying to utilize the definitions to advantage. But I feel, It's better to de-couple this. Define this as normal enum values sequentially so that userspace get readable serial number

kind values.

Quoted 3 lines

And use these in encoder files to get proper values to be programmed as per respective spec, while defining those values per encoder

separately.

Quoted 8 lines
Quoted 8 lines

Hope this is fine.

Quoted 3 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 286

Quoted 3 lines
include/drm/drm_connector.h +3 -0
+/* Additional Colorimetry extension added as part of CTA 861.G */
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65		10
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER
	11
Quoted 3 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 289

Quoted 3 lines
include/drm/drm_connector.h +3 -0
+
+/* DP MSA Colorimetry Options */ #define
+DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_601
	12
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

include/drm/drm_connector.h enum drm_panel_orientation { · line 290

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_709
	13
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Still inconsistent naming in many places (ITU_ vs. BT, YCBCR vs. YCC, order of the two).

Will fix this. Thanks Ville.

Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 292

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_DP_COLORIMETRY_SRGB			14
+#define DRM_MODE_DP_COLORIMETRY_RGB_WIDE_GAMUT
	15
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_DP_COLORIMETRY_SCRGB
	16
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

include/drm/drm_connector.h struct drm_connector_state { · line 543

Quoted 10 lines
include/drm/drm_connector.h +3 -0
+
  /**
   * struct drm_display_info - runtime data about the connected sink
   *
@@ -503,6 +539,13 @@ struct drm_connector_state {
  	unsigned int content_protection;
 
  	/**
+	 * @colorspace: State variable for Connector property to request
+	 * colorspace change on Sink. This is most commonly used to

switch

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

include/drm/drm_connector.h struct drm_connector_state { · line 551

Quoted 8 lines
include/drm/drm_connector.h +5 -0
+	 * to wider color gamuts like BT2020.
+	 */
+	u32 colorspace;
+
+	/**
  	 * @writeback_job: Writeback job for writeback connectors
  	 *
  	 * Holds the framebuffer and out-fence for a writeback

connector.

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 21 lines

As @@ -995,6 +1038,12 @@ struct drm_connector {
struct drm_property *content_protection_property;

/**

include/drm/drm_connector.h +6 -0
+	 * @colorspace_property: Connector property to set the suitable
+	 * colorspace supported by the sink.
+	 */
+	struct drm_property *colorspace_property;
+
+	/**
  	 * @path_blob_ptr:
  	 *
  	 * DRM blob property data for the DP MST path property. This

should only @@ -1269,6 +1318,7 @@ int drm_connector_attach_vrr_capable_property(
int drm_connector_attach_content_protection_property(
struct drm_connector *connector); int
drm_mode_create_aspect_ratio_property(struct drm_device *dev);

include/drm/drm_connector.h +2 -0
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector);
  int drm_mode_create_content_type_property(struct drm_device
Quoted 2 lines

*dev); void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe

*frame,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

const struct

drm_connector_state

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

*conn_state);

Quoted 3 lines

--
1.9.1

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

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

#11 lore raw

Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 341 lines · Shashank

Regards

Shashank

Quoted 321 lines · Ville Syrjälä
Quoted 303 lines · Shashank

Regards
Shashank

Quoted 289 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Shankar, Uma
Sent: Friday, February 8, 2019 5:45 PM
To: Ville Syrjälä <[email protected]>
Cc: [email protected]; Syrjala, Ville <[email protected]>; dri- [email protected]; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 268 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, February 5, 2019 10:02 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 11 lines · Uma Shankar

Create a new connector property to program colorspace to sink devices. Modern sink devices support more than 1 type of colorspace like 601, 709, BT2020 etc. This helps to switch based on content
type which is to be displayed. The decision lies with
compositors as to in which scenarios, a particular colorspace will be picked.

This will be helpful mostly to switch to higher gamut colorspaces like
BT2020 when the media content is encoded as BT2020. Thereby giving a good visual experience to users.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

The expectation from userspace is that it should parse the EDID and get supported colorspaces. Use this property and switch to the one supported. Sink supported colorspaces should be retrieved by userspace from EDID and driver will not explicitly expose

them.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink colorspace
- Set this new property to let the sink know what it converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments. Enhanced the colorspace enum to incorporate both HDMI and DP supported

colorspaces.

Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 36 lines

Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as per Ville, Hans Verkuil and Jonas Karlman suggestions. Changed Default to an unset state where driver will assign the colorspace is not chosen by user, suggested by Ville and Maarten. Addressed other misc review comments from Maarten. Split the changes to have separate colorspace property for DP and HDMI.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list based on the colorspaces supported by the respective protocol standard.

v5: Made the property creation helper accept enum list based on platform capabilties as suggested by Shashank. Consolidated HDMI and DP property creation in the common helper.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian Starkey's suggestion in order to go with string matching at userspace. Updated the commit message to add more details as well kernel docs.

v8: Addressed Maarten's review comments.

v9: Removed macro defines from uapi as per Brian Starkey and Daniel Stone's comments and moved to drm include file. Moved back to older design with exposing all HDMI colorspaces to userspace since infoframe capability is there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten and Jani's ack.

v11: Addressed Ville's review comments. Updated the Macro naming and added DCI-P3 colorspace as well defined in CEA 861.G spec.

Quoted 8 lines

<[email protected]>

---
  drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
  drivers/gpu/drm/drm_connector.c   | 78

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

Quoted 10 lines
  include/drm/drm_connector.h       | 50 +++++++++++++++++++++++++
  3 files changed, 132 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +0 -0
index 9a1f41a..9b5d44f 100644
@@ -746,6 +746,8 @@ static int

drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/drm_atomic_uapi.c

Quoted 7 lines
  			return -EINVAL;
  		}
  		state->content_protection = val;
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
+	} else if (property == connector->colorspace_property) {
+		state->colorspace = val;
  	} else if (property == config->writeback_fb_id_property) {
  		struct drm_framebuffer *fb =

drm_framebuffer_lookup(dev,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

NULL, val);

Quoted 1 line

int ret =

drm_atomic_set_writeback_fb_for_connector(state,

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines

fb); @@

Quoted 2 lines

-814,6 +816,8 @@ static int
drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 14 lines
  		*val = state->picture_aspect_ratio;
  	} else if (property == config->content_type_property) {
  		*val = state->content_type;
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
+	} else if (property == connector->colorspace_property) {
+		*val = state->colorspace;
  	} else if (property == connector->scaling_mode_property) {
  		*val = state->scaling_mode;
  	} else if (property ==

connector->content_protection_property)
{ diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 8475396..4309873 100644

drivers/gpu/drm/drm_connector.c +0 -0
@@ -826,6 +826,33 @@ int
Quoted 3 lines

drm_display_info_set_bus_formats(struct
drm_display_info *info, };
DRM_ENUM_NAME_FN(drm_get_content_protection_name,

drm_cp_enum_list)

Quoted 16 lines
drivers/gpu/drm/drm_connector.c +16 -0
+static const struct drm_prop_enum_list hdmi_colorspaces[] = {
+	/* For Default case, driver will set the colorspace */
+	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+	/* Standard Definition Colorimetry based on CEA 861 */
+	{ DRM_MODE_COLORIMETRY_SMPTE_170M, "SMPTE_170M" },
+	{ DRM_MODE_COLORIMETRY_BT709, "BT709" },
+	/* Standard Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+	/* High Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+	/* Colorimetry based on IEC 61966-2-1/Amendment 1 */
+	{ DRM_MODE_COLORIMETRY_SYCC_601, "SYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 [33] */
+	{ DRM_MODE_COLORIMETRY_OPYCC_601, "opYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 */
+	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_connector.c

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +8 -0
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_CYCC, "BT2020_CYCC" },
+	/* Added as part of Additional Colorimetry Extension in 861.G */
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-

P3_RGB_D65" },

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/drm_connector.c

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-

P3_RGB_Theater" },

Quoted 9 lines
drivers/gpu/drm/drm_connector.c +2 -0
+};
+
  /**
   * DOC: standard connector properties
   *
@@ -1548,6 +1575,57 @@ int
 drm_mode_create_aspect_ratio_property(struct drm_device *dev)
 EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);
 
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/drm_connector.c int · line 1582

Quoted 5 lines
drivers/gpu/drm/drm_connector.c +4 -0
  /**
+ * DOC: standard connector properties
+ *
+ * Colorspace:
+ *     drm_mode_create_colorspace_property - create colorspace

property

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/drm_connector.c int · line 1585

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+ *     This property helps select a suitable colorspace based on the sink
+ *     capability. Modern sink devices support wider gamut like BT2020.
+ *     This helps switch to BT2020 mode if the BT2020 encoded video

stream

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/drm_connector.c +18 -0
+ *     is being played by the user, same for any other colorspace. Thereby
+ *     giving a good visual experience to users.
+ *
+ *     The expectation from userspace is that it should parse the EDID
+ *     and get supported colorspaces. Use this property and switch to the
+ *     one supported. Sink supported colorspaces should be retrieved by
+ *     userspace from EDID and driver will not explicitly expose them.
+ *
+ *     Basically the expectation from userspace is:
+ *      - Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink
+ *        colorspace
+ *      - Set this new property to let the sink know what it
+ *        converted the CRTC output to.
+ *      - This property is just to inform sink what colorspace
+ *        source is trying to drive.
+ *
+ * Called by a driver the first time it's needed, must be
+attached to desired
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_connector.c int · line 1611

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +8 -0
+ * connectors.
+ */
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIA ||

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/gpu/drm/drm_connector.c int · line 1612

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+	    connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIB) {

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/drm_connector.c int · line 1613

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+		prop = drm_property_create_enum(dev,

DRM_MODE_PROP_ENUM,

drivers/gpu/drm/drm_connector.c int · line 1616

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+						"Colorspace",
+						hdmi_colorspaces,
+
	ARRAY_SIZE(hdmi_colorspaces));

drivers/gpu/drm/drm_connector.c int · line 1620

Quoted 4 lines
drivers/gpu/drm/drm_connector.c +4 -0
+		if (!prop)
+			return -ENOMEM;
+	} else {
+		DRM_DEBUG_KMS("Colorspace property not

supported\n");

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/drm_connector.c int · line 1631

Quoted 11 lines
drivers/gpu/drm/drm_connector.c +10 -0
+		return 0;
+	}
+
+	connector->colorspace_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_colorspace_property);
+
+/**
   * drm_mode_create_content_type_property - create content type

property

Quoted 38 lines
Quoted 30 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/drm_connector.c +0 -0
   * @dev: DRM device
   *
(quoted diff) +0 -0

b/include/drm/drm_connector.h index 9941613..58db66e 100644

include/drm/drm_connector.h +9 -0
@@ -253,6 +253,42 @@ enum drm_panel_orientation {
  	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
  };
 
+/*
+ * This is a consolidated colorimetry list supported by HDMI
+and
+ * DP protocol standard. The respective connectors will
+register
+ * a property with the subset of this list (supported by that
+ * respective protocol). Userspace will set the colorspace
+through
+ * a colorspace property which will be created and exposed to
Quoted 8 lines
Quoted 8 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 272

Quoted 8 lines
include/drm/drm_connector.h +8 -0
+ * userspace.
+ */
+
+/* For Default case, driver will set the colorspace */
+#define DRM_MODE_COLORIMETRY_DEFAULT			0
+/* CEA 861 Normal Colorimetry options */
+#define DRM_MODE_COLORIMETRY_NO_DATA			0
+#define DRM_MODE_COLORIMETRY_SMPTE_170M
	1
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 273

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_BT709			2

Still missing the YCbCr information in these two.

Quoted 8 lines
Quoted 4 lines

As per CTA 861.G spec, we have these as only SMPTE_170M and ITU-R BT709, with no specific mention of RGB or YCbCr. Hence, kept it as per spec. We seem to have a common field for both as per CTA spec. Correct me if my understanding is wrong.

Check
"Table 14 Picture Colorimetry Indicated by the RGB or YC B C R (Y), Colorimetry
(C) and Extended Colorimetry (EC) Field Settings"

Quoted 5 lines

These Y2 Y1 Y0 values should be programmed separately and not through the colorspace as they are data formats isn't it. I feel this should get controlled separately independent of colorimetry, or should we add all the YCbCr and RGB versions and program them as part of this property itself

Quoted 7 lines

?

I don't think we can separate them. The values of the colorimetry bits doesn't mean anything without the Y bits. It would make the uapi kinda crazy if we allow the user to specify BT.2020 RGB but then we actually signal BT.2020 YCbCr in the infoframe, or vice versa. Or we just signal a totally invalid value for all the other cases.

I agree we need data format also to be send along with colorspace, but they are 2 different things. To handle YCbCr and variants (YUV 444, 420 or 422) and RGB I feel we should expose a different API instead of using this one. We can create an output csc property which does that job for us.

Quoted 8 lines

So from a user perspective if we wants to set a colorspace we should use the one in this series and set the data format separately using the other interface. Both will be received in the state variables and later Infoframe packet will be created accordingly. Clubbing both in one may lead to lot of possible combinations exposed as enum which may not look too clean.

What do you say about handling that in the output csc property. I will go with what you recommend .

Programming Y2Y1Y0 is already taken care of, when we added support for YCBCR outputs (4:2:0 implementation). In intel_hdmi.c:intel_hdmi_set_avi_infoframe():

Quoted 8 lines

if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420)

	frame.avi.colorspace = HDMI_COLORSPACE_YUV420;
else if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR444)
	frame.avi.colorspace = HDMI_COLORSPACE_YUV444;
else
	frame.avi.colorspace = HDMI_COLORSPACE_RGB;

IMO This looks like a better way to handle this, ie while adding support for a new format, add support for corresponding AVI IF fileds. This will also make scope of the property under discussion less complicated.

That's an exceptional case. We're programming the CSC in that case to do the RGB->YCbCr conversion without telling userspace. So we must also configure the Y bits automagically.

What we want is a check like so:

if (prop.colorspace != default && output_format != RGB)

     return -INVAL;
Quoted 7 lines

because we can't set up the CSC to make a mess of the user's carefully crafted pixels. The pixels might not even contain RGB data in that case.

We'll need to extend that a little bit once we add the explicit control of the output CSC via another prop. But the same principle should hold.

In fact, I remember the reason why we created infrastructure like this, so that, going forward, we could just add a output_format property, for which, we already have the backed and the state variables ready. The consume of this backend can be this drm_property (like output_format), or internal modeset like YCBCR4:2:0 only modes in EDID. It will also be inline with your suggestion of CSC property.

Quoted 3 lines

So we can have two properties colorspace (BT2020/SRGB/REC709) and color_model/color_format(RGB/YCBCR444/420), and a combination of both should program the output AVI info-frames. Does it appeal you ?

I'm not sure it's feasible to split it like that. The combinations supported by the infoframe are rather specific so trying to split it up leads to either super limited uapi, or one that exposes a lot of illegal combinations. Also DP has slightly different set of things it supports which adds more complications.

So I think the best option is still to include the Y=yes/no information in the prop value alognside the C/EC/ACE bits.

Quoted 111 lines

- Shashank

Quoted 108 lines
Quoted 108 lines
Quoted 108 lines

Regards,
Uma Shankar

Quoted 92 lines
Quoted 4 lines

My idea was just to update colorimetry fields alone as part of this interface.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 275

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+/* CEA 861 Extended Colorimetry Options */ #define
+DRM_MODE_COLORIMETRY_XVYCC_601
	3
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

include/drm/drm_connector.h enum drm_panel_orientation { · line 276

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_XVYCC_709
	4
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 278

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_COLORIMETRY_SYCC_601			5
+#define DRM_MODE_COLORIMETRY_OPYCC_601
	6
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 280

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_COLORIMETRY_OPRGB			7
+#define DRM_MODE_COLORIMETRY_BT2020_YCC
	8
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 282

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+/* Both BT2020_RGB and BT2020_YCbCbCr have same value */
+#define DRM_MODE_COLORIMETRY_BT2020_RGB
	9
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 283

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_BT2020_CYCC		9

I though you didn't want these numbers to be based on the spec numbers? This duplicated value seems to go against that idea.

Yeah, for HDMI somehow was trying to utilize the definitions to advantage. But I feel, It's better to de-couple this. Define this as normal enum values sequentially so that userspace get readable serial number

kind values.

Quoted 3 lines

And use these in encoder files to get proper values to be programmed as per respective spec, while defining those values per encoder

separately.

Quoted 8 lines
Quoted 8 lines

Hope this is fine.

Quoted 3 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 286

Quoted 3 lines
include/drm/drm_connector.h +3 -0
+/* Additional Colorimetry extension added as part of CTA 861.G */
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65		10
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER
	11
Quoted 3 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 289

Quoted 3 lines
include/drm/drm_connector.h +3 -0
+
+/* DP MSA Colorimetry Options */ #define
+DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_601
	12
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

include/drm/drm_connector.h enum drm_panel_orientation { · line 290

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_709
	13
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Still inconsistent naming in many places (ITU_ vs. BT, YCBCR vs. YCC, order of the two).

Will fix this. Thanks Ville.

Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 292

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_DP_COLORIMETRY_SRGB			14
+#define DRM_MODE_DP_COLORIMETRY_RGB_WIDE_GAMUT
	15
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_DP_COLORIMETRY_SCRGB
	16
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

include/drm/drm_connector.h struct drm_connector_state { · line 543

Quoted 10 lines
include/drm/drm_connector.h +3 -0
+
  /**
   * struct drm_display_info - runtime data about the connected sink
   *
@@ -503,6 +539,13 @@ struct drm_connector_state {
  	unsigned int content_protection;
 
  	/**
+	 * @colorspace: State variable for Connector property to request
+	 * colorspace change on Sink. This is most commonly used to

switch

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

include/drm/drm_connector.h struct drm_connector_state { · line 551

Quoted 8 lines
include/drm/drm_connector.h +5 -0
+	 * to wider color gamuts like BT2020.
+	 */
+	u32 colorspace;
+
+	/**
  	 * @writeback_job: Writeback job for writeback connectors
  	 *
  	 * Holds the framebuffer and out-fence for a writeback

connector.

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 21 lines

As @@ -995,6 +1038,12 @@ struct drm_connector {
struct drm_property *content_protection_property;

/**

include/drm/drm_connector.h +6 -0
+	 * @colorspace_property: Connector property to set the suitable
+	 * colorspace supported by the sink.
+	 */
+	struct drm_property *colorspace_property;
+
+	/**
  	 * @path_blob_ptr:
  	 *
  	 * DRM blob property data for the DP MST path property. This

should only @@ -1269,6 +1318,7 @@ int drm_connector_attach_vrr_capable_property(
int drm_connector_attach_content_protection_property(
struct drm_connector *connector); int
drm_mode_create_aspect_ratio_property(struct drm_device *dev);

include/drm/drm_connector.h +2 -0
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector);
  int drm_mode_create_content_type_property(struct drm_device
Quoted 2 lines

*dev); void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe

*frame,

Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

const struct

drm_connector_state

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

*conn_state);

Quoted 3 lines

--
1.9.1

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

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

Re: [v11 1/4] drm: Add HDMI colorspace property

Regards

Shashank

Quoted 344 lines · Ville Syrjälä
Quoted 340 lines · Shashank

Regards

Shashank

Quoted 321 lines · Ville Syrjälä
Quoted 303 lines · Shashank

Regards
Shashank

Quoted 289 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Shankar, Uma
Sent: Friday, February 8, 2019 5:45 PM
To: Ville Syrjälä <[email protected]>
Cc: [email protected]; Syrjala, Ville <[email protected]>; dri- [email protected]; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 268 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, February 5, 2019 10:02 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 11 lines · Uma Shankar

Create a new connector property to program colorspace to sink devices. Modern sink devices support more than 1 type of colorspace like 601, 709, BT2020 etc. This helps to switch based on content
type which is to be displayed. The decision lies with
compositors as to in which scenarios, a particular colorspace will be picked.

This will be helpful mostly to switch to higher gamut colorspaces like
BT2020 when the media content is encoded as BT2020. Thereby giving a good visual experience to users.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

The expectation from userspace is that it should parse the EDID and get supported colorspaces. Use this property and switch to the one supported. Sink supported colorspaces should be retrieved by userspace from EDID and driver will not explicitly expose

them.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink colorspace
- Set this new property to let the sink know what it converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments. Enhanced the colorspace enum to incorporate both HDMI and DP supported

colorspaces.

Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 36 lines

Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as per Ville, Hans Verkuil and Jonas Karlman suggestions. Changed Default to an unset state where driver will assign the colorspace is not chosen by user, suggested by Ville and Maarten. Addressed other misc review comments from Maarten. Split the changes to have separate colorspace property for DP and HDMI.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list based on the colorspaces supported by the respective protocol standard.

v5: Made the property creation helper accept enum list based on platform capabilties as suggested by Shashank. Consolidated HDMI and DP property creation in the common helper.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian Starkey's suggestion in order to go with string matching at userspace. Updated the commit message to add more details as well kernel docs.

v8: Addressed Maarten's review comments.

v9: Removed macro defines from uapi as per Brian Starkey and Daniel Stone's comments and moved to drm include file. Moved back to older design with exposing all HDMI colorspaces to userspace since infoframe capability is there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten and Jani's ack.

v11: Addressed Ville's review comments. Updated the Macro naming and added DCI-P3 colorspace as well defined in CEA 861.G spec.

Quoted 8 lines

<[email protected]>

---
   drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
   drivers/gpu/drm/drm_connector.c   | 78

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

Quoted 10 lines
   include/drm/drm_connector.h       | 50 +++++++++++++++++++++++++
   3 files changed, 132 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +0 -0
index 9a1f41a..9b5d44f 100644
@@ -746,6 +746,8 @@ static int

drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/drm_atomic_uapi.c

Quoted 7 lines
   			return -EINVAL;
   		}
   		state->content_protection = val;
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
+	} else if (property == connector->colorspace_property) {
+		state->colorspace = val;
   	} else if (property == config->writeback_fb_id_property) {
   		struct drm_framebuffer *fb =

drm_framebuffer_lookup(dev,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

NULL, val);

Quoted 1 line

int ret =

drm_atomic_set_writeback_fb_for_connector(state,

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines

fb); @@

Quoted 2 lines

-814,6 +816,8 @@ static int
drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 14 lines
   		*val = state->picture_aspect_ratio;
   	} else if (property == config->content_type_property) {
   		*val = state->content_type;
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
+	} else if (property == connector->colorspace_property) {
+		*val = state->colorspace;
   	} else if (property == connector->scaling_mode_property) {
   		*val = state->scaling_mode;
   	} else if (property ==

connector->content_protection_property)
{ diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 8475396..4309873 100644

drivers/gpu/drm/drm_connector.c +0 -0
@@ -826,6 +826,33 @@ int
Quoted 3 lines

drm_display_info_set_bus_formats(struct
drm_display_info *info, };
DRM_ENUM_NAME_FN(drm_get_content_protection_name,

drm_cp_enum_list)

Quoted 16 lines
drivers/gpu/drm/drm_connector.c +16 -0
+static const struct drm_prop_enum_list hdmi_colorspaces[] = {
+	/* For Default case, driver will set the colorspace */
+	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+	/* Standard Definition Colorimetry based on CEA 861 */
+	{ DRM_MODE_COLORIMETRY_SMPTE_170M, "SMPTE_170M" },
+	{ DRM_MODE_COLORIMETRY_BT709, "BT709" },
+	/* Standard Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+	/* High Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+	/* Colorimetry based on IEC 61966-2-1/Amendment 1 */
+	{ DRM_MODE_COLORIMETRY_SYCC_601, "SYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 [33] */
+	{ DRM_MODE_COLORIMETRY_OPYCC_601, "opYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 */
+	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_connector.c

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +8 -0
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_CYCC, "BT2020_CYCC" },
+	/* Added as part of Additional Colorimetry Extension in 861.G */
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-

P3_RGB_D65" },

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/drm_connector.c

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-

P3_RGB_Theater" },

Quoted 9 lines
drivers/gpu/drm/drm_connector.c +2 -0
+};
+
   /**
    * DOC: standard connector properties
    *
@@ -1548,6 +1575,57 @@ int
 drm_mode_create_aspect_ratio_property(struct drm_device *dev)
 EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);
 
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/drm_connector.c int · line 1582

Quoted 5 lines
drivers/gpu/drm/drm_connector.c +4 -0
   /**
+ * DOC: standard connector properties
+ *
+ * Colorspace:
+ *     drm_mode_create_colorspace_property - create colorspace

property

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/drm_connector.c int · line 1585

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+ *     This property helps select a suitable colorspace based on the sink
+ *     capability. Modern sink devices support wider gamut like BT2020.
+ *     This helps switch to BT2020 mode if the BT2020 encoded video

stream

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/drm_connector.c +18 -0
+ *     is being played by the user, same for any other colorspace. Thereby
+ *     giving a good visual experience to users.
+ *
+ *     The expectation from userspace is that it should parse the EDID
+ *     and get supported colorspaces. Use this property and switch to the
+ *     one supported. Sink supported colorspaces should be retrieved by
+ *     userspace from EDID and driver will not explicitly expose them.
+ *
+ *     Basically the expectation from userspace is:
+ *      - Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink
+ *        colorspace
+ *      - Set this new property to let the sink know what it
+ *        converted the CRTC output to.
+ *      - This property is just to inform sink what colorspace
+ *        source is trying to drive.
+ *
+ * Called by a driver the first time it's needed, must be
+attached to desired
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_connector.c int · line 1611

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +8 -0
+ * connectors.
+ */
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIA ||

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/gpu/drm/drm_connector.c int · line 1612

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+	    connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIB) {

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/drm_connector.c int · line 1613

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+		prop = drm_property_create_enum(dev,

DRM_MODE_PROP_ENUM,

drivers/gpu/drm/drm_connector.c int · line 1616

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+						"Colorspace",
+						hdmi_colorspaces,
+
	ARRAY_SIZE(hdmi_colorspaces));

drivers/gpu/drm/drm_connector.c int · line 1620

Quoted 4 lines
drivers/gpu/drm/drm_connector.c +4 -0
+		if (!prop)
+			return -ENOMEM;
+	} else {
+		DRM_DEBUG_KMS("Colorspace property not

supported\n");

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/drm_connector.c int · line 1631

Quoted 11 lines
drivers/gpu/drm/drm_connector.c +10 -0
+		return 0;
+	}
+
+	connector->colorspace_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_colorspace_property);
+
+/**
    * drm_mode_create_content_type_property - create content type

property

Quoted 38 lines
Quoted 30 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/drm_connector.c +0 -0
    * @dev: DRM device
    *
(quoted diff) +0 -0

b/include/drm/drm_connector.h index 9941613..58db66e 100644

include/drm/drm_connector.h +9 -0
@@ -253,6 +253,42 @@ enum drm_panel_orientation {
   	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
   };
 
+/*
+ * This is a consolidated colorimetry list supported by HDMI
+and
+ * DP protocol standard. The respective connectors will
+register
+ * a property with the subset of this list (supported by that
+ * respective protocol). Userspace will set the colorspace
+through
+ * a colorspace property which will be created and exposed to
Quoted 8 lines
Quoted 8 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 272

Quoted 8 lines
include/drm/drm_connector.h +8 -0
+ * userspace.
+ */
+
+/* For Default case, driver will set the colorspace */
+#define DRM_MODE_COLORIMETRY_DEFAULT			0
+/* CEA 861 Normal Colorimetry options */
+#define DRM_MODE_COLORIMETRY_NO_DATA			0
+#define DRM_MODE_COLORIMETRY_SMPTE_170M
	1
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 273

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_BT709			2

Still missing the YCbCr information in these two.

Quoted 8 lines
Quoted 4 lines

As per CTA 861.G spec, we have these as only SMPTE_170M and ITU-R BT709, with no specific mention of RGB or YCbCr. Hence, kept it as per spec. We seem to have a common field for both as per CTA spec. Correct me if my understanding is wrong.

Check
"Table 14 Picture Colorimetry Indicated by the RGB or YC B C R (Y), Colorimetry
(C) and Extended Colorimetry (EC) Field Settings"

Quoted 5 lines

These Y2 Y1 Y0 values should be programmed separately and not through the colorspace as they are data formats isn't it. I feel this should get controlled separately independent of colorimetry, or should we add all the YCbCr and RGB versions and program them as part of this property itself

Quoted 7 lines

?

I don't think we can separate them. The values of the colorimetry bits doesn't mean anything without the Y bits. It would make the uapi kinda crazy if we allow the user to specify BT.2020 RGB but then we actually signal BT.2020 YCbCr in the infoframe, or vice versa. Or we just signal a totally invalid value for all the other cases.

I agree we need data format also to be send along with colorspace, but they are 2 different things. To handle YCbCr and variants (YUV 444, 420 or 422) and RGB I feel we should expose a different API instead of using this one. We can create an output csc property which does that job for us.

Quoted 8 lines

So from a user perspective if we wants to set a colorspace we should use the one in this series and set the data format separately using the other interface. Both will be received in the state variables and later Infoframe packet will be created accordingly. Clubbing both in one may lead to lot of possible combinations exposed as enum which may not look too clean.

What do you say about handling that in the output csc property. I will go with what you recommend .

Programming Y2Y1Y0 is already taken care of, when we added support for YCBCR outputs (4:2:0 implementation). In intel_hdmi.c:intel_hdmi_set_avi_infoframe():

Quoted 8 lines

if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420)

	frame.avi.colorspace = HDMI_COLORSPACE_YUV420;
else if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR444)
	frame.avi.colorspace = HDMI_COLORSPACE_YUV444;
else
	frame.avi.colorspace = HDMI_COLORSPACE_RGB;

IMO This looks like a better way to handle this, ie while adding support for a new format, add support for corresponding AVI IF fileds. This will also make scope of the property under discussion less complicated.

That's an exceptional case. We're programming the CSC in that case to do the RGB->YCbCr conversion without telling userspace. So we must also configure the Y bits automagically.

What we want is a check like so:

if (prop.colorspace != default && output_format != RGB)

      return -INVAL;
Quoted 7 lines

because we can't set up the CSC to make a mess of the user's carefully crafted pixels. The pixels might not even contain RGB data in that case.

We'll need to extend that a little bit once we add the explicit control of the output CSC via another prop. But the same principle should hold.

In fact, I remember the reason why we created infrastructure like this, so that, going forward, we could just add a output_format property, for which, we already have the backed and the state variables ready. The consume of this backend can be this drm_property (like output_format), or internal modeset like YCBCR4:2:0 only modes in EDID. It will also be inline with your suggestion of CSC property.

Quoted 3 lines

So we can have two properties colorspace (BT2020/SRGB/REC709) and color_model/color_format(RGB/YCBCR444/420), and a combination of both should program the output AVI info-frames. Does it appeal you ?

Quoted 8 lines

I'm not sure it's feasible to split it like that. The combinations supported by the infoframe are rather specific so trying to split it up leads to either super limited uapi, or one that exposes a lot of illegal combinations. Also DP has slightly different set of things it supports which adds more complications.

So I think the best option is still to include the Y=yes/no information in the prop value alognside the C/EC/ACE bits.

Yes, you are right, this could be a simpler way of doing things, but with a limited set of combination.

Consider this example:

- If a HDMI monitor supports BT2020, but doesn't support YCBCR formatting, how to handle this option ? This means we have to selectively show BT2020_RGB enum value only not BT2020_YCBCR_444/420,

- This also means we have to probe the EDID first, and then create this property, which means we will be dependent on the hot-plug / detect to create this property, instead of doing this in hdmi_init.

Even more complex scenario would be when the output support depends on monitor + platform both. This means we have to provide this combination upfront while creating this property.

On the other hand, the invalid combination of two property, it would be easy to detect at runtime at atomic_check() and fail the commit.

This is just a thought, honestly I am also not sure what would be the most appropriate solution for this, but seems its simpler to create property with two properties, might be difficult to manage at runtime.

With one property, its very difficult to create, but once created, it would work sure shot.

- Shashank

Quoted 101 lines
Quoted 101 lines

- Shashank

Quoted 99 lines
Quoted 99 lines
Quoted 99 lines

Regards,
Uma Shankar

Quoted 94 lines
Quoted 4 lines

My idea was just to update colorimetry fields alone as part of this interface.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 275

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+/* CEA 861 Extended Colorimetry Options */ #define
+DRM_MODE_COLORIMETRY_XVYCC_601
	3
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

include/drm/drm_connector.h enum drm_panel_orientation { · line 276

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_XVYCC_709
	4
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 278

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_COLORIMETRY_SYCC_601			5
+#define DRM_MODE_COLORIMETRY_OPYCC_601
	6
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 280

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_COLORIMETRY_OPRGB			7
+#define DRM_MODE_COLORIMETRY_BT2020_YCC
	8
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 282

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+/* Both BT2020_RGB and BT2020_YCbCbCr have same value */
+#define DRM_MODE_COLORIMETRY_BT2020_RGB
	9
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 283

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_BT2020_CYCC		9

I though you didn't want these numbers to be based on the spec numbers? This duplicated value seems to go against that idea.

Yeah, for HDMI somehow was trying to utilize the definitions to advantage. But I feel, It's better to de-couple this. Define this as normal enum values sequentially so that userspace get readable serial number

kind values.

Quoted 3 lines

And use these in encoder files to get proper values to be programmed as per respective spec, while defining those values per encoder

separately.

Quoted 8 lines
Quoted 8 lines

Hope this is fine.

Quoted 3 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 286

Quoted 3 lines
include/drm/drm_connector.h +3 -0
+/* Additional Colorimetry extension added as part of CTA 861.G */
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65		10
+#define DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER
	11
Quoted 3 lines
Quoted 3 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 289

Quoted 3 lines
include/drm/drm_connector.h +3 -0
+
+/* DP MSA Colorimetry Options */ #define
+DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_601
	12
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

include/drm/drm_connector.h enum drm_panel_orientation { · line 290

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_709
	13
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Still inconsistent naming in many places (ITU_ vs. BT, YCBCR vs. YCC, order of the two).

Will fix this. Thanks Ville.

Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 292

Quoted 2 lines
include/drm/drm_connector.h +2 -0
+#define DRM_MODE_DP_COLORIMETRY_SRGB			14
+#define DRM_MODE_DP_COLORIMETRY_RGB_WIDE_GAMUT
	15
Quoted 1 line
Quoted 1 line
Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_DP_COLORIMETRY_SCRGB
	16
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

include/drm/drm_connector.h struct drm_connector_state { · line 543

Quoted 10 lines
include/drm/drm_connector.h +3 -0
+
   /**
    * struct drm_display_info - runtime data about the connected sink
    *
@@ -503,6 +539,13 @@ struct drm_connector_state {
   	unsigned int content_protection;
 
   	/**
+	 * @colorspace: State variable for Connector property to request
+	 * colorspace change on Sink. This is most commonly used to

switch

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

include/drm/drm_connector.h struct drm_connector_state { · line 551

Quoted 8 lines
include/drm/drm_connector.h +5 -0
+	 * to wider color gamuts like BT2020.
+	 */
+	u32 colorspace;
+
+	/**
   	 * @writeback_job: Writeback job for writeback connectors
   	 *
   	 * Holds the framebuffer and out-fence for a writeback

connector.

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 21 lines
As @@ -995,6 +1038,12 @@ struct drm_connector {
   	struct drm_property *content_protection_property;

   	/**
include/drm/drm_connector.h +6 -0
+	 * @colorspace_property: Connector property to set the suitable
+	 * colorspace supported by the sink.
+	 */
+	struct drm_property *colorspace_property;
+
+	/**
   	 * @path_blob_ptr:
   	 *
   	 * DRM blob property data for the DP MST path property. This

should only @@ -1269,6 +1318,7 @@ int drm_connector_attach_vrr_capable_property(
int drm_connector_attach_content_protection_property(
struct drm_connector *connector); int
drm_mode_create_aspect_ratio_property(struct drm_device *dev);

include/drm/drm_connector.h +2 -0
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector);
   int drm_mode_create_content_type_property(struct drm_device
Quoted 2 lines

*dev); void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe

*frame,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

const struct

drm_connector_state

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

*conn_state);

Quoted 3 lines

--
1.9.1

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

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

#13 lore raw

Re: [v11 1/4] drm: Add HDMI colorspace property

Quoted 363 lines · Shashank

Regards

Shashank

Quoted 344 lines · Ville Syrjälä
Quoted 340 lines · Shashank

Regards

Shashank

Quoted 321 lines · Ville Syrjälä
Quoted 303 lines · Shashank

Regards
Shashank

Quoted 289 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Shankar, Uma
Sent: Friday, February 8, 2019 5:45 PM
To: Ville Syrjälä <[email protected]>
Cc: [email protected]; Syrjala, Ville <[email protected]>; dri- [email protected]; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 268 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, February 5, 2019 10:02 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 11 lines · Uma Shankar

Create a new connector property to program colorspace to sink devices. Modern sink devices support more than 1 type of colorspace like 601, 709, BT2020 etc. This helps to switch based on content
type which is to be displayed. The decision lies with
compositors as to in which scenarios, a particular colorspace will be picked.

This will be helpful mostly to switch to higher gamut colorspaces like
BT2020 when the media content is encoded as BT2020. Thereby giving a good visual experience to users.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

The expectation from userspace is that it should parse the EDID and get supported colorspaces. Use this property and switch to the one supported. Sink supported colorspaces should be retrieved by userspace from EDID and driver will not explicitly expose

them.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink colorspace
- Set this new property to let the sink know what it converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments. Enhanced the colorspace enum to incorporate both HDMI and DP supported

colorspaces.

Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 36 lines

Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as per Ville, Hans Verkuil and Jonas Karlman suggestions. Changed Default to an unset state where driver will assign the colorspace is not chosen by user, suggested by Ville and Maarten. Addressed other misc review comments from Maarten. Split the changes to have separate colorspace property for DP and HDMI.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list based on the colorspaces supported by the respective protocol standard.

v5: Made the property creation helper accept enum list based on platform capabilties as suggested by Shashank. Consolidated HDMI and DP property creation in the common helper.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian Starkey's suggestion in order to go with string matching at userspace. Updated the commit message to add more details as well kernel docs.

v8: Addressed Maarten's review comments.

v9: Removed macro defines from uapi as per Brian Starkey and Daniel Stone's comments and moved to drm include file. Moved back to older design with exposing all HDMI colorspaces to userspace since infoframe capability is there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten and Jani's ack.

v11: Addressed Ville's review comments. Updated the Macro naming and added DCI-P3 colorspace as well defined in CEA 861.G spec.

Quoted 8 lines

<[email protected]>

---
   drivers/gpu/drm/drm_atomic_uapi.c |  4 ++
   drivers/gpu/drm/drm_connector.c   | 78

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

Quoted 10 lines
   include/drm/drm_connector.h       | 50 +++++++++++++++++++++++++
   3 files changed, 132 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +0 -0
index 9a1f41a..9b5d44f 100644
@@ -746,6 +746,8 @@ static int

drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/drm_atomic_uapi.c

Quoted 7 lines
   			return -EINVAL;
   		}
   		state->content_protection = val;
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
+	} else if (property == connector->colorspace_property) {
+		state->colorspace = val;
   	} else if (property == config->writeback_fb_id_property) {
   		struct drm_framebuffer *fb =

drm_framebuffer_lookup(dev,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

NULL, val);

Quoted 1 line

int ret =

drm_atomic_set_writeback_fb_for_connector(state,

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines

fb); @@

Quoted 2 lines

-814,6 +816,8 @@ static int
drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 14 lines
   		*val = state->picture_aspect_ratio;
   	} else if (property == config->content_type_property) {
   		*val = state->content_type;
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
+	} else if (property == connector->colorspace_property) {
+		*val = state->colorspace;
   	} else if (property == connector->scaling_mode_property) {
   		*val = state->scaling_mode;
   	} else if (property ==

connector->content_protection_property)
{ diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 8475396..4309873 100644

drivers/gpu/drm/drm_connector.c +0 -0
@@ -826,6 +826,33 @@ int
Quoted 3 lines

drm_display_info_set_bus_formats(struct
drm_display_info *info, };
DRM_ENUM_NAME_FN(drm_get_content_protection_name,

drm_cp_enum_list)

Quoted 16 lines
drivers/gpu/drm/drm_connector.c +16 -0
+static const struct drm_prop_enum_list hdmi_colorspaces[] = {
+	/* For Default case, driver will set the colorspace */
+	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+	/* Standard Definition Colorimetry based on CEA 861 */
+	{ DRM_MODE_COLORIMETRY_SMPTE_170M, "SMPTE_170M" },
+	{ DRM_MODE_COLORIMETRY_BT709, "BT709" },
+	/* Standard Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+	/* High Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+	/* Colorimetry based on IEC 61966-2-1/Amendment 1 */
+	{ DRM_MODE_COLORIMETRY_SYCC_601, "SYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 [33] */
+	{ DRM_MODE_COLORIMETRY_OPYCC_601, "opYCC_601" },
+	/* Colorimetry based on IEC 61966-2-5 */
+	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_connector.c

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +8 -0
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB" },
+	/* Colorimetry based on ITU-R BT.2020 */
+	{ DRM_MODE_COLORIMETRY_BT2020_CYCC, "BT2020_CYCC" },
+	/* Added as part of Additional Colorimetry Extension in 861.G */
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-

P3_RGB_D65" },

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/drm_connector.c

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-

P3_RGB_Theater" },

Quoted 9 lines
drivers/gpu/drm/drm_connector.c +2 -0
+};
+
   /**
    * DOC: standard connector properties
    *
@@ -1548,6 +1575,57 @@ int
 drm_mode_create_aspect_ratio_property(struct drm_device *dev)
 EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);
 
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/gpu/drm/drm_connector.c int · line 1582

Quoted 5 lines
drivers/gpu/drm/drm_connector.c +4 -0
   /**
+ * DOC: standard connector properties
+ *
+ * Colorspace:
+ *     drm_mode_create_colorspace_property - create colorspace

property

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/drm_connector.c int · line 1585

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+ *     This property helps select a suitable colorspace based on the sink
+ *     capability. Modern sink devices support wider gamut like BT2020.
+ *     This helps switch to BT2020 mode if the BT2020 encoded video

stream

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/drm_connector.c +18 -0
+ *     is being played by the user, same for any other colorspace. Thereby
+ *     giving a good visual experience to users.
+ *
+ *     The expectation from userspace is that it should parse the EDID
+ *     and get supported colorspaces. Use this property and switch to the
+ *     one supported. Sink supported colorspaces should be retrieved by
+ *     userspace from EDID and driver will not explicitly expose them.
+ *
+ *     Basically the expectation from userspace is:
+ *      - Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink
+ *        colorspace
+ *      - Set this new property to let the sink know what it
+ *        converted the CRTC output to.
+ *      - This property is just to inform sink what colorspace
+ *        source is trying to drive.
+ *
+ * Called by a driver the first time it's needed, must be
+attached to desired
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_connector.c int · line 1611

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +8 -0
+ * connectors.
+ */
+int drm_mode_create_colorspace_property(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIA ||

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

drivers/gpu/drm/drm_connector.c int · line 1612

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+	    connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIB) {

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/drm_connector.c int · line 1613

Quoted 1 line
drivers/gpu/drm/drm_connector.c +1 -0
+		prop = drm_property_create_enum(dev,

DRM_MODE_PROP_ENUM,

drivers/gpu/drm/drm_connector.c int · line 1616

Quoted 3 lines
drivers/gpu/drm/drm_connector.c +3 -0
+						"Colorspace",
+						hdmi_colorspaces,
+
	ARRAY_SIZE(hdmi_colorspaces));

drivers/gpu/drm/drm_connector.c int · line 1620

Quoted 4 lines
drivers/gpu/drm/drm_connector.c +4 -0
+		if (!prop)
+			return -ENOMEM;
+	} else {
+		DRM_DEBUG_KMS("Colorspace property not

supported\n");

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/drm_connector.c int · line 1631

Quoted 11 lines
drivers/gpu/drm/drm_connector.c +10 -0
+		return 0;
+	}
+
+	connector->colorspace_property = prop;
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_colorspace_property);
+
+/**
    * drm_mode_create_content_type_property - create content type

property

Quoted 38 lines
Quoted 30 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/drm_connector.c +0 -0
    * @dev: DRM device
    *
(quoted diff) +0 -0

b/include/drm/drm_connector.h index 9941613..58db66e 100644

include/drm/drm_connector.h +9 -0
@@ -253,6 +253,42 @@ enum drm_panel_orientation {
   	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
   };
 
+/*
+ * This is a consolidated colorimetry list supported by HDMI
+and
+ * DP protocol standard. The respective connectors will
+register
+ * a property with the subset of this list (supported by that
+ * respective protocol). Userspace will set the colorspace
+through
+ * a colorspace property which will be created and exposed to
Quoted 8 lines
Quoted 8 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 272

Quoted 8 lines
include/drm/drm_connector.h +8 -0
+ * userspace.
+ */
+
+/* For Default case, driver will set the colorspace */
+#define DRM_MODE_COLORIMETRY_DEFAULT			0
+/* CEA 861 Normal Colorimetry options */
+#define DRM_MODE_COLORIMETRY_NO_DATA			0
+#define DRM_MODE_COLORIMETRY_SMPTE_170M
	1
Quoted 2 lines
Quoted 2 lines

include/drm/drm_connector.h enum drm_panel_orientation { · line 273

Quoted 1 line
include/drm/drm_connector.h +1 -0
+#define DRM_MODE_COLORIMETRY_BT709			2

Still missing the YCbCr information in these two.

Quoted 8 lines
Quoted 4 lines

As per CTA 861.G spec, we have these as only SMPTE_170M and ITU-R BT709, with no specific mention of RGB or YCbCr. Hence, kept it as per spec. We seem to have a common field for both as per CTA spec. Correct me if my understanding is wrong.

Check
"Table 14 Picture Colorimetry Indicated by the RGB or YC B C R (Y), Colorimetry
(C) and Extended Colorimetry (EC) Field Settings"

Quoted 5 lines

These Y2 Y1 Y0 values should be programmed separately and not through the colorspace as they are data formats isn't it. I feel this should get controlled separately independent of colorimetry, or should we add all the YCbCr and RGB versions and program them as part of this property itself

Quoted 7 lines

?

I don't think we can separate them. The values of the colorimetry bits doesn't mean anything without the Y bits. It would make the uapi kinda crazy if we allow the user to specify BT.2020 RGB but then we actually signal BT.2020 YCbCr in the infoframe, or vice versa. Or we just signal a totally invalid value for all the other cases.

I agree we need data format also to be send along with colorspace, but they are 2 different things. To handle YCbCr and variants (YUV 444, 420 or 422) and RGB I feel we should expose a different API instead of using this one. We can create an output csc property which does that job for us.

Quoted 8 lines

So from a user perspective if we wants to set a colorspace we should use the one in this series and set the data format separately using the other interface. Both will be received in the state variables and later Infoframe packet will be created accordingly. Clubbing both in one may lead to lot of possible combinations exposed as enum which may not look too clean.

What do you say about handling that in the output csc property. I will go with what you recommend .

Programming Y2Y1Y0 is already taken care of, when we added support for YCBCR outputs (4:2:0 implementation). In intel_hdmi.c:intel_hdmi_set_avi_infoframe():

Quoted 8 lines

if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420)

	frame.avi.colorspace = HDMI_COLORSPACE_YUV420;
else if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR444)
	frame.avi.colorspace = HDMI_COLORSPACE_YUV444;
else
	frame.avi.colorspace = HDMI_COLORSPACE_RGB;

IMO This looks like a better way to handle this, ie while adding support for a new format, add support for corresponding AVI IF fileds. This will also make scope of the property under discussion less complicated.

That's an exceptional case. We're programming the CSC in that case to do the RGB->YCbCr conversion without telling userspace. So we must also configure the Y bits automagically.

What we want is a check like so:

if (prop.colorspace != default && output_format != RGB)

      return -INVAL;
Quoted 7 lines

because we can't set up the CSC to make a mess of the user's carefully crafted pixels. The pixels might not even contain RGB data in that case.

We'll need to extend that a little bit once we add the explicit control of the output CSC via another prop. But the same principle should hold.

In fact, I remember the reason why we created infrastructure like this, so that, going forward, we could just add a output_format property, for which, we already have the backed and the state variables ready. The consume of this backend can be this drm_property (like output_format), or internal modeset like YCBCR4:2:0 only modes in EDID. It will also be inline with your suggestion of CSC property.

Quoted 3 lines

So we can have two properties colorspace (BT2020/SRGB/REC709) and color_model/color_format(RGB/YCBCR444/420), and a combination of both should program the output AVI info-frames. Does it appeal you ?

Quoted 8 lines

I'm not sure it's feasible to split it like that. The combinations supported by the infoframe are rather specific so trying to split it up leads to either super limited uapi, or one that exposes a lot of illegal combinations. Also DP has slightly different set of things it supports which adds more complications.

So I think the best option is still to include the Y=yes/no information in the prop value alognside the C/EC/ACE bits.

Yes, you are right, this could be a simpler way of doing things, but with a limited set of combination.

Consider this example:

Quoted 7 lines

- If a HDMI monitor supports BT2020, but doesn't support YCBCR formatting, how to handle this option ? This means we have to selectively show BT2020_RGB enum value only not BT2020_YCBCR_444/420,

- This also means we have to probe the EDID first, and then create this property, which means we will be dependent on the hot-plug / detect to create this property, instead of doing this in hdmi_init.

IMO we just ignore this problem and expose all the legal options the spec has.

If userspace wants to know what's actually supported it will have to parse the EDID. We could think about parsing that in the kernel too and exposing an immutable prop to expose that infromation. But I'm not sure this is such a good idea since we'd basically drown in properties if we try to expose all the information from the EDID. A better long term plan would be a common EDID parsing library for everyone.

Quoted 9 lines

Even more complex scenario would be when the output support depends on monitor + platform both. This means we have to provide this combination upfront while creating this property.

On the other hand, the invalid combination of two property, it would be easy to detect at runtime at atomic_check() and fail the commit.

Quoted 6 lines

This is just a thought, honestly I am also not sure what would be the most appropriate solution for this, but seems its simpler to create property with two properties, might be difficult to manage at runtime.

With one property, its very difficult to create, but once created, it would work sure shot.

I don't think it's that difficult. Just expose all the things in the CTA-861 big table. Which means including the Y bit too.

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

Re: [v11 1/4] drm: Add HDMI colorspace property

Quoted 440 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, February 8, 2019 8:08 PM
To: Sharma, Shashank <[email protected]>
Cc: Shankar, Uma <[email protected]>; [email protected]; Syrjala, Ville <[email protected]>; [email protected]; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 39 lines · Shashank

Regards

Shashank

Quoted 34 lines · Ville Syrjälä
Quoted 33 lines · Shashank

Regards

Shashank

Quoted 28 lines · Ville Syrjälä
Quoted 27 lines · Shashank

Regards
Shashank

Quoted 24 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Shankar, Uma
Sent: Friday, February 8, 2019 5:45 PM
To: Ville Syrjälä <[email protected]>
Cc: [email protected]; Syrjala, Ville <[email protected]>; dri- [email protected]; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, February 5, 2019 10:02 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 1 line · Uma Shankar

Create a new connector property to program colorspace to sink

devices.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Modern sink devices support more than 1 type of colorspace
like 601, 709, BT2020 etc. This helps to switch based on
content type which is to be displayed. The decision lies
with compositors as to in which scenarios, a particular colorspace will

be picked.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

This will be helpful mostly to switch to higher gamut
colorspaces like
BT2020 when the media content is encoded as BT2020.
Thereby giving a good visual experience to users.

The expectation from userspace is that it should parse the
EDID and get supported colorspaces. Use this property and
switch to the one supported. Sink supported colorspaces
should be retrieved by userspace from EDID and driver will
not explicitly expose

them.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink
colorspace
- Set this new property to let the sink know what it
converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments.
Enhanced the colorspace enum to incorporate both HDMI and
DP supported

colorspaces.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as per
Ville, Hans Verkuil and Jonas Karlman suggestions. Changed
Default to an unset state where driver will assign the
colorspace is not chosen by user, suggested by Ville and
Maarten. Addressed other misc review comments from Maarten.
Split the changes to have separate colorspace property for DP and

HDMI.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

v4: Addressed Chris and Ville's review comments, and
created a common colorspace property for DP and HDMI,
filtered the list based on the colorspaces supported by the respective

protocol standard.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

v5: Made the property creation helper accept enum list
based on platform capabilties as suggested by Shashank.
Consolidated HDMI and DP property creation in the common helper.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian
Starkey's suggestion in order to go with string matching at userspace.
Updated the commit message to add more details as well kernel docs.

v8: Addressed Maarten's review comments.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

v9: Removed macro defines from uapi as per Brian Starkey
and Daniel Stone's comments and moved to drm include file.
Moved back to older design with exposing all HDMI
colorspaces to userspace since infoframe capability is
there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten and Jani's

ack.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

v11: Addressed Ville's review comments. Updated the Macro
naming and added DCI-P3 colorspace as well defined in CEA 861.G

spec.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines

Signed-off-by: Uma Shankar <[email protected]>
Acked-by: Jani Nikula <[email protected]>
Reviewed-by: Shashank Sharma <[email protected]>
Reviewed-by: Maarten Lankhorst
<[email protected]>
---
drivers/gpu/drm/drm_atomic_uapi.c | 4 ++
drivers/gpu/drm/drm_connector.c | 78

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

Quoted 1 line

include/drm/drm_connector.h | 50

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

Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines

3 files changed, 132 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c
b/drivers/gpu/drm/drm_atomic_uapi.c
index 9a1f41a..9b5d44f 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -746,6 +746,8 @@ static int
drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

return -EINVAL;
}
state->content_protection = val;
+ } else if (property == connector->colorspace_property) {
+ state->colorspace = val;
} else if (property == config->writeback_fb_id_property) {
struct drm_framebuffer *fb =

drm_framebuffer_lookup(dev,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

NULL, val);

Quoted 1 line

int ret =

drm_atomic_set_writeback_fb_for_connector(state,

Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

fb); @@

Quoted 2 lines

-814,6 +816,8 @@ static int
drm_atomic_connector_set_property(struct

drm_connector *connector,

Quoted 18 lines

*val = state->picture_aspect_ratio;
} else if (property == config->content_type_property) {
*val = state->content_type;
+ } else if (property == connector->colorspace_property) {
+ *val = state->colorspace;
} else if (property == connector->scaling_mode_property) {
*val = state->scaling_mode;
} else if (property ==
connector->content_protection_property)
{ diff --git a/drivers/gpu/drm/drm_connector.c
b/drivers/gpu/drm/drm_connector.c index 8475396..4309873
100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -826,6 +826,33 @@ int
drm_display_info_set_bus_formats(struct
drm_display_info *info, };
DRM_ENUM_NAME_FN(drm_get_content_protection_name,

drm_cp_enum_list)

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

+static const struct drm_prop_enum_list hdmi_colorspaces[] = {
+ /* For Default case, driver will set the colorspace */
+ { DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+ /* Standard Definition Colorimetry based on CEA 861 */
+ { DRM_MODE_COLORIMETRY_SMPTE_170M,

"SMPTE_170M" },

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ { DRM_MODE_COLORIMETRY_BT709, "BT709" },
+ /* Standard Definition Colorimetry based on IEC 61966-2-4

*/

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

+ { DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+ /* High Definition Colorimetry based on IEC 61966-2-4 */
+ { DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+ /* Colorimetry based on IEC 61966-2-1/Amendment 1 */
+ { DRM_MODE_COLORIMETRY_SYCC_601, "SYCC_601" },
+ /* Colorimetry based on IEC 61966-2-5 [33] */
+ { DRM_MODE_COLORIMETRY_OPYCC_601, "opYCC_601" },
+ /* Colorimetry based on IEC 61966-2-5 */
+ { DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
+ /* Colorimetry based on ITU-R BT.2020 */
+ { DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC"

},

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ /* Colorimetry based on ITU-R BT.2020 */
+ { DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB"

},

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ /* Colorimetry based on ITU-R BT.2020 */
+ { DRM_MODE_COLORIMETRY_BT2020_CYCC,

"BT2020_CYCC" },

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ /* Added as part of Additional Colorimetry Extension in

861.G */

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ { DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-

P3_RGB_D65" },

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 1 line

+ { DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-

P3_RGB_Theater" },

Quoted 10 lines

+};
+
/**
* DOC: standard connector properties
*
@@ -1548,6 +1575,57 @@ int
drm_mode_create_aspect_ratio_property(struct drm_device
*dev)
EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

/**
+ * DOC: standard connector properties
+ *
+ * Colorspace:
+ * drm_mode_create_colorspace_property - create colorspace

property

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * This property helps select a suitable colorspace based on the

sink

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * capability. Modern sink devices support wider gamut like

BT2020.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * This helps switch to BT2020 mode if the BT2020 encoded video

stream

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * is being played by the user, same for any other colorspace.

Thereby

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

+ * giving a good visual experience to users.
+ *
+ * The expectation from userspace is that it should parse the EDID
+ * and get supported colorspaces. Use this property and switch to

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * one supported. Sink supported colorspaces should be retrieved

by

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

+ * userspace from EDID and driver will not explicitly expose them.
+ *
+ * Basically the expectation from userspace is:
+ * - Set up CRTC DEGAMMA/CTM/GAMMA to convert to some

sink

Quoted 75 lines
Quoted 75 lines
Quoted 75 lines
Quoted 75 lines
Quoted 75 lines
Quoted 75 lines
Quoted 75 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

+ * colorspace
+ * - Set this new property to let the sink know what it
+ * converted the CRTC output to.
+ * - This property is just to inform sink what colorspace
+ * source is trying to drive.
+ *
+ * Called by a driver the first time it's needed, must be
+attached to desired
+ * connectors.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

+ */
+int drm_mode_create_colorspace_property(struct
+drm_connector
+*connector) {
+ struct drm_device *dev = connector->dev;
+ struct drm_property *prop;
+
+ if (connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIA ||

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIB) {

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 1 line

+ prop = drm_property_create_enum(dev,

DRM_MODE_PROP_ENUM,

Quoted 3 lines

+ "Colorspace",
+ hdmi_colorspaces,
+

	ARRAY_SIZE(hdmi_colorspaces));
Quoted 4 lines

+ if (!prop)
+ return -ENOMEM;
+ } else {
+ DRM_DEBUG_KMS("Colorspace property not

supported\n");

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

+ return 0;
+ }
+
+ connector->colorspace_property = prop;

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

+
+ return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_colorspace_property);
+
+/**
* drm_mode_create_content_type_property - create
content type

property

Quoted 31 lines
Quoted 31 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines

* @dev: DRM device
*
diff --git a/include/drm/drm_connector.h
b/include/drm/drm_connector.h index 9941613..58db66e
100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -253,6 +253,42 @@ enum drm_panel_orientation {
DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
};

+/*
+ * This is a consolidated colorimetry list supported by
+HDMI and
+ * DP protocol standard. The respective connectors will
+register
+ * a property with the subset of this list (supported by
+that
+ * respective protocol). Userspace will set the
+colorspace through
+ * a colorspace property which will be created and
+exposed to

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

+ * userspace.
+ */
+
+/* For Default case, driver will set the colorspace */
+#define DRM_MODE_COLORIMETRY_DEFAULT 0
+/* CEA 861 Normal Colorimetry options */
+#define DRM_MODE_COLORIMETRY_NO_DATA 0
+#define DRM_MODE_COLORIMETRY_SMPTE_170M

	1
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line

+#define DRM_MODE_COLORIMETRY_BT709 2

Still missing the YCbCr information in these two.

As per CTA 861.G spec, we have these as only SMPTE_170M and ITU-R BT709, with no specific mention of RGB or YCbCr. Hence, kept it as per spec. We seem to have a common field for both as

per CTA spec.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 1 line

Correct me if my understanding is wrong.

Check
"Table 14 Picture Colorimetry Indicated by the RGB or YC B C R (Y), Colorimetry
(C) and Extended Colorimetry (EC) Field Settings"

These Y2 Y1 Y0 values should be programmed separately and not through the colorspace as they are data formats isn't it. I feel this should get controlled separately independent of colorimetry, or should we add all the YCbCr and RGB versions and program them as part of this property itself

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

?

I don't think we can separate them. The values of the
colorimetry bits doesn't mean anything without the Y bits. It would make the uapi kinda crazy if we allow the user to specify BT.2020 RGB but then we actually signal BT.2020 YCbCr in the infoframe, or vice versa. Or we just signal a totally invalid value for all the

other cases.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

I agree we need data format also to be send along with colorspace, but they are 2 different things. To handle YCbCr and variants (YUV 444, 420 or 422) and RGB I feel we should expose a different API instead of using this one. We can create an output csc property

which does that job for us.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

So from a user perspective if we wants to set a colorspace we should use the one in this series and set the data format separately using the other interface. Both will be received in the state

variables and later Infoframe packet will be created accordingly.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

Clubbing both in one may lead to lot of possible combinations exposed as enum which may not look too clean.

What do you say about handling that in the output csc property. I will go with what you recommend .

Programming Y2Y1Y0 is already taken care of, when we added support for

YCBCR outputs (4:2:0 implementation).

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

In intel_hdmi.c:intel_hdmi_set_avi_infoframe():

if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420)
frame.avi.colorspace = HDMI_COLORSPACE_YUV420; else if
(crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR444)

	frame.avi.colorspace = HDMI_COLORSPACE_YUV444; else
	frame.avi.colorspace = HDMI_COLORSPACE_RGB;

IMO This looks like a better way to handle this, ie while adding support for a

new format, add support for corresponding AVI IF fileds. This will also make scope of the property under discussion less complicated.

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

That's an exceptional case. We're programming the CSC in that case to do the RGB->YCbCr conversion without telling userspace. So we must also configure the Y bits automagically.

What we want is a check like so:

if (prop.colorspace != default && output_format != RGB)

      return -INVAL;

because we can't set up the CSC to make a mess of the user's carefully crafted pixels. The pixels might not even contain RGB data in that case.

We'll need to extend that a little bit once we add the explicit control of the output CSC via another prop. But the same principle should hold.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

In fact, I remember the reason why we created infrastructure like this, so that, going forward, we could just add a output_format property, for which, we already have the backed and the state variables ready. The consume of this backend can be this drm_property (like output_format), or internal modeset like YCBCR4:2:0 only modes in EDID. It will also be inline with your suggestion of CSC

property.

Quoted 18 lines
Quoted 4 lines
Quoted 4 lines

So we can have two properties colorspace (BT2020/SRGB/REC709) and color_model/color_format(RGB/YCBCR444/420), and a combination of both should program the output AVI info-frames. Does it appeal you ?

Quoted 8 lines

I'm not sure it's feasible to split it like that. The combinations supported by the infoframe are rather specific so trying to split it up leads to either super limited uapi, or one that exposes a lot of illegal combinations. Also DP has slightly different set of things it supports which adds more complications.

So I think the best option is still to include the Y=yes/no information in the prop value alognside the C/EC/ACE bits.

Yes, you are right, this could be a simpler way of doing things, but with a limited set of combination.

Consider this example:

Quoted 7 lines

- If a HDMI monitor supports BT2020, but doesn't support YCBCR formatting, how to handle this option ? This means we have to selectively show BT2020_RGB enum value only not BT2020_YCBCR_444/420,

- This also means we have to probe the EDID first, and then create this property, which means we will be dependent on the hot-plug / detect to create this property, instead of doing this in hdmi_init.

IMO we just ignore this problem and expose all the legal options the spec has.

If userspace wants to know what's actually supported it will have to parse the EDID. We could think about parsing that in the kernel too and exposing an immutable prop to expose that infromation. But I'm not sure this is such a good idea since we'd basically drown in properties if we try to expose all the information from the EDID. A better long term plan would be a common EDID parsing library for everyone.

Quoted 13 lines

Even more complex scenario would be when the output support depends on monitor + platform both. This means we have to provide this combination upfront while creating this property.

On the other hand, the invalid combination of two property, it would be easy to detect at runtime at atomic_check() and fail the commit.

This is just a thought, honestly I am also not sure what would be the most appropriate solution for this, but seems its simpler to create property with two properties, might be difficult to manage at runtime.

Quoted 5 lines
Quoted 2 lines

With one property, its very difficult to create, but once created, it would work sure shot.

I don't think it's that difficult. Just expose all the things in the CTA-861 big table. Which means including the Y bit too.

Hi Ville,
Ok So will try to do this way then:

Have a separate enum option like
DRM_MODE_COLORIMETRY_BT709_YUV444
DRM_MODE_COLORIMETRY_BT709_YUV420
DRM_MODE_COLORIMETRY_BT709_YUV422

and so on for all the others.

Expectation from userspace will be that he should be having content as per above Data format and colorspace and also should be aware that sink is supporting that which can be obtained from EDID.

In driver we will check this and set the appropriate bits of infoframe and send.

Regards,
Uma Shankar

Quoted 4 lines

--
Ville Syrjälä
Intel

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

#15 lore raw

Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 446 lines · Uma
Quoted 440 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, February 8, 2019 8:08 PM
To: Sharma, Shashank <[email protected]>
Cc: Shankar, Uma <[email protected]>; [email protected]; Syrjala, Ville <[email protected]>; [email protected]; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 39 lines · Shashank

Regards

Shashank

Quoted 34 lines · Ville Syrjälä
Quoted 33 lines · Shashank

Regards

Shashank

Quoted 28 lines · Ville Syrjälä
Quoted 27 lines · Shashank

Regards
Shashank

Quoted 24 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Shankar, Uma
Sent: Friday, February 8, 2019 5:45 PM
To: Ville Syrjälä <[email protected]>
Cc: [email protected]; Syrjala, Ville <[email protected]>; dri- [email protected]; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, February 5, 2019 10:02 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected];
[email protected]; Syrjala, Ville
<[email protected]>; Lankhorst, Maarten
<[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace
property

On Tue, Feb 05, 2019 at 09:33:34PM +0530, Uma Shankar wrote:
Create a new connector property to program colorspace to sink

devices.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Modern sink devices support more than 1 type of colorspace
like 601, 709, BT2020 etc. This helps to switch based on
content type which is to be displayed. The decision lies
with compositors as to in which scenarios, a particular colorspace will

be picked.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

This will be helpful mostly to switch to higher gamut
colorspaces like
BT2020 when the media content is encoded as BT2020.
Thereby giving a good visual experience to users.

The expectation from userspace is that it should parse the
EDID and get supported colorspaces. Use this property and
switch to the one supported. Sink supported colorspaces
should be retrieved by userspace from EDID and driver will
not explicitly expose

them.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink
colorspace
- Set this new property to let the sink know what it
converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments.
Enhanced the colorspace enum to incorporate both HDMI and
DP supported

colorspaces.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as per
Ville, Hans Verkuil and Jonas Karlman suggestions. Changed
Default to an unset state where driver will assign the
colorspace is not chosen by user, suggested by Ville and
Maarten. Addressed other misc review comments from Maarten.
Split the changes to have separate colorspace property for DP and

HDMI.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

v4: Addressed Chris and Ville's review comments, and
created a common colorspace property for DP and HDMI,
filtered the list based on the colorspaces supported by the respective

protocol standard.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

v5: Made the property creation helper accept enum list
based on platform capabilties as suggested by Shashank.
Consolidated HDMI and DP property creation in the common helper.

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian
Starkey's suggestion in order to go with string matching at userspace.
Updated the commit message to add more details as well kernel docs.

v8: Addressed Maarten's review comments.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

v9: Removed macro defines from uapi as per Brian Starkey
and Daniel Stone's comments and moved to drm include file.
Moved back to older design with exposing all HDMI
colorspaces to userspace since infoframe capability is
there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten and Jani's

ack.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

v11: Addressed Ville's review comments. Updated the Macro
naming and added DCI-P3 colorspace as well defined in CEA 861.G

spec.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

Signed-off-by: Uma Shankar <[email protected]>
Acked-by: Jani Nikula <[email protected]>
Reviewed-by: Shashank Sharma <[email protected]>
Reviewed-by: Maarten Lankhorst
<[email protected]>
---
drivers/gpu/drm/drm_atomic_uapi.c | 4 ++
drivers/gpu/drm/drm_connector.c | 78
+++++++++++++++++++++++++++++++++++++++
include/drm/drm_connector.h | 50

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

Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

3 files changed, 132 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c
b/drivers/gpu/drm/drm_atomic_uapi.c
index 9a1f41a..9b5d44f 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -746,6 +746,8 @@ static int
drm_atomic_connector_set_property(struct
drm_connector *connector,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

return -EINVAL;
}
state->content_protection = val;
+ } else if (property == connector->colorspace_property) {
+ state->colorspace = val;
} else if (property == config->writeback_fb_id_property) {
struct drm_framebuffer *fb =

drm_framebuffer_lookup(dev,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

NULL, val);
int ret =

drm_atomic_set_writeback_fb_for_connector(state,

Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

fb); @@
-814,6 +816,8 @@ static int
drm_atomic_connector_set_property(struct
drm_connector *connector,
*val = state->picture_aspect_ratio;
} else if (property == config->content_type_property) {
*val = state->content_type;
+ } else if (property == connector->colorspace_property) {
+ *val = state->colorspace;
} else if (property == connector->scaling_mode_property) {
*val = state->scaling_mode;
} else if (property ==
connector->content_protection_property)
{ diff --git a/drivers/gpu/drm/drm_connector.c
b/drivers/gpu/drm/drm_connector.c index 8475396..4309873
100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -826,6 +826,33 @@ int
drm_display_info_set_bus_formats(struct
drm_display_info *info, };
DRM_ENUM_NAME_FN(drm_get_content_protection_name,
drm_cp_enum_list)

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

+static const struct drm_prop_enum_list hdmi_colorspaces[] = {
+ /* For Default case, driver will set the colorspace */
+ { DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+ /* Standard Definition Colorimetry based on CEA 861 */
+ { DRM_MODE_COLORIMETRY_SMPTE_170M,

"SMPTE_170M" },

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ { DRM_MODE_COLORIMETRY_BT709, "BT709" },
+ /* Standard Definition Colorimetry based on IEC 61966-2-4

*/

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

+ { DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+ /* High Definition Colorimetry based on IEC 61966-2-4 */
+ { DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+ /* Colorimetry based on IEC 61966-2-1/Amendment 1 */
+ { DRM_MODE_COLORIMETRY_SYCC_601, "SYCC_601" },
+ /* Colorimetry based on IEC 61966-2-5 [33] */
+ { DRM_MODE_COLORIMETRY_OPYCC_601, "opYCC_601" },
+ /* Colorimetry based on IEC 61966-2-5 */
+ { DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
+ /* Colorimetry based on ITU-R BT.2020 */
+ { DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC"

},

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ /* Colorimetry based on ITU-R BT.2020 */
+ { DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB"

},

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ /* Colorimetry based on ITU-R BT.2020 */
+ { DRM_MODE_COLORIMETRY_BT2020_CYCC,

"BT2020_CYCC" },

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ /* Added as part of Additional Colorimetry Extension in

861.G */

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ { DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-

P3_RGB_D65" },

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

+ { DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-
P3_RGB_Theater" },
+};
+
/**
* DOC: standard connector properties
*
@@ -1548,6 +1575,57 @@ int
drm_mode_create_aspect_ratio_property(struct drm_device
*dev)
EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

/**
+ * DOC: standard connector properties
+ *
+ * Colorspace:
+ * drm_mode_create_colorspace_property - create colorspace

property

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * This property helps select a suitable colorspace based on the

sink

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * capability. Modern sink devices support wider gamut like

BT2020.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * This helps switch to BT2020 mode if the BT2020 encoded video

stream

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * is being played by the user, same for any other colorspace.

Thereby

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

+ * giving a good visual experience to users.
+ *
+ * The expectation from userspace is that it should parse the EDID
+ * and get supported colorspaces. Use this property and switch to

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * one supported. Sink supported colorspaces should be retrieved

by

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

+ * userspace from EDID and driver will not explicitly expose them.
+ *
+ * Basically the expectation from userspace is:
+ * - Set up CRTC DEGAMMA/CTM/GAMMA to convert to some

sink

Quoted 75 lines
Quoted 75 lines
Quoted 75 lines
Quoted 75 lines
Quoted 75 lines
Quoted 75 lines
Quoted 75 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

+ * colorspace
+ * - Set this new property to let the sink know what it
+ * converted the CRTC output to.
+ * - This property is just to inform sink what colorspace
+ * source is trying to drive.
+ *
+ * Called by a driver the first time it's needed, must be
+attached to desired
+ * connectors.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

+ */
+int drm_mode_create_colorspace_property(struct
+drm_connector
+*connector) {
+ struct drm_device *dev = connector->dev;
+ struct drm_property *prop;
+
+ if (connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIA ||

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIB) {

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

+ prop = drm_property_create_enum(dev,
DRM_MODE_PROP_ENUM,
+ "Colorspace",
+ hdmi_colorspaces,
+
ARRAY_SIZE(hdmi_colorspaces));
+ if (!prop)
+ return -ENOMEM;
+ } else {
+ DRM_DEBUG_KMS("Colorspace property not

supported\n");

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

+ return 0;
+ }
+
+ connector->colorspace_property = prop;

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

+
+ return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_colorspace_property);
+
+/**
* drm_mode_create_content_type_property - create
content type

property

Quoted 31 lines
Quoted 31 lines
Quoted 22 lines
Quoted 22 lines

* @dev: DRM device
*
diff --git a/include/drm/drm_connector.h
b/include/drm/drm_connector.h index 9941613..58db66e
100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -253,6 +253,42 @@ enum drm_panel_orientation {
DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
};

+/*
+ * This is a consolidated colorimetry list supported by
+HDMI and
+ * DP protocol standard. The respective connectors will
+register
+ * a property with the subset of this list (supported by
+that
+ * respective protocol). Userspace will set the
+colorspace through
+ * a colorspace property which will be created and
+exposed to

Quoted 8 lines
Quoted 8 lines

+ * userspace.
+ */
+
+/* For Default case, driver will set the colorspace */
+#define DRM_MODE_COLORIMETRY_DEFAULT 0
+/* CEA 861 Normal Colorimetry options */
+#define DRM_MODE_COLORIMETRY_NO_DATA 0
+#define DRM_MODE_COLORIMETRY_SMPTE_170M

	1
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

+#define DRM_MODE_COLORIMETRY_BT709 2
Still missing the YCbCr information in these two.

As per CTA 861.G spec, we have these as only SMPTE_170M and ITU-R BT709, with no specific mention of RGB or YCbCr. Hence, kept it as per spec. We seem to have a common field for both as

per CTA spec.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 1 line

Correct me if my understanding is wrong.

Check
"Table 14 Picture Colorimetry Indicated by the RGB or YC B C R (Y), Colorimetry
(C) and Extended Colorimetry (EC) Field Settings"

These Y2 Y1 Y0 values should be programmed separately and not through the colorspace as they are data formats isn't it. I feel this should get controlled separately independent of colorimetry, or should we add all the YCbCr and RGB versions and program them as part of this property itself

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

?

I don't think we can separate them. The values of the
colorimetry bits doesn't mean anything without the Y bits. It would make the uapi kinda crazy if we allow the user to specify BT.2020 RGB but then we actually signal BT.2020 YCbCr in the infoframe, or vice versa. Or we just signal a totally invalid value for all the

other cases.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

I agree we need data format also to be send along with colorspace, but they are 2 different things. To handle YCbCr and variants (YUV 444, 420 or 422) and RGB I feel we should expose a different API instead of using this one. We can create an output csc property

which does that job for us.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

So from a user perspective if we wants to set a colorspace we should use the one in this series and set the data format separately using the other interface. Both will be received in the state

variables and later Infoframe packet will be created accordingly.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

Clubbing both in one may lead to lot of possible combinations exposed as enum which may not look too clean.

What do you say about handling that in the output csc property. I will go with what you recommend .

Programming Y2Y1Y0 is already taken care of, when we added support for

YCBCR outputs (4:2:0 implementation).

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

In intel_hdmi.c:intel_hdmi_set_avi_infoframe():

if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420)
frame.avi.colorspace = HDMI_COLORSPACE_YUV420; else if
(crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR444)

	frame.avi.colorspace = HDMI_COLORSPACE_YUV444; else
	frame.avi.colorspace = HDMI_COLORSPACE_RGB;

IMO This looks like a better way to handle this, ie while adding support for a

new format, add support for corresponding AVI IF fileds. This will also make scope of the property under discussion less complicated.

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

That's an exceptional case. We're programming the CSC in that case to do the RGB->YCbCr conversion without telling userspace. So we must also configure the Y bits automagically.

What we want is a check like so:

if (prop.colorspace != default && output_format != RGB)

      return -INVAL;

because we can't set up the CSC to make a mess of the user's carefully crafted pixels. The pixels might not even contain RGB data in that case.

We'll need to extend that a little bit once we add the explicit control of the output CSC via another prop. But the same principle should hold.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

In fact, I remember the reason why we created infrastructure like this, so that, going forward, we could just add a output_format property, for which, we already have the backed and the state variables ready. The consume of this backend can be this drm_property (like output_format), or internal modeset like YCBCR4:2:0 only modes in EDID. It will also be inline with your suggestion of CSC

property.

Quoted 18 lines
Quoted 4 lines
Quoted 4 lines

So we can have two properties colorspace (BT2020/SRGB/REC709) and color_model/color_format(RGB/YCBCR444/420), and a combination of both should program the output AVI info-frames. Does it appeal you ?

Quoted 8 lines

I'm not sure it's feasible to split it like that. The combinations supported by the infoframe are rather specific so trying to split it up leads to either super limited uapi, or one that exposes a lot of illegal combinations. Also DP has slightly different set of things it supports which adds more complications.

So I think the best option is still to include the Y=yes/no information in the prop value alognside the C/EC/ACE bits.

Yes, you are right, this could be a simpler way of doing things, but with a limited set of combination.

Consider this example:

Quoted 7 lines

- If a HDMI monitor supports BT2020, but doesn't support YCBCR formatting, how to handle this option ? This means we have to selectively show BT2020_RGB enum value only not BT2020_YCBCR_444/420,

- This also means we have to probe the EDID first, and then create this property, which means we will be dependent on the hot-plug / detect to create this property, instead of doing this in hdmi_init.

IMO we just ignore this problem and expose all the legal options the spec has.

If userspace wants to know what's actually supported it will have to parse the EDID. We could think about parsing that in the kernel too and exposing an immutable prop to expose that infromation. But I'm not sure this is such a good idea since we'd basically drown in properties if we try to expose all the information from the EDID. A better long term plan would be a common EDID parsing library for everyone.

Quoted 13 lines

Even more complex scenario would be when the output support depends on monitor + platform both. This means we have to provide this combination upfront while creating this property.

On the other hand, the invalid combination of two property, it would be easy to detect at runtime at atomic_check() and fail the commit.

This is just a thought, honestly I am also not sure what would be the most appropriate solution for this, but seems its simpler to create property with two properties, might be difficult to manage at runtime.

Quoted 5 lines
Quoted 2 lines

With one property, its very difficult to create, but once created, it would work sure shot.

I don't think it's that difficult. Just expose all the things in the CTA-861 big table. Which means including the Y bit too.

Quoted 7 lines

Hi Ville,
Ok So will try to do this way then:

Have a separate enum option like
DRM_MODE_COLORIMETRY_BT709_YUV444
DRM_MODE_COLORIMETRY_BT709_YUV420
DRM_MODE_COLORIMETRY_BT709_YUV422

Hmm. I'm not quite convinced that we want the subsampling information included here. That will make it difficult to do the output csc property in a way that leaves the driver free to select the subsampling automagically, which we proably still want because of those annoying HDMI 2.0 monitors.

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

Re: [v11 1/4] drm: Add HDMI colorspace property

Quoted 505 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, February 8, 2019 9:06 PM
To: Shankar, Uma <[email protected]>
Cc: Sharma, Shashank <[email protected]>; intel- [email protected]; Syrjala, Ville <[email protected]>; dri- [email protected]; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 83 lines · Uma
Quoted 83 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Friday, February 8, 2019 8:08 PM
To: Sharma, Shashank <[email protected]>
Cc: Shankar, Uma <[email protected]>; [email protected]; Syrjala, Ville <[email protected]>; [email protected]; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 42 lines · Shashank

Regards

Shashank

Quoted 37 lines · Ville Syrjälä
Quoted 36 lines · Shashank

Regards

Shashank

Quoted 31 lines · Ville Syrjälä
Quoted 30 lines · Shashank

Regards
Shashank

Quoted 27 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Shankar, Uma
Sent: Friday, February 8, 2019 5:45 PM
To: Ville Syrjälä <[email protected]>
Cc: [email protected]; Syrjala, Ville <[email protected]>; dri- [email protected]; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI colorspace property

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

-----Original Message-----
From: Ville Syrjälä
[mailto:[email protected]]
Sent: Tuesday, February 5, 2019 10:02 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected];
[email protected]; Syrjala, Ville
<[email protected]>; Lankhorst, Maarten
<[email protected]>
Subject: Re: [Intel-gfx] [v11 1/4] drm: Add HDMI
colorspace property

On Tue, Feb 05, 2019 at 09:33:34PM +0530, Uma Shankar wrote:
Create a new connector property to program colorspace
to sink

devices.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Modern sink devices support more than 1 type of
colorspace like 601, 709, BT2020 etc. This helps to
switch based on content type which is to be displayed.
The decision lies with compositors as to in which
scenarios, a particular colorspace will

be picked.

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

This will be helpful mostly to switch to higher gamut
colorspaces like
BT2020 when the media content is encoded as BT2020.
Thereby giving a good visual experience to users.

The expectation from userspace is that it should parse
the EDID and get supported colorspaces. Use this
property and switch to the one supported. Sink
supported colorspaces should be retrieved by userspace
from EDID and driver will not explicitly expose

them.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Basically the expectation from userspace is:
- Set up CRTC DEGAMMA/CTM/GAMMA to convert to some sink
colorspace
- Set this new property to let the sink know what it
converted the CRTC output to.

v2: Addressed Maarten and Ville's review comments.
Enhanced the colorspace enum to incorporate both HDMI
and DP supported

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

colorspaces.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Also, added a default option for colorspace.

v3: Removed Adobe references from enum definitions as
per Ville, Hans Verkuil and Jonas Karlman suggestions.
Changed Default to an unset state where driver will
assign the colorspace is not chosen by user, suggested
by Ville and Maarten. Addressed other misc review comments from

Maarten.

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Split the changes to have separate colorspace property
for DP and

HDMI.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

v4: Addressed Chris and Ville's review comments, and
created a common colorspace property for DP and HDMI,
filtered the list based on the colorspaces supported by
the respective

Quoted 5 lines
Quoted 5 lines

protocol standard.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

v5: Made the property creation helper accept enum list
based on platform capabilties as suggested by Shashank.
Consolidated HDMI and DP property creation in the common

helper.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

v6: Addressed Shashank's review comments.

v7: Added defines instead of enum in uapi as per Brian
Starkey's suggestion in order to go with string matching at

userspace.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Updated the commit message to add more details as well kernel

docs.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

v8: Addressed Maarten's review comments.

v9: Removed macro defines from uapi as per Brian
Starkey and Daniel Stone's comments and moved to drm include

file.

Quoted 121 lines
Quoted 121 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Moved back to older design with exposing all HDMI
colorspaces to userspace since infoframe capability is
there even on legacy platforms, as per Ville's review comments.

v10: Fixed sparse warnings, updated the RB from Maarten
and Jani's

ack.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

v11: Addressed Ville's review comments. Updated the
Macro naming and added DCI-P3 colorspace as well
defined in CEA 861.G

spec.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

Signed-off-by: Uma Shankar <[email protected]>
Acked-by: Jani Nikula <[email protected]>
Reviewed-by: Shashank Sharma
<[email protected]>
Reviewed-by: Maarten Lankhorst
<[email protected]>
---
drivers/gpu/drm/drm_atomic_uapi.c | 4 ++
drivers/gpu/drm/drm_connector.c | 78

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+++++++++++++++++++++++++++++++++++++++
include/drm/drm_connector.h | 50

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

Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

3 files changed, 132 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c
b/drivers/gpu/drm/drm_atomic_uapi.c
index 9a1f41a..9b5d44f 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -746,6 +746,8 @@ static int
drm_atomic_connector_set_property(struct
drm_connector *connector,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

return -EINVAL;
}
state->content_protection = val;
+ } else if (property == connector->colorspace_property) {
+ state->colorspace = val;
} else if (property == config->writeback_fb_id_property) {
struct drm_framebuffer *fb =

drm_framebuffer_lookup(dev,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

NULL, val);
int ret =

drm_atomic_set_writeback_fb_for_connector(state,

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines

fb); @@
-814,6 +816,8 @@ static int
drm_atomic_connector_set_property(struct
drm_connector *connector,
*val = state->picture_aspect_ratio;
} else if (property == config->content_type_property) {
*val = state->content_type;
+ } else if (property == connector->colorspace_property) {
+ *val = state->colorspace;
} else if (property == connector->scaling_mode_property) {
*val = state->scaling_mode;
} else if (property ==
connector->content_protection_property)
{ diff --git a/drivers/gpu/drm/drm_connector.c
b/drivers/gpu/drm/drm_connector.c index
8475396..4309873
100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -826,6 +826,33 @@ int
drm_display_info_set_bus_formats(struct
drm_display_info *info, };
DRM_ENUM_NAME_FN(drm_get_content_protection_name,
drm_cp_enum_list)

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

+static const struct drm_prop_enum_list hdmi_colorspaces[] = {
+ /* For Default case, driver will set the colorspace */
+ { DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+ /* Standard Definition Colorimetry based on CEA 861 */
+ { DRM_MODE_COLORIMETRY_SMPTE_170M,

"SMPTE_170M" },

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

+ { DRM_MODE_COLORIMETRY_BT709, "BT709" },
+ /* Standard Definition Colorimetry based on IEC
+61966-2-4

*/

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

+ { DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+ /* High Definition Colorimetry based on IEC 61966-2-4 */
+ { DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+ /* Colorimetry based on IEC 61966-2-1/Amendment 1 */
+ { DRM_MODE_COLORIMETRY_SYCC_601, "SYCC_601" },
+ /* Colorimetry based on IEC 61966-2-5 [33] */
+ { DRM_MODE_COLORIMETRY_OPYCC_601, "opYCC_601" },
+ /* Colorimetry based on IEC 61966-2-5 */
+ { DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
+ /* Colorimetry based on ITU-R BT.2020 */
+ { DRM_MODE_COLORIMETRY_BT2020_YCC, "BT2020_YCC"

},

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ /* Colorimetry based on ITU-R BT.2020 */
+ { DRM_MODE_COLORIMETRY_BT2020_RGB, "BT2020_RGB"

},

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ /* Colorimetry based on ITU-R BT.2020 */
+ { DRM_MODE_COLORIMETRY_BT2020_CYCC,

"BT2020_CYCC" },

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+ /* Added as part of Additional Colorimetry Extension
+in

861.G */

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ { DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-

P3_RGB_D65" },

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

+ { DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-
P3_RGB_Theater" },
+};
+
/**
* DOC: standard connector properties
*
@@ -1548,6 +1575,57 @@ int
drm_mode_create_aspect_ratio_property(struct drm_device
*dev)
EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

/**
+ * DOC: standard connector properties
+ *
+ * Colorspace:
+ * drm_mode_create_colorspace_property - create colorspace

property

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * This property helps select a suitable colorspace based on the

sink

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * capability. Modern sink devices support wider gamut like

BT2020.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * This helps switch to BT2020 mode if the BT2020 encoded

video

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

stream

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * is being played by the user, same for any other colorspace.

Thereby

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

+ * giving a good visual experience to users.
+ *
+ * The expectation from userspace is that it should parse the

EDID

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * and get supported colorspaces. Use this property and switch

to

Quoted 2 lines
Quoted 2 lines

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * one supported. Sink supported colorspaces should be

retrieved

Quoted 2 lines
Quoted 2 lines

by

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+ * userspace from EDID and driver will not explicitly expose

them.

Quoted 59 lines
Quoted 59 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

+ *
+ * Basically the expectation from userspace is:
+ * - Set up CRTC DEGAMMA/CTM/GAMMA to convert to some

sink

Quoted 55 lines
Quoted 55 lines
Quoted 55 lines
Quoted 55 lines
Quoted 55 lines
Quoted 55 lines
Quoted 55 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

+ * colorspace
+ * - Set this new property to let the sink know what it
+ * converted the CRTC output to.
+ * - This property is just to inform sink what colorspace
+ * source is trying to drive.
+ *
+ * Called by a driver the first time it's needed, must
+be attached to desired
+ * connectors.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

+ */
+int drm_mode_create_colorspace_property(struct
+drm_connector
+*connector) {
+ struct drm_device *dev = connector->dev;
+ struct drm_property *prop;
+
+ if (connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIA ||

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ connector->connector_type ==

DRM_MODE_CONNECTOR_HDMIB) {

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

+ prop = drm_property_create_enum(dev,
DRM_MODE_PROP_ENUM,
+ "Colorspace",
+ hdmi_colorspaces,
+
ARRAY_SIZE(hdmi_colorspaces));
+ if (!prop)
+ return -ENOMEM;
+ } else {
+ DRM_DEBUG_KMS("Colorspace property not

supported\n");

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

+ return 0;
+ }
+
+ connector->colorspace_property = prop;

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

+
+ return 0;
+}
+EXPORT_SYMBOL(drm_mode_create_colorspace_property);
+
+/**
* drm_mode_create_content_type_property - create
content type

property

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

* @dev: DRM device
*
diff --git a/include/drm/drm_connector.h
b/include/drm/drm_connector.h index 9941613..58db66e
100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -253,6 +253,42 @@ enum drm_panel_orientation {
DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
};

Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

+/*
+ * This is a consolidated colorimetry list supported
+by HDMI and
+ * DP protocol standard. The respective connectors
+will register
+ * a property with the subset of this list (supported
+by that
+ * respective protocol). Userspace will set the

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

+colorspace through
+ * a colorspace property which will be created and
+exposed to
+ * userspace.
+ */
+
+/* For Default case, driver will set the colorspace */
+#define DRM_MODE_COLORIMETRY_DEFAULT

	0
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+/* CEA 861 Normal Colorimetry options */
+#define DRM_MODE_COLORIMETRY_NO_DATA

	0
Quoted 86 lines
Quoted 86 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line

+#define DRM_MODE_COLORIMETRY_SMPTE_170M

	1
Quoted 6 lines

+#define DRM_MODE_COLORIMETRY_BT709 2
Still missing the YCbCr information in these two.
As per CTA 861.G spec, we have these as only SMPTE_170M
and ITU-R BT709, with no specific mention of RGB or YCbCr.
Hence, kept it as per spec. We seem to have a common
field for both as

per CTA spec.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 11 lines
Quoted 5 lines
Quoted 1 line

Correct me if my understanding is wrong.

Check
"Table 14 Picture Colorimetry Indicated by the RGB or YC B C R (Y), Colorimetry
(C) and Extended Colorimetry (EC) Field Settings"

These Y2 Y1 Y0 values should be programmed separately and not through the colorspace as they are data formats isn't it. I feel this should get controlled separately independent of colorimetry, or should we add all the YCbCr and RGB versions and program them as part of this property itself

?

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

I don't think we can separate them. The values of the colorimetry bits doesn't mean anything without the Y bits. It would make the uapi kinda crazy if we allow the user to specify
BT.2020 RGB but then we actually signal BT.2020 YCbCr in the infoframe, or vice versa. Or we just signal a totally invalid value for all the

other cases.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

I agree we need data format also to be send along with colorspace, but they are 2 different things. To handle YCbCr and variants (YUV 444, 420 or 422) and RGB I feel we should expose a different API instead of using this one. We can create an output csc property

which does that job for us.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

So from a user perspective if we wants to set a colorspace we should use the one in this series and set the data format separately using the other interface. Both will be received in the state

variables and later Infoframe packet will be created accordingly.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

Clubbing both in one may lead to lot of possible combinations exposed as enum which may not look too clean.

What do you say about handling that in the output csc property. I will go with what you recommend .

Programming Y2Y1Y0 is already taken care of, when we added support for

YCBCR outputs (4:2:0 implementation).

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

In intel_hdmi.c:intel_hdmi_set_avi_infoframe():

if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420)
frame.avi.colorspace = HDMI_COLORSPACE_YUV420; else if
(crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR444)

	frame.avi.colorspace = HDMI_COLORSPACE_YUV444; else
	frame.avi.colorspace = HDMI_COLORSPACE_RGB;

IMO This looks like a better way to handle this, ie while adding support for a

new format, add support for corresponding AVI IF fileds. This will also make scope of the property under discussion less complicated.

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 9 lines

That's an exceptional case. We're programming the CSC in that case to do the RGB->YCbCr conversion without telling userspace. So we must also configure the Y bits automagically.

What we want is a check like so:

if (prop.colorspace != default && output_format != RGB)

      return -INVAL;
Quoted 7 lines

because we can't set up the CSC to make a mess of the user's carefully crafted pixels. The pixels might not even contain RGB data in that case.

We'll need to extend that a little bit once we add the explicit control of the output CSC via another prop. But the same principle should hold.

In fact, I remember the reason why we created infrastructure like this, so that, going forward, we could just add a output_format property, for which, we already have the backed and the state variables ready. The consume of this backend can be this drm_property (like output_format), or internal modeset like
YCBCR4:2:0 only modes in EDID. It will also be inline with your suggestion of CSC

Quoted 5 lines
Quoted 5 lines

property.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

So we can have two properties colorspace (BT2020/SRGB/REC709) and color_model/color_format(RGB/YCBCR444/420), and a combination of both should program the output AVI info-frames. Does it

appeal you ?

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 8 lines

I'm not sure it's feasible to split it like that. The combinations supported by the infoframe are rather specific so trying to split it up leads to either super limited uapi, or one that exposes a lot of illegal combinations. Also DP has slightly different set of things it supports which adds more complications.

So I think the best option is still to include the Y=yes/no information in the prop value alognside the C/EC/ACE bits.

Yes, you are right, this could be a simpler way of doing things, but with a limited set of combination.

Consider this example:

- If a HDMI monitor supports BT2020, but doesn't support YCBCR formatting, how to handle this option ? This means we have to selectively show BT2020_RGB enum value only not BT2020_YCBCR_444/420,

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

- This also means we have to probe the EDID first, and then create this property, which means we will be dependent on the hot-plug / detect to create this property, instead of doing this in hdmi_init.

IMO we just ignore this problem and expose all the legal options the spec has.

If userspace wants to know what's actually supported it will have to parse the

EDID.

Quoted 4 lines
Quoted 4 lines

We could think about parsing that in the kernel too and exposing an immutable prop to expose that infromation. But I'm not sure this is such a good idea since we'd basically drown in properties if we try to expose all the information from the EDID. A better long term plan would be a

common EDID parsing library for everyone.

Quoted 20 lines
Quoted 14 lines
Quoted 14 lines

Even more complex scenario would be when the output support depends on monitor + platform both. This means we have to provide this combination upfront while creating this property.

On the other hand, the invalid combination of two property, it would be easy to detect at runtime at atomic_check() and fail the commit.

This is just a thought, honestly I am also not sure what would be the most appropriate solution for this, but seems its simpler to create property with two properties, might be difficult to manage at runtime.

Quoted 5 lines
Quoted 2 lines

With one property, its very difficult to create, but once created, it would work sure shot.

I don't think it's that difficult. Just expose all the things in the CTA-861 big table. Which means including the Y bit too.

Quoted 7 lines

Hi Ville,
Ok So will try to do this way then:

Have a separate enum option like
DRM_MODE_COLORIMETRY_BT709_YUV444
DRM_MODE_COLORIMETRY_BT709_YUV420
DRM_MODE_COLORIMETRY_BT709_YUV422

Quoted 4 lines

Hmm. I'm not quite convinced that we want the subsampling information included here. That will make it difficult to do the output csc property in a way that leaves the driver free to select the subsampling automagically, which we proably still want because of those annoying HDMI 2.0 monitors.

Ok, so then I will have all the enum values with explicit information whether its RGB or planar formats. Currently I feel only BT709 and 170M are the ones with ambiguity. Hope we are aligned on this ..

Regards,
Uma Shankar

--

Quoted 2 lines

Ville Syrjälä
Intel

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

#17 lore raw

PATCH v11 2/4 drm: Add DP colorspace property

In reply to Uma Shankar

This patch adds a DP colorspace property, enabling userspace to switch to various supported colorspaces. This will help enable BT2020 along with other colorspaces.

v2: Addressed Maarten and Ville's review comments. Enhanced
the colorspace enum to incorporate both HDMI and DP supported colorspaces. Also, added a default option for colorspace.

v3: Split the changes to have separate colorspace property for DP and HDMI.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list based on the colorspaces supported by the respective protocol standard.

v5: Merged the DP handling along with platform colorspace handling as per Shashank's comments.

v6: Reverted to old design of exposing all colorspaces to userspace as per Ville's review comment

v7: Fixed sparse warnings, updated the RB from Maarten and Jani's ack.

v8: Addressed Ville's review comments and updated the colorspace macro definitions.

---
 drivers/gpu/drm/drm_connector.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/gpu/drm/drm_connector.c +26 -0
index 4309873..86b368bf 100644
@@ -853,6 +853,24 @@ int drm_display_info_set_bus_formats(struct drm_display_info *info,
 	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER, "DCI-P3_RGB_Theater" },
 };
 
+static const struct drm_prop_enum_list dp_colorspaces[] = {
+	/* For Default case, driver will set the colorspace */
+	{ DRM_MODE_COLORIMETRY_DEFAULT, "Default" },
+	/* Standard Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_601, "XVYCC_601" },
+	/* High Definition Colorimetry based on IEC 61966-2-4 */
+	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
+	/* Colorimetry based on IEC 61966-2-5 */
+	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
+	{ DRM_MODE_COLORIMETRY_DCI_P3, "DCI-P3" },
+	/* DP MSA Colorimetry */
+	{ DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_601, "YCBCR_ITU_601" },
+	{ DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_709, "YCBCR_ITU_709" },
+	{ DRM_MODE_DP_COLORIMETRY_SRGB, "sRGB" },
+	{ DRM_MODE_DP_COLORIMETRY_RGB_WIDE_GAMUT, "RGB Wide Gamut" },
+	{ DRM_MODE_DP_COLORIMETRY_SCRGB, "scRGB" },
+};
+
 /**
  * DOC: standard connector properties
  *
@@ -1614,6 +1632,14 @@ int drm_mode_create_colorspace_property(struct drm_connector *connector)
 						ARRAY_SIZE(hdmi_colorspaces));
 		if (!prop)
 			return -ENOMEM;
+	} else if (connector->connector_type == DRM_MODE_CONNECTOR_eDP ||
+		   connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
+		prop = drm_property_create_enum(dev, DRM_MODE_PROP_ENUM,
+						"Colorspace", dp_colorspaces,
+						ARRAY_SIZE(dp_colorspaces));
+
+		if (!prop)
+			return -ENOMEM;
 	} else {
 		DRM_DEBUG_KMS("Colorspace property not supported\n");
 		return 0;
Signature · 6 lines
1.9.1

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

PATCH v11 3/4 drm: Add colorspace info to AVI Infoframe

In reply to Uma Shankar

This adds colorspace information to HDMI AVI infoframe. A helper function is added to program the same.

v2: Moved this to drm core instead of i915 driver.

---
 drivers/gpu/drm/drm_connector.c |  2 +-
 drivers/gpu/drm/drm_edid.c      | 28 ++++++++++++++++++++++++++++
 include/drm/drm_edid.h          |  6 ++++++
 3 files changed, 35 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_connector.c +1 -1
index 86b368bf..086085d 100644
@@ -862,7 +862,7 @@ int drm_display_info_set_bus_formats(struct drm_display_info *info,
 	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
 	/* Colorimetry based on IEC 61966-2-5 */
 	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
-	{ DRM_MODE_COLORIMETRY_DCI_P3, "DCI-P3" },
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-P3_RGB_D65" },
 	/* DP MSA Colorimetry */
 	{ DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_601, "YCBCR_ITU_601" },
 	{ DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_709, "YCBCR_ITU_709" },
drivers/gpu/drm/drm_edid.c +28 -0
index 990b190..1fc0978 100644
@@ -4925,6 +4925,34 @@ static bool is_hdmi2_sink(struct drm_connector *connector)
 EXPORT_SYMBOL(drm_hdmi_avi_infoframe_from_display_mode);
 
 /**
+ * drm_hdmi_avi_infoframe_colorspace() - fill the HDMI AVI infoframe
+ *                                       colorspace information
+ * @frame: HDMI AVI infoframe
+ * @conn_state: connector state
+ */
+void
+drm_hdmi_avi_infoframe_colorspace(struct hdmi_avi_infoframe *frame,
+				  const struct drm_connector_state *conn_state)
+{
+	if (conn_state->colorspace == DRM_MODE_COLORIMETRY_DEFAULT) {
+		/* Set No Data as default for HDMI */
+		frame->colorimetry = DRM_MODE_COLORIMETRY_NO_DATA;
+	} else if (conn_state->colorspace < DRM_MODE_COLORIMETRY_XVYCC_601) {
+		frame->colorimetry = conn_state->colorspace;
+	} else {
+		frame->colorimetry = HDMI_COLORIMETRY_EXTENDED;
+		/*
+		 * Starting from extended list where COLORIMETRY_XV_YCC_601
+		 * is the first extended mode and its value is 0 as per HDMI
+		 * specification.
+		 * ToDO: Extend to support ACE formats defined in CTA 861.G
+		 */
+		frame->extended_colorimetry = conn_state->colorspace -
+						DRM_MODE_COLORIMETRY_XVYCC_601;
+	}
+}
+
+/**
  * drm_hdmi_avi_infoframe_quant_range() - fill the HDMI AVI infoframe
  *                                        quantization range information
  * @frame: HDMI AVI infoframe
include/drm/drm_edid.h +6 -0
index 8dc1a08..9d3b5b9 100644
@@ -331,6 +331,7 @@ struct cea_sad {
 
 struct drm_encoder;
 struct drm_connector;
+struct drm_connector_state;
 struct drm_display_mode;
 
 int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads);
@@ -358,6 +359,11 @@ int drm_av_sync_delay(struct drm_connector *connector,
 drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
 					    struct drm_connector *connector,
 					    const struct drm_display_mode *mode);
+
+void
+drm_hdmi_avi_infoframe_colorspace(struct hdmi_avi_infoframe *frame,
+				  const struct drm_connector_state *conn_state);
+
 void
 drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
 				   struct drm_connector *connector,
Signature · 6 lines
1.9.1

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

Re: [v11 3/4] drm: Add colorspace info to AVI Infoframe

Quoted 47 lines · Uma Shankar

This adds colorspace information to HDMI AVI infoframe. A helper function is added to program the same.

v2: Moved this to drm core instead of i915 driver.

---
 drivers/gpu/drm/drm_connector.c |  2 +-
 drivers/gpu/drm/drm_edid.c      | 28 ++++++++++++++++++++++++++++
 include/drm/drm_edid.h          |  6 ++++++
 3 files changed, 35 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_connector.c +1 -1
index 86b368bf..086085d 100644
@@ -862,7 +862,7 @@ int drm_display_info_set_bus_formats(struct drm_display_info *info,
 	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
 	/* Colorimetry based on IEC 61966-2-5 */
 	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
-	{ DRM_MODE_COLORIMETRY_DCI_P3, "DCI-P3" },
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-P3_RGB_D65" },
 	/* DP MSA Colorimetry */
 	{ DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_601, "YCBCR_ITU_601" },
 	{ DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_709, "YCBCR_ITU_709" },
drivers/gpu/drm/drm_edid.c +14 -0
index 990b190..1fc0978 100644
@@ -4925,6 +4925,34 @@ static bool is_hdmi2_sink(struct drm_connector *connector)
 EXPORT_SYMBOL(drm_hdmi_avi_infoframe_from_display_mode);
 
 /**
+ * drm_hdmi_avi_infoframe_colorspace() - fill the HDMI AVI infoframe
+ *                                       colorspace information
+ * @frame: HDMI AVI infoframe
+ * @conn_state: connector state
+ */
+void
+drm_hdmi_avi_infoframe_colorspace(struct hdmi_avi_infoframe *frame,
+				  const struct drm_connector_state *conn_state)
+{
+	if (conn_state->colorspace == DRM_MODE_COLORIMETRY_DEFAULT) {
+		/* Set No Data as default for HDMI */
+		frame->colorimetry = DRM_MODE_COLORIMETRY_NO_DATA;
+	} else if (conn_state->colorspace < DRM_MODE_COLORIMETRY_XVYCC_601) {
+		frame->colorimetry = conn_state->colorspace;

drivers/gpu/drm/drm_edid.c static bool is_hdmi2_sink(struct drm_connector *connector) · line 4951

Quoted 10 lines
drivers/gpu/drm/drm_edid.c +10 -0
+	} else {
+		frame->colorimetry = HDMI_COLORIMETRY_EXTENDED;
+		/*
+		 * Starting from extended list where COLORIMETRY_XV_YCC_601
+		 * is the first extended mode and its value is 0 as per HDMI
+		 * specification.
+		 * ToDO: Extend to support ACE formats defined in CTA 861.G
+		 */
+		frame->extended_colorimetry = conn_state->colorspace -
+						DRM_MODE_COLORIMETRY_XVYCC_601;

IMO if you don't want to make the numbers based on the spec, then this sould become a proper lookup table.

Quoted 38 lines
drivers/gpu/drm/drm_edid.c +4 -0
+	}
+}
+
+/**
  * drm_hdmi_avi_infoframe_quant_range() - fill the HDMI AVI infoframe
  *                                        quantization range information
  * @frame: HDMI AVI infoframe
include/drm/drm_edid.h +6 -0
index 8dc1a08..9d3b5b9 100644
@@ -331,6 +331,7 @@ struct cea_sad {
 
 struct drm_encoder;
 struct drm_connector;
+struct drm_connector_state;
 struct drm_display_mode;
 
 int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads);
@@ -358,6 +359,11 @@ int drm_av_sync_delay(struct drm_connector *connector,
 drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
 					    struct drm_connector *connector,
 					    const struct drm_display_mode *mode);
+
+void
+drm_hdmi_avi_infoframe_colorspace(struct hdmi_avi_infoframe *frame,
+				  const struct drm_connector_state *conn_state);
+
 void
 drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
 				   struct drm_connector *connector,
Signature · 6 lines
1.9.1

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

RE: [Intel-gfx] [v11 3/4] drm: Add colorspace info to AVI Infoframe

Quoted 73 lines

-----Original Message-----
From: Ville Syrjälä [mailto:[email protected]]
Sent: Tuesday, February 5, 2019 10:03 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Syrjala, Ville <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [Intel-gfx] [v11 3/4] drm: Add colorspace info to AVI Infoframe

drivers/gpu/drm/drm_connector.c int drm_display_info_set_bus_formats(struct

Quoted 17 lines · Uma Shankar

This adds colorspace information to HDMI AVI infoframe. A helper function is added to program the same.

v2: Moved this to drm core instead of i915 driver.

---
 drivers/gpu/drm/drm_connector.c |  2 +-
 drivers/gpu/drm/drm_edid.c      | 28 ++++++++++++++++++++++++++++
 include/drm/drm_edid.h          |  6 ++++++
 3 files changed, 35 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_connector.c index 86b368bf..086085d 100644

drivers/gpu/drm/drm_connector.c +0 -0
@@ -862,7 +862,7 @@ int drm_display_info_set_bus_formats(struct

drm_display_info *info,

drivers/gpu/drm/drm_connector.c int drm_display_info_set_bus_formats(struct drm_display_info *info, · line 868

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +1 -1
 	{ DRM_MODE_COLORIMETRY_XVYCC_709, "XVYCC_709" },
 	/* Colorimetry based on IEC 61966-2-5 */
 	{ DRM_MODE_COLORIMETRY_OPRGB, "opRGB" },
-	{ DRM_MODE_COLORIMETRY_DCI_P3, "DCI-P3" },
+	{ DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65, "DCI-P3_RGB_D65" },
 	/* DP MSA Colorimetry */
 	{ DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_601, "YCBCR_ITU_601" },
 	{ DRM_MODE_DP_COLORIMETRY_YCBCR_ITU_709, "YCBCR_ITU_709" },

diff

Quoted 6 lines

--git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 990b190..1fc0978 100644

drivers/gpu/drm/drm_edid.c +0 -0
@@ -4925,6 +4925,34 @@ static bool is_hdmi2_sink(struct drm_connector
 *connector)  EXPORT_SYMBOL(drm_hdmi_avi_infoframe_from_display_mode);

drivers/gpu/drm/drm_edid.c static bool is_hdmi2_sink(struct drm_connector · line 4935

Quoted 10 lines
drivers/gpu/drm/drm_edid.c +8 -0
 
 /**
+ * drm_hdmi_avi_infoframe_colorspace() - fill the HDMI AVI infoframe
+ *                                       colorspace information
+ * @frame: HDMI AVI infoframe
+ * @conn_state: connector state
+ */
+void
+drm_hdmi_avi_infoframe_colorspace(struct hdmi_avi_infoframe *frame,
+				  const struct drm_connector_state

*conn_state) {

drivers/gpu/drm/drm_edid.c static bool is_hdmi2_sink(struct drm_connector *connector)

Quoted 4 lines
drivers/gpu/drm/drm_edid.c +4 -0
+	if (conn_state->colorspace == DRM_MODE_COLORIMETRY_DEFAULT) {
+		/* Set No Data as default for HDMI */
+		frame->colorimetry = DRM_MODE_COLORIMETRY_NO_DATA;
+	} else if (conn_state->colorspace <

DRM_MODE_COLORIMETRY_XVYCC_601) {

drivers/gpu/drm/drm_edid.c static bool is_hdmi2_sink(struct drm_connector *connector) · line 4954

Quoted 11 lines
drivers/gpu/drm/drm_edid.c +11 -0
+		frame->colorimetry = conn_state->colorspace;
+	} else {
+		frame->colorimetry = HDMI_COLORIMETRY_EXTENDED;
+		/*
+		 * Starting from extended list where COLORIMETRY_XV_YCC_601
+		 * is the first extended mode and its value is 0 as per HDMI
+		 * specification.
+		 * ToDO: Extend to support ACE formats defined in CTA 861.G
+		 */
+		frame->extended_colorimetry = conn_state->colorspace -
+
	DRM_MODE_COLORIMETRY_XVYCC_601;
Quoted 2 lines

IMO if you don't want to make the numbers based on the spec, then this sould become a proper lookup table.

Ok seems good, will define the values separately and use them here.

Quoted 37 lines
Quoted 20 lines
drivers/gpu/drm/drm_edid.c +4 -0
+	}
+}
+
+/**
  * drm_hdmi_avi_infoframe_quant_range() - fill the HDMI AVI infoframe
  *                                        quantization range information
  * @frame: HDMI AVI infoframe
include/drm/drm_edid.h index renamed from include/drm/drm_edid.h +0 -0

8dc1a08..9d3b5b9 100644

include/drm/drm_edid.h +1 -1
@@ -331,6 +331,7 @@ struct cea_sad {
 
 struct drm_encoder;
 struct drm_connector;
+struct drm_connector_state;
 struct drm_display_mode;
 
 int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads); @@
-358,6 +359,11 @@ int drm_av_sync_delay(struct drm_connector
Quoted 1 line

*connector, drm_hdmi_vendor_infoframe_from_display_mode(struct

hdmi_vendor_infoframe *frame,

include/drm/drm_edid.h

Quoted 2 lines
include/drm/drm_edid.h +0 -0
 					    struct drm_connector *connector,
 					    const struct drm_display_mode

*mode);

include/drm/drm_edid.h int drm_av_sync_delay(struct drm_connector *connector,

Quoted 4 lines
include/drm/drm_edid.h +4 -0
+
+void
+drm_hdmi_avi_infoframe_colorspace(struct hdmi_avi_infoframe *frame,
+				  const struct drm_connector_state

*conn_state);

Quoted 7 lines
include/drm/drm_edid.h +1 -1
+
 void
 drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
 				   struct drm_connector *connector,
--

1.9.1

Quoted 8 lines
Quoted 4 lines

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

--
Ville Syrjälä
Intel

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

#21 lore raw

PATCH v11 4/4 drm/i915: Attach colorspace property and enable modeset

In reply to Uma Shankar

This patch attaches the colorspace connector property to the hdmi connector. Based on colorspace change, modeset will be triggered to switch to new colorspace.

Based on colorspace property value create an infoframe with appropriate colorspace. This can be used to send an infoframe packet with proper colorspace value set which will help to enable wider color gamut like BT2020 on sink.

This patch attaches and enables HDMI colorspace, DP will be taken care separately.

v2: Merged the changes of creating infoframe as well to this patch as per Maarten's suggestion.

v3: Addressed review comments from Shashank. Separated HDMI and DP colorspaces as suggested by Ville and Maarten.

v4: Addressed Chris and Ville's review comments, and created a common colorspace property for DP and HDMI, filtered the list based on the colorspaces supported by the respective protocol standard. Handle the default case properly.

v5: Merged the DP handling along with platform colorspace handling as per Shashank's comments.

v6: Reverted to old design of exposing all colorspaces to userspace as per Ville's review comment

v7: Fixed a checkpatch complaint, Addressed Maarten' review comment, updated the RB from Maarten and Jani's ack.

v8: Moved colorspace AVI Infoframe programming to drm core and removed from driver as per Ville's suggestion.

---
 drivers/gpu/drm/i915/intel_atomic.c    |  1 +
 drivers/gpu/drm/i915/intel_connector.c |  8 ++++++++
 drivers/gpu/drm/i915/intel_drv.h       |  1 +
 drivers/gpu/drm/i915/intel_hdmi.c      | 13 +++++++++++++
 4 files changed, 23 insertions(+)
drivers/gpu/drm/i915/intel_atomic.c +1 -0
index 16263ad..a4bb906 100644
@@ -124,6 +124,7 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,
 	 */
 	if (new_conn_state->force_audio != old_conn_state->force_audio ||
 	    new_conn_state->broadcast_rgb != old_conn_state->broadcast_rgb ||
+	    new_conn_state->base.colorspace != old_conn_state->base.colorspace ||
 	    new_conn_state->base.picture_aspect_ratio != old_conn_state->base.picture_aspect_ratio ||
 	    new_conn_state->base.content_type != old_conn_state->base.content_type ||
 	    new_conn_state->base.scaling_mode != old_conn_state->base.scaling_mode)
drivers/gpu/drm/i915/intel_connector.c +8 -0
index ee16758..8352d0b 100644
@@ -265,3 +265,11 @@ int intel_ddc_get_modes(struct drm_connector *connector,
 			connector->dev->mode_config.aspect_ratio_property,
 			DRM_MODE_PICTURE_ASPECT_NONE);
 }
+
+void
+intel_attach_colorspace_property(struct drm_connector *connector)
+{
+	if (!drm_mode_create_colorspace_property(connector))
+		drm_object_attach_property(&connector->base,
+					   connector->colorspace_property, 0);
+}
drivers/gpu/drm/i915/intel_drv.h +1 -0
index 85b913e..5178a9a 100644
@@ -1783,6 +1783,7 @@ int intel_connector_update_modes(struct drm_connector *connector,
 void intel_attach_force_audio_property(struct drm_connector *connector);
 void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
 void intel_attach_aspect_ratio_property(struct drm_connector *connector);
+void intel_attach_colorspace_property(struct drm_connector *connector);
 
 /* intel_csr.c */
 void intel_csr_ucode_init(struct drm_i915_private *);
drivers/gpu/drm/i915/intel_hdmi.c +13 -0
index 97a98e1..0b5e483 100644
@@ -498,6 +498,8 @@ static void intel_hdmi_set_avi_infoframe(struct intel_encoder *encoder,
 	else
 		frame.avi.colorspace = HDMI_COLORSPACE_RGB;
 
+	drm_hdmi_avi_infoframe_colorspace(&frame.avi, conn_state);
+
 	drm_hdmi_avi_infoframe_quant_range(&frame.avi,
 					   conn_state->connector,
 					   adjusted_mode,
@@ -2143,10 +2145,21 @@ static void intel_hdmi_destroy(struct drm_connector *connector)
 intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *connector)
 {
 	struct drm_i915_private *dev_priv = to_i915(connector->dev);
+	struct intel_digital_port *intel_dig_port =
+				hdmi_to_dig_port(intel_hdmi);
 
 	intel_attach_force_audio_property(connector);
 	intel_attach_broadcast_rgb_property(connector);
 	intel_attach_aspect_ratio_property(connector);
+
+	/*
+	 * Attach Colorspace property for Non LSPCON based device
+	 * ToDo: This needs to be extended for LSPCON implementation
+	 * as well. Will be implemented separately.
+	 */
+	if (!intel_dig_port->lspcon.active)
+		intel_attach_colorspace_property(connector);
+
 	drm_connector_attach_content_type_property(connector);
 	connector->state->picture_aspect_ratio = HDMI_PICTURE_ASPECT_NONE;
 
Signature · 6 lines
1.9.1

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

✗ Fi.CI.BAT: failure for Add Colorspace connector property interface (rev11)

In reply to Uma Shankar
== Series Details ==

== Series Details ==

Series: Add Colorspace connector property interface (rev11)
URL : https://patchwork.freedesktop.org/series/47132/
State : failure

== Summary ==

CALL scripts/checksyscalls.sh
DESCEND objtool
CHK include/generated/compile.h
Kernel: arch/x86/boot/bzImage is ready (#1)
Building modules, stage 2.
MODPOST 110 modules
ERROR: "drm_hdmi_avi_infoframe_colorspace" [drivers/gpu/drm/i915/i915.ko] undefined! scripts/Makefile.modpost:92: recipe for target '__modpost' failed make[1]: *** [__modpost] Error 1
Makefile:1260: recipe for target 'modules' failed
make: *** [modules] Error 2

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