From patchwork Thu Mar 19 09:54:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 3193 Return-Path: Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DBFF060416 for ; Thu, 19 Mar 2020 10:54:16 +0100 (CET) Received: by mail-pl1-x62e.google.com with SMTP id h11so836369plk.7 for ; Thu, 19 Mar 2020 02:54:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=x794za9KWEk0GVwZoiDw1d9qmElx4bSfEb1V9GdS25k=; b=o7RElqLEz0an2WnP6Tex/aNAn0m91QcYc14ybuhIhxeRn09aQMaz/T7w0sn6DSbcpH Jz/6JS3WVzpoFqZtqN69FSsJWZBqyVWR4w1Pjbr5Y3UAdoinFhz0WIzQj7D8u8n6gSIC 3mW3ZJDiMOOHD/qFJlwK7+BsERfzPjs6YGvfodMBO9wr7RWaK0vZw9iYI837aEfyrMxW ph40toIaplKl8duMmeXX+OnmbkqIB2Jg8+KVIUt+mi8i5K9FfREii9h9nXg1MaDPcQdw uDm65SfeTSFKGGN/6SSSp3jhHq8HMxQBCnTxCIqSZYWQrt5+jl+E23zfwygSxFmfhnCm t01Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=x794za9KWEk0GVwZoiDw1d9qmElx4bSfEb1V9GdS25k=; b=pHmZJZpxNCYmHxYbuQgUYZHaingHs4lcCfGyy5aYygKM6hb4FaekFP2Yat0pF/p6ke r1YndyON5zZnIQl9/6Pm+h4+lXFwEIp4c8mWmYMSUbWqBCgDtrgTQ7StWYE/eK9NePZz CsorTluHfBq+X7g/2/GonoisuQyUY8Gggs4b7sd4cqsRXbT9sWNtfTdJMhXi+cOTYeSl TmWB/Rk/ak/ARgoUygHZKSsCA0dGZWeTFBK6fZL/P47N7Uj9L02sm2tvfP5FHni4MK/e R1VBcwzr6AKXcXGN+C6Rb+VCJHYF3IgPq8DhtfGA9RH+ioc3Kni93TpHhsyi7GEsvGiG EA2w== X-Gm-Message-State: ANhLgQ1rK2+ulv8HXD65jvFiXq4UY8tpAiT7VBnn0wAOJftW0nJeAUhf 9yAf1Vw9udPG821pEC3B2dAPkQ== X-Google-Smtp-Source: ADFU+vtfcKzvmoaYobbyith57tqeBpNFlGP9EIZVaores3o10gAZ37KhTxgcCxKcC2uD+gyXAtlzVA== X-Received: by 2002:a17:90b:4d07:: with SMTP id mw7mr3019693pjb.103.1584611654758; Thu, 19 Mar 2020 02:54:14 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.153]) by smtp.gmail.com with ESMTPSA id d1sm1743358pfc.3.2020.03.19.02.54.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Mar 2020 02:54:14 -0700 (PDT) Date: Thu, 19 Mar 2020 15:24:06 +0530 From: Kaaira Gupta To: kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org Cc: Helen Koike , Vaishali Thakkar Message-ID: <20200319095406.GA26435@kaaira-HP-Pavilion-Notebook> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Subject: [libcamera-devel] [PATCH LIBCAMERA] libcamera: utils: merge isLibcamerainstalled with libcameraPath 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, 19 Mar 2020 09:54:20 -0000 The two callers of functions libcameraPath() and isLibcameraInstalled() end up using the same process and finally use the path with libcamera.so. Hence write a function libcameraSourcePath() which combines their functions, thereby making call sites simpler. Signed-off-by: Kaaira Gupta --- src/libcamera/include/utils.h | 2 +- src/libcamera/ipa_manager.cpp | 5 +++-- src/libcamera/ipa_proxy.cpp | 6 +++--- src/libcamera/utils.cpp | 20 +++++++++++--------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h index bc96e79..2cff15e 100644 --- a/src/libcamera/include/utils.h +++ b/src/libcamera/include/utils.h @@ -145,7 +145,7 @@ details::StringSplitter split(const std::string &str, const std::string &delim); bool isLibcameraInstalled(); -std::string libcameraPath(); +std::string libcameraSourcePath(); } /* namespace utils */ diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 0bd280c..cf9b6e7 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -119,8 +119,9 @@ IPAManager::IPAManager() * path for the IPA from that point. We need to recurse one level of * sub-directories to match the build tree. */ - if (!utils::isLibcameraInstalled()) { - std::string ipaBuildPath = utils::dirname(utils::libcameraPath()) + "/../ipa"; + std::string libPath = utils::libcameraSourcePath(); + if (!libPath.empty()) { + std::string ipaBuildPath = libPath + "/../ipa"; constexpr int maxDepth = 1; LOG(IPAManager, Info) diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp index 2f866cc..e9b7568 100644 --- a/src/libcamera/ipa_proxy.cpp +++ b/src/libcamera/ipa_proxy.cpp @@ -97,9 +97,9 @@ std::string IPAProxy::resolvePath(const std::string &file) const * This requires identifying the path of the libcamera.so, and * referencing a relative path for the proxy workers from that point. */ - if (!utils::isLibcameraInstalled()) { - std::string ipaProxyDir = utils::dirname(utils::libcameraPath()) - + "/proxy/worker"; + std::string libPath = utils::libcameraSourcePath(); + if (!libPath.empty()) { + std::string ipaProxyDir = libPath + "/proxy/worker"; LOG(IPAProxy, Info) << "libcamera is not installed. Loading proxy workers from'" diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp index 7e118fa..8212d3e 100644 --- a/src/libcamera/utils.cpp +++ b/src/libcamera/utils.cpp @@ -347,16 +347,18 @@ bool isLibcameraInstalled() * * \return A string stating the path */ -std::string libcameraPath() +std::string libcameraSourcePath() { - Dl_info info; - - /* Look up our own symbol. */ - int ret = dladdr(reinterpret_cast(libcameraPath), &info); - if (ret == 0) - return nullptr; - - return info.dli_fname; + if (!utils::isLibcameraInstalled()) { + Dl_info info; + /* Look up our own symbol. */ + int ret = dladdr(reinterpret_cast(libcameraSourcePath), &info); + if (ret == 0) + return nullptr; + + return utils::dirname(info.dli_fname); + } else + return std::string(); } } /* namespace utils */