Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /* The industrial I/O - event passing to userspace
0003  *
0004  * Copyright (c) 2008-2011 Jonathan Cameron
0005  */
0006 #ifndef _IIO_EVENTS_H_
0007 #define _IIO_EVENTS_H_
0008 
0009 #include <linux/iio/types.h>
0010 #include <uapi/linux/iio/events.h>
0011 
0012 /**
0013  * IIO_EVENT_CODE() - create event identifier
0014  * @chan_type:  Type of the channel. Should be one of enum iio_chan_type.
0015  * @diff:   Whether the event is for an differential channel or not.
0016  * @modifier:   Modifier for the channel. Should be one of enum iio_modifier.
0017  * @direction:  Direction of the event. One of enum iio_event_direction.
0018  * @type:   Type of the event. Should be one of enum iio_event_type.
0019  * @chan:   Channel number for non-differential channels.
0020  * @chan1:  First channel number for differential channels.
0021  * @chan2:  Second channel number for differential channels.
0022  */
0023 
0024 #define IIO_EVENT_CODE(chan_type, diff, modifier, direction,        \
0025                type, chan, chan1, chan2)            \
0026     (((u64)type << 56) | ((u64)diff << 55) |            \
0027      ((u64)direction << 48) | ((u64)modifier << 40) |       \
0028      ((u64)chan_type << 32) | (((u16)chan2) << 16) | ((u16)chan1) | \
0029      ((u16)chan))
0030 
0031 
0032 /**
0033  * IIO_MOD_EVENT_CODE() - create event identifier for modified channels
0034  * @chan_type:  Type of the channel. Should be one of enum iio_chan_type.
0035  * @number: Channel number.
0036  * @modifier:   Modifier for the channel. Should be one of enum iio_modifier.
0037  * @type:   Type of the event. Should be one of enum iio_event_type.
0038  * @direction:  Direction of the event. One of enum iio_event_direction.
0039  */
0040 
0041 #define IIO_MOD_EVENT_CODE(chan_type, number, modifier,     \
0042                type, direction)             \
0043     IIO_EVENT_CODE(chan_type, 0, modifier, direction, type, number, 0, 0)
0044 
0045 /**
0046  * IIO_UNMOD_EVENT_CODE() - create event identifier for unmodified channels
0047  * @chan_type:  Type of the channel. Should be one of enum iio_chan_type.
0048  * @number: Channel number.
0049  * @type:   Type of the event. Should be one of enum iio_event_type.
0050  * @direction:  Direction of the event. One of enum iio_event_direction.
0051  */
0052 
0053 #define IIO_UNMOD_EVENT_CODE(chan_type, number, type, direction)    \
0054     IIO_EVENT_CODE(chan_type, 0, 0, direction, type, number, 0, 0)
0055 
0056 #endif