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, VOLUME_MIN
/10, VOLUME_MAX
/10, -25},
33 /* HAVE_SW_TONE_CONTROLS */
34 [SOUND_BASS
] = {"dB", 0, 1, -24, 24, 0},
35 [SOUND_TREBLE
] = {"dB", 0, 1, -24, 24, 0},
36 [SOUND_BALANCE
] = {"%", 0, 1,-100, 100, 0},
37 [SOUND_CHANNELS
] = {"", 0, 1, 0, 5, 0},
38 [SOUND_STEREO_WIDTH
] = {"%", 0, 5, 0, 250, 100},
40 static bool is_muted
= false;
41 /* convert tenth of dB volume to master volume register value */
42 int tenthdb2master(int db
)
44 /* 0 to -63.0dB in 1dB steps, tsc2100 can goto -63.5 in 0.5dB steps */
45 if (db
< VOLUME_MIN
) {
47 } else if (db
>= VOLUME_MAX
) {
50 return(-((db
)/5)); /* VOLUME_MIN is negative */
54 int sound_val2phys(int setting
, int value
)
62 case SOUND_RIGHT_GAIN
:
64 result
= (value
- 23) * 15;
75 void audiohw_init(void)
77 short val
= tsc2100_readreg(TSAC4_PAGE
, TSAC4_ADDRESS
);
78 /* disable DAC PGA soft-stepping */
81 tsc2100_writereg(TSAC4_PAGE
, TSAC4_ADDRESS
, val
);
84 void audiohw_postinit(void)
89 void audiohw_set_master_vol(int vol_l
, int vol_r
)
91 tsc2100_writereg(TSDACGAIN_PAGE
, TSDACGAIN_ADDRESS
, (short)((vol_l
<<8) | vol_r
) );
94 void audiohw_mute(bool mute
)
96 short vol
= tsc2100_readreg(TSDACGAIN_PAGE
, TSDACGAIN_ADDRESS
);
97 /* left mute bit == 1<<15
98 right mute bit == 1<<7
102 vol
|= (1<<15)|(1<<7);
105 vol
&= ~((1<<15)|(1<<7));
108 tsc2100_writereg(TSDACGAIN_PAGE
, TSDACGAIN_ADDRESS
, vol
);
111 void audiohw_close(void)
113 /* mute headphones */
117 void audiohw_set_frequency(int fsel
)