drivers/input/touchscreen/sur40.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/sur40.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/sur40.c- Extension
.c- Size
- 32341 bytes
- Lines
- 1189
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/errno.hlinux/delay.hlinux/init.hlinux/slab.hlinux/module.hlinux/completion.hlinux/uaccess.hlinux/usb.hlinux/printk.hlinux/input.hlinux/input/mt.hlinux/usb/input.hlinux/videodev2.hmedia/v4l2-device.hmedia/v4l2-dev.hmedia/v4l2-ioctl.hmedia/v4l2-ctrls.hmedia/videobuf2-v4l2.hmedia/videobuf2-dma-sg.h
Detected Declarations
struct sur40_headerstruct sur40_blobstruct sur40_datastruct sur40_image_headerstruct sur40_statestruct sur40_bufferfunction sur40_commandfunction sur40_pokefunction sur40_set_preprocessorfunction sur40_set_vsvideofunction sur40_set_irlevelfunction sur40_initfunction sur40_openfunction sur40_closefunction sur40_report_blobfunction sur40_pollfunction sur40_process_videofunction sur40_input_setup_eventsfunction sur40_probefunction sur40_disconnectfunction sur40_queue_setupfunction sur40_buffer_preparefunction sur40_buffer_queuefunction return_all_buffersfunction list_for_each_entry_safefunction sur40_start_streamingfunction sur40_stop_streamingfunction sur40_vidioc_querycapfunction sur40_vidioc_enum_inputfunction sur40_vidioc_s_inputfunction sur40_vidioc_g_inputfunction sur40_vidioc_try_fmtfunction sur40_vidioc_s_fmtfunction sur40_vidioc_g_fmtfunction sur40_s_ctrlfunction sur40_ioctl_parmfunction sur40_vidioc_enum_fmtfunction sur40_vidioc_enum_framesizesfunction sur40_vidioc_enum_frameintervals
Annotated Snippet
struct sur40_header {
__le16 type; /* always 0x0001 */
__le16 count; /* count of blobs (if 0: continue prev. packet) */
__le32 packet_id; /* unique ID for all packets in one frame */
__le32 timestamp; /* milliseconds (inc. by 16 or 17 each frame) */
__le32 unknown; /* "epoch?" always 02/03 00 00 00 */
} __packed;
struct sur40_blob {
__le16 blob_id;
u8 action; /* 0x02 = enter/exit, 0x03 = update (?) */
u8 type; /* bitmask (0x01 blob, 0x02 touch, 0x04 tag) */
__le16 bb_pos_x; /* upper left corner of bounding box */
__le16 bb_pos_y;
__le16 bb_size_x; /* size of bounding box */
__le16 bb_size_y;
__le16 pos_x; /* finger tip position */
__le16 pos_y;
__le16 ctr_x; /* centroid position */
__le16 ctr_y;
__le16 axis_x; /* somehow related to major/minor axis, mostly: */
__le16 axis_y; /* axis_x == bb_size_y && axis_y == bb_size_x */
__le32 angle; /* orientation in radians relative to x axis -
actually an IEEE754 float, don't use in kernel */
__le32 area; /* size in pixels/pressure (?) */
u8 padding[24];
__le32 tag_id; /* valid when type == 0x04 (SUR40_TAG) */
__le32 unknown;
} __packed;
/* combined header/blob data */
struct sur40_data {
struct sur40_header header;
struct sur40_blob blobs[];
} __packed;
/* read 512 bytes from endpoint 0x82 -> get header below
* continue reading 16k blocks until header.size bytes read */
struct sur40_image_header {
__le32 magic; /* "SUBF" */
__le32 packet_id;
__le32 size; /* always 0x0007e900 = 960x540 */
__le32 timestamp; /* milliseconds (increases by 16 or 17 each frame) */
__le32 unknown; /* "epoch?" always 02/03 00 00 00 */
} __packed;
/* version information */
#define DRIVER_SHORT "sur40"
#define DRIVER_LONG "Samsung SUR40"
#define DRIVER_AUTHOR "Florian 'floe' Echtler <floe@butterbrot.org>"
#define DRIVER_DESC "Surface2.0/SUR40/PixelSense input driver"
/* vendor and device IDs */
#define ID_MICROSOFT 0x045e
#define ID_SUR40 0x0775
/* sensor resolution */
#define SENSOR_RES_X 1920
#define SENSOR_RES_Y 1080
/* touch data endpoint */
#define TOUCH_ENDPOINT 0x86
/* video data endpoint */
#define VIDEO_ENDPOINT 0x82
/* video header fields */
#define VIDEO_HEADER_MAGIC 0x46425553
#define VIDEO_PACKET_SIZE 16384
/* polling interval (ms) */
#define POLL_INTERVAL 1
/* maximum number of contacts FIXME: this is a guess? */
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/delay.h`, `linux/init.h`, `linux/slab.h`, `linux/module.h`, `linux/completion.h`, `linux/uaccess.h`.
- Detected declarations: `struct sur40_header`, `struct sur40_blob`, `struct sur40_data`, `struct sur40_image_header`, `struct sur40_state`, `struct sur40_buffer`, `function sur40_command`, `function sur40_poke`, `function sur40_set_preprocessor`, `function sur40_set_vsvideo`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.