{"id":13203,"url":"https://patchwork.libcamera.org/api/1.1/patches/13203/?format=json","web_url":"https://patchwork.libcamera.org/patch/13203/","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":"<20210804124314.8044-8-laurent.pinchart@ideasonboard.com>","date":"2021-08-04T12:43:13","name":"[libcamera-devel,v3,7/8] cam: kms_sink: Enable display on first frame","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"d0d5f016caa601a3430af1b35a2e4ca816792bee","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13203/mbox/","series":[{"id":2303,"url":"https://patchwork.libcamera.org/api/1.1/series/2303/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2303","date":"2021-08-04T12:43:06","name":"libcamera: Add DRM/KMS viewfinder display to cam","version":3,"mbox":"https://patchwork.libcamera.org/series/2303/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13203/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13203/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 B88BAC3239\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  4 Aug 2021 12:43:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 09F5D68887;\n\tWed,  4 Aug 2021 14:43:36 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3945668864\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  4 Aug 2021 14:43:32 +0200 (CEST)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C65B9891\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  4 Aug 2021 14:43:31 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Yg+2kY1G\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628081011;\n\tbh=t2DgIUR+kQdLdDbXvCNrX6b0fSEt53+vwNYiUQSd4T0=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=Yg+2kY1GnSj7Qn+bchm1TMckr0p4Szx5787pQfWwhztP1rQZjqC+pWEWVuMxVPTby\n\tCSGVNCR5zLkO5rdEelDFx/NImHs9mHx11CK0zGTsHrJVev3Xd3TvFM5VYg9WVx1vwn\n\tbAdKi7CrKjZG8dWT9qmeSijFkAwmS4E1wNOLV0TA=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  4 Aug 2021 15:43:13 +0300","Message-Id":"<20210804124314.8044-8-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20210804124314.8044-1-laurent.pinchart@ideasonboard.com>","References":"<20210804124314.8044-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 7/8] cam: kms_sink: Enable display on\n\tfirst frame","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":"Not all display controllers support enabling the display without any\nactive plane. Delay display enabling to the first frame.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n src/cam/kms_sink.cpp | 31 +++++++++++--------------------\n src/cam/kms_sink.h   |  2 --\n 2 files changed, 11 insertions(+), 22 deletions(-)","diff":"diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp\nindex f708b613f226..d9a2efe84c59 100644\n--- a/src/cam/kms_sink.cpp\n+++ b/src/cam/kms_sink.cpp\n@@ -193,23 +193,6 @@ int KMSSink::start()\n \t\treturn ret;\n \t}\n \n-\t/* Enable the display pipeline with no plane to start with. */\n-\trequest = std::make_unique<DRM::AtomicRequest>(&dev_);\n-\n-\trequest->addProperty(connector_, \"CRTC_ID\", crtc_->id());\n-\trequest->addProperty(crtc_, \"ACTIVE\", 1);\n-\trequest->addProperty(crtc_, \"MODE_ID\", mode_->toBlob(&dev_));\n-\n-\tret = request->commit(DRM::AtomicRequest::FlagAllowModeset);\n-\tif (ret < 0) {\n-\t\tstd::cerr\n-\t\t\t<< \"Failed to enable display pipeline: \"\n-\t\t\t<< strerror(-ret) << std::endl;\n-\t\treturn ret;\n-\t}\n-\n-\tplaneInitialized_ = false;\n-\n \treturn 0;\n }\n \n@@ -253,10 +236,17 @@ bool KMSSink::processRequest(libcamera::Request *camRequest)\n \n \tDRM::FrameBuffer *drmBuffer = iter->second.get();\n \n+\tunsigned int flags = DRM::AtomicRequest::FlagAsync;\n \tDRM::AtomicRequest *drmRequest = new DRM::AtomicRequest(&dev_);\n \tdrmRequest->addProperty(plane_, \"FB_ID\", drmBuffer->id());\n \n-\tif (!planeInitialized_) {\n+\tif (!active_ && !queued_) {\n+\t\t/* Enable the display pipeline on the first frame. */\n+\t\tdrmRequest->addProperty(connector_, \"CRTC_ID\", crtc_->id());\n+\n+\t\tdrmRequest->addProperty(crtc_, \"ACTIVE\", 1);\n+\t\tdrmRequest->addProperty(crtc_, \"MODE_ID\", mode_->toBlob(&dev_));\n+\n \t\tdrmRequest->addProperty(plane_, \"CRTC_ID\", crtc_->id());\n \t\tdrmRequest->addProperty(plane_, \"SRC_X\", 0 << 16);\n \t\tdrmRequest->addProperty(plane_, \"SRC_Y\", 0 << 16);\n@@ -266,7 +256,8 @@ bool KMSSink::processRequest(libcamera::Request *camRequest)\n \t\tdrmRequest->addProperty(plane_, \"CRTC_Y\", 0);\n \t\tdrmRequest->addProperty(plane_, \"CRTC_W\", mode_->hdisplay);\n \t\tdrmRequest->addProperty(plane_, \"CRTC_H\", mode_->vdisplay);\n-\t\tplaneInitialized_ = true;\n+\n+\t\tflags |= DRM::AtomicRequest::FlagAllowModeset;\n \t}\n \n \tpending_ = std::make_unique<Request>(drmRequest, camRequest);\n@@ -274,7 +265,7 @@ bool KMSSink::processRequest(libcamera::Request *camRequest)\n \tstd::lock_guard<std::mutex> lock(lock_);\n \n \tif (!queued_) {\n-\t\tint ret = drmRequest->commit(DRM::AtomicRequest::FlagAsync);\n+\t\tint ret = drmRequest->commit(flags);\n \t\tif (ret < 0)\n \t\t\tstd::cerr\n \t\t\t\t<< \"Failed to commit atomic request: \"\ndiff --git a/src/cam/kms_sink.h b/src/cam/kms_sink.h\nindex 2895e00f84a1..cd6f900d692c 100644\n--- a/src/cam/kms_sink.h\n+++ b/src/cam/kms_sink.h\n@@ -63,8 +63,6 @@ private:\n \tlibcamera::Size size_;\n \tunsigned int stride_;\n \n-\tbool planeInitialized_;\n-\n \tstd::map<libcamera::FrameBuffer *, std::unique_ptr<DRM::FrameBuffer>> buffers_;\n \n \tstd::mutex lock_;\n","prefixes":["libcamera-devel","v3","7/8"]}