diff --git a/module_usb_aud_shared/audio.xc b/module_usb_aud_shared/audio.xc index 42cbd908..811832cc 100755 --- a/module_usb_aud_shared/audio.xc +++ b/module_usb_aud_shared/audio.xc @@ -60,7 +60,7 @@ extern void device_reboot(void); /* I2S delivery thread */ #pragma unsafe arrays -unsigned deliver(chanend c_out, chanend c_spd_out, unsigned divide, chanend ?c_dig_rx) +unsigned deliver(chanend c_out, chanend ?c_spd_out, unsigned divide, chanend ?c_dig_rx) { unsigned sample; #if NUM_USB_CHAN_OUT > 0 @@ -515,7 +515,9 @@ static unsigned dummy_deliver(chanend c_out) { void audio(chanend c_mix_out, chanend ?c_dig_rx, chanend ?c_config) { +#ifdef SPDIF chan c_spdif_out; +#endif unsigned curSamFreq = DEFAULT_FREQ; unsigned mClk; unsigned divide; @@ -589,7 +591,13 @@ void audio(chanend c_mix_out, chanend ?c_dig_rx, chanend ?c_config) outuint(c_spdif_out, mClk); #endif - curSamFreq = deliver(c_mix_out, c_spdif_out, divide, c_dig_rx); + curSamFreq = deliver(c_mix_out, +#ifdef SPDIF + c_spdif_out, +#else + null, +#endif + divide, c_dig_rx); // Currently no more audio will happen after this point if (curSamFreq == AUDIO_STOP_FOR_DFU) diff --git a/module_usb_aud_shared/endpoint0/audiorequests.xc b/module_usb_aud_shared/endpoint0/audiorequests.xc index f14ecc3d..2cde9948 100644 --- a/module_usb_aud_shared/endpoint0/audiorequests.xc +++ b/module_usb_aud_shared/endpoint0/audiorequests.xc @@ -35,6 +35,7 @@ extern int volsIn[]; extern unsigned int mutesIn[]; /* Mixer settings */ +#ifdef MIXER extern unsigned char mixer1Crossbar[]; extern short mixer1Weights[]; @@ -48,6 +49,7 @@ extern unsigned char channelMapUsb[NUM_USB_CHAN_IN]; /* Mixer input mapping */ extern unsigned char mixSel[MIX_INPUTS]; +#endif /* Global var for current frequency */ extern unsigned int g_curSamFreq; @@ -863,9 +865,6 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, SetupPacket &sp, chanend int num_freqs = 0; int i = 2; - if(interfaceAlt[1] != 0) - printint(interfaceAlt[1]); - #if MAX_FREQ >= 44100 storeFreq(buffer, i, 44100); num_freqs++; diff --git a/module_usb_aud_shared/endpoint0/endpoint0.xc b/module_usb_aud_shared/endpoint0/endpoint0.xc index ba897759..393d670e 100755 --- a/module_usb_aud_shared/endpoint0/endpoint0.xc +++ b/module_usb_aud_shared/endpoint0/endpoint0.xc @@ -63,6 +63,7 @@ int volsIn[NUM_USB_CHAN_IN + 1]; unsigned int mutesIn[NUM_USB_CHAN_IN + 1]; //unsigned int multIn[NUM_USB_CHAN_IN + 1]; +#ifdef MIXER unsigned char mixer1Crossbar[18]; short mixer1Weights[18*8]; //#define MAX_MIX_COUNT 8 @@ -75,6 +76,7 @@ unsigned char channelMapAud[NUM_USB_CHAN_OUT]; unsigned char channelMapUsb[NUM_USB_CHAN_IN]; #endif unsigned char mixSel[MIX_INPUTS]; +#endif int min(int x, int y); @@ -161,6 +163,7 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, mutesIn[i] = 0; } +#ifdef MIXER /* Set up mixer default state */ for (int i = 0; i < 18*8; i++) { mixer1Weights[i] = 0x8001; //-inf @@ -210,6 +213,7 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, { mixSel[i] = i; } +#endif /* Copy langIDs string desc into string[0] */ /* TODO: Macro? */ diff --git a/module_usb_aud_shared/usb_buffer/decouple.xc b/module_usb_aud_shared/usb_buffer/decouple.xc index 861f2b0f..3377047f 100644 --- a/module_usb_aud_shared/usb_buffer/decouple.xc +++ b/module_usb_aud_shared/usb_buffer/decouple.xc @@ -165,17 +165,21 @@ static inline void swap(xc_ptr &a, xc_ptr &b) } // shared global midi buffering variables +#ifdef MIDI unsigned g_midi_from_host_flag = 0; unsigned g_midi_to_host_flag = 0; int midi_to_host_usb_ep = 0; int midi_from_host_usb_ep = 0; +#endif int aud_from_host_usb_ep = 0; int aud_to_host_usb_ep = 0; int int_usb_ep = 0; +#ifdef MIDI unsigned int g_midi_to_host_buffer_A[MAX_USB_MIDI_PACKET_SIZE/4+4]; unsigned int g_midi_to_host_buffer_B[MAX_USB_MIDI_PACKET_SIZE/4+4]; -int g_midi_from_host_buffer[MAX_USB_MIDI_PACKET_SIZE+4]; +int g_midi_from_host_buffer[MAX_USB_MIDI_PACKET_SIZE/4+4]; +#endif // shared global aud buffering variables @@ -1029,12 +1033,8 @@ void decouple(chanend c_mix_out, /* Swap the collecting and sending buffer */ swap(midi_to_host_buffer_being_collected, midi_to_host_buffer_being_sent); - { - /* Request to send packet */ - int len; - asm("ldw %0, %1[0]":"=r"(len):"r"(midi_to_host_buffer_being_sent)); - XUD_SetReady_In(midi_to_host_usb_ep, 0, midi_to_host_buffer_being_sent+4, len); - } + /* Request to send packet */ + XUD_SetReady_In(midi_to_host_usb_ep, 0, midi_to_host_buffer_being_sent+4, midi_data_collected_from_device); /* Mark as waiting for host to poll us */ midi_waiting_on_send_to_host = 1; @@ -1054,9 +1054,6 @@ void decouple(chanend c_mix_out, if (midi_from_host_flag) { /* The buffer() thread has filled up a buffer */ - int datalength; - int space_left; - /* Reset flag */ SET_SHARED_GLOBAL(g_midi_from_host_flag, 0); @@ -1119,16 +1116,12 @@ void decouple(chanend c_mix_out, if (!midi_waiting_on_send_to_host) { write_via_xc_ptr(midi_to_host_buffer_being_collected, midi_data_collected_from_device); - - midi_data_collected_from_device = 0; + swap(midi_to_host_buffer_being_collected, midi_to_host_buffer_being_sent); // Signal other side to swap - { - int len; - asm("ldw %0, %1[0]":"=r"(len):"r"(midi_to_host_buffer_being_sent)); - XUD_SetReady_In(midi_to_host_usb_ep, 0, midi_to_host_buffer_being_sent+4, len); - } + XUD_SetReady_In(midi_to_host_usb_ep, 0, midi_to_host_buffer_being_sent+4, midi_data_collected_from_device); + midi_data_collected_from_device = 0; midi_waiting_on_send_to_host = 1; } } diff --git a/module_usb_aud_shared/usb_buffer/usb_buffer.xc b/module_usb_aud_shared/usb_buffer/usb_buffer.xc index 16f8d177..2ef11e36 100644 --- a/module_usb_aud_shared/usb_buffer/usb_buffer.xc +++ b/module_usb_aud_shared/usb_buffer/usb_buffer.xc @@ -85,7 +85,9 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud XUD_ep ep_midi_from_host = XUD_Init_Ep(c_midi_from_host); XUD_ep ep_midi_to_host = XUD_Init_Ep(c_midi_to_host); #endif +#if defined(SPDIF_RX) || defined(ADAT_RX) XUD_ep ep_int = XUD_Init_Ep(c_int); +#endif unsigned datalength; unsigned tmp; @@ -116,7 +118,9 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud set_thread_fast_mode_on(); +#if defined(SPDIF_RX) || defined(ADAT_RX) asm("stw %0, dp[int_usb_ep]"::"r"(ep_int)); +#endif asm("stw %0, dp[aud_from_host_usb_ep]"::"r"(ep_aud_out)); asm("stw %0, dp[aud_to_host_usb_ep]"::"r"(ep_aud_in)); asm("stw %0, dp[buffer_aud_ctl_chan]"::"r"(c_aud_ctl)); @@ -195,6 +199,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud /* Wait for response from XUD and service relevant EP */ select { +#if defined(SPDIF_RX) || defined(ADAT_RX) /* Interrupt EP, send back interrupt data. Note, request made from decouple */ case inuint_byref(c_int, tmp): { @@ -221,6 +226,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud XUD_SetNotReady(ep_int); break; } +#endif /* Sample Freq our chan count update from ep 0 */ case inuint_byref(c_aud_ctl, tmp): diff --git a/module_usb_aud_shared/usb_buffer/xc_ptr.h b/module_usb_aud_shared/usb_buffer/xc_ptr.h index e2750668..ac6b8b90 100644 --- a/module_usb_aud_shared/usb_buffer/xc_ptr.h +++ b/module_usb_aud_shared/usb_buffer/xc_ptr.h @@ -12,10 +12,16 @@ inline xc_ptr array_to_xc_ptr(unsigned a[]) { #define write_via_xc_ptr(p,x) asm("stw %0, %1[0]"::"r"(x),"r"(p)) #define write_via_xc_ptr_indexed(p,i,x) asm("stw %0, %1[%2]"::"r"(x),"r"(p),"r"(i)) +#define write_byte_via_xc_ptr_indexed(p,i,x) asm("st8 %0, %1[%2]"::"r"(x),"r"(p),"r"(i)) +// No immediate st8 format +#define write_byte_via_xc_ptr(p,x) write_byte_via_xc_ptr_indexed(p, 0, x) #define read_via_xc_ptr(x,p) asm("ldw %0, %1[0]":"=r"(x):"r"(p)); #define read_via_xc_ptr_indexed(x,p,i) asm("ldw %0, %1[%2]":"=r"(x):"r"(p),"r"(i)); +#define read_byte_via_xc_ptr_indexed(x,p,i) asm("ld8u %0, %1[%2]":"=r"(x):"r"(p),"r"(i)); +// No immediate ld8u format +#define read_byte_via_xc_ptr(x,p) read_byte_via_xc_ptr_indexed(x, p, 0) #define GET_SHARED_GLOBAL(x, g) asm("ldw %0, dp[" #g "]":"=r"(x)) #define SET_SHARED_GLOBAL(g, v) asm("stw %0, dp[" #g "]"::"r"(v))