15738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 25738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 35738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Copyright (C) 2004-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 file contains action functions for advanced audio/video main state 225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * machine. 235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/ 255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bt_target.h" 275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE) 285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <string.h> 305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_av_api.h" 315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_av_int.h" 325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "avdt_api.h" 335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bd.h" 345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "utl.h" 355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "l2c_api.h" 365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE) 375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "bta_ar_api.h" 385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/***************************************************************************** 415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Constants 425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*****************************************************************************/ 435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* the timer in milliseconds to wait for open req after setconfig for incoming connections */ 445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#ifndef BTA_AV_SIG_TIME_VAL 455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define BTA_AV_SIG_TIME_VAL 8000 465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* In millisec to wait for signalling from SNK when it is initiated from SNK. */ 495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* If not, we will start signalling from SRC. */ 505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#ifndef BTA_AV_ACP_SIG_TIME_VAL 515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define BTA_AV_ACP_SIG_TIME_VAL 2000 525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_av_acp_sig_timer_cback (TIMER_LIST_ENT *p_tle); 555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_get_rcb_by_shdl 595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description find the RCB associated with the given SCB handle. 615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns tBTA_AV_RCB 635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjecttBTA_AV_RCB * bta_av_get_rcb_by_shdl(UINT8 shdl) 665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RCB *p_rcb = NULL; 685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int i; 695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (i=0; i<BTA_AV_NUM_RCB; i++) 715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (bta_av_cb.rcb[i].shdl == shdl && bta_av_cb.rcb[i].handle != BTA_AV_RC_HANDLE_NONE) 735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb = &bta_av_cb.rcb[i]; 755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return p_rcb; 795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#define BTA_AV_STS_NO_RSP 0xFF /* a number not used by tAVRC_STS */ 815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_del_rc 855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description delete the given AVRC handle. 875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_del_rc(tBTA_AV_RCB *p_rcb) 925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_SCB *p_scb; 945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 rc_handle; /* connected AVRCP handle */ 955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_rcb->handle != BTA_AV_RC_HANDLE_NONE) 975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_rcb->shdl) 995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb = bta_av_cb.p_scb[p_rcb->shdl - 1]; 1015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_scb) 1025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG3("bta_av_del_rc shdl:%d, srch:%d rc_handle:%d", p_rcb->shdl, 1045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb->rc_handle, p_rcb->handle); 1055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_scb->rc_handle == p_rcb->handle) 1065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb->rc_handle = BTA_AV_RC_HANDLE_NONE; 1075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* just in case the RC timer is active 1085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(bta_av_cb.features & BTA_AV_FEAT_RCCT && p_scb->chnl == BTA_AV_CHNL_AUDIO) */ 1095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_stop_timer(&p_scb->timer); 1105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_EVENT4("bta_av_del_rc handle: %d status=0x%x, rc_acp_handle:%d, idx:%d", 1145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->handle, p_rcb->status, bta_av_cb.rc_acp_handle, bta_av_cb.rc_acp_idx); 1155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_handle = p_rcb->handle; 1165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(!(p_rcb->status & BTA_AV_RC_CONN_MASK) || 1175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ((p_rcb->status & BTA_AV_RC_ROLE_MASK) == BTA_AV_RC_ROLE_INT) ) 1185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->status = 0; 1205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->handle = BTA_AV_RC_HANDLE_NONE; 1215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->shdl = 0; 1225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->lidx = 0; 1235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* else ACP && connected. do not clear the handle yet */ 1255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVRC_Close(rc_handle); 1265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (rc_handle == bta_av_cb.rc_acp_handle) 1275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_cb.rc_acp_handle = BTA_AV_RC_HANDLE_NONE; 1285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_EVENT4("end del_rc handle: %d status=0x%x, rc_acp_handle:%d, lidx:%d", 1295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->handle, p_rcb->status, bta_av_cb.rc_acp_handle, p_rcb->lidx); 1305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_close_all_rc 1375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description close the all AVRC handle. 1395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 1415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_av_close_all_rc(tBTA_AV_CB *p_cb) 1445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int i; 1465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for(i=0; i<BTA_AV_NUM_RCB; i++) 1485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_cb->disabling == TRUE) || (bta_av_cb.rcb[i].shdl != 0)) 1505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_del_rc(&bta_av_cb.rcb[i]); 1515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_del_sdp_rec 1575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description delete the given SDP record handle. 1595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 1615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_av_del_sdp_rec(UINT32 *p_sdp_handle) 1645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(*p_sdp_handle != 0) 1665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SDP_DeleteRecord(*p_sdp_handle); 1685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_sdp_handle = 0; 1695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_avrc_sdp_cback 1755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description AVRCP service discovery callback. 1775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 1795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 1815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_av_avrc_sdp_cback(UINT16 status) 1825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 1835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_msg; 1845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) 1865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 1875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->event = BTA_AV_SDP_AVRC_DISC_EVT; 1885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_sendmsg(p_msg); 1895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 1935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_rc_ctrl_cback 1955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description AVRCP control callback. 1975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 1995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_av_rc_ctrl_cback(UINT8 handle, UINT8 event, UINT16 result, BD_ADDR peer_addr) 2025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RC_CONN_CHG *p_msg; 2045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 msg_event = 0; 2055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (defined(BTA_AV_MIN_DEBUG_TRACES) && BTA_AV_MIN_DEBUG_TRACES == TRUE) 2075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_EVENT2("rc_ctrl handle: %d event=0x%x", handle, event); 2085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else 2095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_EVENT2("bta_av_rc_ctrl_cback handle: %d event=0x%x", handle, event); 2105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 2115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (event == AVRC_OPEN_IND_EVT) 2125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* save handle of opened connection 2145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_cb.rc_handle = handle;*/ 2155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg_event = BTA_AV_AVRC_OPEN_EVT; 2175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (event == AVRC_CLOSE_IND_EVT) 2195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project msg_event = BTA_AV_AVRC_CLOSE_EVT; 2215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (msg_event) 2245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_msg = (tBTA_AV_RC_CONN_CHG *) GKI_getbuf(sizeof(tBTA_AV_RC_CONN_CHG))) != NULL) 2265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->hdr.event = msg_event; 2285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->handle = handle; 2295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(peer_addr) 2305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(p_msg->peer_addr, peer_addr); 2315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_sendmsg(p_msg); 2325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_rc_msg_cback 2395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description AVRCP message callback. 2415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 2435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_av_rc_msg_cback(UINT8 handle, UINT8 label, UINT8 opcode, tAVRC_MSG *p_msg) 2465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RC_MSG *p_buf; 2485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p_data = NULL; 2495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 **p_p_data = NULL; 2505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 data_len = 0; 2515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (defined(BTA_AV_MIN_DEBUG_TRACES) && BTA_AV_MIN_DEBUG_TRACES == TRUE) 2535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_ERROR2("rc_msg handle: %d opcode=0x%x", handle, opcode); 2545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#else 2555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_EVENT2("bta_av_rc_msg_cback handle: %d opcode=0x%x", handle, opcode); 2565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 2575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* determine size of buffer we need */ 2585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (opcode == AVRC_OP_VENDOR && p_msg->vendor.p_vendor_data != NULL) 2595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data = p_msg->vendor.p_vendor_data; 2615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_p_data = &p_msg->vendor.p_vendor_data; 2625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project data_len = (UINT16) p_msg->vendor.vendor_len; 2635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (opcode == AVRC_OP_PASS_THRU && p_msg->pass.p_pass_data != NULL) 2655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data = p_msg->pass.p_pass_data; 2675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_p_data = &p_msg->pass.p_pass_data; 2685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project data_len = (UINT16) p_msg->pass.pass_len; 2695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (tBTA_AV_RC_MSG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_RC_MSG) + data_len))) != NULL) 2725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->hdr.event = BTA_AV_AVRC_MSG_EVT; 2745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->handle = handle; 2755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->label = label; 2765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_buf->opcode = opcode; 2775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(&p_buf->msg, p_msg, sizeof(tAVRC_MSG)); 2785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_data != NULL) 2795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 2805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy((UINT8 *)(p_buf + 1), p_data, data_len); 2815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_p_data = (UINT8 *)(p_buf + 1); 2825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_sendmsg(p_buf); 2845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 2855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 2875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 2885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_rc_create 2905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description alloc RCB and call AVRC_Open 2925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns the created rc handle 2945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 2955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 2965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjectUINT8 bta_av_rc_create(tBTA_AV_CB *p_cb, UINT8 role, UINT8 shdl, UINT8 lidx) 2975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 2985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVRC_CONN_CB ccb; 2995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BD_ADDR_PTR bda = (BD_ADDR_PTR)bd_addr_any; 3005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 status = BTA_AV_RC_ROLE_ACP; 3015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_SCB *p_scb = p_cb->p_scb[shdl - 1]; 3025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int i; 3035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 rc_handle; 3045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RCB *p_rcb; 3055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(role == AVCT_INT) 3075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bda = p_scb->peer_addr; 3095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = BTA_AV_RC_ROLE_INT; 3105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 3125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_rcb = bta_av_get_rcb_by_shdl(shdl)) != NULL ) 3145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_ERROR1("bta_av_rc_create ACP handle exist for shdl:%d", shdl); 3165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return p_rcb->handle; 3175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ccb.p_ctrl_cback = bta_av_rc_ctrl_cback; 3215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ccb.p_msg_cback = bta_av_rc_msg_cback; 3225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ccb.company_id = p_bta_av_cfg->company_id; 3235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ccb.conn = role; 3245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* note: BTA_AV_FEAT_RCTG = AVRC_CT_TARGET, BTA_AV_FEAT_RCCT = AVRC_CT_CONTROL */ 3255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ccb.control = p_cb->features & (BTA_AV_FEAT_RCTG | BTA_AV_FEAT_RCCT | AVRC_CT_PASSIVE); 3265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (AVRC_Open(&rc_handle, &ccb, bda) != AVRC_SUCCESS) 3295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return BTA_AV_RC_HANDLE_NONE; 3305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project i = rc_handle; 3325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb = &p_cb->rcb[i]; 3335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_rcb->handle != BTA_AV_RC_HANDLE_NONE) 3355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_ERROR1("bta_av_rc_create found duplicated handle:%d", rc_handle); 3375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->handle = rc_handle; 3405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->status = status; 3415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->shdl = shdl; 3425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->lidx = lidx; 3435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->peer_features = 0; 3445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(lidx == (BTA_AV_NUM_LINKS + 1)) 3455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* this LIDX is reserved for the AVRCP ACP connection */ 3475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->rc_acp_handle = p_rcb->handle; 3485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->rc_acp_idx = (i + 1); 3495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG2("rc_acp_handle:%d idx:%d", p_cb->rc_acp_handle, p_cb->rc_acp_idx); 3505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG6("create %d, role: %d, shdl:%d, rc_handle:%d, lidx:%d, status:0x%x", 3525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project i, role, shdl, p_rcb->handle, lidx, p_rcb->status); 3535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return rc_handle; 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 bta_av_valid_group_navi_msg 3605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Check if it is Group Navigation Msg for Metadata 3625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns BTA_AV_RSP_ACCEPT or BTA_AV_RSP_NOT_IMPL. 3645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 3655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 366ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic tBTA_AV_CODE bta_av_group_navi_supported(UINT8 len, UINT8 *p_data, BOOLEAN is_inquiry) 3675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 3685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_CODE ret=BTA_AV_RSP_NOT_IMPL; 3695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p_ptr = p_data; 3705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 u16; 3715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT32 u32; 3725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_bta_av_cfg->avrc_group && len == BTA_GROUP_NAVI_MSG_OP_DATA_LEN) 3745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 3755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BTA_AV_BE_STREAM_TO_CO_ID(u32, p_ptr); 3765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BE_STREAM_TO_UINT16(u16, p_ptr); 3775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (u32 == AVRC_CO_METADATA) 3795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 380ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (is_inquiry) 381ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 382ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (u16 <= AVRC_PDU_PREV_GROUP) 383ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ret = BTA_AV_RSP_IMPL_STBL; 384ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 3855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 386ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 387ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (u16 <= AVRC_PDU_PREV_GROUP) 388ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ret = BTA_AV_RSP_ACCEPT; 389ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta else 390ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ret = BTA_AV_RSP_REJ; 391ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 3925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 3945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return ret; 3965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 3995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_op_supported 4015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Check if remote control operation is supported. 4035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns BTA_AV_RSP_ACCEPT of supported, BTA_AV_RSP_NOT_IMPL if not. 4055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 407ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Battastatic tBTA_AV_CODE bta_av_op_supported(tBTA_AV_RC rc_id, BOOLEAN is_inquiry) 4085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_CODE ret_code = BTA_AV_RSP_NOT_IMPL; 4105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_bta_av_rc_id) 4125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 413ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (is_inquiry) 4145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 415ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (p_bta_av_rc_id[rc_id >> 4] & (1 << (rc_id & 0x0F))) 416ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 417ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ret_code = BTA_AV_RSP_IMPL_STBL; 418ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 4195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 420ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta else 4215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 422ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (p_bta_av_rc_id[rc_id >> 4] & (1 << (rc_id & 0x0F))) 423ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 424ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ret_code = BTA_AV_RSP_ACCEPT; 425ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 426ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta else if ((p_bta_av_cfg->rc_pass_rsp == BTA_AV_RSP_INTERIM) && p_bta_av_rc_id_ac) 4275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 428ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (p_bta_av_rc_id_ac[rc_id >> 4] & (1 << (rc_id & 0x0F))) 429ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 430ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ret_code = BTA_AV_RSP_INTERIM; 431ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 4325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 434ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 4355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return ret_code; 4375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 4405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_find_lcb 4425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Given BD_addr, find the associated LCB. 4445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns NULL, if not found. 4465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjecttBTA_AV_LCB * bta_av_find_lcb(BD_ADDR addr, UINT8 op) 4495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_CB *p_cb = &bta_av_cb; 4515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int xx; 4525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 mask; 4535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_LCB *p_lcb = NULL; 4545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for(xx=0; xx<BTA_AV_NUM_LINKS; xx++) 4565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project mask = 1 << xx; /* the used mask for this lcb */ 4585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if((mask & p_cb->conn_lcb) && 0 ==( bdcmp(p_cb->lcb[xx].addr, addr))) 4595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb = &p_cb->lcb[xx]; 4615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(op == BTA_AV_LCB_FREE) 4625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->conn_lcb &= ~mask; /* clear the connect mask */ 4645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("conn_lcb: 0x%x", p_cb->conn_lcb); 4655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 4675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 4695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return p_lcb; 4705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 4735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_rc_opened 4755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Set AVRCP state to opened. 4775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 4795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 4805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 4815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_rc_opened(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 4825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 4835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RC_OPEN rc_open; 4845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_SCB *p_scb; 4855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int i; 4865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 shdl = 0; 4875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_LCB *p_lcb; 4885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RCB *p_rcb; 4895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 tmp; 4905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 disc = 0; 4915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 4925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* find the SCB & stop the timer */ 4935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for(i=0; i<BTA_AV_NUM_STRS; i++) 4945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb = p_cb->p_scb[i]; 4965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_scb && bdcmp(p_scb->peer_addr, p_data->rc_conn_chg.peer_addr) == 0) 4975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 4985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb->rc_handle = p_data->rc_conn_chg.handle; 4995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG2("bta_av_rc_opened shdl:%d, srch %d", i + 1, p_scb->rc_handle); 5005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project shdl = i+1; 5015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_ERROR1("use_rc:%d", p_scb->use_rc); 5025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_stop_timer(&p_scb->timer); 5035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project disc = p_scb->hndl; 5045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 5055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project i = p_data->rc_conn_chg.handle; 5095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cb->rcb[i].handle == BTA_AV_RC_HANDLE_NONE) 5105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_ERROR1("not a valid handle:%d any more", i); 5125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 5135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cb->rcb[i].lidx == (BTA_AV_NUM_LINKS + 1) && shdl != 0) 5175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* rc is opened on the RC only ACP channel, but is for a specific 5195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * SCB -> need to switch RCBs */ 5205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb = bta_av_get_rcb_by_shdl(shdl); 5215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_rcb) 5225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->shdl = p_cb->rcb[i].shdl; 5245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tmp = p_rcb->lidx; 5255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->lidx = p_cb->rcb[i].lidx; 5265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->rcb[i].lidx = tmp; 5275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->rc_acp_handle = p_rcb->handle; 5285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->rc_acp_idx = (p_rcb - p_cb->rcb) + 1; 5295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG2("switching RCB rc_acp_handle:%d idx:%d", 5305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->rc_acp_handle, p_cb->rc_acp_idx); 5315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->rcb[i].shdl = shdl; 5355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_open.rc_handle = i; 5365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_ERROR4("bta_av_rc_opened rcb[%d] shdl:%d lidx:%d/%d", 5375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project i, shdl, p_cb->rcb[i].lidx, p_cb->lcb[BTA_AV_NUM_LINKS].lidx); 5385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->rcb[i].status |= BTA_AV_RC_CONN_MASK; 5395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(!shdl && 0 == p_cb->lcb[BTA_AV_NUM_LINKS].lidx) 5415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* no associated SCB -> connected to an RC only device 5435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * update the index to the extra LCB */ 5445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb = &p_cb->lcb[BTA_AV_NUM_LINKS]; 5455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(p_lcb->addr, p_data->rc_conn_chg.peer_addr); 5465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG6("rc_only bd_addr:%02x-%02x-%02x-%02x-%02x-%02x", 5475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb->addr[0], p_lcb->addr[1], 5485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb->addr[2], p_lcb->addr[3], 5495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb->addr[4], p_lcb->addr[5]); 5505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb->lidx = BTA_AV_NUM_LINKS + 1; 5515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->rcb[i].lidx = p_lcb->lidx; 5525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb->conn_msk = 1; 5535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_ERROR3("rcb[%d].lidx=%d, lcb.conn_msk=x%x", 5545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project i, p_cb->rcb[i].lidx, p_lcb->conn_msk); 5555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project disc = p_data->rc_conn_chg.handle|BTA_AV_CHNL_MSK; 5565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(rc_open.peer_addr, p_data->rc_conn_chg.peer_addr); 5595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_open.peer_features = p_cb->rcb[i].peer_features; 5605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_open.status = BTA_AV_SUCCESS; 5615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG2("local features:x%x peer_features:x%x", p_cb->features, 5625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_open.peer_features); 5635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(rc_open.peer_features == 0) 5645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* we have not done SDP on peer RC capabilities. 5665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * peer must have initiated the RC connection */ 5675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_open.peer_features = BTA_AV_FEAT_RCCT; 5685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_rc_disc(disc); 5695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (*p_cb->p_cback)(BTA_AV_RC_OPEN_EVT, (tBTA_AV *) &rc_open); 5715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 5735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 5755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 5765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_rc_remote_cmd 5785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Send an AVRCP remote control command. 5805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 5825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 5835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 5845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_rc_remote_cmd(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 5855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 5865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RCB *p_rcb; 5875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cb->features & BTA_AV_FEAT_RCCT) 5885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_data->hdr.layer_specific < BTA_AV_NUM_RCB) 5905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb = &p_cb->rcb[p_data->hdr.layer_specific]; 5925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_rcb->status & BTA_AV_RC_CONN_MASK) 5935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 5945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVRC_PassCmd(p_rcb->handle, p_data->api_remote_cmd.label, 5955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project &p_data->api_remote_cmd.msg); 5965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 5995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 6005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 6025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_rc_vendor_cmd 6045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Send an AVRCP vendor specific command. 6065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 6085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 6105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_rc_vendor_cmd(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 6115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 6125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RCB *p_rcb; 6135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ( (p_cb->features & (BTA_AV_FEAT_RCCT | BTA_AV_FEAT_VENDOR)) == 6145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (BTA_AV_FEAT_RCCT | BTA_AV_FEAT_VENDOR)) 6155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_data->hdr.layer_specific < BTA_AV_NUM_RCB) 6175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb = &p_cb->rcb[p_data->hdr.layer_specific]; 6195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVRC_VendorCmd(p_rcb->handle, p_data->api_vendor.label, &p_data->api_vendor.msg); 6205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 6235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 6255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_rc_vendor_rsp 6275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Send an AVRCP vendor specific response. 6295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 6315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 6335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_rc_vendor_rsp(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 6345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 6355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RCB *p_rcb; 6365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ( (p_cb->features & (BTA_AV_FEAT_RCTG | BTA_AV_FEAT_VENDOR)) == 6375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (BTA_AV_FEAT_RCTG | BTA_AV_FEAT_VENDOR)) 6385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_data->hdr.layer_specific < BTA_AV_NUM_RCB) 6405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb = &p_cb->rcb[p_data->hdr.layer_specific]; 6425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVRC_VendorRsp(p_rcb->handle, p_data->api_vendor.label, &p_data->api_vendor.msg); 6435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 6465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 6485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_rc_meta_rsp 6505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Send an AVRCP metadata/advanced control command/response. 6525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 6545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 6565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_rc_meta_rsp(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 6575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 6585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RCB *p_rcb; 6595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BOOLEAN free = TRUE; 6605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_cb->features & BTA_AV_FEAT_METADATA) && (p_data->hdr.layer_specific < BTA_AV_NUM_RCB)) 6625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_data->api_meta_rsp.is_rsp && (p_cb->features & BTA_AV_FEAT_RCTG)) || 6645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (!p_data->api_meta_rsp.is_rsp && (p_cb->features & BTA_AV_FEAT_RCCT)) ) 6655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 6665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb = &p_cb->rcb[p_data->hdr.layer_specific]; 66717b504d0b0b90de00f5f0c59a3601e7b7f444730Zhihai Xu if (p_rcb->handle != BTA_AV_RC_HANDLE_NONE) { 66817b504d0b0b90de00f5f0c59a3601e7b7f444730Zhihai Xu AVRC_MsgReq(p_rcb->handle, p_data->api_meta_rsp.label, 66917b504d0b0b90de00f5f0c59a3601e7b7f444730Zhihai Xu p_data->api_meta_rsp.rsp_code, 67017b504d0b0b90de00f5f0c59a3601e7b7f444730Zhihai Xu p_data->api_meta_rsp.p_pkt); 67117b504d0b0b90de00f5f0c59a3601e7b7f444730Zhihai Xu free = FALSE; 67217b504d0b0b90de00f5f0c59a3601e7b7f444730Zhihai Xu } 6735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 6755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (free) 6775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf (p_data->api_meta_rsp.p_pkt); 6785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 6795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 6815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_rc_free_rsp 6835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description free an AVRCP metadata command buffer. 6855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 6875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 6895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_rc_free_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 6905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 6915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf (p_data->api_meta_rsp.p_pkt); 6925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 6935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 6945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 6955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_rc_meta_req 6975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 6985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Send an AVRCP metadata command. 6995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 7015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 7035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_rc_free_msg (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 7045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 7055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 7065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 7105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_chk_notif_evt_id 7125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description make sure the requested player id is valid. 7145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns BTA_AV_STS_NO_RSP, if no error 7165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 7185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic tAVRC_STS bta_av_chk_notif_evt_id(tAVRC_MSG_VENDOR *p_vendor) 7195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 7205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVRC_STS status = BTA_AV_STS_NO_RSP; 7215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 xx; 7225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 u16; 7235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p = p_vendor->p_vendor_data + 2; 7245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BE_STREAM_TO_UINT16 (u16, p); 7265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* double check the fixed length */ 7275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((u16 != 5) || (p_vendor->vendor_len != 9)) 7285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = AVRC_STS_INTERNAL_ERR; 7305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 7325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* make sure the player_id is valid */ 7345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (xx=0; xx<p_bta_av_cfg->num_evt_ids; xx++) 7355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (*p == p_bta_av_cfg->p_meta_evt_ids[xx]) 7375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 7395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (xx == p_bta_av_cfg->num_evt_ids) 7425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project status = AVRC_STS_BAD_PARAM; 7445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return status; 7485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 7495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 7515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_proc_meta_cmd 7535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Process an AVRCP metadata command from the peer. 7555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns TRUE to respond immediately 7575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 7585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 7595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjecttBTA_AV_EVT bta_av_proc_meta_cmd(tAVRC_RESPONSE *p_rc_rsp, tBTA_AV_RC_MSG *p_msg, UINT8 *p_ctype) 7605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 7615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_EVT evt = BTA_AV_META_MSG_EVT; 7625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 u8, pdu, *p; 7635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 u16; 7645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVRC_MSG_VENDOR *p_vendor = &p_msg->msg.vendor; 7655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 7669adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#if (AVRC_METADATA_INCLUDED == TRUE) 7679adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 7685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project pdu = *(p_vendor->p_vendor_data); 7695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rc_rsp->pdu = pdu; 7705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_ctype = AVRC_RSP_REJ; 7715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Metadata messages only use PANEL sub-unit type */ 7725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_vendor->hdr.subunit_type != AVRC_SUB_PANEL) 7735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG0("SUBUNIT must be PANEL"); 7755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* reject it */ 7765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt=0; 7775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_vendor->hdr.ctype = BTA_AV_RSP_NOT_IMPL; 7785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVRC_VendorRsp(p_msg->handle, p_msg->label, &p_msg->msg.vendor); 7795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 7809adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan else if (!AVRC_IsValidAvcType(pdu, p_vendor->hdr.ctype) ) 7819adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 7829adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan APPL_TRACE_DEBUG2("Invalid pdu/ctype: 0x%x, %d", pdu, p_vendor->hdr.ctype); 7839adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* reject invalid message without reporting to app */ 7849adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan evt = 0; 7859adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan p_rc_rsp->rsp.status = AVRC_STS_BAD_CMD; 7869adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 7875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 7885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project switch (pdu) 7905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 7915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case AVRC_PDU_GET_CAPABILITIES: 7925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* process GetCapabilities command without reporting the event to app */ 7935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt = 0; 7945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project u8 = *(p_vendor->p_vendor_data + 4); 7955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p = p_vendor->p_vendor_data + 2; 7965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rc_rsp->get_caps.capability_id = u8; 7975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BE_STREAM_TO_UINT16 (u16, p); 7985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((u16 != 1) || (p_vendor->vendor_len != 5)) 7995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rc_rsp->get_caps.status = AVRC_STS_INTERNAL_ERR; 8015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 8035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rc_rsp->get_caps.status = AVRC_STS_NO_ERROR; 8055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (u8 == AVRC_CAP_COMPANY_ID) 8065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_ctype = AVRC_RSP_IMPL_STBL; 8085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rc_rsp->get_caps.count = p_bta_av_cfg->num_co_ids; 8095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(p_rc_rsp->get_caps.param.company_id, p_bta_av_cfg->p_meta_co_ids, 8105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (p_bta_av_cfg->num_co_ids << 2)); 8115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (u8 == AVRC_CAP_EVENTS_SUPPORTED) 8135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project *p_ctype = AVRC_RSP_IMPL_STBL; 8155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rc_rsp->get_caps.count = p_bta_av_cfg->num_evt_ids; 8165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(p_rc_rsp->get_caps.param.event_id, p_bta_av_cfg->p_meta_evt_ids, 8175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_bta_av_cfg->num_evt_ids); 8185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 8205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("Invalid capability ID: 0x%x", u8); 8225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* reject - unknown capability ID */ 8235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rc_rsp->get_caps.status = AVRC_STS_BAD_PARAM; 8245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 8275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project case AVRC_PDU_REGISTER_NOTIFICATION: 8305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* make sure the event_id is implemented */ 8315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rc_rsp->rsp.status = bta_av_chk_notif_evt_id (p_vendor); 8325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_rc_rsp->rsp.status != BTA_AV_STS_NO_RSP) 8335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt = 0; 8345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 8355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8389adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#else 8399adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan APPL_TRACE_DEBUG0("AVRCP 1.3 Metadata not supporteed. Reject command."); 8409adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* reject invalid message without reporting to app */ 8419adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan evt = 0; 8429adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan p_rc_rsp->rsp.status = AVRC_STS_BAD_CMD; 8439adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#endif 8445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return evt; 8465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 8475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 8505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_rc_msg 8525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Process an AVRCP message from the peer. 8545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 8565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 8575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 8585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 8595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 8605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_EVT evt = 0; 8615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV av; 8625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_pkt = NULL; 8635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVRC_MSG_VENDOR *p_vendor = &p_data->rc_msg.msg.vendor; 864ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta BOOLEAN is_inquiry = ((p_data->rc_msg.msg.hdr.ctype == AVRC_CMD_SPEC_INQ) || p_data->rc_msg.msg.hdr.ctype == AVRC_CMD_GEN_INQ); 8659adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#if (AVRC_METADATA_INCLUDED == TRUE) 8669adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tAVRC_STS res; 8679adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan UINT8 ctype; 8689adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan tAVRC_RESPONSE rc_rsp; 8699adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan 8709adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan rc_rsp.rsp.status = BTA_AV_STS_NO_RSP; 8719adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#endif 8725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 8735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_data->rc_msg.opcode == AVRC_OP_PASS_THRU) 8745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if this is a pass thru command */ 876ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if ((p_data->rc_msg.msg.hdr.ctype == AVRC_CMD_CTRL) || 877ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (p_data->rc_msg.msg.hdr.ctype == AVRC_CMD_SPEC_INQ) || 878ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta (p_data->rc_msg.msg.hdr.ctype == AVRC_CMD_GEN_INQ) 879ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta ) 8805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* check if operation is supported */ 8825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_data->rc_msg.msg.pass.op_id == AVRC_ID_VENDOR) 8835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 8845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->rc_msg.msg.hdr.ctype = BTA_AV_RSP_NOT_IMPL; 8859adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#if (AVRC_METADATA_INCLUDED == TRUE) 8869adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (p_cb->features & BTA_AV_FEAT_METADATA) 8879adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan p_data->rc_msg.msg.hdr.ctype = 8889adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan bta_av_group_navi_supported(p_data->rc_msg.msg.pass.pass_len, 8899adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan p_data->rc_msg.msg.pass.p_pass_data, is_inquiry); 8909adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#endif 8915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 8935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 894ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta p_data->rc_msg.msg.hdr.ctype = bta_av_op_supported(p_data->rc_msg.msg.pass.op_id, is_inquiry); 8955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 8965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 897ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta APPL_TRACE_DEBUG1("ctype %d",p_data->rc_msg.msg.hdr.ctype) 898ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 8995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* send response */ 9005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_data->rc_msg.msg.hdr.ctype != BTA_AV_RSP_INTERIM) 9015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVRC_PassRsp(p_data->rc_msg.handle, p_data->rc_msg.label, &p_data->rc_msg.msg.pass); 9025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set up for callback if supported */ 9045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_data->rc_msg.msg.hdr.ctype == BTA_AV_RSP_ACCEPT || p_data->rc_msg.msg.hdr.ctype == BTA_AV_RSP_INTERIM) 9055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt = BTA_AV_REMOTE_CMD_EVT; 9075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project av.remote_cmd.rc_id = p_data->rc_msg.msg.pass.op_id; 9085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project av.remote_cmd.key_state = p_data->rc_msg.msg.pass.state; 9095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project av.remote_cmd.p_data = p_data->rc_msg.msg.pass.p_pass_data; 9105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project av.remote_cmd.len = p_data->rc_msg.msg.pass.pass_len; 9115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(&av.remote_cmd.hdr, &p_data->rc_msg.msg.hdr, sizeof (tAVRC_HDR)); 9125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project av.remote_cmd.label = p_data->rc_msg.label; 9135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* else if this is a pass thru response */ 9165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (p_data->rc_msg.msg.hdr.ctype >= AVRC_RSP_ACCEPT) 9175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set up for callback */ 9195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt = BTA_AV_REMOTE_RSP_EVT; 9205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project av.remote_rsp.rc_id = p_data->rc_msg.msg.pass.op_id; 9215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project av.remote_rsp.key_state = p_data->rc_msg.msg.pass.state; 9225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project av.remote_rsp.rsp_code = p_data->rc_msg.msg.hdr.ctype; 9235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project av.remote_rsp.label = p_data->rc_msg.label; 9245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* must be a bad ctype -> reject*/ 9265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 9275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->rc_msg.msg.hdr.ctype = BTA_AV_RSP_REJ; 9295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVRC_PassRsp(p_data->rc_msg.handle, p_data->rc_msg.label, &p_data->rc_msg.msg.pass); 9305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* else if this is a vendor specific command or response */ 9335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (p_data->rc_msg.opcode == AVRC_OP_VENDOR) 9345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set up for callback */ 9365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project av.vendor_cmd.code = p_data->rc_msg.msg.hdr.ctype; 9375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project av.vendor_cmd.company_id = p_vendor->company_id; 9385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project av.vendor_cmd.label = p_data->rc_msg.label; 9395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project av.vendor_cmd.p_data = p_vendor->p_vendor_data; 9405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project av.vendor_cmd.len = p_vendor->vendor_len; 9415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if configured to support vendor specific and it's a command */ 9435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_cb->features & BTA_AV_FEAT_VENDOR) && 9445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->rc_msg.msg.hdr.ctype <= AVRC_CMD_GEN_INQ) 9455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9469adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#if (AVRC_METADATA_INCLUDED == TRUE) 9479adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if ((p_cb->features & BTA_AV_FEAT_METADATA) && 9489adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan (p_vendor->company_id == AVRC_CO_METADATA)) 9499adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 9509adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan av.meta_msg.p_msg = &p_data->rc_msg.msg; 9519adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan evt = bta_av_proc_meta_cmd (&rc_rsp, &p_data->rc_msg, &ctype); 9529adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 9539adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan else 9549adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#endif 9555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt = BTA_AV_VENDOR_CMD_EVT; 9565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* else if configured to support vendor specific and it's a response */ 9585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if ((p_cb->features & BTA_AV_FEAT_VENDOR) && 9595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->rc_msg.msg.hdr.ctype >= AVRC_RSP_ACCEPT) 9605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9619adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#if (AVRC_METADATA_INCLUDED == TRUE) 9629adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if ((p_cb->features & BTA_AV_FEAT_METADATA) && 9639adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan (p_vendor->company_id == AVRC_CO_METADATA)) 9649adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 9659adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan av.meta_msg.p_msg = &p_data->rc_msg.msg; 9669adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan evt = BTA_AV_META_MSG_EVT; 9679adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 9689adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan else 9699adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#endif 9705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project evt = BTA_AV_VENDOR_RSP_EVT; 9715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 9725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* else if not configured to support vendor specific and it's a command */ 9745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (!(p_cb->features & BTA_AV_FEAT_VENDOR) && 9755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->rc_msg.msg.hdr.ctype <= AVRC_CMD_GEN_INQ) 9765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_data->rc_msg.msg.vendor.p_vendor_data[0] == AVRC_PDU_INVALID) 9785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 9795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* reject it */ 9805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->rc_msg.msg.hdr.ctype = BTA_AV_RSP_REJ; 9815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->rc_msg.msg.vendor.p_vendor_data[4] = AVRC_STS_BAD_CMD; 9825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 9845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->rc_msg.msg.hdr.ctype = BTA_AV_RSP_NOT_IMPL; 9855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVRC_VendorRsp(p_data->rc_msg.handle, p_data->rc_msg.label, &p_data->rc_msg.msg.vendor); 9865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 9889adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#if (AVRC_METADATA_INCLUDED == TRUE) 9899adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (evt == 0 && rc_rsp.rsp.status != BTA_AV_STS_NO_RSP) 9909adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 9919adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (!p_pkt) 9929adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 9939adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan rc_rsp.rsp.opcode = p_data->rc_msg.opcode; 9949adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan res = AVRC_BldResponse (0, &rc_rsp, &p_pkt); 9959adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 9969adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if (p_pkt) 9979adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan AVRC_MsgReq (p_data->rc_msg.handle, p_data->rc_msg.label, ctype, p_pkt); 9989adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 9999adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan#endif 10005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* call callback */ 10025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (evt != 0) 10035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project av.remote_cmd.rc_handle = p_data->rc_msg.handle; 10055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (*p_cb->p_cback)(evt, &av); 10065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 10085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 10105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_rc_close 10125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description close the specified AVRC handle. 10145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 10165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 10185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_rc_close (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 10195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 10205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 handle = p_data->hdr.layer_specific; 10215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_SCB *p_scb; 10225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RCB *p_rcb; 10235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(handle < BTA_AV_NUM_RCB) 10255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb = &p_cb->rcb[handle]; 10275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG2("bta_av_rc_close handle: %d, status=0x%x", p_rcb->handle, p_rcb->status); 10295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_rcb->handle != BTA_AV_RC_HANDLE_NONE) 10305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_rcb->shdl) 10325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb = bta_av_cb.p_scb[p_rcb->shdl - 1]; 10345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_scb) 10355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* just in case the RC timer is active 10375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(bta_av_cb.features & BTA_AV_FEAT_RCCT && 10385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb->chnl == BTA_AV_CHNL_AUDIO) */ 10395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_stop_timer(&p_scb->timer); 10405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVRC_Close(p_rcb->handle); 10445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 10475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 10495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_get_shdl 10515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns The index to p_scb[] 10535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 10555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic UINT8 bta_av_get_shdl(tBTA_AV_SCB *p_scb) 10565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 10575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int i; 10585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 shdl = 0; 10595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* find the SCB & stop the timer */ 10605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for(i=0; i<BTA_AV_NUM_STRS; i++) 10615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_scb == bta_av_cb.p_scb[i]) 10635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project shdl = i+1; 10655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 10665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 10685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return shdl; 10695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 10705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 10725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_stream_chg 10745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description audio streaming status changed. 10765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 10785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 10795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 10805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_stream_chg(tBTA_AV_SCB *p_scb, BOOLEAN started) 10815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 10825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 started_msk; 10835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int i; 10845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p_streams; 10855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BOOLEAN no_streams = FALSE; 10865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_SCB *p_scbi; 10875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project started_msk = BTA_AV_HNDL_TO_MSK(p_scb->hdi); 10895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG3 ("bta_av_stream_chg started:%d started_msk:x%x chnl:x%x", started, 10905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project started_msk, p_scb->chnl); 10915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (BTA_AV_CHNL_AUDIO == p_scb->chnl) 10925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_streams = &bta_av_cb.audio_streams; 10935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 10945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_streams = &bta_av_cb.video_streams; 10955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 10965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (started) 10975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 10985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Let L2CAP know this channel is processed with high priority */ 10995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project L2CA_SetAclPriority(p_scb->peer_addr, L2CAP_PRIORITY_HIGH); 11005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (*p_streams) |= started_msk; 11015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 11035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (*p_streams) &= ~started_msk; 11055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (!started) 11085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project i=0; 11105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (BTA_AV_CHNL_AUDIO == p_scb->chnl) 11115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (bta_av_cb.video_streams == 0) 11135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project no_streams = TRUE; 11145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 11165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project no_streams = TRUE; 11185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ( bta_av_cb.audio_streams ) 11195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (; i<BTA_AV_NUM_STRS; i++) 11215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scbi = bta_av_cb.p_scb[i]; 11235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* scb is used and started */ 11245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ( p_scbi && (bta_av_cb.audio_streams & BTA_AV_HNDL_TO_MSK(i)) 11255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project && bdcmp(p_scbi->peer_addr, p_scb->peer_addr) == 0) 11265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project no_streams = FALSE; 11285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 11295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG4 ("no_streams:%d i:%d, audio_streams:x%x, video_streams:x%x", no_streams, i, 11365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_cb.audio_streams, bta_av_cb.video_streams); 11375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (no_streams) 11385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Let L2CAP know this channel is processed with low priority */ 11405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project L2CA_SetAclPriority(p_scb->peer_addr, L2CAP_PRIORITY_NORMAL); 11415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 11445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 11475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_conn_chg 11495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description connetion status changed. 11515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Open an AVRCP acceptor channel, if new conn. 11525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 11545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 11555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 11565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_conn_chg(tBTA_AV_DATA *p_data) 11575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 11585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_CB *p_cb = &bta_av_cb; 11595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_SCB *p_scb; 11605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_SCB *p_scbi; 11615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 mask; 11625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 conn_msk; 11635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 old_msk; 11645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int i; 11655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int index = (p_data->hdr.layer_specific & BTA_AV_HNDL_MSK) - 1; 11665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_LCB *p_lcb; 11675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_LCB *p_lcb_rc; 11685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RCB *p_rcb, *p_rcb2; 11695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BOOLEAN chk_restore = FALSE; 11705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb = p_cb->p_scb[index]; 11725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 11735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project mask = BTA_AV_HNDL_TO_MSK(index); 11745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb = bta_av_find_lcb(p_data->conn_chg.peer_addr, BTA_AV_LCB_FIND); 11755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project conn_msk = 1 << (index + 1); 11765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_data->conn_chg.is_up) 11775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set the conned mask for this channel */ 11795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_scb) 11805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_lcb) 11825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb->conn_msk |= conn_msk; 11845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (i=0; i<BTA_AV_NUM_RCB; i++) 11855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (bta_av_cb.rcb[i].lidx == p_lcb->lidx) 11875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_cb.rcb[i].shdl = index + 1; 11895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG5("conn_chg up[%d]: %d, status=0x%x, shdl:%d, lidx:%d", i, 11905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_cb.rcb[i].handle, bta_av_cb.rcb[i].status, 11915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_cb.rcb[i].shdl, bta_av_cb.rcb[i].lidx); 11925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 11935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 11965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_scb->chnl == BTA_AV_CHNL_AUDIO) 11975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 11985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project old_msk = p_cb->conn_audio; 11995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->conn_audio |= mask; 12005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 12025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project old_msk = p_cb->conn_video; 12045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->conn_video |= mask; 12055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((old_msk & mask) == 0) 12085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* increase the audio open count, if not set yet */ 12105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_cb.audio_open_cnt++; 12115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG2("rc_acp_handle:%d rc_acp_idx:%d", p_cb->rc_acp_handle, p_cb->rc_acp_idx); 12155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* check if the AVRCP ACP channel is already connected */ 12165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_lcb && p_cb->rc_acp_handle != BTA_AV_RC_HANDLE_NONE && p_cb->rc_acp_idx) 12175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb_rc = &p_cb->lcb[BTA_AV_NUM_LINKS]; 12195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("rc_acp is connected && conn_chg on same addr p_lcb_rc->conn_msk:x%x", 12205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb_rc->conn_msk); 12215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* check if the RC is connected to the scb addr */ 12225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG6 ("p_lcb_rc->addr: %02x:%02x:%02x:%02x:%02x:%02x", 12235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb_rc->addr[0], p_lcb_rc->addr[1], p_lcb_rc->addr[2], p_lcb_rc->addr[3], 12245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb_rc->addr[4], p_lcb_rc->addr[5]); 12255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG6 ("conn_chg.peer_addr: %02x:%02x:%02x:%02x:%02x:%02x", 12265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->conn_chg.peer_addr[0], p_data->conn_chg.peer_addr[1], 12275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->conn_chg.peer_addr[2], 12285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->conn_chg.peer_addr[3], p_data->conn_chg.peer_addr[4], 12295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_data->conn_chg.peer_addr[5]); 12305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_lcb_rc->conn_msk && bdcmp(p_lcb_rc->addr, p_data->conn_chg.peer_addr) == 0) 12315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* AVRCP is already connected. 12335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * need to update the association betwen SCB and RCB */ 12345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb_rc->conn_msk = 0; /* indicate RC ONLY is not connected */ 12355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb_rc->lidx = 0; 12365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb->rc_handle = p_cb->rc_acp_handle; 12375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb = &p_cb->rcb[p_cb->rc_acp_idx - 1]; 12385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->shdl = bta_av_get_shdl(p_scb); 12395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG3("update rc_acp shdl:%d/%d srch:%d", index + 1, p_rcb->shdl, 12405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb->rc_handle ); 12415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb2 = bta_av_get_rcb_by_shdl(p_rcb->shdl); 12435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_rcb2) 12445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* found the RCB that was created to associated with this SCB */ 12465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->rc_acp_handle = p_rcb2->handle; 12475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->rc_acp_idx = (p_rcb2 - p_cb->rcb) + 1; 12485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG2("new rc_acp_handle:%d, idx:%d", p_cb->rc_acp_handle, 12495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->rc_acp_idx); 12505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb2->lidx = (BTA_AV_NUM_LINKS + 1); 12515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG3("rc2 handle:%d lidx:%d/%d",p_rcb2->handle, p_rcb2->lidx, 12525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->lcb[p_rcb2->lidx-1].lidx); 12535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->lidx = p_lcb->lidx; 12555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG3("rc handle:%d lidx:%d/%d",p_rcb->handle, p_rcb->lidx, 12565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->lcb[p_rcb->lidx-1].lidx); 12575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 12625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_cb->conn_audio & mask) && bta_av_cb.audio_open_cnt) 12645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* this channel is still marked as open. decrease the count */ 12665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_cb.audio_open_cnt--; 12675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* clear the conned mask for this channel */ 12705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->conn_audio &= ~mask; 12715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->conn_video &= ~mask; 12725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_scb) 12735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* the stream is closed. 12755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * clear the peer address, so it would not mess up the AVRCP for the next round of operation */ 12765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(p_scb->peer_addr, bd_addr_null); 12775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_scb->chnl == BTA_AV_CHNL_AUDIO) 12785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_lcb) 12805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb->conn_msk &= ~conn_msk; 12825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* audio channel is down. make sure the INT channel is down */ 12845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* just in case the RC timer is active 12855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_cb->features & BTA_AV_FEAT_RCCT) */ 12865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_stop_timer(&p_scb->timer); 12885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* one audio channel goes down. check if we need to restore high priority */ 12905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project chk_restore = TRUE; 12915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 12935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 12945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("bta_av_conn_chg shdl:%d", index + 1); 12955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (i=0; i<BTA_AV_NUM_RCB; i++) 12965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 12975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG5("conn_chg dn[%d]: %d, status=0x%x, shdl:%d, lidx:%d", i, 12985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_cb.rcb[i].handle, bta_av_cb.rcb[i].status, 12995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_cb.rcb[i].shdl, bta_av_cb.rcb[i].lidx); 13005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(bta_av_cb.rcb[i].shdl == index + 1) 13015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_del_rc(&bta_av_cb.rcb[i]); 13035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 13045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_cb->conn_audio == 0 && p_cb->conn_video == 0) 13085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if both channels are not connected, 13105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * close all RC channels */ 13115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_close_all_rc(p_cb); 13125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if the AVRCP is no longer listening, create the listening channel */ 13155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (bta_av_cb.rc_acp_handle == BTA_AV_RC_HANDLE_NONE && bta_av_cb.features & BTA_AV_FEAT_RCTG) 13165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_rc_create(&bta_av_cb, AVCT_ACP, 0, BTA_AV_NUM_LINKS + 1); 13175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG6("bta_av_conn_chg audio:%x video:%x up:%d conn_msk:0x%x chk_restore:%d audio_open_cnt:%d", 13205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->conn_audio, p_cb->conn_video, p_data->conn_chg.is_up, conn_msk, chk_restore, p_cb->audio_open_cnt); 13215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (chk_restore) 13235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cb->audio_open_cnt == 1) 13255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* one audio channel goes down and there's one audio channel remains open. 13275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * restore the switch role in default link policy */ 13285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_set_default_policy(BTA_ID_AV, HCI_ENABLE_MASTER_SLAVE_SWITCH); 13295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* allow role switch, if this is the last connection */ 13305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_restore_switch(); 13315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cb->audio_open_cnt) 13335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* adjust flush timeout settings to longer period */ 13355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for (i=0; i<BTA_AV_NUM_STRS; i++) 13365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scbi = bta_av_cb.p_scb[i]; 13385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_scbi && p_scbi->chnl == BTA_AV_CHNL_AUDIO && p_scbi->co_started) 13395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* may need to update the flush timeout of this already started stream */ 13415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_scbi->co_started != bta_av_cb.audio_open_cnt) 13425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scbi->co_started = bta_av_cb.audio_open_cnt; 13445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project L2CA_SetFlushTimeout(p_scbi->peer_addr, p_bta_av_cfg->p_audio_flush_to[p_scbi->co_started - 1] ); 13455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 13515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 13535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 13545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_disable 13555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 13565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description disable AV. 13575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 13585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 13595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 13605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 13615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_disable(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data) 13625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 13635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR hdr; 13645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 xx; 13655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->disabling = TRUE; 13675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_close_all_rc(p_cb); 13695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project utl_freebuf((void **) &p_cb->p_disc_db); 13715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* disable audio/video - de-register all channels, 13735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * expect BTA_AV_DEREG_COMP_EVT when deregister is complete */ 13745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for(xx=0; xx<BTA_AV_NUM_STRS; xx++) 13755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 13765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project hdr.layer_specific = xx + 1; 13775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_api_deregister((tBTA_AV_DATA *)&hdr); 13785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 13795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 13805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 13825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 13835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_api_disconnect 13845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 13855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description . 13865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 13875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 13885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 13895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 13905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_api_disconnect(tBTA_AV_DATA *p_data) 13915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 13925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project AVDT_DisconnectReq(p_data->api_discnt.bd_addr, bta_av_conn_cback); 13935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_stop_timer(&bta_av_cb.sig_tmr); 13945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 13955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 13965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 13975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 13985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_sig_chg 13995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 14005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description process AVDT signal channel up/down. 14015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 14025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 14035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 14045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 14055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_sig_chg(tBTA_AV_DATA *p_data) 14065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 14075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 event = p_data->str_msg.hdr.layer_specific; 14085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_CB *p_cb = &bta_av_cb; 14095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int xx; 14105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 mask; 14115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_LCB *p_lcb = NULL; 14125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("bta_av_sig_chg event: %d", event); 14145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(event == AVDT_CONNECT_IND_EVT) 14155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb = bta_av_find_lcb(p_data->str_msg.bd_addr, BTA_AV_LCB_FIND); 14175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(!p_lcb) 14185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if the address does not have an LCB yet, alloc one */ 14205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for(xx=0; xx<BTA_AV_NUM_LINKS; xx++) 14215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project mask = 1 << xx; 14235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("conn_lcb: 0x%x", p_cb->conn_lcb); 14245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1425ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /* look for a p_lcb with its p_scb registered */ 1426ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if((!(mask & p_cb->conn_lcb)) && (p_cb->p_scb[xx] != NULL)) 1427ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 14285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb = &p_cb->lcb[xx]; 14295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb->lidx = xx + 1; 14305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(p_lcb->addr, p_data->str_msg.bd_addr); 14315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb->conn_msk = 0; /* clear the connect mask */ 14325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* start listening when the signal channel is open */ 14335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cb->features & BTA_AV_FEAT_RCTG) 14345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_rc_create(p_cb, AVCT_ACP, 0, p_lcb->lidx); 14365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* this entry is not used yet. */ 14385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->conn_lcb |= mask; /* mark it as used */ 14395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("start sig timer %d", p_data->hdr.offset); 14405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_data->hdr.offset == AVDT_ACP) 14415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("Incoming L2CAP acquired, set state as incoming", NULL); 14435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(p_cb->p_scb[xx]->peer_addr, p_data->str_msg.bd_addr); 14445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->p_scb[xx]->use_rc = TRUE; /* allowing RC for incoming connection */ 14455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_ssm_execute(p_cb->p_scb[xx], BTA_AV_ACP_CONNECT_EVT, p_data); 14465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* The Pending Event should be sent as soon as the L2CAP signalling channel 14485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * is set up, which is NOW. Earlier this was done only after 14495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * BTA_AV_SIG_TIME_VAL milliseconds. 14505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * The following function shall send the event and start the recurring timer 14515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project */ 14525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_sig_timer(NULL); 14535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Possible collision : need to avoid outgoing processing while the timer is running */ 14555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->p_scb[xx]->coll_mask = BTA_AV_COLL_INC_TMR; 14565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 14575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->acp_sig_tmr.param = (UINT32)xx; 14585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->acp_sig_tmr.p_cback = (TIMER_CBACK*)&bta_av_acp_sig_timer_cback; 14595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_start_timer(&p_cb->acp_sig_tmr, 0, BTA_AV_ACP_SIG_TIME_VAL); 14605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 14625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 1464ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 1465ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /* check if we found something */ 1466ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta if (xx == BTA_AV_NUM_LINKS) 1467ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta { 1468ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /* We do not have scb for this avdt connection. */ 1469ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /* Silently close the connection. */ 1470ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta APPL_TRACE_ERROR0("av scb not available for avdt connection"); 1471ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta AVDT_DisconnectReq (p_data->str_msg.bd_addr, NULL); 1472ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta return; 1473ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta } 14745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE) 14775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (event == BTA_AR_AVDT_CONN_EVT) 14785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_stop_timer(&bta_av_cb.sig_tmr); 14805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 14825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 14835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* disconnected. */ 14855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb = bta_av_find_lcb(p_data->str_msg.bd_addr, BTA_AV_LCB_FREE); 14865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_lcb && p_lcb->conn_msk) 14875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("conn_msk: 0x%x", p_lcb->conn_msk); 14895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* clean up ssm */ 14905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for(xx=0; xx < BTA_AV_NUM_STRS; xx++) 14915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project mask = 1 << (xx + 1); 14935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((mask & p_lcb->conn_msk) && (p_cb->p_scb[xx]) && 14945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (bdcmp(p_cb->p_scb[xx]->peer_addr, p_data->str_msg.bd_addr) == 0)) 14955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 14965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_ssm_execute(p_cb->p_scb[xx], BTA_AV_AVDT_DISCONNECT_EVT, NULL); 14975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 14995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 15005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 15015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("conn_lcb: 0x%x", p_cb->conn_lcb); 15025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 15035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 15055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_sig_timer 15075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description process the signal channel timer. This timer is started 15095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** when the AVDTP signal channel is connected. If no profile 15105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** is connected, the timer goes off every BTA_AV_SIG_TIME_VAL 15115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 15135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 15155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_sig_timer(tBTA_AV_DATA *p_data) 15165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 15175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_CB *p_cb = &bta_av_cb; 15185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int xx; 15195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 mask; 15205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_LCB *p_lcb = NULL; 15215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_PEND pend; 15225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG0("bta_av_sig_timer"); 15245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for(xx=0; xx<BTA_AV_NUM_LINKS; xx++) 15255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 15265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project mask = 1 << xx; 15275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(mask & p_cb->conn_lcb) 15285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 15295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* this entry is used. check if it is connected */ 15305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb = &p_cb->lcb[xx]; 15315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(!p_lcb->conn_msk) 15325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 15335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_start_timer(&p_cb->sig_tmr, BTA_AV_SIG_TIMER_EVT, BTA_AV_SIG_TIME_VAL); 15345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(pend.bd_addr, p_lcb->addr); 15355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (*p_cb->p_cback)(BTA_AV_PENDING_EVT, (tBTA_AV *) &pend); 15365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 15375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 15385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 15395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 15405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 15425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_acp_sig_timer_cback 15445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Process the timeout when SRC is accepting connection 15465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** and SNK did not start signalling. 15475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 15495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 15505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 15515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectstatic void bta_av_acp_sig_timer_cback (TIMER_LIST_ENT *p_tle) 15525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 15535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 inx = (UINT8)p_tle->param; 15545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_CB *p_cb = &bta_av_cb; 15555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_SCB *p_scb = p_cb->p_scb[inx]; 15565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_API_OPEN *p_buf; 15575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_scb) 15595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 15605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("bta_av_acp_sig_timer_cback, coll_mask = 0x%02X", p_scb->coll_mask); 15615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_scb->coll_mask & BTA_AV_COLL_INC_TMR) 15635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 15645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb->coll_mask &= ~BTA_AV_COLL_INC_TMR; 15655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (bta_av_is_scb_opening(p_scb)) 15675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 15685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_scb->p_disc_db) 15695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 15705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* We are still doing SDP. Run the timer again. */ 15715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb->coll_mask |= BTA_AV_COLL_INC_TMR; 15725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->acp_sig_tmr.param = (UINT32)inx; 15745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->acp_sig_tmr.p_cback = (TIMER_CBACK *)&bta_av_acp_sig_timer_cback; 15755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_start_timer(&p_cb->acp_sig_tmr, 0, BTA_AV_ACP_SIG_TIME_VAL); 15765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 15775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 15785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 15795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* SNK did not start signalling, resume signalling process. */ 15805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_discover_req (p_scb, NULL); 15815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 15825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 15835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if (bta_av_is_scb_incoming(p_scb)) 15845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 15855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Stay in incoming state if SNK does not start signalling */ 15865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* API open was called right after SNK opened L2C connection. */ 15885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_scb->coll_mask & BTA_AV_COLL_API_CALLED) 15895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 15905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb->coll_mask &= ~BTA_AV_COLL_API_CALLED; 15915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 15925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* BTA_AV_API_OPEN_EVT */ 15935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_buf = (tBTA_AV_API_OPEN *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL) 15945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 15955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project memcpy(p_buf, &(p_scb->open_api), sizeof(tBTA_AV_API_OPEN)); 15965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_sendmsg(p_buf); 15975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 15985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 15995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 16035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 16055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_check_peer_features 16075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1608ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Description check supported features on the peer device from the SDP record 1609ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** and return the feature mask 16105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 1611ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta** Returns tBTA_AV_FEAT peer device feature mask 16125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 16145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source ProjecttBTA_AV_FEAT bta_av_check_peer_features (UINT16 service_uuid) 16155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 16165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_FEAT peer_features = 0; 16175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_CB *p_cb = &bta_av_cb; 16185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tSDP_DISC_REC *p_rec = NULL; 16195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tSDP_DISC_ATTR *p_attr; 16205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 peer_rc_version=0; 16215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 categories = 0; 16225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("bta_av_check_peer_features service_uuid:x%x", service_uuid); 16245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* loop through all records we found */ 16255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project while (TRUE) 16265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get next record; if none found, we're done */ 16285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_rec = SDP_FindServiceInDb(p_cb->p_disc_db, service_uuid, p_rec)) == NULL) 16295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project break; 16315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (( SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_CLASS_ID_LIST)) != NULL) 16345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* find peer features */ 16365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (SDP_FindServiceInDb(p_cb->p_disc_db, UUID_SERVCLASS_AV_REMOTE_CONTROL, NULL)) 16375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project peer_features |= BTA_AV_FEAT_RCCT; 16395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (SDP_FindServiceInDb(p_cb->p_disc_db, UUID_SERVCLASS_AV_REM_CTRL_TARGET, NULL)) 16415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project peer_features |= BTA_AV_FEAT_RCTG; 16435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (( SDP_FindAttributeInRec(p_rec, ATTR_ID_BT_PROFILE_DESC_LIST)) != NULL) 16475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get profile version (if failure, version parameter is not updated) */ 16495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_AV_REMOTE_CONTROL, &peer_rc_version); 16505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("peer_rc_version 0x%x", peer_rc_version); 16515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (peer_rc_version >= AVRC_REV_1_3) 16535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project peer_features |= (BTA_AV_FEAT_VENDOR | BTA_AV_FEAT_METADATA); 16545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (peer_rc_version >= AVRC_REV_1_4) 16565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project peer_features |= (BTA_AV_FEAT_ADV_CTRL); 16585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* get supported categories */ 16595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_attr = SDP_FindAttributeInRec(p_rec, 16605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ATTR_ID_SUPPORTED_FEATURES)) != NULL) 16615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project categories = p_attr->attr_value.v.u16; 16635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (categories & AVRC_SUPF_CT_BROWSE) 16645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project peer_features |= (BTA_AV_FEAT_BROWSE); 16655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("peer_features:x%x", peer_features); 16705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return peer_features; 16715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 16725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 16745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_rc_disc_done 16765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Handle AVRCP service discovery results. If matching 16785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** service found, open AVRCP connection. 16795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 16815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 16825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 16835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_rc_disc_done(tBTA_AV_DATA *p_data) 16845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 16855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_CB *p_cb = &bta_av_cb; 16865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_SCB *p_scb = NULL; 16875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_LCB *p_lcb; 16885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RC_OPEN rc_open; 16895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RC_FEAT rc_feat; 16905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 rc_handle; 16915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_FEAT peer_features; /* peer features mask */ 16925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("bta_av_rc_disc_done disc:x%x", p_cb->disc); 16945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (!p_cb->disc) 16955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 16965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 16975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 16985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 16995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_cb->disc & BTA_AV_CHNL_MSK) == BTA_AV_CHNL_MSK) 17005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* this is the rc handle/index to tBTA_AV_RCB */ 17025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_handle = p_cb->disc & (~BTA_AV_CHNL_MSK); 17035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 17055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb = p_cb->p_scb[(p_cb->disc & BTA_AV_HNDL_MSK) - 1]; 17075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_scb) 17085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_handle = p_scb->rc_handle; 17095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 17105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->disc = 0; 17125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 17135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("rc_handle %d", rc_handle); 1717ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta /* check peer version and whether support CT and TG role */ 17185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project peer_features = bta_av_check_peer_features (UUID_SERVCLASS_AV_REMOTE_CONTROL); 17199adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan if ((p_cb->features & BTA_AV_FEAT_ADV_CTRL) && ((peer_features&BTA_AV_FEAT_ADV_CTRL) == 0)) 17209adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan { 17219adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan /* if we support advance control and peer does not, check their support on TG role 17229adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan * some implementation uses 1.3 on CT ans 1.4 on TG */ 17239adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan peer_features |= bta_av_check_peer_features (UUID_SERVCLASS_AV_REM_CTRL_TARGET); 17249adddf4965e9ddb01e339b934c343fcbd842a977Ravi Nagarajan } 17255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->disc = 0; 17275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project utl_freebuf((void **) &p_cb->p_disc_db); 17285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG2("peer_features 0x%x, features 0x%x", peer_features, p_cb->features); 17305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if we have no rc connection */ 17325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (rc_handle == BTA_AV_RC_HANDLE_NONE) 17335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_scb) 17355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if peer remote control service matches ours and USE_RC is TRUE */ 17375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((((p_cb->features & BTA_AV_FEAT_RCCT) && (peer_features & BTA_AV_FEAT_RCTG)) || 17385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ((p_cb->features & BTA_AV_FEAT_RCTG) && (peer_features & BTA_AV_FEAT_RCCT))) ) 17395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb = bta_av_find_lcb(p_scb->peer_addr, BTA_AV_LCB_FIND); 17415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_lcb) 17425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_handle = bta_av_rc_create(p_cb, AVCT_INT, (UINT8)(p_scb->hdi + 1), p_lcb->lidx); 17445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->rcb[rc_handle].peer_features = peer_features; 17455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if (BT_USE_TRACES == TRUE || BT_TRACE_APPL == TRUE) 17475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 17485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_ERROR0("can not find LCB!!"); 17505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 17525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if(p_scb->use_rc) 17545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* can not find AVRC on peer device. report failure */ 17565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb->use_rc = FALSE; 17575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(rc_open.peer_addr, p_scb->peer_addr); 17585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_open.peer_features = 0; 17595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_open.status = BTA_AV_FAIL_SDP; 17605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (*p_cb->p_cback)(BTA_AV_RC_OPEN_EVT, (tBTA_AV *) &rc_open); 17615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 17655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->rcb[rc_handle].peer_features = peer_features; 17675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_feat.rc_handle = rc_handle; 17685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_feat.peer_features = peer_features; 17695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (*p_cb->p_cback)(BTA_AV_RC_FEAT_EVT, (tBTA_AV *) &rc_feat); 17705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 17715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 17725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 17745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_rc_closed 17765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description Set AVRCP state to closed. 17785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 17805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 17815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 17825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_rc_closed(tBTA_AV_DATA *p_data) 17835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 17845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_CB *p_cb = &bta_av_cb; 17855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RC_CLOSE rc_close; 17865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RC_CONN_CHG *p_msg = (tBTA_AV_RC_CONN_CHG *)p_data; 17875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_RCB *p_rcb; 17885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_SCB *p_scb; 17895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project int i; 17905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BOOLEAN conn = FALSE; 17915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_LCB *p_lcb; 17925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 17935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_close.rc_handle = BTA_AV_RC_HANDLE_NONE; 17945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("bta_av_rc_closed rc_handle:%d", p_msg->handle); 17955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project for(i=0; i<BTA_AV_NUM_RCB; i++) 17965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 17975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb = &p_cb->rcb[i]; 17985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG3("bta_av_rc_closed rcb[%d] rc_handle:%d, status=0x%x", i, p_rcb->handle, p_rcb->status); 17995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_rcb->handle == p_msg->handle) 18005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_close.rc_handle = i; 18025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->status &= ~BTA_AV_RC_CONN_MASK; 18035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->peer_features = 0; 18045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG2(" shdl:%d, lidx:%d", p_rcb->shdl, p_rcb->lidx); 18055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_rcb->shdl) 18065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb = bta_av_cb.p_scb[p_rcb->shdl - 1]; 18085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_scb) 18095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(rc_close.peer_addr, p_scb->peer_addr); 18115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_scb->rc_handle == p_rcb->handle) 18125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb->rc_handle = BTA_AV_RC_HANDLE_NONE; 18135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG2("shdl:%d, srch:%d", p_rcb->shdl, p_scb->rc_handle); 18145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->shdl = 0; 18165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if(p_rcb->lidx == (BTA_AV_NUM_LINKS + 1) ) 18185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if the RCB uses the extra LCB, use the addr for event and clean it */ 18205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb = &p_cb->lcb[BTA_AV_NUM_LINKS]; 18215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(rc_close.peer_addr, p_msg->peer_addr); 18225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG6("rc_only closed bd_addr:%02x-%02x-%02x-%02x-%02x-%02x", 18235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->peer_addr[0], p_msg->peer_addr[1], 18245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->peer_addr[2], p_msg->peer_addr[3], 18255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_msg->peer_addr[4], p_msg->peer_addr[5]); 18265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb->conn_msk = 0; 18275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_lcb->lidx = 0; 18285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->lidx = 0; 18305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if((p_rcb->status & BTA_AV_RC_ROLE_MASK) == BTA_AV_RC_ROLE_INT) 18325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* AVCT CCB is deallocated */ 18345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->handle = BTA_AV_RC_HANDLE_NONE; 18355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_rcb->status = 0; 18365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 18385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* AVCT CCB is still there. dealloc */ 18405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_del_rc(p_rcb); 18415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if the AVRCP is no longer listening, create the listening channel */ 18435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (bta_av_cb.rc_acp_handle == BTA_AV_RC_HANDLE_NONE && bta_av_cb.features & BTA_AV_FEAT_RCTG) 18445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_rc_create(&bta_av_cb, AVCT_ACP, 0, BTA_AV_NUM_LINKS + 1); 18455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else if((p_rcb->handle != BTA_AV_RC_HANDLE_NONE) && (p_rcb->status & BTA_AV_RC_CONN_MASK)) 18485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* at least one channel is still connected */ 18505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project conn = TRUE; 18515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(!conn) 18555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* no AVRC channels are connected, go back to INIT state */ 18575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_sm_execute(p_cb, BTA_AV_AVRC_NONE_EVT, NULL); 18585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (rc_close.rc_handle == BTA_AV_RC_HANDLE_NONE) 18615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_close.rc_handle = p_msg->handle; 18635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bdcpy(rc_close.peer_addr, p_msg->peer_addr); 18645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 18655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project (*p_cb->p_cback)(BTA_AV_RC_CLOSE_EVT, (tBTA_AV *) &rc_close); 18665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 18675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 18695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_rc_disc 18715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description start AVRC SDP discovery. 18735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 18755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 18765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 18775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_rc_disc(UINT8 disc) 18785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 18795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_CB *p_cb = &bta_av_cb; 18805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tAVRC_SDP_DB_PARAMS db_params; 18815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT16 attr_list[] = {ATTR_ID_SERVICE_CLASS_ID_LIST, 18825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ATTR_ID_BT_PROFILE_DESC_LIST, 18835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ATTR_ID_SUPPORTED_FEATURES}; 18845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 hdi; 18855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_SCB *p_scb; 18865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 *p_addr = NULL; 18875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 rc_handle; 18885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG2("bta_av_rc_disc 0x%x, %d", disc, bta_av_cb.disc); 18905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((bta_av_cb.disc != 0) || (disc == 0)) 18915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project return; 18925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 18935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((disc & BTA_AV_CHNL_MSK) == BTA_AV_CHNL_MSK) 18945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* this is the rc handle/index to tBTA_AV_RCB */ 18965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project rc_handle = disc & (~BTA_AV_CHNL_MSK); 18975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cb->rcb[rc_handle].lidx) 18985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 18995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_addr = p_cb->lcb[p_cb->rcb[rc_handle].lidx-1].addr; 19005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 19015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 19025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 19035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 19045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project hdi = (disc & BTA_AV_HNDL_MSK) - 1; 19055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb = p_cb->p_scb[hdi]; 19065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_scb) 19085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 19095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("rc_handle %d", p_scb->rc_handle); 19105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_addr = p_scb->peer_addr; 19115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 19125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 19135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_addr) 19155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 19165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* allocate discovery database */ 19175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cb->p_disc_db == NULL) 19185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 19195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->p_disc_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(BTA_AV_DISC_BUF_SIZE); 19205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 19215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_cb->p_disc_db) 19235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 19245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* set up parameters */ 19255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project db_params.db_len = BTA_AV_DISC_BUF_SIZE; 19265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project db_params.num_attr = 3; 19275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project db_params.p_db = p_cb->p_disc_db; 19285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project db_params.p_attrs = attr_list; 19295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* searching for UUID_SERVCLASS_AV_REMOTE_CONTROL gets both TG and CT */ 19315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (AVRC_FindService(UUID_SERVCLASS_AV_REMOTE_CONTROL, p_addr, &db_params, 19325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_avrc_sdp_cback) == AVRC_SUCCESS) 19335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 19345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->disc = disc; 19355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG1("disc %d", p_cb->disc); 19365738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 19375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 19385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 19395738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 19405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/******************************************************************************* 19425738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 19435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Function bta_av_dereg_comp 19445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 19455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Description deregister complete. free the stream control block. 19465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 19475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** Returns void 19485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project** 19495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project*******************************************************************************/ 19505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Projectvoid bta_av_dereg_comp(tBTA_AV_DATA *p_data) 19515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project{ 19525738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_CB *p_cb = &bta_av_cb; 19535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_AV_SCB *p_scb; 19545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project tBTA_UTL_COD cod; 19555738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project UINT8 mask; 19565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project BT_HDR *p_buf; 19575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* find the stream control block */ 19595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_scb = bta_av_hndl_to_scb(p_data->hdr.layer_specific); 19605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_scb) 19625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 19635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG2("deregistered %d(h%d)", p_scb->chnl, p_scb->hndl); 19645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project mask = BTA_AV_HNDL_TO_MSK(p_scb->hdi); 19655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_scb->chnl == BTA_AV_CHNL_AUDIO) 19665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 19675738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->reg_audio &= ~mask; 19685738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if ((p_cb->conn_audio & mask) && bta_av_cb.audio_open_cnt) 19695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 19705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* this channel is still marked as open. decrease the count */ 19715738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_cb.audio_open_cnt--; 19725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 19735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->conn_audio &= ~mask; 19745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if (p_scb->q_tag == BTA_AV_Q_TAG_STREAM) 19765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 19775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* make sure no buffers are in q_info.a2d */ 19785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project while((p_buf = (BT_HDR*)GKI_dequeue (&p_scb->q_info.a2d)) != NULL) 19795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project GKI_freebuf(p_buf); 19805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 19815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 19825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* remove the A2DP SDP record, if no more audio stream is left */ 19835738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(!p_cb->reg_audio) 19845738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 19855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE) 19865738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_ar_dereg_avrc (UUID_SERVCLASS_AV_REMOTE_CONTROL, BTA_ID_AV); 19875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 19885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_del_sdp_rec(&p_cb->sdp_a2d_handle); 19895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_remove_uuid(UUID_SERVCLASS_AUDIO_SOURCE); 19905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 19915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 19925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project else 19935738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 19945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->reg_video &= ~mask; 19955738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* make sure that this channel is not connected */ 19965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->conn_video &= ~mask; 19975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* remove the VDP SDP record, (only one video stream at most) */ 19985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_del_sdp_rec(&p_cb->sdp_vdp_handle); 19995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_remove_uuid(UUID_SERVCLASS_VIDEO_SOURCE); 20005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 20015738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 20025738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* make sure that the timer is not active */ 20035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_sys_stop_timer(&p_scb->timer); 20045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project utl_freebuf((void **)&p_cb->p_scb[p_scb->hdi]); 20055738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 20065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 20075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project APPL_TRACE_DEBUG3("audio 0x%x, video: 0x%x, disable:%d", 20085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->reg_audio, p_cb->reg_video, p_cb->disabling); 20095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* if no stream control block is active */ 20105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if((p_cb->reg_audio + p_cb->reg_video) == 0) 20115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 20125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE) 20135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* deregister from AVDT */ 20145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_ar_dereg_avdt(BTA_ID_AV); 20155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 20165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* deregister from AVCT */ 20175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_ar_dereg_avrc (UUID_SERVCLASS_AV_REM_CTRL_TARGET, BTA_ID_AV); 20185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_ar_dereg_avct(BTA_ID_AV); 20195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 20205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 20215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project if(p_cb->disabling) 20225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project { 20235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project p_cb->disabling = FALSE; 20245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project bta_av_cb.features = 0; 20255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 20265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 20275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project /* Clear the Capturing service class bit */ 20285738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project cod.service = BTM_COD_SERVICE_CAPTURING; 20295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project utl_set_device_class(&cod, BTA_UTL_CLR_COD_SERVICE_CLASS); 20305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project } 20315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 20325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif /* BTA_AV_INCLUDED */ 2033