1 /******************************************************************************
3 * Copyright (C) 2006-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 ******************************************************************************/
22 #include "avrc_defs.h"
26 /*****************************************************************************
28 *****************************************************************************/
30 #if (AVRC_METADATA_INCLUDED == TRUE)
32 /*******************************************************************************
34 ** Function avrc_pars_vendor_rsp
36 ** Description This function parses the vendor specific commands defined by
39 ** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
40 ** Otherwise, the error code defined by AVRCP 1.4
42 *******************************************************************************/
43 static tAVRC_STS avrc_pars_vendor_rsp(tAVRC_MSG_VENDOR *p_msg, tAVRC_RESPONSE *p_result)
45 tAVRC_STS status = AVRC_STS_NO_ERROR;
46 UINT8 *p = p_msg->p_vendor_data;
49 tAVRC_NOTIF_RSP_PARAM *p_param;
50 tAVRC_APP_SETTING *p_app_set;
51 tAVRC_APP_SETTING_TEXT *p_app_txt;
52 tAVRC_ATTR_ENTRY *p_entry;
58 BE_STREAM_TO_UINT8 (p_result->pdu, p);
59 p++; /* skip the reserved/packe_type byte */
60 BE_STREAM_TO_UINT16 (len, p);
61 AVRC_TRACE_DEBUG("avrc_pars_vendor_rsp() ctype:0x%x pdu:0x%x, len:%d/0x%x", p_msg->hdr.ctype, p_result->pdu, len, len);
62 if (p_msg->hdr.ctype == AVRC_RSP_REJ)
64 p_result->rsp.status = *p;
65 return p_result->rsp.status;
68 switch (p_result->pdu)
70 /* case AVRC_PDU_REQUEST_CONTINUATION_RSP: 0x40 */
71 /* case AVRC_PDU_ABORT_CONTINUATION_RSP: 0x41 */
73 #if (AVRC_ADV_CTRL_INCLUDED == TRUE)
74 case AVRC_PDU_SET_ABSOLUTE_VOLUME: /* 0x50 */
76 status = AVRC_STS_INTERNAL_ERR;
79 BE_STREAM_TO_UINT8 (p_result->volume.volume, p);
82 #endif /* (AVRC_ADV_CTRL_INCLUDED == TRUE) */
84 case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */
85 #if (AVRC_ADV_CTRL_INCLUDED == TRUE)
86 BE_STREAM_TO_UINT8 (eventid, p);
87 if(AVRC_EVT_VOLUME_CHANGE==eventid
88 && (AVRC_RSP_CHANGED==p_msg->hdr.ctype || AVRC_RSP_INTERIM==p_msg->hdr.ctype
89 || AVRC_RSP_REJ==p_msg->hdr.ctype || AVRC_RSP_NOT_IMPL==p_msg->hdr.ctype))
91 p_result->reg_notif.status=p_msg->hdr.ctype;
92 p_result->reg_notif.event_id=eventid;
93 BE_STREAM_TO_UINT8 (p_result->reg_notif.param.volume, p);
95 AVRC_TRACE_DEBUG("avrc_pars_vendor_rsp PDU reg notif response:event %x, volume %x",eventid,
96 p_result->reg_notif.param.volume);
97 #endif /* (AVRC_ADV_CTRL_INCLUDED == TRUE) */
100 status = AVRC_STS_BAD_CMD;
107 /*******************************************************************************
109 ** Function AVRC_ParsResponse
111 ** Description This function is a superset of AVRC_ParsMetadata to parse the response.
113 ** Returns AVRC_STS_NO_ERROR, if the message in p_data is parsed successfully.
114 ** Otherwise, the error code defined by AVRCP 1.4
116 *******************************************************************************/
117 tAVRC_STS AVRC_ParsResponse (tAVRC_MSG *p_msg, tAVRC_RESPONSE *p_result, UINT8 *p_buf, UINT16 buf_len)
119 tAVRC_STS status = AVRC_STS_INTERNAL_ERR;
124 if (p_msg && p_result)
126 switch (p_msg->hdr.opcode)
128 case AVRC_OP_VENDOR: /* 0x00 Vendor-dependent commands */
129 status = avrc_pars_vendor_rsp(&p_msg->vendor, p_result);
132 case AVRC_OP_PASS_THRU: /* 0x7C panel subunit opcode */
133 status = avrc_pars_pass_thru(&p_msg->pass, &id);
134 if (status == AVRC_STS_NO_ERROR)
136 p_result->pdu = (UINT8)id;
141 AVRC_TRACE_ERROR("AVRC_ParsResponse() unknown opcode:0x%x", p_msg->hdr.opcode);
144 p_result->rsp.opcode = p_msg->hdr.opcode;
145 p_result->rsp.status = status;
151 #endif /* (AVRC_METADATA_INCLUDED == TRUE) */