285 lines
10 KiB
C++
285 lines
10 KiB
C++
/* 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.
|
|
* */
|
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include "raw_address.h"
|
|
#include <hardware/bt_av.h>
|
|
#include "bt_target.h"
|
|
#include "include/hardware/bt_rc.h"
|
|
#include "btif/include/btif_av.h"
|
|
#include "osi/include/list.h"
|
|
#include "osi/include/osi.h"
|
|
#include "osi/include/alarm.h"
|
|
#include "btif/avrcp/avrcp_service.h"
|
|
#include "bta/include/bta_av_api.h"
|
|
#include "btif/include/btif_common.h"
|
|
#include "btif/include/btif_util.h"
|
|
#include "osi/include/allocator.h"
|
|
|
|
/*Notice!!: Here definition copy from AOSP, if AOSP change ,here need chang!@{*/
|
|
#define MAX_CMD_QUEUE_LEN 17
|
|
#define MAX_RC_NOTIFICATIONS AVRC_EVT_VOLUME_CHANGE
|
|
|
|
typedef struct {
|
|
uint8_t bNotify;
|
|
uint8_t label;
|
|
} btif_rc_reg_notifications_t;
|
|
|
|
/*******************************************************************************
|
|
**
|
|
** Function btif_av_max_target_bitrate
|
|
**
|
|
** Description max target bitrate
|
|
**
|
|
** Returns max target bitrate
|
|
**
|
|
*******************************************************************************/
|
|
extern int btif_av_max_target_bitrate(void);
|
|
|
|
extern bool btif_av_ldac_limit_bitrate_330(void);
|
|
|
|
// If vendor.bluetooth.ldac.abr value changed, call this function to update the prop value.
|
|
void btif_ldac_abr_prop_updated(void);
|
|
|
|
// Current device's LDAC ABR support value.
|
|
bool btif_ldac_abr_enabled(void);
|
|
|
|
/*******************************************************************************
|
|
**
|
|
** Function btif_av_inform_firmware_codec_info
|
|
**
|
|
** Description Inform codec type to firmware
|
|
**
|
|
** Returns void
|
|
**
|
|
*******************************************************************************/
|
|
extern void btif_av_inform_firmware_codec_state(bool game_mode, int codec_type);
|
|
|
|
typedef struct {
|
|
uint8_t label;
|
|
uint8_t ctype;
|
|
bool is_rsp_pending;
|
|
} btif_rc_cmd_ctxt_t;
|
|
|
|
typedef struct {
|
|
bool query_started;
|
|
uint8_t num_attrs;
|
|
uint8_t num_ext_attrs;
|
|
|
|
uint8_t attr_index;
|
|
uint8_t ext_attr_index;
|
|
uint8_t ext_val_index;
|
|
btrc_player_app_attr_t attrs[AVRC_MAX_APP_ATTR_SIZE];
|
|
btrc_player_app_ext_attr_t ext_attrs[AVRC_MAX_APP_ATTR_SIZE];
|
|
} btif_rc_player_app_settings_t;
|
|
|
|
typedef struct {
|
|
bool rc_connected;
|
|
bool br_connected; // Browsing channel.
|
|
uint8_t rc_handle;
|
|
tBTA_AV_FEAT rc_features;
|
|
uint16_t rc_cover_art_psm; // AVRCP-BIP psm
|
|
btrc_connection_state_t rc_state;
|
|
RawAddress rc_addr;
|
|
uint16_t rc_pending_play;
|
|
btif_rc_cmd_ctxt_t rc_pdu_info[MAX_CMD_QUEUE_LEN];
|
|
btif_rc_reg_notifications_t rc_notif[MAX_RC_NOTIFICATIONS];
|
|
unsigned int rc_volume;
|
|
uint8_t rc_vol_label;
|
|
list_t* rc_supported_event_list;
|
|
btif_rc_player_app_settings_t rc_app_settings;
|
|
alarm_t* rc_play_status_timer;
|
|
bool rc_features_processed;
|
|
uint64_t rc_playing_uid;
|
|
bool rc_procedure_complete;
|
|
#if defined(MTK_A2DP_SRC_SINK_BOTH) && (MTK_A2DP_SRC_SINK_BOTH == TRUE)
|
|
tBTA_AV_FEAT peer_ct_features;
|
|
tBTA_AV_FEAT peer_tg_features;
|
|
bool launch_cmd_pending; /* pending for getcap/regvolume */
|
|
#endif
|
|
} btif_rc_device_cb_t;
|
|
|
|
typedef struct {
|
|
std::mutex lock;
|
|
btif_rc_device_cb_t rc_multi_cb[BT_RC_NUM_APP];
|
|
} rc_cb_t;
|
|
|
|
typedef struct {
|
|
uint8_t label;
|
|
uint8_t pdu_id;
|
|
} btif_rc_status_cmd_timer_t;
|
|
|
|
typedef struct {
|
|
uint8_t label;
|
|
uint8_t pdu_id;
|
|
} btif_rc_control_cmd_timer_t;
|
|
|
|
typedef struct {
|
|
union {
|
|
btif_rc_status_cmd_timer_t rc_status_cmd;
|
|
btif_rc_control_cmd_timer_t rc_control_cmd;
|
|
};
|
|
RawAddress rc_addr;
|
|
} btif_rc_timer_context_t;
|
|
|
|
typedef struct {
|
|
bool in_use;
|
|
uint8_t lbl;
|
|
uint8_t handle;
|
|
btif_rc_timer_context_t txn_timer_context;
|
|
alarm_t* txn_timer;
|
|
} rc_transaction_t;
|
|
|
|
extern rc_cb_t btif_rc_cb;
|
|
/** @} */
|
|
|
|
#if defined(MTK_A2DP_SRC_SINK_BOTH) && (MTK_A2DP_SRC_SINK_BOTH == TRUE)
|
|
|
|
class BtifAvPeer;
|
|
bool btif_av_both_enable(void);
|
|
bool btif_av_peer_is_connected_sink(const RawAddress& peer_address);
|
|
bool btif_av_peer_is_sink(const RawAddress& peer_address);
|
|
void bta_av_event_callback(tBTA_AV_EVT event, tBTA_AV* p_data);
|
|
extern void btif_rc_get_addr_by_handle(uint8_t handle, RawAddress &rc_addr);
|
|
//extern void btif_rc_response_notification(const RawAddress &rc_addr, btav_audio_state_t a2dp_State);
|
|
void btif_report_both_connection_state(const RawAddress& peer_address,
|
|
btav_connection_state_t state);
|
|
void btif_report_both_audio_state(const RawAddress& peer_address,
|
|
btav_audio_state_t state);
|
|
|
|
BtifAvPeer* btif_av_find_both_peer(const RawAddress& peer_address);
|
|
BtifAvPeer* btif_av_find_both_active_peer();
|
|
BtifAvPeer* btif_av_handle_both_peer(uint8_t peer_sep, const RawAddress& peer_address, tBTA_AV_HNDL bta_handle);
|
|
void btif_av_check_peer_sep(BtifAvPeer& peer, uint8_t open_sep, const RawAddress& bd_addr);
|
|
void connect_int_for_coexist(RawAddress* peer_address, uint16_t uuid);
|
|
void btif_av_acl_disconnected_for_coexist(const RawAddress & peer_address);
|
|
|
|
void btif_get_peer_addr(uint8_t peer_sep, RawAddress &peer_address, tBTA_AV* p_data);
|
|
bool FindPeerForCoexist(uint8_t peer_id, uint8_t type);
|
|
uint8_t btif_get_peer_sep(uint8_t peer_sep, uint8_t registr_sep);
|
|
bool btif_av_peer_is_source(const RawAddress& peer_address);
|
|
|
|
//void btif_rc_get_addr_by_handle(uint8_t handle, RawAddress &rc_addr);
|
|
void btif_rc_check_pending_cmd (const RawAddress& peer_address);
|
|
|
|
#endif
|
|
bool btif_av_peer_is_source(const RawAddress& peer_address);
|
|
|
|
#if defined(MTK_VND_A2DP_PKT_LEN) && (MTK_VND_A2DP_PKT_LEN == TRUE)
|
|
/*******************************************************************************
|
|
**
|
|
** Function btif_av_change_pkt_len_callback
|
|
**
|
|
** Description Callback function for vendor specific event that to change packet length of a2dp
|
|
**
|
|
** Returns void
|
|
**
|
|
*******************************************************************************/
|
|
extern void btif_av_change_pkt_len_callback(uint8_t len, uint8_t* p);
|
|
#endif
|
|
|
|
#if defined(MTK_INTEROP_EXTENSION) && (MTK_INTEROP_EXTENSION == TRUE)
|
|
#include "uipc.h"
|
|
|
|
typedef void (*BtifA2dpDataCallback)(tUIPC_CH_ID ch_id, tUIPC_EVENT event);
|
|
|
|
class BtAvServiceDelayTimer {
|
|
public:
|
|
BtAvServiceDelayTimer() = default;
|
|
~BtAvServiceDelayTimer() = default;
|
|
static struct tUIPC_STATE* a2dp_uipc;
|
|
|
|
/*******************************************************************************
|
|
**
|
|
** Function btif_create_av_domain_timer
|
|
**
|
|
** Description Call it on enable AV service to create delay timer
|
|
**
|
|
** Returns void
|
|
**
|
|
*******************************************************************************/
|
|
static void btif_create_av_domain_timer();
|
|
|
|
/*******************************************************************************
|
|
**
|
|
** Function btif_av_is_black_peer_for_delay_start
|
|
**
|
|
** Description Call it to check peer device. Return TRUE and schedule delay
|
|
** timer when it blacklisted device, else return FALSE
|
|
**
|
|
** Returns bool
|
|
**
|
|
*******************************************************************************/
|
|
bool btif_av_is_black_peer_for_delay_start(const RawAddress& peer_addr);
|
|
|
|
/*******************************************************************************
|
|
**
|
|
** Function btif_a2dp_data_init
|
|
**
|
|
** Description Static function to set init prameters.
|
|
**
|
|
** Returns void
|
|
**
|
|
*******************************************************************************/
|
|
static void btif_a2dp_data_init(BtifA2dpDataCallback cb) {
|
|
BtAvServiceDelayTimer::btif_a2dp_data_cb_ = cb;
|
|
}
|
|
|
|
private:
|
|
static void btif_media_av_delay_start_cmd_hdlr(void* data);
|
|
static BtifA2dpDataCallback btif_a2dp_data_cb_;
|
|
};
|
|
|
|
#endif
|
|
|
|
#if defined(MTK_PTS_AV_TEST) && (MTK_PTS_AV_TEST == TRUE)
|
|
void btif_av_pts_test_init(const RawAddress* peer_address);
|
|
#endif
|
|
|
|
|
|
#if defined(MTK_DUAL_AUDIO) && (MTK_DUAL_AUDIO == TRUE)
|
|
extern void dualaudio_adjust_lrmode(const RawAddress& peer_address,
|
|
std::vector<btav_a2dp_codec_config_t>& codecs_selectable_capabilities);
|
|
void dualaudio_adjust_lrmode(std::vector<btav_a2dp_codec_config_t>& codec_preferences);
|
|
|
|
#endif
|
|
|
|
|