1#ifndef _AC97_CODEC_H_
2#define _AC97_CODEC_H_
3
4#include <linux/types.h>
5#include <linux/soundcard.h>
6
7
8#define AC97_RESET 0x0000
9#define AC97_MASTER_VOL_STEREO 0x0002
10#define AC97_HEADPHONE_VOL 0x0004
11#define AC97_MASTER_VOL_MONO 0x0006
12#define AC97_MASTER_TONE 0x0008
13#define AC97_PCBEEP_VOL 0x000a
14#define AC97_PHONE_VOL 0x000c
15#define AC97_MIC_VOL 0x000e
16#define AC97_LINEIN_VOL 0x0010
17#define AC97_CD_VOL 0x0012
18#define AC97_VIDEO_VOL 0x0014
19#define AC97_AUX_VOL 0x0016
20#define AC97_PCMOUT_VOL 0x0018
21#define AC97_RECORD_SELECT 0x001a
22#define AC97_RECORD_GAIN 0x001c
23#define AC97_RECORD_GAIN_MIC 0x001e
24#define AC97_GENERAL_PURPOSE 0x0020
25#define AC97_3D_CONTROL 0x0022
26#define AC97_MODEM_RATE 0x0024
27#define AC97_POWER_CONTROL 0x0026
28
29
30#define AC97_EXTENDED_ID 0x0028
31#define AC97_EXTENDED_STATUS 0x002A
32#define AC97_PCM_FRONT_DAC_RATE 0x002C
33#define AC97_PCM_SURR_DAC_RATE 0x002E
34#define AC97_PCM_LFE_DAC_RATE 0x0030
35#define AC97_PCM_LR_ADC_RATE 0x0032
36#define AC97_PCM_MIC_ADC_RATE 0x0034
37#define AC97_CENTER_LFE_MASTER 0x0036
38#define AC97_SURROUND_MASTER 0x0038
39#define AC97_RESERVED_3A 0x003A
40
41
42#define AC97_SPDIF_CONTROL 0x003A
43
44
45#define AC97_EXTENDED_MODEM_ID 0x003C
46#define AC97_EXTEND_MODEM_STAT 0x003E
47#define AC97_LINE1_RATE 0x0040
48#define AC97_LINE2_RATE 0x0042
49#define AC97_HANDSET_RATE 0x0044
50#define AC97_LINE1_LEVEL 0x0046
51#define AC97_LINE2_LEVEL 0x0048
52#define AC97_HANDSET_LEVEL 0x004A
53#define AC97_GPIO_CONFIG 0x004C
54#define AC97_GPIO_POLARITY 0x004E
55#define AC97_GPIO_STICKY 0x0050
56#define AC97_GPIO_WAKE_UP 0x0052
57#define AC97_GPIO_STATUS 0x0054
58#define AC97_MISC_MODEM_STAT 0x0056
59#define AC97_RESERVED_58 0x0058
60
61
62
63#define AC97_VENDOR_ID1 0x007c
64#define AC97_VENDOR_ID2 0x007e
65
66
67#define AC97_MUTE 0x8000
68#define AC97_MICBOOST 0x0040
69#define AC97_LEFTVOL 0x3f00
70#define AC97_RIGHTVOL 0x003f
71
72
73#define AC97_RECMUX_MIC 0x0000
74#define AC97_RECMUX_CD 0x0101
75#define AC97_RECMUX_VIDEO 0x0202
76#define AC97_RECMUX_AUX 0x0303
77#define AC97_RECMUX_LINE 0x0404
78#define AC97_RECMUX_STEREO_MIX 0x0505
79#define AC97_RECMUX_MONO_MIX 0x0606
80#define AC97_RECMUX_PHONE 0x0707
81
82
83#define AC97_GP_LPBK 0x0080
84#define AC97_GP_MS 0x0100
85#define AC97_GP_MIX 0x0200
86#define AC97_GP_RLBK 0x0400
87#define AC97_GP_LLBK 0x0800
88#define AC97_GP_LD 0x1000
89#define AC97_GP_3D 0x2000
90#define AC97_GP_ST 0x4000
91#define AC97_GP_POP 0x8000
92
93
94#define AC97_EA_VRA 0x0001
95#define AC97_EA_DRA 0x0002
96#define AC97_EA_SPDIF 0x0004
97#define AC97_EA_VRM 0x0008
98#define AC97_EA_CDAC 0x0040
99#define AC97_EA_SDAC 0x0040
100#define AC97_EA_LDAC 0x0080
101#define AC97_EA_MDAC 0x0100
102#define AC97_EA_SPCV 0x0400
103#define AC97_EA_PRI 0x0800
104#define AC97_EA_PRJ 0x1000
105#define AC97_EA_PRK 0x2000
106#define AC97_EA_PRL 0x4000
107#define AC97_EA_SLOT_MASK 0xffcf
108#define AC97_EA_SPSA_3_4 0x0000
109#define AC97_EA_SPSA_7_8 0x0010
110#define AC97_EA_SPSA_6_9 0x0020
111#define AC97_EA_SPSA_10_11 0x0030
112
113
114#define AC97_SC_PRO 0x0001
115#define AC97_SC_NAUDIO 0x0002
116#define AC97_SC_COPY 0x0004
117#define AC97_SC_PRE 0x0008
118#define AC97_SC_CC_MASK 0x07f0
119#define AC97_SC_L 0x0800
120#define AC97_SC_SPSR_MASK 0xcfff
121#define AC97_SC_SPSR_44K 0x0000
122#define AC97_SC_SPSR_48K 0x2000
123#define AC97_SC_SPSR_32K 0x3000
124#define AC97_SC_DRS 0x4000
125#define AC97_SC_V 0x8000
126
127
128
129
130#define AC97_PWR_MDM 0x0010
131#define AC97_PWR_REF 0x0008
132#define AC97_PWR_ANL 0x0004
133#define AC97_PWR_DAC 0x0002
134#define AC97_PWR_ADC 0x0001
135
136
137#define AC97_PWR_PR0 0x0100
138#define AC97_PWR_PR1 0x0200
139#define AC97_PWR_PR2 0x0400
140#define AC97_PWR_PR3 0x0800
141#define AC97_PWR_PR4 0x1000
142#define AC97_PWR_PR5 0x2000
143#define AC97_PWR_PR6 0x4000
144#define AC97_PWR_PR7 0x8000
145
146
147#define AC97_EXTID_VRA 0x0001
148#define AC97_EXTID_DRA 0x0002
149#define AC97_EXTID_SPDIF 0x0004
150#define AC97_EXTID_VRM 0x0008
151#define AC97_EXTID_DSA0 0x0010
152#define AC97_EXTID_DSA1 0x0020
153#define AC97_EXTID_CDAC 0x0040
154#define AC97_EXTID_SDAC 0x0080
155#define AC97_EXTID_LDAC 0x0100
156#define AC97_EXTID_AMAP 0x0200
157#define AC97_EXTID_REV0 0x0400
158#define AC97_EXTID_REV1 0x0800
159#define AC97_EXTID_ID0 0x4000
160#define AC97_EXTID_ID1 0x8000
161
162
163#define AC97_EXTSTAT_VRA 0x0001
164#define AC97_EXTSTAT_DRA 0x0002
165#define AC97_EXTSTAT_SPDIF 0x0004
166#define AC97_EXTSTAT_VRM 0x0008
167#define AC97_EXTSTAT_SPSA0 0x0010
168#define AC97_EXTSTAT_SPSA1 0x0020
169#define AC97_EXTSTAT_CDAC 0x0040
170#define AC97_EXTSTAT_SDAC 0x0080
171#define AC97_EXTSTAT_LDAC 0x0100
172#define AC97_EXTSTAT_MADC 0x0200
173#define AC97_EXTSTAT_SPCV 0x0400
174#define AC97_EXTSTAT_PRI 0x0800
175#define AC97_EXTSTAT_PRJ 0x1000
176#define AC97_EXTSTAT_PRK 0x2000
177#define AC97_EXTSTAT_PRL 0x4000
178
179
180#define AC97_EXTID_VRA 0x0001
181#define AC97_EXTID_DRA 0x0002
182#define AC97_EXTID_SPDIF 0x0004
183#define AC97_EXTID_VRM 0x0008
184#define AC97_EXTID_DSA0 0x0010
185#define AC97_EXTID_DSA1 0x0020
186#define AC97_EXTID_CDAC 0x0040
187#define AC97_EXTID_SDAC 0x0080
188#define AC97_EXTID_LDAC 0x0100
189#define AC97_EXTID_AMAP 0x0200
190#define AC97_EXTID_REV0 0x0400
191#define AC97_EXTID_REV1 0x0800
192#define AC97_EXTID_ID0 0x4000
193#define AC97_EXTID_ID1 0x8000
194
195
196#define AC97_EXTSTAT_VRA 0x0001
197#define AC97_EXTSTAT_DRA 0x0002
198#define AC97_EXTSTAT_SPDIF 0x0004
199#define AC97_EXTSTAT_VRM 0x0008
200#define AC97_EXTSTAT_SPSA0 0x0010
201#define AC97_EXTSTAT_SPSA1 0x0020
202#define AC97_EXTSTAT_CDAC 0x0040
203#define AC97_EXTSTAT_SDAC 0x0080
204#define AC97_EXTSTAT_LDAC 0x0100
205#define AC97_EXTSTAT_MADC 0x0200
206#define AC97_EXTSTAT_SPCV 0x0400
207#define AC97_EXTSTAT_PRI 0x0800
208#define AC97_EXTSTAT_PRJ 0x1000
209#define AC97_EXTSTAT_PRK 0x2000
210#define AC97_EXTSTAT_PRL 0x4000
211
212
213#define AC97_PWR_D0 0x0000
214#define AC97_PWR_D1 AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR4
215#define AC97_PWR_D2 AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR2|AC97_PWR_PR3|AC97_PWR_PR4
216#define AC97_PWR_D3 AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR2|AC97_PWR_PR3|AC97_PWR_PR4
217#define AC97_PWR_ANLOFF AC97_PWR_PR2|AC97_PWR_PR3
218
219
220#define AC97_REG_CNT 64
221
222
223
224#define AC97_STEREO_MASK (SOUND_MASK_VOLUME|SOUND_MASK_PCM|\
225 SOUND_MASK_LINE|SOUND_MASK_CD|\
226 SOUND_MASK_ALTPCM|SOUND_MASK_IGAIN|\
227 SOUND_MASK_LINE1|SOUND_MASK_VIDEO)
228
229#define AC97_SUPPORTED_MASK (AC97_STEREO_MASK | \
230 SOUND_MASK_BASS|SOUND_MASK_TREBLE|\
231 SOUND_MASK_SPEAKER|SOUND_MASK_MIC|\
232 SOUND_MASK_PHONEIN|SOUND_MASK_PHONEOUT)
233
234#define AC97_RECORD_MASK (SOUND_MASK_MIC|\
235 SOUND_MASK_CD|SOUND_MASK_IGAIN|SOUND_MASK_VIDEO|\
236 SOUND_MASK_LINE1| SOUND_MASK_LINE|\
237 SOUND_MASK_PHONEIN)
238
239
240
241
242
243
244
245#define supported_mixer(CODEC,FOO) ((FOO >= 0) && \
246 (FOO < SOUND_MIXER_NRDEVICES) && \
247 (CODEC)->supported_mixers & (1<<FOO) )
248
249struct ac97_codec {
250
251 struct list_head list;
252
253
254 void *private_data;
255
256 char *name;
257 int id;
258 int dev_mixer;
259 int type;
260 u32 model;
261
262 unsigned int modem:1;
263
264 struct ac97_ops *codec_ops;
265
266
267
268 u16 (*codec_read) (struct ac97_codec *codec, u8 reg);
269 void (*codec_write) (struct ac97_codec *codec, u8 reg, u16 val);
270
271
272 void (*codec_wait) (struct ac97_codec *codec);
273
274
275 void (*codec_unregister) (struct ac97_codec *codec);
276
277 struct ac97_driver *driver;
278 void *driver_private;
279
280 spinlock_t lock;
281
282
283 int modcnt;
284 int supported_mixers;
285 int stereo_mixers;
286 int record_sources;
287
288
289 int flags;
290
291 int bit_resolution;
292
293
294 int (*read_mixer) (struct ac97_codec *codec, int oss_channel);
295 void (*write_mixer)(struct ac97_codec *codec, int oss_channel,
296 unsigned int left, unsigned int right);
297 int (*recmask_io) (struct ac97_codec *codec, int rw, int mask);
298 int (*mixer_ioctl)(struct ac97_codec *codec, unsigned int cmd, unsigned long arg);
299
300
301 unsigned int mixer_state[SOUND_MIXER_NRDEVICES];
302
303
304 int (*modem_ioctl)(struct ac97_codec *codec, unsigned int cmd, unsigned long arg);
305};
306
307
308
309
310
311struct ac97_ops
312{
313
314 int (*init)(struct ac97_codec *c);
315
316 int (*amplifier)(struct ac97_codec *codec, int on);
317
318 int (*digital)(struct ac97_codec *codec, int slots, int rate, int mode);
319#define AUDIO_DIGITAL 0x8000
320#define AUDIO_PRO 0x4000
321#define AUDIO_DRS 0x2000
322#define AUDIO_CCMASK 0x003F
323
324#define AC97_DELUDED_MODEM 1
325#define AC97_NO_PCM_VOLUME 2
326#define AC97_DEFAULT_POWER_OFF 4
327};
328
329extern int ac97_probe_codec(struct ac97_codec *);
330
331extern struct ac97_codec *ac97_alloc_codec(void);
332extern void ac97_release_codec(struct ac97_codec *codec);
333
334struct ac97_driver {
335 struct list_head list;
336 char *name;
337 u32 codec_id;
338 u32 codec_mask;
339 int (*probe) (struct ac97_codec *codec, struct ac97_driver *driver);
340 void (*remove) (struct ac97_codec *codec, struct ac97_driver *driver);
341};
342
343
344enum {
345 AC97_TUNE_DEFAULT = -1,
346 AC97_TUNE_NONE = 0,
347 AC97_TUNE_HP_ONLY,
348 AC97_TUNE_SWAP_HP,
349 AC97_TUNE_SWAP_SURROUND,
350 AC97_TUNE_AD_SHARING,
351 AC97_TUNE_ALC_JACK,
352};
353
354struct ac97_quirk {
355 unsigned short vendor;
356 unsigned short device;
357 unsigned short mask;
358 const char *name;
359 int type;
360};
361
362#endif
363