btfm_codec_hw_interface.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 DEVICE_NAME_MAX_LEN 64
  19. struct hwep_configurations {
  20. void *btfmcodec;
  21. uint8_t stream_id;
  22. uint32_t sample_rate;
  23. uint8_t bit_width;
  24. uint8_t codectype;
  25. uint32_t direction;
  26. uint8_t num_channels;
  27. struct list_head dai_list;
  28. };
  29. struct master_hwep_configurations {
  30. uint8_t stream_id;
  31. uint32_t device_id;
  32. uint32_t sample_rate;
  33. uint8_t bit_width;
  34. uint8_t num_channels;
  35. uint8_t chan_num;
  36. uint8_t codectype;
  37. uint16_t direction;
  38. };
  39. struct hwep_comp_drv {
  40. int (*hwep_probe) (struct snd_soc_component *);
  41. void (*hwep_remove) (struct snd_soc_component *);
  42. unsigned int (*hwep_read)(struct snd_soc_component *, unsigned int );
  43. int (*hwep_write)(struct snd_soc_component *, unsigned int,
  44. unsigned int);
  45. };
  46. struct hwep_dai_ops {
  47. int (*hwep_startup)(void *);
  48. void (*hwep_shutdown)(void *, int);
  49. int (*hwep_hw_params)(void *, uint32_t, uint32_t, uint8_t);
  50. int (*hwep_prepare)(void *, uint32_t, uint32_t, int);
  51. int (*hwep_set_channel_map)(void *, unsigned int, unsigned int *,
  52. unsigned int, unsigned int *);
  53. int (*hwep_get_channel_map)(void *, unsigned int *, unsigned int *,
  54. unsigned int *, unsigned int *, int);
  55. int (*hwep_get_configs)(void *, struct master_hwep_configurations *,
  56. uint8_t);
  57. uint8_t *hwep_codectype;
  58. };
  59. struct hwep_dai_driver {
  60. const char *dai_name;
  61. unsigned int id;
  62. struct snd_soc_pcm_stream capture;
  63. struct snd_soc_pcm_stream playback;
  64. struct hwep_dai_ops *dai_ops;
  65. };
  66. struct hwep_data {
  67. struct device *dev;
  68. char driver_name [DEVICE_NAME_MAX_LEN];
  69. struct hwep_comp_drv *drv;
  70. struct hwep_dai_driver *dai_drv;
  71. struct snd_kcontrol_new *mixer_ctrl;
  72. int num_dai;
  73. int num_mixer_ctrl;
  74. unsigned long flags;
  75. };
  76. int btfmcodec_register_hw_ep(struct hwep_data *);
  77. int btfmcodec_unregister_hw_ep(char *);
  78. // ToDo below.
  79. /*
  80. #if IS_ENABLED(CONFIG_SLIM_BTFM_CODEC_DRV)
  81. int btfmcodec_register_hw_ep(struct hwep_data *);
  82. int btfmcodec_unregister_hw_ep(char *);
  83. #else
  84. static inline int btfmcodec_register_hw_ep(struct hwep_data *hwep_info)
  85. {
  86. return -EOPNOTSUPP;
  87. }
  88. static inline int btfmcodec_unregister_hw_ep(char *dev_name)
  89. {
  90. return -EOPNOTSUPP;
  91. }
  92. #endif
  93. */
  94. #endif /*__LINUX_BTFM_CODEC_HW_INTERFACE_H */