From patchwork Wed Aug 11 12:40:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13304 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 81698C3240 for ; Wed, 11 Aug 2021 12:40:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3B5BD68855; Wed, 11 Aug 2021 14:40:32 +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="K3f0lco7"; dkim-atps=neutral Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CD02868887 for ; Wed, 11 Aug 2021 14:40:29 +0200 (CEST) Received: by mail-pl1-x62d.google.com with SMTP id d17so2496299plr.12 for ; Wed, 11 Aug 2021 05:40:29 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=HiIbadVkUYWpBSWximDdu0NkuYjyYDssTrmu7Q5oHf0=; b=K3f0lco7ifLXjpNIKrcvTI5ecZGaQJr2IfOhEOPUkrMwishWKiPfe6jJb++lNtxDwU D9DJ+0Qla1hQPb/NnoL8uAHxsa6NhMT6SCE3Shi4EsJxgGKQAOvHHMTEGsn5QhpMBW+B 2l7td3F30QPxFIhhVb2A1ASJ+cxMaeoDrOWmE= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=HiIbadVkUYWpBSWximDdu0NkuYjyYDssTrmu7Q5oHf0=; b=s8zOuJcRReWqAyHKRY4BZDnRyXBCFc0nzDqRskgCmEa075DQxz6Uuxm9O0gZ+eVw3m 93Kv8+jqk9KtTefaWQ1haLU9JXtXygUkRFig61GTIfAxRX3HauPSsVWdZF1CP8WhwHJt RZmyUdzF9Bv7+ipQw0a4BAyo4DDh0xEGI5KqgHm3/us8rRc9hIb/CLG85HGigLgXMj1I mCIWCgSt+v7sbRyE+NUPiRbudGhGxkr0nhdtU1cFQRcFCZObQLPBVtMufKm6Nv83Tcw5 tzBuIqE8n9AFjLho/F5a0HJ6T38YSzc61vNdBSLwk0GKUQRNrCA7+ITgHp60jXWhqdLA 0Uuw== X-Gm-Message-State: AOAM530LqCn3NQL+UTHkgZQ+6RKuiFIuzkdsB3ezKrOM9ZDb034B7iEJ eWkLjfkxkT8wAD3lfiv7yNL6boe7u8c/Lg== X-Google-Smtp-Source: ABdhPJw09cPcpvWfcgNWE/onk1Z9GrXuA8x9kpcYNd0xm/CPMwCY8osWxa+T8J58o6BVXCFLRKO7tw== X-Received: by 2002:aa7:8b07:0:b029:3c7:c29f:9822 with SMTP id f7-20020aa78b070000b02903c7c29f9822mr27449149pfd.33.1628685627993; Wed, 11 Aug 2021 05:40:27 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:ba11:c25e:242c:485d]) by smtp.gmail.com with ESMTPSA id p30sm15722876pfh.116.2021.08.11.05.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Aug 2021 05:40:27 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 11 Aug 2021 21:40:13 +0900 Message-Id: <20210811124015.2116188-4-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.605.g8dce9f2422-goog In-Reply-To: <20210811124015.2116188-1-hiroh@chromium.org> References: <20210811124015.2116188-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 3/5] android: camera_device: Fills the size of plane to FrameBuffer::Plane::length 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" CameraDevice fills the size of a buffer to FrameBuffer::Plane::length. It should rather fill the size of a plane to it. Signed-off-by: Hirokazu Honda --- src/android/camera_device.cpp | 37 +++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index a69b687a..f10f27b7 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -746,29 +747,31 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer) { - std::vector planes; + FileDescriptor fd; + /* This assumes all the planes are in the same buffer. */ for (int i = 0; i < camera3buffer->numFds; i++) { /* Skip unused planes. */ - if (camera3buffer->data[i] == -1) + if (camera3buffer->data[i] != -1) { + fd = FileDescriptor(camera3buffer->data[i]); break; - - FrameBuffer::Plane plane; - plane.fd = FileDescriptor(camera3buffer->data[i]); - if (!plane.fd.isValid()) { - LOG(HAL, Error) << "Failed to obtain FileDescriptor (" - << camera3buffer->data[i] << ") " - << " on plane " << i; - return nullptr; } + } - off_t length = lseek(plane.fd.fd(), 0, SEEK_END); - if (length == -1) { - LOG(HAL, Error) << "Failed to query plane length"; - return nullptr; - } + if (!fd.isValid()) { + LOG(HAL, Fatal) << "No valid fd"; + return nullptr; + } + + CameraBuffer buf(camera3buffer, PROT_READ); + if (!buf.isValid()) { + LOG(HAL, Fatal) << "Failed mapping buffer"; + return nullptr; + } - plane.length = length; - planes.push_back(std::move(plane)); + std::vector planes(buf.numPlanes()); + for (size_t i = 0; i < buf.numPlanes(); ++i) { + planes[i].fd = fd; + planes[i].length = buf.plane(i).size(); } return new FrameBuffer(std::move(planes));