diff options
Diffstat (limited to 'firmware/drivers/audio/wm8975.c')
-rw-r--r-- | firmware/drivers/audio/wm8975.c | 51 |
1 files changed, 7 insertions, 44 deletions
diff --git a/firmware/drivers/audio/wm8975.c b/firmware/drivers/audio/wm8975.c index c46dab79de..3b9fef0dbc 100644 --- a/firmware/drivers/audio/wm8975.c +++ b/firmware/drivers/audio/wm8975.c | |||
@@ -34,20 +34,6 @@ | |||
34 | #include "wmcodec.h" | 34 | #include "wmcodec.h" |
35 | #include "audiohw.h" | 35 | #include "audiohw.h" |
36 | 36 | ||
37 | const struct sound_settings_info audiohw_settings[] = { | ||
38 | [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, | ||
39 | [SOUND_BASS] = {"dB", 0, 1, -6, 9, 0}, | ||
40 | [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0}, | ||
41 | [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, | ||
42 | [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, | ||
43 | [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100}, | ||
44 | #ifdef HAVE_RECORDING | ||
45 | [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 63, 23}, | ||
46 | [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 63, 23}, | ||
47 | [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 63, 0}, | ||
48 | #endif | ||
49 | }; | ||
50 | |||
51 | static unsigned short wm8975_regs[WM8975_NUM_REGISTERS] = | 37 | static unsigned short wm8975_regs[WM8975_NUM_REGISTERS] = |
52 | { | 38 | { |
53 | [LINVOL] = LINVOL_LZCEN | 23, /* 0dB */ | 39 | [LINVOL] = LINVOL_LZCEN | 23, /* 0dB */ |
@@ -85,7 +71,7 @@ static void wm8975_write_or(int reg, unsigned bits) | |||
85 | } | 71 | } |
86 | 72 | ||
87 | /* convert tenth of dB volume (-730..60) to master volume register value */ | 73 | /* convert tenth of dB volume (-730..60) to master volume register value */ |
88 | int tenthdb2master(int db) | 74 | static int vol_tenthdb2hw(int db) |
89 | { | 75 | { |
90 | /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ | 76 | /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ |
91 | /* 1111111 == +6dB (0x7f) */ | 77 | /* 1111111 == +6dB (0x7f) */ |
@@ -100,29 +86,6 @@ int tenthdb2master(int db) | |||
100 | } | 86 | } |
101 | } | 87 | } |
102 | 88 | ||
103 | int sound_val2phys(int setting, int value) | ||
104 | { | ||
105 | int result; | ||
106 | |||
107 | switch(setting) | ||
108 | { | ||
109 | #ifdef HAVE_RECORDING | ||
110 | case SOUND_LEFT_GAIN: | ||
111 | case SOUND_RIGHT_GAIN: | ||
112 | result = ((value - 23) * 15) / 2; | ||
113 | break; | ||
114 | case SOUND_MIC_GAIN: | ||
115 | result = ((value - 23) * 15) / 2 + 200; | ||
116 | break; | ||
117 | #endif | ||
118 | default: | ||
119 | result = value; | ||
120 | break; | ||
121 | } | ||
122 | |||
123 | return result; | ||
124 | } | ||
125 | |||
126 | static void audiohw_mute(bool mute) | 89 | static void audiohw_mute(bool mute) |
127 | { | 90 | { |
128 | if (mute) { | 91 | if (mute) { |
@@ -205,13 +168,10 @@ void audiohw_postinit(void) | |||
205 | } | 168 | } |
206 | #endif | 169 | #endif |
207 | 170 | ||
208 | void audiohw_set_master_vol(int vol_l, int vol_r) | 171 | void audiohw_set_volume(int vol_l, int vol_r) |
209 | { | 172 | { |
210 | /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ | 173 | vol_l = vol_tenthdb2hw(vol_l); |
211 | /* 1111111 == +6dB */ | 174 | vol_r = vol_tenthdb2hw(vol_r); |
212 | /* 1111001 == 0dB */ | ||
213 | /* 0110000 == -73dB */ | ||
214 | /* 0101111 == mute (0x2f) */ | ||
215 | 175 | ||
216 | /* OUT1 */ | 176 | /* OUT1 */ |
217 | wm8975_write(LOUT1VOL, LOUT1VOL_LO1ZC | vol_l); | 177 | wm8975_write(LOUT1VOL, LOUT1VOL_LO1ZC | vol_l); |
@@ -220,6 +180,9 @@ void audiohw_set_master_vol(int vol_l, int vol_r) | |||
220 | 180 | ||
221 | void audiohw_set_lineout_vol(int vol_l, int vol_r) | 181 | void audiohw_set_lineout_vol(int vol_l, int vol_r) |
222 | { | 182 | { |
183 | vol_l = vol_tenthdb2hw(vol_l); | ||
184 | vol_r = vol_tenthdb2hw(vol_r); | ||
185 | |||
223 | /* OUT2 */ | 186 | /* OUT2 */ |
224 | wm8975_write(LOUT2VOL, LOUT2VOL_LO2ZC | vol_l); | 187 | wm8975_write(LOUT2VOL, LOUT2VOL_LO2ZC | vol_l); |
225 | wm8975_write(ROUT2VOL, ROUT2VOL_RO2VU | ROUT2VOL_RO2ZC | vol_r); | 188 | wm8975_write(ROUT2VOL, ROUT2VOL_RO2VU | ROUT2VOL_RO2ZC | vol_r); |