patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / sound / pci / ac97 / ac97_proc.c
1 /*
2  *  Copyright (c) by Jaroslav Kysela <perex@suse.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 <sound/driver.h>
26 #include <linux/slab.h>
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 static void snd_ac97_proc_read_functions(ac97_t *ac97, snd_info_buffer_t *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         for (function = 0; function < 12; ++function) {
52                 snd_ac97_write(ac97, AC97_FUNC_SELECT, function << 1);
53                 info = snd_ac97_read(ac97, AC97_FUNC_INFO);
54                 if (!(info & 0x0001))
55                         continue;
56                 if (!header) {
57                         snd_iprintf(buffer, "\n                    Gain     Inverted  Buffer delay  Location\n");
58                         header = 1;
59                 }
60                 sense_info = snd_ac97_read(ac97, AC97_SENSE_INFO);
61                 snd_iprintf(buffer, "%-17s: %3d.%d dBV    %c      %2d/fs         %s\n",
62                             function_names[function],
63                             (info & 0x8000 ? -1 : 1) * ((info & 0x7000) >> 12) * 3 / 2,
64                             ((info & 0x0800) >> 11) * 5,
65                             info & 0x0400 ? 'X' : '-',
66                             (info & 0x03e0) >> 5,
67                             locations[sense_info >> 13]);
68         }
69 }
70
71 static void snd_ac97_proc_read_main(ac97_t *ac97, snd_info_buffer_t * buffer, int subidx)
72 {
73         char name[64];
74         unsigned short val, tmp, ext, mext;
75         static const char *spdif_slots[4] = { " SPDIF=3/4", " SPDIF=7/8", " SPDIF=6/9", " SPDIF=res" };
76         static const char *spdif_rates[4] = { " Rate=44.1kHz", " Rate=res", " Rate=48kHz", " Rate=32kHz" };
77         static const char *spdif_rates_cs4205[4] = { " Rate=48kHz", " Rate=44.1kHz", " Rate=res", " Rate=res" };
78
79         snd_ac97_get_name(NULL, ac97->id, name, 0);
80         snd_iprintf(buffer, "%d-%d/%d: %s\n\n", ac97->addr, ac97->num, subidx, name);
81         if ((ac97->scaps & AC97_SCAP_AUDIO) == 0)
82                 goto __modem;
83
84         if ((ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23) {
85                 val = snd_ac97_read(ac97, AC97_INT_PAGING);
86                 snd_ac97_update_bits(ac97, AC97_INT_PAGING,
87                                      AC97_PAGE_MASK, AC97_PAGE_1);
88                 tmp = snd_ac97_read(ac97, AC97_CODEC_CLASS_REV);
89                 snd_iprintf(buffer, "Revision         : 0x%02x\n", tmp & 0xff);
90                 snd_iprintf(buffer, "Compat. Class    : 0x%02x\n", (tmp >> 8) & 0x1f);
91                 snd_iprintf(buffer, "Subsys. Vendor ID: 0x%04x\n",
92                             snd_ac97_read(ac97, AC97_PCI_SVID));
93                 snd_iprintf(buffer, "Subsys. ID       : 0x%04x\n\n",
94                             snd_ac97_read(ac97, AC97_PCI_SID));
95                 snd_ac97_update_bits(ac97, AC97_INT_PAGING,
96                                      AC97_PAGE_MASK, val & AC97_PAGE_MASK);
97         }
98
99         // val = snd_ac97_read(ac97, AC97_RESET);
100         val = ac97->caps;
101         snd_iprintf(buffer, "Capabilities     :%s%s%s%s%s%s\n",
102                     val & AC97_BC_DEDICATED_MIC ? " -dedicated MIC PCM IN channel-" : "",
103                     val & AC97_BC_RESERVED1 ? " -reserved1-" : "",
104                     val & AC97_BC_BASS_TREBLE ? " -bass & treble-" : "",
105                     val & AC97_BC_SIM_STEREO ? " -simulated stereo-" : "",
106                     val & AC97_BC_HEADPHONE ? " -headphone out-" : "",
107                     val & AC97_BC_LOUDNESS ? " -loudness-" : "");
108         tmp = ac97->caps & AC97_BC_DAC_MASK;
109         snd_iprintf(buffer, "DAC resolution   : %s%s%s%s\n",
110                     tmp == AC97_BC_16BIT_DAC ? "16-bit" : "",
111                     tmp == AC97_BC_18BIT_DAC ? "18-bit" : "",
112                     tmp == AC97_BC_20BIT_DAC ? "20-bit" : "",
113                     tmp == AC97_BC_DAC_MASK ? "???" : "");
114         tmp = ac97->caps & AC97_BC_ADC_MASK;
115         snd_iprintf(buffer, "ADC resolution   : %s%s%s%s\n",
116                     tmp == AC97_BC_16BIT_ADC ? "16-bit" : "",
117                     tmp == AC97_BC_18BIT_ADC ? "18-bit" : "",
118                     tmp == AC97_BC_20BIT_ADC ? "20-bit" : "",
119                     tmp == AC97_BC_ADC_MASK ? "???" : "");
120         snd_iprintf(buffer, "3D enhancement   : %s\n",
121                 snd_ac97_stereo_enhancements[(val >> 10) & 0x1f]);
122         snd_iprintf(buffer, "\nCurrent setup\n");
123         val = snd_ac97_read(ac97, AC97_MIC);
124         snd_iprintf(buffer, "Mic gain         : %s [%s]\n", val & 0x0040 ? "+20dB" : "+0dB", ac97->regs[AC97_MIC] & 0x0040 ? "+20dB" : "+0dB");
125         val = snd_ac97_read(ac97, AC97_GENERAL_PURPOSE);
126         snd_iprintf(buffer, "POP path         : %s 3D\n"
127                     "Sim. stereo      : %s\n"
128                     "3D enhancement   : %s\n"
129                     "Loudness         : %s\n"
130                     "Mono output      : %s\n"
131                     "Mic select       : %s\n"
132                     "ADC/DAC loopback : %s\n",
133                     val & 0x8000 ? "post" : "pre",
134                     val & 0x4000 ? "on" : "off",
135                     val & 0x2000 ? "on" : "off",
136                     val & 0x1000 ? "on" : "off",
137                     val & 0x0200 ? "Mic" : "MIX",
138                     val & 0x0100 ? "Mic2" : "Mic1",
139                     val & 0x0080 ? "on" : "off");
140
141         ext = snd_ac97_read(ac97, AC97_EXTENDED_ID);
142         if (ext == 0)
143                 goto __modem;
144                 
145         snd_iprintf(buffer, "Extended ID      : codec=%i rev=%i%s%s%s%s DSA=%i%s%s%s%s\n",
146                         (ext & AC97_EI_ADDR_MASK) >> AC97_EI_ADDR_SHIFT,
147                         (ext & AC97_EI_REV_MASK) >> AC97_EI_REV_SHIFT,
148                         ext & AC97_EI_AMAP ? " AMAP" : "",
149                         ext & AC97_EI_LDAC ? " LDAC" : "",
150                         ext & AC97_EI_SDAC ? " SDAC" : "",
151                         ext & AC97_EI_CDAC ? " CDAC" : "",
152                         (ext & AC97_EI_DACS_SLOT_MASK) >> AC97_EI_DACS_SLOT_SHIFT,
153                         ext & AC97_EI_VRM ? " VRM" : "",
154                         ext & AC97_EI_SPDIF ? " SPDIF" : "",
155                         ext & AC97_EI_DRA ? " DRA" : "",
156                         ext & AC97_EI_VRA ? " VRA" : "");
157         val = snd_ac97_read(ac97, AC97_EXTENDED_STATUS);
158         snd_iprintf(buffer, "Extended status  :%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
159                         val & AC97_EA_PRL ? " PRL" : "",
160                         val & AC97_EA_PRK ? " PRK" : "",
161                         val & AC97_EA_PRJ ? " PRJ" : "",
162                         val & AC97_EA_PRI ? " PRI" : "",
163                         val & AC97_EA_SPCV ? " SPCV" : "",
164                         val & AC97_EA_MDAC ? " MADC" : "",
165                         val & AC97_EA_LDAC ? " LDAC" : "",
166                         val & AC97_EA_SDAC ? " SDAC" : "",
167                         val & AC97_EA_CDAC ? " CDAC" : "",
168                         ext & AC97_EI_SPDIF ? spdif_slots[(val & AC97_EA_SPSA_SLOT_MASK) >> AC97_EA_SPSA_SLOT_SHIFT] : "",
169                         val & AC97_EA_VRM ? " VRM" : "",
170                         val & AC97_EA_SPDIF ? " SPDIF" : "",
171                         val & AC97_EA_DRA ? " DRA" : "",
172                         val & AC97_EA_VRA ? " VRA" : "");
173         if (ext & AC97_EI_VRA) {        /* VRA */
174                 val = snd_ac97_read(ac97, AC97_PCM_FRONT_DAC_RATE);
175                 snd_iprintf(buffer, "PCM front DAC    : %iHz\n", val);
176                 if (ext & AC97_EI_SDAC) {
177                         val = snd_ac97_read(ac97, AC97_PCM_SURR_DAC_RATE);
178                         snd_iprintf(buffer, "PCM Surr DAC     : %iHz\n", val);
179                 }
180                 if (ext & AC97_EI_LDAC) {
181                         val = snd_ac97_read(ac97, AC97_PCM_LFE_DAC_RATE);
182                         snd_iprintf(buffer, "PCM LFE DAC      : %iHz\n", val);
183                 }
184                 val = snd_ac97_read(ac97, AC97_PCM_LR_ADC_RATE);
185                 snd_iprintf(buffer, "PCM ADC          : %iHz\n", val);
186         }
187         if (ext & AC97_EI_VRM) {
188                 val = snd_ac97_read(ac97, AC97_PCM_MIC_ADC_RATE);
189                 snd_iprintf(buffer, "PCM MIC ADC      : %iHz\n", val);
190         }
191         if ((ext & AC97_EI_SPDIF) || (ac97->flags & AC97_CS_SPDIF)) {
192                 if (ac97->flags & AC97_CS_SPDIF)
193                         val = snd_ac97_read(ac97, AC97_CSR_SPDIF);
194                 else
195                         val = snd_ac97_read(ac97, AC97_SPDIF);
196
197                 snd_iprintf(buffer, "SPDIF Control    :%s%s%s%s Category=0x%x Generation=%i%s%s%s\n",
198                         val & AC97_SC_PRO ? " PRO" : " Consumer",
199                         val & AC97_SC_NAUDIO ? " Non-audio" : " PCM",
200                         val & AC97_SC_COPY ? "" : " Copyright",
201                         val & AC97_SC_PRE ? " Preemph50/15" : "",
202                         (val & AC97_SC_CC_MASK) >> AC97_SC_CC_SHIFT,
203                         (val & AC97_SC_L) >> 11,
204                         (ac97->flags & AC97_CS_SPDIF) ?
205                             spdif_rates_cs4205[(val & AC97_SC_SPSR_MASK) >> AC97_SC_SPSR_SHIFT] :
206                             spdif_rates[(val & AC97_SC_SPSR_MASK) >> AC97_SC_SPSR_SHIFT],
207                         (ac97->flags & AC97_CS_SPDIF) ?
208                             (val & AC97_SC_DRS ? " Validity" : "") :
209                             (val & AC97_SC_DRS ? " DRS" : ""),
210                         (ac97->flags & AC97_CS_SPDIF) ?
211                             (val & AC97_SC_V ? " Enabled" : "") :
212                             (val & AC97_SC_V ? " Validity" : ""));
213                 /* ALC650 specific*/
214                 if ((ac97->id & 0xfffffff0) == 0x414c4720 &&
215                     (snd_ac97_read(ac97, AC97_ALC650_CLOCK) & 0x01)) {
216                         val = snd_ac97_read(ac97, AC97_ALC650_SPDIF_INPUT_STATUS2);
217                         if (val & AC97_ALC650_CLOCK_LOCK) {
218                                 val = snd_ac97_read(ac97, AC97_ALC650_SPDIF_INPUT_STATUS1);
219                                 snd_iprintf(buffer, "SPDIF In Status  :%s%s%s%s Category=0x%x Generation=%i",
220                                             val & AC97_ALC650_PRO ? " PRO" : " Consumer",
221                                             val & AC97_ALC650_NAUDIO ? " Non-audio" : " PCM",
222                                             val & AC97_ALC650_COPY ? "" : " Copyright",
223                                             val & AC97_ALC650_PRE ? " Preemph50/15" : "",
224                                             (val & AC97_ALC650_CC_MASK) >> AC97_ALC650_CC_SHIFT,
225                                             (val & AC97_ALC650_L) >> 15);
226                                 val = snd_ac97_read(ac97, AC97_ALC650_SPDIF_INPUT_STATUS2);
227                                 snd_iprintf(buffer, "%s Accuracy=%i%s%s\n",
228                                             spdif_rates[(val & AC97_ALC650_SPSR_MASK) >> AC97_ALC650_SPSR_SHIFT],
229                                             (val & AC97_ALC650_CLOCK_ACCURACY) >> AC97_ALC650_CLOCK_SHIFT,
230                                             (val & AC97_ALC650_CLOCK_LOCK ? " Locked" : " Unlocked"),
231                                             (val & AC97_ALC650_V ? " Validity?" : ""));
232                         } else {
233                                 snd_iprintf(buffer, "SPDIF In Status  : Not Locked\n");
234                         }
235                 }
236         }
237         if ((ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23) {
238                 val = snd_ac97_read(ac97, AC97_INT_PAGING);
239                 snd_ac97_update_bits(ac97, AC97_INT_PAGING,
240                                      AC97_PAGE_MASK, AC97_PAGE_1);
241                 snd_ac97_proc_read_functions(ac97, buffer);
242                 snd_ac97_update_bits(ac97, AC97_INT_PAGING,
243                                      AC97_PAGE_MASK, val & AC97_PAGE_MASK);
244         }
245
246
247       __modem:
248         mext = snd_ac97_read(ac97, AC97_EXTENDED_MID);
249         if (mext == 0)
250                 return;
251         
252         snd_iprintf(buffer, "Extended modem ID: codec=%i%s%s%s%s%s\n",
253                         (mext & AC97_MEI_ADDR_MASK) >> AC97_MEI_ADDR_SHIFT,
254                         mext & AC97_MEI_CID2 ? " CID2" : "",
255                         mext & AC97_MEI_CID1 ? " CID1" : "",
256                         mext & AC97_MEI_HANDSET ? " HSET" : "",
257                         mext & AC97_MEI_LINE2 ? " LIN2" : "",
258                         mext & AC97_MEI_LINE1 ? " LIN1" : "");
259         val = snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS);
260         snd_iprintf(buffer, "Modem status     :%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
261                         val & AC97_MEA_GPIO ? " GPIO" : "",
262                         val & AC97_MEA_MREF ? " MREF" : "",
263                         val & AC97_MEA_ADC1 ? " ADC1" : "",
264                         val & AC97_MEA_DAC1 ? " DAC1" : "",
265                         val & AC97_MEA_ADC2 ? " ADC2" : "",
266                         val & AC97_MEA_DAC2 ? " DAC2" : "",
267                         val & AC97_MEA_HADC ? " HADC" : "",
268                         val & AC97_MEA_HDAC ? " HDAC" : "",
269                         val & AC97_MEA_PRA ? " PRA(GPIO)" : "",
270                         val & AC97_MEA_PRB ? " PRB(res)" : "",
271                         val & AC97_MEA_PRC ? " PRC(ADC1)" : "",
272                         val & AC97_MEA_PRD ? " PRD(DAC1)" : "",
273                         val & AC97_MEA_PRE ? " PRE(ADC2)" : "",
274                         val & AC97_MEA_PRF ? " PRF(DAC2)" : "",
275                         val & AC97_MEA_PRG ? " PRG(HADC)" : "",
276                         val & AC97_MEA_PRH ? " PRH(HDAC)" : "");
277         if (mext & AC97_MEI_LINE1) {
278                 val = snd_ac97_read(ac97, AC97_LINE1_RATE);
279                 snd_iprintf(buffer, "Line1 rate       : %iHz\n", val);
280         }
281         if (mext & AC97_MEI_LINE2) {
282                 val = snd_ac97_read(ac97, AC97_LINE2_RATE);
283                 snd_iprintf(buffer, "Line2 rate       : %iHz\n", val);
284         }
285         if (mext & AC97_MEI_HANDSET) {
286                 val = snd_ac97_read(ac97, AC97_HANDSET_RATE);
287                 snd_iprintf(buffer, "Headset rate     : %iHz\n", val);
288         }
289 }
290
291 static void snd_ac97_proc_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer)
292 {
293         ac97_t *ac97 = snd_magic_cast(ac97_t, entry->private_data, return);
294         
295         if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) {        // Analog Devices AD1881/85/86
296                 int idx;
297                 down(&ac97->spec.ad18xx.mutex);
298                 for (idx = 0; idx < 3; idx++)
299                         if (ac97->spec.ad18xx.id[idx]) {
300                                 /* select single codec */
301                                 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
302                                                      ac97->spec.ad18xx.unchained[idx] | ac97->spec.ad18xx.chained[idx]);
303                                 snd_ac97_proc_read_main(ac97, buffer, idx);
304                                 snd_iprintf(buffer, "\n\n");
305                         }
306                 /* select all codecs */
307                 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
308                 up(&ac97->spec.ad18xx.mutex);
309                 
310                 snd_iprintf(buffer, "\nAD18XX configuration\n");
311                 snd_iprintf(buffer, "Unchained        : 0x%04x,0x%04x,0x%04x\n",
312                         ac97->spec.ad18xx.unchained[0],
313                         ac97->spec.ad18xx.unchained[1],
314                         ac97->spec.ad18xx.unchained[2]);
315                 snd_iprintf(buffer, "Chained          : 0x%04x,0x%04x,0x%04x\n",
316                         ac97->spec.ad18xx.chained[0],
317                         ac97->spec.ad18xx.chained[1],
318                         ac97->spec.ad18xx.chained[2]);
319         } else {
320                 snd_ac97_proc_read_main(ac97, buffer, 0);
321         }
322 }
323
324 #ifdef CONFIG_SND_DEBUG
325 /* direct register write for debugging */
326 static void snd_ac97_proc_regs_write(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
327 {
328         ac97_t *ac97 = snd_magic_cast(ac97_t, entry->private_data, return);
329         char line[64];
330         unsigned int reg, val;
331         while (!snd_info_get_line(buffer, line, sizeof(line))) {
332                 if (sscanf(line, "%x %x", &reg, &val) != 2)
333                         continue;
334                 /* register must be odd */
335                 if (reg < 0x80 && (reg & 1) == 0 && val <= 0xffff)
336                         snd_ac97_write_cache(ac97, reg, val);
337         }
338 }
339 #endif
340
341 static void snd_ac97_proc_regs_read_main(ac97_t *ac97, snd_info_buffer_t * buffer, int subidx)
342 {
343         int reg, val;
344
345         for (reg = 0; reg < 0x80; reg += 2) {
346                 val = snd_ac97_read(ac97, reg);
347                 snd_iprintf(buffer, "%i:%02x = %04x\n", subidx, reg, val);
348         }
349 }
350
351 static void snd_ac97_proc_regs_read(snd_info_entry_t *entry, 
352                                     snd_info_buffer_t * buffer)
353 {
354         ac97_t *ac97 = snd_magic_cast(ac97_t, entry->private_data, return);
355
356         if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) {        // Analog Devices AD1881/85/86
357
358                 int idx;
359                 down(&ac97->spec.ad18xx.mutex);
360                 for (idx = 0; idx < 3; idx++)
361                         if (ac97->spec.ad18xx.id[idx]) {
362                                 /* select single codec */
363                                 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
364                                                      ac97->spec.ad18xx.unchained[idx] | ac97->spec.ad18xx.chained[idx]);
365                                 snd_ac97_proc_regs_read_main(ac97, buffer, idx);
366                         }
367                 /* select all codecs */
368                 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
369                 up(&ac97->spec.ad18xx.mutex);
370         } else {
371                 snd_ac97_proc_regs_read_main(ac97, buffer, 0);
372         }       
373 }
374
375 void snd_ac97_proc_init(ac97_t * ac97)
376 {
377         snd_info_entry_t *entry;
378         char name[32];
379         const char *prefix;
380
381         if (ac97->bus->proc == NULL)
382                 return;
383         prefix = ac97_is_audio(ac97) ? "ac97" : "mc97";
384         sprintf(name, "%s#%d-%d", prefix, ac97->addr, ac97->num);
385         if ((entry = snd_info_create_card_entry(ac97->bus->card, name, ac97->bus->proc)) != NULL) {
386                 snd_info_set_text_ops(entry, ac97, 1024, snd_ac97_proc_read);
387                 if (snd_info_register(entry) < 0) {
388                         snd_info_free_entry(entry);
389                         entry = NULL;
390                 }
391         }
392         ac97->proc = entry;
393         sprintf(name, "%s#%d-%d+regs", prefix, ac97->addr, ac97->num);
394         if ((entry = snd_info_create_card_entry(ac97->bus->card, name, ac97->bus->proc)) != NULL) {
395                 snd_info_set_text_ops(entry, ac97, 1024, snd_ac97_proc_regs_read);
396 #ifdef CONFIG_SND_DEBUG
397                 entry->mode |= S_IWUSR;
398                 entry->c.text.write_size = 1024;
399                 entry->c.text.write = snd_ac97_proc_regs_write;
400 #endif
401                 if (snd_info_register(entry) < 0) {
402                         snd_info_free_entry(entry);
403                         entry = NULL;
404                 }
405         }
406         ac97->proc_regs = entry;
407 }
408
409 void snd_ac97_proc_done(ac97_t * ac97)
410 {
411         if (ac97->proc_regs) {
412                 snd_info_unregister(ac97->proc_regs);
413                 ac97->proc_regs = NULL;
414         }
415         if (ac97->proc) {
416                 snd_info_unregister(ac97->proc);
417                 ac97->proc = NULL;
418         }
419 }
420
421 void snd_ac97_bus_proc_init(ac97_bus_t * bus)
422 {
423         snd_info_entry_t *entry;
424         char name[32];
425
426         sprintf(name, "codec97#%d", bus->num);
427         if ((entry = snd_info_create_card_entry(bus->card, name, bus->card->proc_root)) != NULL) {
428                 entry->mode = S_IFDIR | S_IRUGO | S_IXUGO;
429                 if (snd_info_register(entry) < 0) {
430                         snd_info_free_entry(entry);
431                         entry = NULL;
432                 }
433         }
434         bus->proc = entry;
435 }
436
437 void snd_ac97_bus_proc_done(ac97_bus_t * bus)
438 {
439         if (bus->proc) {
440                 snd_info_unregister(bus->proc);
441                 bus->proc = NULL;
442         }
443 }