From patchwork Fri Mar 12 05:47:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11554 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 16CFBBD80E for ; Fri, 12 Mar 2021 05:47:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 18F5B68C69; Fri, 12 Mar 2021 06:47:36 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="vs2fOZ7d"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A1D9B605B2 for ; Fri, 12 Mar 2021 06:47:32 +0100 (CET) Received: from localhost.localdomain (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3DB2188F; Fri, 12 Mar 2021 06:47:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1615528052; bh=CuVc+O8xrvItzrd5+0lVelYveOBVepDwPWjRQo0NFQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vs2fOZ7dFRdyBgFVo6zxqhrw3GFXUaFkgVmcploW1bLF1Sbw5V/7P2JaxDuzAYsKM sdTa3mSkNtgQkzDS3az5tpBTaZBoUj0r3z6h5OA+iF/lBri+SDTW9i3Xcqf86YAHNS SoFiJ912yQwg+N0rpvoIzJVofnDxpp1gmNKXZNYo= From: Kieran Bingham To: libcamera devel Date: Fri, 12 Mar 2021 05:47:22 +0000 Message-Id: <20210312054727.852622-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210312054727.852622-1-kieran.bingham@ideasonboard.com> References: <20210312054727.852622-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/8] libcamera: buffer: Initialise status 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" Buffers queued to a pipeline handler may not be yet queued to a device when the request is cancelled. This can lead to the FrameMetadata having never been explicitly set by an underlying V4L2 device. The status field on this is used to check the state of the buffer to determine if it was correctly filled, or if it was cancelled. In the event that the buffer is not used, it must be marked as Error as the metadata associated with that frame will not be valid. Initialise the FrameMetadata to FrameError to prevent uninitialised access. Furthermore, swap the Enum values of the Status such that the first state represents the initial Error state. Signed-off-by: Kieran Bingham Reviewed-by: Niklas Söderlund --- include/libcamera/buffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h index 302fe3d3e86b..3f5d0f1b6363 100644 --- a/include/libcamera/buffer.h +++ b/include/libcamera/buffer.h @@ -19,8 +19,8 @@ class Request; struct FrameMetadata { enum Status { - FrameSuccess, FrameError, + FrameSuccess, FrameCancelled, }; @@ -28,7 +28,7 @@ struct FrameMetadata { unsigned int bytesused; }; - Status status; + Status status = FrameError; unsigned int sequence; uint64_t timestamp; std::vector planes;