xref: /kernel/linux/linux-5.10/sound/pci/hda/hda_proc.c (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Universal Interface for Intel High Definition Audio Codec
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Generic proc interface
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/init.h>
118c2ecf20Sopenharmony_ci#include <linux/slab.h>
128c2ecf20Sopenharmony_ci#include <sound/core.h>
138c2ecf20Sopenharmony_ci#include <linux/module.h>
148c2ecf20Sopenharmony_ci#include <sound/hda_codec.h>
158c2ecf20Sopenharmony_ci#include "hda_local.h"
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistatic int dump_coef = -1;
188c2ecf20Sopenharmony_cimodule_param(dump_coef, int, 0644);
198c2ecf20Sopenharmony_ciMODULE_PARM_DESC(dump_coef, "Dump processing coefficients in codec proc file (-1=auto, 0=disable, 1=enable)");
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci/* always use noncached version */
228c2ecf20Sopenharmony_ci#define param_read(codec, nid, parm) \
238c2ecf20Sopenharmony_ci	snd_hdac_read_parm_uncached(&(codec)->core, nid, parm)
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_cistatic const char *get_wid_type_name(unsigned int wid_value)
268c2ecf20Sopenharmony_ci{
278c2ecf20Sopenharmony_ci	static const char * const names[16] = {
288c2ecf20Sopenharmony_ci		[AC_WID_AUD_OUT] = "Audio Output",
298c2ecf20Sopenharmony_ci		[AC_WID_AUD_IN] = "Audio Input",
308c2ecf20Sopenharmony_ci		[AC_WID_AUD_MIX] = "Audio Mixer",
318c2ecf20Sopenharmony_ci		[AC_WID_AUD_SEL] = "Audio Selector",
328c2ecf20Sopenharmony_ci		[AC_WID_PIN] = "Pin Complex",
338c2ecf20Sopenharmony_ci		[AC_WID_POWER] = "Power Widget",
348c2ecf20Sopenharmony_ci		[AC_WID_VOL_KNB] = "Volume Knob Widget",
358c2ecf20Sopenharmony_ci		[AC_WID_BEEP] = "Beep Generator Widget",
368c2ecf20Sopenharmony_ci		[AC_WID_VENDOR] = "Vendor Defined Widget",
378c2ecf20Sopenharmony_ci	};
388c2ecf20Sopenharmony_ci	if (wid_value == -1)
398c2ecf20Sopenharmony_ci		return "UNKNOWN Widget";
408c2ecf20Sopenharmony_ci	wid_value &= 0xf;
418c2ecf20Sopenharmony_ci	if (names[wid_value])
428c2ecf20Sopenharmony_ci		return names[wid_value];
438c2ecf20Sopenharmony_ci	else
448c2ecf20Sopenharmony_ci		return "UNKNOWN Widget";
458c2ecf20Sopenharmony_ci}
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_cistatic void print_nid_array(struct snd_info_buffer *buffer,
488c2ecf20Sopenharmony_ci			    struct hda_codec *codec, hda_nid_t nid,
498c2ecf20Sopenharmony_ci			    struct snd_array *array)
508c2ecf20Sopenharmony_ci{
518c2ecf20Sopenharmony_ci	int i;
528c2ecf20Sopenharmony_ci	struct hda_nid_item *items = array->list, *item;
538c2ecf20Sopenharmony_ci	struct snd_kcontrol *kctl;
548c2ecf20Sopenharmony_ci	for (i = 0; i < array->used; i++) {
558c2ecf20Sopenharmony_ci		item = &items[i];
568c2ecf20Sopenharmony_ci		if (item->nid == nid) {
578c2ecf20Sopenharmony_ci			kctl = item->kctl;
588c2ecf20Sopenharmony_ci			snd_iprintf(buffer,
598c2ecf20Sopenharmony_ci			  "  Control: name=\"%s\", index=%i, device=%i\n",
608c2ecf20Sopenharmony_ci			  kctl->id.name, kctl->id.index + item->index,
618c2ecf20Sopenharmony_ci			  kctl->id.device);
628c2ecf20Sopenharmony_ci			if (item->flags & HDA_NID_ITEM_AMP)
638c2ecf20Sopenharmony_ci				snd_iprintf(buffer,
648c2ecf20Sopenharmony_ci				  "    ControlAmp: chs=%lu, dir=%s, "
658c2ecf20Sopenharmony_ci				  "idx=%lu, ofs=%lu\n",
668c2ecf20Sopenharmony_ci				  get_amp_channels(kctl),
678c2ecf20Sopenharmony_ci				  get_amp_direction(kctl) ? "Out" : "In",
688c2ecf20Sopenharmony_ci				  get_amp_index(kctl),
698c2ecf20Sopenharmony_ci				  get_amp_offset(kctl));
708c2ecf20Sopenharmony_ci		}
718c2ecf20Sopenharmony_ci	}
728c2ecf20Sopenharmony_ci}
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_cistatic void print_nid_pcms(struct snd_info_buffer *buffer,
758c2ecf20Sopenharmony_ci			   struct hda_codec *codec, hda_nid_t nid)
768c2ecf20Sopenharmony_ci{
778c2ecf20Sopenharmony_ci	int type;
788c2ecf20Sopenharmony_ci	struct hda_pcm *cpcm;
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci	list_for_each_entry(cpcm, &codec->pcm_list_head, list) {
818c2ecf20Sopenharmony_ci		for (type = 0; type < 2; type++) {
828c2ecf20Sopenharmony_ci			if (cpcm->stream[type].nid != nid || cpcm->pcm == NULL)
838c2ecf20Sopenharmony_ci				continue;
848c2ecf20Sopenharmony_ci			snd_iprintf(buffer, "  Device: name=\"%s\", "
858c2ecf20Sopenharmony_ci				    "type=\"%s\", device=%i\n",
868c2ecf20Sopenharmony_ci				    cpcm->name,
878c2ecf20Sopenharmony_ci				    snd_hda_pcm_type_name[cpcm->pcm_type],
888c2ecf20Sopenharmony_ci				    cpcm->pcm->device);
898c2ecf20Sopenharmony_ci		}
908c2ecf20Sopenharmony_ci	}
918c2ecf20Sopenharmony_ci}
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_cistatic void print_amp_caps(struct snd_info_buffer *buffer,
948c2ecf20Sopenharmony_ci			   struct hda_codec *codec, hda_nid_t nid, int dir)
958c2ecf20Sopenharmony_ci{
968c2ecf20Sopenharmony_ci	unsigned int caps;
978c2ecf20Sopenharmony_ci	caps = param_read(codec, nid, dir == HDA_OUTPUT ?
988c2ecf20Sopenharmony_ci			  AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP);
998c2ecf20Sopenharmony_ci	if (caps == -1 || caps == 0) {
1008c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "N/A\n");
1018c2ecf20Sopenharmony_ci		return;
1028c2ecf20Sopenharmony_ci	}
1038c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "ofs=0x%02x, nsteps=0x%02x, stepsize=0x%02x, "
1048c2ecf20Sopenharmony_ci		    "mute=%x\n",
1058c2ecf20Sopenharmony_ci		    caps & AC_AMPCAP_OFFSET,
1068c2ecf20Sopenharmony_ci		    (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT,
1078c2ecf20Sopenharmony_ci		    (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT,
1088c2ecf20Sopenharmony_ci		    (caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT);
1098c2ecf20Sopenharmony_ci}
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci/* is this a stereo widget or a stereo-to-mono mix? */
1128c2ecf20Sopenharmony_cistatic bool is_stereo_amps(struct hda_codec *codec, hda_nid_t nid,
1138c2ecf20Sopenharmony_ci			   int dir, unsigned int wcaps, int indices)
1148c2ecf20Sopenharmony_ci{
1158c2ecf20Sopenharmony_ci	hda_nid_t conn;
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci	if (wcaps & AC_WCAP_STEREO)
1188c2ecf20Sopenharmony_ci		return true;
1198c2ecf20Sopenharmony_ci	/* check for a stereo-to-mono mix; it must be:
1208c2ecf20Sopenharmony_ci	 * only a single connection, only for input, and only a mixer widget
1218c2ecf20Sopenharmony_ci	 */
1228c2ecf20Sopenharmony_ci	if (indices != 1 || dir != HDA_INPUT ||
1238c2ecf20Sopenharmony_ci	    get_wcaps_type(wcaps) != AC_WID_AUD_MIX)
1248c2ecf20Sopenharmony_ci		return false;
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci	if (snd_hda_get_raw_connections(codec, nid, &conn, 1) < 0)
1278c2ecf20Sopenharmony_ci		return false;
1288c2ecf20Sopenharmony_ci	/* the connection source is a stereo? */
1298c2ecf20Sopenharmony_ci	wcaps = snd_hda_param_read(codec, conn, AC_PAR_AUDIO_WIDGET_CAP);
1308c2ecf20Sopenharmony_ci	return !!(wcaps & AC_WCAP_STEREO);
1318c2ecf20Sopenharmony_ci}
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_cistatic void print_amp_vals(struct snd_info_buffer *buffer,
1348c2ecf20Sopenharmony_ci			   struct hda_codec *codec, hda_nid_t nid,
1358c2ecf20Sopenharmony_ci			   int dir, unsigned int wcaps, int indices)
1368c2ecf20Sopenharmony_ci{
1378c2ecf20Sopenharmony_ci	unsigned int val;
1388c2ecf20Sopenharmony_ci	bool stereo;
1398c2ecf20Sopenharmony_ci	int i;
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci	stereo = is_stereo_amps(codec, nid, dir, wcaps, indices);
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci	dir = dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
1448c2ecf20Sopenharmony_ci	for (i = 0; i < indices; i++) {
1458c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " [");
1468c2ecf20Sopenharmony_ci		val = snd_hda_codec_read(codec, nid, 0,
1478c2ecf20Sopenharmony_ci					 AC_VERB_GET_AMP_GAIN_MUTE,
1488c2ecf20Sopenharmony_ci					 AC_AMP_GET_LEFT | dir | i);
1498c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "0x%02x", val);
1508c2ecf20Sopenharmony_ci		if (stereo) {
1518c2ecf20Sopenharmony_ci			val = snd_hda_codec_read(codec, nid, 0,
1528c2ecf20Sopenharmony_ci						 AC_VERB_GET_AMP_GAIN_MUTE,
1538c2ecf20Sopenharmony_ci						 AC_AMP_GET_RIGHT | dir | i);
1548c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " 0x%02x", val);
1558c2ecf20Sopenharmony_ci		}
1568c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "]");
1578c2ecf20Sopenharmony_ci	}
1588c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "\n");
1598c2ecf20Sopenharmony_ci}
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_cistatic void print_pcm_rates(struct snd_info_buffer *buffer, unsigned int pcm)
1628c2ecf20Sopenharmony_ci{
1638c2ecf20Sopenharmony_ci	static const unsigned int rates[] = {
1648c2ecf20Sopenharmony_ci		8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200,
1658c2ecf20Sopenharmony_ci		96000, 176400, 192000, 384000
1668c2ecf20Sopenharmony_ci	};
1678c2ecf20Sopenharmony_ci	int i;
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci	pcm &= AC_SUPPCM_RATES;
1708c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "    rates [0x%x]:", pcm);
1718c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(rates); i++)
1728c2ecf20Sopenharmony_ci		if (pcm & (1 << i))
1738c2ecf20Sopenharmony_ci			snd_iprintf(buffer,  " %d", rates[i]);
1748c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "\n");
1758c2ecf20Sopenharmony_ci}
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_cistatic void print_pcm_bits(struct snd_info_buffer *buffer, unsigned int pcm)
1788c2ecf20Sopenharmony_ci{
1798c2ecf20Sopenharmony_ci	char buf[SND_PRINT_BITS_ADVISED_BUFSIZE];
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "    bits [0x%x]:", (pcm >> 16) & 0xff);
1828c2ecf20Sopenharmony_ci	snd_print_pcm_bits(pcm, buf, sizeof(buf));
1838c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "%s\n", buf);
1848c2ecf20Sopenharmony_ci}
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_cistatic void print_pcm_formats(struct snd_info_buffer *buffer,
1878c2ecf20Sopenharmony_ci			      unsigned int streams)
1888c2ecf20Sopenharmony_ci{
1898c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "    formats [0x%x]:", streams & 0xf);
1908c2ecf20Sopenharmony_ci	if (streams & AC_SUPFMT_PCM)
1918c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " PCM");
1928c2ecf20Sopenharmony_ci	if (streams & AC_SUPFMT_FLOAT32)
1938c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " FLOAT");
1948c2ecf20Sopenharmony_ci	if (streams & AC_SUPFMT_AC3)
1958c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " AC3");
1968c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "\n");
1978c2ecf20Sopenharmony_ci}
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_cistatic void print_pcm_caps(struct snd_info_buffer *buffer,
2008c2ecf20Sopenharmony_ci			   struct hda_codec *codec, hda_nid_t nid)
2018c2ecf20Sopenharmony_ci{
2028c2ecf20Sopenharmony_ci	unsigned int pcm = param_read(codec, nid, AC_PAR_PCM);
2038c2ecf20Sopenharmony_ci	unsigned int stream = param_read(codec, nid, AC_PAR_STREAM);
2048c2ecf20Sopenharmony_ci	if (pcm == -1 || stream == -1) {
2058c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "N/A\n");
2068c2ecf20Sopenharmony_ci		return;
2078c2ecf20Sopenharmony_ci	}
2088c2ecf20Sopenharmony_ci	print_pcm_rates(buffer, pcm);
2098c2ecf20Sopenharmony_ci	print_pcm_bits(buffer, pcm);
2108c2ecf20Sopenharmony_ci	print_pcm_formats(buffer, stream);
2118c2ecf20Sopenharmony_ci}
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_cistatic const char *get_jack_connection(u32 cfg)
2148c2ecf20Sopenharmony_ci{
2158c2ecf20Sopenharmony_ci	static const char * const names[16] = {
2168c2ecf20Sopenharmony_ci		"Unknown", "1/8", "1/4", "ATAPI",
2178c2ecf20Sopenharmony_ci		"RCA", "Optical","Digital", "Analog",
2188c2ecf20Sopenharmony_ci		"DIN", "XLR", "RJ11", "Comb",
2198c2ecf20Sopenharmony_ci		NULL, NULL, NULL, "Other"
2208c2ecf20Sopenharmony_ci	};
2218c2ecf20Sopenharmony_ci	cfg = (cfg & AC_DEFCFG_CONN_TYPE) >> AC_DEFCFG_CONN_TYPE_SHIFT;
2228c2ecf20Sopenharmony_ci	if (names[cfg])
2238c2ecf20Sopenharmony_ci		return names[cfg];
2248c2ecf20Sopenharmony_ci	else
2258c2ecf20Sopenharmony_ci		return "UNKNOWN";
2268c2ecf20Sopenharmony_ci}
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_cistatic const char *get_jack_color(u32 cfg)
2298c2ecf20Sopenharmony_ci{
2308c2ecf20Sopenharmony_ci	static const char * const names[16] = {
2318c2ecf20Sopenharmony_ci		"Unknown", "Black", "Grey", "Blue",
2328c2ecf20Sopenharmony_ci		"Green", "Red", "Orange", "Yellow",
2338c2ecf20Sopenharmony_ci		"Purple", "Pink", NULL, NULL,
2348c2ecf20Sopenharmony_ci		NULL, NULL, "White", "Other",
2358c2ecf20Sopenharmony_ci	};
2368c2ecf20Sopenharmony_ci	cfg = (cfg & AC_DEFCFG_COLOR) >> AC_DEFCFG_COLOR_SHIFT;
2378c2ecf20Sopenharmony_ci	if (names[cfg])
2388c2ecf20Sopenharmony_ci		return names[cfg];
2398c2ecf20Sopenharmony_ci	else
2408c2ecf20Sopenharmony_ci		return "UNKNOWN";
2418c2ecf20Sopenharmony_ci}
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci/*
2448c2ecf20Sopenharmony_ci * Parse the pin default config value and returns the string of the
2458c2ecf20Sopenharmony_ci * jack location, e.g. "Rear", "Front", etc.
2468c2ecf20Sopenharmony_ci */
2478c2ecf20Sopenharmony_cistatic const char *get_jack_location(u32 cfg)
2488c2ecf20Sopenharmony_ci{
2498c2ecf20Sopenharmony_ci	static const char * const bases[7] = {
2508c2ecf20Sopenharmony_ci		"N/A", "Rear", "Front", "Left", "Right", "Top", "Bottom",
2518c2ecf20Sopenharmony_ci	};
2528c2ecf20Sopenharmony_ci	static const unsigned char specials_idx[] = {
2538c2ecf20Sopenharmony_ci		0x07, 0x08,
2548c2ecf20Sopenharmony_ci		0x17, 0x18, 0x19,
2558c2ecf20Sopenharmony_ci		0x37, 0x38
2568c2ecf20Sopenharmony_ci	};
2578c2ecf20Sopenharmony_ci	static const char * const specials[] = {
2588c2ecf20Sopenharmony_ci		"Rear Panel", "Drive Bar",
2598c2ecf20Sopenharmony_ci		"Riser", "HDMI", "ATAPI",
2608c2ecf20Sopenharmony_ci		"Mobile-In", "Mobile-Out"
2618c2ecf20Sopenharmony_ci	};
2628c2ecf20Sopenharmony_ci	int i;
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci	cfg = (cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT;
2658c2ecf20Sopenharmony_ci	if ((cfg & 0x0f) < 7)
2668c2ecf20Sopenharmony_ci		return bases[cfg & 0x0f];
2678c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(specials_idx); i++) {
2688c2ecf20Sopenharmony_ci		if (cfg == specials_idx[i])
2698c2ecf20Sopenharmony_ci			return specials[i];
2708c2ecf20Sopenharmony_ci	}
2718c2ecf20Sopenharmony_ci	return "UNKNOWN";
2728c2ecf20Sopenharmony_ci}
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci/*
2758c2ecf20Sopenharmony_ci * Parse the pin default config value and returns the string of the
2768c2ecf20Sopenharmony_ci * jack connectivity, i.e. external or internal connection.
2778c2ecf20Sopenharmony_ci */
2788c2ecf20Sopenharmony_cistatic const char *get_jack_connectivity(u32 cfg)
2798c2ecf20Sopenharmony_ci{
2808c2ecf20Sopenharmony_ci	static const char * const jack_locations[4] = {
2818c2ecf20Sopenharmony_ci		"Ext", "Int", "Sep", "Oth"
2828c2ecf20Sopenharmony_ci	};
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci	return jack_locations[(cfg >> (AC_DEFCFG_LOCATION_SHIFT + 4)) & 3];
2858c2ecf20Sopenharmony_ci}
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci/*
2888c2ecf20Sopenharmony_ci * Parse the pin default config value and returns the string of the
2898c2ecf20Sopenharmony_ci * jack type, i.e. the purpose of the jack, such as Line-Out or CD.
2908c2ecf20Sopenharmony_ci */
2918c2ecf20Sopenharmony_cistatic const char *get_jack_type(u32 cfg)
2928c2ecf20Sopenharmony_ci{
2938c2ecf20Sopenharmony_ci	static const char * const jack_types[16] = {
2948c2ecf20Sopenharmony_ci		"Line Out", "Speaker", "HP Out", "CD",
2958c2ecf20Sopenharmony_ci		"SPDIF Out", "Digital Out", "Modem Line", "Modem Hand",
2968c2ecf20Sopenharmony_ci		"Line In", "Aux", "Mic", "Telephony",
2978c2ecf20Sopenharmony_ci		"SPDIF In", "Digital In", "Reserved", "Other"
2988c2ecf20Sopenharmony_ci	};
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci	return jack_types[(cfg & AC_DEFCFG_DEVICE)
3018c2ecf20Sopenharmony_ci				>> AC_DEFCFG_DEVICE_SHIFT];
3028c2ecf20Sopenharmony_ci}
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_cistatic void print_pin_caps(struct snd_info_buffer *buffer,
3058c2ecf20Sopenharmony_ci			   struct hda_codec *codec, hda_nid_t nid,
3068c2ecf20Sopenharmony_ci			   int *supports_vref)
3078c2ecf20Sopenharmony_ci{
3088c2ecf20Sopenharmony_ci	static const char * const jack_conns[4] = {
3098c2ecf20Sopenharmony_ci		"Jack", "N/A", "Fixed", "Both"
3108c2ecf20Sopenharmony_ci	};
3118c2ecf20Sopenharmony_ci	unsigned int caps, val;
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci	caps = param_read(codec, nid, AC_PAR_PIN_CAP);
3148c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "  Pincap 0x%08x:", caps);
3158c2ecf20Sopenharmony_ci	if (caps & AC_PINCAP_IN)
3168c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " IN");
3178c2ecf20Sopenharmony_ci	if (caps & AC_PINCAP_OUT)
3188c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " OUT");
3198c2ecf20Sopenharmony_ci	if (caps & AC_PINCAP_HP_DRV)
3208c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " HP");
3218c2ecf20Sopenharmony_ci	if (caps & AC_PINCAP_EAPD)
3228c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " EAPD");
3238c2ecf20Sopenharmony_ci	if (caps & AC_PINCAP_PRES_DETECT)
3248c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " Detect");
3258c2ecf20Sopenharmony_ci	if (caps & AC_PINCAP_BALANCE)
3268c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " Balanced");
3278c2ecf20Sopenharmony_ci	if (caps & AC_PINCAP_HDMI) {
3288c2ecf20Sopenharmony_ci		/* Realtek uses this bit as a different meaning */
3298c2ecf20Sopenharmony_ci		if ((codec->core.vendor_id >> 16) == 0x10ec)
3308c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " R/L");
3318c2ecf20Sopenharmony_ci		else {
3328c2ecf20Sopenharmony_ci			if (caps & AC_PINCAP_HBR)
3338c2ecf20Sopenharmony_ci				snd_iprintf(buffer, " HBR");
3348c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " HDMI");
3358c2ecf20Sopenharmony_ci		}
3368c2ecf20Sopenharmony_ci	}
3378c2ecf20Sopenharmony_ci	if (caps & AC_PINCAP_DP)
3388c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " DP");
3398c2ecf20Sopenharmony_ci	if (caps & AC_PINCAP_TRIG_REQ)
3408c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " Trigger");
3418c2ecf20Sopenharmony_ci	if (caps & AC_PINCAP_IMP_SENSE)
3428c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " ImpSense");
3438c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "\n");
3448c2ecf20Sopenharmony_ci	if (caps & AC_PINCAP_VREF) {
3458c2ecf20Sopenharmony_ci		unsigned int vref =
3468c2ecf20Sopenharmony_ci			(caps & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
3478c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "    Vref caps:");
3488c2ecf20Sopenharmony_ci		if (vref & AC_PINCAP_VREF_HIZ)
3498c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " HIZ");
3508c2ecf20Sopenharmony_ci		if (vref & AC_PINCAP_VREF_50)
3518c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " 50");
3528c2ecf20Sopenharmony_ci		if (vref & AC_PINCAP_VREF_GRD)
3538c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " GRD");
3548c2ecf20Sopenharmony_ci		if (vref & AC_PINCAP_VREF_80)
3558c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " 80");
3568c2ecf20Sopenharmony_ci		if (vref & AC_PINCAP_VREF_100)
3578c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " 100");
3588c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "\n");
3598c2ecf20Sopenharmony_ci		*supports_vref = 1;
3608c2ecf20Sopenharmony_ci	} else
3618c2ecf20Sopenharmony_ci		*supports_vref = 0;
3628c2ecf20Sopenharmony_ci	if (caps & AC_PINCAP_EAPD) {
3638c2ecf20Sopenharmony_ci		val = snd_hda_codec_read(codec, nid, 0,
3648c2ecf20Sopenharmony_ci					 AC_VERB_GET_EAPD_BTLENABLE, 0);
3658c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "  EAPD 0x%x:", val);
3668c2ecf20Sopenharmony_ci		if (val & AC_EAPDBTL_BALANCED)
3678c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " BALANCED");
3688c2ecf20Sopenharmony_ci		if (val & AC_EAPDBTL_EAPD)
3698c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " EAPD");
3708c2ecf20Sopenharmony_ci		if (val & AC_EAPDBTL_LR_SWAP)
3718c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " R/L");
3728c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "\n");
3738c2ecf20Sopenharmony_ci	}
3748c2ecf20Sopenharmony_ci	caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3758c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "  Pin Default 0x%08x: [%s] %s at %s %s\n", caps,
3768c2ecf20Sopenharmony_ci		    jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT],
3778c2ecf20Sopenharmony_ci		    get_jack_type(caps),
3788c2ecf20Sopenharmony_ci		    get_jack_connectivity(caps),
3798c2ecf20Sopenharmony_ci		    get_jack_location(caps));
3808c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "    Conn = %s, Color = %s\n",
3818c2ecf20Sopenharmony_ci		    get_jack_connection(caps),
3828c2ecf20Sopenharmony_ci		    get_jack_color(caps));
3838c2ecf20Sopenharmony_ci	/* Default association and sequence values refer to default grouping
3848c2ecf20Sopenharmony_ci	 * of pin complexes and their sequence within the group. This is used
3858c2ecf20Sopenharmony_ci	 * for priority and resource allocation.
3868c2ecf20Sopenharmony_ci	 */
3878c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "    DefAssociation = 0x%x, Sequence = 0x%x\n",
3888c2ecf20Sopenharmony_ci		    (caps & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT,
3898c2ecf20Sopenharmony_ci		    caps & AC_DEFCFG_SEQUENCE);
3908c2ecf20Sopenharmony_ci	if (((caps & AC_DEFCFG_MISC) >> AC_DEFCFG_MISC_SHIFT) &
3918c2ecf20Sopenharmony_ci	    AC_DEFCFG_MISC_NO_PRESENCE) {
3928c2ecf20Sopenharmony_ci		/* Miscellaneous bit indicates external hardware does not
3938c2ecf20Sopenharmony_ci		 * support presence detection even if the pin complex
3948c2ecf20Sopenharmony_ci		 * indicates it is supported.
3958c2ecf20Sopenharmony_ci		 */
3968c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "    Misc = NO_PRESENCE\n");
3978c2ecf20Sopenharmony_ci	}
3988c2ecf20Sopenharmony_ci}
3998c2ecf20Sopenharmony_ci
4008c2ecf20Sopenharmony_cistatic void print_pin_ctls(struct snd_info_buffer *buffer,
4018c2ecf20Sopenharmony_ci			   struct hda_codec *codec, hda_nid_t nid,
4028c2ecf20Sopenharmony_ci			   int supports_vref)
4038c2ecf20Sopenharmony_ci{
4048c2ecf20Sopenharmony_ci	unsigned int pinctls;
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci	pinctls = snd_hda_codec_read(codec, nid, 0,
4078c2ecf20Sopenharmony_ci				     AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4088c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "  Pin-ctls: 0x%02x:", pinctls);
4098c2ecf20Sopenharmony_ci	if (pinctls & AC_PINCTL_IN_EN)
4108c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " IN");
4118c2ecf20Sopenharmony_ci	if (pinctls & AC_PINCTL_OUT_EN)
4128c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " OUT");
4138c2ecf20Sopenharmony_ci	if (pinctls & AC_PINCTL_HP_EN)
4148c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " HP");
4158c2ecf20Sopenharmony_ci	if (supports_vref) {
4168c2ecf20Sopenharmony_ci		int vref = pinctls & AC_PINCTL_VREFEN;
4178c2ecf20Sopenharmony_ci		switch (vref) {
4188c2ecf20Sopenharmony_ci		case AC_PINCTL_VREF_HIZ:
4198c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " VREF_HIZ");
4208c2ecf20Sopenharmony_ci			break;
4218c2ecf20Sopenharmony_ci		case AC_PINCTL_VREF_50:
4228c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " VREF_50");
4238c2ecf20Sopenharmony_ci			break;
4248c2ecf20Sopenharmony_ci		case AC_PINCTL_VREF_GRD:
4258c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " VREF_GRD");
4268c2ecf20Sopenharmony_ci			break;
4278c2ecf20Sopenharmony_ci		case AC_PINCTL_VREF_80:
4288c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " VREF_80");
4298c2ecf20Sopenharmony_ci			break;
4308c2ecf20Sopenharmony_ci		case AC_PINCTL_VREF_100:
4318c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " VREF_100");
4328c2ecf20Sopenharmony_ci			break;
4338c2ecf20Sopenharmony_ci		}
4348c2ecf20Sopenharmony_ci	}
4358c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "\n");
4368c2ecf20Sopenharmony_ci}
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_cistatic void print_vol_knob(struct snd_info_buffer *buffer,
4398c2ecf20Sopenharmony_ci			   struct hda_codec *codec, hda_nid_t nid)
4408c2ecf20Sopenharmony_ci{
4418c2ecf20Sopenharmony_ci	unsigned int cap = param_read(codec, nid, AC_PAR_VOL_KNB_CAP);
4428c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "  Volume-Knob: delta=%d, steps=%d, ",
4438c2ecf20Sopenharmony_ci		    (cap >> 7) & 1, cap & 0x7f);
4448c2ecf20Sopenharmony_ci	cap = snd_hda_codec_read(codec, nid, 0,
4458c2ecf20Sopenharmony_ci				 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
4468c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "direct=%d, val=%d\n",
4478c2ecf20Sopenharmony_ci		    (cap >> 7) & 1, cap & 0x7f);
4488c2ecf20Sopenharmony_ci}
4498c2ecf20Sopenharmony_ci
4508c2ecf20Sopenharmony_cistatic void print_audio_io(struct snd_info_buffer *buffer,
4518c2ecf20Sopenharmony_ci			   struct hda_codec *codec, hda_nid_t nid,
4528c2ecf20Sopenharmony_ci			   unsigned int wid_type)
4538c2ecf20Sopenharmony_ci{
4548c2ecf20Sopenharmony_ci	int conv = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
4558c2ecf20Sopenharmony_ci	snd_iprintf(buffer,
4568c2ecf20Sopenharmony_ci		    "  Converter: stream=%d, channel=%d\n",
4578c2ecf20Sopenharmony_ci		    (conv & AC_CONV_STREAM) >> AC_CONV_STREAM_SHIFT,
4588c2ecf20Sopenharmony_ci		    conv & AC_CONV_CHANNEL);
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci	if (wid_type == AC_WID_AUD_IN && (conv & AC_CONV_CHANNEL) == 0) {
4618c2ecf20Sopenharmony_ci		int sdi = snd_hda_codec_read(codec, nid, 0,
4628c2ecf20Sopenharmony_ci					     AC_VERB_GET_SDI_SELECT, 0);
4638c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "  SDI-Select: %d\n",
4648c2ecf20Sopenharmony_ci			    sdi & AC_SDI_SELECT);
4658c2ecf20Sopenharmony_ci	}
4668c2ecf20Sopenharmony_ci}
4678c2ecf20Sopenharmony_ci
4688c2ecf20Sopenharmony_cistatic void print_digital_conv(struct snd_info_buffer *buffer,
4698c2ecf20Sopenharmony_ci			       struct hda_codec *codec, hda_nid_t nid)
4708c2ecf20Sopenharmony_ci{
4718c2ecf20Sopenharmony_ci	unsigned int digi1 = snd_hda_codec_read(codec, nid, 0,
4728c2ecf20Sopenharmony_ci						AC_VERB_GET_DIGI_CONVERT_1, 0);
4738c2ecf20Sopenharmony_ci	unsigned char digi2 = digi1 >> 8;
4748c2ecf20Sopenharmony_ci	unsigned char digi3 = digi1 >> 16;
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "  Digital:");
4778c2ecf20Sopenharmony_ci	if (digi1 & AC_DIG1_ENABLE)
4788c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " Enabled");
4798c2ecf20Sopenharmony_ci	if (digi1 & AC_DIG1_V)
4808c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " Validity");
4818c2ecf20Sopenharmony_ci	if (digi1 & AC_DIG1_VCFG)
4828c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " ValidityCfg");
4838c2ecf20Sopenharmony_ci	if (digi1 & AC_DIG1_EMPHASIS)
4848c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " Preemphasis");
4858c2ecf20Sopenharmony_ci	if (digi1 & AC_DIG1_COPYRIGHT)
4868c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " Non-Copyright");
4878c2ecf20Sopenharmony_ci	if (digi1 & AC_DIG1_NONAUDIO)
4888c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " Non-Audio");
4898c2ecf20Sopenharmony_ci	if (digi1 & AC_DIG1_PROFESSIONAL)
4908c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " Pro");
4918c2ecf20Sopenharmony_ci	if (digi1 & AC_DIG1_LEVEL)
4928c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " GenLevel");
4938c2ecf20Sopenharmony_ci	if (digi3 & AC_DIG3_KAE)
4948c2ecf20Sopenharmony_ci		snd_iprintf(buffer, " KAE");
4958c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "\n");
4968c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "  Digital category: 0x%x\n",
4978c2ecf20Sopenharmony_ci		    digi2 & AC_DIG2_CC);
4988c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "  IEC Coding Type: 0x%x\n",
4998c2ecf20Sopenharmony_ci			digi3 & AC_DIG3_ICT);
5008c2ecf20Sopenharmony_ci}
5018c2ecf20Sopenharmony_ci
5028c2ecf20Sopenharmony_cistatic const char *get_pwr_state(u32 state)
5038c2ecf20Sopenharmony_ci{
5048c2ecf20Sopenharmony_ci	static const char * const buf[] = {
5058c2ecf20Sopenharmony_ci		"D0", "D1", "D2", "D3", "D3cold"
5068c2ecf20Sopenharmony_ci	};
5078c2ecf20Sopenharmony_ci	if (state < ARRAY_SIZE(buf))
5088c2ecf20Sopenharmony_ci		return buf[state];
5098c2ecf20Sopenharmony_ci	return "UNKNOWN";
5108c2ecf20Sopenharmony_ci}
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_cistatic void print_power_state(struct snd_info_buffer *buffer,
5138c2ecf20Sopenharmony_ci			      struct hda_codec *codec, hda_nid_t nid)
5148c2ecf20Sopenharmony_ci{
5158c2ecf20Sopenharmony_ci	static const char * const names[] = {
5168c2ecf20Sopenharmony_ci		[ilog2(AC_PWRST_D0SUP)]		= "D0",
5178c2ecf20Sopenharmony_ci		[ilog2(AC_PWRST_D1SUP)]		= "D1",
5188c2ecf20Sopenharmony_ci		[ilog2(AC_PWRST_D2SUP)]		= "D2",
5198c2ecf20Sopenharmony_ci		[ilog2(AC_PWRST_D3SUP)]		= "D3",
5208c2ecf20Sopenharmony_ci		[ilog2(AC_PWRST_D3COLDSUP)]	= "D3cold",
5218c2ecf20Sopenharmony_ci		[ilog2(AC_PWRST_S3D3COLDSUP)]	= "S3D3cold",
5228c2ecf20Sopenharmony_ci		[ilog2(AC_PWRST_CLKSTOP)]	= "CLKSTOP",
5238c2ecf20Sopenharmony_ci		[ilog2(AC_PWRST_EPSS)]		= "EPSS",
5248c2ecf20Sopenharmony_ci	};
5258c2ecf20Sopenharmony_ci
5268c2ecf20Sopenharmony_ci	int sup = param_read(codec, nid, AC_PAR_POWER_STATE);
5278c2ecf20Sopenharmony_ci	int pwr = snd_hda_codec_read(codec, nid, 0,
5288c2ecf20Sopenharmony_ci				     AC_VERB_GET_POWER_STATE, 0);
5298c2ecf20Sopenharmony_ci	if (sup != -1) {
5308c2ecf20Sopenharmony_ci		int i;
5318c2ecf20Sopenharmony_ci
5328c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "  Power states: ");
5338c2ecf20Sopenharmony_ci		for (i = 0; i < ARRAY_SIZE(names); i++) {
5348c2ecf20Sopenharmony_ci			if (sup & (1U << i))
5358c2ecf20Sopenharmony_ci				snd_iprintf(buffer, " %s", names[i]);
5368c2ecf20Sopenharmony_ci		}
5378c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "\n");
5388c2ecf20Sopenharmony_ci	}
5398c2ecf20Sopenharmony_ci
5408c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "  Power: setting=%s, actual=%s",
5418c2ecf20Sopenharmony_ci		    get_pwr_state(pwr & AC_PWRST_SETTING),
5428c2ecf20Sopenharmony_ci		    get_pwr_state((pwr & AC_PWRST_ACTUAL) >>
5438c2ecf20Sopenharmony_ci				  AC_PWRST_ACTUAL_SHIFT));
5448c2ecf20Sopenharmony_ci	if (pwr & AC_PWRST_ERROR)
5458c2ecf20Sopenharmony_ci		snd_iprintf(buffer, ", Error");
5468c2ecf20Sopenharmony_ci	if (pwr & AC_PWRST_CLK_STOP_OK)
5478c2ecf20Sopenharmony_ci		snd_iprintf(buffer, ", Clock-stop-OK");
5488c2ecf20Sopenharmony_ci	if (pwr & AC_PWRST_SETTING_RESET)
5498c2ecf20Sopenharmony_ci		snd_iprintf(buffer, ", Setting-reset");
5508c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "\n");
5518c2ecf20Sopenharmony_ci}
5528c2ecf20Sopenharmony_ci
5538c2ecf20Sopenharmony_cistatic void print_unsol_cap(struct snd_info_buffer *buffer,
5548c2ecf20Sopenharmony_ci			      struct hda_codec *codec, hda_nid_t nid)
5558c2ecf20Sopenharmony_ci{
5568c2ecf20Sopenharmony_ci	int unsol = snd_hda_codec_read(codec, nid, 0,
5578c2ecf20Sopenharmony_ci				       AC_VERB_GET_UNSOLICITED_RESPONSE, 0);
5588c2ecf20Sopenharmony_ci	snd_iprintf(buffer,
5598c2ecf20Sopenharmony_ci		    "  Unsolicited: tag=%02x, enabled=%d\n",
5608c2ecf20Sopenharmony_ci		    unsol & AC_UNSOL_TAG,
5618c2ecf20Sopenharmony_ci		    (unsol & AC_UNSOL_ENABLED) ? 1 : 0);
5628c2ecf20Sopenharmony_ci}
5638c2ecf20Sopenharmony_ci
5648c2ecf20Sopenharmony_cistatic inline bool can_dump_coef(struct hda_codec *codec)
5658c2ecf20Sopenharmony_ci{
5668c2ecf20Sopenharmony_ci	switch (dump_coef) {
5678c2ecf20Sopenharmony_ci	case 0: return false;
5688c2ecf20Sopenharmony_ci	case 1: return true;
5698c2ecf20Sopenharmony_ci	default: return codec->dump_coef;
5708c2ecf20Sopenharmony_ci	}
5718c2ecf20Sopenharmony_ci}
5728c2ecf20Sopenharmony_ci
5738c2ecf20Sopenharmony_cistatic void print_proc_caps(struct snd_info_buffer *buffer,
5748c2ecf20Sopenharmony_ci			    struct hda_codec *codec, hda_nid_t nid)
5758c2ecf20Sopenharmony_ci{
5768c2ecf20Sopenharmony_ci	unsigned int i, ncoeff, oldindex;
5778c2ecf20Sopenharmony_ci	unsigned int proc_caps = param_read(codec, nid, AC_PAR_PROC_CAP);
5788c2ecf20Sopenharmony_ci	ncoeff = (proc_caps & AC_PCAP_NUM_COEF) >> AC_PCAP_NUM_COEF_SHIFT;
5798c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "  Processing caps: benign=%d, ncoeff=%d\n",
5808c2ecf20Sopenharmony_ci		    proc_caps & AC_PCAP_BENIGN, ncoeff);
5818c2ecf20Sopenharmony_ci
5828c2ecf20Sopenharmony_ci	if (!can_dump_coef(codec))
5838c2ecf20Sopenharmony_ci		return;
5848c2ecf20Sopenharmony_ci
5858c2ecf20Sopenharmony_ci	/* Note: This is racy - another process could run in parallel and change
5868c2ecf20Sopenharmony_ci	   the coef index too. */
5878c2ecf20Sopenharmony_ci	oldindex = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_COEF_INDEX, 0);
5888c2ecf20Sopenharmony_ci	for (i = 0; i < ncoeff; i++) {
5898c2ecf20Sopenharmony_ci		unsigned int val;
5908c2ecf20Sopenharmony_ci		snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, i);
5918c2ecf20Sopenharmony_ci		val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF,
5928c2ecf20Sopenharmony_ci					 0);
5938c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "    Coeff 0x%02x: 0x%04x\n", i, val);
5948c2ecf20Sopenharmony_ci	}
5958c2ecf20Sopenharmony_ci	snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_COEF_INDEX, oldindex);
5968c2ecf20Sopenharmony_ci}
5978c2ecf20Sopenharmony_ci
5988c2ecf20Sopenharmony_cistatic void print_conn_list(struct snd_info_buffer *buffer,
5998c2ecf20Sopenharmony_ci			    struct hda_codec *codec, hda_nid_t nid,
6008c2ecf20Sopenharmony_ci			    unsigned int wid_type, hda_nid_t *conn,
6018c2ecf20Sopenharmony_ci			    int conn_len)
6028c2ecf20Sopenharmony_ci{
6038c2ecf20Sopenharmony_ci	int c, curr = -1;
6048c2ecf20Sopenharmony_ci	const hda_nid_t *list;
6058c2ecf20Sopenharmony_ci	int cache_len;
6068c2ecf20Sopenharmony_ci
6078c2ecf20Sopenharmony_ci	if (conn_len > 1 &&
6088c2ecf20Sopenharmony_ci	    wid_type != AC_WID_AUD_MIX &&
6098c2ecf20Sopenharmony_ci	    wid_type != AC_WID_VOL_KNB &&
6108c2ecf20Sopenharmony_ci	    wid_type != AC_WID_POWER)
6118c2ecf20Sopenharmony_ci		curr = snd_hda_codec_read(codec, nid, 0,
6128c2ecf20Sopenharmony_ci					  AC_VERB_GET_CONNECT_SEL, 0);
6138c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "  Connection: %d\n", conn_len);
6148c2ecf20Sopenharmony_ci	if (conn_len > 0) {
6158c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "    ");
6168c2ecf20Sopenharmony_ci		for (c = 0; c < conn_len; c++) {
6178c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " 0x%02x", conn[c]);
6188c2ecf20Sopenharmony_ci			if (c == curr)
6198c2ecf20Sopenharmony_ci				snd_iprintf(buffer, "*");
6208c2ecf20Sopenharmony_ci		}
6218c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "\n");
6228c2ecf20Sopenharmony_ci	}
6238c2ecf20Sopenharmony_ci
6248c2ecf20Sopenharmony_ci	/* Get Cache connections info */
6258c2ecf20Sopenharmony_ci	cache_len = snd_hda_get_conn_list(codec, nid, &list);
6268c2ecf20Sopenharmony_ci	if (cache_len >= 0 && (cache_len != conn_len ||
6278c2ecf20Sopenharmony_ci			      memcmp(list, conn, conn_len) != 0)) {
6288c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "  In-driver Connection: %d\n", cache_len);
6298c2ecf20Sopenharmony_ci		if (cache_len > 0) {
6308c2ecf20Sopenharmony_ci			snd_iprintf(buffer, "    ");
6318c2ecf20Sopenharmony_ci			for (c = 0; c < cache_len; c++)
6328c2ecf20Sopenharmony_ci				snd_iprintf(buffer, " 0x%02x", list[c]);
6338c2ecf20Sopenharmony_ci			snd_iprintf(buffer, "\n");
6348c2ecf20Sopenharmony_ci		}
6358c2ecf20Sopenharmony_ci	}
6368c2ecf20Sopenharmony_ci}
6378c2ecf20Sopenharmony_ci
6388c2ecf20Sopenharmony_cistatic void print_gpio(struct snd_info_buffer *buffer,
6398c2ecf20Sopenharmony_ci		       struct hda_codec *codec, hda_nid_t nid)
6408c2ecf20Sopenharmony_ci{
6418c2ecf20Sopenharmony_ci	unsigned int gpio =
6428c2ecf20Sopenharmony_ci		param_read(codec, codec->core.afg, AC_PAR_GPIO_CAP);
6438c2ecf20Sopenharmony_ci	unsigned int enable, direction, wake, unsol, sticky, data;
6448c2ecf20Sopenharmony_ci	int i, max;
6458c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "GPIO: io=%d, o=%d, i=%d, "
6468c2ecf20Sopenharmony_ci		    "unsolicited=%d, wake=%d\n",
6478c2ecf20Sopenharmony_ci		    gpio & AC_GPIO_IO_COUNT,
6488c2ecf20Sopenharmony_ci		    (gpio & AC_GPIO_O_COUNT) >> AC_GPIO_O_COUNT_SHIFT,
6498c2ecf20Sopenharmony_ci		    (gpio & AC_GPIO_I_COUNT) >> AC_GPIO_I_COUNT_SHIFT,
6508c2ecf20Sopenharmony_ci		    (gpio & AC_GPIO_UNSOLICITED) ? 1 : 0,
6518c2ecf20Sopenharmony_ci		    (gpio & AC_GPIO_WAKE) ? 1 : 0);
6528c2ecf20Sopenharmony_ci	max = gpio & AC_GPIO_IO_COUNT;
6538c2ecf20Sopenharmony_ci	if (!max || max > 8)
6548c2ecf20Sopenharmony_ci		return;
6558c2ecf20Sopenharmony_ci	enable = snd_hda_codec_read(codec, nid, 0,
6568c2ecf20Sopenharmony_ci				    AC_VERB_GET_GPIO_MASK, 0);
6578c2ecf20Sopenharmony_ci	direction = snd_hda_codec_read(codec, nid, 0,
6588c2ecf20Sopenharmony_ci				       AC_VERB_GET_GPIO_DIRECTION, 0);
6598c2ecf20Sopenharmony_ci	wake = snd_hda_codec_read(codec, nid, 0,
6608c2ecf20Sopenharmony_ci				  AC_VERB_GET_GPIO_WAKE_MASK, 0);
6618c2ecf20Sopenharmony_ci	unsol  = snd_hda_codec_read(codec, nid, 0,
6628c2ecf20Sopenharmony_ci				    AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK, 0);
6638c2ecf20Sopenharmony_ci	sticky = snd_hda_codec_read(codec, nid, 0,
6648c2ecf20Sopenharmony_ci				    AC_VERB_GET_GPIO_STICKY_MASK, 0);
6658c2ecf20Sopenharmony_ci	data = snd_hda_codec_read(codec, nid, 0,
6668c2ecf20Sopenharmony_ci				  AC_VERB_GET_GPIO_DATA, 0);
6678c2ecf20Sopenharmony_ci	for (i = 0; i < max; ++i)
6688c2ecf20Sopenharmony_ci		snd_iprintf(buffer,
6698c2ecf20Sopenharmony_ci			    "  IO[%d]: enable=%d, dir=%d, wake=%d, "
6708c2ecf20Sopenharmony_ci			    "sticky=%d, data=%d, unsol=%d\n", i,
6718c2ecf20Sopenharmony_ci			    (enable & (1<<i)) ? 1 : 0,
6728c2ecf20Sopenharmony_ci			    (direction & (1<<i)) ? 1 : 0,
6738c2ecf20Sopenharmony_ci			    (wake & (1<<i)) ? 1 : 0,
6748c2ecf20Sopenharmony_ci			    (sticky & (1<<i)) ? 1 : 0,
6758c2ecf20Sopenharmony_ci			    (data & (1<<i)) ? 1 : 0,
6768c2ecf20Sopenharmony_ci			    (unsol & (1<<i)) ? 1 : 0);
6778c2ecf20Sopenharmony_ci	/* FIXME: add GPO and GPI pin information */
6788c2ecf20Sopenharmony_ci	print_nid_array(buffer, codec, nid, &codec->mixers);
6798c2ecf20Sopenharmony_ci	print_nid_array(buffer, codec, nid, &codec->nids);
6808c2ecf20Sopenharmony_ci}
6818c2ecf20Sopenharmony_ci
6828c2ecf20Sopenharmony_cistatic void print_device_list(struct snd_info_buffer *buffer,
6838c2ecf20Sopenharmony_ci			    struct hda_codec *codec, hda_nid_t nid)
6848c2ecf20Sopenharmony_ci{
6858c2ecf20Sopenharmony_ci	int i, curr = -1;
6868c2ecf20Sopenharmony_ci	u8 dev_list[AC_MAX_DEV_LIST_LEN];
6878c2ecf20Sopenharmony_ci	int devlist_len;
6888c2ecf20Sopenharmony_ci
6898c2ecf20Sopenharmony_ci	devlist_len = snd_hda_get_devices(codec, nid, dev_list,
6908c2ecf20Sopenharmony_ci					AC_MAX_DEV_LIST_LEN);
6918c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "  Devices: %d\n", devlist_len);
6928c2ecf20Sopenharmony_ci	if (devlist_len <= 0)
6938c2ecf20Sopenharmony_ci		return;
6948c2ecf20Sopenharmony_ci
6958c2ecf20Sopenharmony_ci	curr = snd_hda_codec_read(codec, nid, 0,
6968c2ecf20Sopenharmony_ci				AC_VERB_GET_DEVICE_SEL, 0);
6978c2ecf20Sopenharmony_ci
6988c2ecf20Sopenharmony_ci	for (i = 0; i < devlist_len; i++) {
6998c2ecf20Sopenharmony_ci		if (i == curr)
7008c2ecf20Sopenharmony_ci			snd_iprintf(buffer, "    *");
7018c2ecf20Sopenharmony_ci		else
7028c2ecf20Sopenharmony_ci			snd_iprintf(buffer, "     ");
7038c2ecf20Sopenharmony_ci
7048c2ecf20Sopenharmony_ci		snd_iprintf(buffer,
7058c2ecf20Sopenharmony_ci			"Dev %02d: PD = %d, ELDV = %d, IA = %d\n", i,
7068c2ecf20Sopenharmony_ci			!!(dev_list[i] & AC_DE_PD),
7078c2ecf20Sopenharmony_ci			!!(dev_list[i] & AC_DE_ELDV),
7088c2ecf20Sopenharmony_ci			!!(dev_list[i] & AC_DE_IA));
7098c2ecf20Sopenharmony_ci	}
7108c2ecf20Sopenharmony_ci}
7118c2ecf20Sopenharmony_ci
7128c2ecf20Sopenharmony_cistatic void print_codec_core_info(struct hdac_device *codec,
7138c2ecf20Sopenharmony_ci				  struct snd_info_buffer *buffer)
7148c2ecf20Sopenharmony_ci{
7158c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "Codec: ");
7168c2ecf20Sopenharmony_ci	if (codec->vendor_name && codec->chip_name)
7178c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "%s %s\n",
7188c2ecf20Sopenharmony_ci			    codec->vendor_name, codec->chip_name);
7198c2ecf20Sopenharmony_ci	else
7208c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "Not Set\n");
7218c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "Address: %d\n", codec->addr);
7228c2ecf20Sopenharmony_ci	if (codec->afg)
7238c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "AFG Function Id: 0x%x (unsol %u)\n",
7248c2ecf20Sopenharmony_ci			codec->afg_function_id, codec->afg_unsol);
7258c2ecf20Sopenharmony_ci	if (codec->mfg)
7268c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "MFG Function Id: 0x%x (unsol %u)\n",
7278c2ecf20Sopenharmony_ci			codec->mfg_function_id, codec->mfg_unsol);
7288c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "Vendor Id: 0x%08x\n", codec->vendor_id);
7298c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "Subsystem Id: 0x%08x\n", codec->subsystem_id);
7308c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id);
7318c2ecf20Sopenharmony_ci
7328c2ecf20Sopenharmony_ci	if (codec->mfg)
7338c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "Modem Function Group: 0x%x\n", codec->mfg);
7348c2ecf20Sopenharmony_ci	else
7358c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "No Modem Function Group found\n");
7368c2ecf20Sopenharmony_ci}
7378c2ecf20Sopenharmony_ci
7388c2ecf20Sopenharmony_cistatic void print_codec_info(struct snd_info_entry *entry,
7398c2ecf20Sopenharmony_ci			     struct snd_info_buffer *buffer)
7408c2ecf20Sopenharmony_ci{
7418c2ecf20Sopenharmony_ci	struct hda_codec *codec = entry->private_data;
7428c2ecf20Sopenharmony_ci	hda_nid_t nid, fg;
7438c2ecf20Sopenharmony_ci	int i, nodes;
7448c2ecf20Sopenharmony_ci
7458c2ecf20Sopenharmony_ci	print_codec_core_info(&codec->core, buffer);
7468c2ecf20Sopenharmony_ci	fg = codec->core.afg;
7478c2ecf20Sopenharmony_ci	if (!fg)
7488c2ecf20Sopenharmony_ci		return;
7498c2ecf20Sopenharmony_ci	snd_hda_power_up(codec);
7508c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "Default PCM:\n");
7518c2ecf20Sopenharmony_ci	print_pcm_caps(buffer, codec, fg);
7528c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "Default Amp-In caps: ");
7538c2ecf20Sopenharmony_ci	print_amp_caps(buffer, codec, fg, HDA_INPUT);
7548c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "Default Amp-Out caps: ");
7558c2ecf20Sopenharmony_ci	print_amp_caps(buffer, codec, fg, HDA_OUTPUT);
7568c2ecf20Sopenharmony_ci	snd_iprintf(buffer, "State of AFG node 0x%02x:\n", fg);
7578c2ecf20Sopenharmony_ci	print_power_state(buffer, codec, fg);
7588c2ecf20Sopenharmony_ci
7598c2ecf20Sopenharmony_ci	nodes = snd_hda_get_sub_nodes(codec, fg, &nid);
7608c2ecf20Sopenharmony_ci	if (! nid || nodes < 0) {
7618c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "Invalid AFG subtree\n");
7628c2ecf20Sopenharmony_ci		snd_hda_power_down(codec);
7638c2ecf20Sopenharmony_ci		return;
7648c2ecf20Sopenharmony_ci	}
7658c2ecf20Sopenharmony_ci
7668c2ecf20Sopenharmony_ci	print_gpio(buffer, codec, fg);
7678c2ecf20Sopenharmony_ci	if (codec->proc_widget_hook)
7688c2ecf20Sopenharmony_ci		codec->proc_widget_hook(buffer, codec, fg);
7698c2ecf20Sopenharmony_ci
7708c2ecf20Sopenharmony_ci	for (i = 0; i < nodes; i++, nid++) {
7718c2ecf20Sopenharmony_ci		unsigned int wid_caps =
7728c2ecf20Sopenharmony_ci			param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP);
7738c2ecf20Sopenharmony_ci		unsigned int wid_type = get_wcaps_type(wid_caps);
7748c2ecf20Sopenharmony_ci		hda_nid_t *conn = NULL;
7758c2ecf20Sopenharmony_ci		int conn_len = 0;
7768c2ecf20Sopenharmony_ci
7778c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid,
7788c2ecf20Sopenharmony_ci			    get_wid_type_name(wid_type), wid_caps);
7798c2ecf20Sopenharmony_ci		if (wid_caps & AC_WCAP_STEREO) {
7808c2ecf20Sopenharmony_ci			unsigned int chans = get_wcaps_channels(wid_caps);
7818c2ecf20Sopenharmony_ci			if (chans == 2)
7828c2ecf20Sopenharmony_ci				snd_iprintf(buffer, " Stereo");
7838c2ecf20Sopenharmony_ci			else
7848c2ecf20Sopenharmony_ci				snd_iprintf(buffer, " %d-Channels", chans);
7858c2ecf20Sopenharmony_ci		} else
7868c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " Mono");
7878c2ecf20Sopenharmony_ci		if (wid_caps & AC_WCAP_DIGITAL)
7888c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " Digital");
7898c2ecf20Sopenharmony_ci		if (wid_caps & AC_WCAP_IN_AMP)
7908c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " Amp-In");
7918c2ecf20Sopenharmony_ci		if (wid_caps & AC_WCAP_OUT_AMP)
7928c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " Amp-Out");
7938c2ecf20Sopenharmony_ci		if (wid_caps & AC_WCAP_STRIPE)
7948c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " Stripe");
7958c2ecf20Sopenharmony_ci		if (wid_caps & AC_WCAP_LR_SWAP)
7968c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " R/L");
7978c2ecf20Sopenharmony_ci		if (wid_caps & AC_WCAP_CP_CAPS)
7988c2ecf20Sopenharmony_ci			snd_iprintf(buffer, " CP");
7998c2ecf20Sopenharmony_ci		snd_iprintf(buffer, "\n");
8008c2ecf20Sopenharmony_ci
8018c2ecf20Sopenharmony_ci		print_nid_array(buffer, codec, nid, &codec->mixers);
8028c2ecf20Sopenharmony_ci		print_nid_array(buffer, codec, nid, &codec->nids);
8038c2ecf20Sopenharmony_ci		print_nid_pcms(buffer, codec, nid);
8048c2ecf20Sopenharmony_ci
8058c2ecf20Sopenharmony_ci		/* volume knob is a special widget that always have connection
8068c2ecf20Sopenharmony_ci		 * list
8078c2ecf20Sopenharmony_ci		 */
8088c2ecf20Sopenharmony_ci		if (wid_type == AC_WID_VOL_KNB)
8098c2ecf20Sopenharmony_ci			wid_caps |= AC_WCAP_CONN_LIST;
8108c2ecf20Sopenharmony_ci
8118c2ecf20Sopenharmony_ci		if (wid_caps & AC_WCAP_CONN_LIST) {
8128c2ecf20Sopenharmony_ci			conn_len = snd_hda_get_num_raw_conns(codec, nid);
8138c2ecf20Sopenharmony_ci			if (conn_len > 0) {
8148c2ecf20Sopenharmony_ci				conn = kmalloc_array(conn_len,
8158c2ecf20Sopenharmony_ci						     sizeof(hda_nid_t),
8168c2ecf20Sopenharmony_ci						     GFP_KERNEL);
8178c2ecf20Sopenharmony_ci				if (!conn)
8188c2ecf20Sopenharmony_ci					return;
8198c2ecf20Sopenharmony_ci				if (snd_hda_get_raw_connections(codec, nid, conn,
8208c2ecf20Sopenharmony_ci								conn_len) < 0)
8218c2ecf20Sopenharmony_ci					conn_len = 0;
8228c2ecf20Sopenharmony_ci			}
8238c2ecf20Sopenharmony_ci		}
8248c2ecf20Sopenharmony_ci
8258c2ecf20Sopenharmony_ci		if (wid_caps & AC_WCAP_IN_AMP) {
8268c2ecf20Sopenharmony_ci			snd_iprintf(buffer, "  Amp-In caps: ");
8278c2ecf20Sopenharmony_ci			print_amp_caps(buffer, codec, nid, HDA_INPUT);
8288c2ecf20Sopenharmony_ci			snd_iprintf(buffer, "  Amp-In vals: ");
8298c2ecf20Sopenharmony_ci			if (wid_type == AC_WID_PIN ||
8308c2ecf20Sopenharmony_ci			    (codec->single_adc_amp &&
8318c2ecf20Sopenharmony_ci			     wid_type == AC_WID_AUD_IN))
8328c2ecf20Sopenharmony_ci				print_amp_vals(buffer, codec, nid, HDA_INPUT,
8338c2ecf20Sopenharmony_ci					       wid_caps, 1);
8348c2ecf20Sopenharmony_ci			else
8358c2ecf20Sopenharmony_ci				print_amp_vals(buffer, codec, nid, HDA_INPUT,
8368c2ecf20Sopenharmony_ci					       wid_caps, conn_len);
8378c2ecf20Sopenharmony_ci		}
8388c2ecf20Sopenharmony_ci		if (wid_caps & AC_WCAP_OUT_AMP) {
8398c2ecf20Sopenharmony_ci			snd_iprintf(buffer, "  Amp-Out caps: ");
8408c2ecf20Sopenharmony_ci			print_amp_caps(buffer, codec, nid, HDA_OUTPUT);
8418c2ecf20Sopenharmony_ci			snd_iprintf(buffer, "  Amp-Out vals: ");
8428c2ecf20Sopenharmony_ci			if (wid_type == AC_WID_PIN &&
8438c2ecf20Sopenharmony_ci			    codec->pin_amp_workaround)
8448c2ecf20Sopenharmony_ci				print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
8458c2ecf20Sopenharmony_ci					       wid_caps, conn_len);
8468c2ecf20Sopenharmony_ci			else
8478c2ecf20Sopenharmony_ci				print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
8488c2ecf20Sopenharmony_ci					       wid_caps, 1);
8498c2ecf20Sopenharmony_ci		}
8508c2ecf20Sopenharmony_ci
8518c2ecf20Sopenharmony_ci		switch (wid_type) {
8528c2ecf20Sopenharmony_ci		case AC_WID_PIN: {
8538c2ecf20Sopenharmony_ci			int supports_vref;
8548c2ecf20Sopenharmony_ci			print_pin_caps(buffer, codec, nid, &supports_vref);
8558c2ecf20Sopenharmony_ci			print_pin_ctls(buffer, codec, nid, supports_vref);
8568c2ecf20Sopenharmony_ci			break;
8578c2ecf20Sopenharmony_ci		}
8588c2ecf20Sopenharmony_ci		case AC_WID_VOL_KNB:
8598c2ecf20Sopenharmony_ci			print_vol_knob(buffer, codec, nid);
8608c2ecf20Sopenharmony_ci			break;
8618c2ecf20Sopenharmony_ci		case AC_WID_AUD_OUT:
8628c2ecf20Sopenharmony_ci		case AC_WID_AUD_IN:
8638c2ecf20Sopenharmony_ci			print_audio_io(buffer, codec, nid, wid_type);
8648c2ecf20Sopenharmony_ci			if (wid_caps & AC_WCAP_DIGITAL)
8658c2ecf20Sopenharmony_ci				print_digital_conv(buffer, codec, nid);
8668c2ecf20Sopenharmony_ci			if (wid_caps & AC_WCAP_FORMAT_OVRD) {
8678c2ecf20Sopenharmony_ci				snd_iprintf(buffer, "  PCM:\n");
8688c2ecf20Sopenharmony_ci				print_pcm_caps(buffer, codec, nid);
8698c2ecf20Sopenharmony_ci			}
8708c2ecf20Sopenharmony_ci			break;
8718c2ecf20Sopenharmony_ci		}
8728c2ecf20Sopenharmony_ci
8738c2ecf20Sopenharmony_ci		if (wid_caps & AC_WCAP_UNSOL_CAP)
8748c2ecf20Sopenharmony_ci			print_unsol_cap(buffer, codec, nid);
8758c2ecf20Sopenharmony_ci
8768c2ecf20Sopenharmony_ci		if (wid_caps & AC_WCAP_POWER)
8778c2ecf20Sopenharmony_ci			print_power_state(buffer, codec, nid);
8788c2ecf20Sopenharmony_ci
8798c2ecf20Sopenharmony_ci		if (wid_caps & AC_WCAP_DELAY)
8808c2ecf20Sopenharmony_ci			snd_iprintf(buffer, "  Delay: %d samples\n",
8818c2ecf20Sopenharmony_ci				    (wid_caps & AC_WCAP_DELAY) >>
8828c2ecf20Sopenharmony_ci				    AC_WCAP_DELAY_SHIFT);
8838c2ecf20Sopenharmony_ci
8848c2ecf20Sopenharmony_ci		if (wid_type == AC_WID_PIN && codec->dp_mst)
8858c2ecf20Sopenharmony_ci			print_device_list(buffer, codec, nid);
8868c2ecf20Sopenharmony_ci
8878c2ecf20Sopenharmony_ci		if (wid_caps & AC_WCAP_CONN_LIST)
8888c2ecf20Sopenharmony_ci			print_conn_list(buffer, codec, nid, wid_type,
8898c2ecf20Sopenharmony_ci					conn, conn_len);
8908c2ecf20Sopenharmony_ci
8918c2ecf20Sopenharmony_ci		if (wid_caps & AC_WCAP_PROC_WID)
8928c2ecf20Sopenharmony_ci			print_proc_caps(buffer, codec, nid);
8938c2ecf20Sopenharmony_ci
8948c2ecf20Sopenharmony_ci		if (codec->proc_widget_hook)
8958c2ecf20Sopenharmony_ci			codec->proc_widget_hook(buffer, codec, nid);
8968c2ecf20Sopenharmony_ci
8978c2ecf20Sopenharmony_ci		kfree(conn);
8988c2ecf20Sopenharmony_ci	}
8998c2ecf20Sopenharmony_ci	snd_hda_power_down(codec);
9008c2ecf20Sopenharmony_ci}
9018c2ecf20Sopenharmony_ci
9028c2ecf20Sopenharmony_ci/*
9038c2ecf20Sopenharmony_ci * create a proc read
9048c2ecf20Sopenharmony_ci */
9058c2ecf20Sopenharmony_ciint snd_hda_codec_proc_new(struct hda_codec *codec)
9068c2ecf20Sopenharmony_ci{
9078c2ecf20Sopenharmony_ci	char name[32];
9088c2ecf20Sopenharmony_ci
9098c2ecf20Sopenharmony_ci	snprintf(name, sizeof(name), "codec#%d", codec->core.addr);
9108c2ecf20Sopenharmony_ci	return snd_card_ro_proc_new(codec->card, name, codec, print_codec_info);
9118c2ecf20Sopenharmony_ci}
9128c2ecf20Sopenharmony_ci
913