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/platform_device.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
);
70 unsigned long timeout
;
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
) {
80 timeout
= wait_for_completion_timeout(&hubs
->dcs_done
,
81 msecs_to_jiffies(500));
83 dev_warn(codec
->dev
, "No DC servo interrupt\n");
85 reg
= snd_soc_read(codec
, WM8993_DC_SERVO_0
);
90 reg
= snd_soc_read(codec
, WM8993_DC_SERVO_0
);
91 dev_dbg(codec
->dev
, "DC servo: %x\n", reg
);
92 } while (reg
& op
&& count
< 400);
96 dev_err(codec
->dev
, "Timed out waiting for DC Servo %x\n",
100 irqreturn_t
wm_hubs_dcs_done(int irq
, void *data
)
102 struct wm_hubs_data
*hubs
= data
;
104 complete(&hubs
->dcs_done
);
108 EXPORT_SYMBOL_GPL(wm_hubs_dcs_done
);
111 * Startup calibration of the DC servo
113 static void calibrate_dc_servo(struct snd_soc_codec
*codec
)
115 struct wm_hubs_data
*hubs
= snd_soc_codec_get_drvdata(codec
);
117 u16 reg
, reg_l
, reg_r
, dcs_cfg
;
119 /* If we're using a digital only path and have a previously
120 * callibrated DC servo offset stored then use that. */
121 if (hubs
->class_w
&& hubs
->class_w_dcs
) {
122 dev_dbg(codec
->dev
, "Using cached DC servo offset %x\n",
124 snd_soc_write(codec
, WM8993_DC_SERVO_3
, hubs
->class_w_dcs
);
125 wait_for_dc_servo(codec
,
126 WM8993_DCS_TRIG_DAC_WR_0
|
127 WM8993_DCS_TRIG_DAC_WR_1
);
131 if (hubs
->series_startup
) {
132 /* Set for 32 series updates */
133 snd_soc_update_bits(codec
, WM8993_DC_SERVO_1
,
134 WM8993_DCS_SERIES_NO_01_MASK
,
135 32 << WM8993_DCS_SERIES_NO_01_SHIFT
);
136 wait_for_dc_servo(codec
,
137 WM8993_DCS_TRIG_SERIES_0
|
138 WM8993_DCS_TRIG_SERIES_1
);
140 wait_for_dc_servo(codec
,
141 WM8993_DCS_TRIG_STARTUP_0
|
142 WM8993_DCS_TRIG_STARTUP_1
);
145 /* Different chips in the family support different readback
148 switch (hubs
->dcs_readback_mode
) {
150 reg_l
= snd_soc_read(codec
, WM8993_DC_SERVO_READBACK_1
)
151 & WM8993_DCS_INTEG_CHAN_0_MASK
;
152 reg_r
= snd_soc_read(codec
, WM8993_DC_SERVO_READBACK_2
)
153 & WM8993_DCS_INTEG_CHAN_1_MASK
;
156 reg
= snd_soc_read(codec
, WM8993_DC_SERVO_3
);
157 reg_r
= (reg
& WM8993_DCS_DAC_WR_VAL_1_MASK
)
158 >> WM8993_DCS_DAC_WR_VAL_1_SHIFT
;
159 reg_l
= reg
& WM8993_DCS_DAC_WR_VAL_0_MASK
;
162 WARN(1, "Unknown DCS readback method\n");
166 dev_dbg(codec
->dev
, "DCS input: %x %x\n", reg_l
, reg_r
);
168 /* Apply correction to DC servo result */
169 if (hubs
->dcs_codes
) {
170 dev_dbg(codec
->dev
, "Applying %d code DC servo correction\n",
175 offset
+= hubs
->dcs_codes
;
176 dcs_cfg
= (u8
)offset
<< WM8993_DCS_DAC_WR_VAL_1_SHIFT
;
180 offset
+= hubs
->dcs_codes
;
181 dcs_cfg
|= (u8
)offset
;
183 dev_dbg(codec
->dev
, "DCS result: %x\n", dcs_cfg
);
186 snd_soc_write(codec
, WM8993_DC_SERVO_3
, dcs_cfg
);
187 wait_for_dc_servo(codec
,
188 WM8993_DCS_TRIG_DAC_WR_0
|
189 WM8993_DCS_TRIG_DAC_WR_1
);
191 dcs_cfg
= reg_r
<< WM8993_DCS_DAC_WR_VAL_1_SHIFT
;
195 /* Save the callibrated offset if we're in class W mode and
196 * therefore don't have any analogue signal mixed in. */
198 hubs
->class_w_dcs
= dcs_cfg
;
202 * Update the DC servo calibration on gain changes
204 static int wm8993_put_dc_servo(struct snd_kcontrol
*kcontrol
,
205 struct snd_ctl_elem_value
*ucontrol
)
207 struct snd_soc_codec
*codec
= snd_kcontrol_chip(kcontrol
);
208 struct wm_hubs_data
*hubs
= snd_soc_codec_get_drvdata(codec
);
211 ret
= snd_soc_put_volsw_2r(kcontrol
, ucontrol
);
213 /* Updating the analogue gains invalidates the DC servo cache */
214 hubs
->class_w_dcs
= 0;
216 /* If we're applying an offset correction then updating the
217 * callibration would be likely to introduce further offsets. */
218 if (hubs
->dcs_codes
|| hubs
->no_series_update
)
221 /* Only need to do this if the outputs are active */
222 if (snd_soc_read(codec
, WM8993_POWER_MANAGEMENT_1
)
223 & (WM8993_HPOUT1L_ENA
| WM8993_HPOUT1R_ENA
))
224 snd_soc_update_bits(codec
,
226 WM8993_DCS_TRIG_SINGLE_0
|
227 WM8993_DCS_TRIG_SINGLE_1
,
228 WM8993_DCS_TRIG_SINGLE_0
|
229 WM8993_DCS_TRIG_SINGLE_1
);
234 static const struct snd_kcontrol_new analogue_snd_controls
[] = {
235 SOC_SINGLE_TLV("IN1L Volume", WM8993_LEFT_LINE_INPUT_1_2_VOLUME
, 0, 31, 0,
237 SOC_SINGLE("IN1L Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME
, 7, 1, 1),
238 SOC_SINGLE("IN1L ZC Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME
, 6, 1, 0),
240 SOC_SINGLE_TLV("IN1R Volume", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME
, 0, 31, 0,
242 SOC_SINGLE("IN1R Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME
, 7, 1, 1),
243 SOC_SINGLE("IN1R ZC Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME
, 6, 1, 0),
246 SOC_SINGLE_TLV("IN2L Volume", WM8993_LEFT_LINE_INPUT_3_4_VOLUME
, 0, 31, 0,
248 SOC_SINGLE("IN2L Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME
, 7, 1, 1),
249 SOC_SINGLE("IN2L ZC Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME
, 6, 1, 0),
251 SOC_SINGLE_TLV("IN2R Volume", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME
, 0, 31, 0,
253 SOC_SINGLE("IN2R Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME
, 7, 1, 1),
254 SOC_SINGLE("IN2R ZC Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME
, 6, 1, 0),
256 SOC_SINGLE_TLV("MIXINL IN2L Volume", WM8993_INPUT_MIXER3
, 7, 1, 0,
258 SOC_SINGLE_TLV("MIXINL IN1L Volume", WM8993_INPUT_MIXER3
, 4, 1, 0,
260 SOC_SINGLE_TLV("MIXINL Output Record Volume", WM8993_INPUT_MIXER3
, 0, 7, 0,
262 SOC_SINGLE_TLV("MIXINL IN1LP Volume", WM8993_INPUT_MIXER5
, 6, 7, 0, inmix_tlv
),
263 SOC_SINGLE_TLV("MIXINL Direct Voice Volume", WM8993_INPUT_MIXER5
, 0, 6, 0,
266 SOC_SINGLE_TLV("MIXINR IN2R Volume", WM8993_INPUT_MIXER4
, 7, 1, 0,
268 SOC_SINGLE_TLV("MIXINR IN1R Volume", WM8993_INPUT_MIXER4
, 4, 1, 0,
270 SOC_SINGLE_TLV("MIXINR Output Record Volume", WM8993_INPUT_MIXER4
, 0, 7, 0,
272 SOC_SINGLE_TLV("MIXINR IN1RP Volume", WM8993_INPUT_MIXER6
, 6, 7, 0, inmix_tlv
),
273 SOC_SINGLE_TLV("MIXINR Direct Voice Volume", WM8993_INPUT_MIXER6
, 0, 6, 0,
276 SOC_SINGLE_TLV("Left Output Mixer IN2RN Volume", WM8993_OUTPUT_MIXER5
, 6, 7, 1,
278 SOC_SINGLE_TLV("Left Output Mixer IN2LN Volume", WM8993_OUTPUT_MIXER3
, 6, 7, 1,
280 SOC_SINGLE_TLV("Left Output Mixer IN2LP Volume", WM8993_OUTPUT_MIXER3
, 9, 7, 1,
282 SOC_SINGLE_TLV("Left Output Mixer IN1L Volume", WM8993_OUTPUT_MIXER3
, 0, 7, 1,
284 SOC_SINGLE_TLV("Left Output Mixer IN1R Volume", WM8993_OUTPUT_MIXER3
, 3, 7, 1,
286 SOC_SINGLE_TLV("Left Output Mixer Right Input Volume",
287 WM8993_OUTPUT_MIXER5
, 3, 7, 1, outmix_tlv
),
288 SOC_SINGLE_TLV("Left Output Mixer Left Input Volume",
289 WM8993_OUTPUT_MIXER5
, 0, 7, 1, outmix_tlv
),
290 SOC_SINGLE_TLV("Left Output Mixer DAC Volume", WM8993_OUTPUT_MIXER5
, 9, 7, 1,
293 SOC_SINGLE_TLV("Right Output Mixer IN2LN Volume",
294 WM8993_OUTPUT_MIXER6
, 6, 7, 1, outmix_tlv
),
295 SOC_SINGLE_TLV("Right Output Mixer IN2RN Volume",
296 WM8993_OUTPUT_MIXER4
, 6, 7, 1, outmix_tlv
),
297 SOC_SINGLE_TLV("Right Output Mixer IN1L Volume",
298 WM8993_OUTPUT_MIXER4
, 3, 7, 1, outmix_tlv
),
299 SOC_SINGLE_TLV("Right Output Mixer IN1R Volume",
300 WM8993_OUTPUT_MIXER4
, 0, 7, 1, outmix_tlv
),
301 SOC_SINGLE_TLV("Right Output Mixer IN2RP Volume",
302 WM8993_OUTPUT_MIXER4
, 9, 7, 1, outmix_tlv
),
303 SOC_SINGLE_TLV("Right Output Mixer Left Input Volume",
304 WM8993_OUTPUT_MIXER6
, 3, 7, 1, outmix_tlv
),
305 SOC_SINGLE_TLV("Right Output Mixer Right Input Volume",
306 WM8993_OUTPUT_MIXER6
, 6, 7, 1, outmix_tlv
),
307 SOC_SINGLE_TLV("Right Output Mixer DAC Volume",
308 WM8993_OUTPUT_MIXER6
, 9, 7, 1, outmix_tlv
),
310 SOC_DOUBLE_R_TLV("Output Volume", WM8993_LEFT_OPGA_VOLUME
,
311 WM8993_RIGHT_OPGA_VOLUME
, 0, 63, 0, outpga_tlv
),
312 SOC_DOUBLE_R("Output Switch", WM8993_LEFT_OPGA_VOLUME
,
313 WM8993_RIGHT_OPGA_VOLUME
, 6, 1, 0),
314 SOC_DOUBLE_R("Output ZC Switch", WM8993_LEFT_OPGA_VOLUME
,
315 WM8993_RIGHT_OPGA_VOLUME
, 7, 1, 0),
317 SOC_SINGLE("Earpiece Switch", WM8993_HPOUT2_VOLUME
, 5, 1, 1),
318 SOC_SINGLE_TLV("Earpiece Volume", WM8993_HPOUT2_VOLUME
, 4, 1, 1, earpiece_tlv
),
320 SOC_SINGLE_TLV("SPKL Input Volume", WM8993_SPKMIXL_ATTENUATION
,
321 5, 1, 1, wm_hubs_spkmix_tlv
),
322 SOC_SINGLE_TLV("SPKL IN1LP Volume", WM8993_SPKMIXL_ATTENUATION
,
323 4, 1, 1, wm_hubs_spkmix_tlv
),
324 SOC_SINGLE_TLV("SPKL Output Volume", WM8993_SPKMIXL_ATTENUATION
,
325 3, 1, 1, wm_hubs_spkmix_tlv
),
327 SOC_SINGLE_TLV("SPKR Input Volume", WM8993_SPKMIXR_ATTENUATION
,
328 5, 1, 1, wm_hubs_spkmix_tlv
),
329 SOC_SINGLE_TLV("SPKR IN1RP Volume", WM8993_SPKMIXR_ATTENUATION
,
330 4, 1, 1, wm_hubs_spkmix_tlv
),
331 SOC_SINGLE_TLV("SPKR Output Volume", WM8993_SPKMIXR_ATTENUATION
,
332 3, 1, 1, wm_hubs_spkmix_tlv
),
334 SOC_DOUBLE_R_TLV("Speaker Mixer Volume",
335 WM8993_SPKMIXL_ATTENUATION
, WM8993_SPKMIXR_ATTENUATION
,
336 0, 3, 1, spkmixout_tlv
),
337 SOC_DOUBLE_R_TLV("Speaker Volume",
338 WM8993_SPEAKER_VOLUME_LEFT
, WM8993_SPEAKER_VOLUME_RIGHT
,
339 0, 63, 0, outpga_tlv
),
340 SOC_DOUBLE_R("Speaker Switch",
341 WM8993_SPEAKER_VOLUME_LEFT
, WM8993_SPEAKER_VOLUME_RIGHT
,
343 SOC_DOUBLE_R("Speaker ZC Switch",
344 WM8993_SPEAKER_VOLUME_LEFT
, WM8993_SPEAKER_VOLUME_RIGHT
,
346 SOC_DOUBLE_TLV("Speaker Boost Volume", WM8993_SPKOUT_BOOST
, 3, 0, 7, 0,
348 SOC_ENUM("Speaker Reference", speaker_ref
),
349 SOC_ENUM("Speaker Mode", speaker_mode
),
352 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
, .name
= "Headphone Volume",
353 .access
= SNDRV_CTL_ELEM_ACCESS_TLV_READ
|
354 SNDRV_CTL_ELEM_ACCESS_READWRITE
,
356 .info
= snd_soc_info_volsw_2r
,
357 .get
= snd_soc_get_volsw_2r
, .put
= wm8993_put_dc_servo
,
358 .private_value
= (unsigned long)&(struct soc_mixer_control
) {
359 .reg
= WM8993_LEFT_OUTPUT_VOLUME
,
360 .rreg
= WM8993_RIGHT_OUTPUT_VOLUME
,
361 .shift
= 0, .max
= 63
364 SOC_DOUBLE_R("Headphone Switch", WM8993_LEFT_OUTPUT_VOLUME
,
365 WM8993_RIGHT_OUTPUT_VOLUME
, 6, 1, 0),
366 SOC_DOUBLE_R("Headphone ZC Switch", WM8993_LEFT_OUTPUT_VOLUME
,
367 WM8993_RIGHT_OUTPUT_VOLUME
, 7, 1, 0),
369 SOC_SINGLE("LINEOUT1N Switch", WM8993_LINE_OUTPUTS_VOLUME
, 6, 1, 1),
370 SOC_SINGLE("LINEOUT1P Switch", WM8993_LINE_OUTPUTS_VOLUME
, 5, 1, 1),
371 SOC_SINGLE_TLV("LINEOUT1 Volume", WM8993_LINE_OUTPUTS_VOLUME
, 4, 1, 1,
374 SOC_SINGLE("LINEOUT2N Switch", WM8993_LINE_OUTPUTS_VOLUME
, 2, 1, 1),
375 SOC_SINGLE("LINEOUT2P Switch", WM8993_LINE_OUTPUTS_VOLUME
, 1, 1, 1),
376 SOC_SINGLE_TLV("LINEOUT2 Volume", WM8993_LINE_OUTPUTS_VOLUME
, 0, 1, 1,
380 static int hp_supply_event(struct snd_soc_dapm_widget
*w
,
381 struct snd_kcontrol
*kcontrol
, int event
)
383 struct snd_soc_codec
*codec
= w
->codec
;
384 struct wm_hubs_data
*hubs
= snd_soc_codec_get_drvdata(codec
);
387 case SND_SOC_DAPM_PRE_PMU
:
388 switch (hubs
->hp_startup_mode
) {
392 /* Enable the headphone amp */
393 snd_soc_update_bits(codec
, WM8993_POWER_MANAGEMENT_1
,
399 /* Enable the second stage */
400 snd_soc_update_bits(codec
, WM8993_ANALOGUE_HP_0
,
407 dev_err(codec
->dev
, "Unknown HP startup mode %d\n",
408 hubs
->hp_startup_mode
);
412 case SND_SOC_DAPM_PRE_PMD
:
413 snd_soc_update_bits(codec
, WM8993_CHARGE_PUMP_1
,
421 static int hp_event(struct snd_soc_dapm_widget
*w
,
422 struct snd_kcontrol
*kcontrol
, int event
)
424 struct snd_soc_codec
*codec
= w
->codec
;
425 unsigned int reg
= snd_soc_read(codec
, WM8993_ANALOGUE_HP_0
);
428 case SND_SOC_DAPM_POST_PMU
:
429 snd_soc_update_bits(codec
, WM8993_CHARGE_PUMP_1
,
430 WM8993_CP_ENA
, WM8993_CP_ENA
);
434 snd_soc_update_bits(codec
, WM8993_POWER_MANAGEMENT_1
,
435 WM8993_HPOUT1L_ENA
| WM8993_HPOUT1R_ENA
,
436 WM8993_HPOUT1L_ENA
| WM8993_HPOUT1R_ENA
);
438 reg
|= WM8993_HPOUT1L_DLY
| WM8993_HPOUT1R_DLY
;
439 snd_soc_write(codec
, WM8993_ANALOGUE_HP_0
, reg
);
441 /* Smallest supported update interval */
442 snd_soc_update_bits(codec
, WM8993_DC_SERVO_1
,
443 WM8993_DCS_TIMER_PERIOD_01_MASK
, 1);
445 calibrate_dc_servo(codec
);
447 reg
|= WM8993_HPOUT1R_OUTP
| WM8993_HPOUT1R_RMV_SHORT
|
448 WM8993_HPOUT1L_OUTP
| WM8993_HPOUT1L_RMV_SHORT
;
449 snd_soc_write(codec
, WM8993_ANALOGUE_HP_0
, reg
);
452 case SND_SOC_DAPM_PRE_PMD
:
453 snd_soc_update_bits(codec
, WM8993_ANALOGUE_HP_0
,
454 WM8993_HPOUT1L_OUTP
|
455 WM8993_HPOUT1R_OUTP
|
456 WM8993_HPOUT1L_RMV_SHORT
|
457 WM8993_HPOUT1R_RMV_SHORT
, 0);
459 snd_soc_update_bits(codec
, WM8993_ANALOGUE_HP_0
,
461 WM8993_HPOUT1R_DLY
, 0);
463 snd_soc_write(codec
, WM8993_DC_SERVO_0
, 0);
465 snd_soc_update_bits(codec
, WM8993_POWER_MANAGEMENT_1
,
466 WM8993_HPOUT1L_ENA
| WM8993_HPOUT1R_ENA
,
474 static int earpiece_event(struct snd_soc_dapm_widget
*w
,
475 struct snd_kcontrol
*control
, int event
)
477 struct snd_soc_codec
*codec
= w
->codec
;
478 u16 reg
= snd_soc_read(codec
, WM8993_ANTIPOP1
) & ~WM8993_HPOUT2_IN_ENA
;
481 case SND_SOC_DAPM_PRE_PMU
:
482 reg
|= WM8993_HPOUT2_IN_ENA
;
483 snd_soc_write(codec
, WM8993_ANTIPOP1
, reg
);
487 case SND_SOC_DAPM_POST_PMD
:
488 snd_soc_write(codec
, WM8993_ANTIPOP1
, reg
);
499 static const struct snd_kcontrol_new in1l_pga
[] = {
500 SOC_DAPM_SINGLE("IN1LP Switch", WM8993_INPUT_MIXER2
, 5, 1, 0),
501 SOC_DAPM_SINGLE("IN1LN Switch", WM8993_INPUT_MIXER2
, 4, 1, 0),
504 static const struct snd_kcontrol_new in1r_pga
[] = {
505 SOC_DAPM_SINGLE("IN1RP Switch", WM8993_INPUT_MIXER2
, 1, 1, 0),
506 SOC_DAPM_SINGLE("IN1RN Switch", WM8993_INPUT_MIXER2
, 0, 1, 0),
509 static const struct snd_kcontrol_new in2l_pga
[] = {
510 SOC_DAPM_SINGLE("IN2LP Switch", WM8993_INPUT_MIXER2
, 7, 1, 0),
511 SOC_DAPM_SINGLE("IN2LN Switch", WM8993_INPUT_MIXER2
, 6, 1, 0),
514 static const struct snd_kcontrol_new in2r_pga
[] = {
515 SOC_DAPM_SINGLE("IN2RP Switch", WM8993_INPUT_MIXER2
, 3, 1, 0),
516 SOC_DAPM_SINGLE("IN2RN Switch", WM8993_INPUT_MIXER2
, 2, 1, 0),
519 static const struct snd_kcontrol_new mixinl
[] = {
520 SOC_DAPM_SINGLE("IN2L Switch", WM8993_INPUT_MIXER3
, 8, 1, 0),
521 SOC_DAPM_SINGLE("IN1L Switch", WM8993_INPUT_MIXER3
, 5, 1, 0),
524 static const struct snd_kcontrol_new mixinr
[] = {
525 SOC_DAPM_SINGLE("IN2R Switch", WM8993_INPUT_MIXER4
, 8, 1, 0),
526 SOC_DAPM_SINGLE("IN1R Switch", WM8993_INPUT_MIXER4
, 5, 1, 0),
529 static const struct snd_kcontrol_new left_output_mixer
[] = {
530 SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER1
, 7, 1, 0),
531 SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER1
, 6, 1, 0),
532 SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER1
, 5, 1, 0),
533 SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER1
, 4, 1, 0),
534 SOC_DAPM_SINGLE("IN2LP Switch", WM8993_OUTPUT_MIXER1
, 1, 1, 0),
535 SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER1
, 3, 1, 0),
536 SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER1
, 2, 1, 0),
537 SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER1
, 0, 1, 0),
540 static const struct snd_kcontrol_new right_output_mixer
[] = {
541 SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER2
, 7, 1, 0),
542 SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER2
, 6, 1, 0),
543 SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER2
, 5, 1, 0),
544 SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER2
, 4, 1, 0),
545 SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER2
, 3, 1, 0),
546 SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER2
, 2, 1, 0),
547 SOC_DAPM_SINGLE("IN2RP Switch", WM8993_OUTPUT_MIXER2
, 1, 1, 0),
548 SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER2
, 0, 1, 0),
551 static const struct snd_kcontrol_new earpiece_mixer
[] = {
552 SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_HPOUT2_MIXER
, 5, 1, 0),
553 SOC_DAPM_SINGLE("Left Output Switch", WM8993_HPOUT2_MIXER
, 4, 1, 0),
554 SOC_DAPM_SINGLE("Right Output Switch", WM8993_HPOUT2_MIXER
, 3, 1, 0),
557 static const struct snd_kcontrol_new left_speaker_boost
[] = {
558 SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS
, 5, 1, 0),
559 SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS
, 4, 1, 0),
560 SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS
, 3, 1, 0),
563 static const struct snd_kcontrol_new right_speaker_boost
[] = {
564 SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS
, 2, 1, 0),
565 SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS
, 1, 1, 0),
566 SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS
, 0, 1, 0),
569 static const struct snd_kcontrol_new line1_mix
[] = {
570 SOC_DAPM_SINGLE("IN1R Switch", WM8993_LINE_MIXER1
, 2, 1, 0),
571 SOC_DAPM_SINGLE("IN1L Switch", WM8993_LINE_MIXER1
, 1, 1, 0),
572 SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER1
, 0, 1, 0),
575 static const struct snd_kcontrol_new line1n_mix
[] = {
576 SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1
, 6, 1, 0),
577 SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER1
, 5, 1, 0),
580 static const struct snd_kcontrol_new line1p_mix
[] = {
581 SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1
, 0, 1, 0),
584 static const struct snd_kcontrol_new line2_mix
[] = {
585 SOC_DAPM_SINGLE("IN2R Switch", WM8993_LINE_MIXER2
, 2, 1, 0),
586 SOC_DAPM_SINGLE("IN2L Switch", WM8993_LINE_MIXER2
, 1, 1, 0),
587 SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER2
, 0, 1, 0),
590 static const struct snd_kcontrol_new line2n_mix
[] = {
591 SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER2
, 6, 1, 0),
592 SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2
, 5, 1, 0),
595 static const struct snd_kcontrol_new line2p_mix
[] = {
596 SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2
, 0, 1, 0),
599 static const struct snd_soc_dapm_widget analogue_dapm_widgets
[] = {
600 SND_SOC_DAPM_INPUT("IN1LN"),
601 SND_SOC_DAPM_INPUT("IN1LP"),
602 SND_SOC_DAPM_INPUT("IN2LN"),
603 SND_SOC_DAPM_INPUT("IN2LP:VXRN"),
604 SND_SOC_DAPM_INPUT("IN1RN"),
605 SND_SOC_DAPM_INPUT("IN1RP"),
606 SND_SOC_DAPM_INPUT("IN2RN"),
607 SND_SOC_DAPM_INPUT("IN2RP:VXRP"),
609 SND_SOC_DAPM_MICBIAS("MICBIAS2", WM8993_POWER_MANAGEMENT_1
, 5, 0),
610 SND_SOC_DAPM_MICBIAS("MICBIAS1", WM8993_POWER_MANAGEMENT_1
, 4, 0),
612 SND_SOC_DAPM_MIXER("IN1L PGA", WM8993_POWER_MANAGEMENT_2
, 6, 0,
613 in1l_pga
, ARRAY_SIZE(in1l_pga
)),
614 SND_SOC_DAPM_MIXER("IN1R PGA", WM8993_POWER_MANAGEMENT_2
, 4, 0,
615 in1r_pga
, ARRAY_SIZE(in1r_pga
)),
617 SND_SOC_DAPM_MIXER("IN2L PGA", WM8993_POWER_MANAGEMENT_2
, 7, 0,
618 in2l_pga
, ARRAY_SIZE(in2l_pga
)),
619 SND_SOC_DAPM_MIXER("IN2R PGA", WM8993_POWER_MANAGEMENT_2
, 5, 0,
620 in2r_pga
, ARRAY_SIZE(in2r_pga
)),
622 SND_SOC_DAPM_MIXER("MIXINL", WM8993_POWER_MANAGEMENT_2
, 9, 0,
623 mixinl
, ARRAY_SIZE(mixinl
)),
624 SND_SOC_DAPM_MIXER("MIXINR", WM8993_POWER_MANAGEMENT_2
, 8, 0,
625 mixinr
, ARRAY_SIZE(mixinr
)),
627 SND_SOC_DAPM_MIXER("Left Output Mixer", WM8993_POWER_MANAGEMENT_3
, 5, 0,
628 left_output_mixer
, ARRAY_SIZE(left_output_mixer
)),
629 SND_SOC_DAPM_MIXER("Right Output Mixer", WM8993_POWER_MANAGEMENT_3
, 4, 0,
630 right_output_mixer
, ARRAY_SIZE(right_output_mixer
)),
632 SND_SOC_DAPM_PGA("Left Output PGA", WM8993_POWER_MANAGEMENT_3
, 7, 0, NULL
, 0),
633 SND_SOC_DAPM_PGA("Right Output PGA", WM8993_POWER_MANAGEMENT_3
, 6, 0, NULL
, 0),
635 SND_SOC_DAPM_SUPPLY("Headphone Supply", SND_SOC_NOPM
, 0, 0, hp_supply_event
,
636 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_PRE_PMD
),
637 SND_SOC_DAPM_PGA_E("Headphone PGA", SND_SOC_NOPM
, 0, 0,
639 hp_event
, SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_PRE_PMD
),
641 SND_SOC_DAPM_MIXER("Earpiece Mixer", SND_SOC_NOPM
, 0, 0,
642 earpiece_mixer
, ARRAY_SIZE(earpiece_mixer
)),
643 SND_SOC_DAPM_PGA_E("Earpiece Driver", WM8993_POWER_MANAGEMENT_1
, 11, 0,
644 NULL
, 0, earpiece_event
,
645 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
647 SND_SOC_DAPM_MIXER("SPKL Boost", SND_SOC_NOPM
, 0, 0,
648 left_speaker_boost
, ARRAY_SIZE(left_speaker_boost
)),
649 SND_SOC_DAPM_MIXER("SPKR Boost", SND_SOC_NOPM
, 0, 0,
650 right_speaker_boost
, ARRAY_SIZE(right_speaker_boost
)),
652 SND_SOC_DAPM_PGA("SPKL Driver", WM8993_POWER_MANAGEMENT_1
, 12, 0,
654 SND_SOC_DAPM_PGA("SPKR Driver", WM8993_POWER_MANAGEMENT_1
, 13, 0,
657 SND_SOC_DAPM_MIXER("LINEOUT1 Mixer", SND_SOC_NOPM
, 0, 0,
658 line1_mix
, ARRAY_SIZE(line1_mix
)),
659 SND_SOC_DAPM_MIXER("LINEOUT2 Mixer", SND_SOC_NOPM
, 0, 0,
660 line2_mix
, ARRAY_SIZE(line2_mix
)),
662 SND_SOC_DAPM_MIXER("LINEOUT1N Mixer", SND_SOC_NOPM
, 0, 0,
663 line1n_mix
, ARRAY_SIZE(line1n_mix
)),
664 SND_SOC_DAPM_MIXER("LINEOUT1P Mixer", SND_SOC_NOPM
, 0, 0,
665 line1p_mix
, ARRAY_SIZE(line1p_mix
)),
666 SND_SOC_DAPM_MIXER("LINEOUT2N Mixer", SND_SOC_NOPM
, 0, 0,
667 line2n_mix
, ARRAY_SIZE(line2n_mix
)),
668 SND_SOC_DAPM_MIXER("LINEOUT2P Mixer", SND_SOC_NOPM
, 0, 0,
669 line2p_mix
, ARRAY_SIZE(line2p_mix
)),
671 SND_SOC_DAPM_PGA("LINEOUT1N Driver", WM8993_POWER_MANAGEMENT_3
, 13, 0,
673 SND_SOC_DAPM_PGA("LINEOUT1P Driver", WM8993_POWER_MANAGEMENT_3
, 12, 0,
675 SND_SOC_DAPM_PGA("LINEOUT2N Driver", WM8993_POWER_MANAGEMENT_3
, 11, 0,
677 SND_SOC_DAPM_PGA("LINEOUT2P Driver", WM8993_POWER_MANAGEMENT_3
, 10, 0,
680 SND_SOC_DAPM_OUTPUT("SPKOUTLP"),
681 SND_SOC_DAPM_OUTPUT("SPKOUTLN"),
682 SND_SOC_DAPM_OUTPUT("SPKOUTRP"),
683 SND_SOC_DAPM_OUTPUT("SPKOUTRN"),
684 SND_SOC_DAPM_OUTPUT("HPOUT1L"),
685 SND_SOC_DAPM_OUTPUT("HPOUT1R"),
686 SND_SOC_DAPM_OUTPUT("HPOUT2P"),
687 SND_SOC_DAPM_OUTPUT("HPOUT2N"),
688 SND_SOC_DAPM_OUTPUT("LINEOUT1P"),
689 SND_SOC_DAPM_OUTPUT("LINEOUT1N"),
690 SND_SOC_DAPM_OUTPUT("LINEOUT2P"),
691 SND_SOC_DAPM_OUTPUT("LINEOUT2N"),
694 static const struct snd_soc_dapm_route analogue_routes
[] = {
695 { "MICBIAS1", NULL
, "CLK_SYS" },
696 { "MICBIAS2", NULL
, "CLK_SYS" },
698 { "IN1L PGA", "IN1LP Switch", "IN1LP" },
699 { "IN1L PGA", "IN1LN Switch", "IN1LN" },
701 { "IN1R PGA", "IN1RP Switch", "IN1RP" },
702 { "IN1R PGA", "IN1RN Switch", "IN1RN" },
704 { "IN2L PGA", "IN2LP Switch", "IN2LP:VXRN" },
705 { "IN2L PGA", "IN2LN Switch", "IN2LN" },
707 { "IN2R PGA", "IN2RP Switch", "IN2RP:VXRP" },
708 { "IN2R PGA", "IN2RN Switch", "IN2RN" },
710 { "Direct Voice", NULL
, "IN2LP:VXRN" },
711 { "Direct Voice", NULL
, "IN2RP:VXRP" },
713 { "MIXINL", "IN1L Switch", "IN1L PGA" },
714 { "MIXINL", "IN2L Switch", "IN2L PGA" },
715 { "MIXINL", NULL
, "Direct Voice" },
716 { "MIXINL", NULL
, "IN1LP" },
717 { "MIXINL", NULL
, "Left Output Mixer" },
719 { "MIXINR", "IN1R Switch", "IN1R PGA" },
720 { "MIXINR", "IN2R Switch", "IN2R PGA" },
721 { "MIXINR", NULL
, "Direct Voice" },
722 { "MIXINR", NULL
, "IN1RP" },
723 { "MIXINR", NULL
, "Right Output Mixer" },
725 { "ADCL", NULL
, "MIXINL" },
726 { "ADCR", NULL
, "MIXINR" },
728 { "Left Output Mixer", "Left Input Switch", "MIXINL" },
729 { "Left Output Mixer", "Right Input Switch", "MIXINR" },
730 { "Left Output Mixer", "IN2RN Switch", "IN2RN" },
731 { "Left Output Mixer", "IN2LN Switch", "IN2LN" },
732 { "Left Output Mixer", "IN2LP Switch", "IN2LP:VXRN" },
733 { "Left Output Mixer", "IN1L Switch", "IN1L PGA" },
734 { "Left Output Mixer", "IN1R Switch", "IN1R PGA" },
736 { "Right Output Mixer", "Left Input Switch", "MIXINL" },
737 { "Right Output Mixer", "Right Input Switch", "MIXINR" },
738 { "Right Output Mixer", "IN2LN Switch", "IN2LN" },
739 { "Right Output Mixer", "IN2RN Switch", "IN2RN" },
740 { "Right Output Mixer", "IN2RP Switch", "IN2RP:VXRP" },
741 { "Right Output Mixer", "IN1L Switch", "IN1L PGA" },
742 { "Right Output Mixer", "IN1R Switch", "IN1R PGA" },
744 { "Left Output PGA", NULL
, "Left Output Mixer" },
745 { "Left Output PGA", NULL
, "TOCLK" },
747 { "Right Output PGA", NULL
, "Right Output Mixer" },
748 { "Right Output PGA", NULL
, "TOCLK" },
750 { "Earpiece Mixer", "Direct Voice Switch", "Direct Voice" },
751 { "Earpiece Mixer", "Left Output Switch", "Left Output PGA" },
752 { "Earpiece Mixer", "Right Output Switch", "Right Output PGA" },
754 { "Earpiece Driver", NULL
, "Earpiece Mixer" },
755 { "HPOUT2N", NULL
, "Earpiece Driver" },
756 { "HPOUT2P", NULL
, "Earpiece Driver" },
758 { "SPKL", "Input Switch", "MIXINL" },
759 { "SPKL", "IN1LP Switch", "IN1LP" },
760 { "SPKL", "Output Switch", "Left Output PGA" },
761 { "SPKL", NULL
, "TOCLK" },
763 { "SPKR", "Input Switch", "MIXINR" },
764 { "SPKR", "IN1RP Switch", "IN1RP" },
765 { "SPKR", "Output Switch", "Right Output PGA" },
766 { "SPKR", NULL
, "TOCLK" },
768 { "SPKL Boost", "Direct Voice Switch", "Direct Voice" },
769 { "SPKL Boost", "SPKL Switch", "SPKL" },
770 { "SPKL Boost", "SPKR Switch", "SPKR" },
772 { "SPKR Boost", "Direct Voice Switch", "Direct Voice" },
773 { "SPKR Boost", "SPKR Switch", "SPKR" },
774 { "SPKR Boost", "SPKL Switch", "SPKL" },
776 { "SPKL Driver", NULL
, "SPKL Boost" },
777 { "SPKL Driver", NULL
, "CLK_SYS" },
779 { "SPKR Driver", NULL
, "SPKR Boost" },
780 { "SPKR Driver", NULL
, "CLK_SYS" },
782 { "SPKOUTLP", NULL
, "SPKL Driver" },
783 { "SPKOUTLN", NULL
, "SPKL Driver" },
784 { "SPKOUTRP", NULL
, "SPKR Driver" },
785 { "SPKOUTRN", NULL
, "SPKR Driver" },
787 { "Left Headphone Mux", "Mixer", "Left Output PGA" },
788 { "Right Headphone Mux", "Mixer", "Right Output PGA" },
790 { "Headphone PGA", NULL
, "Left Headphone Mux" },
791 { "Headphone PGA", NULL
, "Right Headphone Mux" },
792 { "Headphone PGA", NULL
, "CLK_SYS" },
793 { "Headphone PGA", NULL
, "Headphone Supply" },
795 { "HPOUT1L", NULL
, "Headphone PGA" },
796 { "HPOUT1R", NULL
, "Headphone PGA" },
798 { "LINEOUT1N", NULL
, "LINEOUT1N Driver" },
799 { "LINEOUT1P", NULL
, "LINEOUT1P Driver" },
800 { "LINEOUT2N", NULL
, "LINEOUT2N Driver" },
801 { "LINEOUT2P", NULL
, "LINEOUT2P Driver" },
804 static const struct snd_soc_dapm_route lineout1_diff_routes
[] = {
805 { "LINEOUT1 Mixer", "IN1L Switch", "IN1L PGA" },
806 { "LINEOUT1 Mixer", "IN1R Switch", "IN1R PGA" },
807 { "LINEOUT1 Mixer", "Output Switch", "Left Output PGA" },
809 { "LINEOUT1N Driver", NULL
, "LINEOUT1 Mixer" },
810 { "LINEOUT1P Driver", NULL
, "LINEOUT1 Mixer" },
813 static const struct snd_soc_dapm_route lineout1_se_routes
[] = {
814 { "LINEOUT1N Mixer", "Left Output Switch", "Left Output PGA" },
815 { "LINEOUT1N Mixer", "Right Output Switch", "Right Output PGA" },
817 { "LINEOUT1P Mixer", "Left Output Switch", "Left Output PGA" },
819 { "LINEOUT1N Driver", NULL
, "LINEOUT1N Mixer" },
820 { "LINEOUT1P Driver", NULL
, "LINEOUT1P Mixer" },
823 static const struct snd_soc_dapm_route lineout2_diff_routes
[] = {
824 { "LINEOUT2 Mixer", "IN2L Switch", "IN2L PGA" },
825 { "LINEOUT2 Mixer", "IN2R Switch", "IN2R PGA" },
826 { "LINEOUT2 Mixer", "Output Switch", "Right Output PGA" },
828 { "LINEOUT2N Driver", NULL
, "LINEOUT2 Mixer" },
829 { "LINEOUT2P Driver", NULL
, "LINEOUT2 Mixer" },
832 static const struct snd_soc_dapm_route lineout2_se_routes
[] = {
833 { "LINEOUT2N Mixer", "Left Output Switch", "Left Output PGA" },
834 { "LINEOUT2N Mixer", "Right Output Switch", "Right Output PGA" },
836 { "LINEOUT2P Mixer", "Right Output Switch", "Right Output PGA" },
838 { "LINEOUT2N Driver", NULL
, "LINEOUT2N Mixer" },
839 { "LINEOUT2P Driver", NULL
, "LINEOUT2P Mixer" },
842 int wm_hubs_add_analogue_controls(struct snd_soc_codec
*codec
)
844 struct snd_soc_dapm_context
*dapm
= &codec
->dapm
;
846 /* Latch volume update bits & default ZC on */
847 snd_soc_update_bits(codec
, WM8993_LEFT_LINE_INPUT_1_2_VOLUME
,
848 WM8993_IN1_VU
, WM8993_IN1_VU
);
849 snd_soc_update_bits(codec
, WM8993_RIGHT_LINE_INPUT_1_2_VOLUME
,
850 WM8993_IN1_VU
, WM8993_IN1_VU
);
851 snd_soc_update_bits(codec
, WM8993_LEFT_LINE_INPUT_3_4_VOLUME
,
852 WM8993_IN2_VU
, WM8993_IN2_VU
);
853 snd_soc_update_bits(codec
, WM8993_RIGHT_LINE_INPUT_3_4_VOLUME
,
854 WM8993_IN2_VU
, WM8993_IN2_VU
);
856 snd_soc_update_bits(codec
, WM8993_SPEAKER_VOLUME_LEFT
,
857 WM8993_SPKOUT_VU
, WM8993_SPKOUT_VU
);
858 snd_soc_update_bits(codec
, WM8993_SPEAKER_VOLUME_RIGHT
,
859 WM8993_SPKOUT_VU
, WM8993_SPKOUT_VU
);
861 snd_soc_update_bits(codec
, WM8993_LEFT_OUTPUT_VOLUME
,
862 WM8993_HPOUT1_VU
| WM8993_HPOUT1L_ZC
,
863 WM8993_HPOUT1_VU
| WM8993_HPOUT1L_ZC
);
864 snd_soc_update_bits(codec
, WM8993_RIGHT_OUTPUT_VOLUME
,
865 WM8993_HPOUT1_VU
| WM8993_HPOUT1R_ZC
,
866 WM8993_HPOUT1_VU
| WM8993_HPOUT1R_ZC
);
868 snd_soc_update_bits(codec
, WM8993_LEFT_OPGA_VOLUME
,
869 WM8993_MIXOUTL_ZC
| WM8993_MIXOUT_VU
,
870 WM8993_MIXOUTL_ZC
| WM8993_MIXOUT_VU
);
871 snd_soc_update_bits(codec
, WM8993_RIGHT_OPGA_VOLUME
,
872 WM8993_MIXOUTR_ZC
| WM8993_MIXOUT_VU
,
873 WM8993_MIXOUTR_ZC
| WM8993_MIXOUT_VU
);
875 snd_soc_add_controls(codec
, analogue_snd_controls
,
876 ARRAY_SIZE(analogue_snd_controls
));
878 snd_soc_dapm_new_controls(dapm
, analogue_dapm_widgets
,
879 ARRAY_SIZE(analogue_dapm_widgets
));
882 EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_controls
);
884 int wm_hubs_add_analogue_routes(struct snd_soc_codec
*codec
,
885 int lineout1_diff
, int lineout2_diff
)
887 struct wm_hubs_data
*hubs
= snd_soc_codec_get_drvdata(codec
);
888 struct snd_soc_dapm_context
*dapm
= &codec
->dapm
;
890 init_completion(&hubs
->dcs_done
);
892 snd_soc_dapm_add_routes(dapm
, analogue_routes
,
893 ARRAY_SIZE(analogue_routes
));
896 snd_soc_dapm_add_routes(dapm
,
897 lineout1_diff_routes
,
898 ARRAY_SIZE(lineout1_diff_routes
));
900 snd_soc_dapm_add_routes(dapm
,
902 ARRAY_SIZE(lineout1_se_routes
));
905 snd_soc_dapm_add_routes(dapm
,
906 lineout2_diff_routes
,
907 ARRAY_SIZE(lineout2_diff_routes
));
909 snd_soc_dapm_add_routes(dapm
,
911 ARRAY_SIZE(lineout2_se_routes
));
915 EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_routes
);
917 int wm_hubs_handle_analogue_pdata(struct snd_soc_codec
*codec
,
918 int lineout1_diff
, int lineout2_diff
,
919 int lineout1fb
, int lineout2fb
,
920 int jd_scthr
, int jd_thr
, int micbias1_lvl
,
924 snd_soc_update_bits(codec
, WM8993_LINE_MIXER1
,
925 WM8993_LINEOUT1_MODE
,
926 WM8993_LINEOUT1_MODE
);
928 snd_soc_update_bits(codec
, WM8993_LINE_MIXER2
,
929 WM8993_LINEOUT2_MODE
,
930 WM8993_LINEOUT2_MODE
);
932 /* If the line outputs are differential then we aren't presenting
933 * VMID as an output and can disable it.
935 if (lineout1_diff
&& lineout2_diff
)
936 codec
->dapm
.idle_bias_off
= 1;
939 snd_soc_update_bits(codec
, WM8993_ADDITIONAL_CONTROL
,
940 WM8993_LINEOUT1_FB
, WM8993_LINEOUT1_FB
);
943 snd_soc_update_bits(codec
, WM8993_ADDITIONAL_CONTROL
,
944 WM8993_LINEOUT2_FB
, WM8993_LINEOUT2_FB
);
946 snd_soc_update_bits(codec
, WM8993_MICBIAS
,
947 WM8993_JD_SCTHR_MASK
| WM8993_JD_THR_MASK
|
948 WM8993_MICB1_LVL
| WM8993_MICB2_LVL
,
949 jd_scthr
<< WM8993_JD_SCTHR_SHIFT
|
950 jd_thr
<< WM8993_JD_THR_SHIFT
|
952 micbias2_lvl
<< WM8993_MICB2_LVL_SHIFT
);
956 EXPORT_SYMBOL_GPL(wm_hubs_handle_analogue_pdata
);
958 MODULE_DESCRIPTION("Shared support for Wolfson hubs products");
959 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
960 MODULE_LICENSE("GPL");