static void flip_cover_work(struct work_struct *work) { struct gpio_keys_drvdata *ddata = container_of(work, struct gpio_keys_drvdata, flip_cover_dwork.work); #ifdef CONFIG_SEC_FACTORY int comp_val[2]={0}; comp_val[0] = gpio_get_value(ddata->gpio_flip_cover); mdelay(50); comp_val[1] = gpio_get_value(ddata->gpio_flip_cover); if (comp_val[0] == comp_val[1]) { ddata->flip_cover = gpio_get_value(ddata->gpio_flip_cover); printk(KERN_DEBUG "[keys] %s : %d\n", __func__, ddata->flip_cover); input_report_switch(ddata->input, SW_FLIP, ddata->flip_cover); input_sync(ddata->input); } else { printk(KERN_DEBUG "%s : Value is not same!\n", __func__); } #else ddata->flip_cover = gpio_get_value(ddata->gpio_flip_cover); printk(KERN_DEBUG "[keys_no_delay] %s : %d\n",__func__, ddata->flip_cover); input_report_switch(ddata->input, SW_FLIP, ddata->flip_cover); input_sync(ddata->input); #endif }
static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata) { unsigned char input_value = 0xff; unsigned long flags; //unsigned int code; spin_lock_irqsave(&bdata->lock, flags); input_value = mt_get_gpio_in(bdata->button->gpio); if( bdata->irq != M7X_HALL_IRQ_NUM) { atomic_set(&bdata->key_pressed, (atomic_read(&bdata->key_pressed) == RELEASED)?PRESSED:RELEASED ); input_report_key(bdata->input, bdata->button->code, atomic_read(&bdata->key_pressed)); input_sync(bdata->input); } else { if( atomic_read(&bdata->key_pressed)==CLOSED ) { //code = 0x15; input_report_switch(bdata->input, bdata->button->code, RELEASED); input_sync(bdata->input); atomic_set(&bdata->key_pressed, REMOVED); #ifdef KEY_HALL_DEBUG key_hall_press = REMOVED; #endif } else { //code = 0x15; input_report_switch(bdata->input, bdata->button->code, PRESSED); input_sync(bdata->input); atomic_set(&bdata->key_pressed, CLOSED); #ifdef KEY_HALL_DEBUG key_hall_press = CLOSED; #endif } } spin_unlock_irqrestore(&bdata->lock, flags); #ifdef MEIZU_TP_NOTIFIER if(bdata->irq == M7X_HALL_IRQ_NUM) gpio_key_notify(atomic_read(&bdata->key_pressed),NULL); #endif if( atomic_read(&bdata->key_pressed)==PRESSED ) { schedule_delayed_work(&bdata->delayed_work, msecs_to_jiffies(bdata->timer_debounce)); } else { /* * cant use cancel_delayed_work_sync() in the context */ cancel_delayed_work(&bdata->delayed_work); } #ifdef KEYPAD_DEBUG printk("[Hall] %s: %s--%s gpio_in:%d\n", __func__, bdata->button->desc, (atomic_read(&bdata->key_pressed) == PRESSED)?"Pressed":"Released", input_value); #endif mt_eint_unmask(bdata->button->irq); }
static void remove_headset(struct hsd_info *hi) { int has_mic = switch_get_state(&hi->sdev); HSD_DBG("remove_headset"); gpio_set_value_cansleep(hi->gpio_mic_en, 0); if (hi->set_headset_mic_bias) hi->set_headset_mic_bias(FALSE); atomic_set(&hi->is_3_pole_or_not, 1); mutex_lock(&hi->mutex_lock); switch_set_state(&hi->sdev, NO_DEVICE); mutex_unlock(&hi->mutex_lock); if (atomic_read(&hi->irq_key_enabled)) { unsigned long irq_flags; local_irq_save(irq_flags); disable_irq(hi->irq_key); local_irq_restore(irq_flags); atomic_set(&hi->irq_key_enabled, FALSE); } if (atomic_read(&hi->btn_state)) #ifdef CONFIG_FSA8008_USE_LOCAL_WORK_QUEUE queue_delayed_work(local_fsa8008_workqueue, &(hi->work_for_key_released), hi->latency_for_key ); #else schedule_delayed_work(&(hi->work_for_key_released), hi->latency_for_key ); #endif input_report_switch(hi->input, SW_HEADPHONE_INSERT, 0); if (has_mic == LGE_HEADSET) input_report_switch(hi->input, SW_MICROPHONE_INSERT, 0); input_sync(hi->input); }
int pm8058_othc_svideo_enable(enum othc_micbias micbias, bool enable) { #if 0 struct pm8058_othc *dd = config[micbias]; if (dd == NULL) { pr_err("MIC_BIAS not registered, cannot enable\n"); return -ENODEV; } if (dd->othc_pdata->micbias_capability != OTHC_MICBIAS_HSED) { pr_err("MIC_BIAS enable capability not supported\n"); return -EINVAL; } if (dd->accessories_adc_support) { /* GPIO state for MIC_IN = 0, SVIDEO = 1 */ gpio_set_value_cansleep(dd->video_out_gpio, !!enable); if (enable) { pr_debug("Enable the video path\n"); switch_set_state(&dd->othc_sdev, dd->curr_accessory); input_report_switch(dd->othc_ipd, dd->curr_accessory_code, 1); input_sync(dd->othc_ipd); } else { pr_debug("Disable the video path\n"); switch_set_state(&dd->othc_sdev, 0); input_report_switch(dd->othc_ipd, dd->curr_accessory_code, 0); input_sync(dd->othc_ipd); } } #endif return 0; }
static void remove_headset(struct hsd_info *hi) { int has_mic = switch_get_state(&hi->sdev); HSD_DBG("remove_headset\n"); if(atomic_read(&hi->is_3_pole_or_not) == 1) spmi_write(0x80); if(atomic_read(&hi->is_3_pole_or_not) == 0) gpio_direction_output(hi->gpio_mic_en, 0); atomic_set(&hi->is_3_pole_or_not, 1); mutex_lock(&hi->mutex_lock); switch_set_state(&hi->sdev, NO_DEVICE); mutex_unlock(&hi->mutex_lock); input_report_switch(hi->input, SW_HEADPHONE_INSERT, 0); if (has_mic == LGE_HEADSET) input_report_switch(hi->input, SW_MICROPHONE_INSERT, 0); input_sync(hi->input); if (atomic_read(&hi->irq_key_enabled)) { atomic_set(&hi->irq_key_enabled, FALSE); } if (atomic_read(&hi->btn_state)) #ifdef CONFIG_MAX1462X_USE_LOCAL_WORK_QUEUE queue_delayed_work(local_max1462x_workqueue, &(hi->work_for_key_released), hi->latency_for_key ); #else schedule_delayed_work(&(hi->work_for_key_released), hi->latency_for_key ); #endif atomic_set(&hi->isdetect,FALSE); }
static irqreturn_t flip_cover_detect_isr(int irq, void *dev_id) { struct sci_keypad_t *sci_kpd = dev_id; static int last_value = -1; unsigned int value = gpio_get_value(FLIP_INT); if (value) { /* flip open : high level */ input_report_switch(sci_kpd->input_dev, SW_FLIP, value); input_sync(sci_kpd->input_dev); #if PRINT_KEY_LOG printk("[KEY] hall ic (in irq handler) :: %d, (last_value:%d)\n", value, last_value); #endif irq_set_irq_type(irq, IRQF_TRIGGER_LOW); } else { /* flip close : low level */ input_report_switch(sci_kpd->input_dev, SW_FLIP, value); input_sync(sci_kpd->input_dev); #if PRINT_KEY_LOG printk("[KEY] hall ic (in irq handler) :: %d, (last_value:%d)\n", value, last_value); #endif irq_set_irq_type(irq, IRQF_TRIGGER_HIGH); } last_value = value; return IRQ_HANDLED; }
static void sec_report_flip_key(struct sec_flip *flip) { #if 0 //REPORT_KEY change by yuechun.yao if (flip_status) { input_report_key(flip->input, KEY_FOLDER_OPEN, 1); input_report_key(flip->input, KEY_FOLDER_OPEN, 0); input_sync(flip->input); dbg_printk("[FLIP] %s: input flip key : open\n", __FUNCTION__); } else { input_report_key(flip->input, KEY_FOLDER_CLOSE, 1); input_report_key(flip->input, KEY_FOLDER_CLOSE, 0); input_sync(flip->input); dbg_printk ("[FLIP] %s: input flip key : close\n", __FUNCTION__); } #else if (flip_status) { if(flip_status_before == flip_status) { input_report_switch(flip->input, SW_LID, 1); dbg_printk("[FLIP] %s: force 1 upload : open\n", __FUNCTION__); } input_report_switch(flip->input, SW_LID, 0); input_sync(flip->input); dbg_printk("[FLIP] %s: input flip key : open\n", __FUNCTION__); } else { if(flip_status_before == flip_status) { input_report_switch(flip->input, SW_LID, 0); dbg_printk("[FLIP] %s: force 0 upload : close\n", __FUNCTION__); } input_report_switch(flip->input, SW_LID, 1); input_sync(flip->input); dbg_printk ("[FLIP] %s: input flip key : close\n", __FUNCTION__); } #endif }
static void detect_tablet_mode(struct platform_device *device) { const char *chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE); struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); acpi_handle handle = ACPI_HANDLE(&device->dev); struct acpi_buffer vgbs_output = { ACPI_ALLOCATE_BUFFER, NULL }; union acpi_object *obj; acpi_status status; int m; if (!(chassis_type && strcmp(chassis_type, "31") == 0)) goto out; status = acpi_evaluate_object(handle, "VGBS", NULL, &vgbs_output); if (ACPI_FAILURE(status)) goto out; obj = vgbs_output.pointer; if (!(obj && obj->type == ACPI_TYPE_INTEGER)) goto out; m = !(obj->integer.value & TABLET_MODE_FLAG); input_report_switch(priv->input_dev, SW_TABLET_MODE, m); m = (obj->integer.value & DOCK_MODE_FLAG) ? 1 : 0; input_report_switch(priv->input_dev, SW_DOCK, m); out: kfree(vgbs_output.pointer); }
static void report_headset_switch(struct input_dev *dev, int key, int value) { struct msm_handset *hs = input_get_drvdata(dev); #if 0 input_report_switch(dev, key, value); switch_set_state(&hs->sdev, value); #else switch(value) { case MSM_HEADSET_STE: #if DEBUG printk(KERN_INFO "[msm-handset] [%s] key = %d, !!value = %d, value = %d\n", __func__, key, !!value, value); #endif input_report_switch(dev, key, !!value); break; case NO_DEVICE: #if DEBUG printk(KERN_INFO "[msm-handset] [%s] key = %d, !!value = %d, value = %d\n", __func__, key, !!value, value); #endif input_report_switch(dev, key, !!value); break; default: #if DEBUG printk(KERN_INFO "[msm-handset] [%s] non Value [%d]\n", __func__, value); #endif break; } Headset_Status = value; switch_set_state(&hs->sdev, !!value); #endif }
static void sec_report_flip_key(struct sec_flip *flip) { #if REPORT_KEY if (flip_status) { input_report_key(flip->input, KEY_FOLDER_OPEN, 1); input_report_key(flip->input, KEY_FOLDER_OPEN, 0); input_sync(flip->input); dbg_printk("[FLIP] %s: input flip key : open\n", __FUNCTION__); } else { input_report_key(flip->input, KEY_FOLDER_CLOSE, 1); input_report_key(flip->input, KEY_FOLDER_CLOSE, 0); input_sync(flip->input); dbg_printk ("[FLIP] %s: input flip key : close\n", __FUNCTION__); } #else if (flip_status) { input_report_switch(flip->input, SW_LID, 0); input_sync(flip->input); dbg_printk("[FLIP] %s: input flip key : open\n", __FUNCTION__); } else { input_report_switch(flip->input, SW_LID, 1); input_sync(flip->input); dbg_printk ("[FLIP] %s: input flip key : close\n", __FUNCTION__); } #endif }
static void corgikbd_hinge_timer(unsigned long data) { struct corgikbd *corgikbd_data = (struct corgikbd *) data; unsigned long gprr; unsigned long flags; gprr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_GPRR) & (CORGI_SCP_SWA | CORGI_SCP_SWB); gprr |= (READ_GPIO_BIT(CORGI_GPIO_AK_INT) != 0); if (gprr != sharpsl_hinge_state) { hinge_count = 0; sharpsl_hinge_state = gprr; } else if (hinge_count < HINGE_STABLE_COUNT) { hinge_count++; if (hinge_count >= HINGE_STABLE_COUNT) { spin_lock_irqsave(&corgikbd_data->lock, flags); input_report_switch(corgikbd_data->input, SW_LID, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0)); input_report_switch(corgikbd_data->input, SW_TABLET_MODE, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0)); input_report_switch(corgikbd_data->input, SW_HEADPHONE_INSERT, (READ_GPIO_BIT(CORGI_GPIO_AK_INT) != 0)); input_sync(corgikbd_data->input); spin_unlock_irqrestore(&corgikbd_data->lock, flags); } } mod_timer(&corgikbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); }
static void max1462x_remove_headset(struct max1462x_hsd_info *hi) { int earjack_type = JACK_NONE; pr_info("%s\n", __func__); if (atomic_read(&hi->is_3_pole_or_not)) earjack_type = JACK_HEADPHONE_3_POLE; else earjack_type = JACK_HEADPSET_4_POLE; atomic_set(&hi->is_3_pole_or_not, 1); mutex_lock(&hi->mutex_lock); switch_set_state(&hi->sdev, NO_DEVICE); input_report_switch(hi->input, SW_HEADPHONE_INSERT, 0); if (earjack_type == JACK_HEADPSET_4_POLE) input_report_switch(hi->input, SW_MICROPHONE_INSERT, 0); input_sync(hi->input); mutex_unlock(&hi->mutex_lock); if (atomic_read(&hi->irq_key_enabled)) { disable_irq(hi->irq_key); atomic_set(&hi->irq_key_enabled, false); disable_irq_wake(hi->irq_key); } if (atomic_read(&hi->btn_state)) { queue_delayed_work(local_max1462x_workqueue, &(hi->work_for_key_released), hi->latency_for_key); } }
static void report_hs_key(uint32_t key_code, uint32_t key_parm) { int key, temp_key_code; if (key_code == HS_REL_K) key = hs_find_key(key_parm); else key = hs_find_key(key_code); temp_key_code = key_code; if (key_parm == HS_REL_K) key_code = key_parm; switch (key) { case KEY_POWER: case KEY_END: case KEY_MEDIA: case KEY_VOLUMEUP: case KEY_VOLUMEDOWN: input_report_key(hs->ipdev, key, (key_code != HS_REL_K)); break; case SW_HEADPHONE_INSERT_W_MIC: hs->mic_on = hs->hs_on = (key_code != HS_REL_K) ? 1 : 0; input_report_switch(hs->ipdev, SW_HEADPHONE_INSERT, hs->hs_on); input_report_switch(hs->ipdev, SW_MICROPHONE_INSERT, hs->mic_on); update_state(); break; case SW_HEADPHONE_INSERT: hs->hs_on = (key_code != HS_REL_K) ? 1 : 0; input_report_switch(hs->ipdev, key, hs->hs_on); update_state(); break; case SW_MICROPHONE_INSERT: hs->mic_on = (key_code != HS_REL_K) ? 1 : 0; input_report_switch(hs->ipdev, key, hs->mic_on); update_state(); break; #ifdef FEATURE_KYOCERA_MSND case HS_LINE_SPEAKER: if( key_code != HS_REL_K ) { msm_snddev_poweramp_on(); } else { msm_snddev_poweramp_off(); } break; #endif case -1: printk(KERN_ERR "%s: No mapping for remote handset event %d\n", __func__, temp_key_code); return; } input_sync(hs->ipdev); }
static void insert_headset(struct hsd_info *hi) { int earjack_type; HSD_DBG("insert_headset\n"); if (atomic_read(&hi->isdetect)) { HSD_DBG("duplicate irq\n"); return; } atomic_set(&hi->isdetect, TRUE); irq_set_irq_wake(hi->irq_key, 1); gpio_direction_output(hi->gpio_mic_en, 1); msleep(40); HSD_DBG("insert delay 40\n"); /* */ earjack_type = hi->gpio_get_value_func(hi->gpio_key); if (earjack_type == 1) { HSD_DBG("4 polarity earjack\n"); atomic_set(&hi->is_3_pole_or_not, 0); mutex_lock(&hi->mutex_lock); switch_set_state(&hi->sdev, LGE_HEADSET); mutex_unlock(&hi->mutex_lock); if (!atomic_read(&hi->irq_key_enabled)) { HSD_DBG("irq_key_enabled = FALSE\n"); atomic_set(&hi->irq_key_enabled, TRUE); } input_report_switch(hi->input, SW_HEADPHONE_INSERT, 1); input_report_switch(hi->input, SW_MICROPHONE_INSERT, 1); input_sync(hi->input); } else { gpio_direction_output(hi->gpio_mic_en, 0); spmi_write(0x00); HSD_DBG("3 polarity earjack\n"); atomic_set(&hi->is_3_pole_or_not, 1); mutex_lock(&hi->mutex_lock); switch_set_state(&hi->sdev, LGE_HEADSET_NO_MIC); mutex_unlock(&hi->mutex_lock); irq_set_irq_wake(hi->irq_key, 0); input_report_switch(hi->input, SW_HEADPHONE_INSERT, 1); input_sync(hi->input); } }
static void insert_headset(struct hsd_info *hi) { int earjack_type; HSD_DBG("insert_headset\n"); if (atomic_read(&hi->isdetect)) { HSD_DBG("duplicate irq\n"); return; } atomic_set(&hi->isdetect, TRUE); irq_set_irq_wake(hi->irq_key, 1); gpio_direction_output(hi->gpio_mic_en, 1); msleep(40); HSD_DBG("insert delay 40\n"); /* check if 3-pole or 4-pole 1. read gpio_key 2. check if 3-pole or 4-pole 3-1. NOT regiter irq with gpio_key if 3-pole. complete. 3-2. regiter irq with gpio_key if 4-pole 4. read MPP6 and decide a pressed key when interrupt occurs */ earjack_type = hi->gpio_get_value_func(hi->gpio_key); if (earjack_type == 1) { HSD_DBG("4 polarity earjack\n"); atomic_set(&hi->is_3_pole_or_not, 0); mutex_lock(&hi->mutex_lock); switch_set_state(&hi->sdev, LGE_HEADSET); mutex_unlock(&hi->mutex_lock); if (!atomic_read(&hi->irq_key_enabled)) { HSD_DBG("irq_key_enabled = FALSE\n"); atomic_set(&hi->irq_key_enabled, TRUE); } input_report_switch(hi->input, SW_HEADPHONE_INSERT, 1); input_report_switch(hi->input, SW_MICROPHONE_INSERT, 1); input_sync(hi->input); } else { gpio_direction_output(hi->gpio_mic_en, 0); spmi_write(0x00); HSD_DBG("3 polarity earjack\n"); atomic_set(&hi->is_3_pole_or_not, 1); mutex_lock(&hi->mutex_lock); switch_set_state(&hi->sdev, LGE_HEADSET_NO_MIC); mutex_unlock(&hi->mutex_lock); irq_set_irq_wake(hi->irq_key, 0); input_report_switch(hi->input, SW_HEADPHONE_INSERT, 1); input_sync(hi->input); } }
static int __init hp_wmi_input_setup(void) { acpi_status status; int err, val; hp_wmi_input_dev = input_allocate_device(); if (!hp_wmi_input_dev) return -ENOMEM; hp_wmi_input_dev->name = "HP WMI hotkeys"; hp_wmi_input_dev->phys = "wmi/input0"; hp_wmi_input_dev->id.bustype = BUS_HOST; __set_bit(EV_SW, hp_wmi_input_dev->evbit); /* Dock */ val = hp_wmi_hw_state(HPWMI_DOCK_MASK); if (!(val < 0)) { __set_bit(SW_DOCK, hp_wmi_input_dev->swbit); input_report_switch(hp_wmi_input_dev, SW_DOCK, val); } /* Tablet mode */ val = hp_wmi_hw_state(HPWMI_TABLET_MASK); if (!(val < 0)) { __set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit); input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, val); } err = sparse_keymap_setup(hp_wmi_input_dev, hp_wmi_keymap, NULL); if (err) goto err_free_dev; /* Set initial hardware state */ input_sync(hp_wmi_input_dev); if (!hp_wmi_bios_2009_later() && hp_wmi_bios_2008_later()) hp_wmi_enable_hotkeys(); status = wmi_install_notify_handler(HPWMI_EVENT_GUID, hp_wmi_notify, NULL); if (ACPI_FAILURE(status)) { err = -EIO; goto err_free_dev; } err = input_register_device(hp_wmi_input_dev); if (err) goto err_uninstall_notifier; return 0; err_uninstall_notifier: wmi_remove_notify_handler(HPWMI_EVENT_GUID); err_free_dev: input_free_device(hp_wmi_input_dev); return err; }
static void max1462x_insert_headset(struct max1462x_hsd_info *hi) { int earjack_type; pr_info("%s\n", __func__); /* If you reduce the delay time, it will cause problems. */ msleep(40); /* Issue : Recognized 3-pole after reboot from 4-pole earjack plug. */ /* check if 3-pole or 4-pole * 1. read gpio_key * 2. check if 3-pole or 4-pole * 3-1. NOT regiter irq with gpio_key if 3-pole. complete. * 3-2. regiter irq with gpio_key if 4-pole * 4. read MPP6 and decide a pressed key when interrupt occurs */ earjack_type = gpio_get_value(hi->gpio_key); if (earjack_type == 1) { pr_debug("%s: 4 polarity earjack\n", __func__); atomic_set(&hi->is_3_pole_or_not, 0); mutex_lock(&hi->mutex_lock); switch_set_state(&hi->sdev, MAX1642X_HEADSET); input_report_switch(hi->input, SW_HEADPHONE_INSERT, 1); input_report_switch(hi->input, SW_MICROPHONE_INSERT, 1); input_sync(hi->input); mutex_unlock(&hi->mutex_lock); if (!atomic_read(&hi->irq_key_enabled)) { pr_debug("%s: irq_key_enabled = FALSE, key IRQ = %d\n", __func__, hi->irq_key); enable_irq(hi->irq_key); atomic_set(&hi->irq_key_enabled, true); enable_irq_wake(hi->irq_key); } } else { pr_debug("%s; 3 polarity earjack\n", __func__); atomic_set(&hi->is_3_pole_or_not, 1); mutex_lock(&hi->mutex_lock); switch_set_state(&hi->sdev, MAX1642X_HEADSET_NO_MIC); input_report_switch(hi->input, SW_HEADPHONE_INSERT, 1); input_sync(hi->input); mutex_unlock(&hi->mutex_lock); if (atomic_read(&hi->irq_key_enabled)) { pr_debug("%s: irq_key_enabled = TRUE, key IRQ = %d\n", __func__, hi->irq_key); disable_irq(hi->irq_key); atomic_set(&hi->irq_key_enabled, false); disable_irq_wake(hi->irq_key); } } }
static void process_lid(struct input_dev *ikbdev, unsigned char scancode) { if (scancode == SCAN_LIDSW_OPEN) input_report_switch(ikbdev, SW_LID, 0); else if (scancode == SCAN_LIDSW_CLOSE) input_report_switch(ikbdev, SW_LID, 1); else return; input_sync(ikbdev); }
/* * tuple format: (key_code, key_param) * * old-architecture: * key-press = (key_code, 0) * key-release = (0xff, key_code) * * new-architecutre: * key-press = (key_code, 0) * key-release = (key_code, 0xff) */ static void report_hs_key(uint32_t key_code, uint32_t key_parm) { int key, temp_key_code; if (key_code == HS_REL_K) key = hs_find_key(key_parm); else key = hs_find_key(key_code); temp_key_code = key_code; if (key_parm == HS_REL_K) key_code = key_parm; switch (key) { case KEY_POWER: case KEY_END: if (hs->hs_pdata->ignore_end_key) input_report_key(hs->ipdev, KEY_POWER, (key_code != HS_REL_K)); else input_report_key(hs->ipdev, key, (key_code != HS_REL_K)); break; case KEY_MEDIA: case KEY_VOLUMEUP: case KEY_VOLUMEDOWN: input_report_key(hs->ipdev, key, (key_code != HS_REL_K)); break; case SW_HEADPHONE_INSERT_W_MIC: hs->mic_on = hs->hs_on = (key_code != HS_REL_K) ? 1 : 0; input_report_switch(hs->ipdev, SW_HEADPHONE_INSERT, hs->hs_on); input_report_switch(hs->ipdev, SW_MICROPHONE_INSERT, hs->mic_on); update_state(); break; case SW_HEADPHONE_INSERT: hs->hs_on = (key_code != HS_REL_K) ? 1 : 0; input_report_switch(hs->ipdev, key, hs->hs_on); update_state(); break; case SW_MICROPHONE_INSERT: hs->mic_on = (key_code != HS_REL_K) ? 1 : 0; input_report_switch(hs->ipdev, key, hs->mic_on); update_state(); break; case -1: printk(KERN_ERR "%s: No mapping for remote handset event %d\n", __func__, temp_key_code); return; } input_sync(hs->ipdev); }
/* * tuple format: (key_code, key_param) * * old-architecture: * key-press = (key_code, 0) * key-release = (0xff, key_code) * * new-architecutre: * key-press = (key_code, 0) * key-release = (key_code, 0xff) */ static void report_hs_key(uint32_t key_code, uint32_t key_parm) { int key, temp_key_code; if (key_code == HS_REL_K) key = hs_find_key(key_parm); else key = hs_find_key(key_code); temp_key_code = key_code; if (key_parm == HS_REL_K) key_code = key_parm; switch (key) { case KEY_POWER: case KEY_END: case KEY_MEDIA: case KEY_VOLUMEUP: case KEY_VOLUMEDOWN: input_report_key(hs->ipdev, key, (key_code != HS_REL_K)); #if (defined(CONFIG_MACH_ARIESVE) || defined(CONFIG_MACH_ANCORA) || defined(CONFIG_MACH_GODART)) key_pressed=(key_code != HS_REL_K); #ifdef KERNEL_DEBUG_SEC printk("[key] pwercode %d, %d \n", key, key_pressed); #endif #endif break; case SW_HEADPHONE_INSERT_W_MIC: hs->mic_on = hs->hs_on = (key_code != HS_REL_K) ? 1 : 0; input_report_switch(hs->ipdev, SW_HEADPHONE_INSERT, hs->hs_on); input_report_switch(hs->ipdev, SW_MICROPHONE_INSERT, hs->mic_on); update_state(); break; case SW_HEADPHONE_INSERT: hs->hs_on = (key_code != HS_REL_K) ? 1 : 0; input_report_switch(hs->ipdev, key, hs->hs_on); update_state(); break; case SW_MICROPHONE_INSERT: hs->mic_on = (key_code != HS_REL_K) ? 1 : 0; input_report_switch(hs->ipdev, key, hs->mic_on); update_state(); break; case -1: printk(KERN_ERR "%s: No mapping for remote handset event %d\n", __func__, temp_key_code); return; } input_sync(hs->ipdev); }
static int jack_notifier_event(struct notifier_block *nb, unsigned long event, void *data) { struct snd_soc_codec *codec; struct wm8994_priv *wm8994; struct snd_soc_jack *jack; // Force enable will keep the MICBISA on, even when we stop reording jack = data; if(jack) { codec = jack->card->codec; wm8994 = snd_soc_codec_get_drvdata(codec); if(1 == event){ // Someone inserted a jack, we need to turn on mic bias2 for headset mic detection snd_soc_dapm_force_enable_pin( codec, "MICBIAS2"); pr_crit("MIC DETECT: ENABLE. Jack inserted\n"); // This will enable mic detection on 8958 wm8958_mic_detect( codec, &hp_jack, NULL, NULL); }else if (0 == event){ headphone_plugged = 0; if (headphone_switch) { switch_set_state(headphone_switch, headphone_plugged); } pr_crit("MIC DETECT: DISABLE. Jack removed\n"); // This will disable mic detection on 8958 wm8958_mic_detect( codec, NULL, NULL, NULL); if( wm8994->pdata->jack_is_mic) { dev_err(codec->dev, " Reporting headset removed\n"); wm8994->pdata->jack_is_mic = false; wm8994->micdet[0].jack->jack->type = SND_JACK_MICROPHONE; input_report_switch(wm8994->micdet[0].jack->jack->input_dev, SW_MICROPHONE_INSERT, 0); } else { dev_err(codec->dev, " Reporting headphone removed\n"); input_report_switch(wm8994->micdet[0].jack->jack->input_dev, SW_HEADPHONE_INSERT, 0); } input_sync(jack->jack->input_dev); snd_soc_dapm_disable_pin( codec, "MICBIAS2"); } } return 0; }
static irqreturn_t hall_ic_irq(int irq, void *data) { struct pmic8xxx_kp *kp = data; int hall_status = gpio_get_value(MSM_HALL_IC); if (hall_status) input_report_switch(kp->input, SW_LID, !!hall_status); else input_report_switch(kp->input, SW_LID, !!hall_status); input_sync(kp->input); printk(KERN_INFO "[input_report_switch] slide_int on hall_ic_irq() - !gpio_hall_ic %s\n", hall_status == 0 ? "OPEN" : "CLOSE"); return IRQ_HANDLED; }
static void remove_headset(struct hsd_info *hi) { int has_mic = switch_get_state(&hi->sdev); HSD_DBG("remove_headset"); atomic_set(&hi->is_3_pole_or_not, HEADSET_POLE_INIT); mutex_lock(&hi->mutex_lock); switch_set_state(&hi->sdev, HEADSET_NO_DEVICE); mutex_unlock(&hi->mutex_lock); if (atomic_read(&hi->irq_key_enabled)) { unsigned long irq_flags; local_irq_save(irq_flags); disable_irq(hi->irq_key); local_irq_restore(irq_flags); atomic_set(&hi->irq_key_enabled, FALSE); } if( atomic_read(&hi->btn_state) == HEADSET_BTN_PRESSED ) #ifdef CONFIG_MAX1462X_USE_LOCAL_WORK_QUEUE queue_delayed_work(local_max1462x_workqueue, &(hi->work_for_key_released), hi->latency_for_key ); #else schedule_delayed_work(&(hi->work_for_key_released), hi->latency_for_key ); #endif input_report_switch(hi->input, SW_HEADPHONE_INSERT, 0); if (has_mic == HEADSET_WITH_MIC) { irq_set_irq_wake(hi->irq_key, 0); input_report_switch(hi->input, SW_MICROPHONE_INSERT, 0); //LGE_CHANGE_S 20130710 ilda.jung[Audio] Disable not using GPIO #if !defined(CONFIG_MACH_APQ8064_AWIFI) // set low to an external LDO for mic bias if (hi->set_headset_mic_bias) { hi->set_headset_mic_bias(FALSE); } else if( hi->external_ldo_mic_bias > 0 ) { gpio_cansleep(hi->external_ldo_mic_bias) ? gpio_set_value_cansleep(hi->external_ldo_mic_bias, 0) : gpio_set_value(hi->external_ldo_mic_bias, 0); } #endif //LGE_CHANGE_E 20130710 ilda.jung[Audio] Disable not using GPIO } input_sync(hi->input); }
static void flip_cover_work(struct work_struct *work) { bool first; struct gpio_keys_drvdata *ddata = container_of(work, struct gpio_keys_drvdata, flip_cover_dwork.work); first = gpio_get_value(ddata->gpio_flip_cover); #ifdef CONFIG_W1_SLAVE_DS28EL15 printk(KERN_DEBUG "[keys] %s : %d, gpio_flip_cover(%d)\n", __func__, ddata->flip_cover, first); /* check verification status only when closing s-cover */ if(!first) if(check_verification_status()) return; #else printk(KERN_DEBUG "keys:%s #1 : %d\n", __func__, first); #endif if(ddata->flip_cover != first) { ddata->flip_cover = first; input_report_switch(ddata->input, SW_FLIP, ddata->flip_cover); input_sync(ddata->input); } }
static void flip_cover_work(struct work_struct *work) { bool first,second; struct gpio_keys_drvdata *ddata = container_of(work, struct gpio_keys_drvdata, flip_cover_dwork.work); first = gpio_get_value(ddata->gpio_flip_cover); printk(KERN_DEBUG "keys:%s #1 : %d\n", __func__, first); msleep(50); second = gpio_get_value(ddata->gpio_flip_cover); #ifdef CONFIG_W1_SLAVE_DS28EL15 printk(KERN_DEBUG "[keys] %s : %d, Verification(%d)\n", __func__, ddata->flip_cover, verification); #else printk(KERN_DEBUG "keys:%s #2 : %d\n", __func__, second); #endif if(first == second && ddata->flip_cover != first) { ddata->flip_cover = first; input_report_switch(ddata->input, SW_FLIP, ddata->flip_cover); input_sync(ddata->input); } }
static void flip_cover_work(struct work_struct *work) { bool first,second; struct gpio_keys_drvdata *ddata = container_of(work, struct gpio_keys_drvdata, flip_cover_dwork.work); first = gpio_get_value(ddata->gpio_flip_cover); printk(KERN_DEBUG "[keys] %s #1 : %d\n", __func__, first); msleep(50); second = gpio_get_value(ddata->gpio_flip_cover); printk(KERN_DEBUG "[keys] %s #2 : %d\n", __func__, second); if(first == second && ddata->flip_cover != first) { ddata->flip_cover = first; input_report_switch(ddata->input, SW_FLIP, ddata->flip_cover); input_sync(ddata->input); } }
/*----------------------------------------------------------------------------*/ static void hall_eint_work(struct work_struct *work) { int err; HALL_LOG("hall_eint_work()\n"); if((err = hall_read_status(&g_hall_ptr->hall_status))) { HALL_ERR("hall_read_value: %d\n", err); } if (g_hall_ptr->hall_status == 1) { HALL_ERR("HALL OPEN!!! \n"); mt_eint_set_polarity(CUST_EINT_HALL_COVER_NUM, MT_POLARITY_LOW); } else { HALL_ERR("HALL CLOSE!!! \n"); mt_eint_set_polarity(CUST_EINT_HALL_COVER_NUM, MT_POLARITY_HIGH); } input_report_switch(g_hall_ptr->idev, g_hall_ptr->sw_code, g_hall_ptr->hall_status); input_sync(g_hall_ptr->idev); mt_eint_unmask(CUST_EINT_HALL_COVER_NUM); }
static void pen_insert_work(struct work_struct *work) { struct wacom_i2c *wac_i2c = container_of(work, struct wacom_i2c, pen_insert_dwork.work); if (wac_i2c->init_fail) return; wac_i2c->pen_insert = !gpio_get_value(wac_i2c->gpio_pen_insert); dev_info(&wac_i2c->client->dev, "%s: pen %s\n", __func__, wac_i2c->pen_insert ? "instert" : "remove"); input_report_switch(wac_i2c->input_dev, SW_PEN_INSERT, !wac_i2c->pen_insert); input_sync(wac_i2c->input_dev); #ifdef BATTERY_SAVING_MODE if (wac_i2c->pen_insert) { if (wac_i2c->battery_saving_mode) wacom_i2c_disable(wac_i2c); } else { wacom_i2c_enable(wac_i2c); } #endif }
/** * snd_jack_report - Report the current status of a jack * * @jack: The jack to report status for * @status: The current status of the jack */ void snd_jack_report(struct snd_jack *jack, int status) { int i; if (!jack) return; for (i = 0; i < ARRAY_SIZE(jack->key); i++) { int testbit = SND_JACK_BTN_0 >> i; if (jack->type & testbit) input_report_key(jack->input_dev, jack->key[i], status & testbit); } for (i = 0; i < ARRAY_SIZE(jack_switch_types); i++) { int testbit = 1 << i; if (jack->type & testbit) input_report_switch(jack->input_dev, jack_switch_types[i], status & testbit); } input_sync(jack->input_dev); }
static void report_headset_switch(struct input_dev *dev, int key, int value) { struct msm_handset *hs = input_get_drvdata(dev); value *= 2; // Hack to force headset no mic input_report_switch(dev, key, value); switch_set_state(&hs->sdev, value); }