From patchwork Tue Oct 27 21:24:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 28650 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 2DDD7C324C for ; Tue, 27 Oct 2026 21:24:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 35F8369066; Tue, 27 Oct 2026 22:24:55 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RH2tHrdf"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 402AD6905E for ; Tue, 27 Oct 2026 22:24:52 +0100 (CET) Received: from killaraus.ideasonboard.com (2001-14ba-70f3-e800--a06.rev.dnainternet.fi [IPv6:2001:14ba:70f3:e800::a06]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9BC334BB for ; Tue, 27 Oct 2026 22:22:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1793136159; bh=Rl2/qcRDRcfKDw75tZ8MigW4sJL7R4vzJ5k3uTyay+0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=RH2tHrdfKq5WwTJeGokrntDls+O3OJ2/n6YP6FTBz+lae4RUfUiHwFSP51ZB0+rQ6 Ih3zwUEXKdlXGWC/ph+xfHr6FWEDXjPqho7nkapE3IbT0z1Yr67BmZpmZ7GaM4Ijsu wagHmoMI4LYGD/jtx7rHguvcI18Lwmrq3tdf4u6s= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 2/4] v4l2: v4l2_camera_proxy: Set buffer field unconditionally Date: Tue, 27 Oct 2026 23:24:45 +0200 Message-ID: <20261027212447.2551591-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261027212447.2551591-1-laurent.pinchart@ideasonboard.com> References: <20261027212447.2551591-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When handling a buffer with the V4L2_BUF_FLAG_ERROR flag set, the v4l2-compat layer doesn't set any if the v4l2_buffer fields except for the flag. This leaves the value of v4l2_buffer::field unmodified, and equal to V4L2_FIELD_ANY (0) if the error occurs the first time the buffer is dequeued. v4l2-compliance then reports a failure: Streaming ioctls: test read/write: OK (Not Supported) fail: v4l2-test-buffers.cpp(423): g_field() == V4L2_FIELD_ANY fail: v4l2-test-buffers.cpp(1293): buf.check(q, last_seq) fail: v4l2-test-buffers.cpp(1748): captureBufs(node, node_m2m_cap, q, m2m_q, frame_count, pollmode, capture_count) test MMAP (no poll, REQBUFS): FAIL As the v4l2-compat layer doesn't support interlacing, fix this by unconditionally setting v4l2_buffer::field to V4L2_FIELD_NONE when allocating buffers. While at it, sort the member assignments in the same order as in the structure definition. Closes: https://gitlab.freedesktop.org/camera/libcamera/-/work_items/369 Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/v4l2/v4l2_camera_proxy.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index ca1115d017ac..2786e29e1ed7 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -255,7 +255,6 @@ void V4L2CameraProxy::updateBuffers() [](unsigned int total, const auto &plane) { return total + plane.bytesused; }); - buf.field = V4L2_FIELD_NONE; buf.timestamp.tv_sec = fmd.timestamp / 1000000000; buf.timestamp.tv_usec = (fmd.timestamp / 1000) % 1000000; buf.sequence = fmd.sequence; @@ -557,12 +556,13 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf buffers_.resize(arg->count); for (unsigned int i = 0; i < arg->count; i++) { struct v4l2_buffer buf = {}; + buf.index = i; buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - buf.length = v4l2PixFormat_.sizeimage; + buf.flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; + buf.field = V4L2_FIELD_NONE; buf.memory = V4L2_MEMORY_MMAP; buf.m.offset = i * v4l2PixFormat_.sizeimage; - buf.index = i; - buf.flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; + buf.length = v4l2PixFormat_.sizeimage; buffers_[i] = buf; }