From patchwork Fri Jul 2 15:09:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12797 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 C19C8C0100 for ; Fri, 2 Jul 2021 15:09:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8311968503; Fri, 2 Jul 2021 17:09:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="W5tBv3y2"; dkim-atps=neutral Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3E3D668511 for ; Fri, 2 Jul 2021 17:09:55 +0200 (CEST) Received: by mail-wr1-x429.google.com with SMTP id u8so12837588wrq.8 for ; Fri, 02 Jul 2021 08:09:55 -0700 (PDT) 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=/YpVJmsa5egcjdYPoaMhnVTpbUvYaQTLQzwcDmDF1BE=; b=W5tBv3y2EEbyEwZPrxIJ+eIpO/QLTod1GIbFNYLAVZnyErmjOg6zC4yNn4gwHpMeIr PEsFuyeS9ZQuzDrxsEiUFk3JEW0akyws2PtRvTId03veej3EosU3IMwPuMWVJGyhIs1I UlNPWne/T/nUoLWeNYX88X2Chxy+0svX8kVXymVaSmlsNwO5nLohvNLtdX5xjmmwlgMK jrR6ew05Po8eDW6pf7j2BYDw/M9w5O26JEc35g8OuxYAwy+ULcCRnJocrlcsYTp6b/J6 KQj6+T44+F5thIBOio0fpeO/eFsKru0jHKLfQqZqN+gvwUBX3St0x6CE9aVJ8WHb4EUi RKHw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=/YpVJmsa5egcjdYPoaMhnVTpbUvYaQTLQzwcDmDF1BE=; b=Jou1SvTadOqcGiDUszvpkwfE88shlMTBBm3fr2cjfuNmSVn8KmuPH50YXxcwXFZkel isHg3oPMc/bfMu77T+vrrVHno0JJbZuA2giP1j+VhX3rgqaL/YlsgSuomXnlwSdAWXEk qMWMYqqqYM+YD8eaIRxEncPvdrIC4PH2ryW/TUskZX9rDvk3GxdYKaU4QFZB1GL0QFUf Wk65qWWN+mpLUZCwb7jGveKM/w2hY+S6ts1/wz84Cs+syVLUMVsfXsiQuHAYbs+tJR10 2S+Jmf/uZVZj0IFFVc6+d5ysRxn8UbzmbSrX4f7MFlHmhuskmxq7RHljIze3diwR8SDj ueLg== X-Gm-Message-State: AOAM5318bbv1pDs8P7UHQXSfDdSpasWGsHZLLngHICz23YoikE4IjfK0 Wwxsw6GABcNKsuv4rsKVHA2ttUOsBsNnkg== X-Google-Smtp-Source: ABdhPJzhwlK/k3B1Vc7poAKhLWFjnEYbCAwbFWBhexmiu0ZMsYloOkqpLMFCFYY7vdn+sY8nsbjQMA== X-Received: by 2002:adf:d205:: with SMTP id j5mr135535wrh.242.1625238594712; Fri, 02 Jul 2021 08:09:54 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n4sm3619335wrw.21.2021.07.02.08.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 08:09:54 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Jul 2021 16:09:38 +0100 Message-Id: <20210702150940.226941-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210702150940.226941-1-naush@raspberrypi.com> References: <20210702150940.226941-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 6/8] pipeline: raspberrypi: Use priority write for vblank when writing sensor ctrls 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" When directly writing controls to the sensor device, ensure that VBLANK is written ahead of and before the EXPOSURE control. This is the same priority write mechanism used in DelayedControls. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/raspberrypi.cpp | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 082eb1ee1c23..53a30cff1864 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -154,6 +154,7 @@ public: void embeddedComplete(uint32_t bufferId); void setIspControls(const ControlList &controls); void setDelayedControls(const ControlList &controls); + void setSensorControls(ControlList &controls); /* bufferComplete signal handlers. */ void unicamBufferDequeue(FrameBuffer *buffer); @@ -828,7 +829,7 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) /* Apply any gain/exposure settings that the IPA may have passed back. */ if (!startConfig.controls.empty()) - data->unicam_[Unicam::Image].dev()->setControls(&startConfig.controls); + data->setSensorControls(startConfig.controls); /* Configure the number of dropped frames required on startup. */ data->dropFrameCount_ = startConfig.dropFrameCount; @@ -1294,22 +1295,20 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) return -EPIPE; } - if (!controls.empty()) - unicam_[Unicam::Image].dev()->setControls(&controls); - /* * Configure the H/V flip controls based on the combination of * the sensor and user transform. */ if (supportsFlips_) { - ControlList ctrls(unicam_[Unicam::Image].dev()->controls()); - ctrls.set(V4L2_CID_HFLIP, - static_cast(!!(rpiConfig->combinedTransform_ & Transform::HFlip))); - ctrls.set(V4L2_CID_VFLIP, - static_cast(!!(rpiConfig->combinedTransform_ & Transform::VFlip))); - unicam_[Unicam::Image].dev()->setControls(&ctrls); + controls.set(V4L2_CID_HFLIP, + static_cast(!!(rpiConfig->combinedTransform_ & Transform::HFlip))); + controls.set(V4L2_CID_VFLIP, + static_cast(!!(rpiConfig->combinedTransform_ & Transform::VFlip))); } + if (!controls.empty()) + setSensorControls(controls); + return 0; } @@ -1379,6 +1378,24 @@ void RPiCameraData::setDelayedControls(const ControlList &controls) handleState(); } +void RPiCameraData::setSensorControls(ControlList &controls) +{ + /* + * We need to ensure that if both VBLANK and EXPOSURE are present, the + * former must be written ahead of, and separately from EXPOSURE to avoid + * V4L2 rejecting the latter. This is identical to what DelayedControls + * does with the priority write flag. + */ + if (controls.contains(V4L2_CID_EXPOSURE) && controls.contains(V4L2_CID_VBLANK)) { + ControlList vblank_ctrl; + + vblank_ctrl.set(V4L2_CID_VBLANK, controls.get(V4L2_CID_VBLANK)); + unicam_[Unicam::Image].dev()->setControls(&vblank_ctrl); + } + + unicam_[Unicam::Image].dev()->setControls(&controls); +} + void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer) { RPi::Stream *stream = nullptr;