From patchwork Tue May 19 03:25:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3818 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2998B60E4C for ; Tue, 19 May 2020 05:25:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VH4OH4kr"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B80169CD for ; Tue, 19 May 2020 05:25:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1589858720; bh=//ySr8lEYKBd9z1OWpP/SzhuiA6MxFQlyZEJhG4r/GM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=VH4OH4kr3WYTzsmXr345blGj6KML+aaGGzIIpy1JvPx77wydi7wi8aWXFICM2I1qc JD4bZ7xWxAs3GT3c/MNmkeUgVWc+FTVnIG0Lr5SiqqectHMFX6keC4uMAS6+CNjgX+ p2p5Kd2Pb/E6yM5GTUvfwGh+R79JOBeomz0WYfqg= From: Laurent Pinchart 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 Subject: [libcamera-devel] [PATCH 7/8] cam: kms_sink: Enable display on first frame X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2020 03:25:21 -0000 Not all display controllers support enabling the display without any active plane. Delay display enabling to the first frame. Signed-off-by: Laurent Pinchart --- src/cam/kms_sink.cpp | 31 +++++++++++-------------------- src/cam/kms_sink.h | 2 -- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp index 85f244ea5413..a769255c022e 100644 --- a/src/cam/kms_sink.cpp +++ b/src/cam/kms_sink.cpp @@ -184,23 +184,6 @@ int KMSSink::start() return ret; } - /* Enable the display pipeline with no plane to start with. */ - request = std::make_unique(&dev_); - - request->addProperty(connector_, "CRTC_ID", crtc_->id()); - request->addProperty(crtc_, "ACTIVE", 1); - request->addProperty(crtc_, "MODE_ID", mode_->toBlob(&dev_)); - - ret = request->commit(DRM::AtomicRequest::FlagAllowModeset); - if (ret < 0) { - std::cerr - << "Failed to enable display pipeline: " - << strerror(-ret) << std::endl; - return ret; - } - - planeInitialized_ = false; - return 0; } @@ -244,10 +227,17 @@ bool KMSSink::consumeBuffer(const libcamera::Stream *stream, DRM::FrameBuffer *drmBuffer = iter->second.get(); + unsigned int flags = DRM::AtomicRequest::FlagAsync; DRM::AtomicRequest *request = new DRM::AtomicRequest(&dev_); request->addProperty(plane_, "FB_ID", drmBuffer->id()); - if (!planeInitialized_) { + if (!active_ && !queued_) { + /* Enable the display pipeline on the first frame. */ + request->addProperty(connector_, "CRTC_ID", crtc_->id()); + + request->addProperty(crtc_, "ACTIVE", 1); + request->addProperty(crtc_, "MODE_ID", mode_->toBlob(&dev_)); + request->addProperty(plane_, "CRTC_ID", crtc_->id()); request->addProperty(plane_, "SRC_X", 0 << 16); request->addProperty(plane_, "SRC_Y", 0 << 16); @@ -257,7 +247,8 @@ bool KMSSink::consumeBuffer(const libcamera::Stream *stream, request->addProperty(plane_, "CRTC_Y", 0); request->addProperty(plane_, "CRTC_W", mode_->hdisplay); request->addProperty(plane_, "CRTC_H", mode_->vdisplay); - planeInitialized_ = true; + + flags |= DRM::AtomicRequest::FlagAllowModeset; } pending_ = std::make_unique(request, buffer); @@ -265,7 +256,7 @@ bool KMSSink::consumeBuffer(const libcamera::Stream *stream, std::lock_guard lock(lock_); if (!queued_) { - int ret = request->commit(DRM::AtomicRequest::FlagAsync); + int ret = request->commit(flags); if (ret < 0) std::cerr << "Failed to commit atomic request: " diff --git a/src/cam/kms_sink.h b/src/cam/kms_sink.h index ee257a071c24..0879bb559e5a 100644 --- a/src/cam/kms_sink.h +++ b/src/cam/kms_sink.h @@ -63,8 +63,6 @@ private: libcamera::Size size_; unsigned int stride_; - bool planeInitialized_; - std::map> buffers_; std::mutex lock_;