From patchwork Fri Oct 1 10:33:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 14017 X-Patchwork-Delegate: paul.elder@ideasonboard.com 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 94703BDC71 for ; Fri, 1 Oct 2021 10:33:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 52610691B3; Fri, 1 Oct 2021 12:33:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PH2FAj6Q"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E2A51691B0 for ; Fri, 1 Oct 2021 12:33:40 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 71652596; Fri, 1 Oct 2021 12:33:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1633084420; bh=97M0rv3Sn0paTSe4Y0O7q9AzQaH/dcm29+dgj7mOcKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PH2FAj6QwFVWVb0g+AQI2U7avDES5Ed9i0chEZxM90Wqa+rjIAd9GwmWP4Zanl7Gg bAJVrDpSWhrZ5ODDyDq99f8W8V94vrmfQ86pbb5qVED1oooZckZscL2Q3sTFDwR9jf 4pM7BIOmWT5Hg406wxxKxCn4q3cUVRTx5aXuk6jI= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Fri, 1 Oct 2021 19:33:20 +0900 Message-Id: <20211001103325.1077590-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211001103325.1077590-1-paul.elder@ideasonboard.com> References: <20211001103325.1077590-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/7] libcamera: pipeline: uvcvideo: Support the new AE controls 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" Add support for the new AE controls in the uvcvideo pipeline handler. Bug: https://bugs.libcamera.org/show_bug.cgi?id=42 Bug: https://bugs.libcamera.org/show_bug.cgi?id=43 Signed-off-by: Paul Elder --- Changes in v2: - fix the rebase error where some uvc stuff was in rasberrypi --- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 36 +++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 264f5370..3a9c3b8d 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -268,7 +268,9 @@ int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id, cid = V4L2_CID_CONTRAST; else if (id == controls::Saturation) cid = V4L2_CID_SATURATION; - else if (id == controls::AeEnable) + else if (id == controls::ExposureTimeMode) + cid = V4L2_CID_EXPOSURE_AUTO; + else if (id == controls::AnalogueGainMode) cid = V4L2_CID_EXPOSURE_AUTO; else if (id == controls::ExposureTime) cid = V4L2_CID_EXPOSURE_ABSOLUTE; @@ -302,9 +304,33 @@ int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id, } case V4L2_CID_EXPOSURE_AUTO: { - int32_t ivalue = value.get() + bool exposureSet = controls->contains(V4L2_CID_EXPOSURE_AUTO); + + /* \todo Make this nicer. */ + int32_t ivalue; + if (id == controls::ExposureTimeMode && exposureSet) { + int32_t exposureMode = controls->get(V4L2_CID_EXPOSURE_AUTO).get(); + ivalue = value.get() == controls::ExposureTimeModeAuto + ? (exposureMode == V4L2_EXPOSURE_SHUTTER_PRIORITY + ? V4L2_EXPOSURE_AUTO + : V4L2_EXPOSURE_APERTURE_PRIORITY) + : V4L2_EXPOSURE_MANUAL; + } else if (id == controls::ExposureTimeMode && !exposureSet) { + ivalue = value.get() == controls::ExposureTimeModeAuto ? V4L2_EXPOSURE_APERTURE_PRIORITY : V4L2_EXPOSURE_MANUAL; + } else if (id == controls::AnalogueGainMode && exposureSet) { + int32_t exposureMode = controls->get(V4L2_CID_EXPOSURE_AUTO).get(); + ivalue = value.get() == controls::AnalogueGainModeAuto + ? (exposureMode == V4L2_EXPOSURE_APERTURE_PRIORITY + ? V4L2_EXPOSURE_AUTO + : V4L2_EXPOSURE_SHUTTER_PRIORITY) + : V4L2_EXPOSURE_MANUAL; + } else if (id == controls::AnalogueGainMode && !exposureSet) { + ivalue = value.get() == controls::AnalogueGainModeAuto + ? V4L2_EXPOSURE_SHUTTER_PRIORITY + : V4L2_EXPOSURE_MANUAL; + } controls->set(V4L2_CID_EXPOSURE_AUTO, ivalue); break; } @@ -559,7 +585,7 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info, id = &controls::Saturation; break; case V4L2_CID_EXPOSURE_AUTO: - id = &controls::AeEnable; + id = &controls::ExposureTimeMode; break; case V4L2_CID_EXPOSURE_ABSOLUTE: id = &controls::ExposureTime; @@ -610,7 +636,9 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info, break; case V4L2_CID_EXPOSURE_AUTO: - info = ControlInfo{ false, true, true }; + info = ControlInfo{ { controls::ExposureTimeModeAuto, + controls::ExposureTimeModeDisabled }, + controls::ExposureTimeModeDisabled }; break; case V4L2_CID_EXPOSURE_ABSOLUTE: