16 #include <linux/tty.h>
17 #include <linux/slab.h>
18 #include <linux/module.h>
33 #define CX20442_PM 0x0
35 #define CX20442_TELIN 0
36 #define CX20442_TELOUT 1
38 #define CX20442_SPKOUT 3
68 {
"TELOUT",
NULL,
"TELOUT Amp"},
70 {
"SPKOUT",
NULL,
"SPKOUT Mixer"},
71 {
"SPKOUT Mixer",
NULL,
"SPKOUT Amp"},
73 {
"TELOUT Amp",
NULL,
"DAC"},
74 {
"SPKOUT Amp",
NULL,
"DAC"},
76 {
"SPKOUT Mixer",
NULL,
"SPKOUT AGC"},
77 {
"SPKOUT AGC",
NULL,
"AGCIN"},
79 {
"AGCOUT",
NULL,
"MIC AGC"},
80 {
"MIC AGC",
NULL,
"MIC"},
82 {
"MIC Bias",
NULL,
"MIC"},
83 {
"Input Mixer",
NULL,
"MIC Bias"},
85 {
"TELIN Bias",
NULL,
"TELIN"},
86 {
"Input Mixer",
NULL,
"TELIN Bias"},
88 {
"ADC",
NULL,
"Input Mixer"},
96 if (reg >= codec->
driver->reg_cache_size)
99 return reg_cache[
reg];
126 static int cx20442_pm_to_v253_vls(
u8 value)
144 static int cx20442_pm_to_v253_vsp(
u8 value)
155 static int cx20442_write(
struct snd_soc_codec *codec,
unsigned int reg,
158 struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec);
160 int vls, vsp, old,
len;
163 if (reg >= codec->
driver->reg_cache_size)
171 old = reg_cache[
reg];
174 vls = cx20442_pm_to_v253_vls(value);
178 vsp = cx20442_pm_to_v253_vsp(value);
183 (vls == cx20442_pm_to_v253_vls(old))) {
184 if (vsp == cx20442_pm_to_v253_vsp(old))
187 }
else if (vsp == cx20442_pm_to_v253_vsp(old))
191 "at+vls=%d;+vsp=%d\r", vls, vsp);
196 dev_dbg(codec->
dev,
"%s: %s\n", __func__, buf);
214 static const char *v253_init =
"ate0m0q0+fclass=8\r";
222 if (!tty->
ops->write)
229 if (tty->
ops->write(tty, v253_init, len) != len) {
241 static void v253_close(
struct tty_struct *tty)
251 cx20442 = snd_soc_codec_get_drvdata(codec);
256 codec->
card->pop_time = 0;
260 static int v253_hangup(
struct tty_struct *tty)
267 static void v253_receive(
struct tty_struct *tty,
268 const unsigned char *
cp,
char *
fp,
int count)
276 cx20442 = snd_soc_codec_get_drvdata(codec);
284 codec->
card->pop_time = 1;
289 static void v253_wakeup(
struct tty_struct *tty)
299 .hangup = v253_hangup,
300 .receive_buf = v253_receive,
301 .write_wakeup = v253_wakeup,
311 .name =
"cx20442-voice",
313 .stream_name =
"Playback",
320 .stream_name =
"Capture",
328 static int cx20442_set_bias_level(
struct snd_soc_codec *codec,
331 struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec);
338 if (IS_ERR(cx20442->
por))
339 err = PTR_ERR(cx20442->
por);
346 if (IS_ERR(cx20442->
por))
347 err = PTR_ERR(cx20442->
por);
369 if (IS_ERR(cx20442->
por))
370 dev_warn(codec->
dev,
"failed to get the regulator");
373 snd_soc_codec_set_drvdata(codec, cx20442);
375 codec->
card->pop_time = 0;
383 struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec);
390 if (!IS_ERR(cx20442->
por)) {
395 snd_soc_codec_set_drvdata(codec,
NULL);
400 static const u8 cx20442_reg;
403 .probe = cx20442_codec_probe,
404 .remove = cx20442_codec_remove,
405 .set_bias_level = cx20442_set_bias_level,
406 .reg_cache_default = &cx20442_reg,
408 .reg_word_size =
sizeof(
u8),
409 .
read = cx20442_read_reg_cache,
410 .
write = cx20442_write,
413 .dapm_routes = cx20442_audio_map,
414 .num_dapm_routes =
ARRAY_SIZE(cx20442_audio_map),
420 &cx20442_codec_dev, &cx20442_dai, 1);
431 .name =
"cx20442-codec",
434 .probe = cx20442_platform_probe,
435 .remove =
__exit_p(cx20442_platform_remove),