events.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* 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. #include <linux/iio/types.h>
  12. #include <uapi/linux/iio/events.h>
  13. /**
  14. * IIO_EVENT_CODE() - create event identifier
  15. * @chan_type: Type of the channel. Should be one of enum iio_chan_type.
  16. * @diff: Whether the event is for an differential channel or not.
  17. * @modifier: Modifier for the channel. Should be one of enum iio_modifier.
  18. * @direction: Direction of the event. One of enum iio_event_direction.
  19. * @type: Type of the event. Should be one of enum iio_event_type.
  20. * @chan: Channel number for non-differential channels.
  21. * @chan1: First channel number for differential channels.
  22. * @chan2: Second channel number for differential channels.
  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. * IIO_MOD_EVENT_CODE() - create event identifier for modified channels
  32. * @chan_type: Type of the channel. Should be one of enum iio_chan_type.
  33. * @number: Channel number.
  34. * @modifier: Modifier for the channel. Should be one of enum iio_modifier.
  35. * @type: Type of the event. Should be one of enum iio_event_type.
  36. * @direction: Direction of the event. One of enum iio_event_direction.
  37. */
  38. #define IIO_MOD_EVENT_CODE(chan_type, number, modifier, \
  39. type, direction) \
  40. IIO_EVENT_CODE(chan_type, 0, modifier, direction, type, number, 0, 0)
  41. /**
  42. * IIO_UNMOD_EVENT_CODE() - create event identifier for unmodified channels
  43. * @chan_type: Type of the channel. Should be one of enum iio_chan_type.
  44. * @number: Channel number.
  45. * @type: Type of the event. Should be one of enum iio_event_type.
  46. * @direction: Direction of the event. One of enum iio_event_direction.
  47. */
  48. #define IIO_UNMOD_EVENT_CODE(chan_type, number, type, direction) \
  49. IIO_EVENT_CODE(chan_type, 0, 0, direction, type, number, 0, 0)
  50. #endif