Merge remote-tracking branch 'asoc/topic/dapm' into asoc-next
authorMark Brown <broonie@kernel.org>
Wed, 4 Feb 2015 20:57:04 +0000 (20:57 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 4 Feb 2015 20:57:04 +0000 (20:57 +0000)
1  2 
include/sound/soc-dapm.h
sound/soc/soc-core.c
sound/soc/soc-dapm.c

diff --combined include/sound/soc-dapm.h
@@@ -405,7 -405,7 +405,7 @@@ int snd_soc_dapm_mux_update_power(struc
                struct snd_soc_dapm_update *update);
  
  /* dapm sys fs - used by the core */
 -int snd_soc_dapm_sys_add(struct device *dev);
 +extern struct attribute *soc_dapm_dev_attrs[];
  void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
                                struct dentry *parent);
  
@@@ -431,7 -431,6 +431,6 @@@ int snd_soc_dapm_force_enable_pin_unloc
                                           const char *pin);
  int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
                                const char *pin);
- void snd_soc_dapm_auto_nc_pins(struct snd_soc_card *card);
  unsigned int dapm_kcontrol_get_value(const struct snd_kcontrol *kcontrol);
  
  /* Mostly internal - should not normally be used */
diff --combined sound/soc/soc-core.c
@@@ -191,39 -191,6 +191,39 @@@ static ssize_t pmdown_time_set(struct d
  
  static DEVICE_ATTR(pmdown_time, 0644, pmdown_time_show, pmdown_time_set);
  
 +static struct attribute *soc_dev_attrs[] = {
 +      &dev_attr_codec_reg.attr,
 +      &dev_attr_pmdown_time.attr,
 +      NULL
 +};
 +
 +static umode_t soc_dev_attr_is_visible(struct kobject *kobj,
 +                                     struct attribute *attr, int idx)
 +{
 +      struct device *dev = kobj_to_dev(kobj);
 +      struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev);
 +
 +      if (attr == &dev_attr_pmdown_time.attr)
 +              return attr->mode; /* always visible */
 +      return rtd->codec ? attr->mode : 0; /* enabled only with codec */
 +}
 +
 +static const struct attribute_group soc_dapm_dev_group = {
 +      .attrs = soc_dapm_dev_attrs,
 +      .is_visible = soc_dev_attr_is_visible,
 +};
 +
 +static const struct attribute_group soc_dev_roup = {
 +      .attrs = soc_dev_attrs,
 +      .is_visible = soc_dev_attr_is_visible,
 +};
 +
 +static const struct attribute_group *soc_dev_attr_groups[] = {
 +      &soc_dapm_dev_group,
 +      &soc_dev_roup,
 +      NULL
 +};
 +
  #ifdef CONFIG_DEBUG_FS
  static ssize_t codec_reg_read_file(struct file *file, char __user *user_buf,
                                   size_t count, loff_t *ppos)
@@@ -982,6 -949,8 +982,6 @@@ static void soc_remove_link_dais(struc
  
        /* unregister the rtd device */
        if (rtd->dev_registered) {
 -              device_remove_file(rtd->dev, &dev_attr_pmdown_time);
 -              device_remove_file(rtd->dev, &dev_attr_codec_reg);
                device_unregister(rtd->dev);
                rtd->dev_registered = 0;
        }
@@@ -1151,7 -1120,6 +1151,7 @@@ static int soc_post_component_init(stru
        device_initialize(rtd->dev);
        rtd->dev->parent = rtd->card->dev;
        rtd->dev->release = rtd_release;
 +      rtd->dev->groups = soc_dev_attr_groups;
        dev_set_name(rtd->dev, "%s", name);
        dev_set_drvdata(rtd->dev, rtd);
        mutex_init(&rtd->pcm_mutex);
                return ret;
        }
        rtd->dev_registered = 1;
 -
 -      if (rtd->codec) {
 -              /* add DAPM sysfs entries for this codec */
 -              ret = snd_soc_dapm_sys_add(rtd->dev);
 -              if (ret < 0)
 -                      dev_err(rtd->dev,
 -                              "ASoC: failed to add codec dapm sysfs entries: %d\n",
 -                              ret);
 -
 -              /* add codec sysfs entries */
 -              ret = device_create_file(rtd->dev, &dev_attr_codec_reg);
 -              if (ret < 0)
 -                      dev_err(rtd->dev,
 -                              "ASoC: failed to add codec sysfs files: %d\n",
 -                              ret);
 -      }
 -
        return 0;
  }
  
@@@ -1323,6 -1308,11 +1323,6 @@@ static int soc_probe_link_dais(struct s
        }
  #endif
  
 -      ret = device_create_file(rtd->dev, &dev_attr_pmdown_time);
 -      if (ret < 0)
 -              dev_warn(rtd->dev, "ASoC: failed to add pmdown_time sysfs: %d\n",
 -                      ret);
 -
        if (cpu_dai->driver->compress_dai) {
                /*create compress_device"*/
                ret = soc_new_compress(rtd, num);
@@@ -1636,9 -1626,6 +1636,6 @@@ static int snd_soc_instantiate_card(str
                }
        }
  
-       if (card->fully_routed)
-               snd_soc_dapm_auto_nc_pins(card);
        snd_soc_dapm_new_widgets(card);
  
        ret = snd_card_register(card->snd_card);
@@@ -3240,7 -3227,7 +3237,7 @@@ int snd_soc_of_parse_audio_routing(stru
                                   const char *propname)
  {
        struct device_node *np = card->dev->of_node;
 -      int num_routes, old_routes;
 +      int num_routes;
        struct snd_soc_dapm_route *routes;
        int i, ret;
  
                return -EINVAL;
        }
  
 -      old_routes = card->num_dapm_routes;
 -      routes = devm_kzalloc(card->dev,
 -                            (old_routes + num_routes) * sizeof(*routes),
 +      routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes),
                              GFP_KERNEL);
        if (!routes) {
                dev_err(card->dev,
                return -EINVAL;
        }
  
 -      memcpy(routes, card->dapm_routes, old_routes * sizeof(*routes));
 -
        for (i = 0; i < num_routes; i++) {
                ret = of_property_read_string_index(np, propname,
 -                      2 * i, &routes[old_routes + i].sink);
 +                      2 * i, &routes[i].sink);
                if (ret) {
                        dev_err(card->dev,
                                "ASoC: Property '%s' index %d could not be read: %d\n",
                        return -EINVAL;
                }
                ret = of_property_read_string_index(np, propname,
 -                      (2 * i) + 1, &routes[old_routes + i].source);
 +                      (2 * i) + 1, &routes[i].source);
                if (ret) {
                        dev_err(card->dev,
                                "ASoC: Property '%s' index %d could not be read: %d\n",
                }
        }
  
 -      card->num_dapm_routes += num_routes;
 +      card->num_dapm_routes = num_routes;
        card->dapm_routes = routes;
  
        return 0;
diff --combined sound/soc/soc-dapm.c
@@@ -517,8 -517,8 +517,8 @@@ static int soc_dapm_update_bits(struct 
  {
        if (!dapm->component)
                return -EIO;
-       return snd_soc_component_update_bits_async(dapm->component, reg,
-               mask, value);
+       return snd_soc_component_update_bits(dapm->component, reg,
+                                            mask, value);
  }
  
  static int soc_dapm_test_bits(struct snd_soc_dapm_context *dapm,
@@@ -2127,10 -2127,15 +2127,10 @@@ static ssize_t dapm_widget_show(struct 
  
  static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL);
  
 -int snd_soc_dapm_sys_add(struct device *dev)
 -{
 -      return device_create_file(dev, &dev_attr_dapm_widget);
 -}
 -
 -static void snd_soc_dapm_sys_remove(struct device *dev)
 -{
 -      device_remove_file(dev, &dev_attr_dapm_widget);
 -}
 +struct attribute *soc_dapm_dev_attrs[] = {
 +      &dev_attr_dapm_widget.attr,
 +      NULL
 +};
  
  static void dapm_free_path(struct snd_soc_dapm_path *path)
  {
@@@ -2274,6 -2279,9 +2274,9 @@@ static void dapm_update_widget_flags(st
  
        switch (w->id) {
        case snd_soc_dapm_input:
+               /* On a fully routed card a input is never a source */
+               if (w->dapm->card->fully_routed)
+                       break;
                w->is_source = 1;
                list_for_each_entry(p, &w->sources, list_sink) {
                        if (p->source->id == snd_soc_dapm_micbias ||
                }
                break;
        case snd_soc_dapm_output:
+               /* On a fully routed card a output is never a sink */
+               if (w->dapm->card->fully_routed)
+                       break;
                w->is_sink = 1;
                list_for_each_entry(p, &w->sinks, list_source) {
                        if (p->sink->id == snd_soc_dapm_spk ||
@@@ -3080,16 -3091,24 +3086,24 @@@ snd_soc_dapm_new_control(struct snd_soc
  
        switch (w->id) {
        case snd_soc_dapm_mic:
-       case snd_soc_dapm_input:
                w->is_source = 1;
                w->power_check = dapm_generic_check_power;
                break;
+       case snd_soc_dapm_input:
+               if (!dapm->card->fully_routed)
+                       w->is_source = 1;
+               w->power_check = dapm_generic_check_power;
+               break;
        case snd_soc_dapm_spk:
        case snd_soc_dapm_hp:
-       case snd_soc_dapm_output:
                w->is_sink = 1;
                w->power_check = dapm_generic_check_power;
                break;
+       case snd_soc_dapm_output:
+               if (!dapm->card->fully_routed)
+                       w->is_sink = 1;
+               w->power_check = dapm_generic_check_power;
+               break;
        case snd_soc_dapm_vmid:
        case snd_soc_dapm_siggen:
                w->is_source = 1;
@@@ -3803,93 -3822,6 +3817,6 @@@ int snd_soc_dapm_ignore_suspend(struct 
  }
  EXPORT_SYMBOL_GPL(snd_soc_dapm_ignore_suspend);
  
- /**
-  * dapm_is_external_path() - Checks if a path is a external path
-  * @card: The card the path belongs to
-  * @path: The path to check
-  *
-  * Returns true if the path is either between two different DAPM contexts or
-  * between two external pins of the same DAPM context. Otherwise returns
-  * false.
-  */
- static bool dapm_is_external_path(struct snd_soc_card *card,
-       struct snd_soc_dapm_path *path)
- {
-       dev_dbg(card->dev,
-               "... Path %s(id:%d dapm:%p) - %s(id:%d dapm:%p)\n",
-               path->source->name, path->source->id, path->source->dapm,
-               path->sink->name, path->sink->id, path->sink->dapm);
-       /* Connection between two different DAPM contexts */
-       if (path->source->dapm != path->sink->dapm)
-               return true;
-       /* Loopback connection from external pin to external pin */
-       if (path->sink->id == snd_soc_dapm_input) {
-               switch (path->source->id) {
-               case snd_soc_dapm_output:
-               case snd_soc_dapm_micbias:
-                       return true;
-               default:
-                       break;
-               }
-       }
-       return false;
- }
- static bool snd_soc_dapm_widget_in_card_paths(struct snd_soc_card *card,
-                                             struct snd_soc_dapm_widget *w)
- {
-       struct snd_soc_dapm_path *p;
-       list_for_each_entry(p, &w->sources, list_sink) {
-               if (dapm_is_external_path(card, p))
-                       return true;
-       }
-       list_for_each_entry(p, &w->sinks, list_source) {
-               if (dapm_is_external_path(card, p))
-                       return true;
-       }
-       return false;
- }
- /**
-  * snd_soc_dapm_auto_nc_pins - call snd_soc_dapm_nc_pin for unused pins
-  * @card: The card whose pins should be processed
-  *
-  * Automatically call snd_soc_dapm_nc_pin() for any external pins in the card
-  * which are unused. Pins are used if they are connected externally to a
-  * component, whether that be to some other device, or a loop-back connection to
-  * the component itself.
-  */
- void snd_soc_dapm_auto_nc_pins(struct snd_soc_card *card)
- {
-       struct snd_soc_dapm_widget *w;
-       dev_dbg(card->dev, "ASoC: Auto NC: DAPMs: card:%p\n", &card->dapm);
-       list_for_each_entry(w, &card->widgets, list) {
-               switch (w->id) {
-               case snd_soc_dapm_input:
-               case snd_soc_dapm_output:
-               case snd_soc_dapm_micbias:
-                       dev_dbg(card->dev, "ASoC: Auto NC: Checking widget %s\n",
-                               w->name);
-                       if (!snd_soc_dapm_widget_in_card_paths(card, w)) {
-                               dev_dbg(card->dev,
-                                       "... Not in map; disabling\n");
-                               snd_soc_dapm_nc_pin(w->dapm, w->name);
-                       }
-                       break;
-               default:
-                       break;
-               }
-       }
- }
  /**
   * snd_soc_dapm_free - free dapm resources
   * @dapm: DAPM context
   */
  void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm)
  {
 -      snd_soc_dapm_sys_remove(dapm->dev);
        dapm_debugfs_cleanup(dapm);
        dapm_free_widgets(dapm);
        list_del(&dapm->list);