blob: f9830bd3da18c1338ed88d6b479ec17a5e340dc4 [file] [log] [blame]
Thomas Gleixner16216332019-05-19 15:51:31 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Philippe Rétornaz8b908b82012-05-15 13:53:50 +02002/*
3 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
4 * Copyright 2009 Sascha Hauer, s.hauer@pengutronix.de
5 * Copyright 2012 Philippe Retornaz, philippe.retornaz@epfl.ch
6 *
7 * Initial development of this code was funded by
8 * Phytec Messtechnik GmbH, http://www.phytec.de
Philippe Rétornaz8b908b82012-05-15 13:53:50 +02009 */
10#include <linux/module.h>
11#include <linux/device.h>
Alexander Shiyan780aaef2014-04-26 10:57:03 +040012#include <linux/of.h>
Philippe Rétornaz8b908b82012-05-15 13:53:50 +020013#include <linux/mfd/mc13xxx.h>
14#include <linux/slab.h>
15#include <sound/core.h>
16#include <sound/control.h>
17#include <sound/pcm.h>
18#include <sound/soc.h>
19#include <sound/initval.h>
20#include <sound/soc-dapm.h>
Mark Brown2d9215c2013-09-18 19:04:17 +010021#include <linux/regmap.h>
Philippe Rétornaz8b908b82012-05-15 13:53:50 +020022
23#include "mc13783.h"
24
Philippe Rétornaz8b908b82012-05-15 13:53:50 +020025#define AUDIO_RX0_ALSPEN (1 << 5)
26#define AUDIO_RX0_ALSPSEL (1 << 7)
27#define AUDIO_RX0_ADDCDC (1 << 21)
28#define AUDIO_RX0_ADDSTDC (1 << 22)
29#define AUDIO_RX0_ADDRXIN (1 << 23)
30
31#define AUDIO_RX1_PGARXEN (1 << 0);
32#define AUDIO_RX1_PGASTEN (1 << 5)
33#define AUDIO_RX1_ARXINEN (1 << 10)
34
35#define AUDIO_TX_AMC1REN (1 << 5)
36#define AUDIO_TX_AMC1LEN (1 << 7)
37#define AUDIO_TX_AMC2EN (1 << 9)
38#define AUDIO_TX_ATXINEN (1 << 11)
39#define AUDIO_TX_RXINREC (1 << 13)
40
41#define SSI_NETWORK_CDCTXRXSLOT(x) (((x) & 0x3) << 2)
42#define SSI_NETWORK_CDCTXSECSLOT(x) (((x) & 0x3) << 4)
43#define SSI_NETWORK_CDCRXSECSLOT(x) (((x) & 0x3) << 6)
44#define SSI_NETWORK_CDCRXSECGAIN(x) (((x) & 0x3) << 8)
45#define SSI_NETWORK_CDCSUMGAIN(x) (1 << 10)
46#define SSI_NETWORK_CDCFSDLY(x) (1 << 11)
47#define SSI_NETWORK_DAC_SLOTS_8 (1 << 12)
48#define SSI_NETWORK_DAC_SLOTS_4 (2 << 12)
49#define SSI_NETWORK_DAC_SLOTS_2 (3 << 12)
50#define SSI_NETWORK_DAC_SLOT_MASK (3 << 12)
51#define SSI_NETWORK_DAC_RXSLOT_0_1 (0 << 14)
52#define SSI_NETWORK_DAC_RXSLOT_2_3 (1 << 14)
53#define SSI_NETWORK_DAC_RXSLOT_4_5 (2 << 14)
54#define SSI_NETWORK_DAC_RXSLOT_6_7 (3 << 14)
55#define SSI_NETWORK_DAC_RXSLOT_MASK (3 << 14)
56#define SSI_NETWORK_STDCRXSECSLOT(x) (((x) & 0x3) << 16)
57#define SSI_NETWORK_STDCRXSECGAIN(x) (((x) & 0x3) << 18)
58#define SSI_NETWORK_STDCSUMGAIN (1 << 20)
59
60/*
61 * MC13783_AUDIO_CODEC and MC13783_AUDIO_DAC mostly share the same
62 * register layout
63 */
64#define AUDIO_SSI_SEL (1 << 0)
65#define AUDIO_CLK_SEL (1 << 1)
66#define AUDIO_CSM (1 << 2)
67#define AUDIO_BCL_INV (1 << 3)
68#define AUDIO_CFS_INV (1 << 4)
69#define AUDIO_CFS(x) (((x) & 0x3) << 5)
70#define AUDIO_CLK(x) (((x) & 0x7) << 7)
71#define AUDIO_C_EN (1 << 11)
72#define AUDIO_C_CLK_EN (1 << 12)
73#define AUDIO_C_RESET (1 << 15)
74
75#define AUDIO_CODEC_CDCFS8K16K (1 << 10)
76#define AUDIO_DAC_CFS_DLY_B (1 << 10)
77
78struct mc13783_priv {
Philippe Rétornaz8b908b82012-05-15 13:53:50 +020079 struct mc13xxx *mc13xxx;
Mark Brown2d9215c2013-09-18 19:04:17 +010080 struct regmap *regmap;
Philippe Rétornaz8b908b82012-05-15 13:53:50 +020081
82 enum mc13783_ssi_port adc_ssi_port;
83 enum mc13783_ssi_port dac_ssi_port;
84};
85
Philippe Rétornaz8b908b82012-05-15 13:53:50 +020086/* Mapping between sample rates and register value */
87static unsigned int mc13783_rates[] = {
88 8000, 11025, 12000, 16000,
89 22050, 24000, 32000, 44100,
90 48000, 64000, 96000
91};
92
93static int mc13783_pcm_hw_params_dac(struct snd_pcm_substream *substream,
94 struct snd_pcm_hw_params *params,
95 struct snd_soc_dai *dai)
96{
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +000097 struct snd_soc_component *component = dai->component;
Philippe Rétornaz8b908b82012-05-15 13:53:50 +020098 unsigned int rate = params_rate(params);
99 int i;
100
101 for (i = 0; i < ARRAY_SIZE(mc13783_rates); i++) {
102 if (rate == mc13783_rates[i]) {
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000103 snd_soc_component_update_bits(component, MC13783_AUDIO_DAC,
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200104 0xf << 17, i << 17);
105 return 0;
106 }
107 }
108
109 return -EINVAL;
110}
111
112static int mc13783_pcm_hw_params_codec(struct snd_pcm_substream *substream,
113 struct snd_pcm_hw_params *params,
114 struct snd_soc_dai *dai)
115{
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000116 struct snd_soc_component *component = dai->component;
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200117 unsigned int rate = params_rate(params);
118 unsigned int val;
119
120 switch (rate) {
121 case 8000:
122 val = 0;
123 break;
124 case 16000:
125 val = AUDIO_CODEC_CDCFS8K16K;
126 break;
127 default:
128 return -EINVAL;
129 }
130
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000131 snd_soc_component_update_bits(component, MC13783_AUDIO_CODEC, AUDIO_CODEC_CDCFS8K16K,
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200132 val);
133
134 return 0;
135}
136
137static int mc13783_pcm_hw_params_sync(struct snd_pcm_substream *substream,
138 struct snd_pcm_hw_params *params,
139 struct snd_soc_dai *dai)
140{
141 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
142 return mc13783_pcm_hw_params_dac(substream, params, dai);
143 else
144 return mc13783_pcm_hw_params_codec(substream, params, dai);
145}
146
147static int mc13783_set_fmt(struct snd_soc_dai *dai, unsigned int fmt,
148 unsigned int reg)
149{
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000150 struct snd_soc_component *component = dai->component;
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200151 unsigned int val = 0;
152 unsigned int mask = AUDIO_CFS(3) | AUDIO_BCL_INV | AUDIO_CFS_INV |
153 AUDIO_CSM | AUDIO_C_CLK_EN | AUDIO_C_RESET;
154
155
156 /* DAI mode */
157 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
158 case SND_SOC_DAIFMT_I2S:
159 val |= AUDIO_CFS(2);
160 break;
161 case SND_SOC_DAIFMT_DSP_A:
162 val |= AUDIO_CFS(1);
163 break;
164 default:
165 return -EINVAL;
166 }
167
168 /* DAI clock inversion */
169 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
170 case SND_SOC_DAIFMT_NB_NF:
171 val |= AUDIO_BCL_INV;
172 break;
173 case SND_SOC_DAIFMT_NB_IF:
174 val |= AUDIO_BCL_INV | AUDIO_CFS_INV;
175 break;
176 case SND_SOC_DAIFMT_IB_NF:
177 break;
178 case SND_SOC_DAIFMT_IB_IF:
179 val |= AUDIO_CFS_INV;
180 break;
181 }
182
183 /* DAI clock master masks */
184 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
185 case SND_SOC_DAIFMT_CBM_CFM:
186 val |= AUDIO_C_CLK_EN;
187 break;
188 case SND_SOC_DAIFMT_CBS_CFS:
189 val |= AUDIO_CSM;
190 break;
191 case SND_SOC_DAIFMT_CBM_CFS:
192 case SND_SOC_DAIFMT_CBS_CFM:
193 return -EINVAL;
194 }
195
196 val |= AUDIO_C_RESET;
197
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000198 snd_soc_component_update_bits(component, reg, mask, val);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200199
200 return 0;
201}
202
203static int mc13783_set_fmt_async(struct snd_soc_dai *dai, unsigned int fmt)
204{
205 if (dai->id == MC13783_ID_STEREO_DAC)
206 return mc13783_set_fmt(dai, fmt, MC13783_AUDIO_DAC);
207 else
208 return mc13783_set_fmt(dai, fmt, MC13783_AUDIO_CODEC);
209}
210
211static int mc13783_set_fmt_sync(struct snd_soc_dai *dai, unsigned int fmt)
212{
213 int ret;
214
215 ret = mc13783_set_fmt(dai, fmt, MC13783_AUDIO_DAC);
216 if (ret)
217 return ret;
218
219 /*
220 * In synchronous mode force the voice codec into slave mode
221 * so that the clock / framesync from the stereo DAC is used
222 */
223 fmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
224 fmt |= SND_SOC_DAIFMT_CBS_CFS;
225 ret = mc13783_set_fmt(dai, fmt, MC13783_AUDIO_CODEC);
226
227 return ret;
228}
229
230static int mc13783_sysclk[] = {
231 13000000,
232 15360000,
233 16800000,
234 -1,
235 26000000,
236 -1, /* 12000000, invalid for voice codec */
237 -1, /* 3686400, invalid for voice codec */
238 33600000,
239};
240
241static int mc13783_set_sysclk(struct snd_soc_dai *dai,
242 int clk_id, unsigned int freq, int dir,
243 unsigned int reg)
244{
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000245 struct snd_soc_component *component = dai->component;
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200246 int clk;
247 unsigned int val = 0;
248 unsigned int mask = AUDIO_CLK(0x7) | AUDIO_CLK_SEL;
249
250 for (clk = 0; clk < ARRAY_SIZE(mc13783_sysclk); clk++) {
251 if (mc13783_sysclk[clk] < 0)
252 continue;
253 if (mc13783_sysclk[clk] == freq)
254 break;
255 }
256
257 if (clk == ARRAY_SIZE(mc13783_sysclk))
258 return -EINVAL;
259
260 if (clk_id == MC13783_CLK_CLIB)
261 val |= AUDIO_CLK_SEL;
262
263 val |= AUDIO_CLK(clk);
264
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000265 snd_soc_component_update_bits(component, reg, mask, val);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200266
267 return 0;
268}
269
270static int mc13783_set_sysclk_dac(struct snd_soc_dai *dai,
271 int clk_id, unsigned int freq, int dir)
272{
273 return mc13783_set_sysclk(dai, clk_id, freq, dir, MC13783_AUDIO_DAC);
274}
275
276static int mc13783_set_sysclk_codec(struct snd_soc_dai *dai,
277 int clk_id, unsigned int freq, int dir)
278{
279 return mc13783_set_sysclk(dai, clk_id, freq, dir, MC13783_AUDIO_CODEC);
280}
281
282static int mc13783_set_sysclk_sync(struct snd_soc_dai *dai,
283 int clk_id, unsigned int freq, int dir)
284{
285 int ret;
286
287 ret = mc13783_set_sysclk(dai, clk_id, freq, dir, MC13783_AUDIO_DAC);
288 if (ret)
289 return ret;
290
291 return mc13783_set_sysclk(dai, clk_id, freq, dir, MC13783_AUDIO_CODEC);
292}
293
294static int mc13783_set_tdm_slot_dac(struct snd_soc_dai *dai,
295 unsigned int tx_mask, unsigned int rx_mask, int slots,
296 int slot_width)
297{
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000298 struct snd_soc_component *component = dai->component;
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200299 unsigned int val = 0;
300 unsigned int mask = SSI_NETWORK_DAC_SLOT_MASK |
301 SSI_NETWORK_DAC_RXSLOT_MASK;
302
303 switch (slots) {
304 case 2:
305 val |= SSI_NETWORK_DAC_SLOTS_2;
306 break;
307 case 4:
308 val |= SSI_NETWORK_DAC_SLOTS_4;
309 break;
310 case 8:
311 val |= SSI_NETWORK_DAC_SLOTS_8;
312 break;
313 default:
314 return -EINVAL;
315 }
316
317 switch (rx_mask) {
Lars-Peter Clausenbec78c52015-01-12 10:27:17 +0100318 case 0x03:
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200319 val |= SSI_NETWORK_DAC_RXSLOT_0_1;
320 break;
Lars-Peter Clausenbec78c52015-01-12 10:27:17 +0100321 case 0x0c:
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200322 val |= SSI_NETWORK_DAC_RXSLOT_2_3;
323 break;
Lars-Peter Clausenbec78c52015-01-12 10:27:17 +0100324 case 0x30:
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200325 val |= SSI_NETWORK_DAC_RXSLOT_4_5;
326 break;
Lars-Peter Clausenbec78c52015-01-12 10:27:17 +0100327 case 0xc0:
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200328 val |= SSI_NETWORK_DAC_RXSLOT_6_7;
329 break;
330 default:
331 return -EINVAL;
Joe Perches1d198f22013-10-08 15:55:45 -0700332 }
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200333
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000334 snd_soc_component_update_bits(component, MC13783_SSI_NETWORK, mask, val);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200335
336 return 0;
337}
338
339static int mc13783_set_tdm_slot_codec(struct snd_soc_dai *dai,
340 unsigned int tx_mask, unsigned int rx_mask, int slots,
341 int slot_width)
342{
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000343 struct snd_soc_component *component = dai->component;
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200344 unsigned int val = 0;
345 unsigned int mask = 0x3f;
346
347 if (slots != 4)
348 return -EINVAL;
349
Lars-Peter Clausenbec78c52015-01-12 10:27:17 +0100350 if (tx_mask != 0x3)
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200351 return -EINVAL;
352
353 val |= (0x00 << 2); /* primary timeslot RX/TX(?) is 0 */
354 val |= (0x01 << 4); /* secondary timeslot TX is 1 */
355
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000356 snd_soc_component_update_bits(component, MC13783_SSI_NETWORK, mask, val);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200357
358 return 0;
359}
360
361static int mc13783_set_tdm_slot_sync(struct snd_soc_dai *dai,
362 unsigned int tx_mask, unsigned int rx_mask, int slots,
363 int slot_width)
364{
365 int ret;
366
367 ret = mc13783_set_tdm_slot_dac(dai, tx_mask, rx_mask, slots,
368 slot_width);
369 if (ret)
370 return ret;
371
372 ret = mc13783_set_tdm_slot_codec(dai, tx_mask, rx_mask, slots,
373 slot_width);
374
375 return ret;
376}
377
378static const struct snd_kcontrol_new mc1l_amp_ctl =
Gaëtan Carlier6d97c092012-09-06 09:40:12 +0200379 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_TX, 7, 1, 0);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200380
381static const struct snd_kcontrol_new mc1r_amp_ctl =
Gaëtan Carlier6d97c092012-09-06 09:40:12 +0200382 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_TX, 5, 1, 0);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200383
384static const struct snd_kcontrol_new mc2_amp_ctl =
Gaëtan Carlier6d97c092012-09-06 09:40:12 +0200385 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_TX, 9, 1, 0);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200386
387static const struct snd_kcontrol_new atx_amp_ctl =
Gaëtan Carlier6d97c092012-09-06 09:40:12 +0200388 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_TX, 11, 1, 0);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200389
390
391/* Virtual mux. The chip does the input selection automatically
392 * as soon as we enable one input. */
393static const char * const adcl_enum_text[] = {
394 "MC1L", "RXINL",
395};
396
Lars-Peter Clausen15ab40a2014-02-28 08:31:08 +0100397static SOC_ENUM_SINGLE_VIRT_DECL(adcl_enum, adcl_enum_text);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200398
399static const struct snd_kcontrol_new left_input_mux =
Lars-Peter Clausen36bc38a2014-04-14 21:31:00 +0200400 SOC_DAPM_ENUM("Route", adcl_enum);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200401
402static const char * const adcr_enum_text[] = {
403 "MC1R", "MC2", "RXINR", "TXIN",
404};
405
Lars-Peter Clausen15ab40a2014-02-28 08:31:08 +0100406static SOC_ENUM_SINGLE_VIRT_DECL(adcr_enum, adcr_enum_text);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200407
408static const struct snd_kcontrol_new right_input_mux =
Lars-Peter Clausen36bc38a2014-04-14 21:31:00 +0200409 SOC_DAPM_ENUM("Route", adcr_enum);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200410
411static const struct snd_kcontrol_new samp_ctl =
Gaëtan Carlier6d97c092012-09-06 09:40:12 +0200412 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 3, 1, 0);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200413
Steffen Trumtrarbb7838d2013-10-11 12:28:14 +0200414static const char * const speaker_amp_source_text[] = {
415 "CODEC", "Right"
416};
Takashi Iwaia7509872014-02-18 09:42:50 +0100417static SOC_ENUM_SINGLE_DECL(speaker_amp_source, MC13783_AUDIO_RX0, 4,
418 speaker_amp_source_text);
Steffen Trumtrarbb7838d2013-10-11 12:28:14 +0200419static const struct snd_kcontrol_new speaker_amp_source_mux =
420 SOC_DAPM_ENUM("Speaker Amp Source MUX", speaker_amp_source);
421
422static const char * const headset_amp_source_text[] = {
423 "CODEC", "Mixer"
424};
425
Takashi Iwaia7509872014-02-18 09:42:50 +0100426static SOC_ENUM_SINGLE_DECL(headset_amp_source, MC13783_AUDIO_RX0, 11,
427 headset_amp_source_text);
Steffen Trumtrarbb7838d2013-10-11 12:28:14 +0200428static const struct snd_kcontrol_new headset_amp_source_mux =
429 SOC_DAPM_ENUM("Headset Amp Source MUX", headset_amp_source);
430
431static const struct snd_kcontrol_new cdcout_ctl =
432 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 18, 1, 0);
433
434static const struct snd_kcontrol_new adc_bypass_ctl =
435 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_CODEC, 16, 1, 0);
436
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200437static const struct snd_kcontrol_new lamp_ctl =
Gaëtan Carlier6d97c092012-09-06 09:40:12 +0200438 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 5, 1, 0);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200439
440static const struct snd_kcontrol_new hlamp_ctl =
Gaëtan Carlier6d97c092012-09-06 09:40:12 +0200441 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 10, 1, 0);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200442
443static const struct snd_kcontrol_new hramp_ctl =
Gaëtan Carlier6d97c092012-09-06 09:40:12 +0200444 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 9, 1, 0);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200445
446static const struct snd_kcontrol_new llamp_ctl =
Gaëtan Carlier6d97c092012-09-06 09:40:12 +0200447 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 16, 1, 0);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200448
449static const struct snd_kcontrol_new lramp_ctl =
Gaëtan Carlier6d97c092012-09-06 09:40:12 +0200450 SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 15, 1, 0);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200451
452static const struct snd_soc_dapm_widget mc13783_dapm_widgets[] = {
453/* Input */
454 SND_SOC_DAPM_INPUT("MC1LIN"),
455 SND_SOC_DAPM_INPUT("MC1RIN"),
456 SND_SOC_DAPM_INPUT("MC2IN"),
457 SND_SOC_DAPM_INPUT("RXINR"),
458 SND_SOC_DAPM_INPUT("RXINL"),
459 SND_SOC_DAPM_INPUT("TXIN"),
460
Gaëtan Carlier6d97c092012-09-06 09:40:12 +0200461 SND_SOC_DAPM_SUPPLY("MC1 Bias", MC13783_AUDIO_TX, 0, 0, NULL, 0),
462 SND_SOC_DAPM_SUPPLY("MC2 Bias", MC13783_AUDIO_TX, 1, 0, NULL, 0),
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200463
Gaëtan Carlier6d97c092012-09-06 09:40:12 +0200464 SND_SOC_DAPM_SWITCH("MC1L Amp", MC13783_AUDIO_TX, 7, 0, &mc1l_amp_ctl),
465 SND_SOC_DAPM_SWITCH("MC1R Amp", MC13783_AUDIO_TX, 5, 0, &mc1r_amp_ctl),
466 SND_SOC_DAPM_SWITCH("MC2 Amp", MC13783_AUDIO_TX, 9, 0, &mc2_amp_ctl),
467 SND_SOC_DAPM_SWITCH("TXIN Amp", MC13783_AUDIO_TX, 11, 0, &atx_amp_ctl),
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200468
Lars-Peter Clausen36bc38a2014-04-14 21:31:00 +0200469 SND_SOC_DAPM_MUX("PGA Left Input Mux", SND_SOC_NOPM, 0, 0,
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200470 &left_input_mux),
Lars-Peter Clausen36bc38a2014-04-14 21:31:00 +0200471 SND_SOC_DAPM_MUX("PGA Right Input Mux", SND_SOC_NOPM, 0, 0,
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200472 &right_input_mux),
473
Steffen Trumtrarbb7838d2013-10-11 12:28:14 +0200474 SND_SOC_DAPM_MUX("Speaker Amp Source MUX", SND_SOC_NOPM, 0, 0,
475 &speaker_amp_source_mux),
476
477 SND_SOC_DAPM_MUX("Headset Amp Source MUX", SND_SOC_NOPM, 0, 0,
478 &headset_amp_source_mux),
479
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200480 SND_SOC_DAPM_PGA("PGA Left Input", SND_SOC_NOPM, 0, 0, NULL, 0),
481 SND_SOC_DAPM_PGA("PGA Right Input", SND_SOC_NOPM, 0, 0, NULL, 0),
482
Gaëtan Carlier6d97c092012-09-06 09:40:12 +0200483 SND_SOC_DAPM_ADC("ADC", "Capture", MC13783_AUDIO_CODEC, 11, 0),
484 SND_SOC_DAPM_SUPPLY("ADC_Reset", MC13783_AUDIO_CODEC, 15, 0, NULL, 0),
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200485
Steffen Trumtrarbb7838d2013-10-11 12:28:14 +0200486 SND_SOC_DAPM_PGA("Voice CODEC PGA", MC13783_AUDIO_RX1, 0, 0, NULL, 0),
487 SND_SOC_DAPM_SWITCH("Voice CODEC Bypass", MC13783_AUDIO_CODEC, 16, 0,
488 &adc_bypass_ctl),
489
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200490/* Output */
Gaëtan Carlier6d97c092012-09-06 09:40:12 +0200491 SND_SOC_DAPM_SUPPLY("DAC_E", MC13783_AUDIO_DAC, 11, 0, NULL, 0),
492 SND_SOC_DAPM_SUPPLY("DAC_Reset", MC13783_AUDIO_DAC, 15, 0, NULL, 0),
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200493 SND_SOC_DAPM_OUTPUT("RXOUTL"),
494 SND_SOC_DAPM_OUTPUT("RXOUTR"),
495 SND_SOC_DAPM_OUTPUT("HSL"),
496 SND_SOC_DAPM_OUTPUT("HSR"),
Steffen Trumtrarbb7838d2013-10-11 12:28:14 +0200497 SND_SOC_DAPM_OUTPUT("LSPL"),
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200498 SND_SOC_DAPM_OUTPUT("LSP"),
499 SND_SOC_DAPM_OUTPUT("SP"),
Steffen Trumtrarbb7838d2013-10-11 12:28:14 +0200500 SND_SOC_DAPM_OUTPUT("CDCOUT"),
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200501
Steffen Trumtrarbb7838d2013-10-11 12:28:14 +0200502 SND_SOC_DAPM_SWITCH("CDCOUT Switch", MC13783_AUDIO_RX0, 18, 0,
503 &cdcout_ctl),
504 SND_SOC_DAPM_SWITCH("Speaker Amp Switch", MC13783_AUDIO_RX0, 3, 0,
505 &samp_ctl),
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200506 SND_SOC_DAPM_SWITCH("Loudspeaker Amp", SND_SOC_NOPM, 0, 0, &lamp_ctl),
Gaëtan Carlier6d97c092012-09-06 09:40:12 +0200507 SND_SOC_DAPM_SWITCH("Headset Amp Left", MC13783_AUDIO_RX0, 10, 0,
508 &hlamp_ctl),
509 SND_SOC_DAPM_SWITCH("Headset Amp Right", MC13783_AUDIO_RX0, 9, 0,
510 &hramp_ctl),
511 SND_SOC_DAPM_SWITCH("Line out Amp Left", MC13783_AUDIO_RX0, 16, 0,
512 &llamp_ctl),
513 SND_SOC_DAPM_SWITCH("Line out Amp Right", MC13783_AUDIO_RX0, 15, 0,
514 &lramp_ctl),
515 SND_SOC_DAPM_DAC("DAC", "Playback", MC13783_AUDIO_RX0, 22, 0),
516 SND_SOC_DAPM_PGA("DAC PGA", MC13783_AUDIO_RX1, 5, 0, NULL, 0),
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200517};
518
519static struct snd_soc_dapm_route mc13783_routes[] = {
520/* Input */
521 { "MC1L Amp", NULL, "MC1LIN"},
522 { "MC1R Amp", NULL, "MC1RIN" },
523 { "MC2 Amp", NULL, "MC2IN" },
524 { "TXIN Amp", NULL, "TXIN"},
525
526 { "PGA Left Input Mux", "MC1L", "MC1L Amp" },
527 { "PGA Left Input Mux", "RXINL", "RXINL"},
528 { "PGA Right Input Mux", "MC1R", "MC1R Amp" },
529 { "PGA Right Input Mux", "MC2", "MC2 Amp"},
530 { "PGA Right Input Mux", "TXIN", "TXIN Amp"},
531 { "PGA Right Input Mux", "RXINR", "RXINR"},
532
533 { "PGA Left Input", NULL, "PGA Left Input Mux"},
534 { "PGA Right Input", NULL, "PGA Right Input Mux"},
535
536 { "ADC", NULL, "PGA Left Input"},
537 { "ADC", NULL, "PGA Right Input"},
538 { "ADC", NULL, "ADC_Reset"},
539
Steffen Trumtrarbb7838d2013-10-11 12:28:14 +0200540 { "Voice CODEC PGA", "Voice CODEC Bypass", "ADC" },
541
542 { "Speaker Amp Source MUX", "CODEC", "Voice CODEC PGA"},
543 { "Speaker Amp Source MUX", "Right", "DAC PGA"},
544
545 { "Headset Amp Source MUX", "CODEC", "Voice CODEC PGA"},
546 { "Headset Amp Source MUX", "Mixer", "DAC PGA"},
547
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200548/* Output */
549 { "HSL", NULL, "Headset Amp Left" },
550 { "HSR", NULL, "Headset Amp Right"},
551 { "RXOUTL", NULL, "Line out Amp Left"},
552 { "RXOUTR", NULL, "Line out Amp Right"},
Steffen Trumtrarbb7838d2013-10-11 12:28:14 +0200553 { "SP", "Speaker Amp Switch", "Speaker Amp Source MUX"},
554 { "LSP", "Loudspeaker Amp", "Speaker Amp Source MUX"},
555 { "HSL", "Headset Amp Left", "Headset Amp Source MUX"},
556 { "HSR", "Headset Amp Right", "Headset Amp Source MUX"},
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200557 { "Line out Amp Left", NULL, "DAC PGA"},
558 { "Line out Amp Right", NULL, "DAC PGA"},
559 { "DAC PGA", NULL, "DAC"},
560 { "DAC", NULL, "DAC_E"},
Steffen Trumtrarbb7838d2013-10-11 12:28:14 +0200561 { "CDCOUT", "CDCOUT Switch", "Voice CODEC PGA"},
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200562};
563
564static const char * const mc13783_3d_mixer[] = {"Stereo", "Phase Mix",
565 "Mono", "Mono Mix"};
566
Takashi Iwaid1755bb2014-02-18 10:16:08 +0100567static SOC_ENUM_SINGLE_DECL(mc13783_enum_3d_mixer,
568 MC13783_AUDIO_RX1, 16,
569 mc13783_3d_mixer);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200570
571static struct snd_kcontrol_new mc13783_control_list[] = {
572 SOC_SINGLE("Loudspeaker enable", MC13783_AUDIO_RX0, 5, 1, 0),
573 SOC_SINGLE("PCM Playback Volume", MC13783_AUDIO_RX1, 6, 15, 0),
Steffen Trumtrarc6452e392013-10-11 12:28:13 +0200574 SOC_SINGLE("PCM Playback Switch", MC13783_AUDIO_RX1, 5, 1, 0),
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200575 SOC_DOUBLE("PCM Capture Volume", MC13783_AUDIO_TX, 19, 14, 31, 0),
576 SOC_ENUM("3D Control", mc13783_enum_3d_mixer),
Steffen Trumtrarc6452e392013-10-11 12:28:13 +0200577
578 SOC_SINGLE("CDCOUT Switch", MC13783_AUDIO_RX0, 18, 1, 0),
579 SOC_SINGLE("Earpiece Amp Switch", MC13783_AUDIO_RX0, 3, 1, 0),
580 SOC_DOUBLE("Headset Amp Switch", MC13783_AUDIO_RX0, 10, 9, 1, 0),
581 SOC_DOUBLE("Line out Amp Switch", MC13783_AUDIO_RX0, 16, 15, 1, 0),
582
583 SOC_SINGLE("PCM Capture Mixin Switch", MC13783_AUDIO_RX0, 22, 1, 0),
584 SOC_SINGLE("Line in Capture Mixin Switch", MC13783_AUDIO_RX0, 23, 1, 0),
585
586 SOC_SINGLE("CODEC Capture Volume", MC13783_AUDIO_RX1, 1, 15, 0),
587 SOC_SINGLE("CODEC Capture Mixin Switch", MC13783_AUDIO_RX0, 21, 1, 0),
588
589 SOC_SINGLE("Line in Capture Volume", MC13783_AUDIO_RX1, 12, 15, 0),
590 SOC_SINGLE("Line in Capture Switch", MC13783_AUDIO_RX1, 10, 1, 0),
591
592 SOC_SINGLE("MC1 Capture Bias Switch", MC13783_AUDIO_TX, 0, 1, 0),
593 SOC_SINGLE("MC2 Capture Bias Switch", MC13783_AUDIO_TX, 1, 1, 0),
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200594};
595
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000596static int mc13783_probe(struct snd_soc_component *component)
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200597{
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000598 struct mc13783_priv *priv = snd_soc_component_get_drvdata(component);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200599
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000600 snd_soc_component_init_regmap(component,
601 dev_get_regmap(component->dev->parent, NULL));
Kuninori Morimoto33953d82017-11-28 06:05:31 +0000602
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200603 /* these are the reset values */
604 mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_RX0, 0x25893);
605 mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_RX1, 0x00d35A);
606 mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_TX, 0x420000);
607 mc13xxx_reg_write(priv->mc13xxx, MC13783_SSI_NETWORK, 0x013060);
608 mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_CODEC, 0x180027);
609 mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_DAC, 0x0e0004);
610
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200611 if (priv->adc_ssi_port == MC13783_SSI1_PORT)
612 mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_CODEC,
613 AUDIO_SSI_SEL, 0);
614 else
615 mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_CODEC,
Axel Lin545774b2015-04-27 14:51:35 +0800616 AUDIO_SSI_SEL, AUDIO_SSI_SEL);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200617
618 if (priv->dac_ssi_port == MC13783_SSI1_PORT)
619 mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_DAC,
620 AUDIO_SSI_SEL, 0);
621 else
622 mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_DAC,
Axel Lin545774b2015-04-27 14:51:35 +0800623 AUDIO_SSI_SEL, AUDIO_SSI_SEL);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200624
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200625 return 0;
626}
627
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000628static void mc13783_remove(struct snd_soc_component *component)
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200629{
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000630 struct mc13783_priv *priv = snd_soc_component_get_drvdata(component);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200631
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200632 /* Make sure VAUDIOON is off */
633 mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_RX0, 0x3, 0);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200634}
635
636#define MC13783_RATES_RECORD (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000)
637
638#define MC13783_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
639 SNDRV_PCM_FMTBIT_S24_LE)
640
Axel Lin64793042015-07-15 15:38:14 +0800641static const struct snd_soc_dai_ops mc13783_ops_dac = {
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200642 .hw_params = mc13783_pcm_hw_params_dac,
643 .set_fmt = mc13783_set_fmt_async,
644 .set_sysclk = mc13783_set_sysclk_dac,
645 .set_tdm_slot = mc13783_set_tdm_slot_dac,
646};
647
Axel Lin64793042015-07-15 15:38:14 +0800648static const struct snd_soc_dai_ops mc13783_ops_codec = {
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200649 .hw_params = mc13783_pcm_hw_params_codec,
650 .set_fmt = mc13783_set_fmt_async,
651 .set_sysclk = mc13783_set_sysclk_codec,
652 .set_tdm_slot = mc13783_set_tdm_slot_codec,
653};
654
655/*
656 * The mc13783 has two SSI ports, both of them can be routed either
657 * to the voice codec or the stereo DAC. When two different SSI ports
658 * are used for the voice codec and the stereo DAC we can do different
659 * formats and sysclock settings for playback and capture
660 * (mc13783-hifi-playback and mc13783-hifi-capture). Using the same port
661 * forces us to use symmetric rates (mc13783-hifi).
662 */
663static struct snd_soc_dai_driver mc13783_dai_async[] = {
664 {
665 .name = "mc13783-hifi-playback",
666 .id = MC13783_ID_STEREO_DAC,
667 .playback = {
668 .stream_name = "Playback",
Fabio Estevam37f45cc52012-09-03 13:04:13 -0300669 .channels_min = 2,
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200670 .channels_max = 2,
671 .rates = SNDRV_PCM_RATE_8000_96000,
672 .formats = MC13783_FORMATS,
673 },
674 .ops = &mc13783_ops_dac,
675 }, {
676 .name = "mc13783-hifi-capture",
677 .id = MC13783_ID_STEREO_CODEC,
678 .capture = {
679 .stream_name = "Capture",
Fabio Estevam37f45cc52012-09-03 13:04:13 -0300680 .channels_min = 2,
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200681 .channels_max = 2,
682 .rates = MC13783_RATES_RECORD,
683 .formats = MC13783_FORMATS,
684 },
685 .ops = &mc13783_ops_codec,
686 },
687};
688
Axel Lin64793042015-07-15 15:38:14 +0800689static const struct snd_soc_dai_ops mc13783_ops_sync = {
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200690 .hw_params = mc13783_pcm_hw_params_sync,
691 .set_fmt = mc13783_set_fmt_sync,
692 .set_sysclk = mc13783_set_sysclk_sync,
693 .set_tdm_slot = mc13783_set_tdm_slot_sync,
694};
695
696static struct snd_soc_dai_driver mc13783_dai_sync[] = {
697 {
698 .name = "mc13783-hifi",
699 .id = MC13783_ID_SYNC,
700 .playback = {
701 .stream_name = "Playback",
Fabio Estevam37f45cc52012-09-03 13:04:13 -0300702 .channels_min = 2,
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200703 .channels_max = 2,
704 .rates = SNDRV_PCM_RATE_8000_96000,
705 .formats = MC13783_FORMATS,
706 },
707 .capture = {
708 .stream_name = "Capture",
Fabio Estevam37f45cc52012-09-03 13:04:13 -0300709 .channels_min = 2,
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200710 .channels_max = 2,
711 .rates = MC13783_RATES_RECORD,
712 .formats = MC13783_FORMATS,
713 },
714 .ops = &mc13783_ops_sync,
715 .symmetric_rates = 1,
716 }
717};
718
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000719static const struct snd_soc_component_driver soc_component_dev_mc13783 = {
720 .probe = mc13783_probe,
721 .remove = mc13783_remove,
722 .controls = mc13783_control_list,
723 .num_controls = ARRAY_SIZE(mc13783_control_list),
724 .dapm_widgets = mc13783_dapm_widgets,
725 .num_dapm_widgets = ARRAY_SIZE(mc13783_dapm_widgets),
726 .dapm_routes = mc13783_routes,
727 .num_dapm_routes = ARRAY_SIZE(mc13783_routes),
728 .idle_bias_on = 1,
729 .use_pmdown_time = 1,
730 .endianness = 1,
731 .non_legacy_dai_naming = 1,
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200732};
733
Alexander Shiyana5d3f6a2014-01-05 11:38:31 +0400734static int __init mc13783_codec_probe(struct platform_device *pdev)
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200735{
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200736 struct mc13783_priv *priv;
737 struct mc13xxx_codec_platform_data *pdata = pdev->dev.platform_data;
Alexander Shiyan780aaef2014-04-26 10:57:03 +0400738 struct device_node *np;
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200739 int ret;
740
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200741 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
Alexander Shiyan2b320982014-01-05 11:38:34 +0400742 if (!priv)
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200743 return -ENOMEM;
744
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200745 if (pdata) {
746 priv->adc_ssi_port = pdata->adc_ssi_port;
747 priv->dac_ssi_port = pdata->dac_ssi_port;
748 } else {
Alexander Shiyan780aaef2014-04-26 10:57:03 +0400749 np = of_get_child_by_name(pdev->dev.parent->of_node, "codec");
750 if (!np)
751 return -ENOSYS;
752
753 ret = of_property_read_u32(np, "adc-port", &priv->adc_ssi_port);
Mark Browna66ae632014-10-08 15:31:18 +0100754 if (ret) {
755 of_node_put(np);
756 return ret;
757 }
Alexander Shiyan780aaef2014-04-26 10:57:03 +0400758
759 ret = of_property_read_u32(np, "dac-port", &priv->dac_ssi_port);
Mark Browna66ae632014-10-08 15:31:18 +0100760 if (ret) {
761 of_node_put(np);
762 return ret;
763 }
764
765 of_node_put(np);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200766 }
767
Alexander Shiyan2b320982014-01-05 11:38:34 +0400768 dev_set_drvdata(&pdev->dev, priv);
769 priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
770
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200771 if (priv->adc_ssi_port == priv->dac_ssi_port)
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000772 ret = devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_mc13783,
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200773 mc13783_dai_sync, ARRAY_SIZE(mc13783_dai_sync));
774 else
Kuninori Morimoto78c97ec2018-01-29 04:37:36 +0000775 ret = devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_mc13783,
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200776 mc13783_dai_async, ARRAY_SIZE(mc13783_dai_async));
777
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200778 return ret;
779}
780
781static int mc13783_codec_remove(struct platform_device *pdev)
782{
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200783 return 0;
784}
785
786static struct platform_driver mc13783_codec_driver = {
787 .driver = {
Alexander Shiyan2b320982014-01-05 11:38:34 +0400788 .name = "mc13783-codec",
Alexander Shiyan2b320982014-01-05 11:38:34 +0400789 },
Bill Pemberton7a79e942012-12-07 09:26:37 -0500790 .remove = mc13783_codec_remove,
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200791};
Alexander Shiyana5d3f6a2014-01-05 11:38:31 +0400792module_platform_driver_probe(mc13783_codec_driver, mc13783_codec_probe);
Philippe Rétornaz8b908b82012-05-15 13:53:50 +0200793
794MODULE_DESCRIPTION("ASoC MC13783 driver");
795MODULE_AUTHOR("Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>");
796MODULE_AUTHOR("Philippe Retornaz <philippe.retornaz@epfl.ch>");
797MODULE_LICENSE("GPL");