From patchwork Fri Mar 26 22:04:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phi-bang Nguyen X-Patchwork-Id: 11732 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 79F24C32EB for ; Fri, 26 Mar 2021 22:04:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B9AD968D6D; Fri, 26 Mar 2021 23:04:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="V61t+4i1"; dkim-atps=neutral Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F77568D6A for ; Fri, 26 Mar 2021 23:04:38 +0100 (CET) Received: by mail-wr1-x42d.google.com with SMTP id x7so6973547wrw.10 for ; Fri, 26 Mar 2021 15:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BC7q5wsotl3CYVZQ18BXqI4yqE8oHDVSV0o66Wa0g70=; b=V61t+4i1gnpVW2mozRgNBnGN2zNbLi2EAczjvR2s33gzTx7bkBjM+qv3PstGrq/raO TuGLchkfswO4aOdD6XjAFF2L+GKrYtFOK9+NDs+2XIhNTfcsdzIXs5kfBnKe1+NU78pG RXHl9mQlwWcCQIah4qBh5juHpb88GUUS/xQL2nQiyAEIPRGehkXynkhN0ba54ApDcU6g LXdIHimXyDz11ZnBTijrMWHrNm1d5KmpJpUxw2uQPj4mmDISULhaiNvGpj76U15EPbUG 2+MIhaFT5FQrgAwqw5jqGNq87Gmv4EuJEelcsV+BbqZD8PMtBUe/WCADOcxcMFCYRl8T BoGA== 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=BC7q5wsotl3CYVZQ18BXqI4yqE8oHDVSV0o66Wa0g70=; b=aJMlPHBihHsfC1rImciIXrJ4H37Mmba/Mn+2Pqqv2uGN3fGIyiWiA+8htDnhBJixzx UN9RKA852tPzYLdY4r/FsywEzdUVwtQO2ZlCw1CJAYjxibPaXLbf3ftix4+qnheph1xw bGI0BAEdj49bwLt6oYpPtz8SkYYUCDGyxgxBbYC/3w35RV/0GEz8ujCmlJNMHMGLVZcL DyIzVB+V6FlaO/mVmYmPwxno1+ndxo7G1ErYgm8jZ0cf7YcCf4DXW3glvhTbz/6g166S 6vOgmd6eU3Kq+Q5uIvLrLCAXdJNB0kM0wkShMQuD4qbjJ8PcFL3zY+pY64VLCI9o9gvQ yM5Q== X-Gm-Message-State: AOAM530UD3eLWWxaZQBFJe9dnVok5ZerRdCZsYgpll2sS6bCibwQ0GiH IqJft5J799zmhwsYcR/s4OCGVg== X-Google-Smtp-Source: ABdhPJwQVITHAs6UkU2iqpuP/SrF4eYFPvXIAnggtfWpfcrllV3CYPlS0GRy7uGOBwCsEp8GU7cMfQ== X-Received: by 2002:a05:6000:362:: with SMTP id f2mr8430851wrf.141.1616796277805; Fri, 26 Mar 2021 15:04:37 -0700 (PDT) Received: from localhost.localdomain (206.159.69.91.rev.sfr.net. [91.69.159.206]) by smtp.googlemail.com with ESMTPSA id p6sm15013885wru.2.2021.03.26.15.04.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Mar 2021 15:04:37 -0700 (PDT) From: Phi-Bang Nguyen To: laurent.pinchart@ideasonboard.com Date: Fri, 26 Mar 2021 23:04:10 +0100 Message-Id: <20210326220410.329299-1-pnguyen@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] android: camera_device: Add null check for ScalerCrop control 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: , Cc: libcamera-devel@lists.libcamera.org Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The ScalerCrop control does not contain the null check which can cause the camera HAL crash at boot. Fix it. Signed-off-by: Phi-Bang Nguyen Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/android/camera_device.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index ae693664..a8108e3a 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1107,11 +1107,14 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() * use the maximum and minimum crop rectangles to calculate the * digital zoom factor. */ + float maxZoom = { 1 }; const auto info = controlsInfo.find(&controls::ScalerCrop); - Rectangle min = info->second.min().get(); - Rectangle max = info->second.max().get(); - float maxZoom = std::min(1.0f * max.width / min.width, - 1.0f * max.height / min.height); + if (info != controlsInfo.end()) { + Rectangle min = info->second.min().get(); + Rectangle max = info->second.max().get(); + maxZoom = std::min(1.0f * max.width / min.width, + 1.0f * max.height / min.height); + } staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM, &maxZoom, 1); }