Fix advanced EQ menu
[maemo-rb.git] / firmware / export / wm8731.h
blob28d4d3940d36ae9d26b682d3269758f1b2c48481
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 by Dave Chapman
12 * Header file for WM8711/WM8721/WM8731 codecs.
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 ****************************************************************************/
24 #ifndef _WM8731_H
25 #define _WM8731_H
27 /* volume/balance/treble/bass interdependency */
28 #define VOLUME_MIN -730
29 #define VOLUME_MAX 60
31 extern int tenthdb2master(int db);
33 extern void audiohw_set_master_vol(int vol_l, int vol_r);
35 /* Common register bits */
36 #ifdef HAVE_WM8731
37 #define WMC_IN_VOL_MASK 0x1f
38 #define WMC_IN_VOL(x) ((x) & WMC_IN_VOL_MASK)
39 #define WMC_IN_MUTE (1 << 7)
40 #endif /* WM8731 */
42 #define WMC_OUT_VOL_MASK 0x7f
43 #define WMC_OUT_VOL(x) ((x) & WMC_OUT_VOL_MASK)
44 #define WMC_OUT_ZCEN (1 << 7)
46 #define WMC_BOTH (1 << 8)
48 /* Register addresses and bits */
49 #ifdef HAVE_WM8731
50 #define LINVOL 0x00
51 #define LINVOL_DEFAULT 0x79
52 /* Use IN common bits */
54 #define RINVOL 0x01
55 #define RINVOL_DEFAULT 0x79
56 /* Use IN common bits */
57 #endif /* WM8731 */
59 #define LOUTVOL 0x02
60 #define LOUTVOL_DEFAULT 0x079
61 /* Use OUT common bits */
63 #define ROUTVOL 0x03
64 #define ROUTVOL_DEFAULT 0x079
65 /* Use OUT common bits */
67 #define AAPCTRL 0x04 /* Analog audio path control */
68 #define AAPCTRL_DACSEL (1 << 4)
69 #if defined(HAVE_WM8711)
70 #define AAPCTRL_DEFAULT 0x008 /* BYPASS enabled */
71 #define AAPCTRL_BYPASS (1 << 3)
72 #elif defined(HAVE_WM8721)
73 #define AAPCTRL_DEFAULT 0x000
74 #elif defined(HAVE_WM8731)
75 #define AAPCTRL_DEFAULT 0x00a /* BYPASS enabled, MUTEMIC */
76 #define AAPCTRL_MIC_BOOST (1 << 0)
77 #define AAPCTRL_MUTEMIC (1 << 1)
78 #define AAPCTRL_INSEL (1 << 2)
79 #define AAPCTRL_BYPASS (1 << 3)
80 #define AAPCTRL_SIDETONE (1 << 5)
81 #define AAPCTRL_SIDEATT_MASK (3 << 6)
82 #define AAPCTRL_SIDEATT_6dB (0 << 6)
83 #define AAPCTRL_SIDEATT_9dB (1 << 6)
84 #define AAPCTRL_SIDEATT_12dB (2 << 6)
85 #define AAPCTRL_SIDEATT_15dB (3 << 6)
86 #endif /* WM87x1 */
88 #define DAPCTRL 0x05 /* Digital audio path control */
89 #define DAPCTRL_DEFAULT 0x008
90 #define DAPCTRL_DEEMP_DISABLE (0 << 1)
91 #define DAPCTRL_DEEMP_32KHz (1 << 1)
92 #define DAPCTRL_DEEMP_44KHz (2 << 1)
93 #define DAPCTRL_DEEMP_48KHz (3 << 1)
94 #define DAPCTRL_DEEMP_MASK (3 << 1)
95 #define DAPCTRL_DACMU (1 << 3)
96 #if defined(HAVE_WM8731)
97 #define DAPCTRL_ADCHPD (1 << 0)
98 #define DAPCTRL_HPOR (1 << 4)
99 #endif /* WM8731 */
101 #define PDCTRL 0x06
102 #define PDCTRL_DACPD (1 << 3)
103 #define PDCTRL_OUTPD (1 << 4)
104 #define PDCTRL_POWEROFF (1 << 7)
105 #if defined(HAVE_WM8711)
106 #define PDCTRL_DEFAULT 0x09f /* CLKPD, OSCPD not off */
107 #define PDCTRL_OSCPD (1 << 5)
108 #define PDCTRL_CLKOUTPD (1 << 6)
109 /* These bits should always be '1' */
110 #define PDCTRL_ALWAYS_SET 0x007
111 #elif defined(HAVE_WM8721)
112 #define PDCTRL_DEFAULT 0x0ff
113 /* These bits should always be '1' */
114 #define PDCTRL_ALWAYS_SET 0x067
115 #elif defined(HAVE_WM8731)
116 #define PDCTRL_DEFAULT 0x09f /* CLKPD, OSCPD not off */
117 #define PDCTRL_LINEINPD (1 << 0)
118 #define PDCTRL_MICPD (1 << 1)
119 #define PDCTRL_ADCPD (1 << 2)
120 #define PDCTRL_OSCPD (1 << 5)
121 #define PDCTRL_CLKOUTPD (1 << 6)
122 /* These bits should always be '1' */
123 #define PDCTRL_ALWAYS_SET 0x000
124 #endif
126 #define AINTFCE 0x07
127 #define AINTFCE_DEFAULT 0x00a
128 #define AINTFCE_FORMAT_MSB_RJUST (0 << 0)
129 #define AINTFCE_FORMAT_MSB_LJUST (1 << 0)
130 #define AINTFCE_FORMAT_I2S (2 << 0)
131 #define AINTFCE_FORMAT_DSP (3 << 0)
132 #define AINTFCE_FORMAT_MASK (3 << 0)
133 #define AINTFCE_IWL_16BIT (0 << 2)
134 #define AINTFCE_IWL_20BIT (1 << 2)
135 #define AINTFCE_IWL_24BIT (2 << 2)
136 #define AINTFCE_IWL_32BIT (3 << 2)
137 #define AINTFCE_IWL_MASK (3 << 2)
138 #define AINTFCE_LRP_I2S_RLO (0 << 4)
139 #define AINTFCE_LRP_I2S_RHI (1 << 4)
140 #define AINTFCE_DSP_MODE_B (0 << 4)
141 #define AINTFCE_DSP_MODE_A (1 << 4)
142 #define AINTFCE_LRSWAP (1 << 5)
143 #define AINTFCE_MS (1 << 6)
144 #define AINTFCE_BCLKINV (1 << 7)
146 #define SAMPCTRL 0x08
147 #define SAMPCTRL_DEFAULT 0x000
148 #define SAMPCTRL_USB (1 << 0)
149 /* For 88.2, 96 */
150 #define SAMPCTRL_BOSR_NOR_128fs (0 << 1)
151 #define SAMPCTRL_BOSR_NOR_192fs (1 << 1)
152 /* */
153 #define SAMPCTRL_BOSR_NOR_256fs (0 << 1)
154 #define SAMPCTRL_BOSR_NOR_384fs (1 << 1)
155 #define SAMPCTRL_BOSR_USB_250fs (0 << 1)
156 #define SAMPCTRL_BOSR_USB_272fs (1 << 1)
157 /* Bits 2-5:
158 * Sample rate setting are device-specific.
159 * See WM8711/WM8721/WM8731 datasheet for proper settings for the
160 * device's clocking */
161 #define SAMPCTRL_SR_MASK (0xf << 2)
162 #define SAMPCTRL_CLKIDIV2 (1 << 6)
163 #if defined(HAVE_WM8711) || defined(HAVE_WM8731)
164 #define SAMPCTRL_CLKODIV2 (1 << 7)
165 #endif
167 #define ACTIVECTRL 0x09
168 #define ACTIVECTRL_DEFAULT 0x000
169 #define ACTIVECTRL_ACTIVE (1 << 0)
171 #define RESET 0x0f
172 /* No reset default */
173 #define RESET_RESET 0x000
175 #define WMC_NUM_REGS 0x0a /* RESET not included */
177 /* SAMPCTRL values for the supported samplerates (24MHz MCLK/USB): */
178 #define WMC_USB24_8000HZ 0x4d
179 #define WMC_USB24_32000HZ 0x59
180 #define WMC_USB24_44100HZ 0x63
181 #define WMC_USB24_48000HZ 0x41
182 #define WMC_USB24_88200HZ 0x7f
183 #define WMC_USB24_96000HZ 0x5d
185 #endif /* _WM8731_H */