aboutsummaryrefslogtreecommitdiffstats
path: root/lib/osmosdr
diff options
context:
space:
mode:
authorDimitri Stolnikov <horiz0n@gmx.net>2012-06-06 00:46:49 +0200
committerDimitri Stolnikov <horiz0n@gmx.net>2012-06-06 00:46:49 +0200
commit8099f783c039999e4f18e54169b1f2a43e7e9295 (patch)
treedd0d143dbcbd33c8c6ba18c27faab82cec948f42 /lib/osmosdr
parentd56e18a1d96e41cf39a622acc6ef09bf72113c68 (diff)
osmosdr: use sample rate API
Diffstat (limited to 'lib/osmosdr')
-rw-r--r--lib/osmosdr/osmosdr_src_c.cc40
1 files changed, 11 insertions, 29 deletions
diff --git a/lib/osmosdr/osmosdr_src_c.cc b/lib/osmosdr/osmosdr_src_c.cc
index 770c073..4186d6e 100644
--- a/lib/osmosdr/osmosdr_src_c.cc
+++ b/lib/osmosdr/osmosdr_src_c.cc
@@ -119,10 +119,6 @@ osmosdr_src_c::osmosdr_src_c (const std::string &args)
if (ret < 0)
throw std::runtime_error("Failed to disable IQ swapping.");
- ret = osmosdr_set_fpga_decimation( _dev, 3 ); /* DS register 0x06 */
- if (ret < 0)
- throw std::runtime_error("Failed to set default decimation.");
-
ret = osmosdr_set_sample_rate( _dev, 500000 );
if (ret < 0)
throw std::runtime_error("Failed to set default samplerate.");
@@ -284,37 +280,23 @@ osmosdr::meta_range_t osmosdr_src_c::get_sample_rates()
{
osmosdr::meta_range_t range;
- for (unsigned int i = 64; i >= 4; i >>= 1 ) /* FIXME: hardcoded decimation */
- range += osmosdr::range_t( 4000000 / i ); /* FIXME: hardcoded clock */
-
- // TODO: read from the libosmosdr as soon as the api is available
+ if (_dev) {
+ int count = osmosdr_get_sample_rates(_dev, NULL);
+ if (count > 0) {
+ uint32_t* rates = new uint32_t[ count ];
+ count = osmosdr_get_sample_rates(_dev, rates);
+ for (int i = 0; i < count; i++)
+ range += osmosdr::range_t( rates[i] );
+ delete[] rates;
+ }
+ }
return range;
}
double osmosdr_src_c::set_sample_rate(double rate)
{
- if ( _dev && rate >= 62500.0 ) {
- int decimation = 4000000 / int(rate); /* FIXME: hardcoded clock */
-
- int reg_value;
- if (decimation == 4)
- reg_value = 2;
- else if (decimation == 8)
- reg_value = 3;
- else if (decimation == 16)
- reg_value = 4;
- else if (decimation == 32)
- reg_value = 5;
- else if (decimation == 64)
- reg_value = 6;
- else {
- reg_value = 3;
- rate = 500e6;
- }
-
- osmosdr_set_fpga_decimation( _dev, reg_value );
-
+ if (_dev) {
osmosdr_set_sample_rate( _dev, (uint32_t)rate );
}