/* SPDX-License-Identifier: LGPL-2.0+ WITH Linux-syscall-note *//* * comedi.h * header file for COMEDI user API * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 1998-2001 David A. Schleef <ds@schleef.org> */ #ifndef _COMEDI_H#define _COMEDI_H #define COMEDI_MAJORVERSION 0#define COMEDI_MINORVERSION 7#define COMEDI_MICROVERSION 76#define VERSION "0.7.76" /* comedi's major device number */#define COMEDI_MAJOR 98 /* * maximum number of minor devices. This can be increased, although * kernel structures are currently statically allocated, thus you * don't want this to be much more than you actually use. */#define COMEDI_NDEVICES 16 /* number of config options in the config structure */#define COMEDI_NDEVCONFOPTS 32 /* * NOTE: 'comedi_config --init-data' is deprecated * * The following indexes in the config options were used by * comedi_config to pass firmware blobs from user space to the * comedi drivers. The request_firmware() hotplug interface is * now used by all comedi drivers instead. */ /* length of nth chunk of firmware data -*/#define COMEDI_DEVCONF_AUX_DATA3_LENGTH 25#define COMEDI_DEVCONF_AUX_DATA2_LENGTH 26#define COMEDI_DEVCONF_AUX_DATA1_LENGTH 27#define COMEDI_DEVCONF_AUX_DATA0_LENGTH 28/* most significant 32 bits of pointer address (if needed) */#define COMEDI_DEVCONF_AUX_DATA_HI 29/* least significant 32 bits of pointer address */#define COMEDI_DEVCONF_AUX_DATA_LO 30#define COMEDI_DEVCONF_AUX_DATA_LENGTH 31 /* total data length */ /* max length of device and driver names */#define COMEDI_NAMELEN 20 /* packs and unpacks a channel/range number */ #define CR_PACK(chan, rng, aref) \ ((((aref) & 0x3) << 24) | (((rng) & 0xff) << 16) | (chan))#define CR_PACK_FLAGS(chan, range, aref, flags) \ (CR_PACK(chan, range, aref) | ((flags) & CR_FLAGS_MASK)) #define CR_CHAN(a) ((a) & 0xffff)#define CR_RANGE(a) (((a) >> 16) & 0xff)#define CR_AREF(a) (((a) >> 24) & 0x03) #define CR_FLAGS_MASK 0xfc000000#define CR_ALT_FILTER 0x04000000#define CR_DITHER CR_ALT_FILTER#define CR_DEGLITCH CR_ALT_FILTER#define CR_ALT_SOURCE 0x08000000#define CR_EDGE 0x40000000#define CR_INVERT 0x80000000 #define AREF_GROUND 0x00 /* analog ref = analog ground */#define AREF_COMMON 0x01 /* analog ref = analog common */#define AREF_DIFF 0x02 /* analog ref = differential */#define AREF_OTHER 0x03 /* analog ref = other (undefined) */ /* counters -- these are arbitrary values */#define GPCT_RESET 0x0001#define GPCT_SET_SOURCE 0x0002#define GPCT_SET_GATE 0x0004#define GPCT_SET_DIRECTION 0x0008#define GPCT_SET_OPERATION 0x0010#define GPCT_ARM 0x0020#define GPCT_DISARM 0x0040#define GPCT_GET_INT_CLK_FRQ 0x0080 #define GPCT_INT_CLOCK 0x0001#define GPCT_EXT_PIN 0x0002#define GPCT_NO_GATE 0x0004#define GPCT_UP 0x0008#define GPCT_DOWN 0x0010#define GPCT_HWUD 0x0020#define GPCT_SIMPLE_EVENT 0x0040#define GPCT_SINGLE_PERIOD 0x0080#define GPCT_SINGLE_PW 0x0100#define GPCT_CONT_PULSE_OUT 0x0200#define GPCT_SINGLE_PULSE_OUT 0x0400 /* instructions */ #define INSN_MASK_WRITE 0x8000000#define INSN_MASK_READ 0x4000000#define INSN_MASK_SPECIAL 0x2000000 #define INSN_READ (0 | INSN_MASK_READ)#define INSN_WRITE (1 | INSN_MASK_WRITE)#define INSN_BITS (2 | INSN_MASK_READ | INSN_MASK_WRITE)#define INSN_CONFIG (3 | INSN_MASK_READ | INSN_MASK_WRITE)#define INSN_DEVICE_CONFIG (INSN_CONFIG | INSN_MASK_SPECIAL)#define INSN_GTOD (4 | INSN_MASK_READ | INSN_MASK_SPECIAL)#define INSN_WAIT (5 | INSN_MASK_WRITE | INSN_MASK_SPECIAL)#define INSN_INTTRIG (6 | INSN_MASK_WRITE | INSN_MASK_SPECIAL) /* command flags *//* These flags are used in comedi_cmd structures */ #define CMDF_BOGUS 0x00000001 /* do the motions */ /* try to use a real-time interrupt while performing command */#define CMDF_PRIORITY 0x00000008 /* wake up on end-of-scan events */#define CMDF_WAKE_EOS 0x00000020 #define CMDF_WRITE 0x00000040 #define CMDF_RAWDATA 0x00000080 /* timer rounding definitions */#define CMDF_ROUND_MASK 0x00030000#define CMDF_ROUND_NEAREST 0x00000000#define CMDF_ROUND_DOWN 0x00010000#define CMDF_ROUND_UP 0x00020000#define CMDF_ROUND_UP_NEXT 0x00030000 #define COMEDI_EV_START 0x00040000#define COMEDI_EV_SCAN_BEGIN 0x00080000#define COMEDI_EV_CONVERT 0x00100000#define COMEDI_EV_SCAN_END 0x00200000#define COMEDI_EV_STOP 0x00400000 /* compatibility definitions */#define TRIG_BOGUS CMDF_BOGUS#define TRIG_RT CMDF_PRIORITY#define TRIG_WAKE_EOS CMDF_WAKE_EOS#define TRIG_WRITE CMDF_WRITE#define TRIG_ROUND_MASK CMDF_ROUND_MASK#define TRIG_ROUND_NEAREST CMDF_ROUND_NEAREST#define TRIG_ROUND_DOWN CMDF_ROUND_DOWN#define TRIG_ROUND_UP CMDF_ROUND_UP#define TRIG_ROUND_UP_NEXT CMDF_ROUND_UP_NEXT /* trigger sources */ #define TRIG_ANY 0xffffffff#define TRIG_INVALID 0x00000000 #define TRIG_NONE 0x00000001 /* never trigger */#define TRIG_NOW 0x00000002 /* trigger now + N ns */#define TRIG_FOLLOW 0x00000004 /* trigger on next lower level trig */#define TRIG_TIME 0x00000008 /* trigger at time N ns */#define TRIG_TIMER 0x00000010 /* trigger at rate N ns */#define TRIG_COUNT 0x00000020 /* trigger when count reaches N */#define TRIG_EXT 0x00000040 /* trigger on external signal N */#define TRIG_INT 0x00000080 /* trigger on comedi-internal signal N */#define TRIG_OTHER 0x00000100 /* driver defined */ /* subdevice flags */ #define SDF_BUSY 0x0001 /* device is busy */#define SDF_BUSY_OWNER 0x0002 /* device is busy with your job */#define SDF_LOCKED 0x0004 /* subdevice is locked */#define SDF_LOCK_OWNER 0x0008 /* you own lock */#define SDF_MAXDATA 0x0010 /* maxdata depends on channel */#define SDF_FLAGS 0x0020 /* flags depend on channel */#define SDF_RANGETYPE 0x0040 /* range type depends on channel */#define SDF_PWM_COUNTER 0x0080 /* PWM can automatically switch off */#define SDF_PWM_HBRIDGE 0x0100 /* PWM is signed (H-bridge) */#define SDF_CMD 0x1000 /* can do commands (deprecated) */#define SDF_SOFT_CALIBRATED 0x2000 /* subdevice uses software calibration */#define SDF_CMD_WRITE 0x4000 /* can do output commands */#define SDF_CMD_READ 0x8000 /* can do input commands */ /* subdevice can be read (e.g. analog input) */#define SDF_READABLE 0x00010000/* subdevice can be written (e.g. analog output) */#define SDF_WRITABLE 0x00020000#define SDF_WRITEABLE SDF_WRITABLE /* spelling error in API *//* subdevice does not have externally visible lines */#define SDF_INTERNAL 0x00040000#define SDF_GROUND 0x00100000 /* can do aref=ground */#define SDF_COMMON 0x00200000 /* can do aref=common */#define SDF_DIFF 0x00400000 /* can do aref=diff */#define SDF_OTHER 0x00800000 /* can do aref=other */#define SDF_DITHER 0x01000000 /* can do dithering */#define SDF_DEGLITCH 0x02000000 /* can do deglitching */#define SDF_MMAP 0x04000000 /* can do mmap() */#define SDF_RUNNING 0x08000000 /* subdevice is acquiring data */#define SDF_LSAMPL 0x10000000 /* subdevice uses 32-bit samples */#define SDF_PACKED 0x20000000 /* subdevice can do packed DIO */ /* subdevice types */ /** * enum comedi_subdevice_type - COMEDI subdevice types * @COMEDI_SUBD_UNUSED: Unused subdevice. * @COMEDI_SUBD_AI: Analog input. * @COMEDI_SUBD_AO: Analog output. * @COMEDI_SUBD_DI: Digital input. * @COMEDI_SUBD_DO: Digital output. * @COMEDI_SUBD_DIO: Digital input/output. * @COMEDI_SUBD_COUNTER: Counter. * @COMEDI_SUBD_TIMER: Timer. * @COMEDI_SUBD_MEMORY: Memory, EEPROM, DPRAM. * @COMEDI_SUBD_CALIB: Calibration DACs. * @COMEDI_SUBD_PROC: Processor, DSP. * @COMEDI_SUBD_SERIAL: Serial I/O. * @COMEDI_SUBD_PWM: Pulse-Width Modulation output. */enum comedi_subdevice_type { COMEDI_SUBD_UNUSED, COMEDI_SUBD_AI, COMEDI_SUBD_AO, COMEDI_SUBD_DI, COMEDI_SUBD_DO, COMEDI_SUBD_DIO, COMEDI_SUBD_COUNTER, COMEDI_SUBD_TIMER, COMEDI_SUBD_MEMORY, COMEDI_SUBD_CALIB, COMEDI_SUBD_PROC, COMEDI_SUBD_SERIAL, COMEDI_SUBD_PWM}; /* configuration instructions */ /** * enum comedi_io_direction - COMEDI I/O directions * @COMEDI_INPUT: Input. * @COMEDI_OUTPUT: Output. * @COMEDI_OPENDRAIN: Open-drain (or open-collector) output. * * These are used by the %INSN_CONFIG_DIO_QUERY configuration instruction to * report a direction. They may also be used in other places where a direction * needs to be specified. */enum comedi_io_direction { COMEDI_INPUT = 0, COMEDI_OUTPUT = 1, COMEDI_OPENDRAIN = 2}; /** * enum configuration_ids - COMEDI configuration instruction codes * @INSN_CONFIG_DIO_INPUT: Configure digital I/O as input. * @INSN_CONFIG_DIO_OUTPUT: Configure digital I/O as output. * @INSN_CONFIG_DIO_OPENDRAIN: Configure digital I/O as open-drain (or open * collector) output. * @INSN_CONFIG_ANALOG_TRIG: Configure analog trigger. * @INSN_CONFIG_ALT_SOURCE: Configure alternate input source. * @INSN_CONFIG_DIGITAL_TRIG: Configure digital trigger. * @INSN_CONFIG_BLOCK_SIZE: Configure block size for DMA transfers. * @INSN_CONFIG_TIMER_1: Configure divisor for external clock. * @INSN_CONFIG_FILTER: Configure a filter. * @INSN_CONFIG_CHANGE_NOTIFY: Configure change notification for digital * inputs. (New drivers should use * %INSN_CONFIG_DIGITAL_TRIG instead.) * @INSN_CONFIG_SERIAL_CLOCK: Configure clock for serial I/O. * @INSN_CONFIG_BIDIRECTIONAL_DATA: Send and receive byte over serial I/O. * @INSN_CONFIG_DIO_QUERY: Query direction of digital I/O channel. * @INSN_CONFIG_PWM_OUTPUT: Configure pulse-width modulator output. * @INSN_CONFIG_GET_PWM_OUTPUT: Get pulse-width modulator output configuration. * @INSN_CONFIG_ARM: Arm a subdevice or channel. * @INSN_CONFIG_DISARM: Disarm a subdevice or channel. * @INSN_CONFIG_GET_COUNTER_STATUS: Get counter status. * @INSN_CONFIG_RESET: Reset a subdevice or channel. * @INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR: Configure counter/timer as * single pulse generator. * @INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR: Configure counter/timer as * pulse train generator. * @INSN_CONFIG_GPCT_QUADRATURE_ENCODER: Configure counter as a quadrature * encoder. * @INSN_CONFIG_SET_GATE_SRC: Set counter/timer gate source. * @INSN_CONFIG_GET_GATE_SRC: Get counter/timer gate source. * @INSN_CONFIG_SET_CLOCK_SRC: Set counter/timer master clock source. * @INSN_CONFIG_GET_CLOCK_SRC: Get counter/timer master clock source. * @INSN_CONFIG_SET_OTHER_SRC: Set counter/timer "other" source. * @INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE: Get size (in bytes) of subdevice's * on-board FIFOs used during streaming * input/output. * @INSN_CONFIG_SET_COUNTER_MODE: Set counter/timer mode. * @INSN_CONFIG_8254_SET_MODE: (Deprecated) Same as * %INSN_CONFIG_SET_COUNTER_MODE. * @INSN_CONFIG_8254_READ_STATUS: Read status of 8254 counter channel. * @INSN_CONFIG_SET_ROUTING: Set routing for a channel. * @INSN_CONFIG_GET_ROUTING: Get routing for a channel. * @INSN_CONFIG_PWM_SET_PERIOD: Set PWM period in nanoseconds. * @INSN_CONFIG_PWM_GET_PERIOD: Get PWM period in nanoseconds. * @INSN_CONFIG_GET_PWM_STATUS: Get PWM status. * @INSN_CONFIG_PWM_SET_H_BRIDGE: Set PWM H bridge duty cycle and polarity for * a relay simultaneously. * @INSN_CONFIG_PWM_GET_H_BRIDGE: Get PWM H bridge duty cycle and polarity. * @INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS: Get the hardware timing restraints, * regardless of trigger sources. */enum configuration_ids { INSN_CONFIG_DIO_INPUT = COMEDI_INPUT, INSN_CONFIG_DIO_OUTPUT = COMEDI_OUTPUT, INSN_CONFIG_DIO_OPENDRAIN = COMEDI_OPENDRAIN, INSN_CONFIG_ANALOG_TRIG = 16,/* INSN_CONFIG_WAVEFORM = 17, *//* INSN_CONFIG_TRIG = 18, *//* INSN_CONFIG_COUNTER = 19, */ INSN_CONFIG_ALT_SOURCE = 20, INSN_CONFIG_DIGITAL_TRIG = 21, INSN_CONFIG_BLOCK_SIZE = 22, INSN_CONFIG_TIMER_1 = 23, INSN_CONFIG_FILTER = 24, INSN_CONFIG_CHANGE_NOTIFY = 25, INSN_CONFIG_SERIAL_CLOCK = 26, /*ALPHA*/ INSN_CONFIG_BIDIRECTIONAL_DATA = 27, INSN_CONFIG_DIO_QUERY = 28, INSN_CONFIG_PWM_OUTPUT = 29, INSN_CONFIG_GET_PWM_OUTPUT = 30, INSN_CONFIG_ARM = 31, INSN_CONFIG_DISARM = 32, INSN_CONFIG_GET_COUNTER_STATUS = 33, INSN_CONFIG_RESET = 34, INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR = 1001, INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR = 1002, INSN_CONFIG_GPCT_QUADRATURE_ENCODER = 1003, INSN_CONFIG_SET_GATE_SRC = 2001, INSN_CONFIG_GET_GATE_SRC = 2002, INSN_CONFIG_SET_CLOCK_SRC = 2003, INSN_CONFIG_GET_CLOCK_SRC = 2004, INSN_CONFIG_SET_OTHER_SRC = 2005, INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE = 2006, INSN_CONFIG_SET_COUNTER_MODE = 4097, INSN_CONFIG_8254_SET_MODE = INSN_CONFIG_SET_COUNTER_MODE, INSN_CONFIG_8254_READ_STATUS = 4098, INSN_CONFIG_SET_ROUTING = 4099, INSN_CONFIG_GET_ROUTING = 4109, INSN_CONFIG_PWM_SET_PERIOD = 5000, INSN_CONFIG_PWM_GET_PERIOD = 5001, INSN_CONFIG_GET_PWM_STATUS = 5002, INSN_CONFIG_PWM_SET_H_BRIDGE = 5003, INSN_CONFIG_PWM_GET_H_BRIDGE = 5004, INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS = 5005,}; /** * enum device_configuration_ids - COMEDI configuration instruction codes global * to an entire device. * @INSN_DEVICE_CONFIG_TEST_ROUTE: Validate the possibility of a * globally-named route * @INSN_DEVICE_CONFIG_CONNECT_ROUTE: Connect a globally-named route * @INSN_DEVICE_CONFIG_DISCONNECT_ROUTE:Disconnect a globally-named route * @INSN_DEVICE_CONFIG_GET_ROUTES: Get a list of all globally-named routes * that are valid for a particular device. */enum device_config_route_ids { INSN_DEVICE_CONFIG_TEST_ROUTE = 0, INSN_DEVICE_CONFIG_CONNECT_ROUTE = 1, INSN_DEVICE_CONFIG_DISCONNECT_ROUTE = 2, INSN_DEVICE_CONFIG_GET_ROUTES = 3,}; /** * enum comedi_digital_trig_op - operations for configuring a digital trigger * @COMEDI_DIGITAL_TRIG_DISABLE: Return digital trigger to its default, * inactive, unconfigured state. * @COMEDI_DIGITAL_TRIG_ENABLE_EDGES: Set rising and/or falling edge inputs * that each can fire the trigger. * @COMEDI_DIGITAL_TRIG_ENABLE_LEVELS: Set a combination of high and/or low * level inputs that can fire the trigger. * * These are used with the %INSN_CONFIG_DIGITAL_TRIG configuration instruction. * The data for the configuration instruction is as follows... * * data[%0] = %INSN_CONFIG_DIGITAL_TRIG * * data[%1] = trigger ID * * data[%2] = configuration operation * * data[%3] = configuration parameter 1 * * data[%4] = configuration parameter 2 * * data[%5] = configuration parameter 3 * * The trigger ID (data[%1]) is used to differentiate multiple digital triggers * belonging to the same subdevice. The configuration operation (data[%2]) is * one of the enum comedi_digital_trig_op values. The configuration * parameters (data[%3], data[%4], and data[%5]) depend on the operation; they * are not used with %COMEDI_DIGITAL_TRIG_DISABLE. * * For %COMEDI_DIGITAL_TRIG_ENABLE_EDGES and %COMEDI_DIGITAL_TRIG_ENABLE_LEVELS, * configuration parameter 1 (data[%3]) contains a "left-shift" value that * specifies the input corresponding to bit 0 of configuration parameters 2 * and 3. This is useful if the trigger has more than 32 inputs. * * For %COMEDI_DIGITAL_TRIG_ENABLE_EDGES, configuration parameter 2 (data[%4]) * specifies which of up to 32 inputs have rising-edge sensitivity, and * configuration parameter 3 (data[%5]) specifies which of up to 32 inputs * have falling-edge sensitivity that can fire the trigger. * * For %COMEDI_DIGITAL_TRIG_ENABLE_LEVELS, configuration parameter 2 (data[%4]) * specifies which of up to 32 inputs must be at a high level, and * configuration parameter 3 (data[%5]) specifies which of up to 32 inputs * must be at a low level for the trigger to fire. * * Some sequences of %INSN_CONFIG_DIGITAL_TRIG instructions may have a (partly) * accumulative effect, depending on the low-level driver. This is useful * when setting up a trigger that has more than 32 inputs, or has a combination * of edge- and level-triggered inputs. */enum comedi_digital_trig_op { COMEDI_DIGITAL_TRIG_DISABLE = 0, COMEDI_DIGITAL_TRIG_ENABLE_EDGES = 1, COMEDI_DIGITAL_TRIG_ENABLE_LEVELS = 2}; /** * enum comedi_support_level - support level for a COMEDI feature * @COMEDI_UNKNOWN_SUPPORT: Unspecified support for feature. * @COMEDI_SUPPORTED: Feature is supported. * @COMEDI_UNSUPPORTED: Feature is unsupported. */enum comedi_support_level { COMEDI_UNKNOWN_SUPPORT = 0, COMEDI_SUPPORTED, COMEDI_UNSUPPORTED}; /** * enum comedi_counter_status_flags - counter status bits * @COMEDI_COUNTER_ARMED: Counter is armed. * @COMEDI_COUNTER_COUNTING: Counter is counting. * @COMEDI_COUNTER_TERMINAL_COUNT: Counter reached terminal count. * * These bitwise values are used by the %INSN_CONFIG_GET_COUNTER_STATUS * configuration instruction to report the status of a counter. */enum comedi_counter_status_flags { COMEDI_COUNTER_ARMED = 0x1, COMEDI_COUNTER_COUNTING = 0x2, COMEDI_COUNTER_TERMINAL_COUNT = 0x4,}; /* ioctls */ #define CIO 'd'#define COMEDI_DEVCONFIG _IOW(CIO, 0, struct comedi_devconfig)#define COMEDI_DEVINFO _IOR(CIO, 1, struct comedi_devinfo)#define COMEDI_SUBDINFO _IOR(CIO, 2, struct comedi_subdinfo)#define COMEDI_CHANINFO _IOR(CIO, 3, struct comedi_chaninfo)/* _IOWR(CIO, 4, ...) is reserved */#define COMEDI_LOCK _IO(CIO, 5)#define COMEDI_UNLOCK _IO(CIO, 6)#define COMEDI_CANCEL _IO(CIO, 7)#define COMEDI_RANGEINFO _IOR(CIO, 8, struct comedi_rangeinfo)#define COMEDI_CMD _IOR(CIO, 9, struct comedi_cmd)#define COMEDI_CMDTEST _IOR(CIO, 10, struct comedi_cmd)#define COMEDI_INSNLIST _IOR(CIO, 11, struct comedi_insnlist)#define COMEDI_INSN _IOR(CIO, 12, struct comedi_insn)#define COMEDI_BUFCONFIG _IOR(CIO, 13, struct comedi_bufconfig)#define COMEDI_BUFINFO _IOWR(CIO, 14, struct comedi_bufinfo)#define COMEDI_POLL _IO(CIO, 15)#define COMEDI_SETRSUBD _IO(CIO, 16)#define COMEDI_SETWSUBD _IO(CIO, 17) /* structures */ /** * struct comedi_insn - COMEDI instruction * @insn: COMEDI instruction type (%INSN_xxx). * @n: Length of @data[]. * @data: Pointer to data array operated on by the instruction. * @subdev: Subdevice index. * @chanspec: A packed "chanspec" value consisting of channel number, * analog range index, analog reference type, and flags. * @unused: Reserved for future use. * * This is used with the %COMEDI_INSN ioctl, and indirectly with the * %COMEDI_INSNLIST ioctl. */struct comedi_insn { unsigned int insn; unsigned int n; unsigned int __user *data; unsigned int subdev; unsigned int chanspec; unsigned int unused[3];}; /**Lines 1–500 of 1528. Load more
/* SPDX-License-Identifier: LGPL-2.0+ WITH Linux-syscall-note */ /* * comedi.h * header file for COMEDI user API * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 1998-2001 David A. Schleef <ds@schleef.org> */ #ifndef _COMEDI_H #define _COMEDI_H #define COMEDI_MAJORVERSION 0 #define COMEDI_MINORVERSION 7 #define COMEDI_MICROVERSION 76 #define VERSION "0.7.76" /* comedi's major device number */ #define COMEDI_MAJOR 98 /* * maximum number of minor devices. This can be increased, although * kernel structures are currently statically allocated, thus you * don't want this to be much more than you actually use. */ #define COMEDI_NDEVICES 16 /* number of config options in the config structure */ #define COMEDI_NDEVCONFOPTS 32 /* * NOTE: 'comedi_config --init-data' is deprecated * * The following indexes in the config options were used by * comedi_config to pass firmware blobs from user space to the * comedi drivers. The request_firmware() hotplug interface is * now used by all comedi drivers instead. */ /* length of nth chunk of firmware data -*/ #define COMEDI_DEVCONF_AUX_DATA3_LENGTH 25 #define COMEDI_DEVCONF_AUX_DATA2_LENGTH 26 #define COMEDI_DEVCONF_AUX_DATA1_LENGTH 27 #define COMEDI_DEVCONF_AUX_DATA0_LENGTH 28 /* most significant 32 bits of pointer address (if needed) */ #define COMEDI_DEVCONF_AUX_DATA_HI 29 /* least significant 32 bits of pointer address */ #define COMEDI_DEVCONF_AUX_DATA_LO 30 #define COMEDI_DEVCONF_AUX_DATA_LENGTH 31 /* total data length */ /* max length of device and driver names */ #define COMEDI_NAMELEN 20 /* packs and unpacks a channel/range number */ #define CR_PACK(chan, rng, aref) \ ((((aref) & 0x3) << 24) | (((rng) & 0xff) << 16) | (chan)) #define CR_PACK_FLAGS(chan, range, aref, flags) \ (CR_PACK(chan, range, aref) | ((flags) & CR_FLAGS_MASK)) #define CR_CHAN(a) ((a) & 0xffff) #define CR_RANGE(a) (((a) >> 16) & 0xff) #define CR_AREF(a) (((a) >> 24) & 0x03) #define CR_FLAGS_MASK 0xfc000000 #define CR_ALT_FILTER 0x04000000 #define CR_DITHER CR_ALT_FILTER #define CR_DEGLITCH CR_ALT_FILTER #define CR_ALT_SOURCE 0x08000000 #define CR_EDGE 0x40000000 #define CR_INVERT 0x80000000 #define AREF_GROUND 0x00 /* analog ref = analog ground */ #define AREF_COMMON 0x01 /* analog ref = analog common */ #define AREF_DIFF 0x02 /* analog ref = differential */ #define AREF_OTHER 0x03 /* analog ref = other (undefined) */ /* counters -- these are arbitrary values */ #define GPCT_RESET 0x0001 #define GPCT_SET_SOURCE 0x0002 #define GPCT_SET_GATE 0x0004 #define GPCT_SET_DIRECTION 0x0008 #define GPCT_SET_OPERATION 0x0010 #define GPCT_ARM 0x0020 #define GPCT_DISARM 0x0040 #define GPCT_GET_INT_CLK_FRQ 0x0080 #define GPCT_INT_CLOCK 0x0001 #define GPCT_EXT_PIN 0x0002 #define GPCT_NO_GATE 0x0004 #define GPCT_UP 0x0008 #define GPCT_DOWN 0x0010 #define GPCT_HWUD 0x0020 #define GPCT_SIMPLE_EVENT 0x0040 #define GPCT_SINGLE_PERIOD 0x0080 #define GPCT_SINGLE_PW 0x0100 #define GPCT_CONT_PULSE_OUT 0x0200 #define GPCT_SINGLE_PULSE_OUT 0x0400 /* instructions */ #define INSN_MASK_WRITE 0x8000000 #define INSN_MASK_READ 0x4000000 #define INSN_MASK_SPECIAL 0x2000000 #define INSN_READ (0 | INSN_MASK_READ) #define INSN_WRITE (1 | INSN_MASK_WRITE) #define INSN_BITS (2 | INSN_MASK_READ | INSN_MASK_WRITE) #define INSN_CONFIG (3 | INSN_MASK_READ | INSN_MASK_WRITE) #define INSN_DEVICE_CONFIG (INSN_CONFIG | INSN_MASK_SPECIAL) #define INSN_GTOD (4 | INSN_MASK_READ | INSN_MASK_SPECIAL) #define INSN_WAIT (5 | INSN_MASK_WRITE | INSN_MASK_SPECIAL) #define INSN_INTTRIG (6 | INSN_MASK_WRITE | INSN_MASK_SPECIAL) /* command flags */ /* These flags are used in comedi_cmd structures */ #define CMDF_BOGUS 0x00000001 /* do the motions */ /* try to use a real-time interrupt while performing command */ #define CMDF_PRIORITY 0x00000008 /* wake up on end-of-scan events */ #define CMDF_WAKE_EOS 0x00000020 #define CMDF_WRITE 0x00000040 #define CMDF_RAWDATA 0x00000080 /* timer rounding definitions */ #define CMDF_ROUND_MASK 0x00030000 #define CMDF_ROUND_NEAREST 0x00000000 #define CMDF_ROUND_DOWN 0x00010000 #define CMDF_ROUND_UP 0x00020000 #define CMDF_ROUND_UP_NEXT 0x00030000 #define COMEDI_EV_START 0x00040000 #define COMEDI_EV_SCAN_BEGIN 0x00080000 #define COMEDI_EV_CONVERT 0x00100000 #define COMEDI_EV_SCAN_END 0x00200000 #define COMEDI_EV_STOP 0x00400000 /* compatibility definitions */ #define TRIG_BOGUS CMDF_BOGUS #define TRIG_RT CMDF_PRIORITY #define TRIG_WAKE_EOS CMDF_WAKE_EOS #define TRIG_WRITE CMDF_WRITE #define TRIG_ROUND_MASK CMDF_ROUND_MASK #define TRIG_ROUND_NEAREST CMDF_ROUND_NEAREST #define TRIG_ROUND_DOWN CMDF_ROUND_DOWN #define TRIG_ROUND_UP CMDF_ROUND_UP #define TRIG_ROUND_UP_NEXT CMDF_ROUND_UP_NEXT /* trigger sources */ #define TRIG_ANY 0xffffffff #define TRIG_INVALID 0x00000000 #define TRIG_NONE 0x00000001 /* never trigger */ #define TRIG_NOW 0x00000002 /* trigger now + N ns */ #define TRIG_FOLLOW 0x00000004 /* trigger on next lower level trig */ #define TRIG_TIME 0x00000008 /* trigger at time N ns */ #define TRIG_TIMER 0x00000010 /* trigger at rate N ns */ #define TRIG_COUNT 0x00000020 /* trigger when count reaches N */ #define TRIG_EXT 0x00000040 /* trigger on external signal N */ #define TRIG_INT 0x00000080 /* trigger on comedi-internal signal N */ #define TRIG_OTHER 0x00000100 /* driver defined */ /* subdevice flags */ #define SDF_BUSY 0x0001 /* device is busy */ #define SDF_BUSY_OWNER 0x0002 /* device is busy with your job */ #define SDF_LOCKED 0x0004 /* subdevice is locked */ #define SDF_LOCK_OWNER 0x0008 /* you own lock */ #define SDF_MAXDATA 0x0010 /* maxdata depends on channel */ #define SDF_FLAGS 0x0020 /* flags depend on channel */ #define SDF_RANGETYPE 0x0040 /* range type depends on channel */ #define SDF_PWM_COUNTER 0x0080 /* PWM can automatically switch off */ #define SDF_PWM_HBRIDGE 0x0100 /* PWM is signed (H-bridge) */ #define SDF_CMD 0x1000 /* can do commands (deprecated) */ #define SDF_SOFT_CALIBRATED 0x2000 /* subdevice uses software calibration */ #define SDF_CMD_WRITE 0x4000 /* can do output commands */ #define SDF_CMD_READ 0x8000 /* can do input commands */ /* subdevice can be read (e.g. analog input) */ #define SDF_READABLE 0x00010000 /* subdevice can be written (e.g. analog output) */ #define SDF_WRITABLE 0x00020000 #define SDF_WRITEABLE SDF_WRITABLE /* spelling error in API */ /* subdevice does not have externally visible lines */ #define SDF_INTERNAL 0x00040000 #define SDF_GROUND 0x00100000 /* can do aref=ground */ #define SDF_COMMON 0x00200000 /* can do aref=common */ #define SDF_DIFF 0x00400000 /* can do aref=diff */ #define SDF_OTHER 0x00800000 /* can do aref=other */ #define SDF_DITHER 0x01000000 /* can do dithering */ #define SDF_DEGLITCH 0x02000000 /* can do deglitching */ #define SDF_MMAP 0x04000000 /* can do mmap() */ #define SDF_RUNNING 0x08000000 /* subdevice is acquiring data */ #define SDF_LSAMPL 0x10000000 /* subdevice uses 32-bit samples */ #define SDF_PACKED 0x20000000 /* subdevice can do packed DIO */ /* subdevice types */ /** * enum comedi_subdevice_type - COMEDI subdevice types * @COMEDI_SUBD_UNUSED: Unused subdevice. * @COMEDI_SUBD_AI: Analog input. * @COMEDI_SUBD_AO: Analog output. * @COMEDI_SUBD_DI: Digital input. * @COMEDI_SUBD_DO: Digital output. * @COMEDI_SUBD_DIO: Digital input/output. * @COMEDI_SUBD_COUNTER: Counter. * @COMEDI_SUBD_TIMER: Timer. * @COMEDI_SUBD_MEMORY: Memory, EEPROM, DPRAM. * @COMEDI_SUBD_CALIB: Calibration DACs. * @COMEDI_SUBD_PROC: Processor, DSP. * @COMEDI_SUBD_SERIAL: Serial I/O. * @COMEDI_SUBD_PWM: Pulse-Width Modulation output. */ enum comedi_subdevice_type { COMEDI_SUBD_UNUSED, COMEDI_SUBD_AI, COMEDI_SUBD_AO, COMEDI_SUBD_DI, COMEDI_SUBD_DO, COMEDI_SUBD_DIO, COMEDI_SUBD_COUNTER, COMEDI_SUBD_TIMER, COMEDI_SUBD_MEMORY, COMEDI_SUBD_CALIB, COMEDI_SUBD_PROC, COMEDI_SUBD_SERIAL, COMEDI_SUBD_PWM }; /* configuration instructions */ /** * enum comedi_io_direction - COMEDI I/O directions * @COMEDI_INPUT: Input. * @COMEDI_OUTPUT: Output. * @COMEDI_OPENDRAIN: Open-drain (or open-collector) output. * * These are used by the %INSN_CONFIG_DIO_QUERY configuration instruction to * report a direction. They may also be used in other places where a direction * needs to be specified. */ enum comedi_io_direction { COMEDI_INPUT = 0, COMEDI_OUTPUT = 1, COMEDI_OPENDRAIN = 2 }; /** * enum configuration_ids - COMEDI configuration instruction codes * @INSN_CONFIG_DIO_INPUT: Configure digital I/O as input. * @INSN_CONFIG_DIO_OUTPUT: Configure digital I/O as output. * @INSN_CONFIG_DIO_OPENDRAIN: Configure digital I/O as open-drain (or open * collector) output. * @INSN_CONFIG_ANALOG_TRIG: Configure analog trigger. * @INSN_CONFIG_ALT_SOURCE: Configure alternate input source. * @INSN_CONFIG_DIGITAL_TRIG: Configure digital trigger. * @INSN_CONFIG_BLOCK_SIZE: Configure block size for DMA transfers. * @INSN_CONFIG_TIMER_1: Configure divisor for external clock. * @INSN_CONFIG_FILTER: Configure a filter. * @INSN_CONFIG_CHANGE_NOTIFY: Configure change notification for digital * inputs. (New drivers should use * %INSN_CONFIG_DIGITAL_TRIG instead.) * @INSN_CONFIG_SERIAL_CLOCK: Configure clock for serial I/O. * @INSN_CONFIG_BIDIRECTIONAL_DATA: Send and receive byte over serial I/O. * @INSN_CONFIG_DIO_QUERY: Query direction of digital I/O channel. * @INSN_CONFIG_PWM_OUTPUT: Configure pulse-width modulator output. * @INSN_CONFIG_GET_PWM_OUTPUT: Get pulse-width modulator output configuration. * @INSN_CONFIG_ARM: Arm a subdevice or channel. * @INSN_CONFIG_DISARM: Disarm a subdevice or channel. * @INSN_CONFIG_GET_COUNTER_STATUS: Get counter status. * @INSN_CONFIG_RESET: Reset a subdevice or channel. * @INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR: Configure counter/timer as * single pulse generator. * @INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR: Configure counter/timer as * pulse train generator. * @INSN_CONFIG_GPCT_QUADRATURE_ENCODER: Configure counter as a quadrature * encoder. * @INSN_CONFIG_SET_GATE_SRC: Set counter/timer gate source. * @INSN_CONFIG_GET_GATE_SRC: Get counter/timer gate source. * @INSN_CONFIG_SET_CLOCK_SRC: Set counter/timer master clock source. * @INSN_CONFIG_GET_CLOCK_SRC: Get counter/timer master clock source. * @INSN_CONFIG_SET_OTHER_SRC: Set counter/timer "other" source. * @INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE: Get size (in bytes) of subdevice's * on-board FIFOs used during streaming * input/output. * @INSN_CONFIG_SET_COUNTER_MODE: Set counter/timer mode. * @INSN_CONFIG_8254_SET_MODE: (Deprecated) Same as * %INSN_CONFIG_SET_COUNTER_MODE. * @INSN_CONFIG_8254_READ_STATUS: Read status of 8254 counter channel. * @INSN_CONFIG_SET_ROUTING: Set routing for a channel. * @INSN_CONFIG_GET_ROUTING: Get routing for a channel. * @INSN_CONFIG_PWM_SET_PERIOD: Set PWM period in nanoseconds. * @INSN_CONFIG_PWM_GET_PERIOD: Get PWM period in nanoseconds. * @INSN_CONFIG_GET_PWM_STATUS: Get PWM status. * @INSN_CONFIG_PWM_SET_H_BRIDGE: Set PWM H bridge duty cycle and polarity for * a relay simultaneously. * @INSN_CONFIG_PWM_GET_H_BRIDGE: Get PWM H bridge duty cycle and polarity. * @INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS: Get the hardware timing restraints, * regardless of trigger sources. */ enum configuration_ids { INSN_CONFIG_DIO_INPUT = COMEDI_INPUT, INSN_CONFIG_DIO_OUTPUT = COMEDI_OUTPUT, INSN_CONFIG_DIO_OPENDRAIN = COMEDI_OPENDRAIN, INSN_CONFIG_ANALOG_TRIG = 16, /* INSN_CONFIG_WAVEFORM = 17, */ /* INSN_CONFIG_TRIG = 18, */ /* INSN_CONFIG_COUNTER = 19, */ INSN_CONFIG_ALT_SOURCE = 20, INSN_CONFIG_DIGITAL_TRIG = 21, INSN_CONFIG_BLOCK_SIZE = 22, INSN_CONFIG_TIMER_1 = 23, INSN_CONFIG_FILTER = 24, INSN_CONFIG_CHANGE_NOTIFY = 25, INSN_CONFIG_SERIAL_CLOCK = 26, /*ALPHA*/ INSN_CONFIG_BIDIRECTIONAL_DATA = 27, INSN_CONFIG_DIO_QUERY = 28, INSN_CONFIG_PWM_OUTPUT = 29, INSN_CONFIG_GET_PWM_OUTPUT = 30, INSN_CONFIG_ARM = 31, INSN_CONFIG_DISARM = 32, INSN_CONFIG_GET_COUNTER_STATUS = 33, INSN_CONFIG_RESET = 34, INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR = 1001, INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR = 1002, INSN_CONFIG_GPCT_QUADRATURE_ENCODER = 1003, INSN_CONFIG_SET_GATE_SRC = 2001, INSN_CONFIG_GET_GATE_SRC = 2002, INSN_CONFIG_SET_CLOCK_SRC = 2003, INSN_CONFIG_GET_CLOCK_SRC = 2004, INSN_CONFIG_SET_OTHER_SRC = 2005, INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE = 2006, INSN_CONFIG_SET_COUNTER_MODE = 4097, INSN_CONFIG_8254_SET_MODE = INSN_CONFIG_SET_COUNTER_MODE, INSN_CONFIG_8254_READ_STATUS = 4098, INSN_CONFIG_SET_ROUTING = 4099, INSN_CONFIG_GET_ROUTING = 4109, INSN_CONFIG_PWM_SET_PERIOD = 5000, INSN_CONFIG_PWM_GET_PERIOD = 5001, INSN_CONFIG_GET_PWM_STATUS = 5002, INSN_CONFIG_PWM_SET_H_BRIDGE = 5003, INSN_CONFIG_PWM_GET_H_BRIDGE = 5004, INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS = 5005, }; /** * enum device_configuration_ids - COMEDI configuration instruction codes global * to an entire device. * @INSN_DEVICE_CONFIG_TEST_ROUTE: Validate the possibility of a * globally-named route * @INSN_DEVICE_CONFIG_CONNECT_ROUTE: Connect a globally-named route * @INSN_DEVICE_CONFIG_DISCONNECT_ROUTE:Disconnect a globally-named route * @INSN_DEVICE_CONFIG_GET_ROUTES: Get a list of all globally-named routes * that are valid for a particular device. */ enum device_config_route_ids { INSN_DEVICE_CONFIG_TEST_ROUTE = 0, INSN_DEVICE_CONFIG_CONNECT_ROUTE = 1, INSN_DEVICE_CONFIG_DISCONNECT_ROUTE = 2, INSN_DEVICE_CONFIG_GET_ROUTES = 3, }; /** * enum comedi_digital_trig_op - operations for configuring a digital trigger * @COMEDI_DIGITAL_TRIG_DISABLE: Return digital trigger to its default, * inactive, unconfigured state. * @COMEDI_DIGITAL_TRIG_ENABLE_EDGES: Set rising and/or falling edge inputs * that each can fire the trigger. * @COMEDI_DIGITAL_TRIG_ENABLE_LEVELS: Set a combination of high and/or low * level inputs that can fire the trigger. * * These are used with the %INSN_CONFIG_DIGITAL_TRIG configuration instruction. * The data for the configuration instruction is as follows... * * data[%0] = %INSN_CONFIG_DIGITAL_TRIG * * data[%1] = trigger ID * * data[%2] = configuration operation * * data[%3] = configuration parameter 1 * * data[%4] = configuration parameter 2 * * data[%5] = configuration parameter 3 * * The trigger ID (data[%1]) is used to differentiate multiple digital triggers * belonging to the same subdevice. The configuration operation (data[%2]) is * one of the enum comedi_digital_trig_op values. The configuration * parameters (data[%3], data[%4], and data[%5]) depend on the operation; they * are not used with %COMEDI_DIGITAL_TRIG_DISABLE. * * For %COMEDI_DIGITAL_TRIG_ENABLE_EDGES and %COMEDI_DIGITAL_TRIG_ENABLE_LEVELS, * configuration parameter 1 (data[%3]) contains a "left-shift" value that * specifies the input corresponding to bit 0 of configuration parameters 2 * and 3. This is useful if the trigger has more than 32 inputs. * * For %COMEDI_DIGITAL_TRIG_ENABLE_EDGES, configuration parameter 2 (data[%4]) * specifies which of up to 32 inputs have rising-edge sensitivity, and * configuration parameter 3 (data[%5]) specifies which of up to 32 inputs * have falling-edge sensitivity that can fire the trigger. * * For %COMEDI_DIGITAL_TRIG_ENABLE_LEVELS, configuration parameter 2 (data[%4]) * specifies which of up to 32 inputs must be at a high level, and * configuration parameter 3 (data[%5]) specifies which of up to 32 inputs * must be at a low level for the trigger to fire. * * Some sequences of %INSN_CONFIG_DIGITAL_TRIG instructions may have a (partly) * accumulative effect, depending on the low-level driver. This is useful * when setting up a trigger that has more than 32 inputs, or has a combination * of edge- and level-triggered inputs. */ enum comedi_digital_trig_op { COMEDI_DIGITAL_TRIG_DISABLE = 0, COMEDI_DIGITAL_TRIG_ENABLE_EDGES = 1, COMEDI_DIGITAL_TRIG_ENABLE_LEVELS = 2 }; /** * enum comedi_support_level - support level for a COMEDI feature * @COMEDI_UNKNOWN_SUPPORT: Unspecified support for feature. * @COMEDI_SUPPORTED: Feature is supported. * @COMEDI_UNSUPPORTED: Feature is unsupported. */ enum comedi_support_level { COMEDI_UNKNOWN_SUPPORT = 0, COMEDI_SUPPORTED, COMEDI_UNSUPPORTED }; /** * enum comedi_counter_status_flags - counter status bits * @COMEDI_COUNTER_ARMED: Counter is armed. * @COMEDI_COUNTER_COUNTING: Counter is counting. * @COMEDI_COUNTER_TERMINAL_COUNT: Counter reached terminal count. * * These bitwise values are used by the %INSN_CONFIG_GET_COUNTER_STATUS * configuration instruction to report the status of a counter. */ enum comedi_counter_status_flags { COMEDI_COUNTER_ARMED = 0x1, COMEDI_COUNTER_COUNTING = 0x2, COMEDI_COUNTER_TERMINAL_COUNT = 0x4, }; /* ioctls */ #define CIO 'd' #define COMEDI_DEVCONFIG _IOW(CIO, 0, struct comedi_devconfig) #define COMEDI_DEVINFO _IOR(CIO, 1, struct comedi_devinfo) #define COMEDI_SUBDINFO _IOR(CIO, 2, struct comedi_subdinfo) #define COMEDI_CHANINFO _IOR(CIO, 3, struct comedi_chaninfo) /* _IOWR(CIO, 4, ...) is reserved */ #define COMEDI_LOCK _IO(CIO, 5) #define COMEDI_UNLOCK _IO(CIO, 6) #define COMEDI_CANCEL _IO(CIO, 7) #define COMEDI_RANGEINFO _IOR(CIO, 8, struct comedi_rangeinfo) #define COMEDI_CMD _IOR(CIO, 9, struct comedi_cmd) #define COMEDI_CMDTEST _IOR(CIO, 10, struct comedi_cmd) #define COMEDI_INSNLIST _IOR(CIO, 11, struct comedi_insnlist) #define COMEDI_INSN _IOR(CIO, 12, struct comedi_insn) #define COMEDI_BUFCONFIG _IOR(CIO, 13, struct comedi_bufconfig) #define COMEDI_BUFINFO _IOWR(CIO, 14, struct comedi_bufinfo) #define COMEDI_POLL _IO(CIO, 15) #define COMEDI_SETRSUBD _IO(CIO, 16) #define COMEDI_SETWSUBD _IO(CIO, 17) /* structures */ /** * struct comedi_insn - COMEDI instruction * @insn: COMEDI instruction type (%INSN_xxx). * @n: Length of @data[]. * @data: Pointer to data array operated on by the instruction. * @subdev: Subdevice index. * @chanspec: A packed "chanspec" value consisting of channel number, * analog range index, analog reference type, and flags. * @unused: Reserved for future use. * * This is used with the %COMEDI_INSN ioctl, and indirectly with the * %COMEDI_INSNLIST ioctl. */ struct comedi_insn { unsigned int insn; unsigned int n; unsigned int __user *data; unsigned int subdev; unsigned int chanspec; unsigned int unused[3]; }; /**