diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/asm/generic/pcm-mixer.c | 100 | ||||
-rw-r--r-- | firmware/asm/pcm-mixer.c | 27 |
2 files changed, 15 insertions, 112 deletions
diff --git a/firmware/asm/generic/pcm-mixer.c b/firmware/asm/generic/pcm-mixer.c deleted file mode 100644 index 93841be70d..0000000000 --- a/firmware/asm/generic/pcm-mixer.c +++ /dev/null | |||
@@ -1,100 +0,0 @@ | |||
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 */ | ||
24 | static 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 */ | ||
77 | static 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/asm/pcm-mixer.c b/firmware/asm/pcm-mixer.c index 369e830427..bedaa4c7cb 100644 --- a/firmware/asm/pcm-mixer.c +++ b/firmware/asm/pcm-mixer.c | |||
@@ -25,10 +25,9 @@ | |||
25 | #include "m68k/pcm-mixer.c" | 25 | #include "m68k/pcm-mixer.c" |
26 | #else | 26 | #else |
27 | 27 | ||
28 | /* generic pcm-mixer.c */ | ||
29 | #include "dsp-util.h" /* for clip_sample_16 */ | 28 | #include "dsp-util.h" /* for clip_sample_16 */ |
30 | /* Mix channels' samples and apply gain factors */ | 29 | /* Mix channels' samples and apply gain factors */ |
31 | static FORCE_INLINE void mix_samples(uint32_t *out, | 30 | static FORCE_INLINE void mix_samples(uint16_t *out, |
32 | int16_t *src0, | 31 | int16_t *src0, |
33 | int32_t src0_amp, | 32 | int32_t src0_amp, |
34 | int16_t *src1, | 33 | int16_t *src1, |
@@ -42,9 +41,10 @@ static FORCE_INLINE void mix_samples(uint32_t *out, | |||
42 | { | 41 | { |
43 | int32_t l = *src0++ + *src1++; | 42 | int32_t l = *src0++ + *src1++; |
44 | int32_t h = *src0++ + *src1++; | 43 | int32_t h = *src0++ + *src1++; |
45 | *out++ = (uint16_t)clip_sample_16(l) | (clip_sample_16(h) << 16); | 44 | *out++ = clip_sample_16(l); |
45 | *out++ = clip_sample_16(h); | ||
46 | } | 46 | } |
47 | while ((size -= 4) > 0); | 47 | while ((size -= 2*sizeof(int16_t)) > 0); |
48 | } | 48 | } |
49 | else if (src0_amp != MIX_AMP_UNITY && src1_amp != MIX_AMP_UNITY) | 49 | else if (src0_amp != MIX_AMP_UNITY && src1_amp != MIX_AMP_UNITY) |
50 | { | 50 | { |
@@ -53,9 +53,10 @@ static FORCE_INLINE void mix_samples(uint32_t *out, | |||
53 | { | 53 | { |
54 | int32_t l = (*src0++ * src0_amp >> 16) + (*src1++ * src1_amp >> 16); | 54 | int32_t l = (*src0++ * src0_amp >> 16) + (*src1++ * src1_amp >> 16); |
55 | int32_t h = (*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); | 56 | *out++ = clip_sample_16(l); |
57 | *out++ = clip_sample_16(h); | ||
57 | } | 58 | } |
58 | while ((size -= 4) > 0); | 59 | while ((size -= 2*sizeof(int16_t)) > 0); |
59 | } | 60 | } |
60 | else | 61 | else |
61 | { | 62 | { |
@@ -74,9 +75,10 @@ static FORCE_INLINE void mix_samples(uint32_t *out, | |||
74 | { | 75 | { |
75 | int32_t l = *src0++ + (*src1++ * src1_amp >> 16); | 76 | int32_t l = *src0++ + (*src1++ * src1_amp >> 16); |
76 | int32_t h = *src0++ + (*src1++ * src1_amp >> 16); | 77 | int32_t h = *src0++ + (*src1++ * src1_amp >> 16); |
77 | *out++ = (uint16_t)clip_sample_16(l) | (clip_sample_16(h) << 16); | 78 | *out++ = clip_sample_16(l); |
79 | *out++ = clip_sample_16(h); | ||
78 | } | 80 | } |
79 | while ((size -= 4) > 0); | 81 | while ((size -= 2*sizeof(int16_t)) > 0); |
80 | } | 82 | } |
81 | } | 83 | } |
82 | 84 | ||
@@ -97,12 +99,13 @@ static FORCE_INLINE void write_samples(uint32_t *out, | |||
97 | do | 99 | do |
98 | { | 100 | { |
99 | int32_t l = *src++ * amp >> 16; | 101 | int32_t l = *src++ * amp >> 16; |
100 | int32_t h = *src++ * amp & 0xffff0000; | 102 | int32_t h = *src++ * amp >> 16; |
101 | *out++ = (uint16_t)l | h; | 103 | *out++ = l; |
104 | *out++ = h; | ||
102 | } | 105 | } |
103 | while ((size -= 4) > 0); | 106 | while ((size -= 2*sizeof(int16_t)) > 0); |
104 | } | 107 | } |
105 | } | 108 | } |
106 | 109 | ||
107 | 110 | ||
108 | #endif | 111 | #endif /* CPU_* */ |