From patchwork Fri Oct 22 14:39:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 14262 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 0334FBDB1C for ; Fri, 22 Oct 2021 14:40:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6507C68F69; Fri, 22 Oct 2021 16:40: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="pi6IUNDn"; dkim-atps=neutral Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 551C86023B for ; Fri, 22 Oct 2021 16:40:15 +0200 (CEST) Received: by mail-wr1-x42a.google.com with SMTP id k7so1927579wrd.13 for ; Fri, 22 Oct 2021 07:40:15 -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=dlKh+cB15Cw4lo2b5aY9K5NmMsiPItPmPHaK4JaBV0U=; b=pi6IUNDnL2smEDHm6G0NkaEjSjRXG2v+1O7rAACWRoBzStAGYgoeUtzsFCukbiRGAp PYtw/ae12c4MBxXTMwCeJf4peLSMJQJl0IYsv41YWOfus6/bSWkelxGhgbyphKEOZHHw 8RgQWzPaaIFH3V53utqVh6VnnngpqKcJ5BR5al3Ow/0kS9UEwQcju+ynfS64QWFCK0Rz 2/YGbpAQQ4FOG01ZKXA2bXZHcQLpJsnm7rcMAB6SU4OERjEhZGb6/JakMxuqZZcAYGOL sv112pPHKmCdf1GigvM4+PW0l5dzPQrPi71KCousSw4bVM/YJmB1XwRuF1SHx2h/kFq4 q60A== 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=dlKh+cB15Cw4lo2b5aY9K5NmMsiPItPmPHaK4JaBV0U=; b=u7Ohuu2zb1f+uaby3R3dP4+WnZWlsSbn2m8SMx0nIUEE/TxVEElN1X81IWLFkZC3pT XQDSsi0Ay4Ey/SOG6kbNI12qgJZ1jr2AtwaqgHFdfubfTqajQfU8bdrLioAOf4lwtEKL hqq33Ae0+UMoB175KVEENQDYP38TKO3CfRwiVj31lBmD/llC942/ABTKMXBhERLeFYEb Y+XL0iDkv89QAXse0uKG8xMSjSPZ725jFhakPiUgWMEx+B9caQu2v3TJnrpWXXCCgGNp 0/9uT7KLX2PjCcZxcYTYNWgooMh/IrhemsrR/mheJagQUf1lqCqo4uzUAC2ivNGgSdsP Trgg== X-Gm-Message-State: AOAM530DWh1TSdzN4WSMJ0k+VdL0gX17qqLRlTqNaepk2Va9vZMi9fGS eBt/c9sbGiRYVDvLLLXUEkR4Wa7IMnpYbSY+ X-Google-Smtp-Source: ABdhPJwjwf00xnQZ1nBt0tfR0mhXym4ld5rkDebwCYguipeg/Npc3NkW9hKS9bVMdZO2wo3hatQAuw== X-Received: by 2002:a05:6000:1376:: with SMTP id q22mr272095wrz.359.1634913614727; Fri, 22 Oct 2021 07:40:14 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:f00d:ddf0:61b0:a4cd]) by smtp.gmail.com with ESMTPSA id r205sm8577878wma.3.2021.10.22.07.40.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Oct 2021 07:40:14 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Oct 2021 15:39:04 +0100 Message-Id: <20211022143907.3089419-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022143907.3089419-1-naush@raspberrypi.com> References: <20211022143907.3089419-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/6] 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 --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index a31b0f81eba7..45725527d66e 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -61,11 +61,14 @@ SensorFormats populateSensorFormats(std::unique_ptr &sensor) return formats; } -inline V4L2DeviceFormat toV4L2DeviceFormat(V4L2SubdeviceFormat &mode) +inline V4L2DeviceFormat toV4L2DeviceFormat(V4L2SubdeviceFormat &mode, bool unpacked = false) { V4L2DeviceFormat deviceFormat; BayerFormat bayer = BayerFormat::fromMbusCode(mode.mbus_code); + bayer.packing = unpacked ? BayerFormat::Packing::None + : BayerFormat::Packing::CSI2Packed; + deviceFormat.fourcc = bayer.toV4L2PixelFormat(); deviceFormat.size = mode.size; return deviceFormat; @@ -598,6 +601,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) Size maxSize, sensorSize; unsigned int maxIndex = 0; bool rawStream = false; + bool unpacked = false; /* * Look for the RAW stream (if given) size as well as the largest @@ -613,6 +617,10 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) */ sensorSize = cfg.size; rawStream = true; + /* Check if the user has explicitly set an unpacked format. */ + V4L2PixelFormat fourcc = V4L2PixelFormat::fromPixelFormat(cfg.pixelFormat); + BayerFormat bayer = BayerFormat::fromV4L2PixelFormat(fourcc); + unpacked = bayer.packing == BayerFormat::Packing::None; } else { if (cfg.size > maxSize) { maxSize = config->at(i).size; @@ -623,7 +631,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) /* First calculate the best sensor mode we can use based on the user request. */ V4L2SubdeviceFormat sensorFormat = findBestMode(data->sensorFormats_, rawStream ? sensorSize : maxSize); - V4L2DeviceFormat unicamFormat = toV4L2DeviceFormat(sensorFormat); + V4L2DeviceFormat unicamFormat = toV4L2DeviceFormat(sensorFormat, unpacked); ret = data->sensor_->setFormat(&sensorFormat); if (ret)