From: Vinod Koul <vinod.koul@intel.com>
To: alsa-devel@alsa-project.org
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Russell King - ARM Linux <linux@arm.linux.org.uk>,
tiwai@suse.de, Arnaud Pouliquen <arnaud.pouliquen@st.com>,
Jyri Sarha <jsarha@ti.com>,
liam.r.girdwood@linux.intel.com, patches.audio@intel.com,
broonie@kernel.org, Yakir Yang <ykk@rock-chips.com>,
Vinod Koul <vinod.koul@intel.com>,
"Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
Subject: [PATCH v2 5/6] ASoC: hdac_hdmi: Setup and start infoframe
Date: Mon, 26 Oct 2015 10:07:52 +0900 [thread overview]
Message-ID: <1445821673-4947-6-git-send-email-vinod.koul@intel.com> (raw)
In-Reply-To: <1445821673-4947-1-git-send-email-vinod.koul@intel.com>
From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
This patch uses hdmi framework in video to fill audio infoframe.
Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
sound/soc/codecs/hdac_hdmi.c | 60 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index 82a18724bcd0..2ed4d342efd5 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -21,6 +21,7 @@
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
+#include <linux/hdmi.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/hdaudio_ext.h>
@@ -89,6 +90,59 @@ static int hdac_hdmi_setup_stream(struct hdac_ext_device *hdac,
return 0;
}
+static void hdac_hdmi_set_dip_index(struct hdac_ext_device *hdac, hda_nid_t pin_nid,
+ int packet_index, int byte_index)
+{
+ int val;
+
+ val = (packet_index << 5) | (byte_index & 0x1f);
+
+ snd_hdac_codec_write(&hdac->hdac, pin_nid, 0,
+ AC_VERB_SET_HDMI_DIP_INDEX, val);
+}
+
+static int hdac_hdmi_setup_audio_infoframe(struct hdac_ext_device *hdac,
+ hda_nid_t cvt_nid, hda_nid_t pin_nid)
+{
+ uint8_t buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AUDIO_INFOFRAME_SIZE];
+ struct hdmi_audio_infoframe frame;
+ u8 *dip = (u8 *)&frame;
+ int ret;
+ int i;
+
+ hdmi_audio_infoframe_init(&frame);
+
+ /* Default stereo for now */
+ frame.channels = 2;
+
+ /* setup channel count */
+ snd_hdac_codec_write(&hdac->hdac, cvt_nid, 0,
+ AC_VERB_SET_CVT_CHAN_COUNT, frame.channels - 1);
+
+ ret = hdmi_audio_infoframe_pack(&frame, buffer, sizeof(buffer));
+ if (ret < 0)
+ return ret;
+
+ /* stop infoframe transmission */
+ hdac_hdmi_set_dip_index(hdac, pin_nid, 0x0, 0x0);
+ snd_hdac_codec_write(&hdac->hdac, pin_nid, 0,
+ AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_DISABLE);
+
+
+ /* Fill infoframe. Index auto-incremented */
+ hdac_hdmi_set_dip_index(hdac, pin_nid, 0x0, 0x0);
+ for (i = 0; i < sizeof(frame); i++)
+ snd_hdac_codec_write(&hdac->hdac, pin_nid, 0,
+ AC_VERB_SET_HDMI_DIP_DATA, dip[i]);
+
+ /* Start infoframe */
+ hdac_hdmi_set_dip_index(hdac, pin_nid, 0x0, 0x0);
+ snd_hdac_codec_write(&hdac->hdac, pin_nid, 0,
+ AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_BEST);
+
+ return 0;
+}
+
static void hdac_hdmi_set_power_state(struct hdac_ext_device *edev,
struct hdac_hdmi_dai_pin_map *dai_map, unsigned int pwr_state)
{
@@ -110,6 +164,7 @@ static int hdac_hdmi_playback_prepare(struct snd_pcm_substream *substream,
struct hdac_hdmi_priv *hdmi = hdac->private_data;
struct hdac_hdmi_dai_pin_map *dai_map;
struct hdac_ext_dma_params *dd;
+ int ret;
if (dai->id > 0) {
dev_err(&hdac->hdac.dev, "Only one dai supported as of now\n");
@@ -122,6 +177,11 @@ static int hdac_hdmi_playback_prepare(struct snd_pcm_substream *substream,
dev_dbg(&hdac->hdac.dev, "stream tag from cpu dai %d format in cvt 0x%x\n",
dd->stream_tag, dd->format);
+ ret = hdac_hdmi_setup_audio_infoframe(hdac, dai_map->cvt.nid,
+ dai_map->pin.nid);
+ if (ret < 0)
+ return ret;
+
return hdac_hdmi_setup_stream(hdac, dai_map->cvt.nid, dai_map->pin.nid,
dd->stream_tag, dd->format);
}
--
2.4.3
next prev parent reply other threads:[~2015-10-26 1:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-26 1:07 [PATCH v2 0/6] ASoC: Add HDA HDMI codec driver Vinod Koul
2015-10-26 1:07 ` [PATCH v2 1/6] ALSA: hdac: structure definition for ext_dma_params Vinod Koul
2015-10-26 1:07 ` [PATCH v2 2/6] ASoC: hdac-hdmi: Add hdmi driver Vinod Koul
2015-10-26 7:29 ` Takashi Iwai
2015-10-26 8:30 ` Koul, Vinod
2015-10-26 1:07 ` [PATCH v2 3/6] ASoC: hdac_hdmi: Add PM support for HDMI Vinod Koul
2015-10-26 1:07 ` [PATCH v2 4/6] ASoC: hdac_hdmi: Add hdac hdmi dai ops Vinod Koul
2015-10-26 1:07 ` Vinod Koul [this message]
2015-10-26 1:07 ` [PATCH v2 6/6] ASoC: hdac_hdmi: Use i915 component framework for PM Vinod Koul
2015-11-21 14:00 ` Applied "ASoC: hdac_hdmi: Use i915 component framework for PM" to the asoc tree Mark Brown
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=1445821673-4947-6-git-send-email-vinod.koul@intel.com \
--to=vinod.koul@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=arnaud.pouliquen@st.com \
--cc=broonie@kernel.org \
--cc=jsarha@ti.com \
--cc=lars@metafoo.de \
--cc=liam.r.girdwood@linux.intel.com \
--cc=linux@arm.linux.org.uk \
--cc=patches.audio@intel.com \
--cc=subhransu.s.prusty@intel.com \
--cc=tiwai@suse.de \
--cc=ykk@rock-chips.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;
as well as URLs for NNTP newsgroup(s).