Branch data Line data Source code
1 : : /*
2 : : * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
3 : : * Universal interface for Audio Codec '97
4 : : *
5 : : * For more details look to AC '97 component specification revision 2.2
6 : : * by Intel Corporation (http://developer.intel.com).
7 : : *
8 : : *
9 : : * This program is free software; you can redistribute it and/or modify
10 : : * it under the terms of the GNU General Public License as published by
11 : : * the Free Software Foundation; either version 2 of the License, or
12 : : * (at your option) any later version.
13 : : *
14 : : * This program is distributed in the hope that it will be useful,
15 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : : * GNU General Public License for more details.
18 : : *
19 : : * You should have received a copy of the GNU General Public License
20 : : * along with this program; if not, write to the Free Software
21 : : * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 : : *
23 : : */
24 : :
25 : : #include <linux/mutex.h>
26 : :
27 : : #include <sound/core.h>
28 : : #include <sound/ac97_codec.h>
29 : : #include <sound/asoundef.h>
30 : : #include "ac97_local.h"
31 : : #include "ac97_id.h"
32 : :
33 : : /*
34 : : * proc interface
35 : : */
36 : :
37 : 0 : static void snd_ac97_proc_read_functions(struct snd_ac97 *ac97, struct snd_info_buffer *buffer)
38 : : {
39 : : int header = 0, function;
40 : : unsigned short info, sense_info;
41 : : static const char *function_names[12] = {
42 : : "Master Out", "AUX Out", "Center/LFE Out", "SPDIF Out",
43 : : "Phone In", "Mic 1", "Mic 2", "Line In", "CD In", "Video In",
44 : : "Aux In", "Mono Out"
45 : : };
46 : : static const char *locations[8] = {
47 : : "Rear I/O Panel", "Front Panel", "Motherboard", "Dock/External",
48 : : "reserved", "reserved", "reserved", "NC/unused"
49 : : };
50 : :
51 [ # # ]: 0 : for (function = 0; function < 12; ++function) {
52 : 0 : snd_ac97_write(ac97, AC97_FUNC_SELECT, function << 1);
53 : 0 : info = snd_ac97_read(ac97, AC97_FUNC_INFO);
54 [ # # ]: 0 : if (!(info & 0x0001))
55 : 0 : continue;
56 [ # # ]: 0 : if (!header) {
57 : 0 : snd_iprintf(buffer, "\n Gain Inverted Buffer delay Location\n");
58 : : header = 1;
59 : : }
60 : 0 : sense_info = snd_ac97_read(ac97, AC97_SENSE_INFO);
61 [ # # ]: 0 : snd_iprintf(buffer, "%-17s: %3d.%d dBV %c %2d/fs %s\n",
62 : : function_names[function],
63 [ # # ]: 0 : (info & 0x8000 ? -1 : 1) * ((info & 0x7000) >> 12) * 3 / 2,
64 : 0 : ((info & 0x0800) >> 11) * 5,
65 : 0 : info & 0x0400 ? 'X' : '-',
66 : 0 : (info & 0x03e0) >> 5,
67 : 0 : locations[sense_info >> 13]);
68 : : }
69 : 0 : }
70 : :
71 : : static const char *snd_ac97_stereo_enhancements[] =
72 : : {
73 : : /* 0 */ "No 3D Stereo Enhancement",
74 : : /* 1 */ "Analog Devices Phat Stereo",
75 : : /* 2 */ "Creative Stereo Enhancement",
76 : : /* 3 */ "National Semi 3D Stereo Enhancement",
77 : : /* 4 */ "YAMAHA Ymersion",
78 : : /* 5 */ "BBE 3D Stereo Enhancement",
79 : : /* 6 */ "Crystal Semi 3D Stereo Enhancement",
80 : : /* 7 */ "Qsound QXpander",
81 : : /* 8 */ "Spatializer 3D Stereo Enhancement",
82 : : /* 9 */ "SRS 3D Stereo Enhancement",
83 : : /* 10 */ "Platform Tech 3D Stereo Enhancement",
84 : : /* 11 */ "AKM 3D Audio",
85 : : /* 12 */ "Aureal Stereo Enhancement",
86 : : /* 13 */ "Aztech 3D Enhancement",
87 : : /* 14 */ "Binaura 3D Audio Enhancement",
88 : : /* 15 */ "ESS Technology Stereo Enhancement",
89 : : /* 16 */ "Harman International VMAx",
90 : : /* 17 */ "Nvidea/IC Ensemble/KS Waves 3D Stereo Enhancement",
91 : : /* 18 */ "Philips Incredible Sound",
92 : : /* 19 */ "Texas Instruments 3D Stereo Enhancement",
93 : : /* 20 */ "VLSI Technology 3D Stereo Enhancement",
94 : : /* 21 */ "TriTech 3D Stereo Enhancement",
95 : : /* 22 */ "Realtek 3D Stereo Enhancement",
96 : : /* 23 */ "Samsung 3D Stereo Enhancement",
97 : : /* 24 */ "Wolfson Microelectronics 3D Enhancement",
98 : : /* 25 */ "Delta Integration 3D Enhancement",
99 : : /* 26 */ "SigmaTel 3D Enhancement",
100 : : /* 27 */ "IC Ensemble/KS Waves",
101 : : /* 28 */ "Rockwell 3D Stereo Enhancement",
102 : : /* 29 */ "Reserved 29",
103 : : /* 30 */ "Reserved 30",
104 : : /* 31 */ "Reserved 31"
105 : : };
106 : :
107 : 0 : static void snd_ac97_proc_read_main(struct snd_ac97 *ac97, struct snd_info_buffer *buffer, int subidx)
108 : : {
109 : : char name[64];
110 : : unsigned short val, tmp, ext, mext;
111 : : static const char *spdif_slots[4] = { " SPDIF=3/4", " SPDIF=7/8", " SPDIF=6/9", " SPDIF=10/11" };
112 : : static const char *spdif_rates[4] = { " Rate=44.1kHz", " Rate=res", " Rate=48kHz", " Rate=32kHz" };
113 : : static const char *spdif_rates_cs4205[4] = { " Rate=48kHz", " Rate=44.1kHz", " Rate=res", " Rate=res" };
114 : : static const char *double_rate_slots[4] = { "10/11", "7/8", "reserved", "reserved" };
115 : :
116 : 1 : snd_ac97_get_name(NULL, ac97->id, name, 0);
117 : 1 : snd_iprintf(buffer, "%d-%d/%d: %s\n\n", ac97->addr, ac97->num, subidx, name);
118 : :
119 [ + - ]: 1 : if ((ac97->scaps & AC97_SCAP_AUDIO) == 0)
120 : : goto __modem;
121 : :
122 : 1 : snd_iprintf(buffer, "PCI Subsys Vendor: 0x%04x\n",
123 : 1 : ac97->subsystem_vendor);
124 : 1 : snd_iprintf(buffer, "PCI Subsys Device: 0x%04x\n\n",
125 : 1 : ac97->subsystem_device);
126 : :
127 : 1 : snd_iprintf(buffer, "Flags: %x\n", ac97->flags);
128 : :
129 [ - + ]: 1 : if ((ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23) {
130 : 0 : val = snd_ac97_read(ac97, AC97_INT_PAGING);
131 : 0 : snd_ac97_update_bits(ac97, AC97_INT_PAGING,
132 : : AC97_PAGE_MASK, AC97_PAGE_1);
133 : 0 : tmp = snd_ac97_read(ac97, AC97_CODEC_CLASS_REV);
134 : 0 : snd_iprintf(buffer, "Revision : 0x%02x\n", tmp & 0xff);
135 : 0 : snd_iprintf(buffer, "Compat. Class : 0x%02x\n", (tmp >> 8) & 0x1f);
136 : 0 : snd_iprintf(buffer, "Subsys. Vendor ID: 0x%04x\n",
137 : 0 : snd_ac97_read(ac97, AC97_PCI_SVID));
138 : 0 : snd_iprintf(buffer, "Subsys. ID : 0x%04x\n\n",
139 : 0 : snd_ac97_read(ac97, AC97_PCI_SID));
140 : 0 : snd_ac97_update_bits(ac97, AC97_INT_PAGING,
141 : : AC97_PAGE_MASK, val & AC97_PAGE_MASK);
142 : : }
143 : :
144 : : // val = snd_ac97_read(ac97, AC97_RESET);
145 : 1 : val = ac97->caps;
146 [ + - ][ + - ]: 1 : snd_iprintf(buffer, "Capabilities :%s%s%s%s%s%s\n",
[ + - ][ + - ]
[ + - ][ + - ]
147 : 1 : val & AC97_BC_DEDICATED_MIC ? " -dedicated MIC PCM IN channel-" : "",
148 : 1 : val & AC97_BC_RESERVED1 ? " -reserved1-" : "",
149 : 1 : val & AC97_BC_BASS_TREBLE ? " -bass & treble-" : "",
150 : 1 : val & AC97_BC_SIM_STEREO ? " -simulated stereo-" : "",
151 : 1 : val & AC97_BC_HEADPHONE ? " -headphone out-" : "",
152 : 1 : val & AC97_BC_LOUDNESS ? " -loudness-" : "");
153 : 1 : tmp = ac97->caps & AC97_BC_DAC_MASK;
154 [ + - ][ - + ]: 1 : snd_iprintf(buffer, "DAC resolution : %s%s%s%s\n",
[ + - ][ + - ]
155 : : tmp == AC97_BC_16BIT_DAC ? "16-bit" : "",
156 : : tmp == AC97_BC_18BIT_DAC ? "18-bit" : "",
157 : : tmp == AC97_BC_20BIT_DAC ? "20-bit" : "",
158 : : tmp == AC97_BC_DAC_MASK ? "???" : "");
159 : 1 : tmp = ac97->caps & AC97_BC_ADC_MASK;
160 [ + - ][ - + ]: 1 : snd_iprintf(buffer, "ADC resolution : %s%s%s%s\n",
[ + - ][ + - ]
161 : : tmp == AC97_BC_16BIT_ADC ? "16-bit" : "",
162 : : tmp == AC97_BC_18BIT_ADC ? "18-bit" : "",
163 : : tmp == AC97_BC_20BIT_ADC ? "20-bit" : "",
164 : : tmp == AC97_BC_ADC_MASK ? "???" : "");
165 : 1 : snd_iprintf(buffer, "3D enhancement : %s\n",
166 : 1 : snd_ac97_stereo_enhancements[(val >> 10) & 0x1f]);
167 : 1 : snd_iprintf(buffer, "\nCurrent setup\n");
168 : 1 : val = snd_ac97_read(ac97, AC97_MIC);
169 [ + - ][ + - ]: 1 : snd_iprintf(buffer, "Mic gain : %s [%s]\n", val & 0x0040 ? "+20dB" : "+0dB", ac97->regs[AC97_MIC] & 0x0040 ? "+20dB" : "+0dB");
170 : 1 : val = snd_ac97_read(ac97, AC97_GENERAL_PURPOSE);
171 [ + - ][ + - ]: 1 : snd_iprintf(buffer, "POP path : %s 3D\n"
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
172 : : "Sim. stereo : %s\n"
173 : : "3D enhancement : %s\n"
174 : : "Loudness : %s\n"
175 : : "Mono output : %s\n"
176 : : "Mic select : %s\n"
177 : : "ADC/DAC loopback : %s\n",
178 : 1 : val & 0x8000 ? "post" : "pre",
179 : 1 : val & 0x4000 ? "on" : "off",
180 : 1 : val & 0x2000 ? "on" : "off",
181 : 1 : val & 0x1000 ? "on" : "off",
182 : 1 : val & 0x0200 ? "Mic" : "MIX",
183 : 1 : val & 0x0100 ? "Mic2" : "Mic1",
184 : 1 : val & 0x0080 ? "on" : "off");
185 [ - + ]: 1 : if (ac97->ext_id & AC97_EI_DRA)
186 : 0 : snd_iprintf(buffer, "Double rate slots: %s\n",
187 : 0 : double_rate_slots[(val >> 10) & 3]);
188 : :
189 : 1 : ext = snd_ac97_read(ac97, AC97_EXTENDED_ID);
190 [ + - ]: 1 : if (ext == 0)
191 : : goto __modem;
192 : :
193 [ + - ][ + - ]: 1 : snd_iprintf(buffer, "Extended ID : codec=%i rev=%i%s%s%s%s DSA=%i%s%s%s%s\n",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
194 : 1 : (ext & AC97_EI_ADDR_MASK) >> AC97_EI_ADDR_SHIFT,
195 : 1 : (ext & AC97_EI_REV_MASK) >> AC97_EI_REV_SHIFT,
196 : 1 : ext & AC97_EI_AMAP ? " AMAP" : "",
197 : 1 : ext & AC97_EI_LDAC ? " LDAC" : "",
198 : 1 : ext & AC97_EI_SDAC ? " SDAC" : "",
199 : 1 : ext & AC97_EI_CDAC ? " CDAC" : "",
200 : 1 : (ext & AC97_EI_DACS_SLOT_MASK) >> AC97_EI_DACS_SLOT_SHIFT,
201 : 1 : ext & AC97_EI_VRM ? " VRM" : "",
202 : 1 : ext & AC97_EI_SPDIF ? " SPDIF" : "",
203 : 1 : ext & AC97_EI_DRA ? " DRA" : "",
204 : 1 : ext & AC97_EI_VRA ? " VRA" : "");
205 : 1 : val = snd_ac97_read(ac97, AC97_EXTENDED_STATUS);
206 [ + - ][ + - ]: 1 : snd_iprintf(buffer, "Extended status :%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ - + ]
[ + - ][ + - ]
[ + - ][ - + ]
207 : 1 : val & AC97_EA_PRL ? " PRL" : "",
208 : 1 : val & AC97_EA_PRK ? " PRK" : "",
209 : 1 : val & AC97_EA_PRJ ? " PRJ" : "",
210 : 1 : val & AC97_EA_PRI ? " PRI" : "",
211 : 1 : val & AC97_EA_SPCV ? " SPCV" : "",
212 : 1 : val & AC97_EA_MDAC ? " MADC" : "",
213 : 1 : val & AC97_EA_LDAC ? " LDAC" : "",
214 : 1 : val & AC97_EA_SDAC ? " SDAC" : "",
215 : 1 : val & AC97_EA_CDAC ? " CDAC" : "",
216 : 0 : ext & AC97_EI_SPDIF ? spdif_slots[(val & AC97_EA_SPSA_SLOT_MASK) >> AC97_EA_SPSA_SLOT_SHIFT] : "",
217 : 1 : val & AC97_EA_VRM ? " VRM" : "",
218 : 1 : val & AC97_EA_SPDIF ? " SPDIF" : "",
219 : 1 : val & AC97_EA_DRA ? " DRA" : "",
220 : 1 : val & AC97_EA_VRA ? " VRA" : "");
221 [ + - ]: 1 : if (ext & AC97_EI_VRA) { /* VRA */
222 : 1 : val = snd_ac97_read(ac97, AC97_PCM_FRONT_DAC_RATE);
223 : 1 : snd_iprintf(buffer, "PCM front DAC : %iHz\n", val);
224 [ - + ]: 1 : if (ext & AC97_EI_SDAC) {
225 : 0 : val = snd_ac97_read(ac97, AC97_PCM_SURR_DAC_RATE);
226 : 0 : snd_iprintf(buffer, "PCM Surr DAC : %iHz\n", val);
227 : : }
228 [ - + ]: 1 : if (ext & AC97_EI_LDAC) {
229 : 0 : val = snd_ac97_read(ac97, AC97_PCM_LFE_DAC_RATE);
230 : 0 : snd_iprintf(buffer, "PCM LFE DAC : %iHz\n", val);
231 : : }
232 : 1 : val = snd_ac97_read(ac97, AC97_PCM_LR_ADC_RATE);
233 : 1 : snd_iprintf(buffer, "PCM ADC : %iHz\n", val);
234 : : }
235 [ - + ]: 1 : if (ext & AC97_EI_VRM) {
236 : 0 : val = snd_ac97_read(ac97, AC97_PCM_MIC_ADC_RATE);
237 : 0 : snd_iprintf(buffer, "PCM MIC ADC : %iHz\n", val);
238 : : }
239 [ + - ][ + - ]: 1 : if ((ext & AC97_EI_SPDIF) || (ac97->flags & AC97_CS_SPDIF) ||
[ - + ]
240 : 1 : (ac97->id == AC97_ID_YMF743)) {
241 [ # # ]: 0 : if (ac97->flags & AC97_CS_SPDIF)
242 : 0 : val = snd_ac97_read(ac97, AC97_CSR_SPDIF);
243 [ # # ]: 0 : else if (ac97->id == AC97_ID_YMF743) {
244 : 0 : val = snd_ac97_read(ac97, AC97_YMF7X3_DIT_CTRL);
245 : 0 : val = 0x2000 | (val & 0xff00) >> 4 | (val & 0x38) >> 2;
246 : : } else
247 : 0 : val = snd_ac97_read(ac97, AC97_SPDIF);
248 : :
249 [ # # ][ # # ]: 0 : snd_iprintf(buffer, "SPDIF Control :%s%s%s%s Category=0x%x Generation=%i%s%s%s\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
250 : 0 : val & AC97_SC_PRO ? " PRO" : " Consumer",
251 : 0 : val & AC97_SC_NAUDIO ? " Non-audio" : " PCM",
252 : 0 : val & AC97_SC_COPY ? "" : " Copyright",
253 : 0 : val & AC97_SC_PRE ? " Preemph50/15" : "",
254 : 0 : (val & AC97_SC_CC_MASK) >> AC97_SC_CC_SHIFT,
255 : 0 : (val & AC97_SC_L) >> 11,
256 : 0 : (ac97->flags & AC97_CS_SPDIF) ?
257 : 0 : spdif_rates_cs4205[(val & AC97_SC_SPSR_MASK) >> AC97_SC_SPSR_SHIFT] :
258 : 0 : spdif_rates[(val & AC97_SC_SPSR_MASK) >> AC97_SC_SPSR_SHIFT],
259 : : (ac97->flags & AC97_CS_SPDIF) ?
260 [ # # ]: 0 : (val & AC97_SC_DRS ? " Validity" : "") :
261 [ # # ]: 0 : (val & AC97_SC_DRS ? " DRS" : ""),
262 : : (ac97->flags & AC97_CS_SPDIF) ?
263 [ # # ]: 0 : (val & AC97_SC_V ? " Enabled" : "") :
264 [ # # ]: 0 : (val & AC97_SC_V ? " Validity" : ""));
265 : : /* ALC650 specific*/
266 [ # # # # ]: 0 : if ((ac97->id & 0xfffffff0) == 0x414c4720 &&
267 : 0 : (snd_ac97_read(ac97, AC97_ALC650_CLOCK) & 0x01)) {
268 : 0 : val = snd_ac97_read(ac97, AC97_ALC650_SPDIF_INPUT_STATUS2);
269 [ # # ]: 0 : if (val & AC97_ALC650_CLOCK_LOCK) {
270 : 0 : val = snd_ac97_read(ac97, AC97_ALC650_SPDIF_INPUT_STATUS1);
271 [ # # ][ # # ]: 0 : snd_iprintf(buffer, "SPDIF In Status :%s%s%s%s Category=0x%x Generation=%i",
[ # # ][ # # ]
272 : 0 : val & AC97_ALC650_PRO ? " PRO" : " Consumer",
273 : 0 : val & AC97_ALC650_NAUDIO ? " Non-audio" : " PCM",
274 : 0 : val & AC97_ALC650_COPY ? "" : " Copyright",
275 : 0 : val & AC97_ALC650_PRE ? " Preemph50/15" : "",
276 : 0 : (val & AC97_ALC650_CC_MASK) >> AC97_ALC650_CC_SHIFT,
277 : 0 : (val & AC97_ALC650_L) >> 15);
278 : 0 : val = snd_ac97_read(ac97, AC97_ALC650_SPDIF_INPUT_STATUS2);
279 [ # # ][ # # ]: 0 : snd_iprintf(buffer, "%s Accuracy=%i%s%s\n",
280 : 0 : spdif_rates[(val & AC97_ALC650_SPSR_MASK) >> AC97_ALC650_SPSR_SHIFT],
281 : 0 : (val & AC97_ALC650_CLOCK_ACCURACY) >> AC97_ALC650_CLOCK_SHIFT,
282 : 0 : (val & AC97_ALC650_CLOCK_LOCK ? " Locked" : " Unlocked"),
283 : 0 : (val & AC97_ALC650_V ? " Validity?" : ""));
284 : : } else {
285 : 0 : snd_iprintf(buffer, "SPDIF In Status : Not Locked\n");
286 : : }
287 : : }
288 : : }
289 [ - + ]: 1 : if ((ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23) {
290 : 0 : val = snd_ac97_read(ac97, AC97_INT_PAGING);
291 : 0 : snd_ac97_update_bits(ac97, AC97_INT_PAGING,
292 : : AC97_PAGE_MASK, AC97_PAGE_1);
293 : 0 : snd_ac97_proc_read_functions(ac97, buffer);
294 : 0 : snd_ac97_update_bits(ac97, AC97_INT_PAGING,
295 : : AC97_PAGE_MASK, val & AC97_PAGE_MASK);
296 : : }
297 : :
298 : :
299 : : __modem:
300 : 1 : mext = snd_ac97_read(ac97, AC97_EXTENDED_MID);
301 [ - + ]: 1 : if (mext == 0)
302 : 1 : return;
303 : :
304 [ # # ][ # # ]: 0 : snd_iprintf(buffer, "Extended modem ID: codec=%i%s%s%s%s%s\n",
[ # # ][ # # ]
[ # # ]
305 : 0 : (mext & AC97_MEI_ADDR_MASK) >> AC97_MEI_ADDR_SHIFT,
306 : 0 : mext & AC97_MEI_CID2 ? " CID2" : "",
307 : 0 : mext & AC97_MEI_CID1 ? " CID1" : "",
308 : 0 : mext & AC97_MEI_HANDSET ? " HSET" : "",
309 : 0 : mext & AC97_MEI_LINE2 ? " LIN2" : "",
310 : 0 : mext & AC97_MEI_LINE1 ? " LIN1" : "");
311 : 0 : val = snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS);
312 [ # # ][ # # ]: 0 : snd_iprintf(buffer, "Modem status :%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
313 : 0 : val & AC97_MEA_GPIO ? " GPIO" : "",
314 : 0 : val & AC97_MEA_MREF ? " MREF" : "",
315 : 0 : val & AC97_MEA_ADC1 ? " ADC1" : "",
316 : 0 : val & AC97_MEA_DAC1 ? " DAC1" : "",
317 : 0 : val & AC97_MEA_ADC2 ? " ADC2" : "",
318 : 0 : val & AC97_MEA_DAC2 ? " DAC2" : "",
319 : 0 : val & AC97_MEA_HADC ? " HADC" : "",
320 : 0 : val & AC97_MEA_HDAC ? " HDAC" : "",
321 : 0 : val & AC97_MEA_PRA ? " PRA(GPIO)" : "",
322 : 0 : val & AC97_MEA_PRB ? " PRB(res)" : "",
323 : 0 : val & AC97_MEA_PRC ? " PRC(ADC1)" : "",
324 : 0 : val & AC97_MEA_PRD ? " PRD(DAC1)" : "",
325 : 0 : val & AC97_MEA_PRE ? " PRE(ADC2)" : "",
326 : 0 : val & AC97_MEA_PRF ? " PRF(DAC2)" : "",
327 : 0 : val & AC97_MEA_PRG ? " PRG(HADC)" : "",
328 : 0 : val & AC97_MEA_PRH ? " PRH(HDAC)" : "");
329 [ # # ]: 0 : if (mext & AC97_MEI_LINE1) {
330 : 0 : val = snd_ac97_read(ac97, AC97_LINE1_RATE);
331 : 0 : snd_iprintf(buffer, "Line1 rate : %iHz\n", val);
332 : : }
333 [ # # ]: 0 : if (mext & AC97_MEI_LINE2) {
334 : 0 : val = snd_ac97_read(ac97, AC97_LINE2_RATE);
335 : 0 : snd_iprintf(buffer, "Line2 rate : %iHz\n", val);
336 : : }
337 [ # # ]: 0 : if (mext & AC97_MEI_HANDSET) {
338 : 0 : val = snd_ac97_read(ac97, AC97_HANDSET_RATE);
339 : 0 : snd_iprintf(buffer, "Headset rate : %iHz\n", val);
340 : : }
341 : : }
342 : :
343 : 0 : static void snd_ac97_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
344 : : {
345 : 1 : struct snd_ac97 *ac97 = entry->private_data;
346 : :
347 : 1 : mutex_lock(&ac97->page_mutex);
348 [ - + ]: 2 : if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) { // Analog Devices AD1881/85/86
349 : : int idx;
350 [ # # ]: 0 : for (idx = 0; idx < 3; idx++)
351 [ # # ]: 0 : if (ac97->spec.ad18xx.id[idx]) {
352 : : /* select single codec */
353 : 0 : snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
354 : 0 : ac97->spec.ad18xx.unchained[idx] | ac97->spec.ad18xx.chained[idx]);
355 : 0 : snd_ac97_proc_read_main(ac97, buffer, idx);
356 : 0 : snd_iprintf(buffer, "\n\n");
357 : : }
358 : : /* select all codecs */
359 : 0 : snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
360 : :
361 : 0 : snd_iprintf(buffer, "\nAD18XX configuration\n");
362 : 0 : snd_iprintf(buffer, "Unchained : 0x%04x,0x%04x,0x%04x\n",
363 : 0 : ac97->spec.ad18xx.unchained[0],
364 : 0 : ac97->spec.ad18xx.unchained[1],
365 : 0 : ac97->spec.ad18xx.unchained[2]);
366 : 0 : snd_iprintf(buffer, "Chained : 0x%04x,0x%04x,0x%04x\n",
367 : 0 : ac97->spec.ad18xx.chained[0],
368 : 0 : ac97->spec.ad18xx.chained[1],
369 : 0 : ac97->spec.ad18xx.chained[2]);
370 : : } else {
371 : 1 : snd_ac97_proc_read_main(ac97, buffer, 0);
372 : : }
373 : 1 : mutex_unlock(&ac97->page_mutex);
374 : 1 : }
375 : :
376 : : #ifdef CONFIG_SND_DEBUG
377 : : /* direct register write for debugging */
378 : : static void snd_ac97_proc_regs_write(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
379 : : {
380 : : struct snd_ac97 *ac97 = entry->private_data;
381 : : char line[64];
382 : : unsigned int reg, val;
383 : : mutex_lock(&ac97->page_mutex);
384 : : while (!snd_info_get_line(buffer, line, sizeof(line))) {
385 : : if (sscanf(line, "%x %x", ®, &val) != 2)
386 : : continue;
387 : : /* register must be even */
388 : : if (reg < 0x80 && (reg & 1) == 0 && val <= 0xffff)
389 : : snd_ac97_write_cache(ac97, reg, val);
390 : : }
391 : : mutex_unlock(&ac97->page_mutex);
392 : : }
393 : : #endif
394 : :
395 : 0 : static void snd_ac97_proc_regs_read_main(struct snd_ac97 *ac97, struct snd_info_buffer *buffer, int subidx)
396 : : {
397 : : int reg, val;
398 : :
399 [ + + ]: 65 : for (reg = 0; reg < 0x80; reg += 2) {
400 : 64 : val = snd_ac97_read(ac97, reg);
401 : 64 : snd_iprintf(buffer, "%i:%02x = %04x\n", subidx, reg, val);
402 : : }
403 : 1 : }
404 : :
405 : 0 : static void snd_ac97_proc_regs_read(struct snd_info_entry *entry,
406 : : struct snd_info_buffer *buffer)
407 : : {
408 : 1 : struct snd_ac97 *ac97 = entry->private_data;
409 : :
410 : 1 : mutex_lock(&ac97->page_mutex);
411 [ - + ]: 2 : if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) { // Analog Devices AD1881/85/86
412 : :
413 : : int idx;
414 [ # # ]: 0 : for (idx = 0; idx < 3; idx++)
415 [ # # ]: 0 : if (ac97->spec.ad18xx.id[idx]) {
416 : : /* select single codec */
417 : 0 : snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
418 : 0 : ac97->spec.ad18xx.unchained[idx] | ac97->spec.ad18xx.chained[idx]);
419 : 0 : snd_ac97_proc_regs_read_main(ac97, buffer, idx);
420 : : }
421 : : /* select all codecs */
422 : 0 : snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
423 : : } else {
424 : 1 : snd_ac97_proc_regs_read_main(ac97, buffer, 0);
425 : : }
426 : 1 : mutex_unlock(&ac97->page_mutex);
427 : 1 : }
428 : :
429 : 0 : void snd_ac97_proc_init(struct snd_ac97 * ac97)
430 : : {
431 : : struct snd_info_entry *entry;
432 : : char name[32];
433 : : const char *prefix;
434 : :
435 [ # # ]: 0 : if (ac97->bus->proc == NULL)
436 : 0 : return;
437 [ # # ]: 0 : prefix = ac97_is_audio(ac97) ? "ac97" : "mc97";
438 : 0 : sprintf(name, "%s#%d-%d", prefix, ac97->addr, ac97->num);
439 [ # # ]: 0 : if ((entry = snd_info_create_card_entry(ac97->bus->card, name, ac97->bus->proc)) != NULL) {
440 : : snd_info_set_text_ops(entry, ac97, snd_ac97_proc_read);
441 [ # # ]: 0 : if (snd_info_register(entry) < 0) {
442 : 0 : snd_info_free_entry(entry);
443 : : entry = NULL;
444 : : }
445 : : }
446 : 0 : ac97->proc = entry;
447 : 0 : sprintf(name, "%s#%d-%d+regs", prefix, ac97->addr, ac97->num);
448 [ # # ]: 0 : if ((entry = snd_info_create_card_entry(ac97->bus->card, name, ac97->bus->proc)) != NULL) {
449 : : snd_info_set_text_ops(entry, ac97, snd_ac97_proc_regs_read);
450 : : #ifdef CONFIG_SND_DEBUG
451 : : entry->mode |= S_IWUSR;
452 : : entry->c.text.write = snd_ac97_proc_regs_write;
453 : : #endif
454 [ # # ]: 0 : if (snd_info_register(entry) < 0) {
455 : 0 : snd_info_free_entry(entry);
456 : : entry = NULL;
457 : : }
458 : : }
459 : 0 : ac97->proc_regs = entry;
460 : : }
461 : :
462 : 0 : void snd_ac97_proc_done(struct snd_ac97 * ac97)
463 : : {
464 : 0 : snd_info_free_entry(ac97->proc_regs);
465 : 0 : ac97->proc_regs = NULL;
466 : 0 : snd_info_free_entry(ac97->proc);
467 : 0 : ac97->proc = NULL;
468 : 0 : }
469 : :
470 : 0 : void snd_ac97_bus_proc_init(struct snd_ac97_bus * bus)
471 : : {
472 : : struct snd_info_entry *entry;
473 : : char name[32];
474 : :
475 : 0 : sprintf(name, "codec97#%d", bus->num);
476 [ # # ]: 0 : if ((entry = snd_info_create_card_entry(bus->card, name, bus->card->proc_root)) != NULL) {
477 : 0 : entry->mode = S_IFDIR | S_IRUGO | S_IXUGO;
478 [ # # ]: 0 : if (snd_info_register(entry) < 0) {
479 : 0 : snd_info_free_entry(entry);
480 : : entry = NULL;
481 : : }
482 : : }
483 : 0 : bus->proc = entry;
484 : 0 : }
485 : :
486 : 0 : void snd_ac97_bus_proc_done(struct snd_ac97_bus * bus)
487 : : {
488 : 0 : snd_info_free_entry(bus->proc);
489 : 0 : bus->proc = NULL;
490 : 0 : }
|