0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __SOUND_HDA_GENERIC_H
0009 #define __SOUND_HDA_GENERIC_H
0010
0011 #include <linux/leds.h>
0012
0013
0014 struct hda_multi_io {
0015 hda_nid_t pin;
0016 hda_nid_t dac;
0017 unsigned int ctl_in;
0018 };
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #define MAX_NID_PATH_DEPTH 10
0033
0034 enum {
0035 NID_PATH_VOL_CTL,
0036 NID_PATH_MUTE_CTL,
0037 NID_PATH_BOOST_CTL,
0038 NID_PATH_NUM_CTLS
0039 };
0040
0041 struct nid_path {
0042 int depth;
0043 hda_nid_t path[MAX_NID_PATH_DEPTH];
0044 unsigned char idx[MAX_NID_PATH_DEPTH];
0045 unsigned char multi[MAX_NID_PATH_DEPTH];
0046 unsigned int ctls[NID_PATH_NUM_CTLS];
0047 bool active:1;
0048 bool pin_enabled:1;
0049 bool pin_fixed:1;
0050 bool stream_enabled:1;
0051 };
0052
0053
0054
0055 #define MAX_AUTO_MIC_PINS 3
0056
0057 struct automic_entry {
0058 hda_nid_t pin;
0059 int idx;
0060 unsigned int attr;
0061 };
0062
0063
0064 enum { STREAM_MULTI_OUT, STREAM_INDEP_HP };
0065
0066
0067 enum {
0068 HDA_GEN_PCM_ACT_OPEN,
0069 HDA_GEN_PCM_ACT_PREPARE,
0070 HDA_GEN_PCM_ACT_CLEANUP,
0071 HDA_GEN_PCM_ACT_CLOSE,
0072 };
0073
0074
0075 struct badness_table {
0076 int no_primary_dac;
0077 int no_dac;
0078 int shared_primary;
0079 int shared_surr;
0080 int shared_clfe;
0081 int shared_surr_main;
0082 };
0083
0084 extern const struct badness_table hda_main_out_badness;
0085 extern const struct badness_table hda_extra_out_badness;
0086
0087 struct hda_gen_spec {
0088 char stream_name_analog[32];
0089 const struct hda_pcm_stream *stream_analog_playback;
0090 const struct hda_pcm_stream *stream_analog_capture;
0091
0092 char stream_name_alt_analog[32];
0093 const struct hda_pcm_stream *stream_analog_alt_playback;
0094 const struct hda_pcm_stream *stream_analog_alt_capture;
0095
0096 char stream_name_digital[32];
0097 const struct hda_pcm_stream *stream_digital_playback;
0098 const struct hda_pcm_stream *stream_digital_capture;
0099
0100
0101 unsigned int active_streams;
0102 struct mutex pcm_mutex;
0103
0104
0105 struct hda_multi_out multiout;
0106
0107
0108
0109 hda_nid_t alt_dac_nid;
0110 hda_nid_t follower_dig_outs[3];
0111 int dig_out_type;
0112
0113
0114 unsigned int num_adc_nids;
0115 hda_nid_t adc_nids[AUTO_CFG_MAX_INS];
0116 hda_nid_t dig_in_nid;
0117 hda_nid_t mixer_nid;
0118 hda_nid_t mixer_merge_nid;
0119 const char *input_labels[HDA_MAX_NUM_INPUTS];
0120 int input_label_idxs[HDA_MAX_NUM_INPUTS];
0121
0122
0123 hda_nid_t cur_adc;
0124 unsigned int cur_adc_stream_tag;
0125 unsigned int cur_adc_format;
0126
0127
0128 struct hda_input_mux input_mux;
0129 unsigned int cur_mux[3];
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143 int min_channel_count;
0144 int ext_channel_count;
0145 int const_channel_count;
0146
0147
0148 struct hda_pcm *pcm_rec[3];
0149
0150
0151 struct auto_pin_cfg autocfg;
0152 struct snd_array kctls;
0153 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
0154 hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS];
0155 unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS];
0156
0157 hda_nid_t shared_mic_vref_pin;
0158 hda_nid_t hp_mic_pin;
0159 int hp_mic_mux_idx;
0160
0161
0162 int num_all_dacs;
0163 hda_nid_t all_dacs[16];
0164 int num_all_adcs;
0165 hda_nid_t all_adcs[AUTO_CFG_MAX_INS];
0166
0167
0168 struct snd_array paths;
0169
0170
0171 int out_paths[AUTO_CFG_MAX_OUTS];
0172 int hp_paths[AUTO_CFG_MAX_OUTS];
0173 int speaker_paths[AUTO_CFG_MAX_OUTS];
0174 int aamix_out_paths[3];
0175 int digout_paths[AUTO_CFG_MAX_OUTS];
0176 int input_paths[HDA_MAX_NUM_INPUTS][AUTO_CFG_MAX_INS];
0177 int loopback_paths[HDA_MAX_NUM_INPUTS];
0178 int loopback_merge_path;
0179 int digin_path;
0180
0181
0182 int am_num_entries;
0183 struct automic_entry am_entry[MAX_AUTO_MIC_PINS];
0184
0185
0186
0187 unsigned int hp_jack_present:1;
0188 unsigned int line_jack_present:1;
0189 unsigned int speaker_muted:1;
0190 unsigned int line_out_muted:1;
0191
0192
0193 unsigned int auto_mic:1;
0194 unsigned int automute_speaker:1;
0195 unsigned int automute_lo:1;
0196
0197
0198 unsigned int detect_hp:1;
0199 unsigned int detect_lo:1;
0200 unsigned int automute_speaker_possible:1;
0201 unsigned int automute_lo_possible:1;
0202
0203
0204 unsigned int master_mute:1;
0205 unsigned int keep_vref_in_automute:1;
0206 unsigned int line_in_auto_switch:1;
0207 unsigned int auto_mute_via_amp:1;
0208
0209
0210 unsigned int suppress_auto_mute:1;
0211 unsigned int suppress_auto_mic:1;
0212
0213
0214 unsigned int need_dac_fix:1;
0215 unsigned int hp_mic:1;
0216 unsigned int suppress_hp_mic_detect:1;
0217 unsigned int no_primary_hp:1;
0218 unsigned int no_multi_io:1;
0219 unsigned int multi_cap_vol:1;
0220 unsigned int inv_dmic_split:1;
0221 unsigned int own_eapd_ctl:1;
0222 unsigned int keep_eapd_on:1;
0223 unsigned int vmaster_mute_led:1;
0224 unsigned int mic_mute_led:1;
0225 unsigned int indep_hp:1;
0226 unsigned int prefer_hp_amp:1;
0227 unsigned int add_stereo_mix_input:2;
0228 unsigned int add_jack_modes:1;
0229 unsigned int power_down_unused:1;
0230 unsigned int dac_min_mute:1;
0231 unsigned int suppress_vmaster:1;
0232 unsigned int obey_preferred_dacs:1;
0233
0234
0235 unsigned int no_analog:1;
0236 unsigned int dyn_adc_switch:1;
0237 unsigned int indep_hp_enabled:1;
0238 unsigned int have_aamix_ctl:1;
0239 unsigned int hp_mic_jack_modes:1;
0240 unsigned int skip_verbs:1;
0241
0242
0243 u64 mute_bits;
0244
0245
0246 u64 out_vol_mask;
0247
0248
0249 const struct badness_table *main_out_badness;
0250 const struct badness_table *extra_out_badness;
0251
0252
0253 const hda_nid_t *preferred_dacs;
0254
0255
0256 bool aamix_mode;
0257
0258
0259 hda_nid_t beep_nid;
0260
0261
0262 hda_nid_t vmaster_nid;
0263 unsigned int vmaster_tlv[4];
0264 struct hda_vmaster_mute_hook vmaster_mute;
0265
0266 struct hda_loopback_check loopback;
0267 struct snd_array loopback_list;
0268
0269
0270 int multi_ios;
0271 struct hda_multi_io multi_io[4];
0272
0273
0274 void (*init_hook)(struct hda_codec *codec);
0275 void (*automute_hook)(struct hda_codec *codec);
0276 void (*cap_sync_hook)(struct hda_codec *codec,
0277 struct snd_kcontrol *kcontrol,
0278 struct snd_ctl_elem_value *ucontrol);
0279
0280
0281 void (*pcm_playback_hook)(struct hda_pcm_stream *hinfo,
0282 struct hda_codec *codec,
0283 struct snd_pcm_substream *substream,
0284 int action);
0285 void (*pcm_capture_hook)(struct hda_pcm_stream *hinfo,
0286 struct hda_codec *codec,
0287 struct snd_pcm_substream *substream,
0288 int action);
0289
0290
0291 void (*hp_automute_hook)(struct hda_codec *codec,
0292 struct hda_jack_callback *cb);
0293 void (*line_automute_hook)(struct hda_codec *codec,
0294 struct hda_jack_callback *cb);
0295 void (*mic_autoswitch_hook)(struct hda_codec *codec,
0296 struct hda_jack_callback *cb);
0297
0298
0299 struct led_classdev *led_cdevs[NUM_AUDIO_LEDS];
0300 };
0301
0302
0303 enum {
0304 HDA_HINT_STEREO_MIX_DISABLE,
0305 HDA_HINT_STEREO_MIX_ENABLE,
0306 HDA_HINT_STEREO_MIX_AUTO,
0307 };
0308
0309 int snd_hda_gen_spec_init(struct hda_gen_spec *spec);
0310
0311 int snd_hda_gen_init(struct hda_codec *codec);
0312 void snd_hda_gen_free(struct hda_codec *codec);
0313
0314 int snd_hda_get_path_idx(struct hda_codec *codec, struct nid_path *path);
0315 struct nid_path *snd_hda_get_path_from_idx(struct hda_codec *codec, int idx);
0316 struct nid_path *
0317 snd_hda_add_new_path(struct hda_codec *codec, hda_nid_t from_nid,
0318 hda_nid_t to_nid, int anchor_nid);
0319 void snd_hda_activate_path(struct hda_codec *codec, struct nid_path *path,
0320 bool enable, bool add_aamix);
0321
0322 struct snd_kcontrol_new *
0323 snd_hda_gen_add_kctl(struct hda_gen_spec *spec, const char *name,
0324 const struct snd_kcontrol_new *temp);
0325
0326 int snd_hda_gen_parse_auto_config(struct hda_codec *codec,
0327 struct auto_pin_cfg *cfg);
0328 int snd_hda_gen_build_controls(struct hda_codec *codec);
0329 int snd_hda_gen_build_pcms(struct hda_codec *codec);
0330
0331
0332 void snd_hda_gen_hp_automute(struct hda_codec *codec,
0333 struct hda_jack_callback *jack);
0334 void snd_hda_gen_line_automute(struct hda_codec *codec,
0335 struct hda_jack_callback *jack);
0336 void snd_hda_gen_mic_autoswitch(struct hda_codec *codec,
0337 struct hda_jack_callback *jack);
0338 void snd_hda_gen_update_outputs(struct hda_codec *codec);
0339
0340 #ifdef CONFIG_PM
0341 int snd_hda_gen_check_power_status(struct hda_codec *codec, hda_nid_t nid);
0342 #endif
0343 unsigned int snd_hda_gen_path_power_filter(struct hda_codec *codec,
0344 hda_nid_t nid,
0345 unsigned int power_state);
0346 void snd_hda_gen_stream_pm(struct hda_codec *codec, hda_nid_t nid, bool on);
0347 int snd_hda_gen_fix_pin_power(struct hda_codec *codec, hda_nid_t pin);
0348
0349 int snd_hda_gen_add_mute_led_cdev(struct hda_codec *codec,
0350 int (*callback)(struct led_classdev *,
0351 enum led_brightness));
0352 int snd_hda_gen_add_micmute_led_cdev(struct hda_codec *codec,
0353 int (*callback)(struct led_classdev *,
0354 enum led_brightness));
0355
0356 #endif