forked from len0rd/rockbox
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
This commit is contained in:
parent
dbe5e5f2df
commit
88aeef9127
4 changed files with 67 additions and 14 deletions
|
@ -40,8 +40,7 @@
|
||||||
#define MIX_FRAME_SAMPLES 256
|
#define MIX_FRAME_SAMPLES 256
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* IAUDIO_M5 is very tight on IRAM */
|
#if defined(CPU_COLDFIRE) || defined(CPU_PP)
|
||||||
#if (defined(CPU_COLDFIRE) && !defined(IAUDIO_M5)) || defined(CPU_PP)
|
|
||||||
/* For Coldfire, it's just faster
|
/* For Coldfire, it's just faster
|
||||||
For PortalPlayer, this also avoids more expensive cache coherency */
|
For PortalPlayer, this also avoids more expensive cache coherency */
|
||||||
#define DOWNMIX_BUF_IBSS IBSS_ATTR
|
#define DOWNMIX_BUF_IBSS IBSS_ATTR
|
||||||
|
|
|
@ -51,6 +51,10 @@
|
||||||
extern void dsp_sample_output_init(struct sample_io_data *this);
|
extern void dsp_sample_output_init(struct sample_io_data *this);
|
||||||
extern void dsp_sample_output_flush(struct sample_io_data *this);
|
extern void dsp_sample_output_flush(struct sample_io_data *this);
|
||||||
|
|
||||||
|
#define SAMPLE_BUF_COUNT 128 /* Per channel, per DSP */
|
||||||
|
/* CODEC_IDX_AUDIO = left and right, CODEC_IDX_VOICE = mono */
|
||||||
|
static int32_t sample_bufs[3][SAMPLE_BUF_COUNT] IBSS_ATTR;
|
||||||
|
|
||||||
/* convert count 16-bit mono to 32-bit mono */
|
/* convert count 16-bit mono to 32-bit mono */
|
||||||
static void sample_input_mono16(struct sample_io_data *this,
|
static void sample_input_mono16(struct sample_io_data *this,
|
||||||
struct dsp_buffer **buf_p)
|
struct dsp_buffer **buf_p)
|
||||||
|
@ -269,8 +273,31 @@ static void dsp_sample_input_format_change(struct sample_io_data *this,
|
||||||
format_change_ack(&src->format);
|
format_change_ack(&src->format);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dsp_sample_input_init(struct sample_io_data *this)
|
static void dsp_sample_input_init(struct sample_io_data *this,
|
||||||
|
enum dsp_ids dsp_id)
|
||||||
{
|
{
|
||||||
|
int32_t *lbuf, *rbuf;
|
||||||
|
|
||||||
|
switch (dsp_id)
|
||||||
|
{
|
||||||
|
case CODEC_IDX_AUDIO:
|
||||||
|
lbuf = sample_bufs[0];
|
||||||
|
rbuf = sample_bufs[1];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CODEC_IDX_VOICE:
|
||||||
|
lbuf = rbuf = sample_bufs[2]; /* Always mono */
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* orly */
|
||||||
|
DEBUGF("DSP Input- unknown dsp %d\n", (int)dsp_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->sample_buf_arr[0] = lbuf;
|
||||||
|
this->sample_buf_arr[1] = rbuf;
|
||||||
|
|
||||||
this->input_samples[0] = sample_input_ni_stereo32;
|
this->input_samples[0] = sample_input_ni_stereo32;
|
||||||
this->input_samples[1] = dsp_sample_input_format_change;
|
this->input_samples[1] = dsp_sample_input_format_change;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +315,7 @@ void dsp_sample_io_configure(struct sample_io_data *this,
|
||||||
switch (setting)
|
switch (setting)
|
||||||
{
|
{
|
||||||
case DSP_INIT:
|
case DSP_INIT:
|
||||||
dsp_sample_input_init(this);
|
dsp_sample_input_init(this, (enum dsp_ids)value);
|
||||||
dsp_sample_output_init(this);
|
dsp_sample_output_init(this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
#define WORD_FRACBITS 27
|
#define WORD_FRACBITS 27
|
||||||
#define NATIVE_DEPTH 16
|
#define NATIVE_DEPTH 16
|
||||||
|
|
||||||
#define SAMPLE_BUF_COUNT 128 /* Per channel, per DSP */
|
|
||||||
|
|
||||||
struct sample_io_data;
|
struct sample_io_data;
|
||||||
|
|
||||||
/* DSP initial buffer input function call prototype */
|
/* DSP initial buffer input function call prototype */
|
||||||
|
@ -50,7 +48,7 @@ struct sample_io_data
|
||||||
int stereo_mode; /* Codec-specified input format */
|
int stereo_mode; /* Codec-specified input format */
|
||||||
sample_input_fn_type input_samples[2]; /* input functions */
|
sample_input_fn_type input_samples[2]; /* input functions */
|
||||||
struct dsp_buffer sample_buf; /* Buffer descriptor for converted samples */
|
struct dsp_buffer sample_buf; /* Buffer descriptor for converted samples */
|
||||||
int32_t sample_buf_arr[2][SAMPLE_BUF_COUNT]; /* Internal format */
|
int32_t *sample_buf_arr[2]; /* Internal format buffer pointers */
|
||||||
sample_output_fn_type output_samples[2]; /* Final output functions */
|
sample_output_fn_type output_samples[2]; /* Final output functions */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,9 @@
|
||||||
|
|
||||||
#define RESAMPLE_BUF_COUNT 192 /* Per channel, per DSP */
|
#define RESAMPLE_BUF_COUNT 192 /* Per channel, per DSP */
|
||||||
|
|
||||||
|
/* CODEC_IDX_AUDIO = left and right, CODEC_IDX_VOICE = mono */
|
||||||
|
static int32_t resample_out_bufs[3][RESAMPLE_BUF_COUNT] IBSS_ATTR;
|
||||||
|
|
||||||
/* Data for each resampler on each DSP */
|
/* Data for each resampler on each DSP */
|
||||||
static struct resample_data
|
static struct resample_data
|
||||||
{
|
{
|
||||||
|
@ -50,7 +53,7 @@ static struct resample_data
|
||||||
/* 14h */
|
/* 14h */
|
||||||
struct dsp_config *dsp; /* The DSP for this resampler */
|
struct dsp_config *dsp; /* The DSP for this resampler */
|
||||||
struct dsp_buffer resample_buf; /* Buffer descriptor for resampled data */
|
struct dsp_buffer resample_buf; /* Buffer descriptor for resampled data */
|
||||||
int32_t resample_buf_arr[2][RESAMPLE_BUF_COUNT]; /* Actual output data */
|
int32_t *resample_buf_arr[2]; /* Actual output data pointers */
|
||||||
} resample_data[DSP_COUNT] IBSS_ATTR;
|
} resample_data[DSP_COUNT] IBSS_ATTR;
|
||||||
|
|
||||||
/* Actual worker function. Implemented here or in target assembly code. */
|
/* Actual worker function. Implemented here or in target assembly code. */
|
||||||
|
@ -165,11 +168,9 @@ static void lin_resample_process(struct dsp_proc_entry *this,
|
||||||
if (dst->remcount > 0)
|
if (dst->remcount > 0)
|
||||||
return; /* data still remains */
|
return; /* data still remains */
|
||||||
|
|
||||||
int channels = src->format.num_channels;
|
|
||||||
|
|
||||||
dst->remcount = 0;
|
dst->remcount = 0;
|
||||||
dst->p32[0] = data->resample_buf_arr[0];
|
dst->p32[0] = data->resample_buf_arr[0];
|
||||||
dst->p32[1] = data->resample_buf_arr[channels - 1];
|
dst->p32[1] = data->resample_buf_arr[1];
|
||||||
|
|
||||||
if (src->remcount > 0)
|
if (src->remcount > 0)
|
||||||
{
|
{
|
||||||
|
@ -238,6 +239,36 @@ static void lin_resample_new_format(struct dsp_proc_entry *this,
|
||||||
dsp_proc_call(this, buf_p, 0);
|
dsp_proc_call(this, buf_p, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void lin_resample_init(struct dsp_config *dsp,
|
||||||
|
enum dsp_ids dsp_id)
|
||||||
|
{
|
||||||
|
/* Always enable resampler so that format changes may be monitored and
|
||||||
|
* it self-activated when required */
|
||||||
|
dsp_proc_enable(dsp, DSP_PROC_RESAMPLE, true);
|
||||||
|
|
||||||
|
int32_t *lbuf, *rbuf;
|
||||||
|
|
||||||
|
switch (dsp_id)
|
||||||
|
{
|
||||||
|
case CODEC_IDX_AUDIO:
|
||||||
|
lbuf = resample_out_bufs[0];
|
||||||
|
rbuf = resample_out_bufs[1];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CODEC_IDX_VOICE:
|
||||||
|
lbuf = rbuf = resample_out_bufs[2]; /* Always mono */
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* huh? */
|
||||||
|
DEBUGF("DSP_PROC_RESAMPLE- unknown DSP %d\n", (int)dsp_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
resample_data[dsp_id].resample_buf_arr[0] = lbuf;
|
||||||
|
resample_data[dsp_id].resample_buf_arr[1] = rbuf;
|
||||||
|
}
|
||||||
|
|
||||||
/* DSP message hook */
|
/* DSP message hook */
|
||||||
static intptr_t lin_resample_configure(struct dsp_proc_entry *this,
|
static intptr_t lin_resample_configure(struct dsp_proc_entry *this,
|
||||||
struct dsp_config *dsp,
|
struct dsp_config *dsp,
|
||||||
|
@ -247,9 +278,7 @@ static intptr_t lin_resample_configure(struct dsp_proc_entry *this,
|
||||||
switch (setting)
|
switch (setting)
|
||||||
{
|
{
|
||||||
case DSP_INIT:
|
case DSP_INIT:
|
||||||
/* Always enable resampler so that format changes may be monitored and
|
lin_resample_init(dsp, (enum dsp_ids)value);
|
||||||
* it self-activated when required */
|
|
||||||
dsp_proc_enable(dsp, DSP_PROC_RESAMPLE, true);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DSP_FLUSH:
|
case DSP_FLUSH:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue