diff --git a/filyos/bluetooth/BCM4343A1.hcd b/filyos/bluetooth/BCM4343A1.hcd deleted file mode 100644 index 7f05271eb3126a7b8e3fc4b42121b58730dd458f..0000000000000000000000000000000000000000 Binary files a/filyos/bluetooth/BCM4343A1.hcd and /dev/null differ diff --git a/filyos/bluetooth/BCM4362A2.hcd b/filyos/bluetooth/BCM4362A2.hcd new file mode 100755 index 0000000000000000000000000000000000000000..95c69b42ac17d0791aa8ad73d416c5d75e537346 Binary files /dev/null and b/filyos/bluetooth/BCM4362A2.hcd differ diff --git a/filyos/bluetooth/BUILD.gn b/filyos/bluetooth/BUILD.gn index bc77ec78417603e509d661286fe1bfb63e5ee187..0c5d6c26892d1c3bacfa2849e641bb0938094ca8 100644 --- a/filyos/bluetooth/BUILD.gn +++ b/filyos/bluetooth/BUILD.gn @@ -16,8 +16,8 @@ config("bt_warnings") { ] } -ohos_prebuilt_etc("BCM4343A1.hcd") { - source = "//vendor/opintelink/${product_name}/bluetooth/BCM4343A1.hcd" +ohos_prebuilt_etc("BCM4362A2.hcd") { + source = "//vendor/opintelink/${product_name}/bluetooth/BCM4362A2.hcd" install_images = [ vendor_base_dir ] relative_install_dir = "firmware" part_name = "rockchip_products" @@ -64,7 +64,7 @@ ohos_shared_library("libbt_vendor") { ] install_enable = true - install_images = [ "system" ] + install_images = [ chipset_base_dir ] part_name = "rockchip_products" subsystem_name = "rockchip_products" diff --git a/filyos/bluetooth/include/bt_vendor_brcm.h b/filyos/bluetooth/include/bt_vendor_brcm.h index a0d3cd14f2e6a29f5345e22eb3cf424a9f097738..2ad3d4d3394127f5b4071dccdcbe5d3f92e63360 100644 --- a/filyos/bluetooth/include/bt_vendor_brcm.h +++ b/filyos/bluetooth/include/bt_vendor_brcm.h @@ -55,7 +55,7 @@ /* Device port name where Bluetooth controller attached */ #ifndef BLUETOOTH_UART_DEVICE_PORT -#define BLUETOOTH_UART_DEVICE_PORT "/dev/ttyS0" /* maguro */ +#define BLUETOOTH_UART_DEVICE_PORT "/dev/ttyS9" /* maguro */ #endif /* Location of firmware patch files */ @@ -64,7 +64,7 @@ #endif #ifndef UART_TARGET_BAUD_RATE -#define UART_TARGET_BAUD_RATE USERIAL_LINESPEED_2M +#define UART_TARGET_BAUD_RATE 3000000 #endif /* The millisecond delay pauses on HCI transport after firmware patches @@ -89,7 +89,7 @@ #define FW_AUTO_DETECTION FALSE #endif -/* The Bluetooth Device Aaddress source switch: +/* The Bluetooth Device Address source switch: * * -FALSE- (default value) * Get the factory BDADDR from device's file system. Normally the BDADDR is diff --git a/filyos/bluetooth/src/hardware.c b/filyos/bluetooth/src/hardware.c index fa0c7b4cb6c0988647387fb9376a2d138e8ccb0e..0cd269d96d43927c1eeffc1fb28cae868ecf3e00 100644 --- a/filyos/bluetooth/src/hardware.c +++ b/filyos/bluetooth/src/hardware.c @@ -54,13 +54,13 @@ ******************************************************************************/ #ifndef BTHW_DBG -#define BTHW_DBG FALSE +#define BTHW_DBG TRUE #endif #if (BTHW_DBG == TRUE) #define BTHWDBG(param, ...) \ { \ - HILOGD(param, ##__VA_ARGS__); \ + HILOGI(param, ##__VA_ARGS__); \ } #else #define BTHWDBG(param, ...) \ @@ -164,18 +164,8 @@ typedef struct { /* low power mode parameters */ typedef struct { - uint8_t sleep_mode; /* 0(disable),1(UART),9(H5) */ uint8_t host_stack_idle_threshold; /* Unit scale 300ms/25ms */ - uint8_t host_controller_idle_threshold; /* Unit scale 300ms/25ms */ uint8_t bt_wake_polarity; /* 0=Active Low, 1= Active High */ - uint8_t host_wake_polarity; /* 0=Active Low, 1= Active High */ - uint8_t allow_host_sleep_during_sco; - uint8_t combine_sleep_mode_and_lpm; - uint8_t enable_uart_txd_tri_state; /* UART_TXD Tri-State */ - uint8_t sleep_guard_time; /* sleep guard time in 12.5ms */ - uint8_t wakeup_guard_time; /* wakeup guard time in 12.5ms */ - uint8_t txd_config; /* TXD is high in sleep state */ - uint8_t pulsed_host_wake; /* pulsed host wake if mode = 1 */ } bt_lpm_param_t; /* Firmware re-launch settlement time */ @@ -184,14 +174,6 @@ typedef struct { const uint32_t delay_time; } fw_settlement_entry_t; -#if (FW_AUTO_DETECTION == TRUE) -/* AMPAK FW auto detection table */ -typedef struct { - char *chip_id; - char *updated_chip_id; -} fw_auto_detection_entry_t; -#endif - /****************************************************************************** ** Externs ******************************************************************************/ @@ -212,18 +194,8 @@ static int wbs_sample_rate = SCO_WBS_SAMPLE_RATE; static bt_hw_cfg_cb_t hw_cfg_cb; static bt_lpm_param_t lpm_param = { - LPM_SLEEP_MODE, LPM_IDLE_THRESHOLD, - LPM_HC_IDLE_THRESHOLD, LPM_BT_WAKE_POLARITY, - LPM_HOST_WAKE_POLARITY, - LPM_ALLOW_HOST_SLEEP_DURING_SCO, - LPM_COMBINE_SLEEP_MODE_AND_LPM, - LPM_ENABLE_UART_TXD_TRI_STATE, - 0, /* not applicable */ - 0, /* not applicable */ - 0, /* not applicable */ - LPM_PULSED_HOST_WAKE }; /* need to update the bt_sco_i2spcm_param as well @@ -281,26 +253,6 @@ static uint8_t sco_bus_interface = SCO_INTERFACE_PCM; static uint8_t sco_bus_clock_rate = INVALID_SCO_CLOCK_RATE; static uint8_t sco_bus_wbs_clock_rate = INVALID_SCO_CLOCK_RATE; -#if (FW_AUTO_DETECTION == TRUE) -#define FW_TABLE_VERSION "v1.1 20161117" -static const fw_auto_detection_entry_t fw_auto_detection_table[] = { - {"4343A0", "BCM43438A0"}, // AP6212 - {"BCM43430A1", "BCM43438A1"}, // AP6212A - {"BCM20702A", "BCM20710A1"}, // AP6210B - {"BCM4335C0", "BCM4339A0"}, // AP6335 - {"BCM4330B1", "BCM40183B2"}, // AP6330 - {"BCM4324B3", "BCM43241B4"}, // AP62X2 - {"BCM4350C0", "BCM4354A1"}, // AP6354 - {"BCM4354A2", "BCM4356A2"}, // AP6356 - {"BCM4345C0", "BCM4345C0"}, // AP6255 - {"BCM4345C5", "BCM4345C5"}, // AP6256 - {"BCM43430B0", "BCM4343B0"}, // AP6236 - {"BCM4359C0", "BCM4359C0"}, // AP6359 - {"BCM4349B1", "BCM4359B1"}, // AP6359 - {NULL, NULL} -}; -#endif - /****************************************************************************** ** Static functions ******************************************************************************/ @@ -605,13 +557,11 @@ void hw_sco_config(void); void hw_config_cback(void *p_mem) { HC_BT_HDR *p_evt_buf = (HC_BT_HDR *)p_mem; - char *p_name, *p_tmp; uint8_t *p, status; uint16_t opcode; HC_BT_HDR *p_buf = NULL; ssize_t xmit_bytes = 0; int i; - int delay = 100; #if (USE_CONTROLLER_BDADDR == TRUE) const uint8_t null_bdaddr[BD_ADDR_LEN] = {0, 0, 0, 0, 0, 0}; #endif @@ -678,7 +628,8 @@ void hw_config_cback(void *p_mem) #endif { // /vendor/etc/firmware - p_name = FW_PATCHFILE_LOCATION "BCM4343A1.hcd"; + char *p_name; + p_name = FW_PATCHFILE_LOCATION "BCM4362A2.hcd"; if ((hw_cfg_cb.fw_fd = open(p_name, O_RDONLY)) == -1) { HILOGE("vendor lib preload failed to open [%s]", p_name); } else { @@ -739,6 +690,7 @@ void hw_config_cback(void *p_mem) /* Check if we need to pause a few hundred milliseconds * before sending down any HCI command. */ + int delay = 0; delay = look_up_fw_settlement_delay(); HILOGI("Setting fw settlement delay to %d ", delay); ms_delay(delay); @@ -812,6 +764,8 @@ void hw_config_cback(void *p_mem) #if (USE_CONTROLLER_BDADDR == TRUE) case HW_CFG_READ_BD_ADDR: + { + char *p_tmp; p_tmp = (char *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_LOCAL_BDADDR_ARRAY; HILOGI("entering HW_CFG_READ_BD_ADDR"); @@ -826,6 +780,7 @@ void hw_config_cback(void *p_mem) *(p_tmp + 5), *(p_tmp + 4), *(p_tmp + 3), *(p_tmp + 2), *(p_tmp + 1), *p_tmp); } + } HILOGI("vendor lib fwcfg completed"); bt_vendor_cbacks->dealloc(p_buf); @@ -876,7 +831,7 @@ void hw_config_cback(void *p_mem) ** ** Function hw_lpm_ctrl_cback ** -** Description Callback function for lpm enable/disable rquest +** Description Callback function for lpm enable/disable request ** ** Returns None ** @@ -888,6 +843,7 @@ void hw_lpm_ctrl_cback(void *p_mem) if (*((uint8_t *)(p_evt_buf + 1) + HCI_EVT_CMD_CMPL_STATUS_RET_BYTE) == 0) { status = BTC_OP_RESULT_SUCCESS; + HILOGI("%d", status); } if (bt_vendor_cbacks) { @@ -904,7 +860,6 @@ static void hw_sco_i2spcm_proc_interface_param(void) { bt_op_result_t status = BTC_OP_RESULT_FAIL; uint8_t ret = FALSE; - uint8_t *p; HC_BT_HDR *p_buf = NULL; /* Ask a new buffer to hold WRITE_SCO_PCM_INT_PARAM command */ @@ -917,7 +872,7 @@ static void hw_sco_i2spcm_proc_interface_param(void) p_buf->offset = 0; p_buf->layer_specific = 0; p_buf->len = HCI_CMD_PREAMBLE_SIZE + SCO_PCM_PARAM_SIZE; - p = (uint8_t *)(p_buf + 1); + uint8_t *p = (uint8_t *)(p_buf + 1); /* do we need this VSC for I2S??? */ UINT16_TO_STREAM(p, HCI_VSC_WRITE_SCO_PCM_INT_PARAM); @@ -937,7 +892,6 @@ static void hw_sco_i2spcm_proc_int_param(void) { bt_op_result_t status = BTC_OP_RESULT_FAIL; uint8_t ret = FALSE; - uint8_t *p; HC_BT_HDR *p_buf = NULL; /* Ask a new buffer to hold WRITE_PCM_DATA_FORMAT_PARAM command */ @@ -950,7 +904,7 @@ static void hw_sco_i2spcm_proc_int_param(void) p_buf->layer_specific = 0; p_buf->len = HCI_CMD_PREAMBLE_SIZE + PCM_DATA_FORMAT_PARAM_SIZE; - p = (uint8_t *)(p_buf + 1); + uint8_t *p = (uint8_t *)(p_buf + 1); UINT16_TO_STREAM(p, HCI_VSC_WRITE_PCM_DATA_FORMAT_PARAM); *p++ = PCM_DATA_FORMAT_PARAM_SIZE; memcpy_s(p, &bt_pcm_data_fmt_param, PCM_DATA_FORMAT_PARAM_SIZE); @@ -969,7 +923,7 @@ static void hw_sco_i2spcm_proc_int_param(void) ** ** Function hw_sco_i2spcm_cfg_cback ** -** Description Callback function for SCO I2S/PCM configuration rquest +** Description Callback function for SCO I2S/PCM configuration request ** ** Returns None ** @@ -1057,7 +1011,6 @@ static void hw_set_CVSD_codec_cback(void *p_mem) void hw_config_start(void) { HC_BT_HDR *p_buf = NULL; - uint8_t *p; hw_cfg_cb.state = 0; hw_cfg_cb.fw_fd = -1; @@ -1077,7 +1030,7 @@ void hw_config_start(void) p_buf->layer_specific = 0; p_buf->len = HCI_CMD_PREAMBLE_SIZE; - p = (uint8_t *)(p_buf + 1); + uint8_t *p = (uint8_t *)(p_buf + 1); UINT16_TO_STREAM(p, HCI_RESET); *p = 0; @@ -1104,7 +1057,6 @@ uint8_t hw_lpm_enable(uint8_t turn_on) { HILOGD("entering hw_lpm_enable11"); HC_BT_HDR *p_buf = NULL; - uint8_t *p; uint8_t ret = FALSE; if (bt_vendor_cbacks) @@ -1118,7 +1070,7 @@ uint8_t hw_lpm_enable(uint8_t turn_on) p_buf->layer_specific = 0; p_buf->len = HCI_CMD_PREAMBLE_SIZE + LPM_CMD_PARAM_SIZE; - p = (uint8_t *)(p_buf + 1); + uint8_t *p = (uint8_t *)(p_buf + 1); UINT16_TO_STREAM(p, HCI_VSC_WRITE_SLEEP_MODE); *p++ = LPM_CMD_PARAM_SIZE; /* parameter length */ @@ -1130,12 +1082,12 @@ uint8_t hw_lpm_enable(uint8_t turn_on) upio_set(UPIO_LPM_MODE, UPIO_DEASSERT, 0); } - if ((ret = bt_vendor_cbacks->xmit_cb(HCI_VSC_WRITE_SLEEP_MODE, p_buf)) <= 0) { + if ((ret = bt_vendor_cbacks->xmit_cb(HCI_VSC_WRITE_SLEEP_MODE, p_buf)) == FALSE) { bt_vendor_cbacks->dealloc(p_buf); } } - if ((ret <= 0) && bt_vendor_cbacks) { + if ((ret == 0) && bt_vendor_cbacks) { // bt_vendor_cbacks->lpm_cb(BT_VND_OP_RESULT_FAIL); } HILOGD("hw_lpm_enable ret:%d", ret); @@ -1265,7 +1217,6 @@ static void hw_sco_i2spcm_config_from_command(void *p_mem, uint16_t codec) static void hw_sco_i2spcm_config(uint16_t codec) { HC_BT_HDR *p_buf = NULL; - uint8_t *p, ret; uint16_t cmd_u16 = HCI_CMD_PREAMBLE_SIZE + SCO_I2SPCM_PARAM_SIZE; if (bt_vendor_cbacks) { @@ -1277,8 +1228,8 @@ static void hw_sco_i2spcm_config(uint16_t codec) p_buf->offset = 0; p_buf->layer_specific = 0; p_buf->len = cmd_u16; - - p = (uint8_t *)(p_buf + 1); + uint8_t ret; + uint8_t *p = (uint8_t *)(p_buf + 1); UINT16_TO_STREAM(p, HCI_VSC_WRITE_I2SPCM_INTERFACE_PARAM); *p++ = SCO_I2SPCM_PARAM_SIZE; @@ -1303,7 +1254,7 @@ static void hw_sco_i2spcm_config(uint16_t codec) bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_SAMPLE_RATE], bt_sco_i2spcm_param[SCO_I2SPCM_PARAM_IF_CLOCK_RATE]); - if ((ret = bt_vendor_cbacks->xmit_cb(cmd_u16, p_buf)) <= 0) { + if ((ret = bt_vendor_cbacks->xmit_cb(cmd_u16, p_buf)) == FALSE) { bt_vendor_cbacks->dealloc(p_buf); } else { return; @@ -1326,8 +1277,6 @@ static void hw_sco_i2spcm_config(uint16_t codec) static int hw_set_SCO_codec(uint16_t codec) { HC_BT_HDR *p_buf = NULL; - uint8_t *p; - uint8_t ret; int ret_val = 0; return ret_val; } @@ -1457,7 +1406,6 @@ void hw_epilog_cback(void *p_mem) void hw_epilog_process(void) { HC_BT_HDR *p_buf = NULL; - uint8_t *p; BTHWDBG("hw_epilog_process"); @@ -1474,7 +1422,7 @@ void hw_epilog_process(void) p_buf->layer_specific = 0; p_buf->len = HCI_CMD_PREAMBLE_SIZE; - p = (uint8_t *)(p_buf + 1); + uint8_t *p = (uint8_t *)(p_buf + 1); UINT16_TO_STREAM(p, HCI_RESET); *p = 0; /* parameter length */ @@ -1502,8 +1450,8 @@ void hw_process_event(HC_BT_HDR *p_buf) #endif case HCI_READ_LOCAL_NAME: case HCI_VSC_DOWNLOAD_MINIDRV: - case HCI_VSC_WRITE_FIRMWARE: - case HCI_VSC_LAUNCH_RAM: + case HCI_VSC_WRITE_FIRMWARE: + case HCI_VSC_LAUNCH_RAM: case HCI_RESET: case HCI_VSC_WRITE_UART_CLOCK_SETTING: case HCI_VSC_UPDATE_BAUDRATE: diff --git a/filyos/bluetooth/src/upio.c b/filyos/bluetooth/src/upio.c index 03cb83d95245aab131f1ad0097a1198978249869..cc20a72c8944f06a89647a3eac2ec4789f4583ed 100644 --- a/filyos/bluetooth/src/upio.c +++ b/filyos/bluetooth/src/upio.c @@ -138,21 +138,21 @@ static int init_rfkill(void) { char path[64]; char buf[16]; - int fd, sz, id; + int 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); + int 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)); + int sz = read(fd, &buf, sizeof(buf)); close(fd); if (sz >= (int)strlen("bluetooth") && memcmp(buf, "bluetooth", strlen("bluetooth")) == 0) { diff --git a/filyos/bluetooth/src/userial_vendor.c b/filyos/bluetooth/src/userial_vendor.c index 7cc89e52361501324196a41f4ef47b24b2085af1..bca5b827acd9449aadc73f0947575291885618ff 100644 --- a/filyos/bluetooth/src/userial_vendor.c +++ b/filyos/bluetooth/src/userial_vendor.c @@ -195,8 +195,6 @@ void userial_vendor_init(void) 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; @@ -205,21 +203,6 @@ int userial_vendor_open(tUSERIAL_CFG *p_cfg) 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;