2008-11-05 04:29:31 +00:00
|
|
|
/*
|
|
|
|
include/linux/comedidev.h
|
|
|
|
header file for kernel-only structures, variables, and constants
|
|
|
|
|
|
|
|
COMEDI - Linux Control and Measurement Device Interface
|
|
|
|
Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _COMEDIDEV_H
|
|
|
|
#define _COMEDIDEV_H
|
|
|
|
|
|
|
|
#include <linux/dma-mapping.h>
|
2013-11-08 15:03:23 +00:00
|
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/spinlock_types.h>
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
#include "comedi.h"
|
|
|
|
|
2008-11-14 00:36:22 +00:00
|
|
|
#define DPRINTK(format, args...) do { \
|
|
|
|
if (comedi_debug) \
|
2012-08-16 13:38:05 +00:00
|
|
|
pr_debug("comedi: " format, ## args); \
|
2008-11-14 00:36:22 +00:00
|
|
|
} while (0)
|
2008-11-05 04:29:31 +00:00
|
|
|
|
2008-11-14 00:36:22 +00:00
|
|
|
#define COMEDI_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
|
2009-09-22 23:13:04 +00:00
|
|
|
#define COMEDI_VERSION_CODE COMEDI_VERSION(COMEDI_MAJORVERSION, \
|
|
|
|
COMEDI_MINORVERSION, COMEDI_MICROVERSION)
|
2008-11-05 04:29:31 +00:00
|
|
|
#define COMEDI_RELEASE VERSION
|
|
|
|
|
|
|
|
#define COMEDI_NUM_BOARD_MINORS 0x30
|
|
|
|
|
2009-03-17 02:05:14 +00:00
|
|
|
struct comedi_subdevice {
|
2009-03-17 02:05:08 +00:00
|
|
|
struct comedi_device *device;
|
2012-12-20 00:27:02 +00:00
|
|
|
int index;
|
2008-11-05 04:29:31 +00:00
|
|
|
int type;
|
|
|
|
int n_chan;
|
2010-04-30 22:26:54 +00:00
|
|
|
int subdev_flags;
|
2008-11-05 04:29:31 +00:00
|
|
|
int len_chanlist; /* maximum length of channel/gain list */
|
|
|
|
|
|
|
|
void *private;
|
|
|
|
|
2009-03-17 02:05:20 +00:00
|
|
|
struct comedi_async *async;
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
void *lock;
|
|
|
|
void *busy;
|
|
|
|
unsigned runflags;
|
|
|
|
spinlock_t spin_lock;
|
|
|
|
|
2012-06-18 21:45:42 +00:00
|
|
|
unsigned int io_bits;
|
2008-11-05 04:29:31 +00:00
|
|
|
|
2009-03-17 02:05:02 +00:00
|
|
|
unsigned int maxdata; /* if maxdata==0, use list */
|
|
|
|
const unsigned int *maxdata_list; /* list is channel specific */
|
2008-11-05 04:29:31 +00:00
|
|
|
|
2009-03-17 02:05:31 +00:00
|
|
|
const struct comedi_lrange *range_table;
|
|
|
|
const struct comedi_lrange *const *range_table_list;
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
unsigned int *chanlist; /* driver-owned chanlist (not used) */
|
|
|
|
|
2009-06-08 15:34:41 +00:00
|
|
|
int (*insn_read) (struct comedi_device *, struct comedi_subdevice *,
|
|
|
|
struct comedi_insn *, unsigned int *);
|
|
|
|
int (*insn_write) (struct comedi_device *, struct comedi_subdevice *,
|
|
|
|
struct comedi_insn *, unsigned int *);
|
|
|
|
int (*insn_bits) (struct comedi_device *, struct comedi_subdevice *,
|
|
|
|
struct comedi_insn *, unsigned int *);
|
|
|
|
int (*insn_config) (struct comedi_device *, struct comedi_subdevice *,
|
|
|
|
struct comedi_insn *, unsigned int *);
|
2008-11-05 04:29:31 +00:00
|
|
|
|
2009-03-17 02:05:14 +00:00
|
|
|
int (*do_cmd) (struct comedi_device *, struct comedi_subdevice *);
|
2009-06-08 15:34:41 +00:00
|
|
|
int (*do_cmdtest) (struct comedi_device *, struct comedi_subdevice *,
|
|
|
|
struct comedi_cmd *);
|
2009-03-17 02:05:14 +00:00
|
|
|
int (*poll) (struct comedi_device *, struct comedi_subdevice *);
|
|
|
|
int (*cancel) (struct comedi_device *, struct comedi_subdevice *);
|
2009-09-22 23:13:04 +00:00
|
|
|
/* int (*do_lock)(struct comedi_device *, struct comedi_subdevice *); */
|
|
|
|
/* int (*do_unlock)(struct comedi_device *, \
|
|
|
|
struct comedi_subdevice *); */
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
/* called when the buffer changes */
|
2009-09-22 23:13:04 +00:00
|
|
|
int (*buf_change) (struct comedi_device *dev,
|
|
|
|
struct comedi_subdevice *s, unsigned long new_size);
|
2008-11-05 04:29:31 +00:00
|
|
|
|
2009-09-22 23:13:04 +00:00
|
|
|
void (*munge) (struct comedi_device *dev, struct comedi_subdevice *s,
|
2009-06-08 15:34:41 +00:00
|
|
|
void *data, unsigned int num_bytes,
|
|
|
|
unsigned int start_chan_index);
|
2008-11-05 04:29:31 +00:00
|
|
|
enum dma_data_direction async_dma_dir;
|
|
|
|
|
|
|
|
unsigned int state;
|
|
|
|
|
2009-03-17 02:05:36 +00:00
|
|
|
struct device *class_dev;
|
2008-11-05 04:29:31 +00:00
|
|
|
int minor;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct comedi_buf_page {
|
|
|
|
void *virt_addr;
|
|
|
|
dma_addr_t dma_addr;
|
|
|
|
};
|
|
|
|
|
2009-03-17 02:05:20 +00:00
|
|
|
struct comedi_async {
|
2009-03-17 02:05:14 +00:00
|
|
|
struct comedi_subdevice *subdevice;
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
void *prealloc_buf; /* pre-allocated buffer */
|
|
|
|
unsigned int prealloc_bufsz; /* buffer size, in bytes */
|
2009-09-22 23:13:04 +00:00
|
|
|
/* virtual and dma address of each page */
|
|
|
|
struct comedi_buf_page *buf_page_list;
|
2008-11-05 04:29:31 +00:00
|
|
|
unsigned n_buf_pages; /* num elements in buf_page_list */
|
|
|
|
|
|
|
|
unsigned int max_bufsize; /* maximum buffer size, bytes */
|
2009-09-22 23:13:04 +00:00
|
|
|
/* current number of mmaps of prealloc_buf */
|
|
|
|
unsigned int mmap_count;
|
|
|
|
|
|
|
|
/* byte count for writer (write completed) */
|
|
|
|
unsigned int buf_write_count;
|
|
|
|
/* byte count for writer (allocated for writing) */
|
|
|
|
unsigned int buf_write_alloc_count;
|
|
|
|
/* byte count for reader (read completed) */
|
|
|
|
unsigned int buf_read_count;
|
|
|
|
/* byte count for reader (allocated for reading) */
|
|
|
|
unsigned int buf_read_alloc_count;
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
unsigned int buf_write_ptr; /* buffer marker for writer */
|
|
|
|
unsigned int buf_read_ptr; /* buffer marker for reader */
|
|
|
|
|
|
|
|
unsigned int cur_chan; /* useless channel marker for interrupt */
|
|
|
|
/* number of bytes that have been received for current scan */
|
|
|
|
unsigned int scan_progress;
|
|
|
|
/* keeps track of where we are in chanlist as for munging */
|
|
|
|
unsigned int munge_chan;
|
|
|
|
/* number of bytes that have been munged */
|
|
|
|
unsigned int munge_count;
|
|
|
|
/* buffer marker for munging */
|
|
|
|
unsigned int munge_ptr;
|
|
|
|
|
|
|
|
unsigned int events; /* events that have occurred */
|
|
|
|
|
2009-03-17 02:05:47 +00:00
|
|
|
struct comedi_cmd cmd;
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
wait_queue_head_t wait_head;
|
|
|
|
|
|
|
|
unsigned int cb_mask;
|
|
|
|
|
2009-09-22 23:13:04 +00:00
|
|
|
int (*inttrig) (struct comedi_device *dev, struct comedi_subdevice *s,
|
2008-11-14 00:36:22 +00:00
|
|
|
unsigned int x);
|
2008-11-05 04:29:31 +00:00
|
|
|
};
|
|
|
|
|
2009-03-17 02:05:25 +00:00
|
|
|
struct comedi_driver {
|
|
|
|
struct comedi_driver *next;
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
const char *driver_name;
|
|
|
|
struct module *module;
|
2009-03-17 02:06:20 +00:00
|
|
|
int (*attach) (struct comedi_device *, struct comedi_devconfig *);
|
2012-05-18 00:11:14 +00:00
|
|
|
void (*detach) (struct comedi_device *);
|
2012-10-27 20:44:14 +00:00
|
|
|
int (*auto_attach) (struct comedi_device *, unsigned long);
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
/* number of elements in board_name and board_id arrays */
|
|
|
|
unsigned int num_names;
|
|
|
|
const char *const *board_name;
|
|
|
|
/* offset in bytes from one board name pointer to the next */
|
|
|
|
int offset;
|
|
|
|
};
|
|
|
|
|
2009-03-17 02:05:08 +00:00
|
|
|
struct comedi_device {
|
2008-11-05 04:29:31 +00:00
|
|
|
int use_count;
|
2009-03-17 02:05:25 +00:00
|
|
|
struct comedi_driver *driver;
|
2008-11-05 04:29:31 +00:00
|
|
|
void *private;
|
|
|
|
|
2009-03-17 02:05:36 +00:00
|
|
|
struct device *class_dev;
|
2008-11-05 04:29:31 +00:00
|
|
|
int minor;
|
2008-11-14 00:36:22 +00:00
|
|
|
/* hw_dev is passed to dma_alloc_coherent when allocating async buffers
|
|
|
|
* for subdevices that have async_dma_dir set to something other than
|
|
|
|
* DMA_NONE */
|
2008-11-05 04:29:31 +00:00
|
|
|
struct device *hw_dev;
|
|
|
|
|
|
|
|
const char *board_name;
|
|
|
|
const void *board_ptr;
|
2013-03-15 13:15:33 +00:00
|
|
|
bool attached:1;
|
2013-03-15 13:15:34 +00:00
|
|
|
bool in_request_module:1;
|
2013-03-15 13:15:35 +00:00
|
|
|
bool ioenabled:1;
|
2008-11-05 04:29:31 +00:00
|
|
|
spinlock_t spinlock;
|
|
|
|
struct mutex mutex;
|
|
|
|
|
|
|
|
int n_subdevices;
|
2009-03-17 02:05:14 +00:00
|
|
|
struct comedi_subdevice *subdevices;
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
/* dumb */
|
|
|
|
unsigned long iobase;
|
2013-04-18 21:31:29 +00:00
|
|
|
unsigned long iolen;
|
2008-11-05 04:29:31 +00:00
|
|
|
unsigned int irq;
|
|
|
|
|
2009-03-17 02:05:14 +00:00
|
|
|
struct comedi_subdevice *read_subdev;
|
|
|
|
struct comedi_subdevice *write_subdev;
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
struct fasync_struct *async_queue;
|
|
|
|
|
2010-05-19 13:10:00 +00:00
|
|
|
int (*open) (struct comedi_device *dev);
|
2009-09-22 23:13:04 +00:00
|
|
|
void (*close) (struct comedi_device *dev);
|
2008-11-05 04:29:31 +00:00
|
|
|
};
|
|
|
|
|
2012-11-02 19:18:00 +00:00
|
|
|
static inline const void *comedi_board(const struct comedi_device *dev)
|
2012-04-27 21:10:15 +00:00
|
|
|
{
|
|
|
|
return dev->board_ptr;
|
|
|
|
}
|
|
|
|
|
2008-11-05 04:29:31 +00:00
|
|
|
#ifdef CONFIG_COMEDI_DEBUG
|
|
|
|
extern int comedi_debug;
|
|
|
|
#else
|
2008-11-14 00:36:22 +00:00
|
|
|
static const int comedi_debug;
|
2008-11-05 04:29:31 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* function prototypes
|
|
|
|
*/
|
|
|
|
|
2009-03-17 02:05:14 +00:00
|
|
|
void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s);
|
2009-03-17 02:05:08 +00:00
|
|
|
void comedi_error(const struct comedi_device *dev, const char *s);
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
/* we can expand the number of bits used to encode devices/subdevices into
|
|
|
|
the minor number soon, after more distros support > 8 bit minor numbers
|
|
|
|
(like after Debian Etch gets released) */
|
|
|
|
enum comedi_minor_bits {
|
|
|
|
COMEDI_DEVICE_MINOR_MASK = 0xf,
|
|
|
|
COMEDI_SUBDEVICE_MINOR_MASK = 0xf0
|
|
|
|
};
|
|
|
|
static const unsigned COMEDI_SUBDEVICE_MINOR_SHIFT = 4;
|
|
|
|
static const unsigned COMEDI_SUBDEVICE_MINOR_OFFSET = 1;
|
|
|
|
|
2012-12-19 22:34:40 +00:00
|
|
|
struct comedi_device *comedi_dev_from_minor(unsigned minor);
|
|
|
|
|
2008-11-05 04:29:31 +00:00
|
|
|
void init_polling(void);
|
|
|
|
void cleanup_polling(void);
|
2009-03-17 02:05:08 +00:00
|
|
|
void start_polling(struct comedi_device *);
|
|
|
|
void stop_polling(struct comedi_device *);
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
/* subdevice runflags */
|
|
|
|
enum subdevice_runflags {
|
|
|
|
SRF_RT = 0x00000002,
|
2008-11-14 00:36:22 +00:00
|
|
|
/* indicates an COMEDI_CB_ERROR event has occurred since the last
|
|
|
|
* command was started */
|
2008-11-05 04:29:31 +00:00
|
|
|
SRF_ERROR = 0x00000004,
|
2013-06-11 18:32:29 +00:00
|
|
|
SRF_RUNNING = 0x08000000,
|
|
|
|
SRF_FREE_SPRIV = 0x80000000, /* free s->private on detach */
|
2008-11-05 04:29:31 +00:00
|
|
|
};
|
|
|
|
|
2012-12-19 22:42:47 +00:00
|
|
|
bool comedi_is_subdevice_running(struct comedi_subdevice *s);
|
2013-06-19 22:24:36 +00:00
|
|
|
|
|
|
|
void *comedi_alloc_spriv(struct comedi_subdevice *s, size_t size);
|
2012-12-19 22:42:47 +00:00
|
|
|
|
2010-05-06 09:49:37 +00:00
|
|
|
int comedi_check_chanlist(struct comedi_subdevice *s,
|
|
|
|
int n,
|
|
|
|
unsigned int *chanlist);
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
/* range stuff */
|
|
|
|
|
2008-11-14 00:36:22 +00:00
|
|
|
#define RANGE(a, b) {(a)*1e6, (b)*1e6, 0}
|
|
|
|
#define RANGE_ext(a, b) {(a)*1e6, (b)*1e6, RF_EXTERNAL}
|
|
|
|
#define RANGE_mA(a, b) {(a)*1e6, (b)*1e6, UNIT_mA}
|
2010-04-30 22:26:54 +00:00
|
|
|
#define RANGE_unitless(a, b) {(a)*1e6, (b)*1e6, 0}
|
2008-11-14 00:36:22 +00:00
|
|
|
#define BIP_RANGE(a) {-(a)*1e6, (a)*1e6, 0}
|
|
|
|
#define UNI_RANGE(a) {0, (a)*1e6, 0}
|
2008-11-05 04:29:31 +00:00
|
|
|
|
2009-03-17 02:05:31 +00:00
|
|
|
extern const struct comedi_lrange range_bipolar10;
|
|
|
|
extern const struct comedi_lrange range_bipolar5;
|
|
|
|
extern const struct comedi_lrange range_bipolar2_5;
|
|
|
|
extern const struct comedi_lrange range_unipolar10;
|
|
|
|
extern const struct comedi_lrange range_unipolar5;
|
2013-04-03 20:38:26 +00:00
|
|
|
extern const struct comedi_lrange range_unipolar2_5;
|
2013-04-03 20:40:13 +00:00
|
|
|
extern const struct comedi_lrange range_0_20mA;
|
|
|
|
extern const struct comedi_lrange range_4_20mA;
|
|
|
|
extern const struct comedi_lrange range_0_32mA;
|
2009-03-17 02:05:31 +00:00
|
|
|
extern const struct comedi_lrange range_unknown;
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
#define range_digital range_unipolar5
|
|
|
|
|
|
|
|
#if __GNUC__ >= 3
|
|
|
|
#define GCC_ZERO_LENGTH_ARRAY
|
|
|
|
#else
|
|
|
|
#define GCC_ZERO_LENGTH_ARRAY 0
|
|
|
|
#endif
|
|
|
|
|
2009-03-17 02:05:31 +00:00
|
|
|
struct comedi_lrange {
|
2008-11-05 04:29:31 +00:00
|
|
|
int length;
|
2009-03-17 02:06:31 +00:00
|
|
|
struct comedi_krange range[GCC_ZERO_LENGTH_ARRAY];
|
2008-11-05 04:29:31 +00:00
|
|
|
};
|
|
|
|
|
2013-06-05 22:52:31 +00:00
|
|
|
static inline bool comedi_range_is_bipolar(struct comedi_subdevice *s,
|
|
|
|
unsigned int range)
|
|
|
|
{
|
|
|
|
return s->range_table->range[range].min < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool comedi_range_is_unipolar(struct comedi_subdevice *s,
|
|
|
|
unsigned int range)
|
|
|
|
{
|
|
|
|
return s->range_table->range[range].min >= 0;
|
|
|
|
}
|
|
|
|
|
2013-09-25 22:35:06 +00:00
|
|
|
static inline bool comedi_chan_range_is_bipolar(struct comedi_subdevice *s,
|
|
|
|
unsigned int chan,
|
|
|
|
unsigned int range)
|
|
|
|
{
|
|
|
|
return s->range_table_list[chan]->range[range].min < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool comedi_chan_range_is_unipolar(struct comedi_subdevice *s,
|
|
|
|
unsigned int chan,
|
|
|
|
unsigned int range)
|
|
|
|
{
|
|
|
|
return s->range_table_list[chan]->range[range].min >= 0;
|
|
|
|
}
|
|
|
|
|
2013-09-18 18:49:33 +00:00
|
|
|
/* munge between offset binary and two's complement values */
|
|
|
|
static inline unsigned int comedi_offset_munge(struct comedi_subdevice *s,
|
|
|
|
unsigned int val)
|
|
|
|
{
|
|
|
|
return val ^ s->maxdata ^ (s->maxdata >> 1);
|
|
|
|
}
|
2008-11-05 04:29:31 +00:00
|
|
|
|
2009-03-17 02:05:14 +00:00
|
|
|
static inline unsigned int bytes_per_sample(const struct comedi_subdevice *subd)
|
2008-11-05 04:29:31 +00:00
|
|
|
{
|
|
|
|
if (subd->subdev_flags & SDF_LSAMPL)
|
2009-03-17 02:05:02 +00:00
|
|
|
return sizeof(unsigned int);
|
2008-11-05 04:29:31 +00:00
|
|
|
else
|
2009-03-17 02:05:02 +00:00
|
|
|
return sizeof(short);
|
2008-11-05 04:29:31 +00:00
|
|
|
}
|
|
|
|
|
2013-01-29 16:20:17 +00:00
|
|
|
/*
|
|
|
|
* Must set dev->hw_dev if you wish to dma directly into comedi's buffer.
|
|
|
|
* Also useful for retrieving a previously configured hardware device of
|
|
|
|
* known bus type. Set automatically for auto-configured devices.
|
|
|
|
* Automatically set to NULL when detaching hardware device.
|
|
|
|
*/
|
2013-02-01 13:23:19 +00:00
|
|
|
int comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev);
|
2008-11-05 04:29:31 +00:00
|
|
|
|
2013-01-09 20:32:56 +00:00
|
|
|
unsigned int comedi_buf_write_alloc(struct comedi_async *, unsigned int);
|
|
|
|
unsigned int comedi_buf_write_free(struct comedi_async *, unsigned int);
|
|
|
|
|
|
|
|
unsigned int comedi_buf_read_n_available(struct comedi_async *);
|
|
|
|
unsigned int comedi_buf_read_alloc(struct comedi_async *, unsigned int);
|
|
|
|
unsigned int comedi_buf_read_free(struct comedi_async *, unsigned int);
|
|
|
|
|
2013-10-16 13:40:04 +00:00
|
|
|
int comedi_buf_put(struct comedi_async *, unsigned short);
|
|
|
|
int comedi_buf_get(struct comedi_async *, unsigned short *);
|
2013-01-09 20:32:56 +00:00
|
|
|
|
2009-03-17 02:05:20 +00:00
|
|
|
void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
|
2009-06-08 15:34:41 +00:00
|
|
|
const void *source, unsigned int num_bytes);
|
2009-03-17 02:05:20 +00:00
|
|
|
void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset,
|
2009-06-08 15:34:41 +00:00
|
|
|
void *destination, unsigned int num_bytes);
|
|
|
|
|
2013-01-30 22:24:38 +00:00
|
|
|
/* drivers.c - general comedi driver functions */
|
|
|
|
|
2013-08-06 16:31:35 +00:00
|
|
|
int comedi_dio_insn_config(struct comedi_device *, struct comedi_subdevice *,
|
|
|
|
struct comedi_insn *, unsigned int *data,
|
|
|
|
unsigned int mask);
|
2013-08-30 18:04:56 +00:00
|
|
|
unsigned int comedi_dio_update_state(struct comedi_subdevice *,
|
|
|
|
unsigned int *data);
|
2013-08-06 16:31:35 +00:00
|
|
|
|
2013-06-24 23:55:14 +00:00
|
|
|
void *comedi_alloc_devpriv(struct comedi_device *, size_t);
|
2013-01-30 22:24:38 +00:00
|
|
|
int comedi_alloc_subdevices(struct comedi_device *, int);
|
|
|
|
|
2013-05-17 18:17:00 +00:00
|
|
|
int comedi_load_firmware(struct comedi_device *, struct device *,
|
|
|
|
const char *name,
|
|
|
|
int (*cb)(struct comedi_device *,
|
2013-05-17 18:18:01 +00:00
|
|
|
const u8 *data, size_t size,
|
|
|
|
unsigned long context),
|
|
|
|
unsigned long context);
|
2013-05-17 18:17:00 +00:00
|
|
|
|
2013-04-09 23:30:11 +00:00
|
|
|
int __comedi_request_region(struct comedi_device *,
|
|
|
|
unsigned long start, unsigned long len);
|
2013-04-09 23:05:54 +00:00
|
|
|
int comedi_request_region(struct comedi_device *,
|
|
|
|
unsigned long start, unsigned long len);
|
2013-04-18 21:31:29 +00:00
|
|
|
void comedi_legacy_detach(struct comedi_device *);
|
2013-04-09 23:05:54 +00:00
|
|
|
|
2013-01-30 22:24:38 +00:00
|
|
|
int comedi_auto_config(struct device *, struct comedi_driver *,
|
|
|
|
unsigned long context);
|
|
|
|
void comedi_auto_unconfig(struct device *);
|
|
|
|
|
|
|
|
int comedi_driver_register(struct comedi_driver *);
|
2013-06-27 13:50:57 +00:00
|
|
|
void comedi_driver_unregister(struct comedi_driver *);
|
2013-01-30 22:24:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* module_comedi_driver() - Helper macro for registering a comedi driver
|
|
|
|
* @__comedi_driver: comedi_driver struct
|
|
|
|
*
|
|
|
|
* Helper macro for comedi drivers which do not do anything special in module
|
|
|
|
* init/exit. This eliminates a lot of boilerplate. Each module may only use
|
|
|
|
* this macro once, and calling it replaces module_init() and module_exit().
|
|
|
|
*/
|
|
|
|
#define module_comedi_driver(__comedi_driver) \
|
|
|
|
module_driver(__comedi_driver, comedi_driver_register, \
|
|
|
|
comedi_driver_unregister)
|
2012-11-14 13:10:40 +00:00
|
|
|
|
2013-01-30 22:22:21 +00:00
|
|
|
#ifdef CONFIG_COMEDI_PCI_DRIVERS
|
|
|
|
|
|
|
|
/* comedi_pci.c - comedi PCI driver specific functions */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PCI Vendor IDs not in <linux/pci_ids.h>
|
|
|
|
*/
|
|
|
|
#define PCI_VENDOR_ID_KOLTER 0x1001
|
|
|
|
#define PCI_VENDOR_ID_ICP 0x104c
|
|
|
|
#define PCI_VENDOR_ID_DT 0x1116
|
|
|
|
#define PCI_VENDOR_ID_IOTECH 0x1616
|
|
|
|
#define PCI_VENDOR_ID_CONTEC 0x1221
|
|
|
|
#define PCI_VENDOR_ID_RTD 0x1435
|
|
|
|
|
|
|
|
struct pci_dev;
|
|
|
|
struct pci_driver;
|
|
|
|
|
|
|
|
struct pci_dev *comedi_to_pci_dev(struct comedi_device *);
|
|
|
|
|
2013-03-13 17:36:31 +00:00
|
|
|
int comedi_pci_enable(struct comedi_device *);
|
2013-03-13 17:35:51 +00:00
|
|
|
void comedi_pci_disable(struct comedi_device *);
|
2013-01-30 22:22:21 +00:00
|
|
|
|
2013-03-05 16:53:41 +00:00
|
|
|
int comedi_pci_auto_config(struct pci_dev *, struct comedi_driver *,
|
|
|
|
unsigned long context);
|
2013-01-30 22:22:21 +00:00
|
|
|
void comedi_pci_auto_unconfig(struct pci_dev *);
|
|
|
|
|
|
|
|
int comedi_pci_driver_register(struct comedi_driver *, struct pci_driver *);
|
|
|
|
void comedi_pci_driver_unregister(struct comedi_driver *, struct pci_driver *);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* module_comedi_pci_driver() - Helper macro for registering a comedi PCI driver
|
|
|
|
* @__comedi_driver: comedi_driver struct
|
|
|
|
* @__pci_driver: pci_driver struct
|
|
|
|
*
|
|
|
|
* Helper macro for comedi PCI drivers which do not do anything special
|
|
|
|
* in module init/exit. This eliminates a lot of boilerplate. Each
|
|
|
|
* module may only use this macro once, and calling it replaces
|
|
|
|
* module_init() and module_exit()
|
|
|
|
*/
|
|
|
|
#define module_comedi_pci_driver(__comedi_driver, __pci_driver) \
|
|
|
|
module_driver(__comedi_driver, comedi_pci_driver_register, \
|
|
|
|
comedi_pci_driver_unregister, &(__pci_driver))
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some of the comedi mixed ISA/PCI drivers call the PCI specific
|
|
|
|
* functions. Provide some dummy functions if CONFIG_COMEDI_PCI_DRIVERS
|
|
|
|
* is not enabled.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline struct pci_dev *comedi_to_pci_dev(struct comedi_device *dev)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-03-13 17:36:31 +00:00
|
|
|
static inline int comedi_pci_enable(struct comedi_device *dev)
|
2013-01-30 22:22:21 +00:00
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
2013-03-13 17:35:51 +00:00
|
|
|
static inline void comedi_pci_disable(struct comedi_device *dev)
|
2012-11-14 13:10:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-30 22:22:21 +00:00
|
|
|
#endif /* CONFIG_COMEDI_PCI_DRIVERS */
|
2012-11-14 13:10:40 +00:00
|
|
|
|
2013-01-30 22:22:44 +00:00
|
|
|
#ifdef CONFIG_COMEDI_PCMCIA_DRIVERS
|
|
|
|
|
|
|
|
/* comedi_pcmcia.c - comedi PCMCIA driver specific functions */
|
|
|
|
|
|
|
|
struct pcmcia_driver;
|
2013-01-30 22:23:06 +00:00
|
|
|
struct pcmcia_device;
|
|
|
|
|
|
|
|
struct pcmcia_device *comedi_to_pcmcia_dev(struct comedi_device *);
|
|
|
|
|
2013-02-06 01:16:07 +00:00
|
|
|
int comedi_pcmcia_enable(struct comedi_device *,
|
|
|
|
int (*conf_check)(struct pcmcia_device *, void *));
|
2013-02-04 21:19:35 +00:00
|
|
|
void comedi_pcmcia_disable(struct comedi_device *);
|
|
|
|
|
2013-01-30 22:23:06 +00:00
|
|
|
int comedi_pcmcia_auto_config(struct pcmcia_device *, struct comedi_driver *);
|
|
|
|
void comedi_pcmcia_auto_unconfig(struct pcmcia_device *);
|
2013-01-30 22:22:44 +00:00
|
|
|
|
|
|
|
int comedi_pcmcia_driver_register(struct comedi_driver *,
|
|
|
|
struct pcmcia_driver *);
|
|
|
|
void comedi_pcmcia_driver_unregister(struct comedi_driver *,
|
|
|
|
struct pcmcia_driver *);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* module_comedi_pcmcia_driver() - Helper macro for registering a comedi PCMCIA driver
|
|
|
|
* @__comedi_driver: comedi_driver struct
|
|
|
|
* @__pcmcia_driver: pcmcia_driver struct
|
|
|
|
*
|
|
|
|
* Helper macro for comedi PCMCIA drivers which do not do anything special
|
|
|
|
* in module init/exit. This eliminates a lot of boilerplate. Each
|
|
|
|
* module may only use this macro once, and calling it replaces
|
|
|
|
* module_init() and module_exit()
|
|
|
|
*/
|
|
|
|
#define module_comedi_pcmcia_driver(__comedi_driver, __pcmcia_driver) \
|
|
|
|
module_driver(__comedi_driver, comedi_pcmcia_driver_register, \
|
|
|
|
comedi_pcmcia_driver_unregister, &(__pcmcia_driver))
|
|
|
|
|
|
|
|
#endif /* CONFIG_COMEDI_PCMCIA_DRIVERS */
|
|
|
|
|
2013-01-30 22:21:49 +00:00
|
|
|
#ifdef CONFIG_COMEDI_USB_DRIVERS
|
2012-11-14 13:10:40 +00:00
|
|
|
|
2013-01-30 22:21:49 +00:00
|
|
|
/* comedi_usb.c - comedi USB driver specific functions */
|
|
|
|
|
|
|
|
struct usb_driver;
|
|
|
|
struct usb_interface;
|
|
|
|
|
|
|
|
struct usb_interface *comedi_to_usb_interface(struct comedi_device *);
|
2013-05-20 21:20:02 +00:00
|
|
|
struct usb_device *comedi_to_usb_dev(struct comedi_device *);
|
2013-01-30 22:21:49 +00:00
|
|
|
|
2013-02-06 00:23:40 +00:00
|
|
|
int comedi_usb_auto_config(struct usb_interface *, struct comedi_driver *,
|
|
|
|
unsigned long context);
|
2013-01-30 22:21:49 +00:00
|
|
|
void comedi_usb_auto_unconfig(struct usb_interface *);
|
|
|
|
|
|
|
|
int comedi_usb_driver_register(struct comedi_driver *, struct usb_driver *);
|
|
|
|
void comedi_usb_driver_unregister(struct comedi_driver *, struct usb_driver *);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* module_comedi_usb_driver() - Helper macro for registering a comedi USB driver
|
|
|
|
* @__comedi_driver: comedi_driver struct
|
|
|
|
* @__usb_driver: usb_driver struct
|
|
|
|
*
|
|
|
|
* Helper macro for comedi USB drivers which do not do anything special
|
|
|
|
* in module init/exit. This eliminates a lot of boilerplate. Each
|
|
|
|
* module may only use this macro once, and calling it replaces
|
|
|
|
* module_init() and module_exit()
|
|
|
|
*/
|
|
|
|
#define module_comedi_usb_driver(__comedi_driver, __usb_driver) \
|
|
|
|
module_driver(__comedi_driver, comedi_usb_driver_register, \
|
|
|
|
comedi_usb_driver_unregister, &(__usb_driver))
|
|
|
|
|
|
|
|
#endif /* CONFIG_COMEDI_USB_DRIVERS */
|
2008-11-05 04:29:31 +00:00
|
|
|
|
|
|
|
#endif /* _COMEDIDEV_H */
|