From patchwork Thu Mar 10 12:05:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 15437 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 212D4BE08A for ; Thu, 10 Mar 2022 12:06:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C3B79632E9; Thu, 10 Mar 2022 13:06:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1646913964; bh=r4pKdbZdxlOXmqBXrtmYgA5IRmSMGgYBumBVVDlzeM8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=oXbc0c1D0BzaFC8+ocqP5aI7hYW7CmWuK09kCM5k5g7EsyTbzwgyICcKt7oSxiZUj EQs9NYQTyoAzurE/RFaRUYvjESKocVBNMazM2dKZYL7Hq1+AjFZEaVC4DhnlxEZmew vh8XLb9WF8Q6ofO9EcZcYOvmdvnDGy2gJ2jxM6sVG5yW56zrUkq8UFhyZrTj4Pm4pz 1XG31d+qkMIk+aBYLPBgbnj6e99Nfc+A21Z/jmhQYzqNlZHm2zFGDPjMIimZD4caEs /fNINR6Lqqmny4lpODad5cer8wIr7xdARmKxciV57eKzTfJ+fIApFJe15gf+7zunn+ HFOe9lLS0Mekg== Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3DE07601F5 for ; Thu, 10 Mar 2022 13:06:03 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ihpF2iQy"; dkim-atps=neutral Received: by mail-wr1-x42f.google.com with SMTP id k24so7597371wrd.7 for ; Thu, 10 Mar 2022 04:06:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WqFguFVXyRqDDS3EF9Z9Td+S1KFOVUih7mpL0tJjLuA=; b=ihpF2iQy4+inCoTvnIHQ/ILd6wBYAg8mzDLzt8rgFYtiuIOhmAU2h3/LcWV+ChwvQt Qf8JHFFGlX0kFNLct6luXvEtrFtJh/4C7zLUfT0RnPP/OP4Vu3HN30ZPAIV/Ow01FO/5 74qg7CgW8vafT55CmeMx65rWEx0dmRNiX9QsLVq+OsHf4JAPcdTThh776YFTOkZKintq OlIyiwdBvG3xY+uaPAJ/6/y45xcP0NMkiZOobFwLj0ORgdXKeqPEhNPVJr8BkwIwh9zH /Z/QvLVM/yw39UK+w36f5Q46r7v6ETrEbqreio/EfefM5gUK1jksV6TZv/kgEEpd3trQ vVEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WqFguFVXyRqDDS3EF9Z9Td+S1KFOVUih7mpL0tJjLuA=; b=ptRTKGG14JBH7FJQT0zRzhjmcwFUoJJKTkqKo6ZSTAkWQ4jw9yMvo2m1DzPxwBOS6b YGJclEGknzV4XfY2My92oLGK77q1fEiAey5dphGZ44t7hkvPnmeKy26x5M0xgktPwkSi GS/gpXsw4Af/x3ymn7uFnCRr9gvkV57cIvJgSb5zpXm3OOZu1XcV1/EM7tsxCj+7NIqn zsUuiw42F3mYmGPzEP4punn6JrflBF9nKV1HFxsxo2xF7RQ6SlpBlIowV1gJrKvqvgVB mwTXBDkBDSHx/4ElpsHT5LGgrLZqFu0xDDm7GXWyVXhMahza3YtjMNSBOkQv2KKBZCSj Ckxw== X-Gm-Message-State: AOAM531cIQxM/hGDKfzIzMtfa1uYJnlUyO2qIv4swy1PvHCPxGslFdAY Ax4gvq2FBJ/pTm1bcen7wRgTxSr9t9FRqQ== X-Google-Smtp-Source: ABdhPJyJky0C6oEel1OGD1/e65lJPVpKTixjBc3hLfof8XbZqSZwQHz4QX5GtPo/AOB9dKnwW86JcA== X-Received: by 2002:a5d:538b:0:b0:1f1:e60b:20c2 with SMTP id d11-20020a5d538b000000b001f1e60b20c2mr3230597wrv.294.1646913962540; Thu, 10 Mar 2022 04:06:02 -0800 (PST) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:e4a2:3070:eea4:e434]) by smtp.gmail.com with ESMTPSA id bg18-20020a05600c3c9200b0037c2ef07493sm5399161wmb.3.2022.03.10.04.06.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Mar 2022 04:06:02 -0800 (PST) To: libcamera-devel@lists.libcamera.org, hanlinchen@chromium.org, hpa@redhat.com Date: Thu, 10 Mar 2022 12:05:40 +0000 Message-Id: <20220310120540.15296-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220310120540.15296-1-david.plowman@raspberrypi.com> References: <20220310120540.15296-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/1] libcamera: controls: Controls for driving AF (autofocus) algorithms 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: David Plowman via libcamera-devel From: David Plowman Reply-To: David Plowman Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This patch describes a series of controls that allow applications to drive AF algorithms: AfMode - manual, auto or continuous AfRange - full, macro or normal AfSpeed - fast or slow AfWindow - AF window locations AfTrigger - start (trigger an AF scan) or cancel AfPause - pause continuous AF LensPosition - position of lens from lens driver AfState - reset, scanning, focused or failed --- src/libcamera/control_ids.yaml | 271 +++++++++++++++++++++++++-------- 1 file changed, 211 insertions(+), 60 deletions(-) diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index 9d4638ae..89636d82 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -406,27 +406,6 @@ controls: The camera will cancel any active or completed metering sequence. The AE algorithm is reset to its initial state. - - AfTrigger: - type: int32_t - draft: true - description: | - Control for AF trigger. Currently identical to - ANDROID_CONTROL_AF_TRIGGER. - - Whether the camera device will trigger autofocus for this request. - enum: - - name: AfTriggerIdle - value: 0 - description: The trigger is idle. - - name: AfTriggerStart - value: 1 - description: The AF routine is started by the camera. - - name: AfTriggerCancel - value: 2 - description: | - The camera will cancel any active trigger and the AF routine is - reset to its initial state. - - NoiseReductionMode: type: int32_t draft: true @@ -507,45 +486,6 @@ controls: The AE algorithm has started a pre-capture metering session. \sa AePrecaptureTrigger - - AfState: - type: int32_t - draft: true - description: | - Control to report the current AF algorithm state. Currently identical to - ANDROID_CONTROL_AF_STATE. - - Current state of the AF algorithm. - enum: - - name: AfStateInactive - value: 0 - description: The AF algorithm is inactive. - - name: AfStatePassiveScan - value: 1 - description: | - AF is performing a passive scan of the scene in continuous - auto-focus mode. - - name: AfStatePassiveFocused - value: 2 - description: | - AF believes the scene is in focus, but might restart scanning. - - name: AfStateActiveScan - value: 3 - description: | - AF is performing a scan triggered by an AF trigger request. - \sa AfTrigger - - name: AfStateFocusedLock - value: 4 - description: | - AF believes has focused correctly and has locked focus. - - name: AfStateNotFocusedLock - value: 5 - description: | - AF has not been able to focus and has locked. - - name: AfStatePassiveUnfocused - value: 6 - description: | - AF has completed a passive scan without finding focus. - - AwbState: type: int32_t draft: true @@ -690,4 +630,215 @@ controls: value. All of the custom test patterns will be static (that is the raw image must not vary from frame to frame). + - AfMode: + type: int32_t + draft: true + description: | + Control to set the mode of the AF (autofocus) algorithm. Applications + are allowed to set a new mode, and to send additional controls for + that new mode, in the same request. + enum: + - name: AfModeManual + value: 0 + description: | + The AF algorithm is in manual mode. In this mode it will never + perform any action nor move the lens of its own accord. The only + autofocus controls that have an immediate effect are AfMode (to + switch out of manual mode) and LensPosition (so that the lens can + be moved "manually"). + + In this mode the AfState will always report AfStateReset. + - name: AfModeAuto + value: 1 + description: | + The AF algorithm is in auto mode. This means that the algorithm + will never move the lens or change state unless the AfTrigger + control is used. The AfTrigger control can be used to initiate a + focus scan, the results of which will also be reported by AfState. + + If the autofocus algorithm is moved from AfModeAuto to another + mode while a scan is in progress, the scan is cancelled + immediately, without waiting for the scan to finish. + + When first entering this mode the AfState will report + AfStateReset. When a trigger control is sent, AfState will + report AfStateScanning for a period before spontaneously + changing to AfStateFocused or AfStateFailed, depending on the + outcome of the scan. It will remain in this state until another + scan is initiated by the AfTrigger control. If a scan is + cancelled (without changing to another mode), AfState will return + to AfStateReset. + - name: AfModeContinuous + value: 2 + description: | + The AF algorithm is in continuous mode. This means that the lens + can re-start a scan spontaneously at any moment, without any user + intervention. The AfState still reports whether the algorithm is + currently scanning or not, though the application has no ability + to initiate or cancel scans, nor move the lens for itself. + + When set to AfModeContinuous, the system will immediately initiate + a scan so AfState will report AfStateScanning, and will settle on + one of AfStateFocused or AfStateFailed, depending on the scan + result. + + The continuous autofocus behaviour can be paused with the + AfPause control. Pausing the algorithm does not change the value + reported by AfState, so that applications can determine the + state of the algorithm when the pause control took effect. Once + un-paused ("resumed"), the algorithm starts again from exactly + where it left off when it paused. + + - AfRange: + type: int32_t + draft: true + description: | + Control to set the range of focus distances that is scanned. + enum: + - name: AfRangeNormal + value: 0 + description: | + A wide range of focus distances is scanned, all the way from + infinity down to close distances, though depending on the + implementation, possibly not including the very closest macro + positions. + - name: AfRangeMacro + value: 1 + description: Only close distances are scanned. + - name: AfRangeFull + value: 2 + description: | + The full range of focus distances is scanned just as with + AfRangeNormal but this time including the very closest macro + positions. + + - AfSpeed: + type: int32_t + draft: true + description: | + Control that determines whether the AF algorithm is to move the lens + as quickly as possible or more steadily. For example, during video + recording it may be desirable not to move the lens too abruptly, but + when in a preview mode (waiting for a still capture) it may be + helpful to move the lens as quickly as is reasonably possible. + enum: + - name: AfSpeedNormal + value: 0 + description: Move the lens at its usual speed. + - name: AfSpeedFast + value: 1 + description: Move the lens more quickly. + + - AfWindow: + type: Rectangle + draft: true + description: | + Sets the focus windows used by the AF algorithm. The units used express + a proportion of the ScalerCrop control (or if unavailable, of the entire + image), as u0.16 format numbers. + + In order to be activated, a rectangle must be programmed with non-zero + width and height. If no rectangles are programmed in this way, then the + system will choose its own single default window in the centre of the + image. + + The details of how the windows are used are platform dependent. We note + that when there is more than one AF window, a typical implementation + might find the optimal focus position for each one and finally select + the window closest to the camera. + + size: [platform dependent] + + - AfTrigger: + type: int32_t + draft: true + description: | + This control starts an autofocus scan when AfMode is set to AfModeAuto, + and can also be used to terminate a scan early. + + It is ignored if AfMode is set to AfModeContinuous. + + enum: + - name: AfTriggerStart + value: 0 + description: Start an AF scan. Ignored if a scan is in progress. + - name: AfTriggerCancel + value: 1 + description: Cancel an AF scan. Ingored if no scan is in progress. + + - AfPause: + type: int32_t + draft: true + description: | + This control has no effect except when in continuous autofocus mode + (AfModeContinuous). It can be used to pause any lens movements while + (for example) images are captured. The algorithm remains inactive + until it is instructed to resume. + + enum: + - name: AfPauseImmediate + value: 0 + description: | + Pause the continuous autofocus algorithm immediately, whether or + not any kind of scan is underway. The AfState will continue to + report whatever value it had when the control was enacted. + - name AfPauseDeferred + value: 1 + description: | + Pause the continuous autofocus algorithm as soon as it is no longer + scanning. The AfState will report AfStateFocused or AfStateFailed, + depending on whether the final scan succeeds or not. If no scan is + in currently progress, the algorithm will pause immediately. + - name: AfPauseResume + value: 2 + description: | + Resume continous autofocus operation. The algorithm starts again + from exactly where it left off, with AfState unchanged (one of + AfStateFocused, AfStateFailed or following AfPauseImmediate it + might also have been in the AfStateScanning state). + + - LensPosition: + type: int32_t + draft: true + description: | + Acts as a control to instruct the lens to move to a particular position + and also reports back the position of the lens for each frame. + + The units are determined by the lens driver. + + The LensPosition control is ignored unless the AfMode is set to + AfModeManual. + + - AfState: + type: int32_t + draft: true + description: | + Reports the current state of the AF algorithm. + enum: + - name: AfStateReset + value: 0 + description: | + The AF algorithm reports this state when: + * It is in manual mode (AfModeManual). + * The system has entered auto mode (AfModeAuto) but no scan + has yet been initiated. + * The system is in auto mode (AfModeAuto) and a scan has been + cancelled. + - name: AfStateScanning + value: 1 + description: | + AF is performing a scan. This state can be entered spontaneously + if AfMode is set to AfModeContinuous, otherwise it requires the + application to use the AfTrigger control to start the scan. + - name: AfStateFocused + value: 2 + description: | + An AF scan has been performed and the algorithm believes the + scene is in focus. + - name: AfStateFailed + value: 3 + description: | + An AF scan has been performed but the algorithm has not been able + to find the best focus position. + ...