Show a patch.

GET /api/1.1/patches/14100/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 14100,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14100/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14100/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20211011151154.72856-16-jacopo@jmondi.org>",
    "date": "2021-10-11T15:11:53",
    "name": "[libcamera-devel,v3,15/16] android: capabilties: Fix ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "bb9f8172685288aeea4d47eb73ebf8a3ebdfc163",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/14100/mbox/",
    "series": [
        {
            "id": 2613,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2613/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2613",
            "date": "2021-10-11T15:11:38",
            "name": "IPU3 control info update and HAL frame durations",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/2613/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14100/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14100/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7A99DC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 11 Oct 2021 15:11:32 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3CC8C68F4C;\n\tMon, 11 Oct 2021 17:11:32 +0200 (CEST)",
            "from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net\n\t[217.70.183.196])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 50AA66012B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Oct 2021 17:11:26 +0200 (CEST)",
            "(Authenticated sender: jacopo@jmondi.org)\n\tby relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 7FB3DE0006;\n\tMon, 11 Oct 2021 15:11:25 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 11 Oct 2021 17:11:53 +0200",
        "Message-Id": "<20211011151154.72856-16-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.33.0",
        "In-Reply-To": "<20211011151154.72856-1-jacopo@jmondi.org>",
        "References": "<20211011151154.72856-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 15/16] android: capabilties: Fix\n\tANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "As reported by the CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES documentation\nin the Android developer reference:\n\n\"For devices advertising any color filter arrangement other than NIR, or\ndevices not advertising color filter arrangement, this list will always\ninclude (min, max) and (max, max) where min <= 15 and max = the maximum\noutput frame rate of the maximum YUV_420_888 output size.\"\n\nCollect the higher FPS of the larger YUV stream and use it with the\nminimum FPS rate the camera can produce to populate the\nANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES static metadata.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/android/camera_capabilities.cpp | 75 +++++++++++------------------\n 1 file changed, 28 insertions(+), 47 deletions(-)",
    "diff": "diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp\nindex 2e9d1bcb3340..fbce816c5f61 100644\n--- a/src/android/camera_capabilities.cpp\n+++ b/src/android/camera_capabilities.cpp\n@@ -875,53 +875,6 @@ int CameraCapabilities::initializeStaticMetadata()\n \tstaticMetadata_->addEntry(ANDROID_CONTROL_AE_AVAILABLE_MODES,\n \t\t\t\t  aeAvailableModes);\n \n-\t/* Initialize the AE frame duration limits. */\n-\tconst auto frameDurationsInfo = controlsInfo.find(&controls::FrameDurationLimits);\n-\tint64_t minFrameDurationNsec = frameDurationsInfo->second.min().get<int64_t>() * 1000;\n-\tint64_t maxFrameDurationNsec = frameDurationsInfo->second.max().get<int64_t>() * 1000;\n-\n-\t/*\n-\t * Adjust the minimum frame duration to comply with Android\n-\t * requirements. The camera service mandates all preview/record\n-\t * streams to have a minimum frame duration < 33,366 milliseconds\n-\t * (see MAX_PREVIEW_RECORD_DURATION_NS in the camera service\n-\t * implementation).\n-\t *\n-\t * If we're close enough (+ 500 useconds) to that value, round\n-\t * the minimum frame duration of the camera to an accepted\n-\t * value.\n-\t */\n-\tstatic constexpr int64_t MAX_PREVIEW_RECORD_DURATION_NS = 1e9 / 29.97;\n-\tif (minFrameDurationNsec > MAX_PREVIEW_RECORD_DURATION_NS &&\n-\t    minFrameDurationNsec < MAX_PREVIEW_RECORD_DURATION_NS + 500000)\n-\t\tminFrameDurationNsec = MAX_PREVIEW_RECORD_DURATION_NS - 1000;\n-\n-\t/*\n-\t * The AE routine frame rate limits are computed using the frame\n-\t * duration limits, as libcamera clips the AE routine to the\n-\t * frame durations.\n-\t */\n-\tint32_t maxFps = std::round(1e9 / minFrameDurationNsec);\n-\tint32_t minFps = std::round(1e9 / maxFrameDurationNsec);\n-\tminFps = std::max(1, minFps);\n-\n-\t/*\n-\t * Force rounding errors so that we have the proper frame\n-\t * durations for when we reuse these variables later\n-\t */\n-\tminFrameDurationNsec = 1e9 / maxFps;\n-\tmaxFrameDurationNsec = 1e9 / minFps;\n-\n-\t/*\n-\t * Register to the camera service {min, max} and {max, max}\n-\t * intervals as requested by the metadata documentation.\n-\t */\n-\tint32_t availableAeFpsTarget[] = {\n-\t\tminFps, maxFps, maxFps, maxFps\n-\t};\n-\tstaticMetadata_->addEntry(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES,\n-\t\t\t\t  availableAeFpsTarget);\n-\n \tstd::vector<int32_t> aeCompensationRange = {\n \t\t0, 0,\n \t};\n@@ -1267,8 +1220,12 @@ int CameraCapabilities::initializeStaticMetadata()\n \n \tstd::vector<uint32_t> availableStreamConfigurations;\n \tstd::vector<int64_t> minFrameDurations;\n+\tint maxYUVFps = 0;\n+\tSize maxYUVSize;\n+\n \tavailableStreamConfigurations.reserve(streamConfigurations_.size() * 4);\n \tminFrameDurations.reserve(streamConfigurations_.size() * 4);\n+\n \tfor (const auto &entry : streamConfigurations_) {\n \t\t/*\n \t\t * Filter out YUV streams not capable of running at 30 FPS.\n@@ -1287,6 +1244,16 @@ int CameraCapabilities::initializeStaticMetadata()\n \t\tif (entry.androidFormat != HAL_PIXEL_FORMAT_BLOB && fps < 30)\n \t\t\tcontinue;\n \n+\t\t/*\n+\t\t * Collect the FPS of the maximum YUV output size to populate\n+\t\t * AE_AVAILABLE_TARGET_FPS_RANGE\n+\t\t */\n+\t\tif (entry.androidFormat == HAL_PIXEL_FORMAT_YCbCr_420_888 &&\n+\t\t    entry.resolution > maxYUVSize) {\n+\t\t\tmaxYUVSize = entry.resolution;\n+\t\t\tmaxYUVFps = fps;\n+\t\t}\n+\n \t\t/* Stream configuration map. */\n \t\tavailableStreamConfigurations.push_back(entry.androidFormat);\n \t\tavailableStreamConfigurations.push_back(entry.resolution.width);\n@@ -1312,6 +1279,20 @@ int CameraCapabilities::initializeStaticMetadata()\n \tstaticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS,\n \t\t\t\t  minFrameDurations);\n \n+\t/*\n+\t * Register to the camera service {min, max} and {max, max} with\n+\t * 'max' being the larger YUV stream maximum frame rate and 'min' being\n+\t * the globally minimum frame rate rounded to the next largest integer\n+\t * as the camera service expects the camera maximum frame duration to be\n+\t * smaller than 10^9 / minFps.\n+\t */\n+\tint32_t minFps = std::ceil(1e9 / maxFrameDuration_);\n+\tint32_t availableAeFpsTarget[] = {\n+\t\tminFps, maxYUVFps, maxYUVFps, maxYUVFps,\n+\t};\n+\tstaticMetadata_->addEntry(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES,\n+\t\t\t\t  availableAeFpsTarget);\n+\n \tstd::vector<int64_t> availableStallDurations;\n \tfor (const auto &entry : streamConfigurations_) {\n \t\tif (entry.androidFormat != HAL_PIXEL_FORMAT_BLOB)\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "15/16"
    ]
}