From patchwork Wed Jun 19 11:08:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 1479 Return-Path: Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A598861A1F for ; Wed, 19 Jun 2019 13:07:52 +0200 (CEST) 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 relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 4B7A8FF802; Wed, 19 Jun 2019 11:07:52 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 19 Jun 2019 13:08:58 +0200 Message-Id: <20190619110858.20980-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190619110858.20980-1-jacopo@jmondi.org> References: <20190619110858.20980-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 6/6] [HACK] ipu3: Set and get a few sensor controls 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, 19 Jun 2019 11:07:53 -0000 Not to merge patch to demonstrate how to set controls on the image sensor device. Not-Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 8c26d2c8c60c..8401ced17282 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -693,6 +693,55 @@ int PipelineHandlerIPU3::start(Camera *camera) ImgUDevice *imgu = data->imgu_; int ret; + /* --- Get control values --- */ + V4L2Controls controls; + controls.add(V4L2_CID_EXPOSURE); + controls.add(V4L2_CID_ANALOGUE_GAIN); + ret = cio2->sensor_->getControls(&controls); + if (ret) { + LOG(Error) << "Failed to get control values"; + return -EINVAL; + } + + for (const V4L2Control &ctrl : controls) { + unsigned int id = ctrl.id(); + V4L2ControlInfo *info = cio2->sensor_->getControlInfo(id); + if (!info) + continue; + + int val = controls.get(id); + LOG(Error) << "Control : " << id << " - name : " << info->name() + << " - value: " << val; + } + + /* --- Set control values --- */ + controls.set(V4L2_CID_EXPOSURE, 2046); + controls.set(V4L2_CID_ANALOGUE_GAIN, 1024); + + ret = cio2->sensor_->setControls(&controls); + if (ret) { + LOG(IPU3, Error) << "Failed to set controls"; + return ret; + } + + /* --- Get control values back again and verify they have changed --- */ + ret = cio2->sensor_->getControls(&controls); + if (ret) { + LOG(Error) << "Failed to get control values"; + return -EINVAL; + } + + for (const V4L2Control &ctrl : controls) { + unsigned int id = ctrl.id(); + V4L2ControlInfo *info = cio2->sensor_->getControlInfo(id); + if (!info) + continue; + + int val = controls.get(id); + LOG(Error) << "Control : " << id << " - name : " << info->name() + << " - value: " << val; + } + /* * Start the ImgU video devices, buffers will be queued to the * ImgU output and viewfinder when requests will be queued.