From patchwork Sun Mar 28 20:17:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phi-bang Nguyen X-Patchwork-Id: 11744 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 46DADC32ED for ; Sun, 28 Mar 2021 20:18:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BE7D86877C; Sun, 28 Mar 2021 22:18:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="gGcuM9I9"; dkim-atps=neutral Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A5786084F for ; Sun, 28 Mar 2021 22:18:05 +0200 (CEST) Received: by mail-wr1-x42b.google.com with SMTP id k8so10784422wrc.3 for ; Sun, 28 Mar 2021 13:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=w1X69dQEcf085y6Xa0DcOI3XoyWgWjrKLmZOv78FQbE=; b=gGcuM9I9csveDG1ateL00CleAAhqS6+Qf4zD2SxSenNDAxlyRXOfAKiDR58McOl2Rs GFjdGhHil44u0j7Bz9DbI1bZAHoIzkTSpIv0pk35d9+ykjA5HyzByc5lnUrqEeri4LhV kGXDLMAog8/Srs8+lZQC1QqNp72xRLJ0NHypEVy94jjkpHcRfxaeAxN0mUer4IbKG50Q xdePcLnMF8aNt9/c871RQgw2WIDn1siM8kKayVvRtutES/jgn523NEvmR9OvIOcvOioU bGRTgMj+khh+xRNe1i+bE1GAxXg5SmUv9zEIAXi5mmXj4fFGFig/z4Zvi54L69A6hJJY 7RHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=w1X69dQEcf085y6Xa0DcOI3XoyWgWjrKLmZOv78FQbE=; b=TuBiLtMCFC01t/MR3/yJcWTObXCG1A1snug6OiE2X72hn6Ky3U/0GQh59dCAcNLfyf 9y6LQk9B2gIPyKjCjpYOWSXaUIULevZ4mww/c54lg/zh5ga4MVYtptX6SuyhJtH+8dum LxO4mtJIvIvuuX8t377CecZqagguKmmMm/yFR/nO2j47v+r+iXBCnGkCxR2IYXSTCzn6 GBYbuKf5ZTW3A8NtD/5Fni5lECzWYTVhGtvxd/d+bCqbMgcP/EU0gSX5bQAEl1xGwSVE I3fxLa/ihwYVR0NiSXpoh6zS9OQnyDme3R7+RLLF8pyj044rq8L4oKLlyHgmZBNBMhLZ PPtQ== X-Gm-Message-State: AOAM531fiIH+gLzELTWKImd3/6Tm5hgtu4akvou6gQdcf5Hwxn12p6A6 ZWtADZIHRmH0NmUtLfUQ2+9VrV5JGKGotg== X-Google-Smtp-Source: ABdhPJycDIyKYBFXZGq7uLYmVilVhJ0lxxCKEJaaqK125ptmjyZZSTlxk6yySxxubah8RrSlEgRhEw== X-Received: by 2002:adf:d851:: with SMTP id k17mr25538514wrl.254.1616962684716; Sun, 28 Mar 2021 13:18:04 -0700 (PDT) Received: from localhost.localdomain (206.159.69.91.rev.sfr.net. [91.69.159.206]) by smtp.googlemail.com with ESMTPSA id c2sm19978925wme.15.2021.03.28.13.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Mar 2021 13:18:04 -0700 (PDT) From: Phi-Bang Nguyen To: libcamera-devel@lists.libcamera.org Date: Sun, 28 Mar 2021 22:17:15 +0200 Message-Id: <20210328201715.51816-1-pnguyen@baylibre.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] android: camera_device: Always add mandatory metadata entries X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The following static metadata entries are mandatory. Without them, the Android camera service cannot work properly and application will fail to start (error: "This device doesn't support camera2 API"): - ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES - ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS Fixes: edd4b1dab26b ("android: camera_device: Compute frame durations") Signed-off-by: Phi-Bang Nguyen --- src/android/camera_device.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index a8108e3a..4b5d8f97 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -769,6 +769,9 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() int64_t minFrameDurationNsec = -1; int64_t maxFrameDurationNsec = -1; + std::vector availableAeFpsTarget = { + 15, 30, 30, 30, + }; const auto frameDurationsInfo = controlsInfo.find(&controls::FrameDurations); if (frameDurationsInfo != controlsInfo.end()) { minFrameDurationNsec = frameDurationsInfo->second.min().get() * 1000; @@ -803,12 +806,12 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() * Register to the camera service {min, max} and {max, max} * intervals as requested by the metadata documentation. */ - int32_t availableAeFpsTarget[] = { + availableAeFpsTarget = { minFps, maxFps, maxFps, maxFps }; - staticMetadata_->addEntry(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, - availableAeFpsTarget, 4); } + staticMetadata_->addEntry(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, + availableAeFpsTarget.data(), availableAeFpsTarget.size()); std::vector aeCompensationRange = { 0, 0, @@ -1140,19 +1143,20 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() availableStallDurations.size()); /* Use the minimum frame duration for all the YUV/RGB formats. */ - if (minFrameDurationNsec > 0) { - std::vector minFrameDurations; - minFrameDurations.reserve(streamConfigurations_.size() * 4); - for (const auto &entry : streamConfigurations_) { - minFrameDurations.push_back(entry.androidFormat); - minFrameDurations.push_back(entry.resolution.width); - minFrameDurations.push_back(entry.resolution.height); + std::vector minFrameDurations; + minFrameDurations.reserve(streamConfigurations_.size() * 4); + for (const auto &entry : streamConfigurations_) { + minFrameDurations.push_back(entry.androidFormat); + minFrameDurations.push_back(entry.resolution.width); + minFrameDurations.push_back(entry.resolution.height); + if (minFrameDurationNsec > 0) minFrameDurations.push_back(minFrameDurationNsec); - } - staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS, - minFrameDurations.data(), - minFrameDurations.size()); + else + minFrameDurations.push_back(33333333); } + staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS, + minFrameDurations.data(), + minFrameDurations.size()); uint8_t croppingType = ANDROID_SCALER_CROPPING_TYPE_CENTER_ONLY; staticMetadata_->addEntry(ANDROID_SCALER_CROPPING_TYPE, &croppingType, 1);