/********************************************************** ** Function: Headset driver init function ** Parameter: none ** Return value: none ** ************************************************************/ static int __init headset_init(void) { printk(KERN_INFO "%s+ #####\n", __func__); int ret; printk("HEADSET: Headset detection init\n"); hs_data = kzalloc(sizeof(struct headset_data), GFP_KERNEL); if (!hs_data) return -ENOMEM; hs_data->debouncing_time = ktime_set(0, 100000000); /* 100 ms */ hs_data->sdev.name = "h2w"; hs_data->sdev.print_name = headset_name_show; hs_data->sdev.print_state = headset_state_show; ret = switch_dev_register(&hs_data->sdev); if (ret < 0) goto err_switch_dev_register; g_detection_work_queue = create_workqueue("detection"); hrtimer_init(&hs_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hs_data->timer.function = detect_event_timer_func; printk("HEADSET: Headset detection mode\n"); btn_config_gpio();/*Config hook detection GPIO*/ jack_config_gpio();/*Config jack detection GPIO*/ INIT_WORK(&lineout_work, lineout_work_queue); lineout_config_gpio(); printk(KERN_INFO "%s- #####\n", __func__); return 0; err_switch_dev_register: printk(KERN_ERR "Headset: Failed to register driver\n"); return ret; }
/********************************************************** ** Function: Headset driver init function ** Parameter: none ** Return value: none ** ************************************************************/ static int __init headset_init(void) { int ret; printk(KERN_INFO "%s+ #####\n", __func__); printk("HEADSET: Headset detection init\n"); console_disable = is_tegra_debug_uartport_hs(); project_info = tegra3_get_project_id(); hs_data = kzalloc(sizeof(struct headset_data), GFP_KERNEL); if (!hs_data) return -ENOMEM; hs_data->debouncing_time = ktime_set(0, 100000000); /* 100 ms */ hs_data->sdev.name = "h2w"; hs_data->sdev.print_name = headset_name_show; hs_data->sdev.print_state = headset_state_show; hs_data->ldev.name = "lineout"; hs_data->ldev.print_name = lineout_name_show; hs_data->ldev.print_state = lineout_state_show; ret = switch_dev_register(&hs_data->sdev); if (ret < 0) goto err_switch_dev_register; ret = switch_dev_register(&hs_data->ldev); if (ret < 0) goto err_switch_dev_register; g_detection_work_queue = create_workqueue("detection"); hrtimer_init(&hs_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hs_data->timer.function = detect_event_timer_func; printk("HEADSET: Headset detection mode\n"); btn_config_gpio();/*Config hook detection GPIO*/ if(project_info == TEGRA3_PROJECT_ME301T || project_info == TEGRA3_PROJECT_ME301TL || project_info == TEGRA3_PROJECT_ME570T) switch_config_gpio(); /*Config uart and headphone switch*/ wake_lock_init(&hp_detect_wakelock, WAKE_LOCK_SUSPEND, "headset detection"); INIT_WORK(&lineout_work, lineout_work_queue); if (project_info == TEGRA3_PROJECT_ME301T || project_info == TEGRA3_PROJECT_ME301TL) INIT_WORK(&hook_work, hook_work_queue); switch (project_info) { case TEGRA3_PROJECT_TF201: case TEGRA3_PROJECT_TF300T: case TEGRA3_PROJECT_TF300TG: case TEGRA3_PROJECT_TF300TL: case TEGRA3_PROJECT_TF500T: case TEGRA3_PROJECT_TF700T: hs_data->lineout_gpio = LINEOUT_GPIO; lineout_config_gpio(); break; case TEGRA3_PROJECT_ME301T: hs_data->lineout_gpio = LINEOUT_ME301T; lineout_config_no_dock(); break; default: hs_data->lineout_gpio = LINEOUT_GPIO; lineout_config_gpio(); break; } jack_config_gpio();/*Config jack detection GPIO*/ printk(KERN_INFO "%s- #####\n", __func__); return 0; err_switch_dev_register: printk(KERN_ERR "Headset: Failed to register driver\n"); return ret; }