1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Driver for TSC2100 audio codec
12 * Copyright (c) 2008 Jonathan Gordon
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
31 const struct sound_settings_info audiohw_settings
[] = {
32 [SOUND_VOLUME
] = {"dB", 0, 1, -63, 0, -25},
34 /* HAVE_SW_TONE_CONTROLS */
35 [SOUND_BASS
] = {"dB", 0, 1, -24, 24, 0},
36 [SOUND_TREBLE
] = {"dB", 0, 1, -24, 24, 0},
37 [SOUND_BALANCE
] = {"%", 0, 1,-100, 100, 0},
38 [SOUND_CHANNELS
] = {"", 0, 1, 0, 5, 0},
39 [SOUND_STEREO_WIDTH
] = {"%", 0, 5, 0, 250, 100},
41 [SOUND_MIC_GAIN
] = {"dB", 1, 1, 0, 39, 23},
42 [SOUND_LEFT_GAIN
] = {"dB", 1, 1, 0, 31, 23},
43 [SOUND_RIGHT_GAIN
] = {"dB", 1, 1, 0, 31, 23},
47 static bool is_muted
= false;
48 /* convert tenth of dB volume to master volume register value */
49 int tenthdb2master(int db
)
51 /* 0 to -63.0dB in 1dB steps, tsc2100 can goto -63.5 in 0.5dB steps */
52 if (db
< VOLUME_MIN
) {
54 } else if (db
>= VOLUME_MAX
) {
57 return((db
-VOLUME_MIN
)/10); /* VOLUME_MIN is negative */
61 int sound_val2phys(int setting
, int value
)
69 case SOUND_RIGHT_GAIN
:
71 result
= (value
- 23) * 15;
82 void audiohw_init(void)
84 short val
= tsc2100_readreg(TSAC4_PAGE
, TSAC4_ADDRESS
);
85 /* disable DAC PGA soft-stepping */
88 tsc2100_writereg(TSAC4_PAGE
, TSAC4_ADDRESS
, val
);
91 void audiohw_postinit(void)
96 void audiohw_set_master_vol(int vol_l
, int vol_r
)
98 short vol
= (vol_l
<<14)|(vol_r
);
100 vol
|= (1<<15)|(1<<7);
101 tsc2100_writereg(TSDACGAIN_PAGE
, TSDACGAIN_ADDRESS
, vol
);
104 void audiohw_set_lineout_vol(int vol_l
, int vol_r
)
106 audiohw_set_master_vol(vol_l
, vol_r
);
109 void audiohw_mute(bool mute
)
111 short vol
= tsc2100_readreg(TSDACGAIN_PAGE
, TSDACGAIN_ADDRESS
);
112 /* left mute bit == 1<<15
113 right mute bit == 1<<7
117 vol
|= (1<<15)|(1<<7);
120 vol
&= ~((1<<15)|(1<<7));
123 tsc2100_writereg(TSDACGAIN_PAGE
, TSDACGAIN_ADDRESS
, vol
);
126 void audiohw_close(void)
128 /* mute headphones */
133 void audiohw_set_frequency(int fsel
)