wcd939x.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _WCD939X_H
  7. #define _WCD939X_H
  8. #include <bindings/audio-codec-port-types.h>
  9. #define WCD939X_MAX_SLAVE_CH_TYPES 13
  10. #define ZERO 0
  11. #define WCD939X_DRV_NAME "wcd939x_codec"
  12. enum {
  13. WCD9390 = 0,
  14. WCD9395 = 5,
  15. };
  16. /* from WCD to SWR DMIC events */
  17. enum {
  18. WCD939X_EVT_SSR_DOWN,
  19. WCD939X_EVT_SSR_UP,
  20. };
  21. struct swr_slave_ch_map {
  22. u8 ch_type;
  23. u8 index;
  24. };
  25. static const struct swr_slave_ch_map swr_slv_tx_ch_idx[] = {
  26. {ADC1, 0},
  27. {ADC2, 1},
  28. {ADC3, 2},
  29. {ADC4, 3},
  30. {DMIC0, 4},
  31. {DMIC1, 5},
  32. {MBHC, 6},
  33. {DMIC2, 6},
  34. {DMIC3, 7},
  35. {DMIC4, 8},
  36. {DMIC5, 9},
  37. {DMIC6, 10},
  38. {DMIC7, 11},
  39. };
  40. static int swr_master_ch_map[] = {
  41. ZERO,
  42. SWRM_TX_PCM_OUT,
  43. SWRM_TX1_CH1,
  44. SWRM_TX1_CH2,
  45. SWRM_TX1_CH3,
  46. SWRM_TX1_CH4,
  47. SWRM_TX2_CH1,
  48. SWRM_TX2_CH2,
  49. SWRM_TX2_CH3,
  50. SWRM_TX2_CH4,
  51. SWRM_TX3_CH1,
  52. SWRM_TX3_CH2,
  53. SWRM_TX3_CH3,
  54. SWRM_TX3_CH4,
  55. SWRM_TX_PCM_IN,
  56. };
  57. #if IS_ENABLED(CONFIG_SND_SOC_WCD939X)
  58. int wcd939x_info_create_codec_entry(struct snd_info_entry *codec_root,
  59. struct snd_soc_component *component);
  60. int wcd939x_get_codec_variant(struct snd_soc_component *component);
  61. int wcd939x_codec_force_enable_micbias_v2(struct snd_soc_component *wcd939x,
  62. int event, int micb_num);
  63. int wcd939x_swr_dmic_register_notifier(struct snd_soc_component *wcd939x,
  64. struct notifier_block *nblock,
  65. bool enable);
  66. int wcd939x_codec_get_dev_num(struct snd_soc_component *component);
  67. static inline int wcd939x_slave_get_master_ch_val(int ch)
  68. {
  69. int i;
  70. for (i = 0; i < WCD939X_MAX_SLAVE_CH_TYPES; i++)
  71. if (ch == swr_master_ch_map[i])
  72. return i;
  73. return 0;
  74. }
  75. static inline int wcd939x_slave_get_master_ch(int idx)
  76. {
  77. return swr_master_ch_map[idx];
  78. }
  79. static inline int wcd939x_slave_get_slave_ch_val(int ch)
  80. {
  81. int i;
  82. for (i = 0; i < WCD939X_MAX_SLAVE_CH_TYPES; i++)
  83. if (ch == swr_slv_tx_ch_idx[i].ch_type)
  84. return swr_slv_tx_ch_idx[i].index;
  85. return -EINVAL;
  86. }
  87. #else
  88. static inline int wcd939x_info_create_codec_entry(
  89. struct snd_info_entry *codec_root,
  90. struct snd_soc_component *component)
  91. {
  92. return 0;
  93. }
  94. static inline int wcd939x_get_codec_variant(struct snd_soc_component *component)
  95. {
  96. return 0;
  97. }
  98. static inline int wcd939x_codec_force_enable_micbias_v2(
  99. struct snd_soc_component *wcd939x,
  100. int event, int micb_num)
  101. {
  102. return 0;
  103. }
  104. static inline int wcd939x_slave_get_master_ch_val(int ch)
  105. {
  106. return 0;
  107. }
  108. static inline int wcd939x_slave_get_master_ch(int idx)
  109. {
  110. return 0;
  111. }
  112. static inline int wcd939x_slave_get_slave_ch_val(int ch)
  113. {
  114. return 0;
  115. }
  116. static int wcd939x_codec_get_dev_num(struct snd_soc_component *component)
  117. {
  118. return 0;
  119. }
  120. #endif /* CONFIG_SND_SOC_WCD939X */
  121. #endif /* _WCD939X_H */