drivers/input/rmi4/rmi_2d_sensor.c

Source file repositories/reference/linux-study-clean/drivers/input/rmi4/rmi_2d_sensor.c

File Facts

System
Linux kernel
Corpus path
drivers/input/rmi4/rmi_2d_sensor.c
Extension
.c
Size
8641 bytes
Lines
332
Domain
Driver Families
Bucket
drivers/input
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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

if (obj->type == RMI_2D_OBJECT_STYLUS) {
			major = max(1, major);
			minor = max(1, minor);
		}

		input_event(sensor->input, EV_ABS, ABS_MT_POSITION_X, obj->x);
		input_event(sensor->input, EV_ABS, ABS_MT_POSITION_Y, obj->y);
		input_event(sensor->input, EV_ABS, ABS_MT_ORIENTATION, wide);
		input_event(sensor->input, EV_ABS, ABS_MT_PRESSURE, obj->z);
		input_event(sensor->input, EV_ABS, ABS_MT_TOUCH_MAJOR, major);
		input_event(sensor->input, EV_ABS, ABS_MT_TOUCH_MINOR, minor);

		rmi_dbg(RMI_DEBUG_2D_SENSOR, &sensor->input->dev,
			"%s: obj[%d]: type: 0x%02x X: %d Y: %d Z: %d WX: %d WY: %d\n",
			__func__, slot, obj->type, obj->x, obj->y, obj->z,
			obj->wx, obj->wy);
	}
}
EXPORT_SYMBOL_GPL(rmi_2d_sensor_abs_report);

void rmi_2d_sensor_rel_report(struct rmi_2d_sensor *sensor, int x, int y)
{
	struct rmi_2d_axis_alignment *axis_align = &sensor->axis_align;

	x = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)x));
	y = min(RMI_2D_REL_POS_MAX, max(RMI_2D_REL_POS_MIN, (int)y));

	if (axis_align->flip_x)
		x = min(RMI_2D_REL_POS_MAX, -x);

	if (axis_align->flip_y)
		y = min(RMI_2D_REL_POS_MAX, -y);

	if (axis_align->swap_axes)
		swap(x, y);

	if (x || y) {
		input_report_rel(sensor->input, REL_X, x);
		input_report_rel(sensor->input, REL_Y, y);
	}
}
EXPORT_SYMBOL_GPL(rmi_2d_sensor_rel_report);

static void rmi_2d_sensor_set_input_params(struct rmi_2d_sensor *sensor)
{
	struct input_dev *input = sensor->input;
	int res_x;
	int res_y;
	int max_x, max_y;
	int input_flags = 0;

	if (sensor->report_abs) {
		sensor->min_x = sensor->axis_align.clip_x_low;
		if (sensor->axis_align.clip_x_high)
			sensor->max_x = min(sensor->max_x,
				sensor->axis_align.clip_x_high);

		sensor->min_y = sensor->axis_align.clip_y_low;
		if (sensor->axis_align.clip_y_high)
			sensor->max_y = min(sensor->max_y,
				sensor->axis_align.clip_y_high);

		set_bit(EV_ABS, input->evbit);

		max_x = sensor->max_x;
		max_y = sensor->max_y;
		if (sensor->axis_align.swap_axes)
			swap(max_x, max_y);
		input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_x, 0, 0);
		input_set_abs_params(input, ABS_MT_POSITION_Y, 0, max_y, 0, 0);

		if (sensor->x_mm && sensor->y_mm) {
			res_x = (sensor->max_x - sensor->min_x) / sensor->x_mm;
			res_y = (sensor->max_y - sensor->min_y) / sensor->y_mm;
			if (sensor->axis_align.swap_axes)
				swap(res_x, res_y);

			input_abs_set_res(input, ABS_X, res_x);
			input_abs_set_res(input, ABS_Y, res_y);

			input_abs_set_res(input, ABS_MT_POSITION_X, res_x);
			input_abs_set_res(input, ABS_MT_POSITION_Y, res_y);

			if (!sensor->dmax)
				sensor->dmax = DMAX * res_x;
		}

		input_set_abs_params(input, ABS_MT_PRESSURE, 0, 0xff, 0, 0);
		input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 0x0f, 0, 0);
		input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0, 0x0f, 0, 0);

Annotation

Implementation Notes