From patchwork Mon Jul 13 13:24:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8766 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4BC31BDB1C for ; Mon, 13 Jul 2020 13:25:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1247B60740; Mon, 13 Jul 2020 15:25:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="eckvXv51"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3A46260732 for ; Mon, 13 Jul 2020 15:24:58 +0200 (CEST) Received: from Q.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CA629C9; Mon, 13 Jul 2020 15:24:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1594646698; bh=pSoAy4XI4XXV/bNdip7z3VsfLMgi8XQoYm696m9AJb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eckvXv51zqla1ZExBiNPbMnbNeCYNBETPwWflum1cTeUEl7TXNWPPKEQy4+dVTyCx rV3RhqqXB6C/nhjkC2btuKTYsIZ7w3RVyj3+LtyzgkJm29F5U0xsVU1LARul6XDSSX sXxwL9SK1655rM6cKnaykqJ/2Q9QNtrI+3VZOh3k= From: Kieran Bingham To: libcamera devel Date: Mon, 13 Jul 2020 14:24:47 +0100 Message-Id: <20200713132451.2944673-6-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713132451.2944673-1-kieran.bingham@ideasonboard.com> References: <20200713132451.2944673-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/9] libcamera: pipeline: vivid: Configure the device X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Ward Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When the configurations have been generated and validated, they can be applied to a device. Vivid supports only a single stream, so it directly obtains the first StreamConfiguration from the CameraConfiguration. The VIVID catpure device is a V4L2Video device, so we generate a V4L2DeviceFormat to apply directly to the capture device node. Note that we explicitly convert the libcamera Format stored in cfg.pixelFormat to a V4L2PixelFormat using the helpers provided by the V4L2VideoDevice to ensure that any multiplanar formats are handled correctly and accordingly. Following the call to set the format using the Kernel API, if the format has been adjusted in any way by the kernel driver, then we have failed to correctly handle the validation stages, and thus the configure operation is idendified has having failed. Finally stream specific data can be directly stored and set as reflecting the state of the stream. [NOTE: the cfg.setStream() call here associates the stream to the StreamConfiguration however that should quite likely be done as part of the validation process. TBD] Signed-off-by: Kieran Bingham --- src/libcamera/pipeline/vivid/vivid.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/vivid/vivid.cpp b/src/libcamera/pipeline/vivid/vivid.cpp index 9e95bae8bc30..dbc19424e75a 100644 --- a/src/libcamera/pipeline/vivid/vivid.cpp +++ b/src/libcamera/pipeline/vivid/vivid.cpp @@ -150,7 +150,26 @@ CameraConfiguration *PipelineHandlerVivid::generateConfiguration(Camera *camera, int PipelineHandlerVivid::configure(Camera *camera, CameraConfiguration *config) { - return -1; + VividCameraData *data = cameraData(camera); + StreamConfiguration &cfg = config->at(0); + int ret; + + V4L2DeviceFormat format = {}; + format.fourcc = data->video_->toV4L2PixelFormat(cfg.pixelFormat); + format.size = cfg.size; + + ret = data->video_->setFormat(&format); + if (ret) + return ret; + + if (format.size != cfg.size || + format.fourcc != data->video_->toV4L2PixelFormat(cfg.pixelFormat)) + return -EINVAL; + + cfg.setStream(&data->stream_); + cfg.stride = format.planes[0].bpl; + + return 0; } int PipelineHandlerVivid::exportFrameBuffers(Camera *camera, Stream *stream,