From d4e1bc3906c2f75d89ea997c51257c46e4d89f2b Mon Sep 17 00:00:00 2001 From: Russell Gallop Date: Thu, 11 Aug 2011 15:19:39 +0100 Subject: [PATCH] Add IAP_BUFFERED preprocessor macro to filter out new work to put iAP through buffer and decouple. --- module_usb_aud_shared/devicedefines.h | 4 ++++ module_usb_aud_shared/usb_buffer/decouple.h | 6 +++++- module_usb_aud_shared/usb_buffer/decouple.xc | 18 +++++++++++++++++- module_usb_aud_shared/usb_buffer/usb_buffer.h | 2 ++ module_usb_aud_shared/usb_buffer/usb_buffer.xc | 10 ++++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/module_usb_aud_shared/devicedefines.h b/module_usb_aud_shared/devicedefines.h index d277957e..bac09997 100644 --- a/module_usb_aud_shared/devicedefines.h +++ b/module_usb_aud_shared/devicedefines.h @@ -13,6 +13,10 @@ #undef IAP #endif +#if defined(IAP_BUFFERED) && (IAP_BUFFERED == 0) +#undef IAP_BUFFERED +#endif + #if defined(MIDI) && (MIDI == 0) #undef MIDI #endif diff --git a/module_usb_aud_shared/usb_buffer/decouple.h b/module_usb_aud_shared/usb_buffer/decouple.h index 359b60d2..405bd8e9 100644 --- a/module_usb_aud_shared/usb_buffer/decouple.h +++ b/module_usb_aud_shared/usb_buffer/decouple.h @@ -13,6 +13,10 @@ */ void decouple(chanend c_audio_out, chanend ?c_led, - chanend ?c_midi, chanend ?c_clk_int, chanend ?c_iap); + chanend ?c_midi, chanend ?c_clk_int +#ifdef IAP_BUFFERED +, chanend ?c_iap +#endif +); #endif // __decouple_h__ diff --git a/module_usb_aud_shared/usb_buffer/decouple.xc b/module_usb_aud_shared/usb_buffer/decouple.xc index 61292f1a..f0c850b5 100644 --- a/module_usb_aud_shared/usb_buffer/decouple.xc +++ b/module_usb_aud_shared/usb_buffer/decouple.xc @@ -5,7 +5,9 @@ #define NO_INLINE_MIDI_SELECT_HANDLER 1 #include "usb_midi.h" #define NO_INLINE_IAP_SELECT_HANDLER 1 +#ifdef IAP_BUFFERED #include "iAP.h" +#endif #include "devicedefines.h" #include "testct_byref.h" #include "interrupt.h" @@ -157,12 +159,14 @@ int midi_from_host_usb_ep = 0; #endif #ifdef IAP +#ifdef IAP_BUFFERED unsigned g_iap_from_host_flag = 0; unsigned g_iap_to_host_flag = 0; int iap_to_host_usb_ep = 0; int iap_to_host_int_usb_ep = 0; int iap_from_host_usb_ep = 0; #endif +#endif int aud_from_host_usb_ep = 0; int aud_to_host_usb_ep = 0; @@ -175,10 +179,12 @@ int g_midi_from_host_buffer[MAX_USB_MIDI_PACKET_SIZE/4+4]; #endif #ifdef IAP +#ifdef IAP_BUFFERED unsigned int g_iap_to_host_buffer_A[MAX_IAP_PACKET_SIZE/4+4]; unsigned int g_iap_to_host_buffer_B[MAX_IAP_PACKET_SIZE/4+4]; int g_iap_from_host_buffer[MAX_IAP_PACKET_SIZE/4+4]; #endif +#endif // shared global aud buffering variables @@ -631,7 +637,11 @@ void check_for_interrupt(chanend ?c_clk_int) { #pragma unsafe arrays void decouple(chanend c_mix_out, - chanend ?c_midi, chanend ?c_clk_int, chanend ?c_iap) + chanend ?c_midi, chanend ?c_clk_int +#ifdef IAP_BUFFERED +, chanend ?c_iap +#endif +) { unsigned sampFreq = DEFAULT_FREQ; int aud_from_host_flag=0; @@ -654,6 +664,7 @@ void decouple(chanend c_mix_out, #endif #ifdef IAP +#ifdef IAP_BUFFERED xc_ptr iap_from_host_rdptr; xc_ptr iap_from_host_buffer; xc_ptr iap_to_host_buffer_being_sent = array_to_xc_ptr(g_iap_to_host_buffer_A); @@ -666,6 +677,7 @@ void decouple(chanend c_mix_out, int iap_waiting_on_send_to_host = 0; int iap_to_host_flag = 0; int iap_from_host_flag = 0; +#endif #endif int t = array_to_xc_ptr(outAudioBuff); @@ -737,6 +749,7 @@ void decouple(chanend c_mix_out, #endif #ifdef IAP +#ifdef IAP_BUFFERED //asm("ldaw %0, dp[g_iap_to_host_buffer]":"=r"(iap_to_host_buffer)); asm("ldaw %0, dp[g_iap_from_host_buffer]":"=r"(iap_from_host_buffer)); @@ -751,6 +764,7 @@ void decouple(chanend c_mix_out, // send the current host -> device buffer out of the fifo XUD_SetReady(iap_from_host_usb_ep, 1); #endif +#endif #ifdef OUTPUT // wait for usb_buffer to set up @@ -1166,6 +1180,7 @@ void decouple(chanend c_mix_out, #endif // MIDI #ifdef IAP +#ifdef IAP_BUFFERED /* Check if buffer() has send IAP packet to host */ GET_SHARED_GLOBAL(iap_to_host_flag, g_iap_to_host_flag); if (iap_to_host_flag) @@ -1287,6 +1302,7 @@ void decouple(chanend c_mix_out, default: break; } +#endif #endif // IAP } } diff --git a/module_usb_aud_shared/usb_buffer/usb_buffer.h b/module_usb_aud_shared/usb_buffer/usb_buffer.h index 6515ab66..9378e56b 100644 --- a/module_usb_aud_shared/usb_buffer/usb_buffer.h +++ b/module_usb_aud_shared/usb_buffer/usb_buffer.h @@ -19,9 +19,11 @@ void buffer(chanend c_aud_out, chanend c_aud_in, chanend c_aud_fb, chanend c_midi_from_host, chanend c_midi_to_host, +#ifdef IAP_BUFFERED chanend c_iap_from_host, chanend c_iap_to_host, chanend c_iap_to_host_int, +#endif chanend? c_int, chanend c_sof, chanend c_aud_ctl, diff --git a/module_usb_aud_shared/usb_buffer/usb_buffer.xc b/module_usb_aud_shared/usb_buffer/usb_buffer.xc index 77d60b6c..53115265 100644 --- a/module_usb_aud_shared/usb_buffer/usb_buffer.xc +++ b/module_usb_aud_shared/usb_buffer/usb_buffer.xc @@ -74,9 +74,11 @@ extern unsigned g_numUsbChanIn; void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud_fb, chanend c_midi_from_host, chanend c_midi_to_host, +#ifdef IAP_BUFFERED chanend c_iap_from_host, chanend c_iap_to_host, chanend c_iap_to_host_int, +#endif chanend ?c_int, chanend c_sof, chanend c_aud_ctl, in port p_off_mclk @@ -90,10 +92,12 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud XUD_ep ep_midi_to_host = XUD_Init_Ep(c_midi_to_host); #endif #ifdef IAP +#ifdef IAP_BUFFERED XUD_ep ep_iap_from_host = XUD_Init_Ep(c_iap_from_host); XUD_ep ep_iap_to_host = XUD_Init_Ep(c_iap_to_host); XUD_ep ep_iap_to_host_int = XUD_Init_Ep(c_iap_to_host_int); #endif +#endif #if defined(SPDIF_RX) || defined(ADAT_RX) XUD_ep ep_int = XUD_Init_Ep(c_int); #endif @@ -125,9 +129,11 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud #endif #ifdef IAP +#ifdef IAP_BUFFERED xc_ptr iap_from_host_buffer = 0; xc_ptr iap_to_host_buffer = 0; xc_ptr iap_to_host_waiting_buffer = 0; +#endif #endif set_thread_fast_mode_on(); @@ -178,6 +184,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud #endif #ifdef IAP +#ifdef IAP_BUFFERED // get the two buffers to use for iap device->host asm("ldaw %0, dp[g_iap_to_host_buffer_A]":"=r"(iap_to_host_buffer)); asm("ldaw %0, dp[g_iap_to_host_buffer_B]":"=r"(iap_to_host_waiting_buffer)); @@ -192,6 +199,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud swap(iap_to_host_buffer, iap_to_host_waiting_buffer); SET_SHARED_GLOBAL(g_iap_from_host_flag, 1); #endif +#endif #ifdef OUTPUT SET_SHARED_GLOBAL(g_aud_from_host_flag, 1); @@ -537,6 +545,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud #endif #ifdef IAP +#ifdef IAP_BUFFERED case inuint_byref(c_iap_from_host, tmp): asm("#iap h->d"); @@ -579,6 +588,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud swap(iap_to_host_buffer, iap_to_host_waiting_buffer); break; +#endif #endif }