bta_av_cfg.cc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. /******************************************************************************
  2. *
  3. * Copyright 2005-2016 Broadcom Corporation
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at:
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. ******************************************************************************/
  18. /******************************************************************************
  19. *
  20. * This file contains compile-time configurable constants for advanced
  21. * audio/video
  22. *
  23. ******************************************************************************/
  24. #include <stddef.h>
  25. #include "bt_common.h"
  26. #include "bt_target.h"
  27. #include "bta_api.h"
  28. #include "bta_av_int.h"
  29. #ifndef BTA_AV_RC_COMP_ID
  30. #define BTA_AV_RC_COMP_ID AVRC_CO_GOOGLE
  31. #endif
  32. #ifndef BTA_AV_RC_PASS_RSP_CODE
  33. #define BTA_AV_RC_PASS_RSP_CODE AVRC_RSP_NOT_IMPL
  34. #endif
  35. const uint32_t bta_av_meta_caps_co_ids[] = {AVRC_CO_METADATA, AVRC_CO_BROADCOM};
  36. /* AVRCP supported categories */
  37. #define BTA_AV_RC_SUPF_CT (AVRC_SUPF_CT_CAT2)
  38. #define BTA_AVK_RC_SUPF_CT (AVRC_SUPF_CT_CAT1 | AVRC_SUPF_CT_BROWSE)
  39. #define BTA_AVK_RC_SUPF_TG (AVRC_SUPF_TG_CAT2)
  40. /* AVRCP Controller and Targer default name */
  41. #ifndef BTA_AV_RC_CT_NAME
  42. #define BTA_AV_RC_CT_NAME "AVRC Controller"
  43. #endif
  44. #ifndef BTA_AV_RC_TG_NAME
  45. #define BTA_AV_RC_TG_NAME "AVRC Target"
  46. #endif
  47. /* Added to modify
  48. * 1. flush timeout
  49. * 2. Remove Group navigation support in SupportedFeatures
  50. * 3. GetCapabilities supported event_ids list
  51. * 4. GetCapabilities supported event_ids count
  52. */
  53. /* Flushing partial avdtp packets can cause some headsets to disconnect the link
  54. if receiving partial a2dp frames */
  55. const uint16_t bta_av_audio_flush_to[] = {
  56. 0, /* 1 stream */
  57. 0, /* 2 streams */
  58. 0, /* 3 streams */
  59. 0, /* 4 streams */
  60. 0 /* 5 streams */
  61. }; /* AVDTP audio transport channel flush timeout */
  62. /* Note: Android doesnt support AVRC_SUPF_TG_GROUP_NAVI */
  63. /* Note: if AVRC_SUPF_TG_GROUP_NAVI is set, bta_av_cfg.avrc_group should be true
  64. */
  65. #ifndef BTA_AV_RC_SUPF_TG
  66. #define BTA_AV_RC_SUPF_TG \
  67. (AVRC_SUPF_TG_CAT1 | AVRC_SUPF_TG_MULTI_PLAYER | \
  68. AVRC_SUPF_TG_BROWSE) /* TODO: | AVRC_SUPF_TG_APP_SETTINGS) */
  69. #endif
  70. /*
  71. * If the number of event IDs is changed in this array, BTA_AV_NUM_RC_EVT_IDS
  72. * also needs to be changed.
  73. */
  74. const uint8_t bta_av_meta_caps_evt_ids[] = {
  75. AVRC_EVT_PLAY_STATUS_CHANGE, AVRC_EVT_TRACK_CHANGE,
  76. AVRC_EVT_PLAY_POS_CHANGED, AVRC_EVT_AVAL_PLAYERS_CHANGE,
  77. AVRC_EVT_ADDR_PLAYER_CHANGE, AVRC_EVT_UIDS_CHANGE,
  78. AVRC_EVT_NOW_PLAYING_CHANGE,
  79. /* TODO: Add support for these events
  80. AVRC_EVT_APP_SETTING_CHANGE,
  81. */
  82. };
  83. #ifndef BTA_AV_NUM_RC_EVT_IDS
  84. #define BTA_AV_NUM_RC_EVT_IDS \
  85. (sizeof(bta_av_meta_caps_evt_ids) / sizeof(bta_av_meta_caps_evt_ids[0]))
  86. #endif /* BTA_AV_NUM_RC_EVT_IDS */
  87. const uint8_t bta_avk_meta_caps_evt_ids[] = {
  88. #if (AVRC_ADV_CTRL_INCLUDED == TRUE)
  89. AVRC_EVT_VOLUME_CHANGE,
  90. #endif
  91. };
  92. #ifndef BTA_AVK_NUM_RC_EVT_IDS
  93. #define BTA_AVK_NUM_RC_EVT_IDS \
  94. (sizeof(bta_avk_meta_caps_evt_ids) / sizeof(bta_avk_meta_caps_evt_ids[0]))
  95. #endif /* BTA_AVK_NUM_RC_EVT_IDS */
  96. // These are the only events used with AVRCP1.3
  97. const uint8_t bta_av_meta_caps_evt_ids_avrcp13[] = {
  98. AVRC_EVT_PLAY_STATUS_CHANGE, AVRC_EVT_TRACK_CHANGE,
  99. AVRC_EVT_PLAY_POS_CHANGED,
  100. };
  101. #ifndef BTA_AV_NUM_RC_EVT_IDS_AVRCP13
  102. #define BTA_AV_NUM_RC_EVT_IDS_AVRCP13 \
  103. (sizeof(bta_av_meta_caps_evt_ids_avrcp13) / \
  104. sizeof(bta_av_meta_caps_evt_ids_avrcp13[0]))
  105. #endif /* BTA_AVK_NUM_RC_EVT_IDS_AVRCP13 */
  106. /* the MTU for the AVRCP browsing channel */
  107. #ifndef BTA_AV_MAX_RC_BR_MTU
  108. #define BTA_AV_MAX_RC_BR_MTU 1008
  109. #endif
  110. /* This configuration to be used when we are Src + TG + CT( only for abs vol) */
  111. const tBTA_AV_CFG bta_av_cfg = {
  112. BTA_AV_RC_COMP_ID, /* AVRCP Company ID */
  113. 512, /* AVRCP MTU at L2CAP for control channel */
  114. BTA_AV_MAX_RC_BR_MTU, /* AVRCP MTU at L2CAP for browsing channel */
  115. BTA_AV_RC_SUPF_CT, /* AVRCP controller categories */
  116. BTA_AV_RC_SUPF_TG, /* AVRCP target categories */
  117. 672, /* AVDTP signaling channel MTU at L2CAP */
  118. MAX_3MBPS_AVDTP_MTU, /* AVDTP audio transport channel MTU at L2CAP */
  119. bta_av_audio_flush_to, /* AVDTP audio transport channel flush
  120. timeout */
  121. 6, /* AVDTP audio channel max data queue size */
  122. false, /* true, to accept AVRC 1.3 group nevigation command */
  123. 2, /* company id count in p_meta_co_ids */
  124. BTA_AV_NUM_RC_EVT_IDS, /* event id count in p_meta_evt_ids */
  125. BTA_AV_RC_PASS_RSP_CODE, /* the default response code for pass
  126. through commands */
  127. bta_av_meta_caps_co_ids, /* the metadata Get Capabilities response
  128. for company id */
  129. bta_av_meta_caps_evt_ids, /* the the metadata Get Capabilities
  130. response for event id */
  131. NULL, /* the action function table for audio stream */
  132. BTA_AV_RC_CT_NAME, /* Default AVRCP controller name */
  133. BTA_AV_RC_TG_NAME /* Default AVRCP target name */
  134. };
  135. /* This configuration to be used when we are Sink + CT + TG( only for abs vol)
  136. */
  137. const tBTA_AV_CFG bta_avk_cfg = {
  138. AVRC_CO_METADATA, /* AVRCP Company ID */
  139. 512, /* AVRCP MTU at L2CAP for control channel */
  140. BTA_AV_MAX_RC_BR_MTU, /* AVRCP MTU at L2CAP for browsing channel */
  141. BTA_AVK_RC_SUPF_CT, /* AVRCP controller categories */
  142. BTA_AVK_RC_SUPF_TG, /* AVRCP target categories */
  143. 672, /* AVDTP signaling channel MTU at L2CAP */
  144. MAX_3MBPS_AVDTP_MTU, /* AVDTP audio transport channel MTU at L2CAP */
  145. bta_av_audio_flush_to, /* AVDTP audio transport channel flush timeout */
  146. 6, /* AVDTP audio channel max data queue size */
  147. false, /* true, to accept AVRC 1.3 group nevigation command */
  148. 2, /* company id count in p_meta_co_ids */
  149. BTA_AVK_NUM_RC_EVT_IDS, /* event id count in p_meta_evt_ids */
  150. BTA_AV_RC_PASS_RSP_CODE, /* the default response code for pass
  151. through commands */
  152. bta_av_meta_caps_co_ids, /* the metadata Get Capabilities response
  153. for company id */
  154. bta_avk_meta_caps_evt_ids, /* the the metadata Get Capabilities
  155. response for event id */
  156. NULL, /* the action function table for audio stream */
  157. {0}, /* Default AVRCP controller name */
  158. {0}, /* Default AVRCP target name */
  159. };
  160. /* This configuration to be used when we are using AVRCP1.3 */
  161. const tBTA_AV_CFG bta_av_cfg_compatibility = {
  162. BTA_AV_RC_COMP_ID, /* AVRCP Company ID */
  163. 512, /* AVRCP MTU at L2CAP for control channel */
  164. BTA_AV_MAX_RC_BR_MTU, /* AVRCP MTU at L2CAP for browsing channel */
  165. BTA_AV_RC_SUPF_CT, /* AVRCP controller categories */
  166. AVRC_SUPF_TG_CAT1, /* Only support CAT1 for AVRCP1.3 */
  167. 672, /* AVDTP signaling channel MTU at L2CAP */
  168. MAX_3MBPS_AVDTP_MTU, /* AVDTP audio transport channel MTU at L2CAP */
  169. bta_av_audio_flush_to, /* AVDTP audio transport channel flush timeout */
  170. 6, /* AVDTP audio channel max data queue size */
  171. false, /* true, to accept AVRC 1.3 group nevigation command */
  172. 2, /* company id count in p_meta_co_ids */
  173. BTA_AV_NUM_RC_EVT_IDS_AVRCP13, /* event id count for AVRCP1.3 */
  174. BTA_AV_RC_PASS_RSP_CODE, /* the default response code for pass
  175. through commands */
  176. bta_av_meta_caps_co_ids, /* the metadata Get Capabilities response
  177. for company id */
  178. bta_av_meta_caps_evt_ids_avrcp13, /* the the metadata Get Capabilities
  179. response for event id, compatible
  180. with AVRCP1.3 */
  181. NULL, /* the action function table for audio stream */
  182. BTA_AV_RC_CT_NAME, /* Default AVRCP controller name */
  183. BTA_AV_RC_TG_NAME /* Default AVRCP target name */
  184. };
  185. const tBTA_AV_CFG* p_bta_av_cfg = NULL;
  186. const uint16_t bta_av_rc_id[] = {
  187. 0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT,
  188. 4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN, 7=LEFT_UP,
  189. 8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU, 11=CONT_MENU,
  190. 12=FAV_MENU, 13=EXIT */
  191. 0, /* not used */
  192. 0x0000, /* bit mask: 0=0, 1=1, 2=2, 3=3,
  193. 4=4, 5=5, 6=6, 7=7,
  194. 8=8, 9=9, 10=DOT, 11=ENTER,
  195. 12=CLEAR */
  196. 0x0000, /* bit mask: 0=CHAN_UP, 1=CHAN_DOWN, 2=PREV_CHAN, 3=SOUND_SEL,
  197. 4=INPUT_SEL, 5=DISP_INFO, 6=HELP, 7=PAGE_UP,
  198. 8=PAGE_DOWN */
  199. /* btui_app provides an example of how to leave the decision of rejecting a
  200. command or not
  201. * based on which media player is currently addressed (this is only applicable
  202. for AVRCP 1.4 or later)
  203. * If the decision is per player for a particular rc_id, the related bit is
  204. clear (not set)
  205. * bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE, 4=PLAY, 5=STOP,
  206. 6=PAUSE, 7=RECORD, 8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD,
  207. 12=BACKWARD */
  208. #if (BTA_AV_RC_PASS_RSP_CODE == AVRC_RSP_INTERIM)
  209. 0x0070, /* PLAY | STOP | PAUSE */
  210. #else /* BTA_AV_RC_PASS_RSP_CODE != AVRC_RSP_INTERIM */
  211. 0x1b7E, /* PLAY | STOP | PAUSE | FF | RW | VOL_UP | VOL_DOWN | MUTE | FW |
  212. BACK */
  213. #endif /* BTA_AV_RC_PASS_RSP_CODE */
  214. 0x0000, /* bit mask: 0=ANGLE, 1=SUBPICT */
  215. 0, /* not used */
  216. 0x0000 /* bit mask: 0=not used, 1=F1, 2=F2, 3=F3,
  217. 4=F4, 5=F5 */
  218. };
  219. #if (BTA_AV_RC_PASS_RSP_CODE == AVRC_RSP_INTERIM)
  220. const uint16_t bta_av_rc_id_ac[] = {
  221. 0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT,
  222. 4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN,
  223. 7=LEFT_UP,
  224. 8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU,
  225. 11=CONT_MENU,
  226. 12=FAV_MENU, 13=EXIT */
  227. 0, /* not used */
  228. 0x0000, /* bit mask: 0=0, 1=1, 2=2, 3=3,
  229. 4=4, 5=5, 6=6, 7=7,
  230. 8=8, 9=9, 10=DOT, 11=ENTER,
  231. 12=CLEAR */
  232. 0x0000, /* bit mask: 0=CHAN_UP, 1=CHAN_DOWN, 2=PREV_CHAN,
  233. 3=SOUND_SEL,
  234. 4=INPUT_SEL, 5=DISP_INFO, 6=HELP,
  235. 7=PAGE_UP,
  236. 8=PAGE_DOWN */
  237. /* btui_app provides an example of how to leave the decision of
  238. * rejecting a command or not
  239. * based on which media player is currently addressed (this is
  240. * only applicable for AVRCP 1.4 or later)
  241. * If the decision is per player for a particular rc_id, the
  242. * related bit is set */
  243. 0x1800, /* bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE,
  244. 4=PLAY, 5=STOP, 6=PAUSE, 7=RECORD,
  245. 8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD,
  246. 12=BACKWARD */
  247. 0x0000, /* bit mask: 0=ANGLE, 1=SUBPICT */
  248. 0, /* not used */
  249. 0x0000 /* bit mask: 0=not used, 1=F1, 2=F2, 3=F3,
  250. 4=F4, 5=F5 */
  251. };
  252. uint16_t* p_bta_av_rc_id_ac = (uint16_t*)bta_av_rc_id_ac;
  253. #else
  254. uint16_t* p_bta_av_rc_id_ac = NULL;
  255. #endif
  256. uint16_t* p_bta_av_rc_id = (uint16_t*)bta_av_rc_id;