Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0054ae9
usb: host: rename "struct usbh_contex" to "usbh_context"
Aug 9, 2025
1bad1d0
usb: host: ensure device configuration descriptors are nil-terminated
Jul 26, 2025
4202f6e
usb: host: add host status to the host context
Aug 8, 2025
dedc29a
usb: host: wrap the mutex lock with a helper
Aug 8, 2025
2a7863a
samples: usb: shell: update the output in the README
Aug 14, 2025
1ddca71
usb: host: class: implement more of the class/data struct fields
Aug 14, 2025
7aa4f8d
usb: host: introduce wrappers to access the class function pointers
Aug 15, 2025
bdd549f
usb: host: introduce usbh_class with init functions
Aug 15, 2025
a40fb36
usb: host: implement class filtering and descriptor browsing
Aug 16, 2025
e57477d
usb: uvc: move the header definition to include/
Jul 25, 2025
d6ba924
usb: uvc: prepare the header to be used for both host and device
Aug 17, 2025
94c43f4
uvc: device: move helper functions to a common directory
Aug 17, 2025
faec7f0
usb: host: class: implement usb host video class
AidenHu Jun 9, 2025
84e7ddb
usb: host: update host core to support multi usb classes
AidenHu Aug 6, 2025
48f918f
boards: nxp: rd_rw612_bga: add missed usb host and lcd node
AidenHu Aug 6, 2025
09c5ac6
samples: drivers: video: update video capture sample.
AidenHu Aug 6, 2025
dc968dd
dts: arm: nxp: update nxp_rw6xx_common.dtsi for usb host.
AidenHu Aug 6, 2025
b66ab3c
soc: nxp: rw: update soc.c of rw for usb clock
AidenHu Aug 6, 2025
bce9f09
drivers: usb: uhc: update usb host driver
AidenHu Aug 14, 2025
5d560bc
subsys: usb: host: correct parameters for the class functions
AidenHu Aug 19, 2025
eea5207
subsys: usb: host: fix class match issue and add remove handling
AidenHu Aug 19, 2025
1362e88
subsys: usb: host: fix descriptor parsing by updating curr_addr
AidenHu Aug 19, 2025
96b6bec
modules: hal_nxp: mcux: update macros for usb host EHCI
AidenHu Aug 19, 2025
49b6370
usb: host: class: improve host video class.
AidenHu Aug 19, 2025
91fa606
usb: host: class: use common usb uvc header for host uvc class
AidenHu Aug 20, 2025
1ce0e22
usb: uvc: add more contents for the header used by host and device
AidenHu Aug 20, 2025
d12370e
subsys: usb: host: enhance host video stream transfer
AidenHu Sep 4, 2025
f428572
usb: host: class: add symbol USBH_VIDEO_MULTIPLE_PRIME_COUNT
AidenHu Sep 5, 2025
0c21bc2
samples: drivers: video: improve the video capture sample
AidenHu Sep 5, 2025
9328c37
usb: host: class: improve the video control handling
AidenHu Sep 16, 2025
7af56c4
drivers: video: expose video_find_ctrl by removing static keyword
AidenHu Sep 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions boards/nxp/rd_rw612_bga/rd_rw612_bga.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ zephyr_udc0: &usb_otg {
status = "okay";
};

zephyr_uhc0: &usbh {
status = "okay";
};

&dma0 {
status = "okay";
};
Expand Down Expand Up @@ -316,3 +320,13 @@ nxp_8080_touch_panel_i2c: &arduino_i2c {
status = "okay";
wakeup-source;
};

zephyr_mipi_dbi_spi: &lcdic {
status = "okay";
pinctrl-0 = <&pinmux_lcdic>;
pinctrl-names = "default";
};

nxp_pmod_touch_panel_i2c: &arduino_i2c {
status = "okay";
};
2 changes: 2 additions & 0 deletions boards/nxp/rd_rw612_bga/rd_rw612_bga.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ supported:
- pwm
- spi
- usb_device
- usb_host
- usbh
- watchdog
3 changes: 3 additions & 0 deletions drivers/usb/uhc/uhc_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
const struct uhc_api *api = dev->api;
struct uhc_transfer *xfer = NULL;
uint16_t mps;
uint8_t interval;

api->lock(dev);

Expand All @@ -125,6 +126,7 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
}

mps = ep_desc->wMaxPacketSize;
interval = ep_desc->bInterval;
}

LOG_DBG("Allocate xfer, ep 0x%02x mps %u cb %p", ep, mps, cb);
Expand All @@ -137,6 +139,7 @@ struct uhc_transfer *uhc_xfer_alloc(const struct device *dev,
memset(xfer, 0, sizeof(struct uhc_transfer));
xfer->ep = ep;
xfer->mps = mps;
xfer->interval = interval;
xfer->udev = udev;
xfer->cb = cb;
xfer->priv = cb_priv;
Expand Down
9 changes: 7 additions & 2 deletions drivers/usb/uhc/uhc_mcux_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,20 +280,21 @@ usb_host_pipe_t *uhc_mcux_init_hal_ep(const struct device *dev, struct uhc_trans
/* USB_HostHelperGetPeripheralInformation uses this value as first parameter */
pipe_init.devInstance = xfer->udev;
pipe_init.nakCount = USB_HOST_CONFIG_MAX_NAK;
pipe_init.maxPacketSize = xfer->mps;
pipe_init.maxPacketSize = USB_MPS_EP_SIZE(xfer->mps);
pipe_init.endpointAddress = USB_EP_GET_IDX(xfer->ep);
pipe_init.direction = USB_EP_GET_IDX(xfer->ep) == 0 ? USB_OUT :
USB_EP_GET_DIR(xfer->ep) ? USB_IN : USB_OUT;
/* Current Zephyr Host stack is experimental, the endpoint's interval,
* 'number per uframe' and the endpoint type cannot be got yet.
*/
pipe_init.numberPerUframe = 0; /* TODO: need right way to implement it. */
pipe_init.numberPerUframe = USB_MPS_ADDITIONAL_TRANSACTIONS(xfer->mps);
pipe_init.interval = xfer->interval;
/* TODO: need right way to implement it. */
if (pipe_init.endpointAddress == 0) {
pipe_init.pipeType = USB_ENDPOINT_CONTROL;
} else {
pipe_init.pipeType = USB_ENDPOINT_BULK;
pipe_init.pipeType = USB_ENDPOINT_ISOCHRONOUS;
}

status = priv->mcux_if->controllerOpenPipe(priv->mcux_host.controllerHandle,
Expand Down Expand Up @@ -353,6 +354,10 @@ int uhc_mcux_hal_init_transfer_common(const struct device *dev, usb_host_transfe
? USB_IN
: USB_OUT;
}
else
{
mcux_xfer->direction = USB_EP_DIR_IS_IN(xfer->ep) ? USB_IN : USB_OUT;
}

return 0;
}
4 changes: 4 additions & 0 deletions drivers/usb/uhc/uhc_mcux_ehci.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ static usb_host_transfer_t *uhc_mcux_hal_init_transfer(const struct device *dev,
memcpy(mcux_xfer->setupPacket, xfer->setup_pkt, 8u);
if (xfer->buf != NULL) {
mcux_xfer->transferBuffer = uhc_mcux_nocache_alloc(mcux_xfer->transferLength);
if (mcux_xfer->transferBuffer == NULL)
{
LOG_ERR("Failed to allocate non-cached transfer buffer");
}
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion drivers/video/video_ctrls.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void video_auto_cluster_ctrl(struct video_ctrl *ctrls, uint8_t sz, bool set_vola
}
}

static int video_find_ctrl(const struct device *dev, uint32_t id, struct video_ctrl **ctrl)
int video_find_ctrl(const struct device *dev, uint32_t id, struct video_ctrl **ctrl)
{
struct video_device *vdev = video_find_vdev(dev);

Expand Down
2 changes: 2 additions & 0 deletions drivers/video/video_ctrls.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ int video_init_menu_ctrl(struct video_ctrl *ctrl, const struct device *dev, uint
int video_init_int_menu_ctrl(struct video_ctrl *ctrl, const struct device *dev, uint32_t id,
uint8_t def, const int64_t menu[], size_t menu_len);

int video_find_ctrl(const struct device *dev, uint32_t id, struct video_ctrl **ctrl);

void video_cluster_ctrl(struct video_ctrl *ctrls, uint8_t sz);

void video_auto_cluster_ctrl(struct video_ctrl *ctrls, uint8_t sz, bool set_volatile);
Expand Down
9 changes: 9 additions & 0 deletions dts/arm/nxp/nxp_rw6xx_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,15 @@
status = "disabled";
};

usbh: usbh@145000 {
compatible = "nxp,uhc-ehci";
reg = <0x145000 0x200>;
interrupts = <50 1>;
interrupt-names = "usb_otg";
power-domains = <&power_mode3_domain>;
status = "disabled";
};

flexcomm0: flexcomm@106000 {
compatible = "nxp,lpc-flexcomm";
reg = <0x106000 0x1000>;
Expand Down
12 changes: 12 additions & 0 deletions dts/bindings/usb/zephyr,uvc-host.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2025 NXP
# SPDX-License-Identifier: Apache-2.0

description: |
USB Video Class (UVC) host instance.

Each UVC instance added to the USB Host Controller (UHC) node will be visible
as a new camera from the host point of view.

compatible: "zephyr,uvc-host"

include: base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,26 @@
* - USB Device Class Definition for Video Devices: Motion-JPEG Payload (Revision 1.5)
*/

#ifndef ZEPHYR_INCLUDE_USBD_CLASS_UVC_H_
#define ZEPHYR_INCLUDE_USBD_CLASS_UVC_H_
#ifndef ZEPHYR_INCLUDE_USB_CLASS_UVC_H_
#define ZEPHYR_INCLUDE_USB_CLASS_UVC_H_

#include <zephyr/usb/usb_ch9.h>

/* Video Class-Specific Request Codes */
#define UVC_SET_CUR 0x01
#define UVC_GET_CUR 0x81
#define UVC_SET_CUR_ALL 0x11
#define UVC_GET_MIN 0x82
#define UVC_GET_MAX 0x83
#define UVC_GET_RES 0x84
#define UVC_GET_LEN 0x85
#define UVC_GET_INFO 0x86
#define UVC_GET_INFO 0x86
#define UVC_GET_DEF 0x87
#define UVC_GET_CUR_ALL 0x91
#define UVC_GET_MIN_ALL 0x92
#define UVC_GET_MAX_ALL 0x93
#define UVC_GET_RES_ALL 0x94
#define UVC_GET_DEF_ALL 0x97

/* Flags announcing which controls are supported */
#define UVC_INFO_SUPPORTS_GET BIT(0)
Expand All @@ -55,6 +61,8 @@
#define UVC_BMHEADERINFO_ERROR BIT(6)
#define UVC_BMHEADERINFO_END_OF_HEADER BIT(7)

/* Video Interface Class Codes */
#define UVC_SC_VIDEOCLASS 0x0E
/* Video Interface Subclass Codes */
#define UVC_SC_VIDEOCONTROL 0x01
#define UVC_SC_VIDEOSTREAMING 0x02
Expand Down Expand Up @@ -119,6 +127,7 @@
#define UVC_EXT_COMPONENT_CONNECTOR 0x0403

/* VideoStreaming Interface Controls */
#define UVC_VS_CONTROL_UNDEFINED 0x00
#define UVC_VS_PROBE_CONTROL 0x01
#define UVC_VS_COMMIT_CONTROL 0x02
#define UVC_VS_STILL_PROBE_CONTROL 0x03
Expand All @@ -138,6 +147,7 @@
#define UVC_SU_INPUT_SELECT_CONTROL 0x01

/* Camera Terminal Controls */
#define UVC_CT_CONTROL_UNDEFINED 0x00
#define UVC_CT_SCANNING_MODE_CONTROL 0x01
#define UVC_CT_AE_MODE_CONTROL 0x02
#define UVC_CT_AE_PRIORITY_CONTROL 0x03
Expand Down Expand Up @@ -202,6 +212,52 @@
#define UVC_EU_START_OR_STOP_LAYER_CONTROL 0x13
#define UVC_EU_ERROR_RESILIENCY_CONTROL 0x14

/* Processing Unit Control Bit Positions (for bmControls bitmap) */
#define UVC_PU_BMCONTROL_BRIGHTNESS BIT(0)
#define UVC_PU_BMCONTROL_CONTRAST BIT(1)
#define UVC_PU_BMCONTROL_HUE BIT(2)
#define UVC_PU_BMCONTROL_SATURATION BIT(3)
#define UVC_PU_BMCONTROL_SHARPNESS BIT(4)
#define UVC_PU_BMCONTROL_GAMMA BIT(5)
#define UVC_PU_BMCONTROL_WHITE_BALANCE_TEMPERATURE BIT(6)
#define UVC_PU_BMCONTROL_WHITE_BALANCE_COMPONENT BIT(7)
#define UVC_PU_BMCONTROL_BACKLIGHT_COMPENSATION BIT(8)
#define UVC_PU_BMCONTROL_GAIN BIT(9)
#define UVC_PU_BMCONTROL_POWER_LINE_FREQUENCY BIT(10)
#define UVC_PU_BMCONTROL_HUE_AUTO BIT(11)
#define UVC_PU_BMCONTROL_WHITE_BALANCE_TEMPERATURE_AUTO BIT(12)
#define UVC_PU_BMCONTROL_WHITE_BALANCE_COMPONENT_AUTO BIT(13)
#define UVC_PU_BMCONTROL_DIGITAL_MULTIPLIER BIT(14)
#define UVC_PU_BMCONTROL_DIGITAL_MULTIPLIER_LIMIT BIT(15)
#define UVC_PU_BMCONTROL_ANALOG_VIDEO_STANDARD BIT(16)
#define UVC_PU_BMCONTROL_ANALOG_LOCK_STATUS BIT(17)
#define UVC_PU_BMCONTROL_CONTRAST_AUTO BIT(18)
/* Bits 19-23 are reserved for future use */

/* Camera Terminal Control Bit Positions (for bmControls bitmap) */
#define UVC_CT_BMCONTROL_SCANNING_MODE BIT(0)
#define UVC_CT_BMCONTROL_AE_MODE BIT(1)
#define UVC_CT_BMCONTROL_AE_PRIORITY BIT(2)
#define UVC_CT_BMCONTROL_EXPOSURE_TIME_ABSOLUTE BIT(3)
#define UVC_CT_BMCONTROL_EXPOSURE_TIME_RELATIVE BIT(4)
#define UVC_CT_BMCONTROL_FOCUS_ABSOLUTE BIT(5)
#define UVC_CT_BMCONTROL_FOCUS_RELATIVE BIT(6)
#define UVC_CT_BMCONTROL_IRIS_ABSOLUTE BIT(7)
#define UVC_CT_BMCONTROL_IRIS_RELATIVE BIT(8)
#define UVC_CT_BMCONTROL_ZOOM_ABSOLUTE BIT(9)
#define UVC_CT_BMCONTROL_ZOOM_RELATIVE BIT(10)
#define UVC_CT_BMCONTROL_PAN_TILT_ABSOLUTE BIT(11)
#define UVC_CT_BMCONTROL_PAN_TILT_RELATIVE BIT(12)
#define UVC_CT_BMCONTROL_ROLL_ABSOLUTE BIT(13)
#define UVC_CT_BMCONTROL_ROLL_RELATIVE BIT(14)
/* Bits 15-16 are reserved */
#define UVC_CT_BMCONTROL_FOCUS_AUTO BIT(17)
#define UVC_CT_BMCONTROL_PRIVACY BIT(18)
#define UVC_CT_BMCONTROL_FOCUS_SIMPLE BIT(19)
#define UVC_CT_BMCONTROL_WINDOW BIT(20)
#define UVC_CT_BMCONTROL_REGION_OF_INTEREST BIT(21)
/* Bits 22-23 are reserved for future use */

/* Extension Unit Controls */
#define UVC_XU_BASE_CONTROL 0x00

Expand All @@ -222,7 +278,7 @@ struct uvc_control_header_descriptor {
uint16_t wTotalLength;
uint32_t dwClockFrequency;
uint8_t bInCollection;
uint8_t baInterfaceNr[1];
uint8_t baInterfaceNr[];
} __packed;

struct uvc_unit_descriptor {
Expand All @@ -232,6 +288,16 @@ struct uvc_unit_descriptor {
uint8_t bUnitID;
};

struct uvc_input_terminal_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bTerminalID;
uint16_t wTerminalType;
uint8_t bAssocTerminal;
uint8_t iTerminal;
} __packed;

struct uvc_output_terminal_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
Expand Down Expand Up @@ -307,10 +373,10 @@ struct uvc_extension_unit_descriptor {
uint8_t iExtension;
} __packed;

struct uvc_stream_header_descriptor {
struct uvc_stream_input_header_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubtype;
uint8_t bDescriptorSubType;
uint8_t bNumFormats;
uint16_t wTotalLength;
uint8_t bEndpointAddress;
Expand All @@ -320,6 +386,19 @@ struct uvc_stream_header_descriptor {
uint8_t bTriggerSupport;
uint8_t bTriggerUsage;
uint8_t bControlSize;
uint8_t bmControls[];
} __packed;

struct uvc_stream_output_header_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bNumFormats;
uint16_t wTotalLength;
uint8_t bEndpointAddress;
uint8_t bTerminalLink;
uint8_t bControlSize;
uint8_t bmControls[];
} __packed;

struct uvc_frame_still_image_descriptor {
Expand Down Expand Up @@ -348,7 +427,7 @@ struct uvc_format_descriptor {
struct uvc_format_uncomp_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubtype;
uint8_t bDescriptorSubType;
uint8_t bFormatIndex;
uint8_t bNumFrameDescriptors;
uint8_t guidFormat[16];
Expand All @@ -363,7 +442,7 @@ struct uvc_format_uncomp_descriptor {
struct uvc_format_mjpeg_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubtype;
uint8_t bDescriptorSubType;
uint8_t bFormatIndex;
uint8_t bNumFrameDescriptors;
uint8_t bmFlags;
Expand All @@ -375,10 +454,18 @@ struct uvc_format_mjpeg_descriptor {
uint8_t bCopyProtect;
} __packed;

struct uvc_format_descriptor_header {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
uint8_t bFormatIndex;
uint8_t bNumFrameDescriptors;
} __packed;

struct uvc_frame_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubtype;
uint8_t bDescriptorSubType;
uint8_t bFrameIndex;
uint8_t bmCapabilities;
uint16_t wWidth;
Expand All @@ -394,7 +481,7 @@ struct uvc_frame_descriptor {
struct uvc_frame_continuous_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubtype;
uint8_t bDescriptorSubType;
uint8_t bFrameIndex;
uint8_t bmCapabilities;
uint16_t wWidth;
Expand Down Expand Up @@ -422,7 +509,18 @@ struct uvc_frame_discrete_descriptor {
uint32_t dwMaxVideoFrameBufferSize;
uint32_t dwDefaultFrameInterval;
uint8_t bFrameIntervalType;
/* TODO: commonly configurable frame interval ( suggestion: uint32_t dwFrameInterval[]; )*/
#ifdef CONFIG_USBD_VIDEO_MAX_FRMIVAL
uint32_t dwFrameInterval[CONFIG_USBD_VIDEO_MAX_FRMIVAL];
#else
uint32_t dwFrameInterval[1];
#endif
} __packed;

struct uvc_cs_descriptor_header {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorSubType;
} __packed;

struct uvc_color_descriptor {
Expand Down Expand Up @@ -481,4 +579,4 @@ struct uvc_payload_header {
uint16_t scrSourceClockSOF; /* optional */
} __packed;

#endif /* ZEPHYR_INCLUDE_USBD_CLASS_UVC_H_ */
#endif /* ZEPHYR_INCLUDE_USB_CLASS_UVC_H_ */
Loading