forked from PAWPAW-Mirror/lib_xua
xpd: Cleaned up whitespace
This commit is contained in:
@@ -7,12 +7,12 @@
|
||||
* Description:
|
||||
* APP global includes, constants, declarations, etc.
|
||||
*
|
||||
* Author(s):
|
||||
* Author(s):
|
||||
* Udo Eberhardt
|
||||
*
|
||||
*
|
||||
* Companies:
|
||||
* Thesycon GmbH, Germany http://www.thesycon.de
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#ifndef __global_h__
|
||||
|
||||
@@ -1093,12 +1093,12 @@
|
||||
#endif
|
||||
|
||||
/* Handle in volume control in the mixer - disabled by default */
|
||||
#ifndef IN_VOLUME_IN_MIXER
|
||||
#ifndef IN_VOLUME_IN_MIXER
|
||||
#define IN_VOLUME_IN_MIXER (0)
|
||||
#endif
|
||||
|
||||
/* Apply in volume controls after the mix. Only relebant when IN_VOLUMNE_IN MIXER enabled. Enabled by default */
|
||||
#ifndef IN_VOLUME_AFTER_MIX
|
||||
#ifndef IN_VOLUME_AFTER_MIX
|
||||
#define IN_VOLUME_AFTER_MIX (1)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -290,7 +290,7 @@ __builtin_unreachable();
|
||||
#if (STREAM_FORMAT_OUTPUT_SUBSLOT_3_USED == 0)
|
||||
__builtin_unreachable();
|
||||
#endif
|
||||
/* Note, in this case the unpacking of data is more of an overhead than the loop overhead
|
||||
/* Note, in this case the unpacking of data is more of an overhead than the loop overhead
|
||||
* so we do not currently make attempts to unroll */
|
||||
for(int i = 0; i < g_numUsbChan_Out; i++)
|
||||
{
|
||||
|
||||
@@ -274,7 +274,7 @@ static void updateVol(int unitID, int channel, chanend ?c_mix_ctl)
|
||||
#endif
|
||||
|
||||
void UpdateMixerOutputRouting(chanend c_mix_ctl, unsigned map, unsigned dst, unsigned src)
|
||||
{
|
||||
{
|
||||
outct(c_mix_ctl, XS1_CT_END);
|
||||
inct(c_mix_ctl);
|
||||
outuint(c_mix_ctl, map);
|
||||
@@ -295,7 +295,7 @@ void UpdateMixMap(chanend c_mix_ctl, int mix, int input, int src)
|
||||
}
|
||||
|
||||
void UpdateMixerWeight(chanend c_mix_ctl, int mix, int index, unsigned mult)
|
||||
{
|
||||
{
|
||||
outct(c_mix_ctl, XS1_CT_END);
|
||||
inct(c_mix_ctl);
|
||||
outuint(c_mix_ctl, SET_MIX_MULT);
|
||||
@@ -674,14 +674,14 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c
|
||||
case ID_XU_OUT:
|
||||
{
|
||||
int dst = sp.wValue & 0xff;
|
||||
|
||||
|
||||
if(sp.bmRequestType.Direction == USB_BM_REQTYPE_DIRECTION_H2D) /* Direction: Host-to-device */
|
||||
{
|
||||
if((result = XUD_GetBuffer(ep0_out, (buffer, unsigned char[]), datalength)) != XUD_RES_OKAY)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
if (dst < NUM_USB_CHAN_OUT)
|
||||
{
|
||||
channelMapAud[dst] = (buffer, unsigned char[])[0] | (buffer, unsigned char[])[1] << 8;
|
||||
@@ -691,7 +691,7 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c
|
||||
UpdateMixerOutputRouting(c_mix_ctl, SET_SAMPLES_TO_DEVICE_MAP, dst, channelMapAud[dst]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Send 0 Length as status stage */
|
||||
return XUD_DoSetRequestStatus(ep0_in);
|
||||
}
|
||||
@@ -707,7 +707,7 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c
|
||||
case ID_XU_IN:
|
||||
{
|
||||
int dst = sp.wValue & 0xff;
|
||||
|
||||
|
||||
if(sp.bmRequestType.Direction == USB_BM_REQTYPE_DIRECTION_H2D) /* Direction: Host-to-device */
|
||||
{
|
||||
if((result = XUD_GetBuffer(ep0_out, (buffer, unsigned char[]), datalength)) != XUD_RES_OKAY)
|
||||
@@ -718,7 +718,7 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c
|
||||
if (dst < NUM_USB_CHAN_IN)
|
||||
{
|
||||
channelMapUsb[dst] = (buffer, unsigned char[])[0] | (buffer, unsigned char[])[1] << 8;
|
||||
|
||||
|
||||
if (!isnull(c_mix_ctl))
|
||||
{
|
||||
UpdateMixerOutputRouting(c_mix_ctl, SET_SAMPLES_TO_HOST_MAP, dst, channelMapUsb[dst]);
|
||||
@@ -814,7 +814,7 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c
|
||||
{
|
||||
int cs = sp.wValue >> 8; /* Control Selector - currently unused */
|
||||
int cn = sp.wValue & 0xff; /* Channel number - used for mixer node index */
|
||||
|
||||
|
||||
if(sp.bmRequestType.Direction == USB_BM_REQTYPE_DIRECTION_H2D) /* Direction: Host-to-device */
|
||||
{
|
||||
unsigned weightMult = 0;
|
||||
@@ -824,7 +824,7 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
if(cn < sizeof(mixer1Weights)/sizeof(mixer1Weights[0]))
|
||||
{
|
||||
mixer1Weights[cn] = (buffer, unsigned char[])[0] | (buffer, unsigned char[])[1] << 8;
|
||||
@@ -846,12 +846,12 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c
|
||||
else
|
||||
{
|
||||
short weight = 0x8000;
|
||||
|
||||
|
||||
if(cn < sizeof(mixer1Weights)/sizeof(mixer1Weights[0]))
|
||||
{
|
||||
weight = mixer1Weights[cn];
|
||||
}
|
||||
|
||||
|
||||
storeShort((buffer, unsigned char[]), 0, weight);
|
||||
|
||||
return XUD_DoGetRequest(ep0_out, ep0_in, (buffer, unsigned char[]), sp.wLength, sp.wLength);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef MIX_INPUTS
|
||||
#error
|
||||
#error
|
||||
#endif
|
||||
|
||||
#if (MAX_MIX_COUNT > 0)
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
|
||||
#if defined (LEVEL_METER_HOST) || defined(LEVEL_METER_LEDS) || !FAST_MIXER
|
||||
#include "xc_ptr.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (MIXER)
|
||||
|
||||
#if (OUT_VOLUME_IN_MIXER)
|
||||
#if (OUT_VOLUME_IN_MIXER)
|
||||
static unsigned int multOut_array[NUM_USB_CHAN_OUT + 1];
|
||||
unsafe
|
||||
unsafe
|
||||
{
|
||||
int volatile * unsafe multOut = multOut_array;
|
||||
}
|
||||
@@ -29,11 +29,11 @@ unsafe
|
||||
|
||||
#if (IN_VOLUME_IN_MIXER)
|
||||
static unsigned int multIn_array[NUM_USB_CHAN_IN + 1];
|
||||
unsafe
|
||||
unsafe
|
||||
{
|
||||
int volatile * unsafe multIn = multIn_array;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (LEVEL_METER_LEDS) || defined (LEVEL_METER_HOST)
|
||||
static unsigned abs(int x)
|
||||
@@ -73,7 +73,7 @@ unsafe
|
||||
int volatile * const unsafe mix_mult = mix_mult_array;
|
||||
#if (FAST_MIXER == 0)
|
||||
int volatile * const unsafe mix_map = mix_map_array;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#define slice(a, i) (a + i * MIX_INPUTS)
|
||||
@@ -186,13 +186,13 @@ static inline void GiveSamplesToHost(chanend c, volatile int * unsafe hostMap)
|
||||
|
||||
#if (IN_VOLUME_IN_MIXER && IN_VOLUME_AFTER_MIX)
|
||||
#warning IN Vols in mixer, AFTER mix & map
|
||||
|
||||
|
||||
unsafe
|
||||
{
|
||||
mult = multIn[i];
|
||||
}
|
||||
{h, l} = macs(mult, sample, 0, 0);
|
||||
|
||||
|
||||
//h <<= 3 done on other side */
|
||||
|
||||
outuint(c, h);
|
||||
@@ -386,7 +386,7 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
|
||||
case inct_byref(c_mix_ctl, ct):
|
||||
{
|
||||
int mix, index, val;
|
||||
|
||||
|
||||
/* Handshake back to tell EP0 we are ready for an update */
|
||||
outct(c_mix_ctl, XS1_CT_END);
|
||||
|
||||
@@ -402,7 +402,7 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
|
||||
int dst = inuint(c_mix_ctl);
|
||||
int src = inuint(c_mix_ctl);
|
||||
inct(c_mix_ctl);
|
||||
|
||||
|
||||
assert((dst < NUM_USB_CHAN_IN) && msg("Host map destination out of range"));
|
||||
assert((src < SOURCE_COUNT) && msg("Host map source out of range"));
|
||||
|
||||
@@ -421,7 +421,7 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
|
||||
int dst = inuint(c_mix_ctl);
|
||||
int src = inuint(c_mix_ctl);
|
||||
inct(c_mix_ctl);
|
||||
|
||||
|
||||
assert((dst < NUM_USB_CHAN_OUT) && msg("Device map destination out of range"));
|
||||
assert((src < SOURCE_COUNT) && msg("Device map source out of range"));
|
||||
|
||||
@@ -443,7 +443,7 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
|
||||
|
||||
assert((mix < MAX_MIX_COUNT) && msg("Mix mult mix out of range"));
|
||||
assert((index < MIX_INPUTS) && msg("Mix mult index out of range"));
|
||||
|
||||
|
||||
if((index < MIX_INPUTS) && (mix < MAX_MIX_COUNT))
|
||||
{
|
||||
unsafe
|
||||
@@ -473,7 +473,7 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
|
||||
{
|
||||
mix_map[(mix * MIX_INPUTS) + input] = source;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -484,7 +484,7 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
|
||||
index = inuint(c_mix_ctl);
|
||||
val = inuint(c_mix_ctl);
|
||||
inct(c_mix_ctl);
|
||||
|
||||
|
||||
assert((index < (NUM_USB_CHAN_IN + 1)) && msg("In volume index out of range"));
|
||||
|
||||
if(index < NUM_USB_CHAN_IN + 1)
|
||||
@@ -501,7 +501,7 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
|
||||
index = inuint(c_mix_ctl);
|
||||
val = inuint(c_mix_ctl);
|
||||
inct(c_mix_ctl);
|
||||
|
||||
|
||||
assert((index < (NUM_USB_CHAN_OUT + 1)) && msg("Out volume index out of range"));
|
||||
|
||||
if(index < NUM_USB_CHAN_OUT + 1)
|
||||
@@ -535,7 +535,7 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
|
||||
|
||||
/* Get response from decouple */
|
||||
if(testct(c_host))
|
||||
{
|
||||
{
|
||||
int sampFreq;
|
||||
unsigned command = inct(c_host);
|
||||
|
||||
@@ -773,7 +773,7 @@ static void mixer2(chanend c_mixer1, chanend c_audio)
|
||||
mixed = doMix(ptr_samples, slice(mix_map, 5), slice(mix_mult, 5));
|
||||
#endif
|
||||
ptr_samples[NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + 5] = mixed;
|
||||
|
||||
|
||||
}
|
||||
#if defined (LEVEL_METER_HOST) || defined(LEVEL_METER_LEDS)
|
||||
ComputeMixerLevel(mixed, 5);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022-2023 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
|
||||
/* Tests that routing of mixer inputs behaves as expected
|
||||
/* Tests that routing of mixer inputs behaves as expected
|
||||
*
|
||||
* The device supports MAX_MIX_COUNT mixers each with MIX_INPUTS inputs.
|
||||
*
|
||||
@@ -9,7 +9,7 @@
|
||||
* each of the M mixer units is as follows:
|
||||
*
|
||||
* MIXER[0]:
|
||||
* USB_FROM_HOST[0] -> MIXER[0].INPUT[0]
|
||||
* USB_FROM_HOST[0] -> MIXER[0].INPUT[0]
|
||||
* USB_FROM_HOST[1] -> MIXER[0].INPUT[1]
|
||||
* ...
|
||||
USB_TO_HOST[0] -> MIXER[0].INPUT[NUM_USB_CHAN_OUT]
|
||||
@@ -17,10 +17,10 @@
|
||||
...
|
||||
|
||||
* MIXER[MAX_MIX_COUNT-1]:
|
||||
* USB_FROM_HOST[0] -> MIXER[MAX_MIX_COUNT-1].INPUT[0]
|
||||
* USB_FROM_HOST[0] -> MIXER[MAX_MIX_COUNT-1].INPUT[0]
|
||||
* USB_FROM_HOST[1] -> MIXER[MAX_MIX_COUNT-1].INPUT[1]
|
||||
* ...
|
||||
*
|
||||
*
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "assert.h"
|
||||
#include "random.h"
|
||||
|
||||
#ifndef TEST_ITERATIONS
|
||||
#ifndef TEST_ITERATIONS
|
||||
#define TEST_ITERATIONS (300)
|
||||
#endif
|
||||
|
||||
@@ -50,13 +50,13 @@ void InitModel(struct ModelMixer &modelMixer)
|
||||
for(size_t i = 0; i < NUM_USB_CHAN_OUT; i++)
|
||||
{
|
||||
modelMixer.deviceMap[i] = i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < NUM_USB_CHAN_IN; i++)
|
||||
{
|
||||
modelMixer.hostMap[i] = NUM_USB_CHAN_OUT+i;
|
||||
}
|
||||
|
||||
|
||||
for(size_t i = 0; i < MAX_MIX_COUNT; i++)
|
||||
{
|
||||
// This test only allows for one "active" input to each mixer
|
||||
@@ -70,7 +70,7 @@ void InitModel(struct ModelMixer &modelMixer)
|
||||
}
|
||||
}
|
||||
|
||||
void GenExpectedSamples(struct ModelMixer &modelMixer,
|
||||
void GenExpectedSamples(struct ModelMixer &modelMixer,
|
||||
uint32_t modelOut[NUM_USB_CHAN_OUT],
|
||||
uint32_t modelIn[NUM_USB_CHAN_IN])
|
||||
{
|
||||
@@ -99,7 +99,7 @@ void GenExpectedSamples(struct ModelMixer &modelMixer,
|
||||
|
||||
|
||||
|
||||
void MapMixerInput(int mix, int input, int src, struct ModelMixer &modelMixer, chanend c_mix_ctl,
|
||||
void MapMixerInput(int mix, int input, int src, struct ModelMixer &modelMixer, chanend c_mix_ctl,
|
||||
chanend c_stim_ah, chanend c_stim_de, uint32_t modelIn[], uint32_t modelOut[])
|
||||
{
|
||||
debug_printf("Mapping mix %d input %d", mix, input);
|
||||
@@ -109,38 +109,38 @@ void MapMixerInput(int mix, int input, int src, struct ModelMixer &modelMixer, c
|
||||
|
||||
/* This test only allows for one input to travel "untouched" to the mix output - since this test doesn't model the actual mixing.
|
||||
* Because of this we must also mod the mixer weights, not just the mixer input map.
|
||||
* If we simply just apply an update to the mixer input mapping it would not produce an observable difference on the mixer output
|
||||
* If we simply just apply an update to the mixer input mapping it would not produce an observable difference on the mixer output
|
||||
*/
|
||||
|
||||
|
||||
/* Set previously "activated" input weight to 0 */
|
||||
debug_printf("Setting mix %d, weight %d to 0\n", mix, modelMixer.mixMap_input[mix]);
|
||||
SendTrigger(c_stim_ah, 1);
|
||||
UpdateMixerWeight(c_mix_ctl, mix, modelMixer.mixMap_input[mix], 0);
|
||||
SendTrigger(c_stim_ah, 1);
|
||||
UpdateMixerWeight(c_mix_ctl, mix, modelMixer.mixMap_input[mix], 0);
|
||||
|
||||
/* Set new "activated" input wright to max (i.e. x1) */
|
||||
/* Set new "activated" input wright to max (i.e. x1) */
|
||||
debug_printf("Setting mix %d, weight %d to %x\n", mix, input, XUA_MIXER_MAX_MULT);
|
||||
SendTrigger(c_stim_ah, 1);
|
||||
UpdateMixerWeight(c_mix_ctl, mix, input, XUA_MIXER_MAX_MULT);
|
||||
UpdateMixerWeight(c_mix_ctl, mix, input, XUA_MIXER_MAX_MULT);
|
||||
|
||||
/* Update mixer input in model */
|
||||
modelMixer.mixMap_src[mix] = src;
|
||||
modelMixer.mixMap_input[mix] = input;
|
||||
|
||||
/* Run twice to allow mix inputs derived from mix outputs to propagate */
|
||||
|
||||
/* Run twice to allow mix inputs derived from mix outputs to propagate */
|
||||
GenExpectedSamples(modelMixer, modelOut, modelIn);
|
||||
|
||||
|
||||
/* Finally update the acutal mixer input map */
|
||||
SendTrigger(c_stim_ah, 1);
|
||||
UpdateMixMap(c_mix_ctl, mix, input, src);
|
||||
|
||||
SendTrigger(c_stim_ah, 1);
|
||||
|
||||
SendTrigger(c_stim_ah, 1);
|
||||
UpdateMixMap(c_mix_ctl, mix, input, src);
|
||||
|
||||
SendTrigger(c_stim_ah, 1);
|
||||
|
||||
SendExpected(c_stim_ah, c_stim_de, modelOut, modelIn);
|
||||
}
|
||||
|
||||
|
||||
/* This task configures the routing and maintains a model of the expected routing output
|
||||
* it provides this to the Fake AudioHub and Fake Decouple tasks such that they can self check
|
||||
/* This task configures the routing and maintains a model of the expected routing output
|
||||
* it provides this to the Fake AudioHub and Fake Decouple tasks such that they can self check
|
||||
*/
|
||||
void stim(chanend c_stim_ah, chanend c_stim_de, chanend c_mix_ctl)
|
||||
{
|
||||
@@ -154,32 +154,32 @@ void stim(chanend c_stim_ah, chanend c_stim_de, chanend c_mix_ctl)
|
||||
InitModel(modelMixer);
|
||||
|
||||
GenExpectedSamples(modelMixer, modelOut, modelIn);
|
||||
|
||||
|
||||
/* There is single sample delay between the two mixer cores, so trigger twice to flush though a block
|
||||
* of zero samples */
|
||||
SendTrigger(c_stim_ah, 2);
|
||||
|
||||
/* Send expected samples to AH and DE and run checks */
|
||||
SendTrigger(c_stim_ah, 2);
|
||||
|
||||
/* Send expected samples to AH and DE and run checks */
|
||||
SendExpected(c_stim_ah, c_stim_de, modelOut, modelIn);
|
||||
|
||||
/* Firstly route mixer outputs to the audio interfaces (we could have chosen host)
|
||||
* such that we can observe and check the outputs from the mixer
|
||||
/* Firstly route mixer outputs to the audio interfaces (we could have chosen host)
|
||||
* such that we can observe and check the outputs from the mixer
|
||||
*/
|
||||
for(size_t i = 0; i < MAX_MIX_COUNT; i++)
|
||||
{
|
||||
int map = SET_SAMPLES_TO_DEVICE_MAP;
|
||||
assert(i < NUM_USB_CHAN_OUT);
|
||||
int dst = i;
|
||||
int dst = i;
|
||||
int src = NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN+i; // mix0, mix1..
|
||||
debug_printf("Mapping output to AudioIF: %d ", dst);
|
||||
|
||||
|
||||
PrintDestString(map, dst);
|
||||
debug_printf(" from %d", src);
|
||||
PrintSourceString(src);
|
||||
debug_printf("\n");
|
||||
|
||||
SendTrigger(c_stim_ah, 1);
|
||||
|
||||
SendTrigger(c_stim_ah, 1);
|
||||
|
||||
/* Update the mixer */
|
||||
UpdateMixerOutputRouting(c_mix_ctl, map, dst, src);
|
||||
|
||||
@@ -189,19 +189,19 @@ void stim(chanend c_stim_ah, chanend c_stim_de, chanend c_mix_ctl)
|
||||
|
||||
/* Send expected samples to fake AudioHub and Decouple for checking */
|
||||
SendExpected(c_stim_ah, c_stim_de, modelOut, modelIn);
|
||||
|
||||
|
||||
for(int testIter = 0; testIter < TEST_ITERATIONS; testIter++)
|
||||
{
|
||||
/* Make a random update to the routing - route a random source to a random mix input */
|
||||
unsigned mix = random_get_random_number(rg) % MAX_MIX_COUNT;
|
||||
unsigned input = random_get_random_number(rg) % MIX_INPUTS;
|
||||
|
||||
/* Note, we don't currently support a mix input dervived from another mix
|
||||
* This is not trivial to test since the current mixer implementation only allows for one
|
||||
* config update per "trigger"
|
||||
/* Note, we don't currently support a mix input dervived from another mix
|
||||
* This is not trivial to test since the current mixer implementation only allows for one
|
||||
* config update per "trigger"
|
||||
*/
|
||||
unsigned src = random_get_random_number(rg) % NUM_USB_CHAN_IN + NUM_USB_CHAN_OUT;
|
||||
|
||||
unsigned src = random_get_random_number(rg) % NUM_USB_CHAN_IN + NUM_USB_CHAN_OUT;
|
||||
|
||||
debug_printf("Iteration: %d\n", testIter);
|
||||
MapMixerInput(mix, input, src, modelMixer, c_mix_ctl, c_stim_ah, c_stim_de, modelIn, modelOut);
|
||||
}
|
||||
@@ -209,10 +209,10 @@ void stim(chanend c_stim_ah, chanend c_stim_de, chanend c_mix_ctl)
|
||||
/* Send kill messages to Fake AudioHub & Fake Decouple */
|
||||
outct(c_stim_ah, XS1_CT_END);
|
||||
inct(c_stim_ah);
|
||||
|
||||
|
||||
outct(c_stim_de, XS1_CT_END);
|
||||
inct(c_stim_de);
|
||||
|
||||
|
||||
printstrln("PASS");
|
||||
|
||||
exit(0);
|
||||
@@ -230,7 +230,7 @@ int main()
|
||||
{
|
||||
Fake_XUA_Buffer_Decouple(c_dec_mix, c_stim_de);
|
||||
Fake_XUA_AudioHub(c_mix_aud, c_stim_ah);
|
||||
|
||||
|
||||
/* Mixer from lib_xua */
|
||||
mixer(c_dec_mix, c_mix_aud, c_mix_ctl);
|
||||
|
||||
|
||||
@@ -59,8 +59,8 @@ void Fake_Endpoint0(chanend c_mix_ctl)
|
||||
{
|
||||
XUD_ep ep0_out; /* Never initialised but not used */
|
||||
XUD_ep ep0_in; /* Never initialised but not used */
|
||||
USB_SetupPacket_t sp;
|
||||
|
||||
USB_SetupPacket_t sp;
|
||||
|
||||
random_generator_t rg = random_create_generator_from_seed(TEST_SEED);
|
||||
|
||||
InitLocalMixerState();
|
||||
@@ -74,9 +74,9 @@ void Fake_Endpoint0(chanend c_mix_ctl)
|
||||
unsigned mix = (random_get_random_number(rg) % (MAX_MIX_COUNT + 1)); // Mixs indexed from 1
|
||||
unsigned input = random_get_random_number(rg) % MIX_INPUTS;
|
||||
|
||||
/* Note, we don't currently support a mix input dervived from another mix
|
||||
* This is not trivial to test since the current mixer implementation only allows for one
|
||||
* config update per "trigger"
|
||||
/* Note, we don't currently support a mix input dervived from another mix
|
||||
* This is not trivial to test since the current mixer implementation only allows for one
|
||||
* config update per "trigger"
|
||||
*/
|
||||
unsigned src = random_get_random_number(rg) % (NUM_USB_CHAN_IN + NUM_USB_CHAN_OUT);
|
||||
|
||||
@@ -89,13 +89,13 @@ void Fake_Endpoint0(chanend c_mix_ctl)
|
||||
int cs = mix;
|
||||
int cn = input;
|
||||
sp.bmRequestType.Direction = USB_BM_REQTYPE_DIRECTION_H2D;
|
||||
sp.bRequest = CUR;
|
||||
sp.wValue = cn | (cs << 8);
|
||||
sp.bRequest = CUR;
|
||||
sp.wValue = cn | (cs << 8);
|
||||
sp.wIndex = (unitId << 8);
|
||||
sp.wLength = 1;
|
||||
|
||||
g_src = src; /* This will get picked up by out implementation of XUD_GetBuffer */
|
||||
|
||||
|
||||
/* Call the function used by Endpoint0 to parse the control data and update the mixer output routing */
|
||||
AudioClassRequests_2(ep0_out, ep0_in, sp, null, c_mix_ctl, null);
|
||||
|
||||
@@ -105,11 +105,11 @@ void Fake_Endpoint0(chanend c_mix_ctl)
|
||||
* mixer and endpoint 0 state.
|
||||
*
|
||||
* Going forward we might wish to enhance the mixer API such that it can be tested as a black box.
|
||||
* This would require the addition of "GET" API over it's ctrl channel
|
||||
* This would require the addition of "GET" API over it's ctrl channel
|
||||
*/
|
||||
|
||||
sp.bmRequestType.Direction = USB_BM_REQTYPE_DIRECTION_D2H;
|
||||
|
||||
|
||||
if(mix == 0)
|
||||
{
|
||||
/* If mix is 0 then we need to check that all mixers have been updated */
|
||||
@@ -125,7 +125,7 @@ void Fake_Endpoint0(chanend c_mix_ctl)
|
||||
else
|
||||
{
|
||||
assert(g_src == mixSel[cs-1][cn]);
|
||||
|
||||
|
||||
/* Test read back. Note, the checking is in our overridden implementation of XUD_SetBuffer_EpMax*/
|
||||
AudioClassRequests_2(ep0_out, ep0_in, sp, null, c_mix_ctl, null);
|
||||
}
|
||||
@@ -134,10 +134,10 @@ void Fake_Endpoint0(chanend c_mix_ctl)
|
||||
|
||||
printstrln("PASS");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
void Fake_XUA_AudioHub_CtrlTest(chanend c_mix_aud)
|
||||
{
|
||||
{
|
||||
int readBuffNo = 0;
|
||||
unsigned underflowWord = 0;
|
||||
|
||||
@@ -149,7 +149,7 @@ void Fake_XUA_AudioHub_CtrlTest(chanend c_mix_aud)
|
||||
}
|
||||
|
||||
void Fake_XUA_Buffer_Decouple_CtrlTest(chanend c_dec_mix)
|
||||
{
|
||||
{
|
||||
unsigned samplesIn[NUM_USB_CHAN_IN];
|
||||
unsigned underflowSample;
|
||||
|
||||
@@ -169,7 +169,7 @@ void Fake_XUA_Buffer_Decouple_CtrlTest(chanend c_dec_mix)
|
||||
{
|
||||
samplesIn[i] = inuint(c_dec_mix);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -183,7 +183,7 @@ int main()
|
||||
|
||||
par
|
||||
{
|
||||
/* We need "fake" versions of the AudioHub and Decouple to keep the mixer running and taking updates via
|
||||
/* We need "fake" versions of the AudioHub and Decouple to keep the mixer running and taking updates via
|
||||
* it's control channel */
|
||||
Fake_XUA_Buffer_Decouple_CtrlTest(c_dec_mix);
|
||||
Fake_XUA_AudioHub_CtrlTest(c_mix_aud);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2022-2023 XMOS LIMITED.
|
||||
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
|
||||
|
||||
/* Tests that routing of mixer outputs behaves as expected
|
||||
/* Tests that routing of mixer outputs behaves as expected
|
||||
*
|
||||
* "Outputs" from the device are to the USB host of one of the various audio interaces supported.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* each of the M mixer units is as follows:
|
||||
*
|
||||
* MIXER[0]:
|
||||
* USB_FROM_HOST[0] -> MIXER[0].INPUT[0]
|
||||
* USB_FROM_HOST[0] -> MIXER[0].INPUT[0]
|
||||
* USB_FROM_HOST[1] -> MIXER[0].INPUT[1]
|
||||
* ...
|
||||
USB_TO_HOST[0] -> MIXER[0].INPUT[NUM_USB_CHAN_OUT]
|
||||
@@ -26,7 +26,7 @@
|
||||
...
|
||||
|
||||
* MIXER[MAX_MIX_COUNT-1]:
|
||||
* USB_FROM_HOST[0] -> MIXER[MAX_MIX_COUNT-1].INPUT[0]
|
||||
* USB_FROM_HOST[0] -> MIXER[MAX_MIX_COUNT-1].INPUT[0]
|
||||
* USB_FROM_HOST[1] -> MIXER[MAX_MIX_COUNT-1].INPUT[1]
|
||||
* ...
|
||||
*
|
||||
@@ -47,7 +47,7 @@
|
||||
#include "assert.h"
|
||||
#include "random.h"
|
||||
|
||||
#ifndef TEST_ITERATIONS
|
||||
#ifndef TEST_ITERATIONS
|
||||
#define TEST_ITERATIONS (100)
|
||||
#endif
|
||||
|
||||
@@ -72,7 +72,7 @@ void UpdateModel(uint32_t modelOut[CHANNEL_MAP_AUD_SIZE], uint32_t modelMixerOut
|
||||
src -= NUM_USB_CHAN_OUT;
|
||||
SET_CHANNEL(sample, src);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
SET_SOURCE(sample, SRC_HOST);
|
||||
SET_CHANNEL(sample, src);
|
||||
@@ -83,19 +83,19 @@ void UpdateModel(uint32_t modelOut[CHANNEL_MAP_AUD_SIZE], uint32_t modelMixerOut
|
||||
case SET_SAMPLES_TO_DEVICE_MAP:
|
||||
modelOut[dst] = sample;
|
||||
break;
|
||||
|
||||
|
||||
case SET_SAMPLES_TO_HOST_MAP:
|
||||
modelIn[dst] = sample;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* This task configures the routing and maintains a model of the expected routing output
|
||||
* it provides this to the Fake AudioHub and Fake Decouple tasks such that they can self check
|
||||
/* This task configures the routing and maintains a model of the expected routing output
|
||||
* it provides this to the Fake AudioHub and Fake Decouple tasks such that they can self check
|
||||
*/
|
||||
void stim(chanend c_stim_ah, chanend c_stim_de, chanend c_mix_ctl)
|
||||
{
|
||||
@@ -147,7 +147,7 @@ void stim(chanend c_stim_ah, chanend c_stim_de, chanend c_mix_ctl)
|
||||
/* Make a random update to the routing - route a random source to a random destination */
|
||||
unsigned map = testCmd[random_get_random_number(rg) % (sizeof(testCmd)/sizeof(testCmd[0]))];
|
||||
unsigned dst = random_get_random_number(rg) % CHANNEL_MAP_AUD_SIZE; // TODO this should be CHANNEL_MAP_USB_SIZE for SET_SAMPLES_TO_HOST_MAP
|
||||
unsigned src = random_get_random_number(rg) % (NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + MAX_MIX_COUNT);
|
||||
unsigned src = random_get_random_number(rg) % (NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + MAX_MIX_COUNT);
|
||||
|
||||
switch(map)
|
||||
{
|
||||
@@ -160,7 +160,7 @@ void stim(chanend c_stim_ah, chanend c_stim_de, chanend c_mix_ctl)
|
||||
|
||||
/* Update the mixer */
|
||||
SendTrigger(c_stim_ah, 1);
|
||||
UpdateMixerOutputRouting(c_mix_ctl, map, dst, src);
|
||||
UpdateMixerOutputRouting(c_mix_ctl, map, dst, src);
|
||||
break;
|
||||
|
||||
case SET_SAMPLES_TO_HOST_MAP:
|
||||
@@ -169,10 +169,10 @@ void stim(chanend c_stim_ah, chanend c_stim_de, chanend c_mix_ctl)
|
||||
debug_printf(" from %d", src);
|
||||
PrintSourceString(src);
|
||||
debug_printf("\n");
|
||||
|
||||
|
||||
/* Update the mixer */
|
||||
SendTrigger(c_stim_ah, 1);
|
||||
UpdateMixerOutputRouting(c_mix_ctl, map, dst, src);
|
||||
UpdateMixerOutputRouting(c_mix_ctl, map, dst, src);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -191,10 +191,10 @@ void stim(chanend c_stim_ah, chanend c_stim_de, chanend c_mix_ctl)
|
||||
/* Send kill messages to Fake AudioHub & Fake Decouple */
|
||||
outct(c_stim_ah, XS1_CT_END);
|
||||
inct(c_stim_ah);
|
||||
|
||||
|
||||
outct(c_stim_de, XS1_CT_END);
|
||||
inct(c_stim_de);
|
||||
|
||||
|
||||
printstrln("PASS");
|
||||
exit(0);
|
||||
}
|
||||
@@ -211,7 +211,7 @@ int main()
|
||||
{
|
||||
Fake_XUA_Buffer_Decouple(c_dec_mix, c_stim_de);
|
||||
Fake_XUA_AudioHub(c_mix_aud, c_stim_ah);
|
||||
|
||||
|
||||
/* Mixer from lib_xua */
|
||||
mixer(c_dec_mix, c_mix_aud, c_mix_ctl);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
/* A limitation of the design is that the number of routable output destinations cannot be larger than NUM_USB_CHAN_OUT.
|
||||
* This is due to the transfer samples from Mixer to AudioHub tasks being in blocks of NUM_USB_CHAN_OUT.
|
||||
* This is not normally an issue - since every physical output interface channel on the device is normally derived from a
|
||||
* This is not normally an issue - since every physical output interface channel on the device is normally derived from a
|
||||
* USB channel from the host, but it certainly is a restriction.
|
||||
*/
|
||||
#define CHANNEL_MAP_AUD_SIZE NUM_USB_CHAN_OUT
|
||||
@@ -14,7 +14,7 @@
|
||||
#define CHANNEL_MAP_USB_SIZE NUM_USB_CHAN_IN
|
||||
|
||||
/* Number of channel sources, the channel ordering is as follows
|
||||
* i.e.
|
||||
* i.e.
|
||||
* [0:NUM_USB_CHAN_OUT-1] : Channels from USB Host
|
||||
* [NUM_USB_CHAN_OUT:NUM_USB_CHAN_IN-1] : Channels from Audio Interfaces
|
||||
* [NUM_USB_CHAN_N:MAX_MIX_COUNT-1] : Channels from Mixers
|
||||
@@ -59,7 +59,7 @@ void SendTrigger(chanend c_stim_ah, int count)
|
||||
uint32_t CreateSample(uint32_t modelMixerOutput[], int src)
|
||||
{
|
||||
uint32_t sample = 0;
|
||||
|
||||
|
||||
if(src == (NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + MAX_MIX_COUNT))
|
||||
{
|
||||
SET_SOURCE(sample, SRC_OFF);
|
||||
@@ -75,7 +75,7 @@ uint32_t CreateSample(uint32_t modelMixerOutput[], int src)
|
||||
src -= NUM_USB_CHAN_OUT;
|
||||
SET_CHANNEL(sample, src);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
SET_SOURCE(sample, SRC_HOST);
|
||||
SET_CHANNEL(sample, src);
|
||||
@@ -177,7 +177,7 @@ void SendExpected(chanend c_stim_ah, chanend c_stim_de, uint32_t modelOut[], uin
|
||||
outuint(c_stim_ah, SET_EXPECTED);
|
||||
|
||||
for(int i = 0; i < CHANNEL_MAP_AUD_SIZE; i++)
|
||||
{
|
||||
{
|
||||
outuint(c_stim_ah, modelOut[i]);
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ void SendExpected(chanend c_stim_ah, chanend c_stim_de, uint32_t modelOut[], uin
|
||||
/* Send expected to Decouple */
|
||||
outuint(c_stim_de, SET_EXPECTED);
|
||||
for(int i = 0; i < NUM_USB_CHAN_IN; i++)
|
||||
{
|
||||
{
|
||||
outuint(c_stim_de, modelIn[i]);
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ extern unsigned samplesIn[2][NUM_USB_CHAN_IN];
|
||||
#include "xua_audiohub_st.h"
|
||||
|
||||
int Fake_XUA_AudioHub(chanend c_mix_aud, chanend c_stim)
|
||||
{
|
||||
{
|
||||
int readBuffNo = 0;
|
||||
unsigned underflowWord = 0;
|
||||
uint32_t expectedOut[NUM_USB_CHAN_OUT];
|
||||
@@ -222,35 +222,35 @@ int Fake_XUA_AudioHub(chanend c_mix_aud, chanend c_stim)
|
||||
|
||||
while(!ct)
|
||||
{
|
||||
|
||||
|
||||
select
|
||||
{
|
||||
case testct_byref(c_stim, ct):
|
||||
|
||||
if(!ct)
|
||||
{
|
||||
cmd = inuint(c_stim);
|
||||
|
||||
cmd = inuint(c_stim);
|
||||
|
||||
switch(cmd)
|
||||
{
|
||||
case SET_EXPECTED:
|
||||
|
||||
|
||||
for(int j = 0; j < NUM_USB_CHAN_OUT; j++)
|
||||
{
|
||||
expectedOut[j] = inuint(c_stim);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
debug_printf("AudioHub:\n");
|
||||
CheckBlock(samplesOut, expectedOut, NUM_USB_CHAN_OUT);
|
||||
/* Handshake back */
|
||||
outuint(c_stim, 0);
|
||||
break;
|
||||
|
||||
|
||||
case TRIGGER:
|
||||
/* This will populate samplesOut and send out samplesIn[readBuffNo] */
|
||||
unsigned command = DoSampleTransfer(c_mix_aud, readBuffNo, underflowWord);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
printstr("ERROR: bad cmd in Fake_XUA_AudioHub: ");
|
||||
printintln(cmd);
|
||||
@@ -268,7 +268,7 @@ int Fake_XUA_AudioHub(chanend c_mix_aud, chanend c_stim)
|
||||
}
|
||||
|
||||
int Fake_XUA_Buffer_Decouple(chanend c_dec_mix, chanend c_stim)
|
||||
{
|
||||
{
|
||||
uint32_t expectedSamplesIn[NUM_USB_CHAN_IN];
|
||||
unsigned samplesIn[NUM_USB_CHAN_IN];
|
||||
unsigned ct;
|
||||
@@ -292,21 +292,21 @@ int Fake_XUA_Buffer_Decouple(chanend c_dec_mix, chanend c_stim)
|
||||
{
|
||||
samplesIn[i] = inuint(c_dec_mix);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case testct_byref(c_stim, ct):
|
||||
|
||||
if(!ct)
|
||||
{
|
||||
inuint(c_stim); // TODO don't really need this
|
||||
inuint(c_stim); // TODO don't really need this
|
||||
|
||||
/* Get expected */
|
||||
for(int j = 0; j < NUM_USB_CHAN_IN; j++)
|
||||
{
|
||||
expectedSamplesIn[j] = inuint(c_stim);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
debug_printf("Decouple:\n");
|
||||
CheckBlock(samplesIn, expectedSamplesIn, NUM_USB_CHAN_IN);
|
||||
|
||||
@@ -316,7 +316,7 @@ int Fake_XUA_Buffer_Decouple(chanend c_dec_mix, chanend c_stim)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
outct(c_stim, XS1_CT_END);
|
||||
inct(c_stim);
|
||||
return 0;
|
||||
|
||||
@@ -61,8 +61,8 @@ void Fake_Endpoint0(chanend c_mix_ctl)
|
||||
XUD_ep ep0_out; /* Never initialised but not used */
|
||||
XUD_ep ep0_in; /* Never initialised but not used */
|
||||
unsigned unitIds[] = {ID_XU_OUT, ID_XU_IN};
|
||||
USB_SetupPacket_t sp;
|
||||
|
||||
USB_SetupPacket_t sp;
|
||||
|
||||
random_generator_t rg = random_create_generator_from_seed(TEST_SEED);
|
||||
|
||||
InitLocalMixerState();
|
||||
@@ -74,7 +74,7 @@ void Fake_Endpoint0(chanend c_mix_ctl)
|
||||
{
|
||||
int unitId = unitIds[random_get_random_number(rg) % (sizeof(unitIds)/sizeof(unitIds[0]))];
|
||||
unsigned dst = random_get_random_number(rg);
|
||||
|
||||
|
||||
/* Note, we don't currently support a mix input derived from another mix
|
||||
* This is not trivial to test since the current mixer implementation only allows for one
|
||||
* config update per "trigger"
|
||||
@@ -107,13 +107,13 @@ void Fake_Endpoint0(chanend c_mix_ctl)
|
||||
|
||||
/* Create Control request data for routing change */
|
||||
sp.bmRequestType.Direction = USB_BM_REQTYPE_DIRECTION_H2D;
|
||||
sp.bRequest = CUR;
|
||||
sp.wValue = dst & 0xff;
|
||||
sp.bRequest = CUR;
|
||||
sp.wValue = dst & 0xff;
|
||||
sp.wIndex = (unitId << 8);
|
||||
sp.wLength = 1;
|
||||
|
||||
g_src = src; /* This will get picked up by out implementation of XUD_GetBuffer */
|
||||
|
||||
|
||||
/* Call the function used by Endpoint0() to parse the control data and update the mixer output routing */
|
||||
AudioClassRequests_2(ep0_out, ep0_in, sp, null, c_mix_ctl, null);
|
||||
|
||||
@@ -123,7 +123,7 @@ void Fake_Endpoint0(chanend c_mix_ctl)
|
||||
* mixer and endpoint 0 state.
|
||||
*
|
||||
* Going forward we might wish to enhance the mixer API such that it can be tested as a black box.
|
||||
* This would require the addition of "GET" API over it's ctrl channel
|
||||
* This would require the addition of "GET" API over it's ctrl channel
|
||||
*/
|
||||
switch(unitId)
|
||||
{
|
||||
@@ -155,10 +155,10 @@ void Fake_Endpoint0(chanend c_mix_ctl)
|
||||
|
||||
printstrln("PASS");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
void Fake_XUA_AudioHub_CtrlTest(chanend c_mix_aud)
|
||||
{
|
||||
{
|
||||
int readBuffNo = 0;
|
||||
unsigned underflowWord = 0;
|
||||
|
||||
@@ -170,7 +170,7 @@ void Fake_XUA_AudioHub_CtrlTest(chanend c_mix_aud)
|
||||
}
|
||||
|
||||
void Fake_XUA_Buffer_Decouple_CtrlTest(chanend c_dec_mix)
|
||||
{
|
||||
{
|
||||
unsigned samplesIn[NUM_USB_CHAN_IN];
|
||||
unsigned underflowSample;
|
||||
|
||||
@@ -190,7 +190,7 @@ void Fake_XUA_Buffer_Decouple_CtrlTest(chanend c_dec_mix)
|
||||
{
|
||||
samplesIn[i] = inuint(c_dec_mix);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ int main()
|
||||
|
||||
par
|
||||
{
|
||||
/* We need "fake" versions of the AudioHub and Decouple to keep the mixer running and taking updates via
|
||||
/* We need "fake" versions of the AudioHub and Decouple to keep the mixer running and taking updates via
|
||||
* it's control channel */
|
||||
Fake_XUA_Buffer_Decouple_CtrlTest(c_dec_mix);
|
||||
Fake_XUA_AudioHub_CtrlTest(c_mix_aud);
|
||||
|
||||
Reference in New Issue
Block a user