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