From patchwork Fri Aug 12 09:01:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 17085 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 4E654BE173 for ; Fri, 12 Aug 2022 09:01:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A378E6332A; Fri, 12 Aug 2022 11:01:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660294871; bh=QQbmlaTru7HANm0+BKbT7CuZ8c33iZRKAzLvB+Cn5tA=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Kj0GUxYuHMCshroWwKwT+SzIWhVxNwHNN6yR2bGGeW5ydYur+1PdZ+SAehaZtA1uq /nV4AZjvHXJlqOlcth8xOuEst6xzQF00bvGDCk8NVNLYFNWPhnaDbnyLRl1bw8dnu3 7EYgFFUZ5Rqh1br1quBBRaIgrvaG/H3bNbMCQ5et4LqOdH/o0mAbeaVULK5m0Wqz45 84q1tMQfij/k/XsDrtmMsnAAxTmJh/txCufxBQz6ZtWB9qLgmyMvr0jGFLGkWqfFW8 vLAib67hOD0q2bECbbi5XWx6fT5KHXv1vbIwhPE0v5K3EUXtwOFOLDRmwBfQbb+3PK U8m6+HmsfzrjQ== Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D47C463326 for ; Fri, 12 Aug 2022 11:01:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Hvdtj9Nd"; dkim-atps=neutral Received: by mail-pj1-x102d.google.com with SMTP id q9-20020a17090a2dc900b001f58bcaca95so7767542pjm.3 for ; Fri, 12 Aug 2022 02:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=pXnSr914+nO/rhkBxzopHGK/cxQKlKvOmTElXFME5zI=; b=Hvdtj9Ndd9Ko2hKXeD/u6erUBlQ3+zHd87adBOSFXtzuH5k39FZ4KT8xyVxf8edPnt 0Ag/QU2ijC/SdtikMO7f/KEY79EJ5Z7YJo55C8pbuu0Rt9nX4O+0PKQnfi0ujAkAbUbZ NMCV7BOfszCRKmY24OAsQ7+jh3iKO3/32K+jY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=pXnSr914+nO/rhkBxzopHGK/cxQKlKvOmTElXFME5zI=; b=2FEFBG+PLvnJKPQHWNVpfAxdU4L5zm97czR5tvTDm6Z4Rylhv2ppmS9ndwJpavU1Y9 KB57thMiKNz5Fz5StGAP6dDe0CMUv1Og4Lf8oApTMOZipuW/JpdEE2WxKydj+Sp+TBZh hYm08bgCV9Gy/LMIV/fO1N1tVNG/EvaLWUyKhor3v/0NRXSfdUZZ4mlIultJGMfw18qd OqGqO54e8Q7KErLKUlfgGpVghrvCS7E+s3E0F2XPKM089xw65HP6DHsWvEuaEeQN7epV H/x5AfFROGcxFyZaxHJvFIJNdoMm09lmzmjjDnuMfhXsJiv6IjAI6M0OiMlZSadVCspP DTuA== X-Gm-Message-State: ACgBeo0oD6g3Kkc+cPeDSKAeJJFcns8wnS7wemciE92Gp3S3p7ERT5Rd Ckwk317rrvgUzvZgJbvYcbHTbeokgmK57A== X-Google-Smtp-Source: AA6agR6GtLvCQQLHdo1xoQ1PYoeDx3cfCBjrzKfCdCVLVmS7FAbOu7eZrO9Bz5qCCScEOqBhEeCjbw== X-Received: by 2002:a17:90b:350a:b0:1f5:6a5e:5d12 with SMTP id ls10-20020a17090b350a00b001f56a5e5d12mr12949640pjb.46.1660294868164; Fri, 12 Aug 2022 02:01:08 -0700 (PDT) Received: from localhost ([2401:fa00:1:17:1705:d284:d114:2e24]) by smtp.gmail.com with UTF8SMTPSA id t21-20020a634455000000b00419b128cf98sm935151pgk.54.2022.08.12.02.01.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Aug 2022 02:01:07 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 12 Aug 2022 17:01:03 +0800 Message-Id: <20220812090103.1781246-1-hanlinchen@chromium.org> X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] libcamera: ipu3: Use std::max() instead of expandTo() to get the max resolution 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: , X-Patchwork-Original-From: Han-Lin Chen via libcamera-devel From: Hanlin Chen Reply-To: Han-Lin Chen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Using Size::expandTo() to find the max resolution might generate a non-existent resolution. For example, when application request streams for 1920x1080 and 1600x1200, the max resolution will be wrongly 1920x1200 and fails the configuration. Bug: https://bugs.libcamera.org/show_bug.cgi?id=139 Signed-off-by: Han-Lin Chen Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/ipu3/ipu3.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index f65db3c8..47311953 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -247,6 +247,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() */ unsigned int rawCount = 0; unsigned int yuvCount = 0; + Size rawRequirement; Size maxYuvSize; Size rawSize; @@ -255,10 +256,11 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) { rawCount++; - rawSize.expandTo(cfg.size); + rawSize = std::max(rawSize, cfg.size); } else { yuvCount++; - maxYuvSize.expandTo(cfg.size); + maxYuvSize = std::max(maxYuvSize, cfg.size); + rawRequirement.expandTo(cfg.size); } } @@ -287,17 +289,17 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() * The output YUV streams will be limited in size to the maximum frame * size requested for the RAW stream, if present. * - * If no raw stream is requested generate a size as large as the maximum - * requested YUV size aligned to the ImgU constraints and bound by the - * sensor's maximum resolution. See + * If no raw stream is requested generate a size as large as the span + * of all requested YUV size aligned to the ImgU constraints and bound + * by the sensor's maximum resolution. See * https://bugs.libcamera.org/show_bug.cgi?id=32 */ if (rawSize.isNull()) - rawSize = maxYuvSize.expandedTo({ ImgUDevice::kIFMaxCropWidth, - ImgUDevice::kIFMaxCropHeight }) - .grownBy({ ImgUDevice::kOutputMarginWidth, - ImgUDevice::kOutputMarginHeight }) - .boundedTo(data_->cio2_.sensor()->resolution()); + rawSize = rawRequirement.expandedTo({ ImgUDevice::kIFMaxCropWidth, + ImgUDevice::kIFMaxCropHeight }) + .grownBy({ ImgUDevice::kOutputMarginWidth, + ImgUDevice::kOutputMarginHeight }) + .boundedTo(data_->cio2_.sensor()->resolution()); cio2Configuration_ = data_->cio2_.generateConfiguration(rawSize); if (!cio2Configuration_.pixelFormat.isValid())