btfm_codec_pkt.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_PKT_H
  6. #define __LINUX_BTFM_CODEC_PKT_H
  7. typedef uint32_t btm_opcode;
  8. struct btm_req {
  9. btm_opcode opcode;
  10. uint32_t len;
  11. uint8_t *data;
  12. }__attribute__((packed));
  13. struct btm_rsp {
  14. btm_opcode opcode;
  15. uint8_t status;
  16. }__attribute__((packed));
  17. struct btm_ind {
  18. btm_opcode opcode;
  19. uint32_t len;
  20. uint8_t *data;
  21. }__attribute__((packed));
  22. struct btm_ctrl_pkt {
  23. btm_opcode opcode;
  24. uint32_t len;
  25. uint8_t active_transport;
  26. uint8_t status;
  27. }__attribute__((packed));
  28. #define BTM_BTFMCODEC_PREPARE_AUDIO_BEARER_SWITCH_REQ 0x50000000
  29. #define BTM_BTFMCODEC_PREPARE_AUDIO_BEARER_SWITCH_RSP 0x50000001
  30. #define BTM_BTFMCODEC_MASTER_CONFIG_REQ 0x50000002
  31. #define BTM_BTFMCODEC_MASTER_CONFIG_RSP 0x50000003
  32. #define BTM_BTFMCODEC_MASTER_SHUTDOWN_REQ 0x50000004
  33. #define BTM_BTFMCODEC_CTRL_MASTER_SHUTDOWN_RSP 0x50000005
  34. #define BTM_BTFMCODEC_BEARER_SWITCH_IND 0x58000001
  35. #define BTM_BTFMCODEC_TRANSPORT_SWITCH_FAILED_IND 0x58000002
  36. #define BTM_MASTER_CONFIG_REQ_LEN 13
  37. #define BTM_MASTER_CONFIG_RSP_TIMEOUT 1000
  38. #define BTM_HEADER_LEN 8
  39. #define BTM_PREPARE_AUDIO_BEARER_SWITCH_RSP_LEN 2
  40. #define BTM_MASTER_CONFIG_RSP_LEN 2
  41. #define BTM_MASTER_SHUTDOWN_REQ_LEN 1
  42. #define BTM_PREPARE_AUDIO_BEARER_SWITCH_REQ_LEN 1
  43. #define BTM_BEARER_SWITCH_IND_LEN 1
  44. enum rx_status {
  45. /* Waiting for response */
  46. BTM_WAITING_RSP,
  47. /* Response recevied */
  48. BTM_RSP_RECV,
  49. /* Response recevied with failure status*/
  50. BTM_FAIL_RESP_RECV,
  51. };
  52. enum btfm_kp_status {
  53. /* KP processed message succesfully */
  54. MSG_SUCCESS = 0,
  55. /* Error while processing the message */
  56. MSG_FAILED,
  57. /* Wrong transport type selected by BTADV audio manager */
  58. MSG_WRONG_TRANSPORT_TYPE,
  59. /* Timeout triggered to receive bearer switch indications*/
  60. MSG_INTERNAL_TIMEOUT,
  61. MSG_FAILED_TO_CONFIGURE_HWEP,
  62. MSG_FAILED_TO_SHUTDOWN_HWEP,
  63. MSG_ERR_WHILE_SHUTING_DOWN_HWEP,
  64. };
  65. struct btm_master_config_req {
  66. btm_opcode opcode;
  67. uint32_t len;
  68. uint8_t stream_id;
  69. uint32_t device_id;
  70. uint32_t sample_rate;
  71. uint8_t bit_width;
  72. uint8_t num_channels;
  73. uint8_t channel_num;
  74. uint8_t codec_id;
  75. }__attribute__((packed));
  76. struct btm_master_shutdown_req {
  77. btm_opcode opcode;
  78. uint32_t len;
  79. uint8_t stream_id;
  80. }__attribute__((packed));
  81. int btfmcodec_dev_enqueue_pkt(struct btfmcodec_char_device *, void *, int);
  82. bool btfmcodec_is_valid_cache_avb(struct btfmcodec_data *);
  83. #endif /* __LINUX_BTFM_CODEC_PKT_H*/