1 #ifndef __SSP_IIO_SENSOR_H__
2 #define __SSP_IIO_SENSOR_H__
4 #define SSP_CHANNEL_AG(_type, _mod, _index) \
9 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ),\
10 .scan_index = _index,\
16 .endianness = IIO_LE,\
20 /* It is defined here as it is a mixed timestamp */
21 #define SSP_CHAN_TIMESTAMP(_si) { \
22 .type = IIO_TIMESTAMP, \
32 #define SSP_MS_PER_S 1000
33 #define SSP_INVERTED_SCALING_FACTOR 1000000ULL
35 #define SSP_FACTOR_WITH_MS \
36 (SSP_INVERTED_SCALING_FACTOR * SSP_MS_PER_S)
38 int ssp_common_buffer_postenable(struct iio_dev
*indio_dev
);
40 int ssp_common_buffer_postdisable(struct iio_dev
*indio_dev
);
42 int ssp_common_process_data(struct iio_dev
*indio_dev
, void *buf
,
43 unsigned int len
, int64_t timestamp
);
45 /* Converts time in ms to frequency */
46 static inline void ssp_convert_to_freq(u32 time
, int *integer_part
,
55 *integer_part
= SSP_FACTOR_WITH_MS
/ time
;
56 *fractional
= do_div(*integer_part
, SSP_INVERTED_SCALING_FACTOR
);
59 /* Converts frequency to time in ms */
60 static inline int ssp_convert_to_time(int integer_part
, int fractional
)
64 value
= integer_part
* SSP_INVERTED_SCALING_FACTOR
+ fractional
;
68 return div_u64(SSP_FACTOR_WITH_MS
, value
);
70 #endif /* __SSP_IIO_SENSOR_H__ */