summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm_hubs.c
diff options
context:
space:
mode:
authorMark Brown2011-07-12 08:25:03 +0200
committerMark Brown2011-07-13 17:38:04 +0200
commitd96ca3cd0bcefdcd1d9ad1f2610dcd959fccd252 (patch)
treee7dddc5b7104d02ae765081024c4e9ea1bf2a3ba /sound/soc/codecs/wm_hubs.c
parentASoC: Use late enable handling for direct voice, speaker and headphone (diff)
downloadkernel-qcow2-linux-d96ca3cd0bcefdcd1d9ad1f2610dcd959fccd252.tar.gz
kernel-qcow2-linux-d96ca3cd0bcefdcd1d9ad1f2610dcd959fccd252.tar.xz
kernel-qcow2-linux-d96ca3cd0bcefdcd1d9ad1f2610dcd959fccd252.zip
ASoC: Implement DC servo completion IRQ handling for wm_hubs devices
The individual devices should set the flag dcs_done_irq in the hubs shared data structure to indicate that they will flag the interrupt by calling wm_hubs_dcs_done(). Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm_hubs.c')
-rw-r--r--sound/soc/codecs/wm_hubs.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c
index 7e60e2279671..5c2d5657b472 100644
--- a/sound/soc/codecs/wm_hubs.c
+++ b/sound/soc/codecs/wm_hubs.c
@@ -63,9 +63,11 @@ static const struct soc_enum speaker_mode =
static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op)
{
+ struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
unsigned int reg;
int count = 0;
unsigned int val;
+ unsigned long timeout;
val = op | WM8993_DCS_ENA_CHAN_0 | WM8993_DCS_ENA_CHAN_1;
@@ -74,18 +76,37 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op)
dev_dbg(codec->dev, "Waiting for DC servo...\n");
- do {
- count++;
- msleep(1);
+ if (hubs->dcs_done_irq) {
+ timeout = wait_for_completion_timeout(&hubs->dcs_done,
+ msecs_to_jiffies(500));
+ if (timeout == 0)
+ dev_warn(codec->dev, "No DC servo interrupt\n");
+
reg = snd_soc_read(codec, WM8993_DC_SERVO_0);
- dev_dbg(codec->dev, "DC servo: %x\n", reg);
- } while (reg & op && count < 400);
+ } else {
+ do {
+ count++;
+ msleep(1);
+ reg = snd_soc_read(codec, WM8993_DC_SERVO_0);
+ dev_dbg(codec->dev, "DC servo: %x\n", reg);
+ } while (reg & op && count < 400);
+ }
if (reg & op)
dev_err(codec->dev, "Timed out waiting for DC Servo %x\n",
op);
}
+irqreturn_t wm_hubs_dcs_done(int irq, void *data)
+{
+ struct wm_hubs_data *hubs = data;
+
+ complete(&hubs->dcs_done);
+
+ return IRQ_HANDLED;
+}
+EXPORT_SYMBOL_GPL(wm_hubs_dcs_done);
+
/*
* Startup calibration of the DC servo
*/
@@ -863,8 +884,11 @@ EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_controls);
int wm_hubs_add_analogue_routes(struct snd_soc_codec *codec,
int lineout1_diff, int lineout2_diff)
{
+ struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
struct snd_soc_dapm_context *dapm = &codec->dapm;
+ init_completion(&hubs->dcs_done);
+
snd_soc_dapm_add_routes(dapm, analogue_routes,
ARRAY_SIZE(analogue_routes));