xref: /linux/sound/pci/hda/hda_auto_parser.h (revision 64e05321)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * BIOS auto-parser helper functions for HD-audio
4  *
5  * Copyright (c) 2012 Takashi Iwai <tiwai@suse.de>
6  */
7 
8 #ifndef __SOUND_HDA_AUTO_PARSER_H
9 #define __SOUND_HDA_AUTO_PARSER_H
10 
11 #include "hda_local.h"
12 
13 /*
14  * Helper for automatic pin configuration
15  */
16 
17 enum {
18 	AUTO_PIN_MIC,
19 	AUTO_PIN_LINE_IN,
20 	AUTO_PIN_CD,
21 	AUTO_PIN_AUX,
22 	AUTO_PIN_LAST
23 };
24 
25 enum {
26 	AUTO_PIN_LINE_OUT,
27 	AUTO_PIN_SPEAKER_OUT,
28 	AUTO_PIN_HP_OUT
29 };
30 
31 #define AUTO_CFG_MAX_OUTS	HDA_MAX_OUTS
32 #define AUTO_CFG_MAX_INS	18
33 
34 struct auto_pin_cfg_item {
35 	hda_nid_t pin;
36 	int type;
37 	unsigned int is_headset_mic:1;
38 	unsigned int is_headphone_mic:1; /* Mic-only in headphone jack */
39 	unsigned int has_boost_on_pin:1;
40 };
41 
42 struct auto_pin_cfg;
43 const char *hda_get_autocfg_input_label(struct hda_codec *codec,
44 					const struct auto_pin_cfg *cfg,
45 					int input);
46 int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
47 			  const struct auto_pin_cfg *cfg,
48 			  char *label, int maxlen, int *indexp);
49 
50 enum {
51 	INPUT_PIN_ATTR_UNUSED,	/* pin not connected */
52 	INPUT_PIN_ATTR_INT,	/* internal mic/line-in */
53 	INPUT_PIN_ATTR_DOCK,	/* docking mic/line-in */
54 	INPUT_PIN_ATTR_NORMAL,	/* mic/line-in jack */
55 	INPUT_PIN_ATTR_REAR,	/* mic/line-in jack in rear */
56 	INPUT_PIN_ATTR_FRONT,	/* mic/line-in jack in front */
57 	INPUT_PIN_ATTR_LAST = INPUT_PIN_ATTR_FRONT,
58 };
59 
60 int snd_hda_get_input_pin_attr(unsigned int def_conf);
61 
62 struct auto_pin_cfg {
63 	int line_outs;
64 	/* sorted in the order of Front/Surr/CLFE/Side */
65 	hda_nid_t line_out_pins[AUTO_CFG_MAX_OUTS];
66 	int speaker_outs;
67 	hda_nid_t speaker_pins[AUTO_CFG_MAX_OUTS];
68 	int hp_outs;
69 	int line_out_type;	/* AUTO_PIN_XXX_OUT */
70 	hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS];
71 	int num_inputs;
72 	struct auto_pin_cfg_item inputs[AUTO_CFG_MAX_INS];
73 	int dig_outs;
74 	hda_nid_t dig_out_pins[2];
75 	hda_nid_t dig_in_pin;
76 	hda_nid_t mono_out_pin;
77 	int dig_out_type[2]; /* HDA_PCM_TYPE_XXX */
78 	int dig_in_type; /* HDA_PCM_TYPE_XXX */
79 };
80 
81 /* bit-flags for snd_hda_parse_pin_def_config() behavior */
82 #define HDA_PINCFG_NO_HP_FIXUP   (1 << 0) /* no HP-split */
83 #define HDA_PINCFG_NO_LO_FIXUP   (1 << 1) /* don't take other outs as LO */
84 #define HDA_PINCFG_HEADSET_MIC   (1 << 2) /* Try to find headset mic; mark seq number as 0xc to trigger */
85 #define HDA_PINCFG_HEADPHONE_MIC (1 << 3) /* Try to find headphone mic; mark seq number as 0xd to trigger */
86 
87 int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
88 			     struct auto_pin_cfg *cfg,
89 			     const hda_nid_t *ignore_nids,
90 			     unsigned int cond_flags);
91 
92 /* older function */
93 #define snd_hda_parse_pin_def_config(codec, cfg, ignore) \
94 	snd_hda_parse_pin_defcfg(codec, cfg, ignore, 0)
95 
auto_cfg_hp_outs(const struct auto_pin_cfg * cfg)96 static inline int auto_cfg_hp_outs(const struct auto_pin_cfg *cfg)
97 {
98 	return (cfg->line_out_type == AUTO_PIN_HP_OUT) ?
99 	       cfg->line_outs : cfg->hp_outs;
100 }
auto_cfg_hp_pins(const struct auto_pin_cfg * cfg)101 static inline const hda_nid_t *auto_cfg_hp_pins(const struct auto_pin_cfg *cfg)
102 {
103 	return (cfg->line_out_type == AUTO_PIN_HP_OUT) ?
104 	       cfg->line_out_pins : cfg->hp_pins;
105 }
auto_cfg_speaker_outs(const struct auto_pin_cfg * cfg)106 static inline int auto_cfg_speaker_outs(const struct auto_pin_cfg *cfg)
107 {
108 	return (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) ?
109 	       cfg->line_outs : cfg->speaker_outs;
110 }
auto_cfg_speaker_pins(const struct auto_pin_cfg * cfg)111 static inline const hda_nid_t *auto_cfg_speaker_pins(const struct auto_pin_cfg *cfg)
112 {
113 	return (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) ?
114 	       cfg->line_out_pins : cfg->speaker_pins;
115 }
116 
117 #endif /* __SOUND_HDA_AUTO_PARSER_H */
118