drivers/input/touchscreen/usbtouchscreen.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/usbtouchscreen.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/usbtouchscreen.c- Extension
.c- Size
- 45530 bytes
- Lines
- 1801
- Domain
- Driver Families
- Bucket
- drivers/input
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/slab.hlinux/input.hlinux/module.hlinux/usb.hlinux/usb/input.hlinux/hid.hlinux/mutex.h
Detected Declarations
struct usbtouch_usbstruct usbtouch_device_infostruct usbtouch_usbstruct mtouch_privstruct nexio_privstruct nexio_touch_packetfunction e2i_initfunction e2i_read_datafunction egalax_initfunction egalax_read_datafunction egalax_get_pkt_lenfunction etouch_read_datafunction etouch_get_pkt_lenfunction panjit_read_datafunction mtouch_read_datafunction mtouch_get_fw_revisionfunction mtouch_allocfunction mtouch_initfunction mtouch_exitfunction mtouch_firmware_rev_showfunction mtouch_group_visiblefunction itm_read_datafunction eturbo_read_datafunction eturbo_get_pkt_lenfunction gunze_read_datafunction dmc_tsc10_initfunction dmc_tsc10_read_datafunction irtouch_read_datafunction tc45usb_read_datafunction idealtek_get_pkt_lenfunction idealtek_read_datafunction general_touch_read_datafunction gotop_read_datafunction jastec_read_datafunction zytronic_read_datafunction nexio_ack_completefunction nexio_initfunction nexio_exitfunction nexio_read_datafunction elo_read_datafunction usbtouch_process_pktfunction usbtouch_process_multifunction usbtouch_process_multifunction usbtouch_irqfunction usbtouch_start_iofunction usbtouch_openfunction usbtouch_closefunction scoped_guard
Annotated Snippet
struct usbtouch_device_info {
int min_xc, max_xc;
int min_yc, max_yc;
int min_press, max_press;
int rept_size;
/*
* Always service the USB devices irq not just when the input device is
* open. This is useful when devices have a watchdog which prevents us
* from periodically polling the device. Leave this unset unless your
* touchscreen device requires it, as it does consume more of the USB
* bandwidth.
*/
bool irq_always;
/*
* used to get the packet len. possible return values:
* > 0: packet len
* = 0: skip one byte
* < 0: -return value more bytes needed
*/
int (*get_pkt_len) (unsigned char *pkt, int len);
int (*read_data) (struct usbtouch_usb *usbtouch, unsigned char *pkt);
int (*alloc) (struct usbtouch_usb *usbtouch);
int (*init) (struct usbtouch_usb *usbtouch);
void (*exit) (struct usbtouch_usb *usbtouch);
};
/* a usbtouch device */
struct usbtouch_usb {
unsigned char *data;
dma_addr_t data_dma;
int data_size;
unsigned char *buffer;
int buf_len;
struct urb *irq;
struct usb_interface *interface;
struct input_dev *input;
const struct usbtouch_device_info *type;
struct mutex pm_mutex; /* serialize access to open/suspend */
bool is_open;
char name[128];
char phys[64];
void *priv;
int x, y;
int touch, press;
void (*process_pkt)(struct usbtouch_usb *usbtouch, unsigned char *pkt, int len);
};
/*****************************************************************************
* e2i Part
*/
#ifdef CONFIG_TOUCHSCREEN_USB_E2I
static int e2i_init(struct usbtouch_usb *usbtouch)
{
int ret;
struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
0x01, 0x02, 0x0000, 0x0081,
NULL, 0, USB_CTRL_SET_TIMEOUT);
dev_dbg(&usbtouch->interface->dev,
"%s - usb_control_msg - E2I_RESET - bytes|err: %d\n",
__func__, ret);
return ret;
}
static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
{
int tmp = (pkt[0] << 8) | pkt[1];
dev->x = (pkt[2] << 8) | pkt[3];
dev->y = (pkt[4] << 8) | pkt[5];
tmp = tmp - 0xA000;
dev->touch = (tmp > 0);
dev->press = (tmp > 0 ? tmp : 0);
return 1;
}
static const struct usbtouch_device_info e2i_dev_info = {
.min_xc = 0x0,
.max_xc = 0x7fff,
.min_yc = 0x0,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/input.h`, `linux/module.h`, `linux/usb.h`, `linux/usb/input.h`, `linux/hid.h`, `linux/mutex.h`.
- Detected declarations: `struct usbtouch_usb`, `struct usbtouch_device_info`, `struct usbtouch_usb`, `struct mtouch_priv`, `struct nexio_priv`, `struct nexio_touch_packet`, `function e2i_init`, `function e2i_read_data`, `function egalax_init`, `function egalax_read_data`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.