From 0b886ba5b47dafb992f17312967900b0da7c7482 Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan Date: Fri, 28 Oct 2022 16:00:37 +0530 Subject: [PATCH] remove soapy SDR support --- Makefile | 32 +-- actions.c | 57 ----- adc.h | 3 - ant_menu.c | 60 ----- audio.c | 6 - band.c | 84 ------- band.h | 11 - client_server.c | 5 - discovered.h | 38 ---- discovery.c | 22 -- exit_menu.c | 23 -- general_menu.c | 15 -- main.c | 8 - meter.c | 12 - new_menu.c | 5 - portaudio.c | 9 - protocols.c | 25 --- protocols.h | 3 - pulseaudio.c | 6 - radio.c | 245 --------------------- radio_menu.c | 249 --------------------- receiver.c | 35 --- rx_menu.c | 34 --- rx_panadapter.c | 12 - sliders.c | 22 -- soapy_discovery.c | 319 --------------------------- soapy_discovery.h | 25 --- soapy_protocol.c | 550 ---------------------------------------------- soapy_protocol.h | 52 ----- transmitter.c | 32 --- version.c | 5 +- vfo.c | 15 -- 32 files changed, 8 insertions(+), 2011 deletions(-) delete mode 100644 soapy_discovery.c delete mode 100644 soapy_discovery.h delete mode 100644 soapy_protocol.c delete mode 100644 soapy_protocol.h diff --git a/Makefile b/Makefile index 70c9305..83e4f6c 100644 --- a/Makefile +++ b/Makefile @@ -28,9 +28,6 @@ GPIO_INCLUDE=GPIO # uncomment the line to below include support local CW keyer LOCALCW_INCLUDE=LOCALCW -# uncomment the line below for SoapySDR -#SOAPYSDR_INCLUDE=SOAPYSDR - # uncomment the line to below include support for sx1509 i2c expander #SX1509_INCLUDE=sx1509 @@ -95,21 +92,6 @@ ozyio.o endif -ifeq ($(SOAPYSDR_INCLUDE),SOAPYSDR) -SOAPYSDR_OPTIONS=-D SOAPYSDR -SOAPYSDRLIBS=-lSoapySDR -SOAPYSDR_SOURCES= \ -soapy_discovery.c \ -soapy_protocol.c -SOAPYSDR_HEADERS= \ -soapy_discovery.h \ -soapy_protocol.h -SOAPYSDR_OBJS= \ -soapy_discovery.o \ -soapy_protocol.o -endif - - ifeq ($(LOCALCW_INCLUDE),LOCALCW) LOCALCW_OPTIONS=-D LOCALCW LOCALCW_SOURCES= iambic.c @@ -176,7 +158,7 @@ endif //CFLAGS= -g -Wno-deprecated-declarations -O3 CFLAGS= -g -Wno-deprecated-declarations OPTIONS=$(SMALL_SCREEN_OPTIONS) $(MIDI_OPTIONS) $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_OPTIONS) \ - $(GPIO_OPTIONS) $(GPIOD_OPTIONS) $(SOAPYSDR_OPTIONS) $(LOCALCW_OPTIONS) \ + $(GPIO_OPTIONS) $(GPIOD_OPTIONS) $(LOCALCW_OPTIONS) \ $(PTT_OPTIONS) \ $(SERVER_OPTIONS) \ $(AUDIO_OPTIONS) \ @@ -187,7 +169,7 @@ ifeq ($(UNAME_S), Linux) RT_OPTION=-lrt endif -LIBS=$(RT_OPTION) -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(GTKLIBS) $(GPIO_LIBS) $(SOAPYSDRLIBS) $(MIDI_LIBS) +LIBS=$(RT_OPTION) -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(GTKLIBS) $(GPIO_LIBS) $(MIDI_LIBS) INCLUDES=$(GTKINCLUDES) COMPILE=$(CC) $(CFLAGS) $(OPTIONS) $(INCLUDES) @@ -430,19 +412,19 @@ encoder_menu.o \ switch_menu.o \ toolbar_menu.o -$(PROGRAM): $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(SOAPYSDR_OBJS) \ +$(PROGRAM): $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) \ $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \ $(MIDI_OBJS) $(SERVER_OBJS) $(LINK) -o $(PROGRAM) $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) \ - $(SOAPYSDR_OBJS) $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \ + $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \ $(MIDI_OBJS) $(SERVER_OBJS) $(LIBS) .PHONY: all -all: prebuild $(PROGRAM) $(HEADERS) $(AUDIO_HEADERS) $(USBOZY_HEADERS) $(SOAPYSDR_HEADERS) \ +all: prebuild $(PROGRAM) $(HEADERS) $(AUDIO_HEADERS) $(USBOZY_HEADERS) \ $(LOCALCW_HEADERS) \ $(PURESIGNAL_HEADERS) $(MIDI_HEADERS) $(SERVER_HEADERS) \ $(AUDIO_SOURCES) $(SOURCES) \ - $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(LOCALCW_SOURCE) \ + $(USBOZY_SOURCES) $(LOCALCW_SOURCE) \ $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(SERVER_SOURCES) .PHONY: prebuild @@ -461,7 +443,7 @@ CPPINCLUDES:=$(shell echo $(INCLUDES) | sed -e "s/-pthread / /" ) .PHONY: cppcheck cppcheck: cppcheck $(CPPOPTIONS) $(OPTIONS) $(CPPINCLUDES) $(AUDIO_SOURCES) $(SOURCES) $(REMOTE_SOURCES) \ - $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) \ + $(USBOZY_SOURCES) \ $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(LOCALCW_SOURCES) \ $(SERVER_SOURCES) diff --git a/actions.c b/actions.c index cf123d8..06be50e 100644 --- a/actions.c +++ b/actions.c @@ -346,18 +346,6 @@ int process_action(void *data) { vfo_band_changed(active_receiver->id,band12); } break; -#ifdef SOAPYSDR - case BAND_1240: - if(a->mode==PRESSED) { - vfo_band_changed(active_receiver->id,band1240); - } - break; - case BAND_144: - if(a->mode==PRESSED) { - vfo_band_changed(active_receiver->id,band144); - } - break; -#endif case BAND_15: if(a->mode==PRESSED) { vfo_band_changed(active_receiver->id,band15); @@ -378,42 +366,16 @@ int process_action(void *data) { vfo_band_changed(active_receiver->id,band20); } break; -#ifdef SOAPYSDR - case BAND_220: - if(a->mode==PRESSED) { - vfo_band_changed(active_receiver->id,band220); - } - break; - case BAND_2300: - if(a->mode==PRESSED) { - vfo_band_changed(active_receiver->id,band2300); - } - break; -#endif case BAND_30: if(a->mode==PRESSED) { vfo_band_changed(active_receiver->id,band30); } break; -#ifdef SOAPYSDR - case BAND_3400: - if(a->mode==PRESSED) { - vfo_band_changed(active_receiver->id,band3400); - } - break; -#endif case BAND_40: if(a->mode==PRESSED) { vfo_band_changed(active_receiver->id,band40); } break; -#ifdef SOAPYSDR - case BAND_430: - if(a->mode==PRESSED) { - vfo_band_changed(active_receiver->id,band430); - } - break; -#endif case BAND_6: if(a->mode==PRESSED) { vfo_band_changed(active_receiver->id,band6); @@ -424,30 +386,11 @@ int process_action(void *data) { vfo_band_changed(active_receiver->id,band60); } break; -#ifdef SOAPYSDR - case BAND_70: - if(a->mode==PRESSED) { - vfo_band_changed(active_receiver->id,band70); - } - break; -#endif case BAND_80: if(a->mode==PRESSED) { vfo_band_changed(active_receiver->id,band80); } break; -#ifdef SOAPYSDR - case BAND_902: - if(a->mode==PRESSED) { - vfo_band_changed(active_receiver->id,band902); - } - break; - case BAND_AIR: - if(a->mode==PRESSED) { - vfo_band_changed(active_receiver->id,bandAIR); - } - break; -#endif case BAND_GEN: if(a->mode==PRESSED) { vfo_band_changed(active_receiver->id,bandGen); diff --git a/adc.h b/adc.h index f0a14b4..7a1b5ca 100644 --- a/adc.h +++ b/adc.h @@ -68,9 +68,6 @@ typedef struct _adc { gdouble gain; gdouble min_gain; gdouble max_gain; -#ifdef SOAPYSDR - gboolean agc; -#endif } ADC; #endif diff --git a/ant_menu.c b/ant_menu.c index be686d7..fdd0700 100644 --- a/ant_menu.c +++ b/ant_menu.c @@ -29,10 +29,6 @@ #include "band.h" #include "radio.h" #include "new_protocol.h" -#ifdef SOAPYSDR -#include "soapy_protocol.h" -#endif - static GtkWidget *parent_window=NULL; static GtkWidget *menu_b=NULL; @@ -76,10 +72,6 @@ static void adc0_antenna_cb(GtkComboBox *widget,gpointer data) { adc->antenna=gtk_combo_box_get_active(widget); if(radio->protocol==NEW_PROTOCOL) { schedule_high_priority(); -#ifdef SOAPYSDR - } else if(radio->device==SOAPYSDR_USB_DEVICE) { - soapy_protocol_set_rx_antenna(receiver[0],adc[0].antenna); -#endif } } @@ -88,10 +80,6 @@ static void dac0_antenna_cb(GtkComboBox *widget,gpointer data) { dac->antenna=gtk_combo_box_get_active(widget); if(radio->protocol==NEW_PROTOCOL) { schedule_high_priority(); -#ifdef SOAPYSDR - } else if(radio->device==SOAPYSDR_USB_DEVICE) { - soapy_protocol_set_tx_antenna(transmitter,dac->antenna); -#endif } } @@ -330,9 +318,6 @@ void ant_menu(GtkWidget *parent) { g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL); gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1); -#ifdef SOAPYSDR - if(radio->device!=SOAPYSDR_USB_DEVICE) { -#endif GtkWidget *hf_rb=gtk_radio_button_new_with_label(NULL,"HF"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hf_rb),TRUE); g_signal_connect(hf_rb,"toggled",G_CALLBACK(hf_rb_cb),NULL); @@ -342,10 +327,6 @@ void ant_menu(GtkWidget *parent) { g_signal_connect(xvtr_rb,"toggled",G_CALLBACK(xvtr_rb_cb),NULL); gtk_grid_attach(GTK_GRID(grid),xvtr_rb,2,0,1,1); -#ifdef SOAPYSDR - } -#endif - if ((protocol == NEW_PROTOCOL && (device == NEW_DEVICE_HERMES || device == NEW_DEVICE_ANGELIA || device == NEW_DEVICE_ORION)) || (protocol == ORIGINAL_PROTOCOL && (device == DEVICE_HERMES || device == DEVICE_ANGELIA || device == DEVICE_ORION))) { @@ -431,47 +412,6 @@ void ant_menu(GtkWidget *parent) { show_hf(); } -#ifdef SOAPYSDR - if(radio->device==SOAPYSDR_USB_DEVICE) { - int i; - -g_print("rx_antennas=%ld\n",radio->info.soapy.rx_antennas); - if(radio->info.soapy.rx_antennas>0) { - GtkWidget *antenna_label=gtk_label_new(NULL); - gtk_label_set_markup(GTK_LABEL(antenna_label), "RX Antenna:"); - gtk_grid_attach(GTK_GRID(grid),antenna_label,0,1,1,1); - adc0_antenna_combo_box=gtk_combo_box_text_new(); - - for(i=0;iinfo.soapy.rx_antennas;i++) { - gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(adc0_antenna_combo_box),NULL,radio->info.soapy.rx_antenna[i]); - } - - gtk_combo_box_set_active(GTK_COMBO_BOX(adc0_antenna_combo_box),adc[0].antenna); - g_signal_connect(adc0_antenna_combo_box,"changed",G_CALLBACK(adc0_antenna_cb),&adc[0]); - gtk_grid_attach(GTK_GRID(grid),adc0_antenna_combo_box,1,1,1,1); - } - - if(can_transmit) { - g_print("tx_antennas=%ld\n",radio->info.soapy.tx_antennas); - if(radio->info.soapy.tx_antennas>0) { - GtkWidget *antenna_label=gtk_label_new(NULL); - gtk_label_set_markup(GTK_LABEL(antenna_label), "TX Antenna:"); - gtk_grid_attach(GTK_GRID(grid),antenna_label,0,2,1,1); - dac0_antenna_combo_box=gtk_combo_box_text_new(); - - for(i=0;iinfo.soapy.tx_antennas;i++) { - gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(dac0_antenna_combo_box),NULL,radio->info.soapy.tx_antenna[i]); - } - - gtk_combo_box_set_active(GTK_COMBO_BOX(dac0_antenna_combo_box),dac[0].antenna); - g_signal_connect(dac0_antenna_combo_box,"changed",G_CALLBACK(dac0_antenna_cb),&dac[0]); - gtk_grid_attach(GTK_GRID(grid),dac0_antenna_combo_box,1,2,1,1); - } - } - - } -#endif - gtk_container_add(GTK_CONTAINER(content),grid); sub_menu=dialog; diff --git a/audio.c b/audio.c index bcf38a6..e6cda8c 100644 --- a/audio.c +++ b/audio.c @@ -43,9 +43,6 @@ #include "mode.h" #include "new_protocol.h" #include "old_protocol.h" -#ifdef SOAPYSDR -#include "soapy_protocol.h" -#endif #include "vfo.h" int audio = 0; @@ -509,9 +506,6 @@ g_print("mic_read_thread: snd_pcm_start\n"); switch(protocol) { case ORIGINAL_PROTOCOL: case NEW_PROTOCOL: -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: -#endif // // put sample into ring buffer // diff --git a/band.c b/band.c index de1712e..9ba0261 100644 --- a/band.c +++ b/band.c @@ -127,59 +127,6 @@ BANDSTACK_ENTRY bandstack_entries6[] = {50125000LL,modeUSB,filterF5,200,2800,200,2800}, {50200000LL,modeUSB,filterF5,200,2800,200,2800}}; -#ifdef SOAPYSDR -BANDSTACK_ENTRY bandstack_entries70[] = - {{70010000LL,modeCWU,filterF6,200,2800,200,2800}, - {70200000LL,modeUSB,filterF5,200,2800,200,2800}, - {70250000LL,modeUSB,filterF5,200,2800,200,2800}}; - -BANDSTACK_ENTRY bandstack_entries144[] = - {{144010000LL,modeCWU,filterF6,200,2800,200,2800}, - {144200000LL,modeUSB,filterF5,200,2800,200,2800}, - {144250000LL,modeUSB,filterF5,200,2800,200,2800}, - {145600000LL,modeFMN,filterF1,200,2800,200,2800}, - {145725000LL,modeFMN,filterF1,200,2800,200,2800}, - {145900000LL,modeFMN,filterF1,200,2800,200,2800}}; - -BANDSTACK_ENTRY bandstack_entries220[] = - {{220010000LL,modeCWU,filterF6,200,2800,200,2800}, - {220200000LL,modeUSB,filterF5,200,2800,200,2800}, - {220250000LL,modeUSB,filterF5,200,2800,200,2800}}; - -BANDSTACK_ENTRY bandstack_entries430[] = - {{430010000LL,modeCWU,filterF6,200,2800,200,2800}, - {432100000LL,modeUSB,filterF5,200,2800,200,2800}, - {432300000LL,modeUSB,filterF5,200,2800,200,2800}}; - -BANDSTACK_ENTRY bandstack_entries902[] = - {{902010000LL,modeCWU,filterF6,200,2800,200,2800}, - {902100000LL,modeUSB,filterF5,200,2800,200,2800}, - {902300000LL,modeUSB,filterF5,200,2800,200,2800}}; - -BANDSTACK_ENTRY bandstack_entries1240[] = - {{1240010000LL,modeCWU,filterF6,200,2800,200,2800}, - {1240100000LL,modeUSB,filterF5,200,2800,200,2800}, - {1240300000LL,modeUSB,filterF5,200,2800,200,2800}}; - -BANDSTACK_ENTRY bandstack_entries2300[] = - {{2300010000LL,modeCWU,filterF6,200,2800,200,2800}, - {2300100000LL,modeUSB,filterF5,200,2800,200,2800}, - {2300300000LL,modeUSB,filterF5,200,2800,200,2800}}; - -BANDSTACK_ENTRY bandstack_entries3400[] = - {{3400010000LL,modeCWU,filterF6,200,2800,200,2800}, - {3400100000LL,modeUSB,filterF5,200,2800,200,2800}, - {3400300000LL,modeUSB,filterF5,200,2800,200,2800}}; - -BANDSTACK_ENTRY bandstack_entriesAIR[] = - {{118800000LL,modeAM,filterF3,200,2800,200,2800}, - {120000000LL,modeAM,filterF3,200,2800,200,2800}, - {121700000LL,modeAM,filterF3,200,2800,200,2800}, - {124100000LL,modeAM,filterF3,200,2800,200,2800}, - {126600000LL,modeAM,filterF3,200,2800,200,2800}, - {136500000LL,modeAM,filterF3,200,2800,200,2800}}; -#endif - BANDSTACK_ENTRY bandstack_entriesGEN[] = {{909000LL,modeAM,filterF3,-6000,6000,-6000,60000}, {5975000LL,modeAM,filterF3,-6000,6000,-6000,60000}, @@ -203,17 +150,6 @@ BANDSTACK bandstack15={3,1,bandstack_entries15}; BANDSTACK bandstack12={3,1,bandstack_entries12}; BANDSTACK bandstack10={3,1,bandstack_entries10}; BANDSTACK bandstack6={3,1,bandstack_entries6}; -#ifdef SOAPYSDR -BANDSTACK bandstack70={3,1,bandstack_entries70}; -BANDSTACK bandstack144={6,1,bandstack_entries144}; -BANDSTACK bandstack220={3,1,bandstack_entries220}; -BANDSTACK bandstack430={3,1,bandstack_entries430}; -BANDSTACK bandstack902={3,1,bandstack_entries902}; -BANDSTACK bandstack1240={3,1,bandstack_entries1240}; -BANDSTACK bandstack2300={3,1,bandstack_entries2300}; -BANDSTACK bandstack3400={3,1,bandstack_entries3400}; -BANDSTACK bandstackAIR={6,1,bandstack_entriesAIR}; -#endif BANDSTACK bandstackGEN={3,1,bandstack_entriesGEN}; BANDSTACK bandstackWWV={5,1,bandstack_entriesWWV}; BANDSTACK bandstack136={2,0,bandstack_entries136}; @@ -283,17 +219,6 @@ BAND bands[BANDS+XVTRS] = {"12",&bandstack12,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,24890000LL,24990000LL,0LL,0LL,0}, {"10",&bandstack10,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,28000000LL,29700000LL,0LL,0LL,0}, {"6",&bandstack6,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,50000000LL,54000000LL,0LL,0LL,0}, -#ifdef SOAPYSDR - {"4",&bandstack144,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,70000000LL,70500000LL,0LL,0LL,0}, - {"144",&bandstack144,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,144000000LL,148000000LL,0LL,0LL,0}, - {"220",&bandstack144,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,222000000LL,224980000LL,0LL,0LL,0}, - {"430",&bandstack430,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,420000000LL,450000000LL,0LL,0LL,0}, - {"902",&bandstack430,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,902000000LL,928000000LL,0LL,0LL,0}, - {"1240",&bandstack1240,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,1240000000LL,1300000000LL,0LL,0LL,0}, - {"2300",&bandstack2300,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,2300000000LL,2450000000LL,0LL,0LL,0}, - {"3400",&bandstack3400,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,3400000000LL,3410000000LL,0LL,0LL,0}, - {"AIR",&bandstack3400,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,108000000LL,137000000LL,0LL,0LL,0}, -#endif {"WWV",&bandstackWWV,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0}, {"GEN",&bandstackGEN,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0}, // XVTRS @@ -712,18 +637,12 @@ int canTransmit() { // if(info_band!=bandGen && info_band!=bandWWV -#ifdef SOAPYSDR - && info_band!=bandAIR -#endif ) { result=TRUE; } if (txb == bandGen || txb ==bandWWV -#ifdef SOAPYSDR - || txb ==bandAIR -#endif ) return 0; // @@ -779,9 +698,6 @@ int canTransmit() { if (tx_out_of_band) return TRUE; if(info_band!=bandGen && info_band!=bandWWV -#ifdef SOAPYSDR - && info_band!=bandAIR -#endif ) { result=TRUE; } diff --git a/band.h b/band.h index b312440..5fa15df 100644 --- a/band.h +++ b/band.h @@ -37,17 +37,6 @@ enum { band12, band10, band6, -#ifdef SOAPYSDR - band70, - band144, - band220, - band430, - band902, - band1240, - band2300, - band3400, - bandAIR, -#endif bandWWV, bandGen, BANDS diff --git a/client_server.c b/client_server.c index 5692538..4b16aaa 100644 --- a/client_server.c +++ b/client_server.c @@ -1867,11 +1867,6 @@ g_print("INFO_RADIO: %d\n",bytes_read); radio->supported_receivers=ntohs(radio_data.supported_receivers); temp=ntohll(radio_data.sample_rate); radio_sample_rate=(int)temp; -#ifdef SOAPYSDR - if(protocol==SOAPYSDR_PROTOCOL) { - radio->info.soapy.sample_rate=(int)temp; - } -#endif display_filled=radio_data.display_filled; locked=radio_data.locked; receivers=ntohs(radio_data.receivers); diff --git a/discovered.h b/discovered.h index 921bd7b..347a29b 100644 --- a/discovered.h +++ b/discovered.h @@ -21,9 +21,6 @@ #define _DISCOVERED_H #include -#ifdef SOAPYSDR -#include -#endif #define MAX_DEVICES 16 @@ -53,18 +50,11 @@ #define NEW_DEVICE_HERMES_LITE 6 #define NEW_DEVICE_HERMES_LITE2 1006 -#ifdef SOAPYSDR -#define SOAPYSDR_USB_DEVICE 2000 -#endif - #define STATE_AVAILABLE 2 #define STATE_SENDING 3 #define ORIGINAL_PROTOCOL 0 #define NEW_PROTOCOL 1 -#ifdef SOAPYSDR -#define SOAPYSDR_PROTOCOL 2 -#endif struct _DISCOVERED { int protocol; @@ -89,34 +79,6 @@ struct _DISCOVERED { struct sockaddr_in interface_netmask; char interface_name[64]; } network; -#ifdef SOAPYSDR - struct soapy { - char version[128]; - char hardware_key[64]; - char driver_key[64]; - int rtlsdr_count; - int sdrplay_count; - int sample_rate; - size_t rx_channels; - size_t rx_gains; - char **rx_gain; - SoapySDRRange *rx_range; - gboolean rx_has_automatic_gain; - gboolean rx_has_automatic_dc_offset_correction; - size_t rx_antennas; - char **rx_antenna; - size_t tx_channels; - size_t tx_gains; - char **tx_gain; - SoapySDRRange *tx_range; - size_t tx_antennas; - char **tx_antenna; - size_t sensors; - char **sensor; - gboolean has_temp; - char address[64]; - } soapy; -#endif } info; }; diff --git a/discovery.c b/discovery.c index eda110d..6a46c16 100644 --- a/discovery.c +++ b/discovery.c @@ -37,9 +37,6 @@ #include "discovered.h" #include "old_discovery.h" #include "new_discovery.h" -#ifdef SOAPYSDR -#include "soapy_discovery.h" -#endif #include "main.h" #include "radio.h" #ifdef USBOZY @@ -310,13 +307,6 @@ void discovery() { /* new_discovery(); */ /* } */ -#ifdef SOAPYSDR - if(enable_soapy_protocol) { - status_text("SoapySDR ... Discovering Devices"); - soapy_discovery(); - } -#endif - status_text("Discovery"); fprintf(stderr,"discovery: found %d devices\n", devices); @@ -384,12 +374,6 @@ fprintf(stderr,"%p Protocol=%d name=%s\n",d,d->protocol,d->name); } #endif break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - sprintf(text,"%s (Protocol SOAPY_SDR %s) on %s",d->name,d->info.soapy.version,d->info.soapy.address); - break; - -#endif } GtkWidget *label=gtk_label_new(text); @@ -410,17 +394,11 @@ fprintf(stderr,"%p Protocol=%d name=%s\n",d,d->protocol,d->name); gtk_widget_set_sensitive(start_button, FALSE); } -#ifdef SOAPYSDR - if(d->device!=SOAPYSDR_USB_DEVICE) { -#endif // if not on the same subnet then cannot start it if((d->info.network.interface_address.sin_addr.s_addr&d->info.network.interface_netmask.sin_addr.s_addr) != (d->info.network.address.sin_addr.s_addr&d->info.network.interface_netmask.sin_addr.s_addr)) { gtk_button_set_label(GTK_BUTTON(start_button),"Subnet!"); gtk_widget_set_sensitive(start_button, FALSE); } -#ifdef SOAPYSDR - } -#endif } } diff --git a/exit_menu.c b/exit_menu.c index 2c24ce0..7546ea2 100644 --- a/exit_menu.c +++ b/exit_menu.c @@ -29,9 +29,6 @@ #include "radio.h" #include "new_protocol.h" #include "old_protocol.h" -#ifdef SOAPYSDR -#include "soapy_protocol.h" -#endif #include "actions.h" #ifdef GPIO #include "gpio.h" @@ -63,11 +60,6 @@ static gboolean discovery_cb (GtkWidget *widget, GdkEventButton *event, gpointer case NEW_PROTOCOL: new_protocol_stop(); break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - soapy_protocol_stop(); - break; -#endif } radioSaveState(); radio_stop(); @@ -103,11 +95,6 @@ g_print("exit_cb\n"); case NEW_PROTOCOL: new_protocol_stop(); break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - soapy_protocol_stop(); - break; -#endif } #ifdef CLIENT_SERVER } @@ -128,11 +115,6 @@ static gboolean reboot_cb (GtkWidget *widget, GdkEventButton *event, gpointer da case NEW_PROTOCOL: new_protocol_stop(); break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - soapy_protocol_stop(); - break; -#endif } radioSaveState(); int rc=system("reboot"); @@ -150,11 +132,6 @@ static gboolean shutdown_cb (GtkWidget *widget, GdkEventButton *event, gpointer case NEW_PROTOCOL: new_protocol_stop(); break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - soapy_protocol_stop(); - break; -#endif } radioSaveState(); int rc=system("shutdown -h -P now"); diff --git a/general_menu.c b/general_menu.c index 01e173f..7f22683 100644 --- a/general_menu.c +++ b/general_menu.c @@ -269,21 +269,6 @@ void general_menu(GtkWidget *parent) { } -#ifdef SOAPYSDR - if(protocol==SOAPYSDR_PROTOCOL) { - GtkWidget *sample_rate_1M=gtk_radio_button_new_with_label(NULL,"1000000"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_1M), sample_rate==1000000); - gtk_grid_attach(GTK_GRID(grid),sample_rate_1M,0,2,1,1); - g_signal_connect(sample_rate_1M,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)1000000); - - GtkWidget *sample_rate_2M=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate_1M),"2000000"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_2M), sample_rate==2000000); - gtk_grid_attach(GTK_GRID(grid),sample_rate_2M,0,3,1,1); - g_signal_connect(sample_rate_2M,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)2000000); - - } -#endif - GtkWidget *rit_label=gtk_label_new("RIT step: "); gtk_grid_attach(GTK_GRID(grid),rit_label,5,1,1,1); diff --git a/main.c b/main.c index d81d05e..b427f82 100644 --- a/main.c +++ b/main.c @@ -57,9 +57,6 @@ #include "discovery.h" #include "new_protocol.h" #include "old_protocol.h" -#ifdef SOAPYSDR -#include "soapy_protocol.h" -#endif #include "css.h" #include "ext.h" #include "vfo.h" @@ -160,11 +157,6 @@ gboolean main_delete(GtkWidget *widget) { case NEW_PROTOCOL: new_protocol_stop(); break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - soapy_protocol_stop(); - break; -#endif } #ifdef CLIENT_SERVER } diff --git a/meter.c b/meter.c index 37cd946..4858720 100644 --- a/meter.c +++ b/meter.c @@ -198,12 +198,6 @@ if(analog_meter) { } else { level=value + (double)adc[rx->adc].attenuation; } -#ifdef SOAPYSDR - if(protocol==SOAPYSDR_PROTOCOL) { - //level-=rx->rf_gain; - level-=adc[rx->id].gain; - } -#endif if (filter_board == CHARLY25) { // preamp/dither encodes the preamp level if (rx->preamp) level -= 18.0; @@ -570,12 +564,6 @@ if(analog_meter) { } else { level=value+(double)adc[rx->adc].attenuation; } -#ifdef SOAPYSDR - if(protocol==SOAPYSDR_PROTOCOL) { - //level-=rx->rf_gain; - level-=adc[rx->id].gain; - } -#endif if (filter_board == CHARLY25) { // preamp/dither encodes the preamp level if (rx->preamp) level -= 18.0; diff --git a/new_menu.c b/new_menu.c index e660c1d..e5c1aca 100644 --- a/new_menu.c +++ b/new_menu.c @@ -126,11 +126,6 @@ static gboolean restart_cb (GtkWidget *widget, GdkEventButton *event, gpointer d case NEW_PROTOCOL: new_protocol_restart(); break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - // dunno how to do this for soapy - break; -#endif } return TRUE; } diff --git a/portaudio.c b/portaudio.c index ac33586..265b7ea 100644 --- a/portaudio.c +++ b/portaudio.c @@ -33,9 +33,6 @@ #include "mode.h" #include "portaudio.h" #include "audio.h" -#ifdef SOAPYSDR -#include "soapy_protocol.h" -#endif static PaStream *record_handle=NULL; @@ -236,12 +233,6 @@ int pa_mic_cb(const void *inputBuffer, void *outputBuffer, unsigned long framesP } } break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - // Note that this call ends up deeply in the TX engine - soapy_protocol_process_local_mic(sample); - break; -#endif default: break; } diff --git a/protocols.c b/protocols.c index d86e390..0b23f8b 100644 --- a/protocols.c +++ b/protocols.c @@ -35,9 +35,6 @@ static GtkWidget *dialog; gboolean enable_protocol_1; gboolean enable_protocol_2; -#ifdef SOAPYSDR -gboolean enable_soapy_protocol; -#endif gboolean autostart; void protocols_save_state() { @@ -48,10 +45,6 @@ void protocols_save_state() { setProperty("enable_protocol_1",value); sprintf(value,"%d",enable_protocol_2); setProperty("enable_protocol_2",value); -#ifdef SOAPYSDR - sprintf(value,"%d",enable_soapy_protocol); - setProperty("enable_soapy_protocol",value); -#endif sprintf(value,"%d",autostart); setProperty("autostart",value); @@ -69,11 +62,6 @@ void protocols_restore_state() { enable_protocol_2=TRUE; value=getProperty("enable_protocol_2"); if(value) enable_protocol_2=atoi(value); -#ifdef SOAPYSDR - enable_soapy_protocol=TRUE; - value=getProperty("enable_soapy_protocol"); - if(value) enable_soapy_protocol=atoi(value); -#endif autostart=TRUE; value=getProperty("autostart"); if(value) autostart=atoi(value); @@ -97,11 +85,6 @@ static void protocol_2_cb(GtkToggleButton *widget, gpointer data) { enable_protocol_2=gtk_toggle_button_get_active(widget); } -#ifdef SOAPYSDR -static void soapy_protocol_cb(GtkToggleButton *widget, gpointer data) { - enable_soapy_protocol=gtk_toggle_button_get_active(widget); -} -#endif static void autostart_cb(GtkToggleButton *widget, gpointer data) { autostart=gtk_toggle_button_get_active(widget); @@ -136,14 +119,6 @@ void configure_protocols(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),b_enable_protocol_2,0,row,1,1); row++; -#ifdef SOAPYSDR - GtkWidget *b_enable_soapy_protocol=gtk_check_button_new_with_label("Enable SoapySDR Protocol"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_soapy_protocol), enable_soapy_protocol); - gtk_widget_show(b_enable_soapy_protocol); - g_signal_connect(b_enable_soapy_protocol,"toggled",G_CALLBACK(soapy_protocol_cb),NULL); - gtk_grid_attach(GTK_GRID(grid),b_enable_soapy_protocol,0,row,1,1); - row++; -#endif GtkWidget *b_autostart=gtk_check_button_new_with_label("Auto start if only one device"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_autostart), autostart); diff --git a/protocols.h b/protocols.h index fb58301..3d3571e 100644 --- a/protocols.h +++ b/protocols.h @@ -19,9 +19,6 @@ extern gboolean enable_protocol_1; extern gboolean enable_protocol_2; -#ifdef SOAPYSDR -extern gboolean enable_soapy_protocol; -#endif extern gboolean autostart; extern void protocols_save_state(); diff --git a/pulseaudio.c b/pulseaudio.c index d4197c9..b0b6bfd 100644 --- a/pulseaudio.c +++ b/pulseaudio.c @@ -10,9 +10,6 @@ #include "mode.h" #include "new_protocol.h" #include "old_protocol.h" -#ifdef SOAPYSDR -#include "soapy_protocol.h" -#endif int n_input_devices; AUDIO_DEVICE input_devices[MAX_AUDIO_DEVICES]; @@ -193,9 +190,6 @@ static void *mic_read_thread(gpointer arg) { switch(protocol) { case ORIGINAL_PROTOCOL: case NEW_PROTOCOL: -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: -#endif // // put sample into ring buffer // diff --git a/radio.c b/radio.c index 8a1aa17..528554f 100644 --- a/radio.c +++ b/radio.c @@ -51,9 +51,6 @@ #include "receiver.h" #include "store.h" #include "transmitter.h" -#ifdef SOAPYSDR -#include "soapy_protocol.h" -#endif #include "actions.h" #include "ext.h" #include "gpio.h" @@ -685,11 +682,6 @@ static void create_visual() { case NEW_PROTOCOL: new_protocol_init(display_width); break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - soapy_protocol_init(FALSE); - break; -#endif } #ifdef CLIENT_SERVER } @@ -797,16 +789,6 @@ void start_radio() { break; } break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - if (strcmp(radio->name, "lime") == 0) { - drive_max = 64.0; - } else if (strcmp(radio->name, "plutosdr") == 0) { - drive_max = 89.0; - } - pa_power = PA_1W; - break; -#endif } switch (pa_power) { @@ -879,12 +861,6 @@ void start_radio() { break; } break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - have_rx_gain = 1; - rx_gain_calibration = 10; - break; -#endif default: have_rx_gain = 0; break; @@ -898,13 +874,6 @@ void start_radio() { case NEW_PROTOCOL: can_transmit = 1; break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - can_transmit = (radio->info.soapy.tx_channels != 0); - g_print("start_radio: can_transmit=%d tx_channels=%d\n", can_transmit, - (int)radio->info.soapy.tx_channels); - break; -#endif } // @@ -965,16 +934,6 @@ void start_radio() { sprintf(ip, "%s", inet_ntoa(radio->info.network.address.sin_addr)); sprintf(iface, "%s", radio->info.network.interface_name); break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - strcpy(p, "SoapySDR"); - sprintf(version, "v%d.%d.%d)", radio->software_version / 100, - (radio->software_version % 100) / 10, radio->software_version % 10); - strcpy(mac, ""); - strcpy(ip, ""); - strcpy(iface, ""); - break; -#endif } switch (protocol) { @@ -990,11 +949,6 @@ void start_radio() { } #endif break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - sprintf(text, "Starting %s (%s %s)", radio->name, "SoapySDR", version); - break; -#endif } status_text(text); @@ -1027,11 +981,6 @@ void start_radio() { break; } break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - sprintf(property_path, "%s.props", radio->name); - break; -#endif } switch (protocol) { @@ -1095,29 +1044,12 @@ void start_radio() { break; } break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - if (strcmp(radio->name, "lime") == 0) { - n_adc = 2; - } else { - n_adc = 1; - } - break; -#endif default: break; } iqswap = 0; -#ifdef SOAPYSDR - if (device == SOAPYSDR_USB_DEVICE) { - iqswap = 1; - receivers = 1; - filter_board = NONE; - } -#endif - /* adc_attenuation[0]=0; adc_attenuation[1]=0; @@ -1150,23 +1082,6 @@ void start_radio() { adc[0].attenuation = 0; } -#ifdef SOAPYSDR - adc[0].antenna = 0; - if (device == SOAPYSDR_USB_DEVICE) { - adc[0].gain = 0; - if (radio->info.soapy.rx_gains > 0) { - adc[0].min_gain = radio->info.soapy.rx_range[0].minimum; - adc[0].max_gain = radio->info.soapy.rx_range[0].maximum; - ; - } else { - adc[0].min_gain = 0.0; - adc[0].max_gain = 100.0; - } - adc[0].agc = FALSE; - dac[0].antenna = 1; - dac[0].gain = 0; - } -#endif adc[1].antenna = ANTENNA_1; adc[1].filters = AUTOMATIC; @@ -1180,26 +1095,6 @@ void start_radio() { } else { adc[1].attenuation = 0; } -#ifdef SOAPYSDR - adc[1].antenna = 0; - if (device == SOAPYSDR_USB_DEVICE) { - adc[1].gain = 0; - if (radio->info.soapy.rx_gains > 0) { - adc[1].min_gain = radio->info.soapy.rx_range[0].minimum; - adc[1].max_gain = radio->info.soapy.rx_range[0].maximum; - ; - } else { - adc[1].min_gain = 0.0; - adc[1].max_gain = 100.0; - } - adc[1].max_gain = 0; - adc[1].agc = FALSE; - dac[1].antenna = 1; - dac[1].gain = 0; - } - - radio_sample_rate = radio->info.soapy.sample_rate; -#endif // g_print("meter_calibration=%f display_calibration=%f\n", meter_calibration, // display_calibration); @@ -1235,18 +1130,6 @@ void start_radio() { g_print("%s: setup RECEIVERS protocol=%d\n", __FUNCTION__, protocol); switch (protocol) { -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - g_print("%s: setup RECEIVERS SOAPYSDR\n", __FUNCTION__); - RECEIVERS = 1; - MAX_RECEIVERS = RECEIVERS; -#ifdef PURESIGNAL - PS_TX_FEEDBACK = 0; - PS_RX_FEEDBACK = 0; -#endif - MAX_DDC = 1; - break; -#endif default: g_print("%s: setup RECEIVERS default\n", __FUNCTION__); RECEIVERS = 2; @@ -1282,12 +1165,6 @@ void start_radio() { if (buffer_size > 512) buffer_size = 512; break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - if (buffer_size > 2048) - buffer_size = 2048; - break; -#endif } // // Sanity Check #2: enable diversity only if there are two RX and two ADCs @@ -1319,32 +1196,6 @@ void start_radio() { schedule_high_priority(); } -#ifdef SOAPYSDR - if (protocol == SOAPYSDR_PROTOCOL) { - RECEIVER *rx = receiver[0]; - soapy_protocol_create_receiver(rx); - if (can_transmit) { - soapy_protocol_create_transmitter(transmitter); - soapy_protocol_set_tx_antenna(transmitter, dac[0].antenna); - soapy_protocol_set_tx_gain(transmitter, transmitter->drive); - soapy_protocol_set_tx_frequency(transmitter); - soapy_protocol_start_transmitter(transmitter); - } - - soapy_protocol_set_rx_antenna(rx, adc[0].antenna); - soapy_protocol_set_rx_frequency(rx, VFO_A); - soapy_protocol_set_automatic_gain(rx, adc[0].agc); - soapy_protocol_set_gain(rx); - - if (vfo[0].ctun) { - setFrequency(vfo[0].ctun_frequency); - } - soapy_protocol_start_receiver(rx); - - // g_print("radio: set rf_gain=%f\n",rx->rf_gain); - soapy_protocol_set_gain(rx); - } -#endif g_idle_add(ext_vfo_update, (gpointer)NULL); @@ -1448,12 +1299,6 @@ void radio_change_sample_rate(int rate) { tx_set_ps_sample_rate(transmitter, rate); } break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - soapy_protocol_change_sample_rate(receiver[0]); - soapy_protocol_set_mic_sample_rate(rate); - break; -#endif } } @@ -1502,21 +1347,10 @@ static void rxtx(int state) { SetChannelState(transmitter->id, 1, 0); tx_set_displaying(transmitter, 1); switch (protocol) { -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - soapy_protocol_set_tx_frequency(transmitter); - // soapy_protocol_start_transmitter(transmitter); - break; -#endif } } else { // switch to rx switch (protocol) { -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - // soapy_protocol_stop_transmitter(transmitter); - break; -#endif } SetChannelState(transmitter->id, 0, 1); tx_set_displaying(transmitter, 0); @@ -1547,10 +1381,6 @@ static void rxtx(int state) { void setMox(int state) { if (!can_transmit) return; -#ifdef SOAPYSDR - if (protocol == SOAPYSDR_PROTOCOL && !transmitter->local_microphone) - return; -#endif vox_cancel(); // remove time-out if (mox != state) { if (state && vox) { @@ -1591,31 +1421,9 @@ void frequency_changed(RECEIVER *rx) { if (vfo[0].ctun) { SetRXAShiftFreq(rx->id, (double)vfo[0].offset); RXANBPSetShiftFrequency(rx->id, (double)vfo[0].offset); -#ifdef SOAPYSDR - if (protocol == SOAPYSDR_PROTOCOL) { - /* - if(radio->can_transmit) { - if(radio->transmitter!=NULL && radio->transmitter->rx==rx) { - //soapy_protocol_set_tx_frequency(radio->transmitter); - } - } - */ - } -#endif } else { if (protocol == NEW_PROTOCOL) { schedule_high_priority(); -#ifdef SOAPYSDR - } else if (protocol == SOAPYSDR_PROTOCOL) { - soapy_protocol_set_rx_frequency(rx, VFO_A); -/* - if(radio->can_transmit) { - if(radio->transmitter!=NULL && radio->transmitter->rx==rx) { - soapy_protocol_set_tx_frequency(radio->transmitter); - } - } -*/ -#endif } vfo[0].band = get_band_from_frequency(vfo[0].frequency); } @@ -1770,9 +1578,6 @@ void setFrequency(long long f) { switch (protocol) { case NEW_PROTOCOL: case ORIGINAL_PROTOCOL: -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: -#endif if (vfo[v].ctun) { long long minf = vfo[v].frequency - (long long)(active_receiver->sample_rate / 2); @@ -1798,14 +1603,6 @@ void setFrequency(long long f) { break; case ORIGINAL_PROTOCOL: break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - if (!vfo[v].ctun) { - soapy_protocol_set_rx_frequency(active_receiver, v); - vfo[v].offset = 0; - } - break; -#endif } } @@ -1857,11 +1654,6 @@ void setDrive(double value) { case NEW_PROTOCOL: calcDriveLevel(); break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - soapy_protocol_set_tx_gain(transmitter, transmitter->drive); - break; -#endif } } @@ -1878,10 +1670,6 @@ void setSquelch(RECEIVER *rx) { } void radio_set_rf_gain(RECEIVER *rx) { -#ifdef SOAPYSDR - soapy_protocol_set_gain_element(rx, radio->info.soapy.rx_gain[rx->adc], - (int)adc[rx->adc].gain); -#endif } void set_attenuation(int value) { @@ -1889,12 +1677,6 @@ void set_attenuation(int value) { case NEW_PROTOCOL: schedule_high_priority(); break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - soapy_protocol_set_gain_element( - active_receiver, radio->info.soapy.rx_gain[0], (int)adc[0].gain); - break; -#endif } } @@ -1905,11 +1687,6 @@ void set_alex_rx_antenna(int v) { schedule_high_priority(); } } -#ifdef SOAPYSDR - if (protocol == SOAPYSDR_PROTOCOL) { - soapy_protocol_set_rx_antenna(active_receiver, v); - } -#endif } void set_alex_tx_antenna(int v) { @@ -2305,11 +2082,6 @@ void radioRestoreState() { if (value) adc[0].max_gain = atof(value); -#ifdef SOAPYSDR - if (device == SOAPYSDR_USB_DEVICE) { - value = getProperty("radio.adc[0].agc"); - } -#endif value = getProperty("radio.dac[0].antenna"); if (value) @@ -2356,11 +2128,6 @@ void radioRestoreState() { if (value) adc[1].max_gain = atof(value); -#ifdef SOAPYSDR - if (device == SOAPYSDR_USB_DEVICE) { - value = getProperty("radio.adc[1].agc"); - } -#endif value = getProperty("radio.dac[1].antenna"); if (value) @@ -2638,12 +2405,6 @@ void radioSaveState() { sprintf(value, "%f", adc[0].max_gain); setProperty("radio.adc[0].max_gain", value); -#ifdef SOAPYSDR - if (device == SOAPYSDR_USB_DEVICE) { - sprintf(value, "%d", soapy_protocol_get_automatic_gain(receiver[0])); - setProperty("radio.adc[0].agc", value); - } -#endif sprintf(value, "%d", dac[0].antenna); setProperty("radio.dac[0].antenna", value); @@ -2676,12 +2437,6 @@ void radioSaveState() { sprintf(value, "%f", adc[1].max_gain); setProperty("radio.adc[1].max_gain", value); -#ifdef SOAPYSDR - if (device == SOAPYSDR_USB_DEVICE) { - sprintf(value, "%d", soapy_protocol_get_automatic_gain(receiver[1])); - setProperty("radio.adc[1].agc", value); - } -#endif sprintf(value, "%d", dac[1].antenna); setProperty("radio.dac[1].antenna", value); diff --git a/radio_menu.c b/radio_menu.c index 1a81b99..117bc97 100644 --- a/radio_menu.c +++ b/radio_menu.c @@ -36,9 +36,6 @@ #include "sliders.h" #include "new_protocol.h" #include "old_protocol.h" -#ifdef SOAPYSDR -#include "soapy_protocol.h" -#endif #include "actions.h" #ifdef GPIO #include "gpio.h" @@ -81,91 +78,6 @@ static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_d return FALSE; } -#ifdef SOAPYSDR -static void rf_gain_value_changed_cb(GtkWidget *widget, gpointer data) { - ADC *adc=(ADC *)data; - adc->gain=gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget)); - - if(radio->device==SOAPYSDR_USB_DEVICE) { - soapy_protocol_set_gain(receiver[0]); - } -} - -static void rx_gain_value_changed_cb(GtkWidget *widget, gpointer data) { - ADC *adc=(ADC *)data; - if(radio->device==SOAPYSDR_USB_DEVICE) { - adc->gain=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); - soapy_protocol_set_gain_element(receiver[0],(char *)gtk_widget_get_name(widget),adc->gain); -/* - for(int i=0;iinfo.soapy.rx_gains;i++) { - if(strcmp(radio->info.soapy.rx_gain[i],(char *)gtk_widget_get_name(widget))==0) { - adc[0].rx_gain[i]=gain; - soapy_protocol_set_gain_element(receiver[0],(char *)gtk_widget_get_name(widget),gain); - break; - } - } -*/ - } -} - -static void drive_gain_value_changed_cb(GtkWidget *widget, gpointer data) { - DAC *dac=(DAC *)data; - if(radio->device==SOAPYSDR_USB_DEVICE) { - transmitter->drive=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); - soapy_protocol_set_tx_gain(transmitter,(double)transmitter->drive); -/* - for(int i=0;iinfo.soapy.tx_gains;i++) { - int value=soapy_protocol_get_tx_gain_element(transmitter,radio->info.soapy.tx_gain[i]); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(tx_gains[i]),(double)value); - } -*/ - } -} - -static void tx_gain_value_changed_cb(GtkWidget *widget, gpointer data) { - DAC *dac=(DAC *)data; - int gain; - if(radio->device==SOAPYSDR_USB_DEVICE) { - gain=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); - soapy_protocol_set_tx_gain_element(transmitter,(char *)gtk_widget_get_name(widget),gain); -/* - for(int i=0;iinfo.soapy.tx_gains;i++) { - if(strcmp(radio->info.soapy.tx_gain[i],(char *)gtk_widget_get_name(widget))==0) { - dac[0].tx_gain[i]=gain; - break; - } - } -*/ - } -} - - -static void agc_changed_cb(GtkWidget *widget, gpointer data) { - ADC *adc=(ADC *)data; - gboolean agc=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); - soapy_protocol_set_automatic_gain(active_receiver,agc); - if(!agc) { - soapy_protocol_set_gain(active_receiver); - } -} - -/* -static void dac0_gain_value_changed_cb(GtkWidget *widget, gpointer data) { - DAC *dac=(DAC *)data; - int gain; - if(radio->device==SOAPYSDR_USB_DEVICE) { - gain=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); - soapy_protocol_set_tx_gain_element(radio->transmitter,(char *)gtk_widget_get_name(widget),gain); - for(int i=0;idiscovered->info.soapy.tx_gains;i++) { - if(strcmp(radio->discovered->info.soapy.tx_gain[i],(char *)gtk_widget_get_name(widget))==0) { - radio->dac[0].tx_gain[i]=gain; - break; - } - } - } -} -*/ -#endif static void calibration_value_changed_cb(GtkWidget *widget, gpointer data) { calibration=(long long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); @@ -545,49 +457,6 @@ void radio_menu(GtkWidget *parent) { } break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - if(strcmp(radio->name,"sdrplay")==0) { - GtkWidget *sample_rate_combo_box=gtk_combo_box_text_new(); -// gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(sample_rate_combo_box),NULL,"96000"); -// gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(sample_rate_combo_box),NULL,"192000"); -// gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(sample_rate_combo_box),NULL,"384000"); - gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(sample_rate_combo_box),NULL,"768000"); - switch(radio_sample_rate) { - case 96000: - gtk_combo_box_set_active(GTK_COMBO_BOX(sample_rate_combo_box),0); - break; - case 192000: - gtk_combo_box_set_active(GTK_COMBO_BOX(sample_rate_combo_box),1); - break; - case 384000: - gtk_combo_box_set_active(GTK_COMBO_BOX(sample_rate_combo_box),2); - break; - case 768000: - gtk_combo_box_set_active(GTK_COMBO_BOX(sample_rate_combo_box),3); - break; - } - g_signal_connect(sample_rate_combo_box,"changed",G_CALLBACK(sample_rate_cb),radio); - gtk_grid_attach(GTK_GRID(grid),sample_rate_combo_box,col,row,1,1); - row++; - } else { - GtkWidget *sample_rate_label=gtk_label_new(NULL); - gtk_label_set_markup(GTK_LABEL(sample_rate_label), "Sample Rate:"); - gtk_grid_attach(GTK_GRID(grid),sample_rate_label,col,row,1,1); - row++; - - char rate[16]; - sprintf(rate,"%d",radio->info.soapy.sample_rate); - - GtkWidget *sample_rate=gtk_radio_button_new_with_label(NULL,rate); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate), radio->info.soapy.sample_rate); - gtk_grid_attach(GTK_GRID(grid),sample_rate,col,row,1,1); - g_signal_connect(sample_rate,"toggled",G_CALLBACK(sample_rate_cb),GINT_TO_POINTER(radio->info.soapy.sample_rate)); - - col++; - } - break; -#endif } row++; @@ -845,124 +714,6 @@ void radio_menu(GtkWidget *parent) { if(row>temp_row) temp_row=row; -#ifdef SOAPYSDR - col=0; - if(radio->device==SOAPYSDR_USB_DEVICE) { - int i; - if(radio->info.soapy.rx_gains>0) { - GtkWidget *rx_gain=gtk_label_new(NULL); - gtk_label_set_markup(GTK_LABEL(rx_gain), "RX Gains:"); - gtk_label_set_justify(GTK_LABEL(rx_gain),GTK_JUSTIFY_LEFT); - gtk_grid_attach(GTK_GRID(grid),rx_gain,col,row,1,1); - } - - if(can_transmit) { - if(radio->info.soapy.tx_gains>0) { - col=2; - GtkWidget *tx_gain=gtk_label_new(NULL); - gtk_label_set_markup(GTK_LABEL(tx_gain), "TX Gains:"); - gtk_grid_attach(GTK_GRID(grid),tx_gain,col,row,1,1); - } - } - - row++; - temp_row=row; - col=0; - if(strcmp(radio->name,"sdrplay")==0 || strcmp(radio->name,"rtlsdr")==0) { - for(i=0;iinfo.soapy.rx_gains;i++) { - col=0; - GtkWidget *rx_gain_label=gtk_label_new(radio->info.soapy.rx_gain[i]); - gtk_grid_attach(GTK_GRID(grid),rx_gain_label,col,row,1,1); - col++; - SoapySDRRange range=radio->info.soapy.rx_range[i]; - if(range.step==0.0) { - range.step=1.0; - } - rx_gains[i]=gtk_spin_button_new_with_range(range.minimum,range.maximum,range.step); - gtk_widget_set_name (rx_gains[i], radio->info.soapy.rx_gain[i]); - int value=soapy_protocol_get_gain_element(active_receiver,radio->info.soapy.rx_gain[i]); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(rx_gains[i]),(double)value); - gtk_grid_attach(GTK_GRID(grid),rx_gains[i],col,row,1,1); - g_signal_connect(rx_gains[i],"value_changed",G_CALLBACK(rx_gain_value_changed_cb),&adc[0]); - - row++; - } - } else { - // used single gain control - LimeSDR works out best setting for the 3 rx gains - col=0; - GtkWidget *rf_gain_label=gtk_label_new(NULL); - gtk_label_set_markup(GTK_LABEL(rf_gain_label), "RF Gain"); - gtk_grid_attach(GTK_GRID(grid),rf_gain_label,col,row,1,1); - col++; - double max=100; - if(strcmp(radio->name,"lime")==0) { - max=60.0; - } else if(strcmp(radio->name,"plutosdr")==0) { - max=73.0; - } - GtkWidget *rf_gain_b=gtk_spin_button_new_with_range(0.0,max,1.0); - //gtk_spin_button_set_value(GTK_SPIN_BUTTON(rf_gain_b),active_receiver->rf_gain); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(rf_gain_b),adc[active_receiver->id].gain); - gtk_grid_attach(GTK_GRID(grid),rf_gain_b,col,row,1,1); - g_signal_connect(rf_gain_b,"value_changed",G_CALLBACK(rf_gain_value_changed_cb),&adc[0]); - - row++; - } - - if(radio->info.soapy.rx_has_automatic_gain) { - GtkWidget *agc=gtk_check_button_new_with_label("Hardware AGC: "); - gtk_grid_attach(GTK_GRID(grid),agc,col,row,1,1); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(agc),adc[0].agc); - g_signal_connect(agc,"toggled",G_CALLBACK(agc_changed_cb),&adc[0]); - row++; - } - - row=temp_row; - - if(can_transmit) { -/* - //tx_gains=g_new(GtkWidget*,radio->info.soapy.tx_gains); - for(i=0;iinfo.soapy.tx_gains;i++) { - col=2; - GtkWidget *tx_gain_label=gtk_label_new(radio->info.soapy.tx_gain[i]); - gtk_grid_attach(GTK_GRID(grid),tx_gain_label,col,row,1,1); - col++; - SoapySDRRange range=radio->info.soapy.tx_range[i]; - if(range.step==0.0) { - range.step=1.0; - } - tx_gains[i]=gtk_spin_button_new_with_range(range.minimum,range.maximum,range.step); - gtk_widget_set_name (tx_gains[i], radio->info.soapy.tx_gain[i]); - int value=soapy_protocol_get_tx_gain_element(transmitter,radio->info.soapy.tx_gain[i]); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(tx_gains[i]),(double)value); - //gtk_spin_button_set_value(GTK_SPIN_BUTTON(tx_gains[i]),(double)dac[0].tx_gain[i]); - gtk_grid_attach(GTK_GRID(grid),tx_gains[i],col,row,1,1); - g_signal_connect(tx_gains[i],"value_changed",G_CALLBACK(tx_gain_value_changed_cb),&dac[0]); - - gtk_widget_set_sensitive(tx_gains[i], FALSE); - - row++; - } -*/ - // used single gain control - LimeSDR works out best setting for the 3 rx gains - col=2; - GtkWidget *tx_gain_label=gtk_label_new(NULL); - gtk_label_set_markup(GTK_LABEL(tx_gain_label), "TX Gain"); - gtk_grid_attach(GTK_GRID(grid),tx_gain_label,col,row,1,1); - col++; - double max=100; - if(strcmp(radio->name,"lime")==0) { - max=64.0; - } else if(strcmp(radio->name,"plutosdr")==0) { - max=89.0; - } - tx_gain=gtk_spin_button_new_with_range(0.0,max,1.0); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(tx_gain),transmitter->drive); - gtk_grid_attach(GTK_GRID(grid),tx_gain,col,row,1,1); - g_signal_connect(tx_gain,"value_changed",G_CALLBACK(drive_gain_value_changed_cb),&adc[0]); - } - } -#endif gtk_container_add(GTK_CONTAINER(content),grid); diff --git a/receiver.c b/receiver.c index 4e0e9b7..f3442e7 100644 --- a/receiver.c +++ b/receiver.c @@ -46,9 +46,6 @@ #include "waterfall.h" #include "new_protocol.h" #include "old_protocol.h" -#ifdef SOAPYSDR -#include "soapy_protocol.h" -#endif #include "ext.h" #include "new_menu.h" #ifdef CLIENT_SERVER @@ -213,9 +210,6 @@ void receiver_save_state(RECEIVER *rx) { // and then return quickly. // if (rx->id == PS_RX_FEEDBACK -#ifdef SOAPYSDR - && protocol!=SOAPYSDR_PROTOCOL -#endif ) return; #endif @@ -411,9 +405,6 @@ g_print("%s: id=%d\n",__FUNCTION__,rx->id); // and then return quickly // if (rx->id == PS_RX_FEEDBACK -#ifdef SOAPYSDR - && protocol!=SOAPYSDR_PROTOCOL -#endif ) return; #endif @@ -1027,18 +1018,7 @@ g_print("%s: id=%d buffer_size=%d fft_size=%d pixels=%d fps=%d\n",__FUNCTION__,i } } g_print("%s: id=%d default adc=%d\n",__FUNCTION__,rx->id, rx->adc); -#ifdef SOAPYSDR - if(radio->device==SOAPYSDR_USB_DEVICE) { - rx->sample_rate=radio->info.soapy.sample_rate; - rx->resampler=NULL; - rx->resample_buffer=NULL; -g_print("%s: id=%d sample_rate=%d\n",__FUNCTION__,rx->id, rx->sample_rate); - } else { -#endif rx->sample_rate=48000; -#ifdef SOAPYSDR - } -#endif rx->buffer_size=buffer_size; rx->fft_size=fft_size; rx->fps=fps; @@ -1280,12 +1260,6 @@ g_print("%s: id=%d rate=%d scale=%d buffer_size=%d output_samples=%d\n",__FUNCTI SetInputSamplerate(rx->id, sample_rate); SetEXTANBSamplerate (rx->id, sample_rate); SetEXTNOBSamplerate (rx->id, sample_rate); -#ifdef SOAPYSDR - if(protocol==SOAPYSDR_PROTOCOL) { - soapy_protocol_change_sample_rate(rx); - soapy_protocol_set_mic_sample_rate(rx->sample_rate); - } -#endif SetChannelState(rx->id,1,0); @@ -1328,11 +1302,6 @@ void receiver_frequency_changed(RECEIVER *rx) { case NEW_PROTOCOL: schedule_high_priority(); // send new frequency break; -#if SOAPYSDR - case SOAPYSDR_PROTOCOL: - soapy_protocol_set_rx_frequency(rx,id); - break; -#endif } } } @@ -1441,10 +1410,6 @@ static void process_rx_buffer(RECEIVER *rx) { } } break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - break; -#endif } #ifdef AUDIO_WATERFALL diff --git a/rx_menu.c b/rx_menu.c index 8fade9d..581b1e7 100644 --- a/rx_menu.c +++ b/rx_menu.c @@ -245,40 +245,6 @@ void rx_menu(GtkWidget *parent) { } x++; break; - -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - { - int row=1; - GtkWidget *sample_rate_label=gtk_label_new(NULL); - gtk_label_set_markup(GTK_LABEL(sample_rate_label), "Sample Rate"); - gtk_grid_attach(GTK_GRID(grid),sample_rate_label,x,row,1,1); - row++; - - - char rate_string[16]; - sprintf(rate_string,"%d",radio->info.soapy.sample_rate); - GtkWidget *sample_rate=gtk_radio_button_new_with_label(NULL,rate_string); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate), radio->info.soapy.sample_rate); - gtk_grid_attach(GTK_GRID(grid),sample_rate,x,row,1,1); - g_signal_connect(sample_rate,"toggled",G_CALLBACK(sample_rate_cb),GINT_TO_POINTER(radio->info.soapy.sample_rate)); - row++; - - int rate=radio->info.soapy.sample_rate/2; - while(rate>=48000) { - sprintf(rate_string,"%d",rate); - GtkWidget *next_sample_rate=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate),rate_string); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (next_sample_rate), active_receiver->sample_rate==rate); - gtk_grid_attach(GTK_GRID(grid),next_sample_rate,x,row,1,1); - g_signal_connect(next_sample_rate,"toggled",G_CALLBACK(sample_rate_cb),GINT_TO_POINTER(rate)); - rate=rate/2; - row++; - } - } - x++; - break; -#endif - } // diff --git a/rx_panadapter.c b/rx_panadapter.c index a0cbeaa..eb7eb4f 100644 --- a/rx_panadapter.c +++ b/rx_panadapter.c @@ -498,12 +498,6 @@ void rx_panadapter_update(RECEIVER *rx) { if (rx->preamp) s1 -= 18.0; if (rx->dither) s1 -= 18.0; } -#ifdef SOAPYSDR - if(protocol==SOAPYSDR_PROTOCOL) { - //s1-=rx->rf_gain; - s1-=adc[rx->id].gain; - } -#endif s1 = floor((rx->panadapter_high - s1) * (double) display_height @@ -520,12 +514,6 @@ void rx_panadapter_update(RECEIVER *rx) { if (rx->preamp) s2 -= 18.0; if (rx->dither) s2 -= 18.0; } -#ifdef SOAPYSDR - if(protocol==SOAPYSDR_PROTOCOL) { - //s2-=rx->rf_gain; - s2-=adc[rx->id].gain; - } -#endif s2 = floor((rx->panadapter_high - s2) * (double) display_height / (rx->panadapter_high - rx->panadapter_low)); diff --git a/sliders.c b/sliders.c index 70ae9c1..6a64324 100644 --- a/sliders.c +++ b/sliders.c @@ -43,9 +43,6 @@ #include "band.h" #include "discovered.h" #include "new_protocol.h" -#ifdef SOAPYSDR -#include "soapy_protocol.h" -#endif #include "vfo.h" #include "alex.h" #include "agc.h" @@ -388,11 +385,6 @@ void set_af_gain(int rx,double value) { static void rf_gain_value_changed_cb(GtkWidget *widget, gpointer data) { adc[active_receiver->adc].gain=gtk_range_get_value(GTK_RANGE(rf_gain_scale)); switch(protocol) { -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - soapy_protocol_set_gain(active_receiver); - break; -#endif default: break; } @@ -406,11 +398,6 @@ void update_rf_gain() { void set_rf_gain(int rx,double value) { g_print("%s\n",__FUNCTION__); adc[receiver[rx]->id].gain=value; -#ifdef SOAPYSDR - if(protocol==SOAPYSDR_PROTOCOL) { - soapy_protocol_set_gain(receiver[rx]); - } -#endif if(display_sliders) { //gtk_range_set_value (GTK_RANGE(attenuation_scale),receiver[rx]->rf_gain); gtk_range_set_value (GTK_RANGE(rf_gain_scale),adc[receiver[rx]->id].gain); @@ -853,17 +840,8 @@ fprintf(stderr,"sliders_init: width=%d height=%d\n", width,height); gtk_widget_override_font(rf_gain_label, pango_font_description_from_string("Sans 10")); gtk_widget_show(rf_gain_label); gtk_grid_attach(GTK_GRID(sliders),rf_gain_label,6,0,1,1); -#ifdef SOAPYSDR - if(protocol==SOAPYSDR_PROTOCOL) { - rf_gain_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,adc[0].min_gain, adc[0].max_gain, 1.0); - gtk_range_set_value (GTK_RANGE(rf_gain_scale),adc[0].gain); - } else { -#endif rf_gain_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, -12.0, 48.0, 1.0); gtk_range_set_value (GTK_RANGE(rf_gain_scale),adc[active_receiver->adc].gain); -#ifdef SOAPYSDR - } -#endif gtk_widget_override_font(rf_gain_scale, pango_font_description_from_string("Sans 10")); gtk_range_set_increments (GTK_RANGE(rf_gain_scale),1.0,1.0); gtk_widget_show(rf_gain_scale); diff --git a/soapy_discovery.c b/soapy_discovery.c deleted file mode 100644 index c459ac0..0000000 --- a/soapy_discovery.c +++ /dev/null @@ -1,319 +0,0 @@ -/* Copyright (C) -* 2019 - John Melton, G0ORX/N6LYT -* -* This program 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 2 -* of the License, or (at your option) any later version. -* -* This program 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 this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -*/ - -#include -#include -#include -#include -#include -#include -#include "discovered.h" -#include "soapy_discovery.h" - -static int rtlsdr_count=0; -static int sdrplay_count=0; - -static void get_info(char *driver) { - size_t rx_rates_length, tx_rates_length, rx_gains_length, tx_gains_length, ranges_length, rx_antennas_length, tx_antennas_length, rx_bandwidth_length, tx_bandwidth_length; - int i; - SoapySDRKwargs args={}; - int software_version=0; - char *version; - char *address=NULL; - int rtlsdr_val=0; - int sdrplay_val=0; - char fw_version[16]; - char gw_version[16]; - char hw_version[16]; - char p_version[16]; - char** tx_antennas; - char** tx_gains; - - fprintf(stderr,"soapy_discovery: get_info: %s\n", driver); - - strcpy(fw_version,""); - strcpy(gw_version,""); - strcpy(hw_version,""); - strcpy(p_version,""); - - SoapySDRKwargs_set(&args, "driver", driver); - if(strcmp(driver,"rtlsdr")==0) { - char count[16]; - sprintf(count,"%d",rtlsdr_count); - SoapySDRKwargs_set(&args, "rtl", count); - rtlsdr_val=rtlsdr_count; - rtlsdr_count++; - } else if(strcmp(driver,"sdrplay")==0) { - char label[16]; - sprintf(label,"SDRplay Dev%d",sdrplay_count); - SoapySDRKwargs_set(&args, "label", label); - sdrplay_val=sdrplay_count; - sdrplay_count++; - } - SoapySDRDevice *sdr = SoapySDRDevice_make(&args); - SoapySDRKwargs_clear(&args); - software_version=0; - - char *driverkey=SoapySDRDevice_getDriverKey(sdr); - fprintf(stderr,"DriverKey=%s\n",driverkey); - - char *hardwarekey=SoapySDRDevice_getHardwareKey(sdr); - fprintf(stderr,"HardwareKey=%s\n",hardwarekey); - if(strcmp(driver,"sdrplay")==0) { - address=hardwarekey; - } - - SoapySDRKwargs info=SoapySDRDevice_getHardwareInfo(sdr); - for(i=0;i %f (%f),", rx_rates[i].minimum, rx_rates[i].maximum, rx_rates[i].minimum/48000.0); - } - if(strcmp(driver,"rtlsdr")==0) { - sample_rate=1536000; - } - - fprintf(stderr,"\n"); - free(rx_rates); - fprintf(stderr,"sample_rate selected %d\n",sample_rate); - - if(tx_channels>0) { - SoapySDRRange *tx_rates=SoapySDRDevice_getSampleRateRange(sdr, SOAPY_SDR_TX, 1, &tx_rates_length); - fprintf(stderr,"Tx sample rates: "); - for (size_t i = 0; i < tx_rates_length; i++) { - fprintf(stderr,"%f -> %f (%f),", tx_rates[i].minimum, tx_rates[i].maximum, tx_rates[i].minimum/48000.0); - } - fprintf(stderr,"\n"); - free(tx_rates); - } - - double *bandwidths=SoapySDRDevice_listBandwidths(sdr, SOAPY_SDR_RX, 0, &rx_bandwidth_length); - fprintf(stderr,"Rx bandwidths: "); - for (size_t i = 0; i < rx_bandwidth_length; i++) { - fprintf(stderr,"%f, ", bandwidths[i]); - } - fprintf(stderr,"\n"); - free(bandwidths); - - if(tx_channels>0) { - bandwidths=SoapySDRDevice_listBandwidths(sdr, SOAPY_SDR_TX, 0, &tx_bandwidth_length); - fprintf(stderr,"Tx bandwidths: "); - for (size_t i = 0; i < tx_bandwidth_length; i++) { - fprintf(stderr,"%f, ", bandwidths[i]); - } - fprintf(stderr,"\n"); - free(bandwidths); - } - - double bandwidth=SoapySDRDevice_getBandwidth(sdr, SOAPY_SDR_RX, 0); - fprintf(stderr,"RX0: bandwidth=%f\n",bandwidth); - - if(tx_channels>0) { - bandwidth=SoapySDRDevice_getBandwidth(sdr, SOAPY_SDR_TX, 0); - fprintf(stderr,"TX0: bandwidth=%f\n",bandwidth); - } - - SoapySDRRange *ranges = SoapySDRDevice_getFrequencyRange(sdr, SOAPY_SDR_RX, 0, &ranges_length); - fprintf(stderr,"Rx freq ranges: "); - for (size_t i = 0; i < ranges_length; i++) fprintf(stderr,"[%f Hz -> %f Hz step=%f], ", ranges[i].minimum, ranges[i].maximum,ranges[i].step); - fprintf(stderr,"\n"); - - char** rx_antennas = SoapySDRDevice_listAntennas(sdr, SOAPY_SDR_RX, 0, &rx_antennas_length); - fprintf(stderr, "Rx antennas: "); - for (size_t i = 0; i < rx_antennas_length; i++) fprintf(stderr, "%s, ", rx_antennas[i]); - fprintf(stderr,"\n"); - - - if(tx_channels>0) { - tx_antennas = SoapySDRDevice_listAntennas(sdr, SOAPY_SDR_TX, 0, &tx_antennas_length); - fprintf(stderr, "Tx antennas: "); - for (size_t i = 0; i < tx_antennas_length; i++) fprintf(stderr, "%s, ", tx_antennas[i]); - fprintf(stderr,"\n"); - } - - char **rx_gains = SoapySDRDevice_listGains(sdr, SOAPY_SDR_RX, 0, &rx_gains_length); - - gboolean has_automatic_gain=SoapySDRDevice_hasGainMode(sdr, SOAPY_SDR_RX, 0); - fprintf(stderr,"has_automaic_gain=%d\n",has_automatic_gain); - - gboolean has_automatic_dc_offset_correction=SoapySDRDevice_hasDCOffsetMode(sdr, SOAPY_SDR_RX, 0); - fprintf(stderr,"has_automaic_dc_offset_correction=%d\n",has_automatic_dc_offset_correction); - - if(tx_channels>0) { - tx_gains = SoapySDRDevice_listGains(sdr, SOAPY_SDR_TX, 1, &tx_gains_length); - } - - size_t formats_length; - char **formats = SoapySDRDevice_getStreamFormats(sdr,SOAPY_SDR_RX,0,&formats_length); - fprintf(stderr, "Rx formats: "); - for (size_t i = 0; i < formats_length; i++) fprintf(stderr, "%s, ", formats[i]); - fprintf(stderr,"\n"); - - size_t sensors; - char **sensor = SoapySDRDevice_listSensors(sdr, &sensors); - gboolean has_temp=FALSE; - char *ptr; - fprintf(stderr, "Sensors:\n"); - for (size_t i = 0; i < sensors; i++) { - char *value=SoapySDRDevice_readSensor(sdr, sensor[i]); - fprintf(stderr, " %s=%s\n", sensor[i],value); - if((ptr=strstr(sensor[i],"temp"))!=NULL) { - has_temp=TRUE; - } - } - - if(devices %f step=%f\n",rx_range.minimum,rx_range.maximum,rx_range.step); - discovered[devices].info.soapy.rx_range[i]=rx_range; - } - discovered[devices].info.soapy.rx_has_automatic_gain=has_automatic_gain; - discovered[devices].info.soapy.rx_has_automatic_dc_offset_correction=has_automatic_dc_offset_correction; - discovered[devices].info.soapy.rx_antennas=rx_antennas_length; - discovered[devices].info.soapy.rx_antenna=rx_antennas; - - discovered[devices].info.soapy.tx_channels=tx_channels; - if(tx_channels>0) { - discovered[devices].info.soapy.tx_gains=tx_gains_length; - discovered[devices].info.soapy.tx_gain=tx_gains; - discovered[devices].info.soapy.tx_range=malloc(tx_gains_length*sizeof(SoapySDRRange)); - fprintf(stderr,"Tx gains: \n"); - for (size_t i = 0; i < tx_gains_length; i++) { - fprintf(stderr,"%s ", tx_gains[i]); - SoapySDRRange tx_range=SoapySDRDevice_getGainElementRange(sdr, SOAPY_SDR_TX, 1, tx_gains[i]); - fprintf(stderr,"%f -> %f step=%f\n",tx_range.minimum,tx_range.maximum,tx_range.step); - discovered[devices].info.soapy.tx_range[i]=tx_range; - } - discovered[devices].info.soapy.tx_antennas=tx_antennas_length; - discovered[devices].info.soapy.tx_antenna=tx_antennas; - } - discovered[devices].info.soapy.sensors=sensors; - discovered[devices].info.soapy.sensor=sensor; - discovered[devices].info.soapy.has_temp=has_temp; - - - if(address!=NULL) { - strcpy(discovered[devices].info.soapy.address,address); - } else { - strcpy(discovered[devices].info.soapy.address,"USB"); - } - - devices++; - } - - SoapySDRDevice_unmake(sdr); - - free(ranges); -} - -void soapy_discovery() { - size_t length; - int i,j; - SoapySDRKwargs input_args={}; - SoapySDRKwargs args={}; - -fprintf(stderr,"soapy_discovery\n"); - rtlsdr_count=0; - SoapySDRKwargs_set(&input_args, "hostname", "pluto.local"); - SoapySDRKwargs *results = SoapySDRDevice_enumerate(&input_args, &length); -fprintf(stderr,"soapy_discovery: length=%d\n",(int)length); - for (i = 0; i < length; i++) { - for (size_t j = 0; j < results[i].size; j++) { - if(strcmp(results[i].keys[j],"driver")==0 && strcmp(results[i].vals[j],"audio")!=0) { - get_info(results[i].vals[j]); - } - } - } - SoapySDRKwargsList_clear(results, length); -} diff --git a/soapy_discovery.h b/soapy_discovery.h deleted file mode 100644 index 65df402..0000000 --- a/soapy_discovery.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (C) -* 2019 - John Melton, G0ORX/N6LYT -* -* This program 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 2 -* of the License, or (at your option) any later version. -* -* This program 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 this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -*/ - -#ifndef _SOAPY_DISCOVERY_H -#define _SOAPY_DISCOVERY_H - -void soapy_discovery(); - -#endif diff --git a/soapy_protocol.c b/soapy_protocol.c deleted file mode 100644 index 1c111ef..0000000 --- a/soapy_protocol.c +++ /dev/null @@ -1,550 +0,0 @@ -/* Copyright (C) -* 2019 - John Melton, G0ORX/N6LYT -* -* This program 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 2 -* of the License, or (at your option) any later version. -* -* This program 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 this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -*/ - -#include -#include -#include -#include - -#include "SoapySDR/Constants.h" -#include "SoapySDR/Device.h" -#include "SoapySDR/Formats.h" -#include "SoapySDR/Version.h" -#include "SoapySDR/Logger.h" - -//#define TIMING -#ifdef TIMING -#include -#endif - -#include "band.h" -#include "channel.h" -#include "discovered.h" -#include "mode.h" -#include "filter.h" -#include "receiver.h" -#include "transmitter.h" -#include "radio.h" -#include "main.h" -#include "soapy_protocol.h" -#include "audio.h" -#include "signal.h" -#include "vfo.h" -#include "ext.h" -#include "error_handler.h" - - -#define MAX_CHANNELS 2 -static SoapySDRStream *rx_stream[MAX_CHANNELS]; -static SoapySDRStream *tx_stream; -static SoapySDRDevice *soapy_device; -static int max_samples; - -static int samples=0; - -static double bandwidth=2000000.0; - -static GThread *receive_thread_id; -static gpointer receive_thread(gpointer data); - -static int actual_rate; - -#ifdef TIMING -static int rate_samples; -#endif - -static gboolean running; - -static int mic_samples=0; -static int mic_sample_divisor=1; - -static int max_tx_samples; -static float *output_buffer; -static int output_buffer_index; - -SoapySDRDevice *get_soapy_device() { - return soapy_device; -} - -void soapy_protocol_set_mic_sample_rate(int rate) { - mic_sample_divisor=rate/48000; -} - -void soapy_protocol_change_sample_rate(RECEIVER *rx) { - int rc; - -// rx->mutex already locked - if(strcmp(radio->name,"sdrplay")==0) { - g_print("%s: setting samplerate=%f\n",__FUNCTION__,(double)rx->sample_rate); - rc=SoapySDRDevice_setSampleRate(soapy_device,SOAPY_SDR_RX,rx->adc,(double)rx->sample_rate); - if(rc!=0) { - g_print("%s: SoapySDRDevice_setSampleRate(%f) failed: %s\n",__FUNCTION__,(double)rx->sample_rate,SoapySDR_errToStr(rc)); - } - } else if(rx->sample_rate==radio_sample_rate) { - if(rx->resample_buffer!=NULL) { - g_free(rx->resample_buffer); - rx->resample_buffer=NULL; - rx->resample_buffer_size=0; - } - if(rx->resampler!=NULL) { - destroy_resample(rx->resampler); - rx->resampler=NULL; - } - } else { - if(rx->resample_buffer!=NULL) { - g_free(rx->resample_buffer); - rx->resample_buffer=NULL; - } - if(rx->resampler!=NULL) { - destroy_resample(rx->resampler); - rx->resampler=NULL; - } - rx->resample_buffer_size=2*max_samples/(radio_sample_rate/rx->sample_rate); - rx->resample_buffer=g_new(double,rx->resample_buffer_size); - rx->resampler=create_resample (1,max_samples,rx->buffer,rx->resample_buffer,radio_sample_rate,rx->sample_rate,0.0,0,1.0); - - } - -} - -void soapy_protocol_create_receiver(RECEIVER *rx) { - int rc; - - mic_sample_divisor=rx->sample_rate/48000; - - g_print("%s: device=%p adc=%d setting bandwidth=%f\n",__FUNCTION__,soapy_device,rx->adc,bandwidth); - rc=SoapySDRDevice_setBandwidth(soapy_device,SOAPY_SDR_RX,rx->adc,bandwidth); - if(rc!=0) { - g_print("%s: SoapySDRDevice_setBandwidth(%f) failed: %s\n",__FUNCTION__,(double)bandwidth,SoapySDR_errToStr(rc)); - } - - g_print("%s: setting samplerate=%f device=%p adc=%d mic_sample_divisor=%d\n",__FUNCTION__,(double)radio_sample_rate,soapy_device,rx->adc,mic_sample_divisor); - rc=SoapySDRDevice_setSampleRate(soapy_device,SOAPY_SDR_RX,rx->adc,(double)radio_sample_rate); - if(rc!=0) { - g_print("%s: SoapySDRDevice_setSampleRate(%f) failed: %s\n",__FUNCTION__,(double)radio_sample_rate,SoapySDR_errToStr(rc)); - } - - size_t channel=rx->adc; -#if defined(SOAPY_SDR_API_VERSION) && (SOAPY_SDR_API_VERSION < 0x00080000) - g_print("%s: SoapySDRDevice_setupStream(version<0x00080000): channel=%ld\n",__FUNCTION__,channel); - rc=SoapySDRDevice_setupStream(soapy_device,&rx_stream[channel],SOAPY_SDR_RX,SOAPY_SDR_CF32,&channel,1,NULL); - if(rc!=0) { - g_print("%s: SoapySDRDevice_setupStream (RX) failed: %s\n",__FUNCTION__,SoapySDR_errToStr(rc)); - _exit(-1); - } -#else - g_print("%s: SoapySDRDevice_setupStream(version>=0x00080000): channel=%ld\n",__FUNCTION__,channel); - rx_stream[channel]=SoapySDRDevice_setupStream(soapy_device,SOAPY_SDR_RX,SOAPY_SDR_CF32,&channel,1,NULL); - if(rx_stream[channel]==NULL) { - g_print("%s: SoapySDRDevice_setupStream (RX) failed (rx_stream is NULL)\n",__FUNCTION__); - _exit(-1); - } -#endif - - g_print("%s: id=%d soapy_device=%p rx_stream=%p\n",__FUNCTION__,rx->id,soapy_device,rx_stream); - - max_samples=SoapySDRDevice_getStreamMTU(soapy_device,rx_stream[channel]); - g_print("%s: max_samples=%d\n",__FUNCTION__,max_samples); - if(max_samples>(2*rx->fft_size)) { - max_samples=2*rx->fft_size; - } - rx->buffer=g_new(double,max_samples*2); - - if(rx->sample_rate==radio_sample_rate) { - rx->resample_buffer=NULL; - rx->resampler=NULL; - rx->resample_buffer_size=0; - } else { - rx->resample_buffer_size=2*max_samples/(radio_sample_rate/rx->sample_rate); - rx->resample_buffer=g_new(double,rx->resample_buffer_size); - rx->resampler=create_resample (1,max_samples,rx->buffer,rx->resample_buffer,radio_sample_rate,rx->sample_rate,0.0,0,1.0); - } - - -g_print("%s: max_samples=%d buffer=%p\n",__FUNCTION__,max_samples,rx->buffer); - -} - -void soapy_protocol_start_receiver(RECEIVER *rx) { - int rc; - - g_print("%s: id=%d soapy_device=%p rx_stream=%p\n",__FUNCTION__,rx->id,soapy_device,rx_stream); - - size_t channel=rx->adc; - double rate=SoapySDRDevice_getSampleRate(soapy_device,SOAPY_SDR_RX,rx->adc); - g_print("%s: rate=%f\n",__FUNCTION__,rate); - - g_print("%s: activate Stream\n",__FUNCTION__); - rc=SoapySDRDevice_activateStream(soapy_device, rx_stream[channel], 0, 0LL, 0); - if(rc!=0) { - g_print("%s: SoapySDRDevice_activateStream failed: %s\n",__FUNCTION__,SoapySDR_errToStr(rc)); - _exit(-1); - } - - g_print("%s: create receiver_thread\n",__FUNCTION__); - receive_thread_id = g_thread_new( "soapy_rx", receive_thread, rx); - if( ! receive_thread_id ) - { - g_print("%s: g_thread_new failed for receive_thread\n",__FUNCTION__); - exit( -1 ); - } - g_print("%s: receiver_thread_id=%p\n",__FUNCTION__,receive_thread_id); -} - -void soapy_protocol_create_transmitter(TRANSMITTER *tx) { - int rc; - - g_print("%s: setting samplerate=%f\n",__FUNCTION__,(double)tx->iq_output_rate); - rc=SoapySDRDevice_setSampleRate(soapy_device,SOAPY_SDR_TX,tx->dac,(double)tx->iq_output_rate); - if(rc!=0) { - g_print("%s: SoapySDRDevice_setSampleRate(%f) failed: %s\n",__FUNCTION__,(double)tx->iq_output_rate,SoapySDR_errToStr(rc)); - } - - - size_t channel=tx->dac; - g_print("%s: SoapySDRDevice_setupStream: channel=%ld\n",__FUNCTION__,channel); -#if defined(SOAPY_SDR_API_VERSION) && (SOAPY_SDR_API_VERSION < 0x00080000) - rc=SoapySDRDevice_setupStream(soapy_device,&tx_stream,SOAPY_SDR_TX,SOAPY_SDR_CF32,&channel,1,NULL); - if(rc!=0) { - g_print("%s: SoapySDRDevice_setupStream (RX) failed: %s\n",__FUNCTION__,SoapySDR_errToStr(rc)); - _exit(-1); - } -#else - tx_stream=SoapySDRDevice_setupStream(soapy_device,SOAPY_SDR_TX,SOAPY_SDR_CF32,&channel,1,NULL); - if(tx_stream==NULL) { - g_print("%s: SoapySDRDevice_setupStream (TX) failed: %s\n",__FUNCTION__,SoapySDR_errToStr(rc)); - _exit(-1); - } -#endif - - max_tx_samples=SoapySDRDevice_getStreamMTU(soapy_device,tx_stream); - if(max_tx_samples>(2*tx->fft_size)) { - max_tx_samples=2*tx->fft_size; - } - g_print("%s: max_tx_samples=%d\n",__FUNCTION__,max_tx_samples); - output_buffer=(float *)malloc(max_tx_samples*sizeof(float)*2); - -} - -void soapy_protocol_start_transmitter(TRANSMITTER *tx) { - int rc; - -double rate=SoapySDRDevice_getSampleRate(soapy_device,SOAPY_SDR_TX,tx->dac); -fprintf(stderr,"soapy_protocol_start_transmitter: activateStream rate=%f\n",rate); - rc=SoapySDRDevice_activateStream(soapy_device, tx_stream, 0, 0LL, 0); - if(rc!=0) { - fprintf(stderr,"soapy_protocol_start_transmitter: SoapySDRDevice_activateStream failed: %s\n",SoapySDR_errToStr(rc)); - _exit(-1); - } -} - -void soapy_protocol_stop_transmitter(TRANSMITTER *tx) { - int rc; - -fprintf(stderr,"soapy_protocol_stop_transmitter: deactivateStream\n"); - rc=SoapySDRDevice_deactivateStream(soapy_device, tx_stream, 0, 0LL); - if(rc!=0) { - fprintf(stderr,"soapy_protocol_stop_transmitter: SoapySDRDevice_deactivateStream failed: %s\n",SoapySDR_errToStr(rc)); - _exit(-1); - } -} - -void soapy_protocol_init(gboolean hf) { - SoapySDRKwargs args={}; - char temp[32]; - int rc; - int i; - - - SoapySDR_setLogLevel(SOAPY_SDR_TRACE); - -g_print("%s: hf=%d driver=%s\n",__FUNCTION__,hf,radio->name); - - // initialize the radio - SoapySDRKwargs_set(&args, "driver", radio->name); - if(strcmp(radio->name,"rtlsdr")==0) { - sprintf(temp,"%d",radio->info.soapy.rtlsdr_count); - SoapySDRKwargs_set(&args, "rtl", temp); - - if(hf) { - SoapySDRKwargs_set(&args, "direct_samp", "2"); - } else { - SoapySDRKwargs_set(&args, "direct_samp", "0"); - } - } else if(strcmp(radio->name,"sdrplay")==0) { - sprintf(temp,"SDRplay Dev%d",radio->info.soapy.sdrplay_count); - g_print("%s: label=%s\n",__FUNCTION__,temp); - SoapySDRKwargs_set(&args, "label", temp); - } - soapy_device=SoapySDRDevice_make(&args); - if(soapy_device==NULL) { - g_print("%s: SoapySDRDevice_make failed: %s\n",__FUNCTION__,SoapySDRDevice_lastError()); - _exit(-1); - } - SoapySDRKwargs_clear(&args); - - g_print("%s: soapy_device=%p\n",__FUNCTION__,soapy_device); - - if(can_transmit) { - if(transmitter->local_microphone) { - if(audio_open_input()!=0) { - g_print("%s: audio_open_input failed\n",__FUNCTION__); - transmitter->local_microphone=0; - } - } - } - -} - -static void *receive_thread(void *arg) { - double isample; - double qsample; - int elements; - int flags=0; - long long timeNs=0; - long timeoutUs=100000L; - int i; - RECEIVER *rx=(RECEIVER *)arg; - float *buffer=g_new(float,max_samples*2); - void *buffs[]={buffer}; - float fsample; - running=TRUE; -fprintf(stderr,"soapy_protocol: receive_thread\n"); - size_t channel=rx->adc; - while(running) { - elements=SoapySDRDevice_readStream(soapy_device,rx_stream[channel],buffs,max_samples,&flags,&timeNs,timeoutUs); - //fprintf(stderr,"soapy_protocol_receive_thread: SoapySDRDevice_readStream failed: max_samples=%d read=%d\n",max_samples,elements); - if(elements<0) { - continue; - } - - for(i=0;ibuffer[i*2]=(double)buffer[i*2]; - rx->buffer[(i*2)+1]=(double)buffer[(i*2)+1]; - } - - if(rx->resampler!=NULL) { - int samples=xresample(rx->resampler); - for(i=0;iresample_buffer[i*2]; - qsample=rx->resample_buffer[(i*2)+1]; - if(iqswap) { - add_iq_samples(rx,qsample,isample); - } else { - add_iq_samples(rx,isample,qsample); - } - if(can_transmit) { - mic_samples++; - if(mic_samples>=mic_sample_divisor) { // reduce to 48000 - if(transmitter!=NULL) { - fsample = transmitter->local_microphone ? audio_get_next_mic_sample() : 0.0F; - } else { - fsample=0.0F; - } - add_mic_sample(transmitter,fsample); - mic_samples=0; - } - } - } - } else { - for(i=0;ibuffer[i*2]; - qsample=rx->buffer[(i*2)+1]; - if(iqswap) { - add_iq_samples(rx,qsample,isample); - } else { - add_iq_samples(rx,isample,qsample); - } - if(can_transmit) { - mic_samples++; - if(mic_samples>=mic_sample_divisor) { // reduce to 48000 - if(transmitter!=NULL) { - fsample = transmitter->local_microphone ? audio_get_next_mic_sample() : 0.0F; - } else { - fsample=0.0F; - } - add_mic_sample(transmitter,fsample); - mic_samples=0; - } - } - } - } - } - -fprintf(stderr,"soapy_protocol: receive_thread: SoapySDRDevice_deactivateStream\n"); - SoapySDRDevice_deactivateStream(soapy_device,rx_stream[channel],0,0LL); - /* -fprintf(stderr,"soapy_protocol: receive_thread: SoapySDRDevice_closeStream\n"); - SoapySDRDevice_closeStream(soapy_device,rx_stream[channel]); -fprintf(stderr,"soapy_protocol: receive_thread: SoapySDRDevice_unmake\n"); - SoapySDRDevice_unmake(soapy_device); - */ - return NULL; -} - -void soapy_protocol_process_local_mic(float sample) { - add_mic_sample(transmitter,sample); -} - -void soapy_protocol_iq_samples(float isample,float qsample) { - const void *tx_buffs[]={output_buffer}; - int flags=0; - long long timeNs=0; - long timeoutUs=100000L; - if(isTransmitting()) { - output_buffer[(output_buffer_index*2)]=isample; - output_buffer[(output_buffer_index*2)+1]=qsample; - output_buffer_index++; - if(output_buffer_index>=max_tx_samples) { - int elements=SoapySDRDevice_writeStream(soapy_device,tx_stream,tx_buffs,max_tx_samples,&flags,timeNs,timeoutUs); - if(elements!=max_tx_samples) { - g_print("soapy_protocol_iq_samples: writeStream returned %d for %d elements\n",elements,max_tx_samples); - } - output_buffer_index=0; - } - } -} - - - -void soapy_protocol_stop() { -fprintf(stderr,"soapy_protocol_stop\n"); - running=FALSE; -} - -void soapy_protocol_set_rx_frequency(RECEIVER *rx,int v) { - int rc; - - if(soapy_device!=NULL) { - double f=(double)(vfo[v].frequency-vfo[v].lo); - rc=SoapySDRDevice_setFrequency(soapy_device,SOAPY_SDR_RX,rx->adc,f,NULL); - if(rc!=0) { - fprintf(stderr,"soapy_protocol: SoapySDRDevice_setFrequency(RX) failed: %s\n",SoapySDR_errToStr(rc)); - } - } -} - -void soapy_protocol_set_tx_frequency(TRANSMITTER *tx) { - int v; - int rc; - double f; - - v=get_tx_vfo(); - if(soapy_device!=NULL) { - if(vfo[v].ctun) { - f=(double)(vfo[v].ctun_frequency); - } else { - f=(double)(vfo[v].frequency); - } - - if(transmitter->xit_enabled) { - f+=(double)(transmitter->xit); - } - -//fprintf(stderr,"soapy_protocol_set_tx_frequency: %f\n",f); - rc=SoapySDRDevice_setFrequency(soapy_device,SOAPY_SDR_TX,tx->dac,f,NULL); - if(rc!=0) { - fprintf(stderr,"soapy_protocol: SoapySDRDevice_setFrequency(TX) failed: %s\n",SoapySDR_errToStr(rc)); - } - } -} - -void soapy_protocol_set_rx_antenna(RECEIVER *rx,int ant) { - int rc; - if(soapy_device!=NULL) { - if (ant >= radio->info.soapy.rx_antennas) ant=radio->info.soapy.rx_antennas -1; - g_print("soapy_protocol: set_rx_antenna: %s\n",radio->info.soapy.rx_antenna[ant]); - rc=SoapySDRDevice_setAntenna(soapy_device,SOAPY_SDR_RX,rx->adc,radio->info.soapy.rx_antenna[ant]); - if(rc!=0) { - fprintf(stderr,"soapy_protocol: SoapySDRDevice_setAntenna RX failed: %s\n",SoapySDR_errToStr(rc)); - } - } -} - -void soapy_protocol_set_tx_antenna(TRANSMITTER *tx,int ant) { - int rc; - if(soapy_device!=NULL) { - if (ant >= radio->info.soapy.tx_antennas) ant=radio->info.soapy.tx_antennas -1; - g_print("soapy_protocol: set_tx_antenna: %s\n",radio->info.soapy.tx_antenna[ant]); - rc=SoapySDRDevice_setAntenna(soapy_device,SOAPY_SDR_TX,tx->dac,radio->info.soapy.tx_antenna[ant]); - if(rc!=0) { - fprintf(stderr,"soapy_protocol: SoapySDRDevice_setAntenna TX failed: %s\n",SoapySDR_errToStr(rc)); - } - } -} - -void soapy_protocol_set_gain(RECEIVER *rx) { - int rc; -//fprintf(stderr,"soapy_protocol_set_gain: adc=%d gain=%f\n",gain); - rc=SoapySDRDevice_setGain(soapy_device,SOAPY_SDR_RX,rx->adc,adc[rx->adc].gain); - if(rc!=0) { - fprintf(stderr,"soapy_protocol: SoapySDRDevice_setGain failed: %s\n",SoapySDR_errToStr(rc)); - } -} - -void soapy_protocol_set_gain_element(RECEIVER *rx,char *name,int gain) { - int rc; -g_print("%s: adc=%d %s=%d\n",__FUNCTION__,rx->adc,name,gain); - rc=SoapySDRDevice_setGainElement(soapy_device,SOAPY_SDR_RX,rx->adc,name,(double)gain); - if(rc!=0) { - g_print("%s: SoapySDRDevice_setGainElement %s failed: %s\n",__FUNCTION__,name,SoapySDR_errToStr(rc)); - } -} - -void soapy_protocol_set_tx_gain(TRANSMITTER *tx,int gain) { - int rc; - rc=SoapySDRDevice_setGain(soapy_device,SOAPY_SDR_TX,tx->dac,(double)gain); - if(rc!=0) { - fprintf(stderr,"soapy_protocol: SoapySDRDevice_setGain failed: %s\n",SoapySDR_errToStr(rc)); - } -} - -void soapy_protocol_set_tx_gain_element(TRANSMITTER *tx,char *name,int gain) { - int rc; - rc=SoapySDRDevice_setGainElement(soapy_device,SOAPY_SDR_TX,tx->dac,name,(double)gain); - if(rc!=0) { - fprintf(stderr,"soapy_protocol: SoapySDRDevice_setGainElement %s failed: %s\n",name,SoapySDR_errToStr(rc)); - } -} - -int soapy_protocol_get_gain_element(RECEIVER *rx,char *name) { - double gain; - gain=SoapySDRDevice_getGainElement(soapy_device,SOAPY_SDR_RX,rx->adc,name); - return (int)gain; -} - -int soapy_protocol_get_tx_gain_element(TRANSMITTER *tx,char *name) { - double gain; - gain=SoapySDRDevice_getGainElement(soapy_device,SOAPY_SDR_TX,tx->dac,name); - return (int)gain; -} - -gboolean soapy_protocol_get_automatic_gain(RECEIVER *rx) { - gboolean mode=SoapySDRDevice_getGainMode(soapy_device, SOAPY_SDR_RX, rx->adc); - return mode; -} - -void soapy_protocol_set_automatic_gain(RECEIVER *rx,gboolean mode) { - int rc; - rc=SoapySDRDevice_setGainMode(soapy_device, SOAPY_SDR_RX, rx->adc,mode); - if(rc!=0) { - - fprintf(stderr,"soapy_protocol: SoapySDRDevice_getGainMode failed: %s\n", SoapySDR_errToStr(rc)); - } -} diff --git a/soapy_protocol.h b/soapy_protocol.h deleted file mode 100644 index c5bb4d6..0000000 --- a/soapy_protocol.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) -* 2015 - John Melton, G0ORX/N6LYT -* -* This program 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 2 -* of the License, or (at your option) any later version. -* -* This program 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 this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -*/ - -#ifndef _SOAPY_PROTOCOL_H -#define _SOAPY_PROTOCOL_H - -#define BUFFER_SIZE 1024 - -SoapySDRDevice *get_soapy_device(); - -void soapy_protocol_create_receiver(RECEIVER *rx); -void soapy_protocol_start_receiver(RECEIVER *rx); - -void soapy_protocol_init(gboolean hf); -void soapy_protocol_stop(); -void soapy_protocol_set_rx_frequency(RECEIVER *rx,int v); -void soapy_protocol_set_rx_antenna(RECEIVER *rx,int ant); -void soapy_protocol_set_lna_gain(RECEIVER *rx,int gain); -void soapy_protocol_set_gain(RECEIVER *rx); -void soapy_protocol_set_gain_element(RECEIVER *rx,char *name,int gain); -int soapy_protocol_get_gain_element(RECEIVER *rx,char *name); -void soapy_protocol_change_sample_rate(RECEIVER *rx); -gboolean soapy_protocol_get_automatic_gain(RECEIVER *rx); -void soapy_protocol_set_automatic_gain(RECEIVER *rx,gboolean mode); -void soapy_protocol_create_transmitter(TRANSMITTER *tx); -void soapy_protocol_start_transmitter(TRANSMITTER *tx); -void soapy_protocol_stop_transmitter(TRANSMITTER *tx); -void soapy_protocol_set_tx_frequency(TRANSMITTER *tx); -void soapy_protocol_set_tx_antenna(TRANSMITTER *tx,int ant); -void soapy_protocol_set_tx_gain(TRANSMITTER *tx,int gain); -void soapy_protocol_set_tx_gain_element(TRANSMITTER *tx,char *name,int gain); -int soapy_protocol_get_tx_gain_element(TRANSMITTER *tx,char *name); -void soapy_protocol_process_local_mic(float sample); -void soapy_protocol_iq_samples(float isample,float qsample); -void soapy_protocol_set_mic_sample_rate(int rate); -#endif diff --git a/transmitter.c b/transmitter.c index 017dae9..ac20520 100644 --- a/transmitter.c +++ b/transmitter.c @@ -45,9 +45,6 @@ #include "transmitter.h" #include "new_protocol.h" #include "old_protocol.h" -#ifdef SOAPYSDR -#include "soapy_protocol.h" -#endif #include "audio.h" #include "ext.h" @@ -593,13 +590,6 @@ static gboolean update_display(gpointer data) { } break; -#ifdef SOAPY_SDR - case SOAPY_PROTOCOL: - transmitter->fwd=0.0; - transmitter->exciter=0.0; - transmitter->rev=0.0; - break; -#endif } double fwd=compute_power(transmitter->fwd); @@ -731,13 +721,6 @@ TRANSMITTER *create_transmitter(int id, int buffer_size, int fft_size, int fps, tx->mic_dsp_rate=96000; tx->iq_output_rate=192000; break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - tx->mic_sample_rate=48000; - tx->mic_dsp_rate=96000; - tx->iq_output_rate=radio_sample_rate; - break; -#endif } int ratio=tx->iq_output_rate/tx->mic_sample_rate; @@ -1002,11 +985,6 @@ static void full_tx_buffer(TRANSMITTER *tx) { case NEW_PROTOCOL: gain=8388607.0; // 24 bit break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - gain=32767.0; // 16 bit - break; -#endif } if (cwmode) { @@ -1146,11 +1124,6 @@ static void full_tx_buffer(TRANSMITTER *tx) { case NEW_PROTOCOL: new_protocol_iq_samples(isample,qsample); break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - soapy_protocol_iq_samples((float)isample,(float)qsample); - break; -#endif } } } @@ -1372,11 +1345,6 @@ void tx_set_ps(TRANSMITTER *tx,int state) { tx->puresignal = state ? 1 : 0; schedule_high_priority(); schedule_receive_specific(); -#ifdef SOAPY_SDR - case SOAPY_PROTOCOL: - // are there feedback channels in SOAPY? - break; -#endif } if(state) { // if switching on: wait a while to get the feedback diff --git a/version.c b/version.c index 7778033..78e7eec 100644 --- a/version.c +++ b/version.c @@ -21,7 +21,7 @@ char build_date[]=GIT_DATE; char build_version[]=GIT_VERSION; char version[]=GIT_VERSION -#if defined(GPIO) || defined(PURESIGNAL) || defined(SOAPYSDR) || defined(MIDI) +#if defined(GPIO) || defined(PURESIGNAL) || defined(MIDI) " includes" #endif #ifdef GPIO @@ -30,9 +30,6 @@ char version[]=GIT_VERSION #ifdef PURESIGNAL " PURESIGNAL" #endif -#ifdef SOAPYSDR -" SOAPYSDR" -#endif #ifdef MIDI " MIDI" #endif diff --git a/vfo.c b/vfo.c index c6cc320..597cc26 100644 --- a/vfo.c +++ b/vfo.c @@ -43,9 +43,6 @@ #include "receiver.h" #include "transmitter.h" #include "new_protocol.h" -#ifdef SOAPYSDR -#include "soapy_protocol.h" -#endif #include "vfo.h" #include "channel.h" #include "toolbar.h" @@ -203,13 +200,6 @@ g_print("vfo_restore_state: %d\n",i); vfo[i].band=band20; vfo[i].bandstack=0; vfo[i].frequency=14010000; -#ifdef SOAPYSDR - if(radio->protocol==SOAPYSDR_PROTOCOL) { - vfo[i].band=band144; - vfo[i].bandstack=0; - vfo[i].frequency=144010000; - } -#endif vfo[i].mode=modeCWU; vfo[i].filter=filterF6; vfo[i].lo=0; @@ -342,11 +332,6 @@ void vfo_band_changed(int id,int b) { case NEW_PROTOCOL: schedule_general(); break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - soapy_protocol_set_rx_frequency(active_receiver,id); - break; -#endif } g_idle_add(ext_vfo_update,NULL); } -- 2.45.2