From patchwork Mon Aug 16 04:31:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13367 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 D768DC3242 for ; Mon, 16 Aug 2021 04:32:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 40C16688AC; Mon, 16 Aug 2021 06:32:04 +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="HwligxSW"; dkim-atps=neutral Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 091626888C for ; Mon, 16 Aug 2021 06:32:02 +0200 (CEST) Received: by mail-pl1-x62e.google.com with SMTP id e19so19380696pla.10 for ; Sun, 15 Aug 2021 21:32:01 -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=k7D8nd4mpOzgm8wgTT5iNwJlHKvqDfF85/MjYwtrNUU=; b=HwligxSWkJIAd28VBQvWZj3L1h3GvJDmRrehJHaGTooWWZvwPysO3/CNkQ7DcCZhlK BYGvxrvDtYetZKnx2mTwGIXUdPMOxOcIogiCkYJtcyskD0CnME7QR9y9Wb3TtksKJL/5 +lZXUdqnlhPnlzqCaDmAwCG3o0nyC8AB46XoQ= 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=k7D8nd4mpOzgm8wgTT5iNwJlHKvqDfF85/MjYwtrNUU=; b=iRS51KWBuOFusFUOCtaMWFFk9Hy7ptSNy7+UcVMLSSfv3NEpxFmNQLEo0QJlV+ebq4 khTNTFGeqNMl1N8FvEWGnKQQwyY4o2gx/JAG4i6w7hoYZYn//XStDMPXUdvM4DurYLoP nIc74UUiytDiREPBqIYXEU6bbVID8pwBlir7UQQ20XC3+bP8l9OmlTQ3JjPK+c2H0HZl GWvUG3EzbWhrjSppTg/+ikVW3SBWecHZg+eoY/Q8VP6jqZhOwB5ffG4kTsKH4kii75s4 v4tO4qNXmGFkatK8NTVnIUctdkMBV5jnQ8io6L0MgTwV86whDQTYrmOjLce/O8w2Wluq Qp5w== X-Gm-Message-State: AOAM533rW19a4DYwcXfWl+IdhB97KZyvvsmU2xJcMrLu7gCDwC39Z4fm yHZOhWLEvRUTy/4QVJbpu96cAOkAMnRA8A== X-Google-Smtp-Source: ABdhPJxEcr1S2Co9CSoFFvGgycT5moyngyr1H2O0cAY98XcmAzSCkhq3SqLY9HsIlAwrfQ57kU8f+g== X-Received: by 2002:a17:90a:9b0b:: with SMTP id f11mr15062593pjp.120.1629088320411; Sun, 15 Aug 2021 21:32:00 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:6f5f:1479:a6ab:4229]) by smtp.gmail.com with ESMTPSA id u10sm2767417pgj.48.2021.08.15.21.31.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Aug 2021 21:32:00 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 16 Aug 2021 13:31:37 +0900 Message-Id: <20210816043138.957984-10-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.rc1.237.g0d66db33f3-goog In-Reply-To: <20210816043138.957984-1-hiroh@chromium.org> References: <20210816043138.957984-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 09/10] android: camera_device: Fill offset and right length in CreateFrameBuffer() 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::CreateFrameBuffer() fills the length of the buffer to each FrameBuffer::Plane::length. It should rather be the length of plane. This also changes CreateFrameBuffer() to fill offset of FrameBuffer::Plane. Signed-off-by: Hirokazu Honda --- src/android/camera_device.cpp | 38 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index a69b687a..1ded5cb1 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,30 @@ 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; } + } + if (!fd.isValid()) { + LOG(HAL, Fatal) << "No valid fd"; + 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; - } + 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].offset = buf.plane(i).data() - buf.plane(0).data(); + planes[i].length = buf.plane(i).size(); } return new FrameBuffer(std::move(planes));