Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usb: USB Audio class implementation #21526

Merged
merged 8 commits into from
May 8, 2020

Conversation

eobalski
Copy link
Collaborator

@eobalski eobalski commented Dec 19, 2019

Tested on nRF52840 only, may not work for other platforms.

Two sample apps attached:
-> headphones + microphone
-> headset

Both apps perform loopback. See README.rst for details.

Fixes: #12775
Blocked by: #24735

@eobalski eobalski added area: USB Universal Serial Bus DNM This PR should not be merged (Do Not Merge) Feature A planned feature with a milestone labels Dec 19, 2019
@raveslave
Copy link

Great to see this work-in-progress!

  • would obviously be nice with support for both audio tx, rx endpoints, format types (stereo, sample rates, clocking etc)
  • feature units for controls like mute, gain
  • re: Kconfig/dts, I guess we can look a bit on how it's done in linux, there you have switches for pcm, rawmidi and more.

@eobalski
Copy link
Collaborator Author

  • would obviously be nice with support for both audio tx, rx endpoints, format types (stereo, sample rates, clocking etc)

There is plan for this, but I've started with basics.

  • feature units for controls like mute, gain

There is idea to use Kconfig for feature unit associated with headphones (Feature Unit) to choose what should be supported. This commit in this PR. This will be reworked in more elegant way using COND_CODE_1

  • re: Kconfig/dts, I guess we can look a bit on how it's done in linux, there you have switches for pcm, rawmidi and more.

I will have a look, thanks!

subsys/usb/class/audio/audio.c Outdated Show resolved Hide resolved
include/usb/class/usb_audio.h Outdated Show resolved Hide resolved
subsys/usb/class/audio/Kconfig Outdated Show resolved Hide resolved
subsys/usb/class/audio/audio.c Outdated Show resolved Hide resolved
subsys/usb/class/audio/audio.c Outdated Show resolved Hide resolved
subsys/usb/class/audio/audio.c Outdated Show resolved Hide resolved
subsys/usb/usb_device.c Outdated Show resolved Hide resolved
@eobalski eobalski requested a review from anangl December 20, 2019 12:37
@eobalski eobalski force-pushed the usb_audio_class branch 2 times, most recently from f8867fc to 0ce0cf8 Compare December 20, 2019 14:32
@eobalski eobalski force-pushed the usb_audio_class branch 3 times, most recently from 7bede92 to b0a3964 Compare January 17, 2020 15:18
@zephyrbot zephyrbot added area: API Changes to public APIs area: Samples Samples labels Jan 17, 2020
@zephyrbot
Copy link
Collaborator

zephyrbot commented Jan 17, 2020

All checks are passing now.

checkpatch (informational only, not a failure)

-:2789: WARNING:TRAILING_SEMICOLON: macros should not use a trailing semicolon
#2789: FILE: subsys/usb/class/audio/usb_audio_internal.h:332:
+#define USB_AUDIO_IAD_DECLARE struct usb_association_descriptor iad;

- total: 0 errors, 1 warnings, 2820 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Your patch has style problems, please review.

NOTE: Ignored message types: AVOID_EXTERNS BRACES CONFIG_EXPERIMENTAL CONST_STRUCT DATE_TIME FILE_PATH_CHANGES MINMAX NETWORKING_BLOCK_COMMENT_STYLE PRINTK_WITHOUT_KERN_LEVEL SPDX_LICENSE_TAG SPLIT_STRING VOLATILE

NOTE: If any of the errors are false positives, please report
      them to the maintainers.

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

@eobalski eobalski force-pushed the usb_audio_class branch 7 times, most recently from 1b567d9 to 41780b7 Compare January 24, 2020 12:23
@eobalski eobalski added the DNM This PR should not be merged (Do Not Merge) label Apr 29, 2020
@eobalski
Copy link
Collaborator Author

Pushed the branch with updates addresing @anangl comments.
Branch is now dependent on #24735.
Branch is presenting the fix for #24200 which is global, class specific issue.
This PR does not solve the issue absolutely.

@eobalski eobalski force-pushed the usb_audio_class branch 2 times, most recently from b1ba354 to e42f9b4 Compare May 5, 2020 12:56
include/usb/class/usb_audio.h Outdated Show resolved Hide resolved
include/usb/class/usb_audio.h Outdated Show resolved Hide resolved
include/usb/class/usb_audio.h Outdated Show resolved Hide resolved
samples/subsys/usb/audio/headphones_microphone/prj.conf Outdated Show resolved Hide resolved
subsys/usb/class/audio/usb_audio_internal.h Outdated Show resolved Hide resolved
subsys/usb/class/audio/audio.c Outdated Show resolved Hide resolved
subsys/usb/class/audio/audio.c Outdated Show resolved Hide resolved
subsys/usb/class/audio/audio.c Outdated Show resolved Hide resolved
@carlescufi carlescufi added this to the v2.3.0 milestone May 6, 2020
subsys/usb/class/audio/usb_audio_internal.h Outdated Show resolved Hide resolved
subsys/usb/class/audio/audio.c Outdated Show resolved Hide resolved
subsys/usb/class/audio/audio.c Outdated Show resolved Hide resolved
include/usb/class/usb_audio.h Outdated Show resolved Hide resolved
subsys/usb/class/audio/audio.c Outdated Show resolved Hide resolved
subsys/usb/class/audio/audio.c Outdated Show resolved Hide resolved
subsys/usb/class/audio/audio.c Show resolved Hide resolved
@eobalski
Copy link
Collaborator Author

eobalski commented May 7, 2020

Updated with @jfischer-phytec-iot comments (please revisit) and rebased.

@eobalski eobalski removed the DNM This PR should not be merged (Do Not Merge) label May 7, 2020
subsys/usb/class/audio/audio.c Show resolved Hide resolved
samples/subsys/usb/audio/headphones_microphone/README.rst Outdated Show resolved Hide resolved
samples/subsys/usb/audio/headphones_microphone/README.rst Outdated Show resolved Hide resolved
samples/subsys/usb/audio/headset/README.rst Outdated Show resolved Hide resolved
samples/subsys/usb/audio/headset/README.rst Outdated Show resolved Hide resolved
Emil Obalski added 6 commits May 7, 2020 15:59
By this commit exception for ISO endpoints is made when it comes
to its size. ISO endpoint buffer size for nrf devices is 1023 and
may be configured with variable length size. NRFX checks is size
is chosen accordingly and it is no reason to do it in SHIM.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This commit updates definitions to better match usb 2.0 spec.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This commit adds enumeration type for isochronous
endpoints specific information required by USB Audio Class.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This commit adds files related to USB audio device class.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This commit adds support for receiveing data from ISO OUT endpoint
for NRF devices. NRF USB IP core does not generate IRQ when
data are received on ISO OUT endpoint and it must be synchronized
with SOF event.

Enable SOF handling by default if usb audio is configured
with NRF devices.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
By this commit USB audio class implementation is introduced
to Zephyr.

The Zephyr USB audio device class follows bellow
documentations:

- Universal Serial Bus specification rev2.0 (usb20.pdf)
- Universal Serial Bus Device Class Definition for Audio Devices
  (audio10.pdf)
- Universal Serial Bus Device Class Definition for Audio Data Formats
  (frmts10.pdf)
- Universal Serial Bus Device Class Definition for Terminal Types
  (termt10.pdf)

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Emil Obalski added 2 commits May 8, 2020 12:24
This commit adds USB audio sample for Zephyr project.

The sample configures two devices:
- Microphone (2 channels, Fs=48kHz, PCM format)
- Headphones (2 channels, Fs=48kHz, PCM format)

Input data stream is passed to output data stream.

For more details refer to README.rst.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This commit adds USB audio sample to the Zephyr project.

The sample configures one I/O device:
- Headset (2 channels, Fs=48kHz, PCM format)

Input data sstream is passed to output data stream.

For more details refer to README.rst.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Copy link
Member

@carlescufi carlescufi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work Emil, thanks!

@carlescufi carlescufi merged commit 6789ecb into zephyrproject-rtos:master May 8, 2020
@arvid-r
Copy link
Collaborator

arvid-r commented May 8, 2020

Well done! Great work.

@eobalski eobalski deleted the usb_audio_class branch July 14, 2020 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: Devicetree area: Samples Samples area: USB Universal Serial Bus Feature A planned feature with a milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

USB audio isochronous endpoints
10 participants