btfm_swr.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef BTFM_SWR_H
  6. #define BTFM_SWR_H
  7. #include <linux/types.h>
  8. #include <linux/mutex.h>
  9. #include <bindings/audio-codec-port-types.h>
  10. #include "soc/soundwire.h"
  11. #define SWR_SLAVE_COMPATIBLE_STR "btfmswr_slave"
  12. #define BTFMSWR_DBG(fmt, arg...) pr_debug("%s: " fmt "\n", __func__, ## arg)
  13. #define BTFMSWR_INFO(fmt, arg...) pr_info("%s: " fmt "\n", __func__, ## arg)
  14. #define BTFMSWR_ERR(fmt, arg...) pr_err("%s: " fmt "\n", __func__, ## arg)
  15. extern struct btfmswr *pbtfmswr;
  16. // assumption is that we use adjacent channels
  17. #define ONE_CHANNEL_MASK 1
  18. #define TWO_CHANNEL_MASK 3
  19. #define MAX_BT_PORTS 1
  20. /* Codec driver defines */
  21. enum {
  22. FMAUDIO_TX = 0,
  23. BTAUDIO_TX,
  24. BTAUDIO_RX,
  25. BTAUDIO_A2DP_SINK_TX,
  26. BTFM_NUM_CODEC_DAIS
  27. };
  28. enum {
  29. EVROS = 0,
  30. GANGES = 1,
  31. MAX_SOC_ID = 0xFF
  32. };
  33. struct btfmswr_dai_port_info {
  34. int dai_id;
  35. char *dai_name;
  36. uint8_t port;
  37. };
  38. struct soc_port_mapping {
  39. // enumeration address of BT SOC
  40. u64 ea;
  41. struct btfmswr_dai_port_info port_info[BTFM_NUM_CODEC_DAIS];
  42. };
  43. struct btfmswr {
  44. struct device *dev;
  45. struct swr_device *swr_slave;
  46. bool initialized;
  47. uint32_t sample_rate;
  48. uint32_t bps;
  49. uint16_t direction;
  50. uint8_t num_channels;
  51. int soc_index;
  52. struct soc_port_mapping *p_dai_port;
  53. };
  54. /**
  55. * btfm_swr_hw_init: Initialize soundwire slave device
  56. * Returns:
  57. * 0: Success
  58. * else: Fail
  59. */
  60. int btfm_swr_hw_init(void);
  61. int btfm_get_bt_soc_index(int chipset_ver);
  62. int btfm_swr_enable_port(u8 port_num, u8 ch_count, u32 sample_rate,
  63. u8 port_type);
  64. int btfm_swr_disable_port(u8 port_num, u8 ch_count, u8 usecase);
  65. #endif /* BTFM_SWR_H */