btfm_codec_pkt.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_BTFMCODEC_CTRL_LOG_LVL_IND 0x58000004
  37. #define BTM_MASTER_CONFIG_REQ_LEN 13
  38. #define BTM_MASTER_CONFIG_RSP_TIMEOUT 5000
  39. #define BTM_HEADER_LEN 8
  40. #define BTM_PREPARE_AUDIO_BEARER_SWITCH_RSP_LEN 2
  41. #define BTM_MASTER_CONFIG_RSP_LEN 2
  42. #define BTM_MASTER_SHUTDOWN_REQ_LEN 1
  43. #define BTM_PREPARE_AUDIO_BEARER_SWITCH_REQ_LEN 1
  44. #define BTM_BEARER_SWITCH_IND_LEN 1
  45. #define BTM_LOG_LVL_IND_LEN 1
  46. enum rx_status {
  47. /* Waiting for response */
  48. BTM_WAITING_RSP,
  49. /* Response recevied */
  50. BTM_RSP_RECV,
  51. /* Response recevied with failure status*/
  52. BTM_FAIL_RESP_RECV,
  53. /* Response not recevied, but client killed */
  54. BTM_RSP_NOT_RECV_CLIENT_KILLED,
  55. };
  56. enum btfm_kp_status {
  57. /* KP processed message succesfully */
  58. MSG_SUCCESS = 0,
  59. /* Error while processing the message */
  60. MSG_FAILED,
  61. /* Wrong transport type selected by BTADV audio manager */
  62. MSG_WRONG_TRANSPORT_TYPE,
  63. /* Timeout triggered to receive bearer switch indications*/
  64. MSG_INTERNAL_TIMEOUT,
  65. MSG_FAILED_TO_CONFIGURE_HWEP,
  66. MSG_FAILED_TO_SHUTDOWN_HWEP,
  67. MSG_ERR_WHILE_SHUTING_DOWN_HWEP,
  68. };
  69. struct btm_master_config_req {
  70. btm_opcode opcode;
  71. uint32_t len;
  72. uint8_t stream_id;
  73. uint32_t device_id;
  74. uint32_t sample_rate;
  75. uint8_t bit_width;
  76. uint8_t num_channels;
  77. uint8_t channel_num;
  78. uint8_t codec_id;
  79. }__attribute__((packed));
  80. struct btm_master_shutdown_req {
  81. btm_opcode opcode;
  82. uint32_t len;
  83. uint8_t stream_id;
  84. }__attribute__((packed));
  85. int btfmcodec_dev_enqueue_pkt(struct btfmcodec_char_device *, void *, int);
  86. bool btfmcodec_is_valid_cache_avb(struct btfmcodec_data *);
  87. #endif /* __LINUX_BTFM_CODEC_PKT_H*/