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

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

51自学网 2021-06-03 09:21:43
  C++
这篇教程C++ usb_to_input_id函数代码示例写得很实用,希望能帮到您。

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

在下文中一共展示了usb_to_input_id函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: uvc_input_init

static int uvc_input_init(struct uvc_device *dev){	struct input_dev *input;	int ret;	input = input_allocate_device();	if (input == NULL)		return -ENOMEM;	usb_make_path(dev->udev, dev->input_phys, sizeof(dev->input_phys));	strlcat(dev->input_phys, "/button", sizeof(dev->input_phys));	input->name = dev->name;	input->phys = dev->input_phys;	usb_to_input_id(dev->udev, &input->id);	input->dev.parent = &dev->intf->dev;	__set_bit(EV_KEY, input->evbit);	__set_bit(KEY_CAMERA, input->keybit);	if ((ret = input_register_device(input)) < 0)		goto error;	dev->input = input;	return 0;error:	input_free_device(input);	return ret;}
开发者ID:020gzh,项目名称:linux,代码行数:30,


示例2: konicawc_register_input

static void konicawc_register_input(struct konicawc *cam, struct usb_device *dev){	struct input_dev *input_dev;	int error;	usb_make_path(dev, cam->input_physname, sizeof(cam->input_physname));	strlcat(cam->input_physname, "/input0", sizeof(cam->input_physname));	cam->input = input_dev = input_allocate_device();	if (!input_dev) {		dev_warn(&dev->dev,			 "Not enough memory for camera's input device/n");		return;	}	input_dev->name = "Konicawc snapshot button";	input_dev->phys = cam->input_physname;	usb_to_input_id(dev, &input_dev->id);	input_dev->dev.parent = &dev->dev;	input_dev->evbit[0] = BIT_MASK(EV_KEY);	input_dev->keybit[BIT_WORD(KEY_CAMERA)] = BIT_MASK(KEY_CAMERA);	error = input_register_device(cam->input);	if (error) {		dev_warn(&dev->dev,			 "Failed to register camera's input device, err: %d/n",			 error);		input_free_device(cam->input);		cam->input = NULL;	}}
开发者ID:12rafael,项目名称:jellytimekernel,代码行数:32,


示例3: 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->cdev.dev = &d->udev->dev;	/* 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;	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:IgnasD,项目名称:Tomato-RAF,代码行数:57,


示例4: legacy_dvb_usb_remote_init

static int legacy_dvb_usb_remote_init(struct dvb_usb_device *d){	int i, err, rc_interval;	struct input_dev *input_dev;	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;	d->input_dev = input_dev;	d->rc_dev = NULL;	input_dev->getkeycode = legacy_dvb_usb_getkeycode;	input_dev->setkeycode = legacy_dvb_usb_setkeycode;	/* set the bits for the keys */	deb_rc("key map size: %d/n", d->props.rc.legacy.rc_map_size);	for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {		deb_rc("setting bit for event %d item %d/n",			d->props.rc.legacy.rc_map_table[i].keycode, i);		set_bit(d->props.rc.legacy.rc_map_table[i].keycode, input_dev->keybit);	}	/* setting these two values to non-zero, we have to manage key repeats */	input_dev->rep[REP_PERIOD] = d->props.rc.legacy.rc_interval;	input_dev->rep[REP_DELAY]  = d->props.rc.legacy.rc_interval + 150;	input_set_drvdata(input_dev, d);	err = input_register_device(input_dev);	if (err)		input_free_device(input_dev);	rc_interval = d->props.rc.legacy.rc_interval;	INIT_DELAYED_WORK(&d->rc_query_work, legacy_dvb_usb_read_remote_control);	info("schedule remote query interval to %d msecs.", rc_interval);	schedule_delayed_work(&d->rc_query_work,			      msecs_to_jiffies(rc_interval));	d->state |= DVB_USB_STATE_REMOTE;	return err;}
开发者ID:oscardagrach,项目名称:linux,代码行数:50,


示例5: le16_to_cpu

static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3){	struct device *dev = rr3->dev;	struct rc_dev *rc;	int ret;	u16 prod = le16_to_cpu(rr3->udev->descriptor.idProduct);	rc = rc_allocate_device(RC_DRIVER_IR_RAW);	if (!rc)		return NULL;	snprintf(rr3->name, sizeof(rr3->name),		 "RedRat3%s Infrared Remote Transceiver",		 prod == USB_RR3IIUSB_PRODUCT_ID ? "-II" : "");	usb_make_path(rr3->udev, rr3->phys, sizeof(rr3->phys));	rc->device_name = rr3->name;	rc->input_phys = rr3->phys;	usb_to_input_id(rr3->udev, &rc->input_id);	rc->dev.parent = dev;	rc->priv = rr3;	rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;	rc->min_timeout = MS_TO_NS(RR3_RX_MIN_TIMEOUT);	rc->max_timeout = MS_TO_NS(RR3_RX_MAX_TIMEOUT);	rc->timeout = US_TO_NS(redrat3_get_timeout(rr3));	rc->s_timeout = redrat3_set_timeout;	rc->tx_ir = redrat3_transmit_ir;	rc->s_tx_carrier = redrat3_set_tx_carrier;	rc->s_carrier_report = redrat3_wideband_receiver;	rc->driver_name = DRIVER_NAME;	rc->rx_resolution = US_TO_NS(2);	rc->map_name = RC_MAP_HAUPPAUGE;	ret = rc_register_device(rc);	if (ret < 0) {		dev_err(dev, "remote dev registration failed/n");		goto out;	}	return rc;out:	rc_free_device(rc);	return NULL;}
开发者ID:mkrufky,项目名称:linux,代码行数:46,


示例6: uvc_input_init

/* -------------------------------------------------------------------------- * Input device */static int uvc_input_init(struct uvc_device *dev){	struct usb_device *udev = dev->udev;	struct input_dev *input;	char *phys = NULL;	int ret;	input = input_allocate_device();	if (input == NULL)		return -ENOMEM;	phys = kmalloc(6 + strlen(udev->bus->bus_name) + strlen(udev->devpath),			GFP_KERNEL);	if (phys == NULL) {		ret = -ENOMEM;		goto error;	}	sprintf(phys, "usb-%s-%s", udev->bus->bus_name, udev->devpath);	input->name = dev->name;	input->phys = phys;	usb_to_input_id(udev, &input->id);#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)	input->dev.parent = &dev->intf->dev;#else	input->cdev.dev = &dev->intf->dev;#endif	set_bit(EV_KEY, input->evbit);	set_bit(BTN_0, input->keybit);	if ((ret = input_register_device(input)) < 0)		goto error;	dev->input = input;	return 0;error:	input_free_device(input);	kfree(phys);	return ret;}
开发者ID:xf739645524,项目名称:kernel-rhel5,代码行数:45,


示例7: rc_core_dvb_usb_remote_init

static int rc_core_dvb_usb_remote_init(struct dvb_usb_device *d){	int err, rc_interval;	struct rc_dev *dev;	dev = rc_allocate_device(d->props.rc.core.driver_type);	if (!dev)		return -ENOMEM;	dev->driver_name = d->props.rc.core.module_name;	dev->map_name = d->props.rc.core.rc_codes;	dev->change_protocol = d->props.rc.core.change_protocol;	dev->allowed_protocols = d->props.rc.core.allowed_protos;	usb_to_input_id(d->udev, &dev->input_id);	dev->device_name = "IR-receiver inside an USB DVB receiver";	dev->input_phys = d->rc_phys;	dev->dev.parent = &d->udev->dev;	dev->priv = d;	err = rc_register_device(dev);	if (err < 0) {		rc_free_device(dev);		return err;	}	d->input_dev = NULL;	d->rc_dev = dev;	if (!d->props.rc.core.rc_query || d->props.rc.core.bulk_mode)		return 0;	/* Polling mode - initialize a work queue for handling it */	INIT_DELAYED_WORK(&d->rc_query_work, dvb_usb_read_remote_control);	rc_interval = d->props.rc.core.rc_interval;	info("schedule remote query interval to %d msecs.", rc_interval);	schedule_delayed_work(&d->rc_query_work,			      msecs_to_jiffies(rc_interval));	return 0;}
开发者ID:oscardagrach,项目名称:linux,代码行数:42,


示例8: lme2510_int_service

static int lme2510_int_service(struct dvb_usb_adapter *adap){	struct dvb_usb_device *d = adap->dev;	struct rc_dev *rc;	int ret;	info("STA Configuring Remote");	rc = rc_allocate_device();	if (!rc)		return -ENOMEM;	usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys));	strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys));	rc->input_name = "LME2510 Remote Control";	rc->input_phys = d->rc_phys;	rc->map_name = RC_MAP_LME2510;	rc->driver_name = "LME 2510";	usb_to_input_id(d->udev, &rc->input_id);	ret = rc_register_device(rc);	if (ret) {		rc_free_device(rc);		return ret;	}	d->rc_dev = rc;	/* Start the Interupt */	ret = lme2510_int_read(adap);	if (ret < 0) {		rc_unregister_device(rc);		info("INT Unable to start Interupt Service");		return -ENODEV;	}	return 0;}
开发者ID:LittleForker,项目名称:linux-2.6,代码行数:38,


示例9: bcm5974_probe

static int bcm5974_probe(struct usb_interface *iface,			 const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev(iface);	const struct bcm5974_config *cfg;	struct bcm5974 *dev;	struct input_dev *input_dev;	int error = -ENOMEM;	/* find the product index */	cfg = bcm5974_get_config(udev);	/* allocate memory for our device state and initialize it */	dev = kzalloc(sizeof(struct bcm5974), GFP_KERNEL);	input_dev = input_allocate_device();	if (!dev || !input_dev) {		err("bcm5974: out of memory");		goto err_free_devs;	}	dev->udev = udev;	dev->intf = iface;	dev->input = input_dev;	dev->cfg = *cfg;	mutex_init(&dev->pm_mutex);	/* setup urbs */	dev->bt_urb = usb_alloc_urb(0, GFP_KERNEL);	if (!dev->bt_urb)		goto err_free_devs;	dev->tp_urb = usb_alloc_urb(0, GFP_KERNEL);	if (!dev->tp_urb)		goto err_free_bt_urb;	dev->bt_data = usb_alloc_coherent(dev->udev,					  dev->cfg.bt_datalen, GFP_KERNEL,					  &dev->bt_urb->transfer_dma);	if (!dev->bt_data)		goto err_free_urb;	dev->tp_data = usb_alloc_coherent(dev->udev,					  dev->cfg.tp_datalen, GFP_KERNEL,					  &dev->tp_urb->transfer_dma);	if (!dev->tp_data)		goto err_free_bt_buffer;	usb_fill_int_urb(dev->bt_urb, udev,			 usb_rcvintpipe(udev, cfg->bt_ep),			 dev->bt_data, dev->cfg.bt_datalen,			 bcm5974_irq_button, dev, 1);	usb_fill_int_urb(dev->tp_urb, udev,			 usb_rcvintpipe(udev, cfg->tp_ep),			 dev->tp_data, dev->cfg.tp_datalen,			 bcm5974_irq_trackpad, dev, 1);	/* create bcm5974 device */	usb_make_path(udev, dev->phys, sizeof(dev->phys));	strlcat(dev->phys, "/input0", sizeof(dev->phys));	input_dev->name = "bcm5974";	input_dev->phys = dev->phys;	usb_to_input_id(dev->udev, &input_dev->id);	/* report driver capabilities via the version field */	input_dev->id.version = cfg->caps;	input_dev->dev.parent = &iface->dev;	input_set_drvdata(input_dev, dev);	input_dev->open = bcm5974_open;	input_dev->close = bcm5974_close;	setup_events_to_report(input_dev, cfg);	error = input_register_device(dev->input);	if (error)		goto err_free_buffer;	/* save our data pointer in this interface device */	usb_set_intfdata(iface, dev);	return 0;err_free_buffer:	usb_free_coherent(dev->udev, dev->cfg.tp_datalen,		dev->tp_data, dev->tp_urb->transfer_dma);err_free_bt_buffer:	usb_free_coherent(dev->udev, dev->cfg.bt_datalen,		dev->bt_data, dev->bt_urb->transfer_dma);err_free_urb:	usb_free_urb(dev->tp_urb);err_free_bt_urb:	usb_free_urb(dev->bt_urb);err_free_devs:	usb_set_intfdata(iface, NULL);	input_free_device(input_dev);	kfree(dev);	return error;}
开发者ID:303750856,项目名称:linux-3.1,代码行数:100,


示例10: xpad_probe

static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev(intf);	struct usb_xpad *xpad;	struct input_dev *input_dev;	struct usb_endpoint_descriptor *ep_irq_in;	int i;	int error = -ENOMEM;	for (i = 0; xpad_device[i].idVendor; i++) {		if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&		    (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct))			break;	}	xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);	input_dev = input_allocate_device();	if (!xpad || !input_dev)		goto fail1;	xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN,				       GFP_KERNEL, &xpad->idata_dma);	if (!xpad->idata)		goto fail1;	xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL);	if (!xpad->irq_in)		goto fail2;	xpad->udev = udev;	xpad->dpad_mapping = xpad_device[i].dpad_mapping;	xpad->xtype = xpad_device[i].xtype;	if (xpad->dpad_mapping == MAP_DPAD_UNKNOWN)		xpad->dpad_mapping = !dpad_to_buttons;	if (xpad->xtype == XTYPE_UNKNOWN) {		if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) {			if (intf->cur_altsetting->desc.bInterfaceProtocol == 129)				xpad->xtype = XTYPE_XBOX360W;			else				xpad->xtype = XTYPE_XBOX360;		} else			xpad->xtype = XTYPE_XBOX;	}	xpad->dev = input_dev;	usb_make_path(udev, xpad->phys, sizeof(xpad->phys));	strlcat(xpad->phys, "/input0", sizeof(xpad->phys));	input_dev->name = xpad_device[i].name;	input_dev->phys = xpad->phys;	usb_to_input_id(udev, &input_dev->id);	input_dev->dev.parent = &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) | BIT_MASK(EV_ABS);	/* set up buttons */	for (i = 0; xpad_common_btn[i] >= 0; i++)		set_bit(xpad_common_btn[i], input_dev->keybit);	if ((xpad->xtype == XTYPE_XBOX360) || (xpad->xtype == XTYPE_XBOX360W))		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->dpad_mapping == MAP_DPAD_TO_BUTTONS)		for (i = 0; xpad_btn_pad[i] >= 0; i++)			set_bit(xpad_btn_pad[i], input_dev->keybit);	/* set up axes */	for (i = 0; xpad_abs[i] >= 0; i++)		xpad_set_up_abs(input_dev, xpad_abs[i]);	if (xpad->dpad_mapping == MAP_DPAD_TO_AXES)		for (i = 0; xpad_abs_pad[i] >= 0; i++)		    xpad_set_up_abs(input_dev, xpad_abs_pad[i]);	error = xpad_init_output(intf, xpad);	if (error)		goto fail2;	error = xpad_init_ff(xpad);	if (error)		goto fail3;	error = xpad_led_probe(xpad);	if (error)		goto fail3;	ep_irq_in = &intf->cur_altsetting->endpoint[0].desc;	usb_fill_int_urb(xpad->irq_in, udev,			 usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress),			 xpad->idata, XPAD_PKT_LEN, xpad_irq_in,			 xpad, ep_irq_in->bInterval);	xpad->irq_in->transfer_dma = xpad->idata_dma;	xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;	error = input_register_device(xpad->dev);//.........这里部分代码省略.........
开发者ID:maraz,项目名称:linux-2.6,代码行数:101,


示例11: xpad_probe

static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev (intf);	struct usb_xpad *xpad;	struct input_dev *input_dev;	struct usb_endpoint_descriptor *ep_irq_in;	int i;	int error = -ENOMEM;	for (i = 0; xpad_device[i].idVendor; i++) {		if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&		    (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct))			break;	}	xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);	input_dev = input_allocate_device();	if (!xpad || !input_dev)		goto fail1;	xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN,				       GFP_ATOMIC, &xpad->idata_dma);	if (!xpad->idata)		goto fail1;	xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL);	if (!xpad->irq_in)		goto fail2;	xpad->udev = udev;	xpad->dpad_mapping = xpad_device[i].dpad_mapping;	if (xpad->dpad_mapping == MAP_DPAD_UNKNOWN)		xpad->dpad_mapping = dpad_to_buttons;	xpad->dev = input_dev;	usb_make_path(udev, xpad->phys, sizeof(xpad->phys));	strlcat(xpad->phys, "/input0", sizeof(xpad->phys));	input_dev->name = xpad_device[i].name;	input_dev->phys = xpad->phys;	usb_to_input_id(udev, &input_dev->id);	input_dev->dev.parent = &intf->dev;	input_set_drvdata(input_dev, xpad);	input_dev->open = xpad_open;	input_dev->close = xpad_close;	input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);	/* set up buttons */	for (i = 0; xpad_btn[i] >= 0; i++)		set_bit(xpad_btn[i], input_dev->keybit);	if (xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS)		for (i = 0; xpad_btn_pad[i] >= 0; i++)			set_bit(xpad_btn_pad[i], input_dev->keybit);	/* set up axes */	for (i = 0; xpad_abs[i] >= 0; i++)		xpad_set_up_abs(input_dev, xpad_abs[i]);	if (xpad->dpad_mapping == MAP_DPAD_TO_AXES)		for (i = 0; xpad_abs_pad[i] >= 0; i++)		    xpad_set_up_abs(input_dev, xpad_abs_pad[i]);	ep_irq_in = &intf->cur_altsetting->endpoint[0].desc;	usb_fill_int_urb(xpad->irq_in, udev,			 usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress),			 xpad->idata, XPAD_PKT_LEN, xpad_irq_in,			 xpad, ep_irq_in->bInterval);	xpad->irq_in->transfer_dma = xpad->idata_dma;	xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;	error = input_register_device(xpad->dev);	if (error)		goto fail3;	usb_set_intfdata(intf, xpad);	return 0; fail3:	usb_free_urb(xpad->irq_in); fail2:	usb_buffer_free(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); fail1:	input_free_device(input_dev);	kfree(xpad);	return error;}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:85,


示例12: xpad_probe

static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev(intf);	struct usb_xpad *xpad;	struct input_dev *input_dev;	struct usb_endpoint_descriptor *ep_irq_in;	int ep_irq_in_idx;	int i, error;	for (i = 0; xpad_device[i].idVendor; i++) {		if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&		    (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct))			break;	}	if (xpad_device[i].xtype == XTYPE_XBOXONE &&	    intf->cur_altsetting->desc.bInterfaceNumber != 0) {		/*		 * The Xbox One controller lists three interfaces all with the		 * same interface class, subclass and protocol. Differentiate by		 * interface number.		 */		return -ENODEV;	}	xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);	input_dev = input_allocate_device();	if (!xpad || !input_dev) {		error = -ENOMEM;		goto fail1;	}	xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN,					 GFP_KERNEL, &xpad->idata_dma);	if (!xpad->idata) {		error = -ENOMEM;		goto fail1;	}	xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL);	if (!xpad->irq_in) {		error = -ENOMEM;		goto fail2;	}	xpad->udev = udev;	xpad->intf = intf;	xpad->mapping = xpad_device[i].mapping;	xpad->xtype = xpad_device[i].xtype;	if (xpad->xtype == XTYPE_UNKNOWN) {		if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) {			if (intf->cur_altsetting->desc.bInterfaceProtocol == 129)				xpad->xtype = XTYPE_XBOX360W;			else				xpad->xtype = XTYPE_XBOX360;		} else			xpad->xtype = XTYPE_XBOX;		if (dpad_to_buttons)			xpad->mapping |= MAP_DPAD_TO_BUTTONS;		if (triggers_to_buttons)			xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS;		if (sticks_to_null)			xpad->mapping |= MAP_STICKS_TO_NULL;	}	xpad->dev = input_dev;	usb_make_path(udev, xpad->phys, sizeof(xpad->phys));	strlcat(xpad->phys, "/input0", sizeof(xpad->phys));	input_dev->name = xpad_device[i].name;	input_dev->phys = xpad->phys;	usb_to_input_id(udev, &input_dev->id);	input_dev->dev.parent = &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 {//.........这里部分代码省略.........
开发者ID:19Dan01,项目名称:linux,代码行数:101,


示例13: snd_usb_caiaq_input_init

int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev){	struct usb_device *usb_dev = dev->chip.dev;	struct input_dev *input;	int i, ret = 0;	input = input_allocate_device();	if (!input)		return -ENOMEM;	usb_make_path(usb_dev, dev->phys, sizeof(dev->phys));	strlcat(dev->phys, "/input0", sizeof(dev->phys));	input->name = dev->product_name;	input->phys = dev->phys;	usb_to_input_id(usb_dev, &input->id);	input->dev.parent = &usb_dev->dev;	input_set_drvdata(input, dev);	switch (dev->chip.usb_id) {	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):		input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);		input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |			BIT_MASK(ABS_Z);		BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk2));		memcpy(dev->keycode, keycode_rk2, sizeof(keycode_rk2));		input->keycodemax = ARRAY_SIZE(keycode_rk2);		input_set_abs_params(input, ABS_X, 0, 4096, 0, 10);		input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10);		input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10);		snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0);		break;	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):		input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);		input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |			BIT_MASK(ABS_Z);		BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk3));		memcpy(dev->keycode, keycode_rk3, sizeof(keycode_rk3));		input->keycodemax = ARRAY_SIZE(keycode_rk3);		input_set_abs_params(input, ABS_X, 0, 1024, 0, 10);		input_set_abs_params(input, ABS_Y, 0, 1024, 0, 10);		input_set_abs_params(input, ABS_Z, 0, 1024, 0, 10);		snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0);		break;	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):		input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);		input->absbit[0] = BIT_MASK(ABS_X);		BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_ak1));		memcpy(dev->keycode, keycode_ak1, sizeof(keycode_ak1));		input->keycodemax = ARRAY_SIZE(keycode_ak1);		input_set_abs_params(input, ABS_X, 0, 999, 0, 10);		snd_usb_caiaq_set_auto_msg(dev, 1, 0, 5);		break;	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):		input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);		input->absbit[0] = BIT_MASK(ABS_HAT0X) | BIT_MASK(ABS_HAT0Y) |				   BIT_MASK(ABS_HAT1X) | BIT_MASK(ABS_HAT1Y) |				   BIT_MASK(ABS_HAT2X) | BIT_MASK(ABS_HAT2Y) |				   BIT_MASK(ABS_HAT3X) | BIT_MASK(ABS_HAT3Y) |				   BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |				   BIT_MASK(ABS_Z);		input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);		BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_kore));		memcpy(dev->keycode, keycode_kore, sizeof(keycode_kore));		input->keycodemax = ARRAY_SIZE(keycode_kore);		input_set_abs_params(input, ABS_HAT0X, 0, 999, 0, 10);		input_set_abs_params(input, ABS_HAT0Y, 0, 999, 0, 10);		input_set_abs_params(input, ABS_HAT1X, 0, 999, 0, 10);		input_set_abs_params(input, ABS_HAT1Y, 0, 999, 0, 10);		input_set_abs_params(input, ABS_HAT2X, 0, 999, 0, 10);		input_set_abs_params(input, ABS_HAT2Y, 0, 999, 0, 10);		input_set_abs_params(input, ABS_HAT3X, 0, 999, 0, 10);		input_set_abs_params(input, ABS_HAT3Y, 0, 999, 0, 10);		input_set_abs_params(input, ABS_X, 0, 4096, 0, 10);		input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10);		input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10);		input_set_abs_params(input, ABS_MISC, 0, 255, 0, 1);		snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5);		break;	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):		input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);		input->absbit[0] = BIT_MASK(ABS_HAT0X) | BIT_MASK(ABS_HAT0Y) |				   BIT_MASK(ABS_HAT1X) | BIT_MASK(ABS_HAT1Y) |				   BIT_MASK(ABS_HAT2X) | BIT_MASK(ABS_HAT2Y) |				   BIT_MASK(ABS_HAT3X) | BIT_MASK(ABS_HAT3Y) |				   BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |				   BIT_MASK(ABS_Z);		input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);		BUILD_BUG_ON(sizeof(dev->keycode) < KONTROLX1_INPUTS);		for (i = 0; i < KONTROLX1_INPUTS; i++)			dev->keycode[i] = BTN_MISC + i;		input->keycodemax = KONTROLX1_INPUTS;		/* analog potentiometers */		input_set_abs_params(input, ABS_HAT0X, 0, 4096, 0, 10);		input_set_abs_params(input, ABS_HAT0Y, 0, 4096, 0, 10);		input_set_abs_params(input, ABS_HAT1X, 0, 4096, 0, 10);		input_set_abs_params(input, ABS_HAT1Y, 0, 4096, 0, 10);//.........这里部分代码省略.........
开发者ID:ANFS,项目名称:ANFS-kernel,代码行数:101,


示例14: xpad_probe

static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev(intf);	struct usb_xpad *xpad;	struct input_dev *input_dev;	struct usb_endpoint_descriptor *ep_irq_in;	int i, error;	for (i = 0; xpad_device[i].idVendor; i++) {		if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&		    (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct))			break;	}	xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);	input_dev = input_allocate_device();	if (!xpad || !input_dev) {		error = -ENOMEM;		goto fail1;	}	xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN,					 GFP_KERNEL, &xpad->idata_dma);	if (!xpad->idata) {		error = -ENOMEM;		goto fail1;	}	xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL);	if (!xpad->irq_in) {		error = -ENOMEM;		goto fail2;	}	xpad->udev = udev;	xpad->mapping = xpad_device[i].mapping;	xpad->xtype = xpad_device[i].xtype;	if (xpad->xtype == XTYPE_UNKNOWN) {		if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) {			if (intf->cur_altsetting->desc.bInterfaceProtocol == 129)				xpad->xtype = XTYPE_XBOX360W;			else				xpad->xtype = XTYPE_XBOX360;		} else			xpad->xtype = XTYPE_XBOX;		if (dpad_to_buttons)			xpad->mapping |= MAP_DPAD_TO_BUTTONS;		if (triggers_to_buttons)			xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS;		if (sticks_to_null)			xpad->mapping |= MAP_STICKS_TO_NULL;	}	xpad->dev = input_dev;	usb_make_path(udev, xpad->phys, sizeof(xpad->phys));	strlcat(xpad->phys, "/input0", sizeof(xpad->phys));	input_dev->name = xpad_device[i].name;	input_dev->phys = xpad->phys;	usb_to_input_id(udev, &input_dev->id);	input_dev->dev.parent = &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);				for (i = 0; xpad_abs[i] >= 0; i++)			xpad_set_up_abs(input_dev, xpad_abs[i]);	}		for (i = 0; xpad_common_btn[i] >= 0; i++)		__set_bit(xpad_common_btn[i], input_dev->keybit);		if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) {		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);	} else {		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) {//.........这里部分代码省略.........
开发者ID:mjduddin,项目名称:B14CKB1RD_kernel_m8,代码行数:101,


示例15: xpad_probe

static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev(intf);	struct usb_xpad *xpad;	struct input_dev *input_dev;	struct usb_endpoint_descriptor *ep_irq_in;	int i, error;	for (i = 0; xpad_device[i].idVendor; i++) {		if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&		    (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct))			break;	}	xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);	input_dev = input_allocate_device();	if (!xpad || !input_dev) {		error = -ENOMEM;		goto fail1;	}	xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN,					 GFP_KERNEL, &xpad->idata_dma);	if (!xpad->idata) {		error = -ENOMEM;		goto fail1;	}	xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL);	if (!xpad->irq_in) {		error = -ENOMEM;		goto fail2;	}	xpad->udev = udev;	xpad->mapping = xpad_device[i].mapping;	xpad->xtype = xpad_device[i].xtype;	if (xpad->xtype == XTYPE_UNKNOWN) {		if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) {			if (intf->cur_altsetting->desc.bInterfaceProtocol == 129)				xpad->xtype = XTYPE_XBOX360W;			else				xpad->xtype = XTYPE_XBOX360;		} else			xpad->xtype = XTYPE_XBOX;		if (dpad_to_buttons)			xpad->mapping |= MAP_DPAD_TO_BUTTONS;		if (triggers_to_buttons)			xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS;		if (sticks_to_null)			xpad->mapping |= MAP_STICKS_TO_NULL;	}	xpad->dev = input_dev;	usb_make_path(udev, xpad->phys, sizeof(xpad->phys));	strlcat(xpad->phys, "/input0", sizeof(xpad->phys));	input_dev->name = xpad_device[i].name;	input_dev->phys = xpad->phys;	usb_to_input_id(udev, &input_dev->id);	input_dev->dev.parent = &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) {		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);	} else {		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) {//.........这里部分代码省略.........
开发者ID:DarthInferno,项目名称:kernel_sony_msm8x60,代码行数:101,


示例16: pixcir_probe

static int pixcir_probe(struct usb_interface *intf, const struct usb_device_id *id){	struct usb_host_interface *interface = intf->cur_altsetting;	struct usb_device *dev = interface_to_usbdev(intf);	struct input_dev *input_dev1;	int n = 0, insize = TOUCH_PACKAGE_LEN;	int err; 	const char *path; 	int  len; 	char input_buf[10];	 	struct pixcir_mt_usb *psmt = kzalloc(sizeof(struct pixcir_mt_usb), GFP_KERNEL);	kref_init(&psmt->kref);	mutex_init(&psmt->io_mutex);	  	printk("%s/n", __FUNCTION__);	psmt->type = &type;	psmt->udev = dev;	if (dev->manufacturer)    strlcpy(psmt->name, dev->manufacturer, sizeof(psmt->name));	if (dev->product) {    if (dev->manufacturer)      strlcat(psmt->name, " ", sizeof(psmt->name));    strlcat(psmt->name, dev->product, sizeof(psmt->name));	}	if (!strlen(psmt->name))    snprintf(psmt->name, sizeof(psmt->name), "USB Touchscreen %04x:%04x", le16_to_cpu(dev->descriptor.idVendor), le16_to_cpu(dev->descriptor.idProduct));	if (!psmt->type->process_pkt) {    printk("process_pkt is null/n");    psmt->type->process_pkt = usbtouch_process_pkt; 	}	usb_set_intfdata(intf, psmt);		err = usb_register_dev(intf,&pixcir_class_driver);	if(err){		printk("Not able to get minor for this device.");	}	dev_info(&intf->dev,"now attach to USB-%d",intf->minor);		input_dev1 = input_allocate_device();	input_dev1->name = "pixcir_usb_ts";	usb_to_input_id(dev, &input_dev1->id);	psmt->input_dev = input_dev1;	if(!psmt|| !input_dev1) {    printk("Memory is not enough/n");    goto fail1;	}	input_dev1->dev.parent = &intf->dev;	input_set_drvdata(input_dev1, psmt);	set_bit(EV_SYN, input_dev1->evbit);	set_bit(EV_KEY, input_dev1->evbit);	set_bit(EV_ABS, input_dev1->evbit);	set_bit(BTN_TOUCH, input_dev1->keybit);	input_set_abs_params(input_dev1, ABS_X, psmt->type->min_xc, psmt->type->max_xc, 0, 0);	input_set_abs_params(input_dev1, ABS_Y, psmt->type->min_yc, psmt->type->max_yc, 0, 0);	input_set_abs_params(input_dev1, ABS_MT_POSITION_X, psmt->type->min_xc, psmt->type->max_xc, 0, 0);	input_set_abs_params(input_dev1, ABS_MT_POSITION_Y, psmt->type->min_yc, psmt->type->max_yc, 0, 0);  input_set_abs_params(input_dev1, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);  input_set_abs_params(input_dev1, ABS_MT_WIDTH_MAJOR, 0, 25, 0, 0);  psmt->data = usb_alloc_coherent(dev, insize, GFP_KERNEL, &psmt->data_dma);  if(!psmt->data) {    printk("psmt->data allocating fail");    goto fail;  }  for (n = 0; n < interface->desc.bNumEndpoints; n++) {    struct usb_endpoint_descriptor *endpoint;    int pipe;    int interval;    endpoint = &interface->endpoint[n].desc;		/*find a int endpoint*/    if (!usb_endpoint_xfer_int(endpoint))                   continue;    interval = endpoint->bInterval;    if (usb_endpoint_dir_in(endpoint)) {      if (psmt->urb)        continue;      if (!(psmt->urb = usb_alloc_urb(0, GFP_KERNEL)))        goto fail;      pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);      usb_fill_int_urb(psmt->urb, dev, pipe, psmt->data, insize, pixcir_mt_irq, psmt, interval);      psmt->urb->transfer_dma = psmt->data_dma;//.........这里部分代码省略.........
开发者ID:unixjazz,项目名称:linux-mixtile,代码行数:101,


示例17: iguanair_probe

static int __devinit iguanair_probe(struct usb_interface *intf,						const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev(intf);	struct iguanair *ir;	struct rc_dev *rc;	int ret, pipein, pipeout;	struct usb_host_interface *idesc;	ir = kzalloc(sizeof(*ir), GFP_KERNEL);	rc = rc_allocate_device();	if (!ir || !rc) {		ret = -ENOMEM;		goto out;	}	ir->buf_in = usb_alloc_coherent(udev, MAX_IN_PACKET, GFP_KERNEL,								&ir->dma_in);	ir->packet = usb_alloc_coherent(udev, MAX_OUT_PACKET, GFP_KERNEL,								&ir->dma_out);	ir->urb_in = usb_alloc_urb(0, GFP_KERNEL);	ir->urb_out = usb_alloc_urb(0, GFP_KERNEL);	if (!ir->buf_in || !ir->packet || !ir->urb_in || !ir->urb_out) {		ret = -ENOMEM;		goto out;	}	idesc = intf->altsetting;	if (idesc->desc.bNumEndpoints < 2) {		ret = -ENODEV;		goto out;	}	ir->rc = rc;	ir->dev = &intf->dev;	ir->udev = udev;	mutex_init(&ir->lock);	init_completion(&ir->completion);	pipeout = usb_sndintpipe(udev,				idesc->endpoint[1].desc.bEndpointAddress);	usb_fill_int_urb(ir->urb_out, udev, pipeout, ir->packet, MAX_OUT_PACKET,						iguanair_irq_out, ir, 1);	ir->urb_out->transfer_dma = ir->dma_out;	ir->urb_out->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;	pipein = usb_rcvintpipe(udev, idesc->endpoint[0].desc.bEndpointAddress);	usb_fill_int_urb(ir->urb_in, udev, pipein, ir->buf_in, MAX_IN_PACKET,							 iguanair_rx, ir, 1);	ir->urb_in->transfer_dma = ir->dma_in;	ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;	ret = usb_submit_urb(ir->urb_in, GFP_KERNEL);	if (ret) {		dev_warn(&intf->dev, "failed to submit urb: %d/n", ret);		goto out;	}	ret = iguanair_get_features(ir);	if (ret)		goto out2;	snprintf(ir->name, sizeof(ir->name),		"IguanaWorks USB IR Transceiver version 0x%04x", ir->version);	usb_make_path(ir->udev, ir->phys, sizeof(ir->phys));	rc->input_name = ir->name;	rc->input_phys = ir->phys;	usb_to_input_id(ir->udev, &rc->input_id);	rc->dev.parent = &intf->dev;	rc->driver_type = RC_DRIVER_IR_RAW;	rc->allowed_protos = RC_BIT_ALL;	rc->priv = ir;	rc->open = iguanair_open;	rc->close = iguanair_close;	rc->s_tx_mask = iguanair_set_tx_mask;	rc->s_tx_carrier = iguanair_set_tx_carrier;	rc->tx_ir = iguanair_tx;	rc->driver_name = DRIVER_NAME;	rc->map_name = RC_MAP_RC6_MCE;	rc->timeout = MS_TO_NS(100);	rc->rx_resolution = RX_RESOLUTION;	iguanair_set_tx_carrier(rc, 38000);	ret = rc_register_device(rc);	if (ret < 0) {		dev_err(&intf->dev, "failed to register rc device %d", ret);		goto out2;	}	usb_set_intfdata(intf, ir);	return 0;out2:	usb_kill_urb(ir->urb_in);	usb_kill_urb(ir->urb_out);//.........这里部分代码省略.........
开发者ID:Forzaferrarileo,项目名称:linux,代码行数:101,


示例18: 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;	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:513855417,项目名称:linux,代码行数:69,


示例19: onetouch_connect_input

int onetouch_connect_input(struct us_data *ss){	struct usb_device *udev = ss->pusb_dev;	struct usb_host_interface *interface;	struct usb_endpoint_descriptor *endpoint;	struct usb_onetouch *onetouch;	struct input_dev *input_dev;	int pipe, maxp;	int error = -ENOMEM;	interface = ss->pusb_intf->cur_altsetting;	if (interface->desc.bNumEndpoints != 3)		return -ENODEV;	endpoint = &interface->endpoint[2].desc;	if (!usb_endpoint_is_int_in(endpoint))		return -ENODEV;	pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress);	maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));	onetouch = kzalloc(sizeof(struct usb_onetouch), GFP_KERNEL);	input_dev = input_allocate_device();	if (!onetouch || !input_dev)		goto fail1;	onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN,					  GFP_ATOMIC, &onetouch->data_dma);	if (!onetouch->data)		goto fail1;	onetouch->irq = usb_alloc_urb(0, GFP_KERNEL);	if (!onetouch->irq)		goto fail2;	onetouch->udev = udev;	onetouch->dev = input_dev;	if (udev->manufacturer)		strlcpy(onetouch->name, udev->manufacturer,			sizeof(onetouch->name));	if (udev->product) {		if (udev->manufacturer)			strlcat(onetouch->name, " ", sizeof(onetouch->name));		strlcat(onetouch->name, udev->product, sizeof(onetouch->name));	}	if (!strlen(onetouch->name))		snprintf(onetouch->name, sizeof(onetouch->name),			 "Maxtor Onetouch %04x:%04x",			 le16_to_cpu(udev->descriptor.idVendor),			 le16_to_cpu(udev->descriptor.idProduct));	usb_make_path(udev, onetouch->phys, sizeof(onetouch->phys));	strlcat(onetouch->phys, "/input0", sizeof(onetouch->phys));	input_dev->name = onetouch->name;	input_dev->phys = onetouch->phys;	usb_to_input_id(udev, &input_dev->id);	input_dev->dev.parent = &udev->dev;	set_bit(EV_KEY, input_dev->evbit);	set_bit(ONETOUCH_BUTTON, input_dev->keybit);	clear_bit(0, input_dev->keybit);	input_set_drvdata(input_dev, onetouch);	input_dev->open = usb_onetouch_open;	input_dev->close = usb_onetouch_close;	usb_fill_int_urb(onetouch->irq, udev, pipe, onetouch->data,			 (maxp > 8 ? 8 : maxp),			 usb_onetouch_irq, onetouch, endpoint->bInterval);	onetouch->irq->transfer_dma = onetouch->data_dma;	onetouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;	ss->extra_destructor = onetouch_release_input;	ss->extra = onetouch;#ifdef CONFIG_PM	ss->suspend_resume_hook = usb_onetouch_pm_hook;#endif	error = input_register_device(onetouch->dev);	if (error)		goto fail3;	return 0; fail3:	usb_free_urb(onetouch->irq); fail2:	usb_buffer_free(udev, ONETOUCH_PKT_LEN,			onetouch->data, onetouch->data_dma); fail1:	kfree(onetouch);	input_free_device(input_dev);	return error;}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:96,


示例20: 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_host_interface *interface = intf->cur_altsetting;	struct usb_endpoint_descriptor *endpoint;	struct wacom *wacom;	struct wacom_wac *wacom_wac;	struct wacom_features *features;	struct input_dev *input_dev;	int error = -ENOMEM;	char rep_data[2], limit = 0;	struct hid_descriptor *hid_desc;	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)		goto fail1;	wacom_wac->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma);	if (!wacom_wac->data)		goto fail1;	wacom->irq = usb_alloc_urb(0, GFP_KERNEL);	if (!wacom->irq)		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));	wacom_wac->features = features = get_wacom_feature(id);	BUG_ON(features->pktlen > 10);	input_dev->name = wacom_wac->features->name;	wacom->wacom_wac = wacom_wac;	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;	/* Initialize touch_x_max and touch_y_max in case it is not defined */	if (wacom_wac->features->type == TABLETPC) {		features->touch_x_max = 1023;		features->touch_y_max = 1023;	} else {		features->touch_x_max = 0;		features->touch_y_max = 0;	}	/* TabletPC need to retrieve the physical and logical maximum from report descriptor */	if (wacom_wac->features->type == TABLETPC) {		if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) {			if (usb_get_extra_descriptor(&interface->endpoint[0],						     HID_DEVICET_REPORT, &hid_desc)) {				printk("wacom: can not retrive extra class descriptor/n");				goto fail2;			}		}		error = wacom_parse_hid(intf, hid_desc, wacom_wac);		if (error)			goto fail2;	}	input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);	input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_PEN) |		BIT_MASK(BTN_TOUCH) | BIT_MASK(BTN_STYLUS);	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);	if (features->type == TABLETPC) {		input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_DOUBLETAP);		input_set_abs_params(input_dev, ABS_RX, 0, features->touch_x_max, 4, 0);		input_set_abs_params(input_dev, ABS_RY, 0, features->touch_y_max, 4, 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, wacom_wac->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;	/*//.........这里部分代码省略.........
开发者ID:ClarkChen633,项目名称:rtl819x-toolchain,代码行数:101,


示例21: 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;	__set_bit(EV_KEY, input_dev->evbit);	if (!(xpad->mapping & MAP_STICKS_TO_NULL)) {		__set_bit(EV_ABS, input_dev->evbit);		/* 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]);	}	error = xpad_init_ff(xpad);	if (error)		goto err_free_input;	error = xpad_led_probe(xpad);	if (error)		goto err_destroy_ff;	error = input_register_device(xpad->dev);	if (error)		goto err_disconnect_led;	return 0;err_disconnect_led:	xpad_led_disconnect(xpad);err_destroy_ff:	input_ff_destroy(input_dev);err_free_input:	input_free_device(input_dev);	return error;}
开发者ID:BORETS24,项目名称:common.git-android-4.4,代码行数:90,


示例22: usb_mouse_probe

/*  * 驱动程序的探测函数  */static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_id *id){	/*  	 * 接口结构体包含于设备结构体中,interface_to_usbdev 是通过接口结构体获得它的设备结构体。 	 * usb_host_interface 是用于描述接口设置的结构体,内嵌在接口结构体 usb_interface 中。 	 * usb_endpoint_descriptor 是端点描述符结构体,内嵌在端点结构体 usb_host_endpoint 中,而端点 	 * 结构体内嵌在接口设置结构体中。 	 */	struct usb_device *dev = interface_to_usbdev(intf);	struct usb_host_interface *interface;	struct usb_endpoint_descriptor *endpoint;	struct usb_mouse *mouse;	struct input_dev *input_dev;	int pipe, maxp;	interface = intf->cur_altsetting;	/* 鼠标仅有一个 interrupt 类型的 in 端点,不满足此要求的设备均报错 */	if (interface->desc.bNumEndpoints != 1)		return -ENODEV;	endpoint = &interface->endpoint[0].desc;	if (!usb_endpoint_is_int_in(endpoint))		return -ENODEV;	/* 	 * 返回对应端点能够传输的最大的数据包,鼠标的返回的最大数据包为4个字节,数据包具体内容在 urb 	 * 回调函数中有详细说明。 	 */	pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);	maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));	/* 为 mouse 设备结构体分配内存 */	mouse = kzalloc(sizeof(struct usb_mouse), GFP_KERNEL);	/* input_dev */	input_dev = input_allocate_device();	if (!mouse || !input_dev)		goto fail1;	/* 	 * 申请内存空间用于数据传输,data 为指向该空间的地址,data_dma 则是这块内存空间的 dma 映射, 	 * 即这块内存空间对应的 dma 地址。在使用 dma 传输的情况下,则使用 data_dma 指向的 dma 区域, 	 * 否则使用 data 指向的普通内存区域进行传输。 	 * GFP_ATOMIC 表示不等待,GFP_KERNEL 是普通的优先级,可以睡眠等待,由于鼠标使用中断传输方式, 	 * 不允许睡眠状态,data 又是周期性获取鼠标事件的存储区,因此使用 GFP_ATOMIC 优先级,如果不能 	 * 分配到内存则立即返回 0。 	 */	mouse->data = usb_alloc_coherent(dev, 8, GFP_ATOMIC, &mouse->data_dma);	if (!mouse->data)		goto fail1;	/* 	 * 为 urb 结构体申请内存空间,第一个参数表示等时传输时需要传送包的数量,其它传输方式则为0。 	 * 申请的内存将通过下面即将见到的 usb_fill_int_urb 函数进行填充。  	 */	mouse->irq = usb_alloc_urb(0, GFP_KERNEL);	if (!mouse->irq)		goto fail2;	/* 填充 usb 设备结构体和输入设备结构体 */	mouse->usbdev = dev;	mouse->dev = input_dev;	/* 获取鼠标设备的名称 */	if (dev->manufacturer)		strlcpy(mouse->name, dev->manufacturer, sizeof(mouse->name));	if (dev->product) {		if (dev->manufacturer)			strlcat(mouse->name, " ", sizeof(mouse->name));		strlcat(mouse->name, dev->product, sizeof(mouse->name));	}	if (!strlen(mouse->name))		snprintf(mouse->name, sizeof(mouse->name),			 "USB HIDBP Mouse %04x:%04x",			 le16_to_cpu(dev->descriptor.idVendor),			 le16_to_cpu(dev->descriptor.idProduct));	/* 	 * 填充鼠标设备结构体中的节点名。usb_make_path 用来获取 USB 设备在 Sysfs 中的路径,格式 	 * 为:usb-usb 总线号-路径名。 	 */	usb_make_path(dev, mouse->phys, sizeof(mouse->phys));	strlcat(mouse->phys, "/input0", sizeof(mouse->phys));	/* 将鼠标设备的名称赋给鼠标设备内嵌的输入子系统结构体 */	input_dev->name = mouse->name;	/* 将鼠标设备的设备节点名赋给鼠标设备内嵌的输入子系统结构体 */	input_dev->phys = mouse->phys;	/* 	 * input_dev 中的 input_id 结构体,用来存储厂商、设备类型和设备的编号,这个函数是将设备描述符 	 * 中的编号赋给内嵌的输入子系统结构体 	 */	usb_to_input_id(dev, &input_dev->id);	/* cdev 是设备所属类别(class device) */	input_dev->cdev.dev = &intf->dev;//.........这里部分代码省略.........
开发者ID:zenglg,项目名称:learning,代码行数:101,


示例23: snd_usb_caiaq_input_init

int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev){	struct usb_device *usb_dev = dev->chip.dev;	struct input_dev *input;	int i, ret;	input = input_allocate_device();	if (!input)		return -ENOMEM;	usb_make_path(usb_dev, dev->phys, sizeof(dev->phys));	strlcat(dev->phys, "/input0", sizeof(dev->phys));	input->name = dev->product_name;	input->phys = dev->phys;	usb_to_input_id(usb_dev, &input->id);	input->dev.parent = &usb_dev->dev;        switch (dev->chip.usb_id) {	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):		input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);		input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |			BIT_MASK(ABS_Z);		BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk2));		memcpy(dev->keycode, keycode_rk2, sizeof(keycode_rk2));		input->keycodemax = ARRAY_SIZE(keycode_rk2);		input_set_abs_params(input, ABS_X, 0, 4096, 0, 10);		input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10);		input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10);		snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0);		break;	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):		input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);		input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |			BIT_MASK(ABS_Z);		BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk3));		memcpy(dev->keycode, keycode_rk3, sizeof(keycode_rk3));		input->keycodemax = ARRAY_SIZE(keycode_rk3);		input_set_abs_params(input, ABS_X, 0, 1024, 0, 10);		input_set_abs_params(input, ABS_Y, 0, 1024, 0, 10);		input_set_abs_params(input, ABS_Z, 0, 1024, 0, 10);		snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0);		break;	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):		input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);		input->absbit[0] = BIT_MASK(ABS_X);		BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_ak1));		memcpy(dev->keycode, keycode_ak1, sizeof(keycode_ak1));		input->keycodemax = ARRAY_SIZE(keycode_ak1);		input_set_abs_params(input, ABS_X, 0, 999, 0, 10);		snd_usb_caiaq_set_auto_msg(dev, 1, 0, 5);		break;	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):		input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);		input->absbit[0] = BIT_MASK(ABS_HAT0X) | BIT_MASK(ABS_HAT0Y) |				   BIT_MASK(ABS_HAT1X) | BIT_MASK(ABS_HAT1Y) |				   BIT_MASK(ABS_HAT2X) | BIT_MASK(ABS_HAT2Y) |				   BIT_MASK(ABS_HAT3X) | BIT_MASK(ABS_HAT3Y) |				   BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) |				   BIT_MASK(ABS_Z);		input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);		BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_kore));		memcpy(dev->keycode, keycode_kore, sizeof(keycode_kore));		input->keycodemax = ARRAY_SIZE(keycode_kore);		input_set_abs_params(input, ABS_HAT0X, 0, 999, 0, 10);		input_set_abs_params(input, ABS_HAT0Y, 0, 999, 0, 10);		input_set_abs_params(input, ABS_HAT1X, 0, 999, 0, 10);		input_set_abs_params(input, ABS_HAT1Y, 0, 999, 0, 10);		input_set_abs_params(input, ABS_HAT2X, 0, 999, 0, 10);		input_set_abs_params(input, ABS_HAT2Y, 0, 999, 0, 10);		input_set_abs_params(input, ABS_HAT3X, 0, 999, 0, 10);		input_set_abs_params(input, ABS_HAT3Y, 0, 999, 0, 10);		input_set_abs_params(input, ABS_X, 0, 4096, 0, 10);		input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10);		input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10);		input_set_abs_params(input, ABS_MISC, 0, 255, 0, 1);		snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5);		break;	default:		/* no input methods supported on this device */		input_free_device(input);		return 0;	}	input->keycode = dev->keycode;	input->keycodesize = sizeof(unsigned short);	for (i = 0; i < input->keycodemax; i++)		__set_bit(dev->keycode[i], input->keybit);	ret = input_register_device(input);	if (ret < 0) {		input_free_device(input);		return ret;	}	dev->input_dev = input;	return 0;}
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:99,


示例24: 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,


示例25: iguanair_probe

static int __devinit iguanair_probe(struct usb_interface *intf,						const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev(intf);	struct iguanair *ir;	struct rc_dev *rc;	int ret;	struct usb_host_interface *idesc;	ir = kzalloc(sizeof(*ir), GFP_KERNEL);	rc = rc_allocate_device();	if (!ir || !rc) {		ret = ENOMEM;		goto out;	}	ir->buf_in = usb_alloc_coherent(udev, MAX_PACKET_SIZE, GFP_ATOMIC,								&ir->dma_in);	ir->urb_in = usb_alloc_urb(0, GFP_KERNEL);	if (!ir->buf_in || !ir->urb_in) {		ret = ENOMEM;		goto out;	}	idesc = intf->altsetting;	if (idesc->desc.bNumEndpoints < 2) {		ret = -ENODEV;		goto out;	}	ir->rc = rc;	ir->dev = &intf->dev;	ir->udev = udev;	ir->pipe_in = usb_rcvintpipe(udev,				idesc->endpoint[0].desc.bEndpointAddress);	ir->pipe_out = usb_sndintpipe(udev,				idesc->endpoint[1].desc.bEndpointAddress);	mutex_init(&ir->lock);	init_completion(&ir->completion);	ret = iguanair_get_features(ir);	if (ret) {		dev_warn(&intf->dev, "failed to get device features");		goto out;	}	usb_fill_int_urb(ir->urb_in, ir->udev, ir->pipe_in, ir->buf_in,		MAX_PACKET_SIZE, iguanair_rx, ir,		idesc->endpoint[0].desc.bInterval);	ir->urb_in->transfer_dma = ir->dma_in;	ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;	snprintf(ir->name, sizeof(ir->name),		"IguanaWorks USB IR Transceiver version %d.%d",		ir->version[0], ir->version[1]);	usb_make_path(ir->udev, ir->phys, sizeof(ir->phys));	rc->input_name = ir->name;	rc->input_phys = ir->phys;	usb_to_input_id(ir->udev, &rc->input_id);	rc->dev.parent = &intf->dev;	rc->driver_type = RC_DRIVER_IR_RAW;	rc->allowed_protos = RC_TYPE_ALL;	rc->priv = ir;	rc->open = iguanair_open;	rc->close = iguanair_close;	rc->s_tx_mask = iguanair_set_tx_mask;	rc->s_tx_carrier = iguanair_set_tx_carrier;	rc->tx_ir = iguanair_tx;	rc->driver_name = DRIVER_NAME;	rc->map_name = RC_MAP_EMPTY;	iguanair_set_tx_carrier(rc, 38000);	ret = rc_register_device(rc);	if (ret < 0) {		dev_err(&intf->dev, "failed to register rc device %d", ret);		goto out;	}	usb_set_intfdata(intf, ir);	dev_info(&intf->dev, "Registered %s", ir->name);	return 0;out:	if (ir) {		usb_free_urb(ir->urb_in);		usb_free_coherent(udev, MAX_PACKET_SIZE, ir->buf_in,								ir->dma_in);	}	rc_free_device(rc);	kfree(ir);	return ret;}
开发者ID:ARMWorks,项目名称:FA_2451_Linux_Kernel,代码行数:98,


示例26: dvb_usbv2_remote_init

static int dvb_usbv2_remote_init(struct dvb_usb_device *d){	int ret;	struct rc_dev *dev;	dev_dbg(&d->udev->dev, "%s:/n", __func__);	if (dvb_usbv2_disable_rc_polling || !d->props->get_rc_config)		return 0;	d->rc.map_name = d->rc_map;	ret = d->props->get_rc_config(d, &d->rc);	if (ret < 0)		goto err;	/* disable rc when there is no keymap defined */	if (!d->rc.map_name)		return 0;	dev = rc_allocate_device();	if (!dev) {		ret = -ENOMEM;		goto err;	}	dev->dev.parent = &d->udev->dev;	dev->input_name = d->name;	usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys));	strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys));	dev->input_phys = d->rc_phys;	usb_to_input_id(d->udev, &dev->input_id);	/* TODO: likely RC-core should took const char * */	dev->driver_name = (char *) d->props->driver_name;	dev->map_name = d->rc.map_name;	dev->driver_type = d->rc.driver_type;	dev->allowed_protocols = d->rc.allowed_protos;	dev->change_protocol = d->rc.change_protocol;	dev->priv = d;	ret = rc_register_device(dev);	if (ret < 0) {		rc_free_device(dev);		goto err;	}	d->rc_dev = dev;	/* start polling if needed */	if (d->rc.query && !d->rc.bulk_mode) {		/* initialize a work queue for handling polling */		INIT_DELAYED_WORK(&d->rc_query_work,				dvb_usb_read_remote_control);		dev_info(&d->udev->dev,				"%s: schedule remote query interval to %d msecs/n",				KBUILD_MODNAME, d->rc.interval);		schedule_delayed_work(&d->rc_query_work,				msecs_to_jiffies(d->rc.interval));		d->rc_polling_active = true;	}	return 0;err:	dev_dbg(&d->udev->dev, "%s: failed=%d/n", __func__, ret);	return ret;}
开发者ID:adbensi,项目名称:kernel-odroidc-3.10.80-rt102,代码行数:64,


示例27: usb_pwc_probe

//.........这里部分代码省略.........	pdev->release = le16_to_cpu(udev->descriptor.bcdDevice);	PWC_DEBUG_PROBE("Release: %04x/n", pdev->release);	/* Allocate USB command buffers */	pdev->ctrl_buf = kmalloc(sizeof(pdev->cmd_buf), GFP_KERNEL);	if (!pdev->ctrl_buf) {		PWC_ERROR("Oops, could not allocate memory for pwc_device./n");		rc = -ENOMEM;		goto err_free_mem;	}#ifdef CONFIG_USB_PWC_DEBUG	/* Query sensor type */	if (pwc_get_cmos_sensor(pdev, &rc) >= 0) {		PWC_DEBUG_OPEN("This %s camera is equipped with a %s (%d)./n",				pdev->vdev.name,				pwc_sensor_type_to_string(rc), rc);	}#endif	/* Set the leds off */	pwc_set_leds(pdev, 0, 0);	/* Setup initial videomode */	rc = pwc_set_video_mode(pdev, MAX_WIDTH, MAX_HEIGHT,				V4L2_PIX_FMT_YUV420, 30, &compression, 1);	if (rc)		goto err_free_mem;	/* Register controls (and read default values from camera */	rc = pwc_init_controls(pdev);	if (rc) {		PWC_ERROR("Failed to register v4l2 controls (%d)./n", rc);		goto err_free_mem;	}	/* And powerdown the camera until streaming starts */	pwc_camera_power(pdev, 0);	/* Register the v4l2_device structure */	pdev->v4l2_dev.release = pwc_video_release;	rc = v4l2_device_register(&intf->dev, &pdev->v4l2_dev);	if (rc) {		PWC_ERROR("Failed to register v4l2-device (%d)./n", rc);		goto err_free_controls;	}	pdev->v4l2_dev.ctrl_handler = &pdev->ctrl_handler;	pdev->vdev.v4l2_dev = &pdev->v4l2_dev;	pdev->vdev.lock = &pdev->v4l2_lock;	rc = video_register_device(&pdev->vdev, VFL_TYPE_GRABBER, -1);	if (rc < 0) {		PWC_ERROR("Failed to register as video device (%d)./n", rc);		goto err_unregister_v4l2_dev;	}	PWC_INFO("Registered as %s./n", video_device_node_name(&pdev->vdev));#ifdef CONFIG_USB_PWC_INPUT_EVDEV	/* register webcam snapshot button input device */	pdev->button_dev = input_allocate_device();	if (!pdev->button_dev) {		rc = -ENOMEM;		goto err_video_unreg;	}	usb_make_path(udev, pdev->button_phys, sizeof(pdev->button_phys));	strlcat(pdev->button_phys, "/input0", sizeof(pdev->button_phys));	pdev->button_dev->name = "PWC snapshot button";	pdev->button_dev->phys = pdev->button_phys;	usb_to_input_id(pdev->udev, &pdev->button_dev->id);	pdev->button_dev->dev.parent = &pdev->udev->dev;	pdev->button_dev->evbit[0] = BIT_MASK(EV_KEY);	pdev->button_dev->keybit[BIT_WORD(KEY_CAMERA)] = BIT_MASK(KEY_CAMERA);	rc = input_register_device(pdev->button_dev);	if (rc) {		input_free_device(pdev->button_dev);		pdev->button_dev = NULL;		goto err_video_unreg;	}#endif	return 0;#ifdef CONFIG_USB_PWC_INPUT_EVDEVerr_video_unreg:	video_unregister_device(&pdev->vdev);#endiferr_unregister_v4l2_dev:	v4l2_device_unregister(&pdev->v4l2_dev);err_free_controls:	v4l2_ctrl_handler_free(&pdev->ctrl_handler);err_free_mem:	kfree(pdev->ctrl_buf);	kfree(pdev);	return rc;}
开发者ID:AK101111,项目名称:linux,代码行数:101,



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


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