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: device_next: uac2: Generate Feature Unit descriptor #79634

Merged

Conversation

tmon-nordic
Copy link
Contributor

This PR is limited to Feature Unit descriptor generation because the implementation needed a change in the Zephyr devicetree generator scripts to support string-array properties with enum.

Each Feature Unit control (15 different controls are defined by UAC2 specification) can be present on none (property absent), one channel (e.g. only on Primary channel = property present with just a single value), or any number of channel (e.g. only on Logical channel 1). The use of string-array allows to facilitate any possible control combination (instead of e.g. forcing all logical channels to have the same value as Primary channel) while making the devicetree representation easy to understand and allowing reasonable devicetree-level validation (the strings allowed are one of the enum values) and build-time (each control property can have at most 1 + logical channel values).

@@ -609,15 +609,16 @@ def write_vanilla_props(node: edtlib.Node) -> None:
if spec.enum_tokenizable:
as_token = prop.val_as_token

# DT_N_<node-id>_P_<prop-id>_ENUM_VAL_<val>_EXISTS 1
macro2val[macro + f"_ENUM_VAL_{as_token}_EXISTS"] = 1
if "array" not in prop.type:
Copy link
Member

Choose a reason for hiding this comment

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

see #71497

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that #71497 is merged, all I had to do is to rebase and drop my first commit ("devicetree: Allow using enum with string-array properties").

Add initial Feature Unit bindings allowing user to place the Feature
Unit inside UAC2 instance description. Currently the bindings facilitate
only specifying which controls are available on the Primary channel 0
and on each Logical channel. The number of Logical channels has to be
derived from data-source property.

Signed-off-by: Tomasz Moń <[email protected]>
Rework NUM_SPATIAL_LOCATIONS() to evaluate to integer literal to allow
using it with LISTIFY() macro. This is necessary because Feature Unit do
not operate on channel clusters but rather on logical channels.

Track back Output Terminal channel cluster to appropriate entity. This
is necessary because Feature Unit does not repeat the channel cluster
information.

Signed-off-by: Tomasz Moń <[email protected]>
Insert Feature Units in between:
  * USB Streaming Input Terminal and Headphones Output Terminal
  * Microphone Input Terminal and USB Streaming Output Terminal

The Feature Units have Mute control only on the Primary channel 0.
The headphones Feature Unit also has Automatic Gain control on all
channels while microphone Feature Unit has Automatic Gain control only
on the Logichal channel 1.

Signed-off-by: Tomasz Moń <[email protected]>
@tmon-nordic tmon-nordic force-pushed the uac2-feature-unit-bindings branch from 6b9dc5c to 33c8195 Compare October 15, 2024 08:14
@dleach02 dleach02 merged commit 7c7383c into zephyrproject-rtos:main Oct 15, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree area: USB Universal Serial Bus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants