Xenomai API  2.6.5
subdevice.h
Go to the documentation of this file.
1 
23 #ifndef __ANALOGY_SUBDEVICE__
24 #define __ANALOGY_SUBDEVICE__
25 
26 #ifdef __KERNEL__
27 #include <linux/list.h>
28 #endif /* __KERNEL__ */
29 
30 #include <analogy/types.h>
31 #include <analogy/context.h>
32 #include <analogy/instruction.h>
33 #include <analogy/command.h>
34 #include <analogy/channel_range.h>
35 
36 /* --- Subdevice flags desc stuff --- */
37 
38 /* TODO: replace ANALOGY_SUBD_AI with ANALOGY_SUBD_ANALOG
39  and ANALOGY_SUBD_INPUT */
40 
41 /* Subdevice types masks */
42 #define A4L_SUBD_MASK_READ 0x80000000
43 #define A4L_SUBD_MASK_WRITE 0x40000000
44 #define A4L_SUBD_MASK_SPECIAL 0x20000000
45 
60 #define A4L_SUBD_UNUSED (A4L_SUBD_MASK_SPECIAL|0x1)
61 
64 #define A4L_SUBD_AI (A4L_SUBD_MASK_READ|0x2)
65 
68 #define A4L_SUBD_AO (A4L_SUBD_MASK_WRITE|0x4)
69 
72 #define A4L_SUBD_DI (A4L_SUBD_MASK_READ|0x8)
73 
76 #define A4L_SUBD_DO (A4L_SUBD_MASK_WRITE|0x10)
77 
80 #define A4L_SUBD_DIO (A4L_SUBD_MASK_SPECIAL|0x20)
81 
84 #define A4L_SUBD_COUNTER (A4L_SUBD_MASK_SPECIAL|0x40)
85 
88 #define A4L_SUBD_TIMER (A4L_SUBD_MASK_SPECIAL|0x80)
89 
92 #define A4L_SUBD_MEMORY (A4L_SUBD_MASK_SPECIAL|0x100)
93 
96 #define A4L_SUBD_CALIB (A4L_SUBD_MASK_SPECIAL|0x200)
97 
100 #define A4L_SUBD_PROC (A4L_SUBD_MASK_SPECIAL|0x400)
101 
104 #define A4L_SUBD_SERIAL (A4L_SUBD_MASK_SPECIAL|0x800)
105 
108 #define A4L_SUBD_TYPES (A4L_SUBD_UNUSED | \
109  A4L_SUBD_AI | \
110  A4L_SUBD_AO | \
111  A4L_SUBD_DI | \
112  A4L_SUBD_DO | \
113  A4L_SUBD_DIO | \
114  A4L_SUBD_COUNTER | \
115  A4L_SUBD_TIMER | \
116  A4L_SUBD_MEMORY | \
117  A4L_SUBD_CALIB | \
118  A4L_SUBD_PROC | \
119  A4L_SUBD_SERIAL)
120 
129 /* Subdevice capabilities */
134 #define A4L_SUBD_CMD 0x1000
135 
140 #define A4L_SUBD_MMAP 0x8000
141 
150 /* Subdevice status flag(s) */
155 #define A4L_SUBD_BUSY_NR 0
156 #define A4L_SUBD_BUSY (1 << A4L_SUBD_BUSY_NR)
157 
162 #define A4L_SUBD_CLEAN_NR 1
163 #define A4L_SUBD_CLEAN (1 << A4L_SUBD_CLEAN_NR)
164 
165 
168 #ifdef __KERNEL__
169 
170 /* --- Subdevice descriptor structure --- */
171 
172 struct a4l_device;
173 struct a4l_buffer;
174 
181 
182  struct list_head list;
185  struct a4l_device *dev;
188  unsigned int idx;
191  struct a4l_buffer *buf;
194  /* Subdevice's status (busy, linked?) */
195  unsigned long status;
198  /* Descriptors stuff */
199  unsigned long flags;
203  a4l_rngdesc_t *rng_desc;
208  /* Functions stuff */
209  int (*insn_read) (struct a4l_subdevice *, a4l_kinsn_t *);
211  int (*insn_write) (struct a4l_subdevice *, a4l_kinsn_t *);
213  int (*insn_bits) (struct a4l_subdevice *, a4l_kinsn_t *);
215  int (*insn_config) (struct a4l_subdevice *, a4l_kinsn_t *);
217  int (*do_cmd) (struct a4l_subdevice *, a4l_cmd_t *);
219  int (*do_cmdtest) (struct a4l_subdevice *, a4l_cmd_t *);
221  int (*cancel) (struct a4l_subdevice *);
223  void (*munge) (struct a4l_subdevice *, void *, unsigned long);
225  int (*trigger) (struct a4l_subdevice *, lsampl_t);
228  char priv[0];
230 };
231 typedef struct a4l_subdevice a4l_subd_t;
232 
233 #endif /* __KERNEL__ */
234 
237 #ifndef DOXYGEN_CPP
238 
239 /* --- Subdevice related IOCTL arguments structures --- */
240 
241 /* SUDBINFO IOCTL argument */
242 struct a4l_subd_info {
243  unsigned long flags;
244  unsigned long status;
245  unsigned char nb_chan;
246 };
247 typedef struct a4l_subd_info a4l_sbinfo_t;
248 
249 /* CHANINFO / NBCHANINFO IOCTL arguments */
250 struct a4l_chan_info {
251  unsigned long chan_flags;
252  unsigned char nb_rng;
253  unsigned char nb_bits;
254 };
255 typedef struct a4l_chan_info a4l_chinfo_t;
256 
257 struct a4l_chinfo_arg {
258  unsigned int idx_subd;
259  void *info;
260 };
261 typedef struct a4l_chinfo_arg a4l_chinfo_arg_t;
262 
263 /* RNGINFO / NBRNGINFO IOCTL arguments */
264 struct a4l_rng_info {
265  long min;
266  long max;
267  unsigned long flags;
268 };
269 typedef struct a4l_rng_info a4l_rnginfo_t;
270 
271 struct a4l_rng_info_arg {
272  unsigned int idx_subd;
273  unsigned int idx_chan;
274  void *info;
275 };
276 typedef struct a4l_rng_info_arg a4l_rnginfo_arg_t;
277 
278 #ifdef __KERNEL__
279 
280 /* --- Subdevice related functions and macros --- */
281 
282 a4l_chan_t *a4l_get_chfeat(a4l_subd_t * sb, int idx);
283 a4l_rng_t *a4l_get_rngfeat(a4l_subd_t * sb, int chidx, int rngidx);
284 int a4l_check_chanlist(a4l_subd_t * subd,
285  unsigned char nb_chan, unsigned int *chans);
286 
287 #define a4l_subd_is_input(x) ((A4L_SUBD_MASK_READ & (x)->flags) != 0)
288 /* The following macro considers that a DIO subdevice is firstly an
289  output subdevice */
290 #define a4l_subd_is_output(x) \
291  ((A4L_SUBD_MASK_WRITE & (x)->flags) != 0 || \
292  (A4L_SUBD_DIO & (x)->flags) != 0)
293 
294 /* --- Upper layer functions --- */
295 
296 a4l_subd_t * a4l_get_subd(struct a4l_device *dev, int idx);
297 a4l_subd_t * a4l_alloc_subd(int sizeof_priv,
298  void (*setup)(a4l_subd_t *));
299 int a4l_add_subd(struct a4l_device *dev, a4l_subd_t * subd);
300 int a4l_ioctl_subdinfo(a4l_cxt_t * cxt, void *arg);
301 int a4l_ioctl_chaninfo(a4l_cxt_t * cxt, void *arg);
302 int a4l_ioctl_rnginfo(a4l_cxt_t * cxt, void *arg);
303 int a4l_ioctl_nbchaninfo(a4l_cxt_t * cxt, void *arg);
304 int a4l_ioctl_nbrnginfo(a4l_cxt_t * cxt, void *arg);
305 
306 #endif /* __KERNEL__ */
307 
308 #endif /* !DOXYGEN_CPP */
309 
310 #endif /* __ANALOGY_SUBDEVICE__ */
Structure describing some channel's characteristics.
Definition: channel_range.h:164
struct a4l_buffer * buf
Linked buffer.
Definition: subdevice.h:191
Analogy for Linux, context structure / macros declarations.
Analogy for Linux, driver facilities.
unsigned int idx
Subdevice index.
Definition: subdevice.h:188
Structure describing the asynchronous instruction.
Definition: command.h:198
int(* insn_read)(struct a4l_subdevice *, a4l_kinsn_t *)
Callback for the instruction "read".
Definition: subdevice.h:209
unsigned long status
Subdevice's status.
Definition: subdevice.h:195
int(* insn_write)(struct a4l_subdevice *, a4l_kinsn_t *)
Callback for the instruction "write".
Definition: subdevice.h:211
a4l_chdesc_t * chan_desc
Tab of channels descriptors pointers.
Definition: subdevice.h:201
void(* munge)(struct a4l_subdevice *, void *, unsigned long)
Callback for munge operation.
Definition: subdevice.h:223
int(* cancel)(struct a4l_subdevice *)
Callback for asynchronous transfer cancellation.
Definition: subdevice.h:221
int(* insn_config)(struct a4l_subdevice *, a4l_kinsn_t *)
Callback for the configuration instruction.
Definition: subdevice.h:215
struct list_head list
List stuff.
Definition: subdevice.h:182
Analogy for Linux, instruction related features.
a4l_cmd_t * cmd_mask
Command capabilities mask.
Definition: subdevice.h:205
int a4l_add_subd(a4l_dev_t *dev, a4l_subd_t *subd)
Add a subdevice to the driver descriptor.
a4l_rngdesc_t * rng_desc
Tab of ranges descriptors pointers.
Definition: subdevice.h:203
Analogy for Linux, channel, range related features.
a4l_subd_t * a4l_get_subd(a4l_dev_t *dev, int idx)
Get a pointer to the subdevice descriptor referenced by its registration index.
Structure describing a (unique) range.
Definition: channel_range.h:239
Structure describing the subdevice.
Definition: subdevice.h:180
int(* do_cmdtest)(struct a4l_subdevice *, a4l_cmd_t *)
Callback for command checking.
Definition: subdevice.h:219
char priv[0]
Private data.
Definition: subdevice.h:228
Analogy for Linux, misc declarations.
Structure describing a channels set.
Definition: channel_range.h:193
int(* do_cmd)(struct a4l_subdevice *, a4l_cmd_t *)
Callback for command handling.
Definition: subdevice.h:217
int(* insn_bits)(struct a4l_subdevice *, a4l_kinsn_t *)
Callback for the instruction "bits".
Definition: subdevice.h:213
a4l_subd_t * a4l_alloc_subd(int sizeof_priv, void(*setup)(a4l_subd_t *))
Allocate a subdevice descriptor.
int(* trigger)(struct a4l_subdevice *, lsampl_t)
Callback for trigger operation.
Definition: subdevice.h:225
struct a4l_device * dev
Containing device.
Definition: subdevice.h:185
unsigned long flags
Type flags.
Definition: subdevice.h:199