drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.c
Source file repositories/reference/linux-study-clean/drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.c- Extension
.c- Size
- 16039 bytes
- Lines
- 559
- Domain
- Driver Families
- Bucket
- drivers/iio
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/delay.hlinux/device.hlinux/err.hlinux/minmax.hlinux/mutex.hlinux/pm_runtime.hlinux/regmap.hlinux/time.hlinux/types.hasm/byteorder.hlinux/iio/buffer.hlinux/iio/common/inv_sensors_timestamp.hlinux/iio/iio.hinv_icm45600_buffer.hinv_icm45600.h
Detected Declarations
struct inv_icm45600_fifo_1sensor_packetstruct inv_icm45600_fifo_2sensors_packetfunction inv_icm45600_fifo_decode_packetfunction inv_icm45600_buffer_update_fifo_periodfunction inv_icm45600_buffer_set_fifo_enfunction inv_icm45600_wm_truncatefunction inv_icm45600_buffer_update_watermarkfunction inv_icm45600_buffer_preenablefunction inv_icm45600_buffer_postenablefunction inv_icm45600_buffer_predisablefunction _inv_icm45600_buffer_postdisablefunction inv_icm45600_buffer_postdisablefunction inv_icm45600_buffer_fifo_readfunction inv_icm45600_buffer_fifo_parsefunction inv_icm45600_buffer_hwfifo_flushfunction inv_icm45600_buffer_init
Annotated Snippet
struct inv_icm45600_fifo_1sensor_packet {
u8 header;
struct inv_icm45600_fifo_sensor_data data;
s8 temp;
} __packed;
struct inv_icm45600_fifo_2sensors_packet {
u8 header;
struct inv_icm45600_fifo_sensor_data accel;
struct inv_icm45600_fifo_sensor_data gyro;
s8 temp;
__le16 timestamp;
} __packed;
ssize_t inv_icm45600_fifo_decode_packet(const void *packet,
const struct inv_icm45600_fifo_sensor_data **accel,
const struct inv_icm45600_fifo_sensor_data **gyro,
const s8 **temp,
const __le16 **timestamp, unsigned int *odr)
{
const struct inv_icm45600_fifo_1sensor_packet *pack1 = packet;
const struct inv_icm45600_fifo_2sensors_packet *pack2 = packet;
u8 header = *((const u8 *)packet);
/* FIFO extended header */
if (header & INV_ICM45600_FIFO_EXT_HEADER) {
/* Not yet supported */
return 0;
}
/* handle odr flags. */
*odr = 0;
if (header & INV_ICM45600_FIFO_HEADER_ODR_GYRO)
*odr |= INV_ICM45600_SENSOR_GYRO;
if (header & INV_ICM45600_FIFO_HEADER_ODR_ACCEL)
*odr |= INV_ICM45600_SENSOR_ACCEL;
/* Accel + Gyro data are present. */
if ((header & INV_ICM45600_FIFO_HEADER_ACCEL) &&
(header & INV_ICM45600_FIFO_HEADER_GYRO)) {
*accel = &pack2->accel;
*gyro = &pack2->gyro;
*temp = &pack2->temp;
*timestamp = &pack2->timestamp;
return sizeof(*pack2);
}
/* Accel data only. */
if (header & INV_ICM45600_FIFO_HEADER_ACCEL) {
*accel = &pack1->data;
*gyro = NULL;
*temp = &pack1->temp;
*timestamp = NULL;
return sizeof(*pack1);
}
/* Gyro data only. */
if (header & INV_ICM45600_FIFO_HEADER_GYRO) {
*accel = NULL;
*gyro = &pack1->data;
*temp = &pack1->temp;
*timestamp = NULL;
return sizeof(*pack1);
}
/* Invalid packet if here. */
return -EINVAL;
}
void inv_icm45600_buffer_update_fifo_period(struct inv_icm45600_state *st)
{
u32 period_gyro, period_accel;
if (st->fifo.en & INV_ICM45600_SENSOR_GYRO)
period_gyro = inv_icm45600_odr_to_period(st->conf.gyro.odr);
else
period_gyro = U32_MAX;
if (st->fifo.en & INV_ICM45600_SENSOR_ACCEL)
period_accel = inv_icm45600_odr_to_period(st->conf.accel.odr);
else
period_accel = U32_MAX;
st->fifo.period = min(period_gyro, period_accel);
}
int inv_icm45600_buffer_set_fifo_en(struct inv_icm45600_state *st,
unsigned int fifo_en)
{
unsigned int mask;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/delay.h`, `linux/device.h`, `linux/err.h`, `linux/minmax.h`, `linux/mutex.h`, `linux/pm_runtime.h`, `linux/regmap.h`.
- Detected declarations: `struct inv_icm45600_fifo_1sensor_packet`, `struct inv_icm45600_fifo_2sensors_packet`, `function inv_icm45600_fifo_decode_packet`, `function inv_icm45600_buffer_update_fifo_period`, `function inv_icm45600_buffer_set_fifo_en`, `function inv_icm45600_wm_truncate`, `function inv_icm45600_buffer_update_watermark`, `function inv_icm45600_buffer_preenable`, `function inv_icm45600_buffer_postenable`, `function inv_icm45600_buffer_predisable`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
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.