btfm_codec_pkt.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. #define BTM_BTFMCODEC_USECASE_START_IND 0x58000008
  49. #define BTM_USECASE_START_IND_LEN 1
  50. enum rx_status {
  51. /* Waiting for response */
  52. BTM_WAITING_RSP,
  53. /* Response recevied */
  54. BTM_RSP_RECV,
  55. /* Response recevied with failure status*/
  56. BTM_FAIL_RESP_RECV,
  57. /* Response not recevied, but client killed */
  58. BTM_RSP_NOT_RECV_CLIENT_KILLED,
  59. };
  60. enum btfm_kp_status {
  61. /* KP processed message succesfully */
  62. MSG_SUCCESS = 0,
  63. /* Error while processing the message */
  64. MSG_FAILED,
  65. /* Wrong transport type selected by BTADV audio manager */
  66. MSG_WRONG_TRANSPORT_TYPE,
  67. /* Timeout triggered to receive bearer switch indications*/
  68. MSG_INTERNAL_TIMEOUT,
  69. MSG_FAILED_TO_CONFIGURE_HWEP,
  70. MSG_FAILED_TO_SHUTDOWN_HWEP,
  71. MSG_ERR_WHILE_SHUTING_DOWN_HWEP,
  72. };
  73. struct btm_master_config_req {
  74. btm_opcode opcode;
  75. uint32_t len;
  76. uint8_t stream_id;
  77. uint32_t device_id;
  78. uint32_t sample_rate;
  79. uint8_t bit_width;
  80. uint8_t num_channels;
  81. uint8_t channel_num;
  82. uint8_t codec_id;
  83. }__attribute__((packed));
  84. struct btm_usecase_start_ind {
  85. btm_opcode opcode;
  86. uint32_t len;
  87. uint8_t transport;
  88. } __packed;
  89. struct btm_master_shutdown_req {
  90. btm_opcode opcode;
  91. uint32_t len;
  92. uint8_t stream_id;
  93. }__attribute__((packed));
  94. struct btm_adsp_state_ind {
  95. btm_opcode opcode;
  96. uint32_t len;
  97. uint32_t action;
  98. } __attribute__((packed));
  99. int btfmcodec_dev_enqueue_pkt(struct btfmcodec_char_device *, void *, int);
  100. bool btfmcodec_is_valid_cache_avb(struct btfmcodec_data *);
  101. #endif /* __LINUX_BTFM_CODEC_PKT_H*/