1247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/******************************************************************************
2247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *
3247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *  Copyright (C) 2006-2013 Broadcom Corporation
4247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *
5247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *  Licensed under the Apache License, Version 2.0 (the "License");
6247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *  you may not use this file except in compliance with the License.
7247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *  You may obtain a copy of the License at:
8247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *
9247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *  http://www.apache.org/licenses/LICENSE-2.0
10247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *
11247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *  Unless required by applicable law or agreed to in writing, software
12247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *  distributed under the License is distributed on an "AS IS" BASIS,
13247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *  See the License for the specific language governing permissions and
15247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *  limitations under the License.
16247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji *
17247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji ******************************************************************************/
18247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#include <string.h>
19247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
20247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#include "gki.h"
21247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#include "avrc_api.h"
22247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#include "avrc_defs.h"
23247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#include "avrc_int.h"
24247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
25247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/*****************************************************************************
26247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**  Global data
27247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji*****************************************************************************/
28247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
29247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
30247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#if (AVRC_METADATA_INCLUDED == TRUE)
31247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/*******************************************************************************
32247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
33247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function         avrc_bld_next_cmd
34247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
35247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description      This function builds the Request Continue or Abort command.
36247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
37247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns          AVRC_STS_NO_ERROR, if the command is built successfully
38247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**                  Otherwise, the error code.
39247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
40247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji*******************************************************************************/
41247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic tAVRC_STS avrc_bld_next_cmd (tAVRC_NEXT_CMD *p_cmd, BT_HDR *p_pkt)
42247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{
43247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    UINT8   *p_data, *p_start;
44247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
45b44cc59d286ad255e872c60df02e032bd8d9d75bSharvil Nanavati    AVRC_TRACE_API("avrc_bld_next_cmd");
46247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
47247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    /* get the existing length, if any, and also the num attributes */
48247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
49247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    p_data = p_start + 2; /* pdu + rsvd */
50247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
51247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    /* add fixed lenth 1 - pdu_id (1) */
52247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    UINT16_TO_BE_STREAM(p_data, 1);
53247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    UINT8_TO_BE_STREAM(p_data, p_cmd->target_pdu);
54247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    p_pkt->len = (p_data - p_start);
55247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
56247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    return AVRC_STS_NO_ERROR;
57247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji}
58247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
59247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/*****************************************************************************
60247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**  the following commands are introduced in AVRCP 1.4
61247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji*****************************************************************************/
62247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
63247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
64247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/*******************************************************************************
65247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
66247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function         avrc_bld_set_abs_volume_cmd
67247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
68247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description      This function builds the Set Absolute Volume command.
69247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
70247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns          AVRC_STS_NO_ERROR, if the command is built successfully
71247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**                  Otherwise, the error code.
72247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
73247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji*******************************************************************************/
74247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic tAVRC_STS avrc_bld_set_abs_volume_cmd (tAVRC_SET_VOLUME_CMD *p_cmd, BT_HDR *p_pkt)
75247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{
76247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    UINT8   *p_data, *p_start;
77247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
78b44cc59d286ad255e872c60df02e032bd8d9d75bSharvil Nanavati    AVRC_TRACE_API("avrc_bld_set_abs_volume_cmd");
79247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    /* get the existing length, if any, and also the num attributes */
80247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
81247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    p_data = p_start + 2; /* pdu + rsvd */
82247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    /* add fixed lenth 1 - volume (1) */
83247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    UINT16_TO_BE_STREAM(p_data, 1);
84247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    UINT8_TO_BE_STREAM(p_data, (AVRC_MAX_VOLUME & p_cmd->volume));
85247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    p_pkt->len = (p_data - p_start);
86247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    return AVRC_STS_NO_ERROR;
87247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji}
88247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
89247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/*******************************************************************************
90247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
91247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function         avrc_bld_vol_change_notfn
92247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
93247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description      This function builds the register notification for volume change.
94247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
95247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns          AVRC_STS_NO_ERROR, if the command is built successfully
96247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**                  Otherwise, the error code.
97247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
98247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji*******************************************************************************/
99247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic tAVRC_STS avrc_bld_vol_change_notfn(BT_HDR * p_pkt)
100247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{
101247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    UINT8   *p_data, *p_start;
102247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
103b44cc59d286ad255e872c60df02e032bd8d9d75bSharvil Nanavati    AVRC_TRACE_API("avrc_bld_vol_change");
104247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    /* get the existing length, if any, and also the num attributes */
105247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    // Set the notify value
106247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
107247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    p_data = p_start + 2; /* pdu + rsvd */
108247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    /* add fixed length 5 -*/
109247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    UINT16_TO_BE_STREAM(p_data, 5);
110247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    UINT8_TO_BE_STREAM(p_data,AVRC_EVT_VOLUME_CHANGE);
111247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    UINT32_TO_BE_STREAM(p_data, 0);
112247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    p_pkt->len = (p_data - p_start);
113247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    return AVRC_STS_NO_ERROR;
114247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji}
115247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#endif
116247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
117247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/*******************************************************************************
118247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
119247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function         avrc_bld_init_cmd_buffer
120247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
121247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description      This function initializes the command buffer based on PDU
122247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
123247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns          NULL, if no GKI buffer or failure to build the message.
124247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**                  Otherwise, the GKI buffer that contains the initialized message.
125247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
126247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji*******************************************************************************/
127247c68fe6eee3660cbdcf4509195fe735ae25573Satya Callojistatic BT_HDR *avrc_bld_init_cmd_buffer(tAVRC_COMMAND *p_cmd)
128247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{
129247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    UINT16 offset = 0, chnl = AVCT_DATA_CTRL, len=AVRC_META_CMD_POOL_SIZE;
130247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    BT_HDR *p_pkt=NULL;
131247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    UINT8  opcode;
132247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
133247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    opcode = avrc_opcode_from_pdu(p_cmd->pdu);
134b44cc59d286ad255e872c60df02e032bd8d9d75bSharvil Nanavati    AVRC_TRACE_API("avrc_bld_init_cmd_buffer: pdu=%x, opcode=%x", p_cmd->pdu, opcode);
135247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
136247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    switch (opcode)
137247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    {
138247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    case AVRC_OP_PASS_THRU:
139247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        offset  = AVRC_MSG_PASS_THRU_OFFSET;
140247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        break;
141247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
142247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    case AVRC_OP_VENDOR:
143247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        offset  = AVRC_MSG_VENDOR_OFFSET;
144247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        break;
145247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    }
146247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
147247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    /* allocate and initialize the buffer */
148247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    p_pkt = (BT_HDR *)GKI_getbuf(len);
149247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    if (p_pkt)
150247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    {
151247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        UINT8 *p_data, *p_start;
152247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
153247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        p_pkt->layer_specific = chnl;
154247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        p_pkt->event    = opcode;
155247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        p_pkt->offset   = offset;
156247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
157247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        p_start = p_data;
158247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
159247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        /* pass thru - group navigation - has a two byte op_id, so dont do it here */
160247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        if (opcode != AVRC_OP_PASS_THRU)
161247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji            *p_data++ = p_cmd->pdu;
162247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
163247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        switch (opcode)
164247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        {
165247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        case AVRC_OP_VENDOR:
166247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji            /* reserved 0, packet_type 0 */
167247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji            UINT8_TO_BE_STREAM(p_data, 0);
168247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji            /* continue to the next "case to add length */
169247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji            /* add fixed lenth - 0 */
170247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji            UINT16_TO_BE_STREAM(p_data, 0);
171247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji            break;
172247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        }
173247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
174247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        p_pkt->len = (p_data - p_start);
175247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    }
176247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    p_cmd->cmd.opcode = opcode;
177247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    return p_pkt;
178247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji}
179247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
180247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji/*******************************************************************************
181247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
182247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Function         AVRC_BldCommand
183247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
184247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Description      This function builds the given AVRCP command to the given
185247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**                  GKI buffer
186247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
187247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji** Returns          AVRC_STS_NO_ERROR, if the command is built successfully
188247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**                  Otherwise, the error code.
189247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji**
190247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji*******************************************************************************/
191247c68fe6eee3660cbdcf4509195fe735ae25573Satya CallojitAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt)
192247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji{
193247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    tAVRC_STS status = AVRC_STS_BAD_PARAM;
194247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    BT_HDR  *p_pkt;
195247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    BOOLEAN alloc = FALSE;
196247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
197b44cc59d286ad255e872c60df02e032bd8d9d75bSharvil Nanavati    AVRC_TRACE_API("AVRC_BldCommand: pdu=%x status=%x", p_cmd->cmd.pdu, p_cmd->cmd.status);
198247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    if (!p_cmd || !pp_pkt)
199247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    {
200b44cc59d286ad255e872c60df02e032bd8d9d75bSharvil Nanavati        AVRC_TRACE_API("AVRC_BldCommand. Invalid parameters passed. p_cmd=%p, pp_pkt=%p",
201247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji            p_cmd, pp_pkt);
202247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        return AVRC_STS_BAD_PARAM;
203247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    }
204247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
205247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    if (*pp_pkt == NULL)
206247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    {
207247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        if ((*pp_pkt = avrc_bld_init_cmd_buffer(p_cmd)) == NULL)
208247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        {
209b44cc59d286ad255e872c60df02e032bd8d9d75bSharvil Nanavati            AVRC_TRACE_API("AVRC_BldCommand: Failed to initialize command buffer");
210247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji            return AVRC_STS_INTERNAL_ERR;
211247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        }
212247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        alloc = TRUE;
213247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    }
214247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    status = AVRC_STS_NO_ERROR;
215247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    p_pkt = *pp_pkt;
216247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
217247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    switch (p_cmd->pdu)
218247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    {
219247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    case AVRC_PDU_REQUEST_CONTINUATION_RSP:     /*        0x40 */
220247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        status = avrc_bld_next_cmd(&p_cmd->continu, p_pkt);
221247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        break;
222247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
223247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    case AVRC_PDU_ABORT_CONTINUATION_RSP:       /*          0x41 */
224247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        status = avrc_bld_next_cmd(&p_cmd->abort, p_pkt);
225247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        break;
226247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
227247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    case AVRC_PDU_SET_ABSOLUTE_VOLUME:         /* 0x50 */
228247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        status = avrc_bld_set_abs_volume_cmd(&p_cmd->volume, p_pkt);
229247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        break;
230247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#endif
231247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
232247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    case AVRC_PDU_REGISTER_NOTIFICATION:      /* 0x31 */
233247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
234247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        if(AVRC_EVT_VOLUME_CHANGE==p_cmd->reg_notif.event_id)
235247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji           status=avrc_bld_vol_change_notfn(p_pkt);
236247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#endif
237247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        break;
238247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
239247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    }
240247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
241247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    if (alloc && (status != AVRC_STS_NO_ERROR) )
242247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    {
243247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        GKI_freebuf(p_pkt);
244247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji        *pp_pkt = NULL;
245247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    }
246b44cc59d286ad255e872c60df02e032bd8d9d75bSharvil Nanavati    AVRC_TRACE_API("AVRC_BldCommand: returning %d", status);
247247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji    return status;
248247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji}
249247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji#endif /* (AVRC_METADATA_INCLUDED == TRUE) */
250247c68fe6eee3660cbdcf4509195fe735ae25573Satya Calloji
251