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