[{"id":18563,"web_url":"https://patchwork.libcamera.org/comment/18563/","msgid":"<d52505e1-8462-cb0d-15f1-b569dca6c5f6@ideasonboard.com>","date":"2021-08-05T07:19:19","subject":"Re: [libcamera-devel] [PATCH v3 7/8] cam: kms_sink: Enable display\n\ton first frame","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"On 8/4/21 6:13 PM, Laurent Pinchart wrote:\n> Not all display controllers support enabling the display without any\n> active plane. Delay display enabling to the first frame.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-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(-)\n>\n> diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp\n> index 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\nAh, this was misleading at first as I was reasoning, if we don't have \nany active_ or queued_, how could we init? Isn't this the same thing as \nbefore (init without any plane).\n\nBut then noticed, we have set the \"FB_ID\" just before, so it shall \napplied while commit() below, and hence we have init the display \ncontroller for first frame.\n\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n\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: \"\n> diff --git a/src/cam/kms_sink.h b/src/cam/kms_sink.h\n> index 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_;","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 7FC25C3235\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  5 Aug 2021 07:19:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E4C5968811;\n\tThu,  5 Aug 2021 09:19:34 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 61199687CB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  5 Aug 2021 09:19:34 +0200 (CEST)","from [192.168.1.104] (unknown [103.251.226.40])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8C17D51D;\n\tThu,  5 Aug 2021 09:19:33 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"LZ6TabeD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628147974;\n\tbh=KD8N18u2Olm7LKuDDuw6y74kXa6AeQ+gA67mDtrsMZo=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=LZ6TabeDWZ1uM7tdqZXNpQkwy7hNgWFxst8cF9v+0f4ti+pKSLx3r3UUEpH8AmMcA\n\tDmlhd0RX3tNPJm6rnyUbXZVmkT6pW+3gnMtaICv+HjjCciF3btqYg5reUTElgd3aed\n\tpxPviKoBSCS2z09qh4tyLgAJN8brY1kB2v0hdW24=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210804124314.8044-1-laurent.pinchart@ideasonboard.com>\n\t<20210804124314.8044-8-laurent.pinchart@ideasonboard.com>","From":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<d52505e1-8462-cb0d-15f1-b569dca6c5f6@ideasonboard.com>","Date":"Thu, 5 Aug 2021 12:49:19 +0530","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.10.2","MIME-Version":"1.0","In-Reply-To":"<20210804124314.8044-8-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Transfer-Encoding":"7bit","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH v3 7/8] cam: kms_sink: Enable display\n\ton first 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>"}},{"id":18572,"web_url":"https://patchwork.libcamera.org/comment/18572/","msgid":"<cf0a27c7-27e9-48f5-9675-5407509d315f@ideasonboard.com>","date":"2021-08-05T12:41:38","subject":"Re: [libcamera-devel] [PATCH v3 7/8] cam: kms_sink: Enable display\n\ton first frame","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"On 04/08/2021 13:43, Laurent Pinchart wrote:\n> Not all display controllers support enabling the display without any\n> active plane. Delay display enabling to the first frame.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/cam/kms_sink.cpp | 31 +++++++++++--------------------\n>  src/cam/kms_sink.h   |  2 --\n>  2 files changed, 11 insertions(+), 22 deletions(-)\n> \n> diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp\n> index 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: \"\n> diff --git a/src/cam/kms_sink.h b/src/cam/kms_sink.h\n> index 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>","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 862CBC3235\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  5 Aug 2021 12:41:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 00EA8687CF;\n\tThu,  5 Aug 2021 14:41:43 +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 59FB76026D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  5 Aug 2021 14:41:41 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7E9DC51D;\n\tThu,  5 Aug 2021 14:41:40 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"t3fnA/D5\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628167301;\n\tbh=MHoDfVpDY+6SOWNtxfNKyD0Jzvk8tOErVHhZic5u05Y=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=t3fnA/D5TRgIGT0IIDgZU/c/c3g6vYzvmy25pBaW/gTVfupmzf5agIhTibN+qBNWO\n\trm+adzxgFdwMstGSd4PJ39xSNfsGaqeMfuiIKFEguG89lqBmpMT8d5uJI/583vzFDr\n\tzFdHbj+u4+99/Im4L1DjwjxpIAuraydh/lQqyTps=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210804124314.8044-1-laurent.pinchart@ideasonboard.com>\n\t<20210804124314.8044-8-laurent.pinchart@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<cf0a27c7-27e9-48f5-9675-5407509d315f@ideasonboard.com>","Date":"Thu, 5 Aug 2021 13:41:38 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.11.0","MIME-Version":"1.0","In-Reply-To":"<20210804124314.8044-8-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v3 7/8] cam: kms_sink: Enable display\n\ton first 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>"}}]