Skip to content

Commit 58f47ab

Browse files
committed
Initial commit of the current driver
0 parents  commit 58f47ab

12 files changed

+5695
-0
lines changed

README.md

Whitespace-only changes.

distribution/COPYING

+339
Large diffs are not rendered by default.

distribution/Makefile

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
################################################################################
2+
#
3+
# Makefile: Linux driver for USB3 Vision(TM) Devices.
4+
#
5+
# (C) Copyright 2014 National Instruments Corp.
6+
# Authors: Katie Ensign <[email protected]>,
7+
# Jared Jenson <[email protected]>
8+
#
9+
# The "USB3 Vision" name and logo are trademarks of the AIA and may not
10+
# be used without the authorization of the AIA <www.visiononline.org>
11+
#
12+
# Anyone wishing to develop, manufacture, or sell private labeled
13+
# compliant product for commercial purposes or to develop compliant
14+
# software for distribution must obtain a license to use the USB3
15+
# Vision standard and the USB3 Vision name and logo from the AIA.
16+
# All products (including software) must be registered with the AIA and
17+
# must be tested for compliancy with the standard.
18+
#
19+
# This program is free software; you can redistribute it and/or modify
20+
# it under the terms of the GNU General Public License as published by
21+
# the Free Software Foundation; either version 2 of the License, or
22+
# (at your option) any later version.
23+
#
24+
# This program is distributed in the hope that it will be useful,
25+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
26+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+
# GNU General Public License for more details.
28+
#
29+
# You should have received a copy of the GNU General Public License
30+
# along with this program; if not, write to the Free Software
31+
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32+
#
33+
################################################################################
34+
35+
# If KERNELRELEASE is defined, we've been invoked from the
36+
# kernel build system and can use its language. (LDD3, ch 2, pg 24)
37+
ifneq ($(KERNELRELEASE),)
38+
39+
# if version_compatibility is defined, add a cflag to include the right
40+
# header files
41+
ifneq ($(version_compatibility),)
42+
EXTRA_CFLAGS += -DVERSION_COMPATIBILITY
43+
endif
44+
45+
obj-m := u3v.o
46+
u3v-objs := u3v_core.o u3v_control.o u3v_event.o u3v_stream.o
47+
48+
else
49+
50+
PWD := $(shell pwd)
51+
52+
MOD_DIR := kernel/natinst/u3v
53+
MOD_PATH := /lib/modules/$(shell uname -r)/$(MOD_DIR)
54+
55+
all:
56+
@$(MAKE) --no-print-directory -C $(KERNELHEADERS) M=$(PWD) modules
57+
58+
debug: all
59+
EXTRA_CFLAGS += -DDEBUG -g
60+
61+
install: all
62+
@$(MAKE) --no-print-directory -C $(KERNELHEADERS) M=$(PWD) INSTALL_MOD_DIR=$(MOD_DIR) modules_install
63+
64+
uninstall:
65+
@$(RM) -rf $(MOD_PATH)
66+
@/sbin/depmod -a
67+
68+
clean:
69+
@$(MAKE) --no-print-directory -s -C $(KERNELHEADERS) M=$(PWD) clean
70+
@$(RM) -rf Module.*
71+
72+
.PHONY: all install uninstall clean
73+
74+
endif

u3v.h

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/*
2+
* u3v.h: Driver for USB3 Vision(TM) class devices
3+
*
4+
* (C) Copyright 2014 National Instruments Corp.
5+
* Authors: Katie Ensign <[email protected]>,
6+
* Jared Jenson <[email protected]>
7+
*
8+
* The "USB3 Vision" name and logo are trademarks of the AIA and may not
9+
* be used without the authorization of the AIA <www.visiononline.org>
10+
*
11+
* Anyone wishing to develop, manufacture, or sell private labeled
12+
* compliant product for commercial purposes or to develop compliant
13+
* software for distribution must obtain a license to use the USB3
14+
* Vision standard and the USB3 Vision name and logo from the AIA.
15+
* All products (including software) must be registered with the AIA and
16+
* must be tested for compliancy with the standard.
17+
*
18+
* This program is free software; you can redistribute it and/or
19+
* modify it under the terms of the GNU General Public License
20+
* as published by the Free Software Foundation; version 2
21+
* of the License, or (at your option) any later version.
22+
*
23+
* This program is distributed in the hope that it will be useful,
24+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
25+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26+
* GNU General Public License for more details.
27+
*
28+
* You should have received a copy of the GNU General Public License
29+
* along with this program; if not, write to the Free Software
30+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31+
*/
32+
33+
#ifndef _U3V_H_
34+
#define _U3V_H_
35+
36+
/*
37+
* pr_fmt has to be redefined prior to including linux/kernel.h to prevent
38+
* a compiler warning for its redefinition
39+
*/
40+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
41+
42+
#include <linux/ioctl.h>
43+
#include <linux/usb.h>
44+
#include <linux/kernel.h>
45+
#include <linux/kref.h>
46+
47+
48+
/* General device info */
49+
#define DRIVER_DESC "USB3 Vision Driver"
50+
#define U3V_DEVICE_CLASS 0xEF
51+
#define U3V_DEVICE_SUBCLASS 0x02
52+
#define U3V_DEVICE_PROTOCOL 0x01
53+
#define U3V_INTERFACE_CLASS 0xEF
54+
#define U3V_INTERFACE_SUBCLASS 0x05
55+
#define U3V_INTERFACE_PROTOCOL_CONTROL 0x00
56+
#define U3V_INTERFACE_PROTOCOL_EVENT 0x01
57+
#define U3V_INTERFACE_PROTOCOL_STREAM 0x02
58+
#define U3V_INTERFACE 0x24
59+
#define U3V_DEVICEINFO 0x01
60+
#define MIN_U3V_INFO_LENGTH 20
61+
#define U3V_MINOR_BASE 208
62+
#define U3V_MAX_STR 64
63+
#define U3V_REQUEST_ACK 0x4000
64+
#define U3V_TIMEOUT 5000
65+
#define U3V_DEV_DISCONNECTED 1
66+
67+
68+
struct u3v_interface_info {
69+
u8 idx;
70+
struct usb_endpoint_descriptor *bulk_in;
71+
struct usb_endpoint_descriptor *bulk_out;
72+
struct mutex interface_lock;
73+
struct mutex ioctl_count_lock;
74+
int ioctl_count;
75+
struct completion ioctl_complete;
76+
void *interface_ptr;
77+
};
78+
79+
80+
/*
81+
* A copy of this structure exists for each U3V device to contain its
82+
* private data.
83+
*/
84+
struct u3v_device {
85+
struct usb_device *udev;
86+
struct usb_interface *intf;
87+
struct device *device;
88+
struct kref kref;
89+
struct u3v_device_info *u3v_info; /* device attributes */
90+
struct usb_driver *u3v_driver;
91+
int device_state;
92+
atomic_t device_available;
93+
bool stalling_disabled;
94+
bool device_connected;
95+
struct u3v_interface_info control_info;
96+
struct u3v_interface_info event_info;
97+
struct u3v_interface_info stream_info;
98+
};
99+
100+
101+
#define to_u3v_device(d) container_of(d, struct u3v_device, kref)
102+
103+
/*
104+
* Each u3v_device contains a u3v_device_info struct to store
105+
* device attributes
106+
*/
107+
struct u3v_device_info {
108+
u32 gen_cp_version;
109+
u32 u3v_version;
110+
char device_guid[U3V_MAX_STR];
111+
char vendor_name[U3V_MAX_STR];
112+
char model_name[U3V_MAX_STR];
113+
char family_name[U3V_MAX_STR];
114+
char device_version[U3V_MAX_STR];
115+
char manufacturer_info[U3V_MAX_STR];
116+
char serial_number_u3v[U3V_MAX_STR];
117+
char user_defined_name[U3V_MAX_STR];
118+
u8 speed_support;
119+
u8 previously_initialized;
120+
u32 host_byte_alignment;
121+
u32 os_max_transfer_size;
122+
u64 sirm_addr;
123+
u32 transfer_alignment;
124+
};
125+
126+
/* Helper functions for interfaces */
127+
int reset_pipe(struct u3v_device *u3v, struct u3v_interface_info *iface_info);
128+
#endif /* _U3V_H_ */

0 commit comments

Comments
 (0)