xref: /linux/include/linux/iio/events.h (revision 0be3ff0c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* The industrial I/O - event passing to userspace
3  *
4  * Copyright (c) 2008-2011 Jonathan Cameron
5  */
6 #ifndef _IIO_EVENTS_H_
7 #define _IIO_EVENTS_H_
8 
9 #include <linux/iio/types.h>
10 #include <uapi/linux/iio/events.h>
11 
12 /**
13  * IIO_EVENT_CODE() - create event identifier
14  * @chan_type:	Type of the channel. Should be one of enum iio_chan_type.
15  * @diff:	Whether the event is for an differential channel or not.
16  * @modifier:	Modifier for the channel. Should be one of enum iio_modifier.
17  * @direction:	Direction of the event. One of enum iio_event_direction.
18  * @type:	Type of the event. Should be one of enum iio_event_type.
19  * @chan:	Channel number for non-differential channels.
20  * @chan1:	First channel number for differential channels.
21  * @chan2:	Second channel number for differential channels.
22  */
23 
24 #define IIO_EVENT_CODE(chan_type, diff, modifier, direction,		\
25 		       type, chan, chan1, chan2)			\
26 	(((u64)type << 56) | ((u64)diff << 55) |			\
27 	 ((u64)direction << 48) | ((u64)modifier << 40) |		\
28 	 ((u64)chan_type << 32) | (((u16)chan2) << 16) | ((u16)chan1) | \
29 	 ((u16)chan))
30 
31 
32 /**
33  * IIO_MOD_EVENT_CODE() - create event identifier for modified channels
34  * @chan_type:	Type of the channel. Should be one of enum iio_chan_type.
35  * @number:	Channel number.
36  * @modifier:	Modifier for the channel. Should be one of enum iio_modifier.
37  * @type:	Type of the event. Should be one of enum iio_event_type.
38  * @direction:	Direction of the event. One of enum iio_event_direction.
39  */
40 
41 #define IIO_MOD_EVENT_CODE(chan_type, number, modifier,		\
42 			   type, direction)				\
43 	IIO_EVENT_CODE(chan_type, 0, modifier, direction, type, number, 0, 0)
44 
45 /**
46  * IIO_UNMOD_EVENT_CODE() - create event identifier for unmodified channels
47  * @chan_type:	Type of the channel. Should be one of enum iio_chan_type.
48  * @number:	Channel number.
49  * @type:	Type of the event. Should be one of enum iio_event_type.
50  * @direction:	Direction of the event. One of enum iio_event_direction.
51  */
52 
53 #define IIO_UNMOD_EVENT_CODE(chan_type, number, type, direction)	\
54 	IIO_EVENT_CODE(chan_type, 0, 0, direction, type, number, 0, 0)
55 
56 #endif
57