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