btfm_codec_hw_interface.h 2.6 KB

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