blob: 762a3d3ee5470cdd767f0ae45dffc4d796c59e74 [file] [log] [blame]
Jonathan Cameron3f723952011-08-24 17:28:39 +01001/* 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 Clausen08d60052012-08-17 16:57:00 +010010#ifndef __LINUX_IIO_TRIGGER_CONSUMER_H__
11#define __LINUX_IIO_TRIGGER_CONSUMER_H__
12
Jonathan Cameron3f723952011-08-24 17:28:39 +010013/**
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 **/
27struct 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
38struct 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 ...);
45void iio_dealloc_pollfunc(struct iio_poll_func *pf);
46irqreturn_t iio_pollfunc_store_time(int irq, void *p);
47
48void 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 Cameron3b99fb72011-09-21 11:15:53 +010054int iio_triggered_buffer_postenable(struct iio_dev *indio_dev);
55int iio_triggered_buffer_predisable(struct iio_dev *indio_dev);
Lars-Peter Clausen08d60052012-08-17 16:57:00 +010056
57#endif