From patchwork Wed Jun 10 14:26:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 4016 Return-Path: Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D47DF600F7 for ; Wed, 10 Jun 2020 16:26:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="UNr6oRvB"; dkim-atps=neutral Received: by mail-wr1-x42f.google.com with SMTP id p5so2495786wrw.9 for ; Wed, 10 Jun 2020 07:26:45 -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=Pwg8bO9p1XKqbok530z9bwGhc9mgrACMnhH7k+oIGJ4=; b=UNr6oRvBPUvfh1dSLUqrnp5zanPB2JboR21HfpL08Dyur/aMDvoMpxurXr/HZ53S8E NbYmJo8Q/a9v43WUo7WIjKqtzWTiK0+/Uucd63vRORFzAaDc2McDY3XRd9zdzXytStVY oz48HNnZhun5cMNFfUC89ANq7SqX9wIWoTulv38QWLrKLXJWQPgriSE8qZjiU6XDd0YX MgWaY7KIba7EwzuwjuJsshvUI0TT8sMfpSzigLE5kF4mWFGPMhcKjW2R4GuC0ajgifou /M8fGAFeKtXK+weRCq4GziXQJjY851vQnWNJeWfniy933uUw/87eT3vbC0fF+jREkfG8 VH1w== 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=Pwg8bO9p1XKqbok530z9bwGhc9mgrACMnhH7k+oIGJ4=; b=HXvhC9k5Hi1ivS5mvBS0AouBdFVwi79EixIZSSdlfBBBBY5tMdBkoTg0rbPHVpoZsY VMZ9tSKousuF+kD0MAxrmQWwKIIA9kT5HRah+zcH8bVdu9B65WWwSy1HV17PDB95KG5o 2gLjFXRBv8IfsGf/YydReoKQ9IiTTsvWGThl7q6jGr1OwUVfJ/pnj7GUVONK0XfcgXdb AcHsE1gy9DTC1IYjSVaUGaAXaXfclvUvEP6CiAisgz9khbV4y5pLGz50gB6f2BFHpQZV r30EtPqtTACC9bWL3/ItDhry5cHshhswuV+vx/nt6IWuvY8X+JrtWJhokIfwufNMsHxa 0RZA== X-Gm-Message-State: AOAM533Yut8dYeEsiQl2U+UT3s9RxPWtXV3niizo7j66DsjE4dRyAOwU p37xeZkMV5rHSNyzm5BB5LjmlttISAs= X-Google-Smtp-Source: ABdhPJzGHEzHYVVUucb7lg07KSiaXkb4GMA4ro3wSgaOTGmFJqRjhnC/SMF8sMGEPcAlNn5nfFgH8Q== X-Received: by 2002:adf:a157:: with SMTP id r23mr4247219wrr.92.1591799204903; Wed, 10 Jun 2020 07:26:44 -0700 (PDT) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id c143sm7551724wmd.1.2020.06.10.07.26.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2020 07:26:44 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 10 Jun 2020 15:26:40 +0100 Message-Id: <20200610142640.576529-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] 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: , X-List-Received-Date: Wed, 10 Jun 2020 14:26:46 -0000 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 --- .../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 e16a9c7f..03a1e641 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 = PixelFormat(DRM_FORMAT_NV12); + fmts = data->isp_[Isp::Output0].dev()->formats(); + pixelFormat = PixelFormat(DRM_FORMAT_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 = PixelFormat(DRM_FORMAT_NV12); - cfg.size = { 1920, 1080 }; - cfg.bufferCount = 4; + fmts = data->isp_[Isp::Output0].dev()->formats(); + pixelFormat = PixelFormat(DRM_FORMAT_NV12); + size = { 1920, 1080 }; + bufferCount = 4; break; case StreamRole::Viewfinder: - cfg.pixelFormat = PixelFormat(DRM_FORMAT_ARGB8888); - cfg.size = { 800, 600 }; - cfg.bufferCount = 4; + fmts = data->isp_[Isp::Output0].dev()->formats(); + pixelFormat = PixelFormat(DRM_FORMAT_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.begin()), + [&](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); }