summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2012-05-04 22:00:44 -0400
committerMichael Sevakis <jethead71@rockbox.org>2012-05-04 22:00:44 -0400
commit88aeef91275dd121f2e8663ec79729412aaa2fa2 (patch)
treeb8edc9365cfd8e73744f279724eede910adf53bb
parentdbe5e5f2df24a0dbe650561c0b42ce982346534c (diff)
downloadrockbox-88aeef91275dd121f2e8663ec79729412aaa2fa2.tar.gz
rockbox-88aeef91275dd121f2e8663ec79729412aaa2fa2.zip
Remove pointless IRAM allocation from voice DSP.
It's always used in MONO mode and doesn't need the IRAM sample/ resample buffers and 1280 bytes can be freed. M5 can now have its PCM mixer downmix buffer in IRAM. Change-Id: I0af08be5b212b7dfe382bba588a6585eb328a038
-rw-r--r--firmware/export/pcm_mixer.h3
-rw-r--r--lib/rbcodec/dsp/dsp_sample_input.c31
-rw-r--r--lib/rbcodec/dsp/dsp_sample_io.h4
-rw-r--r--lib/rbcodec/dsp/lin_resample.c43
4 files changed, 67 insertions, 14 deletions
diff --git a/firmware/export/pcm_mixer.h b/firmware/export/pcm_mixer.h
index f6d212d8e0..69d2b894df 100644
--- a/firmware/export/pcm_mixer.h
+++ b/firmware/export/pcm_mixer.h
@@ -40,8 +40,7 @@
40#define MIX_FRAME_SAMPLES 256 40#define MIX_FRAME_SAMPLES 256
41#endif 41#endif
42 42
43/* IAUDIO_M5 is very tight on IRAM */ 43#if defined(CPU_COLDFIRE) || defined(CPU_PP)
44#if (defined(CPU_COLDFIRE) && !defined(IAUDIO_M5)) || defined(CPU_PP)
45/* For Coldfire, it's just faster 44/* For Coldfire, it's just faster
46 For PortalPlayer, this also avoids more expensive cache coherency */ 45 For PortalPlayer, this also avoids more expensive cache coherency */
47#define DOWNMIX_BUF_IBSS IBSS_ATTR 46#define DOWNMIX_BUF_IBSS IBSS_ATTR
diff --git a/lib/rbcodec/dsp/dsp_sample_input.c b/lib/rbcodec/dsp/dsp_sample_input.c
index 97b4ec27ad..df0b01f8c6 100644
--- a/lib/rbcodec/dsp/dsp_sample_input.c
+++ b/lib/rbcodec/dsp/dsp_sample_input.c
@@ -51,6 +51,10 @@
51extern void dsp_sample_output_init(struct sample_io_data *this); 51extern void dsp_sample_output_init(struct sample_io_data *this);
52extern void dsp_sample_output_flush(struct sample_io_data *this); 52extern void dsp_sample_output_flush(struct sample_io_data *this);
53 53
54#define SAMPLE_BUF_COUNT 128 /* Per channel, per DSP */
55/* CODEC_IDX_AUDIO = left and right, CODEC_IDX_VOICE = mono */
56static int32_t sample_bufs[3][SAMPLE_BUF_COUNT] IBSS_ATTR;
57
54/* convert count 16-bit mono to 32-bit mono */ 58/* convert count 16-bit mono to 32-bit mono */
55static void sample_input_mono16(struct sample_io_data *this, 59static void sample_input_mono16(struct sample_io_data *this,
56 struct dsp_buffer **buf_p) 60 struct dsp_buffer **buf_p)
@@ -269,8 +273,31 @@ static void dsp_sample_input_format_change(struct sample_io_data *this,
269 format_change_ack(&src->format); 273 format_change_ack(&src->format);
270} 274}
271 275
272static void dsp_sample_input_init(struct sample_io_data *this) 276static void dsp_sample_input_init(struct sample_io_data *this,
277 enum dsp_ids dsp_id)
273{ 278{
279 int32_t *lbuf, *rbuf;
280
281 switch (dsp_id)
282 {
283 case CODEC_IDX_AUDIO:
284 lbuf = sample_bufs[0];
285 rbuf = sample_bufs[1];
286 break;
287
288 case CODEC_IDX_VOICE:
289 lbuf = rbuf = sample_bufs[2]; /* Always mono */
290 break;
291
292 default:
293 /* orly */
294 DEBUGF("DSP Input- unknown dsp %d\n", (int)dsp_id);
295 return;
296 }
297
298 this->sample_buf_arr[0] = lbuf;
299 this->sample_buf_arr[1] = rbuf;
300
274 this->input_samples[0] = sample_input_ni_stereo32; 301 this->input_samples[0] = sample_input_ni_stereo32;
275 this->input_samples[1] = dsp_sample_input_format_change; 302 this->input_samples[1] = dsp_sample_input_format_change;
276} 303}
@@ -288,7 +315,7 @@ void dsp_sample_io_configure(struct sample_io_data *this,
288 switch (setting) 315 switch (setting)
289 { 316 {
290 case DSP_INIT: 317 case DSP_INIT:
291 dsp_sample_input_init(this); 318 dsp_sample_input_init(this, (enum dsp_ids)value);
292 dsp_sample_output_init(this); 319 dsp_sample_output_init(this);
293 break; 320 break;
294 321
diff --git a/lib/rbcodec/dsp/dsp_sample_io.h b/lib/rbcodec/dsp/dsp_sample_io.h
index 443038919d..0afe75c6ca 100644
--- a/lib/rbcodec/dsp/dsp_sample_io.h
+++ b/lib/rbcodec/dsp/dsp_sample_io.h
@@ -28,8 +28,6 @@
28#define WORD_FRACBITS 27 28#define WORD_FRACBITS 27
29#define NATIVE_DEPTH 16 29#define NATIVE_DEPTH 16
30 30
31#define SAMPLE_BUF_COUNT 128 /* Per channel, per DSP */
32
33struct sample_io_data; 31struct sample_io_data;
34 32
35/* DSP initial buffer input function call prototype */ 33/* DSP initial buffer input function call prototype */
@@ -50,7 +48,7 @@ struct sample_io_data
50 int stereo_mode; /* Codec-specified input format */ 48 int stereo_mode; /* Codec-specified input format */
51 sample_input_fn_type input_samples[2]; /* input functions */ 49 sample_input_fn_type input_samples[2]; /* input functions */
52 struct dsp_buffer sample_buf; /* Buffer descriptor for converted samples */ 50 struct dsp_buffer sample_buf; /* Buffer descriptor for converted samples */
53 int32_t sample_buf_arr[2][SAMPLE_BUF_COUNT]; /* Internal format */ 51 int32_t *sample_buf_arr[2]; /* Internal format buffer pointers */
54 sample_output_fn_type output_samples[2]; /* Final output functions */ 52 sample_output_fn_type output_samples[2]; /* Final output functions */
55}; 53};
56 54
diff --git a/lib/rbcodec/dsp/lin_resample.c b/lib/rbcodec/dsp/lin_resample.c
index b3855ec768..5a6f55ac48 100644
--- a/lib/rbcodec/dsp/lin_resample.c
+++ b/lib/rbcodec/dsp/lin_resample.c
@@ -40,6 +40,9 @@
40 40
41#define RESAMPLE_BUF_COUNT 192 /* Per channel, per DSP */ 41#define RESAMPLE_BUF_COUNT 192 /* Per channel, per DSP */
42 42
43/* CODEC_IDX_AUDIO = left and right, CODEC_IDX_VOICE = mono */
44static int32_t resample_out_bufs[3][RESAMPLE_BUF_COUNT] IBSS_ATTR;
45
43/* Data for each resampler on each DSP */ 46/* Data for each resampler on each DSP */
44static struct resample_data 47static struct resample_data
45{ 48{
@@ -50,7 +53,7 @@ static struct resample_data
50 /* 14h */ 53 /* 14h */
51 struct dsp_config *dsp; /* The DSP for this resampler */ 54 struct dsp_config *dsp; /* The DSP for this resampler */
52 struct dsp_buffer resample_buf; /* Buffer descriptor for resampled data */ 55 struct dsp_buffer resample_buf; /* Buffer descriptor for resampled data */
53 int32_t resample_buf_arr[2][RESAMPLE_BUF_COUNT]; /* Actual output data */ 56 int32_t *resample_buf_arr[2]; /* Actual output data pointers */
54} resample_data[DSP_COUNT] IBSS_ATTR; 57} resample_data[DSP_COUNT] IBSS_ATTR;
55 58
56/* Actual worker function. Implemented here or in target assembly code. */ 59/* Actual worker function. Implemented here or in target assembly code. */
@@ -165,11 +168,9 @@ static void lin_resample_process(struct dsp_proc_entry *this,
165 if (dst->remcount > 0) 168 if (dst->remcount > 0)
166 return; /* data still remains */ 169 return; /* data still remains */
167 170
168 int channels = src->format.num_channels;
169
170 dst->remcount = 0; 171 dst->remcount = 0;
171 dst->p32[0] = data->resample_buf_arr[0]; 172 dst->p32[0] = data->resample_buf_arr[0];
172 dst->p32[1] = data->resample_buf_arr[channels - 1]; 173 dst->p32[1] = data->resample_buf_arr[1];
173 174
174 if (src->remcount > 0) 175 if (src->remcount > 0)
175 { 176 {
@@ -238,6 +239,36 @@ static void lin_resample_new_format(struct dsp_proc_entry *this,
238 dsp_proc_call(this, buf_p, 0); 239 dsp_proc_call(this, buf_p, 0);
239} 240}
240 241
242static void lin_resample_init(struct dsp_config *dsp,
243 enum dsp_ids dsp_id)
244{
245 /* Always enable resampler so that format changes may be monitored and
246 * it self-activated when required */
247 dsp_proc_enable(dsp, DSP_PROC_RESAMPLE, true);
248
249 int32_t *lbuf, *rbuf;
250
251 switch (dsp_id)
252 {
253 case CODEC_IDX_AUDIO:
254 lbuf = resample_out_bufs[0];
255 rbuf = resample_out_bufs[1];
256 break;
257
258 case CODEC_IDX_VOICE:
259 lbuf = rbuf = resample_out_bufs[2]; /* Always mono */
260 break;
261
262 default:
263 /* huh? */
264 DEBUGF("DSP_PROC_RESAMPLE- unknown DSP %d\n", (int)dsp_id);
265 return;
266 }
267
268 resample_data[dsp_id].resample_buf_arr[0] = lbuf;
269 resample_data[dsp_id].resample_buf_arr[1] = rbuf;
270}
271
241/* DSP message hook */ 272/* DSP message hook */
242static intptr_t lin_resample_configure(struct dsp_proc_entry *this, 273static intptr_t lin_resample_configure(struct dsp_proc_entry *this,
243 struct dsp_config *dsp, 274 struct dsp_config *dsp,
@@ -247,9 +278,7 @@ static intptr_t lin_resample_configure(struct dsp_proc_entry *this,
247 switch (setting) 278 switch (setting)
248 { 279 {
249 case DSP_INIT: 280 case DSP_INIT:
250 /* Always enable resampler so that format changes may be monitored and 281 lin_resample_init(dsp, (enum dsp_ids)value);
251 * it self-activated when required */
252 dsp_proc_enable(dsp, DSP_PROC_RESAMPLE, true);
253 break; 282 break;
254 283
255 case DSP_FLUSH: 284 case DSP_FLUSH: