btfm_codec_pkt.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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_CODEC_CONFIG_DMA_REQ 0x58000006
  35. #define BTM_BTFMCODEC_CODEC_CONFIG_DMA_RSP 0x58000007
  36. #define BTM_BTFMCODEC_BEARER_SWITCH_IND 0x58000001
  37. #define BTM_BTFMCODEC_TRANSPORT_SWITCH_FAILED_IND 0x58000002
  38. #define BTM_BTFMCODEC_ADSP_STATE_IND 0x58000003
  39. #define BTM_BTFMCODEC_CTRL_LOG_LVL_IND 0x58000004
  40. #define BTM_MASTER_CONFIG_REQ_LEN 13
  41. #define BTM_MASTER_CONFIG_RSP_TIMEOUT 5000
  42. #define BTM_MASTER_DMA_CONFIG_RSP_TIMEOUT 5000
  43. #define BTM_HEADER_LEN 8
  44. #define BTM_PREPARE_AUDIO_BEARER_SWITCH_RSP_LEN 2
  45. #define BTM_MASTER_CONFIG_RSP_LEN 2
  46. #define BTM_CODEC_CONFIG_DMA_RSP_LEN 2
  47. #define BTM_MASTER_SHUTDOWN_REQ_LEN 1
  48. #define BTM_PREPARE_AUDIO_BEARER_SWITCH_REQ_LEN 1
  49. #define BTM_BEARER_SWITCH_IND_LEN 1
  50. #define BTM_LOG_LVL_IND_LEN 1
  51. #define BTM_ADSP_STATE_IND_LEN 4
  52. #define BTM_CODEC_CONFIG_DMA_REQ_LEN 11
  53. #define BTM_BTFMCODEC_USECASE_START_IND 0x58000008
  54. #define BTM_USECASE_START_IND_LEN 1
  55. enum rx_status {
  56. /* Waiting for response */
  57. BTM_WAITING_RSP,
  58. /* Response recevied */
  59. BTM_RSP_RECV,
  60. /* Response recevied with failure status*/
  61. BTM_FAIL_RESP_RECV,
  62. /* Response not recevied, but client killed */
  63. BTM_RSP_NOT_RECV_CLIENT_KILLED,
  64. };
  65. enum btfm_kp_status {
  66. /* KP processed message succesfully */
  67. MSG_SUCCESS = 0,
  68. /* Error while processing the message */
  69. MSG_FAILED,
  70. /* Wrong transport type selected by BTADV audio manager */
  71. MSG_WRONG_TRANSPORT_TYPE,
  72. /* Timeout triggered to receive bearer switch indications*/
  73. MSG_INTERNAL_TIMEOUT,
  74. MSG_FAILED_TO_CONFIGURE_HWEP,
  75. MSG_FAILED_TO_SHUTDOWN_HWEP,
  76. MSG_ERR_WHILE_SHUTING_DOWN_HWEP,
  77. };
  78. struct btm_master_config_req {
  79. btm_opcode opcode;
  80. uint32_t len;
  81. uint8_t stream_id;
  82. uint32_t device_id;
  83. uint32_t sample_rate;
  84. uint8_t bit_width;
  85. uint8_t num_channels;
  86. uint8_t channel_num;
  87. uint8_t codec_id;
  88. }__attribute__((packed));
  89. struct btm_dma_config_req {
  90. btm_opcode opcode;
  91. uint32_t len;
  92. uint8_t stream_id;
  93. uint32_t sample_rate;
  94. uint8_t bit_width;
  95. uint8_t num_channels;
  96. uint8_t codec_id;
  97. uint8_t lpaif; // Low power audio interface
  98. uint8_t inf_index; // interface index
  99. uint8_t active_channel_mask;
  100. } __packed;
  101. struct btm_usecase_start_ind {
  102. btm_opcode opcode;
  103. uint32_t len;
  104. uint8_t transport;
  105. } __packed;
  106. struct btm_master_shutdown_req {
  107. btm_opcode opcode;
  108. uint32_t len;
  109. uint8_t stream_id;
  110. }__attribute__((packed));
  111. struct btm_adsp_state_ind {
  112. btm_opcode opcode;
  113. uint32_t len;
  114. uint32_t action;
  115. } __attribute__((packed));
  116. int btfmcodec_dev_enqueue_pkt(struct btfmcodec_char_device *, void *, int);
  117. bool btfmcodec_is_valid_cache_avb(struct btfmcodec_data *);
  118. #endif /* __LINUX_BTFM_CODEC_PKT_H*/