summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2013-01-10 16:49:11 -0800
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-01-14 06:55:43 +0900
commita4a2992c531f6ca0aa00ce0deb31e51c1b7ae69b (patch)
treeb8cab15b26088c8cd771ad9c4c82fc5611d34d27 /sound
parent2eebcef31a133b27a09c457f3a7ad509bf237822 (diff)
downloadlinux-a4a2992c531f6ca0aa00ce0deb31e51c1b7ae69b.tar.gz
linux-a4a2992c531f6ca0aa00ce0deb31e51c1b7ae69b.tar.bz2
linux-a4a2992c531f6ca0aa00ce0deb31e51c1b7ae69b.zip
ASoC: simple-card: add asoc_simple_dai for initializing
Current simple-card driver calls asoc_simple_card_dai_init() if platform had a asoc_simple_card_dai_init pointer. And, this initialization function works only when platform has an applicable initial value for each dai settings. And basically, almost all sound card requires certain initialization. This means that almost all platform has initialization settings, and driver do nothing if it doesn't have settings. And additionally, current simple-card supports sysclk settings but it was only for codec. In order to abolish deviation between cpu and codec, and in order to simplify processing, this patch adds asoc_simple_dai, and removed pointless struct asoc_simple_dai_init_info which was trigger of calling asoc_simple_card_dai_init(). Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/generic/simple-card.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index bc050ec8680a..6cf8355a8542 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -16,33 +16,38 @@
#define asoc_simple_get_card_info(p) \
container_of(p->dai_link, struct asoc_simple_card_info, snd_link)
+static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
+ struct asoc_simple_dai *set,
+ unsigned int daifmt)
+{
+ int ret = 0;
+
+ daifmt |= set->fmt;
+
+ if (!ret && daifmt)
+ ret = snd_soc_dai_set_fmt(dai, daifmt);
+
+ if (!ret && set->sysclk)
+ ret = snd_soc_dai_set_sysclk(dai, 0, set->sysclk, 0);
+
+ return ret;
+}
+
static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
{
- struct asoc_simple_card_info *cinfo = asoc_simple_get_card_info(rtd);
- struct asoc_simple_dai_init_info *iinfo = cinfo->init;
+ struct asoc_simple_card_info *info = asoc_simple_get_card_info(rtd);
struct snd_soc_dai *codec = rtd->codec_dai;
struct snd_soc_dai *cpu = rtd->cpu_dai;
- unsigned int cpu_daifmt = iinfo->fmt | iinfo->cpu_daifmt;
- unsigned int codec_daifmt = iinfo->fmt | iinfo->codec_daifmt;
+ unsigned int daifmt = info->daifmt;
int ret;
- if (codec_daifmt) {
- ret = snd_soc_dai_set_fmt(codec, codec_daifmt);
- if (ret < 0)
- return ret;
- }
-
- if (iinfo->sysclk) {
- ret = snd_soc_dai_set_sysclk(codec, 0, iinfo->sysclk, 0);
- if (ret < 0)
- return ret;
- }
+ ret = __asoc_simple_card_dai_init(codec, &info->codec_dai, daifmt);
+ if (ret < 0)
+ return ret;
- if (cpu_daifmt) {
- ret = snd_soc_dai_set_fmt(cpu, cpu_daifmt);
- if (ret < 0)
- return ret;
- }
+ ret = __asoc_simple_card_dai_init(cpu, &info->cpu_dai, daifmt);
+ if (ret < 0)
+ return ret;
return 0;
}
@@ -59,10 +64,10 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
if (!cinfo->name ||
!cinfo->card ||
- !cinfo->cpu_dai ||
!cinfo->codec ||
!cinfo->platform ||
- !cinfo->codec_dai) {
+ !cinfo->cpu_dai.name ||
+ !cinfo->codec_dai.name) {
dev_err(dev, "insufficient asoc_simple_card_info settings\n");
return -EINVAL;
}
@@ -72,14 +77,11 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
*/
cinfo->snd_link.name = cinfo->name;
cinfo->snd_link.stream_name = cinfo->name;
- cinfo->snd_link.cpu_dai_name = cinfo->cpu_dai;
+ cinfo->snd_link.cpu_dai_name = cinfo->cpu_dai.name;
cinfo->snd_link.platform_name = cinfo->platform;
cinfo->snd_link.codec_name = cinfo->codec;
- cinfo->snd_link.codec_dai_name = cinfo->codec_dai;
-
- /* enable snd_link.init if cinfo has settings */
- if (cinfo->init)
- cinfo->snd_link.init = asoc_simple_card_dai_init;
+ cinfo->snd_link.codec_dai_name = cinfo->codec_dai.name;
+ cinfo->snd_link.init = asoc_simple_card_dai_init;
/*
* init snd_soc_card