summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-05-15 16:08:50 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-05-15 16:08:50 +0000
commit46507d29b4bc0f4fe491aadae8d3a474be7cec39 (patch)
tree7a467903a805e13b32217c119260f75ceb69b0fa
parent41723bc14b41498206afc6693c6c8e5b1b0c77de (diff)
downloadrockbox-46507d29b4bc0f4fe491aadae8d3a474be7cec39.tar.gz
rockbox-46507d29b4bc0f4fe491aadae8d3a474be7cec39.zip
FS#12113: Optimize IRAM configuration for SPC. Performance increases by 5-6% on PP5022, PP5024 and S5L870x. No change of performance on Coldfire, PP5002 and PP5020.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29887 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libspc/spc_codec.h64
-rw-r--r--apps/codecs/libspc/spc_cpu.c2
-rw-r--r--apps/codecs/libspc/spc_dsp.c11
-rw-r--r--apps/codecs/libspc/spc_emu.c2
-rw-r--r--apps/codecs/spc.c2
5 files changed, 50 insertions, 31 deletions
diff --git a/apps/codecs/libspc/spc_codec.h b/apps/codecs/libspc/spc_codec.h
index f4f69dd758..391540cb19 100644
--- a/apps/codecs/libspc/spc_codec.h
+++ b/apps/codecs/libspc/spc_codec.h
@@ -89,20 +89,41 @@
89 #define SPC_NOECHO 1 89 #define SPC_NOECHO 1
90#endif 90#endif
91 91
92#ifdef CPU_ARM 92#if (CONFIG_CPU == MCF5250)
93#define IBSS_ATTR_SPC IBSS_ATTR
94#define ICODE_ATTR_SPC ICODE_ATTR
95#define ICONST_ATTR_SPC ICONST_ATTR
96/* Not enough IRAM available to move further data to it. */
97#define IBSS_ATTR_SPC_LARGE_IRAM
98
99#elif (CONFIG_CPU == PP5020)
100/* spc is slower on PP5020 when moving data to IRAM. */
101#define IBSS_ATTR_SPC
102#define ICODE_ATTR_SPC
103#define ICONST_ATTR_SPC
104/* Not enough IRAM available to move further data to it. */
105#define IBSS_ATTR_SPC_LARGE_IRAM
106
107#elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024)
108#define IBSS_ATTR_SPC IBSS_ATTR
109#define ICODE_ATTR_SPC ICODE_ATTR
110#define ICONST_ATTR_SPC ICONST_ATTR
111/* Not enough IRAM available to move further data to it. */
112#define IBSS_ATTR_SPC_LARGE_IRAM
113
114#elif defined(CPU_S5L870X)
115#define IBSS_ATTR_SPC IBSS_ATTR
116#define ICODE_ATTR_SPC ICODE_ATTR
117#define ICONST_ATTR_SPC ICONST_ATTR
118/* Very large IRAM. Move even more data to it. */
119#define IBSS_ATTR_SPC_LARGE_IRAM IBSS_ATTR
93 120
94#if CONFIG_CPU != PP5002 121#else
95 #undef ICODE_ATTR 122#define IBSS_ATTR_SPC IBSS_ATTR
96 #define ICODE_ATTR 123#define ICODE_ATTR_SPC ICODE_ATTR
97 124#define ICONST_ATTR_SPC ICONST_ATTR
98 #undef IDATA_ATTR 125/* Not enough IRAM available to move further data to it. */
99 #define IDATA_ATTR 126#define IBSS_ATTR_SPC_LARGE_IRAM
100
101 #undef ICONST_ATTR
102 #define ICONST_ATTR
103
104 #undef IBSS_ATTR
105 #define IBSS_ATTR
106#endif 127#endif
107 128
108#if SPC_DUAL_CORE 129#if SPC_DUAL_CORE
@@ -111,7 +132,6 @@
111 #undef SHAREDDATA_ATTR 132 #undef SHAREDDATA_ATTR
112 #define SHAREDDATA_ATTR __attribute__((section(".idata"))) 133 #define SHAREDDATA_ATTR __attribute__((section(".idata")))
113#endif 134#endif
114#endif
115 135
116/* Samples per channel per iteration */ 136/* Samples per channel per iteration */
117#if defined(CPU_PP) && NUM_CORES == 1 137#if defined(CPU_PP) && NUM_CORES == 1
@@ -192,7 +212,7 @@ struct cpu_ram_t
192#define RAM ram.ram 212#define RAM ram.ram
193extern struct cpu_ram_t ram; 213extern struct cpu_ram_t ram;
194 214
195long CPU_run( THIS, long start_time ) ICODE_ATTR; 215long CPU_run( THIS, long start_time ) ICODE_ATTR_SPC;
196void CPU_Init( THIS ); 216void CPU_Init( THIS );
197 217
198/* The DSP portion (awe!) */ 218/* The DSP portion (awe!) */
@@ -375,7 +395,7 @@ struct Spc_Dsp
375#endif 395#endif
376}; 396};
377 397
378void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) ICODE_ATTR; 398void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) ICODE_ATTR_SPC;
379void DSP_reset( struct Spc_Dsp* this ); 399void DSP_reset( struct Spc_Dsp* this );
380 400
381static inline void DSP_run( struct Spc_Dsp* this, long count, int32_t* out ) 401static inline void DSP_run( struct Spc_Dsp* this, long count, int32_t* out )
@@ -412,7 +432,7 @@ struct Timer
412 int counter; 432 int counter;
413}; 433};
414 434
415void Timer_run_( struct Timer* t, long time ) ICODE_ATTR; 435void Timer_run_( struct Timer* t, long time ) ICODE_ATTR_SPC;
416 436
417static inline void Timer_run( struct Timer* t, long time ) 437static inline void Timer_run( struct Timer* t, long time )
418{ 438{
@@ -461,7 +481,7 @@ void SPC_Init( THIS );
461int SPC_load_spc( THIS, const void* data, long size ); 481int SPC_load_spc( THIS, const void* data, long size );
462 482
463/**************** DSP interaction ****************/ 483/**************** DSP interaction ****************/
464void DSP_write( struct Spc_Dsp* this, int i, int data ) ICODE_ATTR; 484void DSP_write( struct Spc_Dsp* this, int i, int data ) ICODE_ATTR_SPC;
465 485
466static inline int DSP_read( struct Spc_Dsp* this, int i ) 486static inline int DSP_read( struct Spc_Dsp* this, int i )
467{ 487{
@@ -469,7 +489,7 @@ static inline int DSP_read( struct Spc_Dsp* this, int i )
469 return this->r.reg [i]; 489 return this->r.reg [i];
470} 490}
471 491
472void SPC_run_dsp_( THIS, long time ) ICODE_ATTR; 492void SPC_run_dsp_( THIS, long time ) ICODE_ATTR_SPC;
473 493
474static inline void SPC_run_dsp( THIS, long time ) 494static inline void SPC_run_dsp( THIS, long time )
475{ 495{
@@ -477,10 +497,10 @@ static inline void SPC_run_dsp( THIS, long time )
477 SPC_run_dsp_( this, time ); 497 SPC_run_dsp_( this, time );
478} 498}
479 499
480int SPC_read( THIS, unsigned addr, long const time ) ICODE_ATTR; 500int SPC_read( THIS, unsigned addr, long const time ) ICODE_ATTR_SPC;
481void SPC_write( THIS, unsigned addr, int data, long const time ) ICODE_ATTR; 501void SPC_write( THIS, unsigned addr, int data, long const time ) ICODE_ATTR_SPC;
482 502
483/**************** Sample generation ****************/ 503/**************** Sample generation ****************/
484int SPC_play( THIS, long count, int32_t* out ) ICODE_ATTR; 504int SPC_play( THIS, long count, int32_t* out ) ICODE_ATTR_SPC;
485 505
486#endif /* _SPC_CODEC_H_ */ 506#endif /* _SPC_CODEC_H_ */
diff --git a/apps/codecs/libspc/spc_cpu.c b/apps/codecs/libspc/spc_cpu.c
index d308e6e27c..23dcc257de 100644
--- a/apps/codecs/libspc/spc_cpu.c
+++ b/apps/codecs/libspc/spc_cpu.c
@@ -65,7 +65,7 @@ static unsigned char const cycle_table [0x100] = {
65#define MEM_BIT() CPU_mem_bit( this, pc, spc_time_ ) 65#define MEM_BIT() CPU_mem_bit( this, pc, spc_time_ )
66 66
67static unsigned CPU_mem_bit( THIS, uint8_t const* pc, long const spc_time_ ) 67static unsigned CPU_mem_bit( THIS, uint8_t const* pc, long const spc_time_ )
68 ICODE_ATTR; 68 ICODE_ATTR_SPC;
69 69
70static unsigned CPU_mem_bit( THIS, uint8_t const* pc, long const spc_time_ ) 70static unsigned CPU_mem_bit( THIS, uint8_t const* pc, long const spc_time_ )
71{ 71{
diff --git a/apps/codecs/libspc/spc_dsp.c b/apps/codecs/libspc/spc_dsp.c
index b4fc57158b..4b289caeda 100644
--- a/apps/codecs/libspc/spc_dsp.c
+++ b/apps/codecs/libspc/spc_dsp.c
@@ -28,8 +28,7 @@
28#include "spc_profiler.h" 28#include "spc_profiler.h"
29 29
30#if defined(CPU_COLDFIRE) || defined (CPU_ARM) 30#if defined(CPU_COLDFIRE) || defined (CPU_ARM)
31int32_t fir_buf[FIR_BUF_CNT] 31int32_t fir_buf[FIR_BUF_CNT] IBSS_ATTR_SPC MEM_ALIGN_ATTR;
32 __attribute__ ((aligned (FIR_BUF_ALIGN*1))) IBSS_ATTR;
33#endif 32#endif
34#if SPC_BRRCACHE 33#if SPC_BRRCACHE
35/* a little extra for samples that go past end */ 34/* a little extra for samples that go past end */
@@ -80,7 +79,7 @@ void DSP_write( struct Spc_Dsp* this, int i, int data )
80#if SPC_BRRCACHE 79#if SPC_BRRCACHE
81static void decode_brr( struct Spc_Dsp* this, unsigned start_addr, 80static void decode_brr( struct Spc_Dsp* this, unsigned start_addr,
82 struct voice_t* voice, 81 struct voice_t* voice,
83 struct raw_voice_t const* const raw_voice ) ICODE_ATTR; 82 struct raw_voice_t const* const raw_voice ) ICODE_ATTR_SPC;
84static void decode_brr( struct Spc_Dsp* this, unsigned start_addr, 83static void decode_brr( struct Spc_Dsp* this, unsigned start_addr,
85 struct voice_t* voice, 84 struct voice_t* voice,
86 struct raw_voice_t const* const raw_voice ) 85 struct raw_voice_t const* const raw_voice )
@@ -248,7 +247,7 @@ wave_in_cache:;
248static void key_on(struct Spc_Dsp* const this, struct voice_t* const voice, 247static void key_on(struct Spc_Dsp* const this, struct voice_t* const voice,
249 struct src_dir const* const sd, 248 struct src_dir const* const sd,
250 struct raw_voice_t const* const raw_voice, 249 struct raw_voice_t const* const raw_voice,
251 const int key_on_delay, const int vbit) ICODE_ATTR; 250 const int key_on_delay, const int vbit) ICODE_ATTR_SPC;
252static void key_on(struct Spc_Dsp* const this, struct voice_t* const voice, 251static void key_on(struct Spc_Dsp* const this, struct voice_t* const voice,
253 struct src_dir const* const sd, 252 struct src_dir const* const sd,
254 struct raw_voice_t const* const raw_voice, 253 struct raw_voice_t const* const raw_voice,
@@ -385,7 +384,7 @@ void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf )
385 384
386 /* each rate divides exactly into 0x7800 without remainder */ 385 /* each rate divides exactly into 0x7800 without remainder */
387 int const env_rate_init = 0x7800; 386 int const env_rate_init = 0x7800;
388 static unsigned short const env_rates [0x20] ICONST_ATTR = 387 static unsigned short const env_rates [0x20] ICONST_ATTR_SPC =
389 { 388 {
390 0x0000, 0x000F, 0x0014, 0x0018, 0x001E, 0x0028, 0x0030, 0x003C, 389 0x0000, 0x000F, 0x0014, 0x0018, 0x001E, 0x0028, 0x0030, 0x003C,
391 0x0050, 0x0060, 0x0078, 0x00A0, 0x00C0, 0x00F0, 0x0140, 0x0180, 390 0x0050, 0x0060, 0x0078, 0x00A0, 0x00C0, 0x00F0, 0x0140, 0x0180,
@@ -767,7 +766,7 @@ void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf )
767 #if !SPC_NOINTERP 766 #if !SPC_NOINTERP
768 /* Interleved gauss table (to improve cache coherency). */ 767 /* Interleved gauss table (to improve cache coherency). */
769 /* gauss [i * 2 + j] = normal_gauss [(1 - j) * 256 + i] */ 768 /* gauss [i * 2 + j] = normal_gauss [(1 - j) * 256 + i] */
770 static short const gauss [512] = 769 static short const gauss [512] ICONST_ATTR_SPC =
771 { 770 {
772370,1305, 366,1305, 362,1304, 358,1304, 354,1304, 351,1304, 347,1304, 343,1303, 771370,1305, 366,1305, 362,1304, 358,1304, 354,1304, 351,1304, 347,1304, 343,1303,
773339,1303, 336,1303, 332,1302, 328,1302, 325,1301, 321,1300, 318,1300, 314,1299, 772339,1303, 336,1303, 332,1302, 328,1302, 325,1301, 321,1300, 318,1300, 314,1299,
diff --git a/apps/codecs/libspc/spc_emu.c b/apps/codecs/libspc/spc_emu.c
index 1bebc86d9a..0ad1329a6b 100644
--- a/apps/codecs/libspc/spc_emu.c
+++ b/apps/codecs/libspc/spc_emu.c
@@ -28,7 +28,7 @@
28/* DSP Based on Brad Martin's OpenSPC DSP emulator */ 28/* DSP Based on Brad Martin's OpenSPC DSP emulator */
29/* tag reading from sexyspc by John Brawn (John_Brawn@yahoo.com) and others */ 29/* tag reading from sexyspc by John Brawn (John_Brawn@yahoo.com) and others */
30 30
31struct cpu_ram_t ram CACHEALIGN_ATTR; 31struct cpu_ram_t ram IBSS_ATTR_SPC_LARGE_IRAM CACHEALIGN_ATTR;
32 32
33/**************** Timers ****************/ 33/**************** Timers ****************/
34 34
diff --git a/apps/codecs/spc.c b/apps/codecs/spc.c
index 1b49761810..80c28abbc1 100644
--- a/apps/codecs/spc.c
+++ b/apps/codecs/spc.c
@@ -190,7 +190,7 @@ static int LoadID666(unsigned char *buf) {
190 190
191/**************** Codec ****************/ 191/**************** Codec ****************/
192enum {SAMPLE_RATE = 32000}; 192enum {SAMPLE_RATE = 32000};
193static struct Spc_Emu spc_emu IDATA_ATTR CACHEALIGN_ATTR; 193static struct Spc_Emu spc_emu IBSS_ATTR_SPC CACHEALIGN_ATTR;
194 194
195#if SPC_DUAL_CORE 195#if SPC_DUAL_CORE
196/** Implementations for pipelined dual-core operation **/ 196/** Implementations for pipelined dual-core operation **/