From patchwork Fri Oct 28 03:17:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne via libcamera-devel X-Patchwork-Id: 17713 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 408D4BD16B for ; Fri, 28 Oct 2022 03:17:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C4C0962FB7; Fri, 28 Oct 2022 05:17:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666927053; bh=KAG6VBvMLEaE+uQzo38FS9tf6GUTOandZ8YYv21Fh6o=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=QijdF/PgpvZA2bMSaFizmim0/tYkQEMm6hYX8aTRsgdqGlHdlvDiRrpvW7JTapCgW hZgtjnh3RDpg8vxe3h9LFs6UT9XN9pOIzqGBkK/Xqilg3JdHIr7yOtpk+Zkf+KP7yU i81vl4q9ZwdCHxm6sURvWQIuwTVhpLKYgcLYCyxZoBpap+zMlaZYuRzE6vdMrdaLRn QVGklYyqkMytTBD/YOpuJjfnIoUM+ZT1Xa5kD/AUe3hh73e/Xk0ZAlhdUiZzl44GVz RSzGz2L20mz/miUXhJGCQ52cRGYoWlhXxQXehpUtFlRv+nrPK2HgVc3U3FguuEB5Sn 1yrrEUyMvluIA== Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C0BD562FA5 for ; Fri, 28 Oct 2022 05:17:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=rothemail-net.20210112.gappssmtp.com header.i=@rothemail-net.20210112.gappssmtp.com header.b="P8A8pisJ"; dkim-atps=neutral Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-13ba86b5ac0so5026911fac.1 for ; Thu, 27 Oct 2022 20:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothemail-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=vPPTrdE8P8aEZNt9QylvzE1IoIY92ZIoPAxBlN/CeEU=; b=P8A8pisJzUK8Coq8lKcoOQIZkjTF2FfMbt4ZaUcfp8DUbAYzqTdhGQe0Px3RdLxzeL RNZV2gT1mLfLHD7aZ3zBHHoW3xHFPt+046d9xrk13Ogd8Wb9sQGeoq0yGsT8+kyyAJzz FZE3gPDWsCpymKxUMdt74WN8w3uTdH6u3wd+DRCOAotWIClLzkkyYFmkyXqmg/UMxB5C /q52H9WgKz57QIFVADcwnnb+gg58r6TT0oMSObpmr3FDFtFiuKIGt0D1hpKT7QofNdwx duypEdrU7Y6S51YbPFfE1kkNgZJCNjPW6lCA0LhSubIGPutaPQ816X9B1MrXpZObCQGF XO+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vPPTrdE8P8aEZNt9QylvzE1IoIY92ZIoPAxBlN/CeEU=; b=y3xWDJTM/VVBXbRNeTC36Z11MAFKpqdVEFg/tvmt4vkUaYdlx9JE75ZWYb/oGk9cDm qK98R4mYNOc+O2woTDR2ThsKjJ92rWpvXmIKd8lANu3vlcuhgDigvRIF9URdXCl8jIaw giTgJIc9ZgfhfyYjVgjFDoz8b8c+KQe9a7c8LoNz5amrWt0L68fo7m2oZzRnXy2LGSod CR5BZYgXRRT5Z/XMzdCY2UfjWewMowfWkyfOqTa/FF5ZpAClw1ZY02/j2m7XgQAXxJnE BJd12BsA1Arh3J9vh2YkOTiDgL99UiwOyGNjJSlSw/p3vhY5KJOZMt29PXeRIk0PWU8+ JX9Q== X-Gm-Message-State: ACrzQf0jKY2gP0k0pM2LGBDTTyHMB813XH5ywA+P8i+UUUsVfKs9rseL JNYaZETaXuj8nMA2pDkaSlIXJk7FMb6SeBm1Izk= X-Google-Smtp-Source: AMsMyM4xzQkMeXYywpCGa32Q7+21sCJRV1ytfch+9gJ9rZpfRZ/zZm4yF77eFWah2oCmEwQgr6LIGA== X-Received: by 2002:a05:6870:58a4:b0:11c:9b6d:f066 with SMTP id be36-20020a05687058a400b0011c9b6df066mr7802106oab.155.1666927050086; Thu, 27 Oct 2022 20:17:30 -0700 (PDT) Received: from nroth-pc.attlocal.net ([2600:1700:20:20c0:293a:90ce:6463:244d]) by smtp.gmail.com with ESMTPSA id fp19-20020a056870659300b0013626c1a5f6sm1527738oab.10.2022.10.27.20.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 20:17:29 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 27 Oct 2022 22:17:17 -0500 Message-Id: <20221028031726.4849-2-nicholas@rothemail.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028031726.4849-1-nicholas@rothemail.net> References: <20221027224135.348115-1-nicholas@rothemail.net> <20221028031726.4849-1-nicholas@rothemail.net> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 01/10] ipa: workaround libcxx duration limitation 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-Patchwork-Original-From: Nicholas Roth via libcamera-devel From: Nicolas Dufresne via libcamera-devel Reply-To: libcamera-devel@lists.libcamera.org Cc: nicholas@rothemail.net Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nicholas Roth A bug in libcxx [0] used by clang version 11.0.2 is prevalent when building libcamera for Android SDK30. This has been fixed and integrated upstream with [1]. As a workaround, directly cast libcamera::utils::Duration objects to std::chrono::duration when dividing. Alternatives evaluated: Considered: Enable public inheritance of std::chrono::duration and override operator/ in the class. Outcome: Does not fix the original compiler error. Considered: Enable public inheritance of std::chrono::duration and override operator/ in the libcamera namespace. Outcome: new compiler error: ld.lld: error: duplicate symbol: libcamera::operator/ (libcamera::utils::Duration const&, libcamera::utils::Duration const&) Considered: Use private inheritance of std::chrono::duration and re-implement a pass-through version of each std::chrono::duration operator within libcamera::utils::Duration and use template metaprogramming to fix the division operator. Outcome: Testing shows that this would introduce substantial limitations, i.e. requring the Duration object to be on the LHS of any arithmetic operation with other numeric types. This also substantially increases implementation complexity. Considered: Extract double values from libcamera::utils::Duration objects and use those to divide. Outcome: This creates substantial readability and unit-safety issues. [0] https://github.com/llvm/llvm-project/issues/40475 [1] https://github.com/llvm/llvm-project/commit/efa6d803c624f9251d0ab7881122501bb9d27368 Bug: https://bugs.libcamera.org/show_bug.cgi?id=156 Signed-off-by: Nicholas Roth --- src/ipa/ipu3/algorithms/agc.cpp | 16 ++++++++++------ src/ipa/raspberrypi/cam_helper.cpp | 6 +++--- src/ipa/raspberrypi/cam_helper_imx296.cpp | 3 ++- src/ipa/raspberrypi/controller/rpi/agc.cpp | 12 ++++++++---- src/ipa/raspberrypi/controller/rpi/lux.cpp | 3 ++- src/ipa/rkisp1/algorithms/agc.cpp | 12 ++++++++---- 6 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp index a1a3c38f..f1650468 100644 --- a/src/ipa/ipu3/algorithms/agc.cpp +++ b/src/ipa/ipu3/algorithms/agc.cpp @@ -100,7 +100,8 @@ int Agc::configure(IPAContext &context, /* Configure the default exposure and gain. */ activeState.agc.gain = std::max(minAnalogueGain_, kMinAnalogueGain); - activeState.agc.exposure = 10ms / configuration.sensor.lineDuration; + activeState.agc.exposure = 10ms / + std::chrono::duration(configuration.sensor.lineDuration); frameCount_ = 0; return 0; @@ -240,17 +241,20 @@ void Agc::computeExposure(IPAContext &context, IPAFrameContext &frameContext, * increase the gain. */ utils::Duration shutterTime = - std::clamp(exposureValue / minAnalogueGain_, - minShutterSpeed_, maxShutterSpeed_); - double stepGain = std::clamp(exposureValue / shutterTime, - minAnalogueGain_, maxAnalogueGain_); + std::clamp(std::chrono::duration(exposureValue) / + minAnalogueGain_, + minShutterSpeed_, maxShutterSpeed_); + double stepGain = std::clamp(std::chrono::duration(exposureValue) / + std::chrono::duration(shutterTime), + minAnalogueGain_, maxAnalogueGain_); LOG(IPU3Agc, Debug) << "Divided up shutter and gain are " << shutterTime << " and " << stepGain; IPAActiveState &activeState = context.activeState; /* Update the estimated exposure and gain. */ - activeState.agc.exposure = shutterTime / configuration.sensor.lineDuration; + activeState.agc.exposure = std::chrono::duration(shutterTime) / + std::chrono::duration(configuration.sensor.lineDuration); activeState.agc.gain = stepGain; } diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index d90ac1de..48a8a068 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -63,7 +63,7 @@ void CamHelper::process([[maybe_unused]] StatisticsPtr &stats, uint32_t CamHelper::exposureLines(const Duration exposure, const Duration lineLength) const { - return exposure / lineLength; + return std::chrono::duration(exposure) / std::chrono::duration(lineLength); } Duration CamHelper::exposure(uint32_t exposureLines, const Duration lineLength) const @@ -85,8 +85,8 @@ std::pair CamHelper::getBlanking(Duration &exposure, * frameLengthMax gets calculated on the smallest line length as we do * not want to extend that unless absolutely necessary. */ - frameLengthMin = minFrameDuration / mode_.minLineLength; - frameLengthMax = maxFrameDuration / mode_.minLineLength; + frameLengthMin = std::chrono::duration(minFrameDuration) / std::chrono::duration(mode_.minLineLength); + frameLengthMax = std::chrono::duration(maxFrameDuration) / std::chrono::duration(mode_.minLineLength); /* * Watch out for (exposureLines + frameIntegrationDiff_) overflowing a diff --git a/src/ipa/raspberrypi/cam_helper_imx296.cpp b/src/ipa/raspberrypi/cam_helper_imx296.cpp index ecb845e7..c5180de5 100644 --- a/src/ipa/raspberrypi/cam_helper_imx296.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx296.cpp @@ -57,7 +57,8 @@ double CamHelperImx296::gain(uint32_t gainCode) const uint32_t CamHelperImx296::exposureLines(const Duration exposure, [[maybe_unused]] const Duration lineLength) const { - return std::max(minExposureLines, (exposure - 14.26us) / timePerLine); + return std::max(minExposureLines, std::chrono::duration(exposure - 14.26us) / + std::chrono::duration(timePerLine)); } Duration CamHelperImx296::exposure(uint32_t exposureLines, diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index bd54a639..65baab99 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -418,7 +418,8 @@ void Agc::prepare(Metadata *imageMetadata) Duration actualExposure = deviceStatus.shutterSpeed * deviceStatus.analogueGain; if (actualExposure) { - status_.digitalGain = status_.totalExposureValue / actualExposure; + status_.digitalGain = std::chrono::duration(status_.totalExposureValue) / + std::chrono::duration(actualExposure); LOG(RPiAgc, Debug) << "Want total exposure " << status_.totalExposureValue; /* * Never ask for a gain < 1.0, and also impose @@ -823,7 +824,8 @@ void Agc::divideUpExposure() } if (status_.fixedAnalogueGain == 0.0) { if (exposureMode_->gain[stage] * shutterTime >= exposureValue) { - analogueGain = exposureValue / shutterTime; + analogueGain = std::chrono::duration(exposureValue) / + std::chrono::duration(shutterTime); break; } analogueGain = exposureMode_->gain[stage]; @@ -838,10 +840,12 @@ void Agc::divideUpExposure() */ if (!status_.fixedShutter && !status_.fixedAnalogueGain && status_.flickerPeriod) { - int flickerPeriods = shutterTime / status_.flickerPeriod; + int flickerPeriods = std::chrono::duration(shutterTime) / + std::chrono::duration(status_.flickerPeriod); if (flickerPeriods) { Duration newShutterTime = flickerPeriods * status_.flickerPeriod; - analogueGain *= shutterTime / newShutterTime; + analogueGain *= std::chrono::duration(shutterTime) / + std::chrono::duration(newShutterTime); /* * We should still not allow the ag to go over the * largest value in the exposure mode. Note that this diff --git a/src/ipa/raspberrypi/controller/rpi/lux.cpp b/src/ipa/raspberrypi/controller/rpi/lux.cpp index 9759186a..410f6f44 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.cpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.cpp @@ -94,7 +94,8 @@ void Lux::process(StatisticsPtr &stats, Metadata *imageMetadata) double currentY = sum / (double)num + .5; double gainRatio = referenceGain_ / currentGain; double shutterSpeedRatio = - referenceShutterSpeed_ / deviceStatus.shutterSpeed; + std::chrono::duration(referenceShutterSpeed_) / + std::chrono::duration(deviceStatus.shutterSpeed); double apertureRatio = referenceAperture_ / currentAperture; double yRatio = currentY * (65536 / numBins) / referenceY_; double estimatedLux = shutterSpeedRatio * gainRatio * diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 04062a36..bb874356 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -74,7 +74,8 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) { /* Configure the default exposure and gain. */ context.activeState.agc.gain = std::max(context.configuration.agc.minAnalogueGain, kMinAnalogueGain); - context.activeState.agc.exposure = 10ms / context.configuration.sensor.lineDuration; + context.activeState.agc.exposure = 10ms / + std::chrono::duration(context.configuration.sensor.lineDuration); /* * According to the RkISP1 documentation: @@ -212,16 +213,19 @@ void Agc::computeExposure(IPAContext &context, IPAFrameContext &frameContext, * Push the shutter time up to the maximum first, and only then * increase the gain. */ - utils::Duration shutterTime = std::clamp(exposureValue / minAnalogueGain, + utils::Duration shutterTime = std::clamp(std::chrono::duration(exposureValue) / + minAnalogueGain, minShutterSpeed, maxShutterSpeed); - double stepGain = std::clamp(exposureValue / shutterTime, + double stepGain = std::clamp(std::chrono::duration(exposureValue) / + std::chrono::duration(shutterTime), minAnalogueGain, maxAnalogueGain); LOG(RkISP1Agc, Debug) << "Divided up shutter and gain are " << shutterTime << " and " << stepGain; /* Update the estimated exposure and gain. */ - activeState.agc.exposure = shutterTime / configuration.sensor.lineDuration; + activeState.agc.exposure = std::chrono::duration(shutterTime) / + std::chrono::duration(configuration.sensor.lineDuration); activeState.agc.gain = stepGain; } From patchwork Fri Oct 28 03:17:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne via libcamera-devel X-Patchwork-Id: 17714 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 A943CC3285 for ; Fri, 28 Oct 2022 03:17:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4767F62FC0; Fri, 28 Oct 2022 05:17:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666927057; bh=17Ukq0I3hqoas+gx0WV6KuuhC12XYREv+g1mUc9xNoQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=0V6cMTJvK7a82Kiu67QpdRe9ZNe0/KQgU+Yrx+00HKdihUwNcPoTBETzNDfLp2W7J XCc+ZSCLaPqYIRA/5ZuSIj+VNOngxVQ5CTaFg7K3FkU6+XfmjYyV4YerwSfcPLrMz6 n0A9VTez1pgXt5oWyxyqEw+701PkqclDYn63gexd2y4gY1dYDOHSdQWV427uyN+W15 cVWbaSaFPLnUy1z1p5D0V/06QBAmiTcnN572UMnR7NYGg6FknX3N0lmIxnsrZRZSrl 1qheggzINI7UOBbTZmtFyZ15PW2Bc72+YuwFZANKn9fYFWm1tKxjFZUPI3IRKoaBi8 boj2floaf5LiQ== Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C7AB662FA5 for ; Fri, 28 Oct 2022 05:17:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=rothemail-net.20210112.gappssmtp.com header.i=@rothemail-net.20210112.gappssmtp.com header.b="B+2oZXzp"; dkim-atps=neutral Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-13ba9a4430cso4960140fac.11 for ; Thu, 27 Oct 2022 20:17:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothemail-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=1mfxtU8lTzXIpkx/hUjfyntGA0NGDWGeGZDezQGJzxA=; b=B+2oZXzpxfR3KvDIsb26hBjGDCnit7CK7p5Hn8satZesWBzO1aFioGZhZFeKRKl9MH kmS5zTEHUsZ0NVtz7kwmhWrKt0A+0TF6h9Qj0RedzJ0DcETEkvQ7mM06mts7bkdgbn9V YGU9FK2Sn4AGtzz92x0+mww81TX8/Ktmd8hUkwXq7hJGw78MpnVOJRc9hnuiE0ALy1r1 OMAzbYIDWvYkjprakLi4I+QwyDzkJXM1DnzoviLEvwTHqDd8OvfAAmnDiIICzhOmWDFi Sl62e9AdzA7JmpmGhtZh5wNXZVGCM3BRm1/hChuKUJE84PYoJjGAmqgU21S55HMg9aiq Zl7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=1mfxtU8lTzXIpkx/hUjfyntGA0NGDWGeGZDezQGJzxA=; b=QsJAXrZxgyQuaF+lkYaIlFHNuXdPzDGgFh0CowfKzebjKbhliiyn3TUskd4WYR7HZt aVURCAcecu8DGQx5FPadqL1KuhjVijXxdAUkak7/EAlCs1qDTD1aoFJ2gGDe0has9CCb O/1jGXjnyEQOZjsMfx9sO11DKLS9jQLjC2V60ISINerSOZjs3qbCMaD1T19/wybVwN6r Pmz0KgU5LFX/itOMxemTmLX8r3qI0NAT9Zr2xxTE5RMOaRAhi83p1r8WWLlOkLsii/2P mBfK/zU14VNiPu040FwP20TDRw57pzJ6Y+fYo7b/SHaN6NSIcJdkge8whsTsgNmlKS5B ofyQ== X-Gm-Message-State: ACrzQf2Qbhscx5u3XShOIFH1DqFaZsSOTe5C7P4fKwCh8kCMOIwgcdJ5 Hdesbws7vhcluno69uNq8mLaMymZnfJJ55kmHWA= X-Google-Smtp-Source: AMsMyM5smXSmKBb8eosTavUrHi/j0tmtR29zuLt7/QwcYbRsG1ualyN+WuL5eWuYxiiBwMRNyawAZA== X-Received: by 2002:a05:6871:b2b:b0:13b:6c86:2f40 with SMTP id fq43-20020a0568710b2b00b0013b6c862f40mr7722202oab.51.1666927051157; Thu, 27 Oct 2022 20:17:31 -0700 (PDT) Received: from nroth-pc.attlocal.net ([2600:1700:20:20c0:293a:90ce:6463:244d]) by smtp.gmail.com with ESMTPSA id fp19-20020a056870659300b0013626c1a5f6sm1527738oab.10.2022.10.27.20.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 20:17:30 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 27 Oct 2022 22:17:18 -0500 Message-Id: <20221028031726.4849-3-nicholas@rothemail.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028031726.4849-1-nicholas@rothemail.net> References: <20221027224135.348115-1-nicholas@rothemail.net> <20221028031726.4849-1-nicholas@rothemail.net> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 02/10] ipa: add missing thread-safety annotations 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-Patchwork-Original-From: Nicholas Roth via libcamera-devel From: Nicolas Dufresne via libcamera-devel Reply-To: libcamera-devel@lists.libcamera.org Cc: nicholas@rothemail.net Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nicholas Roth The raspberrypi IPA is missing thread-safety annotations, which breaks the build. Add required thread-safety annotations. ../src/ipa/raspberrypi/controller/metadata.h:108:31: error: mutex 'mutex_' is still held at the end of function [-Werror,-Wthread-safety-analysis] void lock() { mutex_.lock(); } ^ ../src/ipa/raspberrypi/controller/metadata.h:108:23: note: mutex acquired here void lock() { mutex_.lock(); } ^ ../src/ipa/raspberrypi/controller/metadata.h:109:25: error: releasing mutex 'mutex_' that was not held [-Werror,-Wthread-safety-analysis] void unlock() { mutex_.unlock(); } ^ Signed-off-by: Nicholas Roth Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Naushir Patuck --- src/ipa/raspberrypi/controller/metadata.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ipa/raspberrypi/controller/metadata.h b/src/ipa/raspberrypi/controller/metadata.h index 0f7ebfaf..870b6e26 100644 --- a/src/ipa/raspberrypi/controller/metadata.h +++ b/src/ipa/raspberrypi/controller/metadata.h @@ -13,9 +13,11 @@ #include #include +#include + namespace RPiController { -class Metadata +class LIBCAMERA_TSA_CAPABILITY("mutex") Metadata { public: Metadata() = default; @@ -103,8 +105,8 @@ public: * locks with the standard lock classes. * e.g. std::lock_guard lock(metadata) */ - void lock() { mutex_.lock(); } - void unlock() { mutex_.unlock(); } + void lock() LIBCAMERA_TSA_ACQUIRE() { mutex_.lock(); } + void unlock() LIBCAMERA_TSA_RELEASE() { mutex_.unlock(); } private: mutable std::mutex mutex_; From patchwork Fri Oct 28 03:17:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne via libcamera-devel X-Patchwork-Id: 17715 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 B7CA2BD16B for ; Fri, 28 Oct 2022 03:17:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 56B2862FC6; Fri, 28 Oct 2022 05:17:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666927058; bh=GFM5bzyejFGdCmfumkg5WZW+OFQTbKxh3hfs8kuuDvY=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=h4DGxSwQA0nIqZSAIunwl2NGhmQJ1BWgPkMSFstPABEebUImRVIPOWGZKjVjUmLvU XkASA/JUPfyFqX5ogGDx85zdYX1IFN3QOLlJhjmCtt28bBkis4TQpOxCuinGa1MoOz ATMlIAU5D0w1eDlr0vsaFnf1nkay6dKifRoeMKZyG2c1WESdMPpd6JNntA6x3qV6k+ 1WH9K/kOGkPA8skuKJCumuXtB9CfcC3NJ/uBJP8V/vgeU12mYpFOySvSMMcUOqfpJI prRynBq5T+xfjDxnb8CdmJqfB7i4vuUm0saSbQp35ZyKndPNxWT737sSuLFE3lYpvQ 7UDdTW2vinPIg== Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AD05962FAA for ; Fri, 28 Oct 2022 05:17:33 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=rothemail-net.20210112.gappssmtp.com header.i=@rothemail-net.20210112.gappssmtp.com header.b="M+XxCly7"; dkim-atps=neutral Received: by mail-oi1-x234.google.com with SMTP id t10so4922432oib.5 for ; Thu, 27 Oct 2022 20:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothemail-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=o0jPoObmv+RL/G51+tYqdL0a/lbBQwESyygD2hJKwPI=; b=M+XxCly7EOWPRmGfTsH0gTFtlbPC4B1Q9boO48n5/qBpkAtm8NYDehxMQqlXn7dSH8 npaHv4LEsCViOywAjW9RCIq5HJwEZYUhwxUreSHOZ81UEFFACLNzQR3SSMCjWNcF2aZ5 t3JiWKneYTOcWJPNEemZh3UjhMCoJGH+QvjjJMxme+hAccCgMBwBitpNskO13S11zdrT 4B1us1wxQjelWlId52COdWdOnOTWxbTFA0snV88iNRd5zPTXpq+JI/ohhaZKRoONHbvt oNE5+PkW8tbrxRSpnfdnVlSE+fJ8YQmzY17t2VOj7Hr+0LTTU6grsJNQi2lACcNi6WOM w+nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=o0jPoObmv+RL/G51+tYqdL0a/lbBQwESyygD2hJKwPI=; b=bPXUUfmFYtZluVllnc1+IqPBU9Ix15Jle8zKNT0+UCt1Cgu1Nf++BTRMnNn6TIliEm teKyQDcPa9cOFYaUR0FFOyzlyOVwcur7q78Tt2jZtbG9Ro3stHMEfIrhTQlG5AhJNYTW Okcn/Ergm1mmev9EF3pjyX+63wc1WXCVSmJAoSb26pOewDKyLSQJqGNg1R5x8cDvRS30 2i/9QZNeRlQIZDmLn+S8UGbQliO++3k8bmehzg/0TTJzIgW4ytu/+cnNItrFVaJe92/E O7GAFDMVtWmZZGPd3qwpqU5SaECxbiO0LHHUndySUA8SfB6pSK6AwSBHJdVZUfVKb665 KBnQ== X-Gm-Message-State: ACrzQf3JyJtRqGwZUP3MJ/BUIWs95y7r81L3VxPK260qgzaAgH2KNwDi OCMO0hscYZ2gTfzoOP2OhECR4kISiEpcXXdyX/I= X-Google-Smtp-Source: AMsMyM5kt5yFiksTUut6yw0Z0r6cZxQp2Um5R4oZl7YeSlFGjaRhpR1DeudpB9tW3exaQtPS59Qqfw== X-Received: by 2002:a05:6808:128b:b0:354:c73a:7241 with SMTP id a11-20020a056808128b00b00354c73a7241mr6745729oiw.34.1666927052031; Thu, 27 Oct 2022 20:17:32 -0700 (PDT) Received: from nroth-pc.attlocal.net ([2600:1700:20:20c0:293a:90ce:6463:244d]) by smtp.gmail.com with ESMTPSA id fp19-20020a056870659300b0013626c1a5f6sm1527738oab.10.2022.10.27.20.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 20:17:31 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 27 Oct 2022 22:17:19 -0500 Message-Id: <20221028031726.4849-4-nicholas@rothemail.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028031726.4849-1-nicholas@rothemail.net> References: <20221027224135.348115-1-nicholas@rothemail.net> <20221028031726.4849-1-nicholas@rothemail.net> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 03/10] ipa: add rkisp1 metadata to fix Android HAL 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-Patchwork-Original-From: Nicholas Roth via libcamera-devel From: Nicolas Dufresne via libcamera-devel Reply-To: libcamera-devel@lists.libcamera.org Cc: nicholas@rothemail.net Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nicholas Roth Currently, the Android HAL does not work on rkisp1-based devices because required FrameDurationLimits metadata is missing from the ISP implementation. This change introduces sensible defaults for FrameDurationLimits that should generally work most of the time. In theory, it should be possible to implement more sophisticated logic to detect frame durations. The appropriate API hooks for doing so exist and are used in IPAIPU3::updateControls(), although the implementation may be suspect. This is left as future work. Signed-off-by: Nicholas Roth --- src/ipa/rkisp1/rkisp1.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index ba3c547e..dd12c341 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -100,6 +100,12 @@ const ControlInfoMap::Map rkisp1Controls{ { &controls::Contrast, ControlInfo(0.0f, 1.993f) }, { &controls::Saturation, ControlInfo(0.0f, 1.993f) }, { &controls::Sharpness, ControlInfo(0.0f, 10.0f, 1.0f) }, + /* libcamera requires a fixed value for minimum frame duration, + * but this depends on the frame size and the rkisp1 device datasheets + * measure this in pixels per second. Neither the datasheets nor the driver + * specify a maximum. The minimum below is for 1920x1920. The maximum + * corresponds to two seconds. */ + { &controls::FrameDurationLimits, ControlInfo(48505, 2000000) }, { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) }, }; From patchwork Fri Oct 28 03:17:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne via libcamera-devel X-Patchwork-Id: 17716 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 2F789C3285 for ; Fri, 28 Oct 2022 03:17:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BBE9B62FC5; Fri, 28 Oct 2022 05:17:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666927059; bh=daE6WY54HAjKlN885/mrlKW4bKHReC2Ox9JTDd8H68w=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=s3F3WCxfZbXxcpfB3WjGUFAbzwYVPSjxfcGjL+ynqCoXMd4e16dDNnSwrosf43pUU gwpCy2n9wE/B6BkKr0yrTt7rlelyQmsvwn6v/6vCAb1C3dmupto6GEU8wf6VpJM/Q9 TLZpHQTMAd+ryUEZ6USPfIL5EegZHeY4Oc0j4GaA1/6QMG7Defpzo6x2CBuNPIvNll AHkyQEI2inakyi70cuITRtIcXiDJJ8Z0LK/uHsmLwEQ+lzPlHQkiSmeA8XiEnFNjej X0fLi5N096QPO0S8oq2aBCHz2LwKD7CpwbGuBpwIxBI8IEjfO5CxbL6gKT0BJf3zli ngRfPYP96XZJQ== Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5348962FB8 for ; Fri, 28 Oct 2022 05:17:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=rothemail-net.20210112.gappssmtp.com header.i=@rothemail-net.20210112.gappssmtp.com header.b="idayZRA8"; dkim-atps=neutral Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-13be3ef361dso4957316fac.12 for ; Thu, 27 Oct 2022 20:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothemail-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=Nx/vHY66gELOXMwShEVVfeaHqV/OVGT2Ylh4eoO+CP8=; b=idayZRA8Oo+H5eNFz26dCSPThYo2A9FORMsjbhBU//WoPlwuplGrZ3YIP2/4EfvOm+ vRxGv7AyeMsP+KzTqjjzsIp7Lvt/zqpWN9BGoRugZ10pofPqd/VQBVyCTkWI3+dEq4cQ XxP8HtnNdqaFekg68VhYbRrUsZN0PONXm4sOfgjVvoPVjneOfw1+dpjJUJaRYII5CYT5 aohosSS9lYOabU9oIJhvCcZbvGkYEgkyLAdtcqKn0n/4CgocKqS+4z7di7BWBwa2qoVu OMYUJBvvlSIJrbhKqY5Bs+hKJI0/in92+08zVnUYzx8K6q3Yvk+c+15u+hSIpo45roGz u/cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Nx/vHY66gELOXMwShEVVfeaHqV/OVGT2Ylh4eoO+CP8=; b=jI3vfJp2zPApW88nLryqkqZRFb09dSQj/kjb0zlt4eVcvv96Y1fR94Gr6vO2YM+P1z mCNkJulEdxjpxzwvyu6djxGI8OE5iRtzKXdLN2+CblI0Saiy/RG1gcoZ8UkNmdeapIxa otS0H5bymEyQ068xctkrlaG8+uf/qMgfBo7nABZ7qIR9QzdNPPeoBSSu4WeZrQwSFKmY zGEp5K7EaZU28GTSf3WJAFDIdAfJ2ZWt3l1zRM9VszbsNDKgQric2XTbQkK3Kancph7C Ff0bGYDJqu3bXARMLpuIgODlFME1gROW16GXEjygrWtIGK4LxYWDp3N1aiEE1n0fpymm 0jog== X-Gm-Message-State: ACrzQf16D5Z4lccE1u1NFVAdM+ByCABtpnTi7dAqJ4t/U5kOhZYOQV7K yTkdyZEfYSOr+qpp1DVBg4Z6bntmGYqVVpf0P0I= X-Google-Smtp-Source: AMsMyM68lCamEXyqvEojEV0UgHjrMM7PGQuFyrJEu77I9ShQb8SR3klQ8l9LkP6EnrBnJLWI9VFm2g== X-Received: by 2002:a05:6870:c0d5:b0:13a:fb98:713d with SMTP id e21-20020a056870c0d500b0013afb98713dmr7665311oad.199.1666927052589; Thu, 27 Oct 2022 20:17:32 -0700 (PDT) Received: from nroth-pc.attlocal.net ([2600:1700:20:20c0:293a:90ce:6463:244d]) by smtp.gmail.com with ESMTPSA id fp19-20020a056870659300b0013626c1a5f6sm1527738oab.10.2022.10.27.20.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 20:17:32 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 27 Oct 2022 22:17:20 -0500 Message-Id: <20221028031726.4849-5-nicholas@rothemail.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028031726.4849-1-nicholas@rothemail.net> References: <20221027224135.348115-1-nicholas@rothemail.net> <20221028031726.4849-1-nicholas@rothemail.net> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 04/10] ipa: libcamera: add support for ov8858 sensor 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-Patchwork-Original-From: Nicholas Roth via libcamera-devel From: Nicolas Dufresne via libcamera-devel Reply-To: libcamera-devel@lists.libcamera.org Cc: nicholas@rothemail.net Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nicholas Roth Currently, libcamera does not have information for the ov8858 sensor used in the PinePhone Pro, a phone designed to run Linux. This commit adds metadata, especially that sensor gain is reported and set in 1/16 discrete increments. For more information, see "5.8 manual exposure compensation/ manual gain compensation" in [0] and the driver in [1]. [0] http://www.ahdsensor.com/uploadfile/202008/55322e75316871.pdf [1] https://github.com/megous/linux/blob/orange-pi-5.19/drivers/media/i2c/ov8858.c Signed-off-by: Nicholas Roth --- src/ipa/libipa/camera_sensor_helper.cpp | 11 +++++++++++ src/libcamera/camera_sensor_properties.cpp | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp index 35056bec..f2040cbd 100644 --- a/src/ipa/libipa/camera_sensor_helper.cpp +++ b/src/ipa/libipa/camera_sensor_helper.cpp @@ -476,6 +476,17 @@ public: }; REGISTER_CAMERA_SENSOR_HELPER("ov5693", CameraSensorHelperOv5693) +class CameraSensorHelperOv8858 : public CameraSensorHelper +{ +public: + CameraSensorHelperOv8858() + { + gainType_ = AnalogueGainLinear; + gainConstants_.linear = { 1, 0, 0, 16 }; + } +}; +REGISTER_CAMERA_SENSOR_HELPER("m00_f_ov8858", CameraSensorHelperOv8858) + class CameraSensorHelperOv8865 : public CameraSensorHelper { public: diff --git a/src/libcamera/camera_sensor_properties.cpp b/src/libcamera/camera_sensor_properties.cpp index e5f27f06..d0757c15 100644 --- a/src/libcamera/camera_sensor_properties.cpp +++ b/src/libcamera/camera_sensor_properties.cpp @@ -146,6 +146,20 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen */ }, } }, + { "m00_f_ov8858", { + .unitCellSize = { 1200, 1200 }, + .testPatternModes = { + { controls::draft::TestPatternModeOff, 0 }, + { controls::draft::TestPatternModeColorBars, 1 }, + /* + * No best corresponding test pattern for: + * 1: "Vertical Color Bar Type 1", + * 2: "Vertical Color Bar Type 2", + * 3: "Vertical Color Bar Type 3", + * 4: "Vertical Color Bar Type 4" + */ + }, + } }, { "ov8865", { .unitCellSize = { 1400, 1400 }, .testPatternModes = { From patchwork Fri Oct 28 03:17:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne via libcamera-devel X-Patchwork-Id: 17717 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 6C929BD16B for ; Fri, 28 Oct 2022 03:17:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 186D962FBE; Fri, 28 Oct 2022 05:17:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666927062; bh=sX1r6Ne5eEwF5zJZASR+vpq0X820AepDT5mhE6+pR0Y=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=OIn+8KKqIeBT/PN7e0nMtgIsiX/4ha6MOYBuEI7Vv4FFOSVG6sC7S8NKx+yQQnLEe leENq5idXatKKJdTwcaYGsmFBDD/mx5xsFI/IFDZXy9Os48VnwOeL6JtoftY+awLaD o5dMmWpa6GmrbGkC7Q/tQ40lFB7RsKpB6c48qWw2EL6YPpBGwvQzjjqp+nvchm2CVY IptW5GqY4F7FZUbFvJ/+/hwtYeg9YojL6WP9q5l0lNq/QSKP3SSf2rpa8XxtrW0O5y kklYWABOcKoRHUlGr7nFcZ4VqjiAdMJ3nO/RVLvcPv2R9qskcJ0g67RFi1xTX+grF9 fzvbyzuTcGzZw== Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DA37962FAF for ; Fri, 28 Oct 2022 05:17:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=rothemail-net.20210112.gappssmtp.com header.i=@rothemail-net.20210112.gappssmtp.com header.b="vgUrq4Hd"; dkim-atps=neutral Received: by mail-oi1-x22b.google.com with SMTP id r83so4923338oih.2 for ; Thu, 27 Oct 2022 20:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothemail-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=ZTPVpdQPJ0vurOhdlddImO+6D58jD4bRP983l5lu4lc=; b=vgUrq4HdbQvNLcqT0Oa/o0OPhMUjNBuSA/Nx37+VlFrdOCqocB8ClIg+S1tJWjKdbh TQu7I5xP2El0CozDxo+O8xbaSudyAjIKpPkTO/WM2tZE8RqxRDLFXSAWG7ffF/B7ItPG zpNN27fyd5dPkFgN+CG1skdHcmScou4+UxT4NztD4XfZZeBwQDkVXOhjNvhK2H6EzxpR rM1MLTwXiRy7kocgp+AAT6XOMhy2zpzWgmeI20SoRohwy6G6ut2T7c4/h6NcWv9TTmrU W0WGLSPATd0agf77/K+4hFsk8ypGeZHSM26DclrH3EplWI5QwtFhYGyeWe9wwpgPeW9t +msQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ZTPVpdQPJ0vurOhdlddImO+6D58jD4bRP983l5lu4lc=; b=pFOXFkfbTkJnChb95smCUPRHZ1i9v/OJhRoyun2ZGbmQ2olhQ6OvYdOpFFD4loqwZl wHE5vZEVs7xg1UpyWQcKR4H5XB+jBXmgMshj+BCVb/rcDdytxtFbFExgaBuYH1O+bV+9 qZVOo5saicIXbF412hhxlcs91234U3qMLI9X654ZC7csdQLs0pvZzoRey1uW11JGT+kz ozrVs/L0Wc8glbZUIPvDB7n7zgJuyjd3q4ZtXj4udVM70fAiZMfdvQqh9r0FAz32itnA otgNsaq5YMfIz9LdI+Dxg4Hm3NmHRBMAjjlDAb3eiOo0sRuhwE0ShCtBm2dy75S+7+Dg R4kA== X-Gm-Message-State: ACrzQf0xftdwTrcmA9pAdGgOIkR7s/EkJfbcIUhKKXdGgXrU8P8GTF/y najUYCKtOgRmL+OXo7/9jfYtEtThWlb6drT7O38= X-Google-Smtp-Source: AMsMyM6GB5Qy4n1T021VviGyKbTAikROTlthHLxCsW/OCVllFKTpF+NeTIqiAUQ1AqMvfEGPzcuMjw== X-Received: by 2002:a05:6808:1209:b0:353:92d1:2a0 with SMTP id a9-20020a056808120900b0035392d102a0mr6863774oil.51.1666927053043; Thu, 27 Oct 2022 20:17:33 -0700 (PDT) Received: from nroth-pc.attlocal.net ([2600:1700:20:20c0:293a:90ce:6463:244d]) by smtp.gmail.com with ESMTPSA id fp19-20020a056870659300b0013626c1a5f6sm1527738oab.10.2022.10.27.20.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 20:17:32 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 27 Oct 2022 22:17:21 -0500 Message-Id: <20221028031726.4849-6-nicholas@rothemail.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028031726.4849-1-nicholas@rothemail.net> References: <20221027224135.348115-1-nicholas@rothemail.net> <20221028031726.4849-1-nicholas@rothemail.net> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 05/10] android: remove references to std::filesystem 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-Patchwork-Original-From: Nicholas Roth via libcamera-devel From: Nicolas Dufresne via libcamera-devel Reply-To: libcamera-devel@lists.libcamera.org Cc: nicholas@rothemail.net Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nicholas Roth Android 11's toolchain does not support std::filesystem, but camera_hal_config.cpp currently uses it. Remove references to std::filesystem in order to support Android <= 11. This adds a very small difference in behaviour, as File::exist() will return true for special files (pipes, character or block devices, ...) while std::filesystem::is_regular_file() doesn't, but I consider this to be a corner case that doesn't matter much. Signed-off-by: Nicholas Roth Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/android/camera_hal_config.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/android/camera_hal_config.cpp b/src/android/camera_hal_config.cpp index bacfe4b9..0e7cde63 100644 --- a/src/android/camera_hal_config.cpp +++ b/src/android/camera_hal_config.cpp @@ -6,7 +6,6 @@ */ #include "camera_hal_config.h" -#include #include #include @@ -160,15 +159,15 @@ CameraHalConfig::CameraHalConfig() */ int CameraHalConfig::parseConfigurationFile() { - std::filesystem::path filePath = LIBCAMERA_SYSCONF_DIR; - filePath /= "camera_hal.yaml"; - if (!std::filesystem::is_regular_file(filePath)) { + std::string filePath = LIBCAMERA_SYSCONF_DIR "/camera_hal.yaml"; + + File file(filePath); + if (!file.exists()) { LOG(HALConfig, Debug) << "Configuration file: \"" << filePath << "\" not found"; return -ENOENT; } - File file(filePath); if (!file.open(File::OpenModeFlag::ReadOnly)) { int ret = file.error(); LOG(HALConfig, Error) << "Failed to open configuration file " From patchwork Fri Oct 28 03:17:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne via libcamera-devel X-Patchwork-Id: 17718 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 13B32C3285 for ; Fri, 28 Oct 2022 03:17:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C6CCD62FC4; Fri, 28 Oct 2022 05:17:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666927062; bh=3SsAYU1JMVdyMQ/zKyB1Y/Gfebk17k1NLKqdg6/vOfI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=0fjSDZMjtJPrmfYnHp2l+NJu2KE+r8pldLg1aaBcSAE8Dr/PeaxrLifbIPrLvSq34 +LFk3APlGYjliwXGYjpF4ZaSmvOYqLMMPq/w4MeBo4j72W1N2KgTDyx7Z5nmXQ6PSX rghwmfjMcY2Tn980c+mK+ayNgBu+IZbgzlkiZQo4qpjBADofrgXLtwByinGBbEyEHO yozwdN3mKsbFRRpZ4w17uRQE/KNH9BANiPoNwbuaYG5oueCdmAIkJi1e/P/rDfQHAy LZhCdZ+6AqZIIsaQWjCMYBQBsE4ECi5V9scTtB/1nhJmcjMfXI/YrBmN6uZPTkZoUM FnZnkPQ+PngFg== Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8E77562FB5 for ; Fri, 28 Oct 2022 05:17:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=rothemail-net.20210112.gappssmtp.com header.i=@rothemail-net.20210112.gappssmtp.com header.b="JwNSZccG"; dkim-atps=neutral Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-12c8312131fso4995354fac.4 for ; Thu, 27 Oct 2022 20:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothemail-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=RPptAfrtD7k2o7VEK6frv0lekwlYg6ZLNrxS93bfFPA=; b=JwNSZccGijEqrToI0s2uAb523FPaK7YRYZjHoqvCozsBau94Xg5o0uuFhh9UR4ROeV kkaAfBtMGXNUOX+pOUnsExe1ipi8HNvzmNFIGBKBexo48T9LAJz8mCUWLpQgNDvZt/7S Vvim4NlDCG6vuUDkyCIdZXpOuNXpt/cI5eo4anfA54LuMQZWY81H4W2devg8YAG84BEd eKoyIM7c5d1q/V2EzUAmp9h+cGB2HgPKWhIoj/fQcRng22uRFVaBJb0UP6c9UO9X0CYC 5WMXf82EYe5/19QCD5p03/PVhk/2Kzqkr7RUjBC5LZYedD9l3wXTNxm2JLy1Mfs4hdRl YjoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=RPptAfrtD7k2o7VEK6frv0lekwlYg6ZLNrxS93bfFPA=; b=mW9M60h5/H+kJeY7iE7X4O9NjuE3OY451Q0hSZHRui56G8bjKM54UIfwYULfdLHdcT 2d+w7qRkrBlVBp8NZWVfab+THNRAyiCfA/13rrrFKIVPq8MDQXcmL7JWnqxN77uIwXDv gKejnZHLavZhGOBy9Wtm3rIKVfMvv48EI4ypxmhhM2hA3/lwWthNab7rFkAT2ecKLfCQ 48gFgq3p9r/AaHJTvKfLYSFP35GEDhgY/zhh6aQf2sHGAHO6KBkRAe+nNS7bZib+McyF DGZFjirnE+A1CRCESMkT+xdP+8xQWoTE3yQsF6WXQP2xoRASAu0tPYxBuy2OtxIDgzQg aiKw== X-Gm-Message-State: ACrzQf1YuXkUzzqDlo+vl83FyXN3W3X/eoQttm1XkFG3sU+HBKOEoWMx 8CiOTgXfdElmttCn8Os3+GhnFRjN8QGZc3Rl+fM= X-Google-Smtp-Source: AMsMyM5Ck4hasarzQ77XKMryQZzln96CcKyMmKPhrvhIInxcMTlRBoEBmmVeQJmElcdpz8/ktK/kiw== X-Received: by 2002:a05:6870:f21b:b0:13a:ffec:f7ba with SMTP id t27-20020a056870f21b00b0013affecf7bamr7969090oao.218.1666927053860; Thu, 27 Oct 2022 20:17:33 -0700 (PDT) Received: from nroth-pc.attlocal.net ([2600:1700:20:20c0:293a:90ce:6463:244d]) by smtp.gmail.com with ESMTPSA id fp19-20020a056870659300b0013626c1a5f6sm1527738oab.10.2022.10.27.20.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 20:17:33 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 27 Oct 2022 22:17:22 -0500 Message-Id: <20221028031726.4849-7-nicholas@rothemail.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028031726.4849-1-nicholas@rothemail.net> References: <20221027224135.348115-1-nicholas@rothemail.net> <20221028031726.4849-1-nicholas@rothemail.net> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 06/10] ipa: raspberry: replace abs() with std::abs() 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-Patchwork-Original-From: Nicholas Roth via libcamera-devel From: Nicolas Dufresne via libcamera-devel Reply-To: libcamera-devel@lists.libcamera.org Cc: nicholas@rothemail.net Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nicholas Roth pwl.cpp uses abs() instead of std::abs(), which causes unexpected behavior in the Clang compiler used for Android. Replace with C++-standard absolute value function std::abs(), which supports double-precision absolute values in a standard way. Signed-off-by: Nicholas Roth Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Naushir Patuck --- src/ipa/raspberrypi/controller/pwl.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ipa/raspberrypi/controller/pwl.cpp b/src/ipa/raspberrypi/controller/pwl.cpp index c59f5fa1..70c2e24b 100644 --- a/src/ipa/raspberrypi/controller/pwl.cpp +++ b/src/ipa/raspberrypi/controller/pwl.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include "pwl.h" @@ -168,7 +169,7 @@ Pwl Pwl::compose(Pwl const &other, const double eps) const while (thisSpan != (int)points_.size() - 1) { double dx = points_[thisSpan + 1].x - points_[thisSpan].x, dy = points_[thisSpan + 1].y - points_[thisSpan].y; - if (abs(dy) > eps && + if (std::abs(dy) > eps && otherSpan + 1 < (int)other.points_.size() && points_[thisSpan + 1].y >= other.points_[otherSpan + 1].x + eps) { @@ -181,7 +182,7 @@ Pwl Pwl::compose(Pwl const &other, const double eps) const points_[thisSpan].y) * dx / dy; thisY = other.points_[++otherSpan].x; - } else if (abs(dy) > eps && otherSpan > 0 && + } else if (std::abs(dy) > eps && otherSpan > 0 && points_[thisSpan + 1].y <= other.points_[otherSpan - 1].x - eps) { /* From patchwork Fri Oct 28 03:17:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne via libcamera-devel X-Patchwork-Id: 17719 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 0BCD3C3286 for ; Fri, 28 Oct 2022 03:17:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A0A9862FD3; Fri, 28 Oct 2022 05:17:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666927063; bh=DdOeO4Y73eQfxf8oqth1QoKEXEDG56YIYNMB+7UXQco=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=GJLiHkNKDYDwAnUtInU9Wnf+AzAcKiEFDEtEWYOzYOloqa7W9RZDR8dPVy26C9FpZ Bd/5Ct7JDBsnL778Cts/6plT/+yE+jCmqSsy1lNEO9mXuTuU6Ek27HBeUVejH4Q75f +BLXVMQIIvilNFrXtqFsboWiz/+rKYJmSGxPAfaJooJATYwGdEyxxf51LdLE+bR8n6 n6AzffBdghY6d7wICyti1lDwYdEfT5EulfonLtpJHaGLKVwYSKDyRWF5uXnhJdZlAq 4cgPQcwBfFYITfEPyfUjGoP5M33Rq50nCQkuYbBPzGVB73i6DARXW8OvVgot4qITuD +q6+q7QJDhv8g== Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4964462FA6 for ; Fri, 28 Oct 2022 05:17:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=rothemail-net.20210112.gappssmtp.com header.i=@rothemail-net.20210112.gappssmtp.com header.b="2L9GeHNW"; dkim-atps=neutral Received: by mail-oi1-x22d.google.com with SMTP id s125so4430956oib.6 for ; Thu, 27 Oct 2022 20:17:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothemail-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=53GjDLX02zSG1mRkq78FTX8/GBMkyCcDPMdpbL8fvGw=; b=2L9GeHNWaiXwoVHke/WHjBiSvTVLmvtpDNHFlECU/hK982l0J7yJq6RPKNh2kmTcf6 fi1Hpt5ifw6g2HuqdLEBzRlnYVMfq5NCjTjP+lmxw+XJz5Grmsd2TZInfRWFNx+5bMjV hNyijwwhXvc76PErsian/bggAvsbMOXKdZhj+enUE6Q3hDky4lBCcWfGw3HQGN4Wt4Aw 5iNs+y54i6JD21rYTM2Dxc7uvSjcAl06pL7PO8w9+BcY0ZHrp3hKL//h4QX3q8BfG/3L W8UpAE3xaK2y2DDXoV8+/xzJ1dF+ytKnlKZJ7LjCI8QwuLAuNIR/JxRLo8A1lerg9XoK g2VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=53GjDLX02zSG1mRkq78FTX8/GBMkyCcDPMdpbL8fvGw=; b=zBDi3nrWVsHJcyIydpKh+nuHEAPkUOMJGKgLz1/Nx0G+08XVudmo7ybEYK2pCAnRdl zKzVcFagFADCWKvdqhondLmA4Q6zB4RPFu9342Zg8+/wXYaRXTjKWUbPHtSkjAcxrTWf BfEwUvke9kb7POntjAK4PlTPUuQ6HH7Tam3KGmPEOLNfpFoo9hl40bitzryrk00tkcv3 1Fw7JPHmRjOd8bDRBdh4+PkWlZGHricm8BFr8l8KedPuDa0CUWKk4ZfT4jlFvkkT7JaZ OCCC1F+xwappq+22uP+cHi48gv+wSPgq+hfNIh4/7pgMUHYKrGITJ4POjVsoMf+Eodc9 Mc8w== X-Gm-Message-State: ACrzQf2I8Vu8yhkuS90TQjRzxEFEIyZUelTAwTm6AbaA/e5ObIsvTOQo B7cE0q7RulgPZez+dGf489RyPx5Ws4ZYxNxuUbw= X-Google-Smtp-Source: AMsMyM5sL5j5fycTQW+6i46MhQ3txIljRJf7h8iIm6eBSlbPiVzC/ytn2VlA6Addc5Ea8z7rvwg0Aw== X-Received: by 2002:a05:6808:1186:b0:353:b77a:a481 with SMTP id j6-20020a056808118600b00353b77aa481mr6804390oil.199.1666927054513; Thu, 27 Oct 2022 20:17:34 -0700 (PDT) Received: from nroth-pc.attlocal.net ([2600:1700:20:20c0:293a:90ce:6463:244d]) by smtp.gmail.com with ESMTPSA id fp19-20020a056870659300b0013626c1a5f6sm1527738oab.10.2022.10.27.20.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 20:17:34 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 27 Oct 2022 22:17:23 -0500 Message-Id: <20221028031726.4849-8-nicholas@rothemail.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028031726.4849-1-nicholas@rothemail.net> References: <20221027224135.348115-1-nicholas@rothemail.net> <20221028031726.4849-1-nicholas@rothemail.net> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 07/10] libcamera: make libdl optional when provided 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-Patchwork-Original-From: Nicholas Roth via libcamera-devel From: Nicolas Dufresne via libcamera-devel Reply-To: libcamera-devel@lists.libcamera.org Cc: nicholas@rothemail.net Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nicholas Roth Currently, libdl is always required. Sometimes, the C++ runtime includes a dynamic loader, which is the case for Android. Additionally, Android 11 does not have libdl. This fix allows libcamera to build on Android. Signed-off-by: Nicholas Roth Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- src/libcamera/meson.build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 5f39d2e2..0494e808 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -65,7 +65,12 @@ subdir('ipa') subdir('pipeline') subdir('proxy') -libdl = cc.find_library('dl') +null_dep = dependency('', required : false) + +libdl = null_dep +if not cc.has_function('dlopen') + libdl = cc.find_library('dl') +endif libudev = dependency('libudev', required : false) libyaml = dependency('yaml-0.1', required : false) From patchwork Fri Oct 28 03:17:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne via libcamera-devel X-Patchwork-Id: 17720 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 D7372BD16B for ; Fri, 28 Oct 2022 03:17:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 81A9962FD1; Fri, 28 Oct 2022 05:17:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666927064; bh=uYdZd5ooHVKC5fykrTFeNa3vGKYdFi9HN0ca8IDJYbQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=svD/T0/MvM/at9rbCP4ev0GSozrepvf/KnXfofjByZ/GbVZK3h28SXpGO1Sd/QzDH r1L2qU/eehhrnV9hrnr6FY0OaJ5etegZGhMm+Ljk4t/WU+/yh58835I/f1eu9pTamd MoKjPQNjuF93MZeWIvfhJ8TvUaCcVQgO+3+MLm/kLM6VvPduT87Lxx4uWvXUZ6fKJK t/ZY2HlGxEfWFJwjFl93nnZYap9+LeTZ10nLkobvrpjvgW189LicCSaT6+646sasmf DSOa3Q8N9+ALmtyNQGQcpxqkwYkMitG3mjjEFjpw1y9h2ex03xQLsCn2oAHjbmoJ77 +tewqw6SV8UEQ== Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 33FA962FC2 for ; Fri, 28 Oct 2022 05:17:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=rothemail-net.20210112.gappssmtp.com header.i=@rothemail-net.20210112.gappssmtp.com header.b="A8G7lV+a"; dkim-atps=neutral Received: by mail-oi1-x22e.google.com with SMTP id u132so4980257oib.0 for ; Thu, 27 Oct 2022 20:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothemail-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=OrR17ZcndUu6E8+nQhvZfP/G7yO3m+iusFv1/hMho8o=; b=A8G7lV+a7Xy1zltZ9rZcH0zDeEiF1+Zhy3eEX/x8DxTKIJzdy/JywZhnk7Yptbp5Ik al6/tVQFfT6Hzu/0g6HuDrctlZ32pxvoSbmaTF+xSe17CAngYnkzmDZwG7Xb8oiAruoF 95jxYnjE2i9kF7dUb3PQI5MpgETuzGZxVWc4a/bEauK4ixH7iXl7yXIzRIMlPeEZ0mt+ g12ZJPNCeXVEgj+YDfCuHcar5ZOEYXrBsZMlIX5SfWb1st8D82fiaDhIHjauP7ZICaab mUGbCPE/VmMSF/fFU1uilDFbGR+KxINkZWkeO8tBbzmuWeEeNAXT8glqDPjQSofck3W1 C/RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=OrR17ZcndUu6E8+nQhvZfP/G7yO3m+iusFv1/hMho8o=; b=kdBXD6fTA+1zZNtrOfZpHNkBpW41NIcEH28/pWN+72ZlaWtjsn07nRx0X30BO2z5RU 76Kkuna6y1M/zC+XoRi3GpzZleQRNC3Qi+ZHPZaTh6lyL1MHzVzj8Xt98kgzuSCweLAG A4/yB5yfhqToPXDTLblK8VdFqHw23E9+ZoKBnPRRUczppWSmqKMhjYOPh8/DlIaTO90T Ni1wf8bN9nU/+jZaB2q5BSeD5d5LeB282sJmPHSRZR+vK8lj05ctgdynr+SPez4Ibz7p 8YrwZuCAx5VDuozXTOoXiMSCd8lIom1gYLv+TPMF0MG/UlQIIq2xMC0N6uXyZML9enLr 2Y4Q== X-Gm-Message-State: ACrzQf1kK0zUz7Kzdr6WXGZnCQLZXNQV+nz8miHI5i07l/vs3y6FZEvz /yOePFbfMPbVyLm8UNRghBgSOWl0h3yCl3/2P6Q= X-Google-Smtp-Source: AMsMyM6NnQus5BGPnUvehcP9CigNJbonA4ws3JhbvmFJCOZRD86Pp3E0hxJBrZsGhgQ2ynRVB7D5FA== X-Received: by 2002:a05:6808:130c:b0:355:39af:eb4f with SMTP id y12-20020a056808130c00b0035539afeb4fmr7071526oiv.218.1666927055332; Thu, 27 Oct 2022 20:17:35 -0700 (PDT) Received: from nroth-pc.attlocal.net ([2600:1700:20:20c0:293a:90ce:6463:244d]) by smtp.gmail.com with ESMTPSA id fp19-20020a056870659300b0013626c1a5f6sm1527738oab.10.2022.10.27.20.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 20:17:34 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 27 Oct 2022 22:17:24 -0500 Message-Id: <20221028031726.4849-9-nicholas@rothemail.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028031726.4849-1-nicholas@rothemail.net> References: <20221027224135.348115-1-nicholas@rothemail.net> <20221028031726.4849-1-nicholas@rothemail.net> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 08/10] android: add makefiles to build inline with AOSP 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-Patchwork-Original-From: Nicholas Roth via libcamera-devel From: Nicolas Dufresne via libcamera-devel Reply-To: libcamera-devel@lists.libcamera.org Cc: nicholas@rothemail.net Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nicholas Roth Currently, while libcamera advertises Android support, there is no easy way to integrate libcamera into an Android distribution. This commit adds makefiles that allow libcamera to build inline with AOSP, with one example of how to do so documented in [0]. Note that meson_cross.mk is adapted from the Mesa project [1]. As Android support matures, it will be useful to document how to integrate libcamera for distribution owners [Bug]. [0] https://docs.google.com/document/d/1Sly_VH3w6wFIdE72WXijQegoHZh8IxEnJ9m0hH7GodU/edit [1] https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/android/mesa3d_cross.mk Bug https://bugs.libcamera.org/show_bug.cgi?id=164 Signed-off-by: Nichoals Roth --- android/Android.mk | 86 ++++++++++++ android/meson_cross.mk | 298 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 384 insertions(+) create mode 100644 android/Android.mk create mode 100644 android/meson_cross.mk diff --git a/android/Android.mk b/android/Android.mk new file mode 100644 index 00000000..ff0d1472 --- /dev/null +++ b/android/Android.mk @@ -0,0 +1,86 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2021, GlobalLogic Ukraine +# Copyright (C) 2021, Roman Stratiienko (r.stratiienko@gmail.com) +# +# Android.mk - Android makefile +# + +ifneq ($(filter true, $(BOARD_LIBCAMERA_USES_MESON_BUILD)),) + +LOCAL_PATH := $(call my-dir) +LIBCAMERA_TOP := $(dir $(LOCAL_PATH)) +LIBCAMERA_MESON_VERSION := .0.0.1 + +include $(CLEAR_VARS) + +LOCAL_SHARED_LIBRARIES := libc libexif libjpeg libyuv_chromium libdl libyaml +MESON_GEN_PKGCONFIGS := libexif libjpeg yaml-0.1 libyuv dl + +ifeq ($(TARGET_IS_64_BIT),true) +LOCAL_MULTILIB := 64 +else +LOCAL_MULTILIB := 32 +endif +include $(LOCAL_PATH)/meson_cross.mk + +ifdef TARGET_2ND_ARCH +LOCAL_MULTILIB := 32 +include $(LOCAL_PATH)/meson_cross.mk +endif + +#------------------------------------------------------------------------------- + +define libcamera-lib +LOCAL_MODULE_CLASS := SHARED_LIBRARIES +LOCAL_MODULE := $1 +LOCAL_VENDOR_MODULE := true +LOCAL_MODULE_RELATIVE_PATH := $2 +ifdef TARGET_2ND_ARCH +LOCAL_SRC_FILES_$(TARGET_ARCH) := $(call relative_top_path,$(LOCAL_PATH))$($3) +LOCAL_SRC_FILES_$(TARGET_2ND_ARCH) := $(call relative_top_path,$(LOCAL_PATH))$(2ND_$3) +LOCAL_MULTILIB := both +else +LOCAL_SRC_FILES := $(call relative_top_path,$(LOCAL_PATH))$($3) +endif +LOCAL_CHECK_ELF_FILES := false +LOCAL_MODULE_SUFFIX := .so$(${4}) +include $(BUILD_PREBUILT) +include $(CLEAR_VARS) +endef + +__MY_SHARED_LIBRARIES := $(LOCAL_SHARED_LIBRARIES) +include $(CLEAR_VARS) +LOCAL_SHARED_LIBRARIES := $(__MY_SHARED_LIBRARIES) + +# Modules 'libcamera', produces '/vendor/lib{64}/libcamera.so' +$(eval $(call libcamera-lib,libcamera,,LIBCAMERA_BIN,LIBCAMERA_MESON_VERSION)) +# Modules 'libcamera-base', produces '/vendor/lib{64}/libcamera-base.so' +$(eval $(call libcamera-lib,libcamera-base,,LIBCAMERA_BASE_BIN,LIBCAMERA_MESON_VERSION)) +# Modules 'ipa_rkisp1', produces '/vendor/lib{64}/ipa_rkisp1.so' +$(eval $(call libcamera-lib,ipa_rkisp1,,LIBCAMERA_IPA_RKISP1_BIN,)) +# Modules 'ipa_rkisp1', produces '/vendor/lib{64}/ipa_rpi.so' +$(eval $(call libcamera-lib,ipa_rpi,,LIBCAMERA_IPA_RASPBERRYPI_BIN,)) +# Modules 'ipa_rkisp1', produces '/vendor/lib{64}/ipa_ipu3.so' +$(eval $(call libcamera-lib,ipa_ipu3,,LIBCAMERA_IPA_IPU3_BIN,)) +# Modules 'ipa_rkisp1', produces '/vendor/lib{64}/ipa_vimc.so' +$(eval $(call libcamera-lib,ipa_vimc,,LIBCAMERA_IPA_VIMC_BIN,)) + +# Modules 'camera.libcamera', produces '/vendor/lib{64}/hw/camera.libcamera.so' HAL +$(eval $(call libcamera-lib,camera.libcamera,hw,LIBCAMERA_HAL_BIN,)) + +LOCAL_SHARED_LIBRARIES += libcamera libcamera-base ipa_rkisp1 ipa_rpi ipa_ipu3 ipa_vimc +LOCAL_REQUIRED_MODULES := libcamera libcamera-base ipa_rkisp1 ipa_rpi ipa_ipu3 ipa_vimc + +$(shell mkdir -p $(TARGET_OUT_VENDOR_ETC)/rkisp1/) +$(shell mkdir -p $(TARGET_OUT_VENDOR_ETC)/rpi/) +$(shell mkdir -p $(TARGET_OUT_VENDOR_ETC)/ipu3/) +$(shell mkdir -p $(TARGET_OUT_VENDOR_ETC)/vimc/) +$(shell cp $(LIBCAMERA_IPA_RKISP1_CONFIGS)/* $(TARGET_OUT_VENDOR_ETC)/rkisp1/) +$(shell cp $(LIBCAMERA_IPA_RASPBERRYPI_CONFIGS)/* $(TARGET_OUT_VENDOR_ETC)/rpi/) +$(shell cp $(LIBCAMERA_IPA_IPU3_CONFIGS)/* $(TARGET_OUT_VENDOR_ETC)/ipu3/) +$(shell cp $(LIBCAMERA_IPA_VIMC_CONFIGS)/* $(TARGET_OUT_VENDOR_ETC)/vimc/) + +#------------------------------------------------------------------------------- + +endif diff --git a/android/meson_cross.mk b/android/meson_cross.mk new file mode 100644 index 00000000..7a222f9c --- /dev/null +++ b/android/meson_cross.mk @@ -0,0 +1,298 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2021, GlobalLogic Ukraine +# Copyright (C) 2021, Roman Stratiienko (r.stratiienko@gmail.com) +# +# meson_cross.mk - Android makefile +# + +# Turn "dir1/dir2/dir3/dir4" into "../../../../" +define relative_top_path +$(eval __s:=) \ +$(foreach tmp,$(subst /,$(space),$1),$(eval __s:=$(__s)../)) \ +$(__s) +endef + +MY_PATH := $(call my-dir) + +AOSP_ABSOLUTE_PATH := $(realpath .) + +libcam_m_dummy_$(LOCAL_MULTILIB) := $(TARGET_OUT_INTERMEDIATES)/LIBCAM_DUMMY_$(LOCAL_MULTILIB)/dummy.c + +$(libcam_m_dummy_$(LOCAL_MULTILIB)): + mkdir -p $(dir $@) + touch $@ + +LOCAL_SRC_FILES := $(call relative_top_path,$(MY_PATH))$(libcam_m_dummy_$(LOCAL_MULTILIB)) +LOCAL_VENDOR_MODULE := true +LOCAL_MODULE := libcam.dummy.$(LOCAL_MULTILIB) + +# Prepare intermediate variables by AOSP make/core internals +include $(BUILD_SHARED_LIBRARY) + +LOCAL_PATH := $(MY_PATH) + +link_deps := \ + $(built_static_libraries) \ + $(built_shared_libraries) \ + $(built_whole_libraries) \ + $(strip $(all_objects)) \ + $(my_target_libatomic) \ + $(my_target_libcrt_builtins) \ + $(my_target_crtbegin_so_o) \ + $(my_target_crtend_so_o) + +# Build using intermediate variables provided by AOSP make/core internals +M_TARGET_PREFIX := $(my_2nd_arch_prefix) + +LIBCAMERA_LIB_DIR := lib$(subst 32,,$(LOCAL_MULTILIB)) + +MESON_OUT_DIR := $($(M_TARGET_PREFIX)TARGET_OUT_INTERMEDIATES)/MESON_LIBCAMERA +MESON_GEN_DIR := $(MESON_OUT_DIR)_GEN +MESON_GEN_FILES_TARGET := $(MESON_GEN_DIR)/.timestamp + +$(M_TARGET_PREFIX)LIBCAMERA_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libcamera.so +$(M_TARGET_PREFIX)LIBCAMERA_HAL_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libcamera-hal.so +$(M_TARGET_PREFIX)LIBCAMERA_BASE_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libcamera-base.so +$(M_TARGET_PREFIX)LIBCAMERA_IPA_RKISP1_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libcamera/ipa_rkisp1.so +$(M_TARGET_PREFIX)LIBCAMERA_IPA_RASPBERRYPI_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libcamera/ipa_rpi.so +$(M_TARGET_PREFIX)LIBCAMERA_IPA_IPU3_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libcamera/ipa_ipu3.so +$(M_TARGET_PREFIX)LIBCAMERA_IPA_VIMC_BIN := $(MESON_OUT_DIR)/install/usr/local/lib/libcamera/ipa_vimc.so +$(M_TARGET_PREFIX)LIBCAMERA_IPA_RKISP1_CONFIGS := $(MESON_OUT_DIR)/install/usr/local/share/libcamera/ipa/rkisp1 +$(M_TARGET_PREFIX)LIBCAMERA_IPA_RASPBERRYPI_CONFIGS := $(MESON_OUT_DIR)/install/usr/local/share/libcamera/ipa/raspberrypi +$(M_TARGET_PREFIX)LIBCAMERA_IPA_IPU3_CONFIGS := $(MESON_OUT_DIR)/install/usr/local/share/libcamera/ipa/ipu3 +$(M_TARGET_PREFIX)LIBCAMERA_IPA_VIMC_CONFIGS := $(MESON_OUT_DIR)/install/usr/local/share/libcamera/ipa/vimc + +LIBCAMERA_BINS := \ + $($(M_TARGET_PREFIX)LIBCAMERA_BIN) \ + $($(M_TARGET_PREFIX)LIBCAMERA_HAL_BIN) \ + $($(M_TARGET_PREFIX)LIBCAMERA_BASE_BIN) \ + $($(M_TARGET_PREFIX)LIBCAMERA_IPA_RKISP1_BIN) \ + $($(M_TARGET_PREFIX)LIBCAMERA_IPA_RASPBERRYPI_BIN) \ + $($(M_TARGET_PREFIX)LIBCAMERA_IPA_IPU3_BIN) \ + $($(M_TARGET_PREFIX)LIBCAMERA_IPA_VIMC_BIN) + +MESON_GEN_NINJA := \ + cd $(MESON_OUT_DIR) && PATH=/usr/bin:/usr/local/bin:$$PATH meson ./build \ + --cross-file $(AOSP_ABSOLUTE_PATH)/$(MESON_GEN_DIR)/aosp_cross \ + --buildtype=release \ + -Dandroid=enabled \ + -Dipas=$(subst $(space),$(comma),$(BOARD_LIBCAMERA_IPAS)) \ + -Dpipelines=$(subst $(space),$(comma),$(BOARD_LIBCAMERA_PIPELINES)) \ + -Dsysconfdir=/vendor/etc \ + -Dtest=false \ + -Dwerror=false \ + -Dallow_unsigned_ipas_in_process=true + +MESON_BUILD := PATH=/usr/bin:/bin:/sbin:$$PATH ninja -C $(MESON_OUT_DIR)/build + +$(MESON_GEN_FILES_TARGET): MESON_CPU_FAMILY := $(subst arm64,aarch64,$(TARGET_$(M_TARGET_PREFIX)ARCH)) + +define create-pkgconfig +echo -e "Name: $2" \ + "\nDescription: $2" \ + "\nVersion: $3" > $1/$2.pc + +endef + +# Taken from build/make/core/binary.mk. We need this +# to use definitions from build/make/core/definitions.mk +$(MESON_GEN_FILES_TARGET): PRIVATE_GLOBAL_C_INCLUDES := $(my_target_global_c_includes) +$(MESON_GEN_FILES_TARGET): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_target_global_c_system_includes) + +$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $(my_target_global_conlyflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags) + +$(MESON_GEN_FILES_TARGET): PRIVATE_2ND_ARCH_VAR_PREFIX := $(M_TARGET_PREFIX) +$(MESON_GEN_FILES_TARGET): PRIVATE_CC := $(my_cc) +$(MESON_GEN_FILES_TARGET): PRIVATE_LINKER := $(my_linker) +$(MESON_GEN_FILES_TARGET): PRIVATE_CXX := $(my_cxx) +$(MESON_GEN_FILES_TARGET): PRIVATE_CXX_LINK := $(my_cxx_link) +$(MESON_GEN_FILES_TARGET): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS) +$(MESON_GEN_FILES_TARGET): PRIVATE_ASFLAGS := $(my_asflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_CONLYFLAGS := $(my_conlyflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_CFLAGS := $(my_cflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_CPPFLAGS := $(my_cppflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_CFLAGS_NO_OVERRIDE := $(my_cflags_no_override) +$(MESON_GEN_FILES_TARGET): PRIVATE_CPPFLAGS_NO_OVERRIDE := $(my_cppflags_no_override) +$(MESON_GEN_FILES_TARGET): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG) +$(MESON_GEN_FILES_TARGET): PRIVATE_DEBUG_CFLAGS := $(debug_cflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_C_INCLUDES := $(my_c_includes) +$(MESON_GEN_FILES_TARGET): PRIVATE_IMPORTED_INCLUDES := $(imported_includes) +$(MESON_GEN_FILES_TARGET): PRIVATE_LDFLAGS := $(my_ldflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_LDLIBS := $(my_ldlibs) +$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_TIDY_CHECKS := $(my_tidy_checks) +$(MESON_GEN_FILES_TARGET): PRIVATE_TIDY_FLAGS := $(my_tidy_flags) +$(MESON_GEN_FILES_TARGET): PRIVATE_ARFLAGS := $(my_arflags) +$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries) +$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries) +$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries) +$(MESON_GEN_FILES_TARGET): PRIVATE_ALL_OBJECTS := $(strip $(all_objects)) + +$(MESON_GEN_FILES_TARGET): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) + +$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_LIBCRT_BUILTINS := $(my_target_libcrt_builtins) +$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic) +$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o) +$(MESON_GEN_FILES_TARGET): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o) +## + +define m-lld-flags + -nostdlib -Wl,--gc-sections \ + $(PRIVATE_TARGET_CRTBEGIN_SO_O) \ + $(PRIVATE_ALL_OBJECTS) \ + -Wl,--whole-archive \ + $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \ + -Wl,--no-whole-archive \ + $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ + $(PRIVATE_ALL_STATIC_LIBRARIES) \ + $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ + $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \ + $(PRIVATE_TARGET_LIBCRT_BUILTINS) \ + $(PRIVATE_TARGET_LIBATOMIC) \ + $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ + $(PRIVATE_LDFLAGS) \ + $(PRIVATE_ALL_SHARED_LIBRARIES) \ + $(PRIVATE_TARGET_CRTEND_SO_O) \ + $(PRIVATE_LDLIBS) +endef + +define m-lld-flags-cleaned + $(subst prebuilts/,$(AOSP_ABSOLUTE_PATH)/prebuilts/, \ + $(subst out/,$(AOSP_ABSOLUTE_PATH)/out/, \ + $(subst -Wl$(comma)--fatal-warnings,, \ + $(subst -Wl$(comma)--no-undefined-version,, \ + $(subst -Wl$(comma)--gc-sections,, \ + $(patsubst %dummy.o,, \ + $(m-lld-flags))))))) +endef + +define m-cpp-flags + $(PRIVATE_TARGET_GLOBAL_CFLAGS) \ + $(PRIVATE_TARGET_GLOBAL_CPPFLAGS) \ + $(PRIVATE_ARM_CFLAGS) \ + $(PRIVATE_RTTI_FLAG) \ + $(PRIVATE_CFLAGS) \ + $(PRIVATE_CPPFLAGS) \ + $(PRIVATE_DEBUG_CFLAGS) \ + $(PRIVATE_CFLAGS_NO_OVERRIDE) \ + $(PRIVATE_CPPFLAGS_NO_OVERRIDE) +endef + +define m-c-flags + $(PRIVATE_TARGET_GLOBAL_CFLAGS) \ + $(PRIVATE_TARGET_GLOBAL_CONLYFLAGS) \ + $(PRIVATE_ARM_CFLAGS) \ + $(PRIVATE_CFLAGS) \ + $(PRIVATE_CONLYFLAGS) \ + $(PRIVATE_DEBUG_CFLAGS) \ + $(PRIVATE_CFLAGS_NO_OVERRIDE) +endef + +define filter-c-flags + $(subst -std=gnu++17,, \ + $(subst -stdlib=libc++,, \ + $(subst -fno-rtti,, \ + $(patsubst -W%,, \ + $1)))) +endef + +define m-c-includes-common +$(addprefix -I , $(PRIVATE_C_INCLUDES)) \ +$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),,\ + $(addprefix -I ,\ + $(filter-out $(PRIVATE_C_INCLUDES), \ + $(PRIVATE_GLOBAL_C_INCLUDES))) \ + $(addprefix -isystem ,\ + $(filter-out $(PRIVATE_C_INCLUDES), \ + $(PRIVATE_GLOBAL_C_SYSTEM_INCLUDES)))) +endef + +ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 30; echo $$?), 0) +# Android 11+ +define m-c-includes +$(foreach i,$(PRIVATE_IMPORTED_INCLUDES),$(EXPORTS.$(i)))\ +$(m-c-includes-common) +endef +define postprocess-includes +endef +else +# Android 10,9 +$(MESON_GEN_FILES_TARGET): PRIVATE_IMPORT_INCLUDES := $(import_includes) +define postprocess-includes + echo " $$(cat $(PRIVATE_IMPORT_INCLUDES)) " > $(MESON_GEN_DIR)/import_includes && \ + sed -i -e ':a;N;$$!ba;s/\n/ /g' \ + -e 's# \{2,\}# #g' \ + -e 's# -isystem # -isystem#g' \ + -e 's# -I # -I#g' \ + -e 's# -I# -I$(AOSP_ABSOLUTE_PATH)/#g' \ + -e 's# -isystem# -isystem$(AOSP_ABSOLUTE_PATH)/#g' \ + -e "s# #','#g" $(MESON_GEN_DIR)/import_includes && \ + sed -i "s#<_IMPORT_INCLUDES>#$$(cat $(MESON_GEN_DIR)/import_includes)#g" $(MESON_GEN_DIR)/aosp_cross +endef +define m-c-includes +<_IMPORT_INCLUDES> $(m-c-includes-common) +endef +endif + +define m-c-abs-includes + $(subst $(space)-isystem,$(space)-isystem$(AOSP_ABSOLUTE_PATH)/, \ + $(subst $(space)-I, -I$(AOSP_ABSOLUTE_PATH)/, \ + $(subst $(space)-I$(space),$(space)-I, \ + $(subst $(space)-isystem$(space),$(space)-isystem, \ + $(strip $(m-c-includes)))))) +endef + +$(MESON_GEN_FILES_TARGET): MESON_GEN_PKGCONFIGS:=$(MESON_GEN_PKGCONFIGS) +$(MESON_GEN_FILES_TARGET): MESON_GEN_DIR:=$(MESON_GEN_DIR) +$(MESON_GEN_FILES_TARGET): $(sort $(shell find -L $(LIBCAMERA_TOP) -not -path '*/\.*')) + mkdir -p $(dir $@) + echo -e "[properties]\n" \ + "c_args = [$(foreach flag, $(call filter-c-flags,$(m-c-flags) $(m-c-abs-includes)),'$(flag)', )'']\n" \ + "cpp_args = [$(foreach flag, $(call filter-c-flags,$(m-cpp-flags) $(m-c-abs-includes)),'$(flag)', )'']\n" \ + "c_link_args = [$(foreach flag, $(m-lld-flags-cleaned),'$(flag)',)'']\n" \ + "cpp_link_args = [$(foreach flag, $(m-lld-flags-cleaned),'$(flag)',)'']\n" \ + "needs_exe_wrapper = true\n" \ + "[binaries]\n" \ + "ar = '$(AOSP_ABSOLUTE_PATH)/$($($(M_TARGET_PREFIX))TARGET_AR)'\n" \ + "c = [$(foreach arg,$(PRIVATE_CC),'$(subst prebuilts/,$(AOSP_ABSOLUTE_PATH)/prebuilts/,$(arg))',)'']\n" \ + "cpp = [$(foreach arg,$(PRIVATE_CXX),'$(subst prebuilts/,$(AOSP_ABSOLUTE_PATH)/prebuilts/,$(arg))',)'']\n" \ + "c_ld = 'lld'\n" \ + "cpp_ld = 'lld'\n\n" \ + "pkgconfig = ['env', 'PKG_CONFIG_LIBDIR=' + '$(AOSP_ABSOLUTE_PATH)/$(MESON_GEN_DIR)', '/usr/bin/pkg-config']\n\n" \ + "llvm-config = '/dev/null'\n" \ + "[host_machine]\n" \ + "system = 'linux'\n" \ + "cpu_family = '$(MESON_CPU_FAMILY)'\n" \ + "cpu = '$(MESON_CPU_FAMILY)'\n" \ + "endian = 'little'" > $(dir $@)/aosp_cross + + # + $(foreach pkg, $(MESON_GEN_PKGCONFIGS), $(call create-pkgconfig,$(dir $@),$(word 1, $(subst :, ,$(pkg))),$(word 2, $(subst :, ,$(pkg))))) + touch $@ + +$(MESON_OUT_DIR)/.build.timestamp: MESON_GEN_NINJA:=$(MESON_GEN_NINJA) +$(MESON_OUT_DIR)/.build.timestamp: MESON_BUILD:=$(MESON_BUILD) +$(MESON_OUT_DIR)/.build.timestamp: $(MESON_GEN_FILES_TARGET) $(link_deps) + rm -rf $(dir $@) + mkdir -p $(dir $@) + mkdir -p $(dir $@)/build + # Meson will update timestamps in sources directory, continuously retriggering the build + # even if nothing changed. Copy sources into intermediate dir to avoid this effect. + cp -r $(LIBCAMERA_TOP)/* $(dir $@) + $(MESON_GEN_NINJA) + $(MESON_BUILD) + touch $@ + +$(MESON_OUT_DIR)/install/.install.timestamp: MESON_BUILD:=$(MESON_BUILD) +$(MESON_OUT_DIR)/install/.install.timestamp: $(MESON_OUT_DIR)/.build.timestamp + rm -rf $(dir $@) + mkdir -p $(dir $@) + DESTDIR=$(AOSP_ABSOLUTE_PATH)/$(dir $@) $(MESON_BUILD) install + touch $@ + +$(LIBCAMERA_BINS): $(MESON_OUT_DIR)/install/.install.timestamp + echo "Build $@" + touch $@ From patchwork Fri Oct 28 03:17:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne via libcamera-devel X-Patchwork-Id: 17721 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 C43EAC3287 for ; Fri, 28 Oct 2022 03:17:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6583C62FD6; Fri, 28 Oct 2022 05:17:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666927065; bh=uPfBp734F70Nl4/faDEoCE+469eSaTe+2TU432+CN6U=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Sj9Txgd8IxFgSUwhpFOUeIx0+zBFwKPcj0JdT0mbv6NeCQ3cAnTegZKfNGXTPHLlP tyKc6NqmAMROG33Tc0BnZSNuUKCmWNjNvXyiZzSpBN2Z+6Sw+pYeUpOG90N5HiZFoN cTtnN0W8aYZupJXdtmqhU+jdBs/GkCGvZBrE5lHET5PRC7f8b2mIevfXJ+0wAY3XYn MCIMZDvAe7wYjyW1QzZ59WN+1x86/u3QJUirEwdvYm8B+2VehmGb8Mirbdwbanx8ZQ OQMDJDBzlbPAqQTsqgsGEYXdp32haTE+47uZQzUf12EGY2oNVg+3HCR/TZ55JlbsWe gFVnCb+F0fOAg== Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9B2CC62FAD for ; Fri, 28 Oct 2022 05:17:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=rothemail-net.20210112.gappssmtp.com header.i=@rothemail-net.20210112.gappssmtp.com header.b="oOqzTjvv"; dkim-atps=neutral Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-13b23e29e36so4973724fac.8 for ; Thu, 27 Oct 2022 20:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothemail-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=S6elEshRjeYKV2WspXbwSeu79nOguOd5x4rDscK6N9Y=; b=oOqzTjvvX08YAJa5XU9pFTK/n+NaMg7FWwAg0A2h115xVInJbKPxL9wROB5kzO3azR B940iBpEnFirk+tGG4EeiMfzMXrY5LHHEYJrEZy+QMMNeff936/wosL8vzNHHl7rnUDY xg1bPgNchE1hvS/+4bBUM6wJlNtCVfo6SkkDL7dTYTdld6/xkeUnZlF/tQrjFBc+9JE7 +VerkLLB7AUpCnF58hE+uytL361WNk7rTIY2b2z9OC4LvEZdEmO837ka78lm8Ixt1FR2 N6MnKhk3d+YBx0mzLf4JEkpLXnnxipcJVXoy43j0Olh9zmNk64EtlBW7ab5r96uy5v29 sg5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=S6elEshRjeYKV2WspXbwSeu79nOguOd5x4rDscK6N9Y=; b=P7izXvwstjrOTfJyFWmRfhku211nDkgGrfTvjMjdaq7MHzqYT5cnHcB4flezW8GH1u IFemZ+BcujhyyyyZKDlmPjtaFSRNKwGzgli6cPpFI/1LJt7CPy82KSToYl+8+rPZMKt7 b4WW7VUVslRkCtkBqM+Qa2dK/DdFgb0rJvVj3fQ2XrmJCuRvv22DkREO9dWVYaF997/E NG1BAKk5SVOhVUr5+/ZX7z4VeVRo8SF2KWkx1vXs9FjBK9jyQLV3CJBVg0fqxkMt9sM1 EF8sAiAWxaI70YTSPPyNehGlpUBhC8NZdbfNKJX5gXy9B7KoxAwJmQ2/JXkPqMmWvHw3 soXQ== X-Gm-Message-State: ACrzQf0DLmwYZdE9jP08MLtqaXzfL0VSZC57X/dU1kkuXQ1JrJsvY8S6 +D4/eGmjog5b6GfEN7JP/hrBq3kP5aEp+3OJVrM= X-Google-Smtp-Source: AMsMyM54g+qM054PCkV1SXu0eVSoDgG+GbmvoRiE3tJyzzWkJvrWNRmVOB5LTKtPdwI3uFTh7AQ+Aw== X-Received: by 2002:a05:6870:6086:b0:132:e9d6:ea36 with SMTP id t6-20020a056870608600b00132e9d6ea36mr8079790oae.116.1666927055909; Thu, 27 Oct 2022 20:17:35 -0700 (PDT) Received: from nroth-pc.attlocal.net ([2600:1700:20:20c0:293a:90ce:6463:244d]) by smtp.gmail.com with ESMTPSA id fp19-20020a056870659300b0013626c1a5f6sm1527738oab.10.2022.10.27.20.17.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 20:17:35 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 27 Oct 2022 22:17:25 -0500 Message-Id: <20221028031726.4849-10-nicholas@rothemail.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028031726.4849-1-nicholas@rothemail.net> References: <20221027224135.348115-1-nicholas@rothemail.net> <20221028031726.4849-1-nicholas@rothemail.net> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 09/10] ipa: add a flag to disable isolation for Android 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-Patchwork-Original-From: Nicholas Roth via libcamera-devel From: Nicolas Dufresne via libcamera-devel Reply-To: libcamera-devel@lists.libcamera.org Cc: nicholas@rothemail.net Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nicholas Roth Currently, libcamera isolates any IPAs whose signatures cannot be verified. Shared objects are created at build-time, and then signed. The public signing key is embedded in a .cpp file, and libcamera verifies IPA signatures at runtime. When libcamera cannot authenticate an IPA, it runs it out-of-process. This is problematic on three levels: * IPA signing fundamentally does not work on Android for vendor modules like HALs (discussed below) * Executables built to run out-of-process are not ABI-compatible with Android, making isolation infeasible [1] * Linux phone hardware tends to be low-end because of the FOSS requirement, so the performance hit from out-of-process IPA isolation is significant IPA signing fundamentally does not work for Android vendor modules: After we "meson install" built .so files to a known location, Android explicitly access them in PREBUILT_SHARED_LIBRARY or BUILD_PREBUILIT to transform the .so files by stripping symbols among other things [2]. By modifying prebuilt libraries after we have already signed them, the build system renders our signatures useless on Android. Android distribution maintainers can use this flag to disable signature verification, which will allow them to use libcamera. [1] https://github.com/waydroid/waydroid/issues/519 [2] https://cs.android.com/android/platform/superproject/+/master:build/make/core/cc_prebuilt_internal.mk?q=cc_prebuilt_internal Signed-off-by: Nicholas Roth --- meson.build | 4 ++++ meson_options.txt | 5 +++++ src/libcamera/ipa_manager.cpp | 11 +++++++++++ 3 files changed, 20 insertions(+) diff --git a/meson.build b/meson.build index 56910698..883847ef 100644 --- a/meson.build +++ b/meson.build @@ -74,6 +74,10 @@ if cc.has_header_symbol('stdlib.h', 'secure_getenv', prefix : '#define _GNU_SOUR config_h.set('HAVE_SECURE_GETENV', 1) endif +if get_option('allow_unsigned_ipas_in_process') + config_h.set('ALLOW_UNSIGNED_IPAS_IN_PROCESS', 1) +endif + common_arguments = [ '-Wshadow', '-include', meson.current_build_dir() / 'config.h', diff --git a/meson_options.txt b/meson_options.txt index f1d67808..77b21b9a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -64,3 +64,8 @@ option('pycamera', type : 'feature', value : 'disabled', description : 'Enable libcamera Python bindings (experimental)') + +option('allow_unsigned_ipas_in_process', + type : 'boolean', + value : false, + description : 'Allow unsigned IPAs to run in libcamera\'s address space') diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 030ef43f..403cc42a 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -114,6 +114,14 @@ IPAManager::IPAManager() LOG(IPAManager, Warning) << "Public key not valid"; #endif +#if ALLOW_UNSIGNED_IPAS_IN_PROCESS + LOG(IPAManager, Warning) + << "All IPAs running in-process without signature verification." + << " This is recommended only for tightly-managed installs" + << " in contexts where both signature verification and out-of-process" + << " execution are infeasible, such as Android HALs."; +#endif + unsigned int ipaCount = 0; /* User-specified paths take precedence. */ @@ -281,6 +289,9 @@ IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion, bool IPAManager::isSignatureValid([[maybe_unused]] IPAModule *ipa) const { +#if ALLOW_UNSIGNED_IPAS_IN_PROCESS + return true; +#endif #if HAVE_IPA_PUBKEY char *force = utils::secure_getenv("LIBCAMERA_IPA_FORCE_ISOLATION"); if (force && force[0] != '\0') { From patchwork Fri Oct 28 03:17:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dufresne via libcamera-devel X-Patchwork-Id: 17722 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 7FFE6C3285 for ; Fri, 28 Oct 2022 03:17:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 226ED62FD8; Fri, 28 Oct 2022 05:17:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666927066; bh=E2M2gE8AdzSxU0S2gGSqFrwSOir8BrV38NvTiVWiZDo=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=pKbMVbAvErYF1cZRlrbM8d02t3UwvxGdyc4KSagfsqPWAaNF4zPP0kLY3YHH6PemG l2gxn/Oh/QZTPjYf2SmxTY+adHCIvgodG8TWhYZ4/CEKBVS5xbzyhGGAwTbrl7PUfx 7UDzObvNeEJfG/uymVf7UfavStVxUHNkLJm0/Qgk//d1FXq56dU5dBHefE3FerMRzp S9OknsFKWMwtWD4aNzWRWrC9DbrOUz+x3rCtmZpkAtZ0kCU4dlmIEwiknUA7MveTS8 inDqHRrxelBv/Gy7HA7KuWsjn+sjxSM6o51hFi3eaq6AYRZeJ+SGL2Y5kopGBkGSGI 2uVMQijSdjpEw== Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 215D762FC1 for ; Fri, 28 Oct 2022 05:17:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=rothemail-net.20210112.gappssmtp.com header.i=@rothemail-net.20210112.gappssmtp.com header.b="G0ZYeWyj"; dkim-atps=neutral Received: by mail-oi1-x22c.google.com with SMTP id s206so4940364oie.3 for ; Thu, 27 Oct 2022 20:17:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothemail-net.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=6K1PGdxqOtEtfDSAankUdXcm6R3lz9nnSvzIKD/QrHE=; b=G0ZYeWyjriyowYFISGtueEhWmh7Aa6afJ8YAMnQH8bLrxKE8KzPkl73qVNrzJ+gypi IRkGxVV496jvuA4rifpv1y8bCpAM9JNguP6Yu3sr/PQqoaa92xn+OEdbnGH5o9GklL1Q 3IMRN40miVeNV6H7V5U6nhthA3W9SxUnbdl1ZPMnLZmltlqX5e/QO3rgTjRgNE5xHKRw 15G1AzNn15KJ80OlD9KraCJtEkW217z82rv6ZtgnviBuqLi+Tvhnb6KUTX4GDRSuKkB2 JAa2KzV1wFGfVHscRsR8oy8SOy9ChIL5veDEeTsMvB5Z9dgYqsYcFEeapTSV7QG/EzA1 ksSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=6K1PGdxqOtEtfDSAankUdXcm6R3lz9nnSvzIKD/QrHE=; b=IMQP9gp25C/GOgeB+GJX/XkgaKk/U5mVG3o5F+PAXoOYCfuzCMezZtXj9XOiM68GtS 8UpBBatswebXTgFdbA1lOBACQU9omYm166ahOa1pMAW5NLu5wE8gfMuJuxaI4pAoLdqC JJ8pQuQmw0TDImyQJmb6stuwGKho8BXgurNv4m1aDTbICbwhpvvAwvXwnXlo1cvFnjpn CF3b2rLqs0OoxrHkE78JJpZU53gg1MJXdqPNRWa1V/mhHfKkxLvvTlGV7INgXkxPjMeB QsPZoAs2K6sTCI/GyzXVkMrONxdlbeZoGYUQV6bwGzW5UOqGG0FgVFLepYHyCBw2Fob9 3aiQ== X-Gm-Message-State: ACrzQf3Bw8ssbhorf8QVcfHm+/AeneWHS91586FaqhIRJlxY0sXp+IrM odmzlNDOnZHB6gU+pwrc676U7nJSMFc9ai+8HGk= X-Google-Smtp-Source: AMsMyM4VBniTC3qa91E45hMqewZ4I8MQA+E+4m5arVS1SoTrRlAoHGr4IBf3ksrAo0NZqOtG0dprdA== X-Received: by 2002:a05:6808:1a21:b0:355:2173:7975 with SMTP id bk33-20020a0568081a2100b0035521737975mr7150380oib.116.1666927056485; Thu, 27 Oct 2022 20:17:36 -0700 (PDT) Received: from nroth-pc.attlocal.net ([2600:1700:20:20c0:293a:90ce:6463:244d]) by smtp.gmail.com with ESMTPSA id fp19-20020a056870659300b0013626c1a5f6sm1527738oab.10.2022.10.27.20.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 20:17:36 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 27 Oct 2022 22:17:26 -0500 Message-Id: <20221028031726.4849-11-nicholas@rothemail.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028031726.4849-1-nicholas@rothemail.net> References: <20221027224135.348115-1-nicholas@rothemail.net> <20221028031726.4849-1-nicholas@rothemail.net> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 10/10] android: libcamera: add useful debug prints 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-Patchwork-Original-From: Nicholas Roth via libcamera-devel From: Nicolas Dufresne via libcamera-devel Reply-To: libcamera-devel@lists.libcamera.org Cc: nicholas@rothemail.net Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Nicholas Roth I identified opportunities to make libcamera's log output easier to understand while working to get it working on my Android device as a HAL. These additional logging statements came out of that and will hopefully prove useful to Android distribution maintainers with the same goal as mine and to users who attempt to debug tools like Waydroid. Signed-off-by: Nicholas Roth Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- src/android/camera_capabilities.cpp | 12 +++++++++--- src/android/camera_hal_manager.cpp | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 64bd8dde..ef0d10d0 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -374,14 +374,20 @@ void CameraCapabilities::computeHwLevel( camera_metadata_enum_android_info_supported_hardware_level hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL; - if (!caps.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR)) + if (!caps.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR)) { + LOG(HAL, Info) << noFull << "missing manual sensor"; hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + } - if (!caps.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING)) + if (!caps.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING)) { + LOG(HAL, Info) << noFull << "missing manual post processing"; hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + } - if (!caps.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE)) + if (!caps.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE)) { + LOG(HAL, Info) << noFull << "missing burst capture"; hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + } found = staticMetadata_->getEntry(ANDROID_SYNC_MAX_LATENCY, &entry); if (!found || *entry.data.i32 != 0) { diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp index 7512cc4e..b229e2d5 100644 --- a/src/android/camera_hal_manager.cpp +++ b/src/android/camera_hal_manager.cpp @@ -140,7 +140,8 @@ void CameraHalManager::cameraAdded(std::shared_ptr cam) */ if (!isCameraExternal && !halConfig_.exists()) { LOG(HAL, Error) - << "HAL configuration file is mandatory for internal cameras"; + << "HAL configuration file is mandatory for internal cameras." + << " Camera " << cam->id() << "failed to load"; return; }