From 2223760845eae1141e5558dd862f286ad67c4676 Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Mon, 7 Sep 2020 10:14:19 -0700 Subject: [PATCH] Break out stack/btm/btm_sco.h Towards usable APIs Bug: 163134718 Tag: #refactor Test: compile & verify basic functions working Change-Id: I9a68209508efcf595a4ad684e3bc7f27f12bfa42 --- stack/btm/btm_int_types.h | 1 + stack/btm/btm_sco.cc | 25 +++++++++++++++ stack/btm/btm_sco.h | 65 ++++++++++++++++++++++++++++++++++++++ stack/btm/security_device_record.h | 65 -------------------------------------- 4 files changed, 91 insertions(+), 65 deletions(-) create mode 100644 stack/btm/btm_sco.h diff --git a/stack/btm/btm_int_types.h b/stack/btm/btm_int_types.h index 9efa180a5..ee33a768d 100644 --- a/stack/btm/btm_int_types.h +++ b/stack/btm/btm_int_types.h @@ -23,6 +23,7 @@ #include "osi/include/list.h" #include "stack/acl/acl.h" #include "stack/btm/btm_ble_int_types.h" +#include "stack/btm/btm_sco.h" #include "stack/btm/security_device_record.h" #include "stack/include/btm_ble_api_types.h" diff --git a/stack/btm/btm_sco.cc b/stack/btm/btm_sco.cc index 248ab01df..95c687635 100644 --- a/stack/btm/btm_sco.cc +++ b/stack/btm/btm_sco.cc @@ -50,6 +50,31 @@ extern tBTM_CB btm_cb; #define SCO_ST_PEND_ROLECHANGE 7 #define SCO_ST_PEND_MODECHANGE 8 +#define BTM_SCO_PKT_TYPE_MASK \ + (HCI_PKT_TYPES_MASK_HV1 | HCI_PKT_TYPES_MASK_HV2 | HCI_PKT_TYPES_MASK_HV3) + +/* MACROs to convert from SCO packet types mask to ESCO and back */ +#define BTM_SCO_PKT_TYPE_MASK \ + (HCI_PKT_TYPES_MASK_HV1 | HCI_PKT_TYPES_MASK_HV2 | HCI_PKT_TYPES_MASK_HV3) + +/* Mask defining only the SCO types of an esco packet type */ +#define BTM_ESCO_PKT_TYPE_MASK \ + (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 | ESCO_PKT_TYPES_MASK_HV3) + +#define BTM_ESCO_2_SCO(escotype) \ + ((uint16_t)(((escotype)&BTM_ESCO_PKT_TYPE_MASK) << 5)) + +/* Define masks for supported and exception 2.0 SCO packet types + */ +#define BTM_SCO_SUPPORTED_PKTS_MASK \ + (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) + +#define BTM_SCO_EXCEPTION_PKTS_MASK \ + (ESCO_PKT_TYPES_MASK_NO_2_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV3 | \ + ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5) + /******************************************************************************/ /* L O C A L F U N C T I O N P R O T O T Y P E S */ /******************************************************************************/ diff --git a/stack/btm/btm_sco.h b/stack/btm/btm_sco.h new file mode 100644 index 000000000..c87e5d5de --- /dev/null +++ b/stack/btm/btm_sco.h @@ -0,0 +1,65 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * 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 + +#include "device/include/esco_parameters.h" +#include "stack/include/btm_api_types.h" + +/* Define the structures needed by sco + */ + +typedef void(tBTM_SCO_IND_CBACK)(uint16_t sco_inx); + +/* Define the structure that contains (e)SCO data */ +typedef struct { + tBTM_ESCO_CBACK* p_esco_cback; /* Callback for eSCO events */ + enh_esco_params_t setup; + tBTM_ESCO_DATA data; /* Connection complete information */ + uint8_t hci_status; +} tBTM_ESCO_INFO; + +/* Define the structure used for SCO Management + */ +typedef struct { + tBTM_ESCO_INFO esco; /* Current settings */ + tBTM_SCO_CB* p_conn_cb; /* Callback for when connected */ + tBTM_SCO_CB* p_disc_cb; /* Callback for when disconnect */ + uint16_t state; /* The state of the SCO link */ + uint16_t hci_handle; /* HCI Handle */ + bool is_orig; /* true if the originator */ + bool rem_bd_known; /* true if remote BD addr known */ + +} tSCO_CONN; + +/* SCO Management control block */ +typedef struct { + tBTM_SCO_IND_CBACK* app_sco_ind_cb; + tSCO_CONN sco_db[BTM_MAX_SCO_LINKS]; + enh_esco_params_t def_esco_parms; + uint16_t sco_disc_reason; + bool esco_supported; /* true if 1.2 cntlr AND supports eSCO links */ + esco_data_path_t sco_route; /* HCI, PCM, or TEST */ +} tSCO_CB; + +extern void btm_set_sco_ind_cback(tBTM_SCO_IND_CBACK* sco_ind_cb); +extern void btm_accept_sco_link(uint16_t sco_inx, enh_esco_params_t* p_setup, + tBTM_SCO_CB* p_conn_cb, tBTM_SCO_CB* p_disc_cb); +extern void btm_reject_sco_link(uint16_t sco_inx); +extern void btm_sco_chk_pend_rolechange(uint16_t hci_handle); +extern void btm_sco_disc_chk_pend_for_modechange(uint16_t hci_handle); diff --git a/stack/btm/security_device_record.h b/stack/btm/security_device_record.h index fa19fb35d..e53658034 100644 --- a/stack/btm/security_device_record.h +++ b/stack/btm/security_device_record.h @@ -148,71 +148,6 @@ typedef uint8_t tBTM_INQ_TYPE; /* The MSB of the clock offset field indicates whether the offset is valid. */ #define BTM_CLOCK_OFFSET_VALID 0x8000 -/* Define the structures needed by security management - */ - -typedef void(tBTM_SCO_IND_CBACK)(uint16_t sco_inx); - -/* MACROs to convert from SCO packet types mask to ESCO and back */ -#define BTM_SCO_PKT_TYPE_MASK \ - (HCI_PKT_TYPES_MASK_HV1 | HCI_PKT_TYPES_MASK_HV2 | HCI_PKT_TYPES_MASK_HV3) - -/* Mask defining only the SCO types of an esco packet type */ -#define BTM_ESCO_PKT_TYPE_MASK \ - (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 | ESCO_PKT_TYPES_MASK_HV3) - -#define BTM_ESCO_2_SCO(escotype) \ - ((uint16_t)(((escotype)&BTM_ESCO_PKT_TYPE_MASK) << 5)) - -/* Define masks for supported and exception 2.0 SCO packet types - */ -#define BTM_SCO_SUPPORTED_PKTS_MASK \ - (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) - -#define BTM_SCO_EXCEPTION_PKTS_MASK \ - (ESCO_PKT_TYPES_MASK_NO_2_EV3 | ESCO_PKT_TYPES_MASK_NO_3_EV3 | \ - ESCO_PKT_TYPES_MASK_NO_2_EV5 | ESCO_PKT_TYPES_MASK_NO_3_EV5) - -/* Define the structure that contains (e)SCO data */ -typedef struct { - tBTM_ESCO_CBACK* p_esco_cback; /* Callback for eSCO events */ - enh_esco_params_t setup; - tBTM_ESCO_DATA data; /* Connection complete information */ - uint8_t hci_status; -} tBTM_ESCO_INFO; - -/* Define the structure used for SCO Management - */ -typedef struct { - tBTM_ESCO_INFO esco; /* Current settings */ - tBTM_SCO_CB* p_conn_cb; /* Callback for when connected */ - tBTM_SCO_CB* p_disc_cb; /* Callback for when disconnect */ - uint16_t state; /* The state of the SCO link */ - uint16_t hci_handle; /* HCI Handle */ - bool is_orig; /* true if the originator */ - bool rem_bd_known; /* true if remote BD addr known */ - -} tSCO_CONN; - -/* SCO Management control block */ -typedef struct { - tBTM_SCO_IND_CBACK* app_sco_ind_cb; - tSCO_CONN sco_db[BTM_MAX_SCO_LINKS]; - enh_esco_params_t def_esco_parms; - uint16_t sco_disc_reason; - bool esco_supported; /* true if 1.2 cntlr AND supports eSCO links */ - esco_data_path_t sco_route; /* HCI, PCM, or TEST */ -} tSCO_CB; - -extern void btm_set_sco_ind_cback(tBTM_SCO_IND_CBACK* sco_ind_cb); -extern void btm_accept_sco_link(uint16_t sco_inx, enh_esco_params_t* p_setup, - tBTM_SCO_CB* p_conn_cb, tBTM_SCO_CB* p_disc_cb); -extern void btm_reject_sco_link(uint16_t sco_inx); -extern void btm_sco_chk_pend_rolechange(uint16_t hci_handle); -extern void btm_sco_disc_chk_pend_for_modechange(uint16_t hci_handle); - /* * Define structure for Security Service Record. * A record exists for each service registered with the Security Manager -- 2.11.0