added toplevel makefile for xpd
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
#define OUT_BUFFER_PREFILL (MAX(NUM_USB_CHAN_OUT_A1*CLASS_ONE_PACKET_SIZE*3+4,NUM_USB_CHAN_OUT*CLASS_TWO_PACKET_SIZE*4+4)*1)
|
||||
#define IN_BUFFER_PREFILL (MAX(CLASS_ONE_PACKET_SIZE*3+4,CLASS_TWO_PACKET_SIZE*4+4)*2)
|
||||
|
||||
/* Volume and mute tables */
|
||||
/* Volume and mute tables */
|
||||
#ifndef OUT_VOLUME_IN_MIXER
|
||||
unsigned int multOut[NUM_USB_CHAN_OUT + 1];
|
||||
static xc_ptr p_multOut;
|
||||
@@ -70,14 +70,14 @@ int speedRem = 0;
|
||||
xc_ptr aud_from_host_fifo_start;
|
||||
xc_ptr aud_from_host_fifo_end;
|
||||
xc_ptr g_aud_from_host_wrptr;
|
||||
xc_ptr g_aud_from_host_rdptr;
|
||||
xc_ptr g_aud_from_host_rdptr;
|
||||
|
||||
xc_ptr aud_to_host_fifo_start;
|
||||
xc_ptr aud_to_host_fifo_end;
|
||||
xc_ptr g_aud_to_host_wrptr;
|
||||
xc_ptr g_aud_to_host_dptr;
|
||||
xc_ptr g_aud_to_host_rdptr;
|
||||
xc_ptr g_aud_to_host_zeros;
|
||||
xc_ptr g_aud_to_host_rdptr;
|
||||
xc_ptr g_aud_to_host_zeros;
|
||||
int sampsToWrite = 0;
|
||||
int totalSampsToWrite = 0;
|
||||
int aud_data_remaining_to_device = 0;
|
||||
@@ -134,16 +134,16 @@ void handle_audio_request(chanend c_mix_out)
|
||||
g_maxPacketSize = MAX_DEVICE_AUD_PACKET_SIZE_CLASS_ONE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* If in overflow condition then receive samples and throw away */
|
||||
if(inOverflow || sampsToWrite == 0)
|
||||
{
|
||||
#pragma loop unroll
|
||||
for(int i = 0; i < NUM_USB_CHAN_IN; i++)
|
||||
for(int i = 0; i < NUM_USB_CHAN_IN; i++)
|
||||
{
|
||||
(void) inuint(c_mix_out);
|
||||
}
|
||||
|
||||
|
||||
/* Calculate how much space left in buffer */
|
||||
space_left = g_aud_to_host_rdptr - g_aud_to_host_wrptr;
|
||||
|
||||
@@ -153,7 +153,7 @@ void handle_audio_request(chanend c_mix_out)
|
||||
}
|
||||
|
||||
/* Check if we can come out of overflow */
|
||||
if (space_left > (BUFF_SIZE_IN*4/2))
|
||||
if (space_left > (BUFF_SIZE_IN*4/2))
|
||||
{
|
||||
inOverflow = 0;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ __builtin_unreachable();
|
||||
#endif
|
||||
unsigned ptr = g_aud_to_host_dptr;
|
||||
|
||||
for(int i = 0; i < g_numUsbChanIn; i++)
|
||||
for(int i = 0; i < g_numUsbChanIn; i++)
|
||||
{
|
||||
/* Receive sample */
|
||||
int sample = inuint(c_mix_out);
|
||||
@@ -188,20 +188,20 @@ __builtin_unreachable();
|
||||
sample = sample << 3;
|
||||
#endif
|
||||
/* Write into fifo */
|
||||
write_via_xc_ptr(ptr, sample);
|
||||
write_via_xc_ptr(ptr, sample);
|
||||
ptr+=4;
|
||||
}
|
||||
|
||||
|
||||
/* Update global pointer */
|
||||
g_aud_to_host_dptr = ptr;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case 3:
|
||||
#if (SAMPLE_SUBSLOT_SIZE_HS != 3) && (SAMPLE_SUBSLOT_SIZE_FS != 3)
|
||||
__builtin_unreachable();
|
||||
#endif
|
||||
for(int i = 0; i < g_numUsbChanIn; i++)
|
||||
for(int i = 0; i < g_numUsbChanIn; i++)
|
||||
{
|
||||
/* Receive sample */
|
||||
int sample = inuint(c_mix_out);
|
||||
@@ -215,28 +215,28 @@ __builtin_unreachable();
|
||||
sample = h << 3;
|
||||
#endif
|
||||
/* Pack 3 byte samples */
|
||||
switch (packState&0x3)
|
||||
{
|
||||
case 0:
|
||||
switch (packState&0x3)
|
||||
{
|
||||
case 0:
|
||||
packData = sample;
|
||||
break;
|
||||
case 1:
|
||||
packData = (packData >> 8) | ((sample & 0xff00)<<16);
|
||||
write_via_xc_ptr(g_aud_to_host_dptr, packData);
|
||||
write_via_xc_ptr(g_aud_to_host_dptr, packData);
|
||||
g_aud_to_host_dptr+=4;
|
||||
write_via_xc_ptr(g_aud_to_host_dptr, sample>>16);
|
||||
write_via_xc_ptr(g_aud_to_host_dptr, sample>>16);
|
||||
packData = sample;
|
||||
break;
|
||||
case 2:
|
||||
packData = (packData>>16) | ((sample & 0xffff00) << 8);
|
||||
write_via_xc_ptr(g_aud_to_host_dptr, packData);
|
||||
write_via_xc_ptr(g_aud_to_host_dptr, packData);
|
||||
g_aud_to_host_dptr+=4;
|
||||
packData = sample;
|
||||
break;
|
||||
case 3:
|
||||
packData = (packData >> 24) | (sample & 0xffffff00);
|
||||
write_via_xc_ptr(g_aud_to_host_dptr, packData);
|
||||
g_aud_to_host_dptr+=4;
|
||||
write_via_xc_ptr(g_aud_to_host_dptr, packData);
|
||||
g_aud_to_host_dptr+=4;
|
||||
break;
|
||||
}
|
||||
packState++;
|
||||
@@ -248,7 +248,7 @@ __builtin_unreachable();
|
||||
#if (SAMPLE_SUBSLOT_SIZE_HS != 2) && (SAMPLE_SUBSLOT_SIZE_FS != 2)
|
||||
__builtin_unreachable();
|
||||
#endif
|
||||
for(int i = 0; i < g_numUsbChanIn; i++)
|
||||
for(int i = 0; i < g_numUsbChanIn; i++)
|
||||
{
|
||||
/* Receive sample */
|
||||
int sample = inuint(c_mix_out);
|
||||
@@ -270,12 +270,12 @@ __builtin_unreachable();
|
||||
switch (packState&0x1)
|
||||
{
|
||||
case 0:
|
||||
packData = sample;
|
||||
packData = sample;
|
||||
break;
|
||||
case 1:
|
||||
case 1:
|
||||
packData = (packData>>16) | (sample & 0xffff0000);
|
||||
write_via_xc_ptr(g_aud_to_host_dptr, packData);
|
||||
g_aud_to_host_dptr+=4;
|
||||
write_via_xc_ptr(g_aud_to_host_dptr, packData);
|
||||
g_aud_to_host_dptr+=4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -283,24 +283,24 @@ __builtin_unreachable();
|
||||
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Input any remaining channels - past this thread we always operate on max channel count */
|
||||
for(int i = 0; i < NUM_USB_CHAN_IN - g_numUsbChanIn; i++)
|
||||
{
|
||||
inuint(c_mix_out);
|
||||
}
|
||||
|
||||
sampsToWrite--;
|
||||
sampsToWrite--;
|
||||
}
|
||||
|
||||
if(outUnderflow)
|
||||
{
|
||||
{
|
||||
#pragma xta endpoint "out_underflow"
|
||||
#if 0
|
||||
/* We're still pre-buffering, send out 0 samps */
|
||||
for(int i = 0; i < NUM_USB_CHAN_OUT; i++)
|
||||
for(int i = 0; i < NUM_USB_CHAN_OUT; i++)
|
||||
{
|
||||
unsigned sample;
|
||||
unsigned mode;
|
||||
@@ -320,9 +320,9 @@ __builtin_unreachable();
|
||||
{
|
||||
outSamps += BUFF_SIZE_OUT*4;
|
||||
}
|
||||
|
||||
|
||||
/* If we have a decent number of samples, come out of underflow cond */
|
||||
if(outSamps >= (OUT_BUFFER_PREFILL))
|
||||
if(outSamps >= (OUT_BUFFER_PREFILL))
|
||||
{
|
||||
outUnderflow = 0;
|
||||
outSamps++;
|
||||
@@ -335,19 +335,19 @@ __builtin_unreachable();
|
||||
case 4:
|
||||
#if (SAMPLE_SUBSLOT_SIZE_HS != 4) && (SAMPLE_SUBSLOT_SIZE_FS != 4)
|
||||
__builtin_unreachable();
|
||||
#endif
|
||||
#endif
|
||||
/* Buffering not underflow condition send out some samples...*/
|
||||
for(int i = 0; i < g_numUsbChanOut; i++)
|
||||
for(int i = 0; i < g_numUsbChanOut; i++)
|
||||
{
|
||||
#pragma xta endpoint "mixer_request"
|
||||
int sample;
|
||||
int mult;
|
||||
int h;
|
||||
unsigned l;
|
||||
|
||||
|
||||
read_via_xc_ptr(sample, g_aud_from_host_rdptr);
|
||||
g_aud_from_host_rdptr+=4;
|
||||
|
||||
|
||||
#ifndef OUT_VOLUME_IN_MIXER
|
||||
asm("ldw %0, %1[%2]":"=r"(mult):"r"(p_multOut),"r"(i));
|
||||
{h, l} = macs(mult, sample, 0, 0);
|
||||
@@ -363,13 +363,13 @@ __builtin_unreachable();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 3:
|
||||
#if (SAMPLE_SUBSLOT_SIZE_HS != 3) && (SAMPLE_SUBSLOT_SIZE_FS != 3)
|
||||
__builtin_unreachable();
|
||||
#endif
|
||||
#endif
|
||||
/* Buffering not underflow condition send out some samples...*/
|
||||
for(int i = 0; i < g_numUsbChanOut; i++)
|
||||
for(int i = 0; i < g_numUsbChanOut; i++)
|
||||
{
|
||||
#pragma xta endpoint "mixer_request"
|
||||
int sample;
|
||||
@@ -378,12 +378,12 @@ __builtin_unreachable();
|
||||
unsigned l;
|
||||
|
||||
/* Unpack 3 byte samples */
|
||||
switch (unpackState&0x3)
|
||||
switch (unpackState&0x3)
|
||||
{
|
||||
case 0:
|
||||
read_via_xc_ptr(unpackData, g_aud_from_host_rdptr);
|
||||
g_aud_from_host_rdptr+=4;
|
||||
sample = unpackData << 8;
|
||||
sample = unpackData << 8;
|
||||
break;
|
||||
case 1:
|
||||
sample = (unpackData >> 16);
|
||||
@@ -393,7 +393,7 @@ __builtin_unreachable();
|
||||
break;
|
||||
case 2:
|
||||
sample = (unpackData >> 8);
|
||||
read_via_xc_ptr(unpackData, g_aud_from_host_rdptr);
|
||||
read_via_xc_ptr(unpackData, g_aud_from_host_rdptr);
|
||||
g_aud_from_host_rdptr+=4;
|
||||
sample = sample | (unpackData<< 24);
|
||||
break;
|
||||
@@ -402,7 +402,7 @@ __builtin_unreachable();
|
||||
break;
|
||||
}
|
||||
unpackState++;
|
||||
|
||||
|
||||
#ifndef OUT_VOLUME_IN_MIXER
|
||||
asm("ldw %0, %1[%2]":"=r"(mult):"r"(p_multOut),"r"(i));
|
||||
{h, l} = macs(mult, sample, 0, 0);
|
||||
@@ -418,25 +418,25 @@ __builtin_unreachable();
|
||||
case 2:
|
||||
#if (SAMPLE_SUBSLOT_SIZE_HS != 3) && (SAMPLE_SUBSLOT_SIZE_FS != 3)
|
||||
__builtin_unreachable();
|
||||
#endif
|
||||
#endif
|
||||
/* Buffering not underflow condition send out some samples...*/
|
||||
for(int i = 0; i < g_numUsbChanOut; i++)
|
||||
for(int i = 0; i < g_numUsbChanOut; i++)
|
||||
{
|
||||
#pragma xta endpoint "mixer_request"
|
||||
int sample;
|
||||
int mult;
|
||||
int h;
|
||||
unsigned l;
|
||||
|
||||
|
||||
switch (unpackState&0x1)
|
||||
{
|
||||
case 0:
|
||||
read_via_xc_ptr(unpackData, g_aud_from_host_rdptr);
|
||||
sample = unpackData << 16;
|
||||
sample = unpackData << 16;
|
||||
break;
|
||||
case 1:
|
||||
case 1:
|
||||
g_aud_from_host_rdptr+=4;
|
||||
sample = unpackData & 0xffff0000;
|
||||
sample = unpackData & 0xffff0000;
|
||||
break;
|
||||
}
|
||||
unpackState++;
|
||||
@@ -451,7 +451,7 @@ __builtin_unreachable();
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
break;
|
||||
@@ -463,18 +463,18 @@ __builtin_unreachable();
|
||||
{
|
||||
outuint(c_mix_out, 0);
|
||||
}
|
||||
|
||||
/* 3/4 bytes per sample */
|
||||
|
||||
/* 3/4 bytes per sample */
|
||||
aud_data_remaining_to_device -= (g_numUsbChanOut*g_slotSize);
|
||||
}
|
||||
|
||||
if (!inOverflow)
|
||||
|
||||
if (!inOverflow)
|
||||
{
|
||||
if (sampsToWrite == 0)
|
||||
if (sampsToWrite == 0)
|
||||
{
|
||||
int speed;
|
||||
|
||||
if (totalSampsToWrite)
|
||||
if (totalSampsToWrite)
|
||||
{
|
||||
unsigned datasize = totalSampsToWrite * g_slotSize * g_numUsbChanIn;
|
||||
|
||||
@@ -482,7 +482,7 @@ __builtin_unreachable();
|
||||
datasize = (datasize+3) & (~0x3);
|
||||
|
||||
g_aud_to_host_wrptr += 4+datasize;
|
||||
|
||||
|
||||
if (g_aud_to_host_wrptr >= aud_to_host_fifo_end)
|
||||
{
|
||||
g_aud_to_host_wrptr = aud_to_host_fifo_start;
|
||||
@@ -491,66 +491,66 @@ __builtin_unreachable();
|
||||
|
||||
/* Get feedback val - ideally this would be syncronised */
|
||||
asm("ldw %0, dp[g_speed]" : "=r" (speed) :);
|
||||
|
||||
/* Calc packet size to send back based on our fb */
|
||||
|
||||
/* Calc packet size to send back based on our fb */
|
||||
speedRem += speed;
|
||||
totalSampsToWrite = speedRem >> 16;
|
||||
speedRem &= 0xffff;
|
||||
|
||||
#if 0
|
||||
if (usb_speed == XUD_SPEED_HS)
|
||||
if (usb_speed == XUD_SPEED_HS)
|
||||
{
|
||||
if (totalSampsToWrite < 0 || totalSampsToWrite*4*g_numUsbChanIn > (MAX_DEVICE_AUD_PACKET_SIZE_CLASS_TWO))
|
||||
if (totalSampsToWrite < 0 || totalSampsToWrite*4*g_numUsbChanIn > (MAX_DEVICE_AUD_PACKET_SIZE_CLASS_TWO))
|
||||
{
|
||||
totalSampsToWrite = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (totalSampsToWrite < 0 || totalSampsToWrite*3*NUM_USB_CHAN_IN_A1 > (MAX_DEVICE_AUD_PACKET_SIZE_CLASS_ONE))
|
||||
if (totalSampsToWrite < 0 || totalSampsToWrite*3*NUM_USB_CHAN_IN_A1 > (MAX_DEVICE_AUD_PACKET_SIZE_CLASS_ONE))
|
||||
{
|
||||
totalSampsToWrite = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (totalSampsToWrite < 0 || totalSampsToWrite * g_slotSize * g_numUsbChanIn > g_maxPacketSize)
|
||||
if (totalSampsToWrite < 0 || totalSampsToWrite * g_slotSize * g_numUsbChanIn > g_maxPacketSize)
|
||||
{
|
||||
totalSampsToWrite = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Calc slots left in fifo */
|
||||
space_left = g_aud_to_host_rdptr - g_aud_to_host_wrptr;
|
||||
|
||||
/* Calc slots left in fifo */
|
||||
space_left = g_aud_to_host_rdptr - g_aud_to_host_wrptr;
|
||||
|
||||
/* Mod and special case */
|
||||
if (space_left <= 0 && g_aud_to_host_rdptr == aud_to_host_fifo_start)
|
||||
{
|
||||
space_left = aud_to_host_fifo_end - g_aud_to_host_wrptr;
|
||||
}
|
||||
|
||||
if ((space_left <= 0) || (space_left > totalSampsToWrite*g_numUsbChanIn * 4 + 4))
|
||||
{
|
||||
if ((space_left <= 0) || (space_left > totalSampsToWrite*g_numUsbChanIn * 4 + 4))
|
||||
{
|
||||
/* Packet okay, write to fifo */
|
||||
if (totalSampsToWrite)
|
||||
if (totalSampsToWrite)
|
||||
{
|
||||
write_via_xc_ptr(g_aud_to_host_wrptr, totalSampsToWrite*g_slotSize*g_numUsbChanIn);
|
||||
packState = 0;
|
||||
g_aud_to_host_dptr = g_aud_to_host_wrptr + 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
inOverflow = 1;
|
||||
totalSampsToWrite = 0;
|
||||
}
|
||||
sampsToWrite = totalSampsToWrite;
|
||||
sampsToWrite = totalSampsToWrite;
|
||||
}
|
||||
}
|
||||
|
||||
if (!outUnderflow && (aud_data_remaining_to_device<(g_slotSize*g_numUsbChanOut)))
|
||||
|
||||
if (!outUnderflow && (aud_data_remaining_to_device<(g_slotSize*g_numUsbChanOut)))
|
||||
{
|
||||
/* Handle any tail - incase a bad driver sent us a datalength not a multiple of chan count */
|
||||
if (aud_data_remaining_to_device)
|
||||
if (aud_data_remaining_to_device)
|
||||
{
|
||||
/* Round up to nearest word */
|
||||
aud_data_remaining_to_device +=3 - (unpackState&0x3);
|
||||
@@ -569,14 +569,14 @@ __builtin_unreachable();
|
||||
}
|
||||
|
||||
outUnderflow = (g_aud_from_host_rdptr == g_aud_from_host_wrptr);
|
||||
|
||||
|
||||
if (!outUnderflow)
|
||||
{
|
||||
|
||||
|
||||
if (!outUnderflow)
|
||||
{
|
||||
read_via_xc_ptr(aud_data_remaining_to_device, g_aud_from_host_rdptr);
|
||||
|
||||
|
||||
unpackState = 0;
|
||||
|
||||
|
||||
g_aud_from_host_rdptr+=4;
|
||||
}
|
||||
}
|
||||
@@ -610,7 +610,7 @@ static void check_for_interrupt(chanend ?c_clk_int) {
|
||||
//XUD_SetReady(int_usb_ep, 0);
|
||||
|
||||
//asm("ldaw %0, dp[g_intData]":"=r"(x));
|
||||
//XUD_SetReady_In(int_usb_ep, g_intData, 6);
|
||||
//XUD_SetReady_In(int_usb_ep, g_intData, 6);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -619,24 +619,24 @@ static void check_for_interrupt(chanend ?c_clk_int) {
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char tmpBuffer[1026];
|
||||
unsigned char tmpBuffer[1026];
|
||||
|
||||
#pragma unsafe arrays
|
||||
void decouple(chanend c_mix_out,
|
||||
chanend ?c_clk_int
|
||||
#ifdef CHAN_BUFF_CTRL
|
||||
, chanend c_buf_ctrl
|
||||
#endif
|
||||
#endif
|
||||
)
|
||||
{
|
||||
{
|
||||
unsigned sampFreq = DEFAULT_FREQ;
|
||||
#ifdef OUTPUT
|
||||
#ifdef OUTPUT
|
||||
int aud_from_host_flag=0;
|
||||
xc_ptr released_buffer;
|
||||
#endif
|
||||
#ifdef INPUT
|
||||
int aud_to_host_flag = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int t = array_to_xc_ptr(outAudioBuff);
|
||||
int aud_in_ready = 0;
|
||||
@@ -651,18 +651,18 @@ void decouple(chanend c_mix_out,
|
||||
aud_from_host_fifo_start = t;
|
||||
aud_from_host_fifo_end = aud_from_host_fifo_start + BUFF_SIZE_OUT*4;
|
||||
g_aud_from_host_wrptr = aud_from_host_fifo_start;
|
||||
g_aud_from_host_rdptr = aud_from_host_fifo_start;
|
||||
g_aud_from_host_rdptr = aud_from_host_fifo_start;
|
||||
|
||||
t = array_to_xc_ptr(audioBuffIn);
|
||||
|
||||
aud_to_host_fifo_start = t;
|
||||
aud_to_host_fifo_end = aud_to_host_fifo_start + BUFF_SIZE_IN*4;
|
||||
g_aud_to_host_wrptr = aud_to_host_fifo_start;
|
||||
g_aud_to_host_rdptr = aud_to_host_fifo_start;
|
||||
g_aud_to_host_rdptr = aud_to_host_fifo_start;
|
||||
|
||||
t = array_to_xc_ptr(inZeroBuff);
|
||||
g_aud_to_host_zeros = t;
|
||||
|
||||
|
||||
/* Init interrupt report */
|
||||
g_intData[0] = 0; // Class-specific, caused by interface
|
||||
g_intData[1] = 1; // attribute: CUR
|
||||
@@ -678,7 +678,7 @@ void decouple(chanend c_mix_out,
|
||||
asm("stw %0, %1[%2]"::"r"(MAX_VOL),"r"(p_multOut),"r"(i));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef IN_VOLUME_IN_MIXER
|
||||
for (int i = 0; i < NUM_USB_CHAN_IN + 1; i++)
|
||||
{
|
||||
@@ -698,11 +698,11 @@ void decouple(chanend c_mix_out,
|
||||
|
||||
#ifdef OUTPUT
|
||||
// wait for usb_buffer to set up
|
||||
while(!aud_from_host_flag)
|
||||
while(!aud_from_host_flag)
|
||||
{
|
||||
GET_SHARED_GLOBAL(aud_from_host_flag, g_aud_from_host_flag);
|
||||
}
|
||||
|
||||
|
||||
aud_from_host_flag = 0;
|
||||
SET_SHARED_GLOBAL(g_aud_from_host_flag, aud_from_host_flag);
|
||||
|
||||
@@ -713,11 +713,11 @@ void decouple(chanend c_mix_out,
|
||||
|
||||
#ifdef INPUT
|
||||
// Wait for usb_buffer to set up
|
||||
while(!aud_to_host_flag)
|
||||
while(!aud_to_host_flag)
|
||||
{
|
||||
GET_SHARED_GLOBAL(aud_to_host_flag, g_aud_to_host_flag);
|
||||
}
|
||||
|
||||
|
||||
aud_to_host_flag = 0;
|
||||
SET_SHARED_GLOBAL(g_aud_to_host_flag, aud_to_host_flag);
|
||||
|
||||
@@ -729,9 +729,9 @@ void decouple(chanend c_mix_out,
|
||||
|
||||
GET_SHARED_GLOBAL(p, g_aud_to_host_buffer);
|
||||
read_via_xc_ptr(len, p)
|
||||
XUD_SetReady_InPtr(aud_to_host_usb_ep, g_aud_to_host_buffer, len);
|
||||
aud_in_ready = 1;
|
||||
|
||||
XUD_SetReady_InPtr(aud_to_host_usb_ep, g_aud_to_host_buffer, len);
|
||||
aud_in_ready = 1;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -762,24 +762,24 @@ void decouple(chanend c_mix_out,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!isnull(c_clk_int))
|
||||
if (!isnull(c_clk_int))
|
||||
{
|
||||
check_for_interrupt(c_clk_int);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
asm("#decouple-default");
|
||||
|
||||
/* Check for freq change or other update */
|
||||
|
||||
GET_SHARED_GLOBAL(tmp, g_freqChange_flag);
|
||||
if (tmp == SET_SAMPLE_FREQ)
|
||||
if (tmp == SET_SAMPLE_FREQ)
|
||||
{
|
||||
SET_SHARED_GLOBAL(g_freqChange_flag, 0);
|
||||
GET_SHARED_GLOBAL(sampFreq, g_freqChange_sampFreq);
|
||||
|
||||
/* Pass on to mixer */
|
||||
DISABLE_INTERRUPTS();
|
||||
DISABLE_INTERRUPTS();
|
||||
inuint(c_mix_out);
|
||||
outct(c_mix_out, SET_SAMPLE_FREQ);
|
||||
outuint(c_mix_out, sampFreq);
|
||||
@@ -792,7 +792,7 @@ void decouple(chanend c_mix_out,
|
||||
aud_to_host_fifo_start);
|
||||
SET_SHARED_GLOBAL(sampsToWrite, 0);
|
||||
SET_SHARED_GLOBAL(totalSampsToWrite, 0);
|
||||
|
||||
|
||||
/* Set buffer to send back to zeros buffer */
|
||||
SET_SHARED_GLOBAL(g_aud_to_host_buffer,g_aud_to_host_zeros);
|
||||
|
||||
@@ -801,7 +801,7 @@ void decouple(chanend c_mix_out,
|
||||
int min, mid, max, usb_speed;
|
||||
GET_SHARED_GLOBAL(usb_speed, g_curUsbSpeed);
|
||||
GetADCCounts(sampFreq, min, mid, max);
|
||||
if (usb_speed == XUD_SPEED_HS)
|
||||
if (usb_speed == XUD_SPEED_HS)
|
||||
mid*=NUM_USB_CHAN_IN*4;
|
||||
else
|
||||
mid*=NUM_USB_CHAN_IN_A1*3;
|
||||
@@ -815,23 +815,23 @@ void decouple(chanend c_mix_out,
|
||||
{
|
||||
xc_ptr p;
|
||||
int len;
|
||||
|
||||
|
||||
GET_SHARED_GLOBAL(p, g_aud_to_host_buffer);
|
||||
read_via_xc_ptr(len, p);
|
||||
|
||||
read_via_xc_ptr(len, p);
|
||||
|
||||
/* Update packet size */
|
||||
XUD_SetReady_InPtr(aud_to_host_usb_ep, p+4, len);
|
||||
}
|
||||
|
||||
/* Reset OUT buffer state */
|
||||
/* Reset OUT buffer state */
|
||||
outUnderflow = 1;
|
||||
SET_SHARED_GLOBAL(g_aud_from_host_rdptr, aud_from_host_fifo_start);
|
||||
SET_SHARED_GLOBAL(g_aud_from_host_rdptr, aud_from_host_fifo_start);
|
||||
SET_SHARED_GLOBAL(g_aud_from_host_wrptr, aud_from_host_fifo_start);
|
||||
SET_SHARED_GLOBAL(aud_data_remaining_to_device, 0);
|
||||
|
||||
if(outOverflow)
|
||||
{
|
||||
/* If we were previously in overflow we wont have marked as ready */
|
||||
/* If we were previously in overflow we wont have marked as ready */
|
||||
XUD_SetReady_OutPtr(aud_from_host_usb_ep, aud_from_host_fifo_start+4);
|
||||
outOverflow = 0;
|
||||
}
|
||||
@@ -842,7 +842,7 @@ void decouple(chanend c_mix_out,
|
||||
|
||||
SET_SHARED_GLOBAL(g_freqChange, 0);
|
||||
asm("outct res[%0],%1"::"r"(buffer_aud_ctl_chan),"r"(XS1_CT_END));
|
||||
|
||||
|
||||
ENABLE_INTERRUPTS();
|
||||
|
||||
speedRem = 0;
|
||||
@@ -851,11 +851,11 @@ void decouple(chanend c_mix_out,
|
||||
else if(tmp == SET_CHAN_COUNT_IN)
|
||||
{
|
||||
/* Change in IN channel count */
|
||||
DISABLE_INTERRUPTS();
|
||||
DISABLE_INTERRUPTS();
|
||||
SET_SHARED_GLOBAL(g_freqChange_flag, 0);
|
||||
GET_SHARED_GLOBAL(g_numUsbChanIn, g_freqChange_sampFreq); /* Misuse of g_freqChange_sampFreq */
|
||||
|
||||
/* Reset IN buffer state */
|
||||
|
||||
/* Reset IN buffer state */
|
||||
inOverflow = 0;
|
||||
inUnderflow = 1;
|
||||
SET_SHARED_GLOBAL(g_aud_to_host_rdptr, aud_to_host_fifo_start);
|
||||
@@ -863,29 +863,29 @@ void decouple(chanend c_mix_out,
|
||||
SET_SHARED_GLOBAL(sampsToWrite, 0);
|
||||
SET_SHARED_GLOBAL(totalSampsToWrite, 0);
|
||||
SET_SHARED_GLOBAL(g_aud_to_host_buffer, g_aud_to_host_zeros);
|
||||
|
||||
|
||||
SET_SHARED_GLOBAL(g_freqChange, 0);
|
||||
ENABLE_INTERRUPTS();
|
||||
}
|
||||
else if(tmp == SET_CHAN_COUNT_OUT)
|
||||
{
|
||||
/* Change in OUT channel count */
|
||||
DISABLE_INTERRUPTS();
|
||||
DISABLE_INTERRUPTS();
|
||||
SET_SHARED_GLOBAL(g_freqChange_flag, 0);
|
||||
GET_SHARED_GLOBAL(g_numUsbChanOut, g_freqChange_sampFreq); /* Misuse of g_freqChange_sampFreq */
|
||||
|
||||
/* Reset OUT buffer state */
|
||||
|
||||
/* Reset OUT buffer state */
|
||||
SET_SHARED_GLOBAL(g_aud_from_host_rdptr, aud_from_host_fifo_start);
|
||||
SET_SHARED_GLOBAL(g_aud_from_host_wrptr, aud_from_host_fifo_start);
|
||||
|
||||
|
||||
outUnderflow = 1;
|
||||
if(outOverflow)
|
||||
{
|
||||
/* If we were previously in overflow we wont have marked as ready */
|
||||
/* If we were previously in overflow we wont have marked as ready */
|
||||
XUD_SetReady_OutPtr(aud_from_host_usb_ep, aud_from_host_fifo_start+4);
|
||||
outOverflow = 0;
|
||||
}
|
||||
|
||||
|
||||
SET_SHARED_GLOBAL(g_freqChange, 0);
|
||||
ENABLE_INTERRUPTS();
|
||||
}
|
||||
@@ -893,34 +893,34 @@ void decouple(chanend c_mix_out,
|
||||
else if(tmp == SET_DSD_MODE)
|
||||
{
|
||||
unsigned dsdMode;
|
||||
DISABLE_INTERRUPTS();
|
||||
DISABLE_INTERRUPTS();
|
||||
|
||||
/* Clear the buffer as we dont want to send out old PCM samples.. */
|
||||
SET_SHARED_GLOBAL(g_freqChange_flag, 0);
|
||||
GET_SHARED_GLOBAL(dsdMode, g_freqChange_sampFreq); /* Misuse of g_freqChange_sampFreq */
|
||||
|
||||
/* Reset OUT buffer state */
|
||||
|
||||
/* Reset OUT buffer state */
|
||||
SET_SHARED_GLOBAL(g_aud_from_host_rdptr, aud_from_host_fifo_start);
|
||||
SET_SHARED_GLOBAL(g_aud_from_host_wrptr, aud_from_host_fifo_start);
|
||||
|
||||
|
||||
outUnderflow = 1;
|
||||
if(outOverflow)
|
||||
{
|
||||
/* If we were previously in overflow we wont have marked as ready */
|
||||
/* If we were previously in overflow we wont have marked as ready */
|
||||
XUD_SetReady_OutPtr(aud_from_host_usb_ep, aud_from_host_fifo_start+4);
|
||||
outOverflow = 0;
|
||||
}
|
||||
|
||||
|
||||
inuint(c_mix_out);
|
||||
outct(c_mix_out, SET_DSD_MODE);
|
||||
outuint(c_mix_out, dsdMode);
|
||||
|
||||
/* Wait for handshake back */
|
||||
outuint(c_mix_out, dsdMode);
|
||||
|
||||
/* Wait for handshake back */
|
||||
chkct(c_mix_out, XS1_CT_END);
|
||||
|
||||
SET_SHARED_GLOBAL(g_freqChange, 0);
|
||||
asm("outct res[%0],%1"::"r"(buffer_aud_ctl_chan),"r"(XS1_CT_END));
|
||||
|
||||
|
||||
ENABLE_INTERRUPTS();
|
||||
}
|
||||
#endif
|
||||
@@ -938,17 +938,17 @@ void decouple(chanend c_mix_out,
|
||||
int aud_from_host_rdptr;
|
||||
GET_SHARED_GLOBAL(aud_from_host_wrptr, g_aud_from_host_wrptr);
|
||||
GET_SHARED_GLOBAL(aud_from_host_rdptr, g_aud_from_host_rdptr);
|
||||
|
||||
|
||||
SET_SHARED_GLOBAL(g_aud_from_host_flag, 0);
|
||||
GET_SHARED_GLOBAL(released_buffer, g_aud_from_host_buffer);
|
||||
|
||||
|
||||
/* Read datalength from buffer */
|
||||
read_via_xc_ptr(datalength, released_buffer);
|
||||
|
||||
/* Ignore bad small packets */
|
||||
/* Ignore bad small packets */
|
||||
if ((datalength >= (g_numUsbChanOut * g_slotSize)) && (released_buffer == aud_from_host_wrptr))
|
||||
{
|
||||
|
||||
|
||||
/* Move the write pointer of the fifo on - round up to nearest word */
|
||||
aud_from_host_wrptr = aud_from_host_wrptr + ((datalength+3)&~0x3) + 4;
|
||||
|
||||
@@ -959,36 +959,36 @@ void decouple(chanend c_mix_out,
|
||||
}
|
||||
SET_SHARED_GLOBAL(g_aud_from_host_wrptr, aud_from_host_wrptr);
|
||||
}
|
||||
|
||||
/* if we have enough space left then send a new buffer pointer
|
||||
|
||||
/* if we have enough space left then send a new buffer pointer
|
||||
* back to the buffer thread */
|
||||
space_left = aud_from_host_rdptr - aud_from_host_wrptr;
|
||||
|
||||
|
||||
/* Mod and special case */
|
||||
if(space_left <= 0 && g_aud_from_host_rdptr == aud_from_host_fifo_start)
|
||||
{
|
||||
space_left = aud_from_host_fifo_end - g_aud_from_host_wrptr;
|
||||
}
|
||||
|
||||
if (space_left <= 0 || space_left >= MAX_USB_AUD_PACKET_SIZE)
|
||||
{
|
||||
|
||||
if (space_left <= 0 || space_left >= MAX_USB_AUD_PACKET_SIZE)
|
||||
{
|
||||
SET_SHARED_GLOBAL(g_aud_from_host_buffer, aud_from_host_wrptr);
|
||||
XUD_SetReady_OutPtr(aud_from_host_usb_ep, aud_from_host_wrptr+4);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Enter OUT over flow state */
|
||||
outOverflow = 1;
|
||||
else
|
||||
{
|
||||
/* Enter OUT over flow state */
|
||||
outOverflow = 1;
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG_LEDS
|
||||
|
||||
#ifdef DEBUG_LEDS
|
||||
led(c_led);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (outOverflow)
|
||||
else if (outOverflow)
|
||||
{
|
||||
int space_left;
|
||||
int aud_from_host_wrptr;
|
||||
@@ -996,9 +996,9 @@ void decouple(chanend c_mix_out,
|
||||
GET_SHARED_GLOBAL(aud_from_host_wrptr, g_aud_from_host_wrptr);
|
||||
GET_SHARED_GLOBAL(aud_from_host_rdptr, g_aud_from_host_rdptr);
|
||||
space_left = aud_from_host_rdptr - aud_from_host_wrptr;
|
||||
if (space_left <= 0)
|
||||
if (space_left <= 0)
|
||||
space_left += BUFF_SIZE_OUT*4;
|
||||
if (space_left >= (BUFF_SIZE_OUT*4/2))
|
||||
if (space_left >= (BUFF_SIZE_OUT*4/2))
|
||||
{
|
||||
/* Come out of OUT overflow state */
|
||||
outOverflow = 0;
|
||||
@@ -1012,19 +1012,19 @@ void decouple(chanend c_mix_out,
|
||||
#endif
|
||||
|
||||
#ifdef INPUT
|
||||
{
|
||||
{
|
||||
/* Check if buffer() has sent a packet to host - uses shared mem flag to save chanends */
|
||||
int tmp;
|
||||
GET_SHARED_GLOBAL(tmp, g_aud_to_host_flag);
|
||||
//case inuint_byref(c_buf_in, tmp):
|
||||
if (tmp)
|
||||
if (tmp)
|
||||
{
|
||||
/* Signals that the IN endpoint has sent data from the passed buffer */
|
||||
/* Signals that the IN endpoint has sent data from the passed buffer */
|
||||
/* Reset flag */
|
||||
SET_SHARED_GLOBAL(g_aud_to_host_flag, 0);
|
||||
SET_SHARED_GLOBAL(g_aud_to_host_flag, 0);
|
||||
aud_in_ready = 0;
|
||||
|
||||
if (inUnderflow)
|
||||
|
||||
if (inUnderflow)
|
||||
{
|
||||
int aud_to_host_wrptr;
|
||||
int aud_to_host_rdptr;
|
||||
@@ -1038,18 +1038,18 @@ void decouple(chanend c_mix_out,
|
||||
if (fill_level < 0)
|
||||
fill_level += BUFF_SIZE_IN*4;
|
||||
|
||||
if (fill_level >= IN_BUFFER_PREFILL)
|
||||
{
|
||||
if (fill_level >= IN_BUFFER_PREFILL)
|
||||
{
|
||||
inUnderflow = 0;
|
||||
SET_SHARED_GLOBAL(g_aud_to_host_buffer, aud_to_host_rdptr);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
SET_SHARED_GLOBAL(g_aud_to_host_buffer, g_aud_to_host_zeros);
|
||||
SET_SHARED_GLOBAL(g_aud_to_host_buffer, g_aud_to_host_zeros);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Not in IN underflow state */
|
||||
int datalength;
|
||||
@@ -1068,7 +1068,7 @@ void decouple(chanend c_mix_out,
|
||||
SET_SHARED_GLOBAL(g_aud_to_host_rdptr, aud_to_host_rdptr);
|
||||
|
||||
/* Check for read pointer hitting write pointer - underflow */
|
||||
if (aud_to_host_rdptr != aud_to_host_wrptr)
|
||||
if (aud_to_host_rdptr != aud_to_host_wrptr)
|
||||
{
|
||||
SET_SHARED_GLOBAL(g_aud_to_host_buffer, aud_to_host_rdptr);
|
||||
}
|
||||
@@ -1076,13 +1076,13 @@ void decouple(chanend c_mix_out,
|
||||
{
|
||||
inUnderflow = 1;
|
||||
SET_SHARED_GLOBAL(g_aud_to_host_buffer, g_aud_to_host_zeros);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Request to send packet */
|
||||
}
|
||||
|
||||
/* Request to send packet */
|
||||
{
|
||||
int p, len;
|
||||
int p, len;
|
||||
GET_SHARED_GLOBAL(p, g_aud_to_host_buffer);
|
||||
asm("ldw %0, %1[0]":"=r"(len):"r"(p));
|
||||
XUD_SetReady_InPtr(aud_to_host_usb_ep, p+4, len);
|
||||
|
||||
Reference in New Issue
Block a user