Resolved communication mismatch when mixer enabled (major issues on displayed with larger channel counts)

This commit is contained in:
xross
2018-02-08 15:46:37 +00:00
parent 0c158a4970
commit ba1c882210

View File

@@ -149,7 +149,6 @@ static inline int doMix(xc_ptr samples, xc_ptr ptr, xc_ptr mult)
if(l != h) if(l != h)
{ {
//if(h < 0)
if(h>>32) if(h>>32)
h = (0x80000000>>7); h = (0x80000000>>7);
else else
@@ -363,10 +362,12 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
/* Request from audio()/mixer2() */ /* Request from audio()/mixer2() */
request = inuint(c_mixer2); request = inuint(c_mixer2);
/* Forward on Request for data to decouple thread */ /* Forward on Request for data to decouple thread */
outuint(c_host, request); outuint(c_host, request);
/* Sync */
outuint(c_mixer2, 0);
/* Between request to decouple and response ~ 400nS latency for interrupt to fire */ /* Between request to decouple and response ~ 400nS latency for interrupt to fire */
select select
{ {
@@ -380,11 +381,7 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
index = inuint(c_mix_ctl); index = inuint(c_mix_ctl);
val = inuint(c_mix_ctl); val = inuint(c_mix_ctl);
inct(c_mix_ctl); inct(c_mix_ctl);
write_via_xc_ptr_indexed(samples_to_host_map, index, val);
write_via_xc_ptr_indexed(samples_to_host_map,
index,
val);
break; break;
case SET_SAMPLES_TO_DEVICE_MAP: case SET_SAMPLES_TO_DEVICE_MAP:
@@ -412,7 +409,6 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
setPtr(index, val, mix); setPtr(index, val, mix);
#else #else
write_word_to_mix_map(mix, index, val); write_word_to_mix_map(mix, index, val);
#endif #endif
break; break;
#endif /* if MAX_MIX_COUNT > 0 */ #endif /* if MAX_MIX_COUNT > 0 */
@@ -537,16 +533,15 @@ static void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
} }
else else
{ {
#if MAX_MIX_COUNT > 0 #if MAX_MIX_COUNT > 0
outuint(c_mixer2, 0); GetSamplesFromHost(c_host);
GiveSamplesToHost(c_host, samples_to_host_map, multIn); GiveSamplesToHost(c_host, samples_to_host_map, multIn);
/* Sync with mixer 2 (once it has swapped samples with audiohub) */
outuint(c_mixer2, 0); outuint(c_mixer2, 0);
inuint(c_mixer2); inuint(c_mixer2);
GetSamplesFromHost(c_host);
outuint(c_mixer2, 0); /* Do the mixing */
inuint(c_mixer2);
#ifdef FAST_MIXER #ifdef FAST_MIXER
mixed = doMix0(samples, mix_mult_slice(0)); mixed = doMix0(samples, mix_mult_slice(0));
#else #else
@@ -633,6 +628,9 @@ static void mixer2(chanend c_mixer1, chanend c_audio)
/* Forward the request on */ /* Forward the request on */
outuint(c_mixer1, request); outuint(c_mixer1, request);
/* Sync */
inuint(c_mixer1);
if(testct(c_mixer1)) if(testct(c_mixer1))
{ {
int sampFreq; int sampFreq;
@@ -667,86 +665,82 @@ static void mixer2(chanend c_mixer1, chanend c_audio)
write_via_xc_ptr_indexed(samples, (NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + i), 0); write_via_xc_ptr_indexed(samples, (NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + i), 0);
} }
/* Inform audio thread about freq change */
//outct(c_audio, XS1_CT_END);
//outuint(c_audio, sampFreq);
/* Wait for handshake and pass on */ /* Wait for handshake and pass on */
chkct(c_audio, XS1_CT_END); chkct(c_audio, XS1_CT_END);
outct(c_mixer1, XS1_CT_END); outct(c_mixer1, XS1_CT_END);
} }
else else
{ {
(void) inuint(c_mixer1);
GiveSamplesToDevice(c_audio, samples_to_device_map, multOut); GiveSamplesToDevice(c_audio, samples_to_device_map, multOut);
inuint(c_mixer1);
outuint(c_mixer1, 0);
GetSamplesFromDevice(c_audio); GetSamplesFromDevice(c_audio);
/* Sync with mixer 1 (once it has swapped samples with the buffering sub-system) */
inuint(c_mixer1); inuint(c_mixer1);
outuint(c_mixer1, 0); outuint(c_mixer1, 0);
/* Do the mixing */
#if MAX_MIX_COUNT > 1 #if MAX_MIX_COUNT > 1
#ifdef FAST_MIXER #ifdef FAST_MIXER
mixed = doMix1(samples, mix_mult_slice(1)); mixed = doMix1(samples, mix_mult_slice(1));
#else #else
mixed = doMix(samples, mix_map_slice(1),mix_mult_slice(1)); 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); write_via_xc_ptr_indexed(samples, (NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + 1), mixed);
#if defined (LEVEL_METER_HOST) || defined(LEVEL_METER_LEDS) #if defined (LEVEL_METER_HOST) || defined(LEVEL_METER_LEDS)
ComputeMixerLevel(mixed, 1); ComputeMixerLevel(mixed, 1);
#endif #endif
#endif #endif
#if (MAX_FREQ > 96000) #if (MAX_FREQ > 96000)
if (!mixer2_mix2_flag) /* Fewer mixes when running higher than 96kHz */
if (!mixer2_mix2_flag)
#endif #endif
{ {
#if MAX_MIX_COUNT > 3 #if MAX_MIX_COUNT > 3
#ifdef FAST_MIXER #ifdef FAST_MIXER
mixed = doMix3(samples, mix_mult_slice(3)); mixed = doMix3(samples, mix_mult_slice(3));
#else #else
mixed = doMix(samples, mix_map_slice(3),mix_mult_slice(3)); mixed = doMix(samples, mix_map_slice(3),mix_mult_slice(3));
#endif #endif
write_via_xc_ptr_indexed(samples, (NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + 3), mixed); write_via_xc_ptr_indexed(samples, (NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + 3), mixed);
#if defined (LEVEL_METER_HOST) || defined(LEVEL_METER_LEDS) #if defined (LEVEL_METER_HOST) || defined(LEVEL_METER_LEDS)
ComputeMixerLevel(mixed, 3); ComputeMixerLevel(mixed, 3);
#endif #endif
#endif #endif
#if MAX_MIX_COUNT > 5 #if MAX_MIX_COUNT > 5
#ifdef FAST_MIXER #ifdef FAST_MIXER
mixed = doMix5(samples, mix_mult_slice(5)); mixed = doMix5(samples, mix_mult_slice(5));
#else #else
mixed = doMix(samples, mix_map_slice(5),mix_mult_slice(5)); mixed = doMix(samples, mix_map_slice(5),mix_mult_slice(5));
#endif #endif
write_via_xc_ptr_indexed(samples, NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + 5, mixed); write_via_xc_ptr_indexed(samples, NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + 5, mixed);
#if defined (LEVEL_METER_HOST) || defined(LEVEL_METER_LEDS) #if defined (LEVEL_METER_HOST) || defined(LEVEL_METER_LEDS)
ComputeMixerLevel(mixed, 5); ComputeMixerLevel(mixed, 5);
#endif #endif
#endif #endif
#if MAX_MIX_COUNT > 7 #if MAX_MIX_COUNT > 7
#ifdef FAST_MIXER #ifdef FAST_MIXER
mixed = doMix7(samples, mix_mult_slice(7)); mixed = doMix7(samples, mix_mult_slice(7));
#else #else
mixed = doMix(samples, mix_map_slice(7),mix_mult_slice(7)); mixed = doMix(samples, mix_map_slice(7),mix_mult_slice(7));
#endif #endif
write_via_xc_ptr_indexed(samples, NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + 7, mixed); write_via_xc_ptr_indexed(samples, NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + 7, mixed);
#if defined (LEVEL_METER_HOST) || defined(LEVEL_METER_LEDS) #if defined (LEVEL_METER_HOST) || defined(LEVEL_METER_LEDS)
ComputeMixerLevel(mixed, 7); ComputeMixerLevel(mixed, 7);
#endif #endif
#endif #endif
} }
}
} }
}
} }
#endif #endif