wcd937x.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2018, 2020 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022-2023 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. extern int wcd937x_get_codec_variant(struct snd_soc_component *component);
  47. int wcd937x_codec_get_dev_num(struct snd_soc_component *component);
  48. static inline int wcd937x_slave_get_master_ch_val(int ch)
  49. {
  50. int i;
  51. for (i = 0; i < WCD937X_MAX_SLAVE_CH_TYPES; i++)
  52. if (ch == wcd937x_swr_master_ch_map[i])
  53. return i;
  54. return 0;
  55. }
  56. static inline int wcd937x_slave_get_master_ch(int idx)
  57. {
  58. return wcd937x_swr_master_ch_map[idx];
  59. }
  60. static inline int wcd937x_slave_get_slave_ch_val(int ch)
  61. {
  62. int i;
  63. for (i = 0; i < WCD937X_MAX_SLAVE_CH_TYPES; i++)
  64. if (ch == wcd937x_swr_slv_tx_ch_idx[i].ch_type)
  65. return wcd937x_swr_slv_tx_ch_idx[i].index;
  66. return -EINVAL;
  67. }
  68. #else
  69. extern int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root,
  70. struct snd_soc_component *component)
  71. {
  72. return 0;
  73. }
  74. static inline int wcd937x_slave_get_master_ch_val(int ch)
  75. {
  76. return 0;
  77. }
  78. static inline int wcd937x_slave_get_master_ch(int idx)
  79. {
  80. return 0;
  81. }
  82. static inline int wcd937x_slave_get_slave_ch_val(int ch)
  83. {
  84. return 0;
  85. }
  86. static inline int wcd937x_get_codec_variant(struct snd_soc_component *component)
  87. {
  88. return 0;
  89. }
  90. static int wcd937x_codec_get_dev_num(struct snd_soc_component *component)
  91. {
  92. return 0;
  93. }
  94. #endif /* CONFIG_SND_SOC_WCD937X */
  95. #endif