162810dbdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 223d30f28STakashi Iwai /* 323d30f28STakashi Iwai * BIOS auto-parser helper functions for HD-audio 423d30f28STakashi Iwai * 523d30f28STakashi Iwai * Copyright (c) 2012 Takashi Iwai <tiwai@suse.de> 623d30f28STakashi Iwai */ 723d30f28STakashi Iwai 823d30f28STakashi Iwai #ifndef __SOUND_HDA_AUTO_PARSER_H 923d30f28STakashi Iwai #define __SOUND_HDA_AUTO_PARSER_H 1023d30f28STakashi Iwai 11128bc4baSTakashi Iwai /* 12128bc4baSTakashi Iwai * Helper for automatic pin configuration 13128bc4baSTakashi Iwai */ 14128bc4baSTakashi Iwai 15128bc4baSTakashi Iwai enum { 16128bc4baSTakashi Iwai AUTO_PIN_MIC, 17128bc4baSTakashi Iwai AUTO_PIN_LINE_IN, 18128bc4baSTakashi Iwai AUTO_PIN_CD, 19128bc4baSTakashi Iwai AUTO_PIN_AUX, 20128bc4baSTakashi Iwai AUTO_PIN_LAST 21128bc4baSTakashi Iwai }; 22128bc4baSTakashi Iwai 23128bc4baSTakashi Iwai enum { 24128bc4baSTakashi Iwai AUTO_PIN_LINE_OUT, 25128bc4baSTakashi Iwai AUTO_PIN_SPEAKER_OUT, 26128bc4baSTakashi Iwai AUTO_PIN_HP_OUT 27128bc4baSTakashi Iwai }; 28128bc4baSTakashi Iwai 29128bc4baSTakashi Iwai #define AUTO_CFG_MAX_OUTS HDA_MAX_OUTS 30*b95a913cSVitaly Rodionov #define AUTO_CFG_MAX_INS 18 31128bc4baSTakashi Iwai 32128bc4baSTakashi Iwai struct auto_pin_cfg_item { 33128bc4baSTakashi Iwai hda_nid_t pin; 34128bc4baSTakashi Iwai int type; 35a385d97bSDavid Henningsson unsigned int is_headset_mic:1; 36cb420b11SDavid Henningsson unsigned int is_headphone_mic:1; /* Mic-only in headphone jack */ 3795f72cf2SDavid Henningsson unsigned int has_boost_on_pin:1; 38128bc4baSTakashi Iwai }; 39128bc4baSTakashi Iwai 40128bc4baSTakashi Iwai struct auto_pin_cfg; 41128bc4baSTakashi Iwai const char *hda_get_autocfg_input_label(struct hda_codec *codec, 42128bc4baSTakashi Iwai const struct auto_pin_cfg *cfg, 43128bc4baSTakashi Iwai int input); 44128bc4baSTakashi Iwai int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid, 45128bc4baSTakashi Iwai const struct auto_pin_cfg *cfg, 46128bc4baSTakashi Iwai char *label, int maxlen, int *indexp); 47128bc4baSTakashi Iwai 48128bc4baSTakashi Iwai enum { 49128bc4baSTakashi Iwai INPUT_PIN_ATTR_UNUSED, /* pin not connected */ 50128bc4baSTakashi Iwai INPUT_PIN_ATTR_INT, /* internal mic/line-in */ 51128bc4baSTakashi Iwai INPUT_PIN_ATTR_DOCK, /* docking mic/line-in */ 52128bc4baSTakashi Iwai INPUT_PIN_ATTR_NORMAL, /* mic/line-in jack */ 53128bc4baSTakashi Iwai INPUT_PIN_ATTR_REAR, /* mic/line-in jack in rear */ 545ec16d12STakashi Iwai INPUT_PIN_ATTR_FRONT, /* mic/line-in jack in front */ 555ec16d12STakashi Iwai INPUT_PIN_ATTR_LAST = INPUT_PIN_ATTR_FRONT, 56128bc4baSTakashi Iwai }; 57128bc4baSTakashi Iwai 58128bc4baSTakashi Iwai int snd_hda_get_input_pin_attr(unsigned int def_conf); 59128bc4baSTakashi Iwai 60128bc4baSTakashi Iwai struct auto_pin_cfg { 61128bc4baSTakashi Iwai int line_outs; 62128bc4baSTakashi Iwai /* sorted in the order of Front/Surr/CLFE/Side */ 63128bc4baSTakashi Iwai hda_nid_t line_out_pins[AUTO_CFG_MAX_OUTS]; 64128bc4baSTakashi Iwai int speaker_outs; 65128bc4baSTakashi Iwai hda_nid_t speaker_pins[AUTO_CFG_MAX_OUTS]; 66128bc4baSTakashi Iwai int hp_outs; 67128bc4baSTakashi Iwai int line_out_type; /* AUTO_PIN_XXX_OUT */ 68128bc4baSTakashi Iwai hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS]; 69128bc4baSTakashi Iwai int num_inputs; 70128bc4baSTakashi Iwai struct auto_pin_cfg_item inputs[AUTO_CFG_MAX_INS]; 71128bc4baSTakashi Iwai int dig_outs; 72128bc4baSTakashi Iwai hda_nid_t dig_out_pins[2]; 73128bc4baSTakashi Iwai hda_nid_t dig_in_pin; 74128bc4baSTakashi Iwai hda_nid_t mono_out_pin; 75128bc4baSTakashi Iwai int dig_out_type[2]; /* HDA_PCM_TYPE_XXX */ 76128bc4baSTakashi Iwai int dig_in_type; /* HDA_PCM_TYPE_XXX */ 77128bc4baSTakashi Iwai }; 78128bc4baSTakashi Iwai 79128bc4baSTakashi Iwai /* bit-flags for snd_hda_parse_pin_def_config() behavior */ 80128bc4baSTakashi Iwai #define HDA_PINCFG_NO_HP_FIXUP (1 << 0) /* no HP-split */ 81128bc4baSTakashi Iwai #define HDA_PINCFG_NO_LO_FIXUP (1 << 1) /* don't take other outs as LO */ 82cb420b11SDavid Henningsson #define HDA_PINCFG_HEADSET_MIC (1 << 2) /* Try to find headset mic; mark seq number as 0xc to trigger */ 83cb420b11SDavid Henningsson #define HDA_PINCFG_HEADPHONE_MIC (1 << 3) /* Try to find headphone mic; mark seq number as 0xd to trigger */ 84128bc4baSTakashi Iwai 85128bc4baSTakashi Iwai int snd_hda_parse_pin_defcfg(struct hda_codec *codec, 86128bc4baSTakashi Iwai struct auto_pin_cfg *cfg, 87128bc4baSTakashi Iwai const hda_nid_t *ignore_nids, 88128bc4baSTakashi Iwai unsigned int cond_flags); 89128bc4baSTakashi Iwai 90128bc4baSTakashi Iwai /* older function */ 91128bc4baSTakashi Iwai #define snd_hda_parse_pin_def_config(codec, cfg, ignore) \ 92128bc4baSTakashi Iwai snd_hda_parse_pin_defcfg(codec, cfg, ignore, 0) 93128bc4baSTakashi Iwai 943cdbe11aSDavid Henningsson static inline int auto_cfg_hp_outs(const struct auto_pin_cfg *cfg) 953cdbe11aSDavid Henningsson { 963cdbe11aSDavid Henningsson return (cfg->line_out_type == AUTO_PIN_HP_OUT) ? 973cdbe11aSDavid Henningsson cfg->line_outs : cfg->hp_outs; 983cdbe11aSDavid Henningsson } 993cdbe11aSDavid Henningsson static inline const hda_nid_t *auto_cfg_hp_pins(const struct auto_pin_cfg *cfg) 1003cdbe11aSDavid Henningsson { 1013cdbe11aSDavid Henningsson return (cfg->line_out_type == AUTO_PIN_HP_OUT) ? 1023cdbe11aSDavid Henningsson cfg->line_out_pins : cfg->hp_pins; 1033cdbe11aSDavid Henningsson } 1043cdbe11aSDavid Henningsson static inline int auto_cfg_speaker_outs(const struct auto_pin_cfg *cfg) 1053cdbe11aSDavid Henningsson { 1063cdbe11aSDavid Henningsson return (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) ? 1073cdbe11aSDavid Henningsson cfg->line_outs : cfg->speaker_outs; 1083cdbe11aSDavid Henningsson } 1093cdbe11aSDavid Henningsson static inline const hda_nid_t *auto_cfg_speaker_pins(const struct auto_pin_cfg *cfg) 1103cdbe11aSDavid Henningsson { 1113cdbe11aSDavid Henningsson return (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) ? 1123cdbe11aSDavid Henningsson cfg->line_out_pins : cfg->speaker_pins; 1133cdbe11aSDavid Henningsson } 1143cdbe11aSDavid Henningsson 11523d30f28STakashi Iwai #endif /* __SOUND_HDA_AUTO_PARSER_H */ 116