David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 1 | /* |
| 2 | linux/include/comedilib.h |
| 3 | header file for kcomedilib |
| 4 | |
| 5 | COMEDI - Linux Control and Measurement Device Interface |
| 6 | Copyright (C) 1998-2001 David A. Schleef <ds@schleef.org> |
| 7 | |
| 8 | This program is free software; you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation; either version 2 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | This program is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program; if not, write to the Free Software |
| 20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 21 | |
| 22 | */ |
| 23 | |
| 24 | #ifndef _LINUX_COMEDILIB_H |
| 25 | #define _LINUX_COMEDILIB_H |
| 26 | |
Greg Kroah-Hartman | 02ebd47 | 2008-11-14 14:58:46 -0800 | [diff] [blame] | 27 | #include "comedi.h" |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 28 | |
| 29 | /* Kernel internal stuff. Needed by real-time modules and such. */ |
| 30 | |
| 31 | #ifndef __KERNEL__ |
| 32 | #error linux/comedilib.h should not be included by non-kernel-space code |
| 33 | #endif |
| 34 | |
| 35 | /* exported functions */ |
| 36 | |
| 37 | #ifndef KCOMEDILIB_DEPRECATED |
| 38 | |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 39 | /* these functions may not be called at real-time priority */ |
| 40 | |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 41 | void *comedi_open(const char *path); |
| 42 | int comedi_close(void *dev); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 43 | |
| 44 | /* these functions may be called at any priority, but may fail at |
| 45 | real-time priority */ |
| 46 | |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 47 | int comedi_lock(void *dev, unsigned int subdev); |
| 48 | int comedi_unlock(void *dev, unsigned int subdev); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 49 | |
| 50 | /* these functions may be called at any priority, but you must hold |
| 51 | the lock for the subdevice */ |
| 52 | |
| 53 | int comedi_loglevel(int loglevel); |
| 54 | void comedi_perror(const char *s); |
| 55 | char *comedi_strerror(int errnum); |
| 56 | int comedi_errno(void); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 57 | int comedi_fileno(void *dev); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 58 | |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 59 | int comedi_cancel(void *dev, unsigned int subdev); |
| 60 | int comedi_register_callback(void *dev, unsigned int subdev, |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 61 | unsigned int mask, int (*cb) (unsigned int, void *), void *arg); |
| 62 | |
Bill Pemberton | ea6d0d4 | 2009-03-16 22:05:47 -0400 | [diff] [blame] | 63 | int comedi_command(void *dev, struct comedi_cmd *cmd); |
| 64 | int comedi_command_test(void *dev, struct comedi_cmd *cmd); |
Bill Pemberton | b50d88d | 2009-03-16 22:05:42 -0400 | [diff] [blame] | 65 | int comedi_trigger(void *dev, unsigned int subdev, struct comedi_trig *it); |
| 66 | int __comedi_trigger(void *dev, unsigned int subdev, struct comedi_trig *it); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 67 | int comedi_data_write(void *dev, unsigned int subdev, unsigned int chan, |
Bill Pemberton | 790c554 | 2009-03-16 22:05:02 -0400 | [diff] [blame] | 68 | unsigned int range, unsigned int aref, unsigned int data); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 69 | int comedi_data_read(void *dev, unsigned int subdev, unsigned int chan, |
Bill Pemberton | 790c554 | 2009-03-16 22:05:02 -0400 | [diff] [blame] | 70 | unsigned int range, unsigned int aref, unsigned int *data); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 71 | int comedi_data_read_hint(void *dev, unsigned int subdev, |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 72 | unsigned int chan, unsigned int range, unsigned int aref); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 73 | int comedi_data_read_delayed(void *dev, unsigned int subdev, |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 74 | unsigned int chan, unsigned int range, unsigned int aref, |
Bill Pemberton | 790c554 | 2009-03-16 22:05:02 -0400 | [diff] [blame] | 75 | unsigned int *data, unsigned int nano_sec); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 76 | int comedi_dio_config(void *dev, unsigned int subdev, unsigned int chan, |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 77 | unsigned int io); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 78 | int comedi_dio_read(void *dev, unsigned int subdev, unsigned int chan, |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 79 | unsigned int *val); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 80 | int comedi_dio_write(void *dev, unsigned int subdev, unsigned int chan, |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 81 | unsigned int val); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 82 | int comedi_dio_bitfield(void *dev, unsigned int subdev, unsigned int mask, |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 83 | unsigned int *bits); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 84 | int comedi_get_n_subdevices(void *dev); |
| 85 | int comedi_get_version_code(void *dev); |
| 86 | const char *comedi_get_driver_name(void *dev); |
| 87 | const char *comedi_get_board_name(void *dev); |
| 88 | int comedi_get_subdevice_type(void *dev, unsigned int subdevice); |
| 89 | int comedi_find_subdevice_by_type(void *dev, int type, unsigned int subd); |
| 90 | int comedi_get_n_channels(void *dev, unsigned int subdevice); |
Bill Pemberton | 790c554 | 2009-03-16 22:05:02 -0400 | [diff] [blame] | 91 | unsigned int comedi_get_maxdata(void *dev, unsigned int subdevice, unsigned |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 92 | int chan); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 93 | int comedi_get_n_ranges(void *dev, unsigned int subdevice, unsigned int |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 94 | chan); |
Bill Pemberton | 90035c0 | 2009-03-16 22:05:53 -0400 | [diff] [blame] | 95 | int comedi_do_insn(void *dev, struct comedi_insn *insn); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 96 | int comedi_poll(void *dev, unsigned int subdev); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 97 | |
| 98 | /* DEPRECATED functions */ |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 99 | int comedi_get_rangetype(void *dev, unsigned int subdevice, |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 100 | unsigned int chan); |
| 101 | |
| 102 | /* ALPHA functions */ |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 103 | unsigned int comedi_get_subdevice_flags(void *dev, unsigned int subdevice); |
| 104 | int comedi_get_len_chanlist(void *dev, unsigned int subdevice); |
| 105 | int comedi_get_krange(void *dev, unsigned int subdevice, unsigned int |
Bill Pemberton | 1f6325d | 2009-03-16 22:06:31 -0400 | [diff] [blame] | 106 | chan, unsigned int range, struct comedi_krange *krange); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 107 | unsigned int comedi_get_buf_head_pos(void *dev, unsigned int subdevice); |
| 108 | int comedi_set_user_int_count(void *dev, unsigned int subdevice, |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 109 | unsigned int buf_user_count); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 110 | int comedi_map(void *dev, unsigned int subdev, void *ptr); |
| 111 | int comedi_unmap(void *dev, unsigned int subdev); |
| 112 | int comedi_get_buffer_size(void *dev, unsigned int subdev); |
| 113 | int comedi_mark_buffer_read(void *dev, unsigned int subdevice, |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 114 | unsigned int num_bytes); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 115 | int comedi_mark_buffer_written(void *d, unsigned int subdevice, |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 116 | unsigned int num_bytes); |
Bill Pemberton | 0b3fb27 | 2009-03-16 22:04:56 -0400 | [diff] [blame] | 117 | int comedi_get_buffer_contents(void *dev, unsigned int subdevice); |
| 118 | int comedi_get_buffer_offset(void *dev, unsigned int subdevice); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 119 | |
| 120 | #else |
| 121 | |
| 122 | /* these functions may not be called at real-time priority */ |
| 123 | |
| 124 | int comedi_open(unsigned int minor); |
| 125 | void comedi_close(unsigned int minor); |
| 126 | |
| 127 | /* these functions may be called at any priority, but may fail at |
| 128 | real-time priority */ |
| 129 | |
| 130 | int comedi_lock(unsigned int minor, unsigned int subdev); |
| 131 | int comedi_unlock(unsigned int minor, unsigned int subdev); |
| 132 | |
| 133 | /* these functions may be called at any priority, but you must hold |
| 134 | the lock for the subdevice */ |
| 135 | |
| 136 | int comedi_cancel(unsigned int minor, unsigned int subdev); |
| 137 | int comedi_register_callback(unsigned int minor, unsigned int subdev, |
| 138 | unsigned int mask, int (*cb) (unsigned int, void *), void *arg); |
| 139 | |
Bill Pemberton | ea6d0d4 | 2009-03-16 22:05:47 -0400 | [diff] [blame] | 140 | int comedi_command(unsigned int minor, struct comedi_cmd *cmd); |
| 141 | int comedi_command_test(unsigned int minor, struct comedi_cmd *cmd); |
Bill Pemberton | b50d88d | 2009-03-16 22:05:42 -0400 | [diff] [blame] | 142 | int comedi_trigger(unsigned int minor, unsigned int subdev, struct comedi_trig *it); |
| 143 | int __comedi_trigger(unsigned int minor, unsigned int subdev, struct comedi_trig *it); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 144 | int comedi_data_write(unsigned int dev, unsigned int subdev, unsigned int chan, |
Bill Pemberton | 790c554 | 2009-03-16 22:05:02 -0400 | [diff] [blame] | 145 | unsigned int range, unsigned int aref, unsigned int data); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 146 | int comedi_data_read(unsigned int dev, unsigned int subdev, unsigned int chan, |
Bill Pemberton | 790c554 | 2009-03-16 22:05:02 -0400 | [diff] [blame] | 147 | unsigned int range, unsigned int aref, unsigned int *data); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 148 | int comedi_dio_config(unsigned int dev, unsigned int subdev, unsigned int chan, |
| 149 | unsigned int io); |
| 150 | int comedi_dio_read(unsigned int dev, unsigned int subdev, unsigned int chan, |
| 151 | unsigned int *val); |
| 152 | int comedi_dio_write(unsigned int dev, unsigned int subdev, unsigned int chan, |
| 153 | unsigned int val); |
| 154 | int comedi_dio_bitfield(unsigned int dev, unsigned int subdev, |
| 155 | unsigned int mask, unsigned int *bits); |
| 156 | int comedi_get_n_subdevices(unsigned int dev); |
| 157 | int comedi_get_version_code(unsigned int dev); |
| 158 | char *comedi_get_driver_name(unsigned int dev); |
| 159 | char *comedi_get_board_name(unsigned int minor); |
| 160 | int comedi_get_subdevice_type(unsigned int minor, unsigned int subdevice); |
| 161 | int comedi_find_subdevice_by_type(unsigned int minor, int type, |
| 162 | unsigned int subd); |
| 163 | int comedi_get_n_channels(unsigned int minor, unsigned int subdevice); |
Bill Pemberton | 790c554 | 2009-03-16 22:05:02 -0400 | [diff] [blame] | 164 | unsigned int comedi_get_maxdata(unsigned int minor, unsigned int subdevice, unsigned |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 165 | int chan); |
| 166 | int comedi_get_n_ranges(unsigned int minor, unsigned int subdevice, unsigned int |
| 167 | chan); |
Bill Pemberton | 90035c0 | 2009-03-16 22:05:53 -0400 | [diff] [blame] | 168 | int comedi_do_insn(unsigned int minor, struct comedi_insn *insn); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 169 | int comedi_poll(unsigned int minor, unsigned int subdev); |
| 170 | |
| 171 | /* DEPRECATED functions */ |
| 172 | int comedi_get_rangetype(unsigned int minor, unsigned int subdevice, |
| 173 | unsigned int chan); |
| 174 | |
| 175 | /* ALPHA functions */ |
| 176 | unsigned int comedi_get_subdevice_flags(unsigned int minor, unsigned int |
| 177 | subdevice); |
| 178 | int comedi_get_len_chanlist(unsigned int minor, unsigned int subdevice); |
| 179 | int comedi_get_krange(unsigned int minor, unsigned int subdevice, unsigned int |
Bill Pemberton | 1f6325d | 2009-03-16 22:06:31 -0400 | [diff] [blame] | 180 | chan, unsigned int range, struct comedi_krange *krange); |
David Schleef | ed9eccb | 2008-11-04 20:29:31 -0800 | [diff] [blame] | 181 | unsigned int comedi_get_buf_head_pos(unsigned int minor, unsigned int |
| 182 | subdevice); |
| 183 | int comedi_set_user_int_count(unsigned int minor, unsigned int subdevice, |
| 184 | unsigned int buf_user_count); |
| 185 | int comedi_map(unsigned int minor, unsigned int subdev, void **ptr); |
| 186 | int comedi_unmap(unsigned int minor, unsigned int subdev); |
| 187 | |
| 188 | #endif |
| 189 | |
| 190 | #endif |