Lines Matching +full:event +full:- +full:prox

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2001-2005 Edouard TISSERANT <edouard.tisserant@wanadoo.fr>
4 * Copyright (c) 2004-2005 Stephane VOLTZ <svoltz@numericable.fr>
9 * v3.2 - Added sysfs support
38 struct usb_acecad *acecad = urb->context; in usb_acecad_irq()
39 unsigned char *data = acecad->data; in usb_acecad_irq()
40 struct input_dev *dev = acecad->input; in usb_acecad_irq()
41 struct usb_interface *intf = acecad->intf; in usb_acecad_irq()
43 int prox, status; in usb_acecad_irq() local
45 switch (urb->status) { in usb_acecad_irq()
49 case -ECONNRESET: in usb_acecad_irq()
50 case -ENOENT: in usb_acecad_irq()
51 case -ESHUTDOWN: in usb_acecad_irq()
53 dev_dbg(&intf->dev, "%s - urb shutting down with status: %d\n", in usb_acecad_irq()
54 __func__, urb->status); in usb_acecad_irq()
57 dev_dbg(&intf->dev, "%s - nonzero urb status received: %d\n", in usb_acecad_irq()
58 __func__, urb->status); in usb_acecad_irq()
62 prox = (data[0] & 0x04) >> 2; in usb_acecad_irq()
63 input_report_key(dev, BTN_TOOL_PEN, prox); in usb_acecad_irq()
65 if (prox) { in usb_acecad_irq()
81 /* event termination */ in usb_acecad_irq()
87 dev_err(&intf->dev, in usb_acecad_irq()
88 "can't resubmit intr, %s-%s/input0, status %d\n", in usb_acecad_irq()
89 udev->bus->bus_name, in usb_acecad_irq()
90 udev->devpath, status); in usb_acecad_irq()
97 acecad->irq->dev = interface_to_usbdev(acecad->intf); in usb_acecad_open()
98 if (usb_submit_urb(acecad->irq, GFP_KERNEL)) in usb_acecad_open()
99 return -EIO; in usb_acecad_open()
108 usb_kill_urb(acecad->irq); in usb_acecad_close()
114 struct usb_host_interface *interface = intf->cur_altsetting; in usb_acecad_probe()
121 if (interface->desc.bNumEndpoints != 1) in usb_acecad_probe()
122 return -ENODEV; in usb_acecad_probe()
124 endpoint = &interface->endpoint[0].desc; in usb_acecad_probe()
127 return -ENODEV; in usb_acecad_probe()
129 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); in usb_acecad_probe()
135 err = -ENOMEM; in usb_acecad_probe()
139 acecad->data = usb_alloc_coherent(dev, 8, GFP_KERNEL, &acecad->data_dma); in usb_acecad_probe()
140 if (!acecad->data) { in usb_acecad_probe()
141 err= -ENOMEM; in usb_acecad_probe()
145 acecad->irq = usb_alloc_urb(0, GFP_KERNEL); in usb_acecad_probe()
146 if (!acecad->irq) { in usb_acecad_probe()
147 err = -ENOMEM; in usb_acecad_probe()
151 acecad->intf = intf; in usb_acecad_probe()
152 acecad->input = input_dev; in usb_acecad_probe()
154 if (dev->manufacturer) in usb_acecad_probe()
155 strscpy(acecad->name, dev->manufacturer, sizeof(acecad->name)); in usb_acecad_probe()
157 if (dev->product) { in usb_acecad_probe()
158 if (dev->manufacturer) in usb_acecad_probe()
159 strlcat(acecad->name, " ", sizeof(acecad->name)); in usb_acecad_probe()
160 strlcat(acecad->name, dev->product, sizeof(acecad->name)); in usb_acecad_probe()
163 usb_make_path(dev, acecad->phys, sizeof(acecad->phys)); in usb_acecad_probe()
164 strlcat(acecad->phys, "/input0", sizeof(acecad->phys)); in usb_acecad_probe()
166 input_dev->name = acecad->name; in usb_acecad_probe()
167 input_dev->phys = acecad->phys; in usb_acecad_probe()
168 usb_to_input_id(dev, &input_dev->id); in usb_acecad_probe()
169 input_dev->dev.parent = &intf->dev; in usb_acecad_probe()
173 input_dev->open = usb_acecad_open; in usb_acecad_probe()
174 input_dev->close = usb_acecad_close; in usb_acecad_probe()
176 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); in usb_acecad_probe()
177 input_dev->keybit[BIT_WORD(BTN_DIGI)] = BIT_MASK(BTN_TOOL_PEN) | in usb_acecad_probe()
181 switch (id->driver_info) { in usb_acecad_probe()
186 if (!strlen(acecad->name)) in usb_acecad_probe()
187 snprintf(acecad->name, sizeof(acecad->name), in usb_acecad_probe()
189 le16_to_cpu(dev->descriptor.idVendor), in usb_acecad_probe()
190 le16_to_cpu(dev->descriptor.idProduct)); in usb_acecad_probe()
197 if (!strlen(acecad->name)) in usb_acecad_probe()
198 snprintf(acecad->name, sizeof(acecad->name), in usb_acecad_probe()
200 le16_to_cpu(dev->descriptor.idVendor), in usb_acecad_probe()
201 le16_to_cpu(dev->descriptor.idProduct)); in usb_acecad_probe()
205 usb_fill_int_urb(acecad->irq, dev, pipe, in usb_acecad_probe()
206 acecad->data, maxp > 8 ? 8 : maxp, in usb_acecad_probe()
207 usb_acecad_irq, acecad, endpoint->bInterval); in usb_acecad_probe()
208 acecad->irq->transfer_dma = acecad->data_dma; in usb_acecad_probe()
209 acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in usb_acecad_probe()
211 err = input_register_device(acecad->input); in usb_acecad_probe()
219 fail3: usb_free_urb(acecad->irq); in usb_acecad_probe()
220 fail2: usb_free_coherent(dev, 8, acecad->data, acecad->data_dma); in usb_acecad_probe()
233 input_unregister_device(acecad->input); in usb_acecad_disconnect()
234 usb_free_urb(acecad->irq); in usb_acecad_disconnect()
235 usb_free_coherent(udev, 8, acecad->data, acecad->data_dma); in usb_acecad_disconnect()