{"id":383,"url":"https://patchwork.libcamera.org/api/patches/383/?format=json","web_url":"https://patchwork.libcamera.org/patch/383/","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":"<20190125153340.2744-5-niklas.soderlund@ragnatech.se>","date":"2019-01-25T15:33:37","name":"[libcamera-devel,v2,4/7] libcamera: pipelines: add method to configure streams","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"f35f70e74e8b079374c1958c76ac6160eed7e4ea","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":{"id":16,"url":"https://patchwork.libcamera.org/api/users/16/?format=json","username":"neg","first_name":"Niklas","last_name":"Söderlund","email":"niklas.soderlund@ragnatech.se"},"mbox":"https://patchwork.libcamera.org/patch/383/mbox/","series":[{"id":132,"url":"https://patchwork.libcamera.org/api/series/132/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=132","date":"2019-01-25T15:33:33","name":"libcamera: add basic support for Streams and format configuration","version":2,"mbox":"https://patchwork.libcamera.org/series/132/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/383/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/383/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D60EF60B21\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Jan 2019 16:33:53 +0100 (CET)","from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 9debc261-20b6-11e9-874f-005056917f90;\n\tFri, 25 Jan 2019 16:33:51 +0100 (CET)"],"X-Halon-ID":"9debc261-20b6-11e9-874f-005056917f90","Authorized-sender":"niklas@soderlund.pp.se","From":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 25 Jan 2019 16:33:37 +0100","Message-Id":"<20190125153340.2744-5-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190125153340.2744-1-niklas.soderlund@ragnatech.se>","References":"<20190125153340.2744-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 4/7] libcamera: pipelines: add method\n\tto configure streams","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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":"Fri, 25 Jan 2019 15:33:55 -0000"},"content":"All the streams which are to be used needs to be configured at the same\ntime, that is passed from the application to the pipeline handler in a\nsingle call. This would allow the pipeline handler to take any\ndependences between the different streams and there configuration into\naccount when setting up the hardware.\n\nThis implementation do not interact with any hardware, instead it\nextends all pipeline handlers with the argument validation needed to\nmake sure the configuration request is sound. It then proceeds to print\nthe requested frame dimensions to the log. Future work based on more\ncomponents are needed to make the pipeline specific implementations\ntruly useful.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/include/pipeline_handler.h |  3 +++\n src/libcamera/pipeline/ipu3/ipu3.cpp     | 21 +++++++++++++++++++++\n src/libcamera/pipeline/uvcvideo.cpp      | 24 ++++++++++++++++++++++++\n src/libcamera/pipeline/vimc.cpp          | 24 ++++++++++++++++++++++++\n src/libcamera/pipeline_handler.cpp       | 18 ++++++++++++++++++\n 5 files changed, 90 insertions(+)","diff":"diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h\nindex f92cc5b5fa5e777b..5813e00aec068356 100644\n--- a/src/libcamera/include/pipeline_handler.h\n+++ b/src/libcamera/include/pipeline_handler.h\n@@ -18,6 +18,7 @@ class CameraManager;\n class DeviceEnumerator;\n class MediaDevice;\n class Stream;\n+class StreamConfiguration;\n \n class Camera;\n class CameraData\n@@ -41,6 +42,8 @@ public:\n \n \tvirtual std::vector<Stream> streams(const Camera *camera) const = 0;\n \n+\tvirtual int configure(const Camera *camera, std::vector<StreamConfiguration *> &config) = 0;\n+\n \tvirtual bool match(DeviceEnumerator *enumerator) = 0;\n \n protected:\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 5c35c7a53b9347a3..2d790f72dc63c31b 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -30,6 +30,8 @@ public:\n \n \tstd::vector<Stream> streams(const Camera *camera) const;\n \n+\tint configure(const Camera *camera, std::vector<StreamConfiguration *> &config);\n+\n \tbool match(DeviceEnumerator *enumerator);\n \n private:\n@@ -72,6 +74,25 @@ std::vector<Stream> PipelineHandlerIPU3::streams(const Camera *camera) const\n \treturn streams;\n }\n \n+int PipelineHandlerIPU3::configure(const Camera *camera,\n+\t\t\t\t   std::vector<StreamConfiguration *> &config)\n+{\n+\tStreamConfiguration *cfg;\n+\n+\tif (config.size() != 1)\n+\t\treturn -EINVAL;\n+\n+\tcfg = config.front();\n+\n+\tif (!cfg || cfg->id() != 0)\n+\t\treturn -EINVAL;\n+\n+\tLOG(IPU3, Info) << \"TODO: Configure the camera for resolution \" <<\n+\t\tcfg->width() << \"x\" << cfg->height();\n+\n+\treturn 0;\n+}\n+\n bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator)\n {\n \tDeviceMatch cio2_dm(\"ipu3-cio2\");\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex e1f023245b8e63dd..477a9fe7f56d9a75 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -9,12 +9,15 @@\n #include <libcamera/stream.h>\n \n #include \"device_enumerator.h\"\n+#include \"log.h\"\n #include \"media_device.h\"\n #include \"pipeline_handler.h\"\n #include \"v4l2_device.h\"\n \n namespace libcamera {\n \n+LOG_DEFINE_CATEGORY(UVC)\n+\n class PipelineHandlerUVC : public PipelineHandler\n {\n public:\n@@ -23,6 +26,8 @@ public:\n \n \tstd::vector<Stream> streams(const Camera *camera) const;\n \n+\tint configure(const Camera *camera, std::vector<StreamConfiguration *> &config);\n+\n \tbool match(DeviceEnumerator *enumerator);\n \n private:\n@@ -53,6 +58,25 @@ std::vector<Stream> PipelineHandlerUVC::streams(const Camera *camera) const\n \treturn streams;\n }\n \n+int PipelineHandlerUVC::configure(const Camera *camera,\n+\t\t\t\t  std::vector<StreamConfiguration *> &config)\n+{\n+\tStreamConfiguration *cfg;\n+\n+\tif (config.size() != 1)\n+\t\treturn -EINVAL;\n+\n+\tcfg = config.front();\n+\n+\tif (!cfg || cfg->id() != 0)\n+\t\treturn -EINVAL;\n+\n+\tLOG(UVC, Info) << \"TODO: Configure the camera for resolution \" <<\n+\t\tcfg->width() << \"x\" << cfg->height();\n+\n+\treturn 0;\n+}\n+\n bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n {\n \tDeviceMatch dm(\"uvcvideo\");\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex a96ec9f431361a32..f9d3b3a604805baa 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -9,11 +9,14 @@\n #include <libcamera/stream.h>\n \n #include \"device_enumerator.h\"\n+#include \"log.h\"\n #include \"media_device.h\"\n #include \"pipeline_handler.h\"\n \n namespace libcamera {\n \n+LOG_DEFINE_CATEGORY(VIMC)\n+\n class PipeHandlerVimc : public PipelineHandler\n {\n public:\n@@ -22,6 +25,8 @@ public:\n \n \tstd::vector<Stream> streams(const Camera *camera) const;\n \n+\tint configure(const Camera *camera, std::vector<StreamConfiguration *> &config);\n+\n \tbool match(DeviceEnumerator *enumerator);\n \n private:\n@@ -48,6 +53,25 @@ std::vector<Stream> PipeHandlerVimc::streams(const Camera *camera) const\n \treturn streams;\n }\n \n+int PipeHandlerVimc::configure(const Camera *camera,\n+\t\t\t       std::vector<StreamConfiguration *> &config)\n+{\n+\tStreamConfiguration *cfg;\n+\n+\tif (config.size() != 1)\n+\t\treturn -EINVAL;\n+\n+\tcfg = config.front();\n+\n+\tif (!cfg || cfg->id() != 0)\n+\t\treturn -EINVAL;\n+\n+\tLOG(VIMC, Info) << \"TODO: Configure the camera for resolution \" <<\n+\t\tcfg->width() << \"x\" << cfg->height();\n+\n+\treturn 0;\n+}\n+\n bool PipeHandlerVimc::match(DeviceEnumerator *enumerator)\n {\n \tDeviceMatch dm(\"vimc\");\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex a825e7bf882d23c2..dc3535f105e3a992 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -96,6 +96,24 @@ PipelineHandler::~PipelineHandler()\n  *         is not part of the PipelineHandler.\n  */\n \n+/**\n+ * \\fn PipelineHandler::configure(const Camera *camera, std::vector<StreamConfiguration *> &config)\n+ * \\brief Configure a set of streams for a camera\n+ * \\param[in] camera The camera to configure streams for\n+ * \\param[in] config A array of stream configurations to try and setup\n+ *\n+ * This function is the interface to configure one or more streams of a camera\n+ * for capture. The intended user for this interface is the Camera class which\n+ * will receive the array of configurations to apply from the application.\n+ *\n+ * The caller needs to verify the StreamConfiguration objects in the passed\n+ * array after the call as it might remove one or more to satisfy hardware\n+ * limitations. The call might also alter any or all of the configuration\n+ * parameters of any stream to fit within valid operational conditions.\n+ *\n+ * \\return 0 on success or a negative error code on error.\n+ */\n+\n /**\n  * \\fn PipelineHandler::match(DeviceEnumerator *enumerator)\n  * \\brief Match media devices and create camera instances\n","prefixes":["libcamera-devel","v2","4/7"]}