99
99
#define LOG_API_SET_FREQ 0
100
100
101
101
#define INIT_R820T_TUNER_GAIN 0
102
+ #define ENABLE_VCO_OPTIONS 1
103
+
102
104
103
105
/* activate/use RTL's IF AGC control .. from https://github.com/old-dab/rtlsdr
104
106
* purpose: make AGC more smooth .. and NOT freeze
@@ -379,6 +381,10 @@ int r820t_init(void *dev) {
379
381
devt -> r82xx_c .rafael_chip = CHIP_R820T ;
380
382
}
381
383
384
+ devt -> r82xx_c .vco_curr_min = 0xff ; /* VCO min/max current for R18/0x12 bits [7:5] in 0 .. 7. use 0xff for default */
385
+ devt -> r82xx_c .vco_curr_max = 0xff ; /* value is inverted: programmed is 7-value, that 0 is lowest current */
386
+ devt -> r82xx_c .vco_algo = 0x00 ;
387
+
382
388
rtlsdr_get_xtal_freq (devt , NULL , & devt -> r82xx_c .xtal );
383
389
384
390
devt -> r82xx_c .max_i2c_msg_len = 8 ;
@@ -4184,6 +4190,11 @@ const char * rtlsdr_get_opt_help(int longInfo)
4184
4190
"\t\t 0: use I & Q; 1: use I; 2: use Q; 3: use I below threshold frequency;\n"
4185
4191
"\t\t 4: use Q below threshold frequency (=RTL-SDR v3)\n"
4186
4192
"\t\t other values set the threshold frequency\n"
4193
+ #if ENABLE_VCO_OPTIONS
4194
+ "\t\tvcocmin=<current> set R820T/2 VCO current min: 0..7: higher value is more current\n"
4195
+ "\t\tvcocmax=<current> set R820T/2 VCO current max: 0..7\n"
4196
+ "\t\tvcoalgo=<algo> set R820T/2 VCO algorithm. 0: default. 1: with vcomax=3.9G. 2: Youssef/Carl\n"
4197
+ #endif
4187
4198
"\t\tTp=<gpio_pin> set GPIO pin for Bias T, default =0 for rtl-sdr.com compatible V3\n"
4188
4199
"\t\tT=<bias_tee> 1 activates power at antenna one some dongles, e.g. rtl-sdr.com's V3\n"
4189
4200
#ifdef WITH_UDP_SERVER
@@ -4196,7 +4207,12 @@ const char * rtlsdr_get_opt_help(int longInfo)
4196
4207
"\t[-O\tset RTL options string seperated with ':', e.g. -O 'bc=30000:agc=0' ]\n"
4197
4208
"\t\tverbose:f=<freqHz>:bw=<bw_in_kHz>:bc=<if_in_Hz>:sb=<sideband>\n"
4198
4209
"\t\tagc=<tuner_gain_mode>:gain=<tenth_dB>:ifm=<tuner_if_mode>:dagc=<rtl_agc>\n"
4210
+ #if ENABLE_VCO_OPTIONS
4211
+ "\t\tds=<direct_sampling>:dm=<ds_mode_thresh>:vcocmin=<c>:vcocmax=<c>:vcoalgo=<a>\n"
4212
+ "\t\tT=<bias_tee>\n"
4213
+ #else
4199
4214
"\t\tds=<direct_sampling>:dm=<ds_mode_thresh>:T=<bias_tee>\n"
4215
+ #endif
4200
4216
#ifdef WITH_UDP_SERVER
4201
4217
"\t\tport=<udp_port default with 1>\n"
4202
4218
#endif
@@ -4314,6 +4330,47 @@ int rtlsdr_set_opt_string(rtlsdr_dev_t *dev, const char *opts, int verbose)
4314
4330
dev -> direct_sampling_threshold = dm ;
4315
4331
ret = rtlsdr_set_ds_mode (dev , dev -> direct_sampling_mode , dev -> direct_sampling_threshold );
4316
4332
}
4333
+ #if ENABLE_VCO_OPTIONS
4334
+ else if (!strncmp (optPart , "vcocmin = ", 8 )) {
4335
+ int current = atoi (optPart + 8 );
4336
+ if ( 0 <= current && current <= 7 )
4337
+ {
4338
+ dev -> r82xx_c .vco_curr_min = 7 - current ;
4339
+ ret = 0 ;
4340
+ if (verbose )
4341
+ fprintf (stderr , "\nrtlsdr_set_opt_string(): parsed vcocmin config %d\n" , current );
4342
+ } else if (verbose ) {
4343
+ fprintf (stderr , "\nrtlsdr_set_opt_string(): error parsing vcocmin config: valid range 0 .. 7\n" );
4344
+ ret = 1 ;
4345
+ }
4346
+ }
4347
+ else if (!strncmp (optPart , "vcocmax = ", 8 )) {
4348
+ int current = atoi (optPart + 8 );
4349
+ if ( 0 <= current && current <= 7 )
4350
+ {
4351
+ dev -> r82xx_c .vco_curr_max = 7 - current ;
4352
+ ret = 0 ;
4353
+ if (verbose )
4354
+ fprintf (stderr , "\nrtlsdr_set_opt_string(): parsed vcocmax config %d\n" , current );
4355
+ } else if (verbose ) {
4356
+ fprintf (stderr , "\nrtlsdr_set_opt_string(): error parsing vcocmax config: valid range 0 .. 7\n" );
4357
+ ret = 1 ;
4358
+ }
4359
+ }
4360
+ else if (!strncmp (optPart , "vcoalgo = ", 8 )) {
4361
+ int algo = atoi (optPart + 8 );
4362
+ if ( 0 <= algo && algo <= 2 )
4363
+ {
4364
+ dev -> r82xx_c .vco_curr_max = algo ;
4365
+ ret = 0 ;
4366
+ if (verbose )
4367
+ fprintf (stderr , "\nrtlsdr_set_opt_string(): parsed vcoalgo config %d\n" , algo );
4368
+ } else if (verbose ) {
4369
+ fprintf (stderr , "\nrtlsdr_set_opt_string(): error parsing vcoalgo config: valid range 0 .. 2\n" );
4370
+ ret = 1 ;
4371
+ }
4372
+ }
4373
+ #endif
4317
4374
else if (!strncmp (optPart , "tp = ", 3) || !strncmp(optPart, " Tp = ", 3) || !strncmp(optPart, " TP = ", 3) ) {
4318
4375
int gpio_pin_no = atoi (optPart + 3 );
4319
4376
if (verbose )
0 commit comments