This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit bab7e3e51b16183a3c4776a6c556567e7b8937a0
Author: wangjianyu3 <[email protected]>
AuthorDate: Thu Mar 19 19:38:06 2026 +0800

    boards/lckfb-szpi-esp32s3: add UVC camera standalone defconfig
    
    Add UVC configuration for lckfb-szpi-esp32s3 board based on gc0308
    camera config, with USB OTG and UVC gadget driver enabled in
    standalone (non-composite) mode.
    
    - defconfig: enable ESP32S3_OTG, USBUVC, UVC example app
    - board doc: add uvc section with usage and host verification
    
    Signed-off-by: wangjianyu3 <[email protected]>
---
 .../applications/examples/uvc_cam/index.rst        | 72 ++++++++++++++++++++++
 .../esp32s3/boards/lckfb-szpi-esp32s3/index.rst    | 47 ++++++++++++++
 .../lckfb-szpi-esp32s3/configs/uvc/defconfig       | 66 ++++++++++++++++++++
 3 files changed, 185 insertions(+)

diff --git a/Documentation/applications/examples/uvc_cam/index.rst 
b/Documentation/applications/examples/uvc_cam/index.rst
new file mode 100644
index 00000000000..a6d4eba6eb4
--- /dev/null
+++ b/Documentation/applications/examples/uvc_cam/index.rst
@@ -0,0 +1,72 @@
+=============================================
+``uvc_cam`` UVC Camera streaming application
+=============================================
+
+Captures frames from a V4L2 camera sensor and streams them to a USB host
+via the UVC (USB Video Class) gadget driver (``/dev/uvc0``).
+
+The application queries the sensor's native pixel format, resolution and
+frame rate via V4L2, then continuously captures frames and writes them to
+the UVC device node.
+
+Dependencies
+==========================
+
+- :code:`CONFIG_USBUVC=y` – UVC gadget driver
+- :code:`CONFIG_VIDEO=y` – Video subsystem
+- :code:`CONFIG_BOARDCTL_USBDEVCTRL=y` – USB device control via boardctl
+
+Configuration
+==========================
+
+- :code:`CONFIG_EXAMPLES_UVC_CAM=y` – Enable the UVC camera example
+- :code:`CONFIG_EXAMPLES_UVC_CAM_NFRAMES` – Number of frames to stream (0 = 
infinite, default)
+- :code:`CONFIG_EXAMPLES_UVC_CAM_PRIORITY` – Task priority (default 100)
+- :code:`CONFIG_EXAMPLES_UVC_CAM_STACKSIZE` – Stack size (default 4096)
+
+Supported Pixel Formats
+==========================
+
+- ``YUYV`` (2 bytes per pixel)
+- ``RGB565`` (2 bytes per pixel)
+- ``RGB24`` (3 bytes per pixel)
+
+Usage
+==========================
+
+.. code-block:: bash
+
+   uvc_cam [nframes] [video_dev] [uvc_dev]
+
+- ``nframes`` – Number of frames to capture (default from Kconfig, 0 = 
infinite)
+- ``video_dev`` – V4L2 camera device path (default ``/dev/video0``)
+- ``uvc_dev`` – UVC gadget device path (default ``/dev/uvc0``)
+
+Examples
+==========================
+
+- Stream indefinitely with defaults: :code:`uvc_cam`
+- Stream 100 frames: :code:`uvc_cam 100`
+- Use a different camera device: :code:`uvc_cam 0 /dev/video1`
+- Specify both camera and UVC device: :code:`uvc_cam 0 /dev/video0 /dev/uvc1`
+
+Board Support
+==========================
+
+The ``lckfb-szpi-esp32s3`` board provides a ``uvc`` configuration with
+camera and UVC gadget driver pre-enabled::
+
+   $ ./tools/configure.sh lckfb-szpi-esp32s3:uvc
+
+This configuration enables the ESP32-S3 camera interface (GC0308 sensor),
+USB OTG and the UVC gadget driver.  The ``uvc_cam`` example application is
+not enabled by default and must be turned on manually::
+
+   $ kconfig-tweak --enable CONFIG_EXAMPLES_UVC_CAM
+
+Or via ``make menuconfig``:
+:menuselection:`Application Configuration --> Examples --> UVC Camera 
streaming example`
+
+After flashing, run the application manually from the NSH shell::
+
+   nsh> uvc_cam
diff --git 
a/Documentation/platforms/xtensa/esp32s3/boards/lckfb-szpi-esp32s3/index.rst 
b/Documentation/platforms/xtensa/esp32s3/boards/lckfb-szpi-esp32s3/index.rst
index 3a28c65433b..70a492c1286 100644
--- a/Documentation/platforms/xtensa/esp32s3/boards/lckfb-szpi-esp32s3/index.rst
+++ b/Documentation/platforms/xtensa/esp32s3/boards/lckfb-szpi-esp32s3/index.rst
@@ -576,3 +576,50 @@ Then use the camera example to capture a frame::
 
   $ adb -s 1234 shell
   nsh> camera
+
+uvc
+---
+
+USB Video Class (UVC) webcam configuration. Streams YUYV frames from the
+GC0308 DVP camera to a USB host via the UVC gadget driver (Bulk transport).
+The application queries the sensor resolution at runtime and configures the
+UVC descriptors accordingly. Console is accessible over UART0 (serial).
+
+The UVC driver also supports composite USB device mode
+(``CONFIG_USBUVC_COMPOSITE``), allowing it to be combined with other USB
+class drivers (e.g., CDC/ACM) in a single composite device.
+
+You can run the configuration and compilation procedure::
+
+  $ ./tools/configure.sh lckfb-szpi-esp32s3:uvc
+  $ make flash -j$(nproc) ESPTOOL_PORT=/dev/ttyUSB0
+
+The application should work as follows:
+
+1. Create ``/dev/video0`` via ``capture_initialize()`` and open it.
+2. Query the sensor's native resolution with ``VIDIOC_ENUM_FRAMESIZES``
+   (pixel format ``V4L2_PIX_FMT_YUYV``), then ``VIDIOC_S_FMT`` to configure.
+3. Fill ``struct uvc_params_s`` with the queried width, height and fps,
+   pass it to ``boardctl(BOARDIOC_USBDEV_CONTROL)`` via ``ctrl.handle``
+   so the UVC gadget builds USB descriptors matching the actual sensor.
+4. Open ``/dev/uvc0``, use ``poll()`` with ``POLLOUT`` to wait for the
+   USB host to start streaming.
+5. Loop: ``VIDIOC_QBUF`` / ``VIDIOC_DQBUF`` to capture a YUYV frame,
+   then ``write()`` to ``/dev/uvc0``.
+
+On the host side, verify the device is recognized::
+
+  $ sudo dmesg
+  [32982831.662622] usb 1-9.3.3: new full-speed USB device number 72 using 
xhci_hcd
+  [32982831.752856] usb 1-9.3.3: New USB device found, idVendor=1d6b, 
idProduct=0102, bcdDevice= 1.00
+  [32982831.752860] usb 1-9.3.3: New USB device strings: Mfr=1, Product=2, 
SerialNumber=3
+  [32982831.752861] usb 1-9.3.3: Product: NuttX UVC Camera
+  [32982831.752862] usb 1-9.3.3: Manufacturer: NuttX
+  [32982831.752863] usb 1-9.3.3: SerialNumber: 0001
+  [32982831.756625] usb 1-9.3.3: Found UVC 1.10 device NuttX UVC Camera 
(1d6b:0102)
+
+Then open the webcam with any UVC viewer (e.g. ``cheese``, ``guvcview``,
+or ``ffplay``)::
+
+  $ cheese
+
diff --git a/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/configs/uvc/defconfig 
b/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/configs/uvc/defconfig
new file mode 100644
index 00000000000..398f99986c6
--- /dev/null
+++ b/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/configs/uvc/defconfig
@@ -0,0 +1,66 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed 
.config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that 
includes your
+# modifications.
+#
+# CONFIG_ARCH_LEDS is not set
+# CONFIG_NSH_ARGCAT is not set
+# CONFIG_NSH_CMDOPT_HEXDUMP is not set
+CONFIG_ARCH="xtensa"
+CONFIG_ARCH_BOARD="lckfb-szpi-esp32s3"
+CONFIG_ARCH_BOARD_COMMON=y
+CONFIG_ARCH_BOARD_ESP32S3_LCKFB_SZPI=y
+CONFIG_ARCH_CHIP="esp32s3"
+CONFIG_ARCH_CHIP_ESP32S3=y
+CONFIG_ARCH_CHIP_ESP32S3WROOM1N16R8=y
+CONFIG_ARCH_INTERRUPTSTACK=2048
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_ARCH_XTENSA=y
+CONFIG_BOARDCTL_USBDEVCTRL=y
+CONFIG_BOARD_LOOPSPERMSEC=16717
+CONFIG_BUILTIN=y
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_DEV_GPIO=y
+CONFIG_ESP32S3_CAM=y
+CONFIG_ESP32S3_GPIO_IRQ=y
+CONFIG_ESP32S3_I2C0=y
+CONFIG_ESP32S3_OTG=y
+CONFIG_ESP32S3_OTG_ENDPOINT_NUM=2
+CONFIG_ESP32S3_UART0=y
+CONFIG_ESPRESSIF_LEDC=y
+CONFIG_ESPRESSIF_LEDC_CHANNEL0_PIN=42
+CONFIG_ESPRESSIF_LEDC_TIMER0=y
+CONFIG_FS_PROCFS=y
+CONFIG_FS_TMPFS=y
+CONFIG_GPIO_LOWER_HALF=y
+CONFIG_HAVE_CXX=y
+CONFIG_HAVE_CXXINITIALIZE=y
+CONFIG_IDLETHREAD_STACKSIZE=3072
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INIT_STACKSIZE=4096
+CONFIG_INTELHEX_BINARY=y
+CONFIG_IOEXPANDER=y
+CONFIG_IOEXPANDER_PCA9557=y
+CONFIG_LINE_MAX=64
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_READLINE=y
+CONFIG_PREALLOC_TIMERS=4
+CONFIG_RAM_SIZE=114688
+CONFIG_RAM_START=0x20000000
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_WAITPID=y
+CONFIG_START_DAY=6
+CONFIG_START_MONTH=12
+CONFIG_START_YEAR=2011
+CONFIG_SYSLOG_BUFFER=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_UART0_SERIAL_CONSOLE=y
+CONFIG_USBUVC=y
+CONFIG_VIDEO=y
+CONFIG_VIDEO_GC0308=y
+CONFIG_VIDEO_STREAM=y

Reply via email to