{"id":3818,"url":"https://patchwork.libcamera.org/api/patches/3818/?format=json","web_url":"https://patchwork.libcamera.org/patch/3818/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20200519032505.17307-8-laurent.pinchart@ideasonboard.com>","date":"2020-05-19T03:25:04","name":"[libcamera-devel,7/8] cam: kms_sink: Enable display on first frame","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"e9594c8c9771a41b1626d7a646c7e9c2e2a9c176","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":{"id":14,"url":"https://patchwork.libcamera.org/api/users/14/?format=json","username":"pinchartl","first_name":"Laurent","last_name":"Pinchart","email":"laurent.pinchart@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/3818/mbox/","series":[{"id":912,"url":"https://patchwork.libcamera.org/api/series/912/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=912","date":"2020-05-19T03:24:57","name":"libcamera: Add DRM/KMS viewfinder display to cam","version":1,"mbox":"https://patchwork.libcamera.org/series/912/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3818/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3818/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2998B60E4C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 May 2020 05:25:21 +0200 (CEST)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B80169CD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 May 2020 05:25:20 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"VH4OH4kr\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1589858720;\n\tbh=//ySr8lEYKBd9z1OWpP/SzhuiA6MxFQlyZEJhG4r/GM=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=VH4OH4kr3WYTzsmXr345blGj6KML+aaGGzIIpy1JvPx77wydi7wi8aWXFICM2I1qc\n\tJD4bZ7xWxAs3GT3c/MNmkeUgVWc+FTVnIG0Lr5SiqqectHMFX6keC4uMAS6+CNjgX+\n\tp2p5Kd2Pb/E6yM5GTUvfwGh+R79JOBeomz0WYfqg=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 19 May 2020 06:25:04 +0300","Message-Id":"<20200519032505.17307-8-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.26.2","In-Reply-To":"<20200519032505.17307-1-laurent.pinchart@ideasonboard.com>","References":"<20200519032505.17307-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 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>","X-List-Received-Date":"Tue, 19 May 2020 03:25:21 -0000"},"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 85f244ea5413..a769255c022e 100644\n--- a/src/cam/kms_sink.cpp\n+++ b/src/cam/kms_sink.cpp\n@@ -184,23 +184,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@@ -244,10 +227,17 @@ bool KMSSink::consumeBuffer(const libcamera::Stream *stream,\n \n \tDRM::FrameBuffer *drmBuffer = iter->second.get();\n \n+\tunsigned int flags = DRM::AtomicRequest::FlagAsync;\n \tDRM::AtomicRequest *request = new DRM::AtomicRequest(&dev_);\n \trequest->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\trequest->addProperty(connector_, \"CRTC_ID\", crtc_->id());\n+\n+\t\trequest->addProperty(crtc_, \"ACTIVE\", 1);\n+\t\trequest->addProperty(crtc_, \"MODE_ID\", mode_->toBlob(&dev_));\n+\n \t\trequest->addProperty(plane_, \"CRTC_ID\", crtc_->id());\n \t\trequest->addProperty(plane_, \"SRC_X\", 0 << 16);\n \t\trequest->addProperty(plane_, \"SRC_Y\", 0 << 16);\n@@ -257,7 +247,8 @@ bool KMSSink::consumeBuffer(const libcamera::Stream *stream,\n \t\trequest->addProperty(plane_, \"CRTC_Y\", 0);\n \t\trequest->addProperty(plane_, \"CRTC_W\", mode_->hdisplay);\n \t\trequest->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>(request, buffer);\n@@ -265,7 +256,7 @@ bool KMSSink::consumeBuffer(const libcamera::Stream *stream,\n \tstd::lock_guard<std::mutex> lock(lock_);\n \n \tif (!queued_) {\n-\t\tint ret = request->commit(DRM::AtomicRequest::FlagAsync);\n+\t\tint ret = request->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 ee257a071c24..0879bb559e5a 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","7/8"]}