wcd938x.h 2.3 KB

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