]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00218421-1 ESAI: Setup virtual device under ESAI sound card
authorChen Liangjun <b36089@freescale.com>
Wed, 25 Jul 2012 13:18:19 +0000 (21:18 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:35:08 +0000 (08:35 +0200)
For ESAI sound card, ESAI driver setup device 0 for raw ESAI playback
and capture.

In this patch, add ESAI virtual device 1 under ESAI sound card. Device 1
is for ESAI audio p2p playback. Every time user use device 1 for
playback, ASRC would be called defaultly. Thus for device 1, it can
support all sample rate between 8k ~ 192k.

Signed-off-by: Chen Liangjun <b36089@freescale.com>
sound/soc/codecs/cs42888.c
sound/soc/codecs/cs42888.h
sound/soc/imx/imx-cs42888.c

index 97a8fc85db119b7a2d8592f4f68103a9d68c155b..cc802e0e71c2f3890057efca3f324a72263c2d28 100644 (file)
@@ -761,7 +761,8 @@ static struct snd_soc_dai_ops cs42888_dai_ops = {
 };
 
 
-struct snd_soc_dai_driver cs42888_dai = {
+struct snd_soc_dai_driver cs42888_dai[] = {
+       {
        .name = "CS42888",
        .playback = {
                .stream_name = "Playback",
@@ -780,6 +781,18 @@ struct snd_soc_dai_driver cs42888_dai = {
                .formats = CS42888_FORMATS,
        },
        .ops = &cs42888_dai_ops,
+       },
+       {
+               .name = "CS42888_ASRC",
+               .playback = {
+                       .stream_name = "Playback",
+                       .channels_min = 1,
+                       .channels_max = 8,
+                       .rates = SNDRV_PCM_RATE_8000_192000,
+                       .formats = CS42888_FORMATS,
+               },
+               .ops = &cs42888_dai_ops,
+       },
 };
 
 /**
@@ -939,14 +952,14 @@ static int cs42888_i2c_probe(struct i2c_client *i2c_client,
        if (i2c_client->dev.platform_data) {
                memcpy(&cs42888->pdata, i2c_client->dev.platform_data,
                                sizeof(cs42888->pdata));
-               cs42888_dai.playback.rates = cs42888->pdata.rates;
-               cs42888_dai.capture.rates = cs42888->pdata.rates;
+               cs42888_dai[0].playback.rates = cs42888->pdata.rates;
+               cs42888_dai[0].capture.rates = cs42888->pdata.rates;
        }
 
        i2c_set_clientdata(i2c_client, cs42888);
 
        ret = snd_soc_register_codec(&i2c_client->dev,
-               &cs42888_driver, &cs42888_dai, 1);
+               &cs42888_driver, cs42888_dai, 2);
        if (ret) {
                dev_err(&i2c_client->dev, "Failed to register codec:%d\n", ret);
                kfree(cs42888);
index b4f3950e8271b7c279244740c20e5504a5af3c94..a7c92d56e5d6c6245e79da18b56560fd41b4b66c 100644 (file)
@@ -18,7 +18,7 @@
  * The ASoC codec DAI structure for the CS42888.  Assign this structure to
  * the .codec_dai field of your machine driver's snd_soc_dai_link structure.
  */
-extern struct snd_soc_dai_driver cs42888_dai;
+extern struct snd_soc_dai_driver cs42888_dai[];
 
 /*
  * The ASoC codec device structure for the CS42888.  Assign this structure
index 128c9959a25f279f86a8fb8e6b1353f7be2c2198..7f4f2840db7b3933f78a62fb3826bf36ff46609d 100644 (file)
@@ -385,33 +385,14 @@ static int imx_3stack_cs42888_init(struct snd_soc_pcm_runtime *rtd)
 {
        struct snd_soc_codec *codec = rtd->codec;
 
-       if (asrc_support) {
-               struct snd_card *card = codec->card->snd_card;
-               int i;
-               int ret;
-
-               for (i = 0; i < ARRAY_SIZE(asrc_controls); i++) {
-                       ret = snd_ctl_add(card,
-                                       snd_soc_cnew(&asrc_controls[i],
-                                               codec, asrc_controls[i].name,
-                                               codec->name_prefix));
-                       if (ret < 0)
-                               return ret;
-               }
-               /*asrc_func is inited 0.
-                * it means asrc would not
-                * be called defaultly*/
-               asrc_func = 0;
-               asrc_esai_data.input_sample_rate = asrc_rates[asrc_func];
-       }
-
        snd_soc_dapm_new_controls(&codec->dapm, imx_3stack_dapm_widgets,
                                  ARRAY_SIZE(imx_3stack_dapm_widgets));
-
        snd_soc_dapm_add_routes(&codec->dapm, audio_map, ARRAY_SIZE(audio_map));
-
        snd_soc_dapm_sync(&codec->dapm);
-
+       return 0;
+}
+static int imx_asrc_cs42888_init(struct snd_soc_pcm_runtime *rtd)
+{
        return 0;
 }
 
@@ -431,6 +412,21 @@ static struct snd_soc_dai_link imx_3stack_dai[] = {
        .init = imx_3stack_cs42888_init,
        .ops = &imx_3stack_surround_ops,
        },
+       {
+       .name = "HiFi_ASRC",
+       .stream_name = "HIFI_ASRC",
+       .codec_dai_name = "CS42888_ASRC",
+#ifdef CONFIG_SOC_IMX53
+       .codec_name = "cs42888.1-0048",
+#endif
+#ifdef CONFIG_SOC_IMX6Q
+       .codec_name = "cs42888.0-0048",
+#endif
+       .cpu_dai_name = "imx-esai.0",
+       .platform_name = "imx-pcm-audio.0",
+       .init = imx_asrc_cs42888_init,
+       .ops = &imx_3stack_surround_ops,
+       },
 };
 
 static struct snd_soc_card snd_soc_card_imx_3stack = {
@@ -451,8 +447,10 @@ static int __devinit imx_3stack_cs42888_probe(struct platform_device *pdev)
                return -EINVAL;
        }
        mclk_freq = plat_data->sysclk;
-       if (plat_data->codec_name)
+       if (plat_data->codec_name) {
                imx_3stack_dai[0].codec_name = plat_data->codec_name;
+               imx_3stack_dai[1].codec_name = plat_data->codec_name;
+       }
        return 0;
 }