1 /** @file 2 * @brief Audio Video Remote Control Profile internal 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 #define AVCTP_VER_1_4 (0x0104u) 13 #define AVRCP_VER_1_6 (0x0106u) 14 15 #define AVRCP_CAT_1 BIT(0) /* Player/Recorder */ 16 #define AVRCP_CAT_2 BIT(1) /* Monitor/Amplifier */ 17 #define AVRCP_CAT_3 BIT(2) /* Tuner */ 18 #define AVRCP_CAT_4 BIT(3) /* Menu */ 19 20 #define AVRCP_SUBUNIT_PAGE (0) /* Fixed value according to AVRCP */ 21 #define AVRCP_SUBUNIT_EXTENSION_COED (7) /* Fixed value according to TA Document 2001012 */ 22 23 typedef enum __packed { 24 BT_AVRCP_CTYPE_CONTROL = 0x0, 25 BT_AVRCP_CTYPE_STATUS = 0x1, 26 BT_AVRCP_CTYPE_SPECIFIC_INQUIRY = 0x2, 27 BT_AVRCP_CTYPE_NOTIFY = 0x3, 28 BT_AVRCP_CTYPE_GENERAL_INQUIRY = 0x4, 29 BT_AVRCP_CTYPE_NOT_IMPLEMENTED = 0x8, 30 BT_AVRCP_CTYPE_ACCEPTED = 0x9, 31 BT_AVRCP_CTYPE_REJECTED = 0xA, 32 BT_AVRCP_CTYPE_IN_TRANSITION = 0xB, 33 BT_AVRCP_CTYPE_IMPLEMENTED_STABLE = 0xC, 34 BT_AVRCP_CTYPE_CHANGED = 0xD, 35 BT_AVRCP_CTYPE_INTERIM = 0xF, 36 } bt_avrcp_ctype_t; 37 38 typedef enum __packed { 39 BT_AVRCP_SUBUNIT_ID_ZERO = 0x0, 40 BT_AVRCP_SUBUNIT_ID_IGNORE = 0x7, 41 } bt_avrcp_subunit_id_t; 42 43 typedef enum __packed { 44 BT_AVRCP_SUBUNIT_TYPE_PANEL = 0x9, 45 BT_AVRCP_SUBUNIT_TYPE_UNIT = 0x1F, 46 } bt_avrcp_subunit_type_t; 47 48 typedef enum __packed { 49 BT_AVRCP_OPC_VENDOR_DEPENDENT = 0x0, 50 BT_AVRCP_OPC_UNIT_INFO = 0x30, 51 BT_AVRCP_OPC_SUBUNIT_INFO = 0x31, 52 BT_AVRCP_OPC_PASS_THROUGH = 0x7c, 53 } bt_avrcp_opcode_t; 54 55 struct bt_avrcp_req { 56 uint8_t tid; 57 uint8_t subunit; 58 uint8_t opcode; 59 }; 60 61 struct bt_avrcp_header { 62 uint8_t byte0; /** [7:4]: RFA, [3:0]: Ctype */ 63 uint8_t byte1; /** [7:3]: Subunit_type, [2:0]: Subunit_ID */ 64 uint8_t opcode; /** Unit Info, Subunit Info, Vendor Dependent, or Pass Through */ 65 } __packed; 66 67 /** The 4-bit command type or the 4-bit response code. */ 68 #define BT_AVRCP_HDR_GET_CTYPE(hdr) FIELD_GET(GENMASK(3, 0), ((hdr)->byte0)) 69 /** Taken together, the subunit_type and subunit_ID fields define the command recipient’s address 70 * within the target. These fields enable the target to determine whether the command is 71 * addressed to the target unit, or to a specific subunit within the target. The values in these 72 * fields remain unchanged in the response frame. 73 */ 74 #define BT_AVRCP_HDR_GET_SUBUNIT_ID(hdr) FIELD_GET(GENMASK(2, 0), ((hdr)->byte1)) 75 /** Taken together, the subunit_type and subunit_ID fields define the command recipient’s address 76 * within the target. These fields enable the target to determine whether the command is 77 * addressed to the target unit, or to a specific subunit within the target. The values in these 78 * fields remain unchanged in the response frame. 79 */ 80 #define BT_AVRCP_HDR_GET_SUBUNIT_TYPE(hdr) FIELD_GET(GENMASK(7, 3), ((hdr)->byte1)) 81 82 /** The 4-bit command type or the 4-bit response code. */ 83 #define BT_AVRCP_HDR_SET_CTYPE(hdr, ctype) \ 84 (hdr)->byte0 = (((hdr)->byte0) & ~GENMASK(3, 0)) | FIELD_PREP(GENMASK(3, 0), (ctype)) 85 /** Taken together, the subunit_type and subunit_ID fields define the command recipient’s address 86 * within the target. These fields enable the target to determine whether the command is 87 * addressed to the target unit, or to a specific subunit within the target. The values in these 88 * fields remain unchanged in the response frame. 89 */ 90 #define BT_AVRCP_HDR_SET_SUBUNIT_ID(hdr, subunit_id) \ 91 (hdr)->byte1 = (((hdr)->byte1) & ~GENMASK(2, 0)) | FIELD_PREP(GENMASK(2, 0), (subunit_id)) 92 /** Taken together, the subunit_type and subunit_ID fields define the command recipient’s address 93 * within the target. These fields enable the target to determine whether the command is 94 * addressed to the target unit, or to a specific subunit within the target. The values in these 95 * fields remain unchanged in the response frame. 96 */ 97 #define BT_AVRCP_HDR_SET_SUBUNIT_TYPE(hdr, subunit_type) \ 98 (hdr)->byte1 = (((hdr)->byte1) & ~GENMASK(7, 3)) | FIELD_PREP(GENMASK(7, 3), (subunit_type)) 99 100 struct bt_avrcp_unit_info_cmd { 101 struct bt_avrcp_header hdr; 102 uint8_t data[0]; 103 } __packed; 104 105 int bt_avrcp_init(void); 106