Remove pcm_mute() which has been unused since r19308
[kugel-rb.git] / firmware / drivers / audio / tsc2100.c
blobcc6a7eed7dd2d1dfb9a0eecd05cce9f3d5730415
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
23 #include "cpu.h"
24 #include "debug.h"
25 #include "system.h"
26 #include "audio.h"
28 #include "audiohw.h"
29 #include "tsc2100.h"
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) {
46 return 0x7E;
47 } else if (db >= VOLUME_MAX) {
48 return 0x00;
49 } else {
50 return(-((db)/5)); /* VOLUME_MIN is negative */
54 int sound_val2phys(int setting, int value)
56 int result;
58 switch(setting)
60 #if 0
61 case SOUND_LEFT_GAIN:
62 case SOUND_RIGHT_GAIN:
63 case SOUND_MIC_GAIN:
64 result = (value - 23) * 15;
65 break;
66 #endif
67 default:
68 result = value;
69 break;
72 return result;
75 void audiohw_init(void)
77 short val = tsc2100_readreg(TSAC4_PAGE, TSAC4_ADDRESS);
78 /* disable DAC PGA soft-stepping */
79 val |= TSAC4_DASTDP;
81 tsc2100_writereg(TSAC4_PAGE, TSAC4_ADDRESS, val);
84 static void audiohw_mute(bool mute)
86 short vol = tsc2100_readreg(TSDACGAIN_PAGE, TSDACGAIN_ADDRESS);
87 /* left mute bit == 1<<15
88 right mute bit == 1<<7
90 if (mute)
92 vol |= (1<<15)|(1<<7);
93 } else
95 vol &= ~((1<<15)|(1<<7));
97 is_muted = mute;
98 tsc2100_writereg(TSDACGAIN_PAGE, TSDACGAIN_ADDRESS, vol);
101 void audiohw_postinit(void)
103 audiohw_mute(false);
106 void audiohw_set_master_vol(int vol_l, int vol_r)
108 tsc2100_writereg(TSDACGAIN_PAGE, TSDACGAIN_ADDRESS, (short)((vol_l<<8) | vol_r) );
111 void audiohw_close(void)
113 /* mute headphones */
114 audiohw_mute(true);
117 void audiohw_set_frequency(int fsel)
119 int reg_val;
120 reg_val = tsc2100_readreg(TSAC1_PAGE, TSAC1_ADDRESS);
122 reg_val &= ~(0x07<<3);
124 switch(fsel)
126 case HW_FREQ_8:
127 reg_val |= (0x06<<3);
128 break;
129 case HW_FREQ_11:
130 reg_val |= (0x04<<3);
131 break;
132 case HW_FREQ_22:
133 reg_val |= (0x02<<3);
134 break;
135 case HW_FREQ_44:
136 default:
137 break;
140 tsc2100_writereg(TSAC1_PAGE, TSAC1_ADDRESS, reg_val);