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