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,