本文整理匯總了C++中BIT_MASK函數的典型用法代碼示例。如果您正苦於以下問題:C++ BIT_MASK函數的具體用法?C++ BIT_MASK怎麽用?C++ BIT_MASK使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BIT_MASK函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: input_dev_pt
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);
}
示例2: ucb1400_ts_probe
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;
}
示例3: gpio_keys_probe
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++) {
//.........這裏部分代碼省略.........
示例4: locomokbd_probe
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;
}
示例5: cpuboost_input_disconnect
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,
示例6: pcap_ts_probe
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;
}
示例7: w90p910_keypad_probe
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);
//.........這裏部分代碼省略.........
示例8: HC548_probe
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;
//.........這裏部分代碼省略.........
示例9: bt_init
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;
}
示例10: nxp_key_probe
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]);
}
//.........這裏部分代碼省略.........
示例11: iforce_init_device
//.........這裏部分代碼省略.........
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:
示例12: w90x900ts_probe
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;
}
示例13: dvb_usb_remote_init
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;
}
示例14: wacom_probe
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);
//.........這裏部分代碼省略.........
示例15: sun4ikbd_init
static int __init sun4ikbd_init(void)
{
int i;
int err =0;
#ifdef KEY_DEBUG
printk("sun4ikbd_init \n");
#endif
sun4ikbd_dev = input_allocate_device();
if (!sun4ikbd_dev) {
printk(KERN_ERR "sun4ikbd: not enough memory for input device\n");
err = -ENOMEM;
goto fail1;
}
sun4ikbd_dev->name = "sun4i-keyboard";
sun4ikbd_dev->phys = "sun4ikbd/input0";
sun4ikbd_dev->id.bustype = BUS_HOST;
sun4ikbd_dev->id.vendor = 0x0001;
sun4ikbd_dev->id.product = 0x0001;
sun4ikbd_dev->id.version = 0x0100;
#ifdef REPORT_REPEAT_KEY_BY_INPUT_CORE
sun4ikbd_dev->evbit[0] = BIT_MASK(EV_KEY)|BIT_MASK(EV_REP);
printk("REPORT_REPEAT_KEY_BY_INPUT_CORE is defined, support report repeat key value. \n");
#else
sun4ikbd_dev->evbit[0] = BIT_MASK(EV_KEY);
#endif
for (i = 0; i < KEY_MAX_CNT; i++)
set_bit(sun4i_scankeycodes[i], sun4ikbd_dev->keybit);
#ifdef ONE_CHANNEL
writel(LRADC_ADC0_DOWN_EN|LRADC_ADC0_UP_EN|LRADC_ADC0_DATA_EN,KEY_BASSADDRESS + LRADC_INTC);
writel(FIRST_CONCERT_DLY|LEVELB_VOL|KEY_MODE_SELECT|LRADC_HOLD_EN|ADC_CHAN_SELECT|LRADC_SAMPLE_62HZ|LRADC_EN,KEY_BASSADDRESS + LRADC_CTRL);
//writel(FIRST_CONCERT_DLY|LEVELB_VOL|KEY_MODE_SELECT|ADC_CHAN_SELECT|LRADC_SAMPLE_62HZ|LRADC_EN,KEY_BASSADDRESS + LRADC_CTRL);
#else
#endif
if (request_irq(SW_INT_IRQNO_LRADC, sun4i_isr_key, 0, "sun4ikbd", NULL)){
err = -EBUSY;
printk("request irq failure. \n");
goto fail2;
}
err = input_register_device(sun4ikbd_dev);
if (err)
goto fail3;
#ifdef CONFIG_HAS_EARLYSUSPEND
printk("==register_early_suspend =\n");
keyboard_data = kzalloc(sizeof(*keyboard_data), GFP_KERNEL);
if (keyboard_data == NULL) {
err = -ENOMEM;
goto err_alloc_data_failed;
}
keyboard_data->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 3;
keyboard_data->early_suspend.suspend = sun4i_keyboard_suspend;
keyboard_data->early_suspend.resume = sun4i_keyboard_resume;
register_early_suspend(&keyboard_data->early_suspend);
#endif
return 0;
#ifdef CONFIG_HAS_EARLYSUSPEND
err_alloc_data_failed:
#endif
fail3:
free_irq(SW_INT_IRQNO_LRADC, sun4i_isr_key);
fail2:
input_free_device(sun4ikbd_dev);
fail1:
;
#ifdef KEY_DEBUG
printk("sun4ikbd_init failed. \n");
#endif
return err;
}