wcd938x.h 2.6 KB

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