4 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
23 #include <linux/ioctl.h>
25 #define NO_OF_ULL_BYTES 8
26 #define NO_OF_SHORT_VAL 4
30 #define GET_DIFF_BIT(val) (((unsigned short)(val) >> 7) & 0x01)
31 #define GET_DIR_VAL(val) ((val) & 0x0F)
33 #define IOCTL_IIO_EVENT_FD _IOR('i', 0x90, int)
35 struct channel_parameters
41 unsigned int byte_count;
42 unsigned int valid_bits;
44 unsigned long long int mask;
45 unsigned int big_endian;
46 unsigned int is_signed;
48 unsigned int buf_index;
51 typedef struct iio_event_struct
53 unsigned long long int event_id;
54 long long int timestamp;
57 typedef enum event_id_field
65 typedef union ull_bytes
67 unsigned long long num;
68 short int channels[NO_OF_SHORT_VAL];
69 unsigned char bytes[NO_OF_ULL_BYTES];
72 void sort_channels_by_index(struct channel_parameters *channels, int count);
73 int decode_channel_data_type(const char *device_dir, const char *ch_name, struct channel_parameters *ch_info);
74 int add_channel_to_array(const char *device_dir, const char *ch_name, struct channel_parameters *channel);
75 int get_channel_array_size(struct channel_parameters *channels, int num_channels);
76 int update_sysfs_num(const char *filepath, int val, bool verify = false);
77 int update_sysfs_string(const char *filepath, char *val, bool verify = false);
78 int convert_bytes_to_int(int input, struct channel_parameters *info);
80 #endif /* IIO_COMMON_H_ */