Permalink
Browse files

rtl_power: adjustable sample rate

  • Loading branch information...
keenerd committed Aug 22, 2014
1 parent 3223086 commit 40bf3cb47784ec1b0cbff96e9a194eb009b05b01
Showing with 17 additions and 5 deletions.
  1. +17 −5 src/rtl_power.c
View
@@ -72,8 +72,9 @@
#define AUTO_GAIN -100
#define BUFFER_DUMP (1<<12)
-#define MAXIMUM_RATE 2400000
+#define MAXIMUM_RATE 3200000
#define MINIMUM_RATE 1000000
+int target_rate = 2400000;
static volatile int do_exit = 0;
static rtlsdr_dev_t *dev = NULL;
@@ -155,6 +156,7 @@ void usage(void)
"\t enables low-leakage downsample filter,\n"
"\t fir_size can be 0 or 9. 0 has bad roll off,\n"
"\t try with '-c 50%%'\n"
+ "\t[-r max_sample_rate (default: 2.4M)]\n"
"\t[-P enables peak hold (default: off)]\n"
"\t[-D direct_sampling_mode, 0 (default/off), 1 (I), 2 (Q), 3 (no-mod)]\n"
"\t[-O enable offset tuning (default: off)]\n"
@@ -490,7 +492,7 @@ int solve_downsample(struct channel_solve *c, int boxcar)
} else {
ds_next = c->downsample * 2;
}
- if (((int)bw * ds_next) > MAXIMUM_RATE) {
+ if (((int)bw * ds_next) > target_rate) {
break;}
c->downsample = ds_next;
@@ -505,7 +507,7 @@ int solve_hopping(struct channel_solve *c)
{
int i, scan_size, bins_all, bins_crop, bins_2;
scan_size = c->upper - c->lower;
- /* evenly sized ranges, as close to MAXIMUM_RATE as possible */
+ /* evenly sized ranges, as close to target_rate as possible */
for (i=1; i<MAX_TUNES; i++) {
c->bw_wanted = scan_size / i;
bins_all = scan_size / c->bin_spec;
@@ -514,7 +516,7 @@ int solve_hopping(struct channel_solve *c)
bins_2 = 1 << c->bin_e;
c->bw_needed = bins_2 * c->bin_spec;
c->crop_tmp = (double)(bins_2 - bins_crop) / (double)bins_2;
- if (c->bw_needed > MAXIMUM_RATE) {
+ if (c->bw_needed > target_rate) {
continue;}
if (c->crop_tmp < c->crop) {
continue;}
@@ -848,7 +850,7 @@ int main(int argc, char **argv)
double (*window_fn)(int, int) = rectangle;
freq_optarg = "";
- while ((opt = getopt(argc, argv, "f:i:s:t:d:g:p:e:w:c:F:1PD:Oh")) != -1) {
+ while ((opt = getopt(argc, argv, "f:i:s:r:t:d:g:p:e:w:c:F:1PD:Oh")) != -1) {
switch (opt) {
case 'f': // lower:upper:bin_size
freq_optarg = strdup(optarg);
@@ -901,6 +903,9 @@ int main(int argc, char **argv)
ppm_error = atoi(optarg);
custom_ppm = 1;
break;
+ case 'r':
+ target_rate = (int)atofs(optarg);
+ break;
case '1':
single = 1;
break;
@@ -934,6 +939,13 @@ int main(int argc, char **argv)
exit(1);
}
+ if (target_rate < 2 * MINIMUM_RATE) {
+ target_rate = 2 * MINIMUM_RATE;
+ }
+ if (target_rate > MAXIMUM_RATE) {
+ target_rate = MAXIMUM_RATE;
+ }
+
frequency_range(freq_optarg, crop, boxcar);
if (tune_count == 0) {

0 comments on commit 40bf3cb

Please sign in to comment.