From patchwork Thu Oct 3 15:20:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2081 Return-Path: Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C197561915 for ; Thu, 3 Oct 2019 17:19:06 +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 relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 5C52AC0004; Thu, 3 Oct 2019 15:19:06 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Oct 2019 17:20:37 +0200 Message-Id: <20191003152037.74617-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003152037.74617-1-jacopo@jmondi.org> References: <20191003152037.74617-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/5] ipa: vimc: Add support for test back channel 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 15:19:07 -0000 Add support to the dummy VIMC IPA for communication with the IPA interface test unit. Use the test channel, if available, to send a confirmation code when the init() operation is called. Signed-off-by: Jacopo Mondi --- src/ipa/ipa_vimc.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/ipa/ipa_vimc.cpp b/src/ipa/ipa_vimc.cpp index abc06e7f5fd5..781f5796b082 100644 --- a/src/ipa/ipa_vimc.cpp +++ b/src/ipa/ipa_vimc.cpp @@ -7,20 +7,74 @@ #include +#include +#include +#include +#include + #include #include namespace libcamera { +/* Keep these in sync with the IPA Interface test unit. */ +static const char *vimcFifoPath = "/tmp/vimc_ipa_fifo"; +#define IPA_INIT_CODE 0x01 + class IPAVimc : public IPAInterface { public: + IPAVimc(); + ~IPAVimc(); + int init(); + +private: + unsigned int fd_; }; +IPAVimc::IPAVimc() + : fd_(0) +{ + /* Set up the test unit back-channel, if available. */ + struct stat fifoStat; + int ret = stat(vimcFifoPath, &fifoStat); + if (ret) + return; + + ret = ::open(vimcFifoPath, O_WRONLY); + if (ret < 0) { + std::cerr << "Failed to open vimc IPA test fifo at: " + << vimcFifoPath << ": " << strerror(errno) + << std::endl; + return; + } + fd_ = ret; +} + +IPAVimc::~IPAVimc() +{ + if (fd_) + ::close(fd_); +} + int IPAVimc::init() { std::cout << "initializing vimc IPA!" << std::endl; + + if (!fd_) + return 0; + + int8_t data = IPA_INIT_CODE; + int ret = ::write(fd_, &data, 1); + if (ret < 0) { + ret = -errno; + std::cerr << "Failed to write to vimc IPA test fifo at: " + << vimcFifoPath << ": " << strerror(-ret) + << std::endl; + return ret; + } + return 0; }