summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZidan Wang <zidan.wang@freescale.com>2015-04-10 10:27:37 +0800
committerguoyin.chen <guoyin.chen@freescale.com>2015-05-08 17:26:17 +0800
commit372a179fd478049477128d666263a91513e1e3b4 (patch)
tree519428de9005b3f64d892959e50f8f94dc73e8ef
parentbdcef02184a86d3bca56f4d88d0ca77770dce3ba (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>
-rw-r--r--sound/soc/fsl/imx-sii902x.c27
1 files changed, 27 insertions, 0 deletions
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 <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,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,
};