btfm_codec_pkt.h 3.0 KB

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