MAINTAINERS: change broken url for prism54
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / sound / soc / codecs / wm_hubs.c
blob16f1a57da08a597bfd1a12da04f0b3b826bb371d
1 /*
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>
18 #include <linux/pm.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/soc-dapm.h>
26 #include <sound/initval.h>
27 #include <sound/tlv.h>
29 #include "wm8993.h"
30 #include "wm_hubs.h"
32 const DECLARE_TLV_DB_SCALE(wm_hubs_spkmix_tlv, -300, 300, 0);
33 EXPORT_SYMBOL_GPL(wm_hubs_spkmix_tlv);
35 static const DECLARE_TLV_DB_SCALE(inpga_tlv, -1650, 150, 0);
36 static const DECLARE_TLV_DB_SCALE(inmix_sw_tlv, 0, 3000, 0);
37 static const DECLARE_TLV_DB_SCALE(inmix_tlv, -1500, 300, 1);
38 static const DECLARE_TLV_DB_SCALE(earpiece_tlv, -600, 600, 0);
39 static const DECLARE_TLV_DB_SCALE(outmix_tlv, -2100, 300, 0);
40 static const DECLARE_TLV_DB_SCALE(spkmixout_tlv, -1800, 600, 1);
41 static const DECLARE_TLV_DB_SCALE(outpga_tlv, -5700, 100, 0);
42 static const unsigned int spkboost_tlv[] = {
43 TLV_DB_RANGE_HEAD(7),
44 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0),
45 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0),
47 static const DECLARE_TLV_DB_SCALE(line_tlv, -600, 600, 0);
49 static const char *speaker_ref_text[] = {
50 "SPKVDD/2",
51 "VMID",
54 static const struct soc_enum speaker_ref =
55 SOC_ENUM_SINGLE(WM8993_SPEAKER_MIXER, 8, 2, speaker_ref_text);
57 static const char *speaker_mode_text[] = {
58 "Class D",
59 "Class AB",
62 static const struct soc_enum speaker_mode =
63 SOC_ENUM_SINGLE(WM8993_SPKMIXR_ATTENUATION, 8, 2, speaker_mode_text);
65 static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op)
67 unsigned int reg;
68 int count = 0;
69 unsigned int val;
71 val = op | WM8993_DCS_ENA_CHAN_0 | WM8993_DCS_ENA_CHAN_1;
73 /* Trigger the command */
74 snd_soc_write(codec, WM8993_DC_SERVO_0, val);
76 dev_dbg(codec->dev, "Waiting for DC servo...\n");
78 do {
79 count++;
80 msleep(1);
81 reg = snd_soc_read(codec, WM8993_DC_SERVO_0);
82 dev_dbg(codec->dev, "DC servo: %x\n", reg);
83 } while (reg & op && count < 400);
85 if (reg & op)
86 dev_err(codec->dev, "Timed out waiting for DC Servo\n");
90 * Startup calibration of the DC servo
92 static void calibrate_dc_servo(struct snd_soc_codec *codec)
94 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
95 u16 reg, reg_l, reg_r, dcs_cfg;
97 /* Set for 32 series updates */
98 snd_soc_update_bits(codec, WM8993_DC_SERVO_1,
99 WM8993_DCS_SERIES_NO_01_MASK,
100 32 << WM8993_DCS_SERIES_NO_01_SHIFT);
101 wait_for_dc_servo(codec,
102 WM8993_DCS_TRIG_SERIES_0 | WM8993_DCS_TRIG_SERIES_1);
104 /* Apply correction to DC servo result */
105 if (hubs->dcs_codes) {
106 dev_dbg(codec->dev, "Applying %d code DC servo correction\n",
107 hubs->dcs_codes);
109 /* Different chips in the family support different
110 * readback methods.
112 switch (hubs->dcs_readback_mode) {
113 case 0:
114 reg_l = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_1)
115 & WM8993_DCS_INTEG_CHAN_0_MASK;;
116 reg_r = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_2)
117 & WM8993_DCS_INTEG_CHAN_1_MASK;
118 break;
119 case 1:
120 reg = snd_soc_read(codec, WM8993_DC_SERVO_3);
121 reg_l = (reg & WM8993_DCS_DAC_WR_VAL_1_MASK)
122 >> WM8993_DCS_DAC_WR_VAL_1_SHIFT;
123 reg_r = reg & WM8993_DCS_DAC_WR_VAL_0_MASK;
124 break;
125 default:
126 WARN(1, "Unknown DCS readback method");
127 break;
130 dev_dbg(codec->dev, "DCS input: %x %x\n", reg_l, reg_r);
132 /* HPOUT1L */
133 if (reg_l + hubs->dcs_codes > 0 &&
134 reg_l + hubs->dcs_codes < 0xff)
135 reg_l += hubs->dcs_codes;
136 dcs_cfg = reg_l << WM8993_DCS_DAC_WR_VAL_1_SHIFT;
138 /* HPOUT1R */
139 if (reg_r + hubs->dcs_codes > 0 &&
140 reg_r + hubs->dcs_codes < 0xff)
141 reg_r += hubs->dcs_codes;
142 dcs_cfg |= reg_r;
144 dev_dbg(codec->dev, "DCS result: %x\n", dcs_cfg);
146 /* Do it */
147 snd_soc_write(codec, WM8993_DC_SERVO_3, dcs_cfg);
148 wait_for_dc_servo(codec,
149 WM8993_DCS_TRIG_DAC_WR_0 |
150 WM8993_DCS_TRIG_DAC_WR_1);
155 * Update the DC servo calibration on gain changes
157 static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol,
158 struct snd_ctl_elem_value *ucontrol)
160 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
161 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
162 int ret;
164 ret = snd_soc_put_volsw_2r(kcontrol, ucontrol);
166 /* If we're applying an offset correction then updating the
167 * callibration would be likely to introduce further offsets. */
168 if (hubs->dcs_codes)
169 return ret;
171 /* Only need to do this if the outputs are active */
172 if (snd_soc_read(codec, WM8993_POWER_MANAGEMENT_1)
173 & (WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA))
174 snd_soc_update_bits(codec,
175 WM8993_DC_SERVO_0,
176 WM8993_DCS_TRIG_SINGLE_0 |
177 WM8993_DCS_TRIG_SINGLE_1,
178 WM8993_DCS_TRIG_SINGLE_0 |
179 WM8993_DCS_TRIG_SINGLE_1);
181 return ret;
184 static const struct snd_kcontrol_new analogue_snd_controls[] = {
185 SOC_SINGLE_TLV("IN1L Volume", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 0, 31, 0,
186 inpga_tlv),
187 SOC_SINGLE("IN1L Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 7, 1, 1),
188 SOC_SINGLE("IN1L ZC Switch", WM8993_LEFT_LINE_INPUT_1_2_VOLUME, 7, 1, 0),
190 SOC_SINGLE_TLV("IN1R Volume", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 0, 31, 0,
191 inpga_tlv),
192 SOC_SINGLE("IN1R Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 7, 1, 1),
193 SOC_SINGLE("IN1R ZC Switch", WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, 7, 1, 0),
196 SOC_SINGLE_TLV("IN2L Volume", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 0, 31, 0,
197 inpga_tlv),
198 SOC_SINGLE("IN2L Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 7, 1, 1),
199 SOC_SINGLE("IN2L ZC Switch", WM8993_LEFT_LINE_INPUT_3_4_VOLUME, 7, 1, 0),
201 SOC_SINGLE_TLV("IN2R Volume", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 0, 31, 0,
202 inpga_tlv),
203 SOC_SINGLE("IN2R Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 7, 1, 1),
204 SOC_SINGLE("IN2R ZC Switch", WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, 7, 1, 0),
206 SOC_SINGLE_TLV("MIXINL IN2L Volume", WM8993_INPUT_MIXER3, 7, 1, 0,
207 inmix_sw_tlv),
208 SOC_SINGLE_TLV("MIXINL IN1L Volume", WM8993_INPUT_MIXER3, 4, 1, 0,
209 inmix_sw_tlv),
210 SOC_SINGLE_TLV("MIXINL Output Record Volume", WM8993_INPUT_MIXER3, 0, 7, 0,
211 inmix_tlv),
212 SOC_SINGLE_TLV("MIXINL IN1LP Volume", WM8993_INPUT_MIXER5, 6, 7, 0, inmix_tlv),
213 SOC_SINGLE_TLV("MIXINL Direct Voice Volume", WM8993_INPUT_MIXER5, 0, 6, 0,
214 inmix_tlv),
216 SOC_SINGLE_TLV("MIXINR IN2R Volume", WM8993_INPUT_MIXER4, 7, 1, 0,
217 inmix_sw_tlv),
218 SOC_SINGLE_TLV("MIXINR IN1R Volume", WM8993_INPUT_MIXER4, 4, 1, 0,
219 inmix_sw_tlv),
220 SOC_SINGLE_TLV("MIXINR Output Record Volume", WM8993_INPUT_MIXER4, 0, 7, 0,
221 inmix_tlv),
222 SOC_SINGLE_TLV("MIXINR IN1RP Volume", WM8993_INPUT_MIXER6, 6, 7, 0, inmix_tlv),
223 SOC_SINGLE_TLV("MIXINR Direct Voice Volume", WM8993_INPUT_MIXER6, 0, 6, 0,
224 inmix_tlv),
226 SOC_SINGLE_TLV("Left Output Mixer IN2RN Volume", WM8993_OUTPUT_MIXER5, 6, 7, 1,
227 outmix_tlv),
228 SOC_SINGLE_TLV("Left Output Mixer IN2LN Volume", WM8993_OUTPUT_MIXER3, 6, 7, 1,
229 outmix_tlv),
230 SOC_SINGLE_TLV("Left Output Mixer IN2LP Volume", WM8993_OUTPUT_MIXER3, 9, 7, 1,
231 outmix_tlv),
232 SOC_SINGLE_TLV("Left Output Mixer IN1L Volume", WM8993_OUTPUT_MIXER3, 0, 7, 1,
233 outmix_tlv),
234 SOC_SINGLE_TLV("Left Output Mixer IN1R Volume", WM8993_OUTPUT_MIXER3, 3, 7, 1,
235 outmix_tlv),
236 SOC_SINGLE_TLV("Left Output Mixer Right Input Volume",
237 WM8993_OUTPUT_MIXER5, 3, 7, 1, outmix_tlv),
238 SOC_SINGLE_TLV("Left Output Mixer Left Input Volume",
239 WM8993_OUTPUT_MIXER5, 0, 7, 1, outmix_tlv),
240 SOC_SINGLE_TLV("Left Output Mixer DAC Volume", WM8993_OUTPUT_MIXER5, 9, 7, 1,
241 outmix_tlv),
243 SOC_SINGLE_TLV("Right Output Mixer IN2LN Volume",
244 WM8993_OUTPUT_MIXER6, 6, 7, 1, outmix_tlv),
245 SOC_SINGLE_TLV("Right Output Mixer IN2RN Volume",
246 WM8993_OUTPUT_MIXER4, 6, 7, 1, outmix_tlv),
247 SOC_SINGLE_TLV("Right Output Mixer IN1L Volume",
248 WM8993_OUTPUT_MIXER4, 3, 7, 1, outmix_tlv),
249 SOC_SINGLE_TLV("Right Output Mixer IN1R Volume",
250 WM8993_OUTPUT_MIXER4, 0, 7, 1, outmix_tlv),
251 SOC_SINGLE_TLV("Right Output Mixer IN2RP Volume",
252 WM8993_OUTPUT_MIXER4, 9, 7, 1, outmix_tlv),
253 SOC_SINGLE_TLV("Right Output Mixer Left Input Volume",
254 WM8993_OUTPUT_MIXER6, 3, 7, 1, outmix_tlv),
255 SOC_SINGLE_TLV("Right Output Mixer Right Input Volume",
256 WM8993_OUTPUT_MIXER6, 6, 7, 1, outmix_tlv),
257 SOC_SINGLE_TLV("Right Output Mixer DAC Volume",
258 WM8993_OUTPUT_MIXER6, 9, 7, 1, outmix_tlv),
260 SOC_DOUBLE_R_TLV("Output Volume", WM8993_LEFT_OPGA_VOLUME,
261 WM8993_RIGHT_OPGA_VOLUME, 0, 63, 0, outpga_tlv),
262 SOC_DOUBLE_R("Output Switch", WM8993_LEFT_OPGA_VOLUME,
263 WM8993_RIGHT_OPGA_VOLUME, 6, 1, 0),
264 SOC_DOUBLE_R("Output ZC Switch", WM8993_LEFT_OPGA_VOLUME,
265 WM8993_RIGHT_OPGA_VOLUME, 7, 1, 0),
267 SOC_SINGLE("Earpiece Switch", WM8993_HPOUT2_VOLUME, 5, 1, 1),
268 SOC_SINGLE_TLV("Earpiece Volume", WM8993_HPOUT2_VOLUME, 4, 1, 1, earpiece_tlv),
270 SOC_SINGLE_TLV("SPKL Input Volume", WM8993_SPKMIXL_ATTENUATION,
271 5, 1, 1, wm_hubs_spkmix_tlv),
272 SOC_SINGLE_TLV("SPKL IN1LP Volume", WM8993_SPKMIXL_ATTENUATION,
273 4, 1, 1, wm_hubs_spkmix_tlv),
274 SOC_SINGLE_TLV("SPKL Output Volume", WM8993_SPKMIXL_ATTENUATION,
275 3, 1, 1, wm_hubs_spkmix_tlv),
277 SOC_SINGLE_TLV("SPKR Input Volume", WM8993_SPKMIXR_ATTENUATION,
278 5, 1, 1, wm_hubs_spkmix_tlv),
279 SOC_SINGLE_TLV("SPKR IN1RP Volume", WM8993_SPKMIXR_ATTENUATION,
280 4, 1, 1, wm_hubs_spkmix_tlv),
281 SOC_SINGLE_TLV("SPKR Output Volume", WM8993_SPKMIXR_ATTENUATION,
282 3, 1, 1, wm_hubs_spkmix_tlv),
284 SOC_DOUBLE_R_TLV("Speaker Mixer Volume",
285 WM8993_SPKMIXL_ATTENUATION, WM8993_SPKMIXR_ATTENUATION,
286 0, 3, 1, spkmixout_tlv),
287 SOC_DOUBLE_R_TLV("Speaker Volume",
288 WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT,
289 0, 63, 0, outpga_tlv),
290 SOC_DOUBLE_R("Speaker Switch",
291 WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT,
292 6, 1, 0),
293 SOC_DOUBLE_R("Speaker ZC Switch",
294 WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPEAKER_VOLUME_RIGHT,
295 7, 1, 0),
296 SOC_DOUBLE_TLV("Speaker Boost Volume", WM8993_SPKOUT_BOOST, 0, 3, 7, 0,
297 spkboost_tlv),
298 SOC_ENUM("Speaker Reference", speaker_ref),
299 SOC_ENUM("Speaker Mode", speaker_mode),
302 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Headphone Volume",
303 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |
304 SNDRV_CTL_ELEM_ACCESS_READWRITE,
305 .tlv.p = outpga_tlv,
306 .info = snd_soc_info_volsw_2r,
307 .get = snd_soc_get_volsw_2r, .put = wm8993_put_dc_servo,
308 .private_value = (unsigned long)&(struct soc_mixer_control) {
309 .reg = WM8993_LEFT_OUTPUT_VOLUME,
310 .rreg = WM8993_RIGHT_OUTPUT_VOLUME,
311 .shift = 0, .max = 63
314 SOC_DOUBLE_R("Headphone Switch", WM8993_LEFT_OUTPUT_VOLUME,
315 WM8993_RIGHT_OUTPUT_VOLUME, 6, 1, 0),
316 SOC_DOUBLE_R("Headphone ZC Switch", WM8993_LEFT_OUTPUT_VOLUME,
317 WM8993_RIGHT_OUTPUT_VOLUME, 7, 1, 0),
319 SOC_SINGLE("LINEOUT1N Switch", WM8993_LINE_OUTPUTS_VOLUME, 6, 1, 1),
320 SOC_SINGLE("LINEOUT1P Switch", WM8993_LINE_OUTPUTS_VOLUME, 5, 1, 1),
321 SOC_SINGLE_TLV("LINEOUT1 Volume", WM8993_LINE_OUTPUTS_VOLUME, 4, 1, 1,
322 line_tlv),
324 SOC_SINGLE("LINEOUT2N Switch", WM8993_LINE_OUTPUTS_VOLUME, 2, 1, 1),
325 SOC_SINGLE("LINEOUT2P Switch", WM8993_LINE_OUTPUTS_VOLUME, 1, 1, 1),
326 SOC_SINGLE_TLV("LINEOUT2 Volume", WM8993_LINE_OUTPUTS_VOLUME, 0, 1, 1,
327 line_tlv),
330 static int hp_supply_event(struct snd_soc_dapm_widget *w,
331 struct snd_kcontrol *kcontrol, int event)
333 struct snd_soc_codec *codec = w->codec;
334 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
336 switch (event) {
337 case SND_SOC_DAPM_PRE_PMU:
338 switch (hubs->hp_startup_mode) {
339 case 0:
340 break;
341 case 1:
342 /* Enable the headphone amp */
343 snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1,
344 WM8993_HPOUT1L_ENA |
345 WM8993_HPOUT1R_ENA,
346 WM8993_HPOUT1L_ENA |
347 WM8993_HPOUT1R_ENA);
349 /* Enable the second stage */
350 snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0,
351 WM8993_HPOUT1L_DLY |
352 WM8993_HPOUT1R_DLY,
353 WM8993_HPOUT1L_DLY |
354 WM8993_HPOUT1R_DLY);
355 break;
356 default:
357 dev_err(codec->dev, "Unknown HP startup mode %d\n",
358 hubs->hp_startup_mode);
359 break;
362 case SND_SOC_DAPM_PRE_PMD:
363 snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1,
364 WM8993_CP_ENA, 0);
365 break;
368 return 0;
371 static int hp_event(struct snd_soc_dapm_widget *w,
372 struct snd_kcontrol *kcontrol, int event)
374 struct snd_soc_codec *codec = w->codec;
375 unsigned int reg = snd_soc_read(codec, WM8993_ANALOGUE_HP_0);
377 switch (event) {
378 case SND_SOC_DAPM_POST_PMU:
379 snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1,
380 WM8993_CP_ENA, WM8993_CP_ENA);
382 msleep(5);
384 snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1,
385 WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA,
386 WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA);
388 reg |= WM8993_HPOUT1L_DLY | WM8993_HPOUT1R_DLY;
389 snd_soc_write(codec, WM8993_ANALOGUE_HP_0, reg);
391 /* Smallest supported update interval */
392 snd_soc_update_bits(codec, WM8993_DC_SERVO_1,
393 WM8993_DCS_TIMER_PERIOD_01_MASK, 1);
395 calibrate_dc_servo(codec);
397 reg |= WM8993_HPOUT1R_OUTP | WM8993_HPOUT1R_RMV_SHORT |
398 WM8993_HPOUT1L_OUTP | WM8993_HPOUT1L_RMV_SHORT;
399 snd_soc_write(codec, WM8993_ANALOGUE_HP_0, reg);
400 break;
402 case SND_SOC_DAPM_PRE_PMD:
403 snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0,
404 WM8993_HPOUT1L_OUTP |
405 WM8993_HPOUT1R_OUTP |
406 WM8993_HPOUT1L_RMV_SHORT |
407 WM8993_HPOUT1R_RMV_SHORT, 0);
409 snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0,
410 WM8993_HPOUT1L_DLY |
411 WM8993_HPOUT1R_DLY, 0);
413 snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1,
414 WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA,
416 break;
419 return 0;
422 static int earpiece_event(struct snd_soc_dapm_widget *w,
423 struct snd_kcontrol *control, int event)
425 struct snd_soc_codec *codec = w->codec;
426 u16 reg = snd_soc_read(codec, WM8993_ANTIPOP1) & ~WM8993_HPOUT2_IN_ENA;
428 switch (event) {
429 case SND_SOC_DAPM_PRE_PMU:
430 reg |= WM8993_HPOUT2_IN_ENA;
431 snd_soc_write(codec, WM8993_ANTIPOP1, reg);
432 udelay(50);
433 break;
435 case SND_SOC_DAPM_POST_PMD:
436 snd_soc_write(codec, WM8993_ANTIPOP1, reg);
437 break;
439 default:
440 BUG();
441 break;
444 return 0;
447 static const struct snd_kcontrol_new in1l_pga[] = {
448 SOC_DAPM_SINGLE("IN1LP Switch", WM8993_INPUT_MIXER2, 5, 1, 0),
449 SOC_DAPM_SINGLE("IN1LN Switch", WM8993_INPUT_MIXER2, 4, 1, 0),
452 static const struct snd_kcontrol_new in1r_pga[] = {
453 SOC_DAPM_SINGLE("IN1RP Switch", WM8993_INPUT_MIXER2, 1, 1, 0),
454 SOC_DAPM_SINGLE("IN1RN Switch", WM8993_INPUT_MIXER2, 0, 1, 0),
457 static const struct snd_kcontrol_new in2l_pga[] = {
458 SOC_DAPM_SINGLE("IN2LP Switch", WM8993_INPUT_MIXER2, 7, 1, 0),
459 SOC_DAPM_SINGLE("IN2LN Switch", WM8993_INPUT_MIXER2, 6, 1, 0),
462 static const struct snd_kcontrol_new in2r_pga[] = {
463 SOC_DAPM_SINGLE("IN2RP Switch", WM8993_INPUT_MIXER2, 3, 1, 0),
464 SOC_DAPM_SINGLE("IN2RN Switch", WM8993_INPUT_MIXER2, 2, 1, 0),
467 static const struct snd_kcontrol_new mixinl[] = {
468 SOC_DAPM_SINGLE("IN2L Switch", WM8993_INPUT_MIXER3, 8, 1, 0),
469 SOC_DAPM_SINGLE("IN1L Switch", WM8993_INPUT_MIXER3, 5, 1, 0),
472 static const struct snd_kcontrol_new mixinr[] = {
473 SOC_DAPM_SINGLE("IN2R Switch", WM8993_INPUT_MIXER4, 8, 1, 0),
474 SOC_DAPM_SINGLE("IN1R Switch", WM8993_INPUT_MIXER4, 5, 1, 0),
477 static const struct snd_kcontrol_new left_output_mixer[] = {
478 SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER1, 7, 1, 0),
479 SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER1, 6, 1, 0),
480 SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER1, 5, 1, 0),
481 SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER1, 4, 1, 0),
482 SOC_DAPM_SINGLE("IN2LP Switch", WM8993_OUTPUT_MIXER1, 1, 1, 0),
483 SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER1, 3, 1, 0),
484 SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER1, 2, 1, 0),
485 SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER1, 0, 1, 0),
488 static const struct snd_kcontrol_new right_output_mixer[] = {
489 SOC_DAPM_SINGLE("Left Input Switch", WM8993_OUTPUT_MIXER2, 7, 1, 0),
490 SOC_DAPM_SINGLE("Right Input Switch", WM8993_OUTPUT_MIXER2, 6, 1, 0),
491 SOC_DAPM_SINGLE("IN2LN Switch", WM8993_OUTPUT_MIXER2, 5, 1, 0),
492 SOC_DAPM_SINGLE("IN2RN Switch", WM8993_OUTPUT_MIXER2, 4, 1, 0),
493 SOC_DAPM_SINGLE("IN1L Switch", WM8993_OUTPUT_MIXER2, 3, 1, 0),
494 SOC_DAPM_SINGLE("IN1R Switch", WM8993_OUTPUT_MIXER2, 2, 1, 0),
495 SOC_DAPM_SINGLE("IN2RP Switch", WM8993_OUTPUT_MIXER2, 1, 1, 0),
496 SOC_DAPM_SINGLE("DAC Switch", WM8993_OUTPUT_MIXER2, 0, 1, 0),
499 static const struct snd_kcontrol_new earpiece_mixer[] = {
500 SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_HPOUT2_MIXER, 5, 1, 0),
501 SOC_DAPM_SINGLE("Left Output Switch", WM8993_HPOUT2_MIXER, 4, 1, 0),
502 SOC_DAPM_SINGLE("Right Output Switch", WM8993_HPOUT2_MIXER, 3, 1, 0),
505 static const struct snd_kcontrol_new left_speaker_boost[] = {
506 SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS, 5, 1, 0),
507 SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS, 4, 1, 0),
508 SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS, 3, 1, 0),
511 static const struct snd_kcontrol_new right_speaker_boost[] = {
512 SOC_DAPM_SINGLE("Direct Voice Switch", WM8993_SPKOUT_MIXERS, 2, 1, 0),
513 SOC_DAPM_SINGLE("SPKL Switch", WM8993_SPKOUT_MIXERS, 1, 1, 0),
514 SOC_DAPM_SINGLE("SPKR Switch", WM8993_SPKOUT_MIXERS, 0, 1, 0),
517 static const struct snd_kcontrol_new line1_mix[] = {
518 SOC_DAPM_SINGLE("IN1R Switch", WM8993_LINE_MIXER1, 2, 1, 0),
519 SOC_DAPM_SINGLE("IN1L Switch", WM8993_LINE_MIXER1, 1, 1, 0),
520 SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER1, 0, 1, 0),
523 static const struct snd_kcontrol_new line1n_mix[] = {
524 SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1, 6, 1, 0),
525 SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER1, 5, 1, 0),
528 static const struct snd_kcontrol_new line1p_mix[] = {
529 SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER1, 0, 1, 0),
532 static const struct snd_kcontrol_new line2_mix[] = {
533 SOC_DAPM_SINGLE("IN2R Switch", WM8993_LINE_MIXER2, 2, 1, 0),
534 SOC_DAPM_SINGLE("IN2L Switch", WM8993_LINE_MIXER2, 1, 1, 0),
535 SOC_DAPM_SINGLE("Output Switch", WM8993_LINE_MIXER2, 0, 1, 0),
538 static const struct snd_kcontrol_new line2n_mix[] = {
539 SOC_DAPM_SINGLE("Left Output Switch", WM8993_LINE_MIXER2, 6, 1, 0),
540 SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2, 5, 1, 0),
543 static const struct snd_kcontrol_new line2p_mix[] = {
544 SOC_DAPM_SINGLE("Right Output Switch", WM8993_LINE_MIXER2, 0, 1, 0),
547 static const struct snd_soc_dapm_widget analogue_dapm_widgets[] = {
548 SND_SOC_DAPM_INPUT("IN1LN"),
549 SND_SOC_DAPM_INPUT("IN1LP"),
550 SND_SOC_DAPM_INPUT("IN2LN"),
551 SND_SOC_DAPM_INPUT("IN2LP:VXRN"),
552 SND_SOC_DAPM_INPUT("IN1RN"),
553 SND_SOC_DAPM_INPUT("IN1RP"),
554 SND_SOC_DAPM_INPUT("IN2RN"),
555 SND_SOC_DAPM_INPUT("IN2RP:VXRP"),
557 SND_SOC_DAPM_MICBIAS("MICBIAS2", WM8993_POWER_MANAGEMENT_1, 5, 0),
558 SND_SOC_DAPM_MICBIAS("MICBIAS1", WM8993_POWER_MANAGEMENT_1, 4, 0),
560 SND_SOC_DAPM_MIXER("IN1L PGA", WM8993_POWER_MANAGEMENT_2, 6, 0,
561 in1l_pga, ARRAY_SIZE(in1l_pga)),
562 SND_SOC_DAPM_MIXER("IN1R PGA", WM8993_POWER_MANAGEMENT_2, 4, 0,
563 in1r_pga, ARRAY_SIZE(in1r_pga)),
565 SND_SOC_DAPM_MIXER("IN2L PGA", WM8993_POWER_MANAGEMENT_2, 7, 0,
566 in2l_pga, ARRAY_SIZE(in2l_pga)),
567 SND_SOC_DAPM_MIXER("IN2R PGA", WM8993_POWER_MANAGEMENT_2, 5, 0,
568 in2r_pga, ARRAY_SIZE(in2r_pga)),
570 /* Dummy widgets to represent differential paths */
571 SND_SOC_DAPM_PGA("Direct Voice", SND_SOC_NOPM, 0, 0, NULL, 0),
573 SND_SOC_DAPM_MIXER("MIXINL", WM8993_POWER_MANAGEMENT_2, 9, 0,
574 mixinl, ARRAY_SIZE(mixinl)),
575 SND_SOC_DAPM_MIXER("MIXINR", WM8993_POWER_MANAGEMENT_2, 8, 0,
576 mixinr, ARRAY_SIZE(mixinr)),
578 SND_SOC_DAPM_MIXER("Left Output Mixer", WM8993_POWER_MANAGEMENT_3, 5, 0,
579 left_output_mixer, ARRAY_SIZE(left_output_mixer)),
580 SND_SOC_DAPM_MIXER("Right Output Mixer", WM8993_POWER_MANAGEMENT_3, 4, 0,
581 right_output_mixer, ARRAY_SIZE(right_output_mixer)),
583 SND_SOC_DAPM_PGA("Left Output PGA", WM8993_POWER_MANAGEMENT_3, 7, 0, NULL, 0),
584 SND_SOC_DAPM_PGA("Right Output PGA", WM8993_POWER_MANAGEMENT_3, 6, 0, NULL, 0),
586 SND_SOC_DAPM_SUPPLY("Headphone Supply", SND_SOC_NOPM, 0, 0, hp_supply_event,
587 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
588 SND_SOC_DAPM_PGA_E("Headphone PGA", SND_SOC_NOPM, 0, 0,
589 NULL, 0,
590 hp_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
592 SND_SOC_DAPM_MIXER("Earpiece Mixer", SND_SOC_NOPM, 0, 0,
593 earpiece_mixer, ARRAY_SIZE(earpiece_mixer)),
594 SND_SOC_DAPM_PGA_E("Earpiece Driver", WM8993_POWER_MANAGEMENT_1, 11, 0,
595 NULL, 0, earpiece_event,
596 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
598 SND_SOC_DAPM_MIXER("SPKL Boost", SND_SOC_NOPM, 0, 0,
599 left_speaker_boost, ARRAY_SIZE(left_speaker_boost)),
600 SND_SOC_DAPM_MIXER("SPKR Boost", SND_SOC_NOPM, 0, 0,
601 right_speaker_boost, ARRAY_SIZE(right_speaker_boost)),
603 SND_SOC_DAPM_PGA("SPKL Driver", WM8993_POWER_MANAGEMENT_1, 12, 0,
604 NULL, 0),
605 SND_SOC_DAPM_PGA("SPKR Driver", WM8993_POWER_MANAGEMENT_1, 13, 0,
606 NULL, 0),
608 SND_SOC_DAPM_MIXER("LINEOUT1 Mixer", SND_SOC_NOPM, 0, 0,
609 line1_mix, ARRAY_SIZE(line1_mix)),
610 SND_SOC_DAPM_MIXER("LINEOUT2 Mixer", SND_SOC_NOPM, 0, 0,
611 line2_mix, ARRAY_SIZE(line2_mix)),
613 SND_SOC_DAPM_MIXER("LINEOUT1N Mixer", SND_SOC_NOPM, 0, 0,
614 line1n_mix, ARRAY_SIZE(line1n_mix)),
615 SND_SOC_DAPM_MIXER("LINEOUT1P Mixer", SND_SOC_NOPM, 0, 0,
616 line1p_mix, ARRAY_SIZE(line1p_mix)),
617 SND_SOC_DAPM_MIXER("LINEOUT2N Mixer", SND_SOC_NOPM, 0, 0,
618 line2n_mix, ARRAY_SIZE(line2n_mix)),
619 SND_SOC_DAPM_MIXER("LINEOUT2P Mixer", SND_SOC_NOPM, 0, 0,
620 line2p_mix, ARRAY_SIZE(line2p_mix)),
622 SND_SOC_DAPM_PGA("LINEOUT1N Driver", WM8993_POWER_MANAGEMENT_3, 13, 0,
623 NULL, 0),
624 SND_SOC_DAPM_PGA("LINEOUT1P Driver", WM8993_POWER_MANAGEMENT_3, 12, 0,
625 NULL, 0),
626 SND_SOC_DAPM_PGA("LINEOUT2N Driver", WM8993_POWER_MANAGEMENT_3, 11, 0,
627 NULL, 0),
628 SND_SOC_DAPM_PGA("LINEOUT2P Driver", WM8993_POWER_MANAGEMENT_3, 10, 0,
629 NULL, 0),
631 SND_SOC_DAPM_OUTPUT("SPKOUTLP"),
632 SND_SOC_DAPM_OUTPUT("SPKOUTLN"),
633 SND_SOC_DAPM_OUTPUT("SPKOUTRP"),
634 SND_SOC_DAPM_OUTPUT("SPKOUTRN"),
635 SND_SOC_DAPM_OUTPUT("HPOUT1L"),
636 SND_SOC_DAPM_OUTPUT("HPOUT1R"),
637 SND_SOC_DAPM_OUTPUT("HPOUT2P"),
638 SND_SOC_DAPM_OUTPUT("HPOUT2N"),
639 SND_SOC_DAPM_OUTPUT("LINEOUT1P"),
640 SND_SOC_DAPM_OUTPUT("LINEOUT1N"),
641 SND_SOC_DAPM_OUTPUT("LINEOUT2P"),
642 SND_SOC_DAPM_OUTPUT("LINEOUT2N"),
645 static const struct snd_soc_dapm_route analogue_routes[] = {
646 { "IN1L PGA", "IN1LP Switch", "IN1LP" },
647 { "IN1L PGA", "IN1LN Switch", "IN1LN" },
649 { "IN1R PGA", "IN1RP Switch", "IN1RP" },
650 { "IN1R PGA", "IN1RN Switch", "IN1RN" },
652 { "IN2L PGA", "IN2LP Switch", "IN2LP:VXRN" },
653 { "IN2L PGA", "IN2LN Switch", "IN2LN" },
655 { "IN2R PGA", "IN2RP Switch", "IN2RP:VXRP" },
656 { "IN2R PGA", "IN2RN Switch", "IN2RN" },
658 { "Direct Voice", NULL, "IN2LP:VXRN" },
659 { "Direct Voice", NULL, "IN2RP:VXRP" },
661 { "MIXINL", "IN1L Switch", "IN1L PGA" },
662 { "MIXINL", "IN2L Switch", "IN2L PGA" },
663 { "MIXINL", NULL, "Direct Voice" },
664 { "MIXINL", NULL, "IN1LP" },
665 { "MIXINL", NULL, "Left Output Mixer" },
667 { "MIXINR", "IN1R Switch", "IN1R PGA" },
668 { "MIXINR", "IN2R Switch", "IN2R PGA" },
669 { "MIXINR", NULL, "Direct Voice" },
670 { "MIXINR", NULL, "IN1RP" },
671 { "MIXINR", NULL, "Right Output Mixer" },
673 { "ADCL", NULL, "MIXINL" },
674 { "ADCR", NULL, "MIXINR" },
676 { "Left Output Mixer", "Left Input Switch", "MIXINL" },
677 { "Left Output Mixer", "Right Input Switch", "MIXINR" },
678 { "Left Output Mixer", "IN2RN Switch", "IN2RN" },
679 { "Left Output Mixer", "IN2LN Switch", "IN2LN" },
680 { "Left Output Mixer", "IN2LP Switch", "IN2LP:VXRN" },
681 { "Left Output Mixer", "IN1L Switch", "IN1L PGA" },
682 { "Left Output Mixer", "IN1R Switch", "IN1R PGA" },
684 { "Right Output Mixer", "Left Input Switch", "MIXINL" },
685 { "Right Output Mixer", "Right Input Switch", "MIXINR" },
686 { "Right Output Mixer", "IN2LN Switch", "IN2LN" },
687 { "Right Output Mixer", "IN2RN Switch", "IN2RN" },
688 { "Right Output Mixer", "IN2RP Switch", "IN2RP:VXRP" },
689 { "Right Output Mixer", "IN1L Switch", "IN1L PGA" },
690 { "Right Output Mixer", "IN1R Switch", "IN1R PGA" },
692 { "Left Output PGA", NULL, "Left Output Mixer" },
693 { "Left Output PGA", NULL, "TOCLK" },
695 { "Right Output PGA", NULL, "Right Output Mixer" },
696 { "Right Output PGA", NULL, "TOCLK" },
698 { "Earpiece Mixer", "Direct Voice Switch", "Direct Voice" },
699 { "Earpiece Mixer", "Left Output Switch", "Left Output PGA" },
700 { "Earpiece Mixer", "Right Output Switch", "Right Output PGA" },
702 { "Earpiece Driver", NULL, "Earpiece Mixer" },
703 { "HPOUT2N", NULL, "Earpiece Driver" },
704 { "HPOUT2P", NULL, "Earpiece Driver" },
706 { "SPKL", "Input Switch", "MIXINL" },
707 { "SPKL", "IN1LP Switch", "IN1LP" },
708 { "SPKL", "Output Switch", "Left Output Mixer" },
709 { "SPKL", NULL, "TOCLK" },
711 { "SPKR", "Input Switch", "MIXINR" },
712 { "SPKR", "IN1RP Switch", "IN1RP" },
713 { "SPKR", "Output Switch", "Right Output Mixer" },
714 { "SPKR", NULL, "TOCLK" },
716 { "SPKL Boost", "Direct Voice Switch", "Direct Voice" },
717 { "SPKL Boost", "SPKL Switch", "SPKL" },
718 { "SPKL Boost", "SPKR Switch", "SPKR" },
720 { "SPKR Boost", "Direct Voice Switch", "Direct Voice" },
721 { "SPKR Boost", "SPKR Switch", "SPKR" },
722 { "SPKR Boost", "SPKL Switch", "SPKL" },
724 { "SPKL Driver", NULL, "SPKL Boost" },
725 { "SPKL Driver", NULL, "CLK_SYS" },
727 { "SPKR Driver", NULL, "SPKR Boost" },
728 { "SPKR Driver", NULL, "CLK_SYS" },
730 { "SPKOUTLP", NULL, "SPKL Driver" },
731 { "SPKOUTLN", NULL, "SPKL Driver" },
732 { "SPKOUTRP", NULL, "SPKR Driver" },
733 { "SPKOUTRN", NULL, "SPKR Driver" },
735 { "Left Headphone Mux", "Mixer", "Left Output Mixer" },
736 { "Right Headphone Mux", "Mixer", "Right Output Mixer" },
738 { "Headphone PGA", NULL, "Left Headphone Mux" },
739 { "Headphone PGA", NULL, "Right Headphone Mux" },
740 { "Headphone PGA", NULL, "CLK_SYS" },
741 { "Headphone PGA", NULL, "Headphone Supply" },
743 { "HPOUT1L", NULL, "Headphone PGA" },
744 { "HPOUT1R", NULL, "Headphone PGA" },
746 { "LINEOUT1N", NULL, "LINEOUT1N Driver" },
747 { "LINEOUT1P", NULL, "LINEOUT1P Driver" },
748 { "LINEOUT2N", NULL, "LINEOUT2N Driver" },
749 { "LINEOUT2P", NULL, "LINEOUT2P Driver" },
752 static const struct snd_soc_dapm_route lineout1_diff_routes[] = {
753 { "LINEOUT1 Mixer", "IN1L Switch", "IN1L PGA" },
754 { "LINEOUT1 Mixer", "IN1R Switch", "IN1R PGA" },
755 { "LINEOUT1 Mixer", "Output Switch", "Left Output Mixer" },
757 { "LINEOUT1N Driver", NULL, "LINEOUT1 Mixer" },
758 { "LINEOUT1P Driver", NULL, "LINEOUT1 Mixer" },
761 static const struct snd_soc_dapm_route lineout1_se_routes[] = {
762 { "LINEOUT1N Mixer", "Left Output Switch", "Left Output Mixer" },
763 { "LINEOUT1N Mixer", "Right Output Switch", "Left Output Mixer" },
765 { "LINEOUT1P Mixer", "Left Output Switch", "Left Output Mixer" },
767 { "LINEOUT1N Driver", NULL, "LINEOUT1N Mixer" },
768 { "LINEOUT1P Driver", NULL, "LINEOUT1P Mixer" },
771 static const struct snd_soc_dapm_route lineout2_diff_routes[] = {
772 { "LINEOUT2 Mixer", "IN2L Switch", "IN2L PGA" },
773 { "LINEOUT2 Mixer", "IN2R Switch", "IN2R PGA" },
774 { "LINEOUT2 Mixer", "Output Switch", "Right Output Mixer" },
776 { "LINEOUT2N Driver", NULL, "LINEOUT2 Mixer" },
777 { "LINEOUT2P Driver", NULL, "LINEOUT2 Mixer" },
780 static const struct snd_soc_dapm_route lineout2_se_routes[] = {
781 { "LINEOUT2N Mixer", "Left Output Switch", "Left Output Mixer" },
782 { "LINEOUT2N Mixer", "Right Output Switch", "Left Output Mixer" },
784 { "LINEOUT2P Mixer", "Right Output Switch", "Right Output Mixer" },
786 { "LINEOUT2N Driver", NULL, "LINEOUT2N Mixer" },
787 { "LINEOUT2P Driver", NULL, "LINEOUT2P Mixer" },
790 int wm_hubs_add_analogue_controls(struct snd_soc_codec *codec)
792 /* Latch volume update bits & default ZC on */
793 snd_soc_update_bits(codec, WM8993_LEFT_LINE_INPUT_1_2_VOLUME,
794 WM8993_IN1_VU, WM8993_IN1_VU);
795 snd_soc_update_bits(codec, WM8993_RIGHT_LINE_INPUT_1_2_VOLUME,
796 WM8993_IN1_VU, WM8993_IN1_VU);
797 snd_soc_update_bits(codec, WM8993_LEFT_LINE_INPUT_3_4_VOLUME,
798 WM8993_IN2_VU, WM8993_IN2_VU);
799 snd_soc_update_bits(codec, WM8993_RIGHT_LINE_INPUT_3_4_VOLUME,
800 WM8993_IN2_VU, WM8993_IN2_VU);
802 snd_soc_update_bits(codec, WM8993_SPEAKER_VOLUME_RIGHT,
803 WM8993_SPKOUT_VU, WM8993_SPKOUT_VU);
805 snd_soc_update_bits(codec, WM8993_LEFT_OUTPUT_VOLUME,
806 WM8993_HPOUT1L_ZC, WM8993_HPOUT1L_ZC);
807 snd_soc_update_bits(codec, WM8993_RIGHT_OUTPUT_VOLUME,
808 WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC,
809 WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC);
811 snd_soc_update_bits(codec, WM8993_LEFT_OPGA_VOLUME,
812 WM8993_MIXOUTL_ZC, WM8993_MIXOUTL_ZC);
813 snd_soc_update_bits(codec, WM8993_RIGHT_OPGA_VOLUME,
814 WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU,
815 WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU);
817 snd_soc_add_controls(codec, analogue_snd_controls,
818 ARRAY_SIZE(analogue_snd_controls));
820 snd_soc_dapm_new_controls(codec, analogue_dapm_widgets,
821 ARRAY_SIZE(analogue_dapm_widgets));
822 return 0;
824 EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_controls);
826 int wm_hubs_add_analogue_routes(struct snd_soc_codec *codec,
827 int lineout1_diff, int lineout2_diff)
829 snd_soc_dapm_add_routes(codec, analogue_routes,
830 ARRAY_SIZE(analogue_routes));
832 if (lineout1_diff)
833 snd_soc_dapm_add_routes(codec,
834 lineout1_diff_routes,
835 ARRAY_SIZE(lineout1_diff_routes));
836 else
837 snd_soc_dapm_add_routes(codec,
838 lineout1_se_routes,
839 ARRAY_SIZE(lineout1_se_routes));
841 if (lineout2_diff)
842 snd_soc_dapm_add_routes(codec,
843 lineout2_diff_routes,
844 ARRAY_SIZE(lineout2_diff_routes));
845 else
846 snd_soc_dapm_add_routes(codec,
847 lineout2_se_routes,
848 ARRAY_SIZE(lineout2_se_routes));
850 return 0;
852 EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_routes);
854 int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec,
855 int lineout1_diff, int lineout2_diff,
856 int lineout1fb, int lineout2fb,
857 int jd_scthr, int jd_thr, int micbias1_lvl,
858 int micbias2_lvl)
860 if (!lineout1_diff)
861 snd_soc_update_bits(codec, WM8993_LINE_MIXER1,
862 WM8993_LINEOUT1_MODE,
863 WM8993_LINEOUT1_MODE);
864 if (!lineout2_diff)
865 snd_soc_update_bits(codec, WM8993_LINE_MIXER2,
866 WM8993_LINEOUT2_MODE,
867 WM8993_LINEOUT2_MODE);
869 /* If the line outputs are differential then we aren't presenting
870 * VMID as an output and can disable it.
872 if (lineout1_diff && lineout2_diff)
873 codec->idle_bias_off = 1;
875 if (lineout1fb)
876 snd_soc_update_bits(codec, WM8993_ADDITIONAL_CONTROL,
877 WM8993_LINEOUT1_FB, WM8993_LINEOUT1_FB);
879 if (lineout2fb)
880 snd_soc_update_bits(codec, WM8993_ADDITIONAL_CONTROL,
881 WM8993_LINEOUT2_FB, WM8993_LINEOUT2_FB);
883 snd_soc_update_bits(codec, WM8993_MICBIAS,
884 WM8993_JD_SCTHR_MASK | WM8993_JD_THR_MASK |
885 WM8993_MICB1_LVL | WM8993_MICB2_LVL,
886 jd_scthr << WM8993_JD_SCTHR_SHIFT |
887 jd_thr << WM8993_JD_THR_SHIFT |
888 micbias1_lvl |
889 micbias2_lvl << WM8993_MICB2_LVL_SHIFT);
891 return 0;
893 EXPORT_SYMBOL_GPL(wm_hubs_handle_analogue_pdata);
895 MODULE_DESCRIPTION("Shared support for Wolfson hubs products");
896 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
897 MODULE_LICENSE("GPL");