[libcamera-devel] [PATCH] cam: kms_sink: Once you have found a valid crtc break out of loops
Eric Curtin
ecurtin at redhat.com
Thu Jan 27 20:52:39 CET 2022
On Thu, 2 Dec 2021 at 10:26, Eric Curtin <ecurtin at redhat.com> wrote:
>
> Once we have found a suitable plane and CRTC to auto-select, break out
> of all loops, not just the inner-most loop.
>
> Fixes: 1de0f90dd432 ("cam: kms_sink: Print display pipelineconfiguration")
> Signed-off-by: Eric Curtin <ecurtin at redhat.com>
> ---
> src/cam/kms_sink.cpp | 27 ++++++++++++++++-----------
> src/cam/kms_sink.h | 1 +
> 2 files changed, 17 insertions(+), 11 deletions(-)
>
> diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp
> index d30fba78..44a0f07b 100644
> --- a/src/cam/kms_sink.cpp
> +++ b/src/cam/kms_sink.cpp
> @@ -136,12 +136,12 @@ int KMSSink::configure(const libcamera::CameraConfiguration &config)
> return 0;
> }
>
> -int KMSSink::configurePipeline(const libcamera::PixelFormat &format)
> +const DRM::Crtc *KMSSink::findCrtc(const libcamera::PixelFormat &format)
> {
> /*
> - * If the requested format has an alpha channel, also consider the X
> - * variant.
> - */
> + * If the requested format has an alpha channel, also consider the X
> + * variant.
> + */
> libcamera::PixelFormat xFormat;
>
> switch (format) {
> @@ -160,10 +160,10 @@ int KMSSink::configurePipeline(const libcamera::PixelFormat &format)
> }
>
> /*
> - * Find a CRTC and plane suitable for the request format and the
> - * connector at the end of the pipeline. Restrict the search to primary
> - * planes for now.
> - */
> + * Find a CRTC and plane suitable for the request format and the
> + * connector at the end of the pipeline. Restrict the search to primary
> + * planes for now.
> + */
> for (const DRM::Encoder *encoder : connector_->encoders()) {
> for (const DRM::Crtc *crtc : encoder->possibleCrtcs()) {
> for (const DRM::Plane *plane : crtc->planes()) {
> @@ -174,20 +174,25 @@ int KMSSink::configurePipeline(const libcamera::PixelFormat &format)
> crtc_ = crtc;
> plane_ = plane;
> format_ = format;
> - break;
> + return crtc;
> }
>
> if (plane->supportsFormat(xFormat)) {
> crtc_ = crtc;
> plane_ = plane;
> format_ = xFormat;
> - break;
> + return crtc;
> }
> }
> }
> }
>
> - if (!crtc_) {
> + return nullptr;
> +}
> +
> +int KMSSink::configurePipeline(const libcamera::PixelFormat &format)
> +{
> + if (!findCrtc(format)) {
> std::cerr
> << "Unable to find display pipeline for format "
> << format.toString() << std::endl;
> diff --git a/src/cam/kms_sink.h b/src/cam/kms_sink.h
> index 1e4290ad..a8a29399 100644
> --- a/src/cam/kms_sink.h
> +++ b/src/cam/kms_sink.h
> @@ -47,6 +47,7 @@ private:
> libcamera::Request *camRequest_;
> };
>
> + const DRM::Crtc *findCrtc(const libcamera::PixelFormat &format);
> int configurePipeline(const libcamera::PixelFormat &format);
> void requestComplete(DRM::AtomicRequest *request);
>
> --
> 2.33.1
>
Almost forgot about this patch, just a friendly reminder.
More information about the libcamera-devel
mailing list