void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac) { input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER); }
static int ucb1400_ts_probe(struct platform_device *dev) { int error, x_res, y_res; u16 fcsr; struct ucb1400_ts *ucb = dev->dev.platform_data; ucb->ts_idev = input_allocate_device(); if (!ucb->ts_idev) { error = -ENOMEM; goto err; } /* Only in case the IRQ line wasn't supplied, try detecting it */ if (ucb->irq < 0) { error = ucb1400_ts_detect_irq(ucb); if (error) { printk(KERN_ERR "UCB1400: IRQ probe failed\n"); goto err_free_devs; } } init_waitqueue_head(&ucb->ts_wait); error = request_irq(ucb->irq, ucb1400_hard_irq, IRQF_TRIGGER_RISING, "UCB1400", ucb); if (error) { printk(KERN_ERR "ucb1400: unable to grab irq%d: %d\n", ucb->irq, error); goto err_free_devs; } printk(KERN_DEBUG "UCB1400: found IRQ %d\n", ucb->irq); input_set_drvdata(ucb->ts_idev, ucb); ucb->ts_idev->dev.parent = &dev->dev; ucb->ts_idev->name = "UCB1400 touchscreen interface"; ucb->ts_idev->id.vendor = ucb1400_reg_read(ucb->ac97, AC97_VENDOR_ID1); ucb->ts_idev->id.product = ucb->id; ucb->ts_idev->open = ucb1400_ts_open; ucb->ts_idev->close = ucb1400_ts_close; ucb->ts_idev->evbit[0] = BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY); ucb->ts_idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); /* * Enable ADC filter to prevent horrible jitter on Colibri. * This also further reduces jitter on boards where ADCSYNC * pin is connected. */ fcsr = ucb1400_reg_read(ucb->ac97, UCB_FCSR); ucb1400_reg_write(ucb->ac97, UCB_FCSR, fcsr | UCB_FCSR_AVE); ucb1400_adc_enable(ucb->ac97); x_res = ucb1400_ts_read_xres(ucb); y_res = ucb1400_ts_read_yres(ucb); ucb1400_adc_disable(ucb->ac97); printk(KERN_DEBUG "UCB1400: x/y = %d/%d\n", x_res, y_res); input_set_abs_params(ucb->ts_idev, ABS_X, 0, x_res, 0, 0); input_set_abs_params(ucb->ts_idev, ABS_Y, 0, y_res, 0, 0); input_set_abs_params(ucb->ts_idev, ABS_PRESSURE, 0, 0, 0, 0); error = input_register_device(ucb->ts_idev); if (error) goto err_free_irq; return 0; err_free_irq: free_irq(ucb->irq, ucb); err_free_devs: input_free_device(ucb->ts_idev); err: return error; }
static int __devinit gpio_keys_probe(struct platform_device *pdev) { const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; struct gpio_keys_drvdata *ddata; struct gpio_keys_button *button = NULL; struct gpio_button_data *bdata = NULL; struct device *dev = &pdev->dev; struct gpio_keys_platform_data alt_pdata; struct input_dev *input; int i, error; int wakeup = 0; int ret; struct device *sec_key; #ifdef CONFIG_SEC_PATEK_PROJECT struct device *sec_keypad; struct device *sec_flip; #endif if (!pdata) { error = gpio_keys_get_devtree_pdata(dev, &alt_pdata); if (error) return error; pdata = &alt_pdata; } ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + pdata->nbuttons * sizeof(struct gpio_button_data), GFP_KERNEL); input = input_allocate_device(); if (!ddata || !input) { dev_err(dev, "failed to allocate state\n"); error = -ENOMEM; goto fail1; } ddata->input = input; ddata->n_buttons = pdata->nbuttons; ddata->enable = pdata->enable; ddata->disable = pdata->disable; #ifdef CONFIG_SENSORS_HALL_DEBOUNCE ddata->debounce_set = pdata->debounce_set; #endif #ifdef CONFIG_SENSORS_HALL #if defined (CONFIG_SEC_MILLET_PROJECT) || defined (CONFIG_SEC_BERLUTI_PROJECT)\ || defined (CONFIG_SEC_MATISSE_PROJECT) || defined (CONFIG_SEC_ATLANTIC_PROJECT)\ || defined (CONFIG_SEC_MEGA2_PROJECT) || defined (CONFIG_SEC_T8_PROJECT) || defined (CONFIG_SEC_T10_PROJECT) || defined(CONFIG_SEC_HESTIA_PROJECT) ret = gpio_request(pdata->gpio_flip_cover,"HALL"); if(ret) printk(KERN_CRIT "[HALL IC] gpio Request FAIL\n"); else { gpio_tlmm_config(GPIO_CFG(pdata->gpio_flip_cover,0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,GPIO_CFG_2MA),GPIO_CFG_DISABLE); } #endif ddata->gpio_flip_cover = pdata->gpio_flip_cover; ddata->flip_code = pdata->flip_code; ddata->irq_flip_cover = gpio_to_irq(ddata->gpio_flip_cover); wake_lock_init(&ddata->flip_wake_lock, WAKE_LOCK_SUSPEND, "flip_wake_lock"); flip_status_before = -1; #endif mutex_init(&ddata->disable_lock); #ifdef CONFIG_SENSORS_HALL_IRQ_CTRL mutex_init(&ddata->irq_lock); #endif platform_set_drvdata(pdev, ddata); input_set_drvdata(input, ddata); input->name = pdata->name ? : pdev->name; input->phys = "gpio-keys/input0"; input->dev.parent = &pdev->dev; #ifdef CONFIG_SENSORS_HALL if(ddata->gpio_flip_cover != 0) { input->evbit[0] |= BIT_MASK(EV_SW); input_set_capability(input, EV_SW, ddata->flip_code); } #endif #ifdef CONFIG_SENSORS_HALL_IRQ_CTRL ddata->gsm_area = false; ddata->cover_state = false; ddata->workaround_set = pdata->workaround_set; drv_data = ddata; #endif #ifdef CONFIG_SENSORS_HALL_DEBOUNCE ddata->debounce_set = false; #endif input->open = gpio_keys_open; input->close = gpio_keys_close; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; input->id.product = 0x0001; input->id.version = 0x0100; /* Enable auto repeat feature of Linux input subsystem */ if (pdata->rep) __set_bit(EV_REP, input->evbit); for (i = 0; i < pdata->nbuttons; i++) { button = &pdata->buttons[i]; bdata = &ddata->data[i]; error = gpio_keys_setup_key(pdev, input, bdata, button); if (error) goto fail2; #ifdef KEY_BOOSTER error = gpio_key_init_dvfs(bdata); if (error < 0) { dev_err(dev, "Fail get dvfs level for touch booster\n"); goto fail2; } #endif if (button->wakeup) wakeup = 1; } error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); if (error) { dev_err(dev, "Unable to export keys/switches, error: %d\n", error); goto fail2; } error = input_register_device(input); if (error) { dev_err(dev, "Unable to register input device, error: %d\n", error); goto fail3; } /* get current state of buttons that are connected to GPIOs */ for (i = 0; i < pdata->nbuttons; i++) { bdata = &ddata->data[i]; if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); } input_sync(input); sec_key = device_create(sec_class, NULL, 0, NULL, "sec_key"); if (IS_ERR(sec_key)) pr_err("Failed to create device(sec_key)!\n"); #ifdef CONFIG_SEC_PATEK_PROJECT sec_keypad=device_create(sec_class, NULL, 0, NULL, "sec_keypad"); if (device_create_file(sec_keypad, &dev_attr_brightness) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_brightness.attr.name); sec_flip = device_create(sec_class, NULL, 0, NULL, "sec_flip"); if (device_create_file(sec_flip, &dev_attr_flipStatus) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_flipStatus.attr.name); #endif ret = device_create_file(sec_key, &dev_attr_sec_key_pressed); if (ret) { pr_err("Failed to create device file in sysfs entries(%s)!\n", dev_attr_sec_key_pressed.attr.name); } #if defined(CONFIG_SEC_S_PROJECT) ret = device_create_file(sec_key, &dev_attr_sec_key_pressed_code); if (ret) { pr_err("Failed to create device file in sysfs entries(%s)!\n", dev_attr_sec_key_pressed_code.attr.name); } #endif #ifdef CONFIG_SENSORS_HALL_IRQ_CTRL if(ddata->gpio_flip_cover != 0) { ret = device_create_file(sec_key, &dev_attr_hall_irq_ctrl); if (ret < 0) { pr_err("Failed to create device file(%s)!, error: %d\n", dev_attr_hall_irq_ctrl.attr.name, ret); } } #endif #if defined(CONFIG_SENSORS_HALL) if(ddata->gpio_flip_cover != 0) { ret = device_create_file(sec_key, &dev_attr_hall_detect); if (ret < 0) { pr_err("Failed to create device file(%s)!, error: %d\n", dev_attr_hall_detect.attr.name, ret); } } #if defined(CONFIG_SENSORS_HALL_DEBOUNCE) if(ddata->gpio_flip_cover != 0) { ret = device_create_file(sec_key, &dev_attr_hall_irq_ctrl); if (ret < 0) { pr_err("Failed to create device file(%s)!, error: %d\n", dev_attr_hall_irq_ctrl.attr.name, ret); } } #endif #if defined (CONFIG_SEC_MILLET_PROJECT) || defined (CONFIG_SEC_BERLUTI_PROJECT) || defined (CONFIG_SEC_T8_PROJECT) if (!lvs1_1p8) { lvs1_1p8 = regulator_get(dev, "8226_lvs1"); if(!lvs1_1p8) printk(KERN_CRIT "%s: regulator_get for 8226_lvs1 failed\n", __func__); else { ret = regulator_enable(lvs1_1p8); if (ret){ regulator_put(lvs1_1p8); printk(KERN_CRIT "%s: Failed to enable regulator lvs1_1p8.\n",__func__); } } } #endif #endif #ifdef CONFIG_USE_VM_KEYBOARD_REJECT reject_keyboard_specific_key = false; ret = device_create_file(sec_key, &dev_attr_reject_key_comb); if (ret < 0) { pr_err("Failed to create device file(%s), error: %d\n", dev_attr_reject_key_comb.attr.name, ret); } #endif ret = device_create_file(sec_key, &dev_attr_wakeup_keys); if (ret < 0) { pr_err("Failed to create device file(%s), error: %d\n", dev_attr_wakeup_keys.attr.name, ret); } dev_set_drvdata(sec_key, ddata); device_init_wakeup(&pdev->dev, wakeup); #if defined(CONFIG_SEC_PATEK_PROJECT) keypadled_powerset(&pdev->dev); dev_set_drvdata(sec_flip, ddata); #endif #ifdef PERIODIC_CHECK_GPIOS INIT_DELAYED_WORK_DEFERRABLE(&g_gpio_check_work, sec_gpiocheck_work); schedule_delayed_work(&g_gpio_check_work, msecs_to_jiffies(0)); #endif return 0; fail3: sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); fail2: while (--i >= 0) gpio_remove_key(&ddata->data[i]); platform_set_drvdata(pdev, NULL); #ifdef CONFIG_SENSORS_HALL wake_lock_destroy(&ddata->flip_wake_lock); #endif fail1: input_free_device(input); kfree(ddata); /* If we have no platform_data, we allocated buttons dynamically. */ if (!pdev->dev.platform_data) kfree(pdata->buttons); return error; }
static int locomokbd_probe(struct locomo_dev *dev) { struct locomokbd *locomokbd; struct input_dev *input_dev; int i, err; locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL); input_dev = input_allocate_device(); if (!locomokbd || !input_dev) { err = -ENOMEM; goto err_free_mem; } /* try and claim memory region */ if (!request_mem_region((unsigned long) dev->mapbase, dev->length, LOCOMO_DRIVER_NAME(dev))) { err = -EBUSY; printk(KERN_ERR "locomokbd: Can't acquire access to io memory for keyboard\n"); goto err_free_mem; } locomo_set_drvdata(dev, locomokbd); locomokbd->base = (unsigned long) dev->mapbase; spin_lock_init(&locomokbd->lock); init_timer(&locomokbd->timer); locomokbd->timer.function = locomokbd_timer_callback; locomokbd->timer.data = (unsigned long) locomokbd; locomokbd->suspend_jiffies = jiffies; locomokbd->input = input_dev; strcpy(locomokbd->phys, "locomokbd/input0"); input_dev->name = "LoCoMo keyboard"; input_dev->phys = locomokbd->phys; input_dev->id.bustype = BUS_HOST; input_dev->id.vendor = 0x0001; input_dev->id.product = 0x0001; input_dev->id.version = 0x0100; input_dev->open = locomokbd_open; input_dev->close = locomokbd_close; input_dev->dev.parent = &dev->dev; input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | BIT_MASK(EV_PWR); input_dev->keycode = locomokbd->keycode; input_dev->keycodesize = sizeof(locomokbd_keycode[0]); input_dev->keycodemax = ARRAY_SIZE(locomokbd_keycode); input_set_drvdata(input_dev, locomokbd); memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode)); for (i = 0; i < LOCOMOKBD_NUMKEYS; i++) set_bit(locomokbd->keycode[i], input_dev->keybit); clear_bit(0, input_dev->keybit); /* attempt to get the interrupt */ err = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd); if (err) { printk(KERN_ERR "locomokbd: Can't get irq for keyboard\n"); goto err_release_region; } err = input_register_device(locomokbd->input); if (err) goto err_free_irq; return 0; err_free_irq: free_irq(dev->irq[0], locomokbd); err_release_region: release_mem_region((unsigned long) dev->mapbase, dev->length); locomo_set_drvdata(dev, NULL); err_free_mem: input_free_device(input_dev); kfree(locomokbd); return err; }
return error; } static void cpuboost_input_disconnect(struct input_handle *handle) { input_close_device(handle); input_unregister_handle(handle); kfree(handle); } static const struct input_device_id cpuboost_ids[] = { /* multi-touch touchscreen */ { .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT, .evbit = { BIT_MASK(EV_ABS) }, .absbit = { [BIT_WORD(ABS_MT_POSITION_X)] = BIT_MASK(ABS_MT_POSITION_X) | BIT_MASK(ABS_MT_POSITION_Y) }, }, /* touchpad */ { .flags = INPUT_DEVICE_ID_MATCH_KEYBIT | INPUT_DEVICE_ID_MATCH_ABSBIT, .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) }, .absbit = { [BIT_WORD(ABS_X)] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) }, }, /* Keypad */ { .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
static int __devinit pcap_ts_probe(struct platform_device *pdev) { struct input_dev *input_dev; struct pcap_ts *pcap_ts; int err = -ENOMEM; pcap_ts = kzalloc(sizeof(*pcap_ts), GFP_KERNEL); if (!pcap_ts) return err; pcap_ts->pcap = dev_get_drvdata(pdev->dev.parent); platform_set_drvdata(pdev, pcap_ts); input_dev = input_allocate_device(); if (!input_dev) goto fail; INIT_DELAYED_WORK(&pcap_ts->work, pcap_ts_work); pcap_ts->read_state = PCAP_ADC_TS_M_NONTS; pcap_set_ts_bits(pcap_ts->pcap, pcap_ts->read_state << PCAP_ADC_TS_M_SHIFT); pcap_ts->input = input_dev; input_set_drvdata(input_dev, pcap_ts); input_dev->name = "pcap-touchscreen"; input_dev->phys = "pcap_ts/input0"; input_dev->id.bustype = BUS_HOST; input_dev->id.vendor = 0x0001; input_dev->id.product = 0x0002; input_dev->id.version = 0x0100; input_dev->dev.parent = &pdev->dev; input_dev->open = pcap_ts_open; input_dev->close = pcap_ts_close; input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); input_set_abs_params(input_dev, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0); input_set_abs_params(input_dev, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0); input_set_abs_params(input_dev, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0); err = input_register_device(pcap_ts->input); if (err) goto fail_allocate; err = request_irq(pcap_to_irq(pcap_ts->pcap, PCAP_IRQ_TS), pcap_ts_event_touch, 0, "Touch Screen", pcap_ts); if (err) goto fail_register; return 0; fail_register: input_unregister_device(input_dev); goto fail; fail_allocate: input_free_device(input_dev); fail: kfree(pcap_ts); return err; }
static int __devinit w90p910_keypad_probe(struct platform_device *pdev) { const struct w90p910_keypad_platform_data *pdata = pdev->dev.platform_data; const struct matrix_keymap_data *keymap_data; struct w90p910_keypad *keypad; struct input_dev *input_dev; struct resource *res; int irq; int error; if (!pdata) { dev_err(&pdev->dev, "no platform data defined\n"); return -EINVAL; } keymap_data = pdata->keymap_data; irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "failed to get keypad irq\n"); return -ENXIO; } keypad = kzalloc(sizeof(struct w90p910_keypad), GFP_KERNEL); input_dev = input_allocate_device(); if (!keypad || !input_dev) { dev_err(&pdev->dev, "failed to allocate driver data\n"); error = -ENOMEM; goto failed_free; } keypad->pdata = pdata; keypad->input_dev = input_dev; keypad->irq = irq; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { dev_err(&pdev->dev, "failed to get I/O memory\n"); error = -ENXIO; goto failed_free; } res = request_mem_region(res->start, resource_size(res), pdev->name); if (res == NULL) { dev_err(&pdev->dev, "failed to request I/O memory\n"); error = -EBUSY; goto failed_free; } keypad->mmio_base = ioremap(res->start, resource_size(res)); if (keypad->mmio_base == NULL) { dev_err(&pdev->dev, "failed to remap I/O memory\n"); error = -ENXIO; goto failed_free_res; } keypad->clk = clk_get(&pdev->dev, NULL); if (IS_ERR(keypad->clk)) { dev_err(&pdev->dev, "failed to get keypad clock\n"); error = PTR_ERR(keypad->clk); goto failed_free_io; } /* set multi-function pin for w90p910 kpi. */ mfp_set_groupi(&pdev->dev); input_dev->name = pdev->name; input_dev->id.bustype = BUS_HOST; input_dev->open = w90p910_keypad_open; input_dev->close = w90p910_keypad_close; input_dev->dev.parent = &pdev->dev; input_dev->keycode = keypad->keymap; input_dev->keycodesize = sizeof(keypad->keymap[0]); input_dev->keycodemax = ARRAY_SIZE(keypad->keymap); input_set_drvdata(input_dev, keypad); input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); input_set_capability(input_dev, EV_MSC, MSC_SCAN); matrix_keypad_build_keymap(keymap_data, W90P910_ROW_SHIFT, input_dev->keycode, input_dev->keybit); error = request_irq(keypad->irq, w90p910_keypad_irq_handler, IRQF_DISABLED, pdev->name, keypad); if (error) { dev_err(&pdev->dev, "failed to request IRQ\n"); goto failed_put_clk; } /* Register the input device */ error = input_register_device(input_dev); if (error) { dev_err(&pdev->dev, "failed to register input device\n"); goto failed_free_irq; } platform_set_drvdata(pdev, keypad); return 0; failed_free_irq: free_irq(irq, pdev); failed_put_clk: clk_put(keypad->clk); failed_free_io: iounmap(keypad->mmio_base); failed_free_res: release_mem_region(res->start, resource_size(res)); failed_free: input_free_device(input_dev); kfree(keypad); return error; }
static int __devinit HC548_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct HC548_touchscreen_data *data; struct input_dev *input_dev; u8 buf,buf1; int error; #ifdef ENABLE_UPGRADE int times = 0; #endif pr_pos_info(); data = kzalloc(sizeof(struct HC548_touchscreen_data), GFP_KERNEL); if(data == NULL) { pr_red_info("HC548 kzalloc touchscreen_data failed!\n"); error = -ENOMEM; goto exit_alloc_data_failed; } input_dev = input_allocate_device(); if(input_dev == NULL) { pr_red_info("HC548 input allocate device failed!\n"); error = -ENOMEM; goto exit_input_dev_alloc_failed; } data->input_dev = input_dev; input_set_drvdata(input_dev, data); input_dev->name = HC5XX_NAME; input_dev->id.bustype = BUS_I2C; input_dev->dev.parent = &client->dev; input_dev->open = HC548_input_open; input_dev->close = HC548_input_close; input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) ; // input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); input_dev->propbit[0] = BIT(INPUT_PROP_DIRECT); input_dev->absbit[0] = BIT_MASK(ABS_MT_TRACKING_ID) | BIT_MASK(ABS_MT_POSITION_X) | BIT_MASK(ABS_MT_POSITION_Y)| BIT_MASK(ABS_MT_TOUCH_MAJOR);// | BIT_MASK(ABS_MT_WIDTH_MAJOR); input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, HC548_MAX_X, 0 , 0); input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, HC548_MAX_Y, 0 , 0); input_set_abs_params(input_dev,ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); // input_set_abs_params(input_dev,ABS_MT_WIDTH_MAJOR, 0, 200, 0, 0); input_set_abs_params(input_dev, ABS_MT_TRACKING_ID, 0, 5, 0, 0); #ifdef KEY_MAP_INIT HC548_key_map_init(input_dev); #endif error = input_register_device(input_dev); if(error < 0) { pr_red_info("HC548 input_register_device failed!\n"); goto err_unregister_device; } data->ts_wq = create_singlethread_workqueue("kworkqueue_ts"); if (!data->ts_wq) { dev_err(&client->dev, "Could not create workqueue\n"); goto error_wq_create; } flush_workqueue(data->ts_wq); INIT_WORK(&data->work, HC548_poscheck); data->client = client; i2c_set_clientdata(client,data); this_client = client; /* configure rest pin */ #if 0 data->reset = RK30_PIN0_PB6;//RK2928_PIN1_PB1; //INVALID_GPIO;//S5PV210_GPH2(5); if (data->reset != INVALID_GPIO) { error = gpio_request(data->reset, NULL); if (error < 0) { pr_red_info("Unable to request GPIO pin %d to act as reset\n",data->reset); goto exit_rst_gpio_request_failed; } } HC548_hard_reset(data); #endif hc_register_read(0x00, &buf, 1); if(buf == 0x86) pr_green_info("HC548: I2C communication is OK, TP chip ID is %x\n",buf); else pr_red_info("HC548: I2C ERROR!! TP chip ID is %x\n",buf); #ifdef ENABLE_UPGRADE pr_green_info("HC548: HC548_fw_data[0] is %x\n",HC548_fw_data[0]); if(HC548_fw_data[0] == 0xff) //debug_control,if data is 0xff,TP drive always upgrade { while(1) { int ret = 0; ret = HC548_upgrade(client); if(ret < 0) { times ++; printk("times = %d\n",times); } else { times = 0; break; } if(times >= 10) break; } } else { __u8 buf; //i2c_smbus_read_i2c_block_data(client,0x75,1,&buf); hc_register_read(0x75, &buf, 1); hc_register_read(0x73, &buf1, 1); if((buf < HC548_fw_data[0]) || ((buf == HC548_fw_data[0]) && (buf1 < HC548_fw_data[1]))) // if(buf < HC548_fw_data[0]) { while(1) { int ret = 0; ret = HC548_upgrade(client); if(ret < 0) { times ++; printk("times = %d\n",times); } else { times = 0; break; } if(times >= 10) break; } } } printk("====CTP download times = %d\n",times); #endif /* configure interrupt pin */ #if 0 data->irq = RK30_PIN1_PB7;//RK2928_PIN1_PB3;//RK2928_PIN1_PB0; //S5PV210_GPH2(4); error = gpio_request(data->irq, "touch_irq_key"); if (error < 0) { pr_red_info("Unable to request GPIO pin %d. error %d.\n", data->irq, error); goto exit_irq_gpio_request_failed; } error = gpio_direction_input(data->irq); if (error < 0) { pr_red_info("Failed to configure input direction for GPIO %d, error %d\n", data->irq, error); goto err_free_irq_gpio; } #endif client->irq = IRQ_PORT;//gpio_to_irq(data->irq); if (client->irq < 0) { error = client->irq; pr_red_info( "Unable to get irq number for GPIO %d, error %d\n", data->irq, error); goto err_free_irq; } // error = request_threaded_irq(client->irq, NULL, HC548_interrupt, IRQF_TRIGGER_RISING, client->dev.driver->name, data); error = request_threaded_irq(client->irq, NULL, HC548_interrupt, IRQF_TRIGGER_FALLING, client->dev.driver->name, data); if(error) { pr_red_info("HC548 failed to register irq!\n"); goto exit_irq_request_failed; } #ifdef CONFIG_HC8600_SLEEP_KEEP_POWER INIT_WORK(&data->resume_work, ts_work_resume); #endif pr_green_info("HC548_probe ok!\n"); return 0; exit_irq_request_failed: cancel_work_sync(&data->work); err_free_irq: free_irq(client->irq, data); //err_free_irq_gpio: // if (data->irq) // gpio_free(data->irq); //exit_irq_gpio_request_failed: // HC548_hard_reset(data); // if (data->reset) // gpio_free(data->reset); exit_rst_gpio_request_failed: destroy_workqueue(data->ts_wq); i2c_set_clientdata(client,NULL); this_client = NULL; error_wq_create: input_unregister_device(input_dev); err_unregister_device: input_free_device(input_dev); exit_input_dev_alloc_failed: kfree(data); exit_alloc_data_failed: return error; }
static int __init bt_init(void) { int error1,error2; int i; btmouse_dev = input_allocate_device(); //btmouse_dev->dev = btmouse_dev; btmouse_dev->id.bustype = BUS_USB; btmouse_dev->name = BT_MOUSE_NAME; btmouse_dev->phys = "usb-0000:01:0d.1-1/input0"; btmouse_dev->id.vendor = 0x0001; btmouse_dev->id.product = 0x0002; btmouse_dev->id.version = 0x0001; btmouse_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL) |BIT(EV_SYN) |BIT(EV_MSC); btmouse_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y) |BIT(REL_RX) | BIT(REL_RY) | BIT(REL_RZ); btmouse_dev->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT)|BIT_MASK(MSC_SCAN); /*set_bit(EV_KEY,btmouse_dev->evbit); set_bit(EV_REL,btmouse_dev->evbit); set_bit(EV_SYN,btmouse_dev->evbit); set_bit(REL_X,btmouse_dev->relbit); set_bit(REL_Y,btmouse_dev->relbit); set_bit(BTN_LEFT,btmouse_dev->keybit);*/ btmouse_dev->open = btmouse_open; btmouse_dev->close = btmouse_close; error1 = input_register_device(btmouse_dev); if (error1) { printk("bt_mouse: Failed to register device\n"); goto err_free_dev1; } btkb_dev = input_allocate_device(); btkb_dev->id.bustype = BUS_USB; btkb_dev->name = BT_KB_NAME; btkb_dev->phys = "usb-0000:01:0d.1-1/input0"; btkb_dev->id.vendor = 0x0001; btkb_dev->id.product = 0x0002; btkb_dev->id.version = 0x0001; btkb_dev->evbit[0] = BIT(EV_KEY) ; for (i = 0; i < 0xF6; i++) set_bit(i, btkb_dev->keybit); btkb_dev->open = btkb_open; btkb_dev->close = btkb_close; error2 = input_register_device(btkb_dev); if (error2) { printk("bt_keyboard: Failed to register device\n"); goto err_free_dev2; } return 0; err_free_dev1: input_free_device(btmouse_dev); return error1; err_free_dev2: input_free_device(btkb_dev); return error2; }
static int nxp_key_probe(struct platform_device *pdev) { struct nxp_key_plat_data * plat = pdev->dev.platform_data; struct key_info *key = NULL; struct key_code *code = NULL; struct input_dev *input = NULL; int i, keys; int ret = 0; pr_debug("%s (device name:%s, id:%d)\n", __func__, pdev->name, pdev->id); key = kzalloc(sizeof(struct key_info), GFP_KERNEL); if (! key) { pr_err("fail, %s allocate driver info ...\n", pdev->name); return -ENOMEM; } keys = plat->bt_count; code = kzalloc(sizeof(struct key_code)*keys, GFP_KERNEL); if (NULL == code) { pr_err("fail, %s allocate key code ...\n", pdev->name); ret = -ENOMEM; goto err_mm; } input = input_allocate_device(); if (NULL == input) { pr_err("fail, %s allocate input device\n", pdev->name); ret = -ENOMEM; goto err_mm; } key->input = input; key->keys = keys; key->code = code; key->resume_delay_ms = plat->resume_delay_ms; key_input = key->input; INIT_DELAYED_WORK(&key->resume_work, nxp_key_resume_work); input->name = "nxp-keypad"; input->phys = "nexell/input0"; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; input->id.product = 0x0002; input->id.version = 0x0100; input->dev.parent = &pdev->dev; input->keycode = plat->bt_code; input->keycodesize = sizeof(plat->bt_code[0]); input->keycodemax = plat->bt_count * 2; // for long key input->evbit[0] = BIT_MASK(EV_KEY); if (plat->bt_repeat) input->evbit[0] |= BIT_MASK(EV_REP); input_set_capability(input, EV_MSC, MSC_SCAN); input_set_drvdata(input, key); ret = input_register_device(input); if (ret) { pr_err("fail, %s register for input device ...\n", pdev->name); goto err_mm; } for (i=0; keys > i; i++, code++) { code->io = plat->bt_io[i]; code->keycode = plat->bt_code[i]; code->detect_high = plat->bt_detect_high ? plat->bt_detect_high[i]: 0; code->val = i; code->info = key; code->keystat = KEY_STAT_RELEASE; code->kcode_wq = create_singlethread_workqueue(pdev->name); if (!code->kcode_wq) { ret = -ESRCH; goto err_irq; } ret = request_irq(gpio_to_irq(code->io), nxp_key_irqhnd, (IRQF_SHARED | IRQ_TYPE_EDGE_BOTH), pdev->name, code); if (ret) { pr_err("fail, gpio[%d] %s request irq...\n", code->io, pdev->name); goto err_irq; } __set_bit(code->keycode, input->keybit); INIT_DELAYED_WORK(&code->kcode_work, nxp_key_event_wq); pr_debug("[%d] key io=%3d, code=%4d\n", i, code->io, code->keycode); } platform_set_drvdata(pdev, key); return ret; err_irq: for (--i; i >= 0; i--) { cancel_work_sync(&code[i].kcode_work.work); destroy_workqueue(code[i].kcode_wq); free_irq(gpio_to_irq(code[i].io), &code[i]); } input_free_device(input); err_mm: if (code) kfree(code); if (key) kfree(key); return ret; }
int iforce_init_device(struct iforce *iforce) { struct input_dev *input_dev; struct ff_device *ff; unsigned char c[] = "CEOV"; int i, error; int ff_effects = 0; input_dev = input_allocate_device(); if (!input_dev) return -ENOMEM; init_waitqueue_head(&iforce->wait); spin_lock_init(&iforce->xmit_lock); mutex_init(&iforce->mem_mutex); iforce->xmit.buf = iforce->xmit_data; iforce->dev = input_dev; /* * Input device fields. */ switch (iforce->bus) { #ifdef CONFIG_JOYSTICK_IFORCE_USB case IFORCE_USB: input_dev->id.bustype = BUS_USB; input_dev->dev.parent = &iforce->usbdev->dev; break; #endif #ifdef CONFIG_JOYSTICK_IFORCE_232 case IFORCE_232: input_dev->id.bustype = BUS_RS232; input_dev->dev.parent = &iforce->serio->dev; break; #endif } input_set_drvdata(input_dev, iforce); input_dev->name = "Unknown I-Force device"; input_dev->open = iforce_open; input_dev->close = iforce_close; /* * On-device memory allocation. */ iforce->device_memory.name = "I-Force device effect memory"; iforce->device_memory.start = 0; iforce->device_memory.end = 200; iforce->device_memory.flags = IORESOURCE_MEM; iforce->device_memory.parent = NULL; iforce->device_memory.child = NULL; iforce->device_memory.sibling = NULL; /* * Wait until device ready - until it sends its first response. */ for (i = 0; i < 20; i++) if (!iforce_get_id_packet(iforce, "O")) break; if (i == 20) { /* 5 seconds */ dev_err(&input_dev->dev, "Timeout waiting for response from device.\n"); error = -ENODEV; goto fail; } /* * Get device info. */ if (!iforce_get_id_packet(iforce, "M")) input_dev->id.vendor = (iforce->edata[2] << 8) | iforce->edata[1]; else dev_warn(&iforce->dev->dev, "Device does not respond to id packet M\n"); if (!iforce_get_id_packet(iforce, "P")) input_dev->id.product = (iforce->edata[2] << 8) | iforce->edata[1]; else dev_warn(&iforce->dev->dev, "Device does not respond to id packet P\n"); if (!iforce_get_id_packet(iforce, "B")) iforce->device_memory.end = (iforce->edata[2] << 8) | iforce->edata[1]; else dev_warn(&iforce->dev->dev, "Device does not respond to id packet B\n"); if (!iforce_get_id_packet(iforce, "N")) ff_effects = iforce->edata[1]; else dev_warn(&iforce->dev->dev, "Device does not respond to id packet N\n"); /* Check if the device can store more effects than the driver can really handle */ if (ff_effects > IFORCE_EFFECTS_MAX) { dev_warn(&iforce->dev->dev, "Limiting number of effects to %d (device reports %d)\n", IFORCE_EFFECTS_MAX, ff_effects); ff_effects = IFORCE_EFFECTS_MAX; } /* * Display additional info. */ for (i = 0; c[i]; i++) if (!iforce_get_id_packet(iforce, c + i)) iforce_dump_packet(iforce, "info", iforce->ecmd, iforce->edata); /* * Disable spring, enable force feedback. */ iforce_set_autocenter(input_dev, 0); /* * Find appropriate device entry */ for (i = 0; iforce_device[i].idvendor; i++) if (iforce_device[i].idvendor == input_dev->id.vendor && iforce_device[i].idproduct == input_dev->id.product) break; iforce->type = iforce_device + i; input_dev->name = iforce->type->name; /* * Set input device bitfields and ranges. */ input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) | BIT_MASK(EV_FF_STATUS); for (i = 0; iforce->type->btn[i] >= 0; i++) set_bit(iforce->type->btn[i], input_dev->keybit); for (i = 0; iforce->type->abs[i] >= 0; i++) { signed short t = iforce->type->abs[i]; switch (t) { case ABS_X: case ABS_Y: case ABS_WHEEL: input_set_abs_params(input_dev, t, -1920, 1920, 16, 128); set_bit(t, input_dev->ffbit); break; case ABS_THROTTLE: case ABS_GAS: case ABS_BRAKE: input_set_abs_params(input_dev, t, 0, 255, 0, 0); break; case ABS_RUDDER: input_set_abs_params(input_dev, t, -128, 127, 0, 0); break; case ABS_HAT0X: case ABS_HAT0Y: case ABS_HAT1X: case ABS_HAT1Y: input_set_abs_params(input_dev, t, -1, 1, 0, 0); break; } } if (ff_effects) { for (i = 0; iforce->type->ff[i] >= 0; i++) set_bit(iforce->type->ff[i], input_dev->ffbit); error = input_ff_create(input_dev, ff_effects); if (error) goto fail; ff = input_dev->ff; ff->upload = iforce_upload_effect; ff->erase = iforce_erase_effect; ff->set_gain = iforce_set_gain; ff->set_autocenter = iforce_set_autocenter; ff->playback = iforce_playback; } /* * Register input device. */ error = input_register_device(iforce->dev); if (error) goto fail; return 0; fail: input_free_device(input_dev); return error; }
static int w90x900ts_probe(struct platform_device *pdev) { struct w90p910_ts *w90p910_ts; struct input_dev *input_dev; struct resource *res; int err; w90p910_ts = kzalloc(sizeof(struct w90p910_ts), GFP_KERNEL); input_dev = input_allocate_device(); if (!w90p910_ts || !input_dev) { err = -ENOMEM; goto fail1; } w90p910_ts->input = input_dev; w90p910_ts->state = TS_IDLE; spin_lock_init(&w90p910_ts->lock); setup_timer(&w90p910_ts->timer, w90p910_check_pen_up, (unsigned long)w90p910_ts); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { err = -ENXIO; goto fail1; } if (!request_mem_region(res->start, resource_size(res), pdev->name)) { err = -EBUSY; goto fail1; } w90p910_ts->ts_reg = ioremap(res->start, resource_size(res)); if (!w90p910_ts->ts_reg) { err = -ENOMEM; goto fail2; } w90p910_ts->clk = clk_get(&pdev->dev, NULL); if (IS_ERR(w90p910_ts->clk)) { err = PTR_ERR(w90p910_ts->clk); goto fail3; } input_dev->name = "W90P910 TouchScreen"; input_dev->phys = "w90p910ts/event0"; input_dev->id.bustype = BUS_HOST; input_dev->id.vendor = 0x0005; input_dev->id.product = 0x0001; input_dev->id.version = 0x0100; input_dev->dev.parent = &pdev->dev; input_dev->open = w90p910_open; input_dev->close = w90p910_close; input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); input_set_abs_params(input_dev, ABS_X, 0, 0x400, 0, 0); input_set_abs_params(input_dev, ABS_Y, 0, 0x400, 0, 0); input_set_drvdata(input_dev, w90p910_ts); w90p910_ts->irq_num = platform_get_irq(pdev, 0); if (request_irq(w90p910_ts->irq_num, w90p910_ts_interrupt, 0, "w90p910ts", w90p910_ts)) { err = -EBUSY; goto fail4; } err = input_register_device(w90p910_ts->input); if (err) goto fail5; platform_set_drvdata(pdev, w90p910_ts); return 0; fail5: free_irq(w90p910_ts->irq_num, w90p910_ts); fail4: clk_put(w90p910_ts->clk); fail3: iounmap(w90p910_ts->ts_reg); fail2: release_mem_region(res->start, resource_size(res)); fail1: input_free_device(input_dev); kfree(w90p910_ts); return err; }
int dvb_usb_remote_init(struct dvb_usb_device *d) { struct input_dev *input_dev; int i; int err; if (d->props.rc_key_map == NULL || d->props.rc_query == NULL || dvb_usb_disable_rc_polling) return 0; usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys)); strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys)); input_dev = input_allocate_device(); if (!input_dev) return -ENOMEM; input_dev->evbit[0] = BIT_MASK(EV_KEY); input_dev->name = "IR-receiver inside an USB DVB receiver"; input_dev->phys = d->rc_phys; usb_to_input_id(d->udev, &input_dev->id); input_dev->dev.parent = &d->udev->dev; input_dev->getkeycode = dvb_usb_getkeycode; input_dev->setkeycode = dvb_usb_setkeycode; /* set the bits for the keys */ deb_rc("key map size: %d\n", d->props.rc_key_map_size); for (i = 0; i < d->props.rc_key_map_size; i++) { deb_rc("setting bit for event %d item %d\n", d->props.rc_key_map[i].event, i); set_bit(d->props.rc_key_map[i].event, input_dev->keybit); } /* Start the remote-control polling. */ if (d->props.rc_interval < 40) d->props.rc_interval = 100; /* default */ /* setting these two values to non-zero, we have to manage key repeats */ input_dev->rep[REP_PERIOD] = d->props.rc_interval; input_dev->rep[REP_DELAY] = d->props.rc_interval + 150; input_set_drvdata(input_dev, d); err = input_register_device(input_dev); if (err) { input_free_device(input_dev); return err; } d->rc_input_dev = input_dev; INIT_DELAYED_WORK(&d->rc_query_work, dvb_usb_read_remote_control); info("schedule remote query interval to %d msecs.", d->props.rc_interval); schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc_interval)); d->state |= DVB_USB_STATE_REMOTE; return 0; }
static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device *dev = interface_to_usbdev(intf); struct usb_endpoint_descriptor *endpoint; struct wacom *wacom; struct wacom_wac *wacom_wac; struct wacom_features *features; struct input_dev *input_dev; int error; if (!id->driver_info) return -EINVAL; wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL); input_dev = input_allocate_device(); if (!wacom || !input_dev || !wacom_wac) { error = -ENOMEM; goto fail1; } wacom_wac->features = *((struct wacom_features *)id->driver_info); features = &wacom_wac->features; if (features->pktlen > WACOM_PKGLEN_MAX) { error = -EINVAL; goto fail1; } wacom_wac->data = usb_buffer_alloc(dev, WACOM_PKGLEN_MAX, GFP_KERNEL, &wacom->data_dma); if (!wacom_wac->data) { error = -ENOMEM; goto fail1; } wacom->irq = usb_alloc_urb(0, GFP_KERNEL); if (!wacom->irq) { error = -ENOMEM; goto fail2; } wacom->usbdev = dev; wacom->dev = input_dev; wacom->intf = intf; mutex_init(&wacom->lock); usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); usb_to_input_id(dev, &input_dev->id); input_dev->dev.parent = &intf->dev; input_set_drvdata(input_dev, wacom); input_dev->open = wacom_open; input_dev->close = wacom_close; endpoint = &intf->cur_altsetting->endpoint[0].desc; /* Retrieve the physical and logical size for OEM devices */ error = wacom_retrieve_hid_descriptor(intf, features); if (error) goto fail2; strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); if (features->type == TABLETPC || features->type == TABLETPC2FG) { /* Append the device type to the name */ strlcat(wacom_wac->name, features->device_type == BTN_TOOL_PEN ? " Pen" : " Finger", sizeof(wacom_wac->name)); } input_dev->name = wacom_wac->name; wacom->wacom_wac = wacom_wac; input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOUCH); input_set_abs_params(input_dev, ABS_X, 0, features->x_max, 4, 0); input_set_abs_params(input_dev, ABS_Y, 0, features->y_max, 4, 0); input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max, 0, 0); input_dev->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); wacom_init_input_dev(input_dev, wacom_wac); usb_fill_int_urb(wacom->irq, dev, usb_rcvintpipe(dev, endpoint->bEndpointAddress), wacom_wac->data, features->pktlen, wacom_sys_irq, wacom, endpoint->bInterval); wacom->irq->transfer_dma = wacom->data_dma; wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; error = input_register_device(wacom->dev); if (error) goto fail3; /* Note that if query fails it is not a hard failure */ wacom_query_tablet_data(intf, features); usb_set_intfdata(intf, wacom); return 0; fail3: usb_free_urb(wacom->irq); fail2: usb_buffer_free(dev, WACOM_PKGLEN_MAX, wacom_wac->data, wacom->data_dma); fail1: input_free_device(input_dev); kfree(wacom); kfree(wacom_wac); return error; }
/* * Set the appropriate event bits for the input subsystem */ static int elantech_set_input_rel_params(struct asusec_chip *ec_chip) { struct elantech_data *etd ; unsigned char param[3]; int ret; if ((!elan_i2c_asus_cmd(ec_chip->client, NULL, ETP_PS2_CUSTOM_COMMAND)) && (!elan_i2c_asus_cmd(ec_chip->client, NULL, 0x0000)) && (!elan_i2c_asus_cmd(ec_chip->client, param, PSMOUSE_CMD_GETINFO))){ etd = ec_chip->private; if(etd->abs_dev){ return 0; } Public_ETP_XMAX_V2 = (0x0F & param[0]) << 8 | param[1]; Public_ETP_YMAX_V2 = (0xF0 & param[0]) << 4 | param[2]; etd->tap_num = NO_FINGER_ON_TOUCHPAD; init_timer(&console_timer); console_timer.function = timertapprocessing; console_timer.data = (unsigned long) ec_chip; etd->abs_dev = input_allocate_device(); ELAN_INFO("1 elantech_touchscreen=%p\n",etd->abs_dev); if (etd->abs_dev != NULL){ ELAN_INFO("2 elantech_touchscreen=%p\n",etd->abs_dev); Public_ETP_2FT_YMAX = Public_ETP_YMAX_V2; etd->abs_dev->name = "elantech_touchscreen"; etd->abs_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL) | BIT_MASK(EV_SYN); etd->abs_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_MIDDLE); etd->abs_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); etd->abs_dev->relbit[0] |= BIT_MASK(REL_WHEEL); __set_bit(REL_WHEEL, etd->abs_dev->relbit); __set_bit(REL_HWHEEL,etd->abs_dev->relbit); set_bit(EV_SYN, etd->abs_dev->evbit); set_bit(EV_KEY, etd->abs_dev->evbit); set_bit(EV_ABS, etd->abs_dev->evbit); set_bit(BTN_TOUCH, etd->abs_dev->keybit); set_bit(BTN_2, etd->abs_dev->keybit); input_set_abs_params(etd->abs_dev, ABS_X, ETP_XMIN_V2, Public_ETP_XMAX_V2, 0, 0); input_set_abs_params(etd->abs_dev, ABS_Y, ETP_YMIN_V2, Public_ETP_YMAX_V2, 0, 0); input_set_abs_params(etd->abs_dev, ABS_HAT0X, ETP_2FT_XMIN, Public_ETP_XMAX_V2, 0, 0); input_set_abs_params(etd->abs_dev, ABS_HAT0Y, ETP_2FT_YMIN, Public_ETP_YMAX_V2, 0, 0); input_set_abs_params(etd->abs_dev, ABS_PRESSURE, 0, 255, 0, 0); input_set_abs_params(etd->abs_dev, ABS_TOOL_WIDTH,0,16,0,0); input_set_abs_params(etd->abs_dev, ABS_MT_POSITION_X, ETP_2FT_XMIN, Public_ETP_XMAX_V2, 0, 0); input_set_abs_params(etd->abs_dev, ABS_MT_POSITION_Y, ETP_2FT_YMIN, Public_ETP_YMAX_V2, 0, 0); input_set_abs_params(etd->abs_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); input_set_abs_params(etd->abs_dev, ABS_MT_WIDTH_MAJOR, 0, 15, 0, 0); input_set_abs_params(etd->abs_dev, ABS_MT_TRACKING_ID, 0, FINGER_NUM, 0, 0); ret=input_register_device(etd->abs_dev); if (ret) { ELAN_ERR("Unable to register %s input device\n", etd->abs_dev->name); } } return 0; }
static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device *dev = interface_to_usbdev(intf); struct usb_endpoint_descriptor *endpoint; struct kbtab *kbtab; struct input_dev *input_dev; int error = -ENOMEM; if (intf->cur_altsetting->desc.bNumEndpoints < 1) return -ENODEV; kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL); input_dev = input_allocate_device(); if (!kbtab || !input_dev) goto fail1; kbtab->data = usb_alloc_coherent(dev, 8, GFP_KERNEL, &kbtab->data_dma); if (!kbtab->data) goto fail1; kbtab->irq = usb_alloc_urb(0, GFP_KERNEL); if (!kbtab->irq) goto fail2; kbtab->intf = intf; kbtab->dev = input_dev; usb_make_path(dev, kbtab->phys, sizeof(kbtab->phys)); strlcat(kbtab->phys, "/input0", sizeof(kbtab->phys)); input_dev->name = "KB Gear Tablet"; input_dev->phys = kbtab->phys; usb_to_input_id(dev, &input_dev->id); input_dev->dev.parent = &intf->dev; input_set_drvdata(input_dev, kbtab); input_dev->open = kbtab_open; input_dev->close = kbtab_close; input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input_dev->keybit[BIT_WORD(BTN_LEFT)] |= BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT); input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_TOUCH); input_set_abs_params(input_dev, ABS_X, 0, 0x2000, 4, 0); input_set_abs_params(input_dev, ABS_Y, 0, 0x1750, 4, 0); input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xff, 0, 0); endpoint = &intf->cur_altsetting->endpoint[0].desc; usb_fill_int_urb(kbtab->irq, dev, usb_rcvintpipe(dev, endpoint->bEndpointAddress), kbtab->data, 8, kbtab_irq, kbtab, endpoint->bInterval); kbtab->irq->transfer_dma = kbtab->data_dma; kbtab->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; error = input_register_device(kbtab->dev); if (error) goto fail3; usb_set_intfdata(intf, kbtab); return 0; fail3: usb_free_urb(kbtab->irq); fail2: usb_free_coherent(dev, 8, kbtab->data, kbtab->data_dma); fail1: input_free_device(input_dev); kfree(kbtab); return error; }
{ input_close_device(handle); input_unregister_handle(handle); kfree(handle); } /* * We are matching on KEY_LEFTALT insteard of KEY_SYSRQ because not all * keyboards have SysRq ikey predefined and so user may add it to keymap * later, but we expect all such keyboards to have left alt. */ static const struct input_device_id sysrq_ids[] = { { .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT, .evbit = { BIT_MASK(EV_KEY) }, .keybit = { BIT_MASK(KEY_LEFTALT) }, }, { }, }; static struct input_handler sysrq_handler = { .filter = sysrq_filter, .connect = sysrq_connect, .disconnect = sysrq_disconnect, .name = "sysrq", .id_table = sysrq_ids, }; static bool sysrq_handler_registered;
static int __devinit gpio_keys_probe(struct platform_device *pdev) { const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; struct gpio_keys_drvdata *ddata; struct device *dev = &pdev->dev; struct gpio_keys_platform_data alt_pdata; struct input_dev *input; int i, error; int wakeup = 0; if (!pdata) { error = gpio_keys_get_devtree_pdata(dev, &alt_pdata); if (error) return error; pdata = &alt_pdata; } ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + pdata->nbuttons * sizeof(struct gpio_button_data), GFP_KERNEL); input = input_allocate_device(); if (!ddata || !input) { dev_err(dev, "failed to allocate state\n"); error = -ENOMEM; goto fail1; } ddata->input = input; ddata->n_buttons = pdata->nbuttons; ddata->enable = pdata->enable; ddata->disable = pdata->disable; #ifdef CONFIG_SENSORS_HALL ddata->gpio_flip_cover = pdata->gpio_flip_cover; ddata->irq_flip_cover = gpio_to_irq(ddata->gpio_flip_cover);; wake_lock_init(&ddata->flip_wake_lock, WAKE_LOCK_SUSPEND, "flip wake lock"); #endif mutex_init(&ddata->disable_lock); platform_set_drvdata(pdev, ddata); input_set_drvdata(input, ddata); input->name = pdata->name ? : pdev->name; input->phys = "gpio-keys/input0"; input->dev.parent = &pdev->dev; #ifdef CONFIG_SENSORS_HALL input->evbit[0] |= BIT_MASK(EV_SW); input_set_capability(input, EV_SW, SW_FLIP); #endif input->open = gpio_keys_open; input->close = gpio_keys_close; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; input->id.product = 0x0001; input->id.version = 0x0100; /* Enable auto repeat feature of Linux input subsystem */ if (pdata->rep) __set_bit(EV_REP, input->evbit); for (i = 0; i < pdata->nbuttons; i++) { struct gpio_keys_button *button = &pdata->buttons[i]; struct gpio_button_data *bdata = &ddata->data[i]; error = gpio_keys_setup_key(pdev, input, bdata, button); if (error) goto fail2; if (button->wakeup) wakeup = 1; #ifdef KEY_BOOSTER if (button->code == KEY_HOMEPAGE) { error = gpio_key_init_dvfs(bdata); if (error < 0) { dev_err(dev, "Fail get dvfs level for touch booster\n"); goto fail2; } } #endif } error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); if (error) { dev_err(dev, "Unable to export keys/switches, error: %d\n", error); goto fail2; } ddata->sec_key = device_create(sec_class, NULL, 0, ddata, "sec_key"); if (IS_ERR(ddata->sec_key)) dev_err(dev, "Failed to create sec_key device\n"); error = sysfs_create_group(&ddata->sec_key->kobj, &sec_key_attr_group); if (error) { dev_err(dev, "Failed to create the test sysfs: %d\n", error); goto fail2; } #ifdef CONFIG_SENSORS_HALL init_hall_ic_irq(input); #endif error = input_register_device(input); if (error) { dev_err(dev, "Unable to register input device, error: %d\n", error); goto fail3; } /* get current state of buttons */ for (i = 0; i < pdata->nbuttons; i++) gpio_keys_report_event(&ddata->data[i]); input_sync(input); device_init_wakeup(&pdev->dev, wakeup); #if !defined(CONFIG_SAMSUNG_PRODUCT_SHIP) #if defined(CONFIG_N1A) if(set_auto_power_on_off_powerkey_val) { init_timer(&poweroff_keypad_timer); poweroff_keypad_timer.function = poweroff_keypad_timer_handler; poweroff_keypad_timer.data = (unsigned long)&ddata->data[0]; if(lpcharge) poweroff_keypad_timer.expires = jiffies + 20*HZ; else poweroff_keypad_timer.expires = jiffies + 40*HZ; add_timer(&poweroff_keypad_timer); printk("AUTO_POWER_ON_OFF_FLAG Test Start !!!\n"); } #endif #endif return 0; fail3: sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); sysfs_remove_group(&ddata->sec_key->kobj, &sec_key_attr_group); fail2: while (--i >= 0) gpio_remove_key(&ddata->data[i]); platform_set_drvdata(pdev, NULL); #ifdef CONFIG_SENSORS_HALL wake_lock_destroy(&ddata->flip_wake_lock); #endif fail1: input_free_device(input); kfree(ddata); /* If we have no platform_data, we allocated buttons dynamically. */ if (!pdev->dev.platform_data) kfree(pdata->buttons); return error; }
static int prepare_tsc_input_device(uint16_t ind, struct usf_type *usf_info, struct us_input_info_type *input_info, const char *name) { int i = 0; int num_buttons = min(ARRAY_SIZE(s_button_map), sizeof(input_info->req_buttons_bitmap) * BITS_IN_BYTE); uint16_t max_buttons_bitmap = ((1 << ARRAY_SIZE(s_button_map)) - 1); struct input_dev *in_dev = allocate_dev(ind, name); if (in_dev == NULL) return -ENOMEM; if (input_info->req_buttons_bitmap > max_buttons_bitmap) { pr_err("%s: Requested buttons[%d] exceeds max buttons available[%d]\n", __func__, input_info->req_buttons_bitmap, max_buttons_bitmap); return -EINVAL; } usf_info->input_ifs[ind] = in_dev; usf_info->req_buttons_bitmap = input_info->req_buttons_bitmap; in_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); in_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); for (i = 0; i < num_buttons; i++) if (input_info->req_buttons_bitmap & (1 << i)) in_dev->keybit[BIT_WORD(s_button_map[i])] |= BIT_MASK(s_button_map[i]); input_set_abs_params(in_dev, ABS_X, input_info->tsc_x_dim[MIN_IND], input_info->tsc_x_dim[MAX_IND], 0, 0); input_set_abs_params(in_dev, ABS_Y, input_info->tsc_y_dim[MIN_IND], input_info->tsc_y_dim[MAX_IND], 0, 0); input_set_abs_params(in_dev, ABS_DISTANCE, input_info->tsc_z_dim[MIN_IND], input_info->tsc_z_dim[MAX_IND], 0, 0); input_set_abs_params(in_dev, ABS_PRESSURE, input_info->tsc_pressure[MIN_IND], input_info->tsc_pressure[MAX_IND], 0, 0); input_set_abs_params(in_dev, ABS_TILT_X, input_info->tsc_x_tilt[MIN_IND], input_info->tsc_x_tilt[MAX_IND], 0, 0); input_set_abs_params(in_dev, ABS_TILT_Y, input_info->tsc_y_tilt[MIN_IND], input_info->tsc_y_tilt[MAX_IND], 0, 0); return 0; }
static int __devinit imx_keypad_probe(struct platform_device *pdev) { const struct matrix_keymap_data *keymap_data = pdev->dev.platform_data; struct imx_keypad *keypad; struct input_dev *input_dev; struct resource *res; int irq, error, i; if (keymap_data == NULL) { dev_err(&pdev->dev, "no keymap defined\n"); return -EINVAL; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "no irq defined in platform data\n"); return -EINVAL; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { dev_err(&pdev->dev, "no I/O memory defined in platform data\n"); return -EINVAL; } res = request_mem_region(res->start, resource_size(res), pdev->name); if (res == NULL) { dev_err(&pdev->dev, "failed to request I/O memory\n"); return -EBUSY; } input_dev = input_allocate_device(); if (!input_dev) { dev_err(&pdev->dev, "failed to allocate the input device\n"); error = -ENOMEM; goto failed_rel_mem; } keypad = kzalloc(sizeof(struct imx_keypad), GFP_KERNEL); if (!keypad) { dev_err(&pdev->dev, "not enough memory for driver data\n"); error = -ENOMEM; goto failed_free_input; } keypad->input_dev = input_dev; keypad->irq = irq; keypad->stable_count = 0; setup_timer(&keypad->check_matrix_timer, imx_keypad_check_for_events, (unsigned long) keypad); keypad->mmio_base = ioremap(res->start, resource_size(res)); if (keypad->mmio_base == NULL) { dev_err(&pdev->dev, "failed to remap I/O memory\n"); error = -ENOMEM; goto failed_free_priv; } keypad->clk = clk_get(&pdev->dev, "kpp"); if (IS_ERR(keypad->clk)) { dev_err(&pdev->dev, "failed to get keypad clock\n"); error = PTR_ERR(keypad->clk); goto failed_unmap; } /* Search for rows and cols enabled */ for (i = 0; i < keymap_data->keymap_size; i++) { keypad->rows_en_mask |= 1 << KEY_ROW(keymap_data->keymap[i]); keypad->cols_en_mask |= 1 << KEY_COL(keymap_data->keymap[i]); } if (keypad->rows_en_mask > ((1 << MAX_MATRIX_KEY_ROWS) - 1) || keypad->cols_en_mask > ((1 << MAX_MATRIX_KEY_COLS) - 1)) { dev_err(&pdev->dev, "invalid key data (too many rows or colums)\n"); error = -EINVAL; goto failed_clock_put; } dev_dbg(&pdev->dev, "enabled rows mask: %x\n", keypad->rows_en_mask); dev_dbg(&pdev->dev, "enabled cols mask: %x\n", keypad->cols_en_mask); /* Init the Input device */ input_dev->name = pdev->name; input_dev->id.bustype = BUS_HOST; input_dev->dev.parent = &pdev->dev; input_dev->open = imx_keypad_open; input_dev->close = imx_keypad_close; input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); input_dev->keycode = keypad->keycodes; input_dev->keycodesize = sizeof(keypad->keycodes[0]); input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes); matrix_keypad_build_keymap(keymap_data, MATRIX_ROW_SHIFT, keypad->keycodes, input_dev->keybit); input_set_capability(input_dev, EV_MSC, MSC_SCAN); input_set_drvdata(input_dev, keypad); /* Ensure that the keypad will stay dormant until opened */ imx_keypad_inhibit(keypad); error = request_irq(irq, imx_keypad_irq_handler, 0, pdev->name, keypad); if (error) { dev_err(&pdev->dev, "failed to request IRQ\n"); goto failed_clock_put; } /* Register the input device */ error = input_register_device(input_dev); if (error) { dev_err(&pdev->dev, "failed to register input device\n"); goto failed_free_irq; } platform_set_drvdata(pdev, keypad); device_init_wakeup(&pdev->dev, 1); return 0; failed_free_irq: free_irq(irq, pdev); failed_clock_put: clk_put(keypad->clk); failed_unmap: iounmap(keypad->mmio_base); failed_free_priv: kfree(keypad); failed_free_input: input_free_device(input_dev); failed_rel_mem: release_mem_region(res->start, resource_size(res)); return error; }
static int tps6507x_ts_probe(struct platform_device *pdev) { int error; struct tps6507x_ts *tsc; struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); struct touchscreen_init_data *init_data; struct input_dev *input_dev; struct tps6507x_board *tps_board; int schd; /** * tps_board points to pmic related constants * coming from the board-evm file. */ tps_board = (struct tps6507x_board *)tps6507x_dev->dev->platform_data; if (!tps_board) { dev_err(tps6507x_dev->dev, "Could not find tps6507x platform data\n"); return -EIO; } /** * init_data points to array of regulator_init structures * coming from the board-evm file. */ init_data = tps_board->tps6507x_ts_init_data; tsc = kzalloc(sizeof(struct tps6507x_ts), GFP_KERNEL); if (!tsc) { dev_err(tps6507x_dev->dev, "failed to allocate driver data\n"); error = -ENOMEM; goto err0; } tps6507x_dev->ts = tsc; tsc->mfd = tps6507x_dev; tsc->dev = tps6507x_dev->dev; input_dev = input_allocate_device(); if (!input_dev) { dev_err(tsc->dev, "Failed to allocate input device.\n"); error = -ENOMEM; goto err1; } input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); input_set_abs_params(input_dev, ABS_X, 0, MAX_10BIT, 0, 0); input_set_abs_params(input_dev, ABS_Y, 0, MAX_10BIT, 0, 0); input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_10BIT, 0, 0); input_dev->name = "TPS6507x Touchscreen"; input_dev->id.bustype = BUS_I2C; input_dev->dev.parent = tsc->dev; snprintf(tsc->phys, sizeof(tsc->phys), "%s/input0", dev_name(tsc->dev)); input_dev->phys = tsc->phys; dev_dbg(tsc->dev, "device: %s\n", input_dev->phys); input_set_drvdata(input_dev, tsc); tsc->input_dev = input_dev; INIT_DELAYED_WORK(&tsc->work, tps6507x_ts_handler); if (init_data) { tsc->poll_period = init_data->poll_period; tsc->vref = init_data->vref; tsc->min_pressure = init_data->min_pressure; input_dev->id.vendor = init_data->vendor; input_dev->id.product = init_data->product; input_dev->id.version = init_data->version; } else { tsc->poll_period = TSC_DEFAULT_POLL_PERIOD; tsc->min_pressure = TPS_DEFAULT_MIN_PRESSURE; } error = tps6507x_adc_standby(tsc); if (error) goto err2; error = input_register_device(input_dev); if (error) goto err2; schd = schedule_delayed_work(&tsc->work, msecs_to_jiffies(tsc->poll_period)); if (schd) tsc->polling = 1; else { tsc->polling = 0; dev_err(tsc->dev, "schedule failed"); goto err2; } platform_set_drvdata(pdev, tps6507x_dev); return 0; err2: cancel_delayed_work_sync(&tsc->work); input_free_device(input_dev); err1: kfree(tsc); tps6507x_dev->ts = NULL; err0: return error; }
static int __devinit rk28_adckey_probe(struct platform_device *pdev) { struct rk28_adckey *adckey; struct input_dev *input_dev; int error,i,irq_num; struct rk2818_adckey_platform_data *pdata = pdev->dev.platform_data; if (!(pdata->adc_key)) return -1; adckey = kzalloc(sizeof(struct rk28_adckey), GFP_KERNEL); if (adckey == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); return -ENOMEM; } //memcpy(adckey->keycodes, gInitKeyCode, sizeof(adckey->keycodes)); adckey->keycodes = pdata->adc_key->initKeyCode; /* Create and register the input driver. */ input_dev = input_allocate_device(); if (!input_dev) { dev_err(&pdev->dev, "failed to allocate input device\n"); error = -ENOMEM; goto failed_free; } input_dev->name = pdev->name; //input_dev->id.bustype = BUS_HOST; input_dev->open = rk28_adckey_open; input_dev->close = rk28_adckey_close; input_dev->dev.parent = &pdev->dev; input_dev->phys = KEY_PHYS_NAME; input_dev->id.vendor = 0x0001; input_dev->id.product = 0x0001; input_dev->id.version = 0x0100; input_dev->keycode = adckey->keycodes; input_dev->keycodesize = sizeof(unsigned char); input_dev->keycodemax = pdata->adc_key->adc_key_cnt; for (i = 0; i < pdata->adc_key->adc_key_cnt; i++) set_bit(pdata->adc_key->initKeyCode[i], input_dev->keybit); clear_bit(0, input_dev->keybit); adckey->input_dev = input_dev; input_set_drvdata(input_dev, adckey); input_dev->evbit[0] = BIT_MASK(EV_KEY); // rk28_adckey_build_keycode(adckey); platform_set_drvdata(pdev, adckey); pRk28AdcKey = adckey; /* Register the input device */ error = input_register_device(input_dev); if (error) { dev_err(&pdev->dev, "failed to register input device\n"); goto failed_free_dev; } error = gpio_request(pdata->adc_key->pin_playon, "play key gpio"); if (error) { dev_err(&pdev->dev, "failed to request play key gpio\n"); goto free_gpio; } irq_num = gpio_to_irq(pdata->adc_key->pin_playon); if(pdata->adc_key->playon_level) { gpio_pull_updown(pdata->adc_key->pin_playon,GPIOPullDown); error = request_irq(irq_num,rk28_playkey_irq,IRQF_TRIGGER_RISING,NULL,NULL); if(error) { printk("unable to request play key irq\n"); goto free_gpio_irq; } } else { gpio_pull_updown(pdata->adc_key->pin_playon,GPIOPullUp); error = request_irq(irq_num,rk28_playkey_irq,IRQF_TRIGGER_FALLING,NULL,NULL); if(error) { printk("unable to request play key irq\n"); goto free_gpio_irq; } } enable_irq_wake(irq_num); // so play/wakeup key can wake up system setup_timer(&adckey->timer, rk28_adkeyscan_timer, (unsigned long)(pdata->adc_key)); adckey->timer.expires = jiffies+50; add_timer(&adckey->timer); printk(KERN_INFO "rk2818_adckey: driver initialized\n"); return 0; free_gpio_irq: free_irq(irq_num,NULL); free_gpio: gpio_free(pdata->adc_key->pin_playon); failed_free_dev: platform_set_drvdata(pdev, NULL); input_free_device(input_dev); failed_free: kfree(adckey); return error; }
static int __devinit ep93xx_keypad_probe(struct platform_device *pdev) { struct ep93xx_keypad *keypad; struct input_dev *input_dev; struct resource *res; int err; keypad = kzalloc(sizeof(struct ep93xx_keypad), GFP_KERNEL); if (!keypad) return -ENOMEM; keypad->pdata = pdev->dev.platform_data; if (!keypad->pdata) { err = -EINVAL; goto failed_free; } keypad->irq = platform_get_irq(pdev, 0); if (!keypad->irq) { err = -ENXIO; goto failed_free; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { err = -ENXIO; goto failed_free; } res = request_mem_region(res->start, resource_size(res), pdev->name); if (!res) { err = -EBUSY; goto failed_free; } keypad->mmio_base = ioremap(res->start, resource_size(res)); if (keypad->mmio_base == NULL) { err = -ENXIO; goto failed_free_mem; } err = ep93xx_keypad_acquire_gpio(pdev); if (err) goto failed_free_io; keypad->clk = clk_get(&pdev->dev, NULL); if (IS_ERR(keypad->clk)) { err = PTR_ERR(keypad->clk); goto failed_free_gpio; } input_dev = input_allocate_device(); if (!input_dev) { err = -ENOMEM; goto failed_put_clk; } keypad->input_dev = input_dev; input_dev->name = pdev->name; input_dev->id.bustype = BUS_HOST; input_dev->open = ep93xx_keypad_open; input_dev->close = ep93xx_keypad_close; input_dev->dev.parent = &pdev->dev; input_dev->keycode = keypad->matrix_keycodes; input_dev->keycodesize = sizeof(keypad->matrix_keycodes[0]); input_dev->keycodemax = ARRAY_SIZE(keypad->matrix_keycodes); input_set_drvdata(input_dev, keypad); input_dev->evbit[0] = BIT_MASK(EV_KEY); if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT) input_dev->evbit[0] |= BIT_MASK(EV_REP); ep93xx_keypad_build_keycode(keypad); platform_set_drvdata(pdev, keypad); err = request_irq(keypad->irq, ep93xx_keypad_irq_handler, IRQF_DISABLED, pdev->name, keypad); if (err) goto failed_free_dev; err = input_register_device(input_dev); if (err) goto failed_free_irq; device_init_wakeup(&pdev->dev, 1); return 0; failed_free_irq: free_irq(keypad->irq, pdev); platform_set_drvdata(pdev, NULL); failed_free_dev: input_free_device(input_dev); failed_put_clk: clk_put(keypad->clk); failed_free_gpio: ep93xx_keypad_release_gpio(pdev); failed_free_io: iounmap(keypad->mmio_base); failed_free_mem: release_mem_region(res->start, resource_size(res)); failed_free: kfree(keypad); return err; }
static int __devinit ts_probe(struct platform_device *pdev) { int result; struct input_dev *input_dev; #ifdef CONFIG_HUAWEI_TOUCHSCREEN_EXTRA_KEY struct input_dev *key_dev; #endif struct resource *res, *ioarea; struct ts *ts; unsigned int x_max, y_max, pressure_max; struct msm_ts_platform_data *pdata = pdev->dev.platform_data; /* The primary initialization of the TS Hardware * is taken care of by the ADC code on the modem side */ ts = kzalloc(sizeof(struct ts), GFP_KERNEL); input_dev = input_allocate_device(); if (!input_dev || !ts) { result = -ENOMEM; goto fail_alloc_mem; } ts->is_first_point = true; ts->pen_up_count = 0; /*if use touch for keycode, set true*/ ts->use_touch_key = false; if(board_use_tssc_touch(&ts->use_touch_key)) { printk(KERN_ERR "%s: Cannot support MSM_TOUCH!\n", __FUNCTION__); result = -ENODEV; goto fail_alloc_mem; } #ifdef CONFIG_HUAWEI_TOUCHSCREEN_EXTRA_KEY key_dev = input_allocate_device(); if (!key_dev || !ts) { result = -ENOMEM; goto fail_alloc_mem; } #endif res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n"); result = -ENOENT; goto fail_alloc_mem; } ts->irq = platform_get_irq(pdev, 0); if (!ts->irq) { dev_err(&pdev->dev, "Could not get IORESOURCE_IRQ\n"); result = -ENODEV; goto fail_alloc_mem; } ioarea = request_mem_region(res->start, resource_size(res), pdev->name); if (!ioarea) { dev_err(&pdev->dev, "Could not allocate io region\n"); result = -EBUSY; goto fail_alloc_mem; } virt = ioremap(res->start, resource_size(res)); if (!virt) { dev_err(&pdev->dev, "Could not ioremap region\n"); result = -ENOMEM; goto fail_ioremap; } input_dev->name = TS_DRIVER_NAME; input_dev->phys = "msm_touch/input0"; input_dev->id.bustype = BUS_HOST; input_dev->id.vendor = 0x0001; input_dev->id.product = 0x0002; input_dev->id.version = 0x0100; input_dev->dev.parent = &pdev->dev; input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE); input_dev->absbit[BIT_WORD(ABS_MISC)] = BIT_MASK(ABS_MISC); input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); if (pdata) { x_max = pdata->x_max ? : X_MAX; y_max = pdata->y_max ? : Y_MAX; pressure_max = pdata->pressure_max ? : P_MAX; } else {
static int __devinit sh_keysc_probe(struct platform_device *pdev) { struct sh_keysc_priv *priv; struct sh_keysc_info *pdata; struct resource *res; struct input_dev *input; char clk_name[8]; int i, k; int irq, error; if (!pdev->dev.platform_data) { dev_err(&pdev->dev, "no platform data defined\n"); error = -EINVAL; goto err0; } error = -ENXIO; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) { dev_err(&pdev->dev, "failed to get I/O memory\n"); goto err0; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "failed to get irq\n"); goto err0; } priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (priv == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); error = -ENOMEM; goto err0; } platform_set_drvdata(pdev, priv); memcpy(&priv->pdata, pdev->dev.platform_data, sizeof(priv->pdata)); pdata = &priv->pdata; priv->iomem_base = ioremap_nocache(res->start, res_size(res)); if (priv->iomem_base == NULL) { dev_err(&pdev->dev, "failed to remap I/O memory\n"); error = -ENXIO; goto err1; } snprintf(clk_name, sizeof(clk_name), "keysc%d", pdev->id); priv->clk = clk_get(&pdev->dev, clk_name); if (IS_ERR(priv->clk)) { dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); error = PTR_ERR(priv->clk); goto err2; } priv->input = input_allocate_device(); if (!priv->input) { dev_err(&pdev->dev, "failed to allocate input device\n"); error = -ENOMEM; goto err3; } input = priv->input; input->evbit[0] = BIT_MASK(EV_KEY); input->name = pdev->name; input->phys = "sh-keysc-keys/input0"; input->dev.parent = &pdev->dev; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; input->id.product = 0x0001; input->id.version = 0x0100; error = request_irq(irq, sh_keysc_isr, 0, pdev->name, pdev); if (error) { dev_err(&pdev->dev, "failed to request IRQ\n"); goto err4; } for (i = 0; i < SH_KEYSC_MAXKEYS; i++) { k = pdata->keycodes[i]; if (k) input_set_capability(input, EV_KEY, k); } error = input_register_device(input); if (error) { dev_err(&pdev->dev, "failed to register input device\n"); goto err5; } clk_enable(priv->clk); iowrite16((sh_keysc_mode[pdata->mode].kymd << 8) | pdata->scan_timing, priv->iomem_base + KYCR1_OFFS); iowrite16(0, priv->iomem_base + KYOUTDR_OFFS); iowrite16(KYCR2_IRQ_LEVEL, priv->iomem_base + KYCR2_OFFS); device_init_wakeup(&pdev->dev, 1); return 0; err5: free_irq(irq, pdev); err4: input_free_device(input); err3: clk_put(priv->clk); err2: iounmap(priv->iomem_base); err1: platform_set_drvdata(pdev, NULL); kfree(priv); err0: return error; }
static int __devinit matrix_keypad_probe(struct platform_device *pdev) { const struct matrix_keypad_platform_data *pdata; const struct matrix_keymap_data *keymap_data; struct matrix_keypad *keypad; struct input_dev *input_dev; unsigned short *keycodes; unsigned int row_shift; int err; pdata = pdev->dev.platform_data; if (!pdata) { dev_err(&pdev->dev, "no platform data defined\n"); return -EINVAL; } keymap_data = pdata->keymap_data; if (!keymap_data) { dev_err(&pdev->dev, "no keymap data defined\n"); return -EINVAL; } row_shift = get_count_order(pdata->num_col_gpios); keypad = kzalloc(sizeof(struct matrix_keypad), GFP_KERNEL); keycodes = kzalloc((pdata->num_row_gpios << row_shift) * sizeof(*keycodes), GFP_KERNEL); input_dev = input_allocate_device(); if (!keypad || !keycodes || !input_dev) { err = -ENOMEM; goto err_free_mem; } keypad->input_dev = input_dev; keypad->pdata = pdata; keypad->keycodes = keycodes; keypad->row_shift = row_shift; keypad->stopped = true; INIT_DELAYED_WORK(&keypad->work, matrix_keypad_scan); mutex_init(&keypad->lock); input_dev->name = pdev->name; input_dev->id.bustype = BUS_HOST; input_dev->dev.parent = &pdev->dev; input_dev->evbit[0] = BIT_MASK(EV_KEY); if (!pdata->no_autorepeat) input_dev->evbit[0] |= BIT_MASK(EV_REP); input_dev->open = matrix_keypad_start; input_dev->close = matrix_keypad_stop; input_dev->keycode = keycodes; input_dev->keycodesize = sizeof(*keycodes); input_dev->keycodemax = pdata->num_row_gpios << row_shift; matrix_keypad_build_keymap(keymap_data, row_shift, input_dev->keycode, input_dev->keybit); input_set_capability(input_dev, EV_MSC, MSC_SCAN); input_set_drvdata(input_dev, keypad); err = init_matrix_gpio(pdev, keypad); if (err) goto err_free_mem; err = input_register_device(keypad->input_dev); if (err) goto err_free_mem; device_init_wakeup(&pdev->dev, pdata->wakeup); platform_set_drvdata(pdev, keypad); return 0; err_free_mem: input_free_device(input_dev); kfree(keycodes); kfree(keypad); return err; }
static int xpad_init_input(struct usb_xpad *xpad) { struct input_dev *input_dev; int i, error; input_dev = input_allocate_device(); if (!input_dev) return -ENOMEM; xpad->dev = input_dev; input_dev->name = xpad->name; input_dev->phys = xpad->phys; usb_to_input_id(xpad->udev, &input_dev->id); input_dev->dev.parent = &xpad->intf->dev; input_set_drvdata(input_dev, xpad); input_dev->open = xpad_open; input_dev->close = xpad_close; input_dev->evbit[0] = BIT_MASK(EV_KEY); if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { input_dev->evbit[0] |= BIT_MASK(EV_ABS); /* set up axes */ for (i = 0; xpad_abs[i] >= 0; i++) xpad_set_up_abs(input_dev, xpad_abs[i]); } /* set up standard buttons */ for (i = 0; xpad_common_btn[i] >= 0; i++) __set_bit(xpad_common_btn[i], input_dev->keybit); /* set up model-specific ones */ if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W || xpad->xtype == XTYPE_XBOXONE) { for (i = 0; xpad360_btn[i] >= 0; i++) __set_bit(xpad360_btn[i], input_dev->keybit); } else { for (i = 0; xpad_btn[i] >= 0; i++) __set_bit(xpad_btn[i], input_dev->keybit); } if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { for (i = 0; xpad_btn_pad[i] >= 0; i++) __set_bit(xpad_btn_pad[i], input_dev->keybit); } /* this should be a simple else block. However historically xbox360w * has mapped DPAD to buttons while xbox360 did not. * This made no sense, but now we can not just switch back and have to * support both behaviors. */ if(!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || xpad->xtype == XTYPE_XBOX360W) { for (i = 0; xpad_abs_pad[i] >= 0; i++) xpad_set_up_abs(input_dev, xpad_abs_pad[i]); } if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { for (i = 0; xpad_btn_triggers[i] >= 0; i++) __set_bit(xpad_btn_triggers[i], input_dev->keybit); } else { for (i = 0; xpad_abs_triggers[i] >= 0; i++) xpad_set_up_abs(input_dev, xpad_abs_triggers[i]); } xpad_identify_controller(xpad); error = xpad_init_ff(xpad); if (error) goto fail_init_ff; error = xpad_led_probe(xpad); if (error) goto fail_init_led; error = input_register_device(xpad->dev); if (error) goto fail_input_register; return 0; fail_input_register: xpad_led_disconnect(xpad); fail_init_led: input_ff_destroy(input_dev); fail_init_ff: input_free_device(input_dev); return error; }
return error; } static void cpu_iboost_input_disconnect(struct input_handle *handle) { input_close_device(handle); input_unregister_handle(handle); kfree(handle); } static const struct input_device_id cpu_iboost_ids[] = { /* multi-touch touchscreen */ { .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT, .evbit = { BIT_MASK(EV_ABS) }, .absbit = { [BIT_WORD(ABS_MT_POSITION_X)] = BIT_MASK(ABS_MT_POSITION_X) | BIT_MASK(ABS_MT_POSITION_Y) }, }, /* touchpad */ { .flags = INPUT_DEVICE_ID_MATCH_KEYBIT | INPUT_DEVICE_ID_MATCH_ABSBIT, .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) }, .absbit = { [BIT_WORD(ABS_X)] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) }, }, { }, };
void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac) { input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_STYLUS) | BIT_MASK(BTN_STYLUS2); }