[PATCH v3 8/8] video/hdmi: Modify AVI Infoframe pack/unpack helpers for AVI ver 4

Ankit Nautiyal ankit.k.nautiyal at intel.com
Mon Aug 30 12:26:32 UTC 2021


AVI version 4, as defined by CTA-861-G adds new byte DB14 to store
the Additional Colorimetry Extension. This requires change in
AVI version during packing and unpacking, along with the AVI infoframe
length. This patch modifies the pack and unpack function to support
AVI infoframe version 4.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal at intel.com>
---
 drivers/video/hdmi.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index d32c7588cc0b..7c16200cd956 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -61,6 +61,11 @@ hdmi_avi_infoframe_set_version(struct hdmi_avi_infoframe *frame)
 	if (frame->video_code > 127 ||
 	    frame->colorspace == HDMI_COLORSPACE_IDO_DEFINED)
 		frame->version = 3;
+
+	if (frame->extended_colorimetry == HDMI_EXTENDED_COLORIMETRY_RESERVED) {
+		frame->version = 4;
+		frame->length = HDMI_AVI_V4_INFOFRAME_SIZE;
+	}
 }
 EXPORT_SYMBOL(hdmi_avi_infoframe_set_version);
 
@@ -80,8 +85,11 @@ EXPORT_SYMBOL(hdmi_avi_infoframe_init);
 
 static int hdmi_avi_infoframe_check_only(const struct hdmi_avi_infoframe *frame)
 {
-	if (frame->type != HDMI_INFOFRAME_TYPE_AVI ||
-	    frame->length != HDMI_AVI_INFOFRAME_SIZE)
+	if (frame->type != HDMI_INFOFRAME_TYPE_AVI)
+		return -EINVAL;
+	if (frame->version == 4 && frame->length != HDMI_AVI_V4_INFOFRAME_SIZE)
+		return -EINVAL;
+	if (frame->version < 4 && frame->length != HDMI_AVI_INFOFRAME_SIZE)
 		return -EINVAL;
 
 	if (frame->video_code > 127 ||
@@ -1601,6 +1609,10 @@ int hdmi_avi_infoframe_unpack_only(struct hdmi_avi_infoframe *frame,
 
 	frame->itc = ptr[2] & 0x80 ? true : false;
 	frame->extended_colorimetry = (ptr[2] >> 4) & 0x7;
+
+	if (size == HDMI_AVI_V4_INFOFRAME_SIZE &&
+	    frame->extended_colorimetry == HDMI_EXTENDED_COLORIMETRY_RESERVED)
+		frame->ace_colorimetry = ptr[13] >> 4;
 	frame->quantization_range = (ptr[2] >> 2) & 0x3;
 	frame->nups = ptr[2] & 0x3;
 
@@ -1639,13 +1651,18 @@ static int hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame,
 		return -EINVAL;
 
 	if (ptr[0] != HDMI_INFOFRAME_TYPE_AVI ||
-	    ptr[1] > 3 ||
+	    ptr[1] > 4 ||
 	    ptr[1] < 2 ||
-	    ptr[2] != HDMI_AVI_INFOFRAME_SIZE)
+	    ptr[2] > HDMI_AVI_V4_INFOFRAME_SIZE ||
+	    ptr[2] < HDMI_AVI_INFOFRAME_SIZE)
 		return -EINVAL;
 
-	if (hdmi_infoframe_checksum(buffer, HDMI_INFOFRAME_SIZE(AVI)) != 0)
+	if (ptr[2] == HDMI_AVI_V4_INFOFRAME_SIZE) {
+		if (hdmi_infoframe_checksum(buffer, HDMI_INFOFRAME_SIZE(AVI_V4)) != 0)
+			return -EINVAL;
+	} else if (hdmi_infoframe_checksum(buffer, HDMI_INFOFRAME_SIZE(AVI)) != 0) {
 		return -EINVAL;
+	}
 
 	ret = hdmi_avi_infoframe_unpack_only(frame, ptr + HDMI_INFOFRAME_HEADER_SIZE,
 					     size - HDMI_INFOFRAME_HEADER_SIZE);
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list