From patchwork Thu Oct 3 17:49:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 2087 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 17BFE6170D for ; Thu, 3 Oct 2019 19:50:40 +0200 (CEST) X-Halon-ID: 32b2c12b-e606-11e9-837a-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [84.172.88.101]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 32b2c12b-e606-11e9-837a-0050569116f7; Thu, 03 Oct 2019 19:49:50 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Oct 2019 19:49:36 +0200 Message-Id: <20191003174941.1296988-7-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003174941.1296988-1-niklas.soderlund@ragnatech.se> References: <20191003174941.1296988-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 06/11] libcamera: ipa: Extend to support IPA interactions 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: , X-List-Received-Date: Thu, 03 Oct 2019 17:50:40 -0000 The IPA interface needs to support interactions with the pipeline, add interfaces to control the sensor and handling of request ISP parameters and statistics. Signed-off-by: Niklas Söderlund --- include/ipa/ipa_interface.h | 37 +++++++ src/ipa/ipa_dummy.cpp | 7 +- src/libcamera/ipa_interface.cpp | 132 ++++++++++++++++++++++++ src/libcamera/proxy/ipa_proxy_linux.cpp | 14 ++- 4 files changed, 181 insertions(+), 9 deletions(-) diff --git a/include/ipa/ipa_interface.h b/include/ipa/ipa_interface.h index 2c5eb1fd524311cb..2c715314c7a418f0 100644 --- a/include/ipa/ipa_interface.h +++ b/include/ipa/ipa_interface.h @@ -7,14 +7,51 @@ #ifndef __LIBCAMERA_IPA_INTERFACE_H__ #define __LIBCAMERA_IPA_INTERFACE_H__ +#include +#include + +#include +#include +#include +#include + +#include "v4l2_controls.h" + namespace libcamera { +struct IPAStream { + unsigned int pixelFormat; + Size size; +}; + +struct IPABuffer { + unsigned int id; + unsigned int type; + BufferMemory buffer; +}; + +struct IPAOperationData { + unsigned int operation; + std::vector data; + std::vector controls; + /* \todo: Add more vectors for data types used in pipa<->IPA interactions. */ +}; + class IPAInterface { public: virtual ~IPAInterface() {} virtual int init() = 0; + + virtual void configure(const std::map &streamConfig, + const std::map &entityControls) = 0; + + virtual void mapBuffers(const std::vector &buffers) = 0; + virtual void unmapBuffers(const std::vector &buffers) = 0; + + virtual void processEvent(const IPAOperationData &event) = 0; + Signal queueFrameAction; }; } /* namespace libcamera */ diff --git a/src/ipa/ipa_dummy.cpp b/src/ipa/ipa_dummy.cpp index 9d0cbdc8b1ad5565..08f74c4952f3923a 100644 --- a/src/ipa/ipa_dummy.cpp +++ b/src/ipa/ipa_dummy.cpp @@ -15,7 +15,12 @@ namespace libcamera { class IPADummy : public IPAInterface { public: - int init(); + int init() override; + void configure(const std::map &streamConfig, + const std::map &entityControls) override {} + void mapBuffers(const std::vector &buffers) override {} + void unmapBuffers(const std::vector &buffers) override {} + void processEvent(const IPAOperationData &event) override {} }; int IPADummy::init() diff --git a/src/libcamera/ipa_interface.cpp b/src/libcamera/ipa_interface.cpp index d7d8ca8881efcf66..c0f2004f3ec993b2 100644 --- a/src/libcamera/ipa_interface.cpp +++ b/src/libcamera/ipa_interface.cpp @@ -14,6 +14,68 @@ namespace libcamera { + +/** + * \struct IPAStream + * \brief Hold IPA description of a stream. + */ + +/** + * \var IPAStream::pixelFormat + * \brief The streams pixel format + */ + +/** + * \var IPAStream::size + * \brief The streams size + */ + +/** + * \struct IPABuffer + * \brief Hold IPA description of a buffer + */ + +/** + * \var IPABuffer::id + * \brief The pipeline to IPA id cookie for the buffer + */ + +/** + * \var IPABuffer::type + * \brief The pipeline to IPA type for the buffer + */ + +/** + * \var IPABuffer::buffer + * \brief The hardware description of the buffer shared between pipeline and IPA + */ + +/** + * \struct IPAOperationData + * \brief Hold data exchanged between pipeline and IPA + * + * This is the information carrier between pipeline and IPA. The is is used + * to transport the pipeline specific protocol between the two. Core libcamera + * components do not try to interpret the protocol and it's up to the pipeline + * handler to uses the members of this struct in any way they see fit, and to + * document it so multiple IPA implementations for the same pipeline may use it. + */ + +/** + * \var IPAOperationData::operation + * \brief Intended as the operation code in the pipeline to IPA protocol + */ + +/** + * \var IPAOperationData::data + * \brief Intended as the generic data carrier in the pipeline to IPA protocol + */ + +/** + * \var IPAOperationData::controls + * \brief Intended as the ControlList carrier in the pipeline to IPA protocol + */ + /** * \class IPAInterface * \brief Interface for IPA implementation @@ -24,4 +86,74 @@ namespace libcamera { * \brief Initialise the IPAInterface */ +/** + * \fn IPAInterface::configure() + * \brief Configure the IPA stream and sensor settings + * \param[in] streamConfig List of stream configuration descriptions + * \param[in] entityControls List of controls provided by the pipeline entities + * + * This function is called when a pipeline attaches to an IPA to inform the IPA + * of the streams and controls limits the entities(s) in the video pipeline + * supports. + */ + +/** + * \fn IPAInterface::mapBuffers() + * \brief Map the buffers shared by the pipeline to the IPA + * \param[in] buffers List of buffers to map + * + * This function is called when a pipeline handler wants to inform the IPA of + * which buffers it has mapped which the IPA can make use of. All buffers shared + * between these two object's needs to be shared using this function prior to + * use. + * + * After the buffers have been initialized a specific buffer can be referenced + * using the numerical \a type and \a id provided when the buffers where mapped. + * + * The numerical values for type and id used to describe a buffer have no + * meaning in the core libcamera code and the interface is pipeline handler + * specific. + * + * \sa unmapBuffers() + * \todo Can we make this a generic function? + */ + +/** + * \fn IPAInterface::unmapBuffers() + * \brief Unmap the buffers shared by the pipeline to the IPA + * \param[in] buffers List of buffers to unmap + * + * This function is called when a pipeline handler wants to the IPA to unmap + * all or some of the buffer it have mapped. + * + * \sa mapBuffers() + * \todo Can we make this a generic function? + */ + +/** + * \fn IPAInterface::processEvent() + * \brief Process an event from the pipeline handler + * \param[in] event Event to process + * + * The pipeline handler can send events to the IPA to notify it of what is + * going on. This is the entry point on the IPA side for those messages. + * + * The protocol between pipeline and IPA are hilly specific for each pipeline + * and needs to be documented separately. Libcamera reserves no operation + * numbers and make no attempt to interpret the protocol. + */ + +/** + * \fn IPAInterface::queueFrameAction() + * \brief Signal emitted when the IPA wish to queue a FrameAction + * \param[in] frame The frame number for the request + * \param[in] controls List of controls associated with the request + * + * This signal is emitted when the IPA wish to queue a FrameAction on the + * pipeline. The pipeline is still responsible for the scheduling of the action + * on its timeline. + * + * The IPA operation describing the frame action is passed as a parameter. + */ + } /* namespace libcamera */ diff --git a/src/libcamera/proxy/ipa_proxy_linux.cpp b/src/libcamera/proxy/ipa_proxy_linux.cpp index 62fcb529e1c7e4ff..14e8bb6067623fc6 100644 --- a/src/libcamera/proxy/ipa_proxy_linux.cpp +++ b/src/libcamera/proxy/ipa_proxy_linux.cpp @@ -26,7 +26,12 @@ public: IPAProxyLinux(IPAModule *ipam); ~IPAProxyLinux(); - int init(); + int init() override { return 0; } + void configure(const std::map &streamConfig, + const std::map &entityControls) override {} + void mapBuffers(const std::vector &buffers) override {} + void unmapBuffers(const std::vector &buffers) override {} + void processEvent(const IPAOperationData &event) override {} private: void readyRead(IPCUnixSocket *ipc); @@ -36,13 +41,6 @@ private: IPCUnixSocket *socket_; }; -int IPAProxyLinux::init() -{ - LOG(IPAProxy, Debug) << "initializing IPA via dummy proxy!"; - - return 0; -} - IPAProxyLinux::IPAProxyLinux(IPAModule *ipam) : proc_(nullptr), socket_(nullptr) {