Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+67 -14
+1 -2
firmware/export/pcm_mixer.h
··· 40 40 #define MIX_FRAME_SAMPLES 256 41 41 #endif 42 42 43 - /* IAUDIO_M5 is very tight on IRAM */ 44 - #if (defined(CPU_COLDFIRE) && !defined(IAUDIO_M5)) || defined(CPU_PP) 43 + #if defined(CPU_COLDFIRE) || defined(CPU_PP) 45 44 /* For Coldfire, it's just faster 46 45 For PortalPlayer, this also avoids more expensive cache coherency */ 47 46 #define DOWNMIX_BUF_IBSS IBSS_ATTR
+29 -2
lib/rbcodec/dsp/dsp_sample_input.c
··· 51 51 extern void dsp_sample_output_init(struct sample_io_data *this); 52 52 extern 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 */ 56 + static int32_t sample_bufs[3][SAMPLE_BUF_COUNT] IBSS_ATTR; 57 + 54 58 /* convert count 16-bit mono to 32-bit mono */ 55 59 static void sample_input_mono16(struct sample_io_data *this, 56 60 struct dsp_buffer **buf_p) ··· 269 273 format_change_ack(&src->format); 270 274 } 271 275 272 - static void dsp_sample_input_init(struct sample_io_data *this) 276 + static 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 301 this->input_samples[0] = sample_input_ni_stereo32; 275 302 this->input_samples[1] = dsp_sample_input_format_change; 276 303 } ··· 288 315 switch (setting) 289 316 { 290 317 case DSP_INIT: 291 - dsp_sample_input_init(this); 318 + dsp_sample_input_init(this, (enum dsp_ids)value); 292 319 dsp_sample_output_init(this); 293 320 break; 294 321
+1 -3
lib/rbcodec/dsp/dsp_sample_io.h
··· 28 28 #define WORD_FRACBITS 27 29 29 #define NATIVE_DEPTH 16 30 30 31 - #define SAMPLE_BUF_COUNT 128 /* Per channel, per DSP */ 32 - 33 31 struct sample_io_data; 34 32 35 33 /* DSP initial buffer input function call prototype */ ··· 50 48 int stereo_mode; /* Codec-specified input format */ 51 49 sample_input_fn_type input_samples[2]; /* input functions */ 52 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 52 sample_output_fn_type output_samples[2]; /* Final output functions */ 55 53 }; 56 54
+36 -7
lib/rbcodec/dsp/lin_resample.c
··· 40 40 41 41 #define RESAMPLE_BUF_COUNT 192 /* Per channel, per DSP */ 42 42 43 + /* CODEC_IDX_AUDIO = left and right, CODEC_IDX_VOICE = mono */ 44 + static int32_t resample_out_bufs[3][RESAMPLE_BUF_COUNT] IBSS_ATTR; 45 + 43 46 /* Data for each resampler on each DSP */ 44 47 static struct resample_data 45 48 { ··· 50 53 /* 14h */ 51 54 struct dsp_config *dsp; /* The DSP for this resampler */ 52 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 57 } resample_data[DSP_COUNT] IBSS_ATTR; 55 58 56 59 /* Actual worker function. Implemented here or in target assembly code. */ ··· 165 168 if (dst->remcount > 0) 166 169 return; /* data still remains */ 167 170 168 - int channels = src->format.num_channels; 169 - 170 171 dst->remcount = 0; 171 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 175 if (src->remcount > 0) 175 176 { ··· 238 239 dsp_proc_call(this, buf_p, 0); 239 240 } 240 241 242 + static 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 272 /* DSP message hook */ 242 273 static intptr_t lin_resample_configure(struct dsp_proc_entry *this, 243 274 struct dsp_config *dsp, ··· 247 278 switch (setting) 248 279 { 249 280 case DSP_INIT: 250 - /* Always enable resampler so that format changes may be monitored and 251 - * it self-activated when required */ 252 - dsp_proc_enable(dsp, DSP_PROC_RESAMPLE, true); 281 + lin_resample_init(dsp, (enum dsp_ids)value); 253 282 break; 254 283 255 284 case DSP_FLUSH: