162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>,
462306a36Sopenharmony_ci *		     Creative Labs, Inc.
562306a36Sopenharmony_ci *  Definitions for EMU10K1 (SB Live!) chips
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci#ifndef __SOUND_EMU10K1_H
862306a36Sopenharmony_ci#define __SOUND_EMU10K1_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <sound/pcm.h>
1262306a36Sopenharmony_ci#include <sound/rawmidi.h>
1362306a36Sopenharmony_ci#include <sound/hwdep.h>
1462306a36Sopenharmony_ci#include <sound/ac97_codec.h>
1562306a36Sopenharmony_ci#include <sound/util_mem.h>
1662306a36Sopenharmony_ci#include <sound/pcm-indirect.h>
1762306a36Sopenharmony_ci#include <sound/timer.h>
1862306a36Sopenharmony_ci#include <linux/interrupt.h>
1962306a36Sopenharmony_ci#include <linux/mutex.h>
2062306a36Sopenharmony_ci#include <linux/firmware.h>
2162306a36Sopenharmony_ci#include <linux/io.h>
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci#include <uapi/sound/emu10k1.h>
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci/* ------------------- DEFINES -------------------- */
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci#define EMUPAGESIZE     4096
2862306a36Sopenharmony_ci#define MAXPAGES0       4096	/* 32 bit mode */
2962306a36Sopenharmony_ci#define MAXPAGES1       8192	/* 31 bit mode */
3062306a36Sopenharmony_ci#define NUM_G           64              /* use all channels */
3162306a36Sopenharmony_ci#define NUM_EFX_PLAYBACK    16
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/* FIXME? - according to the OSS driver the EMU10K1 needs a 29 bit DMA mask */
3462306a36Sopenharmony_ci#define EMU10K1_DMA_MASK	0x7fffffffUL	/* 31bit */
3562306a36Sopenharmony_ci#define AUDIGY_DMA_MASK		0xffffffffUL	/* 32bit mode */
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#define TMEMSIZE        256*1024
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci#define IP_TO_CP(ip) ((ip == 0) ? 0 : (((0x00001000uL | (ip & 0x00000FFFL)) << (((ip >> 12) & 0x000FL) + 4)) & 0xFFFF0000uL))
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci// This is used to define hardware bit-fields (sub-registers) by combining
4262306a36Sopenharmony_ci// the bit shift and count with the actual register address. The passed
4362306a36Sopenharmony_ci// mask must represent a single run of adjacent bits.
4462306a36Sopenharmony_ci// The non-concatenating (_NC) variant should be used directly only for
4562306a36Sopenharmony_ci// sub-registers that do not follow the <register>_<field> naming pattern.
4662306a36Sopenharmony_ci#define SUB_REG_NC(reg, field, mask) \
4762306a36Sopenharmony_ci	enum { \
4862306a36Sopenharmony_ci		field ## _MASK = mask, \
4962306a36Sopenharmony_ci		field = reg | \
5062306a36Sopenharmony_ci			(__builtin_ctz(mask) << 16) | \
5162306a36Sopenharmony_ci			(__builtin_popcount(mask) << 24), \
5262306a36Sopenharmony_ci	};
5362306a36Sopenharmony_ci#define SUB_REG(reg, field, mask) SUB_REG_NC(reg, reg ## _ ## field, mask)
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci// Macros for manipulating values of bit-fields declared using the above macros.
5662306a36Sopenharmony_ci// Best used with constant register addresses, as otherwise quite some code is
5762306a36Sopenharmony_ci// generated. The actual register read/write functions handle combined addresses
5862306a36Sopenharmony_ci// automatically, so use of these macros conveys no advantage when accessing a
5962306a36Sopenharmony_ci// single sub-register at a time.
6062306a36Sopenharmony_ci#define REG_SHIFT(r) (((r) >> 16) & 0x1f)
6162306a36Sopenharmony_ci#define REG_SIZE(r) (((r) >> 24) & 0x1f)
6262306a36Sopenharmony_ci#define REG_MASK0(r) ((1U << REG_SIZE(r)) - 1U)
6362306a36Sopenharmony_ci#define REG_MASK(r) (REG_MASK0(r) << REG_SHIFT(r))
6462306a36Sopenharmony_ci#define REG_VAL_GET(r, v) ((v & REG_MASK(r)) >> REG_SHIFT(r))
6562306a36Sopenharmony_ci#define REG_VAL_PUT(r, v) ((v) << REG_SHIFT(r))
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci// List terminator for snd_emu10k1_ptr_write_multiple()
6862306a36Sopenharmony_ci#define REGLIST_END ~0
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci// Audigy specify registers are prefixed with 'A_'
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci/************************************************************************************************/
7362306a36Sopenharmony_ci/* PCI function 0 registers, address = <val> + PCIBASE0						*/
7462306a36Sopenharmony_ci/************************************************************************************************/
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci#define PTR			0x00		/* Indexed register set pointer register	*/
7762306a36Sopenharmony_ci						/* NOTE: The CHANNELNUM and ADDRESS words can	*/
7862306a36Sopenharmony_ci						/* be modified independently of each other.	*/
7962306a36Sopenharmony_ci#define PTR_CHANNELNUM_MASK	0x0000003f	/* For each per-channel register, indicates the	*/
8062306a36Sopenharmony_ci						/* channel number of the register to be		*/
8162306a36Sopenharmony_ci						/* accessed.  For non per-channel registers the	*/
8262306a36Sopenharmony_ci						/* value should be set to zero.			*/
8362306a36Sopenharmony_ci#define PTR_ADDRESS_MASK	0x07ff0000	/* Register index				*/
8462306a36Sopenharmony_ci#define A_PTR_ADDRESS_MASK	0x0fff0000
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci#define DATA			0x04		/* Indexed register set data register		*/
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci#define IPR			0x08		/* Global interrupt pending register		*/
8962306a36Sopenharmony_ci						/* Clear pending interrupts by writing a 1 to	*/
9062306a36Sopenharmony_ci						/* the relevant bits and zero to the other bits	*/
9162306a36Sopenharmony_ci#define IPR_P16V		0x80000000	/* Bit set when the CA0151 P16V chip wishes
9262306a36Sopenharmony_ci						   to interrupt */
9362306a36Sopenharmony_ci#define IPR_WATERMARK_REACHED	0x40000000
9462306a36Sopenharmony_ci#define IPR_A_GPIO		0x20000000	/* GPIO input pin change			*/
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci/* The next two interrupts are for the midi port on the Audigy Drive (A_MPU1)			*/
9762306a36Sopenharmony_ci#define IPR_A_MIDITRANSBUFEMPTY2 0x10000000	/* MIDI UART transmit buffer empty		*/
9862306a36Sopenharmony_ci#define IPR_A_MIDIRECVBUFEMPTY2	0x08000000	/* MIDI UART receive buffer empty		*/
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ci#define IPR_SPDIFBUFFULL	0x04000000	/* SPDIF capture related, 10k2 only? (RE)	*/
10162306a36Sopenharmony_ci#define IPR_SPDIFBUFHALFFULL	0x02000000	/* SPDIF capture related? (RE)			*/
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci#define IPR_SAMPLERATETRACKER	0x01000000	/* Sample rate tracker lock status change	*/
10462306a36Sopenharmony_ci#define IPR_FXDSP		0x00800000	/* Enable FX DSP interrupts			*/
10562306a36Sopenharmony_ci#define IPR_FORCEINT		0x00400000	/* Force Sound Blaster interrupt		*/
10662306a36Sopenharmony_ci#define IPR_PCIERROR		0x00200000	/* PCI bus error				*/
10762306a36Sopenharmony_ci#define IPR_VOLINCR		0x00100000	/* Volume increment button pressed		*/
10862306a36Sopenharmony_ci#define IPR_VOLDECR		0x00080000	/* Volume decrement button pressed		*/
10962306a36Sopenharmony_ci#define IPR_MUTE		0x00040000	/* Mute button pressed				*/
11062306a36Sopenharmony_ci#define IPR_MICBUFFULL		0x00020000	/* Microphone buffer full			*/
11162306a36Sopenharmony_ci#define IPR_MICBUFHALFFULL	0x00010000	/* Microphone buffer half full			*/
11262306a36Sopenharmony_ci#define IPR_ADCBUFFULL		0x00008000	/* ADC buffer full				*/
11362306a36Sopenharmony_ci#define IPR_ADCBUFHALFFULL	0x00004000	/* ADC buffer half full				*/
11462306a36Sopenharmony_ci#define IPR_EFXBUFFULL		0x00002000	/* Effects buffer full				*/
11562306a36Sopenharmony_ci#define IPR_EFXBUFHALFFULL	0x00001000	/* Effects buffer half full			*/
11662306a36Sopenharmony_ci#define IPR_GPSPDIFSTATUSCHANGE	0x00000800	/* GPSPDIF channel status change		*/
11762306a36Sopenharmony_ci#define IPR_CDROMSTATUSCHANGE	0x00000400	/* CD-ROM channel status change			*/
11862306a36Sopenharmony_ci#define IPR_INTERVALTIMER	0x00000200	/* Interval timer terminal count		*/
11962306a36Sopenharmony_ci#define IPR_MIDITRANSBUFEMPTY	0x00000100	/* MIDI UART transmit buffer empty		*/
12062306a36Sopenharmony_ci#define IPR_MIDIRECVBUFEMPTY	0x00000080	/* MIDI UART receive buffer empty		*/
12162306a36Sopenharmony_ci#define IPR_CHANNELLOOP		0x00000040	/* Channel (half) loop interrupt(s) pending	*/
12262306a36Sopenharmony_ci						/* The interrupt is triggered shortly after	*/
12362306a36Sopenharmony_ci						/* CCR_READADDRESS has crossed the boundary;	*/
12462306a36Sopenharmony_ci						/* due to the cache, this runs ahead of the	*/
12562306a36Sopenharmony_ci						/* actual playback position.			*/
12662306a36Sopenharmony_ci#define IPR_CHANNELNUMBERMASK	0x0000003f	/* When IPR_CHANNELLOOP is set, indicates the	*/
12762306a36Sopenharmony_ci						/* highest set channel in CLIPL, CLIPH, HLIPL,  */
12862306a36Sopenharmony_ci						/* or HLIPH.  When IPR is written with CL set,	*/
12962306a36Sopenharmony_ci						/* the bit in H/CLIPL or H/CLIPH corresponding	*/
13062306a36Sopenharmony_ci						/* to the CN value written will be cleared.	*/
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci#define INTE			0x0c		/* Interrupt enable register			*/
13362306a36Sopenharmony_ci#define INTE_VIRTUALSB_MASK	0xc0000000	/* Virtual Soundblaster I/O port capture	*/
13462306a36Sopenharmony_ci#define INTE_VIRTUALSB_220	0x00000000	/* Capture at I/O base address 0x220-0x22f	*/
13562306a36Sopenharmony_ci#define INTE_VIRTUALSB_240	0x40000000	/* Capture at I/O base address 0x240		*/
13662306a36Sopenharmony_ci#define INTE_VIRTUALSB_260	0x80000000	/* Capture at I/O base address 0x260		*/
13762306a36Sopenharmony_ci#define INTE_VIRTUALSB_280	0xc0000000	/* Capture at I/O base address 0x280		*/
13862306a36Sopenharmony_ci#define INTE_VIRTUALMPU_MASK	0x30000000	/* Virtual MPU I/O port capture			*/
13962306a36Sopenharmony_ci#define INTE_VIRTUALMPU_300	0x00000000	/* Capture at I/O base address 0x300-0x301	*/
14062306a36Sopenharmony_ci#define INTE_VIRTUALMPU_310	0x10000000	/* Capture at I/O base address 0x310		*/
14162306a36Sopenharmony_ci#define INTE_VIRTUALMPU_320	0x20000000	/* Capture at I/O base address 0x320		*/
14262306a36Sopenharmony_ci#define INTE_VIRTUALMPU_330	0x30000000	/* Capture at I/O base address 0x330		*/
14362306a36Sopenharmony_ci#define INTE_MASTERDMAENABLE	0x08000000	/* Master DMA emulation at 0x000-0x00f		*/
14462306a36Sopenharmony_ci#define INTE_SLAVEDMAENABLE	0x04000000	/* Slave DMA emulation at 0x0c0-0x0df		*/
14562306a36Sopenharmony_ci#define INTE_MASTERPICENABLE	0x02000000	/* Master PIC emulation at 0x020-0x021		*/
14662306a36Sopenharmony_ci#define INTE_SLAVEPICENABLE	0x01000000	/* Slave PIC emulation at 0x0a0-0x0a1		*/
14762306a36Sopenharmony_ci#define INTE_VSBENABLE		0x00800000	/* Enable virtual Soundblaster			*/
14862306a36Sopenharmony_ci#define INTE_ADLIBENABLE	0x00400000	/* Enable AdLib emulation at 0x388-0x38b	*/
14962306a36Sopenharmony_ci#define INTE_MPUENABLE		0x00200000	/* Enable virtual MPU				*/
15062306a36Sopenharmony_ci#define INTE_FORCEINT		0x00100000	/* Continuously assert INTAN			*/
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ci#define INTE_MRHANDENABLE	0x00080000	/* Enable the "Mr. Hand" logic			*/
15362306a36Sopenharmony_ci						/* NOTE: There is no reason to use this under	*/
15462306a36Sopenharmony_ci						/* Linux, and it will cause odd hardware 	*/
15562306a36Sopenharmony_ci						/* behavior and possibly random segfaults and	*/
15662306a36Sopenharmony_ci						/* lockups if enabled.				*/
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci#define INTE_A_GPIOENABLE 	0x00040000	/* Enable GPIO input change interrupts		*/
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ci/* The next two interrupts are for the midi port on the Audigy Drive (A_MPU1)			*/
16162306a36Sopenharmony_ci#define INTE_A_MIDITXENABLE2	0x00020000	/* Enable MIDI transmit-buffer-empty interrupts	*/
16262306a36Sopenharmony_ci#define INTE_A_MIDIRXENABLE2	0x00010000	/* Enable MIDI receive-buffer-empty interrupts	*/
16362306a36Sopenharmony_ci
16462306a36Sopenharmony_ci#define INTE_A_SPDIF_BUFFULL_ENABLE 	0x00008000
16562306a36Sopenharmony_ci#define INTE_A_SPDIF_HALFBUFFULL_ENABLE	0x00004000
16662306a36Sopenharmony_ci
16762306a36Sopenharmony_ci#define INTE_SAMPLERATETRACKER	0x00002000	/* Enable sample rate tracker interrupts	*/
16862306a36Sopenharmony_ci						/* NOTE: This bit must always be enabled       	*/
16962306a36Sopenharmony_ci#define INTE_FXDSPENABLE	0x00001000	/* Enable FX DSP interrupts			*/
17062306a36Sopenharmony_ci#define INTE_PCIERRORENABLE	0x00000800	/* Enable PCI bus error interrupts		*/
17162306a36Sopenharmony_ci#define INTE_VOLINCRENABLE	0x00000400	/* Enable volume increment button interrupts	*/
17262306a36Sopenharmony_ci#define INTE_VOLDECRENABLE	0x00000200	/* Enable volume decrement button interrupts	*/
17362306a36Sopenharmony_ci#define INTE_MUTEENABLE		0x00000100	/* Enable mute button interrupts		*/
17462306a36Sopenharmony_ci#define INTE_MICBUFENABLE	0x00000080	/* Enable microphone buffer interrupts		*/
17562306a36Sopenharmony_ci#define INTE_ADCBUFENABLE	0x00000040	/* Enable ADC buffer interrupts			*/
17662306a36Sopenharmony_ci#define INTE_EFXBUFENABLE	0x00000020	/* Enable Effects buffer interrupts		*/
17762306a36Sopenharmony_ci#define INTE_GPSPDIFENABLE	0x00000010	/* Enable GPSPDIF status interrupts		*/
17862306a36Sopenharmony_ci#define INTE_CDSPDIFENABLE	0x00000008	/* Enable CDSPDIF status interrupts		*/
17962306a36Sopenharmony_ci#define INTE_INTERVALTIMERENB	0x00000004	/* Enable interval timer interrupts		*/
18062306a36Sopenharmony_ci#define INTE_MIDITXENABLE	0x00000002	/* Enable MIDI transmit-buffer-empty interrupts	*/
18162306a36Sopenharmony_ci#define INTE_MIDIRXENABLE	0x00000001	/* Enable MIDI receive-buffer-empty interrupts	*/
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_ci#define WC			0x10		/* Wall Clock register				*/
18462306a36Sopenharmony_ciSUB_REG(WC, SAMPLECOUNTER,	0x03FFFFC0)	/* Sample periods elapsed since reset		*/
18562306a36Sopenharmony_ciSUB_REG(WC, CURRENTCHANNEL,	0x0000003F)	/* Channel [0..63] currently being serviced	*/
18662306a36Sopenharmony_ci						/* NOTE: Each channel takes 1/64th of a sample	*/
18762306a36Sopenharmony_ci						/* period to be serviced.			*/
18862306a36Sopenharmony_ci
18962306a36Sopenharmony_ci#define HCFG			0x14		/* Hardware config register			*/
19062306a36Sopenharmony_ci						/* NOTE: There is no reason to use the legacy	*/
19162306a36Sopenharmony_ci						/* SoundBlaster emulation stuff described below	*/
19262306a36Sopenharmony_ci						/* under Linux, and all kinds of weird hardware	*/
19362306a36Sopenharmony_ci						/* behavior can result if you try.  Don't.	*/
19462306a36Sopenharmony_ci#define HCFG_LEGACYFUNC_MASK	0xe0000000	/* Legacy function number 			*/
19562306a36Sopenharmony_ci#define HCFG_LEGACYFUNC_MPU	0x00000000	/* Legacy MPU	 				*/
19662306a36Sopenharmony_ci#define HCFG_LEGACYFUNC_SB	0x40000000	/* Legacy SB					*/
19762306a36Sopenharmony_ci#define HCFG_LEGACYFUNC_AD	0x60000000	/* Legacy AD					*/
19862306a36Sopenharmony_ci#define HCFG_LEGACYFUNC_MPIC	0x80000000	/* Legacy MPIC					*/
19962306a36Sopenharmony_ci#define HCFG_LEGACYFUNC_MDMA	0xa0000000	/* Legacy MDMA					*/
20062306a36Sopenharmony_ci#define HCFG_LEGACYFUNC_SPCI	0xc0000000	/* Legacy SPCI					*/
20162306a36Sopenharmony_ci#define HCFG_LEGACYFUNC_SDMA	0xe0000000	/* Legacy SDMA					*/
20262306a36Sopenharmony_ci#define HCFG_IOCAPTUREADDR	0x1f000000	/* The 4 LSBs of the captured I/O address.	*/
20362306a36Sopenharmony_ci#define HCFG_LEGACYWRITE	0x00800000	/* 1 = write, 0 = read 				*/
20462306a36Sopenharmony_ci#define HCFG_LEGACYWORD		0x00400000	/* 1 = word, 0 = byte 				*/
20562306a36Sopenharmony_ci#define HCFG_LEGACYINT		0x00200000	/* 1 = legacy event captured. Write 1 to clear.	*/
20662306a36Sopenharmony_ci						/* NOTE: The rest of the bits in this register	*/
20762306a36Sopenharmony_ci						/* _are_ relevant under Linux.			*/
20862306a36Sopenharmony_ci#define HCFG_PUSH_BUTTON_ENABLE 0x00100000	/* Enables Volume Inc/Dec and Mute functions    */
20962306a36Sopenharmony_ci#define HCFG_BAUD_RATE		0x00080000	/* 0 = 48kHz, 1 = 44.1kHz			*/
21062306a36Sopenharmony_ci#define HCFG_EXPANDED_MEM	0x00040000	/* 1 = any 16M of 4G addr, 0 = 32M of 2G addr	*/
21162306a36Sopenharmony_ci#define HCFG_CODECFORMAT_MASK	0x00030000	/* CODEC format					*/
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ci/* Specific to Alice2, CA0102 */
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_ci#define HCFG_CODECFORMAT_AC97_1	0x00000000	/* AC97 CODEC format -- Ver 1.03		*/
21662306a36Sopenharmony_ci#define HCFG_CODECFORMAT_AC97_2	0x00010000	/* AC97 CODEC format -- Ver 2.1			*/
21762306a36Sopenharmony_ci#define HCFG_AUTOMUTE_ASYNC	0x00008000	/* When set, the async sample rate convertors	*/
21862306a36Sopenharmony_ci						/* will automatically mute their output when	*/
21962306a36Sopenharmony_ci						/* they are not rate-locked to the external	*/
22062306a36Sopenharmony_ci						/* async audio source  				*/
22162306a36Sopenharmony_ci#define HCFG_AUTOMUTE_SPDIF	0x00004000	/* When set, the async sample rate convertors	*/
22262306a36Sopenharmony_ci						/* will automatically mute their output when	*/
22362306a36Sopenharmony_ci						/* the SPDIF V-bit indicates invalid audio	*/
22462306a36Sopenharmony_ci#define HCFG_EMU32_SLAVE	0x00002000	/* 0 = Master, 1 = Slave. Slave for EMU1010	*/
22562306a36Sopenharmony_ci#define HCFG_SLOW_RAMP		0x00001000	/* Increases Send Smoothing time constant	*/
22662306a36Sopenharmony_ci/* 0x00000800 not used on Alice2 */
22762306a36Sopenharmony_ci#define HCFG_PHASE_TRACK_MASK	0x00000700	/* When set, forces corresponding input to	*/
22862306a36Sopenharmony_ci						/* phase track the previous input.		*/
22962306a36Sopenharmony_ci						/* I2S0 can phase track the last S/PDIF input	*/
23062306a36Sopenharmony_ci#define HCFG_I2S_ASRC_ENABLE	0x00000070	/* When set, enables asynchronous sample rate   */
23162306a36Sopenharmony_ci						/* conversion for the corresponding		*/
23262306a36Sopenharmony_ci 						/* I2S format input				*/
23362306a36Sopenharmony_ci/* Rest of HCFG 0x0000000f same as below. LOCKSOUNDCACHE etc.  */
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_ci/* Older chips */
23662306a36Sopenharmony_ci
23762306a36Sopenharmony_ci#define HCFG_CODECFORMAT_AC97	0x00000000	/* AC97 CODEC format -- Primary Output		*/
23862306a36Sopenharmony_ci#define HCFG_CODECFORMAT_I2S	0x00010000	/* I2S CODEC format -- Secondary (Rear) Output	*/
23962306a36Sopenharmony_ci#define HCFG_GPINPUT0		0x00004000	/* External pin112				*/
24062306a36Sopenharmony_ci#define HCFG_GPINPUT1		0x00002000	/* External pin110				*/
24162306a36Sopenharmony_ci#define HCFG_GPOUTPUT_MASK	0x00001c00	/* External pins which may be controlled	*/
24262306a36Sopenharmony_ci#define HCFG_GPOUT0		0x00001000	/* External pin? (spdif enable on 5.1)		*/
24362306a36Sopenharmony_ci#define HCFG_GPOUT1		0x00000800	/* External pin? (IR)				*/
24462306a36Sopenharmony_ci#define HCFG_GPOUT2		0x00000400	/* External pin? (IR)				*/
24562306a36Sopenharmony_ci#define HCFG_JOYENABLE      	0x00000200	/* Internal joystick enable    			*/
24662306a36Sopenharmony_ci#define HCFG_PHASETRACKENABLE	0x00000100	/* Phase tracking enable			*/
24762306a36Sopenharmony_ci						/* 1 = Force all 3 async digital inputs to use	*/
24862306a36Sopenharmony_ci						/* the same async sample rate tracker (ZVIDEO)	*/
24962306a36Sopenharmony_ci#define HCFG_AC3ENABLE_MASK	0x000000e0	/* AC3 async input control - Not implemented	*/
25062306a36Sopenharmony_ci#define HCFG_AC3ENABLE_ZVIDEO	0x00000080	/* Channels 0 and 1 replace ZVIDEO		*/
25162306a36Sopenharmony_ci#define HCFG_AC3ENABLE_CDSPDIF	0x00000040	/* Channels 0 and 1 replace CDSPDIF		*/
25262306a36Sopenharmony_ci#define HCFG_AC3ENABLE_GPSPDIF  0x00000020      /* Channels 0 and 1 replace GPSPDIF             */
25362306a36Sopenharmony_ci#define HCFG_AUTOMUTE		0x00000010	/* When set, the async sample rate convertors	*/
25462306a36Sopenharmony_ci						/* will automatically mute their output when	*/
25562306a36Sopenharmony_ci						/* they are not rate-locked to the external	*/
25662306a36Sopenharmony_ci						/* async audio source  				*/
25762306a36Sopenharmony_ci#define HCFG_LOCKSOUNDCACHE	0x00000008	/* 1 = Cancel bustmaster accesses to soundcache */
25862306a36Sopenharmony_ci						/* NOTE: This should generally never be used.  	*/
25962306a36Sopenharmony_ciSUB_REG(HCFG, LOCKTANKCACHE,	0x00000004)	/* 1 = Cancel bustmaster accesses to tankcache	*/
26062306a36Sopenharmony_ci						/* NOTE: This should generally never be used.  	*/
26162306a36Sopenharmony_ci#define HCFG_MUTEBUTTONENABLE	0x00000002	/* 1 = Master mute button sets AUDIOENABLE = 0.	*/
26262306a36Sopenharmony_ci						/* NOTE: This is a 'cheap' way to implement a	*/
26362306a36Sopenharmony_ci						/* master mute function on the mute button, and	*/
26462306a36Sopenharmony_ci						/* in general should not be used unless a more	*/
26562306a36Sopenharmony_ci						/* sophisticated master mute function has not	*/
26662306a36Sopenharmony_ci						/* been written.       				*/
26762306a36Sopenharmony_ci#define HCFG_AUDIOENABLE	0x00000001	/* 0 = CODECs transmit zero-valued samples	*/
26862306a36Sopenharmony_ci						/* Should be set to 1 when the EMU10K1 is	*/
26962306a36Sopenharmony_ci						/* completely initialized.			*/
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_ci// On Audigy, the MPU port moved to the 0x70-0x74 ptr registers
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ci#define MUDATA			0x18		/* MPU401 data register (8 bits)       		*/
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_ci#define MUCMD			0x19		/* MPU401 command register (8 bits)    		*/
27662306a36Sopenharmony_ci#define MUCMD_RESET		0xff		/* RESET command				*/
27762306a36Sopenharmony_ci#define MUCMD_ENTERUARTMODE	0x3f		/* Enter_UART_mode command			*/
27862306a36Sopenharmony_ci						/* NOTE: All other commands are ignored		*/
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci#define MUSTAT			MUCMD		/* MPU401 status register (8 bits)     		*/
28162306a36Sopenharmony_ci#define MUSTAT_IRDYN		0x80		/* 0 = MIDI data or command ACK			*/
28262306a36Sopenharmony_ci#define MUSTAT_ORDYN		0x40		/* 0 = MUDATA can accept a command or data	*/
28362306a36Sopenharmony_ci
28462306a36Sopenharmony_ci#define A_GPIO			0x18		/* GPIO on Audigy card (16bits)			*/
28562306a36Sopenharmony_ci#define A_GPINPUT_MASK		0xff00		/* Alice/2 has 8 input pins			*/
28662306a36Sopenharmony_ci#define A3_GPINPUT_MASK		0x3f00		/* ... while Tina/2 has only 6			*/
28762306a36Sopenharmony_ci#define A_GPOUTPUT_MASK		0x00ff
28862306a36Sopenharmony_ci
28962306a36Sopenharmony_ci// The GPIO port is used for I/O config on Sound Blasters;
29062306a36Sopenharmony_ci// card-specific info can be found in the emu_chip_details table.
29162306a36Sopenharmony_ci// On E-MU cards the port is used as the interface to the FPGA.
29262306a36Sopenharmony_ci
29362306a36Sopenharmony_ci// Audigy output/GPIO stuff taken from the kX drivers
29462306a36Sopenharmony_ci#define A_IOCFG			A_GPIO
29562306a36Sopenharmony_ci#define A_IOCFG_GPOUT0		0x0044		/* analog/digital				*/
29662306a36Sopenharmony_ci#define A_IOCFG_DISABLE_ANALOG	0x0040		/* = 'enable' for Audigy2 (chiprev=4)		*/
29762306a36Sopenharmony_ci#define A_IOCFG_ENABLE_DIGITAL	0x0004
29862306a36Sopenharmony_ci#define A_IOCFG_ENABLE_DIGITAL_AUDIGY4	0x0080
29962306a36Sopenharmony_ci#define A_IOCFG_UNKNOWN_20      0x0020
30062306a36Sopenharmony_ci#define A_IOCFG_DISABLE_AC97_FRONT      0x0080  /* turn off ac97 front -> front (10k2.1)	*/
30162306a36Sopenharmony_ci#define A_IOCFG_GPOUT1		0x0002		/* IR? drive's internal bypass (?)		*/
30262306a36Sopenharmony_ci#define A_IOCFG_GPOUT2		0x0001		/* IR */
30362306a36Sopenharmony_ci#define A_IOCFG_MULTIPURPOSE_JACK	0x2000  /* center+lfe+rear_center (a2/a2ex)		*/
30462306a36Sopenharmony_ci                                                /* + digital for generic 10k2			*/
30562306a36Sopenharmony_ci#define A_IOCFG_DIGITAL_JACK    0x1000          /* digital for a2 platinum			*/
30662306a36Sopenharmony_ci#define A_IOCFG_FRONT_JACK      0x4000
30762306a36Sopenharmony_ci#define A_IOCFG_REAR_JACK       0x8000
30862306a36Sopenharmony_ci#define A_IOCFG_PHONES_JACK     0x0100          /* LiveDrive					*/
30962306a36Sopenharmony_ci
31062306a36Sopenharmony_ci#define TIMER			0x1a		/* Timer terminal count register		*/
31162306a36Sopenharmony_ci						/* NOTE: After the rate is changed, a maximum	*/
31262306a36Sopenharmony_ci						/* of 1024 sample periods should be allowed	*/
31362306a36Sopenharmony_ci						/* before the new rate is guaranteed accurate.	*/
31462306a36Sopenharmony_ci#define TIMER_RATE_MASK		0x03ff		/* Timer interrupt rate in sample periods	*/
31562306a36Sopenharmony_ci						/* 0 == 1024 periods, [1..4] are not useful	*/
31662306a36Sopenharmony_ci
31762306a36Sopenharmony_ci#define AC97DATA		0x1c		/* AC97 register set data register (16 bit)	*/
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_ci#define AC97ADDRESS		0x1e		/* AC97 register set address register (8 bit)	*/
32062306a36Sopenharmony_ci#define AC97ADDRESS_READY	0x80		/* Read-only bit, reflects CODEC READY signal	*/
32162306a36Sopenharmony_ci#define AC97ADDRESS_ADDRESS	0x7f		/* Address of indexed AC97 register		*/
32262306a36Sopenharmony_ci
32362306a36Sopenharmony_ci/* Available on the Audigy 2 and Audigy 4 only. This is the P16V chip. */
32462306a36Sopenharmony_ci#define PTR2			0x20		/* Indexed register set pointer register	*/
32562306a36Sopenharmony_ci#define DATA2			0x24		/* Indexed register set data register		*/
32662306a36Sopenharmony_ci#define IPR2			0x28		/* P16V interrupt pending register		*/
32762306a36Sopenharmony_ci#define IPR2_PLAYBACK_CH_0_LOOP      0x00001000 /* Playback Channel 0 loop                               */
32862306a36Sopenharmony_ci#define IPR2_PLAYBACK_CH_0_HALF_LOOP 0x00000100 /* Playback Channel 0 half loop                          */
32962306a36Sopenharmony_ci#define IPR2_CAPTURE_CH_0_LOOP       0x00100000 /* Capture Channel 0 loop                               */
33062306a36Sopenharmony_ci#define IPR2_CAPTURE_CH_0_HALF_LOOP  0x00010000 /* Capture Channel 0 half loop                          */
33162306a36Sopenharmony_ci						/* 0x00000100 Playback. Only in once per period.
33262306a36Sopenharmony_ci						 * 0x00110000 Capture. Int on half buffer.
33362306a36Sopenharmony_ci						 */
33462306a36Sopenharmony_ci#define INTE2			0x2c		/* P16V Interrupt enable register. 	*/
33562306a36Sopenharmony_ci#define INTE2_PLAYBACK_CH_0_LOOP      0x00001000 /* Playback Channel 0 loop                               */
33662306a36Sopenharmony_ci#define INTE2_PLAYBACK_CH_0_HALF_LOOP 0x00000100 /* Playback Channel 0 half loop                          */
33762306a36Sopenharmony_ci#define INTE2_PLAYBACK_CH_1_LOOP      0x00002000 /* Playback Channel 1 loop                               */
33862306a36Sopenharmony_ci#define INTE2_PLAYBACK_CH_1_HALF_LOOP 0x00000200 /* Playback Channel 1 half loop                          */
33962306a36Sopenharmony_ci#define INTE2_PLAYBACK_CH_2_LOOP      0x00004000 /* Playback Channel 2 loop                               */
34062306a36Sopenharmony_ci#define INTE2_PLAYBACK_CH_2_HALF_LOOP 0x00000400 /* Playback Channel 2 half loop                          */
34162306a36Sopenharmony_ci#define INTE2_PLAYBACK_CH_3_LOOP      0x00008000 /* Playback Channel 3 loop                               */
34262306a36Sopenharmony_ci#define INTE2_PLAYBACK_CH_3_HALF_LOOP 0x00000800 /* Playback Channel 3 half loop                          */
34362306a36Sopenharmony_ci#define INTE2_CAPTURE_CH_0_LOOP       0x00100000 /* Capture Channel 0 loop                               */
34462306a36Sopenharmony_ci#define INTE2_CAPTURE_CH_0_HALF_LOOP  0x00010000 /* Caputre Channel 0 half loop                          */
34562306a36Sopenharmony_ci#define HCFG2			0x34		/* Defaults: 0, win2000 sets it to 00004201 */
34662306a36Sopenharmony_ci						/* 0x00000000 2-channel output. */
34762306a36Sopenharmony_ci						/* 0x00000200 8-channel output. */
34862306a36Sopenharmony_ci						/* 0x00000004 pauses stream/irq fail. */
34962306a36Sopenharmony_ci						/* Rest of bits do nothing to sound output */
35062306a36Sopenharmony_ci						/* bit 0: Enable P16V audio.
35162306a36Sopenharmony_ci						 * bit 1: Lock P16V record memory cache.
35262306a36Sopenharmony_ci						 * bit 2: Lock P16V playback memory cache.
35362306a36Sopenharmony_ci						 * bit 3: Dummy record insert zero samples.
35462306a36Sopenharmony_ci						 * bit 8: Record 8-channel in phase.
35562306a36Sopenharmony_ci						 * bit 9: Playback 8-channel in phase.
35662306a36Sopenharmony_ci						 * bit 11-12: Playback mixer attenuation: 0=0dB, 1=-6dB, 2=-12dB, 3=Mute.
35762306a36Sopenharmony_ci						 * bit 13: Playback mixer enable.
35862306a36Sopenharmony_ci						 * bit 14: Route SRC48 mixer output to fx engine.
35962306a36Sopenharmony_ci						 * bit 15: Enable IEEE 1394 chip.
36062306a36Sopenharmony_ci						 */
36162306a36Sopenharmony_ci#define IPR3			0x38		/* Cdif interrupt pending register		*/
36262306a36Sopenharmony_ci#define INTE3			0x3c		/* Cdif interrupt enable register. 	*/
36362306a36Sopenharmony_ci
36462306a36Sopenharmony_ci/************************************************************************************************/
36562306a36Sopenharmony_ci/* PCI function 1 registers, address = <val> + PCIBASE1						*/
36662306a36Sopenharmony_ci/************************************************************************************************/
36762306a36Sopenharmony_ci
36862306a36Sopenharmony_ci#define JOYSTICK1		0x00		/* Analog joystick port register		*/
36962306a36Sopenharmony_ci#define JOYSTICK2		0x01		/* Analog joystick port register		*/
37062306a36Sopenharmony_ci#define JOYSTICK3		0x02		/* Analog joystick port register		*/
37162306a36Sopenharmony_ci#define JOYSTICK4		0x03		/* Analog joystick port register		*/
37262306a36Sopenharmony_ci#define JOYSTICK5		0x04		/* Analog joystick port register		*/
37362306a36Sopenharmony_ci#define JOYSTICK6		0x05		/* Analog joystick port register		*/
37462306a36Sopenharmony_ci#define JOYSTICK7		0x06		/* Analog joystick port register		*/
37562306a36Sopenharmony_ci#define JOYSTICK8		0x07		/* Analog joystick port register		*/
37662306a36Sopenharmony_ci
37762306a36Sopenharmony_ci/* When writing, any write causes JOYSTICK_COMPARATOR output enable to be pulsed on write.	*/
37862306a36Sopenharmony_ci/* When reading, use these bitfields: */
37962306a36Sopenharmony_ci#define JOYSTICK_BUTTONS	0x0f		/* Joystick button data				*/
38062306a36Sopenharmony_ci#define JOYSTICK_COMPARATOR	0xf0		/* Joystick comparator data			*/
38162306a36Sopenharmony_ci
38262306a36Sopenharmony_ci/********************************************************************************************************/
38362306a36Sopenharmony_ci/* Emu10k1 pointer-offset register set, accessed through the PTR and DATA registers			*/
38462306a36Sopenharmony_ci/********************************************************************************************************/
38562306a36Sopenharmony_ci
38662306a36Sopenharmony_ci// No official documentation was released for EMU10K1, but some info
38762306a36Sopenharmony_ci// about playback can be extrapolated from the EMU8K documents:
38862306a36Sopenharmony_ci// "AWE32/EMU8000 Programmer’s Guide" (emu8kpgm.pdf) - registers
38962306a36Sopenharmony_ci// "AWE32 Developer's Information Pack" (adip301.pdf) - high-level view
39062306a36Sopenharmony_ci
39162306a36Sopenharmony_ci// The short version:
39262306a36Sopenharmony_ci// - The engine has 64 playback channels, also called voices. The channels
39362306a36Sopenharmony_ci//   operate independently, except when paired for stereo (see below).
39462306a36Sopenharmony_ci// - PCM samples are fetched into the cache; see description of CD0 below.
39562306a36Sopenharmony_ci// - Samples are consumed at the rate CPF_CURRENTPITCH.
39662306a36Sopenharmony_ci// - 8-bit samples are transformed upon use: cooked = (raw ^ 0x80) << 8
39762306a36Sopenharmony_ci// - 8 samples are read at CCR_READADDRESS:CPF_FRACADDRESS and interpolated
39862306a36Sopenharmony_ci//   according to CCCA_INTERPROM_*. With CCCA_INTERPROM_0 selected and a zero
39962306a36Sopenharmony_ci//   CPF_FRACADDRESS, this results in CCR_READADDRESS[3] being used verbatim.
40062306a36Sopenharmony_ci// - The value is multiplied by CVCF_CURRENTVOL.
40162306a36Sopenharmony_ci// - The value goes through a filter with cutoff CVCF_CURRENTFILTER;
40262306a36Sopenharmony_ci//   delay stages Z1 and Z2.
40362306a36Sopenharmony_ci// - The value is added by so-called `sends` to 4 (EMU10K1) / 8 (EMU10K2)
40462306a36Sopenharmony_ci//   of the 16 (EMU10K1) / 64 (EMU10K2) FX bus accumulators via FXRT*,
40562306a36Sopenharmony_ci//   multiplied by a per-send amount (*_FXSENDAMOUNT_*).
40662306a36Sopenharmony_ci//   The scaling of the send amounts is exponential-ish.
40762306a36Sopenharmony_ci// - The DSP has a go at FXBUS* and outputs the values to EXTOUT* or EMU32OUT*.
40862306a36Sopenharmony_ci// - The pitch, volume, and filter cutoff can be modulated by two envelope
40962306a36Sopenharmony_ci//   engines and two low frequency oscillators.
41062306a36Sopenharmony_ci// - To avoid abrupt changes to the parameters (which may cause audible
41162306a36Sopenharmony_ci//   distortion), the modulation engine sets the target registers, towards
41262306a36Sopenharmony_ci//   which the current registers "swerve" gradually.
41362306a36Sopenharmony_ci
41462306a36Sopenharmony_ci// For the odd channel in a stereo pair, these registers are meaningless:
41562306a36Sopenharmony_ci//   CPF_STEREO, CPF_CURRENTPITCH, PTRX_PITCHTARGET, CCR_CACHEINVALIDSIZE,
41662306a36Sopenharmony_ci//   PSST_LOOPSTARTADDR, DSL_LOOPENDADDR, CCCA_CURRADDR
41762306a36Sopenharmony_ci// The somewhat non-obviously still meaningful ones are:
41862306a36Sopenharmony_ci//   CPF_STOP, CPF_FRACADDRESS, CCR_READADDRESS (!),
41962306a36Sopenharmony_ci//   CCCA_INTERPROM, CCCA_8BITSELECT (!)
42062306a36Sopenharmony_ci// (The envelope engine is ignored here, as stereo matters only for verbatim playback.)
42162306a36Sopenharmony_ci
42262306a36Sopenharmony_ci#define CPF			0x00		/* Current pitch and fraction register			*/
42362306a36Sopenharmony_ciSUB_REG(CPF, CURRENTPITCH,	0xffff0000)	/* Current pitch (linear, 0x4000 == unity pitch shift) 	*/
42462306a36Sopenharmony_ci#define CPF_STEREO_MASK		0x00008000	/* 1 = Even channel interleave, odd channel locked	*/
42562306a36Sopenharmony_ciSUB_REG(CPF, STOP,		0x00004000)	/* 1 = Current pitch forced to 0			*/
42662306a36Sopenharmony_ci						/* Can be set only while matching bit in SOLEx is 1	*/
42762306a36Sopenharmony_ci#define CPF_FRACADDRESS_MASK	0x00003fff	/* Linear fractional address of the current channel	*/
42862306a36Sopenharmony_ci
42962306a36Sopenharmony_ci#define PTRX			0x01		/* Pitch target and send A/B amounts register		*/
43062306a36Sopenharmony_ciSUB_REG(PTRX, PITCHTARGET,	0xffff0000)	/* Pitch target of specified channel			*/
43162306a36Sopenharmony_ciSUB_REG(PTRX, FXSENDAMOUNT_A,	0x0000ff00)	/* Linear level of channel output sent to FX send bus A	*/
43262306a36Sopenharmony_ciSUB_REG(PTRX, FXSENDAMOUNT_B,	0x000000ff)	/* Linear level of channel output sent to FX send bus B	*/
43362306a36Sopenharmony_ci
43462306a36Sopenharmony_ci// Note: the volumes are raw multpliers, so real 100% is impossible.
43562306a36Sopenharmony_ci#define CVCF			0x02		/* Current volume and filter cutoff register		*/
43662306a36Sopenharmony_ciSUB_REG(CVCF, CURRENTVOL,	0xffff0000)	/* Current linear volume of specified channel		*/
43762306a36Sopenharmony_ciSUB_REG(CVCF, CURRENTFILTER,	0x0000ffff)	/* Current filter cutoff frequency of specified channel	*/
43862306a36Sopenharmony_ci
43962306a36Sopenharmony_ci#define VTFT			0x03		/* Volume target and filter cutoff target register	*/
44062306a36Sopenharmony_ciSUB_REG(VTFT, VOLUMETARGET,	0xffff0000)	/* Volume target of specified channel			*/
44162306a36Sopenharmony_ciSUB_REG(VTFT, FILTERTARGET,	0x0000ffff)	/* Filter cutoff target of specified channel		*/
44262306a36Sopenharmony_ci
44362306a36Sopenharmony_ci#define Z1			0x05		/* Filter delay memory 1 register			*/
44462306a36Sopenharmony_ci
44562306a36Sopenharmony_ci#define Z2			0x04		/* Filter delay memory 2 register			*/
44662306a36Sopenharmony_ci
44762306a36Sopenharmony_ci#define PSST			0x06		/* Send C amount and loop start address register	*/
44862306a36Sopenharmony_ciSUB_REG(PSST, FXSENDAMOUNT_C,	0xff000000)	/* Linear level of channel output sent to FX send bus C	*/
44962306a36Sopenharmony_ciSUB_REG(PSST, LOOPSTARTADDR,	0x00ffffff)	/* Loop start address of the specified channel		*/
45062306a36Sopenharmony_ci
45162306a36Sopenharmony_ci#define DSL			0x07		/* Send D amount and loop end address register	*/
45262306a36Sopenharmony_ciSUB_REG(DSL, FXSENDAMOUNT_D,	0xff000000)	/* Linear level of channel output sent to FX send bus D	*/
45362306a36Sopenharmony_ciSUB_REG(DSL, LOOPENDADDR,	0x00ffffff)	/* Loop end address of the specified channel		*/
45462306a36Sopenharmony_ci
45562306a36Sopenharmony_ci#define CCCA			0x08		/* Filter Q, interp. ROM, byte size, cur. addr register */
45662306a36Sopenharmony_ciSUB_REG(CCCA, RESONANCE,	0xf0000000)	/* Lowpass filter resonance (Q) height			*/
45762306a36Sopenharmony_ci#define CCCA_INTERPROM_MASK	0x0e000000	/* Selects passband of interpolation ROM		*/
45862306a36Sopenharmony_ci						/* 1 == full band, 7 == lowpass				*/
45962306a36Sopenharmony_ci						/* ROM 0 is used when pitch shifting downward or less	*/
46062306a36Sopenharmony_ci						/* then 3 semitones upward.  Increasingly higher ROM	*/
46162306a36Sopenharmony_ci						/* numbers are used, typically in steps of 3 semitones,	*/
46262306a36Sopenharmony_ci						/* as upward pitch shifting is performed.		*/
46362306a36Sopenharmony_ci#define CCCA_INTERPROM_0	0x00000000	/* Select interpolation ROM 0				*/
46462306a36Sopenharmony_ci#define CCCA_INTERPROM_1	0x02000000	/* Select interpolation ROM 1				*/
46562306a36Sopenharmony_ci#define CCCA_INTERPROM_2	0x04000000	/* Select interpolation ROM 2				*/
46662306a36Sopenharmony_ci#define CCCA_INTERPROM_3	0x06000000	/* Select interpolation ROM 3				*/
46762306a36Sopenharmony_ci#define CCCA_INTERPROM_4	0x08000000	/* Select interpolation ROM 4				*/
46862306a36Sopenharmony_ci#define CCCA_INTERPROM_5	0x0a000000	/* Select interpolation ROM 5				*/
46962306a36Sopenharmony_ci#define CCCA_INTERPROM_6	0x0c000000	/* Select interpolation ROM 6				*/
47062306a36Sopenharmony_ci#define CCCA_INTERPROM_7	0x0e000000	/* Select interpolation ROM 7				*/
47162306a36Sopenharmony_ci#define CCCA_8BITSELECT		0x01000000	/* 1 = Sound memory for this channel uses 8-bit samples	*/
47262306a36Sopenharmony_ci						/* 8-bit samples are unsigned, 16-bit ones signed	*/
47362306a36Sopenharmony_ciSUB_REG(CCCA, CURRADDR,		0x00ffffff)	/* Current address of the selected channel		*/
47462306a36Sopenharmony_ci
47562306a36Sopenharmony_ci#define CCR			0x09		/* Cache control register				*/
47662306a36Sopenharmony_ciSUB_REG(CCR, CACHEINVALIDSIZE,	0xfe000000)	/* Number of invalid samples before the read address	*/
47762306a36Sopenharmony_ci#define CCR_CACHELOOPFLAG	0x01000000	/* 1 = Cache has a loop service pending			*/
47862306a36Sopenharmony_ci#define CCR_INTERLEAVEDSAMPLES	0x00800000	/* 1 = A cache service will fetch interleaved samples	*/
47962306a36Sopenharmony_ci						/* Auto-set from CPF_STEREO_MASK			*/
48062306a36Sopenharmony_ci#define CCR_WORDSIZEDSAMPLES	0x00400000	/* 1 = A cache service will fetch word sized samples	*/
48162306a36Sopenharmony_ci						/* Auto-set from CCCA_8BITSELECT			*/
48262306a36Sopenharmony_ciSUB_REG(CCR, READADDRESS,	0x003f0000)	/* Next cached sample to play				*/
48362306a36Sopenharmony_ciSUB_REG(CCR, LOOPINVALSIZE,	0x0000fe00)	/* Number of invalid samples in cache prior to loop	*/
48462306a36Sopenharmony_ci						/* NOTE: This is valid only if CACHELOOPFLAG is set	*/
48562306a36Sopenharmony_ci#define CCR_LOOPFLAG		0x00000100	/* Set for a single sample period when a loop occurs	*/
48662306a36Sopenharmony_ciSUB_REG(CCR, CACHELOOPADDRHI,	0x000000ff)	/* CLP_LOOPSTARTADDR's hi byte if CACHELOOPFLAG is set	*/
48762306a36Sopenharmony_ci
48862306a36Sopenharmony_ci#define CLP			0x0a		/* Cache loop register (valid if CCR_CACHELOOPFLAG = 1) */
48962306a36Sopenharmony_ci						/* NOTE: This register is normally not used		*/
49062306a36Sopenharmony_ciSUB_REG(CLP, CACHELOOPADDR,	0x0000ffff)	/* Cache loop address low word				*/
49162306a36Sopenharmony_ci
49262306a36Sopenharmony_ci#define FXRT			0x0b		/* Effects send routing register			*/
49362306a36Sopenharmony_ci						/* NOTE: It is illegal to assign the same routing to	*/
49462306a36Sopenharmony_ci						/* two effects sends.					*/
49562306a36Sopenharmony_ci#define FXRT_CHANNELA		0x000f0000	/* Effects send bus number for channel's effects send A	*/
49662306a36Sopenharmony_ci#define FXRT_CHANNELB		0x00f00000	/* Effects send bus number for channel's effects send B	*/
49762306a36Sopenharmony_ci#define FXRT_CHANNELC		0x0f000000	/* Effects send bus number for channel's effects send C	*/
49862306a36Sopenharmony_ci#define FXRT_CHANNELD		0xf0000000	/* Effects send bus number for channel's effects send D	*/
49962306a36Sopenharmony_ci
50062306a36Sopenharmony_ci#define MAPA			0x0c		/* Cache map A						*/
50162306a36Sopenharmony_ci#define MAPB			0x0d		/* Cache map B						*/
50262306a36Sopenharmony_ci
50362306a36Sopenharmony_ci#define MAP_PTE_MASK0		0xfffff000	/* The 20 MSBs of the PTE indexed by the PTI		*/
50462306a36Sopenharmony_ci#define MAP_PTI_MASK0		0x00000fff	/* The 12 bit index to one of the 4096 PTE dwords      	*/
50562306a36Sopenharmony_ci
50662306a36Sopenharmony_ci#define MAP_PTE_MASK1		0xffffe000	/* The 19 MSBs of the PTE indexed by the PTI		*/
50762306a36Sopenharmony_ci#define MAP_PTI_MASK1		0x00001fff	/* The 13 bit index to one of the 8192 PTE dwords      	*/
50862306a36Sopenharmony_ci
50962306a36Sopenharmony_ci/* 0x0e, 0x0f: Internal state, at least on Audigy */
51062306a36Sopenharmony_ci
51162306a36Sopenharmony_ci#define ENVVOL			0x10		/* Volume envelope register				*/
51262306a36Sopenharmony_ci#define ENVVOL_MASK		0x0000ffff	/* Current value of volume envelope state variable	*/
51362306a36Sopenharmony_ci						/* 0x8000-n == 666*n usec delay	       			*/
51462306a36Sopenharmony_ci
51562306a36Sopenharmony_ci#define ATKHLDV 		0x11		/* Volume envelope hold and attack register		*/
51662306a36Sopenharmony_ci#define ATKHLDV_PHASE0_MASK	0x00008000	/* 0 = Begin attack phase				*/
51762306a36Sopenharmony_ci#define ATKHLDV_HOLDTIME_MASK	0x00007f00	/* Envelope hold time (127-n == n*88.2msec)		*/
51862306a36Sopenharmony_ci#define ATKHLDV_ATTACKTIME_MASK	0x0000007f	/* Envelope attack time, log encoded			*/
51962306a36Sopenharmony_ci						/* 0 = infinite, 1 = 10.9msec, ... 0x7f = 5.5msec	*/
52062306a36Sopenharmony_ci
52162306a36Sopenharmony_ci#define DCYSUSV 		0x12		/* Volume envelope sustain and decay register		*/
52262306a36Sopenharmony_ci#define DCYSUSV_PHASE1_MASK	0x00008000	/* 0 = Begin decay phase, 1 = begin release phase	*/
52362306a36Sopenharmony_ci#define DCYSUSV_SUSTAINLEVEL_MASK 0x00007f00	/* 127 = full, 0 = off, 0.75dB increments		*/
52462306a36Sopenharmony_ci#define DCYSUSV_CHANNELENABLE_MASK 0x00000080	/* 0 = Inhibit envelope engine from writing values in	*/
52562306a36Sopenharmony_ci						/* this channel and from writing to pitch, filter and	*/
52662306a36Sopenharmony_ci						/* volume targets.					*/
52762306a36Sopenharmony_ci#define DCYSUSV_DECAYTIME_MASK	0x0000007f	/* Volume envelope decay time, log encoded     		*/
52862306a36Sopenharmony_ci						/* 0 = 43.7msec, 1 = 21.8msec, 0x7f = 22msec		*/
52962306a36Sopenharmony_ci
53062306a36Sopenharmony_ci#define LFOVAL1 		0x13		/* Modulation LFO value					*/
53162306a36Sopenharmony_ci#define LFOVAL_MASK		0x0000ffff	/* Current value of modulation LFO state variable	*/
53262306a36Sopenharmony_ci						/* 0x8000-n == 666*n usec delay				*/
53362306a36Sopenharmony_ci
53462306a36Sopenharmony_ci#define ENVVAL			0x14		/* Modulation envelope register				*/
53562306a36Sopenharmony_ci#define ENVVAL_MASK		0x0000ffff	/* Current value of modulation envelope state variable 	*/
53662306a36Sopenharmony_ci						/* 0x8000-n == 666*n usec delay				*/
53762306a36Sopenharmony_ci
53862306a36Sopenharmony_ci#define ATKHLDM			0x15		/* Modulation envelope hold and attack register		*/
53962306a36Sopenharmony_ci#define ATKHLDM_PHASE0_MASK	0x00008000	/* 0 = Begin attack phase				*/
54062306a36Sopenharmony_ci#define ATKHLDM_HOLDTIME	0x00007f00	/* Envelope hold time (127-n == n*42msec)		*/
54162306a36Sopenharmony_ci#define ATKHLDM_ATTACKTIME	0x0000007f	/* Envelope attack time, log encoded			*/
54262306a36Sopenharmony_ci						/* 0 = infinite, 1 = 11msec, ... 0x7f = 5.5msec		*/
54362306a36Sopenharmony_ci
54462306a36Sopenharmony_ci#define DCYSUSM			0x16		/* Modulation envelope decay and sustain register	*/
54562306a36Sopenharmony_ci#define DCYSUSM_PHASE1_MASK	0x00008000	/* 0 = Begin decay phase, 1 = begin release phase	*/
54662306a36Sopenharmony_ci#define DCYSUSM_SUSTAINLEVEL_MASK 0x00007f00	/* 127 = full, 0 = off, 0.75dB increments		*/
54762306a36Sopenharmony_ci#define DCYSUSM_DECAYTIME_MASK	0x0000007f	/* Envelope decay time, log encoded			*/
54862306a36Sopenharmony_ci						/* 0 = 43.7msec, 1 = 21.8msec, 0x7f = 22msec		*/
54962306a36Sopenharmony_ci
55062306a36Sopenharmony_ci#define LFOVAL2 		0x17		/* Vibrato LFO register					*/
55162306a36Sopenharmony_ci#define LFOVAL2_MASK		0x0000ffff	/* Current value of vibrato LFO state variable 		*/
55262306a36Sopenharmony_ci						/* 0x8000-n == 666*n usec delay				*/
55362306a36Sopenharmony_ci
55462306a36Sopenharmony_ci#define IP			0x18		/* Initial pitch register				*/
55562306a36Sopenharmony_ci#define IP_MASK			0x0000ffff	/* Exponential initial pitch shift			*/
55662306a36Sopenharmony_ci						/* 4 bits of octave, 12 bits of fractional octave	*/
55762306a36Sopenharmony_ci#define IP_UNITY		0x0000e000	/* Unity pitch shift					*/
55862306a36Sopenharmony_ci
55962306a36Sopenharmony_ci#define IFATN			0x19		/* Initial filter cutoff and attenuation register	*/
56062306a36Sopenharmony_ciSUB_REG(IFATN, FILTERCUTOFF,	0x0000ff00)	/* Initial filter cutoff frequency in exponential units	*/
56162306a36Sopenharmony_ci						/* 6 most significant bits are semitones		*/
56262306a36Sopenharmony_ci						/* 2 least significant bits are fractions		*/
56362306a36Sopenharmony_ciSUB_REG(IFATN, ATTENUATION,	0x000000ff)	/* Initial attenuation in 0.375dB steps			*/
56462306a36Sopenharmony_ci
56562306a36Sopenharmony_ci#define PEFE			0x1a		/* Pitch envelope and filter envelope amount register	*/
56662306a36Sopenharmony_ciSUB_REG(PEFE, PITCHAMOUNT,	0x0000ff00)	/* Pitch envlope amount					*/
56762306a36Sopenharmony_ci						/* Signed 2's complement, +/- one octave peak extremes	*/
56862306a36Sopenharmony_ciSUB_REG(PEFE, FILTERAMOUNT,	0x000000ff)	/* Filter envlope amount				*/
56962306a36Sopenharmony_ci						/* Signed 2's complement, +/- six octaves peak extremes */
57062306a36Sopenharmony_ci
57162306a36Sopenharmony_ci
57262306a36Sopenharmony_ci#define FMMOD			0x1b		/* Vibrato/filter modulation from LFO register		*/
57362306a36Sopenharmony_ci#define FMMOD_MODVIBRATO	0x0000ff00	/* Vibrato LFO modulation depth				*/
57462306a36Sopenharmony_ci						/* Signed 2's complement, +/- one octave extremes	*/
57562306a36Sopenharmony_ci#define FMMOD_MOFILTER		0x000000ff	/* Filter LFO modulation depth				*/
57662306a36Sopenharmony_ci						/* Signed 2's complement, +/- three octave extremes	*/
57762306a36Sopenharmony_ci
57862306a36Sopenharmony_ci#define TREMFRQ 		0x1c		/* Tremolo amount and modulation LFO frequency register	*/
57962306a36Sopenharmony_ci#define TREMFRQ_DEPTH		0x0000ff00	/* Tremolo depth					*/
58062306a36Sopenharmony_ci						/* Signed 2's complement, with +/- 12dB extremes	*/
58162306a36Sopenharmony_ci#define TREMFRQ_FREQUENCY	0x000000ff	/* Tremolo LFO frequency				*/
58262306a36Sopenharmony_ci						/* ??Hz steps, maximum of ?? Hz.			*/
58362306a36Sopenharmony_ci
58462306a36Sopenharmony_ci#define FM2FRQ2 		0x1d		/* Vibrato amount and vibrato LFO frequency register	*/
58562306a36Sopenharmony_ci#define FM2FRQ2_DEPTH		0x0000ff00	/* Vibrato LFO vibrato depth				*/
58662306a36Sopenharmony_ci						/* Signed 2's complement, +/- one octave extremes	*/
58762306a36Sopenharmony_ci#define FM2FRQ2_FREQUENCY	0x000000ff	/* Vibrato LFO frequency				*/
58862306a36Sopenharmony_ci						/* 0.039Hz steps, maximum of 9.85 Hz.			*/
58962306a36Sopenharmony_ci
59062306a36Sopenharmony_ci#define TEMPENV 		0x1e		/* Tempory envelope register				*/
59162306a36Sopenharmony_ci#define TEMPENV_MASK		0x0000ffff	/* 16-bit value						*/
59262306a36Sopenharmony_ci						/* NOTE: All channels contain internal variables; do	*/
59362306a36Sopenharmony_ci						/* not write to these locations.			*/
59462306a36Sopenharmony_ci
59562306a36Sopenharmony_ci/* 0x1f: not used */
59662306a36Sopenharmony_ci
59762306a36Sopenharmony_ci// 32 cache registers (== 128 bytes) per channel follow.
59862306a36Sopenharmony_ci// In stereo mode, the two channels' caches are concatenated into one,
59962306a36Sopenharmony_ci// and hold the interleaved frames.
60062306a36Sopenharmony_ci// The cache holds 64 frames, so the upper half is not used in 8-bit mode.
60162306a36Sopenharmony_ci// All registers mentioned below count in frames.
60262306a36Sopenharmony_ci// The cache is a ring buffer; CCR_READADDRESS operates modulo 64.
60362306a36Sopenharmony_ci// The cache is filled from (CCCA_CURRADDR - CCR_CACHEINVALIDSIZE)
60462306a36Sopenharmony_ci// into (CCR_READADDRESS - CCR_CACHEINVALIDSIZE).
60562306a36Sopenharmony_ci// The engine has a fetch threshold of 32 bytes, so it tries to keep
60662306a36Sopenharmony_ci// CCR_CACHEINVALIDSIZE below 8 (16-bit stereo), 16 (16-bit mono,
60762306a36Sopenharmony_ci// 8-bit stereo), or 32 (8-bit mono). The actual transfers are pretty
60862306a36Sopenharmony_ci// unpredictable, especially if several voices are running.
60962306a36Sopenharmony_ci// Frames are consumed at CCR_READADDRESS, which is incremented afterwards,
61062306a36Sopenharmony_ci// along with CCCA_CURRADDR and CCR_CACHEINVALIDSIZE. This implies that the
61162306a36Sopenharmony_ci// actual playback position always lags CCCA_CURRADDR by exactly 64 frames.
61262306a36Sopenharmony_ci#define CD0			0x20		/* Cache data registers 0 .. 0x1f			*/
61362306a36Sopenharmony_ci
61462306a36Sopenharmony_ci#define PTB			0x40		/* Page table base register				*/
61562306a36Sopenharmony_ci#define PTB_MASK		0xfffff000	/* Physical address of the page table in host memory	*/
61662306a36Sopenharmony_ci
61762306a36Sopenharmony_ci#define TCB			0x41		/* Tank cache base register    				*/
61862306a36Sopenharmony_ci#define TCB_MASK		0xfffff000	/* Physical address of the bottom of host based TRAM	*/
61962306a36Sopenharmony_ci
62062306a36Sopenharmony_ci#define ADCCR			0x42		/* ADC sample rate/stereo control register		*/
62162306a36Sopenharmony_ci#define ADCCR_RCHANENABLE	0x00000010	/* Enables right channel for writing to the host       	*/
62262306a36Sopenharmony_ci#define ADCCR_LCHANENABLE	0x00000008	/* Enables left channel for writing to the host		*/
62362306a36Sopenharmony_ci						/* NOTE: To guarantee phase coherency, both channels	*/
62462306a36Sopenharmony_ci						/* must be disabled prior to enabling both channels.	*/
62562306a36Sopenharmony_ci#define A_ADCCR_RCHANENABLE	0x00000020
62662306a36Sopenharmony_ci#define A_ADCCR_LCHANENABLE	0x00000010
62762306a36Sopenharmony_ci
62862306a36Sopenharmony_ci#define A_ADCCR_SAMPLERATE_MASK 0x0000000F      /* Audigy sample rate convertor output rate		*/
62962306a36Sopenharmony_ci#define ADCCR_SAMPLERATE_MASK	0x00000007	/* Sample rate convertor output rate			*/
63062306a36Sopenharmony_ci#define ADCCR_SAMPLERATE_48	0x00000000	/* 48kHz sample rate					*/
63162306a36Sopenharmony_ci#define ADCCR_SAMPLERATE_44	0x00000001	/* 44.1kHz sample rate					*/
63262306a36Sopenharmony_ci#define ADCCR_SAMPLERATE_32	0x00000002	/* 32kHz sample rate					*/
63362306a36Sopenharmony_ci#define ADCCR_SAMPLERATE_24	0x00000003	/* 24kHz sample rate					*/
63462306a36Sopenharmony_ci#define ADCCR_SAMPLERATE_22	0x00000004	/* 22.05kHz sample rate					*/
63562306a36Sopenharmony_ci#define ADCCR_SAMPLERATE_16	0x00000005	/* 16kHz sample rate					*/
63662306a36Sopenharmony_ci#define ADCCR_SAMPLERATE_11	0x00000006	/* 11.025kHz sample rate				*/
63762306a36Sopenharmony_ci#define ADCCR_SAMPLERATE_8	0x00000007	/* 8kHz sample rate					*/
63862306a36Sopenharmony_ci#define A_ADCCR_SAMPLERATE_12	0x00000006	/* 12kHz sample rate					*/
63962306a36Sopenharmony_ci#define A_ADCCR_SAMPLERATE_11	0x00000007	/* 11.025kHz sample rate				*/
64062306a36Sopenharmony_ci#define A_ADCCR_SAMPLERATE_8	0x00000008	/* 8kHz sample rate					*/
64162306a36Sopenharmony_ci
64262306a36Sopenharmony_ci#define FXWC			0x43		/* FX output write channels register			*/
64362306a36Sopenharmony_ci						/* When set, each bit enables the writing of the	*/
64462306a36Sopenharmony_ci						/* corresponding FX output channel (internal registers  */
64562306a36Sopenharmony_ci						/* 0x20-0x3f) to host memory.  This mode of recording   */
64662306a36Sopenharmony_ci						/* is 16bit, 48KHz only. All 32 channels can be enabled */
64762306a36Sopenharmony_ci						/* simultaneously.					*/
64862306a36Sopenharmony_ci
64962306a36Sopenharmony_ci#define A_TBLSZ			0x43	/* Effects Tank Internal Table Size. Only low byte or register used */
65062306a36Sopenharmony_ci
65162306a36Sopenharmony_ci#define TCBS			0x44		/* Tank cache buffer size register			*/
65262306a36Sopenharmony_ci#define TCBS_MASK		0x00000007	/* Tank cache buffer size field				*/
65362306a36Sopenharmony_ci#define TCBS_BUFFSIZE_16K	0x00000000
65462306a36Sopenharmony_ci#define TCBS_BUFFSIZE_32K	0x00000001
65562306a36Sopenharmony_ci#define TCBS_BUFFSIZE_64K	0x00000002
65662306a36Sopenharmony_ci#define TCBS_BUFFSIZE_128K	0x00000003
65762306a36Sopenharmony_ci#define TCBS_BUFFSIZE_256K	0x00000004
65862306a36Sopenharmony_ci#define TCBS_BUFFSIZE_512K	0x00000005
65962306a36Sopenharmony_ci#define TCBS_BUFFSIZE_1024K	0x00000006
66062306a36Sopenharmony_ci#define TCBS_BUFFSIZE_2048K	0x00000007
66162306a36Sopenharmony_ci
66262306a36Sopenharmony_ci#define MICBA			0x45		/* AC97 microphone buffer address register		*/
66362306a36Sopenharmony_ci#define MICBA_MASK		0xfffff000	/* 20 bit base address					*/
66462306a36Sopenharmony_ci
66562306a36Sopenharmony_ci#define ADCBA			0x46		/* ADC buffer address register				*/
66662306a36Sopenharmony_ci#define ADCBA_MASK		0xfffff000	/* 20 bit base address					*/
66762306a36Sopenharmony_ci
66862306a36Sopenharmony_ci#define FXBA			0x47		/* FX Buffer Address */
66962306a36Sopenharmony_ci#define FXBA_MASK		0xfffff000	/* 20 bit base address					*/
67062306a36Sopenharmony_ci
67162306a36Sopenharmony_ci#define A_HWM			0x48		/* High PCI Water Mark - word access, defaults to 3f */
67262306a36Sopenharmony_ci
67362306a36Sopenharmony_ci#define MICBS			0x49		/* Microphone buffer size register			*/
67462306a36Sopenharmony_ci
67562306a36Sopenharmony_ci#define ADCBS			0x4a		/* ADC buffer size register				*/
67662306a36Sopenharmony_ci
67762306a36Sopenharmony_ci#define FXBS			0x4b		/* FX buffer size register				*/
67862306a36Sopenharmony_ci
67962306a36Sopenharmony_ci/* The following mask values define the size of the ADC, MIC and FX buffers in bytes */
68062306a36Sopenharmony_ci#define ADCBS_BUFSIZE_NONE	0x00000000
68162306a36Sopenharmony_ci#define ADCBS_BUFSIZE_384	0x00000001
68262306a36Sopenharmony_ci#define ADCBS_BUFSIZE_448	0x00000002
68362306a36Sopenharmony_ci#define ADCBS_BUFSIZE_512	0x00000003
68462306a36Sopenharmony_ci#define ADCBS_BUFSIZE_640	0x00000004
68562306a36Sopenharmony_ci#define ADCBS_BUFSIZE_768	0x00000005
68662306a36Sopenharmony_ci#define ADCBS_BUFSIZE_896	0x00000006
68762306a36Sopenharmony_ci#define ADCBS_BUFSIZE_1024	0x00000007
68862306a36Sopenharmony_ci#define ADCBS_BUFSIZE_1280	0x00000008
68962306a36Sopenharmony_ci#define ADCBS_BUFSIZE_1536	0x00000009
69062306a36Sopenharmony_ci#define ADCBS_BUFSIZE_1792	0x0000000a
69162306a36Sopenharmony_ci#define ADCBS_BUFSIZE_2048	0x0000000b
69262306a36Sopenharmony_ci#define ADCBS_BUFSIZE_2560	0x0000000c
69362306a36Sopenharmony_ci#define ADCBS_BUFSIZE_3072	0x0000000d
69462306a36Sopenharmony_ci#define ADCBS_BUFSIZE_3584	0x0000000e
69562306a36Sopenharmony_ci#define ADCBS_BUFSIZE_4096	0x0000000f
69662306a36Sopenharmony_ci#define ADCBS_BUFSIZE_5120	0x00000010
69762306a36Sopenharmony_ci#define ADCBS_BUFSIZE_6144	0x00000011
69862306a36Sopenharmony_ci#define ADCBS_BUFSIZE_7168	0x00000012
69962306a36Sopenharmony_ci#define ADCBS_BUFSIZE_8192	0x00000013
70062306a36Sopenharmony_ci#define ADCBS_BUFSIZE_10240	0x00000014
70162306a36Sopenharmony_ci#define ADCBS_BUFSIZE_12288	0x00000015
70262306a36Sopenharmony_ci#define ADCBS_BUFSIZE_14366	0x00000016
70362306a36Sopenharmony_ci#define ADCBS_BUFSIZE_16384	0x00000017
70462306a36Sopenharmony_ci#define ADCBS_BUFSIZE_20480	0x00000018
70562306a36Sopenharmony_ci#define ADCBS_BUFSIZE_24576	0x00000019
70662306a36Sopenharmony_ci#define ADCBS_BUFSIZE_28672	0x0000001a
70762306a36Sopenharmony_ci#define ADCBS_BUFSIZE_32768	0x0000001b
70862306a36Sopenharmony_ci#define ADCBS_BUFSIZE_40960	0x0000001c
70962306a36Sopenharmony_ci#define ADCBS_BUFSIZE_49152	0x0000001d
71062306a36Sopenharmony_ci#define ADCBS_BUFSIZE_57344	0x0000001e
71162306a36Sopenharmony_ci#define ADCBS_BUFSIZE_65536	0x0000001f
71262306a36Sopenharmony_ci
71362306a36Sopenharmony_ci// On Audigy, the FX send amounts are not applied instantly, but determine
71462306a36Sopenharmony_ci// targets towards which the following registers swerve gradually.
71562306a36Sopenharmony_ci#define A_CSBA			0x4c		/* FX send B & A current amounts			*/
71662306a36Sopenharmony_ci#define A_CSDC			0x4d		/* FX send D & C current amounts			*/
71762306a36Sopenharmony_ci#define A_CSFE			0x4e		/* FX send F & E current amounts			*/
71862306a36Sopenharmony_ci#define A_CSHG			0x4f		/* FX send H & G current amounts			*/
71962306a36Sopenharmony_ci
72062306a36Sopenharmony_ci// NOTE: 0x50,51,52: 64-bit (split over voices 0 & 1)
72162306a36Sopenharmony_ci#define CDCS			0x50		/* CD-ROM digital channel status register		*/
72262306a36Sopenharmony_ci
72362306a36Sopenharmony_ci#define GPSCS			0x51		/* General Purpose SPDIF channel status register	*/
72462306a36Sopenharmony_ci
72562306a36Sopenharmony_ci// Corresponding EMU10K1_DBG_* constants are in the public header
72662306a36Sopenharmony_ci#define DBG			0x52
72762306a36Sopenharmony_ci
72862306a36Sopenharmony_ci#define A_SPSC			0x52		/* S/PDIF Input C Channel Status			*/
72962306a36Sopenharmony_ci
73062306a36Sopenharmony_ci#define REG53			0x53		/* DO NOT PROGRAM THIS REGISTER!!! MAY DESTROY CHIP	*/
73162306a36Sopenharmony_ci
73262306a36Sopenharmony_ci// Corresponding A_DBG_* constants are in the public header
73362306a36Sopenharmony_ci#define A_DBG			0x53
73462306a36Sopenharmony_ci
73562306a36Sopenharmony_ci// NOTE: 0x54,55,56: 64-bit (split over voices 0 & 1)
73662306a36Sopenharmony_ci#define SPCS0			0x54		/* SPDIF output Channel Status 0 register	*/
73762306a36Sopenharmony_ci
73862306a36Sopenharmony_ci#define SPCS1			0x55		/* SPDIF output Channel Status 1 register	*/
73962306a36Sopenharmony_ci
74062306a36Sopenharmony_ci#define SPCS2			0x56		/* SPDIF output Channel Status 2 register	*/
74162306a36Sopenharmony_ci
74262306a36Sopenharmony_ci#define SPCS_CLKACCYMASK	0x30000000	/* Clock accuracy				*/
74362306a36Sopenharmony_ci#define SPCS_CLKACCY_1000PPM	0x00000000	/* 1000 parts per million			*/
74462306a36Sopenharmony_ci#define SPCS_CLKACCY_50PPM	0x10000000	/* 50 parts per million				*/
74562306a36Sopenharmony_ci#define SPCS_CLKACCY_VARIABLE	0x20000000	/* Variable accuracy				*/
74662306a36Sopenharmony_ci#define SPCS_SAMPLERATEMASK	0x0f000000	/* Sample rate					*/
74762306a36Sopenharmony_ci#define SPCS_SAMPLERATE_44	0x00000000	/* 44.1kHz sample rate				*/
74862306a36Sopenharmony_ci#define SPCS_SAMPLERATE_48	0x02000000	/* 48kHz sample rate				*/
74962306a36Sopenharmony_ci#define SPCS_SAMPLERATE_32	0x03000000	/* 32kHz sample rate				*/
75062306a36Sopenharmony_ci#define SPCS_CHANNELNUMMASK	0x00f00000	/* Channel number				*/
75162306a36Sopenharmony_ci#define SPCS_CHANNELNUM_UNSPEC	0x00000000	/* Unspecified channel number			*/
75262306a36Sopenharmony_ci#define SPCS_CHANNELNUM_LEFT	0x00100000	/* Left channel					*/
75362306a36Sopenharmony_ci#define SPCS_CHANNELNUM_RIGHT	0x00200000	/* Right channel				*/
75462306a36Sopenharmony_ci#define SPCS_SOURCENUMMASK	0x000f0000	/* Source number				*/
75562306a36Sopenharmony_ci#define SPCS_SOURCENUM_UNSPEC	0x00000000	/* Unspecified source number			*/
75662306a36Sopenharmony_ci#define SPCS_GENERATIONSTATUS	0x00008000	/* Originality flag (see IEC-958 spec)		*/
75762306a36Sopenharmony_ci#define SPCS_CATEGORYCODEMASK	0x00007f00	/* Category code (see IEC-958 spec)		*/
75862306a36Sopenharmony_ci#define SPCS_MODEMASK		0x000000c0	/* Mode (see IEC-958 spec)			*/
75962306a36Sopenharmony_ci#define SPCS_EMPHASISMASK	0x00000038	/* Emphasis					*/
76062306a36Sopenharmony_ci#define SPCS_EMPHASIS_NONE	0x00000000	/* No emphasis					*/
76162306a36Sopenharmony_ci#define SPCS_EMPHASIS_50_15	0x00000008	/* 50/15 usec 2 channel				*/
76262306a36Sopenharmony_ci#define SPCS_COPYRIGHT		0x00000004	/* Copyright asserted flag -- do not modify	*/
76362306a36Sopenharmony_ci#define SPCS_NOTAUDIODATA	0x00000002	/* 0 = Digital audio, 1 = not audio		*/
76462306a36Sopenharmony_ci#define SPCS_PROFESSIONAL	0x00000001	/* 0 = Consumer (IEC-958), 1 = pro (AES3-1992)	*/
76562306a36Sopenharmony_ci
76662306a36Sopenharmony_ci/* 0x57: Not used */
76762306a36Sopenharmony_ci
76862306a36Sopenharmony_ci/* The 32-bit CLIx and SOLEx registers all have one bit per channel control/status      	*/
76962306a36Sopenharmony_ci#define CLIEL			0x58		/* Channel loop interrupt enable low register	*/
77062306a36Sopenharmony_ci#define CLIEH			0x59		/* Channel loop interrupt enable high register	*/
77162306a36Sopenharmony_ci
77262306a36Sopenharmony_ci#define CLIPL			0x5a		/* Channel loop interrupt pending low register	*/
77362306a36Sopenharmony_ci#define CLIPH			0x5b		/* Channel loop interrupt pending high register	*/
77462306a36Sopenharmony_ci
77562306a36Sopenharmony_ci// These cause CPF_STOP_MASK to be set shortly after CCCA_CURRADDR passes DSL_LOOPENDADDR.
77662306a36Sopenharmony_ci// Subsequent changes to the address registers don't resume; clearing the bit here or in CPF does.
77762306a36Sopenharmony_ci// The registers are NOT synchronized; the next serviced channel picks up immediately.
77862306a36Sopenharmony_ci#define SOLEL			0x5c		/* Stop on loop enable low register		*/
77962306a36Sopenharmony_ci#define SOLEH			0x5d		/* Stop on loop enable high register		*/
78062306a36Sopenharmony_ci
78162306a36Sopenharmony_ci#define SPBYPASS		0x5e		/* SPDIF BYPASS mode register			*/
78262306a36Sopenharmony_ci#define SPBYPASS_SPDIF0_MASK	0x00000003	/* SPDIF 0 bypass mode				*/
78362306a36Sopenharmony_ci#define SPBYPASS_SPDIF1_MASK	0x0000000c	/* SPDIF 1 bypass mode				*/
78462306a36Sopenharmony_ci/* bypass mode: 0 - DSP; 1 - SPDIF A, 2 - SPDIF B, 3 - SPDIF C					*/
78562306a36Sopenharmony_ci#define SPBYPASS_FORMAT		0x00000f00      /* If 1, SPDIF XX uses 24 bit, if 0 - 20 bit	*/
78662306a36Sopenharmony_ci
78762306a36Sopenharmony_ci#define AC97SLOT		0x5f            /* additional AC97 slots enable bits		*/
78862306a36Sopenharmony_ci#define AC97SLOT_REAR_RIGHT	0x01		/* Rear left					*/
78962306a36Sopenharmony_ci#define AC97SLOT_REAR_LEFT	0x02		/* Rear right					*/
79062306a36Sopenharmony_ci#define AC97SLOT_CNTR		0x10            /* Center enable				*/
79162306a36Sopenharmony_ci#define AC97SLOT_LFE		0x20            /* LFE enable					*/
79262306a36Sopenharmony_ci
79362306a36Sopenharmony_ci#define A_PCB			0x5f		/* PCB Revision					*/
79462306a36Sopenharmony_ci
79562306a36Sopenharmony_ci// NOTE: 0x60,61,62: 64-bit
79662306a36Sopenharmony_ci#define CDSRCS			0x60		/* CD-ROM Sample Rate Converter status register	*/
79762306a36Sopenharmony_ci
79862306a36Sopenharmony_ci#define GPSRCS			0x61		/* General Purpose SPDIF sample rate cvt status */
79962306a36Sopenharmony_ci
80062306a36Sopenharmony_ci#define ZVSRCS			0x62		/* ZVideo sample rate converter status		*/
80162306a36Sopenharmony_ci						/* NOTE: This one has no SPDIFLOCKED field	*/
80262306a36Sopenharmony_ci						/* Assumes sample lock				*/
80362306a36Sopenharmony_ci
80462306a36Sopenharmony_ci/* These three bitfields apply to CDSRCS, GPSRCS, and (except as noted) ZVSRCS.			*/
80562306a36Sopenharmony_ci#define SRCS_SPDIFVALID		0x04000000	/* SPDIF stream valid				*/
80662306a36Sopenharmony_ci#define SRCS_SPDIFLOCKED	0x02000000	/* SPDIF stream locked				*/
80762306a36Sopenharmony_ci#define SRCS_RATELOCKED		0x01000000	/* Sample rate locked				*/
80862306a36Sopenharmony_ci#define SRCS_ESTSAMPLERATE	0x0007ffff	/* Do not modify this field.			*/
80962306a36Sopenharmony_ci
81062306a36Sopenharmony_ci/* Note that these values can vary +/- by a small amount                                        */
81162306a36Sopenharmony_ci#define SRCS_SPDIFRATE_44	0x0003acd9
81262306a36Sopenharmony_ci#define SRCS_SPDIFRATE_48	0x00040000
81362306a36Sopenharmony_ci#define SRCS_SPDIFRATE_96	0x00080000
81462306a36Sopenharmony_ci
81562306a36Sopenharmony_ci#define MICIDX                  0x63            /* Microphone recording buffer index register   */
81662306a36Sopenharmony_ciSUB_REG(MICIDX, IDX,		0x0000ffff)
81762306a36Sopenharmony_ci
81862306a36Sopenharmony_ci#define ADCIDX			0x64		/* ADC recording buffer index register		*/
81962306a36Sopenharmony_ciSUB_REG(ADCIDX, IDX,		0x0000ffff)
82062306a36Sopenharmony_ci
82162306a36Sopenharmony_ci#define A_ADCIDX		0x63
82262306a36Sopenharmony_ciSUB_REG(A_ADCIDX, IDX,		0x0000ffff)
82362306a36Sopenharmony_ci
82462306a36Sopenharmony_ci#define A_MICIDX		0x64
82562306a36Sopenharmony_ciSUB_REG(A_MICIDX, IDX,		0x0000ffff)
82662306a36Sopenharmony_ci
82762306a36Sopenharmony_ci#define FXIDX			0x65		/* FX recording buffer index register		*/
82862306a36Sopenharmony_ciSUB_REG(FXIDX, IDX,		0x0000ffff)
82962306a36Sopenharmony_ci
83062306a36Sopenharmony_ci/* The 32-bit HLIEx and HLIPx registers all have one bit per channel control/status      		*/
83162306a36Sopenharmony_ci#define HLIEL			0x66		/* Channel half loop interrupt enable low register	*/
83262306a36Sopenharmony_ci#define HLIEH			0x67		/* Channel half loop interrupt enable high register	*/
83362306a36Sopenharmony_ci
83462306a36Sopenharmony_ci#define HLIPL			0x68		/* Channel half loop interrupt pending low register	*/
83562306a36Sopenharmony_ci#define HLIPH			0x69		/* Channel half loop interrupt pending high register	*/
83662306a36Sopenharmony_ci
83762306a36Sopenharmony_ci#define A_SPRI			0x6a		/* S/PDIF Host Record Index (bypasses SRC)	*/
83862306a36Sopenharmony_ci#define A_SPRA			0x6b		/* S/PDIF Host Record Address			*/
83962306a36Sopenharmony_ci#define A_SPRC			0x6c		/* S/PDIF Host Record Control			*/
84062306a36Sopenharmony_ci
84162306a36Sopenharmony_ci#define A_DICE			0x6d		/* Delayed Interrupt Counter & Enable		*/
84262306a36Sopenharmony_ci
84362306a36Sopenharmony_ci#define A_TTB			0x6e		/* Tank Table Base				*/
84462306a36Sopenharmony_ci#define A_TDOF			0x6f		/* Tank Delay Offset				*/
84562306a36Sopenharmony_ci
84662306a36Sopenharmony_ci/* This is the MPU port on the card (via the game port)						*/
84762306a36Sopenharmony_ci#define A_MUDATA1		0x70
84862306a36Sopenharmony_ci#define A_MUCMD1		0x71
84962306a36Sopenharmony_ci#define A_MUSTAT1		A_MUCMD1
85062306a36Sopenharmony_ci
85162306a36Sopenharmony_ci/* This is the MPU port on the Audigy Drive 							*/
85262306a36Sopenharmony_ci#define A_MUDATA2		0x72
85362306a36Sopenharmony_ci#define A_MUCMD2		0x73
85462306a36Sopenharmony_ci#define A_MUSTAT2		A_MUCMD2
85562306a36Sopenharmony_ci
85662306a36Sopenharmony_ci/* The next two are the Audigy equivalent of FXWC						*/
85762306a36Sopenharmony_ci/* the Audigy can record any output (16bit, 48kHz, up to 64 channels simultaneously) 		*/
85862306a36Sopenharmony_ci/* Each bit selects a channel for recording */
85962306a36Sopenharmony_ci#define A_FXWC1			0x74            /* Selects 0x7f-0x60 for FX recording           */
86062306a36Sopenharmony_ci#define A_FXWC2			0x75		/* Selects 0x9f-0x80 for FX recording           */
86162306a36Sopenharmony_ci
86262306a36Sopenharmony_ci#define A_EHC			0x76		/* Extended Hardware Control */
86362306a36Sopenharmony_ci
86462306a36Sopenharmony_ci#define A_SPDIF_SAMPLERATE	A_EHC		/* Set the sample rate of SPDIF output		*/
86562306a36Sopenharmony_ci#define A_SPDIF_RATE_MASK	0x000000e0	/* Any other values for rates, just use 48000	*/
86662306a36Sopenharmony_ci#define A_SPDIF_48000		0x00000000	/* kX calls this BYPASS				*/
86762306a36Sopenharmony_ci#define A_SPDIF_192000		0x00000020
86862306a36Sopenharmony_ci#define A_SPDIF_96000		0x00000040
86962306a36Sopenharmony_ci#define A_SPDIF_44100		0x00000080
87062306a36Sopenharmony_ci#define A_SPDIF_MUTED		0x000000c0
87162306a36Sopenharmony_ci
87262306a36Sopenharmony_ciSUB_REG_NC(A_EHC, A_I2S_CAPTURE_RATE, 0x00000e00)  /* This sets the capture PCM rate, but it is  */
87362306a36Sopenharmony_ci						   /* unclear if this sets the ADC rate as well. */
87462306a36Sopenharmony_ci#define A_I2S_CAPTURE_48000	0x0
87562306a36Sopenharmony_ci#define A_I2S_CAPTURE_192000	0x1
87662306a36Sopenharmony_ci#define A_I2S_CAPTURE_96000	0x2
87762306a36Sopenharmony_ci#define A_I2S_CAPTURE_44100	0x4
87862306a36Sopenharmony_ci
87962306a36Sopenharmony_ci#define A_EHC_SRC48_MASK	0x0000e000	/* This sets the playback PCM rate on the P16V	*/
88062306a36Sopenharmony_ci#define A_EHC_SRC48_BYPASS	0x00000000
88162306a36Sopenharmony_ci#define A_EHC_SRC48_192		0x00002000
88262306a36Sopenharmony_ci#define A_EHC_SRC48_96		0x00004000
88362306a36Sopenharmony_ci#define A_EHC_SRC48_44		0x00008000
88462306a36Sopenharmony_ci#define A_EHC_SRC48_MUTED	0x0000c000
88562306a36Sopenharmony_ci
88662306a36Sopenharmony_ci#define A_EHC_P17V_TVM		0x00000001	/* Tank virtual memory mode			*/
88762306a36Sopenharmony_ci#define A_EHC_P17V_SEL0_MASK	0x00030000	/* Aka A_EHC_P16V_PB_RATE; 00: 48, 01: 44.1, 10: 96, 11: 192 */
88862306a36Sopenharmony_ci#define A_EHC_P17V_SEL1_MASK	0x000c0000
88962306a36Sopenharmony_ci#define A_EHC_P17V_SEL2_MASK	0x00300000
89062306a36Sopenharmony_ci#define A_EHC_P17V_SEL3_MASK	0x00c00000
89162306a36Sopenharmony_ci
89262306a36Sopenharmony_ci#define A_EHC_ASYNC_BYPASS	0x80000000
89362306a36Sopenharmony_ci
89462306a36Sopenharmony_ci#define A_SRT3			0x77		/* I2S0 Sample Rate Tracker Status		*/
89562306a36Sopenharmony_ci#define A_SRT4			0x78		/* I2S1 Sample Rate Tracker Status		*/
89662306a36Sopenharmony_ci#define A_SRT5			0x79		/* I2S2 Sample Rate Tracker Status		*/
89762306a36Sopenharmony_ci/* - default to 0x01080000 on my audigy 2 ZS --rlrevell	*/
89862306a36Sopenharmony_ci
89962306a36Sopenharmony_ci#define A_SRT_ESTSAMPLERATE	0x001fffff
90062306a36Sopenharmony_ci#define A_SRT_RATELOCKED	0x01000000
90162306a36Sopenharmony_ci
90262306a36Sopenharmony_ci#define A_TTDA			0x7a		/* Tank Table DMA Address			*/
90362306a36Sopenharmony_ci#define A_TTDD			0x7b		/* Tank Table DMA Data				*/
90462306a36Sopenharmony_ci
90562306a36Sopenharmony_ci// In A_FXRT1 & A_FXRT2, the 0x80 bit of each byte completely disables the
90662306a36Sopenharmony_ci// filter (CVCF_CURRENTFILTER) for the corresponding channel. There is no
90762306a36Sopenharmony_ci// effect on the volume (CVCF_CURRENTVOLUME) or the interpolator's filter
90862306a36Sopenharmony_ci// (CCCA_INTERPROM_MASK).
90962306a36Sopenharmony_ci
91062306a36Sopenharmony_ci#define A_FXRT2			0x7c
91162306a36Sopenharmony_ci#define A_FXRT_CHANNELE		0x0000003f	/* Effects send bus number for channel's effects send E	*/
91262306a36Sopenharmony_ci#define A_FXRT_CHANNELF		0x00003f00	/* Effects send bus number for channel's effects send F	*/
91362306a36Sopenharmony_ci#define A_FXRT_CHANNELG		0x003f0000	/* Effects send bus number for channel's effects send G	*/
91462306a36Sopenharmony_ci#define A_FXRT_CHANNELH		0x3f000000	/* Effects send bus number for channel's effects send H	*/
91562306a36Sopenharmony_ci
91662306a36Sopenharmony_ci#define A_SENDAMOUNTS		0x7d
91762306a36Sopenharmony_ci#define A_FXSENDAMOUNT_E_MASK	0xFF000000
91862306a36Sopenharmony_ci#define A_FXSENDAMOUNT_F_MASK	0x00FF0000
91962306a36Sopenharmony_ci#define A_FXSENDAMOUNT_G_MASK	0x0000FF00
92062306a36Sopenharmony_ci#define A_FXSENDAMOUNT_H_MASK	0x000000FF
92162306a36Sopenharmony_ci
92262306a36Sopenharmony_ci/* The send amounts for this one are the same as used with the emu10k1 */
92362306a36Sopenharmony_ci#define A_FXRT1			0x7e
92462306a36Sopenharmony_ci#define A_FXRT_CHANNELA		0x0000003f
92562306a36Sopenharmony_ci#define A_FXRT_CHANNELB		0x00003f00
92662306a36Sopenharmony_ci#define A_FXRT_CHANNELC		0x003f0000
92762306a36Sopenharmony_ci#define A_FXRT_CHANNELD		0x3f000000
92862306a36Sopenharmony_ci
92962306a36Sopenharmony_ci/* 0x7f: Not used */
93062306a36Sopenharmony_ci
93162306a36Sopenharmony_ci/* The public header defines the GPR and TRAM base addresses that
93262306a36Sopenharmony_ci * are valid for _both_ CPU and DSP addressing. */
93362306a36Sopenharmony_ci
93462306a36Sopenharmony_ci/* Each DSP microcode instruction is mapped into 2 doublewords 					*/
93562306a36Sopenharmony_ci/* NOTE: When writing, always write the LO doubleword first.  Reads can be in either order.	*/
93662306a36Sopenharmony_ci#define MICROCODEBASE		0x400		/* Microcode data base address			*/
93762306a36Sopenharmony_ci#define A_MICROCODEBASE		0x600
93862306a36Sopenharmony_ci
93962306a36Sopenharmony_ci
94062306a36Sopenharmony_ci/************************************************************************************************/
94162306a36Sopenharmony_ci/* E-MU Digital Audio System overview								*/
94262306a36Sopenharmony_ci/************************************************************************************************/
94362306a36Sopenharmony_ci
94462306a36Sopenharmony_ci// - These cards use a regular PCI-attached Audigy chip (Alice2/Tina/Tina2);
94562306a36Sopenharmony_ci//   the PCIe variants simply put the Audigy chip behind a PCI bridge.
94662306a36Sopenharmony_ci// - All physical PCM I/O is routed through an additional FPGA; the regular
94762306a36Sopenharmony_ci//   EXTIN/EXTOUT ports are unconnected.
94862306a36Sopenharmony_ci// - The FPGA has a signal routing matrix, to connect each destination (output
94962306a36Sopenharmony_ci//   socket or capture channel) to a source (input socket or playback channel).
95062306a36Sopenharmony_ci// - The FPGA is controlled via Audigy's GPIO port, while sample data is
95162306a36Sopenharmony_ci//   transmitted via proprietary EMU32 serial links. On first-generation
95262306a36Sopenharmony_ci//   E-MU 1010 cards, Audigy's I2S inputs are also used for sample data.
95362306a36Sopenharmony_ci// - The Audio/Micro Dock is attached to Hana via EDI, a "network" link.
95462306a36Sopenharmony_ci// - The Audigy chip operates in slave mode; the clock is supplied by the FPGA.
95562306a36Sopenharmony_ci//   Gen1 E-MU 1010 cards have two crystals (for 44.1 kHz and 48 kHz multiples),
95662306a36Sopenharmony_ci//   while the later cards use a single crystal and a PLL chip.
95762306a36Sopenharmony_ci// - The whole card is switched to 2x/4x mode to achieve 88.2/96/176.4/192 kHz
95862306a36Sopenharmony_ci//   sample rates. Alice2/Tina keeps running at 44.1/48 kHz, but multiple channels
95962306a36Sopenharmony_ci//   are bundled.
96062306a36Sopenharmony_ci// - The number of available EMU32/EDI channels is hit in 2x/4x mode, so the total
96162306a36Sopenharmony_ci//   number of usable inputs/outputs is limited, esp. with ADAT in use.
96262306a36Sopenharmony_ci// - S/PDIF is unavailable in 4x mode (only over TOSLINK on newer 1010 cards) due
96362306a36Sopenharmony_ci//   to being unspecified at 176.4/192 kHz. Therefore, the Dock's S/PDIF channels
96462306a36Sopenharmony_ci//   can overlap with the Dock's ADC/DAC's high channels.
96562306a36Sopenharmony_ci// - The code names are mentioned below and in the emu_chip_details table.
96662306a36Sopenharmony_ci
96762306a36Sopenharmony_ci/************************************************************************************************/
96862306a36Sopenharmony_ci/* EMU1010 FPGA registers									*/
96962306a36Sopenharmony_ci/************************************************************************************************/
97062306a36Sopenharmony_ci
97162306a36Sopenharmony_ci#define EMU_HANA_DESTHI		0x00	/* 0000xxx  3 bits Link Destination */
97262306a36Sopenharmony_ci#define EMU_HANA_DESTLO		0x01	/* 00xxxxx  5 bits */
97362306a36Sopenharmony_ci
97462306a36Sopenharmony_ci#define EMU_HANA_SRCHI		0x02	/* 0000xxx  3 bits Link Source */
97562306a36Sopenharmony_ci#define EMU_HANA_SRCLO		0x03	/* 00xxxxx  5 bits */
97662306a36Sopenharmony_ci
97762306a36Sopenharmony_ci#define EMU_HANA_DOCK_PWR	0x04	/* 000000x  1 bits Audio Dock power */
97862306a36Sopenharmony_ci#define EMU_HANA_DOCK_PWR_ON		0x01 /* Audio Dock power on */
97962306a36Sopenharmony_ci
98062306a36Sopenharmony_ci#define EMU_HANA_WCLOCK		0x05	/* 0000xxx  3 bits Word Clock source select  */
98162306a36Sopenharmony_ci					/* Must be written after power on to reset DLL */
98262306a36Sopenharmony_ci					/* One is unable to detect the Audio dock without this */
98362306a36Sopenharmony_ci#define EMU_HANA_WCLOCK_SRC_MASK	0x07
98462306a36Sopenharmony_ci#define EMU_HANA_WCLOCK_INT_48K		0x00
98562306a36Sopenharmony_ci#define EMU_HANA_WCLOCK_INT_44_1K	0x01
98662306a36Sopenharmony_ci#define EMU_HANA_WCLOCK_HANA_SPDIF_IN	0x02
98762306a36Sopenharmony_ci#define EMU_HANA_WCLOCK_HANA_ADAT_IN	0x03
98862306a36Sopenharmony_ci#define EMU_HANA_WCLOCK_SYNC_BNC	0x04
98962306a36Sopenharmony_ci#define EMU_HANA_WCLOCK_2ND_HANA	0x05
99062306a36Sopenharmony_ci#define EMU_HANA_WCLOCK_SRC_RESERVED	0x06
99162306a36Sopenharmony_ci#define EMU_HANA_WCLOCK_OFF		0x07 /* For testing, forces fallback to DEFCLOCK */
99262306a36Sopenharmony_ci#define EMU_HANA_WCLOCK_MULT_MASK	0x18
99362306a36Sopenharmony_ci#define EMU_HANA_WCLOCK_1X		0x00
99462306a36Sopenharmony_ci#define EMU_HANA_WCLOCK_2X		0x08
99562306a36Sopenharmony_ci#define EMU_HANA_WCLOCK_4X		0x10
99662306a36Sopenharmony_ci#define EMU_HANA_WCLOCK_MULT_RESERVED	0x18
99762306a36Sopenharmony_ci
99862306a36Sopenharmony_ci// If the selected external clock source is/becomes invalid or incompatible
99962306a36Sopenharmony_ci// with the clock multiplier, the clock source is reset to this value, and
100062306a36Sopenharmony_ci// a WCLK_CHANGED interrupt is raised.
100162306a36Sopenharmony_ci#define EMU_HANA_DEFCLOCK	0x06	/* 000000x  1 bits Default Word Clock  */
100262306a36Sopenharmony_ci#define EMU_HANA_DEFCLOCK_48K		0x00
100362306a36Sopenharmony_ci#define EMU_HANA_DEFCLOCK_44_1K		0x01
100462306a36Sopenharmony_ci
100562306a36Sopenharmony_ci#define EMU_HANA_UNMUTE		0x07	/* 000000x  1 bits Mute all audio outputs  */
100662306a36Sopenharmony_ci#define EMU_MUTE			0x00
100762306a36Sopenharmony_ci#define EMU_UNMUTE			0x01
100862306a36Sopenharmony_ci
100962306a36Sopenharmony_ci#define EMU_HANA_FPGA_CONFIG	0x08	/* 00000xx  2 bits Config control of FPGAs  */
101062306a36Sopenharmony_ci#define EMU_HANA_FPGA_CONFIG_AUDIODOCK	0x01 /* Set in order to program FPGA on Audio Dock */
101162306a36Sopenharmony_ci#define EMU_HANA_FPGA_CONFIG_HANA	0x02 /* Set in order to program FPGA on Hana */
101262306a36Sopenharmony_ci
101362306a36Sopenharmony_ci#define EMU_HANA_IRQ_ENABLE	0x09	/* 000xxxx  4 bits IRQ Enable  */
101462306a36Sopenharmony_ci#define EMU_HANA_IRQ_WCLK_CHANGED	0x01
101562306a36Sopenharmony_ci#define EMU_HANA_IRQ_ADAT		0x02
101662306a36Sopenharmony_ci#define EMU_HANA_IRQ_DOCK		0x04
101762306a36Sopenharmony_ci#define EMU_HANA_IRQ_DOCK_LOST		0x08
101862306a36Sopenharmony_ci
101962306a36Sopenharmony_ci#define EMU_HANA_SPDIF_MODE	0x0a	/* 00xxxxx  5 bits SPDIF MODE  */
102062306a36Sopenharmony_ci#define EMU_HANA_SPDIF_MODE_TX_CONSUMER	0x00
102162306a36Sopenharmony_ci#define EMU_HANA_SPDIF_MODE_TX_PRO	0x01
102262306a36Sopenharmony_ci#define EMU_HANA_SPDIF_MODE_TX_NOCOPY	0x02
102362306a36Sopenharmony_ci#define EMU_HANA_SPDIF_MODE_RX_CONSUMER	0x00
102462306a36Sopenharmony_ci#define EMU_HANA_SPDIF_MODE_RX_PRO	0x04
102562306a36Sopenharmony_ci#define EMU_HANA_SPDIF_MODE_RX_NOCOPY	0x08
102662306a36Sopenharmony_ci#define EMU_HANA_SPDIF_MODE_RX_INVALID	0x10
102762306a36Sopenharmony_ci
102862306a36Sopenharmony_ci#define EMU_HANA_OPTICAL_TYPE	0x0b	/* 00000xx  2 bits ADAT or SPDIF in/out  */
102962306a36Sopenharmony_ci#define EMU_HANA_OPTICAL_IN_SPDIF	0x00
103062306a36Sopenharmony_ci#define EMU_HANA_OPTICAL_IN_ADAT	0x01
103162306a36Sopenharmony_ci#define EMU_HANA_OPTICAL_OUT_SPDIF	0x00
103262306a36Sopenharmony_ci#define EMU_HANA_OPTICAL_OUT_ADAT	0x02
103362306a36Sopenharmony_ci
103462306a36Sopenharmony_ci#define EMU_HANA_MIDI_IN		0x0c	/* 000000x  1 bit  Control MIDI  */
103562306a36Sopenharmony_ci#define EMU_HANA_MIDI_INA_FROM_HAMOA	0x01 /* HAMOA MIDI in to Alice 2 MIDI A */
103662306a36Sopenharmony_ci#define EMU_HANA_MIDI_INA_FROM_DOCK1	0x02 /* Audio Dock-1 MIDI in to Alice 2 MIDI A */
103762306a36Sopenharmony_ci#define EMU_HANA_MIDI_INA_FROM_DOCK2	0x03 /* Audio Dock-2 MIDI in to Alice 2 MIDI A */
103862306a36Sopenharmony_ci#define EMU_HANA_MIDI_INB_FROM_HAMOA	0x08 /* HAMOA MIDI in to Alice 2 MIDI B */
103962306a36Sopenharmony_ci#define EMU_HANA_MIDI_INB_FROM_DOCK1	0x10 /* Audio Dock-1 MIDI in to Alice 2 MIDI B */
104062306a36Sopenharmony_ci#define EMU_HANA_MIDI_INB_FROM_DOCK2	0x18 /* Audio Dock-2 MIDI in to Alice 2 MIDI B */
104162306a36Sopenharmony_ci
104262306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_1	0x0d	/* 000xxxx  4 bit  Audio Dock LEDs  */
104362306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_1_MIDI1	0x01	/* MIDI 1 LED on */
104462306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_1_MIDI2	0x02	/* MIDI 2 LED on */
104562306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_1_SMPTE_IN	0x04	/* SMPTE IN LED on */
104662306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_1_SMPTE_OUT	0x08	/* SMPTE OUT LED on */
104762306a36Sopenharmony_ci
104862306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_2	0x0e	/* 0xxxxxx  6 bit  Audio Dock LEDs  */
104962306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_2_44K	0x01	/* 44.1 kHz LED on */
105062306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_2_48K	0x02	/* 48 kHz LED on */
105162306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_2_96K	0x04	/* 96 kHz LED on */
105262306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_2_192K	0x08	/* 192 kHz LED on */
105362306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_2_LOCK	0x10	/* LOCK LED on */
105462306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_2_EXT	0x20	/* EXT LED on */
105562306a36Sopenharmony_ci
105662306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_3	0x0f	/* 0xxxxxx  6 bit  Audio Dock LEDs  */
105762306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_3_CLIP_A	0x01	/* Mic A Clip LED on */
105862306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_3_CLIP_B	0x02	/* Mic B Clip LED on */
105962306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_3_SIGNAL_A	0x04	/* Signal A Clip LED on */
106062306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_3_SIGNAL_B	0x08	/* Signal B Clip LED on */
106162306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_3_MANUAL_CLIP	0x10	/* Manual Clip detection */
106262306a36Sopenharmony_ci#define EMU_HANA_DOCK_LEDS_3_MANUAL_SIGNAL	0x20	/* Manual Signal detection */
106362306a36Sopenharmony_ci
106462306a36Sopenharmony_ci#define EMU_HANA_ADC_PADS	0x10	/* 0000xxx  3 bit  Audio Dock ADC 14dB pads */
106562306a36Sopenharmony_ci#define EMU_HANA_DOCK_ADC_PAD1		0x01	/* 14dB Attenuation on Audio Dock ADC 1 */
106662306a36Sopenharmony_ci#define EMU_HANA_DOCK_ADC_PAD2		0x02	/* 14dB Attenuation on Audio Dock ADC 2 */
106762306a36Sopenharmony_ci#define EMU_HANA_DOCK_ADC_PAD3		0x04	/* 14dB Attenuation on Audio Dock ADC 3 */
106862306a36Sopenharmony_ci#define EMU_HANA_0202_ADC_PAD1		0x08	/* 14dB Attenuation on 0202 ADC 1 */
106962306a36Sopenharmony_ci
107062306a36Sopenharmony_ci#define EMU_HANA_DOCK_MISC	0x11	/* 0xxxxxx  6 bit  Audio Dock misc bits */
107162306a36Sopenharmony_ci#define EMU_HANA_DOCK_DAC1_MUTE		0x01	/* DAC 1 Mute */
107262306a36Sopenharmony_ci#define EMU_HANA_DOCK_DAC2_MUTE		0x02	/* DAC 2 Mute */
107362306a36Sopenharmony_ci#define EMU_HANA_DOCK_DAC3_MUTE		0x04	/* DAC 3 Mute */
107462306a36Sopenharmony_ci#define EMU_HANA_DOCK_DAC4_MUTE		0x08	/* DAC 4 Mute */
107562306a36Sopenharmony_ci#define EMU_HANA_DOCK_PHONES_192_DAC1	0x00	/* DAC 1 Headphones source at 192kHz */
107662306a36Sopenharmony_ci#define EMU_HANA_DOCK_PHONES_192_DAC2	0x10	/* DAC 2 Headphones source at 192kHz */
107762306a36Sopenharmony_ci#define EMU_HANA_DOCK_PHONES_192_DAC3	0x20	/* DAC 3 Headphones source at 192kHz */
107862306a36Sopenharmony_ci#define EMU_HANA_DOCK_PHONES_192_DAC4	0x30	/* DAC 4 Headphones source at 192kHz */
107962306a36Sopenharmony_ci
108062306a36Sopenharmony_ci#define EMU_HANA_MIDI_OUT	0x12	/* 00xxxxx  5 bit  Source for each MIDI out port */
108162306a36Sopenharmony_ci#define EMU_HANA_MIDI_OUT_0202		0x01 /* 0202 MIDI from Alice 2. 0 = A, 1 = B */
108262306a36Sopenharmony_ci#define EMU_HANA_MIDI_OUT_DOCK1		0x02 /* Audio Dock MIDI1 front, from Alice 2. 0 = A, 1 = B */
108362306a36Sopenharmony_ci#define EMU_HANA_MIDI_OUT_DOCK2		0x04 /* Audio Dock MIDI2 rear, from Alice 2. 0 = A, 1 = B */
108462306a36Sopenharmony_ci#define EMU_HANA_MIDI_OUT_SYNC2		0x08 /* Sync card. Not the actual MIDI out jack. 0 = A, 1 = B */
108562306a36Sopenharmony_ci#define EMU_HANA_MIDI_OUT_LOOP		0x10 /* 0 = bits (3:0) normal. 1 = MIDI loopback enabled. */
108662306a36Sopenharmony_ci
108762306a36Sopenharmony_ci#define EMU_HANA_DAC_PADS	0x13	/* 00xxxxx  5 bit  DAC 14dB attenuation pads */
108862306a36Sopenharmony_ci#define EMU_HANA_DOCK_DAC_PAD1		0x01	/* 14dB Attenuation on AudioDock DAC 1. Left and Right */
108962306a36Sopenharmony_ci#define EMU_HANA_DOCK_DAC_PAD2		0x02	/* 14dB Attenuation on AudioDock DAC 2. Left and Right */
109062306a36Sopenharmony_ci#define EMU_HANA_DOCK_DAC_PAD3		0x04	/* 14dB Attenuation on AudioDock DAC 3. Left and Right */
109162306a36Sopenharmony_ci#define EMU_HANA_DOCK_DAC_PAD4		0x08	/* 14dB Attenuation on AudioDock DAC 4. Left and Right */
109262306a36Sopenharmony_ci#define EMU_HANA_0202_DAC_PAD1		0x10	/* 14dB Attenuation on 0202 DAC 1. Left and Right */
109362306a36Sopenharmony_ci
109462306a36Sopenharmony_ci/* 0x14 - 0x1f Unused R/W registers */
109562306a36Sopenharmony_ci
109662306a36Sopenharmony_ci#define EMU_HANA_IRQ_STATUS	0x20	/* 00xxxxx  5 bits IRQ Status  */
109762306a36Sopenharmony_ci					/* Same bits as for EMU_HANA_IRQ_ENABLE */
109862306a36Sopenharmony_ci					/* Reading the register resets it. */
109962306a36Sopenharmony_ci
110062306a36Sopenharmony_ci#define EMU_HANA_OPTION_CARDS	0x21	/* 000xxxx  4 bits Presence of option cards */
110162306a36Sopenharmony_ci#define EMU_HANA_OPTION_HAMOA		0x01	/* Hamoa (analog I/O) card present */
110262306a36Sopenharmony_ci#define EMU_HANA_OPTION_SYNC		0x02	/* Sync card present */
110362306a36Sopenharmony_ci#define EMU_HANA_OPTION_DOCK_ONLINE	0x04	/* Audio/Micro dock present and FPGA configured */
110462306a36Sopenharmony_ci#define EMU_HANA_OPTION_DOCK_OFFLINE	0x08	/* Audio/Micro dock present and FPGA not configured */
110562306a36Sopenharmony_ci
110662306a36Sopenharmony_ci#define EMU_HANA_ID		0x22	/* 1010101  7 bits ID byte & 0x7f = 0x55 with Alice2 */
110762306a36Sopenharmony_ci					/* 0010101  5 bits ID byte & 0x1f = 0x15 with Tina/2 */
110862306a36Sopenharmony_ci
110962306a36Sopenharmony_ci#define EMU_HANA_MAJOR_REV	0x23	/* 0000xxx  3 bit  Hana FPGA Major rev */
111062306a36Sopenharmony_ci#define EMU_HANA_MINOR_REV	0x24	/* 0000xxx  3 bit  Hana FPGA Minor rev */
111162306a36Sopenharmony_ci
111262306a36Sopenharmony_ci#define EMU_DOCK_MAJOR_REV	0x25	/* 0000xxx  3 bit  Audio Dock FPGA Major rev */
111362306a36Sopenharmony_ci#define EMU_DOCK_MINOR_REV	0x26	/* 0000xxx  3 bit  Audio Dock FPGA Minor rev */
111462306a36Sopenharmony_ci
111562306a36Sopenharmony_ci#define EMU_DOCK_BOARD_ID	0x27	/* 00000xx  2 bits Audio Dock ID pins */
111662306a36Sopenharmony_ci#define EMU_DOCK_BOARD_ID0		0x00	/* ID bit 0 */
111762306a36Sopenharmony_ci#define EMU_DOCK_BOARD_ID1		0x03	/* ID bit 1 */
111862306a36Sopenharmony_ci
111962306a36Sopenharmony_ci// The actual code disagrees about the bit width of the registers -
112062306a36Sopenharmony_ci// the formula used is freq = 0x1770000 / (((X_HI << 5) | X_LO) + 1)
112162306a36Sopenharmony_ci
112262306a36Sopenharmony_ci#define EMU_HANA_WC_SPDIF_HI	0x28	/* 0xxxxxx  6 bit  SPDIF IN Word clock, upper 6 bits */
112362306a36Sopenharmony_ci#define EMU_HANA_WC_SPDIF_LO	0x29	/* 0xxxxxx  6 bit  SPDIF IN Word clock, lower 6 bits */
112462306a36Sopenharmony_ci
112562306a36Sopenharmony_ci#define EMU_HANA_WC_ADAT_HI	0x2a	/* 0xxxxxx  6 bit  ADAT IN Word clock, upper 6 bits */
112662306a36Sopenharmony_ci#define EMU_HANA_WC_ADAT_LO	0x2b	/* 0xxxxxx  6 bit  ADAT IN Word clock, lower 6 bits */
112762306a36Sopenharmony_ci
112862306a36Sopenharmony_ci#define EMU_HANA_WC_BNC_LO	0x2c	/* 0xxxxxx  6 bit  BNC IN Word clock, lower 6 bits */
112962306a36Sopenharmony_ci#define EMU_HANA_WC_BNC_HI	0x2d	/* 0xxxxxx  6 bit  BNC IN Word clock, upper 6 bits */
113062306a36Sopenharmony_ci
113162306a36Sopenharmony_ci#define EMU_HANA2_WC_SPDIF_HI	0x2e	/* 0xxxxxx  6 bit  HANA2 SPDIF IN Word clock, upper 6 bits */
113262306a36Sopenharmony_ci#define EMU_HANA2_WC_SPDIF_LO	0x2f	/* 0xxxxxx  6 bit  HANA2 SPDIF IN Word clock, lower 6 bits */
113362306a36Sopenharmony_ci
113462306a36Sopenharmony_ci/* 0x30 - 0x3f Unused Read only registers */
113562306a36Sopenharmony_ci
113662306a36Sopenharmony_ci// The meaning of this is not clear; kX-project just calls it "lock" in some info-only code.
113762306a36Sopenharmony_ci#define EMU_HANA_LOCK_STS_LO	0x38	/* 0xxxxxx  lower 6 bits */
113862306a36Sopenharmony_ci#define EMU_HANA_LOCK_STS_HI	0x39	/* 0xxxxxx  upper 6 bits */
113962306a36Sopenharmony_ci
114062306a36Sopenharmony_ci/************************************************************************************************/
114162306a36Sopenharmony_ci/* EMU1010 Audio Destinations									*/
114262306a36Sopenharmony_ci/************************************************************************************************/
114362306a36Sopenharmony_ci/* Hana, original 1010,1212m,1820[m] using Alice2
114462306a36Sopenharmony_ci * 0x00, 0x00-0x0f: 16 EMU32 channels to Alice2
114562306a36Sopenharmony_ci * 0x01, 0x00-0x1f: 32 EDI channels to Audio Dock
114662306a36Sopenharmony_ci *       0x00: Dock DAC 1 Left
114762306a36Sopenharmony_ci *       0x04: Dock DAC 1 Right
114862306a36Sopenharmony_ci *       0x08: Dock DAC 2 Left
114962306a36Sopenharmony_ci *       0x0c: Dock DAC 2 Right
115062306a36Sopenharmony_ci *       0x10: Dock DAC 3 Left
115162306a36Sopenharmony_ci *       0x12: PHONES Left (n/a in 2x/4x mode; output mirrors DAC4 Left)
115262306a36Sopenharmony_ci *       0x14: Dock DAC 3 Right
115362306a36Sopenharmony_ci *       0x16: PHONES Right (n/a in 2x/4x mode; output mirrors DAC4 Right)
115462306a36Sopenharmony_ci *       0x18: Dock DAC 4 Left
115562306a36Sopenharmony_ci *       0x1a: S/PDIF Left
115662306a36Sopenharmony_ci *       0x1c: Dock DAC 4 Right
115762306a36Sopenharmony_ci *       0x1e: S/PDIF Right
115862306a36Sopenharmony_ci * 0x02, 0x00: Hana S/PDIF Left
115962306a36Sopenharmony_ci * 0x02, 0x01: Hana S/PDIF Right
116062306a36Sopenharmony_ci * 0x03, 0x00: Hamoa DAC Left
116162306a36Sopenharmony_ci * 0x03, 0x01: Hamoa DAC Right
116262306a36Sopenharmony_ci * 0x04, 0x00-0x07: Hana ADAT
116362306a36Sopenharmony_ci * 0x05, 0x00: I2S0 Left to Alice2
116462306a36Sopenharmony_ci * 0x05, 0x01: I2S0 Right to Alice2
116562306a36Sopenharmony_ci * 0x06, 0x00: I2S0 Left to Alice2
116662306a36Sopenharmony_ci * 0x06, 0x01: I2S0 Right to Alice2
116762306a36Sopenharmony_ci * 0x07, 0x00: I2S0 Left to Alice2
116862306a36Sopenharmony_ci * 0x07, 0x01: I2S0 Right to Alice2
116962306a36Sopenharmony_ci *
117062306a36Sopenharmony_ci * Hana2 never released, but used Tina
117162306a36Sopenharmony_ci * Not needed.
117262306a36Sopenharmony_ci *
117362306a36Sopenharmony_ci * Hana3, rev2 1010,1212m,1616[m] using Tina
117462306a36Sopenharmony_ci * 0x00, 0x00-0x0f: 16 EMU32A channels to Tina
117562306a36Sopenharmony_ci * 0x01, 0x00-0x1f: 32 EDI channels to Micro Dock
117662306a36Sopenharmony_ci *       0x00: Dock DAC 1 Left
117762306a36Sopenharmony_ci *       0x04: Dock DAC 1 Right
117862306a36Sopenharmony_ci *       0x08: Dock DAC 2 Left
117962306a36Sopenharmony_ci *       0x0c: Dock DAC 2 Right
118062306a36Sopenharmony_ci *       0x10: Dock DAC 3 Left
118162306a36Sopenharmony_ci *       0x12: Dock S/PDIF Left
118262306a36Sopenharmony_ci *       0x14: Dock DAC 3 Right
118362306a36Sopenharmony_ci *       0x16: Dock S/PDIF Right
118462306a36Sopenharmony_ci *       0x18-0x1f: Dock ADAT 0-7
118562306a36Sopenharmony_ci * 0x02, 0x00: Hana3 S/PDIF Left
118662306a36Sopenharmony_ci * 0x02, 0x01: Hana3 S/PDIF Right
118762306a36Sopenharmony_ci * 0x03, 0x00: Hamoa DAC Left
118862306a36Sopenharmony_ci * 0x03, 0x01: Hamoa DAC Right
118962306a36Sopenharmony_ci * 0x04, 0x00-0x07: Hana3 ADAT 0-7
119062306a36Sopenharmony_ci * 0x05, 0x00-0x0f: 16 EMU32B channels to Tina
119162306a36Sopenharmony_ci * 0x06-0x07: Not used
119262306a36Sopenharmony_ci *
119362306a36Sopenharmony_ci * HanaLite, rev1 0404 using Alice2
119462306a36Sopenharmony_ci * HanaLiteLite, rev2 0404 using Tina
119562306a36Sopenharmony_ci * 0x00, 0x00-0x0f: 16 EMU32 channels to Alice2/Tina
119662306a36Sopenharmony_ci * 0x01: Not used
119762306a36Sopenharmony_ci * 0x02, 0x00: S/PDIF Left
119862306a36Sopenharmony_ci * 0x02, 0x01: S/PDIF Right
119962306a36Sopenharmony_ci * 0x03, 0x00: DAC Left
120062306a36Sopenharmony_ci * 0x03, 0x01: DAC Right
120162306a36Sopenharmony_ci * 0x04-0x07: Not used
120262306a36Sopenharmony_ci *
120362306a36Sopenharmony_ci * Mana, Cardbus 1616 using Tina2
120462306a36Sopenharmony_ci * 0x00, 0x00-0x0f: 16 EMU32A channels to Tina2
120562306a36Sopenharmony_ci * 0x01, 0x00-0x1f: 32 EDI channels to Micro Dock
120662306a36Sopenharmony_ci *       (same as rev2 1010)
120762306a36Sopenharmony_ci * 0x02: Not used
120862306a36Sopenharmony_ci * 0x03, 0x00: Mana DAC Left
120962306a36Sopenharmony_ci * 0x03, 0x01: Mana DAC Right
121062306a36Sopenharmony_ci * 0x04, 0x00-0x0f: 16 EMU32B channels to Tina2
121162306a36Sopenharmony_ci * 0x05-0x07: Not used
121262306a36Sopenharmony_ci */
121362306a36Sopenharmony_ci
121462306a36Sopenharmony_ci/* 32-bit destinations of signal in the Hana FPGA. Destinations are either
121562306a36Sopenharmony_ci * physical outputs of Hana, or outputs going to Alice2/Tina for capture -
121662306a36Sopenharmony_ci * 16 x EMU_DST_ALICE2_EMU32_X (2x on rev2 boards). Which data is fed into
121762306a36Sopenharmony_ci * a channel depends on the mixer control setting for each destination - see
121862306a36Sopenharmony_ci * the register arrays in emumixer.c.
121962306a36Sopenharmony_ci */
122062306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_0	0x000f	/* 16 EMU32 channels to Alice2 +0 to +0xf */
122162306a36Sopenharmony_ci					/* This channel is delayed by one sample. */
122262306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_1	0x0000	/* 16 EMU32 channels to Alice2 +0 to +0xf */
122362306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_2	0x0001	/* 16 EMU32 channels to Alice2 +0 to +0xf */
122462306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_3	0x0002	/* 16 EMU32 channels to Alice2 +0 to +0xf */
122562306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_4	0x0003	/* 16 EMU32 channels to Alice2 +0 to +0xf */
122662306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_5	0x0004	/* 16 EMU32 channels to Alice2 +0 to +0xf */
122762306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_6	0x0005	/* 16 EMU32 channels to Alice2 +0 to +0xf */
122862306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_7	0x0006	/* 16 EMU32 channels to Alice2 +0 to +0xf */
122962306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_8	0x0007	/* 16 EMU32 channels to Alice2 +0 to +0xf */
123062306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_9	0x0008	/* 16 EMU32 channels to Alice2 +0 to +0xf */
123162306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_A	0x0009	/* 16 EMU32 channels to Alice2 +0 to +0xf */
123262306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_B	0x000a	/* 16 EMU32 channels to Alice2 +0 to +0xf */
123362306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_C	0x000b	/* 16 EMU32 channels to Alice2 +0 to +0xf */
123462306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_D	0x000c	/* 16 EMU32 channels to Alice2 +0 to +0xf */
123562306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_E	0x000d	/* 16 EMU32 channels to Alice2 +0 to +0xf */
123662306a36Sopenharmony_ci#define EMU_DST_ALICE2_EMU32_F	0x000e	/* 16 EMU32 channels to Alice2 +0 to +0xf */
123762306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC1_LEFT1	0x0100	/* Audio Dock DAC1 Left, 1st or 48kHz only */
123862306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC1_LEFT2	0x0101	/* Audio Dock DAC1 Left, 2nd or 96kHz */
123962306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC1_LEFT3	0x0102	/* Audio Dock DAC1 Left, 3rd or 192kHz */
124062306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC1_LEFT4	0x0103	/* Audio Dock DAC1 Left, 4th or 192kHz */
124162306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC1_RIGHT1	0x0104	/* Audio Dock DAC1 Right, 1st or 48kHz only */
124262306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC1_RIGHT2	0x0105	/* Audio Dock DAC1 Right, 2nd or 96kHz */
124362306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC1_RIGHT3	0x0106	/* Audio Dock DAC1 Right, 3rd or 192kHz */
124462306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC1_RIGHT4	0x0107	/* Audio Dock DAC1 Right, 4th or 192kHz */
124562306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC2_LEFT1	0x0108	/* Audio Dock DAC2 Left, 1st or 48kHz only */
124662306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC2_LEFT2	0x0109	/* Audio Dock DAC2 Left, 2nd or 96kHz */
124762306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC2_LEFT3	0x010a	/* Audio Dock DAC2 Left, 3rd or 192kHz */
124862306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC2_LEFT4	0x010b	/* Audio Dock DAC2 Left, 4th or 192kHz */
124962306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC2_RIGHT1	0x010c	/* Audio Dock DAC2 Right, 1st or 48kHz only */
125062306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC2_RIGHT2	0x010d	/* Audio Dock DAC2 Right, 2nd or 96kHz */
125162306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC2_RIGHT3	0x010e	/* Audio Dock DAC2 Right, 3rd or 192kHz */
125262306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC2_RIGHT4	0x010f	/* Audio Dock DAC2 Right, 4th or 192kHz */
125362306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC3_LEFT1	0x0110	/* Audio Dock DAC1 Left, 1st or 48kHz only */
125462306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC3_LEFT2	0x0111	/* Audio Dock DAC1 Left, 2nd or 96kHz */
125562306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC3_LEFT3	0x0112	/* Audio Dock DAC1 Left, 3rd or 192kHz */
125662306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC3_LEFT4	0x0113	/* Audio Dock DAC1 Left, 4th or 192kHz */
125762306a36Sopenharmony_ci#define EMU_DST_DOCK_PHONES_LEFT1	0x0112	/* Audio Dock PHONES Left, 1st or 48kHz only */
125862306a36Sopenharmony_ci#define EMU_DST_DOCK_PHONES_LEFT2	0x0113	/* Audio Dock PHONES Left, 2nd or 96kHz */
125962306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC3_RIGHT1	0x0114	/* Audio Dock DAC1 Right, 1st or 48kHz only */
126062306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC3_RIGHT2	0x0115	/* Audio Dock DAC1 Right, 2nd or 96kHz */
126162306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC3_RIGHT3	0x0116	/* Audio Dock DAC1 Right, 3rd or 192kHz */
126262306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC3_RIGHT4	0x0117	/* Audio Dock DAC1 Right, 4th or 192kHz */
126362306a36Sopenharmony_ci#define EMU_DST_DOCK_PHONES_RIGHT1	0x0116	/* Audio Dock PHONES Right, 1st or 48kHz only */
126462306a36Sopenharmony_ci#define EMU_DST_DOCK_PHONES_RIGHT2	0x0117	/* Audio Dock PHONES Right, 2nd or 96kHz */
126562306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC4_LEFT1	0x0118	/* Audio Dock DAC2 Left, 1st or 48kHz only */
126662306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC4_LEFT2	0x0119	/* Audio Dock DAC2 Left, 2nd or 96kHz */
126762306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC4_LEFT3	0x011a	/* Audio Dock DAC2 Left, 3rd or 192kHz */
126862306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC4_LEFT4	0x011b	/* Audio Dock DAC2 Left, 4th or 192kHz */
126962306a36Sopenharmony_ci#define EMU_DST_DOCK_SPDIF_LEFT1	0x011a	/* Audio Dock SPDIF Left, 1st or 48kHz only */
127062306a36Sopenharmony_ci#define EMU_DST_DOCK_SPDIF_LEFT2	0x011b	/* Audio Dock SPDIF Left, 2nd or 96kHz */
127162306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC4_RIGHT1	0x011c	/* Audio Dock DAC2 Right, 1st or 48kHz only */
127262306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC4_RIGHT2	0x011d	/* Audio Dock DAC2 Right, 2nd or 96kHz */
127362306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC4_RIGHT3	0x011e	/* Audio Dock DAC2 Right, 3rd or 192kHz */
127462306a36Sopenharmony_ci#define EMU_DST_DOCK_DAC4_RIGHT4	0x011f	/* Audio Dock DAC2 Right, 4th or 192kHz */
127562306a36Sopenharmony_ci#define EMU_DST_DOCK_SPDIF_RIGHT1	0x011e	/* Audio Dock SPDIF Right, 1st or 48kHz only */
127662306a36Sopenharmony_ci#define EMU_DST_DOCK_SPDIF_RIGHT2	0x011f	/* Audio Dock SPDIF Right, 2nd or 96kHz */
127762306a36Sopenharmony_ci#define EMU_DST_HANA_SPDIF_LEFT1	0x0200	/* Hana SPDIF Left, 1st or 48kHz only */
127862306a36Sopenharmony_ci#define EMU_DST_HANA_SPDIF_LEFT2	0x0202	/* Hana SPDIF Left, 2nd or 96kHz */
127962306a36Sopenharmony_ci#define EMU_DST_HANA_SPDIF_LEFT3	0x0204	/* Hana SPDIF Left, 3rd or 192kHz */
128062306a36Sopenharmony_ci#define EMU_DST_HANA_SPDIF_LEFT4	0x0206	/* Hana SPDIF Left, 4th or 192kHz */
128162306a36Sopenharmony_ci#define EMU_DST_HANA_SPDIF_RIGHT1	0x0201	/* Hana SPDIF Right, 1st or 48kHz only */
128262306a36Sopenharmony_ci#define EMU_DST_HANA_SPDIF_RIGHT2	0x0203	/* Hana SPDIF Right, 2nd or 96kHz */
128362306a36Sopenharmony_ci#define EMU_DST_HANA_SPDIF_RIGHT3	0x0205	/* Hana SPDIF Right, 3rd or 192kHz */
128462306a36Sopenharmony_ci#define EMU_DST_HANA_SPDIF_RIGHT4	0x0207	/* Hana SPDIF Right, 4th or 192kHz */
128562306a36Sopenharmony_ci#define EMU_DST_HAMOA_DAC_LEFT1	0x0300	/* Hamoa DAC Left, 1st or 48kHz only */
128662306a36Sopenharmony_ci#define EMU_DST_HAMOA_DAC_LEFT2	0x0302	/* Hamoa DAC Left, 2nd or 96kHz */
128762306a36Sopenharmony_ci#define EMU_DST_HAMOA_DAC_LEFT3	0x0304	/* Hamoa DAC Left, 3rd or 192kHz */
128862306a36Sopenharmony_ci#define EMU_DST_HAMOA_DAC_LEFT4	0x0306	/* Hamoa DAC Left, 4th or 192kHz */
128962306a36Sopenharmony_ci#define EMU_DST_HAMOA_DAC_RIGHT1	0x0301	/* Hamoa DAC Right, 1st or 48kHz only */
129062306a36Sopenharmony_ci#define EMU_DST_HAMOA_DAC_RIGHT2	0x0303	/* Hamoa DAC Right, 2nd or 96kHz */
129162306a36Sopenharmony_ci#define EMU_DST_HAMOA_DAC_RIGHT3	0x0305	/* Hamoa DAC Right, 3rd or 192kHz */
129262306a36Sopenharmony_ci#define EMU_DST_HAMOA_DAC_RIGHT4	0x0307	/* Hamoa DAC Right, 4th or 192kHz */
129362306a36Sopenharmony_ci// In S/MUX mode, the samples of one channel are adjacent.
129462306a36Sopenharmony_ci#define EMU_DST_HANA_ADAT	0x0400	/* Hana ADAT 8 channel out +0 to +7 */
129562306a36Sopenharmony_ci#define EMU_DST_ALICE_I2S0_LEFT		0x0500	/* Alice2 I2S0 Left */
129662306a36Sopenharmony_ci#define EMU_DST_ALICE_I2S0_RIGHT	0x0501	/* Alice2 I2S0 Right */
129762306a36Sopenharmony_ci#define EMU_DST_ALICE_I2S1_LEFT		0x0600	/* Alice2 I2S1 Left */
129862306a36Sopenharmony_ci#define EMU_DST_ALICE_I2S1_RIGHT	0x0601	/* Alice2 I2S1 Right */
129962306a36Sopenharmony_ci#define EMU_DST_ALICE_I2S2_LEFT		0x0700	/* Alice2 I2S2 Left */
130062306a36Sopenharmony_ci#define EMU_DST_ALICE_I2S2_RIGHT	0x0701	/* Alice2 I2S2 Right */
130162306a36Sopenharmony_ci
130262306a36Sopenharmony_ci/* Additional destinations for 1616(M)/Microdock */
130362306a36Sopenharmony_ci
130462306a36Sopenharmony_ci#define EMU_DST_MDOCK_SPDIF_LEFT1	0x0112	/* Microdock S/PDIF OUT Left, 1st or 48kHz only */
130562306a36Sopenharmony_ci#define EMU_DST_MDOCK_SPDIF_LEFT2	0x0113	/* Microdock S/PDIF OUT Left, 2nd or 96kHz */
130662306a36Sopenharmony_ci#define EMU_DST_MDOCK_SPDIF_RIGHT1	0x0116	/* Microdock S/PDIF OUT Right, 1st or 48kHz only */
130762306a36Sopenharmony_ci#define EMU_DST_MDOCK_SPDIF_RIGHT2	0x0117	/* Microdock S/PDIF OUT Right, 2nd or 96kHz  */
130862306a36Sopenharmony_ci#define EMU_DST_MDOCK_ADAT		0x0118	/* Microdock S/PDIF ADAT 8 channel out +8 to +f */
130962306a36Sopenharmony_ci
131062306a36Sopenharmony_ci#define EMU_DST_MANA_DAC_LEFT		0x0300	/* Headphone jack on 1010 cardbus? 44.1/48kHz only? */
131162306a36Sopenharmony_ci#define EMU_DST_MANA_DAC_RIGHT		0x0301	/* Headphone jack on 1010 cardbus? 44.1/48kHz only? */
131262306a36Sopenharmony_ci
131362306a36Sopenharmony_ci/************************************************************************************************/
131462306a36Sopenharmony_ci/* EMU1010 Audio Sources									*/
131562306a36Sopenharmony_ci/************************************************************************************************/
131662306a36Sopenharmony_ci/* Hana, original 1010,1212m,1820[m] using Alice2
131762306a36Sopenharmony_ci * 0x00, 0x00-0x1f: Silence
131862306a36Sopenharmony_ci * 0x01, 0x00-0x1f: 32 EDI channels from Audio Dock
131962306a36Sopenharmony_ci *       0x00: Dock Mic A
132062306a36Sopenharmony_ci *       0x04: Dock Mic B
132162306a36Sopenharmony_ci *       0x08: Dock ADC 1 Left
132262306a36Sopenharmony_ci *       0x0c: Dock ADC 1 Right
132362306a36Sopenharmony_ci *       0x10: Dock ADC 2 Left
132462306a36Sopenharmony_ci *       0x14: Dock ADC 2 Right
132562306a36Sopenharmony_ci *       0x18: Dock ADC 3 Left
132662306a36Sopenharmony_ci *       0x1c: Dock ADC 3 Right
132762306a36Sopenharmony_ci * 0x02, 0x00: Hamoa ADC Left
132862306a36Sopenharmony_ci * 0x02, 0x01: Hamoa ADC Right
132962306a36Sopenharmony_ci * 0x03, 0x00-0x0f: 16 inputs from Alice2 Emu32A output
133062306a36Sopenharmony_ci * 0x03, 0x10-0x1f: 16 inputs from Alice2 Emu32B output
133162306a36Sopenharmony_ci * 0x04, 0x00-0x07: Hana ADAT
133262306a36Sopenharmony_ci * 0x05, 0x00: Hana S/PDIF Left
133362306a36Sopenharmony_ci * 0x05, 0x01: Hana S/PDIF Right
133462306a36Sopenharmony_ci * 0x06-0x07: Not used
133562306a36Sopenharmony_ci *
133662306a36Sopenharmony_ci * Hana2 never released, but used Tina
133762306a36Sopenharmony_ci * Not needed.
133862306a36Sopenharmony_ci *
133962306a36Sopenharmony_ci * Hana3, rev2 1010,1212m,1616[m] using Tina
134062306a36Sopenharmony_ci * 0x00, 0x00-0x1f: Silence
134162306a36Sopenharmony_ci * 0x01, 0x00-0x1f: 32 EDI channels from Micro Dock
134262306a36Sopenharmony_ci *       0x00: Dock Mic A
134362306a36Sopenharmony_ci *       0x04: Dock Mic B
134462306a36Sopenharmony_ci *       0x08: Dock ADC 1 Left
134562306a36Sopenharmony_ci *       0x0c: Dock ADC 1 Right
134662306a36Sopenharmony_ci *       0x10: Dock ADC 2 Left
134762306a36Sopenharmony_ci *       0x12: Dock S/PDIF Left
134862306a36Sopenharmony_ci *       0x14: Dock ADC 2 Right
134962306a36Sopenharmony_ci *       0x16: Dock S/PDIF Right
135062306a36Sopenharmony_ci *       0x18-0x1f: Dock ADAT 0-7
135162306a36Sopenharmony_ci * 0x02, 0x00: Hamoa ADC Left
135262306a36Sopenharmony_ci * 0x02, 0x01: Hamoa ADC Right
135362306a36Sopenharmony_ci * 0x03, 0x00-0x0f: 16 inputs from Tina Emu32A output
135462306a36Sopenharmony_ci * 0x03, 0x10-0x1f: 16 inputs from Tina Emu32B output
135562306a36Sopenharmony_ci * 0x04, 0x00-0x07: Hana3 ADAT
135662306a36Sopenharmony_ci * 0x05, 0x00: Hana3 S/PDIF Left
135762306a36Sopenharmony_ci * 0x05, 0x01: Hana3 S/PDIF Right
135862306a36Sopenharmony_ci * 0x06-0x07: Not used
135962306a36Sopenharmony_ci *
136062306a36Sopenharmony_ci * HanaLite, rev1 0404 using Alice2
136162306a36Sopenharmony_ci * HanaLiteLite, rev2 0404 using Tina
136262306a36Sopenharmony_ci * 0x00, 0x00-0x1f: Silence
136362306a36Sopenharmony_ci * 0x01: Not used
136462306a36Sopenharmony_ci * 0x02, 0x00: ADC Left
136562306a36Sopenharmony_ci * 0x02, 0x01: ADC Right
136662306a36Sopenharmony_ci * 0x03, 0x00-0x0f: 16 inputs from Alice2/Tina Emu32A output
136762306a36Sopenharmony_ci * 0x03, 0x10-0x1f: 16 inputs from Alice2/Tina Emu32B output
136862306a36Sopenharmony_ci * 0x04: Not used
136962306a36Sopenharmony_ci * 0x05, 0x00: S/PDIF Left
137062306a36Sopenharmony_ci * 0x05, 0x01: S/PDIF Right
137162306a36Sopenharmony_ci * 0x06-0x07: Not used
137262306a36Sopenharmony_ci *
137362306a36Sopenharmony_ci * Mana, Cardbus 1616 using Tina2
137462306a36Sopenharmony_ci * 0x00, 0x00-0x1f: Silence
137562306a36Sopenharmony_ci * 0x01, 0x00-0x1f: 32 EDI channels from Micro Dock
137662306a36Sopenharmony_ci *       (same as rev2 1010)
137762306a36Sopenharmony_ci * 0x02: Not used
137862306a36Sopenharmony_ci * 0x03, 0x00-0x0f: 16 inputs from Tina2 Emu32A output
137962306a36Sopenharmony_ci * 0x03, 0x10-0x1f: 16 inputs from Tina2 Emu32B output
138062306a36Sopenharmony_ci * 0x04-0x07: Not used
138162306a36Sopenharmony_ci */
138262306a36Sopenharmony_ci
138362306a36Sopenharmony_ci/* 32-bit sources of signal in the Hana FPGA. The sources are routed to
138462306a36Sopenharmony_ci * destinations using a mixer control for each destination - see emumixer.c.
138562306a36Sopenharmony_ci * Sources are either physical inputs of Hana, or inputs from Alice2/Tina -
138662306a36Sopenharmony_ci * 16 x EMU_SRC_ALICE_EMU32A + 16 x EMU_SRC_ALICE_EMU32B.
138762306a36Sopenharmony_ci */
138862306a36Sopenharmony_ci#define EMU_SRC_SILENCE		0x0000	/* Silence */
138962306a36Sopenharmony_ci#define EMU_SRC_DOCK_MIC_A1	0x0100	/* Audio Dock Mic A, 1st or 48kHz only */
139062306a36Sopenharmony_ci#define EMU_SRC_DOCK_MIC_A2	0x0101	/* Audio Dock Mic A, 2nd or 96kHz */
139162306a36Sopenharmony_ci#define EMU_SRC_DOCK_MIC_A3	0x0102	/* Audio Dock Mic A, 3rd or 192kHz */
139262306a36Sopenharmony_ci#define EMU_SRC_DOCK_MIC_A4	0x0103	/* Audio Dock Mic A, 4th or 192kHz */
139362306a36Sopenharmony_ci#define EMU_SRC_DOCK_MIC_B1	0x0104	/* Audio Dock Mic B, 1st or 48kHz only */
139462306a36Sopenharmony_ci#define EMU_SRC_DOCK_MIC_B2	0x0105	/* Audio Dock Mic B, 2nd or 96kHz */
139562306a36Sopenharmony_ci#define EMU_SRC_DOCK_MIC_B3	0x0106	/* Audio Dock Mic B, 3rd or 192kHz */
139662306a36Sopenharmony_ci#define EMU_SRC_DOCK_MIC_B4	0x0107	/* Audio Dock Mic B, 4th or 192kHz */
139762306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC1_LEFT1	0x0108	/* Audio Dock ADC1 Left, 1st or 48kHz only */
139862306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC1_LEFT2	0x0109	/* Audio Dock ADC1 Left, 2nd or 96kHz */
139962306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC1_LEFT3	0x010a	/* Audio Dock ADC1 Left, 3rd or 192kHz */
140062306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC1_LEFT4	0x010b	/* Audio Dock ADC1 Left, 4th or 192kHz */
140162306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC1_RIGHT1	0x010c	/* Audio Dock ADC1 Right, 1st or 48kHz only */
140262306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC1_RIGHT2	0x010d	/* Audio Dock ADC1 Right, 2nd or 96kHz */
140362306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC1_RIGHT3	0x010e	/* Audio Dock ADC1 Right, 3rd or 192kHz */
140462306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC1_RIGHT4	0x010f	/* Audio Dock ADC1 Right, 4th or 192kHz */
140562306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC2_LEFT1	0x0110	/* Audio Dock ADC2 Left, 1st or 48kHz only */
140662306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC2_LEFT2	0x0111	/* Audio Dock ADC2 Left, 2nd or 96kHz */
140762306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC2_LEFT3	0x0112	/* Audio Dock ADC2 Left, 3rd or 192kHz */
140862306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC2_LEFT4	0x0113	/* Audio Dock ADC2 Left, 4th or 192kHz */
140962306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC2_RIGHT1	0x0114	/* Audio Dock ADC2 Right, 1st or 48kHz only */
141062306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC2_RIGHT2	0x0115	/* Audio Dock ADC2 Right, 2nd or 96kHz */
141162306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC2_RIGHT3	0x0116	/* Audio Dock ADC2 Right, 3rd or 192kHz */
141262306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC2_RIGHT4	0x0117	/* Audio Dock ADC2 Right, 4th or 192kHz */
141362306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC3_LEFT1	0x0118	/* Audio Dock ADC3 Left, 1st or 48kHz only */
141462306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC3_LEFT2	0x0119	/* Audio Dock ADC3 Left, 2nd or 96kHz */
141562306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC3_LEFT3	0x011a	/* Audio Dock ADC3 Left, 3rd or 192kHz */
141662306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC3_LEFT4	0x011b	/* Audio Dock ADC3 Left, 4th or 192kHz */
141762306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC3_RIGHT1	0x011c	/* Audio Dock ADC3 Right, 1st or 48kHz only */
141862306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC3_RIGHT2	0x011d	/* Audio Dock ADC3 Right, 2nd or 96kHz */
141962306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC3_RIGHT3	0x011e	/* Audio Dock ADC3 Right, 3rd or 192kHz */
142062306a36Sopenharmony_ci#define EMU_SRC_DOCK_ADC3_RIGHT4	0x011f	/* Audio Dock ADC3 Right, 4th or 192kHz */
142162306a36Sopenharmony_ci#define EMU_SRC_HAMOA_ADC_LEFT1	0x0200	/* Hamoa ADC Left, 1st or 48kHz only */
142262306a36Sopenharmony_ci#define EMU_SRC_HAMOA_ADC_LEFT2	0x0202	/* Hamoa ADC Left, 2nd or 96kHz */
142362306a36Sopenharmony_ci#define EMU_SRC_HAMOA_ADC_LEFT3	0x0204	/* Hamoa ADC Left, 3rd or 192kHz */
142462306a36Sopenharmony_ci#define EMU_SRC_HAMOA_ADC_LEFT4	0x0206	/* Hamoa ADC Left, 4th or 192kHz */
142562306a36Sopenharmony_ci#define EMU_SRC_HAMOA_ADC_RIGHT1	0x0201	/* Hamoa ADC Right, 1st or 48kHz only */
142662306a36Sopenharmony_ci#define EMU_SRC_HAMOA_ADC_RIGHT2	0x0203	/* Hamoa ADC Right, 2nd or 96kHz */
142762306a36Sopenharmony_ci#define EMU_SRC_HAMOA_ADC_RIGHT3	0x0205	/* Hamoa ADC Right, 3rd or 192kHz */
142862306a36Sopenharmony_ci#define EMU_SRC_HAMOA_ADC_RIGHT4	0x0207	/* Hamoa ADC Right, 4th or 192kHz */
142962306a36Sopenharmony_ci#define EMU_SRC_ALICE_EMU32A		0x0300	/* Alice2 EMU32a 16 outputs. +0 to +0xf */
143062306a36Sopenharmony_ci#define EMU_SRC_ALICE_EMU32B		0x0310	/* Alice2 EMU32b 16 outputs. +0 to +0xf */
143162306a36Sopenharmony_ci// In S/MUX mode, the samples of one channel are adjacent.
143262306a36Sopenharmony_ci#define EMU_SRC_HANA_ADAT	0x0400	/* Hana ADAT 8 channel in +0 to +7 */
143362306a36Sopenharmony_ci#define EMU_SRC_HANA_SPDIF_LEFT1	0x0500	/* Hana SPDIF Left, 1st or 48kHz only */
143462306a36Sopenharmony_ci#define EMU_SRC_HANA_SPDIF_LEFT2	0x0502	/* Hana SPDIF Left, 2nd or 96kHz */
143562306a36Sopenharmony_ci#define EMU_SRC_HANA_SPDIF_LEFT3	0x0504	/* Hana SPDIF Left, 3rd or 192kHz */
143662306a36Sopenharmony_ci#define EMU_SRC_HANA_SPDIF_LEFT4	0x0506	/* Hana SPDIF Left, 4th or 192kHz */
143762306a36Sopenharmony_ci#define EMU_SRC_HANA_SPDIF_RIGHT1	0x0501	/* Hana SPDIF Right, 1st or 48kHz only */
143862306a36Sopenharmony_ci#define EMU_SRC_HANA_SPDIF_RIGHT2	0x0503	/* Hana SPDIF Right, 2nd or 96kHz */
143962306a36Sopenharmony_ci#define EMU_SRC_HANA_SPDIF_RIGHT3	0x0505	/* Hana SPDIF Right, 3rd or 192kHz */
144062306a36Sopenharmony_ci#define EMU_SRC_HANA_SPDIF_RIGHT4	0x0507	/* Hana SPDIF Right, 4th or 192kHz */
144162306a36Sopenharmony_ci
144262306a36Sopenharmony_ci/* Additional inputs for 1616(M)/Microdock */
144362306a36Sopenharmony_ci
144462306a36Sopenharmony_ci#define EMU_SRC_MDOCK_SPDIF_LEFT1	0x0112	/* Microdock S/PDIF Left, 1st or 48kHz only */
144562306a36Sopenharmony_ci#define EMU_SRC_MDOCK_SPDIF_LEFT2	0x0113	/* Microdock S/PDIF Left, 2nd or 96kHz */
144662306a36Sopenharmony_ci#define EMU_SRC_MDOCK_SPDIF_RIGHT1	0x0116	/* Microdock S/PDIF Right, 1st or 48kHz only */
144762306a36Sopenharmony_ci#define EMU_SRC_MDOCK_SPDIF_RIGHT2	0x0117	/* Microdock S/PDIF Right, 2nd or 96kHz */
144862306a36Sopenharmony_ci#define EMU_SRC_MDOCK_ADAT		0x0118	/* Microdock ADAT 8 channel in +8 to +f */
144962306a36Sopenharmony_ci
145062306a36Sopenharmony_ci/* 0x600 and 0x700 no used */
145162306a36Sopenharmony_ci
145262306a36Sopenharmony_ci
145362306a36Sopenharmony_ci/* ------------------- CONSTANTS -------------------- */
145462306a36Sopenharmony_ci
145562306a36Sopenharmony_ciextern const char * const snd_emu10k1_fxbus[32];
145662306a36Sopenharmony_ciextern const char * const snd_emu10k1_sblive_ins[16];
145762306a36Sopenharmony_ciextern const char * const snd_emu10k1_audigy_ins[16];
145862306a36Sopenharmony_ciextern const char * const snd_emu10k1_sblive_outs[32];
145962306a36Sopenharmony_ciextern const char * const snd_emu10k1_audigy_outs[32];
146062306a36Sopenharmony_ciextern const s8 snd_emu10k1_sblive51_fxbus2_map[16];
146162306a36Sopenharmony_ci
146262306a36Sopenharmony_ci/* ------------------- STRUCTURES -------------------- */
146362306a36Sopenharmony_ci
146462306a36Sopenharmony_cienum {
146562306a36Sopenharmony_ci	EMU10K1_UNUSED,  // This must be zero
146662306a36Sopenharmony_ci	EMU10K1_EFX,
146762306a36Sopenharmony_ci	EMU10K1_EFX_IRQ,
146862306a36Sopenharmony_ci	EMU10K1_PCM,
146962306a36Sopenharmony_ci	EMU10K1_PCM_IRQ,
147062306a36Sopenharmony_ci	EMU10K1_SYNTH,
147162306a36Sopenharmony_ci	EMU10K1_NUM_TYPES
147262306a36Sopenharmony_ci};
147362306a36Sopenharmony_ci
147462306a36Sopenharmony_cistruct snd_emu10k1;
147562306a36Sopenharmony_ci
147662306a36Sopenharmony_cistruct snd_emu10k1_voice {
147762306a36Sopenharmony_ci	unsigned char number;
147862306a36Sopenharmony_ci	unsigned char use;
147962306a36Sopenharmony_ci	unsigned char dirty;
148062306a36Sopenharmony_ci	unsigned char last;
148162306a36Sopenharmony_ci	void (*interrupt)(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *pvoice);
148262306a36Sopenharmony_ci
148362306a36Sopenharmony_ci	struct snd_emu10k1_pcm *epcm;
148462306a36Sopenharmony_ci};
148562306a36Sopenharmony_ci
148662306a36Sopenharmony_cienum {
148762306a36Sopenharmony_ci	PLAYBACK_EMUVOICE,
148862306a36Sopenharmony_ci	PLAYBACK_EFX,
148962306a36Sopenharmony_ci	CAPTURE_AC97ADC,
149062306a36Sopenharmony_ci	CAPTURE_AC97MIC,
149162306a36Sopenharmony_ci	CAPTURE_EFX
149262306a36Sopenharmony_ci};
149362306a36Sopenharmony_ci
149462306a36Sopenharmony_cistruct snd_emu10k1_pcm {
149562306a36Sopenharmony_ci	struct snd_emu10k1 *emu;
149662306a36Sopenharmony_ci	int type;
149762306a36Sopenharmony_ci	struct snd_pcm_substream *substream;
149862306a36Sopenharmony_ci	struct snd_emu10k1_voice *voices[NUM_EFX_PLAYBACK];
149962306a36Sopenharmony_ci	struct snd_emu10k1_voice *extra;
150062306a36Sopenharmony_ci	unsigned short running;
150162306a36Sopenharmony_ci	unsigned short first_ptr;
150262306a36Sopenharmony_ci	snd_pcm_uframes_t resume_pos;
150362306a36Sopenharmony_ci	struct snd_util_memblk *memblk;
150462306a36Sopenharmony_ci	unsigned int pitch_target;
150562306a36Sopenharmony_ci	unsigned int start_addr;
150662306a36Sopenharmony_ci	unsigned int ccca_start_addr;
150762306a36Sopenharmony_ci	unsigned int capture_ipr;	/* interrupt acknowledge mask */
150862306a36Sopenharmony_ci	unsigned int capture_inte;	/* interrupt enable mask */
150962306a36Sopenharmony_ci	unsigned int capture_ba_reg;	/* buffer address register */
151062306a36Sopenharmony_ci	unsigned int capture_bs_reg;	/* buffer size register */
151162306a36Sopenharmony_ci	unsigned int capture_idx_reg;	/* buffer index register */
151262306a36Sopenharmony_ci	unsigned int capture_cr_val;	/* control value */
151362306a36Sopenharmony_ci	unsigned int capture_cr_val2;	/* control value2 (for audigy) */
151462306a36Sopenharmony_ci	unsigned int capture_bs_val;	/* buffer size value */
151562306a36Sopenharmony_ci	unsigned int capture_bufsize;	/* buffer size in bytes */
151662306a36Sopenharmony_ci};
151762306a36Sopenharmony_ci
151862306a36Sopenharmony_cistruct snd_emu10k1_pcm_mixer {
151962306a36Sopenharmony_ci	/* mono, left, right x 8 sends (4 on emu10k1) */
152062306a36Sopenharmony_ci	unsigned char send_routing[3][8];
152162306a36Sopenharmony_ci	unsigned char send_volume[3][8];
152262306a36Sopenharmony_ci	// 0x8000 is neutral. The mixer code rescales it to 0xffff to maintain
152362306a36Sopenharmony_ci	// backwards compatibility with user space.
152462306a36Sopenharmony_ci	unsigned short attn[3];
152562306a36Sopenharmony_ci	struct snd_emu10k1_pcm *epcm;
152662306a36Sopenharmony_ci};
152762306a36Sopenharmony_ci
152862306a36Sopenharmony_ci#define snd_emu10k1_compose_send_routing(route) \
152962306a36Sopenharmony_ci((route[0] | (route[1] << 4) | (route[2] << 8) | (route[3] << 12)) << 16)
153062306a36Sopenharmony_ci
153162306a36Sopenharmony_ci#define snd_emu10k1_compose_audigy_fxrt1(route) \
153262306a36Sopenharmony_ci((unsigned int)route[0] | ((unsigned int)route[1] << 8) | ((unsigned int)route[2] << 16) | ((unsigned int)route[3] << 24) | 0x80808080)
153362306a36Sopenharmony_ci
153462306a36Sopenharmony_ci#define snd_emu10k1_compose_audigy_fxrt2(route) \
153562306a36Sopenharmony_ci((unsigned int)route[4] | ((unsigned int)route[5] << 8) | ((unsigned int)route[6] << 16) | ((unsigned int)route[7] << 24) | 0x80808080)
153662306a36Sopenharmony_ci
153762306a36Sopenharmony_ci#define snd_emu10k1_compose_audigy_sendamounts(vol) \
153862306a36Sopenharmony_ci(((unsigned int)vol[4] << 24) | ((unsigned int)vol[5] << 16) | ((unsigned int)vol[6] << 8) | (unsigned int)vol[7])
153962306a36Sopenharmony_ci
154062306a36Sopenharmony_cistruct snd_emu10k1_memblk {
154162306a36Sopenharmony_ci	struct snd_util_memblk mem;
154262306a36Sopenharmony_ci	/* private part */
154362306a36Sopenharmony_ci	int first_page, last_page, pages, mapped_page;
154462306a36Sopenharmony_ci	unsigned int map_locked;
154562306a36Sopenharmony_ci	struct list_head mapped_link;
154662306a36Sopenharmony_ci	struct list_head mapped_order_link;
154762306a36Sopenharmony_ci};
154862306a36Sopenharmony_ci
154962306a36Sopenharmony_ci#define snd_emu10k1_memblk_offset(blk)	(((blk)->mapped_page << PAGE_SHIFT) | ((blk)->mem.offset & (PAGE_SIZE - 1)))
155062306a36Sopenharmony_ci
155162306a36Sopenharmony_ci#define EMU10K1_MAX_TRAM_BLOCKS_PER_CODE	16
155262306a36Sopenharmony_ci
155362306a36Sopenharmony_cistruct snd_emu10k1_fx8010_ctl {
155462306a36Sopenharmony_ci	struct list_head list;		/* list link container */
155562306a36Sopenharmony_ci	unsigned int vcount;
155662306a36Sopenharmony_ci	unsigned int count;		/* count of GPR (1..16) */
155762306a36Sopenharmony_ci	unsigned short gpr[32];		/* GPR number(s) */
155862306a36Sopenharmony_ci	int value[32];
155962306a36Sopenharmony_ci	int min;			/* minimum range */
156062306a36Sopenharmony_ci	int max;			/* maximum range */
156162306a36Sopenharmony_ci	unsigned int translation;	/* translation type (EMU10K1_GPR_TRANSLATION*) */
156262306a36Sopenharmony_ci	struct snd_kcontrol *kcontrol;
156362306a36Sopenharmony_ci};
156462306a36Sopenharmony_ci
156562306a36Sopenharmony_citypedef void (snd_fx8010_irq_handler_t)(struct snd_emu10k1 *emu, void *private_data);
156662306a36Sopenharmony_ci
156762306a36Sopenharmony_cistruct snd_emu10k1_fx8010_irq {
156862306a36Sopenharmony_ci	struct snd_emu10k1_fx8010_irq *next;
156962306a36Sopenharmony_ci	snd_fx8010_irq_handler_t *handler;
157062306a36Sopenharmony_ci	unsigned short gpr_running;
157162306a36Sopenharmony_ci	void *private_data;
157262306a36Sopenharmony_ci};
157362306a36Sopenharmony_ci
157462306a36Sopenharmony_cistruct snd_emu10k1_fx8010_pcm {
157562306a36Sopenharmony_ci	unsigned int valid: 1,
157662306a36Sopenharmony_ci		     opened: 1,
157762306a36Sopenharmony_ci		     active: 1;
157862306a36Sopenharmony_ci	unsigned int channels;		/* 16-bit channels count */
157962306a36Sopenharmony_ci	unsigned int tram_start;	/* initial ring buffer position in TRAM (in samples) */
158062306a36Sopenharmony_ci	unsigned int buffer_size;	/* count of buffered samples */
158162306a36Sopenharmony_ci	unsigned short gpr_size;		/* GPR containing size of ring buffer in samples (host) */
158262306a36Sopenharmony_ci	unsigned short gpr_ptr;		/* GPR containing current pointer in the ring buffer (host = reset, FX8010) */
158362306a36Sopenharmony_ci	unsigned short gpr_count;	/* GPR containing count of samples between two interrupts (host) */
158462306a36Sopenharmony_ci	unsigned short gpr_tmpcount;	/* GPR containing current count of samples to interrupt (host = set, FX8010) */
158562306a36Sopenharmony_ci	unsigned short gpr_trigger;	/* GPR containing trigger (activate) information (host) */
158662306a36Sopenharmony_ci	unsigned short gpr_running;	/* GPR containing info if PCM is running (FX8010) */
158762306a36Sopenharmony_ci	unsigned char etram[32];	/* external TRAM address & data */
158862306a36Sopenharmony_ci	struct snd_pcm_indirect pcm_rec;
158962306a36Sopenharmony_ci	unsigned int tram_pos;
159062306a36Sopenharmony_ci	unsigned int tram_shift;
159162306a36Sopenharmony_ci	struct snd_emu10k1_fx8010_irq irq;
159262306a36Sopenharmony_ci};
159362306a36Sopenharmony_ci
159462306a36Sopenharmony_cistruct snd_emu10k1_fx8010 {
159562306a36Sopenharmony_ci	unsigned short extin_mask;	/* used external inputs (bitmask); not used for Audigy */
159662306a36Sopenharmony_ci	unsigned short extout_mask;	/* used external outputs (bitmask); not used for Audigy */
159762306a36Sopenharmony_ci	unsigned int itram_size;	/* internal TRAM size in samples */
159862306a36Sopenharmony_ci	struct snd_dma_buffer etram_pages; /* external TRAM pages and size */
159962306a36Sopenharmony_ci	unsigned int dbg;		/* FX debugger register */
160062306a36Sopenharmony_ci	unsigned char name[128];
160162306a36Sopenharmony_ci	int gpr_size;			/* size of allocated GPR controls */
160262306a36Sopenharmony_ci	int gpr_count;			/* count of used kcontrols */
160362306a36Sopenharmony_ci	struct list_head gpr_ctl;	/* GPR controls */
160462306a36Sopenharmony_ci	struct mutex lock;
160562306a36Sopenharmony_ci	struct snd_emu10k1_fx8010_pcm pcm[8];
160662306a36Sopenharmony_ci	spinlock_t irq_lock;
160762306a36Sopenharmony_ci	struct snd_emu10k1_fx8010_irq *irq_handlers;
160862306a36Sopenharmony_ci};
160962306a36Sopenharmony_ci
161062306a36Sopenharmony_cistruct snd_emu10k1_midi {
161162306a36Sopenharmony_ci	struct snd_emu10k1 *emu;
161262306a36Sopenharmony_ci	struct snd_rawmidi *rmidi;
161362306a36Sopenharmony_ci	struct snd_rawmidi_substream *substream_input;
161462306a36Sopenharmony_ci	struct snd_rawmidi_substream *substream_output;
161562306a36Sopenharmony_ci	unsigned int midi_mode;
161662306a36Sopenharmony_ci	spinlock_t input_lock;
161762306a36Sopenharmony_ci	spinlock_t output_lock;
161862306a36Sopenharmony_ci	spinlock_t open_lock;
161962306a36Sopenharmony_ci	int tx_enable, rx_enable;
162062306a36Sopenharmony_ci	int port;
162162306a36Sopenharmony_ci	int ipr_tx, ipr_rx;
162262306a36Sopenharmony_ci	void (*interrupt)(struct snd_emu10k1 *emu, unsigned int status);
162362306a36Sopenharmony_ci};
162462306a36Sopenharmony_ci
162562306a36Sopenharmony_cienum {
162662306a36Sopenharmony_ci	EMU_MODEL_SB,
162762306a36Sopenharmony_ci	EMU_MODEL_EMU1010,
162862306a36Sopenharmony_ci	EMU_MODEL_EMU1010B,
162962306a36Sopenharmony_ci	EMU_MODEL_EMU1616,
163062306a36Sopenharmony_ci	EMU_MODEL_EMU0404,
163162306a36Sopenharmony_ci};
163262306a36Sopenharmony_ci
163362306a36Sopenharmony_ci// Chip-o-logy:
163462306a36Sopenharmony_ci// - All SB Live! cards use EMU10K1 chips
163562306a36Sopenharmony_ci// - All SB Audigy cards use CA* chips, termed "emu10k2" by the driver
163662306a36Sopenharmony_ci// - Original Audigy uses CA0100 "Alice"
163762306a36Sopenharmony_ci// - Audigy 2 uses CA0102/CA10200 "Alice2"
163862306a36Sopenharmony_ci//   - Has an interface for CA0151 (P16V) "Alice3"
163962306a36Sopenharmony_ci// - Audigy 2 Value uses CA0108/CA10300 "Tina"
164062306a36Sopenharmony_ci//   - Approximately a CA0102 with an on-chip CA0151 (P17V)
164162306a36Sopenharmony_ci// - Audigy 2 ZS NB uses CA0109 "Tina2"
164262306a36Sopenharmony_ci//   - Cardbus version of CA0108
164362306a36Sopenharmony_cistruct snd_emu_chip_details {
164462306a36Sopenharmony_ci	u32 vendor;
164562306a36Sopenharmony_ci	u32 device;
164662306a36Sopenharmony_ci	u32 subsystem;
164762306a36Sopenharmony_ci	unsigned char revision;
164862306a36Sopenharmony_ci	unsigned char emu_model;	/* EMU model type */
164962306a36Sopenharmony_ci	unsigned int emu10k1_chip:1;	/* Original SB Live. Not SB Live 24bit. */
165062306a36Sopenharmony_ci					/* Redundant with emu10k2_chip being unset. */
165162306a36Sopenharmony_ci	unsigned int emu10k2_chip:1;	/* Audigy 1 or Audigy 2. */
165262306a36Sopenharmony_ci	unsigned int ca0102_chip:1;	/* Audigy 1 or Audigy 2. Not SB Audigy 2 Value. */
165362306a36Sopenharmony_ci					/* Redundant with ca0108_chip being unset. */
165462306a36Sopenharmony_ci	unsigned int ca0108_chip:1;	/* Audigy 2 Value */
165562306a36Sopenharmony_ci	unsigned int ca_cardbus_chip:1;	/* Audigy 2 ZS Notebook */
165662306a36Sopenharmony_ci	unsigned int ca0151_chip:1;	/* P16V */
165762306a36Sopenharmony_ci	unsigned int spk20:1;		/* Stereo only */
165862306a36Sopenharmony_ci	unsigned int spk71:1;		/* Has 7.1 speakers */
165962306a36Sopenharmony_ci	unsigned int no_adat:1;		/* Has no ADAT, only SPDIF */
166062306a36Sopenharmony_ci	unsigned int sblive51:1;	/* SBLive! 5.1 - extout 0x11 -> center, 0x12 -> lfe */
166162306a36Sopenharmony_ci	unsigned int spdif_bug:1;	/* Has Spdif phasing bug */
166262306a36Sopenharmony_ci	unsigned int ac97_chip:2;	/* Has an AC97 chip: 1 = mandatory, 2 = optional */
166362306a36Sopenharmony_ci	unsigned int ecard:1;		/* APS EEPROM */
166462306a36Sopenharmony_ci	unsigned int spi_dac:1;		/* SPI interface for DAC; requires ca0108_chip */
166562306a36Sopenharmony_ci	unsigned int i2c_adc:1;		/* I2C interface for ADC; requires ca0108_chip */
166662306a36Sopenharmony_ci	unsigned int adc_1361t:1;	/* Use Philips 1361T ADC */
166762306a36Sopenharmony_ci	unsigned int invert_shared_spdif:1;  /* analog/digital switch inverted */
166862306a36Sopenharmony_ci	const char *driver;
166962306a36Sopenharmony_ci	const char *name;
167062306a36Sopenharmony_ci	const char *id;		/* for backward compatibility - can be NULL if not needed */
167162306a36Sopenharmony_ci};
167262306a36Sopenharmony_ci
167362306a36Sopenharmony_ci#define NUM_OUTPUT_DESTS 28
167462306a36Sopenharmony_ci#define NUM_INPUT_DESTS 22
167562306a36Sopenharmony_ci
167662306a36Sopenharmony_cistruct snd_emu1010 {
167762306a36Sopenharmony_ci	unsigned char output_source[NUM_OUTPUT_DESTS];
167862306a36Sopenharmony_ci	unsigned char input_source[NUM_INPUT_DESTS];
167962306a36Sopenharmony_ci	unsigned int adc_pads; /* bit mask */
168062306a36Sopenharmony_ci	unsigned int dac_pads; /* bit mask */
168162306a36Sopenharmony_ci	unsigned int wclock;  /* Cached register value */
168262306a36Sopenharmony_ci	unsigned int word_clock;  /* Cached effective value */
168362306a36Sopenharmony_ci	unsigned int clock_source;
168462306a36Sopenharmony_ci	unsigned int clock_fallback;
168562306a36Sopenharmony_ci	unsigned int optical_in; /* 0:SPDIF, 1:ADAT */
168662306a36Sopenharmony_ci	unsigned int optical_out; /* 0:SPDIF, 1:ADAT */
168762306a36Sopenharmony_ci	struct work_struct firmware_work;
168862306a36Sopenharmony_ci	struct work_struct clock_work;
168962306a36Sopenharmony_ci};
169062306a36Sopenharmony_ci
169162306a36Sopenharmony_cistruct snd_emu10k1 {
169262306a36Sopenharmony_ci	int irq;
169362306a36Sopenharmony_ci
169462306a36Sopenharmony_ci	unsigned long port;			/* I/O port number */
169562306a36Sopenharmony_ci	unsigned int tos_link: 1,		/* tos link detected */
169662306a36Sopenharmony_ci		rear_ac97: 1,			/* rear channels are on AC'97 */
169762306a36Sopenharmony_ci		enable_ir: 1;
169862306a36Sopenharmony_ci	unsigned int support_tlv :1;
169962306a36Sopenharmony_ci	/* Contains profile of card capabilities */
170062306a36Sopenharmony_ci	const struct snd_emu_chip_details *card_capabilities;
170162306a36Sopenharmony_ci	unsigned int audigy;			/* is Audigy? */
170262306a36Sopenharmony_ci	unsigned int revision;			/* chip revision */
170362306a36Sopenharmony_ci	unsigned int serial;			/* serial number */
170462306a36Sopenharmony_ci	unsigned short model;			/* subsystem id */
170562306a36Sopenharmony_ci	unsigned int ecard_ctrl;		/* ecard control bits */
170662306a36Sopenharmony_ci	unsigned int address_mode;		/* address mode */
170762306a36Sopenharmony_ci	unsigned long dma_mask;			/* PCI DMA mask */
170862306a36Sopenharmony_ci	bool iommu_workaround;			/* IOMMU workaround needed */
170962306a36Sopenharmony_ci	int max_cache_pages;			/* max memory size / PAGE_SIZE */
171062306a36Sopenharmony_ci	struct snd_dma_buffer silent_page;	/* silent page */
171162306a36Sopenharmony_ci	struct snd_dma_buffer ptb_pages;	/* page table pages */
171262306a36Sopenharmony_ci	struct snd_dma_device p16v_dma_dev;
171362306a36Sopenharmony_ci	struct snd_dma_buffer *p16v_buffer;
171462306a36Sopenharmony_ci
171562306a36Sopenharmony_ci	struct snd_util_memhdr *memhdr;		/* page allocation list */
171662306a36Sopenharmony_ci
171762306a36Sopenharmony_ci	struct list_head mapped_link_head;
171862306a36Sopenharmony_ci	struct list_head mapped_order_link_head;
171962306a36Sopenharmony_ci	void **page_ptr_table;
172062306a36Sopenharmony_ci	unsigned long *page_addr_table;
172162306a36Sopenharmony_ci	spinlock_t memblk_lock;
172262306a36Sopenharmony_ci
172362306a36Sopenharmony_ci	unsigned int spdif_bits[3];		/* s/pdif out setup */
172462306a36Sopenharmony_ci	unsigned int i2c_capture_source;
172562306a36Sopenharmony_ci	u8 i2c_capture_volume[4][2];
172662306a36Sopenharmony_ci
172762306a36Sopenharmony_ci	struct snd_emu10k1_fx8010 fx8010;		/* FX8010 info */
172862306a36Sopenharmony_ci	int gpr_base;
172962306a36Sopenharmony_ci
173062306a36Sopenharmony_ci	struct snd_ac97 *ac97;
173162306a36Sopenharmony_ci
173262306a36Sopenharmony_ci	struct pci_dev *pci;
173362306a36Sopenharmony_ci	struct snd_card *card;
173462306a36Sopenharmony_ci	struct snd_pcm *pcm;
173562306a36Sopenharmony_ci	struct snd_pcm *pcm_mic;
173662306a36Sopenharmony_ci	struct snd_pcm *pcm_efx;
173762306a36Sopenharmony_ci	struct snd_pcm *pcm_multi;
173862306a36Sopenharmony_ci	struct snd_pcm *pcm_p16v;
173962306a36Sopenharmony_ci
174062306a36Sopenharmony_ci	spinlock_t synth_lock;
174162306a36Sopenharmony_ci	void *synth;
174262306a36Sopenharmony_ci	int (*get_synth_voice)(struct snd_emu10k1 *emu);
174362306a36Sopenharmony_ci
174462306a36Sopenharmony_ci	spinlock_t reg_lock;  // high-level driver lock
174562306a36Sopenharmony_ci	spinlock_t emu_lock;  // low-level i/o lock
174662306a36Sopenharmony_ci	spinlock_t voice_lock;  // voice allocator lock
174762306a36Sopenharmony_ci	spinlock_t spi_lock; /* serialises access to spi port */
174862306a36Sopenharmony_ci	spinlock_t i2c_lock; /* serialises access to i2c port */
174962306a36Sopenharmony_ci
175062306a36Sopenharmony_ci	struct snd_emu10k1_voice voices[NUM_G];
175162306a36Sopenharmony_ci	int p16v_device_offset;
175262306a36Sopenharmony_ci	u32 p16v_capture_source;
175362306a36Sopenharmony_ci	u32 p16v_capture_channel;
175462306a36Sopenharmony_ci        struct snd_emu1010 emu1010;
175562306a36Sopenharmony_ci	struct snd_emu10k1_pcm_mixer pcm_mixer[32];
175662306a36Sopenharmony_ci	struct snd_emu10k1_pcm_mixer efx_pcm_mixer[NUM_EFX_PLAYBACK];
175762306a36Sopenharmony_ci	struct snd_kcontrol *ctl_send_routing;
175862306a36Sopenharmony_ci	struct snd_kcontrol *ctl_send_volume;
175962306a36Sopenharmony_ci	struct snd_kcontrol *ctl_attn;
176062306a36Sopenharmony_ci	struct snd_kcontrol *ctl_efx_send_routing;
176162306a36Sopenharmony_ci	struct snd_kcontrol *ctl_efx_send_volume;
176262306a36Sopenharmony_ci	struct snd_kcontrol *ctl_efx_attn;
176362306a36Sopenharmony_ci	struct snd_kcontrol *ctl_clock_source;
176462306a36Sopenharmony_ci
176562306a36Sopenharmony_ci	void (*hwvol_interrupt)(struct snd_emu10k1 *emu, unsigned int status);
176662306a36Sopenharmony_ci	void (*capture_interrupt)(struct snd_emu10k1 *emu, unsigned int status);
176762306a36Sopenharmony_ci	void (*capture_mic_interrupt)(struct snd_emu10k1 *emu, unsigned int status);
176862306a36Sopenharmony_ci	void (*capture_efx_interrupt)(struct snd_emu10k1 *emu, unsigned int status);
176962306a36Sopenharmony_ci	void (*spdif_interrupt)(struct snd_emu10k1 *emu, unsigned int status);
177062306a36Sopenharmony_ci	void (*dsp_interrupt)(struct snd_emu10k1 *emu);
177162306a36Sopenharmony_ci	void (*gpio_interrupt)(struct snd_emu10k1 *emu);
177262306a36Sopenharmony_ci	void (*p16v_interrupt)(struct snd_emu10k1 *emu);
177362306a36Sopenharmony_ci
177462306a36Sopenharmony_ci	struct snd_pcm_substream *pcm_capture_substream;
177562306a36Sopenharmony_ci	struct snd_pcm_substream *pcm_capture_mic_substream;
177662306a36Sopenharmony_ci	struct snd_pcm_substream *pcm_capture_efx_substream;
177762306a36Sopenharmony_ci
177862306a36Sopenharmony_ci	struct snd_timer *timer;
177962306a36Sopenharmony_ci
178062306a36Sopenharmony_ci	struct snd_emu10k1_midi midi;
178162306a36Sopenharmony_ci	struct snd_emu10k1_midi midi2; /* for audigy */
178262306a36Sopenharmony_ci
178362306a36Sopenharmony_ci	unsigned int efx_voices_mask[2];
178462306a36Sopenharmony_ci	unsigned int next_free_voice;
178562306a36Sopenharmony_ci
178662306a36Sopenharmony_ci	const struct firmware *firmware;
178762306a36Sopenharmony_ci	const struct firmware *dock_fw;
178862306a36Sopenharmony_ci
178962306a36Sopenharmony_ci#ifdef CONFIG_PM_SLEEP
179062306a36Sopenharmony_ci	unsigned int *saved_ptr;
179162306a36Sopenharmony_ci	unsigned int *saved_gpr;
179262306a36Sopenharmony_ci	unsigned int *tram_val_saved;
179362306a36Sopenharmony_ci	unsigned int *tram_addr_saved;
179462306a36Sopenharmony_ci	unsigned int *saved_icode;
179562306a36Sopenharmony_ci	unsigned int *p16v_saved;
179662306a36Sopenharmony_ci	unsigned int saved_a_iocfg, saved_hcfg;
179762306a36Sopenharmony_ci	bool suspend;
179862306a36Sopenharmony_ci#endif
179962306a36Sopenharmony_ci
180062306a36Sopenharmony_ci};
180162306a36Sopenharmony_ci
180262306a36Sopenharmony_ciint snd_emu10k1_create(struct snd_card *card,
180362306a36Sopenharmony_ci		       struct pci_dev *pci,
180462306a36Sopenharmony_ci		       unsigned short extin_mask,
180562306a36Sopenharmony_ci		       unsigned short extout_mask,
180662306a36Sopenharmony_ci		       long max_cache_bytes,
180762306a36Sopenharmony_ci		       int enable_ir,
180862306a36Sopenharmony_ci		       uint subsystem);
180962306a36Sopenharmony_ci
181062306a36Sopenharmony_ciint snd_emu10k1_pcm(struct snd_emu10k1 *emu, int device);
181162306a36Sopenharmony_ciint snd_emu10k1_pcm_mic(struct snd_emu10k1 *emu, int device);
181262306a36Sopenharmony_ciint snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device);
181362306a36Sopenharmony_ciint snd_p16v_pcm(struct snd_emu10k1 *emu, int device);
181462306a36Sopenharmony_ciint snd_p16v_mixer(struct snd_emu10k1 * emu);
181562306a36Sopenharmony_ciint snd_emu10k1_pcm_multi(struct snd_emu10k1 *emu, int device);
181662306a36Sopenharmony_ciint snd_emu10k1_fx8010_pcm(struct snd_emu10k1 *emu, int device);
181762306a36Sopenharmony_ciint snd_emu10k1_mixer(struct snd_emu10k1 * emu, int pcm_device, int multi_device);
181862306a36Sopenharmony_ciint snd_emu10k1_timer(struct snd_emu10k1 * emu, int device);
181962306a36Sopenharmony_ciint snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device);
182062306a36Sopenharmony_ci
182162306a36Sopenharmony_ciirqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id);
182262306a36Sopenharmony_ci
182362306a36Sopenharmony_civoid snd_emu10k1_voice_init(struct snd_emu10k1 * emu, int voice);
182462306a36Sopenharmony_ciint snd_emu10k1_init_efx(struct snd_emu10k1 *emu);
182562306a36Sopenharmony_civoid snd_emu10k1_free_efx(struct snd_emu10k1 *emu);
182662306a36Sopenharmony_ciint snd_emu10k1_fx8010_tram_setup(struct snd_emu10k1 *emu, u32 size);
182762306a36Sopenharmony_ciint snd_emu10k1_done(struct snd_emu10k1 * emu);
182862306a36Sopenharmony_ci
182962306a36Sopenharmony_ci/* I/O functions */
183062306a36Sopenharmony_ciunsigned int snd_emu10k1_ptr_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn);
183162306a36Sopenharmony_civoid snd_emu10k1_ptr_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data);
183262306a36Sopenharmony_civoid snd_emu10k1_ptr_write_multiple(struct snd_emu10k1 *emu, unsigned int chn, ...);
183362306a36Sopenharmony_ciunsigned int snd_emu10k1_ptr20_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn);
183462306a36Sopenharmony_civoid snd_emu10k1_ptr20_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data);
183562306a36Sopenharmony_ciint snd_emu10k1_spi_write(struct snd_emu10k1 * emu, unsigned int data);
183662306a36Sopenharmony_ciint snd_emu10k1_i2c_write(struct snd_emu10k1 *emu, u32 reg, u32 value);
183762306a36Sopenharmony_civoid snd_emu1010_fpga_write(struct snd_emu10k1 *emu, u32 reg, u32 value);
183862306a36Sopenharmony_civoid snd_emu1010_fpga_read(struct snd_emu10k1 *emu, u32 reg, u32 *value);
183962306a36Sopenharmony_civoid snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 *emu, u32 dst, u32 src);
184062306a36Sopenharmony_ciu32 snd_emu1010_fpga_link_dst_src_read(struct snd_emu10k1 *emu, u32 dst);
184162306a36Sopenharmony_ciint snd_emu1010_get_raw_rate(struct snd_emu10k1 *emu, u8 src);
184262306a36Sopenharmony_civoid snd_emu1010_update_clock(struct snd_emu10k1 *emu);
184362306a36Sopenharmony_ciunsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc);
184462306a36Sopenharmony_civoid snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb);
184562306a36Sopenharmony_civoid snd_emu10k1_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb);
184662306a36Sopenharmony_civoid snd_emu10k1_voice_intr_enable(struct snd_emu10k1 *emu, unsigned int voicenum);
184762306a36Sopenharmony_civoid snd_emu10k1_voice_intr_disable(struct snd_emu10k1 *emu, unsigned int voicenum);
184862306a36Sopenharmony_civoid snd_emu10k1_voice_intr_ack(struct snd_emu10k1 *emu, unsigned int voicenum);
184962306a36Sopenharmony_civoid snd_emu10k1_voice_half_loop_intr_enable(struct snd_emu10k1 *emu, unsigned int voicenum);
185062306a36Sopenharmony_civoid snd_emu10k1_voice_half_loop_intr_disable(struct snd_emu10k1 *emu, unsigned int voicenum);
185162306a36Sopenharmony_civoid snd_emu10k1_voice_half_loop_intr_ack(struct snd_emu10k1 *emu, unsigned int voicenum);
185262306a36Sopenharmony_ci#if 0
185362306a36Sopenharmony_civoid snd_emu10k1_voice_set_loop_stop(struct snd_emu10k1 *emu, unsigned int voicenum);
185462306a36Sopenharmony_civoid snd_emu10k1_voice_clear_loop_stop(struct snd_emu10k1 *emu, unsigned int voicenum);
185562306a36Sopenharmony_ci#endif
185662306a36Sopenharmony_civoid snd_emu10k1_voice_set_loop_stop_multiple(struct snd_emu10k1 *emu, u64 voices);
185762306a36Sopenharmony_civoid snd_emu10k1_voice_clear_loop_stop_multiple(struct snd_emu10k1 *emu, u64 voices);
185862306a36Sopenharmony_ciint snd_emu10k1_voice_clear_loop_stop_multiple_atomic(struct snd_emu10k1 *emu, u64 voices);
185962306a36Sopenharmony_civoid snd_emu10k1_wait(struct snd_emu10k1 *emu, unsigned int wait);
186062306a36Sopenharmony_cistatic inline unsigned int snd_emu10k1_wc(struct snd_emu10k1 *emu) { return (inl(emu->port + WC) >> 6) & 0xfffff; }
186162306a36Sopenharmony_ciunsigned short snd_emu10k1_ac97_read(struct snd_ac97 *ac97, unsigned short reg);
186262306a36Sopenharmony_civoid snd_emu10k1_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short data);
186362306a36Sopenharmony_ci
186462306a36Sopenharmony_ci#ifdef CONFIG_PM_SLEEP
186562306a36Sopenharmony_civoid snd_emu10k1_suspend_regs(struct snd_emu10k1 *emu);
186662306a36Sopenharmony_civoid snd_emu10k1_resume_init(struct snd_emu10k1 *emu);
186762306a36Sopenharmony_civoid snd_emu10k1_resume_regs(struct snd_emu10k1 *emu);
186862306a36Sopenharmony_ciint snd_emu10k1_efx_alloc_pm_buffer(struct snd_emu10k1 *emu);
186962306a36Sopenharmony_civoid snd_emu10k1_efx_free_pm_buffer(struct snd_emu10k1 *emu);
187062306a36Sopenharmony_civoid snd_emu10k1_efx_suspend(struct snd_emu10k1 *emu);
187162306a36Sopenharmony_civoid snd_emu10k1_efx_resume(struct snd_emu10k1 *emu);
187262306a36Sopenharmony_ciint snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu);
187362306a36Sopenharmony_civoid snd_p16v_free_pm_buffer(struct snd_emu10k1 *emu);
187462306a36Sopenharmony_civoid snd_p16v_suspend(struct snd_emu10k1 *emu);
187562306a36Sopenharmony_civoid snd_p16v_resume(struct snd_emu10k1 *emu);
187662306a36Sopenharmony_ci#endif
187762306a36Sopenharmony_ci
187862306a36Sopenharmony_ci/* memory allocation */
187962306a36Sopenharmony_cistruct snd_util_memblk *snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *substream);
188062306a36Sopenharmony_ciint snd_emu10k1_free_pages(struct snd_emu10k1 *emu, struct snd_util_memblk *blk);
188162306a36Sopenharmony_ciint snd_emu10k1_alloc_pages_maybe_wider(struct snd_emu10k1 *emu, size_t size,
188262306a36Sopenharmony_ci					struct snd_dma_buffer *dmab);
188362306a36Sopenharmony_cistruct snd_util_memblk *snd_emu10k1_synth_alloc(struct snd_emu10k1 *emu, unsigned int size);
188462306a36Sopenharmony_ciint snd_emu10k1_synth_free(struct snd_emu10k1 *emu, struct snd_util_memblk *blk);
188562306a36Sopenharmony_ciint snd_emu10k1_synth_bzero(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, int offset, int size);
188662306a36Sopenharmony_ciint snd_emu10k1_synth_copy_from_user(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, int offset, const char __user *data, int size);
188762306a36Sopenharmony_ciint snd_emu10k1_memblk_map(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk);
188862306a36Sopenharmony_ci
188962306a36Sopenharmony_ci/* voice allocation */
189062306a36Sopenharmony_ciint snd_emu10k1_voice_alloc(struct snd_emu10k1 *emu, int type, int count, int channels,
189162306a36Sopenharmony_ci			    struct snd_emu10k1_pcm *epcm, struct snd_emu10k1_voice **rvoice);
189262306a36Sopenharmony_ciint snd_emu10k1_voice_free(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *pvoice);
189362306a36Sopenharmony_ci
189462306a36Sopenharmony_ci/* MIDI uart */
189562306a36Sopenharmony_ciint snd_emu10k1_midi(struct snd_emu10k1 * emu);
189662306a36Sopenharmony_ciint snd_emu10k1_audigy_midi(struct snd_emu10k1 * emu);
189762306a36Sopenharmony_ci
189862306a36Sopenharmony_ci/* proc interface */
189962306a36Sopenharmony_ciint snd_emu10k1_proc_init(struct snd_emu10k1 * emu);
190062306a36Sopenharmony_ci
190162306a36Sopenharmony_ci/* fx8010 irq handler */
190262306a36Sopenharmony_ciint snd_emu10k1_fx8010_register_irq_handler(struct snd_emu10k1 *emu,
190362306a36Sopenharmony_ci					    snd_fx8010_irq_handler_t *handler,
190462306a36Sopenharmony_ci					    unsigned char gpr_running,
190562306a36Sopenharmony_ci					    void *private_data,
190662306a36Sopenharmony_ci					    struct snd_emu10k1_fx8010_irq *irq);
190762306a36Sopenharmony_ciint snd_emu10k1_fx8010_unregister_irq_handler(struct snd_emu10k1 *emu,
190862306a36Sopenharmony_ci					      struct snd_emu10k1_fx8010_irq *irq);
190962306a36Sopenharmony_ci
191062306a36Sopenharmony_ci#endif	/* __SOUND_EMU10K1_H */
1911