Change-Id: Iecf09c75f6124697bd081e7153495a77b0aa626dfourteen-wip
parent
242d50c271
commit
c869ac6233
@ -1,24 +0,0 @@ |
||||
cc_library_static { |
||||
name: "libbtdevice.sm7125", |
||||
defaults: ["fluoride_defaults"], |
||||
stem: "libbtdevice", |
||||
host_supported: true, |
||||
local_include_dirs: [ |
||||
"include", |
||||
], |
||||
include_dirs: [ |
||||
"system/bt", |
||||
"system/bt/btcore/include", |
||||
"system/bt/hci/include", |
||||
"system/bt/internal_include", |
||||
"system/bt/stack/include", |
||||
], |
||||
srcs: [ |
||||
"src/controller.cc", |
||||
"src/esco_parameters.cc", |
||||
"src/interop.cc", |
||||
], |
||||
shared_libs: [ |
||||
"liblog", |
||||
], |
||||
} |
@ -1,128 +0,0 @@ |
||||
/******************************************************************************
|
||||
* |
||||
* Copyright 2014 Google, Inc. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at: |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
******************************************************************************/ |
||||
|
||||
#pragma once |
||||
|
||||
#include <stdbool.h> |
||||
#include <stdint.h> |
||||
|
||||
#include "btcore/include/device_features.h" |
||||
#include "hci/include/hci_layer.h" |
||||
#include "hci/include/hci_packet_factory.h" |
||||
#include "hci/include/hci_packet_parser.h" |
||||
|
||||
static const char CONTROLLER_MODULE[] = "controller_module"; |
||||
|
||||
typedef struct controller_t { |
||||
bool (*get_is_ready)(void); |
||||
|
||||
const RawAddress* (*get_address)(void); |
||||
const bt_version_t* (*get_bt_version)(void); |
||||
|
||||
const uint8_t* (*get_ble_supported_states)(void); |
||||
|
||||
bool (*supports_simple_pairing)(void); |
||||
bool (*supports_secure_connections)(void); |
||||
bool (*supports_simultaneous_le_bredr)(void); |
||||
bool (*supports_reading_remote_extended_features)(void); |
||||
bool (*supports_interlaced_inquiry_scan)(void); |
||||
bool (*supports_rssi_with_inquiry_results)(void); |
||||
bool (*supports_extended_inquiry_response)(void); |
||||
bool (*supports_central_peripheral_role_switch)(void); |
||||
bool (*supports_enhanced_setup_synchronous_connection)(void); |
||||
bool (*supports_enhanced_accept_synchronous_connection)(void); |
||||
bool (*supports_3_slot_packets)(void); |
||||
bool (*supports_5_slot_packets)(void); |
||||
bool (*supports_classic_2m_phy)(void); |
||||
bool (*supports_classic_3m_phy)(void); |
||||
bool (*supports_3_slot_edr_packets)(void); |
||||
bool (*supports_5_slot_edr_packets)(void); |
||||
bool (*supports_sco)(void); |
||||
bool (*supports_hv2_packets)(void); |
||||
bool (*supports_hv3_packets)(void); |
||||
bool (*supports_ev3_packets)(void); |
||||
bool (*supports_ev4_packets)(void); |
||||
bool (*supports_ev5_packets)(void); |
||||
bool (*supports_esco_2m_phy)(void); |
||||
bool (*supports_esco_3m_phy)(void); |
||||
bool (*supports_3_slot_esco_edr_packets)(void); |
||||
bool (*supports_role_switch)(void); |
||||
bool (*supports_hold_mode)(void); |
||||
bool (*supports_sniff_mode)(void); |
||||
bool (*supports_park_mode)(void); |
||||
bool (*supports_non_flushable_pb)(void); |
||||
bool (*supports_sniff_subrating)(void); |
||||
bool (*supports_encryption_pause)(void); |
||||
|
||||
bool (*supports_ble)(void); |
||||
bool (*supports_ble_packet_extension)(void); |
||||
bool (*supports_ble_connection_parameters_request)(void); |
||||
bool (*supports_ble_privacy)(void); |
||||
bool (*supports_ble_set_privacy_mode)(void); |
||||
bool (*supports_ble_2m_phy)(void); |
||||
bool (*supports_ble_coded_phy)(void); |
||||
bool (*supports_ble_extended_advertising)(void); |
||||
bool (*supports_ble_periodic_advertising)(void); |
||||
bool (*supports_ble_peripheral_initiated_feature_exchange)(void); |
||||
bool (*supports_ble_connection_parameter_request)(void); |
||||
bool (*supports_ble_periodic_advertising_sync_transfer_sender)(void); |
||||
bool (*supports_ble_periodic_advertising_sync_transfer_recipient)(void); |
||||
bool (*supports_ble_connected_isochronous_stream_central)(void); |
||||
bool (*supports_ble_connected_isochronous_stream_peripheral)(void); |
||||
bool (*supports_ble_isochronous_broadcaster)(void); |
||||
bool (*supports_ble_synchronized_receiver)(void); |
||||
|
||||
// Get the cached acl data sizes for the controller.
|
||||
uint16_t (*get_acl_data_size_classic)(void); |
||||
uint16_t (*get_acl_data_size_ble)(void); |
||||
uint16_t (*get_iso_data_size)(void); |
||||
|
||||
// Get the cached acl packet sizes for the controller.
|
||||
// This is a convenience function for the respective
|
||||
// acl data size + size of the acl header.
|
||||
uint16_t (*get_acl_packet_size_classic)(void); |
||||
uint16_t (*get_acl_packet_size_ble)(void); |
||||
uint16_t (*get_iso_packet_size)(void); |
||||
|
||||
uint16_t (*get_ble_default_data_packet_length)(void); |
||||
uint16_t (*get_ble_maximum_tx_data_length)(void); |
||||
uint16_t (*get_ble_maximum_tx_time)(void); |
||||
uint16_t (*get_ble_maxium_advertising_data_length)(void); |
||||
uint8_t (*get_ble_number_of_supported_advertising_sets)(void); |
||||
uint8_t (*get_ble_periodic_advertiser_list_size)(void); |
||||
|
||||
// Get the number of acl packets the controller can buffer.
|
||||
uint16_t (*get_acl_buffer_count_classic)(void); |
||||
uint8_t (*get_acl_buffer_count_ble)(void); |
||||
uint8_t (*get_iso_buffer_count)(void); |
||||
|
||||
uint8_t (*get_ble_acceptlist_size)(void); |
||||
|
||||
uint8_t (*get_ble_resolving_list_max_size)(void); |
||||
void (*set_ble_resolving_list_max_size)(int resolving_list_max_size); |
||||
uint8_t* (*get_local_supported_codecs)(uint8_t* number_of_codecs); |
||||
uint8_t (*get_le_all_initiating_phys)(void); |
||||
|
||||
} controller_t; |
||||
|
||||
const controller_t* controller_get_interface(); |
||||
|
||||
const controller_t* controller_get_test_interface( |
||||
const hci_t* hci_interface, |
||||
const hci_packet_factory_t* packet_factory_interface, |
||||
const hci_packet_parser_t* packet_parser_interface); |
@ -1,139 +0,0 @@ |
||||
/******************************************************************************
|
||||
* |
||||
* Copyright 2015 Broadcom Corporation |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at: |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
******************************************************************************/ |
||||
|
||||
#pragma once |
||||
|
||||
#include <stdint.h> |
||||
|
||||
/*******************
|
||||
* SCO Codec Types |
||||
*******************/ |
||||
typedef enum { |
||||
SCO_CODEC_NONE = 0x0000, |
||||
SCO_CODEC_CVSD = 0x0001, |
||||
SCO_CODEC_MSBC = 0x0002, |
||||
} sco_codec_t; |
||||
|
||||
typedef enum { |
||||
SCO_CODEC_CVSD_D1 = 0, |
||||
ESCO_CODEC_CVSD_S3, |
||||
ESCO_CODEC_CVSD_S4, |
||||
ESCO_CODEC_MSBC_T1, |
||||
ESCO_CODEC_MSBC_T2, |
||||
} esco_codec_t; |
||||
|
||||
#define ESCO_NUM_CODECS 5 |
||||
|
||||
// Coding Formats (BT 4.1 or later Assigned numbers)
|
||||
#define ESCO_CODING_FORMAT_ULAW ((uint8_t)0x00) /* u-Law log */ |
||||
#define ESCO_CODING_FORMAT_ALAW ((uint8_t)0x01) /* A-Law log */ |
||||
#define ESCO_CODING_FORMAT_CVSD ((uint8_t)0x02) /* CVSD */ |
||||
#define ESCO_CODING_FORMAT_TRANSPNT ((uint8_t)0x03) /* Transparent */ |
||||
#define ESCO_CODING_FORMAT_LINEAR ((uint8_t)0x04) /* Linear PCM */ |
||||
#define ESCO_CODING_FORMAT_MSBC ((uint8_t)0x05) /* MSBC PCM */ |
||||
#define ESCO_CODING_FORMAT_VS ((uint8_t)0xFF) /* Specifies VSC used */ |
||||
typedef uint8_t esco_coding_format_t; |
||||
|
||||
// PCM Data Formats (BT 4.1 or later Assigned numbers)
|
||||
#define ESCO_PCM_DATA_FORMAT_NA \ |
||||
((uint8_t)0x00) /* N/A to coding format in use */ |
||||
#define ESCO_PCM_DATA_FORMAT_1_COMP ((uint8_t)0x01) /* 1's complement */ |
||||
#define ESCO_PCM_DATA_FORMAT_2_COMP ((uint8_t)0x02) /* 2's complement */ |
||||
#define ESCO_PCM_DATA_FORMAT_SIGN ((uint8_t)0x03) /* Sign-magnitude */ |
||||
#define ESCO_PCM_DATA_FORMAT_UNSIGN ((uint8_t)0x04) /* Unsigned */ |
||||
typedef uint8_t esco_pcm_data_format_t; |
||||
|
||||
// SCO Data Path
|
||||
#define ESCO_DATA_PATH_PCM 1 /* 0x01-0xFE (PCM Chan) */ |
||||
#define ESCO_DATA_PATH_HCI ((uint8_t)0x00) /* HCI-0, 0x01-0xFE (PCM Chan) */ |
||||
#define ESCO_DATA_PATH_TEST ((uint8_t)0xFF) /* 0xFF-Audio Test */ |
||||
typedef uint8_t esco_data_path_t; |
||||
|
||||
// eSCO constants
|
||||
#define TXRX_64KBITS_RATE 0x00001f40 /* 64 kbits/sec data rate */ |
||||
#define TXRX_128KBITS_RATE 0x00003E80 /* 128 kbits/sec data rate */ |
||||
typedef uint32_t esco_txrx_bandwidth_t; |
||||
|
||||
#define INPUT_OUTPUT_64K_RATE 0x00003E80 /* 16000 Bytes/sec over transport */ |
||||
#define INPUT_OUTPUT_128K_RATE 0x00007D00 /* 32000 Bytes/sec over transport */ |
||||
typedef uint32_t esco_io_bandwidth_t; |
||||
|
||||
// Retransmission effort
|
||||
#define ESCO_RETRANSMISSION_OFF 0 |
||||
#define ESCO_RETRANSMISSION_POWER 1 |
||||
#define ESCO_RETRANSMISSION_QUALITY 2 |
||||
#define ESCO_RETRANSMISSION_DONTCARE 0xff |
||||
typedef uint8_t esco_retransmission_effort_t; |
||||
|
||||
// Definitions for eSCO packet type masks (BT1.2 and BT2.0 definitions)
|
||||
#define ESCO_PKT_TYPES_MASK_HV1 0x0001 |
||||
#define ESCO_PKT_TYPES_MASK_HV2 0x0002 |
||||
#define ESCO_PKT_TYPES_MASK_HV3 0x0004 |
||||
#define ESCO_PKT_TYPES_MASK_EV3 0x0008 |
||||
#define ESCO_PKT_TYPES_MASK_EV4 0x0010 |
||||
#define ESCO_PKT_TYPES_MASK_EV5 0x0020 |
||||
#define ESCO_PKT_TYPES_MASK_NO_2_EV3 0x0040 |
||||
#define ESCO_PKT_TYPES_MASK_NO_3_EV3 0x0080 |
||||
#define ESCO_PKT_TYPES_MASK_NO_2_EV5 0x0100 |
||||
#define ESCO_PKT_TYPES_MASK_NO_3_EV5 0x0200 |
||||
typedef uint16_t esco_packet_types_t; |
||||
|
||||
// type definition
|
||||
typedef struct { |
||||
esco_coding_format_t coding_format; /* Coding Format*/ |
||||
uint16_t company_id; /* Company ID from BT SIG Assigned Numbers */ |
||||
uint16_t vendor_specific_codec_id; /* Vendor Specific Codec ID */ |
||||
} esco_coding_id_format_t; |
||||
|
||||
// Enhanced setup/accept synchronous connection See BT 4.1 or later HCI spec for
|
||||
// details
|
||||
typedef struct { |
||||
esco_txrx_bandwidth_t |
||||
transmit_bandwidth; /* Transmit Bandwidth (in octets/second) */ |
||||
esco_txrx_bandwidth_t receive_bandwidth; /* RX BW (# of octets/second) */ |
||||
esco_coding_id_format_t transmit_coding_format; /* TX coding format */ |
||||
esco_coding_id_format_t receive_coding_format; /* RX coding format */ |
||||
uint16_t transmit_codec_frame_size; /* TX CODEC frame size (OTA frame size) */ |
||||
uint16_t receive_codec_frame_size; /* RX CODEC frame size (OTA frame size) */ |
||||
esco_io_bandwidth_t input_bandwidth; /* Input BW (nominal rate octets/sec) */ |
||||
esco_io_bandwidth_t |
||||
output_bandwidth; /* Output BW (nominal rate octets/sec) */ |
||||
esco_coding_id_format_t input_coding_format; /* Input coding format */ |
||||
esco_coding_id_format_t output_coding_format; /* Output coding format */ |
||||
uint16_t input_coded_data_size; /* Input coded data size (in bits) */ |
||||
uint16_t output_coded_data_size; /* Output coded data size (in bits) */ |
||||
esco_pcm_data_format_t |
||||
input_pcm_data_format; /* Input PCM data format (see hcidefs.h) */ |
||||
esco_pcm_data_format_t |
||||
output_pcm_data_format; /* Output PCM data format (see hcidefs.h) */ |
||||
uint8_t input_pcm_payload_msb_position; /* Input PCM sample payload MSB
|
||||
position */ |
||||
uint8_t output_pcm_payload_msb_position; /* Output PCM sample payload MSB
|
||||
position */ |
||||
esco_data_path_t input_data_path; /* 0x00 - HCI, or 0x01-0xFE for VS) */ |
||||
esco_data_path_t output_data_path; /* 0x00 - HCI, or 0x01-0xFE for VS) */ |
||||
uint8_t input_transport_unit_size; /* Input transport unit size */ |
||||
uint8_t output_transport_unit_size; /* Output transport unit size */ |
||||
uint16_t max_latency_ms; /* Maximum latency (0x4-0xFFFE in msecs) */ |
||||
esco_packet_types_t packet_types; /* Packet Types */ |
||||
esco_retransmission_effort_t |
||||
retransmission_effort; /* 0x00-0x02, 0xFF don't care */ |
||||
} enh_esco_params_t; |
||||
|
||||
// Get the enhanced eSCO configuration parameters for the provided |codec|
|
||||
enh_esco_params_t esco_parameters_for_codec(esco_codec_t codec); |
@ -1,146 +0,0 @@ |
||||
/******************************************************************************
|
||||
* |
||||
* Copyright 2015 Google, Inc. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at: |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
******************************************************************************/ |
||||
|
||||
#pragma once |
||||
|
||||
#include <stdbool.h> |
||||
|
||||
#include "raw_address.h" |
||||
|
||||
static const char INTEROP_MODULE[] = "interop_module"; |
||||
|
||||
// NOTE:
|
||||
// Only add values at the end of this enum and do NOT delete values
|
||||
// as they may be used in dynamic device configuration.
|
||||
typedef enum { |
||||
// Disable secure connections
|
||||
// This is for pre BT 4.1/2 devices that do not handle secure mode
|
||||
// very well.
|
||||
INTEROP_DISABLE_LE_SECURE_CONNECTIONS = 0, |
||||
|
||||
// Some devices have proven problematic during the pairing process, often
|
||||
// requiring multiple retries to complete pairing. To avoid degrading the user
|
||||
// experience for those devices, automatically re-try pairing if page
|
||||
// timeouts are received during pairing.
|
||||
INTEROP_AUTO_RETRY_PAIRING, |
||||
|
||||
// Devices requiring this workaround do not handle Bluetooth Absolute Volume
|
||||
// control correctly, leading to undesirable (potentially harmful) volume
|
||||
// levels or general lack of controlability.
|
||||
INTEROP_DISABLE_ABSOLUTE_VOLUME, |
||||
|
||||
// Disable automatic pairing with headsets/car-kits
|
||||
// Some car kits do not react kindly to a failed pairing attempt and
|
||||
// do not allow immediate re-pairing. Rejectlist these so that the initial
|
||||
// pairing attempt makes it to the user instead.
|
||||
INTEROP_DISABLE_AUTO_PAIRING, |
||||
|
||||
// Use a fixed pin for specific keyboards
|
||||
// Keyboards should use a variable pin at all times. However, some keyboards
|
||||
// require a fixed pin of all 0000. This workaround enables auto pairing for
|
||||
// those keyboards.
|
||||
INTEROP_KEYBOARD_REQUIRES_FIXED_PIN, |
||||
|
||||
// Some headsets have audio jitter issues because of increased
|
||||
// re-transmissions as the 3 Mbps packets have a lower link margin, and are
|
||||
// more prone to interference. We can disable 3DH packets (use only 2DH
|
||||
// packets) for the ACL link to improve sensitivity when streaming A2DP audio
|
||||
// to the headset. Air sniffer logs show reduced re-transmissions after
|
||||
// switching to 2DH packets.
|
||||
|
||||
// Disable 3Mbps packets and use only 2Mbps packets for ACL links when
|
||||
// streaming audio.
|
||||
INTEROP_2MBPS_LINK_ONLY, |
||||
|
||||
// Do not use supervision timeout value received from preferred connection
|
||||
// parameters, use 3s instead. Use with HID only.
|
||||
INTEROP_HID_PREF_CONN_SUP_TIMEOUT_3S, |
||||
|
||||
// Do not send service changed indications (GATT client).
|
||||
// This should be removed after the characteristic is implmeented b/62088395.
|
||||
INTEROP_GATTC_NO_SERVICE_CHANGED_IND, |
||||
|
||||
// Do not use AVDTP RECONFIGURE when reconfiguring A2DP streams.
|
||||
// Some A2DP Sink devices report SUCCESS to the AVDTP RECONFIGURE command,
|
||||
// but fail to play the reconfigured audio stream.
|
||||
INTEROP_DISABLE_AVDTP_RECONFIGURE, |
||||
|
||||
// Create dynamic rejectlist to disable role switch.
|
||||
// Some car kits indicate that role switch is supported, but then reject
|
||||
// role switch attempts. After rejecting several role switch attempts,
|
||||
// such car kits will go into bad state.
|
||||
INTEROP_DYNAMIC_ROLE_SWITCH, |
||||
|
||||
// Disable role switch for headsets/car-kits.
|
||||
// Some car kits allow role switch but when the Phone initiates role switch,
|
||||
// the Remote device will go into bad state that will lead to LMP time out.
|
||||
INTEROP_DISABLE_ROLE_SWITCH, |
||||
|
||||
// Set a very low initial sniff subrating for HID devices that do not
|
||||
// set their own sniff interval.
|
||||
INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL, |
||||
|
||||
// Disable remote name requst for some devices.
|
||||
// The public address of these devices are same as the Random address in ADV.
|
||||
// Then will get name by LE_Create_connection, actually fails,
|
||||
// but will block pairing.
|
||||
INTEROP_DISABLE_NAME_REQUEST, |
||||
|
||||
// Respond AVRCP profile version only 1.4 for some device.
|
||||
INTEROP_AVRCP_1_4_ONLY, |
||||
|
||||
// Disable sniff mode for headsets/car-kits
|
||||
// Some car kits supports sniff mode but when DUT initiates sniff req
|
||||
// Remote will go to bad state and its leads to LMP time out.
|
||||
INTEROP_DISABLE_SNIFF, |
||||
|
||||
// Do not send AVDTP SUSPEND while the playback is paused.
|
||||
// Some older A2DP Sink devices might not support to pause the streaming.
|
||||
INTEROP_DISABLE_AVDTP_SUSPEND, |
||||
|
||||
// Some car kits do not send the AT+BIND command while establishing the SLC
|
||||
// which causes an HFP profile connection failure
|
||||
INTEROP_SLC_SKIP_BIND_COMMAND |
||||
} interop_feature_t; |
||||
|
||||
// Check if a given |addr| matches a known interoperability workaround as
|
||||
// identified by the |interop_feature_t| enum. This API is used for simple
|
||||
// address based lookups where more information is not available. No
|
||||
// look-ups or random address resolution are performed on |addr|.
|
||||
bool interop_match_addr(const interop_feature_t feature, |
||||
const RawAddress* addr); |
||||
|
||||
// Check if a given remote device |name| matches a known workaround.
|
||||
// Name comparisons are case sensitive and do not allow for partial matches.
|
||||
// If |name| is "TEST" and a workaround exists for "TESTING", then this function
|
||||
// will return false. But, if |name| is "TESTING" and a workaround exists for
|
||||
// "TEST", this function will return true.
|
||||
// |name| cannot be null and must be null terminated.
|
||||
bool interop_match_name(const interop_feature_t feature, const char* name); |
||||
|
||||
// Add a dynamic interop database entry for a device matching the first |length|
|
||||
// bytes of |addr|, implementing the workaround identified by |feature|.
|
||||
// |addr| may not be null.
|
||||
// |length| must be greater than 0 and less than RawAddress::kLength.
|
||||
// As |interop_feature_t| is not exposed in the public API, feature must be a
|
||||
// valid integer representing an option in the enum.
|
||||
void interop_database_add(uint16_t feature, const RawAddress* addr, |
||||
size_t length); |
||||
|
||||
// Clear the dynamic portion of the interoperability workaround database.
|
||||
void interop_database_clear(void); |
@ -1,217 +0,0 @@ |
||||
/******************************************************************************
|
||||
* |
||||
* Copyright 2015 Google, Inc. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at: |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
******************************************************************************/ |
||||
|
||||
#pragma once |
||||
|
||||
#include "device/include/interop.h" |
||||
#include "raw_address.h" |
||||
|
||||
typedef struct { |
||||
RawAddress addr; |
||||
size_t length; |
||||
interop_feature_t feature; |
||||
} interop_addr_entry_t; |
||||
|
||||
static const interop_addr_entry_t interop_addr_database[] = { |
||||
// Nexus Remote (Spike)
|
||||
// Note: May affect other Asus brand devices
|
||||
{{{0x08, 0x62, 0x66, 0, 0, 0}}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, |
||||
{{{0x38, 0x2c, 0x4a, 0xc9, 0, 0}}, |
||||
4, |
||||
INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, |
||||
{{{0x38, 0x2c, 0x4a, 0xe6, 0, 0}}, |
||||
4, |
||||
INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, |
||||
{{{0x54, 0xa0, 0x50, 0xd9, 0, 0}}, |
||||
4, |
||||
INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, |
||||
{{{0xac, 0x9e, 0x17, 0, 0, 0}}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, |
||||
{{{0xf0, 0x79, 0x59, 0, 0, 0}}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, |
||||
|
||||
{{{0x08, 0x62, 0x66, 0, 0, 0}}, 3, INTEROP_HID_PREF_CONN_SUP_TIMEOUT_3S}, |
||||
{{{0x38, 0x2c, 0x4a, 0xc9, 0, 0}}, 4, INTEROP_HID_PREF_CONN_SUP_TIMEOUT_3S}, |
||||
{{{0x38, 0x2c, 0x4a, 0xe6, 0, 0}}, 4, INTEROP_HID_PREF_CONN_SUP_TIMEOUT_3S}, |
||||
{{{0x54, 0xa0, 0x50, 0xd9, 0, 0}}, 4, INTEROP_HID_PREF_CONN_SUP_TIMEOUT_3S}, |
||||
{{{0xac, 0x9e, 0x17, 0, 0, 0}}, 3, INTEROP_HID_PREF_CONN_SUP_TIMEOUT_3S}, |
||||
{{{0xf0, 0x79, 0x59, 0, 0, 0}}, 3, INTEROP_HID_PREF_CONN_SUP_TIMEOUT_3S}, |
||||
|
||||
// Ausdom M05 - unacceptably loud volume
|
||||
{{{0xa0, 0xe9, 0xdb, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
|
||||
// BMW car kits (Harman/Becker)
|
||||
{{{0x9c, 0xdf, 0x03, 0, 0, 0}}, 3, INTEROP_AUTO_RETRY_PAIRING}, |
||||
|
||||
// Flic smart button
|
||||
{{{0x80, 0xe4, 0xda, 0x70, 0, 0}}, |
||||
4, |
||||
INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, |
||||
|
||||
// iKross IKBT83B HS - unacceptably loud volume
|
||||
{{{0x00, 0x14, 0x02, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
|
||||
// JayBird BlueBuds X - low granularity on volume control
|
||||
{{{0x44, 0x5e, 0xf3, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
{{{0xd4, 0x9c, 0x28, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
|
||||
// Bose QuiteComfort 35, SoundSport and similar (because of older firmware)
|
||||
{{{0x04, 0x52, 0xc7, 0, 0, 0}}, 3, INTEROP_2MBPS_LINK_ONLY}, |
||||
|
||||
// JayBird Family
|
||||
{{{0x00, 0x18, 0x91, 0, 0, 0}}, 3, INTEROP_2MBPS_LINK_ONLY}, |
||||
|
||||
// Sony MBH-10
|
||||
{{{0x20, 0x15, 0x06, 0, 0, 0}}, 3, INTEROP_2MBPS_LINK_ONLY}, |
||||
|
||||
// Uconnect
|
||||
{{{0x00, 0x54, 0xaf, 0, 0, 0}}, 3, INTEROP_2MBPS_LINK_ONLY}, |
||||
{{{0x30, 0x14, 0x4a, 0, 0, 0}}, 3, INTEROP_2MBPS_LINK_ONLY}, |
||||
|
||||
// LG Tone HBS-730 - unacceptably loud volume
|
||||
{{{0x00, 0x18, 0x6b, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
{{{0xb8, 0xad, 0x3e, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
|
||||
// LG Tone HV-800 - unacceptably loud volume
|
||||
{{{0xa0, 0xe9, 0xdb, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
|
||||
// Motorola Key Link
|
||||
{{{0x1c, 0x96, 0x5a, 0, 0, 0}}, 3, INTEROP_DISABLE_LE_SECURE_CONNECTIONS}, |
||||
|
||||
// Motorola Roadster
|
||||
{{{0x00, 0x24, 0x1C, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
|
||||
// Mpow Cheetah - unacceptably loud volume
|
||||
{{{0x00, 0x11, 0xb1, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
|
||||
// Nissan car kits (ALPS) - auto-pairing fails and rejects next pairing
|
||||
{{{0x34, 0xc7, 0x31, 0, 0, 0}}, 3, INTEROP_DISABLE_AUTO_PAIRING}, |
||||
|
||||
// SOL REPUBLIC Tracks Air - unable to adjust volume back off from max
|
||||
{{{0xa4, 0x15, 0x66, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
|
||||
// Subaru car kits (ALPS) - auto-pairing fails and rejects next pairing
|
||||
{{{0x00, 0x07, 0x04, 0, 0, 0}}, 3, INTEROP_DISABLE_AUTO_PAIRING}, |
||||
{{{0xe0, 0x75, 0x0a, 0, 0, 0}}, 3, INTEROP_DISABLE_AUTO_PAIRING}, |
||||
|
||||
// Swage Rokitboost HS - unacceptably loud volume
|
||||
{{{0x00, 0x14, 0xf1, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
|
||||
// VW Car Kit - not enough granularity with volume
|
||||
{{{0x00, 0x26, 0x7e, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
{{{0x90, 0x03, 0xb7, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
|
||||
// Unknown keyboard (carried over from auto_pair_devlist.conf)
|
||||
{{{0x00, 0x0F, 0xF6, 0, 0, 0}}, 3, INTEROP_KEYBOARD_REQUIRES_FIXED_PIN}, |
||||
|
||||
// Kenwood KMM-BT518HD - no audio when A2DP codec sample rate is changed
|
||||
{{{0x00, 0x1d, 0x86, 0, 0, 0}}, 3, INTEROP_DISABLE_AVDTP_RECONFIGURE}, |
||||
|
||||
// NAC FORD-2013 - Lincoln
|
||||
{{{0x00, 0x26, 0xb4, 0, 0, 0}}, 3, INTEROP_DISABLE_ROLE_SWITCH}, |
||||
|
||||
// Toyota Prius - 2015
|
||||
{{{0xfc, 0xc2, 0xde, 0, 0, 0}}, 3, INTEROP_DISABLE_ROLE_SWITCH}, |
||||
|
||||
// OBU II Bluetooth dongle
|
||||
{{{0x00, 0x04, 0x3e, 0, 0, 0}}, 3, INTEROP_DISABLE_ROLE_SWITCH}, |
||||
|
||||
// Roman R9020
|
||||
{{{0x00, 0x23, 0x01, 0, 0, 0}}, 3, INTEROP_DISABLE_ROLE_SWITCH}, |
||||
|
||||
// Jabra Storm
|
||||
{{{0x1c, 0x48, 0xf9, 0, 0, 0}}, 3, INTEROP_DISABLE_ROLE_SWITCH}, |
||||
|
||||
// Jeep Uconnect
|
||||
{{{0x00, 0x54, 0xaf, 0, 0, 0}}, 3, INTEROP_DISABLE_ROLE_SWITCH}, |
||||
|
||||
// deepblue2 - cannot change smoothly the volume: b/37834035
|
||||
{{{0x0c, 0xa6, 0x94, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
|
||||
// AirPods 2 - unacceptably loud volume
|
||||
{{{0x94, 0x16, 0x25, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
|
||||
// AirPods 2 - unacceptably loud volume
|
||||
{{{0x9c, 0x64, 0x8b, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
|
||||
// Phonak AG - volume level not change
|
||||
{{{0x00, 0x0f, 0x59, 0, 0, 0}}, 3, INTEROP_DISABLE_ABSOLUTE_VOLUME}, |
||||
|
||||
// for skip name request,
|
||||
// because BR/EDR address and ADV random address are the same
|
||||
{{{0xd4, 0x7a, 0xe2, 0, 0, 0}}, 3, INTEROP_DISABLE_NAME_REQUEST}, |
||||
|
||||
// Audi Carkit
|
||||
{{{0x90, 0x03, 0xb7, 0, 0, 0}}, 3, INTEROP_AVRCP_1_4_ONLY}, |
||||
|
||||
// Lexus Carkit
|
||||
{{{0x64, 0xd4, 0xbd, 0, 0, 0}}, 3, INTEROP_AVRCP_1_4_ONLY}, |
||||
|
||||
// Mazda Carkit
|
||||
{{{0xfc, 0x35, 0xe6, 0, 0, 0}}, 3, INTEROP_AVRCP_1_4_ONLY}, |
||||
|
||||
// Toyota Car Audio
|
||||
{{{0x00, 0x17, 0x53, 0, 0, 0}}, 3, INTEROP_AVRCP_1_4_ONLY}, |
||||
|
||||
// Honda High End Carkit
|
||||
{{{0x9c, 0x8d, 0x7c, 0, 0, 0}}, 3, INTEROP_AVRCP_1_4_ONLY}, |
||||
|
||||
// Honda Civic Carkit
|
||||
{{{0x0c, 0xd9, 0xc1, 0, 0, 0}}, 3, INTEROP_AVRCP_1_4_ONLY}, |
||||
|
||||
// BMW Carkit
|
||||
{{{0x9c, 0xdf, 0x03, 0, 0, 0}}, 3, INTEROP_AVRCP_1_4_ONLY}, |
||||
|
||||
// KDDI Carkit
|
||||
{{{0x44, 0xea, 0xd8, 0, 0, 0}}, 3, INTEROP_DISABLE_SNIFF}, |
||||
|
||||
// Phonak
|
||||
{{{0x70, 0x66, 0x1b, 0, 0, 0}}, 3, INTEROP_DISABLE_SNIFF}, |
||||
|
||||
// Toyota Camry 2018 Carkit HFP AT+BIND missing
|
||||
{{{0x94, 0xb2, 0xcc, 0x30, 0, 0}}, 4, INTEROP_SLC_SKIP_BIND_COMMAND}, |
||||
}; |
||||
|
||||
typedef struct { |
||||
char name[20]; |
||||
size_t length; |
||||
interop_feature_t feature; |
||||
} interop_name_entry_t; |
||||
|
||||
static const interop_name_entry_t interop_name_database[] = { |
||||
// Carried over from auto_pair_devlist.conf migration
|
||||
{"Audi", 4, INTEROP_DISABLE_AUTO_PAIRING}, |
||||
{"BMW", 3, INTEROP_DISABLE_AUTO_PAIRING}, |
||||
{"Parrot", 6, INTEROP_DISABLE_AUTO_PAIRING}, |
||||
{"Car", 3, INTEROP_DISABLE_AUTO_PAIRING}, |
||||
|
||||
// Nissan Quest rejects pairing after "0000"
|
||||
{"NISSAN", 6, INTEROP_DISABLE_AUTO_PAIRING}, |
||||
|
||||
// Subaru car kits ("CAR M_MEDIA")
|
||||
{"CAR", 3, INTEROP_DISABLE_AUTO_PAIRING}, |
||||
|
||||
// Pixel C Keyboard doesn't respond to service changed indications.
|
||||
{"Pixel C Keyboard", 16, INTEROP_GATTC_NO_SERVICE_CHANGED_IND}, |
||||
|
||||
// Kenwood KMM-BT518HD - no audio when A2DP codec sample rate is changed
|
||||
{"KMM-BT51*HD", 11, INTEROP_DISABLE_AVDTP_RECONFIGURE}, |
||||
|
||||
// Nintendo Switch Pro Controller and Joy Con - do not set sniff interval
|
||||
// dynamically. They require custom HID report command to change mode.
|
||||
{"Pro Controller", 14, INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL}, |
||||
{"Joy-Con", 7, INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL}, |
||||
}; |
@ -1,853 +0,0 @@ |
||||
/******************************************************************************
|
||||
* |
||||
* Copyright 2014 Google, Inc. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at: |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
******************************************************************************/ |
||||
|
||||
#define LOG_TAG "bt_controller" |
||||
|
||||
#include "device/include/controller.h" |
||||
|
||||
#include <base/logging.h> |
||||
|
||||
#include "bt_types.h" |
||||
#include "btcore/include/event_mask.h" |
||||
#include "btcore/include/module.h" |
||||
#include "btcore/include/version.h" |
||||
#include "hcimsgs.h" |
||||
#include "main/shim/controller.h" |
||||
#include "main/shim/shim.h" |
||||
#include "osi/include/future.h" |
||||
#include "osi/include/properties.h" |
||||
#include "stack/include/btm_ble_api.h" |
||||
|
||||
const bt_event_mask_t BLE_EVENT_MASK = {{0x00, 0x00, 0x00, 0x00, 0x7F, 0x02, |
||||
#if (BLE_PRIVACY_SPT == TRUE) |
||||
0xFE, |
||||
#else |
||||
/* Disable "LE Enhanced Connection
|
||||
Complete" when privacy is off */ |
||||
0xFC, |
||||
#endif |
||||
0x7f}}; |
||||
|
||||
const bt_event_mask_t CLASSIC_EVENT_MASK = {HCI_DUMO_EVENT_MASK_EXT}; |
||||
|
||||
// TODO(zachoverflow): factor out into common module
|
||||
const uint8_t SCO_HOST_BUFFER_SIZE = 0xff; |
||||
|
||||
#define HCI_SUPPORTED_COMMANDS_ARRAY_SIZE 64 |
||||
#define MAX_FEATURES_CLASSIC_PAGE_COUNT 3 |
||||
#define BLE_SUPPORTED_STATES_SIZE 8 |
||||
#define BLE_SUPPORTED_FEATURES_SIZE 8 |
||||
#define MAX_LOCAL_SUPPORTED_CODECS_SIZE 8 |
||||
#define LL_FEATURE_BIT_ISO_HOST_SUPPORT 32 |
||||
|
||||
static const hci_t* local_hci; |
||||
static const hci_packet_factory_t* packet_factory; |
||||
static const hci_packet_parser_t* packet_parser; |
||||
|
||||
static RawAddress address; |
||||
static bt_version_t bt_version; |
||||
|
||||
static uint8_t supported_commands[HCI_SUPPORTED_COMMANDS_ARRAY_SIZE]; |
||||
static bt_device_features_t features_classic[MAX_FEATURES_CLASSIC_PAGE_COUNT]; |
||||
static uint8_t last_features_classic_page_index; |
||||
|
||||
static uint16_t acl_data_size_classic; |
||||
static uint16_t acl_data_size_ble; |
||||
static uint16_t iso_data_size; |
||||
|
||||
static uint16_t acl_buffer_count_classic; |
||||
static uint8_t acl_buffer_count_ble; |
||||
static uint8_t iso_buffer_count; |
||||
|
||||
static uint8_t ble_acceptlist_size; |
||||
static uint8_t ble_resolving_list_max_size; |
||||
static uint8_t ble_supported_states[BLE_SUPPORTED_STATES_SIZE]; |
||||
static bt_device_features_t features_ble; |
||||
static uint16_t ble_suggested_default_data_length; |
||||
static uint16_t ble_supported_max_tx_octets; |
||||
static uint16_t ble_supported_max_tx_time; |
||||
static uint16_t ble_supported_max_rx_octets; |
||||
static uint16_t ble_supported_max_rx_time; |
||||
|
||||
static uint16_t ble_maxium_advertising_data_length; |
||||
static uint8_t ble_number_of_supported_advertising_sets; |
||||
static uint8_t ble_periodic_advertiser_list_size; |
||||
static uint8_t local_supported_codecs[MAX_LOCAL_SUPPORTED_CODECS_SIZE]; |
||||
static uint8_t number_of_local_supported_codecs = 0; |
||||
|
||||
static bool readable; |
||||
static bool ble_supported; |
||||
static bool iso_supported; |
||||
static bool simple_pairing_supported; |
||||
static bool secure_connections_supported; |
||||
|
||||
#define AWAIT_COMMAND(command) \ |
||||
static_cast<BT_HDR*>( \
|
||||
future_await(local_hci->transmit_command_futured(command))) |
||||
|
||||
// Module lifecycle functions
|
||||
|
||||
static future_t* start_up(void) { |
||||
BT_HDR* response; |
||||
|
||||
// Send the initial reset command
|
||||
response = AWAIT_COMMAND(packet_factory->make_reset()); |
||||
packet_parser->parse_generic_command_complete(response); |
||||
|
||||
// Request the classic buffer size next
|
||||
response = AWAIT_COMMAND(packet_factory->make_read_buffer_size()); |
||||
packet_parser->parse_read_buffer_size_response( |
||||
response, &acl_data_size_classic, &acl_buffer_count_classic); |
||||
|
||||
// Tell the controller about our buffer sizes and buffer counts next
|
||||
// TODO(zachoverflow): factor this out. eww l2cap contamination. And why just
|
||||
// a hardcoded 10?
|
||||
response = AWAIT_COMMAND(packet_factory->make_host_buffer_size( |
||||
L2CAP_MTU_SIZE, SCO_HOST_BUFFER_SIZE, L2CAP_HOST_FC_ACL_BUFS, 10)); |
||||
|
||||
packet_parser->parse_generic_command_complete(response); |
||||
|
||||
// Read the local version info off the controller next, including
|
||||
// information such as manufacturer and supported HCI version
|
||||
response = AWAIT_COMMAND(packet_factory->make_read_local_version_info()); |
||||
packet_parser->parse_read_local_version_info_response(response, &bt_version); |
||||
|
||||
// Read the bluetooth address off the controller next
|
||||
response = AWAIT_COMMAND(packet_factory->make_read_bd_addr()); |
||||
packet_parser->parse_read_bd_addr_response(response, &address); |
||||
|
||||
// Request the controller's supported commands next
|
||||
response = |
||||
AWAIT_COMMAND(packet_factory->make_read_local_supported_commands()); |
||||
packet_parser->parse_read_local_supported_commands_response( |
||||
response, supported_commands, HCI_SUPPORTED_COMMANDS_ARRAY_SIZE); |
||||
|
||||
// Read page 0 of the controller features next
|
||||
uint8_t page_number = 0; |
||||
response = AWAIT_COMMAND( |
||||
packet_factory->make_read_local_extended_features(page_number)); |
||||
packet_parser->parse_read_local_extended_features_response( |
||||
response, &page_number, &last_features_classic_page_index, |
||||
features_classic, MAX_FEATURES_CLASSIC_PAGE_COUNT); |
||||
|
||||
CHECK(page_number == 0); |
||||
page_number++; |
||||
|
||||
// Inform the controller what page 0 features we support, based on what
|
||||
// it told us it supports. We need to do this first before we request the
|
||||
// next page, because the controller's response for page 1 may be
|
||||
// dependent on what we configure from page 0
|
||||
simple_pairing_supported = |
||||
HCI_SIMPLE_PAIRING_SUPPORTED(features_classic[0].as_array); |
||||
if (simple_pairing_supported) { |
||||
response = AWAIT_COMMAND( |
||||
packet_factory->make_write_simple_pairing_mode(HCI_SP_MODE_ENABLED)); |
||||
packet_parser->parse_generic_command_complete(response); |
||||
} |
||||
|
||||
if (HCI_LE_SPT_SUPPORTED(features_classic[0].as_array)) { |
||||
uint8_t simultaneous_le_host = |
||||
HCI_SIMUL_LE_BREDR_SUPPORTED(features_classic[0].as_array) |
||||
? BTM_BLE_SIMULTANEOUS_HOST |
||||
: 0; |
||||
response = AWAIT_COMMAND(packet_factory->make_ble_write_host_support( |
||||
BTM_BLE_HOST_SUPPORT, simultaneous_le_host)); |
||||
|
||||
packet_parser->parse_generic_command_complete(response); |
||||
|
||||
// If we modified the BT_HOST_SUPPORT, we will need ext. feat. page 1
|
||||
if (last_features_classic_page_index < 1) |
||||
last_features_classic_page_index = 1; |
||||
} |
||||
|
||||
// Done telling the controller about what page 0 features we support
|
||||
// Request the remaining feature pages
|
||||
while (page_number <= last_features_classic_page_index && |
||||
page_number < MAX_FEATURES_CLASSIC_PAGE_COUNT) { |
||||
response = AWAIT_COMMAND( |
||||
packet_factory->make_read_local_extended_features(page_number)); |
||||
packet_parser->parse_read_local_extended_features_response( |
||||
response, &page_number, &last_features_classic_page_index, |
||||
features_classic, MAX_FEATURES_CLASSIC_PAGE_COUNT); |
||||
|
||||
page_number++; |
||||
} |
||||
|
||||
#if (SC_MODE_INCLUDED == TRUE) |
||||
secure_connections_supported = |
||||
HCI_SC_CTRLR_SUPPORTED(features_classic[2].as_array); |
||||
if (secure_connections_supported) { |
||||
response = AWAIT_COMMAND( |
||||
packet_factory->make_write_secure_connections_host_support( |
||||
HCI_SC_MODE_ENABLED)); |
||||
packet_parser->parse_generic_command_complete(response); |
||||
} |
||||
#endif |
||||
|
||||
ble_supported = last_features_classic_page_index >= 1 && |
||||
HCI_LE_HOST_SUPPORTED(features_classic[1].as_array); |
||||
if (ble_supported) { |
||||
// Request the ble acceptlist size next
|
||||
response = AWAIT_COMMAND(packet_factory->make_ble_read_acceptlist_size()); |
||||
packet_parser->parse_ble_read_acceptlist_size_response( |
||||
response, &ble_acceptlist_size); |
||||
|
||||
// Request the ble supported features next
|
||||
response = |
||||
AWAIT_COMMAND(packet_factory->make_ble_read_local_supported_features()); |
||||
packet_parser->parse_ble_read_local_supported_features_response( |
||||
response, &features_ble); |
||||
|
||||
iso_supported = HCI_LE_CIS_CENTRAL(features_ble.as_array) || |
||||
HCI_LE_CIS_PERIPHERAL(features_ble.as_array) || |
||||
HCI_LE_ISO_BROADCASTER(features_ble.as_array); |
||||
|
||||
if (iso_supported) { |
||||
// Request the ble buffer size next
|
||||
response = AWAIT_COMMAND(packet_factory->make_ble_read_buffer_size_v2()); |
||||
packet_parser->parse_ble_read_buffer_size_v2_response( |
||||
response, &acl_data_size_ble, &acl_buffer_count_ble, &iso_data_size, |
||||
&iso_buffer_count); |
||||
|
||||
} else { |
||||
// Request the ble buffer size next
|
||||
response = AWAIT_COMMAND(packet_factory->make_ble_read_buffer_size()); |
||||
packet_parser->parse_ble_read_buffer_size_response( |
||||
response, &acl_data_size_ble, &acl_buffer_count_ble); |
||||
} |
||||
|
||||
// Response of 0 indicates ble has the same buffer size as classic
|
||||
if (acl_data_size_ble == 0) acl_data_size_ble = acl_data_size_classic; |
||||
|
||||
// Request the ble supported states next
|
||||
response = AWAIT_COMMAND(packet_factory->make_ble_read_supported_states()); |
||||
packet_parser->parse_ble_read_supported_states_response( |
||||
response, ble_supported_states, sizeof(ble_supported_states)); |
||||
|
||||
if (HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array)) { |
||||
response = |
||||
AWAIT_COMMAND(packet_factory->make_ble_read_resolving_list_size()); |
||||
packet_parser->parse_ble_read_resolving_list_size_response( |
||||
response, &ble_resolving_list_max_size); |
||||
} |
||||
|
||||
if (HCI_LE_DATA_LEN_EXT_SUPPORTED(features_ble.as_array)) { |
||||
response = |
||||
AWAIT_COMMAND(packet_factory->make_ble_read_maximum_data_length()); |
||||
packet_parser->parse_ble_read_maximum_data_length_response( |
||||
response, &ble_supported_max_tx_octets, &ble_supported_max_tx_time, |
||||
&ble_supported_max_rx_octets, &ble_supported_max_rx_time); |
||||
|
||||
response = AWAIT_COMMAND( |
||||
packet_factory->make_ble_read_suggested_default_data_length()); |
||||
packet_parser->parse_ble_read_suggested_default_data_length_response( |
||||
response, &ble_suggested_default_data_length); |
||||
} |
||||
|
||||
if (HCI_LE_EXTENDED_ADVERTISING_SUPPORTED(features_ble.as_array)) { |
||||
response = AWAIT_COMMAND( |
||||
packet_factory->make_ble_read_maximum_advertising_data_length()); |
||||
packet_parser->parse_ble_read_maximum_advertising_data_length( |
||||
response, &ble_maxium_advertising_data_length); |
||||
|
||||
response = AWAIT_COMMAND( |
||||
packet_factory->make_ble_read_number_of_supported_advertising_sets()); |
||||
packet_parser->parse_ble_read_number_of_supported_advertising_sets( |
||||
response, &ble_number_of_supported_advertising_sets); |
||||
} else { |
||||
/* If LE Excended Advertising is not supported, use the default value */ |
||||
ble_maxium_advertising_data_length = 31; |
||||
} |
||||
|
||||
if (HCI_LE_PERIODIC_ADVERTISING_SUPPORTED(features_ble.as_array)) { |
||||
response = AWAIT_COMMAND( |
||||
packet_factory->make_ble_read_periodic_advertiser_list_size()); |
||||
|
||||
packet_parser->parse_ble_read_size_of_advertiser_list( |
||||
response, &ble_periodic_advertiser_list_size); |
||||
} |
||||
|
||||
// Set the ble event mask next
|
||||
response = |
||||
AWAIT_COMMAND(packet_factory->make_ble_set_event_mask(&BLE_EVENT_MASK)); |
||||
packet_parser->parse_generic_command_complete(response); |
||||
|
||||
if (HCI_LE_SET_HOST_FEATURE_SUPPORTED(supported_commands)) { |
||||
response = AWAIT_COMMAND(packet_factory->make_ble_set_host_features( |
||||
LL_FEATURE_BIT_ISO_HOST_SUPPORT, 0x01)); |
||||
packet_parser->parse_generic_command_complete(response); |
||||
} |
||||
} |
||||
|
||||
if (simple_pairing_supported) { |
||||
response = |
||||
AWAIT_COMMAND(packet_factory->make_set_event_mask(&CLASSIC_EVENT_MASK)); |
||||
packet_parser->parse_generic_command_complete(response); |
||||
} |
||||
|
||||
// read local supported codecs
|
||||
if (HCI_READ_LOCAL_CODECS_SUPPORTED(supported_commands)) { |
||||
response = |
||||
AWAIT_COMMAND(packet_factory->make_read_local_supported_codecs()); |
||||
packet_parser->parse_read_local_supported_codecs_response( |
||||
response, &number_of_local_supported_codecs, local_supported_codecs); |
||||
} |
||||
|
||||
if (!HCI_READ_ENCR_KEY_SIZE_SUPPORTED(supported_commands)) { |
||||
LOG(FATAL) << " Controller must support Read Encryption Key Size command"; |
||||
} |
||||
|
||||
readable = true; |
||||
return future_new_immediate(FUTURE_SUCCESS); |
||||
} |
||||
|
||||
static future_t* shut_down(void) { |
||||
readable = false; |
||||
return future_new_immediate(FUTURE_SUCCESS); |
||||
} |
||||
|
||||
EXPORT_SYMBOL extern const module_t controller_module = { |
||||
.name = CONTROLLER_MODULE, |
||||
.init = NULL, |
||||
.start_up = start_up, |
||||
.shut_down = shut_down, |
||||
.clean_up = NULL, |
||||
.dependencies = {HCI_MODULE, NULL}}; |
||||
|
||||
// Interface functions
|
||||
|
||||
static bool get_is_ready(void) { return readable; } |
||||
|
||||
static const RawAddress* get_address(void) { |
||||
CHECK(readable); |
||||
return &address; |
||||
} |
||||
|
||||
static const bt_version_t* get_bt_version(void) { |
||||
CHECK(readable); |
||||
return &bt_version; |
||||
} |
||||
|
||||
static uint8_t* get_local_supported_codecs(uint8_t* number_of_codecs) { |
||||
CHECK(readable); |
||||
if (number_of_local_supported_codecs) { |
||||
*number_of_codecs = number_of_local_supported_codecs; |
||||
return local_supported_codecs; |
||||
} |
||||
return NULL; |
||||
} |
||||
|
||||
static const uint8_t* get_ble_supported_states(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return ble_supported_states; |
||||
} |
||||
|
||||
static bool supports_simple_pairing(void) { |
||||
CHECK(readable); |
||||
return simple_pairing_supported; |
||||
} |
||||
|
||||
static bool supports_secure_connections(void) { |
||||
CHECK(readable); |
||||
return secure_connections_supported; |
||||
} |
||||
|
||||
static bool supports_simultaneous_le_bredr(void) { |
||||
CHECK(readable); |
||||
return HCI_SIMUL_LE_BREDR_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_reading_remote_extended_features(void) { |
||||
CHECK(readable); |
||||
return HCI_READ_REMOTE_EXT_FEATURES_SUPPORTED(supported_commands); |
||||
} |
||||
|
||||
static bool supports_interlaced_inquiry_scan(void) { |
||||
CHECK(readable); |
||||
return HCI_LMP_INTERLACED_INQ_SCAN_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_rssi_with_inquiry_results(void) { |
||||
CHECK(readable); |
||||
return HCI_LMP_INQ_RSSI_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_extended_inquiry_response(void) { |
||||
CHECK(readable); |
||||
return HCI_EXT_INQ_RSP_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_central_peripheral_role_switch(void) { |
||||
CHECK(readable); |
||||
return HCI_SWITCH_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_enhanced_setup_synchronous_connection(void) { |
||||
assert(readable); |
||||
return HCI_ENH_SETUP_SYNCH_CONN_SUPPORTED(supported_commands); |
||||
} |
||||
|
||||
static bool supports_enhanced_accept_synchronous_connection(void) { |
||||
assert(readable); |
||||
return HCI_ENH_ACCEPT_SYNCH_CONN_SUPPORTED(supported_commands); |
||||
} |
||||
|
||||
static bool supports_3_slot_packets(void) { |
||||
CHECK(readable); |
||||
return HCI_3_SLOT_PACKETS_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_5_slot_packets(void) { |
||||
CHECK(readable); |
||||
return HCI_5_SLOT_PACKETS_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_classic_2m_phy(void) { |
||||
CHECK(readable); |
||||
return HCI_EDR_ACL_2MPS_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_classic_3m_phy(void) { |
||||
CHECK(readable); |
||||
return HCI_EDR_ACL_3MPS_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_3_slot_edr_packets(void) { |
||||
CHECK(readable); |
||||
return HCI_3_SLOT_EDR_ACL_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_5_slot_edr_packets(void) { |
||||
CHECK(readable); |
||||
return HCI_5_SLOT_EDR_ACL_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_sco(void) { |
||||
CHECK(readable); |
||||
return HCI_SCO_LINK_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_hv2_packets(void) { |
||||
CHECK(readable); |
||||
return HCI_HV2_PACKETS_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_hv3_packets(void) { |
||||
CHECK(readable); |
||||
return HCI_HV3_PACKETS_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_ev3_packets(void) { |
||||
CHECK(readable); |
||||
return HCI_ESCO_EV3_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_ev4_packets(void) { |
||||
CHECK(readable); |
||||
return HCI_ESCO_EV4_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_ev5_packets(void) { |
||||
CHECK(readable); |
||||
return HCI_ESCO_EV5_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_esco_2m_phy(void) { |
||||
CHECK(readable); |
||||
return HCI_EDR_ESCO_2MPS_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_esco_3m_phy(void) { |
||||
CHECK(readable); |
||||
return HCI_EDR_ESCO_3MPS_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_3_slot_esco_edr_packets(void) { |
||||
CHECK(readable); |
||||
return HCI_3_SLOT_EDR_ESCO_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_role_switch(void) { |
||||
CHECK(readable); |
||||
return HCI_SWITCH_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_hold_mode(void) { |
||||
CHECK(readable); |
||||
return HCI_HOLD_MODE_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_sniff_mode(void) { |
||||
CHECK(readable); |
||||
return HCI_SNIFF_MODE_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_park_mode(void) { |
||||
CHECK(readable); |
||||
return HCI_PARK_MODE_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_non_flushable_pb(void) { |
||||
CHECK(readable); |
||||
return HCI_NON_FLUSHABLE_PB_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_sniff_subrating(void) { |
||||
CHECK(readable); |
||||
return HCI_SNIFF_SUB_RATE_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_encryption_pause(void) { |
||||
CHECK(readable); |
||||
return HCI_ATOMIC_ENCRYPT_SUPPORTED(features_classic[0].as_array); |
||||
} |
||||
|
||||
static bool supports_ble(void) { |
||||
CHECK(readable); |
||||
return ble_supported; |
||||
} |
||||
|
||||
static bool supports_ble_privacy(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array); |
||||
} |
||||
|
||||
static bool supports_ble_set_privacy_mode() { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_ENHANCED_PRIVACY_SUPPORTED(features_ble.as_array) && |
||||
HCI_LE_SET_PRIVACY_MODE_SUPPORTED(supported_commands); |
||||
} |
||||
|
||||
static bool supports_ble_packet_extension(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_DATA_LEN_EXT_SUPPORTED(features_ble.as_array); |
||||
} |
||||
|
||||
static bool supports_ble_connection_parameters_request(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_CONN_PARAM_REQ_SUPPORTED(features_ble.as_array); |
||||
} |
||||
|
||||
static bool supports_ble_2m_phy(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_2M_PHY_SUPPORTED(features_ble.as_array); |
||||
} |
||||
|
||||
static bool supports_ble_coded_phy(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_CODED_PHY_SUPPORTED(features_ble.as_array); |
||||
} |
||||
|
||||
static bool supports_ble_extended_advertising(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_EXTENDED_ADVERTISING_SUPPORTED(features_ble.as_array); |
||||
} |
||||
|
||||
static bool supports_ble_periodic_advertising(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_PERIODIC_ADVERTISING_SUPPORTED(features_ble.as_array); |
||||
} |
||||
|
||||
static bool supports_ble_peripheral_initiated_feature_exchange(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_PERIPHERAL_INIT_FEAT_EXC_SUPPORTED(features_ble.as_array); |
||||
} |
||||
|
||||
static bool supports_ble_connection_parameter_request(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_CONN_PARAM_REQ_SUPPORTED(features_ble.as_array); |
||||
} |
||||
|
||||
static bool supports_ble_periodic_advertising_sync_transfer_sender(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER_SENDER( |
||||
features_ble.as_array); |
||||
} |
||||
|
||||
static bool supports_ble_periodic_advertising_sync_transfer_recipient(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER_RECIPIENT( |
||||
features_ble.as_array); |
||||
} |
||||
|
||||
static bool supports_ble_connected_isochronous_stream_central(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_CIS_CENTRAL(features_ble.as_array); |
||||
} |
||||
|
||||
static bool supports_ble_connected_isochronous_stream_peripheral(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_CIS_PERIPHERAL(features_ble.as_array); |
||||
} |
||||
|
||||
static bool supports_ble_isochronous_broadcaster(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_ISO_BROADCASTER(features_ble.as_array); |
||||
} |
||||
|
||||
static bool supports_ble_synchronized_receiver(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return HCI_LE_SYNCHRONIZED_RECEIVER(features_ble.as_array); |
||||
} |
||||
|
||||
static uint16_t get_acl_data_size_classic(void) { |
||||
CHECK(readable); |
||||
return acl_data_size_classic; |
||||
} |
||||
|
||||
static uint16_t get_acl_data_size_ble(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return acl_data_size_ble; |
||||
} |
||||
|
||||
static uint16_t get_iso_data_size(void) { |
||||
CHECK(readable); |
||||
return iso_data_size; |
||||
} |
||||
|
||||
static uint16_t get_acl_packet_size_classic(void) { |
||||
CHECK(readable); |
||||
return acl_data_size_classic + HCI_DATA_PREAMBLE_SIZE; |
||||
} |
||||
|
||||
static uint16_t get_acl_packet_size_ble(void) { |
||||
CHECK(readable); |
||||
return acl_data_size_ble + HCI_DATA_PREAMBLE_SIZE; |
||||
} |
||||
|
||||
static uint16_t get_iso_packet_size(void) { |
||||
CHECK(readable); |
||||
return iso_data_size + HCI_DATA_PREAMBLE_SIZE; |
||||
} |
||||
|
||||
static uint16_t get_ble_suggested_default_data_length(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return ble_suggested_default_data_length; |
||||
} |
||||
|
||||
static uint16_t get_ble_maximum_tx_data_length(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return ble_supported_max_tx_octets; |
||||
} |
||||
|
||||
static uint16_t get_ble_maximum_tx_time(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return ble_supported_max_tx_time; |
||||
} |
||||
|
||||
static uint16_t get_ble_maxium_advertising_data_length(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return ble_maxium_advertising_data_length; |
||||
} |
||||
|
||||
static uint8_t get_ble_number_of_supported_advertising_sets(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return ble_number_of_supported_advertising_sets; |
||||
} |
||||
|
||||
static uint8_t get_ble_periodic_advertiser_list_size(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return ble_periodic_advertiser_list_size; |
||||
} |
||||
|
||||
static uint16_t get_acl_buffer_count_classic(void) { |
||||
CHECK(readable); |
||||
return acl_buffer_count_classic; |
||||
} |
||||
|
||||
static uint8_t get_acl_buffer_count_ble(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return acl_buffer_count_ble; |
||||
} |
||||
|
||||
static uint8_t get_iso_buffer_count(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return iso_buffer_count; |
||||
} |
||||
|
||||
static uint8_t get_ble_acceptlist_size(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return ble_acceptlist_size; |
||||
} |
||||
|
||||
static uint8_t get_ble_resolving_list_max_size(void) { |
||||
CHECK(readable); |
||||
CHECK(ble_supported); |
||||
return ble_resolving_list_max_size; |
||||
} |
||||
|
||||
static void set_ble_resolving_list_max_size(int resolving_list_max_size) { |
||||
// Setting "resolving_list_max_size" to 0 is done during cleanup,
|
||||
// hence we ignore the "readable" flag already set to false during shutdown.
|
||||
if (resolving_list_max_size != 0) { |
||||
CHECK(readable); |
||||
} |
||||
CHECK(ble_supported); |
||||
ble_resolving_list_max_size = resolving_list_max_size; |
||||
} |
||||
|
||||
static uint8_t get_le_all_initiating_phys() { |
||||
uint8_t phy = PHY_LE_1M; |
||||
// TODO(jpawlowski): uncomment after next FW udpate
|
||||
// if (supports_ble_2m_phy()) phy |= PHY_LE_2M;
|
||||
// if (supports_ble_coded_phy()) phy |= PHY_LE_CODED;
|
||||
return phy; |
||||
} |
||||
|
||||
static const controller_t interface = { |
||||
get_is_ready, |
||||
|
||||
get_address, |
||||
get_bt_version, |
||||
|
||||
get_ble_supported_states, |
||||
|
||||
supports_simple_pairing, |
||||
supports_secure_connections, |
||||
supports_simultaneous_le_bredr, |
||||
supports_reading_remote_extended_features, |
||||
supports_interlaced_inquiry_scan, |
||||
supports_rssi_with_inquiry_results, |
||||
supports_extended_inquiry_response, |
||||
supports_central_peripheral_role_switch, |
||||
supports_enhanced_setup_synchronous_connection, |
||||
supports_enhanced_accept_synchronous_connection, |
||||
supports_3_slot_packets, |
||||
supports_5_slot_packets, |
||||
supports_classic_2m_phy, |
||||
supports_classic_3m_phy, |
||||
supports_3_slot_edr_packets, |
||||
supports_5_slot_edr_packets, |
||||
supports_sco, |
||||
supports_hv2_packets, |
||||
supports_hv3_packets, |
||||
supports_ev3_packets, |
||||
supports_ev4_packets, |
||||
supports_ev5_packets, |
||||
supports_esco_2m_phy, |
||||
supports_esco_3m_phy, |
||||
supports_3_slot_esco_edr_packets, |
||||
supports_role_switch, |
||||
supports_hold_mode, |
||||
supports_sniff_mode, |
||||
supports_park_mode, |
||||
supports_non_flushable_pb, |
||||
supports_sniff_subrating, |
||||
supports_encryption_pause, |
||||
|
||||
supports_ble, |
||||
supports_ble_packet_extension, |
||||
supports_ble_connection_parameters_request, |
||||
supports_ble_privacy, |
||||
supports_ble_set_privacy_mode, |
||||
supports_ble_2m_phy, |
||||
supports_ble_coded_phy, |
||||
supports_ble_extended_advertising, |
||||
supports_ble_periodic_advertising, |
||||
supports_ble_peripheral_initiated_feature_exchange, |
||||
supports_ble_connection_parameter_request, |
||||
supports_ble_periodic_advertising_sync_transfer_sender, |
||||
supports_ble_periodic_advertising_sync_transfer_recipient, |
||||
supports_ble_connected_isochronous_stream_central, |
||||
supports_ble_connected_isochronous_stream_peripheral, |
||||
supports_ble_isochronous_broadcaster, |
||||
supports_ble_synchronized_receiver, |
||||
|
||||
get_acl_data_size_classic, |
||||
get_acl_data_size_ble, |
||||
get_iso_data_size, |
||||
|
||||
get_acl_packet_size_classic, |
||||
get_acl_packet_size_ble, |
||||
get_iso_packet_size, |
||||
|
||||
get_ble_suggested_default_data_length, |
||||
get_ble_maximum_tx_data_length, |
||||
get_ble_maximum_tx_time, |
||||
get_ble_maxium_advertising_data_length, |
||||
get_ble_number_of_supported_advertising_sets, |
||||
get_ble_periodic_advertiser_list_size, |
||||
|
||||
get_acl_buffer_count_classic, |
||||
get_acl_buffer_count_ble, |
||||
get_iso_buffer_count, |
||||
|
||||
get_ble_acceptlist_size, |
||||
|
||||
get_ble_resolving_list_max_size, |
||||
set_ble_resolving_list_max_size, |
||||
get_local_supported_codecs, |
||||
get_le_all_initiating_phys}; |
||||
|
||||
static const controller_t* controller_get_interface_legacy() { |
||||
static bool loaded = false; |
||||
if (!loaded) { |
||||
loaded = true; |
||||
|
||||
local_hci = hci_layer_get_interface(); |
||||
packet_factory = hci_packet_factory_get_interface(); |
||||
packet_parser = hci_packet_parser_get_interface(); |
||||
} |
||||
|
||||
return &interface; |
||||
} |
||||
|
||||
const controller_t* controller_get_interface() { |
||||
if (bluetooth::shim::is_gd_controller_enabled()) { |
||||
return bluetooth::shim::controller_get_interface(); |
||||
} else { |
||||
return controller_get_interface_legacy(); |
||||
} |
||||
} |
||||
|
||||
const controller_t* controller_get_test_interface( |
||||
const hci_t* hci_interface, |
||||
const hci_packet_factory_t* packet_factory_interface, |
||||
const hci_packet_parser_t* packet_parser_interface) { |
||||
local_hci = hci_interface; |
||||
packet_factory = packet_factory_interface; |
||||
packet_parser = packet_parser_interface; |
||||
return &interface; |
||||
} |
@ -1,217 +0,0 @@ |
||||
/******************************************************************************
|
||||
* |
||||
* Copyright 2015 Broadcom Corporation |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at: |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
******************************************************************************/ |
||||
|
||||
#include "base/logging.h" |
||||
|
||||
#include "device/include/esco_parameters.h" |
||||
|
||||
static const enh_esco_params_t default_esco_parameters[ESCO_NUM_CODECS] = { |
||||
// CVSD D1
|
||||
{ |
||||
.transmit_bandwidth = TXRX_64KBITS_RATE, |
||||
.receive_bandwidth = TXRX_64KBITS_RATE, |
||||
.transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.transmit_codec_frame_size = 60, |
||||
.receive_codec_frame_size = 60, |
||||
.input_bandwidth = INPUT_OUTPUT_64K_RATE, |
||||
.output_bandwidth = INPUT_OUTPUT_64K_RATE, |
||||
.input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.input_coded_data_size = 16, |
||||
.output_coded_data_size = 16, |
||||
.input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP, |
||||
.output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP, |
||||
.input_pcm_payload_msb_position = 0, |
||||
.output_pcm_payload_msb_position = 0, |
||||
.input_data_path = ESCO_DATA_PATH_PCM, |
||||
.output_data_path = ESCO_DATA_PATH_PCM, |
||||
.input_transport_unit_size = 16, |
||||
.output_transport_unit_size = 16, |
||||
.max_latency_ms = 0xFFFF, // Don't care
|
||||
.packet_types = (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 | |
||||
ESCO_PKT_TYPES_MASK_HV3), |
||||
.retransmission_effort = ESCO_RETRANSMISSION_OFF, |
||||
}, |
||||
// CVSD S3
|
||||
{ |
||||
.transmit_bandwidth = TXRX_64KBITS_RATE, |
||||
.receive_bandwidth = TXRX_64KBITS_RATE, |
||||
.transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.transmit_codec_frame_size = 60, |
||||
.receive_codec_frame_size = 60, |
||||
.input_bandwidth = INPUT_OUTPUT_64K_RATE, |
||||
.output_bandwidth = INPUT_OUTPUT_64K_RATE, |
||||
.input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.input_coded_data_size = 16, |
||||
.output_coded_data_size = 16, |
||||
.input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP, |
||||
.output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP, |
||||
.input_pcm_payload_msb_position = 0, |
||||
.output_pcm_payload_msb_position = 0, |
||||
.input_data_path = ESCO_DATA_PATH_PCM, |
||||
.output_data_path = ESCO_DATA_PATH_PCM, |
||||
.input_transport_unit_size = 16, |
||||
.output_transport_unit_size = 16, |
||||
.max_latency_ms = 10, |
||||
.packet_types = |
||||
(ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 | |
||||
ESCO_PKT_TYPES_MASK_HV3 | ESCO_PKT_TYPES_MASK_EV3 | |
||||
ESCO_PKT_TYPES_MASK_EV4 | ESCO_PKT_TYPES_MASK_EV5 | |
||||
ESCO_PKT_TYPES_MASK_NO_3_EV3 | ESCO_PKT_TYPES_MASK_NO_2_EV5 | |
||||
ESCO_PKT_TYPES_MASK_NO_3_EV5), |
||||
.retransmission_effort = ESCO_RETRANSMISSION_POWER, |
||||
}, |
||||
// CVSD S4
|
||||
{ |
||||
.transmit_bandwidth = TXRX_64KBITS_RATE, |
||||
.receive_bandwidth = TXRX_64KBITS_RATE, |
||||
.transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_CVSD, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.transmit_codec_frame_size = 60, |
||||
.receive_codec_frame_size = 60, |
||||
.input_bandwidth = INPUT_OUTPUT_64K_RATE, |
||||
.output_bandwidth = INPUT_OUTPUT_64K_RATE, |
||||
.input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.input_coded_data_size = 16, |
||||
.output_coded_data_size = 16, |
||||
.input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP, |
||||
.output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP, |
||||
.input_pcm_payload_msb_position = 0, |
||||
.output_pcm_payload_msb_position = 0, |
||||
.input_data_path = ESCO_DATA_PATH_PCM, |
||||
.output_data_path = ESCO_DATA_PATH_PCM, |
||||
.input_transport_unit_size = 16, |
||||
.output_transport_unit_size = 16, |
||||
.max_latency_ms = 12, |
||||
.packet_types = |
||||
(ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 | |
||||
ESCO_PKT_TYPES_MASK_HV3 | ESCO_PKT_TYPES_MASK_EV3 | |
||||
ESCO_PKT_TYPES_MASK_EV4 | ESCO_PKT_TYPES_MASK_EV5 | |
||||
ESCO_PKT_TYPES_MASK_NO_3_EV3 | ESCO_PKT_TYPES_MASK_NO_2_EV5 | |
||||
ESCO_PKT_TYPES_MASK_NO_3_EV5), |
||||
.retransmission_effort = ESCO_RETRANSMISSION_QUALITY, |
||||
}, |
||||
// mSBC T1
|
||||
{ |
||||
.transmit_bandwidth = TXRX_64KBITS_RATE, |
||||
.receive_bandwidth = TXRX_64KBITS_RATE, |
||||
.transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.transmit_codec_frame_size = 60, |
||||
.receive_codec_frame_size = 60, |
||||
.input_bandwidth = INPUT_OUTPUT_128K_RATE, |
||||
.output_bandwidth = INPUT_OUTPUT_128K_RATE, |
||||
.input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.input_coded_data_size = 16, |
||||
.output_coded_data_size = 16, |
||||
.input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP, |
||||
.output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP, |
||||
.input_pcm_payload_msb_position = 0, |
||||
.output_pcm_payload_msb_position = 0, |
||||
.input_data_path = ESCO_DATA_PATH_PCM, |
||||
.output_data_path = ESCO_DATA_PATH_PCM, |
||||
.input_transport_unit_size = 16, |
||||
.output_transport_unit_size = 16, |
||||
.max_latency_ms = 8, |
||||
.packet_types = |
||||
(ESCO_PKT_TYPES_MASK_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV3 | |
||||
ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5 | |
||||
ESCO_PKT_TYPES_MASK_NO_2_EV3), |
||||
.retransmission_effort = ESCO_RETRANSMISSION_QUALITY, |
||||
}, |
||||
// mSBC T2
|
||||
{ |
||||
.transmit_bandwidth = TXRX_64KBITS_RATE, |
||||
.receive_bandwidth = TXRX_64KBITS_RATE, |
||||
.transmit_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.receive_coding_format = {.coding_format = ESCO_CODING_FORMAT_MSBC, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.transmit_codec_frame_size = 60, |
||||
.receive_codec_frame_size = 60, |
||||
.input_bandwidth = INPUT_OUTPUT_128K_RATE, |
||||
.output_bandwidth = INPUT_OUTPUT_128K_RATE, |
||||
.input_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.output_coding_format = {.coding_format = ESCO_CODING_FORMAT_LINEAR, |
||||
.company_id = 0x0000, |
||||
.vendor_specific_codec_id = 0x0000}, |
||||
.input_coded_data_size = 16, |
||||
.output_coded_data_size = 16, |
||||
.input_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP, |
||||
.output_pcm_data_format = ESCO_PCM_DATA_FORMAT_2_COMP, |
||||
.input_pcm_payload_msb_position = 0, |
||||
.output_pcm_payload_msb_position = 0, |
||||
.input_data_path = ESCO_DATA_PATH_PCM, |
||||
.output_data_path = ESCO_DATA_PATH_PCM, |
||||
.input_transport_unit_size = 16, |
||||
.output_transport_unit_size = 16, |
||||
.max_latency_ms = 13, |
||||
.packet_types = |
||||
(ESCO_PKT_TYPES_MASK_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV3 | |
||||
ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5), |
||||
.retransmission_effort = ESCO_RETRANSMISSION_QUALITY, |
||||
}, |
||||
}; |
||||
|
||||
enh_esco_params_t esco_parameters_for_codec(esco_codec_t codec) { |
||||
CHECK(codec >= 0) << "codec index " << (int)codec << "< 0"; |
||||
CHECK(codec < ESCO_NUM_CODECS) << "codec index " << (int)codec << " > " |
||||
<< ESCO_NUM_CODECS; |
||||
return default_esco_parameters[codec]; |
||||
} |
@ -1,188 +0,0 @@ |
||||
/******************************************************************************
|
||||
* |
||||
* Copyright 2015 Google, Inc. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at: |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
******************************************************************************/ |
||||
|
||||
#define LOG_TAG "bt_device_interop" |
||||
|
||||
#include <base/logging.h> |
||||
#include <string.h> // For memcmp |
||||
|
||||
#include "btcore/include/module.h" |
||||
#include "device/include/interop.h" |
||||
#include "device/include/interop_database.h" |
||||
#include "osi/include/allocator.h" |
||||
#include "osi/include/list.h" |
||||
#include "osi/include/log.h" |
||||
|
||||
#define CASE_RETURN_STR(const) \ |
||||
case const: \
|
||||
return #const; |
||||
|
||||
static list_t* interop_list = NULL; |
||||
|
||||
static const char* interop_feature_string_(const interop_feature_t feature); |
||||
static void interop_free_entry_(void* data); |
||||
static void interop_lazy_init_(void); |
||||
static bool interop_match_fixed_(const interop_feature_t feature, |
||||
const RawAddress* addr); |
||||
static bool interop_match_dynamic_(const interop_feature_t feature, |
||||
const RawAddress* addr); |
||||
|
||||
// Interface functions
|
||||
|
||||
bool interop_match_addr(const interop_feature_t feature, |
||||
const RawAddress* addr) { |
||||
CHECK(addr); |
||||
|
||||
if (interop_match_fixed_(feature, addr) || |
||||
interop_match_dynamic_(feature, addr)) { |
||||
LOG_INFO("%s() Device %s is a match for interop workaround %s.", __func__, |
||||
addr->ToString().c_str(), interop_feature_string_(feature)); |
||||
return true; |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
|
||||
bool interop_match_name(const interop_feature_t feature, const char* name) { |
||||
CHECK(name); |
||||
|
||||
const size_t db_size = |
||||
sizeof(interop_name_database) / sizeof(interop_name_entry_t); |
||||
for (size_t i = 0; i != db_size; ++i) { |
||||
if (feature == interop_name_database[i].feature && |
||||
strlen(name) >= interop_name_database[i].length && |
||||
strncmp(name, interop_name_database[i].name, |
||||
interop_name_database[i].length) == 0) { |
||||
LOG_INFO("%s() Device %s is a match for interop workaround %s.", __func__, |
||||
name, interop_feature_string_(feature)); |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
|
||||
void interop_database_add(uint16_t feature, const RawAddress* addr, |
||||
size_t length) { |
||||
CHECK(addr); |
||||
CHECK(length > 0); |
||||
CHECK(length < RawAddress::kLength); |
||||
|
||||
interop_addr_entry_t* entry = static_cast<interop_addr_entry_t*>( |
||||
osi_calloc(sizeof(interop_addr_entry_t))); |
||||
memcpy(&entry->addr, addr, length); |
||||
entry->feature = static_cast<interop_feature_t>(feature); |
||||
entry->length = length; |
||||
|
||||
interop_lazy_init_(); |
||||
list_append(interop_list, entry); |
||||
} |
||||
|
||||
void interop_database_clear() { |
||||
if (interop_list) list_clear(interop_list); |
||||
} |
||||
|
||||
// Module life-cycle functions
|
||||
|
||||
static future_t* interop_clean_up(void) { |
||||
list_free(interop_list); |
||||
interop_list = NULL; |
||||
return future_new_immediate(FUTURE_SUCCESS); |
||||
} |
||||
|
||||
EXPORT_SYMBOL module_t interop_module = { |
||||
.name = INTEROP_MODULE, |
||||
.init = NULL, |
||||
.start_up = NULL, |
||||
.shut_down = NULL, |
||||
.clean_up = interop_clean_up, |
||||
.dependencies = {NULL}, |
||||
}; |
||||
|
||||
// Local functions
|
||||
|
||||
static const char* interop_feature_string_(const interop_feature_t feature) { |
||||
switch (feature) { |
||||
CASE_RETURN_STR(INTEROP_DISABLE_LE_SECURE_CONNECTIONS) |
||||
CASE_RETURN_STR(INTEROP_AUTO_RETRY_PAIRING) |
||||
CASE_RETURN_STR(INTEROP_DISABLE_ABSOLUTE_VOLUME) |
||||
CASE_RETURN_STR(INTEROP_DISABLE_AUTO_PAIRING) |
||||
CASE_RETURN_STR(INTEROP_KEYBOARD_REQUIRES_FIXED_PIN) |
||||
CASE_RETURN_STR(INTEROP_2MBPS_LINK_ONLY) |
||||
CASE_RETURN_STR(INTEROP_HID_PREF_CONN_SUP_TIMEOUT_3S) |
||||
CASE_RETURN_STR(INTEROP_GATTC_NO_SERVICE_CHANGED_IND) |
||||
CASE_RETURN_STR(INTEROP_DISABLE_AVDTP_RECONFIGURE) |
||||
CASE_RETURN_STR(INTEROP_DYNAMIC_ROLE_SWITCH) |
||||
CASE_RETURN_STR(INTEROP_DISABLE_ROLE_SWITCH) |
||||
CASE_RETURN_STR(INTEROP_HID_HOST_LIMIT_SNIFF_INTERVAL) |
||||
CASE_RETURN_STR(INTEROP_DISABLE_NAME_REQUEST) |
||||
CASE_RETURN_STR(INTEROP_AVRCP_1_4_ONLY) |
||||
CASE_RETURN_STR(INTEROP_DISABLE_SNIFF) |
||||
CASE_RETURN_STR(INTEROP_DISABLE_AVDTP_SUSPEND) |
||||
CASE_RETURN_STR(INTEROP_SLC_SKIP_BIND_COMMAND); |
||||
} |
||||
|
||||
return "UNKNOWN"; |
||||
} |
||||
|
||||
static void interop_free_entry_(void* data) { |
||||
interop_addr_entry_t* entry = (interop_addr_entry_t*)data; |
||||
osi_free(entry); |
||||
} |
||||
|
||||
static void interop_lazy_init_(void) { |
||||
if (interop_list == NULL) { |
||||
interop_list = list_new(interop_free_entry_); |
||||
} |
||||
} |
||||
|
||||
static bool interop_match_dynamic_(const interop_feature_t feature, |
||||
const RawAddress* addr) { |
||||
if (interop_list == NULL || list_length(interop_list) == 0) return false; |
||||
|
||||
const list_node_t* node = list_begin(interop_list); |
||||
while (node != list_end(interop_list)) { |
||||
interop_addr_entry_t* entry = |
||||
static_cast<interop_addr_entry_t*>(list_node(node)); |
||||
CHECK(entry); |
||||
|
||||
if (feature == entry->feature && |
||||
memcmp(addr, &entry->addr, entry->length) == 0) |
||||
return true; |
||||
|
||||
node = list_next(node); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
static bool interop_match_fixed_(const interop_feature_t feature, |
||||
const RawAddress* addr) { |
||||
CHECK(addr); |
||||
|
||||
const size_t db_size = |
||||
sizeof(interop_addr_database) / sizeof(interop_addr_entry_t); |
||||
for (size_t i = 0; i != db_size; ++i) { |
||||
if (feature == interop_addr_database[i].feature && |
||||
memcmp(addr, &interop_addr_database[i].addr, |
||||
interop_addr_database[i].length) == 0) { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
return false; |
||||
} |
Loading…
Reference in new issue