summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/SOURCES6
-rw-r--r--firmware/drivers/audio/wm8721.c184
-rw-r--r--firmware/drivers/audio/wm8731.c194
-rw-r--r--firmware/export/audiohw.h5
-rw-r--r--firmware/export/config-ipodmini.h2
-rw-r--r--firmware/export/config-ipodmini2g.h4
-rw-r--r--firmware/export/wm8721.h106
-rw-r--r--firmware/export/wm8731.h139
-rw-r--r--firmware/sound.c19
-rw-r--r--firmware/target/arm/pcm-pp.c3
10 files changed, 220 insertions, 442 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 752db73b01..3fadec005e 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -230,9 +230,9 @@ drivers/audio/wm8975.c
230drivers/audio/wm8985.c 230drivers/audio/wm8985.c
231#elif defined(HAVE_WM8758) 231#elif defined(HAVE_WM8758)
232drivers/audio/wm8758.c 232drivers/audio/wm8758.c
233#elif defined(HAVE_WM8721) 233#elif defined(HAVE_WM8711) \
234drivers/audio/wm8721.c 234 || defined(HAVE_WM8721) \
235#elif defined(HAVE_WM8731) 235 || defined(HAVE_WM8731)
236drivers/audio/wm8731.c 236drivers/audio/wm8731.c
237#elif defined(HAVE_AS3514) 237#elif defined(HAVE_AS3514)
238drivers/audio/as3514.c 238drivers/audio/as3514.c
diff --git a/firmware/drivers/audio/wm8721.c b/firmware/drivers/audio/wm8721.c
deleted file mode 100644
index 3f14ca467e..0000000000
--- a/firmware/drivers/audio/wm8721.c
+++ /dev/null
@@ -1,184 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Driver for WM8721 audio codec
11 *
12 * Based on code from the ipodlinux project - http://ipodlinux.org/
13 * Adapted for Rockbox in January 2006
14 *
15 * Original file: linux/arch/armnommu/mach-ipod/audio.c
16 *
17 * Copyright (c) 2003-2005 Bernard Leach (leachbj@bouncycastle.org)
18 *
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version 2
22 * of the License, or (at your option) any later version.
23 *
24 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
25 * KIND, either express or implied.
26 *
27 ****************************************************************************/
28#include "config.h"
29#include "logf.h"
30#include "system.h"
31#include "string.h"
32#include "audio.h"
33
34#include "wmcodec.h"
35#include "audiohw.h"
36
37#define IPOD_PCM_LEVEL 0x65 /* -6dB */
38
39/* use zero crossing to reduce clicks during volume changes */
40#define VOLUME_ZC_WAIT (1<<7)
41
42const struct sound_settings_info audiohw_settings[] = {
43 [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25},
44 /* HAVE_SW_TONE_CONTROLS */
45 [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0},
46 [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0},
47 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
48 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
49 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
50};
51
52/* convert tenth of dB volume (-730..60) to master volume register value */
53int tenthdb2master(int db)
54{
55 /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */
56 /* 1111111 == +6dB (0x7f) */
57 /* 1111001 == 0dB (0x79) */
58 /* 0110000 == -73dB (0x30 */
59 /* 0101111 == mute (0x2f) */
60
61 if (db < VOLUME_MIN) {
62 return 0x2f;
63 } else {
64 return((db/10)+0x30+73);
65 }
66}
67
68void audiohw_mute(bool mute)
69{
70 if (mute)
71 {
72 /* Set DACMU = 1 to soft-mute the audio DACs. */
73 wmcodec_write(DAPCTRL, 0x8);
74 } else {
75 /* Set DACMU = 0 to soft-un-mute the audio DACs. */
76 wmcodec_write(DAPCTRL, 0x0);
77 }
78}
79
80/** From ipodLinux **/
81static void codec_set_active(int active)
82{
83 /* set active to 0x0 or 0x1 */
84 if (active) {
85 wmcodec_write(ACTIVECTRL, 0x01);
86 } else {
87 wmcodec_write(ACTIVECTRL, 0x00);
88 }
89}
90
91
92/* Silently enable / disable audio output */
93void audiohw_preinit(void)
94{
95 wmcodec_write(RESET, 0x0); /*Reset*/
96
97 codec_set_active(0x0);
98
99 /* DACSEL=1 */
100 wmcodec_write(0x4, 0x10);
101
102 /* set power register to POWEROFF=0 on OUTPD=0, DACPD=0 */
103 wmcodec_write(PDCTRL, 0x67);
104
105 /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */
106 /* IWL=00(16 bit) FORMAT=10(I2S format) */
107 wmcodec_write(AINTFCE, 0x42);
108
109 audiohw_set_sample_rate(WM8721_USB24_44100HZ);
110
111 /* set the volume to -6dB */
112 wmcodec_write(LOUTVOL, IPOD_PCM_LEVEL);
113 wmcodec_write(ROUTVOL, 0x100 | IPOD_PCM_LEVEL);
114
115 /* ACTIVE=1 */
116 codec_set_active(1);
117
118 /* 5. Set DACMU = 0 to soft-un-mute the audio DACs. */
119 wmcodec_write(DAPCTRL, 0x0);
120}
121
122void audiohw_postinit(void)
123{
124 audiohw_mute(0);
125}
126
127void audiohw_set_master_vol(int vol_l, int vol_r)
128{
129 /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */
130 /* 1111111 == +6dB */
131 /* 1111001 == 0dB */
132 /* 0110000 == -73dB */
133 /* 0101111 == mute (0x2f) */
134 wmcodec_write(LOUTVOL, VOLUME_ZC_WAIT | vol_l);
135 wmcodec_write(ROUTVOL, VOLUME_ZC_WAIT | vol_r);
136}
137
138/* Nice shutdown of WM8721 codec */
139void audiohw_close(void)
140{
141 /* set DACMU=1 DEEMPH=0 */
142 wmcodec_write(DAPCTRL, 0x8);
143
144 /* ACTIVE=0 */
145 codec_set_active(0x0);
146
147 /* set DACSEL=0, MUTEMIC=1 */
148 wmcodec_write(0x4, 0x2);
149
150 /* set POWEROFF=0 OUTPD=0 DACPD=1 */
151 wmcodec_write(PDCTRL, 0x6f);
152
153 /* set POWEROFF=1 OUTPD=1 DACPD=1 */
154 wmcodec_write(PDCTRL, 0xff);
155}
156
157void audiohw_set_sample_rate(int sampling_control)
158{
159 int rate = 0;
160 switch(sampling_control)
161 {
162 case SAMPR_96:
163 rate = WM8721_USB24_96000HZ;
164 break;
165 case SAMPR_88:
166 rate = WM8721_USB24_88200HZ;
167 break;
168 case SAMPR_48:
169 rate = WM8721_USB24_48000HZ;
170 break;
171 case SAMPR_44:
172 rate = WM8721_USB24_44100HZ;
173 break;
174 case SAMPR_32:
175 rate = WM8721_USB24_32000HZ;
176 break;
177 case SAMPR_8:
178 rate = WM8721_USB24_8000HZ;
179 break;
180 }
181 codec_set_active(0x0);
182 wmcodec_write(SAMPCTRL, rate);
183 codec_set_active(0x1);
184}
diff --git a/firmware/drivers/audio/wm8731.c b/firmware/drivers/audio/wm8731.c
index 2f882e8fe1..3cfd3e4b92 100644
--- a/firmware/drivers/audio/wm8731.c
+++ b/firmware/drivers/audio/wm8731.c
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Driver for WM8731L audio codec 10 * Driver for WM8711/WM8721/WM8731 audio codecs
11 * 11 *
12 * Based on code from the ipodlinux project - http://ipodlinux.org/ 12 * Based on code from the ipodlinux project - http://ipodlinux.org/
13 * Adapted for Rockbox in January 2006 13 * Adapted for Rockbox in January 2006
@@ -43,7 +43,7 @@ const struct sound_settings_info audiohw_settings[] = {
43 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, 43 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
44 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, 44 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
45 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100}, 45 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
46#ifdef HAVE_RECORDING 46#if defined(HAVE_WM8731) && defined(HAVE_RECORDING)
47 [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 31, 23}, 47 [SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 31, 23},
48 [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 31, 23}, 48 [SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 31, 23},
49 [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 1, 0}, 49 [SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 1, 0},
@@ -53,42 +53,57 @@ const struct sound_settings_info audiohw_settings[] = {
53/* Init values/shadows 53/* Init values/shadows
54 * Ignore bit 8 since that only specifies "both" for updating 54 * Ignore bit 8 since that only specifies "both" for updating
55 * gains - "RESET" (15h) not included */ 55 * gains - "RESET" (15h) not included */
56static unsigned char wm8731_regs[WM8731_NUM_REGS] = 56static unsigned char wmc_regs[WMC_NUM_REGS] =
57{ 57{
58 [LINVOL] = 0x97, 58#ifdef HAVE_WM8731
59 [RINVOL] = 0x97, 59 [LINVOL] = LINVOL_DEFAULT,
60 [LOUTVOL] = 0x79 | ROUTVOL_RZCEN, 60 [RINVOL] = RINVOL_DEFAULT,
61 [ROUTVOL] = 0x79 | ROUTVOL_RZCEN, 61#endif
62 [AAPCTRL] = 0x0a, 62 [LOUTVOL] = LOUTVOL_DEFAULT | WMC_OUT_ZCEN,
63 [DAPCTRL] = 0x08, 63 [ROUTVOL] = LOUTVOL_DEFAULT | WMC_OUT_ZCEN,
64 [PDCTRL] = 0x9f, 64#if defined(HAVE_WM8711) || defined(HAVE_WM8731)
65 [AINTFCE] = 0x0a, 65 /* BYPASS on by default - OFF until needed */
66 [SAMPCTRL] = 0x00, 66 [AAPCTRL] = AAPCTRL_DEFAULT & ~AAPCTRL_BYPASS,
67 [ACTIVECTRL] = 0x00, 67 /* CLKOUT and OSC on by default - OFF unless needed by a target */
68 [PDCTRL] = PDCTRL_DEFAULT | PDCTRL_CLKOUTPD | PDCTRL_OSCPD,
69#elif defined(HAVE_WM8721)
70 /* No BYPASS */
71 [AAPCTRL] = AAPCTRL_DEFAULT,
72 /* No CLKOUT or OSC */
73 [PDCTRL] = PDCTRL_DEFAULT,
74#endif
75 [DAPCTRL] = DAPCTRL_DEFAULT,
76#ifndef CODEC_SLAVE
77 [AINTFCE] = AINTFCE_FORMAT_I2S | AINTFCE_IWL_16BIT | AINTFCE_MS,
78#else
79 [AINTFCE] = AINTFCE_FORMAT_I2S | AINTFCE_IWL_16BIT,
80#endif
81 [SAMPCTRL] = SAMPCTRL_DEFAULT,
82 [ACTIVECTRL] = ACTIVECTRL_DEFAULT,
68}; 83};
69 84
70static void wm8731_write(int reg, unsigned val) 85static void wmc_write(int reg, unsigned val)
71{ 86{
72 if ((unsigned)reg >= WM8731_NUM_REGS) 87 if ((unsigned)reg >= WMC_NUM_REGS)
73 return; 88 return;
74 89
75 wm8731_regs[reg] = (unsigned char)val; 90 wmc_regs[reg] = (unsigned char)val;
76 wmcodec_write(reg, val); 91 wmcodec_write(reg, val);
77} 92}
78 93
79static void wm8731_set(int reg, unsigned bits) 94static void wmc_set(int reg, unsigned bits)
80{ 95{
81 wm8731_write(reg, wm8731_regs[reg] | bits); 96 wmc_write(reg, wmc_regs[reg] | bits);
82} 97}
83 98
84static void wm8731_clear(int reg, unsigned bits) 99static void wmc_clear(int reg, unsigned bits)
85{ 100{
86 wm8731_write(reg, wm8731_regs[reg] & ~bits); 101 wmc_write(reg, wmc_regs[reg] & ~bits);
87} 102}
88 103
89static void wm8731_write_masked(int reg, unsigned bits, unsigned mask) 104static void wmc_write_masked(int reg, unsigned bits, unsigned mask)
90{ 105{
91 wm8731_write(reg, (wm8731_regs[reg] & ~mask) | (bits & mask)); 106 wmc_write(reg, (wmc_regs[reg] & ~mask) | (bits & mask));
92} 107}
93 108
94/* convert tenth of dB volume (-730..60) to master volume register value */ 109/* convert tenth of dB volume (-730..60) to master volume register value */
@@ -134,54 +149,50 @@ void audiohw_mute(bool mute)
134{ 149{
135 if (mute) { 150 if (mute) {
136 /* Set DACMU = 1 to soft-mute the audio DACs. */ 151 /* Set DACMU = 1 to soft-mute the audio DACs. */
137 wm8731_set(DAPCTRL, DAPCTRL_DACMU); 152 wmc_set(DAPCTRL, DAPCTRL_DACMU);
138 } else { 153 } else {
139 /* Set DACMU = 0 to soft-un-mute the audio DACs. */ 154 /* Set DACMU = 0 to soft-un-mute the audio DACs. */
140 wm8731_clear(DAPCTRL, DAPCTRL_DACMU); 155 wmc_clear(DAPCTRL, DAPCTRL_DACMU);
141 } 156 }
142} 157}
143 158
144static void codec_set_active(int active) 159static void codec_set_active(int active)
145{ 160{
146 /* set active to 0x0 or 0x1 */ 161 /* set active to 0x0 or 0x1 */
147 wm8731_write(ACTIVECTRL, active ? ACTIVECTRL_ACTIVE : 0); 162 wmc_write(ACTIVECTRL, active ? ACTIVECTRL_ACTIVE : 0);
148} 163}
149 164
150void audiohw_preinit(void) 165void audiohw_preinit(void)
151{ 166{
152 /* POWER UP SEQUENCE */ 167 /* POWER UP SEQUENCE */
153 /* 1) Switch on power supplies. By default the WM8731 is in Standby Mode, 168 /* 1) Switch on power supplies. By default the WM codec is in Standby Mode,
154 * the DAC is digitally muted and the Audio Interface and Outputs are 169 * the DAC is digitally muted and the Audio Interface and Outputs are
155 * all OFF. */ 170 * all OFF. */
156 wmcodec_write(RESET, RESET_RESET); 171 wmcodec_write(RESET, RESET_RESET);
157 172
158 /* 2) Set all required bits in the Power Down register (0Ch) to '0'; 173 /* 2) Set all required bits in the Power Down register (0Ch) to '0';
159 * EXCEPT the OUTPD bit, this should be set to '1' (Default). */ 174 * EXCEPT the OUTPD bit, this should be set to '1' (Default). */
160 wm8731_clear(PDCTRL, PDCTRL_DACPD | PDCTRL_POWEROFF); 175 wmc_clear(PDCTRL, PDCTRL_DACPD | PDCTRL_POWEROFF);
161 176
162 /* 3) Set required values in all other registers except 12h (Active). */ 177 /* 3) Set required values in all other registers except 12h (Active). */
163 wm8731_write(AINTFCE, 178 wmc_set(AINTFCE, 0); /* Set no bits - write init/shadow value */
164#ifndef CODEC_SLAVE
165 AINTFCE_MS |
166#endif
167 AINTFCE_FORMAT_I2S | AINTFCE_IWL_16BIT);
168 179
169 wm8731_set(AAPCTRL, AAPCTRL_DACSEL); 180 wmc_set(AAPCTRL, AAPCTRL_DACSEL);
170 wm8731_write(SAMPCTRL, WM8731_USB24_44100HZ); 181 wmc_write(SAMPCTRL, WMC_USB24_44100HZ);
182
183 /* 4) Set the 'Active' bit in register 12h. */
184 codec_set_active(true);
171 185
172 /* 5) The last write of the sequence should be setting OUTPD to '0' 186 /* 5) The last write of the sequence should be setting OUTPD to '0'
173 * (active) in register 0Ch, enabling the DAC signal path, free 187 * (active) in register 0Ch, enabling the DAC signal path, free
174 * of any significant power-up noise. */ 188 * of any significant power-up noise. */
175 wm8731_clear(PDCTRL, PDCTRL_OUTPD); 189 wmc_clear(PDCTRL, PDCTRL_OUTPD);
176} 190}
177 191
178void audiohw_postinit(void) 192void audiohw_postinit(void)
179{ 193{
180 sleep(HZ); 194 sleep(HZ);
181 195
182 /* 4) Set the 'Active' bit in register 12h. */
183 codec_set_active(true);
184
185 audiohw_mute(false); 196 audiohw_mute(false);
186 197
187#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB) 198#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
@@ -197,51 +208,53 @@ void audiohw_set_master_vol(int vol_l, int vol_r)
197 /* 1111001 == 0dB */ 208 /* 1111001 == 0dB */
198 /* 0110000 == -73dB */ 209 /* 0110000 == -73dB */
199 /* 0101111 == mute (0x2f) */ 210 /* 0101111 == mute (0x2f) */
200 wm8731_write_masked(LOUTVOL, vol_l, LOUTVOL_LHPVOL_MASK); 211 wmc_write_masked(LOUTVOL, vol_l, WMC_OUT_VOL_MASK);
201 wm8731_write_masked(ROUTVOL, vol_r, ROUTVOL_RHPVOL_MASK); 212 wmc_write_masked(ROUTVOL, vol_r, WMC_OUT_VOL_MASK);
202} 213}
203 214
204/* Nice shutdown of WM8731 codec */ 215/* Nice shutdown of WM codec */
205void audiohw_close(void) 216void audiohw_close(void)
206{ 217{
207 /* POWER DOWN SEQUENCE */ 218 /* POWER DOWN SEQUENCE */
208 /* 1) Set the OUTPD bit to '1' (power down). */ 219 /* 1) Set the OUTPD bit to '1' (power down). */
209 wm8731_set(PDCTRL, PDCTRL_OUTPD); 220 wmc_set(PDCTRL, PDCTRL_OUTPD);
210 /* 2) Remove the WM8731 supplies. */ 221 /* 2) Remove the WM codec supplies. */
211} 222}
212 223
213void audiohw_set_sample_rate(int sampling_control) 224void audiohw_set_sample_rate(int sampling_control)
214{ 225{
215 int rate = 0; 226 int rate;
216 227
217 switch(sampling_control) 228 switch(sampling_control)
218 { 229 {
219 case SAMPR_96: 230 case SAMPR_96:
220 rate = WM8731_USB24_96000HZ; 231 rate = WMC_USB24_96000HZ;
221 break; 232 break;
222 case SAMPR_88: 233 case SAMPR_88:
223 rate = WM8731_USB24_88200HZ; 234 rate = WMC_USB24_88200HZ;
224 break; 235 break;
225 case SAMPR_48: 236 case SAMPR_48:
226 rate = WM8731_USB24_48000HZ; 237 rate = WMC_USB24_48000HZ;
227 break; 238 break;
239 default:
228 case SAMPR_44: 240 case SAMPR_44:
229 rate = WM8731_USB24_44100HZ; 241 rate = WMC_USB24_44100HZ;
230 break; 242 break;
231 case SAMPR_32: 243 case SAMPR_32:
232 rate = WM8731_USB24_32000HZ; 244 rate = WMC_USB24_32000HZ;
233 break; 245 break;
234 case SAMPR_8: 246 case SAMPR_8:
235 rate = WM8731_USB24_8000HZ; 247 rate = WMC_USB24_8000HZ;
236 break; 248 break;
237 } 249 }
238 250
239 codec_set_active(false); 251 codec_set_active(false);
240 wm8731_write(SAMPCTRL, rate); 252 wmc_write(SAMPCTRL, rate);
241 codec_set_active(true); 253 codec_set_active(true);
242} 254}
243 255
244#ifdef HAVE_RECORDING 256#if defined(HAVE_WM8731) && defined(HAVE_RECORDING)
257/* WM8731 only */
245void audiohw_enable_recording(bool source_mic) 258void audiohw_enable_recording(bool source_mic)
246{ 259{
247 /* NOTE: When switching to digital monitoring we will not want 260 /* NOTE: When switching to digital monitoring we will not want
@@ -250,27 +263,27 @@ void audiohw_enable_recording(bool source_mic)
250 codec_set_active(false); 263 codec_set_active(false);
251 264
252 if (source_mic) { 265 if (source_mic) {
253 wm8731_set(LINVOL, LINVOL_LINMUTE); 266 wmc_set(LINVOL, WMC_IN_MUTE);
254 wm8731_set(RINVOL, RINVOL_RINMUTE); 267 wmc_set(RINVOL, WMC_IN_MUTE);
255 268
256 wm8731_write_masked(PDCTRL, PDCTRL_LINEINPD | PDCTRL_DACPD, 269 wmc_write_masked(PDCTRL, PDCTRL_LINEINPD | PDCTRL_DACPD,
257 PDCTRL_LINEINPD | PDCTRL_MICPD | 270 PDCTRL_LINEINPD | PDCTRL_MICPD |
258 PDCTRL_ADCPD | PDCTRL_DACPD); 271 PDCTRL_ADCPD | PDCTRL_DACPD);
259 wm8731_write_masked(AAPCTRL, AAPCTRL_INSEL | AAPCTRL_SIDETONE, 272 wmc_write_masked(AAPCTRL, AAPCTRL_INSEL | AAPCTRL_SIDETONE,
260 AAPCTRL_MUTEMIC | AAPCTRL_INSEL | 273 AAPCTRL_MUTEMIC | AAPCTRL_INSEL |
261 AAPCTRL_BYPASS | AAPCTRL_DACSEL | 274 AAPCTRL_BYPASS | AAPCTRL_DACSEL |
262 AAPCTRL_SIDETONE); 275 AAPCTRL_SIDETONE);
263 } else { 276 } else {
264 wm8731_write_masked(PDCTRL, PDCTRL_MICPD | PDCTRL_DACPD, 277 wmc_write_masked(PDCTRL, PDCTRL_MICPD | PDCTRL_DACPD,
265 PDCTRL_LINEINPD | PDCTRL_MICPD | 278 PDCTRL_LINEINPD | PDCTRL_MICPD |
266 PDCTRL_ADCPD | PDCTRL_DACPD); 279 PDCTRL_ADCPD | PDCTRL_DACPD);
267 wm8731_write_masked(AAPCTRL, AAPCTRL_MUTEMIC | AAPCTRL_BYPASS, 280 wmc_write_masked(AAPCTRL, AAPCTRL_MUTEMIC | AAPCTRL_BYPASS,
268 AAPCTRL_MUTEMIC | AAPCTRL_INSEL | 281 AAPCTRL_MUTEMIC | AAPCTRL_INSEL |
269 AAPCTRL_BYPASS | AAPCTRL_DACSEL | 282 AAPCTRL_BYPASS | AAPCTRL_DACSEL |
270 AAPCTRL_SIDETONE); 283 AAPCTRL_SIDETONE);
271 284
272 wm8731_clear(LINVOL, LINVOL_LINMUTE); 285 wmc_clear(LINVOL, WMC_IN_MUTE);
273 wm8731_clear(RINVOL, RINVOL_RINMUTE); 286 wmc_clear(RINVOL, WMC_IN_MUTE);
274 } 287 }
275 288
276 codec_set_active(true); 289 codec_set_active(true);
@@ -281,21 +294,21 @@ void audiohw_disable_recording(void)
281 codec_set_active(false); 294 codec_set_active(false);
282 295
283 /* Mute line inputs */ 296 /* Mute line inputs */
284 wm8731_set(LINVOL, LINVOL_LINMUTE); 297 wmc_set(LINVOL, WMC_IN_MUTE);
285 wm8731_set(RINVOL, RINVOL_RINMUTE); 298 wmc_set(RINVOL, WMC_IN_MUTE);
286 wm8731_set(AAPCTRL, AAPCTRL_MUTEMIC); 299 wmc_set(AAPCTRL, AAPCTRL_MUTEMIC);
287 300
288 /* Turn off input analog audio paths */ 301 /* Turn off input analog audio paths */
289 wm8731_clear(AAPCTRL, AAPCTRL_BYPASS | AAPCTRL_SIDETONE); 302 wmc_clear(AAPCTRL, AAPCTRL_BYPASS | AAPCTRL_SIDETONE);
290 303
291 /* Set power config */ 304 /* Set power config */
292 wm8731_write_masked(PDCTRL, 305 wmc_write_masked(PDCTRL,
293 PDCTRL_LINEINPD | PDCTRL_MICPD | PDCTRL_ADCPD, 306 PDCTRL_LINEINPD | PDCTRL_MICPD | PDCTRL_ADCPD,
294 PDCTRL_LINEINPD | PDCTRL_MICPD | PDCTRL_DACPD | 307 PDCTRL_LINEINPD | PDCTRL_MICPD | PDCTRL_DACPD |
295 PDCTRL_ADCPD); 308 PDCTRL_ADCPD);
296 309
297 /* Select DAC */ 310 /* Select DAC */
298 wm8731_set(AAPCTRL, AAPCTRL_DACSEL); 311 wmc_set(AAPCTRL, AAPCTRL_DACSEL);
299 312
300 codec_set_active(true); 313 codec_set_active(true);
301} 314}
@@ -306,15 +319,15 @@ void audiohw_set_recvol(int left, int right, int type)
306 { 319 {
307 case AUDIO_GAIN_MIC: 320 case AUDIO_GAIN_MIC:
308 if (left > 0) { 321 if (left > 0) {
309 wm8731_set(AAPCTRL, AAPCTRL_MIC_BOOST); 322 wmc_set(AAPCTRL, AAPCTRL_MIC_BOOST);
310 } 323 }
311 else { 324 else {
312 wm8731_clear(AAPCTRL, AAPCTRL_MIC_BOOST); 325 wmc_clear(AAPCTRL, AAPCTRL_MIC_BOOST);
313 } 326 }
314 break; 327 break;
315 case AUDIO_GAIN_LINEIN: 328 case AUDIO_GAIN_LINEIN:
316 wm8731_write_masked(LINVOL, left, LINVOL_MASK); 329 wmc_write_masked(LINVOL, left, WMC_IN_VOL_MASK);
317 wm8731_write_masked(RINVOL, right, RINVOL_MASK); 330 wmc_write_masked(RINVOL, right, WMC_IN_VOL_MASK);
318 break; 331 break;
319 default: 332 default:
320 return; 333 return;
@@ -324,13 +337,12 @@ void audiohw_set_recvol(int left, int right, int type)
324void audiohw_set_monitor(bool enable) 337void audiohw_set_monitor(bool enable)
325{ 338{
326 if(enable) { 339 if(enable) {
327 wm8731_clear(PDCTRL, PDCTRL_LINEINPD); 340 wmc_clear(PDCTRL, PDCTRL_LINEINPD);
328 wm8731_set(AAPCTRL, AAPCTRL_BYPASS); 341 wmc_set(AAPCTRL, AAPCTRL_BYPASS);
329 } 342 }
330 else { 343 else {
331 wm8731_clear(AAPCTRL, AAPCTRL_BYPASS); 344 wmc_clear(AAPCTRL, AAPCTRL_BYPASS);
332 wm8731_set(PDCTRL, PDCTRL_LINEINPD); 345 wmc_set(PDCTRL, PDCTRL_LINEINPD);
333 } 346 }
334} 347}
335#endif /* HAVE_RECORDING */ 348#endif /* HAVE_WM8731 && HAVE_RECORDING */
336
diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h
index b82c27e2fb..51aec65c4c 100644
--- a/firmware/export/audiohw.h
+++ b/firmware/export/audiohw.h
@@ -46,9 +46,8 @@
46#include "wm8985.h" 46#include "wm8985.h"
47#elif defined(HAVE_WM8758) 47#elif defined(HAVE_WM8758)
48#include "wm8758.h" 48#include "wm8758.h"
49#elif defined(HAVE_WM8721) 49#elif defined(HAVE_WM8711) || defined(HAVE_WM8721) || \
50#include "wm8721.h" 50 defined(HAVE_WM8731)
51#elif defined(HAVE_WM8731)
52#include "wm8731.h" 51#include "wm8731.h"
53#elif defined(HAVE_TLV320) 52#elif defined(HAVE_TLV320)
54#include "tlv320.h" 53#include "tlv320.h"
diff --git a/firmware/export/config-ipodmini.h b/firmware/export/config-ipodmini.h
index c2d6376706..5d7781a486 100644
--- a/firmware/export/config-ipodmini.h
+++ b/firmware/export/config-ipodmini.h
@@ -85,7 +85,7 @@
85#define PLUGIN_BUFFER_SIZE 0x80000 85#define PLUGIN_BUFFER_SIZE 0x80000
86 86
87/* Define this if you have the WM8721 audio codec */ 87/* Define this if you have the WM8721 audio codec */
88#define HAVE_WM8721 /* actually WM8731 but no recording */ 88#define HAVE_WM8731
89 89
90/* WM8721 has no tone controls, so we use the software ones */ 90/* WM8721 has no tone controls, so we use the software ones */
91#define HAVE_SW_TONE_CONTROLS 91#define HAVE_SW_TONE_CONTROLS
diff --git a/firmware/export/config-ipodmini2g.h b/firmware/export/config-ipodmini2g.h
index 6d6ebf1a9a..dbbbc4356c 100644
--- a/firmware/export/config-ipodmini2g.h
+++ b/firmware/export/config-ipodmini2g.h
@@ -84,8 +84,8 @@
84/* The number of bytes reserved for loadable plugins */ 84/* The number of bytes reserved for loadable plugins */
85#define PLUGIN_BUFFER_SIZE 0x80000 85#define PLUGIN_BUFFER_SIZE 0x80000
86 86
87/* Define this if you have the WM8721 audio codec */ 87/* Define this if you have the WM8711 audio codec */
88#define HAVE_WM8721 /* actually WM8731 but no recording */ 88#define HAVE_WM8711
89 89
90/* WM8721 has no tone controls, so we use the software ones */ 90/* WM8721 has no tone controls, so we use the software ones */
91#define HAVE_SW_TONE_CONTROLS 91#define HAVE_SW_TONE_CONTROLS
diff --git a/firmware/export/wm8721.h b/firmware/export/wm8721.h
deleted file mode 100644
index 814535621a..0000000000
--- a/firmware/export/wm8721.h
+++ /dev/null
@@ -1,106 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Dave Chapman
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef _WM8721_H
23#define _WM8721_H
24
25/* volume/balance/treble/bass interdependency */
26#define VOLUME_MIN -730
27#define VOLUME_MAX 60
28
29extern int tenthdb2master(int db);
30
31extern void audiohw_set_master_vol(int vol_l, int vol_r);
32extern void audiohw_set_sample_rate(int sampling_control);
33
34/* Register addresses and bits */
35#define LOUTVOL 0x02
36#define LOUTVOL_LHPVOL_MASK 0x7f
37#define LOUTVOL_LZCEN (1 << 7)
38#define LOUTVOL_LRHPBOTH (1 << 8)
39
40#define ROUTVOL 0x03
41#define ROUTVOL_RHPVOL_MASK 0x7f
42#define ROUTVOL_RZCEN (1 << 7)
43#define ROUTVOL_RLHPBOTH (1 << 8)
44
45#define AAPCTRL 0x04 /* Analog audio path control */
46#define AAPCTRL_DACSEL (1 << 4)
47
48#define DAPCTRL 0x05 /* Digital audio path control */
49#define DAPCTRL_DEEMP_DISABLE (0 << 2)
50#define DAPCTRL_DEEMP_32KHz (1 << 2)
51#define DAPCTRL_DEEMP_44KHz (2 << 2)
52#define DAPCTRL_DEEMP_48KHz (3 << 2)
53#define DAPCTRL_DEEMP_MASK (3 << 2)
54#define DAPCTRL_DACMU (1 << 3)
55
56#define PDCTRL 0x06
57#define PDCTRL_DACPD (1 << 3)
58#define PDCTRL_OUTPD (1 << 4)
59#define PDCTRL_POWEROFF (1 << 7)
60
61#define AINTFCE 0x07
62#define AINTFCE_FORMAT_MSB_RJUST (0 << 0)
63#define AINTFCE_FORMAT_MSB_LJUST (1 << 0)
64#define AINTFCE_FORMAT_I2S (2 << 0)
65#define AINTFCE_FORMAT_DSP (3 << 0)
66#define AINTFCE_FORMAT_MASK (3 << 0)
67#define AINTFCE_IWL_16BIT (0 << 2)
68#define AINTFCE_IWL_20BIT (1 << 2)
69#define AINTFCE_IWL_24BIT (2 << 2)
70#define AINTFCE_IWL_32BIT (3 << 2)
71#define AINTFCE_IWL_MASK (3 << 2)
72#define AINTFCE_LRP_I2S_RLO (0 << 4)
73#define AINTFCE_LRP_I2S_RHI (1 << 4)
74#define AINTFCE_DSP_MODE_B (0 << 4)
75#define AINTFCE_DSP_MODE_A (1 << 4)
76#define AINTFCE_LRSWAP (1 << 5)
77#define AINTFCE_MS (1 << 6)
78#define AINTFCE_BCLKINV (1 << 7)
79
80#define SAMPCTRL 0x08
81#define SAMPCTRL_USB (1 << 0)
82#define SAMPCTRL_BOSR_NOR_256fs (0 << 1)
83#define SAMPCTRL_BOSR_NOR_384fs (1 << 1)
84#define SAMPCTRL_BOSR_USB_250fs (0 << 1)
85#define SAMPCTRL_BOSR_USB_272fs (1 << 1)
86/* Bits 2-5:
87 * Sample rate setting are device-specific. See WM8721 datasheet
88 * for proper settings for the device's clocking */
89#define SAMPCTRL_SR_MASK (0xf << 2)
90#define SAMPCTRL_CLKIDIV2 (1 << 6)
91
92#define ACTIVECTRL 0x09
93#define ACTIVECTRL_ACTIVE (1 << 0)
94
95#define RESET 0x0f
96#define RESET_RESET 0x0
97
98/* SAMPCTRL values for the supported samplerates (24MHz MCLK/USB): */
99#define WM8721_USB24_8000HZ 0x4d
100#define WM8721_USB24_32000HZ 0x59
101#define WM8721_USB24_44100HZ 0x63
102#define WM8721_USB24_48000HZ 0x41
103#define WM8721_USB24_88200HZ 0x7f
104#define WM8721_USB24_96000HZ 0x5d
105
106#endif /* _WM8721_H */
diff --git a/firmware/export/wm8731.h b/firmware/export/wm8731.h
index 2ea479fff7..9d5b61833f 100644
--- a/firmware/export/wm8731.h
+++ b/firmware/export/wm8731.h
@@ -9,6 +9,8 @@
9 * 9 *
10 * Copyright (C) 2005 by Dave Chapman 10 * Copyright (C) 2005 by Dave Chapman
11 * 11 *
12 * Header file for WM8711/WM8721/WM8731 codecs.
13 *
12 * This program is free software; you can redistribute it and/or 14 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 15 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2 16 * as published by the Free Software Foundation; either version 2
@@ -31,105 +33,154 @@ extern int tenthdb2master(int db);
31extern void audiohw_set_master_vol(int vol_l, int vol_r); 33extern void audiohw_set_master_vol(int vol_l, int vol_r);
32extern void audiohw_set_sample_rate(int sampling_control); 34extern void audiohw_set_sample_rate(int sampling_control);
33 35
36/* Common register bits */
37#ifdef HAVE_WM8731
38#define WMC_IN_VOL_MASK 0x1f
39#define WMC_IN_VOL(x) ((x) & WMC_IN_VOL_MASK)
40#define WMC_IN_MUTE (1 << 7)
41#endif /* WM8731 */
42
43#define WMC_OUT_VOL_MASK 0x7f
44#define WMC_OUT_VOL(x) ((x) & WMC_OUT_VOL_MASK)
45#define WMC_OUT_ZCEN (1 << 7)
46
47#define WMC_BOTH (1 << 8)
48
34/* Register addresses and bits */ 49/* Register addresses and bits */
50#ifdef HAVE_WM8731
35#define LINVOL 0x00 51#define LINVOL 0x00
36#define LINVOL_MASK 0x1f 52#define LINVOL_DEFAULT 0x79
37#define LINVOL_LRINBOTH (1 << 8) 53/* Use IN common bits */
38#define LINVOL_LINMUTE (1 << 7)
39 54
40#define RINVOL 0x01 55#define RINVOL 0x01
41#define RINVOL_MASK 0x1f 56#define RINVOL_DEFAULT 0x79
42#define RINVOL_RINMUTE (1 << 7) 57/* Use IN common bits */
43#define RINVOL_RLINBOTH (1 << 8) 58#endif /* WM8731 */
44 59
45#define LOUTVOL 0x02 60#define LOUTVOL 0x02
46#define LOUTVOL_LHPVOL_MASK 0x7f 61#define LOUTVOL_DEFAULT 0x079
47#define LOUTVOL_LZCEN (1 << 7) 62/* Use OUT common bits */
48#define LOUTVOL_LRHP_BOTH (1 << 8)
49 63
50#define ROUTVOL 0x03 64#define ROUTVOL 0x03
51#define ROUTVOL_RHPVOL_MASK 0x7f 65#define ROUTVOL_DEFAULT 0x079
52#define ROUTVOL_RZCEN (1 << 7) 66/* Use OUT common bits */
53#define ROUTVOL_RLHP_BOTH (1 << 8)
54 67
55#define AAPCTRL 0x04 /* Analog audio path control */ 68#define AAPCTRL 0x04 /* Analog audio path control */
69#define AAPCTRL_DACSEL (1 << 4)
70#if defined(HAVE_WM8711)
71#define AAPCTRL_DEFAULT 0x008 /* BYPASS enabled */
72#define AAPCTRL_BYPASS (1 << 3)
73#elif defined(HAVE_WM8721)
74#define AAPCTRL_DEFAULT 0x000
75#elif defined(HAVE_WM8731)
76#define AAPCTRL_DEFAULT 0x00a /* BYPASS enabled, MUTEMIC */
56#define AAPCTRL_MIC_BOOST (1 << 0) 77#define AAPCTRL_MIC_BOOST (1 << 0)
57#define AAPCTRL_MUTEMIC (1 << 1) 78#define AAPCTRL_MUTEMIC (1 << 1)
58#define AAPCTRL_INSEL (1 << 2) 79#define AAPCTRL_INSEL (1 << 2)
59#define AAPCTRL_BYPASS (1 << 3) 80#define AAPCTRL_BYPASS (1 << 3)
60#define AAPCTRL_DACSEL (1 << 4)
61#define AAPCTRL_SIDETONE (1 << 5) 81#define AAPCTRL_SIDETONE (1 << 5)
62#define AAPCTRL_SIDEATT_6dB (3 << 6) 82#define AAPCTRL_SIDEATT_MASK (3 << 6)
83#define AAPCTRL_SIDEATT_6dB (0 << 6)
63#define AAPCTRL_SIDEATT_9dB (1 << 6) 84#define AAPCTRL_SIDEATT_9dB (1 << 6)
64#define AAPCTRL_SIDEATT_12dB (2 << 6) 85#define AAPCTRL_SIDEATT_12dB (2 << 6)
65#define AAPCTRL_SIDEATT_15dB (3 << 6) 86#define AAPCTRL_SIDEATT_15dB (3 << 6)
87#endif /* WM87x1 */
66 88
67#define DAPCTRL 0x05 /* Digital audio path control */ 89#define DAPCTRL 0x05 /* Digital audio path control */
68#define DAPCTRL_ADCHPD (1 << 0) 90#define DAPCTRL_DEFAULT 0x008
69#define DAPCTRL_DEEMP_DISABLE (0 << 1) 91#define DAPCTRL_DEEMP_DISABLE (0 << 1)
70#define DAPCTRL_DEEMP_32KHz (1 << 1) 92#define DAPCTRL_DEEMP_32KHz (1 << 1)
71#define DAPCTRL_DEEMP_44KHz (2 << 1) 93#define DAPCTRL_DEEMP_44KHz (2 << 1)
72#define DAPCTRL_DEEMP_48KHz (3 << 1) 94#define DAPCTRL_DEEMP_48KHz (3 << 1)
73#define DAPCTRL_DEEMP_MASK (3 << 1) 95#define DAPCTRL_DEEMP_MASK (3 << 1)
74#define DAPCTRL_DACMU (1 << 3) 96#define DAPCTRL_DACMU (1 << 3)
97#if defined(HAVE_WM8731)
98#define DAPCTRL_ADCHPD (1 << 0)
75#define DAPCTRL_HPOR (1 << 4) 99#define DAPCTRL_HPOR (1 << 4)
100#endif /* WM8731 */
76 101
77#define PDCTRL 0x06 102#define PDCTRL 0x06
103#define PDCTRL_DACPD (1 << 3)
104#define PDCTRL_OUTPD (1 << 4)
105#define PDCTRL_POWEROFF (1 << 7)
106#if defined(HAVE_WM8711)
107#define PDCTRL_DEFAULT 0x09f /* CLKPD, OSCPD not off */
108#define PDCTRL_OSCPD (1 << 5)
109#define PDCTRL_CLKOUTPD (1 << 6)
110/* These bits should always be '1' */
111#define PDCTRL_ALWAYS_SET 0x007
112#elif defined(HAVE_WM8721)
113#define PDCTRL_DEFAULT 0x0ff
114/* These bits should always be '1' */
115#define PDCTRL_ALWAYS_SET 0x067
116#elif defined(HAVE_WM8731)
117#define PDCTRL_DEFAULT 0x09f /* CLKPD, OSCPD not off */
78#define PDCTRL_LINEINPD (1 << 0) 118#define PDCTRL_LINEINPD (1 << 0)
79#define PDCTRL_MICPD (1 << 1) 119#define PDCTRL_MICPD (1 << 1)
80#define PDCTRL_ADCPD (1 << 2) 120#define PDCTRL_ADCPD (1 << 2)
81#define PDCTRL_DACPD (1 << 3)
82#define PDCTRL_OUTPD (1 << 4)
83#define PDCTRL_OSCPD (1 << 5) 121#define PDCTRL_OSCPD (1 << 5)
84#define PDCTRL_CLKOUTPD (1 << 6) 122#define PDCTRL_CLKOUTPD (1 << 6)
85#define PDCTRL_POWEROFF (1 << 7) 123/* These bits should always be '1' */
124#define PDCTRL_ALWAYS_SET 0x000
125#endif
86 126
87#define AINTFCE 0x07 127#define AINTFCE 0x07
128#define AINTFCE_DEFAULT 0x00a
88#define AINTFCE_FORMAT_MSB_RJUST (0 << 0) 129#define AINTFCE_FORMAT_MSB_RJUST (0 << 0)
89#define AINTFCE_FORMAT_MSB_LJUST (1 << 0) 130#define AINTFCE_FORMAT_MSB_LJUST (1 << 0)
90#define AINTFCE_FORMAT_I2S (2 << 0) 131#define AINTFCE_FORMAT_I2S (2 << 0)
91#define AINTFCE_FORMAT_DSP (3 << 0) 132#define AINTFCE_FORMAT_DSP (3 << 0)
92#define AINTFCE_FORMAT_MASK (3 << 0) 133#define AINTFCE_FORMAT_MASK (3 << 0)
93#define AINTFCE_IWL_16BIT (0 << 2) 134#define AINTFCE_IWL_16BIT (0 << 2)
94#define AINTFCE_IWL_20BIT (1 << 2) 135#define AINTFCE_IWL_20BIT (1 << 2)
95#define AINTFCE_IWL_24BIT (2 << 2) 136#define AINTFCE_IWL_24BIT (2 << 2)
96#define AINTFCE_IWL_32BIT (3 << 2) 137#define AINTFCE_IWL_32BIT (3 << 2)
97#define AINTFCE_IWL_MASK (3 << 2) 138#define AINTFCE_IWL_MASK (3 << 2)
98#define AINTFCE_LRP_I2S_RLO (0 << 4) 139#define AINTFCE_LRP_I2S_RLO (0 << 4)
99#define AINTFCE_LRP_I2S_RHI (1 << 4) 140#define AINTFCE_LRP_I2S_RHI (1 << 4)
100#define AINTFCE_DSP_MODE_B (0 << 4) 141#define AINTFCE_DSP_MODE_B (0 << 4)
101#define AINTFCE_DSP_MODE_A (1 << 4) 142#define AINTFCE_DSP_MODE_A (1 << 4)
102#define AINTFCE_LRSWAP (1 << 5) 143#define AINTFCE_LRSWAP (1 << 5)
103#define AINTFCE_MS (1 << 6) 144#define AINTFCE_MS (1 << 6)
104#define AINTFCE_BCLKINV (1 << 7) 145#define AINTFCE_BCLKINV (1 << 7)
105 146
106#define SAMPCTRL 0x08 147#define SAMPCTRL 0x08
148#define SAMPCTRL_DEFAULT 0x000
107#define SAMPCTRL_USB (1 << 0) 149#define SAMPCTRL_USB (1 << 0)
150/* For 88.2, 96 */
151#define SAMPCTRL_BOSR_NOR_128fs (0 << 1)
152#define SAMPCTRL_BOSR_NOR_192fs (1 << 1)
153/* */
108#define SAMPCTRL_BOSR_NOR_256fs (0 << 1) 154#define SAMPCTRL_BOSR_NOR_256fs (0 << 1)
109#define SAMPCTRL_BOSR_NOR_384fs (1 << 1) 155#define SAMPCTRL_BOSR_NOR_384fs (1 << 1)
110#define SAMPCTRL_BOSR_USB_250fs (0 << 1) 156#define SAMPCTRL_BOSR_USB_250fs (0 << 1)
111#define SAMPCTRL_BOSR_USB_272fs (1 << 1) 157#define SAMPCTRL_BOSR_USB_272fs (1 << 1)
112/* Bits 2-5: 158/* Bits 2-5:
113 * Sample rate setting are device-specific. See WM8731(L) datasheet 159 * Sample rate setting are device-specific.
114 * for proper settings for the device's clocking */ 160 * See WM8711/WM8721/WM8731 datasheet for proper settings for the
161 * device's clocking */
115#define SAMPCTRL_SR_MASK (0xf << 2) 162#define SAMPCTRL_SR_MASK (0xf << 2)
116#define SAMPCTRL_CLKIDIV2 (1 << 6) 163#define SAMPCTRL_CLKIDIV2 (1 << 6)
164#if defined(HAVE_WM8711) || defined(HAVE_WM8731)
117#define SAMPCTRL_CLKODIV2 (1 << 7) 165#define SAMPCTRL_CLKODIV2 (1 << 7)
166#endif
118 167
119#define ACTIVECTRL 0x09 168#define ACTIVECTRL 0x09
169#define ACTIVECTRL_DEFAULT 0x000
120#define ACTIVECTRL_ACTIVE (1 << 0) 170#define ACTIVECTRL_ACTIVE (1 << 0)
121 171
122#define RESET 0x0f 172#define RESET 0x0f
123#define RESET_RESET 0x0 173/* No reset default */
174#define RESET_RESET 0x000
124 175
125#define WM8731_NUM_REGS 0x0a /* RESET not included */ 176#define WMC_NUM_REGS 0x0a /* RESET not included */
126 177
127/* SAMPCTRL values for the supported samplerates (24MHz MCLK/USB): */ 178/* SAMPCTRL values for the supported samplerates (24MHz MCLK/USB): */
128#define WM8731_USB24_8000HZ 0x4d 179#define WMC_USB24_8000HZ 0x4d
129#define WM8731_USB24_32000HZ 0x59 180#define WMC_USB24_32000HZ 0x59
130#define WM8731_USB24_44100HZ 0x63 181#define WMC_USB24_44100HZ 0x63
131#define WM8731_USB24_48000HZ 0x41 182#define WMC_USB24_48000HZ 0x41
132#define WM8731_USB24_88200HZ 0x7f 183#define WMC_USB24_88200HZ 0x7f
133#define WM8731_USB24_96000HZ 0x5d 184#define WMC_USB24_96000HZ 0x5d
134 185
135#endif /* _WM8731_H */ 186#endif /* _WM8731_H */
diff --git a/firmware/sound.c b/firmware/sound.c
index 4d109b3900..fb377f6f6d 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -256,8 +256,9 @@ static void set_prescaled_volume(void)
256/* The WM codecs listed don't have suitable prescaler functionality, so we let 256/* The WM codecs listed don't have suitable prescaler functionality, so we let
257 * the prescaler stay at 0 for these unless SW tone controls are in use */ 257 * the prescaler stay at 0 for these unless SW tone controls are in use */
258#if defined(HAVE_SW_TONE_CONTROLS) || !(defined(HAVE_WM8975) \ 258#if defined(HAVE_SW_TONE_CONTROLS) || !(defined(HAVE_WM8975) \
259 || defined(HAVE_WM8731) || defined(HAVE_WM8721) || defined(HAVE_WM8751) \ 259 || defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \
260 || defined(HAVE_WM8758) || defined(HAVE_WM8985)) || defined(HAVE_TSC2100) 260 || defined(HAVE_WM8751) || defined(HAVE_WM8758) || defined(HAVE_WM8985)) \
261 || defined(HAVE_TSC2100)
261 262
262 prescale = MAX(current_bass, current_treble); 263 prescale = MAX(current_bass, current_treble);
263 if (prescale < 0) 264 if (prescale < 0)
@@ -298,8 +299,8 @@ static void set_prescaled_volume(void)
298#if CONFIG_CODEC == MAS3507D 299#if CONFIG_CODEC == MAS3507D
299 dac_volume(tenthdb2reg(l), tenthdb2reg(r), false); 300 dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
300#elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \ 301#elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \
301 || defined(HAVE_WM8731) || defined(HAVE_WM8721) || defined(HAVE_WM8751) \ 302 || defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \
302 || defined(HAVE_AS3514) || defined(HAVE_TSC2100) 303 || defined(HAVE_WM8751) || defined(HAVE_AS3514) || defined(HAVE_TSC2100)
303 audiohw_set_master_vol(tenthdb2master(l), tenthdb2master(r)); 304 audiohw_set_master_vol(tenthdb2master(l), tenthdb2master(r));
304#if defined(HAVE_WM8975) || defined(HAVE_WM8758) \ 305#if defined(HAVE_WM8975) || defined(HAVE_WM8758) \
305 || (defined(HAVE_WM8751) && !defined(MROBE_100)) \ 306 || (defined(HAVE_WM8751) && !defined(MROBE_100)) \
@@ -625,8 +626,11 @@ void sound_set(int setting, int value)
625 sound_set_val(value); 626 sound_set_val(value);
626} 627}
627 628
628#if (!defined(HAVE_AS3514) && !defined (HAVE_WM8731) && !defined(HAVE_WM8975) \ 629#if (!defined(HAVE_AS3514) && !defined(HAVE_WM8975) \
629 && !defined(HAVE_WM8758) && !defined(HAVE_TSC2100)) || defined(SIMULATOR) 630 && !defined(HAVE_WM8758) && !defined(HAVE_TSC2100) \
631 && !defined (HAVE_WM8711) && !defined (HAVE_WM8721) \
632 && !defined (HAVE_WM8731)) \
633 || defined(SIMULATOR)
630int sound_val2phys(int setting, int value) 634int sound_val2phys(int setting, int value)
631{ 635{
632#if CONFIG_CODEC == MAS3587F 636#if CONFIG_CODEC == MAS3587F
@@ -664,7 +668,8 @@ int sound_val2phys(int setting, int value)
664 break; 668 break;
665 } 669 }
666 return result; 670 return result;
667#elif defined(HAVE_TLV320) || defined(HAVE_WM8731) 671#elif defined(HAVE_TLV320) || defined(HAVE_WM8711) \
672 || defined(HAVE_WM8721) || defined(HAVE_WM8731)
668 int result = 0; 673 int result = 0;
669 674
670 switch(setting) 675 switch(setting)
diff --git a/firmware/target/arm/pcm-pp.c b/firmware/target/arm/pcm-pp.c
index 2c4a6ac87d..3157cffaec 100644
--- a/firmware/target/arm/pcm-pp.c
+++ b/firmware/target/arm/pcm-pp.c
@@ -112,7 +112,8 @@ void pcm_apply_settings(void)
112 audiohw_set_frequency(sr_ctrl); 112 audiohw_set_frequency(sr_ctrl);
113#endif 113#endif
114 114
115#if defined(HAVE_WM8731) || defined(HAVE_WM8721) 115#if defined(HAVE_WM8711) || defined(HAVE_WM8721) \
116 || defined(HAVE_WM8731)
116 audiohw_set_sample_rate(pcm_freq); 117 audiohw_set_sample_rate(pcm_freq);
117#endif 118#endif
118 pcm_curr_sampr = pcm_freq; 119 pcm_curr_sampr = pcm_freq;