Skip to content

Conversation

@josuah
Copy link
Contributor

@josuah josuah commented Aug 17, 2025

Dependency:

Downstream:

NOTE: this PR also contains the commit of #94504 and #94590

On top of the commits from the previous PRs:

  • split UVC helpers out of the device stack so that they can be used with the host stack.

UVC Device still works:

west build --build-dir build-uvc -b nrf52840dk/nrf52840 -S video-sw-generator samples/subsys/usb/uvc/

mpv-shot0001

All tests are done on top of main...josuah:zephyr:pr_usb_host_class_api3

@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 4, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
E Reliability Rating on New Code (required ≥ C)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@josuah josuah force-pushed the pr_usb_host_class_api3 branch from 6a5c7fc to 71cb2cf Compare October 9, 2025 21:23
@josuah josuah force-pushed the pr_usb_host_class_api3 branch 4 times, most recently from 2fd3ae8 to a38c550 Compare October 30, 2025 00:49
@josuah
Copy link
Contributor Author

josuah commented Oct 30, 2025

Force-push:

  • Fix some CI errors
  • re-base on top of recent API2 PR
  • integrate tests for the class filtering API

@josuah josuah force-pushed the pr_usb_host_class_api3 branch 2 times, most recently from cb1281f to c1c99ae Compare October 30, 2025 18:52
@josuah
Copy link
Contributor Author

josuah commented Oct 30, 2025

The UVC implementation there is a stub, does not provide anything useful besides logging the descriptors.

The purpose is to show how to implement basic descriptors access and how to use unit tests on host+device class together.

@josuah josuah marked this pull request as ready for review October 30, 2025 21:15
@zephyrbot zephyrbot added area: Devicetree area: Devicetree Bindings area: Boards/SoCs area: USB Universal Serial Bus area: Tests Issues related to a particular existing or missing test labels Oct 30, 2025
@AidenHu
Copy link
Contributor

AidenHu commented Nov 7, 2025

Dependency:

* [USB Host: integrate class API [2: helpers] #94590](https://github.com/zephyrproject-rtos/zephyr/pull/94590)

Downstream:

* [usb: host: class: support for usb host video class #94085](https://github.com/zephyrproject-rtos/zephyr/pull/94085)

NOTE: this PR also contains the commit of #94504 and #94590

On top of the commits from the previous PRs:

* split UVC helpers out of the device stack so that they can be used with the host stack.

UVC Device still works:

west build --build-dir build-uvc -b nrf52840dk/nrf52840 -S video-sw-generator samples/subsys/usb/uvc/

mpv-shot0001

All tests are done on top of main...josuah:zephyr:pr_usb_host_class_api3

Hi @josuah
I have viewed the changes in this PR and I will think about the unit test for host ecm in the future.
Furthermore, I see you also provided usbh_uvc.c in this PR. Considering the usb host video class driver is also implemented in #94085, just want to know what the plan is about the next step aimed for this class driver. Be appreciated for your any comment, Thanks.

@josuah
Copy link
Contributor Author

josuah commented Nov 7, 2025

also implemented in #94085, just want to know what the plan is about the next step aimed for this class driver

The UVC implementation in my PR ("API3") is just a demo of the API, #94085 is more complete and good structure for the UVC/Video part. And needed most changes for the USB API part (as far as I understand).

I wanted to try to import all the commits of #94085 on to of #94591 so that #94085 only needs to add usbh_uvc.c, CMakeLists.txt, Kconfig.

I was working on nRG54LM20 (and ESP32) to be able to test UVC on DWC2 USB host. As soon as this is complete, I can try.

@AidenHu
Copy link
Contributor

AidenHu commented Nov 10, 2025

also implemented in #94085, just want to know what the plan is about the next step aimed for this class driver

The UVC implementation in my PR ("API3") is just a demo of the API, #94085 is more complete and good structure for the UVC/Video part. And needed most changes for the USB API part (as far as I understand).

I wanted to try to import all the commits of #94085 on to of #94591 so that #94085 only needs to add usbh_uvc.c, CMakeLists.txt, Kconfig.

I was working on nRG54LM20) (and ESP32) to be able to test UVC on DWC2 USB host. As soon as this is complete, I can try to test

@josuah, thank you for clarification.

Josuah Demangeon and others added 7 commits November 20, 2025 01:00
Add a "struct usbh_status" that contains a bitmask of flags to keep
track of the global state of the host context, like done for the
device_next implementation.

Signed-off-by: Josuah Demangeon <[email protected]>
Add missing copyright notice for the linker script to help with
check_compliance.py.

Signed-off-by: Josuah Demangeon <[email protected]>
Add a "struct usbh_class_api" for the host implementation, and move all
the function poitners to it. Add more fields to "struct usbh_class_data".

Signed-off-by: Josuah Demangeon <[email protected]>
Add API wrappers around the function pointers in struct usbh_class_api,
while also documenting the USB host class internal API.

Signed-off-by: Josuah Demangeon <[email protected]>
Add functions to probe/remove all classes as part of a new usbh_class.c
and a matching usbh_class.h. These functions are called from the function
usbh_init_device_intl() in usbh_core.c to initialize every class upon
connection of a device. Every class driver provide filters to match the
interfaces of the device.

Co-authored-by: Aiden Hu <[email protected]>
Signed-off-by: Josuah Demangeon <[email protected]>
Move the UVC header with all the definitions from the UVC standard to
share it between USB host and device class implementation.

Signed-off-by: Josuah Demangeon <[email protected]>
Add tests making sure the USB Host class APIs introduced build
and run as expected.

Signed-off-by: Josuah Demangeon <[email protected]>
@josuah josuah force-pushed the pr_usb_host_class_api3 branch from c1c99ae to 70b627c Compare November 20, 2025 19:28
Josuah Demangeon added 3 commits November 20, 2025 21:38
Loop through each of the VideoStreaming and VideoControl descriptor
to parse them. This is meant as a stub for the purpose of testing the
class API.

Signed-off-by: Josuah Demangeon <[email protected]>
Add a test to run the USB Video Class host support by using
the existing Zephyr USB Video Class device support.
This allows running implementing the host side from the device side.
A draft implementation of UVC is added leveraging this test.

Signed-off-by: Josuah Demangeon <[email protected]>
The public API file <zephyr/usb/class/usbd_uvc.h> lacked an include
to <zephyr/drivers/video.h> making it fail depending on the order of
the includes.

Signed-off-by: Josuah Demangeon <[email protected]>
@josuah josuah force-pushed the pr_usb_host_class_api3 branch from 70b627c to 3456f3b Compare November 20, 2025 21:43
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Boards/SoCs area: Devicetree Bindings area: Devicetree area: Tests Issues related to a particular existing or missing test area: USB Universal Serial Bus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants