Add rxdspno parameter to private interface of quadradio.
[debian/gnuradio] / vrt / include / vrt / quadradio.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2009 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 #ifndef INCLUDED_VRT_QUADRADIO_H
22 #define INCLUDED_VRT_QUADRADIO_H
23
24 #include <vrt/rx.h>
25
26 #include <arpa/inet.h>
27 #include <netinet/in.h>
28 #include <sys/types.h>
29 #include <sys/socket.h>
30
31 typedef enum{
32     VRT_TEST_SIG_NORMAL=0,
33     VRT_TEST_SIG_ZEROS=1,
34     VRT_TEST_SIG_ONES=2,
35     VRT_TEST_SIG_TOGGLE=3,
36     VRT_TEST_SIG_RAMP=4,
37     VRT_TEST_SIG_CUSTOM=5,  
38       
39     } vrt_test_sig_t;
40
41 typedef enum{
42     VRT_BAND_SEL_A='A',
43     VRT_BAND_SEL_B='B',
44     VRT_BAND_SEL_C='C',
45     VRT_BAND_SEL_D='D',  
46       
47     } vrt_band_sel_t;
48
49 namespace vrt {
50
51   /*
52    * We're not committing to this interface.  It's just here so we can make progress...
53    *
54    * This implements the ad-hoc control for bringup and has-a vrt::rx
55    */
56   class quadradio
57   {
58     int            d_ctrl_fd;          // socket for control
59     struct in_addr d_ctrl_port_inaddr; // our ip addr
60     int            d_data_fd;          // socket for data (owned by d_rx)
61     int            d_data_port;        // our data port number
62     vrt::rx::sptr  d_rx;               // has-a rx
63     
64     vrt_band_sel_t                 d_band_select;              // band select setting
65     int            d_rx_antenna;               // antenna type rf/cal
66     int            d_attenuation0;             // attenuation setting
67     int            d_attenuation1;             // attenuation setting
68     bool           d_10dB_atten;               // 10dB attenuation on/of
69
70     static bool
71     open_sockets(const char *quad_radio_ip, int quad_radio_ctrl_port,
72                  int *ctrl_fd_ptr, struct in_addr *ctrl_port_inaddr,
73                  int *data_fd_ptr, int *data_port_ptr);
74
75     // dsprxno selects the Rx DSP pipe (0 or 1) to configure
76     static bool
77     send_rx_command(int ctrl_fd, int rxdspno, bool start,
78                     struct in_addr addr, int data_port, int samples_per_pkt);
79
80     // dsprxno selects the Rx DSP pipe (0 or 1) to stop
81     static bool
82     send_stop_rx_command(int ctrl_fd, int rxdspno);
83     
84     static int control_port() { return 790; }
85     int data_socket_fd() const { return d_data_fd; }
86
87     bool open(const char *ip);
88     
89     void update_dboard_pins(void);
90
91   public:
92     typedef boost::shared_ptr<quadradio> sptr;
93
94     quadradio(const std::string &ip, size_t rx_bufsize = 0);
95     ~quadradio();
96
97     vrt::rx::sptr vrt_rx() const { return d_rx; }
98
99     // FIXME add rxdspno as the first parameter
100     bool start_streaming(int samples_per_pkt = 0);
101
102     // FIXME add rxdspno as the first parameter
103     bool stop_streaming();
104
105     /* convenience methods that ultimately write the dboard pins */
106     bool set_center_freq(double target_freq);
107     bool set_band_select(vrt_band_sel_t band);
108     vrt_band_sel_t get_band_select(void){return d_band_select;}
109     //void set_10dB_atten(bool on);
110     bool set_attenuation0(int attenuation);
111     bool select_rx_antenna(const std::string &ant);
112     bool set_attenuation1(int attenuation);
113     
114     /* convenience methods that ultimately call set_hsadc_conf */
115     void set_adc_gain(bool on);
116     void set_dc_offset_comp(bool on);
117     void set_digital_gain(float gain);
118     void set_test_signal(vrt_test_sig_t type);
119     
120     /* primitives */
121     bool set_setting_reg(int regno, int value);
122     bool set_mem32(int addr, int value);        // poke a 32-bit value
123     bool set_lo_freq(double freq);
124     bool set_cal_freq(double freq);
125     bool set_beamforming(int32_t gains[8]);
126     bool set_cal_enb(bool enb);
127     /*
128      * The first parameter for these is a bitmask which indicates which
129      * daughterboard or daughterboards to apply the operation to.
130      * 0x1      -> dboard 0
131      * 0x2      -> dboard 1
132      * 0x3      -> dboard 0 and 1...
133      */
134     bool set_dboard_pins(int dboard_bitmask, int v);
135     bool set_hsadc_conf(int dboard_bitmask, int regno, int value);
136     bool set_lsdac(int dboard_bitmask, int which_dac, int value);
137
138   };
139
140 };
141
142
143 #endif /* INCLUDED_QUADRADIO_H */