aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/da7210.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/da7210.c')
-rw-r--r--sound/soc/codecs/da7210.c91
1 files changed, 82 insertions, 9 deletions
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c
index b545b7d37222..ab38e93c3543 100644
--- a/sound/soc/codecs/da7210.c
+++ b/sound/soc/codecs/da7210.c
@@ -17,7 +17,6 @@
17 17
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/platform_device.h>
21#include <linux/slab.h> 20#include <linux/slab.h>
22#include <linux/module.h> 21#include <linux/module.h>
23#include <sound/pcm.h> 22#include <sound/pcm.h>
@@ -182,9 +181,14 @@
182 181
183/* AUX1_L bit fields */ 182/* AUX1_L bit fields */
184#define DA7210_AUX1_L_VOL (0x3F << 0) 183#define DA7210_AUX1_L_VOL (0x3F << 0)
184#define DA7210_AUX1_L_EN (1 << 7)
185 185
186/* AUX1_R bit fields */ 186/* AUX1_R bit fields */
187#define DA7210_AUX1_R_VOL (0x3F << 0) 187#define DA7210_AUX1_R_VOL (0x3F << 0)
188#define DA7210_AUX1_R_EN (1 << 7)
189
190/* AUX2 bit fields */
191#define DA7210_AUX2_EN (1 << 3)
188 192
189/* Minimum INPGA and AUX1 volume to enable noise suppression */ 193/* Minimum INPGA and AUX1 volume to enable noise suppression */
190#define DA7210_INPGA_MIN_VOL_NS 0x0A /* 10.5dB */ 194#define DA7210_INPGA_MIN_VOL_NS 0x0A /* 10.5dB */
@@ -235,12 +239,22 @@ static const unsigned int mono_vol_tlv[] = {
235 0x3, 0x7, TLV_DB_SCALE_ITEM(-1800, 600, 0) 239 0x3, 0x7, TLV_DB_SCALE_ITEM(-1800, 600, 0)
236}; 240};
237 241
242static const unsigned int aux1_vol_tlv[] = {
243 TLV_DB_RANGE_HEAD(2),
244 0x0, 0x10, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
245 /* -48dB to 21dB */
246 0x11, 0x3f, TLV_DB_SCALE_ITEM(-4800, 150, 0)
247};
248
238static const DECLARE_TLV_DB_SCALE(eq_gain_tlv, -1050, 150, 0); 249static const DECLARE_TLV_DB_SCALE(eq_gain_tlv, -1050, 150, 0);
239static const DECLARE_TLV_DB_SCALE(adc_eq_master_gain_tlv, -1800, 600, 1); 250static const DECLARE_TLV_DB_SCALE(adc_eq_master_gain_tlv, -1800, 600, 1);
240static const DECLARE_TLV_DB_SCALE(dac_gain_tlv, -7725, 75, 0); 251static const DECLARE_TLV_DB_SCALE(dac_gain_tlv, -7725, 75, 0);
252static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, -600, 600, 0);
253static const DECLARE_TLV_DB_SCALE(aux2_vol_tlv, -600, 600, 0);
254static const DECLARE_TLV_DB_SCALE(inpga_gain_tlv, -450, 150, 0);
241 255
242/* ADC and DAC high pass filter f0 value */ 256/* ADC and DAC high pass filter f0 value */
243static const char const *da7210_hpf_cutoff_txt[] = { 257static const char * const da7210_hpf_cutoff_txt[] = {
244 "Fs/8192*pi", "Fs/4096*pi", "Fs/2048*pi", "Fs/1024*pi" 258 "Fs/8192*pi", "Fs/4096*pi", "Fs/2048*pi", "Fs/1024*pi"
245}; 259};
246 260
@@ -251,7 +265,7 @@ static const struct soc_enum da7210_adc_hpf_cutoff =
251 SOC_ENUM_SINGLE(DA7210_ADC_HPF, 0, 4, da7210_hpf_cutoff_txt); 265 SOC_ENUM_SINGLE(DA7210_ADC_HPF, 0, 4, da7210_hpf_cutoff_txt);
252 266
253/* ADC and DAC voice (8kHz) high pass cutoff value */ 267/* ADC and DAC voice (8kHz) high pass cutoff value */
254static const char const *da7210_vf_cutoff_txt[] = { 268static const char * const da7210_vf_cutoff_txt[] = {
255 "2.5Hz", "25Hz", "50Hz", "100Hz", "150Hz", "200Hz", "300Hz", "400Hz" 269 "2.5Hz", "25Hz", "50Hz", "100Hz", "150Hz", "200Hz", "300Hz", "400Hz"
256}; 270};
257 271
@@ -345,6 +359,17 @@ static const struct snd_kcontrol_new da7210_snd_controls[] = {
345 SOC_SINGLE_TLV("Mono Playback Volume", DA7210_OUT2, 0, 0x7, 0, 359 SOC_SINGLE_TLV("Mono Playback Volume", DA7210_OUT2, 0, 0x7, 0,
346 mono_vol_tlv), 360 mono_vol_tlv),
347 361
362 SOC_DOUBLE_R_TLV("Mic Capture Volume",
363 DA7210_MIC_L, DA7210_MIC_R,
364 0, 0x5, 0, mic_vol_tlv),
365 SOC_DOUBLE_R_TLV("Aux1 Capture Volume",
366 DA7210_AUX1_L, DA7210_AUX1_R,
367 0, 0x3f, 0, aux1_vol_tlv),
368 SOC_SINGLE_TLV("Aux2 Capture Volume", DA7210_AUX2, 0, 0x3, 0,
369 aux2_vol_tlv),
370 SOC_DOUBLE_TLV("In PGA Capture Volume", DA7210_IN_GAIN, 0, 4, 0xF, 0,
371 inpga_gain_tlv),
372
348 /* DAC Equalizer controls */ 373 /* DAC Equalizer controls */
349 SOC_SINGLE("DAC EQ Switch", DA7210_DAC_EQ5, 7, 1, 0), 374 SOC_SINGLE("DAC EQ Switch", DA7210_DAC_EQ5, 7, 1, 0),
350 SOC_SINGLE_TLV("DAC EQ1 Volume", DA7210_DAC_EQ1_2, 0, 0xf, 1, 375 SOC_SINGLE_TLV("DAC EQ1 Volume", DA7210_DAC_EQ1_2, 0, 0xf, 1,
@@ -422,26 +447,42 @@ static const struct snd_kcontrol_new da7210_snd_controls[] = {
422static const struct snd_kcontrol_new da7210_dapm_inmixl_controls[] = { 447static const struct snd_kcontrol_new da7210_dapm_inmixl_controls[] = {
423 SOC_DAPM_SINGLE("Mic Left Switch", DA7210_INMIX_L, 0, 1, 0), 448 SOC_DAPM_SINGLE("Mic Left Switch", DA7210_INMIX_L, 0, 1, 0),
424 SOC_DAPM_SINGLE("Mic Right Switch", DA7210_INMIX_L, 1, 1, 0), 449 SOC_DAPM_SINGLE("Mic Right Switch", DA7210_INMIX_L, 1, 1, 0),
450 SOC_DAPM_SINGLE("Aux1 Left Switch", DA7210_INMIX_L, 2, 1, 0),
451 SOC_DAPM_SINGLE("Aux2 Switch", DA7210_INMIX_L, 3, 1, 0),
452 SOC_DAPM_SINGLE("Outmix Left Switch", DA7210_INMIX_L, 4, 1, 0),
425}; 453};
426 454
427/* In Mixer Right */ 455/* In Mixer Right */
428static const struct snd_kcontrol_new da7210_dapm_inmixr_controls[] = { 456static const struct snd_kcontrol_new da7210_dapm_inmixr_controls[] = {
429 SOC_DAPM_SINGLE("Mic Right Switch", DA7210_INMIX_R, 0, 1, 0), 457 SOC_DAPM_SINGLE("Mic Right Switch", DA7210_INMIX_R, 0, 1, 0),
430 SOC_DAPM_SINGLE("Mic Left Switch", DA7210_INMIX_R, 1, 1, 0), 458 SOC_DAPM_SINGLE("Mic Left Switch", DA7210_INMIX_R, 1, 1, 0),
459 SOC_DAPM_SINGLE("Aux1 Right Switch", DA7210_INMIX_R, 2, 1, 0),
460 SOC_DAPM_SINGLE("Aux2 Switch", DA7210_INMIX_R, 3, 1, 0),
461 SOC_DAPM_SINGLE("Outmix Right Switch", DA7210_INMIX_R, 4, 1, 0),
431}; 462};
432 463
433/* Out Mixer Left */ 464/* Out Mixer Left */
434static const struct snd_kcontrol_new da7210_dapm_outmixl_controls[] = { 465static const struct snd_kcontrol_new da7210_dapm_outmixl_controls[] = {
466 SOC_DAPM_SINGLE("Aux1 Left Switch", DA7210_OUTMIX_L, 0, 1, 0),
467 SOC_DAPM_SINGLE("Aux2 Switch", DA7210_OUTMIX_L, 1, 1, 0),
468 SOC_DAPM_SINGLE("INPGA Left Switch", DA7210_OUTMIX_L, 2, 1, 0),
469 SOC_DAPM_SINGLE("INPGA Right Switch", DA7210_OUTMIX_L, 3, 1, 0),
435 SOC_DAPM_SINGLE("DAC Left Switch", DA7210_OUTMIX_L, 4, 1, 0), 470 SOC_DAPM_SINGLE("DAC Left Switch", DA7210_OUTMIX_L, 4, 1, 0),
436}; 471};
437 472
438/* Out Mixer Right */ 473/* Out Mixer Right */
439static const struct snd_kcontrol_new da7210_dapm_outmixr_controls[] = { 474static const struct snd_kcontrol_new da7210_dapm_outmixr_controls[] = {
475 SOC_DAPM_SINGLE("Aux1 Right Switch", DA7210_OUTMIX_R, 0, 1, 0),
476 SOC_DAPM_SINGLE("Aux2 Switch", DA7210_OUTMIX_R, 1, 1, 0),
477 SOC_DAPM_SINGLE("INPGA Left Switch", DA7210_OUTMIX_R, 2, 1, 0),
478 SOC_DAPM_SINGLE("INPGA Right Switch", DA7210_OUTMIX_R, 3, 1, 0),
440 SOC_DAPM_SINGLE("DAC Right Switch", DA7210_OUTMIX_R, 4, 1, 0), 479 SOC_DAPM_SINGLE("DAC Right Switch", DA7210_OUTMIX_R, 4, 1, 0),
441}; 480};
442 481
443/* Mono Mixer */ 482/* Mono Mixer */
444static const struct snd_kcontrol_new da7210_dapm_monomix_controls[] = { 483static const struct snd_kcontrol_new da7210_dapm_monomix_controls[] = {
484 SOC_DAPM_SINGLE("INPGA Right Switch", DA7210_OUT2, 3, 1, 0),
485 SOC_DAPM_SINGLE("INPGA Left Switch", DA7210_OUT2, 4, 1, 0),
445 SOC_DAPM_SINGLE("Outmix Right Switch", DA7210_OUT2, 5, 1, 0), 486 SOC_DAPM_SINGLE("Outmix Right Switch", DA7210_OUT2, 5, 1, 0),
446 SOC_DAPM_SINGLE("Outmix Left Switch", DA7210_OUT2, 6, 1, 0), 487 SOC_DAPM_SINGLE("Outmix Left Switch", DA7210_OUT2, 6, 1, 0),
447}; 488};
@@ -452,14 +493,23 @@ static const struct snd_soc_dapm_widget da7210_dapm_widgets[] = {
452 /* Input Lines */ 493 /* Input Lines */
453 SND_SOC_DAPM_INPUT("MICL"), 494 SND_SOC_DAPM_INPUT("MICL"),
454 SND_SOC_DAPM_INPUT("MICR"), 495 SND_SOC_DAPM_INPUT("MICR"),
496 SND_SOC_DAPM_INPUT("AUX1L"),
497 SND_SOC_DAPM_INPUT("AUX1R"),
498 SND_SOC_DAPM_INPUT("AUX2"),
455 499
456 /* Input PGAs */ 500 /* Input PGAs */
457 SND_SOC_DAPM_PGA("Mic Left", DA7210_STARTUP3, 0, 1, NULL, 0), 501 SND_SOC_DAPM_PGA("Mic Left", DA7210_STARTUP3, 0, 1, NULL, 0),
458 SND_SOC_DAPM_PGA("Mic Right", DA7210_STARTUP3, 1, 1, NULL, 0), 502 SND_SOC_DAPM_PGA("Mic Right", DA7210_STARTUP3, 1, 1, NULL, 0),
503 SND_SOC_DAPM_PGA("Aux1 Left", DA7210_STARTUP3, 2, 1, NULL, 0),
504 SND_SOC_DAPM_PGA("Aux1 Right", DA7210_STARTUP3, 3, 1, NULL, 0),
505 SND_SOC_DAPM_PGA("Aux2 Mono", DA7210_STARTUP3, 4, 1, NULL, 0),
459 506
460 SND_SOC_DAPM_PGA("INPGA Left", DA7210_INMIX_L, 7, 0, NULL, 0), 507 SND_SOC_DAPM_PGA("INPGA Left", DA7210_INMIX_L, 7, 0, NULL, 0),
461 SND_SOC_DAPM_PGA("INPGA Right", DA7210_INMIX_R, 7, 0, NULL, 0), 508 SND_SOC_DAPM_PGA("INPGA Right", DA7210_INMIX_R, 7, 0, NULL, 0),
462 509
510 /* MICBIAS */
511 SND_SOC_DAPM_SUPPLY("Mic Bias", DA7210_MIC_L, 6, 0, NULL, 0),
512
463 /* Input Mixers */ 513 /* Input Mixers */
464 SND_SOC_DAPM_MIXER("In Mixer Left", SND_SOC_NOPM, 0, 0, 514 SND_SOC_DAPM_MIXER("In Mixer Left", SND_SOC_NOPM, 0, 0,
465 &da7210_dapm_inmixl_controls[0], 515 &da7210_dapm_inmixl_controls[0],
@@ -515,12 +565,21 @@ static const struct snd_soc_dapm_route da7210_audio_map[] = {
515 /* Input path */ 565 /* Input path */
516 {"Mic Left", NULL, "MICL"}, 566 {"Mic Left", NULL, "MICL"},
517 {"Mic Right", NULL, "MICR"}, 567 {"Mic Right", NULL, "MICR"},
568 {"Aux1 Left", NULL, "AUX1L"},
569 {"Aux1 Right", NULL, "AUX1R"},
570 {"Aux2 Mono", NULL, "AUX2"},
518 571
519 {"In Mixer Left", "Mic Left Switch", "Mic Left"}, 572 {"In Mixer Left", "Mic Left Switch", "Mic Left"},
520 {"In Mixer Left", "Mic Right Switch", "Mic Right"}, 573 {"In Mixer Left", "Mic Right Switch", "Mic Right"},
574 {"In Mixer Left", "Aux1 Left Switch", "Aux1 Left"},
575 {"In Mixer Left", "Aux2 Switch", "Aux2 Mono"},
576 {"In Mixer Left", "Outmix Left Switch", "Out Mixer Left"},
521 577
522 {"In Mixer Right", "Mic Right Switch", "Mic Right"}, 578 {"In Mixer Right", "Mic Right Switch", "Mic Right"},
523 {"In Mixer Right", "Mic Left Switch", "Mic Left"}, 579 {"In Mixer Right", "Mic Left Switch", "Mic Left"},
580 {"In Mixer Right", "Aux1 Right Switch", "Aux1 Right"},
581 {"In Mixer Right", "Aux2 Switch", "Aux2 Mono"},
582 {"In Mixer Right", "Outmix Right Switch", "Out Mixer Right"},
524 583
525 {"INPGA Left", NULL, "In Mixer Left"}, 584 {"INPGA Left", NULL, "In Mixer Left"},
526 {"ADC Left", NULL, "INPGA Left"}, 585 {"ADC Left", NULL, "INPGA Left"},
@@ -529,9 +588,20 @@ static const struct snd_soc_dapm_route da7210_audio_map[] = {
529 {"ADC Right", NULL, "INPGA Right"}, 588 {"ADC Right", NULL, "INPGA Right"},
530 589
531 /* Output path */ 590 /* Output path */
591 {"Out Mixer Left", "Aux1 Left Switch", "Aux1 Left"},
592 {"Out Mixer Left", "Aux2 Switch", "Aux2 Mono"},
593 {"Out Mixer Left", "INPGA Left Switch", "INPGA Left"},
594 {"Out Mixer Left", "INPGA Right Switch", "INPGA Right"},
532 {"Out Mixer Left", "DAC Left Switch", "DAC Left"}, 595 {"Out Mixer Left", "DAC Left Switch", "DAC Left"},
596
597 {"Out Mixer Right", "Aux1 Right Switch", "Aux1 Right"},
598 {"Out Mixer Right", "Aux2 Switch", "Aux2 Mono"},
599 {"Out Mixer Right", "INPGA Right Switch", "INPGA Right"},
600 {"Out Mixer Right", "INPGA Left Switch", "INPGA Left"},
533 {"Out Mixer Right", "DAC Right Switch", "DAC Right"}, 601 {"Out Mixer Right", "DAC Right Switch", "DAC Right"},
534 602
603 {"Mono Mixer", "INPGA Right Switch", "INPGA Right"},
604 {"Mono Mixer", "INPGA Left Switch", "INPGA Left"},
535 {"Mono Mixer", "Outmix Right Switch", "Out Mixer Right"}, 605 {"Mono Mixer", "Outmix Right Switch", "Out Mixer Right"},
536 {"Mono Mixer", "Outmix Left Switch", "Out Mixer Left"}, 606 {"Mono Mixer", "Outmix Left Switch", "Out Mixer Left"},
537 607
@@ -761,7 +831,7 @@ static int da7210_mute(struct snd_soc_dai *dai, int mute)
761 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 831 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
762 832
763/* DAI operations */ 833/* DAI operations */
764static struct snd_soc_dai_ops da7210_dai_ops = { 834static const struct snd_soc_dai_ops da7210_dai_ops = {
765 .hw_params = da7210_hw_params, 835 .hw_params = da7210_hw_params,
766 .set_fmt = da7210_set_dai_fmt, 836 .set_fmt = da7210_set_dai_fmt,
767 .digital_mute = da7210_mute, 837 .digital_mute = da7210_mute,
@@ -888,6 +958,12 @@ static int da7210_probe(struct snd_soc_codec *codec)
888 snd_soc_write(codec, DA7210_OUT2, DA7210_OUT2_EN | 958 snd_soc_write(codec, DA7210_OUT2, DA7210_OUT2_EN |
889 DA7210_OUT2_OUTMIX_L | DA7210_OUT2_OUTMIX_R); 959 DA7210_OUT2_OUTMIX_L | DA7210_OUT2_OUTMIX_R);
890 960
961 /* Enable Aux1 */
962 snd_soc_write(codec, DA7210_AUX1_L, DA7210_AUX1_L_EN);
963 snd_soc_write(codec, DA7210_AUX1_R, DA7210_AUX1_R_EN);
964 /* Enable Aux2 */
965 snd_soc_write(codec, DA7210_AUX2, DA7210_AUX2_EN);
966
891 /* Diable PLL and bypass it */ 967 /* Diable PLL and bypass it */
892 snd_soc_write(codec, DA7210_PLL, DA7210_PLL_FS_48000); 968 snd_soc_write(codec, DA7210_PLL, DA7210_PLL_FS_48000);
893 969
@@ -945,7 +1021,8 @@ static int __devinit da7210_i2c_probe(struct i2c_client *i2c,
945 struct da7210_priv *da7210; 1021 struct da7210_priv *da7210;
946 int ret; 1022 int ret;
947 1023
948 da7210 = kzalloc(sizeof(struct da7210_priv), GFP_KERNEL); 1024 da7210 = devm_kzalloc(&i2c->dev, sizeof(struct da7210_priv),
1025 GFP_KERNEL);
949 if (!da7210) 1026 if (!da7210)
950 return -ENOMEM; 1027 return -ENOMEM;
951 1028
@@ -954,16 +1031,12 @@ static int __devinit da7210_i2c_probe(struct i2c_client *i2c,
954 1031
955 ret = snd_soc_register_codec(&i2c->dev, 1032 ret = snd_soc_register_codec(&i2c->dev,
956 &soc_codec_dev_da7210, &da7210_dai, 1); 1033 &soc_codec_dev_da7210, &da7210_dai, 1);
957 if (ret < 0)
958 kfree(da7210);
959
960 return ret; 1034 return ret;
961} 1035}
962 1036
963static int __devexit da7210_i2c_remove(struct i2c_client *client) 1037static int __devexit da7210_i2c_remove(struct i2c_client *client)
964{ 1038{
965 snd_soc_unregister_codec(&client->dev); 1039 snd_soc_unregister_codec(&client->dev);
966 kfree(i2c_get_clientdata(client));
967 return 0; 1040 return 0;
968} 1041}
969 1042