From b3eefcc520b4e154e7f93aac5769947dace9c804 Mon Sep 17 00:00:00 2001 From: Zidan Wang Date: Fri, 10 Apr 2015 10:27:37 +0800 Subject: 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 --- sound/soc/fsl/imx-sii902x.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'sound') diff --git a/sound/soc/fsl/imx-sii902x.c b/sound/soc/fsl/imx-sii902x.c index 61154776b0fc..5f283385bfd1 100644 --- a/sound/soc/fsl/imx-sii902x.c +++ b/sound/soc/fsl/imx-sii902x.c @@ -22,6 +22,7 @@ #include #include #include +#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,20 @@ 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_dai *codec_dai = rtd->codec_dai; + struct snd_soc_card *card = codec_dai->codec->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, }; -- cgit v1.2.3