mirror of
https://github.com/openharmony/vendor_osware.git
synced 2026-07-01 20:35:59 -04:00
modify vendor osware review question
Signed-off-by: zhaoxc0502 <zhaoxc0502@thundersoft.com>
This commit is contained in:
Binary file not shown.
@@ -1,84 +0,0 @@
|
||||
# Copyright© 2021–2022 Beijing OSWare Technology Co., Ltd
|
||||
# This file contains confidential and proprietary information of
|
||||
# OSWare Technology Co., Ltd
|
||||
#
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//build/ohos/ndk/ndk.gni")
|
||||
|
||||
config("bt_warnings") {
|
||||
cflags = [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-Wno-switch",
|
||||
"-Wno-unused-function",
|
||||
"-Wno-unused-parameter",
|
||||
"-Wno-unused-variable",
|
||||
"-Wno-implicit-function-declaration",
|
||||
"-Wno-incompatible-pointer-types",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("BCM43438A1.hcd") {
|
||||
source = "//vendor/osware/imx8mm/bluetooth/BCM43438A1.hcd"
|
||||
install_images = [ vendor_base_dir ]
|
||||
relative_install_dir = "firmware"
|
||||
part_name = "osware_products"
|
||||
install_enable = true
|
||||
}
|
||||
|
||||
ohos_shared_library("libbt_vendor") {
|
||||
output_name = "libbt_vendor"
|
||||
sources = [
|
||||
"src/bt_vendor_brcm.c",
|
||||
"src/conf.c",
|
||||
"src/hardware.c",
|
||||
"src/upio.c",
|
||||
"src/userial_vendor.c",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"include",
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
|
||||
"//foundation/communication/bluetooth/services/bluetooth/hardware/include",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-DUSE_CONTROLLER_BDADDR=TRUE",
|
||||
"-DFW_AUTO_DETECTION=TRUE",
|
||||
"-DBT_WAKE_VIA_PROC=FALSE",
|
||||
"-DSCO_PCM_ROUTING=0",
|
||||
"-DSCO_PCM_IF_CLOCK_RATE=1",
|
||||
"-DSCO_PCM_IF_FRAME_TYPE=0",
|
||||
"-DSCO_PCM_IF_SYNC_MODE=0",
|
||||
"-DSCO_PCM_IF_CLOCK_MODE=0",
|
||||
"-DPCM_DATA_FMT_SHIFT_MODE=0",
|
||||
"-DPCM_DATA_FMT_FILL_BITS=0x03",
|
||||
"-DPCM_DATA_FMT_FILL_METHOD=0",
|
||||
"-DPCM_DATA_FMT_FILL_NUM=0",
|
||||
"-DPCM_DATA_FMT_JUSTIFY_MODE=0",
|
||||
]
|
||||
|
||||
configs = [ ":bt_warnings" ]
|
||||
|
||||
deps = [ "//utils/native/base:utils" ]
|
||||
|
||||
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||
|
||||
install_enable = true
|
||||
install_images = [ "system" ]
|
||||
|
||||
part_name = "osware_products"
|
||||
subsystem_name = "osware_products"
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright 2009-2012 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Filename: bt_hci_bdroid.h
|
||||
*
|
||||
* Description: A wrapper header file of bt_hci_lib.h
|
||||
*
|
||||
* Contains definitions specific for interfacing with Bluedroid
|
||||
* Bluetooth stack
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef BT_VENDOR_HCI_BDROID_H
|
||||
#define BT_VENDOR_HCI_BDROID_H
|
||||
|
||||
#ifdef HAS_BDROID_BUILDCFG
|
||||
#include "bdroid_buildcfg.h"
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Constants & Macros
|
||||
*****************************************************************************/
|
||||
#define HCI_ACL_MAX_SIZE 1024
|
||||
#define HCI_MAX_FRAME_SIZE (HCI_ACL_MAX_SIZE + 4)
|
||||
|
||||
/* Host/Controller lib internal event ID */
|
||||
typedef enum {
|
||||
HC_EVENT_LPM_IDLE_TIMEOUT,
|
||||
} bthc_event_t;
|
||||
|
||||
/* Message event mask across Host/Controller lib and stack */
|
||||
#define MSG_EVT_MASK 0xFF00 /* eq. BT_EVT_MASK */
|
||||
#define MSG_SUB_EVT_MASK 0x00FF /* eq. BT_SUB_EVT_MASK */
|
||||
|
||||
/* Message event ID passed from Host/Controller lib to stack */
|
||||
#define MSG_HC_TO_STACK_HCI_ERR 0x1300 /* eq. BT_EVT_TO_BTU_HCIT_ERR */
|
||||
#define MSG_HC_TO_STACK_HCI_ACL 0x1100 /* eq. BT_EVT_TO_BTU_HCI_ACL */
|
||||
#define MSG_HC_TO_STACK_HCI_SCO 0x1200 /* eq. BT_EVT_TO_BTU_HCI_SCO */
|
||||
#define MSG_HC_TO_STACK_HCI_EVT 0x1000 /* eq. BT_EVT_TO_BTU_HCI_EVT */
|
||||
#define MSG_HC_TO_STACK_L2C_SEG_XMIT 0x1900 /* BT_EVT_TO_BTU_L2C_SEG_XMIT */
|
||||
|
||||
/* Message event ID passed from stack to vendor lib */
|
||||
#define MSG_STACK_TO_HC_HCI_ACL 0x2100 /* eq. BT_EVT_TO_LM_HCI_ACL */
|
||||
#define MSG_STACK_TO_HC_HCI_SCO 0x2200 /* eq. BT_EVT_TO_LM_HCI_SCO */
|
||||
#define MSG_STACK_TO_HC_HCI_CMD 0x2000 /* eq. BT_EVT_TO_LM_HCI_CMD */
|
||||
|
||||
/* Local Bluetooth Controller ID for BR/EDR */
|
||||
#define LOCAL_BR_EDR_CONTROLLER_ID 0
|
||||
|
||||
#define BT_HC_HDR_SIZE (sizeof(HC_BT_HDR))
|
||||
/******************************************************************************
|
||||
* Extern variables and functions
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Functions
|
||||
*****************************************************************************/
|
||||
#endif
|
||||
@@ -1,453 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2012 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Filename: bt_vendor_brcm.h
|
||||
*
|
||||
* Description: A wrapper header file of bt_vendor_lib.h
|
||||
*
|
||||
* Contains definitions specific for interfacing with Broadcom
|
||||
* Bluetooth chipsets
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef BT_VENDOR_BRCM_H
|
||||
#define BT_VENDOR_BRCM_H
|
||||
|
||||
#include "bt_vendor_lib.h"
|
||||
|
||||
/******************************************************************************
|
||||
** Constants & Macros
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE (!FALSE)
|
||||
#endif
|
||||
|
||||
#ifndef VENDOR_LIB_RUNTIME_TUNING_ENABLED
|
||||
#define VENDOR_LIB_RUNTIME_TUNING_ENABLED FALSE
|
||||
#endif
|
||||
|
||||
/* Run-time configuration file */
|
||||
#ifndef VENDOR_LIB_CONF_FILE
|
||||
#define VENDOR_LIB_CONF_FILE "/vendor/etc/bluetooth/bt_vendor.conf"
|
||||
#endif
|
||||
|
||||
/* Device port name where Bluetooth controller attached */
|
||||
#ifndef BLUETOOTH_UART_DEVICE_PORT
|
||||
#define BLUETOOTH_UART_DEVICE_PORT "/dev/ttymxc0" /* maguro */
|
||||
#endif
|
||||
|
||||
/* Location of firmware patch files */
|
||||
#ifndef FW_PATCHFILE_LOCATION
|
||||
#define FW_PATCHFILE_LOCATION "/vendor/etc/firmware/" /* maguro */
|
||||
#endif
|
||||
|
||||
#ifndef UART_TARGET_BAUD_RATE
|
||||
#define UART_TARGET_BAUD_RATE 3000000
|
||||
#endif
|
||||
|
||||
/* The millisecond delay pauses on HCI transport after firmware patches
|
||||
* were downloaded. This gives some time for firmware to restart with
|
||||
* patches before host attempts to send down any HCI commands.
|
||||
*
|
||||
* Note: It has been discovered that BCM43241B0 needs at least 200ms
|
||||
* settlement delay in here. Without the delay, a Hardware Error event
|
||||
* from BCM43241B0 had been seen in HCI upstream path right after the
|
||||
* host sent the HCI_VSC_SET_BDADDR commad to the controller at higher
|
||||
* baud.
|
||||
*/
|
||||
#ifndef FW_PATCH_SETTLEMENT_DELAY_MS
|
||||
#define FW_PATCH_SETTLEMENT_DELAY_MS 0
|
||||
#endif
|
||||
|
||||
#ifndef USERIAL_VENDOR_SET_BAUD_DELAY_US
|
||||
#define USERIAL_VENDOR_SET_BAUD_DELAY_US 0
|
||||
#endif
|
||||
|
||||
#ifndef FW_AUTO_DETECTION
|
||||
#define FW_AUTO_DETECTION FALSE
|
||||
#endif
|
||||
|
||||
/* The Bluetooth Device Aaddress source switch:
|
||||
*
|
||||
* -FALSE- (default value)
|
||||
* Get the factory BDADDR from device's file system. Normally the BDADDR is
|
||||
* stored in the location pointed by the PROPERTY_BT_BDADDR_PATH (defined in
|
||||
* btif_common.h file) property.
|
||||
*
|
||||
* -TRUE-
|
||||
* If the Bluetooth Controller has equipped with a non-volatile memory (such
|
||||
* as BCM4330's OTP memory), the factory BDADDR can be stored in there and
|
||||
* retrieved by the stack while enabling BT.
|
||||
* !!! WARNING !!! Make sure that the OTP feature has been enabled in the
|
||||
* firmware patchram (.hcd) file.
|
||||
*/
|
||||
#ifndef USE_CONTROLLER_BDADDR
|
||||
#define USE_CONTROLLER_BDADDR FALSE
|
||||
#endif
|
||||
|
||||
/* sleep mode
|
||||
|
||||
0: disable
|
||||
1: UART with Host wake/BT wake out of band signals
|
||||
*/
|
||||
#ifndef LPM_SLEEP_MODE
|
||||
#define LPM_SLEEP_MODE 0
|
||||
#endif
|
||||
|
||||
/* Host Stack Idle Threshold in 300ms or 25ms
|
||||
In sleep mode 1, this is the number of firmware loops executed with no
|
||||
action before the Host wake line is deasserted. action includes HCI
|
||||
traffic excluding certain sleep mode commands and the presence of SCO
|
||||
connections if the "Allow Host Sleep During SCO" flag is not set to 1.
|
||||
Each count of this parameter is roughly equivalent to 300ms or 25ms.
|
||||
*/
|
||||
#ifndef LPM_IDLE_THRESHOLD
|
||||
#define LPM_IDLE_THRESHOLD 1
|
||||
#endif
|
||||
|
||||
/* Host Controller Idle Threshold in 300ms or 25ms
|
||||
|
||||
This is the number of firmware loops executed with no action before the
|
||||
HC is considered idle. Depending on the mode, HC may then attempt to sleep.
|
||||
Action includes HCI traffic excluding certain sleep mode commands and
|
||||
the presence of ACL/SCO connections.
|
||||
*/
|
||||
#ifndef LPM_HC_IDLE_THRESHOLD
|
||||
#define LPM_HC_IDLE_THRESHOLD 1
|
||||
#endif
|
||||
|
||||
/* BT_WAKE Polarity - 0=Active Low, 1= Active High */
|
||||
#ifndef LPM_BT_WAKE_POLARITY
|
||||
#define LPM_BT_WAKE_POLARITY 1 /* maguro */
|
||||
#endif
|
||||
|
||||
/* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
|
||||
#ifndef LPM_HOST_WAKE_POLARITY
|
||||
#define LPM_HOST_WAKE_POLARITY 1 /* maguro */
|
||||
#endif
|
||||
|
||||
/* LPM_ALLOW_HOST_SLEEP_DURING_SCO
|
||||
|
||||
When this flag is set to 0, the host is not allowed to sleep while
|
||||
an SCO is active. In sleep mode 1, the device will keep the host
|
||||
wake line asserted while an SCO is active.
|
||||
When this flag is set to 1, the host can sleep while an SCO is active.
|
||||
This flag should only be set to 1 if SCO traffic is directed to the PCM
|
||||
interface.
|
||||
*/
|
||||
#ifndef LPM_ALLOW_HOST_SLEEP_DURING_SCO
|
||||
#define LPM_ALLOW_HOST_SLEEP_DURING_SCO 1
|
||||
#endif
|
||||
|
||||
/* LPM_COMBINE_SLEEP_MODE_AND_LPM
|
||||
|
||||
In Mode 0, always set byte 7 to 0. In sleep mode 1, device always
|
||||
requires permission to sleep between scans / periodic inquiries regardless
|
||||
of the setting of this byte. In sleep mode 1, if byte is set, device must
|
||||
have "permission" to sleep during the low power modes of sniff, hold, and
|
||||
park. If byte is not set, device can sleep without permission during these
|
||||
modes. Permission to sleep in Mode 1 is obtained if the BT_WAKE signal is
|
||||
not asserted.
|
||||
*/
|
||||
#ifndef LPM_COMBINE_SLEEP_MODE_AND_LPM
|
||||
#define LPM_COMBINE_SLEEP_MODE_AND_LPM 1
|
||||
#endif
|
||||
|
||||
/* LPM_ENABLE_UART_TXD_TRI_STATE
|
||||
|
||||
When set to 0, the device will not tristate its UART TX line before going
|
||||
to sleep.
|
||||
When set to 1, the device will tristate its UART TX line before going to
|
||||
sleep.
|
||||
*/
|
||||
#ifndef LPM_ENABLE_UART_TXD_TRI_STATE
|
||||
#define LPM_ENABLE_UART_TXD_TRI_STATE 0
|
||||
#endif
|
||||
|
||||
/* LPM_PULSED_HOST_WAKE
|
||||
*/
|
||||
#ifndef LPM_PULSED_HOST_WAKE
|
||||
#define LPM_PULSED_HOST_WAKE 0
|
||||
#endif
|
||||
|
||||
/* LPM_IDLE_TIMEOUT_MULTIPLE
|
||||
|
||||
The multiple factor of host stack idle threshold in 300ms/25ms
|
||||
*/
|
||||
#ifndef LPM_IDLE_TIMEOUT_MULTIPLE
|
||||
#define LPM_IDLE_TIMEOUT_MULTIPLE 10
|
||||
#endif
|
||||
|
||||
/* BT_WAKE_VIA_USERIAL_IOCTL
|
||||
|
||||
Use userial ioctl function to control BT_WAKE signal
|
||||
*/
|
||||
#ifndef BT_WAKE_VIA_USERIAL_IOCTL
|
||||
#define BT_WAKE_VIA_USERIAL_IOCTL FALSE
|
||||
#endif
|
||||
|
||||
/* BT_WAKE_USERIAL_LDISC
|
||||
|
||||
Use line discipline if the BT_WAKE control is in line discipline
|
||||
*/
|
||||
#ifndef BT_WAKE_USERIAL_LDISC
|
||||
#define BT_WAKE_USERIAL_LDISC FALSE
|
||||
#endif
|
||||
|
||||
/* BT_WAKE_VIA_PROC
|
||||
|
||||
LPM & BT_WAKE control through PROC nodes
|
||||
*/
|
||||
#ifndef BT_WAKE_VIA_PROC
|
||||
#define BT_WAKE_VIA_PROC FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BT_WAKE_VIA_PROC_NOTIFY_DEASSERT
|
||||
#define BT_WAKE_VIA_PROC_NOTIFY_DEASSERT FALSE
|
||||
#endif
|
||||
|
||||
/* N_BRCM_HCI
|
||||
|
||||
UART ioctl line discipline
|
||||
*/
|
||||
#ifndef N_BRCM_HCI
|
||||
#define N_BRCM_HCI 25
|
||||
#endif
|
||||
|
||||
/* SCO_CFG_INCLUDED
|
||||
|
||||
Do SCO configuration by default. If the firmware patch had been embedded
|
||||
with desired SCO configuration, set this FALSE to bypass configuration
|
||||
from host software.
|
||||
*/
|
||||
#ifndef SCO_CFG_INCLUDED
|
||||
#define SCO_CFG_INCLUDED TRUE
|
||||
#endif
|
||||
|
||||
#ifndef SCO_USE_I2S_INTERFACE
|
||||
#define SCO_USE_I2S_INTERFACE FALSE
|
||||
#endif
|
||||
|
||||
#define SCO_I2SPCM_PARAM_IF_MODE 0
|
||||
#define SCO_I2SPCM_PARAM_IF_ROLE 1
|
||||
#define SCO_I2SPCM_PARAM_IF_SAMPLE_RATE 2
|
||||
#define SCO_I2SPCM_PARAM_IF_CLOCK_RATE 3
|
||||
#define SCO_I2SPCM_PARAM_SIZE 4
|
||||
|
||||
/* SCO_WBS_SAMPLE_RATE
|
||||
0 : 8K
|
||||
1 : 16K
|
||||
2 : 4K
|
||||
This macro is used for setting WBS sampling rate for a SCO connection
|
||||
If the mobile network supports WBS, we need to use 16KHz as default
|
||||
but if the platform doesn't support 16KHz, the sample rate can be
|
||||
overriden to 8KHz by setting this to 0.
|
||||
*/
|
||||
#ifndef SCO_WBS_SAMPLE_RATE
|
||||
#define SCO_WBS_SAMPLE_RATE 1
|
||||
#endif
|
||||
|
||||
/* SCO_I2SPCM_IF_MODE - 0=Disable, 1=Enable */
|
||||
#ifndef SCO_I2SPCM_IF_MODE
|
||||
#define SCO_I2SPCM_IF_MODE 1
|
||||
#endif
|
||||
|
||||
/* SCO_I2SPCM_IF_ROLE - 0=Slave, 1=Master */
|
||||
#ifndef SCO_I2SPCM_IF_ROLE
|
||||
#define SCO_I2SPCM_IF_ROLE 1
|
||||
#endif
|
||||
|
||||
/* SCO_I2SPCM_IF_SAMPLE_RATE
|
||||
|
||||
0 : 8K
|
||||
1 : 16K
|
||||
2 : 4K
|
||||
*/
|
||||
#ifndef SCO_I2SPCM_IF_SAMPLE_RATE
|
||||
#define SCO_I2SPCM_IF_SAMPLE_RATE 0
|
||||
#endif
|
||||
|
||||
/* SCO_I2SPCM_IF_CLOCK_RATE
|
||||
|
||||
0 : 128K
|
||||
1 : 256K
|
||||
2 : 512K
|
||||
3 : 1024K
|
||||
4 : 2048K
|
||||
*/
|
||||
#ifndef SCO_I2SPCM_IF_CLOCK_RATE
|
||||
#define SCO_I2SPCM_IF_CLOCK_RATE 1
|
||||
#endif
|
||||
|
||||
/* SCO_I2SPCM_IF_CLOCK_RATE4WBS
|
||||
|
||||
0 : 128K
|
||||
1 : 256K
|
||||
2 : 512K
|
||||
3 : 1024K
|
||||
4 : 2048K
|
||||
*/
|
||||
#ifndef SCO_I2SPCM_IF_CLOCK_RATE4WBS
|
||||
#define SCO_I2SPCM_IF_CLOCK_RATE4WBS 2
|
||||
#endif
|
||||
|
||||
#define SCO_PCM_PARAM_ROUTING 0
|
||||
#define SCO_PCM_PARAM_IF_CLOCK_RATE 1
|
||||
#define SCO_PCM_PARAM_IF_FRAME_TYPE 2
|
||||
#define SCO_PCM_PARAM_IF_SYNC_MODE 3
|
||||
#define SCO_PCM_PARAM_IF_CLOCK_MODE 4
|
||||
#define SCO_PCM_PARAM_SIZE 5
|
||||
|
||||
/* SCO_PCM_ROUTING
|
||||
|
||||
0 : PCM
|
||||
1 : Transport
|
||||
2 : Codec
|
||||
3 : I2S
|
||||
*/
|
||||
#ifndef SCO_PCM_ROUTING
|
||||
#define SCO_PCM_ROUTING 0
|
||||
#endif
|
||||
|
||||
/* SCO_PCM_IF_CLOCK_RATE
|
||||
|
||||
NOTICE: suggested to be consistent with SCO_I2SPCM_IF_CLOCK_RATE
|
||||
|
||||
0 : 128K
|
||||
1 : 256K
|
||||
2 : 512K
|
||||
3 : 1024K
|
||||
4 : 2048K
|
||||
*/
|
||||
#ifndef SCO_PCM_IF_CLOCK_RATE
|
||||
#define SCO_PCM_IF_CLOCK_RATE 4
|
||||
#endif
|
||||
|
||||
/* SCO_PCM_IF_FRAME_TYPE - 0=Short, 1=Long */
|
||||
#ifndef SCO_PCM_IF_FRAME_TYPE
|
||||
#define SCO_PCM_IF_FRAME_TYPE 0
|
||||
#endif
|
||||
|
||||
/* SCO_PCM_IF_SYNC_MODE
|
||||
|
||||
NOTICE: in most usage cases the value will be the same as
|
||||
SCO_PCM_IF_CLOCK_MODE setting
|
||||
|
||||
0 : Slave
|
||||
1 : Master
|
||||
*/
|
||||
#ifndef SCO_PCM_IF_SYNC_MODE
|
||||
#define SCO_PCM_IF_SYNC_MODE 0
|
||||
#endif
|
||||
|
||||
/* SCO_PCM_IF_CLOCK_MODE
|
||||
|
||||
NOTICE: suggested to be consistent with SCO_I2SPCM_IF_ROLE
|
||||
|
||||
0 : Slave
|
||||
1 : Master
|
||||
*/
|
||||
#ifndef SCO_PCM_IF_CLOCK_MODE
|
||||
#define SCO_PCM_IF_CLOCK_MODE 0
|
||||
#endif
|
||||
|
||||
#define PCM_DATA_FORMAT_PARAM_SIZE 5
|
||||
|
||||
/* PCM_DATA_FMT_SHIFT_MODE
|
||||
|
||||
0 : MSB first
|
||||
1 : LSB first
|
||||
*/
|
||||
#ifndef PCM_DATA_FMT_SHIFT_MODE
|
||||
#define PCM_DATA_FMT_SHIFT_MODE 0
|
||||
#endif
|
||||
|
||||
/* PCM_DATA_FMT_FILL_BITS
|
||||
|
||||
Specifies the value with which to fill unused bits
|
||||
if Fill_Method is set to programmable
|
||||
*/
|
||||
#ifndef PCM_DATA_FMT_FILL_BITS
|
||||
#define PCM_DATA_FMT_FILL_BITS 0
|
||||
#endif
|
||||
|
||||
/* PCM_DATA_FMT_FILL_METHOD
|
||||
|
||||
0 : 0's
|
||||
1 : 1's
|
||||
2 : Signed
|
||||
3 : Programmable
|
||||
*/
|
||||
#ifndef PCM_DATA_FMT_FILL_METHOD
|
||||
#define PCM_DATA_FMT_FILL_METHOD 3
|
||||
#endif
|
||||
|
||||
/* PCM_DATA_FMT_FILL_NUM
|
||||
|
||||
Specifies the number of bits to be filled
|
||||
*/
|
||||
#ifndef PCM_DATA_FMT_FILL_NUM
|
||||
#define PCM_DATA_FMT_FILL_NUM 0
|
||||
#endif
|
||||
|
||||
/* PCM_DATA_FMT_JUSTIFY_MODE
|
||||
|
||||
0 : Left justify (fill data shifted out last)
|
||||
1 : Right justify (fill data shifted out first)
|
||||
*/
|
||||
#ifndef PCM_DATA_FMT_JUSTIFY_MODE
|
||||
#define PCM_DATA_FMT_JUSTIFY_MODE 0
|
||||
#endif
|
||||
|
||||
/* HW_END_WITH_HCI_RESET
|
||||
|
||||
Sample code implementation of sending a HCI_RESET command during the epilog
|
||||
process. It calls back to the callers after command complete of HCI_RESET
|
||||
is received.
|
||||
*/
|
||||
#ifndef HW_END_WITH_HCI_RESET
|
||||
#define HW_END_WITH_HCI_RESET TRUE
|
||||
#endif
|
||||
|
||||
#define BD_ADDR_LEN 6
|
||||
#define BT_VENDOR_TIME_RAIDX 1000
|
||||
/******************************************************************************
|
||||
** Extern variables and functions
|
||||
******************************************************************************/
|
||||
|
||||
extern bt_vendor_callbacks_t *bt_vendor_cbacks;
|
||||
/** audio (SCO) state changes triggering VS commands for configuration */
|
||||
typedef struct {
|
||||
uint16_t handle;
|
||||
uint16_t peer_codec;
|
||||
uint16_t state;
|
||||
} bt_vendor_op_audio_state_t;
|
||||
|
||||
extern int hw_set_audio_state(bt_vendor_op_audio_state_t *p_state);
|
||||
extern uint8_t vnd_local_bd_addr[BD_ADDR_LEN];
|
||||
|
||||
extern void hw_process_event(HC_BT_HDR *);
|
||||
|
||||
#endif /* BT_VENDOR_BRCM_H */
|
||||
@@ -1,122 +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.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BT_VENDOR_ESCO_PARAMETER_H
|
||||
#define BT_VENDOR_ESCO_PARAMETER_H
|
||||
|
||||
#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 {
|
||||
ESCO_CODEC_CVSD = 0,
|
||||
ESCO_CODEC_MSBC_T1,
|
||||
ESCO_CODEC_MSBC_T2,
|
||||
} esco_codec_t;
|
||||
|
||||
#define ESCO_NUM_CODECS 3
|
||||
|
||||
// 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 */
|
||||
|
||||
// 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 */
|
||||
|
||||
// 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 */
|
||||
|
||||
// eSCO constants
|
||||
#define TXRX_64KBITS_RATE 0x00001f40 /* 64 kbits/sec data rate */
|
||||
#define TXRX_128KBITS_RATE 0x00003E80 /* 128 kbits/sec data rate */
|
||||
|
||||
#define INPUT_OUTPUT_64K_RATE 0x00003E80 /* 16000 Bytes/sec over transport */
|
||||
#define INPUT_OUTPUT_128K_RATE 0x00007D00 /* 32000 Bytes/sec over transport */
|
||||
|
||||
// Retransmission effort
|
||||
#define ESCO_RETRANSMISSION_OFF 0
|
||||
#define ESCO_RETRANSMISSION_POWER 1
|
||||
#define ESCO_RETRANSMISSION_QUALITY 2
|
||||
#define ESCO_RETRANSMISSION_DONTCARE 0xff
|
||||
|
||||
// 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
|
||||
|
||||
// type definition
|
||||
typedef struct {
|
||||
uint8_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 {
|
||||
uint32_t transmit_bandwidth; /* Transmit Bandwidth (in octets/second) */
|
||||
uint32_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) */
|
||||
uint32_t input_bandwidth; /* Input BW (nominal rate octets/sec) */
|
||||
uint32_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) */
|
||||
uint8_t input_pcm_data_format; /* Input PCM data format (see hcidefs.h) */
|
||||
uint8_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 */
|
||||
uint8_t input_data_path; /* 0x00 - HCI, or 0x01-0xFE for VS) */
|
||||
uint8_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) */
|
||||
uint16_t packet_types; /* Packet Types */
|
||||
uint8_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);
|
||||
#endif
|
||||
@@ -1,732 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2012 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains sync message over UIPC
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef BT_VENDOR_UIPC_MSG_H
|
||||
#define BT_VENDOR_UIPC_MSG_H
|
||||
|
||||
#include "bt_types.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/* UIPC version number: 1.0 */
|
||||
/****************************************************************************/
|
||||
#define UIPC_VERSION_MAJOR 0x0001
|
||||
#define UIPC_VERSION_MINOR 0x0000
|
||||
|
||||
/********************************
|
||||
|
||||
UIPC Management Messages
|
||||
|
||||
********************************/
|
||||
|
||||
/* tUIPC_STATUS codes */
|
||||
enum {
|
||||
UIPC_STATUS_SUCCESS,
|
||||
UIPC_STATUS_FAIL
|
||||
};
|
||||
|
||||
/* op_code */
|
||||
#define UIPC_OPEN_REQ 0x00
|
||||
#define UIPC_OPEN_RSP 0x01
|
||||
#define UIPC_CLOSE_REQ 0x02
|
||||
#define UIPC_CLOSE_RSP 0x03
|
||||
|
||||
#pragma pack(push) /* push current alignment to stack */
|
||||
#pragma pack(1) /* set alignment to 1 byte boundary to allow for offset mappings */
|
||||
|
||||
/* Structure of UIPC_OPEN_REQ message */
|
||||
typedef struct {
|
||||
uint8_t opcode; /* UIPC_OPEN_REQ */
|
||||
} tUIPC_OPEN_REQ;
|
||||
#define UIPC_OPEN_REQ_MSGLEN (1)
|
||||
|
||||
/* Structure of UIPC_OPEN_RSP message */
|
||||
typedef struct {
|
||||
uint8_t opcode; /* UIPC_OPEN_RESP */
|
||||
uint8_t status; /* UIPC_STATUS */
|
||||
uint16_t version_major; /* UIPC_VERSION_MAJOR */
|
||||
uint16_t version_minor; /* UIPC_VERSION_MINOR */
|
||||
uint8_t num_streams; /* Number of simultaneous streams supported by the light stack */
|
||||
} tUIPC_OPEN_RSP;
|
||||
#define UIPC_OPEN_RSP_MSGLEN (7)
|
||||
|
||||
/* Structure of UIPC_CLOSE_REQ message */
|
||||
typedef struct t_uipc_close_req {
|
||||
uint8_t opcode; /* UIPC_CLOSE_REQ */
|
||||
} tUIPC_CLOSE_REQ;
|
||||
#define UIPC_CLOSE_REQ_MSGLEN (1)
|
||||
|
||||
/* Structure of UIPC_CLOSE_RSP message, only for BTC, full stack may ignore it */
|
||||
typedef struct t_uipc_close_rsp {
|
||||
uint8_t opcode; /* UIPC_CLOSE_RSP */
|
||||
} tUIPC_CLOSE_RSP;
|
||||
#define UIPC_CLOSE_RSP_MSGLEN (1)
|
||||
|
||||
/* UIPC management message structures */
|
||||
typedef union {
|
||||
uint8_t opcode;
|
||||
tUIPC_OPEN_REQ open_req;
|
||||
tUIPC_OPEN_RSP open_resp;
|
||||
tUIPC_CLOSE_REQ close_req;
|
||||
} tUIPC_MSG;
|
||||
|
||||
#define UIPC_MGMT_MSG_MAXLEN (sizeof(tUIPC_MSG))
|
||||
|
||||
#define IPC_LOG_MSG_LEN 100
|
||||
typedef struct t_uipc_log_msg {
|
||||
uint32_t trace_set_mask;
|
||||
uint8_t msg[IPC_LOG_MSG_LEN];
|
||||
} tUIPC_LOG_MSG;
|
||||
#define UIPC_LOG_MSGLEN (IPC_LOG_MSG_LEN + 4)
|
||||
|
||||
/********************************
|
||||
|
||||
H5 Sync Message
|
||||
|
||||
********************************/
|
||||
|
||||
/* op_code */
|
||||
#define SLIP_SYNC_TO_LITE_REQ 0
|
||||
#define SLIP_SYNC_TO_LITE_RESP 1
|
||||
#define SLIP_SYNC_TO_FULL_REQ 2
|
||||
#define SLIP_SYNC_TO_FULL_RESP 3
|
||||
#define SLIP_SYNC_NOTIFY 4
|
||||
|
||||
/* status */
|
||||
#define SLIP_SYNC_SUCCESS 0
|
||||
#define SLIP_SYNC_FAILURE 1
|
||||
|
||||
typedef struct {
|
||||
uint8_t op_code;
|
||||
uint8_t status;
|
||||
uint16_t acl_pkt_size;
|
||||
uint8_t state;
|
||||
uint8_t lp_state; /* Low Power state */
|
||||
uint8_t next_seqno; /* next send seq */
|
||||
uint8_t ack; /* next ack seq, expected seq from peer */
|
||||
uint8_t sent_ack; /* last sent ack */
|
||||
uint8_t sliding_window_size; /* window size */
|
||||
bool oof_flow_control; /* Out of Frame SW Flow Control */
|
||||
bool data_integrity_type; /* Level of Data Integrity Check */
|
||||
uint8_t rx_state; /* rx state for incoming packet processing */
|
||||
} tSLIP_SYNC_INFO;
|
||||
|
||||
/********************************
|
||||
|
||||
L2CAP Sync Message
|
||||
|
||||
********************************/
|
||||
|
||||
/* op_code */
|
||||
#define L2C_SYNC_TO_LITE_REQ 0
|
||||
#define L2C_SYNC_TO_LITE_RESP 1
|
||||
#define L2C_REMOVE_TO_LITE_REQ 2
|
||||
#define L2C_REMOVE_TO_LITE_RESP 3
|
||||
#define L2C_FLUSH_TO_FULL_IND 4
|
||||
|
||||
/* status */
|
||||
#define L2C_SYNC_SUCCESS 0
|
||||
#define L2C_SYNC_FAILURE 1
|
||||
|
||||
typedef struct t_l2c_stream_info {
|
||||
uint16_t local_cid; /* Local CID */
|
||||
uint16_t remote_cid; /* Remote CID */
|
||||
uint16_t out_mtu; /* Max MTU we will send */
|
||||
uint16_t handle; /* The handle used with LM */
|
||||
uint16_t link_xmit_quota; /* Num outstanding pkts allowed */
|
||||
bool is_flushable; /* TRUE if flushable channel */
|
||||
} tL2C_STREAM_INFO;
|
||||
|
||||
typedef struct t_l2c_sync_to_lite_req {
|
||||
uint8_t op_code; /* L2C_SYNC_TO_LITE_REQ */
|
||||
uint16_t light_xmit_quota; /* Total quota for light stack */
|
||||
uint16_t acl_data_size; /* Max ACL data size across HCI transport */
|
||||
uint16_t non_flushable_pbf; /* L2CAP_PKT_START_NON_FLUSHABLE if controller supports */
|
||||
/* Otherwise, L2CAP_PKT_START */
|
||||
uint8_t multi_av_data_cong_start; /* Multi-AV queue size to start congestion */
|
||||
uint8_t multi_av_data_cong_end; /* Multi-AV queue size to end congestion */
|
||||
uint8_t multi_av_data_cong_discard; /* Multi-AV queue size to discard */
|
||||
uint8_t num_stream;
|
||||
tL2C_STREAM_INFO stream;
|
||||
} tL2C_SYNC_TO_LITE_REQ;
|
||||
|
||||
typedef struct t_l2c_sync_to_lite_resp_stream {
|
||||
uint16_t lcid;
|
||||
uint8_t status;
|
||||
} tL2C_SYNC_TO_LITE_RESP_STREAM;
|
||||
|
||||
typedef struct t_l2c_sync_to_lite_resp {
|
||||
uint8_t op_code; /* L2C_SYNC_TO_LITE_RESP */
|
||||
uint16_t light_xmit_unacked; /* unacked packet more than quota in light stack */
|
||||
uint8_t num_stream;
|
||||
tL2C_SYNC_TO_LITE_RESP_STREAM stream;
|
||||
} tL2C_SYNC_TO_LITE_RESP;
|
||||
|
||||
typedef struct t_l2c_remove_to_lite_req {
|
||||
uint8_t op_code; /* L2C_REMOVE_TO_LITE_REQ */
|
||||
uint16_t light_xmit_quota; /* Total quota for light stack */
|
||||
uint8_t num_stream;
|
||||
uint16_t lcid;
|
||||
} tL2C_REMOVE_TO_LITE_REQ;
|
||||
|
||||
typedef tL2C_SYNC_TO_LITE_RESP tL2C_REMOVE_TO_LITE_RESP;
|
||||
typedef tL2C_REMOVE_TO_LITE_REQ tL2C_FLUSH_TO_FULL_IND;
|
||||
|
||||
typedef union t_l2c_sync_msg {
|
||||
uint8_t op_code;
|
||||
tL2C_SYNC_TO_LITE_REQ sync_req;
|
||||
tL2C_SYNC_TO_LITE_RESP sync_resp;
|
||||
tL2C_REMOVE_TO_LITE_REQ remove_req;
|
||||
tL2C_REMOVE_TO_LITE_RESP remove_resp;
|
||||
tL2C_FLUSH_TO_FULL_IND flush_ind;
|
||||
} tL2C_SYNC_MSG;
|
||||
|
||||
/********************************
|
||||
|
||||
AVDTP Sync Message
|
||||
|
||||
********************************/
|
||||
|
||||
/* op_code */
|
||||
#define AVDT_SYNC_TO_LITE_REQ 0
|
||||
#define AVDT_SYNC_TO_LITE_RESP 1
|
||||
#define AVDT_RESYNC_TO_LITE_REQ 2
|
||||
#define AVDT_RESYNC_TO_LITE_RESP 3
|
||||
#define AVDT_SYNC_TO_FULL_REQ 4
|
||||
#define AVDT_SYNC_TO_FULL_RESP 5
|
||||
#define AVDT_REMOVE_TO_LITE_REQ 6
|
||||
#define AVDT_REMOVE_TO_LITE_RESP 7
|
||||
#define AVDT_SYNC_TO_BTC_LITE_REQ 8
|
||||
#define AVDT_SYNC_TO_BTC_LITE_RESP 9
|
||||
|
||||
/* status */
|
||||
#define AVDT_SYNC_SUCCESS 0
|
||||
#define AVDT_SYNC_FAILURE 1
|
||||
|
||||
typedef struct {
|
||||
uint16_t lcid;
|
||||
uint32_t ssrc;
|
||||
} tAVDT_SYNC_TO_BTC_LITE_REQ_STREAM;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* AVDT_SYNC_TO_BTC_LITE_REQ */
|
||||
uint8_t num_stream;
|
||||
tAVDT_SYNC_TO_BTC_LITE_REQ_STREAM stream;
|
||||
} tAVDT_SYNC_TO_BTC_LITE_REQ;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* AVDT_SYNC_TO_BTC_LITE_RESP */
|
||||
uint8_t status;
|
||||
} tAVDT_SYNC_TO_BTC_LITE_RESP;
|
||||
|
||||
typedef struct t_avdt_scb_sync_info {
|
||||
uint8_t handle; /* SCB handle */
|
||||
BD_ADDR peer_addr; /* BD address of peer */
|
||||
uint16_t local_cid; /* Local CID */
|
||||
uint16_t peer_mtu; /* L2CAP mtu of the peer device */
|
||||
uint8_t mux_tsid_media; /* TSID for media transport session */
|
||||
uint16_t media_seq; /* media packet sequence number */
|
||||
} tAVDT_SCB_SYNC_INFO;
|
||||
|
||||
typedef struct t_avdt_sync_info {
|
||||
uint8_t op_code;
|
||||
uint8_t status;
|
||||
tAVDT_SCB_SYNC_INFO scb_info;
|
||||
} tAVDT_SYNC_INFO;
|
||||
|
||||
typedef union t_avdt_sync_msg {
|
||||
uint8_t op_code;
|
||||
tAVDT_SYNC_INFO sync_info;
|
||||
tAVDT_SYNC_TO_BTC_LITE_REQ btc_sync_req;
|
||||
tAVDT_SYNC_TO_BTC_LITE_RESP btc_sync_resp;
|
||||
} tAVDT_SYNC_MSG;
|
||||
|
||||
/********************************
|
||||
|
||||
BTA AV Sync Message
|
||||
|
||||
********************************/
|
||||
|
||||
/* op_code for MM light stack */
|
||||
#define BTA_AV_SYNC_TO_LITE_REQ 0
|
||||
#define BTA_AV_SYNC_TO_LITE_RESP 1
|
||||
#define BTA_AV_STR_START_TO_LITE_REQ 2
|
||||
#define BTA_AV_STR_START_TO_LITE_RESP 3
|
||||
#define BTA_AV_STR_STOP_TO_LITE_REQ 4
|
||||
#define BTA_AV_STR_STOP_TO_LITE_RESP 5
|
||||
#define BTA_AV_STR_CLEANUP_TO_LITE_REQ 6
|
||||
#define BTA_AV_STR_CLEANUP_TO_LITE_RESP 7
|
||||
#define BTA_AV_STR_SUSPEND_TO_LITE_REQ 8
|
||||
#define BTA_AV_STR_SUSPEND_TO_LITE_RESP 9
|
||||
#define BTA_AV_SYNC_ERROR_RESP 10
|
||||
|
||||
/* op_code for BTC light stack */
|
||||
#define A2DP_START_REQ 11
|
||||
#define A2DP_START_RESP 12
|
||||
#define A2DP_STOP_REQ 13
|
||||
#define A2DP_STOP_RESP 14
|
||||
#define A2DP_CLEANUP_REQ 15
|
||||
#define A2DP_CLEANUP_RESP 16
|
||||
#define A2DP_SUSPEND_REQ 17
|
||||
#define A2DP_SUSPEND_RESP 18
|
||||
|
||||
#define A2DP_JITTER_DONE_IND 41 /* For BTSNK */
|
||||
|
||||
#define AUDIO_CODEC_CONFIG_REQ 19
|
||||
#define AUDIO_CODEC_CONFIG_RESP 20
|
||||
#define AUDIO_CODEC_SET_BITRATE_REQ 21
|
||||
#define AUDIO_CODEC_FLUSH_REQ 22
|
||||
#define AUDIO_ROUTE_CONFIG_REQ 23
|
||||
#define AUDIO_ROUTE_CONFIG_RESP 24
|
||||
#define AUDIO_MIX_CONFIG_REQ 25
|
||||
#define AUDIO_MIX_CONFIG_RESP 26
|
||||
#define AUDIO_BURST_FRAMES_IND 27
|
||||
#define AUDIO_BURST_END_IND 28
|
||||
#define AUDIO_EQ_MODE_CONFIG_REQ 29
|
||||
#define AUDIO_SCALE_CONFIG_REQ 30
|
||||
|
||||
/* For TIVO, only applicable for I2S -> DAC */
|
||||
#define AUDIO_SUB_ROUTE_REQ 51
|
||||
#define AUDIO_SUB_ROUTE_RESP 52
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* A2DP_START_REQ */
|
||||
uint16_t lcid;
|
||||
uint16_t curr_mtu;
|
||||
} tA2DP_START_REQ;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* A2DP_STOP_REQ */
|
||||
uint16_t lcid;
|
||||
} tA2DP_STOP_REQ;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* A2DP_SUSPEND_REQ */
|
||||
uint16_t lcid;
|
||||
} tA2DP_SUSPEND_REQ;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* A2DP_CLEANUP_REQ */
|
||||
uint16_t lcid;
|
||||
uint16_t curr_mtu;
|
||||
} tA2DP_CLEANUP_REQ;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* A2DP_START_RESP, A2DP_STOP_RESP, A2DP_CLEANUP_RESP, A2DP_SUSPEND_RESP */
|
||||
uint16_t lcid;
|
||||
} tA2DP_GENERIC_RESP;
|
||||
|
||||
#define AUDIO_CODEC_NONE 0x0000
|
||||
#define AUDIO_CODEC_SBC_ENC 0x0001
|
||||
#define AUDIO_CODEC_SBC_DEC 0x0002
|
||||
#define AUDIO_CODEC_MP3_ENC 0x0004
|
||||
#define AUDIO_CODEC_MP3_DEC 0x0008
|
||||
#define AUDIO_CODEC_AAC_ENC 0x0010
|
||||
#define AUDIO_CODEC_AAC_DEC 0x0020
|
||||
#define AUDIO_CODEC_AAC_PLUS_ENC 0x0040
|
||||
#define AUDIO_CODEC_AAC_PLUS_DEC 0x0080
|
||||
#define AUDIO_CODEC_MP2_ENC 0x0100
|
||||
#define AUDIO_CODEC_MP2_DEC 0x0200
|
||||
#define AUDIO_CODEC_MP2_5_ENC 0x0400
|
||||
#define AUDIO_CODEC_MP2_5_DEC 0x0800
|
||||
|
||||
/* SBC CODEC Parameters */
|
||||
|
||||
#define CODEC_INFO_SBC_SF_16K 0x00
|
||||
#define CODEC_INFO_SBC_SF_32K 0x01
|
||||
#define CODEC_INFO_SBC_SF_44K 0x02
|
||||
#define CODEC_INFO_SBC_SF_48K 0x03
|
||||
|
||||
#define CODEC_INFO_SBC_BLOCK_4 0x00
|
||||
#define CODEC_INFO_SBC_BLOCK_8 0x01
|
||||
#define CODEC_INFO_SBC_BLOCK_12 0x02
|
||||
#define CODEC_INFO_SBC_BLOCK_16 0x03
|
||||
|
||||
#define CODEC_INFO_SBC_CH_MONO 0x00
|
||||
#define CODEC_INFO_SBC_CH_DUAL 0x01
|
||||
#define CODEC_INFO_SBC_CH_STEREO 0x02
|
||||
#define CODEC_INFO_SBC_CH_JS 0x03
|
||||
|
||||
#define CODEC_INFO_SBC_ALLOC_LOUDNESS 0x00
|
||||
#define CODEC_INFO_SBC_ALLOC_SNR 0x01
|
||||
|
||||
#define CODEC_INFO_SBC_SUBBAND_4 0x00
|
||||
#define CODEC_INFO_SBC_SUBBAND_8 0x01
|
||||
|
||||
/* MPEG audio version ID */
|
||||
#define CODEC_INFO_MP25_ID 0x00
|
||||
#define CODEC_INFO_RESERVE 0x01
|
||||
#define CODEC_INFO_MP2_ID 0x02
|
||||
#define CODEC_INFO_MP3_ID 0x03
|
||||
|
||||
#define CODEC_INFO_MP3_PROTECTION_ON 0x00
|
||||
#define CODEC_INFO_MP3_PROTECTION_OFF 0x01
|
||||
|
||||
#define CODEC_INFO_MP3_BR_IDX_FREE 0x00
|
||||
#define CODEC_INFO_MP3_BR_IDX_32K 0x01
|
||||
#define CODEC_INFO_MP3_BR_IDX_40K 0x02
|
||||
#define CODEC_INFO_MP3_BR_IDX_48K 0x03
|
||||
#define CODEC_INFO_MP3_BR_IDX_56K 0x04
|
||||
#define CODEC_INFO_MP3_BR_IDX_64K 0x05
|
||||
#define CODEC_INFO_MP3_BR_IDX_80K 0x06
|
||||
#define CODEC_INFO_MP3_BR_IDX_96K 0x07
|
||||
#define CODEC_INFO_MP3_BR_IDX_112K 0x08
|
||||
#define CODEC_INFO_MP3_BR_IDX_128K 0x09
|
||||
#define CODEC_INFO_MP3_BR_IDX_160K 0x0A
|
||||
#define CODEC_INFO_MP3_BR_IDX_192K 0x0B
|
||||
#define CODEC_INFO_MP3_BR_IDX_224K 0x0C
|
||||
#define CODEC_INFO_MP3_BR_IDX_256K 0x0D
|
||||
#define CODEC_INFO_MP3_BR_IDX_320K 0x0E
|
||||
|
||||
#define CODEC_INFO_MP3_SF_44K 0x00
|
||||
#define CODEC_INFO_MP3_SF_48K 0x01
|
||||
#define CODEC_INFO_MP3_SF_32K 0x02
|
||||
|
||||
#define CODEC_INFO_MP3_MODE_STEREO 0x00
|
||||
#define CODEC_INFO_MP3_MODE_JS 0x01
|
||||
#define CODEC_INFO_MP3_MODE_DUAL 0x02
|
||||
#define CODEC_INFO_MP3_MODE_SINGLE 0x03
|
||||
|
||||
/* layer 3, type of joint stereo coding method (intensity and ms) */
|
||||
#define CODEC_INFO_MP3_MODE_EXT_OFF_OFF 0x00
|
||||
#define CODEC_INFO_MP3_MODE_EXT_ON_OFF 0x01
|
||||
#define CODEC_INFO_MP3_MODE_EXT_OFF_ON 0x02
|
||||
#define CODEC_INFO_MP3_MODE_EXT_ON_ON 0x03
|
||||
|
||||
#define CODEC_INFO_MP2_PROTECTION_ON 0x00
|
||||
#define CODEC_INFO_MP2_PROTECTION_OFF 0x01
|
||||
|
||||
#define CODEC_INFO_MP2_BR_IDX_FREE 0x00
|
||||
#define CODEC_INFO_MP2_BR_IDX_8K 0x01
|
||||
#define CODEC_INFO_MP2_BR_IDX_16K 0x02
|
||||
#define CODEC_INFO_MP2_BR_IDX_24K 0x03
|
||||
#define CODEC_INFO_MP2_BR_IDX_32K 0x04
|
||||
#define CODEC_INFO_MP2_BR_IDX_40K 0x05
|
||||
#define CODEC_INFO_MP2_BR_IDX_48K 0x06
|
||||
#define CODEC_INFO_MP2_BR_IDX_56K 0x07
|
||||
#define CODEC_INFO_MP2_BR_IDX_64K 0x08
|
||||
#define CODEC_INFO_MP2_BR_IDX_80K 0x09
|
||||
#define CODEC_INFO_MP2_BR_IDX_96K 0x0A
|
||||
#define CODEC_INFO_MP2_BR_IDX_112K 0x0B
|
||||
#define CODEC_INFO_MP2_BR_IDX_128K 0x0C
|
||||
#define CODEC_INFO_MP2_BR_IDX_144K 0x0D
|
||||
#define CODEC_INFO_MP2_BR_IDX_160K 0x0E
|
||||
|
||||
#define CODEC_INFO_MP2_SF_22K 0x00
|
||||
#define CODEC_INFO_MP2_SF_24K 0x01
|
||||
#define CODEC_INFO_MP2_SF_16K 0x02
|
||||
|
||||
#define CODEC_INFO_MP2_MODE_STEREO 0x00
|
||||
#define CODEC_INFO_MP2_MODE_JS 0x01
|
||||
#define CODEC_INFO_MP2_MODE_DUAL 0x02
|
||||
#define CODEC_INFO_MP2_MODE_SINGLE 0x03
|
||||
|
||||
/* layer 3, type of joint stereo coding method (intensity and ms) */
|
||||
#define CODEC_INFO_MP2_MODE_EXT_OFF_OFF 0x00
|
||||
#define CODEC_INFO_MP2_MODE_EXT_ON_OFF 0x01
|
||||
#define CODEC_INFO_MP2_MODE_EXT_OFF_ON 0x02
|
||||
#define CODEC_INFO_MP2_MODE_EXT_ON_ON 0x03
|
||||
|
||||
#define CODEC_INFO_MP2_SAMPLE_PER_FRAME 576
|
||||
|
||||
/* mpeg 2.5 layer 3 decoder */
|
||||
|
||||
#define CODEC_INFO_MP25_PROTECTION_ON 0x00
|
||||
#define CODEC_INFO_MP25_PROTECTION_OFF 0x01
|
||||
|
||||
#define CODEC_INFO_MP25_BR_IDX_FREE 0x00
|
||||
#define CODEC_INFO_MP25_BR_IDX_8K 0x01
|
||||
#define CODEC_INFO_MP25_BR_IDX_16K 0x02
|
||||
#define CODEC_INFO_MP25_BR_IDX_24K 0x03
|
||||
#define CODEC_INFO_MP25_BR_IDX_32K 0x04
|
||||
#define CODEC_INFO_MP25_BR_IDX_40K 0x05
|
||||
#define CODEC_INFO_MP25_BR_IDX_48K 0x06
|
||||
#define CODEC_INFO_MP25_BR_IDX_56K 0x07
|
||||
#define CODEC_INFO_MP25_BR_IDX_64K 0x08
|
||||
#define CODEC_INFO_MP25_BR_IDX_80K 0x09
|
||||
#define CODEC_INFO_MP25_BR_IDX_96K 0x0A
|
||||
#define CODEC_INFO_MP25_BR_IDX_112K 0x0B
|
||||
#define CODEC_INFO_MP25_BR_IDX_128K 0x0C
|
||||
#define CODEC_INFO_MP25_BR_IDX_144K 0x0D
|
||||
#define CODEC_INFO_MP25_BR_IDX_160K 0x0E
|
||||
|
||||
#define CODEC_INFO_MP25_SF_11K 0x00
|
||||
#define CODEC_INFO_MP25_SF_12K 0x01
|
||||
#define CODEC_INFO_MP25_SF_8K 0x02
|
||||
|
||||
#define CODEC_INFO_MP25_MODE_STEREO 0x00
|
||||
#define CODEC_INFO_MP25_MODE_JS 0x01
|
||||
#define CODEC_INFO_MP25_MODE_DUAL 0x02
|
||||
#define CODEC_INFO_MP25_MODE_SINGLE 0x03
|
||||
|
||||
/* layer 3, type of joint stereo coding method (intensity and ms) */
|
||||
#define CODEC_INFO_MP25_MODE_EXT_OFF_OFF 0x00
|
||||
#define CODEC_INFO_MP25_MODE_EXT_ON_OFF 0x01
|
||||
#define CODEC_INFO_MP25_MODE_EXT_OFF_ON 0x02
|
||||
#define CODEC_INFO_MP25_MODE_EXT_ON_ON 0x03
|
||||
|
||||
#define CODEC_INFO_MP25_SAMPLE_PER_FRAME 576
|
||||
|
||||
/* AAC/AAC+ CODEC Parameters */
|
||||
#define CODEC_INFO_AAC_SF_IDX_96K 0x0
|
||||
#define CODEC_INFO_AAC_SF_IDX_88K 0x1
|
||||
#define CODEC_INFO_AAC_SF_IDX_64K 0x2
|
||||
#define CODEC_INFO_AAC_SF_IDX_48K 0x3
|
||||
#define CODEC_INFO_AAC_SF_IDX_44K 0x4
|
||||
#define CODEC_INFO_AAC_SF_IDX_32K 0x5
|
||||
#define CODEC_INFO_AAC_SF_IDX_24K 0x6
|
||||
#define CODEC_INFO_AAC_SF_IDX_22K 0x7
|
||||
#define CODEC_INFO_AAC_SF_IDX_16K 0x8
|
||||
#define CODEC_INFO_AAC_SF_IDX_12K 0x9
|
||||
#define CODEC_INFO_AAC_SF_IDX_11K 0xA
|
||||
#define CODEC_INFO_AAC_SF_IDX_08K 0xB
|
||||
#define CODEC_INFO_AAC_SF_IDX_RESERVE 0xC
|
||||
|
||||
#define CODEC_INFO_AAC_BR_RATE_48K 288000
|
||||
#define CODEC_INFO_AAC_BR_RATE_44K 264600
|
||||
#define CODEC_INFO_AAC_BR_RATE_32K 192000
|
||||
|
||||
#define CODEC_INFO_AAC_1_CH 1 /* center front speaker */
|
||||
#define CODEC_INFO_AAC_2_CH 2 /* left, right front speaker */
|
||||
#define CODEC_INFO_AAC_3_CH 3 /* center front speaker, left right front speaker */
|
||||
#define CODEC_INFO_AAC_4_CH 4 /* center/rear front speaker, left/right front speaker */
|
||||
#define CODEC_INFO_AAC_5_CH 5 /* center, left, right front speaker, left/right surround */
|
||||
#define CODEC_INFO_AAC_6_CH 6 /* center, left, right front speaker, left/right surround, LFE */
|
||||
#define CODEC_INFO_AAC_7_CH 7 /* (left, right)center/left,right front speaker, left/right surround, LFE */
|
||||
|
||||
typedef struct {
|
||||
uint8_t sampling_freq;
|
||||
uint8_t channel_mode;
|
||||
uint8_t block_length;
|
||||
uint8_t num_subbands;
|
||||
uint8_t alloc_method;
|
||||
uint8_t bitpool_size; /* 2 - 250 */
|
||||
} tCODEC_INFO_SBC;
|
||||
|
||||
typedef struct {
|
||||
uint8_t ch_mode;
|
||||
uint8_t sampling_freq;
|
||||
uint8_t bitrate_index; /* 0 - 14 */
|
||||
} tCODEC_INFO_MP3;
|
||||
|
||||
typedef struct {
|
||||
uint8_t ch_mode;
|
||||
uint8_t sampling_freq;
|
||||
uint8_t bitrate_index; /* 0 - 14 */
|
||||
} tCODEC_INFO_MP2;
|
||||
|
||||
typedef struct {
|
||||
uint8_t ch_mode;
|
||||
uint8_t sampling_freq;
|
||||
uint8_t bitrate_index; /* 0 - 14 */
|
||||
} tCODEC_INFO_MP2_5;
|
||||
|
||||
typedef struct {
|
||||
uint16_t sampling_freq;
|
||||
uint8_t channel_mode; /* 0x02:mono, 0x01:dual */
|
||||
uint32_t bitrate; /* 0 - 320K */
|
||||
uint32_t sbr_profile; /* 1: ON, 0: OFF */
|
||||
} tCODEC_INFO_AAC;
|
||||
|
||||
typedef union {
|
||||
tCODEC_INFO_SBC sbc;
|
||||
tCODEC_INFO_MP3 mp3;
|
||||
tCODEC_INFO_MP2 mp2;
|
||||
tCODEC_INFO_MP2_5 mp2_5;
|
||||
tCODEC_INFO_AAC aac;
|
||||
} tCODEC_INFO;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* AUDIO_CODEC_CONFIG_REQ */
|
||||
uint16_t codec_type;
|
||||
tCODEC_INFO codec_info;
|
||||
} tAUDIO_CODEC_CONFIG_REQ;
|
||||
|
||||
#define AUDIO_CONFIG_SUCCESS 0x00
|
||||
#define AUDIO_CONFIG_NOT_SUPPORTED 0x01
|
||||
#define AUDIO_CONFIG_FAIL_OUT_OF_MEMORY 0x02
|
||||
#define AUDIO_CONFIG_FAIL_CODEC_USED 0x03
|
||||
#define AUDIO_CONFIG_FAIL_ROUTE 0x04
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* AUDIO_CODEC_CONFIG_RESP */
|
||||
uint8_t status;
|
||||
} tAUDIO_CODEC_CONFIG_RESP;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* AUDIO_CODEC_SET_BITRATE_REQ */
|
||||
uint16_t codec_type;
|
||||
union {
|
||||
uint8_t sbc;
|
||||
uint8_t mp3;
|
||||
uint32_t aac;
|
||||
} codec_bitrate;
|
||||
} tAUDIO_CODEC_SET_BITRATE_REQ;
|
||||
|
||||
#define AUDIO_ROUTE_SRC_FMRX 0x00
|
||||
#define AUDIO_ROUTE_SRC_I2S 0x01
|
||||
#define AUDIO_ROUTE_SRC_ADC 0x02
|
||||
#define AUDIO_ROUTE_SRC_HOST 0x03
|
||||
#define AUDIO_ROUTE_SRC_PTU 0x04
|
||||
#define AUDIO_ROUTE_SRC_BTSNK 0x05
|
||||
#define AUDIO_ROUTE_SRC_NONE 0x80
|
||||
#define MAX_AUDIO_ROUTE_SRC 6
|
||||
|
||||
#define AUDIO_ROUTE_MIX_NONE 0x00
|
||||
#define AUDIO_ROUTE_MIX_HOST 0x01
|
||||
#define AUDIO_ROUTE_MIX_PCM 0x02
|
||||
#define AUDIO_ROUTE_MIX_CHIRP 0x03
|
||||
#define AUDIO_ROUTE_MIX_I2S 0x04
|
||||
#define AUDIO_ROUTE_MIX_ADC 0x05
|
||||
#define AUDIO_ROUTE_MIX_RESERVED 0x06
|
||||
#define MAX_AUDIO_ROUTE_MIX 7
|
||||
|
||||
#define AUDIO_ROUTE_OUT_NONE 0x0000
|
||||
#define AUDIO_ROUTE_OUT_BTA2DP 0x0001
|
||||
#define AUDIO_ROUTE_OUT_FMTX 0x0002
|
||||
#define AUDIO_ROUTE_OUT_BTSCO 0x0004
|
||||
#define AUDIO_ROUTE_OUT_HOST 0x0008
|
||||
#define AUDIO_ROUTE_OUT_DAC 0x0010
|
||||
#define AUDIO_ROUTE_OUT_I2S 0x0020
|
||||
#define AUDIO_ROUTE_OUT_BTA2DP_DAC 0x0040
|
||||
#define AUDIO_ROUTE_OUT_BTA2DP_I2S 0x0080
|
||||
#define AUDIO_ROUTE_OUT_BTSCO_DAC 0x0100
|
||||
#define AUDIO_ROUTE_OUT_BTSCO_I2S 0x0200
|
||||
#define AUDIO_ROUTE_OUT_HOST_BTA2DP 0x0400
|
||||
#define AUDIO_ROUTE_OUT_HOST_BTSCO 0x0800
|
||||
#define AUDIO_ROUTE_OUT_HOST_DAC 0x1000
|
||||
#define AUDIO_ROUTE_OUT_HOST_I2S 0x2000
|
||||
#define AUDIO_ROUTE_OUT_DAC_I2S 0x4000
|
||||
#define AUDIO_ROUTE_OUT_RESERVED_2 0x8000
|
||||
|
||||
#define MAX_AUDIO_SINGLE_ROUTE_OUT 6
|
||||
#define MAX_AUDIO_MULTI_ROUTE_OUT 16
|
||||
|
||||
#define AUDIO_ROUTE_SF_8K 0x00
|
||||
#define AUDIO_ROUTE_SF_16K 0x01
|
||||
#define AUDIO_ROUTE_SF_32K 0x02
|
||||
#define AUDIO_ROUTE_SF_44_1K 0x03
|
||||
#define AUDIO_ROUTE_SF_48K 0x04
|
||||
#define AUDIO_ROUTE_SF_11K 0x05
|
||||
#define AUDIO_ROUTE_SF_12K 0x06
|
||||
#define AUDIO_ROUTE_SF_22K 0x07
|
||||
#define AUDIO_ROUTE_SF_24K 0x08
|
||||
#define AUDIO_ROUTE_SF_NA 0xFF
|
||||
|
||||
#define AUDIO_ROUTE_EQ_BASS_BOOST 0x00
|
||||
#define AUDIO_ROUTE_EQ_CLASSIC 0x01
|
||||
#define AUDIO_ROUTE_EQ_JAZZ 0x02
|
||||
#define AUDIO_ROUTE_EQ_LIVE 0x03
|
||||
#define AUDIO_ROUTE_EQ_NORMAL 0x04
|
||||
#define AUDIO_ROUTE_EQ_ROCK 0x05
|
||||
#define AUDIO_ROUTE_EQ_BYPASS 0x06
|
||||
|
||||
#define AUDIO_ROUTE_DIGITAL_VOLUME_CONTROL 0x07
|
||||
|
||||
#define AUDIO_ROUTE_EQ_CONFIG_GAIN 0xFF /* Custion Gain Config */
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* AUDIO_ROUTE_CONFIG_REQ */
|
||||
uint8_t src;
|
||||
uint8_t src_sf;
|
||||
uint8_t out;
|
||||
uint8_t out_codec_sf;
|
||||
uint8_t out_i2s_sf;
|
||||
uint8_t eq_mode;
|
||||
} tAUDIO_ROUTE_CONFIG_REQ;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* AUDIO_ROUTE_CONFIG_RESP */
|
||||
uint8_t status;
|
||||
} tAUDIO_ROUTE_CONFIG_RESP;
|
||||
|
||||
typedef struct {
|
||||
uint16_t amp[2]; /* left/right 15 bit amplitude value */
|
||||
uint16_t tone[2]; /* left/right 12 bit frequency 0 - 4096Hz */
|
||||
uint16_t mark[2]; /* left/right 16 bit mark time 0 - 65535ms */
|
||||
uint16_t space[2]; /* left/right 16 bit space time 0 - 65535ms */
|
||||
} tCHIRP_CONFIG;
|
||||
|
||||
typedef struct {
|
||||
uint8_t pri_l; /* Primary Left scale : 0 ~ 255 */
|
||||
uint8_t mix_l; /* Mixing Left scale : 0 ~ 255 */
|
||||
uint8_t pri_r; /* Primary Right scale : 0 ~ 255 */
|
||||
uint8_t mix_r; /* Mixing Right scale : 0 ~ 255 */
|
||||
} tMIX_SCALE_CONFIG;
|
||||
|
||||
/* For custon equalizer gain configuration */
|
||||
typedef struct {
|
||||
uint32_t audio_l_g0; /* IIR biquad filter left ch gain 0 */
|
||||
uint32_t audio_l_g1; /* IIR biquad filter left ch gain 1 */
|
||||
uint32_t audio_l_g2; /* IIR biquad filter left ch gain 2 */
|
||||
uint32_t audio_l_g3; /* IIR biquad filter left ch gain 3 */
|
||||
uint32_t audio_l_g4; /* IIR biquad filter left ch gain 4 */
|
||||
uint32_t audio_l_gl; /* IIR biquad filter left ch global gain */
|
||||
uint32_t audio_r_g0; /* IIR biquad filter left ch gain 0 */
|
||||
uint32_t audio_r_g1; /* IIR biquad filter left ch gain 1 */
|
||||
uint32_t audio_r_g2; /* IIR biquad filter left ch gain 2 */
|
||||
uint32_t audio_r_g3; /* IIR biquad filter left ch gain 3 */
|
||||
uint32_t audio_r_g4; /* IIR biquad filter left ch gain 4 */
|
||||
uint32_t audio_r_gl; /* IIR biquad filter left ch global gain */
|
||||
} tEQ_GAIN_CONFIG;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* AUDIO_MIX_CONFIG_REQ */
|
||||
uint8_t mix_src;
|
||||
uint8_t mix_src_sf;
|
||||
tMIX_SCALE_CONFIG mix_scale;
|
||||
tCHIRP_CONFIG chirp_config;
|
||||
} tAUDIO_MIX_CONFIG_REQ;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* AUDIO_MIX_CONFIG_RESP */
|
||||
uint8_t status;
|
||||
} tAUDIO_MIX_CONFIG_RESP;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* AUDIO_BURST_FRAMES_IND */
|
||||
uint32_t burst_size; /* in bytes */
|
||||
} tAUDIO_BURST_FRAMES_IND;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* AUDIO_BURST_END_IND */
|
||||
} tAUDIO_BURST_END_IND;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* AUDIO_CODEC_FLUSH_REQ */
|
||||
} tAUDIO_CODEC_FLUSH_REQ;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* AUDIO_EQ_MODE_CONFIG_REQ */
|
||||
uint8_t eq_mode;
|
||||
tEQ_GAIN_CONFIG filter_gain; /* Valid only when eq_mode is 0xFF */
|
||||
} tAUDIO_EQ_MODE_CONFIG_REQ;
|
||||
|
||||
typedef struct {
|
||||
uint8_t opcode; /* AUDIO_SCALE_CONFIG_REQ */
|
||||
tMIX_SCALE_CONFIG mix_scale;
|
||||
} tAUDIO_SCALE_CONFIG_REQ;
|
||||
|
||||
#pragma pack(pop) /* pop saved alignment to stack */
|
||||
|
||||
#endif /* BT_VENDOR_UIPC_MSG_H */
|
||||
@@ -1,108 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2012 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Filename: upio.h
|
||||
*
|
||||
* Description: Contains definitions used for I/O controls
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef UPIO_H
|
||||
#define UPIO_H
|
||||
|
||||
#include <stdint.h>
|
||||
/******************************************************************************
|
||||
** Constants & Macros
|
||||
******************************************************************************/
|
||||
|
||||
#define UPIO_BT_POWER_OFF 0
|
||||
#define UPIO_BT_POWER_ON 1
|
||||
|
||||
/* UPIO signals */
|
||||
enum {
|
||||
UPIO_BT_WAKE = 0,
|
||||
UPIO_HOST_WAKE,
|
||||
UPIO_LPM_MODE,
|
||||
UPIO_MAX_COUNT
|
||||
};
|
||||
|
||||
/* UPIO assertion/deassertion */
|
||||
enum {
|
||||
UPIO_UNKNOWN = 0,
|
||||
UPIO_DEASSERT,
|
||||
UPIO_ASSERT
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
** Extern variables and functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
** Functions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function upio_init
|
||||
**
|
||||
** Description Initialization
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void upio_init(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function upio_cleanup
|
||||
**
|
||||
** Description Clean up
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void upio_cleanup(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function upio_set_bluetooth_power
|
||||
**
|
||||
** Description Interact with low layer driver to set Bluetooth power
|
||||
** on/off.
|
||||
**
|
||||
** Returns 0 : SUCCESS or Not-Applicable
|
||||
** <0 : ERROR
|
||||
**
|
||||
*******************************************************************************/
|
||||
int upio_set_bluetooth_power(int on);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function upio_set
|
||||
**
|
||||
** Description Set i/o based on polarity
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void upio_set(uint8_t pio, uint8_t action, uint8_t polarity);
|
||||
|
||||
#endif /* UPIO_H */
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright 2009-2012 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
// This module manages the serial port over which HCI commands
|
||||
// and data are sent/received.
|
||||
|
||||
#ifndef BT_VENDOR_USERIAL_H
|
||||
#define BT_VENDOR_USERIAL_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum {
|
||||
USERIAL_PORT_1,
|
||||
USERIAL_PORT_2,
|
||||
USERIAL_PORT_3,
|
||||
USERIAL_PORT_4,
|
||||
USERIAL_PORT_5,
|
||||
USERIAL_PORT_6,
|
||||
USERIAL_PORT_7,
|
||||
USERIAL_PORT_8,
|
||||
USERIAL_PORT_9,
|
||||
USERIAL_PORT_10,
|
||||
USERIAL_PORT_11,
|
||||
USERIAL_PORT_12,
|
||||
USERIAL_PORT_13,
|
||||
USERIAL_PORT_14,
|
||||
USERIAL_PORT_15,
|
||||
USERIAL_PORT_16,
|
||||
USERIAL_PORT_17,
|
||||
USERIAL_PORT_18,
|
||||
} userial_port_t;
|
||||
|
||||
// Initializes the userial module. This function should only be called once.
|
||||
// It returns true if the module was initialized, false if there was an error.
|
||||
bool userial_init(void);
|
||||
|
||||
// Opens the given serial port. Returns true if successful, false otherwise.
|
||||
// Once this function is called, the userial module will begin producing
|
||||
// buffers from data read off the serial port. If you wish to pause the
|
||||
// production of buffers, call |userial_pause_reading|. You can then resume
|
||||
// by calling |userial_resume_reading|. This function returns true if the
|
||||
// serial port was successfully opened and buffer production has started. It
|
||||
// returns false if there was an error.
|
||||
bool userial_open(userial_port_t port);
|
||||
void userial_close(void);
|
||||
void userial_close_reader(void);
|
||||
|
||||
// Reads a maximum of |len| bytes from the serial port into |p_buffer|.
|
||||
// This function returns the number of bytes actually read, which may be
|
||||
// less than |len|. This function will not block.
|
||||
uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len);
|
||||
|
||||
// Writes a maximum of |len| bytes from |p_data| to the serial port.
|
||||
// This function returns the number of bytes actually written, which may be
|
||||
// less than |len|. This function may block.
|
||||
uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len);
|
||||
#endif
|
||||
@@ -1,188 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2012 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Filename: userial_vendor.h
|
||||
*
|
||||
* Description: Contains vendor-specific definitions used in serial port
|
||||
* controls
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef USERIAL_VENDOR_H
|
||||
#define USERIAL_VENDOR_H
|
||||
|
||||
#include "bt_vendor_brcm.h"
|
||||
#include "userial.h"
|
||||
|
||||
/******************************************************************************
|
||||
** Constants & Macros
|
||||
******************************************************************************/
|
||||
|
||||
/**** baud rates ****/
|
||||
#define USERIAL_BAUD_300 0
|
||||
#define USERIAL_BAUD_600 1
|
||||
#define USERIAL_BAUD_1200 2
|
||||
#define USERIAL_BAUD_2400 3
|
||||
#define USERIAL_BAUD_9600 4
|
||||
#define USERIAL_BAUD_19200 5
|
||||
#define USERIAL_BAUD_57600 6
|
||||
#define USERIAL_BAUD_115200 7
|
||||
#define USERIAL_BAUD_230400 8
|
||||
#define USERIAL_BAUD_460800 9
|
||||
#define USERIAL_BAUD_921600 10
|
||||
#define USERIAL_BAUD_1M 11
|
||||
#define USERIAL_BAUD_1_5M 12
|
||||
#define USERIAL_BAUD_2M 13
|
||||
#define USERIAL_BAUD_3M 14
|
||||
#define USERIAL_BAUD_4M 15
|
||||
#define USERIAL_BAUD_AUTO 16
|
||||
|
||||
#define USERIAL_LINESPEED_600 600
|
||||
#define USERIAL_LINESPEED_1200 1200
|
||||
#define USERIAL_LINESPEED_2400 2400
|
||||
#define USERIAL_LINESPEED_9600 9600
|
||||
#define USERIAL_LINESPEED_19200 19200
|
||||
#define USERIAL_LINESPEED_57600 57600
|
||||
#define USERIAL_LINESPEED_115200 115200
|
||||
#define USERIAL_LINESPEED_230400 230400
|
||||
#define USERIAL_LINESPEED_460800 460800
|
||||
#define USERIAL_LINESPEED_921600 921600
|
||||
#define USERIAL_LINESPEED_1M 1000000
|
||||
#define USERIAL_LINESPEED_1_5M 1500000
|
||||
#define USERIAL_LINESPEED_2M 2000000
|
||||
#define USERIAL_LINESPEED_3M 3000000
|
||||
#define USERIAL_LINESPEED_4M 4000000
|
||||
|
||||
/**** Data Format ****/
|
||||
/* Stop Bits */
|
||||
#define USERIAL_STOPBITS_1 1
|
||||
#define USERIAL_STOPBITS_1_5 (1 << 1)
|
||||
#define USERIAL_STOPBITS_2 (1 << 2)
|
||||
|
||||
/* Parity Bits */
|
||||
#define USERIAL_PARITY_NONE (1 << 3)
|
||||
#define USERIAL_PARITY_EVEN (1 << 4)
|
||||
#define USERIAL_PARITY_ODD (1 << 5)
|
||||
|
||||
/* Data Bits */
|
||||
#define USERIAL_DATABITS_5 (1 << 6)
|
||||
#define USERIAL_DATABITS_6 (1 << 7)
|
||||
#define USERIAL_DATABITS_7 (1 << 8)
|
||||
#define USERIAL_DATABITS_8 (1 << 9)
|
||||
|
||||
#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE)
|
||||
/* These are the ioctl values used for bt_wake ioctl via UART driver. you may
|
||||
* need to redefine them on you platform!
|
||||
* Logically they need to be unique and not colide with existing uart ioctl's.
|
||||
*/
|
||||
#ifndef USERIAL_IOCTL_BT_WAKE_ASSERT
|
||||
#define USERIAL_IOCTL_BT_WAKE_ASSERT 0x8003
|
||||
#endif
|
||||
#ifndef USERIAL_IOCTL_BT_WAKE_DEASSERT
|
||||
#define USERIAL_IOCTL_BT_WAKE_DEASSERT 0x8004
|
||||
#endif
|
||||
#ifndef USERIAL_IOCTL_BT_WAKE_GET_ST
|
||||
#define USERIAL_IOCTL_BT_WAKE_GET_ST 0x8005
|
||||
#endif
|
||||
#endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
|
||||
|
||||
/******************************************************************************
|
||||
** Type definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* Structure used to configure serial port during open */
|
||||
typedef struct {
|
||||
uint16_t fmt; /* Data format */
|
||||
uint8_t baud; /* Baud rate */
|
||||
} tUSERIAL_CFG;
|
||||
|
||||
typedef enum {
|
||||
#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE)
|
||||
USERIAL_OP_ASSERT_BT_WAKE,
|
||||
USERIAL_OP_DEASSERT_BT_WAKE,
|
||||
USERIAL_OP_GET_BT_WAKE_STATE,
|
||||
#endif
|
||||
USERIAL_OP_NOP,
|
||||
} userial_vendor_ioctl_op_t;
|
||||
|
||||
/******************************************************************************
|
||||
** Extern variables and functions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
** Functions
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function userial_vendor_init
|
||||
**
|
||||
** Description Initialize userial vendor-specific control block
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void userial_vendor_init(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function userial_vendor_open
|
||||
**
|
||||
** Description Open the serial port with the given configuration
|
||||
**
|
||||
** Returns device fd
|
||||
**
|
||||
*******************************************************************************/
|
||||
int userial_vendor_open(tUSERIAL_CFG *p_cfg);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function userial_vendor_close
|
||||
**
|
||||
** Description Conduct vendor-specific close work
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void userial_vendor_close(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function userial_vendor_set_baud
|
||||
**
|
||||
** Description Set new baud rate
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void userial_vendor_set_baud(uint8_t userial_baud);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function userial_vendor_ioctl
|
||||
**
|
||||
** Description ioctl inteface
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void userial_vendor_ioctl(userial_vendor_ioctl_op_t op, void *p_data);
|
||||
|
||||
#endif /* USERIAL_VENDOR_H */
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright© 2021–2022 Beijing OSWare Technology Co., Ltd
|
||||
* This file contains confidential and proprietary information of
|
||||
* OSWare Technology Co., Ltd
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef BT_VENDOR_LOG_H
|
||||
#define BT_VENDOR_LOG_H
|
||||
|
||||
#include "hilog/log.h"
|
||||
|
||||
#define HILOGD(...) HiLogPrint(LOG_CORE, LOG_DEBUG, LOG_DOMAIN, "BTVENDOR", __VA_ARGS__)
|
||||
#define HILOGI(...) HiLogPrint(LOG_CORE, LOG_INFO, LOG_DOMAIN, "BTVENDOR", __VA_ARGS__)
|
||||
#define HILOGW(...) HiLogPrint(LOG_CORE, LOG_WARN, LOG_DOMAIN, "BTVENDOR", __VA_ARGS__)
|
||||
#define HILOGE(...) HiLogPrint(LOG_CORE, LOG_ERROR, LOG_DOMAIN, "BTVENDOR", __VA_ARGS__)
|
||||
|
||||
#endif
|
||||
@@ -1,219 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2012 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Filename: bt_vendor_brcm.c
|
||||
*
|
||||
* Description: Broadcom vendor specific library implementation
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#define LOG_TAG "bt_vendor"
|
||||
|
||||
#include <utils/Log.h>
|
||||
#include <string.h>
|
||||
#include "upio.h"
|
||||
#include "userial_vendor.h"
|
||||
#include "bt_vendor_brcm.h"
|
||||
|
||||
#ifndef BTVND_DBG
|
||||
#define BTVND_DBG FALSE
|
||||
#endif
|
||||
|
||||
#if (BTVND_DBG == TRUE)
|
||||
#define BTVNDDBG(param, ...) \
|
||||
{ \
|
||||
HILOGD(param, ##__VA_ARGS__); \
|
||||
}
|
||||
#else
|
||||
#define BTVNDDBG(param, ...) \
|
||||
{ \
|
||||
HILOGD(param, ##__VA_ARGS__); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
** Externs
|
||||
******************************************************************************/
|
||||
|
||||
void hw_config_start(void);
|
||||
uint8_t hw_lpm_enable(uint8_t turn_on);
|
||||
uint32_t hw_lpm_get_idle_timeout(void);
|
||||
void hw_lpm_set_wake_state(uint8_t wake_assert);
|
||||
#if (SCO_CFG_INCLUDED == TRUE)
|
||||
void hw_sco_config(void);
|
||||
#endif
|
||||
void vnd_load_conf(const char *p_path);
|
||||
#if (HW_END_WITH_HCI_RESET == TRUE)
|
||||
void hw_epilog_process(void);
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
** Variables
|
||||
******************************************************************************/
|
||||
|
||||
bt_vendor_callbacks_t *bt_vendor_cbacks = NULL;
|
||||
uint8_t vnd_local_bd_addr[BD_ADDR_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
/******************************************************************************
|
||||
** Local type definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
** Static Variables
|
||||
******************************************************************************/
|
||||
|
||||
static const tUSERIAL_CFG userial_init_cfg = {
|
||||
(USERIAL_DATABITS_8 | USERIAL_PARITY_NONE | USERIAL_STOPBITS_1),
|
||||
USERIAL_BAUD_115200
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
** Functions
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
**
|
||||
** BLUETOOTH VENDOR INTERFACE LIBRARY FUNCTIONS
|
||||
**
|
||||
*****************************************************************************/
|
||||
/** LPM disable/enable request */
|
||||
typedef enum {
|
||||
BT_VND_LPM_DISABLE,
|
||||
BT_VND_LPM_ENABLE,
|
||||
} bt_vendor_lpm_mode_t;
|
||||
|
||||
static int init(const bt_vendor_callbacks_t *p_cb, unsigned char *local_bdaddr)
|
||||
{
|
||||
HILOGI("init, bdaddr:%02x%02x:%02x%02x:%02x%02x", local_bdaddr[0], local_bdaddr[1], local_bdaddr[2],
|
||||
local_bdaddr[3], local_bdaddr[4], local_bdaddr[5]);
|
||||
|
||||
if (p_cb == NULL) {
|
||||
HILOGE("init failed with no user callbacks!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if (VENDOR_LIB_RUNTIME_TUNING_ENABLED == TRUE)
|
||||
HILOGW("*****************************************************************");
|
||||
HILOGW("*****************************************************************");
|
||||
HILOGW("** Warning - BT Vendor Lib is loaded in debug tuning mode!");
|
||||
HILOGW("**");
|
||||
HILOGW("** If this is not intentional, rebuild libbt-vendor.so ");
|
||||
HILOGW("** with VENDOR_LIB_RUNTIME_TUNING_ENABLED=FALSE and ");
|
||||
HILOGW("** check if any run-time tuning parameters needed to be");
|
||||
HILOGW("** carried to the build-time configuration accordingly.");
|
||||
HILOGW("*****************************************************************");
|
||||
HILOGW("*****************************************************************");
|
||||
#endif
|
||||
|
||||
userial_vendor_init();
|
||||
upio_init();
|
||||
|
||||
vnd_load_conf(VENDOR_LIB_CONF_FILE);
|
||||
|
||||
/* store reference to user callbacks */
|
||||
bt_vendor_cbacks = (bt_vendor_callbacks_t *)p_cb;
|
||||
|
||||
#if (BRCM_A2DP_OFFLOAD == TRUE)
|
||||
brcm_vnd_a2dp_init(bt_vendor_cbacks);
|
||||
#endif
|
||||
|
||||
/* This is handed over from the stack */
|
||||
return memcpy_s(vnd_local_bd_addr, BD_ADDR_LEN, local_bdaddr, BD_ADDR_LEN);
|
||||
}
|
||||
|
||||
/** Requested operations */
|
||||
static int op(bt_opcode_t opcode, void *param)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
switch (opcode) {
|
||||
case BT_OP_POWER_ON: // BT_VND_OP_POWER_CTRL
|
||||
upio_set_bluetooth_power(UPIO_BT_POWER_OFF);
|
||||
upio_set_bluetooth_power(UPIO_BT_POWER_ON);
|
||||
break;
|
||||
|
||||
case BT_OP_POWER_OFF: // BT_VND_OP_POWER_CTRL
|
||||
upio_set_bluetooth_power(UPIO_BT_POWER_OFF);
|
||||
hw_lpm_set_wake_state(false);
|
||||
break;
|
||||
|
||||
case BT_OP_HCI_CHANNEL_OPEN: { // BT_VND_OP_USERIAL_OPEN
|
||||
int(*fd_array)[] = (int(*)[])param;
|
||||
int fd, idx;
|
||||
fd = userial_vendor_open((tUSERIAL_CFG *)&userial_init_cfg);
|
||||
if (fd != -1) {
|
||||
for (idx = 0; idx < HCI_MAX_CHANNEL; idx++)
|
||||
(*fd_array)[idx] = fd;
|
||||
|
||||
retval = 1;
|
||||
}
|
||||
/* retval contains numbers of open fd of HCI channels */
|
||||
break;
|
||||
}
|
||||
case BT_OP_HCI_CHANNEL_CLOSE: // BT_VND_OP_USERIAL_CLOSE
|
||||
userial_vendor_close();
|
||||
break;
|
||||
|
||||
case BT_OP_INIT: // BT_VND_OP_FW_CFG
|
||||
hw_config_start();
|
||||
break;
|
||||
|
||||
case BT_OP_GET_LPM_TIMER: { // BT_VND_OP_GET_LPM_IDLE_TIMEOUT
|
||||
uint32_t *timeout_ms = (uint32_t *)param;
|
||||
*timeout_ms = hw_lpm_get_idle_timeout();
|
||||
break;
|
||||
}
|
||||
|
||||
case BT_OP_LPM_ENABLE:
|
||||
retval = hw_lpm_enable(BT_VND_LPM_ENABLE);
|
||||
break;
|
||||
|
||||
case BT_OP_LPM_DISABLE:
|
||||
retval = hw_lpm_enable(BT_VND_LPM_DISABLE);
|
||||
break;
|
||||
|
||||
case BT_OP_WAKEUP_LOCK:
|
||||
hw_lpm_set_wake_state(TRUE);
|
||||
break;
|
||||
case BT_OP_WAKEUP_UNLOCK:
|
||||
hw_lpm_set_wake_state(FALSE);
|
||||
break;
|
||||
case BT_OP_EVENT_CALLBACK:
|
||||
hw_process_event((HC_BT_HDR *)param);
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/** Closes the interface */
|
||||
static void cleanup(void)
|
||||
{
|
||||
BTVNDDBG("cleanup");
|
||||
upio_cleanup();
|
||||
bt_vendor_cbacks = NULL;
|
||||
}
|
||||
|
||||
// Entry point of DLib
|
||||
const bt_vendor_interface_t BLUETOOTH_VENDOR_LIB_INTERFACE = {
|
||||
sizeof(bt_vendor_interface_t),
|
||||
init,
|
||||
op,
|
||||
cleanup};
|
||||
@@ -1,136 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2012 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Filename: conf.c
|
||||
*
|
||||
* Description: Contains functions to conduct run-time module configuration
|
||||
* based on entries present in the .conf file
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#define LOG_TAG "bt_vnd_conf"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <utils/Log.h>
|
||||
#include "bt_vendor_brcm.h"
|
||||
|
||||
/******************************************************************************
|
||||
** Externs
|
||||
******************************************************************************/
|
||||
int userial_set_port(char *p_conf_name, char *p_conf_value, int param);
|
||||
int hw_set_patch_file_path(char *p_conf_name, char *p_conf_value, int param);
|
||||
int hw_set_patch_file_name(char *p_conf_name, char *p_conf_value, int param);
|
||||
#if (VENDOR_LIB_RUNTIME_TUNING_ENABLED == TRUE)
|
||||
int hw_set_patch_settlement_delay(char *p_conf_name, char *p_conf_value, int param);
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
** Local type definitions
|
||||
******************************************************************************/
|
||||
|
||||
#define CONF_COMMENT '#'
|
||||
#define CONF_DELIMITERS " =\n\r\t"
|
||||
#define CONF_VALUES_DELIMITERS "=\n\r\t"
|
||||
#define CONF_MAX_LINE_LEN 255
|
||||
|
||||
typedef int(conf_action_t)(char *p_conf_name, char *p_conf_value, int param);
|
||||
|
||||
typedef struct {
|
||||
const char *conf_entry;
|
||||
conf_action_t *p_action;
|
||||
int param;
|
||||
} conf_entry_t;
|
||||
|
||||
/******************************************************************************
|
||||
** Static variables
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Current supported entries and corresponding action functions
|
||||
*/
|
||||
static const conf_entry_t conf_table[] = {
|
||||
{"UartPort", userial_set_port, 0},
|
||||
{"FwPatchFilePath", hw_set_patch_file_path, 0},
|
||||
{"FwPatchFileName", hw_set_patch_file_name, 0},
|
||||
#if (VENDOR_LIB_RUNTIME_TUNING_ENABLED == TRUE)
|
||||
{"FwPatchSettlementDelay", hw_set_patch_settlement_delay, 0},
|
||||
#endif
|
||||
{(const char *)NULL, NULL, 0}
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
** CONF INTERFACE FUNCTIONS
|
||||
*****************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function vnd_load_conf
|
||||
**
|
||||
** Description Read conf entry from p_path file one by one and call
|
||||
** the corresponding config function
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void vnd_load_conf(const char *p_path)
|
||||
{
|
||||
FILE *p_file;
|
||||
char *p_name;
|
||||
char *p_value;
|
||||
conf_entry_t *p_entry;
|
||||
char line[CONF_MAX_LINE_LEN + 1]; /* add 1 for \0 char */
|
||||
|
||||
HILOGI("Attempt to load conf from %s", p_path);
|
||||
if ((p_file = fopen(p_path, "r")) == NULL) {
|
||||
HILOGI("vnd_load_conf file >%s< not found", p_path);
|
||||
return;
|
||||
}
|
||||
|
||||
/* read line by line */
|
||||
while (fgets(line, CONF_MAX_LINE_LEN + 1, p_file) != NULL) {
|
||||
if (line[0] == CONF_COMMENT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
p_name = strtok(line, CONF_DELIMITERS);
|
||||
if (p_name == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
p_value = strtok(NULL, CONF_DELIMITERS);
|
||||
if (p_value == NULL) {
|
||||
HILOGW("vnd_load_conf: missing value for name: %s", p_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
p_entry = (conf_entry_t *)conf_table;
|
||||
while (p_entry->conf_entry != NULL) {
|
||||
if (strcmp(p_entry->conf_entry, (const char *)p_name) == 0) {
|
||||
p_entry->p_action(p_name, p_value, p_entry->param);
|
||||
break;
|
||||
}
|
||||
|
||||
p_entry++;
|
||||
}
|
||||
}
|
||||
|
||||
(void)fclose(p_file);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,482 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2012 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Filename: upio.c
|
||||
*
|
||||
* Description: Contains I/O functions, like
|
||||
* rfkill control
|
||||
* BT_WAKE/HOST_WAKE control
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#define LOG_TAG "bt_upio"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <utils/Log.h>
|
||||
#include "bt_vendor_brcm.h"
|
||||
#include "userial_vendor.h"
|
||||
#include "upio.h"
|
||||
|
||||
/******************************************************************************
|
||||
** Constants & Macros
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef UPIO_DBG
|
||||
#define UPIO_DBG FALSE
|
||||
#endif
|
||||
|
||||
#if (UPIO_DBG == TRUE)
|
||||
#define UPIODBG(param, ...) \
|
||||
{ \
|
||||
HILOGD(param, ##__VA_ARGS__); \
|
||||
}
|
||||
#else
|
||||
#define UPIODBG(param, ...) \
|
||||
{ \
|
||||
HILOGD(param, ##__VA_ARGS__); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
** Local type definitions
|
||||
******************************************************************************/
|
||||
|
||||
#if (BT_WAKE_VIA_PROC == TRUE)
|
||||
|
||||
/* proc fs node for enable/disable lpm mode */
|
||||
#ifndef VENDOR_LPM_PROC_NODE
|
||||
#define VENDOR_LPM_PROC_NODE "/proc/bluetooth/sleep/lpm"
|
||||
#endif
|
||||
|
||||
/* proc fs node for notifying write request */
|
||||
#ifndef VENDOR_BTWRITE_PROC_NODE
|
||||
#define VENDOR_BTWRITE_PROC_NODE "/proc/bluetooth/sleep/btwrite"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Maximum btwrite assertion holding time without consecutive btwrite kicking.
|
||||
* This value is correlative(shorter) to the in-working timeout period set in
|
||||
* the bluesleep LPM code. The current value used in bluesleep is 10sec.
|
||||
*/
|
||||
#ifndef PROC_BTWRITE_TIMER_TIMEOUT_MS
|
||||
#define PROC_BTWRITE_TIMER_TIMEOUT_MS 8000
|
||||
#endif
|
||||
|
||||
/* lpm proc control block */
|
||||
typedef struct {
|
||||
uint8_t btwrite_active;
|
||||
uint8_t timer_created;
|
||||
timer_t timer_id;
|
||||
uint32_t timeout_ms;
|
||||
} vnd_lpm_proc_cb_t;
|
||||
|
||||
static vnd_lpm_proc_cb_t lpm_proc_cb;
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
** Static variables
|
||||
******************************************************************************/
|
||||
|
||||
static uint8_t upio_state[UPIO_MAX_COUNT];
|
||||
static int rfkill_id = -1;
|
||||
static int bt_emul_enable = 0;
|
||||
static char rfkill_state_path[128];
|
||||
|
||||
/******************************************************************************
|
||||
** Static functions
|
||||
******************************************************************************/
|
||||
|
||||
/* for friendly debugging outpout string */
|
||||
static char *lpm_mode[] = {
|
||||
"UNKNOWN",
|
||||
"disabled",
|
||||
"enabled"
|
||||
};
|
||||
|
||||
static char *lpm_state[] = {
|
||||
"UNKNOWN",
|
||||
"de-asserted",
|
||||
"asserted"
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
** Bluetooth On/Off Static Functions
|
||||
*****************************************************************************/
|
||||
static int is_emulator_context(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int is_rfkill_disabled(void)
|
||||
{
|
||||
return UPIO_BT_POWER_OFF;
|
||||
}
|
||||
|
||||
static int init_rfkill(void)
|
||||
{
|
||||
char path[64];
|
||||
char buf[16];
|
||||
int fd, sz, id;
|
||||
|
||||
for (id = 0;; id++) {
|
||||
if (snprintf_s(path, sizeof(path), sizeof(path), "/sys/class/rfkill/rfkill%d/type", id) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
HILOGE("init_rfkill : open(%s) failed: %s (%d)\n",
|
||||
path, strerror(errno), errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
sz = read(fd, &buf, sizeof(buf));
|
||||
close(fd);
|
||||
|
||||
if (sz >= (int)strlen("bluetooth") && memcmp(buf, "bluetooth", strlen("bluetooth")) == 0) {
|
||||
rfkill_id = id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
(void)sprintf_s(rfkill_state_path, sizeof(rfkill_state_path), "/sys/class/rfkill/rfkill%d/state", rfkill_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** LPM Static Functions
|
||||
*****************************************************************************/
|
||||
|
||||
#if (BT_WAKE_VIA_PROC == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function proc_btwrite_timeout
|
||||
**
|
||||
** Description Timeout thread of proc/.../btwrite assertion holding timer
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void proc_btwrite_timeout(union sigval arg)
|
||||
{
|
||||
UPIODBG("..%s..", __FUNCTION__);
|
||||
lpm_proc_cb.btwrite_active = FALSE;
|
||||
/* drive LPM down; this timer should fire only when BT is awake; */
|
||||
upio_set(UPIO_BT_WAKE, UPIO_DEASSERT, 1);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function upio_start_stop_timer
|
||||
**
|
||||
** Description Arm user space timer in case lpm is left asserted
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*****************************************************************************/
|
||||
void upio_start_stop_timer(int action)
|
||||
{
|
||||
struct itimerspec ts;
|
||||
|
||||
if (action == UPIO_ASSERT) {
|
||||
lpm_proc_cb.btwrite_active = TRUE;
|
||||
if (lpm_proc_cb.timer_created == TRUE) {
|
||||
ts.it_value.tv_sec = PROC_BTWRITE_TIMER_TIMEOUT_MS / BT_VENDOR_TIME_RAIDX;
|
||||
ts.it_value.tv_nsec = BT_VENDOR_TIME_RAIDX * BT_VENDOR_TIME_RAIDX *
|
||||
(PROC_BTWRITE_TIMER_TIMEOUT_MS % BT_VENDOR_TIME_RAIDX);
|
||||
ts.it_interval.tv_sec = 0;
|
||||
ts.it_interval.tv_nsec = 0;
|
||||
}
|
||||
} else {
|
||||
/* unarm timer if writing 0 to lpm; reduce unnecessary user space wakeup */
|
||||
(void)memset_s(&ts, sizeof(ts), 0, sizeof(ts));
|
||||
}
|
||||
|
||||
if (timer_settime(lpm_proc_cb.timer_id, 0, &ts, 0) == 0) {
|
||||
UPIODBG("%s : timer_settime success", __FUNCTION__);
|
||||
} else {
|
||||
UPIODBG("%s : timer_settime failed", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
** UPIO Interface Functions
|
||||
*****************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function upio_init
|
||||
**
|
||||
** Description Initialization
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void upio_init(void)
|
||||
{
|
||||
memset_s(upio_state, sizeof(upio_state), UPIO_UNKNOWN, UPIO_MAX_COUNT);
|
||||
#if (BT_WAKE_VIA_PROC == TRUE)
|
||||
memset_s(&lpm_proc_cb, sizeof(vnd_lpm_proc_cb_t), 0, sizeof(vnd_lpm_proc_cb_t));
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function upio_cleanup
|
||||
**
|
||||
** Description Clean up
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void upio_cleanup(void)
|
||||
{
|
||||
#if (BT_WAKE_VIA_PROC == TRUE)
|
||||
if (lpm_proc_cb.timer_created == TRUE)
|
||||
timer_delete(lpm_proc_cb.timer_id);
|
||||
|
||||
lpm_proc_cb.timer_created = FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function upio_set_bluetooth_power
|
||||
**
|
||||
** Description Interact with low layer driver to set Bluetooth power
|
||||
** on/off.
|
||||
**
|
||||
** Returns 0 : SUCCESS or Not-Applicable
|
||||
** <0 : ERROR
|
||||
**
|
||||
*******************************************************************************/
|
||||
int upio_set_bluetooth_power(int on)
|
||||
{
|
||||
int sz;
|
||||
int fd = -1;
|
||||
int ret = -1;
|
||||
char buffer = '0';
|
||||
|
||||
switch (on) {
|
||||
case UPIO_BT_POWER_OFF:
|
||||
buffer = '0';
|
||||
break;
|
||||
|
||||
case UPIO_BT_POWER_ON:
|
||||
buffer = '1';
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (is_emulator_context()) {
|
||||
/* if new value is same as current, return -1 */
|
||||
if (bt_emul_enable == on) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
UPIODBG("set_bluetooth_power [emul] %d", on);
|
||||
bt_emul_enable = on;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* check if we have rfkill interface */
|
||||
if (is_rfkill_disabled()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (rfkill_id == -1) {
|
||||
if (init_rfkill()) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
fd = open(rfkill_state_path, O_WRONLY);
|
||||
if (fd < 0) {
|
||||
HILOGE("set_bluetooth_power : open(%s) for write failed: %s (%d)",
|
||||
rfkill_state_path, strerror(errno), errno);
|
||||
return ret;
|
||||
}
|
||||
|
||||
sz = write(fd, &buffer, 1);
|
||||
if (sz < 0) {
|
||||
HILOGE("set_bluetooth_power : write(%s) failed: %s (%d)",
|
||||
rfkill_state_path, strerror(errno), errno);
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
if (fd >= 0) {
|
||||
close(fd);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function upio_set
|
||||
**
|
||||
** Description Set i/o based on polarity
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void upio_set(uint8_t pio, uint8_t action, uint8_t polarity)
|
||||
{
|
||||
int rc;
|
||||
#if (BT_WAKE_VIA_PROC == TRUE)
|
||||
int fd = -1;
|
||||
char buffer;
|
||||
#endif
|
||||
UPIODBG("%s : pio %d action %d, polarity %d", __FUNCTION__, pio, action, polarity);
|
||||
switch (pio) {
|
||||
case UPIO_LPM_MODE:
|
||||
if (upio_state[UPIO_LPM_MODE] == action) {
|
||||
UPIODBG("LPM is %s already", lpm_mode[action]);
|
||||
return;
|
||||
}
|
||||
upio_state[UPIO_LPM_MODE] = action;
|
||||
#if (BT_WAKE_VIA_PROC == TRUE)
|
||||
fd = open(VENDOR_LPM_PROC_NODE, O_WRONLY);
|
||||
if (fd < 0) {
|
||||
LOGE("upio_set : open(%s) for write failed: %s (%d)",
|
||||
VENDOR_LPM_PROC_NODE, strerror(errno), errno);
|
||||
return;
|
||||
}
|
||||
if (action == UPIO_ASSERT) {
|
||||
buffer = '1';
|
||||
} else {
|
||||
buffer = '0';
|
||||
// delete btwrite assertion holding timer
|
||||
if (lpm_proc_cb.timer_created == TRUE) {
|
||||
timer_delete(lpm_proc_cb.timer_id);
|
||||
lpm_proc_cb.timer_created = FALSE;
|
||||
}
|
||||
}
|
||||
if (write(fd, &buffer, 1) < 0) {
|
||||
LOGE("upio_set : write(%s) failed: %s (%d)",
|
||||
VENDOR_LPM_PROC_NODE, strerror(errno), errno);
|
||||
#if (PROC_BTWRITE_TIMER_TIMEOUT_MS != 0)
|
||||
} else {
|
||||
if (action == UPIO_ASSERT) {
|
||||
// create btwrite assertion holding timer
|
||||
if (lpm_proc_cb.timer_created == FALSE) {
|
||||
int status;
|
||||
struct sigevent se;
|
||||
se.sigev_notify = SIGEV_THREAD;
|
||||
se.sigev_value.sival_ptr = &lpm_proc_cb.timer_id;
|
||||
se.sigev_notify_function = proc_btwrite_timeout;
|
||||
se.sigev_notify_attributes = NULL;
|
||||
status = timer_create(CLOCK_MONOTONIC, &se,
|
||||
&lpm_proc_cb.timer_id);
|
||||
if (status == 0)
|
||||
lpm_proc_cb.timer_created = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
#endif
|
||||
break;
|
||||
case UPIO_BT_WAKE:
|
||||
if (upio_state[UPIO_BT_WAKE] == action) {
|
||||
UPIODBG("BT_WAKE is %s already", lpm_state[action]);
|
||||
#if (BT_WAKE_VIA_PROC == TRUE)
|
||||
if (lpm_proc_cb.btwrite_active == TRUE) {
|
||||
/*
|
||||
* The proc btwrite node could have not been updated for
|
||||
* certain time already due to heavy downstream path flow.
|
||||
* In this case, we want to explicity touch proc btwrite
|
||||
* node to keep the bt_wake assertion in the LPM kernel
|
||||
* driver. The current kernel bluesleep LPM code starts
|
||||
* a 10sec internal in-activity timeout timer before it
|
||||
* attempts to deassert BT_WAKE line.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
upio_state[UPIO_BT_WAKE] = action;
|
||||
#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE)
|
||||
userial_vendor_ioctl(( (action == UPIO_ASSERT) ? \
|
||||
USERIAL_OP_ASSERT_BT_WAKE : USERIAL_OP_DEASSERT_BT_WAKE), \
|
||||
NULL);
|
||||
#elif (BT_WAKE_VIA_PROC == TRUE)
|
||||
/*
|
||||
* Kick proc btwrite node only at UPIO_ASSERT
|
||||
*/
|
||||
#if (BT_WAKE_VIA_PROC_NOTIFY_DEASSERT == FALSE)
|
||||
if (action == UPIO_DEASSERT)
|
||||
return;
|
||||
#endif
|
||||
fd = open(VENDOR_BTWRITE_PROC_NODE, O_WRONLY);
|
||||
if (fd < 0) {
|
||||
LOGE("upio_set : open(%s) for write failed: %s (%d)",
|
||||
VENDOR_BTWRITE_PROC_NODE, strerror(errno), errno);
|
||||
return;
|
||||
}
|
||||
#if (BT_WAKE_VIA_PROC_NOTIFY_DEASSERT == TRUE)
|
||||
if (action == UPIO_DEASSERT) {
|
||||
buffer = '0';
|
||||
} else {
|
||||
#endif
|
||||
buffer = '1';
|
||||
#if (BT_WAKE_VIA_PROC_NOTIFY_DEASSERT == TRUE)
|
||||
}
|
||||
#endif
|
||||
if (write(fd, &buffer, 1) < 0) {
|
||||
LOGE("upio_set : write(%s) failed: %s (%d)",
|
||||
VENDOR_BTWRITE_PROC_NODE, strerror(errno), errno);
|
||||
#if (PROC_BTWRITE_TIMER_TIMEOUT_MS != 0)
|
||||
} else {
|
||||
/* arm user space timer based on action */
|
||||
upio_start_stop_timer(action);
|
||||
}
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (BT_WAKE_VIA_PROC_NOTIFY_DEASSERT == TRUE)
|
||||
lpm_proc_cb.btwrite_active = TRUE;
|
||||
#endif
|
||||
UPIODBG("%s: proc btwrite assertion, buffer: %c, timer_armed %d %d",
|
||||
__FUNCTION__, buffer, lpm_proc_cb.btwrite_active, lpm_proc_cb.timer_created);
|
||||
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
#endif
|
||||
break;
|
||||
case UPIO_HOST_WAKE:
|
||||
UPIODBG("upio_set: UPIO_HOST_WAKE");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1,364 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2012 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Filename: userial_vendor.c
|
||||
*
|
||||
* Description: Contains vendor-specific userial functions
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#define LOG_TAG "bt_userial_vendor"
|
||||
|
||||
#include <termios.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <utils/Log.h>
|
||||
#include "bt_vendor_brcm.h"
|
||||
#include "userial.h"
|
||||
#include "userial_vendor.h"
|
||||
|
||||
/******************************************************************************
|
||||
** Constants & Macros
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef VNDUSERIAL_DBG
|
||||
#define VNDUSERIAL_DBG FALSE
|
||||
#endif
|
||||
|
||||
#if (VNDUSERIAL_DBG == TRUE)
|
||||
#define VNDUSERIALDBG(param, ...) \
|
||||
{ \
|
||||
HILOGD(param, ##__VA_ARGS__); \
|
||||
}
|
||||
#else
|
||||
#define VNDUSERIALDBG(param, ...) \
|
||||
{ \
|
||||
HILOGD(param, ##__VA_ARGS__); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define VND_PORT_NAME_MAXLEN 256
|
||||
|
||||
/******************************************************************************
|
||||
** Local type definitions
|
||||
******************************************************************************/
|
||||
|
||||
/* vendor serial control block */
|
||||
typedef struct {
|
||||
int fd; /* fd to Bluetooth device */
|
||||
struct termios termios; /* serial terminal of BT port */
|
||||
char port_name[VND_PORT_NAME_MAXLEN];
|
||||
} vnd_userial_cb_t;
|
||||
|
||||
/******************************************************************************
|
||||
** Static variables
|
||||
******************************************************************************/
|
||||
|
||||
static vnd_userial_cb_t vnd_userial;
|
||||
|
||||
/*****************************************************************************
|
||||
** Helper Functions
|
||||
*****************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function userial_to_tcio_baud
|
||||
**
|
||||
** Description helper function converts USERIAL baud rates into TCIO
|
||||
** conforming baud rates
|
||||
**
|
||||
** Returns TRUE/FALSE
|
||||
**
|
||||
*******************************************************************************/
|
||||
uint8_t userial_to_tcio_baud(uint8_t cfg_baud, uint32_t *baud)
|
||||
{
|
||||
if (cfg_baud == USERIAL_BAUD_115200)
|
||||
*baud = B115200;
|
||||
else if (cfg_baud == USERIAL_BAUD_4M)
|
||||
*baud = B4000000;
|
||||
else if (cfg_baud == USERIAL_BAUD_3M)
|
||||
*baud = B3000000;
|
||||
else if (cfg_baud == USERIAL_BAUD_2M)
|
||||
*baud = B2000000;
|
||||
else if (cfg_baud == USERIAL_BAUD_1_5M)
|
||||
*baud = B1500000;
|
||||
else if (cfg_baud == USERIAL_BAUD_1M)
|
||||
*baud = B1000000;
|
||||
else if (cfg_baud == USERIAL_BAUD_921600)
|
||||
*baud = B921600;
|
||||
else if (cfg_baud == USERIAL_BAUD_460800)
|
||||
*baud = B460800;
|
||||
else if (cfg_baud == USERIAL_BAUD_230400)
|
||||
*baud = B230400;
|
||||
else if (cfg_baud == USERIAL_BAUD_57600)
|
||||
*baud = B57600;
|
||||
else if (cfg_baud == USERIAL_BAUD_19200)
|
||||
*baud = B19200;
|
||||
else if (cfg_baud == USERIAL_BAUD_9600)
|
||||
*baud = B9600;
|
||||
else if (cfg_baud == USERIAL_BAUD_1200)
|
||||
*baud = B1200;
|
||||
else if (cfg_baud == USERIAL_BAUD_600)
|
||||
*baud = B600;
|
||||
else {
|
||||
HILOGE("userial vendor open: unsupported baud idx %i", cfg_baud);
|
||||
*baud = B115200;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function userial_ioctl_init_bt_wake
|
||||
**
|
||||
** Description helper function to set the open state of the bt_wake if ioctl
|
||||
** is used. it should not hurt in the rfkill case but it might
|
||||
** be better to compile it out.
|
||||
**
|
||||
** Returns none
|
||||
**
|
||||
*******************************************************************************/
|
||||
void userial_ioctl_init_bt_wake(int fd)
|
||||
{
|
||||
uint32_t bt_wake_state;
|
||||
|
||||
#if (BT_WAKE_USERIAL_LDISC == TRUE)
|
||||
int ldisc = N_BRCM_HCI; /* brcm sleep mode support line discipline */
|
||||
|
||||
/* attempt to load enable discipline driver */
|
||||
if (ioctl(vnd_userial.fd, TIOCSETD, &ldisc) < 0) {
|
||||
VNDUSERIALDBG("USERIAL_Open():fd %d, TIOCSETD failed: error %d for ldisc: %d",
|
||||
fd, errno, ldisc);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* assert BT_WAKE through ioctl */
|
||||
ioctl(fd, USERIAL_IOCTL_BT_WAKE_ASSERT, NULL);
|
||||
ioctl(fd, USERIAL_IOCTL_BT_WAKE_GET_ST, &bt_wake_state);
|
||||
VNDUSERIALDBG("userial_ioctl_init_bt_wake read back BT_WAKE state=%i",
|
||||
bt_wake_state);
|
||||
}
|
||||
#endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
|
||||
|
||||
/*****************************************************************************
|
||||
** Userial Vendor API Functions
|
||||
*****************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function userial_vendor_init
|
||||
**
|
||||
** Description Initialize userial vendor-specific control block
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void userial_vendor_init(void)
|
||||
{
|
||||
vnd_userial.fd = -1;
|
||||
(void)snprintf_s(vnd_userial.port_name, VND_PORT_NAME_MAXLEN, VND_PORT_NAME_MAXLEN, "%s",
|
||||
BLUETOOTH_UART_DEVICE_PORT);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function userial_vendor_open
|
||||
**
|
||||
** Description Open the serial port with the given configuration
|
||||
**
|
||||
** Returns device fd
|
||||
**
|
||||
*******************************************************************************/
|
||||
int userial_vendor_open(tUSERIAL_CFG *p_cfg)
|
||||
{
|
||||
uint32_t baud;
|
||||
uint8_t data_bits;
|
||||
uint16_t parity;
|
||||
uint8_t stop_bits;
|
||||
|
||||
vnd_userial.fd = -1;
|
||||
|
||||
if (!userial_to_tcio_baud(p_cfg->baud, &baud)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (p_cfg->fmt & USERIAL_DATABITS_8)
|
||||
data_bits = CS8;
|
||||
else if (p_cfg->fmt & USERIAL_DATABITS_7)
|
||||
data_bits = CS7;
|
||||
else if (p_cfg->fmt & USERIAL_DATABITS_6)
|
||||
data_bits = CS6;
|
||||
else if (p_cfg->fmt & USERIAL_DATABITS_5)
|
||||
data_bits = CS5;
|
||||
|
||||
if (p_cfg->fmt & USERIAL_PARITY_NONE)
|
||||
parity = 0;
|
||||
else if (p_cfg->fmt & USERIAL_PARITY_EVEN)
|
||||
parity = PARENB;
|
||||
else if (p_cfg->fmt & USERIAL_PARITY_ODD)
|
||||
parity = (PARENB | PARODD);
|
||||
|
||||
if (p_cfg->fmt & USERIAL_STOPBITS_1)
|
||||
stop_bits = 0;
|
||||
else if (p_cfg->fmt & USERIAL_STOPBITS_2)
|
||||
stop_bits = CSTOPB;
|
||||
|
||||
HILOGI("userial vendor open: opening %s", vnd_userial.port_name);
|
||||
|
||||
if ((vnd_userial.fd = open(vnd_userial.port_name, O_RDWR)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
tcflush(vnd_userial.fd, TCIOFLUSH);
|
||||
|
||||
tcgetattr(vnd_userial.fd, &vnd_userial.termios);
|
||||
cfmakeraw(&vnd_userial.termios);
|
||||
vnd_userial.termios.c_cflag |= (CRTSCTS | stop_bits);
|
||||
tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios);
|
||||
tcflush(vnd_userial.fd, TCIOFLUSH);
|
||||
|
||||
tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios);
|
||||
tcflush(vnd_userial.fd, TCIOFLUSH);
|
||||
tcflush(vnd_userial.fd, TCIOFLUSH);
|
||||
|
||||
/* set input/output baudrate */
|
||||
cfsetospeed(&vnd_userial.termios, baud);
|
||||
cfsetispeed(&vnd_userial.termios, baud);
|
||||
tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios);
|
||||
|
||||
#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE)
|
||||
userial_ioctl_init_bt_wake(vnd_userial.fd);
|
||||
#endif
|
||||
|
||||
HILOGI("device fd = %d open", vnd_userial.fd);
|
||||
return vnd_userial.fd;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function userial_vendor_close
|
||||
**
|
||||
** Description Conduct vendor-specific close work
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void userial_vendor_close(void)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (vnd_userial.fd == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE)
|
||||
/* de-assert bt_wake BEFORE closing port */
|
||||
ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_DEASSERT, NULL);
|
||||
#endif
|
||||
|
||||
HILOGI("device fd = %d close", vnd_userial.fd);
|
||||
// flush Tx before close to make sure no chars in buffer
|
||||
tcflush(vnd_userial.fd, TCIOFLUSH);
|
||||
if ((result = close(vnd_userial.fd)) < 0) {
|
||||
HILOGE("close(fd:%d) FAILED result:%d", vnd_userial.fd, result);
|
||||
}
|
||||
|
||||
vnd_userial.fd = -1;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function userial_vendor_set_baud
|
||||
**
|
||||
** Description Set new baud rate
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void userial_vendor_set_baud(uint8_t userial_baud)
|
||||
{
|
||||
uint32_t tcio_baud;
|
||||
|
||||
if (USERIAL_VENDOR_SET_BAUD_DELAY_US > 0) {
|
||||
usleep(USERIAL_VENDOR_SET_BAUD_DELAY_US);
|
||||
}
|
||||
|
||||
userial_to_tcio_baud(userial_baud, &tcio_baud);
|
||||
|
||||
cfsetospeed(&vnd_userial.termios, tcio_baud);
|
||||
cfsetispeed(&vnd_userial.termios, tcio_baud);
|
||||
tcsetattr(vnd_userial.fd, TCSANOW, &vnd_userial.termios);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function userial_vendor_ioctl
|
||||
**
|
||||
** Description ioctl inteface
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void userial_vendor_ioctl(userial_vendor_ioctl_op_t op, void *p_data)
|
||||
{
|
||||
switch (op) {
|
||||
#if (BT_WAKE_VIA_USERIAL_IOCTL == TRUE)
|
||||
case USERIAL_OP_ASSERT_BT_WAKE:
|
||||
VNDUSERIALDBG("## userial_vendor_ioctl: Asserting BT_Wake ##");
|
||||
ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_ASSERT, NULL);
|
||||
break;
|
||||
|
||||
case USERIAL_OP_DEASSERT_BT_WAKE:
|
||||
VNDUSERIALDBG("## userial_vendor_ioctl: De-asserting BT_Wake ##");
|
||||
ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_DEASSERT, NULL);
|
||||
break;
|
||||
|
||||
case USERIAL_OP_GET_BT_WAKE_STATE:
|
||||
ioctl(vnd_userial.fd, USERIAL_IOCTL_BT_WAKE_GET_ST, p_data);
|
||||
break;
|
||||
#endif // (BT_WAKE_VIA_USERIAL_IOCTL==TRUE)
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function userial_set_port
|
||||
**
|
||||
** Description Configure UART port name
|
||||
**
|
||||
** Returns 0 : Success
|
||||
** Otherwise : Fail
|
||||
**
|
||||
*******************************************************************************/
|
||||
int userial_set_port(char *p_conf_name, char *p_conf_value, int param)
|
||||
{
|
||||
(void)strcpy_s(vnd_userial.port_name, VND_PORT_NAME_MAXLEN, p_conf_value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
+2
-2
@@ -4,8 +4,8 @@
|
||||
"device_build_path": "device/board/osware/imx8mm",
|
||||
"target_cpu": "arm",
|
||||
"type": "standard",
|
||||
"version": "3.0",
|
||||
"board": "imx8mm",
|
||||
"version": "1.0",
|
||||
"board": "MILOS_Standard0",
|
||||
"subsystems": [
|
||||
{
|
||||
"subsystem": "arkui",
|
||||
|
||||
Reference in New Issue
Block a user