From patchwork Wed Dec 8 12:36:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15080 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 60FA1C324B for ; Wed, 8 Dec 2021 12:36:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EEC806086A; Wed, 8 Dec 2021 13:36:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="AG7aj4g3"; dkim-atps=neutral Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4007660225 for ; Wed, 8 Dec 2021 13:36:41 +0100 (CET) Received: by mail-wm1-x330.google.com with SMTP id 77-20020a1c0450000000b0033123de3425so4102151wme.0 for ; Wed, 08 Dec 2021 04:36:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CgCVonvnxXDsJlMyIqj1/iVqjcm0DbL2S+Y1AFRZDPQ=; b=AG7aj4g3mCMoVn0SLgANAgBe6oQxzVdud+LIokrWyufHh9azhZKd0sIpG/tHV5tRvh QTIr/hNRqeCXHDZ6/wJMYltRJn5Vx4pNJlJPyvLQAvKJXNypAQXlXSO3IoJfi/0X+bbT B9uzATSFf/JxRabsmZ9Vp0grv8+oXpDIZWyqxoy5r4OMcOTZpevDkSn5VjO/7D67J34b c+lVgXCbd+RMb+gALUWI7kb0cvdmNjK6m5XtBVf6noW+LQ60fZShaI8Ck2XquIeWDSSh 9ZdkTzrRYREO1RRb2xCM8Q3rFrcpQubDOmVMy//W3QsKMx3a7o+yQfyE2uc5iyZFrade YVuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CgCVonvnxXDsJlMyIqj1/iVqjcm0DbL2S+Y1AFRZDPQ=; b=nPT8ztnd9g3oHHmR4taYCjhOAdA046Lv1pqrdEzw+1TmGBKIyfaYy2Bhf4V7uo/Cpq mWENHL1VV0lVyiajZH6GLNBnuHG4XAQNo4NwLmGX2Ws0M0L79uTde2K9Xl24KiOI7kQH xEKFu4WvGibM47IDxwqGSCg2EekQDfMJbhTJcAg9Kiz0VAujz1ZTJdyzZz7ZsHBIrZoR BFBTTUPhpEPqv/aqAKk0cLSXNSWzyan0E1NTM4XGvPFTUBU7ObSjy+vaFfswSQgPzhcB 2VPgGe7WfLGjkhvQU9MEG2SOuxQgCNiE10UxTiTw48vbcPccGlSlADrpOJ5CwRPoQaiG F5vA== X-Gm-Message-State: AOAM533pgGiab2mbzy+hX+McLIeZ4OyovZLlnzvYsL8qoIgP6/2igcP6 c1S/VoRzX1Shfyf4N3osW/zjBeCji4/bE9Kc X-Google-Smtp-Source: ABdhPJyKM7mGZrHrjC+Cc1mO/UkvGwtH3jinE2GXvrNrbE2+NGRNMZ2IPelstBom5KX0imBJqzMhXw== X-Received: by 2002:a05:600c:5125:: with SMTP id o37mr15597969wms.81.1638967000738; Wed, 08 Dec 2021 04:36:40 -0800 (PST) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:27d5:9305:f572:6623]) by smtp.gmail.com with ESMTPSA id n15sm5830360wmq.38.2021.12.08.04.36.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 04:36:40 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 8 Dec 2021 12:36:37 +0000 Message-Id: <20211208123637.1332668-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211208123637.1332668-1-naush@raspberrypi.com> References: <20211208123637.1332668-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/2] pipeline: raspberrypi: Restrict the advertised maximum ISP output 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Limit the advertised ISP output sizes available to the sensor resolution in PipelineHandlerRPi::generateConfiguration(). The user is free to configure a larger resolution than this, and this will work. However, this stops strange behavior in applications that use the V4L2 compatability layer to run, and request the largest possible advertised resolution, which is much larger than the sensor resolution. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 101aaea30743..86851ac467ad 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -530,10 +530,11 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera, unsigned int rawCount = 0; unsigned int outCount = 0; + Size sensorSize = data->sensor_->resolution(); for (const StreamRole role : roles) { switch (role) { case StreamRole::Raw: - size = data->sensor_->resolution(); + size = sensorSize; sensorFormat = findBestFormat(data->sensorFormats_, size, defaultRawBitDepth); pixelFormat = mbusCodeToPixelFormat(sensorFormat.mbus_code, BayerFormat::Packing::CSI2); @@ -546,7 +547,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera, fmts = data->isp_[Isp::Output0].dev()->formats(); pixelFormat = formats::NV12; /* Return the largest sensor resolution. */ - size = data->sensor_->resolution(); + size = sensorSize; bufferCount = 1; outCount++; break; @@ -599,11 +600,15 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera, std::forward_as_tuple(format.second.begin(), format.second.end())); } } else { - /* Translate the V4L2PixelFormat to PixelFormat. */ + /* + * Translate the V4L2PixelFormat to PixelFormat. Note that we + * limit the recommended largest ISP output size to match the + * sensor resolution. + */ for (const auto &format : fmts) { PixelFormat pf = format.first.toPixelFormat(); if (pf.isValid()) - deviceFormats[pf] = format.second; + deviceFormats[pf].emplace_back(sensorSize); } }