]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - sound/pci/hda/hda_proc.c
Merge branch 'topic/fix/hda' into topic/hda
[linux-2.6-omap-h63xx.git] / sound / pci / hda / hda_proc.c
1 /*
2  * Universal Interface for Intel High Definition Audio Codec
3  * 
4  * Generic proc interface
5  *
6  * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
7  *
8  *
9  *  This driver 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 driver 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 #include <linux/init.h>
25 #include <sound/core.h>
26 #include "hda_codec.h"
27 #include "hda_local.h"
28
29 static const char *get_wid_type_name(unsigned int wid_value)
30 {
31         static char *names[16] = {
32                 [AC_WID_AUD_OUT] = "Audio Output",
33                 [AC_WID_AUD_IN] = "Audio Input",
34                 [AC_WID_AUD_MIX] = "Audio Mixer",
35                 [AC_WID_AUD_SEL] = "Audio Selector",
36                 [AC_WID_PIN] = "Pin Complex",
37                 [AC_WID_POWER] = "Power Widget",
38                 [AC_WID_VOL_KNB] = "Volume Knob Widget",
39                 [AC_WID_BEEP] = "Beep Generator Widget",
40                 [AC_WID_VENDOR] = "Vendor Defined Widget",
41         };
42         wid_value &= 0xf;
43         if (names[wid_value])
44                 return names[wid_value];
45         else
46                 return "UNKNOWN Widget";
47 }
48
49 static void print_amp_caps(struct snd_info_buffer *buffer,
50                            struct hda_codec *codec, hda_nid_t nid, int dir)
51 {
52         unsigned int caps;
53         caps = snd_hda_param_read(codec, nid,
54                                   dir == HDA_OUTPUT ?
55                                     AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP);
56         if (caps == -1 || caps == 0) {
57                 snd_iprintf(buffer, "N/A\n");
58                 return;
59         }
60         snd_iprintf(buffer, "ofs=0x%02x, nsteps=0x%02x, stepsize=0x%02x, "
61                     "mute=%x\n",
62                     caps & AC_AMPCAP_OFFSET,
63                     (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT,
64                     (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT,
65                     (caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT);
66 }
67
68 static void print_amp_vals(struct snd_info_buffer *buffer,
69                            struct hda_codec *codec, hda_nid_t nid,
70                            int dir, int stereo, int indices)
71 {
72         unsigned int val;
73         int i;
74
75         dir = dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
76         for (i = 0; i < indices; i++) {
77                 snd_iprintf(buffer, " [");
78                 if (stereo) {
79                         val = snd_hda_codec_read(codec, nid, 0,
80                                                  AC_VERB_GET_AMP_GAIN_MUTE,
81                                                  AC_AMP_GET_LEFT | dir | i);
82                         snd_iprintf(buffer, "0x%02x ", val);
83                 }
84                 val = snd_hda_codec_read(codec, nid, 0,
85                                          AC_VERB_GET_AMP_GAIN_MUTE,
86                                          AC_AMP_GET_RIGHT | dir | i);
87                 snd_iprintf(buffer, "0x%02x]", val);
88         }
89         snd_iprintf(buffer, "\n");
90 }
91
92 void snd_print_pcm_rates(int pcm, char *buf, int buflen)
93 {
94         static unsigned int rates[] = {
95                 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
96                 96000, 176400, 192000, 384000
97         };
98         int i, j;
99
100         for (i = 0, j = 0; i < ARRAY_SIZE(rates); i++)
101                 if (pcm & (1 << i))
102                         j += snprintf(buf + j, buflen - j,  " %d", rates[i]);
103
104         buf[j] = '\0'; /* necessary when j == 0 */
105 }
106
107 static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
108 {
109         char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
110
111         pcm &= AC_SUPPCM_RATES;
112         snd_iprintf(buffer, "    rates [0x%x]:", pcm);
113         snd_print_pcm_rates(pcm, buf, sizeof(buf));
114         snd_iprintf(buffer, "%s\n", buf);
115 }
116
117 void snd_print_pcm_bits(int pcm, char *buf, int buflen)
118 {
119         static unsigned int bits[] = { 8, 16, 20, 24, 32 };
120         int i, j;
121
122         for (i = 0, j = 0; i < ARRAY_SIZE(bits); i++)
123                 if (pcm & (AC_SUPPCM_BITS_8 << i))
124                         j += snprintf(buf + j, buflen - j,  " %d", bits[i]);
125
126         buf[j] = '\0'; /* necessary when j == 0 */
127 }
128
129 static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)
130 {
131         char buf[SND_PRINT_BITS_ADVISED_BUFSIZE];
132
133         snd_iprintf(buffer, "    bits [0x%x]:", pcm);
134         snd_print_pcm_bits(pcm, buf, sizeof(buf));
135         snd_iprintf(buffer, "%s\n", buf);
136 }
137
138 static void print_pcm_formats(struct snd_info_buffer *buffer,
139                               unsigned int streams)
140 {
141         snd_iprintf(buffer, "    formats [0x%x]:", streams & 0xf);
142         if (streams & AC_SUPFMT_PCM)
143                 snd_iprintf(buffer, " PCM");
144         if (streams & AC_SUPFMT_FLOAT32)
145                 snd_iprintf(buffer, " FLOAT");
146         if (streams & AC_SUPFMT_AC3)
147                 snd_iprintf(buffer, " AC3");
148         snd_iprintf(buffer, "\n");
149 }
150
151 static void print_pcm_caps(struct snd_info_buffer *buffer,
152                            struct hda_codec *codec, hda_nid_t nid)
153 {
154         unsigned int pcm = snd_hda_param_read(codec, nid, AC_PAR_PCM);
155         unsigned int stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
156         if (pcm == -1 || stream == -1) {
157                 snd_iprintf(buffer, "N/A\n");
158                 return;
159         }
160         print_pcm_rates(buffer, pcm);
161         print_pcm_bits(buffer, pcm);
162         print_pcm_formats(buffer, stream);
163 }
164
165 static const char *get_jack_connection(u32 cfg)
166 {
167         static char *names[16] = {
168                 "Unknown", "1/8", "1/4", "ATAPI",
169                 "RCA", "Optical","Digital", "Analog",
170                 "DIN", "XLR", "RJ11", "Comb",
171                 NULL, NULL, NULL, "Other"
172         };
173         cfg = (cfg & AC_DEFCFG_CONN_TYPE) >> AC_DEFCFG_CONN_TYPE_SHIFT;
174         if (names[cfg])
175                 return names[cfg];
176         else
177                 return "UNKNOWN";
178 }
179
180 static const char *get_jack_color(u32 cfg)
181 {
182         static char *names[16] = {
183                 "Unknown", "Black", "Grey", "Blue",
184                 "Green", "Red", "Orange", "Yellow",
185                 "Purple", "Pink", NULL, NULL,
186                 NULL, NULL, "White", "Other",
187         };
188         cfg = (cfg & AC_DEFCFG_COLOR) >> AC_DEFCFG_COLOR_SHIFT;
189         if (names[cfg])
190                 return names[cfg];
191         else
192                 return "UNKNOWN";
193 }
194
195 static void print_pin_caps(struct snd_info_buffer *buffer,
196                            struct hda_codec *codec, hda_nid_t nid,
197                            int *supports_vref)
198 {
199         static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" };
200         unsigned int caps, val;
201
202         caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
203         snd_iprintf(buffer, "  Pincap 0x%08x:", caps);
204         if (caps & AC_PINCAP_IN)
205                 snd_iprintf(buffer, " IN");
206         if (caps & AC_PINCAP_OUT)
207                 snd_iprintf(buffer, " OUT");
208         if (caps & AC_PINCAP_HP_DRV)
209                 snd_iprintf(buffer, " HP");
210         if (caps & AC_PINCAP_EAPD)
211                 snd_iprintf(buffer, " EAPD");
212         if (caps & AC_PINCAP_PRES_DETECT)
213                 snd_iprintf(buffer, " Detect");
214         if (caps & AC_PINCAP_BALANCE)
215                 snd_iprintf(buffer, " Balanced");
216         if (caps & AC_PINCAP_HDMI) {
217                 /* Realtek uses this bit as a different meaning */
218                 if ((codec->vendor_id >> 16) == 0x10ec)
219                         snd_iprintf(buffer, " R/L");
220                 else
221                         snd_iprintf(buffer, " HDMI");
222         }
223         if (caps & AC_PINCAP_TRIG_REQ)
224                 snd_iprintf(buffer, " Trigger");
225         if (caps & AC_PINCAP_IMP_SENSE)
226                 snd_iprintf(buffer, " ImpSense");
227         snd_iprintf(buffer, "\n");
228         if (caps & AC_PINCAP_VREF) {
229                 unsigned int vref =
230                         (caps & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
231                 snd_iprintf(buffer, "    Vref caps:");
232                 if (vref & AC_PINCAP_VREF_HIZ)
233                         snd_iprintf(buffer, " HIZ");
234                 if (vref & AC_PINCAP_VREF_50)
235                         snd_iprintf(buffer, " 50");
236                 if (vref & AC_PINCAP_VREF_GRD)
237                         snd_iprintf(buffer, " GRD");
238                 if (vref & AC_PINCAP_VREF_80)
239                         snd_iprintf(buffer, " 80");
240                 if (vref & AC_PINCAP_VREF_100)
241                         snd_iprintf(buffer, " 100");
242                 snd_iprintf(buffer, "\n");
243                 *supports_vref = 1;
244         } else
245                 *supports_vref = 0;
246         if (caps & AC_PINCAP_EAPD) {
247                 val = snd_hda_codec_read(codec, nid, 0,
248                                          AC_VERB_GET_EAPD_BTLENABLE, 0);
249                 snd_iprintf(buffer, "  EAPD 0x%x:", val);
250                 if (val & AC_EAPDBTL_BALANCED)
251                         snd_iprintf(buffer, " BALANCED");
252                 if (val & AC_EAPDBTL_EAPD)
253                         snd_iprintf(buffer, " EAPD");
254                 if (val & AC_EAPDBTL_LR_SWAP)
255                         snd_iprintf(buffer, " R/L");
256                 snd_iprintf(buffer, "\n");
257         }
258         caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
259         snd_iprintf(buffer, "  Pin Default 0x%08x: [%s] %s at %s %s\n", caps,
260                     jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT],
261                     snd_hda_get_jack_type(caps),
262                     snd_hda_get_jack_connectivity(caps),
263                     snd_hda_get_jack_location(caps));
264         snd_iprintf(buffer, "    Conn = %s, Color = %s\n",
265                     get_jack_connection(caps),
266                     get_jack_color(caps));
267         /* Default association and sequence values refer to default grouping
268          * of pin complexes and their sequence within the group. This is used
269          * for priority and resource allocation.
270          */
271         snd_iprintf(buffer, "    DefAssociation = 0x%x, Sequence = 0x%x\n",
272                     (caps & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT,
273                     caps & AC_DEFCFG_SEQUENCE);
274         if (((caps & AC_DEFCFG_MISC) >> AC_DEFCFG_MISC_SHIFT) &
275             AC_DEFCFG_MISC_NO_PRESENCE) {
276                 /* Miscellaneous bit indicates external hardware does not
277                  * support presence detection even if the pin complex
278                  * indicates it is supported.
279                  */
280                 snd_iprintf(buffer, "    Misc = NO_PRESENCE\n");
281         }
282 }
283
284 static void print_pin_ctls(struct snd_info_buffer *buffer,
285                            struct hda_codec *codec, hda_nid_t nid,
286                            int supports_vref)
287 {
288         unsigned int pinctls;
289
290         pinctls = snd_hda_codec_read(codec, nid, 0,
291                                      AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
292         snd_iprintf(buffer, "  Pin-ctls: 0x%02x:", pinctls);
293         if (pinctls & AC_PINCTL_IN_EN)
294                 snd_iprintf(buffer, " IN");
295         if (pinctls & AC_PINCTL_OUT_EN)
296                 snd_iprintf(buffer, " OUT");
297         if (pinctls & AC_PINCTL_HP_EN)
298                 snd_iprintf(buffer, " HP");
299         if (supports_vref) {
300                 int vref = pinctls & AC_PINCTL_VREFEN;
301                 switch (vref) {
302                 case AC_PINCTL_VREF_HIZ:
303                         snd_iprintf(buffer, " VREF_HIZ");
304                         break;
305                 case AC_PINCTL_VREF_50:
306                         snd_iprintf(buffer, " VREF_50");
307                         break;
308                 case AC_PINCTL_VREF_GRD:
309                         snd_iprintf(buffer, " VREF_GRD");
310                         break;
311                 case AC_PINCTL_VREF_80:
312                         snd_iprintf(buffer, " VREF_80");
313                         break;
314                 case AC_PINCTL_VREF_100:
315                         snd_iprintf(buffer, " VREF_100");
316                         break;
317                 }
318         }
319         snd_iprintf(buffer, "\n");
320 }
321
322 static void print_vol_knob(struct snd_info_buffer *buffer,
323                            struct hda_codec *codec, hda_nid_t nid)
324 {
325         unsigned int cap = snd_hda_param_read(codec, nid,
326                                               AC_PAR_VOL_KNB_CAP);
327         snd_iprintf(buffer, "  Volume-Knob: delta=%d, steps=%d, ",
328                     (cap >> 7) & 1, cap & 0x7f);
329         cap = snd_hda_codec_read(codec, nid, 0,
330                                  AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
331         snd_iprintf(buffer, "direct=%d, val=%d\n",
332                     (cap >> 7) & 1, cap & 0x7f);
333 }
334
335 static void print_audio_io(struct snd_info_buffer *buffer,
336                            struct hda_codec *codec, hda_nid_t nid,
337                            unsigned int wid_type)
338 {
339         int conv = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
340         snd_iprintf(buffer,
341                     "  Converter: stream=%d, channel=%d\n",
342                     (conv & AC_CONV_STREAM) >> AC_CONV_STREAM_SHIFT,
343                     conv & AC_CONV_CHANNEL);
344
345         if (wid_type == AC_WID_AUD_IN && (conv & AC_CONV_CHANNEL) == 0) {
346                 int sdi = snd_hda_codec_read(codec, nid, 0,
347                                              AC_VERB_GET_SDI_SELECT, 0);
348                 snd_iprintf(buffer, "  SDI-Select: %d\n",
349                             sdi & AC_SDI_SELECT);
350         }
351 }
352
353 static void print_digital_conv(struct snd_info_buffer *buffer,
354                                struct hda_codec *codec, hda_nid_t nid)
355 {
356         unsigned int digi1 = snd_hda_codec_read(codec, nid, 0,
357                                                 AC_VERB_GET_DIGI_CONVERT_1, 0);
358         snd_iprintf(buffer, "  Digital:");
359         if (digi1 & AC_DIG1_ENABLE)
360                 snd_iprintf(buffer, " Enabled");
361         if (digi1 & AC_DIG1_V)
362                 snd_iprintf(buffer, " Validity");
363         if (digi1 & AC_DIG1_VCFG)
364                 snd_iprintf(buffer, " ValidityCfg");
365         if (digi1 & AC_DIG1_EMPHASIS)
366                 snd_iprintf(buffer, " Preemphasis");
367         if (digi1 & AC_DIG1_COPYRIGHT)
368                 snd_iprintf(buffer, " Copyright");
369         if (digi1 & AC_DIG1_NONAUDIO)
370                 snd_iprintf(buffer, " Non-Audio");
371         if (digi1 & AC_DIG1_PROFESSIONAL)
372                 snd_iprintf(buffer, " Pro");
373         if (digi1 & AC_DIG1_LEVEL)
374                 snd_iprintf(buffer, " GenLevel");
375         snd_iprintf(buffer, "\n");
376         snd_iprintf(buffer, "  Digital category: 0x%x\n",
377                     (digi1 >> 8) & AC_DIG2_CC);
378 }
379
380 static const char *get_pwr_state(u32 state)
381 {
382         static const char *buf[4] = {
383                 "D0", "D1", "D2", "D3"
384         };
385         if (state < 4)
386                 return buf[state];
387         return "UNKNOWN";
388 }
389
390 static void print_power_state(struct snd_info_buffer *buffer,
391                               struct hda_codec *codec, hda_nid_t nid)
392 {
393         int pwr = snd_hda_codec_read(codec, nid, 0,
394                                      AC_VERB_GET_POWER_STATE, 0);
395         snd_iprintf(buffer, "  Power: setting=%s, actual=%s\n",
396                     get_pwr_state(pwr & AC_PWRST_SETTING),
397                     get_pwr_state((pwr & AC_PWRST_ACTUAL) >>
398                                   AC_PWRST_ACTUAL_SHIFT));
399 }
400
401 static void print_unsol_cap(struct snd_info_buffer *buffer,
402                               struct hda_codec *codec, hda_nid_t nid)
403 {
404         int unsol = snd_hda_codec_read(codec, nid, 0,
405                                        AC_VERB_GET_UNSOLICITED_RESPONSE, 0);
406         snd_iprintf(buffer,
407                     "  Unsolicited: tag=%02x, enabled=%d\n",
408                     unsol & AC_UNSOL_TAG,
409                     (unsol & AC_UNSOL_ENABLED) ? 1 : 0);
410 }
411
412 static void print_proc_caps(struct snd_info_buffer *buffer,
413                             struct hda_codec *codec, hda_nid_t nid)
414 {
415         unsigned int proc_caps = snd_hda_param_read(codec, nid,
416                                                     AC_PAR_PROC_CAP);
417         snd_iprintf(buffer, "  Processing caps: benign=%d, ncoeff=%d\n",
418                     proc_caps & AC_PCAP_BENIGN,
419                     (proc_caps & AC_PCAP_NUM_COEF) >> AC_PCAP_NUM_COEF_SHIFT);
420 }
421
422 static void print_conn_list(struct snd_info_buffer *buffer,
423                             struct hda_codec *codec, hda_nid_t nid,
424                             unsigned int wid_type, hda_nid_t *conn,
425                             int conn_len)
426 {
427         int c, curr = -1;
428
429         if (conn_len > 1 && wid_type != AC_WID_AUD_MIX)
430                 curr = snd_hda_codec_read(codec, nid, 0,
431                                           AC_VERB_GET_CONNECT_SEL, 0);
432         snd_iprintf(buffer, "  Connection: %d\n", conn_len);
433         if (conn_len > 0) {
434                 snd_iprintf(buffer, "    ");
435                 for (c = 0; c < conn_len; c++) {
436                         snd_iprintf(buffer, " 0x%02x", conn[c]);
437                         if (c == curr)
438                                 snd_iprintf(buffer, "*");
439                 }
440                 snd_iprintf(buffer, "\n");
441         }
442 }
443
444 static void print_realtek_coef(struct snd_info_buffer *buffer,
445                                struct hda_codec *codec, hda_nid_t nid)
446 {
447         int coeff = snd_hda_codec_read(codec, nid, 0,
448                                        AC_VERB_GET_PROC_COEF, 0);
449         snd_iprintf(buffer, "  Processing Coefficient: 0x%02x\n", coeff);
450         coeff = snd_hda_codec_read(codec, nid, 0,
451                                    AC_VERB_GET_COEF_INDEX, 0);
452         snd_iprintf(buffer, "  Coefficient Index: 0x%02x\n", coeff);
453 }
454
455 static void print_gpio(struct snd_info_buffer *buffer,
456                        struct hda_codec *codec, hda_nid_t nid)
457 {
458         unsigned int gpio =
459                 snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
460         unsigned int enable, direction, wake, unsol, sticky, data;
461         int i, max;
462         snd_iprintf(buffer, "GPIO: io=%d, o=%d, i=%d, "
463                     "unsolicited=%d, wake=%d\n",
464                     gpio & AC_GPIO_IO_COUNT,
465                     (gpio & AC_GPIO_O_COUNT) >> AC_GPIO_O_COUNT_SHIFT,
466                     (gpio & AC_GPIO_I_COUNT) >> AC_GPIO_I_COUNT_SHIFT,
467                     (gpio & AC_GPIO_UNSOLICITED) ? 1 : 0,
468                     (gpio & AC_GPIO_WAKE) ? 1 : 0);
469         max = gpio & AC_GPIO_IO_COUNT;
470         if (!max || max > 8)
471                 return;
472         enable = snd_hda_codec_read(codec, nid, 0,
473                                     AC_VERB_GET_GPIO_MASK, 0);
474         direction = snd_hda_codec_read(codec, nid, 0,
475                                        AC_VERB_GET_GPIO_DIRECTION, 0);
476         wake = snd_hda_codec_read(codec, nid, 0,
477                                   AC_VERB_GET_GPIO_WAKE_MASK, 0);
478         unsol  = snd_hda_codec_read(codec, nid, 0,
479                                     AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK, 0);
480         sticky = snd_hda_codec_read(codec, nid, 0,
481                                     AC_VERB_GET_GPIO_STICKY_MASK, 0);
482         data = snd_hda_codec_read(codec, nid, 0,
483                                   AC_VERB_GET_GPIO_DATA, 0);
484         for (i = 0; i < max; ++i)
485                 snd_iprintf(buffer,
486                             "  IO[%d]: enable=%d, dir=%d, wake=%d, "
487                             "sticky=%d, data=%d, unsol=%d\n", i,
488                             (enable & (1<<i)) ? 1 : 0,
489                             (direction & (1<<i)) ? 1 : 0,
490                             (wake & (1<<i)) ? 1 : 0,
491                             (sticky & (1<<i)) ? 1 : 0,
492                             (data & (1<<i)) ? 1 : 0,
493                             (unsol & (1<<i)) ? 1 : 0);
494         /* FIXME: add GPO and GPI pin information */
495 }
496
497 static void print_codec_info(struct snd_info_entry *entry,
498                              struct snd_info_buffer *buffer)
499 {
500         struct hda_codec *codec = entry->private_data;
501         hda_nid_t nid;
502         int i, nodes;
503
504         snd_iprintf(buffer, "Codec: %s\n",
505                     codec->name ? codec->name : "Not Set");
506         snd_iprintf(buffer, "Address: %d\n", codec->addr);
507         snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id);
508         snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id);
509         snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
510
511         if (codec->mfg)
512                 snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg);
513         else
514                 snd_iprintf(buffer, "No Modem Function Group found\n");
515
516         if (! codec->afg)
517                 return;
518         snd_hda_power_up(codec);
519         snd_iprintf(buffer, "Default PCM:\n");
520         print_pcm_caps(buffer, codec, codec->afg);
521         snd_iprintf(buffer, "Default Amp-In caps: ");
522         print_amp_caps(buffer, codec, codec->afg, HDA_INPUT);
523         snd_iprintf(buffer, "Default Amp-Out caps: ");
524         print_amp_caps(buffer, codec, codec->afg, HDA_OUTPUT);
525
526         nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
527         if (! nid || nodes < 0) {
528                 snd_iprintf(buffer, "Invalid AFG subtree\n");
529                 snd_hda_power_down(codec);
530                 return;
531         }
532
533         print_gpio(buffer, codec, codec->afg);
534
535         for (i = 0; i < nodes; i++, nid++) {
536                 unsigned int wid_caps =
537                         snd_hda_param_read(codec, nid,
538                                            AC_PAR_AUDIO_WIDGET_CAP);
539                 unsigned int wid_type =
540                         (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
541                 hda_nid_t conn[HDA_MAX_CONNECTIONS];
542                 int conn_len = 0;
543
544                 snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid,
545                             get_wid_type_name(wid_type), wid_caps);
546                 if (wid_caps & AC_WCAP_STEREO) {
547                         unsigned int chans;
548                         chans = (wid_caps & AC_WCAP_CHAN_CNT_EXT) >> 13;
549                         chans = ((chans << 1) | 1) + 1;
550                         if (chans == 2)
551                                 snd_iprintf(buffer, " Stereo");
552                         else
553                                 snd_iprintf(buffer, " %d-Channels", chans);
554                 } else
555                         snd_iprintf(buffer, " Mono");
556                 if (wid_caps & AC_WCAP_DIGITAL)
557                         snd_iprintf(buffer, " Digital");
558                 if (wid_caps & AC_WCAP_IN_AMP)
559                         snd_iprintf(buffer, " Amp-In");
560                 if (wid_caps & AC_WCAP_OUT_AMP)
561                         snd_iprintf(buffer, " Amp-Out");
562                 if (wid_caps & AC_WCAP_STRIPE)
563                         snd_iprintf(buffer, " Stripe");
564                 if (wid_caps & AC_WCAP_LR_SWAP)
565                         snd_iprintf(buffer, " R/L");
566                 if (wid_caps & AC_WCAP_CP_CAPS)
567                         snd_iprintf(buffer, " CP");
568                 snd_iprintf(buffer, "\n");
569
570                 /* volume knob is a special widget that always have connection
571                  * list
572                  */
573                 if (wid_type == AC_WID_VOL_KNB)
574                         wid_caps |= AC_WCAP_CONN_LIST;
575
576                 if (wid_caps & AC_WCAP_CONN_LIST)
577                         conn_len = snd_hda_get_connections(codec, nid, conn,
578                                                            HDA_MAX_CONNECTIONS);
579
580                 if (wid_caps & AC_WCAP_IN_AMP) {
581                         snd_iprintf(buffer, "  Amp-In caps: ");
582                         print_amp_caps(buffer, codec, nid, HDA_INPUT);
583                         snd_iprintf(buffer, "  Amp-In vals: ");
584                         print_amp_vals(buffer, codec, nid, HDA_INPUT,
585                                        wid_caps & AC_WCAP_STEREO,
586                                        wid_type == AC_WID_PIN ? 1 : conn_len);
587                 }
588                 if (wid_caps & AC_WCAP_OUT_AMP) {
589                         snd_iprintf(buffer, "  Amp-Out caps: ");
590                         print_amp_caps(buffer, codec, nid, HDA_OUTPUT);
591                         snd_iprintf(buffer, "  Amp-Out vals: ");
592                         print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
593                                        wid_caps & AC_WCAP_STEREO, 1);
594                 }
595
596                 switch (wid_type) {
597                 case AC_WID_PIN: {
598                         int supports_vref;
599                         print_pin_caps(buffer, codec, nid, &supports_vref);
600                         print_pin_ctls(buffer, codec, nid, supports_vref);
601                         break;
602                 }
603                 case AC_WID_VOL_KNB:
604                         print_vol_knob(buffer, codec, nid);
605                         break;
606                 case AC_WID_AUD_OUT:
607                 case AC_WID_AUD_IN:
608                         print_audio_io(buffer, codec, nid, wid_type);
609                         if (wid_caps & AC_WCAP_DIGITAL)
610                                 print_digital_conv(buffer, codec, nid);
611                         if (wid_caps & AC_WCAP_FORMAT_OVRD) {
612                                 snd_iprintf(buffer, "  PCM:\n");
613                                 print_pcm_caps(buffer, codec, nid);
614                         }
615                         break;
616                 }
617
618                 if (wid_caps & AC_WCAP_UNSOL_CAP)
619                         print_unsol_cap(buffer, codec, nid);
620
621                 if (wid_caps & AC_WCAP_POWER)
622                         print_power_state(buffer, codec, nid);
623
624                 if (wid_caps & AC_WCAP_DELAY)
625                         snd_iprintf(buffer, "  Delay: %d samples\n",
626                                     (wid_caps & AC_WCAP_DELAY) >>
627                                     AC_WCAP_DELAY_SHIFT);
628
629                 if (wid_caps & AC_WCAP_CONN_LIST)
630                         print_conn_list(buffer, codec, nid, wid_type,
631                                         conn, conn_len);
632
633                 if (wid_caps & AC_WCAP_PROC_WID)
634                         print_proc_caps(buffer, codec, nid);
635
636                 /* NID 0x20 == Realtek Define Registers */
637                 if (codec->vendor_id == 0x10ec && nid == 0x20)
638                         print_realtek_coef(buffer, codec, nid);
639         }
640         snd_hda_power_down(codec);
641 }
642
643 /*
644  * create a proc read
645  */
646 int snd_hda_codec_proc_new(struct hda_codec *codec)
647 {
648         char name[32];
649         struct snd_info_entry *entry;
650         int err;
651
652         snprintf(name, sizeof(name), "codec#%d", codec->addr);
653         err = snd_card_proc_new(codec->bus->card, name, &entry);
654         if (err < 0)
655                 return err;
656
657         snd_info_set_text_ops(entry, codec, print_codec_info);
658         return 0;
659 }
660