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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <sound/core.h> |
| 26 | #include "hda_codec.h" |
Adrian Bunk | 1861204 | 2005-11-23 13:14:50 +0100 | [diff] [blame] | 27 | #include "hda_local.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
| 29 | static const char *get_wid_type_name(unsigned int wid_value) |
| 30 | { |
| 31 | static char *names[16] = { |
| 32 | [AC_WID_AUD_OUT] = "Audio Output", |
| 33 | [AC_WID_AUD_IN] = "Audio Input", |
| 34 | [AC_WID_AUD_MIX] = "Audio Mixer", |
| 35 | [AC_WID_AUD_SEL] = "Audio Selector", |
| 36 | [AC_WID_PIN] = "Pin Complex", |
| 37 | [AC_WID_POWER] = "Power Widget", |
| 38 | [AC_WID_VOL_KNB] = "Volume Knob Widget", |
| 39 | [AC_WID_BEEP] = "Beep Generator Widget", |
| 40 | [AC_WID_VENDOR] = "Vendor Defined Widget", |
| 41 | }; |
| 42 | wid_value &= 0xf; |
| 43 | if (names[wid_value]) |
| 44 | return names[wid_value]; |
| 45 | else |
Takashi Iwai | 3bc8952 | 2006-10-17 20:41:38 +0200 | [diff] [blame] | 46 | return "UNKNOWN Widget"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | } |
| 48 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 49 | static void print_amp_caps(struct snd_info_buffer *buffer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | struct hda_codec *codec, hda_nid_t nid, int dir) |
| 51 | { |
| 52 | unsigned int caps; |
Jaroslav Kysela | 7f0e2f8 | 2006-07-05 17:39:14 +0200 | [diff] [blame] | 53 | caps = snd_hda_param_read(codec, nid, |
| 54 | dir == HDA_OUTPUT ? |
| 55 | AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | if (caps == -1 || caps == 0) { |
| 57 | snd_iprintf(buffer, "N/A\n"); |
| 58 | return; |
| 59 | } |
Takashi Iwai | d01ce99 | 2007-07-27 16:52:19 +0200 | [diff] [blame] | 60 | snd_iprintf(buffer, "ofs=0x%02x, nsteps=0x%02x, stepsize=0x%02x, " |
| 61 | "mute=%x\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | caps & AC_AMPCAP_OFFSET, |
| 63 | (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT, |
| 64 | (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT, |
| 65 | (caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT); |
| 66 | } |
| 67 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 68 | static void print_amp_vals(struct snd_info_buffer *buffer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | struct hda_codec *codec, hda_nid_t nid, |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 70 | int dir, int stereo, int indices) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { |
| 72 | unsigned int val; |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 73 | int i; |
| 74 | |
Jaroslav Kysela | 7f0e2f8 | 2006-07-05 17:39:14 +0200 | [diff] [blame] | 75 | dir = dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT; |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 76 | for (i = 0; i < indices; i++) { |
| 77 | snd_iprintf(buffer, " ["); |
| 78 | if (stereo) { |
Takashi Iwai | d01ce99 | 2007-07-27 16:52:19 +0200 | [diff] [blame] | 79 | val = snd_hda_codec_read(codec, nid, 0, |
| 80 | AC_VERB_GET_AMP_GAIN_MUTE, |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 81 | AC_AMP_GET_LEFT | dir | i); |
| 82 | snd_iprintf(buffer, "0x%02x ", val); |
| 83 | } |
Takashi Iwai | d01ce99 | 2007-07-27 16:52:19 +0200 | [diff] [blame] | 84 | val = snd_hda_codec_read(codec, nid, 0, |
| 85 | AC_VERB_GET_AMP_GAIN_MUTE, |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 86 | AC_AMP_GET_RIGHT | dir | i); |
| 87 | snd_iprintf(buffer, "0x%02x]", val); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | } |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 89 | snd_iprintf(buffer, "\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Wu Fengguang | 33deeca | 2008-11-18 11:47:51 +0800 | [diff] [blame] | 92 | static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm) |
| 93 | { |
| 94 | char buf[SND_PRINT_RATES_ADVISED_BUFSIZE]; |
Wu Fengguang | d39b435 | 2008-11-19 15:14:02 +0800 | [diff] [blame] | 95 | |
Takashi Iwai | b90d776 | 2006-11-07 16:10:06 +0100 | [diff] [blame] | 96 | pcm &= AC_SUPPCM_RATES; |
| 97 | snd_iprintf(buffer, " rates [0x%x]:", pcm); |
Wu Fengguang | 33deeca | 2008-11-18 11:47:51 +0800 | [diff] [blame] | 98 | snd_print_pcm_rates(pcm, buf, sizeof(buf)); |
| 99 | snd_iprintf(buffer, "%s\n", buf); |
Takashi Iwai | b90d776 | 2006-11-07 16:10:06 +0100 | [diff] [blame] | 100 | } |
| 101 | |
Wu Fengguang | d39b435 | 2008-11-19 15:14:02 +0800 | [diff] [blame] | 102 | static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm) |
| 103 | { |
| 104 | char buf[SND_PRINT_BITS_ADVISED_BUFSIZE]; |
Takashi Iwai | b90d776 | 2006-11-07 16:10:06 +0100 | [diff] [blame] | 105 | |
Takashi Iwai | b0e6481 | 2008-11-25 16:07:01 +0100 | [diff] [blame] | 106 | snd_iprintf(buffer, " bits [0x%x]:", (pcm >> 16) & 0xff); |
Wu Fengguang | d39b435 | 2008-11-19 15:14:02 +0800 | [diff] [blame] | 107 | snd_print_pcm_bits(pcm, buf, sizeof(buf)); |
| 108 | snd_iprintf(buffer, "%s\n", buf); |
Takashi Iwai | b90d776 | 2006-11-07 16:10:06 +0100 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | static void print_pcm_formats(struct snd_info_buffer *buffer, |
| 112 | unsigned int streams) |
| 113 | { |
| 114 | snd_iprintf(buffer, " formats [0x%x]:", streams & 0xf); |
| 115 | if (streams & AC_SUPFMT_PCM) |
| 116 | snd_iprintf(buffer, " PCM"); |
| 117 | if (streams & AC_SUPFMT_FLOAT32) |
| 118 | snd_iprintf(buffer, " FLOAT"); |
| 119 | if (streams & AC_SUPFMT_AC3) |
| 120 | snd_iprintf(buffer, " AC3"); |
| 121 | snd_iprintf(buffer, "\n"); |
| 122 | } |
| 123 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 124 | static void print_pcm_caps(struct snd_info_buffer *buffer, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | struct hda_codec *codec, hda_nid_t nid) |
| 126 | { |
| 127 | unsigned int pcm = snd_hda_param_read(codec, nid, AC_PAR_PCM); |
| 128 | unsigned int stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM); |
| 129 | if (pcm == -1 || stream == -1) { |
| 130 | snd_iprintf(buffer, "N/A\n"); |
| 131 | return; |
| 132 | } |
Takashi Iwai | b90d776 | 2006-11-07 16:10:06 +0100 | [diff] [blame] | 133 | print_pcm_rates(buffer, pcm); |
| 134 | print_pcm_bits(buffer, pcm); |
| 135 | print_pcm_formats(buffer, stream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | static const char *get_jack_connection(u32 cfg) |
| 139 | { |
| 140 | static char *names[16] = { |
| 141 | "Unknown", "1/8", "1/4", "ATAPI", |
| 142 | "RCA", "Optical","Digital", "Analog", |
| 143 | "DIN", "XLR", "RJ11", "Comb", |
| 144 | NULL, NULL, NULL, "Other" |
| 145 | }; |
| 146 | cfg = (cfg & AC_DEFCFG_CONN_TYPE) >> AC_DEFCFG_CONN_TYPE_SHIFT; |
| 147 | if (names[cfg]) |
| 148 | return names[cfg]; |
| 149 | else |
| 150 | return "UNKNOWN"; |
| 151 | } |
| 152 | |
| 153 | static const char *get_jack_color(u32 cfg) |
| 154 | { |
| 155 | static char *names[16] = { |
| 156 | "Unknown", "Black", "Grey", "Blue", |
| 157 | "Green", "Red", "Orange", "Yellow", |
| 158 | "Purple", "Pink", NULL, NULL, |
| 159 | NULL, NULL, "White", "Other", |
| 160 | }; |
| 161 | cfg = (cfg & AC_DEFCFG_COLOR) >> AC_DEFCFG_COLOR_SHIFT; |
| 162 | if (names[cfg]) |
| 163 | return names[cfg]; |
| 164 | else |
| 165 | return "UNKNOWN"; |
| 166 | } |
| 167 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 168 | static void print_pin_caps(struct snd_info_buffer *buffer, |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 169 | struct hda_codec *codec, hda_nid_t nid, |
| 170 | int *supports_vref) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | { |
Takashi Iwai | b0c95f5 | 2005-04-20 13:44:08 +0200 | [diff] [blame] | 172 | static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" }; |
Takashi Iwai | e97a516 | 2007-10-26 14:56:36 +0200 | [diff] [blame] | 173 | unsigned int caps, val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
| 175 | caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); |
Robin H. Johnson | 0481f45 | 2008-09-13 16:54:57 -0700 | [diff] [blame] | 176 | snd_iprintf(buffer, " Pincap 0x%08x:", caps); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | if (caps & AC_PINCAP_IN) |
| 178 | snd_iprintf(buffer, " IN"); |
| 179 | if (caps & AC_PINCAP_OUT) |
| 180 | snd_iprintf(buffer, " OUT"); |
| 181 | if (caps & AC_PINCAP_HP_DRV) |
| 182 | snd_iprintf(buffer, " HP"); |
Takashi Iwai | 5885492 | 2006-06-21 19:19:25 +0200 | [diff] [blame] | 183 | if (caps & AC_PINCAP_EAPD) |
| 184 | snd_iprintf(buffer, " EAPD"); |
| 185 | if (caps & AC_PINCAP_PRES_DETECT) |
| 186 | snd_iprintf(buffer, " Detect"); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 187 | if (caps & AC_PINCAP_BALANCE) |
| 188 | snd_iprintf(buffer, " Balanced"); |
Takashi Iwai | c492060 | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 189 | if (caps & AC_PINCAP_HDMI) { |
| 190 | /* Realtek uses this bit as a different meaning */ |
| 191 | if ((codec->vendor_id >> 16) == 0x10ec) |
| 192 | snd_iprintf(buffer, " R/L"); |
| 193 | else |
| 194 | snd_iprintf(buffer, " HDMI"); |
| 195 | } |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 196 | if (caps & AC_PINCAP_TRIG_REQ) |
| 197 | snd_iprintf(buffer, " Trigger"); |
| 198 | if (caps & AC_PINCAP_IMP_SENSE) |
| 199 | snd_iprintf(buffer, " ImpSense"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | snd_iprintf(buffer, "\n"); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 201 | if (caps & AC_PINCAP_VREF) { |
| 202 | unsigned int vref = |
| 203 | (caps & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 204 | snd_iprintf(buffer, " Vref caps:"); |
| 205 | if (vref & AC_PINCAP_VREF_HIZ) |
| 206 | snd_iprintf(buffer, " HIZ"); |
| 207 | if (vref & AC_PINCAP_VREF_50) |
| 208 | snd_iprintf(buffer, " 50"); |
| 209 | if (vref & AC_PINCAP_VREF_GRD) |
| 210 | snd_iprintf(buffer, " GRD"); |
| 211 | if (vref & AC_PINCAP_VREF_80) |
| 212 | snd_iprintf(buffer, " 80"); |
| 213 | if (vref & AC_PINCAP_VREF_100) |
| 214 | snd_iprintf(buffer, " 100"); |
| 215 | snd_iprintf(buffer, "\n"); |
| 216 | *supports_vref = 1; |
| 217 | } else |
| 218 | *supports_vref = 0; |
| 219 | if (caps & AC_PINCAP_EAPD) { |
| 220 | val = snd_hda_codec_read(codec, nid, 0, |
| 221 | AC_VERB_GET_EAPD_BTLENABLE, 0); |
| 222 | snd_iprintf(buffer, " EAPD 0x%x:", val); |
| 223 | if (val & AC_EAPDBTL_BALANCED) |
| 224 | snd_iprintf(buffer, " BALANCED"); |
| 225 | if (val & AC_EAPDBTL_EAPD) |
| 226 | snd_iprintf(buffer, " EAPD"); |
| 227 | if (val & AC_EAPDBTL_LR_SWAP) |
| 228 | snd_iprintf(buffer, " R/L"); |
| 229 | snd_iprintf(buffer, "\n"); |
| 230 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | 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] | 232 | snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps, |
| 233 | jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT], |
Matthew Ranostay | 50a9f79 | 2008-10-25 01:05:45 -0400 | [diff] [blame] | 234 | snd_hda_get_jack_type(caps), |
| 235 | snd_hda_get_jack_connectivity(caps), |
| 236 | snd_hda_get_jack_location(caps)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | snd_iprintf(buffer, " Conn = %s, Color = %s\n", |
| 238 | get_jack_connection(caps), |
| 239 | get_jack_color(caps)); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 240 | /* Default association and sequence values refer to default grouping |
| 241 | * of pin complexes and their sequence within the group. This is used |
| 242 | * for priority and resource allocation. |
| 243 | */ |
| 244 | snd_iprintf(buffer, " DefAssociation = 0x%x, Sequence = 0x%x\n", |
| 245 | (caps & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT, |
| 246 | caps & AC_DEFCFG_SEQUENCE); |
| 247 | if (((caps & AC_DEFCFG_MISC) >> AC_DEFCFG_MISC_SHIFT) & |
| 248 | AC_DEFCFG_MISC_NO_PRESENCE) { |
| 249 | /* Miscellaneous bit indicates external hardware does not |
| 250 | * support presence detection even if the pin complex |
| 251 | * indicates it is supported. |
| 252 | */ |
| 253 | snd_iprintf(buffer, " Misc = NO_PRESENCE\n"); |
Takashi Iwai | e97a516 | 2007-10-26 14:56:36 +0200 | [diff] [blame] | 254 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | } |
| 256 | |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 257 | static void print_pin_ctls(struct snd_info_buffer *buffer, |
| 258 | struct hda_codec *codec, hda_nid_t nid, |
| 259 | int supports_vref) |
| 260 | { |
| 261 | unsigned int pinctls; |
| 262 | |
| 263 | pinctls = snd_hda_codec_read(codec, nid, 0, |
| 264 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 265 | snd_iprintf(buffer, " Pin-ctls: 0x%02x:", pinctls); |
| 266 | if (pinctls & AC_PINCTL_IN_EN) |
| 267 | snd_iprintf(buffer, " IN"); |
| 268 | if (pinctls & AC_PINCTL_OUT_EN) |
| 269 | snd_iprintf(buffer, " OUT"); |
| 270 | if (pinctls & AC_PINCTL_HP_EN) |
| 271 | snd_iprintf(buffer, " HP"); |
| 272 | if (supports_vref) { |
| 273 | int vref = pinctls & AC_PINCTL_VREFEN; |
| 274 | switch (vref) { |
| 275 | case AC_PINCTL_VREF_HIZ: |
| 276 | snd_iprintf(buffer, " VREF_HIZ"); |
| 277 | break; |
| 278 | case AC_PINCTL_VREF_50: |
| 279 | snd_iprintf(buffer, " VREF_50"); |
| 280 | break; |
| 281 | case AC_PINCTL_VREF_GRD: |
| 282 | snd_iprintf(buffer, " VREF_GRD"); |
| 283 | break; |
| 284 | case AC_PINCTL_VREF_80: |
| 285 | snd_iprintf(buffer, " VREF_80"); |
| 286 | break; |
| 287 | case AC_PINCTL_VREF_100: |
| 288 | snd_iprintf(buffer, " VREF_100"); |
| 289 | break; |
| 290 | } |
| 291 | } |
| 292 | snd_iprintf(buffer, "\n"); |
| 293 | } |
| 294 | |
| 295 | static void print_vol_knob(struct snd_info_buffer *buffer, |
| 296 | struct hda_codec *codec, hda_nid_t nid) |
| 297 | { |
| 298 | unsigned int cap = snd_hda_param_read(codec, nid, |
| 299 | AC_PAR_VOL_KNB_CAP); |
| 300 | snd_iprintf(buffer, " Volume-Knob: delta=%d, steps=%d, ", |
| 301 | (cap >> 7) & 1, cap & 0x7f); |
| 302 | cap = snd_hda_codec_read(codec, nid, 0, |
| 303 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
| 304 | snd_iprintf(buffer, "direct=%d, val=%d\n", |
| 305 | (cap >> 7) & 1, cap & 0x7f); |
| 306 | } |
| 307 | |
| 308 | static void print_audio_io(struct snd_info_buffer *buffer, |
| 309 | struct hda_codec *codec, hda_nid_t nid, |
| 310 | unsigned int wid_type) |
| 311 | { |
| 312 | int conv = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0); |
| 313 | snd_iprintf(buffer, |
| 314 | " Converter: stream=%d, channel=%d\n", |
| 315 | (conv & AC_CONV_STREAM) >> AC_CONV_STREAM_SHIFT, |
| 316 | conv & AC_CONV_CHANNEL); |
| 317 | |
| 318 | if (wid_type == AC_WID_AUD_IN && (conv & AC_CONV_CHANNEL) == 0) { |
| 319 | int sdi = snd_hda_codec_read(codec, nid, 0, |
| 320 | AC_VERB_GET_SDI_SELECT, 0); |
| 321 | snd_iprintf(buffer, " SDI-Select: %d\n", |
| 322 | sdi & AC_SDI_SELECT); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | static void print_digital_conv(struct snd_info_buffer *buffer, |
| 327 | struct hda_codec *codec, hda_nid_t nid) |
| 328 | { |
| 329 | unsigned int digi1 = snd_hda_codec_read(codec, nid, 0, |
| 330 | AC_VERB_GET_DIGI_CONVERT_1, 0); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 331 | snd_iprintf(buffer, " Digital:"); |
| 332 | if (digi1 & AC_DIG1_ENABLE) |
| 333 | snd_iprintf(buffer, " Enabled"); |
| 334 | if (digi1 & AC_DIG1_V) |
| 335 | snd_iprintf(buffer, " Validity"); |
| 336 | if (digi1 & AC_DIG1_VCFG) |
| 337 | snd_iprintf(buffer, " ValidityCfg"); |
| 338 | if (digi1 & AC_DIG1_EMPHASIS) |
| 339 | snd_iprintf(buffer, " Preemphasis"); |
| 340 | if (digi1 & AC_DIG1_COPYRIGHT) |
| 341 | snd_iprintf(buffer, " Copyright"); |
| 342 | if (digi1 & AC_DIG1_NONAUDIO) |
| 343 | snd_iprintf(buffer, " Non-Audio"); |
| 344 | if (digi1 & AC_DIG1_PROFESSIONAL) |
| 345 | snd_iprintf(buffer, " Pro"); |
| 346 | if (digi1 & AC_DIG1_LEVEL) |
| 347 | snd_iprintf(buffer, " GenLevel"); |
| 348 | snd_iprintf(buffer, "\n"); |
Takashi Iwai | a1855d8 | 2008-06-19 15:41:37 +0200 | [diff] [blame] | 349 | snd_iprintf(buffer, " Digital category: 0x%x\n", |
| 350 | (digi1 >> 8) & AC_DIG2_CC); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | static const char *get_pwr_state(u32 state) |
| 354 | { |
| 355 | static const char *buf[4] = { |
| 356 | "D0", "D1", "D2", "D3" |
| 357 | }; |
| 358 | if (state < 4) |
| 359 | return buf[state]; |
| 360 | return "UNKNOWN"; |
| 361 | } |
| 362 | |
| 363 | static void print_power_state(struct snd_info_buffer *buffer, |
| 364 | struct hda_codec *codec, hda_nid_t nid) |
| 365 | { |
| 366 | int pwr = snd_hda_codec_read(codec, nid, 0, |
| 367 | AC_VERB_GET_POWER_STATE, 0); |
| 368 | snd_iprintf(buffer, " Power: setting=%s, actual=%s\n", |
| 369 | get_pwr_state(pwr & AC_PWRST_SETTING), |
| 370 | get_pwr_state((pwr & AC_PWRST_ACTUAL) >> |
| 371 | AC_PWRST_ACTUAL_SHIFT)); |
| 372 | } |
| 373 | |
| 374 | static void print_unsol_cap(struct snd_info_buffer *buffer, |
| 375 | struct hda_codec *codec, hda_nid_t nid) |
| 376 | { |
| 377 | int unsol = snd_hda_codec_read(codec, nid, 0, |
| 378 | AC_VERB_GET_UNSOLICITED_RESPONSE, 0); |
| 379 | snd_iprintf(buffer, |
| 380 | " Unsolicited: tag=%02x, enabled=%d\n", |
| 381 | unsol & AC_UNSOL_TAG, |
| 382 | (unsol & AC_UNSOL_ENABLED) ? 1 : 0); |
| 383 | } |
| 384 | |
| 385 | static void print_proc_caps(struct snd_info_buffer *buffer, |
| 386 | struct hda_codec *codec, hda_nid_t nid) |
| 387 | { |
| 388 | unsigned int proc_caps = snd_hda_param_read(codec, nid, |
| 389 | AC_PAR_PROC_CAP); |
| 390 | snd_iprintf(buffer, " Processing caps: benign=%d, ncoeff=%d\n", |
| 391 | proc_caps & AC_PCAP_BENIGN, |
| 392 | (proc_caps & AC_PCAP_NUM_COEF) >> AC_PCAP_NUM_COEF_SHIFT); |
| 393 | } |
| 394 | |
| 395 | static void print_conn_list(struct snd_info_buffer *buffer, |
| 396 | struct hda_codec *codec, hda_nid_t nid, |
| 397 | unsigned int wid_type, hda_nid_t *conn, |
| 398 | int conn_len) |
| 399 | { |
| 400 | int c, curr = -1; |
| 401 | |
Takashi Iwai | 516a1ce | 2009-02-02 11:37:03 +0100 | [diff] [blame] | 402 | if (conn_len > 1 && wid_type != AC_WID_AUD_MIX && |
| 403 | wid_type != AC_WID_VOL_KNB) |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 404 | curr = snd_hda_codec_read(codec, nid, 0, |
| 405 | AC_VERB_GET_CONNECT_SEL, 0); |
| 406 | snd_iprintf(buffer, " Connection: %d\n", conn_len); |
| 407 | if (conn_len > 0) { |
| 408 | snd_iprintf(buffer, " "); |
| 409 | for (c = 0; c < conn_len; c++) { |
| 410 | snd_iprintf(buffer, " 0x%02x", conn[c]); |
| 411 | if (c == curr) |
| 412 | snd_iprintf(buffer, "*"); |
| 413 | } |
| 414 | snd_iprintf(buffer, "\n"); |
| 415 | } |
| 416 | } |
| 417 | |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 418 | static void print_gpio(struct snd_info_buffer *buffer, |
| 419 | struct hda_codec *codec, hda_nid_t nid) |
| 420 | { |
| 421 | unsigned int gpio = |
| 422 | snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP); |
| 423 | unsigned int enable, direction, wake, unsol, sticky, data; |
| 424 | int i, max; |
| 425 | snd_iprintf(buffer, "GPIO: io=%d, o=%d, i=%d, " |
| 426 | "unsolicited=%d, wake=%d\n", |
| 427 | gpio & AC_GPIO_IO_COUNT, |
| 428 | (gpio & AC_GPIO_O_COUNT) >> AC_GPIO_O_COUNT_SHIFT, |
| 429 | (gpio & AC_GPIO_I_COUNT) >> AC_GPIO_I_COUNT_SHIFT, |
| 430 | (gpio & AC_GPIO_UNSOLICITED) ? 1 : 0, |
| 431 | (gpio & AC_GPIO_WAKE) ? 1 : 0); |
| 432 | max = gpio & AC_GPIO_IO_COUNT; |
Takashi Iwai | c4dc507 | 2008-11-04 13:30:57 +0100 | [diff] [blame] | 433 | if (!max || max > 8) |
| 434 | return; |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 435 | enable = snd_hda_codec_read(codec, nid, 0, |
| 436 | AC_VERB_GET_GPIO_MASK, 0); |
| 437 | direction = snd_hda_codec_read(codec, nid, 0, |
| 438 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 439 | wake = snd_hda_codec_read(codec, nid, 0, |
| 440 | AC_VERB_GET_GPIO_WAKE_MASK, 0); |
| 441 | unsol = snd_hda_codec_read(codec, nid, 0, |
| 442 | AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK, 0); |
| 443 | sticky = snd_hda_codec_read(codec, nid, 0, |
| 444 | AC_VERB_GET_GPIO_STICKY_MASK, 0); |
| 445 | data = snd_hda_codec_read(codec, nid, 0, |
| 446 | AC_VERB_GET_GPIO_DATA, 0); |
| 447 | for (i = 0; i < max; ++i) |
| 448 | snd_iprintf(buffer, |
| 449 | " IO[%d]: enable=%d, dir=%d, wake=%d, " |
Takashi Iwai | 8563964 | 2008-11-19 14:14:50 +0100 | [diff] [blame] | 450 | "sticky=%d, data=%d, unsol=%d\n", i, |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 451 | (enable & (1<<i)) ? 1 : 0, |
| 452 | (direction & (1<<i)) ? 1 : 0, |
| 453 | (wake & (1<<i)) ? 1 : 0, |
| 454 | (sticky & (1<<i)) ? 1 : 0, |
Takashi Iwai | 8563964 | 2008-11-19 14:14:50 +0100 | [diff] [blame] | 455 | (data & (1<<i)) ? 1 : 0, |
| 456 | (unsol & (1<<i)) ? 1 : 0); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 457 | /* FIXME: add GPO and GPI pin information */ |
| 458 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | |
Takashi Iwai | d01ce99 | 2007-07-27 16:52:19 +0200 | [diff] [blame] | 460 | static void print_codec_info(struct snd_info_entry *entry, |
| 461 | struct snd_info_buffer *buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | { |
| 463 | struct hda_codec *codec = entry->private_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | hda_nid_t nid; |
| 465 | int i, nodes; |
| 466 | |
Takashi Iwai | f44ac83 | 2008-07-30 15:01:45 +0200 | [diff] [blame] | 467 | snd_iprintf(buffer, "Codec: %s\n", |
| 468 | codec->name ? codec->name : "Not Set"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | snd_iprintf(buffer, "Address: %d\n", codec->addr); |
| 470 | snd_iprintf(buffer, "Vendor Id: 0x%x\n", codec->vendor_id); |
| 471 | snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id); |
| 472 | snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id); |
Jonathan Phenix | e25c05f | 2007-06-19 18:31:28 +0200 | [diff] [blame] | 473 | |
| 474 | if (codec->mfg) |
| 475 | snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg); |
| 476 | else |
| 477 | snd_iprintf(buffer, "No Modem Function Group found\n"); |
| 478 | |
Takashi Iwai | ec9e1c5 | 2005-09-07 13:29:22 +0200 | [diff] [blame] | 479 | if (! codec->afg) |
| 480 | return; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 481 | snd_hda_power_up(codec); |
Takashi Iwai | b90d776 | 2006-11-07 16:10:06 +0100 | [diff] [blame] | 482 | snd_iprintf(buffer, "Default PCM:\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | print_pcm_caps(buffer, codec, codec->afg); |
| 484 | snd_iprintf(buffer, "Default Amp-In caps: "); |
| 485 | print_amp_caps(buffer, codec, codec->afg, HDA_INPUT); |
| 486 | snd_iprintf(buffer, "Default Amp-Out caps: "); |
| 487 | print_amp_caps(buffer, codec, codec->afg, HDA_OUTPUT); |
| 488 | |
| 489 | nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid); |
| 490 | if (! nid || nodes < 0) { |
| 491 | snd_iprintf(buffer, "Invalid AFG subtree\n"); |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 492 | snd_hda_power_down(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | return; |
| 494 | } |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 495 | |
| 496 | print_gpio(buffer, codec, codec->afg); |
Takashi Iwai | 2d34e1b | 2008-11-28 14:35:16 +0100 | [diff] [blame] | 497 | if (codec->proc_widget_hook) |
| 498 | codec->proc_widget_hook(buffer, codec, codec->afg); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 499 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | for (i = 0; i < nodes; i++, nid++) { |
Takashi Iwai | d01ce99 | 2007-07-27 16:52:19 +0200 | [diff] [blame] | 501 | unsigned int wid_caps = |
| 502 | snd_hda_param_read(codec, nid, |
| 503 | AC_PAR_AUDIO_WIDGET_CAP); |
| 504 | unsigned int wid_type = |
| 505 | (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 506 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 507 | int conn_len = 0; |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 508 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid, |
| 510 | get_wid_type_name(wid_type), wid_caps); |
Takashi Iwai | c492060 | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 511 | if (wid_caps & AC_WCAP_STEREO) { |
| 512 | unsigned int chans; |
| 513 | chans = (wid_caps & AC_WCAP_CHAN_CNT_EXT) >> 13; |
| 514 | chans = ((chans << 1) | 1) + 1; |
| 515 | if (chans == 2) |
| 516 | snd_iprintf(buffer, " Stereo"); |
| 517 | else |
| 518 | snd_iprintf(buffer, " %d-Channels", chans); |
| 519 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | snd_iprintf(buffer, " Mono"); |
| 521 | if (wid_caps & AC_WCAP_DIGITAL) |
| 522 | snd_iprintf(buffer, " Digital"); |
| 523 | if (wid_caps & AC_WCAP_IN_AMP) |
| 524 | snd_iprintf(buffer, " Amp-In"); |
| 525 | if (wid_caps & AC_WCAP_OUT_AMP) |
| 526 | snd_iprintf(buffer, " Amp-Out"); |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 527 | if (wid_caps & AC_WCAP_STRIPE) |
| 528 | snd_iprintf(buffer, " Stripe"); |
| 529 | if (wid_caps & AC_WCAP_LR_SWAP) |
| 530 | snd_iprintf(buffer, " R/L"); |
Takashi Iwai | c492060 | 2008-07-30 15:13:29 +0200 | [diff] [blame] | 531 | if (wid_caps & AC_WCAP_CP_CAPS) |
| 532 | snd_iprintf(buffer, " CP"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | snd_iprintf(buffer, "\n"); |
| 534 | |
Takashi Iwai | e171613 | 2007-11-16 17:52:39 +0100 | [diff] [blame] | 535 | /* volume knob is a special widget that always have connection |
| 536 | * list |
| 537 | */ |
| 538 | if (wid_type == AC_WID_VOL_KNB) |
| 539 | wid_caps |= AC_WCAP_CONN_LIST; |
| 540 | |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 541 | if (wid_caps & AC_WCAP_CONN_LIST) |
| 542 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 543 | HDA_MAX_CONNECTIONS); |
| 544 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | if (wid_caps & AC_WCAP_IN_AMP) { |
| 546 | snd_iprintf(buffer, " Amp-In caps: "); |
| 547 | print_amp_caps(buffer, codec, nid, HDA_INPUT); |
| 548 | snd_iprintf(buffer, " Amp-In vals: "); |
| 549 | print_amp_vals(buffer, codec, nid, HDA_INPUT, |
Takashi Iwai | 9e03ad7 | 2008-02-22 18:46:00 +0100 | [diff] [blame] | 550 | wid_caps & AC_WCAP_STEREO, |
| 551 | wid_type == AC_WID_PIN ? 1 : conn_len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | } |
| 553 | if (wid_caps & AC_WCAP_OUT_AMP) { |
| 554 | snd_iprintf(buffer, " Amp-Out caps: "); |
| 555 | print_amp_caps(buffer, codec, nid, HDA_OUTPUT); |
| 556 | snd_iprintf(buffer, " Amp-Out vals: "); |
| 557 | print_amp_vals(buffer, codec, nid, HDA_OUTPUT, |
Takashi Iwai | 3e289f1 | 2005-06-10 19:45:09 +0200 | [diff] [blame] | 558 | wid_caps & AC_WCAP_STEREO, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | } |
| 560 | |
Takashi Iwai | e97a516 | 2007-10-26 14:56:36 +0200 | [diff] [blame] | 561 | switch (wid_type) { |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 562 | case AC_WID_PIN: { |
| 563 | int supports_vref; |
| 564 | print_pin_caps(buffer, codec, nid, &supports_vref); |
| 565 | print_pin_ctls(buffer, codec, nid, supports_vref); |
Takashi Iwai | e97a516 | 2007-10-26 14:56:36 +0200 | [diff] [blame] | 566 | break; |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 567 | } |
Takashi Iwai | e97a516 | 2007-10-26 14:56:36 +0200 | [diff] [blame] | 568 | case AC_WID_VOL_KNB: |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 569 | print_vol_knob(buffer, codec, nid); |
Takashi Iwai | e97a516 | 2007-10-26 14:56:36 +0200 | [diff] [blame] | 570 | break; |
| 571 | case AC_WID_AUD_OUT: |
| 572 | case AC_WID_AUD_IN: |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 573 | print_audio_io(buffer, codec, nid, wid_type); |
| 574 | if (wid_caps & AC_WCAP_DIGITAL) |
| 575 | print_digital_conv(buffer, codec, nid); |
Takashi Iwai | e97a516 | 2007-10-26 14:56:36 +0200 | [diff] [blame] | 576 | if (wid_caps & AC_WCAP_FORMAT_OVRD) { |
| 577 | snd_iprintf(buffer, " PCM:\n"); |
| 578 | print_pcm_caps(buffer, codec, nid); |
| 579 | } |
| 580 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | } |
| 582 | |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 583 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 584 | print_unsol_cap(buffer, codec, nid); |
Takashi Iwai | b7027cc | 2005-11-02 18:13:41 +0100 | [diff] [blame] | 585 | |
Andrew Paprocki | 797760a | 2008-01-18 12:51:11 +0100 | [diff] [blame] | 586 | if (wid_caps & AC_WCAP_POWER) |
| 587 | print_power_state(buffer, codec, nid); |
| 588 | |
| 589 | if (wid_caps & AC_WCAP_DELAY) |
| 590 | snd_iprintf(buffer, " Delay: %d samples\n", |
| 591 | (wid_caps & AC_WCAP_DELAY) >> |
| 592 | AC_WCAP_DELAY_SHIFT); |
| 593 | |
| 594 | if (wid_caps & AC_WCAP_CONN_LIST) |
| 595 | print_conn_list(buffer, codec, nid, wid_type, |
| 596 | conn, conn_len); |
| 597 | |
| 598 | if (wid_caps & AC_WCAP_PROC_WID) |
| 599 | print_proc_caps(buffer, codec, nid); |
| 600 | |
Takashi Iwai | daead53 | 2008-11-28 12:55:36 +0100 | [diff] [blame] | 601 | if (codec->proc_widget_hook) |
| 602 | codec->proc_widget_hook(buffer, codec, nid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | } |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 604 | snd_hda_power_down(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | /* |
| 608 | * create a proc read |
| 609 | */ |
| 610 | int snd_hda_codec_proc_new(struct hda_codec *codec) |
| 611 | { |
| 612 | char name[32]; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 613 | struct snd_info_entry *entry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | int err; |
| 615 | |
| 616 | snprintf(name, sizeof(name), "codec#%d", codec->addr); |
| 617 | err = snd_card_proc_new(codec->bus->card, name, &entry); |
| 618 | if (err < 0) |
| 619 | return err; |
| 620 | |
Takashi Iwai | bf85020 | 2006-04-28 15:13:41 +0200 | [diff] [blame] | 621 | snd_info_set_text_ops(entry, codec, print_codec_info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | return 0; |
| 623 | } |
| 624 | |