wcd939x-mbhc.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __WCD939X_MBHC_H__
  7. #define __WCD939X_MBHC_H__
  8. #include <asoc/wcd-mbhc-v2.h>
  9. struct wcd939x_mbhc {
  10. struct wcd_mbhc wcd_mbhc;
  11. struct blocking_notifier_head notifier;
  12. struct fw_info *fw_data;
  13. struct timer_list rdown_timer;
  14. int rdown_prev_iter;
  15. bool rdown_timer_complete;
  16. };
  17. static inline u32 get_r_gnd_res_tot_mohms(u32 r_gnd_int_fet_mohms, u32 r_gnd_ext_fet_mohms,
  18. u32 r_gnd_par_tot_mohms)
  19. {
  20. return r_gnd_int_fet_mohms + r_gnd_ext_fet_mohms + r_gnd_par_tot_mohms;
  21. }
  22. static inline u32 get_r_aud_res_tot_mohms(u32 r_aud_int_fet_mohms, u32 r_aud_ext_fet_mohms,
  23. u32 r_load_eff_mohms)
  24. {
  25. return r_aud_int_fet_mohms + r_aud_ext_fet_mohms + r_load_eff_mohms;
  26. }
  27. #if IS_ENABLED(CONFIG_SND_SOC_WCD939X)
  28. extern int wcd939x_mbhc_init(struct wcd939x_mbhc **mbhc,
  29. struct snd_soc_component *component,
  30. struct fw_info *fw_data);
  31. extern void wcd939x_mbhc_hs_detect_exit(struct snd_soc_component *component);
  32. extern int wcd939x_mbhc_hs_detect(struct snd_soc_component *component,
  33. struct wcd_mbhc_config *mbhc_cfg);
  34. extern void wcd939x_mbhc_deinit(struct snd_soc_component *component);
  35. extern void wcd939x_mbhc_ssr_down(struct wcd939x_mbhc *mbhc,
  36. struct snd_soc_component *component);
  37. extern int wcd939x_mbhc_post_ssr_init(struct wcd939x_mbhc *mbhc,
  38. struct snd_soc_component *component);
  39. extern int wcd939x_mbhc_get_impedance(struct wcd939x_mbhc *wcd939x_mbhc,
  40. uint32_t *zl, uint32_t *zr);
  41. #else
  42. static inline int wcd939x_mbhc_init(struct wcd939x_mbhc **mbhc,
  43. struct snd_soc_component *component,
  44. struct fw_info *fw_data)
  45. {
  46. return 0;
  47. }
  48. static inline void wcd939x_mbhc_hs_detect_exit(
  49. struct snd_soc_component *component)
  50. {
  51. }
  52. static inline int wcd939x_mbhc_hs_detect(struct snd_soc_component *component,
  53. struct wcd_mbhc_config *mbhc_cfg)
  54. {
  55. return 0;
  56. }
  57. static inline void wcd939x_mbhc_deinit(struct snd_soc_component *component)
  58. {
  59. }
  60. static inline void wcd939x_mbhc_ssr_down(struct wcd939x_mbhc *mbhc,
  61. struct snd_soc_component *component)
  62. {
  63. }
  64. static inline int wcd939x_mbhc_post_ssr_init(struct wcd939x_mbhc *mbhc,
  65. struct snd_soc_component *component)
  66. {
  67. return 0;
  68. }
  69. static inline int wcd939x_mbhc_get_impedance(struct wcd939x_mbhc *wcd939x_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 /* __WCD939X_MBHC_H__ */