summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/asm/arm/pcm-mixer-armv4.c (renamed from firmware/target/arm/pcm-mixer-armv4.c)0
-rw-r--r--firmware/asm/arm/pcm-mixer-armv5.c (renamed from firmware/target/arm/pcm-mixer-armv5.c)0
-rw-r--r--firmware/asm/arm/pcm-mixer-armv6.c (renamed from firmware/target/arm/pcm-mixer-armv6.c)0
-rw-r--r--firmware/asm/arm/pcm-mixer.c7
-rw-r--r--firmware/asm/generic/pcm-mixer.c100
-rw-r--r--firmware/asm/m68k/pcm-mixer.c (renamed from firmware/target/coldfire/pcm-mixer-coldfire.c)0
-rw-r--r--firmware/asm/pcm-mixer.c108
-rw-r--r--firmware/pcm_mixer.c104
8 files changed, 217 insertions, 102 deletions
diff --git a/firmware/target/arm/pcm-mixer-armv4.c b/firmware/asm/arm/pcm-mixer-armv4.c
index 4818544d7b..4818544d7b 100644
--- a/firmware/target/arm/pcm-mixer-armv4.c
+++ b/firmware/asm/arm/pcm-mixer-armv4.c
diff --git a/firmware/target/arm/pcm-mixer-armv5.c b/firmware/asm/arm/pcm-mixer-armv5.c
index 64f2c86f52..64f2c86f52 100644
--- a/firmware/target/arm/pcm-mixer-armv5.c
+++ b/firmware/asm/arm/pcm-mixer-armv5.c
diff --git a/firmware/target/arm/pcm-mixer-armv6.c b/firmware/asm/arm/pcm-mixer-armv6.c
index 94eecd0f90..94eecd0f90 100644
--- a/firmware/target/arm/pcm-mixer-armv6.c
+++ b/firmware/asm/arm/pcm-mixer-armv6.c
diff --git a/firmware/asm/arm/pcm-mixer.c b/firmware/asm/arm/pcm-mixer.c
new file mode 100644
index 0000000000..16c9c3575d
--- /dev/null
+++ b/firmware/asm/arm/pcm-mixer.c
@@ -0,0 +1,7 @@
1#if ARM_ARCH >= 6
2 #include "pcm-mixer-armv6.c"
3#elif ARM_ARCH >= 5
4 #include "pcm-mixer-armv5.c"
5#elif ARM_ARCH >= 4
6 #include "pcm-mixer-armv4.c"
7#endif
diff --git a/firmware/asm/generic/pcm-mixer.c b/firmware/asm/generic/pcm-mixer.c
new file mode 100644
index 0000000000..93841be70d
--- /dev/null
+++ b/firmware/asm/generic/pcm-mixer.c
@@ -0,0 +1,100 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 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
22#include "dsp-util.h" /* for clip_sample_16 */
23/* Mix channels' samples and apply gain factors */
24static FORCE_INLINE void mix_samples(uint32_t *out,
25 int16_t *src0,
26 int32_t src0_amp,
27 int16_t *src1,
28 int32_t src1_amp,
29 size_t size)
30{
31 if (src0_amp == MIX_AMP_UNITY && src1_amp == MIX_AMP_UNITY)
32 {
33 /* Both are unity amplitude */
34 do
35 {
36 int32_t l = *src0++ + *src1++;
37 int32_t h = *src0++ + *src1++;
38 *out++ = (uint16_t)clip_sample_16(l) | (clip_sample_16(h) << 16);
39 }
40 while ((size -= 4) > 0);
41 }
42 else if (src0_amp != MIX_AMP_UNITY && src1_amp != MIX_AMP_UNITY)
43 {
44 /* Neither are unity amplitude */
45 do
46 {
47 int32_t l = (*src0++ * src0_amp >> 16) + (*src1++ * src1_amp >> 16);
48 int32_t h = (*src0++ * src0_amp >> 16) + (*src1++ * src1_amp >> 16);
49 *out++ = (uint16_t)clip_sample_16(l) | (clip_sample_16(h) << 16);
50 }
51 while ((size -= 4) > 0);
52 }
53 else
54 {
55 /* One is unity amplitude */
56 if (src0_amp != MIX_AMP_UNITY)
57 {
58 /* Keep unity in src0, amp0 */
59 int16_t *src_tmp = src0;
60 src0 = src1;
61 src1 = src_tmp;
62 src1_amp = src0_amp;
63 src0_amp = MIX_AMP_UNITY;
64 }
65
66 do
67 {
68 int32_t l = *src0++ + (*src1++ * src1_amp >> 16);
69 int32_t h = *src0++ + (*src1++ * src1_amp >> 16);
70 *out++ = (uint16_t)clip_sample_16(l) | (clip_sample_16(h) << 16);
71 }
72 while ((size -= 4) > 0);
73 }
74}
75
76/* Write channel's samples and apply gain factor */
77static FORCE_INLINE void write_samples(uint32_t *out,
78 int16_t *src,
79 int32_t amp,
80 size_t size)
81{
82 if (LIKELY(amp == MIX_AMP_UNITY))
83 {
84 /* Channel is unity amplitude */
85 memcpy(out, src, size);
86 }
87 else
88 {
89 /* Channel needs amplitude cut */
90 do
91 {
92 int32_t l = *src++ * amp >> 16;
93 int32_t h = *src++ * amp & 0xffff0000;
94 *out++ = (uint16_t)l | h;
95 }
96 while ((size -= 4) > 0);
97 }
98}
99
100#endif
diff --git a/firmware/target/coldfire/pcm-mixer-coldfire.c b/firmware/asm/m68k/pcm-mixer.c
index d8318fffaf..d8318fffaf 100644
--- a/firmware/target/coldfire/pcm-mixer-coldfire.c
+++ b/firmware/asm/m68k/pcm-mixer.c
diff --git a/firmware/asm/pcm-mixer.c b/firmware/asm/pcm-mixer.c
new file mode 100644
index 0000000000..369e830427
--- /dev/null
+++ b/firmware/asm/pcm-mixer.c
@@ -0,0 +1,108 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 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
22#if defined(CPU_ARM)
23 #include "arm/pcm-mixer.c"
24#elif defined(CPU_COLDFIRE)
25 #include "m68k/pcm-mixer.c"
26#else
27
28/* generic pcm-mixer.c */
29#include "dsp-util.h" /* for clip_sample_16 */
30/* Mix channels' samples and apply gain factors */
31static FORCE_INLINE void mix_samples(uint32_t *out,
32 int16_t *src0,
33 int32_t src0_amp,
34 int16_t *src1,
35 int32_t src1_amp,
36 size_t size)
37{
38 if (src0_amp == MIX_AMP_UNITY && src1_amp == MIX_AMP_UNITY)
39 {
40 /* Both are unity amplitude */
41 do
42 {
43 int32_t l = *src0++ + *src1++;
44 int32_t h = *src0++ + *src1++;
45 *out++ = (uint16_t)clip_sample_16(l) | (clip_sample_16(h) << 16);
46 }
47 while ((size -= 4) > 0);
48 }
49 else if (src0_amp != MIX_AMP_UNITY && src1_amp != MIX_AMP_UNITY)
50 {
51 /* Neither are unity amplitude */
52 do
53 {
54 int32_t l = (*src0++ * src0_amp >> 16) + (*src1++ * src1_amp >> 16);
55 int32_t h = (*src0++ * src0_amp >> 16) + (*src1++ * src1_amp >> 16);
56 *out++ = (uint16_t)clip_sample_16(l) | (clip_sample_16(h) << 16);
57 }
58 while ((size -= 4) > 0);
59 }
60 else
61 {
62 /* One is unity amplitude */
63 if (src0_amp != MIX_AMP_UNITY)
64 {
65 /* Keep unity in src0, amp0 */
66 int16_t *src_tmp = src0;
67 src0 = src1;
68 src1 = src_tmp;
69 src1_amp = src0_amp;
70 src0_amp = MIX_AMP_UNITY;
71 }
72
73 do
74 {
75 int32_t l = *src0++ + (*src1++ * src1_amp >> 16);
76 int32_t h = *src0++ + (*src1++ * src1_amp >> 16);
77 *out++ = (uint16_t)clip_sample_16(l) | (clip_sample_16(h) << 16);
78 }
79 while ((size -= 4) > 0);
80 }
81}
82
83/* Write channel's samples and apply gain factor */
84static FORCE_INLINE void write_samples(uint32_t *out,
85 int16_t *src,
86 int32_t amp,
87 size_t size)
88{
89 if (LIKELY(amp == MIX_AMP_UNITY))
90 {
91 /* Channel is unity amplitude */
92 memcpy(out, src, size);
93 }
94 else
95 {
96 /* Channel needs amplitude cut */
97 do
98 {
99 int32_t l = *src++ * amp >> 16;
100 int32_t h = *src++ * amp & 0xffff0000;
101 *out++ = (uint16_t)l | h;
102 }
103 while ((size -= 4) > 0);
104 }
105}
106
107
108#endif
diff --git a/firmware/pcm_mixer.c b/firmware/pcm_mixer.c
index 25c41c2586..0038b0f5e7 100644
--- a/firmware/pcm_mixer.c
+++ b/firmware/pcm_mixer.c
@@ -70,108 +70,8 @@ static struct mixer_channel * active_channels[PCM_MIXER_NUM_CHANNELS+1] IBSS_ATT
70#define MAX_IDLE_FRAMES (NATIVE_FREQUENCY*3 / MIX_FRAME_SAMPLES) 70#define MAX_IDLE_FRAMES (NATIVE_FREQUENCY*3 / MIX_FRAME_SAMPLES)
71static unsigned int idle_counter = 0; 71static unsigned int idle_counter = 0;
72 72
73#if (CONFIG_PLATFORM & PLATFORM_NATIVE) 73/** Mixing routines, CPU optmized **/
74 74#include "asm/pcm-mixer.c"
75/* Include any implemented CPU-optimized mixdown routines */
76#if defined(CPU_ARM)
77#if ARM_ARCH >= 6
78#include "pcm-mixer-armv6.c"
79#elif ARM_ARCH >= 5
80#include "pcm-mixer-armv5.c"
81#else
82#include "pcm-mixer-armv4.c"
83#endif /* ARM_ARCH */
84#elif defined (CPU_COLDFIRE)
85#include "pcm-mixer-coldfire.c"
86#endif /* CPU_* */
87
88#endif /* CONFIG_PLATFORM */
89
90/** Generic mixing routines **/
91
92#ifndef MIXER_OPTIMIZED_MIX_SAMPLES
93#include "dsp-util.h" /* for clip_sample_16 */
94
95/* Mix channels' samples and apply gain factors */
96static FORCE_INLINE void mix_samples(uint32_t *out,
97 int16_t *src0,
98 int32_t src0_amp,
99 int16_t *src1,
100 int32_t src1_amp,
101 size_t size)
102{
103 if (src0_amp == MIX_AMP_UNITY && src1_amp == MIX_AMP_UNITY)
104 {
105 /* Both are unity amplitude */
106 do
107 {
108 int32_t l = *src0++ + *src1++;
109 int32_t h = *src0++ + *src1++;
110 *out++ = (uint16_t)clip_sample_16(l) | (clip_sample_16(h) << 16);
111 }
112 while ((size -= 4) > 0);
113 }
114 else if (src0_amp != MIX_AMP_UNITY && src1_amp != MIX_AMP_UNITY)
115 {
116 /* Neither are unity amplitude */
117 do
118 {
119 int32_t l = (*src0++ * src0_amp >> 16) + (*src1++ * src1_amp >> 16);
120 int32_t h = (*src0++ * src0_amp >> 16) + (*src1++ * src1_amp >> 16);
121 *out++ = (uint16_t)clip_sample_16(l) | (clip_sample_16(h) << 16);
122 }
123 while ((size -= 4) > 0);
124 }
125 else
126 {
127 /* One is unity amplitude */
128 if (src0_amp != MIX_AMP_UNITY)
129 {
130 /* Keep unity in src0, amp0 */
131 int16_t *src_tmp = src0;
132 src0 = src1;
133 src1 = src_tmp;
134 src1_amp = src0_amp;
135 src0_amp = MIX_AMP_UNITY;
136 }
137
138 do
139 {
140 int32_t l = *src0++ + (*src1++ * src1_amp >> 16);
141 int32_t h = *src0++ + (*src1++ * src1_amp >> 16);
142 *out++ = (uint16_t)clip_sample_16(l) | (clip_sample_16(h) << 16);
143 }
144 while ((size -= 4) > 0);
145 }
146}
147#endif /* MIXER_OPTIMIZED_MIX_SAMPLES */
148
149#ifndef MIXER_OPTIMIZED_WRITE_SAMPLES
150/* Write channel's samples and apply gain factor */
151static FORCE_INLINE void write_samples(uint32_t *out,
152 int16_t *src,
153 int32_t amp,
154 size_t size)
155{
156 if (LIKELY(amp == MIX_AMP_UNITY))
157 {
158 /* Channel is unity amplitude */
159 memcpy(out, src, size);
160 }
161 else
162 {
163 /* Channel needs amplitude cut */
164 do
165 {
166 int32_t l = *src++ * amp >> 16;
167 int32_t h = *src++ * amp & 0xffff0000;
168 *out++ = (uint16_t)l | h;
169 }
170 while ((size -= 4) > 0);
171 }
172}
173#endif /* MIXER_OPTIMIZED_WRITE_SAMPLES */
174
175 75
176/** Private generic routines **/ 76/** Private generic routines **/
177 77