Repository navigation
examples/uvc_cam, system/nxcamera: build with the Linux V4L2 struct layout - #3976
Open
blue-debug wants to merge 2 commits into
Open
blue-debug wants to merge 2 commits into
blue-debug wants to merge 2 commits into
Conversation
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
marked this pull request as ready for review
November 5, 2026 03:24
blue-debug
marked this pull request as draft
November 5, 2026 03:25
blue-debug
marked this pull request as ready for review
November 5, 2026 05:02
xiaoxiang781216
approved these changes
Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_typeofv4l2_frmsizeenumandv4l2_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.idand&qctrl.idto auint16_t *, which no longer builds (incompatible pointer types). The id is now looked up into a localuint32_tand 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_camandsystem/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:nxcameraplusEXAMPLES_CAMERA,EXAMPLES_UVC_CAMandSYSTEM_NXCODEC), checkpatch passes:Each commit builds with no new warnings against apache/nuttx master 6e1126a2362, and the PR builds with no new warnings against master + !include/sys/videoio: align v4l2 structs with the Linux UAPI nuttx#21472. Plain
sim:nxcamerawith-Werror, as CI builds it, passes with both.Without this PR, master + !include/sys/videoio: align v4l2 structs with the Linux UAPI nuttx#21472 fails in
uvc_cam_main.c('struct v4l2_frmsizeenum' has no member named 'buf_type'), and plainsim:nxcamerawith-Werrorfails three times innxcamera_main.c(incompatible-pointer-types).Runtime with !include/sys/videoio: align v4l2 structs with the Linux UAPI nuttx#21472: nxcamera captures 10 frames from a v4l2loopback device, each byte-identical to FFmpeg's smptebars frame.