blob: f465cff28041aef14d97f848f41fd722ddb37572 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <sound/core.h>
26#include "hda_codec.h"
Adrian Bunk18612042005-11-23 13:14:50 +010027#include "hda_local.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29static const char *get_wid_type_name(unsigned int wid_value)
30{
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",
41 };
42 wid_value &= 0xf;
43 if (names[wid_value])
44 return names[wid_value];
45 else
Takashi Iwai3bc89522006-10-17 20:41:38 +020046 return "UNKNOWN Widget";
Linus Torvalds1da177e2005-04-16 15:20:36 -070047}
48
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +010049static void print_nid_mixers(struct snd_info_buffer *buffer,
50 struct hda_codec *codec, hda_nid_t nid)
51{
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);
61 }
62 }
63}
64
65static void print_nid_pcms(struct snd_info_buffer *buffer,
66 struct hda_codec *codec, hda_nid_t nid)
67{
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);
80 }
81 }
82}
83
Takashi Iwaic8b6bf92005-11-17 14:57:47 +010084static void print_amp_caps(struct snd_info_buffer *buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 struct hda_codec *codec, hda_nid_t nid, int dir)
86{
87 unsigned int caps;
Jaroslav Kysela7f0e2f82006-07-05 17:39:14 +020088 caps = snd_hda_param_read(codec, nid,
89 dir == HDA_OUTPUT ?
90 AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP);
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 if (caps == -1 || caps == 0) {
92 snd_iprintf(buffer, "N/A\n");
93 return;
94 }
Takashi Iwaid01ce992007-07-27 16:52:19 +020095 snd_iprintf(buffer, "ofs=0x%02x, nsteps=0x%02x, stepsize=0x%02x, "
96 "mute=%x\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 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);
101}
102
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100103static void print_amp_vals(struct snd_info_buffer *buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 struct hda_codec *codec, hda_nid_t nid,
Takashi Iwai3e289f12005-06-10 19:45:09 +0200105 int dir, int stereo, int indices)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106{
107 unsigned int val;
Takashi Iwai3e289f12005-06-10 19:45:09 +0200108 int i;
109
Jaroslav Kysela7f0e2f82006-07-05 17:39:14 +0200110 dir = dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
Takashi Iwai3e289f12005-06-10 19:45:09 +0200111 for (i = 0; i < indices; i++) {
112 snd_iprintf(buffer, " [");
113 if (stereo) {
Takashi Iwaid01ce992007-07-27 16:52:19 +0200114 val = snd_hda_codec_read(codec, nid, 0,
115 AC_VERB_GET_AMP_GAIN_MUTE,
Takashi Iwai3e289f12005-06-10 19:45:09 +0200116 AC_AMP_GET_LEFT | dir | i);
117 snd_iprintf(buffer, "0x%02x ", val);
118 }
Takashi Iwaid01ce992007-07-27 16:52:19 +0200119 val = snd_hda_codec_read(codec, nid, 0,
120 AC_VERB_GET_AMP_GAIN_MUTE,
Takashi Iwai3e289f12005-06-10 19:45:09 +0200121 AC_AMP_GET_RIGHT | dir | i);
122 snd_iprintf(buffer, "0x%02x]", val);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 }
Takashi Iwai3e289f12005-06-10 19:45:09 +0200124 snd_iprintf(buffer, "\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125}
126
Wu Fengguang33deeca2008-11-18 11:47:51 +0800127static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
128{
129 char buf[SND_PRINT_RATES_ADVISED_BUFSIZE];
Wu Fengguangd39b4352008-11-19 15:14:02 +0800130
Takashi Iwaib90d7762006-11-07 16:10:06 +0100131 pcm &= AC_SUPPCM_RATES;
132 snd_iprintf(buffer, " rates [0x%x]:", pcm);
Wu Fengguang33deeca2008-11-18 11:47:51 +0800133 snd_print_pcm_rates(pcm, buf, sizeof(buf));
134 snd_iprintf(buffer, "%s\n", buf);
Takashi Iwaib90d7762006-11-07 16:10:06 +0100135}
136
Wu Fengguangd39b4352008-11-19 15:14:02 +0800137static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)
138{
139 char buf[SND_PRINT_BITS_ADVISED_BUFSIZE];
Takashi Iwaib90d7762006-11-07 16:10:06 +0100140
Takashi Iwaib0e64812008-11-25 16:07:01 +0100141 snd_iprintf(buffer, " bits [0x%x]:", (pcm >> 16) & 0xff);
Wu Fengguangd39b4352008-11-19 15:14:02 +0800142 snd_print_pcm_bits(pcm, buf, sizeof(buf));
143 snd_iprintf(buffer, "%s\n", buf);
Takashi Iwaib90d7762006-11-07 16:10:06 +0100144}
145
146static void print_pcm_formats(struct snd_info_buffer *buffer,
147 unsigned int streams)
148{
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");
157}
158
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100159static void print_pcm_caps(struct snd_info_buffer *buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 struct hda_codec *codec, hda_nid_t nid)
161{
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;
167 }
Takashi Iwaib90d7762006-11-07 16:10:06 +0100168 print_pcm_rates(buffer, pcm);
169 print_pcm_bits(buffer, pcm);
170 print_pcm_formats(buffer, stream);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171}
172
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173static const char *get_jack_connection(u32 cfg)
174{
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"
180 };
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";
186}
187
188static const char *get_jack_color(u32 cfg)
189{
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",
195 };
196 cfg = (cfg & AC_DEFCFG_COLOR) >> AC_DEFCFG_COLOR_SHIFT;
197 if (names[cfg])
198 return names[cfg];
199 else
200 return "UNKNOWN";
201}
202
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100203static void print_pin_caps(struct snd_info_buffer *buffer,
Andrew Paprocki797760a2008-01-18 12:51:11 +0100204 struct hda_codec *codec, hda_nid_t nid,
205 int *supports_vref)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206{
Takashi Iwaib0c95f52005-04-20 13:44:08 +0200207 static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" };
Takashi Iwaie97a5162007-10-26 14:56:36 +0200208 unsigned int caps, val;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
210 caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
Robin H. Johnson0481f452008-09-13 16:54:57 -0700211 snd_iprintf(buffer, " Pincap 0x%08x:", caps);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 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");
Takashi Iwai58854922006-06-21 19:19:25 +0200218 if (caps & AC_PINCAP_EAPD)
219 snd_iprintf(buffer, " EAPD");
220 if (caps & AC_PINCAP_PRES_DETECT)
221 snd_iprintf(buffer, " Detect");
Andrew Paprocki797760a2008-01-18 12:51:11 +0100222 if (caps & AC_PINCAP_BALANCE)
223 snd_iprintf(buffer, " Balanced");
Takashi Iwaic4920602008-07-30 15:13:29 +0200224 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");
230 }
Andrew Paprocki797760a2008-01-18 12:51:11 +0100231 if (caps & AC_PINCAP_TRIG_REQ)
232 snd_iprintf(buffer, " Trigger");
233 if (caps & AC_PINCAP_IMP_SENSE)
234 snd_iprintf(buffer, " ImpSense");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 snd_iprintf(buffer, "\n");
Andrew Paprocki797760a2008-01-18 12:51:11 +0100236 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");
265 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Takashi Iwaib0c95f52005-04-20 13:44:08 +0200267 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],
Matthew Ranostay50a9f792008-10-25 01:05:45 -0400269 snd_hda_get_jack_type(caps),
270 snd_hda_get_jack_connectivity(caps),
271 snd_hda_get_jack_location(caps));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 snd_iprintf(buffer, " Conn = %s, Color = %s\n",
273 get_jack_connection(caps),
274 get_jack_color(caps));
Andrew Paprocki797760a2008-01-18 12:51:11 +0100275 /* 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.
278 */
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.
287 */
288 snd_iprintf(buffer, " Misc = NO_PRESENCE\n");
Takashi Iwaie97a5162007-10-26 14:56:36 +0200289 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290}
291
Andrew Paprocki797760a2008-01-18 12:51:11 +0100292static void print_pin_ctls(struct snd_info_buffer *buffer,
293 struct hda_codec *codec, hda_nid_t nid,
294 int supports_vref)
295{
296 unsigned int pinctls;
297
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;
325 }
326 }
327 snd_iprintf(buffer, "\n");
328}
329
330static void print_vol_knob(struct snd_info_buffer *buffer,
331 struct hda_codec *codec, hda_nid_t nid)
332{
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);
341}
342
343static void print_audio_io(struct snd_info_buffer *buffer,
344 struct hda_codec *codec, hda_nid_t nid,
345 unsigned int wid_type)
346{
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +0100347 int conv = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
Andrew Paprocki797760a2008-01-18 12:51:11 +0100348 snd_iprintf(buffer,
349 " Converter: stream=%d, channel=%d\n",
350 (conv & AC_CONV_STREAM) >> AC_CONV_STREAM_SHIFT,
351 conv & AC_CONV_CHANNEL);
352
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);
358 }
359}
360
361static void print_digital_conv(struct snd_info_buffer *buffer,
362 struct hda_codec *codec, hda_nid_t nid)
363{
364 unsigned int digi1 = snd_hda_codec_read(codec, nid, 0,
365 AC_VERB_GET_DIGI_CONVERT_1, 0);
Andrew Paprocki797760a2008-01-18 12:51:11 +0100366 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");
Takashi Iwaia1855d82008-06-19 15:41:37 +0200384 snd_iprintf(buffer, " Digital category: 0x%x\n",
385 (digi1 >> 8) & AC_DIG2_CC);
Andrew Paprocki797760a2008-01-18 12:51:11 +0100386}
387
388static const char *get_pwr_state(u32 state)
389{
390 static const char *buf[4] = {
391 "D0", "D1", "D2", "D3"
392 };
393 if (state < 4)
394 return buf[state];
395 return "UNKNOWN";
396}
397
398static void print_power_state(struct snd_info_buffer *buffer,
399 struct hda_codec *codec, hda_nid_t nid)
400{
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));
407}
408
409static void print_unsol_cap(struct snd_info_buffer *buffer,
410 struct hda_codec *codec, hda_nid_t nid)
411{
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);
418}
419
420static void print_proc_caps(struct snd_info_buffer *buffer,
421 struct hda_codec *codec, hda_nid_t nid)
422{
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);
428}
429
430static 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)
434{
435 int c, curr = -1;
436
Takashi Iwai07a1e812009-03-19 17:08:19 +0100437 if (conn_len > 1 &&
438 wid_type != AC_WID_AUD_MIX &&
439 wid_type != AC_WID_VOL_KNB &&
440 wid_type != AC_WID_POWER)
Andrew Paprocki797760a2008-01-18 12:51:11 +0100441 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, "*");
450 }
451 snd_iprintf(buffer, "\n");
452 }
453}
454
Andrew Paprocki797760a2008-01-18 12:51:11 +0100455static void print_gpio(struct snd_info_buffer *buffer,
456 struct hda_codec *codec, hda_nid_t nid)
457{
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;
Takashi Iwaic4dc5072008-11-04 13:30:57 +0100470 if (!max || max > 8)
471 return;
Andrew Paprocki797760a2008-01-18 12:51:11 +0100472 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, "
Takashi Iwai85639642008-11-19 14:14:50 +0100487 "sticky=%d, data=%d, unsol=%d\n", i,
Andrew Paprocki797760a2008-01-18 12:51:11 +0100488 (enable & (1<<i)) ? 1 : 0,
489 (direction & (1<<i)) ? 1 : 0,
490 (wake & (1<<i)) ? 1 : 0,
491 (sticky & (1<<i)) ? 1 : 0,
Takashi Iwai85639642008-11-19 14:14:50 +0100492 (data & (1<<i)) ? 1 : 0,
493 (unsol & (1<<i)) ? 1 : 0);
Andrew Paprocki797760a2008-01-18 12:51:11 +0100494 /* FIXME: add GPO and GPI pin information */
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +0100495 print_nid_mixers(buffer, codec, nid);
Andrew Paprocki797760a2008-01-18 12:51:11 +0100496}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497
Takashi Iwaid01ce992007-07-27 16:52:19 +0200498static void print_codec_info(struct snd_info_entry *entry,
499 struct snd_info_buffer *buffer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500{
501 struct hda_codec *codec = entry->private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 hda_nid_t nid;
503 int i, nodes;
504
Takashi Iwai812a2cc2009-05-16 10:00:49 +0200505 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");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 snd_iprintf(buffer, "Address: %d\n", codec->addr);
Pascal de Bruijn234b4342009-03-23 11:15:59 +0100512 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);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
Jonathan Phenixe25c05f2007-06-19 18:31:28 +0200516
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");
521
Takashi Iwaiec9e1c52005-09-07 13:29:22 +0200522 if (! codec->afg)
523 return;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200524 snd_hda_power_up(codec);
Takashi Iwaib90d7762006-11-07 16:10:06 +0100525 snd_iprintf(buffer, "Default PCM:\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 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);
531
532 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
533 if (! nid || nodes < 0) {
534 snd_iprintf(buffer, "Invalid AFG subtree\n");
Takashi Iwaicb53c622007-08-10 17:21:45 +0200535 snd_hda_power_down(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 return;
537 }
Andrew Paprocki797760a2008-01-18 12:51:11 +0100538
539 print_gpio(buffer, codec, codec->afg);
Takashi Iwai2d34e1b2008-11-28 14:35:16 +0100540 if (codec->proc_widget_hook)
541 codec->proc_widget_hook(buffer, codec, codec->afg);
Andrew Paprocki797760a2008-01-18 12:51:11 +0100542
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 for (i = 0; i < nodes; i++, nid++) {
Takashi Iwaid01ce992007-07-27 16:52:19 +0200544 unsigned int wid_caps =
545 snd_hda_param_read(codec, nid,
546 AC_PAR_AUDIO_WIDGET_CAP);
Takashi Iwaia22d5432009-07-27 12:54:26 +0200547 unsigned int wid_type = get_wcaps_type(wid_caps);
Takashi Iwai3e289f12005-06-10 19:45:09 +0200548 hda_nid_t conn[HDA_MAX_CONNECTIONS];
Andrew Paprocki797760a2008-01-18 12:51:11 +0100549 int conn_len = 0;
Takashi Iwai3e289f12005-06-10 19:45:09 +0200550
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid,
552 get_wid_type_name(wid_type), wid_caps);
Takashi Iwaic4920602008-07-30 15:13:29 +0200553 if (wid_caps & AC_WCAP_STEREO) {
Wu Fengguangfd72d002009-08-24 09:50:46 +0800554 unsigned int chans = get_wcaps_channels(wid_caps);
Takashi Iwaic4920602008-07-30 15:13:29 +0200555 if (chans == 2)
556 snd_iprintf(buffer, " Stereo");
557 else
558 snd_iprintf(buffer, " %d-Channels", chans);
559 } else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 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");
Andrew Paprocki797760a2008-01-18 12:51:11 +0100567 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");
Takashi Iwaic4920602008-07-30 15:13:29 +0200571 if (wid_caps & AC_WCAP_CP_CAPS)
572 snd_iprintf(buffer, " CP");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 snd_iprintf(buffer, "\n");
574
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +0100575 print_nid_mixers(buffer, codec, nid);
576 print_nid_pcms(buffer, codec, nid);
577
Takashi Iwaie1716132007-11-16 17:52:39 +0100578 /* volume knob is a special widget that always have connection
579 * list
580 */
581 if (wid_type == AC_WID_VOL_KNB)
582 wid_caps |= AC_WCAP_CONN_LIST;
583
Takashi Iwai3e289f12005-06-10 19:45:09 +0200584 if (wid_caps & AC_WCAP_CONN_LIST)
585 conn_len = snd_hda_get_connections(codec, nid, conn,
586 HDA_MAX_CONNECTIONS);
587
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 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,
Takashi Iwai9e03ad72008-02-22 18:46:00 +0100593 wid_caps & AC_WCAP_STEREO,
594 wid_type == AC_WID_PIN ? 1 : conn_len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 }
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: ");
Takashi Iwai9421f952009-03-12 17:06:07 +0100600 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);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 }
609
Takashi Iwaie97a5162007-10-26 14:56:36 +0200610 switch (wid_type) {
Andrew Paprocki797760a2008-01-18 12:51:11 +0100611 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);
Takashi Iwaie97a5162007-10-26 14:56:36 +0200615 break;
Andrew Paprocki797760a2008-01-18 12:51:11 +0100616 }
Takashi Iwaie97a5162007-10-26 14:56:36 +0200617 case AC_WID_VOL_KNB:
Andrew Paprocki797760a2008-01-18 12:51:11 +0100618 print_vol_knob(buffer, codec, nid);
Takashi Iwaie97a5162007-10-26 14:56:36 +0200619 break;
620 case AC_WID_AUD_OUT:
621 case AC_WID_AUD_IN:
Andrew Paprocki797760a2008-01-18 12:51:11 +0100622 print_audio_io(buffer, codec, nid, wid_type);
623 if (wid_caps & AC_WCAP_DIGITAL)
624 print_digital_conv(buffer, codec, nid);
Takashi Iwaie97a5162007-10-26 14:56:36 +0200625 if (wid_caps & AC_WCAP_FORMAT_OVRD) {
626 snd_iprintf(buffer, " PCM:\n");
627 print_pcm_caps(buffer, codec, nid);
628 }
629 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 }
631
Andrew Paprocki797760a2008-01-18 12:51:11 +0100632 if (wid_caps & AC_WCAP_UNSOL_CAP)
633 print_unsol_cap(buffer, codec, nid);
Takashi Iwaib7027cc2005-11-02 18:13:41 +0100634
Andrew Paprocki797760a2008-01-18 12:51:11 +0100635 if (wid_caps & AC_WCAP_POWER)
636 print_power_state(buffer, codec, nid);
637
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);
642
643 if (wid_caps & AC_WCAP_CONN_LIST)
644 print_conn_list(buffer, codec, nid, wid_type,
645 conn, conn_len);
646
647 if (wid_caps & AC_WCAP_PROC_WID)
648 print_proc_caps(buffer, codec, nid);
649
Takashi Iwaidaead532008-11-28 12:55:36 +0100650 if (codec->proc_widget_hook)
651 codec->proc_widget_hook(buffer, codec, nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 }
Takashi Iwaicb53c622007-08-10 17:21:45 +0200653 snd_hda_power_down(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654}
655
656/*
657 * create a proc read
658 */
659int snd_hda_codec_proc_new(struct hda_codec *codec)
660{
661 char name[32];
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100662 struct snd_info_entry *entry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 int err;
664
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;
669
Takashi Iwaibf850202006-04-28 15:13:41 +0200670 snd_info_set_text_ops(entry, codec, print_codec_info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 return 0;
672}
673