summaryrefslogtreecommitdiff
path: root/firmware/drivers/tuner
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/tuner')
-rw-r--r--firmware/drivers/tuner/ipod_remote_tuner.c17
-rw-r--r--firmware/drivers/tuner/lv24020lp.c5
-rw-r--r--firmware/drivers/tuner/rda5802.c25
-rw-r--r--firmware/drivers/tuner/si4700.c15
-rw-r--r--firmware/drivers/tuner/tea5760uk.c9
-rw-r--r--firmware/drivers/tuner/tea5767.c9
6 files changed, 47 insertions, 33 deletions
diff --git a/firmware/drivers/tuner/ipod_remote_tuner.c b/firmware/drivers/tuner/ipod_remote_tuner.c
index 25ad2d9845..52d93b8b34 100644
--- a/firmware/drivers/tuner/ipod_remote_tuner.c
+++ b/firmware/drivers/tuner/ipod_remote_tuner.c
@@ -177,8 +177,9 @@ void rmt_tuner_region(int region)
177{ 177{
178 if (region != old_region) 178 if (region != old_region)
179 { 179 {
180 const struct fm_region_data *rd = &fm_region_data[region];
180 unsigned char data[] = {0x07, 0x08, 0x00}; 181 unsigned char data[] = {0x07, 0x08, 0x00};
181 if (region == 2) 182 if (rd->freq_min == 76000000)
182 { 183 {
183 data[2] = 0x02; /* japan band */ 184 data[2] = 0x02; /* japan band */
184 } 185 }
@@ -378,12 +379,14 @@ int ipod_rmt_tuner_set(int setting, int value)
378 379
379 case RADIO_REGION: 380 case RADIO_REGION:
380 { 381 {
381 const struct rmt_tuner_region_data *rd = 382 const struct fm_region_data *rd = &fm_region_data[value];
382 &rmt_tuner_region_data[value]; 383 int band = (rd->freq_min == 76000000) ? 2 : 0;
383 384 int spacing = (100000 / rd->freq_step);
384 rmt_tuner_region(rd->band); 385 int deemphasis = (rd->deemphasis == 50) ? 1 : 0;
385 set_deltafreq(rd->spacing); 386
386 set_deemphasis(rd->deemphasis); 387 rmt_tuner_region(band);
388 set_deltafreq(spacing);
389 set_deemphasis(deemphasis);
387 rmt_tuner_set_param(tuner_param); 390 rmt_tuner_set_param(tuner_param);
388 break; 391 break;
389 } 392 }
diff --git a/firmware/drivers/tuner/lv24020lp.c b/firmware/drivers/tuner/lv24020lp.c
index 86f8c39593..0228888309 100644
--- a/firmware/drivers/tuner/lv24020lp.c
+++ b/firmware/drivers/tuner/lv24020lp.c
@@ -938,11 +938,14 @@ int lv24020lp_set(int setting, int value)
938 break; 938 break;
939 939
940 case RADIO_REGION: 940 case RADIO_REGION:
941 if (lv24020lp_region_data[value]) 941 {
942 const struct fm_region_data *rd = &fm_region_data[value];
943 if (rd->deemphasis == 75)
942 lv24020lp_write_set(AUDIO_CTRL2, DEEMP); 944 lv24020lp_write_set(AUDIO_CTRL2, DEEMP);
943 else 945 else
944 lv24020lp_write_clear(AUDIO_CTRL2, DEEMP); 946 lv24020lp_write_clear(AUDIO_CTRL2, DEEMP);
945 break; 947 break;
948 }
946 949
947 case RADIO_FORCE_MONO: 950 case RADIO_FORCE_MONO:
948 if (value) 951 if (value)
diff --git a/firmware/drivers/tuner/rda5802.c b/firmware/drivers/tuner/rda5802.c
index a505b6b382..8c78a9f243 100644
--- a/firmware/drivers/tuner/rda5802.c
+++ b/firmware/drivers/tuner/rda5802.c
@@ -59,16 +59,16 @@
59#define CHANNEL_BAND (0x3 << 2) 59#define CHANNEL_BAND (0x3 << 2)
60 #define CHANNEL_BANDw(x) (((x) << 2) & CHANNEL_BAND) 60 #define CHANNEL_BANDw(x) (((x) << 2) & CHANNEL_BAND)
61 #define CHANNEL_BANDr(x) (((x) & CHANNEL_BAND) >> 2) 61 #define CHANNEL_BANDr(x) (((x) & CHANNEL_BAND) >> 2)
62 #define CHANNEL_BAND_875_1080 (0x0 << 2) /* tenth-megahertz */ 62 #define CHANNEL_BAND_870_1080 (0x0) /* tenth-megahertz */
63 #define CHANNEL_BAND_760_1080 (0x1 << 2) 63 #define CHANNEL_BAND_760_1080 (0x1)
64 #define CHANNEL_BAND_760_900 (0x2 << 2) 64 #define CHANNEL_BAND_760_900 (0x2)
65 #define CHANNEL_BAND_650_760 (0x3 << 2) 65 #define CHANNEL_BAND_650_760 (0x3)
66#define CHANNEL_SPACE (0x3 << 0) 66#define CHANNEL_SPACE (0x3 << 0)
67 #define CHANNEL_SPACEw(x) (((x) << 0) & CHANNEL_SPACE) 67 #define CHANNEL_SPACEw(x) (((x) << 0) & CHANNEL_SPACE)
68 #define CHANNEL_SPACEr(x) (((x) & CHANNEL_SPACE) >> 0) 68 #define CHANNEL_SPACEr(x) (((x) & CHANNEL_SPACE) >> 0)
69 #define CHANNEL_SPACE_100KHZ (0x0 << 0) 69 #define CHANNEL_SPACE_100KHZ (0x0)
70 #define CHANNEL_SPACE_200KHZ (0x1 << 0) 70 #define CHANNEL_SPACE_200KHZ (0x1)
71 #define CHANNEL_SPACE_50KHZ (0x2 << 0) 71 #define CHANNEL_SPACE_50KHZ (0x2)
72 72
73/* SYSCONFIG1 (0x4) */ 73/* SYSCONFIG1 (0x4) */
74#define SYSCONFIG1_DE (0x1 << 11) 74#define SYSCONFIG1_DE (0x1 << 11)
@@ -239,13 +239,16 @@ static int rda5802_tuned(void)
239 239
240static void rda5802_set_region(int region) 240static void rda5802_set_region(int region)
241{ 241{
242 const struct rda5802_region_data *rd = &rda5802_region_data[region]; 242 const struct fm_region_data *rd = &fm_region_data[region];
243 uint16_t bandspacing = CHANNEL_BANDw(rd->band) | 243 int band = (rd->freq_min == 76000000) ?
244 CHANNEL_BAND_760_900 : CHANNEL_BAND_870_1080;
245 int deemphasis = (rd->deemphasis == 50) ? SYSCONFIG1_DE : 0;
246
247 uint16_t bandspacing = CHANNEL_BANDw(band) |
244 CHANNEL_SPACEw(CHANNEL_SPACE_50KHZ); 248 CHANNEL_SPACEw(CHANNEL_SPACE_50KHZ);
245 uint16_t oldbs = cache[CHANNEL] & (CHANNEL_BAND | CHANNEL_SPACE); 249 uint16_t oldbs = cache[CHANNEL] & (CHANNEL_BAND | CHANNEL_SPACE);
246 250
247 rda5802_write_masked(SYSCONFIG1, rd->deemphasis ? SYSCONFIG1_DE : 0, 251 rda5802_write_masked(SYSCONFIG1, deemphasis, SYSCONFIG1_DE);
248 SYSCONFIG1_DE);
249 rda5802_write_masked(CHANNEL, bandspacing, CHANNEL_BAND | CHANNEL_SPACE); 252 rda5802_write_masked(CHANNEL, bandspacing, CHANNEL_BAND | CHANNEL_SPACE);
250 rda5802_write_cache(); 253 rda5802_write_cache();
251 254
diff --git a/firmware/drivers/tuner/si4700.c b/firmware/drivers/tuner/si4700.c
index f9b26be6f8..ea88dc9835 100644
--- a/firmware/drivers/tuner/si4700.c
+++ b/firmware/drivers/tuner/si4700.c
@@ -400,14 +400,17 @@ static int si4700_tuned(void)
400 400
401static void si4700_set_region(int region) 401static void si4700_set_region(int region)
402{ 402{
403 const struct si4700_region_data *rd = &si4700_region_data[region]; 403 const struct fm_region_data *rd = &fm_region_data[region];
404 uint16_t bandspacing = SYSCONFIG2_BANDw(rd->band) | 404
405 SYSCONFIG2_SPACEw(rd->spacing); 405 int band = (rd->freq_min == 76000000) ? 2 : 0;
406 int spacing = (100000 / rd->freq_step);
407 int deemphasis = (rd->deemphasis == 50) ? SYSCONFIG1_DE : 0;
408
409 uint16_t bandspacing = SYSCONFIG2_BANDw(band) |
410 SYSCONFIG2_SPACEw(spacing);
406 uint16_t oldbs = cache[SYSCONFIG2] & (SYSCONFIG2_BAND | SYSCONFIG2_SPACE); 411 uint16_t oldbs = cache[SYSCONFIG2] & (SYSCONFIG2_BAND | SYSCONFIG2_SPACE);
407 412
408 si4700_write_masked(SYSCONFIG1, 413 si4700_write_masked(SYSCONFIG1, deemphasis, SYSCONFIG1_DE);
409 rd->deemphasis ? SYSCONFIG1_DE : 0,
410 SYSCONFIG1_DE);
411 si4700_write_masked(SYSCONFIG2, bandspacing, 414 si4700_write_masked(SYSCONFIG2, bandspacing,
412 SYSCONFIG2_BAND | SYSCONFIG2_SPACE); 415 SYSCONFIG2_BAND | SYSCONFIG2_SPACE);
413 416
diff --git a/firmware/drivers/tuner/tea5760uk.c b/firmware/drivers/tuner/tea5760uk.c
index db07e20cf4..20234e28ed 100644
--- a/firmware/drivers/tuner/tea5760uk.c
+++ b/firmware/drivers/tuner/tea5760uk.c
@@ -91,11 +91,12 @@ int tea5760_set(int setting, int value)
91 91
92 case RADIO_REGION: 92 case RADIO_REGION:
93 { 93 {
94 const struct tea5760_region_data *rd = 94 const struct fm_region_data *rd = &fm_region_data[value];
95 &tea5760_region_data[value]; 95 int band = (rd->freq_min == 76000000) ? 1 : 0;
96 int deemphasis = (rd->deemphasis == 50) ? 1 : 0;
96 97
97 tea5760_set_clear(4, (1<<1), rd->deemphasis); 98 tea5760_set_clear(3, (1<<5), band);
98 tea5760_set_clear(3, (1<<5), rd->band); 99 tea5760_set_clear(4, (1<<1), deemphasis);
99 } 100 }
100 break; 101 break;
101 102
diff --git a/firmware/drivers/tuner/tea5767.c b/firmware/drivers/tuner/tea5767.c
index 5888e00781..b16bb4b7c5 100644
--- a/firmware/drivers/tuner/tea5767.c
+++ b/firmware/drivers/tuner/tea5767.c
@@ -86,11 +86,12 @@ int tea5767_set(int setting, int value)
86 86
87 case RADIO_REGION: 87 case RADIO_REGION:
88 { 88 {
89 const struct tea5767_region_data *rd = 89 const struct fm_region_data *rd = &fm_region_data[value];
90 &tea5767_region_data[value]; 90 int deemphasis = (rd->deemphasis == 75) ? 1 : 0;
91 int band = (rd->freq_min == 76000000) ? 1 : 0;
91 92
92 tea5767_set_clear(4, (1<<6), rd->deemphasis); 93 tea5767_set_clear(4, (1<<6), deemphasis);
93 tea5767_set_clear(3, (1<<5), rd->band); 94 tea5767_set_clear(3, (1<<5), band);
94 break; 95 break;
95 } 96 }
96 case RADIO_FORCE_MONO: 97 case RADIO_FORCE_MONO: