From patchwork Wed Nov 27 09:25:55 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: 22116 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 CD28EC3213 for ; Wed, 27 Nov 2024 09:26:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4CA05660B9; Wed, 27 Nov 2024 10:26:54 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="UJkZ593m"; dkim-atps=neutral Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ADD13660C2 for ; Wed, 27 Nov 2024 10:26:46 +0100 (CET) Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-71d46ace74aso1722954a34.3 for ; Wed, 27 Nov 2024 01:26:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1732699605; x=1733304405; 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=pdGP+F5FAemY1y8l4UaN9IsfqrmqR26H1y8tizh1Imo=; b=UJkZ593mOFmNVw1u0Grq05ZEb+3btfLWoKVpplO/JGacuN5qYKJ96471vGXcFmZDqz RDDHFZBVgWDZjk81OS2F0BooP1nJSu+Zm96bDptJ4lmfl+hngE05DWwuzRGb5bFQbqba soQuEWxfF/x8js39b5RFETgE4+MV1vhFMPpMM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732699605; x=1733304405; 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=pdGP+F5FAemY1y8l4UaN9IsfqrmqR26H1y8tizh1Imo=; b=cTyr/r0RPJh1tnoFfaBBL3wa9bqYJvjGQHVrhTvBRT2MdF+hRVVisckTmFsMD7qhmy lfwo7y4G9Lo8VVu6qJ4chAd7/bNkCcElbvWN0pkECjoIY6bkCJJkoJ1sk9mKTZISktTQ E4QP3wkCC8IMkUFLbfw9PKetTx/sc6uCsImy+C3Q9JUL3X2wN1P46lxEPVsjj0uBWPO4 eCamA6ol5qmTYaq+Tpki+ou3dzwbkK0YYBpJn3YaLkwRpk+HPOc7Sv1edNM19Q5Y12pb HVZZOjfYUI2GLaYT9WmkrlRyyJrqf1aOY7SGIIg+q88LFBQcnlRmB4UB6fTLz90iRwN1 aP7A== X-Gm-Message-State: AOJu0Yx1+nLvbJDrMSOT+LQp1WgGhCpwQCTkS0pa+U4IoZwMwk27fUdy iHVWNZsVZORwMTpbhbECS3IUQkG2600TBMqBpL+hE4KSd9A2bPfUeynvGbA+M3Et4hy0LEjiLlI = X-Gm-Gg: ASbGncudYqQkZzJ2iDODLmwyalFyqG+y/yNsiJH4LLzUDuYokxRDdRbVsr1sK316DB/ cV9R477MRVIBKDY833e2o3XGi/G9sbSxEZhpaOTqFSSAW3ELjbtGgn5mpsJSMkEYgmN+cqt+Kpk SGTMoR+2mm0v4dHhBgENbzl2boRMZjboseH9xCIA6YaoeAHO2+h1t495LLdCidT0oF6MRd1jEin 6YfXouoo4OcmaSvPNc3gyM9HgiRo0rHbw7EPawiNwUVD+WUd+X1rtBsq93nFWh3BGYIbJD9MlS2 YJ1Yd5QNgce1aj+Ife1N5czR05gVYWOMo/zBVGdaNVW2QRUuDD+tqA== X-Google-Smtp-Source: AGHT+IHOqV76tqcIXHAHI6bqlt7KBWEEhU5HDabDmlEgvsrYEcYZ7A+GrEggmiRV6SHUxewvNJqp/Q== X-Received: by 2002:a05:6830:f94:b0:71d:5f65:ce48 with SMTP id 46e09a7af769-71d65d2809cmr2297014a34.28.1732699605234; Wed, 27 Nov 2024 01:26:45 -0800 (PST) Received: from chenghaoyang-low.c.googlers.com.com (27.247.221.35.bc.googleusercontent.com. [35.221.247.27]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fbcbfc41f9sm8693027a12.8.2024.11.27.01.26.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2024 01:26:44 -0800 (PST) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang , Han-Lin Chen Subject: [PATCH v2 5/9] android: Add CameraDevice::sendCaptureResult() Date: Wed, 27 Nov 2024 09:25:55 +0000 Message-ID: <20241127092632.3145984-6-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241127092632.3145984-1-chenghaoyang@chromium.org> References: <20241127092632.3145984-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" The new function is separated from sendCaptureResults(), which allows other functions to send a result out of order, like aborting. It'll be updated in the upcoming patch, when the usage of error result is separated. This function also allows the upcoming partial results to be sent back to the application without waiting for the requests. Signed-off-by: Han-Lin Chen Co-developed-by: Harvey Yang Signed-off-by: Harvey Yang Reviewed-by: Jacopo Mondi --- src/android/camera_device.cpp | 57 ++++++++++++++++++----------------- src/android/camera_device.h | 1 + 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 62f724041..0377cf215 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1324,42 +1324,45 @@ void CameraDevice::sendCaptureResults() auto descriptor = std::move(descriptors_.front()); descriptors_.pop(); - camera3_capture_result_t captureResult = {}; + sendCaptureResult(descriptor.get()); + } +} - captureResult.frame_number = descriptor->frameNumber_; +void CameraDevice::sendCaptureResult(Camera3RequestDescriptor *request) const +{ + std::vector resultBuffers; + resultBuffers.reserve(request->buffers_.size()); - if (descriptor->resultMetadata_) - captureResult.result = - descriptor->resultMetadata_->getMetadata(); + for (auto &buffer : request->buffers_) { + camera3_buffer_status status = CAMERA3_BUFFER_STATUS_ERROR; - std::vector resultBuffers; - resultBuffers.reserve(descriptor->buffers_.size()); + if (buffer.status == StreamBuffer::Status::Success) + status = CAMERA3_BUFFER_STATUS_OK; - for (auto &buffer : descriptor->buffers_) { - camera3_buffer_status status = CAMERA3_BUFFER_STATUS_ERROR; + /* + * Pass the buffer fence back to the camera framework as + * a release fence. This instructs the framework to wait + * on the acquire fence in case we haven't done so + * ourselves for any reason. + */ + resultBuffers.push_back({ buffer.stream->camera3Stream(), + buffer.camera3Buffer, status, + -1, buffer.fence.release() }); + } - if (buffer.status == StreamBuffer::Status::Success) - status = CAMERA3_BUFFER_STATUS_OK; + camera3_capture_result_t captureResult = {}; - /* - * Pass the buffer fence back to the camera framework as - * a release fence. This instructs the framework to wait - * on the acquire fence in case we haven't done so - * ourselves for any reason. - */ - resultBuffers.push_back({ buffer.stream->camera3Stream(), - buffer.camera3Buffer, status, - -1, buffer.fence.release() }); - } + captureResult.frame_number = request->frameNumber_; + captureResult.num_output_buffers = resultBuffers.size(); + captureResult.output_buffers = resultBuffers.data(); - captureResult.num_output_buffers = resultBuffers.size(); - captureResult.output_buffers = resultBuffers.data(); + if (request->status_ == Camera3RequestDescriptor::Status::Success) + captureResult.partial_result = 1; - if (descriptor->status_ == Camera3RequestDescriptor::Status::Success) - captureResult.partial_result = 1; + if (request->resultMetadata_) + captureResult.result = request->resultMetadata_->getMetadata(); - callbacks_->process_capture_result(callbacks_, &captureResult); - } + callbacks_->process_capture_result(callbacks_, &captureResult); } void CameraDevice::setBufferStatus(StreamBuffer &streamBuffer, diff --git a/src/android/camera_device.h b/src/android/camera_device.h index c92ee1aa4..699aa8f17 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -97,6 +97,7 @@ private: void completeDescriptor(Camera3RequestDescriptor *descriptor) LIBCAMERA_TSA_EXCLUDES(descriptorsMutex_); void sendCaptureResults() LIBCAMERA_TSA_REQUIRES(descriptorsMutex_); + void sendCaptureResult(Camera3RequestDescriptor *request) const; void setBufferStatus(StreamBuffer &buffer, StreamBuffer::Status status); std::unique_ptr getResultMetadata(