From patchwork Tue Dec 10 14:23:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-Hao Yang X-Patchwork-Id: 22273 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 CBA51C3257 for ; Tue, 10 Dec 2024 14:26:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6F34367E9E; Tue, 10 Dec 2024 15:26:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="eO/YnBEW"; dkim-atps=neutral Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 943F167E99 for ; Tue, 10 Dec 2024 15:26:12 +0100 (CET) Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-2ee397a82f6so4978189a91.2 for ; Tue, 10 Dec 2024 06:26:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733840771; x=1734445571; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6LRoqne7Vs2NH7WovLgxTUdHOeemlMfXK+jCzHW5XUQ=; b=eO/YnBEW8zRxBaf1ML8sL9mnyKKRdBKuEasvDbAliMp5yUNanuSQDHgFI5xHRyQwn9 XPrm3bsGIimpaxlSCnmrp+dZX7UYRnsh7RDWgC4d27o0N6fFcfG1P9gAbICg+YW51oef LdjVpnM33CuasOAvKXtzUlbWl0VVYKbAMvw3c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733840771; x=1734445571; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6LRoqne7Vs2NH7WovLgxTUdHOeemlMfXK+jCzHW5XUQ=; b=X0ZW6z482dZGa/esH4w0Rd1Zy4vLNlvK/5cONLdh3Jd8mUZKW8fqqZh7fQeepEjreU wdL7mum8mBdhoRjPfjHkmGTSrIhDxEl1CUR2HQpEcwZ7KJjij5oqutobiSp06D4T2MRw gpwnJHHN3X23kYBWiyVS1m7+XOSJcOY8NMLFFvLOSx53fHGU7vLmickUS6VcHh/KkyDt tzmhxKT50ZS8r9rBOXJvjwybOsxYb4hbyagCoDYUjKym3M1RAXyDoBiOPB89tMiSWKZt Rir8HMJ04MBFUIf/MTv5tlNip+jp2hl/neJdjUGmwyhPCY6Olc4kV/eu3Aue3Gux3Jno MT8g== X-Gm-Message-State: AOJu0YzANEc56bODSAnHN4ui7UyIMnYjnRgGYQCH+FRACZnNnl7YOaNX wKcsmAw+CV1J3FIM/4Q+OCEpQrza701b8HKJKMmhgwCKpgzvS2/WSV0Y1tA0vp1kDNbm4nlNxhc = X-Gm-Gg: ASbGncujMk/o0Clc25IAc3o2AET1lBvmFsBm2Tku+hqQmLv7AFymim2wAvdVGM5zgiI k64laXpSxApnUCDhNpUQXR1fHptQ4ddYalt6tH6HqvJWbGMAENB6aMb7LZjqWJgY1VmduJwhtEB 3XG7cwE9rSts4uxgNi43ypEaAP/LqzRGzuXw+etZsbOX0nBN1B3Tns/yKu88MtZ+mT8NYFciDvg qZ58ApGtSj7VMCl7LnLC5St7+NsKJuLw9ToDhUZMDVTxlTtNym3swq6etSEXjv6YSgkPvs9Clyy JHRlDOH+Vs+qmCIVdJqyEF55zKOr8NBTibAUobgL/zTczUu2DZawyPUpfSc6 X-Google-Smtp-Source: AGHT+IEz3EqGurLMOBF1f3prn9cEG8crqYMhj6EyIJLXA/MTzAtTS3anMPEQGNXFhmgTaiMI/ffGfg== X-Received: by 2002:a17:90b:4a:b0:2ee:b4d4:69 with SMTP id 98e67ed59e1d1-2efcf2c587fmr7783592a91.35.1733840769318; Tue, 10 Dec 2024 06:26:09 -0800 (PST) Received: from chenghaoyang-low.c.googlers.com.com (112.212.229.35.bc.googleusercontent.com. [35.229.212.112]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ef26ff97f2sm11812053a91.11.2024.12.10.06.26.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2024 06:26:08 -0800 (PST) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang , Han-Lin Chen Subject: [PATCH v4 5/7] android: Drop notify CAMERA3_MSG_ERROR_REQUEST when a request fails Date: Tue, 10 Dec 2024 14:23:58 +0000 Message-ID: <20241210142557.2886315-6-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241210142557.2886315-1-chenghaoyang@chromium.org> References: <20241210142557.2886315-1-chenghaoyang@chromium.org> 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" According to Android Camera API v3.2, CAMERA3_MSG_ERROR_REQUEST is used for requests that have not done any processing. When a request is completed with failure, CAMERA3_MSG_ERROR_RESULT should be used instead. To avoid code duplication, when CameraMetadata cannot be generated, CAMERA3_MSG_ERROR_RESULT is notified after process_capture_result. Signed-off-by: Han-Lin Chen Co-developed-by: Harvey Yang Signed-off-by: Harvey Yang --- src/android/camera_device.cpp | 40 ++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index f3f570544..3b10f207e 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1182,6 +1182,18 @@ void CameraDevice::requestComplete(Request *request) * post-processing/compression fails. */ for (auto &buffer : descriptor->buffers_) { + for (auto &[_, frameBuffer] : request->buffers()) { + if (buffer.srcBuffer != frameBuffer && + buffer.frameBuffer.get() != frameBuffer) + continue; + + StreamBuffer::Status status = StreamBuffer::Status::Success; + if (frameBuffer->metadata().status != FrameMetadata::FrameSuccess) { + status = StreamBuffer::Status::Error; + } + setBufferStatus(buffer, status); + } + CameraStream *stream = buffer.stream; /* @@ -1198,22 +1210,18 @@ void CameraDevice::requestComplete(Request *request) if (fence) buffer.fence = fence->release(); } - buffer.status = StreamBuffer::Status::Success; } /* - * If the Request has failed, abort the request by notifying the error - * and complete the request with all buffers in error state. + * If the Request has failed, complete the request with all buffers in + * error state and notify an error result. */ if (request->status() != Request::RequestComplete) { LOG(HAL, Error) << "Request " << request->cookie() << " not successfully completed: " << request->status(); - abortRequest(descriptor); - completeDescriptor(descriptor); - - return; + descriptor->status_ = Camera3RequestDescriptor::Status::Error; } /* @@ -1238,7 +1246,7 @@ void CameraDevice::requestComplete(Request *request) */ descriptor->resultMetadata_ = getResultMetadata(*descriptor); if (!descriptor->resultMetadata_) { - notifyError(descriptor->frameNumber_, nullptr, CAMERA3_MSG_ERROR_RESULT); + descriptor->status_ = Camera3RequestDescriptor::Status::Error; /* * The camera framework expects an empty metadata pack on error. @@ -1271,7 +1279,13 @@ void CameraDevice::requestComplete(Request *request) continue; } + if (buffer->status == StreamBuffer::Status::Error) { + iter = descriptor->pendingStreamsToProcess_.erase(iter); + continue; + } + ++iter; + int ret = stream->process(buffer); if (ret) { setBufferStatus(*buffer, StreamBuffer::Status::Error); @@ -1324,6 +1338,16 @@ void CameraDevice::sendCaptureResults() descriptors_.pop(); sendCaptureResult(descriptor.get()); + + /* + * Call notify with CAMERA3_MSG_ERROR_RESULT to indicate some + * of the expected result metadata might not be available + * because the capture is cancelled by the camera. Only notify + * it when the final result is sent, since Android will ignore + * the following metadata. + */ + if (descriptor->status_ == Camera3RequestDescriptor::Status::Error) + notifyError(descriptor->frameNumber_, nullptr, CAMERA3_MSG_ERROR_RESULT); } }