Statistics
| Branch: | Tag: | Revision:

root / host / lib / usrp / dboard / db_dbsrx.cpp @ 898adebb

History | View | Annotate | Download (21.4 kB)

1
//
2
// Copyright 2010 Ettus Research LLC
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
//
17

    
18
// No RX IO Pins Used
19

    
20
// RX IO Functions
21

    
22
#include "max2118_regs.hpp"
23
#include <uhd/utils/static.hpp>
24
#include <uhd/utils/assert.hpp>
25
#include <uhd/utils/algorithm.hpp>
26
#include <uhd/utils/warning.hpp>
27
#include <uhd/types/ranges.hpp>
28
#include <uhd/types/dict.hpp>
29
#include <uhd/usrp/subdev_props.hpp>
30
#include <uhd/usrp/dboard_base.hpp>
31
#include <uhd/usrp/dboard_manager.hpp>
32
#include <boost/assign/list_of.hpp>
33
#include <boost/format.hpp>
34
#include <boost/thread.hpp>
35
#include <boost/math/special_functions/round.hpp>
36
#include <utility>
37

    
38
using namespace uhd;
39
using namespace uhd::usrp;
40
using namespace boost::assign;
41

    
42
/***********************************************************************
43
 * The DBSRX constants
44
 **********************************************************************/
45
static const bool dbsrx_debug = false;
46

    
47
static const freq_range_t dbsrx_freq_range(0.8e9, 2.4e9);
48

    
49
static const freq_range_t dbsrx_pfd_freq_range(0.15e6, 2.01e6);
50

    
51
static const prop_names_t dbsrx_antennas = list_of("J3");
52

    
53
static const uhd::dict<std::string, gain_range_t> dbsrx_gain_ranges = map_list_of
54
    ("GC1", gain_range_t(0, 56, 0.5))
55
    ("GC2", gain_range_t(0, 24, 1))
56
;
57

    
58
/***********************************************************************
59
 * The DBSRX dboard class
60
 **********************************************************************/
61
class dbsrx : public rx_dboard_base{
62
public:
63
    dbsrx(ctor_args_t args, boost::uint8_t max2118_addr);
64
    ~dbsrx(void);
65

    
66
    void rx_get(const wax::obj &key, wax::obj &val);
67
    void rx_set(const wax::obj &key, const wax::obj &val);
68

    
69
private:
70
    double _lo_freq;
71
    float _bandwidth;
72
    uhd::dict<std::string, float> _gains;
73
    max2118_write_regs_t _max2118_write_regs;
74
    max2118_read_regs_t _max2118_read_regs;
75
    boost::uint8_t _max2118_addr; //0x67 or 0x65 depending on which side
76

    
77
    void set_lo_freq(double target_freq);
78
    void set_gain(float gain, const std::string &name);
79
    void set_bandwidth(float bandwidth);
80

    
81
    void send_reg(boost::uint8_t start_reg, boost::uint8_t stop_reg){
82
        start_reg = boost::uint8_t(std::clip(int(start_reg), 0x0, 0x5));
83
        stop_reg = boost::uint8_t(std::clip(int(stop_reg), 0x0, 0x5));
84

    
85
        for(boost::uint8_t start_addr=start_reg; start_addr <= stop_reg; start_addr += sizeof(boost::uint32_t) - 1){
86
            int num_bytes = int(stop_reg - start_addr + 1) > int(sizeof(boost::uint32_t)) - 1 ? sizeof(boost::uint32_t) - 1 : stop_reg - start_addr + 1;
87

    
88
            //create buffer for register data (+1 for start address)
89
            byte_vector_t regs_vector(num_bytes + 1);
90

    
91
            //first byte is the address of first register
92
            regs_vector[0] = start_addr;
93

    
94
            //get the register data
95
            for(int i=0; i<num_bytes; i++){
96
                regs_vector[1+i] = _max2118_write_regs.get_reg(start_addr+i);
97
                if(dbsrx_debug) std::cerr << boost::format(
98
                    "DBSRX: send reg 0x%02x, value 0x%04x, start_addr = 0x%04x, num_bytes %d"
99
                ) % int(start_addr+i) % int(regs_vector[1+i]) % int(start_addr) % num_bytes << std::endl;
100
            }
101

    
102
            //send the data
103
            this->get_iface()->write_i2c(
104
                _max2118_addr, regs_vector
105
            );
106
        }
107
    }
108

    
109
    void read_reg(boost::uint8_t start_reg, boost::uint8_t stop_reg){
110
        static const boost::uint8_t status_addr = 0x0;
111
        start_reg = boost::uint8_t(std::clip(int(start_reg), 0x0, 0x1));
112
        stop_reg = boost::uint8_t(std::clip(int(stop_reg), 0x0, 0x1));
113

    
114
        for(boost::uint8_t start_addr=start_reg; start_addr <= stop_reg; start_addr += sizeof(boost::uint32_t)){
115
            int num_bytes = int(stop_reg - start_addr + 1) > int(sizeof(boost::uint32_t)) ? sizeof(boost::uint32_t) : stop_reg - start_addr + 1;
116

    
117
            //create buffer for register data
118
            byte_vector_t regs_vector(num_bytes);
119

    
120
            //read from i2c
121
            regs_vector = this->get_iface()->read_i2c(
122
                _max2118_addr, num_bytes
123
            );
124

    
125
            for(boost::uint8_t i=0; i < num_bytes; i++){
126
                if (i + start_addr >= status_addr){
127
                    _max2118_read_regs.set_reg(i + start_addr, regs_vector[i]);
128
                }
129
                if(dbsrx_debug) std::cerr << boost::format(
130
                    "DBSRX: read reg 0x%02x, value 0x%04x, start_addr = 0x%04x, num_bytes %d"
131
                ) % int(start_addr+i) % int(regs_vector[i]) % int(start_addr) % num_bytes << std::endl;
132
            }
133
        }
134
    }
135

    
136
    /*!
137
     * Is the LO locked?
138
     * \return true for locked
139
     */
140
    bool get_locked(void){
141
        read_reg(0x0, 0x0);
142

    
143
        //mask and return lock detect
144
        bool locked = 5 >= _max2118_read_regs.adc && _max2118_read_regs.adc >= 2;
145

    
146
        if(dbsrx_debug) std::cerr << boost::format(
147
            "DBSRX: locked %d"
148
        ) % locked << std::endl;
149

    
150
        return locked;
151
    }
152

    
153
};
154

    
155
/***********************************************************************
156
 * Register the DBSRX dboard
157
 **********************************************************************/
158
// FIXME 0x67 is the default i2c address on USRP2
159
//       need to handle which side for USRP1 with different address
160
static dboard_base::sptr make_dbsrx(dboard_base::ctor_args_t args){
161
    return dboard_base::sptr(new dbsrx(args, 0x67));
162
}
163

    
164
//dbid for USRP2 version
165
UHD_STATIC_BLOCK(reg_dbsrx_dboard){
166
    //register the factory function for the rx dbid
167
    dboard_manager::register_dboard(0x000D, &make_dbsrx, "DBSRX");
168
}
169

    
170
//dbid for USRP1 version
171
UHD_STATIC_BLOCK(reg_dbsrx_on_usrp1_dboard){
172
    //register the factory function for the rx dbid
173
    dboard_manager::register_dboard(0x0002, &make_dbsrx, "DBSRX");
174
}
175

    
176
/***********************************************************************
177
 * Structors
178
 **********************************************************************/
179
dbsrx::dbsrx(ctor_args_t args, boost::uint8_t max2118_addr) : rx_dboard_base(args){
180
    //warn user about incorrect DBID on USRP1, requires R193 populated
181
    if (this->get_iface()->get_mboard_name() == "usrp1" and this->get_rx_id() == 0x000D)
182
        uhd::print_warning(
183
            str(boost::format(
184
                "DBSRX: incorrect dbid\n"
185
                "%s expects dbid 0x0002 and R193\n"
186
                "found dbid == %d\n"
187
                "Please see the daughterboard app notes" 
188
                ) % (this->get_iface()->get_mboard_name()) % (this->get_rx_id().to_pp_string()))
189
        );
190

    
191
    //warn user about incorrect DBID on non-USRP1, requires R194 populated
192
    if (this->get_iface()->get_mboard_name() != "usrp1" and this->get_rx_id() == 0x0002)
193
        uhd::print_warning(
194
            str(boost::format(
195
                "DBSRX: incorrect dbid\n"
196
                "%s expects dbid 0x000D and R194\n"
197
                "found dbid == %d\n"
198
                "Please see the daughterboard app notes" 
199
                ) % (this->get_iface()->get_mboard_name()) % (this->get_rx_id().to_pp_string()))
200
        );
201

    
202
    //enable only the clocks we need
203
    this->get_iface()->set_clock_enabled(dboard_iface::UNIT_RX, true);
204

    
205
    //set the gpio directions and atr controls (identically)
206
    this->get_iface()->set_pin_ctrl(dboard_iface::UNIT_RX, 0x0); // All unused in atr
207
    this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_RX, 0x0); // All Inputs
208

    
209
    //set the i2c address for the max2118
210
    _max2118_addr = max2118_addr;
211

    
212
    //send initial register settings
213
    this->send_reg(0x0, 0x5);
214

    
215
    //set defaults for LO, gains, and filter bandwidth
216
    _bandwidth = 33e6;
217
    set_lo_freq(dbsrx_freq_range.min);
218

    
219
    BOOST_FOREACH(const std::string &name, dbsrx_gain_ranges.keys()){
220
        set_gain(dbsrx_gain_ranges[name].min, name);
221
    }
222

    
223
    set_bandwidth(33e6); // default bandwidth from datasheet
224
}
225

    
226
dbsrx::~dbsrx(void){
227
}
228

    
229

    
230
/***********************************************************************
231
 * Tuning
232
 **********************************************************************/
233
void dbsrx::set_lo_freq(double target_freq){
234
    target_freq = std::clip(target_freq, dbsrx_freq_range.min, dbsrx_freq_range.max);
235

    
236
    double actual_freq=0.0, pfd_freq=0.0, ref_clock=0.0;
237
    int R=0, N=0, r=0, m=0;
238
    bool update_filter_settings = false;
239

    
240
    //choose refclock
241
    std::vector<double> clock_rates = this->get_iface()->get_clock_rates(dboard_iface::UNIT_RX);
242
    BOOST_FOREACH(ref_clock, std::reversed(std::sorted(clock_rates))){
243
        if (ref_clock > 27.0e6) continue;
244

    
245
        //choose m_divider such that filter tuning constraint is met
246
        m = 31;
247
        while ((ref_clock/m < 1e6 or ref_clock/m > 2.5e6) and m > 0){ m--; }
248

    
249
        if(dbsrx_debug) std::cerr << boost::format(
250
            "DBSRX: trying ref_clock %f and m_divider %d"
251
        ) % (this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX)) % m << std::endl;
252

    
253
        if (m >= 32) continue;
254

    
255
        //choose R
256
        for(r = 0; r <= 6; r += 1) {
257
            //compute divider from setting
258
            R = pow(2, r+1);
259
            if (dbsrx_debug) std::cerr << boost::format("DBSRX R:%d\n") % R << std::endl;
260

    
261
            //compute PFD compare frequency = ref_clock/R
262
            pfd_freq = ref_clock / R;
263

    
264
            //constrain the PFD frequency to specified range
265
            if ((pfd_freq < dbsrx_pfd_freq_range.min) or (pfd_freq > dbsrx_pfd_freq_range.max)) continue;
266

    
267
            //compute N
268
            N = int(std::floor(target_freq/pfd_freq));
269

    
270
            //constrain N to specified range
271
            if ((N < 256) or (N > 32768)) continue;
272

    
273
            goto done_loop;
274
        }
275
    } 
276

    
277
    //Assert because we failed to find a suitable combination of ref_clock, R and N 
278
    UHD_ASSERT_THROW(ref_clock/(1 << m) < 1e6 or ref_clock/(1 << m) > 2.5e6);
279
    UHD_ASSERT_THROW((pfd_freq < dbsrx_pfd_freq_range.min) or (pfd_freq > dbsrx_pfd_freq_range.max));
280
    UHD_ASSERT_THROW((N < 256) or (N > 32768));
281
    done_loop:
282

    
283
    if(dbsrx_debug) std::cerr << boost::format(
284
        "DBSRX: choose ref_clock %f and m_divider %d"
285
    ) % (this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX)) % m << std::endl;
286

    
287
    //if ref_clock or m divider changed, we need to update the filter settings
288
    if (ref_clock != this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX) or m != _max2118_write_regs.m_divider) update_filter_settings = true;
289

    
290
    //compute resulting output frequency
291
    actual_freq = pfd_freq * N;
292

    
293
    //apply ref_clock, R, and N settings
294
    this->get_iface()->set_clock_rate(dboard_iface::UNIT_RX, ref_clock);
295
    ref_clock = this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX);
296
    _max2118_write_regs.m_divider = m;
297
    _max2118_write_regs.r_divider = (max2118_write_regs_t::r_divider_t) r;
298
    _max2118_write_regs.set_n_divider(N);
299
    _max2118_write_regs.ade_vco_ade_read = max2118_write_regs_t::ADE_VCO_ADE_READ_ENABLED;
300
    
301
    //compute prescaler variables
302
    int scaler = actual_freq > 1125e6 ? 2 : 4;
303
    _max2118_write_regs.div2 = scaler == 4 ? max2118_write_regs_t::DIV2_DIV4 : max2118_write_regs_t::DIV2_DIV2;
304

    
305
    if(dbsrx_debug) std::cerr << boost::format(
306
        "DBSRX: scaler %d, actual_freq %f MHz, register bit: %d"
307
    ) % scaler % (actual_freq/1e6) % int(_max2118_write_regs.div2) << std::endl;
308

    
309
    //compute vco frequency and select vco
310
    double vco_freq = actual_freq * scaler;
311
    if (vco_freq < 2433e6)
312
        _max2118_write_regs.osc_band = 0;
313
    else if (vco_freq < 2711e6)
314
        _max2118_write_regs.osc_band = 1;
315
    else if (vco_freq < 3025e6)
316
        _max2118_write_regs.osc_band = 2;
317
    else if (vco_freq < 3341e6)
318
        _max2118_write_regs.osc_band = 3;
319
    else if (vco_freq < 3727e6)
320
        _max2118_write_regs.osc_band = 4;
321
    else if (vco_freq < 4143e6)
322
        _max2118_write_regs.osc_band = 5;
323
    else if (vco_freq < 4493e6)
324
        _max2118_write_regs.osc_band = 6;
325
    else
326
        _max2118_write_regs.osc_band = 7;
327

    
328
    //send settings over i2c
329
    send_reg(0x0, 0x4);
330

    
331
    //check vtune for lock condition
332
    read_reg(0x0, 0x0);
333

    
334
    if(dbsrx_debug) std::cerr << boost::format(
335
        "DBSRX: initial guess for vco %d, vtune adc %d"
336
    ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) << std::endl;
337

    
338
    //if we are out of lock for chosen vco, change vco
339
    while ((_max2118_read_regs.adc == 0) or (_max2118_read_regs.adc == 7)){
340

    
341
        //vtune is too low, try lower frequency vco
342
        if (_max2118_read_regs.adc == 0){
343
            if (_max2118_write_regs.osc_band == 0){
344
                uhd::print_warning(
345
                    str(boost::format(
346
                        "DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n" 
347
                        ) % int(_max2118_write_regs.osc_band))
348
                );
349
                UHD_ASSERT_THROW(_max2118_read_regs.adc == 0);
350
            }
351
            if (_max2118_write_regs.osc_band <= 0) break;
352
            _max2118_write_regs.osc_band -= 1;
353
        }
354

    
355
        //vtune is too high, try higher frequency vco
356
        if (_max2118_read_regs.adc == 7){
357
            if (_max2118_write_regs.osc_band == 7){
358
                uhd::print_warning(
359
                    str(boost::format(
360
                        "DBSRX: Tuning exceeded vco range, _max2118_write_regs.osc_band == %d\n" 
361
                        ) % int(_max2118_write_regs.osc_band))
362
                );
363
                UHD_ASSERT_THROW(_max2118_read_regs.adc == 0);
364
            }
365
            if (_max2118_write_regs.osc_band >= 7) break;
366
            _max2118_write_regs.osc_band += 1;
367
        }
368

    
369
        if(dbsrx_debug) std::cerr << boost::format(
370
            "DBSRX: trying vco %d, vtune adc %d"
371
        ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) << std::endl;
372

    
373
        //update vco selection and check vtune
374
        send_reg(0x2, 0x2);
375
        read_reg(0x0, 0x0);
376
    }
377
      
378
    if(dbsrx_debug) std::cerr << boost::format(
379
        "DBSRX: final vco %d, vtune adc %d"
380
    ) % int(_max2118_write_regs.osc_band) % int(_max2118_read_regs.adc) << std::endl;
381

    
382
    //select charge pump bias current
383
    if (_max2118_read_regs.adc <= 2) _max2118_write_regs.cp_current = max2118_write_regs_t::CP_CURRENT_I_CP_100UA;
384
    else if (_max2118_read_regs.adc >= 5) _max2118_write_regs.cp_current = max2118_write_regs_t::CP_CURRENT_I_CP_400UA;
385
    else _max2118_write_regs.cp_current = max2118_write_regs_t::CP_CURRENT_I_CP_200UA;
386
    
387
    //update charge pump bias current setting
388
    send_reg(0x2, 0x2);
389

    
390
    //compute actual tuned frequency
391
    _lo_freq = this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX) / pow(2,(1 + _max2118_write_regs.r_divider)) * _max2118_write_regs.get_n_divider();
392

    
393
    //debug output of calculated variables
394
    if (dbsrx_debug) std::cerr
395
        << boost::format("DBSRX tune:\n")
396
        << boost::format("    VCO=%d, CP=%d, PFD Freq=%fMHz\n") % int(_max2118_write_regs.osc_band) % _max2118_write_regs.cp_current % (pfd_freq/1e6)
397
        << boost::format("    R=%d, N=%f, scaler=%d, div2=%d\n") % R % N % scaler % int(_max2118_write_regs.div2)
398
        << boost::format("    Ref    Freq=%fMHz\n") % (ref_clock/1e6)
399
        << boost::format("    Target Freq=%fMHz\n") % (target_freq/1e6)
400
        << boost::format("    Actual Freq=%fMHz\n") % (_lo_freq/1e6)
401
        << std::endl;
402

    
403
    if (update_filter_settings) set_bandwidth(_bandwidth);
404
    get_locked();
405
}
406

    
407
/***********************************************************************
408
 * Gain Handling
409
 **********************************************************************/
410
/*!
411
 * Convert a requested gain for the GC2 vga into the integer register value.
412
 * The gain passed into the function will be set to the actual value.
413
 * \param gain the requested gain in dB
414
 * \return 5 bit the register value
415
 */
416
static int gain_to_gc2_vga_reg(float &gain){
417
    int reg = 0;
418
    gain = std::clip<float>(boost::math::iround(gain), dbsrx_gain_ranges["GC2"].min, dbsrx_gain_ranges["GC2"].max);
419

    
420
    // Half dB steps from 0-5dB, 1dB steps from 5-24dB
421
    if (gain < 5) {
422
        reg = boost::math::iround(31.0 - gain/0.5);
423
        gain = float(boost::math::iround(gain)) * 0.5;
424
    } else {
425
        reg = boost::math::iround(22.0 - (gain - 4.0));
426
        gain = float(boost::math::iround(gain));
427
    }
428

    
429
    if (dbsrx_debug) std::cerr << boost::format(
430
        "DBSRX GC2 Gain: %f dB, reg: %d"
431
    ) % gain % reg << std::endl;
432

    
433
    return reg;
434
}
435

    
436
/*!
437
 * Convert a requested gain for the GC1 rf vga into the dac_volts value.
438
 * The gain passed into the function will be set to the actual value.
439
 * \param gain the requested gain in dB
440
 * \return dac voltage value
441
 */
442
static float gain_to_gc1_rfvga_dac(float &gain){
443
    //clip the input
444
    gain = std::clip<float>(gain, dbsrx_gain_ranges["GC1"].min, dbsrx_gain_ranges["GC1"].max);
445

    
446
    //voltage level constants
447
    static const float max_volts = float(1.2), min_volts = float(2.7);
448
    static const float slope = (max_volts-min_volts)/dbsrx_gain_ranges["GC1"].max;
449

    
450
    //calculate the voltage for the aux dac
451
    float dac_volts = gain*slope + min_volts;
452

    
453
    if (dbsrx_debug) std::cerr << boost::format(
454
        "DBSRX GC1 Gain: %f dB, dac_volts: %f V"
455
    ) % gain % dac_volts << std::endl;
456

    
457
    //the actual gain setting
458
    gain = (dac_volts - min_volts)/slope;
459

    
460
    return dac_volts;
461
}
462

    
463
void dbsrx::set_gain(float gain, const std::string &name){
464
    assert_has(dbsrx_gain_ranges.keys(), name, "dbsrx gain name");
465
    if (name == "GC2"){
466
        _max2118_write_regs.gc2 = gain_to_gc2_vga_reg(gain);
467
        send_reg(0x5, 0x5);
468
    }
469
    else if(name == "GC1"){
470
        //write the new voltage to the aux dac
471
        this->get_iface()->write_aux_dac(dboard_iface::UNIT_RX, dboard_iface::AUX_DAC_A, gain_to_gc1_rfvga_dac(gain));
472
    }
473
    else UHD_THROW_INVALID_CODE_PATH();
474
    _gains[name] = gain;
475
}
476

    
477
/***********************************************************************
478
 * Bandwidth Handling
479
 **********************************************************************/
480
void dbsrx::set_bandwidth(float bandwidth){
481
    //clip the input
482
    bandwidth = std::clip<float>(bandwidth, 4e6, 33e6);
483

    
484
    double ref_clock = this->get_iface()->get_clock_rate(dboard_iface::UNIT_RX);
485
    
486
    //NOTE: _max2118_write_regs.m_divider set in set_lo_freq
487

    
488
    //compute f_dac setting
489
    _max2118_write_regs.f_dac = std::clip<int>(int((((bandwidth*_max2118_write_regs.m_divider)/ref_clock) - 4)/0.145),0,127);
490

    
491
    //determine actual bandwidth
492
    _bandwidth = float((ref_clock/(_max2118_write_regs.m_divider))*(4+0.145*_max2118_write_regs.f_dac));
493

    
494
    if (dbsrx_debug) std::cerr << boost::format(
495
        "DBSRX Filter Bandwidth: %f MHz, m: %d, f_dac: %d\n"
496
    ) % (_bandwidth/1e6) % int(_max2118_write_regs.m_divider) % int(_max2118_write_regs.f_dac) << std::endl;
497

    
498
    this->send_reg(0x3, 0x4);
499
}
500

    
501
/***********************************************************************
502
 * RX Get and Set
503
 **********************************************************************/
504
void dbsrx::rx_get(const wax::obj &key_, wax::obj &val){
505
    wax::obj key; std::string name;
506
    boost::tie(key, name) = extract_named_prop(key_);
507

    
508
    //handle the get request conditioned on the key
509
    switch(key.as<subdev_prop_t>()){
510
    case SUBDEV_PROP_NAME:
511
        val = get_rx_id().to_pp_string();
512
        return;
513

    
514
    case SUBDEV_PROP_OTHERS:
515
        val = prop_names_t(); //empty
516
        return;
517

    
518
    case SUBDEV_PROP_GAIN:
519
        assert_has(_gains.keys(), name, "dbsrx gain name");
520
        val = _gains[name];
521
        return;
522

    
523
    case SUBDEV_PROP_GAIN_RANGE:
524
        assert_has(dbsrx_gain_ranges.keys(), name, "dbsrx gain name");
525
        val = dbsrx_gain_ranges[name];
526
        return;
527

    
528
    case SUBDEV_PROP_GAIN_NAMES:
529
        val = prop_names_t(dbsrx_gain_ranges.keys());
530
        return;
531

    
532
    case SUBDEV_PROP_FREQ:
533
        val = _lo_freq;
534
        return;
535

    
536
    case SUBDEV_PROP_FREQ_RANGE:
537
        val = dbsrx_freq_range;
538
        return;
539

    
540
    case SUBDEV_PROP_ANTENNA:
541
        val = std::string("J3");
542
        return;
543

    
544
    case SUBDEV_PROP_ANTENNA_NAMES:
545
        val = dbsrx_antennas;
546
        return;
547

    
548
/*
549
    case SUBDEV_PROP_QUADRATURE:
550
        val = true;
551
        return;
552

553
    case SUBDEV_PROP_IQ_SWAPPED:
554
        val = false;
555
        return;
556

557
    case SUBDEV_PROP_SPECTRUM_INVERTED:
558
        val = false;
559
        return;
560
*/
561
    case SUBDEV_PROP_CONNECTION:
562
        val = SUBDEV_CONN_COMPLEX_IQ;
563
        return;
564

    
565
    case SUBDEV_PROP_USE_LO_OFFSET:
566
        val = false;
567
        return;
568

    
569
    case SUBDEV_PROP_LO_LOCKED:
570
        val = this->get_locked();
571
        return;
572

    
573
/*
574
    case SUBDEV_PROP_RSSI:
575
        val = this->get_rssi();
576
        return;
577
*/
578

    
579
    case SUBDEV_PROP_BANDWIDTH:
580
        val = _bandwidth;
581
        return;
582

    
583
    default: UHD_THROW_PROP_GET_ERROR();
584
    }
585
}
586

    
587
void dbsrx::rx_set(const wax::obj &key_, const wax::obj &val){
588
    wax::obj key; std::string name;
589
    boost::tie(key, name) = extract_named_prop(key_);
590

    
591
    //handle the get request conditioned on the key
592
    switch(key.as<subdev_prop_t>()){
593

    
594
    case SUBDEV_PROP_FREQ:
595
        this->set_lo_freq(val.as<double>());
596
        return;
597

    
598
    case SUBDEV_PROP_GAIN:
599
        this->set_gain(val.as<float>(), name);
600
        return;
601

    
602
    case SUBDEV_PROP_BANDWIDTH:
603
        this->set_bandwidth(val.as<float>());
604
        return;
605

    
606
    default: UHD_THROW_PROP_SET_ERROR();
607
    }
608
}
609