wcd938x.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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_TX_PCM_OUT,
  42. SWRM_TX1_CH1,
  43. SWRM_TX1_CH2,
  44. SWRM_TX1_CH3,
  45. SWRM_TX1_CH4,
  46. SWRM_TX2_CH1,
  47. SWRM_TX2_CH2,
  48. SWRM_TX2_CH3,
  49. SWRM_TX2_CH4,
  50. SWRM_TX3_CH1,
  51. SWRM_TX3_CH2,
  52. SWRM_TX3_CH3,
  53. SWRM_TX3_CH4,
  54. SWRM_TX_PCM_IN,
  55. };
  56. #if IS_ENABLED(CONFIG_SND_SOC_WCD938X)
  57. int wcd938x_info_create_codec_entry(struct snd_info_entry *codec_root,
  58. struct snd_soc_component *component);
  59. int wcd938x_get_codec_variant(struct snd_soc_component *component);
  60. int wcd938x_codec_force_enable_micbias_v2(struct snd_soc_component *wcd938x,
  61. int event, int micb_num);
  62. int wcd938x_swr_dmic_register_notifier(struct snd_soc_component *wcd938x,
  63. struct notifier_block *nblock,
  64. bool enable);
  65. int wcd938x_codec_get_dev_num(struct snd_soc_component *component);
  66. static inline int wcd938x_slave_get_master_ch_val(int ch)
  67. {
  68. int i;
  69. for (i = 0; i < WCD938X_MAX_SLAVE_CH_TYPES; i++)
  70. if (ch == swr_master_ch_map[i])
  71. return i;
  72. return 0;
  73. }
  74. static inline int wcd938x_slave_get_master_ch(int idx)
  75. {
  76. return swr_master_ch_map[idx];
  77. }
  78. static inline int wcd938x_slave_get_slave_ch_val(int ch)
  79. {
  80. int i;
  81. for (i = 0; i < WCD938X_MAX_SLAVE_CH_TYPES; i++)
  82. if (ch == swr_slv_tx_ch_idx[i].ch_type)
  83. return swr_slv_tx_ch_idx[i].index;
  84. return -EINVAL;
  85. }
  86. #else
  87. static inline int wcd938x_info_create_codec_entry(
  88. struct snd_info_entry *codec_root,
  89. struct snd_soc_component *component)
  90. {
  91. return 0;
  92. }
  93. static inline int wcd938x_get_codec_variant(struct snd_soc_component *component)
  94. {
  95. return 0;
  96. }
  97. static inline int wcd938x_codec_force_enable_micbias_v2(
  98. struct snd_soc_component *wcd938x,
  99. int event, int micb_num)
  100. {
  101. return 0;
  102. }
  103. static inline int wcd938x_slave_get_master_ch_val(int ch)
  104. {
  105. return 0;
  106. }
  107. static inline int wcd938x_slave_get_master_ch(int idx)
  108. {
  109. return 0;
  110. }
  111. static inline int wcd938x_slave_get_slave_ch_val(int ch)
  112. {
  113. return 0;
  114. }
  115. static int wcd938x_codec_get_dev_num(struct snd_soc_component *component)
  116. {
  117. return 0;
  118. }
  119. #endif /* CONFIG_SND_SOC_WCD938X */
  120. #endif /* _WCD938X_H */