From patchwork Thu Jun 25 07:28:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 4202 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 E2ACEC0100 for ; Thu, 25 Jun 2020 07:28:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 65128609A9; Thu, 25 Jun 2020 09:28:54 +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="QhtQTuVG"; 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 0DADF603BE for ; Thu, 25 Jun 2020 09:28:53 +0200 (CEST) Received: by mail-wm1-x330.google.com with SMTP id f139so4831711wmf.5 for ; Thu, 25 Jun 2020 00:28:53 -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:mime-version :content-transfer-encoding; bh=/9+07XO5x7i1vQzPIT/M3etTIBR+g5HDmLLXTTzny5g=; b=QhtQTuVG13amSd3ysYlahcd0GkoVwbD28NakLfTVTUbo5KkuhllCi6H7MK44EXDLKq WV20iTmslN88qHhyPDRuLip2p1kFEDrc6Xn3do+wU77MXmvizHcnOYvM5hwys0rK8Sk9 Na82ssnV383bvIyvqjc9XFiOpZrYS48yijuHccT5M/bQ0gXtL8+WWT7mQnU71s0dIlif zGdorKDtIOc4lTjq+5RP2/BmvOipQRxBSWeVpsn8hDljfZ17nsAEh/NP1M1092YhpL3U Q4SXrrMbPBsjYf7YP+wdJmB5U9b7Bd76e1T26UzUt7ytTOA0X7yhyeW67aY4xj7DkuTp 1UIg== 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:mime-version :content-transfer-encoding; bh=/9+07XO5x7i1vQzPIT/M3etTIBR+g5HDmLLXTTzny5g=; b=O4KqLxdQd7tFa5Eqdq2rR+Usdg74XkPkdn/KWo4VP3MC27zneD+XL2exB8H7hDlr0x iojEUi8mEyccnqKUfcBrnGDqjLbmuAXPIMNZ8l1yMxNPeVXVnlyqnGNwjbQ3057GlKHj H/9uyLylX9ixVMOTSbgqPHsJsZivE5MromoXapwNDK57/6DQ4kTHaJsqC9fw23wpkAup qGyRDorUikrwTsylrjJrwAzom1aIUokL9LeI472HCr/reF3iZUjoahbCy7NllSaCrK/2 O/RrPOGX6avv8H44q5tkN/zu1v1M50mV5/vI4hv+qOr0yhClEAqwgt0SBK7XhVHuuAQ2 aXLw== X-Gm-Message-State: AOAM533j4rWpuIsOvJEQHG4I2R8seVWis2O3xYJ0DraRFf6JD5TWblDR mpSHHF6cOUjxdC64Vf2NvTMhx5oyIyk= X-Google-Smtp-Source: ABdhPJwOwlnlfeDtzNLJ99SH94bUtWU1WkEMT+0YaHD8/8wJtqyK4xhlLpsTpYjN/jj0Zcg1Eo/I0A== X-Received: by 2002:a1c:2349:: with SMTP id j70mr1841084wmj.22.1593070132418; Thu, 25 Jun 2020 00:28:52 -0700 (PDT) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id b18sm29736184wrn.88.2020.06.25.00.28.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 00:28:51 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Thu, 25 Jun 2020 08:28:44 +0100 Message-Id: <20200625072844.1146902-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] libcamera: pipeline: raspberrypi: Add StreamFormats to StreamConfiguration 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" In generateConfiguration(), add the device node specific formats to the StreamConfiguration for each StreamRole requested. Signed-off-by: Naushir Patuck Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- .../pipeline/raspberrypi/raspberrypi.cpp | 52 +++++++++++++------ 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 60985b71..dcd737a1 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -518,41 +518,45 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera, RPiCameraData *data = cameraData(camera); CameraConfiguration *config = new RPiCameraConfiguration(data); V4L2DeviceFormat sensorFormat; + unsigned int bufferCount; + PixelFormat pixelFormat; V4L2PixFmtMap fmts; + Size size; if (roles.empty()) return config; for (const StreamRole role : roles) { - StreamConfiguration cfg{}; - switch (role) { case StreamRole::StillCaptureRaw: - cfg.size = data->sensor_->resolution(); + size = data->sensor_->resolution(); fmts = data->unicam_[Unicam::Image].dev()->formats(); - sensorFormat = findBestMode(fmts, cfg.size); - cfg.pixelFormat = sensorFormat.fourcc.toPixelFormat(); - ASSERT(cfg.pixelFormat.isValid()); - cfg.bufferCount = 1; + sensorFormat = findBestMode(fmts, size); + pixelFormat = sensorFormat.fourcc.toPixelFormat(); + ASSERT(pixelFormat.isValid()); + bufferCount = 1; break; case StreamRole::StillCapture: - cfg.pixelFormat = formats::NV12; + fmts = data->isp_[Isp::Output0].dev()->formats(); + pixelFormat = formats::NV12; /* Return the largest sensor resolution. */ - cfg.size = data->sensor_->resolution(); - cfg.bufferCount = 1; + size = data->sensor_->resolution(); + bufferCount = 1; break; case StreamRole::VideoRecording: - cfg.pixelFormat = formats::NV12; - cfg.size = { 1920, 1080 }; - cfg.bufferCount = 4; + fmts = data->isp_[Isp::Output0].dev()->formats(); + pixelFormat = formats::NV12; + size = { 1920, 1080 }; + bufferCount = 4; break; case StreamRole::Viewfinder: - cfg.pixelFormat = formats::ARGB8888; - cfg.size = { 800, 600 }; - cfg.bufferCount = 4; + fmts = data->isp_[Isp::Output0].dev()->formats(); + pixelFormat = formats::ARGB8888; + size = { 800, 600 }; + bufferCount = 4; break; default: @@ -561,6 +565,22 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera, break; } + /* Translate the V4L2PixelFormat to PixelFormat. */ + std::map> deviceFormats; + std::transform(fmts.begin(), fmts.end(), std::inserter(deviceFormats, deviceFormats.end()), + [&](const decltype(fmts)::value_type &format) { + return decltype(deviceFormats)::value_type{ + format.first.toPixelFormat(), + format.second + }; + }); + + /* Add the stream format based on the device node used for the use case. */ + StreamFormats formats(deviceFormats); + StreamConfiguration cfg(formats); + cfg.size = size; + cfg.pixelFormat = pixelFormat; + cfg.bufferCount = bufferCount; config->addConfiguration(cfg); }