Add linux-next specific files for 20110716
[linux-2.6/next.git] / sound / pci / hda / hda_proc.c
blob2be57b051aa27c60145d808899cf0375b0b2f6e0
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 char *bits_names(unsigned int bits, char *names[], int size)
31 int i, n;
32 static char buf[128];
34 for (i = 0, n = 0; i < size; i++) {
35 if (bits & (1U<<i) && names[i])
36 n += snprintf(buf + n, sizeof(buf) - n, " %s",
37 names[i]);
39 buf[n] = '\0';
41 return buf;
44 static const char *get_wid_type_name(unsigned int wid_value)
46 static char *names[16] = {
47 [AC_WID_AUD_OUT] = "Audio Output",
48 [AC_WID_AUD_IN] = "Audio Input",
49 [AC_WID_AUD_MIX] = "Audio Mixer",
50 [AC_WID_AUD_SEL] = "Audio Selector",
51 [AC_WID_PIN] = "Pin Complex",
52 [AC_WID_POWER] = "Power Widget",
53 [AC_WID_VOL_KNB] = "Volume Knob Widget",
54 [AC_WID_BEEP] = "Beep Generator Widget",
55 [AC_WID_VENDOR] = "Vendor Defined Widget",
57 wid_value &= 0xf;
58 if (names[wid_value])
59 return names[wid_value];
60 else
61 return "UNKNOWN Widget";
64 static void print_nid_array(struct snd_info_buffer *buffer,
65 struct hda_codec *codec, hda_nid_t nid,
66 struct snd_array *array)
68 int i;
69 struct hda_nid_item *items = array->list, *item;
70 struct snd_kcontrol *kctl;
71 for (i = 0; i < array->used; i++) {
72 item = &items[i];
73 if (item->nid == nid) {
74 kctl = item->kctl;
75 snd_iprintf(buffer,
76 " Control: name=\"%s\", index=%i, device=%i\n",
77 kctl->id.name, kctl->id.index + item->index,
78 kctl->id.device);
79 if (item->flags & HDA_NID_ITEM_AMP)
80 snd_iprintf(buffer,
81 " ControlAmp: chs=%lu, dir=%s, "
82 "idx=%lu, ofs=%lu\n",
83 get_amp_channels(kctl),
84 get_amp_direction(kctl) ? "Out" : "In",
85 get_amp_index(kctl),
86 get_amp_offset(kctl));
91 static void print_nid_pcms(struct snd_info_buffer *buffer,
92 struct hda_codec *codec, hda_nid_t nid)
94 int pcm, type;
95 struct hda_pcm *cpcm;
96 for (pcm = 0; pcm < codec->num_pcms; pcm++) {
97 cpcm = &codec->pcm_info[pcm];
98 for (type = 0; type < 2; type++) {
99 if (cpcm->stream[type].nid != nid || cpcm->pcm == NULL)
100 continue;
101 snd_iprintf(buffer, " Device: name=\"%s\", "
102 "type=\"%s\", device=%i\n",
103 cpcm->name,
104 snd_hda_pcm_type_name[cpcm->pcm_type],
105 cpcm->pcm->device);
110 static void print_amp_caps(struct snd_info_buffer *buffer,
111 struct hda_codec *codec, hda_nid_t nid, int dir)
113 unsigned int caps;
114 caps = snd_hda_param_read(codec, nid,
115 dir == HDA_OUTPUT ?
116 AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP);
117 if (caps == -1 || caps == 0) {
118 snd_iprintf(buffer, "N/A\n");
119 return;
121 snd_iprintf(buffer, "ofs=0x%02x, nsteps=0x%02x, stepsize=0x%02x, "
122 "mute=%x\n",
123 caps & AC_AMPCAP_OFFSET,
124 (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT,
125 (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT,
126 (caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT);
129 static void print_amp_vals(struct snd_info_buffer *buffer,
130 struct hda_codec *codec, hda_nid_t nid,
131 int dir, int stereo, int indices)
133 unsigned int val;
134 int i;
136 dir = dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
137 for (i = 0; i < indices; i++) {
138 snd_iprintf(buffer, " [");
139 if (stereo) {
140 val = snd_hda_codec_read(codec, nid, 0,
141 AC_VERB_GET_AMP_GAIN_MUTE,
142 AC_AMP_GET_LEFT | dir | i);
143 snd_iprintf(buffer, "0x%02x ", val);
145 val = snd_hda_codec_read(codec, nid, 0,
146 AC_VERB_GET_AMP_GAIN_MUTE,
147 AC_AMP_GET_RIGHT | dir | i);
148 snd_iprintf(buffer, "0x%02x]", val);
150 snd_iprintf(buffer, "\n");
153 static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
155 char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
157 pcm &= AC_SUPPCM_RATES;
158 snd_iprintf(buffer, " rates [0x%x]:", pcm);
159 snd_print_pcm_rates(pcm, buf, sizeof(buf));
160 snd_iprintf(buffer, "%s\n", buf);
163 static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)
165 char buf[SND_PRINT_BITS_ADVISED_BUFSIZE];
167 snd_iprintf(buffer, " bits [0x%x]:", (pcm >> 16) & 0xff);
168 snd_print_pcm_bits(pcm, buf, sizeof(buf));
169 snd_iprintf(buffer, "%s\n", buf);
172 static void print_pcm_formats(struct snd_info_buffer *buffer,
173 unsigned int streams)
175 snd_iprintf(buffer, " formats [0x%x]:", streams & 0xf);
176 if (streams & AC_SUPFMT_PCM)
177 snd_iprintf(buffer, " PCM");
178 if (streams & AC_SUPFMT_FLOAT32)
179 snd_iprintf(buffer, " FLOAT");
180 if (streams & AC_SUPFMT_AC3)
181 snd_iprintf(buffer, " AC3");
182 snd_iprintf(buffer, "\n");
185 static void print_pcm_caps(struct snd_info_buffer *buffer,
186 struct hda_codec *codec, hda_nid_t nid)
188 unsigned int pcm = snd_hda_param_read(codec, nid, AC_PAR_PCM);
189 unsigned int stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
190 if (pcm == -1 || stream == -1) {
191 snd_iprintf(buffer, "N/A\n");
192 return;
194 print_pcm_rates(buffer, pcm);
195 print_pcm_bits(buffer, pcm);
196 print_pcm_formats(buffer, stream);
199 static const char *get_jack_connection(u32 cfg)
201 static char *names[16] = {
202 "Unknown", "1/8", "1/4", "ATAPI",
203 "RCA", "Optical","Digital", "Analog",
204 "DIN", "XLR", "RJ11", "Comb",
205 NULL, NULL, NULL, "Other"
207 cfg = (cfg & AC_DEFCFG_CONN_TYPE) >> AC_DEFCFG_CONN_TYPE_SHIFT;
208 if (names[cfg])
209 return names[cfg];
210 else
211 return "UNKNOWN";
214 static const char *get_jack_color(u32 cfg)
216 static char *names[16] = {
217 "Unknown", "Black", "Grey", "Blue",
218 "Green", "Red", "Orange", "Yellow",
219 "Purple", "Pink", NULL, NULL,
220 NULL, NULL, "White", "Other",
222 cfg = (cfg & AC_DEFCFG_COLOR) >> AC_DEFCFG_COLOR_SHIFT;
223 if (names[cfg])
224 return names[cfg];
225 else
226 return "UNKNOWN";
229 static void print_pin_caps(struct snd_info_buffer *buffer,
230 struct hda_codec *codec, hda_nid_t nid,
231 int *supports_vref)
233 static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" };
234 unsigned int caps, val;
236 caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
237 snd_iprintf(buffer, " Pincap 0x%08x:", caps);
238 if (caps & AC_PINCAP_IN)
239 snd_iprintf(buffer, " IN");
240 if (caps & AC_PINCAP_OUT)
241 snd_iprintf(buffer, " OUT");
242 if (caps & AC_PINCAP_HP_DRV)
243 snd_iprintf(buffer, " HP");
244 if (caps & AC_PINCAP_EAPD)
245 snd_iprintf(buffer, " EAPD");
246 if (caps & AC_PINCAP_PRES_DETECT)
247 snd_iprintf(buffer, " Detect");
248 if (caps & AC_PINCAP_BALANCE)
249 snd_iprintf(buffer, " Balanced");
250 if (caps & AC_PINCAP_HDMI) {
251 /* Realtek uses this bit as a different meaning */
252 if ((codec->vendor_id >> 16) == 0x10ec)
253 snd_iprintf(buffer, " R/L");
254 else {
255 if (caps & AC_PINCAP_HBR)
256 snd_iprintf(buffer, " HBR");
257 snd_iprintf(buffer, " HDMI");
260 if (caps & AC_PINCAP_DP)
261 snd_iprintf(buffer, " DP");
262 if (caps & AC_PINCAP_TRIG_REQ)
263 snd_iprintf(buffer, " Trigger");
264 if (caps & AC_PINCAP_IMP_SENSE)
265 snd_iprintf(buffer, " ImpSense");
266 snd_iprintf(buffer, "\n");
267 if (caps & AC_PINCAP_VREF) {
268 unsigned int vref =
269 (caps & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
270 snd_iprintf(buffer, " Vref caps:");
271 if (vref & AC_PINCAP_VREF_HIZ)
272 snd_iprintf(buffer, " HIZ");
273 if (vref & AC_PINCAP_VREF_50)
274 snd_iprintf(buffer, " 50");
275 if (vref & AC_PINCAP_VREF_GRD)
276 snd_iprintf(buffer, " GRD");
277 if (vref & AC_PINCAP_VREF_80)
278 snd_iprintf(buffer, " 80");
279 if (vref & AC_PINCAP_VREF_100)
280 snd_iprintf(buffer, " 100");
281 snd_iprintf(buffer, "\n");
282 *supports_vref = 1;
283 } else
284 *supports_vref = 0;
285 if (caps & AC_PINCAP_EAPD) {
286 val = snd_hda_codec_read(codec, nid, 0,
287 AC_VERB_GET_EAPD_BTLENABLE, 0);
288 snd_iprintf(buffer, " EAPD 0x%x:", val);
289 if (val & AC_EAPDBTL_BALANCED)
290 snd_iprintf(buffer, " BALANCED");
291 if (val & AC_EAPDBTL_EAPD)
292 snd_iprintf(buffer, " EAPD");
293 if (val & AC_EAPDBTL_LR_SWAP)
294 snd_iprintf(buffer, " R/L");
295 snd_iprintf(buffer, "\n");
297 caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
298 snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps,
299 jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT],
300 snd_hda_get_jack_type(caps),
301 snd_hda_get_jack_connectivity(caps),
302 snd_hda_get_jack_location(caps));
303 snd_iprintf(buffer, " Conn = %s, Color = %s\n",
304 get_jack_connection(caps),
305 get_jack_color(caps));
306 /* Default association and sequence values refer to default grouping
307 * of pin complexes and their sequence within the group. This is used
308 * for priority and resource allocation.
310 snd_iprintf(buffer, " DefAssociation = 0x%x, Sequence = 0x%x\n",
311 (caps & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT,
312 caps & AC_DEFCFG_SEQUENCE);
313 if (((caps & AC_DEFCFG_MISC) >> AC_DEFCFG_MISC_SHIFT) &
314 AC_DEFCFG_MISC_NO_PRESENCE) {
315 /* Miscellaneous bit indicates external hardware does not
316 * support presence detection even if the pin complex
317 * indicates it is supported.
319 snd_iprintf(buffer, " Misc = NO_PRESENCE\n");
323 static void print_pin_ctls(struct snd_info_buffer *buffer,
324 struct hda_codec *codec, hda_nid_t nid,
325 int supports_vref)
327 unsigned int pinctls;
329 pinctls = snd_hda_codec_read(codec, nid, 0,
330 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
331 snd_iprintf(buffer, " Pin-ctls: 0x%02x:", pinctls);
332 if (pinctls & AC_PINCTL_IN_EN)
333 snd_iprintf(buffer, " IN");
334 if (pinctls & AC_PINCTL_OUT_EN)
335 snd_iprintf(buffer, " OUT");
336 if (pinctls & AC_PINCTL_HP_EN)
337 snd_iprintf(buffer, " HP");
338 if (supports_vref) {
339 int vref = pinctls & AC_PINCTL_VREFEN;
340 switch (vref) {
341 case AC_PINCTL_VREF_HIZ:
342 snd_iprintf(buffer, " VREF_HIZ");
343 break;
344 case AC_PINCTL_VREF_50:
345 snd_iprintf(buffer, " VREF_50");
346 break;
347 case AC_PINCTL_VREF_GRD:
348 snd_iprintf(buffer, " VREF_GRD");
349 break;
350 case AC_PINCTL_VREF_80:
351 snd_iprintf(buffer, " VREF_80");
352 break;
353 case AC_PINCTL_VREF_100:
354 snd_iprintf(buffer, " VREF_100");
355 break;
358 snd_iprintf(buffer, "\n");
361 static void print_vol_knob(struct snd_info_buffer *buffer,
362 struct hda_codec *codec, hda_nid_t nid)
364 unsigned int cap = snd_hda_param_read(codec, nid,
365 AC_PAR_VOL_KNB_CAP);
366 snd_iprintf(buffer, " Volume-Knob: delta=%d, steps=%d, ",
367 (cap >> 7) & 1, cap & 0x7f);
368 cap = snd_hda_codec_read(codec, nid, 0,
369 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
370 snd_iprintf(buffer, "direct=%d, val=%d\n",
371 (cap >> 7) & 1, cap & 0x7f);
374 static void print_audio_io(struct snd_info_buffer *buffer,
375 struct hda_codec *codec, hda_nid_t nid,
376 unsigned int wid_type)
378 int conv = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
379 snd_iprintf(buffer,
380 " Converter: stream=%d, channel=%d\n",
381 (conv & AC_CONV_STREAM) >> AC_CONV_STREAM_SHIFT,
382 conv & AC_CONV_CHANNEL);
384 if (wid_type == AC_WID_AUD_IN && (conv & AC_CONV_CHANNEL) == 0) {
385 int sdi = snd_hda_codec_read(codec, nid, 0,
386 AC_VERB_GET_SDI_SELECT, 0);
387 snd_iprintf(buffer, " SDI-Select: %d\n",
388 sdi & AC_SDI_SELECT);
392 static void print_digital_conv(struct snd_info_buffer *buffer,
393 struct hda_codec *codec, hda_nid_t nid)
395 unsigned int digi1 = snd_hda_codec_read(codec, nid, 0,
396 AC_VERB_GET_DIGI_CONVERT_1, 0);
397 snd_iprintf(buffer, " Digital:");
398 if (digi1 & AC_DIG1_ENABLE)
399 snd_iprintf(buffer, " Enabled");
400 if (digi1 & AC_DIG1_V)
401 snd_iprintf(buffer, " Validity");
402 if (digi1 & AC_DIG1_VCFG)
403 snd_iprintf(buffer, " ValidityCfg");
404 if (digi1 & AC_DIG1_EMPHASIS)
405 snd_iprintf(buffer, " Preemphasis");
406 if (digi1 & AC_DIG1_COPYRIGHT)
407 snd_iprintf(buffer, " Copyright");
408 if (digi1 & AC_DIG1_NONAUDIO)
409 snd_iprintf(buffer, " Non-Audio");
410 if (digi1 & AC_DIG1_PROFESSIONAL)
411 snd_iprintf(buffer, " Pro");
412 if (digi1 & AC_DIG1_LEVEL)
413 snd_iprintf(buffer, " GenLevel");
414 snd_iprintf(buffer, "\n");
415 snd_iprintf(buffer, " Digital category: 0x%x\n",
416 (digi1 >> 8) & AC_DIG2_CC);
419 static const char *get_pwr_state(u32 state)
421 static const char * const buf[4] = {
422 "D0", "D1", "D2", "D3"
424 if (state < 4)
425 return buf[state];
426 return "UNKNOWN";
429 static void print_power_state(struct snd_info_buffer *buffer,
430 struct hda_codec *codec, hda_nid_t nid)
432 static char *names[] = {
433 [ilog2(AC_PWRST_D0SUP)] = "D0",
434 [ilog2(AC_PWRST_D1SUP)] = "D1",
435 [ilog2(AC_PWRST_D2SUP)] = "D2",
436 [ilog2(AC_PWRST_D3SUP)] = "D3",
437 [ilog2(AC_PWRST_D3COLDSUP)] = "D3cold",
438 [ilog2(AC_PWRST_S3D3COLDSUP)] = "S3D3cold",
439 [ilog2(AC_PWRST_CLKSTOP)] = "CLKSTOP",
440 [ilog2(AC_PWRST_EPSS)] = "EPSS",
443 int sup = snd_hda_param_read(codec, nid, AC_PAR_POWER_STATE);
444 int pwr = snd_hda_codec_read(codec, nid, 0,
445 AC_VERB_GET_POWER_STATE, 0);
446 if (sup)
447 snd_iprintf(buffer, " Power states: %s\n",
448 bits_names(sup, names, ARRAY_SIZE(names)));
450 snd_iprintf(buffer, " Power: setting=%s, actual=%s\n",
451 get_pwr_state(pwr & AC_PWRST_SETTING),
452 get_pwr_state((pwr & AC_PWRST_ACTUAL) >>
453 AC_PWRST_ACTUAL_SHIFT));
456 static void print_unsol_cap(struct snd_info_buffer *buffer,
457 struct hda_codec *codec, hda_nid_t nid)
459 int unsol = snd_hda_codec_read(codec, nid, 0,
460 AC_VERB_GET_UNSOLICITED_RESPONSE, 0);
461 snd_iprintf(buffer,
462 " Unsolicited: tag=%02x, enabled=%d\n",
463 unsol & AC_UNSOL_TAG,
464 (unsol & AC_UNSOL_ENABLED) ? 1 : 0);
467 static void print_proc_caps(struct snd_info_buffer *buffer,
468 struct hda_codec *codec, hda_nid_t nid)
470 unsigned int proc_caps = snd_hda_param_read(codec, nid,
471 AC_PAR_PROC_CAP);
472 snd_iprintf(buffer, " Processing caps: benign=%d, ncoeff=%d\n",
473 proc_caps & AC_PCAP_BENIGN,
474 (proc_caps & AC_PCAP_NUM_COEF) >> AC_PCAP_NUM_COEF_SHIFT);
477 static void print_conn_list(struct snd_info_buffer *buffer,
478 struct hda_codec *codec, hda_nid_t nid,
479 unsigned int wid_type, hda_nid_t *conn,
480 int conn_len)
482 int c, curr = -1;
484 if (conn_len > 1 &&
485 wid_type != AC_WID_AUD_MIX &&
486 wid_type != AC_WID_VOL_KNB &&
487 wid_type != AC_WID_POWER)
488 curr = snd_hda_codec_read(codec, nid, 0,
489 AC_VERB_GET_CONNECT_SEL, 0);
490 snd_iprintf(buffer, " Connection: %d\n", conn_len);
491 if (conn_len > 0) {
492 snd_iprintf(buffer, " ");
493 for (c = 0; c < conn_len; c++) {
494 snd_iprintf(buffer, " 0x%02x", conn[c]);
495 if (c == curr)
496 snd_iprintf(buffer, "*");
498 snd_iprintf(buffer, "\n");
502 static void print_gpio(struct snd_info_buffer *buffer,
503 struct hda_codec *codec, hda_nid_t nid)
505 unsigned int gpio =
506 snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
507 unsigned int enable, direction, wake, unsol, sticky, data;
508 int i, max;
509 snd_iprintf(buffer, "GPIO: io=%d, o=%d, i=%d, "
510 "unsolicited=%d, wake=%d\n",
511 gpio & AC_GPIO_IO_COUNT,
512 (gpio & AC_GPIO_O_COUNT) >> AC_GPIO_O_COUNT_SHIFT,
513 (gpio & AC_GPIO_I_COUNT) >> AC_GPIO_I_COUNT_SHIFT,
514 (gpio & AC_GPIO_UNSOLICITED) ? 1 : 0,
515 (gpio & AC_GPIO_WAKE) ? 1 : 0);
516 max = gpio & AC_GPIO_IO_COUNT;
517 if (!max || max > 8)
518 return;
519 enable = snd_hda_codec_read(codec, nid, 0,
520 AC_VERB_GET_GPIO_MASK, 0);
521 direction = snd_hda_codec_read(codec, nid, 0,
522 AC_VERB_GET_GPIO_DIRECTION, 0);
523 wake = snd_hda_codec_read(codec, nid, 0,
524 AC_VERB_GET_GPIO_WAKE_MASK, 0);
525 unsol = snd_hda_codec_read(codec, nid, 0,
526 AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK, 0);
527 sticky = snd_hda_codec_read(codec, nid, 0,
528 AC_VERB_GET_GPIO_STICKY_MASK, 0);
529 data = snd_hda_codec_read(codec, nid, 0,
530 AC_VERB_GET_GPIO_DATA, 0);
531 for (i = 0; i < max; ++i)
532 snd_iprintf(buffer,
533 " IO[%d]: enable=%d, dir=%d, wake=%d, "
534 "sticky=%d, data=%d, unsol=%d\n", i,
535 (enable & (1<<i)) ? 1 : 0,
536 (direction & (1<<i)) ? 1 : 0,
537 (wake & (1<<i)) ? 1 : 0,
538 (sticky & (1<<i)) ? 1 : 0,
539 (data & (1<<i)) ? 1 : 0,
540 (unsol & (1<<i)) ? 1 : 0);
541 /* FIXME: add GPO and GPI pin information */
542 print_nid_array(buffer, codec, nid, &codec->mixers);
543 print_nid_array(buffer, codec, nid, &codec->nids);
546 static void print_codec_info(struct snd_info_entry *entry,
547 struct snd_info_buffer *buffer)
549 struct hda_codec *codec = entry->private_data;
550 hda_nid_t nid;
551 int i, nodes;
553 snd_iprintf(buffer, "Codec: ");
554 if (codec->vendor_name && codec->chip_name)
555 snd_iprintf(buffer, "%s %s\n",
556 codec->vendor_name, codec->chip_name);
557 else
558 snd_iprintf(buffer, "Not Set\n");
559 snd_iprintf(buffer, "Address: %d\n", codec->addr);
560 if (codec->afg)
561 snd_iprintf(buffer, "AFG Function Id: 0x%x (unsol %u)\n",
562 codec->afg_function_id, codec->afg_unsol);
563 if (codec->mfg)
564 snd_iprintf(buffer, "MFG Function Id: 0x%x (unsol %u)\n",
565 codec->mfg_function_id, codec->mfg_unsol);
566 snd_iprintf(buffer, "Vendor Id: 0x%08x\n", codec->vendor_id);
567 snd_iprintf(buffer, "Subsystem Id: 0x%08x\n", codec->subsystem_id);
568 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
570 if (codec->mfg)
571 snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg);
572 else
573 snd_iprintf(buffer, "No Modem Function Group found\n");
575 if (! codec->afg)
576 return;
577 snd_hda_power_up(codec);
578 snd_iprintf(buffer, "Default PCM:\n");
579 print_pcm_caps(buffer, codec, codec->afg);
580 snd_iprintf(buffer, "Default Amp-In caps: ");
581 print_amp_caps(buffer, codec, codec->afg, HDA_INPUT);
582 snd_iprintf(buffer, "Default Amp-Out caps: ");
583 print_amp_caps(buffer, codec, codec->afg, HDA_OUTPUT);
585 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
586 if (! nid || nodes < 0) {
587 snd_iprintf(buffer, "Invalid AFG subtree\n");
588 snd_hda_power_down(codec);
589 return;
592 print_gpio(buffer, codec, codec->afg);
593 if (codec->proc_widget_hook)
594 codec->proc_widget_hook(buffer, codec, codec->afg);
596 for (i = 0; i < nodes; i++, nid++) {
597 unsigned int wid_caps =
598 snd_hda_param_read(codec, nid,
599 AC_PAR_AUDIO_WIDGET_CAP);
600 unsigned int wid_type = get_wcaps_type(wid_caps);
601 hda_nid_t conn[HDA_MAX_CONNECTIONS];
602 int conn_len = 0;
604 snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid,
605 get_wid_type_name(wid_type), wid_caps);
606 if (wid_caps & AC_WCAP_STEREO) {
607 unsigned int chans = get_wcaps_channels(wid_caps);
608 if (chans == 2)
609 snd_iprintf(buffer, " Stereo");
610 else
611 snd_iprintf(buffer, " %d-Channels", chans);
612 } else
613 snd_iprintf(buffer, " Mono");
614 if (wid_caps & AC_WCAP_DIGITAL)
615 snd_iprintf(buffer, " Digital");
616 if (wid_caps & AC_WCAP_IN_AMP)
617 snd_iprintf(buffer, " Amp-In");
618 if (wid_caps & AC_WCAP_OUT_AMP)
619 snd_iprintf(buffer, " Amp-Out");
620 if (wid_caps & AC_WCAP_STRIPE)
621 snd_iprintf(buffer, " Stripe");
622 if (wid_caps & AC_WCAP_LR_SWAP)
623 snd_iprintf(buffer, " R/L");
624 if (wid_caps & AC_WCAP_CP_CAPS)
625 snd_iprintf(buffer, " CP");
626 snd_iprintf(buffer, "\n");
628 print_nid_array(buffer, codec, nid, &codec->mixers);
629 print_nid_array(buffer, codec, nid, &codec->nids);
630 print_nid_pcms(buffer, codec, nid);
632 /* volume knob is a special widget that always have connection
633 * list
635 if (wid_type == AC_WID_VOL_KNB)
636 wid_caps |= AC_WCAP_CONN_LIST;
638 if (wid_caps & AC_WCAP_CONN_LIST)
639 conn_len = snd_hda_get_raw_connections(codec, nid, conn,
640 HDA_MAX_CONNECTIONS);
642 if (wid_caps & AC_WCAP_IN_AMP) {
643 snd_iprintf(buffer, " Amp-In caps: ");
644 print_amp_caps(buffer, codec, nid, HDA_INPUT);
645 snd_iprintf(buffer, " Amp-In vals: ");
646 print_amp_vals(buffer, codec, nid, HDA_INPUT,
647 wid_caps & AC_WCAP_STEREO,
648 wid_type == AC_WID_PIN ? 1 : conn_len);
650 if (wid_caps & AC_WCAP_OUT_AMP) {
651 snd_iprintf(buffer, " Amp-Out caps: ");
652 print_amp_caps(buffer, codec, nid, HDA_OUTPUT);
653 snd_iprintf(buffer, " Amp-Out vals: ");
654 if (wid_type == AC_WID_PIN &&
655 codec->pin_amp_workaround)
656 print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
657 wid_caps & AC_WCAP_STEREO,
658 conn_len);
659 else
660 print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
661 wid_caps & AC_WCAP_STEREO, 1);
664 switch (wid_type) {
665 case AC_WID_PIN: {
666 int supports_vref;
667 print_pin_caps(buffer, codec, nid, &supports_vref);
668 print_pin_ctls(buffer, codec, nid, supports_vref);
669 break;
671 case AC_WID_VOL_KNB:
672 print_vol_knob(buffer, codec, nid);
673 break;
674 case AC_WID_AUD_OUT:
675 case AC_WID_AUD_IN:
676 print_audio_io(buffer, codec, nid, wid_type);
677 if (wid_caps & AC_WCAP_DIGITAL)
678 print_digital_conv(buffer, codec, nid);
679 if (wid_caps & AC_WCAP_FORMAT_OVRD) {
680 snd_iprintf(buffer, " PCM:\n");
681 print_pcm_caps(buffer, codec, nid);
683 break;
686 if (wid_caps & AC_WCAP_UNSOL_CAP)
687 print_unsol_cap(buffer, codec, nid);
689 if (wid_caps & AC_WCAP_POWER)
690 print_power_state(buffer, codec, nid);
692 if (wid_caps & AC_WCAP_DELAY)
693 snd_iprintf(buffer, " Delay: %d samples\n",
694 (wid_caps & AC_WCAP_DELAY) >>
695 AC_WCAP_DELAY_SHIFT);
697 if (wid_caps & AC_WCAP_CONN_LIST)
698 print_conn_list(buffer, codec, nid, wid_type,
699 conn, conn_len);
701 if (wid_caps & AC_WCAP_PROC_WID)
702 print_proc_caps(buffer, codec, nid);
704 if (codec->proc_widget_hook)
705 codec->proc_widget_hook(buffer, codec, nid);
707 snd_hda_power_down(codec);
711 * create a proc read
713 int snd_hda_codec_proc_new(struct hda_codec *codec)
715 char name[32];
716 struct snd_info_entry *entry;
717 int err;
719 snprintf(name, sizeof(name), "codec#%d", codec->addr);
720 err = snd_card_proc_new(codec->bus->card, name, &entry);
721 if (err < 0)
722 return err;
724 snd_info_set_text_ops(entry, codec, print_codec_info);
725 return 0;