Skip to contentSkip to conversation

Add HDR Metadata Parsing and handling in DRM layer

RFC In review Uma Shankar 3 participants 12 messages May 31, 2017

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

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.
2. UserSpace/Compositors: Blending policies and metadata blob creation and passing to driver.

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. This series is not yet tested.

Uma Shankar (9):
drm: Add HDR source metadata property
drm: Add CEA extended tag blocks and HDR bitfield macros
drm: Parse HDR metadata info from EDID
drm: Parse Colorimetry data block from EDID
drm/i915: Attach HDR metadata property to connector
drm: Add HDR capabilty field to plane structure
drm: Implement HDR source metadata set and get property handling
drm: Enable HDR infoframe support
drm/i915: Write HDR infoframe and send to panel

 drivers/gpu/drm/drm_atomic.c        |   15 ++++
 drivers/gpu/drm/drm_atomic_helper.c |    6 ++
 drivers/gpu/drm/drm_connector.c     |    7 ++
 drivers/gpu/drm/drm_edid.c          |  151 +++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_hdmi.c   |   27 +++++++
 drivers/video/hdmi.c                |  138 ++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h         |   13 +++
 include/drm/drm_edid.h              |    4 +
 include/drm/drm_mode_config.h       |    6 ++
 include/drm/drm_plane.h             |    3 +
 include/linux/hdmi.h                |   21 +++++
 include/uapi/drm/drm_mode.h         |   22 +++++
 12 files changed, 413 insertions(+)
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 5 lines · Uma Shankar

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.

Quoted 7 lines

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.
2. UserSpace/Compositors: Blending policies and metadata blob creation and passing to driver.

This is the key, before we have the userspace there's not much point in reviewing the details of the kernel interface, nor the implementation. -Daniel

Quoted 39 lines

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. This series is not yet tested.

Uma Shankar (9):
drm: Add HDR source metadata property
drm: Add CEA extended tag blocks and HDR bitfield macros
drm: Parse HDR metadata info from EDID
drm: Parse Colorimetry data block from EDID
drm/i915: Attach HDR metadata property to connector
drm: Add HDR capabilty field to plane structure
drm: Implement HDR source metadata set and get property handling
drm: Enable HDR infoframe support
drm/i915: Write HDR infoframe and send to panel

 drivers/gpu/drm/drm_atomic.c        |   15 ++++
 drivers/gpu/drm/drm_atomic_helper.c |    6 ++
 drivers/gpu/drm/drm_connector.c     |    7 ++
 drivers/gpu/drm/drm_edid.c          |  151 +++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_hdmi.c   |   27 +++++++
 drivers/video/hdmi.c                |  138 ++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h         |   13 +++
 include/drm/drm_edid.h              |    4 +
 include/drm/drm_mode_config.h       |    6 ++
 include/drm/drm_plane.h             |    3 +
 include/linux/hdmi.h                |   21 +++++
 include/uapi/drm/drm_mode.h         |   22 +++++
 12 files changed, 413 insertions(+)
Signature · 6 lines
1.7.9.5

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

RFC 1/9 drm: Add HDR source metadata property

In reply to 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.

---
 drivers/gpu/drm/drm_connector.c |    7 +++++++
 include/drm/drm_connector.h     |   11 +++++++++++
 include/drm/drm_mode_config.h   |    6 ++++++
 include/uapi/drm/drm_mode.h     |   22 ++++++++++++++++++++++
 4 files changed, 46 insertions(+)
drivers/gpu/drm/drm_connector.c +7 -0
index 5cd61af..1b36fa2 100644
@@ -789,6 +789,13 @@ int drm_connector_create_standard_properties(struct drm_device *dev)
 		return -ENOMEM;
 	dev->mode_config.link_status_property = prop;
 
+	prop = drm_property_create(dev, DRM_MODE_PROP_BLOB,
+				   "HDR_SOURCE_METADATA", 0);
+
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.hdr_source_metadata_property = prop;
+
 	return 0;
 }
 
include/drm/drm_connector.h +11 -0
index d8bb25f..c99d737 100644
@@ -342,6 +342,13 @@ struct drm_connector_state {
 	 * upscaling, mostly used for built-in panels.
 	 */
 	unsigned int scaling_mode;
+
+	/**
+	 * @metadata_blob_ptr:
+	 * DRM blob property for HDR metadata
+	 */
+	struct drm_property_blob *hdr_source_metadata_blob_ptr;
+	bool hdr_metadata_changed : 1;
 };
 
 /**
@@ -877,6 +884,10 @@ struct drm_connector {
 	uint8_t num_h_tile, num_v_tile;
 	uint8_t tile_h_loc, tile_v_loc;
 	uint16_t tile_h_size, tile_v_size;
+
+	/* HDR metdata */
+	struct hdr_static_metadata *hdr_panel_metadata;
+	struct hdr_static_metadata *hdr_source_metadata;
 };
 
 #define obj_to_connector(x) container_of(x, struct drm_connector, base)
include/drm/drm_mode_config.h +6 -0
index 4298171..9ca49ea 100644
@@ -741,6 +741,12 @@ struct drm_mode_config {
 	 */
 	struct drm_property *suggested_y_property;
 
+	/**
+	 * hdr_metadata_property: Connector property containing hdr metatda
+	 * This will be provided by userspace compositors based on HDR content
+	 */
+	struct drm_property *hdr_source_metadata_property;
+
 	/* dumb ioctl parameters */
 	uint32_t preferred_depth, prefer_shadow;
 
include/uapi/drm/drm_mode.h +22 -0
index 403339f..920ea2a 100644
@@ -590,6 +590,28 @@ struct drm_color_lut {
 	__u16 reserved;
 };
 
+enum supported_eotf_type {
+	TRADITIONAL_GAMMA_SDR = 0,
+	TRADITIONA_GAMMA_HDR,
+	SMPTE_ST2084,
+	FUTURE_EOTF
+};
+
+/* HDR Metadata */
+struct hdr_static_metadata {
+	uint16_t eotf;
+	uint16_t type;
+	uint16_t display_primaries_x[3];
+	uint16_t display_primaries_y[3];
+	uint16_t white_point_x;
+	uint16_t white_point_y;
+	uint16_t max_mastering_display_luminance;
+	uint16_t min_mastering_display_luminance;
+	uint16_t max_fall;
+	uint16_t max_cll;
+	uint16_t min_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.7.9.5

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

RFC 2/9 drm: Add CEA extended tag blocks and HDR bitfield macros

In reply to Uma Shankar

Add bit field and macro for extended tag in CEA block. Also, declare macros for HDR metadata block.

---
 drivers/gpu/drm/drm_edid.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/gpu/drm/drm_edid.c +16 -0
index 2e55599..4dee139 100644
@@ -2572,6 +2572,22 @@ static int drm_cvt_modes(struct drm_connector *connector,
 #define EDID_CEA_YCRCB422	(1 << 4)
 #define EDID_CEA_VCDB_QS	(1 << 6)
 
+#define DATA_BLOCK_EXTENDED_TAG		0x07
+#define VIDEO_CAPABILITY_DATA_BLOCK	0x0
+#define VSVD_DATA_BLOCK			0x1
+#define COLORIMETRY_DATA_BLOCK		0x5
+#define HDR_STATIC_METADATA_BLOCK	0x6
+
+/* HDR Metadata Block: Bit fields */
+#define SUPPORTED_EOTF_MASK            0x3f
+#define TRADITIONAL_GAMMA_SDR          (0x1 << 0)
+#define TRADITIONAL_GAMMA_HDR          (0x1 << 1)
+#define SMPTE_ST2084                   (0x1 << 2)
+#define FUTURE_EOTF                    (0x1 << 3)
+#define RESERVED_EOTF                  (0x3 << 4)
+
+#define STATIC_METADATA_TYPE1          (0x1 << 0)
+
 /*
  * Search EDID for CEA extension block.
  */
Signature · 6 lines
1.7.9.5

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

RFC 3/9 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.

---
 drivers/gpu/drm/drm_edid.c |   58 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
drivers/gpu/drm/drm_edid.c +58 -0
index 4dee139..14f2740 100644
@@ -3375,6 +3375,62 @@ 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) != DATA_BLOCK_EXTENDED_TAG)
+		return false;
+
+	if (db[1] != HDR_STATIC_METADATA_BLOCK)
+		return false;
+
+	return true;
+}
+
+static uint16_t eotf_supported(const u8 *edid_ext)
+{
+	uint16_t val = 0;
+
+	if (edid_ext[2] & TRADITIONAL_GAMMA_SDR)
+		val |= TRADITIONAL_GAMMA_SDR;
+	if (edid_ext[2] & TRADITIONAL_GAMMA_HDR)
+		val |= TRADITIONAL_GAMMA_HDR;
+	if (edid_ext[2] & SMPTE_ST2084)
+		val |= SMPTE_ST2084;
+
+	return val;
+}
+
+static uint16_t hdr_metadata_type(const u8 *edid_ext)
+{
+	uint16_t val = 0;
+
+	if (edid_ext[3] & STATIC_METADATA_TYPE1)
+		val |= STATIC_METADATA_TYPE1;
+
+	return val;
+}
+
+static void
+drm_parse_hdr_metadata_block(struct drm_connector *connector, const u8 *db)
+{
+	uint16_t len;
+
+	len = cea_db_payload_len(db);
+	connector->hdr_panel_metadata->eotf = eotf_supported(db);
+	connector->hdr_panel_metadata->type = hdr_metadata_type(db);
+
+	if (len == 6) {
+		connector->hdr_panel_metadata->max_cll = db[4];
+		connector->hdr_panel_metadata->max_fall = db[5];
+		connector->hdr_panel_metadata->min_cll = db[6];
+	} else if (len == 5) {
+		connector->hdr_panel_metadata->max_cll = db[4];
+		connector->hdr_panel_metadata->max_fall = db[5];
+	} else if (len == 4)
+		connector->hdr_panel_metadata->max_cll = db[4];
+
+}
+
 static void
 drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
 {
@@ -3997,6 +4053,8 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 			drm_parse_hdmi_vsdb_video(connector, db);
 		if (cea_db_is_hdmi_forum_vsdb(db))
 			drm_parse_hdmi_forum_vsdb(connector, db);
+		if (cea_db_is_hdmi_hdr_metadata_block(db))
+			drm_parse_hdr_metadata_block(connector, db);
 	}
 }
 
Signature · 6 lines
1.7.9.5

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

RFC 4/9 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.

---
 drivers/gpu/drm/drm_edid.c  |   24 ++++++++++++++++++++++++
 include/drm/drm_connector.h |    2 ++
 2 files changed, 26 insertions(+)
drivers/gpu/drm/drm_edid.c +24 -0
index 14f2740..c9b9c3c 100644
@@ -3375,6 +3375,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) != DATA_BLOCK_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;
+	uint16_t len;
+
+	len = cea_db_payload_len(db);
+	info->colorimetry = db[2];
+}
+
+
 static bool cea_db_is_hdmi_hdr_metadata_block(const u8 *db)
 {
 	if (cea_db_tag(db) != DATA_BLOCK_EXTENDED_TAG)
@@ -4055,6 +4077,8 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 			drm_parse_hdmi_forum_vsdb(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 +2 -0
index c99d737..c2b0798 100644
@@ -137,6 +137,8 @@ struct drm_scdc {
 struct drm_hdmi_info {
 	/** @scdc: sink's scdc support and capabilities */
 	struct drm_scdc scdc;
+	/* Colorimerty info from EDID */
+	u32 colorimetry;
 };
 
 /**
Signature · 6 lines
1.7.9.5

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

RFC 5/9 drm/i915: Attach HDR metadata property to connector

In reply to Uma Shankar

Attach HDR metadata property to connector object.

---
 drivers/gpu/drm/i915/intel_hdmi.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/intel_hdmi.c +2 -0
index 41267ff..d8b53d0 100644
@@ -1734,6 +1734,8 @@ static void intel_hdmi_destroy(struct drm_connector *connector)
 	intel_attach_broadcast_rgb_property(connector);
 	intel_attach_aspect_ratio_property(connector);
 	connector->state->picture_aspect_ratio = HDMI_PICTURE_ASPECT_NONE;
+	drm_object_attach_property(&connector->base,
+		connector->dev->mode_config.hdr_source_metadata_property, 0);
 }
 
 /*
Signature · 6 lines
1.7.9.5

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

RFC 6/9 drm: Add HDR capabilty field to plane structure

In reply to Uma Shankar

Hardware may have HDR capability on certain plane
engines. Enabling the same in drm plane structure
so that this can be communicated to user space.

Each drm driver should set this flag to true for planes which support HDR.

---
 include/drm/drm_plane.h |    3 +++
 1 file changed, 3 insertions(+)
include/drm/drm_plane.h +3 -0
index 9ab3e70..96d8f55 100644
@@ -498,6 +498,9 @@ struct drm_plane {
 
 	enum drm_plane_type type;
 
+	/* Value of true:1 means HDR is supported */
+	bool hdr_supported;
+
 	/**
 	 * @index: Position inside the mode_config.list, can be used as an array
 	 * index. It is invariant over the lifetime of the plane.
Signature · 6 lines
1.7.9.5

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

RFC 7/9 drm: Implement HDR source metadata set and get property handling

In reply to Uma Shankar

HDR source metadata set and get property implemented in this patch. The blob data is received from userspace and saved in connector state, the same is returned as blob in get property call to userspace.

---
 drivers/gpu/drm/drm_atomic.c        |   15 +++++++++++++++
 drivers/gpu/drm/drm_atomic_helper.c |    6 ++++++
 2 files changed, 21 insertions(+)
drivers/gpu/drm/drm_atomic.c +15 -0
index e163701..c0007c1 100644
@@ -1140,6 +1140,8 @@ 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, val);
@@ -1188,6 +1190,14 @@ 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_source_metadata_property) {
+			ret = drm_atomic_replace_property_blob_from_id(dev,
+					&state->hdr_source_metadata_blob_ptr,
+					val,
+					-1,
+					&replaced);
+			state->hdr_metadata_changed |= replaced;
+			return ret;
 	} else if (property == config->aspect_ratio_property) {
 		state->picture_aspect_ratio = val;
 	} else if (property == connector->scaling_mode_property) {
@@ -1210,6 +1220,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->funcs->atomic_print_state)
 		connector->funcs->atomic_print_state(p, state);
@@ -1272,6 +1284,9 @@ static void drm_atomic_connector_print_state(struct drm_printer *p,
 		*val = state->picture_aspect_ratio;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
+	} else if (property == config->hdr_source_metadata_property) {
+		*val = (state->hdr_source_metadata_blob_ptr) ?
+			state->hdr_source_metadata_blob_ptr->base.id : 0;
 	} else if (connector->funcs->atomic_get_property) {
 		return connector->funcs->atomic_get_property(connector,
 				state, property, val);
drivers/gpu/drm/drm_atomic_helper.c +6 -0
index 93b0221..1406441 100644
@@ -3436,6 +3436,10 @@ void drm_atomic_helper_connector_reset(struct drm_connector *connector)
 	memcpy(state, connector->state, sizeof(*state));
 	if (state->crtc)
 		drm_connector_get(connector);
+	if (state->hdr_source_metadata_blob_ptr)
+		drm_property_blob_get(state->hdr_source_metadata_blob_ptr);
+
+	state->hdr_metadata_changed = false;
 }
 EXPORT_SYMBOL(__drm_atomic_helper_connector_duplicate_state);
 
@@ -3562,6 +3566,8 @@ struct drm_atomic_state *
 {
 	if (state->crtc)
 		drm_connector_put(state->connector);
+	if (state->hdr_source_metadata_blob_ptr)
+		drm_property_blob_put(state->hdr_source_metadata_blob_ptr);
 }
 EXPORT_SYMBOL(__drm_atomic_helper_connector_destroy_state);
 
Signature · 6 lines
1.7.9.5

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

RFC 8/9 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.

---
 drivers/gpu/drm/drm_edid.c |   53 +++++++++++++++++
 drivers/video/hdmi.c       |  138 ++++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h     |    4 ++
 include/linux/hdmi.h       |   21 +++++++
 4 files changed, 216 insertions(+)
drivers/gpu/drm/drm_edid.c +53 -0
index c9b9c3c..3b99284 100644
@@ -4428,6 +4428,59 @@ void drm_set_preferred_mode(struct drm_connector *connector,
 EXPORT_SYMBOL(drm_set_preferred_mode);
 
 /**
+ * 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 -EINVAL;
+
+	err = hdmi_drm_infoframe_init(frame);
+	if (err < 0)
+		return err;
+
+	hdr_source_metadata = (struct hdr_static_metadata *)hdr_metadata;
+
+	frame->length = sizeof(struct hdr_static_metadata);
+
+
+	frame->eotf = hdr_source_metadata->eotf;
+	frame->type = hdr_source_metadata->type;
+
+	for (i = 0; i < 3; i++) {
+		frame->display_primaries_x[i] =
+			hdr_source_metadata->display_primaries_x[i];
+		frame->display_primaries_y[i] =
+			hdr_source_metadata->display_primaries_y[i];
+	}
+
+	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;
+
+	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 +138 -0

168 lines not on this page · raw message

include/drm/drm_edid.h +4 -0
index 7b9f48b..f80c235 100644
@@ -353,6 +353,10 @@ int drm_av_sync_delay(struct drm_connector *connector,
 				   enum hdmi_quantization_range rgb_quant_range,
 				   bool rgb_quant_range_selectable);
 
+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 +21 -0
index d271ff2..a8095e1 100644
@@ -32,6 +32,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
@@ -160,10 +161,29 @@ struct hdmi_avi_infoframe {
 	unsigned short right_bar;
 };
 
+struct hdmi_drm_infoframe {
+	enum hdmi_infoframe_type type;
+	unsigned char version;
+	unsigned char length;
+	uint16_t eotf;
+	uint16_t metadata_type;
+	uint16_t display_primaries_x[3];
+	uint16_t display_primaries_y[3];
+	uint16_t white_point_x;
+	uint16_t white_point_y;
+	uint16_t max_mastering_display_luminance;
+	uint16_t min_mastering_display_luminance;
+	uint16_t max_fall;
+	uint16_t max_cll;
+	uint16_t 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);
 
+int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame);
+
 enum hdmi_spd_sdi {
 	HDMI_SPD_SDI_UNKNOWN,
 	HDMI_SPD_SDI_DSTB,
@@ -328,6 +348,7 @@ ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame,
 	struct hdmi_spd_infoframe spd;
 	union hdmi_vendor_any_infoframe vendor;
 	struct hdmi_audio_infoframe audio;
+	struct hdmi_drm_infoframe drm;
 };
 
 ssize_t
Signature · 6 lines
1.7.9.5

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

RFC 9/9 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.

---
 drivers/gpu/drm/i915/intel_hdmi.c |   25 +++++++++++++++++++++++++
 drivers/video/hdmi.c              |    2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_hdmi.c +25 -0
index d8b53d0..91e0399 100644
@@ -453,6 +453,27 @@ static void intel_write_infoframe(struct drm_encoder *encoder,
 	intel_hdmi->write_infoframe(encoder, crtc_state, frame->any.type, buffer, len);
 }
 
+/* Set Dynamic Range and Mastering Infoframe */
+static void intel_hdmi_set_drm_infoframe(struct drm_encoder *encoder,
+					 const struct intel_crtc_state *crtc_state,
+					 const struct drm_connector_state *conn_state)
+{
+	union hdmi_infoframe frame;
+	struct hdr_static_metadata *hdr_metadata;
+	int ret;
+
+	hdr_metadata = (struct hdr_static_metadata *)
+		conn_state->hdr_source_metadata_blob_ptr->data;
+
+	ret = drm_hdmi_infoframe_set_hdr_metadata(&frame.drm, hdr_metadata);
+	if (ret < 0) {
+		DRM_ERROR("couldn't set HDR metadata in infoframe\n");
+		return;
+	}
+
+	intel_write_infoframe(encoder, crtc_state, &frame);
+}
+
 static void intel_hdmi_set_avi_infoframe(struct drm_encoder *encoder,
 					 const struct intel_crtc_state *crtc_state)
 {
@@ -840,6 +861,10 @@ static void hsw_set_infoframes(struct drm_encoder *encoder,
 	intel_hdmi_set_avi_infoframe(encoder, crtc_state);
 	intel_hdmi_set_spd_infoframe(encoder, crtc_state);
 	intel_hdmi_set_hdmi_infoframe(encoder, crtc_state);
+
+	/* Set Dynamic Range and Mastering Infoframe if supported and changed */
+	if (conn_state->hdr_metadata_changed)
+		intel_hdmi_set_drm_infoframe(encoder, crtc_state, conn_state);
 }
 
 void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable)
drivers/video/hdmi.c +1 -1
index 2740f40..8d06ea2 100644
@@ -421,7 +421,7 @@ int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame)
  * error code on failure.
  */
 ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
-                                size_t size)
+                               size_t size)
 {
 	u8 *ptr = buffer;
 	size_t length;
Signature · 6 lines
1.7.9.5

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

✓ Fi.CI.BAT: success for Add HDR Metadata Parsing and handling in DRM layer

In reply to Uma Shankar
== Series Details ==

== Series Details ==

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

== Summary ==

Series 25091v1 Add HDR Metadata Parsing and handling in DRM layer
https://patchwork.freedesktop.org/api/1.0/series/25091/revisions/1/mbox/

Test gem_exec_flush:

        Subgroup basic-batch-kernel-default-uc:
                fail       -> PASS       (fi-snb-2600) fdo#100007

fdo#100007 https://bugs.freedesktop.org/show_bug.cgi?id=100007

fi-bdw-5557u     total:278  pass:267  dwarn:0   dfail:0   fail:0   skip:11  time:447s
fi-bdw-gvtdvm    total:278  pass:256  dwarn:8   dfail:0   fail:0   skip:14  time:437s
fi-bsw-n3050     total:278  pass:242  dwarn:0   dfail:0   fail:0   skip:36  time:565s
fi-bxt-j4205     total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:19  time:510s
fi-byt-j1900     total:278  pass:254  dwarn:0   dfail:0   fail:0   skip:24  time:483s
fi-byt-n2820     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time:482s
fi-hsw-4770      total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time:430s
fi-hsw-4770r     total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time:406s
fi-ilk-650       total:278  pass:228  dwarn:0   dfail:0   fail:0   skip:50  time:417s
fi-ivb-3520m     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:501s
fi-ivb-3770      total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:464s
fi-kbl-7500u     total:278  pass:255  dwarn:5   dfail:0   fail:0   skip:18  time:469s
fi-kbl-7560u     total:278  pass:263  dwarn:5   dfail:0   fail:0   skip:10  time:568s
fi-skl-6260u     total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:460s
fi-skl-6700hq    total:278  pass:239  dwarn:0   dfail:1   fail:17  skip:21  time:439s
fi-skl-6700k     total:278  pass:256  dwarn:4   dfail:0   fail:0   skip:18  time:463s
fi-skl-6770hq    total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:507s
fi-skl-gvtdvm    total:278  pass:265  dwarn:0   dfail:0   fail:0   skip:13  time:435s
fi-snb-2520m     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time:531s
fi-snb-2600      total:278  pass:249  dwarn:0   dfail:0   fail:0   skip:29  time:407s

4aa1d46d3b24bbe545cdf7cbd407c18f5cd5e43d drm-tip: 2017y-05m-31d-08h-58m-36s UTC integration manifest 80ea7eb drm/i915: Write HDR infoframe and send to panel
bb69a3f drm: Enable HDR infoframe support
1b963db drm: Implement HDR source metadata set and get property handling
911c67e drm: Add HDR capabilty field to plane structure
8e5e780 drm/i915: Attach HDR metadata property to connector
0add68b drm: Parse Colorimetry data block from EDID
c3de98a drm: Parse HDR metadata info from EDID
d3b603b drm: Add CEA extended tag blocks and HDR bitfield macros
64003ce drm: Add HDR source metadata property

== Logs ==

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