wcd934x-mbhc.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __WCD934X_MBHC_H__
  6. #define __WCD934X_MBHC_H__
  7. #include "../wcd-mbhc-v2.h"
  8. enum wcd934x_on_demand_supply_name {
  9. WCD934X_ON_DEMAND_MICBIAS = 0,
  10. WCD934X_ON_DEMAND_SUPPLIES_MAX,
  11. };
  12. struct wcd934x_on_demand_supply {
  13. struct regulator *supply;
  14. int ondemand_supply_count;
  15. };
  16. struct wcd934x_mbhc {
  17. struct wcd_mbhc wcd_mbhc;
  18. struct blocking_notifier_head notifier;
  19. struct wcd934x_on_demand_supply on_demand_list[
  20. WCD934X_ON_DEMAND_SUPPLIES_MAX];
  21. struct wcd9xxx *wcd9xxx;
  22. struct fw_info *fw_data;
  23. bool mbhc_started;
  24. bool is_hph_recover;
  25. };
  26. #if IS_ENABLED(CONFIG_SND_SOC_WCD934X_MBHC)
  27. extern int tavil_mbhc_init(struct wcd934x_mbhc **mbhc,
  28. struct snd_soc_codec *codec,
  29. struct fw_info *fw_data);
  30. extern void tavil_mbhc_hs_detect_exit(struct snd_soc_codec *codec);
  31. extern int tavil_mbhc_hs_detect(struct snd_soc_codec *codec,
  32. struct wcd_mbhc_config *mbhc_cfg);
  33. extern void tavil_mbhc_deinit(struct snd_soc_codec *codec);
  34. extern int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc,
  35. struct snd_soc_codec *codec);
  36. extern int tavil_mbhc_get_impedance(struct wcd934x_mbhc *wcd934x_mbhc,
  37. uint32_t *zl, uint32_t *zr);
  38. #else
  39. static inline int tavil_mbhc_init(struct wcd934x_mbhc **mbhc,
  40. struct snd_soc_codec *codec,
  41. struct fw_info *fw_data)
  42. {
  43. return 0;
  44. }
  45. static inline void tavil_mbhc_hs_detect_exit(struct snd_soc_codec *codec)
  46. {
  47. }
  48. static inline int tavil_mbhc_hs_detect(struct snd_soc_codec *codec,
  49. struct wcd_mbhc_config *mbhc_cfg)
  50. {
  51. return 0;
  52. }
  53. static inline void tavil_mbhc_deinit(struct snd_soc_codec *codec)
  54. {
  55. }
  56. static inline int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc,
  57. struct snd_soc_codec *codec)
  58. {
  59. return 0;
  60. }
  61. static inline int tavil_mbhc_get_impedance(struct wcd934x_mbhc *wcd934x_mbhc,
  62. uint32_t *zl, uint32_t *zr)
  63. {
  64. if (zl)
  65. *zl = 0;
  66. if (zr)
  67. *zr = 0;
  68. return -EINVAL;
  69. }
  70. #endif
  71. #endif /* __WCD934X_MBHC_H__ */