diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2007-06-08 23:42:04 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2007-06-08 23:42:04 +0000 |
commit | 2d48d0ffa6baddd19e6ff077f25068f90af7be3d (patch) | |
tree | 68c80646a748496fee423d77aa43afafb783b269 | |
parent | a85793fc54a0079f5483d5a5c6c60b7d17ca688c (diff) | |
download | rockbox-2d48d0ffa6baddd19e6ff077f25068f90af7be3d.tar.gz rockbox-2d48d0ffa6baddd19e6ff077f25068f90af7be3d.zip |
Straighten out some audio path APIs and misc. audio stuff. Having recording is not a prerequisite to having input/output source selection which is probably most useful when adding a audio input features like FM to a new port without forcing recording to be implemented first.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13599 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/SOURCES | 3 | ||||
-rw-r--r-- | apps/audio_path.c | 145 | ||||
-rw-r--r-- | apps/debug_menu.c | 4 | ||||
-rw-r--r-- | apps/playback.c | 4 | ||||
-rw-r--r-- | apps/plugin.c | 7 | ||||
-rw-r--r-- | apps/plugin.h | 7 | ||||
-rw-r--r-- | apps/plugins/test_sampr.c | 6 | ||||
-rw-r--r-- | apps/recorder/radio.c | 8 | ||||
-rw-r--r-- | apps/recorder/recording.c | 107 | ||||
-rw-r--r-- | apps/recorder/recording.h | 4 | ||||
-rw-r--r-- | firmware/export/audio.h | 20 | ||||
-rw-r--r-- | firmware/export/config_caps.h | 9 | ||||
-rw-r--r-- | firmware/export/spdif.h | 8 | ||||
-rw-r--r-- | firmware/pcm_record.c | 26 | ||||
-rw-r--r-- | firmware/target/arm/audio-pp.c | 4 | ||||
-rw-r--r-- | firmware/target/arm/sandisk/sansa-e200/audio-e200.c | 6 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/m5/audio-m5.c | 5 | ||||
-rw-r--r-- | firmware/target/coldfire/iaudio/x5/audio-x5.c | 4 | ||||
-rw-r--r-- | firmware/target/coldfire/iriver/audio-iriver.c | 6 | ||||
-rw-r--r-- | firmware/target/coldfire/iriver/h100/power-h100.c | 3 | ||||
-rw-r--r-- | firmware/target/coldfire/iriver/h100/spdif-h100.c | 3 | ||||
-rw-r--r-- | firmware/target/coldfire/pcm-coldfire.c | 2 |
22 files changed, 237 insertions, 154 deletions
diff --git a/apps/SOURCES b/apps/SOURCES index ccc481b07b..ccb9ca2772 100644 --- a/apps/SOURCES +++ b/apps/SOURCES | |||
@@ -86,6 +86,9 @@ recorder/radio.c | |||
86 | recorder/recording.c | 86 | recorder/recording.c |
87 | #endif | 87 | #endif |
88 | #if CONFIG_CODEC == SWCODEC | 88 | #if CONFIG_CODEC == SWCODEC |
89 | #if INPUT_SRC_CAPS != 0 | ||
90 | audio_path.c | ||
91 | #endif /* INPUT_SRC_CAPS != 0 */ | ||
89 | pcmbuf.c | 92 | pcmbuf.c |
90 | playback.c | 93 | playback.c |
91 | codecs.c | 94 | codecs.c |
diff --git a/apps/audio_path.c b/apps/audio_path.c new file mode 100644 index 0000000000..998b2988c9 --- /dev/null +++ b/apps/audio_path.c | |||
@@ -0,0 +1,145 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Audio signal path management APIs | ||
11 | * | ||
12 | * Copyright (C) 2007 by Michael Sevakis | ||
13 | * | ||
14 | * All files in this archive are subject to the GNU General Public License. | ||
15 | * See the file COPYING in the source tree root for full license agreement. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "system.h" | ||
22 | #include "cpu.h" | ||
23 | #include "audio.h" | ||
24 | #include "general.h" | ||
25 | #include "settings.h" | ||
26 | #if defined(HAVE_SPDIF_IN) || defined(HAVE_SPDIF_OUT) | ||
27 | #ifdef HAVE_SPDIF_POWER | ||
28 | #include "power.h" | ||
29 | #endif | ||
30 | #include "spdif.h" | ||
31 | #endif | ||
32 | #if CONFIG_TUNER | ||
33 | #include "radio.h" | ||
34 | #endif | ||
35 | |||
36 | /* Some audio sources may require a boosted CPU */ | ||
37 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
38 | #ifdef HAVE_SPDIF_REC | ||
39 | #define AUDIO_CPU_BOOST | ||
40 | #endif | ||
41 | #endif | ||
42 | |||
43 | #ifndef SIMULATOR | ||
44 | |||
45 | #ifdef AUDIO_CPU_BOOST | ||
46 | static void audio_cpu_boost(bool state) | ||
47 | { | ||
48 | static bool cpu_boosted = false; | ||
49 | |||
50 | if (state != cpu_boosted) | ||
51 | { | ||
52 | cpu_boost(state); | ||
53 | cpu_boosted = state; | ||
54 | } | ||
55 | } /* audio_cpu_boost */ | ||
56 | #endif /* AUDIO_CPU_BOOST */ | ||
57 | |||
58 | /** | ||
59 | * Selects an audio source for recording or playback | ||
60 | * powers/unpowers related devices and sets up monitoring. | ||
61 | */ | ||
62 | void audio_set_input_source(int source, unsigned flags) | ||
63 | { | ||
64 | /** Do power up/down of associated device(s) **/ | ||
65 | |||
66 | /** SPDIF **/ | ||
67 | #ifdef AUDIO_CPU_BOOST | ||
68 | /* Always boost for SPDIF */ | ||
69 | audio_cpu_boost(source == AUDIO_SRC_SPDIF); | ||
70 | #endif /* AUDIO_CPU_BOOST */ | ||
71 | |||
72 | #ifdef HAVE_SPDIF_POWER | ||
73 | /* Check if S/PDIF output power should be switched off or on. NOTE: assumes | ||
74 | both optical in and out is controlled by the same power source, which is | ||
75 | the case on H1x0. */ | ||
76 | spdif_power_enable((source == AUDIO_SRC_SPDIF) || | ||
77 | global_settings.spdif_enable); | ||
78 | #endif /* HAVE_SPDIF_POWER */ | ||
79 | /* Set the appropriate feed for spdif output */ | ||
80 | #ifdef HAVE_SPDIF_OUT | ||
81 | spdif_set_output_source(source | ||
82 | IF_SPDIF_POWER_(, global_settings.spdif_enable)); | ||
83 | #endif /* HAVE_SPDIF_OUT */ | ||
84 | |||
85 | /** Tuner **/ | ||
86 | #if CONFIG_TUNER | ||
87 | /* Switch radio off or on per source and flags. */ | ||
88 | if (source != AUDIO_SRC_FMRADIO) | ||
89 | radio_stop(); | ||
90 | else if (flags & SRCF_FMRADIO_PAUSED) | ||
91 | radio_pause(); | ||
92 | else | ||
93 | radio_start(); | ||
94 | #endif | ||
95 | |||
96 | /* set hardware inputs */ | ||
97 | audio_input_mux(source, flags); | ||
98 | } /* audio_set_source */ | ||
99 | |||
100 | #ifdef HAVE_SPDIF_IN | ||
101 | /** | ||
102 | * Return SPDIF sample rate index in audio_master_sampr_list. Since we base | ||
103 | * our reading on the actual SPDIF sample rate (which might be a bit | ||
104 | * inaccurate), we round off to the closest sample rate that is supported by | ||
105 | * SPDIF. | ||
106 | */ | ||
107 | int audio_get_spdif_sample_rate(void) | ||
108 | { | ||
109 | unsigned long measured_rate = spdif_measure_frequency(); | ||
110 | /* Find which SPDIF sample rate we're closest to. */ | ||
111 | return round_value_to_list32(measured_rate, audio_master_sampr_list, | ||
112 | SAMPR_NUM_FREQ, false); | ||
113 | } /* audio_get_spdif_sample_rate */ | ||
114 | #endif /* HAVE_SPDIF_IN */ | ||
115 | |||
116 | #else /* SIMULATOR */ | ||
117 | |||
118 | /** Sim stubs **/ | ||
119 | |||
120 | #ifdef AUDIO_CPU_BOOST | ||
121 | static void audio_cpu_boost(bool state) | ||
122 | { | ||
123 | (void)state; | ||
124 | } /* audio_cpu_boost */ | ||
125 | #endif /* AUDIO_CPU_BOOST */ | ||
126 | |||
127 | void audio_set_output_source(int source) | ||
128 | { | ||
129 | (void)source; | ||
130 | } /* audio_set_output_source */ | ||
131 | |||
132 | void audio_set_input_source(int source, unsigned flags) | ||
133 | { | ||
134 | (void)source; | ||
135 | (void)flags; | ||
136 | } /* audio_set_input_source */ | ||
137 | |||
138 | #ifdef HAVE_SPDIF_IN | ||
139 | int audio_get_spdif_sample_rate(void) | ||
140 | { | ||
141 | return FREQ_44; | ||
142 | } /* audio_get_spdif_sample_rate */ | ||
143 | #endif /* HAVE_SPDIF_IN */ | ||
144 | |||
145 | #endif /* !SIMULATOR */ | ||
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 404d82c63e..691e9f5070 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -693,7 +693,7 @@ static bool dbg_spdif(void) | |||
693 | bool done = false; | 693 | bool done = false; |
694 | bool spdif_src_on; | 694 | bool spdif_src_on; |
695 | int spdif_source = spdif_get_output_source(&spdif_src_on); | 695 | int spdif_source = spdif_get_output_source(&spdif_src_on); |
696 | spdif_set_output_source(AUDIO_SRC_SPDIF, true); | 696 | spdif_set_output_source(AUDIO_SRC_SPDIF IF_SPDIF_POWER_(, true)); |
697 | 697 | ||
698 | lcd_setmargins(0, 0); | 698 | lcd_setmargins(0, 0); |
699 | lcd_clear_display(); | 699 | lcd_clear_display(); |
@@ -844,7 +844,7 @@ static bool dbg_spdif(void) | |||
844 | break; | 844 | break; |
845 | } | 845 | } |
846 | 846 | ||
847 | spdif_set_output_source(spdif_source, spdif_src_on); | 847 | spdif_set_output_source(spdif_source IF_SPDIF_POWER_(, spdif_src_on)); |
848 | 848 | ||
849 | #ifdef HAVE_SPDIF_POWER | 849 | #ifdef HAVE_SPDIF_POWER |
850 | spdif_power_enable(global_settings.spdif_enable); | 850 | spdif_power_enable(global_settings.spdif_enable); |
diff --git a/apps/playback.c b/apps/playback.c index b48bcc8c26..9cd82de9b6 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -3301,8 +3301,8 @@ static void audio_stop_playback(void) | |||
3301 | 3301 | ||
3302 | static void audio_play_start(size_t offset) | 3302 | static void audio_play_start(size_t offset) |
3303 | { | 3303 | { |
3304 | #if defined(HAVE_RECORDING) || CONFIG_TUNER | 3304 | #if INPUT_SRC_CAPS != 0 |
3305 | rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); | 3305 | audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); |
3306 | #endif | 3306 | #endif |
3307 | 3307 | ||
3308 | /* Wait for any previously playing audio to flush - TODO: Not necessary? */ | 3308 | /* Wait for any previously playing audio to flush - TODO: Not necessary? */ |
diff --git a/apps/plugin.c b/apps/plugin.c index a63e5cd6ee..79ecae9a1f 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -349,11 +349,12 @@ static const struct plugin_api rockbox_api = { | |||
349 | pcm_stop_recording, | 349 | pcm_stop_recording, |
350 | pcm_calculate_rec_peaks, | 350 | pcm_calculate_rec_peaks, |
351 | audio_set_recording_gain, | 351 | audio_set_recording_gain, |
352 | audio_set_output_source, | ||
353 | rec_set_source, | ||
354 | #endif /* HAVE_RECORDING */ | 352 | #endif /* HAVE_RECORDING */ |
355 | 353 | #if INPUT_SRC_CAPS != 0 | |
354 | audio_set_output_source, | ||
355 | audio_set_input_source, | ||
356 | #endif | 356 | #endif |
357 | #endif /* CONFIG_CODEC == SWCODEC */ | ||
357 | 358 | ||
358 | /* playback control */ | 359 | /* playback control */ |
359 | playlist_amount, | 360 | playlist_amount, |
diff --git a/apps/plugin.h b/apps/plugin.h index 2c8b328fe1..bc6adffab2 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -448,11 +448,12 @@ struct plugin_api { | |||
448 | void (*pcm_stop_recording)(void); | 448 | void (*pcm_stop_recording)(void); |
449 | void (*pcm_calculate_rec_peaks)(int *left, int *right); | 449 | void (*pcm_calculate_rec_peaks)(int *left, int *right); |
450 | void (*audio_set_recording_gain)(int left, int right, int type); | 450 | void (*audio_set_recording_gain)(int left, int right, int type); |
451 | void (*audio_set_output_source)(int monitor); | ||
452 | void (*rec_set_source)(int source, unsigned flags); | ||
453 | #endif /* HAVE_RECORDING */ | 451 | #endif /* HAVE_RECORDING */ |
454 | 452 | #if INPUT_SRC_CAPS != 0 | |
453 | void (*audio_set_output_source)(int monitor); | ||
454 | void (*audio_set_input_source)(int source, unsigned flags); | ||
455 | #endif | 455 | #endif |
456 | #endif /* CONFIG_CODEC == SWCODC */ | ||
456 | 457 | ||
457 | /* playback control */ | 458 | /* playback control */ |
458 | int (*playlist_amount)(void); | 459 | int (*playlist_amount)(void); |
diff --git a/apps/plugins/test_sampr.c b/apps/plugins/test_sampr.c index 253c592eaa..e1511e3dfd 100644 --- a/apps/plugins/test_sampr.c +++ b/apps/plugins/test_sampr.c | |||
@@ -199,9 +199,9 @@ void play_waveform(void) | |||
199 | rb->audio_stop(); | 199 | rb->audio_stop(); |
200 | rb->sound_set(SOUND_VOLUME, rb->sound_default(SOUND_VOLUME)); | 200 | rb->sound_set(SOUND_VOLUME, rb->sound_default(SOUND_VOLUME)); |
201 | 201 | ||
202 | #ifdef HAVE_RECORDING | 202 | #ifdef INPUT_SRC_CAPS != 0 |
203 | /* Select playback */ | 203 | /* Select playback */ |
204 | rb->rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); | 204 | rb->audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); |
205 | #endif | 205 | #endif |
206 | 206 | ||
207 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 207 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
@@ -210,7 +210,7 @@ void play_waveform(void) | |||
210 | 210 | ||
211 | rb->pcm_set_frequency(rb->hw_freq_sampr[freq]); | 211 | rb->pcm_set_frequency(rb->hw_freq_sampr[freq]); |
212 | 212 | ||
213 | #ifdef HAVE_RECORDING | 213 | #ifdef INPUT_SRC_CAPS != 0 |
214 | /* Recordable targets can play back from other sources */ | 214 | /* Recordable targets can play back from other sources */ |
215 | rb->audio_set_output_source(AUDIO_SRC_PLAYBACK); | 215 | rb->audio_set_output_source(AUDIO_SRC_PLAYBACK); |
216 | #endif | 216 | #endif |
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index 9f3228be1f..23e820e835 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c | |||
@@ -509,9 +509,9 @@ int radio_screen(void) | |||
509 | 509 | ||
510 | /* turn on radio */ | 510 | /* turn on radio */ |
511 | #if CONFIG_CODEC == SWCODEC | 511 | #if CONFIG_CODEC == SWCODEC |
512 | rec_set_source(AUDIO_SRC_FMRADIO, | 512 | audio_set_input_source(AUDIO_SRC_FMRADIO, |
513 | (radio_status == FMRADIO_PAUSED) ? | 513 | (radio_status == FMRADIO_PAUSED) ? |
514 | SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING); | 514 | SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING); |
515 | #else | 515 | #else |
516 | if (radio_status == FMRADIO_OFF) | 516 | if (radio_status == FMRADIO_OFF) |
517 | radio_start(); | 517 | radio_start(); |
@@ -985,7 +985,7 @@ int radio_screen(void) | |||
985 | else | 985 | else |
986 | { | 986 | { |
987 | #if CONFIG_CODEC == SWCODEC | 987 | #if CONFIG_CODEC == SWCODEC |
988 | rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); | 988 | audio_set_input_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); |
989 | #else | 989 | #else |
990 | radio_stop(); | 990 | radio_stop(); |
991 | #endif | 991 | #endif |
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 5738a34949..226ff9a17f 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c | |||
@@ -547,80 +547,6 @@ int rec_create_directory(void) | |||
547 | return 0; | 547 | return 0; |
548 | } | 548 | } |
549 | 549 | ||
550 | #if CONFIG_CODEC == SWCODEC && !defined(SIMULATOR) | ||
551 | |||
552 | # ifdef HAVE_SPDIF_REC | ||
553 | # ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
554 | static void rec_boost(bool state) | ||
555 | { | ||
556 | static bool cpu_boosted = false; | ||
557 | |||
558 | if (state != cpu_boosted) | ||
559 | { | ||
560 | cpu_boost(state); | ||
561 | cpu_boosted = state; | ||
562 | } | ||
563 | } | ||
564 | # endif | ||
565 | # endif | ||
566 | |||
567 | /** | ||
568 | * Selects an audio source for recording or playback | ||
569 | * powers/unpowers related devices and sets up monitoring. | ||
570 | * Here because it calls app code and used only for HAVE_RECORDING atm. | ||
571 | * Would like it in pcm_record.c. | ||
572 | * | ||
573 | * Behaves like a firmware function in that it does not use global settings | ||
574 | * to determine the state. | ||
575 | * | ||
576 | * The order of setting monitoring may need tweaking dependent upon the | ||
577 | * selected source to get the smoothest transition. | ||
578 | */ | ||
579 | void rec_set_source(int source, unsigned flags) | ||
580 | { | ||
581 | /** Do power up/down of associated device(s) **/ | ||
582 | |||
583 | /** SPDIF **/ | ||
584 | #ifdef HAVE_SPDIF_REC | ||
585 | /* Always boost for SPDIF */ | ||
586 | rec_boost(source == AUDIO_SRC_SPDIF); | ||
587 | #endif /* HAVE_SPDIF_IN */ | ||
588 | |||
589 | #ifdef HAVE_SPDIF_POWER | ||
590 | /* Check if S/PDIF output power should be switched off or on. NOTE: assumes | ||
591 | both optical in and out is controlled by the same power source, which is | ||
592 | the case on H1x0. */ | ||
593 | spdif_power_enable((source == AUDIO_SRC_SPDIF) || | ||
594 | global_settings.spdif_enable); | ||
595 | /* Set the appropriate feed for spdif output */ | ||
596 | #ifdef HAVE_SPDIF_OUT | ||
597 | spdif_set_output_source(source, global_settings.spdif_enable); | ||
598 | #endif | ||
599 | #else /* !HAVE_SPDIF_POWER */ | ||
600 | #ifdef HAVE_SPDIF_OUT | ||
601 | spdif_set_output_source(source, true); | ||
602 | #endif | ||
603 | #endif /* !HAVE_SPDIF_POWER */ | ||
604 | |||
605 | /** Tuner **/ | ||
606 | #if CONFIG_TUNER | ||
607 | /* Switch radio off or on per source and flags. */ | ||
608 | if (source != AUDIO_SRC_FMRADIO) | ||
609 | radio_stop(); | ||
610 | else if (flags & SRCF_FMRADIO_PAUSED) | ||
611 | radio_pause(); | ||
612 | else | ||
613 | radio_start(); | ||
614 | #endif | ||
615 | |||
616 | /* set hardware inputs */ | ||
617 | audio_set_source(source, flags); | ||
618 | |||
619 | peak_meter_playback((flags & SRCF_RECORDING) == 0); | ||
620 | peak_meter_enabled = true; | ||
621 | } /* rec_set_source */ | ||
622 | #endif /* CONFIG_CODEC == SWCODEC && !defined(SIMULATOR) */ | ||
623 | |||
624 | void rec_init_recording_options(struct audio_recording_options *options) | 550 | void rec_init_recording_options(struct audio_recording_options *options) |
625 | { | 551 | { |
626 | options->rec_source = global_settings.rec_source; | 552 | options->rec_source = global_settings.rec_source; |
@@ -637,6 +563,18 @@ void rec_init_recording_options(struct audio_recording_options *options) | |||
637 | #endif | 563 | #endif |
638 | } | 564 | } |
639 | 565 | ||
566 | #if CONFIG_CODEC == SWCODEC && !defined (SIMULATOR) | ||
567 | void rec_set_source(int source, unsigned flags) | ||
568 | { | ||
569 | /* Set audio input source, power up/down devices */ | ||
570 | audio_set_input_source(source, flags); | ||
571 | |||
572 | /* Set peakmeters for recording or reset to playback */ | ||
573 | peak_meter_playback((flags & SRCF_RECORDING) == 0); | ||
574 | peak_meter_enabled = true; | ||
575 | } | ||
576 | #endif /* CONFIG_CODEC == SWCODEC && !defined (SIMULATOR) */ | ||
577 | |||
640 | void rec_set_recording_options(struct audio_recording_options *options) | 578 | void rec_set_recording_options(struct audio_recording_options *options) |
641 | { | 579 | { |
642 | #if CONFIG_CODEC != SWCODEC | 580 | #if CONFIG_CODEC != SWCODEC |
@@ -2062,20 +2000,6 @@ void rec_set_source(int source, unsigned flags) | |||
2062 | flags = flags; | 2000 | flags = flags; |
2063 | } | 2001 | } |
2064 | 2002 | ||
2065 | #ifdef HAVE_SPDIF_IN | ||
2066 | #ifdef HAVE_SPDIF_POWER | ||
2067 | void audio_set_spdif_power_setting(bool on) | ||
2068 | { | ||
2069 | on = on; | ||
2070 | } | ||
2071 | |||
2072 | bool audio_get_spdif_power_setting(void) | ||
2073 | { | ||
2074 | return true; | ||
2075 | } | ||
2076 | #endif /* HAVE_SPDIF_POWER */ | ||
2077 | #endif /* HAVE_SPDIF_IN */ | ||
2078 | |||
2079 | void audio_set_recording_options(struct audio_recording_options *options) | 2003 | void audio_set_recording_options(struct audio_recording_options *options) |
2080 | { | 2004 | { |
2081 | options = options; | 2005 | options = options; |
@@ -2088,13 +2012,12 @@ void audio_set_recording_gain(int left, int right, int type) | |||
2088 | type = type; | 2012 | type = type; |
2089 | } | 2013 | } |
2090 | 2014 | ||
2091 | void audio_set_output_source(int source) | 2015 | void audio_record(const char *filename) |
2092 | { | 2016 | { |
2093 | source = source; | 2017 | filename = filename; |
2094 | } | 2018 | } |
2095 | 2019 | ||
2096 | 2020 | void audio_new_file(const char *filename) | |
2097 | void audio_record(const char *filename) | ||
2098 | { | 2021 | { |
2099 | filename = filename; | 2022 | filename = filename; |
2100 | } | 2023 | } |
diff --git a/apps/recorder/recording.h b/apps/recorder/recording.h index 3ca1f35834..50a73856cf 100644 --- a/apps/recorder/recording.h +++ b/apps/recorder/recording.h | |||
@@ -29,7 +29,7 @@ int rec_create_directory(void); | |||
29 | extern bool recording_start_automatic; | 29 | extern bool recording_start_automatic; |
30 | 30 | ||
31 | #if CONFIG_CODEC == SWCODEC | 31 | #if CONFIG_CODEC == SWCODEC |
32 | /* handles device powerup and sets audio source */ | 32 | /* handles device powerup, sets audio source and peakmeter mode */ |
33 | void rec_set_source(int source, unsigned flags); | 33 | void rec_set_source(int source, unsigned flags); |
34 | #endif /* CONFIG_CODEC == SW_CODEC */ | 34 | #endif /* CONFIG_CODEC == SW_CODEC */ |
35 | 35 | ||
@@ -47,4 +47,4 @@ void rec_record(void); | |||
47 | /* creates unique filename and starts recording */ | 47 | /* creates unique filename and starts recording */ |
48 | void rec_new_file(void); | 48 | void rec_new_file(void); |
49 | 49 | ||
50 | #endif | 50 | #endif /* RECORDING_H */ |
diff --git a/firmware/export/audio.h b/firmware/export/audio.h index a79a734e29..e6fed90069 100644 --- a/firmware/export/audio.h +++ b/firmware/export/audio.h | |||
@@ -194,12 +194,7 @@ void audio_record(const char *filename); | |||
194 | void audio_stop_recording(void); | 194 | void audio_stop_recording(void); |
195 | void audio_pause_recording(void); | 195 | void audio_pause_recording(void); |
196 | void audio_resume_recording(void); | 196 | void audio_resume_recording(void); |
197 | #if CONFIG_CODEC == SWCODEC | ||
198 | static inline void audio_new_file(const char *filename) | ||
199 | { audio_record(filename); } | ||
200 | #else | ||
201 | void audio_new_file(const char *filename); | 197 | void audio_new_file(const char *filename); |
202 | #endif /* CONFIG_CODEC == SWCODEC */ | ||
203 | void audio_set_recording_options(struct audio_recording_options *options); | 198 | void audio_set_recording_options(struct audio_recording_options *options); |
204 | void audio_set_recording_gain(int left, int right, int type); | 199 | void audio_set_recording_gain(int left, int right, int type); |
205 | unsigned long audio_recorded_time(void); | 200 | unsigned long audio_recorded_time(void); |
@@ -211,11 +206,22 @@ unsigned long audio_num_recorded_bytes(void); | |||
211 | bool audio_load_encoder(int afmt); | 206 | bool audio_load_encoder(int afmt); |
212 | void audio_remove_encoder(void); | 207 | void audio_remove_encoder(void); |
213 | unsigned char *audio_get_recording_buffer(size_t *buffer_size); | 208 | unsigned char *audio_get_recording_buffer(size_t *buffer_size); |
214 | void audio_set_source(int source, unsigned flags); | ||
215 | void audio_set_output_source(int source); | ||
216 | #endif /* CONFIG_CODEC == SWCODEC */ | 209 | #endif /* CONFIG_CODEC == SWCODEC */ |
210 | |||
217 | #endif /* HAVE_RECORDING */ | 211 | #endif /* HAVE_RECORDING */ |
218 | 212 | ||
213 | #if CONFIG_CODEC == SWCODEC | ||
214 | /* SWCODEC misc. audio functions */ | ||
215 | #if INPUT_SRC_CAPS != 0 | ||
216 | /* audio.c */ | ||
217 | void audio_set_input_source(int source, unsigned flags); | ||
218 | /* audio_input_mux: target-specific implementation used by audio_set_source | ||
219 | to set hardware inputs and audio paths */ | ||
220 | void audio_input_mux(int source, unsigned flags); | ||
221 | void audio_set_output_source(int source); | ||
222 | #endif /* INPUT_SRC_CAPS */ | ||
223 | #endif /* CONFIG_CODEC == SWCODEC */ | ||
224 | |||
219 | #ifdef HAVE_SPDIF_IN | 225 | #ifdef HAVE_SPDIF_IN |
220 | /* returns index into rec_master_sampr_list */ | 226 | /* returns index into rec_master_sampr_list */ |
221 | int audio_get_spdif_sample_rate(void); | 227 | int audio_get_spdif_sample_rate(void); |
diff --git a/firmware/export/config_caps.h b/firmware/export/config_caps.h index 8e3832d3a7..62cae8f8d8 100644 --- a/firmware/export/config_caps.h +++ b/firmware/export/config_caps.h | |||
@@ -66,6 +66,10 @@ | |||
66 | #define HAVE_FMRADIO_IN_(...) | 66 | #define HAVE_FMRADIO_IN_(...) |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | #if INPUT_SRC_CAPS != 0 && (INPUT_SRC_CAPS & (INPUT_SRC_CAPS-1)) != 0 | ||
70 | #define HAVE_MULTI_INPUT_SRC | ||
71 | #endif | ||
72 | |||
69 | #ifdef HAVE_RECORDING | 73 | #ifdef HAVE_RECORDING |
70 | /* Recordable source implies it has the input as well */ | 74 | /* Recordable source implies it has the input as well */ |
71 | 75 | ||
@@ -104,4 +108,9 @@ | |||
104 | #else | 108 | #else |
105 | #define HAVE_FMRADIO_REC_(...) | 109 | #define HAVE_FMRADIO_REC_(...) |
106 | #endif | 110 | #endif |
111 | |||
112 | #if REC_SRC_CAPS != 0 && (REC_SRC_CAPS & (REC_SRC_CAPS-1)) != 0 | ||
113 | #define HAVE_MULTI_REC_SRC | ||
114 | #endif | ||
115 | |||
107 | #endif /* HAVE_RECORDING */ | 116 | #endif /* HAVE_RECORDING */ |
diff --git a/firmware/export/spdif.h b/firmware/export/spdif.h index f4712fb88f..4179c7873f 100644 --- a/firmware/export/spdif.h +++ b/firmware/export/spdif.h | |||
@@ -20,6 +20,12 @@ | |||
20 | #ifndef SPDIF_H | 20 | #ifndef SPDIF_H |
21 | #define SPDIF_H | 21 | #define SPDIF_H |
22 | 22 | ||
23 | #ifdef HAVE_SPDIF_POWER | ||
24 | #define IF_SPDIF_POWER_(...) __VA_ARGS__ | ||
25 | #else | ||
26 | #define IF_SPDIF_POWER_(...) | ||
27 | #endif | ||
28 | |||
23 | /* Initialize the S/PDIF driver */ | 29 | /* Initialize the S/PDIF driver */ |
24 | void spdif_init(void); | 30 | void spdif_init(void); |
25 | /* Return the S/PDIF frequency in herz - unrounded */ | 31 | /* Return the S/PDIF frequency in herz - unrounded */ |
@@ -27,7 +33,7 @@ unsigned long spdif_measure_frequency(void); | |||
27 | #ifdef HAVE_SPDIF_OUT | 33 | #ifdef HAVE_SPDIF_OUT |
28 | /* Set the S/PDIF audio feed - Use AUDIO_SRC_* values - | 34 | /* Set the S/PDIF audio feed - Use AUDIO_SRC_* values - |
29 | will be off if not powered or !on */ | 35 | will be off if not powered or !on */ |
30 | void spdif_set_output_source(int source, bool on); | 36 | void spdif_set_output_source(int source IF_SPDIF_POWER_(, bool on)); |
31 | /* Return the last set S/PDIF audio source - literally the last value passed | 37 | /* Return the last set S/PDIF audio source - literally the last value passed |
32 | to spdif_set_monitor regardless of power state */ | 38 | to spdif_set_monitor regardless of power state */ |
33 | int spdif_get_output_source(bool *src_on); | 39 | int spdif_get_output_source(bool *src_on); |
diff --git a/firmware/pcm_record.c b/firmware/pcm_record.c index c27f80400d..1430100a09 100644 --- a/firmware/pcm_record.c +++ b/firmware/pcm_record.c | |||
@@ -481,6 +481,14 @@ void audio_record(const char *filename) | |||
481 | } /* audio_record */ | 481 | } /* audio_record */ |
482 | 482 | ||
483 | /** | 483 | /** |
484 | * audio_record wrapper for API compatibility with HW codec | ||
485 | */ | ||
486 | void audio_new_file(const char *filename) | ||
487 | { | ||
488 | audio_record(filename); | ||
489 | } /* audio_new_file */ | ||
490 | |||
491 | /** | ||
484 | * Stop current recording if recording | 492 | * Stop current recording if recording |
485 | */ | 493 | */ |
486 | void audio_stop_recording(void) | 494 | void audio_stop_recording(void) |
@@ -551,22 +559,6 @@ unsigned long audio_num_recorded_bytes(void) | |||
551 | return num_rec_bytes; | 559 | return num_rec_bytes; |
552 | } /* audio_num_recorded_bytes */ | 560 | } /* audio_num_recorded_bytes */ |
553 | 561 | ||
554 | #ifdef HAVE_SPDIF_IN | ||
555 | /** | ||
556 | * Return SPDIF sample rate index in audio_master_sampr_list. Since we base | ||
557 | * our reading on the actual SPDIF sample rate (which might be a bit | ||
558 | * inaccurate), we round off to the closest sample rate that is supported by | ||
559 | * SPDIF. | ||
560 | */ | ||
561 | int audio_get_spdif_sample_rate(void) | ||
562 | { | ||
563 | unsigned long measured_rate = spdif_measure_frequency(); | ||
564 | /* Find which SPDIF sample rate we're closest to. */ | ||
565 | return round_value_to_list32(measured_rate, audio_master_sampr_list, | ||
566 | SAMPR_NUM_FREQ, false); | ||
567 | } /* audio_get_spdif_sample_rate */ | ||
568 | #endif /* HAVE_SPDIF_IN */ | ||
569 | |||
570 | /***************************************************************************/ | 562 | /***************************************************************************/ |
571 | /* */ | 563 | /* */ |
572 | /* Functions that execute in the context of pcmrec_thread */ | 564 | /* Functions that execute in the context of pcmrec_thread */ |
@@ -1756,7 +1748,7 @@ void enc_set_parameters(struct enc_parameters *params) | |||
1756 | fnq_size *= MAX_PATH; | 1748 | fnq_size *= MAX_PATH; |
1757 | logf("fnq files:%ld", fnq_size / MAX_PATH); | 1749 | logf("fnq files:%ld", fnq_size / MAX_PATH); |
1758 | 1750 | ||
1759 | #if 1 | 1751 | #if 0 |
1760 | logf("ab :%08lX", (uintptr_t)audiobuf); | 1752 | logf("ab :%08lX", (uintptr_t)audiobuf); |
1761 | logf("pcm:%08lX", (uintptr_t)pcm_buffer); | 1753 | logf("pcm:%08lX", (uintptr_t)pcm_buffer); |
1762 | logf("enc:%08lX", (uintptr_t)enc_buffer); | 1754 | logf("enc:%08lX", (uintptr_t)enc_buffer); |
diff --git a/firmware/target/arm/audio-pp.c b/firmware/target/arm/audio-pp.c index 91670cb015..9fff197520 100644 --- a/firmware/target/arm/audio-pp.c +++ b/firmware/target/arm/audio-pp.c | |||
@@ -29,7 +29,7 @@ void audio_set_output_source(int source) | |||
29 | source = AUDIO_SRC_PLAYBACK; | 29 | source = AUDIO_SRC_PLAYBACK; |
30 | } /* audio_set_output_source */ | 30 | } /* audio_set_output_source */ |
31 | 31 | ||
32 | void audio_set_source(int source, unsigned flags) | 32 | void audio_input_mux(int source, unsigned flags) |
33 | { | 33 | { |
34 | (void)flags; | 34 | (void)flags; |
35 | /* Prevent pops from unneeded switching */ | 35 | /* Prevent pops from unneeded switching */ |
@@ -87,6 +87,6 @@ void audio_set_source(int source, unsigned flags) | |||
87 | } /* end switch */ | 87 | } /* end switch */ |
88 | 88 | ||
89 | last_source = source; | 89 | last_source = source; |
90 | } /* audio_set_source */ | 90 | } /* audio_input_mux */ |
91 | 91 | ||
92 | 92 | ||
diff --git a/firmware/target/arm/sandisk/sansa-e200/audio-e200.c b/firmware/target/arm/sandisk/sansa-e200/audio-e200.c index f046f0db99..0c3db7b87b 100644 --- a/firmware/target/arm/sandisk/sansa-e200/audio-e200.c +++ b/firmware/target/arm/sandisk/sansa-e200/audio-e200.c | |||
@@ -39,7 +39,7 @@ void audio_set_output_source(int source) | |||
39 | set_fiq_status(oldmode); | 39 | set_fiq_status(oldmode); |
40 | } /* audio_set_output_source */ | 40 | } /* audio_set_output_source */ |
41 | 41 | ||
42 | void audio_set_source(int source, unsigned flags) | 42 | void audio_input_mux(int source, unsigned flags) |
43 | { | 43 | { |
44 | static int last_source = AUDIO_SRC_PLAYBACK; | 44 | static int last_source = AUDIO_SRC_PLAYBACK; |
45 | static bool last_recording = false; | 45 | static bool last_recording = false; |
@@ -89,6 +89,4 @@ void audio_set_source(int source, unsigned flags) | |||
89 | } /* end switch */ | 89 | } /* end switch */ |
90 | 90 | ||
91 | last_source = source; | 91 | last_source = source; |
92 | } /* audio_set_source */ | 92 | } /* audio_input_mux */ |
93 | |||
94 | |||
diff --git a/firmware/target/coldfire/iaudio/m5/audio-m5.c b/firmware/target/coldfire/iaudio/m5/audio-m5.c index 2442351fed..87a7c35574 100644 --- a/firmware/target/coldfire/iaudio/m5/audio-m5.c +++ b/firmware/target/coldfire/iaudio/m5/audio-m5.c | |||
@@ -35,7 +35,7 @@ void audio_set_output_source(int source) | |||
35 | set_irq_level(level); | 35 | set_irq_level(level); |
36 | } /* audio_set_output_source */ | 36 | } /* audio_set_output_source */ |
37 | 37 | ||
38 | void audio_set_source(int source, unsigned flags) | 38 | void audio_input_mux(int source, unsigned flags) |
39 | { | 39 | { |
40 | /* Prevent pops from unneeded switching */ | 40 | /* Prevent pops from unneeded switching */ |
41 | static int last_source = AUDIO_SRC_PLAYBACK; | 41 | static int last_source = AUDIO_SRC_PLAYBACK; |
@@ -79,5 +79,4 @@ void audio_set_source(int source, unsigned flags) | |||
79 | or_l((1 << 29), &GPIO_FUNCTION); | 79 | or_l((1 << 29), &GPIO_FUNCTION); |
80 | 80 | ||
81 | last_source = source; | 81 | last_source = source; |
82 | } /* audio_set_source */ | 82 | } /* audio_input_mux */ |
83 | |||
diff --git a/firmware/target/coldfire/iaudio/x5/audio-x5.c b/firmware/target/coldfire/iaudio/x5/audio-x5.c index 91100ed751..594ff3b574 100644 --- a/firmware/target/coldfire/iaudio/x5/audio-x5.c +++ b/firmware/target/coldfire/iaudio/x5/audio-x5.c | |||
@@ -35,7 +35,7 @@ void audio_set_output_source(int source) | |||
35 | set_irq_level(level); | 35 | set_irq_level(level); |
36 | } /* audio_set_output_source */ | 36 | } /* audio_set_output_source */ |
37 | 37 | ||
38 | void audio_set_source(int source, unsigned flags) | 38 | void audio_input_mux(int source, unsigned flags) |
39 | { | 39 | { |
40 | /* Prevent pops from unneeded switching */ | 40 | /* Prevent pops from unneeded switching */ |
41 | static int last_source = AUDIO_SRC_PLAYBACK; | 41 | static int last_source = AUDIO_SRC_PLAYBACK; |
@@ -109,5 +109,5 @@ void audio_set_source(int source, unsigned flags) | |||
109 | or_l((1 << 29), &GPIO_FUNCTION); | 109 | or_l((1 << 29), &GPIO_FUNCTION); |
110 | 110 | ||
111 | last_source = source; | 111 | last_source = source; |
112 | } /* audio_set_source */ | 112 | } /* audio_input_mux */ |
113 | 113 | ||
diff --git a/firmware/target/coldfire/iriver/audio-iriver.c b/firmware/target/coldfire/iriver/audio-iriver.c index bd071430b2..4d22e7c987 100644 --- a/firmware/target/coldfire/iriver/audio-iriver.c +++ b/firmware/target/coldfire/iriver/audio-iriver.c | |||
@@ -44,7 +44,7 @@ void audio_set_output_source(int source) | |||
44 | set_irq_level(level); | 44 | set_irq_level(level); |
45 | } /* audio_set_output_source */ | 45 | } /* audio_set_output_source */ |
46 | 46 | ||
47 | void audio_set_source(int source, unsigned flags) | 47 | void audio_input_mux(int source, unsigned flags) |
48 | { | 48 | { |
49 | /* Prevent pops from unneeded switching */ | 49 | /* Prevent pops from unneeded switching */ |
50 | static int last_source = AUDIO_SRC_PLAYBACK; | 50 | static int last_source = AUDIO_SRC_PLAYBACK; |
@@ -131,6 +131,4 @@ void audio_set_source(int source, unsigned flags) | |||
131 | or_l(MUX_BIT, &GPIO_FUNCTION); | 131 | or_l(MUX_BIT, &GPIO_FUNCTION); |
132 | 132 | ||
133 | last_source = source; | 133 | last_source = source; |
134 | } /* audio_set_source */ | 134 | } /* audio_input_mux */ |
135 | |||
136 | |||
diff --git a/firmware/target/coldfire/iriver/h100/power-h100.c b/firmware/target/coldfire/iriver/h100/power-h100.c index ce1c350802..943168967f 100644 --- a/firmware/target/coldfire/iriver/h100/power-h100.c +++ b/firmware/target/coldfire/iriver/h100/power-h100.c | |||
@@ -89,7 +89,8 @@ void spdif_power_enable(bool on) | |||
89 | 89 | ||
90 | #ifndef BOOTLOADER | 90 | #ifndef BOOTLOADER |
91 | /* Make sure the feed is reset */ | 91 | /* Make sure the feed is reset */ |
92 | spdif_set_output_source(spdif_get_output_source(NULL), true); | 92 | spdif_set_output_source(spdif_get_output_source(NULL) |
93 | IF_SPDIF_POWER_(, true)); | ||
93 | #endif | 94 | #endif |
94 | } | 95 | } |
95 | 96 | ||
diff --git a/firmware/target/coldfire/iriver/h100/spdif-h100.c b/firmware/target/coldfire/iriver/h100/spdif-h100.c index ee4a9402ea..beede3fdce 100644 --- a/firmware/target/coldfire/iriver/h100/spdif-h100.c +++ b/firmware/target/coldfire/iriver/h100/spdif-h100.c | |||
@@ -33,7 +33,8 @@ void spdif_init(void) | |||
33 | { | 33 | { |
34 | /* PHASECONFIG setup: gain = 3*2^13, source = EBUIN */ | 34 | /* PHASECONFIG setup: gain = 3*2^13, source = EBUIN */ |
35 | PHASECONFIG = (6 << 3) | (4 << 0); | 35 | PHASECONFIG = (6 << 3) | (4 << 0); |
36 | spdif_set_output_source(AUDIO_SRC_PLAYBACK, true); | 36 | spdif_set_output_source(AUDIO_SRC_PLAYBACK |
37 | IF_SPDIF_POWER_(, true)); | ||
37 | } | 38 | } |
38 | 39 | ||
39 | /* Return the S/PDIF frequency in herz - unrounded */ | 40 | /* Return the S/PDIF frequency in herz - unrounded */ |
diff --git a/firmware/target/coldfire/pcm-coldfire.c b/firmware/target/coldfire/pcm-coldfire.c index dc40dacf0e..41aa9fbc61 100644 --- a/firmware/target/coldfire/pcm-coldfire.c +++ b/firmware/target/coldfire/pcm-coldfire.c | |||
@@ -271,7 +271,7 @@ void pcm_init(void) | |||
271 | /* Initialize default register values. */ | 271 | /* Initialize default register values. */ |
272 | audiohw_init(); | 272 | audiohw_init(); |
273 | 273 | ||
274 | audio_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); | 274 | audio_input_mux(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); |
275 | 275 | ||
276 | audiohw_set_frequency(freq_ent[FPARM_FSEL]); | 276 | audiohw_set_frequency(freq_ent[FPARM_FSEL]); |
277 | coldfire_set_pllcr_audio_bits(PLLCR_SET_AUDIO_BITS_DEFPARM); | 277 | coldfire_set_pllcr_audio_bits(PLLCR_SET_AUDIO_BITS_DEFPARM); |