1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Dave Chapman
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
24 /* volume/balance/treble/bass interdependency */
25 #define VOLUME_MIN -730
28 /* turn off 3D Enchance feature of WM8750 for now
29 #if defined(HAVE_WM8750)
30 #define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP | PRESCALER_CAP | DEPTH_3D_CAP)
33 #define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP | PRESCALER_CAP)
36 extern int tenthdb2master(int db
);
38 extern void audiohw_set_master_vol(int vol_l
, int vol_r
);
39 extern void audiohw_set_lineout_vol(int vol_l
, int vol_r
);
40 #if defined(HAVE_WM8750) && defined(HAVE_RECORDING)
41 void audiohw_set_recsrc(int source
, bool recording
);
44 /* Register addresses and bits */
45 #define OUTPUT_MUTED 0x2f
46 #define OUTPUT_0DB 0x79
48 #if defined(HAVE_WM8750)
50 #define LINVOL_LINVOL(x) ((x) & 0x3f)
51 #define LINVOL_LIZC (1 << 6)
52 #define LINVOL_LINMUTE (1 << 7)
53 #define LINVOL_LIVU (1 << 8)
56 #define RINVOL_RINVOL(x) ((x) & 0x3f)
57 #define RINVOL_RIZC (1 << 6)
58 #define RINVOL_RINMUTE (1 << 7)
59 #define RINVOL_RIVU (1 << 8)
63 #define LOUT1_LOUT1VOL_MASK (0x07f << 0)
64 #define LOUT1_LOUT1VOL(x) ((x) & 0x7f)
65 #define LOUT1_LO1ZC (1 << 7)
66 #define LOUT1_LO1VU (1 << 8)
69 #define ROUT1_ROUT1VOL(x) ((x) & 0x7f)
70 #define ROUT1_RO1ZC (1 << 7)
71 #define ROUT1_RO1VU (1 << 8)
74 #define DACCTRL_DEEMPH_NONE (0 << 1)
75 #define DACCTRL_DEEMPH_32 (1 << 1)
76 #define DACCTRL_DEEMPH_44 (2 << 1)
77 #define DACCTRL_DEEMPH_48 (3 << 1)
78 #define DACCTRL_DEEMPH(x) ((x) & (0x3 << 1))
79 #define DACCTRL_DACMU (1 << 3)
80 #define DACCTRL_DAT (1 << 7)
83 #define AINTFCE_FORMAT_RJUST (0 << 0)
84 #define AINTFCE_FORMAT_LJUST (1 << 0)
85 #define AINTFCE_FORMAT_I2S (2 << 0)
86 #define AINTFCE_FORMAT_DSP (3 << 0)
87 #define AINTFCE_FORMAT(x) ((x) & 0x3)
88 #define AINTFCE_WL_16 (0 << 2)
89 #define AINTFCE_WL_20 (1 << 2)
90 #define AINTFCE_WL_24 (2 << 2)
91 #define AINTFCE_WL_32 (3 << 2)
92 #define AINTFCE_WL(x) ((x) & (0x3 << 2))
93 #define AINTFCE_LRP (1 << 4)
94 #define AINTFCE_LRSWAP (1 << 5)
95 #define AINTFCE_MS (1 << 6)
96 #define AINTFCE_BCLKINV (1 << 7)
99 #define CLOCKING_SR_USB (1 << 0)
100 #define CLOCKING_SR(x) ((x) & (0x1f << 1))
101 #define CLOCKING_MCLK_DIV2 (1 << 6)
102 #define CLOCKING_BCLK_DIV2 (1 << 7)
104 #define LEFTGAIN 0x0a
105 #define LEFTGAIN_LDACVOL 0xff
106 #define LEFTGAIN_LDVU (1 << 8)
108 #define RIGHTGAIN 0x0b
109 #define RIGHTGAIN_RDACVOL 0xff
110 #define RIGHTGAIN_RDVU (1 << 8)
112 #define BASSCTRL 0x0c
113 #define BASSCTRL_BASS(x) ((x) & 0xf)
114 #define BASSCTRL_BC (1 << 6)
115 #define BASSCTRL_BB (1 << 7)
117 #define TREBCTRL 0x0d
118 #define TREBCTRL_TREB(x) ((x) & 0xf)
119 #define TREBCTRL_TC (1 << 6)
122 #define RESET_RESET 0x000
124 #if defined(HAVE_WM8750)
125 #define ENHANCE_3D 0x10
126 #define ENHANCE_3D_3DEN (1 << 0)
127 #define ENHANCE_3D_DEPTH(x) (((x) & 0xf) << 1)
128 #define ENHANCE_3D_3DLC (1 << 5)
129 #define ENHANCE_3D_3DUC (1 << 6)
130 #define ENHANCE_3D_MODE3D_PLAYBACK (1 << 7)
131 #define ENHANCE_3D_MODE3D_RECORD (0 << 7)
134 #define ALC1_ALCL(x) ((x) & (0x0f))
135 #define ALC1_MAXGAIN(x) ((x) & (0x07 << 4))
136 #define ALC1_ALCSEL_DISABLED (0 << 7)
137 #define ALC1_ALCSEL_RIGHT (1 << 7)
138 #define ALC1_ALCSEL_LEFT (2 << 7)
139 #define ALC1_ALCSEL_STEREO (3 << 7)
142 #define ALC2_HLD(x) ((x) & 0x0f)
143 #define ALC2_ALCZC (1 << 7)
146 #define ALC3_ATK(x) ((x) & 0x0f)
147 #define ALC3_DCY(x) ((x) & (0x0f << 4))
150 #define NGAT_NGAT (1 << 0)
151 #define NGAT_NGG_CONST (0 << 1)
152 #define NGAT_NGG_MUTEADC (1 << 1)
153 #define NGAT_NGG(x) ((x) & (0x3 << 1))
154 #define NGAT_NGTH(x) ((x) & (0x1f << 3))
157 #define ADDITIONAL1 0x17
158 #define ADDITIONAL1_TOEN (1 << 0)
159 #define ADDITIONAL1_DACINV (1 << 1)
160 #define ADDITIONAL1_DMONOMIX_LLRR (0 << 4)
161 #define ADDITIONAL1_DMONOMIX_ML0R (1 << 4)
162 #define ADDITIONAL1_DMONOMIX_0LMR (2 << 4)
163 #define ADDITIONAL1_DMONOMIX_MLMR (3 << 4)
164 #define ADDITIONAL1_DMONOMIX(x) ((x) & (0x03 << 4))
165 #define ADDITIONAL1_VSEL_LOWEST (0 << 6)
166 #define ADDITIONAL1_VSEL_LOW (1 << 6)
167 #define ADDITIONAL1_VSEL_DEFAULT2 (2 << 6)
168 #define ADDITIONAL1_VSEL_DEFAULT (3 << 6)
169 #define ADDITIONAL1_VSEL(x) ((x) & (0x3 << 6))
170 #define ADDITIONAL1_TSDEN (1 << 8)
172 #define ADDITIONAL2 0x18
173 #define ADDITIONAL2_DACOSR (1 << 0)
174 #define ADDITIONAL2_HPSWZC (1 << 3)
175 #define ADDITIONAL2_ROUT2INV (1 << 4)
176 #define ADDITIONAL2_HPSWPOL (1 << 5)
177 #define ADDITIONAL2_HPSWEN (1 << 6)
178 #define ADDITIONAL2_OUT3SW_VREF (0 << 7)
179 #define ADDITIONAL2_OUT3SW_ROUT1 (1 << 7)
180 #define ADDITIONAL2_OUT3SW_MONOOUT (2 << 7)
181 #define ADDITIONAL2_OUT3SW_R_MIX_OUT (3 << 7)
182 #define ADDITIONAL2_OUT3SW(x) ((x) & (0x3 << 7))
184 #define PWRMGMT1 0x19
185 #define PWRMGMT1_DIGENB (1 << 0)
186 #if defined(HAVE_WM8750)
187 #define PWRMGMT1_MICBIAS (1 << 1)
188 #define PWRMGMT1_ADCR (1 << 2)
189 #define PWRMGMT1_ADCL (1 << 3)
190 #define PWRMGMT1_AINR (1 << 4)
191 #define PWRMGMT1_AINL (1 << 5)
193 #define PWRMGMT1_VREF (1 << 6)
194 #define PWRMGMT1_VMIDSEL_DISABLED (0 << 7)
195 #define PWRMGMT1_VMIDSEL_50K (1 << 7)
196 #define PWRMGMT1_VMIDSEL_500K (2 << 7)
197 #define PWRMGMT1_VMIDSEL_5K (3 << 7)
198 #define PWRMGMT1_VMIDSEL(x) ((x) & (0x3 << 7))
200 #define PWRMGMT2 0x1a
201 #define PWRMGMT2_OUT3 (1 << 1)
202 #define PWRMGMT2_MOUT (1 << 2)
203 #define PWRMGMT2_ROUT2 (1 << 3)
204 #define PWRMGMT2_LOUT2 (1 << 4)
205 #define PWRMGMT2_ROUT1 (1 << 5)
206 #define PWRMGMT2_LOUT1 (1 << 6)
207 #define PWRMGMT2_DACR (1 << 7)
208 #define PWRMGMT2_DACL (1 << 8)
210 #define ADDITIONAL3 0x1b
211 #define ADDITIONAL3_ADCLRM ((x) & (0x3 << 7))
212 #define ADDITIONAL3_HPFLREN (1 << 5)
213 #define ADDITIONAL3_VROI (1 << 6)
215 #if defined(HAVE_WM8750)
217 #define ADCIM_LDCM (1 << 4)
218 #define ADCIM_RDCM (1 << 5)
219 #define ADCIM_MONOMIX_STEREO (0 << 6)
220 #define ADCIM_MONOMIX_AMONOL (1 << 6)
221 #define ADCIM_MONOMIX_AMONOR (2 << 6)
222 #define ADCIM_MONOMIX_DMONO (3 << 6)
223 #define ADCIM_MONOMIX(x) ((x) & (0x3 << 6))
224 #define ADCIM_DS (1 << 8)
227 #define ADCL_LMICBOOST_DISABLED (0 << 4)
228 #define ADCL_LMICBOOST_13DB (1 << 4)
229 #define ADCL_LMICBOOST_20DB (2 << 4)
230 #define ADCL_LMICBOOST_29DB (3 << 4)
231 #define ADCL_LMICBOOST(x) (((x) & 0x3) << 4))
232 #define ADCL_LINSEL_LINPUT1 (0 << 6)
233 #define ADCL_LINSEL_LINPUT2 (1 << 6)
234 #define ADCL_LINSEL_LINPUT3 (2 << 6)
235 #define ADCL_LINSEL_DIFF (3 << 6)
238 #define ADCR_RMICBOOST_DISABLED (0 << 4)
239 #define ADCR_RMICBOOST_13DB (1 << 4)
240 #define ADCR_RMICBOOST_20DB (2 << 4)
241 #define ADCR_RMICBOOST_29DB (3 << 4)
242 #define ADCR_RMICBOOST(x) ((x) & (0x3 << 7))
243 #define ADCR_RINSEL_RINPUT1 (0 << 6)
244 #define ADCR_RINSEL_RINPUT2 (1 << 6)
245 #define ADCR_RINSEL_RINPUT3 (2 << 6)
246 #define ADCR_RINSEL_DIFF (3 << 6)
249 #define LEFTMIX1 0x22
250 #if defined(HAVE_WM8750)
251 #define LEFTMIX1_LMIXSEL_LINPUT1 (0 << 0)
252 #define LEFTMIX1_LMIXSEL_LINPUT2 (1 << 0)
253 #define LEFTMIX1_LMIXSEL_LINPUT3 (2 << 0)
254 #define LEFTMIX1_LMIXSEL_ADCLIN (3 << 0)
255 #define LEFTMIX1_LMIXSEL_DIFF (4 << 0)
257 #define LEFTMIX1_LI2LO_DEFAULT (5 << 4)
258 #define LEFTMIX1_LI2LOVOL(x) ((x) & (0x7 << 4))
259 #define LEFTMIX1_LI2LO (1 << 7)
260 #define LEFTMIX1_LD2LO (1 << 8)
262 #define LEFTMIX2 0x23
263 #define LEFTMIX2_MI2LO_DEFAULT (5 << 4)
264 #define LEFTMIX2_MI2LOVOL(x) ((x) & (0x7 << 4))
265 #if defined(HAVE_WM8750)
266 #define LEFTMIX2_RI2LO (1 << 7)
267 #elif defined(HAVE_WM8751)
268 #define LEFTMIX2_MI2LO (1 << 7)
270 #define LEFTMIX2_RD2LO (1 << 8)
272 #define RIGHTMIX1 0x24
273 #if defined(HAVE_WM8750)
274 #define RIGHTMIX1_RMIXSEL_RINPUT1 (0 << 0)
275 #define RIGHTMIX1_RMIXSEL_RINPUT2 (1 << 0)
276 #define RIGHTMIX1_RMIXSEL_RINPUT3 (2 << 0)
277 #define RIGHTMIX1_RMIXSEL_ADCRIN (3 << 0)
278 #define RIGHTMIX1_RMIXSEL_DIFF (4 << 0)
279 #define RIGHTMIX1_LI2RO_DEFAULT (5 << 4)
280 #define RIGHTMIX1_LI2ROVOL(x) ((x) & (0x7 << 4))
281 #define RIGHTMIX1_LI2RO (1 << 7)
282 #define RIGHTMIX1_LD2RO (1 << 8)
283 #elif defined(HAVE_WM8751)
284 #define RIGHTMIX1_MI2RO_DEFAULT (5 << 4)
285 #define RIGHTMIX1_MI2ROVOL(x) ((x) & (0x7 << 4))
286 #define RIGHTMIX1_MI2RO (1 << 7)
287 #define RIGHTMIX1_LD2RO (1 << 8)
290 #define RIGHTMIX2 0x25
291 #if defined(HAVE_WM8750)
292 #define RIGHTMIX2_RMIXSEL_RINPUT1 (0 << 0)
293 #define RIGHTMIX2_RMIXSEL_RINPUT2 (1 << 0)
294 #define RIGHTMIX2_RMIXSEL_RINPUT3 (2 << 0)
295 #define RIGHTMIX2_RMIXSEL_ADCRIN (3 << 0)
296 #define RIGHTMIX2_RMIXSEL_DIFF (4 << 0)
298 #define RIGHTMIX2_RI2RO_DEFAULT (5 << 4)
299 #define RIGHTMIX2_RI2ROVOL(x) ((x) & (0x7 << 4))
300 #define RIGHTMIX2_RI2RO (1 << 7)
301 #define RIGHTMIX2_RD2RO (1 << 8)
303 #define MONOMIX1 0x26
304 #define MONOMIX1_DMEN (1 << 0)
305 #define MONOMIX1_LI2MOVOL(x) ((x) & (0x7 << 4))
306 #define MONOMIX1_LI2MO (1 << 7)
307 #define MONOMIX1_LD2MO (1 << 8)
309 #define MONOMIX2 0x27
310 #define MONOMIX2_RI2MOVOL(x) ((x) & (0x7 << 4))
311 #define MONOMIX2_RI2MO (1 << 7)
312 #define MONOMIX2_RD2MO (1 << 8)
315 #define LOUT2_LOUT2VOL(x) ((x) & 0x7f)
316 #define LOUT2_LO2ZC (1 << 7)
317 #define LOUT2_LO2VU (1 << 8)
320 #define ROUT2_ROUT2VOL(x) ((x) & 0x7f)
321 #define ROUT2_RO2ZC (1 << 7)
322 #define ROUT2_RO2VU (1 << 8)
325 #define MONOOUT_MOZC (1 << 7)
327 #endif /* _WM8751_H */