FILE
inv_icm45600_buffer.h
File preview with syntax highlighting.
linux-6.19.14/drivers/iio/imu/inv_icm45600/inv_icm45600_buffer.h
1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2/* Copyright (C) 2025 Invensense, Inc. */ 3 4#ifndef INV_ICM45600_BUFFER_H_ 5#define INV_ICM45600_BUFFER_H_ 6 7#include <linux/bits.h> 8#include <linux/limits.h> 9#include <linux/types.h> 10 11#include <asm/byteorder.h> 12 13#include <linux/iio/iio.h> 14 15struct inv_icm45600_state; 16 17#define INV_ICM45600_SENSOR_GYRO BIT(0) 18#define INV_ICM45600_SENSOR_ACCEL BIT(1) 19#define INV_ICM45600_SENSOR_TEMP BIT(2) 20 21/** 22 * struct inv_icm45600_fifo - FIFO state variables 23 * @on: reference counter for FIFO on. 24 * @en: bits field of INV_ICM45600_SENSOR_* for FIFO EN bits. 25 * @period: FIFO internal period. 26 * @watermark: watermark configuration values for accel and gyro. 27 * @watermark.gyro: requested watermark for gyro. 28 * @watermark.accel: requested watermark for accel. 29 * @watermark.eff_gyro: effective watermark for gyro. 30 * @watermark.eff_accel: effective watermark for accel. 31 * @count: number of bytes in the FIFO data buffer. 32 * @nb: gyro, accel and total samples in the FIFO data buffer. 33 * @data: FIFO data buffer aligned for DMA (8kB) 34 */ 35struct inv_icm45600_fifo { 36 unsigned int on; 37 unsigned int en; 38 u32 period; 39 struct { 40 unsigned int gyro; 41 unsigned int accel; 42 unsigned int eff_gyro; 43 unsigned int eff_accel; 44 } watermark; 45 size_t count; 46 struct { 47 size_t gyro; 48 size_t accel; 49 size_t total; 50 } nb; 51 u8 *data; 52}; 53 54/* FIFO data packet */ 55struct inv_icm45600_fifo_sensor_data { 56 __le16 x; 57 __le16 y; 58 __le16 z; 59} __packed; 60#define INV_ICM45600_DATA_INVALID S16_MIN 61 62static inline bool 63inv_icm45600_fifo_is_data_valid(const struct inv_icm45600_fifo_sensor_data *s) 64{ 65 s16 x, y, z; 66 67 x = le16_to_cpu(s->x); 68 y = le16_to_cpu(s->y); 69 z = le16_to_cpu(s->z); 70 71 return (x != INV_ICM45600_DATA_INVALID || 72 y != INV_ICM45600_DATA_INVALID || 73 z != INV_ICM45600_DATA_INVALID); 74} 75 76ssize_t inv_icm45600_fifo_decode_packet(const void *packet, 77 const struct inv_icm45600_fifo_sensor_data **accel, 78 const struct inv_icm45600_fifo_sensor_data **gyro, 79 const s8 **temp, 80 const __le16 **timestamp, unsigned int *odr); 81 82extern const struct iio_buffer_setup_ops inv_icm45600_buffer_ops; 83 84int inv_icm45600_buffer_init(struct inv_icm45600_state *st); 85 86void inv_icm45600_buffer_update_fifo_period(struct inv_icm45600_state *st); 87 88int inv_icm45600_buffer_set_fifo_en(struct inv_icm45600_state *st, 89 unsigned int fifo_en); 90 91int inv_icm45600_buffer_update_watermark(struct inv_icm45600_state *st); 92 93int inv_icm45600_buffer_fifo_read(struct inv_icm45600_state *st, 94 unsigned int max); 95 96int inv_icm45600_buffer_fifo_parse(struct inv_icm45600_state *st); 97 98int inv_icm45600_buffer_hwfifo_flush(struct inv_icm45600_state *st, 99 unsigned int count); 100 101#endif
~/
Read-only file preview.