Skip to content

examples/uvc_cam, system/nxcamera: build with the Linux V4L2 struct layout - #3976

Open
blue-debug wants to merge 2 commits into
apache:masterfrom
blue-debug:uvc-cam-fix-v3
Open

blue-debug wants to merge 2 commits into
apache:masterfrom
blue-debug:uvc-cam-fix-v3

Conversation

@blue-debug

@blue-debug blue-debug commented Nov 5, 2026 •

Copy link
Copy Markdown

Note: Please adhere to Contributing Guidelines.

Summary

apache/nuttx#21472 gives the V4L2 structs in <sys/videoio.h> the Linux layout. Two apps would stop building with that layout; this PR changes them so that they build with both the current and the new header, so it can go in first.

  • examples/uvc_cam: stop setting buf_type of v4l2_frmsizeenum and v4l2_frmivalenum. Linux has no such field and the NuttX kernel never read it; !include/sys/videoio: align v4l2 structs with the Linux UAPI nuttx#21472 removes it. Also fixes the two existing nxstyle errors in the file.

  • system/nxcamera: control ids become 32 bits wide, as on Linux. nxcamera passed &ctrl.id and &qctrl.id to a uint16_t *, which no longer builds (incompatible pointer types). The id is now looked up into a local uint32_t and then assigned, which builds with both id widths.

This PR is not a breaking change by itself: it changes no API, no struct and no runtime behaviour, and it builds unchanged against today's <sys/videoio.h>. It is the forward-compatible half of the pair.

Order: this PR goes in before apache/nuttx#21472. It has no dependency of its own.

Impact

Affects: examples/uvc_cam and system/nxcamera.

Behavior: no change; every NuttX control id fits in 16 bits today, and the kernel does not read buf_type.

Compatibility: builds with the current <sys/videoio.h> and with the Linux layout of apache/nuttx#21472, so it is safe to merge first and safe to keep if apache/nuttx#21472 is reworked.

Testing

Simulator (sim:nxcamera plus EXAMPLES_CAMERA, EXAMPLES_UVC_CAM and SYSTEM_NXCODEC), checkpatch passes:

fangyibo and others added 2 commits November 5, 2026 10:42
struct v4l2_frmsizeenum and struct v4l2_frmivalenum carry a buf_type
field that Linux does not have, and the V4L2 capture driver never reads
it. Stop setting it, so that the example keeps building once these
structs are aligned with the Linux UAPI.

While here, fix the two nxstyle errors in the file (missing blank line
after declarations).

No functional change.

Assisted-by: Kiro:claude-opus-5-5
Signed-off-by: fangyibo <fangyibo@xiaomi.com>
In Linux, V4L2 control ids are 32 bits wide (struct v4l2_control.id and
the query and menu control id fields are __u32), and NuttX is aligning
include/sys/videoio.h with that. nxcamera passes &ctrl.id and &qctrl.id
straight to nxcamera_find_ctrl_id(), which takes a uint16_t pointer, so
with 32-bit id fields the set, get and query commands no longer build
(incompatible pointer types, an error with -Werror).

Widen nxcamera_ctrl_name_s.id and the nxcamera_find_ctrl_id()
out-parameter to uint32_t, and look the id up into a local variable that
is then assigned to the struct field. This builds with both the current
16-bit and the new 32-bit id fields, so it does not depend on when the
NuttX change is merged.

Signed-off-by: yaojingwei <yaojingwei@xiaomi.com>
@blue-debug
blue-debug marked this pull request as ready for review November 5, 2026 03:24
@blue-debug
blue-debug marked this pull request as draft November 5, 2026 03:25
@blue-debug
blue-debug marked this pull request as ready for review November 5, 2026 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants