static int bluesleep_write_proc_lpm(struct file *file, const char *buffer, unsigned long count, void *data) { char b; if (count < 1) return -EINVAL; if (copy_from_user(&b, buffer, 1)) return -EFAULT; if (b == '0') { /* HCI_DEV_UNREG */ bluesleep_stop(); has_lpm_enabled = false; bsi->uport = NULL; } else { /* HCI_DEV_REG */ if (!has_lpm_enabled) { has_lpm_enabled = true; if (bluesleep_uart_dev) bsi->uport = bluesleep_get_uart_port(); /* if bluetooth started, start bluesleep*/ bluesleep_start(); } } return count; }
static int bluesleep_write_proc_lpm(struct file *file, const char __user * buffer, size_t count, loff_t * ppos) { char b; if (count < 1) return -EINVAL; if (copy_from_user(&b, buffer, 1)) return -EFAULT; if (b == '0') { /* HCI_DEV_UNREG */ bluesleep_stop(); has_lpm_enabled = false; bsi->uport = NULL; } else { /* HCI_DEV_REG */ if (!has_lpm_enabled) { has_lpm_enabled = true; bsi->uport = msm_hs_get_uart_port(BT_PORT_ID); /* if bluetooth started, start bluesleep */ bluesleep_start(); } } return count; }
static int bt_power_control(struct bt_power *bt_power, int enable) { if (enable == bt_power_state) return 0; switch (enable) { case RFKILL_STATE_SOFT_BLOCKED: bluesleep_stop(); msleep(15); bcm_power_down(); bt_disable_power(bt_power); if (bt_power->pdata->set_pin_status != NULL){ (*bt_power->pdata->set_pin_status)(enable); } else { pr_warn("%s set_pin_status is not defined\n", __func__); } break; case RFKILL_STATE_UNBLOCKED: if (bt_power->pdata->restore_pin_status != NULL){ (*bt_power->pdata->restore_pin_status)(enable); } else { pr_warn("%s set_pin_status is not defined\n", __func__); } bcm_power_on(); if (bt_power->bt_rst_n != -1) { gpio_direction_output(bt_power->bt_rst_n, 0); } else { pr_warn("%s bt_rst_n can not be defined to -1\n", __func__); } bt_enable_power(bt_power); mdelay(15); if (bt_power->bt_rst_n != -1) { gpio_set_value(bt_power->bt_rst_n, 1); } else { pr_warn("%s bt_rst_n can not be defined to -1\n", __func__); } mdelay(15); bluesleep_start(); break; default: break; } bt_power_state = enable; return 0; }
/** * Stops the Sleep-Mode Protocol on the Host. */ void brcm_btsleep_stop(enum sleep_type type) { #ifdef LPM_BLUESLEEP //BT_S : fix wrong lpm_param issue, [START] printk("%s - %d\n", __func__, type); if(type == SLEEP_BLUESLEEP) #if defined(CONFIG_BT_MSM_SLEEP) bluesleep_stop(); #elif defined(CONFIG_LGE_BLUETOOTH_PM) bluetooth_pm_sleep_stop(); #endif //BT_E : fix wrong lpm_param issue, [END] #endif }
/** * Modify the low-power protocol used by the Host via the proc interface. * @param file Not used. * @param buffer The buffer to read from. * @param count The number of bytes to be written. * @param data Not used. * @return On success, the number of bytes written. On error, -1, and * <code>errno</code> is set appropriately. */ static int bluesleep_write_proc_proto(struct file *file, const char *buffer, unsigned long count, void *data) { char proto; if (count < 1) return -EINVAL; if (copy_from_user(&proto, buffer, 1)) return -EFAULT; if (proto == '0') bluesleep_stop(); else bluesleep_start(); /* claim that we wrote everything */ return count; }
/** * Modify the low-power protocol used by the Host via the proc interface. * @param file Not used. * @param buffer The buffer to read from. * @param count The number of bytes to be written. * @param data Not used. * @return On success, the number of bytes written. On error, -1, and * <code>errno</code> is set appropriately. */ static ssize_t bluesleep_write_proc_proto(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { char proto; if (count < 1) return -EINVAL; if (copy_from_user(&proto, buffer, 1)) return -EFAULT; if (proto == '0') bluesleep_stop(); else bluesleep_start(); /* claim that we wrote everything */ return count; }
/** * Modify the low-power protocol used by the Host via the proc interface. */ static ssize_t bluesleep_write_proc_proto(struct file *filp, const char __user *buffer, size_t len, loff_t *off) { char proto = 0; if ((len < 1) || (NULL == g_bs_data)) return -EINVAL; if (copy_from_user(&proto, buffer, sizeof(proto))) return -EFAULT; if (proto == '0') bluesleep_stop(g_bs_data); else if (proto == '1') bluesleep_start(g_bs_data); else pr_err("bluesleep_write_proc_proto error %d\n", proto); /* claim that we wrote everything */ return len; }
static int bluesleep_write_proc_lpm(struct file *file, const char *buffer, unsigned long count, void *data) { char b; if (count < 1) return -EINVAL; if (copy_from_user(&b, buffer, 1)) return -EFAULT; if (b == '0') { BT_ERR("(bluesleep_write_proc_lpm) Unreg HCI notifier."); /* HCI_DEV_UNREG */ bluesleep_stop(); bt_enabled = false; //bsi->uport = NULL; } else if (b == '1') { BT_ERR("(bluesleep_write_proc_lpm) Reg HCI notifier."); /* HCI_DEV_REG */ if (!bt_enabled) { bt_enabled = true; bsi->uport = bluesleep_get_uart_port(); /* if bluetooth started, start bluesleep*/ bluesleep_start(); } } else if (b == '2') { BT_ERR("(bluesleep_write_proc_lpm) don`t control ext_wake & uart clk"); if(bt_enabled) { bt_enabled = false; bluesleep_abnormal_stop(); } } return count; }