linux/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright (C) 2020 Invensense, Inc.
 */

#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/delay.h>

#include <linux/iio/buffer.h>
#include <linux/iio/common/inv_sensors_timestamp.h>
#include <linux/iio/iio.h>

#include "inv_icm42600.h"
#include "inv_icm42600_buffer.h"

/* FIFO header: 1 byte */
#define INV_ICM42600_FIFO_HEADER_MSG
#define INV_ICM42600_FIFO_HEADER_ACCEL
#define INV_ICM42600_FIFO_HEADER_GYRO
#define INV_ICM42600_FIFO_HEADER_TMST_FSYNC
#define INV_ICM42600_FIFO_HEADER_ODR_ACCEL
#define INV_ICM42600_FIFO_HEADER_ODR_GYRO

struct inv_icm42600_fifo_1sensor_packet {} __packed;
#define INV_ICM42600_FIFO_1SENSOR_PACKET_SIZE

struct inv_icm42600_fifo_2sensors_packet {} __packed;
#define INV_ICM42600_FIFO_2SENSORS_PACKET_SIZE

ssize_t inv_icm42600_fifo_decode_packet(const void *packet, const void **accel,
					const void **gyro, const int8_t **temp,
					const void **timestamp, unsigned int *odr)
{}

void inv_icm42600_buffer_update_fifo_period(struct inv_icm42600_state *st)
{}

int inv_icm42600_buffer_set_fifo_en(struct inv_icm42600_state *st,
				    unsigned int fifo_en)
{}

static size_t inv_icm42600_get_packet_size(unsigned int fifo_en)
{}

static unsigned int inv_icm42600_wm_truncate(unsigned int watermark,
					     size_t packet_size)
{}

/**
 * inv_icm42600_buffer_update_watermark - update watermark FIFO threshold
 * @st:	driver internal state
 *
 * Returns 0 on success, a negative error code otherwise.
 *
 * FIFO watermark threshold is computed based on the required watermark values
 * set for gyro and accel sensors. Since watermark is all about acceptable data
 * latency, use the smallest setting between the 2. It means choosing the
 * smallest latency but this is not as simple as choosing the smallest watermark
 * value. Latency depends on watermark and ODR. It requires several steps:
 * 1) compute gyro and accel latencies and choose the smallest value.
 * 2) adapt the choosen latency so that it is a multiple of both gyro and accel
 *    ones. Otherwise it is possible that you don't meet a requirement. (for
 *    example with gyro @100Hz wm 4 and accel @100Hz with wm 6, choosing the
 *    value of 4 will not meet accel latency requirement because 6 is not a
 *    multiple of 4. You need to use the value 2.)
 * 3) Since all periods are multiple of each others, watermark is computed by
 *    dividing this computed latency by the smallest period, which corresponds
 *    to the FIFO frequency. Beware that this is only true because we are not
 *    using 500Hz frequency which is not a multiple of the others.
 */
int inv_icm42600_buffer_update_watermark(struct inv_icm42600_state *st)
{}

static int inv_icm42600_buffer_preenable(struct iio_dev *indio_dev)
{}

/*
 * update_scan_mode callback is turning sensors on and setting data FIFO enable
 * bits.
 */
static int inv_icm42600_buffer_postenable(struct iio_dev *indio_dev)
{}

static int inv_icm42600_buffer_predisable(struct iio_dev *indio_dev)
{}

static int inv_icm42600_buffer_postdisable(struct iio_dev *indio_dev)
{}

const struct iio_buffer_setup_ops inv_icm42600_buffer_ops =;

int inv_icm42600_buffer_fifo_read(struct inv_icm42600_state *st,
				  unsigned int max)
{}

int inv_icm42600_buffer_fifo_parse(struct inv_icm42600_state *st)
{}

int inv_icm42600_buffer_hwfifo_flush(struct inv_icm42600_state *st,
				     unsigned int count)
{}

int inv_icm42600_buffer_init(struct inv_icm42600_state *st)
{}