summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorAdrian Alonso <aalonso@freescale.com>2012-05-14 18:48:27 -0500
committerJason Liu <r64343@freescale.com>2012-07-20 13:37:33 +0800
commit1df3a2cfa951b5a411779c49550776ea8a152391 (patch)
treea86cd46d6759873862449137e13fc35ac7f5bd20 /sound
parentcc3b359b4d8fc72a0f84321f244833a9e6d17bec (diff)
ENGR00209384-1 mxc_spdif: add trigger handler function
* Add trigger function in order to handle user space events start/stop/pause playback/capture Signed-off-by: Adrian Alonso <aalonso@freescale.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/mxc_spdif.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/sound/soc/codecs/mxc_spdif.c b/sound/soc/codecs/mxc_spdif.c
index 613caf633fae..8c163fbd7c7d 100644
--- a/sound/soc/codecs/mxc_spdif.c
+++ b/sound/soc/codecs/mxc_spdif.c
@@ -633,6 +633,33 @@ static int mxc_spdif_playback_shutdown(struct snd_pcm_substream *substream,
return 0;
}
+static int mxc_spdif_playback_trigger(struct snd_pcm_substream *substream,
+ int cmd, struct snd_soc_dai *dai)
+{
+ struct snd_soc_codec *codec = dai->codec;
+ struct mxc_spdif_priv *spdif_priv = snd_soc_codec_get_drvdata(codec);
+ struct mxc_spdif_platform_data *plat_data = spdif_priv->plat_data;
+ int ret = 0;
+
+ if (!plat_data->spdif_tx)
+ return -EINVAL;
+
+ switch (cmd) {
+ case SNDRV_PCM_TRIGGER_START:
+ case SNDRV_PCM_TRIGGER_RESUME:
+ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+ break;
+ case SNDRV_PCM_TRIGGER_STOP:
+ case SNDRV_PCM_TRIGGER_SUSPEND:
+ case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return ret;
+}
+
static int mxc_spdif_capture_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
@@ -757,6 +784,33 @@ static int mxc_spdif_capture_shutdown(struct snd_pcm_substream *substream,
return 0;
}
+static int mxc_spdif_capture_trigger(struct snd_pcm_substream *substream,
+ int cmd, struct snd_soc_dai *dai)
+{
+ struct snd_soc_codec *codec = dai->codec;
+ struct mxc_spdif_priv *spdif_priv = snd_soc_codec_get_drvdata(codec);
+ struct mxc_spdif_platform_data *plat_data = spdif_priv->plat_data;
+ int ret = 0;
+
+ if (!plat_data->spdif_rx)
+ return -EINVAL;
+
+ switch (cmd) {
+ case SNDRV_PCM_TRIGGER_START:
+ case SNDRV_PCM_TRIGGER_RESUME:
+ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+ break;
+ case SNDRV_PCM_TRIGGER_STOP:
+ case SNDRV_PCM_TRIGGER_SUSPEND:
+ case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return ret;
+}
+
/*
* MXC SPDIF IEC958 controller(mixer) functions
*
@@ -1117,9 +1171,23 @@ static int mxc_spdif_prepare(struct snd_pcm_substream *substream,
return ret;
}
+static int mxc_spdif_trigger(struct snd_pcm_substream *substream,
+ int cmd, struct snd_soc_dai *dai)
+{
+ int ret = 0;
+
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ ret = mxc_spdif_playback_trigger(substream, cmd, dai);
+ else
+ ret = mxc_spdif_capture_trigger(substream, cmd, dai);
+
+ return ret;
+}
+
struct snd_soc_dai_ops mxc_spdif_codec_dai_ops = {
.startup = mxc_spdif_startup,
.prepare = mxc_spdif_prepare,
+ .trigger = mxc_spdif_trigger,
.shutdown = mxc_spdif_shutdown,
};