Adding IIO event related data structures for non-trigger based IIO drivers 46/25346/3
authorAmit Dharmapurikar <amit.vd@samsung.com>
Mon, 4 Aug 2014 06:50:04 +0000 (12:20 +0530)
committerAmit Dharmapurikar <amit.vd@samsung.com>
Mon, 18 Aug 2014 11:50:14 +0000 (17:20 +0530)
  IIO event data structure and other event decoding data types have been defined for sensor drivers without IIO trigger.

Change-Id: I38e6d78ee907f47f3544fdacfcffc41d7e5d1ae6
Signed-off-by: Amit Dharmapurikar <amit.vd@samsung.com>
src/shared/iio_common.h

index 0f456dc..9f00c13 100644 (file)
 #ifndef IIO_COMMON_H_
 #define IIO_COMMON_H_
 
-struct channel_parameters {
+#include <linux/ioctl.h>
+
+#define NO_OF_ULL_BYTES                8
+#define NO_OF_SHORT_VAL                4
+#define CH0_INDEX                      0
+#define CH1_INDEX                      1
+
+#define GET_DIFF_BIT(val)      (((unsigned short)(val) >> 7) & 0x01)
+#define GET_DIR_VAL(val)       ((val) & 0x0F)
+
+#define IOCTL_IIO_EVENT_FD _IOR('i', 0x90, int)
+
+struct channel_parameters
+{
        char *prefix_str;
        float scale;
        float offset;
@@ -35,6 +48,27 @@ struct channel_parameters {
        unsigned int buf_index;
 };
 
+typedef struct iio_event_struct
+{
+       unsigned long long int event_id;
+       long long int timestamp;
+} iio_event_t;
+
+typedef enum event_id_field
+{
+       CH_TYPE = 4,
+       MODIFIER,
+       DIRECTION,
+       EVENT_TYPE,
+} event_id_field_t;
+
+typedef union ull_bytes
+{
+       unsigned long long num;
+       short int channels[NO_OF_SHORT_VAL];
+       unsigned char bytes[NO_OF_ULL_BYTES];
+} ull_bytes_t;
+
 void sort_channels_by_index(struct channel_parameters *channels, int count);
 int decode_channel_data_type(const char *device_dir, const char *ch_name, struct channel_parameters *ch_info);
 int add_channel_to_array(const char *device_dir, const char *ch_name, struct channel_parameters *channel);