diff options
-rw-r--r-- | apps/recorder/radio.c | 9 | ||||
-rw-r--r-- | firmware/export/tuner.h | 2 | ||||
-rw-r--r-- | firmware/tuner_philips.c | 21 | ||||
-rw-r--r-- | firmware/tuner_samsung.c | 4 |
4 files changed, 17 insertions, 19 deletions
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index 9eac63a520..d60d1bd4d7 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include "config.h" | 20 | #include "config.h" |
21 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | #include <stdbool.h> | 22 | #include <stdbool.h> |
23 | #include <stdlib.h> | ||
23 | #include "sprintf.h" | 24 | #include "sprintf.h" |
24 | #include "lcd.h" | 25 | #include "lcd.h" |
25 | #include "mas.h" | 26 | #include "mas.h" |
@@ -160,7 +161,7 @@ bool radio_screen(void) | |||
160 | bool done = false; | 161 | bool done = false; |
161 | int button; | 162 | int button; |
162 | int freq; | 163 | int freq; |
163 | int i_freq; | 164 | int freq_diff; |
164 | bool stereo = false; | 165 | bool stereo = false; |
165 | int search_dir = 0; | 166 | int search_dir = 0; |
166 | int fw, fh; | 167 | int fw, fh; |
@@ -254,10 +255,10 @@ bool radio_screen(void) | |||
254 | sleep(1); | 255 | sleep(1); |
255 | 256 | ||
256 | /* Now check how close to the IF frequency we are */ | 257 | /* Now check how close to the IF frequency we are */ |
257 | i_freq = radio_get(RADIO_IF_MEASURED); | 258 | freq_diff = radio_get(RADIO_DEVIATION); |
258 | 259 | ||
259 | /* Stop searching if the IF frequency is close to 10.7MHz */ | 260 | /* Stop searching if the tuning is close */ |
260 | if(i_freq > 1065 && i_freq < 1075) | 261 | if(abs(freq_diff) < 50) |
261 | { | 262 | { |
262 | search_dir = 0; | 263 | search_dir = 0; |
263 | curr_preset = find_preset(curr_freq); | 264 | curr_preset = find_preset(curr_freq); |
diff --git a/firmware/export/tuner.h b/firmware/export/tuner.h index ae31c6d354..c399bb391b 100644 --- a/firmware/export/tuner.h +++ b/firmware/export/tuner.h | |||
@@ -29,7 +29,7 @@ | |||
29 | #define RADIO_FORCE_MONO 5 | 29 | #define RADIO_FORCE_MONO 5 |
30 | /* readback from the tuner layer */ | 30 | /* readback from the tuner layer */ |
31 | #define RADIO_PRESENT 0 | 31 | #define RADIO_PRESENT 0 |
32 | #define RADIO_IF_MEASURED 1 | 32 | #define RADIO_DEVIATION 1 |
33 | #define RADIO_STEREO 2 | 33 | #define RADIO_STEREO 2 |
34 | 34 | ||
35 | #ifdef CONFIG_TUNER | 35 | #ifdef CONFIG_TUNER |
diff --git a/firmware/tuner_philips.c b/firmware/tuner_philips.c index e63d063bfd..3fdf0f7cd0 100644 --- a/firmware/tuner_philips.c +++ b/firmware/tuner_philips.c | |||
@@ -29,7 +29,6 @@ static unsigned char write_bytes[5]; | |||
29 | /* tuner abstraction layer: set something to the tuner */ | 29 | /* tuner abstraction layer: set something to the tuner */ |
30 | void philips_set(int setting, int value) | 30 | void philips_set(int setting, int value) |
31 | { | 31 | { |
32 | (void)value; | ||
33 | switch(setting) | 32 | switch(setting) |
34 | { | 33 | { |
35 | case RADIO_INIT: | 34 | case RADIO_INIT: |
@@ -42,33 +41,31 @@ void philips_set(int setting, int value) | |||
42 | n = (4 * (value - 225000)) / 50000; | 41 | n = (4 * (value - 225000)) / 50000; |
43 | write_bytes[0] = (write_bytes[0] & 0xC0) | (n >> 8); | 42 | write_bytes[0] = (write_bytes[0] & 0xC0) | (n >> 8); |
44 | write_bytes[1] = n & 0xFF; | 43 | write_bytes[1] = n & 0xFF; |
45 | fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes)); | ||
46 | } | 44 | } |
47 | break; | 45 | break; |
48 | 46 | ||
49 | case RADIO_MUTE: | 47 | case RADIO_MUTE: |
50 | write_bytes[0] = (write_bytes[0] & 0x7F) | (value ? 0x80 : 0); | 48 | write_bytes[0] = (write_bytes[0] & 0x7F) | (value ? 0x80 : 0); |
51 | fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes)); | ||
52 | break; | ||
53 | |||
54 | case RADIO_IF_MEASUREMENT: | ||
55 | break; | ||
56 | |||
57 | case RADIO_SENSITIVITY: | ||
58 | break; | 49 | break; |
59 | 50 | ||
60 | case RADIO_FORCE_MONO: | 51 | case RADIO_FORCE_MONO: |
61 | write_bytes[2] = (write_bytes[2] & 0xF7) | (value ? 0x08 : 0); | 52 | write_bytes[2] = (write_bytes[2] & 0xF7) | (value ? 0x08 : 0); |
62 | fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes)); | 53 | fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes)); |
63 | break; | 54 | break; |
55 | |||
56 | case RADIO_IF_MEASUREMENT: | ||
57 | case RADIO_SENSITIVITY: | ||
58 | default: | ||
59 | return; | ||
64 | } | 60 | } |
61 | fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes)); | ||
65 | } | 62 | } |
66 | 63 | ||
67 | /* tuner abstraction layer: read something from the tuner */ | 64 | /* tuner abstraction layer: read something from the tuner */ |
68 | int philips_get(int setting) | 65 | int philips_get(int setting) |
69 | { | 66 | { |
70 | unsigned char read_bytes[5]; | 67 | unsigned char read_bytes[5]; |
71 | int val = -1; | 68 | int val = -1; /* default for unsupported query */ |
72 | 69 | ||
73 | fmradio_i2c_read(I2C_ADR, read_bytes, sizeof(read_bytes)); | 70 | fmradio_i2c_read(I2C_ADR, read_bytes, sizeof(read_bytes)); |
74 | 71 | ||
@@ -78,9 +75,9 @@ int philips_get(int setting) | |||
78 | val = 1; /* true */ | 75 | val = 1; /* true */ |
79 | break; | 76 | break; |
80 | 77 | ||
81 | case RADIO_IF_MEASURED: | 78 | case RADIO_DEVIATION: |
82 | val = read_bytes[2] & 0x7F; | 79 | val = read_bytes[2] & 0x7F; |
83 | val = 1070 + (val-55)/2; | 80 | val = 222 - val*4; /* convert to kHz */ |
84 | break; | 81 | break; |
85 | 82 | ||
86 | case RADIO_STEREO: | 83 | case RADIO_STEREO: |
diff --git a/firmware/tuner_samsung.c b/firmware/tuner_samsung.c index 781a4bcd3e..98166e1d4d 100644 --- a/firmware/tuner_samsung.c +++ b/firmware/tuner_samsung.c | |||
@@ -96,9 +96,9 @@ int samsung_get(int setting) | |||
96 | val = (val == 0x140885); | 96 | val = (val == 0x140885); |
97 | break; | 97 | break; |
98 | 98 | ||
99 | case RADIO_IF_MEASURED: | 99 | case RADIO_DEVIATION: |
100 | val = fmradio_read(3); | 100 | val = fmradio_read(3); |
101 | val = (val & 0x7ffff) / 80; /* convert to kHz */ | 101 | val = 10700 - ((val & 0x7ffff) / 8); /* convert to kHz */ |
102 | break; | 102 | break; |
103 | 103 | ||
104 | case RADIO_STEREO: | 104 | case RADIO_STEREO: |