void acc_accessory_uevent(struct acc_con_info *acc, int acc_adc) { enum accessory_type current_accessory = ACCESSORY_NONE; char *env_ptr; char *stat_ptr; char *envp[3]; // value is changed for PxLTE // 3 pole earjack 1.00 V ( 0.90~1.10V) adc: 797~1002 // Car mount 1.38 V (1.24~1.45V) adc: 1134~1352 // 4 pole earjack just bundles is supported . adc :1360~1449 : No Warranty // OTG 2.2 V (2.00~2.35V) adc: 1903~2248 if (acc_adc != false) { if(check_using_stmpe811_adc()) { if ((1100 < acc_adc) && (1400 > acc_adc)) { // 3 pole earjack 1247 env_ptr = "ACCESSORY=lineout"; current_accessory = ACCESSORY_LINEOUT; // } else if ((1134 < acc_adc) && (1352 > acc_adc)) { // car mount // env_ptr = "ACCESSORY=carmount"; // acc->current_accessory = ACCESSORY_CARMOUNT; } else if ((1800 < acc_adc) && (2350 > acc_adc)) { // 4 pole earjack, No warranty 1948 env_ptr = "ACCESSORY=lineout"; current_accessory = ACCESSORY_LINEOUT; } else if ((2400 < acc_adc) && (2800 > acc_adc)) { // otg 2586 env_ptr = "ACCESSORY=OTG"; current_accessory = ACCESSORY_OTG; } else { env_ptr = "ACCESSORY=unknown"; current_accessory = ACCESSORY_UNKNOWN; } } else { // not stmpe adc if ((797 < acc_adc) && (1002 > acc_adc)) { // 3 pole earjack 911 env_ptr = "ACCESSORY=lineout"; current_accessory = ACCESSORY_LINEOUT; } else if ((1134 < acc_adc) && (1352 > acc_adc)) { // car mount env_ptr = "ACCESSORY=carmount"; current_accessory = ACCESSORY_CARMOUNT; } else if ((1400 < acc_adc) && (1690 > acc_adc)) { // 4 pole earjack, No warranty 1534 env_ptr = "ACCESSORY=lineout"; current_accessory = ACCESSORY_LINEOUT; } else if ((1900 < acc_adc) && (2250 > acc_adc)) { // otg 2125 env_ptr = "ACCESSORY=OTG"; current_accessory = ACCESSORY_OTG; } else { env_ptr = "ACCESSORY=unknown"; current_accessory = ACCESSORY_UNKNOWN; } } if (current_accessory == acc->current_accessory) { ACC_CONDEV_DBG("same accessory type is connected %d", \ current_accessory); return; } if (acc->current_accessory != ACCESSORY_NONE) { ACC_CONDEV_DBG("assuming prev accessory disconnected %d", \ acc->current_accessory); if (acc->current_accessory == ACCESSORY_OTG) envp[0] = "ACCESSORY=OTG"; else if (acc->current_accessory == ACCESSORY_LINEOUT) envp[0] = "ACCESSORY=lineout"; else if (acc->current_accessory == ACCESSORY_CARMOUNT) envp[0] = "ACCESSORY=carmount"; else envp[0] = "ACCESSORY=unknown"; envp[1] = "STATE=offline"; envp[2] = NULL; kobject_uevent_env(&acc->acc_dev->kobj, KOBJ_CHANGE, envp); if ((acc->current_accessory == ACCESSORY_OTG) && acc->pdata->otg_en) acc->pdata->otg_en(0); #if defined(CONFIG_TARGET_LOCALE_KOR) || defined(CONFIG_TARGET_LOCALE_JPN) #else if (acc->current_accessory == ACCESSORY_LINEOUT) switch_set_state(&acc->ear_jack_switch, UEVENT_DOCK_NONE); #endif ACC_CONDEV_DBG("%s : %s", envp[0], envp[1]); } acc->current_accessory = current_accessory; stat_ptr = "STATE=online"; envp[0] = env_ptr; envp[1] = stat_ptr; envp[2] = NULL; if (acc->current_accessory == ACCESSORY_OTG) { /* force acc power off to ensure otg detection */ if (acc->pdata->acc_power) acc->pdata->acc_power(0, false); msleep(20); if (acc->pdata->otg_en) acc->pdata->otg_en(1); msleep(30); } else if (acc->current_accessory == ACCESSORY_LINEOUT) { #if defined(CONFIG_TARGET_LOCALE_KOR) || defined(CONFIG_TARGET_LOCALE_JPN) #else switch_set_state(&acc->ear_jack_switch, 1); #endif } kobject_uevent_env(&acc->acc_dev->kobj, KOBJ_CHANGE, envp); ACC_CONDEV_DBG("%s : %s", env_ptr, stat_ptr); } else { if (acc->current_accessory == ACCESSORY_OTG) env_ptr = "ACCESSORY=OTG"; else if (acc->current_accessory == ACCESSORY_LINEOUT) { env_ptr = "ACCESSORY=lineout"; #if defined(CONFIG_TARGET_LOCALE_KOR) || defined(CONFIG_TARGET_LOCALE_JPN) #else switch_set_state(&acc->ear_jack_switch, UEVENT_DOCK_NONE); #endif } else if (acc->current_accessory == ACCESSORY_CARMOUNT) env_ptr = "ACCESSORY=carmount"; else env_ptr = "ACCESSORY=unknown"; stat_ptr = "STATE=offline"; envp[0] = env_ptr; envp[1] = stat_ptr; envp[2] = NULL; kobject_uevent_env(&acc->acc_dev->kobj, KOBJ_CHANGE, envp); if ((acc->current_accessory == ACCESSORY_OTG) && acc->pdata->otg_en) acc->pdata->otg_en(0); acc->current_accessory = ACCESSORY_NONE; ACC_CONDEV_DBG("%s : %s", env_ptr, stat_ptr); } }
void acc_notified(struct acc_con_info *acc, int acc_adc) { enum accessory_type current_accessory = ACCESSORY_NONE; char *env_ptr; char *stat_ptr; char *envp[3]; /* value is changed for Espresso 3 pole earjack 1.00 V ( 0.90~1.10V) adc: 1207~1256 Car mount 1.38 V (1.24~1.45V) adc: 1680~1749 4 pole earjack just bundles is supported . adc :2189~2278 : No Warranty OTG 2.2 V (2.00~2.35V) adc: 2676~2785 */ if (acc_adc != false) { if (check_using_stmpe811_adc()) { if ((1207 < acc_adc) && (1256 > acc_adc)) { env_ptr = "ACCESSORY=lineout"; current_accessory = ACCESSORY_LINEOUT; } else if ((1680 < acc_adc) && (1749 > acc_adc)) { env_ptr = "ACCESSORY=carmount"; acc->current_accessory = ACCESSORY_CARMOUNT; } else if ((2189 < acc_adc) && (2278 > acc_adc)) { env_ptr = "ACCESSORY=lineout"; current_accessory = ACCESSORY_LINEOUT; #ifdef CONFIG_CAMERON_HEALTH } else if ((2400 < acc_adc) && (2500 > acc_adc)) { env_ptr = "ACCESSORY=cameron"; current_accessory = ACCESSORY_CAMERON; #endif } else if ((2676 < acc_adc) && (2785 > acc_adc)) { env_ptr = "ACCESSORY=OTG"; current_accessory = ACCESSORY_OTG; } else { env_ptr = "ACCESSORY=unknown"; current_accessory = ACCESSORY_UNKNOWN; } } else { /* not stmpe adc */ if ((797 < acc_adc) && (1002 > acc_adc)) { env_ptr = "ACCESSORY=lineout"; current_accessory = ACCESSORY_LINEOUT; } else if ((1134 < acc_adc) && (1352 > acc_adc)) { env_ptr = "ACCESSORY=carmount"; current_accessory = ACCESSORY_CARMOUNT; } else if ((1400 < acc_adc) && (1690 > acc_adc)) { env_ptr = "ACCESSORY=lineout"; current_accessory = ACCESSORY_LINEOUT; } else if ((1900 < acc_adc) && (2250 > acc_adc)) { env_ptr = "ACCESSORY=OTG"; current_accessory = ACCESSORY_OTG; } else { env_ptr = "ACCESSORY=unknown"; current_accessory = ACCESSORY_UNKNOWN; } } if (current_accessory == acc->current_accessory) { ACC_CONDEV_DBG("same accessory type is connected %d", current_accessory); return; } if (acc->current_accessory != ACCESSORY_NONE) { ACC_CONDEV_DBG("assuming prev accessory " "disconnected %d", acc->current_accessory); if (acc->current_accessory == ACCESSORY_OTG) envp[0] = "ACCESSORY=OTG"; else if (acc->current_accessory == ACCESSORY_LINEOUT) envp[0] = "ACCESSORY=lineout"; else if (acc->current_accessory == ACCESSORY_CARMOUNT) envp[0] = "ACCESSORY=carmount"; #ifdef CONFIG_CAMERON_HEALTH else if (acc->current_accessory == ACCESSORY_CAMERON) envp[0] = "ACCESSORY=cameron"; #endif else envp[0] = "ACCESSORY=unknown"; envp[1] = "STATE=offline"; envp[2] = NULL; kobject_uevent_env(&acc->acc_dev->kobj, KOBJ_CHANGE, envp); if ((acc->current_accessory == ACCESSORY_OTG) && acc->pdata->otg_en) acc->pdata->otg_en(0); if (acc->current_accessory == ACCESSORY_LINEOUT) switch_set_state(&acc->ear_jack_switch, UEVENT_DOCK_NONE); ACC_CONDEV_DBG("%s : %s", envp[0], envp[1]); } acc->current_accessory = current_accessory; stat_ptr = "STATE=online"; envp[0] = env_ptr; envp[1] = stat_ptr; envp[2] = NULL; if (acc->current_accessory == ACCESSORY_OTG) { /* force acc power off to ensure otg detection */ if (acc->pdata->acc_power) acc->pdata->acc_power(0, false); msleep(20); if (acc->pdata->otg_en) acc->pdata->otg_en(1); msleep(30); } else if (acc->current_accessory == ACCESSORY_LINEOUT) switch_set_state(&acc->ear_jack_switch, 1); #ifdef CONFIG_CAMERON_HEALTH else if (acc->current_accessory == ACCESSORY_CAMERON) { /* To do, when the cameron health device is connected */ /* force acc power off to ensure otg detection */ if (acc->pdata->acc_power) acc->pdata->acc_power(0, false); msleep(20); if (acc->pdata->cameron_health_en) acc->pdata->cameron_health_en(1); msleep(30); } #endif kobject_uevent_env(&acc->acc_dev->kobj, KOBJ_CHANGE, envp); ACC_CONDEV_DBG("%s : %s", env_ptr, stat_ptr); } else { if (acc->current_accessory == ACCESSORY_OTG) { env_ptr = "ACCESSORY=OTG"; } else if (acc->current_accessory == ACCESSORY_LINEOUT) { env_ptr = "ACCESSORY=lineout"; switch_set_state(&acc->ear_jack_switch, UEVENT_DOCK_NONE); } else if (acc->current_accessory == ACCESSORY_CARMOUNT) { env_ptr = "ACCESSORY=carmount"; #ifdef CONFIG_CAMERON_HEALTH } else if (acc->current_accessory == ACCESSORY_CAMERON) { env_ptr = "ACCESSORY=cameron"; #endif } else { env_ptr = "ACCESSORY=unknown"; } stat_ptr = "STATE=offline"; envp[0] = env_ptr; envp[1] = stat_ptr; envp[2] = NULL; kobject_uevent_env(&acc->acc_dev->kobj, KOBJ_CHANGE, envp); if ((acc->current_accessory == ACCESSORY_OTG) && acc->pdata->otg_en) acc->pdata->otg_en(0); #ifdef CONFIG_CAMERON_HEALTH else if (acc->current_accessory == ACCESSORY_CAMERON) acc->pdata->cameron_health_en(0); #endif acc->current_accessory = ACCESSORY_NONE; ACC_CONDEV_DBG("%s : %s", env_ptr, stat_ptr); } }