Adding support for VENDOR_REQUESTS_PARAMS

This commit is contained in:
Ross Owen
2016-06-08 12:40:29 +01:00
parent 959c0f3ca9
commit 78ab9a067a
5 changed files with 69 additions and 14 deletions

View File

@@ -1,6 +1,4 @@
/** /**
* g
* @file endpoint0.xc
* @brief Implements endpoint zero for an USB Audio 1.0/2.0 device * @brief Implements endpoint zero for an USB Audio 1.0/2.0 device
* @author Ross Owen, XMOS Semiconductor * @author Ross Owen, XMOS Semiconductor
*/ */
@@ -31,7 +29,7 @@
#endif #endif
#ifndef __XC__ #ifndef __XC__
/* Support for C */ /* Support for xCORE channels in C */
#define null 0 #define null 0
#define outuint(c, x) asm ("out res[%0], %1" :: "r" (c), "r" (x)) #define outuint(c, x) asm ("out res[%0], %1" :: "r" (c), "r" (x))
#define chkct(c, x) asm ("chkct res[%0], %1" :: "r" (c), "r" (x)) #define chkct(c, x) asm ("chkct res[%0], %1" :: "r" (c), "r" (x))
@@ -65,11 +63,9 @@ unsigned int DFU_mode_active = 0; // 0 - App active, 1 - DFU active
/* Global volume and mute tables */ /* Global volume and mute tables */
int volsOut[NUM_USB_CHAN_OUT + 1]; int volsOut[NUM_USB_CHAN_OUT + 1];
unsigned int mutesOut[NUM_USB_CHAN_OUT + 1]; unsigned int mutesOut[NUM_USB_CHAN_OUT + 1];
//unsigned int multOut[NUM_USB_CHAN_OUT + 1];
int volsIn[NUM_USB_CHAN_IN + 1]; int volsIn[NUM_USB_CHAN_IN + 1];
unsigned int mutesIn[NUM_USB_CHAN_IN + 1]; unsigned int mutesIn[NUM_USB_CHAN_IN + 1];
//unsigned int multIn[NUM_USB_CHAN_IN + 1];
#ifdef MIXER #ifdef MIXER
unsigned char mixer1Crossbar[18]; unsigned char mixer1Crossbar[18];
@@ -204,7 +200,7 @@ const unsigned g_chanCount_In_HS[INPUT_FORMAT_COUNT] = {HS_STREAM_FORMAT_I
/* Endpoint 0 function. Handles all requests to the device */ /* Endpoint 0 function. Handles all requests to the device */
void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
chanend c_mix_ctl, chanend c_clk_ctl, chanend c_EANativeTransport_ctrl, CLIENT_INTERFACE(i_dfu, dfuInterface)) chanend c_mix_ctl, chanend c_clk_ctl, chanend c_EANativeTransport_ctrl, CLIENT_INTERFACE(i_dfu, dfuInterface) VENDOR_REQUESTS_PARAMS_DEC_)
{ {
USB_SetupPacket_t sp; USB_SetupPacket_t sp;
XUD_ep ep0_out = XUD_InitEp(c_ep0_out); XUD_ep ep0_out = XUD_InitEp(c_ep0_out);
@@ -288,7 +284,7 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
/* Stop audio */ /* Stop audio */
outuint(c_audioControl, SET_SAMPLE_FREQ); outuint(c_audioControl, SET_SAMPLE_FREQ);
outuint(c_audioControl, AUDIO_STOP_FOR_DFU); outuint(c_audioControl, AUDIO_STOP_FOR_DFU);
// No Handshake /* No Handshake */
DFU_mode_active = 1; DFU_mode_active = 1;
} }
#endif #endif
@@ -628,6 +624,17 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
} /* if(result == XUD_RES_OKAY) */ } /* if(result == XUD_RES_OKAY) */
//if(i_vendorRequests != null)
{
if(result == XUD_RES_ERR)
{
/* Run vendor defined parsing/processing */
/* Note, an interface might seem ideal hear but this *must* be executed on the same
* core sure to shared memory depandancy */
VendorRequests(ep0_out, ep0_in, &sp VENDOR_REQUESTS_PARAMS_);
}
}
if(result == XUD_RES_ERR) if(result == XUD_RES_ERR)
{ {
#ifdef DFU #ifdef DFU

View File

@@ -3,6 +3,8 @@
#define _ENDPOINT0_H_ #define _ENDPOINT0_H_
#include "dfu_interface.h" #include "dfu_interface.h"
#include "devicedefines.h"
#include "vendorrequests.h"
/** Function implementing Endpoint 0 for enumeration, control and configuration /** Function implementing Endpoint 0 for enumeration, control and configuration
* of USB audio devices. It uses the descriptors defined in ``descriptors_2.h``. * of USB audio devices. It uses the descriptors defined in ``descriptors_2.h``.
@@ -21,6 +23,7 @@
* endpoint manager if present * endpoint manager if present
*/ */
void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioCtrl, void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioCtrl,
chanend ?c_mix_ctl,chanend ?c_clk_ctl, chanend ?c_EANativeTransport_ctr, client interface i_dfu dfuInterface); chanend ?c_mix_ctl,chanend ?c_clk_ctl, chanend ?c_EANativeTransport_ctr, client interface i_dfu dfuInterface
VENDOR_REQUESTS_PARAMS_DEC_);
#endif #endif

View File

@@ -0,0 +1,26 @@
#include "xud.h"
#include "vendorrequests.h"
int VendorAudioRequests(XUD_ep ep0_out, XUD_ep ep0_in, unsigned char bRequest, unsigned char cs, unsigned char cn,
unsigned short unitId, unsigned char direction, chanend c_audioControl,
NULLABLE_RESOURCE(chanend, c_mix_ctl),
NULLABLE_RESOURCE(chanend, c_clk_ctL)) __attribute__ ((weak));
int VendorAudioRequests(XUD_ep ep0_out, XUD_ep ep0_in, unsigned char bRequest, unsigned char cs, unsigned char cn,
unsigned short unitId, unsigned char direction, chanend c_audioControl,
NULLABLE_RESOURCE(chanend, c_mix_ctl),
NULLABLE_RESOURCE(chanend, c_clk_ctL))
{
return XUD_RES_ERR;
}
int VendorRequests(XUD_ep ep0_out, XUD_ep ep0_in, REFERENCE_PARAM(USB_SetupPacket_t, sp) VENDOR_REQUESTS_PARAMS_DEC_) __attribute__ ((weak));
int VendorRequests(XUD_ep ep0_out, XUD_ep ep0_in, REFERENCE_PARAM(USB_SetupPacket_t, sp) VENDOR_REQUESTS_PARAMS_DEC_)
{
return XUD_RES_ERR;
}

View File

@@ -2,6 +2,9 @@
#define _VENDORREQUESTS_H_ #define _VENDORREQUESTS_H_
#include <xccompat.h> #include <xccompat.h>
#include "devicedefines.h"
#include "xud.h"
#include "usb_std_requests.h"
/* Functions that handle vustomer vendor requests. /* Functions that handle vustomer vendor requests.
* *
@@ -11,10 +14,24 @@
* *
* */ * */
#define PREPEND_COMMA(x) ,x
#ifndef VENDOR_REQUESTS_PARAMS
#define VENDOR_REQUESTS_PARAMS_
#define VENDOR_REQUESTS_PARAMS_DEC_
#else
#define VENDOR_REQUESTS_PARAMS_ PREPEND_COMMA(VENDOR_REQUESTS_PARAMS)
#define VENDOR_REQUESTS_PARAMS_DEC_ PREPEND_COMMA(VENDOR_REQUESTS_PARAMS_DEC)
#endif
int VendorAudioRequests(XUD_ep ep0_out, XUD_ep ep0_in, unsigned char bRequest, unsigned char cs, unsigned char cn, int VendorAudioRequests(XUD_ep ep0_out, XUD_ep ep0_in, unsigned char bRequest, unsigned char cs, unsigned char cn,
unsigned short unitId, unsigned char direction, chanend c_audioControl, unsigned short unitId, unsigned char direction, chanend c_audioControl,
NULLABLE_RESOURCE(chanend, c_mix_ctl), NULLABLE_RESOURCE(chanend, c_mix_ctl),
NULLABLE_RESOURCE(chanend, c_clk_ctL)); NULLABLE_RESOURCE(chanend, c_clk_ctL));
int VendorRequests(XUD_ep ep0_out, XUD_ep ep0_in, REFERENCE_PARAM(USB_SetupPacket_t, sp) VENDOR_REQUESTS_PARAMS_DEC_);
#endif #endif

View File

@@ -287,6 +287,7 @@ void usb_audio_core(chanend c_mix_out
, chanend ?c_clk_int , chanend ?c_clk_int
, chanend ?c_clk_ctl , chanend ?c_clk_ctl
, client interface i_dfu ?dfuInterface , client interface i_dfu ?dfuInterface
VENDOR_REQUESTS_PARAMS_DEC_
) )
{ {
chan c_sof; chan c_sof;
@@ -381,7 +382,7 @@ void usb_audio_core(chanend c_mix_out
/* Endpoint 0 Core */ /* Endpoint 0 Core */
{ {
thread_speed(); thread_speed();
Endpoint0( c_xud_out[0], c_xud_in[0], c_aud_ctl, c_mix_ctl, c_clk_ctl, c_EANativeTransport_ctrl, dfuInterface); Endpoint0( c_xud_out[0], c_xud_in[0], c_aud_ctl, c_mix_ctl, c_clk_ctl, c_EANativeTransport_ctrl, dfuInterface VENDOR_REQUESTS_PARAMS_);
} }
/* Decoupling core */ /* Decoupling core */
@@ -581,6 +582,7 @@ int main()
, c_mix_ctl , c_mix_ctl
#endif #endif
, c_clk_int, c_clk_ctl, dfuInterface , c_clk_int, c_clk_ctl, dfuInterface
VENDOR_REQUESTS_PARAMS_
); );
} }