From patchwork Tue Dec 10 14:23:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 22272 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 BBF03C32DC for ; Tue, 10 Dec 2024 14:26:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3C59B67E94; Tue, 10 Dec 2024 15:26:12 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="dhXFYs1L"; dkim-atps=neutral Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B47A967E92 for ; Tue, 10 Dec 2024 15:26:09 +0100 (CET) Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-2ef6af22ea8so3851186a91.0 for ; Tue, 10 Dec 2024 06:26:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733840768; x=1734445568; 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=Q96BeC7n8E+Cipc4Avk4B1MuW6eoeZ2GDO3TPgfwR30=; b=dhXFYs1LrB0+HBSg2q4L9eooFL183G9znQoZ+gGhPuZa2A6m9rYjlPLYwIsLTZye7s dSoKB3EXHxYYS/5m/jTu9eg2lYg/xdkbOu8GTZLFhKMUkSMNZHkQZkgEXDzLK7Ih9k6N 09nX8tJIT+FM0J3Ey8Uerdh8rpab6ngmdtiBY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733840768; x=1734445568; 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=Q96BeC7n8E+Cipc4Avk4B1MuW6eoeZ2GDO3TPgfwR30=; b=vtmebzs8ZomaPNO2jK+/5AVQSfOE5pBgCrH7YqKaANAXlMJBo9us8FSHV4CelQvEvi YxK/GgzUdT0sGso/UQTCuWTT3t/+xtIpqVRUuwKYuuAictqSoqTdbNgzLoGOEDslt/dB fJjkaqChCuubwVNrKiOvd2m9fWajvGNDYDJrT9+d+Tb+S/6dyAb5xHZ5I8KtRNh9cFro GijMY8MgwwSr/2C/Vh3hJljsSrzZugok/w8xxAMCeNycB6CcSZTNhttW7msCCLO4DN8k PKIIFqDDkWWnjStZTFP2T12RzzzVKNailCUq4CIxBUc9S/uOoRTj1OMp7z7Ysyq7YLlz ivbA== X-Gm-Message-State: AOJu0YyirYG3sgl7im6MAcUSg1jT3uGOvpP9y8qu5EYxK4QvBcm6Y3yz PoWx0bI4eKZEdUSXmcJTVUFpUkvYyvwDa0dIgKtH+/HTtlyXkBai8OQ733gFpvefcD2MVPVALLk = X-Gm-Gg: ASbGncsNoQ4hwisLcYxjueC0hjWVoJykFZS4oHQcfco0wIRoXqHOVWstWSJEmitwL+w /uyY+vPdUfBvKuJXG3EiFZWD7YRFeMM5VZ+9HOMgJdhK7PDgP8xOmA7UzB+wOChZOUNtn8EHzJR qoEC72LiBqaQxpngWMi28hDC9E8SKdpn1Y0eOqz1IT/1ZFNwbccifchfRTAZVwXaxtb5J2cLLP/ z+PMdN8k840yYxlM1S6XImXLOXlfTVBdjMErGZmRfrSNmvAKt3yGVq34QXE9MWcSRtVP/7Iuilh /XNKguDvMM/anBOn37wp2AAKCi6ZpUqQFW5Jys7kAj8LaRUqUwvMhSDYh+G9 X-Google-Smtp-Source: AGHT+IGXJGeS6mtX+n8Fmp/JnA6e9xzkj/6LwVm3r8PN+IxNudp/V6wxUB52SN08DDV7WPOm+L/EDQ== X-Received: by 2002:a17:90b:4b10:b0:2ee:535f:ac27 with SMTP id 98e67ed59e1d1-2efcf2c572dmr7671921a91.33.1733840767895; Tue, 10 Dec 2024 06:26:07 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2024 06:26:07 -0800 (PST) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang , Han-Lin Chen , Jacopo Mondi Subject: [PATCH v4 4/7] android: Add CameraDevice::sendCaptureResult() Date: Tue, 10 Dec 2024 14:23:57 +0000 Message-ID: <20241210142557.2886315-5-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" 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 6bc19a74a..f3f570544 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1323,42 +1323,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(