^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * usbtouchscreen.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Driver for USB Touchscreens, supporting those devices:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * - eGalax Touchkit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * includes eTurboTouch CT-410/510/700
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * - 3M/Microtouch EX II series
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * - ITM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * - PanJit TouchSet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * - eTurboTouch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * - Gunze AHL61
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * - DMC TSC-10/25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * - IRTOUCHSYSTEMS/UNITOP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * - IdealTEK URTC1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * - General Touch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * - GoTop Super_Q2/GogoPen/PenPower tablets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * - JASTEC USB touch controller/DigiTech DTR-02U
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * - Zytronic capacitive touchscreen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * - NEXIO/iNexio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * - Elo TouchSystems 2700 IntelliTouch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * - EasyTouch USB Dual/Multi touch controller from Data Modul
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * Copyright (C) 2004-2007 by Daniel Ritz <daniel.ritz@gmx.ch>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * Copyright (C) by Todd E. Johnson (mtouchusb.c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * Driver is based on touchkitusb.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * - ITM parts are from itmtouch.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * - 3M parts are from mtouchusb.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * - PanJit parts are from an unmerged driver by Lanslott Gish
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * - DMC TSC 10/25 are from Holger Schurig, with ideas from an unmerged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * driver from Marius Vollmer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) //#define DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include <linux/usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include <linux/usb/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include <linux/hid.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static bool swap_xy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) module_param(swap_xy, bool, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static bool hwcalib_xy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) module_param(hwcalib_xy, bool, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) MODULE_PARM_DESC(hwcalib_xy, "If set hw-calibrated X/Y are used if available");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) /* device specifc data/functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct usbtouch_usb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct usbtouch_device_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) int min_xc, max_xc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) int min_yc, max_yc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) int min_press, max_press;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) int rept_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * Always service the USB devices irq not just when the input device is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * open. This is useful when devices have a watchdog which prevents us
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * from periodically polling the device. Leave this unset unless your
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * touchscreen device requires it, as it does consume more of the USB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * bandwidth.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) bool irq_always;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) void (*process_pkt) (struct usbtouch_usb *usbtouch, unsigned char *pkt, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * used to get the packet len. possible return values:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * > 0: packet len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * = 0: skip one byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * < 0: -return value more bytes needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) int (*get_pkt_len) (unsigned char *pkt, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) int (*read_data) (struct usbtouch_usb *usbtouch, unsigned char *pkt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) int (*alloc) (struct usbtouch_usb *usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) int (*init) (struct usbtouch_usb *usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) void (*exit) (struct usbtouch_usb *usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /* a usbtouch device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct usbtouch_usb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) unsigned char *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) dma_addr_t data_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) int data_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) unsigned char *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) int buf_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) struct urb *irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct usb_interface *interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) struct input_dev *input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct usbtouch_device_info *type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct mutex pm_mutex; /* serialize access to open/suspend */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) bool is_open;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) char name[128];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) char phys[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) void *priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) int x, y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) int touch, press;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) /* device types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) DEVTYPE_IGNORE = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) DEVTYPE_EGALAX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) DEVTYPE_PANJIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) DEVTYPE_3M,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) DEVTYPE_ITM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) DEVTYPE_ETURBO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) DEVTYPE_GUNZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) DEVTYPE_DMC_TSC10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) DEVTYPE_IRTOUCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) DEVTYPE_IRTOUCH_HIRES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) DEVTYPE_IDEALTEK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) DEVTYPE_GENERAL_TOUCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) DEVTYPE_GOTOP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) DEVTYPE_JASTEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) DEVTYPE_E2I,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) DEVTYPE_ZYTRONIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) DEVTYPE_TC45USB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) DEVTYPE_NEXIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) DEVTYPE_ELO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) DEVTYPE_ETOUCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #define USB_DEVICE_HID_CLASS(vend, prod) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) | USB_DEVICE_ID_MATCH_DEVICE, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) .idVendor = (vend), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) .idProduct = (prod), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) .bInterfaceClass = USB_INTERFACE_CLASS_HID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static const struct usb_device_id usbtouch_devices[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /* ignore the HID capable devices, handled by usbhid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {USB_DEVICE_HID_CLASS(0x0eef, 0x0001), .driver_info = DEVTYPE_IGNORE},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {USB_DEVICE_HID_CLASS(0x0eef, 0x0002), .driver_info = DEVTYPE_IGNORE},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /* normal device IDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) {USB_DEVICE(0x3823, 0x0001), .driver_info = DEVTYPE_EGALAX},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {USB_DEVICE(0x3823, 0x0002), .driver_info = DEVTYPE_EGALAX},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) {USB_DEVICE(0x0123, 0x0001), .driver_info = DEVTYPE_EGALAX},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) {USB_DEVICE(0x0eef, 0x0001), .driver_info = DEVTYPE_EGALAX},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {USB_DEVICE(0x0eef, 0x0002), .driver_info = DEVTYPE_EGALAX},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {USB_DEVICE(0x1234, 0x0001), .driver_info = DEVTYPE_EGALAX},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {USB_DEVICE(0x1234, 0x0002), .driver_info = DEVTYPE_EGALAX},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) {USB_DEVICE(0x134c, 0x0001), .driver_info = DEVTYPE_PANJIT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) {USB_DEVICE(0x134c, 0x0002), .driver_info = DEVTYPE_PANJIT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {USB_DEVICE(0x134c, 0x0003), .driver_info = DEVTYPE_PANJIT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) {USB_DEVICE(0x134c, 0x0004), .driver_info = DEVTYPE_PANJIT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) #ifdef CONFIG_TOUCHSCREEN_USB_3M
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {USB_DEVICE(0x0596, 0x0001), .driver_info = DEVTYPE_3M},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) #ifdef CONFIG_TOUCHSCREEN_USB_ITM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) {USB_DEVICE(0x0403, 0xf9e9), .driver_info = DEVTYPE_ITM},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {USB_DEVICE(0x16e3, 0xf9e9), .driver_info = DEVTYPE_ITM},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {USB_DEVICE(0x1234, 0x5678), .driver_info = DEVTYPE_ETURBO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {USB_DEVICE(0x0637, 0x0001), .driver_info = DEVTYPE_GUNZE},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) {USB_DEVICE(0x0afa, 0x03e8), .driver_info = DEVTYPE_DMC_TSC10},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {USB_DEVICE(0x255e, 0x0001), .driver_info = DEVTYPE_IRTOUCH},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) {USB_DEVICE(0x595a, 0x0001), .driver_info = DEVTYPE_IRTOUCH},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {USB_DEVICE(0x6615, 0x0001), .driver_info = DEVTYPE_IRTOUCH},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) {USB_DEVICE(0x6615, 0x0012), .driver_info = DEVTYPE_IRTOUCH_HIRES},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) {USB_DEVICE(0x1391, 0x1000), .driver_info = DEVTYPE_IDEALTEK},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) {USB_DEVICE(0x0dfc, 0x0001), .driver_info = DEVTYPE_GENERAL_TOUCH},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) {USB_DEVICE(0x08f2, 0x007f), .driver_info = DEVTYPE_GOTOP},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) {USB_DEVICE(0x08f2, 0x00ce), .driver_info = DEVTYPE_GOTOP},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {USB_DEVICE(0x08f2, 0x00f4), .driver_info = DEVTYPE_GOTOP},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) {USB_DEVICE(0x0f92, 0x0001), .driver_info = DEVTYPE_JASTEC},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) #ifdef CONFIG_TOUCHSCREEN_USB_E2I
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) {USB_DEVICE(0x1ac7, 0x0001), .driver_info = DEVTYPE_E2I},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) {USB_DEVICE(0x14c8, 0x0003), .driver_info = DEVTYPE_ZYTRONIC},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) /* TC5UH */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) {USB_DEVICE(0x0664, 0x0309), .driver_info = DEVTYPE_TC45USB},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /* TC4UM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) {USB_DEVICE(0x0664, 0x0306), .driver_info = DEVTYPE_TC45USB},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /* data interface only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) {USB_DEVICE_AND_INTERFACE_INFO(0x10f0, 0x2002, 0x0a, 0x00, 0x00),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) .driver_info = DEVTYPE_NEXIO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {USB_DEVICE_AND_INTERFACE_INFO(0x1870, 0x0001, 0x0a, 0x00, 0x00),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) .driver_info = DEVTYPE_NEXIO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) #ifdef CONFIG_TOUCHSCREEN_USB_ELO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) {USB_DEVICE(0x04e7, 0x0020), .driver_info = DEVTYPE_ELO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) #ifdef CONFIG_TOUCHSCREEN_USB_EASYTOUCH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {USB_DEVICE(0x7374, 0x0001), .driver_info = DEVTYPE_ETOUCH},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * e2i Part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) #ifdef CONFIG_TOUCHSCREEN_USB_E2I
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) static int e2i_init(struct usbtouch_usb *usbtouch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 0x01, 0x02, 0x0000, 0x0081,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) NULL, 0, USB_CTRL_SET_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) dev_dbg(&usbtouch->interface->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) "%s - usb_control_msg - E2I_RESET - bytes|err: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) __func__, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) int tmp = (pkt[0] << 8) | pkt[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) dev->x = (pkt[2] << 8) | pkt[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) dev->y = (pkt[4] << 8) | pkt[5];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) tmp = tmp - 0xA000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) dev->touch = (tmp > 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) dev->press = (tmp > 0 ? tmp : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) * eGalax part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) #ifndef MULTI_PACKET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) #define MULTI_PACKET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) #define EGALAX_PKT_TYPE_MASK 0xFE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) #define EGALAX_PKT_TYPE_REPT 0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) #define EGALAX_PKT_TYPE_DIAG 0x0A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) static int egalax_init(struct usbtouch_usb *usbtouch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) int ret, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) unsigned char *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) * An eGalax diagnostic packet kicks the device into using the right
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) * protocol. We send a "check active" packet. The response will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) * read later and ignored.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) buf = kmalloc(3, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) if (!buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) buf[0] = EGALAX_PKT_TYPE_DIAG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) buf[1] = 1; /* length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) buf[2] = 'A'; /* command - check active */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) for (i = 0; i < 3; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 0, 0, buf, 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) USB_CTRL_SET_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) if (ret >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) if (ret != -EPIPE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) static int egalax_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) if ((pkt[0] & EGALAX_PKT_TYPE_MASK) != EGALAX_PKT_TYPE_REPT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) dev->x = ((pkt[3] & 0x0F) << 7) | (pkt[4] & 0x7F);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) dev->y = ((pkt[1] & 0x0F) << 7) | (pkt[2] & 0x7F);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) dev->touch = pkt[0] & 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) static int egalax_get_pkt_len(unsigned char *buf, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) switch (buf[0] & EGALAX_PKT_TYPE_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) case EGALAX_PKT_TYPE_REPT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) return 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) case EGALAX_PKT_TYPE_DIAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) if (len < 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) return buf[1] + 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) * EasyTouch part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) #ifdef CONFIG_TOUCHSCREEN_USB_EASYTOUCH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) #ifndef MULTI_PACKET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) #define MULTI_PACKET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) #define ETOUCH_PKT_TYPE_MASK 0xFE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) #define ETOUCH_PKT_TYPE_REPT 0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) #define ETOUCH_PKT_TYPE_REPT2 0xB0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) #define ETOUCH_PKT_TYPE_DIAG 0x0A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) static int etouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) if ((pkt[0] & ETOUCH_PKT_TYPE_MASK) != ETOUCH_PKT_TYPE_REPT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) (pkt[0] & ETOUCH_PKT_TYPE_MASK) != ETOUCH_PKT_TYPE_REPT2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) dev->x = ((pkt[1] & 0x1F) << 7) | (pkt[2] & 0x7F);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) dev->y = ((pkt[3] & 0x1F) << 7) | (pkt[4] & 0x7F);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) dev->touch = pkt[0] & 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) static int etouch_get_pkt_len(unsigned char *buf, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) switch (buf[0] & ETOUCH_PKT_TYPE_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) case ETOUCH_PKT_TYPE_REPT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) case ETOUCH_PKT_TYPE_REPT2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) return 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) case ETOUCH_PKT_TYPE_DIAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) if (len < 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) return buf[1] + 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) * PanJit Part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) static int panjit_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) dev->x = ((pkt[2] & 0x0F) << 8) | pkt[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) dev->y = ((pkt[4] & 0x0F) << 8) | pkt[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) dev->touch = pkt[0] & 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) * 3M/Microtouch Part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) #ifdef CONFIG_TOUCHSCREEN_USB_3M
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) #define MTOUCHUSB_ASYNC_REPORT 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) #define MTOUCHUSB_RESET 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) #define MTOUCHUSB_REQ_CTRLLR_ID 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) #define MTOUCHUSB_REQ_CTRLLR_ID_LEN 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) static int mtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) if (hwcalib_xy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) dev->x = (pkt[4] << 8) | pkt[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) dev->y = 0xffff - ((pkt[6] << 8) | pkt[5]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) dev->x = (pkt[8] << 8) | pkt[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) dev->y = (pkt[10] << 8) | pkt[9];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) dev->touch = (pkt[2] & 0x40) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) struct mtouch_priv {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) u8 fw_rev_major;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) u8 fw_rev_minor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) static ssize_t mtouch_firmware_rev_show(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) struct device_attribute *attr, char *output)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) struct usb_interface *intf = to_usb_interface(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) struct mtouch_priv *priv = usbtouch->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) return scnprintf(output, PAGE_SIZE, "%1x.%1x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) priv->fw_rev_major, priv->fw_rev_minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) static DEVICE_ATTR(firmware_rev, 0444, mtouch_firmware_rev_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) static struct attribute *mtouch_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) &dev_attr_firmware_rev.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) static const struct attribute_group mtouch_attr_group = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) .attrs = mtouch_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) static int mtouch_get_fw_revision(struct usbtouch_usb *usbtouch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) struct mtouch_priv *priv = usbtouch->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) u8 *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) buf = kzalloc(MTOUCHUSB_REQ_CTRLLR_ID_LEN, GFP_NOIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) if (!buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) MTOUCHUSB_REQ_CTRLLR_ID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 0, 0, buf, MTOUCHUSB_REQ_CTRLLR_ID_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) USB_CTRL_SET_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) if (ret != MTOUCHUSB_REQ_CTRLLR_ID_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) dev_warn(&usbtouch->interface->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) "Failed to read FW rev: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) ret = ret < 0 ? ret : -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) goto free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) priv->fw_rev_major = buf[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) priv->fw_rev_minor = buf[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) static int mtouch_alloc(struct usbtouch_usb *usbtouch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) usbtouch->priv = kmalloc(sizeof(struct mtouch_priv), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) if (!usbtouch->priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) ret = sysfs_create_group(&usbtouch->interface->dev.kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) &mtouch_attr_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) kfree(usbtouch->priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) usbtouch->priv = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) static int mtouch_init(struct usbtouch_usb *usbtouch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) int ret, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) ret = mtouch_get_fw_revision(usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) MTOUCHUSB_RESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) dev_dbg(&usbtouch->interface->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) "%s - usb_control_msg - MTOUCHUSB_RESET - bytes|err: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) __func__, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) msleep(150);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) for (i = 0; i < 3; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) MTOUCHUSB_ASYNC_REPORT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) dev_dbg(&usbtouch->interface->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) "%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) __func__, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) if (ret >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) if (ret != -EPIPE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) /* Default min/max xy are the raw values, override if using hw-calib */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) if (hwcalib_xy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) input_set_abs_params(usbtouch->input, ABS_X, 0, 0xffff, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) input_set_abs_params(usbtouch->input, ABS_Y, 0, 0xffff, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) static void mtouch_exit(struct usbtouch_usb *usbtouch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) struct mtouch_priv *priv = usbtouch->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) sysfs_remove_group(&usbtouch->interface->dev.kobj, &mtouch_attr_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) kfree(priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) * ITM Part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) #ifdef CONFIG_TOUCHSCREEN_USB_ITM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) static int itm_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) int touch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) * ITM devices report invalid x/y data if not touched.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) * if the screen was touched before but is not touched any more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) * report touch as 0 with the last valid x/y data once. then stop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) * reporting data until touched again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) dev->press = ((pkt[2] & 0x01) << 7) | (pkt[5] & 0x7F);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) touch = ~pkt[7] & 0x20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) if (!touch) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) if (dev->touch) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) dev->touch = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) dev->x = ((pkt[0] & 0x1F) << 7) | (pkt[3] & 0x7F);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) dev->y = ((pkt[1] & 0x1F) << 7) | (pkt[4] & 0x7F);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) dev->touch = touch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) * eTurboTouch part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) #ifndef MULTI_PACKET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) #define MULTI_PACKET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) static int eturbo_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) unsigned int shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) /* packets should start with sync */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) if (!(pkt[0] & 0x80))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) shift = (6 - (pkt[0] & 0x03));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) dev->x = ((pkt[3] << 7) | pkt[4]) >> shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) dev->y = ((pkt[1] << 7) | pkt[2]) >> shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) dev->touch = (pkt[0] & 0x10) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) static int eturbo_get_pkt_len(unsigned char *buf, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) if (buf[0] & 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) return 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) if (buf[0] == 0x01)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) return 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) * Gunze part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) static int gunze_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) if (!(pkt[0] & 0x80) || ((pkt[1] | pkt[2] | pkt[3]) & 0x80))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) dev->x = ((pkt[0] & 0x1F) << 7) | (pkt[2] & 0x7F);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) dev->y = ((pkt[1] & 0x1F) << 7) | (pkt[3] & 0x7F);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) dev->touch = pkt[0] & 0x20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) * DMC TSC-10/25 Part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) * Documentation about the controller and it's protocol can be found at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) * http://www.dmccoltd.com/files/controler/tsc10usb_pi_e.pdf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) * http://www.dmccoltd.com/files/controler/tsc25_usb_e.pdf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) /* supported data rates. currently using 130 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) #define TSC10_RATE_POINT 0x50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) #define TSC10_RATE_30 0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) #define TSC10_RATE_50 0x41
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) #define TSC10_RATE_80 0x42
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) #define TSC10_RATE_100 0x43
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) #define TSC10_RATE_130 0x44
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) #define TSC10_RATE_150 0x45
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) /* commands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) #define TSC10_CMD_RESET 0x55
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) #define TSC10_CMD_RATE 0x05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) #define TSC10_CMD_DATA1 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) static int dmc_tsc10_init(struct usbtouch_usb *usbtouch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) struct usb_device *dev = interface_to_usbdev(usbtouch->interface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) int ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) unsigned char *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) buf = kmalloc(2, GFP_NOIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) if (!buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) goto err_nobuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) /* reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) buf[0] = buf[1] = 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) TSC10_CMD_RESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 0, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) goto err_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) if (buf[0] != 0x06) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) ret = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) goto err_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) /* TSC-25 data sheet specifies a delay after the RESET command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) msleep(150);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) /* set coordinate output rate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) buf[0] = buf[1] = 0xFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) TSC10_CMD_RATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) TSC10_RATE_150, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) goto err_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) if ((buf[0] != 0x06) && (buf[0] != 0x15 || buf[1] != 0x01)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) ret = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) goto err_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) /* start sending data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) TSC10_CMD_DATA1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) err_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) err_nobuf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) static int dmc_tsc10_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) dev->x = ((pkt[2] & 0x03) << 8) | pkt[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) dev->y = ((pkt[4] & 0x03) << 8) | pkt[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) dev->touch = pkt[0] & 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) * IRTOUCH Part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) static int irtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) dev->x = (pkt[3] << 8) | pkt[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) dev->y = (pkt[5] << 8) | pkt[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) dev->touch = (pkt[1] & 0x03) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) * ET&T TC5UH/TC4UM part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) static int tc45usb_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) dev->x = ((pkt[2] & 0x0F) << 8) | pkt[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) dev->y = ((pkt[4] & 0x0F) << 8) | pkt[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) dev->touch = pkt[0] & 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) * IdealTEK URTC1000 Part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) #ifndef MULTI_PACKET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) #define MULTI_PACKET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) static int idealtek_get_pkt_len(unsigned char *buf, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) if (buf[0] & 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) return 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) if (buf[0] == 0x01)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) static int idealtek_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) switch (pkt[0] & 0x98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) case 0x88:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) /* touch data in IdealTEK mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) dev->x = (pkt[1] << 5) | (pkt[2] >> 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) dev->y = (pkt[3] << 5) | (pkt[4] >> 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) dev->touch = (pkt[0] & 0x40) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) case 0x98:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) /* touch data in MT emulation mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) dev->x = (pkt[2] << 5) | (pkt[1] >> 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) dev->y = (pkt[4] << 5) | (pkt[3] >> 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) dev->touch = (pkt[0] & 0x40) ? 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) * General Touch Part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) static int general_touch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) dev->x = (pkt[2] << 8) | pkt[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) dev->y = (pkt[4] << 8) | pkt[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) dev->press = pkt[5] & 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) dev->touch = pkt[0] & 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) * GoTop Part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) static int gotop_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) dev->x = ((pkt[1] & 0x38) << 4) | pkt[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) dev->y = ((pkt[1] & 0x07) << 7) | pkt[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) dev->touch = pkt[0] & 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) * JASTEC Part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) static int jastec_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) dev->x = ((pkt[0] & 0x3f) << 6) | (pkt[2] & 0x3f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) dev->y = ((pkt[1] & 0x3f) << 6) | (pkt[3] & 0x3f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) dev->touch = (pkt[0] & 0x40) >> 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) * Zytronic Part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) static int zytronic_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) struct usb_interface *intf = dev->interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) switch (pkt[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) case 0x3A: /* command response */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) dev_dbg(&intf->dev, "%s: Command response %d\n", __func__, pkt[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) case 0xC0: /* down */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) dev->x = (pkt[1] & 0x7f) | ((pkt[2] & 0x07) << 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) dev->y = (pkt[3] & 0x7f) | ((pkt[4] & 0x07) << 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) dev->touch = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) dev_dbg(&intf->dev, "%s: down %d,%d\n", __func__, dev->x, dev->y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) case 0x80: /* up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) dev->x = (pkt[1] & 0x7f) | ((pkt[2] & 0x07) << 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) dev->y = (pkt[3] & 0x7f) | ((pkt[4] & 0x07) << 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) dev->touch = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) dev_dbg(&intf->dev, "%s: up %d,%d\n", __func__, dev->x, dev->y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) dev_dbg(&intf->dev, "%s: Unknown return %d\n", __func__, pkt[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) * NEXIO Part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) #define NEXIO_TIMEOUT 5000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) #define NEXIO_BUFSIZE 1024
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) #define NEXIO_THRESHOLD 50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) struct nexio_priv {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) struct urb *ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) unsigned char *ack_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) struct nexio_touch_packet {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) u8 flags; /* 0xe1 = touch, 0xe1 = release */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) __be16 data_len; /* total bytes of touch data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) __be16 x_len; /* bytes for X axis */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) __be16 y_len; /* bytes for Y axis */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) u8 data[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) } __attribute__ ((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) static unsigned char nexio_ack_pkt[2] = { 0xaa, 0x02 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) static unsigned char nexio_init_pkt[4] = { 0x82, 0x04, 0x0a, 0x0f };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) static void nexio_ack_complete(struct urb *urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) static int nexio_alloc(struct usbtouch_usb *usbtouch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) struct nexio_priv *priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) int ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) if (!usbtouch->priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) goto out_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) priv = usbtouch->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) priv->ack_buf = kmemdup(nexio_ack_pkt, sizeof(nexio_ack_pkt),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) if (!priv->ack_buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) goto err_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) priv->ack = usb_alloc_urb(0, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) if (!priv->ack) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) dev_dbg(&usbtouch->interface->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) "%s - usb_alloc_urb failed: usbtouch->ack\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) goto err_ack_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) err_ack_buf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) kfree(priv->ack_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) err_priv:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) kfree(priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) out_buf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) static int nexio_init(struct usbtouch_usb *usbtouch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) struct usb_device *dev = interface_to_usbdev(usbtouch->interface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) struct usb_host_interface *interface = usbtouch->interface->cur_altsetting;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) struct nexio_priv *priv = usbtouch->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) int ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) int actual_len, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) unsigned char *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) char *firmware_ver = NULL, *device_name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) int input_ep = 0, output_ep = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) /* find first input and output endpoint */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) for (i = 0; i < interface->desc.bNumEndpoints; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) if (!input_ep &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) usb_endpoint_dir_in(&interface->endpoint[i].desc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) input_ep = interface->endpoint[i].desc.bEndpointAddress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) if (!output_ep &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) usb_endpoint_dir_out(&interface->endpoint[i].desc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) output_ep = interface->endpoint[i].desc.bEndpointAddress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) if (!input_ep || !output_ep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) buf = kmalloc(NEXIO_BUFSIZE, GFP_NOIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) if (!buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) goto out_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) /* two empty reads */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) for (i = 0; i < 2; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, input_ep),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) buf, NEXIO_BUFSIZE, &actual_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) NEXIO_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) goto out_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) /* send init command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) memcpy(buf, nexio_init_pkt, sizeof(nexio_init_pkt));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) ret = usb_bulk_msg(dev, usb_sndbulkpipe(dev, output_ep),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) buf, sizeof(nexio_init_pkt), &actual_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) NEXIO_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) goto out_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) /* read replies */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) for (i = 0; i < 3; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) memset(buf, 0, NEXIO_BUFSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, input_ep),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) buf, NEXIO_BUFSIZE, &actual_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) NEXIO_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) if (ret < 0 || actual_len < 1 || buf[1] != actual_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) switch (buf[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) case 0x83: /* firmware version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) if (!firmware_ver)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) firmware_ver = kstrdup(&buf[2], GFP_NOIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) case 0x84: /* device name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) if (!device_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) device_name = kstrdup(&buf[2], GFP_NOIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) printk(KERN_INFO "Nexio device: %s, firmware version: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) device_name, firmware_ver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) kfree(firmware_ver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) kfree(device_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) usb_fill_bulk_urb(priv->ack, dev, usb_sndbulkpipe(dev, output_ep),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) priv->ack_buf, sizeof(nexio_ack_pkt),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) nexio_ack_complete, usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) out_buf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) static void nexio_exit(struct usbtouch_usb *usbtouch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) struct nexio_priv *priv = usbtouch->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) usb_kill_urb(priv->ack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) usb_free_urb(priv->ack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) kfree(priv->ack_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) kfree(priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) static int nexio_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) struct nexio_touch_packet *packet = (void *) pkt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) struct nexio_priv *priv = usbtouch->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) unsigned int data_len = be16_to_cpu(packet->data_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) unsigned int x_len = be16_to_cpu(packet->x_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) unsigned int y_len = be16_to_cpu(packet->y_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) int x, y, begin_x, begin_y, end_x, end_y, w, h, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) /* got touch data? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) if ((pkt[0] & 0xe0) != 0xe0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) if (data_len > 0xff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) data_len -= 0x100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) if (x_len > 0xff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) x_len -= 0x80;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) /* send ACK */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) ret = usb_submit_urb(priv->ack, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) if (!usbtouch->type->max_xc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) usbtouch->type->max_xc = 2 * x_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) input_set_abs_params(usbtouch->input, ABS_X,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 0, usbtouch->type->max_xc, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) usbtouch->type->max_yc = 2 * y_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) input_set_abs_params(usbtouch->input, ABS_Y,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 0, usbtouch->type->max_yc, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) * The device reports state of IR sensors on X and Y axes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) * Each byte represents "darkness" percentage (0-100) of one element.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) * 17" touchscreen reports only 64 x 52 bytes so the resolution is low.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) * This also means that there's a limited multi-touch capability but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) * it's disabled (and untested) here as there's no X driver for that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) begin_x = end_x = begin_y = end_y = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) for (x = 0; x < x_len; x++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) if (begin_x == -1 && packet->data[x] > NEXIO_THRESHOLD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) begin_x = x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) if (end_x == -1 && begin_x != -1 && packet->data[x] < NEXIO_THRESHOLD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) end_x = x - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) for (y = x_len; y < data_len; y++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) if (begin_y == -1 && packet->data[y] > NEXIO_THRESHOLD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) begin_y = y - x_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) if (end_y == -1 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) begin_y != -1 && packet->data[y] < NEXIO_THRESHOLD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) end_y = y - 1 - x_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) w = end_x - begin_x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) h = end_y - begin_y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) /* multi-touch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) input_report_abs(usbtouch->input,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) ABS_MT_TOUCH_MAJOR, max(w,h));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) input_report_abs(usbtouch->input,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) ABS_MT_TOUCH_MINOR, min(x,h));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) input_report_abs(usbtouch->input,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) ABS_MT_POSITION_X, 2*begin_x+w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) input_report_abs(usbtouch->input,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) ABS_MT_POSITION_Y, 2*begin_y+h);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) input_report_abs(usbtouch->input,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) ABS_MT_ORIENTATION, w > h);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) input_mt_sync(usbtouch->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) /* single touch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) usbtouch->x = 2 * begin_x + w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) usbtouch->y = 2 * begin_y + h;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) usbtouch->touch = packet->flags & 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) begin_y = end_y = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) begin_x = end_x = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) * ELO part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) #ifdef CONFIG_TOUCHSCREEN_USB_ELO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) static int elo_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) dev->x = (pkt[3] << 8) | pkt[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) dev->y = (pkt[5] << 8) | pkt[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) dev->touch = pkt[6] > 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) dev->press = pkt[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) * the different device descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) #ifdef MULTI_PACKET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) unsigned char *pkt, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) static struct usbtouch_device_info usbtouch_dev_info[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) #ifdef CONFIG_TOUCHSCREEN_USB_ELO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) [DEVTYPE_ELO] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) .max_xc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) .max_yc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) .max_press = 0xff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) .rept_size = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) .read_data = elo_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) [DEVTYPE_EGALAX] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) .max_xc = 0x07ff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) .max_yc = 0x07ff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) .rept_size = 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) .process_pkt = usbtouch_process_multi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) .get_pkt_len = egalax_get_pkt_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) .read_data = egalax_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) .init = egalax_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) #ifdef CONFIG_TOUCHSCREEN_USB_PANJIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) [DEVTYPE_PANJIT] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) .max_xc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) .max_yc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) .rept_size = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) .read_data = panjit_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) #ifdef CONFIG_TOUCHSCREEN_USB_3M
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) [DEVTYPE_3M] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) .max_xc = 0x4000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) .max_yc = 0x4000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) .rept_size = 11,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) .read_data = mtouch_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) .alloc = mtouch_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) .init = mtouch_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) .exit = mtouch_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) #ifdef CONFIG_TOUCHSCREEN_USB_ITM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) [DEVTYPE_ITM] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) .max_xc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) .max_yc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) .max_press = 0xff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) .rept_size = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) .read_data = itm_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) #ifdef CONFIG_TOUCHSCREEN_USB_ETURBO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) [DEVTYPE_ETURBO] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) .max_xc = 0x07ff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) .max_yc = 0x07ff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) .rept_size = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) .process_pkt = usbtouch_process_multi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) .get_pkt_len = eturbo_get_pkt_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) .read_data = eturbo_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) #ifdef CONFIG_TOUCHSCREEN_USB_GUNZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) [DEVTYPE_GUNZE] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) .max_xc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) .max_yc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) .rept_size = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) .read_data = gunze_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) #ifdef CONFIG_TOUCHSCREEN_USB_DMC_TSC10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) [DEVTYPE_DMC_TSC10] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) .max_xc = 0x03ff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) .max_yc = 0x03ff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) .rept_size = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) .init = dmc_tsc10_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) .read_data = dmc_tsc10_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) #ifdef CONFIG_TOUCHSCREEN_USB_IRTOUCH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) [DEVTYPE_IRTOUCH] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) .max_xc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) .max_yc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) .rept_size = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) .read_data = irtouch_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) [DEVTYPE_IRTOUCH_HIRES] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) .max_xc = 0x7fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) .max_yc = 0x7fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) .rept_size = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) .read_data = irtouch_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) #ifdef CONFIG_TOUCHSCREEN_USB_IDEALTEK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) [DEVTYPE_IDEALTEK] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) .max_xc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) .max_yc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) .rept_size = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) .process_pkt = usbtouch_process_multi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) .get_pkt_len = idealtek_get_pkt_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) .read_data = idealtek_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) #ifdef CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) [DEVTYPE_GENERAL_TOUCH] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) .max_xc = 0x7fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) .max_yc = 0x7fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) .rept_size = 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) .read_data = general_touch_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) #ifdef CONFIG_TOUCHSCREEN_USB_GOTOP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) [DEVTYPE_GOTOP] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) .max_xc = 0x03ff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) .max_yc = 0x03ff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) .rept_size = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) .read_data = gotop_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) #ifdef CONFIG_TOUCHSCREEN_USB_JASTEC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) [DEVTYPE_JASTEC] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) .max_xc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) .max_yc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) .rept_size = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) .read_data = jastec_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) #ifdef CONFIG_TOUCHSCREEN_USB_E2I
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) [DEVTYPE_E2I] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) .max_xc = 0x7fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) .max_yc = 0x7fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) .rept_size = 6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) .init = e2i_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) .read_data = e2i_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) #ifdef CONFIG_TOUCHSCREEN_USB_ZYTRONIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) [DEVTYPE_ZYTRONIC] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) .max_xc = 0x03ff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) .max_yc = 0x03ff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) .rept_size = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) .read_data = zytronic_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) .irq_always = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) #ifdef CONFIG_TOUCHSCREEN_USB_ETT_TC45USB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) [DEVTYPE_TC45USB] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) .max_xc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) .max_yc = 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) .rept_size = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) .read_data = tc45usb_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) #ifdef CONFIG_TOUCHSCREEN_USB_NEXIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) [DEVTYPE_NEXIO] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) .rept_size = 1024,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) .irq_always = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) .read_data = nexio_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) .alloc = nexio_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) .init = nexio_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) .exit = nexio_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) #ifdef CONFIG_TOUCHSCREEN_USB_EASYTOUCH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) [DEVTYPE_ETOUCH] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) .min_xc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) .max_xc = 0x07ff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) .min_yc = 0x0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) .max_yc = 0x07ff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) .rept_size = 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) .process_pkt = usbtouch_process_multi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) .get_pkt_len = etouch_get_pkt_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) .read_data = etouch_read_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) /*****************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) * Generic Part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) unsigned char *pkt, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) struct usbtouch_device_info *type = usbtouch->type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) if (!type->read_data(usbtouch, pkt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) input_report_key(usbtouch->input, BTN_TOUCH, usbtouch->touch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) if (swap_xy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) input_report_abs(usbtouch->input, ABS_X, usbtouch->y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) input_report_abs(usbtouch->input, ABS_Y, usbtouch->x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) input_report_abs(usbtouch->input, ABS_X, usbtouch->x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) input_report_abs(usbtouch->input, ABS_Y, usbtouch->y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) if (type->max_press)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) input_report_abs(usbtouch->input, ABS_PRESSURE, usbtouch->press);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) input_sync(usbtouch->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) #ifdef MULTI_PACKET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) unsigned char *pkt, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) unsigned char *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) int pkt_len, pos, buf_len, tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) /* process buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) if (unlikely(usbtouch->buf_len)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) /* try to get size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) pkt_len = usbtouch->type->get_pkt_len(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) usbtouch->buffer, usbtouch->buf_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) /* drop? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) if (unlikely(!pkt_len))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) goto out_flush_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) /* need to append -pkt_len bytes before able to get size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) if (unlikely(pkt_len < 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) int append = -pkt_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) if (unlikely(append > len))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) append = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) if (usbtouch->buf_len + append >= usbtouch->type->rept_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) goto out_flush_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, append);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) usbtouch->buf_len += append;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) pkt_len = usbtouch->type->get_pkt_len(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) usbtouch->buffer, usbtouch->buf_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) if (pkt_len < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) /* append */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) tmp = pkt_len - usbtouch->buf_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) if (usbtouch->buf_len + tmp >= usbtouch->type->rept_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) goto out_flush_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) usbtouch_process_pkt(usbtouch, usbtouch->buffer, pkt_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) buffer = pkt + tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) buf_len = len - tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) buffer = pkt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) buf_len = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) /* loop over the received packet, process */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) pos = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) while (pos < buf_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) /* get packet len */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) pkt_len = usbtouch->type->get_pkt_len(buffer + pos,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) buf_len - pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) /* unknown packet: skip one byte */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) if (unlikely(!pkt_len)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) pos++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) /* full packet: process */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) if (likely((pkt_len > 0) && (pkt_len <= buf_len - pos))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) usbtouch_process_pkt(usbtouch, buffer + pos, pkt_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) /* incomplete packet: save in buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) memcpy(usbtouch->buffer, buffer + pos, buf_len - pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) usbtouch->buf_len = buf_len - pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) pos += pkt_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) out_flush_buf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) usbtouch->buf_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) static void usbtouch_irq(struct urb *urb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) struct usbtouch_usb *usbtouch = urb->context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) struct device *dev = &usbtouch->interface->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) switch (urb->status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) /* success */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) case -ETIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) /* this urb is timing out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) dev_dbg(dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) "%s - urb timed out - was the device unplugged?\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) case -ECONNRESET:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) case -ENOENT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) case -ESHUTDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) case -EPIPE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) /* this urb is terminated, clean up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) dev_dbg(dev, "%s - urb shutting down with status: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) __func__, urb->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) dev_dbg(dev, "%s - nonzero urb status received: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) __func__, urb->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) usbtouch->type->process_pkt(usbtouch, usbtouch->data, urb->actual_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) usb_mark_last_busy(interface_to_usbdev(usbtouch->interface));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) retval = usb_submit_urb(urb, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) dev_err(dev, "%s - usb_submit_urb failed with result: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) __func__, retval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) static int usbtouch_open(struct input_dev *input)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) struct usbtouch_usb *usbtouch = input_get_drvdata(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) usbtouch->irq->dev = interface_to_usbdev(usbtouch->interface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) r = usb_autopm_get_interface(usbtouch->interface) ? -EIO : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) if (r < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) mutex_lock(&usbtouch->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) if (!usbtouch->type->irq_always) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) if (usb_submit_urb(usbtouch->irq, GFP_KERNEL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) r = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) goto out_put;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) usbtouch->interface->needs_remote_wakeup = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) usbtouch->is_open = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) out_put:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) mutex_unlock(&usbtouch->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) usb_autopm_put_interface(usbtouch->interface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) static void usbtouch_close(struct input_dev *input)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) struct usbtouch_usb *usbtouch = input_get_drvdata(input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) mutex_lock(&usbtouch->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) if (!usbtouch->type->irq_always)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) usb_kill_urb(usbtouch->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) usbtouch->is_open = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) mutex_unlock(&usbtouch->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) r = usb_autopm_get_interface(usbtouch->interface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) usbtouch->interface->needs_remote_wakeup = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) if (!r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) usb_autopm_put_interface(usbtouch->interface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) static int usbtouch_suspend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) (struct usb_interface *intf, pm_message_t message)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) usb_kill_urb(usbtouch->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) static int usbtouch_resume(struct usb_interface *intf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) int result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) mutex_lock(&usbtouch->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) if (usbtouch->is_open || usbtouch->type->irq_always)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) result = usb_submit_urb(usbtouch->irq, GFP_NOIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) mutex_unlock(&usbtouch->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) static int usbtouch_reset_resume(struct usb_interface *intf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) /* reinit the device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) if (usbtouch->type->init) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) err = usbtouch->type->init(usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) dev_dbg(&intf->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) "%s - type->init() failed, err: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) __func__, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) /* restart IO if needed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) mutex_lock(&usbtouch->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) if (usbtouch->is_open)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) err = usb_submit_urb(usbtouch->irq, GFP_NOIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) mutex_unlock(&usbtouch->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) static void usbtouch_free_buffers(struct usb_device *udev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) struct usbtouch_usb *usbtouch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) usb_free_coherent(udev, usbtouch->data_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) usbtouch->data, usbtouch->data_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) kfree(usbtouch->buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) static struct usb_endpoint_descriptor *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) usbtouch_get_input_endpoint(struct usb_host_interface *interface)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) for (i = 0; i < interface->desc.bNumEndpoints; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) if (usb_endpoint_dir_in(&interface->endpoint[i].desc))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) return &interface->endpoint[i].desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) static int usbtouch_probe(struct usb_interface *intf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) const struct usb_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) struct usbtouch_usb *usbtouch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) struct input_dev *input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) struct usb_endpoint_descriptor *endpoint;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) struct usb_device *udev = interface_to_usbdev(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) struct usbtouch_device_info *type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) int err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) /* some devices are ignored */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) if (id->driver_info == DEVTYPE_IGNORE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) endpoint = usbtouch_get_input_endpoint(intf->cur_altsetting);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) if (!endpoint)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) input_dev = input_allocate_device();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) if (!usbtouch || !input_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) mutex_init(&usbtouch->pm_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) type = &usbtouch_dev_info[id->driver_info];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) usbtouch->type = type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) if (!type->process_pkt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) type->process_pkt = usbtouch_process_pkt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) usbtouch->data_size = type->rept_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) if (type->get_pkt_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) * When dealing with variable-length packets we should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) * not request more than wMaxPacketSize bytes at once
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) * as we do not know if there is more data coming or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) * we filled exactly wMaxPacketSize bytes and there is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) * nothing else.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) usbtouch->data_size = min(usbtouch->data_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) usb_endpoint_maxp(endpoint));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) usbtouch->data = usb_alloc_coherent(udev, usbtouch->data_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) GFP_KERNEL, &usbtouch->data_dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) if (!usbtouch->data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) if (type->get_pkt_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) usbtouch->buffer = kmalloc(type->rept_size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) if (!usbtouch->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) goto out_free_buffers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) usbtouch->irq = usb_alloc_urb(0, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) if (!usbtouch->irq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) dev_dbg(&intf->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) "%s - usb_alloc_urb failed: usbtouch->irq\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) goto out_free_buffers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) usbtouch->interface = intf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) usbtouch->input = input_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) if (udev->manufacturer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) strlcpy(usbtouch->name, udev->manufacturer, sizeof(usbtouch->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) if (udev->product) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) if (udev->manufacturer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) strlcat(usbtouch->name, " ", sizeof(usbtouch->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) strlcat(usbtouch->name, udev->product, sizeof(usbtouch->name));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) if (!strlen(usbtouch->name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) snprintf(usbtouch->name, sizeof(usbtouch->name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) "USB Touchscreen %04x:%04x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) le16_to_cpu(udev->descriptor.idVendor),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) le16_to_cpu(udev->descriptor.idProduct));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) usb_make_path(udev, usbtouch->phys, sizeof(usbtouch->phys));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) strlcat(usbtouch->phys, "/input0", sizeof(usbtouch->phys));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) input_dev->name = usbtouch->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) input_dev->phys = usbtouch->phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) usb_to_input_id(udev, &input_dev->id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) input_dev->dev.parent = &intf->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) input_set_drvdata(input_dev, usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) input_dev->open = usbtouch_open;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) input_dev->close = usbtouch_close;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) input_set_abs_params(input_dev, ABS_X, type->min_xc, type->max_xc, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) input_set_abs_params(input_dev, ABS_Y, type->min_yc, type->max_yc, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) if (type->max_press)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) input_set_abs_params(input_dev, ABS_PRESSURE, type->min_press,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) type->max_press, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) if (usb_endpoint_type(endpoint) == USB_ENDPOINT_XFER_INT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) usb_fill_int_urb(usbtouch->irq, udev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) usb_rcvintpipe(udev, endpoint->bEndpointAddress),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) usbtouch->data, usbtouch->data_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) usbtouch_irq, usbtouch, endpoint->bInterval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) usb_fill_bulk_urb(usbtouch->irq, udev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) usb_rcvbulkpipe(udev, endpoint->bEndpointAddress),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) usbtouch->data, usbtouch->data_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) usbtouch_irq, usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) usbtouch->irq->dev = udev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) usbtouch->irq->transfer_dma = usbtouch->data_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) /* device specific allocations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) if (type->alloc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) err = type->alloc(usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) dev_dbg(&intf->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) "%s - type->alloc() failed, err: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) __func__, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) goto out_free_urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) /* device specific initialisation*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) if (type->init) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) err = type->init(usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) dev_dbg(&intf->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) "%s - type->init() failed, err: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) __func__, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) goto out_do_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) err = input_register_device(usbtouch->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) dev_dbg(&intf->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) "%s - input_register_device failed, err: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) __func__, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) goto out_do_exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) usb_set_intfdata(intf, usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) if (usbtouch->type->irq_always) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) /* this can't fail */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) usb_autopm_get_interface(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) err = usb_submit_urb(usbtouch->irq, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) usb_autopm_put_interface(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) dev_err(&intf->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) "%s - usb_submit_urb failed with result: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) __func__, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) goto out_unregister_input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) out_unregister_input:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) input_unregister_device(input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) input_dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) out_do_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) if (type->exit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) type->exit(usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) out_free_urb:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) usb_free_urb(usbtouch->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) out_free_buffers:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) usbtouch_free_buffers(udev, usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) out_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) input_free_device(input_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) kfree(usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) static void usbtouch_disconnect(struct usb_interface *intf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) if (!usbtouch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) dev_dbg(&intf->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) "%s - usbtouch is initialized, cleaning up\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) usb_set_intfdata(intf, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) /* this will stop IO via close */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) input_unregister_device(usbtouch->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) usb_free_urb(usbtouch->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) if (usbtouch->type->exit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) usbtouch->type->exit(usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) usbtouch_free_buffers(interface_to_usbdev(intf), usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) kfree(usbtouch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) MODULE_DEVICE_TABLE(usb, usbtouch_devices);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) static struct usb_driver usbtouch_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) .name = "usbtouchscreen",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) .probe = usbtouch_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) .disconnect = usbtouch_disconnect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) .suspend = usbtouch_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) .resume = usbtouch_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) .reset_resume = usbtouch_reset_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) .id_table = usbtouch_devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) .supports_autosuspend = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) module_usb_driver(usbtouch_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) MODULE_AUTHOR("Daniel Ritz <daniel.ritz@gmx.ch>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) MODULE_DESCRIPTION("USB Touchscreen Driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) MODULE_ALIAS("touchkitusb");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) MODULE_ALIAS("itmtouch");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) MODULE_ALIAS("mtouchusb");