Fix typo.
[Rockbox.git] / firmware / export / uda1380.h
blobb4b83d1ee99f7cff22d5f351a8951e8d79d041f8
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #ifndef _UDA1380_H
21 #define _UDA1380_H
23 /* volume/balance/treble/bass interdependency */
24 #define VOLUME_MIN -840
25 #define VOLUME_MAX 0
27 extern int tenthdb2master(int db);
28 extern int tenthdb2mixer(int db);
30 extern void audiohw_reset(void);
31 extern void audiohw_enable_output(bool enable);
32 extern int audiohw_set_master_vol(int vol_l, int vol_r);
33 extern int audiohw_set_mixer_vol(int channel1, int channel2);
34 extern void audiohw_set_bass(int value);
35 extern void audiohw_set_treble(int value);
37 /**
38 * Sets frequency settings for DAC and ADC relative to MCLK
40 * Selection for frequency ranges:
41 * Fs: range: with:
42 * 11025: 0 = 6.25 to 12.5 SCLK, LRCK: Audio Clk / 16
43 * 22050: 1 = 12.5 to 25 SCLK, LRCK: Audio Clk / 8
44 * 44100: 2 = 25 to 50 SCLK, LRCK: Audio Clk / 4 (default)
45 * 88200: 3 = 50 to 100 SCLK, LRCK: Audio Clk / 2
47 extern void audiohw_set_frequency(unsigned fsel);
48 extern void audiohw_enable_recording(bool source_mic);
49 extern void audiohw_disable_recording(void);
50 extern void audiohw_set_recvol(int left, int right, int type);
51 extern void audiohw_set_monitor(int enable);
53 #define UDA1380_ADDR 0x30
55 /* REG_0: Misc settings */
56 #define REG_0 0x00
57 #define EN_ADC (1 << 11) /* Enable ADC */
58 #define EN_DEC (1 << 10) /* Enable Decimator */
59 #define EN_DAC (1 << 9) /* Enable DAC */
60 #define EN_INT (1 << 8) /* Enable Interpolator */
61 #define ADC_CLK (1 << 5) /* ADC_CLK: WSPLL (1) SYSCLK (0) */
62 #define DAC_CLK (1 << 4) /* DAC_CLK: WSPLL (1) SYSCLK (0) */
64 /* SYSCLK freqency select */
65 #define SYSCLK_256FS (0 << 2)
66 #define SYSCLK_384FS (1 << 2)
67 #define SYSCLK_512FS (2 << 2)
68 #define SYSCLK_768FS (3 << 2)
70 /* WSPLL Input frequency range (kHz) */
71 #define WSPLL_625_125 (0 << 0) /* 6.25 - 12.5 */
72 #define WSPLL_125_25 (1 << 0) /* 12.5 - 25 */
73 #define WSPLL_25_50 (2 << 0) /* 25 - 50 */
74 #define WSPLL_50_100 (3 << 0) /* 50 - 100 */
77 /* REG_I2S: I2S settings */
78 #define REG_I2S 0x01
79 #define I2S_IFMT_IIS (0 << 8)
80 #define I2S_IFMT_LSB16 (1 << 8)
81 #define I2S_IFMT_LSB18 (2 << 8)
82 #define I2S_IFMT_LSB20 (3 << 8)
83 #define I2S_IFMT_MSB (5 << 8)
84 #define I2S_OFMT_IIS (0 << 0)
85 #define I2S_OFMT_LSB16 (1 << 0)
86 #define I2S_OFMT_LSB18 (2 << 0)
87 #define I2S_OFMT_LSB20 (3 << 0)
88 #define I2S_OFMT_LSB24 (4 << 0)
89 #define I2S_OFMT_MSB (5 << 0)
90 #define I2S_MODE_MASTER (1 << 4)
92 /* REG_PWR: Power control */
93 #define REG_PWR 0x02
94 #define PON_PLL (1 << 15) /* Power-on WSPLL */
95 #define PON_HP (1 << 13) /* Power-on Headphone driver */
96 #define PON_DAC (1 << 10) /* Power-on DAC */
97 #define PON_BIAS (1 << 8) /* Power-on BIAS for ADC, AVC, FSDAC */
98 #define EN_AVC (1 << 7) /* Enable analog mixer */
99 #define PON_AVC (1 << 6) /* Power-on analog mixer */
100 #define PON_LNA (1 << 4) /* Power-on LNA & SDC */
101 #define PON_PGAL (1 << 3) /* Power-on PGA left */
102 #define PON_ADCL (1 << 2) /* Power-on ADC left */
103 #define PON_PGAR (1 << 1) /* Power-on PGA right */
104 #define PON_ADCR (1 << 0) /* Power-on ADC right */
107 /* REG_AMIX: Analog mixer */
108 #define REG_AMIX 0x03
109 #define AMIX_LEFT(x) (((x) & 0x3f) << 8)
110 #define AMIX_RIGHT(x) (((x) & 0x3f) << 0)
112 /* REG_HP: Headphone amp */
113 #define REG_HP 0x04
115 /* REG_MV: Master Volume control */
116 #define REG_MASTER_VOL 0x10
118 #define MASTER_VOL_RIGHT(x) (((x) & 0xff) << 8)
119 #define MASTER_VOL_LEFT(x) (((x) & 0xff) << 0)
121 /* REG_MIX: Mixer volume control */
122 /* Channel 1 is from digital data from I2S */
123 /* Channel 2 is from decimation filter */
125 #define REG_MIX_VOL 0x11
126 #define MIX_VOL_CH_1(x) (((x) & 0xff) << 0)
127 #define MIX_VOL_CH_2(x) (((x) & 0xff) << 8)
129 /* REG_EQ: Bass boost and tremble */
130 #define REG_EQ 0x12
131 #define EQ_MODE_FLAT (0 << 14)
132 #define EQ_MODE_MIN (1 << 14)
133 #define EQ_MODE_MAX (3 << 14)
134 #define BASSL(x) (((x) & 0x1E) << 7)
135 #define BASSR(x) (((x) & 0x1E) >> 1)
136 #define TREBLEL(x) (((x) & 0x6) << 11)
137 #define TREBLER(x) (((x) & 0x6) << 3)
138 #define BASS_MASK 0x0F0F
139 #define TREBLE_MASK 0x3030
141 /* REG_MUTE: Master Mute, silence detector and oversampling */
142 #define REG_MUTE 0x13
143 #define MUTE_MASTER (1 << 14) /* Master Mute (soft) */
144 #define MUTE_CH2 (1 << 11) /* Channel 2 mute */
145 #define MUTE_CH1 (1 << 3) /* Channel 1 mute */
146 #define DE_EMPHASIS_NONE (0 << 8) /* no de-emphasis */
147 #define DE_EMPHASIS_32kHz (1 << 8) /* 32 kHz */
148 #define DE_EMPHASIS_44kHz (2 << 8) /* 44.1 kHz */
149 #define DE_EMPHASIS_48kHz (3 << 8) /* 48 kHz */
150 #define DE_EMPHASIS_96kHz (4 << 8) /* 96 kHz */
152 /* REG_MIX_CTL: Mixer, silence detector and oversampling settings */
153 #define REG_MIX_CTL 0x14
154 #define DAC_INVERT (1 << 15) /* invert DAC polarity */
155 #define MIX_CTL_SEL_NS (1 << 14) /* 0 = 3rd, 1 = 5th order */
156 #define MIX_CTL_MIX_POS (1 << 13) /* MIX MODE bit MIX POS */
157 #define MIX_CTL_MIX (1 << 12) /* MIX MODE bit MIX */
158 #define MIX_MODE(x) (((x) & 0x3) << 12) /* Mixer mode: See table 48 */
159 #define SILENCE_MODE (1 << 7) /* force silence output */
160 #define SILENCE_DET_ON (1 << 6) /* enable silence detection */
161 #define SILENCE_DET(x) (((x) & 0x3) << 4) /* silence detection value */
162 #define SILENCE_DET_3200 (0 << 4) /* 3200 samples */
163 #define SILENCE_DET_4800 (1 << 4) /* 4800 samples */
164 #define SILENCE_DET_9600 (2 << 4) /* 9600 samples */
165 #define SILENCE_DET_19200 (3 << 4) /* 19200 samples */
166 #define OVERSAMPLE_MODE(x) (((x) & 0x3) << 0) /* oversampling mode */
168 /* REG_DEC_VOL: Decimator (ADC) volume control */
169 #define REG_DEC_VOL 0x20
170 #define DEC_VOLL(x) (((x) & 0xff) << 8)
171 #define DEC_VOLR(x) (((x) & 0xff) << 0)
173 /* REG_PGA: PGA settings and mute */
174 #define REG_PGA 0x21
175 #define MUTE_ADC (1 << 15) /* Mute ADC */
176 #define PGA_GAINR(x) (((x) & 0xF) << 8)
177 #define PGA_GAINL(x) (((x) & 0xF) << 0)
178 #define PGA_GAIN_MASK 0x0F0F
180 /* REG_ADC: */
181 #define REG_ADC 0x22
182 #define ADC_INVERT (1 << 12) /* invert ADC polarity */
183 #define VGA_GAIN(x) (((x) & 0xF) << 8)
184 #define VGA_GAIN_MASK 0x0F00
185 #define SEL_LNA (1 << 3)
186 #define SEL_MIC (1 << 2)
187 #define SKIP_DCFIL (1 << 1)
188 #define EN_DCFIL (1 << 0)
190 /* REG_AGC: Attack / Gain */
191 #define REG_AGC 0x23
193 #endif /* _UDA_1380_H */