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); 89cb53c626STakashi Iwai #ifdef SND_HDA_NEEDS_RESUME 90b3ac5636STakashi Iwai void snd_hda_codec_resume_amp(struct hda_codec *codec); 9182beb8fdSTakashi Iwai #endif 921da177e4SLinus Torvalds 932134ea4fSTakashi Iwai void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir, 942134ea4fSTakashi Iwai unsigned int *tlv); 952134ea4fSTakashi Iwai struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec, 962134ea4fSTakashi Iwai const char *name); 972134ea4fSTakashi Iwai int snd_hda_add_vmaster(struct hda_codec *codec, char *name, 982134ea4fSTakashi Iwai unsigned int *tlv, const char **slaves); 996c1f45eaSTakashi Iwai void snd_hda_codec_reset(struct hda_codec *codec); 1006c1f45eaSTakashi Iwai int snd_hda_codec_configure(struct hda_codec *codec); 1012134ea4fSTakashi Iwai 10247fd830aSTakashi Iwai /* amp value bits */ 10347fd830aSTakashi Iwai #define HDA_AMP_MUTE 0x80 10447fd830aSTakashi Iwai #define HDA_AMP_UNMUTE 0x00 10547fd830aSTakashi Iwai #define HDA_AMP_VOLMASK 0x7f 10647fd830aSTakashi Iwai 107985be54bSTakashi Iwai /* mono switch binding multiple inputs */ 108985be54bSTakashi Iwai #define HDA_BIND_MUTE_MONO(xname, nid, channel, indices, direction) \ 109985be54bSTakashi Iwai { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 110985be54bSTakashi Iwai .info = snd_hda_mixer_amp_switch_info, \ 111985be54bSTakashi Iwai .get = snd_hda_mixer_bind_switch_get, \ 112985be54bSTakashi Iwai .put = snd_hda_mixer_bind_switch_put, \ 113985be54bSTakashi Iwai .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) } 114985be54bSTakashi Iwai 115985be54bSTakashi Iwai /* stereo switch binding multiple inputs */ 116d01ce99fSTakashi Iwai #define HDA_BIND_MUTE(xname,nid,indices,dir) \ 117d01ce99fSTakashi Iwai HDA_BIND_MUTE_MONO(xname,nid,3,indices,dir) 118985be54bSTakashi Iwai 119d01ce99fSTakashi Iwai int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, 120d01ce99fSTakashi Iwai struct snd_ctl_elem_value *ucontrol); 121d01ce99fSTakashi Iwai int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, 122d01ce99fSTakashi Iwai struct snd_ctl_elem_value *ucontrol); 123985be54bSTakashi Iwai 124532d5381STakashi Iwai /* more generic bound controls */ 125532d5381STakashi Iwai struct hda_ctl_ops { 126532d5381STakashi Iwai snd_kcontrol_info_t *info; 127532d5381STakashi Iwai snd_kcontrol_get_t *get; 128532d5381STakashi Iwai snd_kcontrol_put_t *put; 129532d5381STakashi Iwai snd_kcontrol_tlv_rw_t *tlv; 130532d5381STakashi Iwai }; 131532d5381STakashi Iwai 132532d5381STakashi Iwai extern struct hda_ctl_ops snd_hda_bind_vol; /* for bind-volume with TLV */ 133532d5381STakashi Iwai extern struct hda_ctl_ops snd_hda_bind_sw; /* for bind-switch */ 134532d5381STakashi Iwai 135532d5381STakashi Iwai struct hda_bind_ctls { 136532d5381STakashi Iwai struct hda_ctl_ops *ops; 137532d5381STakashi Iwai long values[]; 138532d5381STakashi Iwai }; 139532d5381STakashi Iwai 140532d5381STakashi Iwai int snd_hda_mixer_bind_ctls_info(struct snd_kcontrol *kcontrol, 141532d5381STakashi Iwai struct snd_ctl_elem_info *uinfo); 142532d5381STakashi Iwai int snd_hda_mixer_bind_ctls_get(struct snd_kcontrol *kcontrol, 143532d5381STakashi Iwai struct snd_ctl_elem_value *ucontrol); 144532d5381STakashi Iwai int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol, 145532d5381STakashi Iwai struct snd_ctl_elem_value *ucontrol); 146532d5381STakashi Iwai int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag, 147532d5381STakashi Iwai unsigned int size, unsigned int __user *tlv); 148532d5381STakashi Iwai 149532d5381STakashi Iwai #define HDA_BIND_VOL(xname, bindrec) \ 150532d5381STakashi Iwai { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 151532d5381STakashi Iwai .name = xname, \ 152532d5381STakashi Iwai .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |\ 153532d5381STakashi Iwai SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ 154532d5381STakashi Iwai SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK,\ 155532d5381STakashi Iwai .info = snd_hda_mixer_bind_ctls_info,\ 156532d5381STakashi Iwai .get = snd_hda_mixer_bind_ctls_get,\ 157532d5381STakashi Iwai .put = snd_hda_mixer_bind_ctls_put,\ 158532d5381STakashi Iwai .tlv = { .c = snd_hda_mixer_bind_tlv },\ 159532d5381STakashi Iwai .private_value = (long) (bindrec) } 160532d5381STakashi Iwai #define HDA_BIND_SW(xname, bindrec) \ 161532d5381STakashi Iwai { .iface = SNDRV_CTL_ELEM_IFACE_MIXER,\ 162532d5381STakashi Iwai .name = xname, \ 163532d5381STakashi Iwai .info = snd_hda_mixer_bind_ctls_info,\ 164532d5381STakashi Iwai .get = snd_hda_mixer_bind_ctls_get,\ 165532d5381STakashi Iwai .put = snd_hda_mixer_bind_ctls_put,\ 166532d5381STakashi Iwai .private_value = (long) (bindrec) } 167532d5381STakashi Iwai 168532d5381STakashi Iwai /* 169532d5381STakashi Iwai * SPDIF I/O 170532d5381STakashi Iwai */ 1711da177e4SLinus Torvalds int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid); 1721da177e4SLinus Torvalds int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid); 1731da177e4SLinus Torvalds 1741da177e4SLinus Torvalds /* 1751da177e4SLinus Torvalds * input MUX helper 1761da177e4SLinus Torvalds */ 17754d17403STakashi Iwai #define HDA_MAX_NUM_INPUTS 16 1781da177e4SLinus Torvalds struct hda_input_mux_item { 1791da177e4SLinus Torvalds const char *label; 1801da177e4SLinus Torvalds unsigned int index; 1811da177e4SLinus Torvalds }; 1821da177e4SLinus Torvalds struct hda_input_mux { 1831da177e4SLinus Torvalds unsigned int num_items; 1841da177e4SLinus Torvalds struct hda_input_mux_item items[HDA_MAX_NUM_INPUTS]; 1851da177e4SLinus Torvalds }; 1861da177e4SLinus Torvalds 187d01ce99fSTakashi Iwai int snd_hda_input_mux_info(const struct hda_input_mux *imux, 188d01ce99fSTakashi Iwai struct snd_ctl_elem_info *uinfo); 189d01ce99fSTakashi Iwai int snd_hda_input_mux_put(struct hda_codec *codec, 190d01ce99fSTakashi Iwai const struct hda_input_mux *imux, 191c8b6bf9bSTakashi Iwai struct snd_ctl_elem_value *ucontrol, hda_nid_t nid, 1921da177e4SLinus Torvalds unsigned int *cur_val); 1931da177e4SLinus Torvalds 194d2a6d7dcSTakashi Iwai /* 195d2a6d7dcSTakashi Iwai * Channel mode helper 196d2a6d7dcSTakashi Iwai */ 197d2a6d7dcSTakashi Iwai struct hda_channel_mode { 198d2a6d7dcSTakashi Iwai int channels; 199d2a6d7dcSTakashi Iwai const struct hda_verb *sequence; 200d2a6d7dcSTakashi Iwai }; 201d2a6d7dcSTakashi Iwai 202d01ce99fSTakashi Iwai int snd_hda_ch_mode_info(struct hda_codec *codec, 203d01ce99fSTakashi Iwai struct snd_ctl_elem_info *uinfo, 204d01ce99fSTakashi Iwai const struct hda_channel_mode *chmode, 205d01ce99fSTakashi Iwai int num_chmodes); 206d01ce99fSTakashi Iwai int snd_hda_ch_mode_get(struct hda_codec *codec, 207d01ce99fSTakashi Iwai struct snd_ctl_elem_value *ucontrol, 208d01ce99fSTakashi Iwai const struct hda_channel_mode *chmode, 209d01ce99fSTakashi Iwai int num_chmodes, 210d2a6d7dcSTakashi Iwai int max_channels); 211d01ce99fSTakashi Iwai int snd_hda_ch_mode_put(struct hda_codec *codec, 212d01ce99fSTakashi Iwai struct snd_ctl_elem_value *ucontrol, 213d01ce99fSTakashi Iwai const struct hda_channel_mode *chmode, 214d01ce99fSTakashi Iwai int num_chmodes, 215d2a6d7dcSTakashi Iwai int *max_channelsp); 216d2a6d7dcSTakashi Iwai 2171da177e4SLinus Torvalds /* 2181da177e4SLinus Torvalds * Multi-channel / digital-out PCM helper 2191da177e4SLinus Torvalds */ 2201da177e4SLinus Torvalds 2211da177e4SLinus Torvalds enum { HDA_FRONT, HDA_REAR, HDA_CLFE, HDA_SIDE }; /* index for dac_nidx */ 2221da177e4SLinus Torvalds enum { HDA_DIG_NONE, HDA_DIG_EXCLUSIVE, HDA_DIG_ANALOG_DUP }; /* dig_out_used */ 2231da177e4SLinus Torvalds 2241da177e4SLinus Torvalds struct hda_multi_out { 2251da177e4SLinus Torvalds int num_dacs; /* # of DACs, must be more than 1 */ 2261da177e4SLinus Torvalds hda_nid_t *dac_nids; /* DAC list */ 2271da177e4SLinus Torvalds hda_nid_t hp_nid; /* optional DAC for HP, 0 when not exists */ 22882bc955fSTakashi Iwai hda_nid_t extra_out_nid[3]; /* optional DACs, 0 when not exists */ 2291da177e4SLinus Torvalds hda_nid_t dig_out_nid; /* digital out audio widget */ 2301da177e4SLinus Torvalds int max_channels; /* currently supported analog channels */ 2311da177e4SLinus Torvalds int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */ 232d29240ceSTakashi Iwai int no_share_stream; /* don't share a stream with multiple pins */ 2339a08160bSTakashi Iwai int share_spdif; /* share SPDIF pin */ 2349a08160bSTakashi Iwai /* PCM information for both analog and SPDIF DACs */ 2359a08160bSTakashi Iwai unsigned int analog_rates; 2369a08160bSTakashi Iwai unsigned int analog_maxbps; 2379a08160bSTakashi Iwai u64 analog_formats; 2389a08160bSTakashi Iwai unsigned int spdif_rates; 2399a08160bSTakashi Iwai unsigned int spdif_maxbps; 2409a08160bSTakashi Iwai u64 spdif_formats; 2411da177e4SLinus Torvalds }; 2421da177e4SLinus Torvalds 2439a08160bSTakashi Iwai int snd_hda_create_spdif_share_sw(struct hda_codec *codec, 2449a08160bSTakashi Iwai struct hda_multi_out *mout); 245d01ce99fSTakashi Iwai int snd_hda_multi_out_dig_open(struct hda_codec *codec, 246d01ce99fSTakashi Iwai struct hda_multi_out *mout); 247d01ce99fSTakashi Iwai int snd_hda_multi_out_dig_close(struct hda_codec *codec, 248d01ce99fSTakashi Iwai struct hda_multi_out *mout); 2496b97eb45STakashi Iwai int snd_hda_multi_out_dig_prepare(struct hda_codec *codec, 2506b97eb45STakashi Iwai struct hda_multi_out *mout, 2516b97eb45STakashi Iwai unsigned int stream_tag, 2526b97eb45STakashi Iwai unsigned int format, 2536b97eb45STakashi Iwai struct snd_pcm_substream *substream); 254d01ce99fSTakashi Iwai int snd_hda_multi_out_analog_open(struct hda_codec *codec, 255d01ce99fSTakashi Iwai struct hda_multi_out *mout, 2569a08160bSTakashi Iwai struct snd_pcm_substream *substream, 2579a08160bSTakashi Iwai struct hda_pcm_stream *hinfo); 258d01ce99fSTakashi Iwai int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, 259d01ce99fSTakashi Iwai struct hda_multi_out *mout, 2601da177e4SLinus Torvalds unsigned int stream_tag, 2611da177e4SLinus Torvalds unsigned int format, 262c8b6bf9bSTakashi Iwai struct snd_pcm_substream *substream); 263d01ce99fSTakashi Iwai int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, 264d01ce99fSTakashi Iwai struct hda_multi_out *mout); 2651da177e4SLinus Torvalds 2661da177e4SLinus Torvalds /* 2671da177e4SLinus Torvalds * generic codec parser 2681da177e4SLinus Torvalds */ 26935a1e0ccSTakashi Iwai #ifdef CONFIG_SND_HDA_GENERIC 2701da177e4SLinus Torvalds int snd_hda_parse_generic_codec(struct hda_codec *codec); 27135a1e0ccSTakashi Iwai #else 27235a1e0ccSTakashi Iwai static inline int snd_hda_parse_generic_codec(struct hda_codec *codec) 27335a1e0ccSTakashi Iwai { 27435a1e0ccSTakashi Iwai return -ENODEV; 27535a1e0ccSTakashi Iwai } 27635a1e0ccSTakashi Iwai #endif 2771da177e4SLinus Torvalds 2781da177e4SLinus Torvalds /* 2791da177e4SLinus Torvalds * generic proc interface 2801da177e4SLinus Torvalds */ 2811da177e4SLinus Torvalds #ifdef CONFIG_PROC_FS 2821da177e4SLinus Torvalds int snd_hda_codec_proc_new(struct hda_codec *codec); 2831da177e4SLinus Torvalds #else 2841da177e4SLinus Torvalds static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; } 2851da177e4SLinus Torvalds #endif 2861da177e4SLinus Torvalds 2871da177e4SLinus Torvalds /* 2881da177e4SLinus Torvalds * Misc 2891da177e4SLinus Torvalds */ 290f5fcc13cSTakashi Iwai int snd_hda_check_board_config(struct hda_codec *codec, int num_configs, 291f5fcc13cSTakashi Iwai const char **modelnames, 292f5fcc13cSTakashi Iwai const struct snd_pci_quirk *pci_list); 293d01ce99fSTakashi Iwai int snd_hda_add_new_ctls(struct hda_codec *codec, 294d01ce99fSTakashi Iwai struct snd_kcontrol_new *knew); 2951da177e4SLinus Torvalds 2961da177e4SLinus Torvalds /* 2971da177e4SLinus Torvalds * unsolicited event handler 2981da177e4SLinus Torvalds */ 2991da177e4SLinus Torvalds 3001da177e4SLinus Torvalds #define HDA_UNSOL_QUEUE_SIZE 64 3011da177e4SLinus Torvalds 3021da177e4SLinus Torvalds struct hda_bus_unsolicited { 3031da177e4SLinus Torvalds /* ring buffer */ 3041da177e4SLinus Torvalds u32 queue[HDA_UNSOL_QUEUE_SIZE * 2]; 3051da177e4SLinus Torvalds unsigned int rp, wp; 3061da177e4SLinus Torvalds 3071da177e4SLinus Torvalds /* workqueue */ 3081da177e4SLinus Torvalds struct work_struct work; 309c4028958SDavid Howells struct hda_bus *bus; 3101da177e4SLinus Torvalds }; 3111da177e4SLinus Torvalds 312e9edcee0STakashi Iwai /* 313e9edcee0STakashi Iwai * Helper for automatic ping configuration 314e9edcee0STakashi Iwai */ 315e9edcee0STakashi Iwai 316e9edcee0STakashi Iwai enum { 317e9edcee0STakashi Iwai AUTO_PIN_MIC, 318e9edcee0STakashi Iwai AUTO_PIN_FRONT_MIC, 319e9edcee0STakashi Iwai AUTO_PIN_LINE, 320e9edcee0STakashi Iwai AUTO_PIN_FRONT_LINE, 321e9edcee0STakashi Iwai AUTO_PIN_CD, 322e9edcee0STakashi Iwai AUTO_PIN_AUX, 323e9edcee0STakashi Iwai AUTO_PIN_LAST 324e9edcee0STakashi Iwai }; 325e9edcee0STakashi Iwai 326d258e24aSTakashi Iwai enum { 327d258e24aSTakashi Iwai AUTO_PIN_LINE_OUT, 328d258e24aSTakashi Iwai AUTO_PIN_SPEAKER_OUT, 329d258e24aSTakashi Iwai AUTO_PIN_HP_OUT 330d258e24aSTakashi Iwai }; 331d258e24aSTakashi Iwai 3324a471b7dSTakashi Iwai extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST]; 3334a471b7dSTakashi Iwai 33441923e44STakashi Iwai #define AUTO_CFG_MAX_OUTS 5 33541923e44STakashi Iwai 336e9edcee0STakashi Iwai struct auto_pin_cfg { 337e9edcee0STakashi Iwai int line_outs; 33841923e44STakashi Iwai /* sorted in the order of Front/Surr/CLFE/Side */ 33941923e44STakashi Iwai hda_nid_t line_out_pins[AUTO_CFG_MAX_OUTS]; 34082bc955fSTakashi Iwai int speaker_outs; 34141923e44STakashi Iwai hda_nid_t speaker_pins[AUTO_CFG_MAX_OUTS]; 342eb06ed8fSTakashi Iwai int hp_outs; 343d258e24aSTakashi Iwai int line_out_type; /* AUTO_PIN_XXX_OUT */ 34441923e44STakashi Iwai hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS]; 345e9edcee0STakashi Iwai hda_nid_t input_pins[AUTO_PIN_LAST]; 346e9edcee0STakashi Iwai hda_nid_t dig_out_pin; 347e9edcee0STakashi Iwai hda_nid_t dig_in_pin; 34890da78bfSMatthew Ranostay hda_nid_t mono_out_pin; 349e9edcee0STakashi Iwai }; 350e9edcee0STakashi Iwai 351d01ce99fSTakashi Iwai #define get_defcfg_connect(cfg) \ 352d01ce99fSTakashi Iwai ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT) 353d01ce99fSTakashi Iwai #define get_defcfg_association(cfg) \ 354d01ce99fSTakashi Iwai ((cfg & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT) 355d01ce99fSTakashi Iwai #define get_defcfg_location(cfg) \ 356d01ce99fSTakashi Iwai ((cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT) 357d01ce99fSTakashi Iwai #define get_defcfg_sequence(cfg) \ 358d01ce99fSTakashi Iwai (cfg & AC_DEFCFG_SEQUENCE) 359d01ce99fSTakashi Iwai #define get_defcfg_device(cfg) \ 360d01ce99fSTakashi Iwai ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) 361e9edcee0STakashi Iwai 362d01ce99fSTakashi Iwai int snd_hda_parse_pin_def_config(struct hda_codec *codec, 363d01ce99fSTakashi Iwai struct auto_pin_cfg *cfg, 364df694daaSKailang Yang hda_nid_t *ignore_nids); 365e9edcee0STakashi Iwai 3668d88bc3dSTakashi Iwai /* amp values */ 3678d88bc3dSTakashi Iwai #define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8)) 3688d88bc3dSTakashi Iwai #define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8)) 3698d88bc3dSTakashi Iwai #define AMP_OUT_MUTE 0xb080 3708d88bc3dSTakashi Iwai #define AMP_OUT_UNMUTE 0xb000 3718d88bc3dSTakashi Iwai #define AMP_OUT_ZERO 0xb000 3728d88bc3dSTakashi Iwai /* pinctl values */ 37335e8901eSRobin H. Johnson #define PIN_IN (AC_PINCTL_IN_EN) 37435e8901eSRobin H. Johnson #define PIN_VREFHIZ (AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ) 37535e8901eSRobin H. Johnson #define PIN_VREF50 (AC_PINCTL_IN_EN | AC_PINCTL_VREF_50) 37635e8901eSRobin H. Johnson #define PIN_VREFGRD (AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD) 37735e8901eSRobin H. Johnson #define PIN_VREF80 (AC_PINCTL_IN_EN | AC_PINCTL_VREF_80) 37835e8901eSRobin H. Johnson #define PIN_VREF100 (AC_PINCTL_IN_EN | AC_PINCTL_VREF_100) 37935e8901eSRobin H. Johnson #define PIN_OUT (AC_PINCTL_OUT_EN) 38035e8901eSRobin H. Johnson #define PIN_HP (AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN) 38135e8901eSRobin H. Johnson #define PIN_HP_AMP (AC_PINCTL_HP_EN) 3828d88bc3dSTakashi Iwai 38354d17403STakashi Iwai /* 38454d17403STakashi Iwai * get widget capabilities 38554d17403STakashi Iwai */ 38654d17403STakashi Iwai static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid) 38754d17403STakashi Iwai { 38854d17403STakashi Iwai if (nid < codec->start_nid || 38954d17403STakashi Iwai nid >= codec->start_nid + codec->num_nodes) 390dca008f3STakashi Iwai return 0; 39154d17403STakashi Iwai return codec->wcaps[nid - codec->start_nid]; 39254d17403STakashi Iwai } 39354d17403STakashi Iwai 39409a99959SMatthew Ranostay u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction); 395897cc188STakashi Iwai int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir, 396897cc188STakashi Iwai unsigned int caps); 39754d17403STakashi Iwai 398d13bd412STakashi Iwai int snd_hda_ctl_add(struct hda_codec *codec, struct snd_kcontrol *kctl); 399d13bd412STakashi Iwai void snd_hda_ctls_clear(struct hda_codec *codec); 400d13bd412STakashi Iwai 4012807314dSTakashi Iwai /* 4022807314dSTakashi Iwai * hwdep interface 4032807314dSTakashi Iwai */ 404*d7ffba19STakashi Iwai #ifdef CONFIG_SND_HDA_HWDEP 4052807314dSTakashi Iwai int snd_hda_create_hwdep(struct hda_codec *codec); 406*d7ffba19STakashi Iwai int snd_hda_hwdep_add_sysfs(struct hda_codec *codec); 407*d7ffba19STakashi Iwai #else 408*d7ffba19STakashi Iwai static inline int snd_hda_create_hwdep(struct hda_codec *codec) { return 0; } 409*d7ffba19STakashi Iwai #endif 4102807314dSTakashi Iwai 411cb53c626STakashi Iwai /* 412cb53c626STakashi Iwai * power-management 413cb53c626STakashi Iwai */ 414cb53c626STakashi Iwai 415cb53c626STakashi Iwai #ifdef CONFIG_SND_HDA_POWER_SAVE 416cb53c626STakashi Iwai void snd_hda_schedule_power_save(struct hda_codec *codec); 417cb53c626STakashi Iwai 418cb53c626STakashi Iwai struct hda_amp_list { 419cb53c626STakashi Iwai hda_nid_t nid; 420cb53c626STakashi Iwai unsigned char dir; 421cb53c626STakashi Iwai unsigned char idx; 422cb53c626STakashi Iwai }; 423cb53c626STakashi Iwai 424cb53c626STakashi Iwai struct hda_loopback_check { 425cb53c626STakashi Iwai struct hda_amp_list *amplist; 426cb53c626STakashi Iwai int power_on; 427cb53c626STakashi Iwai }; 428cb53c626STakashi Iwai 429cb53c626STakashi Iwai int snd_hda_check_amp_list_power(struct hda_codec *codec, 430cb53c626STakashi Iwai struct hda_loopback_check *check, 431cb53c626STakashi Iwai hda_nid_t nid); 432cb53c626STakashi Iwai #endif /* CONFIG_SND_HDA_POWER_SAVE */ 433cb53c626STakashi Iwai 43489385035SMatthew Ranostay /* 43589385035SMatthew Ranostay * AMP control callbacks 43689385035SMatthew Ranostay */ 43789385035SMatthew Ranostay /* retrieve parameters from private_value */ 43889385035SMatthew Ranostay #define get_amp_nid(kc) ((kc)->private_value & 0xffff) 43989385035SMatthew Ranostay #define get_amp_channels(kc) (((kc)->private_value >> 16) & 0x3) 44089385035SMatthew Ranostay #define get_amp_direction(kc) (((kc)->private_value >> 18) & 0x1) 44189385035SMatthew Ranostay #define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf) 44289385035SMatthew Ranostay 4431da177e4SLinus Torvalds #endif /* __SOUND_HDA_LOCAL_H */ 444