blob: 8ad87d1c5340bedf557bd498fcc03b10a123a8e9 [file] [log] [blame]
Jonathan Cameronaf5046a2011-10-26 17:41:32 +01001/* The industrial I/O - event passing to userspace
2 *
3 * Copyright (c) 2008-2011 Jonathan Cameron
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 */
9#ifndef _IIO_EVENTS_H_
10#define _IIO_EVENTS_H_
11
Jonathan Cameron06458e22012-04-25 15:54:58 +010012#include <linux/iio/types.h>
Daniel Baluta293487c2015-02-10 18:33:51 +020013#include <uapi/linux/iio/events.h>
Jonathan Cameronaf5046a2011-10-26 17:41:32 +010014
Lars-Peter Clausen3014cd92011-10-26 17:41:34 +010015/**
16 * IIO_EVENT_CODE() - create event identifier
17 * @chan_type: Type of the channel. Should be one of enum iio_chan_type.
18 * @diff: Whether the event is for an differential channel or not.
19 * @modifier: Modifier for the channel. Should be one of enum iio_modifier.
20 * @direction: Direction of the event. One of enum iio_event_direction.
Peter Meerwaldfb1c4bc2012-06-15 19:25:28 +020021 * @type: Type of the event. Should be one of enum iio_event_type.
Lars-Peter Clausen3014cd92011-10-26 17:41:34 +010022 * @chan: Channel number for non-differential channels.
23 * @chan1: First channel number for differential channels.
24 * @chan2: Second channel number for differential channels.
25 */
26
Jonathan Cameronaf5046a2011-10-26 17:41:32 +010027#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) | \
Lars-Peter Clausen19c2aed2011-11-02 09:40:01 +010031 ((u64)chan_type << 32) | (((u16)chan2) << 16) | ((u16)chan1) | \
32 ((u16)chan))
Jonathan Cameronaf5046a2011-10-26 17:41:32 +010033
34
Lars-Peter Clausen3014cd92011-10-26 17:41:34 +010035/**
36 * IIO_MOD_EVENT_CODE() - create event identifier for modified channels
37 * @chan_type: Type of the channel. Should be one of enum iio_chan_type.
38 * @number: Channel number.
39 * @modifier: Modifier for the channel. Should be one of enum iio_modifier.
Peter Meerwaldfb1c4bc2012-06-15 19:25:28 +020040 * @type: Type of the event. Should be one of enum iio_event_type.
Lars-Peter Clausen3014cd92011-10-26 17:41:34 +010041 * @direction: Direction of the event. One of enum iio_event_direction.
42 */
Jonathan Cameronaf5046a2011-10-26 17:41:32 +010043
Lars-Peter Clausen3014cd92011-10-26 17:41:34 +010044#define IIO_MOD_EVENT_CODE(chan_type, number, modifier, \
45 type, direction) \
46 IIO_EVENT_CODE(chan_type, 0, modifier, direction, type, number, 0, 0)
47
48/**
49 * IIO_UNMOD_EVENT_CODE() - create event identifier for unmodified channels
50 * @chan_type: Type of the channel. Should be one of enum iio_chan_type.
51 * @number: Channel number.
Peter Meerwaldfb1c4bc2012-06-15 19:25:28 +020052 * @type: Type of the event. Should be one of enum iio_event_type.
Lars-Peter Clausen3014cd92011-10-26 17:41:34 +010053 * @direction: Direction of the event. One of enum iio_event_direction.
54 */
55
56#define IIO_UNMOD_EVENT_CODE(chan_type, number, type, direction) \
57 IIO_EVENT_CODE(chan_type, 0, 0, direction, type, number, 0, 0)
Jonathan Cameronaf5046a2011-10-26 17:41:32 +010058
Jonathan Cameronaf5046a2011-10-26 17:41:32 +010059#endif