drm: Add HDMI infoframe helpers
authorThierry Reding <thierry.reding@avionic-design.de>
Wed, 21 Nov 2012 14:31:35 +0000 (15:31 +0100)
committerThierry Reding <thierry.reding@avionic-design.de>
Fri, 22 Feb 2013 07:20:10 +0000 (08:20 +0100)
Add a generic helper to fill in an HDMI AVI infoframe with data
extracted from a DRM display mode.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/Kconfig
drivers/gpu/drm/drm_edid.c
include/drm/drm_edid.h

index f8dae85..1e82882 100644 (file)
@@ -7,6 +7,7 @@
 menuconfig DRM
        tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)"
        depends on (AGP || AGP=n) && !EMULATED_CMPXCHG && MMU
+       select HDMI
        select I2C
        select I2C_ALGOBIT
        select DMA_SHARED_BUFFER
index 6995d2f..c194f4e 100644 (file)
@@ -29,6 +29,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/hdmi.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
 #include <drm/drmP.h>
@@ -2856,3 +2857,35 @@ int drm_add_modes_noedid(struct drm_connector *connector,
        return num_modes;
 }
 EXPORT_SYMBOL(drm_add_modes_noedid);
+
+/**
+ * drm_hdmi_avi_infoframe_from_display_mode() - fill an HDMI AVI infoframe with
+ *                                              data from a DRM display mode
+ * @frame: HDMI AVI infoframe
+ * @mode: DRM display mode
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+int
+drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
+                                        const struct drm_display_mode *mode)
+{
+       int err;
+
+       if (!frame || !mode)
+               return -EINVAL;
+
+       err = hdmi_avi_infoframe_init(frame);
+       if (err < 0)
+               return err;
+
+       frame->video_code = drm_match_cea_mode(mode);
+       if (!frame->video_code)
+               return 0;
+
+       frame->picture_aspect = HDMI_PICTURE_ASPECT_NONE;
+       frame->active_aspect = HDMI_ACTIVE_ASPECT_PICTURE;
+
+       return 0;
+}
+EXPORT_SYMBOL(drm_hdmi_avi_infoframe_from_display_mode);
index 0cac551..5da1b4a 100644 (file)
@@ -247,6 +247,8 @@ struct edid {
 struct drm_encoder;
 struct drm_connector;
 struct drm_display_mode;
+struct hdmi_avi_infoframe;
+
 void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid);
 int drm_av_sync_delay(struct drm_connector *connector,
                      struct drm_display_mode *mode);
@@ -254,4 +256,8 @@ struct drm_connector *drm_select_eld(struct drm_encoder *encoder,
                                     struct drm_display_mode *mode);
 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);
+
 #endif /* __DRM_EDID_H__ */