drivers/input/misc/adxl34x.c
Source file repositories/reference/linux-study-clean/drivers/input/misc/adxl34x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/misc/adxl34x.c- Extension
.c- Size
- 22645 bytes
- Lines
- 873
- 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.
- 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/device.hlinux/delay.hlinux/export.hlinux/input.hlinux/interrupt.hlinux/irq.hlinux/slab.hlinux/workqueue.hlinux/input/adxl34x.hlinux/module.hadxl34x.h
Detected Declarations
struct axis_triplestruct adxl34xfunction adxl34x_get_triplefunction adxl34x_service_ev_fifofunction adxl34x_report_key_singlefunction adxl34x_send_key_eventsfunction adxl34x_do_tapfunction adxl34x_irqfunction __adxl34x_disablefunction __adxl34x_enablefunction adxl34x_suspendfunction adxl34x_resumefunction adxl34x_disable_showfunction adxl34x_disable_storefunction adxl34x_calibrate_showfunction adxl34x_calibrate_storefunction adxl34x_rate_showfunction adxl34x_rate_storefunction adxl34x_autosleep_showfunction adxl34x_autosleep_storefunction adxl34x_position_showfunction adxl34x_write_storefunction adxl34x_input_openfunction adxl34x_input_closeexport adxl34x_groupsexport adxl34x_probe
Annotated Snippet
struct axis_triple {
int x;
int y;
int z;
};
struct adxl34x {
struct device *dev;
struct input_dev *input;
struct mutex mutex; /* reentrant protection for struct */
struct adxl34x_platform_data pdata;
struct axis_triple swcal;
struct axis_triple hwcal;
struct axis_triple saved;
char phys[32];
unsigned orient2d_saved;
unsigned orient3d_saved;
bool disabled; /* P: mutex */
bool opened; /* P: mutex */
bool suspended; /* P: mutex */
bool fifo_delay;
int irq;
unsigned model;
unsigned int_mask;
const struct adxl34x_bus_ops *bops;
};
static const struct adxl34x_platform_data adxl34x_default_init = {
.tap_threshold = 35,
.tap_duration = 3,
.tap_latency = 20,
.tap_window = 20,
.tap_axis_control = ADXL_TAP_X_EN | ADXL_TAP_Y_EN | ADXL_TAP_Z_EN,
.act_axis_control = 0xFF,
.activity_threshold = 6,
.inactivity_threshold = 4,
.inactivity_time = 3,
.free_fall_threshold = 8,
.free_fall_time = 0x20,
.data_rate = 8,
.data_range = ADXL_FULL_RES,
.ev_type = EV_ABS,
.ev_code_x = ABS_X, /* EV_REL */
.ev_code_y = ABS_Y, /* EV_REL */
.ev_code_z = ABS_Z, /* EV_REL */
.ev_code_tap = {BTN_TOUCH, BTN_TOUCH, BTN_TOUCH}, /* EV_KEY {x,y,z} */
.power_mode = ADXL_AUTO_SLEEP | ADXL_LINK,
.fifo_mode = ADXL_FIFO_STREAM,
.watermark = 0,
};
static void adxl34x_get_triple(struct adxl34x *ac, struct axis_triple *axis)
{
__le16 buf[3];
ac->bops->read_block(ac->dev, DATAX0, DATAZ1 - DATAX0 + 1, buf);
guard(mutex)(&ac->mutex);
ac->saved.x = (s16) le16_to_cpu(buf[0]);
axis->x = ac->saved.x;
ac->saved.y = (s16) le16_to_cpu(buf[1]);
axis->y = ac->saved.y;
ac->saved.z = (s16) le16_to_cpu(buf[2]);
axis->z = ac->saved.z;
}
static void adxl34x_service_ev_fifo(struct adxl34x *ac)
{
struct adxl34x_platform_data *pdata = &ac->pdata;
struct axis_triple axis;
adxl34x_get_triple(ac, &axis);
input_event(ac->input, pdata->ev_type, pdata->ev_code_x,
axis.x - ac->swcal.x);
input_event(ac->input, pdata->ev_type, pdata->ev_code_y,
axis.y - ac->swcal.y);
input_event(ac->input, pdata->ev_type, pdata->ev_code_z,
axis.z - ac->swcal.z);
}
static void adxl34x_report_key_single(struct input_dev *input, int key)
{
input_report_key(input, key, true);
Annotation
- Immediate include surface: `linux/device.h`, `linux/delay.h`, `linux/export.h`, `linux/input.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/slab.h`, `linux/workqueue.h`.
- Detected declarations: `struct axis_triple`, `struct adxl34x`, `function adxl34x_get_triple`, `function adxl34x_service_ev_fifo`, `function adxl34x_report_key_single`, `function adxl34x_send_key_events`, `function adxl34x_do_tap`, `function adxl34x_irq`, `function __adxl34x_disable`, `function __adxl34x_enable`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: integration implementation candidate.
- 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.