1 /******************************************************************************
2  *
3  *  Copyright (C) 2003-2012 Broadcom Corporation
4  *
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:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This file contains the action functions for QoS state
22  *  machine.
23  *
24  ******************************************************************************/
25 
26 #include "bta/bta_sys.h"
27 #include "bta/bta_api.h"
28 #include "bta_dm_int.h"
29 #include "stack/btm_api.h"
30 #include "osi/allocator.h"
31 
32 #if (BTA_DM_QOS_INCLUDED == TRUE)
33 
bta_dm_set_qos(tBTA_DM_MSG * p_data)34 void bta_dm_set_qos(tBTA_DM_MSG *p_data)
35 {
36     FLOW_SPEC p_flow = {
37         .qos_flags = 0,          /* TBD */
38         .service_type = GUARANTEED,      /* see below */
39         .token_rate = 0,         /* bytes/second */
40         .token_bucket_size = 0,  /* bytes */
41         .peak_bandwidth = 0,      /* bytes/second */
42         .latency = 625 * p_data->qos_set.t_poll,           /* microseconds */
43         .delay_variation = 0xFFFFFFFF    /* microseconds */
44     };
45 
46     tBTM_STATUS status = BTM_SetQoS (p_data->qos_set.bd_addr, &p_flow, p_data->qos_set.p_cb);
47 
48     if(status != BTM_CMD_STARTED) {
49         APPL_TRACE_ERROR("%s ERROR: 0x%x\n", __func__, status);
50     }
51 }
52 
53 
BTA_DmSetQos(BD_ADDR bd_addr,UINT32 t_poll,tBTM_CMPL_CB * p_cb)54 void BTA_DmSetQos(BD_ADDR bd_addr, UINT32 t_poll, tBTM_CMPL_CB *p_cb)
55 {
56     tBTA_DM_API_QOS_SET *p_msg;
57 
58     if ((p_msg = (tBTA_DM_API_QOS_SET *) osi_malloc(sizeof(tBTA_DM_API_QOS_SET))) != NULL) {
59         p_msg->hdr.event = BTA_DM_API_QOS_SET_EVT;
60 
61         bdcpy(p_msg->bd_addr, bd_addr);
62         p_msg->t_poll = t_poll;
63         p_msg->p_cb = p_cb;
64 
65         bta_sys_sendmsg(p_msg);
66     }
67 }
68 #endif /// (BTA_DM_QOS_INCLUDED == TRUE)
69