{"id":15899,"url":"https://patchwork.libcamera.org/api/1.1/patches/15899/?format=json","web_url":"https://patchwork.libcamera.org/patch/15899/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20220512103258.324339-4-chenghaoyang@google.com>","date":"2022-05-12T10:32:53","name":"[libcamera-devel,3/8] Use imgu0 as default","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ae07b2c32f69073134608a1198d8e5ae88d4b3f2","submitter":{"id":117,"url":"https://patchwork.libcamera.org/api/1.1/people/117/?format=json","name":"Cheng-Hao Yang","email":"chenghaoyang@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15899/mbox/","series":[{"id":3111,"url":"https://patchwork.libcamera.org/api/1.1/series/3111/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3111","date":"2022-05-12T10:32:50","name":"Use two imgus in ipu3 pipeline handler","version":1,"mbox":"https://patchwork.libcamera.org/series/3111/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15899/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15899/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BB9D7C3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 12 May 2022 10:33:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 746F365666;\n\tThu, 12 May 2022 12:33:11 +0200 (CEST)","from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com\n\t[IPv6:2607:f8b0:4864:20::1030])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0958565641\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 May 2022 12:33:09 +0200 (CEST)","by mail-pj1-x1030.google.com with SMTP id\n\tcq17-20020a17090af99100b001dc0386cd8fso4485950pjb.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 May 2022 03:33:08 -0700 (PDT)","from chenghaoyang-low.c.googlers.com.com\n\t(174.71.80.34.bc.googleusercontent.com. [34.80.71.174])\n\tby smtp.gmail.com with ESMTPSA id\n\tt19-20020a62d153000000b005087c23ad8dsm3402219pfl.0.2022.05.12.03.33.06\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 12 May 2022 03:33:07 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652351591;\n\tbh=SA3x853iYpMjSAV0dBy2JefOlLjk94LRbL2O21yu0Pk=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=PH/PFHzt/aBv10FlLU21dWLNsKFbMMP/vbAlg5umXyGdPUyTVz41hnERjogjxYlun\n\t9qT3rzTvqOWsJCZRIEwNA3QVxsJUD6EviUkoPb8ays1jt+ECtt6Zv8bqrdHAJQhnjQ\n\tSl53S8hZFHnK1T44IGeTdz7lGwuzCL8vwelJsDNyX/yYXjzHCNK4o5mEsUIsP0RveY\n\tBYzgpXtchUtJzdI9MpIu/MSc2E042IMVmiIlJh2PbNczqjqSbjb5ExODRAjzUoAb9j\n\tGVxr+3+VR+uyg2XbqidjLlhSasr7gM/Mk+IZrkXvoYcV9DthYTnKfnLLhvf0rUxHy1\n\tHgSbeDyRZqz+w==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=FRUFoZcbRLEU/0iUZWg2v4aaKCgp6exIn71fmvTYPjo=;\n\tb=ERpRvZRn9T0aXB10zYvarDICsSo1m/LoGxoBUg2lannqbNbYyUPSzMn+P7Gh1pW5FU\n\t5YnqV0QjtlA2VXUG6mIBN77j38cg5zlYYV8TYWJCC/W3Xdpxjk01JsXJwyTSW8duhSjn\n\t7+azrN5X6FYhB/4b6lMAei8B4hxOADTVIyQqg="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"ERpRvZRn\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=FRUFoZcbRLEU/0iUZWg2v4aaKCgp6exIn71fmvTYPjo=;\n\tb=C7Vukp+QPymOWXWe2d4B0USqNqmtq2k0RqxN6VZhc0eeh5ne2bMF9n/mhYn+5ML5ai\n\tYw5rKFIZY6Q18MJpSy2zWN/eaLPvFsy0W6Al26UHSPx3y8dySRee8ykLl61ri62VwZZe\n\tyw5SJScQQgO+Ytwt+KWPTdcFZjbaF+ekZKtogb2JqjdQa8jqDnQ97MPA/3uA0xkFq+Hz\n\tEasONeM+277wF2V6ayV8MPDRhotD+0bLC5gKQ2NSvTHhtMLV8lNds2DpQL+wMQMhyjSH\n\t77VB8A3TY8pjMlqNiRppKgbhJtB/IF6vh+/vGmAA21/jMs4lL0CrTzwGTmGCRtPgbgVn\n\t3/rA==","X-Gm-Message-State":"AOAM533DN1/qkorSSH1jy1RmkCrBMUEoii2CPOK70oXJI5j5CB368TMw\n\tXgdT6foJTjXy0efdJu7A+C3WQFs7fWn4hrXp","X-Google-Smtp-Source":"ABdhPJzY1JliQZVM28CzphxbiJPzopK0YxUiK6wJkrpPJT4KsrLzbfZLgvRqW95DObfi/sQ6+OrcOQ==","X-Received":"by 2002:a17:902:db05:b0:15e:d003:54f2 with SMTP id\n\tm5-20020a170902db0500b0015ed00354f2mr29376098plx.103.1652351588086; \n\tThu, 12 May 2022 03:33:08 -0700 (PDT)","X-Google-Original-From":"Harvey Yang <chenghaoyang@google.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 12 May 2022 10:32:53 +0000","Message-Id":"<20220512103258.324339-4-chenghaoyang@google.com>","X-Mailer":"git-send-email 2.36.0.512.ge40c2bad7a-goog","In-Reply-To":"<20220512103258.324339-1-chenghaoyang@google.com>","References":"<20220512103258.324339-1-chenghaoyang@google.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 3/8] Use imgu0 as default","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>","From":"Harvey Yang via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Harvey Yang <chenghaoyang@chromium.org>","Cc":"Harvey Yang <chenghaoyang@chromium.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Harvey Yang <chenghaoyang@chromium.org>\n\nWith only one camera being started, we can always use imgu0 to process\nframes (for video/preview). In the following patches, we'll use imgu1\nfor still capture if needed.\n\nSigned-off-by: Harvey Yang <chenghaoyang@chromium.org>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 86 ++++++++++++++++------------\n 1 file changed, 48 insertions(+), 38 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 111ba053..5dd13c41 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -64,7 +64,8 @@ public:\n \tvoid frameStart(uint32_t sequence);\n \n \tCIO2Device cio2_;\n-\tImgUDevice *imgu_;\n+\tImgUDevice *imgu0_;\n+\tImgUDevice *imgu1_;\n \n \tStream outStream_;\n \tStream vfStream_;\n@@ -406,7 +407,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()\n \n \t/* Only compute the ImgU configuration if a YUV stream has been requested. */\n \tif (yuvCount) {\n-\t\tpipeConfig_ = data_->imgu_->calculatePipeConfig(&pipe);\n+\t\tpipeConfig_ = data_->imgu0_->calculatePipeConfig(&pipe);\n \t\tif (pipeConfig_.isNull()) {\n \t\t\tLOG(IPU3, Error) << \"Failed to calculate pipe configuration: \"\n \t\t\t\t\t << \"unsupported resolutions.\";\n@@ -518,7 +519,6 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n \tStream *outStream = &data->outStream_;\n \tStream *vfStream = &data->vfStream_;\n \tCIO2Device *cio2 = &data->cio2_;\n-\tImgUDevice *imgu = data->imgu_;\n \tV4L2DeviceFormat outputFormat;\n \tint ret;\n \n@@ -560,7 +560,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n \t * stream which is for raw capture, in which case no buffers will\n \t * ever be queued to the ImgU.\n \t */\n-\tret = data->imgu_->enableLinks(true);\n+\tret = imgu0_.enableLinks(true);\n \tif (ret)\n \t\treturn ret;\n \n@@ -610,7 +610,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n \tif (imguConfig.isNull())\n \t\treturn 0;\n \n-\tret = imgu->configure(imguConfig, &cio2Format);\n+\tret = imgu0_.configure(imguConfig, &cio2Format);\n \tif (ret)\n \t\treturn ret;\n \n@@ -624,12 +624,12 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n \n \t\tif (stream == outStream) {\n \t\t\tmainCfg = &cfg;\n-\t\t\tret = imgu->configureOutput(cfg, &outputFormat);\n+\t\t\tret = imgu0_.configureOutput(cfg, &outputFormat);\n \t\t\tif (ret)\n \t\t\t\treturn ret;\n \t\t} else if (stream == vfStream) {\n \t\t\tvfCfg = &cfg;\n-\t\t\tret = imgu->configureViewfinder(cfg, &outputFormat);\n+\t\t\tret = imgu0_.configureViewfinder(cfg, &outputFormat);\n \t\t\tif (ret)\n \t\t\t\treturn ret;\n \t\t}\n@@ -641,13 +641,13 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n \t * be at least one active stream in the configuration request).\n \t */\n \tif (!vfCfg) {\n-\t\tret = imgu->configureViewfinder(*mainCfg, &outputFormat);\n+\t\tret = imgu0_.configureViewfinder(*mainCfg, &outputFormat);\n \t\tif (ret)\n \t\t\treturn ret;\n \t}\n \n \t/* Apply the \"pipe_mode\" control to the ImgU subdevice. */\n-\tControlList ctrls(imgu->imgu_->controls());\n+\tControlList ctrls(imgu0_.imgu_->controls());\n \t/*\n \t * Set the ImgU pipe mode to 'Video' unconditionally to have statistics\n \t * generated.\n@@ -657,7 +657,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)\n \t */\n \tctrls.set(V4L2_CID_IPU3_PIPE_MODE,\n \t\t  static_cast<int32_t>(IPU3PipeModeVideo));\n-\tret = imgu->imgu_->setControls(&ctrls);\n+\tret = imgu0_.imgu_->setControls(&ctrls);\n \tif (ret) {\n \t\tLOG(IPU3, Error) << \"Unable to set pipe_mode control\";\n \t\treturn ret;\n@@ -691,9 +691,9 @@ int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream,\n \tunsigned int count = stream->configuration().bufferCount;\n \n \tif (stream == &data->outStream_)\n-\t\treturn data->imgu_->output_->exportBuffers(count, buffers);\n+\t\treturn imgu0_.output_->exportBuffers(count, buffers);\n \telse if (stream == &data->vfStream_)\n-\t\treturn data->imgu_->viewfinder_->exportBuffers(count, buffers);\n+\t\treturn imgu0_.viewfinder_->exportBuffers(count, buffers);\n \telse if (stream == &data->rawStream_)\n \t\treturn data->cio2_.exportBuffers(count, buffers);\n \n@@ -711,7 +711,6 @@ int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream,\n int PipelineHandlerIPU3::allocateBuffers(Camera *camera)\n {\n \tIPU3CameraData *data = cameraData(camera);\n-\tImgUDevice *imgu = data->imgu_;\n \tunsigned int bufferCount;\n \tint ret;\n \n@@ -721,26 +720,26 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera)\n \t\tdata->rawStream_.configuration().bufferCount,\n \t});\n \n-\tret = imgu->allocateBuffers(bufferCount);\n+\tret = imgu0_.allocateBuffers(bufferCount);\n \tif (ret < 0)\n \t\treturn ret;\n \n \t/* Map buffers to the IPA. */\n \tunsigned int ipaBufferId = 1;\n \n-\tfor (const std::unique_ptr<FrameBuffer> &buffer : imgu->paramBuffers_) {\n+\tfor (const std::unique_ptr<FrameBuffer> &buffer : imgu0_.paramBuffers_) {\n \t\tbuffer->setCookie(ipaBufferId++);\n \t\tipaBuffers_.emplace_back(buffer->cookie(), buffer->planes());\n \t}\n \n-\tfor (const std::unique_ptr<FrameBuffer> &buffer : imgu->statBuffers_) {\n+\tfor (const std::unique_ptr<FrameBuffer> &buffer : imgu0_.statBuffers_) {\n \t\tbuffer->setCookie(ipaBufferId++);\n \t\tipaBuffers_.emplace_back(buffer->cookie(), buffer->planes());\n \t}\n \n \tdata->ipa_->mapBuffers(ipaBuffers_);\n \n-\tdata->frameInfos_.init(imgu->paramBuffers_, imgu->statBuffers_);\n+\tdata->frameInfos_.init(imgu0_.paramBuffers_, imgu0_.statBuffers_);\n \tdata->frameInfos_.bufferAvailable.connect(\n \t\tdata, &IPU3CameraData::queuePendingRequests);\n \n@@ -760,7 +759,7 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera)\n \tdata->ipa_->unmapBuffers(ids);\n \tipaBuffers_.clear();\n \n-\tdata->imgu_->freeBuffers();\n+\timgu0_.freeBuffers();\n \n \treturn 0;\n }\n@@ -773,9 +772,18 @@ int PipelineHandlerIPU3::start(Camera *camera, [[maybe_unused]] const ControlLis\n \n \tIPU3CameraData *data = cameraData(camera);\n \tCIO2Device *cio2 = &data->cio2_;\n-\tImgUDevice *imgu = data->imgu_;\n \tint ret;\n \n+\timgu0_.input_->bufferReady.connect(&data->cio2_,\n+\t\t\t\t\t   &CIO2Device::tryReturnBuffer);\n+\timgu0_.output_->bufferReady.connect(data,\n+\t\t\t\t\t    &IPU3CameraData::imguOutputBufferReady);\n+\timgu0_.viewfinder_->bufferReady.connect(data,\n+\t\t\t\t\t\t&IPU3CameraData::imguOutputBufferReady);\n+\timgu0_.param_->bufferReady.connect(data,\n+\t\t\t\t\t   &IPU3CameraData::paramBufferReady);\n+\timgu0_.stat_->bufferReady.connect(data,\n+\t\t\t\t\t  &IPU3CameraData::statBufferReady);\n \t/* Disable test pattern mode on the sensor, if any. */\n \tret = cio2->sensor()->setTestPatternMode(\n \t\tcontrols::draft::TestPatternModeEnum::TestPatternModeOff);\n@@ -803,19 +811,24 @@ int PipelineHandlerIPU3::start(Camera *camera, [[maybe_unused]] const ControlLis\n \tif (ret)\n \t\tgoto error;\n \n-\tret = imgu->start();\n+\tret = imgu0_.start();\n \tif (ret)\n \t\tgoto error;\n \n \treturn 0;\n \n error:\n-\timgu->stop();\n+\timgu0_.stop();\n \tcio2->stop();\n \tdata->ipa_->stop();\n \tfreeBuffers(camera);\n \tLOG(IPU3, Error) << \"Failed to start camera \" << camera->id();\n \n+\timgu0_.input_->bufferReady.disconnect();\n+\timgu0_.output_->bufferReady.disconnect();\n+\timgu0_.viewfinder_->bufferReady.disconnect();\n+\timgu0_.param_->bufferReady.disconnect();\n+\timgu0_.stat_->bufferReady.disconnect();\n \tinUseCamera_ = nullptr;\n \n \treturn ret;\n@@ -830,13 +843,19 @@ void PipelineHandlerIPU3::stopDevice(Camera *camera)\n \n \tdata->ipa_->stop();\n \n-\tret |= data->imgu_->stop();\n+\tret |= imgu0_.stop();\n \tret |= data->cio2_.stop();\n \tif (ret)\n \t\tLOG(IPU3, Warning) << \"Failed to stop camera \" << camera->id();\n \n \tfreeBuffers(camera);\n \n+\tdata->imgu0_->input_->bufferReady.disconnect();\n+\tdata->imgu0_->output_->bufferReady.disconnect();\n+\tdata->imgu0_->viewfinder_->bufferReady.disconnect();\n+\tdata->imgu0_->param_->bufferReady.disconnect();\n+\tdata->imgu0_->stat_->bufferReady.disconnect();\n+\n \tinUseCamera_ = nullptr;\n }\n \n@@ -1180,7 +1199,8 @@ int PipelineHandlerIPU3::registerCameras()\n \t\t * only, and assign imgu0 to the first one and imgu1 to the\n \t\t * second.\n \t\t */\n-\t\tdata->imgu_ = numCameras ? &imgu1_ : &imgu0_;\n+\t\tdata->imgu0_ = &imgu0_;\n+\t\tdata->imgu1_ = &imgu1_;\n \n \t\t/*\n \t\t * Connect video devices' 'bufferReady' signals to their\n@@ -1194,16 +1214,6 @@ int PipelineHandlerIPU3::registerCameras()\n \t\t\t\t\t&IPU3CameraData::cio2BufferReady);\n \t\tdata->cio2_.bufferAvailable.connect(\n \t\t\tdata.get(), &IPU3CameraData::queuePendingRequests);\n-\t\tdata->imgu_->input_->bufferReady.connect(&data->cio2_,\n-\t\t\t\t\t&CIO2Device::tryReturnBuffer);\n-\t\tdata->imgu_->output_->bufferReady.connect(data.get(),\n-\t\t\t\t\t&IPU3CameraData::imguOutputBufferReady);\n-\t\tdata->imgu_->viewfinder_->bufferReady.connect(data.get(),\n-\t\t\t\t\t&IPU3CameraData::imguOutputBufferReady);\n-\t\tdata->imgu_->param_->bufferReady.connect(data.get(),\n-\t\t\t\t\t&IPU3CameraData::paramBufferReady);\n-\t\tdata->imgu_->stat_->bufferReady.connect(data.get(),\n-\t\t\t\t\t&IPU3CameraData::statBufferReady);\n \n \t\t/* Create and register the Camera instance. */\n \t\tconst std::string &cameraId = cio2->sensor()->id();\n@@ -1296,14 +1306,14 @@ void IPU3CameraData::paramsBufferReady(unsigned int id)\n \t\tFrameBuffer *outbuffer = it.second;\n \n \t\tif (stream == &outStream_)\n-\t\t\timgu_->output_->queueBuffer(outbuffer);\n+\t\t\timgu0_->output_->queueBuffer(outbuffer);\n \t\telse if (stream == &vfStream_)\n-\t\t\timgu_->viewfinder_->queueBuffer(outbuffer);\n+\t\t\timgu0_->viewfinder_->queueBuffer(outbuffer);\n \t}\n \n-\timgu_->param_->queueBuffer(info->paramBuffer);\n-\timgu_->stat_->queueBuffer(info->statBuffer);\n-\timgu_->input_->queueBuffer(info->rawBuffer);\n+\timgu0_->param_->queueBuffer(info->paramBuffer);\n+\timgu0_->stat_->queueBuffer(info->statBuffer);\n+\timgu0_->input_->queueBuffer(info->rawBuffer);\n }\n \n void IPU3CameraData::metadataReady(unsigned int id, const ControlList &metadata)\n","prefixes":["libcamera-devel","3/8"]}