xref: /freebsd/sys/dev/sound/macio/davbusreg.h (revision aa24f48b361effe51163877d84f1b70d32b77e04)
1 /*-
2  * Copyright 2008 by Marco Trillo. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
20  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  *
25  * $FreeBSD$
26  */
27 
28 /*
29  *	Apple DAVbus audio controller.
30  */
31 
32 #ifndef _SOUND_DAVBUS_H
33 #define _SOUND_DAVBUS_H
34 
35 /* DAVbus controller registers. */
36 #define DAVBUS_SOUND_CTRL	0x00
37 #define DAVBUS_CODEC_CTRL	0x10
38 #define DAVBUS_CODEC_STATUS	0x20
39 #define DAVBUS_CLIP_COUNT	0x30
40 #define DAVBUS_BYTE_SWAP	0x40
41 
42 /*
43  * The DAVbus uses a serial bus time multiplexed in four subframes,
44  * but the controller itself uses subframe 0 to communicate with the codec.
45  * In some machines, the other subframes may be used by external devices
46  * thorugh the DAV interface.
47  */
48 /* DAVBUS_SOUND_CTRL bit definitions. */
49 #define DAVBUS_INPUT_SUBFRAME0	0x00000001
50 #define DAVBUS_INPUT_SUBFRAME1	0x00000002
51 #define DAVBUS_INPUT_SUBFRAME2	0x00000004
52 #define DAVBUS_INPUT_SUBFRAME3	0x00000008
53 
54 #define DAVBUS_OUTPUT_SUBFRAME0	0x00000010
55 #define DAVBUS_OUTPUT_SUBFRAME1	0x00000020
56 #define DAVBUS_OUTPUT_SUBFRAME2	0x00000040
57 #define DAVBUS_OUTPUT_SUBFRAME3	0x00000080
58 
59 #define DAVBUS_RATE_44100	0x00000000
60 #define DAVBUS_RATE_29400	0x00000100
61 #define DAVBUS_RATE_22050	0x00000200
62 #define DAVBUS_RATE_17640	0x00000300
63 #define DAVBUS_RATE_14700	0x00000400
64 #define DAVBUS_RATE_11025	0x00000500
65 #define DAVBUS_RATE_8820	0x00000600
66 #define DAVBUS_RATE_7350	0x00000700
67 #define DAVBUS_RATE_MASK	0x00000700
68 
69 #define DAVBUS_ERROR		0x00000800
70 #define DAVBUS_PORTCHG		0x00001000
71 #define DAVBUS_INTR_ERROR	0x00002000	/* interrupt on error */
72 #define DAVBUS_INTR_PORTCHG	0x00004000	/* interrupt on port change */
73 
74 #define DAVBUS_STATUS_SUBFRAME	0x00018000	/* mask */
75 
76 /* DAVBUS_CODEC_CTRL bit definitions. */
77 #define DAVBUS_CODEC_BUSY	0x01000000
78 
79 
80 /*
81  * Burgundy Codec Control Bits
82  */
83 
84 /* Burgundy transaction bits. */
85 #define BURGUNDY_CTRL_RESET	0x00100000
86 #define BURGUNDY_CTRL_WRITE	0x00200000
87 
88 /* Mute control for each analog output port. */
89 #define BURGUNDY_MUTE_REG	0x16000
90 #define BURGUNDY_P13M_EN	0x01
91 #define BURGUNDY_P14L_EN	0x02
92 #define BURGUNDY_P14R_EN	0x04
93 #define BURGUNDY_P15L_EN	0x08
94 #define BURGUNDY_P15R_EN	0x10
95 #define BURGUNDY_P16L_EN	0x20
96 #define BURGUNDY_P16R_EN	0x40
97 #define BURGUNDY_P17M_EN	0x80
98 
99 /* Attenuation of each analog output port. */
100 #define BURGUNDY_OL13_REG	0x16100
101 #define BURGUNDY_OL14_REG	0x16200
102 #define BURGUNDY_OL15_REG	0x16300
103 #define BURGUNDY_OL16_REG	0x16400
104 #define BURGUNDY_OL17_REG	0x16500
105 
106 /* Inputs of four digital mixers. */
107 #define BURGUNDY_MIX0_REG	0x42900
108 #define BURGUNDY_MIX1_REG	0x42A00
109 #define BURGUNDY_MIX2_REG	0x42B00
110 #define BURGUNDY_MIX3_REG	0x42C00
111 #define BURGUNDY_MIX_IS0	0x00010001
112 #define BURGUNDY_MIX_IS1	0x00020002
113 #define BURGUNDY_MIX_IS2	0x00040004
114 #define BURGUNDY_MIX_IS3	0x00080008
115 #define BURGUNDY_MIX_IS4	0x00100010
116 #define BURGUNDY_MIX_ISA	0x01000100 /* Digital stream ISA. */
117 #define BURGUNDY_MIX_ISB	0x02000200 /* Digital stream ISB. */
118 #define BURGUNDY_MIX_ISC	0x04000400 /* Digital stream ISC. */
119 #define BURGUNDY_MIX_ISD	0x08000800 /* Digital stream ISD. */
120 #define BURGUNDY_MIX_ISE	0x10001000 /* Digital stream ISE. */
121 #define BURGUNDY_MIX_ISF	0x20002000 /* Digital stream ISF. */
122 #define BURGUNDY_MIX_ISG	0x40004000 /* Digital stream ISG. */
123 #define BURGUNDY_MIX_ISH	0x80008000 /* Digital stream ISH. */
124 
125 /* A digital scalar at the output of each mixer. */
126 #define BURGUNDY_MXS0L_REG	0x12D00
127 #define BURGUNDY_MXS0R_REG	0x12D01
128 #define BURGUNDY_MXS1L_REG	0x12D02
129 #define BURGUNDY_MXS1R_REG	0x12D03
130 #define BURGUNDY_MXS2L_REG	0x12E00
131 #define BURGUNDY_MXS2R_REG	0x12E01
132 #define BURGUNDY_MXS3L_REG	0x12E02
133 #define BURGUNDY_MXS3R_REG	0x12E03
134 #define BURGUNDY_MXS_UNITY	0xDF
135 
136 /* Demultiplexer. Routes the mixer 0-3 (see above) to output sources.
137    Output sources 0-2 can be converted to analog. */
138 #define BURGUNDY_OS_REG		0x42F00
139 #define BURGUNDY_OS0_MIX0	0x00000000
140 #define BURGUNDY_OS0_MIX1	0x00000001
141 #define BURGUNDY_OS0_MIX2	0x00000002
142 #define BURGUNDY_OS0_MIX3	0x00000003
143 #define BURGUNDY_OS1_MIX0       0x00000000
144 #define BURGUNDY_OS1_MIX1       0x00000004
145 #define BURGUNDY_OS1_MIX2       0x00000008
146 #define BURGUNDY_OS1_MIX3       0x0000000C
147 #define BURGUNDY_OS2_MIX0       0x00000000
148 #define BURGUNDY_OS2_MIX1       0x00000010
149 #define BURGUNDY_OS2_MIX2       0x00000020
150 #define BURGUNDY_OS2_MIX3       0x00000030
151 #define BURGUNDY_OS3_MIX0       0x00000000
152 #define BURGUNDY_OS3_MIX1       0x00000040
153 #define BURGUNDY_OS3_MIX2       0x00000080
154 #define BURGUNDY_OS3_MIX3       0x000000C0
155 #define BURGUNDY_OSA_MIX0	0x00000000
156 #define BURGUNDY_OSA_MIX1	0x00010000
157 #define BURGUNDY_OSA_MIX2	0x00020000
158 #define BURGUNDY_OSA_MIX3	0x00030000
159 #define BURGUNDY_OSB_MIX0       0x00000000
160 #define BURGUNDY_OSB_MIX1       0x00040000
161 #define BURGUNDY_OSB_MIX2	0x00080000
162 #define BURGUNDY_OSB_MIX3	0x000C0000
163 #define BURGUNDY_OSC_MIX0       0x00000000
164 #define BURGUNDY_OSC_MIX1       0x00100000
165 #define BURGUNDY_OSC_MIX2	0x00200000
166 #define BURGUNDY_OSC_MIX3	0x00300000
167 #define BURGUNDY_OSD_MIX0       0x00000000
168 #define BURGUNDY_OSD_MIX1       0x00400000
169 #define BURGUNDY_OSD_MIX2	0x00800000
170 #define BURGUNDY_OSD_MIX3	0x00C00000
171 #define BURGUNDY_OSE_MIX0       0x00000000
172 #define BURGUNDY_OSE_MIX1	0x01000000
173 #define BURGUNDY_OSE_MIX2	0x02000000
174 #define BURGUNDY_OSE_MIX3	0x03000000
175 #define BURGUNDY_OSF_MIX0       0x00000000
176 #define BURGUNDY_OSF_MIX1       0x04000000
177 #define BURGUNDY_OSF_MIX2	0x08000000
178 #define BURGUNDY_OSF_MIX3	0x0C000000
179 #define BURGUNDY_OSG_MIX0       0x00000000
180 #define BURGUNDY_OSG_MIX1       0x10000000
181 #define BURGUNDY_OSG_MIX2	0x20000000
182 #define BURGUNDY_OSG_MIX3	0x30000000
183 #define BURGUNDY_OSH_MIX0       0x00000000
184 #define BURGUNDY_OSH_MIX1       0x40000000
185 #define BURGUNDY_OSH_MIX2	0x80000000
186 #define BURGUNDY_OSH_MIX3	0xC0000000
187 
188 /* A digital scalar for output sources 0 to 3. */
189 #define BURGUNDY_OSS0L_REG	0x13000
190 #define BURGUNDY_OSS0R_REG	0x13001
191 #define BURGUNDY_OSS1L_REG	0x13002
192 #define BURGUNDY_OSS1R_REG	0x13003
193 #define BURGUNDY_OSS2L_REG	0x13100
194 #define BURGUNDY_OSS2R_REG	0x13101
195 #define BURGUNDY_OSS3L_REG	0x13102
196 #define BURGUNDY_OSS3R_REG	0x13103
197 #define BURGUNDY_OSS_UNITY	0xDF
198 
199 /* Digital input streams ISA-ISC. A stream may be derived from data coming
200    from the controller in subframes 0 to 3 as well as from internal
201    output sources OSA-OSD. */
202 #define BURGUNDY_SDIN_REG	0x17800
203 #define BURGUNDY_ISA_SF0	0x00
204 #define BURGUNDY_ISA_OSA	0x02
205 #define BURGUNDY_ISB_SF1	0x00
206 #define BURGUNDY_ISB_OSB	0x08
207 #define BURGUNDY_ISC_SF2	0x00
208 #define BURGUNDY_ISC_OSC	0x20
209 #define BURGUNDY_ISD_SF3	0x00
210 #define BURGUNDY_ISD_OSD	0x80
211 
212 /* A digital scaler for input streams 0-4 A-H. */
213 #define BURGUNDY_ISSAL_REG	0x12500
214 #define BURGUNDY_ISSAR_REG	0x12501
215 #define BURGUNDY_ISS_UNITY	0xDF
216 
217 /*
218  * Screamer codec control bits
219  * This codec has the following 12-bit control registers:
220  *	cc0 cc1 cc2 cc4 cc5 cc6 cc7
221  */
222 
223 /* screamer transaction bits. */
224 #define SCREAMER_CODEC_ADDR0	0x00000000
225 #define SCREAMER_CODEC_ADDR1	0x00001000
226 #define SCREAMER_CODEC_ADDR2	0x00002000
227 #define SCREAMER_CODEC_ADDR4	0x00004000
228 #define SCREAMER_CODEC_ADDR5	0x00005000
229 #define SCREAMER_CODEC_ADDR6	0x00006000
230 #define SCREAMER_CODEC_ADDR7	0x00007000
231 #define SCREAMER_CODEC_EMSEL0	0x00000000
232 #define SCREAMER_CODEC_EMSEL1	0x00400000
233 #define SCREAMER_CODEC_EMSEL2	0x00800000
234 #define SCREAMER_CODEC_EMSEL4	0x00c00000
235 
236 
237 /* cc0 */
238 /*
239  * Bits 7-4 specify the left ADC input gain;
240  * bits 3-0 specify the right ADC input gain.
241  *
242  * The gain is a 4-bit value expressed in units of 1.5 dB,
243  * ranging from 0 dB (0) to +22.5 dB (15).
244  */
245 #define SCREAMER_DEFAULT_CD_GAIN	0x000000bb /* +16.5 dB */
246 #define SCREAMER_INPUT_CD		0x00000200
247 #define SCREAMER_INPUT_LINE		0x00000400
248 #define SCREAMER_INPUT_MICROPHONE	0x00000800
249 #define SCREAMER_INPUT_MASK		0x00000e00
250 
251 /* cc1 */
252 #define SCREAMER_LOOP_THROUGH		0x00000040
253 #define SCREAMER_MUTE_SPEAKER		0x00000080
254 #define SCREAMER_MUTE_HEADPHONES	0x00000200
255 #define SCREAMER_PARALLEL_OUTPUT	0x00000c00
256 #define SCREAMER_PROG_OUTPUT0      	0x00000400
257 #define SCREAMER_PROG_OUTPUT1      	0x00000800
258 
259 /* cc2: headphones/external port attenuation */
260 /* cc4: internal speaker attenuation */
261 /*
262  * Bits 9-6 specify left DAC output attenuation.
263  * Bits 3-0 specify right DAC output attenuation.
264  *
265  * The attenuation is a 4-bit value expressed in units of -1.5 dB,
266  * ranging from 0 dB (0) to -22.5 dB (15).
267  */
268 
269 /* screamer codec status bits. */
270 #define SCREAMER_STATUS_MASK 	0x00FFFFFF
271 #define SCREAMER_STATUS_SENSEMASK 	0x0000000F
272 #define  SCREAMER_STATUS_SENSE0 	0x00000008
273 #define  SCREAMER_STATUS_SENSE1 	0x00000004
274 #define  SCREAMER_STATUS_SENSE2 	0x00000002
275 #define  SCREAMER_STATUS_SENSE3 	0x00000001
276 #define SCREAMER_STATUS_PARTMASK	0x00000300
277 #define SCREAMER_STATUS_PARTSHFT	8
278 #define  SCREAMER_PART_CRYSTAL	0x00000100
279 #define  SCREAMER_PART_NATIONAL	0x00000200
280 #define  SCREAMER_PART_TI		0x00000300
281 #define SCREAMER_STATUS_REVMASK	0x0000F000
282 #define SCREAMER_STATUS_REVSHFT	12
283 
284 #endif /* _SOUND_DAVBUS_H */
285 
286