linux/drivers/comedi/drivers/usbduxsigma.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * usbduxsigma.c
 * Copyright (C) 2011-2015 Bernd Porr, [email protected]
 */

/*
 * Driver: usbduxsigma
 * Description: University of Stirling USB DAQ & INCITE Technology Limited
 * Devices: [ITL] USB-DUX-SIGMA (usbduxsigma)
 * Author: Bernd Porr <[email protected]>
 * Updated: 20 July 2015
 * Status: stable
 */

/*
 * I must give credit here to Chris Baugher who
 * wrote the driver for AT-MIO-16d. I used some parts of this
 * driver. I also must give credits to David Brownell
 * who supported me with the USB development.
 *
 * Note: the raw data from the A/D converter is 24 bit big endian
 * anything else is little endian to/from the dux board
 *
 *
 * Revision history:
 *   0.1: initial version
 *   0.2: all basic functions implemented, digital I/O only for one port
 *   0.3: proper vendor ID and driver name
 *   0.4: fixed D/A voltage range
 *   0.5: various bug fixes, health check at startup
 *   0.6: corrected wrong input range
 *   0.7: rewrite code that urb->interval is always 1
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/input.h>
#include <linux/fcntl.h>
#include <linux/compiler.h>
#include <linux/unaligned.h>
#include <linux/comedi/comedi_usb.h>

/* timeout for the USB-transfer in ms*/
#define BULK_TIMEOUT

/* constants for "firmware" upload and download */
#define FIRMWARE
#define FIRMWARE_MAX_LEN
#define USBDUXSUB_FIRMWARE
#define VENDOR_DIR_IN
#define VENDOR_DIR_OUT

/* internal addresses of the 8051 processor */
#define USBDUXSUB_CPUCS

/* 300Hz max frequ under PWM */
#define MIN_PWM_PERIOD

/* Default PWM frequency */
#define PWM_DEFAULT_PERIOD

/* Number of channels (16 AD and offset)*/
#define NUMCHANNELS

/* Size of one A/D value */
#define SIZEADIN

/*
 * Size of the async input-buffer IN BYTES, the DIO state is transmitted
 * as the first byte.
 */
#define SIZEINBUF

/* 16 bytes. */
#define SIZEINSNBUF

/* Number of DA channels */
#define NUMOUTCHANNELS

/* size of one value for the D/A converter: channel and value */
#define SIZEDAOUT

/*
 * Size of the output-buffer in bytes
 * Actually only the first 4 triplets are used but for the
 * high speed mode we need to pad it to 8 (microframes).
 */
#define SIZEOUTBUF

/*
 * Size of the buffer for the dux commands: just now max size is determined
 * by the analogue out + command byte + panic bytes...
 */
#define SIZEOFDUXBUFFER

/* Number of in-URBs which receive the data: min=2 */
#define NUMOFINBUFFERSFULL

/* Number of out-URBs which send the data: min=2 */
#define NUMOFOUTBUFFERSFULL

/* Number of in-URBs which receive the data: min=5 */
/* must have more buffers due to buggy USB ctr */
#define NUMOFINBUFFERSHIGH

/* Number of out-URBs which send the data: min=5 */
/* must have more buffers due to buggy USB ctr */
#define NUMOFOUTBUFFERSHIGH

/* number of retries to get the right dux command */
#define RETRIES

/* bulk transfer commands to usbduxsigma */
#define USBBUXSIGMA_AD_CMD
#define USBDUXSIGMA_DA_CMD
#define USBDUXSIGMA_DIO_CFG_CMD
#define USBDUXSIGMA_DIO_BITS_CMD
#define USBDUXSIGMA_SINGLE_AD_CMD
#define USBDUXSIGMA_PWM_ON_CMD
#define USBDUXSIGMA_PWM_OFF_CMD

static const struct comedi_lrange usbduxsigma_ai_range =;

struct usbduxsigma_private {};

static void usbduxsigma_unlink_urbs(struct urb **urbs, int num_urbs)
{}

static void usbduxsigma_ai_stop(struct comedi_device *dev, int do_unlink)
{}

static int usbduxsigma_ai_cancel(struct comedi_device *dev,
				 struct comedi_subdevice *s)
{}

static void usbduxsigma_ai_handle_urb(struct comedi_device *dev,
				      struct comedi_subdevice *s,
				      struct urb *urb)
{}

static void usbduxsigma_ai_urb_complete(struct urb *urb)
{}

static void usbduxsigma_ao_stop(struct comedi_device *dev, int do_unlink)
{}

static int usbduxsigma_ao_cancel(struct comedi_device *dev,
				 struct comedi_subdevice *s)
{}

static void usbduxsigma_ao_handle_urb(struct comedi_device *dev,
				      struct comedi_subdevice *s,
				      struct urb *urb)
{}

static void usbduxsigma_ao_urb_complete(struct urb *urb)
{}

static int usbduxsigma_submit_urbs(struct comedi_device *dev,
				   struct urb **urbs, int num_urbs,
				   int input_urb)
{}

static int usbduxsigma_chans_to_interval(int num_chan)
{}

static int usbduxsigma_ai_cmdtest(struct comedi_device *dev,
				  struct comedi_subdevice *s,
				  struct comedi_cmd *cmd)
{}

/*
 * creates the ADC command for the MAX1271
 * range is the range value from comedi
 */
static void create_adc_command(unsigned int chan,
			       u8 *muxsg0, u8 *muxsg1)
{}

static int usbbuxsigma_send_cmd(struct comedi_device *dev, int cmd_type)
{}

static int usbduxsigma_receive_cmd(struct comedi_device *dev, int command)
{}

static int usbduxsigma_ai_inttrig(struct comedi_device *dev,
				  struct comedi_subdevice *s,
				  unsigned int trig_num)
{}

static int usbduxsigma_ai_cmd(struct comedi_device *dev,
			      struct comedi_subdevice *s)
{}

static int usbduxsigma_ai_insn_read(struct comedi_device *dev,
				    struct comedi_subdevice *s,
				    struct comedi_insn *insn,
				    unsigned int *data)
{}

static int usbduxsigma_ao_insn_read(struct comedi_device *dev,
				    struct comedi_subdevice *s,
				    struct comedi_insn *insn,
				    unsigned int *data)
{}

static int usbduxsigma_ao_insn_write(struct comedi_device *dev,
				     struct comedi_subdevice *s,
				     struct comedi_insn *insn,
				     unsigned int *data)
{}

static int usbduxsigma_ao_inttrig(struct comedi_device *dev,
				  struct comedi_subdevice *s,
				  unsigned int trig_num)
{}

static int usbduxsigma_ao_cmdtest(struct comedi_device *dev,
				  struct comedi_subdevice *s,
				  struct comedi_cmd *cmd)
{}

static int usbduxsigma_ao_cmd(struct comedi_device *dev,
			      struct comedi_subdevice *s)
{}

static int usbduxsigma_dio_insn_config(struct comedi_device *dev,
				       struct comedi_subdevice *s,
				       struct comedi_insn *insn,
				       unsigned int *data)
{}

static int usbduxsigma_dio_insn_bits(struct comedi_device *dev,
				     struct comedi_subdevice *s,
				     struct comedi_insn *insn,
				     unsigned int *data)
{}

static void usbduxsigma_pwm_stop(struct comedi_device *dev, int do_unlink)
{}

static int usbduxsigma_pwm_cancel(struct comedi_device *dev,
				  struct comedi_subdevice *s)
{}

static void usbduxsigma_pwm_urb_complete(struct urb *urb)
{}

static int usbduxsigma_submit_pwm_urb(struct comedi_device *dev)
{}

static int usbduxsigma_pwm_period(struct comedi_device *dev,
				  struct comedi_subdevice *s,
				  unsigned int period)
{}

static int usbduxsigma_pwm_start(struct comedi_device *dev,
				 struct comedi_subdevice *s)
{}

static void usbduxsigma_pwm_pattern(struct comedi_device *dev,
				    struct comedi_subdevice *s,
				    unsigned int chan,
				    unsigned int value,
				    unsigned int sign)
{}

static int usbduxsigma_pwm_write(struct comedi_device *dev,
				 struct comedi_subdevice *s,
				 struct comedi_insn *insn,
				 unsigned int *data)
{}

static int usbduxsigma_pwm_config(struct comedi_device *dev,
				  struct comedi_subdevice *s,
				  struct comedi_insn *insn,
				  unsigned int *data)
{}

static int usbduxsigma_getstatusinfo(struct comedi_device *dev, int chan)
{}

static int usbduxsigma_firmware_upload(struct comedi_device *dev,
				       const u8 *data, size_t size,
				       unsigned long context)
{}

static int usbduxsigma_alloc_usb_buffers(struct comedi_device *dev)
{}

static void usbduxsigma_free_usb_buffers(struct comedi_device *dev)
{}

static int usbduxsigma_auto_attach(struct comedi_device *dev,
				   unsigned long context_unused)
{}

static void usbduxsigma_detach(struct comedi_device *dev)
{}

static struct comedi_driver usbduxsigma_driver =;

static int usbduxsigma_usb_probe(struct usb_interface *intf,
				 const struct usb_device_id *id)
{}

static const struct usb_device_id usbduxsigma_usb_table[] =;
MODULE_DEVICE_TABLE(usb, usbduxsigma_usb_table);

static struct usb_driver usbduxsigma_usb_driver =;
module_comedi_usb_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_FIRMWARE();