static ssize_t uart_switch_store ( struct device *dev, struct device_attribute *attr, const char *buf, size_t size ) { int switch_sel; int console_mode; int path_save = 1; if (sec_get_param_value) { sec_get_param_value(__SWITCH_SEL, &switch_sel); sec_get_param_value(__CONSOLE_MODE, &console_mode); } if (strstr(buf, "PDA") || strstr(buf, "pda")) { if(uart_current_owner != SWITCH_PDA) { sio_switch_config(AP_UART_MODE); } uart_current_owner = SWITCH_PDA; switch_sel |= UART_SEL_MASK; console_mode = 1; printk("[UART Switch] Path : PDA\n"); } else if (strstr(buf, "MODEM") || strstr(buf, "modem")) { if(uart_current_owner != SWITCH_MODEM) { sio_switch_config(CP_UART_MODE); } uart_current_owner = SWITCH_MODEM; switch_sel &= ~UART_SEL_MASK; console_mode = 0; printk("[UART Switch] Path : MODEM\n"); } if(strstr(buf, "NOSAVE") || strstr(buf, "nosave")) { path_save = 0; printk("[UART Switch] path is not saved\n"); } if(path_save) { if (sec_set_param_value) { sec_set_param_value(__SWITCH_SEL, &switch_sel); sec_set_param_value(__CONSOLE_MODE, &console_mode); } } return size; }
static ssize_t usb_sel_store ( struct device *dev, struct device_attribute *attr, const char *buf, size_t size ) { int switch_sel; int path_save = 1; if (sec_get_param_value) { sec_get_param_value(__SWITCH_SEL, &switch_sel); } if(strstr(buf, "PDA") || strstr(buf, "pda")) { if(usb_path != SWITCH_PDA) { sio_switch_config(AP_USB_MODE); } usb_path = SWITCH_PDA; switch_sel |= USB_SEL_MASK; printk("[USB Switch] Path : PDA\n"); } else if(strstr(buf, "MODEM") || strstr(buf, "modem")) { if(usb_path != SWITCH_MODEM) { sio_switch_config(CP_USB_MODE); } usb_path = SWITCH_MODEM; switch_sel &= ~USB_SEL_MASK; printk("[USB Switch] Path : MODEM\n"); } if(strstr(buf, "NOSAVE") || strstr(buf, "nosave")) { path_save = 0; printk("[USB Switch] path is not saved\n"); } if(path_save) { if (sec_set_param_value) { sec_set_param_value(__SWITCH_SEL, &switch_sel); } } return size; }
static void sio_switch_init_worker(struct work_struct *ignored) { int switch_sel; if (sec_get_param_value) { sec_get_param_value(__SWITCH_SEL, &switch_sel); cancel_delayed_work(&sio_switch_init_work); } else { schedule_delayed_work(&sio_switch_init_work, msecs_to_jiffies(100)); return; } if (switch_sel & USB_SEL_MASK) usb_path = SWITCH_PDA; else usb_path = SWITCH_MODEM; if (switch_sel & UART_SEL_MASK) uart_current_owner = SWITCH_PDA; else uart_current_owner = SWITCH_MODEM; #ifdef _FMC_DM_ if (switch_sel & USB_LOCK_MASK) { usb_access_lock = 1; android_usb_set_connected(0); } #endif if (uart_current_owner == SWITCH_PDA) { sio_switch_config(AP_UART_MODE); } else if (uart_current_owner == SWITCH_MODEM) { printk("----------------- Cutting off PDA UART ---------------------\n"); sio_switch_config(CP_UART_MODE); } if (usb_path == SWITCH_MODEM) { sio_switch_config(CP_USB_MODE); } microusb_init(); }
static void sio_switch_init_worker(struct work_struct *ignored) { int switch_sel; if (sec_get_param_value) { sec_get_param_value(__SWITCH_SEL, &switch_sel); cancel_delayed_work(&sio_switch_init_work); } else { schedule_delayed_work(&sio_switch_init_work, msecs_to_jiffies(100)); return; } if (switch_sel & USB_SEL_MASK) { usb_path = SWITCH_PDA; sio_switch_config(AP_USB_MODE); } else usb_path = SWITCH_MODEM; if (switch_sel & UART_SEL_MASK) uart_current_owner = SWITCH_PDA; else uart_current_owner = SWITCH_MODEM; if (uart_current_owner == SWITCH_PDA) { sio_switch_config(AP_UART_MODE); } else if (uart_current_owner == SWITCH_MODEM) { printk("----------------- Cutting off PDA UART ---------------------\n"); sio_switch_config(CP_UART_MODE); } if (usb_path == SWITCH_MODEM) { sio_switch_config(CP_USB_MODE); } }