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