btfm_codec_hw_interface.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef __LINUX_BTFM_CODEC_HW_INTERFACE_H
  6. #define __LINUX_BTFM_CODEC_HW_INTERFACE_H
  7. #include <linux/kernel.h>
  8. #include <linux/bitops.h>
  9. #include <sound/pcm.h>
  10. #include <sound/pcm_params.h>
  11. #include <sound/soc.h>
  12. #include <sound/soc-dapm.h>
  13. #include <sound/tlv.h>
  14. /* This flag is set to indicate btfm codec driver is
  15. * responsible to configure master.
  16. */
  17. #define BTADV_AUDIO_MASTER_CONFIG 0
  18. #define BTADV_CONFIGURE_DMA 1
  19. #define DEVICE_NAME_MAX_LEN 64
  20. struct hwep_configurations {
  21. void *btfmcodec;
  22. uint8_t stream_id;
  23. uint32_t sample_rate;
  24. uint8_t bit_width;
  25. uint8_t codectype;
  26. uint32_t direction;
  27. uint8_t num_channels;
  28. struct list_head dai_list;
  29. };
  30. struct master_hwep_configurations {
  31. uint8_t stream_id;
  32. uint32_t device_id;
  33. uint32_t sample_rate;
  34. uint8_t bit_width;
  35. uint8_t num_channels;
  36. uint8_t chan_num;
  37. uint8_t codectype;
  38. uint16_t direction;
  39. };
  40. struct hwep_dma_configurations {
  41. uint8_t stream_id;
  42. uint32_t sample_rate;
  43. uint8_t bit_width;
  44. uint8_t num_channels;
  45. uint8_t codectype;
  46. uint8_t lpaif; // Low power audio interface
  47. uint8_t inf_index; // interface index
  48. uint8_t active_channel_mask;
  49. };
  50. struct hwep_comp_drv {
  51. int (*hwep_probe) (struct snd_soc_component *);
  52. void (*hwep_remove) (struct snd_soc_component *);
  53. unsigned int (*hwep_read)(struct snd_soc_component *, unsigned int );
  54. int (*hwep_write)(struct snd_soc_component *, unsigned int,
  55. unsigned int);
  56. };
  57. struct hwep_dai_ops {
  58. int (*hwep_startup)(void *);
  59. void (*hwep_shutdown)(void *, int);
  60. int (*hwep_hw_params)(void *, uint32_t, uint32_t, uint8_t);
  61. int (*hwep_prepare)(void *, uint32_t, uint32_t, int);
  62. int (*hwep_set_channel_map)(void *, unsigned int, unsigned int *,
  63. unsigned int, unsigned int *);
  64. int (*hwep_get_channel_map)(void *, unsigned int *, unsigned int *,
  65. unsigned int *, unsigned int *, int);
  66. int (*hwep_get_configs)(void *a, void *b, uint8_t c);
  67. uint8_t *hwep_codectype;
  68. };
  69. struct hwep_dai_driver {
  70. const char *dai_name;
  71. unsigned int id;
  72. struct snd_soc_pcm_stream capture;
  73. struct snd_soc_pcm_stream playback;
  74. struct hwep_dai_ops *dai_ops;
  75. };
  76. struct hwep_data {
  77. struct device *dev;
  78. char driver_name [DEVICE_NAME_MAX_LEN];
  79. struct hwep_comp_drv *drv;
  80. struct hwep_dai_driver *dai_drv;
  81. struct snd_kcontrol_new *mixer_ctrl;
  82. int num_dai;
  83. int num_mixer_ctrl;
  84. unsigned long flags;
  85. };
  86. int btfmcodec_register_hw_ep(struct hwep_data *);
  87. int btfmcodec_unregister_hw_ep(char *);
  88. // ToDo below.
  89. /*
  90. #if IS_ENABLED(CONFIG_SLIM_BTFM_CODEC_DRV)
  91. int btfmcodec_register_hw_ep(struct hwep_data *);
  92. int btfmcodec_unregister_hw_ep(char *);
  93. #else
  94. static inline int btfmcodec_register_hw_ep(struct hwep_data *hwep_info)
  95. {
  96. return -EOPNOTSUPP;
  97. }
  98. static inline int btfmcodec_unregister_hw_ep(char *dev_name)
  99. {
  100. return -EOPNOTSUPP;
  101. }
  102. #endif
  103. */
  104. #endif /*__LINUX_BTFM_CODEC_HW_INTERFACE_H */