trigger_consumer.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* The industrial I/O core, trigger consumer functions
  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 __LINUX_IIO_TRIGGER_CONSUMER_H__
  10. #define __LINUX_IIO_TRIGGER_CONSUMER_H__
  11. #include <linux/interrupt.h>
  12. #include <linux/types.h>
  13. struct iio_dev;
  14. struct iio_trigger;
  15. /**
  16. * struct iio_poll_func - poll function pair
  17. *
  18. * @indio_dev: data specific to device (passed into poll func)
  19. * @h: the function that is actually run on trigger
  20. * @thread: threaded interrupt part
  21. * @type: the type of interrupt (basically if oneshot)
  22. * @name: name used to identify the trigger consumer.
  23. * @irq: the corresponding irq as allocated from the
  24. * trigger pool
  25. * @timestamp: some devices need a timestamp grabbed as soon
  26. * as possible after the trigger - hence handler
  27. * passes it via here.
  28. **/
  29. struct iio_poll_func {
  30. struct iio_dev *indio_dev;
  31. irqreturn_t (*h)(int irq, void *p);
  32. irqreturn_t (*thread)(int irq, void *p);
  33. int type;
  34. char *name;
  35. int irq;
  36. s64 timestamp;
  37. };
  38. struct iio_poll_func
  39. *iio_alloc_pollfunc(irqreturn_t (*h)(int irq, void *p),
  40. irqreturn_t (*thread)(int irq, void *p),
  41. int type,
  42. struct iio_dev *indio_dev,
  43. const char *fmt,
  44. ...);
  45. void iio_dealloc_pollfunc(struct iio_poll_func *pf);
  46. irqreturn_t iio_pollfunc_store_time(int irq, void *p);
  47. void iio_trigger_notify_done(struct iio_trigger *trig);
  48. /*
  49. * Two functions for common case where all that happens is a pollfunc
  50. * is attached and detached from a trigger
  51. */
  52. int iio_triggered_buffer_postenable(struct iio_dev *indio_dev);
  53. int iio_triggered_buffer_predisable(struct iio_dev *indio_dev);
  54. #endif