iio: core: Introduce IIO_CHAN_INFO_CALIBHEIGHT
[deliverable/linux.git] / drivers / staging / iio / iio_simple_dummy.h
CommitLineData
e6477000
JC
1/**
2 * Copyright (c) 2011 Jonathan Cameron
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * Join together the various functionality of iio_simple_dummy driver
9 */
10
f3f883b4
RD
11#ifndef _IIO_SIMPLE_DUMMY_H_
12#define _IIO_SIMPLE_DUMMY_H_
e6477000
JC
13#include <linux/kernel.h>
14
15struct iio_dummy_accel_calibscale;
356ae946 16struct iio_dummy_regs;
e6477000
JC
17
18/**
19 * struct iio_dummy_state - device instance specific state.
20 * @dac_val: cache for dac value
21 * @single_ended_adc_val: cache for single ended adc value
22 * @differential_adc_val: cache for differential adc value
23 * @accel_val: cache for acceleration value
24 * @accel_calibbias: cache for acceleration calibbias
25 * @accel_calibscale: cache for acceleration calibscale
26 * @lock: lock to ensure state is consistent
27 * @event_irq: irq number for event line (faked)
28 * @event_val: cache for event theshold value
29 * @event_en: cache of whether event is enabled
30 */
31struct iio_dummy_state {
32 int dac_val;
33 int single_ended_adc_val;
34 int differential_adc_val[2];
35 int accel_val;
36 int accel_calibbias;
37 const struct iio_dummy_accel_calibscale *accel_calibscale;
38 struct mutex lock;
356ae946 39 struct iio_dummy_regs *regs;
e6477000
JC
40#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
41 int event_irq;
42 int event_val;
43 bool event_en;
44#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */
45};
46
47#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
48
49struct iio_dev;
50
51int iio_simple_dummy_read_event_config(struct iio_dev *indio_dev,
bda624b0
LPC
52 const struct iio_chan_spec *chan,
53 enum iio_event_type type,
54 enum iio_event_direction dir);
e6477000
JC
55
56int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev,
bda624b0
LPC
57 const struct iio_chan_spec *chan,
58 enum iio_event_type type,
59 enum iio_event_direction dir,
e6477000
JC
60 int state);
61
62int iio_simple_dummy_read_event_value(struct iio_dev *indio_dev,
bda624b0
LPC
63 const struct iio_chan_spec *chan,
64 enum iio_event_type type,
65 enum iio_event_direction dir,
66 enum iio_event_info info, int *val,
67 int *val2);
e6477000
JC
68
69int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev,
bda624b0
LPC
70 const struct iio_chan_spec *chan,
71 enum iio_event_type type,
72 enum iio_event_direction dir,
73 enum iio_event_info info, int val,
74 int val2);
e6477000
JC
75
76int iio_simple_dummy_events_register(struct iio_dev *indio_dev);
77int iio_simple_dummy_events_unregister(struct iio_dev *indio_dev);
78
79#else /* Stubs for when events are disabled at compile time */
80
81static inline int
82iio_simple_dummy_events_register(struct iio_dev *indio_dev)
83{
84 return 0;
85};
86
87static inline int
88iio_simple_dummy_events_unregister(struct iio_dev *indio_dev)
89{
90 return 0;
91};
92
93#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/
94
9ad2e2e1
JC
95/**
96 * enum iio_simple_dummy_scan_elements - scan index enum
97 * @voltage0: the single ended voltage channel
98 * @diffvoltage1m2: first differential channel
99 * @diffvoltage3m4: second differenial channel
100 * @accelx: acceleration channel
101 *
102 * Enum provides convenient numbering for the scan index.
103 */
104enum iio_simple_dummy_scan_elements {
105 voltage0,
106 diffvoltage1m2,
107 diffvoltage3m4,
108 accelx,
109};
e6477000 110
9ad2e2e1 111#ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER
3fff2274
LPC
112int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev,
113 const struct iio_chan_spec *channels, unsigned int num_channels);
9ad2e2e1
JC
114void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev);
115#else
3fff2274
LPC
116static inline int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev,
117 const struct iio_chan_spec *channels, unsigned int num_channels)
9ad2e2e1
JC
118{
119 return 0;
120};
121static inline
122void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev)
123{};
f3f883b4 124
9ad2e2e1 125#endif /* CONFIG_IIO_SIMPLE_DUMMY_BUFFER */
f3f883b4 126#endif /* _IIO_SIMPLE_DUMMY_H_ */
This page took 0.270848 seconds and 5 git commands to generate.