/* Copyright Statement: * * * * This software/firmware and related documentation ("MediaTek Software") are * * protected under relevant copyright laws. The information contained herein * * is confidential and proprietary to MediaTek Inc. and/or its licensors. * * Without the prior written permission of MediaTek inc. and/or its licensors, * * any reproduction, modification, use or disclosure of MediaTek Software, * * and information contained herein, in whole or in part, shall be strictly prohibited. * * * * MediaTek Inc. (C) 2016. All rights reserved. * * * * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES * * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") * * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON * * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, * * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. * * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE * * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR * * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH * * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES * * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES * * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK * * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR * * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND * * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, * * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, * * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO * * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. * * * * The following software/firmware and/or related documentation ("MediaTek Software") * * have been modified by MediaTek Inc. All revisions are subject to any receiver's * * applicable license agreements with MediaTek Inc. * */ #include "mtk_avct_int.h" #if defined(MTK_A2DP_SRC_SINK_BOTH) && (MTK_A2DP_SRC_SINK_BOTH == TRUE) /* legacy and new avrcp both register ACP, so we should not allocate more than * one scb for ACP. */ tAVCT_CCB* avct_ccb_find_acp(tAVCT_CC* p_cc) { tAVCT_CCB* p_ccb = &avct_cb.ccb[0]; int i; if (p_cc->role != AVCT_ACP) return NULL; for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) { if (p_ccb->allocated == AVCT_ALOC_LCB && p_ccb->cc.role == AVCT_ACP) { return p_ccb; } } return NULL; } uint16_t avct_ccb_check_acp(uint8_t* p_handle, tAVRC_CONN_CB* p_ccb, tAVCT_CC* p_cc) { uint16_t status = AVCT_SUCCESS; tAVCT_CCB* p_ctccb; p_ctccb = avct_ccb_find_acp(p_cc); if (p_ctccb != NULL) { *p_handle = avct_ccb_to_idx(p_ctccb); /* if ct and new avrcp register acp, there has been one registered */ AVRC_TRACE_DEBUG("%s acp has exist, handle:%d, company_id=%d, acp_company_id=%d", __func__, *p_handle, avrc_cb.ccb[*p_handle].company_id, p_ccb->company_id); if (avrc_cb.ccb[*p_handle].company_id != p_ccb->company_id) { avrc_cb.ccb_acp[*p_handle] = *p_ccb; } status = AVCT_ACP_EXIST; } return status; } void avrc_ccb_ctrl_cback(uint8_t handle, uint8_t event, uint16_t result, const RawAddress* peer_addr) { /* only ACP scb will use two callback for legacy and new avrcp */ if (avrc_cb.ccb_acp[handle].company_id != 0 && avrc_cb.ccb_acp[handle].company_id != avrc_cb.ccb[handle].company_id) { AVRC_TRACE_DEBUG("AVRC: ctrl handle=0x%02x, new_avrcp=%d", handle, avrc_cb.ccb_acp[handle].company_id==AVRC_CO_GOOGLE); avrc_cb.ccb_acp[handle].ctrl_cback.Run(handle, event, result, peer_addr); } } void avrc_ccb_msg_cback(uint8_t handle, uint8_t label, uint16_t opcode, tAVRC_MSG* p_msg) { /* only ACP scb will use two callback for legacy and new avrcp */ if (avrc_cb.ccb_acp[handle].company_id != 0 && avrc_cb.ccb_acp[handle].company_id != avrc_cb.ccb[handle].company_id) { AVRC_TRACE_DEBUG("AVRC: ctrl handle=0x%02x, new_avrcp=%d", handle, avrc_cb.ccb_acp[handle].company_id==AVRC_CO_GOOGLE); avrc_cb.ccb_acp[handle].msg_cback.Run(handle, label, opcode, p_msg); } } #endif