comedi.h 54 KB

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