comedi.h 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362
  1. /*
  2. * comedi.h
  3. * header file for COMEDI user API
  4. *
  5. * COMEDI - Linux Control and Measurement Device Interface
  6. * Copyright (C) 1998-2001 David A. Schleef <ds@schleef.org>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #ifndef _COMEDI_H
  19. #define _COMEDI_H
  20. #define COMEDI_MAJORVERSION 0
  21. #define COMEDI_MINORVERSION 7
  22. #define COMEDI_MICROVERSION 76
  23. #define VERSION "0.7.76"
  24. /* comedi's major device number */
  25. #define COMEDI_MAJOR 98
  26. /*
  27. * maximum number of minor devices. This can be increased, although
  28. * kernel structures are currently statically allocated, thus you
  29. * don't want this to be much more than you actually use.
  30. */
  31. #define COMEDI_NDEVICES 16
  32. /* number of config options in the config structure */
  33. #define COMEDI_NDEVCONFOPTS 32
  34. /*
  35. * NOTE: 'comedi_config --init-data' is deprecated
  36. *
  37. * The following indexes in the config options were used by
  38. * comedi_config to pass firmware blobs from user space to the
  39. * comedi drivers. The request_firmware() hotplug interface is
  40. * now used by all comedi drivers instead.
  41. */
  42. /* length of nth chunk of firmware data -*/
  43. #define COMEDI_DEVCONF_AUX_DATA3_LENGTH 25
  44. #define COMEDI_DEVCONF_AUX_DATA2_LENGTH 26
  45. #define COMEDI_DEVCONF_AUX_DATA1_LENGTH 27
  46. #define COMEDI_DEVCONF_AUX_DATA0_LENGTH 28
  47. /* most significant 32 bits of pointer address (if needed) */
  48. #define COMEDI_DEVCONF_AUX_DATA_HI 29
  49. /* least significant 32 bits of pointer address */
  50. #define COMEDI_DEVCONF_AUX_DATA_LO 30
  51. #define COMEDI_DEVCONF_AUX_DATA_LENGTH 31 /* total data length */
  52. /* max length of device and driver names */
  53. #define COMEDI_NAMELEN 20
  54. /* packs and unpacks a channel/range number */
  55. #define CR_PACK(chan, rng, aref) \
  56. ((((aref) & 0x3) << 24) | (((rng) & 0xff) << 16) | (chan))
  57. #define CR_PACK_FLAGS(chan, range, aref, flags) \
  58. (CR_PACK(chan, range, aref) | ((flags) & CR_FLAGS_MASK))
  59. #define CR_CHAN(a) ((a) & 0xffff)
  60. #define CR_RANGE(a) (((a) >> 16) & 0xff)
  61. #define CR_AREF(a) (((a) >> 24) & 0x03)
  62. #define CR_FLAGS_MASK 0xfc000000
  63. #define CR_ALT_FILTER 0x04000000
  64. #define CR_DITHER CR_ALT_FILTER
  65. #define CR_DEGLITCH CR_ALT_FILTER
  66. #define CR_ALT_SOURCE 0x08000000
  67. #define CR_EDGE 0x40000000
  68. #define CR_INVERT 0x80000000
  69. #define AREF_GROUND 0x00 /* analog ref = analog ground */
  70. #define AREF_COMMON 0x01 /* analog ref = analog common */
  71. #define AREF_DIFF 0x02 /* analog ref = differential */
  72. #define AREF_OTHER 0x03 /* analog ref = other (undefined) */
  73. /* counters -- these are arbitrary values */
  74. #define GPCT_RESET 0x0001
  75. #define GPCT_SET_SOURCE 0x0002
  76. #define GPCT_SET_GATE 0x0004
  77. #define GPCT_SET_DIRECTION 0x0008
  78. #define GPCT_SET_OPERATION 0x0010
  79. #define GPCT_ARM 0x0020
  80. #define GPCT_DISARM 0x0040
  81. #define GPCT_GET_INT_CLK_FRQ 0x0080
  82. #define GPCT_INT_CLOCK 0x0001
  83. #define GPCT_EXT_PIN 0x0002
  84. #define GPCT_NO_GATE 0x0004
  85. #define GPCT_UP 0x0008
  86. #define GPCT_DOWN 0x0010
  87. #define GPCT_HWUD 0x0020
  88. #define GPCT_SIMPLE_EVENT 0x0040
  89. #define GPCT_SINGLE_PERIOD 0x0080
  90. #define GPCT_SINGLE_PW 0x0100
  91. #define GPCT_CONT_PULSE_OUT 0x0200
  92. #define GPCT_SINGLE_PULSE_OUT 0x0400
  93. /* instructions */
  94. #define INSN_MASK_WRITE 0x8000000
  95. #define INSN_MASK_READ 0x4000000
  96. #define INSN_MASK_SPECIAL 0x2000000
  97. #define INSN_READ (0 | INSN_MASK_READ)
  98. #define INSN_WRITE (1 | INSN_MASK_WRITE)
  99. #define INSN_BITS (2 | INSN_MASK_READ | INSN_MASK_WRITE)
  100. #define INSN_CONFIG (3 | INSN_MASK_READ | INSN_MASK_WRITE)
  101. #define INSN_GTOD (4 | INSN_MASK_READ | INSN_MASK_SPECIAL)
  102. #define INSN_WAIT (5 | INSN_MASK_WRITE | INSN_MASK_SPECIAL)
  103. #define INSN_INTTRIG (6 | INSN_MASK_WRITE | INSN_MASK_SPECIAL)
  104. /* command flags */
  105. /* These flags are used in comedi_cmd structures */
  106. #define CMDF_BOGUS 0x00000001 /* do the motions */
  107. /* try to use a real-time interrupt while performing command */
  108. #define CMDF_PRIORITY 0x00000008
  109. /* wake up on end-of-scan events */
  110. #define CMDF_WAKE_EOS 0x00000020
  111. #define CMDF_WRITE 0x00000040
  112. #define CMDF_RAWDATA 0x00000080
  113. /* timer rounding definitions */
  114. #define CMDF_ROUND_MASK 0x00030000
  115. #define CMDF_ROUND_NEAREST 0x00000000
  116. #define CMDF_ROUND_DOWN 0x00010000
  117. #define CMDF_ROUND_UP 0x00020000
  118. #define CMDF_ROUND_UP_NEXT 0x00030000
  119. #define COMEDI_EV_START 0x00040000
  120. #define COMEDI_EV_SCAN_BEGIN 0x00080000
  121. #define COMEDI_EV_CONVERT 0x00100000
  122. #define COMEDI_EV_SCAN_END 0x00200000
  123. #define COMEDI_EV_STOP 0x00400000
  124. /* compatibility definitions */
  125. #define TRIG_BOGUS CMDF_BOGUS
  126. #define TRIG_RT CMDF_PRIORITY
  127. #define TRIG_WAKE_EOS CMDF_WAKE_EOS
  128. #define TRIG_WRITE CMDF_WRITE
  129. #define TRIG_ROUND_MASK CMDF_ROUND_MASK
  130. #define TRIG_ROUND_NEAREST CMDF_ROUND_NEAREST
  131. #define TRIG_ROUND_DOWN CMDF_ROUND_DOWN
  132. #define TRIG_ROUND_UP CMDF_ROUND_UP
  133. #define TRIG_ROUND_UP_NEXT CMDF_ROUND_UP_NEXT
  134. /* trigger sources */
  135. #define TRIG_ANY 0xffffffff
  136. #define TRIG_INVALID 0x00000000
  137. #define TRIG_NONE 0x00000001 /* never trigger */
  138. #define TRIG_NOW 0x00000002 /* trigger now + N ns */
  139. #define TRIG_FOLLOW 0x00000004 /* trigger on next lower level trig */
  140. #define TRIG_TIME 0x00000008 /* trigger at time N ns */
  141. #define TRIG_TIMER 0x00000010 /* trigger at rate N ns */
  142. #define TRIG_COUNT 0x00000020 /* trigger when count reaches N */
  143. #define TRIG_EXT 0x00000040 /* trigger on external signal N */
  144. #define TRIG_INT 0x00000080 /* trigger on comedi-internal signal N */
  145. #define TRIG_OTHER 0x00000100 /* driver defined */
  146. /* subdevice flags */
  147. #define SDF_BUSY 0x0001 /* device is busy */
  148. #define SDF_BUSY_OWNER 0x0002 /* device is busy with your job */
  149. #define SDF_LOCKED 0x0004 /* subdevice is locked */
  150. #define SDF_LOCK_OWNER 0x0008 /* you own lock */
  151. #define SDF_MAXDATA 0x0010 /* maxdata depends on channel */
  152. #define SDF_FLAGS 0x0020 /* flags depend on channel */
  153. #define SDF_RANGETYPE 0x0040 /* range type depends on channel */
  154. #define SDF_PWM_COUNTER 0x0080 /* PWM can automatically switch off */
  155. #define SDF_PWM_HBRIDGE 0x0100 /* PWM is signed (H-bridge) */
  156. #define SDF_CMD 0x1000 /* can do commands (deprecated) */
  157. #define SDF_SOFT_CALIBRATED 0x2000 /* subdevice uses software calibration */
  158. #define SDF_CMD_WRITE 0x4000 /* can do output commands */
  159. #define SDF_CMD_READ 0x8000 /* can do input commands */
  160. /* subdevice can be read (e.g. analog input) */
  161. #define SDF_READABLE 0x00010000
  162. /* subdevice can be written (e.g. analog output) */
  163. #define SDF_WRITABLE 0x00020000
  164. #define SDF_WRITEABLE SDF_WRITABLE /* spelling error in API */
  165. /* subdevice does not have externally visible lines */
  166. #define SDF_INTERNAL 0x00040000
  167. #define SDF_GROUND 0x00100000 /* can do aref=ground */
  168. #define SDF_COMMON 0x00200000 /* can do aref=common */
  169. #define SDF_DIFF 0x00400000 /* can do aref=diff */
  170. #define SDF_OTHER 0x00800000 /* can do aref=other */
  171. #define SDF_DITHER 0x01000000 /* can do dithering */
  172. #define SDF_DEGLITCH 0x02000000 /* can do deglitching */
  173. #define SDF_MMAP 0x04000000 /* can do mmap() */
  174. #define SDF_RUNNING 0x08000000 /* subdevice is acquiring data */
  175. #define SDF_LSAMPL 0x10000000 /* subdevice uses 32-bit samples */
  176. #define SDF_PACKED 0x20000000 /* subdevice can do packed DIO */
  177. /* subdevice types */
  178. /**
  179. * enum comedi_subdevice_type - COMEDI subdevice types
  180. * @COMEDI_SUBD_UNUSED: Unused subdevice.
  181. * @COMEDI_SUBD_AI: Analog input.
  182. * @COMEDI_SUBD_AO: Analog output.
  183. * @COMEDI_SUBD_DI: Digital input.
  184. * @COMEDI_SUBD_DO: Digital output.
  185. * @COMEDI_SUBD_DIO: Digital input/output.
  186. * @COMEDI_SUBD_COUNTER: Counter.
  187. * @COMEDI_SUBD_TIMER: Timer.
  188. * @COMEDI_SUBD_MEMORY: Memory, EEPROM, DPRAM.
  189. * @COMEDI_SUBD_CALIB: Calibration DACs.
  190. * @COMEDI_SUBD_PROC: Processor, DSP.
  191. * @COMEDI_SUBD_SERIAL: Serial I/O.
  192. * @COMEDI_SUBD_PWM: Pulse-Width Modulation output.
  193. */
  194. enum comedi_subdevice_type {
  195. COMEDI_SUBD_UNUSED,
  196. COMEDI_SUBD_AI,
  197. COMEDI_SUBD_AO,
  198. COMEDI_SUBD_DI,
  199. COMEDI_SUBD_DO,
  200. COMEDI_SUBD_DIO,
  201. COMEDI_SUBD_COUNTER,
  202. COMEDI_SUBD_TIMER,
  203. COMEDI_SUBD_MEMORY,
  204. COMEDI_SUBD_CALIB,
  205. COMEDI_SUBD_PROC,
  206. COMEDI_SUBD_SERIAL,
  207. COMEDI_SUBD_PWM
  208. };
  209. /* configuration instructions */
  210. /**
  211. * enum configuration_ids - COMEDI configuration instruction codes
  212. * @INSN_CONFIG_DIO_INPUT: Configure digital I/O as input.
  213. * @INSN_CONFIG_DIO_OUTPUT: Configure digital I/O as output.
  214. * @INSN_CONFIG_DIO_OPENDRAIN: Configure digital I/O as open-drain (or open
  215. * collector) output.
  216. * @INSN_CONFIG_ANALOG_TRIG: Configure analog trigger.
  217. * @INSN_CONFIG_ALT_SOURCE: Configure alternate input source.
  218. * @INSN_CONFIG_DIGITAL_TRIG: Configure digital trigger.
  219. * @INSN_CONFIG_BLOCK_SIZE: Configure block size for DMA transfers.
  220. * @INSN_CONFIG_TIMER_1: Configure divisor for external clock.
  221. * @INSN_CONFIG_FILTER: Configure a filter.
  222. * @INSN_CONFIG_CHANGE_NOTIFY: Configure change notification for digital
  223. * inputs. (New drivers should use
  224. * %INSN_CONFIG_DIGITAL_TRIG instead.)
  225. * @INSN_CONFIG_SERIAL_CLOCK: Configure clock for serial I/O.
  226. * @INSN_CONFIG_BIDIRECTIONAL_DATA: Send and receive byte over serial I/O.
  227. * @INSN_CONFIG_DIO_QUERY: Query direction of digital I/O channel.
  228. * @INSN_CONFIG_PWM_OUTPUT: Configure pulse-width modulator output.
  229. * @INSN_CONFIG_GET_PWM_OUTPUT: Get pulse-width modulator output configuration.
  230. * @INSN_CONFIG_ARM: Arm a subdevice or channel.
  231. * @INSN_CONFIG_DISARM: Disarm a subdevice or channel.
  232. * @INSN_CONFIG_GET_COUNTER_STATUS: Get counter status.
  233. * @INSN_CONFIG_RESET: Reset a subdevice or channel.
  234. * @INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR: Configure counter/timer as
  235. * single pulse generator.
  236. * @INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR: Configure counter/timer as
  237. * pulse train generator.
  238. * @INSN_CONFIG_GPCT_QUADRATURE_ENCODER: Configure counter as a quadrature
  239. * encoder.
  240. * @INSN_CONFIG_SET_GATE_SRC: Set counter/timer gate source.
  241. * @INSN_CONFIG_GET_GATE_SRC: Get counter/timer gate source.
  242. * @INSN_CONFIG_SET_CLOCK_SRC: Set counter/timer master clock source.
  243. * @INSN_CONFIG_GET_CLOCK_SRC: Get counter/timer master clock source.
  244. * @INSN_CONFIG_SET_OTHER_SRC: Set counter/timer "other" source.
  245. * @INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE: Get size (in bytes) of subdevice's
  246. * on-board FIFOs used during streaming
  247. * input/output.
  248. * @INSN_CONFIG_SET_COUNTER_MODE: Set counter/timer mode.
  249. * @INSN_CONFIG_8254_SET_MODE: (Deprecated) Same as
  250. * %INSN_CONFIG_SET_COUNTER_MODE.
  251. * @INSN_CONFIG_8254_READ_STATUS: Read status of 8254 counter channel.
  252. * @INSN_CONFIG_SET_ROUTING: Set routing for a channel.
  253. * @INSN_CONFIG_GET_ROUTING: Get routing for a channel.
  254. * @INSN_CONFIG_PWM_SET_PERIOD: Set PWM period in nanoseconds.
  255. * @INSN_CONFIG_PWM_GET_PERIOD: Get PWM period in nanoseconds.
  256. * @INSN_CONFIG_GET_PWM_STATUS: Get PWM status.
  257. * @INSN_CONFIG_PWM_SET_H_BRIDGE: Set PWM H bridge duty cycle and polarity for
  258. * a relay simultaneously.
  259. * @INSN_CONFIG_PWM_GET_H_BRIDGE: Get PWM H bridge duty cycle and polarity.
  260. */
  261. enum configuration_ids {
  262. INSN_CONFIG_DIO_INPUT = 0,
  263. INSN_CONFIG_DIO_OUTPUT = 1,
  264. INSN_CONFIG_DIO_OPENDRAIN = 2,
  265. INSN_CONFIG_ANALOG_TRIG = 16,
  266. /* INSN_CONFIG_WAVEFORM = 17, */
  267. /* INSN_CONFIG_TRIG = 18, */
  268. /* INSN_CONFIG_COUNTER = 19, */
  269. INSN_CONFIG_ALT_SOURCE = 20,
  270. INSN_CONFIG_DIGITAL_TRIG = 21,
  271. INSN_CONFIG_BLOCK_SIZE = 22,
  272. INSN_CONFIG_TIMER_1 = 23,
  273. INSN_CONFIG_FILTER = 24,
  274. INSN_CONFIG_CHANGE_NOTIFY = 25,
  275. INSN_CONFIG_SERIAL_CLOCK = 26, /*ALPHA*/
  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,
  285. INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR = 1002,
  286. INSN_CONFIG_GPCT_QUADRATURE_ENCODER = 1003,
  287. INSN_CONFIG_SET_GATE_SRC = 2001,
  288. INSN_CONFIG_GET_GATE_SRC = 2002,
  289. INSN_CONFIG_SET_CLOCK_SRC = 2003,
  290. INSN_CONFIG_GET_CLOCK_SRC = 2004,
  291. INSN_CONFIG_SET_OTHER_SRC = 2005,
  292. INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE = 2006,
  293. INSN_CONFIG_SET_COUNTER_MODE = 4097,
  294. INSN_CONFIG_8254_SET_MODE = INSN_CONFIG_SET_COUNTER_MODE,
  295. INSN_CONFIG_8254_READ_STATUS = 4098,
  296. INSN_CONFIG_SET_ROUTING = 4099,
  297. INSN_CONFIG_GET_ROUTING = 4109,
  298. INSN_CONFIG_PWM_SET_PERIOD = 5000,
  299. INSN_CONFIG_PWM_GET_PERIOD = 5001,
  300. INSN_CONFIG_GET_PWM_STATUS = 5002,
  301. INSN_CONFIG_PWM_SET_H_BRIDGE = 5003,
  302. INSN_CONFIG_PWM_GET_H_BRIDGE = 5004
  303. };
  304. /**
  305. * enum comedi_digital_trig_op - operations for configuring a digital trigger
  306. * @COMEDI_DIGITAL_TRIG_DISABLE: Return digital trigger to its default,
  307. * inactive, unconfigured state.
  308. * @COMEDI_DIGITAL_TRIG_ENABLE_EDGES: Set rising and/or falling edge inputs
  309. * that each can fire the trigger.
  310. * @COMEDI_DIGITAL_TRIG_ENABLE_LEVELS: Set a combination of high and/or low
  311. * level inputs that can fire the trigger.
  312. *
  313. * These are used with the %INSN_CONFIG_DIGITAL_TRIG configuration instruction.
  314. * The data for the configuration instruction is as follows...
  315. *
  316. * data[%0] = %INSN_CONFIG_DIGITAL_TRIG
  317. *
  318. * data[%1] = trigger ID
  319. *
  320. * data[%2] = configuration operation
  321. *
  322. * data[%3] = configuration parameter 1
  323. *
  324. * data[%4] = configuration parameter 2
  325. *
  326. * data[%5] = configuration parameter 3
  327. *
  328. * The trigger ID (data[%1]) is used to differentiate multiple digital triggers
  329. * belonging to the same subdevice. The configuration operation (data[%2]) is
  330. * one of the enum comedi_digital_trig_op values. The configuration
  331. * parameters (data[%3], data[%4], and data[%5]) depend on the operation; they
  332. * are not used with %COMEDI_DIGITAL_TRIG_DISABLE.
  333. *
  334. * For %COMEDI_DIGITAL_TRIG_ENABLE_EDGES and %COMEDI_DIGITAL_TRIG_ENABLE_LEVELS,
  335. * configuration parameter 1 (data[%3]) contains a "left-shift" value that
  336. * specifies the input corresponding to bit 0 of configuration parameters 2
  337. * and 3. This is useful if the trigger has more than 32 inputs.
  338. *
  339. * For %COMEDI_DIGITAL_TRIG_ENABLE_EDGES, configuration parameter 2 (data[%4])
  340. * specifies which of up to 32 inputs have rising-edge sensitivity, and
  341. * configuration parameter 3 (data[%5]) specifies which of up to 32 inputs
  342. * have falling-edge sensitivity that can fire the trigger.
  343. *
  344. * For %COMEDI_DIGITAL_TRIG_ENABLE_LEVELS, configuration parameter 2 (data[%4])
  345. * specifies which of up to 32 inputs must be at a high level, and
  346. * configuration parameter 3 (data[%5]) specifies which of up to 32 inputs
  347. * must be at a low level for the trigger to fire.
  348. *
  349. * Some sequences of %INSN_CONFIG_DIGITAL_TRIG instructions may have a (partly)
  350. * accumulative effect, depending on the low-level driver. This is useful
  351. * when setting up a trigger that has more than 32 inputs, or has a combination
  352. * of edge- and level-triggered inputs.
  353. */
  354. enum comedi_digital_trig_op {
  355. COMEDI_DIGITAL_TRIG_DISABLE = 0,
  356. COMEDI_DIGITAL_TRIG_ENABLE_EDGES = 1,
  357. COMEDI_DIGITAL_TRIG_ENABLE_LEVELS = 2
  358. };
  359. /**
  360. * enum comedi_io_direction - COMEDI I/O directions
  361. * @COMEDI_INPUT: Input.
  362. * @COMEDI_OUTPUT: Output.
  363. * @COMEDI_OPENDRAIN: Open-drain (or open-collector) output.
  364. *
  365. * These are used by the %INSN_CONFIG_DIO_QUERY configuration instruction to
  366. * report a direction. They may also be used in other places where a direction
  367. * needs to be specified.
  368. */
  369. enum comedi_io_direction {
  370. COMEDI_INPUT = 0,
  371. COMEDI_OUTPUT = 1,
  372. COMEDI_OPENDRAIN = 2
  373. };
  374. /**
  375. * enum comedi_support_level - support level for a COMEDI feature
  376. * @COMEDI_UNKNOWN_SUPPORT: Unspecified support for feature.
  377. * @COMEDI_SUPPORTED: Feature is supported.
  378. * @COMEDI_UNSUPPORTED: Feature is unsupported.
  379. */
  380. enum comedi_support_level {
  381. COMEDI_UNKNOWN_SUPPORT = 0,
  382. COMEDI_SUPPORTED,
  383. COMEDI_UNSUPPORTED
  384. };
  385. /**
  386. * enum comedi_counter_status_flags - counter status bits
  387. * @COMEDI_COUNTER_ARMED: Counter is armed.
  388. * @COMEDI_COUNTER_COUNTING: Counter is counting.
  389. * @COMEDI_COUNTER_TERMINAL_COUNT: Counter reached terminal count.
  390. *
  391. * These bitwise values are used by the %INSN_CONFIG_GET_COUNTER_STATUS
  392. * configuration instruction to report the status of a counter.
  393. */
  394. enum comedi_counter_status_flags {
  395. COMEDI_COUNTER_ARMED = 0x1,
  396. COMEDI_COUNTER_COUNTING = 0x2,
  397. COMEDI_COUNTER_TERMINAL_COUNT = 0x4,
  398. };
  399. /* ioctls */
  400. #define CIO 'd'
  401. #define COMEDI_DEVCONFIG _IOW(CIO, 0, struct comedi_devconfig)
  402. #define COMEDI_DEVINFO _IOR(CIO, 1, struct comedi_devinfo)
  403. #define COMEDI_SUBDINFO _IOR(CIO, 2, struct comedi_subdinfo)
  404. #define COMEDI_CHANINFO _IOR(CIO, 3, struct comedi_chaninfo)
  405. /* _IOWR(CIO, 4, ...) is reserved */
  406. #define COMEDI_LOCK _IO(CIO, 5)
  407. #define COMEDI_UNLOCK _IO(CIO, 6)
  408. #define COMEDI_CANCEL _IO(CIO, 7)
  409. #define COMEDI_RANGEINFO _IOR(CIO, 8, struct comedi_rangeinfo)
  410. #define COMEDI_CMD _IOR(CIO, 9, struct comedi_cmd)
  411. #define COMEDI_CMDTEST _IOR(CIO, 10, struct comedi_cmd)
  412. #define COMEDI_INSNLIST _IOR(CIO, 11, struct comedi_insnlist)
  413. #define COMEDI_INSN _IOR(CIO, 12, struct comedi_insn)
  414. #define COMEDI_BUFCONFIG _IOR(CIO, 13, struct comedi_bufconfig)
  415. #define COMEDI_BUFINFO _IOWR(CIO, 14, struct comedi_bufinfo)
  416. #define COMEDI_POLL _IO(CIO, 15)
  417. #define COMEDI_SETRSUBD _IO(CIO, 16)
  418. #define COMEDI_SETWSUBD _IO(CIO, 17)
  419. /* structures */
  420. /**
  421. * struct comedi_insn - COMEDI instruction
  422. * @insn: COMEDI instruction type (%INSN_xxx).
  423. * @n: Length of @data[].
  424. * @data: Pointer to data array operated on by the instruction.
  425. * @subdev: Subdevice index.
  426. * @chanspec: A packed "chanspec" value consisting of channel number,
  427. * analog range index, analog reference type, and flags.
  428. * @unused: Reserved for future use.
  429. *
  430. * This is used with the %COMEDI_INSN ioctl, and indirectly with the
  431. * %COMEDI_INSNLIST ioctl.
  432. */
  433. struct comedi_insn {
  434. unsigned int insn;
  435. unsigned int n;
  436. unsigned int __user *data;
  437. unsigned int subdev;
  438. unsigned int chanspec;
  439. unsigned int unused[3];
  440. };
  441. /**
  442. * struct comedi_insnlist - list of COMEDI instructions
  443. * @n_insns: Number of COMEDI instructions.
  444. * @insns: Pointer to array COMEDI instructions.
  445. *
  446. * This is used with the %COMEDI_INSNLIST ioctl.
  447. */
  448. struct comedi_insnlist {
  449. unsigned int n_insns;
  450. struct comedi_insn __user *insns;
  451. };
  452. /**
  453. * struct comedi_cmd - COMEDI asynchronous acquisition command details
  454. * @subdev: Subdevice index.
  455. * @flags: Command flags (%CMDF_xxx).
  456. * @start_src: "Start acquisition" trigger source (%TRIG_xxx).
  457. * @start_arg: "Start acquisition" trigger argument.
  458. * @scan_begin_src: "Scan begin" trigger source.
  459. * @scan_begin_arg: "Scan begin" trigger argument.
  460. * @convert_src: "Convert" trigger source.
  461. * @convert_arg: "Convert" trigger argument.
  462. * @scan_end_src: "Scan end" trigger source.
  463. * @scan_end_arg: "Scan end" trigger argument.
  464. * @stop_src: "Stop acquisition" trigger source.
  465. * @stop_arg: "Stop acquisition" trigger argument.
  466. * @chanlist: Pointer to array of "chanspec" values, containing a
  467. * sequence of channel numbers packed with analog range
  468. * index, etc.
  469. * @chanlist_len: Number of channels in sequence.
  470. * @data: Pointer to miscellaneous set-up data (not used).
  471. * @data_len: Length of miscellaneous set-up data.
  472. *
  473. * This is used with the %COMEDI_CMD or %COMEDI_CMDTEST ioctl to set-up
  474. * or validate an asynchronous acquisition command. The ioctl may modify
  475. * the &struct comedi_cmd and copy it back to the caller.
  476. *
  477. * Optional command @flags values that can be ORed together...
  478. *
  479. * %CMDF_BOGUS - makes %COMEDI_CMD ioctl return error %EAGAIN instead of
  480. * starting the command.
  481. *
  482. * %CMDF_PRIORITY - requests "hard real-time" processing (which is not
  483. * supported in this version of COMEDI).
  484. *
  485. * %CMDF_WAKE_EOS - requests the command makes data available for reading
  486. * after every "scan" period.
  487. *
  488. * %CMDF_WRITE - marks the command as being in the "write" (to device)
  489. * direction. This does not need to be specified by the caller unless the
  490. * subdevice supports commands in either direction.
  491. *
  492. * %CMDF_RAWDATA - prevents the command from "munging" the data between the
  493. * COMEDI sample format and the raw hardware sample format.
  494. *
  495. * %CMDF_ROUND_NEAREST - requests timing periods to be rounded to nearest
  496. * supported values.
  497. *
  498. * %CMDF_ROUND_DOWN - requests timing periods to be rounded down to supported
  499. * values (frequencies rounded up).
  500. *
  501. * %CMDF_ROUND_UP - requests timing periods to be rounded up to supported
  502. * values (frequencies rounded down).
  503. *
  504. * Trigger source values for @start_src, @scan_begin_src, @convert_src,
  505. * @scan_end_src, and @stop_src...
  506. *
  507. * %TRIG_ANY - "all ones" value used to test which trigger sources are
  508. * supported.
  509. *
  510. * %TRIG_INVALID - "all zeroes" value used to indicate that all requested
  511. * trigger sources are invalid.
  512. *
  513. * %TRIG_NONE - never trigger (often used as a @stop_src value).
  514. *
  515. * %TRIG_NOW - trigger after '_arg' nanoseconds.
  516. *
  517. * %TRIG_FOLLOW - trigger follows another event.
  518. *
  519. * %TRIG_TIMER - trigger every '_arg' nanoseconds.
  520. *
  521. * %TRIG_COUNT - trigger when count '_arg' is reached.
  522. *
  523. * %TRIG_EXT - trigger on external signal specified by '_arg'.
  524. *
  525. * %TRIG_INT - trigger on internal, software trigger specified by '_arg'.
  526. *
  527. * %TRIG_OTHER - trigger on other, driver-defined signal specified by '_arg'.
  528. */
  529. struct comedi_cmd {
  530. unsigned int subdev;
  531. unsigned int flags;
  532. unsigned int start_src;
  533. unsigned int start_arg;
  534. unsigned int scan_begin_src;
  535. unsigned int scan_begin_arg;
  536. unsigned int convert_src;
  537. unsigned int convert_arg;
  538. unsigned int scan_end_src;
  539. unsigned int scan_end_arg;
  540. unsigned int stop_src;
  541. unsigned int stop_arg;
  542. unsigned int *chanlist;
  543. unsigned int chanlist_len;
  544. short __user *data;
  545. unsigned int data_len;
  546. };
  547. /**
  548. * struct comedi_chaninfo - used to retrieve per-channel information
  549. * @subdev: Subdevice index.
  550. * @maxdata_list: Optional pointer to per-channel maximum data values.
  551. * @flaglist: Optional pointer to per-channel flags.
  552. * @rangelist: Optional pointer to per-channel range types.
  553. * @unused: Reserved for future use.
  554. *
  555. * This is used with the %COMEDI_CHANINFO ioctl to get per-channel information
  556. * for the subdevice. Use of this requires knowledge of the number of channels
  557. * and subdevice flags obtained using the %COMEDI_SUBDINFO ioctl.
  558. *
  559. * The @maxdata_list member must be %NULL unless the %SDF_MAXDATA subdevice
  560. * flag is set. The @flaglist member must be %NULL unless the %SDF_FLAGS
  561. * subdevice flag is set. The @rangelist member must be %NULL unless the
  562. * %SDF_RANGETYPE subdevice flag is set. Otherwise, the arrays they point to
  563. * must be at least as long as the number of channels.
  564. */
  565. struct comedi_chaninfo {
  566. unsigned int subdev;
  567. unsigned int __user *maxdata_list;
  568. unsigned int __user *flaglist;
  569. unsigned int __user *rangelist;
  570. unsigned int unused[4];
  571. };
  572. /**
  573. * struct comedi_rangeinfo - used to retrieve the range table for a channel
  574. * @range_type: Encodes subdevice index (bits 27:24), channel index
  575. * (bits 23:16) and range table length (bits 15:0).
  576. * @range_ptr: Pointer to array of @struct comedi_krange to be filled
  577. * in with the range table for the channel or subdevice.
  578. *
  579. * This is used with the %COMEDI_RANGEINFO ioctl to retrieve the range table
  580. * for a specific channel (if the subdevice has the %SDF_RANGETYPE flag set to
  581. * indicate that the range table depends on the channel), or for the subdevice
  582. * as a whole (if the %SDF_RANGETYPE flag is clear, indicating the range table
  583. * is shared by all channels).
  584. *
  585. * The @range_type value is an input to the ioctl and comes from a previous
  586. * use of the %COMEDI_SUBDINFO ioctl (if the %SDF_RANGETYPE flag is clear),
  587. * or the %COMEDI_CHANINFO ioctl (if the %SDF_RANGETYPE flag is set).
  588. */
  589. struct comedi_rangeinfo {
  590. unsigned int range_type;
  591. void __user *range_ptr;
  592. };
  593. /**
  594. * struct comedi_krange - describes a range in a range table
  595. * @min: Minimum value in millionths (1e-6) of a unit.
  596. * @max: Maximum value in millionths (1e-6) of a unit.
  597. * @flags: Indicates the units (in bits 7:0) OR'ed with optional flags.
  598. *
  599. * A range table is associated with a single channel, or with all channels in a
  600. * subdevice, and a list of one or more ranges. A %struct comedi_krange
  601. * describes the physical range of units for one of those ranges. Sample
  602. * values in COMEDI are unsigned from %0 up to some 'maxdata' value. The
  603. * mapping from sample values to physical units is assumed to be nomimally
  604. * linear (for the purpose of describing the range), with sample value %0
  605. * mapping to @min, and the 'maxdata' sample value mapping to @max.
  606. *
  607. * The currently defined units are %UNIT_volt (%0), %UNIT_mA (%1), and
  608. * %UNIT_none (%2). The @min and @max values are the physical range multiplied
  609. * by 1e6, so a @max value of %1000000 (with %UNIT_volt) represents a maximal
  610. * value of 1 volt.
  611. *
  612. * The only defined flag value is %RF_EXTERNAL (%0x100), indicating that the
  613. * the range needs to be multiplied by an external reference.
  614. */
  615. struct comedi_krange {
  616. int min;
  617. int max;
  618. unsigned int flags;
  619. };
  620. /**
  621. * struct comedi_subdinfo - used to retrieve information about a subdevice
  622. * @type: Type of subdevice from &enum comedi_subdevice_type.
  623. * @n_chan: Number of channels the subdevice supports.
  624. * @subd_flags: A mixture of static and dynamic flags describing
  625. * aspects of the subdevice and its current state.
  626. * @timer_type: Timer type. Always set to %5 ("nanosecond timer").
  627. * @len_chanlist: Maximum length of a channel list if the subdevice
  628. * supports asynchronous acquisition commands.
  629. * @maxdata: Maximum sample value for all channels if the
  630. * %SDF_MAXDATA subdevice flag is clear.
  631. * @flags: Channel flags for all channels if the %SDF_FLAGS
  632. * subdevice flag is clear.
  633. * @range_type: The range type for all channels if the %SDF_RANGETYPE
  634. * subdevice flag is clear. Encodes the subdevice index
  635. * (bits 27:24), a dummy channel index %0 (bits 23:16),
  636. * and the range table length (bits 15:0).
  637. * @settling_time_0: Not used.
  638. * @insn_bits_support: Set to %COMEDI_SUPPORTED if the subdevice supports the
  639. * %INSN_BITS instruction, or to %COMEDI_UNSUPPORTED if it
  640. * does not.
  641. * @unused: Reserved for future use.
  642. *
  643. * This is used with the %COMEDI_SUBDINFO ioctl which copies an array of
  644. * &struct comedi_subdinfo back to user space, with one element per subdevice.
  645. * Use of this requires knowledge of the number of subdevices obtained from
  646. * the %COMEDI_DEVINFO ioctl.
  647. *
  648. * These are the @subd_flags values that may be ORed together...
  649. *
  650. * %SDF_BUSY - the subdevice is busy processing an asynchronous command or a
  651. * synchronous instruction.
  652. *
  653. * %SDF_BUSY_OWNER - the subdevice is busy processing an asynchronous
  654. * acquisition command started on the current file object (the file object
  655. * issuing the %COMEDI_SUBDINFO ioctl).
  656. *
  657. * %SDF_LOCKED - the subdevice is locked by a %COMEDI_LOCK ioctl.
  658. *
  659. * %SDF_LOCK_OWNER - the subdevice is locked by a %COMEDI_LOCK ioctl from the
  660. * current file object.
  661. *
  662. * %SDF_MAXDATA - maximum sample values are channel-specific.
  663. *
  664. * %SDF_FLAGS - channel flags are channel-specific.
  665. *
  666. * %SDF_RANGETYPE - range types are channel-specific.
  667. *
  668. * %SDF_PWM_COUNTER - PWM can switch off automatically.
  669. *
  670. * %SDF_PWM_HBRIDGE - or PWM is signed (H-bridge).
  671. *
  672. * %SDF_CMD - the subdevice supports asynchronous commands.
  673. *
  674. * %SDF_SOFT_CALIBRATED - the subdevice uses software calibration.
  675. *
  676. * %SDF_CMD_WRITE - the subdevice supports asynchronous commands in the output
  677. * ("write") direction.
  678. *
  679. * %SDF_CMD_READ - the subdevice supports asynchronous commands in the input
  680. * ("read") direction.
  681. *
  682. * %SDF_READABLE - the subdevice is readable (e.g. analog input).
  683. *
  684. * %SDF_WRITABLE (aliased as %SDF_WRITEABLE) - the subdevice is writable (e.g.
  685. * analog output).
  686. *
  687. * %SDF_INTERNAL - the subdevice has no externally visible lines.
  688. *
  689. * %SDF_GROUND - the subdevice can use ground as an analog reference.
  690. *
  691. * %SDF_COMMON - the subdevice can use a common analog reference.
  692. *
  693. * %SDF_DIFF - the subdevice can use differential inputs (or outputs).
  694. *
  695. * %SDF_OTHER - the subdevice can use some other analog reference.
  696. *
  697. * %SDF_DITHER - the subdevice can do dithering.
  698. *
  699. * %SDF_DEGLITCH - the subdevice can do deglitching.
  700. *
  701. * %SDF_MMAP - this is never set.
  702. *
  703. * %SDF_RUNNING - an asynchronous command is still running.
  704. *
  705. * %SDF_LSAMPL - the subdevice uses "long" (32-bit) samples (for asynchronous
  706. * command data).
  707. *
  708. * %SDF_PACKED - the subdevice packs several DIO samples into a single sample
  709. * (for asynchronous command data).
  710. *
  711. * No "channel flags" (@flags) values are currently defined.
  712. */
  713. struct comedi_subdinfo {
  714. unsigned int type;
  715. unsigned int n_chan;
  716. unsigned int subd_flags;
  717. unsigned int timer_type;
  718. unsigned int len_chanlist;
  719. unsigned int maxdata;
  720. unsigned int flags;
  721. unsigned int range_type;
  722. unsigned int settling_time_0;
  723. unsigned int insn_bits_support;
  724. unsigned int unused[8];
  725. };
  726. /**
  727. * struct comedi_devinfo - used to retrieve information about a COMEDI device
  728. * @version_code: COMEDI version code.
  729. * @n_subdevs: Number of subdevices the device has.
  730. * @driver_name: Null-terminated COMEDI driver name.
  731. * @board_name: Null-terminated COMEDI board name.
  732. * @read_subdevice: Index of the current "read" subdevice (%-1 if none).
  733. * @write_subdevice: Index of the current "write" subdevice (%-1 if none).
  734. * @unused: Reserved for future use.
  735. *
  736. * This is used with the %COMEDI_DEVINFO ioctl to get basic information about
  737. * the device.
  738. */
  739. struct comedi_devinfo {
  740. unsigned int version_code;
  741. unsigned int n_subdevs;
  742. char driver_name[COMEDI_NAMELEN];
  743. char board_name[COMEDI_NAMELEN];
  744. int read_subdevice;
  745. int write_subdevice;
  746. int unused[30];
  747. };
  748. /**
  749. * struct comedi_devconfig - used to configure a legacy COMEDI device
  750. * @board_name: Null-terminated string specifying the type of board
  751. * to configure.
  752. * @options: An array of integer configuration options.
  753. *
  754. * This is used with the %COMEDI_DEVCONFIG ioctl to configure a "legacy" COMEDI
  755. * device, such as an ISA card. Not all COMEDI drivers support this. Those
  756. * that do either expect the specified board name to match one of a list of
  757. * names registered with the COMEDI core, or expect the specified board name
  758. * to match the COMEDI driver name itself. The configuration options are
  759. * handled in a driver-specific manner.
  760. */
  761. struct comedi_devconfig {
  762. char board_name[COMEDI_NAMELEN];
  763. int options[COMEDI_NDEVCONFOPTS];
  764. };
  765. /**
  766. * struct comedi_bufconfig - used to set or get buffer size for a subdevice
  767. * @subdevice: Subdevice index.
  768. * @flags: Not used.
  769. * @maximum_size: Maximum allowed buffer size.
  770. * @size: Buffer size.
  771. * @unused: Reserved for future use.
  772. *
  773. * This is used with the %COMEDI_BUFCONFIG ioctl to get or configure the
  774. * maximum buffer size and current buffer size for a COMEDI subdevice that
  775. * supports asynchronous commands. If the subdevice does not support
  776. * asynchronous commands, @maximum_size and @size are ignored and set to 0.
  777. *
  778. * On ioctl input, non-zero values of @maximum_size and @size specify a
  779. * new maximum size and new current size (in bytes), respectively. These
  780. * will by rounded up to a multiple of %PAGE_SIZE. Specifying a new maximum
  781. * size requires admin capabilities.
  782. *
  783. * On ioctl output, @maximum_size and @size and set to the current maximum
  784. * buffer size and current buffer size, respectively.
  785. */
  786. struct comedi_bufconfig {
  787. unsigned int subdevice;
  788. unsigned int flags;
  789. unsigned int maximum_size;
  790. unsigned int size;
  791. unsigned int unused[4];
  792. };
  793. /**
  794. * struct comedi_bufinfo - used to manipulate buffer position for a subdevice
  795. * @subdevice: Subdevice index.
  796. * @bytes_read: Specify amount to advance read position for an
  797. * asynchronous command in the input ("read") direction.
  798. * @buf_write_ptr: Current write position (index) within the buffer.
  799. * @buf_read_ptr: Current read position (index) within the buffer.
  800. * @buf_write_count: Total amount written, modulo 2^32.
  801. * @buf_read_count: Total amount read, modulo 2^32.
  802. * @bytes_written: Specify amount to advance write position for an
  803. * asynchronous command in the output ("write") direction.
  804. * @unused: Reserved for future use.
  805. *
  806. * This is used with the %COMEDI_BUFINFO ioctl to optionally advance the
  807. * current read or write position in an asynchronous acquisition data buffer,
  808. * and to get the current read and write positions in the buffer.
  809. */
  810. struct comedi_bufinfo {
  811. unsigned int subdevice;
  812. unsigned int bytes_read;
  813. unsigned int buf_write_ptr;
  814. unsigned int buf_read_ptr;
  815. unsigned int buf_write_count;
  816. unsigned int buf_read_count;
  817. unsigned int bytes_written;
  818. unsigned int unused[4];
  819. };
  820. /* range stuff */
  821. #define __RANGE(a, b) ((((a) & 0xffff) << 16) | ((b) & 0xffff))
  822. #define RANGE_OFFSET(a) (((a) >> 16) & 0xffff)
  823. #define RANGE_LENGTH(b) ((b) & 0xffff)
  824. #define RF_UNIT(flags) ((flags) & 0xff)
  825. #define RF_EXTERNAL 0x100
  826. #define UNIT_volt 0
  827. #define UNIT_mA 1
  828. #define UNIT_none 2
  829. #define COMEDI_MIN_SPEED 0xffffffffu
  830. /**********************************************************/
  831. /* everything after this line is ALPHA */
  832. /**********************************************************/
  833. /*
  834. * 8254 specific configuration.
  835. *
  836. * It supports two config commands:
  837. *
  838. * 0 ID: INSN_CONFIG_SET_COUNTER_MODE
  839. * 1 8254 Mode
  840. * I8254_MODE0, I8254_MODE1, ..., I8254_MODE5
  841. * OR'ed with:
  842. * I8254_BCD, I8254_BINARY
  843. *
  844. * 0 ID: INSN_CONFIG_8254_READ_STATUS
  845. * 1 <-- Status byte returned here.
  846. * B7 = Output
  847. * B6 = NULL Count
  848. * B5 - B0 Current mode.
  849. */
  850. enum i8254_mode {
  851. I8254_MODE0 = (0 << 1), /* Interrupt on terminal count */
  852. I8254_MODE1 = (1 << 1), /* Hardware retriggerable one-shot */
  853. I8254_MODE2 = (2 << 1), /* Rate generator */
  854. I8254_MODE3 = (3 << 1), /* Square wave mode */
  855. I8254_MODE4 = (4 << 1), /* Software triggered strobe */
  856. /* Hardware triggered strobe (retriggerable) */
  857. I8254_MODE5 = (5 << 1),
  858. /* Use binary-coded decimal instead of binary (pretty useless) */
  859. I8254_BCD = 1,
  860. I8254_BINARY = 0
  861. };
  862. #define NI_USUAL_PFI_SELECT(x) (((x) < 10) ? (0x1 + (x)) : (0xb + (x)))
  863. #define NI_USUAL_RTSI_SELECT(x) (((x) < 7) ? (0xb + (x)) : 0x1b)
  864. /*
  865. * mode bits for NI general-purpose counters, set with
  866. * INSN_CONFIG_SET_COUNTER_MODE
  867. */
  868. #define NI_GPCT_COUNTING_MODE_SHIFT 16
  869. #define NI_GPCT_INDEX_PHASE_BITSHIFT 20
  870. #define NI_GPCT_COUNTING_DIRECTION_SHIFT 24
  871. enum ni_gpct_mode_bits {
  872. NI_GPCT_GATE_ON_BOTH_EDGES_BIT = 0x4,
  873. NI_GPCT_EDGE_GATE_MODE_MASK = 0x18,
  874. NI_GPCT_EDGE_GATE_STARTS_STOPS_BITS = 0x0,
  875. NI_GPCT_EDGE_GATE_STOPS_STARTS_BITS = 0x8,
  876. NI_GPCT_EDGE_GATE_STARTS_BITS = 0x10,
  877. NI_GPCT_EDGE_GATE_NO_STARTS_NO_STOPS_BITS = 0x18,
  878. NI_GPCT_STOP_MODE_MASK = 0x60,
  879. NI_GPCT_STOP_ON_GATE_BITS = 0x00,
  880. NI_GPCT_STOP_ON_GATE_OR_TC_BITS = 0x20,
  881. NI_GPCT_STOP_ON_GATE_OR_SECOND_TC_BITS = 0x40,
  882. NI_GPCT_LOAD_B_SELECT_BIT = 0x80,
  883. NI_GPCT_OUTPUT_MODE_MASK = 0x300,
  884. NI_GPCT_OUTPUT_TC_PULSE_BITS = 0x100,
  885. NI_GPCT_OUTPUT_TC_TOGGLE_BITS = 0x200,
  886. NI_GPCT_OUTPUT_TC_OR_GATE_TOGGLE_BITS = 0x300,
  887. NI_GPCT_HARDWARE_DISARM_MASK = 0xc00,
  888. NI_GPCT_NO_HARDWARE_DISARM_BITS = 0x000,
  889. NI_GPCT_DISARM_AT_TC_BITS = 0x400,
  890. NI_GPCT_DISARM_AT_GATE_BITS = 0x800,
  891. NI_GPCT_DISARM_AT_TC_OR_GATE_BITS = 0xc00,
  892. NI_GPCT_LOADING_ON_TC_BIT = 0x1000,
  893. NI_GPCT_LOADING_ON_GATE_BIT = 0x4000,
  894. NI_GPCT_COUNTING_MODE_MASK = 0x7 << NI_GPCT_COUNTING_MODE_SHIFT,
  895. NI_GPCT_COUNTING_MODE_NORMAL_BITS =
  896. 0x0 << NI_GPCT_COUNTING_MODE_SHIFT,
  897. NI_GPCT_COUNTING_MODE_QUADRATURE_X1_BITS =
  898. 0x1 << NI_GPCT_COUNTING_MODE_SHIFT,
  899. NI_GPCT_COUNTING_MODE_QUADRATURE_X2_BITS =
  900. 0x2 << NI_GPCT_COUNTING_MODE_SHIFT,
  901. NI_GPCT_COUNTING_MODE_QUADRATURE_X4_BITS =
  902. 0x3 << NI_GPCT_COUNTING_MODE_SHIFT,
  903. NI_GPCT_COUNTING_MODE_TWO_PULSE_BITS =
  904. 0x4 << NI_GPCT_COUNTING_MODE_SHIFT,
  905. NI_GPCT_COUNTING_MODE_SYNC_SOURCE_BITS =
  906. 0x6 << NI_GPCT_COUNTING_MODE_SHIFT,
  907. NI_GPCT_INDEX_PHASE_MASK = 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT,
  908. NI_GPCT_INDEX_PHASE_LOW_A_LOW_B_BITS =
  909. 0x0 << NI_GPCT_INDEX_PHASE_BITSHIFT,
  910. NI_GPCT_INDEX_PHASE_LOW_A_HIGH_B_BITS =
  911. 0x1 << NI_GPCT_INDEX_PHASE_BITSHIFT,
  912. NI_GPCT_INDEX_PHASE_HIGH_A_LOW_B_BITS =
  913. 0x2 << NI_GPCT_INDEX_PHASE_BITSHIFT,
  914. NI_GPCT_INDEX_PHASE_HIGH_A_HIGH_B_BITS =
  915. 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT,
  916. NI_GPCT_INDEX_ENABLE_BIT = 0x400000,
  917. NI_GPCT_COUNTING_DIRECTION_MASK =
  918. 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
  919. NI_GPCT_COUNTING_DIRECTION_DOWN_BITS =
  920. 0x00 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
  921. NI_GPCT_COUNTING_DIRECTION_UP_BITS =
  922. 0x1 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
  923. NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS =
  924. 0x2 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
  925. NI_GPCT_COUNTING_DIRECTION_HW_GATE_BITS =
  926. 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
  927. NI_GPCT_RELOAD_SOURCE_MASK = 0xc000000,
  928. NI_GPCT_RELOAD_SOURCE_FIXED_BITS = 0x0,
  929. NI_GPCT_RELOAD_SOURCE_SWITCHING_BITS = 0x4000000,
  930. NI_GPCT_RELOAD_SOURCE_GATE_SELECT_BITS = 0x8000000,
  931. NI_GPCT_OR_GATE_BIT = 0x10000000,
  932. NI_GPCT_INVERT_OUTPUT_BIT = 0x20000000
  933. };
  934. /*
  935. * Bits for setting a clock source with
  936. * INSN_CONFIG_SET_CLOCK_SRC when using NI general-purpose counters.
  937. */
  938. enum ni_gpct_clock_source_bits {
  939. NI_GPCT_CLOCK_SRC_SELECT_MASK = 0x3f,
  940. NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS = 0x0,
  941. NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS = 0x1,
  942. NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS = 0x2,
  943. NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS = 0x3,
  944. NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS = 0x4,
  945. NI_GPCT_NEXT_TC_CLOCK_SRC_BITS = 0x5,
  946. /* NI 660x-specific */
  947. NI_GPCT_SOURCE_PIN_i_CLOCK_SRC_BITS = 0x6,
  948. NI_GPCT_PXI10_CLOCK_SRC_BITS = 0x7,
  949. NI_GPCT_PXI_STAR_TRIGGER_CLOCK_SRC_BITS = 0x8,
  950. NI_GPCT_ANALOG_TRIGGER_OUT_CLOCK_SRC_BITS = 0x9,
  951. NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK = 0x30000000,
  952. NI_GPCT_NO_PRESCALE_CLOCK_SRC_BITS = 0x0,
  953. /* divide source by 2 */
  954. NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS = 0x10000000,
  955. /* divide source by 8 */
  956. NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS = 0x20000000,
  957. NI_GPCT_INVERT_CLOCK_SRC_BIT = 0x80000000
  958. };
  959. /* NI 660x-specific */
  960. #define NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(x) (0x10 + (x))
  961. #define NI_GPCT_RTSI_CLOCK_SRC_BITS(x) (0x18 + (x))
  962. /* no pfi on NI 660x */
  963. #define NI_GPCT_PFI_CLOCK_SRC_BITS(x) (0x20 + (x))
  964. /*
  965. * Possibilities for setting a gate source with
  966. * INSN_CONFIG_SET_GATE_SRC when using NI general-purpose counters.
  967. * May be bitwise-or'd with CR_EDGE or CR_INVERT.
  968. */
  969. enum ni_gpct_gate_select {
  970. /* m-series gates */
  971. NI_GPCT_TIMESTAMP_MUX_GATE_SELECT = 0x0,
  972. NI_GPCT_AI_START2_GATE_SELECT = 0x12,
  973. NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT = 0x13,
  974. NI_GPCT_NEXT_OUT_GATE_SELECT = 0x14,
  975. NI_GPCT_AI_START1_GATE_SELECT = 0x1c,
  976. NI_GPCT_NEXT_SOURCE_GATE_SELECT = 0x1d,
  977. NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT = 0x1e,
  978. NI_GPCT_LOGIC_LOW_GATE_SELECT = 0x1f,
  979. /* more gates for 660x */
  980. NI_GPCT_SOURCE_PIN_i_GATE_SELECT = 0x100,
  981. NI_GPCT_GATE_PIN_i_GATE_SELECT = 0x101,
  982. /* more gates for 660x "second gate" */
  983. NI_GPCT_UP_DOWN_PIN_i_GATE_SELECT = 0x201,
  984. NI_GPCT_SELECTED_GATE_GATE_SELECT = 0x21e,
  985. /*
  986. * m-series "second gate" sources are unknown,
  987. * we should add them here with an offset of 0x300 when
  988. * known.
  989. */
  990. NI_GPCT_DISABLED_GATE_SELECT = 0x8000,
  991. };
  992. #define NI_GPCT_GATE_PIN_GATE_SELECT(x) (0x102 + (x))
  993. #define NI_GPCT_RTSI_GATE_SELECT(x) NI_USUAL_RTSI_SELECT(x)
  994. #define NI_GPCT_PFI_GATE_SELECT(x) NI_USUAL_PFI_SELECT(x)
  995. #define NI_GPCT_UP_DOWN_PIN_GATE_SELECT(x) (0x202 + (x))
  996. /*
  997. * Possibilities for setting a source with
  998. * INSN_CONFIG_SET_OTHER_SRC when using NI general-purpose counters.
  999. */
  1000. enum ni_gpct_other_index {
  1001. NI_GPCT_SOURCE_ENCODER_A,
  1002. NI_GPCT_SOURCE_ENCODER_B,
  1003. NI_GPCT_SOURCE_ENCODER_Z
  1004. };
  1005. enum ni_gpct_other_select {
  1006. /* m-series gates */
  1007. /* Still unknown, probably only need NI_GPCT_PFI_OTHER_SELECT */
  1008. NI_GPCT_DISABLED_OTHER_SELECT = 0x8000,
  1009. };
  1010. #define NI_GPCT_PFI_OTHER_SELECT(x) NI_USUAL_PFI_SELECT(x)
  1011. /*
  1012. * start sources for ni general-purpose counters for use with
  1013. * INSN_CONFIG_ARM
  1014. */
  1015. enum ni_gpct_arm_source {
  1016. NI_GPCT_ARM_IMMEDIATE = 0x0,
  1017. /*
  1018. * Start both the counter and the adjacent pared
  1019. * counter simultaneously
  1020. */
  1021. NI_GPCT_ARM_PAIRED_IMMEDIATE = 0x1,
  1022. /*
  1023. * NI doesn't document bits for selecting hardware arm triggers.
  1024. * If the NI_GPCT_ARM_UNKNOWN bit is set, we will pass the least
  1025. * significant bits (3 bits for 660x or 5 bits for m-series)
  1026. * through to the hardware. This will at least allow someone to
  1027. * figure out what the bits do later.
  1028. */
  1029. NI_GPCT_ARM_UNKNOWN = 0x1000,
  1030. };
  1031. /* digital filtering options for ni 660x for use with INSN_CONFIG_FILTER. */
  1032. enum ni_gpct_filter_select {
  1033. NI_GPCT_FILTER_OFF = 0x0,
  1034. NI_GPCT_FILTER_TIMEBASE_3_SYNC = 0x1,
  1035. NI_GPCT_FILTER_100x_TIMEBASE_1 = 0x2,
  1036. NI_GPCT_FILTER_20x_TIMEBASE_1 = 0x3,
  1037. NI_GPCT_FILTER_10x_TIMEBASE_1 = 0x4,
  1038. NI_GPCT_FILTER_2x_TIMEBASE_1 = 0x5,
  1039. NI_GPCT_FILTER_2x_TIMEBASE_3 = 0x6
  1040. };
  1041. /*
  1042. * PFI digital filtering options for ni m-series for use with
  1043. * INSN_CONFIG_FILTER.
  1044. */
  1045. enum ni_pfi_filter_select {
  1046. NI_PFI_FILTER_OFF = 0x0,
  1047. NI_PFI_FILTER_125ns = 0x1,
  1048. NI_PFI_FILTER_6425ns = 0x2,
  1049. NI_PFI_FILTER_2550us = 0x3
  1050. };
  1051. /* master clock sources for ni mio boards and INSN_CONFIG_SET_CLOCK_SRC */
  1052. enum ni_mio_clock_source {
  1053. NI_MIO_INTERNAL_CLOCK = 0,
  1054. /*
  1055. * Doesn't work for m-series, use NI_MIO_PLL_RTSI_CLOCK()
  1056. * the NI_MIO_PLL_* sources are m-series only
  1057. */
  1058. NI_MIO_RTSI_CLOCK = 1,
  1059. NI_MIO_PLL_PXI_STAR_TRIGGER_CLOCK = 2,
  1060. NI_MIO_PLL_PXI10_CLOCK = 3,
  1061. NI_MIO_PLL_RTSI0_CLOCK = 4
  1062. };
  1063. #define NI_MIO_PLL_RTSI_CLOCK(x) (NI_MIO_PLL_RTSI0_CLOCK + (x))
  1064. /*
  1065. * Signals which can be routed to an NI RTSI pin with INSN_CONFIG_SET_ROUTING.
  1066. * The numbers assigned are not arbitrary, they correspond to the bits required
  1067. * to program the board.
  1068. */
  1069. enum ni_rtsi_routing {
  1070. NI_RTSI_OUTPUT_ADR_START1 = 0,
  1071. NI_RTSI_OUTPUT_ADR_START2 = 1,
  1072. NI_RTSI_OUTPUT_SCLKG = 2,
  1073. NI_RTSI_OUTPUT_DACUPDN = 3,
  1074. NI_RTSI_OUTPUT_DA_START1 = 4,
  1075. NI_RTSI_OUTPUT_G_SRC0 = 5,
  1076. NI_RTSI_OUTPUT_G_GATE0 = 6,
  1077. NI_RTSI_OUTPUT_RGOUT0 = 7,
  1078. NI_RTSI_OUTPUT_RTSI_BRD_0 = 8,
  1079. /* Pre-m-series always have RTSI clock on line 7 */
  1080. NI_RTSI_OUTPUT_RTSI_OSC = 12
  1081. };
  1082. #define NI_RTSI_OUTPUT_RTSI_BRD(x) (NI_RTSI_OUTPUT_RTSI_BRD_0 + (x))
  1083. /*
  1084. * Signals which can be routed to an NI PFI pin on an m-series board with
  1085. * INSN_CONFIG_SET_ROUTING. These numbers are also returned by
  1086. * INSN_CONFIG_GET_ROUTING on pre-m-series boards, even though their routing
  1087. * cannot be changed. The numbers assigned are not arbitrary, they correspond
  1088. * to the bits required to program the board.
  1089. */
  1090. enum ni_pfi_routing {
  1091. NI_PFI_OUTPUT_PFI_DEFAULT = 0,
  1092. NI_PFI_OUTPUT_AI_START1 = 1,
  1093. NI_PFI_OUTPUT_AI_START2 = 2,
  1094. NI_PFI_OUTPUT_AI_CONVERT = 3,
  1095. NI_PFI_OUTPUT_G_SRC1 = 4,
  1096. NI_PFI_OUTPUT_G_GATE1 = 5,
  1097. NI_PFI_OUTPUT_AO_UPDATE_N = 6,
  1098. NI_PFI_OUTPUT_AO_START1 = 7,
  1099. NI_PFI_OUTPUT_AI_START_PULSE = 8,
  1100. NI_PFI_OUTPUT_G_SRC0 = 9,
  1101. NI_PFI_OUTPUT_G_GATE0 = 10,
  1102. NI_PFI_OUTPUT_EXT_STROBE = 11,
  1103. NI_PFI_OUTPUT_AI_EXT_MUX_CLK = 12,
  1104. NI_PFI_OUTPUT_GOUT0 = 13,
  1105. NI_PFI_OUTPUT_GOUT1 = 14,
  1106. NI_PFI_OUTPUT_FREQ_OUT = 15,
  1107. NI_PFI_OUTPUT_PFI_DO = 16,
  1108. NI_PFI_OUTPUT_I_ATRIG = 17,
  1109. NI_PFI_OUTPUT_RTSI0 = 18,
  1110. NI_PFI_OUTPUT_PXI_STAR_TRIGGER_IN = 26,
  1111. NI_PFI_OUTPUT_SCXI_TRIG1 = 27,
  1112. NI_PFI_OUTPUT_DIO_CHANGE_DETECT_RTSI = 28,
  1113. NI_PFI_OUTPUT_CDI_SAMPLE = 29,
  1114. NI_PFI_OUTPUT_CDO_UPDATE = 30
  1115. };
  1116. #define NI_PFI_OUTPUT_RTSI(x) (NI_PFI_OUTPUT_RTSI0 + (x))
  1117. /*
  1118. * Signals which can be routed to output on a NI PFI pin on a 660x board
  1119. * with INSN_CONFIG_SET_ROUTING. The numbers assigned are
  1120. * not arbitrary, they correspond to the bits required
  1121. * to program the board. Lines 0 to 7 can only be set to
  1122. * NI_660X_PFI_OUTPUT_DIO. Lines 32 to 39 can only be set to
  1123. * NI_660X_PFI_OUTPUT_COUNTER.
  1124. */
  1125. enum ni_660x_pfi_routing {
  1126. NI_660X_PFI_OUTPUT_COUNTER = 1, /* counter */
  1127. NI_660X_PFI_OUTPUT_DIO = 2, /* static digital output */
  1128. };
  1129. /*
  1130. * NI External Trigger lines. These values are not arbitrary, but are related
  1131. * to the bits required to program the board (offset by 1 for historical
  1132. * reasons).
  1133. */
  1134. #define NI_EXT_PFI(x) (NI_USUAL_PFI_SELECT(x) - 1)
  1135. #define NI_EXT_RTSI(x) (NI_USUAL_RTSI_SELECT(x) - 1)
  1136. /*
  1137. * Clock sources for CDIO subdevice on NI m-series boards. Used as the
  1138. * scan_begin_arg for a comedi_command. These sources may also be bitwise-or'd
  1139. * with CR_INVERT to change polarity.
  1140. */
  1141. enum ni_m_series_cdio_scan_begin_src {
  1142. NI_CDIO_SCAN_BEGIN_SRC_GROUND = 0,
  1143. NI_CDIO_SCAN_BEGIN_SRC_AI_START = 18,
  1144. NI_CDIO_SCAN_BEGIN_SRC_AI_CONVERT = 19,
  1145. NI_CDIO_SCAN_BEGIN_SRC_PXI_STAR_TRIGGER = 20,
  1146. NI_CDIO_SCAN_BEGIN_SRC_G0_OUT = 28,
  1147. NI_CDIO_SCAN_BEGIN_SRC_G1_OUT = 29,
  1148. NI_CDIO_SCAN_BEGIN_SRC_ANALOG_TRIGGER = 30,
  1149. NI_CDIO_SCAN_BEGIN_SRC_AO_UPDATE = 31,
  1150. NI_CDIO_SCAN_BEGIN_SRC_FREQ_OUT = 32,
  1151. NI_CDIO_SCAN_BEGIN_SRC_DIO_CHANGE_DETECT_IRQ = 33
  1152. };
  1153. #define NI_CDIO_SCAN_BEGIN_SRC_PFI(x) NI_USUAL_PFI_SELECT(x)
  1154. #define NI_CDIO_SCAN_BEGIN_SRC_RTSI(x) NI_USUAL_RTSI_SELECT(x)
  1155. /*
  1156. * scan_begin_src for scan_begin_arg==TRIG_EXT with analog output command on NI
  1157. * boards. These scan begin sources can also be bitwise-or'd with CR_INVERT to
  1158. * change polarity.
  1159. */
  1160. #define NI_AO_SCAN_BEGIN_SRC_PFI(x) NI_USUAL_PFI_SELECT(x)
  1161. #define NI_AO_SCAN_BEGIN_SRC_RTSI(x) NI_USUAL_RTSI_SELECT(x)
  1162. /*
  1163. * Bits for setting a clock source with
  1164. * INSN_CONFIG_SET_CLOCK_SRC when using NI frequency output subdevice.
  1165. */
  1166. enum ni_freq_out_clock_source_bits {
  1167. NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC, /* 10 MHz */
  1168. NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC /* 100 KHz */
  1169. };
  1170. /*
  1171. * Values for setting a clock source with INSN_CONFIG_SET_CLOCK_SRC for
  1172. * 8254 counter subdevices on Amplicon DIO boards (amplc_dio200 driver).
  1173. */
  1174. enum amplc_dio_clock_source {
  1175. /*
  1176. * Per channel external clock
  1177. * input/output pin (pin is only an
  1178. * input when clock source set to this value,
  1179. * otherwise it is an output)
  1180. */
  1181. AMPLC_DIO_CLK_CLKN,
  1182. AMPLC_DIO_CLK_10MHZ, /* 10 MHz internal clock */
  1183. AMPLC_DIO_CLK_1MHZ, /* 1 MHz internal clock */
  1184. AMPLC_DIO_CLK_100KHZ, /* 100 kHz internal clock */
  1185. AMPLC_DIO_CLK_10KHZ, /* 10 kHz internal clock */
  1186. AMPLC_DIO_CLK_1KHZ, /* 1 kHz internal clock */
  1187. /*
  1188. * Output of preceding counter channel
  1189. * (for channel 0, preceding counter
  1190. * channel is channel 2 on preceding
  1191. * counter subdevice, for first counter
  1192. * subdevice, preceding counter
  1193. * subdevice is the last counter
  1194. * subdevice)
  1195. */
  1196. AMPLC_DIO_CLK_OUTNM1,
  1197. AMPLC_DIO_CLK_EXT, /* per chip external input pin */
  1198. /* the following are "enhanced" clock sources for PCIe models */
  1199. AMPLC_DIO_CLK_VCC, /* clock input HIGH */
  1200. AMPLC_DIO_CLK_GND, /* clock input LOW */
  1201. AMPLC_DIO_CLK_PAT_PRESENT, /* "pattern present" signal */
  1202. AMPLC_DIO_CLK_20MHZ /* 20 MHz internal clock */
  1203. };
  1204. /*
  1205. * Values for setting a clock source with INSN_CONFIG_SET_CLOCK_SRC for
  1206. * timer subdevice on some Amplicon DIO PCIe boards (amplc_dio200 driver).
  1207. */
  1208. enum amplc_dio_ts_clock_src {
  1209. AMPLC_DIO_TS_CLK_1GHZ, /* 1 ns period with 20 ns granularity */
  1210. AMPLC_DIO_TS_CLK_1MHZ, /* 1 us period */
  1211. AMPLC_DIO_TS_CLK_1KHZ /* 1 ms period */
  1212. };
  1213. /*
  1214. * Values for setting a gate source with INSN_CONFIG_SET_GATE_SRC for
  1215. * 8254 counter subdevices on Amplicon DIO boards (amplc_dio200 driver).
  1216. */
  1217. enum amplc_dio_gate_source {
  1218. AMPLC_DIO_GAT_VCC, /* internal high logic level */
  1219. AMPLC_DIO_GAT_GND, /* internal low logic level */
  1220. AMPLC_DIO_GAT_GATN, /* per channel external gate input */
  1221. /*
  1222. * negated output of counter channel minus 2
  1223. * (for channels 0 or 1, channel minus 2 is channel 1 or 2 on
  1224. * the preceding counter subdevice, for the first counter subdevice
  1225. * the preceding counter subdevice is the last counter subdevice)
  1226. */
  1227. AMPLC_DIO_GAT_NOUTNM2,
  1228. AMPLC_DIO_GAT_RESERVED4,
  1229. AMPLC_DIO_GAT_RESERVED5,
  1230. AMPLC_DIO_GAT_RESERVED6,
  1231. AMPLC_DIO_GAT_RESERVED7,
  1232. /* the following are "enhanced" gate sources for PCIe models */
  1233. AMPLC_DIO_GAT_NGATN = 6, /* negated per channel gate input */
  1234. /* non-negated output of counter channel minus 2 */
  1235. AMPLC_DIO_GAT_OUTNM2,
  1236. AMPLC_DIO_GAT_PAT_PRESENT, /* "pattern present" signal */
  1237. AMPLC_DIO_GAT_PAT_OCCURRED, /* "pattern occurred" latched */
  1238. AMPLC_DIO_GAT_PAT_GONE, /* "pattern gone away" latched */
  1239. AMPLC_DIO_GAT_NPAT_PRESENT, /* negated "pattern present" */
  1240. AMPLC_DIO_GAT_NPAT_OCCURRED, /* negated "pattern occurred" */
  1241. AMPLC_DIO_GAT_NPAT_GONE /* negated "pattern gone away" */
  1242. };
  1243. /*
  1244. * Values for setting a clock source with INSN_CONFIG_SET_CLOCK_SRC for
  1245. * the counter subdevice on the Kolter Electronic PCI-Counter board
  1246. * (ke_counter driver).
  1247. */
  1248. enum ke_counter_clock_source {
  1249. KE_CLK_20MHZ, /* internal 20MHz (default) */
  1250. KE_CLK_4MHZ, /* internal 4MHz (option) */
  1251. KE_CLK_EXT /* external clock on pin 21 of D-Sub */
  1252. };
  1253. #endif /* _COMEDI_H */