1 /******************************************************************************
3 * Copyright (C) 2003-2013 Broadcom Corporation
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 ******************************************************************************/
20 #include "bt_common.h"
25 #if (AVRC_METADATA_INCLUDED == TRUE)
27 /**************************************************************************
29 ** Function AVRC_IsValidAvcType
31 ** Description Check if correct AVC type is specified
33 ** Returns returns TRUE if it is valid
36 *******************************************************************************/
37 BOOLEAN AVRC_IsValidAvcType(UINT8 pdu_id, UINT8 avc_type)
41 if (avc_type < AVRC_RSP_NOT_IMPL) /* command msg */
45 case AVRC_PDU_GET_CAPABILITIES: /* 0x10 */
46 case AVRC_PDU_LIST_PLAYER_APP_ATTR: /* 0x11 */
47 case AVRC_PDU_LIST_PLAYER_APP_VALUES: /* 0x12 */
48 case AVRC_PDU_GET_CUR_PLAYER_APP_VALUE: /* 0x13 */
49 case AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT: /* 0x15 */
50 case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT: /* 0x16 */
51 case AVRC_PDU_GET_ELEMENT_ATTR: /* 0x20 */
52 case AVRC_PDU_GET_PLAY_STATUS: /* 0x30 */
53 if (avc_type == AVRC_CMD_STATUS)
57 case AVRC_PDU_SET_PLAYER_APP_VALUE: /* 0x14 */
58 case AVRC_PDU_INFORM_DISPLAY_CHARSET: /* 0x17 */
59 case AVRC_PDU_INFORM_BATTERY_STAT_OF_CT: /* 0x18 */
60 case AVRC_PDU_REQUEST_CONTINUATION_RSP: /* 0x40 */
61 case AVRC_PDU_ABORT_CONTINUATION_RSP: /* 0x41 */
62 case AVRC_PDU_SET_ADDRESSED_PLAYER:
63 case AVRC_PDU_PLAY_ITEM:
64 case AVRC_PDU_SET_ABSOLUTE_VOLUME:
65 if (avc_type == AVRC_CMD_CTRL)
69 case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */
70 if (avc_type == AVRC_CMD_NOTIF)
75 else /* response msg */
77 if (avc_type >= AVRC_RSP_NOT_IMPL &&
78 avc_type <= AVRC_RSP_INTERIM )
85 /*******************************************************************************
87 ** Function avrc_is_valid_player_attrib_value
89 ** Description Check if the given attrib value is valid for its attribute
91 ** Returns returns TRUE if it is valid
93 *******************************************************************************/
94 BOOLEAN avrc_is_valid_player_attrib_value(UINT8 attrib, UINT8 value)
100 case AVRC_PLAYER_SETTING_EQUALIZER:
102 (value <= AVRC_PLAYER_VAL_ON))
106 case AVRC_PLAYER_SETTING_REPEAT:
108 (value <= AVRC_PLAYER_VAL_GROUP_REPEAT))
112 case AVRC_PLAYER_SETTING_SHUFFLE:
113 case AVRC_PLAYER_SETTING_SCAN:
115 (value <= AVRC_PLAYER_VAL_GROUP_SHUFFLE))
120 if (attrib >= AVRC_PLAYER_SETTING_LOW_MENU_EXT)
125 "avrc_is_valid_player_attrib_value() found not matching attrib(x%x)-value(x%x) pair!",
131 /*******************************************************************************
133 ** Function AVRC_IsValidPlayerAttr
135 ** Description Check if the given attrib value is a valid one
137 ** Returns returns TRUE if it is valid
139 *******************************************************************************/
140 BOOLEAN AVRC_IsValidPlayerAttr(UINT8 attr)
142 BOOLEAN result=FALSE;
144 if ( (attr >= AVRC_PLAYER_SETTING_EQUALIZER && attr <= AVRC_PLAYER_SETTING_SCAN) ||
145 (attr >= AVRC_PLAYER_SETTING_LOW_MENU_EXT) )
155 /*******************************************************************************
157 ** Function avrc_pars_pass_thru
159 ** Description This function parses the pass thru commands defined by
162 ** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
163 ** Otherwise, the error code defined by AVRCP 1.4
165 *******************************************************************************/
166 tAVRC_STS avrc_pars_pass_thru(tAVRC_MSG_PASS *p_msg, UINT16 *p_vendor_unique_id)
171 tAVRC_STS status = AVRC_STS_BAD_CMD;
173 if (p_msg->op_id == AVRC_ID_VENDOR && p_msg->pass_len == AVRC_PASS_THRU_GROUP_LEN)
175 p_data = p_msg->p_pass_data;
176 AVRC_BE_STREAM_TO_CO_ID (co_id, p_data);
177 if (co_id == AVRC_CO_METADATA)
179 BE_STREAM_TO_UINT16 (id, p_data);
180 if (AVRC_IS_VALID_GROUP(id))
182 *p_vendor_unique_id = id;
183 status = AVRC_STS_NO_ERROR;
190 /*******************************************************************************
192 ** Function avrc_opcode_from_pdu
194 ** Description This function returns the opcode of the given pdu
196 ** Returns AVRC_OP_VENDOR, AVRC_OP_PASS_THRU or AVRC_OP_BROWSE
198 *******************************************************************************/
199 UINT8 avrc_opcode_from_pdu(UINT8 pdu)
205 case AVRC_PDU_NEXT_GROUP:
206 case AVRC_PDU_PREV_GROUP: /* pass thru */
207 opcode = AVRC_OP_PASS_THRU;
210 default: /* vendor */
211 opcode = AVRC_OP_VENDOR;
218 /*******************************************************************************
220 ** Function avrc_is_valid_opcode
222 ** Description This function returns the opcode of the given pdu
224 ** Returns AVRC_OP_VENDOR, AVRC_OP_PASS_THRU or AVRC_OP_BROWSE
226 *******************************************************************************/
227 BOOLEAN avrc_is_valid_opcode(UINT8 opcode)
229 BOOLEAN is_valid = FALSE;
233 case AVRC_OP_PASS_THRU:
241 #endif /* (AVRC_METADATA_INCLUDED == TRUE) */