0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef __SOUND_HDA_LOCAL_H
0011 #define __SOUND_HDA_LOCAL_H
0012
0013
0014
0015
0016
0017
0018
0019
0020 #define HDA_SUBDEV_NID_FLAG (1U << 31)
0021 #define HDA_SUBDEV_AMP_FLAG (1U << 30)
0022
0023
0024
0025
0026 #define HDA_COMPOSE_AMP_VAL_OFS(nid,chs,idx,dir,ofs) \
0027 ((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19) | ((ofs)<<23))
0028 #define HDA_AMP_VAL_MIN_MUTE (1<<29)
0029 #define HDA_COMPOSE_AMP_VAL(nid,chs,idx,dir) \
0030 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, idx, dir, 0)
0031
0032 #define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, dir, flags) \
0033 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \
0034 .subdevice = HDA_SUBDEV_AMP_FLAG, \
0035 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
0036 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
0037 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
0038 .info = snd_hda_mixer_amp_volume_info, \
0039 .get = snd_hda_mixer_amp_volume_get, \
0040 .put = snd_hda_mixer_amp_volume_put, \
0041 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
0042 .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, dir) | flags }
0043
0044 #define HDA_CODEC_VOLUME_IDX(xname, xcidx, nid, xindex, direction) \
0045 HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, 3, xindex, direction, 0)
0046
0047 #define HDA_CODEC_VOLUME_MONO(xname, nid, channel, xindex, direction) \
0048 HDA_CODEC_VOLUME_MONO_IDX(xname, 0, nid, channel, xindex, direction, 0)
0049
0050 #define HDA_CODEC_VOLUME(xname, nid, xindex, direction) \
0051 HDA_CODEC_VOLUME_MONO(xname, nid, 3, xindex, direction)
0052
0053 #define HDA_CODEC_VOLUME_MIN_MUTE(xname, nid, xindex, direction) \
0054 HDA_CODEC_VOLUME_MONO_IDX(xname, 0, nid, 3, xindex, direction, \
0055 HDA_AMP_VAL_MIN_MUTE)
0056
0057 #define HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
0058 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \
0059 .subdevice = HDA_SUBDEV_AMP_FLAG, \
0060 .info = snd_hda_mixer_amp_switch_info, \
0061 .get = snd_hda_mixer_amp_switch_get, \
0062 .put = snd_hda_mixer_amp_switch_put, \
0063 .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, direction) }
0064
0065 #define HDA_CODEC_MUTE_IDX(xname, xcidx, nid, xindex, direction) \
0066 HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, 3, xindex, direction)
0067
0068 #define HDA_CODEC_MUTE_MONO(xname, nid, channel, xindex, direction) \
0069 HDA_CODEC_MUTE_MONO_IDX(xname, 0, nid, channel, xindex, direction)
0070
0071 #define HDA_CODEC_MUTE(xname, nid, xindex, direction) \
0072 HDA_CODEC_MUTE_MONO(xname, nid, 3, xindex, direction)
0073 #ifdef CONFIG_SND_HDA_INPUT_BEEP
0074
0075 #define HDA_CODEC_MUTE_BEEP_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
0076 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \
0077 .subdevice = HDA_SUBDEV_AMP_FLAG, \
0078 .info = snd_hda_mixer_amp_switch_info, \
0079 .get = snd_hda_mixer_amp_switch_get_beep, \
0080 .put = snd_hda_mixer_amp_switch_put_beep, \
0081 .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, direction) }
0082 #else
0083
0084 #define HDA_CODEC_MUTE_BEEP_MONO_IDX(xname, xcidx, nid, ch, xidx, dir) \
0085 HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, ch, xidx, dir)
0086 #endif
0087
0088 #define HDA_CODEC_MUTE_BEEP_MONO(xname, nid, channel, xindex, direction) \
0089 HDA_CODEC_MUTE_BEEP_MONO_IDX(xname, 0, nid, channel, xindex, direction)
0090
0091 #define HDA_CODEC_MUTE_BEEP(xname, nid, xindex, direction) \
0092 HDA_CODEC_MUTE_BEEP_MONO(xname, nid, 3, xindex, direction)
0093
0094 extern const char *snd_hda_pcm_type_name[];
0095
0096 int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
0097 struct snd_ctl_elem_info *uinfo);
0098 int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
0099 struct snd_ctl_elem_value *ucontrol);
0100 int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
0101 struct snd_ctl_elem_value *ucontrol);
0102 int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
0103 unsigned int size, unsigned int __user *_tlv);
0104 int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol,
0105 struct snd_ctl_elem_info *uinfo);
0106 int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
0107 struct snd_ctl_elem_value *ucontrol);
0108 int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
0109 struct snd_ctl_elem_value *ucontrol);
0110 #ifdef CONFIG_SND_HDA_INPUT_BEEP
0111 int snd_hda_mixer_amp_switch_get_beep(struct snd_kcontrol *kcontrol,
0112 struct snd_ctl_elem_value *ucontrol);
0113 int snd_hda_mixer_amp_switch_put_beep(struct snd_kcontrol *kcontrol,
0114 struct snd_ctl_elem_value *ucontrol);
0115 #endif
0116
0117 #define snd_hda_codec_amp_read(codec, nid, ch, dir, idx) \
0118 snd_hdac_regmap_get_amp(&(codec)->core, nid, ch, dir, idx)
0119 int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid,
0120 int ch, int dir, int idx, int mask, int val);
0121 int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid,
0122 int direction, int idx, int mask, int val);
0123 int snd_hda_codec_amp_init(struct hda_codec *codec, hda_nid_t nid, int ch,
0124 int direction, int idx, int mask, int val);
0125 int snd_hda_codec_amp_init_stereo(struct hda_codec *codec, hda_nid_t nid,
0126 int dir, int idx, int mask, int val);
0127 void snd_hda_set_vmaster_tlv(struct hda_codec *codec, hda_nid_t nid, int dir,
0128 unsigned int *tlv);
0129 struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
0130 const char *name);
0131 int __snd_hda_add_vmaster(struct hda_codec *codec, char *name,
0132 unsigned int *tlv, const char * const *followers,
0133 const char *suffix, bool init_follower_vol,
0134 unsigned int access, struct snd_kcontrol **ctl_ret);
0135 #define snd_hda_add_vmaster(codec, name, tlv, followers, suffix, access) \
0136 __snd_hda_add_vmaster(codec, name, tlv, followers, suffix, true, access, NULL)
0137 int snd_hda_codec_reset(struct hda_codec *codec);
0138 void snd_hda_codec_disconnect_pcms(struct hda_codec *codec);
0139
0140 #define snd_hda_regmap_sync(codec) snd_hdac_regmap_sync(&(codec)->core)
0141
0142 struct hda_vmaster_mute_hook {
0143
0144
0145
0146 struct snd_kcontrol *sw_kctl;
0147 void (*hook)(void *, int);
0148
0149 struct hda_codec *codec;
0150 };
0151
0152 int snd_hda_add_vmaster_hook(struct hda_codec *codec,
0153 struct hda_vmaster_mute_hook *hook);
0154 void snd_hda_sync_vmaster_hook(struct hda_vmaster_mute_hook *hook);
0155
0156
0157 #define HDA_AMP_MUTE 0x80
0158 #define HDA_AMP_UNMUTE 0x00
0159 #define HDA_AMP_VOLMASK 0x7f
0160
0161
0162
0163
0164 int snd_hda_create_dig_out_ctls(struct hda_codec *codec,
0165 hda_nid_t associated_nid,
0166 hda_nid_t cvt_nid, int type);
0167 #define snd_hda_create_spdif_out_ctls(codec, anid, cnid) \
0168 snd_hda_create_dig_out_ctls(codec, anid, cnid, HDA_PCM_TYPE_SPDIF)
0169 int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid);
0170
0171
0172
0173
0174 #define HDA_MAX_NUM_INPUTS 36
0175 struct hda_input_mux_item {
0176 char label[32];
0177 unsigned int index;
0178 };
0179 struct hda_input_mux {
0180 unsigned int num_items;
0181 struct hda_input_mux_item items[HDA_MAX_NUM_INPUTS];
0182 };
0183
0184 int snd_hda_input_mux_info(const struct hda_input_mux *imux,
0185 struct snd_ctl_elem_info *uinfo);
0186 int snd_hda_input_mux_put(struct hda_codec *codec,
0187 const struct hda_input_mux *imux,
0188 struct snd_ctl_elem_value *ucontrol, hda_nid_t nid,
0189 unsigned int *cur_val);
0190 int snd_hda_add_imux_item(struct hda_codec *codec,
0191 struct hda_input_mux *imux, const char *label,
0192 int index, int *type_idx);
0193
0194
0195
0196
0197
0198 enum { HDA_FRONT, HDA_REAR, HDA_CLFE, HDA_SIDE };
0199 enum { HDA_DIG_NONE, HDA_DIG_EXCLUSIVE, HDA_DIG_ANALOG_DUP };
0200
0201 #define HDA_MAX_OUTS 5
0202
0203 struct hda_multi_out {
0204 int num_dacs;
0205 const hda_nid_t *dac_nids;
0206 hda_nid_t hp_nid;
0207 hda_nid_t hp_out_nid[HDA_MAX_OUTS];
0208 hda_nid_t extra_out_nid[HDA_MAX_OUTS];
0209 hda_nid_t dig_out_nid;
0210 const hda_nid_t *follower_dig_outs;
0211 int max_channels;
0212 int dig_out_used;
0213 int no_share_stream;
0214 int share_spdif;
0215
0216 unsigned int analog_rates;
0217 unsigned int analog_maxbps;
0218 u64 analog_formats;
0219 unsigned int spdif_rates;
0220 unsigned int spdif_maxbps;
0221 u64 spdif_formats;
0222 };
0223
0224 int snd_hda_create_spdif_share_sw(struct hda_codec *codec,
0225 struct hda_multi_out *mout);
0226 int snd_hda_multi_out_dig_open(struct hda_codec *codec,
0227 struct hda_multi_out *mout);
0228 int snd_hda_multi_out_dig_close(struct hda_codec *codec,
0229 struct hda_multi_out *mout);
0230 int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
0231 struct hda_multi_out *mout,
0232 unsigned int stream_tag,
0233 unsigned int format,
0234 struct snd_pcm_substream *substream);
0235 int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec,
0236 struct hda_multi_out *mout);
0237 int snd_hda_multi_out_analog_open(struct hda_codec *codec,
0238 struct hda_multi_out *mout,
0239 struct snd_pcm_substream *substream,
0240 struct hda_pcm_stream *hinfo);
0241 int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
0242 struct hda_multi_out *mout,
0243 unsigned int stream_tag,
0244 unsigned int format,
0245 struct snd_pcm_substream *substream);
0246 int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,
0247 struct hda_multi_out *mout);
0248
0249
0250
0251
0252 #ifdef CONFIG_SND_PROC_FS
0253 int snd_hda_codec_proc_new(struct hda_codec *codec);
0254 #else
0255 static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; }
0256 #endif
0257
0258 #define SND_PRINT_BITS_ADVISED_BUFSIZE 16
0259 void snd_print_pcm_bits(int pcm, char *buf, int buflen);
0260
0261
0262
0263
0264 int snd_hda_add_new_ctls(struct hda_codec *codec,
0265 const struct snd_kcontrol_new *knew);
0266
0267
0268
0269
0270
0271 struct hda_pintbl {
0272 hda_nid_t nid;
0273 u32 val;
0274 };
0275
0276 struct hda_model_fixup {
0277 const int id;
0278 const char *name;
0279 };
0280
0281 struct hda_fixup {
0282 int type;
0283 bool chained:1;
0284 bool chained_before:1;
0285 int chain_id;
0286 union {
0287 const struct hda_pintbl *pins;
0288 const struct hda_verb *verbs;
0289 void (*func)(struct hda_codec *codec,
0290 const struct hda_fixup *fix,
0291 int action);
0292 } v;
0293 };
0294
0295 struct snd_hda_pin_quirk {
0296 unsigned int codec;
0297 unsigned short subvendor;
0298 const struct hda_pintbl *pins;
0299 #ifdef CONFIG_SND_DEBUG_VERBOSE
0300 const char *name;
0301 #endif
0302 int value;
0303 };
0304
0305 #ifdef CONFIG_SND_DEBUG_VERBOSE
0306
0307 #define SND_HDA_PIN_QUIRK(_codec, _subvendor, _name, _value, _pins...) \
0308 { .codec = _codec,\
0309 .subvendor = _subvendor,\
0310 .name = _name,\
0311 .value = _value,\
0312 .pins = (const struct hda_pintbl[]) { _pins, {0, 0}} \
0313 }
0314 #else
0315
0316 #define SND_HDA_PIN_QUIRK(_codec, _subvendor, _name, _value, _pins...) \
0317 { .codec = _codec,\
0318 .subvendor = _subvendor,\
0319 .value = _value,\
0320 .pins = (const struct hda_pintbl[]) { _pins, {0, 0}} \
0321 }
0322
0323 #endif
0324
0325 #define HDA_FIXUP_ID_NOT_SET -1
0326 #define HDA_FIXUP_ID_NO_FIXUP -2
0327
0328
0329 enum {
0330 HDA_FIXUP_INVALID,
0331 HDA_FIXUP_PINS,
0332 HDA_FIXUP_VERBS,
0333 HDA_FIXUP_FUNC,
0334 HDA_FIXUP_PINCTLS,
0335 };
0336
0337
0338 enum {
0339 HDA_FIXUP_ACT_PRE_PROBE,
0340 HDA_FIXUP_ACT_PROBE,
0341 HDA_FIXUP_ACT_INIT,
0342 HDA_FIXUP_ACT_BUILD,
0343 HDA_FIXUP_ACT_FREE,
0344 };
0345
0346 int snd_hda_add_verbs(struct hda_codec *codec, const struct hda_verb *list);
0347 void snd_hda_apply_verbs(struct hda_codec *codec);
0348 void snd_hda_apply_pincfgs(struct hda_codec *codec,
0349 const struct hda_pintbl *cfg);
0350 void snd_hda_apply_fixup(struct hda_codec *codec, int action);
0351 void __snd_hda_apply_fixup(struct hda_codec *codec, int id, int action, int depth);
0352 void snd_hda_pick_fixup(struct hda_codec *codec,
0353 const struct hda_model_fixup *models,
0354 const struct snd_pci_quirk *quirk,
0355 const struct hda_fixup *fixlist);
0356 void snd_hda_pick_pin_fixup(struct hda_codec *codec,
0357 const struct snd_hda_pin_quirk *pin_quirk,
0358 const struct hda_fixup *fixlist,
0359 bool match_all_pins);
0360
0361
0362 #define get_defcfg_connect(cfg) \
0363 ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT)
0364 #define get_defcfg_association(cfg) \
0365 ((cfg & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT)
0366 #define get_defcfg_location(cfg) \
0367 ((cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT)
0368 #define get_defcfg_sequence(cfg) \
0369 (cfg & AC_DEFCFG_SEQUENCE)
0370 #define get_defcfg_device(cfg) \
0371 ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT)
0372 #define get_defcfg_misc(cfg) \
0373 ((cfg & AC_DEFCFG_MISC) >> AC_DEFCFG_MISC_SHIFT)
0374
0375
0376 #define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8))
0377 #define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8))
0378 #define AMP_OUT_MUTE 0xb080
0379 #define AMP_OUT_UNMUTE 0xb000
0380 #define AMP_OUT_ZERO 0xb000
0381
0382 #define PIN_IN (AC_PINCTL_IN_EN)
0383 #define PIN_VREFHIZ (AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ)
0384 #define PIN_VREF50 (AC_PINCTL_IN_EN | AC_PINCTL_VREF_50)
0385 #define PIN_VREFGRD (AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD)
0386 #define PIN_VREF80 (AC_PINCTL_IN_EN | AC_PINCTL_VREF_80)
0387 #define PIN_VREF100 (AC_PINCTL_IN_EN | AC_PINCTL_VREF_100)
0388 #define PIN_OUT (AC_PINCTL_OUT_EN)
0389 #define PIN_HP (AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN)
0390 #define PIN_HP_AMP (AC_PINCTL_HP_EN)
0391
0392 unsigned int snd_hda_get_default_vref(struct hda_codec *codec, hda_nid_t pin);
0393 unsigned int snd_hda_correct_pin_ctl(struct hda_codec *codec,
0394 hda_nid_t pin, unsigned int val);
0395 int _snd_hda_set_pin_ctl(struct hda_codec *codec, hda_nid_t pin,
0396 unsigned int val, bool cached);
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413 static inline int
0414 snd_hda_set_pin_ctl(struct hda_codec *codec, hda_nid_t pin, unsigned int val)
0415 {
0416 return _snd_hda_set_pin_ctl(codec, pin, val, false);
0417 }
0418
0419
0420
0421
0422
0423
0424
0425
0426
0427 static inline int
0428 snd_hda_set_pin_ctl_cache(struct hda_codec *codec, hda_nid_t pin,
0429 unsigned int val)
0430 {
0431 return _snd_hda_set_pin_ctl(codec, pin, val, true);
0432 }
0433
0434 int snd_hda_codec_get_pin_target(struct hda_codec *codec, hda_nid_t nid);
0435 int snd_hda_codec_set_pin_target(struct hda_codec *codec, hda_nid_t nid,
0436 unsigned int val);
0437
0438 #define for_each_hda_codec_node(nid, codec) \
0439 for ((nid) = (codec)->core.start_nid; (nid) < (codec)->core.end_nid; (nid)++)
0440
0441
0442
0443
0444
0445 static inline void snd_hda_codec_allow_unsol_events(struct hda_codec *codec)
0446 {
0447 codec->core.dev.power.power_state = PMSG_ON;
0448 }
0449
0450
0451
0452
0453 static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
0454 {
0455 if (nid < codec->core.start_nid ||
0456 nid >= codec->core.start_nid + codec->core.num_nodes)
0457 return 0;
0458 return codec->wcaps[nid - codec->core.start_nid];
0459 }
0460
0461
0462 static inline int get_wcaps_type(unsigned int wcaps)
0463 {
0464 if (!wcaps)
0465 return -1;
0466 return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
0467 }
0468
0469 static inline unsigned int get_wcaps_channels(u32 wcaps)
0470 {
0471 unsigned int chans;
0472
0473 chans = (wcaps & AC_WCAP_CHAN_CNT_EXT) >> 13;
0474 chans = ((chans << 1) | 1) + 1;
0475
0476 return chans;
0477 }
0478
0479 static inline void snd_hda_override_wcaps(struct hda_codec *codec,
0480 hda_nid_t nid, u32 val)
0481 {
0482 if (nid >= codec->core.start_nid &&
0483 nid < codec->core.start_nid + codec->core.num_nodes)
0484 codec->wcaps[nid - codec->core.start_nid] = val;
0485 }
0486
0487 u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction);
0488 int snd_hda_override_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir,
0489 unsigned int caps);
0490
0491
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501 static inline u32
0502 snd_hda_query_pin_caps(struct hda_codec *codec, hda_nid_t nid)
0503 {
0504 return snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
0505
0506 }
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518 static inline int
0519 snd_hda_override_pin_caps(struct hda_codec *codec, hda_nid_t nid,
0520 unsigned int caps)
0521 {
0522 return snd_hdac_override_parm(&codec->core, nid, AC_PAR_PIN_CAP, caps);
0523 }
0524
0525 bool snd_hda_check_amp_caps(struct hda_codec *codec, hda_nid_t nid,
0526 int dir, unsigned int bits);
0527
0528 #define nid_has_mute(codec, nid, dir) \
0529 snd_hda_check_amp_caps(codec, nid, dir, (AC_AMPCAP_MUTE | AC_AMPCAP_MIN_MUTE))
0530 #define nid_has_volume(codec, nid, dir) \
0531 snd_hda_check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS)
0532
0533
0534
0535 #define HDA_NID_ITEM_AMP (1<<0)
0536
0537 struct hda_nid_item {
0538 struct snd_kcontrol *kctl;
0539 unsigned int index;
0540 hda_nid_t nid;
0541 unsigned short flags;
0542 };
0543
0544 int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid,
0545 struct snd_kcontrol *kctl);
0546 int snd_hda_add_nid(struct hda_codec *codec, struct snd_kcontrol *kctl,
0547 unsigned int index, hda_nid_t nid);
0548 void snd_hda_ctls_clear(struct hda_codec *codec);
0549
0550
0551
0552
0553 #ifdef CONFIG_SND_HDA_HWDEP
0554 int snd_hda_create_hwdep(struct hda_codec *codec);
0555 #else
0556 static inline int snd_hda_create_hwdep(struct hda_codec *codec) { return 0; }
0557 #endif
0558
0559 void snd_hda_sysfs_init(struct hda_codec *codec);
0560 void snd_hda_sysfs_clear(struct hda_codec *codec);
0561
0562 extern const struct attribute_group *snd_hda_dev_attr_groups[];
0563
0564 #ifdef CONFIG_SND_HDA_RECONFIG
0565 const char *snd_hda_get_hint(struct hda_codec *codec, const char *key);
0566 int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key);
0567 int snd_hda_get_int_hint(struct hda_codec *codec, const char *key, int *valp);
0568 #else
0569 static inline
0570 const char *snd_hda_get_hint(struct hda_codec *codec, const char *key)
0571 {
0572 return NULL;
0573 }
0574
0575 static inline
0576 int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key)
0577 {
0578 return -ENOENT;
0579 }
0580
0581 static inline
0582 int snd_hda_get_int_hint(struct hda_codec *codec, const char *key, int *valp)
0583 {
0584 return -ENOENT;
0585 }
0586 #endif
0587
0588
0589
0590
0591
0592 void snd_hda_schedule_power_save(struct hda_codec *codec);
0593
0594 struct hda_amp_list {
0595 hda_nid_t nid;
0596 unsigned char dir;
0597 unsigned char idx;
0598 };
0599
0600 struct hda_loopback_check {
0601 const struct hda_amp_list *amplist;
0602 int power_on;
0603 };
0604
0605 int snd_hda_check_amp_list_power(struct hda_codec *codec,
0606 struct hda_loopback_check *check,
0607 hda_nid_t nid);
0608
0609
0610 static inline bool
0611 snd_hda_check_power_state(struct hda_codec *codec, hda_nid_t nid,
0612 unsigned int target_state)
0613 {
0614 return snd_hdac_check_power_state(&codec->core, nid, target_state);
0615 }
0616
0617 static inline unsigned int snd_hda_sync_power_state(struct hda_codec *codec,
0618 hda_nid_t nid,
0619 unsigned int target_state)
0620 {
0621 return snd_hdac_sync_power_state(&codec->core, nid, target_state);
0622 }
0623 unsigned int snd_hda_codec_eapd_power_filter(struct hda_codec *codec,
0624 hda_nid_t nid,
0625 unsigned int power_state);
0626
0627 void snd_hda_codec_shutdown(struct hda_codec *codec);
0628
0629
0630
0631
0632
0633 #define get_amp_nid_(pv) ((pv) & 0xffff)
0634 #define get_amp_nid(kc) get_amp_nid_((kc)->private_value)
0635 #define get_amp_channels(kc) (((kc)->private_value >> 16) & 0x3)
0636 #define get_amp_direction_(pv) (((pv) >> 18) & 0x1)
0637 #define get_amp_direction(kc) get_amp_direction_((kc)->private_value)
0638 #define get_amp_index_(pv) (((pv) >> 19) & 0xf)
0639 #define get_amp_index(kc) get_amp_index_((kc)->private_value)
0640 #define get_amp_offset(kc) (((kc)->private_value >> 23) & 0x3f)
0641 #define get_amp_min_mute(kc) (((kc)->private_value >> 29) & 0x1)
0642
0643
0644
0645
0646 int snd_hda_enum_helper_info(struct snd_kcontrol *kcontrol,
0647 struct snd_ctl_elem_info *uinfo,
0648 int num_items, const char * const *texts);
0649 #define snd_hda_enum_bool_helper_info(kcontrol, uinfo) \
0650 snd_hda_enum_helper_info(kcontrol, uinfo, 0, NULL)
0651
0652
0653
0654
0655 struct cea_sad {
0656 int channels;
0657 int format;
0658 int rates;
0659 int sample_bits;
0660 int max_bitrate;
0661 int profile;
0662 };
0663
0664 #define ELD_FIXED_BYTES 20
0665 #define ELD_MAX_SIZE 256
0666 #define ELD_MAX_MNL 16
0667 #define ELD_MAX_SAD 16
0668
0669
0670
0671
0672 struct parsed_hdmi_eld {
0673
0674
0675
0676 int baseline_len;
0677 int eld_ver;
0678 int cea_edid_ver;
0679 char monitor_name[ELD_MAX_MNL + 1];
0680 int manufacture_id;
0681 int product_id;
0682 u64 port_id;
0683 int support_hdcp;
0684 int support_ai;
0685 int conn_type;
0686 int aud_synch_delay;
0687 int spk_alloc;
0688 int sad_count;
0689 struct cea_sad sad[ELD_MAX_SAD];
0690 };
0691
0692 struct hdmi_eld {
0693 bool monitor_present;
0694 bool eld_valid;
0695 int eld_size;
0696 char eld_buffer[ELD_MAX_SIZE];
0697 struct parsed_hdmi_eld info;
0698 };
0699
0700 int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid);
0701 int snd_hdmi_get_eld(struct hda_codec *codec, hda_nid_t nid,
0702 unsigned char *buf, int *eld_size);
0703 int snd_hdmi_parse_eld(struct hda_codec *codec, struct parsed_hdmi_eld *e,
0704 const unsigned char *buf, int size);
0705 void snd_hdmi_show_eld(struct hda_codec *codec, struct parsed_hdmi_eld *e);
0706 void snd_hdmi_eld_update_pcm_info(struct parsed_hdmi_eld *e,
0707 struct hda_pcm_stream *hinfo);
0708
0709 int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid,
0710 unsigned char *buf, int *eld_size,
0711 bool rev3_or_later);
0712
0713 #ifdef CONFIG_SND_PROC_FS
0714 void snd_hdmi_print_eld_info(struct hdmi_eld *eld,
0715 struct snd_info_buffer *buffer);
0716 void snd_hdmi_write_eld_info(struct hdmi_eld *eld,
0717 struct snd_info_buffer *buffer);
0718 #endif
0719
0720 #define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
0721 void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
0722
0723 void snd_hda_codec_display_power(struct hda_codec *codec, bool enable);
0724
0725
0726
0727 #define codec_err(codec, fmt, args...) \
0728 dev_err(hda_codec_dev(codec), fmt, ##args)
0729 #define codec_warn(codec, fmt, args...) \
0730 dev_warn(hda_codec_dev(codec), fmt, ##args)
0731 #define codec_info(codec, fmt, args...) \
0732 dev_info(hda_codec_dev(codec), fmt, ##args)
0733 #define codec_dbg(codec, fmt, args...) \
0734 dev_dbg(hda_codec_dev(codec), fmt, ##args)
0735
0736 #endif