Line data Source code
1 1 : /** @file
2 : * @brief Audio Video Remote Control Profile header.
3 : */
4 :
5 : /*
6 : * Copyright (c) 2015-2016 Intel Corporation
7 : * Copyright (C) 2024 Xiaomi Corporation
8 : *
9 : * SPDX-License-Identifier: Apache-2.0
10 : */
11 :
12 : #ifndef ZEPHYR_INCLUDE_BLUETOOTH_AVRCP_H_
13 : #define ZEPHYR_INCLUDE_BLUETOOTH_AVRCP_H_
14 :
15 : #ifdef __cplusplus
16 : extern "C" {
17 : #endif
18 :
19 0 : #define BT_AVRCP_COMPANY_ID_SIZE (3)
20 0 : #define BT_AVRCP_COMPANY_ID_BLUETOOTH_SIG (0x001958)
21 :
22 : /** @brief AVRCP Capability ID */
23 0 : typedef enum __packed {
24 : BT_AVRCP_CAP_COMPANY_ID = 0x2,
25 : BT_AVRCP_CAP_EVENTS_SUPPORTED = 0x3,
26 : } bt_avrcp_cap_t;
27 :
28 : /** @brief AVRCP Notification Events */
29 0 : typedef enum __packed {
30 : BT_AVRCP_EVT_PLAYBACK_STATUS_CHANGED = 0x01,
31 : BT_AVRCP_EVT_TRACK_CHANGED = 0x02,
32 : BT_AVRCP_EVT_TRACK_REACHED_END = 0x03,
33 : BT_AVRCP_EVT_TRACK_REACHED_START = 0x04,
34 : BT_AVRCP_EVT_PLAYBACK_POS_CHANGED = 0x05,
35 : BT_AVRCP_EVT_BATT_STATUS_CHANGED = 0x06,
36 : BT_AVRCP_EVT_SYSTEM_STATUS_CHANGED = 0x07,
37 : BT_AVRCP_EVT_PLAYER_APP_SETTING_CHANGED = 0x08,
38 : BT_AVRCP_EVT_NOW_PLAYING_CONTENT_CHANGED = 0x09,
39 : BT_AVRCP_EVT_AVAILABLE_PLAYERS_CHANGED = 0x0a,
40 : BT_AVRCP_EVT_ADDRESSED_PLAYER_CHANGED = 0x0b,
41 : BT_AVRCP_EVT_UIDS_CHANGED = 0x0c,
42 : BT_AVRCP_EVT_VOLUME_CHANGED = 0x0d,
43 : } bt_avrcp_evt_t;
44 :
45 : /** @brief AV/C command types */
46 0 : typedef enum __packed {
47 : BT_AVRCP_CTYPE_CONTROL = 0x0,
48 : BT_AVRCP_CTYPE_STATUS = 0x1,
49 : BT_AVRCP_CTYPE_SPECIFIC_INQUIRY = 0x2,
50 : BT_AVRCP_CTYPE_NOTIFY = 0x3,
51 : BT_AVRCP_CTYPE_GENERAL_INQUIRY = 0x4,
52 : } bt_avrcp_ctype_t;
53 :
54 : /** @brief AV/C response codes */
55 0 : typedef enum __packed {
56 : BT_AVRCP_RSP_NOT_IMPLEMENTED = 0x8,
57 : BT_AVRCP_RSP_ACCEPTED = 0x9,
58 : BT_AVRCP_RSP_REJECTED = 0xa,
59 : BT_AVRCP_RSP_IN_TRANSITION = 0xb,
60 : BT_AVRCP_RSP_IMPLEMENTED = 0xc, /**< For SPECIFIC_INQUIRY and GENERAL_INQUIRY commands */
61 : BT_AVRCP_RSP_STABLE = 0xc, /**< For STATUS commands */
62 : BT_AVRCP_RSP_CHANGED = 0xd,
63 : BT_AVRCP_RSP_INTERIM = 0xf,
64 : } bt_avrcp_rsp_t;
65 :
66 : /** @brief AV/C subunit type, also used for unit type */
67 0 : typedef enum __packed {
68 : BT_AVRCP_SUBUNIT_TYPE_PANEL = 0x09,
69 : BT_AVRCP_SUBUNIT_TYPE_UNIT = 0x1f,
70 : } bt_avrcp_subunit_type_t;
71 :
72 : /** @brief AV/C operation ids used in AVRCP passthrough commands */
73 0 : typedef enum __packed {
74 : BT_AVRCP_OPID_SELECT = 0x00,
75 : BT_AVRCP_OPID_UP = 0x01,
76 : BT_AVRCP_OPID_DOWN = 0x02,
77 : BT_AVRCP_OPID_LEFT = 0x03,
78 : BT_AVRCP_OPID_RIGHT = 0x04,
79 : BT_AVRCP_OPID_RIGHT_UP = 0x05,
80 : BT_AVRCP_OPID_RIGHT_DOWN = 0x06,
81 : BT_AVRCP_OPID_LEFT_UP = 0x07,
82 : BT_AVRCP_OPID_LEFT_DOWN = 0x08,
83 : BT_AVRCP_OPID_ROOT_MENU = 0x09,
84 : BT_AVRCP_OPID_SETUP_MENU = 0x0a,
85 : BT_AVRCP_OPID_CONTENTS_MENU = 0x0b,
86 : BT_AVRCP_OPID_FAVORITE_MENU = 0x0c,
87 : BT_AVRCP_OPID_EXIT = 0x0d,
88 :
89 : BT_AVRCP_OPID_0 = 0x20,
90 : BT_AVRCP_OPID_1 = 0x21,
91 : BT_AVRCP_OPID_2 = 0x22,
92 : BT_AVRCP_OPID_3 = 0x23,
93 : BT_AVRCP_OPID_4 = 0x24,
94 : BT_AVRCP_OPID_5 = 0x25,
95 : BT_AVRCP_OPID_6 = 0x26,
96 : BT_AVRCP_OPID_7 = 0x27,
97 : BT_AVRCP_OPID_8 = 0x28,
98 : BT_AVRCP_OPID_9 = 0x29,
99 : BT_AVRCP_OPID_DOT = 0x2a,
100 : BT_AVRCP_OPID_ENTER = 0x2b,
101 : BT_AVRCP_OPID_CLEAR = 0x2c,
102 :
103 : BT_AVRCP_OPID_CHANNEL_UP = 0x30,
104 : BT_AVRCP_OPID_CHANNEL_DOWN = 0x31,
105 : BT_AVRCP_OPID_PREVIOUS_CHANNEL = 0x32,
106 : BT_AVRCP_OPID_SOUND_SELECT = 0x33,
107 : BT_AVRCP_OPID_INPUT_SELECT = 0x34,
108 : BT_AVRCP_OPID_DISPLAY_INFORMATION = 0x35,
109 : BT_AVRCP_OPID_HELP = 0x36,
110 : BT_AVRCP_OPID_PAGE_UP = 0x37,
111 : BT_AVRCP_OPID_PAGE_DOWN = 0x38,
112 :
113 : BT_AVRCP_OPID_POWER = 0x40,
114 : BT_AVRCP_OPID_VOLUME_UP = 0x41,
115 : BT_AVRCP_OPID_VOLUME_DOWN = 0x42,
116 : BT_AVRCP_OPID_MUTE = 0x43,
117 : BT_AVRCP_OPID_PLAY = 0x44,
118 : BT_AVRCP_OPID_STOP = 0x45,
119 : BT_AVRCP_OPID_PAUSE = 0x46,
120 : BT_AVRCP_OPID_RECORD = 0x47,
121 : BT_AVRCP_OPID_REWIND = 0x48,
122 : BT_AVRCP_OPID_FAST_FORWARD = 0x49,
123 : BT_AVRCP_OPID_EJECT = 0x4a,
124 : BT_AVRCP_OPID_FORWARD = 0x4b,
125 : BT_AVRCP_OPID_BACKWARD = 0x4c,
126 :
127 : BT_AVRCP_OPID_ANGLE = 0x50,
128 : BT_AVRCP_OPID_SUBPICTURE = 0x51,
129 :
130 : BT_AVRCP_OPID_F1 = 0x71,
131 : BT_AVRCP_OPID_F2 = 0x72,
132 : BT_AVRCP_OPID_F3 = 0x73,
133 : BT_AVRCP_OPID_F4 = 0x74,
134 : BT_AVRCP_OPID_F5 = 0x75,
135 : BT_AVRCP_OPID_VENDOR_UNIQUE = 0x7e,
136 : } bt_avrcp_opid_t;
137 :
138 : /** @brief AVRCP button state flag */
139 0 : typedef enum __packed {
140 : BT_AVRCP_BUTTON_PRESSED = 0,
141 : BT_AVRCP_BUTTON_RELEASED = 1,
142 : } bt_avrcp_button_state_t;
143 :
144 : /**
145 : * @brief AVRCP status and error codes.
146 : *
147 : * These status codes are used in AVRCP responses to indicate the result of a command.
148 : */
149 1 : typedef enum __packed {
150 : /** Invalid command.
151 : * Valid for Commands: All
152 : */
153 : BT_AVRCP_STATUS_INVALID_COMMAND = 0x00,
154 :
155 : /** Invalid parameter.
156 : * Valid for Commands: All
157 : */
158 : BT_AVRCP_STATUS_INVALID_PARAMETER = 0x01,
159 :
160 : /** Parameter content error.
161 : * Valid for Commands: All
162 : */
163 : BT_AVRCP_STATUS_PARAMETER_CONTENT_ERROR = 0x02,
164 :
165 : /** Internal error.
166 : * Valid for Commands: All
167 : */
168 : BT_AVRCP_STATUS_INTERNAL_ERROR = 0x03,
169 :
170 : /** Operation completed without error.
171 : * Valid for Commands: All except where the response CType is AV/C REJECTED
172 : */
173 : BT_AVRCP_STATUS_OPERATION_COMPLETED = 0x04,
174 :
175 : /** The UIDs on the device have changed.
176 : * Valid for Commands: All
177 : */
178 : BT_AVRCP_STATUS_UID_CHANGED = 0x05,
179 :
180 : /** The Direction parameter is invalid.
181 : * Valid for Commands: ChangePath
182 : */
183 : BT_AVRCP_STATUS_INVALID_DIRECTION = 0x07,
184 :
185 : /** The UID provided does not refer to a folder item.
186 : * Valid for Commands: ChangePath
187 : */
188 : BT_AVRCP_STATUS_NOT_A_DIRECTORY = 0x08,
189 :
190 : /** The UID provided does not refer to any currently valid item.
191 : * Valid for Commands: ChangePath, PlayItem, AddToNowPlaying, GetItemAttributes
192 : */
193 : BT_AVRCP_STATUS_DOES_NOT_EXIST = 0x09,
194 :
195 : /** Invalid scope.
196 : * Valid for Commands: GetFolderItems, PlayItem, AddToNowPlayer, GetItemAttributes,
197 : * GetTotalNumberOfItems
198 : */
199 : BT_AVRCP_STATUS_INVALID_SCOPE = 0x0a,
200 :
201 : /** Range out of bounds.
202 : * Valid for Commands: GetFolderItems
203 : */
204 : BT_AVRCP_STATUS_RANGE_OUT_OF_BOUNDS = 0x0b,
205 :
206 : /** Folder item is not playable.
207 : * Valid for Commands: Play Item, AddToNowPlaying
208 : */
209 : BT_AVRCP_STATUS_FOLDER_ITEM_IS_NOT_PLAYABLE = 0x0c,
210 :
211 : /** Media in use.
212 : * Valid for Commands: PlayItem, AddToNowPlaying
213 : */
214 : BT_AVRCP_STATUS_MEDIA_IN_USE = 0x0d,
215 :
216 : /** Now Playing List full.
217 : * Valid for Commands: AddToNowPlaying
218 : */
219 : BT_AVRCP_STATUS_NOW_PLAYING_LIST_FULL = 0x0e,
220 :
221 : /** Search not supported.
222 : * Valid for Commands: Search
223 : */
224 : BT_AVRCP_STATUS_SEARCH_NOT_SUPPORTED = 0x0f,
225 :
226 : /** Search in progress.
227 : * Valid for Commands: Search
228 : */
229 : BT_AVRCP_STATUS_SEARCH_IN_PROGRESS = 0x10,
230 :
231 : /** The specified Player Id does not refer to a valid player.
232 : * Valid for Commands: SetAddressedPlayer, SetBrowsedPlayer
233 : */
234 : BT_AVRCP_STATUS_INVALID_PLAYER_ID = 0x11,
235 :
236 : /** Player not browsable.
237 : * Valid for Commands: SetBrowsedPlayer
238 : */
239 : BT_AVRCP_STATUS_PLAYER_NOT_BROWSABLE = 0x12,
240 :
241 : /** Player not addressed.
242 : * Valid for Commands: Search, SetBrowsedPlayer
243 : */
244 : BT_AVRCP_STATUS_PLAYER_NOT_ADDRESSED = 0x13,
245 :
246 : /** No valid search results.
247 : * Valid for Commands: GetFolderItems
248 : */
249 : BT_AVRCP_STATUS_NO_VALID_SEARCH_RESULTS = 0x14,
250 :
251 : /** No available players.
252 : * Valid for Commands: ALL
253 : */
254 : BT_AVRCP_STATUS_NO_AVAILABLE_PLAYERS = 0x15,
255 :
256 : /** Addressed player changed.
257 : * Valid for Commands: All Register Notification commands
258 : */
259 : BT_AVRCP_STATUS_ADDRESSED_PLAYER_CHANGED = 0x16,
260 : } bt_avrcp_status_t;
261 :
262 : /** @brief AVRCP CT structure */
263 : struct bt_avrcp_ct;
264 : /** @brief AVRCP TG structure */
265 : struct bt_avrcp_tg;
266 :
267 0 : struct bt_avrcp_unit_info_rsp {
268 0 : bt_avrcp_subunit_type_t unit_type;
269 0 : uint32_t company_id;
270 : };
271 :
272 0 : struct bt_avrcp_subunit_info_rsp {
273 0 : bt_avrcp_subunit_type_t subunit_type;
274 0 : uint8_t max_subunit_id;
275 1 : const uint8_t *extended_subunit_type; /**< contains max_subunit_id items */
276 1 : const uint8_t *extended_subunit_id; /**< contains max_subunit_id items */
277 : };
278 :
279 0 : #define BT_AVRCP_PASSTHROUGH_GET_STATE(payload) \
280 : ((bt_avrcp_opid_t)(FIELD_GET(BIT(7), ((payload)->opid_state))))
281 0 : #define BT_AVRCP_PASSTHROUGH_GET_OPID(payload) \
282 : ((bt_avrcp_button_state_t)(FIELD_GET(GENMASK(6, 0), ((payload)->opid_state))))
283 0 : #define BT_AVRCP_PASSTHROUGH_SET_STATE_OPID(payload, state, opid) \
284 : (payload)->opid_state = FIELD_PREP(BIT(7), state) | FIELD_PREP(GENMASK(6, 0), opid)
285 :
286 0 : struct bt_avrcp_passthrough_opvu_data {
287 0 : uint8_t company_id[BT_AVRCP_COMPANY_ID_SIZE];
288 0 : uint16_t opid_vu;
289 : } __packed;
290 :
291 0 : struct bt_avrcp_passthrough_cmd {
292 1 : uint8_t opid_state; /**< [7]: state_flag, [6:0]: opid */
293 0 : uint8_t data_len;
294 1 : struct bt_avrcp_passthrough_opvu_data data[0]; /**< opvu data */
295 : } __packed;
296 :
297 0 : struct bt_avrcp_passthrough_rsp {
298 1 : uint8_t opid_state; /**< [7]: state_flag, [6:0]: opid */
299 0 : uint8_t data_len;
300 1 : struct bt_avrcp_passthrough_opvu_data data[0]; /**< opvu data */
301 : } __packed;
302 :
303 0 : struct bt_avrcp_get_cap_rsp {
304 1 : uint8_t cap_id; /**< bt_avrcp_cap_t */
305 1 : uint8_t cap_cnt; /**< number of items contained in *cap */
306 1 : uint8_t cap[]; /**< 1 or 3 octets each depends on cap_id */
307 : } __packed;
308 :
309 : /** @brief AVRCP Character Set IDs */
310 0 : typedef enum __packed {
311 : BT_AVRCP_CHARSET_UTF8 = 0x006a,
312 : } bt_avrcp_charset_t;
313 :
314 : /** @brief get folder name (response) */
315 1 : struct bt_avrcp_folder_name {
316 0 : uint16_t folder_name_len;
317 0 : uint8_t folder_name[];
318 : } __packed;
319 :
320 : /** @brief Set browsed player response structure */
321 1 : struct bt_avrcp_set_browsed_player_rsp {
322 1 : uint8_t status; /**< Status see bt_avrcp_status_t.*/
323 1 : uint16_t uid_counter; /**< UID counter */
324 1 : uint32_t num_items; /**< Number of items in the folder */
325 1 : uint16_t charset_id; /**< Character set ID */
326 1 : uint8_t folder_depth; /**< Folder depth */
327 1 : struct bt_avrcp_folder_name folder_names[0]; /**< Folder names data */
328 : } __packed;
329 :
330 0 : struct bt_avrcp_ct_cb {
331 : /** @brief An AVRCP CT connection has been established.
332 : *
333 : * This callback notifies the application of an avrcp connection,
334 : * i.e., an AVCTP L2CAP connection.
335 : *
336 : * @param conn Connection object.
337 : * @param ct AVRCP CT connection object.
338 : */
339 1 : void (*connected)(struct bt_conn *conn, struct bt_avrcp_ct *ct);
340 :
341 : /** @brief An AVRCP CT connection has been disconnected.
342 : *
343 : * This callback notifies the application that an avrcp connection
344 : * has been disconnected.
345 : *
346 : * @param ct AVRCP CT connection object.
347 : */
348 1 : void (*disconnected)(struct bt_avrcp_ct *ct);
349 :
350 : /** @brief An AVRCP CT browsing connection has been established.
351 : *
352 : * This callback notifies the application of an avrcp browsing connection,
353 : * i.e., an AVCTP browsing L2CAP connection.
354 : *
355 : * @param conn Connection object.
356 : * @param ct AVRCP CT connection object.
357 : */
358 1 : void (*browsing_connected)(struct bt_conn *conn, struct bt_avrcp_ct *ct);
359 :
360 : /** @brief An AVRCP CT browsing connection has been disconnected.
361 : *
362 : * This callback notifies the application that an avrcp browsing connection
363 : * has been disconnected.
364 : *
365 : * @param ct AVRCP CT connection object.
366 : */
367 1 : void (*browsing_disconnected)(struct bt_avrcp_ct *ct);
368 :
369 : /** @brief Callback function for bt_avrcp_get_cap().
370 : *
371 : * Called when the get capabilities process is completed.
372 : *
373 : * @param ct AVRCP CT connection object.
374 : * @param tid The transaction label of the response.
375 : * @param rsp The response for Get Capabilities command.
376 : */
377 1 : void (*get_cap_rsp)(struct bt_avrcp_ct *ct, uint8_t tid,
378 : const struct bt_avrcp_get_cap_rsp *rsp);
379 :
380 : /** @brief Callback function for bt_avrcp_get_unit_info().
381 : *
382 : * Called when the get unit info process is completed.
383 : *
384 : * @param ct AVRCP CT connection object.
385 : * @param tid The transaction label of the response.
386 : * @param rsp The response for UNIT INFO command.
387 : */
388 1 : void (*unit_info_rsp)(struct bt_avrcp_ct *ct, uint8_t tid,
389 : struct bt_avrcp_unit_info_rsp *rsp);
390 :
391 : /** @brief Callback function for bt_avrcp_get_subunit_info().
392 : *
393 : * Called when the get subunit info process is completed.
394 : *
395 : * @param ct AVRCP CT connection object.
396 : * @param tid The transaction label of the response.
397 : * @param rsp The response for SUBUNIT INFO command.
398 : */
399 1 : void (*subunit_info_rsp)(struct bt_avrcp_ct *ct, uint8_t tid,
400 : struct bt_avrcp_subunit_info_rsp *rsp);
401 :
402 : /** @brief Callback function for bt_avrcp_passthrough().
403 : *
404 : * Called when a passthrough response is received.
405 : *
406 : * @param ct AVRCP CT connection object.
407 : * @param tid The transaction label of the response.
408 : * @param result The result of the operation.
409 : * @param rsp The response for PASS THROUGH command.
410 : */
411 1 : void (*passthrough_rsp)(struct bt_avrcp_ct *ct, uint8_t tid, bt_avrcp_rsp_t result,
412 : const struct bt_avrcp_passthrough_rsp *rsp);
413 :
414 : /** @brief Callback function for bt_avrcp_ct_set_browsed_player().
415 : *
416 : * Called when the set browsed player process is completed.
417 : *
418 : * @param ct AVRCP CT connection object.
419 : * @param tid The transaction label of the response.
420 : * @param buf The response buffer containing the set browsed player response data.
421 : * The application can parse this payload according to the format defined in
422 : * @ref bt_avrcp_set_browsed_player_rsp. Note that the data is encoded in
423 : * big-endian format.
424 : */
425 1 : void (*browsed_player_rsp)(struct bt_avrcp_ct *ct, uint8_t tid, struct net_buf *buf);
426 : };
427 :
428 : /** @brief Connect AVRCP.
429 : *
430 : * This function is to be called after the conn parameter is obtained by
431 : * performing a GAP procedure. The API is to be used to establish AVRCP
432 : * connection between devices.
433 : *
434 : * @param conn Pointer to bt_conn structure.
435 : *
436 : * @return 0 in case of success or error code in case of error.
437 : *
438 : */
439 1 : int bt_avrcp_connect(struct bt_conn *conn);
440 :
441 : /** @brief Disconnect AVRCP.
442 : *
443 : * This function close AVCTP L2CAP connection.
444 : *
445 : * @param conn Pointer to bt_conn structure.
446 : *
447 : * @return 0 in case of success or error code in case of error.
448 : */
449 1 : int bt_avrcp_disconnect(struct bt_conn *conn);
450 :
451 : /**
452 : * @brief Allocate a net_buf for AVRCP PDU transmission, reserving headroom
453 : * for AVRCP, AVRCTP, L2CAP, and ACL headers.
454 : *
455 : * This function allocates a buffer from the specified pool and reserves
456 : * sufficient headroom for protocol headers required by AVRCP over Bluetooth.
457 : *
458 : * @param pool The buffer pool to allocate from.
459 : *
460 : * @return A newly allocated net_buf with reserved headroom.
461 : */
462 1 : struct net_buf *bt_avrcp_create_pdu(struct net_buf_pool *pool);
463 :
464 : /** @brief Connect AVRCP browsing channel.
465 : *
466 : * This function is to be called after the AVRCP control channel is established.
467 : * The API is to be used to establish AVRCP browsing connection between devices.
468 : *
469 : * @param conn Pointer to bt_conn structure.
470 : *
471 : * @return 0 in case of success or error code in case of error.
472 : */
473 1 : int bt_avrcp_browsing_connect(struct bt_conn *conn);
474 :
475 : /** @brief Disconnect AVRCP browsing channel.
476 : *
477 : * This function close AVCTP browsing channel L2CAP connection.
478 : *
479 : * @param conn Pointer to bt_conn structure.
480 : *
481 : * @return 0 in case of success or error code in case of error.
482 : */
483 1 : int bt_avrcp_browsing_disconnect(struct bt_conn *conn);
484 :
485 : /** @brief Register callback.
486 : *
487 : * Register AVRCP callbacks to monitor the state and interact with the remote device.
488 : *
489 : * @param cb The AVRCP CT callback function.
490 : *
491 : * @return 0 in case of success or error code in case of error.
492 : */
493 1 : int bt_avrcp_ct_register_cb(const struct bt_avrcp_ct_cb *cb);
494 :
495 : /** @brief Get AVRCP Capabilities.
496 : *
497 : * This function gets the capabilities supported by remote device.
498 : *
499 : * @param ct The AVRCP CT instance.
500 : * @param tid The transaction label of the response, valid from 0 to 15.
501 : * @param cap_id Specific capability requested, see @ref bt_avrcp_cap_t.
502 : *
503 : * @return 0 in case of success or error code in case of error.
504 : */
505 1 : int bt_avrcp_ct_get_cap(struct bt_avrcp_ct *ct, uint8_t tid, uint8_t cap_id);
506 :
507 : /** @brief Get AVRCP Unit Info.
508 : *
509 : * This function obtains information that pertains to the AV/C unit as a whole.
510 : *
511 : * @param ct The AVRCP CT instance.
512 : * @param tid The transaction label of the response, valid from 0 to 15.
513 : *
514 : * @return 0 in case of success or error code in case of error.
515 : */
516 1 : int bt_avrcp_ct_get_unit_info(struct bt_avrcp_ct *ct, uint8_t tid);
517 :
518 : /** @brief Get AVRCP Subunit Info.
519 : *
520 : * This function obtains information about the subunit(s) of an AV/C unit. A device with AVRCP
521 : * may support other subunits than the panel subunit if other profiles co-exist in the device.
522 : *
523 : * @param ct The AVRCP CT instance.
524 : * @param tid The transaction label of the response, valid from 0 to 15.
525 : *
526 : * @return 0 in case of success or error code in case of error.
527 : */
528 1 : int bt_avrcp_ct_get_subunit_info(struct bt_avrcp_ct *ct, uint8_t tid);
529 :
530 : /** @brief Send AVRCP Pass Through command.
531 : *
532 : * This function send a pass through command to the remote device. Passsthhrough command is used
533 : * to transfer user operation information from a CT to Panel subunit of TG.
534 : *
535 : * @param ct The AVRCP CT instance.
536 : * @param tid The transaction label of the response, valid from 0 to 15.
537 : * @param opid The user operation id, see @ref bt_avrcp_opid_t.
538 : * @param state The button state, see @ref bt_avrcp_button_state_t.
539 : * @param payload The payload of the pass through command. Should not be NULL if len is not zero.
540 : * @param len The length of the payload.
541 : *
542 : * @return 0 in case of success or error code in case of error.
543 : */
544 1 : int bt_avrcp_ct_passthrough(struct bt_avrcp_ct *ct, uint8_t tid, uint8_t opid, uint8_t state,
545 : const uint8_t *payload, uint8_t len);
546 :
547 : /** @brief Set browsed player.
548 : *
549 : * This function sets the browsed player on the remote device.
550 : *
551 : * @param ct The AVRCP CT instance.
552 : * @param tid The transaction label of the response, valid from 0 to 15.
553 : * @param player_id The player ID to be set as browsed player.
554 : *
555 : * @return 0 in case of success or error code in case of error.
556 : */
557 1 : int bt_avrcp_ct_set_browsed_player(struct bt_avrcp_ct *ct, uint8_t tid, uint16_t player_id);
558 :
559 0 : struct bt_avrcp_tg_cb {
560 : /** @brief An AVRCP TG connection has been established.
561 : *
562 : * This callback notifies the application of an avrcp connection,
563 : * i.e., an AVCTP L2CAP connection.
564 : *
565 : * @param conn Connection object.
566 : * @param tg AVRCP TG connection object.
567 : */
568 1 : void (*connected)(struct bt_conn *conn, struct bt_avrcp_tg *tg);
569 :
570 : /** @brief An AVRCP TG connection has been disconnected.
571 : *
572 : * This callback notifies the application that an avrcp connection
573 : * has been disconnected.
574 : *
575 : * @param tg AVRCP TG connection object.
576 : */
577 1 : void (*disconnected)(struct bt_avrcp_tg *tg);
578 :
579 : /** @brief Unit info request callback.
580 : *
581 : * This callback is called whenever an AVRCP unit info is requested.
582 : *
583 : * @param tid The transaction label of the request.
584 : * @param tg AVRCP TG connection object.
585 : */
586 1 : void (*unit_info_req)(struct bt_avrcp_tg *tg, uint8_t tid);
587 :
588 : /** @brief Subunit Info Request callback.
589 : *
590 : * This callback is called whenever an AVRCP subunit info is requested.
591 : *
592 : * @param tg AVRCP TG connection object.
593 : * @param tid The transaction label of the request.
594 : */
595 1 : void (*subunit_info_req)(struct bt_avrcp_tg *tg, uint8_t tid);
596 :
597 : /** @brief An AVRCP TG browsing connection has been established.
598 : *
599 : * This callback notifies the application of an avrcp browsing connection,
600 : * i.e., an AVCTP browsing L2CAP connection.
601 : *
602 : * @param conn Connection object.
603 : * @param tg AVRCP TG connection object.
604 : */
605 1 : void (*browsing_connected)(struct bt_conn *conn, struct bt_avrcp_tg *tg);
606 :
607 : /** @brief An AVRCP TG browsing connection has been disconnected.
608 : *
609 : * This callback notifies the application that an avrcp browsing connection
610 : * has been disconnected.
611 : *
612 : * @param tg AVRCP TG connection object.
613 : */
614 1 : void (*browsing_disconnected)(struct bt_avrcp_tg *tg);
615 :
616 : /** @brief Set browsed player request callback.
617 : *
618 : * This callback is called whenever an AVRCP set browsed player request is received.
619 : *
620 : * @param tg AVRCP TG connection object.
621 : * @param tid The transaction label of the request.
622 : * @param player_id The player ID to be set as browsed player.
623 : */
624 1 : void (*set_browsed_player_req)(struct bt_avrcp_tg *tg, uint8_t tid, uint16_t player_id);
625 :
626 : /** @brief Pass Through command request callback.
627 : *
628 : * This callback is called whenever an AVRCP Pass Through command is request.
629 : *
630 : * @param tg AVRCP TG connection object.
631 : * @param tid The transaction label of the request.
632 : * @param buf The buffer containing the PASS THROUGH command payload.
633 : * The application can parse this payload according to the format defined
634 : * in @ref bt_avrcp_passthrough_rsp. Note that the data is encoded
635 : * in big-endian format.
636 : */
637 1 : void (*passthrough_req)(struct bt_avrcp_tg *tg, uint8_t tid, struct net_buf *buf);
638 : };
639 :
640 : /** @brief Register callback.
641 : *
642 : * Register AVRCP callbacks to monitor the state and interact with the remote device.
643 : *
644 : * @param cb The AVRCP TG callback function.
645 : *
646 : * @return 0 in case of success or error code in case of error.
647 : */
648 1 : int bt_avrcp_tg_register_cb(const struct bt_avrcp_tg_cb *cb);
649 :
650 : /** @brief Send the unit info response.
651 : *
652 : * This function is called by the application to send the unit info response.
653 : *
654 : * @param tg The AVRCP TG instance.
655 : * @param tid The transaction label of the response, valid from 0 to 15.
656 : * @param rsp The response for UNIT INFO command.
657 : *
658 : * @return 0 in case of success or error code in case of error.
659 : */
660 1 : int bt_avrcp_tg_send_unit_info_rsp(struct bt_avrcp_tg *tg, uint8_t tid,
661 : struct bt_avrcp_unit_info_rsp *rsp);
662 :
663 : /** @brief Send the subunit info response.
664 : *
665 : * This function is called by the application to send the subunit info response.
666 : *
667 : * @param tg The AVRCP TG instance.
668 : * @param tid The transaction label of the response, valid from 0 to 15.
669 : *
670 : * @return 0 in case of success or error code in case of error.
671 : */
672 1 : int bt_avrcp_tg_send_subunit_info_rsp(struct bt_avrcp_tg *tg, uint8_t tid);
673 :
674 : /** @brief Send the set browsed player response.
675 : *
676 : * This function is called by the application to send the set browsed player response.
677 : *
678 : * @param tg The AVRCP TG instance.
679 : * @param tid The transaction label of the response, valid from 0 to 15.
680 : * @param buf The response buffer containing the set browsed player response data.
681 : *
682 : * @return 0 in case of success or error code in case of error.
683 : */
684 1 : int bt_avrcp_tg_send_set_browsed_player_rsp(struct bt_avrcp_tg *tg, uint8_t tid,
685 : struct net_buf *buf);
686 :
687 : /** @brief Send AVRCP Pass Through response.
688 : *
689 : * This function is called by the application to send the Pass Through response.
690 : *
691 : * @param tg The AVRCP TG instance.
692 : * @param tid The transaction label of the response, valid from 0 to 15.
693 : * @param result The response code, see @ref bt_avrcp_rsp_t, can support
694 : * 0x8(NOT_IMPLEMENTED), 0x9 (ACCEPTED), 0xA (REJECTED)
695 : * @param buf The buffer containing the PASS THROUGH command payload.
696 : * The application can construct this payload according to the format defined
697 : * in @ref bt_avrcp_passthrough_rsp. Note that the data is encoded
698 : * in big-endian format.
699 : *
700 : * @return 0 in case of success or error code in case of error.
701 : */
702 1 : int bt_avrcp_tg_send_passthrough_rsp(struct bt_avrcp_tg *tg, uint8_t tid, bt_avrcp_rsp_t result,
703 : struct net_buf *buf);
704 : #ifdef __cplusplus
705 : }
706 : #endif
707 :
708 : #endif /* ZEPHYR_INCLUDE_BLUETOOTH_AVRCP_H_ */
|