blob: b36d4d06485d5390bb13ad18f3269d2da1a6e9ab [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
Takashi Iwaic8b6bf92005-11-17 14:57:47 +010049static void print_amp_caps(struct snd_info_buffer *buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 struct hda_codec *codec, hda_nid_t nid, int dir)
51{
52 unsigned int caps;
Jaroslav Kysela7f0e2f82006-07-05 17:39:14 +020053 caps = snd_hda_param_read(codec, nid,
54 dir == HDA_OUTPUT ?
55 AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 if (caps == -1 || caps == 0) {
57 snd_iprintf(buffer, "N/A\n");
58 return;
59 }
Takashi Iwaid01ce992007-07-27 16:52:19 +020060 snd_iprintf(buffer, "ofs=0x%02x, nsteps=0x%02x, stepsize=0x%02x, "
61 "mute=%x\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 caps & AC_AMPCAP_OFFSET,
63 (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT,
64 (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT,
65 (caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT);
66}
67
Takashi Iwaic8b6bf92005-11-17 14:57:47 +010068static void print_amp_vals(struct snd_info_buffer *buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 struct hda_codec *codec, hda_nid_t nid,
Takashi Iwai3e289f12005-06-10 19:45:09 +020070 int dir, int stereo, int indices)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
72 unsigned int val;
Takashi Iwai3e289f12005-06-10 19:45:09 +020073 int i;
74
Jaroslav Kysela7f0e2f82006-07-05 17:39:14 +020075 dir = dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
Takashi Iwai3e289f12005-06-10 19:45:09 +020076 for (i = 0; i < indices; i++) {
77 snd_iprintf(buffer, " [");
78 if (stereo) {
Takashi Iwaid01ce992007-07-27 16:52:19 +020079 val = snd_hda_codec_read(codec, nid, 0,
80 AC_VERB_GET_AMP_GAIN_MUTE,
Takashi Iwai3e289f12005-06-10 19:45:09 +020081 AC_AMP_GET_LEFT | dir | i);
82 snd_iprintf(buffer, "0x%02x ", val);
83 }
Takashi Iwaid01ce992007-07-27 16:52:19 +020084 val = snd_hda_codec_read(codec, nid, 0,
85 AC_VERB_GET_AMP_GAIN_MUTE,
Takashi Iwai3e289f12005-06-10 19:45:09 +020086 AC_AMP_GET_RIGHT | dir | i);
87 snd_iprintf(buffer, "0x%02x]", val);
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 }
Takashi Iwai3e289f12005-06-10 19:45:09 +020089 snd_iprintf(buffer, "\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -070090}
91
Takashi Iwaib90d7762006-11-07 16:10:06 +010092static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
93{
94 static unsigned int rates[] = {
95 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
96 96000, 176400, 192000, 384000
97 };
98 int i;
99
100 pcm &= AC_SUPPCM_RATES;
101 snd_iprintf(buffer, " rates [0x%x]:", pcm);
102 for (i = 0; i < ARRAY_SIZE(rates); i++)
103 if (pcm & (1 << i))
104 snd_iprintf(buffer, " %d", rates[i]);
105 snd_iprintf(buffer, "\n");
106}
107
108static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)
109{
110 static unsigned int bits[] = { 8, 16, 20, 24, 32 };
111 int i;
112
113 pcm = (pcm >> 16) & 0xff;
114 snd_iprintf(buffer, " bits [0x%x]:", pcm);
115 for (i = 0; i < ARRAY_SIZE(bits); i++)
116 if (pcm & (1 << i))
117 snd_iprintf(buffer, " %d", bits[i]);
118 snd_iprintf(buffer, "\n");
119}
120
121static void print_pcm_formats(struct snd_info_buffer *buffer,
122 unsigned int streams)
123{
124 snd_iprintf(buffer, " formats [0x%x]:", streams & 0xf);
125 if (streams & AC_SUPFMT_PCM)
126 snd_iprintf(buffer, " PCM");
127 if (streams & AC_SUPFMT_FLOAT32)
128 snd_iprintf(buffer, " FLOAT");
129 if (streams & AC_SUPFMT_AC3)
130 snd_iprintf(buffer, " AC3");
131 snd_iprintf(buffer, "\n");
132}
133
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100134static void print_pcm_caps(struct snd_info_buffer *buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 struct hda_codec *codec, hda_nid_t nid)
136{
137 unsigned int pcm = snd_hda_param_read(codec, nid, AC_PAR_PCM);
138 unsigned int stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
139 if (pcm == -1 || stream == -1) {
140 snd_iprintf(buffer, "N/A\n");
141 return;
142 }
Takashi Iwaib90d7762006-11-07 16:10:06 +0100143 print_pcm_rates(buffer, pcm);
144 print_pcm_bits(buffer, pcm);
145 print_pcm_formats(buffer, stream);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146}
147
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148static const char *get_jack_connection(u32 cfg)
149{
150 static char *names[16] = {
151 "Unknown", "1/8", "1/4", "ATAPI",
152 "RCA", "Optical","Digital", "Analog",
153 "DIN", "XLR", "RJ11", "Comb",
154 NULL, NULL, NULL, "Other"
155 };
156 cfg = (cfg & AC_DEFCFG_CONN_TYPE) >> AC_DEFCFG_CONN_TYPE_SHIFT;
157 if (names[cfg])
158 return names[cfg];
159 else
160 return "UNKNOWN";
161}
162
163static const char *get_jack_color(u32 cfg)
164{
165 static char *names[16] = {
166 "Unknown", "Black", "Grey", "Blue",
167 "Green", "Red", "Orange", "Yellow",
168 "Purple", "Pink", NULL, NULL,
169 NULL, NULL, "White", "Other",
170 };
171 cfg = (cfg & AC_DEFCFG_COLOR) >> AC_DEFCFG_COLOR_SHIFT;
172 if (names[cfg])
173 return names[cfg];
174 else
175 return "UNKNOWN";
176}
177
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100178static void print_pin_caps(struct snd_info_buffer *buffer,
Andrew Paprocki797760a2008-01-18 12:51:11 +0100179 struct hda_codec *codec, hda_nid_t nid,
180 int *supports_vref)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181{
Takashi Iwaib0c95f52005-04-20 13:44:08 +0200182 static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" };
Takashi Iwaie97a5162007-10-26 14:56:36 +0200183 unsigned int caps, val;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184
185 caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
Robin H. Johnson0481f452008-09-13 16:54:57 -0700186 snd_iprintf(buffer, " Pincap 0x%08x:", caps);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 if (caps & AC_PINCAP_IN)
188 snd_iprintf(buffer, " IN");
189 if (caps & AC_PINCAP_OUT)
190 snd_iprintf(buffer, " OUT");
191 if (caps & AC_PINCAP_HP_DRV)
192 snd_iprintf(buffer, " HP");
Takashi Iwai58854922006-06-21 19:19:25 +0200193 if (caps & AC_PINCAP_EAPD)
194 snd_iprintf(buffer, " EAPD");
195 if (caps & AC_PINCAP_PRES_DETECT)
196 snd_iprintf(buffer, " Detect");
Andrew Paprocki797760a2008-01-18 12:51:11 +0100197 if (caps & AC_PINCAP_BALANCE)
198 snd_iprintf(buffer, " Balanced");
Takashi Iwaic4920602008-07-30 15:13:29 +0200199 if (caps & AC_PINCAP_HDMI) {
200 /* Realtek uses this bit as a different meaning */
201 if ((codec->vendor_id >> 16) == 0x10ec)
202 snd_iprintf(buffer, " R/L");
203 else
204 snd_iprintf(buffer, " HDMI");
205 }
Andrew Paprocki797760a2008-01-18 12:51:11 +0100206 if (caps & AC_PINCAP_TRIG_REQ)
207 snd_iprintf(buffer, " Trigger");
208 if (caps & AC_PINCAP_IMP_SENSE)
209 snd_iprintf(buffer, " ImpSense");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 snd_iprintf(buffer, "\n");
Andrew Paprocki797760a2008-01-18 12:51:11 +0100211 if (caps & AC_PINCAP_VREF) {
212 unsigned int vref =
213 (caps & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
214 snd_iprintf(buffer, " Vref caps:");
215 if (vref & AC_PINCAP_VREF_HIZ)
216 snd_iprintf(buffer, " HIZ");
217 if (vref & AC_PINCAP_VREF_50)
218 snd_iprintf(buffer, " 50");
219 if (vref & AC_PINCAP_VREF_GRD)
220 snd_iprintf(buffer, " GRD");
221 if (vref & AC_PINCAP_VREF_80)
222 snd_iprintf(buffer, " 80");
223 if (vref & AC_PINCAP_VREF_100)
224 snd_iprintf(buffer, " 100");
225 snd_iprintf(buffer, "\n");
226 *supports_vref = 1;
227 } else
228 *supports_vref = 0;
229 if (caps & AC_PINCAP_EAPD) {
230 val = snd_hda_codec_read(codec, nid, 0,
231 AC_VERB_GET_EAPD_BTLENABLE, 0);
232 snd_iprintf(buffer, " EAPD 0x%x:", val);
233 if (val & AC_EAPDBTL_BALANCED)
234 snd_iprintf(buffer, " BALANCED");
235 if (val & AC_EAPDBTL_EAPD)
236 snd_iprintf(buffer, " EAPD");
237 if (val & AC_EAPDBTL_LR_SWAP)
238 snd_iprintf(buffer, " R/L");
239 snd_iprintf(buffer, "\n");
240 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
Takashi Iwaib0c95f52005-04-20 13:44:08 +0200242 snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps,
243 jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT],
Matthew Ranostay50a9f792008-10-25 01:05:45 -0400244 snd_hda_get_jack_type(caps),
245 snd_hda_get_jack_connectivity(caps),
246 snd_hda_get_jack_location(caps));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 snd_iprintf(buffer, " Conn = %s, Color = %s\n",
248 get_jack_connection(caps),
249 get_jack_color(caps));
Andrew Paprocki797760a2008-01-18 12:51:11 +0100250 /* Default association and sequence values refer to default grouping
251 * of pin complexes and their sequence within the group. This is used
252 * for priority and resource allocation.
253 */
254 snd_iprintf(buffer, " DefAssociation = 0x%x, Sequence = 0x%x\n",
255 (caps & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT,
256 caps & AC_DEFCFG_SEQUENCE);
257 if (((caps & AC_DEFCFG_MISC) >> AC_DEFCFG_MISC_SHIFT) &
258 AC_DEFCFG_MISC_NO_PRESENCE) {
259 /* Miscellaneous bit indicates external hardware does not
260 * support presence detection even if the pin complex
261 * indicates it is supported.
262 */
263 snd_iprintf(buffer, " Misc = NO_PRESENCE\n");
Takashi Iwaie97a5162007-10-26 14:56:36 +0200264 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265}
266
Andrew Paprocki797760a2008-01-18 12:51:11 +0100267static void print_pin_ctls(struct snd_info_buffer *buffer,
268 struct hda_codec *codec, hda_nid_t nid,
269 int supports_vref)
270{
271 unsigned int pinctls;
272
273 pinctls = snd_hda_codec_read(codec, nid, 0,
274 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
275 snd_iprintf(buffer, " Pin-ctls: 0x%02x:", pinctls);
276 if (pinctls & AC_PINCTL_IN_EN)
277 snd_iprintf(buffer, " IN");
278 if (pinctls & AC_PINCTL_OUT_EN)
279 snd_iprintf(buffer, " OUT");
280 if (pinctls & AC_PINCTL_HP_EN)
281 snd_iprintf(buffer, " HP");
282 if (supports_vref) {
283 int vref = pinctls & AC_PINCTL_VREFEN;
284 switch (vref) {
285 case AC_PINCTL_VREF_HIZ:
286 snd_iprintf(buffer, " VREF_HIZ");
287 break;
288 case AC_PINCTL_VREF_50:
289 snd_iprintf(buffer, " VREF_50");
290 break;
291 case AC_PINCTL_VREF_GRD:
292 snd_iprintf(buffer, " VREF_GRD");
293 break;
294 case AC_PINCTL_VREF_80:
295 snd_iprintf(buffer, " VREF_80");
296 break;
297 case AC_PINCTL_VREF_100:
298 snd_iprintf(buffer, " VREF_100");
299 break;
300 }
301 }
302 snd_iprintf(buffer, "\n");
303}
304
305static void print_vol_knob(struct snd_info_buffer *buffer,
306 struct hda_codec *codec, hda_nid_t nid)
307{
308 unsigned int cap = snd_hda_param_read(codec, nid,
309 AC_PAR_VOL_KNB_CAP);
310 snd_iprintf(buffer, " Volume-Knob: delta=%d, steps=%d, ",
311 (cap >> 7) & 1, cap & 0x7f);
312 cap = snd_hda_codec_read(codec, nid, 0,
313 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
314 snd_iprintf(buffer, "direct=%d, val=%d\n",
315 (cap >> 7) & 1, cap & 0x7f);
316}
317
318static void print_audio_io(struct snd_info_buffer *buffer,
319 struct hda_codec *codec, hda_nid_t nid,
320 unsigned int wid_type)
321{
322 int conv = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
323 snd_iprintf(buffer,
324 " Converter: stream=%d, channel=%d\n",
325 (conv & AC_CONV_STREAM) >> AC_CONV_STREAM_SHIFT,
326 conv & AC_CONV_CHANNEL);
327
328 if (wid_type == AC_WID_AUD_IN && (conv & AC_CONV_CHANNEL) == 0) {
329 int sdi = snd_hda_codec_read(codec, nid, 0,
330 AC_VERB_GET_SDI_SELECT, 0);
331 snd_iprintf(buffer, " SDI-Select: %d\n",
332 sdi & AC_SDI_SELECT);
333 }
334}
335
336static void print_digital_conv(struct snd_info_buffer *buffer,
337 struct hda_codec *codec, hda_nid_t nid)
338{
339 unsigned int digi1 = snd_hda_codec_read(codec, nid, 0,
340 AC_VERB_GET_DIGI_CONVERT_1, 0);
Andrew Paprocki797760a2008-01-18 12:51:11 +0100341 snd_iprintf(buffer, " Digital:");
342 if (digi1 & AC_DIG1_ENABLE)
343 snd_iprintf(buffer, " Enabled");
344 if (digi1 & AC_DIG1_V)
345 snd_iprintf(buffer, " Validity");
346 if (digi1 & AC_DIG1_VCFG)
347 snd_iprintf(buffer, " ValidityCfg");
348 if (digi1 & AC_DIG1_EMPHASIS)
349 snd_iprintf(buffer, " Preemphasis");
350 if (digi1 & AC_DIG1_COPYRIGHT)
351 snd_iprintf(buffer, " Copyright");
352 if (digi1 & AC_DIG1_NONAUDIO)
353 snd_iprintf(buffer, " Non-Audio");
354 if (digi1 & AC_DIG1_PROFESSIONAL)
355 snd_iprintf(buffer, " Pro");
356 if (digi1 & AC_DIG1_LEVEL)
357 snd_iprintf(buffer, " GenLevel");
358 snd_iprintf(buffer, "\n");
Takashi Iwaia1855d82008-06-19 15:41:37 +0200359 snd_iprintf(buffer, " Digital category: 0x%x\n",
360 (digi1 >> 8) & AC_DIG2_CC);
Andrew Paprocki797760a2008-01-18 12:51:11 +0100361}
362
363static const char *get_pwr_state(u32 state)
364{
365 static const char *buf[4] = {
366 "D0", "D1", "D2", "D3"
367 };
368 if (state < 4)
369 return buf[state];
370 return "UNKNOWN";
371}
372
373static void print_power_state(struct snd_info_buffer *buffer,
374 struct hda_codec *codec, hda_nid_t nid)
375{
376 int pwr = snd_hda_codec_read(codec, nid, 0,
377 AC_VERB_GET_POWER_STATE, 0);
378 snd_iprintf(buffer, " Power: setting=%s, actual=%s\n",
379 get_pwr_state(pwr & AC_PWRST_SETTING),
380 get_pwr_state((pwr & AC_PWRST_ACTUAL) >>
381 AC_PWRST_ACTUAL_SHIFT));
382}
383
384static void print_unsol_cap(struct snd_info_buffer *buffer,
385 struct hda_codec *codec, hda_nid_t nid)
386{
387 int unsol = snd_hda_codec_read(codec, nid, 0,
388 AC_VERB_GET_UNSOLICITED_RESPONSE, 0);
389 snd_iprintf(buffer,
390 " Unsolicited: tag=%02x, enabled=%d\n",
391 unsol & AC_UNSOL_TAG,
392 (unsol & AC_UNSOL_ENABLED) ? 1 : 0);
393}
394
395static void print_proc_caps(struct snd_info_buffer *buffer,
396 struct hda_codec *codec, hda_nid_t nid)
397{
398 unsigned int proc_caps = snd_hda_param_read(codec, nid,
399 AC_PAR_PROC_CAP);
400 snd_iprintf(buffer, " Processing caps: benign=%d, ncoeff=%d\n",
401 proc_caps & AC_PCAP_BENIGN,
402 (proc_caps & AC_PCAP_NUM_COEF) >> AC_PCAP_NUM_COEF_SHIFT);
403}
404
405static void print_conn_list(struct snd_info_buffer *buffer,
406 struct hda_codec *codec, hda_nid_t nid,
407 unsigned int wid_type, hda_nid_t *conn,
408 int conn_len)
409{
410 int c, curr = -1;
411
412 if (conn_len > 1 && wid_type != AC_WID_AUD_MIX)
413 curr = snd_hda_codec_read(codec, nid, 0,
414 AC_VERB_GET_CONNECT_SEL, 0);
415 snd_iprintf(buffer, " Connection: %d\n", conn_len);
416 if (conn_len > 0) {
417 snd_iprintf(buffer, " ");
418 for (c = 0; c < conn_len; c++) {
419 snd_iprintf(buffer, " 0x%02x", conn[c]);
420 if (c == curr)
421 snd_iprintf(buffer, "*");
422 }
423 snd_iprintf(buffer, "\n");
424 }
425}
426
427static void print_realtek_coef(struct snd_info_buffer *buffer,
428 struct hda_codec *codec, hda_nid_t nid)
429{
430 int coeff = snd_hda_codec_read(codec, nid, 0,
431 AC_VERB_GET_PROC_COEF, 0);
432 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
433 coeff = snd_hda_codec_read(codec, nid, 0,
434 AC_VERB_GET_COEF_INDEX, 0);
435 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
436}
437
438static void print_gpio(struct snd_info_buffer *buffer,
439 struct hda_codec *codec, hda_nid_t nid)
440{
441 unsigned int gpio =
442 snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
443 unsigned int enable, direction, wake, unsol, sticky, data;
444 int i, max;
445 snd_iprintf(buffer, "GPIO: io=%d, o=%d, i=%d, "
446 "unsolicited=%d, wake=%d\n",
447 gpio & AC_GPIO_IO_COUNT,
448 (gpio & AC_GPIO_O_COUNT) >> AC_GPIO_O_COUNT_SHIFT,
449 (gpio & AC_GPIO_I_COUNT) >> AC_GPIO_I_COUNT_SHIFT,
450 (gpio & AC_GPIO_UNSOLICITED) ? 1 : 0,
451 (gpio & AC_GPIO_WAKE) ? 1 : 0);
452 max = gpio & AC_GPIO_IO_COUNT;
453 enable = snd_hda_codec_read(codec, nid, 0,
454 AC_VERB_GET_GPIO_MASK, 0);
455 direction = snd_hda_codec_read(codec, nid, 0,
456 AC_VERB_GET_GPIO_DIRECTION, 0);
457 wake = snd_hda_codec_read(codec, nid, 0,
458 AC_VERB_GET_GPIO_WAKE_MASK, 0);
459 unsol = snd_hda_codec_read(codec, nid, 0,
460 AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK, 0);
461 sticky = snd_hda_codec_read(codec, nid, 0,
462 AC_VERB_GET_GPIO_STICKY_MASK, 0);
463 data = snd_hda_codec_read(codec, nid, 0,
464 AC_VERB_GET_GPIO_DATA, 0);
465 for (i = 0; i < max; ++i)
466 snd_iprintf(buffer,
467 " IO[%d]: enable=%d, dir=%d, wake=%d, "
468 "sticky=%d, data=%d\n", i,
469 (enable & (1<<i)) ? 1 : 0,
470 (direction & (1<<i)) ? 1 : 0,
471 (wake & (1<<i)) ? 1 : 0,
472 (sticky & (1<<i)) ? 1 : 0,
473 (data & (1<<i)) ? 1 : 0);
474 /* FIXME: add GPO and GPI pin information */
475}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476
Takashi Iwaid01ce992007-07-27 16:52:19 +0200477static void print_codec_info(struct snd_info_entry *entry,
478 struct snd_info_buffer *buffer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479{
480 struct hda_codec *codec = entry->private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 hda_nid_t nid;
482 int i, nodes;
483
Takashi Iwaif44ac832008-07-30 15:01:45 +0200484 snd_iprintf(buffer, "Codec: %s\n",
485 codec->name ? codec->name : "Not Set");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 snd_iprintf(buffer, "Address: %d\n", codec->addr);
487 snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id);
488 snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id);
489 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
Jonathan Phenixe25c05f2007-06-19 18:31:28 +0200490
491 if (codec->mfg)
492 snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg);
493 else
494 snd_iprintf(buffer, "No Modem Function Group found\n");
495
Takashi Iwaiec9e1c52005-09-07 13:29:22 +0200496 if (! codec->afg)
497 return;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200498 snd_hda_power_up(codec);
Takashi Iwaib90d7762006-11-07 16:10:06 +0100499 snd_iprintf(buffer, "Default PCM:\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 print_pcm_caps(buffer, codec, codec->afg);
501 snd_iprintf(buffer, "Default Amp-In caps: ");
502 print_amp_caps(buffer, codec, codec->afg, HDA_INPUT);
503 snd_iprintf(buffer, "Default Amp-Out caps: ");
504 print_amp_caps(buffer, codec, codec->afg, HDA_OUTPUT);
505
506 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
507 if (! nid || nodes < 0) {
508 snd_iprintf(buffer, "Invalid AFG subtree\n");
Takashi Iwaicb53c622007-08-10 17:21:45 +0200509 snd_hda_power_down(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 return;
511 }
Andrew Paprocki797760a2008-01-18 12:51:11 +0100512
513 print_gpio(buffer, codec, codec->afg);
514
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 for (i = 0; i < nodes; i++, nid++) {
Takashi Iwaid01ce992007-07-27 16:52:19 +0200516 unsigned int wid_caps =
517 snd_hda_param_read(codec, nid,
518 AC_PAR_AUDIO_WIDGET_CAP);
519 unsigned int wid_type =
520 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai3e289f12005-06-10 19:45:09 +0200521 hda_nid_t conn[HDA_MAX_CONNECTIONS];
Andrew Paprocki797760a2008-01-18 12:51:11 +0100522 int conn_len = 0;
Takashi Iwai3e289f12005-06-10 19:45:09 +0200523
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid,
525 get_wid_type_name(wid_type), wid_caps);
Takashi Iwaic4920602008-07-30 15:13:29 +0200526 if (wid_caps & AC_WCAP_STEREO) {
527 unsigned int chans;
528 chans = (wid_caps & AC_WCAP_CHAN_CNT_EXT) >> 13;
529 chans = ((chans << 1) | 1) + 1;
530 if (chans == 2)
531 snd_iprintf(buffer, " Stereo");
532 else
533 snd_iprintf(buffer, " %d-Channels", chans);
534 } else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 snd_iprintf(buffer, " Mono");
536 if (wid_caps & AC_WCAP_DIGITAL)
537 snd_iprintf(buffer, " Digital");
538 if (wid_caps & AC_WCAP_IN_AMP)
539 snd_iprintf(buffer, " Amp-In");
540 if (wid_caps & AC_WCAP_OUT_AMP)
541 snd_iprintf(buffer, " Amp-Out");
Andrew Paprocki797760a2008-01-18 12:51:11 +0100542 if (wid_caps & AC_WCAP_STRIPE)
543 snd_iprintf(buffer, " Stripe");
544 if (wid_caps & AC_WCAP_LR_SWAP)
545 snd_iprintf(buffer, " R/L");
Takashi Iwaic4920602008-07-30 15:13:29 +0200546 if (wid_caps & AC_WCAP_CP_CAPS)
547 snd_iprintf(buffer, " CP");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 snd_iprintf(buffer, "\n");
549
Takashi Iwaie1716132007-11-16 17:52:39 +0100550 /* volume knob is a special widget that always have connection
551 * list
552 */
553 if (wid_type == AC_WID_VOL_KNB)
554 wid_caps |= AC_WCAP_CONN_LIST;
555
Takashi Iwai3e289f12005-06-10 19:45:09 +0200556 if (wid_caps & AC_WCAP_CONN_LIST)
557 conn_len = snd_hda_get_connections(codec, nid, conn,
558 HDA_MAX_CONNECTIONS);
559
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 if (wid_caps & AC_WCAP_IN_AMP) {
561 snd_iprintf(buffer, " Amp-In caps: ");
562 print_amp_caps(buffer, codec, nid, HDA_INPUT);
563 snd_iprintf(buffer, " Amp-In vals: ");
564 print_amp_vals(buffer, codec, nid, HDA_INPUT,
Takashi Iwai9e03ad72008-02-22 18:46:00 +0100565 wid_caps & AC_WCAP_STEREO,
566 wid_type == AC_WID_PIN ? 1 : conn_len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 }
568 if (wid_caps & AC_WCAP_OUT_AMP) {
569 snd_iprintf(buffer, " Amp-Out caps: ");
570 print_amp_caps(buffer, codec, nid, HDA_OUTPUT);
571 snd_iprintf(buffer, " Amp-Out vals: ");
572 print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
Takashi Iwai3e289f12005-06-10 19:45:09 +0200573 wid_caps & AC_WCAP_STEREO, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 }
575
Takashi Iwaie97a5162007-10-26 14:56:36 +0200576 switch (wid_type) {
Andrew Paprocki797760a2008-01-18 12:51:11 +0100577 case AC_WID_PIN: {
578 int supports_vref;
579 print_pin_caps(buffer, codec, nid, &supports_vref);
580 print_pin_ctls(buffer, codec, nid, supports_vref);
Takashi Iwaie97a5162007-10-26 14:56:36 +0200581 break;
Andrew Paprocki797760a2008-01-18 12:51:11 +0100582 }
Takashi Iwaie97a5162007-10-26 14:56:36 +0200583 case AC_WID_VOL_KNB:
Andrew Paprocki797760a2008-01-18 12:51:11 +0100584 print_vol_knob(buffer, codec, nid);
Takashi Iwaie97a5162007-10-26 14:56:36 +0200585 break;
586 case AC_WID_AUD_OUT:
587 case AC_WID_AUD_IN:
Andrew Paprocki797760a2008-01-18 12:51:11 +0100588 print_audio_io(buffer, codec, nid, wid_type);
589 if (wid_caps & AC_WCAP_DIGITAL)
590 print_digital_conv(buffer, codec, nid);
Takashi Iwaie97a5162007-10-26 14:56:36 +0200591 if (wid_caps & AC_WCAP_FORMAT_OVRD) {
592 snd_iprintf(buffer, " PCM:\n");
593 print_pcm_caps(buffer, codec, nid);
594 }
595 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 }
597
Andrew Paprocki797760a2008-01-18 12:51:11 +0100598 if (wid_caps & AC_WCAP_UNSOL_CAP)
599 print_unsol_cap(buffer, codec, nid);
Takashi Iwaib7027cc2005-11-02 18:13:41 +0100600
Andrew Paprocki797760a2008-01-18 12:51:11 +0100601 if (wid_caps & AC_WCAP_POWER)
602 print_power_state(buffer, codec, nid);
603
604 if (wid_caps & AC_WCAP_DELAY)
605 snd_iprintf(buffer, " Delay: %d samples\n",
606 (wid_caps & AC_WCAP_DELAY) >>
607 AC_WCAP_DELAY_SHIFT);
608
609 if (wid_caps & AC_WCAP_CONN_LIST)
610 print_conn_list(buffer, codec, nid, wid_type,
611 conn, conn_len);
612
613 if (wid_caps & AC_WCAP_PROC_WID)
614 print_proc_caps(buffer, codec, nid);
615
616 /* NID 0x20 == Realtek Define Registers */
617 if (codec->vendor_id == 0x10ec && nid == 0x20)
618 print_realtek_coef(buffer, codec, nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 }
Takashi Iwaicb53c622007-08-10 17:21:45 +0200620 snd_hda_power_down(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621}
622
623/*
624 * create a proc read
625 */
626int snd_hda_codec_proc_new(struct hda_codec *codec)
627{
628 char name[32];
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100629 struct snd_info_entry *entry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 int err;
631
632 snprintf(name, sizeof(name), "codec#%d", codec->addr);
633 err = snd_card_proc_new(codec->bus->card, name, &entry);
634 if (err < 0)
635 return err;
636
Takashi Iwaibf850202006-04-28 15:13:41 +0200637 snd_info_set_text_ops(entry, codec, print_codec_info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 return 0;
639}
640