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