From patchwork Wed Oct 27 09:28:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 14360 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 8FF2EBDB1C for ; Wed, 27 Oct 2021 09:28:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3C6C26488D; Wed, 27 Oct 2021 11:28:18 +0200 (CEST) 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="caUnQDxG"; dkim-atps=neutral Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D7B5F64886 for ; Wed, 27 Oct 2021 11:28:11 +0200 (CEST) Received: by mail-wr1-x436.google.com with SMTP id s14so71582wrb.3 for ; Wed, 27 Oct 2021 02:28:11 -0700 (PDT) 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=EnUQ4idl8bJve6HakceXlG5RBJ4/vOz49Rc+AHEsMgQ=; b=caUnQDxGEOeYpGHfRYw/lwz7hwbrjPrXPI3onybog2H09/78ABitioRej3dE19JQSO 3RHCY39kyYaVqtp/POJuKd1XZ/SoP7t6VcweZEa6EYY2qosekF4J1LJZXUATV/SYZBA4 CllW1WuoKNiRhmk5y87smAwum+AGoMIRFOwzac0y2c865QXwvo12XWlaYclbt2U86/sy MtGtofQllknYC/7c8jSgajb4MZMawTSrrl9cz1rkmpsWdO6SqXp6bj8Z1qeC2gePPrj/ /FXp9BeI6cL9LbXfgklbmZ649RjHi1Ug7CSCpcsvALafKWk3wbDAksyMM8CMYYJaCCAZ Espw== 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=EnUQ4idl8bJve6HakceXlG5RBJ4/vOz49Rc+AHEsMgQ=; b=mb3AX6HvcS+Vbz7BK5aaPLeOufnO3QiBIStye+rm3px9csFHT9yDC5c8X2GP4eJz+d oc+HuzpSQiyb8m/lmJuZ9rIp58fQr/0ngV3GsblTXoI3CMBnQ4gUvDOlmI2ZNBoO+3OV +IUKrBxBV0XSKvkPpvCg3oHrpSPYlUr0SfCoyvB3jd4xmLwBOtpSTn427lLdSr2ql9kY sJ+kNKWzymYuQQ2gqgLcm5Xu/Rn/03N3lLpH9DjlXJDXWiF7YEVPnnrOWrKSbTPCe4LQ xkDgDvKVoUM66EjvHA/T0Rc7hpXUg68jZ4avV0hNkJ0TJMiJ3zkaQyWCDRlJ59Oc5z7P 9ktg== X-Gm-Message-State: AOAM532FqKib1m8Ngb74GvRpmDJLd1GA1Ib5HR6Vcv1SdlEq9KUMdpsU Uu4TrhtZeR63khwmcbzZ/ygg2pfRCE1AtJ4l X-Google-Smtp-Source: ABdhPJzGu4oTs98HzXnUh712xfvPRPOV0lK3Jc6WD0zI6/RRoMPbOyR52gHqYn7G/t4DmIHSuLXH0Q== X-Received: by 2002:adf:b355:: with SMTP id k21mr39025149wrd.380.1635326891394; Wed, 27 Oct 2021 02:28:11 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:6561:eb24:3f00:ce98]) by smtp.gmail.com with ESMTPSA id x2sm2861360wmj.3.2021.10.27.02.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 02:28:10 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Oct 2021 10:28:00 +0100 Message-Id: <20211027092803.3671096-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211027092803.3671096-1-naush@raspberrypi.com> References: <20211027092803.3671096-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 6/9] pipeline: raspberrypi: Set packing formats for the Unicam image node 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" Default to using CSI2 packed formats when setting up the Unicam image format, but use an unpacked format if the user requests one through StreamConfiguration. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 48f561d31a31..1b78b5e74a63 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -96,14 +96,14 @@ BayerFormat mbusCodeToBayerFormat(unsigned int mbusCode) return BayerFormat{}; } -V4L2DeviceFormat toV4L2DeviceFormat(V4L2SubdeviceFormat &format) +V4L2DeviceFormat toV4L2DeviceFormat(V4L2SubdeviceFormat &format, BayerFormat::Packing packing) { V4L2DeviceFormat deviceFormat; BayerFormat bayer = mbusCodeToBayerFormat(format.mbus_code); ASSERT(bayer.isValid()); - bayer.packing = BayerFormat::Packing::CSI2Packed; + bayer.packing = packing; deviceFormat.fourcc = bayer.toV4L2PixelFormat(); deviceFormat.size = format.size; return deviceFormat; @@ -413,7 +413,8 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() * the user request. */ V4L2SubdeviceFormat sensorFormat = findBestFormat(data_->sensorFormats_, cfg.size); - V4L2DeviceFormat unicamFormat = toV4L2DeviceFormat(sensorFormat); + V4L2DeviceFormat unicamFormat = toV4L2DeviceFormat(sensorFormat, + BayerFormat::Packing::CSI2Packed); int ret = data_->unicam_[Unicam::Image].dev()->tryFormat(&unicamFormat); if (ret) return Invalid; @@ -631,6 +632,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) for (auto const stream : data->streams_) stream->reset(); + BayerFormat::Packing packing = BayerFormat::Packing::CSI2Packed; Size maxSize, sensorSize; unsigned int maxIndex = 0; bool rawStream = false; @@ -649,6 +651,8 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) */ sensorSize = cfg.size; rawStream = true; + /* Check if the user has explicitly set an unpacked format. */ + packing = BayerFormat::fromPixelFormat(cfg.pixelFormat).packing; } else { if (cfg.size > maxSize) { maxSize = config->at(i).size; @@ -667,7 +671,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) * Unicam image output format. The ISP input format gets set at start, * just in case we have swapped bayer orders due to flips. */ - V4L2DeviceFormat unicamFormat = toV4L2DeviceFormat(sensorFormat); + V4L2DeviceFormat unicamFormat = toV4L2DeviceFormat(sensorFormat, packing); ret = data->unicam_[Unicam::Image].dev()->setFormat(&unicamFormat); if (ret) return ret;