• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <cstdint>
27 
28 #include "bt_target.h"  // Must be first to define build configuration
29 
30 #include "bta/include/bta_av_api.h"
31 #include "stack/include/avrc_api.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 
67 /* Note: Android doesnt support AVRC_SUPF_TG_GROUP_NAVI  */
68 /* Note: if AVRC_SUPF_TG_GROUP_NAVI is set, bta_av_cfg.avrc_group should be true
69  */
70 #ifndef BTA_AV_RC_SUPF_TG
71 #define BTA_AV_RC_SUPF_TG                          \
72   (AVRC_SUPF_TG_CAT1 | AVRC_SUPF_TG_MULTI_PLAYER | \
73    AVRC_SUPF_TG_BROWSE) /* TODO: | AVRC_SUPF_TG_APP_SETTINGS) */
74 #endif
75 
76 /*
77  * If the number of event IDs is changed in this array, BTA_AV_NUM_RC_EVT_IDS
78  * also needs to be changed.
79  */
80 const uint8_t bta_av_meta_caps_evt_ids[] = {
81     AVRC_EVT_PLAY_STATUS_CHANGE, AVRC_EVT_TRACK_CHANGE,
82     AVRC_EVT_PLAY_POS_CHANGED,   AVRC_EVT_AVAL_PLAYERS_CHANGE,
83     AVRC_EVT_ADDR_PLAYER_CHANGE, AVRC_EVT_UIDS_CHANGE,
84     AVRC_EVT_NOW_PLAYING_CHANGE,
85     /* TODO: Add support for these events
86     AVRC_EVT_APP_SETTING_CHANGE,
87     */
88 };
89 
90 #ifndef BTA_AV_NUM_RC_EVT_IDS
91 #define BTA_AV_NUM_RC_EVT_IDS \
92   (sizeof(bta_av_meta_caps_evt_ids) / sizeof(bta_av_meta_caps_evt_ids[0]))
93 #endif /* BTA_AV_NUM_RC_EVT_IDS */
94 
95 const uint8_t bta_avk_meta_caps_evt_ids[] = {
96 #if (AVRC_ADV_CTRL_INCLUDED == TRUE)
97     AVRC_EVT_VOLUME_CHANGE,
98 #endif
99 };
100 
101 #ifndef BTA_AVK_NUM_RC_EVT_IDS
102 #define BTA_AVK_NUM_RC_EVT_IDS \
103   (sizeof(bta_avk_meta_caps_evt_ids) / sizeof(bta_avk_meta_caps_evt_ids[0]))
104 #endif /* BTA_AVK_NUM_RC_EVT_IDS */
105 
106 // These are the only events used with AVRCP1.3
107 const uint8_t bta_av_meta_caps_evt_ids_avrcp13[] = {
108     AVRC_EVT_PLAY_STATUS_CHANGE, AVRC_EVT_TRACK_CHANGE,
109     AVRC_EVT_PLAY_POS_CHANGED,
110 };
111 
112 #ifndef BTA_AV_NUM_RC_EVT_IDS_AVRCP13
113 #define BTA_AV_NUM_RC_EVT_IDS_AVRCP13         \
114   (sizeof(bta_av_meta_caps_evt_ids_avrcp13) / \
115    sizeof(bta_av_meta_caps_evt_ids_avrcp13[0]))
116 #endif /* BTA_AVK_NUM_RC_EVT_IDS_AVRCP13 */
117 
118 /* This configuration to be used when we are Src + TG + CT( only for abs vol) */
119 extern const tBTA_AV_CFG bta_av_cfg = {
120     BTA_AV_RC_COMP_ID, /* AVRCP Company ID */
121     BTA_AV_RC_SUPF_CT, /* AVRCP controller categories */
122     BTA_AV_RC_SUPF_TG, /* AVRCP target categories */
123     6,                 /* AVDTP audio channel max data queue size */
124     false,             /* true, to accept AVRC 1.3 group nevigation command */
125     2,                 /* company id count in p_meta_co_ids */
126     BTA_AV_NUM_RC_EVT_IDS,    /* event id count in p_meta_evt_ids */
127     BTA_AV_RC_PASS_RSP_CODE,  /* the default response code for pass
128                                  through commands */
129     bta_av_meta_caps_co_ids,  /* the metadata Get Capabilities response
130                                  for company id */
131     bta_av_meta_caps_evt_ids, /* the the metadata Get Capabilities
132                                  response for event id */
133     BTA_AV_RC_CT_NAME,        /* Default AVRCP controller name */
134     BTA_AV_RC_TG_NAME         /* Default AVRCP target name */
135 };
136 
137 /* This configuration to be used when we are Sink + CT + TG( only for abs vol)
138  */
139 extern const tBTA_AV_CFG bta_avk_cfg = {
140     AVRC_CO_METADATA,   /* AVRCP Company ID */
141     BTA_AVK_RC_SUPF_CT, /* AVRCP controller categories */
142     BTA_AVK_RC_SUPF_TG, /* AVRCP target categories */
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_AVK_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_avk_meta_caps_evt_ids, /* the the metadata Get Capabilities
152                                   response for event id */
153     {0},                       /* Default AVRCP controller name */
154     {0},                       /* Default AVRCP target name */
155 };
156 
157 /* This configuration to be used when we are using AVRCP1.3 */
158 extern const tBTA_AV_CFG bta_av_cfg_compatibility = {
159     BTA_AV_RC_COMP_ID, /* AVRCP Company ID */
160     BTA_AV_RC_SUPF_CT, /* AVRCP controller categories */
161     AVRC_SUPF_TG_CAT1, /* Only support CAT1 for AVRCP1.3 */
162     6,                 /* AVDTP audio channel max data queue size */
163     false,             /* true, to accept AVRC 1.3 group nevigation command */
164     2,                 /* company id count in p_meta_co_ids */
165     BTA_AV_NUM_RC_EVT_IDS_AVRCP13,    /* event id count for AVRCP1.3 */
166     BTA_AV_RC_PASS_RSP_CODE,          /* the default response code for pass
167                                          through commands */
168     bta_av_meta_caps_co_ids,          /* the metadata Get Capabilities response
169                                          for company id */
170     bta_av_meta_caps_evt_ids_avrcp13, /* the the metadata Get Capabilities
171                                          response for event id, compatible
172                                          with AVRCP1.3 */
173     BTA_AV_RC_CT_NAME,                /* Default AVRCP controller name */
174     BTA_AV_RC_TG_NAME                 /* Default AVRCP target name */
175 };
176 
177 const tBTA_AV_CFG* p_bta_av_cfg = NULL;
178 
179 const uint16_t bta_av_rc_id[] = {
180     0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT,
181                          4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN, 7=LEFT_UP,
182                          8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU, 11=CONT_MENU,
183                          12=FAV_MENU, 13=EXIT */
184 
185     0, /* not used */
186 
187     0x0000, /* bit mask: 0=0, 1=1, 2=2, 3=3,
188                          4=4, 5=5, 6=6, 7=7,
189                          8=8, 9=9, 10=DOT, 11=ENTER,
190                          12=CLEAR */
191 
192     0x0000, /* bit mask: 0=CHAN_UP, 1=CHAN_DOWN, 2=PREV_CHAN, 3=SOUND_SEL,
193                          4=INPUT_SEL, 5=DISP_INFO, 6=HELP, 7=PAGE_UP,
194                          8=PAGE_DOWN */
195 
196 /* btui_app provides an example of how to leave the decision of rejecting a
197  command or not
198  * based on which media player is currently addressed (this is only applicable
199  for AVRCP 1.4 or later)
200  * If the decision is per player for a particular rc_id, the related bit is
201  clear (not set)
202  * bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE, 4=PLAY, 5=STOP,
203              6=PAUSE, 7=RECORD, 8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD,
204              12=BACKWARD */
205 #if (BTA_AV_RC_PASS_RSP_CODE == AVRC_RSP_INTERIM)
206     0x0070, /* PLAY | STOP | PAUSE */
207 #else       /* BTA_AV_RC_PASS_RSP_CODE != AVRC_RSP_INTERIM */
208     0x1b7E, /* PLAY | STOP | PAUSE | FF | RW | VOL_UP | VOL_DOWN | MUTE | FW |
209                BACK */
210 #endif /* BTA_AV_RC_PASS_RSP_CODE */
211 
212     0x0000, /* bit mask: 0=ANGLE, 1=SUBPICT */
213 
214     0, /* not used */
215 
216     0x0000 /* bit mask: 0=not used, 1=F1, 2=F2, 3=F3,
217                         4=F4, 5=F5 */
218 };
219 
220 #if (BTA_AV_RC_PASS_RSP_CODE == AVRC_RSP_INTERIM)
221 const uint16_t bta_av_rc_id_ac[] = {
222     0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT,
223                          4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN,
224                7=LEFT_UP,
225                          8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU,
226                11=CONT_MENU,
227                          12=FAV_MENU, 13=EXIT */
228 
229     0, /* not used */
230 
231     0x0000, /* bit mask: 0=0, 1=1, 2=2, 3=3,
232                          4=4, 5=5, 6=6, 7=7,
233                          8=8, 9=9, 10=DOT, 11=ENTER,
234                          12=CLEAR */
235 
236     0x0000, /* bit mask: 0=CHAN_UP, 1=CHAN_DOWN, 2=PREV_CHAN,
237                3=SOUND_SEL,
238                          4=INPUT_SEL, 5=DISP_INFO, 6=HELP,
239                7=PAGE_UP,
240                          8=PAGE_DOWN */
241 
242     /* btui_app provides an example of how to leave the decision of
243      * rejecting a command or not
244      * based on which media player is currently addressed (this is
245      * only applicable for AVRCP 1.4 or later)
246      * If the decision is per player for a particular rc_id, the
247      * related bit is set */
248     0x1800, /* bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE,
249                          4=PLAY, 5=STOP, 6=PAUSE, 7=RECORD,
250                          8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD,
251                          12=BACKWARD */
252 
253     0x0000, /* bit mask: 0=ANGLE, 1=SUBPICT */
254 
255     0, /* not used */
256 
257     0x0000 /* bit mask: 0=not used, 1=F1, 2=F2, 3=F3,
258                         4=F4, 5=F5 */
259 };
260 uint16_t* p_bta_av_rc_id_ac = (uint16_t*)bta_av_rc_id_ac;
261 #else
262 uint16_t* p_bta_av_rc_id_ac = NULL;
263 #endif
264 
265 uint16_t* p_bta_av_rc_id = (uint16_t*)bta_av_rc_id;
266