{"id":11774,"url":"https://patchwork.libcamera.org/api/1.1/patches/11774/?format=json","web_url":"https://patchwork.libcamera.org/patch/11774/","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":"<20210329174046.86591-1-pnguyen@baylibre.com>","date":"2021-03-29T17:40:46","name":"[libcamera-devel,v3] android: camera_device: Add null check for ScalerCrop control","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"29753695db31e98457475f067cb5590c6c1091a2","submitter":{"id":79,"url":"https://patchwork.libcamera.org/api/1.1/people/79/?format=json","name":"Phi-bang Nguyen","email":"pnguyen@baylibre.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11774/mbox/","series":[{"id":1864,"url":"https://patchwork.libcamera.org/api/1.1/series/1864/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1864","date":"2021-03-29T17:40:46","name":"[libcamera-devel,v3] android: camera_device: Add null check for ScalerCrop control","version":3,"mbox":"https://patchwork.libcamera.org/series/1864/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11774/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11774/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 3DFDAC32F0\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Mar 2021 17:41:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8A9B268784;\n\tMon, 29 Mar 2021 19:41:12 +0200 (CEST)","from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com\n\t[IPv6:2a00:1450:4864:20::32f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B86C06877D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Mar 2021 19:41:11 +0200 (CEST)","by mail-wm1-x32f.google.com with SMTP id\n\tw203-20020a1c49d40000b029010c706d0642so8878325wma.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Mar 2021 10:41:11 -0700 (PDT)","from localhost.localdomain (206.159.69.91.rev.sfr.net.\n\t[91.69.159.206]) by smtp.googlemail.com with ESMTPSA id\n\tb65sm144368wmh.4.2021.03.29.10.41.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 29 Mar 2021 10:41:10 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=baylibre-com.20150623.gappssmtp.com\n\theader.i=@baylibre-com.20150623.gappssmtp.com\n\theader.b=\"c8oHUHUV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=09oRVhxdPvd5qx78k0wVXXFF+9FLjhHM2pVPVQWlYtQ=;\n\tb=c8oHUHUVppETposVzbP1eIgLIc1Bf2YEcJjW5zakF7Q9FaqUYLL1rZRXNCNVRdYA8T\n\tqJI8sUd9JaOpzNgTlXBmNdHuNcU9+ADbExJjnSa+E5J9REX7hAwOnzq0PYMTA7f3h26I\n\tLdTrxszp7g7tB01+X69JXPRdqGvmewJwP5j7arKyy6Eu/fQLtKuVKO2ZfXijds9+ozTV\n\t8Bbx7qyVZjrdroejGOCt3Qt5oxl4zMzCxbyZWs+5Ha9HiQMXiIj4y3ef+xGQJDo4qtJI\n\ttYMGykFwlI0JDiL/4daqD6+rFqfqo6/iIOh3WfwPTOR767XAtCx/mHRCoQ3eFNYUxU+h\n\tJAMw==","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:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=09oRVhxdPvd5qx78k0wVXXFF+9FLjhHM2pVPVQWlYtQ=;\n\tb=b3yB/BlMhqYgh2OH5sfCzq0rLAkcXvp/DGWY+9zLHewwsqejUDm3JYSfvpc0CuGzB6\n\tSLjjBCQegKF6TL91Q52q+wrCHcT+SabBEVV8tV5XZENmPxwRoKj/Ojv4v62/nawXin+c\n\tLchKaC+6TKyresQ358Kwki4LUL2ERsSOHLIGPIJd/JY+zgC7cs/p1nfIs6zAE6FRqXoW\n\tYMILmsc/7FbLtS+1B/0uz171L/IhqYh7EMfAnvMzex2AqCG6GH9V1vnryi4CIUsCSjPQ\n\tXbnAOdHUzwe7MdMY4XajR1ovX/9732nuX9UgnGYLgpmVeylUwEpaJaEr1WbSy0zOTvu6\n\t8igA==","X-Gm-Message-State":"AOAM5318x4NLVjYUzvXXNp29eAWUyeo1z+pKfpUaazdeTJSFdqZsJMdU\n\tDRtrMEhTvTKM9NrZPtfnd8KrI5dn6OPRGg==","X-Google-Smtp-Source":"ABdhPJw5TzCdzgJrJktUaTM2jVpWb/0dGMjiNnP8q6raH+mmXdnbdsefFMS/oBrDwN0ToNj+1gWu9A==","X-Received":"by 2002:a7b:c3c1:: with SMTP id t1mr207521wmj.47.1617039671091; \n\tMon, 29 Mar 2021 10:41:11 -0700 (PDT)","From":"Phi-Bang Nguyen <pnguyen@baylibre.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 29 Mar 2021 19:40:46 +0200","Message-Id":"<20210329174046.86591-1-pnguyen@baylibre.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<YGGNCu7el9F0isDL@pendragon.ideasonboard.com>","References":"<YGGNCu7el9F0isDL@pendragon.ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v3] android: camera_device: Add null check\n\tfor ScalerCrop control","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":"The ScalerCrop control does not contain the null check which can\ncause the camera HAL crash at boot. Fix it.\n\nFixes: 31a1a628cd0e (\"android: camera_device: Register MAX_DIGITAL_ZOOM\")\n\nSigned-off-by: Phi-Bang Nguyen <pnguyen@baylibre.com>\n---\n src/android/camera_device.cpp | 40 ++++++++++++++++++-----------------\n 1 file changed, 21 insertions(+), 19 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex ae693664..9ec261c3 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1095,26 +1095,28 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \t}\n \n \t/* Scaler static metadata. */\n-\t{\n-\t\t/*\n-\t\t * \\todo The digital zoom factor is a property that depends\n-\t\t * on the desired output configuration and the sensor frame size\n-\t\t * input to the ISP. This information is not available to the\n-\t\t * Android HAL, not at initialization time at least.\n-\t\t *\n-\t\t * As a workaround rely on pipeline handlers initializing the\n-\t\t * ScalerCrop control with the camera default configuration and\n-\t\t * use the maximum and minimum crop rectangles to calculate the\n-\t\t * digital zoom factor.\n-\t\t */\n-\t\tconst auto info = controlsInfo.find(&controls::ScalerCrop);\n-\t\tRectangle min = info->second.min().get<Rectangle>();\n-\t\tRectangle max = info->second.max().get<Rectangle>();\n-\t\tfloat maxZoom = std::min(1.0f * max.width / min.width,\n-\t\t\t\t\t 1.0f * max.height / min.height);\n-\t\tstaticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,\n-\t\t\t\t\t  &maxZoom, 1);\n+\n+\t/*\n+\t * \\todo The digital zoom factor is a property that depends\n+\t * on the desired output configuration and the sensor frame size\n+\t * input to the ISP. This information is not available to the\n+\t * Android HAL, not at initialization time at least.\n+\t *\n+\t * As a workaround rely on pipeline handlers initializing the\n+\t * ScalerCrop control with the camera default configuration and\n+\t * use the maximum and minimum crop rectangles to calculate the\n+\t * digital zoom factor.\n+\t */\n+\tfloat maxZoom = 1.0f;\n+\tconst auto scalerCrop = controlsInfo.find(&controls::ScalerCrop);\n+\tif (scalerCrop != controlsInfo.end()) {\n+\t\tRectangle min = scalerCrop->second.min().get<Rectangle>();\n+\t\tRectangle max = scalerCrop->second.max().get<Rectangle>();\n+\t\tmaxZoom = std::min(1.0f * max.width / min.width,\n+\t\t\t\t   1.0f * max.height / min.height);\n \t}\n+\tstaticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,\n+\t\t\t\t  &maxZoom, 1);\n \n \tstd::vector<uint32_t> availableStreamConfigurations;\n \tavailableStreamConfigurations.reserve(streamConfigurations_.size() * 4);\n","prefixes":["libcamera-devel","v3"]}