Merge branch 'topic/multi-component' of git://git.kernel.org/pub/scm/linux/kernel...
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 12 Aug 2010 13:40:28 +0000 (14:40 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 12 Aug 2010 13:40:28 +0000 (14:40 +0100)
1  2 
sound/soc/codecs/wm8580.c
sound/soc/s3c24xx/smdk64xx_wm8580.c

index 1881b16bc24832a021f7fcfa02686814004612e5,39ad46c41e8aaf370ac3f0113bc4f0f17c2d9fa2..b1a80e5ff8b5f4704ff07f692ef41ae7520d81ef
@@@ -199,7 -199,7 +199,7 @@@ static const char *wm8580_supply_names[
  
  /* codec private data */
  struct wm8580_priv {
-       struct snd_soc_codec codec;
+       enum snd_soc_control_type control_type;
        struct regulator_bulk_data supplies[WM8580_NUM_SUPPLIES];
        u16 reg_cache[WM8580_MAX_REGISTER + 1];
        struct pll_state a;
@@@ -273,8 -273,8 +273,8 @@@ SOC_SINGLE("DAC1 Switch", WM8580_DAC_CO
  SOC_SINGLE("DAC2 Switch", WM8580_DAC_CONTROL5, 1, 1, 0),
  SOC_SINGLE("DAC3 Switch", WM8580_DAC_CONTROL5, 2, 1, 0),
  
 -SOC_DOUBLE("ADC Mute Switch", WM8580_ADC_CONTROL1, 0, 1, 1, 0),
 -SOC_SINGLE("ADC High-Pass Filter Switch", WM8580_ADC_CONTROL1, 4, 1, 0),
 +SOC_DOUBLE("Capture Switch", WM8580_ADC_CONTROL1, 0, 1, 1, 0),
 +SOC_SINGLE("Capture High-Pass Filter Switch", WM8580_ADC_CONTROL1, 4, 1, 0),
  };
  
  static const struct snd_soc_dapm_widget wm8580_dapm_widgets[] = {
@@@ -484,9 -484,8 +484,8 @@@ static int wm8580_paif_hw_params(struc
                                 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->card->codec;
-       u16 paifb = snd_soc_read(codec, WM8580_PAIF3 + dai->id);
+       struct snd_soc_codec *codec = rtd->codec;
+       u16 paifb = snd_soc_read(codec, WM8580_PAIF3 + dai->driver->id);
  
        paifb &= ~WM8580_AIF_LENGTH_MASK;
        /* bit size */
                return -EINVAL;
        }
  
-       snd_soc_write(codec, WM8580_PAIF3 + dai->id, paifb);
+       snd_soc_write(codec, WM8580_PAIF3 + dai->driver->id, paifb);
        return 0;
  }
  
@@@ -518,8 -517,8 +517,8 @@@ static int wm8580_set_paif_dai_fmt(stru
        unsigned int aifb;
        int can_invert_lrclk;
  
-       aifa = snd_soc_read(codec, WM8580_PAIF1 + codec_dai->id);
-       aifb = snd_soc_read(codec, WM8580_PAIF3 + codec_dai->id);
+       aifa = snd_soc_read(codec, WM8580_PAIF1 + codec_dai->driver->id);
+       aifb = snd_soc_read(codec, WM8580_PAIF3 + codec_dai->driver->id);
  
        aifb &= ~(WM8580_AIF_FMT_MASK | WM8580_AIF_LRP | WM8580_AIF_BCP);
  
                return -EINVAL;
        }
  
-       snd_soc_write(codec, WM8580_PAIF1 + codec_dai->id, aifa);
-       snd_soc_write(codec, WM8580_PAIF3 + codec_dai->id, aifb);
+       snd_soc_write(codec, WM8580_PAIF1 + codec_dai->driver->id, aifa);
+       snd_soc_write(codec, WM8580_PAIF3 + codec_dai->driver->id, aifb);
  
        return 0;
  }
@@@ -746,10 -745,10 +745,10 @@@ static struct snd_soc_dai_ops wm8580_da
        .set_pll        = wm8580_set_dai_pll,
  };
  
- struct snd_soc_dai wm8580_dai[] = {
+ static struct snd_soc_dai_driver wm8580_dai[] = {
        {
-               .name = "WM8580 PAIFRX",
-               .id = 0,
+               .name = "wm8580-hifi-playback",
+               .id     = WM8580_DAI_PAIFRX,
                .playback = {
                        .stream_name = "Playback",
                        .channels_min = 1,
                .ops = &wm8580_dai_ops_playback,
        },
        {
-               .name = "WM8580 PAIFTX",
-               .id = 1,
+               .name = "wm8580-hifi-capture",
+               .id     =       WM8580_DAI_PAIFTX,
                .capture = {
                        .stream_name = "Capture",
                        .channels_min = 2,
                .ops = &wm8580_dai_ops_capture,
        },
  };
- EXPORT_SYMBOL_GPL(wm8580_dai);
  
- static struct snd_soc_codec *wm8580_codec;
- static int wm8580_probe(struct platform_device *pdev)
+ static int wm8580_probe(struct snd_soc_codec *codec)
  {
-       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
-       struct snd_soc_codec *codec;
-       int ret = 0;
-       if (wm8580_codec == NULL) {
-               dev_err(&pdev->dev, "Codec device not registered\n");
-               return -ENODEV;
-       }
-       socdev->card->codec = wm8580_codec;
-       codec = wm8580_codec;
-       /* register pcms */
-       ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to create pcms: %d\n", ret);
-               goto pcm_err;
-       }
-       snd_soc_add_controls(codec, wm8580_snd_controls,
-                            ARRAY_SIZE(wm8580_snd_controls));
-       wm8580_add_widgets(codec);
-       return ret;
- pcm_err:
-       return ret;
- }
- /* power down chip */
- static int wm8580_remove(struct platform_device *pdev)
- {
-       struct snd_soc_device *socdev = platform_get_drvdata(pdev);
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
-       return 0;
- }
- struct snd_soc_codec_device soc_codec_dev_wm8580 = {
-       .probe =        wm8580_probe,
-       .remove =       wm8580_remove,
- };
- EXPORT_SYMBOL_GPL(soc_codec_dev_wm8580);
- static int wm8580_register(struct wm8580_priv *wm8580,
-                          enum snd_soc_control_type control)
- {
-       int ret, i;
-       struct snd_soc_codec *codec = &wm8580->codec;
-       if (wm8580_codec) {
-               dev_err(codec->dev, "Another WM8580 is registered\n");
-               ret = -EINVAL;
-               goto err;
-       }
-       mutex_init(&codec->mutex);
-       INIT_LIST_HEAD(&codec->dapm_widgets);
-       INIT_LIST_HEAD(&codec->dapm_paths);
-       snd_soc_codec_set_drvdata(codec, wm8580);
-       codec->name = "WM8580";
-       codec->owner = THIS_MODULE;
-       codec->bias_level = SND_SOC_BIAS_OFF;
-       codec->set_bias_level = wm8580_set_bias_level;
-       codec->dai = wm8580_dai;
-       codec->num_dai = ARRAY_SIZE(wm8580_dai);
-       codec->reg_cache_size = ARRAY_SIZE(wm8580->reg_cache);
-       codec->reg_cache = &wm8580->reg_cache;
-       memcpy(codec->reg_cache, wm8580_reg, sizeof(wm8580_reg));
+       struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec);
+       int ret = 0,i;
  
-       ret = snd_soc_codec_set_cache_io(codec, 7, 9, control);
+       ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8580->control_type);
        if (ret < 0) {
                dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
-               goto err;
+               return ret;
        }
  
        for (i = 0; i < ARRAY_SIZE(wm8580->supplies); i++)
                                 wm8580->supplies);
        if (ret != 0) {
                dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
-               goto err;
+               return ret;
        }
  
        ret = regulator_bulk_enable(ARRAY_SIZE(wm8580->supplies),
                goto err_regulator_enable;
        }
  
-       for (i = 0; i < ARRAY_SIZE(wm8580_dai); i++)
-               wm8580_dai[i].dev = codec->dev;
        wm8580_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
  
-       wm8580_codec = codec;
-       ret = snd_soc_register_codec(codec);
-       if (ret != 0) {
-               dev_err(codec->dev, "Failed to register codec: %d\n", ret);
-               goto err_regulator_enable;
-       }
-       ret = snd_soc_register_dais(wm8580_dai, ARRAY_SIZE(wm8580_dai));
-       if (ret != 0) {
-               dev_err(codec->dev, "Failed to register DAI: %d\n", ret);
-               goto err_codec;
-       }
+       snd_soc_add_controls(codec, wm8580_snd_controls,
+                            ARRAY_SIZE(wm8580_snd_controls));
+       wm8580_add_widgets(codec);
  
        return 0;
  
- err_codec:
-       snd_soc_unregister_codec(codec);
  err_regulator_enable:
        regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies);
  err_regulator_get:
        regulator_bulk_free(ARRAY_SIZE(wm8580->supplies), wm8580->supplies);
- err:
-       kfree(wm8580);
        return ret;
  }
  
- static void wm8580_unregister(struct wm8580_priv *wm8580)
+ /* power down chip */
+ static int wm8580_remove(struct snd_soc_codec *codec)
  {
-       wm8580_set_bias_level(&wm8580->codec, SND_SOC_BIAS_OFF);
-       snd_soc_unregister_dais(wm8580_dai, ARRAY_SIZE(wm8580_dai));
-       snd_soc_unregister_codec(&wm8580->codec);
+       struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec);
+       wm8580_set_bias_level(codec, SND_SOC_BIAS_OFF);
        regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies);
        regulator_bulk_free(ARRAY_SIZE(wm8580->supplies), wm8580->supplies);
-       kfree(wm8580);
-       wm8580_codec = NULL;
+       return 0;
  }
  
+ static struct snd_soc_codec_driver soc_codec_dev_wm8580 = {
+       .probe =        wm8580_probe,
+       .remove =       wm8580_remove,
+       .set_bias_level = wm8580_set_bias_level,
+       .reg_cache_size = sizeof(wm8580_reg),
+       .reg_word_size = sizeof(u16),
+       .reg_cache_default = &wm8580_reg,
+ };
  #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
  static int wm8580_i2c_probe(struct i2c_client *i2c,
                            const struct i2c_device_id *id)
  {
        struct wm8580_priv *wm8580;
-       struct snd_soc_codec *codec;
+       int ret;
  
        wm8580 = kzalloc(sizeof(struct wm8580_priv), GFP_KERNEL);
        if (wm8580 == NULL)
                return -ENOMEM;
  
-       codec = &wm8580->codec;
        i2c_set_clientdata(i2c, wm8580);
-       codec->control_data = i2c;
-       codec->dev = &i2c->dev;
+       wm8580->control_type = SND_SOC_I2C;
  
-       return wm8580_register(wm8580, SND_SOC_I2C);
+       ret =  snd_soc_register_codec(&i2c->dev,
+                       &soc_codec_dev_wm8580, wm8580_dai, ARRAY_SIZE(wm8580_dai));
+       if (ret < 0)
+               kfree(wm8580);
+       return ret;
  }
  
  static int wm8580_i2c_remove(struct i2c_client *client)
  {
-       struct wm8580_priv *wm8580 = i2c_get_clientdata(client);
-       wm8580_unregister(wm8580);
+       snd_soc_unregister_codec(&client->dev);
+       kfree(i2c_get_clientdata(client));
        return 0;
  }
  
@@@ -961,7 -880,7 +880,7 @@@ MODULE_DEVICE_TABLE(i2c, wm8580_i2c_id)
  
  static struct i2c_driver wm8580_i2c_driver = {
        .driver = {
-               .name = "wm8580",
+               .name = "wm8580-codec",
                .owner = THIS_MODULE,
        },
        .probe =    wm8580_i2c_probe,
  
  static int __init wm8580_modinit(void)
  {
-       int ret;
+       int ret = 0;
  
  #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
        ret = i2c_add_driver(&wm8580_i2c_driver);
        }
  #endif
  
-       return 0;
+       return ret;
  }
  module_init(wm8580_modinit);
  
index 4926acaaa8b0760df08aacf57fa87d204248e1f8,634acfc41608318b21f1fdb8b6340de08a02e3d9..5c21e26da07563d2267f9bfe572da0320faa874a
  #include "s3c-dma.h"
  #include "s3c64xx-i2s.h"
  
 +/*
 + * Default CFG switch settings to use this driver:
 + *
 + *   SMDK6410: Set CFG1 1-3 Off, CFG2 1-4 On
 + */
 +
  /* SMDK64XX has a 12MHZ crystal attached to WM8580 */
  #define SMDK64XX_WM8580_FREQ 12000000
  
@@@ -35,8 -29,8 +35,8 @@@ static int smdk64xx_hw_params(struct sn
        struct snd_pcm_hw_params *params)
  {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
-       struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
+       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+       struct snd_soc_dai *codec_dai = rtd->codec_dai;
        unsigned int pll_out;
        int bfs, rfs, ret;
  
@@@ -144,9 -138,9 +144,9 @@@ static struct snd_soc_ops smdk64xx_ops 
  
  /* SMDK64xx Playback widgets */
  static const struct snd_soc_dapm_widget wm8580_dapm_widgets_pbk[] = {
 -      SND_SOC_DAPM_HP("Front-L/R", NULL),
 -      SND_SOC_DAPM_HP("Center/Sub", NULL),
 -      SND_SOC_DAPM_HP("Rear-L/R", NULL),
 +      SND_SOC_DAPM_HP("Front", NULL),
 +      SND_SOC_DAPM_HP("Center+Sub", NULL),
 +      SND_SOC_DAPM_HP("Rear", NULL),
  };
  
  /* SMDK64xx Capture widgets */
@@@ -168,20 -162,22 +168,22 @@@ static const struct snd_soc_dapm_route 
  /* SMDK-PAIFRX connections */
  static const struct snd_soc_dapm_route audio_map_rx[] = {
        /* Front Left/Right are fed VOUT1L/R */
 -      {"Front-L/R", NULL, "VOUT1L"},
 -      {"Front-L/R", NULL, "VOUT1R"},
 +      {"Front", NULL, "VOUT1L"},
 +      {"Front", NULL, "VOUT1R"},
  
        /* Center/Sub are fed VOUT2L/R */
 -      {"Center/Sub", NULL, "VOUT2L"},
 -      {"Center/Sub", NULL, "VOUT2R"},
 +      {"Center+Sub", NULL, "VOUT2L"},
 +      {"Center+Sub", NULL, "VOUT2R"},
  
        /* Rear Left/Right are fed VOUT3L/R */
 -      {"Rear-L/R", NULL, "VOUT3L"},
 -      {"Rear-L/R", NULL, "VOUT3R"},
 +      {"Rear", NULL, "VOUT3L"},
 +      {"Rear", NULL, "VOUT3R"},
  };
  
- static int smdk64xx_wm8580_init_paiftx(struct snd_soc_codec *codec)
+ static int smdk64xx_wm8580_init_paiftx(struct snd_soc_pcm_runtime *rtd)
  {
+       struct snd_soc_codec *codec = rtd->codec;
        /* Add smdk64xx specific Capture widgets */
        snd_soc_dapm_new_controls(codec, wm8580_dapm_widgets_cpt,
                                  ARRAY_SIZE(wm8580_dapm_widgets_cpt));
        return 0;
  }
  
- static int smdk64xx_wm8580_init_paifrx(struct snd_soc_codec *codec)
+ static int smdk64xx_wm8580_init_paifrx(struct snd_soc_pcm_runtime *rtd)
  {
+       struct snd_soc_codec *codec = rtd->codec;
        /* Add smdk64xx specific Playback widgets */
        snd_soc_dapm_new_controls(codec, wm8580_dapm_widgets_pbk,
                                  ARRAY_SIZE(wm8580_dapm_widgets_pbk));
@@@ -219,16 -217,20 +223,20 @@@ static struct snd_soc_dai_link smdk64xx
  { /* Primary Playback i/f */
        .name = "WM8580 PAIF RX",
        .stream_name = "Playback",
-       .cpu_dai = &s3c64xx_i2s_v4_dai,
-       .codec_dai = &wm8580_dai[WM8580_DAI_PAIFRX],
+       .cpu_dai_name = "s3c64xx-iis-v4",
+       .codec_dai_name = "wm8580-hifi-playback",
+       .platform_name = "s3c24xx-pcm-audio",
+       .codec_name = "wm8580-codec.0-001b",
        .init = smdk64xx_wm8580_init_paifrx,
        .ops = &smdk64xx_ops,
  },
  { /* Primary Capture i/f */
        .name = "WM8580 PAIF TX",
        .stream_name = "Capture",
-       .cpu_dai = &s3c64xx_i2s_v4_dai,
-       .codec_dai = &wm8580_dai[WM8580_DAI_PAIFTX],
+       .cpu_dai_name = "s3c64xx-iis-v4",
+       .codec_dai_name = "wm8580-hifi-capture",
+       .platform_name = "s3c24xx-pcm-audio",
+       .codec_name = "wm8580-codec.0-001b",
        .init = smdk64xx_wm8580_init_paiftx,
        .ops = &smdk64xx_ops,
  },
  
  static struct snd_soc_card smdk64xx = {
        .name = "smdk64xx",
-       .platform = &s3c24xx_soc_platform,
        .dai_link = smdk64xx_dai,
        .num_links = ARRAY_SIZE(smdk64xx_dai),
  };
  
- static struct snd_soc_device smdk64xx_snd_devdata = {
-       .card = &smdk64xx,
-       .codec_dev = &soc_codec_dev_wm8580,
- };
  static struct platform_device *smdk64xx_snd_device;
  
  static int __init smdk64xx_audio_init(void)
        if (!smdk64xx_snd_device)
                return -ENOMEM;
  
-       platform_set_drvdata(smdk64xx_snd_device, &smdk64xx_snd_devdata);
-       smdk64xx_snd_devdata.dev = &smdk64xx_snd_device->dev;
+       platform_set_drvdata(smdk64xx_snd_device, &smdk64xx);
        ret = platform_device_add(smdk64xx_snd_device);
  
        if (ret)
This page took 0.047437 seconds and 5 git commands to generate.