{"id":11864,"url":"https://patchwork.libcamera.org/api/patches/11864/?format=json","web_url":"https://patchwork.libcamera.org/patch/11864/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210408031040.1388568-1-hiroh@chromium.org>","date":"2021-04-08T03:10:39","name":"[libcamera-devel,v3,1/2] android: CameraBuffer: Add a static function to check a buffer validness","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"50ed8462079103b235494701f3d98822b9d49b9e","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11864/mbox/","series":[{"id":1903,"url":"https://patchwork.libcamera.org/api/series/1903/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1903","date":"2021-04-08T03:10:39","name":"[libcamera-devel,v3,1/2] android: CameraBuffer: Add a static function to check a buffer validness","version":3,"mbox":"https://patchwork.libcamera.org/series/1903/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11864/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11864/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 750B4BD224\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  8 Apr 2021 03:10:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AC267687F4;\n\tThu,  8 Apr 2021 05:10:58 +0200 (CEST)","from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com\n\t[IPv6:2607:f8b0:4864:20::1036])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EE96468414\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  8 Apr 2021 05:10:56 +0200 (CEST)","by mail-pj1-x1036.google.com with SMTP id\n\tk23-20020a17090a5917b02901043e35ad4aso2352757pji.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 07 Apr 2021 20:10:56 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:2:8822:ec6c:14d8:eea9])\n\tby smtp.gmail.com with ESMTPSA id\n\tq14sm23685397pgt.54.2021.04.07.20.10.53\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 07 Apr 2021 20:10:54 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"Qgsmt3bm\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; h=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=tEJOL3o2NVXOZwxuu+1sdbqzp0ND1V2UzdVwclEipuA=;\n\tb=Qgsmt3bmGoO6DdDNYlTqSclc/lY81I0BjW0jNA1aRWWZi/YaTd4cnGfKgGok3s3ijU\n\tUl4L1dxEnDfKkGMrFY5bNoUylzcgDGWmmNBkpQo52+OUNE4cZPDEVvtvPCKfJh1ikC3s\n\tD7p4LJK7N1fTEn+tzUio4iKRXUAUFOoxNudpg=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=tEJOL3o2NVXOZwxuu+1sdbqzp0ND1V2UzdVwclEipuA=;\n\tb=CcaQe1ABPIY+v3eJWXqMtA/7IM7hhYNuVtAwfOsZhJyG4kyl8s3FggsnKsMqQ4xPvI\n\tN2sH0uG/58Jd0EB1sdPSygPgHc7dd5gPrnUu0IX4EWHet6wYRSqtm1yd+PfEyeJWJTVU\n\t+Qj/PILFLwV4bHm6RDP++gHE5d0pYH8pUwZv8ACw0La2MhZbVLjTk7LzyGAMJlQEBLqq\n\tNwkF5ETlYRmH9E7kLfjwJX0WPhoiQ5dzQLPokzTbNdMyzrSDI8/h0iGBo4QfzPSoXRtn\n\tvyWZgG/kcRk+So6bfU0Ryian4czc1h9x4pd5q+xNwsPOAs//oOD+g7S7LS3Z/Pwp26sE\n\tPzGg==","X-Gm-Message-State":"AOAM531EbFQ5UuRK5V9wXP7vVuSoWhwq7RbWDNOba8/BcPccJ+wQSO84\n\tcFCh3uC1uYpB7oVGMxnV6qPfV+m0FHf8RQ==","X-Google-Smtp-Source":"ABdhPJw+NXMQX7KS0vbBt29QL/behJcGfgDXC3g8JKHHqT/RLHXk8tM3mg3eWmjJL/he1FmtR+INNQ==","X-Received":"by 2002:a17:902:24a:b029:e8:fe62:2840 with SMTP id\n\t68-20020a170902024ab02900e8fe622840mr5891724plc.71.1617851454823; \n\tWed, 07 Apr 2021 20:10:54 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  8 Apr 2021 12:10:39 +0900","Message-Id":"<20210408031040.1388568-1-hiroh@chromium.org>","X-Mailer":"git-send-email 2.31.0.208.g409f899ff0-goog","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v3 1/2] android: CameraBuffer: Add a\n\tstatic function to check a buffer validness","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"This adds a static function to CameraBuffer class that checks if\na buffer_handle is valid with a platform dependent framework.\nFor example, the function validates a buffer using\ncros::CameraBufferManager on ChromeOS.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_buffer.h              |  6 ++++++\n src/android/mm/cros_camera_buffer.cpp    | 18 ++++++++++++++++++\n src/android/mm/generic_camera_buffer.cpp |  9 +++++++++\n 3 files changed, 33 insertions(+)","diff":"diff --git a/src/android/camera_buffer.h b/src/android/camera_buffer.h\nindex 7e8970b4..ade082c3 100644\n--- a/src/android/camera_buffer.h\n+++ b/src/android/camera_buffer.h\n@@ -20,6 +20,8 @@ public:\n \tCameraBuffer(buffer_handle_t camera3Buffer, int flags);\n \t~CameraBuffer();\n \n+\tstatic bool isValidBuffer(buffer_hanlde_t camera3Buffer);\n+\n \tbool isValid() const;\n \n \tunsigned int numPlanes() const;\n@@ -38,6 +40,10 @@ CameraBuffer::CameraBuffer(buffer_handle_t camera3Buffer, int flags)\t\\\n CameraBuffer::~CameraBuffer()\t\t\t\t\t\t\\\n {\t\t\t\t\t\t\t\t\t\\\n }\t\t\t\t\t\t\t\t\t\\\n+bool CameraBuffer::isValidBuffer(buffer_handle_t buffer)\t\t\\\n+{\t\t\t\t\t\t\t\t\t\\\n+\treturn Private::isValidBuffer(buffer)\t\t\t\t\\\n+}\t\t\t\t\t\t\t\t\t\\\n bool CameraBuffer::isValid() const\t\t\t\t\t\\\n {\t\t\t\t\t\t\t\t\t\\\n \tconst Private *const d = LIBCAMERA_D_PTR();\t\t\t\\\ndiff --git a/src/android/mm/cros_camera_buffer.cpp b/src/android/mm/cros_camera_buffer.cpp\nindex 1a4fd5d1..f8449dfd 100644\n--- a/src/android/mm/cros_camera_buffer.cpp\n+++ b/src/android/mm/cros_camera_buffer.cpp\n@@ -24,6 +24,8 @@ public:\n \t\tbuffer_handle_t camera3Buffer, int flags);\n \t~Private();\n \n+\tstatic bool isValidBuffer(buffer_handle_t camera3Buffer);\n+\n \tbool isValid() const { return valid_; }\n \n \tunsigned int numPlanes() const;\n@@ -133,4 +135,20 @@ size_t CameraBuffer::Private::jpegBufferSize(size_t maxJpegBufferSize) const\n \treturn bufferManager_->GetPlaneSize(handle_, 0);\n }\n \n+/* static */\n+bool CameraBuffer::Private::isValidBuffer(buffer_handle_t camera3Buffer)\n+{\n+\tcros::CameraBufferManager *bufferManager =\n+\t\tcros::CameraBufferManager::GetInstance();\n+\n+\tint ret = bufferManager->Register(camera3Buffer);\n+\tif (ret) {\n+\t\treturn false;\n+\t}\n+\n+\tbufferManager->Deregister(camera3Buffer);\n+\n+\treturn true;\n+}\n+\n PUBLIC_CAMERA_BUFFER_IMPLEMENTATION\ndiff --git a/src/android/mm/generic_camera_buffer.cpp b/src/android/mm/generic_camera_buffer.cpp\nindex 929e078a..07a07372 100644\n--- a/src/android/mm/generic_camera_buffer.cpp\n+++ b/src/android/mm/generic_camera_buffer.cpp\n@@ -24,6 +24,8 @@ public:\n \t\tbuffer_handle_t camera3Buffer, int flags);\n \t~Private();\n \n+\tstatic bool isValidBuffer(buffer_handle_t camera3Buffer);\n+\n \tunsigned int numPlanes() const;\n \n \tSpan<uint8_t> plane(unsigned int plane);\n@@ -85,4 +87,11 @@ size_t CameraBuffer::Private::jpegBufferSize(size_t maxJpegBufferSize) const\n \t\t\t\t      maxJpegBufferSize);\n }\n \n+/* static */\n+bool CameraBuffer::Private::isValidBuffer(\n+\t[[maybe_unused]] buffer_handle_t camera3Buffer)\n+{\n+\treturn true;\n+}\n+\n PUBLIC_CAMERA_BUFFER_IMPLEMENTATION\n","prefixes":["libcamera-devel","v3","1/2"]}