ASoC: make ops a pointer in 'struct snd_soc_dai'
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / sound / soc / codecs / wm8971.c
index f41a578ddd4fabe908053cee4b273a43155b0e77..032dca22dbd3dce34746a3e3bc65717c051c7501 100644 (file)
@@ -195,21 +195,6 @@ static const struct snd_kcontrol_new wm8971_snd_controls[] = {
        SOC_DOUBLE_R("Mic Boost", WM8971_LADCIN, WM8971_RADCIN, 4, 3, 0),
 };
 
-/* add non-DAPM controls */
-static int wm8971_add_controls(struct snd_soc_codec *codec)
-{
-       int err, i;
-
-       for (i = 0; i < ARRAY_SIZE(wm8971_snd_controls); i++) {
-               err = snd_ctl_add(codec->card,
-                               snd_soc_cnew(&wm8971_snd_controls[i],
-                                            codec, NULL));
-               if (err < 0)
-                       return err;
-       }
-       return 0;
-}
-
 /*
  * DAPM Controls
  */
@@ -541,11 +526,12 @@ static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai,
 }
 
 static int wm8971_pcm_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 wm8971_priv *wm8971 = codec->private_data;
        u16 iface = wm8971_read_reg_cache(codec, WM8971_IFACE) & 0x1f3;
        u16 srate = wm8971_read_reg_cache(codec, WM8971_SRATE) & 0x1c0;
@@ -618,6 +604,13 @@ static int wm8971_set_bias_level(struct snd_soc_codec *codec,
 #define WM8971_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
        SNDRV_PCM_FMTBIT_S24_LE)
 
+static struct snd_soc_dai_ops wm8971_dai_ops = {
+       .hw_params      = wm8971_pcm_hw_params,
+       .digital_mute   = wm8971_mute,
+       .set_fmt        = wm8971_set_dai_fmt,
+       .set_sysclk     = wm8971_set_dai_sysclk,
+};
+
 struct snd_soc_dai wm8971_dai = {
        .name = "WM8971",
        .playback = {
@@ -632,14 +625,7 @@ struct snd_soc_dai wm8971_dai = {
                .channels_max = 2,
                .rates = WM8971_RATES,
                .formats = WM8971_FORMATS,},
-       .ops = {
-               .hw_params = wm8971_pcm_hw_params,
-       },
-       .dai_ops = {
-               .digital_mute = wm8971_mute,
-               .set_fmt = wm8971_set_dai_fmt,
-               .set_sysclk = wm8971_set_dai_sysclk,
-       },
+       .ops = &wm8971_dai_ops,
 };
 EXPORT_SYMBOL_GPL(wm8971_dai);
 
@@ -653,7 +639,7 @@ static void wm8971_work(struct work_struct *work)
 static int wm8971_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;
 
        wm8971_set_bias_level(codec, SND_SOC_BIAS_OFF);
        return 0;
@@ -662,7 +648,7 @@ static int wm8971_suspend(struct platform_device *pdev, pm_message_t state)
 static int wm8971_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;
@@ -693,7 +679,7 @@ static int wm8971_resume(struct platform_device *pdev)
 
 static int wm8971_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 = "WM8971";
@@ -746,9 +732,10 @@ static int wm8971_init(struct snd_soc_device *socdev)
        reg = wm8971_read_reg_cache(codec, WM8971_RINVOL);
        wm8971_write(codec, WM8971_RINVOL, reg | 0x0100);
 
-       wm8971_add_controls(codec);
+       snd_soc_add_controls(codec, wm8971_snd_controls,
+                               ARRAY_SIZE(wm8971_snd_controls));
        wm8971_add_widgets(codec);
-       ret = snd_soc_register_card(socdev);
+       ret = snd_soc_init_card(socdev);
        if (ret < 0) {
                printk(KERN_ERR "wm8971: failed to register card\n");
                goto card_err;
@@ -773,7 +760,7 @@ static int wm8971_i2c_probe(struct i2c_client *i2c,
                            const struct i2c_device_id *id)
 {
        struct snd_soc_device *socdev = wm8971_socdev;
-       struct snd_soc_codec *codec = socdev->codec;
+       struct snd_soc_codec *codec = socdev->card->codec;
        int ret;
 
        i2c_set_clientdata(i2c, codec);
@@ -874,7 +861,7 @@ static int wm8971_probe(struct platform_device *pdev)
        }
 
        codec->private_data = wm8971;
-       socdev->codec = codec;
+       socdev->card->codec = codec;
        mutex_init(&codec->mutex);
        INIT_LIST_HEAD(&codec->dapm_widgets);
        INIT_LIST_HEAD(&codec->dapm_paths);
@@ -909,7 +896,7 @@ static int wm8971_probe(struct platform_device *pdev)
 static int wm8971_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)
                wm8971_set_bias_level(codec, SND_SOC_BIAS_OFF);
@@ -936,6 +923,18 @@ struct snd_soc_codec_device soc_codec_dev_wm8971 = {
 
 EXPORT_SYMBOL_GPL(soc_codec_dev_wm8971);
 
+static int __init wm8971_modinit(void)
+{
+       return snd_soc_register_dai(&wm8971_dai);
+}
+module_init(wm8971_modinit);
+
+static void __exit wm8971_exit(void)
+{
+       snd_soc_unregister_dai(&wm8971_dai);
+}
+module_exit(wm8971_exit);
+
 MODULE_DESCRIPTION("ASoC WM8971 driver");
 MODULE_AUTHOR("Lab126");
 MODULE_LICENSE("GPL");