diff options
Diffstat (limited to 'firmware/export')
-rw-r--r-- | firmware/export/config/ondavx747.h | 5 | ||||
-rw-r--r-- | firmware/export/config/ondavx777.h | 5 | ||||
-rw-r--r-- | firmware/export/jz4740-codec.h | 2 | ||||
-rw-r--r-- | firmware/export/pcm-internal.h | 54 | ||||
-rw-r--r-- | firmware/export/pcm_sw_volume.h | 40 | ||||
-rw-r--r-- | firmware/export/sound.h | 3 |
6 files changed, 93 insertions, 16 deletions
diff --git a/firmware/export/config/ondavx747.h b/firmware/export/config/ondavx747.h index d303ea5925..8499c15ce9 100644 --- a/firmware/export/config/ondavx747.h +++ b/firmware/export/config/ondavx747.h | |||
@@ -132,11 +132,6 @@ | |||
132 | /* has no volume control, so we use the software ones */ | 132 | /* has no volume control, so we use the software ones */ |
133 | #define HAVE_SW_VOLUME_CONTROL | 133 | #define HAVE_SW_VOLUME_CONTROL |
134 | 134 | ||
135 | /* software controlled volume ranges from -73 -> 0 dB, other than that | ||
136 | is controlled by hardware */ | ||
137 | #define SW_VOLUME_MIN -73 | ||
138 | #define SW_VOLUME_MAX 0 | ||
139 | |||
140 | /* define the bitmask of hardware sample rates */ | 135 | /* define the bitmask of hardware sample rates */ |
141 | #define HW_SAMPR_CAPS (SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \ | 136 | #define HW_SAMPR_CAPS (SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \ |
142 | SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \ | 137 | SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \ |
diff --git a/firmware/export/config/ondavx777.h b/firmware/export/config/ondavx777.h index 33bf6442af..a254b0177c 100644 --- a/firmware/export/config/ondavx777.h +++ b/firmware/export/config/ondavx777.h | |||
@@ -126,11 +126,6 @@ | |||
126 | /* has no volume control, so we use the software ones */ | 126 | /* has no volume control, so we use the software ones */ |
127 | #define HAVE_SW_VOLUME_CONTROL | 127 | #define HAVE_SW_VOLUME_CONTROL |
128 | 128 | ||
129 | /* software controlled volume ranges from -73 -> 0 dB, other than that | ||
130 | is controlled by hardware */ | ||
131 | #define SW_VOLUME_MIN -73 | ||
132 | #define SW_VOLUME_MAX 0 | ||
133 | |||
134 | /* define the bitmask of hardware sample rates */ | 129 | /* define the bitmask of hardware sample rates */ |
135 | #define HW_SAMPR_CAPS (SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \ | 130 | #define HW_SAMPR_CAPS (SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \ |
136 | SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \ | 131 | SAMPR_CAP_24 | SAMPR_CAP_22 | SAMPR_CAP_16 | \ |
diff --git a/firmware/export/jz4740-codec.h b/firmware/export/jz4740-codec.h index 37d2347f5b..3c088f5bf7 100644 --- a/firmware/export/jz4740-codec.h +++ b/firmware/export/jz4740-codec.h | |||
@@ -24,6 +24,6 @@ | |||
24 | #define VOLUME_MIN -730 | 24 | #define VOLUME_MIN -730 |
25 | #define VOLUME_MAX 60 | 25 | #define VOLUME_MAX 60 |
26 | 26 | ||
27 | void audiohw_set_volume(int v); | 27 | void audiohw_set_master_vol(int vol_l, int vol_r); |
28 | 28 | ||
29 | #endif /* __JZ4740_CODEC_H_ */ | 29 | #endif /* __JZ4740_CODEC_H_ */ |
diff --git a/firmware/export/pcm-internal.h b/firmware/export/pcm-internal.h index 397cf6832f..03e5c5e6e7 100644 --- a/firmware/export/pcm-internal.h +++ b/firmware/export/pcm-internal.h | |||
@@ -24,6 +24,19 @@ | |||
24 | 24 | ||
25 | #include "config.h" | 25 | #include "config.h" |
26 | 26 | ||
27 | #ifdef HAVE_SW_VOLUME_CONTROL | ||
28 | /* Default settings - architecture may have other optimal values */ | ||
29 | |||
30 | #define PCM_FACTOR_BITS 15 /* Allows -73 to +6dB gain, sans 64-bit math */ | ||
31 | #define PCM_PLAY_DBL_BUF_SAMPLES 1024 /* Max 4KByte chunks */ | ||
32 | #define PCM_DBL_BUF_BSS /* In DRAM, uncached may be better */ | ||
33 | #define PCM_FACTOR_MIN 0x00000 /* Minimum final factor */ | ||
34 | #define PCM_FACTOR_MAX 0x10000 /* Maximum final factor */ | ||
35 | |||
36 | #define PCM_FACTOR_UNITY (1 << PCM_FACTOR_BITS) | ||
37 | #endif /* HAVE_SW_VOLUME_CONTROL */ | ||
38 | |||
39 | #define PCM_SAMPLE_SIZE (2 * sizeof (int16_t)) | ||
27 | /* Cheapo buffer align macro to align to the 16-16 PCM size */ | 40 | /* Cheapo buffer align macro to align to the 16-16 PCM size */ |
28 | #define ALIGN_AUDIOBUF(start, size) \ | 41 | #define ALIGN_AUDIOBUF(start, size) \ |
29 | ({ (start) = (void *)(((uintptr_t)(start) + 3) & ~3); \ | 42 | ({ (start) = (void *)(((uintptr_t)(start) + 3) & ~3); \ |
@@ -34,6 +47,23 @@ void pcm_do_peak_calculation(struct pcm_peaks *peaks, bool active, | |||
34 | 47 | ||
35 | /** The following are for internal use between pcm.c and target- | 48 | /** The following are for internal use between pcm.c and target- |
36 | specific portion **/ | 49 | specific portion **/ |
50 | /* Call registered callback to obtain next buffer */ | ||
51 | static inline bool pcm_get_more_int(const void **addr, size_t *size) | ||
52 | { | ||
53 | extern volatile pcm_play_callback_type pcm_callback_for_more; | ||
54 | pcm_play_callback_type get_more = pcm_callback_for_more; | ||
55 | |||
56 | if (UNLIKELY(!get_more)) | ||
57 | return false; | ||
58 | |||
59 | *addr = NULL; | ||
60 | *size = 0; | ||
61 | get_more(addr, size); | ||
62 | ALIGN_AUDIOBUF(*addr, *size); | ||
63 | |||
64 | return *addr && *size; | ||
65 | } | ||
66 | |||
37 | static FORCE_INLINE enum pcm_dma_status pcm_call_status_cb( | 67 | static FORCE_INLINE enum pcm_dma_status pcm_call_status_cb( |
38 | pcm_status_callback_type callback, enum pcm_dma_status status) | 68 | pcm_status_callback_type callback, enum pcm_dma_status status) |
39 | { | 69 | { |
@@ -43,14 +73,34 @@ static FORCE_INLINE enum pcm_dma_status pcm_call_status_cb( | |||
43 | return callback(status); | 73 | return callback(status); |
44 | } | 74 | } |
45 | 75 | ||
46 | static FORCE_INLINE enum pcm_dma_status | 76 | static FORCE_INLINE enum pcm_dma_status pcm_play_call_status_cb( |
47 | pcm_play_dma_status_callback(enum pcm_dma_status status) | 77 | enum pcm_dma_status status) |
48 | { | 78 | { |
49 | extern enum pcm_dma_status | 79 | extern enum pcm_dma_status |
50 | (* volatile pcm_play_status_callback)(enum pcm_dma_status); | 80 | (* volatile pcm_play_status_callback)(enum pcm_dma_status); |
51 | return pcm_call_status_cb(pcm_play_status_callback, status); | 81 | return pcm_call_status_cb(pcm_play_status_callback, status); |
52 | } | 82 | } |
53 | 83 | ||
84 | static FORCE_INLINE enum pcm_dma_status | ||
85 | pcm_play_dma_status_callback(enum pcm_dma_status status) | ||
86 | { | ||
87 | #ifdef HAVE_SW_VOLUME_CONTROL | ||
88 | extern enum pcm_dma_status | ||
89 | pcm_play_dma_status_callback_int(enum pcm_dma_status status); | ||
90 | return pcm_play_dma_status_callback_int(status); | ||
91 | #else | ||
92 | return pcm_play_call_status_cb(status); | ||
93 | #endif /* HAVE_SW_VOLUME_CONTROL */ | ||
94 | } | ||
95 | |||
96 | #ifdef HAVE_SW_VOLUME_CONTROL | ||
97 | void pcm_play_dma_start_int(const void *addr, size_t size); | ||
98 | void pcm_play_dma_pause_int(bool pause); | ||
99 | void pcm_play_dma_stop_int(void); | ||
100 | void pcm_play_stop_int(void); | ||
101 | const void *pcm_play_dma_get_peak_buffer_int(int *count); | ||
102 | #endif /* HAVE_SW_VOLUME_CONTROL */ | ||
103 | |||
54 | /* Called by the bottom layer ISR when more data is needed. Returns true | 104 | /* Called by the bottom layer ISR when more data is needed. Returns true |
55 | * if a new buffer is available, false otherwise. */ | 105 | * if a new buffer is available, false otherwise. */ |
56 | bool pcm_play_dma_complete_callback(enum pcm_dma_status status, | 106 | bool pcm_play_dma_complete_callback(enum pcm_dma_status status, |
diff --git a/firmware/export/pcm_sw_volume.h b/firmware/export/pcm_sw_volume.h new file mode 100644 index 0000000000..b86e78f500 --- /dev/null +++ b/firmware/export/pcm_sw_volume.h | |||
@@ -0,0 +1,40 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2013 by Michael Sevakis | ||
11 | * | ||
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. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef PCM_SW_VOLUME_H | ||
22 | #define PCM_SW_VOLUME_H | ||
23 | |||
24 | #ifdef HAVE_SW_VOLUME_CONTROL | ||
25 | |||
26 | #include <audiohw.h> | ||
27 | |||
28 | #define PCM_MUTE_LEVEL INT_MIN | ||
29 | |||
30 | #ifdef AUDIOHW_HAVE_PRESCALER | ||
31 | /* Set the prescaler value for all PCM playback */ | ||
32 | void pcm_set_prescaler(int prescale); | ||
33 | #endif /* AUDIOHW_HAVE_PRESCALER */ | ||
34 | |||
35 | /* Set the per-channel volume cut/gain for all PCM playback */ | ||
36 | void pcm_set_master_volume(int vol_l, int vol_r); | ||
37 | |||
38 | #endif /* HAVE_SW_VOLUME_CONTROL */ | ||
39 | |||
40 | #endif /* PCM_SW_VOLUME_H */ | ||
diff --git a/firmware/export/sound.h b/firmware/export/sound.h index ba6120ce8f..ebf728c7c7 100644 --- a/firmware/export/sound.h +++ b/firmware/export/sound.h | |||
@@ -32,9 +32,6 @@ enum { | |||
32 | DSP_CALLBACK_SET_TREBLE, | 32 | DSP_CALLBACK_SET_TREBLE, |
33 | DSP_CALLBACK_SET_CHANNEL_CONFIG, | 33 | DSP_CALLBACK_SET_CHANNEL_CONFIG, |
34 | DSP_CALLBACK_SET_STEREO_WIDTH, | 34 | DSP_CALLBACK_SET_STEREO_WIDTH, |
35 | #ifdef HAVE_SW_VOLUME_CONTROL | ||
36 | DSP_CALLBACK_SET_SW_VOLUME, | ||
37 | #endif | ||
38 | }; | 35 | }; |
39 | #endif | 36 | #endif |
40 | 37 | ||