Message ID | 20210804124314.8044-8-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
On 8/4/21 6:13 PM, Laurent Pinchart wrote: > 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> > --- > 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 f708b613f226..d9a2efe84c59 100644 > --- a/src/cam/kms_sink.cpp > +++ b/src/cam/kms_sink.cpp > @@ -193,23 +193,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; > } > > @@ -253,10 +236,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_) { Ah, this was misleading at first as I was reasoning, if we don't have any active_ or queued_, how could we init? Isn't this the same thing as before (init without any plane). But then noticed, we have set the "FB_ID" just before, so it shall applied while commit() below, and hence we have init the display controller for first frame. Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> > + /* 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); > @@ -266,7 +256,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); > @@ -274,7 +265,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 2895e00f84a1..cd6f900d692c 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<libcamera::FrameBuffer *, std::unique_ptr<DRM::FrameBuffer>> buffers_; > > std::mutex lock_;
On 04/08/2021 13:43, Laurent Pinchart wrote: > 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: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > 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 f708b613f226..d9a2efe84c59 100644 > --- a/src/cam/kms_sink.cpp > +++ b/src/cam/kms_sink.cpp > @@ -193,23 +193,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; > } > > @@ -253,10 +236,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); > @@ -266,7 +256,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); > @@ -274,7 +265,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 2895e00f84a1..cd6f900d692c 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<libcamera::FrameBuffer *, std::unique_ptr<DRM::FrameBuffer>> buffers_; > > std::mutex lock_; >
diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp index f708b613f226..d9a2efe84c59 100644 --- a/src/cam/kms_sink.cpp +++ b/src/cam/kms_sink.cpp @@ -193,23 +193,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; } @@ -253,10 +236,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); @@ -266,7 +256,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); @@ -274,7 +265,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 2895e00f84a1..cd6f900d692c 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<libcamera::FrameBuffer *, std::unique_ptr<DRM::FrameBuffer>> buffers_; std::mutex lock_;