drivers/input/keyboard/cap11xx.c

Source file repositories/reference/linux-study-clean/drivers/input/keyboard/cap11xx.c

File Facts

System
Linux kernel
Corpus path
drivers/input/keyboard/cap11xx.c
Extension
.c
Size
18749 bytes
Lines
679
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 cap11xx_led {
	struct cap11xx_priv *priv;
	struct led_classdev cdev;
	u32 reg;
};
#endif

struct cap11xx_priv {
	struct regmap *regmap;
	struct device *dev;
	struct input_dev *idev;
	const struct cap11xx_hw_model *model;

	struct cap11xx_led *leds;
	int num_leds;

	/* config */
	u8 analog_gain;
	u8 sensitivity_delta_sense;
	u8 signal_guard_inputs_mask;
	u32 thresholds[8];
	u32 calib_sensitivities[8];
	u32 keycodes[];
};

struct cap11xx_hw_model {
	u8 product_id;
	unsigned int num_channels;
	unsigned int num_leds;
	bool has_gain;
	bool has_irq_config;
	bool has_sensitivity_control;
	bool has_signal_guard;
};

static const struct reg_default cap11xx_reg_defaults[] = {
	{ CAP11XX_REG_MAIN_CONTROL,		0x00 },
	{ CAP11XX_REG_GENERAL_STATUS,		0x00 },
	{ CAP11XX_REG_SENSOR_INPUT,		0x00 },
	{ CAP11XX_REG_NOISE_FLAG_STATUS,	0x00 },
	{ CAP11XX_REG_SENSITIVITY_CONTROL,	0x2f },
	{ CAP11XX_REG_CONFIG,			0x20 },
	{ CAP11XX_REG_SENSOR_ENABLE,		0x3f },
	{ CAP11XX_REG_SENSOR_CONFIG,		0xa4 },
	{ CAP11XX_REG_SENSOR_CONFIG2,		0x07 },
	{ CAP11XX_REG_SAMPLING_CONFIG,		0x39 },
	{ CAP11XX_REG_CALIBRATION,		0x00 },
	{ CAP11XX_REG_INT_ENABLE,		0x3f },
	{ CAP11XX_REG_REPEAT_RATE,		0x3f },
	{ CAP11XX_REG_MT_CONFIG,		0x80 },
	{ CAP11XX_REG_MT_PATTERN_CONFIG,	0x00 },
	{ CAP11XX_REG_MT_PATTERN,		0x3f },
	{ CAP11XX_REG_RECALIB_CONFIG,		0x8a },
	{ CAP11XX_REG_SENSOR_THRESH(0),		0x40 },
	{ CAP11XX_REG_SENSOR_THRESH(1),		0x40 },
	{ CAP11XX_REG_SENSOR_THRESH(2),		0x40 },
	{ CAP11XX_REG_SENSOR_THRESH(3),		0x40 },
	{ CAP11XX_REG_SENSOR_THRESH(4),		0x40 },
	{ CAP11XX_REG_SENSOR_THRESH(5),		0x40 },
	{ CAP11XX_REG_SENSOR_NOISE_THRESH,	0x01 },
	{ CAP11XX_REG_STANDBY_CHANNEL,		0x00 },
	{ CAP11XX_REG_STANDBY_CONFIG,		0x39 },
	{ CAP11XX_REG_STANDBY_SENSITIVITY,	0x02 },
	{ CAP11XX_REG_STANDBY_THRESH,		0x40 },
	{ CAP11XX_REG_CONFIG2,			0x40 },
	{ CAP11XX_REG_LED_POLARITY,		0x00 },
	{ CAP11XX_REG_SENSOR_CALIB_LSB1,	0x00 },
	{ CAP11XX_REG_SENSOR_CALIB_LSB2,	0x00 },
};

static bool cap11xx_volatile_reg(struct device *dev, unsigned int reg)
{
	switch (reg) {
	case CAP11XX_REG_MAIN_CONTROL:
	case CAP11XX_REG_SENSOR_INPUT:
	case CAP11XX_REG_SENOR_DELTA(0):
	case CAP11XX_REG_SENOR_DELTA(1):
	case CAP11XX_REG_SENOR_DELTA(2):
	case CAP11XX_REG_SENOR_DELTA(3):
	case CAP11XX_REG_SENOR_DELTA(4):
	case CAP11XX_REG_SENOR_DELTA(5):
		return true;
	}

	return false;
}

static const struct regmap_config cap11xx_regmap_config = {
	.reg_bits = 8,
	.val_bits = 8,

Annotation

Implementation Notes