xref: /openbmc/linux/sound/pci/hda/hda_local.h (revision cb53c626e1145edf1d619bc4953f6293d3a77ace)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * Universal Interface for Intel High Definition Audio Codec
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  * Local helper functions
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
71da177e4SLinus Torvalds  *
81da177e4SLinus Torvalds  *  This program is free software; you can redistribute it and/or modify it
91da177e4SLinus Torvalds  *  under the terms of the GNU General Public License as published by the Free
101da177e4SLinus Torvalds  *  Software Foundation; either version 2 of the License, or (at your option)
111da177e4SLinus Torvalds  *  any later version.
121da177e4SLinus Torvalds  *
131da177e4SLinus Torvalds  *  This program is distributed in the hope that it will be useful, but WITHOUT
141da177e4SLinus Torvalds  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
151da177e4SLinus Torvalds  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
161da177e4SLinus Torvalds  *  more details.
171da177e4SLinus Torvalds  *
181da177e4SLinus Torvalds  *  You should have received a copy of the GNU General Public License along with
191da177e4SLinus Torvalds  *  this program; if not, write to the Free Software Foundation, Inc., 59
201da177e4SLinus Torvalds  *  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
211da177e4SLinus Torvalds  */
221da177e4SLinus Torvalds 
231da177e4SLinus Torvalds #ifndef __SOUND_HDA_LOCAL_H
241da177e4SLinus Torvalds #define __SOUND_HDA_LOCAL_H
251da177e4SLinus Torvalds 
261da177e4SLinus Torvalds /*
271da177e4SLinus Torvalds  * for mixer controls
281da177e4SLinus Torvalds  */
29d01ce99fSTakashi Iwai #define HDA_COMPOSE_AMP_VAL(nid,chs,idx,dir) \
30d01ce99fSTakashi Iwai 	((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19))
31985be54bSTakashi Iwai /* mono volume with index (index=0,1,...) (channel=1,2) */
321da177e4SLinus Torvalds #define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
331da177e4SLinus Torvalds 	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx,  \
34302e9c5aSJaroslav Kysela 	  .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
35302e9c5aSJaroslav Kysela 	  	    SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
36302e9c5aSJaroslav Kysela 	  	    SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
371da177e4SLinus Torvalds 	  .info = snd_hda_mixer_amp_volume_info, \
381da177e4SLinus Torvalds 	  .get = snd_hda_mixer_amp_volume_get, \
391da177e4SLinus Torvalds 	  .put = snd_hda_mixer_amp_volume_put, \
407cf0a953STakashi Iwai 	  .tlv = { .c = snd_hda_mixer_amp_tlv },		\
411da177e4SLinus Torvalds 	  .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, direction) }
42985be54bSTakashi Iwai /* stereo volume with index */
431da177e4SLinus Torvalds #define HDA_CODEC_VOLUME_IDX(xname, xcidx, nid, xindex, direction) \
441da177e4SLinus Torvalds 	HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, 3, xindex, direction)
45985be54bSTakashi Iwai /* mono volume */
461da177e4SLinus Torvalds #define HDA_CODEC_VOLUME_MONO(xname, nid, channel, xindex, direction) \
471da177e4SLinus Torvalds 	HDA_CODEC_VOLUME_MONO_IDX(xname, 0, nid, channel, xindex, direction)
48985be54bSTakashi Iwai /* stereo volume */
491da177e4SLinus Torvalds #define HDA_CODEC_VOLUME(xname, nid, xindex, direction) \
501da177e4SLinus Torvalds 	HDA_CODEC_VOLUME_MONO(xname, nid, 3, xindex, direction)
51985be54bSTakashi Iwai /* mono mute switch with index (index=0,1,...) (channel=1,2) */
521da177e4SLinus Torvalds #define HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
531da177e4SLinus Torvalds 	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \
541da177e4SLinus Torvalds 	  .info = snd_hda_mixer_amp_switch_info, \
551da177e4SLinus Torvalds 	  .get = snd_hda_mixer_amp_switch_get, \
561da177e4SLinus Torvalds 	  .put = snd_hda_mixer_amp_switch_put, \
571da177e4SLinus Torvalds 	  .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, direction) }
58985be54bSTakashi Iwai /* stereo mute switch with index */
591da177e4SLinus Torvalds #define HDA_CODEC_MUTE_IDX(xname, xcidx, nid, xindex, direction) \
601da177e4SLinus Torvalds 	HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, 3, xindex, direction)
61985be54bSTakashi Iwai /* mono mute switch */
621da177e4SLinus Torvalds #define HDA_CODEC_MUTE_MONO(xname, nid, channel, xindex, direction) \
631da177e4SLinus Torvalds 	HDA_CODEC_MUTE_MONO_IDX(xname, 0, nid, channel, xindex, direction)
64985be54bSTakashi Iwai /* stereo mute switch */
651da177e4SLinus Torvalds #define HDA_CODEC_MUTE(xname, nid, xindex, direction) \
661da177e4SLinus Torvalds 	HDA_CODEC_MUTE_MONO(xname, nid, 3, xindex, direction)
671da177e4SLinus Torvalds 
68d01ce99fSTakashi Iwai int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
69d01ce99fSTakashi Iwai 				  struct snd_ctl_elem_info *uinfo);
70d01ce99fSTakashi Iwai int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
71d01ce99fSTakashi Iwai 				 struct snd_ctl_elem_value *ucontrol);
72d01ce99fSTakashi Iwai int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
73d01ce99fSTakashi Iwai 				 struct snd_ctl_elem_value *ucontrol);
74d01ce99fSTakashi Iwai int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
75d01ce99fSTakashi Iwai 			  unsigned int size, unsigned int __user *tlv);
76d01ce99fSTakashi Iwai int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol,
77d01ce99fSTakashi Iwai 				  struct snd_ctl_elem_info *uinfo);
78d01ce99fSTakashi Iwai int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
79d01ce99fSTakashi Iwai 				 struct snd_ctl_elem_value *ucontrol);
80d01ce99fSTakashi Iwai int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
81d01ce99fSTakashi Iwai 				 struct snd_ctl_elem_value *ucontrol);
82834be88dSTakashi Iwai /* lowlevel accessor with caching; use carefully */
83834be88dSTakashi Iwai int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch,
84834be88dSTakashi Iwai 			   int direction, int index);
85834be88dSTakashi Iwai int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
86834be88dSTakashi Iwai 			     int direction, int idx, int mask, int val);
8747fd830aSTakashi Iwai int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid,
8847fd830aSTakashi Iwai 			     int dir, int idx, int mask, int val);
89*cb53c626STakashi Iwai #ifdef SND_HDA_NEEDS_RESUME
90b3ac5636STakashi Iwai void snd_hda_codec_resume_amp(struct hda_codec *codec);
9182beb8fdSTakashi Iwai #endif
921da177e4SLinus Torvalds 
9347fd830aSTakashi Iwai /* amp value bits */
9447fd830aSTakashi Iwai #define HDA_AMP_MUTE	0x80
9547fd830aSTakashi Iwai #define HDA_AMP_UNMUTE	0x00
9647fd830aSTakashi Iwai #define HDA_AMP_VOLMASK	0x7f
9747fd830aSTakashi Iwai 
98985be54bSTakashi Iwai /* mono switch binding multiple inputs */
99985be54bSTakashi Iwai #define HDA_BIND_MUTE_MONO(xname, nid, channel, indices, direction) \
100985be54bSTakashi Iwai 	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
101985be54bSTakashi Iwai 	  .info = snd_hda_mixer_amp_switch_info, \
102985be54bSTakashi Iwai 	  .get = snd_hda_mixer_bind_switch_get, \
103985be54bSTakashi Iwai 	  .put = snd_hda_mixer_bind_switch_put, \
104985be54bSTakashi Iwai 	  .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) }
105985be54bSTakashi Iwai 
106985be54bSTakashi Iwai /* stereo switch binding multiple inputs */
107d01ce99fSTakashi Iwai #define HDA_BIND_MUTE(xname,nid,indices,dir) \
108d01ce99fSTakashi Iwai 	HDA_BIND_MUTE_MONO(xname,nid,3,indices,dir)
109985be54bSTakashi Iwai 
110d01ce99fSTakashi Iwai int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol,
111d01ce99fSTakashi Iwai 				  struct snd_ctl_elem_value *ucontrol);
112d01ce99fSTakashi Iwai int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol,
113d01ce99fSTakashi Iwai 				  struct snd_ctl_elem_value *ucontrol);
114985be54bSTakashi Iwai 
115532d5381STakashi Iwai /* more generic bound controls */
116532d5381STakashi Iwai struct hda_ctl_ops {
117532d5381STakashi Iwai 	snd_kcontrol_info_t *info;
118532d5381STakashi Iwai 	snd_kcontrol_get_t *get;
119532d5381STakashi Iwai 	snd_kcontrol_put_t *put;
120532d5381STakashi Iwai 	snd_kcontrol_tlv_rw_t *tlv;
121532d5381STakashi Iwai };
122532d5381STakashi Iwai 
123532d5381STakashi Iwai extern struct hda_ctl_ops snd_hda_bind_vol;	/* for bind-volume with TLV */
124532d5381STakashi Iwai extern struct hda_ctl_ops snd_hda_bind_sw;	/* for bind-switch */
125532d5381STakashi Iwai 
126532d5381STakashi Iwai struct hda_bind_ctls {
127532d5381STakashi Iwai 	struct hda_ctl_ops *ops;
128532d5381STakashi Iwai 	long values[];
129532d5381STakashi Iwai };
130532d5381STakashi Iwai 
131532d5381STakashi Iwai int snd_hda_mixer_bind_ctls_info(struct snd_kcontrol *kcontrol,
132532d5381STakashi Iwai 				 struct snd_ctl_elem_info *uinfo);
133532d5381STakashi Iwai int snd_hda_mixer_bind_ctls_get(struct snd_kcontrol *kcontrol,
134532d5381STakashi Iwai 				struct snd_ctl_elem_value *ucontrol);
135532d5381STakashi Iwai int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol,
136532d5381STakashi Iwai 				struct snd_ctl_elem_value *ucontrol);
137532d5381STakashi Iwai int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag,
138532d5381STakashi Iwai 			   unsigned int size, unsigned int __user *tlv);
139532d5381STakashi Iwai 
140532d5381STakashi Iwai #define HDA_BIND_VOL(xname, bindrec) \
141532d5381STakashi Iwai 	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
142532d5381STakashi Iwai 	  .name = xname, \
143532d5381STakashi Iwai 	  .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |\
144532d5381STakashi Iwai 			  SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
145532d5381STakashi Iwai 			  SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK,\
146532d5381STakashi Iwai 	  .info = snd_hda_mixer_bind_ctls_info,\
147532d5381STakashi Iwai 	  .get =  snd_hda_mixer_bind_ctls_get,\
148532d5381STakashi Iwai 	  .put = snd_hda_mixer_bind_ctls_put,\
149532d5381STakashi Iwai 	  .tlv = { .c = snd_hda_mixer_bind_tlv },\
150532d5381STakashi Iwai 	  .private_value = (long) (bindrec) }
151532d5381STakashi Iwai #define HDA_BIND_SW(xname, bindrec) \
152532d5381STakashi Iwai 	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,\
153532d5381STakashi Iwai 	  .name = xname, \
154532d5381STakashi Iwai 	  .info = snd_hda_mixer_bind_ctls_info,\
155532d5381STakashi Iwai 	  .get =  snd_hda_mixer_bind_ctls_get,\
156532d5381STakashi Iwai 	  .put = snd_hda_mixer_bind_ctls_put,\
157532d5381STakashi Iwai 	  .private_value = (long) (bindrec) }
158532d5381STakashi Iwai 
159532d5381STakashi Iwai /*
160532d5381STakashi Iwai  * SPDIF I/O
161532d5381STakashi Iwai  */
1621da177e4SLinus Torvalds int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid);
1631da177e4SLinus Torvalds int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid);
1641da177e4SLinus Torvalds 
1651da177e4SLinus Torvalds /*
1661da177e4SLinus Torvalds  * input MUX helper
1671da177e4SLinus Torvalds  */
16854d17403STakashi Iwai #define HDA_MAX_NUM_INPUTS	16
1691da177e4SLinus Torvalds struct hda_input_mux_item {
1701da177e4SLinus Torvalds 	const char *label;
1711da177e4SLinus Torvalds 	unsigned int index;
1721da177e4SLinus Torvalds };
1731da177e4SLinus Torvalds struct hda_input_mux {
1741da177e4SLinus Torvalds 	unsigned int num_items;
1751da177e4SLinus Torvalds 	struct hda_input_mux_item items[HDA_MAX_NUM_INPUTS];
1761da177e4SLinus Torvalds };
1771da177e4SLinus Torvalds 
178d01ce99fSTakashi Iwai int snd_hda_input_mux_info(const struct hda_input_mux *imux,
179d01ce99fSTakashi Iwai 			   struct snd_ctl_elem_info *uinfo);
180d01ce99fSTakashi Iwai int snd_hda_input_mux_put(struct hda_codec *codec,
181d01ce99fSTakashi Iwai 			  const struct hda_input_mux *imux,
182c8b6bf9bSTakashi Iwai 			  struct snd_ctl_elem_value *ucontrol, hda_nid_t nid,
1831da177e4SLinus Torvalds 			  unsigned int *cur_val);
1841da177e4SLinus Torvalds 
185d2a6d7dcSTakashi Iwai /*
186d2a6d7dcSTakashi Iwai  * Channel mode helper
187d2a6d7dcSTakashi Iwai  */
188d2a6d7dcSTakashi Iwai struct hda_channel_mode {
189d2a6d7dcSTakashi Iwai 	int channels;
190d2a6d7dcSTakashi Iwai 	const struct hda_verb *sequence;
191d2a6d7dcSTakashi Iwai };
192d2a6d7dcSTakashi Iwai 
193d01ce99fSTakashi Iwai int snd_hda_ch_mode_info(struct hda_codec *codec,
194d01ce99fSTakashi Iwai 			 struct snd_ctl_elem_info *uinfo,
195d01ce99fSTakashi Iwai 			 const struct hda_channel_mode *chmode,
196d01ce99fSTakashi Iwai 			 int num_chmodes);
197d01ce99fSTakashi Iwai int snd_hda_ch_mode_get(struct hda_codec *codec,
198d01ce99fSTakashi Iwai 			struct snd_ctl_elem_value *ucontrol,
199d01ce99fSTakashi Iwai 			const struct hda_channel_mode *chmode,
200d01ce99fSTakashi Iwai 			int num_chmodes,
201d2a6d7dcSTakashi Iwai 			int max_channels);
202d01ce99fSTakashi Iwai int snd_hda_ch_mode_put(struct hda_codec *codec,
203d01ce99fSTakashi Iwai 			struct snd_ctl_elem_value *ucontrol,
204d01ce99fSTakashi Iwai 			const struct hda_channel_mode *chmode,
205d01ce99fSTakashi Iwai 			int num_chmodes,
206d2a6d7dcSTakashi Iwai 			int *max_channelsp);
207d2a6d7dcSTakashi Iwai 
2081da177e4SLinus Torvalds /*
2091da177e4SLinus Torvalds  * Multi-channel / digital-out PCM helper
2101da177e4SLinus Torvalds  */
2111da177e4SLinus Torvalds 
2121da177e4SLinus Torvalds enum { HDA_FRONT, HDA_REAR, HDA_CLFE, HDA_SIDE }; /* index for dac_nidx */
2131da177e4SLinus Torvalds enum { HDA_DIG_NONE, HDA_DIG_EXCLUSIVE, HDA_DIG_ANALOG_DUP }; /* dig_out_used */
2141da177e4SLinus Torvalds 
2151da177e4SLinus Torvalds struct hda_multi_out {
2161da177e4SLinus Torvalds 	int num_dacs;		/* # of DACs, must be more than 1 */
2171da177e4SLinus Torvalds 	hda_nid_t *dac_nids;	/* DAC list */
2181da177e4SLinus Torvalds 	hda_nid_t hp_nid;	/* optional DAC for HP, 0 when not exists */
21982bc955fSTakashi Iwai 	hda_nid_t extra_out_nid[3];	/* optional DACs, 0 when not exists */
2201da177e4SLinus Torvalds 	hda_nid_t dig_out_nid;	/* digital out audio widget */
2211da177e4SLinus Torvalds 	int max_channels;	/* currently supported analog channels */
2221da177e4SLinus Torvalds 	int dig_out_used;	/* current usage of digital out (HDA_DIG_XXX) */
2231da177e4SLinus Torvalds };
2241da177e4SLinus Torvalds 
225d01ce99fSTakashi Iwai int snd_hda_multi_out_dig_open(struct hda_codec *codec,
226d01ce99fSTakashi Iwai 			       struct hda_multi_out *mout);
227d01ce99fSTakashi Iwai int snd_hda_multi_out_dig_close(struct hda_codec *codec,
228d01ce99fSTakashi Iwai 				struct hda_multi_out *mout);
2296b97eb45STakashi Iwai int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
2306b97eb45STakashi Iwai 				  struct hda_multi_out *mout,
2316b97eb45STakashi Iwai 				  unsigned int stream_tag,
2326b97eb45STakashi Iwai 				  unsigned int format,
2336b97eb45STakashi Iwai 				  struct snd_pcm_substream *substream);
234d01ce99fSTakashi Iwai int snd_hda_multi_out_analog_open(struct hda_codec *codec,
235d01ce99fSTakashi Iwai 				  struct hda_multi_out *mout,
236c8b6bf9bSTakashi Iwai 				  struct snd_pcm_substream *substream);
237d01ce99fSTakashi Iwai int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
238d01ce99fSTakashi Iwai 				     struct hda_multi_out *mout,
2391da177e4SLinus Torvalds 				     unsigned int stream_tag,
2401da177e4SLinus Torvalds 				     unsigned int format,
241c8b6bf9bSTakashi Iwai 				     struct snd_pcm_substream *substream);
242d01ce99fSTakashi Iwai int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,
243d01ce99fSTakashi Iwai 				     struct hda_multi_out *mout);
2441da177e4SLinus Torvalds 
2451da177e4SLinus Torvalds /*
2461da177e4SLinus Torvalds  * generic codec parser
2471da177e4SLinus Torvalds  */
2481da177e4SLinus Torvalds int snd_hda_parse_generic_codec(struct hda_codec *codec);
2491da177e4SLinus Torvalds 
2501da177e4SLinus Torvalds /*
2511da177e4SLinus Torvalds  * generic proc interface
2521da177e4SLinus Torvalds  */
2531da177e4SLinus Torvalds #ifdef CONFIG_PROC_FS
2541da177e4SLinus Torvalds int snd_hda_codec_proc_new(struct hda_codec *codec);
2551da177e4SLinus Torvalds #else
2561da177e4SLinus Torvalds static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; }
2571da177e4SLinus Torvalds #endif
2581da177e4SLinus Torvalds 
2591da177e4SLinus Torvalds /*
2601da177e4SLinus Torvalds  * Misc
2611da177e4SLinus Torvalds  */
262f5fcc13cSTakashi Iwai int snd_hda_check_board_config(struct hda_codec *codec, int num_configs,
263f5fcc13cSTakashi Iwai 			       const char **modelnames,
264f5fcc13cSTakashi Iwai 			       const struct snd_pci_quirk *pci_list);
265d01ce99fSTakashi Iwai int snd_hda_add_new_ctls(struct hda_codec *codec,
266d01ce99fSTakashi Iwai 			 struct snd_kcontrol_new *knew);
2671da177e4SLinus Torvalds 
2681da177e4SLinus Torvalds /*
2691da177e4SLinus Torvalds  * unsolicited event handler
2701da177e4SLinus Torvalds  */
2711da177e4SLinus Torvalds 
2721da177e4SLinus Torvalds #define HDA_UNSOL_QUEUE_SIZE	64
2731da177e4SLinus Torvalds 
2741da177e4SLinus Torvalds struct hda_bus_unsolicited {
2751da177e4SLinus Torvalds 	/* ring buffer */
2761da177e4SLinus Torvalds 	u32 queue[HDA_UNSOL_QUEUE_SIZE * 2];
2771da177e4SLinus Torvalds 	unsigned int rp, wp;
2781da177e4SLinus Torvalds 
2791da177e4SLinus Torvalds 	/* workqueue */
2801da177e4SLinus Torvalds 	struct work_struct work;
281c4028958SDavid Howells 	struct hda_bus *bus;
2821da177e4SLinus Torvalds };
2831da177e4SLinus Torvalds 
284e9edcee0STakashi Iwai /*
285e9edcee0STakashi Iwai  * Helper for automatic ping configuration
286e9edcee0STakashi Iwai  */
287e9edcee0STakashi Iwai 
288e9edcee0STakashi Iwai enum {
289e9edcee0STakashi Iwai 	AUTO_PIN_MIC,
290e9edcee0STakashi Iwai 	AUTO_PIN_FRONT_MIC,
291e9edcee0STakashi Iwai 	AUTO_PIN_LINE,
292e9edcee0STakashi Iwai 	AUTO_PIN_FRONT_LINE,
293e9edcee0STakashi Iwai 	AUTO_PIN_CD,
294e9edcee0STakashi Iwai 	AUTO_PIN_AUX,
295e9edcee0STakashi Iwai 	AUTO_PIN_LAST
296e9edcee0STakashi Iwai };
297e9edcee0STakashi Iwai 
298d258e24aSTakashi Iwai enum {
299d258e24aSTakashi Iwai 	AUTO_PIN_LINE_OUT,
300d258e24aSTakashi Iwai 	AUTO_PIN_SPEAKER_OUT,
301d258e24aSTakashi Iwai 	AUTO_PIN_HP_OUT
302d258e24aSTakashi Iwai };
303d258e24aSTakashi Iwai 
3044a471b7dSTakashi Iwai extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST];
3054a471b7dSTakashi Iwai 
306e9edcee0STakashi Iwai struct auto_pin_cfg {
307e9edcee0STakashi Iwai 	int line_outs;
308d01ce99fSTakashi Iwai 	hda_nid_t line_out_pins[5]; /* sorted in the order of
309d01ce99fSTakashi Iwai 				     * Front/Surr/CLFE/Side
310d01ce99fSTakashi Iwai 				     */
31182bc955fSTakashi Iwai 	int speaker_outs;
31282bc955fSTakashi Iwai 	hda_nid_t speaker_pins[5];
313eb06ed8fSTakashi Iwai 	int hp_outs;
314d258e24aSTakashi Iwai 	int line_out_type;	/* AUTO_PIN_XXX_OUT */
315eb06ed8fSTakashi Iwai 	hda_nid_t hp_pins[5];
316e9edcee0STakashi Iwai 	hda_nid_t input_pins[AUTO_PIN_LAST];
317e9edcee0STakashi Iwai 	hda_nid_t dig_out_pin;
318e9edcee0STakashi Iwai 	hda_nid_t dig_in_pin;
319e9edcee0STakashi Iwai };
320e9edcee0STakashi Iwai 
321d01ce99fSTakashi Iwai #define get_defcfg_connect(cfg) \
322d01ce99fSTakashi Iwai 	((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT)
323d01ce99fSTakashi Iwai #define get_defcfg_association(cfg) \
324d01ce99fSTakashi Iwai 	((cfg & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT)
325d01ce99fSTakashi Iwai #define get_defcfg_location(cfg) \
326d01ce99fSTakashi Iwai 	((cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT)
327d01ce99fSTakashi Iwai #define get_defcfg_sequence(cfg) \
328d01ce99fSTakashi Iwai 	(cfg & AC_DEFCFG_SEQUENCE)
329d01ce99fSTakashi Iwai #define get_defcfg_device(cfg) \
330d01ce99fSTakashi Iwai 	((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT)
331e9edcee0STakashi Iwai 
332d01ce99fSTakashi Iwai int snd_hda_parse_pin_def_config(struct hda_codec *codec,
333d01ce99fSTakashi Iwai 				 struct auto_pin_cfg *cfg,
334df694daaSKailang Yang 				 hda_nid_t *ignore_nids);
335e9edcee0STakashi Iwai 
3368d88bc3dSTakashi Iwai /* amp values */
3378d88bc3dSTakashi Iwai #define AMP_IN_MUTE(idx)	(0x7080 | ((idx)<<8))
3388d88bc3dSTakashi Iwai #define AMP_IN_UNMUTE(idx)	(0x7000 | ((idx)<<8))
3398d88bc3dSTakashi Iwai #define AMP_OUT_MUTE	0xb080
3408d88bc3dSTakashi Iwai #define AMP_OUT_UNMUTE	0xb000
3418d88bc3dSTakashi Iwai #define AMP_OUT_ZERO	0xb000
3428d88bc3dSTakashi Iwai /* pinctl values */
3438d88bc3dSTakashi Iwai #define PIN_IN		0x20
3448d88bc3dSTakashi Iwai #define PIN_VREF80	0x24
3458d88bc3dSTakashi Iwai #define PIN_VREF50	0x21
3468d88bc3dSTakashi Iwai #define PIN_OUT		0x40
3478d88bc3dSTakashi Iwai #define PIN_HP		0xc0
3488d88bc3dSTakashi Iwai #define PIN_HP_AMP	0x80
3498d88bc3dSTakashi Iwai 
35054d17403STakashi Iwai /*
35154d17403STakashi Iwai  * get widget capabilities
35254d17403STakashi Iwai  */
35354d17403STakashi Iwai static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
35454d17403STakashi Iwai {
35554d17403STakashi Iwai 	if (nid < codec->start_nid ||
35654d17403STakashi Iwai 	    nid >= codec->start_nid + codec->num_nodes)
35754d17403STakashi Iwai 		return snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP);
35854d17403STakashi Iwai 	return codec->wcaps[nid - codec->start_nid];
35954d17403STakashi Iwai }
36054d17403STakashi Iwai 
361897cc188STakashi Iwai int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
362897cc188STakashi Iwai 			      unsigned int caps);
36354d17403STakashi Iwai 
3642807314dSTakashi Iwai /*
3652807314dSTakashi Iwai  * hwdep interface
3662807314dSTakashi Iwai  */
3672807314dSTakashi Iwai int snd_hda_create_hwdep(struct hda_codec *codec);
3682807314dSTakashi Iwai 
369*cb53c626STakashi Iwai /*
370*cb53c626STakashi Iwai  * power-management
371*cb53c626STakashi Iwai  */
372*cb53c626STakashi Iwai 
373*cb53c626STakashi Iwai #ifdef CONFIG_SND_HDA_POWER_SAVE
374*cb53c626STakashi Iwai void snd_hda_schedule_power_save(struct hda_codec *codec);
375*cb53c626STakashi Iwai 
376*cb53c626STakashi Iwai struct hda_amp_list {
377*cb53c626STakashi Iwai 	hda_nid_t nid;
378*cb53c626STakashi Iwai 	unsigned char dir;
379*cb53c626STakashi Iwai 	unsigned char idx;
380*cb53c626STakashi Iwai };
381*cb53c626STakashi Iwai 
382*cb53c626STakashi Iwai struct hda_loopback_check {
383*cb53c626STakashi Iwai 	struct hda_amp_list *amplist;
384*cb53c626STakashi Iwai 	int power_on;
385*cb53c626STakashi Iwai };
386*cb53c626STakashi Iwai 
387*cb53c626STakashi Iwai int snd_hda_check_amp_list_power(struct hda_codec *codec,
388*cb53c626STakashi Iwai 				 struct hda_loopback_check *check,
389*cb53c626STakashi Iwai 				 hda_nid_t nid);
390*cb53c626STakashi Iwai #endif /* CONFIG_SND_HDA_POWER_SAVE */
391*cb53c626STakashi Iwai 
3921da177e4SLinus Torvalds #endif /* __SOUND_HDA_LOCAL_H */
393