Lines Matching +full:touchscreen +full:- +full:min +full:- +full:pressure

1 // SPDX-License-Identifier: GPL-2.0-or-later
9 * Copyright (c) 2004 Jan Steinhoff (cpad@jan-steinhoff . de)
14 * http://jan-steinhoff.de/linux/synaptics-usb.html
16 * Bases on: usb_skeleton.c v2.2 by Greg Kroah-Hartman
49 #define USB_DEVICE_ID_SYNAPTICS_TS 0x0006 /* Synaptics TouchScreen */
96 struct input_dev *input_dev = synusb->input; in synusb_report_buttons()
98 input_report_key(input_dev, BTN_LEFT, synusb->data[1] & 0x04); in synusb_report_buttons()
99 input_report_key(input_dev, BTN_RIGHT, synusb->data[1] & 0x01); in synusb_report_buttons()
100 input_report_key(input_dev, BTN_MIDDLE, synusb->data[1] & 0x02); in synusb_report_buttons()
105 struct input_dev *input_dev = synusb->input; in synusb_report_stick()
107 unsigned int pressure; in synusb_report_stick() local
109 pressure = synusb->data[6]; in synusb_report_stick()
110 x = (s16)(be16_to_cpup((__be16 *)&synusb->data[2]) << 3) >> 7; in synusb_report_stick()
111 y = (s16)(be16_to_cpup((__be16 *)&synusb->data[4]) << 3) >> 7; in synusb_report_stick()
113 if (pressure > 0) { in synusb_report_stick()
115 input_report_rel(input_dev, REL_Y, -y); in synusb_report_stick()
118 input_report_abs(input_dev, ABS_PRESSURE, pressure); in synusb_report_stick()
127 struct input_dev *input_dev = synusb->input; in synusb_report_touchpad()
130 unsigned int pressure, w; in synusb_report_touchpad() local
132 pressure = synusb->data[6]; in synusb_report_touchpad()
133 x = be16_to_cpup((__be16 *)&synusb->data[2]); in synusb_report_touchpad()
134 y = be16_to_cpup((__be16 *)&synusb->data[4]); in synusb_report_touchpad()
135 w = synusb->data[0] & 0x0f; in synusb_report_touchpad()
137 if (pressure > 0) { in synusb_report_touchpad()
160 * absolute -> relative conversion in synusb_report_touchpad()
163 if (pressure > 30) in synusb_report_touchpad()
165 if (pressure < 25) in synusb_report_touchpad()
171 YMAX_NOMINAL + YMIN_NOMINAL - y); in synusb_report_touchpad()
174 input_report_abs(input_dev, ABS_PRESSURE, pressure); in synusb_report_touchpad()
182 if (synusb->flags & SYNUSB_AUXDISPLAY) in synusb_report_touchpad()
183 input_report_key(input_dev, BTN_MIDDLE, synusb->data[1] & 0x08); in synusb_report_touchpad()
190 struct synusb *synusb = urb->context; in synusb_irq()
194 switch (urb->status) { in synusb_irq()
196 usb_mark_last_busy(synusb->udev); in synusb_irq()
200 case -ECONNRESET: in synusb_irq()
201 case -ENOENT: in synusb_irq()
202 case -ESHUTDOWN: in synusb_irq()
210 if (synusb->flags & SYNUSB_STICK) in synusb_irq()
217 if (error && error != -EPERM) in synusb_irq()
218 dev_err(&synusb->intf->dev, in synusb_irq()
219 "%s - usb_submit_urb failed with result: %d", in synusb_irq()
230 for (i = 0; i < iface->desc.bNumEndpoints; ++i) { in synusb_get_in_endpoint()
231 endpoint = &iface->endpoint[i].desc; in synusb_get_in_endpoint()
247 retval = usb_autopm_get_interface(synusb->intf); in synusb_open()
249 dev_err(&synusb->intf->dev, in synusb_open()
250 "%s - usb_autopm_get_interface failed, error: %d\n", in synusb_open()
255 mutex_lock(&synusb->pm_mutex); in synusb_open()
256 retval = usb_submit_urb(synusb->urb, GFP_KERNEL); in synusb_open()
258 dev_err(&synusb->intf->dev, in synusb_open()
259 "%s - usb_submit_urb failed, error: %d\n", in synusb_open()
261 retval = -EIO; in synusb_open()
265 synusb->intf->needs_remote_wakeup = 1; in synusb_open()
266 synusb->is_open = true; in synusb_open()
269 mutex_unlock(&synusb->pm_mutex); in synusb_open()
270 usb_autopm_put_interface(synusb->intf); in synusb_open()
279 autopm_error = usb_autopm_get_interface(synusb->intf); in synusb_close()
281 mutex_lock(&synusb->pm_mutex); in synusb_close()
282 usb_kill_urb(synusb->urb); in synusb_close()
283 synusb->intf->needs_remote_wakeup = 0; in synusb_close()
284 synusb->is_open = false; in synusb_close()
285 mutex_unlock(&synusb->pm_mutex); in synusb_close()
288 usb_autopm_put_interface(synusb->intf); in synusb_close()
298 unsigned int intf_num = intf->cur_altsetting->desc.bInterfaceNumber; in synusb_probe()
299 unsigned int altsetting = min(intf->num_altsetting, 1U); in synusb_probe()
304 dev_err(&udev->dev, in synusb_probe()
310 ep = synusb_get_in_endpoint(intf->cur_altsetting); in synusb_probe()
312 return -ENODEV; in synusb_probe()
317 error = -ENOMEM; in synusb_probe()
321 synusb->udev = udev; in synusb_probe()
322 synusb->intf = intf; in synusb_probe()
323 synusb->input = input_dev; in synusb_probe()
324 mutex_init(&synusb->pm_mutex); in synusb_probe()
326 synusb->flags = id->driver_info; in synusb_probe()
327 if (synusb->flags & SYNUSB_COMBO) { in synusb_probe()
332 synusb->flags |= intf_num == 1 ? in synusb_probe()
336 synusb->urb = usb_alloc_urb(0, GFP_KERNEL); in synusb_probe()
337 if (!synusb->urb) { in synusb_probe()
338 error = -ENOMEM; in synusb_probe()
342 synusb->data = usb_alloc_coherent(udev, SYNUSB_RECV_SIZE, GFP_KERNEL, in synusb_probe()
343 &synusb->urb->transfer_dma); in synusb_probe()
344 if (!synusb->data) { in synusb_probe()
345 error = -ENOMEM; in synusb_probe()
349 usb_fill_int_urb(synusb->urb, udev, in synusb_probe()
350 usb_rcvintpipe(udev, ep->bEndpointAddress), in synusb_probe()
351 synusb->data, SYNUSB_RECV_SIZE, in synusb_probe()
353 ep->bInterval); in synusb_probe()
354 synusb->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in synusb_probe()
356 if (udev->manufacturer) in synusb_probe()
357 strlcpy(synusb->name, udev->manufacturer, in synusb_probe()
358 sizeof(synusb->name)); in synusb_probe()
360 if (udev->product) { in synusb_probe()
361 if (udev->manufacturer) in synusb_probe()
362 strlcat(synusb->name, " ", sizeof(synusb->name)); in synusb_probe()
363 strlcat(synusb->name, udev->product, sizeof(synusb->name)); in synusb_probe()
366 if (!strlen(synusb->name)) in synusb_probe()
367 snprintf(synusb->name, sizeof(synusb->name), in synusb_probe()
369 le16_to_cpu(udev->descriptor.idVendor), in synusb_probe()
370 le16_to_cpu(udev->descriptor.idProduct)); in synusb_probe()
372 if (synusb->flags & SYNUSB_STICK) in synusb_probe()
373 strlcat(synusb->name, " (Stick)", sizeof(synusb->name)); in synusb_probe()
375 usb_make_path(udev, synusb->phys, sizeof(synusb->phys)); in synusb_probe()
376 strlcat(synusb->phys, "/input0", sizeof(synusb->phys)); in synusb_probe()
378 input_dev->name = synusb->name; in synusb_probe()
379 input_dev->phys = synusb->phys; in synusb_probe()
380 usb_to_input_id(udev, &input_dev->id); in synusb_probe()
381 input_dev->dev.parent = &synusb->intf->dev; in synusb_probe()
383 if (!(synusb->flags & SYNUSB_IO_ALWAYS)) { in synusb_probe()
384 input_dev->open = synusb_open; in synusb_probe()
385 input_dev->close = synusb_close; in synusb_probe()
390 __set_bit(EV_ABS, input_dev->evbit); in synusb_probe()
391 __set_bit(EV_KEY, input_dev->evbit); in synusb_probe()
393 if (synusb->flags & SYNUSB_STICK) { in synusb_probe()
394 __set_bit(EV_REL, input_dev->evbit); in synusb_probe()
395 __set_bit(REL_X, input_dev->relbit); in synusb_probe()
396 __set_bit(REL_Y, input_dev->relbit); in synusb_probe()
397 __set_bit(INPUT_PROP_POINTING_STICK, input_dev->propbit); in synusb_probe()
406 __set_bit(BTN_TOUCH, input_dev->keybit); in synusb_probe()
407 __set_bit(BTN_TOOL_FINGER, input_dev->keybit); in synusb_probe()
408 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); in synusb_probe()
409 __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); in synusb_probe()
412 if (synusb->flags & SYNUSB_TOUCHSCREEN) in synusb_probe()
413 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); in synusb_probe()
415 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); in synusb_probe()
417 __set_bit(BTN_LEFT, input_dev->keybit); in synusb_probe()
418 __set_bit(BTN_RIGHT, input_dev->keybit); in synusb_probe()
419 __set_bit(BTN_MIDDLE, input_dev->keybit); in synusb_probe()
423 if (synusb->flags & SYNUSB_IO_ALWAYS) { in synusb_probe()
431 dev_err(&udev->dev, in synusb_probe()
440 if (synusb->flags & SYNUSB_IO_ALWAYS) in synusb_probe()
441 synusb_close(synusb->input); in synusb_probe()
443 usb_free_coherent(udev, SYNUSB_RECV_SIZE, synusb->data, in synusb_probe()
444 synusb->urb->transfer_dma); in synusb_probe()
446 usb_free_urb(synusb->urb); in synusb_probe()
460 if (synusb->flags & SYNUSB_IO_ALWAYS) in synusb_disconnect()
461 synusb_close(synusb->input); in synusb_disconnect()
463 input_unregister_device(synusb->input); in synusb_disconnect()
465 usb_free_coherent(udev, SYNUSB_RECV_SIZE, synusb->data, in synusb_disconnect()
466 synusb->urb->transfer_dma); in synusb_disconnect()
467 usb_free_urb(synusb->urb); in synusb_disconnect()
477 mutex_lock(&synusb->pm_mutex); in synusb_suspend()
478 usb_kill_urb(synusb->urb); in synusb_suspend()
479 mutex_unlock(&synusb->pm_mutex); in synusb_suspend()
489 mutex_lock(&synusb->pm_mutex); in synusb_resume()
491 if ((synusb->is_open || (synusb->flags & SYNUSB_IO_ALWAYS)) && in synusb_resume()
492 usb_submit_urb(synusb->urb, GFP_NOIO) < 0) { in synusb_resume()
493 retval = -EIO; in synusb_resume()
496 mutex_unlock(&synusb->pm_mutex); in synusb_resume()
505 mutex_lock(&synusb->pm_mutex); in synusb_pre_reset()
506 usb_kill_urb(synusb->urb); in synusb_pre_reset()
516 if ((synusb->is_open || (synusb->flags & SYNUSB_IO_ALWAYS)) && in synusb_post_reset()
517 usb_submit_urb(synusb->urb, GFP_NOIO) < 0) { in synusb_post_reset()
518 retval = -EIO; in synusb_post_reset()
521 mutex_unlock(&synusb->pm_mutex); in synusb_post_reset()
563 "Jan Steinhoff <cpad@jan-steinhoff.de>");