From patchwork Mon Jun 14 10:00: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: 12588 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 0AB01BD78E for ; Mon, 14 Jun 2021 10:00:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 67A7D6893A; Mon, 14 Jun 2021 12:00:49 +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="LPs5gVWl"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 87E1D6029D for ; Mon, 14 Jun 2021 12:00:47 +0200 (CEST) Received: by mail-wm1-x335.google.com with SMTP id m3so6540986wms.4 for ; Mon, 14 Jun 2021 03:00:47 -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=XOTzI+LHz/v5CJrTrK8WL78atBQ6sIBz/zqpsVLy2h4=; b=LPs5gVWlHAo3iJDVUmMETvJ4cfCtuEIJ8hRjDZTx2QlyQCYB+8IcQPEIBA01+9fydB TEp5fM5H6R8U1IJ9qSNYJkVkL68bw+ylkJvKEhET9OO4GEpFJ81c1o0haT2Qjn/TjJC4 SYugBSDasLUGvi+Lx+UEsAhLxToWHITPSDDvgDdR226P41sCRKk6/7ffWQhQsqMPstUS D088ZOHR0qVrToYQGd94w542PUONlRfHoPV8d01UZLzONATTk4PwgBhtjVfVH20eSxk7 E3hqIqViTbOU0anAo5Ne55XAe2ZO7zdNEqk31HY49uwTcqcuidJJSkUZkOAcxULmPmnI S8oQ== 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=XOTzI+LHz/v5CJrTrK8WL78atBQ6sIBz/zqpsVLy2h4=; b=a/Sp/qkrMdOELftoLP8QCtWckND1eLBnz6wFziMTjM/xWAK2iRaBTDGKP57Ja5KtIx xfJkgTq62udbjXJnSho7HwUX+gvVMX3YgE/XDniUKCbBwGg9SsTGqUKXR8R9ksc+pygB KdwCr/hSSFdO++N9ucq92g+jpVGbIEzNug5NEX/1nb1agmsHvo6kUbFvqg80ELU5+BCp p8rboFJOzGJ1C/a7AKKqV6Di7+Tahnvr+h0hLN4Wvkwn0BpM2xBuY6bjc87p1YtZ94YE 70Ve+Inm0TN4YPaX/wasXus9t9EIWxomZa/UQWq5blJ83Vf/kHjtVyptkUsakbojTqPj Lsgw== X-Gm-Message-State: AOAM530b8KDHhcef9E2klgXvDtZSqqOEvS68WrJhHwjNm9HFrz6XlqlK Au2+OXA0fkYhmRSyWOh2MJtWcsmKY4QEFg== X-Google-Smtp-Source: ABdhPJzKxIzdF94Xhtk8uF8BQJRfZ4s/OdXTsMcaMTZxwgx6FZlc04aMFg70DMZizqMeea46LAp3uQ== X-Received: by 2002:a05:600c:282:: with SMTP id 2mr32255251wmk.98.1623664846986; Mon, 14 Jun 2021 03:00:46 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:fd93:d554:2dff:83ca]) by smtp.gmail.com with ESMTPSA id 89sm16235959wrq.14.2021.06.14.03.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 03:00:46 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Mon, 14 Jun 2021 11:00:38 +0100 Message-Id: <20210614100040.3054433-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614100040.3054433-1-naush@raspberrypi.com> References: <20210614100040.3054433-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/4] 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 EXPSOURE 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 887f8d0f7404..d180fc059613 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -153,6 +153,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); @@ -827,7 +828,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; @@ -1293,22 +1294,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; } @@ -1378,6 +1377,24 @@ void RPiCameraData::setDelayedControls(const ControlList &controls) handleState(); } +void RPiCameraData::setSensorControls(ControlList &controls) +{ + /* + * We need to ensure that if both VBLANK and EXPSURE 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;