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