2 * wm_hubs.c -- WM8993/4 common code
4 * Copyright 2009 Wolfson Microelectronics plc
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/module.h>
15 #include <linux/moduleparam.h>
16 #include <linux/init.h>
17 #include <linux/delay.h>
19 #include <linux/i2c.h>
20 #include <linux/mfd/wm8994/registers.h>
21 #include <sound/core.h>
22 #include <sound/pcm.h>
23 #include <sound/pcm_params.h>
24 #include <sound/soc.h>
25 #include <sound/initval.h>
26 #include <sound/tlv.h>
31 const DECLARE_TLV_DB_SCALE(wm_hubs_spkmix_tlv
, -300, 300, 0);
32 EXPORT_SYMBOL_GPL(wm_hubs_spkmix_tlv
);
34 static const DECLARE_TLV_DB_SCALE(inpga_tlv
, -1650, 150, 0);
35 static const DECLARE_TLV_DB_SCALE(inmix_sw_tlv
, 0, 3000, 0);
36 static const DECLARE_TLV_DB_SCALE(inmix_tlv
, -1500, 300, 1);
37 static const DECLARE_TLV_DB_SCALE(earpiece_tlv
, -600, 600, 0);
38 static const DECLARE_TLV_DB_SCALE(outmix_tlv
, -2100, 300, 0);
39 static const DECLARE_TLV_DB_SCALE(spkmixout_tlv
, -1800, 600, 1);
40 static const DECLARE_TLV_DB_SCALE(outpga_tlv
, -5700, 100, 0);
41 static const unsigned int spkboost_tlv
[] = {
43 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0),
44 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0),
46 static const DECLARE_TLV_DB_SCALE(line_tlv
, -600, 600, 0);
48 static const char *speaker_ref_text
[] = {
53 static const struct soc_enum speaker_ref
=
54 SOC_ENUM_SINGLE(WM8993_SPEAKER_MIXER
, 8, 2, speaker_ref_text
);
56 static const char *speaker_mode_text
[] = {
61 static const struct soc_enum speaker_mode
=
62 SOC_ENUM_SINGLE(WM8993_SPKMIXR_ATTENUATION
, 8, 2, speaker_mode_text
);
64 static void wait_for_dc_servo(struct snd_soc_codec
*codec
, unsigned int op
)
66 struct wm_hubs_data
*hubs
= snd_soc_codec_get_drvdata(codec
);
72 val
= op
| WM8993_DCS_ENA_CHAN_0
| WM8993_DCS_ENA_CHAN_1
;
74 /* Trigger the command */
75 snd_soc_write(codec
, WM8993_DC_SERVO_0
, val
);
77 dev_dbg(codec
->dev
, "Waiting for DC servo...\n");
79 if (hubs
->dcs_done_irq
)
87 if (hubs
->dcs_done_irq
)
88 wait_for_completion_timeout(&hubs
->dcs_done
,
89 msecs_to_jiffies(250));
93 reg
= snd_soc_read(codec
, WM8993_DC_SERVO_0
);
94 dev_dbg(codec
->dev
, "DC servo: %x\n", reg
);
95 } while (reg
& op
&& count
< timeout
);
98 dev_err(codec
->dev
, "Timed out waiting for DC Servo %x\n",
102 irqreturn_t
wm_hubs_dcs_done(int irq
, void *data
)
104 struct wm_hubs_data
*hubs
= data
;
106 complete(&hubs
->dcs_done
);
110 EXPORT_SYMBOL_GPL(wm_hubs_dcs_done
);
113 * Startup calibration of the DC servo
115 static void calibrate_dc_servo(struct snd_soc_codec
*codec
)
117 struct wm_hubs_data
*hubs
= snd_soc_codec_get_drvdata(codec
);
119 u16 reg
, reg_l
, reg_r
, dcs_cfg
, dcs_reg
;
121 switch (hubs
->dcs_readback_mode
) {
123 dcs_reg
= WM8994_DC_SERVO_4E
;
126 dcs_reg
= WM8993_DC_SERVO_3
;
130 /* If we're using a digital only path and have a previously
131 * callibrated DC servo offset stored then use that. */
132 if (hubs
->class_w
&& hubs
->class_w_dcs
) {
133 dev_dbg(codec
->dev
, "Using cached DC servo offset %x\n",
135 snd_soc_write(codec
, dcs_reg
, hubs
->class_w_dcs
);
136 wait_for_dc_servo(codec
,
137 WM8993_DCS_TRIG_DAC_WR_0
|
138 WM8993_DCS_TRIG_DAC_WR_1
);
142 if (hubs
->series_startup
) {
143 /* Set for 32 series updates */
144 snd_soc_update_bits(codec
, WM8993_DC_SERVO_1
,
145 WM8993_DCS_SERIES_NO_01_MASK
,
146 32 << WM8993_DCS_SERIES_NO_01_SHIFT
);
147 wait_for_dc_servo(codec
,
148 WM8993_DCS_TRIG_SERIES_0
|
149 WM8993_DCS_TRIG_SERIES_1
);
151 wait_for_dc_servo(codec
,
152 WM8993_DCS_TRIG_STARTUP_0
|
153 WM8993_DCS_TRIG_STARTUP_1
);
156 /* Different chips in the family support different readback
159 switch (hubs
->dcs_readback_mode
) {
161 reg_l
= snd_soc_read(codec
, WM8993_DC_SERVO_READBACK_1
)
162 & WM8993_DCS_INTEG_CHAN_0_MASK
;
163 reg_r
= snd_soc_read(codec
, WM8993_DC_SERVO_READBACK_2
)
164 & WM8993_DCS_INTEG_CHAN_1_MASK
;
168 reg
= snd_soc_read(codec
, dcs_reg
);
169 reg_r
= (reg
& WM8993_DCS_DAC_WR_VAL_1_MASK
)
170 >> WM8993_DCS_DAC_WR_VAL_1_SHIFT
;
171 reg_l
= reg
& WM8993_DCS_DAC_WR_VAL_0_MASK
;
174 WARN(1, "Unknown DCS readback method\n");
178 dev_dbg(codec
->dev
, "DCS input: %x %x\n", reg_l
, reg_r
);
180 /* Apply correction to DC servo result */
181 if (hubs
->dcs_codes_l
|| hubs
->dcs_codes_r
) {
183 "Applying %d/%d code DC servo correction\n",
184 hubs
->dcs_codes_l
, hubs
->dcs_codes_r
);
188 offset
+= hubs
->dcs_codes_r
;
189 dcs_cfg
= (u8
)offset
<< WM8993_DCS_DAC_WR_VAL_1_SHIFT
;
193 offset
+= hubs
->dcs_codes_l
;
194 dcs_cfg
|= (u8
)offset
;
196 dev_dbg(codec
->dev
, "DCS result: %x\n", dcs_cfg
);
199 snd_soc_write(codec
, dcs_reg
, dcs_cfg
);
200 wait_for_dc_servo(codec
,
201 WM8993_DCS_TRIG_DAC_WR_0
|
202 WM8993_DCS_TRIG_DAC_WR_1
);
204 dcs_cfg
= reg_r
<< WM8993_DCS_DAC_WR_VAL_1_SHIFT
;
208 /* Save the callibrated offset if we're in class W mode and
209 * therefore don't have any analogue signal mixed in. */
211 hubs
->class_w_dcs
= dcs_cfg
;
215 * Update the DC servo calibration on gain changes
217 static int wm8993_put_dc_servo(struct snd_kcontrol
*kcontrol
,
218 struct snd_ctl_elem_value
*ucontrol
)
220 struct snd_soc_codec
*codec
= snd_kcontrol_chip(kcontrol
);
221 struct wm_hubs_data
*hubs
= snd_soc_codec_get_drvdata(codec
);
224 ret
= snd_soc_put_volsw(kcontrol
, ucontrol
);
226 /* Updating the analogue gains invalidates the DC servo cache */
227 hubs
->class_w_dcs
= 0;
229 /* If we're applying an offset correction then updating the
230 * callibration would be likely to introduce further offsets. */
231 if (hubs
->dcs_codes_l
|| hubs
->dcs_codes_r
|| hubs
->no_series_update
)
234 /* Only need to do this if the outputs are active */
235 if (snd_soc_read(codec
, WM8993_POWER_MANAGEMENT_1
)
236 & (WM8993_HPOUT1L_ENA
| WM8993_HPOUT1R_ENA
))
237 snd_soc_update_bits(codec
,
239 WM8993_DCS_TRIG_SINGLE_0
|
240 WM8993_DCS_TRIG_SINGLE_1
,
241 WM8993_DCS_TRIG_SINGLE_0
|
242 WM8993_DCS_TRIG_SINGLE_1
);
247 static const struct snd_kcontrol_new analogue_snd_controls
[] = {
248 SOC_SINGLE_TLV("IN1L Volume", WM8993_LEFT_LINE_INPUT_1_2_VOLUME
, 0, 31, 0,
250 SOC_SINGLE("IN1L Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME
, 7, 1, 1),
251 SOC_SINGLE("IN1L ZC Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME
, 6, 1, 0),
253 SOC_SINGLE_TLV("IN1R Volume", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME
, 0, 31, 0,
255 SOC_SINGLE("IN1R Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME
, 7, 1, 1),
256 SOC_SINGLE("IN1R ZC Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME
, 6, 1, 0),
259 SOC_SINGLE_TLV("IN2L Volume", WM8993_LEFT_LINE_INPUT_3_4_VOLUME
, 0, 31, 0,
261 SOC_SINGLE("IN2L Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME
, 7, 1, 1),
262 SOC_SINGLE("IN2L ZC Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME
, 6, 1, 0),
264 SOC_SINGLE_TLV("IN2R Volume", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME
, 0, 31, 0,
266 SOC_SINGLE("IN2R Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME
, 7, 1, 1),
267 SOC_SINGLE("IN2R ZC Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME
, 6, 1, 0),
269 SOC_SINGLE_TLV("MIXINL IN2L Volume", WM8993_INPUT_MIXER3
, 7, 1, 0,
271 SOC_SINGLE_TLV("MIXINL IN1L Volume", WM8993_INPUT_MIXER3
, 4, 1, 0,
273 SOC_SINGLE_TLV("MIXINL Output Record Volume", WM8993_INPUT_MIXER3
, 0, 7, 0,
275 SOC_SINGLE_TLV("MIXINL IN1LP Volume", WM8993_INPUT_MIXER5
, 6, 7, 0, inmix_tlv
),
276 SOC_SINGLE_TLV("MIXINL Direct Voice Volume", WM8993_INPUT_MIXER5
, 0, 6, 0,
279 SOC_SINGLE_TLV("MIXINR IN2R Volume", WM8993_INPUT_MIXER4
, 7, 1, 0,
281 SOC_SINGLE_TLV("MIXINR IN1R Volume", WM8993_INPUT_MIXER4
, 4, 1, 0,
283 SOC_SINGLE_TLV("MIXINR Output Record Volume", WM8993_INPUT_MIXER4
, 0, 7, 0,
285 SOC_SINGLE_TLV("MIXINR IN1RP Volume", WM8993_INPUT_MIXER6
, 6, 7, 0, inmix_tlv
),
286 SOC_SINGLE_TLV("MIXINR Direct Voice Volume", WM8993_INPUT_MIXER6
, 0, 6, 0,
289 SOC_SINGLE_TLV("Left Output Mixer IN2RN Volume", WM8993_OUTPUT_MIXER5
, 6, 7, 1,
291 SOC_SINGLE_TLV("Left Output Mixer IN2LN Volume", WM8993_OUTPUT_MIXER3
, 6, 7, 1,
293 SOC_SINGLE_TLV("Left Output Mixer IN2LP Volume", WM8993_OUTPUT_MIXER3
, 9, 7, 1,
295 SOC_SINGLE_TLV("Left Output Mixer IN1L Volume", WM8993_OUTPUT_MIXER3
, 0, 7, 1,
297 SOC_SINGLE_TLV("Left Output Mixer IN1R Volume", WM8993_OUTPUT_MIXER3
, 3, 7, 1,
299 SOC_SINGLE_TLV("Left Output Mixer Right Input Volume",
300 WM8993_OUTPUT_MIXER5
, 3, 7, 1, outmix_tlv
),
301 SOC_SINGLE_TLV("Left Output Mixer Left Input Volume",
302 WM8993_OUTPUT_MIXER5
, 0, 7, 1, outmix_tlv
),
303 SOC_SINGLE_TLV("Left Output Mixer DAC Volume", WM8993_OUTPUT_MIXER5
, 9, 7, 1,
306 SOC_SINGLE_TLV("Right Output Mixer IN2LN Volume",
307 WM8993_OUTPUT_MIXER6
, 6, 7, 1, outmix_tlv
),
308 SOC_SINGLE_TLV("Right Output Mixer IN2RN Volume",
309 WM8993_OUTPUT_MIXER4
, 6, 7, 1, outmix_tlv
),
310 SOC_SINGLE_TLV("Right Output Mixer IN1L Volume",
311 WM8993_OUTPUT_MIXER4
, 3, 7, 1, outmix_tlv
),
312 SOC_SINGLE_TLV("Right Output Mixer IN1R Volume",
313 WM8993_OUTPUT_MIXER4
, 0, 7, 1, outmix_tlv
),
314 SOC_SINGLE_TLV("Right Output Mixer IN2RP Volume",
315 WM8993_OUTPUT_MIXER4
, 9, 7, 1, outmix_tlv
),
316 SOC_SINGLE_TLV("Right Output Mixer Left Input Volume",
317 WM8993_OUTPUT_MIXER6
, 3, 7, 1, outmix_tlv
),
318 SOC_SINGLE_TLV("Right Output Mixer Right Input Volume",
319 WM8993_OUTPUT_MIXER6
, 6, 7, 1, outmix_tlv
),
320 SOC_SINGLE_TLV("Right Output Mixer DAC Volume",
321 WM8993_OUTPUT_MIXER6
, 9, 7, 1, outmix_tlv
),
323 SOC_DOUBLE_R_TLV("Output Volume", WM8993_LEFT_OPGA_VOLUME
,
324 WM8993_RIGHT_OPGA_VOLUME
, 0, 63, 0, outpga_tlv
),
325 SOC_DOUBLE_R("Output Switch", WM8993_LEFT_OPGA_VOLUME
,
326 WM8993_RIGHT_OPGA_VOLUME
, 6, 1, 0),
327 SOC_DOUBLE_R("Output ZC Switch", WM8993_LEFT_OPGA_VOLUME
,
328 WM8993_RIGHT_OPGA_VOLUME
, 7, 1, 0),
330 SOC_SINGLE("Earpiece Switch", WM8993_HPOUT2_VOLUME
, 5, 1, 1),
331 SOC_SINGLE_TLV("Earpiece Volume", WM8993_HPOUT2_VOLUME
, 4, 1, 1, earpiece_tlv
),
333 SOC_SINGLE_TLV("SPKL Input Volume", WM8993_SPKMIXL_ATTENUATION
,
334 5, 1, 1, wm_hubs_spkmix_tlv
),
335 SOC_SINGLE_TLV("SPKL IN1LP Volume", WM8993_SPKMIXL_ATTENUATION
,
336 4, 1, 1, wm_hubs_spkmix_tlv
),
337 SOC_SINGLE_TLV("SPKL Output Volume", WM8993_SPKMIXL_ATTENUATION
,
338 3, 1, 1, wm_hubs_spkmix_tlv
),
340 SOC_SINGLE_TLV("SPKR Input Volume", WM8993_SPKMIXR_ATTENUATION
,
341 5, 1, 1, wm_hubs_spkmix_tlv
),
342 SOC_SINGLE_TLV("SPKR IN1RP Volume", WM8993_SPKMIXR_ATTENUATION
,
343 4, 1, 1, wm_hubs_spkmix_tlv
),
344 SOC_SINGLE_TLV("SPKR Output Volume", WM8993_SPKMIXR_ATTENUATION
,
345 3, 1, 1, wm_hubs_spkmix_tlv
),
347 SOC_DOUBLE_R_TLV("Speaker Mixer Volume",
348 WM8993_SPKMIXL_ATTENUATION
, WM8993_SPKMIXR_ATTENUATION
,
349 0, 3, 1, spkmixout_tlv
),
350 SOC_DOUBLE_R_TLV("Speaker Volume",
351 WM8993_SPEAKER_VOLUME_LEFT
, WM8993_SPEAKER_VOLUME_RIGHT
,
352 0, 63, 0, outpga_tlv
),
353 SOC_DOUBLE_R("Speaker Switch",
354 WM8993_SPEAKER_VOLUME_LEFT
, WM8993_SPEAKER_VOLUME_RIGHT
,
356 SOC_DOUBLE_R("Speaker ZC Switch",
357 WM8993_SPEAKER_VOLUME_LEFT
, WM8993_SPEAKER_VOLUME_RIGHT
,
359 SOC_DOUBLE_TLV("Speaker Boost Volume", WM8993_SPKOUT_BOOST
, 3, 0, 7, 0,
361 SOC_ENUM("Speaker Reference", speaker_ref
),
362 SOC_ENUM("Speaker Mode", speaker_mode
),
364 SOC_DOUBLE_R_EXT_TLV("Headphone Volume",
365 WM8993_LEFT_OUTPUT_VOLUME
, WM8993_RIGHT_OUTPUT_VOLUME
,
366 0, 63, 0, snd_soc_get_volsw
, wm8993_put_dc_servo
,
369 SOC_DOUBLE_R("Headphone Switch", WM8993_LEFT_OUTPUT_VOLUME
,
370 WM8993_RIGHT_OUTPUT_VOLUME
, 6, 1, 0),
371 SOC_DOUBLE_R("Headphone ZC Switch", WM8993_LEFT_OUTPUT_VOLUME
,
372 WM8993_RIGHT_OUTPUT_VOLUME
, 7, 1, 0),
374 SOC_SINGLE("LINEOUT1N Switch", WM8993_LINE_OUTPUTS_VOLUME
, 6, 1, 1),
375 SOC_SINGLE("LINEOUT1P Switch", WM8993_LINE_OUTPUTS_VOLUME
, 5, 1, 1),
376 SOC_SINGLE_TLV("LINEOUT1 Volume", WM8993_LINE_OUTPUTS_VOLUME
, 4, 1, 1,
379 SOC_SINGLE("LINEOUT2N Switch", WM8993_LINE_OUTPUTS_VOLUME
, 2, 1, 1),
380 SOC_SINGLE("LINEOUT2P Switch", WM8993_LINE_OUTPUTS_VOLUME
, 1, 1, 1),
381 SOC_SINGLE_TLV("LINEOUT2 Volume", WM8993_LINE_OUTPUTS_VOLUME
, 0, 1, 1,
385 static int hp_supply_event(struct snd_soc_dapm_widget
*w
,
386 struct snd_kcontrol
*kcontrol
, int event
)
388 struct snd_soc_codec
*codec
= w
->codec
;
389 struct wm_hubs_data
*hubs
= snd_soc_codec_get_drvdata(codec
);
392 case SND_SOC_DAPM_PRE_PMU
:
393 switch (hubs
->hp_startup_mode
) {
397 /* Enable the headphone amp */
398 snd_soc_update_bits(codec
, WM8993_POWER_MANAGEMENT_1
,
404 /* Enable the second stage */
405 snd_soc_update_bits(codec
, WM8993_ANALOGUE_HP_0
,
412 dev_err(codec
->dev
, "Unknown HP startup mode %d\n",
413 hubs
->hp_startup_mode
);
417 case SND_SOC_DAPM_PRE_PMD
:
418 snd_soc_update_bits(codec
, WM8993_CHARGE_PUMP_1
,
426 static int hp_event(struct snd_soc_dapm_widget
*w
,
427 struct snd_kcontrol
*kcontrol
, int event
)
429 struct snd_soc_codec
*codec
= w
->codec
;
430 unsigned int reg
= snd_soc_read(codec
, WM8993_ANALOGUE_HP_0
);
433 case SND_SOC_DAPM_POST_PMU
:
434 snd_soc_update_bits(codec
, WM8993_CHARGE_PUMP_1
,
435 WM8993_CP_ENA
, WM8993_CP_ENA
);
439 snd_soc_update_bits(codec
, WM8993_POWER_MANAGEMENT_1
,
440 WM8993_HPOUT1L_ENA
| WM8993_HPOUT1R_ENA
,
441 WM8993_HPOUT1L_ENA
| WM8993_HPOUT1R_ENA
);
443 reg
|= WM8993_HPOUT1L_DLY
| WM8993_HPOUT1R_DLY
;
444 snd_soc_write(codec
, WM8993_ANALOGUE_HP_0
, reg
);
446 snd_soc_update_bits(codec
, WM8993_DC_SERVO_1
,
447 WM8993_DCS_TIMER_PERIOD_01_MASK
, 0);
449 calibrate_dc_servo(codec
);
451 reg
|= WM8993_HPOUT1R_OUTP
| WM8993_HPOUT1R_RMV_SHORT
|
452 WM8993_HPOUT1L_OUTP
| WM8993_HPOUT1L_RMV_SHORT
;
453 snd_soc_write(codec
, WM8993_ANALOGUE_HP_0
, reg
);
456 case SND_SOC_DAPM_PRE_PMD
:
457 snd_soc_update_bits(codec
, WM8993_ANALOGUE_HP_0
,
458 WM8993_HPOUT1L_OUTP
|
459 WM8993_HPOUT1R_OUTP
|
460 WM8993_HPOUT1L_RMV_SHORT
|
461 WM8993_HPOUT1R_RMV_SHORT
, 0);
463 snd_soc_update_bits(codec
, WM8993_ANALOGUE_HP_0
,
465 WM8993_HPOUT1R_DLY
, 0);
467 snd_soc_write(codec
, WM8993_DC_SERVO_0
, 0);
469 snd_soc_update_bits(codec
, WM8993_POWER_MANAGEMENT_1
,
470 WM8993_HPOUT1L_ENA
| WM8993_HPOUT1R_ENA
,
478 static int earpiece_event(struct snd_soc_dapm_widget
*w
,
479 struct snd_kcontrol
*control
, int event
)
481 struct snd_soc_codec
*codec
= w
->codec
;
482 u16 reg
= snd_soc_read(codec
, WM8993_ANTIPOP1
) & ~WM8993_HPOUT2_IN_ENA
;
485 case SND_SOC_DAPM_PRE_PMU
:
486 reg
|= WM8993_HPOUT2_IN_ENA
;
487 snd_soc_write(codec
, WM8993_ANTIPOP1
, reg
);
491 case SND_SOC_DAPM_POST_PMD
:
492 snd_soc_write(codec
, WM8993_ANTIPOP1
, reg
);
503 static const struct snd_kcontrol_new in1l_pga
[] = {
504 SOC_DAPM_SINGLE("IN1LP Switch", WM8993_INPUT_MIXER2
, 5, 1, 0),
505 SOC_DAPM_SINGLE("IN1LN Switch", WM8993_INPUT_MIXER2
, 4, 1, 0),
508 static const struct snd_kcontrol_new in1r_pga
[] = {
509 SOC_DAPM_SINGLE("IN1RP Switch", WM8993_INPUT_MIXER2
, 1, 1, 0),
510 SOC_DAPM_SINGLE("IN1RN Switch", WM8993_INPUT_MIXER2
, 0, 1, 0),
513 static const struct snd_kcontrol_new in2l_pga
[] = {
514 SOC_DAPM_SINGLE("IN2LP Switch", WM8993_INPUT_MIXER2
, 7, 1, 0),
515 SOC_DAPM_SINGLE("IN2LN Switch", WM8993_INPUT_MIXER2
, 6, 1, 0),
518 static const struct snd_kcontrol_new in2r_pga
[] = {
519 SOC_DAPM_SINGLE("IN2RP Switch", WM8993_INPUT_MIXER2
, 3, 1, 0),
520 SOC_DAPM_SINGLE("IN2RN Switch", WM8993_INPUT_MIXER2
, 2, 1, 0),
523 static const struct snd_kcontrol_new mixinl
[] = {
524 SOC_DAPM_SINGLE("IN2L Switch", WM8993_INPUT_MIXER3
, 8, 1, 0),
525 SOC_DAPM_SINGLE("IN1L Switch", WM8993_INPUT_MIXER3
, 5, 1, 0),
528 static const struct snd_kcontrol_new mixinr
[] = {
529 SOC_DAPM_SINGLE("IN2R Switch", WM8993_INPUT_MIXER4
, 8, 1, 0),
530 SOC_DAPM_SINGLE("IN1R Switch", WM8993_INPUT_MIXER4
, 5, 1, 0),
533 static const struct snd_kcontrol_new left_output_mixer
[] = {
534 SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER1
, 7, 1, 0),
535 SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER1
, 6, 1, 0),
536 SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER1
, 5, 1, 0),
537 SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER1
, 4, 1, 0),
538 SOC_DAPM_SINGLE("IN2LP Switch", WM8993_OUTPUT_MIXER1
, 1, 1, 0),
539 SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER1
, 3, 1, 0),
540 SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER1
, 2, 1, 0),
541 SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER1
, 0, 1, 0),
544 static const struct snd_kcontrol_new right_output_mixer
[] = {
545 SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER2
, 7, 1, 0),
546 SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER2
, 6, 1, 0),
547 SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER2
, 5, 1, 0),
548 SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER2
, 4, 1, 0),
549 SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER2
, 3, 1, 0),
550 SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER2
, 2, 1, 0),
551 SOC_DAPM_SINGLE("IN2RP Switch", WM8993_OUTPUT_MIXER2
, 1, 1, 0),
552 SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER2
, 0, 1, 0),
555 static const struct snd_kcontrol_new earpiece_mixer
[] = {
556 SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_HPOUT2_MIXER
, 5, 1, 0),
557 SOC_DAPM_SINGLE("Left Output Switch", WM8993_HPOUT2_MIXER
, 4, 1, 0),
558 SOC_DAPM_SINGLE("Right Output Switch", WM8993_HPOUT2_MIXER
, 3, 1, 0),
561 static const struct snd_kcontrol_new left_speaker_boost
[] = {
562 SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS
, 5, 1, 0),
563 SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS
, 4, 1, 0),
564 SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS
, 3, 1, 0),
567 static const struct snd_kcontrol_new right_speaker_boost
[] = {
568 SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS
, 2, 1, 0),
569 SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS
, 1, 1, 0),
570 SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS
, 0, 1, 0),
573 static const struct snd_kcontrol_new line1_mix
[] = {
574 SOC_DAPM_SINGLE("IN1R Switch", WM8993_LINE_MIXER1
, 2, 1, 0),
575 SOC_DAPM_SINGLE("IN1L Switch", WM8993_LINE_MIXER1
, 1, 1, 0),
576 SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER1
, 0, 1, 0),
579 static const struct snd_kcontrol_new line1n_mix
[] = {
580 SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1
, 6, 1, 0),
581 SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER1
, 5, 1, 0),
584 static const struct snd_kcontrol_new line1p_mix
[] = {
585 SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1
, 0, 1, 0),
588 static const struct snd_kcontrol_new line2_mix
[] = {
589 SOC_DAPM_SINGLE("IN1L Switch", WM8993_LINE_MIXER2
, 2, 1, 0),
590 SOC_DAPM_SINGLE("IN1R Switch", WM8993_LINE_MIXER2
, 1, 1, 0),
591 SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER2
, 0, 1, 0),
594 static const struct snd_kcontrol_new line2n_mix
[] = {
595 SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER2
, 5, 1, 0),
596 SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2
, 6, 1, 0),
599 static const struct snd_kcontrol_new line2p_mix
[] = {
600 SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2
, 0, 1, 0),
603 static const struct snd_soc_dapm_widget analogue_dapm_widgets
[] = {
604 SND_SOC_DAPM_INPUT("IN1LN"),
605 SND_SOC_DAPM_INPUT("IN1LP"),
606 SND_SOC_DAPM_INPUT("IN2LN"),
607 SND_SOC_DAPM_INPUT("IN2LP:VXRN"),
608 SND_SOC_DAPM_INPUT("IN1RN"),
609 SND_SOC_DAPM_INPUT("IN1RP"),
610 SND_SOC_DAPM_INPUT("IN2RN"),
611 SND_SOC_DAPM_INPUT("IN2RP:VXRP"),
613 SND_SOC_DAPM_SUPPLY("MICBIAS2", WM8993_POWER_MANAGEMENT_1
, 5, 0, NULL
, 0),
614 SND_SOC_DAPM_SUPPLY("MICBIAS1", WM8993_POWER_MANAGEMENT_1
, 4, 0, NULL
, 0),
616 SND_SOC_DAPM_SUPPLY("LINEOUT_VMID_BUF", WM8993_ANTIPOP1
, 7, 0, NULL
, 0),
618 SND_SOC_DAPM_MIXER("IN1L PGA", WM8993_POWER_MANAGEMENT_2
, 6, 0,
619 in1l_pga
, ARRAY_SIZE(in1l_pga
)),
620 SND_SOC_DAPM_MIXER("IN1R PGA", WM8993_POWER_MANAGEMENT_2
, 4, 0,
621 in1r_pga
, ARRAY_SIZE(in1r_pga
)),
623 SND_SOC_DAPM_MIXER("IN2L PGA", WM8993_POWER_MANAGEMENT_2
, 7, 0,
624 in2l_pga
, ARRAY_SIZE(in2l_pga
)),
625 SND_SOC_DAPM_MIXER("IN2R PGA", WM8993_POWER_MANAGEMENT_2
, 5, 0,
626 in2r_pga
, ARRAY_SIZE(in2r_pga
)),
628 SND_SOC_DAPM_MIXER("MIXINL", WM8993_POWER_MANAGEMENT_2
, 9, 0,
629 mixinl
, ARRAY_SIZE(mixinl
)),
630 SND_SOC_DAPM_MIXER("MIXINR", WM8993_POWER_MANAGEMENT_2
, 8, 0,
631 mixinr
, ARRAY_SIZE(mixinr
)),
633 SND_SOC_DAPM_MIXER("Left Output Mixer", WM8993_POWER_MANAGEMENT_3
, 5, 0,
634 left_output_mixer
, ARRAY_SIZE(left_output_mixer
)),
635 SND_SOC_DAPM_MIXER("Right Output Mixer", WM8993_POWER_MANAGEMENT_3
, 4, 0,
636 right_output_mixer
, ARRAY_SIZE(right_output_mixer
)),
638 SND_SOC_DAPM_PGA("Left Output PGA", WM8993_POWER_MANAGEMENT_3
, 7, 0, NULL
, 0),
639 SND_SOC_DAPM_PGA("Right Output PGA", WM8993_POWER_MANAGEMENT_3
, 6, 0, NULL
, 0),
641 SND_SOC_DAPM_SUPPLY("Headphone Supply", SND_SOC_NOPM
, 0, 0, hp_supply_event
,
642 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_PRE_PMD
),
643 SND_SOC_DAPM_PGA_E("Headphone PGA", SND_SOC_NOPM
, 0, 0,
645 hp_event
, SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_PRE_PMD
),
647 SND_SOC_DAPM_MIXER("Earpiece Mixer", SND_SOC_NOPM
, 0, 0,
648 earpiece_mixer
, ARRAY_SIZE(earpiece_mixer
)),
649 SND_SOC_DAPM_PGA_E("Earpiece Driver", WM8993_POWER_MANAGEMENT_1
, 11, 0,
650 NULL
, 0, earpiece_event
,
651 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
653 SND_SOC_DAPM_MIXER("SPKL Boost", SND_SOC_NOPM
, 0, 0,
654 left_speaker_boost
, ARRAY_SIZE(left_speaker_boost
)),
655 SND_SOC_DAPM_MIXER("SPKR Boost", SND_SOC_NOPM
, 0, 0,
656 right_speaker_boost
, ARRAY_SIZE(right_speaker_boost
)),
658 SND_SOC_DAPM_SUPPLY("TSHUT", WM8993_POWER_MANAGEMENT_2
, 14, 0, NULL
, 0),
659 SND_SOC_DAPM_PGA("SPKL Driver", WM8993_POWER_MANAGEMENT_1
, 12, 0,
661 SND_SOC_DAPM_PGA("SPKR Driver", WM8993_POWER_MANAGEMENT_1
, 13, 0,
664 SND_SOC_DAPM_MIXER("LINEOUT1 Mixer", SND_SOC_NOPM
, 0, 0,
665 line1_mix
, ARRAY_SIZE(line1_mix
)),
666 SND_SOC_DAPM_MIXER("LINEOUT2 Mixer", SND_SOC_NOPM
, 0, 0,
667 line2_mix
, ARRAY_SIZE(line2_mix
)),
669 SND_SOC_DAPM_MIXER("LINEOUT1N Mixer", SND_SOC_NOPM
, 0, 0,
670 line1n_mix
, ARRAY_SIZE(line1n_mix
)),
671 SND_SOC_DAPM_MIXER("LINEOUT1P Mixer", SND_SOC_NOPM
, 0, 0,
672 line1p_mix
, ARRAY_SIZE(line1p_mix
)),
673 SND_SOC_DAPM_MIXER("LINEOUT2N Mixer", SND_SOC_NOPM
, 0, 0,
674 line2n_mix
, ARRAY_SIZE(line2n_mix
)),
675 SND_SOC_DAPM_MIXER("LINEOUT2P Mixer", SND_SOC_NOPM
, 0, 0,
676 line2p_mix
, ARRAY_SIZE(line2p_mix
)),
678 SND_SOC_DAPM_PGA("LINEOUT1N Driver", WM8993_POWER_MANAGEMENT_3
, 13, 0,
680 SND_SOC_DAPM_PGA("LINEOUT1P Driver", WM8993_POWER_MANAGEMENT_3
, 12, 0,
682 SND_SOC_DAPM_PGA("LINEOUT2N Driver", WM8993_POWER_MANAGEMENT_3
, 11, 0,
684 SND_SOC_DAPM_PGA("LINEOUT2P Driver", WM8993_POWER_MANAGEMENT_3
, 10, 0,
687 SND_SOC_DAPM_OUTPUT("SPKOUTLP"),
688 SND_SOC_DAPM_OUTPUT("SPKOUTLN"),
689 SND_SOC_DAPM_OUTPUT("SPKOUTRP"),
690 SND_SOC_DAPM_OUTPUT("SPKOUTRN"),
691 SND_SOC_DAPM_OUTPUT("HPOUT1L"),
692 SND_SOC_DAPM_OUTPUT("HPOUT1R"),
693 SND_SOC_DAPM_OUTPUT("HPOUT2P"),
694 SND_SOC_DAPM_OUTPUT("HPOUT2N"),
695 SND_SOC_DAPM_OUTPUT("LINEOUT1P"),
696 SND_SOC_DAPM_OUTPUT("LINEOUT1N"),
697 SND_SOC_DAPM_OUTPUT("LINEOUT2P"),
698 SND_SOC_DAPM_OUTPUT("LINEOUT2N"),
701 static const struct snd_soc_dapm_route analogue_routes
[] = {
702 { "MICBIAS1", NULL
, "CLK_SYS" },
703 { "MICBIAS2", NULL
, "CLK_SYS" },
705 { "IN1L PGA", "IN1LP Switch", "IN1LP" },
706 { "IN1L PGA", "IN1LN Switch", "IN1LN" },
708 { "IN1L PGA", NULL
, "VMID" },
709 { "IN1R PGA", NULL
, "VMID" },
710 { "IN2L PGA", NULL
, "VMID" },
711 { "IN2R PGA", NULL
, "VMID" },
713 { "IN1R PGA", "IN1RP Switch", "IN1RP" },
714 { "IN1R PGA", "IN1RN Switch", "IN1RN" },
716 { "IN2L PGA", "IN2LP Switch", "IN2LP:VXRN" },
717 { "IN2L PGA", "IN2LN Switch", "IN2LN" },
719 { "IN2R PGA", "IN2RP Switch", "IN2RP:VXRP" },
720 { "IN2R PGA", "IN2RN Switch", "IN2RN" },
722 { "Direct Voice", NULL
, "IN2LP:VXRN" },
723 { "Direct Voice", NULL
, "IN2RP:VXRP" },
725 { "MIXINL", "IN1L Switch", "IN1L PGA" },
726 { "MIXINL", "IN2L Switch", "IN2L PGA" },
727 { "MIXINL", NULL
, "Direct Voice" },
728 { "MIXINL", NULL
, "IN1LP" },
729 { "MIXINL", NULL
, "Left Output Mixer" },
730 { "MIXINL", NULL
, "VMID" },
732 { "MIXINR", "IN1R Switch", "IN1R PGA" },
733 { "MIXINR", "IN2R Switch", "IN2R PGA" },
734 { "MIXINR", NULL
, "Direct Voice" },
735 { "MIXINR", NULL
, "IN1RP" },
736 { "MIXINR", NULL
, "Right Output Mixer" },
737 { "MIXINR", NULL
, "VMID" },
739 { "ADCL", NULL
, "MIXINL" },
740 { "ADCR", NULL
, "MIXINR" },
742 { "Left Output Mixer", "Left Input Switch", "MIXINL" },
743 { "Left Output Mixer", "Right Input Switch", "MIXINR" },
744 { "Left Output Mixer", "IN2RN Switch", "IN2RN" },
745 { "Left Output Mixer", "IN2LN Switch", "IN2LN" },
746 { "Left Output Mixer", "IN2LP Switch", "IN2LP:VXRN" },
747 { "Left Output Mixer", "IN1L Switch", "IN1L PGA" },
748 { "Left Output Mixer", "IN1R Switch", "IN1R PGA" },
750 { "Right Output Mixer", "Left Input Switch", "MIXINL" },
751 { "Right Output Mixer", "Right Input Switch", "MIXINR" },
752 { "Right Output Mixer", "IN2LN Switch", "IN2LN" },
753 { "Right Output Mixer", "IN2RN Switch", "IN2RN" },
754 { "Right Output Mixer", "IN2RP Switch", "IN2RP:VXRP" },
755 { "Right Output Mixer", "IN1L Switch", "IN1L PGA" },
756 { "Right Output Mixer", "IN1R Switch", "IN1R PGA" },
758 { "Left Output PGA", NULL
, "Left Output Mixer" },
759 { "Left Output PGA", NULL
, "TOCLK" },
761 { "Right Output PGA", NULL
, "Right Output Mixer" },
762 { "Right Output PGA", NULL
, "TOCLK" },
764 { "Earpiece Mixer", "Direct Voice Switch", "Direct Voice" },
765 { "Earpiece Mixer", "Left Output Switch", "Left Output PGA" },
766 { "Earpiece Mixer", "Right Output Switch", "Right Output PGA" },
768 { "Earpiece Driver", NULL
, "VMID" },
769 { "Earpiece Driver", NULL
, "Earpiece Mixer" },
770 { "HPOUT2N", NULL
, "Earpiece Driver" },
771 { "HPOUT2P", NULL
, "Earpiece Driver" },
773 { "SPKL", "Input Switch", "MIXINL" },
774 { "SPKL", "IN1LP Switch", "IN1LP" },
775 { "SPKL", "Output Switch", "Left Output PGA" },
776 { "SPKL", NULL
, "TOCLK" },
778 { "SPKR", "Input Switch", "MIXINR" },
779 { "SPKR", "IN1RP Switch", "IN1RP" },
780 { "SPKR", "Output Switch", "Right Output PGA" },
781 { "SPKR", NULL
, "TOCLK" },
783 { "SPKL Boost", "Direct Voice Switch", "Direct Voice" },
784 { "SPKL Boost", "SPKL Switch", "SPKL" },
785 { "SPKL Boost", "SPKR Switch", "SPKR" },
787 { "SPKR Boost", "Direct Voice Switch", "Direct Voice" },
788 { "SPKR Boost", "SPKR Switch", "SPKR" },
789 { "SPKR Boost", "SPKL Switch", "SPKL" },
791 { "SPKL Driver", NULL
, "VMID" },
792 { "SPKL Driver", NULL
, "SPKL Boost" },
793 { "SPKL Driver", NULL
, "CLK_SYS" },
794 { "SPKL Driver", NULL
, "TSHUT" },
796 { "SPKR Driver", NULL
, "VMID" },
797 { "SPKR Driver", NULL
, "SPKR Boost" },
798 { "SPKR Driver", NULL
, "CLK_SYS" },
799 { "SPKR Driver", NULL
, "TSHUT" },
801 { "SPKOUTLP", NULL
, "SPKL Driver" },
802 { "SPKOUTLN", NULL
, "SPKL Driver" },
803 { "SPKOUTRP", NULL
, "SPKR Driver" },
804 { "SPKOUTRN", NULL
, "SPKR Driver" },
806 { "Left Headphone Mux", "Mixer", "Left Output PGA" },
807 { "Right Headphone Mux", "Mixer", "Right Output PGA" },
809 { "Headphone PGA", NULL
, "Left Headphone Mux" },
810 { "Headphone PGA", NULL
, "Right Headphone Mux" },
811 { "Headphone PGA", NULL
, "VMID" },
812 { "Headphone PGA", NULL
, "CLK_SYS" },
813 { "Headphone PGA", NULL
, "Headphone Supply" },
815 { "HPOUT1L", NULL
, "Headphone PGA" },
816 { "HPOUT1R", NULL
, "Headphone PGA" },
818 { "LINEOUT1N Driver", NULL
, "VMID" },
819 { "LINEOUT1P Driver", NULL
, "VMID" },
820 { "LINEOUT2N Driver", NULL
, "VMID" },
821 { "LINEOUT2P Driver", NULL
, "VMID" },
823 { "LINEOUT1N", NULL
, "LINEOUT1N Driver" },
824 { "LINEOUT1P", NULL
, "LINEOUT1P Driver" },
825 { "LINEOUT2N", NULL
, "LINEOUT2N Driver" },
826 { "LINEOUT2P", NULL
, "LINEOUT2P Driver" },
829 static const struct snd_soc_dapm_route lineout1_diff_routes
[] = {
830 { "LINEOUT1 Mixer", "IN1L Switch", "IN1L PGA" },
831 { "LINEOUT1 Mixer", "IN1R Switch", "IN1R PGA" },
832 { "LINEOUT1 Mixer", "Output Switch", "Left Output PGA" },
834 { "LINEOUT1N Driver", NULL
, "LINEOUT1 Mixer" },
835 { "LINEOUT1P Driver", NULL
, "LINEOUT1 Mixer" },
838 static const struct snd_soc_dapm_route lineout1_se_routes
[] = {
839 { "LINEOUT1N Mixer", NULL
, "LINEOUT_VMID_BUF" },
840 { "LINEOUT1N Mixer", "Left Output Switch", "Left Output PGA" },
841 { "LINEOUT1N Mixer", "Right Output Switch", "Right Output PGA" },
843 { "LINEOUT1P Mixer", NULL
, "LINEOUT_VMID_BUF" },
844 { "LINEOUT1P Mixer", "Left Output Switch", "Left Output PGA" },
846 { "LINEOUT1N Driver", NULL
, "LINEOUT1N Mixer" },
847 { "LINEOUT1P Driver", NULL
, "LINEOUT1P Mixer" },
850 static const struct snd_soc_dapm_route lineout2_diff_routes
[] = {
851 { "LINEOUT2 Mixer", "IN1L Switch", "IN1L PGA" },
852 { "LINEOUT2 Mixer", "IN1R Switch", "IN1R PGA" },
853 { "LINEOUT2 Mixer", "Output Switch", "Right Output PGA" },
855 { "LINEOUT2N Driver", NULL
, "LINEOUT2 Mixer" },
856 { "LINEOUT2P Driver", NULL
, "LINEOUT2 Mixer" },
859 static const struct snd_soc_dapm_route lineout2_se_routes
[] = {
860 { "LINEOUT2N Mixer", NULL
, "LINEOUT_VMID_BUF" },
861 { "LINEOUT2N Mixer", "Left Output Switch", "Left Output PGA" },
862 { "LINEOUT2N Mixer", "Right Output Switch", "Right Output PGA" },
864 { "LINEOUT2P Mixer", NULL
, "LINEOUT_VMID_BUF" },
865 { "LINEOUT2P Mixer", "Right Output Switch", "Right Output PGA" },
867 { "LINEOUT2N Driver", NULL
, "LINEOUT2N Mixer" },
868 { "LINEOUT2P Driver", NULL
, "LINEOUT2P Mixer" },
871 int wm_hubs_add_analogue_controls(struct snd_soc_codec
*codec
)
873 struct snd_soc_dapm_context
*dapm
= &codec
->dapm
;
875 /* Latch volume update bits & default ZC on */
876 snd_soc_update_bits(codec
, WM8993_LEFT_LINE_INPUT_1_2_VOLUME
,
877 WM8993_IN1_VU
, WM8993_IN1_VU
);
878 snd_soc_update_bits(codec
, WM8993_RIGHT_LINE_INPUT_1_2_VOLUME
,
879 WM8993_IN1_VU
, WM8993_IN1_VU
);
880 snd_soc_update_bits(codec
, WM8993_LEFT_LINE_INPUT_3_4_VOLUME
,
881 WM8993_IN2_VU
, WM8993_IN2_VU
);
882 snd_soc_update_bits(codec
, WM8993_RIGHT_LINE_INPUT_3_4_VOLUME
,
883 WM8993_IN2_VU
, WM8993_IN2_VU
);
885 snd_soc_update_bits(codec
, WM8993_SPEAKER_VOLUME_LEFT
,
886 WM8993_SPKOUT_VU
, WM8993_SPKOUT_VU
);
887 snd_soc_update_bits(codec
, WM8993_SPEAKER_VOLUME_RIGHT
,
888 WM8993_SPKOUT_VU
, WM8993_SPKOUT_VU
);
890 snd_soc_update_bits(codec
, WM8993_LEFT_OUTPUT_VOLUME
,
891 WM8993_HPOUT1_VU
| WM8993_HPOUT1L_ZC
,
892 WM8993_HPOUT1_VU
| WM8993_HPOUT1L_ZC
);
893 snd_soc_update_bits(codec
, WM8993_RIGHT_OUTPUT_VOLUME
,
894 WM8993_HPOUT1_VU
| WM8993_HPOUT1R_ZC
,
895 WM8993_HPOUT1_VU
| WM8993_HPOUT1R_ZC
);
897 snd_soc_update_bits(codec
, WM8993_LEFT_OPGA_VOLUME
,
898 WM8993_MIXOUTL_ZC
| WM8993_MIXOUT_VU
,
899 WM8993_MIXOUTL_ZC
| WM8993_MIXOUT_VU
);
900 snd_soc_update_bits(codec
, WM8993_RIGHT_OPGA_VOLUME
,
901 WM8993_MIXOUTR_ZC
| WM8993_MIXOUT_VU
,
902 WM8993_MIXOUTR_ZC
| WM8993_MIXOUT_VU
);
904 snd_soc_add_controls(codec
, analogue_snd_controls
,
905 ARRAY_SIZE(analogue_snd_controls
));
907 snd_soc_dapm_new_controls(dapm
, analogue_dapm_widgets
,
908 ARRAY_SIZE(analogue_dapm_widgets
));
911 EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_controls
);
913 int wm_hubs_add_analogue_routes(struct snd_soc_codec
*codec
,
914 int lineout1_diff
, int lineout2_diff
)
916 struct wm_hubs_data
*hubs
= snd_soc_codec_get_drvdata(codec
);
917 struct snd_soc_dapm_context
*dapm
= &codec
->dapm
;
919 init_completion(&hubs
->dcs_done
);
921 snd_soc_dapm_add_routes(dapm
, analogue_routes
,
922 ARRAY_SIZE(analogue_routes
));
925 snd_soc_dapm_add_routes(dapm
,
926 lineout1_diff_routes
,
927 ARRAY_SIZE(lineout1_diff_routes
));
929 snd_soc_dapm_add_routes(dapm
,
931 ARRAY_SIZE(lineout1_se_routes
));
934 snd_soc_dapm_add_routes(dapm
,
935 lineout2_diff_routes
,
936 ARRAY_SIZE(lineout2_diff_routes
));
938 snd_soc_dapm_add_routes(dapm
,
940 ARRAY_SIZE(lineout2_se_routes
));
944 EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_routes
);
946 int wm_hubs_handle_analogue_pdata(struct snd_soc_codec
*codec
,
947 int lineout1_diff
, int lineout2_diff
,
948 int lineout1fb
, int lineout2fb
,
949 int jd_scthr
, int jd_thr
, int micbias1_lvl
,
953 snd_soc_update_bits(codec
, WM8993_LINE_MIXER1
,
954 WM8993_LINEOUT1_MODE
,
955 WM8993_LINEOUT1_MODE
);
957 snd_soc_update_bits(codec
, WM8993_LINE_MIXER2
,
958 WM8993_LINEOUT2_MODE
,
959 WM8993_LINEOUT2_MODE
);
961 /* If the line outputs are differential then we aren't presenting
962 * VMID as an output and can disable it.
964 if (lineout1_diff
&& lineout2_diff
)
965 codec
->dapm
.idle_bias_off
= 1;
968 snd_soc_update_bits(codec
, WM8993_ADDITIONAL_CONTROL
,
969 WM8993_LINEOUT1_FB
, WM8993_LINEOUT1_FB
);
972 snd_soc_update_bits(codec
, WM8993_ADDITIONAL_CONTROL
,
973 WM8993_LINEOUT2_FB
, WM8993_LINEOUT2_FB
);
975 snd_soc_update_bits(codec
, WM8993_MICBIAS
,
976 WM8993_JD_SCTHR_MASK
| WM8993_JD_THR_MASK
|
977 WM8993_MICB1_LVL
| WM8993_MICB2_LVL
,
978 jd_scthr
<< WM8993_JD_SCTHR_SHIFT
|
979 jd_thr
<< WM8993_JD_THR_SHIFT
|
981 micbias2_lvl
<< WM8993_MICB2_LVL_SHIFT
);
985 EXPORT_SYMBOL_GPL(wm_hubs_handle_analogue_pdata
);
987 MODULE_DESCRIPTION("Shared support for Wolfson hubs products");
988 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
989 MODULE_LICENSE("GPL");