Break out stack/btm/btm_sco.h
Towards usable APIs
Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I9a68209508efcf595a4ad684e3bc7f27f12bfa42
diff --git a/system/stack/btm/btm_int_types.h b/system/stack/btm/btm_int_types.h
index d111b00..af9b2ed 100644
--- a/system/stack/btm/btm_int_types.h
+++ b/system/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/system/stack/btm/btm_sco.cc b/system/stack/btm/btm_sco.cc
index 248ab01..95c6876 100644
--- a/system/stack/btm/btm_sco.cc
+++ b/system/stack/btm/btm_sco.cc
@@ -50,6 +50,31 @@
#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/system/stack/btm/btm_sco.h b/system/stack/btm/btm_sco.h
new file mode 100644
index 0000000..c87e5d5
--- /dev/null
+++ b/system/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 <cstdint>
+
+#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/system/stack/btm/security_device_record.h b/system/stack/btm/security_device_record.h
index fa19fb3..e536580 100644
--- a/system/stack/btm/security_device_record.h
+++ b/system/stack/btm/security_device_record.h
@@ -148,71 +148,6 @@
/* 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