From ad0f889656441120d85f012ae9e2a90d799315b3 Mon Sep 17 00:00:00 2001
From: Laurentiu Palcu <laurentiu.palcu@nxp.com>
Date: Fri, 22 Feb 2019 12:41:19 +0200
Subject: [PATCH] MMFMWK-8413: video/hdmi: Fix DRM info-frame packing

The hdmi_drm_infoframe_pack() was wrongly packing the HDR metadata. It
was setting the x display primaries followed by the y display primaries.
Instead, in the specifications, each x display primary should be
followed by the corresponding y display primary.

Also, byte 8 of the frame payload was being skipped. Fixed that too.

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@nxp.com>
Reported-by: Jared Hu <jared.hu@nxp.com>
---
 drivers/video/hdmi.c | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index 28b1e325536fa7..78c425fd7cab7d 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -452,38 +452,38 @@ ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
 	ptr[2] = frame->display_primaries_x[0] & 0xff;
 	ptr[3] = frame->display_primaries_x[0] >> 8;
 
-	ptr[4] = frame->display_primaries_x[1] & 0xff;
-	ptr[5] = frame->display_primaries_x[1] >> 8;
+	ptr[4] = frame->display_primaries_y[0] & 0xff;
+	ptr[5] = frame->display_primaries_y[0] >> 8;
 
-	ptr[6] = frame->display_primaries_x[2] & 0xff;
-	ptr[7] = frame->display_primaries_x[2] >> 8;
+	ptr[6] = frame->display_primaries_x[1] & 0xff;
+	ptr[7] = frame->display_primaries_x[1] >> 8;
 
-	ptr[9] = frame->display_primaries_y[0] & 0xff;
-	ptr[10] = frame->display_primaries_y[0] >> 8;
+	ptr[8] = frame->display_primaries_y[1] & 0xff;
+	ptr[9] = frame->display_primaries_y[1] >> 8;
 
-	ptr[11] = frame->display_primaries_y[1] & 0xff;
-	ptr[12] = frame->display_primaries_y[1] >> 8;
+	ptr[10] = frame->display_primaries_x[2] & 0xff;
+	ptr[11] = frame->display_primaries_x[2] >> 8;
 
-	ptr[13] = frame->display_primaries_y[2] & 0xff;
-	ptr[14] = frame->display_primaries_y[2] >> 8;
+	ptr[12] = frame->display_primaries_y[2] & 0xff;
+	ptr[13] = frame->display_primaries_y[2] >> 8;
 
-	ptr[15] = frame->white_point_x & 0xff;
-	ptr[16] = frame->white_point_x >> 8;
+	ptr[14] = frame->white_point_x & 0xff;
+	ptr[15] = frame->white_point_x >> 8;
 
-	ptr[17] = frame->white_point_y & 0xff;
-	ptr[18] = frame->white_point_y >> 8;
+	ptr[16] = frame->white_point_y & 0xff;
+	ptr[17] = frame->white_point_y >> 8;
 
-	ptr[19] = frame->max_mastering_display_luminance & 0xff;
-	ptr[20] = frame->max_mastering_display_luminance >> 8;
+	ptr[18] = frame->max_mastering_display_luminance & 0xff;
+	ptr[19] = frame->max_mastering_display_luminance >> 8;
 
-	ptr[21] = frame->min_mastering_display_luminance & 0xff;
-	ptr[22] = frame->min_mastering_display_luminance >> 8;
+	ptr[20] = frame->min_mastering_display_luminance & 0xff;
+	ptr[21] = frame->min_mastering_display_luminance >> 8;
 
-	ptr[23] = frame->max_cll & 0xff;
-	ptr[24] = frame->max_cll >> 8;
+	ptr[22] = frame->max_cll & 0xff;
+	ptr[23] = frame->max_cll >> 8;
 
-	ptr[25] = frame->max_fall & 0xff;
-	ptr[26] = frame->max_fall >> 8;
+	ptr[24] = frame->max_fall & 0xff;
+	ptr[25] = frame->max_fall >> 8;
 
 	hdmi_infoframe_set_checksum(buffer, length);
 
-- 
GitLab