wcd934x-mbhc.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __WCD934X_MBHC_H__
  6. #define __WCD934X_MBHC_H__
  7. #include <asoc/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_component *component,
  29. struct fw_info *fw_data);
  30. extern void tavil_mbhc_hs_detect_exit(struct snd_soc_component *component);
  31. extern int tavil_mbhc_hs_detect(struct snd_soc_component *component,
  32. struct wcd_mbhc_config *mbhc_cfg);
  33. extern void tavil_mbhc_deinit(struct snd_soc_component *component);
  34. extern int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc,
  35. struct snd_soc_component *component);
  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_component *component,
  41. struct fw_info *fw_data)
  42. {
  43. return 0;
  44. }
  45. static inline void tavil_mbhc_hs_detect_exit(
  46. struct snd_soc_component *component)
  47. {
  48. }
  49. static inline int tavil_mbhc_hs_detect(struct snd_soc_component *component,
  50. struct wcd_mbhc_config *mbhc_cfg)
  51. {
  52. return 0;
  53. }
  54. static inline void tavil_mbhc_deinit(struct snd_soc_component *component)
  55. {
  56. }
  57. static inline int tavil_mbhc_post_ssr_init(struct wcd934x_mbhc *mbhc,
  58. struct snd_soc_component *component)
  59. {
  60. return 0;
  61. }
  62. static inline int tavil_mbhc_get_impedance(struct wcd934x_mbhc *wcd934x_mbhc,
  63. uint32_t *zl, uint32_t *zr)
  64. {
  65. if (zl)
  66. *zl = 0;
  67. if (zr)
  68. *zr = 0;
  69. return -EINVAL;
  70. }
  71. #endif
  72. #endif /* __WCD934X_MBHC_H__ */