summaryrefslogtreecommitdiff
path: root/sound/soc/soc-dai.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-dai.c')
-rw-r--r--sound/soc/soc-dai.c119
1 files changed, 36 insertions, 83 deletions
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 6f8773a8fc05..ca0308f6d41c 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -11,7 +11,7 @@
#include <sound/soc-link.h>
#define soc_dai_ret(dai, ret) _soc_dai_ret(dai, __func__, ret)
-static inline int _soc_dai_ret(struct snd_soc_dai *dai,
+static inline int _soc_dai_ret(const struct snd_soc_dai *dai,
const char *func, int ret)
{
/* Positive, Zero values are not errors */
@@ -37,7 +37,7 @@ static inline int _soc_dai_ret(struct snd_soc_dai *dai,
* In such case, we can update these macros.
*/
#define soc_dai_mark_push(dai, substream, tgt) ((dai)->mark_##tgt = substream)
-#define soc_dai_mark_pop(dai, substream, tgt) ((dai)->mark_##tgt = NULL)
+#define soc_dai_mark_pop(dai, tgt) ((dai)->mark_##tgt = NULL)
#define soc_dai_mark_match(dai, substream, tgt) ((dai)->mark_##tgt == substream)
/**
@@ -45,7 +45,7 @@ static inline int _soc_dai_ret(struct snd_soc_dai *dai,
* @dai: DAI
* @clk_id: DAI specific clock ID
* @freq: new clock frequency in Hz
- * @dir: new clock direction - input/output.
+ * @dir: new clock direction (SND_SOC_CLOCK_IN or SND_SOC_CLOCK_OUT)
*
* Configures the DAI master (MCLK) or system (SYSCLK) clocking.
*/
@@ -134,7 +134,7 @@ int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
}
EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_ratio);
-int snd_soc_dai_get_fmt_max_priority(struct snd_soc_pcm_runtime *rtd)
+int snd_soc_dai_get_fmt_max_priority(const struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_dai *dai;
int i, max = 0;
@@ -166,7 +166,7 @@ int snd_soc_dai_get_fmt_max_priority(struct snd_soc_pcm_runtime *rtd)
* modes. This will mean that sometimes fewer formats
* are reported here than are supported by set_fmt().
*/
-u64 snd_soc_dai_get_fmt(struct snd_soc_dai *dai, int priority)
+u64 snd_soc_dai_get_fmt(const struct snd_soc_dai *dai, int priority)
{
const struct snd_soc_dai_ops *ops = dai->driver->ops;
u64 fmt = 0;
@@ -304,8 +304,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_tdm_slot);
* configure the relationship between channel number and TDM slot number.
*/
int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai,
- unsigned int tx_num, unsigned int *tx_slot,
- unsigned int rx_num, unsigned int *rx_slot)
+ unsigned int tx_num, const unsigned int *tx_slot,
+ unsigned int rx_num, const unsigned int *rx_slot)
{
int ret = -ENOTSUPP;
@@ -327,7 +327,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_channel_map);
* @rx_slot: pointer to an array which imply the RX slot number channel
* 0~num-1 uses
*/
-int snd_soc_dai_get_channel_map(struct snd_soc_dai *dai,
+int snd_soc_dai_get_channel_map(const struct snd_soc_dai *dai,
unsigned int *tx_num, unsigned int *tx_slot,
unsigned int *rx_num, unsigned int *rx_slot)
{
@@ -360,6 +360,22 @@ int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate)
}
EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate);
+int snd_soc_dai_prepare(struct snd_soc_dai *dai,
+ struct snd_pcm_substream *substream)
+{
+ int ret = 0;
+
+ if (!snd_soc_dai_stream_valid(dai, substream->stream))
+ return 0;
+
+ if (dai->driver->ops &&
+ dai->driver->ops->prepare)
+ ret = dai->driver->ops->prepare(substream, dai);
+
+ return soc_dai_ret(dai, ret);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_prepare);
+
/**
* snd_soc_dai_digital_mute - configure DAI system or master clock.
* @dai: DAI
@@ -416,7 +432,7 @@ void snd_soc_dai_hw_free(struct snd_soc_dai *dai,
dai->driver->ops->hw_free(substream, dai);
/* remove marked substream */
- soc_dai_mark_pop(dai, substream, hw_params);
+ soc_dai_mark_pop(dai, hw_params);
}
int snd_soc_dai_startup(struct snd_soc_dai *dai,
@@ -453,16 +469,16 @@ void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
dai->driver->ops->shutdown(substream, dai);
/* remove marked substream */
- soc_dai_mark_pop(dai, substream, startup);
+ soc_dai_mark_pop(dai, startup);
}
int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
- struct snd_soc_pcm_runtime *rtd, int num)
+ struct snd_soc_pcm_runtime *rtd)
{
int ret = -ENOTSUPP;
if (dai->driver->ops &&
dai->driver->ops->compress_new)
- ret = dai->driver->ops->compress_new(rtd, num);
+ ret = dai->driver->ops->compress_new(rtd);
return soc_dai_ret(dai, ret);
}
@@ -471,52 +487,14 @@ int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
*
* Returns true if the DAI supports the indicated stream type.
*/
-bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int dir)
+bool snd_soc_dai_stream_valid(const struct snd_soc_dai *dai, int dir)
{
- struct snd_soc_pcm_stream *stream = snd_soc_dai_get_pcm_stream(dai, dir);
+ const struct snd_soc_pcm_stream *stream = snd_soc_dai_get_pcm_stream(dai, dir);
/* If the codec specifies any channels at all, it supports the stream */
return stream->channels_min;
}
-/*
- * snd_soc_dai_link_set_capabilities() - set dai_link properties based on its DAIs
- */
-void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link)
-{
- bool supported[SNDRV_PCM_STREAM_LAST + 1];
- int direction;
-
- for_each_pcm_streams(direction) {
- struct snd_soc_dai_link_component *cpu;
- struct snd_soc_dai_link_component *codec;
- struct snd_soc_dai *dai;
- bool supported_cpu = false;
- bool supported_codec = false;
- int i;
-
- for_each_link_cpus(dai_link, i, cpu) {
- dai = snd_soc_find_dai_with_mutex(cpu);
- if (dai && snd_soc_dai_stream_valid(dai, direction)) {
- supported_cpu = true;
- break;
- }
- }
- for_each_link_codecs(dai_link, i, codec) {
- dai = snd_soc_find_dai_with_mutex(codec);
- if (dai && snd_soc_dai_stream_valid(dai, direction)) {
- supported_codec = true;
- break;
- }
- }
- supported[direction] = supported_cpu && supported_codec;
- }
-
- dai_link->dpcm_playback = supported[SNDRV_PCM_STREAM_PLAYBACK];
- dai_link->dpcm_capture = supported[SNDRV_PCM_STREAM_CAPTURE];
-}
-EXPORT_SYMBOL_GPL(snd_soc_dai_link_set_capabilities);
-
void snd_soc_dai_action(struct snd_soc_dai *dai,
int stream, int action)
{
@@ -528,7 +506,7 @@ void snd_soc_dai_action(struct snd_soc_dai *dai,
}
EXPORT_SYMBOL_GPL(snd_soc_dai_action);
-int snd_soc_dai_active(struct snd_soc_dai *dai)
+int snd_soc_dai_active(const struct snd_soc_dai *dai)
{
int stream, active;
@@ -615,14 +593,9 @@ int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream)
int i, ret;
for_each_rtd_dais(rtd, i, dai) {
- if (!snd_soc_dai_stream_valid(dai, substream->stream))
- continue;
- if (dai->driver->ops &&
- dai->driver->ops->prepare) {
- ret = dai->driver->ops->prepare(substream, dai);
- if (ret < 0)
- return soc_dai_ret(dai, ret);
- }
+ ret = snd_soc_dai_prepare(dai, substream);
+ if (ret < 0)
+ return ret;
}
return 0;
@@ -678,33 +651,13 @@ int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream,
r = soc_dai_trigger(dai, substream, cmd);
if (r < 0)
ret = r; /* use last ret */
- soc_dai_mark_pop(dai, substream, trigger);
+ soc_dai_mark_pop(dai, trigger);
}
}
return ret;
}
-int snd_soc_pcm_dai_bespoke_trigger(struct snd_pcm_substream *substream,
- int cmd)
-{
- struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
- struct snd_soc_dai *dai;
- int i, ret;
-
- for_each_rtd_dais(rtd, i, dai) {
- if (dai->driver->ops &&
- dai->driver->ops->bespoke_trigger) {
- ret = dai->driver->ops->bespoke_trigger(substream,
- cmd, dai);
- if (ret < 0)
- return soc_dai_ret(dai, ret);
- }
- }
-
- return 0;
-}
-
void snd_soc_pcm_dai_delay(struct snd_pcm_substream *substream,
snd_pcm_sframes_t *cpu_delay,
snd_pcm_sframes_t *codec_delay)
@@ -762,7 +715,7 @@ void snd_soc_dai_compr_shutdown(struct snd_soc_dai *dai,
dai->driver->cops->shutdown(cstream, dai);
/* remove marked cstream */
- soc_dai_mark_pop(dai, cstream, compr_startup);
+ soc_dai_mark_pop(dai, compr_startup);
}
EXPORT_SYMBOL_GPL(snd_soc_dai_compr_shutdown);