1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun #ifndef __SOUND_ICE1712_H
3*4882a593Smuzhiyun #define __SOUND_ICE1712_H
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun /*
6*4882a593Smuzhiyun * ALSA driver for ICEnsemble ICE1712 (Envy24)
7*4882a593Smuzhiyun *
8*4882a593Smuzhiyun * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
9*4882a593Smuzhiyun */
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun #include <linux/io.h>
12*4882a593Smuzhiyun #include <sound/control.h>
13*4882a593Smuzhiyun #include <sound/ac97_codec.h>
14*4882a593Smuzhiyun #include <sound/rawmidi.h>
15*4882a593Smuzhiyun #include <sound/i2c.h>
16*4882a593Smuzhiyun #include <sound/ak4xxx-adda.h>
17*4882a593Smuzhiyun #include <sound/ak4114.h>
18*4882a593Smuzhiyun #include <sound/pt2258.h>
19*4882a593Smuzhiyun #include <sound/pcm.h>
20*4882a593Smuzhiyun #include <sound/mpu401.h>
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun /*
24*4882a593Smuzhiyun * Direct registers
25*4882a593Smuzhiyun */
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun #define ICEREG(ice, x) ((ice)->port + ICE1712_REG_##x)
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun #define ICE1712_REG_CONTROL 0x00 /* byte */
30*4882a593Smuzhiyun #define ICE1712_RESET 0x80 /* soft reset whole chip */
31*4882a593Smuzhiyun #define ICE1712_SERR_ASSERT_DS_DMA 0x40 /* disabled SERR# assertion for the DS DMA Ch-C irq otherwise enabled */
32*4882a593Smuzhiyun #define ICE1712_DOS_VOL 0x10 /* DOS WT/FM volume control */
33*4882a593Smuzhiyun #define ICE1712_SERR_LEVEL 0x08 /* SERR# level otherwise edge */
34*4882a593Smuzhiyun #define ICE1712_SERR_ASSERT_SB 0x02 /* disabled SERR# assertion for SB irq otherwise enabled */
35*4882a593Smuzhiyun #define ICE1712_NATIVE 0x01 /* native mode otherwise SB */
36*4882a593Smuzhiyun #define ICE1712_REG_IRQMASK 0x01 /* byte */
37*4882a593Smuzhiyun #define ICE1712_IRQ_MPU1 0x80 /* MIDI irq mask */
38*4882a593Smuzhiyun #define ICE1712_IRQ_TIMER 0x40 /* Timer mask */
39*4882a593Smuzhiyun #define ICE1712_IRQ_MPU2 0x20 /* Secondary MIDI irq mask */
40*4882a593Smuzhiyun #define ICE1712_IRQ_PROPCM 0x10 /* professional multi-track */
41*4882a593Smuzhiyun #define ICE1712_IRQ_FM 0x08 /* FM/MIDI - legacy */
42*4882a593Smuzhiyun #define ICE1712_IRQ_PBKDS 0x04 /* playback DS channels */
43*4882a593Smuzhiyun #define ICE1712_IRQ_CONCAP 0x02 /* consumer capture */
44*4882a593Smuzhiyun #define ICE1712_IRQ_CONPBK 0x01 /* consumer playback */
45*4882a593Smuzhiyun #define ICE1712_REG_IRQSTAT 0x02 /* byte */
46*4882a593Smuzhiyun /* look to ICE1712_IRQ_* */
47*4882a593Smuzhiyun #define ICE1712_REG_INDEX 0x03 /* byte - indirect CCIxx regs */
48*4882a593Smuzhiyun #define ICE1712_REG_DATA 0x04 /* byte - indirect CCIxx regs */
49*4882a593Smuzhiyun #define ICE1712_REG_NMI_STAT1 0x05 /* byte */
50*4882a593Smuzhiyun #define ICE1712_REG_NMI_DATA 0x06 /* byte */
51*4882a593Smuzhiyun #define ICE1712_REG_NMI_INDEX 0x07 /* byte */
52*4882a593Smuzhiyun #define ICE1712_REG_AC97_INDEX 0x08 /* byte */
53*4882a593Smuzhiyun #define ICE1712_REG_AC97_CMD 0x09 /* byte */
54*4882a593Smuzhiyun #define ICE1712_AC97_COLD 0x80 /* cold reset */
55*4882a593Smuzhiyun #define ICE1712_AC97_WARM 0x40 /* warm reset */
56*4882a593Smuzhiyun #define ICE1712_AC97_WRITE 0x20 /* W: write, R: write in progress */
57*4882a593Smuzhiyun #define ICE1712_AC97_READ 0x10 /* W: read, R: read in progress */
58*4882a593Smuzhiyun #define ICE1712_AC97_READY 0x08 /* codec ready status bit */
59*4882a593Smuzhiyun #define ICE1712_AC97_PBK_VSR 0x02 /* playback VSR */
60*4882a593Smuzhiyun #define ICE1712_AC97_CAP_VSR 0x01 /* capture VSR */
61*4882a593Smuzhiyun #define ICE1712_REG_AC97_DATA 0x0a /* word (little endian) */
62*4882a593Smuzhiyun #define ICE1712_REG_MPU1_CTRL 0x0c /* byte */
63*4882a593Smuzhiyun #define ICE1712_REG_MPU1_DATA 0x0d /* byte */
64*4882a593Smuzhiyun #define ICE1712_REG_I2C_DEV_ADDR 0x10 /* byte */
65*4882a593Smuzhiyun #define ICE1712_I2C_WRITE 0x01 /* write direction */
66*4882a593Smuzhiyun #define ICE1712_REG_I2C_BYTE_ADDR 0x11 /* byte */
67*4882a593Smuzhiyun #define ICE1712_REG_I2C_DATA 0x12 /* byte */
68*4882a593Smuzhiyun #define ICE1712_REG_I2C_CTRL 0x13 /* byte */
69*4882a593Smuzhiyun #define ICE1712_I2C_EEPROM 0x80 /* EEPROM exists */
70*4882a593Smuzhiyun #define ICE1712_I2C_BUSY 0x01 /* busy bit */
71*4882a593Smuzhiyun #define ICE1712_REG_CONCAP_ADDR 0x14 /* dword - consumer capture */
72*4882a593Smuzhiyun #define ICE1712_REG_CONCAP_COUNT 0x18 /* word - current/base count */
73*4882a593Smuzhiyun #define ICE1712_REG_SERR_SHADOW 0x1b /* byte */
74*4882a593Smuzhiyun #define ICE1712_REG_MPU2_CTRL 0x1c /* byte */
75*4882a593Smuzhiyun #define ICE1712_REG_MPU2_DATA 0x1d /* byte */
76*4882a593Smuzhiyun #define ICE1712_REG_TIMER 0x1e /* word */
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun /*
79*4882a593Smuzhiyun * Indirect registers
80*4882a593Smuzhiyun */
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun #define ICE1712_IREG_PBK_COUNT_LO 0x00
83*4882a593Smuzhiyun #define ICE1712_IREG_PBK_COUNT_HI 0x01
84*4882a593Smuzhiyun #define ICE1712_IREG_PBK_CTRL 0x02
85*4882a593Smuzhiyun #define ICE1712_IREG_PBK_LEFT 0x03 /* left volume */
86*4882a593Smuzhiyun #define ICE1712_IREG_PBK_RIGHT 0x04 /* right volume */
87*4882a593Smuzhiyun #define ICE1712_IREG_PBK_SOFT 0x05 /* soft volume */
88*4882a593Smuzhiyun #define ICE1712_IREG_PBK_RATE_LO 0x06
89*4882a593Smuzhiyun #define ICE1712_IREG_PBK_RATE_MID 0x07
90*4882a593Smuzhiyun #define ICE1712_IREG_PBK_RATE_HI 0x08
91*4882a593Smuzhiyun #define ICE1712_IREG_CAP_COUNT_LO 0x10
92*4882a593Smuzhiyun #define ICE1712_IREG_CAP_COUNT_HI 0x11
93*4882a593Smuzhiyun #define ICE1712_IREG_CAP_CTRL 0x12
94*4882a593Smuzhiyun #define ICE1712_IREG_GPIO_DATA 0x20
95*4882a593Smuzhiyun #define ICE1712_IREG_GPIO_WRITE_MASK 0x21
96*4882a593Smuzhiyun #define ICE1712_IREG_GPIO_DIRECTION 0x22
97*4882a593Smuzhiyun #define ICE1712_IREG_CONSUMER_POWERDOWN 0x30
98*4882a593Smuzhiyun #define ICE1712_IREG_PRO_POWERDOWN 0x31
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun /*
101*4882a593Smuzhiyun * Consumer section direct DMA registers
102*4882a593Smuzhiyun */
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun #define ICEDS(ice, x) ((ice)->dmapath_port + ICE1712_DS_##x)
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun #define ICE1712_DS_INTMASK 0x00 /* word - interrupt mask */
107*4882a593Smuzhiyun #define ICE1712_DS_INTSTAT 0x02 /* word - interrupt status */
108*4882a593Smuzhiyun #define ICE1712_DS_DATA 0x04 /* dword - channel data */
109*4882a593Smuzhiyun #define ICE1712_DS_INDEX 0x08 /* dword - channel index */
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun /*
112*4882a593Smuzhiyun * Consumer section channel registers
113*4882a593Smuzhiyun */
114*4882a593Smuzhiyun
115*4882a593Smuzhiyun #define ICE1712_DSC_ADDR0 0x00 /* dword - base address 0 */
116*4882a593Smuzhiyun #define ICE1712_DSC_COUNT0 0x01 /* word - count 0 */
117*4882a593Smuzhiyun #define ICE1712_DSC_ADDR1 0x02 /* dword - base address 1 */
118*4882a593Smuzhiyun #define ICE1712_DSC_COUNT1 0x03 /* word - count 1 */
119*4882a593Smuzhiyun #define ICE1712_DSC_CONTROL 0x04 /* byte - control & status */
120*4882a593Smuzhiyun #define ICE1712_BUFFER1 0x80 /* buffer1 is active */
121*4882a593Smuzhiyun #define ICE1712_BUFFER1_AUTO 0x40 /* buffer1 auto init */
122*4882a593Smuzhiyun #define ICE1712_BUFFER0_AUTO 0x20 /* buffer0 auto init */
123*4882a593Smuzhiyun #define ICE1712_FLUSH 0x10 /* flush FIFO */
124*4882a593Smuzhiyun #define ICE1712_STEREO 0x08 /* stereo */
125*4882a593Smuzhiyun #define ICE1712_16BIT 0x04 /* 16-bit data */
126*4882a593Smuzhiyun #define ICE1712_PAUSE 0x02 /* pause */
127*4882a593Smuzhiyun #define ICE1712_START 0x01 /* start */
128*4882a593Smuzhiyun #define ICE1712_DSC_RATE 0x05 /* dword - rate */
129*4882a593Smuzhiyun #define ICE1712_DSC_VOLUME 0x06 /* word - volume control */
130*4882a593Smuzhiyun
131*4882a593Smuzhiyun /*
132*4882a593Smuzhiyun * Professional multi-track direct control registers
133*4882a593Smuzhiyun */
134*4882a593Smuzhiyun
135*4882a593Smuzhiyun #define ICEMT(ice, x) ((ice)->profi_port + ICE1712_MT_##x)
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun #define ICE1712_MT_IRQ 0x00 /* byte - interrupt mask */
138*4882a593Smuzhiyun #define ICE1712_MULTI_CAPTURE 0x80 /* capture IRQ */
139*4882a593Smuzhiyun #define ICE1712_MULTI_PLAYBACK 0x40 /* playback IRQ */
140*4882a593Smuzhiyun #define ICE1712_MULTI_CAPSTATUS 0x02 /* capture IRQ status */
141*4882a593Smuzhiyun #define ICE1712_MULTI_PBKSTATUS 0x01 /* playback IRQ status */
142*4882a593Smuzhiyun #define ICE1712_MT_RATE 0x01 /* byte - sampling rate select */
143*4882a593Smuzhiyun #define ICE1712_SPDIF_MASTER 0x10 /* S/PDIF input is master clock */
144*4882a593Smuzhiyun #define ICE1712_MT_I2S_FORMAT 0x02 /* byte - I2S data format */
145*4882a593Smuzhiyun #define ICE1712_MT_AC97_INDEX 0x04 /* byte - AC'97 index */
146*4882a593Smuzhiyun #define ICE1712_MT_AC97_CMD 0x05 /* byte - AC'97 command & status */
147*4882a593Smuzhiyun /* look to ICE1712_AC97_* */
148*4882a593Smuzhiyun #define ICE1712_MT_AC97_DATA 0x06 /* word - AC'97 data */
149*4882a593Smuzhiyun #define ICE1712_MT_PLAYBACK_ADDR 0x10 /* dword - playback address */
150*4882a593Smuzhiyun #define ICE1712_MT_PLAYBACK_SIZE 0x14 /* word - playback size */
151*4882a593Smuzhiyun #define ICE1712_MT_PLAYBACK_COUNT 0x16 /* word - playback count */
152*4882a593Smuzhiyun #define ICE1712_MT_PLAYBACK_CONTROL 0x18 /* byte - control */
153*4882a593Smuzhiyun #define ICE1712_CAPTURE_START_SHADOW 0x04 /* capture start */
154*4882a593Smuzhiyun #define ICE1712_PLAYBACK_PAUSE 0x02 /* playback pause */
155*4882a593Smuzhiyun #define ICE1712_PLAYBACK_START 0x01 /* playback start */
156*4882a593Smuzhiyun #define ICE1712_MT_CAPTURE_ADDR 0x20 /* dword - capture address */
157*4882a593Smuzhiyun #define ICE1712_MT_CAPTURE_SIZE 0x24 /* word - capture size */
158*4882a593Smuzhiyun #define ICE1712_MT_CAPTURE_COUNT 0x26 /* word - capture count */
159*4882a593Smuzhiyun #define ICE1712_MT_CAPTURE_CONTROL 0x28 /* byte - control */
160*4882a593Smuzhiyun #define ICE1712_CAPTURE_START 0x01 /* capture start */
161*4882a593Smuzhiyun #define ICE1712_MT_ROUTE_PSDOUT03 0x30 /* word */
162*4882a593Smuzhiyun #define ICE1712_MT_ROUTE_SPDOUT 0x32 /* word */
163*4882a593Smuzhiyun #define ICE1712_MT_ROUTE_CAPTURE 0x34 /* dword */
164*4882a593Smuzhiyun #define ICE1712_MT_MONITOR_VOLUME 0x38 /* word */
165*4882a593Smuzhiyun #define ICE1712_MT_MONITOR_INDEX 0x3a /* byte */
166*4882a593Smuzhiyun #define ICE1712_MT_MONITOR_RATE 0x3b /* byte */
167*4882a593Smuzhiyun #define ICE1712_MT_MONITOR_ROUTECTRL 0x3c /* byte */
168*4882a593Smuzhiyun #define ICE1712_ROUTE_AC97 0x01 /* route digital mixer output to AC'97 */
169*4882a593Smuzhiyun #define ICE1712_MT_MONITOR_PEAKINDEX 0x3e /* byte */
170*4882a593Smuzhiyun #define ICE1712_MT_MONITOR_PEAKDATA 0x3f /* byte */
171*4882a593Smuzhiyun
172*4882a593Smuzhiyun /*
173*4882a593Smuzhiyun * Codec configuration bits
174*4882a593Smuzhiyun */
175*4882a593Smuzhiyun
176*4882a593Smuzhiyun /* PCI[60] System Configuration */
177*4882a593Smuzhiyun #define ICE1712_CFG_CLOCK 0xc0
178*4882a593Smuzhiyun #define ICE1712_CFG_CLOCK512 0x00 /* 22.5692Mhz, 44.1kHz*512 */
179*4882a593Smuzhiyun #define ICE1712_CFG_CLOCK384 0x40 /* 16.9344Mhz, 44.1kHz*384 */
180*4882a593Smuzhiyun #define ICE1712_CFG_EXT 0x80 /* external clock */
181*4882a593Smuzhiyun #define ICE1712_CFG_2xMPU401 0x20 /* two MPU401 UARTs */
182*4882a593Smuzhiyun #define ICE1712_CFG_NO_CON_AC97 0x10 /* consumer AC'97 codec is not present */
183*4882a593Smuzhiyun #define ICE1712_CFG_ADC_MASK 0x0c /* one, two, three, four stereo ADCs */
184*4882a593Smuzhiyun #define ICE1712_CFG_DAC_MASK 0x03 /* one, two, three, four stereo DACs */
185*4882a593Smuzhiyun /* PCI[61] AC-Link Configuration */
186*4882a593Smuzhiyun #define ICE1712_CFG_PRO_I2S 0x80 /* multitrack converter: I2S or AC'97 */
187*4882a593Smuzhiyun #define ICE1712_CFG_AC97_PACKED 0x01 /* split or packed mode - AC'97 */
188*4882a593Smuzhiyun /* PCI[62] I2S Features */
189*4882a593Smuzhiyun #define ICE1712_CFG_I2S_VOLUME 0x80 /* volume/mute capability */
190*4882a593Smuzhiyun #define ICE1712_CFG_I2S_96KHZ 0x40 /* supports 96kHz sampling */
191*4882a593Smuzhiyun #define ICE1712_CFG_I2S_RESMASK 0x30 /* resolution mask, 16,18,20,24-bit */
192*4882a593Smuzhiyun #define ICE1712_CFG_I2S_OTHER 0x0f /* other I2S IDs */
193*4882a593Smuzhiyun /* PCI[63] S/PDIF Configuration */
194*4882a593Smuzhiyun #define ICE1712_CFG_I2S_CHIPID 0xfc /* I2S chip ID */
195*4882a593Smuzhiyun #define ICE1712_CFG_SPDIF_IN 0x02 /* S/PDIF input is present */
196*4882a593Smuzhiyun #define ICE1712_CFG_SPDIF_OUT 0x01 /* S/PDIF output is present */
197*4882a593Smuzhiyun
198*4882a593Smuzhiyun /*
199*4882a593Smuzhiyun * DMA mode values
200*4882a593Smuzhiyun * identical with DMA_XXX on i386 architecture.
201*4882a593Smuzhiyun */
202*4882a593Smuzhiyun #define ICE1712_DMA_MODE_WRITE 0x48
203*4882a593Smuzhiyun #define ICE1712_DMA_AUTOINIT 0x10
204*4882a593Smuzhiyun
205*4882a593Smuzhiyun
206*4882a593Smuzhiyun /*
207*4882a593Smuzhiyun * I2C EEPROM Address
208*4882a593Smuzhiyun */
209*4882a593Smuzhiyun #define ICE_I2C_EEPROM_ADDR 0xA0
210*4882a593Smuzhiyun
211*4882a593Smuzhiyun struct snd_ice1712;
212*4882a593Smuzhiyun
213*4882a593Smuzhiyun struct snd_ice1712_eeprom {
214*4882a593Smuzhiyun unsigned int subvendor; /* PCI[2c-2f] */
215*4882a593Smuzhiyun unsigned char size; /* size of EEPROM image in bytes */
216*4882a593Smuzhiyun unsigned char version; /* must be 1 (or 2 for vt1724) */
217*4882a593Smuzhiyun unsigned char data[32];
218*4882a593Smuzhiyun unsigned int gpiomask;
219*4882a593Smuzhiyun unsigned int gpiostate;
220*4882a593Smuzhiyun unsigned int gpiodir;
221*4882a593Smuzhiyun };
222*4882a593Smuzhiyun
223*4882a593Smuzhiyun enum {
224*4882a593Smuzhiyun ICE_EEP1_CODEC = 0, /* 06 */
225*4882a593Smuzhiyun ICE_EEP1_ACLINK, /* 07 */
226*4882a593Smuzhiyun ICE_EEP1_I2SID, /* 08 */
227*4882a593Smuzhiyun ICE_EEP1_SPDIF, /* 09 */
228*4882a593Smuzhiyun ICE_EEP1_GPIO_MASK, /* 0a */
229*4882a593Smuzhiyun ICE_EEP1_GPIO_STATE, /* 0b */
230*4882a593Smuzhiyun ICE_EEP1_GPIO_DIR, /* 0c */
231*4882a593Smuzhiyun ICE_EEP1_AC97_MAIN_LO, /* 0d */
232*4882a593Smuzhiyun ICE_EEP1_AC97_MAIN_HI, /* 0e */
233*4882a593Smuzhiyun ICE_EEP1_AC97_PCM_LO, /* 0f */
234*4882a593Smuzhiyun ICE_EEP1_AC97_PCM_HI, /* 10 */
235*4882a593Smuzhiyun ICE_EEP1_AC97_REC_LO, /* 11 */
236*4882a593Smuzhiyun ICE_EEP1_AC97_REC_HI, /* 12 */
237*4882a593Smuzhiyun ICE_EEP1_AC97_RECSRC, /* 13 */
238*4882a593Smuzhiyun ICE_EEP1_DAC_ID, /* 14 */
239*4882a593Smuzhiyun ICE_EEP1_DAC_ID1,
240*4882a593Smuzhiyun ICE_EEP1_DAC_ID2,
241*4882a593Smuzhiyun ICE_EEP1_DAC_ID3,
242*4882a593Smuzhiyun ICE_EEP1_ADC_ID, /* 18 */
243*4882a593Smuzhiyun ICE_EEP1_ADC_ID1,
244*4882a593Smuzhiyun ICE_EEP1_ADC_ID2,
245*4882a593Smuzhiyun ICE_EEP1_ADC_ID3
246*4882a593Smuzhiyun };
247*4882a593Smuzhiyun
248*4882a593Smuzhiyun #define ice_has_con_ac97(ice) (!((ice)->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_NO_CON_AC97))
249*4882a593Smuzhiyun
250*4882a593Smuzhiyun
251*4882a593Smuzhiyun struct snd_ak4xxx_private {
252*4882a593Smuzhiyun unsigned int cif:1; /* CIF mode */
253*4882a593Smuzhiyun unsigned char caddr; /* C0 and C1 bits */
254*4882a593Smuzhiyun unsigned int data_mask; /* DATA gpio bit */
255*4882a593Smuzhiyun unsigned int clk_mask; /* CLK gpio bit */
256*4882a593Smuzhiyun unsigned int cs_mask; /* bit mask for select/deselect address */
257*4882a593Smuzhiyun unsigned int cs_addr; /* bits to select address */
258*4882a593Smuzhiyun unsigned int cs_none; /* bits to deselect address */
259*4882a593Smuzhiyun unsigned int add_flags; /* additional bits at init */
260*4882a593Smuzhiyun unsigned int mask_flags; /* total mask bits */
261*4882a593Smuzhiyun struct snd_akm4xxx_ops {
262*4882a593Smuzhiyun void (*set_rate_val)(struct snd_akm4xxx *ak, unsigned int rate);
263*4882a593Smuzhiyun } ops;
264*4882a593Smuzhiyun };
265*4882a593Smuzhiyun
266*4882a593Smuzhiyun struct snd_ice1712_spdif {
267*4882a593Smuzhiyun unsigned char cs8403_bits;
268*4882a593Smuzhiyun unsigned char cs8403_stream_bits;
269*4882a593Smuzhiyun struct snd_kcontrol *stream_ctl;
270*4882a593Smuzhiyun
271*4882a593Smuzhiyun struct snd_ice1712_spdif_ops {
272*4882a593Smuzhiyun void (*open)(struct snd_ice1712 *, struct snd_pcm_substream *);
273*4882a593Smuzhiyun void (*setup_rate)(struct snd_ice1712 *, int rate);
274*4882a593Smuzhiyun void (*close)(struct snd_ice1712 *, struct snd_pcm_substream *);
275*4882a593Smuzhiyun void (*default_get)(struct snd_ice1712 *, struct snd_ctl_elem_value *ucontrol);
276*4882a593Smuzhiyun int (*default_put)(struct snd_ice1712 *, struct snd_ctl_elem_value *ucontrol);
277*4882a593Smuzhiyun void (*stream_get)(struct snd_ice1712 *, struct snd_ctl_elem_value *ucontrol);
278*4882a593Smuzhiyun int (*stream_put)(struct snd_ice1712 *, struct snd_ctl_elem_value *ucontrol);
279*4882a593Smuzhiyun } ops;
280*4882a593Smuzhiyun };
281*4882a593Smuzhiyun
282*4882a593Smuzhiyun struct snd_ice1712_card_info;
283*4882a593Smuzhiyun
284*4882a593Smuzhiyun struct snd_ice1712 {
285*4882a593Smuzhiyun unsigned long conp_dma_size;
286*4882a593Smuzhiyun unsigned long conc_dma_size;
287*4882a593Smuzhiyun unsigned long prop_dma_size;
288*4882a593Smuzhiyun unsigned long proc_dma_size;
289*4882a593Smuzhiyun int irq;
290*4882a593Smuzhiyun
291*4882a593Smuzhiyun unsigned long port;
292*4882a593Smuzhiyun unsigned long ddma_port;
293*4882a593Smuzhiyun unsigned long dmapath_port;
294*4882a593Smuzhiyun unsigned long profi_port;
295*4882a593Smuzhiyun
296*4882a593Smuzhiyun struct pci_dev *pci;
297*4882a593Smuzhiyun struct snd_card *card;
298*4882a593Smuzhiyun struct snd_pcm *pcm;
299*4882a593Smuzhiyun struct snd_pcm *pcm_ds;
300*4882a593Smuzhiyun struct snd_pcm *pcm_pro;
301*4882a593Smuzhiyun struct snd_pcm_substream *playback_con_substream;
302*4882a593Smuzhiyun struct snd_pcm_substream *playback_con_substream_ds[6];
303*4882a593Smuzhiyun struct snd_pcm_substream *capture_con_substream;
304*4882a593Smuzhiyun struct snd_pcm_substream *playback_pro_substream;
305*4882a593Smuzhiyun struct snd_pcm_substream *capture_pro_substream;
306*4882a593Smuzhiyun unsigned int playback_pro_size;
307*4882a593Smuzhiyun unsigned int capture_pro_size;
308*4882a593Smuzhiyun unsigned int playback_con_virt_addr[6];
309*4882a593Smuzhiyun unsigned int playback_con_active_buf[6];
310*4882a593Smuzhiyun unsigned int capture_con_virt_addr;
311*4882a593Smuzhiyun unsigned int ac97_ext_id;
312*4882a593Smuzhiyun struct snd_ac97 *ac97;
313*4882a593Smuzhiyun struct snd_rawmidi *rmidi[2];
314*4882a593Smuzhiyun
315*4882a593Smuzhiyun spinlock_t reg_lock;
316*4882a593Smuzhiyun struct snd_info_entry *proc_entry;
317*4882a593Smuzhiyun
318*4882a593Smuzhiyun struct snd_ice1712_eeprom eeprom;
319*4882a593Smuzhiyun const struct snd_ice1712_card_info *card_info;
320*4882a593Smuzhiyun
321*4882a593Smuzhiyun unsigned int pro_volumes[20];
322*4882a593Smuzhiyun unsigned int omni:1; /* Delta Omni I/O */
323*4882a593Smuzhiyun unsigned int dxr_enable:1; /* Terratec DXR enable for DMX6FIRE */
324*4882a593Smuzhiyun unsigned int vt1724:1;
325*4882a593Smuzhiyun unsigned int vt1720:1;
326*4882a593Smuzhiyun unsigned int has_spdif:1; /* VT1720/4 - has SPDIF I/O */
327*4882a593Smuzhiyun unsigned int force_pdma4:1; /* VT1720/4 - PDMA4 as non-spdif */
328*4882a593Smuzhiyun unsigned int force_rdma1:1; /* VT1720/4 - RDMA1 as non-spdif */
329*4882a593Smuzhiyun unsigned int midi_output:1; /* VT1720/4: MIDI output triggered */
330*4882a593Smuzhiyun unsigned int midi_input:1; /* VT1720/4: MIDI input triggered */
331*4882a593Smuzhiyun unsigned int own_routing:1; /* VT1720/4: use own routing ctls */
332*4882a593Smuzhiyun unsigned int num_total_dacs; /* total DACs */
333*4882a593Smuzhiyun unsigned int num_total_adcs; /* total ADCs */
334*4882a593Smuzhiyun unsigned int cur_rate; /* current rate */
335*4882a593Smuzhiyun
336*4882a593Smuzhiyun struct mutex open_mutex;
337*4882a593Smuzhiyun struct snd_pcm_substream *pcm_reserved[4];
338*4882a593Smuzhiyun const struct snd_pcm_hw_constraint_list *hw_rates; /* card-specific rate constraints */
339*4882a593Smuzhiyun
340*4882a593Smuzhiyun unsigned int akm_codecs;
341*4882a593Smuzhiyun struct snd_akm4xxx *akm;
342*4882a593Smuzhiyun struct snd_ice1712_spdif spdif;
343*4882a593Smuzhiyun
344*4882a593Smuzhiyun struct mutex i2c_mutex; /* I2C mutex for ICE1724 registers */
345*4882a593Smuzhiyun struct snd_i2c_bus *i2c; /* I2C bus */
346*4882a593Smuzhiyun struct snd_i2c_device *cs8427; /* CS8427 I2C device */
347*4882a593Smuzhiyun unsigned int cs8427_timeout; /* CS8427 reset timeout in HZ/100 */
348*4882a593Smuzhiyun
349*4882a593Smuzhiyun struct ice1712_gpio {
350*4882a593Smuzhiyun unsigned int direction; /* current direction bits */
351*4882a593Smuzhiyun unsigned int write_mask; /* current mask bits */
352*4882a593Smuzhiyun unsigned int saved[2]; /* for ewx_i2c */
353*4882a593Smuzhiyun /* operators */
354*4882a593Smuzhiyun void (*set_mask)(struct snd_ice1712 *ice, unsigned int data);
355*4882a593Smuzhiyun unsigned int (*get_mask)(struct snd_ice1712 *ice);
356*4882a593Smuzhiyun void (*set_dir)(struct snd_ice1712 *ice, unsigned int data);
357*4882a593Smuzhiyun unsigned int (*get_dir)(struct snd_ice1712 *ice);
358*4882a593Smuzhiyun void (*set_data)(struct snd_ice1712 *ice, unsigned int data);
359*4882a593Smuzhiyun unsigned int (*get_data)(struct snd_ice1712 *ice);
360*4882a593Smuzhiyun /* misc operators - move to another place? */
361*4882a593Smuzhiyun void (*set_pro_rate)(struct snd_ice1712 *ice, unsigned int rate);
362*4882a593Smuzhiyun void (*i2s_mclk_changed)(struct snd_ice1712 *ice);
363*4882a593Smuzhiyun } gpio;
364*4882a593Smuzhiyun struct mutex gpio_mutex;
365*4882a593Smuzhiyun
366*4882a593Smuzhiyun /* other board-specific data */
367*4882a593Smuzhiyun void *spec;
368*4882a593Smuzhiyun
369*4882a593Smuzhiyun /* VT172x specific */
370*4882a593Smuzhiyun int pro_rate_default;
371*4882a593Smuzhiyun int (*is_spdif_master)(struct snd_ice1712 *ice);
372*4882a593Smuzhiyun unsigned int (*get_rate)(struct snd_ice1712 *ice);
373*4882a593Smuzhiyun void (*set_rate)(struct snd_ice1712 *ice, unsigned int rate);
374*4882a593Smuzhiyun unsigned char (*set_mclk)(struct snd_ice1712 *ice, unsigned int rate);
375*4882a593Smuzhiyun int (*set_spdif_clock)(struct snd_ice1712 *ice, int type);
376*4882a593Smuzhiyun int (*get_spdif_master_type)(struct snd_ice1712 *ice);
377*4882a593Smuzhiyun const char * const *ext_clock_names;
378*4882a593Smuzhiyun int ext_clock_count;
379*4882a593Smuzhiyun void (*pro_open)(struct snd_ice1712 *, struct snd_pcm_substream *);
380*4882a593Smuzhiyun #ifdef CONFIG_PM_SLEEP
381*4882a593Smuzhiyun int (*pm_suspend)(struct snd_ice1712 *);
382*4882a593Smuzhiyun int (*pm_resume)(struct snd_ice1712 *);
383*4882a593Smuzhiyun unsigned int pm_suspend_enabled:1;
384*4882a593Smuzhiyun unsigned int pm_saved_is_spdif_master:1;
385*4882a593Smuzhiyun unsigned int pm_saved_spdif_ctrl;
386*4882a593Smuzhiyun unsigned char pm_saved_spdif_cfg;
387*4882a593Smuzhiyun unsigned int pm_saved_route;
388*4882a593Smuzhiyun #endif
389*4882a593Smuzhiyun };
390*4882a593Smuzhiyun
391*4882a593Smuzhiyun
392*4882a593Smuzhiyun /*
393*4882a593Smuzhiyun * gpio access functions
394*4882a593Smuzhiyun */
snd_ice1712_gpio_set_dir(struct snd_ice1712 * ice,unsigned int bits)395*4882a593Smuzhiyun static inline void snd_ice1712_gpio_set_dir(struct snd_ice1712 *ice, unsigned int bits)
396*4882a593Smuzhiyun {
397*4882a593Smuzhiyun ice->gpio.set_dir(ice, bits);
398*4882a593Smuzhiyun }
399*4882a593Smuzhiyun
snd_ice1712_gpio_get_dir(struct snd_ice1712 * ice)400*4882a593Smuzhiyun static inline unsigned int snd_ice1712_gpio_get_dir(struct snd_ice1712 *ice)
401*4882a593Smuzhiyun {
402*4882a593Smuzhiyun return ice->gpio.get_dir(ice);
403*4882a593Smuzhiyun }
404*4882a593Smuzhiyun
snd_ice1712_gpio_set_mask(struct snd_ice1712 * ice,unsigned int bits)405*4882a593Smuzhiyun static inline void snd_ice1712_gpio_set_mask(struct snd_ice1712 *ice, unsigned int bits)
406*4882a593Smuzhiyun {
407*4882a593Smuzhiyun ice->gpio.set_mask(ice, bits);
408*4882a593Smuzhiyun }
409*4882a593Smuzhiyun
snd_ice1712_gpio_write(struct snd_ice1712 * ice,unsigned int val)410*4882a593Smuzhiyun static inline void snd_ice1712_gpio_write(struct snd_ice1712 *ice, unsigned int val)
411*4882a593Smuzhiyun {
412*4882a593Smuzhiyun ice->gpio.set_data(ice, val);
413*4882a593Smuzhiyun }
414*4882a593Smuzhiyun
snd_ice1712_gpio_read(struct snd_ice1712 * ice)415*4882a593Smuzhiyun static inline unsigned int snd_ice1712_gpio_read(struct snd_ice1712 *ice)
416*4882a593Smuzhiyun {
417*4882a593Smuzhiyun return ice->gpio.get_data(ice);
418*4882a593Smuzhiyun }
419*4882a593Smuzhiyun
420*4882a593Smuzhiyun /*
421*4882a593Smuzhiyun * save and restore gpio status
422*4882a593Smuzhiyun * The access to gpio will be protected by mutex, so don't forget to
423*4882a593Smuzhiyun * restore!
424*4882a593Smuzhiyun */
snd_ice1712_save_gpio_status(struct snd_ice1712 * ice)425*4882a593Smuzhiyun static inline void snd_ice1712_save_gpio_status(struct snd_ice1712 *ice)
426*4882a593Smuzhiyun {
427*4882a593Smuzhiyun mutex_lock(&ice->gpio_mutex);
428*4882a593Smuzhiyun ice->gpio.saved[0] = ice->gpio.direction;
429*4882a593Smuzhiyun ice->gpio.saved[1] = ice->gpio.write_mask;
430*4882a593Smuzhiyun }
431*4882a593Smuzhiyun
snd_ice1712_restore_gpio_status(struct snd_ice1712 * ice)432*4882a593Smuzhiyun static inline void snd_ice1712_restore_gpio_status(struct snd_ice1712 *ice)
433*4882a593Smuzhiyun {
434*4882a593Smuzhiyun ice->gpio.set_dir(ice, ice->gpio.saved[0]);
435*4882a593Smuzhiyun ice->gpio.set_mask(ice, ice->gpio.saved[1]);
436*4882a593Smuzhiyun ice->gpio.direction = ice->gpio.saved[0];
437*4882a593Smuzhiyun ice->gpio.write_mask = ice->gpio.saved[1];
438*4882a593Smuzhiyun mutex_unlock(&ice->gpio_mutex);
439*4882a593Smuzhiyun }
440*4882a593Smuzhiyun
441*4882a593Smuzhiyun /* for bit controls */
442*4882a593Smuzhiyun #define ICE1712_GPIO(xiface, xname, xindex, mask, invert, xaccess) \
443*4882a593Smuzhiyun { .iface = xiface, .name = xname, .access = xaccess, .info = snd_ctl_boolean_mono_info, \
444*4882a593Smuzhiyun .get = snd_ice1712_gpio_get, .put = snd_ice1712_gpio_put, \
445*4882a593Smuzhiyun .private_value = mask | (invert << 24) }
446*4882a593Smuzhiyun
447*4882a593Smuzhiyun int snd_ice1712_gpio_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
448*4882a593Smuzhiyun int snd_ice1712_gpio_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
449*4882a593Smuzhiyun
450*4882a593Smuzhiyun /*
451*4882a593Smuzhiyun * set gpio direction, write mask and data
452*4882a593Smuzhiyun */
snd_ice1712_gpio_write_bits(struct snd_ice1712 * ice,unsigned int mask,unsigned int bits)453*4882a593Smuzhiyun static inline void snd_ice1712_gpio_write_bits(struct snd_ice1712 *ice,
454*4882a593Smuzhiyun unsigned int mask, unsigned int bits)
455*4882a593Smuzhiyun {
456*4882a593Smuzhiyun unsigned val;
457*4882a593Smuzhiyun
458*4882a593Smuzhiyun ice->gpio.direction |= mask;
459*4882a593Smuzhiyun snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
460*4882a593Smuzhiyun val = snd_ice1712_gpio_read(ice);
461*4882a593Smuzhiyun val &= ~mask;
462*4882a593Smuzhiyun val |= mask & bits;
463*4882a593Smuzhiyun snd_ice1712_gpio_write(ice, val);
464*4882a593Smuzhiyun }
465*4882a593Smuzhiyun
snd_ice1712_gpio_read_bits(struct snd_ice1712 * ice,unsigned int mask)466*4882a593Smuzhiyun static inline int snd_ice1712_gpio_read_bits(struct snd_ice1712 *ice,
467*4882a593Smuzhiyun unsigned int mask)
468*4882a593Smuzhiyun {
469*4882a593Smuzhiyun ice->gpio.direction &= ~mask;
470*4882a593Smuzhiyun snd_ice1712_gpio_set_dir(ice, ice->gpio.direction);
471*4882a593Smuzhiyun return snd_ice1712_gpio_read(ice) & mask;
472*4882a593Smuzhiyun }
473*4882a593Smuzhiyun
474*4882a593Smuzhiyun /* route access functions */
475*4882a593Smuzhiyun int snd_ice1724_get_route_val(struct snd_ice1712 *ice, int shift);
476*4882a593Smuzhiyun int snd_ice1724_put_route_val(struct snd_ice1712 *ice, unsigned int val,
477*4882a593Smuzhiyun int shift);
478*4882a593Smuzhiyun
479*4882a593Smuzhiyun int snd_ice1712_spdif_build_controls(struct snd_ice1712 *ice);
480*4882a593Smuzhiyun
481*4882a593Smuzhiyun int snd_ice1712_akm4xxx_init(struct snd_akm4xxx *ak,
482*4882a593Smuzhiyun const struct snd_akm4xxx *template,
483*4882a593Smuzhiyun const struct snd_ak4xxx_private *priv,
484*4882a593Smuzhiyun struct snd_ice1712 *ice);
485*4882a593Smuzhiyun void snd_ice1712_akm4xxx_free(struct snd_ice1712 *ice);
486*4882a593Smuzhiyun int snd_ice1712_akm4xxx_build_controls(struct snd_ice1712 *ice);
487*4882a593Smuzhiyun
488*4882a593Smuzhiyun int snd_ice1712_init_cs8427(struct snd_ice1712 *ice, int addr);
489*4882a593Smuzhiyun
snd_ice1712_write(struct snd_ice1712 * ice,u8 addr,u8 data)490*4882a593Smuzhiyun static inline void snd_ice1712_write(struct snd_ice1712 *ice, u8 addr, u8 data)
491*4882a593Smuzhiyun {
492*4882a593Smuzhiyun outb(addr, ICEREG(ice, INDEX));
493*4882a593Smuzhiyun outb(data, ICEREG(ice, DATA));
494*4882a593Smuzhiyun }
495*4882a593Smuzhiyun
snd_ice1712_read(struct snd_ice1712 * ice,u8 addr)496*4882a593Smuzhiyun static inline u8 snd_ice1712_read(struct snd_ice1712 *ice, u8 addr)
497*4882a593Smuzhiyun {
498*4882a593Smuzhiyun outb(addr, ICEREG(ice, INDEX));
499*4882a593Smuzhiyun return inb(ICEREG(ice, DATA));
500*4882a593Smuzhiyun }
501*4882a593Smuzhiyun
502*4882a593Smuzhiyun
503*4882a593Smuzhiyun /*
504*4882a593Smuzhiyun * entry pointer
505*4882a593Smuzhiyun */
506*4882a593Smuzhiyun
507*4882a593Smuzhiyun struct snd_ice1712_card_info {
508*4882a593Smuzhiyun unsigned int subvendor;
509*4882a593Smuzhiyun const char *name;
510*4882a593Smuzhiyun const char *model;
511*4882a593Smuzhiyun const char *driver;
512*4882a593Smuzhiyun int (*chip_init)(struct snd_ice1712 *);
513*4882a593Smuzhiyun void (*chip_exit)(struct snd_ice1712 *);
514*4882a593Smuzhiyun int (*build_controls)(struct snd_ice1712 *);
515*4882a593Smuzhiyun unsigned int no_mpu401:1;
516*4882a593Smuzhiyun unsigned int mpu401_1_info_flags;
517*4882a593Smuzhiyun unsigned int mpu401_2_info_flags;
518*4882a593Smuzhiyun const char *mpu401_1_name;
519*4882a593Smuzhiyun const char *mpu401_2_name;
520*4882a593Smuzhiyun const unsigned int eeprom_size;
521*4882a593Smuzhiyun const unsigned char *eeprom_data;
522*4882a593Smuzhiyun };
523*4882a593Smuzhiyun
524*4882a593Smuzhiyun
525*4882a593Smuzhiyun #endif /* __SOUND_ICE1712_H */
526