18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk>
48c2ecf20Sopenharmony_ci *  Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit
58c2ecf20Sopenharmony_ci *  Version: 0.0.22
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci *  FEATURES currently supported:
88c2ecf20Sopenharmony_ci *    See ca0106_main.c for features.
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci *  Changelog:
118c2ecf20Sopenharmony_ci *    Support interrupts per period.
128c2ecf20Sopenharmony_ci *    Removed noise from Center/LFE channel when in Analog mode.
138c2ecf20Sopenharmony_ci *    Rename and remove mixer controls.
148c2ecf20Sopenharmony_ci *  0.0.6
158c2ecf20Sopenharmony_ci *    Use separate card based DMA buffer for periods table list.
168c2ecf20Sopenharmony_ci *  0.0.7
178c2ecf20Sopenharmony_ci *    Change remove and rename ctrls into lists.
188c2ecf20Sopenharmony_ci *  0.0.8
198c2ecf20Sopenharmony_ci *    Try to fix capture sources.
208c2ecf20Sopenharmony_ci *  0.0.9
218c2ecf20Sopenharmony_ci *    Fix AC3 output.
228c2ecf20Sopenharmony_ci *    Enable S32_LE format support.
238c2ecf20Sopenharmony_ci *  0.0.10
248c2ecf20Sopenharmony_ci *    Enable playback 48000 and 96000 rates. (Rates other that these do not work, even with "plug:front".)
258c2ecf20Sopenharmony_ci *  0.0.11
268c2ecf20Sopenharmony_ci *    Add Model name recognition.
278c2ecf20Sopenharmony_ci *  0.0.12
288c2ecf20Sopenharmony_ci *    Correct interrupt timing. interrupt at end of period, instead of in the middle of a playback period.
298c2ecf20Sopenharmony_ci *    Remove redundent "voice" handling.
308c2ecf20Sopenharmony_ci *  0.0.13
318c2ecf20Sopenharmony_ci *    Single trigger call for multi channels.
328c2ecf20Sopenharmony_ci *  0.0.14
338c2ecf20Sopenharmony_ci *    Set limits based on what the sound card hardware can do.
348c2ecf20Sopenharmony_ci *    playback periods_min=2, periods_max=8
358c2ecf20Sopenharmony_ci *    capture hw constraints require period_size = n * 64 bytes.
368c2ecf20Sopenharmony_ci *    playback hw constraints require period_size = n * 64 bytes.
378c2ecf20Sopenharmony_ci *  0.0.15
388c2ecf20Sopenharmony_ci *    Separated ca0106.c into separate functional .c files.
398c2ecf20Sopenharmony_ci *  0.0.16
408c2ecf20Sopenharmony_ci *    Implement 192000 sample rate.
418c2ecf20Sopenharmony_ci *  0.0.17
428c2ecf20Sopenharmony_ci *    Add support for SB0410 and SB0413.
438c2ecf20Sopenharmony_ci *  0.0.18
448c2ecf20Sopenharmony_ci *    Modified Copyright message.
458c2ecf20Sopenharmony_ci *  0.0.19
468c2ecf20Sopenharmony_ci *    Added I2C and SPI registers. Filled in interrupt enable.
478c2ecf20Sopenharmony_ci *  0.0.20
488c2ecf20Sopenharmony_ci *    Added GPIO info for SB Live 24bit.
498c2ecf20Sopenharmony_ci *  0.0.21
508c2ecf20Sopenharmony_ci *   Implement support for Line-in capture on SB Live 24bit.
518c2ecf20Sopenharmony_ci *  0.0.22
528c2ecf20Sopenharmony_ci *    Add support for mute control on SB Live 24bit (cards w/ SPI DAC)
538c2ecf20Sopenharmony_ci *
548c2ecf20Sopenharmony_ci *  This code was initially based on code from ALSA's emu10k1x.c which is:
558c2ecf20Sopenharmony_ci *  Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com>
568c2ecf20Sopenharmony_ci */
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci/************************************************************************************************/
598c2ecf20Sopenharmony_ci/* PCI function 0 registers, address = <val> + PCIBASE0						*/
608c2ecf20Sopenharmony_ci/************************************************************************************************/
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci#define PTR			0x00		/* Indexed register set pointer register	*/
638c2ecf20Sopenharmony_ci						/* NOTE: The CHANNELNUM and ADDRESS words can	*/
648c2ecf20Sopenharmony_ci						/* be modified independently of each other.	*/
658c2ecf20Sopenharmony_ci						/* CNL[1:0], ADDR[27:16]                        */
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci#define DATA			0x04		/* Indexed register set data register		*/
688c2ecf20Sopenharmony_ci						/* DATA[31:0]					*/
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci#define IPR			0x08		/* Global interrupt pending register		*/
718c2ecf20Sopenharmony_ci						/* Clear pending interrupts by writing a 1 to	*/
728c2ecf20Sopenharmony_ci						/* the relevant bits and zero to the other bits	*/
738c2ecf20Sopenharmony_ci#define IPR_MIDI_RX_B		0x00020000	/* MIDI UART-B Receive buffer non-empty		*/
748c2ecf20Sopenharmony_ci#define IPR_MIDI_TX_B		0x00010000	/* MIDI UART-B Transmit buffer empty		*/
758c2ecf20Sopenharmony_ci#define IPR_SPDIF_IN_USER	0x00004000      /* SPDIF input user data has 16 more bits	*/
768c2ecf20Sopenharmony_ci#define IPR_SPDIF_OUT_USER	0x00002000      /* SPDIF output user data needs 16 more bits	*/
778c2ecf20Sopenharmony_ci#define IPR_SPDIF_OUT_FRAME	0x00001000      /* SPDIF frame about to start			*/
788c2ecf20Sopenharmony_ci#define IPR_SPI			0x00000800      /* SPI transaction completed			*/
798c2ecf20Sopenharmony_ci#define IPR_I2C_EEPROM		0x00000400      /* I2C EEPROM transaction completed		*/
808c2ecf20Sopenharmony_ci#define IPR_I2C_DAC		0x00000200      /* I2C DAC transaction completed		*/
818c2ecf20Sopenharmony_ci#define IPR_AI			0x00000100      /* Audio pending register changed. See PTR reg 0x76	*/
828c2ecf20Sopenharmony_ci#define IPR_GPI			0x00000080      /* General Purpose input changed		*/
838c2ecf20Sopenharmony_ci#define IPR_SRC_LOCKED          0x00000040      /* SRC lock status changed			*/
848c2ecf20Sopenharmony_ci#define IPR_SPDIF_STATUS        0x00000020      /* SPDIF status changed				*/
858c2ecf20Sopenharmony_ci#define IPR_TIMER2              0x00000010      /* 192000Hz Timer				*/
868c2ecf20Sopenharmony_ci#define IPR_TIMER1              0x00000008      /* 44100Hz Timer				*/
878c2ecf20Sopenharmony_ci#define IPR_MIDI_RX_A		0x00000004	/* MIDI UART-A Receive buffer non-empty		*/
888c2ecf20Sopenharmony_ci#define IPR_MIDI_TX_A		0x00000002	/* MIDI UART-A Transmit buffer empty		*/
898c2ecf20Sopenharmony_ci#define IPR_PCI			0x00000001	/* PCI Bus error				*/
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci#define INTE			0x0c		/* Interrupt enable register			*/
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci#define INTE_MIDI_RX_B		0x00020000	/* MIDI UART-B Receive buffer non-empty		*/
948c2ecf20Sopenharmony_ci#define INTE_MIDI_TX_B		0x00010000	/* MIDI UART-B Transmit buffer empty		*/
958c2ecf20Sopenharmony_ci#define INTE_SPDIF_IN_USER	0x00004000      /* SPDIF input user data has 16 more bits	*/
968c2ecf20Sopenharmony_ci#define INTE_SPDIF_OUT_USER	0x00002000      /* SPDIF output user data needs 16 more bits	*/
978c2ecf20Sopenharmony_ci#define INTE_SPDIF_OUT_FRAME	0x00001000      /* SPDIF frame about to start			*/
988c2ecf20Sopenharmony_ci#define INTE_SPI		0x00000800      /* SPI transaction completed			*/
998c2ecf20Sopenharmony_ci#define INTE_I2C_EEPROM		0x00000400      /* I2C EEPROM transaction completed		*/
1008c2ecf20Sopenharmony_ci#define INTE_I2C_DAC		0x00000200      /* I2C DAC transaction completed		*/
1018c2ecf20Sopenharmony_ci#define INTE_AI			0x00000100      /* Audio pending register changed. See PTR reg 0x75 */
1028c2ecf20Sopenharmony_ci#define INTE_GPI		0x00000080      /* General Purpose input changed		*/
1038c2ecf20Sopenharmony_ci#define INTE_SRC_LOCKED         0x00000040      /* SRC lock status changed			*/
1048c2ecf20Sopenharmony_ci#define INTE_SPDIF_STATUS       0x00000020      /* SPDIF status changed				*/
1058c2ecf20Sopenharmony_ci#define INTE_TIMER2             0x00000010      /* 192000Hz Timer				*/
1068c2ecf20Sopenharmony_ci#define INTE_TIMER1             0x00000008      /* 44100Hz Timer				*/
1078c2ecf20Sopenharmony_ci#define INTE_MIDI_RX_A		0x00000004	/* MIDI UART-A Receive buffer non-empty		*/
1088c2ecf20Sopenharmony_ci#define INTE_MIDI_TX_A		0x00000002	/* MIDI UART-A Transmit buffer empty		*/
1098c2ecf20Sopenharmony_ci#define INTE_PCI		0x00000001	/* PCI Bus error				*/
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci#define UNKNOWN10		0x10		/* Unknown ??. Defaults to 0 */
1128c2ecf20Sopenharmony_ci#define HCFG			0x14		/* Hardware config register			*/
1138c2ecf20Sopenharmony_ci						/* 0x1000 causes AC3 to fails. It adds a dither bit. */
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci#define HCFG_STAC		0x10000000	/* Special mode for STAC9460 Codec. */
1168c2ecf20Sopenharmony_ci#define HCFG_CAPTURE_I2S_BYPASS	0x08000000	/* 1 = bypass I2S input async SRC. */
1178c2ecf20Sopenharmony_ci#define HCFG_CAPTURE_SPDIF_BYPASS 0x04000000	/* 1 = bypass SPDIF input async SRC. */
1188c2ecf20Sopenharmony_ci#define HCFG_PLAYBACK_I2S_BYPASS 0x02000000	/* 0 = I2S IN mixer output, 1 = I2S IN1. */
1198c2ecf20Sopenharmony_ci#define HCFG_FORCE_LOCK		0x01000000	/* For test only. Force input SRC tracker to lock. */
1208c2ecf20Sopenharmony_ci#define HCFG_PLAYBACK_ATTENUATION 0x00006000	/* Playback attenuation mask. 0 = 0dB, 1 = 6dB, 2 = 12dB, 3 = Mute. */
1218c2ecf20Sopenharmony_ci#define HCFG_PLAYBACK_DITHER	0x00001000	/* 1 = Add dither bit to all playback channels. */
1228c2ecf20Sopenharmony_ci#define HCFG_PLAYBACK_S32_LE	0x00000800	/* 1 = S32_LE, 0 = S16_LE                       */
1238c2ecf20Sopenharmony_ci#define HCFG_CAPTURE_S32_LE	0x00000400	/* 1 = S32_LE, 0 = S16_LE (S32_LE current not working)	*/
1248c2ecf20Sopenharmony_ci#define HCFG_8_CHANNEL_PLAY	0x00000200	/* 1 = 8 channels, 0 = 2 channels per substream.*/
1258c2ecf20Sopenharmony_ci#define HCFG_8_CHANNEL_CAPTURE	0x00000100	/* 1 = 8 channels, 0 = 2 channels per substream.*/
1268c2ecf20Sopenharmony_ci#define HCFG_MONO		0x00000080	/* 1 = I2S Input mono                           */
1278c2ecf20Sopenharmony_ci#define HCFG_I2S_OUTPUT		0x00000010	/* 1 = I2S Output disabled                      */
1288c2ecf20Sopenharmony_ci#define HCFG_AC97		0x00000008	/* 0 = AC97 1.0, 1 = AC97 2.0                   */
1298c2ecf20Sopenharmony_ci#define HCFG_LOCK_PLAYBACK_CACHE 0x00000004	/* 1 = Cancel bustmaster accesses to soundcache */
1308c2ecf20Sopenharmony_ci						/* NOTE: This should generally never be used.  	*/
1318c2ecf20Sopenharmony_ci#define HCFG_LOCK_CAPTURE_CACHE	0x00000002	/* 1 = Cancel bustmaster accesses to soundcache */
1328c2ecf20Sopenharmony_ci						/* NOTE: This should generally never be used.  	*/
1338c2ecf20Sopenharmony_ci#define HCFG_AUDIOENABLE	0x00000001	/* 0 = CODECs transmit zero-valued samples	*/
1348c2ecf20Sopenharmony_ci						/* Should be set to 1 when the EMU10K1 is	*/
1358c2ecf20Sopenharmony_ci						/* completely initialized.			*/
1368c2ecf20Sopenharmony_ci#define GPIO			0x18		/* Defaults: 005f03a3-Analog, 005f02a2-SPDIF.   */
1378c2ecf20Sopenharmony_ci						/* Here pins 0,1,2,3,4,,6 are output. 5,7 are input */
1388c2ecf20Sopenharmony_ci						/* For the Audigy LS, pin 0 (or bit 8) controls the SPDIF/Analog jack. */
1398c2ecf20Sopenharmony_ci						/* SB Live 24bit:
1408c2ecf20Sopenharmony_ci						 * bit 8 0 = SPDIF in and out / 1 = Analog (Mic or Line)-in.
1418c2ecf20Sopenharmony_ci						 * bit 9 0 = Mute / 1 = Analog out.
1428c2ecf20Sopenharmony_ci						 * bit 10 0 = Line-in / 1 = Mic-in.
1438c2ecf20Sopenharmony_ci						 * bit 11 0 = ? / 1 = ?
1448c2ecf20Sopenharmony_ci						 * bit 12 0 = 48 Khz / 1 = 96 Khz Analog out on SB Live 24bit.
1458c2ecf20Sopenharmony_ci						 * bit 13 0 = ? / 1 = ?
1468c2ecf20Sopenharmony_ci						 * bit 14 0 = Mute / 1 = Analog out
1478c2ecf20Sopenharmony_ci						 * bit 15 0 = ? / 1 = ?
1488c2ecf20Sopenharmony_ci						 * Both bit 9 and bit 14 have to be set for analog sound to work on the SB Live 24bit.
1498c2ecf20Sopenharmony_ci						 */
1508c2ecf20Sopenharmony_ci						/* 8 general purpose programmable In/Out pins.
1518c2ecf20Sopenharmony_ci						 * GPI [8:0] Read only. Default 0.
1528c2ecf20Sopenharmony_ci						 * GPO [15:8] Default 0x9. (Default to SPDIF jack enabled for SPDIF)
1538c2ecf20Sopenharmony_ci						 * GPO Enable [23:16] Default 0x0f. Setting a bit to 1, causes the pin to be an output pin.
1548c2ecf20Sopenharmony_ci						 */
1558c2ecf20Sopenharmony_ci#define AC97DATA		0x1c		/* AC97 register set data register (16 bit)	*/
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci#define AC97ADDRESS		0x1e		/* AC97 register set address register (8 bit)	*/
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci/********************************************************************************************************/
1608c2ecf20Sopenharmony_ci/* CA0106 pointer-offset register set, accessed through the PTR and DATA registers                     */
1618c2ecf20Sopenharmony_ci/********************************************************************************************************/
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci/* Initially all registers from 0x00 to 0x3f have zero contents. */
1648c2ecf20Sopenharmony_ci#define PLAYBACK_LIST_ADDR	0x00		/* Base DMA address of a list of pointers to each period/size */
1658c2ecf20Sopenharmony_ci						/* One list entry: 4 bytes for DMA address,
1668c2ecf20Sopenharmony_ci						 * 4 bytes for period_size << 16.
1678c2ecf20Sopenharmony_ci						 * One list entry is 8 bytes long.
1688c2ecf20Sopenharmony_ci						 * One list entry for each period in the buffer.
1698c2ecf20Sopenharmony_ci						 */
1708c2ecf20Sopenharmony_ci						/* ADDR[31:0], Default: 0x0 */
1718c2ecf20Sopenharmony_ci#define PLAYBACK_LIST_SIZE	0x01		/* Size of list in bytes << 16. E.g. 8 periods -> 0x00380000  */
1728c2ecf20Sopenharmony_ci						/* SIZE[21:16], Default: 0x8 */
1738c2ecf20Sopenharmony_ci#define PLAYBACK_LIST_PTR	0x02		/* Pointer to the current period being played */
1748c2ecf20Sopenharmony_ci						/* PTR[5:0], Default: 0x0 */
1758c2ecf20Sopenharmony_ci#define PLAYBACK_UNKNOWN3	0x03		/* Not used ?? */
1768c2ecf20Sopenharmony_ci#define PLAYBACK_DMA_ADDR	0x04		/* Playback DMA address */
1778c2ecf20Sopenharmony_ci						/* DMA[31:0], Default: 0x0 */
1788c2ecf20Sopenharmony_ci#define PLAYBACK_PERIOD_SIZE	0x05		/* Playback period size. win2000 uses 0x04000000 */
1798c2ecf20Sopenharmony_ci						/* SIZE[31:16], Default: 0x0 */
1808c2ecf20Sopenharmony_ci#define PLAYBACK_POINTER	0x06		/* Playback period pointer. Used with PLAYBACK_LIST_PTR to determine buffer position currently in DAC */
1818c2ecf20Sopenharmony_ci						/* POINTER[15:0], Default: 0x0 */
1828c2ecf20Sopenharmony_ci#define PLAYBACK_PERIOD_END_ADDR 0x07		/* Playback fifo end address */
1838c2ecf20Sopenharmony_ci						/* END_ADDR[15:0], FLAG[16] 0 = don't stop, 1 = stop */
1848c2ecf20Sopenharmony_ci#define PLAYBACK_FIFO_OFFSET_ADDRESS	0x08	/* Current fifo offset address [21:16] */
1858c2ecf20Sopenharmony_ci						/* Cache size valid [5:0] */
1868c2ecf20Sopenharmony_ci#define PLAYBACK_UNKNOWN9	0x09		/* 0x9 to 0xf Unused */
1878c2ecf20Sopenharmony_ci#define CAPTURE_DMA_ADDR	0x10		/* Capture DMA address */
1888c2ecf20Sopenharmony_ci						/* DMA[31:0], Default: 0x0 */
1898c2ecf20Sopenharmony_ci#define CAPTURE_BUFFER_SIZE	0x11		/* Capture buffer size */
1908c2ecf20Sopenharmony_ci						/* SIZE[31:16], Default: 0x0 */
1918c2ecf20Sopenharmony_ci#define CAPTURE_POINTER		0x12		/* Capture buffer pointer. Sample currently in ADC */
1928c2ecf20Sopenharmony_ci						/* POINTER[15:0], Default: 0x0 */
1938c2ecf20Sopenharmony_ci#define CAPTURE_FIFO_OFFSET_ADDRESS	0x13	/* Current fifo offset address [21:16] */
1948c2ecf20Sopenharmony_ci						/* Cache size valid [5:0] */
1958c2ecf20Sopenharmony_ci#define PLAYBACK_LAST_SAMPLE    0x20		/* The sample currently being played */
1968c2ecf20Sopenharmony_ci/* 0x21 - 0x3f unused */
1978c2ecf20Sopenharmony_ci#define BASIC_INTERRUPT         0x40		/* Used by both playback and capture interrupt handler */
1988c2ecf20Sopenharmony_ci						/* Playback (0x1<<channel_id) */
1998c2ecf20Sopenharmony_ci						/* Capture  (0x100<<channel_id) */
2008c2ecf20Sopenharmony_ci						/* Playback sample rate 96000 = 0x20000 */
2018c2ecf20Sopenharmony_ci						/* Start Playback [3:0] (one bit per channel)
2028c2ecf20Sopenharmony_ci						 * Start Capture [11:8] (one bit per channel)
2038c2ecf20Sopenharmony_ci						 * Playback rate [23:16] (2 bits per channel) (0=48kHz, 1=44.1kHz, 2=96kHz, 3=192Khz)
2048c2ecf20Sopenharmony_ci						 * Playback mixer in enable [27:24] (one bit per channel)
2058c2ecf20Sopenharmony_ci						 * Playback mixer out enable [31:28] (one bit per channel)
2068c2ecf20Sopenharmony_ci						 */
2078c2ecf20Sopenharmony_ci/* The Digital out jack is shared with the Center/LFE Analogue output.
2088c2ecf20Sopenharmony_ci * The jack has 4 poles. I will call 1 - Tip, 2 - Next to 1, 3 - Next to 2, 4 - Next to 3
2098c2ecf20Sopenharmony_ci * For Analogue: 1 -> Center Speaker, 2 -> Sub Woofer, 3 -> Ground, 4 -> Ground
2108c2ecf20Sopenharmony_ci * For Digital: 1 -> Front SPDIF, 2 -> Rear SPDIF, 3 -> Center/Subwoofer SPDIF, 4 -> Ground.
2118c2ecf20Sopenharmony_ci * Standard 4 pole Video A/V cable with RCA outputs: 1 -> White, 2 -> Yellow, 3 -> Shield on all three, 4 -> Red.
2128c2ecf20Sopenharmony_ci * So, from this you can see that you cannot use a Standard 4 pole Video A/V cable with the SB Audigy LS card.
2138c2ecf20Sopenharmony_ci */
2148c2ecf20Sopenharmony_ci/* The Front SPDIF PCM gets mixed with samples from the AC97 codec, so can only work for Stereo PCM and not AC3/DTS
2158c2ecf20Sopenharmony_ci * The Rear SPDIF can be used for Stereo PCM and also AC3/DTS
2168c2ecf20Sopenharmony_ci * The Center/LFE SPDIF cannot be used for AC3/DTS, but can be used for Stereo PCM.
2178c2ecf20Sopenharmony_ci * Summary: For ALSA we use the Rear channel for SPDIF Digital AC3/DTS output
2188c2ecf20Sopenharmony_ci */
2198c2ecf20Sopenharmony_ci/* A standard 2 pole mono mini-jack to RCA plug can be used for SPDIF Stereo PCM output from the Front channel.
2208c2ecf20Sopenharmony_ci * A standard 3 pole stereo mini-jack to 2 RCA plugs can be used for SPDIF AC3/DTS and Stereo PCM output utilising the Rear channel and just one of the RCA plugs.
2218c2ecf20Sopenharmony_ci */
2228c2ecf20Sopenharmony_ci#define SPCS0			0x41		/* SPDIF output Channel Status 0 register. For Rear. default=0x02108004, non-audio=0x02108006	*/
2238c2ecf20Sopenharmony_ci#define SPCS1			0x42		/* SPDIF output Channel Status 1 register. For Front */
2248c2ecf20Sopenharmony_ci#define SPCS2			0x43		/* SPDIF output Channel Status 2 register. For Center/LFE */
2258c2ecf20Sopenharmony_ci#define SPCS3			0x44		/* SPDIF output Channel Status 3 register. Unknown */
2268c2ecf20Sopenharmony_ci						/* When Channel set to 0: */
2278c2ecf20Sopenharmony_ci#define SPCS_CLKACCYMASK	0x30000000	/* Clock accuracy				*/
2288c2ecf20Sopenharmony_ci#define SPCS_CLKACCY_1000PPM	0x00000000	/* 1000 parts per million			*/
2298c2ecf20Sopenharmony_ci#define SPCS_CLKACCY_50PPM	0x10000000	/* 50 parts per million				*/
2308c2ecf20Sopenharmony_ci#define SPCS_CLKACCY_VARIABLE	0x20000000	/* Variable accuracy				*/
2318c2ecf20Sopenharmony_ci#define SPCS_SAMPLERATEMASK	0x0f000000	/* Sample rate					*/
2328c2ecf20Sopenharmony_ci#define SPCS_SAMPLERATE_44	0x00000000	/* 44.1kHz sample rate				*/
2338c2ecf20Sopenharmony_ci#define SPCS_SAMPLERATE_48	0x02000000	/* 48kHz sample rate				*/
2348c2ecf20Sopenharmony_ci#define SPCS_SAMPLERATE_32	0x03000000	/* 32kHz sample rate				*/
2358c2ecf20Sopenharmony_ci#define SPCS_CHANNELNUMMASK	0x00f00000	/* Channel number				*/
2368c2ecf20Sopenharmony_ci#define SPCS_CHANNELNUM_UNSPEC	0x00000000	/* Unspecified channel number			*/
2378c2ecf20Sopenharmony_ci#define SPCS_CHANNELNUM_LEFT	0x00100000	/* Left channel					*/
2388c2ecf20Sopenharmony_ci#define SPCS_CHANNELNUM_RIGHT	0x00200000	/* Right channel				*/
2398c2ecf20Sopenharmony_ci#define SPCS_SOURCENUMMASK	0x000f0000	/* Source number				*/
2408c2ecf20Sopenharmony_ci#define SPCS_SOURCENUM_UNSPEC	0x00000000	/* Unspecified source number			*/
2418c2ecf20Sopenharmony_ci#define SPCS_GENERATIONSTATUS	0x00008000	/* Originality flag (see IEC-958 spec)		*/
2428c2ecf20Sopenharmony_ci#define SPCS_CATEGORYCODEMASK	0x00007f00	/* Category code (see IEC-958 spec)		*/
2438c2ecf20Sopenharmony_ci#define SPCS_MODEMASK		0x000000c0	/* Mode (see IEC-958 spec)			*/
2448c2ecf20Sopenharmony_ci#define SPCS_EMPHASISMASK	0x00000038	/* Emphasis					*/
2458c2ecf20Sopenharmony_ci#define SPCS_EMPHASIS_NONE	0x00000000	/* No emphasis					*/
2468c2ecf20Sopenharmony_ci#define SPCS_EMPHASIS_50_15	0x00000008	/* 50/15 usec 2 channel				*/
2478c2ecf20Sopenharmony_ci#define SPCS_COPYRIGHT		0x00000004	/* Copyright asserted flag -- do not modify	*/
2488c2ecf20Sopenharmony_ci#define SPCS_NOTAUDIODATA	0x00000002	/* 0 = Digital audio, 1 = not audio		*/
2498c2ecf20Sopenharmony_ci#define SPCS_PROFESSIONAL	0x00000001	/* 0 = Consumer (IEC-958), 1 = pro (AES3-1992)	*/
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci						/* When Channel set to 1: */
2528c2ecf20Sopenharmony_ci#define SPCS_WORD_LENGTH_MASK	0x0000000f	/* Word Length Mask				*/
2538c2ecf20Sopenharmony_ci#define SPCS_WORD_LENGTH_16	0x00000008	/* Word Length 16 bit				*/
2548c2ecf20Sopenharmony_ci#define SPCS_WORD_LENGTH_17	0x00000006	/* Word Length 17 bit				*/
2558c2ecf20Sopenharmony_ci#define SPCS_WORD_LENGTH_18	0x00000004	/* Word Length 18 bit				*/
2568c2ecf20Sopenharmony_ci#define SPCS_WORD_LENGTH_19	0x00000002	/* Word Length 19 bit				*/
2578c2ecf20Sopenharmony_ci#define SPCS_WORD_LENGTH_20A	0x0000000a	/* Word Length 20 bit				*/
2588c2ecf20Sopenharmony_ci#define SPCS_WORD_LENGTH_20	0x00000009	/* Word Length 20 bit (both 0xa and 0x9 are 20 bit) */
2598c2ecf20Sopenharmony_ci#define SPCS_WORD_LENGTH_21	0x00000007	/* Word Length 21 bit				*/
2608c2ecf20Sopenharmony_ci#define SPCS_WORD_LENGTH_22	0x00000005	/* Word Length 22 bit				*/
2618c2ecf20Sopenharmony_ci#define SPCS_WORD_LENGTH_23	0x00000003	/* Word Length 23 bit				*/
2628c2ecf20Sopenharmony_ci#define SPCS_WORD_LENGTH_24	0x0000000b	/* Word Length 24 bit				*/
2638c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_MASK	0x000000f0 /* Original Sample rate			*/
2648c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_NONE	0x00000000 /* Original Sample rate not indicated	*/
2658c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_16000	0x00000010 /* Original Sample rate	*/
2668c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_RES1	0x00000020 /* Original Sample rate	*/
2678c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_32000	0x00000030 /* Original Sample rate	*/
2688c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_12000	0x00000040 /* Original Sample rate	*/
2698c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_11025	0x00000050 /* Original Sample rate	*/
2708c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_8000	0x00000060 /* Original Sample rate	*/
2718c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_RES2	0x00000070 /* Original Sample rate	*/
2728c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_192000 0x00000080 /* Original Sample rate	*/
2738c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_24000	0x00000090 /* Original Sample rate	*/
2748c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_96000	0x000000a0 /* Original Sample rate	*/
2758c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_48000	0x000000b0 /* Original Sample rate	*/
2768c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_176400 0x000000c0 /* Original Sample rate	*/
2778c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_22050	0x000000d0 /* Original Sample rate	*/
2788c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_88200	0x000000e0 /* Original Sample rate	*/
2798c2ecf20Sopenharmony_ci#define SPCS_ORIGINAL_SAMPLE_RATE_44100	0x000000f0 /* Original Sample rate	*/
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci#define SPDIF_SELECT1		0x45		/* Enables SPDIF or Analogue outputs 0-SPDIF, 0xf00-Analogue */
2828c2ecf20Sopenharmony_ci						/* 0x100 - Front, 0x800 - Rear, 0x200 - Center/LFE.
2838c2ecf20Sopenharmony_ci						 * But as the jack is shared, use 0xf00.
2848c2ecf20Sopenharmony_ci						 * The Windows2000 driver uses 0x0000000f for both digital and analog.
2858c2ecf20Sopenharmony_ci						 * 0xf00 introduces interesting noises onto the Center/LFE.
2868c2ecf20Sopenharmony_ci						 * If you turn the volume up, you hear computer noise,
2878c2ecf20Sopenharmony_ci						 * e.g. mouse moving, changing between app windows etc.
2888c2ecf20Sopenharmony_ci						 * So, I am going to set this to 0x0000000f all the time now,
2898c2ecf20Sopenharmony_ci						 * same as the windows driver does.
2908c2ecf20Sopenharmony_ci						 * Use register SPDIF_SELECT2(0x72) to switch between SPDIF and Analog.
2918c2ecf20Sopenharmony_ci						 */
2928c2ecf20Sopenharmony_ci						/* When Channel = 0:
2938c2ecf20Sopenharmony_ci						 * Wide SPDIF format [3:0] (one bit for each channel) (0=20bit, 1=24bit)
2948c2ecf20Sopenharmony_ci						 * Tristate SPDIF Output [11:8] (one bit for each channel) (0=Not tristate, 1=Tristate)
2958c2ecf20Sopenharmony_ci						 * SPDIF Bypass enable [19:16] (one bit for each channel) (0=Not bypass, 1=Bypass)
2968c2ecf20Sopenharmony_ci						 */
2978c2ecf20Sopenharmony_ci						/* When Channel = 1:
2988c2ecf20Sopenharmony_ci						 * SPDIF 0 User data [7:0]
2998c2ecf20Sopenharmony_ci						 * SPDIF 1 User data [15:8]
3008c2ecf20Sopenharmony_ci						 * SPDIF 0 User data [23:16]
3018c2ecf20Sopenharmony_ci						 * SPDIF 0 User data [31:24]
3028c2ecf20Sopenharmony_ci						 * User data can be sent by using the SPDIF output frame pending and SPDIF output user bit interrupts.
3038c2ecf20Sopenharmony_ci						 */
3048c2ecf20Sopenharmony_ci#define WATERMARK		0x46		/* Test bit to indicate cache usage level */
3058c2ecf20Sopenharmony_ci#define SPDIF_INPUT_STATUS	0x49		/* SPDIF Input status register. Bits the same as SPCS.
3068c2ecf20Sopenharmony_ci						 * When Channel = 0: Bits the same as SPCS channel 0.
3078c2ecf20Sopenharmony_ci						 * When Channel = 1: Bits the same as SPCS channel 1.
3088c2ecf20Sopenharmony_ci						 * When Channel = 2:
3098c2ecf20Sopenharmony_ci						 * SPDIF Input User data [16:0]
3108c2ecf20Sopenharmony_ci						 * SPDIF Input Frame count [21:16]
3118c2ecf20Sopenharmony_ci						 */
3128c2ecf20Sopenharmony_ci#define CAPTURE_CACHE_DATA	0x50		/* 0x50-0x5f Recorded samples. */
3138c2ecf20Sopenharmony_ci#define CAPTURE_SOURCE          0x60            /* Capture Source 0 = MIC */
3148c2ecf20Sopenharmony_ci#define CAPTURE_SOURCE_CHANNEL0 0xf0000000	/* Mask for selecting the Capture sources */
3158c2ecf20Sopenharmony_ci#define CAPTURE_SOURCE_CHANNEL1 0x0f000000	/* 0 - SPDIF mixer output. */
3168c2ecf20Sopenharmony_ci#define CAPTURE_SOURCE_CHANNEL2 0x00f00000      /* 1 - What you hear or . 2 - ?? */
3178c2ecf20Sopenharmony_ci#define CAPTURE_SOURCE_CHANNEL3 0x000f0000	/* 3 - Mic in, Line in, TAD in, Aux in. */
3188c2ecf20Sopenharmony_ci#define CAPTURE_SOURCE_RECORD_MAP 0x0000ffff	/* Default 0x00e4 */
3198c2ecf20Sopenharmony_ci						/* Record Map [7:0] (2 bits per channel) 0=mapped to channel 0, 1=mapped to channel 1, 2=mapped to channel2, 3=mapped to channel3
3208c2ecf20Sopenharmony_ci						 * Record source select for channel 0 [18:16]
3218c2ecf20Sopenharmony_ci						 * Record source select for channel 1 [22:20]
3228c2ecf20Sopenharmony_ci						 * Record source select for channel 2 [26:24]
3238c2ecf20Sopenharmony_ci						 * Record source select for channel 3 [30:28]
3248c2ecf20Sopenharmony_ci						 * 0 - SPDIF mixer output.
3258c2ecf20Sopenharmony_ci						 * 1 - i2s mixer output.
3268c2ecf20Sopenharmony_ci						 * 2 - SPDIF input.
3278c2ecf20Sopenharmony_ci						 * 3 - i2s input.
3288c2ecf20Sopenharmony_ci						 * 4 - AC97 capture.
3298c2ecf20Sopenharmony_ci						 * 5 - SRC output.
3308c2ecf20Sopenharmony_ci						 */
3318c2ecf20Sopenharmony_ci#define CAPTURE_VOLUME1         0x61            /* Capture  volume per channel 0-3 */
3328c2ecf20Sopenharmony_ci#define CAPTURE_VOLUME2         0x62            /* Capture  volume per channel 4-7 */
3338c2ecf20Sopenharmony_ci
3348c2ecf20Sopenharmony_ci#define PLAYBACK_ROUTING1       0x63            /* Playback routing of channels 0-7. Effects AC3 output. Default 0x32765410 */
3358c2ecf20Sopenharmony_ci#define ROUTING1_REAR           0x77000000      /* Channel_id 0 sends to 10, Channel_id 1 sends to 32 */
3368c2ecf20Sopenharmony_ci#define ROUTING1_NULL           0x00770000      /* Channel_id 2 sends to 54, Channel_id 3 sends to 76 */
3378c2ecf20Sopenharmony_ci#define ROUTING1_CENTER_LFE     0x00007700      /* 0x32765410 means, send Channel_id 0 to FRONT, Channel_id 1 to REAR */
3388c2ecf20Sopenharmony_ci#define ROUTING1_FRONT          0x00000077	/* Channel_id 2 to CENTER_LFE, Channel_id 3 to NULL. */
3398c2ecf20Sopenharmony_ci						/* Channel_id's handle stereo channels. Channel X is a single mono channel */
3408c2ecf20Sopenharmony_ci						/* Host is input from the PCI bus. */
3418c2ecf20Sopenharmony_ci						/* Host channel 0 [2:0] -> SPDIF Mixer/Router channel 0-7.
3428c2ecf20Sopenharmony_ci						 * Host channel 1 [6:4] -> SPDIF Mixer/Router channel 0-7.
3438c2ecf20Sopenharmony_ci						 * Host channel 2 [10:8] -> SPDIF Mixer/Router channel 0-7.
3448c2ecf20Sopenharmony_ci						 * Host channel 3 [14:12] -> SPDIF Mixer/Router channel 0-7.
3458c2ecf20Sopenharmony_ci						 * Host channel 4 [18:16] -> SPDIF Mixer/Router channel 0-7.
3468c2ecf20Sopenharmony_ci						 * Host channel 5 [22:20] -> SPDIF Mixer/Router channel 0-7.
3478c2ecf20Sopenharmony_ci						 * Host channel 6 [26:24] -> SPDIF Mixer/Router channel 0-7.
3488c2ecf20Sopenharmony_ci						 * Host channel 7 [30:28] -> SPDIF Mixer/Router channel 0-7.
3498c2ecf20Sopenharmony_ci						 */
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci#define PLAYBACK_ROUTING2       0x64            /* Playback Routing . Feeding Capture channels back into Playback. Effects AC3 output. Default 0x76767676 */
3528c2ecf20Sopenharmony_ci						/* SRC is input from the capture inputs. */
3538c2ecf20Sopenharmony_ci						/* SRC channel 0 [2:0] -> SPDIF Mixer/Router channel 0-7.
3548c2ecf20Sopenharmony_ci						 * SRC channel 1 [6:4] -> SPDIF Mixer/Router channel 0-7.
3558c2ecf20Sopenharmony_ci						 * SRC channel 2 [10:8] -> SPDIF Mixer/Router channel 0-7.
3568c2ecf20Sopenharmony_ci						 * SRC channel 3 [14:12] -> SPDIF Mixer/Router channel 0-7.
3578c2ecf20Sopenharmony_ci						 * SRC channel 4 [18:16] -> SPDIF Mixer/Router channel 0-7.
3588c2ecf20Sopenharmony_ci						 * SRC channel 5 [22:20] -> SPDIF Mixer/Router channel 0-7.
3598c2ecf20Sopenharmony_ci						 * SRC channel 6 [26:24] -> SPDIF Mixer/Router channel 0-7.
3608c2ecf20Sopenharmony_ci						 * SRC channel 7 [30:28] -> SPDIF Mixer/Router channel 0-7.
3618c2ecf20Sopenharmony_ci						 */
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_ci#define PLAYBACK_MUTE           0x65            /* Unknown. While playing 0x0, while silent 0x00fc0000 */
3648c2ecf20Sopenharmony_ci						/* SPDIF Mixer input control:
3658c2ecf20Sopenharmony_ci						 * Invert SRC to SPDIF Mixer [7-0] (One bit per channel)
3668c2ecf20Sopenharmony_ci						 * Invert Host to SPDIF Mixer [15:8] (One bit per channel)
3678c2ecf20Sopenharmony_ci						 * SRC to SPDIF Mixer disable [23:16] (One bit per channel)
3688c2ecf20Sopenharmony_ci						 * Host to SPDIF Mixer disable [31:24] (One bit per channel)
3698c2ecf20Sopenharmony_ci						 */
3708c2ecf20Sopenharmony_ci#define PLAYBACK_VOLUME1        0x66            /* Playback SPDIF volume per channel. Set to the same PLAYBACK_VOLUME(0x6a) */
3718c2ecf20Sopenharmony_ci						/* PLAYBACK_VOLUME1 must be set to 30303030 for SPDIF AC3 Playback */
3728c2ecf20Sopenharmony_ci						/* SPDIF mixer input volume. 0=12dB, 0x30=0dB, 0xFE=-51.5dB, 0xff=Mute */
3738c2ecf20Sopenharmony_ci						/* One register for each of the 4 stereo streams. */
3748c2ecf20Sopenharmony_ci						/* SRC Right volume [7:0]
3758c2ecf20Sopenharmony_ci						 * SRC Left  volume [15:8]
3768c2ecf20Sopenharmony_ci						 * Host Right volume [23:16]
3778c2ecf20Sopenharmony_ci						 * Host Left  volume [31:24]
3788c2ecf20Sopenharmony_ci						 */
3798c2ecf20Sopenharmony_ci#define CAPTURE_ROUTING1        0x67            /* Capture Routing. Default 0x32765410 */
3808c2ecf20Sopenharmony_ci						/* Similar to register 0x63, except that the destination is the I2S mixer instead of the SPDIF mixer. I.E. Outputs to the Analog outputs instead of SPDIF. */
3818c2ecf20Sopenharmony_ci#define CAPTURE_ROUTING2        0x68            /* Unknown Routing. Default 0x76767676 */
3828c2ecf20Sopenharmony_ci						/* Similar to register 0x64, except that the destination is the I2S mixer instead of the SPDIF mixer. I.E. Outputs to the Analog outputs instead of SPDIF. */
3838c2ecf20Sopenharmony_ci#define CAPTURE_MUTE            0x69            /* Unknown. While capturing 0x0, while silent 0x00fc0000 */
3848c2ecf20Sopenharmony_ci						/* Similar to register 0x65, except that the destination is the I2S mixer instead of the SPDIF mixer. I.E. Outputs to the Analog outputs instead of SPDIF. */
3858c2ecf20Sopenharmony_ci#define PLAYBACK_VOLUME2        0x6a            /* Playback Analog volume per channel. Does not effect AC3 output */
3868c2ecf20Sopenharmony_ci						/* Similar to register 0x66, except that the destination is the I2S mixer instead of the SPDIF mixer. I.E. Outputs to the Analog outputs instead of SPDIF. */
3878c2ecf20Sopenharmony_ci#define UNKNOWN6b               0x6b            /* Unknown. Readonly. Default 00400000 00400000 00400000 00400000 */
3888c2ecf20Sopenharmony_ci#define MIDI_UART_A_DATA		0x6c            /* Midi Uart A Data */
3898c2ecf20Sopenharmony_ci#define MIDI_UART_A_CMD		0x6d            /* Midi Uart A Command/Status */
3908c2ecf20Sopenharmony_ci#define MIDI_UART_B_DATA		0x6e            /* Midi Uart B Data (currently unused) */
3918c2ecf20Sopenharmony_ci#define MIDI_UART_B_CMD		0x6f            /* Midi Uart B Command/Status (currently unused) */
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_ci/* unique channel identifier for midi->channel */
3948c2ecf20Sopenharmony_ci
3958c2ecf20Sopenharmony_ci#define CA0106_MIDI_CHAN_A		0x1
3968c2ecf20Sopenharmony_ci#define CA0106_MIDI_CHAN_B		0x2
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_ci/* from mpu401 */
3998c2ecf20Sopenharmony_ci
4008c2ecf20Sopenharmony_ci#define CA0106_MIDI_INPUT_AVAIL 	0x80
4018c2ecf20Sopenharmony_ci#define CA0106_MIDI_OUTPUT_READY	0x40
4028c2ecf20Sopenharmony_ci#define CA0106_MPU401_RESET		0xff
4038c2ecf20Sopenharmony_ci#define CA0106_MPU401_ENTER_UART	0x3f
4048c2ecf20Sopenharmony_ci#define CA0106_MPU401_ACK		0xfe
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci#define SAMPLE_RATE_TRACKER_STATUS 0x70         /* Readonly. Default 00108000 00108000 00500000 00500000 */
4078c2ecf20Sopenharmony_ci						/* Estimated sample rate [19:0] Relative to 48kHz. 0x8000 =  1.0
4088c2ecf20Sopenharmony_ci						 * Rate Locked [20]
4098c2ecf20Sopenharmony_ci						 * SPDIF Locked [21] For SPDIF channel only.
4108c2ecf20Sopenharmony_ci						 * Valid Audio [22] For SPDIF channel only.
4118c2ecf20Sopenharmony_ci						 */
4128c2ecf20Sopenharmony_ci#define CAPTURE_CONTROL         0x71            /* Some sort of routing. default = 40c81000 30303030 30300000 00700000 */
4138c2ecf20Sopenharmony_ci						/* Channel_id 0: 0x40c81000 must be changed to 0x40c80000 for SPDIF AC3 input or output. */
4148c2ecf20Sopenharmony_ci						/* Channel_id 1: 0xffffffff(mute) 0x30303030(max) controls CAPTURE feedback into PLAYBACK. */
4158c2ecf20Sopenharmony_ci						/* Sample rate output control register Channel=0
4168c2ecf20Sopenharmony_ci						 * Sample output rate [1:0] (0=48kHz, 1=44.1kHz, 2=96kHz, 3=192Khz)
4178c2ecf20Sopenharmony_ci						 * Sample input rate [3:2] (0=48kHz, 1=Not available, 2=96kHz, 3=192Khz)
4188c2ecf20Sopenharmony_ci						 * SRC input source select [4] 0=Audio from digital mixer, 1=Audio from analog source.
4198c2ecf20Sopenharmony_ci						 * Record rate [9:8] (0=48kHz, 1=Not available, 2=96kHz, 3=192Khz)
4208c2ecf20Sopenharmony_ci						 * Record mixer output enable [12:10]
4218c2ecf20Sopenharmony_ci						 * I2S input rate master mode [15:14] (0=48kHz, 1=44.1kHz, 2=96kHz, 3=192Khz)
4228c2ecf20Sopenharmony_ci						 * I2S output rate [17:16] (0=48kHz, 1=44.1kHz, 2=96kHz, 3=192Khz)
4238c2ecf20Sopenharmony_ci						 * I2S output source select [18] (0=Audio from host, 1=Audio from SRC)
4248c2ecf20Sopenharmony_ci						 * Record mixer I2S enable [20:19] (enable/disable i2sin1 and i2sin0)
4258c2ecf20Sopenharmony_ci						 * I2S output master clock select [21] (0=256*I2S output rate, 1=512*I2S output rate.)
4268c2ecf20Sopenharmony_ci						 * I2S input master clock select [22] (0=256*I2S input rate, 1=512*I2S input rate.)
4278c2ecf20Sopenharmony_ci						 * I2S input mode [23] (0=Slave, 1=Master)
4288c2ecf20Sopenharmony_ci						 * SPDIF output rate [25:24] (0=48kHz, 1=44.1kHz, 2=96kHz, 3=192Khz)
4298c2ecf20Sopenharmony_ci						 * SPDIF output source select [26] (0=host, 1=SRC)
4308c2ecf20Sopenharmony_ci						 * Not used [27]
4318c2ecf20Sopenharmony_ci						 * Record Source 0 input [29:28] (0=SPDIF in, 1=I2S in, 2=AC97 Mic, 3=AC97 PCM)
4328c2ecf20Sopenharmony_ci						 * Record Source 1 input [31:30] (0=SPDIF in, 1=I2S in, 2=AC97 Mic, 3=AC97 PCM)
4338c2ecf20Sopenharmony_ci						 */
4348c2ecf20Sopenharmony_ci						/* Sample rate output control register Channel=1
4358c2ecf20Sopenharmony_ci						 * I2S Input 0 volume Right [7:0]
4368c2ecf20Sopenharmony_ci						 * I2S Input 0 volume Left [15:8]
4378c2ecf20Sopenharmony_ci						 * I2S Input 1 volume Right [23:16]
4388c2ecf20Sopenharmony_ci						 * I2S Input 1 volume Left [31:24]
4398c2ecf20Sopenharmony_ci						 */
4408c2ecf20Sopenharmony_ci						/* Sample rate output control register Channel=2
4418c2ecf20Sopenharmony_ci						 * SPDIF Input volume Right [23:16]
4428c2ecf20Sopenharmony_ci						 * SPDIF Input volume Left [31:24]
4438c2ecf20Sopenharmony_ci						 */
4448c2ecf20Sopenharmony_ci						/* Sample rate output control register Channel=3
4458c2ecf20Sopenharmony_ci						 * No used
4468c2ecf20Sopenharmony_ci						 */
4478c2ecf20Sopenharmony_ci#define SPDIF_SELECT2           0x72            /* Some sort of routing. Channel_id 0 only. default = 0x0f0f003f. Analog 0x000b0000, Digital 0x0b000000 */
4488c2ecf20Sopenharmony_ci#define ROUTING2_FRONT_MASK     0x00010000      /* Enable for Front speakers. */
4498c2ecf20Sopenharmony_ci#define ROUTING2_CENTER_LFE_MASK 0x00020000     /* Enable for Center/LFE speakers. */
4508c2ecf20Sopenharmony_ci#define ROUTING2_REAR_MASK      0x00080000      /* Enable for Rear speakers. */
4518c2ecf20Sopenharmony_ci						/* Audio output control
4528c2ecf20Sopenharmony_ci						 * AC97 output enable [5:0]
4538c2ecf20Sopenharmony_ci						 * I2S output enable [19:16]
4548c2ecf20Sopenharmony_ci						 * SPDIF output enable [27:24]
4558c2ecf20Sopenharmony_ci						 */
4568c2ecf20Sopenharmony_ci#define UNKNOWN73               0x73            /* Unknown. Readonly. Default 0x0 */
4578c2ecf20Sopenharmony_ci#define CHIP_VERSION            0x74            /* P17 Chip version. Channel_id 0 only. Default 00000071 */
4588c2ecf20Sopenharmony_ci#define EXTENDED_INT_MASK       0x75            /* Used by both playback and capture interrupt handler */
4598c2ecf20Sopenharmony_ci						/* Sets which Interrupts are enabled. */
4608c2ecf20Sopenharmony_ci						/* 0x00000001 = Half period. Playback.
4618c2ecf20Sopenharmony_ci						 * 0x00000010 = Full period. Playback.
4628c2ecf20Sopenharmony_ci						 * 0x00000100 = Half buffer. Playback.
4638c2ecf20Sopenharmony_ci						 * 0x00001000 = Full buffer. Playback.
4648c2ecf20Sopenharmony_ci						 * 0x00010000 = Half buffer. Capture.
4658c2ecf20Sopenharmony_ci						 * 0x00100000 = Full buffer. Capture.
4668c2ecf20Sopenharmony_ci						 * Capture can only do 2 periods.
4678c2ecf20Sopenharmony_ci						 * 0x01000000 = End audio. Playback.
4688c2ecf20Sopenharmony_ci						 * 0x40000000 = Half buffer Playback,Caputre xrun.
4698c2ecf20Sopenharmony_ci						 * 0x80000000 = Full buffer Playback,Caputre xrun.
4708c2ecf20Sopenharmony_ci						 */
4718c2ecf20Sopenharmony_ci#define EXTENDED_INT            0x76            /* Used by both playback and capture interrupt handler */
4728c2ecf20Sopenharmony_ci						/* Shows which interrupts are active at the moment. */
4738c2ecf20Sopenharmony_ci						/* Same bit layout as EXTENDED_INT_MASK */
4748c2ecf20Sopenharmony_ci#define COUNTER77               0x77		/* Counter range 0 to 0x3fffff, 192000 counts per second. */
4758c2ecf20Sopenharmony_ci#define COUNTER78               0x78		/* Counter range 0 to 0x3fffff, 44100 counts per second. */
4768c2ecf20Sopenharmony_ci#define EXTENDED_INT_TIMER      0x79            /* Channel_id 0 only. Used by both playback and capture interrupt handler */
4778c2ecf20Sopenharmony_ci						/* Causes interrupts based on timer intervals. */
4788c2ecf20Sopenharmony_ci#define SPI			0x7a		/* SPI: Serial Interface Register */
4798c2ecf20Sopenharmony_ci#define I2C_A			0x7b		/* I2C Address. 32 bit */
4808c2ecf20Sopenharmony_ci#define I2C_D0			0x7c		/* I2C Data Port 0. 32 bit */
4818c2ecf20Sopenharmony_ci#define I2C_D1			0x7d		/* I2C Data Port 1. 32 bit */
4828c2ecf20Sopenharmony_ci//I2C values
4838c2ecf20Sopenharmony_ci#define I2C_A_ADC_ADD_MASK	0x000000fe	//The address is a 7 bit address
4848c2ecf20Sopenharmony_ci#define I2C_A_ADC_RW_MASK	0x00000001	//bit mask for R/W
4858c2ecf20Sopenharmony_ci#define I2C_A_ADC_TRANS_MASK	0x00000010  	//Bit mask for I2c address DAC value
4868c2ecf20Sopenharmony_ci#define I2C_A_ADC_ABORT_MASK	0x00000020	//Bit mask for I2C transaction abort flag
4878c2ecf20Sopenharmony_ci#define I2C_A_ADC_LAST_MASK	0x00000040	//Bit mask for Last word transaction
4888c2ecf20Sopenharmony_ci#define I2C_A_ADC_BYTE_MASK	0x00000080	//Bit mask for Byte Mode
4898c2ecf20Sopenharmony_ci
4908c2ecf20Sopenharmony_ci#define I2C_A_ADC_ADD		0x00000034	//This is the Device address for ADC
4918c2ecf20Sopenharmony_ci#define I2C_A_ADC_READ		0x00000001	//To perform a read operation
4928c2ecf20Sopenharmony_ci#define I2C_A_ADC_START		0x00000100	//Start I2C transaction
4938c2ecf20Sopenharmony_ci#define I2C_A_ADC_ABORT		0x00000200	//I2C transaction abort
4948c2ecf20Sopenharmony_ci#define I2C_A_ADC_LAST		0x00000400	//I2C last transaction
4958c2ecf20Sopenharmony_ci#define I2C_A_ADC_BYTE		0x00000800	//I2C one byte mode
4968c2ecf20Sopenharmony_ci
4978c2ecf20Sopenharmony_ci#define I2C_D_ADC_REG_MASK	0xfe000000  	//ADC address register
4988c2ecf20Sopenharmony_ci#define I2C_D_ADC_DAT_MASK	0x01ff0000  	//ADC data register
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_ci#define ADC_TIMEOUT		0x00000007	//ADC Timeout Clock Disable
5018c2ecf20Sopenharmony_ci#define ADC_IFC_CTRL		0x0000000b	//ADC Interface Control
5028c2ecf20Sopenharmony_ci#define ADC_MASTER		0x0000000c	//ADC Master Mode Control
5038c2ecf20Sopenharmony_ci#define ADC_POWER		0x0000000d	//ADC PowerDown Control
5048c2ecf20Sopenharmony_ci#define ADC_ATTEN_ADCL		0x0000000e	//ADC Attenuation ADCL
5058c2ecf20Sopenharmony_ci#define ADC_ATTEN_ADCR		0x0000000f	//ADC Attenuation ADCR
5068c2ecf20Sopenharmony_ci#define ADC_ALC_CTRL1		0x00000010	//ADC ALC Control 1
5078c2ecf20Sopenharmony_ci#define ADC_ALC_CTRL2		0x00000011	//ADC ALC Control 2
5088c2ecf20Sopenharmony_ci#define ADC_ALC_CTRL3		0x00000012	//ADC ALC Control 3
5098c2ecf20Sopenharmony_ci#define ADC_NOISE_CTRL		0x00000013	//ADC Noise Gate Control
5108c2ecf20Sopenharmony_ci#define ADC_LIMIT_CTRL		0x00000014	//ADC Limiter Control
5118c2ecf20Sopenharmony_ci#define ADC_MUX			0x00000015  	//ADC Mux offset
5128c2ecf20Sopenharmony_ci
5138c2ecf20Sopenharmony_ci#if 0
5148c2ecf20Sopenharmony_ci/* FIXME: Not tested yet. */
5158c2ecf20Sopenharmony_ci#define ADC_GAIN_MASK		0x000000ff	//Mask for ADC Gain
5168c2ecf20Sopenharmony_ci#define ADC_ZERODB		0x000000cf	//Value to set ADC to 0dB
5178c2ecf20Sopenharmony_ci#define ADC_MUTE_MASK		0x000000c0	//Mask for ADC mute
5188c2ecf20Sopenharmony_ci#define ADC_MUTE		0x000000c0	//Value to mute ADC
5198c2ecf20Sopenharmony_ci#define ADC_OSR			0x00000008	//Mask for ADC oversample rate select
5208c2ecf20Sopenharmony_ci#define ADC_TIMEOUT_DISABLE	0x00000008	//Value and mask to disable Timeout clock
5218c2ecf20Sopenharmony_ci#define ADC_HPF_DISABLE		0x00000100	//Value and mask to disable High pass filter
5228c2ecf20Sopenharmony_ci#define ADC_TRANWIN_MASK	0x00000070	//Mask for Length of Transient Window
5238c2ecf20Sopenharmony_ci#endif
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_ci#define ADC_MUX_MASK		0x0000000f	//Mask for ADC Mux
5268c2ecf20Sopenharmony_ci#define ADC_MUX_PHONE		0x00000001	//Value to select TAD at ADC Mux (Not used)
5278c2ecf20Sopenharmony_ci#define ADC_MUX_MIC		0x00000002	//Value to select Mic at ADC Mux
5288c2ecf20Sopenharmony_ci#define ADC_MUX_LINEIN		0x00000004	//Value to select LineIn at ADC Mux
5298c2ecf20Sopenharmony_ci#define ADC_MUX_AUX		0x00000008	//Value to select Aux at ADC Mux
5308c2ecf20Sopenharmony_ci
5318c2ecf20Sopenharmony_ci#define SET_CHANNEL 0  /* Testing channel outputs 0=Front, 1=Center/LFE, 2=Unknown, 3=Rear */
5328c2ecf20Sopenharmony_ci#define PCM_FRONT_CHANNEL 0
5338c2ecf20Sopenharmony_ci#define PCM_REAR_CHANNEL 1
5348c2ecf20Sopenharmony_ci#define PCM_CENTER_LFE_CHANNEL 2
5358c2ecf20Sopenharmony_ci#define PCM_UNKNOWN_CHANNEL 3
5368c2ecf20Sopenharmony_ci#define CONTROL_FRONT_CHANNEL 0
5378c2ecf20Sopenharmony_ci#define CONTROL_REAR_CHANNEL 3
5388c2ecf20Sopenharmony_ci#define CONTROL_CENTER_LFE_CHANNEL 1
5398c2ecf20Sopenharmony_ci#define CONTROL_UNKNOWN_CHANNEL 2
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_ci
5428c2ecf20Sopenharmony_ci/* Based on WM8768 Datasheet Rev 4.2 page 32 */
5438c2ecf20Sopenharmony_ci#define SPI_REG_MASK	0x1ff	/* 16-bit SPI writes have a 7-bit address */
5448c2ecf20Sopenharmony_ci#define SPI_REG_SHIFT	9	/* followed by 9 bits of data */
5458c2ecf20Sopenharmony_ci
5468c2ecf20Sopenharmony_ci#define SPI_LDA1_REG		0	/* digital attenuation */
5478c2ecf20Sopenharmony_ci#define SPI_RDA1_REG		1
5488c2ecf20Sopenharmony_ci#define SPI_LDA2_REG		4
5498c2ecf20Sopenharmony_ci#define SPI_RDA2_REG		5
5508c2ecf20Sopenharmony_ci#define SPI_LDA3_REG		6
5518c2ecf20Sopenharmony_ci#define SPI_RDA3_REG		7
5528c2ecf20Sopenharmony_ci#define SPI_LDA4_REG		13
5538c2ecf20Sopenharmony_ci#define SPI_RDA4_REG		14
5548c2ecf20Sopenharmony_ci#define SPI_MASTDA_REG		8
5558c2ecf20Sopenharmony_ci
5568c2ecf20Sopenharmony_ci#define SPI_DA_BIT_UPDATE	(1<<8)	/* update attenuation values */
5578c2ecf20Sopenharmony_ci#define SPI_DA_BIT_0dB		0xff	/* 0 dB */
5588c2ecf20Sopenharmony_ci#define SPI_DA_BIT_infdB	0x00	/* inf dB attenuation (mute) */
5598c2ecf20Sopenharmony_ci
5608c2ecf20Sopenharmony_ci#define SPI_PL_REG		2
5618c2ecf20Sopenharmony_ci#define SPI_PL_BIT_L_M		(0<<5)	/* left channel = mute */
5628c2ecf20Sopenharmony_ci#define SPI_PL_BIT_L_L		(1<<5)	/* left channel = left */
5638c2ecf20Sopenharmony_ci#define SPI_PL_BIT_L_R		(2<<5)	/* left channel = right */
5648c2ecf20Sopenharmony_ci#define SPI_PL_BIT_L_C		(3<<5)	/* left channel = (L+R)/2 */
5658c2ecf20Sopenharmony_ci#define SPI_PL_BIT_R_M		(0<<7)	/* right channel = mute */
5668c2ecf20Sopenharmony_ci#define SPI_PL_BIT_R_L		(1<<7)	/* right channel = left */
5678c2ecf20Sopenharmony_ci#define SPI_PL_BIT_R_R		(2<<7)	/* right channel = right */
5688c2ecf20Sopenharmony_ci#define SPI_PL_BIT_R_C		(3<<7)	/* right channel = (L+R)/2 */
5698c2ecf20Sopenharmony_ci#define SPI_IZD_REG		2
5708c2ecf20Sopenharmony_ci#define SPI_IZD_BIT		(0<<4)	/* infinite zero detect */
5718c2ecf20Sopenharmony_ci
5728c2ecf20Sopenharmony_ci#define SPI_FMT_REG		3
5738c2ecf20Sopenharmony_ci#define SPI_FMT_BIT_RJ		(0<<0)	/* right justified mode */
5748c2ecf20Sopenharmony_ci#define SPI_FMT_BIT_LJ		(1<<0)	/* left justified mode */
5758c2ecf20Sopenharmony_ci#define SPI_FMT_BIT_I2S		(2<<0)	/* I2S mode */
5768c2ecf20Sopenharmony_ci#define SPI_FMT_BIT_DSP		(3<<0)	/* DSP Modes A or B */
5778c2ecf20Sopenharmony_ci#define SPI_LRP_REG		3
5788c2ecf20Sopenharmony_ci#define SPI_LRP_BIT		(1<<2)	/* invert LRCLK polarity */
5798c2ecf20Sopenharmony_ci#define SPI_BCP_REG		3
5808c2ecf20Sopenharmony_ci#define SPI_BCP_BIT		(1<<3)	/* invert BCLK polarity */
5818c2ecf20Sopenharmony_ci#define SPI_IWL_REG		3
5828c2ecf20Sopenharmony_ci#define SPI_IWL_BIT_16		(0<<4)	/* 16-bit world length */
5838c2ecf20Sopenharmony_ci#define SPI_IWL_BIT_20		(1<<4)	/* 20-bit world length */
5848c2ecf20Sopenharmony_ci#define SPI_IWL_BIT_24		(2<<4)	/* 24-bit world length */
5858c2ecf20Sopenharmony_ci#define SPI_IWL_BIT_32		(3<<4)	/* 32-bit world length */
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_ci#define SPI_MS_REG		10
5888c2ecf20Sopenharmony_ci#define SPI_MS_BIT		(1<<5)	/* master mode */
5898c2ecf20Sopenharmony_ci#define SPI_RATE_REG		10	/* only applies in master mode */
5908c2ecf20Sopenharmony_ci#define SPI_RATE_BIT_128	(0<<6)	/* MCLK = LRCLK * 128 */
5918c2ecf20Sopenharmony_ci#define SPI_RATE_BIT_192	(1<<6)
5928c2ecf20Sopenharmony_ci#define SPI_RATE_BIT_256	(2<<6)
5938c2ecf20Sopenharmony_ci#define SPI_RATE_BIT_384	(3<<6)
5948c2ecf20Sopenharmony_ci#define SPI_RATE_BIT_512	(4<<6)
5958c2ecf20Sopenharmony_ci#define SPI_RATE_BIT_768	(5<<6)
5968c2ecf20Sopenharmony_ci
5978c2ecf20Sopenharmony_ci/* They really do label the bit for the 4th channel "4" and not "3" */
5988c2ecf20Sopenharmony_ci#define SPI_DMUTE0_REG		9
5998c2ecf20Sopenharmony_ci#define SPI_DMUTE1_REG		9
6008c2ecf20Sopenharmony_ci#define SPI_DMUTE2_REG		9
6018c2ecf20Sopenharmony_ci#define SPI_DMUTE4_REG		15
6028c2ecf20Sopenharmony_ci#define SPI_DMUTE0_BIT		(1<<3)
6038c2ecf20Sopenharmony_ci#define SPI_DMUTE1_BIT		(1<<4)
6048c2ecf20Sopenharmony_ci#define SPI_DMUTE2_BIT		(1<<5)
6058c2ecf20Sopenharmony_ci#define SPI_DMUTE4_BIT		(1<<2)
6068c2ecf20Sopenharmony_ci
6078c2ecf20Sopenharmony_ci#define SPI_PHASE0_REG		3
6088c2ecf20Sopenharmony_ci#define SPI_PHASE1_REG		3
6098c2ecf20Sopenharmony_ci#define SPI_PHASE2_REG		3
6108c2ecf20Sopenharmony_ci#define SPI_PHASE4_REG		15
6118c2ecf20Sopenharmony_ci#define SPI_PHASE0_BIT		(1<<6)
6128c2ecf20Sopenharmony_ci#define SPI_PHASE1_BIT		(1<<7)
6138c2ecf20Sopenharmony_ci#define SPI_PHASE2_BIT		(1<<8)
6148c2ecf20Sopenharmony_ci#define SPI_PHASE4_BIT		(1<<3)
6158c2ecf20Sopenharmony_ci
6168c2ecf20Sopenharmony_ci#define SPI_PDWN_REG		2	/* power down all DACs */
6178c2ecf20Sopenharmony_ci#define SPI_PDWN_BIT		(1<<2)
6188c2ecf20Sopenharmony_ci#define SPI_DACD0_REG		10	/* power down individual DACs */
6198c2ecf20Sopenharmony_ci#define SPI_DACD1_REG		10
6208c2ecf20Sopenharmony_ci#define SPI_DACD2_REG		10
6218c2ecf20Sopenharmony_ci#define SPI_DACD4_REG		15
6228c2ecf20Sopenharmony_ci#define SPI_DACD0_BIT		(1<<1)
6238c2ecf20Sopenharmony_ci#define SPI_DACD1_BIT		(1<<2)
6248c2ecf20Sopenharmony_ci#define SPI_DACD2_BIT		(1<<3)
6258c2ecf20Sopenharmony_ci#define SPI_DACD4_BIT		(1<<0)	/* datasheet error says it's 1 */
6268c2ecf20Sopenharmony_ci
6278c2ecf20Sopenharmony_ci#define SPI_PWRDNALL_REG	10	/* power down everything */
6288c2ecf20Sopenharmony_ci#define SPI_PWRDNALL_BIT	(1<<4)
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ci#include "ca_midi.h"
6318c2ecf20Sopenharmony_ci
6328c2ecf20Sopenharmony_cistruct snd_ca0106;
6338c2ecf20Sopenharmony_ci
6348c2ecf20Sopenharmony_cistruct snd_ca0106_channel {
6358c2ecf20Sopenharmony_ci	struct snd_ca0106 *emu;
6368c2ecf20Sopenharmony_ci	int number;
6378c2ecf20Sopenharmony_ci	int use;
6388c2ecf20Sopenharmony_ci	void (*interrupt)(struct snd_ca0106 *emu, struct snd_ca0106_channel *channel);
6398c2ecf20Sopenharmony_ci	struct snd_ca0106_pcm *epcm;
6408c2ecf20Sopenharmony_ci};
6418c2ecf20Sopenharmony_ci
6428c2ecf20Sopenharmony_cistruct snd_ca0106_pcm {
6438c2ecf20Sopenharmony_ci	struct snd_ca0106 *emu;
6448c2ecf20Sopenharmony_ci	struct snd_pcm_substream *substream;
6458c2ecf20Sopenharmony_ci        int channel_id;
6468c2ecf20Sopenharmony_ci	unsigned short running;
6478c2ecf20Sopenharmony_ci};
6488c2ecf20Sopenharmony_ci
6498c2ecf20Sopenharmony_cistruct snd_ca0106_details {
6508c2ecf20Sopenharmony_ci        u32 serial;
6518c2ecf20Sopenharmony_ci        char * name;
6528c2ecf20Sopenharmony_ci	int ac97;	/* ac97 = 0 -> Select MIC, Line in, TAD in, AUX in.
6538c2ecf20Sopenharmony_ci			   ac97 = 1 -> Default to AC97 in. */
6548c2ecf20Sopenharmony_ci	int gpio_type;	/* gpio_type = 1 -> shared mic-in/line-in
6558c2ecf20Sopenharmony_ci			   gpio_type = 2 -> shared side-out/line-in. */
6568c2ecf20Sopenharmony_ci	int i2c_adc;	/* with i2c_adc=1, the driver adds some capture volume
6578c2ecf20Sopenharmony_ci			   controls, phone, mic, line-in and aux. */
6588c2ecf20Sopenharmony_ci	u16 spi_dac;	/* spi_dac = 0 -> no spi interface for DACs
6598c2ecf20Sopenharmony_ci			   spi_dac = 0x<front><rear><center-lfe><side>
6608c2ecf20Sopenharmony_ci			   -> specifies DAC id for each channel pair. */
6618c2ecf20Sopenharmony_ci};
6628c2ecf20Sopenharmony_ci
6638c2ecf20Sopenharmony_ci// definition of the chip-specific record
6648c2ecf20Sopenharmony_cistruct snd_ca0106 {
6658c2ecf20Sopenharmony_ci	struct snd_card *card;
6668c2ecf20Sopenharmony_ci	const struct snd_ca0106_details *details;
6678c2ecf20Sopenharmony_ci	struct pci_dev *pci;
6688c2ecf20Sopenharmony_ci
6698c2ecf20Sopenharmony_ci	unsigned long port;
6708c2ecf20Sopenharmony_ci	struct resource *res_port;
6718c2ecf20Sopenharmony_ci	int irq;
6728c2ecf20Sopenharmony_ci
6738c2ecf20Sopenharmony_ci	unsigned int serial;            /* serial number */
6748c2ecf20Sopenharmony_ci	unsigned short model;		/* subsystem id */
6758c2ecf20Sopenharmony_ci
6768c2ecf20Sopenharmony_ci	spinlock_t emu_lock;
6778c2ecf20Sopenharmony_ci
6788c2ecf20Sopenharmony_ci	struct snd_ac97 *ac97;
6798c2ecf20Sopenharmony_ci	struct snd_pcm *pcm[4];
6808c2ecf20Sopenharmony_ci
6818c2ecf20Sopenharmony_ci	struct snd_ca0106_channel playback_channels[4];
6828c2ecf20Sopenharmony_ci	struct snd_ca0106_channel capture_channels[4];
6838c2ecf20Sopenharmony_ci	u32 spdif_bits[4];             /* s/pdif out default setup */
6848c2ecf20Sopenharmony_ci	u32 spdif_str_bits[4];         /* s/pdif out per-stream setup */
6858c2ecf20Sopenharmony_ci	int spdif_enable;
6868c2ecf20Sopenharmony_ci	int capture_source;
6878c2ecf20Sopenharmony_ci	int i2c_capture_source;
6888c2ecf20Sopenharmony_ci	u8 i2c_capture_volume[4][2];
6898c2ecf20Sopenharmony_ci	int capture_mic_line_in;
6908c2ecf20Sopenharmony_ci
6918c2ecf20Sopenharmony_ci	struct snd_dma_buffer buffer;
6928c2ecf20Sopenharmony_ci
6938c2ecf20Sopenharmony_ci	struct snd_ca_midi midi;
6948c2ecf20Sopenharmony_ci	struct snd_ca_midi midi2;
6958c2ecf20Sopenharmony_ci
6968c2ecf20Sopenharmony_ci	u16 spi_dac_reg[16];
6978c2ecf20Sopenharmony_ci
6988c2ecf20Sopenharmony_ci#ifdef CONFIG_PM_SLEEP
6998c2ecf20Sopenharmony_ci#define NUM_SAVED_VOLUMES	9
7008c2ecf20Sopenharmony_ci	unsigned int saved_vol[NUM_SAVED_VOLUMES];
7018c2ecf20Sopenharmony_ci#endif
7028c2ecf20Sopenharmony_ci};
7038c2ecf20Sopenharmony_ci
7048c2ecf20Sopenharmony_ciint snd_ca0106_mixer(struct snd_ca0106 *emu);
7058c2ecf20Sopenharmony_ciint snd_ca0106_proc_init(struct snd_ca0106 * emu);
7068c2ecf20Sopenharmony_ci
7078c2ecf20Sopenharmony_ciunsigned int snd_ca0106_ptr_read(struct snd_ca0106 * emu,
7088c2ecf20Sopenharmony_ci				 unsigned int reg,
7098c2ecf20Sopenharmony_ci				 unsigned int chn);
7108c2ecf20Sopenharmony_ci
7118c2ecf20Sopenharmony_civoid snd_ca0106_ptr_write(struct snd_ca0106 *emu,
7128c2ecf20Sopenharmony_ci			  unsigned int reg,
7138c2ecf20Sopenharmony_ci			  unsigned int chn,
7148c2ecf20Sopenharmony_ci			  unsigned int data);
7158c2ecf20Sopenharmony_ci
7168c2ecf20Sopenharmony_ciint snd_ca0106_i2c_write(struct snd_ca0106 *emu, u32 reg, u32 value);
7178c2ecf20Sopenharmony_ci
7188c2ecf20Sopenharmony_ciint snd_ca0106_spi_write(struct snd_ca0106 * emu,
7198c2ecf20Sopenharmony_ci				   unsigned int data);
7208c2ecf20Sopenharmony_ci
7218c2ecf20Sopenharmony_ci#ifdef CONFIG_PM_SLEEP
7228c2ecf20Sopenharmony_civoid snd_ca0106_mixer_suspend(struct snd_ca0106 *chip);
7238c2ecf20Sopenharmony_civoid snd_ca0106_mixer_resume(struct snd_ca0106 *chip);
7248c2ecf20Sopenharmony_ci#else
7258c2ecf20Sopenharmony_ci#define snd_ca0106_mixer_suspend(chip)	do { } while (0)
7268c2ecf20Sopenharmony_ci#define snd_ca0106_mixer_resume(chip)	do { } while (0)
7278c2ecf20Sopenharmony_ci#endif
728