From patchwork Wed Dec 4 16:36:29 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: 22166 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 72964BDB1C for ; Wed, 4 Dec 2024 16:41:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 01951660EE; Wed, 4 Dec 2024 17:41:56 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Hx02CMGh"; dkim-atps=neutral Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 350E2660C5 for ; Wed, 4 Dec 2024 17:41:51 +0100 (CET) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-21572ca3cccso38664565ad.2 for ; Wed, 04 Dec 2024 08:41:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733330508; x=1733935308; 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=SW0ReRfQT80HjLN0627g1Oa3EjdkMjs9/avml1BZiic=; b=Hx02CMGhIvUuKLDjp10qxPdPfEe3CwgWKlLZABIcK9n9UXW49Nek2kIi6+fYZSTX6K gyx90hqy97UQ/3RFJMe/6jCuduN2ownzLO2cHZM0HnZeKNbj1mfnZ5k+N2xKdOktr6Lu ttho2z8vsemG3OSC1GwjeAezJv3owMeMVfpMA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733330508; x=1733935308; 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=SW0ReRfQT80HjLN0627g1Oa3EjdkMjs9/avml1BZiic=; b=BvnACHeqyR4Mfg5Rbi+8lQwNJ2U2BZItfWeynfOH+KFd/Gtg5r26sQ6aBJOmdQH7sR ego8+oAckq0mogRQ8HHvH36Sa2nMDXTngkBROgig0WUjEAB2bLrYKG+zBQKm8LAaKrtP iEDqmfnD+UY87HK7QGSpy3l64oRzEs0far6//HVUokhfuxhFer3g9krJDrtiCGSATENP 0LMOWhUCaVHgcP0zK9mL5YktZHeZ3SBVbcuFw3agxQ/CR8JWH2AdYLcEh+bTs8Y7wi+5 hKgNY8C/jf8RSrwttkb6ayel3lvEUaJXSHhat1IZAlswUlzChbUnX7w1LWXtQlSaisfc AwtQ== X-Gm-Message-State: AOJu0YzTyRR+sqDfsIwMmE+rv9cEMDtAcvAqcZoCGv9kzHKyLfZs3h0y JluEgtSFYi5XrM1Vt5KtQ807j28XCs4EXMjKjy4ZcsA5ZT08jF6iGOiwDjp4oc7i4T/4PXFv7t8 = X-Gm-Gg: ASbGncuL2Uox8Lno0NNviRbzKzGna6hdTzk92Arf417kqF3Do+pfTf97mTxno3rFzj/ 4FgeCQDWvHjwZrp5Bs9u7NMPcGIxEbFjFV00/OYBlWOnGNfBcVYoYyqil9E59HkpfHptLGuowfZ WGTTN3ceoHuSI9n2jMT5Yrj+80ytsS4csWY6gBnmOdTIwkhAe3d5brWsM01M9ukfSwrzM696axE Jb9nePikeDfceZwA8K47ZLEx2D8U9ECj0oRrqzzokc3/fEtbSGjPPIPsKbWABOqlH632Hxm0a+q 0GAFF45Z9BHkI9IgLlanevO1R3yS4UsQQ23IieE8KoGCLURAvOlbWIw9 X-Google-Smtp-Source: AGHT+IGtYS/y7Qc8dbU0w8S14phcpaspCB7oQFpIJJhQ1iSeKtXIAW+JGdNReK/9N8vGShN+d1UKQg== X-Received: by 2002:a17:903:1790:b0:215:711f:4979 with SMTP id d9443c01a7336-215bd24b939mr107924905ad.35.1733330508309; Wed, 04 Dec 2024 08:41:48 -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 d2e1a72fcca58-725417725e9sm12551779b3a.80.2024.12.04.08.41.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 08:41:47 -0800 (PST) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang , Han-Lin Chen , Jacopo Mondi Subject: [PATCH v3 4/7] android: Add CameraDevice::sendCaptureResult() Date: Wed, 4 Dec 2024 16:36:29 +0000 Message-ID: <20241204164137.3938891-5-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241204164137.3938891-1-chenghaoyang@chromium.org> References: <20241204164137.3938891-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 f2dd8d4fd..497d363d6 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(