dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@avionic-design.de>
To: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org, Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: [PATCH v4 5/9] drm: Add HDMI infoframe helpers
Date: Thu, 21 Feb 2013 15:50:14 +0100	[thread overview]
Message-ID: <1361458218-14464-6-git-send-email-thierry.reding@avionic-design.de> (raw)
In-Reply-To: <1361458218-14464-1-git-send-email-thierry.reding@avionic-design.de>

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>
---
Changes in v2:
- reuse CEA modes defined in drm_edid_modes.h
- don't use pixel aspect ratio for picture aspect

Changes in v3:
- move implementation into drm_edid.[ch]

Changes in v4:
- none

 drivers/gpu/drm/Kconfig    |  1 +
 drivers/gpu/drm/drm_edid.c | 33 +++++++++++++++++++++++++++++++++
 include/drm/drm_edid.h     |  6 ++++++
 3 files changed, 40 insertions(+)

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index f8dae85..1e82882 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -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
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 6995d2f..c194f4e 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -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);
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index 0cac551..5da1b4a 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -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__ */
-- 
1.8.1.2

  parent reply	other threads:[~2013-02-21 14:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-21 14:50 [PATCH v4 0/9] Add HDMI infoframe helpers Thierry Reding
2013-02-21 14:50 ` [PATCH v4 1/9] drm: Remove duplicate drm_mode_cea_vic() Thierry Reding
2013-02-21 15:04   ` Ville Syrjälä
2013-02-21 15:13     ` Thierry Reding
2013-02-21 14:50 ` [PATCH v4 2/9] drm: Move mode tables to drm_edid.c Thierry Reding
2013-02-21 14:50 ` [PATCH v4 3/9] drm: Add some missing forward declarations Thierry Reding
2013-02-21 14:50 ` [PATCH v4 4/9] video: Add generic HDMI infoframe helpers Thierry Reding
2013-02-21 14:50 ` Thierry Reding [this message]
2013-02-21 14:50 ` [PATCH v4 6/9] drm: Add EDID helper documentation Thierry Reding
2013-02-21 14:50 ` [PATCH v4 7/9] drm/tegra: Use generic HDMI infoframe helpers Thierry Reding
2013-02-21 14:50 ` [PATCH v4 8/9] drm/i915: " Thierry Reding
2013-02-21 14:50 ` [PATCH v4 9/9] drm/radeon: " Thierry Reding
2013-02-21 17:38 ` [PATCH v4 0/9] Add " Alex Deucher

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=1361458218-14464-6-git-send-email-thierry.reding@avionic-design.de \
    --to=thierry.reding@avionic-design.de \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=paulo.r.zanoni@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox