{"id":12588,"url":"https://patchwork.libcamera.org/api/1.1/patches/12588/?format=json","web_url":"https://patchwork.libcamera.org/patch/12588/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210614100040.3054433-3-naush@raspberrypi.com>","date":"2021-06-14T10:00:38","name":"[libcamera-devel,2/4] pipeline: raspberrypi: Use priority write for vblank when writing sensor ctrls","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"7a3e8dec9033058ccfae5bcd951a0cb32e8508c4","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12588/mbox/","series":[{"id":2129,"url":"https://patchwork.libcamera.org/api/1.1/series/2129/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2129","date":"2021-06-14T10:00:36","name":"Raspberry Pi: Enable imx477 long exposure modes","version":1,"mbox":"https://patchwork.libcamera.org/series/2129/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12588/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12588/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0AB01BD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 14 Jun 2021 10:00:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 67A7D6893A;\n\tMon, 14 Jun 2021 12:00:49 +0200 (CEST)","from mail-wm1-x335.google.com (mail-wm1-x335.google.com\n\t[IPv6:2a00:1450:4864:20::335])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 87E1D6029D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 14 Jun 2021 12:00:47 +0200 (CEST)","by mail-wm1-x335.google.com with SMTP id m3so6540986wms.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 14 Jun 2021 03:00:47 -0700 (PDT)","from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:fd93:d554:2dff:83ca])\n\tby smtp.gmail.com with ESMTPSA id\n\t89sm16235959wrq.14.2021.06.14.03.00.46\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 14 Jun 2021 03:00:46 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"LPs5gVWl\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=XOTzI+LHz/v5CJrTrK8WL78atBQ6sIBz/zqpsVLy2h4=;\n\tb=LPs5gVWlHAo3iJDVUmMETvJ4cfCtuEIJ8hRjDZTx2QlyQCYB+8IcQPEIBA01+9fydB\n\tTEp5fM5H6R8U1IJ9qSNYJkVkL68bw+ylkJvKEhET9OO4GEpFJ81c1o0haT2Qjn/TjJC4\n\tSYugBSDasLUGvi+Lx+UEsAhLxToWHITPSDDvgDdR226P41sCRKk6/7ffWQhQsqMPstUS\n\tD088ZOHR0qVrToYQGd94w542PUONlRfHoPV8d01UZLzONATTk4PwgBhtjVfVH20eSxk7\n\tE3hqIqViTbOU0anAo5Ne55XAe2ZO7zdNEqk31HY49uwTcqcuidJJSkUZkOAcxULmPmnI\n\tS8oQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=XOTzI+LHz/v5CJrTrK8WL78atBQ6sIBz/zqpsVLy2h4=;\n\tb=a/Sp/qkrMdOELftoLP8QCtWckND1eLBnz6wFziMTjM/xWAK2iRaBTDGKP57Ja5KtIx\n\txfJkgTq62udbjXJnSho7HwUX+gvVMX3YgE/XDniUKCbBwGg9SsTGqUKXR8R9ksc+pygB\n\tKdwCr/hSSFdO++N9ucq92g+jpVGbIEzNug5NEX/1nb1agmsHvo6kUbFvqg80ELU5+BCp\n\tp8rboFJOzGJ1C/a7AKKqV6Di7+Tahnvr+h0hLN4Wvkwn0BpM2xBuY6bjc87p1YtZ94YE\n\t70Ve+Inm0TN4YPaX/wasXus9t9EIWxomZa/UQWq5blJ83Vf/kHjtVyptkUsakbojTqPj\n\tLsgw==","X-Gm-Message-State":"AOAM530b8KDHhcef9E2klgXvDtZSqqOEvS68WrJhHwjNm9HFrz6XlqlK\n\tAu2+OXA0fkYhmRSyWOh2MJtWcsmKY4QEFg==","X-Google-Smtp-Source":"ABdhPJzKxIzdF94Xhtk8uF8BQJRfZ4s/OdXTsMcaMTZxwgx6FZlc04aMFg70DMZizqMeea46LAp3uQ==","X-Received":"by 2002:a05:600c:282:: with SMTP id\n\t2mr32255251wmk.98.1623664846986; \n\tMon, 14 Jun 2021 03:00:46 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 2/4] pipeline: raspberrypi: Use priority\n\twrite for vblank when writing sensor ctrls","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"When directly writing controls to the sensor device, ensure that VBLANK is\nwritten ahead of and before the EXPSOURE control. This is the same priority\nwrite mechanism used in DelayedControls.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 37 ++++++++++++++-----\n 1 file changed, 27 insertions(+), 10 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 887f8d0f7404..d180fc059613 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -153,6 +153,7 @@ public:\n \tvoid embeddedComplete(uint32_t bufferId);\n \tvoid setIspControls(const ControlList &controls);\n \tvoid setDelayedControls(const ControlList &controls);\n+\tvoid setSensorControls(ControlList &controls);\n \n \t/* bufferComplete signal handlers. */\n \tvoid unicamBufferDequeue(FrameBuffer *buffer);\n@@ -827,7 +828,7 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)\n \n \t/* Apply any gain/exposure settings that the IPA may have passed back. */\n \tif (!startConfig.controls.empty())\n-\t\tdata->unicam_[Unicam::Image].dev()->setControls(&startConfig.controls);\n+\t\tdata->setSensorControls(startConfig.controls);\n \n \t/* Configure the number of dropped frames required on startup. */\n \tdata->dropFrameCount_ = startConfig.dropFrameCount;\n@@ -1293,22 +1294,20 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config)\n \t\treturn -EPIPE;\n \t}\n \n-\tif (!controls.empty())\n-\t\tunicam_[Unicam::Image].dev()->setControls(&controls);\n-\n \t/*\n \t * Configure the H/V flip controls based on the combination of\n \t * the sensor and user transform.\n \t */\n \tif (supportsFlips_) {\n-\t\tControlList ctrls(unicam_[Unicam::Image].dev()->controls());\n-\t\tctrls.set(V4L2_CID_HFLIP,\n-\t\t\t  static_cast<int32_t>(!!(rpiConfig->combinedTransform_ & Transform::HFlip)));\n-\t\tctrls.set(V4L2_CID_VFLIP,\n-\t\t\t  static_cast<int32_t>(!!(rpiConfig->combinedTransform_ & Transform::VFlip)));\n-\t\tunicam_[Unicam::Image].dev()->setControls(&ctrls);\n+\t\tcontrols.set(V4L2_CID_HFLIP,\n+\t\t\t     static_cast<int32_t>(!!(rpiConfig->combinedTransform_ & Transform::HFlip)));\n+\t\tcontrols.set(V4L2_CID_VFLIP,\n+\t\t\t     static_cast<int32_t>(!!(rpiConfig->combinedTransform_ & Transform::VFlip)));\n \t}\n \n+\tif (!controls.empty())\n+\t\tsetSensorControls(controls);\n+\n \treturn 0;\n }\n \n@@ -1378,6 +1377,24 @@ void RPiCameraData::setDelayedControls(const ControlList &controls)\n \thandleState();\n }\n \n+void RPiCameraData::setSensorControls(ControlList &controls)\n+{\n+\t/*\n+\t * We need to ensure that if both VBLANK and EXPSURE are present, the\n+\t * former must be written ahead of, and separately from EXPOSURE to avoid\n+\t * V4L2 rejecting the latter. This is identical to what DelayedControls\n+\t * does with the priority write flag.\n+\t */\n+\tif (controls.contains(V4L2_CID_EXPOSURE) && controls.contains(V4L2_CID_VBLANK)) {\n+\t\tControlList vblank_ctrl;\n+\n+\t\tvblank_ctrl.set(V4L2_CID_VBLANK, controls.get(V4L2_CID_VBLANK));\n+\t\tunicam_[Unicam::Image].dev()->setControls(&vblank_ctrl);\n+\t}\n+\n+\tunicam_[Unicam::Image].dev()->setControls(&controls);\n+}\n+\n void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer)\n {\n \tRPi::Stream *stream = nullptr;\n","prefixes":["libcamera-devel","2/4"]}