From patchwork Sun Jun 28 23:19:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8489 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 0589CC2E66 for ; Sun, 28 Jun 2020 23:19:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C949A60B00; Mon, 29 Jun 2020 01:19:51 +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="lDPeoNJm"; 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 5927560AF1 for ; Mon, 29 Jun 2020 01:19:43 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B6D934FB; Mon, 29 Jun 2020 01:19:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593386382; bh=dbBYdgdx2A9b3rVj18b78K4/NFH7Ho0429N8US51R2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lDPeoNJmMGfOfHQbJAdYuvvcBET23E+YBs4PCLcM21iRyzuMxj+0EuhrZbGrRBle+ WDujxi2KlHePrFEncw5IdsEeHd6Vi8TMKtB2qjPNqMQc5M3CXDcomuIL9KD0Ei34uS w2V7o7rfO1B+Eqsacrb3kWZJIiNMS4q01t/Uks24= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Jun 2020 02:19:30 +0300 Message-Id: <20200628231934.29025-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> References: <20200628231934.29025-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 5/9] libcamera: pipeline: raspberrypi: Move configureIPA() to RPiCameraData 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The PipelineHandlerRPi::configureIPA() function accesses plenty of member data from the RPiCameraData class and no member from the PipelineHandlerRPi class. Move it to RPiCameraData where it logically belongs. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Naushir Patuck Reviewed-by: Jacopo Mondi --- .../pipeline/raspberrypi/raspberrypi.cpp | 117 +++++++++--------- 1 file changed, 58 insertions(+), 59 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 3b5cdf1e1849..0f9237a7f346 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -311,6 +311,8 @@ public: void frameStarted(uint32_t sequence); int loadIPA(); + int configureIPA(); + void queueFrameAction(unsigned int frame, const IPAOperationData &action); /* bufferComplete signal handlers. */ @@ -396,8 +398,6 @@ private: return static_cast(PipelineHandler::cameraData(camera)); } - int configureIPA(Camera *camera); - int queueAllBuffers(Camera *camera); int prepareBuffers(Camera *camera); void freeBuffers(Camera *camera); @@ -752,7 +752,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) crop.y = (sensorFormat.size.height - crop.height) >> 1; data->isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &crop); - ret = configureIPA(camera); + ret = data->configureIPA(); if (ret) LOG(RPI, Error) << "Failed to configure the IPA: " << ret; @@ -968,62 +968,6 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) return true; } -int PipelineHandlerRPi::configureIPA(Camera *camera) -{ - std::map streamConfig; - std::map entityControls; - RPiCameraData *data = cameraData(camera); - - /* Get the device format to pass to the IPA. */ - V4L2DeviceFormat sensorFormat; - data->unicam_[Unicam::Image].dev()->getFormat(&sensorFormat); - /* Inform IPA of stream configuration and sensor controls. */ - unsigned int i = 0; - for (auto const &stream : data->isp_) { - if (stream.isExternal()) { - streamConfig[i] = { - .pixelFormat = stream.configuration().pixelFormat, - .size = stream.configuration().size - }; - } - } - entityControls.emplace(0, data->unicam_[Unicam::Image].dev()->controls()); - entityControls.emplace(1, data->isp_[Isp::Input].dev()->controls()); - - /* Allocate the lens shading table via vcsm and pass to the IPA. */ - if (!data->lsTable_) { - data->lsTable_ = data->vcsm_.alloc("ls_grid", MAX_LS_GRID_SIZE); - uintptr_t ptr = reinterpret_cast(data->lsTable_); - - if (!data->lsTable_) - return -ENOMEM; - - /* - * The vcsm allocation will always be in the memory region - * < 32-bits to allow Videocore to access the memory. - */ - IPAOperationData op; - op.operation = RPI_IPA_EVENT_LS_TABLE_ALLOCATION; - op.data = { static_cast(ptr & 0xffffffff), - data->vcsm_.getVCHandle(data->lsTable_) }; - data->ipa_->processEvent(op); - } - - CameraSensorInfo sensorInfo = {}; - int ret = data->sensor_->sensorInfo(&sensorInfo); - if (ret) { - LOG(RPI, Error) << "Failed to retrieve camera sensor info"; - return ret; - } - - /* Ready the IPA - it must know about the sensor resolution. */ - IPAOperationData ipaConfig; - data->ipa_->configure(sensorInfo, streamConfig, entityControls, - ipaConfig, nullptr); - - return 0; -} - int PipelineHandlerRPi::queueAllBuffers(Camera *camera) { RPiCameraData *data = cameraData(camera); @@ -1161,6 +1105,61 @@ int RPiCameraData::loadIPA() return ipa_->start(); } +int RPiCameraData::configureIPA() +{ + std::map streamConfig; + std::map entityControls; + + /* Get the device format to pass to the IPA. */ + V4L2DeviceFormat sensorFormat; + unicam_[Unicam::Image].dev()->getFormat(&sensorFormat); + /* Inform IPA of stream configuration and sensor controls. */ + unsigned int i = 0; + for (auto const &stream : isp_) { + if (stream.isExternal()) { + streamConfig[i] = { + .pixelFormat = stream.configuration().pixelFormat, + .size = stream.configuration().size + }; + } + } + entityControls.emplace(0, unicam_[Unicam::Image].dev()->controls()); + entityControls.emplace(1, isp_[Isp::Input].dev()->controls()); + + /* Allocate the lens shading table via vcsm and pass to the IPA. */ + if (!lsTable_) { + lsTable_ = vcsm_.alloc("ls_grid", MAX_LS_GRID_SIZE); + uintptr_t ptr = reinterpret_cast(lsTable_); + + if (!lsTable_) + return -ENOMEM; + + /* + * The vcsm allocation will always be in the memory region + * < 32-bits to allow Videocore to access the memory. + */ + IPAOperationData op; + op.operation = RPI_IPA_EVENT_LS_TABLE_ALLOCATION; + op.data = { static_cast(ptr & 0xffffffff), + vcsm_.getVCHandle(lsTable_) }; + ipa_->processEvent(op); + } + + CameraSensorInfo sensorInfo = {}; + int ret = sensor_->sensorInfo(&sensorInfo); + if (ret) { + LOG(RPI, Error) << "Failed to retrieve camera sensor info"; + return ret; + } + + /* Ready the IPA - it must know about the sensor resolution. */ + IPAOperationData ipaConfig; + ipa_->configure(sensorInfo, streamConfig, entityControls, ipaConfig, + nullptr); + + return 0; +} + void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData &action) { /*