Staging: Add the Meilhaus ME-IDS driver package
[linux-2.6/mini2440.git] / drivers / staging / meilhaus / mesubdevice.h
blob19ec2b5d96f03328c6eeeeac7a624d960ee1e89b
1 /**
2 * @file mesubdevice.h
4 * @brief Provides the subdevice base class.
5 * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
6 * @author Guenter Gebhardt
7 */
9 #ifndef _MESUBDEVICE_H_
10 #define _MESUBDEVICE_H_
12 #include <linux/list.h>
14 #include "metypes.h"
15 #include "meioctl.h"
16 #include "meslock.h"
18 # include <linux/workqueue.h>
20 #ifdef __KERNEL__
22 /**
23 * @brief Macro used to enter a subdevice.
25 #define ME_SUBDEVICE_ENTER \
26 { \
27 int err; \
28 err = me_slock_enter(&instance->base.lock, filep); \
29 if(err){ \
30 PERROR("Cannot enter subdevice.\n"); \
31 return err; \
32 } \
35 /**
36 * @brief Macro used to exit a subdevice.
38 #define ME_SUBDEVICE_EXIT \
40 int err; \
41 err = me_slock_exit(&instance->base.lock, filep); \
42 if(err){ \
43 PERROR("Cannot exit subdevice.\n"); \
44 return err; \
45 } \
48 /**
49 * @brief The subdevice base class.
51 typedef struct me_subdevice {
52 /* Attributes */
53 struct list_head list; /**< Enables the subdevice to be added to a dynamic list. */
54 me_slock_t lock; /**< Used by user application in order to lock the subdevice for exclusive usage. */
56 /* Methods */
57 int (*me_subdevice_io_irq_start) (struct me_subdevice * subdevice,
58 struct file * filep,
59 int channel,
60 int irq_source,
61 int irq_edge, int irq_arg, int flags);
63 int (*me_subdevice_io_irq_wait) (struct me_subdevice * subdevice,
64 struct file * filep,
65 int channel,
66 int *irq_count,
67 int *value, int time_out, int flags);
69 int (*me_subdevice_io_irq_stop) (struct me_subdevice * subdevice,
70 struct file * filep,
71 int channel, int flags);
73 int (*me_subdevice_io_reset_subdevice) (struct me_subdevice * subdevice,
74 struct file * filep, int flags);
76 int (*me_subdevice_io_single_config) (struct me_subdevice * subdevice,
77 struct file * filep,
78 int channel,
79 int single_config,
80 int ref,
81 int trig_chan,
82 int trig_type,
83 int trig_edge, int flags);
85 int (*me_subdevice_io_single_read) (struct me_subdevice * subdevice,
86 struct file * filep,
87 int channel,
88 int *value,
89 int time_out, int flags);
91 int (*me_subdevice_io_single_write) (struct me_subdevice * subdevice,
92 struct file * filep,
93 int channel,
94 int value,
95 int time_out, int flags);
97 int (*me_subdevice_io_stream_config) (struct me_subdevice * subdevice,
98 struct file * filep,
99 meIOStreamConfig_t * config_list,
100 int count,
101 meIOStreamTrigger_t * trigger,
102 int fifo_irq_threshold,
103 int flags);
105 int (*me_subdevice_io_stream_new_values) (struct me_subdevice *
106 subdevice,
107 struct file * filep,
108 int time_out, int *count,
109 int flags);
111 int (*me_subdevice_io_stream_read) (struct me_subdevice * subdevice,
112 struct file * filep,
113 int read_mode,
114 int *values, int *count, int flags);
116 int (*me_subdevice_io_stream_start) (struct me_subdevice * subdevice,
117 struct file * filep,
118 int start_mode,
119 int time_out, int flags);
121 int (*me_subdevice_io_stream_status) (struct me_subdevice * subdevice,
122 struct file * filep,
123 int wait,
124 int *status,
125 int *count, int flags);
127 int (*me_subdevice_io_stream_stop) (struct me_subdevice * subdevice,
128 struct file * filep,
129 int stop_mode, int flags);
131 int (*me_subdevice_io_stream_write) (struct me_subdevice * subdevice,
132 struct file * filep,
133 int write_mode,
134 int *values,
135 int *count, int flags);
137 int (*me_subdevice_lock_subdevice) (struct me_subdevice * subdevice,
138 struct file * filep,
139 int lock, int flags);
141 int (*me_subdevice_query_number_channels) (struct me_subdevice *
142 subdevice, int *number);
144 int (*me_subdevice_query_number_ranges) (struct me_subdevice *
145 subdevice, int unit,
146 int *count);
148 int (*me_subdevice_query_range_by_min_max) (struct me_subdevice *
149 subdevice, int unit,
150 int *min, int *max,
151 int *maxdata, int *range);
153 int (*me_subdevice_query_range_info) (struct me_subdevice * subdevice,
154 int range,
155 int *unit,
156 int *min, int *max, int *maxdata);
158 int (*me_subdevice_query_subdevice_type) (struct me_subdevice *
159 subdevice, int *type,
160 int *subtype);
162 int (*me_subdevice_query_subdevice_caps) (struct me_subdevice *
163 subdevice, int *caps);
165 int (*me_subdevice_query_subdevice_caps_args) (struct me_subdevice *
166 subdevice, int cap,
167 int *args, int count);
169 int (*me_subdevice_query_timer) (struct me_subdevice * subdevice,
170 int timer,
171 int *base_frequency,
172 long long *min_ticks,
173 long long *max_ticks);
175 int (*me_subdevice_config_load) (struct me_subdevice * subdevice,
176 me_cfg_device_entry_t * config);
178 void (*me_subdevice_destructor) (struct me_subdevice * subdevice);
179 } me_subdevice_t;
182 * @brief Initializes a subdevice structure.
184 * @param subdevice The subdevice structure to initialize.
185 * @return 0 on success.
187 int me_subdevice_init(me_subdevice_t * subdevice);
190 * @brief Deinitializes a subdevice structure.
192 * @param subdevice The subdevice structure to initialize.
194 void me_subdevice_deinit(me_subdevice_t * subdevice);
196 #endif
197 #endif