您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ BIT_MASK函数代码示例

51自学网 2021-06-01 19:50:48
  C++
这篇教程C++ BIT_MASK函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中BIT_MASK函数的典型用法代码示例。如果您正苦于以下问题:C++ BIT_MASK函数的具体用法?C++ BIT_MASK怎么用?C++ BIT_MASK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了BIT_MASK函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);}
开发者ID:A2109devs,项目名称:lenovo_a2109a_kernel,代码行数:4,


示例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;}
开发者ID:Medvedroid,项目名称:OT_903D-kernel-2.6.35.7,代码行数:76,


示例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++) {//.........这里部分代码省略.........
开发者ID:atxoxx,项目名称:FireWork-Kernel-GT-i9506,代码行数:101,


示例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;}
开发者ID:020gzh,项目名称:linux,代码行数:84,


示例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,
开发者ID:adyjl,项目名称:DORIMANX_LG_STOCK_LP_KERNEL,代码行数:31,


示例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;}
开发者ID:12019,项目名称:kernel_zte_u880,代码行数:64,


示例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);//.........这里部分代码省略.........
开发者ID:1111saeid,项目名称:jb_kernel_3.0.16_htc_golfu,代码行数:101,


示例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;//.........这里部分代码省略.........
开发者ID:advx9600,项目名称:kernel-4.4-RuiEr,代码行数:101,


示例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;}
开发者ID:zhu8920253,项目名称:linux_driver,代码行数:71,


示例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]);    }//.........这里部分代码省略.........
开发者ID:advx9600,项目名称:kernel-4.4-RuiEr,代码行数:101,


示例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:
开发者ID:AlexShiLucky,项目名称:linux,代码行数:67,


示例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;}
开发者ID:03199618,项目名称:linux,代码行数:85,


示例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;}
开发者ID:asdlei00,项目名称:Ace-i,代码行数:61,


示例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);//.........这里部分代码省略.........
开发者ID:A2109devs,项目名称:lenovo_a2109a_kernel,代码行数:101,


示例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;}
开发者ID:abazad,项目名称:android_kernel_allwinner_a10,代码行数:81,


示例16: kbtab_probe

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;}
开发者ID:asmalldev,项目名称:linux,代码行数:72,


示例17: input_close_device

{	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;
开发者ID:debugevery,项目名称:android-kernel-samsung-dev,代码行数:30,


示例18: 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 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);//.........这里部分代码省略.........
开发者ID:halaszk,项目名称:android_kernel_samsung_lt03,代码行数:101,


示例19: prepare_tsc_input_device

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;}
开发者ID:aexon,项目名称:hammerheadcaf_kernel,代码行数:64,


示例20: imx_keypad_probe

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 *///.........这里部分代码省略.........
开发者ID:0xroot,项目名称:Blackphone-BP1-Kernel,代码行数:101,


示例21: tps6507x_ts_probe

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;	 }//.........这里部分代码省略.........
开发者ID:33d,项目名称:linux-2.6.21-hh20,代码行数:101,


示例22: ep93xx_keypad_probe

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://.........这里部分代码省略.........
开发者ID:KroMignon,项目名称:linux-emcraft,代码行数:101,


示例23: ts_probe

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 {
开发者ID:troykitten,项目名称:kernel_huawei_u8120,代码行数:89,


示例24: matrix_keypad_probe

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;}
开发者ID:SmokyBob,项目名称:android_kernel_asus_padfone2,代码行数:80,


示例25: xpad_init_input

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;}
开发者ID:coolmint,项目名称:xpad,代码行数:92,


示例26: cpu_iboost_input_disconnect

	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) },	},	{ },};
开发者ID:acuicultor,项目名称:Radioactive-kernel-caf,代码行数:30,


示例27: input_dev_pl

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);}
开发者ID:A2109devs,项目名称:lenovo_a2109a_kernel,代码行数:5,



注:本文中的BIT_MASK函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ BIT_SET函数代码示例
C++ BIT_CHECK函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。