{"id":13151,"url":"https://patchwork.libcamera.org/api/1.1/patches/13151/?format=json","web_url":"https://patchwork.libcamera.org/patch/13151/","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":"<20210730010306.19956-8-laurent.pinchart@ideasonboard.com>","date":"2021-07-30T01:03:05","name":"[libcamera-devel,v2,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/13151/mbox/","series":[{"id":2289,"url":"https://patchwork.libcamera.org/api/1.1/series/2289/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2289","date":"2021-07-30T01:02:59","name":"libcamera: Add DRM/KMS viewfinder display to cam","version":2,"mbox":"https://patchwork.libcamera.org/series/2289/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13151/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13151/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 5D76DC3235\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 30 Jul 2021 01:03:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0F57E687FA;\n\tFri, 30 Jul 2021 03:03:28 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 01909687BE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 30 Jul 2021 03:03:21 +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 92B1E101E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 30 Jul 2021 03:03:20 +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=\"GDuVQes+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1627607000;\n\tbh=WaBgTgKNnFsIAIOquzNhwQvmGzwrlHUaHB6eaghRYZQ=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=GDuVQes+hgvBe7BAQuuqF8gymeAJponEi2L96NpKoDwtLELRC6uTWyhUTlkZOoFK5\n\tJ8DQCNc+Nk2z81fec3wCPv678MQ5mjEHK5/sV8iE+t8Oh1XVjRTFj2jg5TMqUV7tAR\n\tSVGWBqZhtAQqOjOkZiAqo4kPLwA5kMRELBbqOVdw=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 30 Jul 2021 04:03:05 +0300","Message-Id":"<20210730010306.19956-8-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20210730010306.19956-1-laurent.pinchart@ideasonboard.com>","References":"<20210730010306.19956-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 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>\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 b8f86dcb6f4e..2c767cb40885 100644\n--- a/src/cam/kms_sink.cpp\n+++ b/src/cam/kms_sink.cpp\n@@ -185,23 +185,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@@ -245,10 +228,17 @@ bool KMSSink::consumeRequest(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@@ -258,7 +248,8 @@ bool KMSSink::consumeRequest(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@@ -266,7 +257,7 @@ bool KMSSink::consumeRequest(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 7b6ffcede28c..8536ef2e532d 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","v2","7/8"]}