wcd937x.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2018, 2020 The Linux Foundation. All rights reserved.
  3. */
  4. #ifndef _WCD937X_H
  5. #define _WCD937X_H
  6. #include <dt-bindings/sound/audio-codec-port-types.h>
  7. #define WCD937X_MAX_SLAVE_CH_TYPES 10
  8. #define ZERO 0
  9. #define WCD937X_DRV_NAME "wcd937x_codec"
  10. struct wcd937x_swr_slave_ch_map {
  11. u8 ch_type;
  12. u8 index;
  13. };
  14. static const struct wcd937x_swr_slave_ch_map wcd937x_swr_slv_tx_ch_idx[] = {
  15. {ADC1, 0},
  16. {ADC2, 1},
  17. {ADC3, 2},
  18. {DMIC0, 3},
  19. {DMIC1, 4},
  20. {MBHC, 5},
  21. {DMIC2, 6},
  22. {DMIC3, 7},
  23. {DMIC4, 8},
  24. {DMIC5, 9},
  25. };
  26. static int wcd937x_swr_master_ch_map[] = {
  27. ZERO,
  28. SWRM_TX1_CH1,
  29. SWRM_TX1_CH2,
  30. SWRM_TX1_CH3,
  31. SWRM_TX1_CH4,
  32. SWRM_TX2_CH1,
  33. SWRM_TX2_CH2,
  34. SWRM_TX2_CH3,
  35. SWRM_TX2_CH4,
  36. SWRM_TX3_CH1,
  37. SWRM_TX3_CH2,
  38. SWRM_TX3_CH3,
  39. SWRM_TX3_CH4,
  40. SWRM_PCM_IN,
  41. };
  42. #ifdef CONFIG_SND_SOC_WCD937X
  43. extern int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root,
  44. struct snd_soc_component *component);
  45. static inline int wcd937x_slave_get_master_ch_val(int ch)
  46. {
  47. int i;
  48. for (i = 0; i < WCD937X_MAX_SLAVE_CH_TYPES; i++)
  49. if (ch == wcd937x_swr_master_ch_map[i])
  50. return i;
  51. return 0;
  52. }
  53. static inline int wcd937x_slave_get_master_ch(int idx)
  54. {
  55. return wcd937x_swr_master_ch_map[idx];
  56. }
  57. static inline int wcd937x_slave_get_slave_ch_val(int ch)
  58. {
  59. int i;
  60. for (i = 0; i < WCD937X_MAX_SLAVE_CH_TYPES; i++)
  61. if (ch == wcd937x_swr_slv_tx_ch_idx[i].ch_type)
  62. return wcd937x_swr_slv_tx_ch_idx[i].index;
  63. return -EINVAL;
  64. }
  65. #else
  66. extern int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root,
  67. struct snd_soc_component *component)
  68. {
  69. return 0;
  70. }
  71. static inline int wcd937x_slave_get_master_ch_val(int ch)
  72. {
  73. return 0;
  74. }
  75. static inline int wcd937x_slave_get_master_ch(int idx)
  76. {
  77. return 0;
  78. }
  79. static inline int wcd937x_slave_get_slave_ch_val(int ch)
  80. {
  81. return 0;
  82. }
  83. #endif /* CONFIG_SND_SOC_WCD937X */
  84. #endif