forked from PAWPAW-Mirror/lib_xua
Merge pull request #99 from xmos/develop
Infrastructure update + audio stream start/stop callbacks
This commit is contained in:
@@ -6,12 +6,14 @@ lib_xua Change Log
|
||||
|
||||
* ADDED: Initial library documentation
|
||||
* ADDED: Application note AN00247: Using lib_xua with lib_spdif (transmit)
|
||||
* ADDED: Separate callbacks for input/output audio stream start/stop
|
||||
* CHANGE: I2S hardware resources no longer used globally and must be passed
|
||||
to XUA_AudioHub()
|
||||
* CHANGE: XUA_AudioHub() no longer pars S/PDIF transmitter task
|
||||
* CHANGE: Moved to lib_spdif (from module_spdif_tx & module_spdif_rx)
|
||||
* CHANGE: Define NUM_PDM_MICS renamed to XUA_NUM_PDM_MICS
|
||||
* CHANGE: Define NO_USB renamed to XUA_USB_EN
|
||||
* CHANGE: Build files updated to support new "xcommon" behaviour in xwaf.
|
||||
* RESOLVED: wChannelConfig in UAC1 descriptor set according to output channel
|
||||
count
|
||||
* RESOLVED: Indexing of ADAT channel strings (#18059)
|
||||
@@ -19,6 +21,10 @@ lib_xua Change Log
|
||||
|
||||
* Changes to dependencies:
|
||||
|
||||
- lib_dsp: Added dependency 5.0.0
|
||||
|
||||
- lib_mic_array: Added dependency 4.0.0
|
||||
|
||||
- lib_spdif: Added dependency 3.1.0
|
||||
|
||||
- lib_xassert: Added dependency 3.0.1
|
||||
|
||||
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@@ -133,7 +133,7 @@ pipeline {
|
||||
}
|
||||
post {
|
||||
cleanup {
|
||||
cleanWs()
|
||||
xcoreCleanSandbox()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,66 @@
|
||||
# You can set flags specifically for your module by using the MODULE_XCC_FLAGS
|
||||
# variable. So the following
|
||||
#
|
||||
# MODULE_XCC_FLAGS = $(XCC_FLAGS) -O3
|
||||
#
|
||||
# specifies that everything in the modules should have the application
|
||||
# build flags with -O3 appended (so the files will build at
|
||||
# optimization level -O3).
|
||||
#
|
||||
# You can also set MODULE_XCC_C_FLAGS, MODULE_XCC_XC_FLAGS etc..
|
||||
VERSION = 0.2.0
|
||||
|
||||
MODULE_XCC_FLAGS = $(XCC_FLAGS) -O3 -DREF_CLK_FREQ=100 -fasm-linenum -fcomment-asm
|
||||
DEPENDENT_MODULES = lib_logging(>=3.0.0) \
|
||||
lib_xassert(>=4.0.0) \
|
||||
lib_xud(>=0.2.0) \
|
||||
lib_spdif(>=4.0.0) \
|
||||
lib_mic_array(>=4.0.0)
|
||||
|
||||
MODULE_XCC_FLAGS = $(XCC_FLAGS) \
|
||||
-O3 \
|
||||
-DREF_CLK_FREQ=100 \
|
||||
-fasm-linenum \
|
||||
-fcomment-asm
|
||||
|
||||
# Core
|
||||
XCC_FLAGS_xua_endpoint0.c = $(MODULE_XCC_FLAGS) -Os -mno-dual-issue
|
||||
XCC_FLAGS_xua_ep0_uacreqs.xc = $(MODULE_XCC_FLAGS) -Os -mno-dual-issue
|
||||
XCC_FLAGS_dbcalc.xc = $(MODULE_XCC_FLAGS) -Os -mno-dual-issue
|
||||
XCC_FLAGS_audioports.c = $(MODULE_XCC_FLAGS) -Os -mno-dual-issue
|
||||
XCC_FLAGS_audioports.xc = $(MODULE_XCC_FLAGS) -Os -mno-dual-issue
|
||||
|
||||
# DFU
|
||||
XCC_FLAGS_dfu.xc = $(MODULE_XCC_FLAGS) -Os -mno-dual-issue
|
||||
XCC_FLAGS_flash_interface.c = $(MODULE_XCC_FLAGS) -Os -mno-dual-issue
|
||||
XCC_FLAGS_flashlib_user.c = $(MODULE_XCC_FLAGS) -Os -mno-dual-issue
|
||||
|
||||
OPTIONAL_HEADERS += xua_conf.h
|
||||
|
||||
VERSION = 0.2.0
|
||||
EXPORT_INCLUDE_DIRS = api \
|
||||
src/core \
|
||||
src/core/audiohub \
|
||||
src/core/buffer/ep \
|
||||
src/core/endpoint0 \
|
||||
src/dfu
|
||||
|
||||
DEPENDENT_MODULES = lib_logging(>=2.1.0) lib_xassert(>=2.0.0) lib_xud(>=0.1.0) lib_spdif(>=3.0.0)
|
||||
INCLUDE_DIRS = $(EXPORT_INCLUDE_DIRS) \
|
||||
src/core/buffer/decouple \
|
||||
src/core/clocking \
|
||||
src/core/mixer \
|
||||
src/core/pdm_mics \
|
||||
src/core/ports \
|
||||
src/core/support \
|
||||
src/core/support/powersave \
|
||||
src/core/user \
|
||||
src/core/user/audiostream \
|
||||
src/core/user/hostactive \
|
||||
src/midi
|
||||
|
||||
INCLUDE_DIRS = api src/*
|
||||
SOURCE_DIRS = src/core \
|
||||
src/core/audiohub \
|
||||
src/core/buffer/decouple \
|
||||
src/core/buffer/ep \
|
||||
src/core/clocking \
|
||||
src/core/endpoint0 \
|
||||
src/core/mixer \
|
||||
src/core/pdm_mics \
|
||||
src/core/ports \
|
||||
src/core/support \
|
||||
src/core/support/powersave \
|
||||
src/core/user/audiostream \
|
||||
src/core/user/hostactive \
|
||||
src/core/xuduser \
|
||||
src/dfu \
|
||||
src/midi
|
||||
|
||||
#ignore host dir
|
||||
SOURCE_DIRS = src/*
|
||||
|
||||
# The following file specific flags are not automatically kept in sync with the wscript file
|
||||
# Core
|
||||
EXCLUDE_FILES += descriptors_2.rst
|
||||
XCC_FLAGS_xua_endpoint0.c = -Os -mno-dual-issue $(XCC_FLAGS)
|
||||
XCC_FLAGS_xua_ep0_uacreqs.xc = -Os -mno-dual-issue $(XCC_FLAGS)
|
||||
XCC_FLAGS_dbcalc.xc = -Os -mno-dual-issue $(XCC_FLAGS)
|
||||
XCC_FLAGS_audioports.c = -Os -mno-dual-issue $(XCC_FLAGS)
|
||||
XCC_FLAGS_audioports.xc = -Os -mno-dual-issue $(XCC_FLAGS)
|
||||
|
||||
# DFU
|
||||
XCC_FLAGS_dfu.xc = -Os -mno-dual-issue $(XCC_FLAGS)
|
||||
XCC_FLAGS_flash_interface.c = -Os -mno-dual-issue $(XCC_FLAGS)
|
||||
XCC_FLAGS_flashlib_user.c = -Os -mno-dual-issue $(XCC_FLAGS)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011-2018, XMOS Ltd, All rights reserved
|
||||
// Copyright (c) 2011-2019, XMOS Ltd, All rights reserved
|
||||
/**
|
||||
* @brief Implements endpoint zero for an USB Audio 1.0/2.0 device
|
||||
* @author Ross Owen, XMOS Semiconductor
|
||||
@@ -409,23 +409,48 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
||||
}
|
||||
|
||||
#if (NUM_USB_CHAN_OUT > 0) && (NUM_USB_CHAN_IN > 0)
|
||||
if ((sp.wIndex == INTERFACE_NUMBER_AUDIO_OUTPUT) || (sp.wIndex == INTERFACE_NUMBER_AUDIO_INPUT))
|
||||
unsigned num_input_interfaces = g_interfaceAlt[INTERFACE_NUMBER_AUDIO_INPUT];
|
||||
unsigned num_output_interfaces = g_interfaceAlt[INTERFACE_NUMBER_AUDIO_OUTPUT];
|
||||
if (sp.wIndex == INTERFACE_NUMBER_AUDIO_INPUT)
|
||||
{
|
||||
/* Check for stream start stop on output and input audio interfaces */
|
||||
if(sp.wValue && !g_interfaceAlt[INTERFACE_NUMBER_AUDIO_OUTPUT] && !g_interfaceAlt[INTERFACE_NUMBER_AUDIO_INPUT])
|
||||
// in: 0 -> 1
|
||||
if (sp.wValue && !num_input_interfaces)
|
||||
{
|
||||
/* If start and input AND output not currently running */
|
||||
UserAudioStreamStart();
|
||||
UserAudioInputStreamStart();
|
||||
if (!num_output_interfaces)
|
||||
{
|
||||
UserAudioStreamStart();
|
||||
}
|
||||
}
|
||||
else if(((sp.wIndex == 1) && (!sp.wValue)) && g_interfaceAlt[INTERFACE_NUMBER_AUDIO_OUTPUT] && (!g_interfaceAlt[INTERFACE_NUMBER_AUDIO_INPUT]))
|
||||
// in: 1 -> 0
|
||||
else if (!sp.wValue && num_input_interfaces)
|
||||
{
|
||||
/* if output stop and output running and input not running */
|
||||
UserAudioStreamStop();
|
||||
UserAudioInputStreamStop();
|
||||
if (!num_output_interfaces)
|
||||
{
|
||||
UserAudioStreamStop();
|
||||
}
|
||||
}
|
||||
else if(((sp.wIndex == 2) && (!sp.wValue)) && g_interfaceAlt[INTERFACE_NUMBER_AUDIO_INPUT] && (!g_interfaceAlt[INTERFACE_NUMBER_AUDIO_OUTPUT]))
|
||||
}
|
||||
else if (sp.wIndex == INTERFACE_NUMBER_AUDIO_OUTPUT)
|
||||
{
|
||||
// out: 0 -> 1
|
||||
if (sp.wValue && !num_output_interfaces)
|
||||
{
|
||||
/* if input stop and input running and output not running */
|
||||
UserAudioStreamStop();
|
||||
UserAudioOutputStreamStart();
|
||||
if (!num_input_interfaces)
|
||||
{
|
||||
UserAudioStreamStart();
|
||||
}
|
||||
}
|
||||
// out: 1 -> 0
|
||||
else if (!sp.wValue && num_output_interfaces)
|
||||
{
|
||||
UserAudioOutputStreamStop();
|
||||
if (!num_input_interfaces)
|
||||
{
|
||||
UserAudioStreamStop();
|
||||
}
|
||||
}
|
||||
}
|
||||
#elif (NUM_USB_CHAN_OUT > 0)
|
||||
@@ -435,11 +460,13 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
||||
{
|
||||
/* if start and not currently running */
|
||||
UserAudioStreamStart();
|
||||
UserAudioOutputStreamStart();
|
||||
}
|
||||
else if (!sp.wValue && g_interfaceAlt[INTERFACE_NUMBER_AUDIO_OUTPUT])
|
||||
{
|
||||
/* if stop and currently running */
|
||||
UserAudioStreamStop();
|
||||
UserAudioOutputStreamStop();
|
||||
}
|
||||
}
|
||||
#elif (NUM_USB_CHAN_IN > 0)
|
||||
@@ -449,11 +476,13 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
||||
{
|
||||
/* if start and not currently running */
|
||||
UserAudioStreamStart();
|
||||
UserAudioInputStreamStart();
|
||||
}
|
||||
else if (!sp.wValue && g_interfaceAlt[INTERFACE_NUMBER_AUDIO_INPUT])
|
||||
{
|
||||
/* if stop and currently running */
|
||||
UserAudioStreamStop();
|
||||
UserAudioInputStreamStop();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2015-2018, XMOS Ltd, All rights reserved
|
||||
// Copyright (c) 2015-2019, XMOS Ltd, All rights reserved
|
||||
|
||||
#include "xua.h"
|
||||
|
||||
@@ -88,7 +88,7 @@ void XUA_PdmBuffer(streaming chanend c_ds_output[2], chanend c_audio)
|
||||
fir_coefs[6] = g_third_stage_div_12_fir;
|
||||
|
||||
//dcc = {MIC_ARRAY_MAX_FRAME_SIZE_LOG2, 1, 0, 0, decimationfactor, fir_coefs[decimationfactor/2], 0, 0, DECIMATOR_NO_FRAME_OVERLAP, 2};
|
||||
dcc.frame_size_log2 = MIC_ARRAY_MAX_FRAME_SIZE_LOG2;
|
||||
dcc.len = MIC_ARRAY_MAX_FRAME_SIZE_LOG2;
|
||||
dcc.apply_dc_offset_removal = 1;
|
||||
dcc.index_bit_reversal = 0;
|
||||
dcc.windowing_function = null;
|
||||
@@ -107,6 +107,7 @@ void XUA_PdmBuffer(streaming chanend c_ds_output[2], chanend c_audio)
|
||||
dc[0].mic_gain_compensation[2]=0;
|
||||
dc[0].mic_gain_compensation[3]=0;
|
||||
dc[0].channel_count = 4;
|
||||
dc[0].async_interface_enabled = 0;
|
||||
dc[1].dcc = &dcc;
|
||||
dc[1].data = mic_decimator_fir_data[4];
|
||||
dc[1].mic_gain_compensation[0]=0;
|
||||
@@ -114,6 +115,7 @@ void XUA_PdmBuffer(streaming chanend c_ds_output[2], chanend c_audio)
|
||||
dc[1].mic_gain_compensation[2]=0;
|
||||
dc[1].mic_gain_compensation[3]=0;
|
||||
dc[1].channel_count = 4;
|
||||
dc[0].async_interface_enabled = 0;
|
||||
|
||||
mic_array_decimator_configure(c_ds_output, decimatorCount, dc);
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright (c) 2013-2018, XMOS Ltd, All rights reserved
|
||||
// Copyright (c) 2013-2019, XMOS Ltd, All rights reserved
|
||||
|
||||
/* Default implementations of AudioStreamStop() and AudioStreamStart()
|
||||
* callbacks.
|
||||
*/
|
||||
|
||||
/* Deafult implementations of AudioStreamStop() and AudioStreamStart(). Both can be over-ridden */
|
||||
void UserAudioStreamStop() __attribute__ ((weak));
|
||||
void UserAudioStreamStop()
|
||||
{
|
||||
@@ -12,3 +15,27 @@ void UserAudioStreamStart()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void UserAudioInputStreamStop() __attribute__ ((weak));
|
||||
void UserAudioInputStreamStop()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void UserAudioInputStreamStart() __attribute__ ((weak));
|
||||
void UserAudioInputStreamStart()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void UserAudioOutputStreamStop() __attribute__ ((weak));
|
||||
void UserAudioOutputStreamStop()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void UserAudioOutputStreamStart() __attribute__ ((weak));
|
||||
void UserAudioOutputStreamStart()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011-2018, XMOS Ltd, All rights reserved
|
||||
// Copyright (c) 2011-2019, XMOS Ltd, All rights reserved
|
||||
#ifndef _AUDIOSTREAM_H_
|
||||
#define _AUDIOSTREAM_H_
|
||||
|
||||
@@ -14,5 +14,17 @@ void UserAudioStreamStart(void);
|
||||
/* Any actions required on stream stop e.g. DAC mute - run every steam stop */
|
||||
void UserAudioStreamStop(void);
|
||||
|
||||
/* Any actions required on input stream start */
|
||||
void UserAudioInputStreamStart(void);
|
||||
|
||||
/* Any actions required on input stream stop */
|
||||
void UserAudioInputStreamStop(void);
|
||||
|
||||
/* Any actions required on output stream start */
|
||||
void UserAudioOutputStreamStart(void);
|
||||
|
||||
/* Any actions required on output stream stop */
|
||||
void UserAudioOutputStreamStop(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
109
lib_xua/wscript
109
lib_xua/wscript
@@ -1,109 +0,0 @@
|
||||
import os.path
|
||||
|
||||
|
||||
def create_list_from_make_flag(bld, list_of_flags):
|
||||
for i, flag in enumerate(list_of_flags):
|
||||
if flag.startswith('$('):
|
||||
for f in bld.env[flag.strip('$()')]:
|
||||
list_of_flags.insert(i, f)
|
||||
i += 1
|
||||
list_of_flags.remove(flag)
|
||||
return list_of_flags
|
||||
|
||||
|
||||
def create_list_of_strings(whitespace_seperated_list):
|
||||
list_of_strings = whitespace_seperated_list.split(' ')
|
||||
for item in list_of_strings:
|
||||
item = "'{}'".format(item)
|
||||
return list_of_strings
|
||||
|
||||
|
||||
def read_module_build_info(bld):
|
||||
with open(os.path.join(bld.path.abspath(), 'module_build_info')) as file:
|
||||
module_build_info = {}
|
||||
for line in file.readlines():
|
||||
line = line.strip()
|
||||
if line and not line.startswith('#'):
|
||||
key, value = line.split('=', 1)
|
||||
module_build_info[key.strip(' +')] = value.strip()
|
||||
|
||||
try:
|
||||
module_build_info['OPTIONAL_HEADERS'] = (
|
||||
create_list_of_strings(module_build_info['OPTIONAL_HEADERS']))
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
module_build_info['DEPENDENT_MODULES'] = (
|
||||
create_list_of_strings(module_build_info['DEPENDENT_MODULES']))
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
module_build_info['MODULE_XCC_FLAGS'] = (
|
||||
create_list_from_make_flag(bld,
|
||||
create_list_of_strings(module_build_info['MODULE_XCC_FLAGS'])))
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
module_build_info['MODULE_XCC_XC_FLAGS'] = (
|
||||
create_list_from_make_flag(bld,
|
||||
create_list_of_strings(module_build_info['MODULE_XCC_XC_FLAGS'])))
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
module_build_info['MODULE_XCC_C_FLAGS'] = (
|
||||
create_list_from_make_flag(bld,
|
||||
create_list_of_strings(module_build_info['MODULE_XCC_C_FLAGS'])))
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
module_build_info['MODULE_XCC_CPP_FLAGS'] = (
|
||||
create_list_from_make_flag(bld,
|
||||
create_list_of_strings(module_build_info['MODULE_XCC_CPP_FLAGS'])))
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
module_build_info['MODULE_XCC_ASM_FLAGS'] = (
|
||||
create_list_from_make_flag(bld,
|
||||
create_list_of_strings(module_build_info['MODULE_XCC_ASM_FLAGS'])))
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
module_build_info['INCLUDE_DIRS'] = (
|
||||
create_list_of_strings(module_build_info['INCLUDE_DIRS']))
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return module_build_info
|
||||
|
||||
|
||||
def use_module(bld):
|
||||
module_build_info = read_module_build_info(bld)
|
||||
source = bld.path.ant_glob(['src/**/*.xc', 'src/**/*.c', 'src/**/*.S'],
|
||||
excl=['**/descriptors_2.rst'])
|
||||
bld.env.MODULE_XCC_FLAGS = module_build_info['MODULE_XCC_FLAGS']
|
||||
|
||||
# The following file specific flags are not automatically kept in sync with the module_build_info file
|
||||
# Core
|
||||
bld.env['XCC_FLAGS_endpoint0.c'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
|
||||
bld.env['XCC_FLAGS_xua_ep0_uacreqs.xc'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
|
||||
bld.env['XCC_FLAGS_dbcalc.xc'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
|
||||
bld.env['XCC_FLAGS_audioports.c'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
|
||||
bld.env['XCC_FLAGS_audioports.xc'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
|
||||
# DFU
|
||||
bld.env['XCC_FLAGS_dfu.xc'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
|
||||
bld.env['XCC_FLAGS_flash_interface.c'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
|
||||
bld.env['XCC_FLAGS_flashlib_user.c'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
|
||||
|
||||
bld.module(
|
||||
source=source,
|
||||
depends_on=module_build_info['DEPENDENT_MODULES'],
|
||||
includes=module_build_info['INCLUDE_DIRS'],
|
||||
optional_headers=module_build_info['OPTIONAL_HEADERS'],
|
||||
version=module_build_info['VERSION'])
|
||||
Reference in New Issue
Block a user