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