{"id":11855,"url":"https://patchwork.libcamera.org/api/1.1/patches/11855/?format=json","web_url":"https://patchwork.libcamera.org/patch/11855/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20210407043620.1756347-1-hiroh@chromium.org>","date":"2021-04-07T04:36:19","name":"[libcamera-devel,v2,1/2] android: CameraBuffer: Add a static function to check a buffer validness","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"aab7e3a2f591ba054cbbec190d0971668b86f116","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11855/mbox/","series":[{"id":1898,"url":"https://patchwork.libcamera.org/api/1.1/series/1898/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1898","date":"2021-04-07T04:36:19","name":"[libcamera-devel,v2,1/2] android: CameraBuffer: Add a static function to check a buffer validness","version":2,"mbox":"https://patchwork.libcamera.org/series/1898/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11855/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11855/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 67DCABD695\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 Apr 2021 04:36:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CBB79687D5;\n\tWed,  7 Apr 2021 06:36:29 +0200 (CEST)","from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com\n\t[IPv6:2607:f8b0:4864:20::52f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 337E1602CD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Apr 2021 06:36:28 +0200 (CEST)","by mail-pg1-x52f.google.com with SMTP id l76so12051983pga.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 06 Apr 2021 21:36:28 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:2:4180:40db:6f79:a143])\n\tby smtp.gmail.com with ESMTPSA id\n\td2sm19466967pgp.47.2021.04.06.21.36.25\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 06 Apr 2021 21:36:25 -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=\"hoI86jhK\"; 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=R7HrEa+QGQ2YjpplnhmLYGq/Ic9JEtUOQu6cMCuTjxY=;\n\tb=hoI86jhK3DUcxLJ5IU+6LZbxaewghk2XKpGUr+BxzH+wEueorr/OcPVYuzjLfnn0b0\n\t0UT/Frm4Ty6II4Bym21jU2IMW3grpO4kMR97P2IAX9RZsNp/DqdD3ByUgEV0xm0tEdOy\n\t1u6xhPq9+vPEeFsXO5BCDG/RstNjnZ9GZFaG8=","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=R7HrEa+QGQ2YjpplnhmLYGq/Ic9JEtUOQu6cMCuTjxY=;\n\tb=Z6DlpkSM60HvABgHxEOP1SuwDbRMEYXI6Gx5fDCVNG68JUrM1IfBOE/zkYXFIIaNnQ\n\tbyW7GIlgNPANhysk9FbhTFyaB0mzf8pNUqgb7WlD3Sk4AW1CDAruy+eqreQG4O+A2hGb\n\tKKdBte/fld49ADvNK97locVxw6pt38UchYEJMwpMVUXAkj2JdBVw7A3OtXTvigXU57LF\n\t9dMsqP+6tkamn1HcsC/sOcCis8euSoFB7qeuf2D7h2Z5dvyJGrzbUlrlnpN+jzK7jOnU\n\tssBhS2jA0VNUWHSQYoO3UVPJ0jQUr1TJ69UXp2SKlCWg8ul9cRs1IGIwvso4+9yzW5VB\n\tr3aw==","X-Gm-Message-State":"AOAM532W9vaVzHuuarQpisLjGRIJJlgxZ1oRl7mvR2JGyktTEJr24riw\n\tsYcNxBy3WRjmbW3VprYpg0OxikZyS/gerw==","X-Google-Smtp-Source":"ABdhPJygivTIYRlcBenuvNm+tLoWVnAMZ0bJfH4gC6ZsIcokgBNHadDGa2MfUiHaOVzNbH72CWgjUw==","X-Received":"by 2002:a62:1c8f:0:b029:209:7eb2:748f with SMTP id\n\tc137-20020a621c8f0000b02902097eb2748fmr1235159pfc.79.1617770186230; \n\tTue, 06 Apr 2021 21:36:26 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  7 Apr 2021 13:36:19 +0900","Message-Id":"<20210407043620.1756347-1-hiroh@chromium.org>","X-Mailer":"git-send-email 2.31.0.208.g409f899ff0-goog","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2 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>\n---\n src/android/camera_buffer.h              |  6 ++++++\n src/android/mm/cros_camera_buffer.cpp    | 19 +++++++++++++++++++\n src/android/mm/generic_camera_buffer.cpp |  9 +++++++++\n 3 files changed, 34 insertions(+)","diff":"diff --git a/src/android/camera_buffer.h b/src/android/camera_buffer.h\nindex 7e8970b4..3bb9a435 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_handle_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 camera3Buffer)\t\t\\\n+{\t\t\t\t\t\t\t\t\t\\\n+\treturn Private::isValidBuffer(camera3Buffer);\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..371a2511 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,21 @@ 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+\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..0c52e196 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+       [[maybe_unused]] buffer_handle_t camera3Buffer)\n+{\n+\treturn true;\n+\n+}\n PUBLIC_CAMERA_BUFFER_IMPLEMENTATION\n","prefixes":["libcamera-devel","v2","1/2"]}