]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge branch 'for-2.6.29' into for-2.6.30
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 13 Feb 2009 14:02:08 +0000 (14:02 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 13 Feb 2009 14:02:08 +0000 (14:02 +0000)
1  2 
sound/soc/soc-core.c

diff --combined sound/soc/soc-core.c
index 580a1a534ad03a4e72571e611870d5fcf8570be3,ec3f8bb4b51d9805d827279e8b025aeeb12d657a..d4b90d82a098cdf98d939f1b409d7b1b2ace087c
@@@ -234,7 -234,7 +234,7 @@@ static int soc_pcm_open(struct snd_pcm_
                cpu_dai->capture.active = codec_dai->capture.active = 1;
        cpu_dai->active = codec_dai->active = 1;
        cpu_dai->runtime = runtime;
 -      socdev->codec->active++;
 +      card->codec->active++;
        mutex_unlock(&pcm_mutex);
        return 0;
  
@@@ -264,7 -264,7 +264,7 @@@ static void close_delayed_work(struct w
        struct snd_soc_card *card = container_of(work, struct snd_soc_card,
                                                 delayed_work.work);
        struct snd_soc_device *socdev = card->socdev;
 -      struct snd_soc_codec *codec = socdev->codec;
 +      struct snd_soc_codec *codec = card->codec;
        struct snd_soc_dai *codec_dai;
        int i;
  
@@@ -319,7 -319,7 +319,7 @@@ static int soc_codec_close(struct snd_p
        struct snd_soc_platform *platform = card->platform;
        struct snd_soc_dai *cpu_dai = machine->cpu_dai;
        struct snd_soc_dai *codec_dai = machine->codec_dai;
 -      struct snd_soc_codec *codec = socdev->codec;
 +      struct snd_soc_codec *codec = card->codec;
  
        mutex_lock(&pcm_mutex);
  
@@@ -387,7 -387,7 +387,7 @@@ static int soc_pcm_prepare(struct snd_p
        struct snd_soc_platform *platform = card->platform;
        struct snd_soc_dai *cpu_dai = machine->cpu_dai;
        struct snd_soc_dai *codec_dai = machine->codec_dai;
 -      struct snd_soc_codec *codec = socdev->codec;
 +      struct snd_soc_codec *codec = card->codec;
        int ret = 0;
  
        mutex_lock(&pcm_mutex);
@@@ -553,7 -553,7 +553,7 @@@ static int soc_pcm_hw_free(struct snd_p
        struct snd_soc_platform *platform = card->platform;
        struct snd_soc_dai *cpu_dai = machine->cpu_dai;
        struct snd_soc_dai *codec_dai = machine->codec_dai;
 -      struct snd_soc_codec *codec = socdev->codec;
 +      struct snd_soc_codec *codec = card->codec;
  
        mutex_lock(&pcm_mutex);
  
@@@ -629,7 -629,7 +629,7 @@@ static int soc_suspend(struct platform_
        struct snd_soc_card *card = socdev->card;
        struct snd_soc_platform *platform = card->platform;
        struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
 -      struct snd_soc_codec *codec = socdev->codec;
 +      struct snd_soc_codec *codec = card->codec;
        int i;
  
        /* Due to the resume being scheduled into a workqueue we could
@@@ -705,7 -705,7 +705,7 @@@ static void soc_resume_deferred(struct 
        struct snd_soc_device *socdev = card->socdev;
        struct snd_soc_platform *platform = card->platform;
        struct snd_soc_codec_device *codec_dev = socdev->codec_dev;
 -      struct snd_soc_codec *codec = socdev->codec;
 +      struct snd_soc_codec *codec = card->codec;
        struct platform_device *pdev = to_platform_device(socdev->dev);
        int i;
  
@@@ -982,8 -982,8 +982,8 @@@ static struct platform_driver soc_drive
  static int soc_new_pcm(struct snd_soc_device *socdev,
        struct snd_soc_dai_link *dai_link, int num)
  {
 -      struct snd_soc_codec *codec = socdev->codec;
        struct snd_soc_card *card = socdev->card;
 +      struct snd_soc_codec *codec = card->codec;
        struct snd_soc_platform *platform = card->platform;
        struct snd_soc_dai *codec_dai = dai_link->codec_dai;
        struct snd_soc_dai *cpu_dai = dai_link->cpu_dai;
  
        rtd->dai = dai_link;
        rtd->socdev = socdev;
 -      codec_dai->codec = socdev->codec;
 +      codec_dai->codec = card->codec;
  
        /* check client and interface hw capabilities */
        sprintf(new_name, "%s %s-%d", dai_link->stream_name, codec_dai->name,
  }
  
  /* codec register dump */
 -static ssize_t soc_codec_reg_show(struct snd_soc_device *devdata, char *buf)
 +static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf)
  {
 -      struct snd_soc_codec *codec = devdata->codec;
        int i, step = 1, count = 0;
  
        if (!codec->reg_cache_size)
@@@ -1089,7 -1090,7 +1089,7 @@@ static ssize_t codec_reg_show(struct de
        struct device_attribute *attr, char *buf)
  {
        struct snd_soc_device *devdata = dev_get_drvdata(dev);
 -      return soc_codec_reg_show(devdata, buf);
 +      return soc_codec_reg_show(devdata->card->codec, buf);
  }
  
  static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL);
@@@ -1106,10 -1107,12 +1106,10 @@@ static ssize_t codec_reg_read_file(stru
  {
        ssize_t ret;
        struct snd_soc_codec *codec = file->private_data;
 -      struct device *card_dev = codec->card->dev;
 -      struct snd_soc_device *devdata = card_dev->driver_data;
        char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
 -      ret = soc_codec_reg_show(devdata, buf);
 +      ret = soc_codec_reg_show(codec, buf);
        if (ret >= 0)
                ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
        kfree(buf);
@@@ -1306,19 -1309,19 +1306,19 @@@ EXPORT_SYMBOL_GPL(snd_soc_test_bits)
   */
  int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid)
  {
 -      struct snd_soc_codec *codec = socdev->codec;
        struct snd_soc_card *card = socdev->card;
 -      int ret = 0, i;
 +      struct snd_soc_codec *codec = card->codec;
 +      int ret, i;
  
        mutex_lock(&codec->mutex);
  
        /* register a sound card */
 -      codec->card = snd_card_new(idx, xid, codec->owner, 0);
 -      if (!codec->card) {
 +      ret = snd_card_create(idx, xid, codec->owner, 0, &codec->card);
 +      if (ret < 0) {
                printk(KERN_ERR "asoc: can't create sound card for codec %s\n",
                        codec->name);
                mutex_unlock(&codec->mutex);
 -              return -ENODEV;
 +              return ret;
        }
  
        codec->card->dev = socdev->dev;
@@@ -1352,8 -1355,8 +1352,8 @@@ EXPORT_SYMBOL_GPL(snd_soc_new_pcms)
   */
  int snd_soc_init_card(struct snd_soc_device *socdev)
  {
 -      struct snd_soc_codec *codec = socdev->codec;
        struct snd_soc_card *card = socdev->card;
 +      struct snd_soc_codec *codec = card->codec;
        int ret = 0, i, ac97 = 0, err = 0;
  
        for (i = 0; i < card->num_links; i++) {
  
        mutex_lock(&codec->mutex);
  #ifdef CONFIG_SND_SOC_AC97_BUS
-       if (ac97) {
+       /* Only instantiate AC97 if not already done by the adaptor
+        * for the generic AC97 subsystem.
+        */
+       if (ac97 && strcmp(codec->name, "AC97") != 0) {
                ret = soc_ac97_dev_register(codec);
                if (ret < 0) {
                        printk(KERN_ERR "asoc: AC97 device register failed\n");
        if (err < 0)
                printk(KERN_WARNING "asoc: failed to add codec sysfs files\n");
  
 -      soc_init_codec_debugfs(socdev->codec);
 +      soc_init_codec_debugfs(codec);
        mutex_unlock(&codec->mutex);
  
  out:
@@@ -1418,14 -1424,14 +1421,14 @@@ EXPORT_SYMBOL_GPL(snd_soc_init_card)
   */
  void snd_soc_free_pcms(struct snd_soc_device *socdev)
  {
 -      struct snd_soc_codec *codec = socdev->codec;
 +      struct snd_soc_codec *codec = socdev->card->codec;
  #ifdef CONFIG_SND_SOC_AC97_BUS
        struct snd_soc_dai *codec_dai;
        int i;
  #endif
  
        mutex_lock(&codec->mutex);
 -      soc_cleanup_codec_debugfs(socdev->codec);
 +      soc_cleanup_codec_debugfs(codec);
  #ifdef CONFIG_SND_SOC_AC97_BUS
        for (i = 0; i < codec->num_dai; i++) {
                codec_dai = &codec->dai[i];
@@@ -1491,37 -1497,6 +1494,37 @@@ struct snd_kcontrol *snd_soc_cnew(cons
  }
  EXPORT_SYMBOL_GPL(snd_soc_cnew);
  
 +/**
 + * snd_soc_add_controls - add an array of controls to a codec.
 + * Convienience function to add a list of controls. Many codecs were
 + * duplicating this code.
 + *
 + * @codec: codec to add controls to
 + * @controls: array of controls to add
 + * @num_controls: number of elements in the array
 + *
 + * Return 0 for success, else error.
 + */
 +int snd_soc_add_controls(struct snd_soc_codec *codec,
 +      const struct snd_kcontrol_new *controls, int num_controls)
 +{
 +      struct snd_card *card = codec->card;
 +      int err, i;
 +
 +      for (i = 0; i < num_controls; i++) {
 +              const struct snd_kcontrol_new *control = &controls[i];
 +              err = snd_ctl_add(card, snd_soc_cnew(control, codec, NULL));
 +              if (err < 0) {
 +                      dev_err(codec->dev, "%s: Failed to add %s\n",
 +                              codec->name, control->name);
 +                      return err;
 +              }
 +      }
 +
 +      return 0;
 +}
 +EXPORT_SYMBOL_GPL(snd_soc_add_controls);
 +
  /**
   * snd_soc_info_enum_double - enumerated double mixer info callback
   * @kcontrol: mixer control