Remove leftover backslash from macro conversion in FRACTMUL_SHL
[maemo-rb.git] / apps / radio / radio.c
blobe4b14c843e2d531427e88b0da9fbc2698e13ca56
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2003 Linus Nielsen Feltzing
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include <stdio.h>
23 #include <stdbool.h>
24 #include <stdlib.h>
25 #include "config.h"
26 #include "system.h"
27 #include "settings.h"
28 #include "status.h"
29 #include "audio.h"
30 #include "general.h"
31 #include "radio.h"
32 #include "menu.h"
33 #include "menus/exported_menus.h"
34 #include "misc.h"
35 #include "screens.h"
36 #include "peakmeter.h"
37 #include "lang.h"
38 #ifdef HAVE_RECORDING
39 #include "recording.h"
40 #endif
41 #ifdef IPOD_ACCESSORY_PROTOCOL
42 #include "iap.h"
43 #endif
44 #include "talk.h"
45 #include "tuner.h"
46 #include "power.h"
47 #include "sound.h"
48 #include "screen_access.h"
49 #include "splash.h"
50 #include "yesno.h"
51 #include "tree.h"
52 #include "dir.h"
53 #include "action.h"
54 #include "viewport.h"
55 #include "skin_engine/skin_engine.h"
56 #include "statusbar-skinned.h"
57 #if CONFIG_CODEC == SWCODEC
58 #include "playback.h"
59 #endif
60 #include "presets.h"
62 #if CONFIG_TUNER
64 #if CONFIG_KEYPAD == RECORDER_PAD
65 #define FM_RECORD
66 #define FM_PRESET_ADD
67 #define FM_PRESET_ACTION
68 #define FM_PRESET
69 #define FM_MODE
71 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
72 #define FM_PRESET
73 #define FM_MODE
74 #define FM_NEXT_PRESET
75 #define FM_PREV_PRESET
77 #elif CONFIG_KEYPAD == IRIVER_H10_PAD
78 #define FM_PRESET
79 #define FM_MODE
81 #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
82 #define FM_PRESET
83 #define FM_MODE
84 /* This should be removeable if the whole tuning thing is sorted out since
85 proper tuning quiets the screen almost entirely in that extreme measures
86 have to be taken to hear any interference. */
87 #define HAVE_NOISY_IDLE_MODE
89 #elif CONFIG_KEYPAD == ONDIO_PAD
90 #define FM_RECORD_DBLPRE
91 #define FM_RECORD
93 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || (CONFIG_KEYPAD == SANSA_C200_PAD) ||\
94 (CONFIG_KEYPAD == SANSA_FUZE_PAD) || (CONFIG_KEYPAD == SANSA_CLIP_PAD)
95 #define FM_MENU
96 #define FM_PRESET
97 #define FM_STOP
98 #define FM_MODE
99 #define FM_EXIT
100 #define FM_PLAY
102 #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
103 #define FM_PRESET
104 #define FM_MODE
106 #elif (CONFIG_KEYPAD == COWON_D2_PAD)
107 #define FM_MENU
108 #define FM_PRESET
109 #define FM_STOP
110 #define FM_MODE
111 #define FM_EXIT
112 #define FM_PLAY
114 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
115 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
116 #define FM_MENU
117 #define FM_STOP
118 #define FM_EXIT
119 #define FM_PLAY
120 #define FM_MODE
122 #elif (CONFIG_KEYPAD == MPIO_HD200_PAD)
123 #define FM_MENU
124 #define FM_STOP
125 #define FM_EXIT
126 #define FM_PLAY
127 #define FM_MODE
128 #define FM_STOP
130 #endif
132 /* presets.c needs these so keep unstatic or redo the whole thing! */
133 int curr_freq; /* current frequency in Hz */
134 int radio_mode = RADIO_SCAN_MODE;
136 static int search_dir = 0;
137 static int radio_status = FMRADIO_OFF;
138 static bool in_screen = false;
141 static void radio_off(void);
143 bool radio_scan_mode(void)
145 return radio_mode == RADIO_SCAN_MODE;
148 bool radio_is_stereo(void)
150 return tuner_get(RADIO_STEREO) && !global_settings.fm_force_mono;
152 int radio_current_frequency(void)
154 return curr_freq;
157 /* Function to manipulate all yesno dialogues.
158 This function needs the output text as an argument. */
159 bool yesno_pop(const char* text)
161 int i;
162 const char *lines[]={text};
163 const struct text_message message={lines, 1};
164 bool ret = (gui_syncyesno_run(&message,NULL,NULL)== YESNO_YES);
165 FOR_NB_SCREENS(i)
166 screens[i].clear_viewport();
167 return ret;
170 void radio_init(void)
172 tuner_init();
173 radio_off();
174 #ifdef HAVE_ALBUMART
175 radioart_init(false);
176 #endif
179 int get_radio_status(void)
181 return radio_status;
184 bool in_radio_screen(void)
186 return in_screen;
189 /* TODO: Move some more of the control functionality to firmware
190 and clean up the mess */
192 /* secret flag for starting paused - prevents unmute */
193 #define FMRADIO_START_PAUSED 0x8000
194 void radio_start(void)
196 const struct fm_region_data *fmr;
197 bool start_paused;
199 if(radio_status == FMRADIO_PLAYING)
200 return;
202 fmr = &fm_region_data[global_settings.fm_region];
204 start_paused = radio_status & FMRADIO_START_PAUSED;
205 /* clear flag before any yielding */
206 radio_status &= ~FMRADIO_START_PAUSED;
208 if(radio_status == FMRADIO_OFF)
209 tuner_power(true);
211 curr_freq = global_status.last_frequency * fmr->freq_step + fmr->freq_min;
213 tuner_set(RADIO_SLEEP, 0); /* wake up the tuner */
215 if(radio_status == FMRADIO_OFF)
217 #ifdef HAVE_RADIO_REGION
218 tuner_set(RADIO_REGION, global_settings.fm_region);
219 #endif
220 tuner_set(RADIO_FORCE_MONO, global_settings.fm_force_mono);
223 tuner_set(RADIO_FREQUENCY, curr_freq);
225 #ifdef HAVE_RADIO_MUTE_TIMEOUT
227 unsigned long mute_timeout = current_tick + HZ;
228 if (radio_status != FMRADIO_OFF)
230 /* paused */
231 mute_timeout += HZ;
234 while(!tuner_get(RADIO_STEREO) && !tuner_get(RADIO_TUNED))
236 if(TIME_AFTER(current_tick, mute_timeout))
237 break;
238 yield();
241 #endif
243 /* keep radio from sounding initially */
244 if(!start_paused)
245 tuner_set(RADIO_MUTE, 0);
247 radio_status = FMRADIO_PLAYING;
248 } /* radio_start */
250 void radio_pause(void)
252 if(radio_status == FMRADIO_PAUSED)
253 return;
255 if(radio_status == FMRADIO_OFF)
257 radio_status |= FMRADIO_START_PAUSED;
258 radio_start();
261 tuner_set(RADIO_MUTE, 1);
262 /* For si4700: 2==this is really 'pause'. other tuners treat it
263 * like 'bool'. */
264 tuner_set(RADIO_SLEEP, 2);
266 radio_status = FMRADIO_PAUSED;
267 } /* radio_pause */
269 static void radio_off(void)
271 tuner_set(RADIO_MUTE, 1);
272 tuner_set(RADIO_SLEEP, 1); /* low power mode, if available */
273 radio_status = FMRADIO_OFF;
274 tuner_power(false); /* status update, power off if avail. */
277 void radio_stop(void)
279 if(radio_status == FMRADIO_OFF)
280 return;
282 radio_off();
283 } /* radio_stop */
285 bool radio_hardware_present(void)
287 return tuner_get(RADIO_PRESENT);
290 /* Keep freq on the grid for the current region */
291 int snap_freq_to_grid(int freq)
293 const struct fm_region_data * const fmr =
294 &fm_region_data[global_settings.fm_region];
296 /* Range clamp if out of range or just round to nearest */
297 if (freq < fmr->freq_min)
298 freq = fmr->freq_min;
299 else if (freq > fmr->freq_max)
300 freq = fmr->freq_max;
301 else
302 freq = (freq - fmr->freq_min + fmr->freq_step/2) /
303 fmr->freq_step * fmr->freq_step + fmr->freq_min;
305 return freq;
308 void remember_frequency(void)
310 const struct fm_region_data * const fmr =
311 &fm_region_data[global_settings.fm_region];
312 global_status.last_frequency = (curr_freq - fmr->freq_min)
313 / fmr->freq_step;
314 status_save();
317 /* Step to the next or previous frequency */
318 static int step_freq(int freq, int direction)
320 const struct fm_region_data * const fmr =
321 &fm_region_data[global_settings.fm_region];
323 freq += direction*fmr->freq_step;
325 /* Wrap first or snapping to grid will not let us on the band extremes */
326 if (freq > fmr->freq_max)
327 freq = direction > 0 ? fmr->freq_min : fmr->freq_max;
328 else if (freq < fmr->freq_min)
329 freq = direction < 0 ? fmr->freq_max : fmr->freq_min;
330 else
331 freq = snap_freq_to_grid(freq);
333 return freq;
336 /* Step to the next or previous station */
337 void next_station(int direction)
339 if (direction != 0 && radio_mode != RADIO_SCAN_MODE)
341 preset_next(direction);
342 return;
345 curr_freq = step_freq(curr_freq, direction);
347 if (radio_status == FMRADIO_PLAYING)
348 tuner_set(RADIO_MUTE, 1);
350 tuner_set(RADIO_FREQUENCY, curr_freq);
352 if (radio_status == FMRADIO_PLAYING)
353 tuner_set(RADIO_MUTE, 0);
355 preset_set_current(preset_find(curr_freq));
356 remember_frequency();
359 /* Ends an in-progress search */
360 static void end_search(void)
362 if (search_dir != 0 && radio_status == FMRADIO_PLAYING)
363 tuner_set(RADIO_MUTE, 0);
364 search_dir = 0;
367 void radio_screen(void)
369 bool done = false;
370 int button;
371 int i;
372 bool stereo = false, last_stereo = false;
373 int update_type = 0;
374 bool screen_freeze = false;
375 bool keep_playing = false;
376 bool talk = false;
377 #ifdef FM_RECORD_DBLPRE
378 int lastbutton = BUTTON_NONE;
379 unsigned long rec_lastclick = 0;
380 #endif
381 #if CONFIG_CODEC != SWCODEC
382 int timeout = current_tick + HZ/10;
383 #if !defined(SIMULATOR)
384 unsigned int last_seconds = 0;
385 unsigned int seconds = 0;
386 struct audio_recording_options rec_options;
387 #endif /* SIMULATOR */
388 #endif /* CONFIG_CODEC != SWCODEC */
389 #ifndef HAVE_NOISY_IDLE_MODE
390 int button_timeout = current_tick + (2*HZ);
391 #endif
393 /* change status to "in screen" */
394 push_current_activity(ACTIVITY_FM);
395 in_screen = true;
397 if(radio_preset_count() <= 0)
399 radio_load_presets(global_settings.fmr_file);
401 skin_get_global_state()->id3 = NULL;
402 #ifdef HAVE_ALBUMART
403 radioart_init(true);
404 #endif
406 if(radio_status == FMRADIO_OFF)
407 audio_stop();
409 #ifndef SIMULATOR
411 #if CONFIG_CODEC != SWCODEC
412 rec_create_directory();
413 audio_init_recording(talk_get_bufsize());
415 sound_settings_apply();
416 /* Yes, we use the D/A for monitoring */
417 peak_meter_playback(true);
419 peak_meter_enable(true);
421 rec_init_recording_options(&rec_options);
422 rec_options.rec_source = AUDIO_SRC_LINEIN;
423 rec_set_recording_options(&rec_options);
425 audio_set_recording_gain(sound_default(SOUND_LEFT_GAIN),
426 sound_default(SOUND_RIGHT_GAIN), AUDIO_GAIN_LINEIN);
428 #endif /* CONFIG_CODEC != SWCODEC */
429 #endif /* ndef SIMULATOR */
431 /* turn on radio */
432 #if CONFIG_CODEC == SWCODEC
433 /* This should be done before touching audio settings */
434 while (!audio_is_thread_ready())
435 sleep(0);
437 audio_set_input_source(AUDIO_SRC_FMRADIO,
438 (radio_status == FMRADIO_PAUSED) ?
439 SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING);
440 #else
441 if (radio_status == FMRADIO_OFF)
442 radio_start();
443 #endif
445 if(radio_preset_count() < 1 && yesno_pop(ID2P(LANG_FM_FIRST_AUTOSCAN)))
446 presets_scan(NULL);
448 fms_fix_displays(FMS_ENTER);
449 FOR_NB_SCREENS(i)
450 skin_update(FM_SCREEN, i, SKIN_REFRESH_ALL);
452 preset_set_current(preset_find(curr_freq));
453 if(radio_current_preset() != -1)
454 radio_mode = RADIO_PRESET_MODE;
456 #ifndef HAVE_NOISY_IDLE_MODE
457 cpu_idle_mode(true);
458 #endif
460 while(!done)
462 if(search_dir != 0)
464 curr_freq = step_freq(curr_freq, search_dir);
465 update_type = SKIN_REFRESH_ALL;
467 if(tuner_set(RADIO_SCAN_FREQUENCY, curr_freq))
469 preset_set_current(preset_find(curr_freq));
470 remember_frequency();
471 end_search();
472 talk = true;
474 trigger_cpu_boost();
477 if (!update_type)
479 cancel_cpu_boost();
482 button = fms_do_button_loop(update_type>0);
484 #ifndef HAVE_NOISY_IDLE_MODE
485 if (button != ACTION_NONE)
487 cpu_idle_mode(false);
488 button_timeout = current_tick + (2*HZ);
490 #endif
491 switch(button)
493 case ACTION_FM_STOP:
494 #if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
495 if(audio_status() == AUDIO_STATUS_RECORD)
497 audio_stop();
499 else
500 #endif
502 done = true;
503 if(presets_have_changed())
505 if(yesno_pop(ID2P(LANG_FM_SAVE_CHANGES)))
507 presets_save();
511 update_type = SKIN_REFRESH_NON_STATIC;
512 break;
514 #ifdef FM_RECORD
515 case ACTION_FM_RECORD:
516 #ifdef FM_RECORD_DBLPRE
517 if (lastbutton != ACTION_FM_RECORD_DBLPRE)
519 rec_lastclick = 0;
520 break;
522 if (current_tick - rec_lastclick > HZ/2)
524 rec_lastclick = current_tick;
525 break;
527 #endif /* FM_RECORD_DBLPRE */
528 #ifndef SIMULATOR
529 if(audio_status() == AUDIO_STATUS_RECORD)
531 rec_command(RECORDING_CMD_START_NEWFILE);
532 update_type = SKIN_REFRESH_ALL;
534 else
536 rec_command(RECORDING_CMD_START);
537 update_type = SKIN_REFRESH_ALL;
539 #if CONFIG_CODEC != SWCODEC
540 last_seconds = 0;
541 #endif
542 #endif /* SIMULATOR */
543 break;
544 #endif /* #ifdef FM_RECORD */
546 case ACTION_FM_EXIT:
547 #if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
548 if(audio_status() == AUDIO_STATUS_RECORD)
549 audio_stop();
550 #endif
551 keep_playing = true;
552 done = true;
553 if(presets_have_changed())
555 if(yesno_pop(ID2P(LANG_FM_SAVE_CHANGES)))
557 presets_save();
561 break;
563 case ACTION_STD_PREV:
564 case ACTION_STD_NEXT:
565 next_station(button == ACTION_STD_PREV ? -1 : 1);
566 end_search();
567 update_type = SKIN_REFRESH_ALL;
568 talk = true;
569 break;
571 case ACTION_STD_PREVREPEAT:
572 case ACTION_STD_NEXTREPEAT:
574 int dir = search_dir;
575 search_dir = button == ACTION_STD_PREVREPEAT ? -1 : 1;
576 if (radio_mode != RADIO_SCAN_MODE)
578 preset_next(search_dir);
579 end_search();
580 talk = true;
582 else if (dir == 0)
584 /* Starting auto scan */
585 tuner_set(RADIO_MUTE, 1);
587 update_type = SKIN_REFRESH_ALL;
588 break;
591 case ACTION_SETTINGS_INC:
592 case ACTION_SETTINGS_INCREPEAT:
593 global_settings.volume++;
594 setvol();
595 update_type = SKIN_REFRESH_NON_STATIC;
596 break;
598 case ACTION_SETTINGS_DEC:
599 case ACTION_SETTINGS_DECREPEAT:
600 global_settings.volume--;
601 setvol();
602 update_type = SKIN_REFRESH_NON_STATIC;
603 break;
605 case ACTION_FM_PLAY:
606 if (radio_status == FMRADIO_PLAYING)
607 radio_pause();
608 else
609 radio_start();
611 update_type = SKIN_REFRESH_NON_STATIC;
612 talk = false;
613 talk_shutup();
614 break;
616 case ACTION_FM_MENU:
617 fms_fix_displays(FMS_EXIT);
618 do_menu(&radio_settings_menu, NULL, NULL, false);
619 preset_set_current(preset_find(curr_freq));
620 fms_fix_displays(FMS_ENTER);
621 update_type = SKIN_REFRESH_ALL;
622 break;
624 #ifdef FM_PRESET
625 case ACTION_FM_PRESET:
626 if(radio_preset_count() < 1)
628 splash(HZ, ID2P(LANG_FM_NO_PRESETS));
629 update_type = SKIN_REFRESH_ALL;
630 break;
632 fms_fix_displays(FMS_EXIT);
633 handle_radio_presets();
634 fms_fix_displays(FMS_ENTER);
635 update_type = SKIN_REFRESH_ALL;
636 break;
637 #endif /* FM_PRESET */
639 #ifdef FM_FREEZE
640 case ACTION_FM_FREEZE:
641 if(!screen_freeze)
643 splash(HZ, str(LANG_FM_FREEZE));
644 screen_freeze = true;
646 else
648 update_type = SKIN_REFRESH_ALL;
649 screen_freeze = false;
651 break;
652 #endif /* FM_FREEZE */
654 case SYS_USB_CONNECTED:
655 #if CONFIG_CODEC != SWCODEC
656 /* Only accept USB connection when not recording */
657 if(audio_status() != AUDIO_STATUS_RECORD)
658 #endif
660 default_event_handler(SYS_USB_CONNECTED);
661 screen_freeze = true; /* Cosmetic: makes sure the
662 radio screen doesn't redraw */
663 done = true;
665 break;
667 #ifdef FM_MODE
668 case ACTION_FM_MODE:
669 if(radio_mode == RADIO_SCAN_MODE)
671 /* Force scan mode if there are no presets. */
672 if(radio_preset_count() > 0)
673 radio_mode = RADIO_PRESET_MODE;
675 else
676 radio_mode = RADIO_SCAN_MODE;
677 update_type = SKIN_REFRESH_ALL;
678 cond_talk_ids_fq(radio_mode ?
679 LANG_PRESET : LANG_RADIO_SCAN_MODE);
680 talk = true;
681 break;
682 #endif /* FM_MODE */
684 #ifdef FM_NEXT_PRESET
685 case ACTION_FM_NEXT_PRESET:
686 preset_next(1);
687 end_search();
688 update_type = SKIN_REFRESH_ALL;
689 talk = true;
690 break;
691 #endif
693 #ifdef FM_PREV_PRESET
694 case ACTION_FM_PREV_PRESET:
695 preset_next(-1);
696 end_search();
697 update_type = SKIN_REFRESH_ALL;
698 talk = true;
699 break;
700 #endif
701 case ACTION_NONE:
702 update_type = SKIN_REFRESH_NON_STATIC;
703 break;
705 default:
706 default_event_handler(button);
707 #ifdef HAVE_RDS_CAP
708 if (tuner_get(RADIO_EVENT))
709 update_type = SKIN_REFRESH_ALL;
710 #endif
711 if (!tuner_get(RADIO_PRESENT))
713 #if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
714 if(audio_status() == AUDIO_STATUS_RECORD)
715 audio_stop();
716 #endif
717 keep_playing = false;
718 done = true;
719 if(presets_have_changed())
721 if(yesno_pop(ID2P(LANG_FM_SAVE_CHANGES)))
723 radio_save_presets();
727 /* Clear the preset list on exit. */
728 preset_list_clear();
730 break;
731 } /*switch(button)*/
733 #ifdef FM_RECORD_DBLPRE
734 if (button != ACTION_NONE)
735 lastbutton = button;
736 #endif
738 #if CONFIG_CODEC != SWCODEC
739 peak_meter_peek();
740 #endif
742 if(!screen_freeze)
744 /* Only display the peak meter when not recording */
745 #if CONFIG_CODEC != SWCODEC
746 if(TIME_AFTER(current_tick, timeout))
748 timeout = current_tick + HZ;
749 #else /* SWCODEC */
751 #endif /* CONFIG_CODEC == SWCODEC */
753 /* keep "mono" from always being displayed when paused */
754 if (radio_status != FMRADIO_PAUSED)
756 stereo = tuner_get(RADIO_STEREO) &&
757 !global_settings.fm_force_mono;
759 if(stereo != last_stereo)
761 update_type = SKIN_REFRESH_ALL;
762 last_stereo = stereo;
767 #if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
768 seconds = audio_recorded_time() / HZ;
769 if (update_type || seconds > last_seconds)
771 last_seconds = seconds;
772 #else
773 if (update_type)
775 #endif
776 FOR_NB_SCREENS(i)
777 skin_update(FM_SCREEN, i, update_type);
780 update_type = 0;
782 if (global_settings.talk_file && talk
783 && radio_status == FMRADIO_PAUSED)
785 talk = false;
786 bool enqueue = false;
787 if (radio_mode == RADIO_SCAN_MODE)
789 talk_value_decimal(curr_freq, UNIT_INT, 6, enqueue);
790 enqueue = true;
792 if (radio_current_preset() >= 0)
793 preset_talk(radio_current_preset(), radio_mode == RADIO_PRESET_MODE,
794 enqueue);
797 #if CONFIG_CODEC != SWCODEC
798 if(audio_status() & AUDIO_STATUS_ERROR)
800 done = true;
802 #endif
804 #ifndef HAVE_NOISY_IDLE_MODE
805 if (TIME_AFTER(current_tick, button_timeout))
807 cpu_idle_mode(true);
809 #endif
810 } /*while(!done)*/
812 #ifndef SIMULATOR
813 #if CONFIG_CODEC != SWCODEC
814 if(audio_status() & AUDIO_STATUS_ERROR)
816 splash(0, str(LANG_DISK_FULL));
817 audio_error_clear();
819 while(1)
821 button = get_action(CONTEXT_FM, TIMEOUT_BLOCK);
822 if(button == ACTION_FM_STOP)
823 break;
827 audio_init_playback();
828 #endif /* CONFIG_CODEC != SWCODEC */
830 sound_settings_apply();
831 #endif /* SIMULATOR */
833 if(keep_playing)
835 /* Catch FMRADIO_PLAYING status for the sim. */
836 #ifndef SIMULATOR
837 #if CONFIG_CODEC != SWCODEC
838 /* Enable the Left and right A/D Converter */
839 audio_set_recording_gain(sound_default(SOUND_LEFT_GAIN),
840 sound_default(SOUND_RIGHT_GAIN),
841 AUDIO_GAIN_LINEIN);
842 mas_codec_writereg(6, 0x4000);
843 #endif
844 end_search();
845 #endif /* SIMULATOR */
847 else
849 #if CONFIG_CODEC == SWCODEC
850 audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
851 #else
852 radio_stop();
853 #endif
856 #ifndef HAVE_NOISY_IDLE_MODE
857 cpu_idle_mode(false);
858 #endif
859 fms_fix_displays(FMS_EXIT);
860 pop_current_activity();
861 in_screen = false;
862 } /* radio_screen */
864 void toggle_mono_mode(bool mono)
866 tuner_set(RADIO_FORCE_MONO, mono);
869 void set_radio_region(int region)
871 #ifdef HAVE_RADIO_REGION
872 tuner_set(RADIO_REGION, region);
873 #endif
874 next_station(0);
875 remember_frequency();
876 (void)region;
879 #endif