wcd937x.h 1.9 KB

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