15738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 25738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 35738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Copyright (C) 2003-2012 Broadcom Corporation 45738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 55738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 65738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * you may not use this file except in compliance with the License. 75738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * You may obtain a copy of the License at: 85738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 95738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * See the License for the specific language governing permissions and 155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * limitations under the License. 165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/ 185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * This module contains API of the audio/video control transport protocol. 225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/ 245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <string.h> 265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "data_types.h" 275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bt_target.h" 285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "gki.h" 295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "l2c_api.h" 305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "l2cdefs.h" 315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "btm_api.h" 325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "avct_api.h" 335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "avct_int.h" 345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* Control block for AVCT */ 365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if AVCT_DYNAMIC_MEMORY == FALSE 375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjecttAVCT_CB avct_cb; 385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function AVCT_Register 435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This is the system level registration function for the 455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** AVCTP protocol. This function initializes AVCTP and 465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** prepares the protocol stack for its use. This function 475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** must be called once by the system or platform using AVCTP 485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** before the other functions of the API an be used. 495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid AVCT_Register(UINT16 mtu, UINT16 mtu_br, UINT8 sec_mask) 555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVCT_TRACE_API0("AVCT_Register"); 575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* register PSM with L2CAP */ 595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project L2CA_Register(AVCT_PSM, (tL2CAP_APPL_INFO *) &avct_l2c_appl); 605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set security level */ 625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTM_SetSecurityLevel(TRUE, "", BTM_SEC_SERVICE_AVCTP, sec_mask, AVCT_PSM, 0, 0); 635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_AVCTP, sec_mask, AVCT_PSM, 0, 0); 645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* initialize AVCTP data structures */ 665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memset(&avct_cb, 0, sizeof(tAVCT_CB)); 675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (AVCT_BROWSE_INCLUDED == TRUE) 695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Include the browsing channel which uses eFCR */ 705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project L2CA_Register(AVCT_BR_PSM, (tL2CAP_APPL_INFO *) &avct_l2c_br_appl); 715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTM_SetSecurityLevel(TRUE, "", BTM_SEC_SERVICE_AVCTP_BROWSE, sec_mask, AVCT_BR_PSM, 0, 0); 735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_AVCTP_BROWSE, sec_mask, AVCT_BR_PSM, 0, 0); 745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (mtu_br < AVCT_MIN_BROWSE_MTU) 765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project mtu_br = AVCT_MIN_BROWSE_MTU; 775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avct_cb.mtu_br = mtu_br; 785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if defined(AVCT_INITIAL_TRACE_LEVEL) 815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avct_cb.trace_level = AVCT_INITIAL_TRACE_LEVEL; 825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else 835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avct_cb.trace_level = BT_TRACE_LEVEL_NONE; 845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (mtu < AVCT_MIN_CONTROL_MTU) 875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project mtu = AVCT_MIN_CONTROL_MTU; 885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* store mtu */ 895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avct_cb.mtu = mtu; 905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function AVCT_Deregister 955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description This function is called to deregister use AVCTP protocol. 975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** It is called when AVCTP is no longer being used by any 985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** application in the system. Before this function can be 995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** called, all connections must be removed with 1005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** AVCT_RemoveConn(). 1015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 1045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid AVCT_Deregister(void) 1075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVCT_TRACE_API0("AVCT_Deregister"); 1095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* deregister PSM with L2CAP */ 1115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project L2CA_Deregister(AVCT_PSM); 1125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function AVCT_CreateConn 1175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Create an AVCTP connection. There are two types of 1195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** connections, initiator and acceptor, as determined by 1205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** the p_cc->role parameter. When this function is called to 1215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** create an initiator connection, an AVCTP connection to 1225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** the peer device is initiated if one does not already exist. 1235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** If an acceptor connection is created, the connection waits 1245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** passively for an incoming AVCTP connection from a peer device. 1255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns AVCT_SUCCESS if successful, otherwise error. 1285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectUINT16 AVCT_CreateConn(UINT8 *p_handle, tAVCT_CC *p_cc, BD_ADDR peer_addr) 1315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 result = AVCT_SUCCESS; 1335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVCT_CCB *p_ccb; 1345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVCT_LCB *p_lcb; 1355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVCT_TRACE_API2("AVCT_CreateConn: %d, control:%d", p_cc->role, p_cc->control); 1375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Allocate ccb; if no ccbs, return failure */ 1395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_ccb = avct_ccb_alloc(p_cc)) == NULL) 1405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project result = AVCT_NO_RESOURCES; 1425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 1445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get handle */ 1465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_handle = avct_ccb_to_idx(p_ccb); 1475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if initiator connection */ 1495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cc->role == AVCT_INT) 1505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* find link; if none allocate a new one */ 1525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_lcb = avct_lcb_by_bd(peer_addr)) == NULL) 1535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_lcb = avct_lcb_alloc(peer_addr)) == NULL) 1555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* no link resources; free ccb as well */ 1575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avct_ccb_dealloc(p_ccb, AVCT_NO_EVT, 0, NULL); 1585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project result = AVCT_NO_RESOURCES; 1595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* check if PID already in use */ 1625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (avct_lcb_has_pid(p_lcb, p_cc->pid)) 1635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avct_ccb_dealloc(p_ccb, AVCT_NO_EVT, 0, NULL); 1655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project result = AVCT_PID_IN_USE; 1665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (result == AVCT_SUCCESS) 1695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* bind lcb to ccb */ 1715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_lcb = p_lcb; 1725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVCT_TRACE_DEBUG1("ch_state: %d", p_lcb->ch_state); 1735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avct_lcb_event(p_lcb, AVCT_LCB_UL_BIND_EVT, (tAVCT_LCB_EVT *) &p_ccb); 1745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return result; 1785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function AVCT_RemoveConn 1835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Remove an AVCTP connection. This function is called when 1855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** the application is no longer using a connection. If this 1865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** is the last connection to a peer the L2CAP channel for AVCTP 1875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** will be closed. 1885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns AVCT_SUCCESS if successful, otherwise error. 1915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectUINT16 AVCT_RemoveConn(UINT8 handle) 1945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 result = AVCT_SUCCESS; 1965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVCT_CCB *p_ccb; 1975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVCT_TRACE_API0("AVCT_RemoveConn"); 1995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* map handle to ccb */ 2015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_ccb = avct_ccb_by_idx(handle)) == NULL) 2025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project result = AVCT_BAD_HANDLE; 2045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if connection not bound to lcb, dealloc */ 2065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (p_ccb->p_lcb == NULL) 2075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avct_ccb_dealloc(p_ccb, AVCT_NO_EVT, 0, NULL); 2095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* send unbind event to lcb */ 2115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 2125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avct_lcb_event(p_ccb->p_lcb, AVCT_LCB_UL_UNBIND_EVT, (tAVCT_LCB_EVT *) &p_ccb); 2145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return result; 2165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function AVCT_CreateBrowse 2215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Create an AVCTP Browse channel. There are two types of 2235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** connections, initiator and acceptor, as determined by 2245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** the role parameter. When this function is called to 2255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** create an initiator connection, the Browse channel to 2265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** the peer device is initiated if one does not already exist. 2275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** If an acceptor connection is created, the connection waits 2285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** passively for an incoming AVCTP connection from a peer device. 2295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns AVCT_SUCCESS if successful, otherwise error. 2325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectUINT16 AVCT_CreateBrowse (UINT8 handle, UINT8 role) 2355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (AVCT_BROWSE_INCLUDED == TRUE) 2375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 result = AVCT_SUCCESS; 2385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVCT_CCB *p_ccb; 2395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVCT_BCB *p_bcb; 2405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int index; 2415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVCT_TRACE_API1("AVCT_CreateBrowse: %d", role); 2435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* map handle to ccb */ 2455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_ccb = avct_ccb_by_idx(handle)) == NULL) 2465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return AVCT_BAD_HANDLE; 2485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 2505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* mark this CCB as supporting browsing channel */ 2525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_ccb->allocated & AVCT_ALOC_BCB) == 0) 2535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->allocated |= AVCT_ALOC_BCB; 2555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if initiator connection */ 2595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (role == AVCT_INT) 2605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* the link control block must exist before this function is called as INT. */ 2625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_ccb->p_lcb == NULL) 2635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project result = AVCT_NOT_OPEN; 2655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 2675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* find link; if none allocate a new one */ 2695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project index = p_ccb->p_lcb->allocated; 2705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (index > AVCT_NUM_LINKS) 2715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project result = AVCT_BAD_HANDLE; 2735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 2755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_bcb = &avct_cb.bcb[index - 1]; 2775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_bcb->allocated = index; 2785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (result == AVCT_SUCCESS) 2825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* bind bcb to ccb */ 2845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_bcb = p_bcb; 2855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVCT_TRACE_DEBUG1("ch_state: %d", p_bcb->ch_state); 2865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avct_bcb_event(p_bcb, AVCT_LCB_UL_BIND_EVT, (tAVCT_LCB_EVT *) &p_ccb); 2875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return result; 2915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else 2925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return AVCT_NO_RESOURCES; 2935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 2945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function AVCT_RemoveBrowse 2995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Remove an AVCTP Browse channel. This function is called when 3015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** the application is no longer using a connection. If this 3025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** is the last connection to a peer the L2CAP channel for AVCTP 3035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** will be closed. 3045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns AVCT_SUCCESS if successful, otherwise error. 3075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 3095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectUINT16 AVCT_RemoveBrowse (UINT8 handle) 3105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (AVCT_BROWSE_INCLUDED == TRUE) 3125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 result = AVCT_SUCCESS; 3135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVCT_CCB *p_ccb; 3145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVCT_TRACE_API0("AVCT_RemoveBrowse"); 3165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* map handle to ccb */ 3185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_ccb = avct_ccb_by_idx(handle)) == NULL) 3195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project result = AVCT_BAD_HANDLE; 3215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (p_ccb->p_bcb != NULL) 3235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* send unbind event to bcb */ 3245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avct_bcb_event(p_ccb->p_bcb, AVCT_LCB_UL_UNBIND_EVT, (tAVCT_LCB_EVT *) &p_ccb); 3265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return result; 3285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else 3295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return AVCT_NO_RESOURCES; 3305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 3315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function AVCT_GetBrowseMtu 3365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Get the peer_mtu for the AVCTP Browse channel of the given 3385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** connection. 3395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns the peer browsing channel MTU. 3415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 3435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectUINT16 AVCT_GetBrowseMtu (UINT8 handle) 3445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 peer_mtu = AVCT_MIN_BROWSE_MTU; 3465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (AVCT_BROWSE_INCLUDED == TRUE) 3475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVCT_CCB *p_ccb; 3485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_ccb = avct_ccb_by_idx(handle)) != NULL && p_ccb->p_bcb != NULL) 3505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project peer_mtu = p_ccb->p_bcb->peer_mtu; 3525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 3545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return peer_mtu; 3555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function AVCT_GetPeerMtu 3605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Get the peer_mtu for the AVCTP channel of the given 3625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** connection. 3635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns the peer MTU size. 3655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 3675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectUINT16 AVCT_GetPeerMtu (UINT8 handle) 3685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 peer_mtu = L2CAP_DEFAULT_MTU; 3705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVCT_CCB *p_ccb; 3715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* map handle to ccb */ 3735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_ccb = avct_ccb_by_idx(handle)) != NULL) 3745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_ccb->p_lcb) 3765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project peer_mtu = p_ccb->p_lcb->peer_mtu; 3785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return peer_mtu; 3825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function AVCT_MsgReq 3875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Send an AVCTP message to a peer device. In calling 3895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** AVCT_MsgReq(), the application should keep track of the 3905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** congestion state of AVCTP as communicated with events 3915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** AVCT_CONG_IND_EVT and AVCT_UNCONG_IND_EVT. If the 3925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** application calls AVCT_MsgReq() when AVCTP is congested 3935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** the message may be discarded. The application may make its 3945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** first call to AVCT_MsgReq() after it receives an 3955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** AVCT_CONNECT_CFM_EVT or AVCT_CONNECT_IND_EVT on control channel or 3965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** AVCT_BROWSE_CONN_CFM_EVT or AVCT_BROWSE_CONN_IND_EVT on browsing channel. 3975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** p_msg->layer_specific must be set to 3995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** AVCT_DATA_CTRL for control channel traffic; 4005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** AVCT_DATA_BROWSE for for browse channel traffic. 4015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns AVCT_SUCCESS if successful, otherwise error. 4035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectUINT16 AVCT_MsgReq(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR *p_msg) 4065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 result = AVCT_SUCCESS; 4085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVCT_CCB *p_ccb; 4095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVCT_UL_MSG ul_msg; 4105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVCT_TRACE_API0("AVCT_MsgReq"); 4125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* verify p_msg parameter */ 4145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_msg == NULL) 4155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return AVCT_NO_RESOURCES; 4175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVCT_TRACE_API1("len: %d", p_msg->len); 4195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* map handle to ccb */ 4215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_ccb = avct_ccb_by_idx(handle)) == NULL) 4225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project result = AVCT_BAD_HANDLE; 4245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf(p_msg); 4255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* verify channel is bound to link */ 4275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (p_ccb->p_lcb == NULL) 4285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project result = AVCT_NOT_OPEN; 4305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf(p_msg); 4315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (result == AVCT_SUCCESS) 4345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ul_msg.p_buf = p_msg; 4365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ul_msg.p_ccb = p_ccb; 4375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ul_msg.label = label; 4385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ul_msg.cr = cr; 4395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (AVCT_BROWSE_INCLUDED == TRUE) 4415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* send msg event to bcb */ 4425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_msg->layer_specific == AVCT_DATA_BROWSE) 4435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_ccb->p_bcb == NULL && (p_ccb->allocated & AVCT_ALOC_BCB) == 0) 4455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* BCB channel is not open and not allocated */ 4475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project result = AVCT_BAD_HANDLE; 4485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf(p_msg); 4495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 4515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_ccb->p_bcb = avct_bcb_by_lcb(p_ccb->p_lcb); 4535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avct_bcb_event(p_ccb->p_bcb, AVCT_LCB_UL_MSG_EVT, (tAVCT_LCB_EVT *) &ul_msg); 4545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* send msg event to lcb */ 4575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 4585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 4595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project avct_lcb_event(p_ccb->p_lcb, AVCT_LCB_UL_MSG_EVT, (tAVCT_LCB_EVT *) &ul_msg); 4615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return result; 4645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 466