From patchwork Wed Mar 20 16:30:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 770 Return-Path: Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D9826611B4 for ; Wed, 20 Mar 2019 17:30:42 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 7109E200010; Wed, 20 Mar 2019 16:30:42 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 20 Mar 2019 17:30:48 +0100 Message-Id: <20190320163055.22056-25-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 Subject: [libcamera-devel] [PATCH v4 24/31] libcamera: ipu3: Queue request for multiple streams 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: Wed, 20 Mar 2019 16:30:43 -0000 Add support for queue request on the main and secondary outputs of the ImgU. Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 46 ++++++++++++++++------------ 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index ff1e5329c83d..b2df9a4ac922 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -689,38 +689,46 @@ void PipelineHandlerIPU3::stop(Camera *camera) int PipelineHandlerIPU3::queueRequest(Camera *camera, Request *request) { + std::set streams = request->streams(); IPU3CameraData *data = cameraData(camera); V4L2Device *viewfinder = data->imgu->viewfinder; V4L2Device *output = data->imgu->output; V4L2Device *stat = data->imgu->stat; - Stream *stream = &data->streams_[0]; + ImgUDevice *imgu = data->imgu; Buffer *tmpBuffer; - /* - * Queue buffer on VF and stat. - * FIXME: this is an hack! - */ - tmpBuffer = &data->imgu->vfPool.buffers()[tmpBufferCount]; - viewfinder->queueBuffer(tmpBuffer); + for (Stream *stream : streams) { + Buffer *buffer = request->findBuffer(stream); + if (!buffer) { + LOG(IPU3, Error) << "Attempt to queue invalid request"; + return -ENOENT; + } + + V4L2Device *videoDevice = isOutput(data, stream) + ? output : viewfinder; + + int ret = videoDevice->queueBuffer(buffer); + if (ret < 0) + return ret; + + if (isOutput(data, stream) && !isViewfinderActive(data)) { + tmpBuffer = &imgu->vfPool.buffers()[tmpBufferCount]; + viewfinder->queueBuffer(tmpBuffer); + } + if (isViewfinder(data, stream) && !isOutputActive(data)) { + tmpBuffer = &imgu->outputPool.buffers()[tmpBufferCount]; + output->queueBuffer(tmpBuffer); + } + } + + /* Queue buffer on stat unconditionally. */ tmpBuffer = &data->imgu->statPool.buffers()[tmpBufferCount]; stat->queueBuffer(tmpBuffer); tmpBufferCount++; tmpBufferCount %= IPU3_IMGU_BUFFER_COUNT; - /* Queue a buffer to the ImgU output for capture. */ - Buffer *buffer = request->findBuffer(stream); - if (!buffer) { - LOG(IPU3, Error) - << "Attempt to queue request with invalid stream"; - return -ENOENT; - } - - int ret = output->queueBuffer(buffer); - if (ret < 0) - return ret; - PipelineHandler::queueRequest(camera, request); return 0;