[Intel-gfx] [PATCH v2 3/6] video/hdmi: Separate function for unpacking AVI Infoframe Data

Ankit Nautiyal ankit.k.nautiyal at intel.com
Fri Aug 13 07:01:18 UTC 2021


Currently while unpacking the AVI Infoframe, the Infoframe Headers
and data are checked in same unpack function.

This patch separates the unpacking of AVI infoframe Data only,
so that it can be used for the DP cases, where the AVI Infoframe is
encapsulated in DP SDP packets. In such a case we need to only
unpack the data bytes as the header bits for DP SDP will be different.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal at intel.com>
---
 drivers/video/hdmi.c | 65 ++++++++++++++++++++++++++++++++------------
 include/linux/hdmi.h |  2 ++
 2 files changed, 49 insertions(+), 18 deletions(-)

diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index 947be761dfa4..f8e325cccfee 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -1537,38 +1537,30 @@ void hdmi_infoframe_log(const char *level,
 EXPORT_SYMBOL(hdmi_infoframe_log);
 
 /**
- * hdmi_avi_infoframe_unpack() - unpack binary buffer to a HDMI AVI infoframe
+ * hdmi_avi_infoframe_unpack_only() - unpack binary buffer of CTA-861-G AVI
+ *                                    infoframe DataBytes to a HDMI AVI
+ *                                    infoframe
  * @frame: HDMI AVI infoframe
  * @buffer: source buffer
  * @size: size of buffer
  *
- * Unpacks the information contained in binary @buffer into a structured
- * @frame of the HDMI Auxiliary Video (AVI) information frame.
- * Also verifies the checksum as required by section 5.3.5 of the HDMI 1.4
- * specification.
+ * Unpacks CTA-861-G AVI infoframe DataBytes contained in the binary @buffer
+ * into a structured @frame of the HDMI Auxiliary Video Information (AVI)
+ * infoframe.
  *
  * Returns 0 on success or a negative error code on failure.
  */
-static int hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame,
-				     const void *buffer, size_t size)
+
+int hdmi_avi_infoframe_unpack_only(struct hdmi_avi_infoframe *frame,
+				   const void *buffer, size_t size)
 {
 	const u8 *ptr = buffer;
 
-	if (size < HDMI_INFOFRAME_SIZE(AVI))
-		return -EINVAL;
-
-	if (ptr[0] != HDMI_INFOFRAME_TYPE_AVI ||
-	    ptr[1] != 2 ||
-	    ptr[2] != HDMI_AVI_INFOFRAME_SIZE)
-		return -EINVAL;
-
-	if (hdmi_infoframe_checksum(buffer, HDMI_INFOFRAME_SIZE(AVI)) != 0)
+	if (size < HDMI_AVI_INFOFRAME_SIZE)
 		return -EINVAL;
 
 	hdmi_avi_infoframe_init(frame);
 
-	ptr += HDMI_INFOFRAME_HEADER_SIZE;
-
 	frame->colorspace = (ptr[0] >> 5) & 0x3;
 	if (ptr[0] & 0x10)
 		frame->active_aspect = ptr[1] & 0xf;
@@ -1599,6 +1591,43 @@ static int hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame,
 
 	return 0;
 }
+EXPORT_SYMBOL(hdmi_avi_infoframe_unpack_only);
+
+/**
+ * hdmi_avi_infoframe_unpack() - unpack binary buffer to a HDMI AVI infoframe
+ * @frame: HDMI AVI infoframe
+ * @buffer: source buffer
+ * @size: size of buffer
+ *
+ * Unpacks the information contained in binary @buffer into a structured
+ * @frame of the HDMI Auxiliary Video (AVI) information frame.
+ * Also verifies the checksum as required by section 5.3.5 of the HDMI 1.4
+ * specification.
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+static int hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame,
+				     const void *buffer, size_t size)
+{
+	const u8 *ptr = buffer;
+	int ret;
+
+	if (size < HDMI_INFOFRAME_SIZE(AVI))
+		return -EINVAL;
+
+	if (ptr[0] != HDMI_INFOFRAME_TYPE_AVI ||
+	    ptr[1] != 2 ||
+	    ptr[2] != HDMI_AVI_INFOFRAME_SIZE)
+		return -EINVAL;
+
+	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);
+
+	return ret;
+}
 
 /**
  * hdmi_spd_infoframe_unpack() - unpack binary buffer to a HDMI SPD infoframe
diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h
index c8ec982ff498..dda209fb77e3 100644
--- a/include/linux/hdmi.h
+++ b/include/linux/hdmi.h
@@ -222,6 +222,8 @@ ssize_t hdmi_drm_infoframe_pack_only(const struct hdmi_drm_infoframe *frame,
 int hdmi_drm_infoframe_check(struct hdmi_drm_infoframe *frame);
 int hdmi_drm_infoframe_unpack_only(struct hdmi_drm_infoframe *frame,
 				   const void *buffer, size_t size);
+int hdmi_avi_infoframe_unpack_only(struct hdmi_avi_infoframe *frame,
+				   const void *buffer, size_t size);
 
 enum hdmi_spd_sdi {
 	HDMI_SPD_SDI_UNKNOWN,
-- 
2.25.1



More information about the Intel-gfx mailing list