events.h 2.1 KB

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