hda_auto_parser.h 3.3 KB

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