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.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'usrp/host/lib/fusb.h') diff --git a/usrp/host/lib/fusb.h b/usrp/host/lib/fusb.h index 769e51cca..bfe34d5b8 100644 --- a/usrp/host/lib/fusb.h +++ b/usrp/host/lib/fusb.h @@ -26,7 +26,7 @@ #define _FUSB_H_ -struct usb_dev_handle; +struct libusb_device_handle; class fusb_ephandle; /*! @@ -39,11 +39,11 @@ private: fusb_devhandle &operator= (const fusb_devhandle &rhs); // no assignment operator protected: - usb_dev_handle *d_udh; + libusb_device_handle *d_udh; public: // CREATORS - fusb_devhandle (usb_dev_handle *udh); + fusb_devhandle (libusb_device_handle *udh); virtual ~fusb_devhandle (); // MANIPULATORS @@ -55,7 +55,7 @@ public: int block_size = 0, int nblocks = 0) = 0; // ACCESSORS - usb_dev_handle *get_usb_dev_handle () const { return d_udh; } + libusb_device_handle *get_libusb_device_handle () const { return d_udh; } }; @@ -116,7 +116,7 @@ public: /*! * \brief returns fusb_devhandle or throws if trouble */ - static fusb_devhandle *make_devhandle (usb_dev_handle *udh); + static fusb_devhandle *make_devhandle (libusb_device_handle *udh); /*! * \brief Returns max block size in bytes (hard limit). -- 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.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'usrp/host/lib/fusb.h') diff --git a/usrp/host/lib/fusb.h b/usrp/host/lib/fusb.h index bfe34d5b8..fbd651204 100644 --- a/usrp/host/lib/fusb.h +++ b/usrp/host/lib/fusb.h @@ -27,6 +27,7 @@ struct libusb_device_handle; +struct libusb_context; class fusb_ephandle; /*! @@ -116,7 +117,8 @@ public: /*! * \brief returns fusb_devhandle or throws if trouble */ - static fusb_devhandle *make_devhandle (libusb_device_handle *udh); + static fusb_devhandle *make_devhandle (libusb_device_handle *udh, + libusb_context *ctx); /*! * \brief Returns max block size in bytes (hard limit). -- cgit From c62085a66bd97f389f49167492f7dccfb0b02976 Mon Sep 17 00:00:00 2001 From: ttsou Date: Thu, 27 Aug 2009 18:13:54 -0400 Subject: first shot at re-adding libusb-0.12 support --- usrp/host/lib/fusb.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'usrp/host/lib/fusb.h') diff --git a/usrp/host/lib/fusb.h b/usrp/host/lib/fusb.h index fbd651204..24d2bee6e 100644 --- a/usrp/host/lib/fusb.h +++ b/usrp/host/lib/fusb.h @@ -26,7 +26,13 @@ #define _FUSB_H_ +#if 1 +struct usb_dev_handle; +typedef struct usb_dev_handle libusb_device_handle; +#else struct libusb_device_handle; +#endif + struct libusb_context; class fusb_ephandle; @@ -120,6 +126,8 @@ public: static fusb_devhandle *make_devhandle (libusb_device_handle *udh, libusb_context *ctx); + static fusb_devhandle *make_devhandle (libusb_device_handle *udh); + /*! * \brief Returns max block size in bytes (hard limit). */ -- cgit From 158caeaa92df7ffdf363236985f4b8e7825f3950 Mon Sep 17 00:00:00 2001 From: ttsou Date: Wed, 9 Sep 2009 11:02:41 -0400 Subject: Added autotools header generation and build time version checking --- usrp/host/lib/fusb.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'usrp/host/lib/fusb.h') diff --git a/usrp/host/lib/fusb.h b/usrp/host/lib/fusb.h index 24d2bee6e..dbfda5a61 100644 --- a/usrp/host/lib/fusb.h +++ b/usrp/host/lib/fusb.h @@ -25,12 +25,15 @@ #ifndef _FUSB_H_ #define _FUSB_H_ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -#if 1 +#ifdef HAVE_LIBUSB_1 +struct libusb_device_handle; +#else struct usb_dev_handle; typedef struct usb_dev_handle libusb_device_handle; -#else -struct libusb_device_handle; #endif struct libusb_context; -- 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.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'usrp/host/lib/fusb.h') diff --git a/usrp/host/lib/fusb.h b/usrp/host/lib/fusb.h index dbfda5a61..00bdffcc0 100644 --- a/usrp/host/lib/fusb.h +++ b/usrp/host/lib/fusb.h @@ -127,9 +127,7 @@ public: * \brief returns fusb_devhandle or throws if trouble */ static fusb_devhandle *make_devhandle (libusb_device_handle *udh, - libusb_context *ctx); - - static fusb_devhandle *make_devhandle (libusb_device_handle *udh); + libusb_context *ctx = 0); /*! * \brief Returns max block size in bytes (hard limit). -- cgit From c6f6e69024bd21e99f5f8673dce2399c4bfd8bb8 Mon Sep 17 00:00:00 2001 From: U-CERVELO\ttsou Date: Fri, 11 Sep 2009 15:35:28 -0400 Subject: changes to build on windows / cygwin --- usrp/host/lib/fusb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usrp/host/lib/fusb.h') diff --git a/usrp/host/lib/fusb.h b/usrp/host/lib/fusb.h index 00bdffcc0..341e570a4 100644 --- a/usrp/host/lib/fusb.h +++ b/usrp/host/lib/fusb.h @@ -65,7 +65,7 @@ public: int block_size = 0, int nblocks = 0) = 0; // ACCESSORS - libusb_device_handle *get_libusb_device_handle () const { return d_udh; } + libusb_device_handle *get_usb_dev_handle () const { return d_udh; } }; -- cgit From 68b0364367f8d99a34f0c38e8a0db0a290f297fc Mon Sep 17 00:00:00 2001 From: ttsou Date: Mon, 14 Sep 2009 14:43:37 -0400 Subject: Commonized more usrp_prims code and renamed libusb-0.12 files to libusb0 --- usrp/host/lib/fusb.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'usrp/host/lib/fusb.h') diff --git a/usrp/host/lib/fusb.h b/usrp/host/lib/fusb.h index 341e570a4..2ff7dc89f 100644 --- a/usrp/host/lib/fusb.h +++ b/usrp/host/lib/fusb.h @@ -25,6 +25,10 @@ #ifndef _FUSB_H_ #define _FUSB_H_ +/* + * This is bad, but it works for now. The fusb header files are not installed. + */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -33,7 +37,7 @@ struct libusb_device_handle; #else struct usb_dev_handle; -typedef struct usb_dev_handle libusb_device_handle; +typedef usb_dev_handle libusb_device_handle; #endif struct libusb_context; -- 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.h | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'usrp/host/lib/fusb.h') diff --git a/usrp/host/lib/fusb.h b/usrp/host/lib/fusb.h index 2ff7dc89f..506f396fa 100644 --- a/usrp/host/lib/fusb.h +++ b/usrp/host/lib/fusb.h @@ -25,20 +25,8 @@ #ifndef _FUSB_H_ #define _FUSB_H_ -/* - * This is bad, but it works for now. The fusb header files are not installed. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef HAVE_LIBUSB_1 -struct libusb_device_handle; -#else struct usb_dev_handle; typedef usb_dev_handle libusb_device_handle; -#endif struct libusb_context; class fusb_ephandle; -- 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.h | 141 --------------------------------------------------- 1 file changed, 141 deletions(-) delete mode 100644 usrp/host/lib/fusb.h (limited to 'usrp/host/lib/fusb.h') diff --git a/usrp/host/lib/fusb.h b/usrp/host/lib/fusb.h deleted file mode 100644 index 506f396fa..000000000 --- a/usrp/host/lib/fusb.h +++ /dev/null @@ -1,141 +0,0 @@ -/* -*- 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. - */ - -// Fast USB interface - -#ifndef _FUSB_H_ -#define _FUSB_H_ - -struct usb_dev_handle; -typedef usb_dev_handle libusb_device_handle; - -struct libusb_context; -class fusb_ephandle; - -/*! - * \brief abstract usb device handle - */ -class fusb_devhandle { -private: - // NOT IMPLEMENTED - fusb_devhandle (const fusb_devhandle &rhs); // no copy constructor - fusb_devhandle &operator= (const fusb_devhandle &rhs); // no assignment operator - -protected: - libusb_device_handle *d_udh; - -public: - // CREATORS - fusb_devhandle (libusb_device_handle *udh); - virtual ~fusb_devhandle (); - - // MANIPULATORS - - /*! - * \brief return an ephandle of the correct subtype - */ - virtual fusb_ephandle *make_ephandle (int endpoint, bool input_p, - int block_size = 0, int nblocks = 0) = 0; - - // ACCESSORS - libusb_device_handle *get_usb_dev_handle () const { return d_udh; } -}; - - -/*! - * \brief abstract usb end point handle - */ -class fusb_ephandle { -private: - // NOT IMPLEMENTED - fusb_ephandle (const fusb_ephandle &rhs); // no copy constructor - fusb_ephandle &operator= (const fusb_ephandle &rhs); // no assignment operator - -protected: - int d_endpoint; - bool d_input_p; - int d_block_size; - int d_nblocks; - bool d_started; - -public: - fusb_ephandle (int endpoint, bool input_p, - int block_size = 0, int nblocks = 0); - virtual ~fusb_ephandle (); - - virtual bool start () = 0; //!< begin streaming i/o - virtual bool stop () = 0; //!< stop streaming i/o - - /*! - * \returns \p nbytes if write was successfully enqueued, else -1. - * Will block if no free buffers available. - */ - virtual int write (const void *buffer, int nbytes) = 0; - - /*! - * \returns number of bytes read or -1 if error. - * number of bytes read will be <= nbytes. - * Will block if no input available. - */ - virtual int read (void *buffer, int nbytes) = 0; - - /* - * block until all outstanding writes have completed - */ - virtual void wait_for_completion () = 0; - - /*! - * \brief returns current block size. - */ - int block_size () { return d_block_size; }; -}; - - -/*! - * \brief factory for creating concrete instances of the appropriate subtype. - */ -class fusb_sysconfig { -public: - /*! - * \brief returns fusb_devhandle or throws if trouble - */ - static fusb_devhandle *make_devhandle (libusb_device_handle *udh, - libusb_context *ctx = 0); - - /*! - * \brief Returns max block size in bytes (hard limit). - */ - static int max_block_size (); - - /*! - * \brief Returns default block size in bytes. - */ - static int default_block_size (); - - /*! - * \brief Returns the default buffer size in bytes. - */ - static int default_buffer_size (); - -}; - -#endif /* _FUSB_H_ */ -- cgit From df4edacd55663aecee58a9b3f95cbc08bceaab81 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Tue, 29 Sep 2009 18:29:44 -0700 Subject: Consolidate conditional headers into libusb_types.h, use automake --- usrp/host/lib/fusb.h | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 usrp/host/lib/fusb.h (limited to 'usrp/host/lib/fusb.h') diff --git a/usrp/host/lib/fusb.h b/usrp/host/lib/fusb.h new file mode 100644 index 000000000..5e3f3aacb --- /dev/null +++ b/usrp/host/lib/fusb.h @@ -0,0 +1,138 @@ +/* -*- Mode: C++ -*- */ +/* + * Copyright 2005,2009 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. + */ + +#ifndef _FUSB_H_ +#define _FUSB_H_ + +#include + +struct libusb_context; +class fusb_ephandle; + +/*! + * \brief abstract usb device handle + */ +class fusb_devhandle { +private: + // NOT IMPLEMENTED + fusb_devhandle (const fusb_devhandle &rhs); // no copy constructor + fusb_devhandle &operator= (const fusb_devhandle &rhs); // no assignment operator + +protected: + libusb_device_handle *d_udh; + +public: + // CREATORS + fusb_devhandle (libusb_device_handle *udh); + virtual ~fusb_devhandle (); + + // MANIPULATORS + + /*! + * \brief return an ephandle of the correct subtype + */ + virtual fusb_ephandle *make_ephandle (int endpoint, bool input_p, + int block_size = 0, int nblocks = 0) = 0; + + // ACCESSORS + libusb_device_handle *get_usb_dev_handle () const { return d_udh; } +}; + + +/*! + * \brief abstract usb end point handle + */ +class fusb_ephandle { +private: + // NOT IMPLEMENTED + fusb_ephandle (const fusb_ephandle &rhs); // no copy constructor + fusb_ephandle &operator= (const fusb_ephandle &rhs); // no assignment operator + +protected: + int d_endpoint; + bool d_input_p; + int d_block_size; + int d_nblocks; + bool d_started; + +public: + fusb_ephandle (int endpoint, bool input_p, + int block_size = 0, int nblocks = 0); + virtual ~fusb_ephandle (); + + virtual bool start () = 0; //!< begin streaming i/o + virtual bool stop () = 0; //!< stop streaming i/o + + /*! + * \returns \p nbytes if write was successfully enqueued, else -1. + * Will block if no free buffers available. + */ + virtual int write (const void *buffer, int nbytes) = 0; + + /*! + * \returns number of bytes read or -1 if error. + * number of bytes read will be <= nbytes. + * Will block if no input available. + */ + virtual int read (void *buffer, int nbytes) = 0; + + /* + * block until all outstanding writes have completed + */ + virtual void wait_for_completion () = 0; + + /*! + * \brief returns current block size. + */ + int block_size () { return d_block_size; }; +}; + + +/*! + * \brief factory for creating concrete instances of the appropriate subtype. + */ +class fusb_sysconfig { +public: + /*! + * \brief returns fusb_devhandle or throws if trouble + */ + static fusb_devhandle *make_devhandle (libusb_device_handle *udh, + libusb_context *ctx = 0); + + /*! + * \brief Returns max block size in bytes (hard limit). + */ + static int max_block_size (); + + /*! + * \brief Returns default block size in bytes. + */ + static int default_block_size (); + + /*! + * \brief Returns the default buffer size in bytes. + */ + static int default_buffer_size (); + +}; + +#endif /* _FUSB_H_ */ -- 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.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usrp/host/lib/fusb.h') diff --git a/usrp/host/lib/fusb.h b/usrp/host/lib/fusb.h index 5e3f3aacb..538ae1ae0 100644 --- a/usrp/host/lib/fusb.h +++ b/usrp/host/lib/fusb.h @@ -1,4 +1,4 @@ -/* -*- Mode: C++ -*- */ +/* -*- c++ -*- */ /* * Copyright 2005,2009 Free Software Foundation, Inc. * -- cgit