ASoC: Push the codec runtime storage into the card structure
[deliverable/linux.git] / sound / soc / codecs / wm8731.c
index 7f8a7e36b33e9124d0c3d924301d9cccb6cb9c5f..0150fe53a65d77c451d78e899e07724b8f6a886d 100644 (file)
@@ -129,22 +129,6 @@ SOC_SINGLE("Store DC Offset Switch", WM8731_APDIGI, 4, 1, 0),
 SOC_ENUM("Playback De-emphasis", wm8731_enum[1]),
 };
 
-/* add non dapm controls */
-static int wm8731_add_controls(struct snd_soc_codec *codec)
-{
-       int err, i;
-
-       for (i = 0; i < ARRAY_SIZE(wm8731_snd_controls); i++) {
-               err = snd_ctl_add(codec->card,
-                                 snd_soc_cnew(&wm8731_snd_controls[i],
-                                               codec, NULL));
-               if (err < 0)
-                       return err;
-       }
-
-       return 0;
-}
-
 /* Output Mixer */
 static const struct snd_kcontrol_new wm8731_output_mixer_controls[] = {
 SOC_DAPM_SINGLE("Line Bypass Switch", WM8731_APANA, 3, 1, 0),
@@ -264,11 +248,12 @@ static inline int get_coeff(int mclk, int rate)
 }
 
 static int wm8731_hw_params(struct snd_pcm_substream *substream,
-       struct snd_pcm_hw_params *params)
+                           struct snd_pcm_hw_params *params,
+                           struct snd_soc_dai *dai)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct snd_soc_device *socdev = rtd->socdev;
-       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_codec *codec = socdev->card->codec;
        struct wm8731_priv *wm8731 = codec->private_data;
        u16 iface = wm8731_read_reg_cache(codec, WM8731_IFACE) & 0xfff3;
        int i = get_coeff(wm8731->sysclk, params_rate(params));
@@ -293,11 +278,12 @@ static int wm8731_hw_params(struct snd_pcm_substream *substream,
        return 0;
 }
 
-static int wm8731_pcm_prepare(struct snd_pcm_substream *substream)
+static int wm8731_pcm_prepare(struct snd_pcm_substream *substream,
+                             struct snd_soc_dai *dai)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct snd_soc_device *socdev = rtd->socdev;
-       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_codec *codec = socdev->card->codec;
 
        /* set active */
        wm8731_write(codec, WM8731_ACTIVE, 0x0001);
@@ -305,11 +291,12 @@ static int wm8731_pcm_prepare(struct snd_pcm_substream *substream)
        return 0;
 }
 
-static void wm8731_shutdown(struct snd_pcm_substream *substream)
+static void wm8731_shutdown(struct snd_pcm_substream *substream,
+                           struct snd_soc_dai *dai)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct snd_soc_device *socdev = rtd->socdev;
-       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_codec *codec = socdev->card->codec;
 
        /* deactivate */
        if (!codec->active) {
@@ -461,8 +448,6 @@ struct snd_soc_dai wm8731_dai = {
                .prepare = wm8731_pcm_prepare,
                .hw_params = wm8731_hw_params,
                .shutdown = wm8731_shutdown,
-       },
-       .dai_ops = {
                .digital_mute = wm8731_mute,
                .set_sysclk = wm8731_set_dai_sysclk,
                .set_fmt = wm8731_set_dai_fmt,
@@ -473,7 +458,7 @@ EXPORT_SYMBOL_GPL(wm8731_dai);
 static int wm8731_suspend(struct platform_device *pdev, pm_message_t state)
 {
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
-       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_codec *codec = socdev->card->codec;
 
        wm8731_write(codec, WM8731_ACTIVE, 0x0);
        wm8731_set_bias_level(codec, SND_SOC_BIAS_OFF);
@@ -483,7 +468,7 @@ static int wm8731_suspend(struct platform_device *pdev, pm_message_t state)
 static int wm8731_resume(struct platform_device *pdev)
 {
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
-       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_codec *codec = socdev->card->codec;
        int i;
        u8 data[2];
        u16 *cache = codec->reg_cache;
@@ -505,7 +490,7 @@ static int wm8731_resume(struct platform_device *pdev)
  */
 static int wm8731_init(struct snd_soc_device *socdev)
 {
-       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_codec *codec = socdev->card->codec;
        int reg, ret = 0;
 
        codec->name = "WM8731";
@@ -542,9 +527,10 @@ static int wm8731_init(struct snd_soc_device *socdev)
        reg = wm8731_read_reg_cache(codec, WM8731_RINVOL);
        wm8731_write(codec, WM8731_RINVOL, reg & ~0x0100);
 
-       wm8731_add_controls(codec);
+       snd_soc_add_controls(codec, wm8731_snd_controls,
+                               ARRAY_SIZE(wm8731_snd_controls));
        wm8731_add_widgets(codec);
-       ret = snd_soc_register_card(socdev);
+       ret = snd_soc_init_card(socdev);
        if (ret < 0) {
                printk(KERN_ERR "wm8731: failed to register card\n");
                goto card_err;
@@ -575,7 +561,7 @@ static int wm8731_i2c_probe(struct i2c_client *i2c,
                            const struct i2c_device_id *id)
 {
        struct snd_soc_device *socdev = wm8731_socdev;
-       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_codec *codec = socdev->card->codec;
        int ret;
 
        i2c_set_clientdata(i2c, codec);
@@ -656,7 +642,7 @@ err_driver:
 static int __devinit wm8731_spi_probe(struct spi_device *spi)
 {
        struct snd_soc_device *socdev = wm8731_socdev;
-       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_codec *codec = socdev->card->codec;
        int ret;
 
        codec->control_data = spi;
@@ -730,7 +716,7 @@ static int wm8731_probe(struct platform_device *pdev)
        }
 
        codec->private_data = wm8731;
-       socdev->codec = codec;
+       socdev->card->codec = codec;
        mutex_init(&codec->mutex);
        INIT_LIST_HEAD(&codec->dapm_widgets);
        INIT_LIST_HEAD(&codec->dapm_paths);
@@ -764,7 +750,7 @@ static int wm8731_probe(struct platform_device *pdev)
 static int wm8731_remove(struct platform_device *pdev)
 {
        struct snd_soc_device *socdev = platform_get_drvdata(pdev);
-       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_codec *codec = socdev->card->codec;
 
        if (codec->control_data)
                wm8731_set_bias_level(codec, SND_SOC_BIAS_OFF);
@@ -792,6 +778,18 @@ struct snd_soc_codec_device soc_codec_dev_wm8731 = {
 };
 EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731);
 
+static int __init wm8731_modinit(void)
+{
+       return snd_soc_register_dai(&wm8731_dai);
+}
+module_init(wm8731_modinit);
+
+static void __exit wm8731_exit(void)
+{
+       snd_soc_unregister_dai(&wm8731_dai);
+}
+module_exit(wm8731_exit);
+
 MODULE_DESCRIPTION("ASoC WM8731 driver");
 MODULE_AUTHOR("Richard Purdie");
 MODULE_LICENSE("GPL");
This page took 0.033217 seconds and 5 git commands to generate.