aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaesar Wang <wxt@rock-chips.com>2016-01-28 03:43:36 -0500
committerMark Brown <broonie@kernel.org>2016-01-28 16:54:19 -0500
commit99081589c5ad590e9828ae9febc384612f241164 (patch)
tree0a74cfb11ecfaf2b6e8b6ab93da88d3f1fb62cde
parentdcaee813a64368e09878d0cee931d14c9603e925 (diff)
ASoC: rt5616: trivial: fix the typo
This patch try to fix the trivial typo. Run "scripts/checkpatch.pl -f --subjective xxx" The enable more subjective tests. Signed-off-by: Caesar Wang <wxt@rock-chips.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/rt5616.c376
1 files changed, 191 insertions, 185 deletions
diff --git a/sound/soc/codecs/rt5616.c b/sound/soc/codecs/rt5616.c
index 1c10d8ed39d2..d4bdf9f6f0af 100644
--- a/sound/soc/codecs/rt5616.c
+++ b/sound/soc/codecs/rt5616.c
@@ -53,6 +53,7 @@ static const struct reg_sequence init_list[] = {
53 {RT5616_PR_BASE + 0x21, 0x4040}, 53 {RT5616_PR_BASE + 0x21, 0x4040},
54 {RT5616_PR_BASE + 0x23, 0x0004}, 54 {RT5616_PR_BASE + 0x23, 0x0004},
55}; 55};
56
56#define RT5616_INIT_REG_LEN ARRAY_SIZE(init_list) 57#define RT5616_INIT_REG_LEN ARRAY_SIZE(init_list)
57 58
58static const struct reg_default rt5616_reg[] = { 59static const struct reg_default rt5616_reg[] = {
@@ -162,9 +163,8 @@ static bool rt5616_volatile_register(struct device *dev, unsigned int reg)
162 163
163 for (i = 0; i < ARRAY_SIZE(rt5616_ranges); i++) { 164 for (i = 0; i < ARRAY_SIZE(rt5616_ranges); i++) {
164 if (reg >= rt5616_ranges[i].range_min && 165 if (reg >= rt5616_ranges[i].range_min &&
165 reg <= rt5616_ranges[i].range_max) { 166 reg <= rt5616_ranges[i].range_max)
166 return true; 167 return true;
167 }
168 } 168 }
169 169
170 switch (reg) { 170 switch (reg) {
@@ -190,9 +190,8 @@ static bool rt5616_readable_register(struct device *dev, unsigned int reg)
190 190
191 for (i = 0; i < ARRAY_SIZE(rt5616_ranges); i++) { 191 for (i = 0; i < ARRAY_SIZE(rt5616_ranges); i++) {
192 if (reg >= rt5616_ranges[i].range_min && 192 if (reg >= rt5616_ranges[i].range_min &&
193 reg <= rt5616_ranges[i].range_max) { 193 reg <= rt5616_ranges[i].range_max)
194 return true; 194 return true;
195 }
196 } 195 }
197 196
198 switch (reg) { 197 switch (reg) {
@@ -307,45 +306,45 @@ static unsigned int bst_tlv[] = {
307static const struct snd_kcontrol_new rt5616_snd_controls[] = { 306static const struct snd_kcontrol_new rt5616_snd_controls[] = {
308 /* Headphone Output Volume */ 307 /* Headphone Output Volume */
309 SOC_DOUBLE("HP Playback Switch", RT5616_HP_VOL, 308 SOC_DOUBLE("HP Playback Switch", RT5616_HP_VOL,
310 RT5616_L_MUTE_SFT, RT5616_R_MUTE_SFT, 1, 1), 309 RT5616_L_MUTE_SFT, RT5616_R_MUTE_SFT, 1, 1),
311 SOC_DOUBLE_TLV("HP Playback Volume", RT5616_HP_VOL, 310 SOC_DOUBLE_TLV("HP Playback Volume", RT5616_HP_VOL,
312 RT5616_L_VOL_SFT, RT5616_R_VOL_SFT, 39, 1, out_vol_tlv), 311 RT5616_L_VOL_SFT, RT5616_R_VOL_SFT, 39, 1, out_vol_tlv),
313 /* OUTPUT Control */ 312 /* OUTPUT Control */
314 SOC_DOUBLE("OUT Playback Switch", RT5616_LOUT_CTRL1, 313 SOC_DOUBLE("OUT Playback Switch", RT5616_LOUT_CTRL1,
315 RT5616_L_MUTE_SFT, RT5616_R_MUTE_SFT, 1, 1), 314 RT5616_L_MUTE_SFT, RT5616_R_MUTE_SFT, 1, 1),
316 SOC_DOUBLE("OUT Channel Switch", RT5616_LOUT_CTRL1, 315 SOC_DOUBLE("OUT Channel Switch", RT5616_LOUT_CTRL1,
317 RT5616_VOL_L_SFT, RT5616_VOL_R_SFT, 1, 1), 316 RT5616_VOL_L_SFT, RT5616_VOL_R_SFT, 1, 1),
318 SOC_DOUBLE_TLV("OUT Playback Volume", RT5616_LOUT_CTRL1, 317 SOC_DOUBLE_TLV("OUT Playback Volume", RT5616_LOUT_CTRL1,
319 RT5616_L_VOL_SFT, RT5616_R_VOL_SFT, 39, 1, out_vol_tlv), 318 RT5616_L_VOL_SFT, RT5616_R_VOL_SFT, 39, 1, out_vol_tlv),
320 319
321 /* DAC Digital Volume */ 320 /* DAC Digital Volume */
322 SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5616_DAC1_DIG_VOL, 321 SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5616_DAC1_DIG_VOL,
323 RT5616_L_VOL_SFT, RT5616_R_VOL_SFT, 322 RT5616_L_VOL_SFT, RT5616_R_VOL_SFT,
324 175, 0, dac_vol_tlv), 323 175, 0, dac_vol_tlv),
325 /* IN1/IN2 Control */ 324 /* IN1/IN2 Control */
326 SOC_SINGLE_TLV("IN1 Boost Volume", RT5616_IN1_IN2, 325 SOC_SINGLE_TLV("IN1 Boost Volume", RT5616_IN1_IN2,
327 RT5616_BST_SFT1, 8, 0, bst_tlv), 326 RT5616_BST_SFT1, 8, 0, bst_tlv),
328 SOC_SINGLE_TLV("IN2 Boost Volume", RT5616_IN1_IN2, 327 SOC_SINGLE_TLV("IN2 Boost Volume", RT5616_IN1_IN2,
329 RT5616_BST_SFT2, 8, 0, bst_tlv), 328 RT5616_BST_SFT2, 8, 0, bst_tlv),
330 /* INL/INR Volume Control */ 329 /* INL/INR Volume Control */
331 SOC_DOUBLE_TLV("IN Capture Volume", RT5616_INL1_INR1_VOL, 330 SOC_DOUBLE_TLV("IN Capture Volume", RT5616_INL1_INR1_VOL,
332 RT5616_INL_VOL_SFT, RT5616_INR_VOL_SFT, 331 RT5616_INL_VOL_SFT, RT5616_INR_VOL_SFT,
333 31, 1, in_vol_tlv), 332 31, 1, in_vol_tlv),
334 /* ADC Digital Volume Control */ 333 /* ADC Digital Volume Control */
335 SOC_DOUBLE("ADC Capture Switch", RT5616_ADC_DIG_VOL, 334 SOC_DOUBLE("ADC Capture Switch", RT5616_ADC_DIG_VOL,
336 RT5616_L_MUTE_SFT, RT5616_R_MUTE_SFT, 1, 1), 335 RT5616_L_MUTE_SFT, RT5616_R_MUTE_SFT, 1, 1),
337 SOC_DOUBLE_TLV("ADC Capture Volume", RT5616_ADC_DIG_VOL, 336 SOC_DOUBLE_TLV("ADC Capture Volume", RT5616_ADC_DIG_VOL,
338 RT5616_L_VOL_SFT, RT5616_R_VOL_SFT, 337 RT5616_L_VOL_SFT, RT5616_R_VOL_SFT,
339 127, 0, adc_vol_tlv), 338 127, 0, adc_vol_tlv),
340 339
341 /* ADC Boost Volume Control */ 340 /* ADC Boost Volume Control */
342 SOC_DOUBLE_TLV("ADC Boost Volume", RT5616_ADC_BST_VOL, 341 SOC_DOUBLE_TLV("ADC Boost Volume", RT5616_ADC_BST_VOL,
343 RT5616_ADC_L_BST_SFT, RT5616_ADC_R_BST_SFT, 342 RT5616_ADC_L_BST_SFT, RT5616_ADC_R_BST_SFT,
344 3, 0, adc_bst_tlv), 343 3, 0, adc_bst_tlv),
345}; 344};
346 345
347static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, 346static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
348 struct snd_soc_dapm_widget *sink) 347 struct snd_soc_dapm_widget *sink)
349{ 348{
350 unsigned int val; 349 unsigned int val;
351 350
@@ -462,20 +461,20 @@ static const struct snd_kcontrol_new rt5616_lout_mix[] = {
462}; 461};
463 462
464static int rt5616_adc_event(struct snd_soc_dapm_widget *w, 463static int rt5616_adc_event(struct snd_soc_dapm_widget *w,
465 struct snd_kcontrol *kcontrol, int event) 464 struct snd_kcontrol *kcontrol, int event)
466{ 465{
467 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 466 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
468 467
469 switch (event) { 468 switch (event) {
470 case SND_SOC_DAPM_POST_PMU: 469 case SND_SOC_DAPM_POST_PMU:
471 snd_soc_update_bits(codec, RT5616_ADC_DIG_VOL, 470 snd_soc_update_bits(codec, RT5616_ADC_DIG_VOL,
472 RT5616_L_MUTE | RT5616_R_MUTE, 0); 471 RT5616_L_MUTE | RT5616_R_MUTE, 0);
473 break; 472 break;
474 473
475 case SND_SOC_DAPM_POST_PMD: 474 case SND_SOC_DAPM_POST_PMD:
476 snd_soc_update_bits(codec, RT5616_ADC_DIG_VOL, 475 snd_soc_update_bits(codec, RT5616_ADC_DIG_VOL,
477 RT5616_L_MUTE | RT5616_R_MUTE, 476 RT5616_L_MUTE | RT5616_R_MUTE,
478 RT5616_L_MUTE | RT5616_R_MUTE); 477 RT5616_L_MUTE | RT5616_R_MUTE);
479 break; 478 break;
480 479
481 default: 480 default:
@@ -486,7 +485,7 @@ static int rt5616_adc_event(struct snd_soc_dapm_widget *w,
486} 485}
487 486
488static int rt5616_charge_pump_event(struct snd_soc_dapm_widget *w, 487static int rt5616_charge_pump_event(struct snd_soc_dapm_widget *w,
489 struct snd_kcontrol *kcontrol, int event) 488 struct snd_kcontrol *kcontrol, int event)
490{ 489{
491 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 490 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
492 491
@@ -494,54 +493,55 @@ static int rt5616_charge_pump_event(struct snd_soc_dapm_widget *w,
494 case SND_SOC_DAPM_POST_PMU: 493 case SND_SOC_DAPM_POST_PMU:
495 /* depop parameters */ 494 /* depop parameters */
496 snd_soc_update_bits(codec, RT5616_DEPOP_M2, 495 snd_soc_update_bits(codec, RT5616_DEPOP_M2,
497 RT5616_DEPOP_MASK, RT5616_DEPOP_MAN); 496 RT5616_DEPOP_MASK, RT5616_DEPOP_MAN);
498 snd_soc_update_bits(codec, RT5616_DEPOP_M1, 497 snd_soc_update_bits(codec, RT5616_DEPOP_M1,
499 RT5616_HP_CP_MASK | RT5616_HP_SG_MASK | 498 RT5616_HP_CP_MASK | RT5616_HP_SG_MASK |
500 RT5616_HP_CB_MASK, RT5616_HP_CP_PU | 499 RT5616_HP_CB_MASK, RT5616_HP_CP_PU |
501 RT5616_HP_SG_DIS | RT5616_HP_CB_PU); 500 RT5616_HP_SG_DIS | RT5616_HP_CB_PU);
502 snd_soc_write(codec, RT5616_PR_BASE + 501 snd_soc_write(codec, RT5616_PR_BASE +
503 RT5616_HP_DCC_INT1, 0x9f00); 502 RT5616_HP_DCC_INT1, 0x9f00);
504 /* headphone amp power on */ 503 /* headphone amp power on */
505 snd_soc_update_bits(codec, RT5616_PWR_ANLG1, 504 snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
506 RT5616_PWR_FV1 | RT5616_PWR_FV2, 0); 505 RT5616_PWR_FV1 | RT5616_PWR_FV2, 0);
507 snd_soc_update_bits(codec, RT5616_PWR_VOL, 506 snd_soc_update_bits(codec, RT5616_PWR_VOL,
508 RT5616_PWR_HV_L | RT5616_PWR_HV_R, 507 RT5616_PWR_HV_L | RT5616_PWR_HV_R,
509 RT5616_PWR_HV_L | RT5616_PWR_HV_R); 508 RT5616_PWR_HV_L | RT5616_PWR_HV_R);
510 snd_soc_update_bits(codec, RT5616_PWR_ANLG1, 509 snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
511 RT5616_PWR_HP_L | RT5616_PWR_HP_R | 510 RT5616_PWR_HP_L | RT5616_PWR_HP_R |
512 RT5616_PWR_HA, RT5616_PWR_HP_L | 511 RT5616_PWR_HA, RT5616_PWR_HP_L |
513 RT5616_PWR_HP_R | RT5616_PWR_HA); 512 RT5616_PWR_HP_R | RT5616_PWR_HA);
514 msleep(50); 513 msleep(50);
515 snd_soc_update_bits(codec, RT5616_PWR_ANLG1, 514 snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
516 RT5616_PWR_FV1 | RT5616_PWR_FV2, 515 RT5616_PWR_FV1 | RT5616_PWR_FV2,
517 RT5616_PWR_FV1 | RT5616_PWR_FV2); 516 RT5616_PWR_FV1 | RT5616_PWR_FV2);
518 517
519 snd_soc_update_bits(codec, RT5616_CHARGE_PUMP, 518 snd_soc_update_bits(codec, RT5616_CHARGE_PUMP,
520 RT5616_PM_HP_MASK, RT5616_PM_HP_HV); 519 RT5616_PM_HP_MASK, RT5616_PM_HP_HV);
521 snd_soc_update_bits(codec, RT5616_PR_BASE + 520 snd_soc_update_bits(codec, RT5616_PR_BASE +
522 RT5616_CHOP_DAC_ADC, 0x0200, 0x0200); 521 RT5616_CHOP_DAC_ADC, 0x0200, 0x0200);
523 snd_soc_update_bits(codec, RT5616_DEPOP_M1, 522 snd_soc_update_bits(codec, RT5616_DEPOP_M1,
524 RT5616_HP_CO_MASK | RT5616_HP_SG_MASK, 523 RT5616_HP_CO_MASK | RT5616_HP_SG_MASK,
525 RT5616_HP_CO_EN | RT5616_HP_SG_EN); 524 RT5616_HP_CO_EN | RT5616_HP_SG_EN);
526 break; 525 break;
527 case SND_SOC_DAPM_PRE_PMD: 526 case SND_SOC_DAPM_PRE_PMD:
528 snd_soc_update_bits(codec, RT5616_PR_BASE + 527 snd_soc_update_bits(codec, RT5616_PR_BASE +
529 RT5616_CHOP_DAC_ADC, 0x0200, 0x0); 528 RT5616_CHOP_DAC_ADC, 0x0200, 0x0);
530 snd_soc_update_bits(codec, RT5616_DEPOP_M1, 529 snd_soc_update_bits(codec, RT5616_DEPOP_M1,
531 RT5616_HP_SG_MASK | RT5616_HP_L_SMT_MASK | 530 RT5616_HP_SG_MASK | RT5616_HP_L_SMT_MASK |
532 RT5616_HP_R_SMT_MASK, RT5616_HP_SG_DIS | 531 RT5616_HP_R_SMT_MASK, RT5616_HP_SG_DIS |
533 RT5616_HP_L_SMT_DIS | RT5616_HP_R_SMT_DIS); 532 RT5616_HP_L_SMT_DIS | RT5616_HP_R_SMT_DIS);
534 /* headphone amp power down */ 533 /* headphone amp power down */
535 snd_soc_update_bits(codec, RT5616_DEPOP_M1, 534 snd_soc_update_bits(codec, RT5616_DEPOP_M1,
536 RT5616_SMT_TRIG_MASK | RT5616_HP_CD_PD_MASK | 535 RT5616_SMT_TRIG_MASK |
537 RT5616_HP_CO_MASK | RT5616_HP_CP_MASK | 536 RT5616_HP_CD_PD_MASK | RT5616_HP_CO_MASK |
538 RT5616_HP_SG_MASK | RT5616_HP_CB_MASK, 537 RT5616_HP_CP_MASK | RT5616_HP_SG_MASK |
539 RT5616_SMT_TRIG_DIS | RT5616_HP_CD_PD_EN | 538 RT5616_HP_CB_MASK,
540 RT5616_HP_CO_DIS | RT5616_HP_CP_PD | 539 RT5616_SMT_TRIG_DIS | RT5616_HP_CD_PD_EN |
541 RT5616_HP_SG_EN | RT5616_HP_CB_PD); 540 RT5616_HP_CO_DIS | RT5616_HP_CP_PD |
541 RT5616_HP_SG_EN | RT5616_HP_CB_PD);
542 snd_soc_update_bits(codec, RT5616_PWR_ANLG1, 542 snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
543 RT5616_PWR_HP_L | RT5616_PWR_HP_R | 543 RT5616_PWR_HP_L | RT5616_PWR_HP_R |
544 RT5616_PWR_HA, 0); 544 RT5616_PWR_HA, 0);
545 break; 545 break;
546 default: 546 default:
547 return 0; 547 return 0;
@@ -551,7 +551,7 @@ static int rt5616_charge_pump_event(struct snd_soc_dapm_widget *w,
551} 551}
552 552
553static int rt5616_hp_event(struct snd_soc_dapm_widget *w, 553static int rt5616_hp_event(struct snd_soc_dapm_widget *w,
554 struct snd_kcontrol *kcontrol, int event) 554 struct snd_kcontrol *kcontrol, int event)
555{ 555{
556 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 556 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
557 557
@@ -559,57 +559,57 @@ static int rt5616_hp_event(struct snd_soc_dapm_widget *w,
559 case SND_SOC_DAPM_POST_PMU: 559 case SND_SOC_DAPM_POST_PMU:
560 /* headphone unmute sequence */ 560 /* headphone unmute sequence */
561 snd_soc_update_bits(codec, RT5616_DEPOP_M3, 561 snd_soc_update_bits(codec, RT5616_DEPOP_M3,
562 RT5616_CP_FQ1_MASK | RT5616_CP_FQ2_MASK | 562 RT5616_CP_FQ1_MASK | RT5616_CP_FQ2_MASK |
563 RT5616_CP_FQ3_MASK, 563 RT5616_CP_FQ3_MASK,
564 (RT5616_CP_FQ_192_KHZ << RT5616_CP_FQ1_SFT) | 564 RT5616_CP_FQ_192_KHZ << RT5616_CP_FQ1_SFT |
565 (RT5616_CP_FQ_12_KHZ << RT5616_CP_FQ2_SFT) | 565 RT5616_CP_FQ_12_KHZ << RT5616_CP_FQ2_SFT |
566 (RT5616_CP_FQ_192_KHZ << RT5616_CP_FQ3_SFT)); 566 RT5616_CP_FQ_192_KHZ << RT5616_CP_FQ3_SFT);
567 snd_soc_write(codec, RT5616_PR_BASE + 567 snd_soc_write(codec, RT5616_PR_BASE +
568 RT5616_MAMP_INT_REG2, 0xfc00); 568 RT5616_MAMP_INT_REG2, 0xfc00);
569 snd_soc_update_bits(codec, RT5616_DEPOP_M1, 569 snd_soc_update_bits(codec, RT5616_DEPOP_M1,
570 RT5616_SMT_TRIG_MASK, RT5616_SMT_TRIG_EN); 570 RT5616_SMT_TRIG_MASK, RT5616_SMT_TRIG_EN);
571 snd_soc_update_bits(codec, RT5616_DEPOP_M1, 571 snd_soc_update_bits(codec, RT5616_DEPOP_M1,
572 RT5616_RSTN_MASK, RT5616_RSTN_EN); 572 RT5616_RSTN_MASK, RT5616_RSTN_EN);
573 snd_soc_update_bits(codec, RT5616_DEPOP_M1, 573 snd_soc_update_bits(codec, RT5616_DEPOP_M1,
574 RT5616_RSTN_MASK | RT5616_HP_L_SMT_MASK | 574 RT5616_RSTN_MASK | RT5616_HP_L_SMT_MASK |
575 RT5616_HP_R_SMT_MASK, RT5616_RSTN_DIS | 575 RT5616_HP_R_SMT_MASK, RT5616_RSTN_DIS |
576 RT5616_HP_L_SMT_EN | RT5616_HP_R_SMT_EN); 576 RT5616_HP_L_SMT_EN | RT5616_HP_R_SMT_EN);
577 snd_soc_update_bits(codec, RT5616_HP_VOL, 577 snd_soc_update_bits(codec, RT5616_HP_VOL,
578 RT5616_L_MUTE | RT5616_R_MUTE, 0); 578 RT5616_L_MUTE | RT5616_R_MUTE, 0);
579 msleep(100); 579 msleep(100);
580 snd_soc_update_bits(codec, RT5616_DEPOP_M1, 580 snd_soc_update_bits(codec, RT5616_DEPOP_M1,
581 RT5616_HP_SG_MASK | RT5616_HP_L_SMT_MASK | 581 RT5616_HP_SG_MASK | RT5616_HP_L_SMT_MASK |
582 RT5616_HP_R_SMT_MASK, RT5616_HP_SG_DIS | 582 RT5616_HP_R_SMT_MASK, RT5616_HP_SG_DIS |
583 RT5616_HP_L_SMT_DIS | RT5616_HP_R_SMT_DIS); 583 RT5616_HP_L_SMT_DIS | RT5616_HP_R_SMT_DIS);
584 msleep(20); 584 msleep(20);
585 snd_soc_update_bits(codec, RT5616_HP_CALIB_AMP_DET, 585 snd_soc_update_bits(codec, RT5616_HP_CALIB_AMP_DET,
586 RT5616_HPD_PS_MASK, RT5616_HPD_PS_EN); 586 RT5616_HPD_PS_MASK, RT5616_HPD_PS_EN);
587 break; 587 break;
588 588
589 case SND_SOC_DAPM_PRE_PMD: 589 case SND_SOC_DAPM_PRE_PMD:
590 /* headphone mute sequence */ 590 /* headphone mute sequence */
591 snd_soc_update_bits(codec, RT5616_DEPOP_M3, 591 snd_soc_update_bits(codec, RT5616_DEPOP_M3,
592 RT5616_CP_FQ1_MASK | RT5616_CP_FQ2_MASK | 592 RT5616_CP_FQ1_MASK | RT5616_CP_FQ2_MASK |
593 RT5616_CP_FQ3_MASK, 593 RT5616_CP_FQ3_MASK,
594 (RT5616_CP_FQ_96_KHZ << RT5616_CP_FQ1_SFT) | 594 RT5616_CP_FQ_96_KHZ << RT5616_CP_FQ1_SFT |
595 (RT5616_CP_FQ_12_KHZ << RT5616_CP_FQ2_SFT) | 595 RT5616_CP_FQ_12_KHZ << RT5616_CP_FQ2_SFT |
596 (RT5616_CP_FQ_96_KHZ << RT5616_CP_FQ3_SFT)); 596 RT5616_CP_FQ_96_KHZ << RT5616_CP_FQ3_SFT);
597 snd_soc_write(codec, RT5616_PR_BASE + 597 snd_soc_write(codec, RT5616_PR_BASE +
598 RT5616_MAMP_INT_REG2, 0xfc00); 598 RT5616_MAMP_INT_REG2, 0xfc00);
599 snd_soc_update_bits(codec, RT5616_DEPOP_M1, 599 snd_soc_update_bits(codec, RT5616_DEPOP_M1,
600 RT5616_HP_SG_MASK, RT5616_HP_SG_EN); 600 RT5616_HP_SG_MASK, RT5616_HP_SG_EN);
601 snd_soc_update_bits(codec, RT5616_DEPOP_M1, 601 snd_soc_update_bits(codec, RT5616_DEPOP_M1,
602 RT5616_RSTP_MASK, RT5616_RSTP_EN); 602 RT5616_RSTP_MASK, RT5616_RSTP_EN);
603 snd_soc_update_bits(codec, RT5616_DEPOP_M1, 603 snd_soc_update_bits(codec, RT5616_DEPOP_M1,
604 RT5616_RSTP_MASK | RT5616_HP_L_SMT_MASK | 604 RT5616_RSTP_MASK | RT5616_HP_L_SMT_MASK |
605 RT5616_HP_R_SMT_MASK, RT5616_RSTP_DIS | 605 RT5616_HP_R_SMT_MASK, RT5616_RSTP_DIS |
606 RT5616_HP_L_SMT_EN | RT5616_HP_R_SMT_EN); 606 RT5616_HP_L_SMT_EN | RT5616_HP_R_SMT_EN);
607 snd_soc_update_bits(codec, RT5616_HP_CALIB_AMP_DET, 607 snd_soc_update_bits(codec, RT5616_HP_CALIB_AMP_DET,
608 RT5616_HPD_PS_MASK, RT5616_HPD_PS_DIS); 608 RT5616_HPD_PS_MASK, RT5616_HPD_PS_DIS);
609 msleep(90); 609 msleep(90);
610 snd_soc_update_bits(codec, RT5616_HP_VOL, 610 snd_soc_update_bits(codec, RT5616_HP_VOL,
611 RT5616_L_MUTE | RT5616_R_MUTE, 611 RT5616_L_MUTE | RT5616_R_MUTE,
612 RT5616_L_MUTE | RT5616_R_MUTE); 612 RT5616_L_MUTE | RT5616_R_MUTE);
613 msleep(30); 613 msleep(30);
614 break; 614 break;
615 615
@@ -621,24 +621,24 @@ static int rt5616_hp_event(struct snd_soc_dapm_widget *w,
621} 621}
622 622
623static int rt5616_lout_event(struct snd_soc_dapm_widget *w, 623static int rt5616_lout_event(struct snd_soc_dapm_widget *w,
624 struct snd_kcontrol *kcontrol, int event) 624 struct snd_kcontrol *kcontrol, int event)
625{ 625{
626 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 626 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
627 627
628 switch (event) { 628 switch (event) {
629 case SND_SOC_DAPM_POST_PMU: 629 case SND_SOC_DAPM_POST_PMU:
630 snd_soc_update_bits(codec, RT5616_PWR_ANLG1, 630 snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
631 RT5616_PWR_LM, RT5616_PWR_LM); 631 RT5616_PWR_LM, RT5616_PWR_LM);
632 snd_soc_update_bits(codec, RT5616_LOUT_CTRL1, 632 snd_soc_update_bits(codec, RT5616_LOUT_CTRL1,
633 RT5616_L_MUTE | RT5616_R_MUTE, 0); 633 RT5616_L_MUTE | RT5616_R_MUTE, 0);
634 break; 634 break;
635 635
636 case SND_SOC_DAPM_PRE_PMD: 636 case SND_SOC_DAPM_PRE_PMD:
637 snd_soc_update_bits(codec, RT5616_LOUT_CTRL1, 637 snd_soc_update_bits(codec, RT5616_LOUT_CTRL1,
638 RT5616_L_MUTE | RT5616_R_MUTE, 638 RT5616_L_MUTE | RT5616_R_MUTE,
639 RT5616_L_MUTE | RT5616_R_MUTE); 639 RT5616_L_MUTE | RT5616_R_MUTE);
640 snd_soc_update_bits(codec, RT5616_PWR_ANLG1, 640 snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
641 RT5616_PWR_LM, 0); 641 RT5616_PWR_LM, 0);
642 break; 642 break;
643 643
644 default: 644 default:
@@ -649,19 +649,19 @@ static int rt5616_lout_event(struct snd_soc_dapm_widget *w,
649} 649}
650 650
651static int rt5616_bst1_event(struct snd_soc_dapm_widget *w, 651static int rt5616_bst1_event(struct snd_soc_dapm_widget *w,
652 struct snd_kcontrol *kcontrol, int event) 652 struct snd_kcontrol *kcontrol, int event)
653{ 653{
654 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 654 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
655 655
656 switch (event) { 656 switch (event) {
657 case SND_SOC_DAPM_POST_PMU: 657 case SND_SOC_DAPM_POST_PMU:
658 snd_soc_update_bits(codec, RT5616_PWR_ANLG2, 658 snd_soc_update_bits(codec, RT5616_PWR_ANLG2,
659 RT5616_PWR_BST1_OP2, RT5616_PWR_BST1_OP2); 659 RT5616_PWR_BST1_OP2, RT5616_PWR_BST1_OP2);
660 break; 660 break;
661 661
662 case SND_SOC_DAPM_PRE_PMD: 662 case SND_SOC_DAPM_PRE_PMD:
663 snd_soc_update_bits(codec, RT5616_PWR_ANLG2, 663 snd_soc_update_bits(codec, RT5616_PWR_ANLG2,
664 RT5616_PWR_BST1_OP2, 0); 664 RT5616_PWR_BST1_OP2, 0);
665 break; 665 break;
666 666
667 default: 667 default:
@@ -672,19 +672,19 @@ static int rt5616_bst1_event(struct snd_soc_dapm_widget *w,
672} 672}
673 673
674static int rt5616_bst2_event(struct snd_soc_dapm_widget *w, 674static int rt5616_bst2_event(struct snd_soc_dapm_widget *w,
675 struct snd_kcontrol *kcontrol, int event) 675 struct snd_kcontrol *kcontrol, int event)
676{ 676{
677 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 677 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
678 678
679 switch (event) { 679 switch (event) {
680 case SND_SOC_DAPM_POST_PMU: 680 case SND_SOC_DAPM_POST_PMU:
681 snd_soc_update_bits(codec, RT5616_PWR_ANLG2, 681 snd_soc_update_bits(codec, RT5616_PWR_ANLG2,
682 RT5616_PWR_BST2_OP2, RT5616_PWR_BST2_OP2); 682 RT5616_PWR_BST2_OP2, RT5616_PWR_BST2_OP2);
683 break; 683 break;
684 684
685 case SND_SOC_DAPM_PRE_PMD: 685 case SND_SOC_DAPM_PRE_PMD:
686 snd_soc_update_bits(codec, RT5616_PWR_ANLG2, 686 snd_soc_update_bits(codec, RT5616_PWR_ANLG2,
687 RT5616_PWR_BST2_OP2, 0); 687 RT5616_PWR_BST2_OP2, 0);
688 break; 688 break;
689 689
690 default: 690 default:
@@ -696,13 +696,13 @@ static int rt5616_bst2_event(struct snd_soc_dapm_widget *w,
696 696
697static const struct snd_soc_dapm_widget rt5616_dapm_widgets[] = { 697static const struct snd_soc_dapm_widget rt5616_dapm_widgets[] = {
698 SND_SOC_DAPM_SUPPLY("PLL1", RT5616_PWR_ANLG2, 698 SND_SOC_DAPM_SUPPLY("PLL1", RT5616_PWR_ANLG2,
699 RT5616_PWR_PLL_BIT, 0, NULL, 0), 699 RT5616_PWR_PLL_BIT, 0, NULL, 0),
700 /* Input Side */ 700 /* Input Side */
701 /* micbias */ 701 /* micbias */
702 SND_SOC_DAPM_SUPPLY("LDO", RT5616_PWR_ANLG1, 702 SND_SOC_DAPM_SUPPLY("LDO", RT5616_PWR_ANLG1,
703 RT5616_PWR_LDO_BIT, 0, NULL, 0), 703 RT5616_PWR_LDO_BIT, 0, NULL, 0),
704 SND_SOC_DAPM_SUPPLY("micbias1", RT5616_PWR_ANLG2, 704 SND_SOC_DAPM_SUPPLY("micbias1", RT5616_PWR_ANLG2,
705 RT5616_PWR_MB1_BIT, 0, NULL, 0), 705 RT5616_PWR_MB1_BIT, 0, NULL, 0),
706 706
707 /* Input Lines */ 707 /* Input Lines */
708 SND_SOC_DAPM_INPUT("MIC1"), 708 SND_SOC_DAPM_INPUT("MIC1"),
@@ -714,45 +714,47 @@ static const struct snd_soc_dapm_widget rt5616_dapm_widgets[] = {
714 714
715 /* Boost */ 715 /* Boost */
716 SND_SOC_DAPM_PGA_E("BST1", RT5616_PWR_ANLG2, 716 SND_SOC_DAPM_PGA_E("BST1", RT5616_PWR_ANLG2,
717 RT5616_PWR_BST1_BIT, 0, NULL, 0, rt5616_bst1_event, 717 RT5616_PWR_BST1_BIT, 0, NULL, 0, rt5616_bst1_event,
718 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 718 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
719 SND_SOC_DAPM_PGA_E("BST2", RT5616_PWR_ANLG2, 719 SND_SOC_DAPM_PGA_E("BST2", RT5616_PWR_ANLG2,
720 RT5616_PWR_BST2_BIT, 0, NULL, 0, rt5616_bst2_event, 720 RT5616_PWR_BST2_BIT, 0, NULL, 0, rt5616_bst2_event,
721 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 721 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
722 /* Input Volume */ 722 /* Input Volume */
723 SND_SOC_DAPM_PGA("INL1 VOL", RT5616_PWR_VOL, 723 SND_SOC_DAPM_PGA("INL1 VOL", RT5616_PWR_VOL,
724 RT5616_PWR_IN1_L_BIT, 0, NULL, 0), 724 RT5616_PWR_IN1_L_BIT, 0, NULL, 0),
725 SND_SOC_DAPM_PGA("INR1 VOL", RT5616_PWR_VOL, 725 SND_SOC_DAPM_PGA("INR1 VOL", RT5616_PWR_VOL,
726 RT5616_PWR_IN1_R_BIT, 0, NULL, 0), 726 RT5616_PWR_IN1_R_BIT, 0, NULL, 0),
727 SND_SOC_DAPM_PGA("INL2 VOL", RT5616_PWR_VOL, 727 SND_SOC_DAPM_PGA("INL2 VOL", RT5616_PWR_VOL,
728 RT5616_PWR_IN2_L_BIT, 0, NULL, 0), 728 RT5616_PWR_IN2_L_BIT, 0, NULL, 0),
729 SND_SOC_DAPM_PGA("INR2 VOL", RT5616_PWR_VOL, 729 SND_SOC_DAPM_PGA("INR2 VOL", RT5616_PWR_VOL,
730 RT5616_PWR_IN2_R_BIT, 0, NULL, 0), 730 RT5616_PWR_IN2_R_BIT, 0, NULL, 0),
731 731
732 /* REC Mixer */ 732 /* REC Mixer */
733 SND_SOC_DAPM_MIXER("RECMIXL", RT5616_PWR_MIXER, RT5616_PWR_RM_L_BIT, 0, 733 SND_SOC_DAPM_MIXER("RECMIXL", RT5616_PWR_MIXER, RT5616_PWR_RM_L_BIT, 0,
734 rt5616_rec_l_mix, ARRAY_SIZE(rt5616_rec_l_mix)), 734 rt5616_rec_l_mix, ARRAY_SIZE(rt5616_rec_l_mix)),
735 SND_SOC_DAPM_MIXER("RECMIXR", RT5616_PWR_MIXER, RT5616_PWR_RM_R_BIT, 0, 735 SND_SOC_DAPM_MIXER("RECMIXR", RT5616_PWR_MIXER, RT5616_PWR_RM_R_BIT, 0,
736 rt5616_rec_r_mix, ARRAY_SIZE(rt5616_rec_r_mix)), 736 rt5616_rec_r_mix, ARRAY_SIZE(rt5616_rec_r_mix)),
737 /* ADCs */ 737 /* ADCs */
738 SND_SOC_DAPM_ADC_E("ADC L", NULL, RT5616_PWR_DIG1, 738 SND_SOC_DAPM_ADC_E("ADC L", NULL, RT5616_PWR_DIG1,
739 RT5616_PWR_ADC_L_BIT, 0, rt5616_adc_event, 739 RT5616_PWR_ADC_L_BIT, 0, rt5616_adc_event,
740 SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU), 740 SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU),
741 SND_SOC_DAPM_ADC_E("ADC R", NULL, RT5616_PWR_DIG1, 741 SND_SOC_DAPM_ADC_E("ADC R", NULL, RT5616_PWR_DIG1,
742 RT5616_PWR_ADC_R_BIT, 0, rt5616_adc_event, 742 RT5616_PWR_ADC_R_BIT, 0, rt5616_adc_event,
743 SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU), 743 SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU),
744 744
745 /* ADC Mixer */ 745 /* ADC Mixer */
746 SND_SOC_DAPM_SUPPLY("stereo1 filter", RT5616_PWR_DIG2, 746 SND_SOC_DAPM_SUPPLY("stereo1 filter", RT5616_PWR_DIG2,
747 RT5616_PWR_ADC_STO1_F_BIT, 0, NULL, 0), 747 RT5616_PWR_ADC_STO1_F_BIT, 0, NULL, 0),
748 SND_SOC_DAPM_MIXER("Stereo1 ADC MIXL", SND_SOC_NOPM, 0, 0, 748 SND_SOC_DAPM_MIXER("Stereo1 ADC MIXL", SND_SOC_NOPM, 0, 0,
749 rt5616_sto1_adc_l_mix, ARRAY_SIZE(rt5616_sto1_adc_l_mix)), 749 rt5616_sto1_adc_l_mix,
750 ARRAY_SIZE(rt5616_sto1_adc_l_mix)),
750 SND_SOC_DAPM_MIXER("Stereo1 ADC MIXR", SND_SOC_NOPM, 0, 0, 751 SND_SOC_DAPM_MIXER("Stereo1 ADC MIXR", SND_SOC_NOPM, 0, 0,
751 rt5616_sto1_adc_r_mix, ARRAY_SIZE(rt5616_sto1_adc_r_mix)), 752 rt5616_sto1_adc_r_mix,
753 ARRAY_SIZE(rt5616_sto1_adc_r_mix)),
752 754
753 /* Digital Interface */ 755 /* Digital Interface */
754 SND_SOC_DAPM_SUPPLY("I2S1", RT5616_PWR_DIG1, 756 SND_SOC_DAPM_SUPPLY("I2S1", RT5616_PWR_DIG1,
755 RT5616_PWR_I2S1_BIT, 0, NULL, 0), 757 RT5616_PWR_I2S1_BIT, 0, NULL, 0),
756 SND_SOC_DAPM_PGA("IF1 DAC", SND_SOC_NOPM, 0, 0, NULL, 0), 758 SND_SOC_DAPM_PGA("IF1 DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
757 SND_SOC_DAPM_PGA("IF1 DAC1 L", SND_SOC_NOPM, 0, 0, NULL, 0), 759 SND_SOC_DAPM_PGA("IF1 DAC1 L", SND_SOC_NOPM, 0, 0, NULL, 0),
758 SND_SOC_DAPM_PGA("IF1 DAC1 R", SND_SOC_NOPM, 0, 0, NULL, 0), 760 SND_SOC_DAPM_PGA("IF1 DAC1 R", SND_SOC_NOPM, 0, 0, NULL, 0),
@@ -770,68 +772,70 @@ static const struct snd_soc_dapm_widget rt5616_dapm_widgets[] = {
770 /* Output Side */ 772 /* Output Side */
771 /* DAC mixer before sound effect */ 773 /* DAC mixer before sound effect */
772 SND_SOC_DAPM_MIXER("DAC MIXL", SND_SOC_NOPM, 0, 0, 774 SND_SOC_DAPM_MIXER("DAC MIXL", SND_SOC_NOPM, 0, 0,
773 rt5616_dac_l_mix, ARRAY_SIZE(rt5616_dac_l_mix)), 775 rt5616_dac_l_mix, ARRAY_SIZE(rt5616_dac_l_mix)),
774 SND_SOC_DAPM_MIXER("DAC MIXR", SND_SOC_NOPM, 0, 0, 776 SND_SOC_DAPM_MIXER("DAC MIXR", SND_SOC_NOPM, 0, 0,
775 rt5616_dac_r_mix, ARRAY_SIZE(rt5616_dac_r_mix)), 777 rt5616_dac_r_mix, ARRAY_SIZE(rt5616_dac_r_mix)),
776 778
777 SND_SOC_DAPM_SUPPLY("Stero1 DAC Power", RT5616_PWR_DIG2, 779 SND_SOC_DAPM_SUPPLY("Stero1 DAC Power", RT5616_PWR_DIG2,
778 RT5616_PWR_DAC_STO1_F_BIT, 0, NULL, 0), 780 RT5616_PWR_DAC_STO1_F_BIT, 0, NULL, 0),
779 781
780 /* DAC Mixer */ 782 /* DAC Mixer */
781 SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0, 783 SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0,
782 rt5616_sto_dac_l_mix, ARRAY_SIZE(rt5616_sto_dac_l_mix)), 784 rt5616_sto_dac_l_mix,
785 ARRAY_SIZE(rt5616_sto_dac_l_mix)),
783 SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0, 786 SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0,
784 rt5616_sto_dac_r_mix, ARRAY_SIZE(rt5616_sto_dac_r_mix)), 787 rt5616_sto_dac_r_mix,
788 ARRAY_SIZE(rt5616_sto_dac_r_mix)),
785 789
786 /* DACs */ 790 /* DACs */
787 SND_SOC_DAPM_DAC("DAC L1", NULL, RT5616_PWR_DIG1, 791 SND_SOC_DAPM_DAC("DAC L1", NULL, RT5616_PWR_DIG1,
788 RT5616_PWR_DAC_L1_BIT, 0), 792 RT5616_PWR_DAC_L1_BIT, 0),
789 SND_SOC_DAPM_DAC("DAC R1", NULL, RT5616_PWR_DIG1, 793 SND_SOC_DAPM_DAC("DAC R1", NULL, RT5616_PWR_DIG1,
790 RT5616_PWR_DAC_R1_BIT, 0), 794 RT5616_PWR_DAC_R1_BIT, 0),
791 /* OUT Mixer */ 795 /* OUT Mixer */
792 SND_SOC_DAPM_MIXER("OUT MIXL", RT5616_PWR_MIXER, RT5616_PWR_OM_L_BIT, 796 SND_SOC_DAPM_MIXER("OUT MIXL", RT5616_PWR_MIXER, RT5616_PWR_OM_L_BIT,
793 0, rt5616_out_l_mix, ARRAY_SIZE(rt5616_out_l_mix)), 797 0, rt5616_out_l_mix, ARRAY_SIZE(rt5616_out_l_mix)),
794 SND_SOC_DAPM_MIXER("OUT MIXR", RT5616_PWR_MIXER, RT5616_PWR_OM_R_BIT, 798 SND_SOC_DAPM_MIXER("OUT MIXR", RT5616_PWR_MIXER, RT5616_PWR_OM_R_BIT,
795 0, rt5616_out_r_mix, ARRAY_SIZE(rt5616_out_r_mix)), 799 0, rt5616_out_r_mix, ARRAY_SIZE(rt5616_out_r_mix)),
796 /* Output Volume */ 800 /* Output Volume */
797 SND_SOC_DAPM_PGA("OUTVOL L", RT5616_PWR_VOL, 801 SND_SOC_DAPM_PGA("OUTVOL L", RT5616_PWR_VOL,
798 RT5616_PWR_OV_L_BIT, 0, NULL, 0), 802 RT5616_PWR_OV_L_BIT, 0, NULL, 0),
799 SND_SOC_DAPM_PGA("OUTVOL R", RT5616_PWR_VOL, 803 SND_SOC_DAPM_PGA("OUTVOL R", RT5616_PWR_VOL,
800 RT5616_PWR_OV_R_BIT, 0, NULL, 0), 804 RT5616_PWR_OV_R_BIT, 0, NULL, 0),
801 SND_SOC_DAPM_PGA("HPOVOL L", RT5616_PWR_VOL, 805 SND_SOC_DAPM_PGA("HPOVOL L", RT5616_PWR_VOL,
802 RT5616_PWR_HV_L_BIT, 0, NULL, 0), 806 RT5616_PWR_HV_L_BIT, 0, NULL, 0),
803 SND_SOC_DAPM_PGA("HPOVOL R", RT5616_PWR_VOL, 807 SND_SOC_DAPM_PGA("HPOVOL R", RT5616_PWR_VOL,
804 RT5616_PWR_HV_R_BIT, 0, NULL, 0), 808 RT5616_PWR_HV_R_BIT, 0, NULL, 0),
805 SND_SOC_DAPM_PGA("DAC 1", SND_SOC_NOPM, 809 SND_SOC_DAPM_PGA("DAC 1", SND_SOC_NOPM,
806 0, 0, NULL, 0), 810 0, 0, NULL, 0),
807 SND_SOC_DAPM_PGA("DAC 2", SND_SOC_NOPM, 811 SND_SOC_DAPM_PGA("DAC 2", SND_SOC_NOPM,
808 0, 0, NULL, 0), 812 0, 0, NULL, 0),
809 SND_SOC_DAPM_PGA("HPOVOL", SND_SOC_NOPM, 813 SND_SOC_DAPM_PGA("HPOVOL", SND_SOC_NOPM,
810 0, 0, NULL, 0), 814 0, 0, NULL, 0),
811 SND_SOC_DAPM_PGA("INL1", RT5616_PWR_VOL, 815 SND_SOC_DAPM_PGA("INL1", RT5616_PWR_VOL,
812 RT5616_PWR_IN1_L_BIT, 0, NULL, 0), 816 RT5616_PWR_IN1_L_BIT, 0, NULL, 0),
813 SND_SOC_DAPM_PGA("INR1", RT5616_PWR_VOL, 817 SND_SOC_DAPM_PGA("INR1", RT5616_PWR_VOL,
814 RT5616_PWR_IN1_R_BIT, 0, NULL, 0), 818 RT5616_PWR_IN1_R_BIT, 0, NULL, 0),
815 SND_SOC_DAPM_PGA("INL2", RT5616_PWR_VOL, 819 SND_SOC_DAPM_PGA("INL2", RT5616_PWR_VOL,
816 RT5616_PWR_IN2_L_BIT, 0, NULL, 0), 820 RT5616_PWR_IN2_L_BIT, 0, NULL, 0),
817 SND_SOC_DAPM_PGA("INR2", RT5616_PWR_VOL, 821 SND_SOC_DAPM_PGA("INR2", RT5616_PWR_VOL,
818 RT5616_PWR_IN2_R_BIT, 0, NULL, 0), 822 RT5616_PWR_IN2_R_BIT, 0, NULL, 0),
819 /* HPO/LOUT/Mono Mixer */ 823 /* HPO/LOUT/Mono Mixer */
820 SND_SOC_DAPM_MIXER("HPO MIX", SND_SOC_NOPM, 0, 0, 824 SND_SOC_DAPM_MIXER("HPO MIX", SND_SOC_NOPM, 0, 0,
821 rt5616_hpo_mix, ARRAY_SIZE(rt5616_hpo_mix)), 825 rt5616_hpo_mix, ARRAY_SIZE(rt5616_hpo_mix)),
822 SND_SOC_DAPM_MIXER("LOUT MIX", SND_SOC_NOPM, 0, 0, 826 SND_SOC_DAPM_MIXER("LOUT MIX", SND_SOC_NOPM, 0, 0,
823 rt5616_lout_mix, ARRAY_SIZE(rt5616_lout_mix)), 827 rt5616_lout_mix, ARRAY_SIZE(rt5616_lout_mix)),
824 828
825 SND_SOC_DAPM_PGA_S("HP amp", 1, SND_SOC_NOPM, 0, 0, 829 SND_SOC_DAPM_PGA_S("HP amp", 1, SND_SOC_NOPM, 0, 0,
826 rt5616_hp_event, SND_SOC_DAPM_PRE_PMD | 830 rt5616_hp_event, SND_SOC_DAPM_PRE_PMD |
827 SND_SOC_DAPM_POST_PMU), 831 SND_SOC_DAPM_POST_PMU),
828 SND_SOC_DAPM_PGA_S("LOUT amp", 1, SND_SOC_NOPM, 0, 0, 832 SND_SOC_DAPM_PGA_S("LOUT amp", 1, SND_SOC_NOPM, 0, 0,
829 rt5616_lout_event, SND_SOC_DAPM_PRE_PMD | 833 rt5616_lout_event, SND_SOC_DAPM_PRE_PMD |
830 SND_SOC_DAPM_POST_PMU), 834 SND_SOC_DAPM_POST_PMU),
831 835
832 SND_SOC_DAPM_SUPPLY_S("Charge Pump", 1, SND_SOC_NOPM, 0, 0, 836 SND_SOC_DAPM_SUPPLY_S("Charge Pump", 1, SND_SOC_NOPM, 0, 0,
833 rt5616_charge_pump_event, SND_SOC_DAPM_POST_PMU | 837 rt5616_charge_pump_event, SND_SOC_DAPM_POST_PMU |
834 SND_SOC_DAPM_PRE_PMD), 838 SND_SOC_DAPM_PRE_PMD),
835 839
836 /* Output Lines */ 840 /* Output Lines */
837 SND_SOC_DAPM_OUTPUT("HPOL"), 841 SND_SOC_DAPM_OUTPUT("HPOL"),
@@ -950,7 +954,8 @@ static const struct snd_soc_dapm_route rt5616_dapm_routes[] = {
950}; 954};
951 955
952static int rt5616_hw_params(struct snd_pcm_substream *substream, 956static int rt5616_hw_params(struct snd_pcm_substream *substream,
953 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) 957 struct snd_pcm_hw_params *params,
958 struct snd_soc_dai *dai)
954{ 959{
955 struct snd_soc_pcm_runtime *rtd = substream->private_data; 960 struct snd_soc_pcm_runtime *rtd = substream->private_data;
956 struct snd_soc_codec *codec = rtd->codec; 961 struct snd_soc_codec *codec = rtd->codec;
@@ -977,7 +982,7 @@ static int rt5616_hw_params(struct snd_pcm_substream *substream,
977 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", 982 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n",
978 rt5616->bclk[dai->id], rt5616->lrck[dai->id]); 983 rt5616->bclk[dai->id], rt5616->lrck[dai->id]);
979 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", 984 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n",
980 bclk_ms, pre_div, dai->id); 985 bclk_ms, pre_div, dai->id);
981 986
982 switch (params_format(params)) { 987 switch (params_format(params)) {
983 case SNDRV_PCM_FORMAT_S16_LE: 988 case SNDRV_PCM_FORMAT_S16_LE:
@@ -998,10 +1003,9 @@ static int rt5616_hw_params(struct snd_pcm_substream *substream,
998 mask_clk = RT5616_I2S_PD1_MASK; 1003 mask_clk = RT5616_I2S_PD1_MASK;
999 val_clk = pre_div << RT5616_I2S_PD1_SFT; 1004 val_clk = pre_div << RT5616_I2S_PD1_SFT;
1000 snd_soc_update_bits(codec, RT5616_I2S1_SDP, 1005 snd_soc_update_bits(codec, RT5616_I2S1_SDP,
1001 RT5616_I2S_DL_MASK, val_len); 1006 RT5616_I2S_DL_MASK, val_len);
1002 snd_soc_update_bits(codec, RT5616_ADDA_CLK1, mask_clk, val_clk); 1007 snd_soc_update_bits(codec, RT5616_ADDA_CLK1, mask_clk, val_clk);
1003 1008
1004
1005 return 0; 1009 return 0;
1006} 1010}
1007 1011
@@ -1050,15 +1054,14 @@ static int rt5616_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
1050 } 1054 }
1051 1055
1052 snd_soc_update_bits(codec, RT5616_I2S1_SDP, 1056 snd_soc_update_bits(codec, RT5616_I2S1_SDP,
1053 RT5616_I2S_MS_MASK | RT5616_I2S_BP_MASK | 1057 RT5616_I2S_MS_MASK | RT5616_I2S_BP_MASK |
1054 RT5616_I2S_DF_MASK, reg_val); 1058 RT5616_I2S_DF_MASK, reg_val);
1055
1056 1059
1057 return 0; 1060 return 0;
1058} 1061}
1059 1062
1060static int rt5616_set_dai_sysclk(struct snd_soc_dai *dai, 1063static int rt5616_set_dai_sysclk(struct snd_soc_dai *dai,
1061 int clk_id, unsigned int freq, int dir) 1064 int clk_id, unsigned int freq, int dir)
1062{ 1065{
1063 struct snd_soc_codec *codec = dai->codec; 1066 struct snd_soc_codec *codec = dai->codec;
1064 struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec); 1067 struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec);
@@ -1078,8 +1081,9 @@ static int rt5616_set_dai_sysclk(struct snd_soc_dai *dai,
1078 dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); 1081 dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id);
1079 return -EINVAL; 1082 return -EINVAL;
1080 } 1083 }
1084
1081 snd_soc_update_bits(codec, RT5616_GLB_CLK, 1085 snd_soc_update_bits(codec, RT5616_GLB_CLK,
1082 RT5616_SCLK_SRC_MASK, reg_val); 1086 RT5616_SCLK_SRC_MASK, reg_val);
1083 rt5616->sysclk = freq; 1087 rt5616->sysclk = freq;
1084 rt5616->sysclk_src = clk_id; 1088 rt5616->sysclk_src = clk_id;
1085 1089
@@ -1089,7 +1093,7 @@ static int rt5616_set_dai_sysclk(struct snd_soc_dai *dai,
1089} 1093}
1090 1094
1091static int rt5616_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, 1095static int rt5616_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
1092 unsigned int freq_in, unsigned int freq_out) 1096 unsigned int freq_in, unsigned int freq_out)
1093{ 1097{
1094 struct snd_soc_codec *codec = dai->codec; 1098 struct snd_soc_codec *codec = dai->codec;
1095 struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec); 1099 struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec);
@@ -1106,19 +1110,22 @@ static int rt5616_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
1106 rt5616->pll_in = 0; 1110 rt5616->pll_in = 0;
1107 rt5616->pll_out = 0; 1111 rt5616->pll_out = 0;
1108 snd_soc_update_bits(codec, RT5616_GLB_CLK, 1112 snd_soc_update_bits(codec, RT5616_GLB_CLK,
1109 RT5616_SCLK_SRC_MASK, RT5616_SCLK_SRC_MCLK); 1113 RT5616_SCLK_SRC_MASK,
1114 RT5616_SCLK_SRC_MCLK);
1110 return 0; 1115 return 0;
1111 } 1116 }
1112 1117
1113 switch (source) { 1118 switch (source) {
1114 case RT5616_PLL1_S_MCLK: 1119 case RT5616_PLL1_S_MCLK:
1115 snd_soc_update_bits(codec, RT5616_GLB_CLK, 1120 snd_soc_update_bits(codec, RT5616_GLB_CLK,
1116 RT5616_PLL1_SRC_MASK, RT5616_PLL1_SRC_MCLK); 1121 RT5616_PLL1_SRC_MASK,
1122 RT5616_PLL1_SRC_MCLK);
1117 break; 1123 break;
1118 case RT5616_PLL1_S_BCLK1: 1124 case RT5616_PLL1_S_BCLK1:
1119 case RT5616_PLL1_S_BCLK2: 1125 case RT5616_PLL1_S_BCLK2:
1120 snd_soc_update_bits(codec, RT5616_GLB_CLK, 1126 snd_soc_update_bits(codec, RT5616_GLB_CLK,
1121 RT5616_PLL1_SRC_MASK, RT5616_PLL1_SRC_BCLK1); 1127 RT5616_PLL1_SRC_MASK,
1128 RT5616_PLL1_SRC_BCLK1);
1122 break; 1129 break;
1123 default: 1130 default:
1124 dev_err(codec->dev, "Unknown PLL source %d\n", source); 1131 dev_err(codec->dev, "Unknown PLL source %d\n", source);
@@ -1136,10 +1143,11 @@ static int rt5616_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
1136 pll_code.n_code, pll_code.k_code); 1143 pll_code.n_code, pll_code.k_code);
1137 1144
1138 snd_soc_write(codec, RT5616_PLL_CTRL1, 1145 snd_soc_write(codec, RT5616_PLL_CTRL1,
1139 pll_code.n_code << RT5616_PLL_N_SFT | pll_code.k_code); 1146 pll_code.n_code << RT5616_PLL_N_SFT | pll_code.k_code);
1140 snd_soc_write(codec, RT5616_PLL_CTRL2, 1147 snd_soc_write(codec, RT5616_PLL_CTRL2,
1141 (pll_code.m_bp ? 0 : pll_code.m_code) << RT5616_PLL_M_SFT | 1148 (pll_code.m_bp ? 0 : pll_code.m_code) <<
1142 pll_code.m_bp << RT5616_PLL_M_BP_SFT); 1149 RT5616_PLL_M_SFT |
1150 pll_code.m_bp << RT5616_PLL_M_BP_SFT);
1143 1151
1144 rt5616->pll_in = freq_in; 1152 rt5616->pll_in = freq_in;
1145 rt5616->pll_out = freq_out; 1153 rt5616->pll_out = freq_out;
@@ -1149,22 +1157,23 @@ static int rt5616_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
1149} 1157}
1150 1158
1151static int rt5616_set_bias_level(struct snd_soc_codec *codec, 1159static int rt5616_set_bias_level(struct snd_soc_codec *codec,
1152 enum snd_soc_bias_level level) 1160 enum snd_soc_bias_level level)
1153{ 1161{
1154 switch (level) { 1162 switch (level) {
1155 case SND_SOC_BIAS_STANDBY: 1163 case SND_SOC_BIAS_STANDBY:
1156 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { 1164 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
1157 snd_soc_update_bits(codec, RT5616_PWR_ANLG1, 1165 snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
1158 RT5616_PWR_VREF1 | RT5616_PWR_MB | 1166 RT5616_PWR_VREF1 | RT5616_PWR_MB |
1159 RT5616_PWR_BG | RT5616_PWR_VREF2, 1167 RT5616_PWR_BG | RT5616_PWR_VREF2,
1160 RT5616_PWR_VREF1 | RT5616_PWR_MB | 1168 RT5616_PWR_VREF1 | RT5616_PWR_MB |
1161 RT5616_PWR_BG | RT5616_PWR_VREF2); 1169 RT5616_PWR_BG | RT5616_PWR_VREF2);
1162 mdelay(10); 1170 mdelay(10);
1163 snd_soc_update_bits(codec, RT5616_PWR_ANLG1, 1171 snd_soc_update_bits(codec, RT5616_PWR_ANLG1,
1164 RT5616_PWR_FV1 | RT5616_PWR_FV2, 1172 RT5616_PWR_FV1 | RT5616_PWR_FV2,
1165 RT5616_PWR_FV1 | RT5616_PWR_FV2); 1173 RT5616_PWR_FV1 | RT5616_PWR_FV2);
1166 snd_soc_update_bits(codec, RT5616_D_MISC, 1174 snd_soc_update_bits(codec, RT5616_D_MISC,
1167 RT5616_D_GATE_EN, RT5616_D_GATE_EN); 1175 RT5616_D_GATE_EN,
1176 RT5616_D_GATE_EN);
1168 } 1177 }
1169 break; 1178 break;
1170 1179
@@ -1222,7 +1231,6 @@ static int rt5616_resume(struct snd_soc_codec *codec)
1222#define RT5616_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ 1231#define RT5616_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
1223 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) 1232 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
1224 1233
1225
1226struct snd_soc_dai_ops rt5616_aif_dai_ops = { 1234struct snd_soc_dai_ops rt5616_aif_dai_ops = {
1227 .hw_params = rt5616_hw_params, 1235 .hw_params = rt5616_hw_params,
1228 .set_fmt = rt5616_set_dai_fmt, 1236 .set_fmt = rt5616_set_dai_fmt,
@@ -1296,15 +1304,15 @@ MODULE_DEVICE_TABLE(of, rt5616_of_match);
1296#endif 1304#endif
1297 1305
1298static int rt5616_i2c_probe(struct i2c_client *i2c, 1306static int rt5616_i2c_probe(struct i2c_client *i2c,
1299 const struct i2c_device_id *id) 1307 const struct i2c_device_id *id)
1300{ 1308{
1301 struct rt5616_priv *rt5616; 1309 struct rt5616_priv *rt5616;
1302 unsigned int val; 1310 unsigned int val;
1303 int ret; 1311 int ret;
1304 1312
1305 rt5616 = devm_kzalloc(&i2c->dev, sizeof(struct rt5616_priv), 1313 rt5616 = devm_kzalloc(&i2c->dev, sizeof(struct rt5616_priv),
1306 GFP_KERNEL); 1314 GFP_KERNEL);
1307 if (rt5616 == NULL) 1315 if (!rt5616)
1308 return -ENOMEM; 1316 return -ENOMEM;
1309 1317
1310 i2c_set_clientdata(i2c, rt5616); 1318 i2c_set_clientdata(i2c, rt5616);
@@ -1326,14 +1334,14 @@ static int rt5616_i2c_probe(struct i2c_client *i2c,
1326 } 1334 }
1327 regmap_write(rt5616->regmap, RT5616_RESET, 0); 1335 regmap_write(rt5616->regmap, RT5616_RESET, 0);
1328 regmap_update_bits(rt5616->regmap, RT5616_PWR_ANLG1, 1336 regmap_update_bits(rt5616->regmap, RT5616_PWR_ANLG1,
1329 RT5616_PWR_VREF1 | RT5616_PWR_MB | 1337 RT5616_PWR_VREF1 | RT5616_PWR_MB |
1330 RT5616_PWR_BG | RT5616_PWR_VREF2, 1338 RT5616_PWR_BG | RT5616_PWR_VREF2,
1331 RT5616_PWR_VREF1 | RT5616_PWR_MB | 1339 RT5616_PWR_VREF1 | RT5616_PWR_MB |
1332 RT5616_PWR_BG | RT5616_PWR_VREF2); 1340 RT5616_PWR_BG | RT5616_PWR_VREF2);
1333 mdelay(10); 1341 mdelay(10);
1334 regmap_update_bits(rt5616->regmap, RT5616_PWR_ANLG1, 1342 regmap_update_bits(rt5616->regmap, RT5616_PWR_ANLG1,
1335 RT5616_PWR_FV1 | RT5616_PWR_FV2, 1343 RT5616_PWR_FV1 | RT5616_PWR_FV2,
1336 RT5616_PWR_FV1 | RT5616_PWR_FV2); 1344 RT5616_PWR_FV1 | RT5616_PWR_FV2);
1337 1345
1338 ret = regmap_register_patch(rt5616->regmap, init_list, 1346 ret = regmap_register_patch(rt5616->regmap, init_list,
1339 ARRAY_SIZE(init_list)); 1347 ARRAY_SIZE(init_list));
@@ -1341,11 +1349,10 @@ static int rt5616_i2c_probe(struct i2c_client *i2c,
1341 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); 1349 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret);
1342 1350
1343 regmap_update_bits(rt5616->regmap, RT5616_PWR_ANLG1, 1351 regmap_update_bits(rt5616->regmap, RT5616_PWR_ANLG1,
1344 RT5616_PWR_LDO_DVO_MASK, RT5616_PWR_LDO_DVO_1_2V); 1352 RT5616_PWR_LDO_DVO_MASK, RT5616_PWR_LDO_DVO_1_2V);
1345 1353
1346 return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5616, 1354 return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5616,
1347 rt5616_dai, ARRAY_SIZE(rt5616_dai)); 1355 rt5616_dai, ARRAY_SIZE(rt5616_dai));
1348
1349} 1356}
1350 1357
1351static int rt5616_i2c_remove(struct i2c_client *i2c) 1358static int rt5616_i2c_remove(struct i2c_client *i2c)
@@ -1361,7 +1368,6 @@ static void rt5616_i2c_shutdown(struct i2c_client *client)
1361 1368
1362 regmap_write(rt5616->regmap, RT5616_HP_VOL, 0xc8c8); 1369 regmap_write(rt5616->regmap, RT5616_HP_VOL, 0xc8c8);
1363 regmap_write(rt5616->regmap, RT5616_LOUT_CTRL1, 0xc8c8); 1370 regmap_write(rt5616->regmap, RT5616_LOUT_CTRL1, 0xc8c8);
1364
1365} 1371}
1366 1372
1367static struct i2c_driver rt5616_i2c_driver = { 1373static struct i2c_driver rt5616_i2c_driver = {