{"id":11823,"url":"https://patchwork.libcamera.org/api/patches/11823/?format=json","web_url":"https://patchwork.libcamera.org/patch/11823/","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":"<20210402024452.1308253-1-hiroh@chromium.org>","date":"2021-04-02T02:44:51","name":"[libcamera-devel,v3,1/2] android: cameraDevice: Factorize the code of validating camera3_capture_request","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"f08199ac897658c347ac3b83deb374bf1df6cd9c","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/11823/mbox/","series":[{"id":1883,"url":"https://patchwork.libcamera.org/api/series/1883/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1883","date":"2021-04-02T02:44:51","name":"[libcamera-devel,v3,1/2] android: cameraDevice: Factorize the code of validating camera3_capture_request","version":3,"mbox":"https://patchwork.libcamera.org/series/1883/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11823/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11823/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 CC0E6C0DA3\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Apr 2021 02:45:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4FCAD6877D;\n\tFri,  2 Apr 2021 04:45:01 +0200 (CEST)","from mail-pl1-x634.google.com (mail-pl1-x634.google.com\n\t[IPv6:2607:f8b0:4864:20::634])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E1AE36877C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 Apr 2021 04:44:59 +0200 (CEST)","by mail-pl1-x634.google.com with SMTP id v8so1918340plz.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 01 Apr 2021 19:44:59 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:2:908:1da:b07c:32bc])\n\tby smtp.gmail.com with ESMTPSA id\n\tbb16sm145361pjb.17.2021.04.01.19.44.56\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 01 Apr 2021 19:44:57 -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=\"POvf7J4y\"; 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=CWvnM27sMJybluUYtLViRKdO83r8N0cZtWfmPfv2wjQ=;\n\tb=POvf7J4y9i+rSV69kR0LRfCOdCzlALvNULle3A5dNBxWsExzkLbC+NkfnAcHhJhL3T\n\tERtEyk7ULjhnRa1qJ/UXdsTsixKzrz3CDOHV+2GVm98ycRlS6wv02R4AufppwofoHRBq\n\t4kP1wVDyAEr8lMutqcsJBcqXXeNAHjX9aPa78=","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=CWvnM27sMJybluUYtLViRKdO83r8N0cZtWfmPfv2wjQ=;\n\tb=O2U0KW7LRjq5Oxw0FQsc8W9sRRr11KqJ86IwH2qqAX/us2RewYGrkbAg6jXVW9z7GV\n\tnmxZZjVaEZmKIwb/evq/18cq8tA6JveS6tB7wqRp3IeVQKcQcQLdbsCXoqgvOpPP3oPf\n\th30AkAg6hOmdIps5xBO2PvmepmvDmZBBTWy2fdzXW+yD+ND1cHYjTlRF2LBMsDA5rbIZ\n\t0rEG8Srh5vZ6SIOrSyVwVNs+A1p6OWAvXBQ46dURDx4k/1d0T2EsL6eotZGTabJumrjF\n\t05iP4vz50KGufD6B3NLgHAPbpjTKRACMXUN/aRx/e69jaHfWluEpazsTz8ST0lhHls7n\n\ttpKg==","X-Gm-Message-State":"AOAM530KCeezgs27owK00X1boO90TgUdWoeSg4VQWKq2hxLfM267opo7\n\tFDDpACieWQVLq84KiLanM0ecuz/N1XNmvA==","X-Google-Smtp-Source":"ABdhPJys+dqbhIsbpiQ9o2k13i8oJtnPdFFEkj/yD9UZ/u5ZefAe7hx0hkB5zJYF/QweDUnaRbTjqQ==","X-Received":"by 2002:a17:903:10d:b029:e7:3875:33ed with SMTP id\n\ty13-20020a170903010db02900e7387533edmr10896372plc.34.1617331498258; \n\tThu, 01 Apr 2021 19:44:58 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  2 Apr 2021 11:44:51 +0900","Message-Id":"<20210402024452.1308253-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: cameraDevice: Factorize\n\tthe code of validating camera3_capture_request","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":"CameraDevice::processCaptureRequest() checks the validness of a\nprovided camera3_capture_request. This factorizes the code in\norder to add more validation to the request later.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/android/camera_device.cpp | 24 ++++++++++++++++--------\n 1 file changed, 16 insertions(+), 8 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex eb327978..988c1fd5 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -256,6 +256,21 @@ void sortCamera3StreamConfigs(std::vector<Camera3StreamConfig> &unsortedConfigs,\n \tunsortedConfigs = sortedConfigs;\n }\n \n+bool isValidRequest(camera3_capture_request_t *camera3Request)\n+{\n+\tif (!camera3Request) {\n+\t\tLOG(HAL, Error) << \"No capture request provided\";\n+\t\treturn false;\n+\t}\n+\n+\tif (!camera3Request->num_output_buffers) {\n+\t\tLOG(HAL, Error) << \"No output buffers provided\";\n+\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+\n } /* namespace */\n \n /*\n@@ -1785,15 +1800,8 @@ int CameraDevice::processControls(Camera3RequestDescriptor *descriptor)\n \n int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request)\n {\n-\tif (!camera3Request) {\n-\t\tLOG(HAL, Error) << \"No capture request provided\";\n+\tif (isValidRequest(camera3Request))\n \t\treturn -EINVAL;\n-\t}\n-\n-\tif (!camera3Request->num_output_buffers) {\n-\t\tLOG(HAL, Error) << \"No output buffers provided\";\n-\t\treturn -EINVAL;\n-\t}\n \n \t/* Start the camera if that's the first request we handle. */\n \tif (!running_) {\n","prefixes":["libcamera-devel","v3","1/2"]}