Commit graph

876 commits

Author SHA1 Message Date
Jon Szymaniak
2caa67a624 libbladeRF: Refactored async stream implementation, non-callback buf submission
To support cases where callbacks would need to block (which they can't),
the async stream implementation has been modified to support
bladerf_submit_stream_buffer(), which allows buffers to be submitted for
transfer outside of the callback functions.

There are some caveats to using this; the documentation has been updated
to note where care should be taken with lock acquisition.
2014-03-30 20:30:30 -04:00
Jon Szymaniak
fd072df449 libbladeRF: Hold lock while executing stream callbacks
Per the libusb documentation, the libusb async callbacks must be
executed atomically.

In half-duplex cases where one thread is sitting in a bladerf_stream()
call, this was a problem.  However, in full-duplex cases, we can have
two threads, each calling a libusb handle_events fn, enter the callback
for a single module. This would result in:
    - Buffers being passed to user callbacks in the wrong order
    - Stream state and error conditions being corrupted
2014-03-22 14:52:15 -04:00
Jon Szymaniak
d586e44bec libbladeRF: Moved stream code and definitions to stream.c/.h
Re-arranged some code in preparation for making changes to the async
stream implementation.
2014-03-22 14:10:55 -04:00
Jon Szymaniak
b876a96811 libbladeRF: test_sync - bladerf_enable_module() thread safety fix
As stated in the API documentation, control calls must only be executed
in one context at a time. A lock has been added to ensure this in the
test_sync program
2014-03-20 00:15:31 -04:00
Jon Szymaniak
c43ea368b7 bladeRF-cli: Added file expansion to flash_init_cal and flash_image 2014-03-18 22:43:01 -04:00
Jon Szymaniak
300356bd50 bladeRF-cli: Bumped patch version (v0.10.7) bladeRF-cli_v0.10.7
Changes include:
    - Serial # printed in `flash_image` output
    - Help text fixes and improvements
    - Additional parameter range checks
    - Minor source tree reorganization
    - Windows: Fixed reading binary files in for transmission
    - Added libc version check to determine if -lrt is required
2014-03-18 20:58:37 -04:00
Jon Szymaniak
11cf991a2e bladeRF-cli: Print serial number in 'flash_image' output 2014-03-18 20:43:04 -04:00
Jon Szymaniak
850d36e4d3 libbladeRF: Added status check missed in 26639556 2014-03-18 09:23:20 -04:00
Jon Szymaniak
2663955614 libbladeRF: Fixed build issues for dummy backend only 2014-03-17 23:46:06 -04:00
Jon Szymaniak
69271ae9ab libbladeRF: Added missing return status checks to bladerf_init_device() 2014-03-17 23:15:56 -04:00
Jon Szymaniak
b55468f09a libbladeRF: Windows build fix
Declarations are required to be at the start of a scope.
2014-03-16 19:52:57 -04:00
Jon Szymaniak
1fce2bffa1 libbladeRF: Corrected Windows header include for mingw compatibility
Thank you to sm5bsz for noting this issue and fix.
2014-03-16 19:51:09 -04:00
Jon Szymaniak
bdbcb810df bladeRF-cli: Enforce parameter ranges, help text touchups 2014-03-16 15:38:05 -04:00
Jon Szymaniak
9e97a34ab4 libbladeRF: Improved range checks and associated documentation
API documentation changes:
    - Added min/max #defines for:
        RXVGA1, RXVGA2, TXVGA1, TXVGA2, sample rate, bandwidth,
        & frequency

    - Documented ranges and error/clamping behavior for:
        bladerf_set_sample_rate, bladerf_set_rational_sample_rate,
        bladerf_set_correction, bladerf_set_txvga1, bladerf_set_txvga2,
        bladerf_set_rxvga1, bladerf_set_rxvga2, bladerf_select_band,

Ensured the aforementioned functions clamp or return an error
for out-of-range input. The low-level functions have NOT been updated
for range checks. (e.g., bladerf_si5338_set_tx_freq).
2014-03-16 15:37:59 -04:00
Jon Szymaniak
d9db54396e libbladeRF: Typo fix for previous commit 2014-03-15 23:09:43 -04:00
Jon Szymaniak
1dd23171b4 libbladeRF: Only clear sync buffer status for TX items
When starting an RX stream, the first N buffers, where N is the number
of transfers, will be submitted when the bladerf_stream() call is made.

Therefore, it is incorrect to clear IN_FLIGHT status; this will result in an
assertion firing in the RX callback.

After looking into this, it's become clear that the sync interface does
not correctly handle the situation where the underlying async stream
starts up. Issue #229 has been opened to further track the associated
defect and resolution.
2014-03-15 19:43:29 -04:00
Jon Szymaniak
06776a5f8b libbladeRF: Clear sync buffer "in-flight" status when restarting stream
When restarting a stream, we assume in-flight buffers are lost. These
must be marked empty so they can be re-used.

Also in this commit:
    - Cleaned up unnecessary unlock, relock, unlock
    - Fixed return value check of pthread_cond_timedwait
2014-03-13 21:14:17 -04:00
Jon Szymaniak
5f8bcae45a libbladeRF: Added windows resource file with version information
A thank you goes out to LazyDodo for providing this patch.
2014-03-12 00:11:05 -04:00
Jon Szymaniak
0acf5b1159 libbladeRF: Fixed i386 build issue (libladerf_test_sync)
gcc-4.8.1 reports the following for FREQ_MIN:

... /test_sync/src/main.c:215:48:
error: this decimal constant is unsigned only in ISO C90 [-Werror]
2014-03-08 22:29:42 -05:00
Jon Szymaniak
6681d1a048 libbladeRF: Bumped minor rev (v0.14.0) libbladeRF_v0.14.0
Note that this version introduces some reverse-incompatible changes
with respect to v0.13.z and earlier.

Changes Include:
    - Removal of bladerf_rx and bladerf_tx functions
    - Addition of a new synchronous interface that operates atop the
      asynchronous interface.
    - Renaming of stream transfer timeout functions

A friendly reminder - the v0.y.z series is officially "unstable."

Some further reverse-incompatible changes are expected to be made as
metadata support is integrated into libbladeRF. It is recommended to
avoid accessing/modifying metadata structures for the time being, as
these are subject to change.
2014-03-08 19:58:56 -05:00
Jon Szymaniak
2a0dde641f libbladeRF: Added further clarification to (Doxygen) documentation 2014-03-08 19:55:22 -05:00
Jon Szymaniak
3ad30c3b5a libbladeRF: Windows build fix for test_sync program
Build error results from treating warnings as errors, with possible overflow in 64 -> 32bit conversion.
2014-03-08 19:55:22 -05:00
Konstanty Bialkowski
8e133b7ca6 libbladeRF: Include required OSX common/ directory items in build
The following items were missing from the changes introduced in commit
28ed798ce9:

   - Add common/include/osx directory to libbladeRF include path
   - Add common/osx/src/clock_gettime.c to libbladeRF build
2014-03-08 19:55:22 -05:00
Jon Szymaniak
19d4826fae libbladeRF: Moved internal sync handles into an array
This is a bit more consistent with what's already done with timeouts,
and is the preferred method of adding per-module items in the future.
2014-03-08 19:55:21 -05:00
Jon Szymaniak
ffb54863b2 libbladeRF: Added loopback and clean SIGTERM handling to test_sync 2014-03-08 19:55:21 -05:00
Jon Szymaniak
b5da596db7 libbladeRF: libbladerf_test_sync runs full duplex 2014-03-08 19:55:21 -05:00
Jon Szymaniak
daaa2e92c8 libbladeRF: Re-implemented sync interface, updated API docs, renamed timeout function
The sync interface has been re-implemented atop the existing
asynchronous interface. This is currently opt-in and only enable when
pthreads support is enabled and available.

Some clarifications have been made in the API documentation,
specifically in the explanations of the various stream parameters.

The bladerf_set_transfer_timeout and bladerf_get_transfer_timeout have
been named more appropriately, as these control stream transfer
timeouts, as opposed to all transfers.
2014-03-08 19:55:21 -05:00
Jon Szymaniak
8ed77b9a0f bladeRF-cli: Open binary sample files with "rb"
In Windows this caused the sample data to be corrupted when read.
2014-03-08 17:17:35 -05:00
Jon Szymaniak
3b19148112 host: Added check for libc version
It's necessary to build with -lrt for libc < 2.17 when using
clock_gettime().
2014-03-08 03:05:03 -05:00
Jon Szymaniak
215807088c libbladeRF: Documentation touch-up in bladerf_stream description
Noted that bladerf_enable_module() *must* be called prior to calling
bladerf_stream().
2014-03-08 00:24:32 -05:00
Jon Szymaniak
3144cfa1b9 bladeRF-cli: Fixed unclear help text 2014-03-07 22:45:04 -05:00
Jon Szymaniak
3ff779f236 bladeRF-cli: Bumped patch rev (v0.10.6) bladeRF-cli_v0.10.6 libbladeRF_v0.13.2
Changes include:
    - Removal of bladerf_close() call after bladerf_device_reset() call
2014-03-07 00:21:53 -05:00
Jon Szymaniak
94a3c40944 libbladeRF: Bumped patch rev (v0.13.2)
Changes include:
 - Repeater test hotkey support and minor fixes
2014-03-07 00:15:42 -05:00
Jon Szymaniak
2b7b26eeda libbladeRF: Minor touch-ups in test_repeater
No need to use dummy variable with bladerf_init_stream as of commit
3e89a44f66.

Reduced default sample rate to 1 Msps to avoid timeouts on Hi-speed
connections.
2014-03-02 21:42:09 -05:00
Frank Jenner
03159d96a0 libbladeRF: Added gain hotkey support to repeater test program
The numeric keys may be used to increase/decrease gains while running.
2014-03-02 21:41:50 -05:00
Robert Ghilduta
b909236fb0 bladeRF-cli: fix a BSOD on Windows
Calling bladerf_close() after bladerf_device_reset() essentially
causes bladerf_close() to use a non-existent handle thus causing a BSOD.
2014-03-01 13:51:03 -05:00
Jon Szymaniak
8a5dc51c18 libbladeRF: Bumped version to v0.13.1 bladeRF-cli_v0.10.5 libbladeRF_v0.13.1
Changes include:
    - Fixes for regressions in LMS code introduced in v0.13.0
2014-02-27 21:18:14 -05:00
Jon Szymaniak
4ccbb03194 bladeRF-cli: Bumped to version v0.10.5
Changes include:
    - Error message corrections
    - Fixes to RXVGA1-related textual output
2014-02-27 21:15:27 -05:00
Jon Szymaniak
c52de9b711 bladeRF-cli: Fixed incorrect error message output 2014-02-27 21:14:42 -05:00
Jon Szymaniak
a712304f02 libbladeRF: Fixed LMS SELOUT[1:0] corruption when changing bands
SELOUT[1:0] was being OR'd, rather than set to the desired value.
2014-02-18 23:10:59 -05:00
Jon Szymaniak
23cfc1dd87 cmake: Finer granularity in configuring doc generation
BUILD_DOCUMENATION is now a top-level switch to turn on/off doc generation.

When BUILD_DOCUMENTATION=ON, individual components may be turned ON/OFF.
These default to the state of ${BUILD_DOCUMENTATION}.
    - BUILD_LIBBLADERF_DOCUMENTATION     (libbladeRF Doxygen docs)
    - BUILD_BLADERF_CLI_DOCUMENTATION    (bladeRF-cli man page)
    - BUILD_BLADERF_FLASH_DOCUMENTATION  (bladeRF-flash man page)
2014-02-16 14:26:30 -05:00
Jon Szymaniak
12c944a48b libbladeRF: Cleaned up LMS VGA range checks, RXVGA1 LUT and enable bit
Moved LMS VGA range checks out of bladeRF.c into lms.c.

Replaced RXVGA1 calculations with lookup tables. (h/t to LazyDodo for
the suggestion.)

Corrected RXVGA1 enable/disable. Previously we were just setting the
bias current to 0, but it turns out there's an actual bit for this in
reserved register 0x7d.
2014-02-16 00:56:11 -05:00
Jon Szymaniak
3acf129cb4 COPYING: Typo fix 2014-02-14 22:54:52 -05:00
Jon Szymaniak
39f07b933c bladeRF-cli: Corrected RXVGA1 range description
RXVGA1 is exposed via the API in dB, not the raw register value.
2014-02-13 20:47:18 -05:00
Jon Szymaniak
02d0cb38be bladeRF-cli: Bumped version to v0.10.4 bladeRF-cli_v0.10.4 libbladeRF_v0.13.0
Changes include:
    - Loopback support added to print/set commands
    - Bug fixes
2014-02-13 15:34:51 -05:00
Jon Szymaniak
eaf2c6e885 bladeRF-cli: Added gain VGA gain ranges to help text 2014-02-13 15:34:51 -05:00
Jon Szymaniak
e4661b60c9 bladeRF-cli: Added loopback support to 'print' and 'set' commands 2014-02-13 15:34:51 -05:00
Jon Szymaniak
af285804bb libbladeRF: Bumped version to v0.13.0
Changes include:
    - LMS refactoring and loopback support
    - Support for passing NULL to optional API parameters
    - Dummy backend
    - Bug fixes
2014-02-13 15:34:51 -05:00
Jon Szymaniak
9ee9c765d4 libbladeRF: Refactored lms code, implemented baseband and RF loopback
Changes include stylistic and functional clean-up. LMS functions now
return and check status codes.

Finer grained loopback options have been added.
2014-02-13 15:34:46 -05:00
Jon Szymaniak
0655e83d7b libbladeRF: Fixed unintentional floor() in frequency.nfrac calculation 2014-02-09 17:23:47 -05:00