wcd9378.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _WCD9378_H
  7. #define _WCD9378_H
  8. #include <bindings/audio-codec-port-types.h>
  9. #include <sound/info.h>
  10. #include <linux/component.h>
  11. #define WCD9378_MAX_SLAVE_CH_TYPES 13
  12. #define ZERO 0
  13. #define WCD9378_DRV_NAME "wcd9378_codec"
  14. /* from WCD to SWR DMIC events */
  15. enum {
  16. WCD9378_EVT_SSR_DOWN,
  17. WCD9378_EVT_SSR_UP,
  18. };
  19. struct wcd9378_swr_slave_ch_map {
  20. u8 ch_type;
  21. u8 index;
  22. };
  23. static const struct wcd9378_swr_slave_ch_map wcd9378_swr_slv_tx_ch_idx[] = {
  24. {ADC1, 0},
  25. {ADC2, 1},
  26. {ADC3, 2},
  27. {ADC4, 3},
  28. {DMIC0, 4},
  29. {DMIC1, 5},
  30. {MBHC, 6},
  31. {DMIC2, 6},
  32. {DMIC3, 7},
  33. {DMIC4, 8},
  34. {DMIC5, 9},
  35. {DMIC6, 10},
  36. {DMIC7, 11},
  37. };
  38. static int wcd9378_swr_master_ch_map[] = {
  39. ZERO,
  40. SWRM_TX1_CH1,
  41. SWRM_TX1_CH2,
  42. SWRM_TX1_CH3,
  43. SWRM_TX1_CH4,
  44. SWRM_TX2_CH1,
  45. SWRM_TX2_CH2,
  46. SWRM_TX2_CH3,
  47. SWRM_TX2_CH4,
  48. SWRM_TX3_CH1,
  49. SWRM_TX3_CH2,
  50. SWRM_TX3_CH3,
  51. SWRM_TX3_CH4,
  52. SWRM_TX_PCM_IN,
  53. };
  54. #if IS_ENABLED(CONFIG_SND_SOC_WCD9378)
  55. int wcd9378_info_create_codec_entry(struct snd_info_entry *codec_root,
  56. struct snd_soc_component *component);
  57. int wcd9378_swr_dmic_register_notifier(struct snd_soc_component *wcd9378,
  58. struct notifier_block *nblock,
  59. bool enable);
  60. int wcd9378_codec_get_dev_num(struct snd_soc_component *component);
  61. static inline int wcd9378_slave_get_master_ch_val(int ch)
  62. {
  63. int i;
  64. for (i = 0; i < WCD9378_MAX_SLAVE_CH_TYPES; i++)
  65. if (ch == wcd9378_swr_master_ch_map[i])
  66. return i;
  67. return 0;
  68. }
  69. static inline int wcd9378_slave_get_master_ch(int idx)
  70. {
  71. return wcd9378_swr_master_ch_map[idx];
  72. }
  73. static inline int wcd9378_slave_get_slave_ch_val(int ch)
  74. {
  75. int i;
  76. for (i = 0; i < WCD9378_MAX_SLAVE_CH_TYPES; i++)
  77. if (ch == wcd9378_swr_slv_tx_ch_idx[i].ch_type)
  78. return wcd9378_swr_slv_tx_ch_idx[i].index;
  79. return -EINVAL;
  80. }
  81. #else
  82. static inline int wcd9378_info_create_codec_entry(
  83. struct snd_info_entry *codec_root,
  84. struct snd_soc_component *component)
  85. {
  86. return 0;
  87. }
  88. static inline int wcd9378_slave_get_master_ch_val(int ch)
  89. {
  90. return 0;
  91. }
  92. static inline int wcd9378_slave_get_master_ch(int idx)
  93. {
  94. return 0;
  95. }
  96. static inline int wcd9378_slave_get_slave_ch_val(int ch)
  97. {
  98. return 0;
  99. }
  100. static int wcd9378_codec_get_dev_num(struct snd_soc_component *component)
  101. {
  102. return 0;
  103. }
  104. #endif /* CONFIG_SND_SOC_WCD9378 */
  105. #endif /* _WCD9378_H */