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 * Drivers should use the specialized macros below instead of using this one 24 * directly. 25 */ 26 27 #define _IIO_EVENT_CODE(chan_type, diff, modifier, direction, \ 28 type, chan, chan1, chan2) \ 29 (((u64)type << 56) | ((u64)diff << 55) | \ 30 ((u64)direction << 48) | ((u64)modifier << 40) | \ 31 ((u64)chan_type << 32) | (((u16)chan2) << 16) | ((u16)chan1) | \ 32 ((u16)chan)) 33 34 35 /** 36 * IIO_MOD_EVENT_CODE() - create event identifier for modified (non 37 * differential) channels 38 * @chan_type: Type of the channel. Should be one of enum iio_chan_type. 39 * @number: Channel number. 40 * @modifier: Modifier for the channel. Should be one of enum iio_modifier. 41 * @type: Type of the event. Should be one of enum iio_event_type. 42 * @direction: Direction of the event. One of enum iio_event_direction. 43 */ 44 45 #define IIO_MOD_EVENT_CODE(chan_type, number, modifier, \ 46 type, direction) \ 47 _IIO_EVENT_CODE(chan_type, 0, modifier, direction, type, number, 0, 0) 48 49 /** 50 * IIO_UNMOD_EVENT_CODE() - create event identifier for unmodified (non 51 * differential) channels 52 * @chan_type: Type of the channel. Should be one of enum iio_chan_type. 53 * @number: Channel number. 54 * @type: Type of the event. Should be one of enum iio_event_type. 55 * @direction: Direction of the event. One of enum iio_event_direction. 56 */ 57 58 #define IIO_UNMOD_EVENT_CODE(chan_type, number, type, direction) \ 59 _IIO_EVENT_CODE(chan_type, 0, 0, direction, type, number, 0, 0) 60 61 /** 62 * IIO_DIFF_EVENT_CODE() - create event identifier for differential channels 63 * @chan_type: Type of the channel. Should be one of enum iio_chan_type. 64 * @chan1: First channel number for differential channels. 65 * @chan2: Second channel number for differential channels. 66 * @type: Type of the event. Should be one of enum iio_event_type. 67 * @direction: Direction of the event. One of enum iio_event_direction. 68 */ 69 70 #define IIO_DIFF_EVENT_CODE(chan_type, chan1, chan2, type, direction) \ 71 _IIO_EVENT_CODE(chan_type, 1, 0, direction, type, 0, chan1, chan2) 72 73 #endif 74