wcd939x-mbhc.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. };
  14. static inline u32 get_r_gnd_res_tot_mohms(u32 r_gnd_int_fet_mohms, u32 r_gnd_ext_fet_mohms,
  15. u32 r_gnd_par_tot_mohms)
  16. {
  17. return r_gnd_int_fet_mohms + r_gnd_ext_fet_mohms + r_gnd_par_tot_mohms;
  18. }
  19. static inline u32 get_r_aud_res_tot_mohms(u32 r_aud_int_fet_mohms, u32 r_aud_ext_fet_mohms)
  20. {
  21. return r_aud_int_fet_mohms + r_aud_ext_fet_mohms;
  22. }
  23. #if IS_ENABLED(CONFIG_SND_SOC_WCD939X)
  24. extern int wcd939x_mbhc_init(struct wcd939x_mbhc **mbhc,
  25. struct snd_soc_component *component,
  26. struct fw_info *fw_data);
  27. extern void wcd939x_mbhc_hs_detect_exit(struct snd_soc_component *component);
  28. extern int wcd939x_mbhc_hs_detect(struct snd_soc_component *component,
  29. struct wcd_mbhc_config *mbhc_cfg);
  30. extern void wcd939x_mbhc_deinit(struct snd_soc_component *component);
  31. extern void wcd939x_mbhc_ssr_down(struct wcd939x_mbhc *mbhc,
  32. struct snd_soc_component *component);
  33. extern int wcd939x_mbhc_post_ssr_init(struct wcd939x_mbhc *mbhc,
  34. struct snd_soc_component *component);
  35. extern int wcd939x_mbhc_get_impedance(struct wcd939x_mbhc *wcd939x_mbhc,
  36. uint32_t *zl, uint32_t *zr);
  37. #else
  38. static inline int wcd939x_mbhc_init(struct wcd939x_mbhc **mbhc,
  39. struct snd_soc_component *component,
  40. struct fw_info *fw_data)
  41. {
  42. return 0;
  43. }
  44. static inline void wcd939x_mbhc_hs_detect_exit(
  45. struct snd_soc_component *component)
  46. {
  47. }
  48. static inline int wcd939x_mbhc_hs_detect(struct snd_soc_component *component,
  49. struct wcd_mbhc_config *mbhc_cfg)
  50. {
  51. return 0;
  52. }
  53. static inline void wcd939x_mbhc_deinit(struct snd_soc_component *component)
  54. {
  55. }
  56. static inline void wcd939x_mbhc_ssr_down(struct wcd939x_mbhc *mbhc,
  57. struct snd_soc_component *component)
  58. {
  59. }
  60. static inline int wcd939x_mbhc_post_ssr_init(struct wcd939x_mbhc *mbhc,
  61. struct snd_soc_component *component)
  62. {
  63. return 0;
  64. }
  65. static inline int wcd939x_mbhc_get_impedance(struct wcd939x_mbhc *wcd939x_mbhc,
  66. uint32_t *zl, uint32_t *zr)
  67. {
  68. if (zl)
  69. *zl = 0;
  70. if (zr)
  71. *zr = 0;
  72. return -EINVAL;
  73. }
  74. #endif
  75. #endif /* __WCD939X_MBHC_H__ */