From 85bcddb5ad90cc5d5e39f3594004295c141adaa8 Mon Sep 17 00:00:00 2001 From: claude-noether Date: Sun, 17 May 2026 10:20:31 +0000 Subject: [PATCH] v4l2: surface error_idx + errno on VIDIOC_S_EXT_CTRLS failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ampere-av1 Phase 2.1 + 3 diagnostic: log which control failed validation on S_EXT_CTRLS rejection so debug iterations can identify the offending CID without strace. Pre-validation failures (error_idx >= count) log as "" with the syscall errno surfacing the root reason. Already informative on ampere — surfaces the pre-existing benign H264 + HEVC device-init failures on the vpu981 AV1 fd as count=2 / failed_cid=0 (those go through (void)cast at context.c:450/473 by design). Co-Authored-By: Claude Opus 4.7 --- src/v4l2.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/v4l2.c b/src/v4l2.c index 9e2ce8b..65f1205 100644 --- a/src/v4l2.c +++ b/src/v4l2.c @@ -433,6 +433,7 @@ static int v4l2_ioctl_controls(int video_fd, int request_fd, unsigned long ioc, unsigned int num_controls) { struct v4l2_ext_controls controls; + int rc; memset(&controls, 0, sizeof(controls)); @@ -444,7 +445,28 @@ static int v4l2_ioctl_controls(int video_fd, int request_fd, unsigned long ioc, controls.request_fd = request_fd; } - return ioctl(video_fd, ioc, &controls); + rc = ioctl(video_fd, ioc, &controls); + if (rc < 0) { + /* ampere-av1 Phase 2.1 diag: surface error_idx so the caller's + * error path knows which CID failed validation. error_idx >= + * count means the failure was pre-validation (e.g., bad + * request_fd). errno carries the syscall-level reason. */ + const char *failed_cid_label = ""; + unsigned int failed_size = 0; + if (controls.error_idx < num_controls) { + failed_size = control_array[controls.error_idx].size; + (void)failed_cid_label; /* keep symbol if logger truncates */ + } + request_log("v4l2_ioctl_controls: rc=%d errno=%d (%s) " + "ioc=0x%lx error_idx=%u count=%u " + "failed_cid=0x%x failed_size=%u\n", + rc, errno, strerror(errno), ioc, + controls.error_idx, num_controls, + controls.error_idx < num_controls + ? control_array[controls.error_idx].id : 0, + failed_size); + } + return rc; } int v4l2_get_controls(int video_fd, int request_fd,