btfm_codec.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_H
  6. #define __LINUX_BTFM_CODEC_H
  7. #include <linux/kernel.h>
  8. #include <linux/bitops.h>
  9. #include <linux/printk.h>
  10. #include <linux/cdev.h>
  11. #include "btfm_codec_hw_interface.h"
  12. #define BTFMCODEC_DBG(fmt, arg...) pr_err("%s: " fmt "\n", __func__, ## arg)
  13. #define BTFMCODEC_INFO(fmt, arg...) pr_err("%s: " fmt "\n", __func__, ## arg)
  14. #define BTFMCODEC_ERR(fmt, arg...) pr_err("%s: " fmt "\n", __func__, ## arg)
  15. #define BTFMCODEC_WARN(fmt, arg...) pr_warn("%s: " fmt "\n", __func__, ## arg)
  16. #define DEVICE_NAME_MAX_LEN 64
  17. enum btfmcodec_states {
  18. /*Default state of btfm codec driver */
  19. IDLE = 0,
  20. /* When BT is active transport */
  21. BT_Connected = 1,
  22. /* Waiting for BT bearer indication after configuring HW ports */
  23. BT_Connecting = 2,
  24. /* When BTADV_AUDIO is active transport */
  25. BTADV_AUDIO_Connected = 3,
  26. /* Waiting for BTADV_AUDIO bearer switch indications */
  27. BTADV_AUDIO_Connecting = 4
  28. };
  29. char *coverttostring(enum btfmcodec_states);
  30. struct btfmcodec_state_machine {
  31. enum btfmcodec_states prev_state;
  32. enum btfmcodec_states current_state;
  33. enum btfmcodec_states next_state;
  34. };
  35. struct btfmcodec_char_device {
  36. struct cdev cdev;
  37. refcount_t active_clients;
  38. struct mutex lock;
  39. int reuse_minor;
  40. char dev_name[DEVICE_NAME_MAX_LEN];
  41. };
  42. struct btfmcodec_data {
  43. struct device dev;
  44. struct btfmcodec_state_machine states;
  45. struct btfmcodec_char_device *btfmcodec_dev;
  46. struct hwep_data *hwep_info;
  47. };
  48. struct btfmcodec_data *btfm_get_btfmcodec(void);
  49. #endif /*__LINUX_BTFM_CODEC_H */