summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tuner_fc0012.c16
-rw-r--r--src/tuner_fc0013.c16
2 files changed, 28 insertions, 4 deletions
diff --git a/src/tuner_fc0012.c b/src/tuner_fc0012.c
index 91ac882..4ad2045 100644
--- a/src/tuner_fc0012.c
+++ b/src/tuner_fc0012.c
@@ -22,6 +22,7 @@
*/
#include <stdint.h>
+#include <stdio.h>
#include "rtlsdr_i2c.h"
#include "tuner_fc0012.h"
@@ -215,12 +216,23 @@ int fc0012_set_params(void *dev, uint32_t freq, uint32_t bandwidth)
am = (uint8_t)(xdiv - (8 * pm));
if (am < 2) {
- reg[1] = am + 8;
- reg[2] = pm - 1;
+ am += 8;
+ pm--;
+ }
+
+ if (pm > 31) {
+ reg[1] = am + (8 * (pm - 31));
+ reg[2] = 31;
} else {
reg[1] = am;
reg[2] = pm;
}
+
+ if (reg[1] > 15) {
+ fprintf(stderr, "[FC0012] no valid PLL combination "
+ "found for %u Hz!\n", freq);
+ return -1;
+ }
} else {
/* fix for frequency less than 45 MHz */
reg[1] = 0x06;
diff --git a/src/tuner_fc0013.c b/src/tuner_fc0013.c
index 5423941..76e4b68 100644
--- a/src/tuner_fc0013.c
+++ b/src/tuner_fc0013.c
@@ -25,6 +25,7 @@
*/
#include <stdint.h>
+#include <stdio.h>
#include "rtlsdr_i2c.h"
#include "tuner_fc0013.h"
@@ -320,12 +321,23 @@ int fc0013_set_params(void *dev, uint32_t freq, uint32_t bandwidth)
am = (uint8_t)(xdiv - (8 * pm));
if (am < 2) {
- reg[1] = am + 8;
- reg[2] = pm - 1;
+ am += 8;
+ pm--;
+ }
+
+ if (pm > 31) {
+ reg[1] = am + (8 * (pm - 31));
+ reg[2] = 31;
} else {
reg[1] = am;
reg[2] = pm;
}
+
+ if (reg[1] > 15) {
+ fprintf(stderr, "[FC0013] no valid PLL combination "
+ "found for %u Hz!\n", freq);
+ return -1;
+ }
} else {
/* fix for frequency less than 45 MHz */
reg[1] = 0x06;