Bring consistency to pcm implementation and samplerate handling. Less low-level dupli...
[kugel-rb.git] / firmware / export / wm8731.h
blob512ef9ff3f7bde03b50d92e6b85f3e8be122a335
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);
34 extern void audiohw_set_frequency(int fsel);
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 */
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)
47 #define WMC_BOTH (1 << 8)
49 /* Register addresses and bits */
50 #ifdef HAVE_WM8731
51 #define LINVOL 0x00
52 #define LINVOL_DEFAULT 0x79
53 /* Use IN common bits */
55 #define RINVOL 0x01
56 #define RINVOL_DEFAULT 0x79
57 /* Use IN common bits */
58 #endif /* WM8731 */
60 #define LOUTVOL 0x02
61 #define LOUTVOL_DEFAULT 0x079
62 /* Use OUT common bits */
64 #define ROUTVOL 0x03
65 #define ROUTVOL_DEFAULT 0x079
66 /* Use OUT common bits */
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 */
77 #define AAPCTRL_MIC_BOOST (1 << 0)
78 #define AAPCTRL_MUTEMIC (1 << 1)
79 #define AAPCTRL_INSEL (1 << 2)
80 #define AAPCTRL_BYPASS (1 << 3)
81 #define AAPCTRL_SIDETONE (1 << 5)
82 #define AAPCTRL_SIDEATT_MASK (3 << 6)
83 #define AAPCTRL_SIDEATT_6dB (0 << 6)
84 #define AAPCTRL_SIDEATT_9dB (1 << 6)
85 #define AAPCTRL_SIDEATT_12dB (2 << 6)
86 #define AAPCTRL_SIDEATT_15dB (3 << 6)
87 #endif /* WM87x1 */
89 #define DAPCTRL 0x05 /* Digital audio path control */
90 #define DAPCTRL_DEFAULT 0x008
91 #define DAPCTRL_DEEMP_DISABLE (0 << 1)
92 #define DAPCTRL_DEEMP_32KHz (1 << 1)
93 #define DAPCTRL_DEEMP_44KHz (2 << 1)
94 #define DAPCTRL_DEEMP_48KHz (3 << 1)
95 #define DAPCTRL_DEEMP_MASK (3 << 1)
96 #define DAPCTRL_DACMU (1 << 3)
97 #if defined(HAVE_WM8731)
98 #define DAPCTRL_ADCHPD (1 << 0)
99 #define DAPCTRL_HPOR (1 << 4)
100 #endif /* WM8731 */
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 */
118 #define PDCTRL_LINEINPD (1 << 0)
119 #define PDCTRL_MICPD (1 << 1)
120 #define PDCTRL_ADCPD (1 << 2)
121 #define PDCTRL_OSCPD (1 << 5)
122 #define PDCTRL_CLKOUTPD (1 << 6)
123 /* These bits should always be '1' */
124 #define PDCTRL_ALWAYS_SET 0x000
125 #endif
127 #define AINTFCE 0x07
128 #define AINTFCE_DEFAULT 0x00a
129 #define AINTFCE_FORMAT_MSB_RJUST (0 << 0)
130 #define AINTFCE_FORMAT_MSB_LJUST (1 << 0)
131 #define AINTFCE_FORMAT_I2S (2 << 0)
132 #define AINTFCE_FORMAT_DSP (3 << 0)
133 #define AINTFCE_FORMAT_MASK (3 << 0)
134 #define AINTFCE_IWL_16BIT (0 << 2)
135 #define AINTFCE_IWL_20BIT (1 << 2)
136 #define AINTFCE_IWL_24BIT (2 << 2)
137 #define AINTFCE_IWL_32BIT (3 << 2)
138 #define AINTFCE_IWL_MASK (3 << 2)
139 #define AINTFCE_LRP_I2S_RLO (0 << 4)
140 #define AINTFCE_LRP_I2S_RHI (1 << 4)
141 #define AINTFCE_DSP_MODE_B (0 << 4)
142 #define AINTFCE_DSP_MODE_A (1 << 4)
143 #define AINTFCE_LRSWAP (1 << 5)
144 #define AINTFCE_MS (1 << 6)
145 #define AINTFCE_BCLKINV (1 << 7)
147 #define SAMPCTRL 0x08
148 #define SAMPCTRL_DEFAULT 0x000
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 /* */
154 #define SAMPCTRL_BOSR_NOR_256fs (0 << 1)
155 #define SAMPCTRL_BOSR_NOR_384fs (1 << 1)
156 #define SAMPCTRL_BOSR_USB_250fs (0 << 1)
157 #define SAMPCTRL_BOSR_USB_272fs (1 << 1)
158 /* Bits 2-5:
159 * Sample rate setting are device-specific.
160 * See WM8711/WM8721/WM8731 datasheet for proper settings for the
161 * device's clocking */
162 #define SAMPCTRL_SR_MASK (0xf << 2)
163 #define SAMPCTRL_CLKIDIV2 (1 << 6)
164 #if defined(HAVE_WM8711) || defined(HAVE_WM8731)
165 #define SAMPCTRL_CLKODIV2 (1 << 7)
166 #endif
168 #define ACTIVECTRL 0x09
169 #define ACTIVECTRL_DEFAULT 0x000
170 #define ACTIVECTRL_ACTIVE (1 << 0)
172 #define RESET 0x0f
173 /* No reset default */
174 #define RESET_RESET 0x000
176 #define WMC_NUM_REGS 0x0a /* RESET not included */
178 /* SAMPCTRL values for the supported samplerates (24MHz MCLK/USB): */
179 #define WMC_USB24_8000HZ 0x4d
180 #define WMC_USB24_32000HZ 0x59
181 #define WMC_USB24_44100HZ 0x63
182 #define WMC_USB24_48000HZ 0x41
183 #define WMC_USB24_88200HZ 0x7f
184 #define WMC_USB24_96000HZ 0x5d
186 #endif /* _WM8731_H */