Synced with comedi.
[comedilib.git] / swig / comedi.i
1 /***********************************************************
2            Interface file for wrapping Comedilib
3
4     Copyright (C) 2003 Bryan Cole  <bryan.cole@teraview.co.uk>
5     Copyright (C) 1998-2002 David A. Schleef <ds@schleef.org>
6     Copyright (C) 2003,2004 Frank Mori Hess <fmhess@users.sourceforge.net>
7     Copyright (C) 2003 Steven Jenkins <steven.jenkins@ieee.org>
8
9     This program is free software; you can redistribute it and/or modify
10     it under the terms of the GNU Lesser General Public License as published by
11     the Free Software Foundation; either version 2 of the License, or
12     (at your option) any later version.
13
14     This program is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License for more details.
18
19     You should have received a copy of the GNU General Public License
20     along with this program; if not, write to the Free Software
21     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 ***********************************************************
24 *
25 *     This file was created with Python wrappers in mind but wil
26 *  probably work for other swig-supported script languages
27 *
28 *    to regenerate the wrappers run:
29 *    swig -python comedi.i
30 *
31 ***********************************************************/
32 %module comedi
33 %{
34 #include "comedilib.h"
35 %}
36 %include "carrays.i"
37 %include "typemaps.i"
38
39 %inline %{
40 static unsigned int cr_pack(unsigned int chan, unsigned int rng, unsigned int aref){
41         return CR_PACK(chan,rng,aref);
42 }
43 static unsigned int cr_pack_flags(unsigned int chan, unsigned int rng, unsigned int aref, unsigned int flags){
44         return CR_PACK_FLAGS(chan,rng,aref, flags);
45 }
46 static unsigned int cr_chan(unsigned int a){
47         return CR_CHAN(a);
48 }
49 static unsigned int cr_range(unsigned int a){
50         return CR_RANGE(a);
51 }
52 static unsigned int cr_aref(unsigned int a){
53         return CR_AREF(a);
54 }
55 %}
56
57 %array_class(unsigned int, chanlist);
58
59 %typemap(ruby, argout) comedi_cmd *INOUT(VALUE info) {
60     $result = output_helper($result, $arg);
61 };
62
63 /* below are (modified) copies of comedi.h and comedilib.h */
64
65 /* comedi.h */
66
67 /* comedi's major device number */
68 #define COMEDI_MAJOR 98
69
70 /*
71    maximum number of minor devices.  This can be increased, although
72    kernel structures are currently statically allocated, thus you
73    don't want this to be much more than you actually use.
74  */
75 #define COMEDI_NDEVICES 16
76
77 /* number of config options in the config structure */
78 #define COMEDI_NDEVCONFOPTS 32
79 /*length of nth chunk of firmware data*/
80 #define COMEDI_DEVCONF_AUX_DATA3_LENGTH         25
81 #define COMEDI_DEVCONF_AUX_DATA2_LENGTH         26
82 #define COMEDI_DEVCONF_AUX_DATA1_LENGTH         27
83 #define COMEDI_DEVCONF_AUX_DATA0_LENGTH         28
84 #define COMEDI_DEVCONF_AUX_DATA_HI              29      /*most significant 32 bits of pointer address (if needed)*/
85 #define COMEDI_DEVCONF_AUX_DATA_LO              30      /*least significant 32 bits of pointer address*/
86 #define COMEDI_DEVCONF_AUX_DATA_LENGTH  31      /* total data length */
87
88 /* max length of device and driver names */
89 #define COMEDI_NAMELEN 20
90
91
92 typedef unsigned int lsampl_t;
93 typedef unsigned short sampl_t;
94
95 /* packs and unpacks a channel/range number */
96
97 #define CR_PACK(chan,rng,aref)          ( (((aref)&0x3)<<24) | (((rng)&0xff)<<16) | (chan) )
98 #define CR_PACK_FLAGS(chan, range, aref, flags) (CR_PACK(chan, range, aref) | ((flags) & CR_FLAGS_MASK))
99
100 #define CR_CHAN(a)      ((a)&0xffff)
101 #define CR_RANGE(a)     (((a)>>16)&0xff)
102 #define CR_AREF(a)      (((a)>>24)&0x03)
103
104 #define CR_FLAGS_MASK   0xfc000000
105 #define CR_ALT_FILTER   (1<<26)
106 #define CR_DITHER               CR_ALT_FILTER
107 #define CR_DEGLITCH             CR_ALT_FILTER
108 #define CR_ALT_SOURCE   (1<<27)
109 #define CR_EDGE (1<<30)
110 #define CR_INVERT       (1<<31)
111
112 #define AREF_GROUND     0x00            /* analog ref = analog ground */
113 #define AREF_COMMON     0x01            /* analog ref = analog common */
114 #define AREF_DIFF       0x02            /* analog ref = differential */
115 #define AREF_OTHER      0x03            /* analog ref = other (undefined) */
116
117 /* counters -- these are arbitrary values */
118 #define GPCT_RESET              0x0001
119 #define GPCT_SET_SOURCE         0x0002
120 #define GPCT_SET_GATE           0x0004
121 #define GPCT_SET_DIRECTION      0x0008
122 #define GPCT_SET_OPERATION      0x0010
123 #define GPCT_ARM                0x0020
124 #define GPCT_DISARM             0x0040
125 #define GPCT_GET_INT_CLK_FRQ    0x0080
126
127 #define GPCT_INT_CLOCK          0x0001
128 #define GPCT_EXT_PIN            0x0002
129 #define GPCT_NO_GATE            0x0004
130 #define GPCT_UP                 0x0008
131 #define GPCT_DOWN               0x0010
132 #define GPCT_HWUD               0x0020
133 #define GPCT_SIMPLE_EVENT       0x0040
134 #define GPCT_SINGLE_PERIOD      0x0080
135 #define GPCT_SINGLE_PW          0x0100
136 #define GPCT_CONT_PULSE_OUT     0x0200
137 #define GPCT_SINGLE_PULSE_OUT   0x0400
138
139 /* instructions */
140
141 #define INSN_MASK_WRITE         0x8000000
142 #define INSN_MASK_READ          0x4000000
143 #define INSN_MASK_SPECIAL       0x2000000
144
145 #define INSN_READ               ( 0 | INSN_MASK_READ)
146 #define INSN_WRITE              ( 1 | INSN_MASK_WRITE)
147 #define INSN_BITS               ( 2 | INSN_MASK_READ|INSN_MASK_WRITE)
148 #define INSN_CONFIG             ( 3 | INSN_MASK_READ|INSN_MASK_WRITE)
149 #define INSN_GTOD               ( 4 | INSN_MASK_READ|INSN_MASK_SPECIAL)
150 #define INSN_WAIT               ( 5 | INSN_MASK_WRITE|INSN_MASK_SPECIAL)
151 #define INSN_INTTRIG            ( 6 | INSN_MASK_WRITE|INSN_MASK_SPECIAL)
152
153 /* trigger flags */
154 /* These flags are used in comedi_trig structures */
155
156 #define TRIG_BOGUS      0x0001          /* do the motions */
157 #define TRIG_DITHER     0x0002          /* enable dithering */
158 #define TRIG_DEGLITCH   0x0004          /* enable deglitching */
159 //#define TRIG_RT       0x0008          /* perform op in real time */
160 #define TRIG_CONFIG     0x0010          /* perform configuration, not triggering */
161 #define TRIG_WAKE_EOS   0x0020          /* wake up on end-of-scan events */
162 //#define TRIG_WRITE    0x0040          /* write to bidirectional devices */
163
164 /* command flags */
165 /* These flags are used in comedi_cmd structures */
166
167 #define CMDF_PRIORITY           0x00000008 /* try to use a real-time interrupt while performing command */
168
169 #define TRIG_RT         CMDF_PRIORITY /* compatibility definition */
170
171 #define CMDF_WRITE              0x00000040
172 #define TRIG_WRITE      CMDF_WRITE /* compatibility definition */
173
174 #define CMDF_RAWDATA            0x00000080
175
176 #define COMEDI_EV_START         0x00040000
177 #define COMEDI_EV_SCAN_BEGIN    0x00080000
178 #define COMEDI_EV_CONVERT       0x00100000
179 #define COMEDI_EV_SCAN_END      0x00200000
180 #define COMEDI_EV_STOP          0x00400000
181
182 #define TRIG_ROUND_MASK         0x00030000
183 #define TRIG_ROUND_NEAREST      0x00000000
184 #define TRIG_ROUND_DOWN         0x00010000
185 #define TRIG_ROUND_UP           0x00020000
186 #define TRIG_ROUND_UP_NEXT      0x00030000
187
188 /* trigger sources */
189
190 #define TRIG_ANY        0xffffffff
191 #define TRIG_INVALID    0x00000000
192
193 #define TRIG_NONE       0x00000001      /* never trigger */
194 #define TRIG_NOW        0x00000002      /* trigger now + N ns */
195 #define TRIG_FOLLOW     0x00000004      /* trigger on next lower level trig */
196 #define TRIG_TIME       0x00000008      /* trigger at time N ns */
197 #define TRIG_TIMER      0x00000010      /* trigger at rate N ns */
198 #define TRIG_COUNT      0x00000020      /* trigger when count reaches N */
199 #define TRIG_EXT        0x00000040      /* trigger on external signal N */
200 #define TRIG_INT        0x00000080      /* trigger on comedi-internal signal N */
201 #define TRIG_OTHER      0x00000100      /* driver defined */
202
203 /* subdevice flags */
204
205 #define SDF_BUSY        0x0001          /* device is busy */
206 #define SDF_BUSY_OWNER  0x0002          /* device is busy with your job */
207 #define SDF_LOCKED      0x0004          /* subdevice is locked */
208 #define SDF_LOCK_OWNER  0x0008          /* you own lock */
209 #define SDF_MAXDATA     0x0010          /* maxdata depends on channel */
210 #define SDF_FLAGS       0x0020          /* flags depend on channel */
211 #define SDF_RANGETYPE   0x0040          /* range type depends on channel */
212 #define SDF_MODE0       0x0080          /* can do mode 0 */
213 #define SDF_MODE1       0x0100          /* can do mode 1 */
214 #define SDF_MODE2       0x0200          /* can do mode 2 */
215 #define SDF_MODE3       0x0400          /* can do mode 3 */
216 #define SDF_MODE4       0x0800          /* can do mode 4 */
217 #define SDF_CMD         0x1000          /* can do commands (deprecated) */
218 #define SDF_SOFT_CALIBRATED     0x2000  /* subdevice uses software calibration */
219 #define SDF_CMD_WRITE           0x4000          /* can do output commands */
220 #define SDF_CMD_READ            0x8000          /* can do input commands */
221
222 #define SDF_READABLE    0x00010000      /* subdevice can be read (e.g. analog input) */
223 #define SDF_WRITABLE    0x00020000      /* subdevice can be written (e.g. analog output) */
224 #define SDF_WRITEABLE   SDF_WRITABLE    /* spelling error in API */
225 #define SDF_INTERNAL    0x00040000      /* subdevice does not have externally visible lines */
226 #define SDF_RT          0x00080000      /* DEPRECATED: subdevice is RT capable */
227 #define SDF_GROUND      0x00100000      /* can do aref=ground */
228 #define SDF_COMMON      0x00200000      /* can do aref=common */
229 #define SDF_DIFF        0x00400000      /* can do aref=diff */
230 #define SDF_OTHER       0x00800000      /* can do aref=other */
231 #define SDF_DITHER      0x01000000      /* can do dithering */
232 #define SDF_DEGLITCH    0x02000000      /* can do deglitching */
233 #define SDF_MMAP        0x04000000      /* can do mmap() */
234 #define SDF_RUNNING     0x08000000      /* subdevice is acquiring data */
235 #define SDF_LSAMPL      0x10000000      /* subdevice uses 32-bit samples */
236 #define SDF_PACKED      0x20000000      /* subdevice can do packed DIO */
237
238 /* subdevice types */
239
240 enum comedi_subdevice_type
241 {
242         COMEDI_SUBD_UNUSED,     /* unused by driver */
243         COMEDI_SUBD_AI, /* analog input */
244         COMEDI_SUBD_AO, /* analog output */
245         COMEDI_SUBD_DI, /* digital input */
246         COMEDI_SUBD_DO, /* digital output */
247         COMEDI_SUBD_DIO,        /* digital input/output */
248         COMEDI_SUBD_COUNTER,    /* counter */
249         COMEDI_SUBD_TIMER,      /* timer */
250         COMEDI_SUBD_MEMORY,     /* memory, EEPROM, DPRAM */
251         COMEDI_SUBD_CALIB,      /* calibration DACs */
252         COMEDI_SUBD_PROC,       /* processor, DSP */
253         COMEDI_SUBD_SERIAL      /* serial IO */
254 };
255
256 /* configuration instructions */
257
258 enum configuration_ids
259 {
260         INSN_CONFIG_DIO_INPUT = 0,
261         INSN_CONFIG_DIO_OUTPUT = 1,
262         INSN_CONFIG_DIO_OPENDRAIN = 2,
263         INSN_CONFIG_ANALOG_TRIG = 16,
264 //      INSN_CONFIG_WAVEFORM = 17,
265 //      INSN_CONFIG_TRIG = 18,
266 //      INSN_CONFIG_COUNTER = 19,
267         INSN_CONFIG_ALT_SOURCE = 20,
268         INSN_CONFIG_DIGITAL_TRIG = 21,
269         INSN_CONFIG_BLOCK_SIZE = 22,
270         INSN_CONFIG_TIMER_1 = 23,
271         INSN_CONFIG_FILTER = 24,
272         INSN_CONFIG_CHANGE_NOTIFY = 25,
273
274         /*ALPHA*/
275         INSN_CONFIG_SERIAL_CLOCK = 26,
276         INSN_CONFIG_BIDIRECTIONAL_DATA = 27,
277         INSN_CONFIG_DIO_QUERY = 28,
278         INSN_CONFIG_PWM_OUTPUT = 29,
279         INSN_CONFIG_GET_PWM_OUTPUT = 30,
280         INSN_CONFIG_ARM = 31,
281         INSN_CONFIG_DISARM = 32,
282         INSN_CONFIG_GET_COUNTER_STATUS = 33,
283         INSN_CONFIG_RESET = 34,
284         INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR = 1001, // Use CTR as single pulsegenerator
285         INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR = 1002, // Use CTR as pulsetraingenerator
286         INSN_CONFIG_GPCT_QUADRATURE_ENCODER = 1003, // Use the counter as encoder
287         INSN_CONFIG_SET_GATE_SRC = 2001,        // Set gate source
288         INSN_CONFIG_GET_GATE_SRC = 2002,        // Get gate source
289         INSN_CONFIG_SET_CLOCK_SRC = 2003,       // Set master clock source
290         INSN_CONFIG_GET_CLOCK_SRC = 2004,       // Get master clock source
291         INSN_CONFIG_SET_OTHER_SRC = 2005,       // Set other source
292 //      INSN_CONFIG_GET_OTHER_SRC = 2006,       // Get other source
293         INSN_CONFIG_SET_COUNTER_MODE = 4097,
294         INSN_CONFIG_8254_SET_MODE = INSN_CONFIG_SET_COUNTER_MODE,       /* deprecated */
295         INSN_CONFIG_8254_READ_STATUS = 4098,
296         INSN_CONFIG_SET_ROUTING = 4099,
297         INSN_CONFIG_GET_ROUTING = 4109,
298 };
299
300 enum comedi_io_direction
301 {
302         COMEDI_INPUT = 0,
303         COMEDI_OUTPUT = 1,
304         COMEDI_OPENDRAIN = 2
305 };
306
307 /* ioctls */
308
309 #define CIO 'd'
310 #define COMEDI_DEVCONFIG _IOW(CIO,0,comedi_devconfig)
311 #define COMEDI_DEVINFO _IOR(CIO,1,comedi_devinfo)
312 #define COMEDI_SUBDINFO _IOR(CIO,2,comedi_subdinfo)
313 #define COMEDI_CHANINFO _IOR(CIO,3,comedi_chaninfo)
314 #define COMEDI_TRIG _IOWR(CIO,4,comedi_trig)
315 #define COMEDI_LOCK _IO(CIO,5)
316 #define COMEDI_UNLOCK _IO(CIO,6)
317 #define COMEDI_CANCEL _IO(CIO,7)
318 #define COMEDI_RANGEINFO _IOR(CIO,8,comedi_rangeinfo)
319 #define COMEDI_CMD _IOR(CIO,9,comedi_cmd)
320 #define COMEDI_CMDTEST _IOR(CIO,10,comedi_cmd)
321 #define COMEDI_INSNLIST _IOR(CIO,11,comedi_insnlist)
322 #define COMEDI_INSN _IOR(CIO,12,comedi_insn)
323 #define COMEDI_BUFCONFIG _IOR(CIO,13,comedi_bufconfig)
324 #define COMEDI_BUFINFO _IOWR(CIO,14,comedi_bufinfo)
325 #define COMEDI_POLL _IO(CIO,15)
326
327
328 /* structures */
329
330 typedef struct comedi_trig_struct comedi_trig;
331 typedef struct comedi_cmd_struct comedi_cmd;
332 typedef struct comedi_insn_struct comedi_insn;
333 typedef struct comedi_insnlist_struct comedi_insnlist;
334 typedef struct comedi_chaninfo_struct comedi_chaninfo;
335 typedef struct comedi_subdinfo_struct comedi_subdinfo;
336 typedef struct comedi_devinfo_struct comedi_devinfo;
337 typedef struct comedi_devconfig_struct comedi_devconfig;
338 typedef struct comedi_rangeinfo_struct comedi_rangeinfo;
339 typedef struct comedi_krange_struct comedi_krange;
340 typedef struct comedi_bufconfig_struct comedi_bufconfig;
341 typedef struct comedi_bufinfo_struct comedi_bufinfo;
342
343 struct comedi_trig_struct{
344         unsigned int subdev;            /* subdevice */
345         unsigned int mode;              /* mode */
346         unsigned int flags;
347         unsigned int n_chan;            /* number of channels */
348         unsigned int *chanlist;         /* channel/range list */
349         sampl_t *data;                  /* data list, size depends on subd flags */
350         unsigned int n;                 /* number of scans */
351         unsigned int trigsrc;
352         unsigned int trigvar;
353         unsigned int trigvar1;
354         unsigned int data_len;
355         unsigned int unused[3];
356 };
357
358 struct comedi_insn_struct{
359         unsigned int insn;
360         unsigned int n;
361         lsampl_t *data;
362         unsigned int subdev;
363         unsigned int chanspec;
364         unsigned int unused[3];
365 };
366
367 struct comedi_insnlist_struct{
368         unsigned int n_insns;
369         comedi_insn *insns;
370 };
371
372 struct comedi_cmd_struct{
373         unsigned int subdev;
374         unsigned int flags;
375
376         unsigned int start_src;
377         unsigned int start_arg;
378
379         unsigned int scan_begin_src;
380         unsigned int scan_begin_arg;
381
382         unsigned int convert_src;
383         unsigned int convert_arg;
384
385         unsigned int scan_end_src;
386         unsigned int scan_end_arg;
387
388         unsigned int stop_src;
389         unsigned int stop_arg;
390
391         unsigned int *chanlist;         /* channel/range list */
392         unsigned int chanlist_len;
393
394         sampl_t *data;                  /* data list, size depends on subd flags */
395         unsigned int data_len;
396 };
397
398 struct comedi_chaninfo_struct{
399         unsigned int subdev;
400         lsampl_t *maxdata_list;
401         unsigned int *flaglist;
402         unsigned int *rangelist;
403         unsigned int unused[4];
404 };
405
406 struct comedi_rangeinfo_struct{
407         unsigned int range_type;
408         void *range_ptr;
409 };
410
411 struct comedi_krange_struct{
412         int min;        /* fixed point, multiply by 1e-6 */
413         int max;        /* fixed point, multiply by 1e-6 */
414         unsigned int flags;
415 };
416
417 struct comedi_subdinfo_struct{
418         unsigned int type;
419         unsigned int n_chan;
420         unsigned int subd_flags;
421         unsigned int timer_type;
422         unsigned int len_chanlist;
423         lsampl_t        maxdata;
424         unsigned int    flags;          /* channel flags */
425         unsigned int    range_type;     /* lookup in kernel */
426         unsigned int    settling_time_0;
427         unsigned int unused[9];
428 };
429
430 struct comedi_devinfo_struct{
431         unsigned int version_code;
432         unsigned int n_subdevs;
433         char driver_name[COMEDI_NAMELEN];
434         char board_name[COMEDI_NAMELEN];
435         int read_subdevice;
436         int write_subdevice;
437         int unused[30];
438 };
439
440 struct comedi_devconfig_struct{
441         char board_name[COMEDI_NAMELEN];
442         int options[COMEDI_NDEVCONFOPTS];
443 };
444
445 struct comedi_bufconfig_struct{
446         unsigned int subdevice;
447         unsigned int flags;
448
449         unsigned int maximum_size;
450         unsigned int size;
451
452         unsigned int unused[4];
453 };
454
455 struct comedi_bufinfo_struct{
456         unsigned int subdevice;
457         unsigned int bytes_read;
458
459         unsigned int buf_write_ptr;
460         unsigned int buf_read_ptr;
461         unsigned int buf_write_count;
462         unsigned int buf_read_count;
463
464         unsigned int bytes_written;
465
466         unsigned int unused[4];
467 };
468
469 /* range stuff */
470
471 #define __RANGE(a,b)    ((((a)&0xffff)<<16)|((b)&0xffff))
472
473 #define RANGE_OFFSET(a)         (((a)>>16)&0xffff)
474 #define RANGE_LENGTH(b)         ((b)&0xffff)
475
476 #define RF_UNIT(flags)          ((flags)&0xff)
477 #define RF_EXTERNAL             (1<<8)
478
479 #define UNIT_volt               0
480 #define UNIT_mA                 1
481 #define UNIT_none               2
482
483 #define COMEDI_MIN_SPEED        ((unsigned int)0xffffffff)
484
485 /* callback stuff */
486 /* only relevant to kernel modules. */
487
488 #define COMEDI_CB_EOS           1       /* end of scan */
489 #define COMEDI_CB_EOA           2       /* end of acquisition */
490 #define COMEDI_CB_BLOCK         4       /* DEPRECATED: convenient block size */
491 #define COMEDI_CB_EOBUF         8       /* DEPRECATED: end of buffer */
492 #define COMEDI_CB_ERROR         16      /* card error during acquisition */
493 #define COMEDI_CB_OVERFLOW      32      /* buffer overflow/underflow */
494
495 /**********************************************************/
496 /* everything after this line is ALPHA */
497 /**********************************************************/
498
499 /*
500   8254 specific configuration.
501
502   It supports two config commands:
503
504   0 ID: INSN_CONFIG_SET_COUNTER_MODE
505   1 8254 Mode
506     I8254_MODE0, I8254_MODE1, ..., I8254_MODE5
507     OR'ed with:
508     I8254_BCD, I8254_BINARY
509
510   0 ID: INSN_CONFIG_8254_READ_STATUS
511   1 <-- Status byte returned here.
512     B7=Output
513     B6=NULL Count
514     B5-B0 Current mode.
515
516 */
517
518 enum i8254_mode
519 {
520         I8254_MODE0 = (0<<1),  /* Interrupt on terminal count */
521         I8254_MODE1 = (1<<1),  /* Hardware retriggerable one-shot */
522         I8254_MODE2 = (2<<1),  /* Rate generator */
523         I8254_MODE3 = (3<<1),  /* Square wave mode */
524         I8254_MODE4 = (4<<1),  /* Software triggered strobe */
525         I8254_MODE5 = (5<<1),  /* Hardware triggered strobe (retriggerable) */
526         I8254_BCD = 1, /* use binary-coded decimal instead of binary (pretty useless) */
527         I8254_BINARY = 0
528 };
529
530 /* mode bits for NI general-purpose counters, set with INSN_CONFIG_SET_COUNTER_MODE */
531 #define NI_GPCT_COUNTING_MODE_SHIFT 16
532 #define NI_GPCT_INDEX_PHASE_BITSHIFT 20
533 #define NI_GPCT_COUNTING_DIRECTION_SHIFT 24
534 enum ni_gpct_mode_bits
535 {
536         NI_GPCT_GATE_ON_BOTH_EDGES_BIT = 0x4,
537         NI_GPCT_EDGE_GATE_MODE_MASK = 0x18,
538         NI_GPCT_EDGE_GATE_STARTS_STOPS_BITS = 0x0,
539         NI_GPCT_EDGE_GATE_STOPS_STARTS_BITS = 0x8,
540         NI_GPCT_EDGE_GATE_STARTS_BITS = 0x10,
541         NI_GPCT_EDGE_GATE_NO_STARTS_NO_STOPS_BITS = 0x18,
542         NI_GPCT_STOP_MODE_MASK = 0x60,
543         NI_GPCT_STOP_ON_GATE_BITS = 0x00,
544         NI_GPCT_STOP_ON_GATE_OR_TC_BITS = 0x20,
545         NI_GPCT_STOP_ON_GATE_OR_SECOND_TC_BITS = 0x40,
546         NI_GPCT_LOAD_B_SELECT_BIT = 0x80,
547         NI_GPCT_OUTPUT_MODE_MASK = 0x300,
548         NI_GPCT_OUTPUT_TC_PULSE_BITS = 0x100,
549         NI_GPCT_OUTPUT_TC_TOGGLE_BITS = 0x200,
550         NI_GPCT_OUTPUT_TC_OR_GATE_TOGGLE_BITS = 0x300,
551         NI_GPCT_HARDWARE_DISARM_MASK = 0xc00,
552         NI_GPCT_NO_HARDWARE_DISARM_BITS = 0x000,
553         NI_GPCT_DISARM_AT_TC_BITS = 0x400,
554         NI_GPCT_DISARM_AT_GATE_BITS = 0x800,
555         NI_GPCT_DISARM_AT_TC_OR_GATE_BITS = 0xc00,
556         NI_GPCT_LOADING_ON_TC_BIT = 0x1000,
557         NI_GPCT_LOADING_ON_GATE_BIT = 0x4000,
558         NI_GPCT_COUNTING_MODE_MASK = 0x7 << NI_GPCT_COUNTING_MODE_SHIFT,
559         NI_GPCT_COUNTING_MODE_NORMAL_BITS = 0x0 << NI_GPCT_COUNTING_MODE_SHIFT,
560         NI_GPCT_COUNTING_MODE_QUADRATURE_X1_BITS = 0x1 << NI_GPCT_COUNTING_MODE_SHIFT,
561         NI_GPCT_COUNTING_MODE_QUADRATURE_X2_BITS = 0x2 << NI_GPCT_COUNTING_MODE_SHIFT,
562         NI_GPCT_COUNTING_MODE_QUADRATURE_X4_BITS = 0x3 << NI_GPCT_COUNTING_MODE_SHIFT,
563         NI_GPCT_COUNTING_MODE_TWO_PULSE_BITS = 0x4 << NI_GPCT_COUNTING_MODE_SHIFT,
564         NI_GPCT_COUNTING_MODE_SYNC_SOURCE_BITS = 0x6 << NI_GPCT_COUNTING_MODE_SHIFT,
565         NI_GPCT_INDEX_PHASE_MASK = 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT,
566         NI_GPCT_INDEX_PHASE_LOW_A_LOW_B_BITS = 0x0 << NI_GPCT_INDEX_PHASE_BITSHIFT,
567         NI_GPCT_INDEX_PHASE_LOW_A_HIGH_B_BITS = 0x1 << NI_GPCT_INDEX_PHASE_BITSHIFT,
568         NI_GPCT_INDEX_PHASE_HIGH_A_LOW_B_BITS = 0x2 << NI_GPCT_INDEX_PHASE_BITSHIFT,
569         NI_GPCT_INDEX_PHASE_HIGH_A_HIGH_B_BITS = 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT,
570         NI_GPCT_INDEX_ENABLE_BIT = 0x400000,
571         NI_GPCT_COUNTING_DIRECTION_MASK = 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
572         NI_GPCT_COUNTING_DIRECTION_DOWN_BITS = 0x00 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
573         NI_GPCT_COUNTING_DIRECTION_UP_BITS = 0x1 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
574         NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS = 0x2 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
575         NI_GPCT_COUNTING_DIRECTION_HW_GATE_BITS = 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
576         NI_GPCT_RELOAD_SOURCE_MASK = 0xc000000,
577         NI_GPCT_RELOAD_SOURCE_FIXED_BITS = 0x0,
578         NI_GPCT_RELOAD_SOURCE_SWITCHING_BITS = 0x4000000,
579         NI_GPCT_RELOAD_SOURCE_GATE_SELECT_BITS = 0x8000000,
580         NI_GPCT_OR_GATE_BIT = 0x10000000,
581         NI_GPCT_INVERT_OUTPUT_BIT = 0x20000000
582 };
583
584 /* Bits for setting a clock source with
585  * INSN_CONFIG_SET_CLOCK_SRC when using NI general-purpose counters. */
586 enum ni_gpct_clock_source_bits
587 {
588         NI_GPCT_CLOCK_SRC_SELECT_MASK = 0x3f,
589         NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS = 0x0,
590         NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS = 0x1,
591         NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS = 0x2,
592         NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS = 0x3,
593         NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS = 0x4,
594         NI_GPCT_NEXT_TC_CLOCK_SRC_BITS = 0x5,
595         NI_GPCT_SOURCE_PIN_i_CLOCK_SRC_BITS = 0x6, /* NI 660x-specific */
596         NI_GPCT_PXI10_CLOCK_SRC_BITS = 0x7,
597         NI_GPCT_PXI_STAR_TRIGGER_CLOCK_SRC_BITS = 0x8,
598         NI_GPCT_ANALOG_TRIGGER_OUT_CLOCK_SRC_BITS = 0x9,
599         NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK = 0x30000000,
600         NI_GPCT_NO_PRESCALE_CLOCK_SRC_BITS = 0x0,
601         NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS = 0x10000000,        /* divide source by 2 */
602         NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS = 0x20000000,        /* divide source by 8 */
603         NI_GPCT_INVERT_CLOCK_SRC_BIT = 0x80000000
604 };
605
606 /* Possibilities for setting a gate source with
607 INSN_CONFIG_SET_GATE_SRC when using NI general-purpose counters.
608 May be bitwise-or'd with CR_EDGE or CR_INVERT. */
609 enum ni_gpct_gate_select
610 {
611         /* m-series gates */
612         NI_GPCT_TIMESTAMP_MUX_GATE_SELECT = 0x0,
613         NI_GPCT_AI_START2_GATE_SELECT = 0x12,
614         NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT = 0x13,
615         NI_GPCT_NEXT_OUT_GATE_SELECT = 0x14,
616         NI_GPCT_AI_START1_GATE_SELECT = 0x1c,
617         NI_GPCT_NEXT_SOURCE_GATE_SELECT = 0x1d,
618         NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT = 0x1e,
619         NI_GPCT_LOGIC_LOW_GATE_SELECT = 0x1f,
620         /* more gates for 660x */
621         NI_GPCT_SOURCE_PIN_i_GATE_SELECT = 0x100,
622         NI_GPCT_GATE_PIN_i_GATE_SELECT = 0x101,
623         /* more gates for 660x "second gate" */
624         NI_GPCT_UP_DOWN_PIN_i_GATE_SELECT = 0x201,
625         NI_GPCT_SELECTED_GATE_GATE_SELECT = 0x21e,
626         /* m-series "second gate" sources are unknown,
627         we should add them here with an offset of 0x300 when known. */
628         NI_GPCT_DISABLED_GATE_SELECT = 0x8000,
629 };
630
631 /* Possibilities for setting a source with
632 INSN_CONFIG_SET_OTHER_SRC when using NI general-purpose counters. */
633 enum ni_gpct_other_index {
634   NI_GPCT_SOURCE_ENCODER_A,
635   NI_GPCT_SOURCE_ENCODER_B,
636   NI_GPCT_SOURCE_ENCODER_Z
637 };
638 enum ni_gpct_other_select
639 {
640         /* m-series gates */
641         // Still unknown, probably only need NI_GPCT_PFI_OTHER_SELECT
642         NI_GPCT_DISABLED_OTHER_SELECT = 0x8000,
643 };
644
645
646 /* start sources for ni general-purpose counters for use with
647 INSN_CONFIG_ARM */
648 enum ni_gpct_arm_source
649 {
650         NI_GPCT_ARM_IMMEDIATE = 0x0,
651         NI_GPCT_ARM_PAIRED_IMMEDIATE = 0x1, /* Start both the counter and the adjacent paired counter simultaneously */
652         /* NI doesn't document bits for selecting hardware arm triggers.  If
653         the NI_GPCT_ARM_UNKNOWN bit is set, we will pass the least significant
654         bits (3 bits for 660x or 5 bits for m-series) through to the hardware.
655         This will at least allow someone to figure out what the bits do later.*/
656         NI_GPCT_ARM_UNKNOWN = 0x1000,
657 };
658
659 /* digital filtering options for ni 660x for use with INSN_CONFIG_FILTER. */
660 enum ni_gpct_filter_select
661 {
662         NI_GPCT_FILTER_OFF = 0x0,
663         NI_GPCT_FILTER_TIMEBASE_3_SYNC = 0x1,
664         NI_GPCT_FILTER_100x_TIMEBASE_1= 0x2,
665         NI_GPCT_FILTER_20x_TIMEBASE_1 = 0x3,
666         NI_GPCT_FILTER_10x_TIMEBASE_1 = 0x4,
667         NI_GPCT_FILTER_2x_TIMEBASE_1 = 0x5,
668         NI_GPCT_FILTER_2x_TIMEBASE_3 = 0x6
669 };
670
671 /* PFI digital filtering options for ni m-series for use with INSN_CONFIG_FILTER. */
672 enum ni_pfi_filter_select
673 {
674         NI_PFI_FILTER_OFF = 0x0,
675         NI_PFI_FILTER_125ns = 0x1,
676         NI_PFI_FILTER_6425ns = 0x2,
677         NI_PFI_FILTER_2550us = 0x3
678 };
679
680 /* master clock sources for ni mio boards and INSN_CONFIG_SET_CLOCK_SRC */
681 enum ni_mio_clock_source
682 {
683         NI_MIO_INTERNAL_CLOCK = 0,
684         NI_MIO_RTSI_CLOCK = 1,  /* doesn't work for m-series, use NI_MIO_PLL_RTSI_CLOCK() */
685         /* the NI_MIO_PLL_* sources are m-series only */
686         NI_MIO_PLL_PXI_STAR_TRIGGER_CLOCK = 2,
687         NI_MIO_PLL_PXI10_CLOCK = 3,
688         NI_MIO_PLL_RTSI0_CLOCK = 4
689 };
690
691 /* Signals which can be routed to an NI RTSI pin with INSN_CONFIG_SET_ROUTING.
692  The numbers assigned are not arbitrary, they correspond to the bits required
693  to program the board. */
694 enum ni_rtsi_routing
695 {
696         NI_RTSI_OUTPUT_ADR_START1 = 0,
697         NI_RTSI_OUTPUT_ADR_START2 = 1,
698         NI_RTSI_OUTPUT_SCLKG = 2,
699         NI_RTSI_OUTPUT_DACUPDN = 3,
700         NI_RTSI_OUTPUT_DA_START1 = 4,
701         NI_RTSI_OUTPUT_G_SRC0 = 5,
702         NI_RTSI_OUTPUT_G_GATE0 = 6,
703         NI_RTSI_OUTPUT_RGOUT0 = 7,
704         NI_RTSI_OUTPUT_RTSI_BRD_0 = 8,
705         NI_RTSI_OUTPUT_RTSI_OSC = 12 /* pre-m-series always have RTSI clock on line 7 */
706 };
707
708 /* Signals which can be routed to an NI PFI pin on an m-series board
709  with INSN_CONFIG_SET_ROUTING.  These numbers are also returned
710  by INSN_CONFIG_GET_ROUTING on pre-m-series boards, even though
711  their routing cannot be changed.  The numbers assigned are
712  not arbitrary, they correspond to the bits required
713  to program the board. */
714 enum ni_pfi_routing
715 {
716         NI_PFI_OUTPUT_PFI_DEFAULT = 0,
717         NI_PFI_OUTPUT_AI_START1 = 1,
718         NI_PFI_OUTPUT_AI_START2 = 2,
719         NI_PFI_OUTPUT_AI_CONVERT = 3,
720         NI_PFI_OUTPUT_G_SRC1 = 4,
721         NI_PFI_OUTPUT_G_GATE1 = 5,
722         NI_PFI_OUTPUT_AO_UPDATE_N = 6,
723         NI_PFI_OUTPUT_AO_START1 = 7,
724         NI_PFI_OUTPUT_AI_START_PULSE = 8,
725         NI_PFI_OUTPUT_G_SRC0 = 9,
726         NI_PFI_OUTPUT_G_GATE0 = 10,
727         NI_PFI_OUTPUT_EXT_STROBE = 11,
728         NI_PFI_OUTPUT_AI_EXT_MUX_CLK = 12,
729         NI_PFI_OUTPUT_GOUT0 = 13,
730         NI_PFI_OUTPUT_GOUT1 = 14,
731         NI_PFI_OUTPUT_FREQ_OUT = 15,
732         NI_PFI_OUTPUT_PFI_DO = 16,
733         NI_PFI_OUTPUT_I_ATRIG = 17,
734         NI_PFI_OUTPUT_RTSI0 = 18,
735         NI_PFI_OUTPUT_PXI_STAR_TRIGGER_IN = 26,
736         NI_PFI_OUTPUT_SCXI_TRIG1 = 27,
737         NI_PFI_OUTPUT_DIO_CHANGE_DETECT_RTSI = 28,
738         NI_PFI_OUTPUT_CDI_SAMPLE = 29,
739         NI_PFI_OUTPUT_CDO_UPDATE = 30
740 };
741
742 /* NI External Trigger lines.  These values are not arbitrary, but are related to
743         the bits required to program the board (offset by 1 for historical reasons). */
744
745 /* status bits for INSN_CONFIG_GET_COUNTER_STATUS */
746 enum comedi_counter_status_flags
747 {
748         COMEDI_COUNTER_ARMED = 0x1,
749         COMEDI_COUNTER_COUNTING = 0x2,
750         COMEDI_COUNTER_TERMINAL_COUNT = 0x4,
751 };
752
753 /* comedilib.h */
754
755 typedef struct comedi_t_struct comedi_t;
756
757 typedef struct{
758         double min;
759         double max;
760         unsigned int unit;
761 }comedi_range;
762
763 typedef struct comedi_sv_struct{
764         comedi_t *dev;
765         unsigned int subdevice;
766         unsigned int chan;
767
768         /* range policy */
769         int range;
770         int aref;
771
772         /* number of measurements to average (for ai) */
773         int n;
774
775         lsampl_t maxdata;
776 }comedi_sv_t;
777
778 enum comedi_oor_behavior {
779         COMEDI_OOR_NUMBER = 0,
780         COMEDI_OOR_NAN
781 };
782
783
784
785
786 comedi_t *comedi_open(const char *fn);
787 int comedi_close(comedi_t *it);
788
789 /* logging */
790 int comedi_loglevel(int loglevel);
791 void comedi_perror(const char *s);
792 char *comedi_strerror(int errnum);
793 int comedi_errno(void);
794 int comedi_fileno(comedi_t *it);
795
796 /* global behavior */
797 enum comedi_oor_behavior comedi_set_global_oor_behavior(enum comedi_oor_behavior behavior);
798
799 /* device queries */
800 int comedi_get_n_subdevices(comedi_t *it);
801 #define COMEDI_VERSION_CODE(a,b,c) (((a)<<16) | ((b)<<8) | (c))
802 int comedi_get_version_code(comedi_t *it);
803 const char *comedi_get_driver_name(comedi_t *it);
804 const char *comedi_get_board_name(comedi_t *it);
805 int comedi_get_read_subdevice(comedi_t *dev);
806 int comedi_get_write_subdevice(comedi_t *dev);
807
808 /* subdevice queries */
809 int comedi_get_subdevice_type(comedi_t *it,unsigned int subdevice);
810 int comedi_find_subdevice_by_type(comedi_t *it,int type,unsigned int subd);
811 int comedi_get_subdevice_flags(comedi_t *it,unsigned int subdevice);
812 int comedi_get_n_channels(comedi_t *it,unsigned int subdevice);
813 int comedi_range_is_chan_specific(comedi_t *it,unsigned int subdevice);
814 int comedi_maxdata_is_chan_specific(comedi_t *it,unsigned int subdevice);
815
816 /* channel queries */
817 lsampl_t comedi_get_maxdata(comedi_t *it,unsigned int subdevice,
818         unsigned int chan);
819 int comedi_get_n_ranges(comedi_t *it,unsigned int subdevice,
820         unsigned int chan);
821 comedi_range * comedi_get_range(comedi_t *it,unsigned int subdevice,
822         unsigned int chan,unsigned int range);
823 int comedi_find_range(comedi_t *it,unsigned int subd,unsigned int chan,
824         unsigned int unit,double min,double max);
825
826 /* buffer queries */
827 int comedi_get_buffer_size(comedi_t *it,unsigned int subdevice);
828 int comedi_get_max_buffer_size(comedi_t *it,unsigned int subdevice);
829 int comedi_set_buffer_size(comedi_t *it,unsigned int subdevice,
830         unsigned int len);
831
832 /* low-level stuff */
833 #ifdef _COMEDILIB_DEPRECATED
834 int comedi_trigger(comedi_t *it,comedi_trig *trig); /* deprecated */
835 #endif
836 int comedi_do_insnlist(comedi_t *it,comedi_insnlist *il);
837 int comedi_do_insn(comedi_t *it,comedi_insn *insn);
838 int comedi_lock(comedi_t *it,unsigned int subdevice);
839 int comedi_unlock(comedi_t *it,unsigned int subdevice);
840
841 /* physical units */
842 double comedi_to_phys(lsampl_t data,comedi_range *rng,lsampl_t maxdata);
843 lsampl_t comedi_from_phys(double data,comedi_range *rng,lsampl_t maxdata);
844 int comedi_sampl_to_phys(double *dest, int dst_stride, sampl_t *src,
845         int src_stride, comedi_range *rng, lsampl_t maxdata, int n);
846 int comedi_sampl_from_phys(sampl_t *dest,int dst_stride,double *src,
847         int src_stride, comedi_range *rng, lsampl_t maxdata, int n);
848
849 /* syncronous stuff */
850 int comedi_data_read(comedi_t *it,unsigned int subd,unsigned int chan,
851         unsigned int range,unsigned int aref,lsampl_t *OUTPUT);
852 int comedi_data_read_n(comedi_t *it,unsigned int subd,unsigned int chan,
853         unsigned int range,unsigned int aref,lsampl_t *OUTPUT, unsigned int n);
854 int comedi_data_read_hint(comedi_t *it,unsigned int subd,unsigned int chan,
855         unsigned int range,unsigned int aref);
856 int comedi_data_read_delayed(comedi_t *it,unsigned int subd,unsigned int chan,
857         unsigned int range,unsigned int aref,lsampl_t *OUTPUT, unsigned int nano_sec);
858 int comedi_data_write(comedi_t *it,unsigned int subd,unsigned int chan,
859         unsigned int range,unsigned int aref,lsampl_t data);
860 int comedi_dio_config(comedi_t *it,unsigned int subd,unsigned int chan,
861         unsigned int dir);
862 int comedi_dio_get_config(comedi_t *it,unsigned int subd,unsigned int chan,
863         unsigned int *OUTPUT);
864 int comedi_dio_read(comedi_t *it,unsigned int subd,unsigned int chan,
865         unsigned int *OUTPUT);
866 int comedi_dio_write(comedi_t *it,unsigned int subd,unsigned int chan,
867         unsigned int bit);
868 int comedi_dio_bitfield(comedi_t *it,unsigned int subd,
869         unsigned int write_mask, unsigned int *INOUT);
870 int comedi_dio_bitfield2(comedi_t *it, unsigned int subd,
871         unsigned int write_mask, unsigned int *INOUT, unsigned base_channel);
872
873 /* slowly varying stuff */
874 int comedi_sv_init(comedi_sv_t *it,comedi_t *dev,unsigned int subd,unsigned int chan);
875 int comedi_sv_update(comedi_sv_t *it);
876 int comedi_sv_measure(comedi_sv_t *it,double *data);
877
878 /* streaming I/O (commands) */
879
880 int comedi_get_cmd_src_mask(comedi_t *dev,unsigned int subdevice,
881         comedi_cmd *INOUT);
882 int comedi_get_cmd_generic_timed(comedi_t *dev,unsigned int subdevice,
883         comedi_cmd *INOUT, unsigned chanlist_len, unsigned int scan_period_ns);
884 int comedi_cancel(comedi_t *it,unsigned int subdevice);
885 int comedi_command(comedi_t *it,comedi_cmd *cmd);
886 int comedi_command_test(comedi_t *it,comedi_cmd *INOUT);
887 int comedi_poll(comedi_t *dev,unsigned int subdevice);
888
889 /* buffer control */
890
891 int comedi_set_max_buffer_size(comedi_t *it, unsigned int subdev,
892         unsigned int max_size);
893 int comedi_get_buffer_contents(comedi_t *it, unsigned int subdev);
894 int comedi_mark_buffer_read(comedi_t *it, unsigned int subdev,
895         unsigned int bytes);
896 int comedi_mark_buffer_written(comedi_t *it, unsigned int subdev,
897         unsigned int bytes);
898 int comedi_get_buffer_offset(comedi_t *it, unsigned int subdev);
899
900 #ifdef _COMEDILIB_DEPRECATED
901 /*
902  * The following functions are deprecated and should not be used.
903  */
904 int comedi_get_timer(comedi_t *it,unsigned int subdev,double freq,
905         unsigned int *trigvar,double *actual_freq);
906 int comedi_timed_1chan(comedi_t *it,unsigned int subdev,unsigned int chan,
907         unsigned int range, unsigned int aref,double freq,
908         unsigned int n_samples,double *data);
909 int comedi_get_rangetype(comedi_t *it,unsigned int subdevice,
910         unsigned int chan);
911 int comedi_dio_bitfield(comedi_t *it,unsigned int subd,
912         unsigned int write_mask, unsigned int *bits);
913 #endif
914
915
916 #ifndef _COMEDILIB_STRICT_ABI
917 /*
918    The following prototypes are _NOT_ part of the Comedilib ABI, and
919    may change in future versions without regard to source or binary
920    compatibility.  In practice, this is a holding place for the next
921    library ABI version change.
922  */
923 /* structs and functions used for parsing calibration files */
924 typedef struct
925 {
926         unsigned int subdevice;
927         unsigned int channel;
928         unsigned int value;
929 } comedi_caldac_t;
930 #define COMEDI_MAX_NUM_POLYNOMIAL_COEFFICIENTS 4
931 typedef struct
932 {
933         double coefficients[COMEDI_MAX_NUM_POLYNOMIAL_COEFFICIENTS];
934         double expansion_origin;
935         unsigned order;
936 } comedi_polynomial_t;
937 typedef struct
938 {
939         comedi_polynomial_t *to_phys;
940         comedi_polynomial_t *from_phys;
941 } comedi_softcal_t;
942 #define CS_MAX_AREFS_LENGTH 4
943 typedef struct
944 {
945         unsigned int subdevice;
946         unsigned int *channels;
947         unsigned int num_channels;
948         unsigned int *ranges;
949         unsigned int num_ranges;
950         unsigned int arefs[ CS_MAX_AREFS_LENGTH ];
951         unsigned int num_arefs;
952         comedi_caldac_t *caldacs;
953         unsigned int num_caldacs;
954         comedi_softcal_t soft_calibration;
955 } comedi_calibration_setting_t;
956
957 typedef struct
958 {
959         char *driver_name;
960         char *board_name;
961         comedi_calibration_setting_t *settings;
962         unsigned int num_settings;
963 } comedi_calibration_t;
964
965 comedi_calibration_t* comedi_parse_calibration_file( const char *cal_file_path );
966 int comedi_apply_parsed_calibration( comedi_t *dev, unsigned int subdev, unsigned int channel,
967         unsigned int range, unsigned int aref, const comedi_calibration_t *calibration );
968 char* comedi_get_default_calibration_path( comedi_t *dev );
969 void comedi_cleanup_calibration( comedi_calibration_t *calibration );
970 int comedi_apply_calibration( comedi_t *dev, unsigned int subdev, unsigned int channel,
971         unsigned int range, unsigned int aref, const char *cal_file_path);
972
973 /* New stuff to provide conversion between integers and physical values that
974 * can support software calibrations. */
975 enum comedi_conversion_direction
976 {
977         COMEDI_TO_PHYSICAL,
978         COMEDI_FROM_PHYSICAL
979 };
980 int comedi_get_softcal_converter(
981         unsigned subdevice, unsigned channel, unsigned range,
982         enum comedi_conversion_direction direction,
983         const comedi_calibration_t *calibration, comedi_polynomial_t* OUTPUT);
984 int comedi_get_hardcal_converter(
985         comedi_t *dev, unsigned subdevice, unsigned channel, unsigned range,
986         enum comedi_conversion_direction direction, comedi_polynomial_t* OUTPUT);
987 double comedi_to_physical(lsampl_t data,
988         const comedi_polynomial_t *conversion_polynomial);
989 lsampl_t comedi_from_physical(double data,
990         const comedi_polynomial_t *conversion_polynomial);
991
992 #endif