clear-pkgs-linux-iot-lts2018/0175-ASoC-Add-dai_ops-to-se...

127 lines
4.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Hardik T Shah <hardik.t.shah@intel.com>
Date: Thu, 10 Mar 2016 10:16:10 +0530
Subject: [PATCH] ASoC: Add dai_ops to set the stream tag.
Stream tag is introduced for supporting SoundWire links
as part of ASoC. stream tag is unique stream identifier
for each stream. Same stream tag is assigned to all the
CPU and codec DAIs part of same stream tag. This function
provides dai ops to be called to let the DAI know its
stream tag. Normally stream tag is allocated by CPU
DAI and get programmed to codec dai. This function
calls all the codec DAI ops to program the stream tag
allocated by CPU DAI.
Change-Id: I9a74dc1329c21b34aaf7f096c68f932b537653f2
Signed-off-by: Hardik T Shah <hardik.t.shah@intel.com>
---
include/sound/soc-dai.h | 17 +++++++++++++
sound/soc/soc-core.c | 55 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+)
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index f5d70041108f..c393f1126839 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -145,6 +145,13 @@ int snd_soc_dai_get_channel_map(struct snd_soc_dai *dai,
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_pcm_substream *substream,
+ struct snd_soc_dai *cpu_dai, int stream_tag);
+void snd_soc_dai_remove_stream_tag(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *cpu_dai);
+
struct snd_soc_dai_ops {
/*
* DAI clocking configuration, all optional.
@@ -184,6 +191,16 @@ struct snd_soc_dai_ops {
int (*digital_mute)(struct snd_soc_dai *dai, int mute);
int (*mute_stream)(struct snd_soc_dai *dai, int mute, int stream);
+ /*
+ * stream_tag - Optional
+ * Used by SoundWire and HDA driver to set same stream
+ * tag for both CPU and Codec DAI
+ */
+ int (*program_stream_tag)(struct snd_pcm_substream *,
+ struct snd_soc_dai *, int);
+ int (*remove_stream_tag)(struct snd_pcm_substream *,
+ struct snd_soc_dai *);
+
/*
* 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 595fe20bbc6d..39056ff80dc9 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2626,6 +2626,61 @@ 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 - Program the stream tag allocated by
+ * CPU DAI to codec DAI. This will be
+ * used in HDA and soundwire, wherex
+ * audio stream between codec and
+ * SoC need to have same stream tag.
+ * substream: Substream
+ * cpu_dai: CPU DAI
+ * stream_tag: Stream tag to be programmed.
+ */
+int snd_soc_dai_program_stream_tag(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *cpu_dai, int stream_tag)
+{
+ int i;
+ struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
+ 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];
+ codec_dai_ops = codec_dai->driver->ops;
+ if (codec_dai_ops->program_stream_tag) {
+ ret = codec_dai_ops->program_stream_tag(substream,
+ codec_dai, stream_tag);
+ if (ret)
+ return ret;
+ }
+ }
+ return ret;
+
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_program_stream_tag);
+/**
+ * snd_soc_dai_remove_stream_tag - Reverse the programmed stream tag
+ * substream: Substream
+ * cpu_dai: CPU DAI
+ */
+void snd_soc_dai_remove_stream_tag(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *cpu_dai)
+{
+ int i;
+ struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
+ const struct snd_soc_dai_ops *codec_dai_ops;
+ struct snd_soc_dai *codec_dai;
+
+ for (i = 0; i < rtd->num_codecs; i++) {
+ codec_dai = rtd->codec_dais[i];
+ codec_dai_ops = codec_dai->driver->ops;
+ if (codec_dai_ops->program_stream_tag)
+ codec_dai_ops->remove_stream_tag(substream, codec_dai);
+ }
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_remove_stream_tag);
+
/**
* snd_soc_dai_set_channel_map - configure DAI audio channel map
* @dai: DAI
--
https://clearlinux.org