Lines Matching +full:pen +full:- +full:up
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Pegasus Mobile Notetaker Pen input tablet driver
10 * |-------------------------------------|
13 * |-------------------------------------|
15 * |-------------------------------------|
18 * and pen is in range:
21 * --------------------------------------------
35 * S Switch 1 (pen button)
100 return -ENOMEM; in pegasus_control_msg()
106 result = usb_control_msg(pegasus->usbdev, in pegasus_control_msg()
107 usb_sndctrlpipe(pegasus->usbdev, 0), in pegasus_control_msg()
116 error = result < 0 ? result : -EIO; in pegasus_control_msg()
117 dev_err(&pegasus->usbdev->dev, "control msg error: %d\n", in pegasus_control_msg()
134 unsigned char *data = pegasus->data; in pegasus_parse_packet()
135 struct input_dev *dev = pegasus->dev; in pegasus_parse_packet()
142 schedule_work(&pegasus->init); in pegasus_parse_packet()
148 dev_warn_once(&dev->dev, "Pen battery low\n"); in pegasus_parse_packet()
156 /* pen-up event */ in pegasus_parse_packet()
170 dev_warn_once(&pegasus->usbdev->dev, in pegasus_parse_packet()
177 struct pegasus *pegasus = urb->context; in pegasus_irq()
178 struct usb_device *dev = pegasus->usbdev; in pegasus_irq()
181 switch (urb->status) { in pegasus_irq()
184 usb_mark_last_busy(pegasus->usbdev); in pegasus_irq()
187 case -ECONNRESET: in pegasus_irq()
188 case -ENOENT: in pegasus_irq()
189 case -ESHUTDOWN: in pegasus_irq()
190 dev_err(&dev->dev, "%s - urb shutting down with status: %d", in pegasus_irq()
191 __func__, urb->status); in pegasus_irq()
195 dev_err(&dev->dev, "%s - nonzero urb status received: %d", in pegasus_irq()
196 __func__, urb->status); in pegasus_irq()
202 dev_err(&dev->dev, "%s - usb_submit_urb failed with result %d", in pegasus_irq()
213 dev_err(&pegasus->usbdev->dev, "pegasus_set_mode error: %d\n", in pegasus_init()
222 error = usb_autopm_get_interface(pegasus->intf); in pegasus_open()
226 mutex_lock(&pegasus->pm_mutex); in pegasus_open()
227 pegasus->irq->dev = pegasus->usbdev; in pegasus_open()
228 if (usb_submit_urb(pegasus->irq, GFP_KERNEL)) { in pegasus_open()
229 error = -EIO; in pegasus_open()
237 pegasus->is_open = true; in pegasus_open()
238 mutex_unlock(&pegasus->pm_mutex); in pegasus_open()
242 usb_kill_urb(pegasus->irq); in pegasus_open()
243 cancel_work_sync(&pegasus->init); in pegasus_open()
245 mutex_unlock(&pegasus->pm_mutex); in pegasus_open()
246 usb_autopm_put_interface(pegasus->intf); in pegasus_open()
254 mutex_lock(&pegasus->pm_mutex); in pegasus_close()
255 usb_kill_urb(pegasus->irq); in pegasus_close()
256 cancel_work_sync(&pegasus->init); in pegasus_close()
257 pegasus->is_open = false; in pegasus_close()
258 mutex_unlock(&pegasus->pm_mutex); in pegasus_close()
260 usb_autopm_put_interface(pegasus->intf); in pegasus_close()
274 if (intf->cur_altsetting->desc.bInterfaceNumber >= 1) in pegasus_probe()
275 return -ENODEV; in pegasus_probe()
278 if (intf->cur_altsetting->desc.bNumEndpoints < 1) { in pegasus_probe()
279 dev_err(&intf->dev, "Invalid number of endpoints\n"); in pegasus_probe()
280 return -EINVAL; in pegasus_probe()
283 endpoint = &intf->cur_altsetting->endpoint[0].desc; in pegasus_probe()
288 error = -ENOMEM; in pegasus_probe()
292 mutex_init(&pegasus->pm_mutex); in pegasus_probe()
294 pegasus->usbdev = dev; in pegasus_probe()
295 pegasus->dev = input_dev; in pegasus_probe()
296 pegasus->intf = intf; in pegasus_probe()
298 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); in pegasus_probe()
301 error = -EINVAL; in pegasus_probe()
305 pegasus->data_len = usb_maxpacket(dev, pipe); in pegasus_probe()
307 pegasus->data = usb_alloc_coherent(dev, pegasus->data_len, GFP_KERNEL, in pegasus_probe()
308 &pegasus->data_dma); in pegasus_probe()
309 if (!pegasus->data) { in pegasus_probe()
310 error = -ENOMEM; in pegasus_probe()
314 pegasus->irq = usb_alloc_urb(0, GFP_KERNEL); in pegasus_probe()
315 if (!pegasus->irq) { in pegasus_probe()
316 error = -ENOMEM; in pegasus_probe()
320 usb_fill_int_urb(pegasus->irq, dev, pipe, in pegasus_probe()
321 pegasus->data, pegasus->data_len, in pegasus_probe()
322 pegasus_irq, pegasus, endpoint->bInterval); in pegasus_probe()
324 pegasus->irq->transfer_dma = pegasus->data_dma; in pegasus_probe()
325 pegasus->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in pegasus_probe()
327 if (dev->manufacturer) in pegasus_probe()
328 strscpy(pegasus->name, dev->manufacturer, in pegasus_probe()
329 sizeof(pegasus->name)); in pegasus_probe()
331 if (dev->product) { in pegasus_probe()
332 if (dev->manufacturer) in pegasus_probe()
333 strlcat(pegasus->name, " ", sizeof(pegasus->name)); in pegasus_probe()
334 strlcat(pegasus->name, dev->product, sizeof(pegasus->name)); in pegasus_probe()
337 if (!strlen(pegasus->name)) in pegasus_probe()
338 snprintf(pegasus->name, sizeof(pegasus->name), in pegasus_probe()
340 le16_to_cpu(dev->descriptor.idVendor), in pegasus_probe()
341 le16_to_cpu(dev->descriptor.idProduct)); in pegasus_probe()
343 usb_make_path(dev, pegasus->phys, sizeof(pegasus->phys)); in pegasus_probe()
344 strlcat(pegasus->phys, "/input0", sizeof(pegasus->phys)); in pegasus_probe()
346 INIT_WORK(&pegasus->init, pegasus_init); in pegasus_probe()
350 input_dev->name = pegasus->name; in pegasus_probe()
351 input_dev->phys = pegasus->phys; in pegasus_probe()
352 usb_to_input_id(dev, &input_dev->id); in pegasus_probe()
353 input_dev->dev.parent = &intf->dev; in pegasus_probe()
357 input_dev->open = pegasus_open; in pegasus_probe()
358 input_dev->close = pegasus_close; in pegasus_probe()
360 __set_bit(EV_ABS, input_dev->evbit); in pegasus_probe()
361 __set_bit(EV_KEY, input_dev->evbit); in pegasus_probe()
363 __set_bit(ABS_X, input_dev->absbit); in pegasus_probe()
364 __set_bit(ABS_Y, input_dev->absbit); in pegasus_probe()
366 __set_bit(BTN_TOUCH, input_dev->keybit); in pegasus_probe()
367 __set_bit(BTN_RIGHT, input_dev->keybit); in pegasus_probe()
368 __set_bit(BTN_TOOL_PEN, input_dev->keybit); in pegasus_probe()
370 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); in pegasus_probe()
371 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); in pegasus_probe()
373 input_set_abs_params(input_dev, ABS_X, -1500, 1500, 8, 0); in pegasus_probe()
376 error = input_register_device(pegasus->dev); in pegasus_probe()
383 usb_free_urb(pegasus->irq); in pegasus_probe()
385 usb_free_coherent(dev, pegasus->data_len, in pegasus_probe()
386 pegasus->data, pegasus->data_dma); in pegasus_probe()
399 input_unregister_device(pegasus->dev); in pegasus_disconnect()
401 usb_free_urb(pegasus->irq); in pegasus_disconnect()
403 pegasus->data_len, pegasus->data, in pegasus_disconnect()
404 pegasus->data_dma); in pegasus_disconnect()
414 mutex_lock(&pegasus->pm_mutex); in pegasus_suspend()
415 usb_kill_urb(pegasus->irq); in pegasus_suspend()
416 cancel_work_sync(&pegasus->init); in pegasus_suspend()
417 mutex_unlock(&pegasus->pm_mutex); in pegasus_suspend()
427 mutex_lock(&pegasus->pm_mutex); in pegasus_resume()
428 if (pegasus->is_open && usb_submit_urb(pegasus->irq, GFP_NOIO) < 0) in pegasus_resume()
429 retval = -EIO; in pegasus_resume()
430 mutex_unlock(&pegasus->pm_mutex); in pegasus_resume()
440 mutex_lock(&pegasus->pm_mutex); in pegasus_reset_resume()
441 if (pegasus->is_open) { in pegasus_reset_resume()
444 if (!retval && usb_submit_urb(pegasus->irq, GFP_NOIO) < 0) in pegasus_reset_resume()
445 retval = -EIO; in pegasus_reset_resume()
447 mutex_unlock(&pegasus->pm_mutex); in pegasus_reset_resume()
473 MODULE_DESCRIPTION("Pegasus Mobile Notetaker Pen tablet driver");