1. 28 10月, 2014 6 次提交
    • L
      ASoC: dapm: Mark endpoints instead of IO widgets dirty during suspend/resume · 8be4da29
      Lars-Peter Clausen 提交于
      The state of endpoint widgets is affected by that card's power state.
      Endpoint widgets that do no have the ignore_suspend flag set will be
      considered inactive during suspend. So they have to be re-checked and marked
      dirty after the card's power state changes. Currently the input and output
      widgets are marked dirty instead, this works most of the time since
      typically a path from one endpoint to another will go via a input or output
      widget. But marking the endpoints dirty is technically more correct and will
      also work for odd corner cases.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      8be4da29
    • L
      ASoC: dapm: Add a flag to mark paths connected to supply widgets · c1862c8b
      Lars-Peter Clausen 提交于
      Supply widgets do not count towards the input and output widgets of their
      neighbors and for supply widgets themselves we do not care for the number
      of input or output paths. This means that a path that connects to a supply
      widget effectively behaves the same as a path that as the weak property set.
      This patch adds a new path flag that gets set to true when the path is
      connected to at least one supply widget. If a path with the flag set is
      encountered in is_connected_{input,output}_ep() is is skipped in the same
      way that weak paths are skipped. This slightly brings down the number of
      path checks.
      
      Since both the weak and the supply flag are implemented as bitfields which
      are stored in the same word there is no runtime overhead due to checking
      both rather than just one and also the size of the path struct is not
      increased by this patch. Another advantage is that we do not have to handle
      supply widgets in is_connected_{input,output}_ep() anymore since it will
      never be called for supply widgets. The only exception is from
      dapm_widget_power_read_file() where a check is added to special case supply
      widgets.
      
      Testing with the ADAU1761, which has a handful of supply widgets, shows the
      following changes in the DAPM stats for a playback stream start.
      
               Power  Path  Neighbour
      Before:  34     78    117
      After:   34     48    117
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      c1862c8b
    • L
      ASoC: dapm: Introduce toplevel widget categories · 6dd98b0a
      Lars-Peter Clausen 提交于
      DAPM widgets can be classified into four categories:
      	* supply: Supply widgets do not affect the power state of their
      		non-supply widget neighbors and unlike other widgets a
      		supply widget is not powered up when it is on an active
      		path, but when at least on of its neighbors is powered up.
      	* source: A source is a widget that receives data from outside the
      		DAPM graph or generates data. This can for example be a
      		microphone, the playback DMA or a signal generator. A source
      		widget will be considered powered up if there is an active
      		path to a sink widget.
      	* sink: A sink is a widget that transmits data to somewhere outside
      		of the DAPM graph. This can e.g. be a speaker or the capture
      		DMA. A sink widget will be considered powered up if there is
      		an active path from a source widget.
      	* normal: Normal widgets are widgets not covered by the categories
      		above. A normal widget will be considered powered up if it
      		is on an active path between a source widget and a sink
      		widget.
      
      The way the number of input and output paths for a widget is calculated
      depends on its category. There are a bunch of factors which decide which
      category a widget is. Currently there is no formal classification of these
      categories and we calculate the category of the widget based on these
      factors whenever we want to know it. This is at least once for every widget
      during each power update sequence. The factors which determine the category
      of the widgets are mostly static though and if at all change rather seldom.
      This patch introduces three new per widget flags, one for each of non-normal
      widgets categories. Instead of re-computing the category each time we want
      to know them the flags will be checked. For the majority of widgets the
      category is solely determined by the widget id, which means it never changes
      and only has to be set once when the widget is created. The only widgets
      with dynamic categories are:
      
      	snd_soc_dapm_dai_out: Is considered a sink iff the capture stream is
      		active, otherwise normal.
      	snd_soc_dapm_dai_in: Is considered a source iff the playback stream
      		is active, otherwise normal.
      	snd_soc_dapm_input: Is considered a sink iff it has no outgoing
      		paths, otherwise normal.
      	snd_soc_dapm_output: Is considered a source iff it has no incoming
      		paths, otherwise normal.
      	snd_soc_dapm_line: Is considered a sink iff it has no outgoing paths
      		and is considered a source iff it has no incoming paths,
      		otherwise normal.
      
      For snd_soc_dapm_dai_out/snd_soc_dapm_dai_in widgets the category will be
      updated when a stream is started or stopped. For the other dynamic widgets
      the category will be updated when a path connecting to it is added or
      removed.
      
      Introducing those new widget categories allows to make
      is_connected_{output,input}_ep, which are among the hottest paths of the
      DAPM algorithm, more generic and significantly shorter.
      
      The before and after sizes for is_connected_{output,input}_ep are:
      
      On ARM (defconfig + CONFIG_SND_SOC):
      	function                                     old     new   delta
      	is_connected_output_ep                       480     340    -140
      	is_connected_input_ep                        456     352    -104
      
      On amd64 (defconfig + CONFIG_SND_SOC):
      	function                                     old     new   delta
      	is_connected_output_ep                       579     427    -152
      	is_connected_input_ep                        563     427    -136
      
      Which is about a 25%-30% decrease, other architectures are expected to have
      similar numbers. At the same time the size of the snd_soc_dapm_widget struct
      does not change since the new flags are stored in the same word as the
      existing flags.
      
      Note: that since the per widget 'ext' flag was only used to decide whether a
      snd_soc_dapm_input or snd_soc_dapm_output widget was a source or a sink it
      is now unused and can be removed.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      6dd98b0a
    • L
      ASoC: dapm: Do not pretend to support controls for non mixer/mux widgets · 5fe5b767
      Lars-Peter Clausen 提交于
      Controls on a path only have an effect if the sink on the path is either a
      mixer or mux widget. Currently we sort of silently ignore controls on other
      paths, but since they don't do anything having them on other paths does not
      make much sense and it is probably safe to assume that if we see such a path
      it is a mistake in the driver that registered the path. This patch modifies
      snd_soc_dapm_add_path() to report an error if a path with and control is
      encountered where we didn't expect a control. This also allows to simplify
      the code quite a bit.
      
      The patch also moves the connecting of the path lists out of
      dapm_connect_mux() and dapm_connect_mixer() into snd_soc_dapm_add_path().
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      5fe5b767
    • L
      ASoC: dapm: Do not add un-muxed paths to MUX control · 98407efc
      Lars-Peter Clausen 提交于
      Paths that are directly connected to a MUX widget are not affected by
      changes to the MUX's control. Rather than checking if a path is directly
      connected each time the MUX is updated do it only once when MUX is created.
      
      We can also remove the check for e->texts[mux] != NULL, since if that
      condition was true the code would have had already crashed much earlier (And
      generally speaking if a enum's 'texts' entry is NULL it's a bug in the
      driver).
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      98407efc
    • L
      ASoC: dapm: Only mark paths dirty when the connection status changed · 4a201948
      Lars-Peter Clausen 提交于
      Rework soc_dapm_{mixer,mux}_update_power() to only mark a path dirty if the
      connect state if the path has actually changed. This avoids unnecessary
      power state checks for the widgets involved.
      
      Also factor out the common code that is involved in this into a helper
      function.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      4a201948
  2. 22 10月, 2014 5 次提交
    • L
      ASoC: dapm: Remove path 'walked' flag · 130897ac
      Lars-Peter Clausen 提交于
      The 'walked' flag was used to avoid walking paths that have already been
      walked. But since we started caching the number of inputs and outputs of a
      path we never actually get into a situation where we try to walk a path that
      has the 'walked' flag set.
      
      There are two cases in which we can end up walking a path multiple times
      within a single run of is_connected_output_ep() or is_connected_input_ep().
      
      1) If a path splits up and rejoins later:
      
      	     .--> C ---v
      	A -> B         E --> F
      	     '--> D ---^
      
      When walking from A to F we'll end up at E twice, once via C and once via D.
      But since we do a depth first search we'll fully discover the path and
      initialize the number of outputs/inputs of the widget the first time we get
      there. The second time we get there we'll use the cached value and not
      bother to check any of the paths again. So we'll never see a path where
      'walked' is set in this case.
      
      2) If there is a circle:
      
      	A --> B <-- C <-.--> F
      	      '--> D ---'
      
      When walking from A to F we'll end up twice at B. But since there is a
      circle the 'walking' flag will still be set on B once we get there the
      second time. This means we won't look at any of it's outgoing paths. So in
      this case we won't ever see a path where 'walked' is set either.
      
      So it is safe to remove the flag. This on one hand means we remove some
      always true checks from one of the hottest paths of the DAPM algorithm and
      on the other hand means we do not have to do the tedious clearing of the
      flag after checking the number inputs or outputs of a widget.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      130897ac
    • L
      ASoC: dapm: Remove special DAI widget power check functions · cdef2ad3
      Lars-Peter Clausen 提交于
      dapm_adc_check_power() checks if the widget is active, if yes it only checks
      whether there are any connected input paths. Otherwise it calls
      dapm_generic_check_power() which will check for both connected input and
      output paths. But the function that checks for connected output paths will
      return true if the widget is a active sink. Which means the generic power
      check function will work just fine and there is no need for a special power
      check function.
      
      The same applies for dapm_dac_check_power(), but with input and output paths
      reversed.
      
      This patch removes both dapm_adc_check_power() and dapm_dac_check_power()
      and replace their usage with dapm_generic_check_power().
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      cdef2ad3
    • L
      ASoC: dapm: Remove always true path source/sink checks · 7ddd4cd5
      Lars-Peter Clausen 提交于
      A path has always a valid source and a valid sink otherwise we wouldn't add
      it in the first place. Hence all tests that check if sink/source is non NULL
      always evaluate to true and can be removed.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      7ddd4cd5
    • L
      ASoC: dapm: Reduce number of checked paths in dapm_widget_in_card_paths() · cdc4508b
      Lars-Peter Clausen 提交于
      Each widget has a list of all the paths that it is connected to. There is no
      need to iterate over all paths when we are only interested in the paths of a
      specific widget.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      cdc4508b
    • R
      ASoC: dapm: Remove redundant cast · 98ad73c9
      Rasmus Villemoes 提交于
      Both path->name and e->texts[i] have type const char*, so the cast is
      slightly confusing and certainly unnecessary.
      Signed-off-by: NRasmus Villemoes <linux@rasmusvillemoes.dk>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      98ad73c9
  3. 07 10月, 2014 1 次提交
    • D
      ASoC: soc-dapm: fix use after free · e5092c96
      Daniel Mack 提交于
      Coverity spotted the following possible use-after-free condition in
      dapm_create_or_share_mixmux_kcontrol():
      
      If kcontrol is NULL, and (wname_in_long_name && kcname_in_long_name)
      validates to true, 'name' will be set to an allocated string, and be
      freed a few lines later via the 'long_name' alias. 'name', however,
      is used by dev_err() in case snd_ctl_add() fails.
      
      Fix this by adding a jump label that frees 'long_name' at the end of
      the function.
      Signed-off-by: NDaniel Mack <daniel@zonque.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Cc: stable@vger.kernel.org
      e5092c96
  4. 03 10月, 2014 2 次提交
  5. 30 9月, 2014 1 次提交
  6. 05 9月, 2014 1 次提交
    • L
      ASoC: Add support for automatically going to BIAS_OFF on suspend · 86dbf2ac
      Lars-Peter Clausen 提交于
      There is a substantial amount of drivers that in go to SND_SOC_BIAS_OFF on
      suspend and go back to SND_SOC_BIAS_SUSPEND on resume (Often this is even
      the only thing done in the suspend and resume handlers). This patch
      introduces a new suspend_bias_off flag, which when set by a driver will let
      the ASoC core automatically put the device's DAPM context at the
      SND_SOC_BIAS_OFF level during suspend. Once the device is resumed the DAPM
      context will go back to SND_SOC_BIAS_STANDBY (if the context is idle,
      otherwise to SND_SOC_BIAS_ON).
      
      This will allow us to remove a fair bit of duplicated code from the drivers.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      86dbf2ac
  7. 12 8月, 2014 1 次提交
  8. 23 7月, 2014 1 次提交
    • L
      ASoC: Move card field form platform/codec to component · 00200107
      Lars-Peter Clausen 提交于
      Both the snd_soc_codec and snd_soc_platform struct do have a pointer to the
      parent card and both handle this pointer in mostly the same way. This patch
      moves the card field to the component level which will allow further code
      consolidation between platforms and CODECS.
      
      Since there are only a handful of users of the snd_soc_codec struct's card field
      (and none of the snd_soc_platform's) these are update in this patch as well,
      which allows it to be removed from the snd_soc_codec struct.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      00200107
  9. 17 7月, 2014 3 次提交
  10. 22 6月, 2014 6 次提交
    • L
      ASoC: dapm: Remove platform field from widget and dapm context struct · 88a8fe3d
      Lars-Peter Clausen 提交于
      The platform field in the snd_soc_dapm_widget and snd_soc_dapm_context structs
      is now unused can be removed. New code that wants to get the platform for a
      widget or dapm context should use snd_soc_dapm_to_platform(w->dapm) or
      snd_soc_dapm_to_platform(dapm).
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      88a8fe3d
    • L
      ASoC: Add DAPM support at the component level · ce0fc93a
      Lars-Peter Clausen 提交于
      This patch adds full DAPM support at the component level. Previously there was
      only full DAPM support for CODECs and partial DAPM support (e.g. no Mixers nor
      MUXs) for platforms. Having DAPM support at the component level will allow all
      types of components to use DAPM and also help in consolidating the DAPM support
      between CODECs and platforms.
      
      Since the DAPM context is directly embedded into the snd_soc_codec and
      snd_soc_platform struct and the 'dapm' field is directly referenced in a lot of
      drivers moving the field just right now is not possible without causing code
      churn. The approach this patch takes is to add two new fields to the component
      struct. One field which is the pointer to the actual DAPM context used by the
      component and one DAPM context that will be used as the default if no other
      context was specified. For CODECs and platforms the pointer is initialized to
      point to the CODEC or platform DAPM context. All generic code when referencing
      a component's DAPM struct will go via the pointer. This will make it possible to
      eventually seamlessly move the DAPM context from snd_soc_codec and
      snd_soc_platform struct over once all direct references have been eliminated.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      ce0fc93a
    • L
      ASoC: Add a set_bias_level() callback to the DAPM context struct · 68f831c2
      Lars-Peter Clausen 提交于
      Currently the DAPM code directly looks at the CODEC driver struct to get a
      handle to the set_bias_level() callback. This patch adds a new set_bias_level()
      callback to the DAPM context struct. The DAPM code will use this new callback
      instead of the CODEC callback. For CODECs the new callback is set up to call the
      CODEC specific set_bias_level callback(). Not looking directly at the CODEC
      driver struct will allow non CODEC DAPM contexts to implement a set_bias_level()
      callback.
      
      This is also similar to how the seq_notifier() and stream_event() callbacks are
      currently handled.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      68f831c2
    • L
      ASoC: Auto disconnect pins from all DAPM contexts · 7df37884
      Lars-Peter Clausen 提交于
      Currently only pins in CODEC DAPM contexts are automatically marked as
      non-connected if the card has the fully_routed flag set. This makes sense since
      widgets which qualify for auto-disconnection are only found in CODEC DAPM
      contexts. But with componentisation this is going to change, so consider all
      widgets for auto-disconnection.
      
      Also it is probably faster to walk the widgets list only once rather than once
      for each CODEC.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      7df37884
    • L
      ASoC: Move name and id from CODEC/platform to component · f4333203
      Lars-Peter Clausen 提交于
      The component struct already has a name and id field which are initialized to
      the same values as the same fields in the CODEC and platform structs. So remove
      them from the CODEC and platform structs and used the ones from the component
      struct instead.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      f4333203
    • L
      ASoC: Move name_prefix from CODEC to component · 94f99c87
      Lars-Peter Clausen 提交于
      Move the name_prefix from the CODEC struct to the component struct. This will
      eventually allow to specify prefixes for all types of components. It is also
      necessary to make the DAPM code component type independent (i.e. a DAPM context
      does not need to know whether it belongs to a CODEC or a platform or something
      else).
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      94f99c87
  11. 10 6月, 2014 1 次提交
  12. 13 5月, 2014 7 次提交
  13. 06 5月, 2014 1 次提交
  14. 30 4月, 2014 1 次提交
  15. 22 4月, 2014 2 次提交
    • L
      ASoC: dapm: Rename soc_widget_update_bits_locked() to soc_widget_update_bits() · 23d5442b
      Lars-Peter Clausen 提交于
      There is no unlocked version of soc_widget_update_bits_locked() and there is no
      plan to introduce it in the near future, so drop the _locked suffix.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      23d5442b
    • L
      ASoC: Move IO abstraction to the component level · e2c330b9
      Lars-Peter Clausen 提交于
      We currently have two very similar IO abstractions in ASoC, one for CODECs, the
      other for platforms. Moving this to the component level will allow us to unify
      those two. It will also enable us to move the standard kcontrol helpers as well
      as DAPM support to the component level.
      
      The new component level abstraction layer is primarily build around regmap.
      There is a per component pointer for the regmap instance for the underlying
      device. There are four new function snd_soc_component_read(),
      snd_soc_component_write(), snd_soc_component_update_bits() and
      snd_soc_component_update_bits_async(). They have the same signature as their
      regmap counter-part and will internally forward the call one-to-one to regmap.
      If the component it not using regmap it will fallback to using the custom IO
      callbacks. This is done to be able to support drivers that haven't been
      converted to regmap yet, but it is expected that this will eventually be removed
      in the future once all component drivers have been converted to regmap.
      Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      e2c330b9
  16. 21 4月, 2014 1 次提交
    • J
      ASoC: dapm: Fix widget double free with auto-disable DAPM kcontrol · 2697e4fb
      Jarkko Nikula 提交于
      Commit 9e1fda4ae158 ("ASoC: dapm: Implement mixer input auto-disable")
      is trying to free the widget it allocated by snd_soc_dapm_new_control()
      call in dapm_kcontrol_data_alloc() by adding kfree(data->widget) to
      dapm_kcontrol_free().
      
      This is causing a widget double free with auto-disabled DAPM kcontrols
      in sound card unregistration because widgets are already freed before
      dapm_kcontrol_free() is called.
      
      Reason for that is all widgets are added into dapm->card->widgets list
      in snd_soc_dapm_new_control() and freed in dapm_free_widgets() during
      execution of snd_soc_dapm_free().
      
      Now snd_soc_dapm_free() calls for different DAPM contexts happens before
      snd_card_free() call from where the call chain to dapm_kcontrol_free()
      begins:
      
      soc_cleanup_card_resources()
        soc_remove_dai_links()
          soc_remove_link_dais()
            snd_soc_dapm_free(&cpu_dai->dapm)
          soc_remove_link_components()
            soc_remove_platform()
              snd_soc_dapm_free(&platform->dapm)
            soc_remove_codec()
              snd_soc_dapm_free(&codec->dapm)
        snd_soc_dapm_free(&card->dapm)
        snd_card_free()
          snd_card_do_free()
            snd_device_free_all()
              snd_device_free()
                snd_ctl_dev_free()
                  snd_ctl_remove()
                    snd_ctl_free_one()
                      dapm_kcontrol_free()
      
      This wasn't making harm with ordinary DAPM kcontrols since data->widget is NULL for
      them.
      
      Fixes: 9e1fda4ae158 (ASoC: dapm: Implement mixer input auto-disable)
      Signed-off-by: NJarkko Nikula <jarkko.nikula@linux.intel.com>
      Acked-by: NLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: NMark Brown <broonie@linaro.org>
      Cc: stable@vger.kernel.org
      2697e4fb