summaryrefslogtreecommitdiff
path: root/firmware/drivers/audio
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/audio')
-rw-r--r--firmware/drivers/audio/wm8751.c70
1 files changed, 55 insertions, 15 deletions
diff --git a/firmware/drivers/audio/wm8751.c b/firmware/drivers/audio/wm8751.c
index ba94cf4b54..4cb85db436 100644
--- a/firmware/drivers/audio/wm8751.c
+++ b/firmware/drivers/audio/wm8751.c
@@ -40,10 +40,15 @@ const struct sound_settings_info audiohw_settings[] = {
40 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, 40 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
41 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100}, 41 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
42#ifdef HAVE_RECORDING 42#ifdef HAVE_RECORDING
43 /* -17.25dB to 30.0dB in 0.75dB increments 64 steps*/ 43 /* PGA -17.25dB to 30.0dB in 0.75dB increments 64 steps
44 [SOUND_LEFT_GAIN] = {"dB", 2, 75, -1725, 3000, 0}, 44 * digital gain 0dB to 30.0dB in 0.5dB increments
45 [SOUND_RIGHT_GAIN] = {"dB", 2, 75, -1725, 3000, 0}, 45 * we use 0.75dB fake steps through whole range
46 [SOUND_MIC_GAIN] = {"dB", 2, 75, -1725, 3000, 3000}, 46 *
47 * This combined gives -17.25 to 60.0dB
48 */
49 [SOUND_LEFT_GAIN] = {"dB", 2, 75, -1725, 6000, 0},
50 [SOUND_RIGHT_GAIN] = {"dB", 2, 75, -1725, 6000, 0},
51 [SOUND_MIC_GAIN] = {"dB", 2, 75, -1725, 6000, 3000},
47#endif 52#endif
48#ifdef AUDIOHW_HAVE_BASS_CUTOFF 53#ifdef AUDIOHW_HAVE_BASS_CUTOFF
49 [SOUND_BASS_CUTOFF] = {"Hz", 0, 70, 130, 200, 200}, 54 [SOUND_BASS_CUTOFF] = {"Hz", 0, 70, 130, 200, 200},
@@ -181,13 +186,6 @@ void audiohw_set_treble_cutoff(int val)
181} 186}
182#endif 187#endif
183 188
184#ifdef HAVE_RECORDING
185static int recvol2hw(int value)
186{
187 /* -1725 to 3000 => 0 ... 23 ... 63 */
188 return ((4 * value) / 300) + 23;
189}
190#endif
191 189
192int sound_val2phys(int setting, int value) 190int sound_val2phys(int setting, int value)
193{ 191{
@@ -667,17 +665,59 @@ void audiohw_set_recsrc(int source, bool recording)
667 } /* switch(source) */ 665 } /* switch(source) */
668} 666}
669 667
670/* Setup PGA gain */ 668static int digital_gain2hw(int value)
669{
670 /* -9700 to 3000 => 0 ... 195 ... 255 */
671 return (2 * value) / 100 + 195;
672}
673
674static int pga_gain2hw(int value)
675{
676 /* -1725 to 3000 => 0 ... 23 ... 63 */
677 return ((4 * value) / 300) + 23;
678}
679
671void audiohw_set_recvol(int vol_l, int vol_r, int type) 680void audiohw_set_recvol(int vol_l, int vol_r, int type)
672{ 681{
673 wmcodec_set_reg(LINVOL, LINVOL_LIZC | LINVOL_LINVOL(recvol2hw(vol_l))); 682 int d_vol_l = 0;
683 int d_vol_r = 0;
684
685 if (vol_l > 3000)
686 {
687 d_vol_l = vol_l - 3000;
688 vol_l = 3000;
689 }
690
691 if (vol_r > 3000)
692 {
693 d_vol_r = vol_r - 3000;
694 vol_r = 3000;
695 }
696
697 /* PGA left gain */
698 wmcodec_set_reg(LINVOL, LINVOL_LIZC | LINVOL_LINVOL(pga_gain2hw(vol_l)));
699
700 /* digital left gain set */
701 wmcodec_set_reg(LADCVOL, digital_gain2hw(d_vol_l));
674 702
675 if (type == AUDIO_GAIN_MIC) 703 if (type == AUDIO_GAIN_MIC)
704 {
705 /* PGA right gain = PGA left gain*/
676 wmcodec_set_reg(RINVOL, RINVOL_RIVU | RINVOL_RIZC | 706 wmcodec_set_reg(RINVOL, RINVOL_RIVU | RINVOL_RIZC |
677 RINVOL_RINVOL(recvol2hw(vol_l))); 707 RINVOL_RINVOL(pga_gain2hw(vol_l)));
708
709 /* digital right gain = digital left gain*/
710 wmcodec_set_reg(RADCVOL, RADCVOL_RAVU | digital_gain2hw(d_vol_l));
711 }
678 else 712 else
713 {
714 /* PGA right gain */
679 wmcodec_set_reg(RINVOL, RINVOL_RIVU | RINVOL_RIZC | 715 wmcodec_set_reg(RINVOL, RINVOL_RIVU | RINVOL_RIZC |
680 RINVOL_RINVOL(recvol2hw(vol_r))); 716 RINVOL_RINVOL(pga_gain2hw(vol_r)));
717
718 /* digital right gain */
719 wmcodec_set_reg(RADCVOL, RADCVOL_RAVU | digital_gain2hw(d_vol_r));
720 }
681} 721}
682#endif /* HAVE_RECORDING */ 722#endif /* HAVE_RECORDING */
683#endif /* HAVE_WM8750 */ 723#endif /* HAVE_WM8750 */