ALSA: hda - proc - introduce Control: lines to show mixer<->NID assignment
[firewire-audio.git] / sound / pci / hda / hda_proc.c
blobf465cff28041aef14d97f848f41fd722ddb37572
1 /*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * Generic proc interface
6 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
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.
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.
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
24 #include <linux/init.h>
25 #include <sound/core.h>
26 #include "hda_codec.h"
27 #include "hda_local.h"
29 static const char *get_wid_type_name(unsigned int wid_value)
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",
42 wid_value &= 0xf;
43 if (names[wid_value])
44 return names[wid_value];
45 else
46 return "UNKNOWN Widget";
49 static void print_nid_mixers(struct snd_info_buffer *buffer,
50 struct hda_codec *codec, hda_nid_t nid)
52 int i;
53 struct hda_nid_item *items = codec->mixers.list;
54 struct snd_kcontrol *kctl;
55 for (i = 0; i < codec->mixers.used; i++) {
56 if (items[i].nid == nid) {
57 kctl = items[i].kctl;
58 snd_iprintf(buffer,
59 " Control: name=\"%s\", index=%i, device=%i\n",
60 kctl->id.name, kctl->id.index, kctl->id.device);
65 static void print_nid_pcms(struct snd_info_buffer *buffer,
66 struct hda_codec *codec, hda_nid_t nid)
68 int pcm, type;
69 struct hda_pcm *cpcm;
70 for (pcm = 0; pcm < codec->num_pcms; pcm++) {
71 cpcm = &codec->pcm_info[pcm];
72 for (type = 0; type < 2; type++) {
73 if (cpcm->stream[type].nid != nid || cpcm->pcm == NULL)
74 continue;
75 snd_iprintf(buffer, " Device: name=\"%s\", "
76 "type=\"%s\", device=%i\n",
77 cpcm->name,
78 snd_hda_pcm_type_name[cpcm->pcm_type],
79 cpcm->pcm->device);
84 static void print_amp_caps(struct snd_info_buffer *buffer,
85 struct hda_codec *codec, hda_nid_t nid, int dir)
87 unsigned int caps;
88 caps = snd_hda_param_read(codec, nid,
89 dir == HDA_OUTPUT ?
90 AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP);
91 if (caps == -1 || caps == 0) {
92 snd_iprintf(buffer, "N/A\n");
93 return;
95 snd_iprintf(buffer, "ofs=0x%02x, nsteps=0x%02x, stepsize=0x%02x, "
96 "mute=%x\n",
97 caps & AC_AMPCAP_OFFSET,
98 (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT,
99 (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT,
100 (caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT);
103 static void print_amp_vals(struct snd_info_buffer *buffer,
104 struct hda_codec *codec, hda_nid_t nid,
105 int dir, int stereo, int indices)
107 unsigned int val;
108 int i;
110 dir = dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
111 for (i = 0; i < indices; i++) {
112 snd_iprintf(buffer, " [");
113 if (stereo) {
114 val = snd_hda_codec_read(codec, nid, 0,
115 AC_VERB_GET_AMP_GAIN_MUTE,
116 AC_AMP_GET_LEFT | dir | i);
117 snd_iprintf(buffer, "0x%02x ", val);
119 val = snd_hda_codec_read(codec, nid, 0,
120 AC_VERB_GET_AMP_GAIN_MUTE,
121 AC_AMP_GET_RIGHT | dir | i);
122 snd_iprintf(buffer, "0x%02x]", val);
124 snd_iprintf(buffer, "\n");
127 static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
129 char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
131 pcm &= AC_SUPPCM_RATES;
132 snd_iprintf(buffer, " rates [0x%x]:", pcm);
133 snd_print_pcm_rates(pcm, buf, sizeof(buf));
134 snd_iprintf(buffer, "%s\n", buf);
137 static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)
139 char buf[SND_PRINT_BITS_ADVISED_BUFSIZE];
141 snd_iprintf(buffer, " bits [0x%x]:", (pcm >> 16) & 0xff);
142 snd_print_pcm_bits(pcm, buf, sizeof(buf));
143 snd_iprintf(buffer, "%s\n", buf);
146 static void print_pcm_formats(struct snd_info_buffer *buffer,
147 unsigned int streams)
149 snd_iprintf(buffer, " formats [0x%x]:", streams & 0xf);
150 if (streams & AC_SUPFMT_PCM)
151 snd_iprintf(buffer, " PCM");
152 if (streams & AC_SUPFMT_FLOAT32)
153 snd_iprintf(buffer, " FLOAT");
154 if (streams & AC_SUPFMT_AC3)
155 snd_iprintf(buffer, " AC3");
156 snd_iprintf(buffer, "\n");
159 static void print_pcm_caps(struct snd_info_buffer *buffer,
160 struct hda_codec *codec, hda_nid_t nid)
162 unsigned int pcm = snd_hda_param_read(codec, nid, AC_PAR_PCM);
163 unsigned int stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
164 if (pcm == -1 || stream == -1) {
165 snd_iprintf(buffer, "N/A\n");
166 return;
168 print_pcm_rates(buffer, pcm);
169 print_pcm_bits(buffer, pcm);
170 print_pcm_formats(buffer, stream);
173 static const char *get_jack_connection(u32 cfg)
175 static char *names[16] = {
176 "Unknown", "1/8", "1/4", "ATAPI",
177 "RCA", "Optical","Digital", "Analog",
178 "DIN", "XLR", "RJ11", "Comb",
179 NULL, NULL, NULL, "Other"
181 cfg = (cfg & AC_DEFCFG_CONN_TYPE) >> AC_DEFCFG_CONN_TYPE_SHIFT;
182 if (names[cfg])
183 return names[cfg];
184 else
185 return "UNKNOWN";
188 static const char *get_jack_color(u32 cfg)
190 static char *names[16] = {
191 "Unknown", "Black", "Grey", "Blue",
192 "Green", "Red", "Orange", "Yellow",
193 "Purple", "Pink", NULL, NULL,
194 NULL, NULL, "White", "Other",
196 cfg = (cfg & AC_DEFCFG_COLOR) >> AC_DEFCFG_COLOR_SHIFT;
197 if (names[cfg])
198 return names[cfg];
199 else
200 return "UNKNOWN";
203 static void print_pin_caps(struct snd_info_buffer *buffer,
204 struct hda_codec *codec, hda_nid_t nid,
205 int *supports_vref)
207 static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" };
208 unsigned int caps, val;
210 caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
211 snd_iprintf(buffer, " Pincap 0x%08x:", caps);
212 if (caps & AC_PINCAP_IN)
213 snd_iprintf(buffer, " IN");
214 if (caps & AC_PINCAP_OUT)
215 snd_iprintf(buffer, " OUT");
216 if (caps & AC_PINCAP_HP_DRV)
217 snd_iprintf(buffer, " HP");
218 if (caps & AC_PINCAP_EAPD)
219 snd_iprintf(buffer, " EAPD");
220 if (caps & AC_PINCAP_PRES_DETECT)
221 snd_iprintf(buffer, " Detect");
222 if (caps & AC_PINCAP_BALANCE)
223 snd_iprintf(buffer, " Balanced");
224 if (caps & AC_PINCAP_HDMI) {
225 /* Realtek uses this bit as a different meaning */
226 if ((codec->vendor_id >> 16) == 0x10ec)
227 snd_iprintf(buffer, " R/L");
228 else
229 snd_iprintf(buffer, " HDMI");
231 if (caps & AC_PINCAP_TRIG_REQ)
232 snd_iprintf(buffer, " Trigger");
233 if (caps & AC_PINCAP_IMP_SENSE)
234 snd_iprintf(buffer, " ImpSense");
235 snd_iprintf(buffer, "\n");
236 if (caps & AC_PINCAP_VREF) {
237 unsigned int vref =
238 (caps & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
239 snd_iprintf(buffer, " Vref caps:");
240 if (vref & AC_PINCAP_VREF_HIZ)
241 snd_iprintf(buffer, " HIZ");
242 if (vref & AC_PINCAP_VREF_50)
243 snd_iprintf(buffer, " 50");
244 if (vref & AC_PINCAP_VREF_GRD)
245 snd_iprintf(buffer, " GRD");
246 if (vref & AC_PINCAP_VREF_80)
247 snd_iprintf(buffer, " 80");
248 if (vref & AC_PINCAP_VREF_100)
249 snd_iprintf(buffer, " 100");
250 snd_iprintf(buffer, "\n");
251 *supports_vref = 1;
252 } else
253 *supports_vref = 0;
254 if (caps & AC_PINCAP_EAPD) {
255 val = snd_hda_codec_read(codec, nid, 0,
256 AC_VERB_GET_EAPD_BTLENABLE, 0);
257 snd_iprintf(buffer, " EAPD 0x%x:", val);
258 if (val & AC_EAPDBTL_BALANCED)
259 snd_iprintf(buffer, " BALANCED");
260 if (val & AC_EAPDBTL_EAPD)
261 snd_iprintf(buffer, " EAPD");
262 if (val & AC_EAPDBTL_LR_SWAP)
263 snd_iprintf(buffer, " R/L");
264 snd_iprintf(buffer, "\n");
266 caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
267 snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps,
268 jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT],
269 snd_hda_get_jack_type(caps),
270 snd_hda_get_jack_connectivity(caps),
271 snd_hda_get_jack_location(caps));
272 snd_iprintf(buffer, " Conn = %s, Color = %s\n",
273 get_jack_connection(caps),
274 get_jack_color(caps));
275 /* Default association and sequence values refer to default grouping
276 * of pin complexes and their sequence within the group. This is used
277 * for priority and resource allocation.
279 snd_iprintf(buffer, " DefAssociation = 0x%x, Sequence = 0x%x\n",
280 (caps & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT,
281 caps & AC_DEFCFG_SEQUENCE);
282 if (((caps & AC_DEFCFG_MISC) >> AC_DEFCFG_MISC_SHIFT) &
283 AC_DEFCFG_MISC_NO_PRESENCE) {
284 /* Miscellaneous bit indicates external hardware does not
285 * support presence detection even if the pin complex
286 * indicates it is supported.
288 snd_iprintf(buffer, " Misc = NO_PRESENCE\n");
292 static void print_pin_ctls(struct snd_info_buffer *buffer,
293 struct hda_codec *codec, hda_nid_t nid,
294 int supports_vref)
296 unsigned int pinctls;
298 pinctls = snd_hda_codec_read(codec, nid, 0,
299 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
300 snd_iprintf(buffer, " Pin-ctls: 0x%02x:", pinctls);
301 if (pinctls & AC_PINCTL_IN_EN)
302 snd_iprintf(buffer, " IN");
303 if (pinctls & AC_PINCTL_OUT_EN)
304 snd_iprintf(buffer, " OUT");
305 if (pinctls & AC_PINCTL_HP_EN)
306 snd_iprintf(buffer, " HP");
307 if (supports_vref) {
308 int vref = pinctls & AC_PINCTL_VREFEN;
309 switch (vref) {
310 case AC_PINCTL_VREF_HIZ:
311 snd_iprintf(buffer, " VREF_HIZ");
312 break;
313 case AC_PINCTL_VREF_50:
314 snd_iprintf(buffer, " VREF_50");
315 break;
316 case AC_PINCTL_VREF_GRD:
317 snd_iprintf(buffer, " VREF_GRD");
318 break;
319 case AC_PINCTL_VREF_80:
320 snd_iprintf(buffer, " VREF_80");
321 break;
322 case AC_PINCTL_VREF_100:
323 snd_iprintf(buffer, " VREF_100");
324 break;
327 snd_iprintf(buffer, "\n");
330 static void print_vol_knob(struct snd_info_buffer *buffer,
331 struct hda_codec *codec, hda_nid_t nid)
333 unsigned int cap = snd_hda_param_read(codec, nid,
334 AC_PAR_VOL_KNB_CAP);
335 snd_iprintf(buffer, " Volume-Knob: delta=%d, steps=%d, ",
336 (cap >> 7) & 1, cap & 0x7f);
337 cap = snd_hda_codec_read(codec, nid, 0,
338 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
339 snd_iprintf(buffer, "direct=%d, val=%d\n",
340 (cap >> 7) & 1, cap & 0x7f);
343 static void print_audio_io(struct snd_info_buffer *buffer,
344 struct hda_codec *codec, hda_nid_t nid,
345 unsigned int wid_type)
347 int conv = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
348 snd_iprintf(buffer,
349 " Converter: stream=%d, channel=%d\n",
350 (conv & AC_CONV_STREAM) >> AC_CONV_STREAM_SHIFT,
351 conv & AC_CONV_CHANNEL);
353 if (wid_type == AC_WID_AUD_IN && (conv & AC_CONV_CHANNEL) == 0) {
354 int sdi = snd_hda_codec_read(codec, nid, 0,
355 AC_VERB_GET_SDI_SELECT, 0);
356 snd_iprintf(buffer, " SDI-Select: %d\n",
357 sdi & AC_SDI_SELECT);
361 static void print_digital_conv(struct snd_info_buffer *buffer,
362 struct hda_codec *codec, hda_nid_t nid)
364 unsigned int digi1 = snd_hda_codec_read(codec, nid, 0,
365 AC_VERB_GET_DIGI_CONVERT_1, 0);
366 snd_iprintf(buffer, " Digital:");
367 if (digi1 & AC_DIG1_ENABLE)
368 snd_iprintf(buffer, " Enabled");
369 if (digi1 & AC_DIG1_V)
370 snd_iprintf(buffer, " Validity");
371 if (digi1 & AC_DIG1_VCFG)
372 snd_iprintf(buffer, " ValidityCfg");
373 if (digi1 & AC_DIG1_EMPHASIS)
374 snd_iprintf(buffer, " Preemphasis");
375 if (digi1 & AC_DIG1_COPYRIGHT)
376 snd_iprintf(buffer, " Copyright");
377 if (digi1 & AC_DIG1_NONAUDIO)
378 snd_iprintf(buffer, " Non-Audio");
379 if (digi1 & AC_DIG1_PROFESSIONAL)
380 snd_iprintf(buffer, " Pro");
381 if (digi1 & AC_DIG1_LEVEL)
382 snd_iprintf(buffer, " GenLevel");
383 snd_iprintf(buffer, "\n");
384 snd_iprintf(buffer, " Digital category: 0x%x\n",
385 (digi1 >> 8) & AC_DIG2_CC);
388 static const char *get_pwr_state(u32 state)
390 static const char *buf[4] = {
391 "D0", "D1", "D2", "D3"
393 if (state < 4)
394 return buf[state];
395 return "UNKNOWN";
398 static void print_power_state(struct snd_info_buffer *buffer,
399 struct hda_codec *codec, hda_nid_t nid)
401 int pwr = snd_hda_codec_read(codec, nid, 0,
402 AC_VERB_GET_POWER_STATE, 0);
403 snd_iprintf(buffer, " Power: setting=%s, actual=%s\n",
404 get_pwr_state(pwr & AC_PWRST_SETTING),
405 get_pwr_state((pwr & AC_PWRST_ACTUAL) >>
406 AC_PWRST_ACTUAL_SHIFT));
409 static void print_unsol_cap(struct snd_info_buffer *buffer,
410 struct hda_codec *codec, hda_nid_t nid)
412 int unsol = snd_hda_codec_read(codec, nid, 0,
413 AC_VERB_GET_UNSOLICITED_RESPONSE, 0);
414 snd_iprintf(buffer,
415 " Unsolicited: tag=%02x, enabled=%d\n",
416 unsol & AC_UNSOL_TAG,
417 (unsol & AC_UNSOL_ENABLED) ? 1 : 0);
420 static void print_proc_caps(struct snd_info_buffer *buffer,
421 struct hda_codec *codec, hda_nid_t nid)
423 unsigned int proc_caps = snd_hda_param_read(codec, nid,
424 AC_PAR_PROC_CAP);
425 snd_iprintf(buffer, " Processing caps: benign=%d, ncoeff=%d\n",
426 proc_caps & AC_PCAP_BENIGN,
427 (proc_caps & AC_PCAP_NUM_COEF) >> AC_PCAP_NUM_COEF_SHIFT);
430 static void print_conn_list(struct snd_info_buffer *buffer,
431 struct hda_codec *codec, hda_nid_t nid,
432 unsigned int wid_type, hda_nid_t *conn,
433 int conn_len)
435 int c, curr = -1;
437 if (conn_len > 1 &&
438 wid_type != AC_WID_AUD_MIX &&
439 wid_type != AC_WID_VOL_KNB &&
440 wid_type != AC_WID_POWER)
441 curr = snd_hda_codec_read(codec, nid, 0,
442 AC_VERB_GET_CONNECT_SEL, 0);
443 snd_iprintf(buffer, " Connection: %d\n", conn_len);
444 if (conn_len > 0) {
445 snd_iprintf(buffer, " ");
446 for (c = 0; c < conn_len; c++) {
447 snd_iprintf(buffer, " 0x%02x", conn[c]);
448 if (c == curr)
449 snd_iprintf(buffer, "*");
451 snd_iprintf(buffer, "\n");
455 static void print_gpio(struct snd_info_buffer *buffer,
456 struct hda_codec *codec, hda_nid_t nid)
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 print_nid_mixers(buffer, codec, nid);
498 static void print_codec_info(struct snd_info_entry *entry,
499 struct snd_info_buffer *buffer)
501 struct hda_codec *codec = entry->private_data;
502 hda_nid_t nid;
503 int i, nodes;
505 snd_iprintf(buffer, "Codec: ");
506 if (codec->vendor_name && codec->chip_name)
507 snd_iprintf(buffer, "%s %s\n",
508 codec->vendor_name, codec->chip_name);
509 else
510 snd_iprintf(buffer, "Not Set\n");
511 snd_iprintf(buffer, "Address: %d\n", codec->addr);
512 snd_iprintf(buffer, "Function Id: 0x%x\n", codec->function_id);
513 snd_iprintf(buffer, "Vendor Id: 0x%08x\n", codec->vendor_id);
514 snd_iprintf(buffer, "Subsystem Id: 0x%08x\n", codec->subsystem_id);
515 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
517 if (codec->mfg)
518 snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg);
519 else
520 snd_iprintf(buffer, "No Modem Function Group found\n");
522 if (! codec->afg)
523 return;
524 snd_hda_power_up(codec);
525 snd_iprintf(buffer, "Default PCM:\n");
526 print_pcm_caps(buffer, codec, codec->afg);
527 snd_iprintf(buffer, "Default Amp-In caps: ");
528 print_amp_caps(buffer, codec, codec->afg, HDA_INPUT);
529 snd_iprintf(buffer, "Default Amp-Out caps: ");
530 print_amp_caps(buffer, codec, codec->afg, HDA_OUTPUT);
532 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
533 if (! nid || nodes < 0) {
534 snd_iprintf(buffer, "Invalid AFG subtree\n");
535 snd_hda_power_down(codec);
536 return;
539 print_gpio(buffer, codec, codec->afg);
540 if (codec->proc_widget_hook)
541 codec->proc_widget_hook(buffer, codec, codec->afg);
543 for (i = 0; i < nodes; i++, nid++) {
544 unsigned int wid_caps =
545 snd_hda_param_read(codec, nid,
546 AC_PAR_AUDIO_WIDGET_CAP);
547 unsigned int wid_type = get_wcaps_type(wid_caps);
548 hda_nid_t conn[HDA_MAX_CONNECTIONS];
549 int conn_len = 0;
551 snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid,
552 get_wid_type_name(wid_type), wid_caps);
553 if (wid_caps & AC_WCAP_STEREO) {
554 unsigned int chans = get_wcaps_channels(wid_caps);
555 if (chans == 2)
556 snd_iprintf(buffer, " Stereo");
557 else
558 snd_iprintf(buffer, " %d-Channels", chans);
559 } else
560 snd_iprintf(buffer, " Mono");
561 if (wid_caps & AC_WCAP_DIGITAL)
562 snd_iprintf(buffer, " Digital");
563 if (wid_caps & AC_WCAP_IN_AMP)
564 snd_iprintf(buffer, " Amp-In");
565 if (wid_caps & AC_WCAP_OUT_AMP)
566 snd_iprintf(buffer, " Amp-Out");
567 if (wid_caps & AC_WCAP_STRIPE)
568 snd_iprintf(buffer, " Stripe");
569 if (wid_caps & AC_WCAP_LR_SWAP)
570 snd_iprintf(buffer, " R/L");
571 if (wid_caps & AC_WCAP_CP_CAPS)
572 snd_iprintf(buffer, " CP");
573 snd_iprintf(buffer, "\n");
575 print_nid_mixers(buffer, codec, nid);
576 print_nid_pcms(buffer, codec, nid);
578 /* volume knob is a special widget that always have connection
579 * list
581 if (wid_type == AC_WID_VOL_KNB)
582 wid_caps |= AC_WCAP_CONN_LIST;
584 if (wid_caps & AC_WCAP_CONN_LIST)
585 conn_len = snd_hda_get_connections(codec, nid, conn,
586 HDA_MAX_CONNECTIONS);
588 if (wid_caps & AC_WCAP_IN_AMP) {
589 snd_iprintf(buffer, " Amp-In caps: ");
590 print_amp_caps(buffer, codec, nid, HDA_INPUT);
591 snd_iprintf(buffer, " Amp-In vals: ");
592 print_amp_vals(buffer, codec, nid, HDA_INPUT,
593 wid_caps & AC_WCAP_STEREO,
594 wid_type == AC_WID_PIN ? 1 : conn_len);
596 if (wid_caps & AC_WCAP_OUT_AMP) {
597 snd_iprintf(buffer, " Amp-Out caps: ");
598 print_amp_caps(buffer, codec, nid, HDA_OUTPUT);
599 snd_iprintf(buffer, " Amp-Out vals: ");
600 if (wid_type == AC_WID_PIN &&
601 codec->pin_amp_workaround)
602 print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
603 wid_caps & AC_WCAP_STEREO,
604 conn_len);
605 else
606 print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
607 wid_caps & AC_WCAP_STEREO, 1);
610 switch (wid_type) {
611 case AC_WID_PIN: {
612 int supports_vref;
613 print_pin_caps(buffer, codec, nid, &supports_vref);
614 print_pin_ctls(buffer, codec, nid, supports_vref);
615 break;
617 case AC_WID_VOL_KNB:
618 print_vol_knob(buffer, codec, nid);
619 break;
620 case AC_WID_AUD_OUT:
621 case AC_WID_AUD_IN:
622 print_audio_io(buffer, codec, nid, wid_type);
623 if (wid_caps & AC_WCAP_DIGITAL)
624 print_digital_conv(buffer, codec, nid);
625 if (wid_caps & AC_WCAP_FORMAT_OVRD) {
626 snd_iprintf(buffer, " PCM:\n");
627 print_pcm_caps(buffer, codec, nid);
629 break;
632 if (wid_caps & AC_WCAP_UNSOL_CAP)
633 print_unsol_cap(buffer, codec, nid);
635 if (wid_caps & AC_WCAP_POWER)
636 print_power_state(buffer, codec, nid);
638 if (wid_caps & AC_WCAP_DELAY)
639 snd_iprintf(buffer, " Delay: %d samples\n",
640 (wid_caps & AC_WCAP_DELAY) >>
641 AC_WCAP_DELAY_SHIFT);
643 if (wid_caps & AC_WCAP_CONN_LIST)
644 print_conn_list(buffer, codec, nid, wid_type,
645 conn, conn_len);
647 if (wid_caps & AC_WCAP_PROC_WID)
648 print_proc_caps(buffer, codec, nid);
650 if (codec->proc_widget_hook)
651 codec->proc_widget_hook(buffer, codec, nid);
653 snd_hda_power_down(codec);
657 * create a proc read
659 int snd_hda_codec_proc_new(struct hda_codec *codec)
661 char name[32];
662 struct snd_info_entry *entry;
663 int err;
665 snprintf(name, sizeof(name), "codec#%d", codec->addr);
666 err = snd_card_proc_new(codec->bus->card, name, &entry);
667 if (err < 0)
668 return err;
670 snd_info_set_text_ops(entry, codec, print_codec_info);
671 return 0;