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