summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/lang/english.lang77
-rw-r--r--apps/recorder/radio.c114
-rw-r--r--apps/recorder/radio.h12
-rw-r--r--apps/settings.c3
-rw-r--r--apps/settings.h4
-rw-r--r--firmware/export/tuner.h4
-rw-r--r--firmware/tuner_philips.c8
7 files changed, 190 insertions, 32 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 1c6c0a3a3e..f93ce0a0ac 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -7408,10 +7408,10 @@
7408 desc: in radio screen 7408 desc: in radio screen
7409 user: 7409 user:
7410 <source> 7410 <source>
7411 *: "Station: %d.%dMHz" 7411 *: "Station: %d.%02d MHz"
7412 </source> 7412 </source>
7413 <dest> 7413 <dest>
7414 *: "Station: %d.%dMHz" 7414 *: "Station: %d.%02d MHz"
7415 </dest> 7415 </dest>
7416 <voice> 7416 <voice>
7417 *: "" 7417 *: ""
@@ -7646,10 +7646,10 @@
7646 desc: during auto scan 7646 desc: during auto scan
7647 user: 7647 user:
7648 <source> 7648 <source>
7649 *: "Scanning %d.%01dMHz" 7649 *: "Scanning %d.%02d MHz"
7650 </source> 7650 </source>
7651 <dest> 7651 <dest>
7652 *: "Scanning %d.%01dMHz" 7652 *: "Scanning %d.%02d MHz"
7653 </dest> 7653 </dest>
7654 <voice> 7654 <voice>
7655 *: "" 7655 *: ""
@@ -7660,10 +7660,10 @@
7660 desc: default preset name for auto scan mode 7660 desc: default preset name for auto scan mode
7661 user: 7661 user:
7662 <source> 7662 <source>
7663 *: "%d.%01dMHz" 7663 *: "%d.%02d MHz"
7664 </source> 7664 </source>
7665 <dest> 7665 <dest>
7666 *: "%d.%01dMHz" 7666 *: "%d.%02d MHz"
7667 </dest> 7667 </dest>
7668 <voice> 7668 <voice>
7669 *: "" 7669 *: ""
@@ -9862,3 +9862,68 @@
9862 *: "Disable auto-resume if phones not present" 9862 *: "Disable auto-resume if phones not present"
9863 </voice> 9863 </voice>
9864</phrase> 9864</phrase>
9865<phrase>
9866 id: LANG_FM_REGION
9867 desc: fm tuner region setting
9868 <source>
9869 *: "Region"
9870 </source>
9871 <dest>
9872 *: "Region"
9873 </dest>
9874 <voice>
9875 *: "Region"
9876 </voice>
9877</phrase>
9878<phrase>
9879 id: LANG_FM_EUROPE
9880 desc: fm tuner region europe
9881 <source>
9882 *: "Europe"
9883 </source>
9884 <dest>
9885 *: "Europe"
9886 </dest>
9887 <voice>
9888 *: "Europe"
9889 </voice>
9890</phrase>
9891<phrase>
9892 id: LANG_FM_US
9893 desc: fm region us / canada
9894 <source>
9895 *: "US / Canada"
9896 </source>
9897 <dest>
9898 *: "US / Canada"
9899 </dest>
9900 <voice>
9901 *: "US / Canada"
9902 </voice>
9903</phrase>
9904<phrase>
9905 id: LANG_FM_JAPAN
9906 desc: fm region japan
9907 <source>
9908 *: "Japan"
9909 </source>
9910 <dest>
9911 *: "Japan"
9912 </dest>
9913 <voice>
9914 *: "Japan"
9915 </voice>
9916</phrase>
9917<phrase>
9918 id: LANG_FM_KOREA
9919 desc: fm region korea
9920 <source>
9921 *: "Korea"
9922 </source>
9923 <dest>
9924 *: "Korea"
9925 </dest>
9926 <voice>
9927 *: "Korea"
9928 </voice>
9929</phrase>
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 4afe0b2204..e7a5912235 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -85,13 +85,31 @@
85#define FM_RECORD 85#define FM_RECORD
86#endif 86#endif
87 87
88#define MAX_FREQ (108000000)
89#define MIN_FREQ (87500000)
90#define FREQ_STEP 100000
91
92#define RADIO_SCAN_MODE 0 88#define RADIO_SCAN_MODE 0
93#define RADIO_PRESET_MODE 1 89#define RADIO_PRESET_MODE 1
94 90
91#if (CONFIG_TUNER & TEA5767)
92#define DEEMPH_50 0,
93#define DEEMPH_75 1,
94#define BAND_LIM_EU 0
95#define BAND_LIM_JP 1
96#else
97#define DEEMPH_50
98#define DEEMPH_75
99#define BAND_LIM_EU
100#define BAND_LIM_JP
101#endif
102static struct fm_region_setting fm_region[] = {
103 /* Europe */
104 { LANG_FM_EUROPE, 87500000, 108000000, 50000, DEEMPH_50 BAND_LIM_EU },
105 /* US / Canada */
106 { LANG_FM_US, 87900000, 107900000, 200000, DEEMPH_75 BAND_LIM_EU },
107 /* Japan */
108 { LANG_FM_JAPAN, 76000000, 90000000, 100000, DEEMPH_50 BAND_LIM_JP },
109 /* Korea */
110 { LANG_FM_KOREA, 87500000, 108000000, 100000, DEEMPH_50 BAND_LIM_EU },
111 };
112
95static int curr_preset = -1; 113static int curr_preset = -1;
96static int curr_freq; 114static int curr_freq;
97static int radio_mode = RADIO_SCAN_MODE; 115static int radio_mode = RADIO_SCAN_MODE;
@@ -194,7 +212,9 @@ void radio_start(void)
194 if(radio_status == FMRADIO_OFF) 212 if(radio_status == FMRADIO_OFF)
195 radio_power(true); 213 radio_power(true);
196 214
197 curr_freq = global_settings.last_frequency * FREQ_STEP + MIN_FREQ; 215 curr_freq = global_settings.last_frequency
216 * fm_region[global_settings.fm_region].freq_step
217 + fm_region[global_settings.fm_region].freq_min;
198 218
199 radio_set(RADIO_SLEEP, 0); /* wake up the tuner */ 219 radio_set(RADIO_SLEEP, 0); /* wake up the tuner */
200 radio_set(RADIO_FREQUENCY, curr_freq); 220 radio_set(RADIO_FREQUENCY, curr_freq);
@@ -285,7 +305,7 @@ static int find_closest_preset(int freq)
285{ 305{
286 int i; 306 int i;
287 int diff; 307 int diff;
288 int min_diff = MAX_FREQ; 308 int min_diff = fm_region[global_settings.fm_region].freq_min;
289 int preset = -1; 309 int preset = -1;
290 310
291 for(i = 0;i < MAX_PRESETS;i++) 311 for(i = 0;i < MAX_PRESETS;i++)
@@ -307,7 +327,9 @@ static int find_closest_preset(int freq)
307 327
308static void remember_frequency(void) 328static void remember_frequency(void)
309{ 329{
310 global_settings.last_frequency = (curr_freq - MIN_FREQ) / FREQ_STEP; 330 global_settings.last_frequency = (curr_freq
331 - fm_region[global_settings.fm_region].freq_min)
332 / fm_region[global_settings.fm_region].freq_step;
311 settings_save(); 333 settings_save();
312} 334}
313 335
@@ -450,11 +472,12 @@ bool radio_screen(void)
450 { 472 {
451 if(search_dir) 473 if(search_dir)
452 { 474 {
453 curr_freq += search_dir * FREQ_STEP; 475 curr_freq += search_dir
454 if(curr_freq < MIN_FREQ) 476 * fm_region[global_settings.fm_region].freq_step;
455 curr_freq = MAX_FREQ; 477 if(curr_freq < fm_region[global_settings.fm_region].freq_min)
456 if(curr_freq > MAX_FREQ) 478 curr_freq = fm_region[global_settings.fm_region].freq_max;
457 curr_freq = MIN_FREQ; 479 if(curr_freq > fm_region[global_settings.fm_region].freq_max)
480 curr_freq = fm_region[global_settings.fm_region].freq_min;
458 481
459 /* Tune in and delay */ 482 /* Tune in and delay */
460 radio_set(RADIO_FREQUENCY, curr_freq); 483 radio_set(RADIO_FREQUENCY, curr_freq);
@@ -573,9 +596,11 @@ bool radio_screen(void)
573 case ACTION_STD_PREV: 596 case ACTION_STD_PREV:
574 if(radio_mode == RADIO_SCAN_MODE) 597 if(radio_mode == RADIO_SCAN_MODE)
575 { 598 {
576 curr_freq -= FREQ_STEP; 599 curr_freq
577 if(curr_freq < MIN_FREQ) 600 -= fm_region[global_settings.fm_region].freq_step;
578 curr_freq = MAX_FREQ; 601 if(curr_freq < fm_region[global_settings.fm_region].freq_min)
602 curr_freq
603 = fm_region[global_settings.fm_region].freq_max;
579 radio_set(RADIO_FREQUENCY, curr_freq); 604 radio_set(RADIO_FREQUENCY, curr_freq);
580 curr_preset = find_preset(curr_freq); 605 curr_preset = find_preset(curr_freq);
581 remember_frequency(); 606 remember_frequency();
@@ -589,9 +614,11 @@ bool radio_screen(void)
589 case ACTION_STD_NEXT: 614 case ACTION_STD_NEXT:
590 if(radio_mode == RADIO_SCAN_MODE) 615 if(radio_mode == RADIO_SCAN_MODE)
591 { 616 {
592 curr_freq += FREQ_STEP; 617 curr_freq
593 if(curr_freq > MAX_FREQ) 618 += fm_region[global_settings.fm_region].freq_step;
594 curr_freq = MIN_FREQ; 619 if(curr_freq > fm_region[global_settings.fm_region].freq_max)
620 curr_freq
621 = fm_region[global_settings.fm_region].freq_min;
595 radio_set(RADIO_FREQUENCY, curr_freq); 622 radio_set(RADIO_FREQUENCY, curr_freq);
596 curr_preset = find_preset(curr_freq); 623 curr_preset = find_preset(curr_freq);
597 remember_frequency(); 624 remember_frequency();
@@ -821,8 +848,8 @@ bool radio_screen(void)
821 FOR_NB_SCREENS(i) 848 FOR_NB_SCREENS(i)
822 screens[i].puts_scroll(0, top_of_screen, buf); 849 screens[i].puts_scroll(0, top_of_screen, buf);
823 850
824 freq = curr_freq / 100000; 851 freq = curr_freq / 10000;
825 snprintf(buf, 128, str(LANG_FM_STATION), freq / 10, freq % 10); 852 snprintf(buf, 128, str(LANG_FM_STATION), freq / 100, freq % 100);
826 FOR_NB_SCREENS(i) 853 FOR_NB_SCREENS(i)
827 screens[i].puts_scroll(0, top_of_screen + 1, buf); 854 screens[i].puts_scroll(0, top_of_screen + 1, buf);
828 855
@@ -1316,6 +1343,39 @@ static bool toggle_mono_mode(void)
1316 return false; 1343 return false;
1317} 1344}
1318 1345
1346char region_menu_string[32];
1347static void create_region_menu(void)
1348{
1349 snprintf(region_menu_string, sizeof(region_menu_string),
1350 "%s: %s", str(LANG_FM_REGION),
1351 str(fm_region[global_settings.fm_region].lang));
1352}
1353
1354static bool toggle_region_mode(void)
1355{
1356 global_settings.fm_region++;
1357 if(global_settings.fm_region >=
1358 (int)(sizeof(fm_region) / sizeof(struct fm_region_setting)))
1359 global_settings.fm_region = 0;
1360#if (CONFIG_TUNER & TEA5767)
1361 radio_set(RADIO_SET_DEEMPHASIS,
1362 fm_region[global_settings.fm_region].deemphasis);
1363 radio_set(RADIO_SET_BAND, fm_region[global_settings.fm_region].band);
1364#endif
1365 /* make sure the current frequency is in the region range */
1366 curr_freq -= (curr_freq - fm_region[global_settings.fm_region].freq_min)
1367 % fm_region[global_settings.fm_region].freq_step;
1368 if(curr_freq < fm_region[global_settings.fm_region].freq_min)
1369 curr_freq = fm_region[global_settings.fm_region].freq_min;
1370 if(curr_freq > fm_region[global_settings.fm_region].freq_max)
1371 curr_freq = fm_region[global_settings.fm_region].freq_max;
1372 radio_set(RADIO_FREQUENCY, curr_freq);
1373
1374 settings_save();
1375 create_region_menu();
1376 return false;
1377}
1378
1319#ifndef FM_MODE 1379#ifndef FM_MODE
1320char radiomode_menu_string[32]; 1380char radiomode_menu_string[32];
1321 1381
@@ -1346,17 +1406,17 @@ static bool scan_presets(void)
1346 1406
1347 if(do_scan) 1407 if(do_scan)
1348 { 1408 {
1349 curr_freq = MIN_FREQ; 1409 curr_freq = fm_region[global_settings.fm_region].freq_min;
1350 num_presets = 0; 1410 num_presets = 0;
1351 memset(presets, 0, sizeof(presets)); 1411 memset(presets, 0, sizeof(presets));
1352 while(curr_freq <= MAX_FREQ) 1412 while(curr_freq <= fm_region[global_settings.fm_region].freq_max)
1353 { 1413 {
1354 if (num_presets >= MAX_PRESETS) 1414 if (num_presets >= MAX_PRESETS)
1355 break; 1415 break;
1356 1416
1357 freq = curr_freq /100000; 1417 freq = curr_freq / 10000;
1358 snprintf(buf, MAX_FMPRESET_LEN, str(LANG_FM_SCANNING), 1418 snprintf(buf, MAX_FMPRESET_LEN, str(LANG_FM_SCANNING),
1359 freq/10, freq % 10); 1419 freq/100, freq % 100);
1360 gui_syncsplash(0, true, buf); 1420 gui_syncsplash(0, true, buf);
1361 1421
1362 /* Tune in and delay */ 1422 /* Tune in and delay */
@@ -1373,13 +1433,13 @@ static bool scan_presets(void)
1373 /* add preset */ 1433 /* add preset */
1374 if(tuned){ 1434 if(tuned){
1375 snprintf(buf, MAX_FMPRESET_LEN, 1435 snprintf(buf, MAX_FMPRESET_LEN,
1376 str(LANG_FM_DEFAULT_PRESET_NAME),freq/10, freq % 10); 1436 str(LANG_FM_DEFAULT_PRESET_NAME),freq/100, freq % 100);
1377 strcpy(presets[num_presets].name,buf); 1437 strcpy(presets[num_presets].name,buf);
1378 presets[num_presets].frequency = curr_freq; 1438 presets[num_presets].frequency = curr_freq;
1379 num_presets++; 1439 num_presets++;
1380 } 1440 }
1381 1441
1382 curr_freq += FREQ_STEP; 1442 curr_freq += fm_region[global_settings.fm_region].freq_step;
1383 1443
1384 } 1444 }
1385 1445
@@ -1504,6 +1564,7 @@ bool radio_menu(void)
1504#ifndef FM_MODE 1564#ifndef FM_MODE
1505 { radiomode_menu_string , toggle_radio_mode }, 1565 { radiomode_menu_string , toggle_radio_mode },
1506#endif 1566#endif
1567 { region_menu_string , toggle_region_mode },
1507 { ID2P(LANG_SOUND_SETTINGS) , sound_menu }, 1568 { ID2P(LANG_SOUND_SETTINGS) , sound_menu },
1508#ifndef SIMULATOR 1569#ifndef SIMULATOR
1509#if defined(HAVE_FMRADIO_IN) || CONFIG_CODEC != SWCODEC 1570#if defined(HAVE_FMRADIO_IN) || CONFIG_CODEC != SWCODEC
@@ -1515,6 +1576,7 @@ bool radio_menu(void)
1515 }; 1576 };
1516 1577
1517 create_monomode_menu(); 1578 create_monomode_menu();
1579 create_region_menu();
1518#ifndef FM_MODE 1580#ifndef FM_MODE
1519 create_radiomode_menu(); 1581 create_radiomode_menu();
1520#endif 1582#endif
diff --git a/apps/recorder/radio.h b/apps/recorder/radio.h
index fdf446dc0a..439061e579 100644
--- a/apps/recorder/radio.h
+++ b/apps/recorder/radio.h
@@ -42,6 +42,18 @@ struct fmstation
42 char name[MAX_FMPRESET_LEN+1]; 42 char name[MAX_FMPRESET_LEN+1];
43}; 43};
44 44
45struct fm_region_setting
46{
47 int lang;
48 int freq_min;
49 int freq_max;
50 int freq_step;
51#if (CONFIG_TUNER & TEA5767)
52 int deemphasis; /* 0: 50us, 1: 75us */
53 int band; /* 0: europe, 1: japan (BL in TEA spec)*/
54#endif
55};
56
45#endif 57#endif
46 58
47#endif 59#endif
diff --git a/apps/settings.c b/apps/settings.c
index d419d4ae8b..ebe0d1e4cd 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -661,6 +661,9 @@ static const struct bit_entry hd_bits[] =
661 {4, S_O(unplug_rw), 0, "rewind duration on pause", NULL}, 661 {4, S_O(unplug_rw), 0, "rewind duration on pause", NULL},
662 {1, S_O(unplug_autoresume), 0, "disable autoresume if phones not present", off_on }, 662 {1, S_O(unplug_autoresume), 0, "disable autoresume if phones not present", off_on },
663#endif 663#endif
664#ifdef CONFIG_TUNER
665 {2, S_O(fm_region), 0, "fm_region", "eu,us,jp,kr" },
666#endif
664 667
665 /* If values are just added to the end, no need to bump the version. */ 668 /* If values are just added to the end, no need to bump the version. */
666 /* new stuff to be added at the end */ 669 /* new stuff to be added at the end */
diff --git a/apps/settings.h b/apps/settings.h
index 09834ec183..b29a219733 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -491,6 +491,10 @@ struct user_settings
491 int unplug_rw; /* time in s to rewind when pausing */ 491 int unplug_rw; /* time in s to rewind when pausing */
492 bool unplug_autoresume; /* disable auto-resume if no phones */ 492 bool unplug_autoresume; /* disable auto-resume if no phones */
493#endif 493#endif
494#ifdef CONFIG_TUNER
495 int fm_region;
496#endif
497
494}; 498};
495 499
496enum optiontype { INT, BOOL }; 500enum optiontype { INT, BOOL };
diff --git a/firmware/export/tuner.h b/firmware/export/tuner.h
index a6a7e8ee0e..48d9bc97d1 100644
--- a/firmware/export/tuner.h
+++ b/firmware/export/tuner.h
@@ -27,6 +27,10 @@
27#define RADIO_IF_MEASUREMENT 3 27#define RADIO_IF_MEASUREMENT 3
28#define RADIO_SENSITIVITY 4 28#define RADIO_SENSITIVITY 4
29#define RADIO_FORCE_MONO 5 29#define RADIO_FORCE_MONO 5
30#if (CONFIG_TUNER & TEA5767)
31#define RADIO_SET_DEEMPHASIS 6
32#define RADIO_SET_BAND 7
33#endif
30/* readback from the tuner layer */ 34/* readback from the tuner layer */
31#define RADIO_PRESENT 0 35#define RADIO_PRESENT 0
32#define RADIO_TUNED 1 36#define RADIO_TUNED 1
diff --git a/firmware/tuner_philips.c b/firmware/tuner_philips.c
index 2958e9e829..89c7dd11c7 100644
--- a/firmware/tuner_philips.c
+++ b/firmware/tuner_philips.c
@@ -73,6 +73,14 @@ void philips_set(int setting, int value)
73 fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes)); 73 fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes));
74 break; 74 break;
75 75
76 case RADIO_SET_DEEMPHASIS:
77 write_bytes[4] = (write_bytes[4] & ~(1<<6)) | (value ? (1<<6) : 0);
78 fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes));
79 break;
80
81 case RADIO_SET_BAND:
82 write_bytes[3] = (write_bytes[3] & ~(1<<5)) | (value ? (1<<5) : 0);
83 fmradio_i2c_write(I2C_ADR, write_bytes, sizeof(write_bytes));
76 default: 84 default:
77 return; 85 return;
78 } 86 }