From patchwork Mon Jun 10 16:40:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 1386 Return-Path: Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AF198635E2 for ; Mon, 10 Jun 2019 18:39:48 +0200 (CEST) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 47BBF240008; Mon, 10 Jun 2019 16:39:48 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 10 Jun 2019 18:40:51 +0200 Message-Id: <20190610164052.30741-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190610164052.30741-1-jacopo@jmondi.org> References: <20190610164052.30741-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/6] libcamera: ipu3: Set pipe_mode based on stream configuration X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jun 2019 16:39:49 -0000 Set the ImgU pipe_mode control based on the active stream configuration. Use 'Video' pipe mode unless the viewfinder stream is not active. Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 05005c42106b..b3e7fb0e9c64 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -22,6 +22,7 @@ #include "media_device.h" #include "pipeline_handler.h" #include "utils.h" +#include "v4l2_controls.h" #include "v4l2_device.h" #include "v4l2_subdevice.h" @@ -29,6 +30,8 @@ namespace libcamera { LOG_DEFINE_CATEGORY(IPU3) +#define IPU3_PIPE_MODE_CTRL 0x009819c1 + class ImgUDevice { public: @@ -536,6 +539,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) * the configuration of the active one for that purpose (there should * be at least one active stream in the configuration request). */ + unsigned int pipeMode = 0; if (!outStream->active_) { ret = imgu->configureOutput(outStream->device_, config->at(0)); if (ret) @@ -546,6 +550,12 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) ret = imgu->configureOutput(vfStream->device_, config->at(0)); if (ret) return ret; + + /* + * \todo: This works as long as only two concurrent streams + * per pipe are supported. + */ + pipeMode = 1; } /* @@ -559,6 +569,25 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) if (ret) return ret; + /* Apply the "pipe_mode" control to the ImgU subdevice. */ + V4L2Controls ctrls; + ctrls.set(IPU3_PIPE_MODE_CTRL, pipeMode); + ret = imgu->imgu_->setControls(ctrls); + if (ret) { + LOG(IPU3, Error) << "Unable to set pipe_mode control"; + return ret; + } + + std::vector ctrlId = { IPU3_PIPE_MODE_CTRL, }; + ret = imgu->imgu_->getControls(ctrlId, &ctrls); + if (ret) { + LOG(IPU3, Error) << "Unable to get pipe_mode control value"; + return ret; + } + + pipeMode = ctrls.getInt(IPU3_PIPE_MODE_CTRL); + LOG(IPU3, Debug) << "ImgU pipe mode set to: " + << (pipeMode ? "'Still Capture'" : "'Video'"); return 0; }