4 * @brief Provides the subdevice base class.
5 * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
6 * @author Guenter Gebhardt
9 #ifndef _MESUBDEVICE_H_
10 #define _MESUBDEVICE_H_
12 #include <linux/list.h>
18 # include <linux/workqueue.h>
23 * @brief Macro used to enter a subdevice.
25 #define ME_SUBDEVICE_ENTER \
28 err = me_slock_enter(&instance->base.lock, filep); \
30 PERROR("Cannot enter subdevice.\n"); \
36 * @brief Macro used to exit a subdevice.
38 #define ME_SUBDEVICE_EXIT \
41 err = me_slock_exit(&instance->base.lock, filep); \
43 PERROR("Cannot exit subdevice.\n"); \
49 * @brief The subdevice base class.
51 typedef struct me_subdevice {
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. */
57 int (*me_subdevice_io_irq_start) (struct me_subdevice * subdevice,
61 int irq_edge, int irq_arg, int flags);
63 int (*me_subdevice_io_irq_wait) (struct me_subdevice * subdevice,
67 int *value, int time_out, int flags);
69 int (*me_subdevice_io_irq_stop) (struct me_subdevice * subdevice,
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,
83 int trig_edge, int flags);
85 int (*me_subdevice_io_single_read) (struct me_subdevice * subdevice,
89 int time_out, int flags);
91 int (*me_subdevice_io_single_write) (struct me_subdevice * subdevice,
95 int time_out, int flags);
97 int (*me_subdevice_io_stream_config) (struct me_subdevice * subdevice,
99 meIOStreamConfig_t * config_list,
101 meIOStreamTrigger_t * trigger,
102 int fifo_irq_threshold,
105 int (*me_subdevice_io_stream_new_values) (struct me_subdevice *
108 int time_out, int *count,
111 int (*me_subdevice_io_stream_read) (struct me_subdevice * subdevice,
114 int *values, int *count, int flags);
116 int (*me_subdevice_io_stream_start) (struct me_subdevice * subdevice,
119 int time_out, int flags);
121 int (*me_subdevice_io_stream_status) (struct me_subdevice * subdevice,
125 int *count, int flags);
127 int (*me_subdevice_io_stream_stop) (struct me_subdevice * subdevice,
129 int stop_mode, int flags);
131 int (*me_subdevice_io_stream_write) (struct me_subdevice * subdevice,
135 int *count, int flags);
137 int (*me_subdevice_lock_subdevice) (struct me_subdevice * subdevice,
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 *
148 int (*me_subdevice_query_range_by_min_max) (struct me_subdevice *
151 int *maxdata, int *range);
153 int (*me_subdevice_query_range_info) (struct me_subdevice * subdevice,
156 int *min, int *max, int *maxdata);
158 int (*me_subdevice_query_subdevice_type) (struct me_subdevice *
159 subdevice, int *type,
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 *
167 int *args, int count);
169 int (*me_subdevice_query_timer) (struct me_subdevice * subdevice,
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);
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);