Commit Graph

19 Commits

Author SHA1 Message Date
Jarkko Nikula 535787b6ae ASoC: Allow use sleeping gpio in soc-jack
It is safe to use sleeping gpio in snd_soc_jack_gpio_detect as it is not
called from interrupt context. This avoids WARN_ON from __gpio_get_value
if sleeping gpio is registered for jack.

Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-02-11 11:17:43 +00:00
Vinod Koul fa9879edeb ASoC: add support for multiple jack types
This patch adds soc-jack support for adding voltage zones and for
detecting jack type

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Harsha Priya <priya.harsha@intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2011-02-09 23:02:43 +00:00
Mark Brown 3028eb8c51 ASoC: Add trace events for jack detection
As jack detection can trigger DAPM and the latency in debouncing can create
confusing windows in operation provide some trace events which will hopefully
help in diagnostics. The soc-jack core traces all reports that it gets and
the resulting notifications to upper layers. An event for jack IRQs is also
provided for instrumentation of debounce, and used in the GPIO jack code.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
2010-12-06 14:13:42 +00:00
Jarkko Nikula 505fb824e7 ASoC: Do not include soc-dapm.h
There is no need to include soc-dapm.h since soc.h includes it.

Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2010-11-22 14:04:41 +00:00
Mark Brown f9a67059d4 ASoC: Prevent system suspend while debouncing wakeup capable GPIO jacks
If the device associated with a GPIO jack is wakeup capable then disable
suspend while we're debouncing the jack so that we skip suspends that race
with the jack.

Note that currently the GPIO based jack has a CODEC associated with it
which we're using right now. These jacks should be reparented against the
card itself and this code adjusted.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
2010-11-15 11:44:43 +00:00
Liam Girdwood ce6120cca2 ASoC: Decouple DAPM from CODECs
Decoupling Dynamic Audio Power Management (DAPM) from codec devices is
required when developing ASoC further. Such as for other ASoC components to
have DAPM widgets or when extending DAPM to handle cross-device paths.

This patch decouples DAPM related variables from struct snd_soc_codec and
moves them to new struct snd_soc_dapm_context that is used to encapsulate
DAPM context of a device. ASoC core and API of DAPM functions are modified
to use DAPM context instead of codec.

This patch does not change current functionality and a large part of changes
come because of structure and internal API changes.

Core implementation is from Liam Girdwood <lrg@slimlogic.co.uk> with some
minor core changes, codecs and machine driver conversions from
Jarkko Nikula <jhnikula@gmail.com>.

Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Manuel Lauss <manuel.lauss@googlemail.com>
Cc: Mike Frysinger <vapier.adi@gmail.com>
Cc: Cliff Cai <cliff.cai@analog.com>
Cc: Kevin Hilman <khilman@deeprootsystems.com>
Cc: Ryan Mallon <ryan@bluewatersys.com>
Cc: Timur Tabi <timur@freescale.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Arnaud Patard (Rtp) <arnaud.patard@rtp-net.org>
Cc: Wan ZongShun <mcuos.com@gmail.com>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Jassi Brar <jassi.brar@samsung.com>
Cc: Daniel Gloeckner <dg@emlix.com>
Cc: Kuninori Morimoto <morimoto.kuninori@renesas.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2010-11-06 11:28:29 -04:00
Mark Brown 3f58fd84b0 ASoC: Convert soc-jack code to use request_any_context_irq()
Allow the standard soc-jack GPIO based jack handling to handle the use of
GPIOs which may sleep (such as those on GPIO expanders) by converting the
code to use request_any_context_irq().

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
2010-11-03 12:37:00 -04:00
Mark Brown 4c14d78e8a ASoC: Use delayed work for debounce of GPIO based jacks
Rather than block the workqueue by sleeping to do the debounce use delayed
work to implement the debounce time. This should also means that we extend
the debounce time on each new bounce, potentially allowing shorter debounce
times for clean insertions.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
2010-10-07 12:58:56 -07:00
Liam Girdwood f0fba2ad1b ASoC: multi-component - ASoC Multi-Component Support
This patch extends the ASoC API to allow sound cards to have more than one
CODEC and more than one platform DMA controller. This is achieved by dividing
some current ASoC structures that contain both driver data and device data into
structures that only either contain device data or driver data. i.e.

 struct snd_soc_codec    --->  struct snd_soc_codec (device data)
                          +->  struct snd_soc_codec_driver (driver data)

 struct snd_soc_platform --->  struct snd_soc_platform (device data)
                          +->  struct snd_soc_platform_driver (driver data)

 struct snd_soc_dai      --->  struct snd_soc_dai (device data)
                          +->  struct snd_soc_dai_driver (driver data)

 struct snd_soc_device   --->  deleted

This now allows ASoC to be more tightly aligned with the Linux driver model and
also means that every ASoC codec, platform and (platform) DAI is a kernel
device. ASoC component private data is now stored as device private data.

The ASoC sound card struct snd_soc_card has also been updated to store lists
of it's components rather than a pointer to a codec and platform. The PCM
runtime struct soc_pcm_runtime now has pointers to all its components.

This patch adds DAPM support for ASoC multi-component and removes struct
snd_soc_socdev from DAPM core. All DAPM calls are now made on a card, codec
or runtime PCM level basis rather than using snd_soc_socdev.

Other notable multi-component changes:-

 * Stream operations now de-reference less structures.
 * close_delayed work() now runs on a DAI basis rather than looping all DAIs
   in a card.
 * PM suspend()/resume() operations can now handle N CODECs and Platforms
   per sound card.
 * Added soc_bind_dai_link() to bind the component devices to the sound card.
 * Added soc_dai_link_probe() and soc_dai_link_remove() to probe and remove
   DAI link components.
 * sysfs entries can now be registered per component per card.
 * snd_soc_new_pcms() functionailty rolled into dai_link_probe().
 * snd_soc_register_codec() now does all the codec list and mutex init.

This patch changes the probe() and remove() of the CODEC drivers as follows:-

 o Make CODEC driver a platform driver
 o Moved all struct snd_soc_codec list, mutex, etc initialiasation to core.
 o Removed all static codec pointers (drivers now support > 1 codec dev)
 o snd_soc_register_pcms() now done by core.
 o snd_soc_register_dai() folded into snd_soc_register_codec().

CS4270 portions:
Acked-by: Timur Tabi <timur@freescale.com>

Some TLV320aic23 and Cirrus platform fixes.
Signed-off-by: Ryan Mallon <ryan@bluewatersys.com>

TI CODEC and OMAP fixes
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
Signed-off-by: Jarkko Nikula <jhnikula@gmail.com>

Samsung platform and misc fixes :-
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Jassi Brar <jassi.brar@samsung.com>
Signed-off-by: Seungwhan Youn <sw.youn@samsung.com>

MPC8610 and PPC fixes.
Signed-off-by: Timur Tabi <timur@freescale.com>

i.MX fixes and some core fixes.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

J4740 platform fixes:-
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

CC: Tony Lindgren <tony@atomide.com>
CC: Nicolas Ferre <nicolas.ferre@atmel.com>
CC: Kevin Hilman <khilman@deeprootsystems.com>
CC: Sascha Hauer <s.hauer@pengutronix.de>
CC: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
CC: Kuninori Morimoto <morimoto.kuninori@renesas.com>
CC: Daniel Gloeckner <dg@emlix.com>
CC: Manuel Lauss <mano@roarinelk.homelinux.net>
CC: Mike Frysinger <vapier.adi@gmail.com>
CC: Arnaud Patard <apatard@mandriva.com>
CC: Wan ZongShun <mcuos.com@gmail.com>

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
2010-08-12 14:00:00 +01:00
Mark Brown 3a278a0c65 ASoC: Allow reporting of NULL jacks
Follow the core jack implementation and allow reporting on the status
of NULL jacks, avoiding the need to check in detection implementations.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
2010-04-23 17:07:10 +01:00
Mark Brown d5021ec9fc ASoC: Add a notifier for jack status changes
Some systems provide both mechanical and electrical detection of jack
status changes. On such systems power savings can be achieved by only
enabling the electrical detection methods when physical insertion has
been detected.

Begin supporting such systems by providing a notifier for jack status
changes which can be used to trigger any reconfiguration.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
2010-03-22 17:20:57 +00:00
Joonyoung Shim c871a05315 ASoC: Add jack_status_check callback function for GPIO jacks
The jack_status_check callback function is the interface to check the
status of the jack. Some target provides the method to distinguish what
is the jack inserted - headphone jack, microphone jack, tvout jack, etc,
so we can implement it using the jack_status_check function.

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2009-11-12 16:45:53 +00:00
Julia Lawall 4f066173fe ASoC: Move dereference after NULL test
If the NULL test on jack is needed, then the derefernce should be after the
NULL test.

A simplified version of the semantic match that detects this problem is as
follows (http://coccinelle.lip6.fr/):

// <smpl>
@match exists@
expression x, E;
identifier fld;
@@

* x->fld
  ... when != \(x = E\|&x\)
* x == NULL
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2009-10-19 16:12:35 +01:00
Lars-Peter Clausen b8e22c1fe3 ASoC: jack: Fix race in snd_soc_jack_add_gpios
The irq can fire as soon as it has been requested, thus all fields accessed
from within the irq handler must be initialized prior to requesting the irq.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2009-07-31 22:38:43 +01:00
Janusz Krzysztofik 178b699c25 ASoC: Jack handling enhancements as suggested by subsystem maintainer
The patch adds a few small enhancements to the ASoC jack handling, as
suggested by Mark in his comments to my Amstrad Delta driver, and a few fixes
for related bugs found while learning Mark's code and testing results.

Enhancements:
1. Update status of an ASoC jack while associating it with new gpios.
2. Really update DAPM pins while associating them with an ASoC jack.
3. Export ASoC jack gpios over gpiolib sysfs for diagnostic purposes.

Fixes:
1. Apply mask on jack status report before using it, just for case.
2. While updating jack associated DAPM pins, use full resulting jack status,
   not the status report passed as an argument.

Created and tested on linux-2.6.31-rc3

Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2009-07-24 11:28:59 +01:00
Mark Brown 26bd7b496c ASoC: Staticise workqueue function for GPIO jack detection
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2009-03-06 13:37:19 +00:00
Lopez Cruz, Misael ec67624d33 ASoC: Add GPIO support for jack reporting interface
Add GPIO support to jack reporting framework in ASoC using gpiolib calls.
The gpio support exports two new functions: snd_soc_jack_add_gpios and
snd_soc_jack_free_gpios.

Client drivers using gpio feature must pass an array of jack_gpio pins
belonging to a specific jack to the snd_soc_jack_add_gpios function. The
framework will request the gpios, set the data direction and request irq.
The framework will update power status of related jack_pins when an event on
the gpio pins comes according to the reporting bits defined for each gpio.

All gpio resources allocated when adding jack_gpio pins can be released
using snd_soc_jack_free_gpios function.

Signed-off-by: Misael Lopez Cruz <x0052729@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2009-03-04 14:47:38 +00:00
Mark Brown 6627a653bc ASoC: Push the codec runtime storage into the card structure
This is a further stage on the road to refactoring away the ASoC
platform device.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2009-01-27 10:30:54 +00:00
Mark Brown 8a2cd6180f ASoC: Add jack reporting interface
This patch adds a jack reporting interface to ASoC.  This wraps the ALSA
core jack detection functionality and provides integration with DAPM to
automatically update the power state of pins based on the jack state.

Since embedded platforms can have multiple detecton methods used for a
single jack (eg, separate microphone and headphone detection) the report
function allows specification of which bits are being updated on a given
report.

The expected usage is that machine drivers will create jack objects and
then configure jack detection methods to update that jack.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2009-01-09 10:31:31 +00:00