Skip to contentSkip to conversation

Add HDR Metadata Parsing and handling in DRM layer

PATCH Superseded Uma Shankar 5 participants 34 messages Mar 20, 2019 – Apr 2, 2019

Subsystems (4)

v6 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v6 cover Add HDR Metadata Parsing and handling in DRM layer

This patch series enables HDR support in drm. It basically defines HDR metadata structures, property to pass content (after blending) metadata from user space compositors to driver.

Dynamic Range and Mastering infoframe creation and sending.

ToDo:
1. We need to get the color framework in place for all planes which support HDR content in hardware. This is already in progres and patches are out for review in mailing list.
2. UserSpace/Compositors: Blending policies and metadata blob creation and passing to driver. Work is already in progress by Intel's middleware teams on wayland and we should be getting the initial version pretty soon for review.

Please review and share your feedbacks/suggestions.

Note: The intention for these patches is to get a design feedback on the uapi changes, generic property design and infoframe handling. This cannot get merged as of now without the userspace support in place.

A POC has already been developed by Ville based on wayland. Please refer below link to see the component interactions and usage:
https://lists.freedesktop.org/archives/wayland-devel/2017-December/036403.html

v2: Updated Ville's POC changes to the patch series.Incorporated cleanups and fixes from Ville. Rebase on latest drm-tip.

v3: Fixed a warning causing builds to break on CI. No major change.

v4: Addressed Shashank's review comments.

v5: Rebase on top of Ville's infoframe refactoring changes. Fixed non modeset case for HDR metadata update. Dropped a redundant patch.

v6: Addressed Shashank's review comments and added RB's received.

Note: Media driver and VAAPI changes for HDR are already out, with compositors changes also expected to land soon. Weston changes already floated and reviews started in community and is in active development along with GL efforts.

Uma Shankar (10):
drm: Add HDR source metadata property
drm: Parse HDR metadata info from EDID
drm: Parse Colorimetry data block from EDID
drm/i915: Attach HDR metadata property to connector
drm: Implement HDR output metadata set and get property handling
drm: Enable HDR infoframe support
drm/i915: Write HDR infoframe and send to panel drm/i915:Enabled Modeset when HDR Infoframe changes drm/i915: Set Infoframe for non modeset case for HDR video/hdmi: Add const variants for drm infoframe

Ville Syrjälä (3):
drm/i915: [DO NOT MERGE] hack for glk board outputs drm/i915: Add HLG EOTF
drm/i915: Enable infoframes on GLK+ for HDR

 drivers/gpu/drm/drm_atomic.c        |   2 +
 drivers/gpu/drm/drm_atomic_uapi.c   |  13 +++
 drivers/gpu/drm/drm_connector.c     |   6 ++
 drivers/gpu/drm/drm_edid.c          | 131 +++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_reg.h     |   4 +
 drivers/gpu/drm/i915/intel_atomic.c |  15 ++-
 drivers/gpu/drm/i915/intel_bios.c   |   7 ++
 drivers/gpu/drm/i915/intel_ddi.c    |  13 +++
 drivers/gpu/drm/i915/intel_drv.h    |   1 +
 drivers/gpu/drm/i915/intel_hdmi.c   |  59 ++++++++++-
 drivers/video/hdmi.c                | 188 ++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h         |  13 +++
 include/drm/drm_edid.h              |   4 +
 include/drm/drm_mode_config.h       |   6 ++
 include/linux/hdmi.h                |  38 ++++++++
 include/uapi/drm/drm_mode.h         |  16 +++
 16 files changed, 513 insertions(+), 3 deletions(-)
Signature · 6 lines
1.9.1

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

PATCH v6 1/13 drm: Add HDR source metadata property

This patch adds a blob property to get HDR metadata information from userspace. This will be send as part of AVI Infoframe to panel.

v2: Rebase and modified the metadata structure elements as per Ville's POC changes.

v3: No Change

v4: Addressed Shashank's review comments

v5: Rebase.

---
 drivers/gpu/drm/drm_connector.c |  6 ++++++
 include/drm/drm_connector.h     | 10 ++++++++++
 include/drm/drm_mode_config.h   |  6 ++++++
 include/linux/hdmi.h            | 10 ++++++++++
 include/uapi/drm/drm_mode.h     | 16 ++++++++++++++++
 5 files changed, 48 insertions(+)
drivers/gpu/drm/drm_connector.c +6 -0
index 2355124..0bdae90 100644
@@ -1058,6 +1058,12 @@ int drm_connector_create_standard_properties(struct drm_device *dev)
 		return -ENOMEM;
 	dev->mode_config.non_desktop_property = prop;
 
+	prop = drm_property_create(dev, DRM_MODE_PROP_BLOB,
+				   "HDR_OUTPUT_METADATA", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.hdr_output_metadata_property = prop;
+
 	return 0;
 }
 
include/drm/drm_connector.h +10 -0
index c806199..29388bd 100644
@@ -561,6 +561,13 @@ struct drm_connector_state {
 	 * and the connector bpc limitations obtained from edid.
 	 */
 	u8 max_bpc;
+
+	/**
+	 * @metadata_blob_ptr:
+	 * DRM blob property for HDR output metadata
+	 */
+	struct drm_property_blob *hdr_output_metadata_blob_ptr;
+	u8 hdr_metadata_changed : 1;
 };
 
 /**
@@ -1201,6 +1208,9 @@ struct drm_connector {
 	 * &drm_mode_config.connector_free_work.
 	 */
 	struct llist_node free_node;
+
+	/* HDR metdata */
+	struct hdr_static_metadata hdr_metadata;
 };
 
 #define obj_to_connector(x) container_of(x, struct drm_connector, base)
include/drm/drm_mode_config.h +6 -0
index 7f60e8e..ef2656b 100644
@@ -836,6 +836,12 @@ struct drm_mode_config {
 	 */
 	struct drm_property *writeback_out_fence_ptr_property;
 
+	/*
+	 * hdr_metadata_property: Connector property containing hdr metatda
+	 * This will be provided by userspace compositors based on HDR content
+	 */
+	struct drm_property *hdr_output_metadata_property;
+
 	/* dumb ioctl parameters */
 	uint32_t preferred_depth, prefer_shadow;
 
include/linux/hdmi.h +10 -0
index 927ad64..a065194 100644
@@ -152,6 +152,16 @@ enum hdmi_content_type {
 	HDMI_CONTENT_TYPE_GAME,
 };
 
+enum hdmi_metadata_type {
+	HDMI_STATIC_METADATA_TYPE1 = 1,
+};
+
+enum hdmi_eotf {
+	HDMI_EOTF_TRADITIONAL_GAMMA_SDR,
+	HDMI_EOTF_TRADITIONAL_GAMMA_HDR,
+	HDMI_EOTF_SMPTE_ST2084,
+};
+
 struct hdmi_avi_infoframe {
 	enum hdmi_infoframe_type type;
 	unsigned char version;
include/uapi/drm/drm_mode.h +16 -0
index a439c2e..5012af2 100644
@@ -630,6 +630,22 @@ struct drm_color_lut {
 	__u16 reserved;
 };
 
+/* HDR Metadata */
+struct hdr_static_metadata {
+	uint8_t eotf;
+	uint8_t metadata_type;
+	struct {
+		uint16_t x, y;
+		} display_primaries[3];
+	struct {
+		uint16_t x, y;
+		} white_point;
+	uint16_t max_mastering_display_luminance;
+	uint16_t min_mastering_display_luminance;
+	uint16_t max_fall;
+	uint16_t max_cll;
+};
+
 #define DRM_MODE_PAGE_FLIP_EVENT 0x01
 #define DRM_MODE_PAGE_FLIP_ASYNC 0x02
 #define DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE 0x4
Signature · 6 lines
1.9.1

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

Re: [v6 01/13] drm: Add HDR source metadata property

Hi Uma,

Quoted 110 lines · Uma Shankar

This patch adds a blob property to get HDR metadata information from userspace. This will be send as part of AVI Infoframe to panel.

v2: Rebase and modified the metadata structure elements as per Ville's POC changes.

v3: No Change

v4: Addressed Shashank's review comments

v5: Rebase.

---
 drivers/gpu/drm/drm_connector.c |  6 ++++++
 include/drm/drm_connector.h     | 10 ++++++++++
 include/drm/drm_mode_config.h   |  6 ++++++
 include/linux/hdmi.h            | 10 ++++++++++
 include/uapi/drm/drm_mode.h     | 16 ++++++++++++++++
 5 files changed, 48 insertions(+)
drivers/gpu/drm/drm_connector.c +6 -0
index 2355124..0bdae90 100644
@@ -1058,6 +1058,12 @@ int drm_connector_create_standard_properties(struct drm_device *dev)
 		return -ENOMEM;
 	dev->mode_config.non_desktop_property = prop;
 
+	prop = drm_property_create(dev, DRM_MODE_PROP_BLOB,
+				   "HDR_OUTPUT_METADATA", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.hdr_output_metadata_property = prop;
+
 	return 0;
 }
 
include/drm/drm_connector.h +10 -0
index c806199..29388bd 100644
@@ -561,6 +561,13 @@ struct drm_connector_state {
 	 * and the connector bpc limitations obtained from edid.
 	 */
 	u8 max_bpc;
+
+	/**
+	 * @metadata_blob_ptr:
+	 * DRM blob property for HDR output metadata
+	 */
+	struct drm_property_blob *hdr_output_metadata_blob_ptr;
+	u8 hdr_metadata_changed : 1;
 };
 
 /**
@@ -1201,6 +1208,9 @@ struct drm_connector {
 	 * &drm_mode_config.connector_free_work.
 	 */
 	struct llist_node free_node;
+
+	/* HDR metdata */
+	struct hdr_static_metadata hdr_metadata;
 };
 
 #define obj_to_connector(x) container_of(x, struct drm_connector, base)
include/drm/drm_mode_config.h +6 -0
index 7f60e8e..ef2656b 100644
@@ -836,6 +836,12 @@ struct drm_mode_config {
 	 */
 	struct drm_property *writeback_out_fence_ptr_property;
 
+	/*
+	 * hdr_metadata_property: Connector property containing hdr metatda
+	 * This will be provided by userspace compositors based on HDR content
+	 */
+	struct drm_property *hdr_output_metadata_property;
+
 	/* dumb ioctl parameters */
 	uint32_t preferred_depth, prefer_shadow;
 
include/linux/hdmi.h +10 -0
index 927ad64..a065194 100644
@@ -152,6 +152,16 @@ enum hdmi_content_type {
 	HDMI_CONTENT_TYPE_GAME,
 };
 
+enum hdmi_metadata_type {
+	HDMI_STATIC_METADATA_TYPE1 = 1,
+};
+
+enum hdmi_eotf {
+	HDMI_EOTF_TRADITIONAL_GAMMA_SDR,
+	HDMI_EOTF_TRADITIONAL_GAMMA_HDR,
+	HDMI_EOTF_SMPTE_ST2084,
+};
+
 struct hdmi_avi_infoframe {
 	enum hdmi_infoframe_type type;
 	unsigned char version;
include/uapi/drm/drm_mode.h +0 -0
index a439c2e..5012af2 100644

include/uapi/drm/drm_mode.h struct drm_color_lut { · line 633

Quoted 4 lines
include/uapi/drm/drm_mode.h +1 -0
@@ -630,6 +630,22 @@ struct drm_color_lut {
 	__u16 reserved;
 };
 
+/* HDR Metadata */

If this is meant to exactly match the layout in the CTA spec, maybe it's worth a note here saying that, to make it clear it isn't arbitrary.

include/uapi/drm/drm_mode.h struct drm_color_lut { · line 646

Quoted 13 lines
include/uapi/drm/drm_mode.h +13 -0
+struct hdr_static_metadata {
+	uint8_t eotf;
+	uint8_t metadata_type;
+	struct {
+		uint16_t x, y;
+		} display_primaries[3];
+	struct {
+		uint16_t x, y;
+		} white_point;
+	uint16_t max_mastering_display_luminance;
+	uint16_t min_mastering_display_luminance;
+	uint16_t max_fall;
+	uint16_t max_cll;

In my copy of CTA-861, fall and cll are the other way around. cll in bytes 23/24, fall in 25/26.

include/uapi/drm/drm_mode.h struct drm_color_lut { · line 647

Quoted 1 line
include/uapi/drm/drm_mode.h +1 -0
+};

The types should be __u8 etc in this kernel header.

It occurred to me that we're likely to want to support dynamic metadata before too long, and I'm sure there'll be other new HDR metadata types too. So, perhaps we should add a "header" of sorts to the HDR_OUTPUT_METADATA blob, to let it be re-used for stuff which isn't "STATIC_METADATA_TYPE1" in the future.

Something like:

struct hdr_output_metadata {
	__u32 metadata_type;
	union {
		struct hdr_static_metadata hdmi_type1;
	};
};

Not sure how DRM feels about unions in ioctl arguments.

Thanks,
-Brian

Quoted 7 lines
include/uapi/drm/drm_mode.h +1 -0
+
 #define DRM_MODE_PAGE_FLIP_EVENT 0x01
 #define DRM_MODE_PAGE_FLIP_ASYNC 0x02
 #define DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE 0x4
Signature · 1 line
1.9.1

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

#3 lore raw

Re: [v6 01/13] drm: Add HDR source metadata property

Quoted 134 lines

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Brian Starkey
Sent: Thursday, March 21, 2019 5:01 PM
To: Shankar, Uma <[email protected]>
Cc: Syrjala, Ville <[email protected]>; Liviu Dudau <[email protected]>; [email protected]; [email protected]; dri- [email protected]; nd <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [v6 01/13] drm: Add HDR source metadata property

Hi Uma,

drivers/gpu/drm/drm_connector.c int drm_connector_create_standard_properties(struct

Quoted 26 lines · Uma Shankar

This patch adds a blob property to get HDR metadata information from userspace. This will be send as part of AVI Infoframe to panel.

v2: Rebase and modified the metadata structure elements as per Ville's POC changes.

v3: No Change

v4: Addressed Shashank's review comments

v5: Rebase.

---
 drivers/gpu/drm/drm_connector.c |  6 ++++++
 include/drm/drm_connector.h     | 10 ++++++++++
 include/drm/drm_mode_config.h   |  6 ++++++
 include/linux/hdmi.h            | 10 ++++++++++
 include/uapi/drm/drm_mode.h     | 16 ++++++++++++++++
 5 files changed, 48 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_connector.c index 2355124..0bdae90 100644

drivers/gpu/drm/drm_connector.c +0 -0
@@ -1058,6 +1058,12 @@ int drm_connector_create_standard_properties(struct

drm_device *dev)

Quoted 83 lines
drivers/gpu/drm/drm_connector.c +6 -0
 		return -ENOMEM;
 	dev->mode_config.non_desktop_property = prop;
 
+	prop = drm_property_create(dev, DRM_MODE_PROP_BLOB,
+				   "HDR_OUTPUT_METADATA", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.hdr_output_metadata_property = prop;
+
 	return 0;
 }
 
include/drm/drm_connector.h +10 -0
index c806199..29388bd 100644
@@ -561,6 +561,13 @@ struct drm_connector_state {
 	 * and the connector bpc limitations obtained from edid.
 	 */
 	u8 max_bpc;
+
+	/**
+	 * @metadata_blob_ptr:
+	 * DRM blob property for HDR output metadata
+	 */
+	struct drm_property_blob *hdr_output_metadata_blob_ptr;
+	u8 hdr_metadata_changed : 1;
 };
 
 /**
@@ -1201,6 +1208,9 @@ struct drm_connector {
 	 * &drm_mode_config.connector_free_work.
 	 */
 	struct llist_node free_node;
+
+	/* HDR metdata */
+	struct hdr_static_metadata hdr_metadata;
 };
 
 #define obj_to_connector(x) container_of(x, struct drm_connector,

base) diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index 7f60e8e..ef2656b 100644

include/drm/drm_mode_config.h +6 -0
@@ -836,6 +836,12 @@ struct drm_mode_config {
 	 */
 	struct drm_property *writeback_out_fence_ptr_property;
 
+	/*
+	 * hdr_metadata_property: Connector property containing hdr metatda
+	 * This will be provided by userspace compositors based on HDR content
+	 */
+	struct drm_property *hdr_output_metadata_property;
+
 	/* dumb ioctl parameters */
 	uint32_t preferred_depth, prefer_shadow;
 
include/linux/hdmi.h index renamed from include/linux/hdmi.h +0 -0

927ad64..a065194 100644

include/linux/hdmi.h +10 -0
@@ -152,6 +152,16 @@ enum hdmi_content_type {
 	HDMI_CONTENT_TYPE_GAME,
 };
 
+enum hdmi_metadata_type {
+	HDMI_STATIC_METADATA_TYPE1 = 1,
+};
+
+enum hdmi_eotf {
+	HDMI_EOTF_TRADITIONAL_GAMMA_SDR,
+	HDMI_EOTF_TRADITIONAL_GAMMA_HDR,
+	HDMI_EOTF_SMPTE_ST2084,
+};
+
 struct hdmi_avi_infoframe {
 	enum hdmi_infoframe_type type;
 	unsigned char version;
include/uapi/drm/drm_mode.h +0 -0
index a439c2e..5012af2 100644

include/uapi/drm/drm_mode.h struct drm_color_lut { · line 633

Quoted 4 lines
include/uapi/drm/drm_mode.h +1 -0
@@ -630,6 +630,22 @@ struct drm_color_lut {
 	__u16 reserved;
 };
 
+/* HDR Metadata */

If this is meant to exactly match the layout in the CTA spec, maybe it's worth a note here saying that, to make it clear it isn't arbitrary.

Quoted 16 lines

include/uapi/drm/drm_mode.h struct drm_color_lut { · line 646

Quoted 13 lines
include/uapi/drm/drm_mode.h +13 -0
+struct hdr_static_metadata {
+	uint8_t eotf;
+	uint8_t metadata_type;
+	struct {
+		uint16_t x, y;
+		} display_primaries[3];
+	struct {
+		uint16_t x, y;
+		} white_point;
+	uint16_t max_mastering_display_luminance;
+	uint16_t min_mastering_display_luminance;
+	uint16_t max_fall;
+	uint16_t max_cll;

In my copy of CTA-861, fall and cll are the other way around. cll in bytes 23/24, fall in 25/26.

Sure Brian, will re-order these.

Quoted 3 lines

include/uapi/drm/drm_mode.h struct drm_color_lut { · line 647

Quoted 1 line
include/uapi/drm/drm_mode.h +1 -0
+};

The types should be __u8 etc in this kernel header.

Ok will update them.

Quoted 7 lines

It occurred to me that we're likely to want to support dynamic metadata before too long, and I'm sure there'll be other new HDR metadata types too. So, perhaps we should add a "header" of sorts to the HDR_OUTPUT_METADATA blob, to let it be re- used for stuff which isn't "STATIC_METADATA_TYPE1" in the future.

Something like:

Quoted 8 lines
struct hdr_output_metadata {
	__u32 metadata_type;
	union {
		struct hdr_static_metadata hdmi_type1;
	};
};

Not sure how DRM feels about unions in ioctl arguments.

Sounds good, I will update like this and will try to test this out.

Thanks & Regards,
Uma Shankar

Quoted 10 lines

Thanks,
-Brian

Quoted 7 lines
include/uapi/drm/drm_mode.h +1 -0
+
 #define DRM_MODE_PAGE_FLIP_EVENT 0x01  #define

DRM_MODE_PAGE_FLIP_ASYNC 0x02 #define
DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE 0x4
--
1.9.1

Quoted 4 lines

_______________________________________________
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

#4 lore raw

PATCH v6 2/13 drm: Parse HDR metadata info from EDID

In reply to Uma Shankar

HDR metadata block is introduced in CEA-861.3 spec. Parsing the same to get the panel's HDR metadata.

v2: Rebase and added Ville's POC changes to the patch.

v3: No Change

v4: Addressed Shashank's review comments

---
 drivers/gpu/drm/drm_edid.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
drivers/gpu/drm/drm_edid.c +49 -0
index fa39592..fd8a621a 100644
@@ -2840,6 +2840,7 @@ static int drm_cvt_modes(struct drm_connector *connector,
 #define VIDEO_BLOCK     0x02
 #define VENDOR_BLOCK    0x03
 #define SPEAKER_BLOCK	0x04
+#define HDR_STATIC_METADATA_BLOCK	0x6
 #define USE_EXTENDED_TAG 0x07
 #define EXT_VIDEO_CAPABILITY_BLOCK 0x00
 #define EXT_VIDEO_DATA_BLOCK_420	0x0E
@@ -3587,6 +3588,12 @@ static int add_3d_struct_modes(struct drm_connector *connector, u16 structure,
 }
 
 static int
+cea_db_payload_len_ext(const u8 *db)
+{
+	return (db[0] & 0x1f) - 1;
+}
+
+static int
 cea_db_extended_tag(const u8 *db)
 {
 	return db[1];
@@ -3822,6 +3829,46 @@ static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode)
 	mode->clock = clock;
 }
 
+static bool cea_db_is_hdmi_hdr_metadata_block(const u8 *db)
+{
+	if (cea_db_tag(db) != USE_EXTENDED_TAG)
+		return false;
+
+	if (db[1] != HDR_STATIC_METADATA_BLOCK)
+		return false;
+
+	return true;
+}
+
+static uint8_t eotf_supported(const u8 *edid_ext)
+{
+	return edid_ext[2] &
+		(BIT(HDMI_EOTF_TRADITIONAL_GAMMA_SDR) |
+		 BIT(HDMI_EOTF_TRADITIONAL_GAMMA_HDR) |
+		 BIT(HDMI_EOTF_SMPTE_ST2084));
+}
+
+static uint8_t hdr_metadata_type(const u8 *edid_ext)
+{
+	return edid_ext[3] &
+		BIT(HDMI_STATIC_METADATA_TYPE1);
+}
+
+static void
+drm_parse_hdr_metadata_block(struct drm_connector *connector, const u8 *db)
+{
+	u16 len;
+
+	len = cea_db_payload_len_ext(db);
+	connector->hdr_metadata.eotf = eotf_supported(db);
+	connector->hdr_metadata.metadata_type = hdr_metadata_type(db);
+
+	if (len >= 5)
+		connector->hdr_metadata.max_fall = db[5];
+	if (len >= 4)
+		connector->hdr_metadata.max_cll = db[4];
+}
+
 static void
 drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
 {
@@ -4449,6 +4496,8 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 			drm_parse_y420cmdb_bitmap(connector, db);
 		if (cea_db_is_vcdb(db))
 			drm_parse_vcdb(connector, db);
+		if (cea_db_is_hdmi_hdr_metadata_block(db))
+			drm_parse_hdr_metadata_block(connector, db);
 	}
 }
 
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v6 2/13
#5 lore raw

Re: [v6 02/13] drm: Parse HDR metadata info from EDID

Quoted 70 lines · Uma Shankar

HDR metadata block is introduced in CEA-861.3 spec. Parsing the same to get the panel's HDR metadata.

v2: Rebase and added Ville's POC changes to the patch.

v3: No Change

v4: Addressed Shashank's review comments

---
  drivers/gpu/drm/drm_edid.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 49 insertions(+)
drivers/gpu/drm/drm_edid.c +34 -0
index fa39592..fd8a621a 100644
@@ -2840,6 +2840,7 @@ static int drm_cvt_modes(struct drm_connector *connector,
  #define VIDEO_BLOCK     0x02
  #define VENDOR_BLOCK    0x03
  #define SPEAKER_BLOCK	0x04
+#define HDR_STATIC_METADATA_BLOCK	0x6
  #define USE_EXTENDED_TAG 0x07
  #define EXT_VIDEO_CAPABILITY_BLOCK 0x00
  #define EXT_VIDEO_DATA_BLOCK_420	0x0E
@@ -3587,6 +3588,12 @@ static int add_3d_struct_modes(struct drm_connector *connector, u16 structure,
  }
 
  static int
+cea_db_payload_len_ext(const u8 *db)
+{
+	return (db[0] & 0x1f) - 1;
+}
+
+static int
  cea_db_extended_tag(const u8 *db)
  {
  	return db[1];
@@ -3822,6 +3829,46 @@ static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode)
  	mode->clock = clock;
  }
 
+static bool cea_db_is_hdmi_hdr_metadata_block(const u8 *db)
+{
+	if (cea_db_tag(db) != USE_EXTENDED_TAG)
+		return false;
+
+	if (db[1] != HDR_STATIC_METADATA_BLOCK)
+		return false;
+
+	return true;
+}
+
+static uint8_t eotf_supported(const u8 *edid_ext)
+{
+	return edid_ext[2] &
+		(BIT(HDMI_EOTF_TRADITIONAL_GAMMA_SDR) |
+		 BIT(HDMI_EOTF_TRADITIONAL_GAMMA_HDR) |
+		 BIT(HDMI_EOTF_SMPTE_ST2084));
+}
+
+static uint8_t hdr_metadata_type(const u8 *edid_ext)
+{
+	return edid_ext[3] &
+		BIT(HDMI_STATIC_METADATA_TYPE1);
+}
+
+static void
+drm_parse_hdr_metadata_block(struct drm_connector *connector, const u8 *db)

drivers/gpu/drm/drm_edid.c static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode) · line 3868

Quoted 10 lines
drivers/gpu/drm/drm_edid.c +10 -0
+{
+	u16 len;
+
+	len = cea_db_payload_len_ext(db);
+	connector->hdr_metadata.eotf = eotf_supported(db);
+	connector->hdr_metadata.metadata_type = hdr_metadata_type(db);
+
+	if (len >= 5)
+		connector->hdr_metadata.max_fall = db[5];
+	if (len >= 4)

Little bike shed, If we pass >=5 we need not to compare >= 4, or we should check >=4 first and then >=5 in sequence.

With that change ( and assuming you fixed the checkpatch stuff already), please feel free to use:

Quoted 7 lines
drivers/gpu/drm/drm_edid.c +3 -0
+		connector->hdr_metadata.max_cll = db[4];
+}
+
  static void
  drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
  {

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4503

Quoted 8 lines
drivers/gpu/drm/drm_edid.c +2 -0
@@ -4449,6 +4496,8 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
  			drm_parse_y420cmdb_bitmap(connector, db);
  		if (cea_db_is_vcdb(db))
  			drm_parse_vcdb(connector, db);
+		if (cea_db_is_hdmi_hdr_metadata_block(db))
+			drm_parse_hdr_metadata_block(connector, db);
  	}
  }
 

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

#6 lore raw

PATCH v6 3/13 drm: Parse Colorimetry data block from EDID

In reply to Uma Shankar

CEA 861.3 spec adds colorimetry data block for HDMI. Parsing the block to get the colorimetry data from panel.

v2: Rebase

v3: No Change

v4: Addressed Shashank's review comments. Updated colorimetry field to 16 bit as DCI-P3 got added in CEA 861-G spec, as pointed out by Shashank.

v5: Fixed checkpatch warnings with --strict option.

---
 drivers/gpu/drm/drm_edid.c  | 25 +++++++++++++++++++++++++
 include/drm/drm_connector.h |  3 +++
 2 files changed, 28 insertions(+)
drivers/gpu/drm/drm_edid.c +25 -0
index fd8a621a..676569b 100644
@@ -2840,6 +2840,7 @@ static int drm_cvt_modes(struct drm_connector *connector,
 #define VIDEO_BLOCK     0x02
 #define VENDOR_BLOCK    0x03
 #define SPEAKER_BLOCK	0x04
+#define COLORIMETRY_DATA_BLOCK		0x5
 #define HDR_STATIC_METADATA_BLOCK	0x6
 #define USE_EXTENDED_TAG 0x07
 #define EXT_VIDEO_CAPABILITY_BLOCK 0x00
@@ -3829,6 +3830,28 @@ static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode)
 	mode->clock = clock;
 }
 
+static bool cea_db_is_hdmi_colorimetry_data_block(const u8 *db)
+{
+	if (cea_db_tag(db) != USE_EXTENDED_TAG)
+		return false;
+
+	if (db[1] != COLORIMETRY_DATA_BLOCK)
+		return false;
+
+	return true;
+}
+
+static void
+drm_parse_colorimetry_data_block(struct drm_connector *connector, const u8 *db)
+{
+	struct drm_hdmi_info *info = &connector->display_info.hdmi;
+	u16 len;
+
+	len = cea_db_payload_len_ext(db);
+	/* As per CEA 861-G spec */
+	info->colorimetry = ((db[3] & (0x1 << 7)) << 1) | db[2];
+}
+
 static bool cea_db_is_hdmi_hdr_metadata_block(const u8 *db)
 {
 	if (cea_db_tag(db) != USE_EXTENDED_TAG)
@@ -4498,6 +4521,8 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 			drm_parse_vcdb(connector, db);
 		if (cea_db_is_hdmi_hdr_metadata_block(db))
 			drm_parse_hdr_metadata_block(connector, db);
+		if (cea_db_is_hdmi_colorimetry_data_block(db))
+			drm_parse_colorimetry_data_block(connector, db);
 	}
 }
 
include/drm/drm_connector.h +3 -0
index 29388bd..94f926e 100644
@@ -206,6 +206,9 @@ struct drm_hdmi_info {
 
 	/** @y420_dc_modes: bitmap of deep color support index */
 	u8 y420_dc_modes;
+
+	/* @colorimetry: bitmap of supported colorimetry modes */
+	u16 colorimetry;
 };
 
 /**
Signature · 6 lines
1.9.1

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

Re: [v6 03/13] drm: Parse Colorimetry data block from EDID

Hi Uma,

Quoted 4 lines · Uma Shankar

CEA 861.3 spec adds colorimetry data block for HDMI. Parsing the block to get the colorimetry data from panel.

While code which parses these parts (patches 2 and 3) out of EDID could be useful - it doesn't seem to actually be used anywhere in the kernel (sorry if I missed it), and I'm not sure it will/can be unless we expose more properties.

The discussion last time leant towards a more useful/generic userspace library for EDID parsing, so perhaps patches 2 and 3 should be dropped.

Did you have an intended use for them in the kernel?

Thanks,
-Brian

Quoted 84 lines

v2: Rebase

v3: No Change

v4: Addressed Shashank's review comments. Updated colorimetry field to 16 bit as DCI-P3 got added in CEA 861-G spec, as pointed out by Shashank.

v5: Fixed checkpatch warnings with --strict option.

---
 drivers/gpu/drm/drm_edid.c  | 25 +++++++++++++++++++++++++
 include/drm/drm_connector.h |  3 +++
 2 files changed, 28 insertions(+)
drivers/gpu/drm/drm_edid.c +25 -0
index fd8a621a..676569b 100644
@@ -2840,6 +2840,7 @@ static int drm_cvt_modes(struct drm_connector *connector,
 #define VIDEO_BLOCK     0x02
 #define VENDOR_BLOCK    0x03
 #define SPEAKER_BLOCK	0x04
+#define COLORIMETRY_DATA_BLOCK		0x5
 #define HDR_STATIC_METADATA_BLOCK	0x6
 #define USE_EXTENDED_TAG 0x07
 #define EXT_VIDEO_CAPABILITY_BLOCK 0x00
@@ -3829,6 +3830,28 @@ static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode)
 	mode->clock = clock;
 }
 
+static bool cea_db_is_hdmi_colorimetry_data_block(const u8 *db)
+{
+	if (cea_db_tag(db) != USE_EXTENDED_TAG)
+		return false;
+
+	if (db[1] != COLORIMETRY_DATA_BLOCK)
+		return false;
+
+	return true;
+}
+
+static void
+drm_parse_colorimetry_data_block(struct drm_connector *connector, const u8 *db)
+{
+	struct drm_hdmi_info *info = &connector->display_info.hdmi;
+	u16 len;
+
+	len = cea_db_payload_len_ext(db);
+	/* As per CEA 861-G spec */
+	info->colorimetry = ((db[3] & (0x1 << 7)) << 1) | db[2];
+}
+
 static bool cea_db_is_hdmi_hdr_metadata_block(const u8 *db)
 {
 	if (cea_db_tag(db) != USE_EXTENDED_TAG)
@@ -4498,6 +4521,8 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 			drm_parse_vcdb(connector, db);
 		if (cea_db_is_hdmi_hdr_metadata_block(db))
 			drm_parse_hdr_metadata_block(connector, db);
+		if (cea_db_is_hdmi_colorimetry_data_block(db))
+			drm_parse_colorimetry_data_block(connector, db);
 	}
 }
 
include/drm/drm_connector.h +3 -0
index 29388bd..94f926e 100644
@@ -206,6 +206,9 @@ struct drm_hdmi_info {
 
 	/** @y420_dc_modes: bitmap of deep color support index */
 	u8 y420_dc_modes;
+
+	/* @colorimetry: bitmap of supported colorimetry modes */
+	u16 colorimetry;
 };
 
 /**
Signature · 1 line
1.9.1

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

#8 lore raw

Re: [v6 03/13] drm: Parse Colorimetry data block from EDID

Quoted 19 lines

-----Original Message-----
From: Brian Starkey [mailto:[email protected]]
Sent: Thursday, March 21, 2019 4:47 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Lankhorst, Maarten <[email protected]>; Syrjala, Ville <[email protected]>; Sharma, Shashank <[email protected]>; [email protected]; Liviu Dudau <[email protected]>; nd <[email protected]>
Subject: Re: [v6 03/13] drm: Parse Colorimetry data block from EDID

Hi Uma,

Quoted 3 lines · Uma Shankar

CEA 861.3 spec adds colorimetry data block for HDMI. Parsing the block to get the colorimetry data from panel.

Quoted 8 lines

While code which parses these parts (patches 2 and 3) out of EDID could be useful - it doesn't seem to actually be used anywhere in the kernel (sorry if I missed it), and I'm not sure it will/can be unless we expose more properties.

The discussion last time leant towards a more useful/generic userspace library for EDID parsing, so perhaps patches 2 and 3 should be dropped.

Did you have an intended use for them in the kernel?

The idea was to use them for any kernel defaults or some state and error checking, when we have more such types exposed. But yeah, may be till we have it I can drop it for now and re-introduced them later when needed.

Thanks & Regards,
Uma Shankar

Quoted 81 lines

Thanks,
-Brian

drivers/gpu/drm/drm_edid.c static int drm_cvt_modes(struct drm_connector

Quoted 22 lines

v2: Rebase

v3: No Change

v4: Addressed Shashank's review comments. Updated colorimetry field to 16 bit as DCI-P3 got added in CEA 861-G spec, as pointed out by Shashank.

v5: Fixed checkpatch warnings with --strict option.

---
 drivers/gpu/drm/drm_edid.c  | 25 +++++++++++++++++++++++++
include/drm/drm_connector.h |  3 +++
 2 files changed, 28 insertions(+)
drivers/gpu/drm/drm_edid.c +0 -0
index fd8a621a..676569b 100644
@@ -2840,6 +2840,7 @@ static int drm_cvt_modes(struct drm_connector

*connector,

Quoted 55 lines
drivers/gpu/drm/drm_edid.c +1 -0
 #define VIDEO_BLOCK     0x02
 #define VENDOR_BLOCK    0x03
 #define SPEAKER_BLOCK	0x04
+#define COLORIMETRY_DATA_BLOCK		0x5
 #define HDR_STATIC_METADATA_BLOCK	0x6
 #define USE_EXTENDED_TAG 0x07
 #define EXT_VIDEO_CAPABILITY_BLOCK 0x00 @@ -3829,6 +3830,28 @@ static

void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode)

drivers/gpu/drm/drm_edid.c +20 -0
 	mode->clock = clock;
 }
 
+static bool cea_db_is_hdmi_colorimetry_data_block(const u8 *db) {
+	if (cea_db_tag(db) != USE_EXTENDED_TAG)
+		return false;
+
+	if (db[1] != COLORIMETRY_DATA_BLOCK)
+		return false;
+
+	return true;
+}
+
+static void
+drm_parse_colorimetry_data_block(struct drm_connector *connector,
+const u8 *db) {
+	struct drm_hdmi_info *info = &connector->display_info.hdmi;
+	u16 len;
+
+	len = cea_db_payload_len_ext(db);
+	/* As per CEA 861-G spec */
+	info->colorimetry = ((db[3] & (0x1 << 7)) << 1) | db[2]; }
+
 static bool cea_db_is_hdmi_hdr_metadata_block(const u8 *db)  {
 	if (cea_db_tag(db) != USE_EXTENDED_TAG) @@ -4498,6 +4521,8 @@ static

void drm_parse_cea_ext(struct drm_connector *connector,

drivers/gpu/drm/drm_edid.c +2 -0
 			drm_parse_vcdb(connector, db);
 		if (cea_db_is_hdmi_hdr_metadata_block(db))
 			drm_parse_hdr_metadata_block(connector, db);
+		if (cea_db_is_hdmi_colorimetry_data_block(db))
+			drm_parse_colorimetry_data_block(connector, db);
 	}
 }
include/drm/drm_connector.h +3 -0
index 29388bd..94f926e 100644
@@ -206,6 +206,9 @@ struct drm_hdmi_info {
 
 	/** @y420_dc_modes: bitmap of deep color support index */
 	u8 y420_dc_modes;
+
+	/* @colorimetry: bitmap of supported colorimetry modes */
+	u16 colorimetry;
 };
 
Quoted 4 lines
Quoted 4 lines
include/drm/drm_connector.h +0 -1
 /**
--

1.9.1

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

#9 lore raw

PATCH v6 4/13 drm/i915: Attach HDR metadata property to connector

In reply to Uma Shankar

Attach HDR metadata property to connector object.

v2: Rebase

v3: Updated the property name as per updated name
while creating hdr metadata property

---
 drivers/gpu/drm/i915/intel_hdmi.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/intel_hdmi.c +2 -0
index 5ccb305..5f06237 100644
@@ -2719,6 +2719,8 @@ static void intel_hdmi_destroy(struct drm_connector *connector)
 
 	drm_connector_attach_content_type_property(connector);
 	connector->state->picture_aspect_ratio = HDMI_PICTURE_ASPECT_NONE;
+	drm_object_attach_property(&connector->base,
+				   connector->dev->mode_config.hdr_output_metadata_property, 0);
 
 	if (!HAS_GMCH(dev_priv))
 		drm_connector_attach_max_bpc_property(connector, 8, 12);
Signature · 6 lines
1.9.1

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

PATCH v6 5/13 drm: Implement HDR output metadata set and get property handling

In reply to Uma Shankar

This patch implements get() and set() functions for HDR output metadata property.The blob data is received from userspace and saved in connector state, the same is returned as blob in get property call to userspace.

v2: Rebase and added Ville's POC changes

v3: No Change

v4: Addressed Shashank's review comments

---
 drivers/gpu/drm/drm_atomic.c      |  2 ++
 drivers/gpu/drm/drm_atomic_uapi.c | 13 +++++++++++++
 2 files changed, 15 insertions(+)
drivers/gpu/drm/drm_atomic.c +2 -0
index 5eb4013..8b9c126 100644
@@ -881,6 +881,8 @@ static void drm_atomic_connector_print_state(struct drm_printer *p,
 
 	drm_printf(p, "connector[%u]: %s\n", connector->base.id, connector->name);
 	drm_printf(p, "\tcrtc=%s\n", state->crtc ? state->crtc->name : "(null)");
+	drm_printf(p, "\thdr_metadata_changed=%d\n",
+		   state->hdr_metadata_changed);
 
 	if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
 		if (state->writeback_job && state->writeback_job->fb)
drivers/gpu/drm/drm_atomic_uapi.c +13 -0
index 4eb81f1..18c8b81f 100644
@@ -686,6 +686,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
 {
 	struct drm_device *dev = connector->dev;
 	struct drm_mode_config *config = &dev->mode_config;
+	bool replaced = false;
+	int ret;
 
 	if (property == config->prop_crtc_id) {
 		struct drm_crtc *crtc = drm_crtc_find(dev, NULL, val);
@@ -734,6 +736,14 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
 		 */
 		if (state->link_status != DRM_LINK_STATUS_GOOD)
 			state->link_status = val;
+	} else if (property == config->hdr_output_metadata_property) {
+		ret = drm_atomic_replace_property_blob_from_id(dev,
+				&state->hdr_output_metadata_blob_ptr,
+				val,
+				-1, sizeof(struct hdr_static_metadata),
+				&replaced);
+		state->hdr_metadata_changed |= replaced;
+		return ret;
 	} else if (property == config->aspect_ratio_property) {
 		state->picture_aspect_ratio = val;
 	} else if (property == config->content_type_property) {
@@ -820,6 +830,9 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
 		*val = state->colorspace;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
+	} else if (property == config->hdr_output_metadata_property) {
+		*val = (state->hdr_output_metadata_blob_ptr) ?
+			state->hdr_output_metadata_blob_ptr->base.id : 0;
 	} else if (property == connector->content_protection_property) {
 		*val = state->content_protection;
 	} else if (property == config->writeback_fb_id_property) {
Signature · 6 lines
1.9.1

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

Re: [v6 05/13] drm: Implement HDR output metadata set and get property handling

Hi,

Quoted 5 lines · Uma Shankar

This patch implements get() and set() functions for HDR output metadata property.The blob data is received from userspace and saved in connector state, the same is returned as blob in get property call to userspace.

Quoted 7 lines

v2: Rebase and added Ville's POC changes

v3: No Change

v4: Addressed Shashank's review comments

This looks like a candidate to be squashed into patch 1.

Quoted 32 lines
---
 drivers/gpu/drm/drm_atomic.c      |  2 ++
 drivers/gpu/drm/drm_atomic_uapi.c | 13 +++++++++++++
 2 files changed, 15 insertions(+)
drivers/gpu/drm/drm_atomic.c +2 -0
index 5eb4013..8b9c126 100644
@@ -881,6 +881,8 @@ static void drm_atomic_connector_print_state(struct drm_printer *p,
 
 	drm_printf(p, "connector[%u]: %s\n", connector->base.id, connector->name);
 	drm_printf(p, "\tcrtc=%s\n", state->crtc ? state->crtc->name : "(null)");
+	drm_printf(p, "\thdr_metadata_changed=%d\n",
+		   state->hdr_metadata_changed);
 
 	if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
 		if (state->writeback_job && state->writeback_job->fb)
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
index 4eb81f1..18c8b81f 100644
@@ -686,6 +686,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
 {
 	struct drm_device *dev = connector->dev;
 	struct drm_mode_config *config = &dev->mode_config;
+	bool replaced = false;
+	int ret;
 
 	if (property == config->prop_crtc_id) {
 		struct drm_crtc *crtc = drm_crtc_find(dev, NULL, val);

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

Quoted 10 lines
drivers/gpu/drm/drm_atomic_uapi.c +7 -0
@@ -734,6 +736,14 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
 		 */
 		if (state->link_status != DRM_LINK_STATUS_GOOD)
 			state->link_status = val;
+	} else if (property == config->hdr_output_metadata_property) {
+		ret = drm_atomic_replace_property_blob_from_id(dev,
+				&state->hdr_output_metadata_blob_ptr,
+				val,
+				-1, sizeof(struct hdr_static_metadata),
+				&replaced);
+		state->hdr_metadata_changed |= replaced;

I've said the same about other flags: Do we really need them? It seems easy enough to just compare the blob pointers or their IDs

Thanks,
-Brian

Quoted 17 lines
drivers/gpu/drm/drm_atomic_uapi.c +4 -0
+		return ret;
 	} else if (property == config->aspect_ratio_property) {
 		state->picture_aspect_ratio = val;
 	} else if (property == config->content_type_property) {
@@ -820,6 +830,9 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
 		*val = state->colorspace;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
+	} else if (property == config->hdr_output_metadata_property) {
+		*val = (state->hdr_output_metadata_blob_ptr) ?
+			state->hdr_output_metadata_blob_ptr->base.id : 0;
 	} else if (property == connector->content_protection_property) {
 		*val = state->content_protection;
 	} else if (property == config->writeback_fb_id_property) {
Signature · 1 line
1.9.1

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

#12 lore raw

Re: [v6 05/13] drm: Implement HDR output metadata set and get property handling

Quoted 23 lines

-----Original Message-----
From: Brian Starkey [mailto:[email protected]]
Sent: Thursday, March 21, 2019 5:17 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Lankhorst, Maarten <[email protected]>; Syrjala, Ville <[email protected]>; Sharma, Shashank <[email protected]>; [email protected]; Liviu Dudau <[email protected]>; nd <[email protected]>
Subject: Re: [v6 05/13] drm: Implement HDR output metadata set and get property handling

Hi,

Quoted 7 lines · Uma Shankar

This patch implements get() and set() functions for HDR output metadata property.The blob data is received from userspace and saved in connector state, the same is returned as blob in get property call to userspace.

v2: Rebase and added Ville's POC changes

Quoted 7 lines
Quoted 5 lines

v3: No Change

v4: Addressed Shashank's review comments

This looks like a candidate to be squashed into patch 1.

Ok, will merged it with 1.

Quoted 37 lines
Quoted 27 lines
---
 drivers/gpu/drm/drm_atomic.c      |  2 ++
 drivers/gpu/drm/drm_atomic_uapi.c | 13 +++++++++++++
 2 files changed, 15 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic.c index 5eb4013..8b9c126 100644

drivers/gpu/drm/drm_atomic.c +2 -0
@@ -881,6 +881,8 @@ static void
 drm_atomic_connector_print_state(struct drm_printer *p,
 
 	drm_printf(p, "connector[%u]: %s\n", connector->base.id, connector-
 name);
 	drm_printf(p, "\tcrtc=%s\n", state->crtc ? state->crtc->name :
 "(null)");
+	drm_printf(p, "\thdr_metadata_changed=%d\n",
+		   state->hdr_metadata_changed);
drivers/gpu/drm/drm_atomic.c +0 -0
 	if (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)
 		if (state->writeback_job && state->writeback_job->fb) diff --git

a/drivers/gpu/drm/drm_atomic_uapi.c
b/drivers/gpu/drm/drm_atomic_uapi.c
index 4eb81f1..18c8b81f 100644

drivers/gpu/drm/drm_atomic_uapi.c static int

Quoted 9 lines
drivers/gpu/drm/drm_atomic_uapi.c +3 -0
@@ -686,6 +686,8 @@ static int
 drm_atomic_connector_set_property(struct drm_connector *connector,  {
 	struct drm_device *dev = connector->dev;
 	struct drm_mode_config *config = &dev->mode_config;
+	bool replaced = false;
+	int ret;
 
 	if (property == config->prop_crtc_id) {
 		struct drm_crtc *crtc = drm_crtc_find(dev, NULL, val); @@ -734,6
+736,14 @@ static int drm_atomic_connector_set_property(struct drm_connector

*connector,

Quoted 13 lines

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

Quoted 10 lines
drivers/gpu/drm/drm_atomic_uapi.c +7 -0
 		 */
 		if (state->link_status != DRM_LINK_STATUS_GOOD)
 			state->link_status = val;
+	} else if (property == config->hdr_output_metadata_property) {
+		ret = drm_atomic_replace_property_blob_from_id(dev,
+				&state->hdr_output_metadata_blob_ptr,
+				val,
+				-1, sizeof(struct hdr_static_metadata),
+				&replaced);
+		state->hdr_metadata_changed |= replaced;

I've said the same about other flags: Do we really need them? It seems easy enough to just compare the blob pointers or their IDs

This was just an extension of how gamma luts are used. It's just to have this check here and later use it where ever needed, since we may require it at multiple places for certain checks.

Regards,
Uma Shankar

Quoted 10 lines

Thanks,
-Brian

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

Quoted 5 lines
drivers/gpu/drm/drm_atomic_uapi.c +2 -0
+		return ret;
 	} else if (property == config->aspect_ratio_property) {
 		state->picture_aspect_ratio = val;
 	} else if (property == config->content_type_property) { @@ -820,6
+830,9 @@ static int drm_atomic_connector_set_property(struct drm_connector

*connector,

Quoted 12 lines
Quoted 10 lines
drivers/gpu/drm/drm_atomic_uapi.c +3 -1
 		*val = state->colorspace;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
+	} else if (property == config->hdr_output_metadata_property) {
+		*val = (state->hdr_output_metadata_blob_ptr) ?
+			state->hdr_output_metadata_blob_ptr->base.id : 0;
 	} else if (property == connector->content_protection_property) {
 		*val = state->content_protection;
 	} else if (property == config->writeback_fb_id_property) {
--
Quoted 2 lines

1.9.1

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

#13 lore raw

PATCH v6 6/13 drm: Enable HDR infoframe support

In reply to Uma Shankar

Enable Dynamic Range and Mastering Infoframe for HDR content, which is defined in CEA 861.3 spec.

The metadata will be computed based on blending policy in userspace compositors and passed as a connector property blob to driver. The same will be sent as infoframe to panel which support HDR.

v2: Rebase and added Ville's POC changes.

v3: No Change

v4: Addressed Shashank's review comments and merged the patch making drm infoframe function arguments as constant.

v5: Rebase

v6: Fixed checkpatch warnings with --strict option. Addressed Shashank's review comments and added his RB.

---
 drivers/gpu/drm/drm_edid.c |  56 ++++++++++++++++++++
 drivers/video/hdmi.c       | 129 +++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h     |   4 ++
 include/linux/hdmi.h       |  22 ++++++++
 4 files changed, 211 insertions(+)
drivers/gpu/drm/drm_edid.c +56 -0
index 676569b..78c0b97 100644
@@ -4916,6 +4916,62 @@ static bool is_hdmi2_sink(struct drm_connector *connector)
 }
 
 /**
+ * drm_hdmi_infoframe_set_hdr_metadata() - fill an HDMI AVI infoframe with
+ *                                         HDR metadata from userspace
+ * @frame: HDMI AVI infoframe
+ * @hdr_source_metadata: hdr_source_metadata info from userspace
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int
+drm_hdmi_infoframe_set_hdr_metadata(struct hdmi_drm_infoframe *frame,
+				    void *hdr_metadata)
+{
+	struct hdr_static_metadata *hdr_source_metadata;
+	int err, i;
+
+	if (!frame || !hdr_metadata)
+		return true;
+
+	err = hdmi_drm_infoframe_init(frame);
+	if (err < 0)
+		return err;
+
+	DRM_DEBUG_KMS("type = %x\n", frame->type);
+
+	hdr_source_metadata = (struct hdr_static_metadata *)hdr_metadata;
+
+	frame->length = sizeof(struct hdr_static_metadata);
+
+	frame->eotf = hdr_source_metadata->eotf;
+	frame->metadata_type = hdr_source_metadata->metadata_type;
+
+	for (i = 0; i < 3; i++) {
+		frame->display_primaries[i].x =
+			hdr_source_metadata->display_primaries[i].x;
+		frame->display_primaries[i].y =
+			hdr_source_metadata->display_primaries[i].y;
+	}
+
+	frame->white_point.x = hdr_source_metadata->white_point.x;
+	frame->white_point.y = hdr_source_metadata->white_point.y;
+
+	frame->max_mastering_display_luminance =
+		hdr_source_metadata->max_mastering_display_luminance;
+	frame->min_mastering_display_luminance =
+		hdr_source_metadata->min_mastering_display_luminance;
+
+	frame->max_cll = hdr_source_metadata->max_cll;
+	frame->max_fall = hdr_source_metadata->max_fall;
+
+	hdmi_infoframe_log(KERN_CRIT, NULL,
+			   (union hdmi_infoframe *)frame);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_hdmi_infoframe_set_hdr_metadata);
+
+/**
  * drm_hdmi_avi_infoframe_from_display_mode() - fill an HDMI AVI infoframe with
  *                                              data from a DRM display mode
  * @frame: HDMI AVI infoframe
drivers/video/hdmi.c +129 -0

159 lines not on this page · raw message

include/drm/drm_edid.h +4 -0
index 9d3b5b9..973e43e 100644
@@ -370,6 +370,10 @@ int drm_av_sync_delay(struct drm_connector *connector,
 				   const struct drm_display_mode *mode,
 				   enum hdmi_quantization_range rgb_quant_range);
 
+int
+drm_hdmi_infoframe_set_hdr_metadata(struct hdmi_drm_infoframe *frame,
+				    void *hdr_source_metadata);
+
 /**
  * drm_eld_mnl - Get ELD monitor name length in bytes.
  * @eld: pointer to an eld memory structure with mnl set
include/linux/hdmi.h +22 -0
index a065194..b925b24 100644
@@ -47,6 +47,7 @@ enum hdmi_infoframe_type {
 	HDMI_INFOFRAME_TYPE_AVI = 0x82,
 	HDMI_INFOFRAME_TYPE_SPD = 0x83,
 	HDMI_INFOFRAME_TYPE_AUDIO = 0x84,
+	HDMI_INFOFRAME_TYPE_DRM = 0x87,
 };
 
 #define HDMI_IEEE_OUI 0x000c03
@@ -185,12 +186,32 @@ struct hdmi_avi_infoframe {
 	unsigned short right_bar;
 };
 
+struct hdmi_drm_infoframe {
+	enum hdmi_infoframe_type type;
+	unsigned char version;
+	unsigned char length;
+	enum hdmi_eotf eotf;
+	enum hdmi_metadata_type metadata_type;
+	struct {
+		u16 x, y;
+	} display_primaries[3];
+	struct {
+		u16 x, y;
+	} white_point;
+	u16 max_mastering_display_luminance;
+	u16 min_mastering_display_luminance;
+	u16 max_fall;
+	u16 max_cll;
+	u16 min_cll;
+};
+
 int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame);
 ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer,
 				size_t size);
 ssize_t hdmi_avi_infoframe_pack_only(const struct hdmi_avi_infoframe *frame,
 				     void *buffer, size_t size);
 int hdmi_avi_infoframe_check(struct hdmi_avi_infoframe *frame);
+int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame);
 
 enum hdmi_spd_sdi {
 	HDMI_SPD_SDI_UNKNOWN,
@@ -365,6 +386,7 @@ ssize_t hdmi_vendor_infoframe_pack_only(const struct hdmi_vendor_infoframe *fram
 	struct hdmi_spd_infoframe spd;
 	union hdmi_vendor_any_infoframe vendor;
 	struct hdmi_audio_infoframe audio;
+	struct hdmi_drm_infoframe drm;
 };
 
 ssize_t hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer,
Signature · 6 lines
1.9.1

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

Re: [v6 06/13] drm: Enable HDR infoframe support

Quoted 38 lines · Uma Shankar

Enable Dynamic Range and Mastering Infoframe for HDR content, which is defined in CEA 861.3 spec.

The metadata will be computed based on blending policy in userspace compositors and passed as a connector property blob to driver. The same will be sent as infoframe to panel which support HDR.

v2: Rebase and added Ville's POC changes.

v3: No Change

v4: Addressed Shashank's review comments and merged the patch making drm infoframe function arguments as constant.

v5: Rebase

v6: Fixed checkpatch warnings with --strict option. Addressed Shashank's review comments and added his RB.

---
 drivers/gpu/drm/drm_edid.c |  56 ++++++++++++++++++++
 drivers/video/hdmi.c       | 129 +++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h     |   4 ++
 include/linux/hdmi.h       |  22 ++++++++
 4 files changed, 211 insertions(+)
drivers/gpu/drm/drm_edid.c +0 -0
index 676569b..78c0b97 100644
@@ -4916,6 +4916,62 @@ static bool is_hdmi2_sink(struct drm_connector *connector)
 }
 
 /**

drivers/gpu/drm/drm_edid.c static bool is_hdmi2_sink(struct drm_connector *connector) · line 4928

Quoted 10 lines
drivers/gpu/drm/drm_edid.c +10 -0
+ * drm_hdmi_infoframe_set_hdr_metadata() - fill an HDMI AVI infoframe with
+ *                                         HDR metadata from userspace
+ * @frame: HDMI AVI infoframe
+ * @hdr_source_metadata: hdr_source_metadata info from userspace
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int
+drm_hdmi_infoframe_set_hdr_metadata(struct hdmi_drm_infoframe *frame,
+				    void *hdr_metadata)

I don't think this needs to be/should be a void *, you might as well us (struct hdr_static_metadata *). Looks like you do the cast in i915 before calling this function anyway.

Quoted 27 lines
drivers/gpu/drm/drm_edid.c +27 -0
+{
+	struct hdr_static_metadata *hdr_source_metadata;
+	int err, i;
+
+	if (!frame || !hdr_metadata)
+		return true;
+
+	err = hdmi_drm_infoframe_init(frame);
+	if (err < 0)
+		return err;
+
+	DRM_DEBUG_KMS("type = %x\n", frame->type);
+
+	hdr_source_metadata = (struct hdr_static_metadata *)hdr_metadata;
+
+	frame->length = sizeof(struct hdr_static_metadata);
+
+	frame->eotf = hdr_source_metadata->eotf;
+	frame->metadata_type = hdr_source_metadata->metadata_type;
+
+	for (i = 0; i < 3; i++) {
+		frame->display_primaries[i].x =
+			hdr_source_metadata->display_primaries[i].x;
+		frame->display_primaries[i].y =
+			hdr_source_metadata->display_primaries[i].y;
+	}
+

drivers/gpu/drm/drm_edid.c static bool is_hdmi2_sink(struct drm_connector *connector) · line 4965

Quoted 10 lines
drivers/gpu/drm/drm_edid.c +10 -0
+	frame->white_point.x = hdr_source_metadata->white_point.x;
+	frame->white_point.y = hdr_source_metadata->white_point.y;
+
+	frame->max_mastering_display_luminance =
+		hdr_source_metadata->max_mastering_display_luminance;
+	frame->min_mastering_display_luminance =
+		hdr_source_metadata->min_mastering_display_luminance;
+
+	frame->max_cll = hdr_source_metadata->max_cll;
+	frame->max_fall = hdr_source_metadata->max_fall;

Couldn't the infoframe definition embed the UAPI structure, making this a straight memcpy() ?

Quoted 217 lines
drivers/gpu/drm/drm_edid.c +9 -0
+
+	hdmi_infoframe_log(KERN_CRIT, NULL,
+			   (union hdmi_infoframe *)frame);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_hdmi_infoframe_set_hdr_metadata);
+
+/**
  * drm_hdmi_avi_infoframe_from_display_mode() - fill an HDMI AVI infoframe with
  *                                              data from a DRM display mode
  * @frame: HDMI AVI infoframe
drivers/video/hdmi.c +129 -0
index 799ae49..80bb0ee 100644
@@ -650,6 +650,93 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
 	return 0;
 }
 
+/**
+ * hdmi_drm_infoframe_init() - initialize an HDMI Dynaminc Range and
+ * mastering infoframe
+ * @frame: HDMI DRM infoframe
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame)
+{
+	memset(frame, 0, sizeof(*frame));
+
+	frame->type = HDMI_INFOFRAME_TYPE_DRM;
+	frame->version = 1;
+
+	return 0;
+}
+EXPORT_SYMBOL(hdmi_drm_infoframe_init);
+
+/**
+ * hdmi_drm_infoframe_pack() - write HDMI DRM infoframe to binary buffer
+ * @frame: HDMI DRM infoframe
+ * @buffer: destination buffer
+ * @size: size of buffer
+ *
+ * Packs the information contained in the @frame structure into a binary
+ * representation that can be written into the corresponding controller
+ * registers. Also computes the checksum as required by section 5.3.5 of
+ * the HDMI 1.4 specification.
+ *
+ * Returns the number of bytes packed into the binary buffer or a negative
+ * error code on failure.
+ */
+ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
+				size_t size)
+{
+	u8 *ptr = buffer;
+	size_t length;
+	int i;
+
+	length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
+
+	if (size < length)
+		return -ENOSPC;
+
+	memset(buffer, 0, size);
+
+	ptr[0] = frame->type;
+	ptr[1] = frame->version;
+	ptr[2] = frame->length;
+	ptr[3] = 0; /* checksum */
+
+	/* start infoframe payload */
+	ptr += HDMI_INFOFRAME_HEADER_SIZE;
+
+	*ptr++ = frame->eotf;
+	*ptr++ = frame->metadata_type;
+
+	for (i = 0; i < 3; i++) {
+		*ptr++ = frame->display_primaries[i].x;
+		*ptr++ = frame->display_primaries[i].x >> 8;
+		*ptr++ = frame->display_primaries[i].y;
+		*ptr++ = frame->display_primaries[i].y >> 8;
+	}
+
+	*ptr++ = frame->white_point.x;
+	*ptr++ = frame->white_point.x >> 8;
+
+	*ptr++ = frame->white_point.y;
+	*ptr++ = frame->white_point.y >> 8;
+
+	*ptr++ = frame->max_mastering_display_luminance;
+	*ptr++ = frame->max_mastering_display_luminance >> 8;
+
+	*ptr++ = frame->min_mastering_display_luminance;
+	*ptr++ = frame->min_mastering_display_luminance >> 8;
+
+	*ptr++ = frame->max_cll;
+	*ptr++ = frame->max_cll >> 8;
+
+	*ptr++ = frame->max_fall;
+	*ptr++ = frame->max_fall >> 8;
+
+	hdmi_infoframe_set_checksum(buffer, length);
+
+	return length;
+}
+
 /*
  * hdmi_vendor_any_infoframe_check() - check a vendor infoframe
  */
@@ -806,6 +893,9 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
 	case HDMI_INFOFRAME_TYPE_AVI:
 		length = hdmi_avi_infoframe_pack(&frame->avi, buffer, size);
 		break;
+	case HDMI_INFOFRAME_TYPE_DRM:
+		length = hdmi_drm_infoframe_pack(&frame->drm, buffer, size);
+		break;
 	case HDMI_INFOFRAME_TYPE_SPD:
 		length = hdmi_spd_infoframe_pack(&frame->spd, buffer, size);
 		break;
@@ -838,6 +928,8 @@ static const char *hdmi_infoframe_type_get_name(enum hdmi_infoframe_type type)
 		return "Source Product Description (SPD)";
 	case HDMI_INFOFRAME_TYPE_AUDIO:
 		return "Audio";
+	case HDMI_INFOFRAME_TYPE_DRM:
+		return "Dynamic Range and Mastering";
 	}
 	return "Reserved";
 }
@@ -1284,6 +1376,40 @@ static void hdmi_audio_infoframe_log(const char *level,
 			frame->downmix_inhibit ? "Yes" : "No");
 }
 
+/**
+ * hdmi_drm_infoframe_log() - log info of HDMI DRM infoframe
+ * @level: logging level
+ * @dev: device
+ * @frame: HDMI DRM infoframe
+ */
+static void hdmi_drm_infoframe_log(const char *level,
+				   struct device *dev,
+				   const struct hdmi_drm_infoframe *frame)
+{
+	int i;
+
+	hdmi_infoframe_log_header(level, dev,
+				  (struct hdmi_any_infoframe *)frame);
+	hdmi_log("length: %d\n", frame->length);
+	hdmi_log("metadata type: %d\n", frame->metadata_type);
+	hdmi_log("eotf: %d\n", frame->eotf);
+	for (i = 0; i < 3; i++) {
+		hdmi_log("x[%d]: %d\n", i, frame->display_primaries[i].x);
+		hdmi_log("y[%d]: %d\n", i, frame->display_primaries[i].y);
+	}
+
+	hdmi_log("white point x: %d\n", frame->white_point.x);
+	hdmi_log("white point y: %d\n", frame->white_point.y);
+
+	hdmi_log("max_mastering_display_luminance: %d\n",
+		 frame->max_mastering_display_luminance);
+	hdmi_log("min_mastering_display_luminance: %d\n",
+		 frame->min_mastering_display_luminance);
+
+	hdmi_log("max_cll: %d\n", frame->max_cll);
+	hdmi_log("max_fall: %d\n", frame->max_fall);
+}
+
 static const char *
 hdmi_3d_structure_get_name(enum hdmi_3d_structure s3d_struct)
 {
@@ -1372,6 +1498,9 @@ void hdmi_infoframe_log(const char *level,
 	case HDMI_INFOFRAME_TYPE_VENDOR:
 		hdmi_vendor_any_infoframe_log(level, dev, &frame->vendor);
 		break;
+	case HDMI_INFOFRAME_TYPE_DRM:
+		hdmi_drm_infoframe_log(level, dev, &frame->drm);
+		break;
 	}
 }
 EXPORT_SYMBOL(hdmi_infoframe_log);
include/drm/drm_edid.h +4 -0
index 9d3b5b9..973e43e 100644
@@ -370,6 +370,10 @@ int drm_av_sync_delay(struct drm_connector *connector,
 				   const struct drm_display_mode *mode,
 				   enum hdmi_quantization_range rgb_quant_range);
 
+int
+drm_hdmi_infoframe_set_hdr_metadata(struct hdmi_drm_infoframe *frame,
+				    void *hdr_source_metadata);
+
 /**
  * drm_eld_mnl - Get ELD monitor name length in bytes.
  * @eld: pointer to an eld memory structure with mnl set
include/linux/hdmi.h +7 -0
index a065194..b925b24 100644
@@ -47,6 +47,7 @@ enum hdmi_infoframe_type {
 	HDMI_INFOFRAME_TYPE_AVI = 0x82,
 	HDMI_INFOFRAME_TYPE_SPD = 0x83,
 	HDMI_INFOFRAME_TYPE_AUDIO = 0x84,
+	HDMI_INFOFRAME_TYPE_DRM = 0x87,
 };
 
 #define HDMI_IEEE_OUI 0x000c03
@@ -185,12 +186,32 @@ struct hdmi_avi_infoframe {
 	unsigned short right_bar;
 };
 
+struct hdmi_drm_infoframe {
+	enum hdmi_infoframe_type type;
+	unsigned char version;
+	unsigned char length;
+	enum hdmi_eotf eotf;
+	enum hdmi_metadata_type metadata_type;

include/linux/hdmi.h struct hdmi_avi_infoframe { · line 204

Quoted 10 lines
include/linux/hdmi.h +10 -0
+	struct {
+		u16 x, y;
+	} display_primaries[3];
+	struct {
+		u16 x, y;
+	} white_point;
+	u16 max_mastering_display_luminance;
+	u16 min_mastering_display_luminance;
+	u16 max_fall;
+	u16 max_cll;

Less confusing IMO if these are the same way around as in the spec. max_cll first, then max_fall.

include/linux/hdmi.h struct hdmi_avi_infoframe { · line 205

Quoted 1 line
include/linux/hdmi.h +1 -0
+	u16 min_cll;

This guy isn't in the copy of I have (CTA-861-G). I'm probably out of date, but you also don't print or encode this value, so should it be dropped?

Cheers,
-Brian

Quoted 23 lines
include/linux/hdmi.h +4 -0
+};
+
 int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame);
 ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer,
 				size_t size);
 ssize_t hdmi_avi_infoframe_pack_only(const struct hdmi_avi_infoframe *frame,
 				     void *buffer, size_t size);
 int hdmi_avi_infoframe_check(struct hdmi_avi_infoframe *frame);
+int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame);
 
 enum hdmi_spd_sdi {
 	HDMI_SPD_SDI_UNKNOWN,
@@ -365,6 +386,7 @@ ssize_t hdmi_vendor_infoframe_pack_only(const struct hdmi_vendor_infoframe *fram
 	struct hdmi_spd_infoframe spd;
 	union hdmi_vendor_any_infoframe vendor;
 	struct hdmi_audio_infoframe audio;
+	struct hdmi_drm_infoframe drm;
 };
 
 ssize_t hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer,
Signature · 1 line
1.9.1

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

#15 lore raw

RE: [v6 06/13] drm: Enable HDR infoframe support

Quoted 51 lines

-----Original Message-----
From: Brian Starkey [mailto:[email protected]]
Sent: Thursday, March 21, 2019 5:12 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; Lankhorst, Maarten <[email protected]>; Syrjala, Ville <[email protected]>; Sharma, Shashank <[email protected]>; [email protected]; Liviu Dudau <[email protected]>; Ville Syrjälä <[email protected]>; nd <[email protected]>
Subject: Re: [v6 06/13] drm: Enable HDR infoframe support

Quoted 19 lines · Uma Shankar

Enable Dynamic Range and Mastering Infoframe for HDR content, which is defined in CEA 861.3 spec.

The metadata will be computed based on blending policy in userspace compositors and passed as a connector property blob to driver. The same will be sent as infoframe to panel which support HDR.

v2: Rebase and added Ville's POC changes.

v3: No Change

v4: Addressed Shashank's review comments and merged the patch making drm infoframe function arguments as constant.

v5: Rebase

v6: Fixed checkpatch warnings with --strict option. Addressed Shashank's review comments and added his RB.

Quoted 6 lines
---
 drivers/gpu/drm/drm_edid.c |  56 ++++++++++++++++++++
 drivers/video/hdmi.c       | 129

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

Quoted 11 lines
 include/drm/drm_edid.h     |   4 ++
 include/linux/hdmi.h       |  22 ++++++++
 4 files changed, 211 insertions(+)
drivers/gpu/drm/drm_edid.c +0 -0
index 676569b..78c0b97 100644
@@ -4916,6 +4916,62 @@ static bool is_hdmi2_sink(struct drm_connector
 *connector)  }
 
Quoted 15 lines

drivers/gpu/drm/drm_edid.c static bool is_hdmi2_sink(struct drm_connector *connector) · line 4928

Quoted 11 lines
drivers/gpu/drm/drm_edid.c +10 -0
 /**
+ * drm_hdmi_infoframe_set_hdr_metadata() - fill an HDMI AVI infoframe with
+ *                                         HDR metadata from userspace
+ * @frame: HDMI AVI infoframe
+ * @hdr_source_metadata: hdr_source_metadata info from userspace
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int
+drm_hdmi_infoframe_set_hdr_metadata(struct hdmi_drm_infoframe *frame,
+				    void *hdr_metadata)

I don't think this needs to be/should be a void *, you might as well us (struct hdr_static_metadata *). Looks like you do the cast in i915 before calling this function anyway.

Ok, will update this.

Quoted 32 lines
Quoted 32 lines
drivers/gpu/drm/drm_edid.c +32 -0
+{
+	struct hdr_static_metadata *hdr_source_metadata;
+	int err, i;
+
+	if (!frame || !hdr_metadata)
+		return true;
+
+	err = hdmi_drm_infoframe_init(frame);
+	if (err < 0)
+		return err;
+
+	DRM_DEBUG_KMS("type = %x\n", frame->type);
+
+	hdr_source_metadata = (struct hdr_static_metadata *)hdr_metadata;
+
+	frame->length = sizeof(struct hdr_static_metadata);
+
+	frame->eotf = hdr_source_metadata->eotf;
+	frame->metadata_type = hdr_source_metadata->metadata_type;
+
+	for (i = 0; i < 3; i++) {
+		frame->display_primaries[i].x =
+			hdr_source_metadata->display_primaries[i].x;
+		frame->display_primaries[i].y =
+			hdr_source_metadata->display_primaries[i].y;
+	}
+
+	frame->white_point.x = hdr_source_metadata->white_point.x;
+	frame->white_point.y = hdr_source_metadata->white_point.y;
+
+	frame->max_mastering_display_luminance =
+		hdr_source_metadata->max_mastering_display_luminance;
Quoted 8 lines

drivers/gpu/drm/drm_edid.c static bool is_hdmi2_sink(struct drm_connector *connector) · line 4965

Quoted 5 lines
drivers/gpu/drm/drm_edid.c +5 -0
+	frame->min_mastering_display_luminance =
+		hdr_source_metadata->min_mastering_display_luminance;
+
+	frame->max_cll = hdr_source_metadata->max_cll;
+	frame->max_fall = hdr_source_metadata->max_fall;

Couldn't the infoframe definition embed the UAPI structure, making this a straight memcpy() ?

Yeah it's doable, currently the structures were not exactly same. Will try to make them Identical and perform a memcpy as even suggested by Shashank.

Quoted 236 lines

drivers/video/hdmi.c ssize_t hdmi_vendor_infoframe_pack(struct

Quoted 17 lines
drivers/gpu/drm/drm_edid.c +9 -0
+
+	hdmi_infoframe_log(KERN_CRIT, NULL,
+			   (union hdmi_infoframe *)frame);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_hdmi_infoframe_set_hdr_metadata);
+
+/**
  * drm_hdmi_avi_infoframe_from_display_mode() - fill an HDMI AVI infoframe with
  *                                              data from a DRM display mode
  * @frame: HDMI AVI infoframe
drivers/video/hdmi.c index renamed from drivers/video/hdmi.c +0 -0

799ae49..80bb0ee 100644

drivers/video/hdmi.c +0 -0
@@ -650,6 +650,93 @@ ssize_t hdmi_vendor_infoframe_pack(struct

hdmi_vendor_infoframe *frame,

Quoted 30 lines
drivers/video/hdmi.c +27 -0
 	return 0;
 }
 
+/**
+ * hdmi_drm_infoframe_init() - initialize an HDMI Dynaminc Range and
+ * mastering infoframe
+ * @frame: HDMI DRM infoframe
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame) {
+	memset(frame, 0, sizeof(*frame));
+
+	frame->type = HDMI_INFOFRAME_TYPE_DRM;
+	frame->version = 1;
+
+	return 0;
+}
+EXPORT_SYMBOL(hdmi_drm_infoframe_init);
+
+/**
+ * hdmi_drm_infoframe_pack() - write HDMI DRM infoframe to binary
+buffer
+ * @frame: HDMI DRM infoframe
+ * @buffer: destination buffer
+ * @size: size of buffer
+ *
+ * Packs the information contained in the @frame structure into a
+binary
+ * representation that can be written into the corresponding

drivers/video/hdmi.c ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,

Quoted 10 lines
drivers/video/hdmi.c +10 -0
+controller
+ * registers. Also computes the checksum as required by section 5.3.5
+of
+ * the HDMI 1.4 specification.
+ *
+ * Returns the number of bytes packed into the binary buffer or a
+negative
+ * error code on failure.
+ */
+ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void

*buffer,

drivers/video/hdmi.c ssize_t hdmi_vendor_infoframe_pack(struct

Quoted 58 lines
drivers/video/hdmi.c +54 -0
+				size_t size)
+{
+	u8 *ptr = buffer;
+	size_t length;
+	int i;
+
+	length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
+
+	if (size < length)
+		return -ENOSPC;
+
+	memset(buffer, 0, size);
+
+	ptr[0] = frame->type;
+	ptr[1] = frame->version;
+	ptr[2] = frame->length;
+	ptr[3] = 0; /* checksum */
+
+	/* start infoframe payload */
+	ptr += HDMI_INFOFRAME_HEADER_SIZE;
+
+	*ptr++ = frame->eotf;
+	*ptr++ = frame->metadata_type;
+
+	for (i = 0; i < 3; i++) {
+		*ptr++ = frame->display_primaries[i].x;
+		*ptr++ = frame->display_primaries[i].x >> 8;
+		*ptr++ = frame->display_primaries[i].y;
+		*ptr++ = frame->display_primaries[i].y >> 8;
+	}
+
+	*ptr++ = frame->white_point.x;
+	*ptr++ = frame->white_point.x >> 8;
+
+	*ptr++ = frame->white_point.y;
+	*ptr++ = frame->white_point.y >> 8;
+
+	*ptr++ = frame->max_mastering_display_luminance;
+	*ptr++ = frame->max_mastering_display_luminance >> 8;
+
+	*ptr++ = frame->min_mastering_display_luminance;
+	*ptr++ = frame->min_mastering_display_luminance >> 8;
+
+	*ptr++ = frame->max_cll;
+	*ptr++ = frame->max_cll >> 8;
+
+	*ptr++ = frame->max_fall;
+	*ptr++ = frame->max_fall >> 8;
+
+	hdmi_infoframe_set_checksum(buffer, length);
+
+	return length;
+}
+
 /*
  * hdmi_vendor_any_infoframe_check() - check a vendor infoframe
  */
@@ -806,6 +893,9 @@ ssize_t hdmi_vendor_infoframe_pack(struct

hdmi_vendor_infoframe *frame,

drivers/video/hdmi.c static const char *hdmi_infoframe_type_get_name(enum

Quoted 10 lines
drivers/video/hdmi.c +3 -0
 	case HDMI_INFOFRAME_TYPE_AVI:
 		length = hdmi_avi_infoframe_pack(&frame->avi, buffer, size);
 		break;
+	case HDMI_INFOFRAME_TYPE_DRM:
+		length = hdmi_drm_infoframe_pack(&frame->drm, buffer, size);
+		break;
 	case HDMI_INFOFRAME_TYPE_SPD:
 		length = hdmi_spd_infoframe_pack(&frame->spd, buffer, size);
 		break;
@@ -838,6 +928,8 @@ static const char *hdmi_infoframe_type_get_name(enum

hdmi_infoframe_type type)

drivers/video/hdmi.c static void hdmi_audio_infoframe_log(const char

Quoted 9 lines
drivers/video/hdmi.c +2 -0
 		return "Source Product Description (SPD)";
 	case HDMI_INFOFRAME_TYPE_AUDIO:
 		return "Audio";
+	case HDMI_INFOFRAME_TYPE_DRM:
+		return "Dynamic Range and Mastering";
 	}
 	return "Reserved";
 }
@@ -1284,6 +1376,40 @@ static void hdmi_audio_infoframe_log(const char

*level,

Quoted 83 lines
drivers/video/hdmi.c +35 -1
 			frame->downmix_inhibit ? "Yes" : "No");  }
 
+/**
+ * hdmi_drm_infoframe_log() - log info of HDMI DRM infoframe
+ * @level: logging level
+ * @dev: device
+ * @frame: HDMI DRM infoframe
+ */
+static void hdmi_drm_infoframe_log(const char *level,
+				   struct device *dev,
+				   const struct hdmi_drm_infoframe *frame) {
+	int i;
+
+	hdmi_infoframe_log_header(level, dev,
+				  (struct hdmi_any_infoframe *)frame);
+	hdmi_log("length: %d\n", frame->length);
+	hdmi_log("metadata type: %d\n", frame->metadata_type);
+	hdmi_log("eotf: %d\n", frame->eotf);
+	for (i = 0; i < 3; i++) {
+		hdmi_log("x[%d]: %d\n", i, frame->display_primaries[i].x);
+		hdmi_log("y[%d]: %d\n", i, frame->display_primaries[i].y);
+	}
+
+	hdmi_log("white point x: %d\n", frame->white_point.x);
+	hdmi_log("white point y: %d\n", frame->white_point.y);
+
+	hdmi_log("max_mastering_display_luminance: %d\n",
+		 frame->max_mastering_display_luminance);
+	hdmi_log("min_mastering_display_luminance: %d\n",
+		 frame->min_mastering_display_luminance);
+
+	hdmi_log("max_cll: %d\n", frame->max_cll);
+	hdmi_log("max_fall: %d\n", frame->max_fall); }
+
 static const char *
 hdmi_3d_structure_get_name(enum hdmi_3d_structure s3d_struct)  { @@
-1372,6 +1498,9 @@ void hdmi_infoframe_log(const char *level,
 	case HDMI_INFOFRAME_TYPE_VENDOR:
 		hdmi_vendor_any_infoframe_log(level, dev, &frame->vendor);
 		break;
+	case HDMI_INFOFRAME_TYPE_DRM:
+		hdmi_drm_infoframe_log(level, dev, &frame->drm);
+		break;
 	}
 }
 EXPORT_SYMBOL(hdmi_infoframe_log);
include/drm/drm_edid.h index renamed from include/drm/drm_edid.h +0 -0

9d3b5b9..973e43e 100644

include/drm/drm_edid.h +4 -0
@@ -370,6 +370,10 @@ int drm_av_sync_delay(struct drm_connector *connector,
 				   const struct drm_display_mode *mode,
 				   enum hdmi_quantization_range rgb_quant_range);
 
+int
+drm_hdmi_infoframe_set_hdr_metadata(struct hdmi_drm_infoframe *frame,
+				    void *hdr_source_metadata);
+
 /**
  * drm_eld_mnl - Get ELD monitor name length in bytes.
  * @eld: pointer to an eld memory structure with mnl set diff --git

a/include/linux/hdmi.h b/include/linux/hdmi.h index a065194..b925b24 100644

include/linux/hdmi.h +7 -0
@@ -47,6 +47,7 @@ enum hdmi_infoframe_type {
 	HDMI_INFOFRAME_TYPE_AVI = 0x82,
 	HDMI_INFOFRAME_TYPE_SPD = 0x83,
 	HDMI_INFOFRAME_TYPE_AUDIO = 0x84,
+	HDMI_INFOFRAME_TYPE_DRM = 0x87,
 };
 
 #define HDMI_IEEE_OUI 0x000c03
@@ -185,12 +186,32 @@ struct hdmi_avi_infoframe {
 	unsigned short right_bar;
 };
 
+struct hdmi_drm_infoframe {
+	enum hdmi_infoframe_type type;
+	unsigned char version;
+	unsigned char length;
+	enum hdmi_eotf eotf;
+	enum hdmi_metadata_type metadata_type;

include/linux/hdmi.h struct hdmi_avi_infoframe { · line 204

Quoted 10 lines
include/linux/hdmi.h +10 -0
+	struct {
+		u16 x, y;
+	} display_primaries[3];
+	struct {
+		u16 x, y;
+	} white_point;
+	u16 max_mastering_display_luminance;
+	u16 min_mastering_display_luminance;
+	u16 max_fall;
+	u16 max_cll;

Less confusing IMO if these are the same way around as in the spec. max_cll first, then max_fall.

Quoted 4 lines

include/linux/hdmi.h struct hdmi_avi_infoframe { · line 205

Quoted 1 line
include/linux/hdmi.h +1 -0
+	u16 min_cll;

This guy isn't in the copy of I have (CTA-861-G). I'm probably out of date, but you also don't print or encode this value, so should it be dropped?

Sure, will match exactly to 861.G. There were certain deltas here b/w 861.F and G. Will update this.

Thanks & Regards,
Uma Shankar

Quoted 23 lines

Cheers,
-Brian

include/linux/hdmi.h ssize_t hdmi_vendor_infoframe_pack_only(const struct

Quoted 13 lines
include/linux/hdmi.h +3 -0
+};
+
 int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame);
 ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer,
 				size_t size);
 ssize_t hdmi_avi_infoframe_pack_only(const struct hdmi_avi_infoframe *frame,
 				     void *buffer, size_t size);
 int hdmi_avi_infoframe_check(struct hdmi_avi_infoframe *frame);
+int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame);
 
 enum hdmi_spd_sdi {
 	HDMI_SPD_SDI_UNKNOWN,
@@ -365,6 +386,7 @@ ssize_t hdmi_vendor_infoframe_pack_only(const struct

hdmi_vendor_infoframe *fram

Quoted 6 lines
include/linux/hdmi.h +1 -0
 	struct hdmi_spd_infoframe spd;
 	union hdmi_vendor_any_infoframe vendor;
 	struct hdmi_audio_infoframe audio;
+	struct hdmi_drm_infoframe drm;
 };
 
Quoted 5 lines
Quoted 5 lines
include/linux/hdmi.h +0 -0
 ssize_t hdmi_infoframe_pack(union hdmi_infoframe *frame, void

*buffer,
--
1.9.1

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

#16 lore raw

PATCH v6 7/13 drm/i915: Write HDR infoframe and send to panel

In reply to Uma Shankar

Enable writing of HDR metadata infoframe to panel. The data will be provid by usersapace compositors, based on blending policies and passsed to driver through a blob property.

v2: Rebase

v3: Fixed a warning message

v4: Addressed Shashank's review comments

v5: Rebase. Added infoframe calculation in compute config.

v6: Addressed Shashank's review comment. Added HDR metadata support from GEN10 onwards as per Shashank's recommendation.

---
 drivers/gpu/drm/i915/intel_drv.h  |  1 +
 drivers/gpu/drm/i915/intel_hdmi.c | 41 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)
drivers/gpu/drm/i915/intel_drv.h +1 -0
index d9f188e..c6c3cc7 100644
@@ -1043,6 +1043,7 @@ struct intel_crtc_state {
 		union hdmi_infoframe avi;
 		union hdmi_infoframe spd;
 		union hdmi_infoframe hdmi;
+		union hdmi_infoframe drm;
 	} infoframes;
 
 	/* HDMI scrambling status */
drivers/gpu/drm/i915/intel_hdmi.c +41 -0

65 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
#17 lore raw

Re: [v6 07/13] drm/i915: Write HDR infoframe and send to panel

Quoted 78 lines · Uma Shankar

Enable writing of HDR metadata infoframe to panel. The data will be provid by usersapace compositors, based on blending policies and passsed to driver through a blob property.

v2: Rebase

v3: Fixed a warning message

v4: Addressed Shashank's review comments

v5: Rebase. Added infoframe calculation in compute config.

v6: Addressed Shashank's review comment. Added HDR metadata support from GEN10 onwards as per Shashank's recommendation.

---
  drivers/gpu/drm/i915/intel_drv.h  |  1 +
  drivers/gpu/drm/i915/intel_hdmi.c | 41 +++++++++++++++++++++++++++++++++++++++
  2 files changed, 42 insertions(+)
drivers/gpu/drm/i915/intel_drv.h +1 -0
index d9f188e..c6c3cc7 100644
@@ -1043,6 +1043,7 @@ struct intel_crtc_state {
  		union hdmi_infoframe avi;
  		union hdmi_infoframe spd;
  		union hdmi_infoframe hdmi;
+		union hdmi_infoframe drm;
  	} infoframes;
 
  	/* HDMI scrambling status */
drivers/gpu/drm/i915/intel_hdmi.c +25 -0
index 5f06237..e4bc7fc 100644
@@ -555,6 +555,7 @@ static u32 hsw_infoframes_enabled(struct intel_encoder *encoder,
  	HDMI_INFOFRAME_TYPE_AVI,
  	HDMI_INFOFRAME_TYPE_SPD,
  	HDMI_INFOFRAME_TYPE_VENDOR,
+	HDMI_INFOFRAME_TYPE_DRM,
  };
 
  u32 intel_hdmi_infoframe_enable(unsigned int type)
@@ -777,6 +778,30 @@ void intel_read_infoframe(struct intel_encoder *encoder,
  	return true;
  }
 
+static bool
+intel_hdmi_compute_drm_infoframe(struct intel_encoder *encoder,
+				 struct intel_crtc_state *crtc_state,
+				 struct drm_connector_state *conn_state)
+{
+	struct hdmi_drm_infoframe *frame = &crtc_state->infoframes.drm.drm;
+	struct hdr_static_metadata *hdr_metadata;
+	int ret;
+
+	hdr_metadata = (struct hdr_static_metadata *)
+			conn_state->hdr_output_metadata_blob_ptr->data;
+
+	ret = drm_hdmi_infoframe_set_hdr_metadata(frame, hdr_metadata);
+	if (ret < 0) {
+		DRM_ERROR("couldn't set HDR metadata in infoframe\n");
+		return false;
+	}
+
+	crtc_state->infoframes.enable |=
+		intel_hdmi_infoframe_enable(HDMI_INFOFRAME_TYPE_DRM);
+
+	return true;
+}
+
  static void g4x_set_infoframes(struct intel_encoder *encoder,
  			       bool enable,
  			       const struct intel_crtc_state *crtc_state,

drivers/gpu/drm/i915/intel_hdmi.c static void hsw_set_infoframes(struct intel_encoder *encoder, · line 1203

Quoted 4 lines
drivers/gpu/drm/i915/intel_hdmi.c +1 -0
@@ -1175,6 +1200,9 @@ static void hsw_set_infoframes(struct intel_encoder *encoder,
  	intel_write_infoframe(encoder, crtc_state,
  			      HDMI_INFOFRAME_TYPE_VENDOR,
  			      &crtc_state->infoframes.hdmi);
+	intel_write_infoframe(encoder, crtc_state,

We should have a GEN check here also, else, there could be case where we dint compute infoframes <=10 but wrote it, which will write garbage.

- Shashank

Quoted 15 lines
drivers/gpu/drm/i915/intel_hdmi.c +8 -0
+			      HDMI_INFOFRAME_TYPE_DRM,
+			      &crtc_state->infoframes.drm);
  }
 
  void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable)
@@ -2381,6 +2409,19 @@ int intel_hdmi_compute_config(struct intel_encoder *encoder,
  		return -EINVAL;
  	}
 
+	/*
+	 * Support HDR Metadata from Gen10 onwards
+	 * ToDo: Gen9 also can support HDR with LSPCON.
+	 * Support for the same to be enabled later.
+	 */
+	if (INTEL_GEN(dev_priv) >= 10) {

drivers/gpu/drm/i915/intel_hdmi.c int intel_hdmi_compute_config(struct intel_encoder *encoder, · line 2427

Quoted 10 lines
drivers/gpu/drm/i915/intel_hdmi.c +7 -0
+		if (!intel_hdmi_compute_drm_infoframe(encoder, pipe_config,
+						      conn_state)) {
+			DRM_DEBUG_KMS("bad DRM infoframe\n");
+			return -EINVAL;
+		}
+	}
+
  	return 0;
  }
 

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

#18 lore raw

PATCH v6 8/13 drm/i915: [DO NOT MERGE] hack for glk board outputs

In reply to Uma Shankar

From: Ville Syrjälä <[email protected]>

This is to limit PORT C on GLK to drive only
HDMI. Not sure if this is mandatory, this is just to test HDR on GLK HDMI.

---
 drivers/gpu/drm/i915/intel_bios.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/i915/intel_bios.c +7 -0
index 64f2017..4934b5f 100644
@@ -1405,6 +1405,13 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,
 		is_hdmi = false;
 	}
 
+	if (IS_GEMINILAKE(dev_priv) && port == PORT_C) {
+		is_hdmi = true;
+		is_dvi = true;
+		is_dp = false;
+		is_edp = false;
+	}
+
 	info->supports_dvi = is_dvi;
 	info->supports_hdmi = is_hdmi;
 	info->supports_dp = is_dp;
Signature · 6 lines
1.9.1

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

PATCH v6 9/13 drm/i915: Add HLG EOTF

In reply to Uma Shankar

From: Ville Syrjälä <[email protected]>

ADD HLG EOTF to the list of EOTF transfer functions supported. Hybrid Log-Gamma (HLG) is a high dynamic range (HDR) standard. HLG defines a nonlinear transfer function in which the lower half of the signal values use a gamma curve and the upper half of the signal values use a logarithmic curve.

v2: Rebase

v3: Fixed a warning message

v4: Addressed Shashank's review comments

---
 drivers/gpu/drm/drm_edid.c | 3 ++-
 include/linux/hdmi.h       | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_edid.c +2 -1
index 78c0b97..4784447 100644
@@ -3868,7 +3868,8 @@ static uint8_t eotf_supported(const u8 *edid_ext)
 	return edid_ext[2] &
 		(BIT(HDMI_EOTF_TRADITIONAL_GAMMA_SDR) |
 		 BIT(HDMI_EOTF_TRADITIONAL_GAMMA_HDR) |
-		 BIT(HDMI_EOTF_SMPTE_ST2084));
+		 BIT(HDMI_EOTF_SMPTE_ST2084) |
+		 BIT(HDMI_EOTF_BT_2100_HLG));
 }
 
 static uint8_t hdr_metadata_type(const u8 *edid_ext)
include/linux/hdmi.h +1 -0
index b925b24..202ed4a 100644
@@ -161,6 +161,7 @@ enum hdmi_eotf {
 	HDMI_EOTF_TRADITIONAL_GAMMA_SDR,
 	HDMI_EOTF_TRADITIONAL_GAMMA_HDR,
 	HDMI_EOTF_SMPTE_ST2084,
+	HDMI_EOTF_BT_2100_HLG,
 };
 
 struct hdmi_avi_infoframe {
Signature · 6 lines
1.9.1

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

PATCH v6 10/13 drm/i915: Enable infoframes on GLK+ for HDR

In reply to Uma Shankar

From: Ville Syrjälä <[email protected]>

This patch enables infoframes on GLK+ to be
used to send HDR metadata to HDMI sink.

v2: Addressed Shashank's review comment.

---
 drivers/gpu/drm/i915/i915_reg.h   |  4 ++++
 drivers/gpu/drm/i915/intel_hdmi.c | 18 +++++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +4 -0
index 31a3020..fe931e7 100644
@@ -4718,6 +4718,7 @@ enum {
 #define   VIDEO_DIP_FREQ_MASK		(3 << 16)
 /* HSW and later: */
 #define   DRM_DIP_ENABLE		(1 << 28)
+#define   VIDEO_DIP_ENABLE_DRM_GLK	(1 << 28)
 #define   PSR_VSC_BIT_7_SET		(1 << 27)
 #define   VSC_SELECT_MASK		(0x3 << 25)
 #define   VSC_SELECT_SHIFT		25
@@ -8156,6 +8157,7 @@ enum {
 #define _HSW_VIDEO_DIP_SPD_DATA_A	0x602A0
 #define _HSW_VIDEO_DIP_GMP_DATA_A	0x602E0
 #define _HSW_VIDEO_DIP_VSC_DATA_A	0x60320
+#define _GLK_VIDEO_DIP_DRM_DATA_A	0x60440
 #define _HSW_VIDEO_DIP_AVI_ECC_A	0x60240
 #define _HSW_VIDEO_DIP_VS_ECC_A		0x60280
 #define _HSW_VIDEO_DIP_SPD_ECC_A	0x602C0
@@ -8169,6 +8171,7 @@ enum {
 #define _HSW_VIDEO_DIP_SPD_DATA_B	0x612A0
 #define _HSW_VIDEO_DIP_GMP_DATA_B	0x612E0
 #define _HSW_VIDEO_DIP_VSC_DATA_B	0x61320
+#define _GLK_VIDEO_DIP_DRM_DATA_B	0x61440
 #define _HSW_VIDEO_DIP_BVI_ECC_B	0x61240
 #define _HSW_VIDEO_DIP_VS_ECC_B		0x61280
 #define _HSW_VIDEO_DIP_SPD_ECC_B	0x612C0
@@ -8194,6 +8197,7 @@ enum {
 #define HSW_TVIDEO_DIP_SPD_DATA(trans, i)	_MMIO_TRANS2(trans, _HSW_VIDEO_DIP_SPD_DATA_A + (i) * 4)
 #define HSW_TVIDEO_DIP_GMP_DATA(trans, i)	_MMIO_TRANS2(trans, _HSW_VIDEO_DIP_GMP_DATA_A + (i) * 4)
 #define HSW_TVIDEO_DIP_VSC_DATA(trans, i)	_MMIO_TRANS2(trans, _HSW_VIDEO_DIP_VSC_DATA_A + (i) * 4)
+#define GLK_TVIDEO_DIP_DRM_DATA(trans, i)	_MMIO_TRANS2(trans, _GLK_VIDEO_DIP_DRM_DATA_A + (i) * 4)
 #define ICL_VIDEO_DIP_PPS_DATA(trans, i)	_MMIO_TRANS2(trans, _ICL_VIDEO_DIP_PPS_DATA_A + (i) * 4)
 #define ICL_VIDEO_DIP_PPS_ECC(trans, i)		_MMIO_TRANS2(trans, _ICL_VIDEO_DIP_PPS_ECC_A + (i) * 4)
 
drivers/gpu/drm/i915/intel_hdmi.c +13 -5
index e4bc7fc..8decafd 100644
@@ -134,6 +134,8 @@ static u32 hsw_infoframe_enable(unsigned int type)
 		return VIDEO_DIP_ENABLE_SPD_HSW;
 	case HDMI_INFOFRAME_TYPE_VENDOR:
 		return VIDEO_DIP_ENABLE_VS_HSW;
+	case HDMI_INFOFRAME_TYPE_DRM:
+		return VIDEO_DIP_ENABLE_DRM_GLK;
 	default:
 		MISSING_CASE(type);
 		return 0;
@@ -159,6 +161,8 @@ static u32 hsw_infoframe_enable(unsigned int type)
 		return HSW_TVIDEO_DIP_SPD_DATA(cpu_transcoder, i);
 	case HDMI_INFOFRAME_TYPE_VENDOR:
 		return HSW_TVIDEO_DIP_VS_DATA(cpu_transcoder, i);
+	case HDMI_INFOFRAME_TYPE_DRM:
+		return GLK_TVIDEO_DIP_DRM_DATA(cpu_transcoder, i);
 	default:
 		MISSING_CASE(type);
 		return INVALID_MMIO_REG;
@@ -545,7 +549,8 @@ static u32 hsw_infoframes_enabled(struct intel_encoder *encoder,
 
 	return val & (VIDEO_DIP_ENABLE_VSC_HSW | VIDEO_DIP_ENABLE_AVI_HSW |
 		      VIDEO_DIP_ENABLE_GCP_HSW | VIDEO_DIP_ENABLE_VS_HSW |
-		      VIDEO_DIP_ENABLE_GMP_HSW | VIDEO_DIP_ENABLE_SPD_HSW);
+		      VIDEO_DIP_ENABLE_GMP_HSW | VIDEO_DIP_ENABLE_SPD_HSW |
+		      VIDEO_DIP_ENABLE_DRM_GLK);
 }
 
 static const u8 infoframe_type_to_idx[] = {
@@ -1177,7 +1182,8 @@ static void hsw_set_infoframes(struct intel_encoder *encoder,
 
 	val &= ~(VIDEO_DIP_ENABLE_VSC_HSW | VIDEO_DIP_ENABLE_AVI_HSW |
 		 VIDEO_DIP_ENABLE_GCP_HSW | VIDEO_DIP_ENABLE_VS_HSW |
-		 VIDEO_DIP_ENABLE_GMP_HSW | VIDEO_DIP_ENABLE_SPD_HSW);
+		 VIDEO_DIP_ENABLE_GMP_HSW | VIDEO_DIP_ENABLE_SPD_HSW |
+		 VIDEO_DIP_ENABLE_DRM_GLK);
 
 	if (!enable) {
 		I915_WRITE(reg, val);
@@ -1200,9 +1206,11 @@ static void hsw_set_infoframes(struct intel_encoder *encoder,
 	intel_write_infoframe(encoder, crtc_state,
 			      HDMI_INFOFRAME_TYPE_VENDOR,
 			      &crtc_state->infoframes.hdmi);
-	intel_write_infoframe(encoder, crtc_state,
-			      HDMI_INFOFRAME_TYPE_DRM,
-			      &crtc_state->infoframes.drm);
+	if ((INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv)) &&
+	    conn_state->hdr_metadata_changed)
+		intel_write_infoframe(encoder, crtc_state,
+				      HDMI_INFOFRAME_TYPE_DRM,
+				      &crtc_state->infoframes.drm);
 }
 
 void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable)
Signature · 6 lines
1.9.1

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

Re: [v6 10/13] drm/i915: Enable infoframes on GLK+ for HDR

Quoted 73 lines · Uma Shankar

From: Ville Syrjälä <[email protected]>

This patch enables infoframes on GLK+ to be
used to send HDR metadata to HDMI sink.

v2: Addressed Shashank's review comment.

---
  drivers/gpu/drm/i915/i915_reg.h   |  4 ++++
  drivers/gpu/drm/i915/intel_hdmi.c | 18 +++++++++++++-----
  2 files changed, 17 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +4 -0
index 31a3020..fe931e7 100644
@@ -4718,6 +4718,7 @@ enum {
  #define   VIDEO_DIP_FREQ_MASK		(3 << 16)
  /* HSW and later: */
  #define   DRM_DIP_ENABLE		(1 << 28)
+#define   VIDEO_DIP_ENABLE_DRM_GLK	(1 << 28)
  #define   PSR_VSC_BIT_7_SET		(1 << 27)
  #define   VSC_SELECT_MASK		(0x3 << 25)
  #define   VSC_SELECT_SHIFT		25
@@ -8156,6 +8157,7 @@ enum {
  #define _HSW_VIDEO_DIP_SPD_DATA_A	0x602A0
  #define _HSW_VIDEO_DIP_GMP_DATA_A	0x602E0
  #define _HSW_VIDEO_DIP_VSC_DATA_A	0x60320
+#define _GLK_VIDEO_DIP_DRM_DATA_A	0x60440
  #define _HSW_VIDEO_DIP_AVI_ECC_A	0x60240
  #define _HSW_VIDEO_DIP_VS_ECC_A		0x60280
  #define _HSW_VIDEO_DIP_SPD_ECC_A	0x602C0
@@ -8169,6 +8171,7 @@ enum {
  #define _HSW_VIDEO_DIP_SPD_DATA_B	0x612A0
  #define _HSW_VIDEO_DIP_GMP_DATA_B	0x612E0
  #define _HSW_VIDEO_DIP_VSC_DATA_B	0x61320
+#define _GLK_VIDEO_DIP_DRM_DATA_B	0x61440
  #define _HSW_VIDEO_DIP_BVI_ECC_B	0x61240
  #define _HSW_VIDEO_DIP_VS_ECC_B		0x61280
  #define _HSW_VIDEO_DIP_SPD_ECC_B	0x612C0
@@ -8194,6 +8197,7 @@ enum {
  #define HSW_TVIDEO_DIP_SPD_DATA(trans, i)	_MMIO_TRANS2(trans, _HSW_VIDEO_DIP_SPD_DATA_A + (i) * 4)
  #define HSW_TVIDEO_DIP_GMP_DATA(trans, i)	_MMIO_TRANS2(trans, _HSW_VIDEO_DIP_GMP_DATA_A + (i) * 4)
  #define HSW_TVIDEO_DIP_VSC_DATA(trans, i)	_MMIO_TRANS2(trans, _HSW_VIDEO_DIP_VSC_DATA_A + (i) * 4)
+#define GLK_TVIDEO_DIP_DRM_DATA(trans, i)	_MMIO_TRANS2(trans, _GLK_VIDEO_DIP_DRM_DATA_A + (i) * 4)
  #define ICL_VIDEO_DIP_PPS_DATA(trans, i)	_MMIO_TRANS2(trans, _ICL_VIDEO_DIP_PPS_DATA_A + (i) * 4)
  #define ICL_VIDEO_DIP_PPS_ECC(trans, i)		_MMIO_TRANS2(trans, _ICL_VIDEO_DIP_PPS_ECC_A + (i) * 4)
 
drivers/gpu/drm/i915/intel_hdmi.c +4 -0
index e4bc7fc..8decafd 100644
@@ -134,6 +134,8 @@ static u32 hsw_infoframe_enable(unsigned int type)
  		return VIDEO_DIP_ENABLE_SPD_HSW;
  	case HDMI_INFOFRAME_TYPE_VENDOR:
  		return VIDEO_DIP_ENABLE_VS_HSW;
+	case HDMI_INFOFRAME_TYPE_DRM:
+		return VIDEO_DIP_ENABLE_DRM_GLK;
  	default:
  		MISSING_CASE(type);
  		return 0;
@@ -159,6 +161,8 @@ static u32 hsw_infoframe_enable(unsigned int type)
  		return HSW_TVIDEO_DIP_SPD_DATA(cpu_transcoder, i);
  	case HDMI_INFOFRAME_TYPE_VENDOR:
  		return HSW_TVIDEO_DIP_VS_DATA(cpu_transcoder, i);
+	case HDMI_INFOFRAME_TYPE_DRM:
+		return GLK_TVIDEO_DIP_DRM_DATA(cpu_transcoder, i);
  	default:
  		MISSING_CASE(type);
  		return INVALID_MMIO_REG;

drivers/gpu/drm/i915/intel_hdmi.c static u32 hsw_infoframes_enabled(struct intel_encoder *encoder, · line 553

Quoted 6 lines
drivers/gpu/drm/i915/intel_hdmi.c +2 -1
@@ -545,7 +549,8 @@ static u32 hsw_infoframes_enabled(struct intel_encoder *encoder,
 
  	return val & (VIDEO_DIP_ENABLE_VSC_HSW | VIDEO_DIP_ENABLE_AVI_HSW |
  		      VIDEO_DIP_ENABLE_GCP_HSW | VIDEO_DIP_ENABLE_VS_HSW |
-		      VIDEO_DIP_ENABLE_GMP_HSW | VIDEO_DIP_ENABLE_SPD_HSW);
+		      VIDEO_DIP_ENABLE_GMP_HSW | VIDEO_DIP_ENABLE_SPD_HSW |
+		      VIDEO_DIP_ENABLE_DRM_GLK);

I think this should also be GEN check protected, as hsw_infoframes_enabled will be called by many platforms, and before GLK they cant support DRM_IF.

drivers/gpu/drm/i915/intel_hdmi.c static void hsw_set_infoframes(struct intel_encoder *encoder, · line 1186

Quoted 10 lines
drivers/gpu/drm/i915/intel_hdmi.c +2 -1
  }
 
  static const u8 infoframe_type_to_idx[] = {
@@ -1177,7 +1182,8 @@ static void hsw_set_infoframes(struct intel_encoder *encoder,
 
  	val &= ~(VIDEO_DIP_ENABLE_VSC_HSW | VIDEO_DIP_ENABLE_AVI_HSW |
  		 VIDEO_DIP_ENABLE_GCP_HSW | VIDEO_DIP_ENABLE_VS_HSW |
-		 VIDEO_DIP_ENABLE_GMP_HSW | VIDEO_DIP_ENABLE_SPD_HSW);
+		 VIDEO_DIP_ENABLE_GMP_HSW | VIDEO_DIP_ENABLE_SPD_HSW |
+		 VIDEO_DIP_ENABLE_DRM_GLK);

Same here.

- Shashank

Quoted 8 lines
drivers/gpu/drm/i915/intel_hdmi.c +0 -1
  	if (!enable) {
  		I915_WRITE(reg, val);
@@ -1200,9 +1206,11 @@ static void hsw_set_infoframes(struct intel_encoder *encoder,
  	intel_write_infoframe(encoder, crtc_state,
  			      HDMI_INFOFRAME_TYPE_VENDOR,
  			      &crtc_state->infoframes.hdmi);
-	intel_write_infoframe(encoder, crtc_state,

drivers/gpu/drm/i915/intel_hdmi.c static void hsw_set_infoframes(struct intel_encoder *encoder, · line 1216

Quoted 10 lines
drivers/gpu/drm/i915/intel_hdmi.c +5 -2
-			      HDMI_INFOFRAME_TYPE_DRM,
-			      &crtc_state->infoframes.drm);
+	if ((INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv)) &&
+	    conn_state->hdr_metadata_changed)
+		intel_write_infoframe(encoder, crtc_state,
+				      HDMI_INFOFRAME_TYPE_DRM,
+				      &crtc_state->infoframes.drm);
  }
 
  void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable)

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

#22 lore raw

PATCH v6 11/13 drm/i915:Enabled Modeset when HDR Infoframe changes

In reply to Uma Shankar

This patch enables modeset whenever HDR metadata
needs to be updated to sink.

---
 drivers/gpu/drm/i915/intel_atomic.c | 15 ++++++++++++++-
 drivers/gpu/drm/i915/intel_hdmi.c   |  4 ++++
 2 files changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_atomic.c +14 -1
index b844e88..4ff6042 100644
@@ -102,6 +102,16 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector,
 	return -EINVAL;
 }
 
+static bool blob_equal(const struct drm_property_blob *a,
+		       const struct drm_property_blob *b)
+{
+	if (a && b)
+		return a->length == b->length &&
+			!memcmp(a->data, b->data, a->length);
+
+	return !a == !b;
+}
+
 int intel_digital_connector_atomic_check(struct drm_connector *conn,
 					 struct drm_connector_state *new_state)
 {
@@ -129,7 +139,10 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,
 	    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)
+	    new_conn_state->base.scaling_mode !=
+				old_conn_state->base.scaling_mode ||
+	    !blob_equal(new_conn_state->base.hdr_output_metadata_blob_ptr,
+			old_conn_state->base.hdr_output_metadata_blob_ptr))
 		crtc_state->mode_changed = true;
 
 	return 0;
drivers/gpu/drm/i915/intel_hdmi.c +4 -0
index 8decafd..4d06734 100644
@@ -792,6 +792,10 @@ void intel_read_infoframe(struct intel_encoder *encoder,
 	struct hdr_static_metadata *hdr_metadata;
 	int ret;
 
+	if (!conn_state->hdr_output_metadata_blob_ptr ||
+	    conn_state->hdr_output_metadata_blob_ptr->length == 0)
+		return true;
+
 	hdr_metadata = (struct hdr_static_metadata *)
 			conn_state->hdr_output_metadata_blob_ptr->data;
 
Signature · 6 lines
1.9.1

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

Re: [v6 11/13] drm/i915:Enabled Modeset when HDR Infoframe changes

Quoted 32 lines · Uma Shankar

This patch enables modeset whenever HDR metadata
needs to be updated to sink.

---
  drivers/gpu/drm/i915/intel_atomic.c | 15 ++++++++++++++-
  drivers/gpu/drm/i915/intel_hdmi.c   |  4 ++++
  2 files changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_atomic.c +10 -0
index b844e88..4ff6042 100644
@@ -102,6 +102,16 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector,
  	return -EINVAL;
  }
 
+static bool blob_equal(const struct drm_property_blob *a,
+		       const struct drm_property_blob *b)
+{
+	if (a && b)
+		return a->length == b->length &&
+			!memcmp(a->data, b->data, a->length);
+
+	return !a == !b;
+}
+
  int intel_digital_connector_atomic_check(struct drm_connector *conn,
  					 struct drm_connector_state *new_state)
  {

drivers/gpu/drm/i915/intel_atomic.c int intel_digital_connector_atomic_check(struct drm_connector *conn, · line 144

Quoted 7 lines
drivers/gpu/drm/i915/intel_atomic.c +3 -1
@@ -129,7 +139,10 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,
  	    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)
+	    new_conn_state->base.scaling_mode !=
+				old_conn_state->base.scaling_mode ||
+	    !blob_equal(new_conn_state->base.hdr_output_metadata_blob_ptr,

If you are keeping this line ahead of the upper one due to 80 char limit, please pull that one also two tabs back, right now this is not even looking good.

Quoted 9 lines
drivers/gpu/drm/i915/intel_atomic.c +1 -0
+			old_conn_state->base.hdr_output_metadata_blob_ptr))
  		crtc_state->mode_changed = true;
 
  	return 0;
drivers/gpu/drm/i915/intel_hdmi.c +0 -0
index 8decafd..4d06734 100644

drivers/gpu/drm/i915/intel_hdmi.c void intel_read_infoframe(struct intel_encoder *encoder, · line 798

Quoted 7 lines
drivers/gpu/drm/i915/intel_hdmi.c +4 -0
@@ -792,6 +792,10 @@ void intel_read_infoframe(struct intel_encoder *encoder,
  	struct hdr_static_metadata *hdr_metadata;
  	int ret;
 
+	if (!conn_state->hdr_output_metadata_blob_ptr ||
+	    conn_state->hdr_output_metadata_blob_ptr->length == 0)
+		return true;
+

This patch needs a rebase on the latest code, as this is definitely not where we want this code :-)

- Shashank

drivers/gpu/drm/i915/intel_hdmi.c void intel_read_infoframe(struct intel_encoder *encoder, · line 801

Quoted 3 lines
drivers/gpu/drm/i915/intel_hdmi.c +0 -0
  	hdr_metadata = (struct hdr_static_metadata *)
  			conn_state->hdr_output_metadata_blob_ptr->data;
 

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

#24 lore raw

PATCH v6 12/13 drm/i915: Set Infoframe for non modeset case for HDR

In reply to Uma Shankar

HDR metadata requires a infoframe to be set. Due to fastset, full modeset is not performed hence adding it to update_pipe to handle that.

---
 drivers/gpu/drm/i915/intel_ddi.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/gpu/drm/i915/intel_ddi.c +13 -0
index 69aa0d1..a27aab9 100644
@@ -3566,6 +3566,10 @@ static void intel_ddi_update_pipe(struct intel_encoder *encoder,
 				  const struct intel_crtc_state *crtc_state,
 				  const struct drm_connector_state *conn_state)
 {
+	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
+	struct intel_digital_port *intel_dig_port =
+			enc_to_dig_port(&encoder->base);
+
 	if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
 		intel_ddi_update_pipe_dp(encoder, crtc_state, conn_state);
 
@@ -3575,6 +3579,15 @@ static void intel_ddi_update_pipe(struct intel_encoder *encoder,
 	else if (conn_state->content_protection ==
 		 DRM_MODE_CONTENT_PROTECTION_UNDESIRED)
 		intel_hdcp_disable(to_intel_connector(conn_state->connector));
+
+	/* Set the infoframe for NON modeset cases as well */
+	if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {
+		if ((INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv)) &&
+		    conn_state->hdr_metadata_changed)
+			intel_dig_port->set_infoframes(encoder,
+						       crtc_state->has_infoframe,
+						       crtc_state, conn_state);
+	}
 }
 
 static void intel_ddi_set_fia_lane_count(struct intel_encoder *encoder,
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v6 12/13
#25 lore raw

Re: [v6 12/13] drm/i915: Set Infoframe for non modeset case for HDR

Quoted 29 lines · Uma Shankar

HDR metadata requires a infoframe to be set. Due to fastset, full modeset is not performed hence adding it to update_pipe to handle that.

---
  drivers/gpu/drm/i915/intel_ddi.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
drivers/gpu/drm/i915/intel_ddi.c +5 -0
index 69aa0d1..a27aab9 100644
@@ -3566,6 +3566,10 @@ static void intel_ddi_update_pipe(struct intel_encoder *encoder,
  				  const struct intel_crtc_state *crtc_state,
  				  const struct drm_connector_state *conn_state)
  {
+	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
+	struct intel_digital_port *intel_dig_port =
+			enc_to_dig_port(&encoder->base);
+
  	if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
  		intel_ddi_update_pipe_dp(encoder, crtc_state, conn_state);
 
@@ -3575,6 +3579,15 @@ static void intel_ddi_update_pipe(struct intel_encoder *encoder,
  	else if (conn_state->content_protection ==
  		 DRM_MODE_CONTENT_PROTECTION_UNDESIRED)
  		intel_hdcp_disable(to_intel_connector(conn_state->connector));
+

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_update_pipe(struct intel_encoder *encoder, · line 3592

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +8 -0
+	/* Set the infoframe for NON modeset cases as well */
+	if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {
+		if ((INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv)) &&
+		    conn_state->hdr_metadata_changed)
+			intel_dig_port->set_infoframes(encoder,
+						       crtc_state->has_infoframe,
+						       crtc_state, conn_state);
+	}
  }
 

Looks good to me,  Please feel free to use:

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_update_pipe(struct intel_encoder *encoder, · line 3593

Quoted 1 line
drivers/gpu/drm/i915/intel_ddi.c +0 -0
  static void intel_ddi_set_fia_lane_count(struct intel_encoder *encoder,

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

#26 lore raw

Re: [v6 12/13] drm/i915: Set Infoframe for non modeset case for HDR

In reply to Uma Shankar
Quoted 26 lines · Uma Shankar

HDR metadata requires a infoframe to be set. Due to fastset, full modeset is not performed hence adding it to update_pipe to handle that.

---
 drivers/gpu/drm/i915/intel_ddi.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/gpu/drm/i915/intel_ddi.c +4 -0
index 69aa0d1..a27aab9 100644
@@ -3566,6 +3566,10 @@ static void intel_ddi_update_pipe(struct intel_encoder *encoder,
 				  const struct intel_crtc_state *crtc_state,
 				  const struct drm_connector_state *conn_state)
 {
+	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
+	struct intel_digital_port *intel_dig_port =
+			enc_to_dig_port(&encoder->base);
+
 	if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
 		intel_ddi_update_pipe_dp(encoder, crtc_state, conn_state);
 
@@ -3575,6 +3579,15 @@ static void intel_ddi_update_pipe(struct intel_encoder *encoder,
 	else if (conn_state->content_protection ==

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_update_pipe(struct intel_encoder *encoder, · line 3589

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +8 -0
 		 DRM_MODE_CONTENT_PROTECTION_UNDESIRED)
 		intel_hdcp_disable(to_intel_connector(conn_state->connector));
+
+	/* Set the infoframe for NON modeset cases as well */
+	if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {
+		if ((INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv)) &&
+		    conn_state->hdr_metadata_changed)
+			intel_dig_port->set_infoframes(encoder,
+						       crtc_state->has_infoframe,
+						       crtc_state, conn_state);

I don't think this should be tied to the drm infoframe. It should be totally generic. IIRC there is also some magic dance we may have to perform when updating infoframes with the port enabled. But the details escape right now.

Quoted 11 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -0
+	}
 }
 
 static void intel_ddi_set_fia_lane_count(struct intel_encoder *encoder,
Signature · 6 lines
1.9.1

_______________________________________________
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
#27 lore raw

RE: [v6 12/13] drm/i915: Set Infoframe for non modeset case for HDR

Quoted 40 lines

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Ville Syrjälä
Sent: Friday, March 29, 2019 7:35 PM
To: Shankar, Uma <[email protected]>
Cc: Syrjala, Ville <[email protected]>; [email protected]; intel- [email protected]; [email protected]; dri- [email protected]; Lankhorst, Maarten <[email protected]>
Subject: Re: [v6 12/13] drm/i915: Set Infoframe for non modeset case for HDR

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_update_pipe(struct intel_encoder

Quoted 15 lines · Uma Shankar

HDR metadata requires a infoframe to be set. Due to fastset, full modeset is not performed hence adding it to update_pipe to handle that.

---
 drivers/gpu/drm/i915/intel_ddi.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index 69aa0d1..a27aab9 100644
@@ -3566,6 +3566,10 @@ static void intel_ddi_update_pipe(struct intel_encoder

*encoder,

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_update_pipe(struct intel_encoder

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +4 -0
 				  const struct intel_crtc_state *crtc_state,
 				  const struct drm_connector_state *conn_state)  {
+	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
+	struct intel_digital_port *intel_dig_port =
+			enc_to_dig_port(&encoder->base);
+
 	if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI))
 		intel_ddi_update_pipe_dp(encoder, crtc_state, conn_state);
 
@@ -3575,6 +3579,15 @@ static void intel_ddi_update_pipe(struct intel_encoder

*encoder,

Quoted 15 lines

drivers/gpu/drm/i915/intel_ddi.c static void intel_ddi_update_pipe(struct intel_encoder *encoder, · line 3589

Quoted 11 lines
drivers/gpu/drm/i915/intel_ddi.c +8 -0
 	else if (conn_state->content_protection ==
 		 DRM_MODE_CONTENT_PROTECTION_UNDESIRED)
 		intel_hdcp_disable(to_intel_connector(conn_state->connector));
+
+	/* Set the infoframe for NON modeset cases as well */
+	if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) {
+		if ((INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv)) &&
+		    conn_state->hdr_metadata_changed)
+			intel_dig_port->set_infoframes(encoder,
+						       crtc_state->has_infoframe,
+						       crtc_state, conn_state);

I don't think this should be tied to the drm infoframe. It should be totally generic. IIRC there is also some magic dance we may have to perform when updating infoframes with the port enabled. But the details escape right now.

Hi Ville,
I agree, currently limiting it to DRM Infoframes so that we don't break the legacy usecase/non HDR cases. We will have to enable this for all kind of infoframes and validate if things are fine.

Regards,
Uma Shankar

Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -0
+	}
 }
 
 static void intel_ddi_set_fia_lane_count(struct intel_encoder

*encoder,
--
1.9.1

Quoted 12 lines
Quoted 4 lines

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

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

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

#28 lore raw

PATCH v6 13/13 video/hdmi: Add const variants for drm infoframe

In reply to Uma Shankar

Added the const version of infoframe for DRM metadata for HDR.

---
 drivers/video/hdmi.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 include/linux/hdmi.h |  5 +++++
 2 files changed, 66 insertions(+), 2 deletions(-)
drivers/video/hdmi.c +61 -2
index 80bb0ee..f9ca555 100644
@@ -668,6 +668,30 @@ int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame)
 }
 EXPORT_SYMBOL(hdmi_drm_infoframe_init);
 
+static int hdmi_drm_infoframe_check_only(const struct hdmi_drm_infoframe *frame)
+{
+	if (frame->type != HDMI_INFOFRAME_TYPE_DRM ||
+	    frame->version != 1)
+		return -EINVAL;
+
+	return 0;
+}
+
+/**
+ * hdmi_drm_infoframe_check() - check a HDMI DRM infoframe
+ * @frame: HDMI DRM infoframe
+ *
+ * Validates that the infoframe is consistent and updates derived fields
+ * (eg. length) based on other fields.
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+int hdmi_drm_infoframe_check(struct hdmi_drm_infoframe *frame)
+{
+	return hdmi_drm_infoframe_check_only(frame);
+}
+EXPORT_SYMBOL(hdmi_drm_infoframe_check);
+
 /**
  * hdmi_drm_infoframe_pack() - write HDMI DRM infoframe to binary buffer
  * @frame: HDMI DRM infoframe
@@ -682,8 +706,8 @@ int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame)
  * Returns the number of bytes packed into the binary buffer or a negative
  * error code on failure.
  */
-ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
-				size_t size)
+ssize_t hdmi_drm_infoframe_pack_only(const struct hdmi_drm_infoframe *frame,
+				     void *buffer, size_t size)
 {
 	u8 *ptr = buffer;
 	size_t length;
@@ -736,6 +760,37 @@ ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
 
 	return length;
 }
+EXPORT_SYMBOL(hdmi_drm_infoframe_pack_only);
+
+/**
+ * hdmi_drm_infoframe_pack() - check a HDMI DRM infoframe,
+ *                             and write it to binary buffer
+ * @frame: HDMI DRM infoframe
+ * @buffer: destination buffer
+ * @size: size of buffer
+ *
+ * Validates that the infoframe is consistent and updates derived fields
+ * (eg. length) based on other fields, after which it packs the information
+ * contained in the @frame structure into a binary representation that
+ * can be written into the corresponding controller registers. This function
+ * also computes the checksum as required by section 5.3.5 of the HDMI 1.4
+ * specification.
+ *
+ * Returns the number of bytes packed into the binary buffer or a negative
+ * error code on failure.
+ */
+ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame,
+				void *buffer, size_t size)
+{
+	int ret;
+
+	ret = hdmi_drm_infoframe_check(frame);
+	if (ret)
+		return ret;
+
+	return hdmi_drm_infoframe_pack_only(frame, buffer, size);
+}
+EXPORT_SYMBOL(hdmi_drm_infoframe_pack);
 
 /*
  * hdmi_vendor_any_infoframe_check() - check a vendor infoframe
@@ -845,6 +900,10 @@ ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
 		length = hdmi_avi_infoframe_pack_only(&frame->avi,
 						      buffer, size);
 		break;
+	case HDMI_INFOFRAME_TYPE_DRM:
+		length = hdmi_drm_infoframe_pack_only(&frame->drm,
+						      buffer, size);
+		break;
 	case HDMI_INFOFRAME_TYPE_SPD:
 		length = hdmi_spd_infoframe_pack_only(&frame->spd,
 						      buffer, size);
include/linux/hdmi.h +5 -0
index 202ed4a..fd8e534 100644
@@ -213,6 +213,11 @@ ssize_t hdmi_avi_infoframe_pack_only(const struct hdmi_avi_infoframe *frame,
 				     void *buffer, size_t size);
 int hdmi_avi_infoframe_check(struct hdmi_avi_infoframe *frame);
 int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame);
+ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
+				size_t size);
+ssize_t hdmi_drm_infoframe_pack_only(const struct hdmi_drm_infoframe *frame,
+				     void *buffer, size_t size);
+int hdmi_drm_infoframe_check(struct hdmi_drm_infoframe *frame);
 
 enum hdmi_spd_sdi {
 	HDMI_SPD_SDI_UNKNOWN,
Signature · 6 lines
1.9.1

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

Re: [v6 13/13] video/hdmi: Add const variants for drm infoframe

Hi,

Quoted 4 lines · Uma Shankar

Added the const version of infoframe for DRM metadata for HDR.

Unless there's a strong reason not to, I think this can be squashed into patch 6.

Quoted 18 lines
---
 drivers/video/hdmi.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 include/linux/hdmi.h |  5 +++++
 2 files changed, 66 insertions(+), 2 deletions(-)
drivers/video/hdmi.c +5 -0
index 80bb0ee..f9ca555 100644
@@ -668,6 +668,30 @@ int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame)
 }
 EXPORT_SYMBOL(hdmi_drm_infoframe_init);
 
+static int hdmi_drm_infoframe_check_only(const struct hdmi_drm_infoframe *frame)
+{
+	if (frame->type != HDMI_INFOFRAME_TYPE_DRM ||
+	    frame->version != 1)
+		return -EINVAL;

drivers/video/hdmi.c int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame) · line 685

Quoted 10 lines
drivers/video/hdmi.c +10 -0
+
+	return 0;
+}
+
+/**
+ * hdmi_drm_infoframe_check() - check a HDMI DRM infoframe
+ * @frame: HDMI DRM infoframe
+ *
+ * Validates that the infoframe is consistent and updates derived fields
+ * (eg. length) based on other fields.

This comment doesn't match the implementation.

Thanks,
-Brian

Quoted 91 lines
drivers/video/hdmi.c +46 -2
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+int hdmi_drm_infoframe_check(struct hdmi_drm_infoframe *frame)
+{
+	return hdmi_drm_infoframe_check_only(frame);
+}
+EXPORT_SYMBOL(hdmi_drm_infoframe_check);
+
 /**
  * hdmi_drm_infoframe_pack() - write HDMI DRM infoframe to binary buffer
  * @frame: HDMI DRM infoframe
@@ -682,8 +706,8 @@ int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame)
  * Returns the number of bytes packed into the binary buffer or a negative
  * error code on failure.
  */
-ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
-				size_t size)
+ssize_t hdmi_drm_infoframe_pack_only(const struct hdmi_drm_infoframe *frame,
+				     void *buffer, size_t size)
 {
 	u8 *ptr = buffer;
 	size_t length;
@@ -736,6 +760,37 @@ ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
 
 	return length;
 }
+EXPORT_SYMBOL(hdmi_drm_infoframe_pack_only);
+
+/**
+ * hdmi_drm_infoframe_pack() - check a HDMI DRM infoframe,
+ *                             and write it to binary buffer
+ * @frame: HDMI DRM infoframe
+ * @buffer: destination buffer
+ * @size: size of buffer
+ *
+ * Validates that the infoframe is consistent and updates derived fields
+ * (eg. length) based on other fields, after which it packs the information
+ * contained in the @frame structure into a binary representation that
+ * can be written into the corresponding controller registers. This function
+ * also computes the checksum as required by section 5.3.5 of the HDMI 1.4
+ * specification.
+ *
+ * Returns the number of bytes packed into the binary buffer or a negative
+ * error code on failure.
+ */
+ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame,
+				void *buffer, size_t size)
+{
+	int ret;
+
+	ret = hdmi_drm_infoframe_check(frame);
+	if (ret)
+		return ret;
+
+	return hdmi_drm_infoframe_pack_only(frame, buffer, size);
+}
+EXPORT_SYMBOL(hdmi_drm_infoframe_pack);
 
 /*
  * hdmi_vendor_any_infoframe_check() - check a vendor infoframe
@@ -845,6 +900,10 @@ ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
 		length = hdmi_avi_infoframe_pack_only(&frame->avi,
 						      buffer, size);
 		break;
+	case HDMI_INFOFRAME_TYPE_DRM:
+		length = hdmi_drm_infoframe_pack_only(&frame->drm,
+						      buffer, size);
+		break;
 	case HDMI_INFOFRAME_TYPE_SPD:
 		length = hdmi_spd_infoframe_pack_only(&frame->spd,
 						      buffer, size);
include/linux/hdmi.h +5 -0
index 202ed4a..fd8e534 100644
@@ -213,6 +213,11 @@ ssize_t hdmi_avi_infoframe_pack_only(const struct hdmi_avi_infoframe *frame,
 				     void *buffer, size_t size);
 int hdmi_avi_infoframe_check(struct hdmi_avi_infoframe *frame);
 int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame);
+ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
+				size_t size);
+ssize_t hdmi_drm_infoframe_pack_only(const struct hdmi_drm_infoframe *frame,
+				     void *buffer, size_t size);
+int hdmi_drm_infoframe_check(struct hdmi_drm_infoframe *frame);
 
 enum hdmi_spd_sdi {
 	HDMI_SPD_SDI_UNKNOWN,
Signature · 1 line
1.9.1

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

#30 lore raw

Re: [v6 13/13] video/hdmi: Add const variants for drm infoframe

Quoted 13 lines

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Brian Starkey
Sent: Thursday, March 21, 2019 5:31 PM
To: Shankar, Uma <[email protected]>
Cc: Syrjala, Ville <[email protected]>; Liviu Dudau <[email protected]>; [email protected]; [email protected]; dri- [email protected]; nd <[email protected]>; Lankhorst, Maarten <[email protected]>
Subject: Re: [v6 13/13] video/hdmi: Add const variants for drm infoframe

Quoted 8 lines

Hi,

Quoted 3 lines · Uma Shankar

Added the const version of infoframe for DRM metadata for HDR.

Unless there's a strong reason not to, I think this can be squashed into patch 6.

This was added later after some infoframe rework, so was keeping this separately, but yeah this can be squashed with 6.

Quoted 23 lines
Quoted 23 lines
---
 drivers/video/hdmi.c | 63
++++++++++++++++++++++++++++++++++++++++++++++++++--
 include/linux/hdmi.h |  5 +++++
 2 files changed, 66 insertions(+), 2 deletions(-)
drivers/video/hdmi.c index renamed from drivers/video/hdmi.c +0 -0

80bb0ee..f9ca555 100644

drivers/video/hdmi.c +10 -0
@@ -668,6 +668,30 @@ int hdmi_drm_infoframe_init(struct
 hdmi_drm_infoframe *frame)  }  EXPORT_SYMBOL(hdmi_drm_infoframe_init);
 
+static int hdmi_drm_infoframe_check_only(const struct
+hdmi_drm_infoframe *frame) {
+	if (frame->type != HDMI_INFOFRAME_TYPE_DRM ||
+	    frame->version != 1)
+		return -EINVAL;
+
+	return 0;
+}
+
+/**
Quoted 8 lines

drivers/video/hdmi.c int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame) · line 685

Quoted 6 lines
drivers/video/hdmi.c +6 -0
+ * hdmi_drm_infoframe_check() - check a HDMI DRM infoframe
+ * @frame: HDMI DRM infoframe
+ *
+ * Validates that the infoframe is consistent and updates derived
+fields
+ * (eg. length) based on other fields.

This comment doesn't match the implementation.

Ok, will update this comment.

Thanks Brian for the review and valuable feedback. Will send out the next version soon fixing all the comments.

Regards,
Uma Shankar

Quoted 99 lines

Thanks,
-Brian

drivers/video/hdmi.c int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe

Quoted 12 lines
drivers/video/hdmi.c +8 -0
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+int hdmi_drm_infoframe_check(struct hdmi_drm_infoframe *frame) {
+	return hdmi_drm_infoframe_check_only(frame);
+}
+EXPORT_SYMBOL(hdmi_drm_infoframe_check);
+
 /**
  * hdmi_drm_infoframe_pack() - write HDMI DRM infoframe to binary buffer
  * @frame: HDMI DRM infoframe
@@ -682,8 +706,8 @@ int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe

*frame)

drivers/video/hdmi.c int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame)

Quoted 4 lines
drivers/video/hdmi.c +0 -1
  * Returns the number of bytes packed into the binary buffer or a negative
  * error code on failure.
  */
-ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void

*buffer,

Quoted 41 lines
drivers/video/hdmi.c +32 -1
-				size_t size)
+ssize_t hdmi_drm_infoframe_pack_only(const struct hdmi_drm_infoframe *frame,
+				     void *buffer, size_t size)
 {
 	u8 *ptr = buffer;
 	size_t length;
@@ -736,6 +760,37 @@ ssize_t hdmi_drm_infoframe_pack(struct
 hdmi_drm_infoframe *frame, void *buffer,
 
 	return length;
 }
+EXPORT_SYMBOL(hdmi_drm_infoframe_pack_only);
+
+/**
+ * hdmi_drm_infoframe_pack() - check a HDMI DRM infoframe,
+ *                             and write it to binary buffer
+ * @frame: HDMI DRM infoframe
+ * @buffer: destination buffer
+ * @size: size of buffer
+ *
+ * Validates that the infoframe is consistent and updates derived
+fields
+ * (eg. length) based on other fields, after which it packs the
+information
+ * contained in the @frame structure into a binary representation
+that
+ * can be written into the corresponding controller registers. This
+function
+ * also computes the checksum as required by section 5.3.5 of the
+HDMI 1.4
+ * specification.
+ *
+ * Returns the number of bytes packed into the binary buffer or a
+negative
+ * error code on failure.
+ */
+ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame,
+				void *buffer, size_t size)
+{
+	int ret;
+

drivers/video/hdmi.c ssize_t hdmi_drm_infoframe_pack(struct

Quoted 10 lines
drivers/video/hdmi.c +6 -1
+	ret = hdmi_drm_infoframe_check(frame);
+	if (ret)
+		return ret;
+
+	return hdmi_drm_infoframe_pack_only(frame, buffer, size); }
+EXPORT_SYMBOL(hdmi_drm_infoframe_pack);
 
 /*
  * hdmi_vendor_any_infoframe_check() - check a vendor infoframe @@
-845,6 +900,10 @@ ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe

*frame, void *buffer,

include/linux/hdmi.h ssize_t hdmi_avi_infoframe_pack_only(const struct

Quoted 15 lines
drivers/video/hdmi.c +4 -0
 		length = hdmi_avi_infoframe_pack_only(&frame->avi,
 						      buffer, size);
 		break;
+	case HDMI_INFOFRAME_TYPE_DRM:
+		length = hdmi_drm_infoframe_pack_only(&frame->drm,
+						      buffer, size);
+		break;
 	case HDMI_INFOFRAME_TYPE_SPD:
 		length = hdmi_spd_infoframe_pack_only(&frame->spd,
 						      buffer, size);
include/linux/hdmi.h index renamed from include/linux/hdmi.h +0 -0

202ed4a..fd8e534 100644

include/linux/hdmi.h +0 -0
@@ -213,6 +213,11 @@ ssize_t hdmi_avi_infoframe_pack_only(const struct

hdmi_avi_infoframe *frame,

include/linux/hdmi.h ssize_t hdmi_avi_infoframe_pack_only(const struct · line 216

Quoted 4 lines
include/linux/hdmi.h +1 -0
 				     void *buffer, size_t size);
 int hdmi_avi_infoframe_check(struct hdmi_avi_infoframe *frame);  int
 hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame);
+ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void

*buffer,

Quoted 5 lines
include/linux/hdmi.h +4 -0
+				size_t size);
+ssize_t hdmi_drm_infoframe_pack_only(const struct hdmi_drm_infoframe *frame,
+				     void *buffer, size_t size);
+int hdmi_drm_infoframe_check(struct hdmi_drm_infoframe *frame);
 
Quoted 9 lines
Quoted 5 lines
include/linux/hdmi.h +0 -1
 enum hdmi_spd_sdi {
 	HDMI_SPD_SDI_UNKNOWN,
--

1.9.1

_______________________________________________
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

Reviewed-by on v6 13/13
#31 lore raw

Re: [v6 13/13] video/hdmi: Add const variants for drm infoframe

In reply to Uma Shankar
Quoted 23 lines · Uma Shankar

Added the const version of infoframe for DRM metadata for HDR.

---
  drivers/video/hdmi.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++--
  include/linux/hdmi.h |  5 +++++
  2 files changed, 66 insertions(+), 2 deletions(-)
drivers/video/hdmi.c +6 -0
index 80bb0ee..f9ca555 100644
@@ -668,6 +668,30 @@ int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame)
  }
  EXPORT_SYMBOL(hdmi_drm_infoframe_init);
 
+static int hdmi_drm_infoframe_check_only(const struct hdmi_drm_infoframe *frame)
+{
+	if (frame->type != HDMI_INFOFRAME_TYPE_DRM ||
+	    frame->version != 1)
+		return -EINVAL;
+

drivers/video/hdmi.c int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame) · line 686

Quoted 10 lines
drivers/video/hdmi.c +10 -0
+	return 0;
+}
+
+/**
+ * hdmi_drm_infoframe_check() - check a HDMI DRM infoframe
+ * @frame: HDMI DRM infoframe
+ *
+ * Validates that the infoframe is consistent and updates derived fields
+ * (eg. length) based on other fields.
+ *

This comment doesn't match what's being done in this function, as, hdmi_drm_infoframe_check_only() doesn't validate length.

Quoted 77 lines
drivers/video/hdmi.c +45 -2
+ * Returns 0 on success or a negative error code on failure.
+ */
+int hdmi_drm_infoframe_check(struct hdmi_drm_infoframe *frame)
+{
+	return hdmi_drm_infoframe_check_only(frame);
+}
+EXPORT_SYMBOL(hdmi_drm_infoframe_check);
+
  /**
   * hdmi_drm_infoframe_pack() - write HDMI DRM infoframe to binary buffer
   * @frame: HDMI DRM infoframe
@@ -682,8 +706,8 @@ int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame)
   * Returns the number of bytes packed into the binary buffer or a negative
   * error code on failure.
   */
-ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
-				size_t size)
+ssize_t hdmi_drm_infoframe_pack_only(const struct hdmi_drm_infoframe *frame,
+				     void *buffer, size_t size)
  {
  	u8 *ptr = buffer;
  	size_t length;
@@ -736,6 +760,37 @@ ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
 
  	return length;
  }
+EXPORT_SYMBOL(hdmi_drm_infoframe_pack_only);
+
+/**
+ * hdmi_drm_infoframe_pack() - check a HDMI DRM infoframe,
+ *                             and write it to binary buffer
+ * @frame: HDMI DRM infoframe
+ * @buffer: destination buffer
+ * @size: size of buffer
+ *
+ * Validates that the infoframe is consistent and updates derived fields
+ * (eg. length) based on other fields, after which it packs the information
+ * contained in the @frame structure into a binary representation that
+ * can be written into the corresponding controller registers. This function
+ * also computes the checksum as required by section 5.3.5 of the HDMI 1.4
+ * specification.
+ *
+ * Returns the number of bytes packed into the binary buffer or a negative
+ * error code on failure.
+ */
+ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame,
+				void *buffer, size_t size)
+{
+	int ret;
+
+	ret = hdmi_drm_infoframe_check(frame);
+	if (ret)
+		return ret;
+
+	return hdmi_drm_infoframe_pack_only(frame, buffer, size);
+}
+EXPORT_SYMBOL(hdmi_drm_infoframe_pack);
 
  /*
   * hdmi_vendor_any_infoframe_check() - check a vendor infoframe
@@ -845,6 +900,10 @@ ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
  		length = hdmi_avi_infoframe_pack_only(&frame->avi,
  						      buffer, size);
  		break;
+	case HDMI_INFOFRAME_TYPE_DRM:
+		length = hdmi_drm_infoframe_pack_only(&frame->drm,
+						      buffer, size);
+		break;
  	case HDMI_INFOFRAME_TYPE_SPD:
  		length = hdmi_spd_infoframe_pack_only(&frame->spd,
  						      buffer, size);
include/linux/hdmi.h +0 -0
index 202ed4a..fd8e534 100644
@@ -213,6 +213,11 @@ ssize_t hdmi_avi_infoframe_pack_only(const struct hdmi_avi_infoframe *frame,
  				     void *buffer, size_t size);

include/linux/hdmi.h ssize_t hdmi_avi_infoframe_pack_only(const struct hdmi_avi_infoframe *frame, · line 223

Quoted 10 lines
include/linux/hdmi.h +5 -0
  int hdmi_avi_infoframe_check(struct hdmi_avi_infoframe *frame);
  int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame);
+ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
+				size_t size);
+ssize_t hdmi_drm_infoframe_pack_only(const struct hdmi_drm_infoframe *frame,
+				     void *buffer, size_t size);
+int hdmi_drm_infoframe_check(struct hdmi_drm_infoframe *frame);
 
  enum hdmi_spd_sdi {
  	HDMI_SPD_SDI_UNKNOWN,

With that minor comment related to description fixed, this patch looks good to me. Please feel free to use:

- Shashank

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

#32 lore raw

✗ Fi.CI.CHECKPATCH: warning for Add HDR Metadata Parsing and handling in DRM layer (rev6)

In reply to Uma Shankar
== Series Details ==

== Series Details ==

Series: Add HDR Metadata Parsing and handling in DRM layer (rev6)
URL : https://patchwork.freedesktop.org/series/25091/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
3ffebb6ddcbf drm: Add HDR source metadata property
6d0a7b41e79c drm: Parse HDR metadata info from EDID
02252707998b drm: Parse Colorimetry data block from EDID
311d0c32e536 drm/i915: Attach HDR metadata property to connector
cc3d717ffd61 drm: Implement HDR output metadata set and get property handling
-:52: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis
#52: FILE: drivers/gpu/drm/drm_atomic_uapi.c:741:
+		ret = drm_atomic_replace_property_blob_from_id(dev,
+				&state->hdr_output_metadata_blob_ptr,

total: 0 errors, 0 warnings, 1 checks, 39 lines checked a39aa58b30aa drm: Enable HDR infoframe support bd2cd9ae7106 drm/i915: Write HDR infoframe and send to panel 504bef292ea4 drm/i915: [DO NOT MERGE] hack for glk board outputs aea5797dab83 drm/i915: Add HLG EOTF
2ca575ccdf2f drm/i915: Enable infoframes on GLK+ for HDR -:49: WARNING:LONG_LINE: line over 100 characters
#49: FILE: drivers/gpu/drm/i915/i915_reg.h:8209:
+#define GLK_TVIDEO_DIP_DRM_DATA(trans, i) _MMIO_TRANS2(trans, _GLK_VIDEO_DIP_DRM_DATA_A + (i) * 4)

total: 0 errors, 1 warnings, 0 checks, 76 lines checked 9cb3d2a68365 drm/i915:Enabled Modeset when HDR Infoframe changes ba5c46ba53f9 drm/i915: Set Infoframe for non modeset case for HDR 9184e65ae696 video/hdmi: Add const variants for drm infoframe

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

#33 lore raw

✗ Fi.CI.BAT: failure for Add HDR Metadata Parsing and handling in DRM layer (rev6)

In reply to Uma Shankar
== Series Details ==

== Series Details ==

Series: Add HDR Metadata Parsing and handling in DRM layer (rev6)
URL : https://patchwork.freedesktop.org/series/25091/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_5780 -> Patchwork_12528
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_12528 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_12528, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://patchwork.freedesktop.org/api/1.0/series/25091/revisions/6/mbox/

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_12528:

### IGT changes ###

#### Possible regressions ####

* igt@runner@aborted:

    - fi-byt-j1900:       NOTRUN -> FAIL
    - fi-bsw-n3050:       NOTRUN -> FAIL
    - fi-byt-n2820:       NOTRUN -> FAIL
    - fi-elk-e7500:       NOTRUN -> FAIL

Known issues
------------

Here are the changes found in Patchwork_12528 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_basic@basic-bsd2:
- fi-kbl-7500u: NOTRUN -> SKIP [fdo#109271] +9

* igt@gem_exec_suspend@basic-s3:
- fi-blb-e6850: PASS -> INCOMPLETE [fdo#107718]

* igt@kms_chamelium@dp-crc-fast:
- fi-kbl-7500u: NOTRUN -> DMESG-WARN [fdo#103841]

* igt@kms_frontbuffer_tracking@basic:
- fi-byt-clapper: PASS -> FAIL [fdo#103167]

* igt@prime_vgem@basic-fence-flip:
- fi-gdg-551: PASS -> DMESG-FAIL [fdo#103182]

* igt@runner@aborted:

    - fi-kbl-7500u:       NOTRUN -> FAIL [fdo#103841]
    - fi-apl-guc:         NOTRUN -> FAIL [fdo#108622] / [fdo#109720]
    - fi-snb-2600:        NOTRUN -> FAIL [fdo#108929]

#### Possible fixes ####

* igt@kms_busy@basic-flip-a:
- fi-gdg-551: FAIL [fdo#103182] -> PASS

[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
[fdo#103841]: https://bugs.freedesktop.org/show_bug.cgi?id=103841
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#108622]: https://bugs.freedesktop.org/show_bug.cgi?id=108622
[fdo#108929]: https://bugs.freedesktop.org/show_bug.cgi?id=108929
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109720]: https://bugs.freedesktop.org/show_bug.cgi?id=109720

Participating hosts (48 -> 42)
------------------------------

Additional (1): fi-kbl-7500u
Missing (7): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-icl-y

Build changes
-------------

* Linux: CI_DRM_5780 -> Patchwork_12528

CI_DRM_5780: 774f8c588542dda6d73161429cbf1e027789d6ef @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4892: 8ae86621d6fff60b6e20c6b0f9b336785c935b0f @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_12528: 9184e65ae696ba0aaa2fa93a4f6a6d3e04ecb625 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

9184e65ae696 video/hdmi: Add const variants for drm infoframe ba5c46ba53f9 drm/i915: Set Infoframe for non modeset case for HDR 9cb3d2a68365 drm/i915:Enabled Modeset when HDR Infoframe changes 2ca575ccdf2f drm/i915: Enable infoframes on GLK+ for HDR aea5797dab83 drm/i915: Add HLG EOTF
504bef292ea4 drm/i915: [DO NOT MERGE] hack for glk board outputs bd2cd9ae7106 drm/i915: Write HDR infoframe and send to panel a39aa58b30aa drm: Enable HDR infoframe support
cc3d717ffd61 drm: Implement HDR output metadata set and get property handling 311d0c32e536 drm/i915: Attach HDR metadata property to connector 02252707998b drm: Parse Colorimetry data block from EDID 6d0a7b41e79c drm: Parse HDR metadata info from EDID
3ffebb6ddcbf drm: Add HDR source metadata property

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12528/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx