From patchwork Mon Apr 26 03:45:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12108 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 1CF80BDC92 for ; Mon, 26 Apr 2021 03:45:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6F7EB6889F; Mon, 26 Apr 2021 05:45:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="BArLKbw8"; dkim-atps=neutral Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4BB0F68883 for ; Mon, 26 Apr 2021 05:45:09 +0200 (CEST) Received: by mail-pj1-x1033.google.com with SMTP id s14so21337828pjl.5 for ; Sun, 25 Apr 2021 20:45:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5NAMTi6DGK+JAjbXjVACPKoYoNIfdbfagRJcw748ezQ=; b=BArLKbw8cdT5/0pPaMiyWyTVXpgLVyRcC6J20QlRNRL0jCFrvjI7Iv9YDfa2GCSzCW puGyQMruJl/CXC7oCCkUtVWfza5HfvCBrBgUoRU4vbAvFnqVsG4rj5AxBBni3PJzUn4m 0cTppH2lvyks6EYsZWvVoCQ5sHvx1/twl67So= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5NAMTi6DGK+JAjbXjVACPKoYoNIfdbfagRJcw748ezQ=; b=asgnuoTWIBfreFe1Ufb0YK5iUxBlPW6F7ybdz5DtChEuN/QKb3TaHCHPYOlY4XzvLS GT1KnSdRqJIU5EqwIVnxsVMWTH5FBMKawUZRdktnkJyjSoFMckKYYNyS4PXF53Ucg2iU Gyy8wlXRsH0M3MTbeShv6zvSb7xB8+Sk4f/2VWl1P5xmYPWOCnRvT27lnfKNqz7+OXDw ccwEQ7D6VSpEtzYBkCI5pShEA7hrZNposYV3/W+KFqdDSwrHo+wIa2ZI3hQ12c3GMSkd a40SFasZakAS5EpdR3PQj/eb1u4Wajzx6qT44G3gP55XuDnCdCUPcvy/DbsPhdevMmv2 aIzg== X-Gm-Message-State: AOAM5319cbPwfid4RDfTjIoXLmr+FmUZlxMjdBcWDxDyHtRlfjKRhvQt oqmoDT8VIUpWHCm23eoMHdC+fTtDU1lVQw== X-Google-Smtp-Source: ABdhPJxebpMnsqy99Wd0M42xsRfBy+FRhe9kEtvoGFkODyB7YP6GXFgYZYiNYgGcRKg05oz9Gb4Zvg== X-Received: by 2002:a17:90a:66cb:: with SMTP id z11mr19304066pjl.15.1619408707753; Sun, 25 Apr 2021 20:45:07 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:56d0:a14c:fac3:5bc3]) by smtp.gmail.com with ESMTPSA id y18sm9671479pfp.121.2021.04.25.20.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Apr 2021 20:45:07 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 26 Apr 2021 12:45:02 +0900 Message-Id: <20210426034502.2270770-1-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] android: CameraDevice: factorize generating a capture result 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" This factorizes a code of generating camera3_capture_result. It will be useful to report capture result in other places than CameraDevice::reqeustComplete(). Signed-off-by: Hirokazu Honda --- I was going to implement reportShutter() - createCaptureResult() + notifyShutter(), and reportError() - createCaptureResult() + notifyError(). But reportError() can be called after reportShutter(). It is a bit less efficient to create capture result twice in the case. So I only factorize a code of generating a capture result. --- src/android/camera_device.cpp | 29 ++++++++++++++++++++--------- src/android/camera_device.h | 3 +++ 2 files changed, 23 insertions(+), 9 deletions(-) -- 2.31.1.498.g6c1eba8ee3d-goog diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index a71aee2f..ced8efcc 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -2094,15 +2094,8 @@ void CameraDevice::requestComplete(Request *request) } /* Prepare to call back the Android camera stack. */ - camera3_capture_result_t captureResult = {}; - captureResult.frame_number = descriptor.frameNumber_; - captureResult.num_output_buffers = descriptor.buffers_.size(); - for (camera3_stream_buffer_t &buffer : descriptor.buffers_) { - buffer.acquire_fence = -1; - buffer.release_fence = -1; - buffer.status = status; - } - captureResult.output_buffers = descriptor.buffers_.data(); + camera3_capture_result_t captureResult = + createCaptureResult(descriptor, status); if (status == CAMERA3_BUFFER_STATUS_OK) { notifyShutter(descriptor.frameNumber_, timestamp); @@ -2130,6 +2123,24 @@ std::string CameraDevice::logPrefix() const return "'" + camera_->id() + "'"; } + +camera3_capture_result_t CameraDevice::createCaptureResult( + Camera3RequestDescriptor &descriptor, + camera3_buffer_status status) const +{ + camera3_capture_result_t captureResult = {}; + captureResult.frame_number = descriptor.frameNumber_; + captureResult.num_output_buffers = descriptor.buffers_.size(); + for (camera3_stream_buffer_t &buffer : descriptor.buffers_) { + buffer.acquire_fence = -1; + buffer.release_fence = -1; + buffer.status = status; + } + captureResult.output_buffers = descriptor.buffers_.data(); + + return captureResult; +} + void CameraDevice::notifyShutter(uint32_t frameNumber, uint64_t timestamp) { camera3_notify_msg_t notify = {}; diff --git a/src/android/camera_device.h b/src/android/camera_device.h index c63e8e21..a1abcead 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -100,6 +100,9 @@ private: std::tuple calculateStaticMetadataSize(); libcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer); + camera3_capture_result_t createCaptureResult( + Camera3RequestDescriptor &descriptor, + camera3_buffer_status status) const; void notifyShutter(uint32_t frameNumber, uint64_t timestamp); void notifyError(uint32_t frameNumber, camera3_stream_t *stream); std::unique_ptr requestTemplatePreview();