Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include <linux/init.h> |
Takashi Iwai | 4eea309 | 2013-02-07 18:18:19 +0100 | [diff] [blame] | 25 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <sound/core.h> |
David Henningsson | cd26251 | 2014-01-29 10:37:10 +0100 | [diff] [blame] | 27 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include "hda_codec.h" |
Adrian Bunk | 1861204 | 2005-11-23 13:14:50 +0100 | [diff] [blame] | 29 | #include "hda_local.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
David Henningsson | cd26251 | 2014-01-29 10:37:10 +0100 | [diff] [blame] | 31 | static int dump_coef = -1; |
| 32 | module_param(dump_coef, int, 0644); |
| 33 | MODULE_PARM_DESC(dump_coef, "Dump processing coefficients in codec proc file (-1=auto, 0=disable, 1=enable)"); |
| 34 | |
Wu Fengguang | 83d605f | 2009-11-18 12:38:08 +0800 | [diff] [blame] | 35 | static char *bits_names(unsigned int bits, char *names[], int size) |
| 36 | { |
| 37 | int i, n; |
| 38 | static char buf[128]; |
| 39 | |
| 40 | for (i = 0, n = 0; i < size; i++) { |
| 41 | if (bits & (1U<<i) && names[i]) |
| 42 | n += snprintf(buf + n, sizeof(buf) - n, " %s", |
| 43 | names[i]); |
| 44 | } |
| 45 | buf[n] = '\0'; |
| 46 | |
| 47 | return buf; |
| 48 | } |
| 49 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | static const char *get_wid_type_name(unsigned int wid_value) |
| 51 | { |
| 52 | static char *names[16] = { |
| 53 | [AC_WID_AUD_OUT] = "Audio Output", |
| 54 | [AC_WID_AUD_IN] = "Audio Input", |
| 55 | [AC_WID_AUD_MIX] = "Audio Mixer", |
| 56 | [AC_WID_AUD_SEL] = "Audio Selector", |
| 57 | [AC_WID_PIN] = "Pin Complex", |
| 58 | [AC_WID_POWER] = "Power Widget", |
| 59 | [AC_WID_VOL_KNB] = "Volume Knob Widget", |
| 60 | [AC_WID_BEEP] = "Beep Generator Widget", |
| 61 | [AC_WID_VENDOR] = "Vendor Defined Widget", |
| 62 | }; |
Takashi Iwai | 3a90274 | 2012-01-10 12:41:22 +0100 | [diff] [blame] | 63 | if (wid_value == -1) |
| 64 | return "UNKNOWN Widget"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | wid_value &= 0xf; |
| 66 | if (names[wid_value]) |
| 67 | return names[wid_value]; |
| 68 | else |
Takashi Iwai | 3bc8952 | 2006-10-17 20:41:38 +0200 | [diff] [blame] | 69 | return "UNKNOWN Widget"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | } |
| 71 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 72 | static void print_nid_array(struct snd_info_buffer *buffer, |
| 73 | struct hda_codec *codec, hda_nid_t nid, |
| 74 | struct snd_array *array) |
Jaroslav Kysela | 3911a4c | 2009-11-11 13:43:01 +0100 | [diff] [blame] | 75 | { |
| 76 | int i; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 77 | struct hda_nid_item *items = array->list, *item; |
Jaroslav Kysela | 3911a4c | 2009-11-11 13:43:01 +0100 | [diff] [blame] | 78 | struct snd_kcontrol *kctl; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 79 | for (i = 0; i < array->used; i++) { |
| 80 | item = &items[i]; |
| 81 | if (item->nid == nid) { |
| 82 | kctl = item->kctl; |
Jaroslav Kysela | 3911a4c | 2009-11-11 13:43:01 +0100 | [diff] [blame] | 83 | snd_iprintf(buffer, |
| 84 | " Control: name=\"%s\", index=%i, device=%i\n", |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 85 | kctl->id.name, kctl->id.index + item->index, |
| 86 | kctl->id.device); |
Jaroslav Kysela | 9e3fd87 | 2009-12-08 17:45:25 +0100 | [diff] [blame] | 87 | if (item->flags & HDA_NID_ITEM_AMP) |
| 88 | snd_iprintf(buffer, |
| 89 | " ControlAmp: chs=%lu, dir=%s, " |
| 90 | "idx=%lu, ofs=%lu\n", |
| 91 | get_amp_channels(kctl), |
| 92 | get_amp_direction(kctl) ? "Out" : "In", |
| 93 | get_amp_index(kctl), |
| 94 | get_amp_offset(kctl)); |
Jaroslav Kysela | 3911a4c | 2009-11-11 13:43:01 +0100 | [diff] [blame] | 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | static void print_nid_pcms(struct snd_info_buffer *buffer, |
| 100 | struct hda_codec *codec, hda_nid_t nid) |
| 101 | { |
| 102 | int pcm, type; |
| 103 | struct hda_pcm *cpcm; |
| 104 | for (pcm = 0; pcm < codec->num_pcms; pcm++) { |
| 105 | cpcm = &codec->pcm_info[pcm]; |
| 106 | for (type = 0; type < 2; type++) { |
| 107 | if (cpcm->stream[type].nid != nid || cpcm->pcm == NULL) |
| 108 | continue; |
| 109 | snd_iprintf(buffer, " Device: name=\"%s\", " |
| 110 | "type=\"%s\", device=%i\n", |
| 111 | cpcm->name, |
| 112 | snd_hda_pcm_type_name[cpcm->pcm_type], |
| 113 | cpcm->pcm->device); |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 118 | static void print_amp_caps(struct snd_info_buffer *buffer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | struct hda_codec *codec, hda_nid_t nid, int dir) |
| 120 | { |
| 121 | unsigned int caps; |
Jaroslav Kysela | 7f0e2f8 | 2006-07-05 17:39:14 +0200 | [diff] [blame] | 122 | caps = snd_hda_param_read(codec, nid, |
| 123 | dir == HDA_OUTPUT ? |
| 124 | AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | if (caps == -1 || caps == 0) { |
| 126 | snd_iprintf(buffer, "N/A\n"); |
| 127 | return; |
| 128 | } |
Takashi Iwai | d01ce99 | 2007-07-27 16:52:19 +0200 | [diff] [blame] | 129 | snd_iprintf(buffer, "ofs=0x%02x, nsteps=0x%02x, stepsize=0x%02x, " |
| 130 | "mute=%x\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | caps & AC_AMPCAP_OFFSET, |
| 132 | (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT, |
| 133 | (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT, |
| 134 | (caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT); |
| 135 | } |
| 136 | |
Takashi Iwai | cc26173 | 2015-03-16 10:18:08 +0100 | [diff] [blame] | 137 | /* is this a stereo widget or a stereo-to-mono mix? */ |
| 138 | static bool is_stereo_amps(struct hda_codec *codec, hda_nid_t nid, |
| 139 | int dir, unsigned int wcaps, int indices) |
| 140 | { |
| 141 | hda_nid_t conn; |
| 142 | |
| 143 | if (wcaps & AC_WCAP_STEREO) |
| 144 | return true; |
| 145 | /* check for a stereo-to-mono mix; it must be: |
| 146 | * only a single connection, only for input, and only a mixer widget |
| 147 | */ |
| 148 | if (indices != 1 || dir != HDA_INPUT || |
| 149 | get_wcaps_type(wcaps) != AC_WID_AUD_MIX) |
| 150 | return false; |
| 151 | |
| 152 | if (snd_hda_get_raw_connections(codec, nid, &conn, 1) < 0) |
| 153 | return false; |
| 154 | /* the connection source is a stereo? */ |
| 155 | wcaps = snd_hda_param_read(codec, conn, AC_PAR_AUDIO_WIDGET_CAP); |
| 156 | return !!(wcaps & AC_WCAP_STEREO); |
| 157 | } |
| 158 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 159 | static void print_amp_vals(struct snd_info_buffer *buffer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | struct hda_codec *codec, hda_nid_t nid, |
Takashi Iwai | cc26173 | 2015-03-16 10:18:08 +0100 | [diff] [blame] | 161 | int dir, unsigned int wcaps, int indices) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | { |
| 163 | unsigned int val; |
Takashi Iwai | cc26173 | 2015-03-16 10:18:08 +0100 | [diff] [blame] | 164 | bool stereo; |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 165 | int i; |
| 166 | |
Takashi Iwai | cc26173 | 2015-03-16 10:18:08 +0100 | [diff] [blame] | 167 | stereo = is_stereo_amps(codec, nid, dir, wcaps, indices); |
| 168 | |
Jaroslav Kysela | 7f0e2f8 | 2006-07-05 17:39:14 +0200 | [diff] [blame] | 169 | dir = dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT; |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 170 | for (i = 0; i < indices; i++) { |
| 171 | snd_iprintf(buffer, " ["); |
Takashi Iwai | 2f17972 | 2012-12-10 15:58:34 +0100 | [diff] [blame] | 172 | val = snd_hda_codec_read(codec, nid, 0, |
| 173 | AC_VERB_GET_AMP_GAIN_MUTE, |
| 174 | AC_AMP_GET_LEFT | dir | i); |
| 175 | snd_iprintf(buffer, "0x%02x", val); |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 176 | if (stereo) { |
Takashi Iwai | d01ce99 | 2007-07-27 16:52:19 +0200 | [diff] [blame] | 177 | val = snd_hda_codec_read(codec, nid, 0, |
| 178 | AC_VERB_GET_AMP_GAIN_MUTE, |
Takashi Iwai | 2f17972 | 2012-12-10 15:58:34 +0100 | [diff] [blame] | 179 | AC_AMP_GET_RIGHT | dir | i); |
| 180 | snd_iprintf(buffer, " 0x%02x", val); |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 181 | } |
Takashi Iwai | 2f17972 | 2012-12-10 15:58:34 +0100 | [diff] [blame] | 182 | snd_iprintf(buffer, "]"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | } |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 184 | snd_iprintf(buffer, "\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Wu Fengguang | 33deeca | 2008-11-18 11:47:51 +0800 | [diff] [blame] | 187 | static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm) |
| 188 | { |
Takashi Iwai | f71ff0d | 2011-10-06 08:16:29 +0200 | [diff] [blame] | 189 | static unsigned int rates[] = { |
| 190 | 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200, |
| 191 | 96000, 176400, 192000, 384000 |
| 192 | }; |
| 193 | int i; |
Wu Fengguang | d39b435 | 2008-11-19 15:14:02 +0800 | [diff] [blame] | 194 | |
Takashi Iwai | b90d776 | 2006-11-07 16:10:06 +0100 | [diff] [blame] | 195 | pcm &= AC_SUPPCM_RATES; |
| 196 | snd_iprintf(buffer, " rates [0x%x]:", pcm); |
Takashi Iwai | f71ff0d | 2011-10-06 08:16:29 +0200 | [diff] [blame] | 197 | for (i = 0; i < ARRAY_SIZE(rates); i++) |
| 198 | if (pcm & (1 << i)) |
| 199 | snd_iprintf(buffer, " %d", rates[i]); |
| 200 | snd_iprintf(buffer, "\n"); |
Takashi Iwai | b90d776 | 2006-11-07 16:10:06 +0100 | [diff] [blame] | 201 | } |
| 202 | |
Wu Fengguang | d39b435 | 2008-11-19 15:14:02 +0800 | [diff] [blame] | 203 | static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm) |
| 204 | { |
| 205 | char buf[SND_PRINT_BITS_ADVISED_BUFSIZE]; |
Takashi Iwai | b90d776 | 2006-11-07 16:10:06 +0100 | [diff] [blame] | 206 | |
Takashi Iwai | b0e6481 | 2008-11-25 16:07:01 +0100 | [diff] [blame] | 207 | snd_iprintf(buffer, " bits [0x%x]:", (pcm >> 16) & 0xff); |
Wu Fengguang | d39b435 | 2008-11-19 15:14:02 +0800 | [diff] [blame] | 208 | snd_print_pcm_bits(pcm, buf, sizeof(buf)); |
| 209 | snd_iprintf(buffer, "%s\n", buf); |
Takashi Iwai | b90d776 | 2006-11-07 16:10:06 +0100 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | static void print_pcm_formats(struct snd_info_buffer *buffer, |
| 213 | unsigned int streams) |
| 214 | { |
| 215 | snd_iprintf(buffer, " formats [0x%x]:", streams & 0xf); |
| 216 | if (streams & AC_SUPFMT_PCM) |
| 217 | snd_iprintf(buffer, " PCM"); |
| 218 | if (streams & AC_SUPFMT_FLOAT32) |
| 219 | snd_iprintf(buffer, " FLOAT"); |
| 220 | if (streams & AC_SUPFMT_AC3) |
| 221 | snd_iprintf(buffer, " AC3"); |
| 222 | snd_iprintf(buffer, "\n"); |
| 223 | } |
| 224 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 225 | static void print_pcm_caps(struct snd_info_buffer *buffer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | struct hda_codec *codec, hda_nid_t nid) |
| 227 | { |
| 228 | unsigned int pcm = snd_hda_param_read(codec, nid, AC_PAR_PCM); |
| 229 | unsigned int stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM); |
| 230 | if (pcm == -1 || stream == -1) { |
| 231 | snd_iprintf(buffer, "N/A\n"); |
| 232 | return; |
| 233 | } |
Takashi Iwai | b90d776 | 2006-11-07 16:10:06 +0100 | [diff] [blame] | 234 | print_pcm_rates(buffer, pcm); |
| 235 | print_pcm_bits(buffer, pcm); |
| 236 | print_pcm_formats(buffer, stream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | } |
| 238 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | static const char *get_jack_connection(u32 cfg) |
| 240 | { |
| 241 | static char *names[16] = { |
| 242 | "Unknown", "1/8", "1/4", "ATAPI", |
| 243 | "RCA", "Optical","Digital", "Analog", |
| 244 | "DIN", "XLR", "RJ11", "Comb", |
| 245 | NULL, NULL, NULL, "Other" |
| 246 | }; |
| 247 | cfg = (cfg & AC_DEFCFG_CONN_TYPE) >> AC_DEFCFG_CONN_TYPE_SHIFT; |
| 248 | if (names[cfg]) |
| 249 | return names[cfg]; |
| 250 | else |
| 251 | return "UNKNOWN"; |
| 252 | } |
| 253 | |
| 254 | static const char *get_jack_color(u32 cfg) |
| 255 | { |
| 256 | static char *names[16] = { |
| 257 | "Unknown", "Black", "Grey", "Blue", |
| 258 | "Green", "Red", "Orange", "Yellow", |
| 259 | "Purple", "Pink", NULL, NULL, |
| 260 | NULL, NULL, "White", "Other", |
| 261 | }; |
| 262 | cfg = (cfg & AC_DEFCFG_COLOR) >> AC_DEFCFG_COLOR_SHIFT; |
| 263 | if (names[cfg]) |
| 264 | return names[cfg]; |
| 265 | else |
| 266 | return "UNKNOWN"; |
| 267 | } |
| 268 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 269 | static void print_pin_caps(struct snd_info_buffer *buffer, |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 270 | struct hda_codec *codec, hda_nid_t nid, |
| 271 | int *supports_vref) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | { |
Takashi Iwai | b0c95f5 | 2005-04-20 13:44:08 +0200 | [diff] [blame] | 273 | static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" }; |
Takashi Iwai | e97a516 | 2007-10-26 14:56:36 +0200 | [diff] [blame] | 274 | unsigned int caps, val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | |
| 276 | caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); |
Robin H. Johnson | 0481f45 | 2008-09-13 16:54:57 -0700 | [diff] [blame] | 277 | snd_iprintf(buffer, " Pincap 0x%08x:", caps); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | if (caps & AC_PINCAP_IN) |
| 279 | snd_iprintf(buffer, " IN"); |
| 280 | if (caps & AC_PINCAP_OUT) |
| 281 | snd_iprintf(buffer, " OUT"); |
| 282 | if (caps & AC_PINCAP_HP_DRV) |
| 283 | snd_iprintf(buffer, " HP"); |
Takashi Iwai | 5885492 | 2006-06-21 19:19:25 +0200 | [diff] [blame] | 284 | if (caps & AC_PINCAP_EAPD) |
| 285 | snd_iprintf(buffer, " EAPD"); |
| 286 | if (caps & AC_PINCAP_PRES_DETECT) |
| 287 | snd_iprintf(buffer, " Detect"); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 288 | if (caps & AC_PINCAP_BALANCE) |
| 289 | snd_iprintf(buffer, " Balanced"); |
Takashi Iwai | c492060 | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 290 | if (caps & AC_PINCAP_HDMI) { |
| 291 | /* Realtek uses this bit as a different meaning */ |
| 292 | if ((codec->vendor_id >> 16) == 0x10ec) |
| 293 | snd_iprintf(buffer, " R/L"); |
Wu Fengguang | b923528 | 2009-12-11 12:28:33 +0800 | [diff] [blame] | 294 | else { |
| 295 | if (caps & AC_PINCAP_HBR) |
| 296 | snd_iprintf(buffer, " HBR"); |
Takashi Iwai | c492060 | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 297 | snd_iprintf(buffer, " HDMI"); |
Wu Fengguang | b923528 | 2009-12-11 12:28:33 +0800 | [diff] [blame] | 298 | } |
Takashi Iwai | c492060 | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 299 | } |
Wu Fengguang | 728765b | 2009-12-11 12:28:34 +0800 | [diff] [blame] | 300 | if (caps & AC_PINCAP_DP) |
| 301 | snd_iprintf(buffer, " DP"); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 302 | if (caps & AC_PINCAP_TRIG_REQ) |
| 303 | snd_iprintf(buffer, " Trigger"); |
| 304 | if (caps & AC_PINCAP_IMP_SENSE) |
| 305 | snd_iprintf(buffer, " ImpSense"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | snd_iprintf(buffer, "\n"); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 307 | if (caps & AC_PINCAP_VREF) { |
| 308 | unsigned int vref = |
| 309 | (caps & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 310 | snd_iprintf(buffer, " Vref caps:"); |
| 311 | if (vref & AC_PINCAP_VREF_HIZ) |
| 312 | snd_iprintf(buffer, " HIZ"); |
| 313 | if (vref & AC_PINCAP_VREF_50) |
| 314 | snd_iprintf(buffer, " 50"); |
| 315 | if (vref & AC_PINCAP_VREF_GRD) |
| 316 | snd_iprintf(buffer, " GRD"); |
| 317 | if (vref & AC_PINCAP_VREF_80) |
| 318 | snd_iprintf(buffer, " 80"); |
| 319 | if (vref & AC_PINCAP_VREF_100) |
| 320 | snd_iprintf(buffer, " 100"); |
| 321 | snd_iprintf(buffer, "\n"); |
| 322 | *supports_vref = 1; |
| 323 | } else |
| 324 | *supports_vref = 0; |
| 325 | if (caps & AC_PINCAP_EAPD) { |
| 326 | val = snd_hda_codec_read(codec, nid, 0, |
| 327 | AC_VERB_GET_EAPD_BTLENABLE, 0); |
| 328 | snd_iprintf(buffer, " EAPD 0x%x:", val); |
| 329 | if (val & AC_EAPDBTL_BALANCED) |
| 330 | snd_iprintf(buffer, " BALANCED"); |
| 331 | if (val & AC_EAPDBTL_EAPD) |
| 332 | snd_iprintf(buffer, " EAPD"); |
| 333 | if (val & AC_EAPDBTL_LR_SWAP) |
| 334 | snd_iprintf(buffer, " R/L"); |
| 335 | snd_iprintf(buffer, "\n"); |
| 336 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); |
Takashi Iwai | b0c95f5 | 2005-04-20 13:44:08 +0200 | [diff] [blame] | 338 | snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps, |
| 339 | jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT], |
Matthew Ranostay | 50a9f79 | 2008-10-25 01:05:45 -0400 | [diff] [blame] | 340 | snd_hda_get_jack_type(caps), |
| 341 | snd_hda_get_jack_connectivity(caps), |
| 342 | snd_hda_get_jack_location(caps)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | snd_iprintf(buffer, " Conn = %s, Color = %s\n", |
| 344 | get_jack_connection(caps), |
| 345 | get_jack_color(caps)); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 346 | /* Default association and sequence values refer to default grouping |
| 347 | * of pin complexes and their sequence within the group. This is used |
| 348 | * for priority and resource allocation. |
| 349 | */ |
| 350 | snd_iprintf(buffer, " DefAssociation = 0x%x, Sequence = 0x%x\n", |
| 351 | (caps & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT, |
| 352 | caps & AC_DEFCFG_SEQUENCE); |
| 353 | if (((caps & AC_DEFCFG_MISC) >> AC_DEFCFG_MISC_SHIFT) & |
| 354 | AC_DEFCFG_MISC_NO_PRESENCE) { |
| 355 | /* Miscellaneous bit indicates external hardware does not |
| 356 | * support presence detection even if the pin complex |
| 357 | * indicates it is supported. |
| 358 | */ |
| 359 | snd_iprintf(buffer, " Misc = NO_PRESENCE\n"); |
Takashi Iwai | e97a516 | 2007-10-26 14:56:36 +0200 | [diff] [blame] | 360 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | } |
| 362 | |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 363 | static void print_pin_ctls(struct snd_info_buffer *buffer, |
| 364 | struct hda_codec *codec, hda_nid_t nid, |
| 365 | int supports_vref) |
| 366 | { |
| 367 | unsigned int pinctls; |
| 368 | |
| 369 | pinctls = snd_hda_codec_read(codec, nid, 0, |
| 370 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 371 | snd_iprintf(buffer, " Pin-ctls: 0x%02x:", pinctls); |
| 372 | if (pinctls & AC_PINCTL_IN_EN) |
| 373 | snd_iprintf(buffer, " IN"); |
| 374 | if (pinctls & AC_PINCTL_OUT_EN) |
| 375 | snd_iprintf(buffer, " OUT"); |
| 376 | if (pinctls & AC_PINCTL_HP_EN) |
| 377 | snd_iprintf(buffer, " HP"); |
| 378 | if (supports_vref) { |
| 379 | int vref = pinctls & AC_PINCTL_VREFEN; |
| 380 | switch (vref) { |
| 381 | case AC_PINCTL_VREF_HIZ: |
| 382 | snd_iprintf(buffer, " VREF_HIZ"); |
| 383 | break; |
| 384 | case AC_PINCTL_VREF_50: |
| 385 | snd_iprintf(buffer, " VREF_50"); |
| 386 | break; |
| 387 | case AC_PINCTL_VREF_GRD: |
| 388 | snd_iprintf(buffer, " VREF_GRD"); |
| 389 | break; |
| 390 | case AC_PINCTL_VREF_80: |
| 391 | snd_iprintf(buffer, " VREF_80"); |
| 392 | break; |
| 393 | case AC_PINCTL_VREF_100: |
| 394 | snd_iprintf(buffer, " VREF_100"); |
| 395 | break; |
| 396 | } |
| 397 | } |
| 398 | snd_iprintf(buffer, "\n"); |
| 399 | } |
| 400 | |
| 401 | static void print_vol_knob(struct snd_info_buffer *buffer, |
| 402 | struct hda_codec *codec, hda_nid_t nid) |
| 403 | { |
| 404 | unsigned int cap = snd_hda_param_read(codec, nid, |
| 405 | AC_PAR_VOL_KNB_CAP); |
| 406 | snd_iprintf(buffer, " Volume-Knob: delta=%d, steps=%d, ", |
| 407 | (cap >> 7) & 1, cap & 0x7f); |
| 408 | cap = snd_hda_codec_read(codec, nid, 0, |
| 409 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
| 410 | snd_iprintf(buffer, "direct=%d, val=%d\n", |
| 411 | (cap >> 7) & 1, cap & 0x7f); |
| 412 | } |
| 413 | |
| 414 | static void print_audio_io(struct snd_info_buffer *buffer, |
| 415 | struct hda_codec *codec, hda_nid_t nid, |
| 416 | unsigned int wid_type) |
| 417 | { |
Jaroslav Kysela | 3911a4c | 2009-11-11 13:43:01 +0100 | [diff] [blame] | 418 | int conv = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 419 | snd_iprintf(buffer, |
| 420 | " Converter: stream=%d, channel=%d\n", |
| 421 | (conv & AC_CONV_STREAM) >> AC_CONV_STREAM_SHIFT, |
| 422 | conv & AC_CONV_CHANNEL); |
| 423 | |
| 424 | if (wid_type == AC_WID_AUD_IN && (conv & AC_CONV_CHANNEL) == 0) { |
| 425 | int sdi = snd_hda_codec_read(codec, nid, 0, |
| 426 | AC_VERB_GET_SDI_SELECT, 0); |
| 427 | snd_iprintf(buffer, " SDI-Select: %d\n", |
| 428 | sdi & AC_SDI_SELECT); |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | static void print_digital_conv(struct snd_info_buffer *buffer, |
| 433 | struct hda_codec *codec, hda_nid_t nid) |
| 434 | { |
| 435 | unsigned int digi1 = snd_hda_codec_read(codec, nid, 0, |
| 436 | AC_VERB_GET_DIGI_CONVERT_1, 0); |
Wang Xingchao | 6152597 | 2012-08-13 15:43:49 +0800 | [diff] [blame] | 437 | unsigned char digi2 = digi1 >> 8; |
| 438 | unsigned char digi3 = digi1 >> 16; |
| 439 | |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 440 | snd_iprintf(buffer, " Digital:"); |
| 441 | if (digi1 & AC_DIG1_ENABLE) |
| 442 | snd_iprintf(buffer, " Enabled"); |
| 443 | if (digi1 & AC_DIG1_V) |
| 444 | snd_iprintf(buffer, " Validity"); |
| 445 | if (digi1 & AC_DIG1_VCFG) |
| 446 | snd_iprintf(buffer, " ValidityCfg"); |
| 447 | if (digi1 & AC_DIG1_EMPHASIS) |
| 448 | snd_iprintf(buffer, " Preemphasis"); |
| 449 | if (digi1 & AC_DIG1_COPYRIGHT) |
Wang Xingchao | 088c820 | 2012-08-13 14:11:10 +0800 | [diff] [blame] | 450 | snd_iprintf(buffer, " Non-Copyright"); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 451 | if (digi1 & AC_DIG1_NONAUDIO) |
| 452 | snd_iprintf(buffer, " Non-Audio"); |
| 453 | if (digi1 & AC_DIG1_PROFESSIONAL) |
| 454 | snd_iprintf(buffer, " Pro"); |
| 455 | if (digi1 & AC_DIG1_LEVEL) |
| 456 | snd_iprintf(buffer, " GenLevel"); |
Wang Xingchao | 6152597 | 2012-08-13 15:43:49 +0800 | [diff] [blame] | 457 | if (digi3 & AC_DIG3_KAE) |
| 458 | snd_iprintf(buffer, " KAE"); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 459 | snd_iprintf(buffer, "\n"); |
Takashi Iwai | a1855d8 | 2008-06-19 15:41:37 +0200 | [diff] [blame] | 460 | snd_iprintf(buffer, " Digital category: 0x%x\n", |
Wang Xingchao | 6152597 | 2012-08-13 15:43:49 +0800 | [diff] [blame] | 461 | digi2 & AC_DIG2_CC); |
| 462 | snd_iprintf(buffer, " IEC Coding Type: 0x%x\n", |
| 463 | digi3 & AC_DIG3_ICT); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | static const char *get_pwr_state(u32 state) |
| 467 | { |
Takashi Iwai | 167d2d5 | 2012-06-06 12:17:20 +0200 | [diff] [blame] | 468 | static const char * const buf[] = { |
| 469 | "D0", "D1", "D2", "D3", "D3cold" |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 470 | }; |
Takashi Iwai | 167d2d5 | 2012-06-06 12:17:20 +0200 | [diff] [blame] | 471 | if (state < ARRAY_SIZE(buf)) |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 472 | return buf[state]; |
| 473 | return "UNKNOWN"; |
| 474 | } |
| 475 | |
| 476 | static void print_power_state(struct snd_info_buffer *buffer, |
| 477 | struct hda_codec *codec, hda_nid_t nid) |
| 478 | { |
Wu Fengguang | 83d605f | 2009-11-18 12:38:08 +0800 | [diff] [blame] | 479 | static char *names[] = { |
| 480 | [ilog2(AC_PWRST_D0SUP)] = "D0", |
| 481 | [ilog2(AC_PWRST_D1SUP)] = "D1", |
| 482 | [ilog2(AC_PWRST_D2SUP)] = "D2", |
| 483 | [ilog2(AC_PWRST_D3SUP)] = "D3", |
| 484 | [ilog2(AC_PWRST_D3COLDSUP)] = "D3cold", |
| 485 | [ilog2(AC_PWRST_S3D3COLDSUP)] = "S3D3cold", |
| 486 | [ilog2(AC_PWRST_CLKSTOP)] = "CLKSTOP", |
| 487 | [ilog2(AC_PWRST_EPSS)] = "EPSS", |
| 488 | }; |
| 489 | |
| 490 | int sup = snd_hda_param_read(codec, nid, AC_PAR_POWER_STATE); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 491 | int pwr = snd_hda_codec_read(codec, nid, 0, |
| 492 | AC_VERB_GET_POWER_STATE, 0); |
Wang Xingchao | e076eb5 | 2012-06-07 16:52:07 +0800 | [diff] [blame] | 493 | if (sup != -1) |
Wu Fengguang | 83d605f | 2009-11-18 12:38:08 +0800 | [diff] [blame] | 494 | snd_iprintf(buffer, " Power states: %s\n", |
| 495 | bits_names(sup, names, ARRAY_SIZE(names))); |
| 496 | |
Wang Xingchao | ce63f3b | 2012-06-06 13:49:44 +0800 | [diff] [blame] | 497 | snd_iprintf(buffer, " Power: setting=%s, actual=%s", |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 498 | get_pwr_state(pwr & AC_PWRST_SETTING), |
| 499 | get_pwr_state((pwr & AC_PWRST_ACTUAL) >> |
| 500 | AC_PWRST_ACTUAL_SHIFT)); |
Wang Xingchao | ce63f3b | 2012-06-06 13:49:44 +0800 | [diff] [blame] | 501 | if (pwr & AC_PWRST_ERROR) |
| 502 | snd_iprintf(buffer, ", Error"); |
| 503 | if (pwr & AC_PWRST_CLK_STOP_OK) |
| 504 | snd_iprintf(buffer, ", Clock-stop-OK"); |
| 505 | if (pwr & AC_PWRST_SETTING_RESET) |
| 506 | snd_iprintf(buffer, ", Setting-reset"); |
| 507 | snd_iprintf(buffer, "\n"); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | static void print_unsol_cap(struct snd_info_buffer *buffer, |
| 511 | struct hda_codec *codec, hda_nid_t nid) |
| 512 | { |
| 513 | int unsol = snd_hda_codec_read(codec, nid, 0, |
| 514 | AC_VERB_GET_UNSOLICITED_RESPONSE, 0); |
| 515 | snd_iprintf(buffer, |
| 516 | " Unsolicited: tag=%02x, enabled=%d\n", |
| 517 | unsol & AC_UNSOL_TAG, |
| 518 | (unsol & AC_UNSOL_ENABLED) ? 1 : 0); |
| 519 | } |
| 520 | |
David Henningsson | cd26251 | 2014-01-29 10:37:10 +0100 | [diff] [blame] | 521 | static inline bool can_dump_coef(struct hda_codec *codec) |
| 522 | { |
| 523 | switch (dump_coef) { |
| 524 | case 0: return false; |
| 525 | case 1: return true; |
| 526 | default: return codec->dump_coef; |
| 527 | } |
| 528 | } |
| 529 | |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 530 | static void print_proc_caps(struct snd_info_buffer *buffer, |
| 531 | struct hda_codec *codec, hda_nid_t nid) |
| 532 | { |
David Henningsson | cd26251 | 2014-01-29 10:37:10 +0100 | [diff] [blame] | 533 | unsigned int i, ncoeff, oldindex; |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 534 | unsigned int proc_caps = snd_hda_param_read(codec, nid, |
| 535 | AC_PAR_PROC_CAP); |
David Henningsson | cd26251 | 2014-01-29 10:37:10 +0100 | [diff] [blame] | 536 | ncoeff = (proc_caps & AC_PCAP_NUM_COEF) >> AC_PCAP_NUM_COEF_SHIFT; |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 537 | snd_iprintf(buffer, " Processing caps: benign=%d, ncoeff=%d\n", |
David Henningsson | cd26251 | 2014-01-29 10:37:10 +0100 | [diff] [blame] | 538 | proc_caps & AC_PCAP_BENIGN, ncoeff); |
| 539 | |
| 540 | if (!can_dump_coef(codec)) |
| 541 | return; |
| 542 | |
| 543 | /* Note: This is racy - another process could run in parallel and change |
| 544 | the coef index too. */ |
| 545 | oldindex = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_COEF_INDEX, 0); |
| 546 | for (i = 0; i < ncoeff; i++) { |
| 547 | unsigned int val; |
| 548 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, i); |
| 549 | val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, |
| 550 | 0); |
| 551 | snd_iprintf(buffer, " Coeff 0x%02x: 0x%04x\n", i, val); |
| 552 | } |
| 553 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, oldindex); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | static void print_conn_list(struct snd_info_buffer *buffer, |
| 557 | struct hda_codec *codec, hda_nid_t nid, |
| 558 | unsigned int wid_type, hda_nid_t *conn, |
| 559 | int conn_len) |
| 560 | { |
| 561 | int c, curr = -1; |
Wang Xingchao | 8b2c7a5 | 2013-06-24 23:41:23 -0400 | [diff] [blame] | 562 | const hda_nid_t *list; |
| 563 | int cache_len; |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 564 | |
Takashi Iwai | 07a1e81 | 2009-03-19 17:08:19 +0100 | [diff] [blame] | 565 | if (conn_len > 1 && |
| 566 | wid_type != AC_WID_AUD_MIX && |
| 567 | wid_type != AC_WID_VOL_KNB && |
| 568 | wid_type != AC_WID_POWER) |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 569 | curr = snd_hda_codec_read(codec, nid, 0, |
| 570 | AC_VERB_GET_CONNECT_SEL, 0); |
| 571 | snd_iprintf(buffer, " Connection: %d\n", conn_len); |
| 572 | if (conn_len > 0) { |
| 573 | snd_iprintf(buffer, " "); |
| 574 | for (c = 0; c < conn_len; c++) { |
| 575 | snd_iprintf(buffer, " 0x%02x", conn[c]); |
| 576 | if (c == curr) |
| 577 | snd_iprintf(buffer, "*"); |
| 578 | } |
| 579 | snd_iprintf(buffer, "\n"); |
| 580 | } |
Wang Xingchao | 8b2c7a5 | 2013-06-24 23:41:23 -0400 | [diff] [blame] | 581 | |
| 582 | /* Get Cache connections info */ |
| 583 | cache_len = snd_hda_get_conn_list(codec, nid, &list); |
| 584 | if (cache_len != conn_len |
| 585 | || memcmp(list, conn, conn_len)) { |
| 586 | snd_iprintf(buffer, " In-driver Connection: %d\n", cache_len); |
| 587 | if (cache_len > 0) { |
| 588 | snd_iprintf(buffer, " "); |
| 589 | for (c = 0; c < cache_len; c++) |
| 590 | snd_iprintf(buffer, " 0x%02x", list[c]); |
| 591 | snd_iprintf(buffer, "\n"); |
| 592 | } |
| 593 | } |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 594 | } |
| 595 | |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 596 | static void print_gpio(struct snd_info_buffer *buffer, |
| 597 | struct hda_codec *codec, hda_nid_t nid) |
| 598 | { |
| 599 | unsigned int gpio = |
| 600 | snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP); |
| 601 | unsigned int enable, direction, wake, unsol, sticky, data; |
| 602 | int i, max; |
| 603 | snd_iprintf(buffer, "GPIO: io=%d, o=%d, i=%d, " |
| 604 | "unsolicited=%d, wake=%d\n", |
| 605 | gpio & AC_GPIO_IO_COUNT, |
| 606 | (gpio & AC_GPIO_O_COUNT) >> AC_GPIO_O_COUNT_SHIFT, |
| 607 | (gpio & AC_GPIO_I_COUNT) >> AC_GPIO_I_COUNT_SHIFT, |
| 608 | (gpio & AC_GPIO_UNSOLICITED) ? 1 : 0, |
| 609 | (gpio & AC_GPIO_WAKE) ? 1 : 0); |
| 610 | max = gpio & AC_GPIO_IO_COUNT; |
Takashi Iwai | c4dc507 | 2008-11-04 13:30:57 +0100 | [diff] [blame] | 611 | if (!max || max > 8) |
| 612 | return; |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 613 | enable = snd_hda_codec_read(codec, nid, 0, |
| 614 | AC_VERB_GET_GPIO_MASK, 0); |
| 615 | direction = snd_hda_codec_read(codec, nid, 0, |
| 616 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 617 | wake = snd_hda_codec_read(codec, nid, 0, |
| 618 | AC_VERB_GET_GPIO_WAKE_MASK, 0); |
| 619 | unsol = snd_hda_codec_read(codec, nid, 0, |
| 620 | AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK, 0); |
| 621 | sticky = snd_hda_codec_read(codec, nid, 0, |
| 622 | AC_VERB_GET_GPIO_STICKY_MASK, 0); |
| 623 | data = snd_hda_codec_read(codec, nid, 0, |
| 624 | AC_VERB_GET_GPIO_DATA, 0); |
| 625 | for (i = 0; i < max; ++i) |
| 626 | snd_iprintf(buffer, |
| 627 | " IO[%d]: enable=%d, dir=%d, wake=%d, " |
Takashi Iwai | 8563964 | 2008-11-19 14:14:50 +0100 | [diff] [blame] | 628 | "sticky=%d, data=%d, unsol=%d\n", i, |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 629 | (enable & (1<<i)) ? 1 : 0, |
| 630 | (direction & (1<<i)) ? 1 : 0, |
| 631 | (wake & (1<<i)) ? 1 : 0, |
| 632 | (sticky & (1<<i)) ? 1 : 0, |
Takashi Iwai | 8563964 | 2008-11-19 14:14:50 +0100 | [diff] [blame] | 633 | (data & (1<<i)) ? 1 : 0, |
| 634 | (unsol & (1<<i)) ? 1 : 0); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 635 | /* FIXME: add GPO and GPI pin information */ |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 636 | print_nid_array(buffer, codec, nid, &codec->mixers); |
| 637 | print_nid_array(buffer, codec, nid, &codec->nids); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 638 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | |
Mengdong Lin | 7a624ea | 2013-08-26 21:35:31 -0400 | [diff] [blame] | 640 | static void print_device_list(struct snd_info_buffer *buffer, |
| 641 | struct hda_codec *codec, hda_nid_t nid) |
| 642 | { |
| 643 | int i, curr = -1; |
| 644 | u8 dev_list[AC_MAX_DEV_LIST_LEN]; |
| 645 | int devlist_len; |
| 646 | |
| 647 | devlist_len = snd_hda_get_devices(codec, nid, dev_list, |
| 648 | AC_MAX_DEV_LIST_LEN); |
| 649 | snd_iprintf(buffer, " Devices: %d\n", devlist_len); |
| 650 | if (devlist_len <= 0) |
| 651 | return; |
| 652 | |
| 653 | curr = snd_hda_codec_read(codec, nid, 0, |
| 654 | AC_VERB_GET_DEVICE_SEL, 0); |
| 655 | |
| 656 | for (i = 0; i < devlist_len; i++) { |
| 657 | if (i == curr) |
| 658 | snd_iprintf(buffer, " *"); |
| 659 | else |
| 660 | snd_iprintf(buffer, " "); |
| 661 | |
| 662 | snd_iprintf(buffer, |
| 663 | "Dev %02d: PD = %d, ELDV = %d, IA = %d\n", i, |
| 664 | !!(dev_list[i] & AC_DE_PD), |
| 665 | !!(dev_list[i] & AC_DE_ELDV), |
| 666 | !!(dev_list[i] & AC_DE_IA)); |
| 667 | } |
| 668 | } |
| 669 | |
Takashi Iwai | d01ce99 | 2007-07-27 16:52:19 +0200 | [diff] [blame] | 670 | static void print_codec_info(struct snd_info_entry *entry, |
| 671 | struct snd_info_buffer *buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | { |
| 673 | struct hda_codec *codec = entry->private_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | hda_nid_t nid; |
| 675 | int i, nodes; |
| 676 | |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 677 | snd_iprintf(buffer, "Codec: "); |
| 678 | if (codec->vendor_name && codec->chip_name) |
| 679 | snd_iprintf(buffer, "%s %s\n", |
| 680 | codec->vendor_name, codec->chip_name); |
| 681 | else |
| 682 | snd_iprintf(buffer, "Not Set\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | snd_iprintf(buffer, "Address: %d\n", codec->addr); |
Jaroslav Kysela | 79c944a | 2010-07-19 15:52:39 +0200 | [diff] [blame] | 684 | if (codec->afg) |
| 685 | snd_iprintf(buffer, "AFG Function Id: 0x%x (unsol %u)\n", |
| 686 | codec->afg_function_id, codec->afg_unsol); |
| 687 | if (codec->mfg) |
| 688 | snd_iprintf(buffer, "MFG Function Id: 0x%x (unsol %u)\n", |
| 689 | codec->mfg_function_id, codec->mfg_unsol); |
Pascal de Bruijn | 234b434 | 2009-03-23 11:15:59 +0100 | [diff] [blame] | 690 | snd_iprintf(buffer, "Vendor Id: 0x%08x\n", codec->vendor_id); |
| 691 | snd_iprintf(buffer, "Subsystem Id: 0x%08x\n", codec->subsystem_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id); |
Jonathan Phenix | e25c05f | 2007-06-19 18:31:28 +0200 | [diff] [blame] | 693 | |
| 694 | if (codec->mfg) |
| 695 | snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg); |
| 696 | else |
| 697 | snd_iprintf(buffer, "No Modem Function Group found\n"); |
| 698 | |
Takashi Iwai | ec9e1c5 | 2005-09-07 13:29:22 +0200 | [diff] [blame] | 699 | if (! codec->afg) |
| 700 | return; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 701 | snd_hda_power_up(codec); |
Takashi Iwai | b90d776 | 2006-11-07 16:10:06 +0100 | [diff] [blame] | 702 | snd_iprintf(buffer, "Default PCM:\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | print_pcm_caps(buffer, codec, codec->afg); |
| 704 | snd_iprintf(buffer, "Default Amp-In caps: "); |
| 705 | print_amp_caps(buffer, codec, codec->afg, HDA_INPUT); |
| 706 | snd_iprintf(buffer, "Default Amp-Out caps: "); |
| 707 | print_amp_caps(buffer, codec, codec->afg, HDA_OUTPUT); |
David Henningsson | f4f0a8c | 2013-01-08 15:01:18 +0100 | [diff] [blame] | 708 | snd_iprintf(buffer, "State of AFG node 0x%02x:\n", codec->afg); |
| 709 | print_power_state(buffer, codec, codec->afg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | |
| 711 | nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid); |
| 712 | if (! nid || nodes < 0) { |
| 713 | snd_iprintf(buffer, "Invalid AFG subtree\n"); |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 714 | snd_hda_power_down(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | return; |
| 716 | } |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 717 | |
| 718 | print_gpio(buffer, codec, codec->afg); |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 719 | if (codec->proc_widget_hook) |
| 720 | codec->proc_widget_hook(buffer, codec, codec->afg); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 721 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 722 | for (i = 0; i < nodes; i++, nid++) { |
Takashi Iwai | d01ce99 | 2007-07-27 16:52:19 +0200 | [diff] [blame] | 723 | unsigned int wid_caps = |
| 724 | snd_hda_param_read(codec, nid, |
| 725 | AC_PAR_AUDIO_WIDGET_CAP); |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 726 | unsigned int wid_type = get_wcaps_type(wid_caps); |
Takashi Iwai | 4eea309 | 2013-02-07 18:18:19 +0100 | [diff] [blame] | 727 | hda_nid_t *conn = NULL; |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 728 | int conn_len = 0; |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 729 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid, |
| 731 | get_wid_type_name(wid_type), wid_caps); |
Takashi Iwai | c492060 | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 732 | if (wid_caps & AC_WCAP_STEREO) { |
Wu Fengguang | fd72d00 | 2009-08-24 09:50:46 +0800 | [diff] [blame] | 733 | unsigned int chans = get_wcaps_channels(wid_caps); |
Takashi Iwai | c492060 | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 734 | if (chans == 2) |
| 735 | snd_iprintf(buffer, " Stereo"); |
| 736 | else |
| 737 | snd_iprintf(buffer, " %d-Channels", chans); |
| 738 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | snd_iprintf(buffer, " Mono"); |
| 740 | if (wid_caps & AC_WCAP_DIGITAL) |
| 741 | snd_iprintf(buffer, " Digital"); |
| 742 | if (wid_caps & AC_WCAP_IN_AMP) |
| 743 | snd_iprintf(buffer, " Amp-In"); |
| 744 | if (wid_caps & AC_WCAP_OUT_AMP) |
| 745 | snd_iprintf(buffer, " Amp-Out"); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 746 | if (wid_caps & AC_WCAP_STRIPE) |
| 747 | snd_iprintf(buffer, " Stripe"); |
| 748 | if (wid_caps & AC_WCAP_LR_SWAP) |
| 749 | snd_iprintf(buffer, " R/L"); |
Takashi Iwai | c492060 | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 750 | if (wid_caps & AC_WCAP_CP_CAPS) |
| 751 | snd_iprintf(buffer, " CP"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | snd_iprintf(buffer, "\n"); |
| 753 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 754 | print_nid_array(buffer, codec, nid, &codec->mixers); |
| 755 | print_nid_array(buffer, codec, nid, &codec->nids); |
Jaroslav Kysela | 3911a4c | 2009-11-11 13:43:01 +0100 | [diff] [blame] | 756 | print_nid_pcms(buffer, codec, nid); |
| 757 | |
Takashi Iwai | e171613 | 2007-11-16 17:52:39 +0100 | [diff] [blame] | 758 | /* volume knob is a special widget that always have connection |
| 759 | * list |
| 760 | */ |
| 761 | if (wid_type == AC_WID_VOL_KNB) |
| 762 | wid_caps |= AC_WCAP_CONN_LIST; |
| 763 | |
Takashi Iwai | 4eea309 | 2013-02-07 18:18:19 +0100 | [diff] [blame] | 764 | if (wid_caps & AC_WCAP_CONN_LIST) { |
| 765 | conn_len = snd_hda_get_num_raw_conns(codec, nid); |
| 766 | if (conn_len > 0) { |
| 767 | conn = kmalloc(sizeof(hda_nid_t) * conn_len, |
| 768 | GFP_KERNEL); |
| 769 | if (!conn) |
| 770 | return; |
| 771 | if (snd_hda_get_raw_connections(codec, nid, conn, |
| 772 | conn_len) < 0) |
| 773 | conn_len = 0; |
| 774 | } |
| 775 | } |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 776 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | if (wid_caps & AC_WCAP_IN_AMP) { |
| 778 | snd_iprintf(buffer, " Amp-In caps: "); |
| 779 | print_amp_caps(buffer, codec, nid, HDA_INPUT); |
| 780 | snd_iprintf(buffer, " Amp-In vals: "); |
Michael Karcher | 4f32456 | 2012-04-06 15:34:15 +0200 | [diff] [blame] | 781 | if (wid_type == AC_WID_PIN || |
| 782 | (codec->single_adc_amp && |
| 783 | wid_type == AC_WID_AUD_IN)) |
| 784 | print_amp_vals(buffer, codec, nid, HDA_INPUT, |
Takashi Iwai | cc26173 | 2015-03-16 10:18:08 +0100 | [diff] [blame] | 785 | wid_caps, 1); |
Michael Karcher | 4f32456 | 2012-04-06 15:34:15 +0200 | [diff] [blame] | 786 | else |
| 787 | print_amp_vals(buffer, codec, nid, HDA_INPUT, |
Takashi Iwai | cc26173 | 2015-03-16 10:18:08 +0100 | [diff] [blame] | 788 | wid_caps, conn_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 789 | } |
| 790 | if (wid_caps & AC_WCAP_OUT_AMP) { |
| 791 | snd_iprintf(buffer, " Amp-Out caps: "); |
| 792 | print_amp_caps(buffer, codec, nid, HDA_OUTPUT); |
| 793 | snd_iprintf(buffer, " Amp-Out vals: "); |
Takashi Iwai | 9421f95 | 2009-03-12 17:06:07 +0100 | [diff] [blame] | 794 | if (wid_type == AC_WID_PIN && |
| 795 | codec->pin_amp_workaround) |
| 796 | print_amp_vals(buffer, codec, nid, HDA_OUTPUT, |
Takashi Iwai | cc26173 | 2015-03-16 10:18:08 +0100 | [diff] [blame] | 797 | wid_caps, conn_len); |
Takashi Iwai | 9421f95 | 2009-03-12 17:06:07 +0100 | [diff] [blame] | 798 | else |
| 799 | print_amp_vals(buffer, codec, nid, HDA_OUTPUT, |
Takashi Iwai | cc26173 | 2015-03-16 10:18:08 +0100 | [diff] [blame] | 800 | wid_caps, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | } |
| 802 | |
Takashi Iwai | e97a516 | 2007-10-26 14:56:36 +0200 | [diff] [blame] | 803 | switch (wid_type) { |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 804 | case AC_WID_PIN: { |
| 805 | int supports_vref; |
| 806 | print_pin_caps(buffer, codec, nid, &supports_vref); |
| 807 | print_pin_ctls(buffer, codec, nid, supports_vref); |
Takashi Iwai | e97a516 | 2007-10-26 14:56:36 +0200 | [diff] [blame] | 808 | break; |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 809 | } |
Takashi Iwai | e97a516 | 2007-10-26 14:56:36 +0200 | [diff] [blame] | 810 | case AC_WID_VOL_KNB: |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 811 | print_vol_knob(buffer, codec, nid); |
Takashi Iwai | e97a516 | 2007-10-26 14:56:36 +0200 | [diff] [blame] | 812 | break; |
| 813 | case AC_WID_AUD_OUT: |
| 814 | case AC_WID_AUD_IN: |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 815 | print_audio_io(buffer, codec, nid, wid_type); |
| 816 | if (wid_caps & AC_WCAP_DIGITAL) |
| 817 | print_digital_conv(buffer, codec, nid); |
Takashi Iwai | e97a516 | 2007-10-26 14:56:36 +0200 | [diff] [blame] | 818 | if (wid_caps & AC_WCAP_FORMAT_OVRD) { |
| 819 | snd_iprintf(buffer, " PCM:\n"); |
| 820 | print_pcm_caps(buffer, codec, nid); |
| 821 | } |
| 822 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | } |
| 824 | |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 825 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 826 | print_unsol_cap(buffer, codec, nid); |
Takashi Iwai | b7027cc | 2005-11-02 18:13:41 +0100 | [diff] [blame] | 827 | |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 828 | if (wid_caps & AC_WCAP_POWER) |
| 829 | print_power_state(buffer, codec, nid); |
| 830 | |
| 831 | if (wid_caps & AC_WCAP_DELAY) |
| 832 | snd_iprintf(buffer, " Delay: %d samples\n", |
| 833 | (wid_caps & AC_WCAP_DELAY) >> |
| 834 | AC_WCAP_DELAY_SHIFT); |
| 835 | |
Mengdong Lin | 7a624ea | 2013-08-26 21:35:31 -0400 | [diff] [blame] | 836 | if (wid_type == AC_WID_PIN && codec->dp_mst) |
| 837 | print_device_list(buffer, codec, nid); |
| 838 | |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 839 | if (wid_caps & AC_WCAP_CONN_LIST) |
| 840 | print_conn_list(buffer, codec, nid, wid_type, |
| 841 | conn, conn_len); |
| 842 | |
| 843 | if (wid_caps & AC_WCAP_PROC_WID) |
| 844 | print_proc_caps(buffer, codec, nid); |
| 845 | |
Takashi Iwai | daead53 | 2008-11-28 12:55:36 +0100 | [diff] [blame] | 846 | if (codec->proc_widget_hook) |
| 847 | codec->proc_widget_hook(buffer, codec, nid); |
Takashi Iwai | 4eea309 | 2013-02-07 18:18:19 +0100 | [diff] [blame] | 848 | |
| 849 | kfree(conn); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | } |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 851 | snd_hda_power_down(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | } |
| 853 | |
| 854 | /* |
| 855 | * create a proc read |
| 856 | */ |
| 857 | int snd_hda_codec_proc_new(struct hda_codec *codec) |
| 858 | { |
| 859 | char name[32]; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 860 | struct snd_info_entry *entry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | int err; |
| 862 | |
| 863 | snprintf(name, sizeof(name), "codec#%d", codec->addr); |
| 864 | err = snd_card_proc_new(codec->bus->card, name, &entry); |
| 865 | if (err < 0) |
| 866 | return err; |
| 867 | |
Takashi Iwai | bf85020 | 2006-04-28 15:13:41 +0200 | [diff] [blame] | 868 | snd_info_set_text_ops(entry, codec, print_codec_info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | return 0; |
| 870 | } |
| 871 | |