summaryrefslogtreecommitdiff
path: root/sound/soc/fsl/imx-sii902x.c
diff options
context:
space:
mode:
authorZidan Wang <zidan.wang@freescale.com>2015-04-10 10:27:37 +0800
committerDong Aisheng <aisheng.dong@nxp.com>2019-11-25 15:49:58 +0800
commite2310573c9f79debefa11aa124789255744f887c (patch)
tree00c755f16f99de459504466990e52b344fa84dbd /sound/soc/fsl/imx-sii902x.c
parentc9f343d9df682121cf76bb25e6dbef21e295eb06 (diff)
MLK-10611-2 ASoC: imx-sii902x: forbid using SAI when SAI is being used by other device
imx7d-sdb board using one SAI for wm8960 and sii902x hdmi audio, wm8960 using SAI as slave mode and sii902x hdmi audio using SAI as master mode, so SAI can't be used at the same time. Forbid palyback(capture) when SAI is being used capture(playback) by other device. Signed-off-by: Zidan Wang <zidan.wang@freescale.com> (cherry picked from commit bac15c28c3b8a57fbe04ea80b8fb5eb47a0211f1)
Diffstat (limited to 'sound/soc/fsl/imx-sii902x.c')
-rw-r--r--sound/soc/fsl/imx-sii902x.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/sound/soc/fsl/imx-sii902x.c b/sound/soc/fsl/imx-sii902x.c
index 61154776b0fc..8dfcf4cfde64 100644
--- a/sound/soc/fsl/imx-sii902x.c
+++ b/sound/soc/fsl/imx-sii902x.c
@@ -22,6 +22,7 @@
#include <sound/pcm_params.h>
#include <sound/soc-dapm.h>
#include <linux/pinctrl/consumer.h>
+#include "fsl_sai.h"
#define SUPPORT_RATE_NUM 10
@@ -29,6 +30,7 @@ struct imx_sii902x_data {
struct snd_soc_dai_link dai;
struct snd_soc_card card;
struct i2c_client *sii902x;
+ bool is_stream_opened[2];
};
static int imx_sii902x_startup(struct snd_pcm_substream *substream)
@@ -36,8 +38,21 @@ static int imx_sii902x_startup(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime;
static struct snd_pcm_hw_constraint_list constraint_rates;
static u32 support_rates[SUPPORT_RATE_NUM];
+ struct snd_soc_pcm_runtime *rtd = substream->private_data;
+ struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+ struct snd_soc_card *card = rtd->card;
+ struct imx_sii902x_data *data = snd_soc_card_get_drvdata(card);
+ struct fsl_sai *sai = dev_get_drvdata(cpu_dai->dev);
+ bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
int ret;
+ data->is_stream_opened[tx] = true;
+ if (data->is_stream_opened[tx] != sai->is_stream_opened[tx] ||
+ data->is_stream_opened[!tx] != sai->is_stream_opened[!tx]) {
+ data->is_stream_opened[tx] = false;
+ return -EBUSY;
+ }
+
support_rates[0] = 32000;
support_rates[1] = 48000;
constraint_rates.list = support_rates;
@@ -136,8 +151,19 @@ static int imx_sii902x_hw_free(struct snd_pcm_substream *substream)
return 0;
}
+static void imx_sii902x_shutdown(struct snd_pcm_substream *substream)
+{
+ struct snd_soc_pcm_runtime *rtd = substream->private_data;
+ struct snd_soc_card *card = rtd->card;
+ struct imx_sii902x_data *data = snd_soc_card_get_drvdata(card);
+ bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
+
+ data->is_stream_opened[tx] = false;
+}
+
static struct snd_soc_ops imx_sii902x_ops = {
.startup = imx_sii902x_startup,
+ .shutdown = imx_sii902x_shutdown,
.hw_params = imx_sii902x_hw_params,
.hw_free = imx_sii902x_hw_free,
};