1
2
3
4
5
6
7
8
9
10
11
12
13
14#include <linux/module.h>
15#include <linux/moduleparam.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/delay.h>
19#include <linux/pm.h>
20#include <linux/regmap.h>
21#include <linux/i2c.h>
22#include <linux/slab.h>
23#include <sound/core.h>
24#include <sound/pcm.h>
25#include <sound/pcm_params.h>
26#include <sound/soc.h>
27#include <sound/soc-dapm.h>
28#include <sound/tlv.h>
29#include <sound/jack.h>
30#include <sound/initval.h>
31#include <asm/div64.h>
32#include "isabelle.h"
33
34
35
36static struct reg_default isabelle_reg_defs[] = {
37 { 0, 0x00 },
38 { 1, 0x00 },
39 { 2, 0x00 },
40 { 3, 0x00 },
41 { 4, 0x00 },
42 { 5, 0x00 },
43 { 6, 0x00 },
44 { 7, 0x00 },
45 { 8, 0x00 },
46 { 9, 0x00 },
47 { 10, 0x00 },
48 { 11, 0x00 },
49 { 12, 0x00 },
50 { 13, 0x00 },
51 { 14, 0x00 },
52 { 15, 0x00 },
53 { 16, 0x00 },
54 { 17, 0x00 },
55 { 18, 0x00 },
56 { 19, 0x00 },
57 { 20, 0x00 },
58 { 21, 0x02 },
59 { 22, 0x02 },
60 { 23, 0x02 },
61 { 24, 0x02 },
62 { 25, 0x0F },
63 { 26, 0x8F },
64 { 27, 0x0F },
65 { 28, 0x8F },
66 { 29, 0x00 },
67 { 30, 0x00 },
68 { 31, 0x00 },
69 { 32, 0x00 },
70 { 33, 0x00 },
71 { 34, 0x00 },
72 { 35, 0x00 },
73 { 36, 0x00 },
74 { 37, 0x00 },
75 { 38, 0x00 },
76 { 39, 0x00 },
77 { 40, 0x00 },
78 { 41, 0x00 },
79 { 42, 0x00 },
80 { 43, 0x00 },
81 { 44, 0x00 },
82 { 45, 0x00 },
83 { 46, 0x00 },
84 { 47, 0x00 },
85 { 48, 0x00 },
86 { 49, 0x00 },
87 { 50, 0x00 },
88 { 51, 0x00 },
89 { 52, 0x00 },
90 { 53, 0x00 },
91 { 54, 0x00 },
92 { 55, 0x00 },
93 { 56, 0x00 },
94 { 57, 0x00 },
95 { 58, 0x00 },
96 { 59, 0x00 },
97 { 60, 0x00 },
98 { 61, 0x00 },
99 { 62, 0x00 },
100 { 63, 0x00 },
101 { 64, 0x00 },
102 { 65, 0x00 },
103 { 66, 0x00 },
104 { 67, 0x00 },
105 { 68, 0x00 },
106 { 69, 0x90 },
107 { 70, 0x90 },
108 { 71, 0x90 },
109 { 72, 0x00 },
110 { 73, 0x00 },
111 { 74, 0x00 },
112 { 75, 0x00 },
113 { 76, 0x00 },
114 { 77, 0x00 },
115 { 78, 0x00 },
116 { 79, 0x00 },
117 { 80, 0x00 },
118 { 81, 0x00 },
119 { 82, 0x00 },
120 { 83, 0x00 },
121 { 84, 0x00 },
122 { 85, 0x07 },
123 { 86, 0x00 },
124 { 87, 0x00 },
125 { 88, 0x00 },
126 { 89, 0x07 },
127 { 90, 0x80 },
128 { 91, 0x07 },
129 { 92, 0x07 },
130 { 93, 0x00 },
131 { 94, 0x00 },
132 { 95, 0x00 },
133 { 96, 0x00 },
134 { 97, 0x00 },
135 { 98, 0x00 },
136 { 99, 0x00 },
137};
138
139static const char *isabelle_rx1_texts[] = {"VRX1", "ARX1"};
140static const char *isabelle_rx2_texts[] = {"VRX2", "ARX2"};
141
142static const struct soc_enum isabelle_rx1_enum[] = {
143 SOC_ENUM_SINGLE(ISABELLE_VOICE_HPF_CFG_REG, 3,
144 ARRAY_SIZE(isabelle_rx1_texts), isabelle_rx1_texts),
145 SOC_ENUM_SINGLE(ISABELLE_AUDIO_HPF_CFG_REG, 5,
146 ARRAY_SIZE(isabelle_rx1_texts), isabelle_rx1_texts),
147};
148
149static const struct soc_enum isabelle_rx2_enum[] = {
150 SOC_ENUM_SINGLE(ISABELLE_VOICE_HPF_CFG_REG, 2,
151 ARRAY_SIZE(isabelle_rx2_texts), isabelle_rx2_texts),
152 SOC_ENUM_SINGLE(ISABELLE_AUDIO_HPF_CFG_REG, 4,
153 ARRAY_SIZE(isabelle_rx2_texts), isabelle_rx2_texts),
154};
155
156
157static const struct snd_kcontrol_new rx1_mux_controls =
158 SOC_DAPM_ENUM("Route", isabelle_rx1_enum);
159
160static const struct snd_kcontrol_new rx2_mux_controls =
161 SOC_DAPM_ENUM("Route", isabelle_rx2_enum);
162
163
164static const char *isabelle_atx_texts[] = {"AMIC1", "DMIC"};
165static const char *isabelle_vtx_texts[] = {"AMIC2", "DMIC"};
166
167static const struct soc_enum isabelle_atx_enum[] = {
168 SOC_ENUM_SINGLE(ISABELLE_AMIC_CFG_REG, 7,
169 ARRAY_SIZE(isabelle_atx_texts), isabelle_atx_texts),
170 SOC_ENUM_SINGLE(ISABELLE_DMIC_CFG_REG, 0,
171 ARRAY_SIZE(isabelle_atx_texts), isabelle_atx_texts),
172};
173
174static const struct soc_enum isabelle_vtx_enum[] = {
175 SOC_ENUM_SINGLE(ISABELLE_AMIC_CFG_REG, 6,
176 ARRAY_SIZE(isabelle_vtx_texts), isabelle_vtx_texts),
177 SOC_ENUM_SINGLE(ISABELLE_DMIC_CFG_REG, 0,
178 ARRAY_SIZE(isabelle_vtx_texts), isabelle_vtx_texts),
179};
180
181static const struct snd_kcontrol_new atx_mux_controls =
182 SOC_DAPM_ENUM("Route", isabelle_atx_enum);
183
184static const struct snd_kcontrol_new vtx_mux_controls =
185 SOC_DAPM_ENUM("Route", isabelle_vtx_enum);
186
187
188static const char *isabelle_amic1_texts[] = {
189 "Main Mic", "Headset Mic", "Aux/FM Left"};
190
191
192static const char *isabelle_amic2_texts[] = {"Sub Mic", "Aux/FM Right"};
193
194static SOC_ENUM_SINGLE_DECL(isabelle_amic1_enum,
195 ISABELLE_AMIC_CFG_REG, 5,
196 isabelle_amic1_texts);
197
198static SOC_ENUM_SINGLE_DECL(isabelle_amic2_enum,
199 ISABELLE_AMIC_CFG_REG, 4,
200 isabelle_amic2_texts);
201
202static const struct snd_kcontrol_new amic1_control =
203 SOC_DAPM_ENUM("Route", isabelle_amic1_enum);
204
205static const struct snd_kcontrol_new amic2_control =
206 SOC_DAPM_ENUM("Route", isabelle_amic2_enum);
207
208static const char *isabelle_st_audio_texts[] = {"ATX1", "ATX2"};
209
210static const char *isabelle_st_voice_texts[] = {"VTX1", "VTX2"};
211
212static const struct soc_enum isabelle_st_audio_enum[] = {
213 SOC_ENUM_SINGLE(ISABELLE_ATX_STPGA1_CFG_REG, 7,
214 ARRAY_SIZE(isabelle_st_audio_texts),
215 isabelle_st_audio_texts),
216 SOC_ENUM_SINGLE(ISABELLE_ATX_STPGA2_CFG_REG, 7,
217 ARRAY_SIZE(isabelle_st_audio_texts),
218 isabelle_st_audio_texts),
219};
220
221static const struct soc_enum isabelle_st_voice_enum[] = {
222 SOC_ENUM_SINGLE(ISABELLE_VTX_STPGA1_CFG_REG, 7,
223 ARRAY_SIZE(isabelle_st_voice_texts),
224 isabelle_st_voice_texts),
225 SOC_ENUM_SINGLE(ISABELLE_VTX2_STPGA2_CFG_REG, 7,
226 ARRAY_SIZE(isabelle_st_voice_texts),
227 isabelle_st_voice_texts),
228};
229
230static const struct snd_kcontrol_new st_audio_control =
231 SOC_DAPM_ENUM("Route", isabelle_st_audio_enum);
232
233static const struct snd_kcontrol_new st_voice_control =
234 SOC_DAPM_ENUM("Route", isabelle_st_voice_enum);
235
236
237static const struct snd_kcontrol_new isabelle_hs_left_mixer_controls[] = {
238SOC_DAPM_SINGLE("DAC1L Playback Switch", ISABELLE_HSDRV_CFG1_REG, 7, 1, 0),
239SOC_DAPM_SINGLE("APGA1 Playback Switch", ISABELLE_HSDRV_CFG1_REG, 6, 1, 0),
240};
241
242static const struct snd_kcontrol_new isabelle_hs_right_mixer_controls[] = {
243SOC_DAPM_SINGLE("DAC1R Playback Switch", ISABELLE_HSDRV_CFG1_REG, 5, 1, 0),
244SOC_DAPM_SINGLE("APGA2 Playback Switch", ISABELLE_HSDRV_CFG1_REG, 4, 1, 0),
245};
246
247static const struct snd_kcontrol_new isabelle_hf_left_mixer_controls[] = {
248SOC_DAPM_SINGLE("DAC2L Playback Switch", ISABELLE_HFLPGA_CFG_REG, 7, 1, 0),
249SOC_DAPM_SINGLE("APGA1 Playback Switch", ISABELLE_HFLPGA_CFG_REG, 6, 1, 0),
250};
251
252static const struct snd_kcontrol_new isabelle_hf_right_mixer_controls[] = {
253SOC_DAPM_SINGLE("DAC2R Playback Switch", ISABELLE_HFRPGA_CFG_REG, 7, 1, 0),
254SOC_DAPM_SINGLE("APGA2 Playback Switch", ISABELLE_HFRPGA_CFG_REG, 6, 1, 0),
255};
256
257static const struct snd_kcontrol_new isabelle_ep_mixer_controls[] = {
258SOC_DAPM_SINGLE("DAC2L Playback Switch", ISABELLE_EARDRV_CFG1_REG, 7, 1, 0),
259SOC_DAPM_SINGLE("APGA1 Playback Switch", ISABELLE_EARDRV_CFG1_REG, 6, 1, 0),
260};
261
262static const struct snd_kcontrol_new isabelle_aux_left_mixer_controls[] = {
263SOC_DAPM_SINGLE("DAC3L Playback Switch", ISABELLE_LINEAMP_CFG_REG, 7, 1, 0),
264SOC_DAPM_SINGLE("APGA1 Playback Switch", ISABELLE_LINEAMP_CFG_REG, 6, 1, 0),
265};
266
267static const struct snd_kcontrol_new isabelle_aux_right_mixer_controls[] = {
268SOC_DAPM_SINGLE("DAC3R Playback Switch", ISABELLE_LINEAMP_CFG_REG, 5, 1, 0),
269SOC_DAPM_SINGLE("APGA2 Playback Switch", ISABELLE_LINEAMP_CFG_REG, 4, 1, 0),
270};
271
272static const struct snd_kcontrol_new isabelle_dpga1_left_mixer_controls[] = {
273SOC_DAPM_SINGLE("RX1 Playback Switch", ISABELLE_DPGA1LR_IN_SEL_REG, 7, 1, 0),
274SOC_DAPM_SINGLE("RX3 Playback Switch", ISABELLE_DPGA1LR_IN_SEL_REG, 6, 1, 0),
275SOC_DAPM_SINGLE("RX5 Playback Switch", ISABELLE_DPGA1LR_IN_SEL_REG, 5, 1, 0),
276};
277
278static const struct snd_kcontrol_new isabelle_dpga1_right_mixer_controls[] = {
279SOC_DAPM_SINGLE("RX2 Playback Switch", ISABELLE_DPGA1LR_IN_SEL_REG, 3, 1, 0),
280SOC_DAPM_SINGLE("RX4 Playback Switch", ISABELLE_DPGA1LR_IN_SEL_REG, 2, 1, 0),
281SOC_DAPM_SINGLE("RX6 Playback Switch", ISABELLE_DPGA1LR_IN_SEL_REG, 1, 1, 0),
282};
283
284static const struct snd_kcontrol_new isabelle_dpga2_left_mixer_controls[] = {
285SOC_DAPM_SINGLE("RX1 Playback Switch", ISABELLE_DPGA2L_IN_SEL_REG, 7, 1, 0),
286SOC_DAPM_SINGLE("RX2 Playback Switch", ISABELLE_DPGA2L_IN_SEL_REG, 6, 1, 0),
287SOC_DAPM_SINGLE("RX3 Playback Switch", ISABELLE_DPGA2L_IN_SEL_REG, 5, 1, 0),
288SOC_DAPM_SINGLE("RX4 Playback Switch", ISABELLE_DPGA2L_IN_SEL_REG, 4, 1, 0),
289SOC_DAPM_SINGLE("RX5 Playback Switch", ISABELLE_DPGA2L_IN_SEL_REG, 3, 1, 0),
290SOC_DAPM_SINGLE("RX6 Playback Switch", ISABELLE_DPGA2L_IN_SEL_REG, 2, 1, 0),
291};
292
293static const struct snd_kcontrol_new isabelle_dpga2_right_mixer_controls[] = {
294SOC_DAPM_SINGLE("USNC Playback Switch", ISABELLE_DPGA2R_IN_SEL_REG, 7, 1, 0),
295SOC_DAPM_SINGLE("RX2 Playback Switch", ISABELLE_DPGA2R_IN_SEL_REG, 3, 1, 0),
296SOC_DAPM_SINGLE("RX4 Playback Switch", ISABELLE_DPGA2R_IN_SEL_REG, 2, 1, 0),
297SOC_DAPM_SINGLE("RX6 Playback Switch", ISABELLE_DPGA2R_IN_SEL_REG, 1, 1, 0),
298};
299
300static const struct snd_kcontrol_new isabelle_dpga3_left_mixer_controls[] = {
301SOC_DAPM_SINGLE("RX1 Playback Switch", ISABELLE_DPGA3LR_IN_SEL_REG, 7, 1, 0),
302SOC_DAPM_SINGLE("RX3 Playback Switch", ISABELLE_DPGA3LR_IN_SEL_REG, 6, 1, 0),
303SOC_DAPM_SINGLE("RX5 Playback Switch", ISABELLE_DPGA3LR_IN_SEL_REG, 5, 1, 0),
304};
305
306static const struct snd_kcontrol_new isabelle_dpga3_right_mixer_controls[] = {
307SOC_DAPM_SINGLE("RX2 Playback Switch", ISABELLE_DPGA3LR_IN_SEL_REG, 3, 1, 0),
308SOC_DAPM_SINGLE("RX4 Playback Switch", ISABELLE_DPGA3LR_IN_SEL_REG, 2, 1, 0),
309SOC_DAPM_SINGLE("RX6 Playback Switch", ISABELLE_DPGA3LR_IN_SEL_REG, 1, 1, 0),
310};
311
312static const struct snd_kcontrol_new isabelle_rx1_mixer_controls[] = {
313SOC_DAPM_SINGLE("ST1 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 7, 1, 0),
314SOC_DAPM_SINGLE("DL1 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 6, 1, 0),
315};
316
317static const struct snd_kcontrol_new isabelle_rx2_mixer_controls[] = {
318SOC_DAPM_SINGLE("ST2 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 5, 1, 0),
319SOC_DAPM_SINGLE("DL2 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 4, 1, 0),
320};
321
322static const struct snd_kcontrol_new isabelle_rx3_mixer_controls[] = {
323SOC_DAPM_SINGLE("ST1 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 3, 1, 0),
324SOC_DAPM_SINGLE("DL3 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 2, 1, 0),
325};
326
327static const struct snd_kcontrol_new isabelle_rx4_mixer_controls[] = {
328SOC_DAPM_SINGLE("ST2 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 1, 1, 0),
329SOC_DAPM_SINGLE("DL4 Playback Switch", ISABELLE_RX_INPUT_CFG_REG, 0, 1, 0),
330};
331
332static const struct snd_kcontrol_new isabelle_rx5_mixer_controls[] = {
333SOC_DAPM_SINGLE("ST1 Playback Switch", ISABELLE_RX_INPUT_CFG2_REG, 7, 1, 0),
334SOC_DAPM_SINGLE("DL5 Playback Switch", ISABELLE_RX_INPUT_CFG2_REG, 6, 1, 0),
335};
336
337static const struct snd_kcontrol_new isabelle_rx6_mixer_controls[] = {
338SOC_DAPM_SINGLE("ST2 Playback Switch", ISABELLE_RX_INPUT_CFG2_REG, 5, 1, 0),
339SOC_DAPM_SINGLE("DL6 Playback Switch", ISABELLE_RX_INPUT_CFG2_REG, 4, 1, 0),
340};
341
342static const struct snd_kcontrol_new ep_path_enable_control =
343 SOC_DAPM_SINGLE("Switch", ISABELLE_EARDRV_CFG2_REG, 0, 1, 0);
344
345
346static const DECLARE_TLV_DB_SCALE(mic_amp_tlv, 0, 100, 0);
347static const DECLARE_TLV_DB_SCALE(afm_amp_tlv, -3300, 300, 0);
348static const DECLARE_TLV_DB_SCALE(dac_tlv, -1200, 200, 0);
349static const DECLARE_TLV_DB_SCALE(hf_tlv, -5000, 200, 0);
350
351
352static const DECLARE_TLV_DB_SCALE(dpga_tlv, -6300, 100, 1);
353
354
355static const DECLARE_TLV_DB_SCALE(rx_tlv, -6300, 100, 1);
356
357static const DECLARE_TLV_DB_SCALE(st_tlv, -2700, 300, 1);
358static const DECLARE_TLV_DB_SCALE(tx_tlv, -600, 100, 0);
359
360static const struct snd_kcontrol_new isabelle_snd_controls[] = {
361 SOC_DOUBLE_TLV("Headset Playback Volume", ISABELLE_HSDRV_GAIN_REG,
362 4, 0, 0xF, 0, dac_tlv),
363 SOC_DOUBLE_R_TLV("Handsfree Playback Volume",
364 ISABELLE_HFLPGA_CFG_REG, ISABELLE_HFRPGA_CFG_REG,
365 0, 0x1F, 0, hf_tlv),
366 SOC_DOUBLE_TLV("Aux Playback Volume", ISABELLE_LINEAMP_GAIN_REG,
367 4, 0, 0xF, 0, dac_tlv),
368 SOC_SINGLE_TLV("Earpiece Playback Volume", ISABELLE_EARDRV_CFG1_REG,
369 0, 0xF, 0, dac_tlv),
370
371 SOC_DOUBLE_TLV("Aux FM Volume", ISABELLE_APGA_GAIN_REG, 4, 0, 0xF, 0,
372 afm_amp_tlv),
373 SOC_SINGLE_TLV("Mic1 Capture Volume", ISABELLE_MIC1_GAIN_REG, 3, 0x1F,
374 0, mic_amp_tlv),
375 SOC_SINGLE_TLV("Mic2 Capture Volume", ISABELLE_MIC2_GAIN_REG, 3, 0x1F,
376 0, mic_amp_tlv),
377
378 SOC_DOUBLE_R_TLV("DPGA1 Volume", ISABELLE_DPGA1L_GAIN_REG,
379 ISABELLE_DPGA1R_GAIN_REG, 0, 0x3F, 0, dpga_tlv),
380 SOC_DOUBLE_R_TLV("DPGA2 Volume", ISABELLE_DPGA2L_GAIN_REG,
381 ISABELLE_DPGA2R_GAIN_REG, 0, 0x3F, 0, dpga_tlv),
382 SOC_DOUBLE_R_TLV("DPGA3 Volume", ISABELLE_DPGA3L_GAIN_REG,
383 ISABELLE_DPGA3R_GAIN_REG, 0, 0x3F, 0, dpga_tlv),
384
385 SOC_SINGLE_TLV("Sidetone Audio TX1 Volume",
386 ISABELLE_ATX_STPGA1_CFG_REG, 0, 0xF, 0, st_tlv),
387 SOC_SINGLE_TLV("Sidetone Audio TX2 Volume",
388 ISABELLE_ATX_STPGA2_CFG_REG, 0, 0xF, 0, st_tlv),
389 SOC_SINGLE_TLV("Sidetone Voice TX1 Volume",
390 ISABELLE_VTX_STPGA1_CFG_REG, 0, 0xF, 0, st_tlv),
391 SOC_SINGLE_TLV("Sidetone Voice TX2 Volume",
392 ISABELLE_VTX2_STPGA2_CFG_REG, 0, 0xF, 0, st_tlv),
393
394 SOC_SINGLE_TLV("Audio TX1 Volume", ISABELLE_ATX1_DPGA_REG, 4, 0xF, 0,
395 tx_tlv),
396 SOC_SINGLE_TLV("Audio TX2 Volume", ISABELLE_ATX2_DPGA_REG, 4, 0xF, 0,
397 tx_tlv),
398 SOC_SINGLE_TLV("Voice TX1 Volume", ISABELLE_VTX1_DPGA_REG, 4, 0xF, 0,
399 tx_tlv),
400 SOC_SINGLE_TLV("Voice TX2 Volume", ISABELLE_VTX2_DPGA_REG, 4, 0xF, 0,
401 tx_tlv),
402
403 SOC_SINGLE_TLV("RX1 DPGA Volume", ISABELLE_RX1_DPGA_REG, 0, 0x3F, 0,
404 rx_tlv),
405 SOC_SINGLE_TLV("RX2 DPGA Volume", ISABELLE_RX2_DPGA_REG, 0, 0x3F, 0,
406 rx_tlv),
407 SOC_SINGLE_TLV("RX3 DPGA Volume", ISABELLE_RX3_DPGA_REG, 0, 0x3F, 0,
408 rx_tlv),
409 SOC_SINGLE_TLV("RX4 DPGA Volume", ISABELLE_RX4_DPGA_REG, 0, 0x3F, 0,
410 rx_tlv),
411 SOC_SINGLE_TLV("RX5 DPGA Volume", ISABELLE_RX5_DPGA_REG, 0, 0x3F, 0,
412 rx_tlv),
413 SOC_SINGLE_TLV("RX6 DPGA Volume", ISABELLE_RX6_DPGA_REG, 0, 0x3F, 0,
414 rx_tlv),
415
416 SOC_SINGLE("Headset Noise Gate", ISABELLE_HS_NG_CFG1_REG, 7, 1, 0),
417 SOC_SINGLE("Handsfree Noise Gate", ISABELLE_HF_NG_CFG1_REG, 7, 1, 0),
418
419 SOC_SINGLE("ATX1 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
420 7, 1, 0),
421 SOC_SINGLE("ATX2 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
422 6, 1, 0),
423 SOC_SINGLE("ARX1 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
424 5, 1, 0),
425 SOC_SINGLE("ARX2 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
426 4, 1, 0),
427 SOC_SINGLE("ARX3 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
428 3, 1, 0),
429 SOC_SINGLE("ARX4 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
430 2, 1, 0),
431 SOC_SINGLE("ARX5 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
432 1, 1, 0),
433 SOC_SINGLE("ARX6 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
434 0, 1, 0),
435 SOC_SINGLE("VRX1 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
436 3, 1, 0),
437 SOC_SINGLE("VRX2 Filter Bypass Switch", ISABELLE_AUDIO_HPF_CFG_REG,
438 2, 1, 0),
439
440 SOC_SINGLE("ATX1 Filter Enable Switch", ISABELLE_ALU_TX_EN_REG,
441 7, 1, 0),
442 SOC_SINGLE("ATX2 Filter Enable Switch", ISABELLE_ALU_TX_EN_REG,
443 6, 1, 0),
444 SOC_SINGLE("VTX1 Filter Enable Switch", ISABELLE_ALU_TX_EN_REG,
445 5, 1, 0),
446 SOC_SINGLE("VTX2 Filter Enable Switch", ISABELLE_ALU_TX_EN_REG,
447 4, 1, 0),
448 SOC_SINGLE("RX1 Filter Enable Switch", ISABELLE_ALU_RX_EN_REG,
449 5, 1, 0),
450 SOC_SINGLE("RX2 Filter Enable Switch", ISABELLE_ALU_RX_EN_REG,
451 4, 1, 0),
452 SOC_SINGLE("RX3 Filter Enable Switch", ISABELLE_ALU_RX_EN_REG,
453 3, 1, 0),
454 SOC_SINGLE("RX4 Filter Enable Switch", ISABELLE_ALU_RX_EN_REG,
455 2, 1, 0),
456 SOC_SINGLE("RX5 Filter Enable Switch", ISABELLE_ALU_RX_EN_REG,
457 1, 1, 0),
458 SOC_SINGLE("RX6 Filter Enable Switch", ISABELLE_ALU_RX_EN_REG,
459 0, 1, 0),
460
461 SOC_SINGLE("ULATX12 Capture Switch", ISABELLE_ULATX12_INTF_CFG_REG,
462 7, 1, 0),
463
464 SOC_SINGLE("DL12 Playback Switch", ISABELLE_DL12_INTF_CFG_REG,
465 7, 1, 0),
466 SOC_SINGLE("DL34 Playback Switch", ISABELLE_DL34_INTF_CFG_REG,
467 7, 1, 0),
468 SOC_SINGLE("DL56 Playback Switch", ISABELLE_DL56_INTF_CFG_REG,
469 7, 1, 0),
470
471
472 SOC_SINGLE("DMIC Switch", ISABELLE_DMIC_CFG_REG, 0, 1, 0),
473};
474
475static const struct snd_soc_dapm_widget isabelle_dapm_widgets[] = {
476
477 SND_SOC_DAPM_INPUT("MAINMIC"),
478 SND_SOC_DAPM_INPUT("HSMIC"),
479 SND_SOC_DAPM_INPUT("SUBMIC"),
480 SND_SOC_DAPM_INPUT("LINEIN1"),
481 SND_SOC_DAPM_INPUT("LINEIN2"),
482 SND_SOC_DAPM_INPUT("DMICDAT"),
483
484
485 SND_SOC_DAPM_OUTPUT("HSOL"),
486 SND_SOC_DAPM_OUTPUT("HSOR"),
487 SND_SOC_DAPM_OUTPUT("HFL"),
488 SND_SOC_DAPM_OUTPUT("HFR"),
489 SND_SOC_DAPM_OUTPUT("EP"),
490 SND_SOC_DAPM_OUTPUT("LINEOUT1"),
491 SND_SOC_DAPM_OUTPUT("LINEOUT2"),
492
493 SND_SOC_DAPM_PGA("DL1", SND_SOC_NOPM, 0, 0, NULL, 0),
494 SND_SOC_DAPM_PGA("DL2", SND_SOC_NOPM, 0, 0, NULL, 0),
495 SND_SOC_DAPM_PGA("DL3", SND_SOC_NOPM, 0, 0, NULL, 0),
496 SND_SOC_DAPM_PGA("DL4", SND_SOC_NOPM, 0, 0, NULL, 0),
497 SND_SOC_DAPM_PGA("DL5", SND_SOC_NOPM, 0, 0, NULL, 0),
498 SND_SOC_DAPM_PGA("DL6", SND_SOC_NOPM, 0, 0, NULL, 0),
499
500
501 SND_SOC_DAPM_MUX("Analog Left Capture Route",
502 SND_SOC_NOPM, 0, 0, &amic1_control),
503 SND_SOC_DAPM_MUX("Analog Right Capture Route",
504 SND_SOC_NOPM, 0, 0, &amic2_control),
505
506 SND_SOC_DAPM_MUX("Sidetone Audio Playback", SND_SOC_NOPM, 0, 0,
507 &st_audio_control),
508 SND_SOC_DAPM_MUX("Sidetone Voice Playback", SND_SOC_NOPM, 0, 0,
509 &st_voice_control),
510
511
512 SND_SOC_DAPM_AIF_IN("INTF1_SDI", NULL, 0, ISABELLE_INTF_EN_REG, 7, 0),
513 SND_SOC_DAPM_AIF_IN("INTF2_SDI", NULL, 0, ISABELLE_INTF_EN_REG, 6, 0),
514
515 SND_SOC_DAPM_AIF_OUT("INTF1_SDO", NULL, 0, ISABELLE_INTF_EN_REG, 5, 0),
516 SND_SOC_DAPM_AIF_OUT("INTF2_SDO", NULL, 0, ISABELLE_INTF_EN_REG, 4, 0),
517
518 SND_SOC_DAPM_OUT_DRV("ULATX1", SND_SOC_NOPM, 0, 0, NULL, 0),
519 SND_SOC_DAPM_OUT_DRV("ULATX2", SND_SOC_NOPM, 0, 0, NULL, 0),
520 SND_SOC_DAPM_OUT_DRV("ULVTX1", SND_SOC_NOPM, 0, 0, NULL, 0),
521 SND_SOC_DAPM_OUT_DRV("ULVTX2", SND_SOC_NOPM, 0, 0, NULL, 0),
522
523
524 SND_SOC_DAPM_PGA("MicAmp1", ISABELLE_AMIC_CFG_REG, 5, 0, NULL, 0),
525 SND_SOC_DAPM_PGA("MicAmp2", ISABELLE_AMIC_CFG_REG, 4, 0, NULL, 0),
526
527
528 SND_SOC_DAPM_PGA("APGA1", ISABELLE_APGA_CFG_REG, 7, 0, NULL, 0),
529 SND_SOC_DAPM_PGA("APGA2", ISABELLE_APGA_CFG_REG, 6, 0, NULL, 0),
530
531
532 SND_SOC_DAPM_ADC("ADC1", "Left Front Capture",
533 ISABELLE_AMIC_CFG_REG, 7, 0),
534 SND_SOC_DAPM_ADC("ADC2", "Right Front Capture",
535 ISABELLE_AMIC_CFG_REG, 6, 0),
536
537
538 SND_SOC_DAPM_SUPPLY("Headset Mic Bias", ISABELLE_ABIAS_CFG_REG,
539 3, 0, NULL, 0),
540 SND_SOC_DAPM_SUPPLY("Main Mic Bias", ISABELLE_ABIAS_CFG_REG,
541 2, 0, NULL, 0),
542 SND_SOC_DAPM_SUPPLY("Digital Mic1 Bias",
543 ISABELLE_DBIAS_CFG_REG, 3, 0, NULL, 0),
544 SND_SOC_DAPM_SUPPLY("Digital Mic2 Bias",
545 ISABELLE_DBIAS_CFG_REG, 2, 0, NULL, 0),
546
547
548 SND_SOC_DAPM_MIXER("Headset Left Mixer", SND_SOC_NOPM, 0, 0,
549 isabelle_hs_left_mixer_controls,
550 ARRAY_SIZE(isabelle_hs_left_mixer_controls)),
551 SND_SOC_DAPM_MIXER("Headset Right Mixer", SND_SOC_NOPM, 0, 0,
552 isabelle_hs_right_mixer_controls,
553 ARRAY_SIZE(isabelle_hs_right_mixer_controls)),
554 SND_SOC_DAPM_MIXER("Handsfree Left Mixer", SND_SOC_NOPM, 0, 0,
555 isabelle_hf_left_mixer_controls,
556 ARRAY_SIZE(isabelle_hf_left_mixer_controls)),
557 SND_SOC_DAPM_MIXER("Handsfree Right Mixer", SND_SOC_NOPM, 0, 0,
558 isabelle_hf_right_mixer_controls,
559 ARRAY_SIZE(isabelle_hf_right_mixer_controls)),
560 SND_SOC_DAPM_MIXER("LINEOUT1 Mixer", SND_SOC_NOPM, 0, 0,
561 isabelle_aux_left_mixer_controls,
562 ARRAY_SIZE(isabelle_aux_left_mixer_controls)),
563 SND_SOC_DAPM_MIXER("LINEOUT2 Mixer", SND_SOC_NOPM, 0, 0,
564 isabelle_aux_right_mixer_controls,
565 ARRAY_SIZE(isabelle_aux_right_mixer_controls)),
566 SND_SOC_DAPM_MIXER("Earphone Mixer", SND_SOC_NOPM, 0, 0,
567 isabelle_ep_mixer_controls,
568 ARRAY_SIZE(isabelle_ep_mixer_controls)),
569
570 SND_SOC_DAPM_MIXER("DPGA1L Mixer", SND_SOC_NOPM, 0, 0,
571 isabelle_dpga1_left_mixer_controls,
572 ARRAY_SIZE(isabelle_dpga1_left_mixer_controls)),
573 SND_SOC_DAPM_MIXER("DPGA1R Mixer", SND_SOC_NOPM, 0, 0,
574 isabelle_dpga1_right_mixer_controls,
575 ARRAY_SIZE(isabelle_dpga1_right_mixer_controls)),
576 SND_SOC_DAPM_MIXER("DPGA2L Mixer", SND_SOC_NOPM, 0, 0,
577 isabelle_dpga2_left_mixer_controls,
578 ARRAY_SIZE(isabelle_dpga2_left_mixer_controls)),
579 SND_SOC_DAPM_MIXER("DPGA2R Mixer", SND_SOC_NOPM, 0, 0,
580 isabelle_dpga2_right_mixer_controls,
581 ARRAY_SIZE(isabelle_dpga2_right_mixer_controls)),
582 SND_SOC_DAPM_MIXER("DPGA3L Mixer", SND_SOC_NOPM, 0, 0,
583 isabelle_dpga3_left_mixer_controls,
584 ARRAY_SIZE(isabelle_dpga3_left_mixer_controls)),
585 SND_SOC_DAPM_MIXER("DPGA3R Mixer", SND_SOC_NOPM, 0, 0,
586 isabelle_dpga3_right_mixer_controls,
587 ARRAY_SIZE(isabelle_dpga3_right_mixer_controls)),
588
589 SND_SOC_DAPM_MIXER("RX1 Mixer", SND_SOC_NOPM, 0, 0,
590 isabelle_rx1_mixer_controls,
591 ARRAY_SIZE(isabelle_rx1_mixer_controls)),
592 SND_SOC_DAPM_MIXER("RX2 Mixer", SND_SOC_NOPM, 0, 0,
593 isabelle_rx2_mixer_controls,
594 ARRAY_SIZE(isabelle_rx2_mixer_controls)),
595 SND_SOC_DAPM_MIXER("RX3 Mixer", SND_SOC_NOPM, 0, 0,
596 isabelle_rx3_mixer_controls,
597 ARRAY_SIZE(isabelle_rx3_mixer_controls)),
598 SND_SOC_DAPM_MIXER("RX4 Mixer", SND_SOC_NOPM, 0, 0,
599 isabelle_rx4_mixer_controls,
600 ARRAY_SIZE(isabelle_rx4_mixer_controls)),
601 SND_SOC_DAPM_MIXER("RX5 Mixer", SND_SOC_NOPM, 0, 0,
602 isabelle_rx5_mixer_controls,
603 ARRAY_SIZE(isabelle_rx5_mixer_controls)),
604 SND_SOC_DAPM_MIXER("RX6 Mixer", SND_SOC_NOPM, 0, 0,
605 isabelle_rx6_mixer_controls,
606 ARRAY_SIZE(isabelle_rx6_mixer_controls)),
607
608
609 SND_SOC_DAPM_DAC("DAC1L", "Headset Playback", ISABELLE_DAC_CFG_REG,
610 5, 0),
611 SND_SOC_DAPM_DAC("DAC1R", "Headset Playback", ISABELLE_DAC_CFG_REG,
612 4, 0),
613 SND_SOC_DAPM_DAC("DAC2L", "Handsfree Playback", ISABELLE_DAC_CFG_REG,
614 3, 0),
615 SND_SOC_DAPM_DAC("DAC2R", "Handsfree Playback", ISABELLE_DAC_CFG_REG,
616 2, 0),
617 SND_SOC_DAPM_DAC("DAC3L", "Lineout Playback", ISABELLE_DAC_CFG_REG,
618 1, 0),
619 SND_SOC_DAPM_DAC("DAC3R", "Lineout Playback", ISABELLE_DAC_CFG_REG,
620 0, 0),
621
622
623 SND_SOC_DAPM_PGA("Sidetone Audio PGA", SND_SOC_NOPM, 0, 0, NULL, 0),
624 SND_SOC_DAPM_PGA("Sidetone Voice PGA", SND_SOC_NOPM, 0, 0, NULL, 0),
625 SND_SOC_DAPM_PGA("HF Left PGA", SND_SOC_NOPM, 0, 0, NULL, 0),
626 SND_SOC_DAPM_PGA("HF Right PGA", SND_SOC_NOPM, 0, 0, NULL, 0),
627 SND_SOC_DAPM_PGA("DPGA1L", SND_SOC_NOPM, 0, 0, NULL, 0),
628 SND_SOC_DAPM_PGA("DPGA1R", SND_SOC_NOPM, 0, 0, NULL, 0),
629 SND_SOC_DAPM_PGA("DPGA2L", SND_SOC_NOPM, 0, 0, NULL, 0),
630 SND_SOC_DAPM_PGA("DPGA2R", SND_SOC_NOPM, 0, 0, NULL, 0),
631 SND_SOC_DAPM_PGA("DPGA3L", SND_SOC_NOPM, 0, 0, NULL, 0),
632 SND_SOC_DAPM_PGA("DPGA3R", SND_SOC_NOPM, 0, 0, NULL, 0),
633
634
635 SND_SOC_DAPM_MUX("RX1 Playback", ISABELLE_ALU_RX_EN_REG, 5, 0,
636 &rx1_mux_controls),
637 SND_SOC_DAPM_MUX("RX2 Playback", ISABELLE_ALU_RX_EN_REG, 4, 0,
638 &rx2_mux_controls),
639
640
641 SND_SOC_DAPM_MUX("ATX Select", ISABELLE_TX_INPUT_CFG_REG,
642 7, 0, &atx_mux_controls),
643 SND_SOC_DAPM_MUX("VTX Select", ISABELLE_TX_INPUT_CFG_REG,
644 6, 0, &vtx_mux_controls),
645
646 SND_SOC_DAPM_SWITCH("Earphone Playback", SND_SOC_NOPM, 0, 0,
647 &ep_path_enable_control),
648
649
650 SND_SOC_DAPM_OUT_DRV("HS Left Driver", ISABELLE_HSDRV_CFG2_REG,
651 1, 0, NULL, 0),
652 SND_SOC_DAPM_OUT_DRV("HS Right Driver", ISABELLE_HSDRV_CFG2_REG,
653 0, 0, NULL, 0),
654 SND_SOC_DAPM_OUT_DRV("LINEOUT1 Left Driver", ISABELLE_LINEAMP_CFG_REG,
655 1, 0, NULL, 0),
656 SND_SOC_DAPM_OUT_DRV("LINEOUT2 Right Driver", ISABELLE_LINEAMP_CFG_REG,
657 0, 0, NULL, 0),
658 SND_SOC_DAPM_OUT_DRV("Earphone Driver", ISABELLE_EARDRV_CFG2_REG,
659 1, 0, NULL, 0),
660
661 SND_SOC_DAPM_OUT_DRV("HF Left Driver", ISABELLE_HFDRV_CFG_REG,
662 1, 0, NULL, 0),
663 SND_SOC_DAPM_OUT_DRV("HF Right Driver", ISABELLE_HFDRV_CFG_REG,
664 0, 0, NULL, 0),
665};
666
667static const struct snd_soc_dapm_route isabelle_intercon[] = {
668
669 { "DL1", "DL12 Playback Switch", "INTF1_SDI" },
670 { "DL2", "DL12 Playback Switch", "INTF1_SDI" },
671 { "DL3", "DL34 Playback Switch", "INTF1_SDI" },
672 { "DL4", "DL34 Playback Switch", "INTF1_SDI" },
673 { "DL5", "DL56 Playback Switch", "INTF1_SDI" },
674 { "DL6", "DL56 Playback Switch", "INTF1_SDI" },
675
676 { "DL1", "DL12 Playback Switch", "INTF2_SDI" },
677 { "DL2", "DL12 Playback Switch", "INTF2_SDI" },
678 { "DL3", "DL34 Playback Switch", "INTF2_SDI" },
679 { "DL4", "DL34 Playback Switch", "INTF2_SDI" },
680 { "DL5", "DL56 Playback Switch", "INTF2_SDI" },
681 { "DL6", "DL56 Playback Switch", "INTF2_SDI" },
682
683
684 { "Sidetone Audio PGA", NULL, "Sidetone Audio Playback" },
685 { "Sidetone Voice PGA", NULL, "Sidetone Voice Playback" },
686
687 { "RX1 Mixer", "ST1 Playback Switch", "Sidetone Audio PGA" },
688
689 { "RX1 Mixer", "ST1 Playback Switch", "Sidetone Voice PGA" },
690 { "RX1 Mixer", "DL1 Playback Switch", "DL1" },
691
692 { "RX2 Mixer", "ST2 Playback Switch", "Sidetone Audio PGA" },
693
694 { "RX2 Mixer", "ST2 Playback Switch", "Sidetone Voice PGA" },
695 { "RX2 Mixer", "DL2 Playback Switch", "DL2" },
696
697 { "RX3 Mixer", "ST1 Playback Switch", "Sidetone Voice PGA" },
698 { "RX3 Mixer", "DL3 Playback Switch", "DL3" },
699
700 { "RX4 Mixer", "ST2 Playback Switch", "Sidetone Voice PGA" },
701 { "RX4 Mixer", "DL4 Playback Switch", "DL4" },
702
703 { "RX5 Mixer", "ST1 Playback Switch", "Sidetone Voice PGA" },
704 { "RX5 Mixer", "DL5 Playback Switch", "DL5" },
705
706 { "RX6 Mixer", "ST2 Playback Switch", "Sidetone Voice PGA" },
707 { "RX6 Mixer", "DL6 Playback Switch", "DL6" },
708
709
710 { "Analog Left Capture Route", "Headset Mic", "HSMIC" },
711 { "Analog Left Capture Route", "Main Mic", "MAINMIC" },
712 { "Analog Left Capture Route", "Aux/FM Left", "LINEIN1" },
713
714 { "Analog Right Capture Route", "Sub Mic", "SUBMIC" },
715 { "Analog Right Capture Route", "Aux/FM Right", "LINEIN2" },
716
717 { "MicAmp1", NULL, "Analog Left Capture Route" },
718 { "MicAmp2", NULL, "Analog Right Capture Route" },
719
720 { "ADC1", NULL, "MicAmp1" },
721 { "ADC2", NULL, "MicAmp2" },
722
723 { "ATX Select", "AMIC1", "ADC1" },
724 { "ATX Select", "DMIC", "DMICDAT" },
725 { "ATX Select", "AMIC2", "ADC2" },
726
727 { "VTX Select", "AMIC1", "ADC1" },
728 { "VTX Select", "DMIC", "DMICDAT" },
729 { "VTX Select", "AMIC2", "ADC2" },
730
731 { "ULATX1", "ATX1 Filter Enable Switch", "ATX Select" },
732 { "ULATX1", "ATX1 Filter Bypass Switch", "ATX Select" },
733 { "ULATX2", "ATX2 Filter Enable Switch", "ATX Select" },
734 { "ULATX2", "ATX2 Filter Bypass Switch", "ATX Select" },
735
736 { "ULVTX1", "VTX1 Filter Enable Switch", "VTX Select" },
737 { "ULVTX1", "VTX1 Filter Bypass Switch", "VTX Select" },
738 { "ULVTX2", "VTX2 Filter Enable Switch", "VTX Select" },
739 { "ULVTX2", "VTX2 Filter Bypass Switch", "VTX Select" },
740
741 { "INTF1_SDO", "ULATX12 Capture Switch", "ULATX1" },
742 { "INTF1_SDO", "ULATX12 Capture Switch", "ULATX2" },
743 { "INTF2_SDO", "ULATX12 Capture Switch", "ULATX1" },
744 { "INTF2_SDO", "ULATX12 Capture Switch", "ULATX2" },
745
746 { "INTF1_SDO", NULL, "ULVTX1" },
747 { "INTF1_SDO", NULL, "ULVTX2" },
748 { "INTF2_SDO", NULL, "ULVTX1" },
749 { "INTF2_SDO", NULL, "ULVTX2" },
750
751
752 { "APGA1", NULL, "LINEIN1" },
753 { "APGA2", NULL, "LINEIN2" },
754
755 { "RX1 Playback", "VRX1 Filter Bypass Switch", "RX1 Mixer" },
756 { "RX1 Playback", "ARX1 Filter Bypass Switch", "RX1 Mixer" },
757 { "RX1 Playback", "RX1 Filter Enable Switch", "RX1 Mixer" },
758
759 { "RX2 Playback", "VRX2 Filter Bypass Switch", "RX2 Mixer" },
760 { "RX2 Playback", "ARX2 Filter Bypass Switch", "RX2 Mixer" },
761 { "RX2 Playback", "RX2 Filter Enable Switch", "RX2 Mixer" },
762
763 { "RX3 Playback", "ARX3 Filter Bypass Switch", "RX3 Mixer" },
764 { "RX3 Playback", "RX3 Filter Enable Switch", "RX3 Mixer" },
765
766 { "RX4 Playback", "ARX4 Filter Bypass Switch", "RX4 Mixer" },
767 { "RX4 Playback", "RX4 Filter Enable Switch", "RX4 Mixer" },
768
769 { "RX5 Playback", "ARX5 Filter Bypass Switch", "RX5 Mixer" },
770 { "RX5 Playback", "RX5 Filter Enable Switch", "RX5 Mixer" },
771
772 { "RX6 Playback", "ARX6 Filter Bypass Switch", "RX6 Mixer" },
773 { "RX6 Playback", "RX6 Filter Enable Switch", "RX6 Mixer" },
774
775 { "DPGA1L Mixer", "RX1 Playback Switch", "RX1 Playback" },
776 { "DPGA1L Mixer", "RX3 Playback Switch", "RX3 Playback" },
777 { "DPGA1L Mixer", "RX5 Playback Switch", "RX5 Playback" },
778
779 { "DPGA1R Mixer", "RX2 Playback Switch", "RX2 Playback" },
780 { "DPGA1R Mixer", "RX4 Playback Switch", "RX4 Playback" },
781 { "DPGA1R Mixer", "RX6 Playback Switch", "RX6 Playback" },
782
783 { "DPGA1L", NULL, "DPGA1L Mixer" },
784 { "DPGA1R", NULL, "DPGA1R Mixer" },
785
786 { "DAC1L", NULL, "DPGA1L" },
787 { "DAC1R", NULL, "DPGA1R" },
788
789 { "DPGA2L Mixer", "RX1 Playback Switch", "RX1 Playback" },
790 { "DPGA2L Mixer", "RX2 Playback Switch", "RX2 Playback" },
791 { "DPGA2L Mixer", "RX3 Playback Switch", "RX3 Playback" },
792 { "DPGA2L Mixer", "RX4 Playback Switch", "RX4 Playback" },
793 { "DPGA2L Mixer", "RX5 Playback Switch", "RX5 Playback" },
794 { "DPGA2L Mixer", "RX6 Playback Switch", "RX6 Playback" },
795
796 { "DPGA2R Mixer", "RX2 Playback Switch", "RX2 Playback" },
797 { "DPGA2R Mixer", "RX4 Playback Switch", "RX4 Playback" },
798 { "DPGA2R Mixer", "RX6 Playback Switch", "RX6 Playback" },
799
800 { "DPGA2L", NULL, "DPGA2L Mixer" },
801 { "DPGA2R", NULL, "DPGA2R Mixer" },
802
803 { "DAC2L", NULL, "DPGA2L" },
804 { "DAC2R", NULL, "DPGA2R" },
805
806 { "DPGA3L Mixer", "RX1 Playback Switch", "RX1 Playback" },
807 { "DPGA3L Mixer", "RX3 Playback Switch", "RX3 Playback" },
808 { "DPGA3L Mixer", "RX5 Playback Switch", "RX5 Playback" },
809
810 { "DPGA3R Mixer", "RX2 Playback Switch", "RX2 Playback" },
811 { "DPGA3R Mixer", "RX4 Playback Switch", "RX4 Playback" },
812 { "DPGA3R Mixer", "RX6 Playback Switch", "RX6 Playback" },
813
814 { "DPGA3L", NULL, "DPGA3L Mixer" },
815 { "DPGA3R", NULL, "DPGA3R Mixer" },
816
817 { "DAC3L", NULL, "DPGA3L" },
818 { "DAC3R", NULL, "DPGA3R" },
819
820 { "Headset Left Mixer", "DAC1L Playback Switch", "DAC1L" },
821 { "Headset Left Mixer", "APGA1 Playback Switch", "APGA1" },
822
823 { "Headset Right Mixer", "DAC1R Playback Switch", "DAC1R" },
824 { "Headset Right Mixer", "APGA2 Playback Switch", "APGA2" },
825
826 { "HS Left Driver", NULL, "Headset Left Mixer" },
827 { "HS Right Driver", NULL, "Headset Right Mixer" },
828
829 { "HSOL", NULL, "HS Left Driver" },
830 { "HSOR", NULL, "HS Right Driver" },
831
832
833 { "Earphone Mixer", "DAC2L Playback Switch", "DAC2L" },
834 { "Earphone Mixer", "APGA1 Playback Switch", "APGA1" },
835
836 { "Earphone Playback", "Switch", "Earphone Mixer" },
837 { "Earphone Driver", NULL, "Earphone Playback" },
838 { "EP", NULL, "Earphone Driver" },
839
840 { "Handsfree Left Mixer", "DAC2L Playback Switch", "DAC2L" },
841 { "Handsfree Left Mixer", "APGA1 Playback Switch", "APGA1" },
842
843 { "Handsfree Right Mixer", "DAC2R Playback Switch", "DAC2R" },
844 { "Handsfree Right Mixer", "APGA2 Playback Switch", "APGA2" },
845
846 { "HF Left PGA", NULL, "Handsfree Left Mixer" },
847 { "HF Right PGA", NULL, "Handsfree Right Mixer" },
848
849 { "HF Left Driver", NULL, "HF Left PGA" },
850 { "HF Right Driver", NULL, "HF Right PGA" },
851
852 { "HFL", NULL, "HF Left Driver" },
853 { "HFR", NULL, "HF Right Driver" },
854
855 { "LINEOUT1 Mixer", "DAC3L Playback Switch", "DAC3L" },
856 { "LINEOUT1 Mixer", "APGA1 Playback Switch", "APGA1" },
857
858 { "LINEOUT2 Mixer", "DAC3R Playback Switch", "DAC3R" },
859 { "LINEOUT2 Mixer", "APGA2 Playback Switch", "APGA2" },
860
861 { "LINEOUT1 Driver", NULL, "LINEOUT1 Mixer" },
862 { "LINEOUT2 Driver", NULL, "LINEOUT2 Mixer" },
863
864 { "LINEOUT1", NULL, "LINEOUT1 Driver" },
865 { "LINEOUT2", NULL, "LINEOUT2 Driver" },
866};
867
868static int isabelle_hs_mute(struct snd_soc_dai *dai, int mute)
869{
870 snd_soc_update_bits(dai->codec, ISABELLE_DAC1_SOFTRAMP_REG,
871 BIT(4), (mute ? BIT(4) : 0));
872
873 return 0;
874}
875
876static int isabelle_hf_mute(struct snd_soc_dai *dai, int mute)
877{
878 snd_soc_update_bits(dai->codec, ISABELLE_DAC2_SOFTRAMP_REG,
879 BIT(4), (mute ? BIT(4) : 0));
880
881 return 0;
882}
883
884static int isabelle_line_mute(struct snd_soc_dai *dai, int mute)
885{
886 snd_soc_update_bits(dai->codec, ISABELLE_DAC3_SOFTRAMP_REG,
887 BIT(4), (mute ? BIT(4) : 0));
888
889 return 0;
890}
891
892static int isabelle_set_bias_level(struct snd_soc_codec *codec,
893 enum snd_soc_bias_level level)
894{
895 switch (level) {
896 case SND_SOC_BIAS_ON:
897 break;
898 case SND_SOC_BIAS_PREPARE:
899 break;
900
901 case SND_SOC_BIAS_STANDBY:
902 snd_soc_update_bits(codec, ISABELLE_PWR_EN_REG,
903 ISABELLE_CHIP_EN, BIT(0));
904 break;
905
906 case SND_SOC_BIAS_OFF:
907 snd_soc_update_bits(codec, ISABELLE_PWR_EN_REG,
908 ISABELLE_CHIP_EN, 0);
909 break;
910 }
911
912 codec->dapm.bias_level = level;
913
914 return 0;
915}
916
917static int isabelle_hw_params(struct snd_pcm_substream *substream,
918 struct snd_pcm_hw_params *params,
919 struct snd_soc_dai *dai)
920{
921 struct snd_soc_codec *codec = dai->codec;
922 u16 aif = 0;
923 unsigned int fs_val = 0;
924
925 switch (params_rate(params)) {
926 case 8000:
927 fs_val = ISABELLE_FS_RATE_8;
928 break;
929 case 11025:
930 fs_val = ISABELLE_FS_RATE_11;
931 break;
932 case 12000:
933 fs_val = ISABELLE_FS_RATE_12;
934 break;
935 case 16000:
936 fs_val = ISABELLE_FS_RATE_16;
937 break;
938 case 22050:
939 fs_val = ISABELLE_FS_RATE_22;
940 break;
941 case 24000:
942 fs_val = ISABELLE_FS_RATE_24;
943 break;
944 case 32000:
945 fs_val = ISABELLE_FS_RATE_32;
946 break;
947 case 44100:
948 fs_val = ISABELLE_FS_RATE_44;
949 break;
950 case 48000:
951 fs_val = ISABELLE_FS_RATE_48;
952 break;
953 default:
954 return -EINVAL;
955 }
956
957 snd_soc_update_bits(codec, ISABELLE_FS_RATE_CFG_REG,
958 ISABELLE_FS_RATE_MASK, fs_val);
959
960
961 switch (params_width(params)) {
962 case 20:
963 aif |= ISABELLE_AIF_LENGTH_20;
964 break;
965 case 32:
966 aif |= ISABELLE_AIF_LENGTH_32;
967 break;
968 default:
969 return -EINVAL;
970 }
971
972 snd_soc_update_bits(codec, ISABELLE_INTF_CFG_REG,
973 ISABELLE_AIF_LENGTH_MASK, aif);
974
975 return 0;
976}
977
978static int isabelle_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
979{
980 struct snd_soc_codec *codec = codec_dai->codec;
981 unsigned int aif_val = 0;
982
983 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
984 case SND_SOC_DAIFMT_CBS_CFS:
985 aif_val &= ~ISABELLE_AIF_MS;
986 break;
987 case SND_SOC_DAIFMT_CBM_CFM:
988 aif_val |= ISABELLE_AIF_MS;
989 break;
990 default:
991 return -EINVAL;
992 }
993
994 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
995 case SND_SOC_DAIFMT_I2S:
996 aif_val |= ISABELLE_I2S_MODE;
997 break;
998 case SND_SOC_DAIFMT_LEFT_J:
999 aif_val |= ISABELLE_LEFT_J_MODE;
1000 break;
1001 case SND_SOC_DAIFMT_PDM:
1002 aif_val |= ISABELLE_PDM_MODE;
1003 break;
1004 default:
1005 return -EINVAL;
1006 }
1007
1008 snd_soc_update_bits(codec, ISABELLE_INTF_CFG_REG,
1009 (ISABELLE_AIF_MS | ISABELLE_AIF_FMT_MASK), aif_val);
1010
1011 return 0;
1012}
1013
1014
1015#define ISABELLE_RATES SNDRV_PCM_RATE_8000_48000
1016
1017
1018#define ISABELLE_FORMATS (SNDRV_PCM_FMTBIT_S20_3LE |\
1019 SNDRV_PCM_FMTBIT_S32_LE)
1020
1021static struct snd_soc_dai_ops isabelle_hs_dai_ops = {
1022 .hw_params = isabelle_hw_params,
1023 .set_fmt = isabelle_set_dai_fmt,
1024 .digital_mute = isabelle_hs_mute,
1025};
1026
1027static struct snd_soc_dai_ops isabelle_hf_dai_ops = {
1028 .hw_params = isabelle_hw_params,
1029 .set_fmt = isabelle_set_dai_fmt,
1030 .digital_mute = isabelle_hf_mute,
1031};
1032
1033static struct snd_soc_dai_ops isabelle_line_dai_ops = {
1034 .hw_params = isabelle_hw_params,
1035 .set_fmt = isabelle_set_dai_fmt,
1036 .digital_mute = isabelle_line_mute,
1037};
1038
1039static struct snd_soc_dai_ops isabelle_ul_dai_ops = {
1040 .hw_params = isabelle_hw_params,
1041 .set_fmt = isabelle_set_dai_fmt,
1042};
1043
1044
1045static struct snd_soc_dai_driver isabelle_dai[] = {
1046 {
1047 .name = "isabelle-dl1",
1048 .playback = {
1049 .stream_name = "Headset Playback",
1050 .channels_min = 1,
1051 .channels_max = 2,
1052 .rates = ISABELLE_RATES,
1053 .formats = ISABELLE_FORMATS,
1054 },
1055 .ops = &isabelle_hs_dai_ops,
1056 },
1057 {
1058 .name = "isabelle-dl2",
1059 .playback = {
1060 .stream_name = "Handsfree Playback",
1061 .channels_min = 1,
1062 .channels_max = 2,
1063 .rates = ISABELLE_RATES,
1064 .formats = ISABELLE_FORMATS,
1065 },
1066 .ops = &isabelle_hf_dai_ops,
1067 },
1068 {
1069 .name = "isabelle-lineout",
1070 .playback = {
1071 .stream_name = "Lineout Playback",
1072 .channels_min = 1,
1073 .channels_max = 2,
1074 .rates = ISABELLE_RATES,
1075 .formats = ISABELLE_FORMATS,
1076 },
1077 .ops = &isabelle_line_dai_ops,
1078 },
1079 {
1080 .name = "isabelle-ul",
1081 .capture = {
1082 .stream_name = "Capture",
1083 .channels_min = 1,
1084 .channels_max = 2,
1085 .rates = ISABELLE_RATES,
1086 .formats = ISABELLE_FORMATS,
1087 },
1088 .ops = &isabelle_ul_dai_ops,
1089 },
1090};
1091
1092static struct snd_soc_codec_driver soc_codec_dev_isabelle = {
1093 .set_bias_level = isabelle_set_bias_level,
1094 .controls = isabelle_snd_controls,
1095 .num_controls = ARRAY_SIZE(isabelle_snd_controls),
1096 .dapm_widgets = isabelle_dapm_widgets,
1097 .num_dapm_widgets = ARRAY_SIZE(isabelle_dapm_widgets),
1098 .dapm_routes = isabelle_intercon,
1099 .num_dapm_routes = ARRAY_SIZE(isabelle_intercon),
1100 .idle_bias_off = true,
1101};
1102
1103static const struct regmap_config isabelle_regmap_config = {
1104 .reg_bits = 8,
1105 .val_bits = 8,
1106
1107 .max_register = ISABELLE_MAX_REGISTER,
1108 .reg_defaults = isabelle_reg_defs,
1109 .num_reg_defaults = ARRAY_SIZE(isabelle_reg_defs),
1110 .cache_type = REGCACHE_RBTREE,
1111};
1112
1113static int isabelle_i2c_probe(struct i2c_client *i2c,
1114 const struct i2c_device_id *id)
1115{
1116 struct regmap *isabelle_regmap;
1117 int ret = 0;
1118
1119 isabelle_regmap = devm_regmap_init_i2c(i2c, &isabelle_regmap_config);
1120 if (IS_ERR(isabelle_regmap)) {
1121 ret = PTR_ERR(isabelle_regmap);
1122 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
1123 ret);
1124 return ret;
1125 }
1126 i2c_set_clientdata(i2c, isabelle_regmap);
1127
1128 ret = snd_soc_register_codec(&i2c->dev,
1129 &soc_codec_dev_isabelle, isabelle_dai,
1130 ARRAY_SIZE(isabelle_dai));
1131 if (ret < 0) {
1132 dev_err(&i2c->dev, "Failed to register codec: %d\n", ret);
1133 return ret;
1134 }
1135
1136 return ret;
1137}
1138
1139static int isabelle_i2c_remove(struct i2c_client *client)
1140{
1141 snd_soc_unregister_codec(&client->dev);
1142 return 0;
1143}
1144
1145static const struct i2c_device_id isabelle_i2c_id[] = {
1146 { "isabelle", 0 },
1147 { }
1148};
1149MODULE_DEVICE_TABLE(i2c, isabelle_i2c_id);
1150
1151static struct i2c_driver isabelle_i2c_driver = {
1152 .driver = {
1153 .name = "isabelle",
1154 .owner = THIS_MODULE,
1155 },
1156 .probe = isabelle_i2c_probe,
1157 .remove = isabelle_i2c_remove,
1158 .id_table = isabelle_i2c_id,
1159};
1160
1161module_i2c_driver(isabelle_i2c_driver);
1162
1163MODULE_DESCRIPTION("ASoC ISABELLE driver");
1164MODULE_AUTHOR("Vishwas A Deshpande <vishwas.a.deshpande@ti.com>");
1165MODULE_AUTHOR("M R Swami Reddy <MR.Swami.Reddy@ti.com>");
1166MODULE_LICENSE("GPL v2");
1167