drivers/input/misc/da7280.c
Source file repositories/reference/linux-study-clean/drivers/input/misc/da7280.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/misc/da7280.c- Extension
.c- Size
- 34917 bytes
- Lines
- 1329
- 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.
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/bitops.hlinux/err.hlinux/i2c.hlinux/input.hlinux/interrupt.hlinux/module.hlinux/pwm.hlinux/regmap.hlinux/workqueue.hlinux/uaccess.h
Detected Declarations
struct da7280_gpi_ctlstruct da7280_hapticenum da7280_haptic_dev_tenum da7280_op_modeenum da7280_custom_effect_paramenum da7280_custom_gpi_effect_paramfunction da7280_volatile_registerfunction da7280_haptic_mem_updatefunction da7280_haptic_set_pwmfunction da7280_haptic_activatefunction da7280_haptic_deactivatefunction da7280_haptic_workfunction da7280_haptics_upload_effectfunction da7280_haptics_playbackfunction da7280_haptic_startfunction da7280_haptic_stopfunction da7280_haptic_openfunction da7280_haptic_closefunction da7280_haptic_of_mode_strfunction da7280_haptic_of_gpi_mode_strfunction da7280_haptic_of_gpi_pol_strfunction da7280_haptic_of_volt_rating_setfunction da7280_parse_propertiesfunction da7280_irq_handlerfunction da7280_initfunction da7280_probefunction da7280_suspendfunction da7280_resumefunction scoped_guard
Annotated Snippet
struct da7280_gpi_ctl {
u8 seq_id;
u8 mode;
u8 polarity;
};
struct da7280_haptic {
struct regmap *regmap;
struct input_dev *input_dev;
struct device *dev;
struct i2c_client *client;
struct pwm_device *pwm_dev;
struct work_struct work;
int val;
u16 gain;
s16 level;
u8 dev_type;
u8 op_mode;
u8 const_op_mode;
u8 periodic_op_mode;
u16 nommax;
u16 absmax;
u32 imax;
u32 impd;
u32 resonant_freq_h;
u32 resonant_freq_l;
bool bemf_sense_en;
bool freq_track_en;
bool acc_en;
bool rapid_stop_en;
bool amp_pid_en;
u8 ps_seq_id;
u8 ps_seq_loop;
struct da7280_gpi_ctl gpi_ctl[3];
bool mem_update;
u8 snp_mem[DA7280_SNP_MEM_SIZE];
bool active;
bool suspended;
};
static bool da7280_volatile_register(struct device *dev, unsigned int reg)
{
switch (reg) {
case DA7280_IRQ_EVENT1:
case DA7280_IRQ_EVENT_WARNING_DIAG:
case DA7280_IRQ_EVENT_SEQ_DIAG:
case DA7280_IRQ_STATUS1:
case DA7280_TOP_CTL1:
return true;
default:
return false;
}
}
static const struct regmap_config da7280_haptic_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = DA7280_SNP_MEM_MAX,
.volatile_reg = da7280_volatile_register,
};
static int da7280_haptic_mem_update(struct da7280_haptic *haptics)
{
unsigned int val;
int error;
/* The patterns should be updated when haptic is not working */
error = regmap_read(haptics->regmap, DA7280_IRQ_STATUS1, &val);
if (error)
return error;
if (val & DA7280_STA_WARNING_MASK) {
dev_warn(haptics->dev,
"Warning! Please check HAPTIC status.\n");
return -EBUSY;
}
/* Patterns are not updated if the lock bit is enabled */
val = 0;
error = regmap_read(haptics->regmap, DA7280_MEM_CTL2, &val);
if (error)
return error;
if (~val & DA7280_WAV_MEM_LOCK_MASK) {
dev_warn(haptics->dev, "Please unlock the bit first\n");
return -EACCES;
}
/* Set to Inactive mode to make sure safety */
error = regmap_update_bits(haptics->regmap,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitops.h`, `linux/err.h`, `linux/i2c.h`, `linux/input.h`, `linux/interrupt.h`, `linux/module.h`, `linux/pwm.h`.
- Detected declarations: `struct da7280_gpi_ctl`, `struct da7280_haptic`, `enum da7280_haptic_dev_t`, `enum da7280_op_mode`, `enum da7280_custom_effect_param`, `enum da7280_custom_gpi_effect_param`, `function da7280_volatile_register`, `function da7280_haptic_mem_update`, `function da7280_haptic_set_pwm`, `function da7280_haptic_activate`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.