Code Monkey home page Code Monkey logo

lib_xua's Introduction

lib_xua

Version: 3.5.1
Vendor:XMOS
Scope:General Use

Summary

lib_xua contains shared components for use in the XMOS USB Audio (XUA) Reference Designs.

These components enable the development of USB Audio devices on the XMOS xCORE architecture.

Features

Key features of the various components in this repository are as follows

  • USB Audio Class 1.0/2.0 Compliant
  • Fully Asynchronous operation (synchronous mode as an option)
  • Support for the following sample frequencies: 8, 11.025, 12, 16, 32, 44.1, 48, 88.2, 96, 176.4, 192, 352.8, 384kHz
  • Volume/mute controls for input/output (for both master and individual channels)
  • Support for dynamically selectable output audio formats (e.g. resolution)
  • Field firmware upgrade compliant to the USB Device Firmware Upgrade (DFU) Class Specification
  • S/PDIF output
  • S/PDIF input
  • ADAT output
  • ADAT input
  • Synchronisation to external digital streams i.e. S/PDIF or ADAT (when in asynchronous mode)
  • I2S (slave/master modes with configurable word-length)
  • TDM (slave/master modes with configurable word-length)
  • MIDI input/output (Compliant to USB Class Specification for MIDI devices)
  • DSD output ("native" and DoP mode) at DSD64 and DSD128 rates
  • Mixer with flexible routing
  • Simple playback controls via USB Human Interface Device (HID) Class
  • Support for adding custom HID interfaces

Note, not all features may be supported at all sample frequencies, simultaneously or on all devices. Some features may also require specific host driver support.

Host System Requirements

USB Audio devices built using lib_xua have the following host system requirements.

  • Mac OSX version 10.6 or later
  • Windows Vista, 7, 8 or 10 with Thesycon Audio Class 2.0 driver for Windows (Tested against version 3.20). Please contact XMOS for details.
  • Windows Vista, 7, 8 or 10 with built-in USB Audio Class 1.0 driver.

Older versions of Windows are not guaranteed to operate as expected. Devices are also expected to operate with various Linux distributions including mobile variants.

Related Application Notes

The following application notes use this library:

  • AN000246 - Simple USB Audio Device using lib_xua
  • AN000247 - Using lib_xua with lib_spdif (transmit)
  • AN000248 - Using lib_xua with lib_mic_array

Required Software (dependencies)

Documentation

You can find the documentation for this software in the /doc directory of the package.

Support

This package is supported by XMOS Ltd. Issues can be raised against the software at: http://www.xmos.com/support

lib_xua's People

Contributors

acascarino avatar andrewstanfordjason avatar brennangit avatar chrisc-xmos avatar ciaranwoodward avatar danielpieczko avatar djpwilk avatar ed-xmos avatar henkmuller avatar kbxmos avatar keithauxmos avatar kevinyeungxmos avatar kieran-kohtz avatar larry-xmos avatar lucianomartin avatar mbanth avatar oscarbailey-xmos avatar quinnwang avatar russellgallop avatar samchesney avatar shuchitak avatar tdw89 avatar xmos-jenkins avatar xmosbrendon avatar xross avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lib_xua's Issues

Rate control for "hybrid" configuration of vf incorrect

In the case where USB rate is 16k and audio rate 48k (AUD_TO_USB_RATIO=3), userBufferManagement is called at too slow a rate (16k instead of 48k).

The issue is the call to DoSampleTransfer https://github.com/xmos/lib_xua/blob/master/lib_xua/src/core/audiohub/xua_audiohub.xc#L792
is guarded by audioToUsbRatioCounter. However UserBufferManagement is called in DoSampleTransfer so will be called at the USB rate, not the audio rate for the hybrid config.

This should be able to fixed by putting the ((AUD_TO_USB_RATIO - 1) == audioToUsbRatioCounter) check in DoSampleTransfer around the communication with decouple() and leaving userBufferManagement to be called at the audio rate.

Inverted semantics UAC_IMPLICIT_FEEDBACK_EP instead of UAC_FORCE_FEEDBACK_EP

We've had FAE/customer reports from various Linux hosts seemingly failing to do adaptive sink when the feedback is implicit

Microsoft's own class 2 driver apparently doesn't support implicit feedback at all

It might make more sense for explicit to be the default, and you turn implicit on if you can be sure it will work

Crash in the absence of master clock

Not sure if this is a recent change but don't remember this behaviour in sc_usb_audio. With master clock absent, decouple crashes in upstream overflow, the "keep throwing away packets" loop.

            GET_SHARED_GLOBAL(rdPtr, g_aud_to_host_rdptr);
            asm volatile("ldw %0, %1[0]":"=r"(datalength):"r"(rdPtr));

I noticed that g_speed gets set to zero. Is this correct or could be the cause of the crash?

Runtime check for packet size limit

A very long time was spent chasing down audio issues on new hardware that in the end was nothing to do with the new hardware. The application specified 8 channels at 48kHz/24bit and audio class 1.0. This exceeds 1,023 bytes per packet, but there is no clear indication of that.

A check in USB buffer or decouple with a runtime assertion would greatly help catch this early. Suggest leaving it disabled by default, similar to an existing one in xmos/lib_mic_array.

UAC1 Associated Terminal field set incorrectly

The UAC1 USB Terminal descriptor for the Device to Host USB Streaming terminal, defined in xua_ep0_descriptors.h, sets the Terminal Type field (wTerminalType) to 0x0101 and the Associated Terminal (bAssocTerminal) field to 1.

That combination violates the USB Device Class Definition for Audio Devices (Release 2.0, 31 May 2006) which states that, 'The bAssocTerminal field is used to associate an Input Terminal to this Output Terminal, effectively implementing a bi-directional Terminal pair. If no association exists, the bAssocTerminal field must be set to zero.'

Bi-directional terminals have Terminal Type values between 0x0400 and 0x0405 (see the USB Device Class Definition for Terminal Types, Release 2.0, 31 May 2006).

I have not observed this issue having a detrimental effect when enumerating a UAC1 device connected to either MacOS or Windows.

Make build flags consistently either #ifdef FLAG or #if FLAG

Some flags are set by defining them e.g. -DUAC_FORCE_FEEDBACK_EP
whereas others are set to either 0 or 1 e.g. -DXUA_USB_EN=0

This can be confusing at the app level e.g. -DUAC_FORCE_FEEDBACK_EP=0 counter-intuitively enables the feedback endpoint.

Cannot install pipenv under WSL

The Confluence page How to build the 3510 firmware on WSL includes an instruction to install pipenv, pipenv install --python ~/.pyenv/versions/3.7.4/bin/python. On my machine, this step produces an error with a long message ending with, pipenv.patched.notpip._internal.exceptions.InstallationError: Command "python setup.py egg_info" failed with error code 1 in /tmp/tmpw99ccpwwbuild/functools32/.

UAC2 interface count-descriptor mismatch

The top-level Class 2 Configuration descriptor in xua_ep0_descriptors.h sets the number of interfaces (bNumInterfaces) to INTERFACE_COUNT. INTERFACE_COUNT, defined in descriptor_defs.h, includes the vendor-specific interface (INTERFACE_NUMBER_MISC_CONTROL) used to provide run-time parameter control over USB. However the set of Class 2 descriptors in xua_ep0_descriptors.h does not include a descriptor for this interface, resulting in a mismatch between the number of interfaces claimed and the number of interface descriptors provided.

This mismatch prevents the Windows-native USB driver from successfully enumerating xvf3500 (and likely other products that use lib_xua and include the control interface) when operated as USB Audio Class 2.

Slave frame sync check seems broken

From initial inspection

Frame sync test appears to fail - hitting the main while(1) loop.
However, due to the firstIteration flag it doesn't resync - drops right though and the loopback test continues to pass

Streaming issue when input enabled

Large (invalid) IN audio packets to be set to host.

Effects app_usb_aud_xk_216_mc (1i2o2xxxxxx tested)

Doesn't seem to effect XVF (1i1o2_cir43 tested) - could be port map related?

Caution - bug crashes core audio on OSX

Windows DFU host utility

Attached example from customer RT case 32296

Required change from libusb_ to usb_ function names, and related API updates

Furthermore, timeout value of 0 sets default, which has proven insufficient for the flash erase on first download operation. So use a specific large value.

xmosdfu_win.cpp.zip

Unit test of TDM slave synchronisation

Example of what would be a nice test to have in xmos/lib_xua for the 'syncError' based checking is on larry-xmos/sc_usb_audio branch tdm_slave_sync_test

UAC1 assumes device always has input

If not you get this in decouple:

Program received signal ET_LOAD_STORE, Memory access exception.
[Switching to tile[1] core[1]]
SetupZerosSendBuffer (sampFreq=, aud_to_host_usb_ep=0, slotSize=2)
at /Users/Ed/apps/views/stereo_vocalfusion/lib_xua/lib_xua/src/core/buffer/decouple/decouple.xc:612
612 XUD_SetReady_InPtr(aud_to_host_usb_ep, p+4, mid);

Looks like guards around setting up input endpoint in UAC1 needed

descriptor_defs.h depends on xua.h

Unless defined in a Make file, the definition of NUM_USB_CHAN_IN and NUM_USB_CHAN_OUT occur in either xua_conf.h or xua_conf_default.h. These symbols appear in descriptor_defs.h and govern the values assigned to constants in the USBInterfaceNumber enum. The constants receive incorrect values if two conditions hold:

  1. The symbols are not defined in the Make file; and
  2. A #include "xua.h" does not preceed the #include "descriptor_defs.h" in a translation unit.

Adding a #include "xua.h" before referencing NUM_USB_CHAN_IN or NUM_USB_CHAN_OUT in descriptor_defs.h solves the problem.

Sector-wise flash erase

Often it takes longer than 5 seconds to erase flash on the first DFU download request

DFU specification isn't concerned with erasing the storage medium, but USB specification mandates any request completes within 5 sec

Multiple customer support cases have pointed to the need for splitting up the erase operation. Eg one sector at a time across multiple download requests.

Doing this would move the code one step closer towards 'DFU compliance' as described by Thesycon

Libusb version in Lib

This repo has a copy of libusb. Our tools ship with a different version of libusb. We need to separate the libusb dependancy from the repo and either have another repo or simply use the tools copy

framecount incorrectly handled when AUD_TO_USB_RATIO != 1

Getting weird lr_clck waveforms - framecount reset should be outside of the ratio loop check.

Also a comment is out of date with recent code changes:

 /* Increase frameCount by 2 since we have output two channels (per data line) */
             frameCount+=1;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.