{"id":4016,"url":"https://patchwork.libcamera.org/api/patches/4016/?format=json","web_url":"https://patchwork.libcamera.org/patch/4016/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200610142640.576529-1-naush@raspberrypi.com>","date":"2020-06-10T14:26:40","name":"[libcamera-devel] libcamera: pipeline: raspberrypi: Add StreamFormats to StreamConfiguration","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"c1e0ca3538a0c877957bbe2ff8a288372fd719a9","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/4016/mbox/","series":[{"id":985,"url":"https://patchwork.libcamera.org/api/series/985/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=985","date":"2020-06-10T14:26:40","name":"[libcamera-devel] libcamera: pipeline: raspberrypi: Add StreamFormats to StreamConfiguration","version":1,"mbox":"https://patchwork.libcamera.org/series/985/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/4016/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/4016/checks/","tags":{},"headers":{"Return-Path":"<naush@raspberrypi.com>","Received":["from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com\n\t[IPv6:2a00:1450:4864:20::42f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D47DF600F7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Jun 2020 16:26:45 +0200 (CEST)","by mail-wr1-x42f.google.com with SMTP id p5so2495786wrw.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Jun 2020 07:26:45 -0700 (PDT)","from naushir-VirtualBox.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\tc143sm7551724wmd.1.2020.06.10.07.26.44\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 10 Jun 2020 07:26:44 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"UNr6oRvB\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=Pwg8bO9p1XKqbok530z9bwGhc9mgrACMnhH7k+oIGJ4=;\n\tb=UNr6oRvBPUvfh1dSLUqrnp5zanPB2JboR21HfpL08Dyur/aMDvoMpxurXr/HZ53S8E\n\tNbYmJo8Q/a9v43WUo7WIjKqtzWTiK0+/Uucd63vRORFzAaDc2McDY3XRd9zdzXytStVY\n\toz48HNnZhun5cMNFfUC89ANq7SqX9wIWoTulv38QWLrKLXJWQPgriSE8qZjiU6XDd0YX\n\tMgWaY7KIba7EwzuwjuJsshvUI0TT8sMfpSzigLE5kF4mWFGPMhcKjW2R4GuC0ajgifou\n\t/M8fGAFeKtXK+weRCq4GziXQJjY851vQnWNJeWfniy933uUw/87eT3vbC0fF+jREkfG8\n\tVH1w==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=Pwg8bO9p1XKqbok530z9bwGhc9mgrACMnhH7k+oIGJ4=;\n\tb=HXvhC9k5Hi1ivS5mvBS0AouBdFVwi79EixIZSSdlfBBBBY5tMdBkoTg0rbPHVpoZsY\n\tVMZ9tSKousuF+kD0MAxrmQWwKIIA9kT5HRah+zcH8bVdu9B65WWwSy1HV17PDB95KG5o\n\t2gLjFXRBv8IfsGf/YydReoKQ9IiTTsvWGThl7q6jGr1OwUVfJ/pnj7GUVONK0XfcgXdb\n\tAcHsE1gy9DTC1IYjSVaUGaAXaXfclvUvEP6CiAisgz9khbV4y5pLGz50gB6f2BFHpQZV\n\tr30EtPqtTACC9bWL3/ItDhry5cHshhswuV+vx/nt6IWuvY8X+JrtWJhokIfwufNMsHxa\n\t0RZA==","X-Gm-Message-State":"AOAM533Yut8dYeEsiQl2U+UT3s9RxPWtXV3niizo7j66DsjE4dRyAOwU\n\tp37xeZkMV5rHSNyzm5BB5LjmlttISAs=","X-Google-Smtp-Source":"ABdhPJzGHEzHYVVUucb7lg07KSiaXkb4GMA4ro3wSgaOTGmFJqRjhnC/SMF8sMGEPcAlNn5nfFgH8Q==","X-Received":"by 2002:adf:a157:: with SMTP id r23mr4247219wrr.92.1591799204903;\n\tWed, 10 Jun 2020 07:26:44 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] libcamera: pipeline: raspberrypi: Add\n\tStreamFormats to StreamConfiguration","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Wed, 10 Jun 2020 14:26:46 -0000"},"content":"In generateConfiguration(), add the device node specific formats to the\nStreamConfiguration for each StreamRole requested.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 52 +++++++++++++------\n 1 file changed, 36 insertions(+), 16 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex e16a9c7f..03a1e641 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -518,41 +518,45 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n \tRPiCameraData *data = cameraData(camera);\n \tCameraConfiguration *config = new RPiCameraConfiguration(data);\n \tV4L2DeviceFormat sensorFormat;\n+\tunsigned int bufferCount;\n+\tPixelFormat pixelFormat;\n \tV4L2PixFmtMap fmts;\n+\tSize size;\n \n \tif (roles.empty())\n \t\treturn config;\n \n \tfor (const StreamRole role : roles) {\n-\t\tStreamConfiguration cfg{};\n-\n \t\tswitch (role) {\n \t\tcase StreamRole::StillCaptureRaw:\n-\t\t\tcfg.size = data->sensor_->resolution();\n+\t\t\tsize = data->sensor_->resolution();\n \t\t\tfmts = data->unicam_[Unicam::Image].dev()->formats();\n-\t\t\tsensorFormat = findBestMode(fmts, cfg.size);\n-\t\t\tcfg.pixelFormat = sensorFormat.fourcc.toPixelFormat();\n-\t\t\tASSERT(cfg.pixelFormat.isValid());\n-\t\t\tcfg.bufferCount = 1;\n+\t\t\tsensorFormat = findBestMode(fmts, size);\n+\t\t\tpixelFormat = sensorFormat.fourcc.toPixelFormat();\n+\t\t\tASSERT(pixelFormat.isValid());\n+\t\t\tbufferCount = 1;\n \t\t\tbreak;\n \n \t\tcase StreamRole::StillCapture:\n-\t\t\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12);\n+\t\t\tfmts = data->isp_[Isp::Output0].dev()->formats();\n+\t\t\tpixelFormat = PixelFormat(DRM_FORMAT_NV12);\n \t\t\t/* Return the largest sensor resolution. */\n-\t\t\tcfg.size = data->sensor_->resolution();\n-\t\t\tcfg.bufferCount = 1;\n+\t\t\tsize = data->sensor_->resolution();\n+\t\t\tbufferCount = 1;\n \t\t\tbreak;\n \n \t\tcase StreamRole::VideoRecording:\n-\t\t\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_NV12);\n-\t\t\tcfg.size = { 1920, 1080 };\n-\t\t\tcfg.bufferCount = 4;\n+\t\t\tfmts = data->isp_[Isp::Output0].dev()->formats();\n+\t\t\tpixelFormat = PixelFormat(DRM_FORMAT_NV12);\n+\t\t\tsize = { 1920, 1080 };\n+\t\t\tbufferCount = 4;\n \t\t\tbreak;\n \n \t\tcase StreamRole::Viewfinder:\n-\t\t\tcfg.pixelFormat = PixelFormat(DRM_FORMAT_ARGB8888);\n-\t\t\tcfg.size = { 800, 600 };\n-\t\t\tcfg.bufferCount = 4;\n+\t\t\tfmts = data->isp_[Isp::Output0].dev()->formats();\n+\t\t\tpixelFormat = PixelFormat(DRM_FORMAT_ARGB8888);\n+\t\t\tsize = { 800, 600 };\n+\t\t\tbufferCount = 4;\n \t\t\tbreak;\n \n \t\tdefault:\n@@ -561,6 +565,22 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n \t\t\tbreak;\n \t\t}\n \n+\t\t/* Translate the V4L2PixelFormat to PixelFormat. */\n+\t\tstd::map<PixelFormat, std::vector<SizeRange>> deviceFormats;\n+\t\tstd::transform(fmts.begin(), fmts.end(), std::inserter(deviceFormats, deviceFormats.begin()),\n+\t\t\t       [&](const decltype(fmts)::value_type &format) {\n+\t\t\t\t\treturn decltype(deviceFormats)::value_type{\n+\t\t\t\t\t\tformat.first.toPixelFormat(),\n+\t\t\t\t\t\tformat.second\n+\t\t\t\t\t};\n+\t\t\t       });\n+\n+\t\t/* Add the stream format based on the device node used for the use case. */\n+\t\tStreamFormats formats(deviceFormats);\n+\t\tStreamConfiguration cfg(formats);\n+\t\tcfg.size = size;\n+\t\tcfg.pixelFormat = pixelFormat;\n+\t\tcfg.bufferCount = bufferCount;\n \t\tconfig->addConfiguration(cfg);\n \t}\n \n","prefixes":["libcamera-devel"]}