diff options
Diffstat (limited to 'firmware/export')
-rw-r--r-- | firmware/export/audiohw.h | 5 | ||||
-rw-r--r-- | firmware/export/config.h | 18 | ||||
-rw-r--r-- | firmware/export/hosted_codec.h | 5 | ||||
-rw-r--r-- | firmware/export/pcm-internal.h | 39 | ||||
-rw-r--r-- | firmware/export/pcm_sw_volume.h | 6 |
5 files changed, 60 insertions, 13 deletions
diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h index 843ac0c0c4..4379c20a79 100644 --- a/firmware/export/audiohw.h +++ b/firmware/export/audiohw.h | |||
@@ -111,11 +111,6 @@ struct sound_settings_info | |||
111 | #include "hosted_codec.h" | 111 | #include "hosted_codec.h" |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | #if defined(SIMULATOR) && !defined(HAVE_SW_VOLUME_CONTROL) | ||
115 | /* For now, without software volume control, sim only supports mono control */ | ||
116 | #define AUDIOHW_HAVE_MONO_VOLUME | ||
117 | #endif | ||
118 | |||
119 | /* convert caps into defines */ | 114 | /* convert caps into defines */ |
120 | #ifdef AUDIOHW_CAPS | 115 | #ifdef AUDIOHW_CAPS |
121 | /* Tone controls */ | 116 | /* Tone controls */ |
diff --git a/firmware/export/config.h b/firmware/export/config.h index 6a4a4648c8..7d7a18cc23 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -1139,6 +1139,24 @@ Lyre prototype 1 */ | |||
1139 | #define ROCKBOX_HAS_LOGDISKF | 1139 | #define ROCKBOX_HAS_LOGDISKF |
1140 | #endif | 1140 | #endif |
1141 | 1141 | ||
1142 | #if defined(HAVE_SDL_AUDIO) \ | ||
1143 | && !(CONFIG_PLATFORM & PLATFORM_MAEMO5) \ | ||
1144 | && !defined(HAVE_SW_VOLUME_CONTROL) \ | ||
1145 | && CONFIG_CODEC == SWCODEC | ||
1146 | /* SW volume is needed for accurate control and no double buffering should be | ||
1147 | * required. If target uses SW volume, then its definitions are used instead | ||
1148 | * so things are as on target. */ | ||
1149 | #define HAVE_SW_VOLUME_CONTROL | ||
1150 | #define PCM_SW_VOLUME_UNBUFFERED /* pcm driver itself is buffered */ | ||
1151 | #ifdef SIMULATOR | ||
1152 | /* For sim, nice res for ~ -127dB..+36dB that so far covers all targets */ | ||
1153 | #define PCM_SW_VOLUME_FRACBITS (24) | ||
1154 | #else | ||
1155 | /* For app, use fractional-only setup for -79..+0, no large-integer math */ | ||
1156 | #define PCM_SW_VOLUME_FRACBITS (16) | ||
1157 | #endif /* SIMULATOR */ | ||
1158 | #endif /* default SDL SW volume conditions */ | ||
1159 | |||
1142 | /* null audiohw setting macro for when codec header is included for reasons | 1160 | /* null audiohw setting macro for when codec header is included for reasons |
1143 | other than audio support */ | 1161 | other than audio support */ |
1144 | #define AUDIOHW_SETTING(name, us, nd, st, minv, maxv, defv, expr...) | 1162 | #define AUDIOHW_SETTING(name, us, nd, st, minv, maxv, defv, expr...) |
diff --git a/firmware/export/hosted_codec.h b/firmware/export/hosted_codec.h index 72495709e8..f5e92ed297 100644 --- a/firmware/export/hosted_codec.h +++ b/firmware/export/hosted_codec.h | |||
@@ -21,8 +21,13 @@ | |||
21 | #ifndef HOSTED_CODEC_H | 21 | #ifndef HOSTED_CODEC_H |
22 | #define HOSTED_CODEC_H | 22 | #define HOSTED_CODEC_H |
23 | 23 | ||
24 | #if defined(HAVE_SDL_AUDIO) \ | ||
25 | && !(CONFIG_PLATFORM & PLATFORM_MAEMO5) | ||
26 | AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -80, 0, 0) | ||
27 | #else | ||
24 | #define AUDIOHW_CAPS (MONO_VOL_CAP) | 28 | #define AUDIOHW_CAPS (MONO_VOL_CAP) |
25 | AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -99, 0, 0) | 29 | AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -99, 0, 0) |
30 | #endif /* CONFIG_PLATFORM & PLATFORM_SDL */ | ||
26 | 31 | ||
27 | #if (CONFIG_PLATFORM & PLATFORM_ANDROID) | 32 | #if (CONFIG_PLATFORM & PLATFORM_ANDROID) |
28 | /* Bass and treble tone controls */ | 33 | /* Bass and treble tone controls */ |
diff --git a/firmware/export/pcm-internal.h b/firmware/export/pcm-internal.h index 03e5c5e6e7..2b73f64ef6 100644 --- a/firmware/export/pcm-internal.h +++ b/firmware/export/pcm-internal.h | |||
@@ -27,13 +27,36 @@ | |||
27 | #ifdef HAVE_SW_VOLUME_CONTROL | 27 | #ifdef HAVE_SW_VOLUME_CONTROL |
28 | /* Default settings - architecture may have other optimal values */ | 28 | /* Default settings - architecture may have other optimal values */ |
29 | 29 | ||
30 | #define PCM_FACTOR_BITS 15 /* Allows -73 to +6dB gain, sans 64-bit math */ | 30 | #ifndef PCM_SW_VOLUME_FRACBITS |
31 | /* Allows -73 to +6dB gain, sans large integer math */ | ||
32 | #define PCM_SW_VOLUME_FRACBITS (15) | ||
33 | #endif | ||
34 | |||
35 | /* Constants selected based on integer math overflow avoidance */ | ||
36 | #if PCM_SW_VOLUME_FRACBITS <= 16 | ||
37 | #define PCM_FACTOR_MAX 0x00010000u | ||
38 | #define PCM_FACTOR_UNITY (1u << PCM_SW_VOLUME_FRACBITS) | ||
39 | #elif PCM_SW_VOLUME_FRACBITS <= 31 | ||
40 | #define PCM_FACTOR_MAX 0x80000000u | ||
41 | #define PCM_FACTOR_UNITY (1u << PCM_SW_VOLUME_FRACBITS) | ||
42 | #endif /* PCM_SW_VOLUME_FRACBITS */ | ||
43 | |||
44 | #ifdef PCM_SW_VOLUME_UNBUFFERED | ||
45 | /* Copies buffer with volume scaling applied */ | ||
46 | void pcm_sw_volume_copy_buffer(void *dst, const void *src, size_t size); | ||
47 | #define pcm_copy_buffer pcm_sw_volume_copy_buffer | ||
48 | #else /* !PCM_SW_VOLUME_UNBUFFERED */ | ||
49 | #ifdef HAVE_SDL_AUDIO | ||
50 | #define pcm_copy_buffer memcpy | ||
51 | #endif | ||
52 | #ifndef PCM_PLAY_DBL_BUF_SAMPLES | ||
31 | #define PCM_PLAY_DBL_BUF_SAMPLES 1024 /* Max 4KByte chunks */ | 53 | #define PCM_PLAY_DBL_BUF_SAMPLES 1024 /* Max 4KByte chunks */ |
54 | #endif | ||
55 | #ifndef PCM_DBL_BUF_BSS | ||
32 | #define PCM_DBL_BUF_BSS /* In DRAM, uncached may be better */ | 56 | #define PCM_DBL_BUF_BSS /* In DRAM, uncached may be better */ |
33 | #define PCM_FACTOR_MIN 0x00000 /* Minimum final factor */ | 57 | #endif |
34 | #define PCM_FACTOR_MAX 0x10000 /* Maximum final factor */ | 58 | #endif /* PCM_SW_VOLUME_UNBUFFERED */ |
35 | 59 | ||
36 | #define PCM_FACTOR_UNITY (1 << PCM_FACTOR_BITS) | ||
37 | #endif /* HAVE_SW_VOLUME_CONTROL */ | 60 | #endif /* HAVE_SW_VOLUME_CONTROL */ |
38 | 61 | ||
39 | #define PCM_SAMPLE_SIZE (2 * sizeof (int16_t)) | 62 | #define PCM_SAMPLE_SIZE (2 * sizeof (int16_t)) |
@@ -84,22 +107,22 @@ static FORCE_INLINE enum pcm_dma_status pcm_play_call_status_cb( | |||
84 | static FORCE_INLINE enum pcm_dma_status | 107 | static FORCE_INLINE enum pcm_dma_status |
85 | pcm_play_dma_status_callback(enum pcm_dma_status status) | 108 | pcm_play_dma_status_callback(enum pcm_dma_status status) |
86 | { | 109 | { |
87 | #ifdef HAVE_SW_VOLUME_CONTROL | 110 | #if defined(HAVE_SW_VOLUME_CONTROL) && !defined(PCM_SW_VOLUME_UNBUFFERED) |
88 | extern enum pcm_dma_status | 111 | extern enum pcm_dma_status |
89 | pcm_play_dma_status_callback_int(enum pcm_dma_status status); | 112 | pcm_play_dma_status_callback_int(enum pcm_dma_status status); |
90 | return pcm_play_dma_status_callback_int(status); | 113 | return pcm_play_dma_status_callback_int(status); |
91 | #else | 114 | #else |
92 | return pcm_play_call_status_cb(status); | 115 | return pcm_play_call_status_cb(status); |
93 | #endif /* HAVE_SW_VOLUME_CONTROL */ | 116 | #endif /* HAVE_SW_VOLUME_CONTROL && !PCM_SW_VOLUME_UNBUFFERED */ |
94 | } | 117 | } |
95 | 118 | ||
96 | #ifdef HAVE_SW_VOLUME_CONTROL | 119 | #if defined(HAVE_SW_VOLUME_CONTROL) && !defined(PCM_SW_VOLUME_UNBUFFERED) |
97 | void pcm_play_dma_start_int(const void *addr, size_t size); | 120 | void pcm_play_dma_start_int(const void *addr, size_t size); |
98 | void pcm_play_dma_pause_int(bool pause); | 121 | void pcm_play_dma_pause_int(bool pause); |
99 | void pcm_play_dma_stop_int(void); | 122 | void pcm_play_dma_stop_int(void); |
100 | void pcm_play_stop_int(void); | 123 | void pcm_play_stop_int(void); |
101 | const void *pcm_play_dma_get_peak_buffer_int(int *count); | 124 | const void *pcm_play_dma_get_peak_buffer_int(int *count); |
102 | #endif /* HAVE_SW_VOLUME_CONTROL */ | 125 | #endif /* HAVE_SW_VOLUME_CONTROL && !PCM_SW_VOLUME_UNBUFFERED */ |
103 | 126 | ||
104 | /* Called by the bottom layer ISR when more data is needed. Returns true | 127 | /* Called by the bottom layer ISR when more data is needed. Returns true |
105 | * if a new buffer is available, false otherwise. */ | 128 | * if a new buffer is available, false otherwise. */ |
diff --git a/firmware/export/pcm_sw_volume.h b/firmware/export/pcm_sw_volume.h index b5d70654a1..5088eadeb1 100644 --- a/firmware/export/pcm_sw_volume.h +++ b/firmware/export/pcm_sw_volume.h | |||
@@ -21,6 +21,12 @@ | |||
21 | #ifndef PCM_SW_VOLUME_H | 21 | #ifndef PCM_SW_VOLUME_H |
22 | #define PCM_SW_VOLUME_H | 22 | #define PCM_SW_VOLUME_H |
23 | 23 | ||
24 | /*** | ||
25 | ** Note: Only PCM drivers that are themselves buffered should use the | ||
26 | ** PCM_SW_VOLUME_UNBUFFERED configuration. This may be part of the platform, | ||
27 | ** the library or a hardware necessity. Normally, it shouldn't be used and | ||
28 | ** only the port developer can properly decide. | ||
29 | **/ | ||
24 | #ifdef HAVE_SW_VOLUME_CONTROL | 30 | #ifdef HAVE_SW_VOLUME_CONTROL |
25 | 31 | ||
26 | #include <audiohw.h> | 32 | #include <audiohw.h> |