{"id":773,"url":"https://patchwork.libcamera.org/api/patches/773/?format=json","web_url":"https://patchwork.libcamera.org/patch/773/","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":"<20190320163055.22056-28-jacopo@jmondi.org>","date":"2019-03-20T16:30:51","name":"[libcamera-devel,v4,27/31] src: cam: Create requests with multiple streams","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"33a2e1829cfd67f1e3c62c1d5fa5de8643e2db0b","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/773/mbox/","series":[{"id":214,"url":"https://patchwork.libcamera.org/api/series/214/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=214","date":"2019-03-20T16:30:24","name":"libcamera: ipu3: Add ImgU support + multiple streams","version":4,"mbox":"https://patchwork.libcamera.org/series/214/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/773/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/773/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 04A9F611AA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Mar 2019 17:30:45 +0100 (CET)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay12.mail.gandi.net (Postfix) with ESMTPSA id 8BA2B200003;\n\tWed, 20 Mar 2019 16:30:44 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 20 Mar 2019 17:30:51 +0100","Message-Id":"<20190320163055.22056-28-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190320163055.22056-1-jacopo@jmondi.org>","References":"<20190320163055.22056-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 27/31] src: cam: Create requests with\n\tmultiple 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":"Wed, 20 Mar 2019 16:30:45 -0000"},"content":"Add support for multiple streams to request creation and enqueuing to\nthe 'capture()' method of the cam test application.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/cam/main.cpp | 28 ++++++++++++++++++----------\n 1 file changed, 18 insertions(+), 10 deletions(-)","diff":"diff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex 9257f391988b..201dbda765fe 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -144,8 +144,6 @@ static int capture()\n \t\treturn ret;\n \t}\n \n-\tStream *stream = *streams.begin();\n-\n \tret = camera->allocateBuffers();\n \tif (ret) {\n \t\tstd::cerr << \"Failed to allocate buffers\"\n@@ -153,11 +151,14 @@ static int capture()\n \t\treturn ret;\n \t}\n \n-\tcamera->requestCompleted.connect(requestComplete);\n-\n-\tBufferPool &pool = stream->bufferPool();\n-\n-\tfor (Buffer &buffer : pool.buffers()) {\n+\t/*\n+\t * Create the requests to be later enqueued.\n+\t *\n+\t * FIXME: Assume all streams have the same number of buffers: use\n+\t * the first stream's buffer pool and create on request per buffer.\n+\t */\n+\tunsigned int bufferCount = (*streams.begin())->bufferPool().count();\n+\tfor (unsigned int i = 0; i < bufferCount; ++i) {\n \t\tRequest *request = camera->createRequest();\n \t\tif (!request) {\n \t\t\tstd::cerr << \"Can't create request\" << std::endl;\n@@ -165,9 +166,14 @@ static int capture()\n \t\t\tgoto out;\n \t\t}\n \n-\t\tstd::map<Stream *, Buffer *> map;\n-\t\tmap[stream] = &buffer;\n-\t\tret = request->setBuffers(map);\n+\t\t/* Provide to each request a stream to buffer association map. */\n+\t\tstd::map<Stream *, Buffer *> requestMap;\n+\t\tfor (Stream *stream : streams) {\n+\t\t\tBuffer *buffer = &stream->bufferPool().buffers()[i];\n+\t\t\trequestMap[stream] = buffer;\n+\t\t}\n+\n+\t\tret = request->setBuffers(requestMap);\n \t\tif (ret < 0) {\n \t\t\tstd::cerr << \"Can't set buffers for request\" << std::endl;\n \t\t\tgoto out;\n@@ -176,6 +182,8 @@ static int capture()\n \t\trequests.push_back(request);\n \t}\n \n+\tcamera->requestCompleted.connect(requestComplete);\n+\n \tret = camera->start();\n \tif (ret) {\n \t\tstd::cout << \"Failed to start capture\" << std::endl;\n","prefixes":["libcamera-devel","v4","27/31"]}