forked from len0rd/rockbox
Adapted codecs and DSP system to having MACSR saved in thread context.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7485 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4cd06c41f6
commit
735208a541
11 changed files with 44 additions and 30 deletions
|
|
@ -762,6 +762,12 @@ int ov_clear(OggVorbis_File *vf){
|
||||||
|
|
||||||
int ov_open_callbacks(void *f,OggVorbis_File *vf,char *initial,long ibytes,
|
int ov_open_callbacks(void *f,OggVorbis_File *vf,char *initial,long ibytes,
|
||||||
ov_callbacks callbacks){
|
ov_callbacks callbacks){
|
||||||
|
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
||||||
|
/* this seems to be the closest we get to an init function, let's init emac
|
||||||
|
here. rounding is disabled because of MULT31_SHIFT15, which will be
|
||||||
|
inaccurate with rounding in its current incarnation */
|
||||||
|
coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE);
|
||||||
|
#endif
|
||||||
int ret=_ov_open1(f,vf,initial,ibytes,callbacks);
|
int ret=_ov_open1(f,vf,initial,ibytes,callbacks);
|
||||||
if(ret)return ret;
|
if(ret)return ret;
|
||||||
return _ov_open2(vf);
|
return _ov_open2(vf);
|
||||||
|
|
@ -1287,15 +1293,12 @@ int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos){
|
||||||
int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos){
|
int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos){
|
||||||
ogg_packet op={0,0,0,0,0,0};
|
ogg_packet op={0,0,0,0,0,0};
|
||||||
ogg_page og={0,0,0,0};
|
ogg_page og={0,0,0,0};
|
||||||
|
|
||||||
int thisblock,lastblock=0;
|
int thisblock,lastblock=0;
|
||||||
int ret=ov_pcm_seek_page(vf,pos);
|
int ret=ov_pcm_seek_page(vf,pos);
|
||||||
if(ret<0)return(ret);
|
if(ret<0)return(ret);
|
||||||
_make_decode_ready(vf);
|
_make_decode_ready(vf);
|
||||||
|
|
||||||
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
|
||||||
mcf5249_init_mac();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* discard leading packets we don't need for the lapping of the
|
/* discard leading packets we don't need for the lapping of the
|
||||||
position we want; don't decode them */
|
position we want; don't decode them */
|
||||||
|
|
||||||
|
|
@ -1553,10 +1556,6 @@ long ov_read(OggVorbis_File *vf,char *buffer,int bytes_req,int *bitstream){
|
||||||
|
|
||||||
if(vf->ready_state<OPENED)return(OV_EINVAL);
|
if(vf->ready_state<OPENED)return(OV_EINVAL);
|
||||||
|
|
||||||
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
|
||||||
mcf5249_init_mac();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
if(vf->ready_state==INITSET){
|
if(vf->ready_state==INITSET){
|
||||||
samples=vorbis_synthesis_pcmout(&vf->vd,&pcm);
|
samples=vorbis_synthesis_pcmout(&vf->vd,&pcm);
|
||||||
|
|
@ -1622,10 +1621,6 @@ long ov_read_fixed(OggVorbis_File *vf,ogg_int32_t ***pcm_channels,int length,
|
||||||
int *bitstream){
|
int *bitstream){
|
||||||
if(vf->ready_state<OPENED)return(OV_EINVAL);
|
if(vf->ready_state<OPENED)return(OV_EINVAL);
|
||||||
|
|
||||||
#if CONFIG_CPU == MCF5249
|
|
||||||
mcf5249_init_mac();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
if(vf->ready_state==INITSET){
|
if(vf->ready_state==INITSET){
|
||||||
ogg_int32_t **pcm;
|
ogg_int32_t **pcm;
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
/* Global declarations to be used in rockbox software codecs */
|
/* Global declarations to be used in rockbox software codecs */
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "system.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ a52_state_t * a52_init (uint32_t mm_accel)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
||||||
asm volatile ("move.l #0x30, %macsr"); /* frac. mode with rounding */
|
coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_ROUND | EMAC_SATURATE);
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
this needs to come back if we ever want two decoder instances
|
this needs to come back if we ever want two decoder instances
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ III_imdct_s:
|
||||||
* get more low bits out of the accext01 register _before_ doing the
|
* get more low bits out of the accext01 register _before_ doing the
|
||||||
* movclrs.
|
* movclrs.
|
||||||
*/
|
*/
|
||||||
move.l #0xb0, %macsr /* frac mode, saturation, rounding */
|
|
||||||
sub.l %a0, %a0 /* clear loop variable */
|
sub.l %a0, %a0 /* clear loop variable */
|
||||||
.imdctloop: /* outer loop label */
|
.imdctloop: /* outer loop label */
|
||||||
lea.l imdct_s, %a1 /* load pointer to imdct coefs in a1 */
|
lea.l imdct_s, %a1 /* load pointer to imdct coefs in a1 */
|
||||||
|
|
|
||||||
|
|
@ -1775,8 +1775,6 @@ void imdct36(mad_fixed_t const X[18], mad_fixed_t x[36])
|
||||||
mad_fixed_t t[16];
|
mad_fixed_t t[16];
|
||||||
/* assumes FRACBITS = 28 */
|
/* assumes FRACBITS = 28 */
|
||||||
asm volatile (
|
asm volatile (
|
||||||
"move.l #0xb0, %%d0\n\t" /* frac. mode, saturate, round */
|
|
||||||
"move.l %%d0, %%macsr\n\t"
|
|
||||||
"move.l (4*4, %[X]), %%d0\n\t"
|
"move.l (4*4, %[X]), %%d0\n\t"
|
||||||
"move.l #0x0ec835e8, %%d1\n\t"
|
"move.l #0x0ec835e8, %%d1\n\t"
|
||||||
"mac.l %%d0, %%d1, (13*4, %[X]), %%d0, %%acc0\n\t"
|
"mac.l %%d0, %%d1, (13*4, %[X]), %%d0, %%acc0\n\t"
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,11 @@ void mad_synth_init(struct mad_synth *synth)
|
||||||
synth->pcm.samplerate = 0;
|
synth->pcm.samplerate = 0;
|
||||||
synth->pcm.channels = 0;
|
synth->pcm.channels = 0;
|
||||||
synth->pcm.length = 0;
|
synth->pcm.length = 0;
|
||||||
|
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
||||||
|
/* init the emac unit here, since this function should always be called
|
||||||
|
before using libmad */
|
||||||
|
coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE | EMAC_ROUND);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -582,8 +587,6 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
|
||||||
mad_fixed_t const (*Dptr)[32];
|
mad_fixed_t const (*Dptr)[32];
|
||||||
mad_fixed64hi_t hi;
|
mad_fixed64hi_t hi;
|
||||||
|
|
||||||
asm volatile("move.l #0x20, %macsr"); /* fractional mode */
|
|
||||||
|
|
||||||
for (ch = 0; ch < nch; ++ch) {
|
for (ch = 0; ch < nch; ++ch) {
|
||||||
sbsample = &frame->sbsample[ch];
|
sbsample = &frame->sbsample[ch];
|
||||||
filter = &synth->filter[ch];
|
filter = &synth->filter[ch];
|
||||||
|
|
|
||||||
|
|
@ -1173,6 +1173,10 @@ void mpc_decoder_setup(mpc_decoder *d, mpc_reader *r)
|
||||||
mpc_decoder_initialisiere_quantisierungstabellen(d, 1.0f);
|
mpc_decoder_initialisiere_quantisierungstabellen(d, 1.0f);
|
||||||
mpc_decoder_init_huffman_sv6(d);
|
mpc_decoder_init_huffman_sv6(d);
|
||||||
mpc_decoder_init_huffman_sv7(d);
|
mpc_decoder_init_huffman_sv7(d);
|
||||||
|
|
||||||
|
#if defined(CPU_COLDFIRE)&& !defined(SIMULATOR)
|
||||||
|
coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_ROUND | EMAC_SATURATE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si)
|
static void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si)
|
||||||
|
|
|
||||||
|
|
@ -335,9 +335,6 @@ static void Synthese_Filter_float_internal(MPC_SAMPLE_FORMAT * OutData,MPC_SAMPL
|
||||||
{
|
{
|
||||||
mpc_uint32_t n;
|
mpc_uint32_t n;
|
||||||
|
|
||||||
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
|
||||||
asm volatile ("move.l #0x20, %macsr"); /* fractional emac mode */
|
|
||||||
#endif
|
|
||||||
for ( n = 0; n < 36; n++, Y += 32 ) {
|
for ( n = 0; n < 36; n++, Y += 32 ) {
|
||||||
V -= 64;
|
V -= 64;
|
||||||
Calculate_New_V ( Y, V );
|
Calculate_New_V ( Y, V );
|
||||||
|
|
|
||||||
|
|
@ -114,9 +114,6 @@ enum codec_status codec_start(struct codec_api* api)
|
||||||
ci->memset(&Synth, 0, sizeof(struct mad_synth));
|
ci->memset(&Synth, 0, sizeof(struct mad_synth));
|
||||||
ci->memset(&Timer, 0, sizeof(mad_timer_t));
|
ci->memset(&Timer, 0, sizeof(mad_timer_t));
|
||||||
|
|
||||||
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
|
||||||
mcf5249_init_mac();
|
|
||||||
#endif
|
|
||||||
mad_stream_init(&Stream);
|
mad_stream_init(&Stream);
|
||||||
mad_frame_init(&Frame);
|
mad_frame_init(&Frame);
|
||||||
mad_synth_init(&Synth);
|
mad_synth_init(&Synth);
|
||||||
|
|
|
||||||
15
apps/dsp.c
15
apps/dsp.c
|
|
@ -43,7 +43,6 @@
|
||||||
|
|
||||||
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
||||||
|
|
||||||
#define INIT() asm volatile ("move.l #0xb0, %macsr") /* frac, round, clip */
|
|
||||||
/* Multiply two S.31 fractional integers and return the sign bit and the
|
/* Multiply two S.31 fractional integers and return the sign bit and the
|
||||||
* 31 most significant bits of the result.
|
* 31 most significant bits of the result.
|
||||||
*/
|
*/
|
||||||
|
|
@ -89,7 +88,6 @@
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define INIT()
|
|
||||||
#define FRACMUL(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 31))
|
#define FRACMUL(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 31))
|
||||||
#define FRACMUL_8(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 23))
|
#define FRACMUL_8(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 23))
|
||||||
#define FRACMUL_8_LOOP(x, y, s) \
|
#define FRACMUL_8_LOOP(x, y, s) \
|
||||||
|
|
@ -492,11 +490,17 @@ long dsp_process(char* dst, char* src[], long size)
|
||||||
long factor;
|
long factor;
|
||||||
int samples;
|
int samples;
|
||||||
|
|
||||||
|
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
||||||
|
/* set emac unit for dsp processing, and save old macsr, we're running in
|
||||||
|
codec thread context at this point, so can't clobber it */
|
||||||
|
unsigned long old_macsr = coldfire_get_macsr();
|
||||||
|
coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_ROUND | EMAC_SATURATE);
|
||||||
|
#endif
|
||||||
|
|
||||||
dsp = &dsp_conf[current_codec];
|
dsp = &dsp_conf[current_codec];
|
||||||
|
|
||||||
factor = (dsp->stereo_mode != STEREO_MONO) ? 2 : 1;
|
factor = (dsp->stereo_mode != STEREO_MONO) ? 2 : 1;
|
||||||
size /= dsp->sample_bytes * factor;
|
size /= dsp->sample_bytes * factor;
|
||||||
INIT();
|
|
||||||
dsp_set_replaygain(false);
|
dsp_set_replaygain(false);
|
||||||
|
|
||||||
while (size > 0)
|
while (size > 0)
|
||||||
|
|
@ -510,7 +514,10 @@ long dsp_process(char* dst, char* src[], long size)
|
||||||
dst += samples * sizeof(short) * 2;
|
dst += samples * sizeof(short) * 2;
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
|
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
||||||
|
/* set old macsr again */
|
||||||
|
coldfire_set_macsr(old_macsr);
|
||||||
|
#endif
|
||||||
return written * sizeof(short) * 2;
|
return written * sizeof(short) * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,8 +125,21 @@ enum {
|
||||||
: /* %0 */ "d"(mask), \
|
: /* %0 */ "d"(mask), \
|
||||||
/* %1 */ "a"(address))
|
/* %1 */ "a"(address))
|
||||||
|
|
||||||
static inline void mcf5249_init_mac(void) {
|
#define EMAC_ROUND 0x10
|
||||||
asm volatile ("move.l #0x20, %macsr;"); /* frac, truncate, no saturation */
|
#define EMAC_FRACTIONAL 0x20
|
||||||
|
#define EMAC_SATURATE 0x80
|
||||||
|
|
||||||
|
static inline void coldfire_set_macsr(const unsigned long flags)
|
||||||
|
{
|
||||||
|
asm volatile ("move.l %0, %%macsr" : : "r" (flags));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long coldfire_get_macsr(void)
|
||||||
|
{
|
||||||
|
unsigned long m;
|
||||||
|
|
||||||
|
asm volatile ("move.l %%macsr, %0" : "=r" (m));
|
||||||
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue