added toplevel makefile for xpd

This commit is contained in:
dan
2014-01-22 11:00:41 +00:00
parent 7c42307440
commit 98b3bdba95
47 changed files with 2789 additions and 2778 deletions

View File

@@ -1,176 +1,176 @@
//#include "devicedefines.h"
#define MAX_MIX_COUNT 8
#define MIX_INPUTS 18
#define DOMIX_TOP(i) \
.cc_top doMix##i.function,doMix##i; \
.align 4 ;\
.globl doMix##i ;\
.type doMix##i, @function ;\
.globl doMix##i##.nstackwords ;\
.globl doMix##i##.maxthreads ; \
.globl doMix##i##.maxtimers ; \
.globl doMix##i##.maxchanends ; \
.globl doMix##i##.maxsync ;\
.linkset doMix##i##.locnoside, 1; \
.linkset doMix##i##.locnochandec, 1;\
.linkset doMix##i##.nstackwords, 0 ;\
.linkset doMix##i##.maxchanends, 0 ;\
.linkset doMix##i##.maxtimers, 0 ;\
.linkset doMix##i##.maxthreads, 1; \
doMix##i##: ;\
set cp, r0; \
set dp, r1; \
lsub r0, r1, r0, r0, r0;\
.label_##i##:
#define DOMIX_BOT(i) \
ldap r11, _dp; \
set dp, r11;\
ldap r11, _cp;\
set cp, r11;\
\
mov r0, r1;\
ldc r2, 0x19;\
sext r0, r2;\
eq r0, r0, r1;\
bf r0, .L20; \
\
shl r0, r1, 0x7;\
retsp 0x0;\
\
\
.size doMix##i, .-doMix##i; \
.cc_bottom doMix##i##.function;
#define N MIX_INPUTS
#define BODY(i) \
ldw r2,cp[i]; \
ldw r11, dp[i]; \
maccs r1, r0, r2, r11;
.text
.L20:\
lss r0, r1, r3;\
bt r0, .L16; \
ldw r0, cp[.LC0];\
retsp 0x0; \
.L16:\
ldw r0, cp[.LC1];\
retsp 0x0; \
#if(MAX_MIX_COUNT > 0)
DOMIX_TOP(0)
#include "repeat.h"
DOMIX_BOT(0)
#endif
#if(MAX_MIX_COUNT > 1)
DOMIX_TOP(1)
#include "repeat.h"
DOMIX_BOT(1)
#endif
#if(MAX_MIX_COUNT > 2)
DOMIX_TOP(2)
#include "repeat.h"
DOMIX_BOT(2)
#endif
#if(MAX_MIX_COUNT > 3)
DOMIX_TOP(3)
#include "repeat.h"
DOMIX_BOT(3)
#endif
#if(MAX_MIX_COUNT > 4)
DOMIX_TOP(4)
#include "repeat.h"
DOMIX_BOT(4)
#endif
#if(MAX_MIX_COUNT > 5)
DOMIX_TOP(5)
#include "repeat.h"
DOMIX_BOT(5)
#endif
#if(MAX_MIX_COUNT > 6)
DOMIX_TOP(6)
#include "repeat.h"
DOMIX_BOT(6)
#endif
#if(MAX_MIX_COUNT > 7)
DOMIX_TOP(7)
#include "repeat.h"
DOMIX_BOT(7)
#endif
#if(MAX_MIX_COUNT>8)
#error MAX_MIX_COUNT>7
#endif
/* We need MIX_OUTPUT x setPtr functions */
#undef N
#undef BODY
#define N MAX_MIX_COUNT
.cc_top setPtr.function,setPtr;
.align 4 ;
.globl setPtr;
.type setPtr, @function
.globl setPtr.nstackwords;
.globl setPtr.maxthreads;
.globl setPtr.maxtimers;
.globl setPtr.maxchanends;
.globl setPtr.maxsync;
.linkset setPtr.locnoside, 1;
.linkset setPtr.locnochandec, 1;
.linkset setPtr.nstackwords, 0;
.linkset setPtr.maxchanends, 0;
.linkset setPtr.maxtimers, 0;
.linkset setPtr.maxthreads, 1;
setPtr:
shl r2, r2, 1
.xtabranch .label_0
bru r2
#define BODY(i) \
ldap r11, .label_##i; \
bu setPtr_go
#include "repeat.h"
setPtr_go:
shl r0, r0, 3;
ldc r2, 0x80;
add r1, r1, r2;
st8 r1, r11[r0];
retsp 0;
.size setPtr, .-setPtr
.cc_bottom setPtr.function
.section .cp.const4, "acM", @progbits, 4
.cc_top .LC0.data
.align 4
.LC0:
.int 0x7fffff00
.cc_bottom .LC0.data
.cc_top .LC1.data
.align 4
.LC1:
.int 0x80000000
.cc_bottom .LC1.data
#undef N
#undef BODY
//#include "devicedefines.h"
#define MAX_MIX_COUNT 8
#define MIX_INPUTS 18
#define DOMIX_TOP(i) \
.cc_top doMix##i.function,doMix##i; \
.align 4 ;\
.globl doMix##i ;\
.type doMix##i, @function ;\
.globl doMix##i##.nstackwords ;\
.globl doMix##i##.maxthreads ; \
.globl doMix##i##.maxtimers ; \
.globl doMix##i##.maxchanends ; \
.globl doMix##i##.maxsync ;\
.linkset doMix##i##.locnoside, 1; \
.linkset doMix##i##.locnochandec, 1;\
.linkset doMix##i##.nstackwords, 0 ;\
.linkset doMix##i##.maxchanends, 0 ;\
.linkset doMix##i##.maxtimers, 0 ;\
.linkset doMix##i##.maxthreads, 1; \
doMix##i##: ;\
set cp, r0; \
set dp, r1; \
lsub r0, r1, r0, r0, r0;\
.label_##i##:
#define DOMIX_BOT(i) \
ldap r11, _dp; \
set dp, r11;\
ldap r11, _cp;\
set cp, r11;\
\
mov r0, r1;\
ldc r2, 0x19;\
sext r0, r2;\
eq r0, r0, r1;\
bf r0, .L20; \
\
shl r0, r1, 0x7;\
retsp 0x0;\
\
\
.size doMix##i, .-doMix##i; \
.cc_bottom doMix##i##.function;
#define N MIX_INPUTS
#define BODY(i) \
ldw r2,cp[i]; \
ldw r11, dp[i]; \
maccs r1, r0, r2, r11;
.text
.L20:\
lss r0, r1, r3;\
bt r0, .L16; \
ldw r0, cp[.LC0];\
retsp 0x0; \
.L16:\
ldw r0, cp[.LC1];\
retsp 0x0; \
#if(MAX_MIX_COUNT > 0)
DOMIX_TOP(0)
#include "repeat.h"
DOMIX_BOT(0)
#endif
#if(MAX_MIX_COUNT > 1)
DOMIX_TOP(1)
#include "repeat.h"
DOMIX_BOT(1)
#endif
#if(MAX_MIX_COUNT > 2)
DOMIX_TOP(2)
#include "repeat.h"
DOMIX_BOT(2)
#endif
#if(MAX_MIX_COUNT > 3)
DOMIX_TOP(3)
#include "repeat.h"
DOMIX_BOT(3)
#endif
#if(MAX_MIX_COUNT > 4)
DOMIX_TOP(4)
#include "repeat.h"
DOMIX_BOT(4)
#endif
#if(MAX_MIX_COUNT > 5)
DOMIX_TOP(5)
#include "repeat.h"
DOMIX_BOT(5)
#endif
#if(MAX_MIX_COUNT > 6)
DOMIX_TOP(6)
#include "repeat.h"
DOMIX_BOT(6)
#endif
#if(MAX_MIX_COUNT > 7)
DOMIX_TOP(7)
#include "repeat.h"
DOMIX_BOT(7)
#endif
#if(MAX_MIX_COUNT>8)
#error MAX_MIX_COUNT>7
#endif
/* We need MIX_OUTPUT x setPtr functions */
#undef N
#undef BODY
#define N MAX_MIX_COUNT
.cc_top setPtr.function,setPtr;
.align 4 ;
.globl setPtr;
.type setPtr, @function
.globl setPtr.nstackwords;
.globl setPtr.maxthreads;
.globl setPtr.maxtimers;
.globl setPtr.maxchanends;
.globl setPtr.maxsync;
.linkset setPtr.locnoside, 1;
.linkset setPtr.locnochandec, 1;
.linkset setPtr.nstackwords, 0;
.linkset setPtr.maxchanends, 0;
.linkset setPtr.maxtimers, 0;
.linkset setPtr.maxthreads, 1;
setPtr:
shl r2, r2, 1
.xtabranch .label_0
bru r2
#define BODY(i) \
ldap r11, .label_##i; \
bu setPtr_go
#include "repeat.h"
setPtr_go:
shl r0, r0, 3;
ldc r2, 0x80;
add r1, r1, r2;
st8 r1, r11[r0];
retsp 0;
.size setPtr, .-setPtr
.cc_bottom setPtr.function
.section .cp.const4, "acM", @progbits, 4
.cc_top .LC0.data
.align 4
.LC0:
.int 0x7fffff00
.cc_bottom .LC0.data
.cc_top .LC1.data
.align 4
.LC1:
.int 0x80000000
.cc_bottom .LC1.data
#undef N
#undef BODY

View File

@@ -18,14 +18,14 @@ enum mix_ctl_cmd {
*
* This thread mixes audio streams between the decouple() thread and
* the audio() thread.
*
*
* \param c_to_host a chanend connected to the decouple() thread for
* receiving/transmitting samples
* \param c_to_audio a chanend connected to the audio() thread for
* receiving/transmitting samples
* \param c_mix_ctl a chanend connected to the Endpoint0() thread for
* receiving control commands
*
* receiving control commands
*
*/
void mixer(chanend c_to_host, chanend c_to_audio, chanend c_mix_ctl);

View File

@@ -19,7 +19,7 @@ unsigned int multIn_array[NUM_USB_CHAN_IN + 1];
static xc_ptr multIn;
#endif
#if defined (LEVEL_METER_LEDS) || defined (LEVEL_METER_HOST)
#if defined (LEVEL_METER_LEDS) || defined (LEVEL_METER_HOST)
static unsigned abs(int x)
{
#if 0
@@ -49,7 +49,7 @@ int mix_mult_array[MAX_MIX_COUNT][MIX_INPUTS];
xc_ptr mix_mult;
#define write_word_to_mix_mult(x,y,val) write_via_xc_ptr_indexed(mix_mult,((x)*MIX_INPUTS)+(y), val)
#define mix_mult_slice(x) (mix_mult + x * MIX_INPUTS * sizeof(int))
#ifndef FAST_MIXER
#ifndef FAST_MIXER
int mix_map_array[MAX_MIX_COUNT][MIX_INPUTS];
xc_ptr mix_map;
#define write_word_to_mix_map(x,y,val) write_via_xc_ptr_indexed(mix_map,((x)*MIX_INPUTS)+(y), val)
@@ -77,7 +77,7 @@ static int samples_to_host_outputs[NUM_USB_CHAN_OUT]; /* Device outputs */
#pragma xta command "set required - 10400 ns" /* 96kHz */
#endif
#if defined (LEVEL_METER_LEDS) || defined (LEVEL_METER_HOST)
#if defined (LEVEL_METER_LEDS) || defined (LEVEL_METER_HOST)
static inline void ComputeMixerLevel(int sample, int i)
{
int x;
@@ -88,8 +88,8 @@ static inline void ComputeMixerLevel(int sample, int i)
x = abs(sample);
/* y = samples_to_host_outputs[i] */
asm("ldaw %0, dp[samples_to_host_outputs]":"=r"(ptr):); /* Might want to hoist this */
asm("ldw %0, %1[%2]":"=r"(y):"r"(ptr),"r"(i));
asm("ldaw %0, dp[samples_to_host_outputs]":"=r"(ptr):); /* Might want to hoist this */
asm("ldw %0, %1[%2]":"=r"(y):"r"(ptr),"r"(i));
if(x > y)
{
@@ -116,12 +116,12 @@ int doMix8(xc_ptr samples, xc_ptr mult);
#pragma unsafe arrays
static int doMix(xc_ptr samples, xc_ptr ptr, xc_ptr mult)
{
int h=0;
int l=0;
int h=0;
int l=0;
/* By breaking up the loop we keep things in the encoding for ldw (0-11) */
#pragma loop unroll
for (int i=0; i<MIX_INPUTS; i++)
for (int i=0; i<MIX_INPUTS; i++)
{
int sample;
int index;
@@ -131,7 +131,7 @@ static int doMix(xc_ptr samples, xc_ptr ptr, xc_ptr mult)
read_via_xc_ptr_indexed(m, mult, i);
{h,l} = macs(sample, m, h, l);
}
#if 1
/* Perform saturation */
l = sext(h, 25);
@@ -139,7 +139,7 @@ static int doMix(xc_ptr samples, xc_ptr ptr, xc_ptr mult)
if(l != h)
{
//if(h < 0)
if(h>>32)
if(h>>32)
h = (0x80000000>>7);
else
h = (0x7fffff00>>7);
@@ -159,7 +159,7 @@ static void giveSamplesToHost(chanend c, xc_ptr samples, xc_ptr ptr, xc_ptr mult
#endif
#pragma loop unroll
for (int i=0;i<NUM_USB_CHAN_IN;i++)
for (int i=0;i<NUM_USB_CHAN_IN;i++)
{
int sample;
int index;
@@ -171,9 +171,9 @@ static void giveSamplesToHost(chanend c, xc_ptr samples, xc_ptr ptr, xc_ptr mult
//asm("ldw %0, %1[%2]":"=r"(mult):"r"(multIn),"r"(i));
read_via_xc_ptr_indexed(mult, multIn, i);
{h, l} = macs(mult, sample, 0, 0);
//h <<= 3 done on other side */
outuint(c, h);
#else
outuint(c,sample);
@@ -196,7 +196,7 @@ static void getSamplesFromHost(chanend c, xc_ptr samples, int base, unsigned und
int h;
unsigned l;
#endif
/* Receive sample from decouple */
/* Receive sample from decouple */
sample = inuint(c);
#if defined (LEVEL_METER_HOST) || defined(LEVEL_METER_LEDS)
@@ -229,7 +229,7 @@ static void giveSamplesToDevice(chanend c, xc_ptr samples, xc_ptr ptr, xc_ptr mu
if(!underflow)
{
#pragma loop unroll
for (int i=0;i<NUM_USB_CHAN_OUT;i++)
for (int i=0;i<NUM_USB_CHAN_OUT;i++)
{
int sample,x;
#if defined(OUT_VOLUME_IN_MIXER) && defined(OUT_VOLUME_AFTER_MIX)
@@ -264,7 +264,7 @@ static void getSamplesFromDevice(chanend c, xc_ptr samples, int base)
#endif
#pragma loop unroll
for (int i=0;i<NUM_USB_CHAN_IN;i++)
for (int i=0;i<NUM_USB_CHAN_IN;i++)
{
int sample;
int x;
@@ -296,7 +296,7 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
int mixed;
unsigned cmd;
while (1)
while (1)
{
#pragma xta endpoint "mixer1_req"
/* Request from audio() */
@@ -304,14 +304,14 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
/* Request data from decouple thread */
outuint(c_host, 0);
/* Between request to decouple and respose ~ 400nS latency for interrupt to fire */
select
/* Between request to decouple and respose ~ 400nS latency for interrupt to fire */
select
{
case inuint_byref(c_mix_ctl, cmd):
{
int mix, index, val;
switch (cmd)
switch (cmd)
{
#if MAX_MIX_COUNT > 0
case SET_SAMPLES_TO_HOST_MAP:
@@ -331,7 +331,7 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
inct(c_mix_ctl);
write_via_xc_ptr_indexed(samples_to_device_map,index,val);
break;
case SET_MIX_MULT:
mix = inuint(c_mix_ctl);
index = inuint(c_mix_ctl);
@@ -340,7 +340,7 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
write_word_to_mix_mult(mix, index, val);
break;
case SET_MIX_MAP:
mix = inuint(c_mix_ctl);
index = inuint(c_mix_ctl); /* mixer input */
@@ -381,12 +381,12 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
outct(c_mix_ctl, XS1_CT_END);
samples_to_host_streams[index] = 0;
break;
case GET_INPUT_LEVELS:
index = inuint(c_mix_ctl);
chkct(c_mix_ctl, XS1_CT_END);
#ifdef LEVEL_METER_LEDS
/* Level LEDS process reseting samples_to_host_inputs
#ifdef LEVEL_METER_LEDS
/* Level LEDS process reseting samples_to_host_inputs
* Other side makes sure we don't miss a peak */
read_via_xc_ptr_indexed(val, samples_to_host_inputs_buff, index);
write_via_xc_ptr_indexed(samples_to_host_inputs_buff, index, 0);
@@ -399,7 +399,7 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
outct(c_mix_ctl, XS1_CT_END);
break;
#if MAX_MIX_COUNT > 0
#if MAX_MIX_COUNT > 0
case GET_OUTPUT_LEVELS:
index = inuint(c_mix_ctl);
chkct(c_mix_ctl, XS1_CT_END);
@@ -428,8 +428,8 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
mixer1_mix2_flag = sampFreq > 96000;
#pragma loop unroll
for (int i=0;i<MAX_MIX_COUNT;i++)
#pragma loop unroll
for (int i=0;i<MAX_MIX_COUNT;i++)
{
write_via_xc_ptr_indexed(samples, (NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + i), 0);
}
@@ -442,7 +442,7 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
chkct(c_mixer2, XS1_CT_END);
outct(c_host, XS1_CT_END);
}
else
else
{
unsigned underflow = inuint(c_host);
#if MAX_MIX_COUNT > 0
@@ -465,9 +465,9 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
ComputeMixerLevel(mixed, 0);
#endif
#if (MAX_FREQ > 96000)
#if (MAX_FREQ > 96000)
if (!mixer1_mix2_flag)
#endif
#endif
{
#if MAX_MIX_COUNT > 2
@@ -522,7 +522,7 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
static int mixer2_mix2_flag = (DEFAULT_FREQ > 96000);
#if (MAX_MIX_COUNT > 0)
#if (MAX_MIX_COUNT > 0)
#pragma unsafe arrays
static void mixer2(chanend c_mixer1, chanend c_audio)
{
@@ -532,7 +532,7 @@ static void mixer2(chanend c_mixer1, chanend c_audio)
outuint(c_mixer1, 0);
#pragma xta endpoint "mixer2_req"
inuint(c_audio);
if(testct(c_mixer1))
if(testct(c_mixer1))
{
int sampFreq;
#pragma xta endpoint "mixer2_rate_change"
@@ -541,8 +541,8 @@ static void mixer2(chanend c_mixer1, chanend c_audio)
mixer2_mix2_flag = sampFreq > 96000;
for (int i=0;i<MAX_MIX_COUNT;i++)
for (int i=0;i<MAX_MIX_COUNT;i++)
{
write_via_xc_ptr_indexed(samples, (NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + i), 0);
}
@@ -569,7 +569,7 @@ static void mixer2(chanend c_mixer1, chanend c_audio)
mixed = doMix1(samples, mix_mult_slice(1));
#else
mixed = doMix(samples,mix_map_slice(1),mix_mult_slice(1));
#endif
#endif
write_via_xc_ptr_indexed(samples, (NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + 1), mixed);
@@ -580,8 +580,8 @@ static void mixer2(chanend c_mixer1, chanend c_audio)
#if (MAX_FREQ > 96000)
if (!mixer2_mix2_flag)
#if (MAX_FREQ > 96000)
if (!mixer2_mix2_flag)
#endif
{
#if MAX_MIX_COUNT > 3
@@ -610,7 +610,7 @@ static void mixer2(chanend c_mixer1, chanend c_audio)
ComputeMixerLevel(mixed, 5);
#endif
#endif
#if MAX_MIX_COUNT > 7
#ifdef FAST_MIXER
mixed = doMix7(samples, mix_mult_slice(7));
@@ -649,14 +649,14 @@ void mixer(chanend c_mix_in, chanend c_mix_out, chanend c_mix_ctl)
#endif
#endif
for (int i=0;i<NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + MAX_MIX_COUNT;i++)
for (int i=0;i<NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + MAX_MIX_COUNT;i++)
{
write_via_xc_ptr_indexed(samples,i,0);
}
{
int num_mixes = DEFAULT_FREQ > 96000 ? 2 : MAX_MIX_COUNT;
for (int i=0;i<NUM_USB_CHAN_OUT;i++)
for (int i=0;i<NUM_USB_CHAN_OUT;i++)
{
//samples_to_device_map_array[i] = i;
asm("stw %0, %1[%2]":: "r"(i), "r"(samples_to_device_map), "r"(i));
@@ -664,27 +664,27 @@ void mixer(chanend c_mix_in, chanend c_mix_out, chanend c_mix_ctl)
}
#ifdef OUT_VOLUME_IN_MIXER
for (int i=0;i<NUM_USB_CHAN_OUT;i++)
for (int i=0;i<NUM_USB_CHAN_OUT;i++)
{
write_via_xc_ptr_indexed(multOut, i, MAX_VOL);
}
#endif
#ifdef IN_VOLUME_IN_MIXER
for (int i=0;i<NUM_USB_CHAN_IN;i++)
for (int i=0;i<NUM_USB_CHAN_IN;i++)
{
write_via_xc_ptr_indexed(multIn, i, MAX_VOL);
}
#endif
for (int i=0;i<NUM_USB_CHAN_IN;i++)
for (int i=0;i<NUM_USB_CHAN_IN;i++)
{
write_via_xc_ptr_indexed(samples_to_host_map, i, NUM_USB_CHAN_OUT + i);
}
#if MAX_MIX_COUNT> 0
for (int i=0;i<MAX_MIX_COUNT;i++)
for (int j=0;j<MIX_INPUTS;j++)
for (int j=0;j<MIX_INPUTS;j++)
{
#ifndef FAST_MIXER
write_word_to_mix_map(i,j, j < 16 ? j : j + 2);
@@ -694,9 +694,9 @@ void mixer(chanend c_mix_in, chanend c_mix_out, chanend c_mix_ctl)
#endif
par
par
{
#if (MAX_MIX_COUNT > 0)
#if (MAX_MIX_COUNT > 0)
mixer1(c_mix_in, c_mix_ctl, c);
mixer2(c, c_mix_out);
#else