181fcb170STakashi Iwai #ifndef __SOUND_TRIDENT_H 281fcb170STakashi Iwai #define __SOUND_TRIDENT_H 381fcb170STakashi Iwai 481fcb170STakashi Iwai /* 581fcb170STakashi Iwai * audio@tridentmicro.com 681fcb170STakashi Iwai * Fri Feb 19 15:55:28 MST 1999 781fcb170STakashi Iwai * Definitions for Trident 4DWave DX/NX chips 881fcb170STakashi Iwai * 981fcb170STakashi Iwai * 1081fcb170STakashi Iwai * This program is free software; you can redistribute it and/or modify 1181fcb170STakashi Iwai * it under the terms of the GNU General Public License as published by 1281fcb170STakashi Iwai * the Free Software Foundation; either version 2 of the License, or 1381fcb170STakashi Iwai * (at your option) any later version. 1481fcb170STakashi Iwai * 1581fcb170STakashi Iwai * This program is distributed in the hope that it will be useful, 1681fcb170STakashi Iwai * but WITHOUT ANY WARRANTY; without even the implied warranty of 1781fcb170STakashi Iwai * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1881fcb170STakashi Iwai * GNU General Public License for more details. 1981fcb170STakashi Iwai * 2081fcb170STakashi Iwai * You should have received a copy of the GNU General Public License 2181fcb170STakashi Iwai * along with this program; if not, write to the Free Software 2281fcb170STakashi Iwai * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 2381fcb170STakashi Iwai * 2481fcb170STakashi Iwai */ 2581fcb170STakashi Iwai 2681fcb170STakashi Iwai #include <sound/pcm.h> 2781fcb170STakashi Iwai #include <sound/mpu401.h> 2881fcb170STakashi Iwai #include <sound/ac97_codec.h> 2981fcb170STakashi Iwai #include <sound/util_mem.h> 3081fcb170STakashi Iwai 3181fcb170STakashi Iwai #define TRIDENT_DEVICE_ID_DX ((PCI_VENDOR_ID_TRIDENT<<16)|PCI_DEVICE_ID_TRIDENT_4DWAVE_DX) 3281fcb170STakashi Iwai #define TRIDENT_DEVICE_ID_NX ((PCI_VENDOR_ID_TRIDENT<<16)|PCI_DEVICE_ID_TRIDENT_4DWAVE_NX) 3381fcb170STakashi Iwai #define TRIDENT_DEVICE_ID_SI7018 ((PCI_VENDOR_ID_SI<<16)|PCI_DEVICE_ID_SI_7018) 3481fcb170STakashi Iwai 3581fcb170STakashi Iwai #define SNDRV_TRIDENT_VOICE_TYPE_PCM 0 3681fcb170STakashi Iwai #define SNDRV_TRIDENT_VOICE_TYPE_SYNTH 1 3781fcb170STakashi Iwai #define SNDRV_TRIDENT_VOICE_TYPE_MIDI 2 3881fcb170STakashi Iwai 3981fcb170STakashi Iwai #define SNDRV_TRIDENT_VFLG_RUNNING (1<<0) 4081fcb170STakashi Iwai 4181fcb170STakashi Iwai /* TLB code constants */ 4281fcb170STakashi Iwai #define SNDRV_TRIDENT_PAGE_SIZE 4096 4381fcb170STakashi Iwai #define SNDRV_TRIDENT_PAGE_SHIFT 12 4481fcb170STakashi Iwai #define SNDRV_TRIDENT_PAGE_MASK ((1<<SNDRV_TRIDENT_PAGE_SHIFT)-1) 4581fcb170STakashi Iwai #define SNDRV_TRIDENT_MAX_PAGES 4096 4681fcb170STakashi Iwai 4781fcb170STakashi Iwai /* 4881fcb170STakashi Iwai * Direct registers 4981fcb170STakashi Iwai */ 5081fcb170STakashi Iwai 5181fcb170STakashi Iwai #define TRID_REG(trident, x) ((trident)->port + (x)) 5281fcb170STakashi Iwai 5381fcb170STakashi Iwai #define ID_4DWAVE_DX 0x2000 5481fcb170STakashi Iwai #define ID_4DWAVE_NX 0x2001 5581fcb170STakashi Iwai 5681fcb170STakashi Iwai /* Bank definitions */ 5781fcb170STakashi Iwai 5881fcb170STakashi Iwai #define T4D_BANK_A 0 5981fcb170STakashi Iwai #define T4D_BANK_B 1 6081fcb170STakashi Iwai #define T4D_NUM_BANKS 2 6181fcb170STakashi Iwai 6281fcb170STakashi Iwai /* Register definitions */ 6381fcb170STakashi Iwai 6481fcb170STakashi Iwai /* Global registers */ 6581fcb170STakashi Iwai 6681fcb170STakashi Iwai enum global_control_bits { 6781fcb170STakashi Iwai CHANNEL_IDX = 0x0000003f, 6881fcb170STakashi Iwai OVERRUN_IE = 0x00000400, /* interrupt enable: capture overrun */ 6981fcb170STakashi Iwai UNDERRUN_IE = 0x00000800, /* interrupt enable: playback underrun */ 7081fcb170STakashi Iwai ENDLP_IE = 0x00001000, /* interrupt enable: end of buffer */ 7181fcb170STakashi Iwai MIDLP_IE = 0x00002000, /* interrupt enable: middle buffer */ 7281fcb170STakashi Iwai ETOG_IE = 0x00004000, /* interrupt enable: envelope toggling */ 7381fcb170STakashi Iwai EDROP_IE = 0x00008000, /* interrupt enable: envelope drop */ 7481fcb170STakashi Iwai BANK_B_EN = 0x00010000, /* SiS: enable bank B (64 channels) */ 7581fcb170STakashi Iwai PCMIN_B_MIX = 0x00020000, /* SiS: PCM IN B mixing enable */ 7681fcb170STakashi Iwai I2S_OUT_ASSIGN = 0x00040000, /* SiS: I2S Out contains surround PCM */ 7781fcb170STakashi Iwai SPDIF_OUT_ASSIGN= 0x00080000, /* SiS: 0=S/PDIF L/R | 1=PCM Out FIFO */ 7881fcb170STakashi Iwai MAIN_OUT_ASSIGN = 0x00100000, /* SiS: 0=PCM Out FIFO | 1=MMC Out buffer */ 7981fcb170STakashi Iwai }; 8081fcb170STakashi Iwai 8181fcb170STakashi Iwai enum miscint_bits { 8281fcb170STakashi Iwai PB_UNDERRUN_IRQ = 0x00000001, REC_OVERRUN_IRQ = 0x00000002, 8381fcb170STakashi Iwai SB_IRQ = 0x00000004, MPU401_IRQ = 0x00000008, 8481fcb170STakashi Iwai OPL3_IRQ = 0x00000010, ADDRESS_IRQ = 0x00000020, 8581fcb170STakashi Iwai ENVELOPE_IRQ = 0x00000040, PB_UNDERRUN = 0x00000100, 8681fcb170STakashi Iwai REC_OVERRUN = 0x00000200, MIXER_UNDERFLOW = 0x00000400, 8781fcb170STakashi Iwai MIXER_OVERFLOW = 0x00000800, NX_SB_IRQ_DISABLE = 0x00001000, 8881fcb170STakashi Iwai ST_TARGET_REACHED = 0x00008000, 8981fcb170STakashi Iwai PB_24K_MODE = 0x00010000, ST_IRQ_EN = 0x00800000, 9081fcb170STakashi Iwai ACGPIO_IRQ = 0x01000000 9181fcb170STakashi Iwai }; 9281fcb170STakashi Iwai 9381fcb170STakashi Iwai /* T2 legacy dma control registers. */ 9481fcb170STakashi Iwai #define LEGACY_DMAR0 0x00 // ADR0 9581fcb170STakashi Iwai #define LEGACY_DMAR4 0x04 // CNT0 9681fcb170STakashi Iwai #define LEGACY_DMAR6 0x06 // CNT0 - High bits 9781fcb170STakashi Iwai #define LEGACY_DMAR11 0x0b // MOD 9881fcb170STakashi Iwai #define LEGACY_DMAR15 0x0f // MMR 9981fcb170STakashi Iwai 10081fcb170STakashi Iwai #define T4D_START_A 0x80 10181fcb170STakashi Iwai #define T4D_STOP_A 0x84 10281fcb170STakashi Iwai #define T4D_DLY_A 0x88 10381fcb170STakashi Iwai #define T4D_SIGN_CSO_A 0x8c 10481fcb170STakashi Iwai #define T4D_CSPF_A 0x90 10581fcb170STakashi Iwai #define T4D_CSPF_B 0xbc 10681fcb170STakashi Iwai #define T4D_CEBC_A 0x94 10781fcb170STakashi Iwai #define T4D_AINT_A 0x98 10881fcb170STakashi Iwai #define T4D_AINTEN_A 0x9c 10981fcb170STakashi Iwai #define T4D_LFO_GC_CIR 0xa0 11081fcb170STakashi Iwai #define T4D_MUSICVOL_WAVEVOL 0xa8 11181fcb170STakashi Iwai #define T4D_SBDELTA_DELTA_R 0xac 11281fcb170STakashi Iwai #define T4D_MISCINT 0xb0 11381fcb170STakashi Iwai #define T4D_START_B 0xb4 11481fcb170STakashi Iwai #define T4D_STOP_B 0xb8 11581fcb170STakashi Iwai #define T4D_SBBL_SBCL 0xc0 11681fcb170STakashi Iwai #define T4D_SBCTRL_SBE2R_SBDD 0xc4 11781fcb170STakashi Iwai #define T4D_STIMER 0xc8 11881fcb170STakashi Iwai #define T4D_AINT_B 0xd8 11981fcb170STakashi Iwai #define T4D_AINTEN_B 0xdc 12081fcb170STakashi Iwai #define T4D_RCI 0x70 12181fcb170STakashi Iwai 12281fcb170STakashi Iwai /* MPU-401 UART */ 12381fcb170STakashi Iwai #define T4D_MPU401_BASE 0x20 12481fcb170STakashi Iwai #define T4D_MPUR0 0x20 12581fcb170STakashi Iwai #define T4D_MPUR1 0x21 12681fcb170STakashi Iwai #define T4D_MPUR2 0x22 12781fcb170STakashi Iwai #define T4D_MPUR3 0x23 12881fcb170STakashi Iwai 12981fcb170STakashi Iwai /* S/PDIF Registers */ 13081fcb170STakashi Iwai #define NX_SPCTRL_SPCSO 0x24 13181fcb170STakashi Iwai #define NX_SPLBA 0x28 13281fcb170STakashi Iwai #define NX_SPESO 0x2c 13381fcb170STakashi Iwai #define NX_SPCSTATUS 0x64 13481fcb170STakashi Iwai 13581fcb170STakashi Iwai /* Joystick */ 13681fcb170STakashi Iwai #define GAMEPORT_GCR 0x30 13781fcb170STakashi Iwai #define GAMEPORT_MODE_ADC 0x80 13881fcb170STakashi Iwai #define GAMEPORT_LEGACY 0x31 13981fcb170STakashi Iwai #define GAMEPORT_AXES 0x34 14081fcb170STakashi Iwai 14181fcb170STakashi Iwai /* NX Specific Registers */ 14281fcb170STakashi Iwai #define NX_TLBC 0x6c 14381fcb170STakashi Iwai 14481fcb170STakashi Iwai /* Channel Registers */ 14581fcb170STakashi Iwai 14681fcb170STakashi Iwai #define CH_START 0xe0 14781fcb170STakashi Iwai 14881fcb170STakashi Iwai #define CH_DX_CSO_ALPHA_FMS 0xe0 14981fcb170STakashi Iwai #define CH_DX_ESO_DELTA 0xe8 15081fcb170STakashi Iwai #define CH_DX_FMC_RVOL_CVOL 0xec 15181fcb170STakashi Iwai 15281fcb170STakashi Iwai #define CH_NX_DELTA_CSO 0xe0 15381fcb170STakashi Iwai #define CH_NX_DELTA_ESO 0xe8 15481fcb170STakashi Iwai #define CH_NX_ALPHA_FMS_FMC_RVOL_CVOL 0xec 15581fcb170STakashi Iwai 15681fcb170STakashi Iwai #define CH_LBA 0xe4 15781fcb170STakashi Iwai #define CH_GVSEL_PAN_VOL_CTRL_EC 0xf0 15881fcb170STakashi Iwai #define CH_EBUF1 0xf4 15981fcb170STakashi Iwai #define CH_EBUF2 0xf8 16081fcb170STakashi Iwai 16181fcb170STakashi Iwai /* AC-97 Registers */ 16281fcb170STakashi Iwai 16381fcb170STakashi Iwai #define DX_ACR0_AC97_W 0x40 16481fcb170STakashi Iwai #define DX_ACR1_AC97_R 0x44 16581fcb170STakashi Iwai #define DX_ACR2_AC97_COM_STAT 0x48 16681fcb170STakashi Iwai 16781fcb170STakashi Iwai #define NX_ACR0_AC97_COM_STAT 0x40 16881fcb170STakashi Iwai #define NX_ACR1_AC97_W 0x44 16981fcb170STakashi Iwai #define NX_ACR2_AC97_R_PRIMARY 0x48 17081fcb170STakashi Iwai #define NX_ACR3_AC97_R_SECONDARY 0x4c 17181fcb170STakashi Iwai 17281fcb170STakashi Iwai #define SI_AC97_WRITE 0x40 17381fcb170STakashi Iwai #define SI_AC97_READ 0x44 17481fcb170STakashi Iwai #define SI_SERIAL_INTF_CTRL 0x48 17581fcb170STakashi Iwai #define SI_AC97_GPIO 0x4c 17681fcb170STakashi Iwai #define SI_ASR0 0x50 17781fcb170STakashi Iwai #define SI_SPDIF_CS 0x70 17881fcb170STakashi Iwai #define SI_GPIO 0x7c 17981fcb170STakashi Iwai 18081fcb170STakashi Iwai enum trident_nx_ac97_bits { 18181fcb170STakashi Iwai /* ACR1-3 */ 18281fcb170STakashi Iwai NX_AC97_BUSY_WRITE = 0x0800, 18381fcb170STakashi Iwai NX_AC97_BUSY_READ = 0x0800, 18481fcb170STakashi Iwai NX_AC97_BUSY_DATA = 0x0400, 18581fcb170STakashi Iwai NX_AC97_WRITE_SECONDARY = 0x0100, 18681fcb170STakashi Iwai /* ACR0 */ 18781fcb170STakashi Iwai NX_AC97_SECONDARY_READY = 0x0040, 18881fcb170STakashi Iwai NX_AC97_SECONDARY_RECORD = 0x0020, 18981fcb170STakashi Iwai NX_AC97_SURROUND_OUTPUT = 0x0010, 19081fcb170STakashi Iwai NX_AC97_PRIMARY_READY = 0x0008, 19181fcb170STakashi Iwai NX_AC97_PRIMARY_RECORD = 0x0004, 19281fcb170STakashi Iwai NX_AC97_PCM_OUTPUT = 0x0002, 19381fcb170STakashi Iwai NX_AC97_WARM_RESET = 0x0001 19481fcb170STakashi Iwai }; 19581fcb170STakashi Iwai 19681fcb170STakashi Iwai enum trident_dx_ac97_bits { 19781fcb170STakashi Iwai DX_AC97_BUSY_WRITE = 0x8000, 19881fcb170STakashi Iwai DX_AC97_BUSY_READ = 0x8000, 19981fcb170STakashi Iwai DX_AC97_READY = 0x0010, 20081fcb170STakashi Iwai DX_AC97_RECORD = 0x0008, 20181fcb170STakashi Iwai DX_AC97_PLAYBACK = 0x0002 20281fcb170STakashi Iwai }; 20381fcb170STakashi Iwai 20481fcb170STakashi Iwai enum sis7018_ac97_bits { 20581fcb170STakashi Iwai SI_AC97_BUSY_WRITE = 0x00008000, 20681fcb170STakashi Iwai SI_AC97_AUDIO_BUSY = 0x00004000, 20781fcb170STakashi Iwai SI_AC97_MODEM_BUSY = 0x00002000, 20881fcb170STakashi Iwai SI_AC97_BUSY_READ = 0x00008000, 20981fcb170STakashi Iwai SI_AC97_SECONDARY = 0x00000080, 21081fcb170STakashi Iwai }; 21181fcb170STakashi Iwai 21281fcb170STakashi Iwai enum serial_intf_ctrl_bits { 21381fcb170STakashi Iwai WARM_RESET = 0x00000001, 21481fcb170STakashi Iwai COLD_RESET = 0x00000002, 21581fcb170STakashi Iwai I2S_CLOCK = 0x00000004, 21681fcb170STakashi Iwai PCM_SEC_AC97 = 0x00000008, 21781fcb170STakashi Iwai AC97_DBL_RATE = 0x00000010, 21881fcb170STakashi Iwai SPDIF_EN = 0x00000020, 21981fcb170STakashi Iwai I2S_OUTPUT_EN = 0x00000040, 22081fcb170STakashi Iwai I2S_INPUT_EN = 0x00000080, 22181fcb170STakashi Iwai PCMIN = 0x00000100, 22281fcb170STakashi Iwai LINE1IN = 0x00000200, 22381fcb170STakashi Iwai MICIN = 0x00000400, 22481fcb170STakashi Iwai LINE2IN = 0x00000800, 22581fcb170STakashi Iwai HEAD_SET_IN = 0x00001000, 22681fcb170STakashi Iwai GPIOIN = 0x00002000, 22781fcb170STakashi Iwai /* 7018 spec says id = 01 but the demo board routed to 10 22881fcb170STakashi Iwai SECONDARY_ID= 0x00004000, */ 22981fcb170STakashi Iwai SECONDARY_ID = 0x00004000, 23081fcb170STakashi Iwai PCMOUT = 0x00010000, 23181fcb170STakashi Iwai SURROUT = 0x00020000, 23281fcb170STakashi Iwai CENTEROUT = 0x00040000, 23381fcb170STakashi Iwai LFEOUT = 0x00080000, 23481fcb170STakashi Iwai LINE1OUT = 0x00100000, 23581fcb170STakashi Iwai LINE2OUT = 0x00200000, 23681fcb170STakashi Iwai GPIOOUT = 0x00400000, 23781fcb170STakashi Iwai SI_AC97_PRIMARY_READY = 0x01000000, 23881fcb170STakashi Iwai SI_AC97_SECONDARY_READY = 0x02000000, 23981fcb170STakashi Iwai SI_AC97_POWERDOWN = 0x04000000, 24081fcb170STakashi Iwai }; 24181fcb170STakashi Iwai 24281fcb170STakashi Iwai /* PCM defaults */ 24381fcb170STakashi Iwai 24481fcb170STakashi Iwai #define T4D_DEFAULT_PCM_VOL 10 /* 0 - 255 */ 24581fcb170STakashi Iwai #define T4D_DEFAULT_PCM_PAN 0 /* 0 - 127 */ 24681fcb170STakashi Iwai #define T4D_DEFAULT_PCM_RVOL 127 /* 0 - 127 */ 24781fcb170STakashi Iwai #define T4D_DEFAULT_PCM_CVOL 127 /* 0 - 127 */ 24881fcb170STakashi Iwai 24981fcb170STakashi Iwai struct snd_trident; 25081fcb170STakashi Iwai struct snd_trident_voice; 25181fcb170STakashi Iwai struct snd_trident_pcm_mixer; 25281fcb170STakashi Iwai 25381fcb170STakashi Iwai struct snd_trident_port { 25481fcb170STakashi Iwai struct snd_midi_channel_set * chset; 25581fcb170STakashi Iwai struct snd_trident * trident; 25681fcb170STakashi Iwai int mode; /* operation mode */ 25781fcb170STakashi Iwai int client; /* sequencer client number */ 25881fcb170STakashi Iwai int port; /* sequencer port number */ 25981fcb170STakashi Iwai unsigned int midi_has_voices: 1; 26081fcb170STakashi Iwai }; 26181fcb170STakashi Iwai 26281fcb170STakashi Iwai struct snd_trident_memblk_arg { 26381fcb170STakashi Iwai short first_page, last_page; 26481fcb170STakashi Iwai }; 26581fcb170STakashi Iwai 26681fcb170STakashi Iwai struct snd_trident_tlb { 26781fcb170STakashi Iwai unsigned int * entries; /* 16k-aligned TLB table */ 26881fcb170STakashi Iwai dma_addr_t entries_dmaaddr; /* 16k-aligned PCI address to TLB table */ 26981fcb170STakashi Iwai unsigned long * shadow_entries; /* shadow entries with virtual addresses */ 27081fcb170STakashi Iwai struct snd_dma_buffer buffer; 27181fcb170STakashi Iwai struct snd_util_memhdr * memhdr; /* page allocation list */ 27281fcb170STakashi Iwai struct snd_dma_buffer silent_page; 27381fcb170STakashi Iwai }; 27481fcb170STakashi Iwai 27581fcb170STakashi Iwai struct snd_trident_voice { 27681fcb170STakashi Iwai unsigned int number; 27781fcb170STakashi Iwai unsigned int use: 1, 27881fcb170STakashi Iwai pcm: 1, 27981fcb170STakashi Iwai synth:1, 28081fcb170STakashi Iwai midi: 1; 28181fcb170STakashi Iwai unsigned int flags; 28281fcb170STakashi Iwai unsigned char client; 28381fcb170STakashi Iwai unsigned char port; 28481fcb170STakashi Iwai unsigned char index; 28581fcb170STakashi Iwai 28681fcb170STakashi Iwai struct snd_trident_sample_ops *sample_ops; 28781fcb170STakashi Iwai 28881fcb170STakashi Iwai /* channel parameters */ 28981fcb170STakashi Iwai unsigned int CSO; /* 24 bits (16 on DX) */ 29081fcb170STakashi Iwai unsigned int ESO; /* 24 bits (16 on DX) */ 29181fcb170STakashi Iwai unsigned int LBA; /* 30 bits */ 29281fcb170STakashi Iwai unsigned short EC; /* 12 bits */ 29381fcb170STakashi Iwai unsigned short Alpha; /* 12 bits */ 29481fcb170STakashi Iwai unsigned short Delta; /* 16 bits */ 29581fcb170STakashi Iwai unsigned short Attribute; /* 16 bits - SiS 7018 */ 29681fcb170STakashi Iwai unsigned short Vol; /* 12 bits (6.6) */ 29781fcb170STakashi Iwai unsigned char Pan; /* 7 bits (1.4.2) */ 29881fcb170STakashi Iwai unsigned char GVSel; /* 1 bit */ 29981fcb170STakashi Iwai unsigned char RVol; /* 7 bits (5.2) */ 30081fcb170STakashi Iwai unsigned char CVol; /* 7 bits (5.2) */ 30181fcb170STakashi Iwai unsigned char FMC; /* 2 bits */ 30281fcb170STakashi Iwai unsigned char CTRL; /* 4 bits */ 30381fcb170STakashi Iwai unsigned char FMS; /* 4 bits */ 30481fcb170STakashi Iwai unsigned char LFO; /* 8 bits */ 30581fcb170STakashi Iwai 30681fcb170STakashi Iwai unsigned int negCSO; /* nonzero - use negative CSO */ 30781fcb170STakashi Iwai 30881fcb170STakashi Iwai struct snd_util_memblk *memblk; /* memory block if TLB enabled */ 30981fcb170STakashi Iwai 31081fcb170STakashi Iwai /* PCM data */ 31181fcb170STakashi Iwai 31281fcb170STakashi Iwai struct snd_trident *trident; 31381fcb170STakashi Iwai struct snd_pcm_substream *substream; 31481fcb170STakashi Iwai struct snd_trident_voice *extra; /* extra PCM voice (acts as interrupt generator) */ 31581fcb170STakashi Iwai unsigned int running: 1, 31681fcb170STakashi Iwai capture: 1, 31781fcb170STakashi Iwai spdif: 1, 31881fcb170STakashi Iwai foldback: 1, 31981fcb170STakashi Iwai isync: 1, 32081fcb170STakashi Iwai isync2: 1, 32181fcb170STakashi Iwai isync3: 1; 32281fcb170STakashi Iwai int foldback_chan; /* foldback subdevice number */ 32381fcb170STakashi Iwai unsigned int stimer; /* global sample timer (to detect spurious interrupts) */ 32481fcb170STakashi Iwai unsigned int spurious_threshold; /* spurious threshold */ 32581fcb170STakashi Iwai unsigned int isync_mark; 32681fcb170STakashi Iwai unsigned int isync_max; 32781fcb170STakashi Iwai unsigned int isync_ESO; 32881fcb170STakashi Iwai 32981fcb170STakashi Iwai /* --- */ 33081fcb170STakashi Iwai 33181fcb170STakashi Iwai void *private_data; 33281fcb170STakashi Iwai void (*private_free)(struct snd_trident_voice *voice); 33381fcb170STakashi Iwai }; 33481fcb170STakashi Iwai 33581fcb170STakashi Iwai struct snd_4dwave { 33681fcb170STakashi Iwai int seq_client; 33781fcb170STakashi Iwai 33881fcb170STakashi Iwai struct snd_trident_port seq_ports[4]; 33981fcb170STakashi Iwai struct snd_trident_voice voices[64]; 34081fcb170STakashi Iwai 34181fcb170STakashi Iwai int ChanSynthCount; /* number of allocated synth channels */ 34281fcb170STakashi Iwai int max_size; /* maximum synth memory size in bytes */ 34381fcb170STakashi Iwai int current_size; /* current allocated synth mem in bytes */ 34481fcb170STakashi Iwai }; 34581fcb170STakashi Iwai 34681fcb170STakashi Iwai struct snd_trident_pcm_mixer { 34781fcb170STakashi Iwai struct snd_trident_voice *voice; /* active voice */ 34881fcb170STakashi Iwai unsigned short vol; /* front volume */ 34981fcb170STakashi Iwai unsigned char pan; /* pan control */ 35081fcb170STakashi Iwai unsigned char rvol; /* rear volume */ 35181fcb170STakashi Iwai unsigned char cvol; /* center volume */ 35281fcb170STakashi Iwai unsigned char pad; 35381fcb170STakashi Iwai }; 35481fcb170STakashi Iwai 35581fcb170STakashi Iwai struct snd_trident { 35681fcb170STakashi Iwai int irq; 35781fcb170STakashi Iwai 35881fcb170STakashi Iwai unsigned int device; /* device ID */ 35981fcb170STakashi Iwai 36081fcb170STakashi Iwai unsigned char bDMAStart; 36181fcb170STakashi Iwai 36281fcb170STakashi Iwai unsigned long port; 36381fcb170STakashi Iwai unsigned long midi_port; 36481fcb170STakashi Iwai 36581fcb170STakashi Iwai unsigned int spurious_irq_count; 36681fcb170STakashi Iwai unsigned int spurious_irq_max_delta; 36781fcb170STakashi Iwai 36881fcb170STakashi Iwai struct snd_trident_tlb tlb; /* TLB entries for NX cards */ 36981fcb170STakashi Iwai 37081fcb170STakashi Iwai unsigned char spdif_ctrl; 37181fcb170STakashi Iwai unsigned char spdif_pcm_ctrl; 37281fcb170STakashi Iwai unsigned int spdif_bits; 37381fcb170STakashi Iwai unsigned int spdif_pcm_bits; 37481fcb170STakashi Iwai struct snd_kcontrol *spdif_pcm_ctl; /* S/PDIF settings */ 37581fcb170STakashi Iwai unsigned int ac97_ctrl; 37681fcb170STakashi Iwai 37781fcb170STakashi Iwai unsigned int ChanMap[2]; /* allocation map for hardware channels */ 37881fcb170STakashi Iwai 37981fcb170STakashi Iwai int ChanPCM; /* max number of PCM channels */ 38081fcb170STakashi Iwai int ChanPCMcnt; /* actual number of PCM channels */ 38181fcb170STakashi Iwai 38281fcb170STakashi Iwai unsigned int ac97_detect: 1; /* 1 = AC97 in detection phase */ 38381fcb170STakashi Iwai unsigned int in_suspend: 1; /* 1 during suspend/resume */ 38481fcb170STakashi Iwai 38581fcb170STakashi Iwai struct snd_4dwave synth; /* synth specific variables */ 38681fcb170STakashi Iwai 38781fcb170STakashi Iwai spinlock_t event_lock; 38881fcb170STakashi Iwai spinlock_t voice_alloc; 38981fcb170STakashi Iwai 39081fcb170STakashi Iwai struct snd_dma_device dma_dev; 39181fcb170STakashi Iwai 39281fcb170STakashi Iwai struct pci_dev *pci; 39381fcb170STakashi Iwai struct snd_card *card; 39481fcb170STakashi Iwai struct snd_pcm *pcm; /* ADC/DAC PCM */ 39581fcb170STakashi Iwai struct snd_pcm *foldback; /* Foldback PCM */ 39681fcb170STakashi Iwai struct snd_pcm *spdif; /* SPDIF PCM */ 39781fcb170STakashi Iwai struct snd_rawmidi *rmidi; 39881fcb170STakashi Iwai 39981fcb170STakashi Iwai struct snd_ac97_bus *ac97_bus; 40081fcb170STakashi Iwai struct snd_ac97 *ac97; 40181fcb170STakashi Iwai struct snd_ac97 *ac97_sec; 40281fcb170STakashi Iwai 40381fcb170STakashi Iwai unsigned int musicvol_wavevol; 40481fcb170STakashi Iwai struct snd_trident_pcm_mixer pcm_mixer[32]; 40581fcb170STakashi Iwai struct snd_kcontrol *ctl_vol; /* front volume */ 40681fcb170STakashi Iwai struct snd_kcontrol *ctl_pan; /* pan */ 40781fcb170STakashi Iwai struct snd_kcontrol *ctl_rvol; /* rear volume */ 40881fcb170STakashi Iwai struct snd_kcontrol *ctl_cvol; /* center volume */ 40981fcb170STakashi Iwai 41081fcb170STakashi Iwai spinlock_t reg_lock; 41181fcb170STakashi Iwai 41281fcb170STakashi Iwai struct gameport *gameport; 41381fcb170STakashi Iwai }; 41481fcb170STakashi Iwai 41581fcb170STakashi Iwai int snd_trident_create(struct snd_card *card, 41681fcb170STakashi Iwai struct pci_dev *pci, 41781fcb170STakashi Iwai int pcm_streams, 41881fcb170STakashi Iwai int pcm_spdif_device, 41981fcb170STakashi Iwai int max_wavetable_size, 42081fcb170STakashi Iwai struct snd_trident ** rtrident); 42181fcb170STakashi Iwai int snd_trident_create_gameport(struct snd_trident *trident); 42281fcb170STakashi Iwai 423*1b16416fSLars-Peter Clausen int snd_trident_pcm(struct snd_trident *trident, int device); 424*1b16416fSLars-Peter Clausen int snd_trident_foldback_pcm(struct snd_trident *trident, int device); 425*1b16416fSLars-Peter Clausen int snd_trident_spdif_pcm(struct snd_trident *trident, int device); 42681fcb170STakashi Iwai int snd_trident_attach_synthesizer(struct snd_trident * trident); 42781fcb170STakashi Iwai struct snd_trident_voice *snd_trident_alloc_voice(struct snd_trident * trident, int type, 42881fcb170STakashi Iwai int client, int port); 42981fcb170STakashi Iwai void snd_trident_free_voice(struct snd_trident * trident, struct snd_trident_voice *voice); 43081fcb170STakashi Iwai void snd_trident_start_voice(struct snd_trident * trident, unsigned int voice); 43181fcb170STakashi Iwai void snd_trident_stop_voice(struct snd_trident * trident, unsigned int voice); 43281fcb170STakashi Iwai void snd_trident_write_voice_regs(struct snd_trident * trident, struct snd_trident_voice *voice); 43381fcb170STakashi Iwai extern const struct dev_pm_ops snd_trident_pm; 43481fcb170STakashi Iwai 43581fcb170STakashi Iwai /* TLB memory allocation */ 43681fcb170STakashi Iwai struct snd_util_memblk *snd_trident_alloc_pages(struct snd_trident *trident, 43781fcb170STakashi Iwai struct snd_pcm_substream *substream); 43881fcb170STakashi Iwai int snd_trident_free_pages(struct snd_trident *trident, struct snd_util_memblk *blk); 43981fcb170STakashi Iwai struct snd_util_memblk *snd_trident_synth_alloc(struct snd_trident *trident, unsigned int size); 44081fcb170STakashi Iwai int snd_trident_synth_free(struct snd_trident *trident, struct snd_util_memblk *blk); 44181fcb170STakashi Iwai int snd_trident_synth_copy_from_user(struct snd_trident *trident, struct snd_util_memblk *blk, 44281fcb170STakashi Iwai int offset, const char __user *data, int size); 44381fcb170STakashi Iwai 44481fcb170STakashi Iwai #endif /* __SOUND_TRIDENT_H */ 445