From fca986b8ae30e646b4fac5caff60688e361b0daf Mon Sep 17 00:00:00 2001 From: ttsou Date: Mon, 14 Sep 2009 21:42:03 -0400 Subject: [PATCH] Moved to single generated fusb.h, headers now generated out of lib directory --- host/Makefile.am | 2 +- host/include/usrp/Makefile.am | 10 -- host/lib/Makefile.am | 33 ++++- host/lib/fusb.cc | 4 - host/lib/{fusb.h => fusb.h.in} | 30 ----- host/lib/fusb_libusb1.cc | 3 +- host/lib/fusb_libusb1.h | 2 +- host/lib/fusb_libusb1_base.h | 140 --------------------- host/lib/fusb_sysconfig_libusb1.cc | 2 +- host/{include/usrp => lib}/usrp_basic.h.in | 0 host/lib/usrp_basic_common.cc | 3 +- host/lib/usrp_basic_libusb1.cc | 2 +- host/{include/usrp => lib}/usrp_prims.h.in | 0 13 files changed, 35 insertions(+), 196 deletions(-) rename host/lib/{fusb.h => fusb.h.in} (73%) delete mode 100644 host/lib/fusb_libusb1_base.h rename host/{include/usrp => lib}/usrp_basic.h.in (100%) rename host/{include/usrp => lib}/usrp_prims.h.in (100%) diff --git a/host/Makefile.am b/host/Makefile.am index cc4ba91..aa94fbd 100644 --- a/host/Makefile.am +++ b/host/Makefile.am @@ -19,7 +19,7 @@ # Boston, MA 02110-1301, USA. # -SUBDIRS = misc include lib apps +SUBDIRS = misc lib include apps if PYTHON SUBDIRS += swig diff --git a/host/include/usrp/Makefile.am b/host/include/usrp/Makefile.am index 1e36b10..d580d8a 100644 --- a/host/include/usrp/Makefile.am +++ b/host/include/usrp/Makefile.am @@ -23,16 +23,6 @@ include $(top_srcdir)/Makefile.common usrpincludedir = $(includedir)/usrp -usrp_prims.h: usrp_prims.h.in $(top_srcdir)/config.status - cd $(top_srcdir) \ - && CONFIG_FILES= CONFIG_HEADERS= CONFIG_OTHER=usrp_prims.h \ - $(SHELL) ./config.status - -usrp_basic.h: usrp_basic.h.in $(top_srcdir)/config.status - cd $(top_srcdir) \ - && CONFIG_FILES= CONFIG_HEADERS= CONFIG_OTHER=usrp_basic.h \ - $(SHELL) ./config.status - usrpinclude_HEADERS = \ db_base.h \ db_basic.h \ diff --git a/host/lib/Makefile.am b/host/lib/Makefile.am index 3687aae..16f53bd 100644 --- a/host/lib/Makefile.am +++ b/host/lib/Makefile.am @@ -44,10 +44,16 @@ endif EXTRA_DIST = \ std_paths.h.in \ - usrp_dbid.dat + usrp_dbid.dat \ + fusb.h.in \ + usrp_prims.h.in \ + usrp_basic.h.in BUILT_SOURCES = \ - $(abs_top_builddir)/usrp/host/include/usrp/usrp_dbid.h + $(abs_top_builddir)/usrp/host/include/usrp/usrp_dbid.h \ + fusb.h \ + usrp_prims.h \ + usrp_basic.h BUILT_SOURCES += usrp_dbid.cc \ usrp_dbid.py @@ -133,8 +139,6 @@ libusrp_la_common_SOURCES = \ db_dtt768.cc \ db_util.cc - - if FUSB_TECH_generic libusrp_la_SOURCES = $(libusrp_la_common_SOURCES) $(generic_CODE) endif @@ -166,7 +170,6 @@ noinst_HEADERS = \ db_boards.h \ db_util.h \ fusb.h \ - fusb_libusb1_base.h \ fusb_darwin.h \ fusb_generic.h \ fusb_linux.h \ @@ -193,3 +196,23 @@ gen_sources = $(BUILT_SOURCES) gen_sources_deps = gen_usrp_dbid.py usrp_dbid.dat par_gen_command = PYTHONPATH=$(top_srcdir)/usrp/src srcdir=$(srcdir) $(PYTHON) $(srcdir)/gen_usrp_dbid.py $(srcdir)/usrp_dbid.dat include $(top_srcdir)/Makefile.par.gen + + +# Generate libusb dependent header files from configure. +# These are already defined, but override them here, which throws warnings. +# Need to figure out how to separate rules for BUILD_SOURCES. +fusb.h: fusb.h.in $(top_srcdir)/config.status + cd $(top_srcdir) \ + && CONFIG_FILES= CONFIG_HEADERS= CONFIG_OTHER=fusb.h \ + $(SHELL) ./config.status + +usrp_prims.h: usrp_prims.h.in $(top_srcdir)/config.status + cd $(top_srcdir) \ + && CONFIG_FILES= CONFIG_HEADERS= CONFIG_OTHER=usrp_prims.h \ + $(SHELL) ./config.status + +usrp_basic.h: usrp_basic.h.in $(top_srcdir)/config.status + cd $(top_srcdir) \ + && CONFIG_FILES= CONFIG_HEADERS= CONFIG_OTHER=usrp_basic.h \ + $(SHELL) ./config.status + diff --git a/host/lib/fusb.cc b/host/lib/fusb.cc index 992e1a2..c14d7c1 100644 --- a/host/lib/fusb.cc +++ b/host/lib/fusb.cc @@ -24,11 +24,7 @@ #include "config.h" #endif -#ifdef HAVE_LIBUSB_1 -#include -#else #include -#endif // ------------------------------------------------------------------------ // device handle diff --git a/host/lib/fusb.h b/host/lib/fusb.h.in similarity index 73% rename from host/lib/fusb.h rename to host/lib/fusb.h.in index 506f396..4a65d99 100644 --- a/host/lib/fusb.h +++ b/host/lib/fusb.h.in @@ -1,33 +1,3 @@ -/* -*- 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; diff --git a/host/lib/fusb_libusb1.cc b/host/lib/fusb_libusb1.cc index 6ea7607..0171235 100644 --- a/host/lib/fusb_libusb1.cc +++ b/host/lib/fusb_libusb1.cc @@ -25,6 +25,7 @@ #endif #include +#include #include #include #include @@ -41,7 +42,7 @@ static const int DEFAULT_BLOCK_SIZE = MAX_BLOCK_SIZE; static const int DEFAULT_BUFFER_SIZE = 4 * (1L << 20); // 4 MB endpoint static const int LIBUSB_TIMEOUT = 0; // no timeout -inline static fusb_ephandle_libusb1* +inline static fusb_ephandle_libusb1 * lut_get_ephandle (libusb_transfer *lut) { return (fusb_ephandle_libusb1 *) lut->user_data; diff --git a/host/lib/fusb_libusb1.h b/host/lib/fusb_libusb1.h index 0257ac3..4bc49aa 100644 --- a/host/lib/fusb_libusb1.h +++ b/host/lib/fusb_libusb1.h @@ -23,7 +23,7 @@ #ifndef _FUSB_LIBUSB1_H_ #define _FUSB_LIBUSB1_H_ -#include +#include #include struct libusb_transfer; diff --git a/host/lib/fusb_libusb1_base.h b/host/lib/fusb_libusb1_base.h deleted file mode 100644 index 6a24364..0000000 --- a/host/lib/fusb_libusb1_base.h +++ /dev/null @@ -1,140 +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_LIBUSB1_BASE_H_ -#define _FUSB_LIBUSB1_BASE_H_ - -struct 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_LIBUSB1_BASE_H_ */ - diff --git a/host/lib/fusb_sysconfig_libusb1.cc b/host/lib/fusb_sysconfig_libusb1.cc index ab3c475..f71e34f 100644 --- a/host/lib/fusb_sysconfig_libusb1.cc +++ b/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 diff --git a/host/include/usrp/usrp_basic.h.in b/host/lib/usrp_basic.h.in similarity index 100% rename from host/include/usrp/usrp_basic.h.in rename to host/lib/usrp_basic.h.in diff --git a/host/lib/usrp_basic_common.cc b/host/lib/usrp_basic_common.cc index 9a1f9fd..b617f52 100644 --- a/host/lib/usrp_basic_common.cc +++ b/host/lib/usrp_basic_common.cc @@ -25,10 +25,8 @@ #endif #ifdef HAVE_LIBUSB_1 -#include "fusb_libusb1_base.h" #include #else -#include "fusb.h" #include #endif @@ -37,6 +35,7 @@ #include "usrp_interfaces.h" #include "fpga_regs_common.h" #include "fpga_regs_standard.h" +#include "fusb.h" #include "db_boards.h" #include #include diff --git a/host/lib/usrp_basic_libusb1.cc b/host/lib/usrp_basic_libusb1.cc index 7cfd69b..64cff60 100644 --- a/host/lib/usrp_basic_libusb1.cc +++ b/host/lib/usrp_basic_libusb1.cc @@ -29,7 +29,7 @@ #include "usrp_interfaces.h" #include "fpga_regs_common.h" #include "fpga_regs_standard.h" -#include "fusb_libusb1_base.h" +#include "fusb.h" #include "db_boards.h" #include #include diff --git a/host/include/usrp/usrp_prims.h.in b/host/lib/usrp_prims.h.in similarity index 100% rename from host/include/usrp/usrp_prims.h.in rename to host/lib/usrp_prims.h.in