diff mbox

[RFC,9/9] drm/i915: Write HDR infoframe and send to panel

Message ID 1496225457-30514-10-git-send-email-uma.shankar@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shankar, Uma May 31, 2017, 10:10 a.m. UTC
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.

Signed-off-by: Uma Shankar <uma.shankar@intel.com>
---
 drivers/gpu/drm/i915/intel_hdmi.c |   25 +++++++++++++++++++++++++
 drivers/video/hdmi.c              |    2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index d8b53d0..91e0399 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -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)
diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index 2740f40..8d06ea2 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -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;