Lines Matching +full:tablet +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Pegasus Mobile Notetaker Pen input tablet driver
10 * |-------------------------------------|
13 * |-------------------------------------|
15 * |-------------------------------------|
17 * data packet after set xy mode command, 0x80 0xb5 0x02 0x01
21 * --------------------------------------------
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()
125 static int pegasus_set_mode(struct pegasus *pegasus, u8 mode, u8 led) in pegasus_set_mode() argument
127 u8 cmd[] = { NOTETAKER_SET_CMD, NOTETAKER_SET_MODE, led, mode }; in pegasus_set_mode()
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()
299 pegasus->data_len = usb_maxpacket(dev, pipe, usb_pipeout(pipe)); in pegasus_probe()
301 pegasus->data = usb_alloc_coherent(dev, pegasus->data_len, GFP_KERNEL, in pegasus_probe()
302 &pegasus->data_dma); in pegasus_probe()
303 if (!pegasus->data) { in pegasus_probe()
304 error = -ENOMEM; in pegasus_probe()
308 pegasus->irq = usb_alloc_urb(0, GFP_KERNEL); in pegasus_probe()
309 if (!pegasus->irq) { in pegasus_probe()
310 error = -ENOMEM; in pegasus_probe()
314 usb_fill_int_urb(pegasus->irq, dev, pipe, in pegasus_probe()
315 pegasus->data, pegasus->data_len, in pegasus_probe()
316 pegasus_irq, pegasus, endpoint->bInterval); in pegasus_probe()
318 pegasus->irq->transfer_dma = pegasus->data_dma; in pegasus_probe()
319 pegasus->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in pegasus_probe()
321 if (dev->manufacturer) in pegasus_probe()
322 strlcpy(pegasus->name, dev->manufacturer, in pegasus_probe()
323 sizeof(pegasus->name)); in pegasus_probe()
325 if (dev->product) { in pegasus_probe()
326 if (dev->manufacturer) in pegasus_probe()
327 strlcat(pegasus->name, " ", sizeof(pegasus->name)); in pegasus_probe()
328 strlcat(pegasus->name, dev->product, sizeof(pegasus->name)); in pegasus_probe()
331 if (!strlen(pegasus->name)) in pegasus_probe()
332 snprintf(pegasus->name, sizeof(pegasus->name), in pegasus_probe()
334 le16_to_cpu(dev->descriptor.idVendor), in pegasus_probe()
335 le16_to_cpu(dev->descriptor.idProduct)); in pegasus_probe()
337 usb_make_path(dev, pegasus->phys, sizeof(pegasus->phys)); in pegasus_probe()
338 strlcat(pegasus->phys, "/input0", sizeof(pegasus->phys)); in pegasus_probe()
340 INIT_WORK(&pegasus->init, pegasus_init); in pegasus_probe()
344 input_dev->name = pegasus->name; in pegasus_probe()
345 input_dev->phys = pegasus->phys; in pegasus_probe()
346 usb_to_input_id(dev, &input_dev->id); in pegasus_probe()
347 input_dev->dev.parent = &intf->dev; in pegasus_probe()
351 input_dev->open = pegasus_open; in pegasus_probe()
352 input_dev->close = pegasus_close; in pegasus_probe()
354 __set_bit(EV_ABS, input_dev->evbit); in pegasus_probe()
355 __set_bit(EV_KEY, input_dev->evbit); in pegasus_probe()
357 __set_bit(ABS_X, input_dev->absbit); in pegasus_probe()
358 __set_bit(ABS_Y, input_dev->absbit); in pegasus_probe()
360 __set_bit(BTN_TOUCH, input_dev->keybit); in pegasus_probe()
361 __set_bit(BTN_RIGHT, input_dev->keybit); in pegasus_probe()
362 __set_bit(BTN_TOOL_PEN, input_dev->keybit); in pegasus_probe()
364 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); in pegasus_probe()
365 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); in pegasus_probe()
367 input_set_abs_params(input_dev, ABS_X, -1500, 1500, 8, 0); in pegasus_probe()
370 error = input_register_device(pegasus->dev); in pegasus_probe()
377 usb_free_urb(pegasus->irq); in pegasus_probe()
379 usb_free_coherent(dev, pegasus->data_len, in pegasus_probe()
380 pegasus->data, pegasus->data_dma); in pegasus_probe()
393 input_unregister_device(pegasus->dev); in pegasus_disconnect()
395 usb_free_urb(pegasus->irq); in pegasus_disconnect()
397 pegasus->data_len, pegasus->data, in pegasus_disconnect()
398 pegasus->data_dma); in pegasus_disconnect()
408 mutex_lock(&pegasus->pm_mutex); in pegasus_suspend()
409 usb_kill_urb(pegasus->irq); in pegasus_suspend()
410 cancel_work_sync(&pegasus->init); in pegasus_suspend()
411 mutex_unlock(&pegasus->pm_mutex); in pegasus_suspend()
421 mutex_lock(&pegasus->pm_mutex); in pegasus_resume()
422 if (pegasus->is_open && usb_submit_urb(pegasus->irq, GFP_NOIO) < 0) in pegasus_resume()
423 retval = -EIO; in pegasus_resume()
424 mutex_unlock(&pegasus->pm_mutex); in pegasus_resume()
434 mutex_lock(&pegasus->pm_mutex); in pegasus_reset_resume()
435 if (pegasus->is_open) { in pegasus_reset_resume()
438 if (!retval && usb_submit_urb(pegasus->irq, GFP_NOIO) < 0) in pegasus_reset_resume()
439 retval = -EIO; in pegasus_reset_resume()
441 mutex_unlock(&pegasus->pm_mutex); in pegasus_reset_resume()
467 MODULE_DESCRIPTION("Pegasus Mobile Notetaker Pen tablet driver");