hda_auto_parser.h 3.3 KB

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