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