include/linux/platform_data/cros_ec_sensorhub.h

Source file repositories/reference/linux-study-clean/include/linux/platform_data/cros_ec_sensorhub.h

File Facts

System
Linux kernel
Corpus path
include/linux/platform_data/cros_ec_sensorhub.h
Extension
.h
Size
6259 bytes
Lines
195
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct cros_ec_sensor_platform {
	u8 sensor_num;
};

/**
 * typedef cros_ec_sensorhub_push_data_cb_t - Callback function to send datum
 *					      to specific sensors.
 *
 * @indio_dev: The IIO device that will process the sample.
 * @data: Vector array of the ring sample.
 * @timestamp: Timestamp in host timespace when the sample was acquired by
 *             the EC.
 */
typedef int (*cros_ec_sensorhub_push_data_cb_t)(struct iio_dev *indio_dev,
						s16 *data,
						s64 timestamp);

struct cros_ec_sensorhub_sensor_push_data {
	struct iio_dev *indio_dev;
	cros_ec_sensorhub_push_data_cb_t push_data_cb;
};

enum {
	CROS_EC_SENSOR_LAST_TS,
	CROS_EC_SENSOR_NEW_TS,
	CROS_EC_SENSOR_ALL_TS
};

struct cros_ec_sensors_ring_sample {
	u8  sensor_id;
	u8  flag;
	s16 vector[3];
	s64 timestamp;
} __packed;

/* State used for cros_ec_ring_fix_overflow */
struct cros_ec_sensors_ec_overflow_state {
	s64 offset;
	s64 last;
};

/* Length of the filter, how long to remember entries for */
#define CROS_EC_SENSORHUB_TS_HISTORY_SIZE 64

/**
 * struct cros_ec_sensors_ts_filter_state - Timestamp filetr state.
 *
 * @x_offset: x is EC interrupt time. x_offset its last value.
 * @y_offset: y is the difference between AP and EC time, y_offset its last
 *            value.
 * @x_history: The past history of x, relative to x_offset.
 * @y_history: The past history of y, relative to y_offset.
 * @m_history: rate between y and x.
 * @history_len: Amount of valid historic data in the arrays.
 * @temp_buf: Temporary buffer used when updating the filter.
 * @median_m: median value of m_history
 * @median_error: final error to apply to AP interrupt timestamp to get the
 *                "true timestamp" the event occurred.
 */
struct cros_ec_sensors_ts_filter_state {
	s64 x_offset, y_offset;
	s64 x_history[CROS_EC_SENSORHUB_TS_HISTORY_SIZE];
	s64 y_history[CROS_EC_SENSORHUB_TS_HISTORY_SIZE];
	s64 m_history[CROS_EC_SENSORHUB_TS_HISTORY_SIZE];
	int history_len;

	s64 temp_buf[CROS_EC_SENSORHUB_TS_HISTORY_SIZE];

	s64 median_m;
	s64 median_error;
};

/* struct cros_ec_sensors_ts_batch_state - State of batch of a single sensor.
 *
 * Use to store information to batch data using median fileter information.
 *
 * @penul_ts: last but one batch timestamp (penultimate timestamp).
 *	      Used for timestamp spreading calculations
 *	      when a batch shows up.
 * @penul_len: last but one batch length.
 * @last_ts: Last batch timestam.
 * @last_len: Last batch length.
 * @newest_sensor_event: Last sensor timestamp.
 */
struct cros_ec_sensors_ts_batch_state {
	s64 penul_ts;
	int penul_len;
	s64 last_ts;
	int last_len;
	s64 newest_sensor_event;

Annotation

Implementation Notes