diff mbox

[RFC,02/11] ASoC: Add dai_ops to set the stream tag.

Message ID 1466999284-14782-3-git-send-email-subhransu.s.prusty@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Subhransu S. Prusty June 27, 2016, 3:47 a.m. UTC
From: Hardik T Shah <hardik.t.shah@intel.com>

Stream tag is unique stream identifier for each HDA stream. It's
programmed in both host and codec to identify link the stream is
transported.  The platform driver allocates the stream and calls
this ops to program the stream tag in the codec dai.

Signed-off-by: Hardik T Shah <hardik.t.shah@intel.com>
Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
 include/sound/soc-dai.h | 12 ++++++++++++
 sound/soc/soc-core.c    | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)

Comments

Mark Brown June 27, 2016, 5:30 p.m. UTC | #1
On Mon, Jun 27, 2016 at 09:17:55AM +0530, Subhransu S. Prusty wrote:

> Stream tag is unique stream identifier for each HDA stream. It's
> programmed in both host and codec to identify link the stream is
> transported.  The platform driver allocates the stream and calls
> this ops to program the stream tag in the codec dai.

This seems incredibly HDMI specific...  what are these tags, can we
represent this as TDM (which seems to be what this is really)?
Subhransu S. Prusty June 28, 2016, 5:21 a.m. UTC | #2
On Mon, Jun 27, 2016 at 06:30:09PM +0100, Mark Brown wrote:
> On Mon, Jun 27, 2016 at 09:17:55AM +0530, Subhransu S. Prusty wrote:
> 
> > Stream tag is unique stream identifier for each HDA stream. It's
> > programmed in both host and codec to identify link the stream is
> > transported.  The platform driver allocates the stream and calls
> > this ops to program the stream tag in the codec dai.
> 
> This seems incredibly HDMI specific...  what are these tags, can we
> represent this as TDM (which seems to be what this is really)?

Hi Mark,

This is HDA specific and the tag is to support use of same DMA channel by
both host and codec.

Regards,
Subhransu
Mark Brown June 28, 2016, 11:15 a.m. UTC | #3
On Tue, Jun 28, 2016 at 10:51:38AM +0530, Subhransu S. Prusty wrote:
> On Mon, Jun 27, 2016 at 06:30:09PM +0100, Mark Brown wrote:

> > This seems incredibly HDMI specific...  what are these tags, can we
> > represent this as TDM (which seems to be what this is really)?

> This is HDA specific and the tag is to support use of same DMA channel by
> both host and codec.

What is a "DMA channel"?
Subhransu S. Prusty June 29, 2016, 4:08 a.m. UTC | #4
On Tue, Jun 28, 2016 at 12:15:20PM +0100, Mark Brown wrote:
> On Tue, Jun 28, 2016 at 10:51:38AM +0530, Subhransu S. Prusty wrote:
> > On Mon, Jun 27, 2016 at 06:30:09PM +0100, Mark Brown wrote:
> 
> > > This seems incredibly HDMI specific...  what are these tags, can we
> > > represent this as TDM (which seems to be what this is really)?
> 
> > This is HDA specific and the tag is to support use of same DMA channel by
> > both host and codec.
> 
> What is a "DMA channel"?

Ok. I agree this looks like TDM and we should model it like that :)

Now, the issue is how? The current TDM API doesn't seem so intutive to
invoke for this case. What do you suggest...

Regards,
Subhransu
Mark Brown June 29, 2016, 6:50 p.m. UTC | #5
On Wed, Jun 29, 2016 at 09:38:11AM +0530, Subhransu S. Prusty wrote:
> On Tue, Jun 28, 2016 at 12:15:20PM +0100, Mark Brown wrote:
> > On Tue, Jun 28, 2016 at 10:51:38AM +0530, Subhransu S. Prusty wrote:

> > > This is HDA specific and the tag is to support use of same DMA channel by
> > > both host and codec.

> > What is a "DMA channel"?

> Ok. I agree this looks like TDM and we should model it like that :)

> Now, the issue is how? The current TDM API doesn't seem so intutive to
> invoke for this case. What do you suggest...

Without knowing what tags and DMA channels are it's hard to make
suggestions...
Subhransu S. Prusty June 30, 2016, 8:59 a.m. UTC | #6
On Wed, Jun 29, 2016 at 07:50:23PM +0100, Mark Brown wrote:
> On Wed, Jun 29, 2016 at 09:38:11AM +0530, Subhransu S. Prusty wrote:
> > On Tue, Jun 28, 2016 at 12:15:20PM +0100, Mark Brown wrote:
> > > On Tue, Jun 28, 2016 at 10:51:38AM +0530, Subhransu S. Prusty wrote:
> 
> > > > This is HDA specific and the tag is to support use of same DMA channel by
> > > > both host and codec.
> 
> > > What is a "DMA channel"?
> 
> > Ok. I agree this looks like TDM and we should model it like that :)
> 
> > Now, the issue is how? The current TDM API doesn't seem so intutive to
> > invoke for this case. What do you suggest...
> 
> Without knowing what tags and DMA channels are it's hard to make
> suggestions...

Hi Mark,

Sure. Let me explain more.

Each DMA channel can be mapped to a stream in HDA. Each stream is mapped
uniquely with a stream tag. The stream is programmed in both host and
codec. In host the DMA is programmed with this stream tag and based on this
DMA picks data from host buffer and puts it onto the link. Similarly the
codec converter is programmed with the same stream tag and codec receives
packet from the link associated with the stream tag.

Regards,
Subhransu
Mark Brown July 5, 2016, 12:54 p.m. UTC | #7
On Thu, Jun 30, 2016 at 02:29:07PM +0530, Subhransu S. Prusty wrote:

> Each DMA channel can be mapped to a stream in HDA. Each stream is mapped
> uniquely with a stream tag. The stream is programmed in both host and
> codec. In host the DMA is programmed with this stream tag and based on this
> DMA picks data from host buffer and puts it onto the link. Similarly the
> codec converter is programmed with the same stream tag and codec receives
> packet from the link associated with the stream tag.

Are these arbatrary tags?  If so why not just pick tags that look like
normal TDM timeslots?
Subhransu S. Prusty July 8, 2016, 5:27 a.m. UTC | #8
On Tue, Jul 05, 2016 at 02:54:03PM +0200, Mark Brown wrote:
> On Thu, Jun 30, 2016 at 02:29:07PM +0530, Subhransu S. Prusty wrote:
> 
> > Each DMA channel can be mapped to a stream in HDA. Each stream is mapped
> > uniquely with a stream tag. The stream is programmed in both host and
> > codec. In host the DMA is programmed with this stream tag and based on this
> > DMA picks data from host buffer and puts it onto the link. Similarly the
> > codec converter is programmed with the same stream tag and codec receives
> > packet from the link associated with the stream tag.
> 
> Are these arbatrary tags?  If so why not just pick tags that look like
> normal TDM timeslots?

If I understand correctly, the tag will be programmed in the tx_mask and
all other arguments will not be used.

Regards,
Subhransu
diff mbox

Patch

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 964b7de..52e52b4 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -140,6 +140,11 @@  int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute,
 
 int snd_soc_dai_is_dummy(struct snd_soc_dai *dai);
 
+
+/* Stream tag programming for codec and cpu dai */
+int snd_soc_dai_program_stream_tag(struct snd_soc_pcm_runtime *rtd,
+						int stream_tag);
+
 struct snd_soc_dai_ops {
 	/*
 	 * DAI clocking configuration, all optional.
@@ -175,6 +180,13 @@  struct snd_soc_dai_ops {
 	int (*mute_stream)(struct snd_soc_dai *dai, int mute, int stream);
 
 	/*
+	 * stream_tag - optional
+	 * Can be used by to program same stream tag for both cpu dai
+	 * and codec dai.
+	 */
+	int (*program_stream_tag)(struct snd_soc_dai *, int);
+
+	/*
 	 * ALSA PCM audio operations - all optional.
 	 * Called by soc-core during audio PCM operations.
 	 */
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index d2e62b15..b096a2f 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2528,6 +2528,41 @@  int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
 EXPORT_SYMBOL_GPL(snd_soc_dai_set_tdm_slot);
 
 /**
+ * snd_soc_dai_program_stream_tag - used to program same stream tag for both
+ *				cpu dai and codec dai.
+ * @rtd: The runtime for which the DAI link format should be changed
+ * @stream_tag: Stream tag to be programmed.
+ *
+ * Returns 0 on success, otherwise a negative error code.
+ */
+int snd_soc_dai_program_stream_tag(struct snd_soc_pcm_runtime *rtd,
+						int stream_tag)
+{
+	int i;
+	const struct snd_soc_dai_ops *codec_dai_ops;
+	struct snd_soc_dai *codec_dai;
+	int ret = 0;
+
+	for (i = 0; i < rtd->num_codecs; i++) {
+		codec_dai = rtd->codec_dais[i];
+		if (!codec_dai->driver)
+			continue;
+
+		codec_dai_ops = codec_dai->driver->ops;
+		if (codec_dai_ops->program_stream_tag) {
+			ret = codec_dai_ops->program_stream_tag(
+					codec_dai, stream_tag);
+			if (ret)
+				return ret;
+		}
+	}
+
+	return ret;
+
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_program_stream_tag);
+
+/**
  * snd_soc_dai_set_channel_map - configure DAI audio channel map
  * @dai: DAI
  * @tx_num: how many TX channels