From patchwork Tue Jul 25 12:56:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 18890 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 6EA09C324E for ; Tue, 25 Jul 2023 12:56:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 191AE628C6; Tue, 25 Jul 2023 14:56:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1690289810; bh=MHr/q2/XPNp28koWGsMujRqxQLVldKxL7/9CX6gIJIs=; 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=oPb0CgTdJDw9RVJY/UF4WLXGkKDm16DnjRrn4NQgLafddMlHNzwyTcbKD2XNGST+3 un/sYQQy84vBw/yb2ld/iVmAKXm2D3HYuO1GwWTN/ILBEETPkR8yfBcHtUrOJ35cl7 0+GOiLBw6lBCQ8E84MvRhvx/lKKwc4rjp+1C4s2EjvI7ihG/tmjhrjoZlsLZnyH6PD oeWLgVuAilCsVZ/7/r+5GJ9Km3Wpx1cPKN5xSr5QmdpoEmOgn4hTzqz0VyzfPVlTni +iCzTaCh4WE0+p4umfEs2Cowx2TmlHqGrSYK5Jdqvv6H4yDpYcZ1t9T9FjTCkBlAG1 6kX4MbSyGRD2w== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F6B361E29 for ; Tue, 25 Jul 2023 14:56:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RgihpP8j"; dkim-atps=neutral Received: from Monstersaurus.local (aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net [82.37.23.78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 967ABA06; Tue, 25 Jul 2023 14:55:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1690289748; bh=MHr/q2/XPNp28koWGsMujRqxQLVldKxL7/9CX6gIJIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RgihpP8jIbTikn6nR2dCkdUez69l64RwLkaeEQnpQm836VWyumzPMFA1Cjm4lB6rz Kp/q/70CMyw8cXV1iGjnYtT+OEjzDi72cWUayRU+Wet56TueUSZkRJtYT932G0NK2j fegNGHpHTzBzpk2Ggg6XRNZEi4rm/4BXREC0SboY= To: libcamera devel Date: Tue, 25 Jul 2023 13:56:40 +0100 Message-Id: <20230725125641.1557350-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230725125641.1557350-1-kieran.bingham@ideasonboard.com> References: <20230725125641.1557350-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] py: gen-py-controls: Remove SceneFlicker workaround 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: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Cc: Vedant Paranjape Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The python bindings layer has to parse the libcamera controls to ensure that they are converted to suitable names for the python layer. Part of this strips out common prefixes from control names, however the SceneFlicker control would end up using an illegal name if processed in the same way as the other controls. The SceneFlicker control has now been removed as part of the introduction of the AeFlickerMode and AeFlickerPeriod controls. Remove the workaround in the python layer. Fixes: 6fdbf3f38c31 ("libcamera: controls: Add controls for AEC/AGC flicker avoidance") Signed-off-by: Kieran Bingham Reviewed-by: David Plowman Reviewed-by: Laurent Pinchart --- src/py/libcamera/gen-py-controls.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/py/libcamera/gen-py-controls.py b/src/py/libcamera/gen-py-controls.py index 99f3bbcf5b80..9948c41e42b1 100755 --- a/src/py/libcamera/gen-py-controls.py +++ b/src/py/libcamera/gen-py-controls.py @@ -48,9 +48,6 @@ def generate_py(controls, mode): # Adjustments for controls if name == 'LensShadingMapMode': prefix = 'LensShadingMapMode' - elif name == 'SceneFlicker': - # If we strip the prefix, we would get '50Hz', which is illegal name - prefix = '' else: prefix = find_common_prefix([e['name'] for e in enum]) else: From patchwork Tue Jul 25 12:56:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 18891 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 C4E8ABDC71 for ; Tue, 25 Jul 2023 12:56:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ED3EB628C4; Tue, 25 Jul 2023 14:56:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1690289811; bh=zvBHbP5hQQ3RLymul2dakGq72RThh7OoxW54kOu9ffE=; 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=xvLVEPVFrNFGFBPFngmXc0l0M627IqVbWZgXQg0H8V+N/iErFH+db6jUViYjFeG9k Y+X2Lvd3gw3HG3Q4CBW5Flc2WO1TYMETRYHxz1EX1FmifOiflIgUgDol5jqwD6TKit oygdOstSJiUQnL/jpjd49c+5kC42kL+k02DwY3KbDi0WbGf2vseRosXHHMd69J0OaH jgZ+f9I0nfCzsjJP1dYz4omoV3eFp0/Fr/nvw9iaYspoe7/z+lp6JGiqw9zbXo0KdY PnhHUymK2F6sadoswV2zXEJ8w32A51RiZC8EthjzESQu4iZSp6uFsswO45iZJAtRG6 /TMx9GciB8lpw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6A57E628BD for ; Tue, 25 Jul 2023 14:56:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Hu6XuJWQ"; dkim-atps=neutral Received: from Monstersaurus.local (aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net [82.37.23.78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0B378EBA; Tue, 25 Jul 2023 14:55:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1690289749; bh=zvBHbP5hQQ3RLymul2dakGq72RThh7OoxW54kOu9ffE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hu6XuJWQa0zRZ5MPTm9BikBKaOCoYW/1Xi7vnravWQLpnkYPgobJ9V9gOoAbQwo2k SsBjRvYXcX2+kYI4OB0TqnO5UFbXbSN6Zq8jt7Wcpl8JAOYluI+1Pqi7DhWZuXKv+s V1FEAXnI0iBTp24LfBXIaNJLn6m6f4XyLa6jOo1k= To: libcamera devel Date: Tue, 25 Jul 2023 13:56:41 +0100 Message-Id: <20230725125641.1557350-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230725125641.1557350-1-kieran.bingham@ideasonboard.com> References: <20230725125641.1557350-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: uvcvideo: Implement AeFlickerMode 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: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Cc: Vedant Paranjape Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" UVC devices often provide controls to support setting the power line frequency which adapts the camera processing to avoid flicker visible to the user. Now that libcamera has implemented AeFlickerMode, use the new control to implement support for UVC devices. Signed-off-by: Kieran Bingham Reviewed-by: David Plowman --- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 59 ++++++++++++++++++-- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 38f48a5d9269..365410284e5b 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -89,8 +89,8 @@ public: bool match(DeviceEnumerator *enumerator) override; private: - int processControl(ControlList *controls, unsigned int id, - const ControlValue &value); + int processControl(Request *request, ControlList *controls, + unsigned int id, const ControlValue &value); int processControls(UVCCameraData *data, Request *request); UVCCameraData *cameraData(Camera *camera) @@ -260,7 +260,8 @@ void PipelineHandlerUVC::stopDevice(Camera *camera) data->video_->releaseBuffers(); } -int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id, +int PipelineHandlerUVC::processControl(Request *request, ControlList *controls, + unsigned int id, const ControlValue &value) { uint32_t cid; @@ -277,6 +278,8 @@ int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id, cid = V4L2_CID_EXPOSURE_ABSOLUTE; else if (id == controls::AnalogueGain) cid = V4L2_CID_GAIN; + else if (id == controls::AeFlickerMode) + cid = V4L2_CID_POWER_LINE_FREQUENCY; else return -EINVAL; @@ -331,6 +334,42 @@ int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id, break; } + case V4L2_CID_POWER_LINE_FREQUENCY: { + enum v4l2_power_line_frequency mode; + unsigned int period = request->controls().get(controls::AeFlickerPeriod) + .value_or(0); + switch (value.get()) { + default: + case controls::FlickerOff: + mode = V4L2_CID_POWER_LINE_FREQUENCY_DISABLED; + break; + case controls::FlickerAuto: + mode = V4L2_CID_POWER_LINE_FREQUENCY_AUTO; + break; + case controls::FlickerManual: + switch (period) { + case 10000: /* 100Hz in microseconds */ + mode = V4L2_CID_POWER_LINE_FREQUENCY_50HZ; + break; + case 8333: /* 120Hz in microseconds */ + mode = V4L2_CID_POWER_LINE_FREQUENCY_60HZ; + break; + default: + LOG(UVC, Warning) + << "Unsupported AeFlickerPeriod : " + << period; + [[fallthrough]]; + case 0: + mode = V4L2_CID_POWER_LINE_FREQUENCY_DISABLED; + break; + } + break; + } + + controls->set(cid, static_cast(mode)); + break; + } + default: { int32_t ivalue = value.get(); controls->set(cid, ivalue); @@ -346,7 +385,7 @@ int PipelineHandlerUVC::processControls(UVCCameraData *data, Request *request) ControlList controls(data->video_->controls()); for (const auto &[id, value] : request->controls()) - processControl(&controls, id, value); + processControl(request, &controls, id, value); for (const auto &ctrl : controls) LOG(UVC, Debug) @@ -605,6 +644,9 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info, case V4L2_CID_GAIN: id = &controls::AnalogueGain; break; + case V4L2_CID_POWER_LINE_FREQUENCY: + id = &controls::AeFlickerMode; + break; default: return; } @@ -689,6 +731,15 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info, break; } + case V4L2_CID_POWER_LINE_FREQUENCY: { + info = ControlInfo{ + { static_cast(controls::FlickerOff) }, + { static_cast(controls::FlickerAuto) }, + { static_cast(controls::FlickerOff) } + }; + break; + } + default: info = v4l2Info; break;