1 #ifndef _AC97_CODEC_H_
2 #define _AC97_CODEC_H_
3
4 #include <linux/types.h>
5 #include <linux/soundcard.h>
6
7 /* AC97 1.0 */
8 #define AC97_RESET 0x0000 //
9 #define AC97_MASTER_VOL_STEREO 0x0002 // Line Out
10 #define AC97_HEADPHONE_VOL 0x0004 //
11 #define AC97_MASTER_VOL_MONO 0x0006 // TAD Output
12 #define AC97_MASTER_TONE 0x0008 //
13 #define AC97_PCBEEP_VOL 0x000a // none
14 #define AC97_PHONE_VOL 0x000c // TAD Input (mono)
15 #define AC97_MIC_VOL 0x000e // MIC Input (mono)
16 #define AC97_LINEIN_VOL 0x0010 // Line Input (stereo)
17 #define AC97_CD_VOL 0x0012 // CD Input (stereo)
18 #define AC97_VIDEO_VOL 0x0014 // none
19 #define AC97_AUX_VOL 0x0016 // Aux Input (stereo)
20 #define AC97_PCMOUT_VOL 0x0018 // Wave Output (stereo)
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 /* AC'97 2.0 */
30 #define AC97_EXTENDED_ID 0x0028 /* Extended Audio ID */
31 #define AC97_EXTENDED_STATUS 0x002A /* Extended Audio Status */
32 #define AC97_PCM_FRONT_DAC_RATE 0x002C /* PCM Front DAC Rate */
33 #define AC97_PCM_SURR_DAC_RATE 0x002E /* PCM Surround DAC Rate */
34 #define AC97_PCM_LFE_DAC_RATE 0x0030 /* PCM LFE DAC Rate */
35 #define AC97_PCM_LR_DAC_RATE 0x0032 /* PCM LR DAC Rate */
36 #define AC97_PCM_MIC_ADC_RATE 0x0034 /* PCM MIC ADC Rate */
37 #define AC97_CENTER_LFE_MASTER 0x0036 /* Center + LFE Master Volume */
38 #define AC97_SURROUND_MASTER 0x0038 /* Surround (Rear) Master Volume */
39 #define AC97_RESERVED_3A 0x003A /* Reserved */
40
41 /* range 0x3c-0x58 - MODEM */
42 #define AC97_EXTENDED_MODEM_ID 0x003C
43 #define AC97_EXTEND_MODEM_STAT 0x003E
44 #define AC97_LINE1_RATE 0x0040
45 #define AC97_LINE2_RATE 0x0042
46 #define AC97_HANDSET_RATE 0x0044
47 #define AC97_LINE1_LEVEL 0x0046
48 #define AC97_LINE2_LEVEL 0x0048
49 #define AC97_HANDSET_LEVEL 0x004A
50 #define AC97_GPIO_CONFIG 0x004C
51 #define AC97_GPIO_POLARITY 0x004E
52 #define AC97_GPIO_STICKY 0x0050
53 #define AC97_GPIO_WAKE_UP 0x0052
54 #define AC97_GPIO_STATUS 0x0054
55 #define AC97_MISC_MODEM_STAT 0x0056
56 #define AC97_RESERVED_58 0x0058
57
58 /* registers 0x005a - 0x007a are vendor reserved */
59
60 #define AC97_VENDOR_ID1 0x007c
61 #define AC97_VENDOR_ID2 0x007e
62
63 /* volume control bit defines */
64 #define AC97_MUTE 0x8000
65 #define AC97_MICBOOST 0x0040
66 #define AC97_LEFTVOL 0x3f00
67 #define AC97_RIGHTVOL 0x003f
68
69 /* record mux defines */
70 #define AC97_RECMUX_MIC 0x0000
71 #define AC97_RECMUX_CD 0x0101
72 #define AC97_RECMUX_VIDEO 0x0202
73 #define AC97_RECMUX_AUX 0x0303
74 #define AC97_RECMUX_LINE 0x0404
75 #define AC97_RECMUX_STEREO_MIX 0x0505
76 #define AC97_RECMUX_MONO_MIX 0x0606
77 #define AC97_RECMUX_PHONE 0x0707
78
79 /* general purpose register bit defines */
80 #define AC97_GP_LPBK 0x0080 /* Loopback mode */
81 #define AC97_GP_MS 0x0100 /* Mic Select 0=Mic1, 1=Mic2 */
82 #define AC97_GP_MIX 0x0200 /* Mono output select 0=Mix, 1=Mic */
83 #define AC97_GP_RLBK 0x0400 /* Remote Loopback - Modem line codec */
84 #define AC97_GP_LLBK 0x0800 /* Local Loopback - Modem Line codec */
85 #define AC97_GP_LD 0x1000 /* Loudness 1=on */
86 #define AC97_GP_3D 0x2000 /* 3D Enhancement 1=on */
87 #define AC97_GP_ST 0x4000 /* Stereo Enhancement 1=on */
88 #define AC97_GP_POP 0x8000 /* Pcm Out Path, 0=pre 3D, 1=post 3D */
89
90 /* powerdown control and status bit defines */
91
92 /* status */
93 #define AC97_PWR_MDM 0x0010 /* Modem section ready */
94 #define AC97_PWR_REF 0x0008 /* Vref nominal */
95 #define AC97_PWR_ANL 0x0004 /* Analog section ready */
96 #define AC97_PWR_DAC 0x0002 /* DAC section ready */
97 #define AC97_PWR_ADC 0x0001 /* ADC section ready */
98
99 /* control */
100 #define AC97_PWR_PR0 0x0100 /* ADC and Mux powerdown */
101 #define AC97_PWR_PR1 0x0200 /* DAC powerdown */
102 #define AC97_PWR_PR2 0x0400 /* Output mixer powerdown (Vref on) */
103 #define AC97_PWR_PR3 0x0800 /* Output mixer powerdown (Vref off) */
104 #define AC97_PWR_PR4 0x1000 /* AC-link powerdown */
105 #define AC97_PWR_PR5 0x2000 /* Internal Clk disable */
106 #define AC97_PWR_PR6 0x4000 /* HP amp powerdown */
107 #define AC97_PWR_PR7 0x8000 /* Modem off - if supported */
108
109 /* useful power states */
110 #define AC97_PWR_D0 0x0000 /* everything on */
111 #define AC97_PWR_D1 AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR4
112 #define AC97_PWR_D2 AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR2|AC97_PWR_PR3|AC97_PWR_PR4
113 #define AC97_PWR_D3 AC97_PWR_PR0|AC97_PWR_PR1|AC97_PWR_PR2|AC97_PWR_PR3|AC97_PWR_PR4
114 #define AC97_PWR_ANLOFF AC97_PWR_PR2|AC97_PWR_PR3 /* analog section off */
115
116 /* Total number of defined registers. */
117 #define AC97_REG_CNT 64
118
119
120 /* OSS interface to the ac97s.. */
121 #define AC97_STEREO_MASK (SOUND_MASK_VOLUME|SOUND_MASK_PCM|\
122 SOUND_MASK_LINE|SOUND_MASK_CD|\
123 SOUND_MASK_ALTPCM|SOUND_MASK_IGAIN|\
124 SOUND_MASK_LINE1|SOUND_MASK_VIDEO)
125
126 #define AC97_SUPPORTED_MASK (AC97_STEREO_MASK | \
127 SOUND_MASK_BASS|SOUND_MASK_TREBLE|\
128 SOUND_MASK_SPEAKER|SOUND_MASK_MIC|\
129 SOUND_MASK_PHONEIN|SOUND_MASK_PHONEOUT)
130
131 #define AC97_RECORD_MASK (SOUND_MASK_MIC|\
132 SOUND_MASK_CD|SOUND_MASK_IGAIN|SOUND_MASK_VIDEO|\
133 SOUND_MASK_LINE1| SOUND_MASK_LINE|\
134 SOUND_MASK_PHONEIN)
135
136 #define supported_mixer(CODEC,FOO) ((CODEC)->supported_mixers & (1<<FOO) )
137
138 struct ac97_codec {
139 /* AC97 controller connected with */
140 void *private_data;
141
142 char *name;
143 int id;
144 int dev_mixer;
145 int type;
146
147 /* codec specific init/reset routines, used mainly for 4 or 6 channel support */
148 int (*codec_init) (struct ac97_codec *codec);
149
150 /* controller specific lower leverl ac97 accessing routines */
151 u16 (*codec_read) (struct ac97_codec *codec, u8 reg);
152 void (*codec_write) (struct ac97_codec *codec, u8 reg, u16 val);
153
154 /* Wait for codec-ready. Ok to sleep here. */
155 void (*codec_wait) (struct ac97_codec *codec);
156
157 /* OSS mixer masks */
158 int modcnt;
159 int supported_mixers;
160 int stereo_mixers;
161 int record_sources;
162
163 int bit_resolution;
164
165 /* OSS mixer interface */
166 int (*read_mixer) (struct ac97_codec *codec, int oss_channel);
167 void (*write_mixer)(struct ac97_codec *codec, int oss_channel,
168 unsigned int left, unsigned int right);
169 int (*recmask_io) (struct ac97_codec *codec, int rw, int mask);
170 int (*mixer_ioctl)(struct ac97_codec *codec, unsigned int cmd, unsigned long arg);
171
172 /* saved OSS mixer states */
173 unsigned int mixer_state[SOUND_MIXER_NRDEVICES];
174
175 /* Software Modem interface */
176 int (*modem_ioctl)(struct ac97_codec *codec, unsigned int cmd, unsigned long arg);
177 };
178
179 extern int ac97_read_proc (char *page_out, char **start, off_t off,
180 int count, int *eof, void *data);
181 extern int ac97_probe_codec(struct ac97_codec *);
182
183 #endif /* _AC97_CODEC_H_ */
184
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.