Merge pull request #392 from shuchitak/fix/alt_itf_out_chan_count

Fix/alt itf out chan count
This commit is contained in:
danielpieczko
2024-05-21 09:14:34 +01:00
committed by GitHub
3 changed files with 58 additions and 51 deletions

View File

@@ -16,6 +16,8 @@ UNRELEASED
* CHANGED: aud_to_host buffer size and the condition to come out of underflow
in decoupler to fix buffer underflow seen in ADAT tests
* FIXED: Initialise SMUX based on DEFAULT_FREQ in clockgen
* FIXED: Update g_numUsbChan_Out to the number of channels for the selected
interface when receiving a set interface request over EP0
4.0.0
-----

View File

@@ -155,68 +155,65 @@ unsigned unpackData = 0;
unsigned packState = 0;
unsigned packData = 0;
static inline void SendSamples4(chanend c_mix_out)
static inline void _send_sample_4(chanend c_mix_out, int ch)
{
/* Doing this checking allows us to unroll */
if(g_numUsbChan_Out == NUM_USB_CHAN_OUT)
{
/* Buffering not underflow condition send out some samples...*/
#pragma loop unroll
for(int i = 0; i < NUM_USB_CHAN_OUT; i++)
{
int sample;
int mult;
int h;
unsigned l;
read_via_xc_ptr(sample, g_aud_from_host_rdptr);
g_aud_from_host_rdptr+=4;
int sample;
read_via_xc_ptr(sample, g_aud_from_host_rdptr);
g_aud_from_host_rdptr+=4;
#if (OUTPUT_VOLUME_CONTROL == 1) && (!OUT_VOLUME_IN_MIXER)
unsafe
{
mult = multOutPtr[i];
}
{h, l} = macs(mult, sample, 0, 0);
h <<= 3;
int mult;
int h;
unsigned l;
unsafe
{
mult = multOutPtr[ch];
}
{h, l} = macs(mult, sample, 0, 0);
h <<= 3;
#if (STREAM_FORMAT_OUTPUT_RESOLUTION_32BIT_USED == 1)
h |= (l >>29) & 0x7; // Note: This step is not required if we assume sample depth is 24bit (rather than 32bit)
// Note: We need all 32bits for Native DSD
h |= (l >>29) & 0x7; // Note: This step is not required if we assume sample depth is 24bit (rather than 32bit)
// Note: We need all 32bits for Native DSD
#endif
outuint(c_mix_out, h);
outuint(c_mix_out, h);
#else
outuint(c_mix_out, sample);
outuint(c_mix_out, sample);
#endif
}
static inline void SendSamples4(chanend c_mix_out)
{
/* Doing this allows us to unroll */
if(g_numUsbChan_Out == HS_STREAM_FORMAT_OUTPUT_1_CHAN_COUNT)
{
#pragma loop unroll
for(int i = 0; i < HS_STREAM_FORMAT_OUTPUT_1_CHAN_COUNT; i++)
{
_send_sample_4(c_mix_out, i);
}
}
else if(g_numUsbChan_Out == HS_STREAM_FORMAT_OUTPUT_2_CHAN_COUNT)
{
#pragma loop unroll
for(int i = 0; i < HS_STREAM_FORMAT_OUTPUT_2_CHAN_COUNT; i++)
{
_send_sample_4(c_mix_out, i);
}
}
else if(g_numUsbChan_Out == HS_STREAM_FORMAT_OUTPUT_3_CHAN_COUNT)
{
#pragma loop unroll
for(int i = 0; i < HS_STREAM_FORMAT_OUTPUT_3_CHAN_COUNT; i++)
{
_send_sample_4(c_mix_out, i);
}
}
else
{
#pragma loop unroll
#pragma loop unroll
for(int i = 0; i < NUM_USB_CHAN_OUT_FS; i++)
{
int sample;
int mult;
int h;
unsigned l;
read_via_xc_ptr(sample, g_aud_from_host_rdptr);
g_aud_from_host_rdptr+=4;
#if (OUTPUT_VOLUME_CONTROL == 1) && (!OUT_VOLUME_IN_MIXER)
unsafe
{
mult = multOutPtr[i];
}
{h, l} = macs(mult, sample, 0, 0);
h <<= 3;
#if (STREAM_FORMAT_OUTPUT_RESOLUTION_32BIT_USED == 1)
h |= (l >>29) & 0x7; // Note: This step is not required if we assume sample depth is 24bit (rather than 32bit)
// Note: We need all 32bits for Native DSD
#endif
outuint(c_mix_out, h);
#else
outuint(c_mix_out, sample);
#endif
_send_sample_4(c_mix_out, i);
}
}
}

View File

@@ -245,7 +245,6 @@ const unsigned g_dataFormat_In[INPUT_FORMAT_COUNT] = {STREAM_FORMAT_INPUT_1
};
/* Channel count */
/* Note, currently only input changes.. */
const unsigned g_chanCount_In_HS[INPUT_FORMAT_COUNT] = {HS_STREAM_FORMAT_INPUT_1_CHAN_COUNT,
#if(INPUT_FORMAT_COUNT > 1)
HS_STREAM_FORMAT_INPUT_2_CHAN_COUNT,
@@ -255,6 +254,15 @@ const unsigned g_chanCount_In_HS[INPUT_FORMAT_COUNT] = {HS_STREAM_FORMAT_I
#endif
};
const unsigned g_chanCount_Out_HS[OUTPUT_FORMAT_COUNT] = {HS_STREAM_FORMAT_OUTPUT_1_CHAN_COUNT,
#if(OUTPUT_FORMAT_COUNT > 1)
HS_STREAM_FORMAT_OUTPUT_2_CHAN_COUNT,
#endif
#if(OUTPUT_FORMAT_COUNT > 2)
HS_STREAM_FORMAT_OUTPUT_3_CHAN_COUNT
#endif
};
XUD_ep ep0_out;
XUD_ep ep0_in;
@@ -580,7 +588,7 @@ void XUA_Endpoint0_loop(XUD_Result_t result, USB_SetupPacket_t sp, chanend c_ep0
if(g_curUsbSpeed == XUD_SPEED_HS)
{
outuint(c_audioControl, NUM_USB_CHAN_OUT); /* Channel count */
outuint(c_audioControl, g_chanCount_Out_HS[sp.wValue-1]); /* Channel count */
outuint(c_audioControl, g_subSlot_Out_HS[sp.wValue-1]); /* Subslot */
outuint(c_audioControl, g_sampRes_Out_HS[sp.wValue-1]); /* Resolution */
}