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); 14218478e8bSTakashi Iwai int __snd_hda_add_vmaster(struct hda_codec *codec, char *name, 1439322ca54STakashi Iwai unsigned int *tlv, const char * const *slaves, 14429e5853dSTakashi Iwai const char *suffix, bool init_slave_vol, 14529e5853dSTakashi Iwai struct snd_kcontrol **ctl_ret); 14618478e8bSTakashi Iwai #define snd_hda_add_vmaster(codec, name, tlv, slaves, suffix) \ 14729e5853dSTakashi Iwai __snd_hda_add_vmaster(codec, name, tlv, slaves, suffix, true, NULL) 148a65d629cSTakashi Iwai int snd_hda_codec_reset(struct hda_codec *codec); 1492134ea4fSTakashi Iwai 150d2f344b5STakashi Iwai enum { 151d2f344b5STakashi Iwai HDA_VMUTE_OFF, 152d2f344b5STakashi Iwai HDA_VMUTE_ON, 153d2f344b5STakashi Iwai HDA_VMUTE_FOLLOW_MASTER, 154d2f344b5STakashi Iwai }; 155d2f344b5STakashi Iwai 156d2f344b5STakashi Iwai struct hda_vmaster_mute_hook { 157d2f344b5STakashi Iwai /* below two fields must be filled by the caller of 158d2f344b5STakashi Iwai * snd_hda_add_vmaster_hook() beforehand 159d2f344b5STakashi Iwai */ 160d2f344b5STakashi Iwai struct snd_kcontrol *sw_kctl; 161d2f344b5STakashi Iwai void (*hook)(void *, int); 162d2f344b5STakashi Iwai /* below are initialized automatically */ 163d2f344b5STakashi Iwai unsigned int mute_mode; /* HDA_VMUTE_XXX */ 164d2f344b5STakashi Iwai struct hda_codec *codec; 165d2f344b5STakashi Iwai }; 166d2f344b5STakashi Iwai 167d2f344b5STakashi Iwai int snd_hda_add_vmaster_hook(struct hda_codec *codec, 168f29735cbSTakashi Iwai struct hda_vmaster_mute_hook *hook, 169f29735cbSTakashi Iwai bool expose_enum_ctl); 170d2f344b5STakashi Iwai void snd_hda_sync_vmaster_hook(struct hda_vmaster_mute_hook *hook); 171d2f344b5STakashi Iwai 17247fd830aSTakashi Iwai /* amp value bits */ 17347fd830aSTakashi Iwai #define HDA_AMP_MUTE 0x80 17447fd830aSTakashi Iwai #define HDA_AMP_UNMUTE 0x00 17547fd830aSTakashi Iwai #define HDA_AMP_VOLMASK 0x7f 17647fd830aSTakashi Iwai 177985be54bSTakashi Iwai /* mono switch binding multiple inputs */ 178985be54bSTakashi Iwai #define HDA_BIND_MUTE_MONO(xname, nid, channel, indices, direction) \ 179985be54bSTakashi Iwai { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 180985be54bSTakashi Iwai .info = snd_hda_mixer_amp_switch_info, \ 181985be54bSTakashi Iwai .get = snd_hda_mixer_bind_switch_get, \ 182985be54bSTakashi Iwai .put = snd_hda_mixer_bind_switch_put, \ 183985be54bSTakashi Iwai .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) } 184985be54bSTakashi Iwai 185985be54bSTakashi Iwai /* stereo switch binding multiple inputs */ 186d01ce99fSTakashi Iwai #define HDA_BIND_MUTE(xname,nid,indices,dir) \ 187d01ce99fSTakashi Iwai HDA_BIND_MUTE_MONO(xname,nid,3,indices,dir) 188985be54bSTakashi Iwai 189d01ce99fSTakashi Iwai int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, 190d01ce99fSTakashi Iwai struct snd_ctl_elem_value *ucontrol); 191d01ce99fSTakashi Iwai int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, 192d01ce99fSTakashi Iwai struct snd_ctl_elem_value *ucontrol); 193985be54bSTakashi Iwai 194532d5381STakashi Iwai /* more generic bound controls */ 195532d5381STakashi Iwai struct hda_ctl_ops { 196532d5381STakashi Iwai snd_kcontrol_info_t *info; 197532d5381STakashi Iwai snd_kcontrol_get_t *get; 198532d5381STakashi Iwai snd_kcontrol_put_t *put; 199532d5381STakashi Iwai snd_kcontrol_tlv_rw_t *tlv; 200532d5381STakashi Iwai }; 201532d5381STakashi Iwai 202532d5381STakashi Iwai extern struct hda_ctl_ops snd_hda_bind_vol; /* for bind-volume with TLV */ 203532d5381STakashi Iwai extern struct hda_ctl_ops snd_hda_bind_sw; /* for bind-switch */ 204532d5381STakashi Iwai 205532d5381STakashi Iwai struct hda_bind_ctls { 206532d5381STakashi Iwai struct hda_ctl_ops *ops; 2075d9b6c07SHannes Eder unsigned long values[]; 208532d5381STakashi Iwai }; 209532d5381STakashi Iwai 210532d5381STakashi Iwai int snd_hda_mixer_bind_ctls_info(struct snd_kcontrol *kcontrol, 211532d5381STakashi Iwai struct snd_ctl_elem_info *uinfo); 212532d5381STakashi Iwai int snd_hda_mixer_bind_ctls_get(struct snd_kcontrol *kcontrol, 213532d5381STakashi Iwai struct snd_ctl_elem_value *ucontrol); 214532d5381STakashi Iwai int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol, 215532d5381STakashi Iwai struct snd_ctl_elem_value *ucontrol); 216532d5381STakashi Iwai int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag, 217532d5381STakashi Iwai unsigned int size, unsigned int __user *tlv); 218532d5381STakashi Iwai 219532d5381STakashi Iwai #define HDA_BIND_VOL(xname, bindrec) \ 220532d5381STakashi Iwai { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 221532d5381STakashi Iwai .name = xname, \ 222532d5381STakashi Iwai .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |\ 223532d5381STakashi Iwai SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ 224532d5381STakashi Iwai SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK,\ 225532d5381STakashi Iwai .info = snd_hda_mixer_bind_ctls_info,\ 226532d5381STakashi Iwai .get = snd_hda_mixer_bind_ctls_get,\ 227532d5381STakashi Iwai .put = snd_hda_mixer_bind_ctls_put,\ 228532d5381STakashi Iwai .tlv = { .c = snd_hda_mixer_bind_tlv },\ 229532d5381STakashi Iwai .private_value = (long) (bindrec) } 230532d5381STakashi Iwai #define HDA_BIND_SW(xname, bindrec) \ 231532d5381STakashi Iwai { .iface = SNDRV_CTL_ELEM_IFACE_MIXER,\ 232532d5381STakashi Iwai .name = xname, \ 233532d5381STakashi Iwai .info = snd_hda_mixer_bind_ctls_info,\ 234532d5381STakashi Iwai .get = snd_hda_mixer_bind_ctls_get,\ 235532d5381STakashi Iwai .put = snd_hda_mixer_bind_ctls_put,\ 236532d5381STakashi Iwai .private_value = (long) (bindrec) } 237532d5381STakashi Iwai 238532d5381STakashi Iwai /* 239532d5381STakashi Iwai * SPDIF I/O 240532d5381STakashi Iwai */ 24174b654c9SStephen Warren int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, 24274b654c9SStephen Warren hda_nid_t associated_nid, 24374b654c9SStephen Warren hda_nid_t cvt_nid); 2441da177e4SLinus Torvalds int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid); 2451da177e4SLinus Torvalds 2461da177e4SLinus Torvalds /* 2471da177e4SLinus Torvalds * input MUX helper 2481da177e4SLinus Torvalds */ 24954d17403STakashi Iwai #define HDA_MAX_NUM_INPUTS 16 2501da177e4SLinus Torvalds struct hda_input_mux_item { 251b5786e85STakashi Iwai char label[32]; 2521da177e4SLinus Torvalds unsigned int index; 2531da177e4SLinus Torvalds }; 2541da177e4SLinus Torvalds struct hda_input_mux { 2551da177e4SLinus Torvalds unsigned int num_items; 2561da177e4SLinus Torvalds struct hda_input_mux_item items[HDA_MAX_NUM_INPUTS]; 2571da177e4SLinus Torvalds }; 2581da177e4SLinus Torvalds 259d01ce99fSTakashi Iwai int snd_hda_input_mux_info(const struct hda_input_mux *imux, 260d01ce99fSTakashi Iwai struct snd_ctl_elem_info *uinfo); 261d01ce99fSTakashi Iwai int snd_hda_input_mux_put(struct hda_codec *codec, 262d01ce99fSTakashi Iwai const struct hda_input_mux *imux, 263c8b6bf9bSTakashi Iwai struct snd_ctl_elem_value *ucontrol, hda_nid_t nid, 2641da177e4SLinus Torvalds unsigned int *cur_val); 2651da177e4SLinus Torvalds 266d2a6d7dcSTakashi Iwai /* 267d2a6d7dcSTakashi Iwai * Channel mode helper 268d2a6d7dcSTakashi Iwai */ 269d2a6d7dcSTakashi Iwai struct hda_channel_mode { 270d2a6d7dcSTakashi Iwai int channels; 271d2a6d7dcSTakashi Iwai const struct hda_verb *sequence; 272d2a6d7dcSTakashi Iwai }; 273d2a6d7dcSTakashi Iwai 274d01ce99fSTakashi Iwai int snd_hda_ch_mode_info(struct hda_codec *codec, 275d01ce99fSTakashi Iwai struct snd_ctl_elem_info *uinfo, 276d01ce99fSTakashi Iwai const struct hda_channel_mode *chmode, 277d01ce99fSTakashi Iwai int num_chmodes); 278d01ce99fSTakashi Iwai int snd_hda_ch_mode_get(struct hda_codec *codec, 279d01ce99fSTakashi Iwai struct snd_ctl_elem_value *ucontrol, 280d01ce99fSTakashi Iwai const struct hda_channel_mode *chmode, 281d01ce99fSTakashi Iwai int num_chmodes, 282d2a6d7dcSTakashi Iwai int max_channels); 283d01ce99fSTakashi Iwai int snd_hda_ch_mode_put(struct hda_codec *codec, 284d01ce99fSTakashi Iwai struct snd_ctl_elem_value *ucontrol, 285d01ce99fSTakashi Iwai const struct hda_channel_mode *chmode, 286d01ce99fSTakashi Iwai int num_chmodes, 287d2a6d7dcSTakashi Iwai int *max_channelsp); 288d2a6d7dcSTakashi Iwai 2891da177e4SLinus Torvalds /* 2901da177e4SLinus Torvalds * Multi-channel / digital-out PCM helper 2911da177e4SLinus Torvalds */ 2921da177e4SLinus Torvalds 2931da177e4SLinus Torvalds enum { HDA_FRONT, HDA_REAR, HDA_CLFE, HDA_SIDE }; /* index for dac_nidx */ 2941da177e4SLinus Torvalds enum { HDA_DIG_NONE, HDA_DIG_EXCLUSIVE, HDA_DIG_ANALOG_DUP }; /* dig_out_used */ 2951da177e4SLinus Torvalds 296a06dbfc2STakashi Iwai #define HDA_MAX_OUTS 5 297a06dbfc2STakashi Iwai 2981da177e4SLinus Torvalds struct hda_multi_out { 2991da177e4SLinus Torvalds int num_dacs; /* # of DACs, must be more than 1 */ 300dda14410STakashi Iwai const hda_nid_t *dac_nids; /* DAC list */ 3011da177e4SLinus Torvalds hda_nid_t hp_nid; /* optional DAC for HP, 0 when not exists */ 302a06dbfc2STakashi Iwai hda_nid_t hp_out_nid[HDA_MAX_OUTS]; /* DACs for multiple HPs */ 303a06dbfc2STakashi Iwai hda_nid_t extra_out_nid[HDA_MAX_OUTS]; /* other (e.g. speaker) DACs */ 3041da177e4SLinus Torvalds hda_nid_t dig_out_nid; /* digital out audio widget */ 305dda14410STakashi Iwai const hda_nid_t *slave_dig_outs; 3061da177e4SLinus Torvalds int max_channels; /* currently supported analog channels */ 3071da177e4SLinus Torvalds int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */ 308d29240ceSTakashi Iwai int no_share_stream; /* don't share a stream with multiple pins */ 3099a08160bSTakashi Iwai int share_spdif; /* share SPDIF pin */ 3109a08160bSTakashi Iwai /* PCM information for both analog and SPDIF DACs */ 3119a08160bSTakashi Iwai unsigned int analog_rates; 3129a08160bSTakashi Iwai unsigned int analog_maxbps; 3139a08160bSTakashi Iwai u64 analog_formats; 3149a08160bSTakashi Iwai unsigned int spdif_rates; 3159a08160bSTakashi Iwai unsigned int spdif_maxbps; 3169a08160bSTakashi Iwai u64 spdif_formats; 3171da177e4SLinus Torvalds }; 3181da177e4SLinus Torvalds 3199a08160bSTakashi Iwai int snd_hda_create_spdif_share_sw(struct hda_codec *codec, 3209a08160bSTakashi Iwai struct hda_multi_out *mout); 321d01ce99fSTakashi Iwai int snd_hda_multi_out_dig_open(struct hda_codec *codec, 322d01ce99fSTakashi Iwai struct hda_multi_out *mout); 323d01ce99fSTakashi Iwai int snd_hda_multi_out_dig_close(struct hda_codec *codec, 324d01ce99fSTakashi Iwai struct hda_multi_out *mout); 3256b97eb45STakashi Iwai int snd_hda_multi_out_dig_prepare(struct hda_codec *codec, 3266b97eb45STakashi Iwai struct hda_multi_out *mout, 3276b97eb45STakashi Iwai unsigned int stream_tag, 3286b97eb45STakashi Iwai unsigned int format, 3296b97eb45STakashi Iwai struct snd_pcm_substream *substream); 3309411e21cSTakashi Iwai int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec, 3319411e21cSTakashi Iwai struct hda_multi_out *mout); 332d01ce99fSTakashi Iwai int snd_hda_multi_out_analog_open(struct hda_codec *codec, 333d01ce99fSTakashi Iwai struct hda_multi_out *mout, 3349a08160bSTakashi Iwai struct snd_pcm_substream *substream, 3359a08160bSTakashi Iwai struct hda_pcm_stream *hinfo); 336d01ce99fSTakashi Iwai int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, 337d01ce99fSTakashi Iwai struct hda_multi_out *mout, 3381da177e4SLinus Torvalds unsigned int stream_tag, 3391da177e4SLinus Torvalds unsigned int format, 340c8b6bf9bSTakashi Iwai struct snd_pcm_substream *substream); 341d01ce99fSTakashi Iwai int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, 342d01ce99fSTakashi Iwai struct hda_multi_out *mout); 3431da177e4SLinus Torvalds 3441da177e4SLinus Torvalds /* 3451da177e4SLinus Torvalds * generic codec parser 3461da177e4SLinus Torvalds */ 34735a1e0ccSTakashi Iwai #ifdef CONFIG_SND_HDA_GENERIC 3481da177e4SLinus Torvalds int snd_hda_parse_generic_codec(struct hda_codec *codec); 34935a1e0ccSTakashi Iwai #else 35035a1e0ccSTakashi Iwai static inline int snd_hda_parse_generic_codec(struct hda_codec *codec) 35135a1e0ccSTakashi Iwai { 35235a1e0ccSTakashi Iwai return -ENODEV; 35335a1e0ccSTakashi Iwai } 35435a1e0ccSTakashi Iwai #endif 3551da177e4SLinus Torvalds 3561da177e4SLinus Torvalds /* 3571da177e4SLinus Torvalds * generic proc interface 3581da177e4SLinus Torvalds */ 3591da177e4SLinus Torvalds #ifdef CONFIG_PROC_FS 3601da177e4SLinus Torvalds int snd_hda_codec_proc_new(struct hda_codec *codec); 3611da177e4SLinus Torvalds #else 3621da177e4SLinus Torvalds static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; } 3631da177e4SLinus Torvalds #endif 3641da177e4SLinus Torvalds 365d39b4352SWu Fengguang #define SND_PRINT_BITS_ADVISED_BUFSIZE 16 366d39b4352SWu Fengguang void snd_print_pcm_bits(int pcm, char *buf, int buflen); 367d39b4352SWu Fengguang 3681da177e4SLinus Torvalds /* 3691da177e4SLinus Torvalds * Misc 3701da177e4SLinus Torvalds */ 371f5fcc13cSTakashi Iwai int snd_hda_check_board_config(struct hda_codec *codec, int num_configs, 372ea734963STakashi Iwai const char * const *modelnames, 373f5fcc13cSTakashi Iwai const struct snd_pci_quirk *pci_list); 3742eda3445SMauro Carvalho Chehab int snd_hda_check_board_codec_sid_config(struct hda_codec *codec, 375ea734963STakashi Iwai int num_configs, const char * const *models, 3762eda3445SMauro Carvalho Chehab const struct snd_pci_quirk *tbl); 377d01ce99fSTakashi Iwai int snd_hda_add_new_ctls(struct hda_codec *codec, 378031024eeSTakashi Iwai const struct snd_kcontrol_new *knew); 3791da177e4SLinus Torvalds 3801da177e4SLinus Torvalds /* 3811da177e4SLinus Torvalds * unsolicited event handler 3821da177e4SLinus Torvalds */ 3831da177e4SLinus Torvalds 3841da177e4SLinus Torvalds #define HDA_UNSOL_QUEUE_SIZE 64 3851da177e4SLinus Torvalds 3861da177e4SLinus Torvalds struct hda_bus_unsolicited { 3871da177e4SLinus Torvalds /* ring buffer */ 3881da177e4SLinus Torvalds u32 queue[HDA_UNSOL_QUEUE_SIZE * 2]; 3891da177e4SLinus Torvalds unsigned int rp, wp; 3901da177e4SLinus Torvalds 3911da177e4SLinus Torvalds /* workqueue */ 3921da177e4SLinus Torvalds struct work_struct work; 393c4028958SDavid Howells struct hda_bus *bus; 3941da177e4SLinus Torvalds }; 3951da177e4SLinus Torvalds 396e9edcee0STakashi Iwai /* 397b7a5633aSJustin P. Mattock * Helper for automatic pin configuration 398e9edcee0STakashi Iwai */ 399e9edcee0STakashi Iwai 400e9edcee0STakashi Iwai enum { 401e9edcee0STakashi Iwai AUTO_PIN_MIC, 40286e2959aSTakashi Iwai AUTO_PIN_LINE_IN, 403e9edcee0STakashi Iwai AUTO_PIN_CD, 404e9edcee0STakashi Iwai AUTO_PIN_AUX, 405e9edcee0STakashi Iwai AUTO_PIN_LAST 406e9edcee0STakashi Iwai }; 407e9edcee0STakashi Iwai 408d258e24aSTakashi Iwai enum { 409d258e24aSTakashi Iwai AUTO_PIN_LINE_OUT, 410d258e24aSTakashi Iwai AUTO_PIN_SPEAKER_OUT, 411d258e24aSTakashi Iwai AUTO_PIN_HP_OUT 412d258e24aSTakashi Iwai }; 413d258e24aSTakashi Iwai 414a06dbfc2STakashi Iwai #define AUTO_CFG_MAX_OUTS HDA_MAX_OUTS 41575e0eb24STakashi Iwai #define AUTO_CFG_MAX_INS 8 41675e0eb24STakashi Iwai 41775e0eb24STakashi Iwai struct auto_pin_cfg_item { 41875e0eb24STakashi Iwai hda_nid_t pin; 41975e0eb24STakashi Iwai int type; 42075e0eb24STakashi Iwai }; 42175e0eb24STakashi Iwai 42275e0eb24STakashi Iwai struct auto_pin_cfg; 42310a20af7STakashi Iwai const char *hda_get_autocfg_input_label(struct hda_codec *codec, 42410a20af7STakashi Iwai const struct auto_pin_cfg *cfg, 42510a20af7STakashi Iwai int input); 426201e06ffSTakashi Iwai int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid, 427201e06ffSTakashi Iwai const struct auto_pin_cfg *cfg, 428201e06ffSTakashi Iwai char *label, int maxlen, int *indexp); 42910a20af7STakashi Iwai int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label, 43010a20af7STakashi Iwai int index, int *type_index_ret); 43141923e44STakashi Iwai 43299ae28beSTakashi Iwai enum { 43399ae28beSTakashi Iwai INPUT_PIN_ATTR_UNUSED, /* pin not connected */ 43499ae28beSTakashi Iwai INPUT_PIN_ATTR_INT, /* internal mic/line-in */ 43599ae28beSTakashi Iwai INPUT_PIN_ATTR_DOCK, /* docking mic/line-in */ 43699ae28beSTakashi Iwai INPUT_PIN_ATTR_NORMAL, /* mic/line-in jack */ 43799ae28beSTakashi Iwai INPUT_PIN_ATTR_FRONT, /* mic/line-in jack in front */ 43899ae28beSTakashi Iwai INPUT_PIN_ATTR_REAR, /* mic/line-in jack in rear */ 43999ae28beSTakashi Iwai }; 44099ae28beSTakashi Iwai 44199ae28beSTakashi Iwai int snd_hda_get_input_pin_attr(unsigned int def_conf); 44299ae28beSTakashi Iwai 443e9edcee0STakashi Iwai struct auto_pin_cfg { 444e9edcee0STakashi Iwai int line_outs; 44541923e44STakashi Iwai /* sorted in the order of Front/Surr/CLFE/Side */ 44641923e44STakashi Iwai hda_nid_t line_out_pins[AUTO_CFG_MAX_OUTS]; 44782bc955fSTakashi Iwai int speaker_outs; 44841923e44STakashi Iwai hda_nid_t speaker_pins[AUTO_CFG_MAX_OUTS]; 449eb06ed8fSTakashi Iwai int hp_outs; 450d258e24aSTakashi Iwai int line_out_type; /* AUTO_PIN_XXX_OUT */ 45141923e44STakashi Iwai hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS]; 45275e0eb24STakashi Iwai int num_inputs; 45375e0eb24STakashi Iwai struct auto_pin_cfg_item inputs[AUTO_CFG_MAX_INS]; 4540852d7a6STakashi Iwai int dig_outs; 4550852d7a6STakashi Iwai hda_nid_t dig_out_pins[2]; 456e9edcee0STakashi Iwai hda_nid_t dig_in_pin; 45790da78bfSMatthew Ranostay hda_nid_t mono_out_pin; 4580852d7a6STakashi Iwai int dig_out_type[2]; /* HDA_PCM_TYPE_XXX */ 4592297bd6eSTakashi Iwai int dig_in_type; /* HDA_PCM_TYPE_XXX */ 460e9edcee0STakashi Iwai }; 461e9edcee0STakashi Iwai 462d01ce99fSTakashi Iwai #define get_defcfg_connect(cfg) \ 463d01ce99fSTakashi Iwai ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT) 464d01ce99fSTakashi Iwai #define get_defcfg_association(cfg) \ 465d01ce99fSTakashi Iwai ((cfg & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT) 466d01ce99fSTakashi Iwai #define get_defcfg_location(cfg) \ 467d01ce99fSTakashi Iwai ((cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT) 468d01ce99fSTakashi Iwai #define get_defcfg_sequence(cfg) \ 469d01ce99fSTakashi Iwai (cfg & AC_DEFCFG_SEQUENCE) 470d01ce99fSTakashi Iwai #define get_defcfg_device(cfg) \ 471d01ce99fSTakashi Iwai ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) 47208a1f5ebSTakashi Iwai #define get_defcfg_misc(cfg) \ 47308a1f5ebSTakashi Iwai ((cfg & AC_DEFCFG_MISC) >> AC_DEFCFG_MISC_SHIFT) 474e9edcee0STakashi Iwai 475d025febcSTakashi Iwai /* bit-flags for snd_hda_parse_pin_def_config() behavior */ 476d025febcSTakashi Iwai #define HDA_PINCFG_NO_HP_FIXUP (1 << 0) /* no HP-split */ 477d025febcSTakashi Iwai #define HDA_PINCFG_NO_LO_FIXUP (1 << 1) /* don't take other outs as LO */ 478d025febcSTakashi Iwai 479d025febcSTakashi Iwai int snd_hda_parse_pin_defcfg(struct hda_codec *codec, 480d01ce99fSTakashi Iwai struct auto_pin_cfg *cfg, 481d025febcSTakashi Iwai const hda_nid_t *ignore_nids, 482d025febcSTakashi Iwai unsigned int cond_flags); 483d025febcSTakashi Iwai 484d025febcSTakashi Iwai /* older function */ 485d025febcSTakashi Iwai #define snd_hda_parse_pin_def_config(codec, cfg, ignore) \ 486d025febcSTakashi Iwai snd_hda_parse_pin_defcfg(codec, cfg, ignore, 0) 487e9edcee0STakashi Iwai 4888d88bc3dSTakashi Iwai /* amp values */ 4898d88bc3dSTakashi Iwai #define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8)) 4908d88bc3dSTakashi Iwai #define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8)) 4918d88bc3dSTakashi Iwai #define AMP_OUT_MUTE 0xb080 4928d88bc3dSTakashi Iwai #define AMP_OUT_UNMUTE 0xb000 4938d88bc3dSTakashi Iwai #define AMP_OUT_ZERO 0xb000 4948d88bc3dSTakashi Iwai /* pinctl values */ 49535e8901eSRobin H. Johnson #define PIN_IN (AC_PINCTL_IN_EN) 49635e8901eSRobin H. Johnson #define PIN_VREFHIZ (AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ) 49735e8901eSRobin H. Johnson #define PIN_VREF50 (AC_PINCTL_IN_EN | AC_PINCTL_VREF_50) 49835e8901eSRobin H. Johnson #define PIN_VREFGRD (AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD) 49935e8901eSRobin H. Johnson #define PIN_VREF80 (AC_PINCTL_IN_EN | AC_PINCTL_VREF_80) 50035e8901eSRobin H. Johnson #define PIN_VREF100 (AC_PINCTL_IN_EN | AC_PINCTL_VREF_100) 50135e8901eSRobin H. Johnson #define PIN_OUT (AC_PINCTL_OUT_EN) 50235e8901eSRobin H. Johnson #define PIN_HP (AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN) 50335e8901eSRobin H. Johnson #define PIN_HP_AMP (AC_PINCTL_HP_EN) 5048d88bc3dSTakashi Iwai 505*4740860bSTakashi Iwai unsigned int snd_hda_get_default_vref(struct hda_codec *codec, hda_nid_t pin); 506cdd03cedSTakashi Iwai int _snd_hda_set_pin_ctl(struct hda_codec *codec, hda_nid_t pin, 507cdd03cedSTakashi Iwai unsigned int val, bool cached); 508cdd03cedSTakashi Iwai 509cdd03cedSTakashi Iwai /** 510cdd03cedSTakashi Iwai * _snd_hda_set_pin_ctl - Set a pin-control value safely 511cdd03cedSTakashi Iwai * @codec: the codec instance 512cdd03cedSTakashi Iwai * @pin: the pin NID to set the control 513cdd03cedSTakashi Iwai * @val: the pin-control value (AC_PINCTL_* bits) 514cdd03cedSTakashi Iwai * 515cdd03cedSTakashi Iwai * This function sets the pin-control value to the given pin, but 516cdd03cedSTakashi Iwai * filters out the invalid pin-control bits when the pin has no such 517cdd03cedSTakashi Iwai * capabilities. For example, when PIN_HP is passed but the pin has no 518cdd03cedSTakashi Iwai * HP-drive capability, the HP bit is omitted. 519cdd03cedSTakashi Iwai * 520cdd03cedSTakashi Iwai * The function doesn't check the input VREF capability bits, though. 521*4740860bSTakashi Iwai * Use snd_hda_get_default_vref() to guess the right value. 522cdd03cedSTakashi Iwai * Also, this function is only for analog pins, not for HDMI pins. 523cdd03cedSTakashi Iwai */ 524cdd03cedSTakashi Iwai static inline int 525cdd03cedSTakashi Iwai snd_hda_set_pin_ctl(struct hda_codec *codec, hda_nid_t pin, unsigned int val) 526cdd03cedSTakashi Iwai { 527cdd03cedSTakashi Iwai return _snd_hda_set_pin_ctl(codec, pin, val, false); 528cdd03cedSTakashi Iwai } 529cdd03cedSTakashi Iwai 530cdd03cedSTakashi Iwai /** 531cdd03cedSTakashi Iwai * snd_hda_set_pin_ctl_cache - Set a pin-control value safely 532cdd03cedSTakashi Iwai * @codec: the codec instance 533cdd03cedSTakashi Iwai * @pin: the pin NID to set the control 534cdd03cedSTakashi Iwai * @val: the pin-control value (AC_PINCTL_* bits) 535cdd03cedSTakashi Iwai * 536cdd03cedSTakashi Iwai * Just like snd_hda_set_pin_ctl() but write to cache as well. 537cdd03cedSTakashi Iwai */ 538cdd03cedSTakashi Iwai static inline int 539cdd03cedSTakashi Iwai snd_hda_set_pin_ctl_cache(struct hda_codec *codec, hda_nid_t pin, 540cdd03cedSTakashi Iwai unsigned int val) 541cdd03cedSTakashi Iwai { 542cdd03cedSTakashi Iwai return _snd_hda_set_pin_ctl(codec, pin, val, true); 543cdd03cedSTakashi Iwai } 544cdd03cedSTakashi Iwai 54554d17403STakashi Iwai /* 54654d17403STakashi Iwai * get widget capabilities 54754d17403STakashi Iwai */ 54854d17403STakashi Iwai static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid) 54954d17403STakashi Iwai { 55054d17403STakashi Iwai if (nid < codec->start_nid || 55154d17403STakashi Iwai nid >= codec->start_nid + codec->num_nodes) 552dca008f3STakashi Iwai return 0; 55354d17403STakashi Iwai return codec->wcaps[nid - codec->start_nid]; 55454d17403STakashi Iwai } 55554d17403STakashi Iwai 556a22d543aSTakashi Iwai /* get the widget type from widget capability bits */ 5573a90274dSTakashi Iwai static inline int get_wcaps_type(unsigned int wcaps) 5583a90274dSTakashi Iwai { 5593a90274dSTakashi Iwai if (!wcaps) 5603a90274dSTakashi Iwai return -1; /* invalid type */ 5613a90274dSTakashi Iwai return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 5623a90274dSTakashi Iwai } 563a22d543aSTakashi Iwai 564fd72d008SWu Fengguang static inline unsigned int get_wcaps_channels(u32 wcaps) 565fd72d008SWu Fengguang { 566fd72d008SWu Fengguang unsigned int chans; 567fd72d008SWu Fengguang 568fd72d008SWu Fengguang chans = (wcaps & AC_WCAP_CHAN_CNT_EXT) >> 13; 569fd72d008SWu Fengguang chans = ((chans << 1) | 1) + 1; 570fd72d008SWu Fengguang 571fd72d008SWu Fengguang return chans; 572fd72d008SWu Fengguang } 573fd72d008SWu Fengguang 57409a99959SMatthew Ranostay u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction); 575897cc188STakashi Iwai int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, 576897cc188STakashi Iwai unsigned int caps); 5771327a32bSTakashi Iwai u32 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid); 578f57c2565STakashi Iwai int snd_hda_override_pin_caps(struct hda_codec *codec, hda_nid_t nid, 579f57c2565STakashi Iwai unsigned int caps); 58003697e2aSTakashi Iwai 5819e3fd871SJaroslav Kysela /* flags for hda_nid_item */ 5829e3fd871SJaroslav Kysela #define HDA_NID_ITEM_AMP (1<<0) 5839e3fd871SJaroslav Kysela 5843911a4c1SJaroslav Kysela struct hda_nid_item { 5853911a4c1SJaroslav Kysela struct snd_kcontrol *kctl; 5865b0cb1d8SJaroslav Kysela unsigned int index; 5873911a4c1SJaroslav Kysela hda_nid_t nid; 5889e3fd871SJaroslav Kysela unsigned short flags; 5893911a4c1SJaroslav Kysela }; 5903911a4c1SJaroslav Kysela 5913911a4c1SJaroslav Kysela int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid, 5923911a4c1SJaroslav Kysela struct snd_kcontrol *kctl); 5935b0cb1d8SJaroslav Kysela int snd_hda_add_nid(struct hda_codec *codec, struct snd_kcontrol *kctl, 5945b0cb1d8SJaroslav Kysela unsigned int index, hda_nid_t nid); 595d13bd412STakashi Iwai void snd_hda_ctls_clear(struct hda_codec *codec); 596d13bd412STakashi Iwai 5972807314dSTakashi Iwai /* 5982807314dSTakashi Iwai * hwdep interface 5992807314dSTakashi Iwai */ 600d7ffba19STakashi Iwai #ifdef CONFIG_SND_HDA_HWDEP 6012807314dSTakashi Iwai int snd_hda_create_hwdep(struct hda_codec *codec); 602d7ffba19STakashi Iwai #else 603d7ffba19STakashi Iwai static inline int snd_hda_create_hwdep(struct hda_codec *codec) { return 0; } 604d7ffba19STakashi Iwai #endif 6052807314dSTakashi Iwai 6067288561aSTakashi Iwai #if defined(CONFIG_SND_HDA_POWER_SAVE) && defined(CONFIG_SND_HDA_HWDEP) 607a2f6309eSTakashi Iwai int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec); 608a2f6309eSTakashi Iwai #else 609a2f6309eSTakashi Iwai static inline int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec) 610a2f6309eSTakashi Iwai { 611a2f6309eSTakashi Iwai return 0; 612a2f6309eSTakashi Iwai } 613a2f6309eSTakashi Iwai #endif 614a2f6309eSTakashi Iwai 615e7ee058cSTakashi Iwai #ifdef CONFIG_SND_HDA_RECONFIG 616e7ee058cSTakashi Iwai int snd_hda_hwdep_add_sysfs(struct hda_codec *codec); 617e7ee058cSTakashi Iwai #else 618e7ee058cSTakashi Iwai static inline int snd_hda_hwdep_add_sysfs(struct hda_codec *codec) 619e7ee058cSTakashi Iwai { 620e7ee058cSTakashi Iwai return 0; 621e7ee058cSTakashi Iwai } 622e7ee058cSTakashi Iwai #endif 623e7ee058cSTakashi Iwai 62443b62713STakashi Iwai #ifdef CONFIG_SND_HDA_RECONFIG 62543b62713STakashi Iwai const char *snd_hda_get_hint(struct hda_codec *codec, const char *key); 62643b62713STakashi Iwai int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key); 62743b62713STakashi Iwai #else 62843b62713STakashi Iwai static inline 62943b62713STakashi Iwai const char *snd_hda_get_hint(struct hda_codec *codec, const char *key) 63043b62713STakashi Iwai { 63143b62713STakashi Iwai return NULL; 63243b62713STakashi Iwai } 63343b62713STakashi Iwai 63443b62713STakashi Iwai static inline 63543b62713STakashi Iwai int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key) 63643b62713STakashi Iwai { 63743b62713STakashi Iwai return -ENOENT; 63843b62713STakashi Iwai } 63943b62713STakashi Iwai #endif 64043b62713STakashi Iwai 641cb53c626STakashi Iwai /* 642cb53c626STakashi Iwai * power-management 643cb53c626STakashi Iwai */ 644cb53c626STakashi Iwai 645cb53c626STakashi Iwai void snd_hda_schedule_power_save(struct hda_codec *codec); 646cb53c626STakashi Iwai 647cb53c626STakashi Iwai struct hda_amp_list { 648cb53c626STakashi Iwai hda_nid_t nid; 649cb53c626STakashi Iwai unsigned char dir; 650cb53c626STakashi Iwai unsigned char idx; 651cb53c626STakashi Iwai }; 652cb53c626STakashi Iwai 653cb53c626STakashi Iwai struct hda_loopback_check { 654031024eeSTakashi Iwai const struct hda_amp_list *amplist; 655cb53c626STakashi Iwai int power_on; 656cb53c626STakashi Iwai }; 657cb53c626STakashi Iwai 658cb53c626STakashi Iwai int snd_hda_check_amp_list_power(struct hda_codec *codec, 659cb53c626STakashi Iwai struct hda_loopback_check *check, 660cb53c626STakashi Iwai hda_nid_t nid); 661cb53c626STakashi Iwai 66289385035SMatthew Ranostay /* 66389385035SMatthew Ranostay * AMP control callbacks 66489385035SMatthew Ranostay */ 66589385035SMatthew Ranostay /* retrieve parameters from private_value */ 6663911a4c1SJaroslav Kysela #define get_amp_nid_(pv) ((pv) & 0xffff) 6673911a4c1SJaroslav Kysela #define get_amp_nid(kc) get_amp_nid_((kc)->private_value) 66889385035SMatthew Ranostay #define get_amp_channels(kc) (((kc)->private_value >> 16) & 0x3) 669527e4d73STakashi Iwai #define get_amp_direction_(pv) (((pv) >> 18) & 0x1) 670527e4d73STakashi Iwai #define get_amp_direction(kc) get_amp_direction_((kc)->private_value) 67189385035SMatthew Ranostay #define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf) 67229fdbec2STakashi Iwai #define get_amp_offset(kc) (((kc)->private_value >> 23) & 0x3f) 673de8c85f7SClemens Ladisch #define get_amp_min_mute(kc) (((kc)->private_value >> 29) & 0x1) 67489385035SMatthew Ranostay 6757f4a9f43SWu Fengguang /* 6767f4a9f43SWu Fengguang * CEA Short Audio Descriptor data 6777f4a9f43SWu Fengguang */ 6787f4a9f43SWu Fengguang struct cea_sad { 6797f4a9f43SWu Fengguang int channels; 6807f4a9f43SWu Fengguang int format; /* (format == 0) indicates invalid SAD */ 6817f4a9f43SWu Fengguang int rates; 6827f4a9f43SWu Fengguang int sample_bits; /* for LPCM */ 6837f4a9f43SWu Fengguang int max_bitrate; /* for AC3...ATRAC */ 6847f4a9f43SWu Fengguang int profile; /* for WMAPRO */ 6857f4a9f43SWu Fengguang }; 6867f4a9f43SWu Fengguang 6877f4a9f43SWu Fengguang #define ELD_FIXED_BYTES 20 68814bc52b8SPierre-Louis Bossart #define ELD_MAX_SIZE 256 6897f4a9f43SWu Fengguang #define ELD_MAX_MNL 16 6907f4a9f43SWu Fengguang #define ELD_MAX_SAD 16 6917f4a9f43SWu Fengguang 6927f4a9f43SWu Fengguang /* 6937f4a9f43SWu Fengguang * ELD: EDID Like Data 6947f4a9f43SWu Fengguang */ 6955b87ebb7SWu Fengguang struct hdmi_eld { 69623ccc2bdSWu Fengguang bool monitor_present; 69723ccc2bdSWu Fengguang bool eld_valid; 6987f4a9f43SWu Fengguang int eld_size; 6997f4a9f43SWu Fengguang int baseline_len; 70023ccc2bdSWu Fengguang int eld_ver; 7017f4a9f43SWu Fengguang int cea_edid_ver; 7027f4a9f43SWu Fengguang char monitor_name[ELD_MAX_MNL + 1]; 7037f4a9f43SWu Fengguang int manufacture_id; 7047f4a9f43SWu Fengguang int product_id; 7057f4a9f43SWu Fengguang u64 port_id; 7067f4a9f43SWu Fengguang int support_hdcp; 7077f4a9f43SWu Fengguang int support_ai; 7087f4a9f43SWu Fengguang int conn_type; 7097f4a9f43SWu Fengguang int aud_synch_delay; 7107f4a9f43SWu Fengguang int spk_alloc; 7117f4a9f43SWu Fengguang int sad_count; 7127f4a9f43SWu Fengguang struct cea_sad sad[ELD_MAX_SAD]; 713b95d68b8SWu Fengguang /* 714b95d68b8SWu Fengguang * all fields above eld_buffer will be cleared before updating ELD 715b95d68b8SWu Fengguang */ 71614bc52b8SPierre-Louis Bossart char eld_buffer[ELD_MAX_SIZE]; 717f208dba9STakashi Iwai #ifdef CONFIG_PROC_FS 718f208dba9STakashi Iwai struct snd_info_entry *proc_entry; 719f208dba9STakashi Iwai #endif 7207f4a9f43SWu Fengguang }; 7217f4a9f43SWu Fengguang 7227f4a9f43SWu Fengguang int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid); 7235b87ebb7SWu Fengguang int snd_hdmi_get_eld(struct hdmi_eld *, struct hda_codec *, hda_nid_t); 7245b87ebb7SWu Fengguang void snd_hdmi_show_eld(struct hdmi_eld *eld); 7252def8172SStephen Warren void snd_hdmi_eld_update_pcm_info(struct hdmi_eld *eld, 7262def8172SStephen Warren struct hda_pcm_stream *hinfo); 7277f4a9f43SWu Fengguang 7285f1e71b1SWu Fengguang #ifdef CONFIG_PROC_FS 72954a25f87SWu Fengguang int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld, 73054a25f87SWu Fengguang int index); 731f208dba9STakashi Iwai void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld); 7325f1e71b1SWu Fengguang #else 7330623536cSTakashi Iwai static inline int snd_hda_eld_proc_new(struct hda_codec *codec, 73454a25f87SWu Fengguang struct hdmi_eld *eld, 73554a25f87SWu Fengguang int index) 7365f1e71b1SWu Fengguang { 7375f1e71b1SWu Fengguang return 0; 7385f1e71b1SWu Fengguang } 739f208dba9STakashi Iwai static inline void snd_hda_eld_proc_free(struct hda_codec *codec, 740f208dba9STakashi Iwai struct hdmi_eld *eld) 741f208dba9STakashi Iwai { 742f208dba9STakashi Iwai } 7435f1e71b1SWu Fengguang #endif 7445f1e71b1SWu Fengguang 745903b21d8SWu Fengguang #define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80 746903b21d8SWu Fengguang void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen); 747903b21d8SWu Fengguang 7481da177e4SLinus Torvalds #endif /* __SOUND_HDA_LOCAL_H */ 749