summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-05-19 04:44:56 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-08-05 16:23:11 +0300
commit063c9969f502d133428639adbee9b864f22e2d6f (patch)
treef9dddab42fefa74fbfa4ba09072737c16f4467b9
parent6d7ddace52782a5a977cd9c37558c9078948e53e (diff)
cam: kms_sink: Enable display on first frame
Not all display controllers support enabling the display without any active plane. Delay display enabling to the first frame. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--src/cam/kms_sink.cpp31
-rw-r--r--src/cam/kms_sink.h2
2 files changed, 11 insertions, 22 deletions
diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp
index 35d2a242..8c0b79c6 100644
--- a/src/cam/kms_sink.cpp
+++ b/src/cam/kms_sink.cpp
@@ -195,23 +195,6 @@ int KMSSink::start()
return ret;
}
- /* Enable the display pipeline with no plane to start with. */
- request = std::make_unique<DRM::AtomicRequest>(&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;
}
@@ -259,10 +242,17 @@ bool KMSSink::processRequest(libcamera::Request *camRequest)
DRM::FrameBuffer *drmBuffer = iter->second.get();
+ unsigned int flags = DRM::AtomicRequest::FlagAsync;
DRM::AtomicRequest *drmRequest = new DRM::AtomicRequest(&dev_);
drmRequest->addProperty(plane_, "FB_ID", drmBuffer->id());
- if (!planeInitialized_) {
+ if (!active_ && !queued_) {
+ /* Enable the display pipeline on the first frame. */
+ drmRequest->addProperty(connector_, "CRTC_ID", crtc_->id());
+
+ drmRequest->addProperty(crtc_, "ACTIVE", 1);
+ drmRequest->addProperty(crtc_, "MODE_ID", mode_->toBlob(&dev_));
+
drmRequest->addProperty(plane_, "CRTC_ID", crtc_->id());
drmRequest->addProperty(plane_, "SRC_X", 0 << 16);
drmRequest->addProperty(plane_, "SRC_Y", 0 << 16);
@@ -272,7 +262,8 @@ bool KMSSink::processRequest(libcamera::Request *camRequest)
drmRequest->addProperty(plane_, "CRTC_Y", 0);
drmRequest->addProperty(plane_, "CRTC_W", mode_->hdisplay);
drmRequest->addProperty(plane_, "CRTC_H", mode_->vdisplay);
- planeInitialized_ = true;
+
+ flags |= DRM::AtomicRequest::FlagAllowModeset;
}
pending_ = std::make_unique<Request>(drmRequest, camRequest);
@@ -280,7 +271,7 @@ bool KMSSink::processRequest(libcamera::Request *camRequest)
std::lock_guard<std::mutex> lock(lock_);
if (!queued_) {
- int ret = drmRequest->commit(DRM::AtomicRequest::FlagAsync);
+ int ret = drmRequest->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 0c01df40..072ef1c9 100644
--- a/src/cam/kms_sink.h
+++ b/src/cam/kms_sink.h
@@ -61,8 +61,6 @@ private:
libcamera::Size size_;
unsigned int stride_;
- bool planeInitialized_;
-
std::map<libcamera::FrameBuffer *, std::unique_ptr<DRM::FrameBuffer>> buffers_;
std::mutex lock_;