diff --git a/lib_xua/api/xua_usb_params_funcs.h b/lib_xua/api/xua_usb_params_funcs.h new file mode 100644 index 00000000..460c4008 --- /dev/null +++ b/lib_xua/api/xua_usb_params_funcs.h @@ -0,0 +1,16 @@ +// Copyright (c) 2017-2020, XMOS Ltd, All rights reserved + +#ifndef __XUA_API_H__ +#define __XUA_API_H__ + +extern void set_usb_to_device_rate(uint32_t rate); +extern void set_device_to_usb_rate(uint32_t rate); +extern void set_usb_to_device_bit_res(uint32_t rate); +extern void set_device_to_usb_bit_res(uint32_t rate); + +extern uint32_t get_usb_to_device_rate(); +extern uint32_t get_device_to_usb_rate(); +extern uint32_t get_usb_to_device_bit_res(); +extern uint32_t get_device_to_usb_bit_res(); + +#endif //__XUA_API_H__ diff --git a/lib_xua/src/core/buffer/decouple/decouple.xc b/lib_xua/src/core/buffer/decouple/decouple.xc index b6dffe51..f217b0e4 100644 --- a/lib_xua/src/core/buffer/decouple/decouple.xc +++ b/lib_xua/src/core/buffer/decouple/decouple.xc @@ -7,6 +7,7 @@ #include "interrupt.h" #include "xua_commands.h" #include "xud.h" +#include "xua_usb_params_funcs.h" #ifdef NATIVE_DSD #include "usbaudio20.h" /* Defines from the USB Audio 2.0 Specifications */ @@ -17,12 +18,6 @@ #endif #define MAX(x,y) ((x)>(y) ? (x) : (y)) -#if(defined USB_DESCRIPTOR_OVERRIDE_RATE_RES) -extern uint32_t get_usb_to_device_rate(); -extern uint32_t get_device_to_usb_rate(); -extern uint32_t get_usb_to_device_bit_res(); -extern uint32_t get_device_to_usb_bit_res(); -#endif /* TODO use SLOTSIZE to potentially save memory */ /* Note we could improve on this, for one subslot is set to 4 */ @@ -165,7 +160,7 @@ int g_maxPacketSize = MAX_DEVICE_AUD_PACKET_SIZE_IN_FS; void handle_audio_request(chanend c_mix_out) { int space_left; -#if(defined USB_DESCRIPTOR_OVERRIDE_RATE_RES) +#if(defined XUA_USB_DESCRIPTOR_OVERWRITE_RATE_RES) g_curSubSlot_Out = get_usb_to_device_bit_res() >> 3; g_curSubSlot_In = get_device_to_usb_bit_res() >> 3; #endif diff --git a/lib_xua/src/core/endpoint0/xua_endpoint0.c b/lib_xua/src/core/endpoint0/xua_endpoint0.c index 18ae1ee6..2a183c72 100755 --- a/lib_xua/src/core/endpoint0/xua_endpoint0.c +++ b/lib_xua/src/core/endpoint0/xua_endpoint0.c @@ -29,6 +29,8 @@ #include "dsd_support.h" #endif +#include "xua_usb_params_funcs.h" + #ifndef __XC__ /* Support for xCORE channels in C */ #define null 0 @@ -65,13 +67,6 @@ extern void device_reboot(void); #include "xua_hid.h" #endif -#if(defined USB_DESCRIPTOR_OVERRIDE_RATE_RES) -extern uint32_t get_usb_to_device_rate(); -extern uint32_t get_device_to_usb_rate(); -extern uint32_t get_usb_to_device_bit_res(); -extern uint32_t get_device_to_usb_bit_res(); -#endif - unsigned int DFU_mode_active = 0; // 0 - App active, 1 - DFU active /* Global volume and mute tables */ @@ -344,7 +339,7 @@ void XUA_Endpoint0_init(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioCont } #endif -#ifdef USB_DESCRIPTOR_OVERRIDE_RATE_RES //change USB descriptor frequencies and bit resolution values here +#ifdef XUA_USB_DESCRIPTOR_OVERWRITE_RATE_RES //change USB descriptor frequencies and bit resolution values here cfgDesc_Audio1[USB_AS_IN_INTERFACE_DESCRIPTOR_OFFSET_SUB_FRAME] = get_device_to_usb_bit_res() >> 3; //sub frame rate = bit rate /8 cfgDesc_Audio1[USB_AS_IN_INTERFACE_DESCRIPTOR_OFFSET_SUB_FRAME + 1] = (get_device_to_usb_bit_res() & 0xff); //bit resolution @@ -352,7 +347,7 @@ void XUA_Endpoint0_init(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioCont cfgDesc_Audio1[USB_AS_OUT_INTERFACE_DESCRIPTOR_OFFSET_SUB_FRAME] = get_usb_to_device_bit_res() >> 3; //sub frame rate = bit rate /8 cfgDesc_Audio1[USB_AS_OUT_INTERFACE_DESCRIPTOR_OFFSET_SUB_FRAME + 1] = (get_usb_to_device_bit_res() & 0xff); //bit resolution - const unsigned num_of_usb_descriptor_freq=3; //This should be =3 according to the comments "sing a value of <=2 or > 7 for num_freqs_a1 causes enumeration issues on Windows" in xua_ep0_descriptors.h + const unsigned num_of_usb_descriptor_freq=3; //This should be =3 according to the comments "using a value of <=2 or > 7 for num_freqs_a1 causes enumeration issues on Windows" in xua_ep0_descriptors.h int i=0; for(i=0;i