0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/init.h>
0011 #include <linux/slab.h>
0012 #include <sound/core.h>
0013 #include <linux/module.h>
0014 #include <sound/hda_codec.h>
0015 #include "hda_local.h"
0016
0017 static int dump_coef = -1;
0018 module_param(dump_coef, int, 0644);
0019 MODULE_PARM_DESC(dump_coef, "Dump processing coefficients in codec proc file (-1=auto, 0=disable, 1=enable)");
0020
0021
0022 #define param_read(codec, nid, parm) \
0023 snd_hdac_read_parm_uncached(&(codec)->core, nid, parm)
0024
0025 static const char *get_wid_type_name(unsigned int wid_value)
0026 {
0027 static const char * const names[16] = {
0028 [AC_WID_AUD_OUT] = "Audio Output",
0029 [AC_WID_AUD_IN] = "Audio Input",
0030 [AC_WID_AUD_MIX] = "Audio Mixer",
0031 [AC_WID_AUD_SEL] = "Audio Selector",
0032 [AC_WID_PIN] = "Pin Complex",
0033 [AC_WID_POWER] = "Power Widget",
0034 [AC_WID_VOL_KNB] = "Volume Knob Widget",
0035 [AC_WID_BEEP] = "Beep Generator Widget",
0036 [AC_WID_VENDOR] = "Vendor Defined Widget",
0037 };
0038 if (wid_value == -1)
0039 return "UNKNOWN Widget";
0040 wid_value &= 0xf;
0041 if (names[wid_value])
0042 return names[wid_value];
0043 else
0044 return "UNKNOWN Widget";
0045 }
0046
0047 static void print_nid_array(struct snd_info_buffer *buffer,
0048 struct hda_codec *codec, hda_nid_t nid,
0049 struct snd_array *array)
0050 {
0051 int i;
0052 struct hda_nid_item *items = array->list, *item;
0053 struct snd_kcontrol *kctl;
0054 for (i = 0; i < array->used; i++) {
0055 item = &items[i];
0056 if (item->nid == nid) {
0057 kctl = item->kctl;
0058 snd_iprintf(buffer,
0059 " Control: name=\"%s\", index=%i, device=%i\n",
0060 kctl->id.name, kctl->id.index + item->index,
0061 kctl->id.device);
0062 if (item->flags & HDA_NID_ITEM_AMP)
0063 snd_iprintf(buffer,
0064 " ControlAmp: chs=%lu, dir=%s, "
0065 "idx=%lu, ofs=%lu\n",
0066 get_amp_channels(kctl),
0067 get_amp_direction(kctl) ? "Out" : "In",
0068 get_amp_index(kctl),
0069 get_amp_offset(kctl));
0070 }
0071 }
0072 }
0073
0074 static void print_nid_pcms(struct snd_info_buffer *buffer,
0075 struct hda_codec *codec, hda_nid_t nid)
0076 {
0077 int type;
0078 struct hda_pcm *cpcm;
0079
0080 list_for_each_entry(cpcm, &codec->pcm_list_head, list) {
0081 for (type = 0; type < 2; type++) {
0082 if (cpcm->stream[type].nid != nid || cpcm->pcm == NULL)
0083 continue;
0084 snd_iprintf(buffer, " Device: name=\"%s\", "
0085 "type=\"%s\", device=%i\n",
0086 cpcm->name,
0087 snd_hda_pcm_type_name[cpcm->pcm_type],
0088 cpcm->pcm->device);
0089 }
0090 }
0091 }
0092
0093 static void print_amp_caps(struct snd_info_buffer *buffer,
0094 struct hda_codec *codec, hda_nid_t nid, int dir)
0095 {
0096 unsigned int caps;
0097 caps = param_read(codec, nid, dir == HDA_OUTPUT ?
0098 AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP);
0099 if (caps == -1 || caps == 0) {
0100 snd_iprintf(buffer, "N/A\n");
0101 return;
0102 }
0103 snd_iprintf(buffer, "ofs=0x%02x, nsteps=0x%02x, stepsize=0x%02x, "
0104 "mute=%x\n",
0105 caps & AC_AMPCAP_OFFSET,
0106 (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT,
0107 (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT,
0108 (caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT);
0109 }
0110
0111
0112 static bool is_stereo_amps(struct hda_codec *codec, hda_nid_t nid,
0113 int dir, unsigned int wcaps, int indices)
0114 {
0115 hda_nid_t conn;
0116
0117 if (wcaps & AC_WCAP_STEREO)
0118 return true;
0119
0120
0121
0122 if (indices != 1 || dir != HDA_INPUT ||
0123 get_wcaps_type(wcaps) != AC_WID_AUD_MIX)
0124 return false;
0125
0126 if (snd_hda_get_raw_connections(codec, nid, &conn, 1) < 0)
0127 return false;
0128
0129 wcaps = snd_hda_param_read(codec, conn, AC_PAR_AUDIO_WIDGET_CAP);
0130 return !!(wcaps & AC_WCAP_STEREO);
0131 }
0132
0133 static void print_amp_vals(struct snd_info_buffer *buffer,
0134 struct hda_codec *codec, hda_nid_t nid,
0135 int dir, unsigned int wcaps, int indices)
0136 {
0137 unsigned int val;
0138 bool stereo;
0139 int i;
0140
0141 stereo = is_stereo_amps(codec, nid, dir, wcaps, indices);
0142
0143 dir = dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
0144 for (i = 0; i < indices; i++) {
0145 snd_iprintf(buffer, " [");
0146 val = snd_hda_codec_read(codec, nid, 0,
0147 AC_VERB_GET_AMP_GAIN_MUTE,
0148 AC_AMP_GET_LEFT | dir | i);
0149 snd_iprintf(buffer, "0x%02x", val);
0150 if (stereo) {
0151 val = snd_hda_codec_read(codec, nid, 0,
0152 AC_VERB_GET_AMP_GAIN_MUTE,
0153 AC_AMP_GET_RIGHT | dir | i);
0154 snd_iprintf(buffer, " 0x%02x", val);
0155 }
0156 snd_iprintf(buffer, "]");
0157 }
0158 snd_iprintf(buffer, "\n");
0159 }
0160
0161 static void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
0162 {
0163 static const unsigned int rates[] = {
0164 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
0165 96000, 176400, 192000, 384000
0166 };
0167 int i;
0168
0169 pcm &= AC_SUPPCM_RATES;
0170 snd_iprintf(buffer, " rates [0x%x]:", pcm);
0171 for (i = 0; i < ARRAY_SIZE(rates); i++)
0172 if (pcm & (1 << i))
0173 snd_iprintf(buffer, " %d", rates[i]);
0174 snd_iprintf(buffer, "\n");
0175 }
0176
0177 static void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)
0178 {
0179 char buf[SND_PRINT_BITS_ADVISED_BUFSIZE];
0180
0181 snd_iprintf(buffer, " bits [0x%x]:", (pcm >> 16) & 0xff);
0182 snd_print_pcm_bits(pcm, buf, sizeof(buf));
0183 snd_iprintf(buffer, "%s\n", buf);
0184 }
0185
0186 static void print_pcm_formats(struct snd_info_buffer *buffer,
0187 unsigned int streams)
0188 {
0189 snd_iprintf(buffer, " formats [0x%x]:", streams & 0xf);
0190 if (streams & AC_SUPFMT_PCM)
0191 snd_iprintf(buffer, " PCM");
0192 if (streams & AC_SUPFMT_FLOAT32)
0193 snd_iprintf(buffer, " FLOAT");
0194 if (streams & AC_SUPFMT_AC3)
0195 snd_iprintf(buffer, " AC3");
0196 snd_iprintf(buffer, "\n");
0197 }
0198
0199 static void print_pcm_caps(struct snd_info_buffer *buffer,
0200 struct hda_codec *codec, hda_nid_t nid)
0201 {
0202 unsigned int pcm = param_read(codec, nid, AC_PAR_PCM);
0203 unsigned int stream = param_read(codec, nid, AC_PAR_STREAM);
0204 if (pcm == -1 || stream == -1) {
0205 snd_iprintf(buffer, "N/A\n");
0206 return;
0207 }
0208 print_pcm_rates(buffer, pcm);
0209 print_pcm_bits(buffer, pcm);
0210 print_pcm_formats(buffer, stream);
0211 }
0212
0213 static const char *get_jack_connection(u32 cfg)
0214 {
0215 static const char * const names[16] = {
0216 "Unknown", "1/8", "1/4", "ATAPI",
0217 "RCA", "Optical","Digital", "Analog",
0218 "DIN", "XLR", "RJ11", "Comb",
0219 NULL, NULL, NULL, "Other"
0220 };
0221 cfg = (cfg & AC_DEFCFG_CONN_TYPE) >> AC_DEFCFG_CONN_TYPE_SHIFT;
0222 if (names[cfg])
0223 return names[cfg];
0224 else
0225 return "UNKNOWN";
0226 }
0227
0228 static const char *get_jack_color(u32 cfg)
0229 {
0230 static const char * const names[16] = {
0231 "Unknown", "Black", "Grey", "Blue",
0232 "Green", "Red", "Orange", "Yellow",
0233 "Purple", "Pink", NULL, NULL,
0234 NULL, NULL, "White", "Other",
0235 };
0236 cfg = (cfg & AC_DEFCFG_COLOR) >> AC_DEFCFG_COLOR_SHIFT;
0237 if (names[cfg])
0238 return names[cfg];
0239 else
0240 return "UNKNOWN";
0241 }
0242
0243
0244
0245
0246
0247 static const char *get_jack_location(u32 cfg)
0248 {
0249 static const char * const bases[7] = {
0250 "N/A", "Rear", "Front", "Left", "Right", "Top", "Bottom",
0251 };
0252 static const unsigned char specials_idx[] = {
0253 0x07, 0x08,
0254 0x17, 0x18, 0x19,
0255 0x37, 0x38
0256 };
0257 static const char * const specials[] = {
0258 "Rear Panel", "Drive Bar",
0259 "Riser", "HDMI", "ATAPI",
0260 "Mobile-In", "Mobile-Out"
0261 };
0262 int i;
0263
0264 cfg = (cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT;
0265 if ((cfg & 0x0f) < 7)
0266 return bases[cfg & 0x0f];
0267 for (i = 0; i < ARRAY_SIZE(specials_idx); i++) {
0268 if (cfg == specials_idx[i])
0269 return specials[i];
0270 }
0271 return "UNKNOWN";
0272 }
0273
0274
0275
0276
0277
0278 static const char *get_jack_connectivity(u32 cfg)
0279 {
0280 static const char * const jack_locations[4] = {
0281 "Ext", "Int", "Sep", "Oth"
0282 };
0283
0284 return jack_locations[(cfg >> (AC_DEFCFG_LOCATION_SHIFT + 4)) & 3];
0285 }
0286
0287
0288
0289
0290
0291 static const char *get_jack_type(u32 cfg)
0292 {
0293 static const char * const jack_types[16] = {
0294 "Line Out", "Speaker", "HP Out", "CD",
0295 "SPDIF Out", "Digital Out", "Modem Line", "Modem Hand",
0296 "Line In", "Aux", "Mic", "Telephony",
0297 "SPDIF In", "Digital In", "Reserved", "Other"
0298 };
0299
0300 return jack_types[(cfg & AC_DEFCFG_DEVICE)
0301 >> AC_DEFCFG_DEVICE_SHIFT];
0302 }
0303
0304 static void print_pin_caps(struct snd_info_buffer *buffer,
0305 struct hda_codec *codec, hda_nid_t nid,
0306 int *supports_vref)
0307 {
0308 static const char * const jack_conns[4] = {
0309 "Jack", "N/A", "Fixed", "Both"
0310 };
0311 unsigned int caps, val;
0312
0313 caps = param_read(codec, nid, AC_PAR_PIN_CAP);
0314 snd_iprintf(buffer, " Pincap 0x%08x:", caps);
0315 if (caps & AC_PINCAP_IN)
0316 snd_iprintf(buffer, " IN");
0317 if (caps & AC_PINCAP_OUT)
0318 snd_iprintf(buffer, " OUT");
0319 if (caps & AC_PINCAP_HP_DRV)
0320 snd_iprintf(buffer, " HP");
0321 if (caps & AC_PINCAP_EAPD)
0322 snd_iprintf(buffer, " EAPD");
0323 if (caps & AC_PINCAP_PRES_DETECT)
0324 snd_iprintf(buffer, " Detect");
0325 if (caps & AC_PINCAP_BALANCE)
0326 snd_iprintf(buffer, " Balanced");
0327 if (caps & AC_PINCAP_HDMI) {
0328
0329 if ((codec->core.vendor_id >> 16) == 0x10ec)
0330 snd_iprintf(buffer, " R/L");
0331 else {
0332 if (caps & AC_PINCAP_HBR)
0333 snd_iprintf(buffer, " HBR");
0334 snd_iprintf(buffer, " HDMI");
0335 }
0336 }
0337 if (caps & AC_PINCAP_DP)
0338 snd_iprintf(buffer, " DP");
0339 if (caps & AC_PINCAP_TRIG_REQ)
0340 snd_iprintf(buffer, " Trigger");
0341 if (caps & AC_PINCAP_IMP_SENSE)
0342 snd_iprintf(buffer, " ImpSense");
0343 snd_iprintf(buffer, "\n");
0344 if (caps & AC_PINCAP_VREF) {
0345 unsigned int vref =
0346 (caps & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
0347 snd_iprintf(buffer, " Vref caps:");
0348 if (vref & AC_PINCAP_VREF_HIZ)
0349 snd_iprintf(buffer, " HIZ");
0350 if (vref & AC_PINCAP_VREF_50)
0351 snd_iprintf(buffer, " 50");
0352 if (vref & AC_PINCAP_VREF_GRD)
0353 snd_iprintf(buffer, " GRD");
0354 if (vref & AC_PINCAP_VREF_80)
0355 snd_iprintf(buffer, " 80");
0356 if (vref & AC_PINCAP_VREF_100)
0357 snd_iprintf(buffer, " 100");
0358 snd_iprintf(buffer, "\n");
0359 *supports_vref = 1;
0360 } else
0361 *supports_vref = 0;
0362 if (caps & AC_PINCAP_EAPD) {
0363 val = snd_hda_codec_read(codec, nid, 0,
0364 AC_VERB_GET_EAPD_BTLENABLE, 0);
0365 snd_iprintf(buffer, " EAPD 0x%x:", val);
0366 if (val & AC_EAPDBTL_BALANCED)
0367 snd_iprintf(buffer, " BALANCED");
0368 if (val & AC_EAPDBTL_EAPD)
0369 snd_iprintf(buffer, " EAPD");
0370 if (val & AC_EAPDBTL_LR_SWAP)
0371 snd_iprintf(buffer, " R/L");
0372 snd_iprintf(buffer, "\n");
0373 }
0374 caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
0375 snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps,
0376 jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT],
0377 get_jack_type(caps),
0378 get_jack_connectivity(caps),
0379 get_jack_location(caps));
0380 snd_iprintf(buffer, " Conn = %s, Color = %s\n",
0381 get_jack_connection(caps),
0382 get_jack_color(caps));
0383
0384
0385
0386
0387 snd_iprintf(buffer, " DefAssociation = 0x%x, Sequence = 0x%x\n",
0388 (caps & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT,
0389 caps & AC_DEFCFG_SEQUENCE);
0390 if (((caps & AC_DEFCFG_MISC) >> AC_DEFCFG_MISC_SHIFT) &
0391 AC_DEFCFG_MISC_NO_PRESENCE) {
0392
0393
0394
0395
0396 snd_iprintf(buffer, " Misc = NO_PRESENCE\n");
0397 }
0398 }
0399
0400 static void print_pin_ctls(struct snd_info_buffer *buffer,
0401 struct hda_codec *codec, hda_nid_t nid,
0402 int supports_vref)
0403 {
0404 unsigned int pinctls;
0405
0406 pinctls = snd_hda_codec_read(codec, nid, 0,
0407 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
0408 snd_iprintf(buffer, " Pin-ctls: 0x%02x:", pinctls);
0409 if (pinctls & AC_PINCTL_IN_EN)
0410 snd_iprintf(buffer, " IN");
0411 if (pinctls & AC_PINCTL_OUT_EN)
0412 snd_iprintf(buffer, " OUT");
0413 if (pinctls & AC_PINCTL_HP_EN)
0414 snd_iprintf(buffer, " HP");
0415 if (supports_vref) {
0416 int vref = pinctls & AC_PINCTL_VREFEN;
0417 switch (vref) {
0418 case AC_PINCTL_VREF_HIZ:
0419 snd_iprintf(buffer, " VREF_HIZ");
0420 break;
0421 case AC_PINCTL_VREF_50:
0422 snd_iprintf(buffer, " VREF_50");
0423 break;
0424 case AC_PINCTL_VREF_GRD:
0425 snd_iprintf(buffer, " VREF_GRD");
0426 break;
0427 case AC_PINCTL_VREF_80:
0428 snd_iprintf(buffer, " VREF_80");
0429 break;
0430 case AC_PINCTL_VREF_100:
0431 snd_iprintf(buffer, " VREF_100");
0432 break;
0433 }
0434 }
0435 snd_iprintf(buffer, "\n");
0436 }
0437
0438 static void print_vol_knob(struct snd_info_buffer *buffer,
0439 struct hda_codec *codec, hda_nid_t nid)
0440 {
0441 unsigned int cap = param_read(codec, nid, AC_PAR_VOL_KNB_CAP);
0442 snd_iprintf(buffer, " Volume-Knob: delta=%d, steps=%d, ",
0443 (cap >> 7) & 1, cap & 0x7f);
0444 cap = snd_hda_codec_read(codec, nid, 0,
0445 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
0446 snd_iprintf(buffer, "direct=%d, val=%d\n",
0447 (cap >> 7) & 1, cap & 0x7f);
0448 }
0449
0450 static void print_audio_io(struct snd_info_buffer *buffer,
0451 struct hda_codec *codec, hda_nid_t nid,
0452 unsigned int wid_type)
0453 {
0454 int conv = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
0455 snd_iprintf(buffer,
0456 " Converter: stream=%d, channel=%d\n",
0457 (conv & AC_CONV_STREAM) >> AC_CONV_STREAM_SHIFT,
0458 conv & AC_CONV_CHANNEL);
0459
0460 if (wid_type == AC_WID_AUD_IN && (conv & AC_CONV_CHANNEL) == 0) {
0461 int sdi = snd_hda_codec_read(codec, nid, 0,
0462 AC_VERB_GET_SDI_SELECT, 0);
0463 snd_iprintf(buffer, " SDI-Select: %d\n",
0464 sdi & AC_SDI_SELECT);
0465 }
0466 }
0467
0468 static void print_digital_conv(struct snd_info_buffer *buffer,
0469 struct hda_codec *codec, hda_nid_t nid)
0470 {
0471 unsigned int digi1 = snd_hda_codec_read(codec, nid, 0,
0472 AC_VERB_GET_DIGI_CONVERT_1, 0);
0473 unsigned char digi2 = digi1 >> 8;
0474 unsigned char digi3 = digi1 >> 16;
0475
0476 snd_iprintf(buffer, " Digital:");
0477 if (digi1 & AC_DIG1_ENABLE)
0478 snd_iprintf(buffer, " Enabled");
0479 if (digi1 & AC_DIG1_V)
0480 snd_iprintf(buffer, " Validity");
0481 if (digi1 & AC_DIG1_VCFG)
0482 snd_iprintf(buffer, " ValidityCfg");
0483 if (digi1 & AC_DIG1_EMPHASIS)
0484 snd_iprintf(buffer, " Preemphasis");
0485 if (digi1 & AC_DIG1_COPYRIGHT)
0486 snd_iprintf(buffer, " Non-Copyright");
0487 if (digi1 & AC_DIG1_NONAUDIO)
0488 snd_iprintf(buffer, " Non-Audio");
0489 if (digi1 & AC_DIG1_PROFESSIONAL)
0490 snd_iprintf(buffer, " Pro");
0491 if (digi1 & AC_DIG1_LEVEL)
0492 snd_iprintf(buffer, " GenLevel");
0493 if (digi3 & AC_DIG3_KAE)
0494 snd_iprintf(buffer, " KAE");
0495 snd_iprintf(buffer, "\n");
0496 snd_iprintf(buffer, " Digital category: 0x%x\n",
0497 digi2 & AC_DIG2_CC);
0498 snd_iprintf(buffer, " IEC Coding Type: 0x%x\n",
0499 digi3 & AC_DIG3_ICT);
0500 }
0501
0502 static const char *get_pwr_state(u32 state)
0503 {
0504 static const char * const buf[] = {
0505 "D0", "D1", "D2", "D3", "D3cold"
0506 };
0507 if (state < ARRAY_SIZE(buf))
0508 return buf[state];
0509 return "UNKNOWN";
0510 }
0511
0512 static void print_power_state(struct snd_info_buffer *buffer,
0513 struct hda_codec *codec, hda_nid_t nid)
0514 {
0515 static const char * const names[] = {
0516 [ilog2(AC_PWRST_D0SUP)] = "D0",
0517 [ilog2(AC_PWRST_D1SUP)] = "D1",
0518 [ilog2(AC_PWRST_D2SUP)] = "D2",
0519 [ilog2(AC_PWRST_D3SUP)] = "D3",
0520 [ilog2(AC_PWRST_D3COLDSUP)] = "D3cold",
0521 [ilog2(AC_PWRST_S3D3COLDSUP)] = "S3D3cold",
0522 [ilog2(AC_PWRST_CLKSTOP)] = "CLKSTOP",
0523 [ilog2(AC_PWRST_EPSS)] = "EPSS",
0524 };
0525
0526 int sup = param_read(codec, nid, AC_PAR_POWER_STATE);
0527 int pwr = snd_hda_codec_read(codec, nid, 0,
0528 AC_VERB_GET_POWER_STATE, 0);
0529 if (sup != -1) {
0530 int i;
0531
0532 snd_iprintf(buffer, " Power states: ");
0533 for (i = 0; i < ARRAY_SIZE(names); i++) {
0534 if (sup & (1U << i))
0535 snd_iprintf(buffer, " %s", names[i]);
0536 }
0537 snd_iprintf(buffer, "\n");
0538 }
0539
0540 snd_iprintf(buffer, " Power: setting=%s, actual=%s",
0541 get_pwr_state(pwr & AC_PWRST_SETTING),
0542 get_pwr_state((pwr & AC_PWRST_ACTUAL) >>
0543 AC_PWRST_ACTUAL_SHIFT));
0544 if (pwr & AC_PWRST_ERROR)
0545 snd_iprintf(buffer, ", Error");
0546 if (pwr & AC_PWRST_CLK_STOP_OK)
0547 snd_iprintf(buffer, ", Clock-stop-OK");
0548 if (pwr & AC_PWRST_SETTING_RESET)
0549 snd_iprintf(buffer, ", Setting-reset");
0550 snd_iprintf(buffer, "\n");
0551 }
0552
0553 static void print_unsol_cap(struct snd_info_buffer *buffer,
0554 struct hda_codec *codec, hda_nid_t nid)
0555 {
0556 int unsol = snd_hda_codec_read(codec, nid, 0,
0557 AC_VERB_GET_UNSOLICITED_RESPONSE, 0);
0558 snd_iprintf(buffer,
0559 " Unsolicited: tag=%02x, enabled=%d\n",
0560 unsol & AC_UNSOL_TAG,
0561 (unsol & AC_UNSOL_ENABLED) ? 1 : 0);
0562 }
0563
0564 static inline bool can_dump_coef(struct hda_codec *codec)
0565 {
0566 switch (dump_coef) {
0567 case 0: return false;
0568 case 1: return true;
0569 default: return codec->dump_coef;
0570 }
0571 }
0572
0573 static void print_proc_caps(struct snd_info_buffer *buffer,
0574 struct hda_codec *codec, hda_nid_t nid)
0575 {
0576 unsigned int i, ncoeff, oldindex;
0577 unsigned int proc_caps = param_read(codec, nid, AC_PAR_PROC_CAP);
0578 ncoeff = (proc_caps & AC_PCAP_NUM_COEF) >> AC_PCAP_NUM_COEF_SHIFT;
0579 snd_iprintf(buffer, " Processing caps: benign=%d, ncoeff=%d\n",
0580 proc_caps & AC_PCAP_BENIGN, ncoeff);
0581
0582 if (!can_dump_coef(codec))
0583 return;
0584
0585
0586
0587 oldindex = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_COEF_INDEX, 0);
0588 for (i = 0; i < ncoeff; i++) {
0589 unsigned int val;
0590 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, i);
0591 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF,
0592 0);
0593 snd_iprintf(buffer, " Coeff 0x%02x: 0x%04x\n", i, val);
0594 }
0595 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, oldindex);
0596 }
0597
0598 static void print_conn_list(struct snd_info_buffer *buffer,
0599 struct hda_codec *codec, hda_nid_t nid,
0600 unsigned int wid_type, hda_nid_t *conn,
0601 int conn_len)
0602 {
0603 int c, curr = -1;
0604 const hda_nid_t *list;
0605 int cache_len;
0606
0607 if (conn_len > 1 &&
0608 wid_type != AC_WID_AUD_MIX &&
0609 wid_type != AC_WID_VOL_KNB &&
0610 wid_type != AC_WID_POWER)
0611 curr = snd_hda_codec_read(codec, nid, 0,
0612 AC_VERB_GET_CONNECT_SEL, 0);
0613 snd_iprintf(buffer, " Connection: %d\n", conn_len);
0614 if (conn_len > 0) {
0615 snd_iprintf(buffer, " ");
0616 for (c = 0; c < conn_len; c++) {
0617 snd_iprintf(buffer, " 0x%02x", conn[c]);
0618 if (c == curr)
0619 snd_iprintf(buffer, "*");
0620 }
0621 snd_iprintf(buffer, "\n");
0622 }
0623
0624
0625 cache_len = snd_hda_get_conn_list(codec, nid, &list);
0626 if (cache_len >= 0 && (cache_len != conn_len ||
0627 memcmp(list, conn, conn_len) != 0)) {
0628 snd_iprintf(buffer, " In-driver Connection: %d\n", cache_len);
0629 if (cache_len > 0) {
0630 snd_iprintf(buffer, " ");
0631 for (c = 0; c < cache_len; c++)
0632 snd_iprintf(buffer, " 0x%02x", list[c]);
0633 snd_iprintf(buffer, "\n");
0634 }
0635 }
0636 }
0637
0638 static void print_gpio(struct snd_info_buffer *buffer,
0639 struct hda_codec *codec, hda_nid_t nid)
0640 {
0641 unsigned int gpio =
0642 param_read(codec, codec->core.afg, AC_PAR_GPIO_CAP);
0643 unsigned int enable, direction, wake, unsol, sticky, data;
0644 int i, max;
0645 snd_iprintf(buffer, "GPIO: io=%d, o=%d, i=%d, "
0646 "unsolicited=%d, wake=%d\n",
0647 gpio & AC_GPIO_IO_COUNT,
0648 (gpio & AC_GPIO_O_COUNT) >> AC_GPIO_O_COUNT_SHIFT,
0649 (gpio & AC_GPIO_I_COUNT) >> AC_GPIO_I_COUNT_SHIFT,
0650 (gpio & AC_GPIO_UNSOLICITED) ? 1 : 0,
0651 (gpio & AC_GPIO_WAKE) ? 1 : 0);
0652 max = gpio & AC_GPIO_IO_COUNT;
0653 if (!max || max > 8)
0654 return;
0655 enable = snd_hda_codec_read(codec, nid, 0,
0656 AC_VERB_GET_GPIO_MASK, 0);
0657 direction = snd_hda_codec_read(codec, nid, 0,
0658 AC_VERB_GET_GPIO_DIRECTION, 0);
0659 wake = snd_hda_codec_read(codec, nid, 0,
0660 AC_VERB_GET_GPIO_WAKE_MASK, 0);
0661 unsol = snd_hda_codec_read(codec, nid, 0,
0662 AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK, 0);
0663 sticky = snd_hda_codec_read(codec, nid, 0,
0664 AC_VERB_GET_GPIO_STICKY_MASK, 0);
0665 data = snd_hda_codec_read(codec, nid, 0,
0666 AC_VERB_GET_GPIO_DATA, 0);
0667 for (i = 0; i < max; ++i)
0668 snd_iprintf(buffer,
0669 " IO[%d]: enable=%d, dir=%d, wake=%d, "
0670 "sticky=%d, data=%d, unsol=%d\n", i,
0671 (enable & (1<<i)) ? 1 : 0,
0672 (direction & (1<<i)) ? 1 : 0,
0673 (wake & (1<<i)) ? 1 : 0,
0674 (sticky & (1<<i)) ? 1 : 0,
0675 (data & (1<<i)) ? 1 : 0,
0676 (unsol & (1<<i)) ? 1 : 0);
0677
0678 print_nid_array(buffer, codec, nid, &codec->mixers);
0679 print_nid_array(buffer, codec, nid, &codec->nids);
0680 }
0681
0682 static void print_dpmst_connections(struct snd_info_buffer *buffer, struct hda_codec *codec,
0683 hda_nid_t nid, int dev_num)
0684 {
0685 int c, conn_len, curr, dev_id_saved;
0686 hda_nid_t *conn;
0687
0688 conn_len = snd_hda_get_num_raw_conns(codec, nid);
0689 if (conn_len <= 0)
0690 return;
0691
0692 conn = kmalloc_array(conn_len, sizeof(hda_nid_t), GFP_KERNEL);
0693 if (!conn)
0694 return;
0695
0696 dev_id_saved = snd_hda_get_dev_select(codec, nid);
0697
0698 snd_hda_set_dev_select(codec, nid, dev_num);
0699 curr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
0700 if (snd_hda_get_raw_connections(codec, nid, conn, conn_len) < 0)
0701 goto out;
0702
0703 for (c = 0; c < conn_len; c++) {
0704 snd_iprintf(buffer, " 0x%02x", conn[c]);
0705 if (c == curr)
0706 snd_iprintf(buffer, "*");
0707 }
0708
0709 out:
0710 kfree(conn);
0711 snd_hda_set_dev_select(codec, nid, dev_id_saved);
0712 }
0713
0714 static void print_device_list(struct snd_info_buffer *buffer,
0715 struct hda_codec *codec, hda_nid_t nid)
0716 {
0717 int i, curr = -1;
0718 u8 dev_list[AC_MAX_DEV_LIST_LEN];
0719 int devlist_len;
0720
0721 devlist_len = snd_hda_get_devices(codec, nid, dev_list,
0722 AC_MAX_DEV_LIST_LEN);
0723 snd_iprintf(buffer, " Devices: %d\n", devlist_len);
0724 if (devlist_len <= 0)
0725 return;
0726
0727 curr = snd_hda_codec_read(codec, nid, 0,
0728 AC_VERB_GET_DEVICE_SEL, 0);
0729
0730 for (i = 0; i < devlist_len; i++) {
0731 if (i == curr)
0732 snd_iprintf(buffer, " *");
0733 else
0734 snd_iprintf(buffer, " ");
0735
0736 snd_iprintf(buffer,
0737 "Dev %02d: PD = %d, ELDV = %d, IA = %d, Connections [", i,
0738 !!(dev_list[i] & AC_DE_PD),
0739 !!(dev_list[i] & AC_DE_ELDV),
0740 !!(dev_list[i] & AC_DE_IA));
0741
0742 print_dpmst_connections(buffer, codec, nid, i);
0743
0744 snd_iprintf(buffer, " ]\n");
0745 }
0746 }
0747
0748 static void print_codec_core_info(struct hdac_device *codec,
0749 struct snd_info_buffer *buffer)
0750 {
0751 snd_iprintf(buffer, "Codec: ");
0752 if (codec->vendor_name && codec->chip_name)
0753 snd_iprintf(buffer, "%s %s\n",
0754 codec->vendor_name, codec->chip_name);
0755 else
0756 snd_iprintf(buffer, "Not Set\n");
0757 snd_iprintf(buffer, "Address: %d\n", codec->addr);
0758 if (codec->afg)
0759 snd_iprintf(buffer, "AFG Function Id: 0x%x (unsol %u)\n",
0760 codec->afg_function_id, codec->afg_unsol);
0761 if (codec->mfg)
0762 snd_iprintf(buffer, "MFG Function Id: 0x%x (unsol %u)\n",
0763 codec->mfg_function_id, codec->mfg_unsol);
0764 snd_iprintf(buffer, "Vendor Id: 0x%08x\n", codec->vendor_id);
0765 snd_iprintf(buffer, "Subsystem Id: 0x%08x\n", codec->subsystem_id);
0766 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
0767
0768 if (codec->mfg)
0769 snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg);
0770 else
0771 snd_iprintf(buffer, "No Modem Function Group found\n");
0772 }
0773
0774 static void print_codec_info(struct snd_info_entry *entry,
0775 struct snd_info_buffer *buffer)
0776 {
0777 struct hda_codec *codec = entry->private_data;
0778 hda_nid_t nid, fg;
0779 int i, nodes;
0780
0781 print_codec_core_info(&codec->core, buffer);
0782 fg = codec->core.afg;
0783 if (!fg)
0784 return;
0785 snd_hda_power_up(codec);
0786 snd_iprintf(buffer, "Default PCM:\n");
0787 print_pcm_caps(buffer, codec, fg);
0788 snd_iprintf(buffer, "Default Amp-In caps: ");
0789 print_amp_caps(buffer, codec, fg, HDA_INPUT);
0790 snd_iprintf(buffer, "Default Amp-Out caps: ");
0791 print_amp_caps(buffer, codec, fg, HDA_OUTPUT);
0792 snd_iprintf(buffer, "State of AFG node 0x%02x:\n", fg);
0793 print_power_state(buffer, codec, fg);
0794
0795 nodes = snd_hda_get_sub_nodes(codec, fg, &nid);
0796 if (! nid || nodes < 0) {
0797 snd_iprintf(buffer, "Invalid AFG subtree\n");
0798 snd_hda_power_down(codec);
0799 return;
0800 }
0801
0802 print_gpio(buffer, codec, fg);
0803 if (codec->proc_widget_hook)
0804 codec->proc_widget_hook(buffer, codec, fg);
0805
0806 for (i = 0; i < nodes; i++, nid++) {
0807 unsigned int wid_caps =
0808 param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP);
0809 unsigned int wid_type = get_wcaps_type(wid_caps);
0810 hda_nid_t *conn = NULL;
0811 int conn_len = 0;
0812
0813 snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid,
0814 get_wid_type_name(wid_type), wid_caps);
0815 if (wid_caps & AC_WCAP_STEREO) {
0816 unsigned int chans = get_wcaps_channels(wid_caps);
0817 if (chans == 2)
0818 snd_iprintf(buffer, " Stereo");
0819 else
0820 snd_iprintf(buffer, " %d-Channels", chans);
0821 } else
0822 snd_iprintf(buffer, " Mono");
0823 if (wid_caps & AC_WCAP_DIGITAL)
0824 snd_iprintf(buffer, " Digital");
0825 if (wid_caps & AC_WCAP_IN_AMP)
0826 snd_iprintf(buffer, " Amp-In");
0827 if (wid_caps & AC_WCAP_OUT_AMP)
0828 snd_iprintf(buffer, " Amp-Out");
0829 if (wid_caps & AC_WCAP_STRIPE)
0830 snd_iprintf(buffer, " Stripe");
0831 if (wid_caps & AC_WCAP_LR_SWAP)
0832 snd_iprintf(buffer, " R/L");
0833 if (wid_caps & AC_WCAP_CP_CAPS)
0834 snd_iprintf(buffer, " CP");
0835 snd_iprintf(buffer, "\n");
0836
0837 print_nid_array(buffer, codec, nid, &codec->mixers);
0838 print_nid_array(buffer, codec, nid, &codec->nids);
0839 print_nid_pcms(buffer, codec, nid);
0840
0841
0842
0843
0844 if (wid_type == AC_WID_VOL_KNB)
0845 wid_caps |= AC_WCAP_CONN_LIST;
0846
0847 if (wid_caps & AC_WCAP_CONN_LIST) {
0848 conn_len = snd_hda_get_num_raw_conns(codec, nid);
0849 if (conn_len > 0) {
0850 conn = kmalloc_array(conn_len,
0851 sizeof(hda_nid_t),
0852 GFP_KERNEL);
0853 if (!conn)
0854 return;
0855 if (snd_hda_get_raw_connections(codec, nid, conn,
0856 conn_len) < 0)
0857 conn_len = 0;
0858 }
0859 }
0860
0861 if (wid_caps & AC_WCAP_IN_AMP) {
0862 snd_iprintf(buffer, " Amp-In caps: ");
0863 print_amp_caps(buffer, codec, nid, HDA_INPUT);
0864 snd_iprintf(buffer, " Amp-In vals: ");
0865 if (wid_type == AC_WID_PIN ||
0866 (codec->single_adc_amp &&
0867 wid_type == AC_WID_AUD_IN))
0868 print_amp_vals(buffer, codec, nid, HDA_INPUT,
0869 wid_caps, 1);
0870 else
0871 print_amp_vals(buffer, codec, nid, HDA_INPUT,
0872 wid_caps, conn_len);
0873 }
0874 if (wid_caps & AC_WCAP_OUT_AMP) {
0875 snd_iprintf(buffer, " Amp-Out caps: ");
0876 print_amp_caps(buffer, codec, nid, HDA_OUTPUT);
0877 snd_iprintf(buffer, " Amp-Out vals: ");
0878 if (wid_type == AC_WID_PIN &&
0879 codec->pin_amp_workaround)
0880 print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
0881 wid_caps, conn_len);
0882 else
0883 print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
0884 wid_caps, 1);
0885 }
0886
0887 switch (wid_type) {
0888 case AC_WID_PIN: {
0889 int supports_vref;
0890 print_pin_caps(buffer, codec, nid, &supports_vref);
0891 print_pin_ctls(buffer, codec, nid, supports_vref);
0892 break;
0893 }
0894 case AC_WID_VOL_KNB:
0895 print_vol_knob(buffer, codec, nid);
0896 break;
0897 case AC_WID_AUD_OUT:
0898 case AC_WID_AUD_IN:
0899 print_audio_io(buffer, codec, nid, wid_type);
0900 if (wid_caps & AC_WCAP_DIGITAL)
0901 print_digital_conv(buffer, codec, nid);
0902 if (wid_caps & AC_WCAP_FORMAT_OVRD) {
0903 snd_iprintf(buffer, " PCM:\n");
0904 print_pcm_caps(buffer, codec, nid);
0905 }
0906 break;
0907 }
0908
0909 if (wid_caps & AC_WCAP_UNSOL_CAP)
0910 print_unsol_cap(buffer, codec, nid);
0911
0912 if (wid_caps & AC_WCAP_POWER)
0913 print_power_state(buffer, codec, nid);
0914
0915 if (wid_caps & AC_WCAP_DELAY)
0916 snd_iprintf(buffer, " Delay: %d samples\n",
0917 (wid_caps & AC_WCAP_DELAY) >>
0918 AC_WCAP_DELAY_SHIFT);
0919
0920 if (wid_type == AC_WID_PIN && codec->dp_mst)
0921 print_device_list(buffer, codec, nid);
0922
0923 if (wid_caps & AC_WCAP_CONN_LIST)
0924 print_conn_list(buffer, codec, nid, wid_type,
0925 conn, conn_len);
0926
0927 if (wid_caps & AC_WCAP_PROC_WID)
0928 print_proc_caps(buffer, codec, nid);
0929
0930 if (codec->proc_widget_hook)
0931 codec->proc_widget_hook(buffer, codec, nid);
0932
0933 kfree(conn);
0934 }
0935 snd_hda_power_down(codec);
0936 }
0937
0938
0939
0940
0941 int snd_hda_codec_proc_new(struct hda_codec *codec)
0942 {
0943 char name[32];
0944
0945 snprintf(name, sizeof(name), "codec#%d", codec->core.addr);
0946 return snd_card_ro_proc_new(codec->card, name, codec, print_codec_info);
0947 }
0948