xref: /openbmc/linux/sound/pci/hda/hda_local.h (revision 14bc52b8feaae6cbc88934399f418125ac176399)
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 
269c96fa59STakashi Iwai /* We abuse kcontrol_new.subdev field to pass the NID corresponding to
279c96fa59STakashi Iwai  * the given new control.  If id.subdev has a bit flag HDA_SUBDEV_NID_FLAG,
289c96fa59STakashi Iwai  * snd_hda_ctl_add() takes the lower-bit subdev value as a valid NID.
299c96fa59STakashi Iwai  *
309c96fa59STakashi Iwai  * Note that the subdevice field is cleared again before the real registration
319c96fa59STakashi Iwai  * in snd_hda_ctl_add(), so that this value won't appear in the outside.
329c96fa59STakashi Iwai  */
339c96fa59STakashi Iwai #define HDA_SUBDEV_NID_FLAG	(1U << 31)
349e3fd871SJaroslav Kysela #define HDA_SUBDEV_AMP_FLAG	(1U << 30)
359c96fa59STakashi Iwai 
361da177e4SLinus Torvalds /*
371da177e4SLinus Torvalds  * for mixer controls
381da177e4SLinus Torvalds  */
3929fdbec2STakashi Iwai #define HDA_COMPOSE_AMP_VAL_OFS(nid,chs,idx,dir,ofs)		\
4029fdbec2STakashi Iwai 	((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19) | ((ofs)<<23))
41de8c85f7SClemens Ladisch #define HDA_AMP_VAL_MIN_MUTE (1<<29)
42d01ce99fSTakashi Iwai #define HDA_COMPOSE_AMP_VAL(nid,chs,idx,dir) \
4329fdbec2STakashi Iwai 	HDA_COMPOSE_AMP_VAL_OFS(nid, chs, idx, dir, 0)
44985be54bSTakashi Iwai /* mono volume with index (index=0,1,...) (channel=1,2) */
45de8c85f7SClemens Ladisch #define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, dir, flags) \
461da177e4SLinus Torvalds 	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx,  \
475e26dfd0SJaroslav Kysela 	  .subdevice = HDA_SUBDEV_AMP_FLAG, \
48302e9c5aSJaroslav Kysela 	  .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
49302e9c5aSJaroslav Kysela 	  	    SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
50302e9c5aSJaroslav Kysela 	  	    SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
511da177e4SLinus Torvalds 	  .info = snd_hda_mixer_amp_volume_info, \
521da177e4SLinus Torvalds 	  .get = snd_hda_mixer_amp_volume_get, \
531da177e4SLinus Torvalds 	  .put = snd_hda_mixer_amp_volume_put, \
547cf0a953STakashi Iwai 	  .tlv = { .c = snd_hda_mixer_amp_tlv },		\
55de8c85f7SClemens Ladisch 	  .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, dir) | flags }
56985be54bSTakashi Iwai /* stereo volume with index */
571da177e4SLinus Torvalds #define HDA_CODEC_VOLUME_IDX(xname, xcidx, nid, xindex, direction) \
58de8c85f7SClemens Ladisch 	HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, 3, xindex, direction, 0)
59985be54bSTakashi Iwai /* mono volume */
601da177e4SLinus Torvalds #define HDA_CODEC_VOLUME_MONO(xname, nid, channel, xindex, direction) \
61de8c85f7SClemens Ladisch 	HDA_CODEC_VOLUME_MONO_IDX(xname, 0, nid, channel, xindex, direction, 0)
62985be54bSTakashi Iwai /* stereo volume */
631da177e4SLinus Torvalds #define HDA_CODEC_VOLUME(xname, nid, xindex, direction) \
641da177e4SLinus Torvalds 	HDA_CODEC_VOLUME_MONO(xname, nid, 3, xindex, direction)
65de8c85f7SClemens Ladisch /* stereo volume with min=mute */
66de8c85f7SClemens Ladisch #define HDA_CODEC_VOLUME_MIN_MUTE(xname, nid, xindex, direction) \
67de8c85f7SClemens Ladisch 	HDA_CODEC_VOLUME_MONO_IDX(xname, 0, nid, 3, xindex, direction, \
68de8c85f7SClemens Ladisch 				  HDA_AMP_VAL_MIN_MUTE)
69985be54bSTakashi Iwai /* mono mute switch with index (index=0,1,...) (channel=1,2) */
701da177e4SLinus Torvalds #define HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
711da177e4SLinus Torvalds 	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \
725e26dfd0SJaroslav Kysela 	  .subdevice = HDA_SUBDEV_AMP_FLAG, \
731da177e4SLinus Torvalds 	  .info = snd_hda_mixer_amp_switch_info, \
741da177e4SLinus Torvalds 	  .get = snd_hda_mixer_amp_switch_get, \
751da177e4SLinus Torvalds 	  .put = snd_hda_mixer_amp_switch_put, \
761da177e4SLinus Torvalds 	  .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, direction) }
77985be54bSTakashi Iwai /* stereo mute switch with index */
781da177e4SLinus Torvalds #define HDA_CODEC_MUTE_IDX(xname, xcidx, nid, xindex, direction) \
791da177e4SLinus Torvalds 	HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, 3, xindex, direction)
80985be54bSTakashi Iwai /* mono mute switch */
811da177e4SLinus Torvalds #define HDA_CODEC_MUTE_MONO(xname, nid, channel, xindex, direction) \
821da177e4SLinus Torvalds 	HDA_CODEC_MUTE_MONO_IDX(xname, 0, nid, channel, xindex, direction)
83985be54bSTakashi Iwai /* stereo mute switch */
841da177e4SLinus Torvalds #define HDA_CODEC_MUTE(xname, nid, xindex, direction) \
851da177e4SLinus Torvalds 	HDA_CODEC_MUTE_MONO(xname, nid, 3, xindex, direction)
8667d634c0STakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP
87123c07aeSJaroslav Kysela /* special beep mono mute switch with index (index=0,1,...) (channel=1,2) */
88123c07aeSJaroslav Kysela #define HDA_CODEC_MUTE_BEEP_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
89123c07aeSJaroslav Kysela 	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \
905e26dfd0SJaroslav Kysela 	  .subdevice = HDA_SUBDEV_AMP_FLAG, \
91123c07aeSJaroslav Kysela 	  .info = snd_hda_mixer_amp_switch_info, \
92123c07aeSJaroslav Kysela 	  .get = snd_hda_mixer_amp_switch_get, \
93123c07aeSJaroslav Kysela 	  .put = snd_hda_mixer_amp_switch_put_beep, \
94123c07aeSJaroslav Kysela 	  .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, direction) }
9567d634c0STakashi Iwai #else
9667d634c0STakashi Iwai /* no digital beep - just the standard one */
9767d634c0STakashi Iwai #define HDA_CODEC_MUTE_BEEP_MONO_IDX(xname, xcidx, nid, ch, xidx, dir) \
9867d634c0STakashi Iwai 	HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, ch, xidx, dir)
9967d634c0STakashi Iwai #endif /* CONFIG_SND_HDA_INPUT_BEEP */
100123c07aeSJaroslav Kysela /* special beep mono mute switch */
101123c07aeSJaroslav Kysela #define HDA_CODEC_MUTE_BEEP_MONO(xname, nid, channel, xindex, direction) \
102123c07aeSJaroslav Kysela 	HDA_CODEC_MUTE_BEEP_MONO_IDX(xname, 0, nid, channel, xindex, direction)
103123c07aeSJaroslav Kysela /* special beep stereo mute switch */
104123c07aeSJaroslav Kysela #define HDA_CODEC_MUTE_BEEP(xname, nid, xindex, direction) \
105123c07aeSJaroslav Kysela 	HDA_CODEC_MUTE_BEEP_MONO(xname, nid, 3, xindex, direction)
1061da177e4SLinus Torvalds 
10785dd662fSJaroslav Kysela extern const char *snd_hda_pcm_type_name[];
10885dd662fSJaroslav Kysela 
109d01ce99fSTakashi Iwai int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
110d01ce99fSTakashi Iwai 				  struct snd_ctl_elem_info *uinfo);
111d01ce99fSTakashi Iwai int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
112d01ce99fSTakashi Iwai 				 struct snd_ctl_elem_value *ucontrol);
113d01ce99fSTakashi Iwai int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
114d01ce99fSTakashi Iwai 				 struct snd_ctl_elem_value *ucontrol);
115d01ce99fSTakashi Iwai int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
116d01ce99fSTakashi Iwai 			  unsigned int size, unsigned int __user *tlv);
117d01ce99fSTakashi Iwai int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol,
118d01ce99fSTakashi Iwai 				  struct snd_ctl_elem_info *uinfo);
119d01ce99fSTakashi Iwai int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
120d01ce99fSTakashi Iwai 				 struct snd_ctl_elem_value *ucontrol);
121d01ce99fSTakashi Iwai int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
122d01ce99fSTakashi Iwai 				 struct snd_ctl_elem_value *ucontrol);
12367d634c0STakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_BEEP
124123c07aeSJaroslav Kysela int snd_hda_mixer_amp_switch_put_beep(struct snd_kcontrol *kcontrol,
125123c07aeSJaroslav Kysela 				      struct snd_ctl_elem_value *ucontrol);
12667d634c0STakashi Iwai #endif
127834be88dSTakashi Iwai /* lowlevel accessor with caching; use carefully */
128834be88dSTakashi Iwai int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch,
129834be88dSTakashi Iwai 			   int direction, int index);
130834be88dSTakashi Iwai int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
131834be88dSTakashi Iwai 			     int direction, int idx, int mask, int val);
13247fd830aSTakashi Iwai int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid,
13347fd830aSTakashi Iwai 			     int dir, int idx, int mask, int val);
1342a43952aSTakashi Iwai #ifdef CONFIG_PM
135b3ac5636STakashi Iwai void snd_hda_codec_resume_amp(struct hda_codec *codec);
13682beb8fdSTakashi Iwai #endif
1371da177e4SLinus Torvalds 
1382134ea4fSTakashi Iwai void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir,
1392134ea4fSTakashi Iwai 			     unsigned int *tlv);
1402134ea4fSTakashi Iwai struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
1412134ea4fSTakashi Iwai 					    const char *name);
1422134ea4fSTakashi Iwai int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
143ea734963STakashi Iwai 			unsigned int *tlv, const char * const *slaves);
144a65d629cSTakashi Iwai int snd_hda_codec_reset(struct hda_codec *codec);
1452134ea4fSTakashi Iwai 
14647fd830aSTakashi Iwai /* amp value bits */
14747fd830aSTakashi Iwai #define HDA_AMP_MUTE	0x80
14847fd830aSTakashi Iwai #define HDA_AMP_UNMUTE	0x00
14947fd830aSTakashi Iwai #define HDA_AMP_VOLMASK	0x7f
15047fd830aSTakashi Iwai 
151985be54bSTakashi Iwai /* mono switch binding multiple inputs */
152985be54bSTakashi Iwai #define HDA_BIND_MUTE_MONO(xname, nid, channel, indices, direction) \
153985be54bSTakashi Iwai 	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
154985be54bSTakashi Iwai 	  .info = snd_hda_mixer_amp_switch_info, \
155985be54bSTakashi Iwai 	  .get = snd_hda_mixer_bind_switch_get, \
156985be54bSTakashi Iwai 	  .put = snd_hda_mixer_bind_switch_put, \
157985be54bSTakashi Iwai 	  .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) }
158985be54bSTakashi Iwai 
159985be54bSTakashi Iwai /* stereo switch binding multiple inputs */
160d01ce99fSTakashi Iwai #define HDA_BIND_MUTE(xname,nid,indices,dir) \
161d01ce99fSTakashi Iwai 	HDA_BIND_MUTE_MONO(xname,nid,3,indices,dir)
162985be54bSTakashi Iwai 
163d01ce99fSTakashi Iwai int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol,
164d01ce99fSTakashi Iwai 				  struct snd_ctl_elem_value *ucontrol);
165d01ce99fSTakashi Iwai int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol,
166d01ce99fSTakashi Iwai 				  struct snd_ctl_elem_value *ucontrol);
167985be54bSTakashi Iwai 
168532d5381STakashi Iwai /* more generic bound controls */
169532d5381STakashi Iwai struct hda_ctl_ops {
170532d5381STakashi Iwai 	snd_kcontrol_info_t *info;
171532d5381STakashi Iwai 	snd_kcontrol_get_t *get;
172532d5381STakashi Iwai 	snd_kcontrol_put_t *put;
173532d5381STakashi Iwai 	snd_kcontrol_tlv_rw_t *tlv;
174532d5381STakashi Iwai };
175532d5381STakashi Iwai 
176532d5381STakashi Iwai extern struct hda_ctl_ops snd_hda_bind_vol;	/* for bind-volume with TLV */
177532d5381STakashi Iwai extern struct hda_ctl_ops snd_hda_bind_sw;	/* for bind-switch */
178532d5381STakashi Iwai 
179532d5381STakashi Iwai struct hda_bind_ctls {
180532d5381STakashi Iwai 	struct hda_ctl_ops *ops;
1815d9b6c07SHannes Eder 	unsigned long values[];
182532d5381STakashi Iwai };
183532d5381STakashi Iwai 
184532d5381STakashi Iwai int snd_hda_mixer_bind_ctls_info(struct snd_kcontrol *kcontrol,
185532d5381STakashi Iwai 				 struct snd_ctl_elem_info *uinfo);
186532d5381STakashi Iwai int snd_hda_mixer_bind_ctls_get(struct snd_kcontrol *kcontrol,
187532d5381STakashi Iwai 				struct snd_ctl_elem_value *ucontrol);
188532d5381STakashi Iwai int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol,
189532d5381STakashi Iwai 				struct snd_ctl_elem_value *ucontrol);
190532d5381STakashi Iwai int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag,
191532d5381STakashi Iwai 			   unsigned int size, unsigned int __user *tlv);
192532d5381STakashi Iwai 
193532d5381STakashi Iwai #define HDA_BIND_VOL(xname, bindrec) \
194532d5381STakashi Iwai 	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
195532d5381STakashi Iwai 	  .name = xname, \
196532d5381STakashi Iwai 	  .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |\
197532d5381STakashi Iwai 			  SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
198532d5381STakashi Iwai 			  SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK,\
199532d5381STakashi Iwai 	  .info = snd_hda_mixer_bind_ctls_info,\
200532d5381STakashi Iwai 	  .get =  snd_hda_mixer_bind_ctls_get,\
201532d5381STakashi Iwai 	  .put = snd_hda_mixer_bind_ctls_put,\
202532d5381STakashi Iwai 	  .tlv = { .c = snd_hda_mixer_bind_tlv },\
203532d5381STakashi Iwai 	  .private_value = (long) (bindrec) }
204532d5381STakashi Iwai #define HDA_BIND_SW(xname, bindrec) \
205532d5381STakashi Iwai 	{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,\
206532d5381STakashi Iwai 	  .name = xname, \
207532d5381STakashi Iwai 	  .info = snd_hda_mixer_bind_ctls_info,\
208532d5381STakashi Iwai 	  .get =  snd_hda_mixer_bind_ctls_get,\
209532d5381STakashi Iwai 	  .put = snd_hda_mixer_bind_ctls_put,\
210532d5381STakashi Iwai 	  .private_value = (long) (bindrec) }
211532d5381STakashi Iwai 
212532d5381STakashi Iwai /*
213532d5381STakashi Iwai  * SPDIF I/O
214532d5381STakashi Iwai  */
21574b654c9SStephen Warren int snd_hda_create_spdif_out_ctls(struct hda_codec *codec,
21674b654c9SStephen Warren 				  hda_nid_t associated_nid,
21774b654c9SStephen Warren 				  hda_nid_t cvt_nid);
2181da177e4SLinus Torvalds int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid);
2191da177e4SLinus Torvalds 
2201da177e4SLinus Torvalds /*
2211da177e4SLinus Torvalds  * input MUX helper
2221da177e4SLinus Torvalds  */
22354d17403STakashi Iwai #define HDA_MAX_NUM_INPUTS	16
2241da177e4SLinus Torvalds struct hda_input_mux_item {
225b5786e85STakashi Iwai 	char label[32];
2261da177e4SLinus Torvalds 	unsigned int index;
2271da177e4SLinus Torvalds };
2281da177e4SLinus Torvalds struct hda_input_mux {
2291da177e4SLinus Torvalds 	unsigned int num_items;
2301da177e4SLinus Torvalds 	struct hda_input_mux_item items[HDA_MAX_NUM_INPUTS];
2311da177e4SLinus Torvalds };
2321da177e4SLinus Torvalds 
233d01ce99fSTakashi Iwai int snd_hda_input_mux_info(const struct hda_input_mux *imux,
234d01ce99fSTakashi Iwai 			   struct snd_ctl_elem_info *uinfo);
235d01ce99fSTakashi Iwai int snd_hda_input_mux_put(struct hda_codec *codec,
236d01ce99fSTakashi Iwai 			  const struct hda_input_mux *imux,
237c8b6bf9bSTakashi Iwai 			  struct snd_ctl_elem_value *ucontrol, hda_nid_t nid,
2381da177e4SLinus Torvalds 			  unsigned int *cur_val);
2391da177e4SLinus Torvalds 
240d2a6d7dcSTakashi Iwai /*
241d2a6d7dcSTakashi Iwai  * Channel mode helper
242d2a6d7dcSTakashi Iwai  */
243d2a6d7dcSTakashi Iwai struct hda_channel_mode {
244d2a6d7dcSTakashi Iwai 	int channels;
245d2a6d7dcSTakashi Iwai 	const struct hda_verb *sequence;
246d2a6d7dcSTakashi Iwai };
247d2a6d7dcSTakashi Iwai 
248d01ce99fSTakashi Iwai int snd_hda_ch_mode_info(struct hda_codec *codec,
249d01ce99fSTakashi Iwai 			 struct snd_ctl_elem_info *uinfo,
250d01ce99fSTakashi Iwai 			 const struct hda_channel_mode *chmode,
251d01ce99fSTakashi Iwai 			 int num_chmodes);
252d01ce99fSTakashi Iwai int snd_hda_ch_mode_get(struct hda_codec *codec,
253d01ce99fSTakashi Iwai 			struct snd_ctl_elem_value *ucontrol,
254d01ce99fSTakashi Iwai 			const struct hda_channel_mode *chmode,
255d01ce99fSTakashi Iwai 			int num_chmodes,
256d2a6d7dcSTakashi Iwai 			int max_channels);
257d01ce99fSTakashi Iwai int snd_hda_ch_mode_put(struct hda_codec *codec,
258d01ce99fSTakashi Iwai 			struct snd_ctl_elem_value *ucontrol,
259d01ce99fSTakashi Iwai 			const struct hda_channel_mode *chmode,
260d01ce99fSTakashi Iwai 			int num_chmodes,
261d2a6d7dcSTakashi Iwai 			int *max_channelsp);
262d2a6d7dcSTakashi Iwai 
2631da177e4SLinus Torvalds /*
2641da177e4SLinus Torvalds  * Multi-channel / digital-out PCM helper
2651da177e4SLinus Torvalds  */
2661da177e4SLinus Torvalds 
2671da177e4SLinus Torvalds enum { HDA_FRONT, HDA_REAR, HDA_CLFE, HDA_SIDE }; /* index for dac_nidx */
2681da177e4SLinus Torvalds enum { HDA_DIG_NONE, HDA_DIG_EXCLUSIVE, HDA_DIG_ANALOG_DUP }; /* dig_out_used */
2691da177e4SLinus Torvalds 
270a06dbfc2STakashi Iwai #define HDA_MAX_OUTS	5
271a06dbfc2STakashi Iwai 
2721da177e4SLinus Torvalds struct hda_multi_out {
2731da177e4SLinus Torvalds 	int num_dacs;		/* # of DACs, must be more than 1 */
274dda14410STakashi Iwai 	const hda_nid_t *dac_nids;	/* DAC list */
2751da177e4SLinus Torvalds 	hda_nid_t hp_nid;	/* optional DAC for HP, 0 when not exists */
276a06dbfc2STakashi Iwai 	hda_nid_t hp_out_nid[HDA_MAX_OUTS];	/* DACs for multiple HPs */
277a06dbfc2STakashi Iwai 	hda_nid_t extra_out_nid[HDA_MAX_OUTS];	/* other (e.g. speaker) DACs */
2781da177e4SLinus Torvalds 	hda_nid_t dig_out_nid;	/* digital out audio widget */
279dda14410STakashi Iwai 	const hda_nid_t *slave_dig_outs;
2801da177e4SLinus Torvalds 	int max_channels;	/* currently supported analog channels */
2811da177e4SLinus Torvalds 	int dig_out_used;	/* current usage of digital out (HDA_DIG_XXX) */
282d29240ceSTakashi Iwai 	int no_share_stream;	/* don't share a stream with multiple pins */
2839a08160bSTakashi Iwai 	int share_spdif;	/* share SPDIF pin */
2849a08160bSTakashi Iwai 	/* PCM information for both analog and SPDIF DACs */
2859a08160bSTakashi Iwai 	unsigned int analog_rates;
2869a08160bSTakashi Iwai 	unsigned int analog_maxbps;
2879a08160bSTakashi Iwai 	u64 analog_formats;
2889a08160bSTakashi Iwai 	unsigned int spdif_rates;
2899a08160bSTakashi Iwai 	unsigned int spdif_maxbps;
2909a08160bSTakashi Iwai 	u64 spdif_formats;
2911da177e4SLinus Torvalds };
2921da177e4SLinus Torvalds 
2939a08160bSTakashi Iwai int snd_hda_create_spdif_share_sw(struct hda_codec *codec,
2949a08160bSTakashi Iwai 				  struct hda_multi_out *mout);
295d01ce99fSTakashi Iwai int snd_hda_multi_out_dig_open(struct hda_codec *codec,
296d01ce99fSTakashi Iwai 			       struct hda_multi_out *mout);
297d01ce99fSTakashi Iwai int snd_hda_multi_out_dig_close(struct hda_codec *codec,
298d01ce99fSTakashi Iwai 				struct hda_multi_out *mout);
2996b97eb45STakashi Iwai int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
3006b97eb45STakashi Iwai 				  struct hda_multi_out *mout,
3016b97eb45STakashi Iwai 				  unsigned int stream_tag,
3026b97eb45STakashi Iwai 				  unsigned int format,
3036b97eb45STakashi Iwai 				  struct snd_pcm_substream *substream);
3049411e21cSTakashi Iwai int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec,
3059411e21cSTakashi Iwai 				  struct hda_multi_out *mout);
306d01ce99fSTakashi Iwai int snd_hda_multi_out_analog_open(struct hda_codec *codec,
307d01ce99fSTakashi Iwai 				  struct hda_multi_out *mout,
3089a08160bSTakashi Iwai 				  struct snd_pcm_substream *substream,
3099a08160bSTakashi Iwai 				  struct hda_pcm_stream *hinfo);
310d01ce99fSTakashi Iwai int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
311d01ce99fSTakashi Iwai 				     struct hda_multi_out *mout,
3121da177e4SLinus Torvalds 				     unsigned int stream_tag,
3131da177e4SLinus Torvalds 				     unsigned int format,
314c8b6bf9bSTakashi Iwai 				     struct snd_pcm_substream *substream);
315d01ce99fSTakashi Iwai int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,
316d01ce99fSTakashi Iwai 				     struct hda_multi_out *mout);
3171da177e4SLinus Torvalds 
3181da177e4SLinus Torvalds /*
3191da177e4SLinus Torvalds  * generic codec parser
3201da177e4SLinus Torvalds  */
32135a1e0ccSTakashi Iwai #ifdef CONFIG_SND_HDA_GENERIC
3221da177e4SLinus Torvalds int snd_hda_parse_generic_codec(struct hda_codec *codec);
32335a1e0ccSTakashi Iwai #else
32435a1e0ccSTakashi Iwai static inline int snd_hda_parse_generic_codec(struct hda_codec *codec)
32535a1e0ccSTakashi Iwai {
32635a1e0ccSTakashi Iwai 	return -ENODEV;
32735a1e0ccSTakashi Iwai }
32835a1e0ccSTakashi Iwai #endif
3291da177e4SLinus Torvalds 
3301da177e4SLinus Torvalds /*
3311da177e4SLinus Torvalds  * generic proc interface
3321da177e4SLinus Torvalds  */
3331da177e4SLinus Torvalds #ifdef CONFIG_PROC_FS
3341da177e4SLinus Torvalds int snd_hda_codec_proc_new(struct hda_codec *codec);
3351da177e4SLinus Torvalds #else
3361da177e4SLinus Torvalds static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; }
3371da177e4SLinus Torvalds #endif
3381da177e4SLinus Torvalds 
33933deeca3SWu Fengguang #define SND_PRINT_RATES_ADVISED_BUFSIZE	80
34033deeca3SWu Fengguang void snd_print_pcm_rates(int pcm, char *buf, int buflen);
34133deeca3SWu Fengguang 
342d39b4352SWu Fengguang #define SND_PRINT_BITS_ADVISED_BUFSIZE	16
343d39b4352SWu Fengguang void snd_print_pcm_bits(int pcm, char *buf, int buflen);
344d39b4352SWu Fengguang 
3451da177e4SLinus Torvalds /*
3461da177e4SLinus Torvalds  * Misc
3471da177e4SLinus Torvalds  */
348f5fcc13cSTakashi Iwai int snd_hda_check_board_config(struct hda_codec *codec, int num_configs,
349ea734963STakashi Iwai 			       const char * const *modelnames,
350f5fcc13cSTakashi Iwai 			       const struct snd_pci_quirk *pci_list);
3512eda3445SMauro Carvalho Chehab int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
352ea734963STakashi Iwai                                int num_configs, const char * const *models,
3532eda3445SMauro Carvalho Chehab                                const struct snd_pci_quirk *tbl);
354d01ce99fSTakashi Iwai int snd_hda_add_new_ctls(struct hda_codec *codec,
355031024eeSTakashi Iwai 			 const struct snd_kcontrol_new *knew);
3561da177e4SLinus Torvalds 
3571da177e4SLinus Torvalds /*
3581da177e4SLinus Torvalds  * unsolicited event handler
3591da177e4SLinus Torvalds  */
3601da177e4SLinus Torvalds 
3611da177e4SLinus Torvalds #define HDA_UNSOL_QUEUE_SIZE	64
3621da177e4SLinus Torvalds 
3631da177e4SLinus Torvalds struct hda_bus_unsolicited {
3641da177e4SLinus Torvalds 	/* ring buffer */
3651da177e4SLinus Torvalds 	u32 queue[HDA_UNSOL_QUEUE_SIZE * 2];
3661da177e4SLinus Torvalds 	unsigned int rp, wp;
3671da177e4SLinus Torvalds 
3681da177e4SLinus Torvalds 	/* workqueue */
3691da177e4SLinus Torvalds 	struct work_struct work;
370c4028958SDavid Howells 	struct hda_bus *bus;
3711da177e4SLinus Torvalds };
3721da177e4SLinus Torvalds 
373e9edcee0STakashi Iwai /*
374b7a5633aSJustin P. Mattock  * Helper for automatic pin configuration
375e9edcee0STakashi Iwai  */
376e9edcee0STakashi Iwai 
377e9edcee0STakashi Iwai enum {
378e9edcee0STakashi Iwai 	AUTO_PIN_MIC,
37986e2959aSTakashi Iwai 	AUTO_PIN_LINE_IN,
380e9edcee0STakashi Iwai 	AUTO_PIN_CD,
381e9edcee0STakashi Iwai 	AUTO_PIN_AUX,
382e9edcee0STakashi Iwai 	AUTO_PIN_LAST
383e9edcee0STakashi Iwai };
384e9edcee0STakashi Iwai 
385d258e24aSTakashi Iwai enum {
386d258e24aSTakashi Iwai 	AUTO_PIN_LINE_OUT,
387d258e24aSTakashi Iwai 	AUTO_PIN_SPEAKER_OUT,
388d258e24aSTakashi Iwai 	AUTO_PIN_HP_OUT
389d258e24aSTakashi Iwai };
390d258e24aSTakashi Iwai 
391a06dbfc2STakashi Iwai #define AUTO_CFG_MAX_OUTS	HDA_MAX_OUTS
39275e0eb24STakashi Iwai #define AUTO_CFG_MAX_INS	8
39375e0eb24STakashi Iwai 
39475e0eb24STakashi Iwai struct auto_pin_cfg_item {
39575e0eb24STakashi Iwai 	hda_nid_t pin;
39675e0eb24STakashi Iwai 	int type;
39775e0eb24STakashi Iwai };
39875e0eb24STakashi Iwai 
39975e0eb24STakashi Iwai struct auto_pin_cfg;
40010a20af7STakashi Iwai const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin,
40110a20af7STakashi Iwai 				    int check_location);
40210a20af7STakashi Iwai const char *hda_get_autocfg_input_label(struct hda_codec *codec,
40310a20af7STakashi Iwai 					const struct auto_pin_cfg *cfg,
40410a20af7STakashi Iwai 					int input);
40510a20af7STakashi Iwai int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label,
40610a20af7STakashi Iwai 			  int index, int *type_index_ret);
40741923e44STakashi Iwai 
40899ae28beSTakashi Iwai enum {
40999ae28beSTakashi Iwai 	INPUT_PIN_ATTR_UNUSED,	/* pin not connected */
41099ae28beSTakashi Iwai 	INPUT_PIN_ATTR_INT,	/* internal mic/line-in */
41199ae28beSTakashi Iwai 	INPUT_PIN_ATTR_DOCK,	/* docking mic/line-in */
41299ae28beSTakashi Iwai 	INPUT_PIN_ATTR_NORMAL,	/* mic/line-in jack */
41399ae28beSTakashi Iwai 	INPUT_PIN_ATTR_FRONT,	/* mic/line-in jack in front */
41499ae28beSTakashi Iwai 	INPUT_PIN_ATTR_REAR,	/* mic/line-in jack in rear */
41599ae28beSTakashi Iwai };
41699ae28beSTakashi Iwai 
41799ae28beSTakashi Iwai int snd_hda_get_input_pin_attr(unsigned int def_conf);
41899ae28beSTakashi Iwai 
419e9edcee0STakashi Iwai struct auto_pin_cfg {
420e9edcee0STakashi Iwai 	int line_outs;
42141923e44STakashi Iwai 	/* sorted in the order of Front/Surr/CLFE/Side */
42241923e44STakashi Iwai 	hda_nid_t line_out_pins[AUTO_CFG_MAX_OUTS];
42382bc955fSTakashi Iwai 	int speaker_outs;
42441923e44STakashi Iwai 	hda_nid_t speaker_pins[AUTO_CFG_MAX_OUTS];
425eb06ed8fSTakashi Iwai 	int hp_outs;
426d258e24aSTakashi Iwai 	int line_out_type;	/* AUTO_PIN_XXX_OUT */
42741923e44STakashi Iwai 	hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS];
42875e0eb24STakashi Iwai 	int num_inputs;
42975e0eb24STakashi Iwai 	struct auto_pin_cfg_item inputs[AUTO_CFG_MAX_INS];
4300852d7a6STakashi Iwai 	int dig_outs;
4310852d7a6STakashi Iwai 	hda_nid_t dig_out_pins[2];
432e9edcee0STakashi Iwai 	hda_nid_t dig_in_pin;
43390da78bfSMatthew Ranostay 	hda_nid_t mono_out_pin;
4340852d7a6STakashi Iwai 	int dig_out_type[2]; /* HDA_PCM_TYPE_XXX */
4352297bd6eSTakashi Iwai 	int dig_in_type; /* HDA_PCM_TYPE_XXX */
436e9edcee0STakashi Iwai };
437e9edcee0STakashi Iwai 
438d01ce99fSTakashi Iwai #define get_defcfg_connect(cfg) \
439d01ce99fSTakashi Iwai 	((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT)
440d01ce99fSTakashi Iwai #define get_defcfg_association(cfg) \
441d01ce99fSTakashi Iwai 	((cfg & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT)
442d01ce99fSTakashi Iwai #define get_defcfg_location(cfg) \
443d01ce99fSTakashi Iwai 	((cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT)
444d01ce99fSTakashi Iwai #define get_defcfg_sequence(cfg) \
445d01ce99fSTakashi Iwai 	(cfg & AC_DEFCFG_SEQUENCE)
446d01ce99fSTakashi Iwai #define get_defcfg_device(cfg) \
447d01ce99fSTakashi Iwai 	((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT)
448e9edcee0STakashi Iwai 
449d025febcSTakashi Iwai /* bit-flags for snd_hda_parse_pin_def_config() behavior */
450d025febcSTakashi Iwai #define HDA_PINCFG_NO_HP_FIXUP	(1 << 0) /* no HP-split */
451d025febcSTakashi Iwai #define HDA_PINCFG_NO_LO_FIXUP	(1 << 1) /* don't take other outs as LO */
452d025febcSTakashi Iwai 
453d025febcSTakashi Iwai int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
454d01ce99fSTakashi Iwai 			     struct auto_pin_cfg *cfg,
455d025febcSTakashi Iwai 			     const hda_nid_t *ignore_nids,
456d025febcSTakashi Iwai 			     unsigned int cond_flags);
457d025febcSTakashi Iwai 
458d025febcSTakashi Iwai /* older function */
459d025febcSTakashi Iwai #define snd_hda_parse_pin_def_config(codec, cfg, ignore) \
460d025febcSTakashi Iwai 	snd_hda_parse_pin_defcfg(codec, cfg, ignore, 0)
461e9edcee0STakashi Iwai 
4628d88bc3dSTakashi Iwai /* amp values */
4638d88bc3dSTakashi Iwai #define AMP_IN_MUTE(idx)	(0x7080 | ((idx)<<8))
4648d88bc3dSTakashi Iwai #define AMP_IN_UNMUTE(idx)	(0x7000 | ((idx)<<8))
4658d88bc3dSTakashi Iwai #define AMP_OUT_MUTE		0xb080
4668d88bc3dSTakashi Iwai #define AMP_OUT_UNMUTE		0xb000
4678d88bc3dSTakashi Iwai #define AMP_OUT_ZERO		0xb000
4688d88bc3dSTakashi Iwai /* pinctl values */
46935e8901eSRobin H. Johnson #define PIN_IN			(AC_PINCTL_IN_EN)
47035e8901eSRobin H. Johnson #define PIN_VREFHIZ		(AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ)
47135e8901eSRobin H. Johnson #define PIN_VREF50		(AC_PINCTL_IN_EN | AC_PINCTL_VREF_50)
47235e8901eSRobin H. Johnson #define PIN_VREFGRD		(AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD)
47335e8901eSRobin H. Johnson #define PIN_VREF80		(AC_PINCTL_IN_EN | AC_PINCTL_VREF_80)
47435e8901eSRobin H. Johnson #define PIN_VREF100		(AC_PINCTL_IN_EN | AC_PINCTL_VREF_100)
47535e8901eSRobin H. Johnson #define PIN_OUT			(AC_PINCTL_OUT_EN)
47635e8901eSRobin H. Johnson #define PIN_HP			(AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN)
47735e8901eSRobin H. Johnson #define PIN_HP_AMP		(AC_PINCTL_HP_EN)
4788d88bc3dSTakashi Iwai 
47954d17403STakashi Iwai /*
48054d17403STakashi Iwai  * get widget capabilities
48154d17403STakashi Iwai  */
48254d17403STakashi Iwai static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
48354d17403STakashi Iwai {
48454d17403STakashi Iwai 	if (nid < codec->start_nid ||
48554d17403STakashi Iwai 	    nid >= codec->start_nid + codec->num_nodes)
486dca008f3STakashi Iwai 		return 0;
48754d17403STakashi Iwai 	return codec->wcaps[nid - codec->start_nid];
48854d17403STakashi Iwai }
48954d17403STakashi Iwai 
490a22d543aSTakashi Iwai /* get the widget type from widget capability bits */
491a22d543aSTakashi Iwai #define get_wcaps_type(wcaps) (((wcaps) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT)
492a22d543aSTakashi Iwai 
493fd72d008SWu Fengguang static inline unsigned int get_wcaps_channels(u32 wcaps)
494fd72d008SWu Fengguang {
495fd72d008SWu Fengguang 	unsigned int chans;
496fd72d008SWu Fengguang 
497fd72d008SWu Fengguang 	chans = (wcaps & AC_WCAP_CHAN_CNT_EXT) >> 13;
498fd72d008SWu Fengguang 	chans = ((chans << 1) | 1) + 1;
499fd72d008SWu Fengguang 
500fd72d008SWu Fengguang 	return chans;
501fd72d008SWu Fengguang }
502fd72d008SWu Fengguang 
50309a99959SMatthew Ranostay u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction);
504897cc188STakashi Iwai int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
505897cc188STakashi Iwai 			      unsigned int caps);
5061327a32bSTakashi Iwai u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid);
507f57c2565STakashi Iwai int snd_hda_override_pin_caps(struct hda_codec *codec, hda_nid_t nid,
508f57c2565STakashi Iwai 			      unsigned int caps);
509864f92beSWu Fengguang u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid);
510864f92beSWu Fengguang int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid);
51154d17403STakashi Iwai 
51203697e2aSTakashi Iwai static inline bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid)
51303697e2aSTakashi Iwai {
514e35d9d6aSTakashi Iwai 	return (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_PRES_DETECT) &&
515e35d9d6aSTakashi Iwai 		(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP);
51603697e2aSTakashi Iwai }
51703697e2aSTakashi Iwai 
5189e3fd871SJaroslav Kysela /* flags for hda_nid_item */
5199e3fd871SJaroslav Kysela #define HDA_NID_ITEM_AMP	(1<<0)
5209e3fd871SJaroslav Kysela 
5213911a4c1SJaroslav Kysela struct hda_nid_item {
5223911a4c1SJaroslav Kysela 	struct snd_kcontrol *kctl;
5235b0cb1d8SJaroslav Kysela 	unsigned int index;
5243911a4c1SJaroslav Kysela 	hda_nid_t nid;
5259e3fd871SJaroslav Kysela 	unsigned short flags;
5263911a4c1SJaroslav Kysela };
5273911a4c1SJaroslav Kysela 
5283911a4c1SJaroslav Kysela int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid,
5293911a4c1SJaroslav Kysela 		    struct snd_kcontrol *kctl);
5305b0cb1d8SJaroslav Kysela int snd_hda_add_nid(struct hda_codec *codec, struct snd_kcontrol *kctl,
5315b0cb1d8SJaroslav Kysela 		    unsigned int index, hda_nid_t nid);
532d13bd412STakashi Iwai void snd_hda_ctls_clear(struct hda_codec *codec);
533d13bd412STakashi Iwai 
5342807314dSTakashi Iwai /*
5352807314dSTakashi Iwai  * hwdep interface
5362807314dSTakashi Iwai  */
537d7ffba19STakashi Iwai #ifdef CONFIG_SND_HDA_HWDEP
5382807314dSTakashi Iwai int snd_hda_create_hwdep(struct hda_codec *codec);
539d7ffba19STakashi Iwai #else
540d7ffba19STakashi Iwai static inline int snd_hda_create_hwdep(struct hda_codec *codec) { return 0; }
541d7ffba19STakashi Iwai #endif
5422807314dSTakashi Iwai 
5437288561aSTakashi Iwai #if defined(CONFIG_SND_HDA_POWER_SAVE) && defined(CONFIG_SND_HDA_HWDEP)
544a2f6309eSTakashi Iwai int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec);
545a2f6309eSTakashi Iwai #else
546a2f6309eSTakashi Iwai static inline int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec)
547a2f6309eSTakashi Iwai {
548a2f6309eSTakashi Iwai 	return 0;
549a2f6309eSTakashi Iwai }
550a2f6309eSTakashi Iwai #endif
551a2f6309eSTakashi Iwai 
552e7ee058cSTakashi Iwai #ifdef CONFIG_SND_HDA_RECONFIG
553e7ee058cSTakashi Iwai int snd_hda_hwdep_add_sysfs(struct hda_codec *codec);
554e7ee058cSTakashi Iwai #else
555e7ee058cSTakashi Iwai static inline int snd_hda_hwdep_add_sysfs(struct hda_codec *codec)
556e7ee058cSTakashi Iwai {
557e7ee058cSTakashi Iwai 	return 0;
558e7ee058cSTakashi Iwai }
559e7ee058cSTakashi Iwai #endif
560e7ee058cSTakashi Iwai 
56143b62713STakashi Iwai #ifdef CONFIG_SND_HDA_RECONFIG
56243b62713STakashi Iwai const char *snd_hda_get_hint(struct hda_codec *codec, const char *key);
56343b62713STakashi Iwai int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key);
56443b62713STakashi Iwai #else
56543b62713STakashi Iwai static inline
56643b62713STakashi Iwai const char *snd_hda_get_hint(struct hda_codec *codec, const char *key)
56743b62713STakashi Iwai {
56843b62713STakashi Iwai 	return NULL;
56943b62713STakashi Iwai }
57043b62713STakashi Iwai 
57143b62713STakashi Iwai static inline
57243b62713STakashi Iwai int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key)
57343b62713STakashi Iwai {
57443b62713STakashi Iwai 	return -ENOENT;
57543b62713STakashi Iwai }
57643b62713STakashi Iwai #endif
57743b62713STakashi Iwai 
578cb53c626STakashi Iwai /*
579cb53c626STakashi Iwai  * power-management
580cb53c626STakashi Iwai  */
581cb53c626STakashi Iwai 
582cb53c626STakashi Iwai void snd_hda_schedule_power_save(struct hda_codec *codec);
583cb53c626STakashi Iwai 
584cb53c626STakashi Iwai struct hda_amp_list {
585cb53c626STakashi Iwai 	hda_nid_t nid;
586cb53c626STakashi Iwai 	unsigned char dir;
587cb53c626STakashi Iwai 	unsigned char idx;
588cb53c626STakashi Iwai };
589cb53c626STakashi Iwai 
590cb53c626STakashi Iwai struct hda_loopback_check {
591031024eeSTakashi Iwai 	const struct hda_amp_list *amplist;
592cb53c626STakashi Iwai 	int power_on;
593cb53c626STakashi Iwai };
594cb53c626STakashi Iwai 
595cb53c626STakashi Iwai int snd_hda_check_amp_list_power(struct hda_codec *codec,
596cb53c626STakashi Iwai 				 struct hda_loopback_check *check,
597cb53c626STakashi Iwai 				 hda_nid_t nid);
598cb53c626STakashi Iwai 
59989385035SMatthew Ranostay /*
60089385035SMatthew Ranostay  * AMP control callbacks
60189385035SMatthew Ranostay  */
60289385035SMatthew Ranostay /* retrieve parameters from private_value */
6033911a4c1SJaroslav Kysela #define get_amp_nid_(pv)	((pv) & 0xffff)
6043911a4c1SJaroslav Kysela #define get_amp_nid(kc)		get_amp_nid_((kc)->private_value)
60589385035SMatthew Ranostay #define get_amp_channels(kc)	(((kc)->private_value >> 16) & 0x3)
60689385035SMatthew Ranostay #define get_amp_direction(kc)	(((kc)->private_value >> 18) & 0x1)
60789385035SMatthew Ranostay #define get_amp_index(kc)	(((kc)->private_value >> 19) & 0xf)
60829fdbec2STakashi Iwai #define get_amp_offset(kc)	(((kc)->private_value >> 23) & 0x3f)
609de8c85f7SClemens Ladisch #define get_amp_min_mute(kc)	(((kc)->private_value >> 29) & 0x1)
61089385035SMatthew Ranostay 
6117f4a9f43SWu Fengguang /*
6127f4a9f43SWu Fengguang  * CEA Short Audio Descriptor data
6137f4a9f43SWu Fengguang  */
6147f4a9f43SWu Fengguang struct cea_sad {
6157f4a9f43SWu Fengguang 	int	channels;
6167f4a9f43SWu Fengguang 	int	format;		/* (format == 0) indicates invalid SAD */
6177f4a9f43SWu Fengguang 	int	rates;
6187f4a9f43SWu Fengguang 	int	sample_bits;	/* for LPCM */
6197f4a9f43SWu Fengguang 	int	max_bitrate;	/* for AC3...ATRAC */
6207f4a9f43SWu Fengguang 	int	profile;	/* for WMAPRO */
6217f4a9f43SWu Fengguang };
6227f4a9f43SWu Fengguang 
6237f4a9f43SWu Fengguang #define ELD_FIXED_BYTES	20
624*14bc52b8SPierre-Louis Bossart #define ELD_MAX_SIZE    256
6257f4a9f43SWu Fengguang #define ELD_MAX_MNL	16
6267f4a9f43SWu Fengguang #define ELD_MAX_SAD	16
6277f4a9f43SWu Fengguang 
6287f4a9f43SWu Fengguang /*
6297f4a9f43SWu Fengguang  * ELD: EDID Like Data
6307f4a9f43SWu Fengguang  */
6315b87ebb7SWu Fengguang struct hdmi_eld {
63223ccc2bdSWu Fengguang 	bool	monitor_present;
63323ccc2bdSWu Fengguang 	bool	eld_valid;
6347f4a9f43SWu Fengguang 	int	eld_size;
6357f4a9f43SWu Fengguang 	int	baseline_len;
63623ccc2bdSWu Fengguang 	int	eld_ver;
6377f4a9f43SWu Fengguang 	int	cea_edid_ver;
6387f4a9f43SWu Fengguang 	char	monitor_name[ELD_MAX_MNL + 1];
6397f4a9f43SWu Fengguang 	int	manufacture_id;
6407f4a9f43SWu Fengguang 	int	product_id;
6417f4a9f43SWu Fengguang 	u64	port_id;
6427f4a9f43SWu Fengguang 	int	support_hdcp;
6437f4a9f43SWu Fengguang 	int	support_ai;
6447f4a9f43SWu Fengguang 	int	conn_type;
6457f4a9f43SWu Fengguang 	int	aud_synch_delay;
6467f4a9f43SWu Fengguang 	int	spk_alloc;
6477f4a9f43SWu Fengguang 	int	sad_count;
6487f4a9f43SWu Fengguang 	struct cea_sad sad[ELD_MAX_SAD];
649*14bc52b8SPierre-Louis Bossart 	char    eld_buffer[ELD_MAX_SIZE];
650f208dba9STakashi Iwai #ifdef CONFIG_PROC_FS
651f208dba9STakashi Iwai 	struct snd_info_entry *proc_entry;
652f208dba9STakashi Iwai #endif
6537f4a9f43SWu Fengguang };
6547f4a9f43SWu Fengguang 
6557f4a9f43SWu Fengguang int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid);
6565b87ebb7SWu Fengguang int snd_hdmi_get_eld(struct hdmi_eld *, struct hda_codec *, hda_nid_t);
6575b87ebb7SWu Fengguang void snd_hdmi_show_eld(struct hdmi_eld *eld);
6582def8172SStephen Warren void snd_hdmi_eld_update_pcm_info(struct hdmi_eld *eld,
6592def8172SStephen Warren 			      struct hda_pcm_stream *hinfo);
6607f4a9f43SWu Fengguang 
6615f1e71b1SWu Fengguang #ifdef CONFIG_PROC_FS
66254a25f87SWu Fengguang int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld,
66354a25f87SWu Fengguang 			 int index);
664f208dba9STakashi Iwai void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld);
6655f1e71b1SWu Fengguang #else
6660623536cSTakashi Iwai static inline int snd_hda_eld_proc_new(struct hda_codec *codec,
66754a25f87SWu Fengguang 				       struct hdmi_eld *eld,
66854a25f87SWu Fengguang 				       int index)
6695f1e71b1SWu Fengguang {
6705f1e71b1SWu Fengguang 	return 0;
6715f1e71b1SWu Fengguang }
672f208dba9STakashi Iwai static inline void snd_hda_eld_proc_free(struct hda_codec *codec,
673f208dba9STakashi Iwai 					 struct hdmi_eld *eld)
674f208dba9STakashi Iwai {
675f208dba9STakashi Iwai }
6765f1e71b1SWu Fengguang #endif
6775f1e71b1SWu Fengguang 
678903b21d8SWu Fengguang #define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
679903b21d8SWu Fengguang void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
680903b21d8SWu Fengguang 
681cd372fb3STakashi Iwai /*
682cd372fb3STakashi Iwai  * Input-jack notification support
683cd372fb3STakashi Iwai  */
684cd372fb3STakashi Iwai #ifdef CONFIG_SND_HDA_INPUT_JACK
685cd372fb3STakashi Iwai int snd_hda_input_jack_add(struct hda_codec *codec, hda_nid_t nid, int type,
686cd372fb3STakashi Iwai 			   const char *name);
687cd372fb3STakashi Iwai void snd_hda_input_jack_report(struct hda_codec *codec, hda_nid_t nid);
688cd372fb3STakashi Iwai void snd_hda_input_jack_free(struct hda_codec *codec);
689cd372fb3STakashi Iwai #else /* CONFIG_SND_HDA_INPUT_JACK */
690cd372fb3STakashi Iwai static inline int snd_hda_input_jack_add(struct hda_codec *codec,
691cd372fb3STakashi Iwai 					 hda_nid_t nid, int type,
692cd372fb3STakashi Iwai 					 const char *name)
693cd372fb3STakashi Iwai {
694cd372fb3STakashi Iwai 	return 0;
695cd372fb3STakashi Iwai }
696cd372fb3STakashi Iwai static inline void snd_hda_input_jack_report(struct hda_codec *codec,
697cd372fb3STakashi Iwai 					     hda_nid_t nid)
698cd372fb3STakashi Iwai {
699cd372fb3STakashi Iwai }
700cd372fb3STakashi Iwai static inline void snd_hda_input_jack_free(struct hda_codec *codec)
701cd372fb3STakashi Iwai {
702cd372fb3STakashi Iwai }
703cd372fb3STakashi Iwai #endif /* CONFIG_SND_HDA_INPUT_JACK */
704cd372fb3STakashi Iwai 
7051da177e4SLinus Torvalds #endif /* __SOUND_HDA_LOCAL_H */
706