summaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-dapm.c
Commit message (Collapse)AuthorAgeFilesLines
* ASoC: dapm - Fix check for codec context in dapm_power_widgets().Liam Girdwood2012-01-161-1/+1
| | | | | | | | Fixes a NULL pointer dereference in dapm_power_widgets() if the dapm context has no codec. Signed-off-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Dynamically allocate the rtd device for a non-empty release()Mark Brown2012-01-101-2/+1
| | | | | | | The device model needs a release() function so it can free devices when they become dereferenced. Do that for rtds. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Take a pm_runtime reference on DAPM devices that are enabledMark Brown2011-12-081-0/+7
| | | | | | | As for PCMs take a runtime power management reference to devices that are in a non-off bias, avoiding the need to do this in individual drivers. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Add signal generator widget typeMark Brown2011-12-021-0/+7
| | | | | | | | | A signal generator behaves as an input would but is not considered for any of the special behaviour associated with external input pins. This is especially useful when automatically working out not connected widgets. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
* ASoC: Log automatic pin disconnection per CODEC rather than per cardMark Brown2011-11-271-3/+3
| | | | | | | This makes the output a bit less confusing on multi-CODEC systems as the same pin may appear in multiple CODECs. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Implement fully_routed card propertyStephen Warren2011-11-231-0/+73
| | | | | | | | | | | | | | | | | | | | | | | | A card is fully routed if the DAPM route table describes all connections on the board. When a card is fully routed, some operations can be automated by the ASoC core. The first, and currently only, such operation is described below, and implemented by this patch. Codecs often have a large number of external pins, and not all of these pins will be connected on all board designs. Some machine drivers therefore call snd_soc_dapm_nc_pin() for all the unused pins, in order to tell the ASoC core never to activate them. However, when a card is fully routed, the information needed to derive the set of unused pins is present in card->dapm_routes. In this case, have the ASoC core automatically call snd_soc_dapm_nc_pin() for each unused codec pin. This has been tested with soc/tegra/tegra_wm8903.c and soc/tegra/trimslice.c. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Fix DAPM sync for TLV320AIC3x custom DAPM widgetMark Brown2011-10-101-1/+2
| | | | | | | We really should be doing this in the core, not in a driver... Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Tested-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
* ASoC: Cache connected input and output recursionsMark Brown2011-10-091-15/+45
| | | | | | | | | | | | | | | The number of connected input and output endpoints for a given widgets can't change during a DAPM run so there is no need to redo the recursion through branches of the tree we've already visited. Doing this on one of my test systems gives an improvement of: Power Path Neighbour Before: 63 607 731 After: 63 141 181 which scales up well as more widgets are involved in paths. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Assign power_check when we allocate DAPM widgetsMark Brown2011-10-081-28/+39
| | | | | | | This ensures none of the rest of the code ever encounters a widget which does not have a power check function. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Suppress early calls to snd_soc_dapm_sync()Mark Brown2011-10-081-0/+7
| | | | | | | | | | Ensure we only have one sync during the initial startup of the card by making snd_soc_dapm_sync() a noop on non-instantiated cards. This avoids any bounces due to things like jacks reporting their initial state on partially initialised cards. The callers that don't also get called at runtime should just be removed. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Use dapm_mark_dirty() for new DAPM widgets for consistencyMark Brown2011-10-051-1/+1
| | | | Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Stop checking for supplied widgets after we find the firstMark Brown2011-10-051-6/+3
| | | | | | | | | | | | | We don't really care how many widgets a supply is supplying, we just care if the number is non-zero. This didn't actually produce any improvement in the test cases I've been using but seems obviously sensible enough that I'm pushing it out anyway. We could do a similar thing for other widgets but this may be unhelpful for further refactorings Liam was working on aiming to allow us to identify connected audio paths. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Don't mark the outputs of supplies as dirty on state changesMark Brown2011-10-051-4/+11
| | | | | | | | | | | | | | | The whole point of supply widgets is that they aren't inputs to their sinks so a state change in a supply should never affect the state of the widget being supplied and we don't need to mark them as dirty. Power Path Neighbour Before: 69 727 905 After: 63 607 731 This is particularly useful where supplies affect large portions of the chip (eg, a bandgap supplying the analogue sections). Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Only run power_check() on a widget once per runMark Brown2011-10-051-2/+13
| | | | | | | | | | | | | | | | Some widgets will get power_check() run on them more than once during a DAPM run, most commonly due to supply widgets checking to see if their consumers are powered up. It's wasteful to do this so cache the result of power_check() during a run. For one system I tested this on I got an improvement of: Power Path Neighbour Before: 106 970 1186 After: 69 727 905 from this. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Add verbose debugging showing why widgets get marked dirtyMark Brown2011-10-051-11/+15
| | | | | | | | | Help diagnose why we're checking widgets by providing some logging when we first dirty them. This should possibly be a trace point if it's useful but can be absurdly verbose if enabled, we can always change it later if desired. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Reduce the number of neigbours we mark dirty when updating powerMark Brown2011-10-041-6/+20
| | | | | | | | | | | | | | | | | | If two widgets are not currently connected then there is no need to propagate a power state change between them as we mark the affected widgets when we change a connection. Similarly if a neighbour widget is already in the state being set for the current widget then there is no need to recheck. On one system I tested this gave: Power Path Neighbour Before: 114 1066 1327 After: 106 970 1186 which is an improvement, although relatively small. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Do DAPM power checks only for widgets changed since last runMark Brown2011-10-041-6/+55
| | | | | | | | | | | | | | | | | | | | In order to reduce the number of DAPM power checks we run keep a list of widgets which have been changed since the last DAPM run and iterate over that rather than the full widget list. Whenever we change the power state for a widget we add all the source and sink widgets it has to the dirty list, ensuring that all widgets in the path are checked. This covers more widgets than we need to as some of the neighbour widgets won't be connected but it's simpler as a first step. On one system I tried this gave: Power Path Neighbour Before: 207 1939 2461 After: 114 1066 1327 which seems useful. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Mark headphone, mic, speaker and line widgets as always connectedMark Brown2011-10-041-4/+4
| | | | | | | | We're not actually doing any dynamic power management based on connection and output drivers (which are pretty much the same thing) are marked as unconditionally connected already. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Factor out widget power check operationMark Brown2011-10-041-11/+10
| | | | | | | We've got the same code in two different places, let's have it in a single place instead. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Ensure all DAPM widgets have a power check callbackMark Brown2011-10-041-3/+8
| | | | | | Makes the code simpler. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Move bias level decision into main dapm_power_widgets()Mark Brown2011-10-041-21/+23
| | | | | | | | | | | | | | Future patches will try to reduce the number of widgets we check on each DAPM run but we're still going to need to look and see if the devices is on at all so we can manage the overall device bias. Move these checks out into the main dapm_power_widgets() function so we don't have to think about them for now. Once we're doing more incremental updates it'll probably be worth using refcounts for each bias level to avoid having to do the sweep over all widgets but that's not going to be where the big performance wins are. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Factor write of widget power out into a separate functionMark Brown2011-10-041-11/+18
| | | | | | | Split the decision about what the new power should be out from the implementation of that decision. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Also count neighbour checks for suppliesMark Brown2011-09-281-0/+2
| | | | | | Missed when the stat was originally added. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Don't force bias on ground referenced devicesMark Brown2011-09-231-2/+5
| | | | | | | | | | | | | | | Currently we force all devices in the system to be at the same bias level. This is due to concerns about power or pop/click impacts from either ramping VMID or mismatching VMID on the analogue I/O lines between connected devices but does mean we power devices up more often than we really need to. If a device flags idle_bias_off this will usually mean that it's either all digital or ground referenced (in which case the idle and powered bias levels are identical) so this concern does not apply and we can save some power by leaving it off when not needed itself. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Add another DAPM stat for neighbour checksMark Brown2011-09-221-0/+4
| | | | | | | | The number of times we look at a potentially connected neighbour is just as important as the number of times we actually recurse into looking at that neighbour so also collect that statistic. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Factor out per-widget DAPM power checksMark Brown2011-09-211-52/+60
| | | | | | | The indentation is getting a little deep. Should be straight code motion, no functional changes. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Trace and collect statistics for DAPM graph walkingMark Brown2011-09-211-0/+17
| | | | | | | | | | | | | | | | | | One of the longest standing areas for improvement in ASoC has been the DAPM algorithm - it repeats the same checks many times whenever it is run and makes no effort to limit the areas of the graph it checks meaning we do an awful lot of walks over the full graph. This has never mattered too much as the size of the graph has generally been small in relation to the size of the devices supported and the speed of CPUs but it is annoying. In preparation for work on improving this insert a trace point after the graph walk has been done. This gives us specific timing information for the walk, and in order to give quantifiable (non-benchmark) numbers also count every time we check a link or check the power for a widget and report those numbers. Substantial changes in the algorithm may require tweaks to the stats but they should be useful for simpler things. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Display the error code when we fail to add a DAPM controlMark Brown2011-09-191-2/+2
| | | | | | | Useful for diagnostics. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
* Merge branch 'for-3.1' into for-3.2Mark Brown2011-08-311-1/+1
|\
| * ASoC: soc-dapm: Fix parameter comment for snd_soc_dapm_freePeter Ujfalusi2011-08-311-1/+1
| | | | | | | | | | | | | | We have dapm_context instead of codec parameter. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | ASoC: DAPM: Allow multiple mixer sources to be routed via the same switchLars-Peter Clausen2011-08-161-1/+5
| | | | | | | | | | | | | | | | | | | | Currently it is only possible to route one source per switch into a mixer. This patch modifies the code, so that it is possible to route multiple sources into a mixer via the same switch. One use-case for this is routing a stereo channel pair into a mono-mixer via the same switch. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | ASoC: dapm - change stream event dbg to vdgbLiam Girdwood2011-07-251-1/+1
| | | | | | | | | | | | | | | | Stream event debug can be noisy on larger audio devices so improve the debug SNR by changing it to the verbose level. Signed-off-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* | ASoC: dapm - Add DAPM stream completion event.Liam Girdwood2011-07-251-0/+4
|/ | | | | | | | | | | | | In preparation for Dynamic PCM (AKA DSP) support. This adds a callback function to be called at the completion of a DAPM stream event. This can be used by DSP components to perform calculations based on DAPM graphs after completion of stream events. Signed-off-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: dapm - Add methods to retrieve snd_card and soc_card from dapm context.Liam Girdwood2011-07-201-0/+30
| | | | | | | | | | In preparation for ASoC Dynamic PCM (AKA DSP) support. Provide convenience methods to retrieve the soc_card or snd_card from a DAPM context. Signed-off-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Don't use -1 to boostrap subseq so it can be used by driversMark Brown2011-07-171-1/+1
| | | | | | | Makes life a little easier if you want to add subsequences to an existing driver as you can use -1 to put things at the start of sequences. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: core - Add platform widget IOLiam Girdwood2011-07-051-2/+11
| | | | | | | Allow platform driver widgets to perform any IO required for DAPM. Signed-off-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Fix DAPM sequence run for per-widget I/O methodsMark Brown2011-06-201-0/+6
| | | | | | | | | | | | | Previously we were using the DAPM context rather than a widget as the argument for update_bits() so we didn't need to care that our list walk of widgets left us one beyond the end of the list. Now we're using them for the register update we need to make sure we're pointing at an actual widget not the list_head. Fix originally suggested by Liam on IM. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
* ASoC: dapm - Refactor widget IO functions in preparation for platform widgets.Liam Girdwood2011-06-141-6/+43
| | | | | | | | | | | | | | This time with soc_widget_update_bits reflecting recent soc_update_bits changes. Currently widget IO is tightly coupled to the CODEC drivers. Future platform DSP devices have mixer components that can alter power usage and hence require full DAPM support. This provides a generic widget IO operation wrapper in preparation for future patches that implement platform driver DAPM. Signed-off-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Add weak routes for sidetone style pathsMark Brown2011-06-131-0/+87
| | | | | | | | | | | | | | | | | | Normally DAPM will power up any connected audio path. This is not ideal for sidetone paths as with sidetone paths the audio path is not wanted in itself, it is only desired if the two paths it provides a sidetone between are both active. If the sidetone path causes a power up then it can be hard to minimise pops as we first power up either the sidetone or the main output path and then power the other, with the second power up potentially introducing a DC offset. Address this by introducing the concept of a weak path. If a path is marked as weak then DAPM will ignore that path when walking the graph, though all the relevant controls are still available to the application layer to allow these paths to be configured. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
* Merge branch 'for-3.0' into for-3.1Mark Brown2011-06-091-9/+8
|\
| * ASoC: snd_soc_new_{mixer,mux,pga} make sure to use right DAPM contextLars-Peter Clausen2011-06-091-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | Currently it is possible that snd_soc_new_{mixer,mux,pga} is called with a DAPM context not matching the widgets context. This can lead to a wrong prefix_len calculation, which will result in undefined behaviour. To avoid this always use the DAPM context from the widget itself. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: stable@kernel.org
* | ASoC: Only provide a default bias level update for CODEC contextsMark Brown2011-06-061-4/+7
| | | | | | | | | | | | | | | | This allows the card driver to use the bias level variable more easily in multi component systems. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
* | ASoC: Add context parameter to card DAPM callbacksMark Brown2011-06-061-2/+2
| | | | | | | | | | | | | | | | | | The card callback will get called for each DAPM context in the card so it can be useful for it to know which device is currently undergoing a transition. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
* | ASoC: Simplify logic in snd_soc_dapm_set_bias_level()Mark Brown2011-06-061-10/+12
| | | | | | | | | | | | | | No functional changes but much less indentation. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
* | ASoC: Remove trace for DAPM bias level loggingMark Brown2011-06-061-18/+0
| | | | | | | | | | | | | | It's redundant now thanks to the use of the generic trace infrastructure. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
* | ASoC: Indentation fix for null loop operationMark Brown2011-06-061-1/+1
| | | | | | | | | | | | | | More with the legibility. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
* | ASoC: Don't bring the CODEC up to full power for supplies and biasesMark Brown2011-06-061-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | If the only widgets active within a CODEC are supplies and micbiases we are not passing audio, we are probably just doing microphone detection. This will not generally require either fully accurate reference voltages or much power so If this turns out to be unsuitable for some systems we can provide a facility to override this decision. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
* | ASoC: Specify target bias state directly as a bias stateMark Brown2011-06-061-27/+33
|/ | | | | | | | | | Rather than a simple flag to say if we want the DAPM context to be at full power specify the target bias state. This should have no current effect but is a bit more direct and so makes it easier to change our decisions about the which bias state to go into in future. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@ti.com>
* ASoC: Fix dapm_is_shared_kcontrol so everything isn't sharedStephen Warren2011-05-271-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit af46800 ("ASoC: Implement mux control sharing") introduced function dapm_is_shared_kcontrol. When this function returns true, the naming of DAPM controls is derived from the kcontrol_new. Otherwise, the name comes from the widget (and possibly a widget's naming prefix). A bug in the implementation of dapm_is_shared_kcontrol made it return 1 in all cases. Hence, that commit caused a change in control naming for all controls instead of just shared controls. Specifically, a control is always considered shared because it is always compared against itself. Solve this by never comparing against the widget containing the control being created. Equally, controls should never be shared between DAPM contexts; when the same codec is instantiated multiple times, the same kcontrol_new will be used. However, the control should no be shared between the multiple instances. I tested that with the Tegra WM8903 driver: * Shared is now mostly 0 as expected, and sometimes 1. * The expected controls are still generated after this change. However, I don't have any systems that have a widget/control naming prefix, so I can't test that aspect. Thanks for Jarkko Nikula for pointing out how to fix this. Reported-by: Liam Girdwood <lrg@ti.com> Tested-by: Jarkko Nikula <jhnikula@gmail.com> Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
* ASoC: Fix power down for widgetless per-card DAPM context caseJarkko Nikula2011-05-261-1/+1
| | | | | | | | | | | | | | | | | | | | Commit 52ba67b ("ASoC: Force all DAPM contexts into the same bias state") powers up all the DAPM contexts in a card if any DAPM context becomes active. Unfortunately power down newer happens if per-card DAPM context doesn't have any widgets. Reason for this is that power state of per-card DAPM context without widgets is never cleared and thus all the DAPM contexts remain permanently active. Test for widgetless calling DAPM context in dapm_power_widgets() doesn't work for per-card DAPM context since power change is never originating from widgetless per-card DAPM context. Fix this by pre-clearing power state flag of non-codec DAPM context at the beginning of power sequence. Signed-off-by: Jarkko Nikula <jhnikula@gmail.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
OpenPOWER on IntegriCloud