All of lore.kernel.org
 help / color / mirror / Atom feed
From: Uma Shankar <uma.shankar@intel.com>
To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: ville.syrjala@intel.com, Liviu.Dudau@arm.com,
	emil.l.velikov@gmail.com, Uma Shankar <uma.shankar@intel.com>,
	maarten.lankhorst@intel.com
Subject: [v6 13/13] video/hdmi: Add const variants for drm infoframe
Date: Wed, 20 Mar 2019 16:18:26 +0530	[thread overview]
Message-ID: <1553078906-5991-14-git-send-email-uma.shankar@intel.com> (raw)
In-Reply-To: <1553078906-5991-1-git-send-email-uma.shankar@intel.com>

Added the const version of infoframe for DRM metadata
for HDR.

Signed-off-by: Uma Shankar <uma.shankar@intel.com>
---
 drivers/video/hdmi.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 include/linux/hdmi.h |  5 +++++
 2 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index 80bb0ee..f9ca555 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -668,6 +668,30 @@ int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame)
 }
 EXPORT_SYMBOL(hdmi_drm_infoframe_init);
 
+static int hdmi_drm_infoframe_check_only(const struct hdmi_drm_infoframe *frame)
+{
+	if (frame->type != HDMI_INFOFRAME_TYPE_DRM ||
+	    frame->version != 1)
+		return -EINVAL;
+
+	return 0;
+}
+
+/**
+ * hdmi_drm_infoframe_check() - check a HDMI DRM infoframe
+ * @frame: HDMI DRM infoframe
+ *
+ * Validates that the infoframe is consistent and updates derived fields
+ * (eg. length) based on other fields.
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+int hdmi_drm_infoframe_check(struct hdmi_drm_infoframe *frame)
+{
+	return hdmi_drm_infoframe_check_only(frame);
+}
+EXPORT_SYMBOL(hdmi_drm_infoframe_check);
+
 /**
  * hdmi_drm_infoframe_pack() - write HDMI DRM infoframe to binary buffer
  * @frame: HDMI DRM infoframe
@@ -682,8 +706,8 @@ int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame)
  * Returns the number of bytes packed into the binary buffer or a negative
  * error code on failure.
  */
-ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
-				size_t size)
+ssize_t hdmi_drm_infoframe_pack_only(const struct hdmi_drm_infoframe *frame,
+				     void *buffer, size_t size)
 {
 	u8 *ptr = buffer;
 	size_t length;
@@ -736,6 +760,37 @@ ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
 
 	return length;
 }
+EXPORT_SYMBOL(hdmi_drm_infoframe_pack_only);
+
+/**
+ * hdmi_drm_infoframe_pack() - check a HDMI DRM infoframe,
+ *                             and write it to binary buffer
+ * @frame: HDMI DRM infoframe
+ * @buffer: destination buffer
+ * @size: size of buffer
+ *
+ * Validates that the infoframe is consistent and updates derived fields
+ * (eg. length) based on other fields, after which it packs the information
+ * contained in the @frame structure into a binary representation that
+ * can be written into the corresponding controller registers. This function
+ * also computes the checksum as required by section 5.3.5 of the HDMI 1.4
+ * specification.
+ *
+ * Returns the number of bytes packed into the binary buffer or a negative
+ * error code on failure.
+ */
+ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame,
+				void *buffer, size_t size)
+{
+	int ret;
+
+	ret = hdmi_drm_infoframe_check(frame);
+	if (ret)
+		return ret;
+
+	return hdmi_drm_infoframe_pack_only(frame, buffer, size);
+}
+EXPORT_SYMBOL(hdmi_drm_infoframe_pack);
 
 /*
  * hdmi_vendor_any_infoframe_check() - check a vendor infoframe
@@ -845,6 +900,10 @@ ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
 		length = hdmi_avi_infoframe_pack_only(&frame->avi,
 						      buffer, size);
 		break;
+	case HDMI_INFOFRAME_TYPE_DRM:
+		length = hdmi_drm_infoframe_pack_only(&frame->drm,
+						      buffer, size);
+		break;
 	case HDMI_INFOFRAME_TYPE_SPD:
 		length = hdmi_spd_infoframe_pack_only(&frame->spd,
 						      buffer, size);
diff --git a/include/linux/hdmi.h b/include/linux/hdmi.h
index 202ed4a..fd8e534 100644
--- a/include/linux/hdmi.h
+++ b/include/linux/hdmi.h
@@ -213,6 +213,11 @@ ssize_t hdmi_avi_infoframe_pack_only(const struct hdmi_avi_infoframe *frame,
 				     void *buffer, size_t size);
 int hdmi_avi_infoframe_check(struct hdmi_avi_infoframe *frame);
 int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame);
+ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer,
+				size_t size);
+ssize_t hdmi_drm_infoframe_pack_only(const struct hdmi_drm_infoframe *frame,
+				     void *buffer, size_t size);
+int hdmi_drm_infoframe_check(struct hdmi_drm_infoframe *frame);
 
 enum hdmi_spd_sdi {
 	HDMI_SPD_SDI_UNKNOWN,
-- 
1.9.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2019-03-20 10:48 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 10:48 [v6 00/13] Add HDR Metadata Parsing and handling in DRM layer Uma Shankar
2019-03-20 10:48 ` [v6 01/13] drm: Add HDR source metadata property Uma Shankar
2019-03-21 11:30   ` Brian Starkey
2019-03-29  6:13     ` Shankar, Uma
2019-03-20 10:48 ` [v6 02/13] drm: Parse HDR metadata info from EDID Uma Shankar
2019-03-29 11:41   ` Sharma, Shashank
2019-03-20 10:48 ` [v6 03/13] drm: Parse Colorimetry data block " Uma Shankar
2019-03-21 11:17   ` Brian Starkey
2019-03-29  6:16     ` Shankar, Uma
2019-03-20 10:48 ` [v6 04/13] drm/i915: Attach HDR metadata property to connector Uma Shankar
2019-03-20 10:48 ` [v6 05/13] drm: Implement HDR output metadata set and get property handling Uma Shankar
2019-03-21 11:46   ` Brian Starkey
2019-03-29  6:21     ` Shankar, Uma
2019-03-20 10:48 ` [v6 06/13] drm: Enable HDR infoframe support Uma Shankar
2019-03-21 11:41   ` Brian Starkey
2019-03-29  6:24     ` Shankar, Uma
2019-03-20 10:48 ` [v6 07/13] drm/i915: Write HDR infoframe and send to panel Uma Shankar
2019-03-29 11:48   ` Sharma, Shashank
2019-03-20 10:48 ` [v6 08/13] drm/i915: [DO NOT MERGE] hack for glk board outputs Uma Shankar
2019-03-20 10:48 ` [v6 09/13] drm/i915: Add HLG EOTF Uma Shankar
2019-03-20 10:48 ` [v6 10/13] drm/i915: Enable infoframes on GLK+ for HDR Uma Shankar
2019-03-29 12:31   ` Sharma, Shashank
2019-03-20 10:48 ` [v6 11/13] drm/i915:Enabled Modeset when HDR Infoframe changes Uma Shankar
2019-03-29 12:56   ` Sharma, Shashank
2019-03-20 10:48 ` [v6 12/13] drm/i915: Set Infoframe for non modeset case for HDR Uma Shankar
2019-03-29 12:14   ` Sharma, Shashank
2019-03-29 14:04   ` Ville Syrjälä
2019-04-02 16:27     ` Shankar, Uma
2019-03-20 10:48 ` Uma Shankar [this message]
2019-03-21 12:00   ` [v6 13/13] video/hdmi: Add const variants for drm infoframe Brian Starkey
2019-03-29  6:29     ` Shankar, Uma
2019-03-29 12:22   ` Sharma, Shashank
2019-03-20 13:32 ` ✗ Fi.CI.CHECKPATCH: warning for Add HDR Metadata Parsing and handling in DRM layer (rev6) Patchwork
2019-03-20 14:01 ` ✗ Fi.CI.BAT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1553078906-5991-14-git-send-email-uma.shankar@intel.com \
    --to=uma.shankar@intel.com \
    --cc=Liviu.Dudau@arm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.l.velikov@gmail.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=maarten.lankhorst@intel.com \
    --cc=ville.syrjala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.