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