From patchwork Tue Mar 12 12:12:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 722 Return-Path: Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C706C611A2 for ; Tue, 12 Mar 2019 13:12:23 +0100 (CET) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 5BE4A1C000A; Tue, 12 Mar 2019 12:12:23 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 12 Mar 2019 13:12:35 +0100 Message-Id: <20190312121242.2253-8-jacopo@jmondi.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190312121242.2253-1-jacopo@jmondi.org> References: <20190312121242.2253-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 07/14] libcamera: ipu3: Implement camera start/stop 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: Tue, 12 Mar 2019 12:12:24 -0000 Start and stop video devices in the pipeline. Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 54 ++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 3502c39f5e31..363b24ceead2 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -338,12 +338,52 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera, Stream *stream) int PipelineHandlerIPU3::start(Camera *camera) { IPU3CameraData *data = cameraData(camera); - V4L2Device *cio2 = data->cio2.output; int ret; - ret = cio2->streamOn(); + /* + * Enqueue all available buffers to the CIO2 unit to start frame + * capture. Start ImgU video devices and queue buffers to the output + * ones at queueRequest() time. + */ + for (Buffer &buffer: data->cio2.pool.buffers()) { + ret = data->cio2.output->queueBuffer(&buffer); + if (ret) + return ret; + } + + ret = data->cio2.output->streamOn(); if (ret) { - LOG(IPU3, Info) << "Failed to start camera " << camera->name(); + LOG(IPU3, Error) << "Failed to start CIO2"; + stop(camera); + return ret; + } + + /* Start the ImgU video devices. */ + ret = data->imgu->output->streamOn(); + if (ret) { + LOG(IPU3, Error) << "Failed to start ImgU output"; + stop(camera); + return ret; + } + + ret = data->imgu->viewfinder->streamOn(); + if (ret) { + LOG(IPU3, Error) << "Failed to start ImgU viewfinder"; + stop(camera); + return ret; + } + + ret = data->imgu->stat->streamOn(); + if (ret) { + LOG(IPU3, Error) << "Failed to start ImgU stat"; + stop(camera); + return ret; + } + + ret = data->imgu->input->streamOn(); + if (ret) { + LOG(IPU3, Error) << "Failed to start ImgU input"; + stop(camera); return ret; } @@ -353,10 +393,12 @@ int PipelineHandlerIPU3::start(Camera *camera) void PipelineHandlerIPU3::stop(Camera *camera) { IPU3CameraData *data = cameraData(camera); - V4L2Device *cio2 = data->cio2.output; - if (cio2->streamOff()) - LOG(IPU3, Info) << "Failed to stop camera " << camera->name(); + data->cio2.output->streamOff(); + data->imgu->output->streamOff(); + data->imgu->viewfinder->streamOff(); + data->imgu->stat->streamOff(); + data->imgu->input->streamOff(); PipelineHandler::stop(camera); }