18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * BIOS auto-parser helper functions for HD-audio 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2012 Takashi Iwai <tiwai@suse.de> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef __SOUND_HDA_AUTO_PARSER_H 98c2ecf20Sopenharmony_ci#define __SOUND_HDA_AUTO_PARSER_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci/* 128c2ecf20Sopenharmony_ci * Helper for automatic pin configuration 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cienum { 168c2ecf20Sopenharmony_ci AUTO_PIN_MIC, 178c2ecf20Sopenharmony_ci AUTO_PIN_LINE_IN, 188c2ecf20Sopenharmony_ci AUTO_PIN_CD, 198c2ecf20Sopenharmony_ci AUTO_PIN_AUX, 208c2ecf20Sopenharmony_ci AUTO_PIN_LAST 218c2ecf20Sopenharmony_ci}; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cienum { 248c2ecf20Sopenharmony_ci AUTO_PIN_LINE_OUT, 258c2ecf20Sopenharmony_ci AUTO_PIN_SPEAKER_OUT, 268c2ecf20Sopenharmony_ci AUTO_PIN_HP_OUT 278c2ecf20Sopenharmony_ci}; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define AUTO_CFG_MAX_OUTS HDA_MAX_OUTS 308c2ecf20Sopenharmony_ci#define AUTO_CFG_MAX_INS 8 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistruct auto_pin_cfg_item { 338c2ecf20Sopenharmony_ci hda_nid_t pin; 348c2ecf20Sopenharmony_ci int type; 358c2ecf20Sopenharmony_ci unsigned int is_headset_mic:1; 368c2ecf20Sopenharmony_ci unsigned int is_headphone_mic:1; /* Mic-only in headphone jack */ 378c2ecf20Sopenharmony_ci unsigned int has_boost_on_pin:1; 388c2ecf20Sopenharmony_ci}; 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistruct auto_pin_cfg; 418c2ecf20Sopenharmony_ciconst char *hda_get_autocfg_input_label(struct hda_codec *codec, 428c2ecf20Sopenharmony_ci const struct auto_pin_cfg *cfg, 438c2ecf20Sopenharmony_ci int input); 448c2ecf20Sopenharmony_ciint snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid, 458c2ecf20Sopenharmony_ci const struct auto_pin_cfg *cfg, 468c2ecf20Sopenharmony_ci char *label, int maxlen, int *indexp); 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cienum { 498c2ecf20Sopenharmony_ci INPUT_PIN_ATTR_UNUSED, /* pin not connected */ 508c2ecf20Sopenharmony_ci INPUT_PIN_ATTR_INT, /* internal mic/line-in */ 518c2ecf20Sopenharmony_ci INPUT_PIN_ATTR_DOCK, /* docking mic/line-in */ 528c2ecf20Sopenharmony_ci INPUT_PIN_ATTR_NORMAL, /* mic/line-in jack */ 538c2ecf20Sopenharmony_ci INPUT_PIN_ATTR_REAR, /* mic/line-in jack in rear */ 548c2ecf20Sopenharmony_ci INPUT_PIN_ATTR_FRONT, /* mic/line-in jack in front */ 558c2ecf20Sopenharmony_ci INPUT_PIN_ATTR_LAST = INPUT_PIN_ATTR_FRONT, 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ciint snd_hda_get_input_pin_attr(unsigned int def_conf); 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistruct auto_pin_cfg { 618c2ecf20Sopenharmony_ci int line_outs; 628c2ecf20Sopenharmony_ci /* sorted in the order of Front/Surr/CLFE/Side */ 638c2ecf20Sopenharmony_ci hda_nid_t line_out_pins[AUTO_CFG_MAX_OUTS]; 648c2ecf20Sopenharmony_ci int speaker_outs; 658c2ecf20Sopenharmony_ci hda_nid_t speaker_pins[AUTO_CFG_MAX_OUTS]; 668c2ecf20Sopenharmony_ci int hp_outs; 678c2ecf20Sopenharmony_ci int line_out_type; /* AUTO_PIN_XXX_OUT */ 688c2ecf20Sopenharmony_ci hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS]; 698c2ecf20Sopenharmony_ci int num_inputs; 708c2ecf20Sopenharmony_ci struct auto_pin_cfg_item inputs[AUTO_CFG_MAX_INS]; 718c2ecf20Sopenharmony_ci int dig_outs; 728c2ecf20Sopenharmony_ci hda_nid_t dig_out_pins[2]; 738c2ecf20Sopenharmony_ci hda_nid_t dig_in_pin; 748c2ecf20Sopenharmony_ci hda_nid_t mono_out_pin; 758c2ecf20Sopenharmony_ci int dig_out_type[2]; /* HDA_PCM_TYPE_XXX */ 768c2ecf20Sopenharmony_ci int dig_in_type; /* HDA_PCM_TYPE_XXX */ 778c2ecf20Sopenharmony_ci}; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* bit-flags for snd_hda_parse_pin_def_config() behavior */ 808c2ecf20Sopenharmony_ci#define HDA_PINCFG_NO_HP_FIXUP (1 << 0) /* no HP-split */ 818c2ecf20Sopenharmony_ci#define HDA_PINCFG_NO_LO_FIXUP (1 << 1) /* don't take other outs as LO */ 828c2ecf20Sopenharmony_ci#define HDA_PINCFG_HEADSET_MIC (1 << 2) /* Try to find headset mic; mark seq number as 0xc to trigger */ 838c2ecf20Sopenharmony_ci#define HDA_PINCFG_HEADPHONE_MIC (1 << 3) /* Try to find headphone mic; mark seq number as 0xd to trigger */ 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ciint snd_hda_parse_pin_defcfg(struct hda_codec *codec, 868c2ecf20Sopenharmony_ci struct auto_pin_cfg *cfg, 878c2ecf20Sopenharmony_ci const hda_nid_t *ignore_nids, 888c2ecf20Sopenharmony_ci unsigned int cond_flags); 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci/* older function */ 918c2ecf20Sopenharmony_ci#define snd_hda_parse_pin_def_config(codec, cfg, ignore) \ 928c2ecf20Sopenharmony_ci snd_hda_parse_pin_defcfg(codec, cfg, ignore, 0) 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_cistatic inline int auto_cfg_hp_outs(const struct auto_pin_cfg *cfg) 958c2ecf20Sopenharmony_ci{ 968c2ecf20Sopenharmony_ci return (cfg->line_out_type == AUTO_PIN_HP_OUT) ? 978c2ecf20Sopenharmony_ci cfg->line_outs : cfg->hp_outs; 988c2ecf20Sopenharmony_ci} 998c2ecf20Sopenharmony_cistatic inline const hda_nid_t *auto_cfg_hp_pins(const struct auto_pin_cfg *cfg) 1008c2ecf20Sopenharmony_ci{ 1018c2ecf20Sopenharmony_ci return (cfg->line_out_type == AUTO_PIN_HP_OUT) ? 1028c2ecf20Sopenharmony_ci cfg->line_out_pins : cfg->hp_pins; 1038c2ecf20Sopenharmony_ci} 1048c2ecf20Sopenharmony_cistatic inline int auto_cfg_speaker_outs(const struct auto_pin_cfg *cfg) 1058c2ecf20Sopenharmony_ci{ 1068c2ecf20Sopenharmony_ci return (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) ? 1078c2ecf20Sopenharmony_ci cfg->line_outs : cfg->speaker_outs; 1088c2ecf20Sopenharmony_ci} 1098c2ecf20Sopenharmony_cistatic inline const hda_nid_t *auto_cfg_speaker_pins(const struct auto_pin_cfg *cfg) 1108c2ecf20Sopenharmony_ci{ 1118c2ecf20Sopenharmony_ci return (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) ? 1128c2ecf20Sopenharmony_ci cfg->line_out_pins : cfg->speaker_pins; 1138c2ecf20Sopenharmony_ci} 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci#endif /* __SOUND_HDA_AUTO_PARSER_H */ 116