drivers/input/mouse/bcm5974.c

Source file repositories/reference/linux-study-clean/drivers/input/mouse/bcm5974.c

File Facts

System
Linux kernel
Corpus path
drivers/input/mouse/bcm5974.c
Extension
.c
Size
32654 bytes
Lines
1065
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct bt_data {
	u8 unknown1;		/* constant */
	u8 button;		/* left button */
	u8 rel_x;		/* relative x coordinate */
	u8 rel_y;		/* relative y coordinate */
};

/* trackpad header types */
enum tp_type {
	TYPE1,			/* plain trackpad */
	TYPE2,			/* button integrated in trackpad */
	TYPE3,			/* additional header fields since June 2013 */
	TYPE4			/* additional header field for pressure data */
};

/* trackpad finger data offsets, le16-aligned */
#define HEADER_TYPE1		(13 * sizeof(__le16))
#define HEADER_TYPE2		(15 * sizeof(__le16))
#define HEADER_TYPE3		(19 * sizeof(__le16))
#define HEADER_TYPE4		(23 * sizeof(__le16))

/* trackpad button data offsets */
#define BUTTON_TYPE1		0
#define BUTTON_TYPE2		15
#define BUTTON_TYPE3		23
#define BUTTON_TYPE4		31

/* list of device capability bits */
#define HAS_INTEGRATED_BUTTON	1

/* trackpad finger data block size */
#define FSIZE_TYPE1		(14 * sizeof(__le16))
#define FSIZE_TYPE2		(14 * sizeof(__le16))
#define FSIZE_TYPE3		(14 * sizeof(__le16))
#define FSIZE_TYPE4		(15 * sizeof(__le16))

/* offset from header to finger struct */
#define DELTA_TYPE1		(0 * sizeof(__le16))
#define DELTA_TYPE2		(0 * sizeof(__le16))
#define DELTA_TYPE3		(0 * sizeof(__le16))
#define DELTA_TYPE4		(1 * sizeof(__le16))

/* usb control message mode switch data */
#define USBMSG_TYPE1		8, 0x300, 0, 0, 0x1, 0x8
#define USBMSG_TYPE2		8, 0x300, 0, 0, 0x1, 0x8
#define USBMSG_TYPE3		8, 0x300, 0, 0, 0x1, 0x8
#define USBMSG_TYPE4		2, 0x302, 2, 1, 0x1, 0x0

/* Wellspring initialization constants */
#define BCM5974_WELLSPRING_MODE_READ_REQUEST_ID		1
#define BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID	9

/* trackpad finger structure, le16-aligned */
struct tp_finger {
	__le16 origin;		/* zero when switching track finger */
	__le16 abs_x;		/* absolute x coodinate */
	__le16 abs_y;		/* absolute y coodinate */
	__le16 rel_x;		/* relative x coodinate */
	__le16 rel_y;		/* relative y coodinate */
	__le16 tool_major;	/* tool area, major axis */
	__le16 tool_minor;	/* tool area, minor axis */
	__le16 orientation;	/* 16384 when point, else 15 bit angle */
	__le16 touch_major;	/* touch area, major axis */
	__le16 touch_minor;	/* touch area, minor axis */
	__le16 unused[2];	/* zeros */
	__le16 pressure;	/* pressure on forcetouch touchpad */
	__le16 multi;		/* one finger: varies, more fingers: constant */
} __attribute__((packed,aligned(2)));

/* trackpad finger data size, empirically at least ten fingers */
#define MAX_FINGERS		16
#define MAX_FINGER_ORIENTATION	16384

/* device-specific parameters */
struct bcm5974_param {
	int snratio;		/* signal-to-noise ratio */
	int min;		/* device minimum reading */
	int max;		/* device maximum reading */
};

/* device-specific configuration */
struct bcm5974_config {
	int ansi, iso, jis;	/* the product id of this device */
	int caps;		/* device capability bitmask */
	int bt_ep;		/* the endpoint of the button interface */
	int bt_datalen;		/* data length of the button interface */
	int tp_ep;		/* the endpoint of the trackpad interface */
	enum tp_type tp_type;	/* type of trackpad interface */
	int tp_header;		/* bytes in header block */
	int tp_datalen;		/* data length of the trackpad interface */

Annotation

Implementation Notes