drivers/input/misc/cs40l50-vibra.c

Source file repositories/reference/linux-study-clean/drivers/input/misc/cs40l50-vibra.c

File Facts

System
Linux kernel
Corpus path
drivers/input/misc/cs40l50-vibra.c
Extension
.c
Size
14294 bytes
Lines
555
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 cs40l50_bank {
	enum cs40l50_bank_type type;
	u32 base_index;
	u32 max_index;
};

struct cs40l50_effect {
	enum cs40l50_bank_type type;
	struct list_head list;
	u32 gpio_reg;
	u32 index;
	int id;
};

/* Describes haptic interface of loaded DSP firmware */
struct cs40l50_vibra_dsp {
	struct cs40l50_bank *banks;
	u32 gpio_base_reg;
	u32 owt_offset_reg;
	u32 owt_size_reg;
	u32 owt_base_reg;
	u32 push_owt_cmd;
	u32 delete_owt_cmd;
	u32 stop_cmd;
	int (*write)(struct device *dev, struct regmap *regmap, u32 val);
};

/* Describes configuration and state of haptic operations */
struct cs40l50_vibra {
	struct device *dev;
	struct regmap *regmap;
	struct input_dev *input;
	struct workqueue_struct *vib_wq;
	struct list_head effect_head;
	struct cs40l50_vibra_dsp dsp;
};

struct cs40l50_work {
	struct cs40l50_vibra *vib;
	struct ff_effect *effect;
	struct work_struct work;
	s16 *custom_data;
	int custom_len;
	int count;
	int error;
};

static struct cs40l50_bank cs40l50_banks[] = {
	{
		.type =		CS40L50_WVFRM_BANK_RAM,
		.base_index =	CS40L50_RAM_INDEX_START,
		.max_index =	CS40L50_RAM_INDEX_END,
	},
	{
		.type =		CS40L50_WVFRM_BANK_ROM,
		.base_index =	CS40L50_ROM_INDEX_START,
		.max_index =	CS40L50_ROM_INDEX_END,
	},
	{
		.type =		CS40L50_WVFRM_BANK_OWT,
		.base_index =	CS40L50_RTH_INDEX_START,
		.max_index =	CS40L50_RTH_INDEX_END,
	},
};

static struct cs40l50_vibra_dsp cs40l50_dsp = {
	.banks =		cs40l50_banks,
	.gpio_base_reg =	CS40L50_GPIO_BASE,
	.owt_base_reg =		CS40L50_OWT_BASE,
	.owt_offset_reg =	CS40L50_OWT_NEXT,
	.owt_size_reg =		CS40L50_OWT_SIZE,
	.push_owt_cmd =		CS40L50_OWT_PUSH,
	.delete_owt_cmd =	CS40L50_OWT_DELETE,
	.stop_cmd =		CS40L50_STOP_PLAYBACK,
	.write =		cs40l50_dsp_write,
};

static struct cs40l50_effect *cs40l50_find_effect(int id, struct list_head *effect_head)
{
	struct cs40l50_effect *effect;

	list_for_each_entry(effect, effect_head, list)
		if (effect->id == id)
			return effect;

	return NULL;
}

static int cs40l50_effect_bank_set(struct cs40l50_work *work_data,
				   struct cs40l50_effect *effect)

Annotation

Implementation Notes