forked from PAWPAW-Mirror/lib_xua
Adding support for VENDOR_REQUESTS_PARAMS
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
/**
|
||||
* g
|
||||
* @file endpoint0.xc
|
||||
* @brief Implements endpoint zero for an USB Audio 1.0/2.0 device
|
||||
* @author Ross Owen, XMOS Semiconductor
|
||||
*/
|
||||
@@ -15,7 +13,7 @@
|
||||
|
||||
#include "devicedefines.h"
|
||||
#include "usb_device.h" /* Standard descriptor requests */
|
||||
#include "descriptors.h" /* This devices descriptors */
|
||||
#include "descriptors.h" /* This devices descriptors */
|
||||
#include "commands.h"
|
||||
#include "audiostream.h"
|
||||
#include "hostactive.h"
|
||||
@@ -31,7 +29,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef __XC__
|
||||
/* Support for C */
|
||||
/* Support for xCORE channels in C */
|
||||
#define null 0
|
||||
#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))
|
||||
@@ -65,11 +63,9 @@ unsigned int DFU_mode_active = 0; // 0 - App active, 1 - DFU active
|
||||
/* Global volume and mute tables */
|
||||
int volsOut[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];
|
||||
unsigned int mutesIn[NUM_USB_CHAN_IN + 1];
|
||||
//unsigned int multIn[NUM_USB_CHAN_IN + 1];
|
||||
|
||||
#ifdef MIXER
|
||||
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 */
|
||||
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;
|
||||
XUD_ep ep0_out = XUD_InitEp(c_ep0_out);
|
||||
@@ -271,10 +267,10 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
||||
|
||||
/* Init mixer inputs */
|
||||
for(int j = 0; j < MAX_MIX_COUNT; j++)
|
||||
for(int i = 0; i < MIX_INPUTS; i++)
|
||||
{
|
||||
mixSel[j][i] = i;
|
||||
}
|
||||
for(int i = 0; i < MIX_INPUTS; i++)
|
||||
{
|
||||
mixSel[j][i] = i;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VENDOR_AUDIO_REQS
|
||||
@@ -288,7 +284,7 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
||||
/* Stop audio */
|
||||
outuint(c_audioControl, SET_SAMPLE_FREQ);
|
||||
outuint(c_audioControl, AUDIO_STOP_FOR_DFU);
|
||||
// No Handshake
|
||||
/* No Handshake */
|
||||
DFU_mode_active = 1;
|
||||
}
|
||||
#endif
|
||||
@@ -628,6 +624,17 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
||||
|
||||
} /* 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)
|
||||
{
|
||||
#ifdef DFU
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#define _ENDPOINT0_H_
|
||||
|
||||
#include "dfu_interface.h"
|
||||
#include "devicedefines.h"
|
||||
#include "vendorrequests.h"
|
||||
|
||||
/** Function implementing Endpoint 0 for enumeration, control and configuration
|
||||
* of USB audio devices. It uses the descriptors defined in ``descriptors_2.h``.
|
||||
@@ -21,6 +23,7 @@
|
||||
* endpoint manager if present
|
||||
*/
|
||||
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
|
||||
|
||||
26
module_usb_audio/endpoint0/vendorrequests.c
Normal file
26
module_usb_audio/endpoint0/vendorrequests.c
Normal 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;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#define _VENDORREQUESTS_H_
|
||||
|
||||
#include <xccompat.h>
|
||||
#include "devicedefines.h"
|
||||
#include "xud.h"
|
||||
#include "usb_std_requests.h"
|
||||
|
||||
/* 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,
|
||||
unsigned short unitId, unsigned char direction, chanend c_audioControl,
|
||||
NULLABLE_RESOURCE(chanend, c_mix_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
|
||||
|
||||
|
||||
@@ -287,6 +287,7 @@ void usb_audio_core(chanend c_mix_out
|
||||
, chanend ?c_clk_int
|
||||
, chanend ?c_clk_ctl
|
||||
, client interface i_dfu ?dfuInterface
|
||||
VENDOR_REQUESTS_PARAMS_DEC_
|
||||
)
|
||||
{
|
||||
chan c_sof;
|
||||
@@ -381,7 +382,7 @@ void usb_audio_core(chanend c_mix_out
|
||||
/* Endpoint 0 Core */
|
||||
{
|
||||
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 */
|
||||
@@ -581,6 +582,7 @@ int main()
|
||||
, c_mix_ctl
|
||||
#endif
|
||||
, c_clk_int, c_clk_ctl, dfuInterface
|
||||
VENDOR_REQUESTS_PARAMS_
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user