drivers/hid/usbhid/hid-pidff.c

Source file repositories/reference/linux-study-clean/drivers/hid/usbhid/hid-pidff.c

File Facts

System
Linux kernel
Corpus path
drivers/hid/usbhid/hid-pidff.c
Extension
.c
Size
45898 bytes
Lines
1647
Domain
Driver Families
Bucket
drivers/hid
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

struct pidff_usage {
	struct hid_field *field;
	s32 *value;
};

struct pidff_effect {
	int pid_id;
	int is_infinite;
	unsigned int loop_count;
};

struct pidff_device {
	struct hid_device *hid;

	struct hid_report *reports[ARRAY_SIZE(pidff_reports)];

	struct pidff_usage set_effect[ARRAY_SIZE(pidff_set_effect)];
	struct pidff_usage set_envelope[ARRAY_SIZE(pidff_set_envelope)];
	struct pidff_usage set_condition[ARRAY_SIZE(pidff_set_condition)];
	struct pidff_usage set_periodic[ARRAY_SIZE(pidff_set_periodic)];
	struct pidff_usage set_constant[ARRAY_SIZE(pidff_set_constant)];
	struct pidff_usage set_ramp[ARRAY_SIZE(pidff_set_ramp)];

	struct pidff_usage device_gain[ARRAY_SIZE(pidff_device_gain)];
	struct pidff_usage block_load[ARRAY_SIZE(pidff_block_load)];
	struct pidff_usage pool[ARRAY_SIZE(pidff_pool)];
	struct pidff_usage effect_operation[ARRAY_SIZE(pidff_effect_operation)];
	struct pidff_usage block_free[ARRAY_SIZE(pidff_block_free)];

	struct pidff_effect effect[PID_EFFECTS_MAX];

	/*
	 * Special field is a field that is not composed of
	 * usage<->value pairs that pidff_usage values are
	 */

	/* Special field in create_new_effect */
	struct hid_field *create_new_effect_type;

	/* Special fields in set_effect */
	struct hid_field *set_effect_type;
	struct hid_field *effect_direction;
	struct hid_field *axes_enable;

	/* Special field in device_control */
	struct hid_field *device_control;

	/* Special field in block_load */
	struct hid_field *block_load_status;

	/* Special field in effect_operation */
	struct hid_field *effect_operation_status;

	int control_id[ARRAY_SIZE(pidff_device_control)];
	int type_id[ARRAY_SIZE(pidff_effect_types)];
	int status_id[ARRAY_SIZE(pidff_block_load_status)];
	int operation_id[ARRAY_SIZE(pidff_effect_operation_status)];
	int direction_axis_id[ARRAY_SIZE(pidff_direction_axis)];

	u32 quirks;
	u8 effect_count;
	u8 axis_count;
};

static int pidff_is_effect_conditional(struct ff_effect *effect)
{
	return effect->type == FF_SPRING  ||
	       effect->type == FF_DAMPER  ||
	       effect->type == FF_INERTIA ||
	       effect->type == FF_FRICTION;
}

static int pidff_is_duration_infinite(u16 duration)
{
	return duration == FF_INFINITE || duration == PID_INFINITE;
}

/*
 * Get PID effect index from FF effect type.
 * Return 0 if invalid.
 */
static int pidff_effect_ff_to_pid(struct ff_effect *effect)
{
	switch (effect->type) {
	case FF_CONSTANT:
		return PID_CONSTANT;
	case FF_RAMP:
		return PID_RAMP;
	case FF_SPRING:
		return PID_SPRING;

Annotation

Implementation Notes