From b5aa407ec2b1bdebc1c950a9428789fe50327776 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Mon, 17 Aug 2009 23:46:30 -0400 Subject: Applied libusb-1.0 patch set from Thomas Tsou : This patch set updates the usrp to support libusb-1.0. Asynchronous I/O through libusb is added with fusb_libusb1.*, which is heavily based on fusb_linux.*. In short, URB's and ioctl calls are replaced with libusb_transfer structs and native calls. Transfer reaping is handled by libusb and associated callbacks. I get 32Mb/s on all of my machines using test_usrp_standard_rx or tx. Due to the API rewrite in 1.0 from 0.12, there are alot of changes, many are simply name changes. Known Issues: Transmit and receive both work, but not at same time (e.g. usrp_benchmark_usb.py). libusb does not create any internal threads, so for a single session fusb_libusb1 works in the same manner as fusb_linux with the callback called at controlled times. With multiple libusb sessions the callback may occur at any time and threading issues come into play causing behavior to become undefined. The use of separate libusb_contexts _might_ solve this issue; I have not had the time to look into it. --- usrp/host/lib/fusb_sysconfig_libusb1.cc | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 usrp/host/lib/fusb_sysconfig_libusb1.cc (limited to 'usrp/host/lib/fusb_sysconfig_libusb1.cc') diff --git a/usrp/host/lib/fusb_sysconfig_libusb1.cc b/usrp/host/lib/fusb_sysconfig_libusb1.cc new file mode 100644 index 000000000..e0d9458e1 --- /dev/null +++ b/usrp/host/lib/fusb_sysconfig_libusb1.cc @@ -0,0 +1,49 @@ +/* -*- c++ -*- */ +/* + * Copyright 2003 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio 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 3, or (at your option) + * any later version. + * + * GNU Radio 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. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include +#include + +static const int MAX_BLOCK_SIZE = 16 * 1024; // hard limit +static const int DEFAULT_BLOCK_SIZE = 4 * 1024; +static const int FUSB_BUFFER_SIZE = 2 * (1L << 20); // 2 MB + +fusb_devhandle * +fusb_sysconfig::make_devhandle (libusb_device_handle *udh) +{ + return new fusb_devhandle_libusb1 (udh); +} + +int fusb_sysconfig::max_block_size () +{ + return MAX_BLOCK_SIZE; +} + +int fusb_sysconfig::default_block_size () +{ + return DEFAULT_BLOCK_SIZE; +} + +int fusb_sysconfig::default_buffer_size () +{ + return FUSB_BUFFER_SIZE; +} -- cgit From 0854c4604fcbdb64c74e4b93b87ac07be3d75f55 Mon Sep 17 00:00:00 2001 From: ttsou Date: Tue, 25 Aug 2009 14:53:34 -0400 Subject: Fix for simultaneous tx-rx using libusb_contexts --- usrp/host/lib/fusb_sysconfig_libusb1.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'usrp/host/lib/fusb_sysconfig_libusb1.cc') diff --git a/usrp/host/lib/fusb_sysconfig_libusb1.cc b/usrp/host/lib/fusb_sysconfig_libusb1.cc index e0d9458e1..c82bfe9a1 100644 --- a/usrp/host/lib/fusb_sysconfig_libusb1.cc +++ b/usrp/host/lib/fusb_sysconfig_libusb1.cc @@ -27,10 +27,12 @@ static const int MAX_BLOCK_SIZE = 16 * 1024; // hard limit static const int DEFAULT_BLOCK_SIZE = 4 * 1024; static const int FUSB_BUFFER_SIZE = 2 * (1L << 20); // 2 MB +struct libusb_context; + fusb_devhandle * -fusb_sysconfig::make_devhandle (libusb_device_handle *udh) +fusb_sysconfig::make_devhandle (libusb_device_handle *udh, libusb_context *ctx) { - return new fusb_devhandle_libusb1 (udh); + return new fusb_devhandle_libusb1 (udh, ctx); } int fusb_sysconfig::max_block_size () -- cgit From 3d3888c40ac46cbbd8851e9bc5e83557e0415887 Mon Sep 17 00:00:00 2001 From: ttsou Date: Tue, 25 Aug 2009 18:46:14 -0400 Subject: non-blocking reap and fusb default buffer size change --- usrp/host/lib/fusb_sysconfig_libusb1.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usrp/host/lib/fusb_sysconfig_libusb1.cc') diff --git a/usrp/host/lib/fusb_sysconfig_libusb1.cc b/usrp/host/lib/fusb_sysconfig_libusb1.cc index c82bfe9a1..a005f540d 100644 --- a/usrp/host/lib/fusb_sysconfig_libusb1.cc +++ b/usrp/host/lib/fusb_sysconfig_libusb1.cc @@ -25,7 +25,7 @@ static const int MAX_BLOCK_SIZE = 16 * 1024; // hard limit static const int DEFAULT_BLOCK_SIZE = 4 * 1024; -static const int FUSB_BUFFER_SIZE = 2 * (1L << 20); // 2 MB +static const int FUSB_BUFFER_SIZE = 1 * (1L << 20); // 1 MB struct libusb_context; -- cgit From f79de610d42fdbe8425a1a4aa3c04a1ee3c58e06 Mon Sep 17 00:00:00 2001 From: ttsou Date: Fri, 28 Aug 2009 11:42:41 -0400 Subject: Added libusb1 specific usrp_prims and usrp_basic --- usrp/host/lib/fusb_sysconfig_libusb1.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'usrp/host/lib/fusb_sysconfig_libusb1.cc') diff --git a/usrp/host/lib/fusb_sysconfig_libusb1.cc b/usrp/host/lib/fusb_sysconfig_libusb1.cc index a005f540d..aafbb81cb 100644 --- a/usrp/host/lib/fusb_sysconfig_libusb1.cc +++ b/usrp/host/lib/fusb_sysconfig_libusb1.cc @@ -30,7 +30,14 @@ static const int FUSB_BUFFER_SIZE = 1 * (1L << 20); // 1 MB struct libusb_context; fusb_devhandle * -fusb_sysconfig::make_devhandle (libusb_device_handle *udh, libusb_context *ctx) +fusb_sysconfig::make_devhandle (libusb_device_handle *udh) +{ + return new fusb_devhandle_libusb1 (udh, NULL); +} + +fusb_devhandle * +fusb_sysconfig::make_devhandle (libusb_device_handle *udh, + libusb_context *ctx) { return new fusb_devhandle_libusb1 (udh, ctx); } -- cgit From fff854782eb2fbfc2a49e07ed9941b3beccc3e83 Mon Sep 17 00:00:00 2001 From: Thomas Tsou Date: Wed, 9 Sep 2009 18:52:34 -0400 Subject: Fixed swig and usrp apps to work with libusb-0.12 and libusb-1.0 plus minor cleanup --- usrp/host/lib/fusb_sysconfig_libusb1.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usrp/host/lib/fusb_sysconfig_libusb1.cc') diff --git a/usrp/host/lib/fusb_sysconfig_libusb1.cc b/usrp/host/lib/fusb_sysconfig_libusb1.cc index aafbb81cb..4cbb74132 100644 --- a/usrp/host/lib/fusb_sysconfig_libusb1.cc +++ b/usrp/host/lib/fusb_sysconfig_libusb1.cc @@ -32,7 +32,7 @@ struct libusb_context; fusb_devhandle * fusb_sysconfig::make_devhandle (libusb_device_handle *udh) { - return new fusb_devhandle_libusb1 (udh, NULL); + make_devhandle (udh, NULL); } fusb_devhandle * -- cgit From 98b30a4fc683d91458ccaefeaafbc8f4b783d17e Mon Sep 17 00:00:00 2001 From: ttsou Date: Thu, 10 Sep 2009 15:08:16 -0400 Subject: Use default arguments instead of overloaded virtual constructors for cleaner interface --- usrp/host/lib/fusb_sysconfig_libusb1.cc | 6 ------ 1 file changed, 6 deletions(-) (limited to 'usrp/host/lib/fusb_sysconfig_libusb1.cc') diff --git a/usrp/host/lib/fusb_sysconfig_libusb1.cc b/usrp/host/lib/fusb_sysconfig_libusb1.cc index 4cbb74132..f71e34fa9 100644 --- a/usrp/host/lib/fusb_sysconfig_libusb1.cc +++ b/usrp/host/lib/fusb_sysconfig_libusb1.cc @@ -29,12 +29,6 @@ static const int FUSB_BUFFER_SIZE = 1 * (1L << 20); // 1 MB struct libusb_context; -fusb_devhandle * -fusb_sysconfig::make_devhandle (libusb_device_handle *udh) -{ - make_devhandle (udh, NULL); -} - fusb_devhandle * fusb_sysconfig::make_devhandle (libusb_device_handle *udh, libusb_context *ctx) -- cgit From 579c6354514d57d3f1881131203ba6bbd9648816 Mon Sep 17 00:00:00 2001 From: ttsou Date: Mon, 14 Sep 2009 19:50:26 -0400 Subject: Removed preprocessor declrs out of fusb.h and created separate fusb_libusb1_base.h --- usrp/host/lib/fusb_sysconfig_libusb1.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usrp/host/lib/fusb_sysconfig_libusb1.cc') diff --git a/usrp/host/lib/fusb_sysconfig_libusb1.cc b/usrp/host/lib/fusb_sysconfig_libusb1.cc index f71e34fa9..ab3c475d5 100644 --- a/usrp/host/lib/fusb_sysconfig_libusb1.cc +++ b/usrp/host/lib/fusb_sysconfig_libusb1.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include +#include #include static const int MAX_BLOCK_SIZE = 16 * 1024; // hard limit -- cgit From 44269e7b15129102f93131269e7796fde70ddc05 Mon Sep 17 00:00:00 2001 From: ttsou Date: Mon, 14 Sep 2009 21:42:03 -0400 Subject: Moved to single generated fusb.h, headers now generated out of lib directory --- usrp/host/lib/fusb_sysconfig_libusb1.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usrp/host/lib/fusb_sysconfig_libusb1.cc') diff --git a/usrp/host/lib/fusb_sysconfig_libusb1.cc b/usrp/host/lib/fusb_sysconfig_libusb1.cc index ab3c475d5..f71e34fa9 100644 --- a/usrp/host/lib/fusb_sysconfig_libusb1.cc +++ b/usrp/host/lib/fusb_sysconfig_libusb1.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include +#include #include static const int MAX_BLOCK_SIZE = 16 * 1024; // hard limit -- cgit From 8d3550d330eeac88f4991db866288468be084ddf Mon Sep 17 00:00:00 2001 From: ttsou Date: Thu, 17 Sep 2009 11:24:55 -0400 Subject: Allow fusb_sysconfig to build on non-linux libusb-0.12 impls --- usrp/host/lib/fusb_sysconfig_libusb1.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'usrp/host/lib/fusb_sysconfig_libusb1.cc') diff --git a/usrp/host/lib/fusb_sysconfig_libusb1.cc b/usrp/host/lib/fusb_sysconfig_libusb1.cc index f71e34fa9..a005f540d 100644 --- a/usrp/host/lib/fusb_sysconfig_libusb1.cc +++ b/usrp/host/lib/fusb_sysconfig_libusb1.cc @@ -30,8 +30,7 @@ static const int FUSB_BUFFER_SIZE = 1 * (1L << 20); // 1 MB struct libusb_context; fusb_devhandle * -fusb_sysconfig::make_devhandle (libusb_device_handle *udh, - libusb_context *ctx) +fusb_sysconfig::make_devhandle (libusb_device_handle *udh, libusb_context *ctx) { return new fusb_devhandle_libusb1 (udh, ctx); } -- cgit From f4a86ccaa23e7e513dbbfa45456ea5783c106ec0 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Thu, 1 Oct 2009 13:51:03 -0700 Subject: Cleanup in preparation for merge Fix trailing whitespace Use standard include guards Add more missing config.h includes Fixup emacs mode strings Update copyright notices --- usrp/host/lib/fusb_sysconfig_libusb1.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usrp/host/lib/fusb_sysconfig_libusb1.cc') diff --git a/usrp/host/lib/fusb_sysconfig_libusb1.cc b/usrp/host/lib/fusb_sysconfig_libusb1.cc index a005f540d..46daf561a 100644 --- a/usrp/host/lib/fusb_sysconfig_libusb1.cc +++ b/usrp/host/lib/fusb_sysconfig_libusb1.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2003 Free Software Foundation, Inc. + * Copyright 2003,2009 Free Software Foundation, Inc. * * This file is part of GNU Radio * -- cgit