hda_auto_parser.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. #ifndef __SOUND_HDA_AUTO_PARSER_H
  12. #define __SOUND_HDA_AUTO_PARSER_H
  13. /*
  14. * Helper for automatic pin configuration
  15. */
  16. enum {
  17. AUTO_PIN_MIC,
  18. AUTO_PIN_LINE_IN,
  19. AUTO_PIN_CD,
  20. AUTO_PIN_AUX,
  21. AUTO_PIN_LAST
  22. };
  23. enum {
  24. AUTO_PIN_LINE_OUT,
  25. AUTO_PIN_SPEAKER_OUT,
  26. AUTO_PIN_HP_OUT
  27. };
  28. #define AUTO_CFG_MAX_OUTS HDA_MAX_OUTS
  29. #define AUTO_CFG_MAX_INS 8
  30. struct auto_pin_cfg_item {
  31. hda_nid_t pin;
  32. int type;
  33. };
  34. struct auto_pin_cfg;
  35. const char *hda_get_autocfg_input_label(struct hda_codec *codec,
  36. const struct auto_pin_cfg *cfg,
  37. int input);
  38. int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid,
  39. const struct auto_pin_cfg *cfg,
  40. char *label, int maxlen, int *indexp);
  41. enum {
  42. INPUT_PIN_ATTR_UNUSED, /* pin not connected */
  43. INPUT_PIN_ATTR_INT, /* internal mic/line-in */
  44. INPUT_PIN_ATTR_DOCK, /* docking mic/line-in */
  45. INPUT_PIN_ATTR_NORMAL, /* mic/line-in jack */
  46. INPUT_PIN_ATTR_FRONT, /* mic/line-in jack in front */
  47. INPUT_PIN_ATTR_REAR, /* mic/line-in jack in rear */
  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. int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
  72. struct auto_pin_cfg *cfg,
  73. const hda_nid_t *ignore_nids,
  74. unsigned int cond_flags);
  75. /* older function */
  76. #define snd_hda_parse_pin_def_config(codec, cfg, ignore) \
  77. snd_hda_parse_pin_defcfg(codec, cfg, ignore, 0)
  78. /*
  79. */
  80. struct hda_gen_spec {
  81. /* fix-up list */
  82. int fixup_id;
  83. const struct hda_fixup *fixup_list;
  84. const char *fixup_name;
  85. /* additional init verbs */
  86. struct snd_array verbs;
  87. };
  88. /*
  89. * Fix-up pin default configurations and add default verbs
  90. */
  91. struct hda_pintbl {
  92. hda_nid_t nid;
  93. u32 val;
  94. };
  95. struct hda_model_fixup {
  96. const int id;
  97. const char *name;
  98. };
  99. struct hda_fixup {
  100. int type;
  101. bool chained;
  102. int chain_id;
  103. union {
  104. const struct hda_pintbl *pins;
  105. const struct hda_verb *verbs;
  106. void (*func)(struct hda_codec *codec,
  107. const struct hda_fixup *fix,
  108. int action);
  109. } v;
  110. };
  111. /* fixup types */
  112. enum {
  113. HDA_FIXUP_INVALID,
  114. HDA_FIXUP_PINS,
  115. HDA_FIXUP_VERBS,
  116. HDA_FIXUP_FUNC,
  117. };
  118. /* fixup action definitions */
  119. enum {
  120. HDA_FIXUP_ACT_PRE_PROBE,
  121. HDA_FIXUP_ACT_PROBE,
  122. HDA_FIXUP_ACT_INIT,
  123. HDA_FIXUP_ACT_BUILD,
  124. };
  125. int snd_hda_gen_add_verbs(struct hda_gen_spec *spec,
  126. const struct hda_verb *list);
  127. void snd_hda_gen_apply_verbs(struct hda_codec *codec);
  128. void snd_hda_apply_pincfgs(struct hda_codec *codec,
  129. const struct hda_pintbl *cfg);
  130. void snd_hda_apply_fixup(struct hda_codec *codec, int action);
  131. void snd_hda_pick_fixup(struct hda_codec *codec,
  132. const struct hda_model_fixup *models,
  133. const struct snd_pci_quirk *quirk,
  134. const struct hda_fixup *fixlist);
  135. static inline void snd_hda_gen_init(struct hda_gen_spec *spec)
  136. {
  137. snd_array_init(&spec->verbs, sizeof(struct hda_verb *), 8);
  138. }
  139. static inline void snd_hda_gen_free(struct hda_gen_spec *spec)
  140. {
  141. snd_array_free(&spec->verbs);
  142. }
  143. #endif /* __SOUND_HDA_AUTO_PARSER_H */