Xenomai  3.1
analogy.h
Go to the documentation of this file.
1 
21 #ifndef _RTDM_UAPI_ANALOGY_H
22 #define _RTDM_UAPI_ANALOGY_H
23 
24 /* --- Misc precompilation constant --- */
25 #define A4L_NAMELEN 20
26 
27 #define A4L_INFINITE 0
28 #define A4L_NONBLOCK (-1)
29 
30 /* --- Common Analogy types --- */
31 
32 typedef unsigned short sampl_t;
33 typedef unsigned long lsampl_t;
34 
35 /* MMAP ioctl argument structure */
36 struct a4l_mmap_arg {
37  unsigned int idx_subd;
38  unsigned long size;
39  void *ptr;
40 };
41 typedef struct a4l_mmap_arg a4l_mmap_t;
42 
43 /* Constants related with buffer size
44  (might be used with BUFCFG ioctl) */
45 #define A4L_BUF_MAXSIZE 0x1000000
46 #define A4L_BUF_DEFSIZE 0x10000
47 #define A4L_BUF_DEFMAGIC 0xffaaff55
48 
49 /* BUFCFG ioctl argument structure */
50 struct a4l_buffer_config {
51  /* NOTE: with the last buffer implementation, the field
52  idx_subd became useless; the buffer are now
53  per-context. So, the buffer size configuration is specific
54  to an opened device. There is a little exception: we can
55  define a default buffer size for a device.
56  So far, a hack is used to implement the configuration of
57  the default buffer size */
58  unsigned int idx_subd;
59  unsigned long buf_size;
60 };
61 typedef struct a4l_buffer_config a4l_bufcfg_t;
62 
63 /* BUFINFO ioctl argument structure */
64 struct a4l_buffer_info {
65  unsigned int idx_subd;
66  unsigned long buf_size;
67  unsigned long rw_count;
68 };
69 typedef struct a4l_buffer_info a4l_bufinfo_t;
70 
71 /* BUFCFG2 / BUFINFO2 ioctl argument structure */
72 struct a4l_buffer_config2 {
73  unsigned long wake_count;
74  unsigned long reserved[3];
75 };
76 typedef struct a4l_buffer_config2 a4l_bufcfg2_t;
77 
78 /* POLL ioctl argument structure */
79 struct a4l_poll {
80  unsigned int idx_subd;
81  unsigned long arg;
82 };
83 typedef struct a4l_poll a4l_poll_t;
84 
85 /* DEVCFG ioctl argument structure */
86 struct a4l_link_desc {
87  unsigned char bname_size;
88  char *bname;
89  unsigned int opts_size;
90  void *opts;
91 };
92 typedef struct a4l_link_desc a4l_lnkdesc_t;
93 
94 /* DEVINFO ioctl argument structure */
95 struct a4l_dev_info {
96  char board_name[A4L_NAMELEN];
97  char driver_name[A4L_NAMELEN];
98  int nb_subd;
99  int idx_read_subd;
100  int idx_write_subd;
101 };
102 typedef struct a4l_dev_info a4l_dvinfo_t;
103 
104 #define CIO 'd'
105 #define A4L_DEVCFG _IOW(CIO,0,a4l_lnkdesc_t)
106 #define A4L_DEVINFO _IOR(CIO,1,a4l_dvinfo_t)
107 #define A4L_SUBDINFO _IOR(CIO,2,a4l_sbinfo_t)
108 #define A4L_CHANINFO _IOR(CIO,3,a4l_chinfo_arg_t)
109 #define A4L_RNGINFO _IOR(CIO,4,a4l_rnginfo_arg_t)
110 #define A4L_CMD _IOWR(CIO,5,a4l_cmd_t)
111 #define A4L_CANCEL _IOR(CIO,6,unsigned int)
112 #define A4L_INSNLIST _IOR(CIO,7,unsigned int)
113 #define A4L_INSN _IOR(CIO,8,unsigned int)
114 #define A4L_BUFCFG _IOR(CIO,9,a4l_bufcfg_t)
115 #define A4L_BUFINFO _IOWR(CIO,10,a4l_bufinfo_t)
116 #define A4L_POLL _IOR(CIO,11,unsigned int)
117 #define A4L_MMAP _IOWR(CIO,12,unsigned int)
118 #define A4L_NBCHANINFO _IOR(CIO,13,a4l_chinfo_arg_t)
119 #define A4L_NBRNGINFO _IOR(CIO,14,a4l_rnginfo_arg_t)
120 
121 /* These IOCTLs are bound to be merged with A4L_BUFCFG and A4L_BUFINFO
122  at the next major release */
123 #define A4L_BUFCFG2 _IOR(CIO,15,a4l_bufcfg_t)
124 #define A4L_BUFINFO2 _IOWR(CIO,16,a4l_bufcfg_t)
125 
140 #define A4L_CMD_SIMUL 0x1
141 
144 #define A4L_CMD_BULK 0x2
145 
148 #define A4L_CMD_WRITE 0x4
149 
161 #define TRIG_NONE 0x00000001
162 
165 #define TRIG_NOW 0x00000002
166 
169 #define TRIG_FOLLOW 0x00000004
170 
173 #define TRIG_TIME 0x00000008
174 
177 #define TRIG_TIMER 0x00000010
178 
181 #define TRIG_COUNT 0x00000020
182 
185 #define TRIG_EXT 0x00000040
186 
189 #define TRIG_INT 0x00000080
190 
193 #define TRIG_OTHER 0x00000100
194 
197 #define TRIG_WAKE_EOS 0x0020
198 
201 #define TRIG_ROUND_MASK 0x00030000
202 
205 #define TRIG_ROUND_NEAREST 0x00000000
206 
209 #define TRIG_ROUND_DOWN 0x00010000
210 
213 #define TRIG_ROUND_UP 0x00020000
214 
217 #define TRIG_ROUND_UP_NEXT 0x00030000
218 
231 #define CHAN(a) ((a) & 0xffff)
232 
235 #define RNG(a) (((a) & 0xff) << 16)
236 
239 #define AREF(a) (((a) & 0x03) << 24)
240 
243 #define FLAGS(a) ((a) & CR_FLAGS_MASK)
244 
247 #define PACK(a, b, c) (a | RNG(b) | AREF(c))
248 
251 #define PACK_FLAGS(a, b, c, d) (PACK(a, b, c) | FLAGS(d))
252 
256 #define AREF_GROUND 0x00
257 
260 #define AREF_COMMON 0x01
261 
264 #define AREF_DIFF 0x02
265 
268 #define AREF_OTHER 0x03
269 
272 #if !defined(DOXYGEN_CPP)
273 
274 #define CR_FLAGS_MASK 0xfc000000
275 #define CR_ALT_FILTER (1<<26)
276 #define CR_DITHER CR_ALT_FILTER
277 #define CR_DEGLITCH CR_ALT_FILTER
278 #define CR_ALT_SOURCE (1<<27)
279 #define CR_EDGE (1<<30)
280 #define CR_INVERT (1<<31)
281 
282 #endif /* !DOXYGEN_CPP */
283 
289 struct a4l_cmd_desc {
290  unsigned char idx_subd;
293  unsigned long flags;
296  /* Command trigger characteristics */
297  unsigned int start_src;
299  unsigned int start_arg;
301  unsigned int scan_begin_src;
303  unsigned int scan_begin_arg;
305  unsigned int convert_src;
307  unsigned int convert_arg;
309  unsigned int scan_end_src;
311  unsigned int scan_end_arg;
313  unsigned int stop_src;
315  unsigned int stop_arg;
318  unsigned char nb_chan;
320  unsigned int *chan_descs;
323  /* Driver specific fields */
324  unsigned int valid_simul_stages;
327  unsigned int data_len;
329  sampl_t *data;
331 };
332 typedef struct a4l_cmd_desc a4l_cmd_t;
333 
336 /* --- Range section --- */
337 
340 #define A4L_RNG_FACTOR 1000000
341 
345 #define A4L_RNG_VOLT_UNIT 0x0
346 
349 #define A4L_RNG_MAMP_UNIT 0x1
350 
353 #define A4L_RNG_NO_UNIT 0x2
354 
357 #define A4L_RNG_EXT_UNIT 0x4
358 
362 #define A4L_RNG_UNIT(x) (x & (A4L_RNG_VOLT_UNIT | \
363  A4L_RNG_MAMP_UNIT | \
364  A4L_RNG_NO_UNIT | \
365  A4L_RNG_EXT_UNIT))
366 
367 /* --- Subdevice flags desc stuff --- */
368 
369 /* TODO: replace ANALOGY_SUBD_AI with ANALOGY_SUBD_ANALOG
370  and ANALOGY_SUBD_INPUT */
371 
372 /* Subdevice types masks */
373 #define A4L_SUBD_MASK_READ 0x80000000
374 #define A4L_SUBD_MASK_WRITE 0x40000000
375 #define A4L_SUBD_MASK_SPECIAL 0x20000000
376 
391 #define A4L_SUBD_UNUSED (A4L_SUBD_MASK_SPECIAL|0x1)
392 
395 #define A4L_SUBD_AI (A4L_SUBD_MASK_READ|0x2)
396 
399 #define A4L_SUBD_AO (A4L_SUBD_MASK_WRITE|0x4)
400 
403 #define A4L_SUBD_DI (A4L_SUBD_MASK_READ|0x8)
404 
407 #define A4L_SUBD_DO (A4L_SUBD_MASK_WRITE|0x10)
408 
411 #define A4L_SUBD_DIO (A4L_SUBD_MASK_SPECIAL|0x20)
412 
415 #define A4L_SUBD_COUNTER (A4L_SUBD_MASK_SPECIAL|0x40)
416 
419 #define A4L_SUBD_TIMER (A4L_SUBD_MASK_SPECIAL|0x80)
420 
423 #define A4L_SUBD_MEMORY (A4L_SUBD_MASK_SPECIAL|0x100)
424 
427 #define A4L_SUBD_CALIB (A4L_SUBD_MASK_SPECIAL|0x200)
428 
431 #define A4L_SUBD_PROC (A4L_SUBD_MASK_SPECIAL|0x400)
432 
435 #define A4L_SUBD_SERIAL (A4L_SUBD_MASK_SPECIAL|0x800)
436 
439 #define A4L_SUBD_TYPES (A4L_SUBD_UNUSED | \
440  A4L_SUBD_AI | \
441  A4L_SUBD_AO | \
442  A4L_SUBD_DI | \
443  A4L_SUBD_DO | \
444  A4L_SUBD_DIO | \
445  A4L_SUBD_COUNTER | \
446  A4L_SUBD_TIMER | \
447  A4L_SUBD_MEMORY | \
448  A4L_SUBD_CALIB | \
449  A4L_SUBD_PROC | \
450  A4L_SUBD_SERIAL)
451 
460 /* Subdevice capabilities */
465 #define A4L_SUBD_CMD 0x1000
466 
471 #define A4L_SUBD_MMAP 0x8000
472 
481 /* Subdevice status flag(s) */
486 #define A4L_SUBD_BUSY_NR 0
487 #define A4L_SUBD_BUSY (1 << A4L_SUBD_BUSY_NR)
488 
493 #define A4L_SUBD_CLEAN_NR 1
494 #define A4L_SUBD_CLEAN (1 << A4L_SUBD_CLEAN_NR)
495 
496 
499 /* --- Subdevice related IOCTL arguments structures --- */
500 
501 /* SUDBINFO IOCTL argument */
502 struct a4l_subd_info {
503  unsigned long flags;
504  unsigned long status;
505  unsigned char nb_chan;
506 };
507 typedef struct a4l_subd_info a4l_sbinfo_t;
508 
509 /* CHANINFO / NBCHANINFO IOCTL arguments */
510 struct a4l_chan_info {
511  unsigned long chan_flags;
512  unsigned char nb_rng;
513  unsigned char nb_bits;
514 };
515 typedef struct a4l_chan_info a4l_chinfo_t;
516 
517 struct a4l_chinfo_arg {
518  unsigned int idx_subd;
519  void *info;
520 };
521 typedef struct a4l_chinfo_arg a4l_chinfo_arg_t;
522 
523 /* RNGINFO / NBRNGINFO IOCTL arguments */
524 struct a4l_rng_info {
525  long min;
526  long max;
527  unsigned long flags;
528 };
529 typedef struct a4l_rng_info a4l_rnginfo_t;
530 
531 struct a4l_rng_info_arg {
532  unsigned int idx_subd;
533  unsigned int idx_chan;
534  void *info;
535 };
536 typedef struct a4l_rng_info_arg a4l_rnginfo_arg_t;
537 
540 #define A4L_INSN_MASK_READ 0x8000000
541 #define A4L_INSN_MASK_WRITE 0x4000000
542 #define A4L_INSN_MASK_SPECIAL 0x2000000
543 
558 #define A4L_INSN_READ (0 | A4L_INSN_MASK_READ)
559 
562 #define A4L_INSN_WRITE (1 | A4L_INSN_MASK_WRITE)
563 
566 #define A4L_INSN_BITS (2 | A4L_INSN_MASK_READ | \
567  A4L_INSN_MASK_WRITE)
568 
571 #define A4L_INSN_CONFIG (3 | A4L_INSN_MASK_READ | \
572  A4L_INSN_MASK_WRITE)
573 
576 #define A4L_INSN_GTOD (4 | A4L_INSN_MASK_READ | \
577  A4L_INSN_MASK_SPECIAL)
578 
581 #define A4L_INSN_WAIT (5 | A4L_INSN_MASK_WRITE | \
582  A4L_INSN_MASK_SPECIAL)
583 
586 #define A4L_INSN_INTTRIG (6 | A4L_INSN_MASK_WRITE | \
587  A4L_INSN_MASK_SPECIAL)
588 
594 #define A4L_INSN_WAIT_MAX 100000
595 
602 #define A4L_INSN_CONFIG_DIO_INPUT 0
603 #define A4L_INSN_CONFIG_DIO_OUTPUT 1
604 #define A4L_INSN_CONFIG_DIO_OPENDRAIN 2
605 #define A4L_INSN_CONFIG_ANALOG_TRIG 16
606 #define A4L_INSN_CONFIG_ALT_SOURCE 20
607 #define A4L_INSN_CONFIG_DIGITAL_TRIG 21
608 #define A4L_INSN_CONFIG_BLOCK_SIZE 22
609 #define A4L_INSN_CONFIG_TIMER_1 23
610 #define A4L_INSN_CONFIG_FILTER 24
611 #define A4L_INSN_CONFIG_CHANGE_NOTIFY 25
612 #define A4L_INSN_CONFIG_SERIAL_CLOCK 26
613 #define A4L_INSN_CONFIG_BIDIRECTIONAL_DATA 27
614 #define A4L_INSN_CONFIG_DIO_QUERY 28
615 #define A4L_INSN_CONFIG_PWM_OUTPUT 29
616 #define A4L_INSN_CONFIG_GET_PWM_OUTPUT 30
617 #define A4L_INSN_CONFIG_ARM 31
618 #define A4L_INSN_CONFIG_DISARM 32
619 #define A4L_INSN_CONFIG_GET_COUNTER_STATUS 33
620 #define A4L_INSN_CONFIG_RESET 34
621 #define A4L_INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR 1001 /* Use CTR as single pulsegenerator */
622 #define A4L_INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR 1002 /* Use CTR as pulsetraingenerator */
623 #define A4L_INSN_CONFIG_GPCT_QUADRATURE_ENCODER 1003 /* Use the counter as encoder */
624 #define A4L_INSN_CONFIG_SET_GATE_SRC 2001 /* Set gate source */
625 #define A4L_INSN_CONFIG_GET_GATE_SRC 2002 /* Get gate source */
626 #define A4L_INSN_CONFIG_SET_CLOCK_SRC 2003 /* Set master clock source */
627 #define A4L_INSN_CONFIG_GET_CLOCK_SRC 2004 /* Get master clock source */
628 #define A4L_INSN_CONFIG_SET_OTHER_SRC 2005 /* Set other source */
629 #define A4L_INSN_CONFIG_SET_COUNTER_MODE 4097
630 #define A4L_INSN_CONFIG_SET_ROUTING 4099
631 #define A4L_INSN_CONFIG_GET_ROUTING 4109
632 
641 #define A4L_COUNTER_ARMED 0x1
642 #define A4L_COUNTER_COUNTING 0x2
643 #define A4L_COUNTER_TERMINAL_COUNT 0x4
644 
653 #define A4L_INPUT 0
654 #define A4L_OUTPUT 1
655 #define A4L_OPENDRAIN 2
656 
667 #define A4L_EV_START 0x00040000
668 #define A4L_EV_SCAN_BEGIN 0x00080000
669 #define A4L_EV_CONVERT 0x00100000
670 #define A4L_EV_SCAN_END 0x00200000
671 #define A4L_EV_STOP 0x00400000
672 
681  unsigned int type;
683  unsigned int idx_subd;
685  unsigned int chan_desc;
687  unsigned int data_size;
689  void *data;
691 };
692 typedef struct a4l_instruction a4l_insn_t;
693 
700  unsigned int count;
704 };
705 typedef struct a4l_instruction_list a4l_insnlst_t;
706 
709 struct a4l_calibration_subdev {
710  a4l_sbinfo_t *info;
711  char *name;
712  int slen;
713  int idx;
714 };
715 
716 struct a4l_calibration_subdev_data {
717  int index;
718  int channel;
719  int range;
720  int expansion;
721  int nb_coeff;
722  double *coeff;
723 
724 };
725 
726 struct a4l_calibration_data {
727  char *driver_name;
728  char *board_name;
729  int nb_ai;
730  struct a4l_calibration_subdev_data *ai;
731  int nb_ao;
732  struct a4l_calibration_subdev_data *ao;
733 };
734 
735 struct a4l_polynomial {
736  int expansion;
737  int order;
738  int nb_coeff;
739  double *coeff;
740 };
741 
742 
743 #endif /* _RTDM_UAPI_ANALOGY_H */
unsigned int scan_begin_arg
Scan begin trigger argument.
Definition: analogy.h:303
unsigned int idx_subd
Subdevice to which the instruction will be applied.
Definition: analogy.h:683
unsigned int stop_arg
Stop trigger argument.
Definition: analogy.h:315
unsigned int chan_desc
Channel descriptor.
Definition: analogy.h:685
sampl_t * data
Driver specific buffer pointer.
Definition: analogy.h:329
Structure describing the asynchronous instruction.
Definition: analogy.h:289
void * data
Instruction data.
Definition: analogy.h:689
int a4l_poll(a4l_desc_t *dsc, unsigned int idx_subd, unsigned long ms_timeout)
Get the available data count.
Definition: async.c:286
unsigned char idx_subd
Subdevice to which the command will be applied.
Definition: analogy.h:290
a4l_insn_t * insns
Tab containing the instructions pointers.
Definition: analogy.h:702
unsigned long flags
Command flags.
Definition: analogy.h:293
unsigned int scan_begin_src
Scan begin trigger type.
Definition: analogy.h:301
unsigned int convert_src
Convert trigger type.
Definition: analogy.h:305
unsigned int * chan_descs
Tab containing channels descriptors.
Definition: analogy.h:320
unsigned int start_arg
Start trigger argument.
Definition: analogy.h:299
Structure describing the synchronous instruction.
Definition: analogy.h:680
unsigned int data_size
Size of the intruction data.
Definition: analogy.h:687
unsigned int type
Instruction type.
Definition: analogy.h:681
unsigned int scan_end_arg
Scan end trigger argument.
Definition: analogy.h:311
unsigned int scan_end_src
Scan end trigger type.
Definition: analogy.h:309
unsigned int count
Instructions count.
Definition: analogy.h:700
unsigned int start_src
Start trigger type.
Definition: analogy.h:297
unsigned int convert_arg
Convert trigger argument.
Definition: analogy.h:307
unsigned char nb_chan
Count of channels related with the command.
Definition: analogy.h:318
unsigned int data_len
< cmd simulation valid stages (driver dependent)
Definition: analogy.h:327
Structure describing the list of synchronous instructions.
Definition: analogy.h:699
unsigned int stop_src
Stop trigger type.
Definition: analogy.h:313