wcd934x-mbhc.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __WCD934X_MBHC_H__
  14. #define __WCD934X_MBHC_H__
  15. #include "../wcd-mbhc-v2.h"
  16. enum wcd934x_on_demand_supply_name {
  17. WCD934X_ON_DEMAND_MICBIAS = 0,
  18. WCD934X_ON_DEMAND_SUPPLIES_MAX,
  19. };
  20. struct wcd934x_on_demand_supply {
  21. struct regulator *supply;
  22. int ondemand_supply_count;
  23. };
  24. struct wcd934x_mbhc {
  25. struct wcd_mbhc wcd_mbhc;
  26. struct blocking_notifier_head notifier;
  27. struct wcd934x_on_demand_supply on_demand_list[
  28. WCD934X_ON_DEMAND_SUPPLIES_MAX];
  29. struct wcd9xxx *wcd9xxx;
  30. struct fw_info *fw_data;
  31. bool mbhc_started;
  32. bool is_hph_recover;
  33. };
  34. #if IS_ENABLED(CONFIG_SND_SOC_WCD934X_MBHC)
  35. extern int tavil_mbhc_init(struct wcd934x_mbhc **mbhc,
  36. struct snd_soc_codec *codec,
  37. struct fw_info *fw_data);
  38. extern void tavil_mbhc_hs_detect_exit(struct snd_soc_codec *codec);
  39. extern int tavil_mbhc_hs_detect(struct snd_soc_codec *codec,
  40. struct wcd_mbhc_config *mbhc_cfg);
  41. extern void tavil_mbhc_deinit(struct snd_soc_codec *codec);
  42. extern int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc,
  43. struct snd_soc_codec *codec);
  44. extern int tavil_mbhc_get_impedance(struct wcd934x_mbhc *wcd934x_mbhc,
  45. uint32_t *zl, uint32_t *zr);
  46. #else
  47. static inline int tavil_mbhc_init(struct wcd934x_mbhc **mbhc,
  48. struct snd_soc_codec *codec,
  49. struct fw_info *fw_data)
  50. {
  51. return 0;
  52. }
  53. static inline void tavil_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
  54. {
  55. }
  56. static inline int tavil_mbhc_hs_detect(struct snd_soc_codec *codec,
  57. struct wcd_mbhc_config *mbhc_cfg)
  58. {
  59. return 0;
  60. }
  61. static inline void tavil_mbhc_deinit(struct snd_soc_codec *codec)
  62. {
  63. }
  64. static inline int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc,
  65. struct snd_soc_codec *codec)
  66. {
  67. return 0;
  68. }
  69. static inline int tavil_mbhc_get_impedance(struct wcd934x_mbhc *wcd934x_mbhc,
  70. uint32_t *zl, uint32_t *zr)
  71. {
  72. if (zl)
  73. *zl = 0;
  74. if (zr)
  75. *zr = 0;
  76. return -EINVAL;
  77. }
  78. #endif
  79. #endif /* __WCD934X_MBHC_H__ */