]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
drm: Add a helper to forge HDMI vendor infoframes
authorLespiau, Damien <damien.lespiau@intel.com>
Mon, 19 Aug 2013 15:59:03 +0000 (16:59 +0100)
committerDave Airlie <airlied@gmail.com>
Thu, 29 Aug 2013 22:41:49 +0000 (08:41 +1000)
This can then be used by DRM drivers to setup their vendor infoframes.

v2: Fix hmdi typo (Simon Farnsworth)
v3: Adapt to the hdmi_vendor_infoframe rename

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Reviewed-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
drivers/gpu/drm/drm_edid.c
include/drm/drm_edid.h

index 3aa653fd03a7ccc61d33eebb5c7866bb34192b5f..ed3505fe8ace10644efa4eea990597a0a76b92d4 100644 (file)
@@ -3263,3 +3263,39 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
        return 0;
 }
 EXPORT_SYMBOL(drm_hdmi_avi_infoframe_from_display_mode);
+
+/**
+ * drm_hdmi_vendor_infoframe_from_display_mode() - fill an HDMI infoframe with
+ * data from a DRM display mode
+ * @frame: HDMI vendor infoframe
+ * @mode: DRM display mode
+ *
+ * Note that there's is a need to send HDMI vendor infoframes only when using a
+ * 4k or stereoscopic 3D mode. So when giving any other mode as input this
+ * function will return -EINVAL, error that can be safely ignored.
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+int
+drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
+                                           const struct drm_display_mode *mode)
+{
+       int err;
+       u8 vic;
+
+       if (!frame || !mode)
+               return -EINVAL;
+
+       vic = drm_match_hdmi_mode(mode);
+       if (!vic)
+               return -EINVAL;
+
+       err = hdmi_vendor_infoframe_init(frame);
+       if (err < 0)
+               return err;
+
+       frame->vic = vic;
+
+       return 0;
+}
+EXPORT_SYMBOL(drm_hdmi_vendor_infoframe_from_display_mode);
index fc481fc170855e47a0ff9c858845077990b56f03..7b75621fda4c905b1bc5e666689bacb5bb97c02b 100644 (file)
@@ -256,6 +256,7 @@ struct drm_encoder;
 struct drm_connector;
 struct drm_display_mode;
 struct hdmi_avi_infoframe;
+struct hdmi_vendor_infoframe;
 
 void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid);
 int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads);
@@ -268,5 +269,8 @@ int drm_load_edid_firmware(struct drm_connector *connector);
 int
 drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
                                         const struct drm_display_mode *mode);
+int
+drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
+                                           const struct drm_display_mode *mode);
 
 #endif /* __DRM_EDID_H__ */