From patchwork Wed Dec 1 16:44:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Curtin X-Patchwork-Id: 14982 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id B02D5BDB13 for ; Wed, 1 Dec 2021 16:46:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1164D6082A; Wed, 1 Dec 2021 17:46:23 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="LZXGdNbW"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0DDE5607DE for ; Wed, 1 Dec 2021 17:46:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638377179; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sK1Hm5hfY97GDSm3GmKgL6pVEINx3VnDGeB5CnHEJ7s=; b=LZXGdNbWOV/BZfr5mu0YEYkSHmoz9ttz9wlDUeSyz3O6EuqLEut/r4CCwzG183dAZYUF2R bcqWBDtyza48/0EhFMVJu+LfdebJkGI7l4+VCjQ6ZUe0wKUPAyDTFpR68Q6H2pot2bjTGX /07TzznagaDoi1AH0Jsb8yzDuJ7dKvM= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-144-3GfKWquBO1qVmXimXcQYwA-1; Wed, 01 Dec 2021 11:46:18 -0500 X-MC-Unique: 3GfKWquBO1qVmXimXcQYwA-1 Received: by mail-wm1-f72.google.com with SMTP id o18-20020a05600c511200b00332fa17a02eso1175308wms.5 for ; Wed, 01 Dec 2021 08:46:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sK1Hm5hfY97GDSm3GmKgL6pVEINx3VnDGeB5CnHEJ7s=; b=Zlku/O0d+IxjWZoZr9zZmEp9u5u1RF4jaO6JN+ZqVurwam5DgEbA1ZHCv+/CHY5CHA 6bNS8XA8UHznNPulARxQhPFfBM6yEIAHd2k1OjzUc7/VNLTgqjGMFELZQlbPfq3xEZpn v/dTCKP20Mplh+LyXGKGlZCZfVxE8f2hbpD+FqwzpS0huGorLAMCplxE5N9J8yNr/pVj auvBchIQTr0IJHRZ2C5CXfGabqgnKa/cP4h12f4K0200GK2nIoKrNoAhur6L2d+Wjfv+ XMYN/zhrurzucTpMIouQv8b2ipVPmmEGbOXFASMdu/gIsugln1pBddvRkuHvj0FdMUYa sOgg== X-Gm-Message-State: AOAM530RrO11cvVRSZWmNDZVOJ+OXu1ev5/ptlM7r+pWdyyU4aZML2Xb klpLVRvKlYkjxtk16NuGaNy/diRi8cJOAHjiOcOrjlfZeinIYwe0KHVRmK0RbJPtrsPd/eRIqm8 uxQKGIcD4TpUxyD5aK+zl1hXBPu79dE1bVXfNLKXQq+vRFue3d2a9ZOdpgzpLRiTy1/TJpSczxI QQKgKRPVeX X-Received: by 2002:adf:cf0a:: with SMTP id o10mr8372544wrj.84.1638377177462; Wed, 01 Dec 2021 08:46:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlonVBoFSfrNNp2OaYMBAb46gR3bNGqwTr3L8OTim6AqX/r6sbjKazVzjdw4ux/WsoS1EsJg== X-Received: by 2002:adf:cf0a:: with SMTP id o10mr8372520wrj.84.1638377177236; Wed, 01 Dec 2021 08:46:17 -0800 (PST) Received: from curtine-ThinkPad-P1-Gen-3.Home (86-40-122-19-dynamic.agg7.rlc.lmk-mlw.eircom.net. [86.40.122.19]) by smtp.gmail.com with ESMTPSA id s8sm293034wro.19.2021.12.01.08.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Dec 2021 08:46:16 -0800 (PST) From: Eric Curtin To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 16:44:13 +0000 Message-Id: <20211201164413.95396-1-ecurtin@redhat.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ecurtin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [libcamera-devel] [PATCH] cam: kms_sink: select valid crtc 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When looping through possibleCrtcs on my machine, the only valid crtc is actually the first one. This can be identified by checking if the clock variable is non-zero. Signed-off-by: Eric Curtin --- src/cam/drm.cpp | 2 +- src/cam/drm.h | 2 ++ src/cam/kms_sink.cpp | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cam/drm.cpp b/src/cam/drm.cpp index f2530091..808e5a87 100644 --- a/src/cam/drm.cpp +++ b/src/cam/drm.cpp @@ -128,7 +128,7 @@ std::unique_ptr Mode::toBlob(Device *dev) const } Crtc::Crtc(Device *dev, const drmModeCrtc *crtc, unsigned int index) - : Object(dev, crtc->crtc_id, Object::TypeCrtc), index_(index) + : Object(dev, crtc->crtc_id, Object::TypeCrtc), index_(index), crtc_(crtc) { } diff --git a/src/cam/drm.h b/src/cam/drm.h index de57e445..d05e6d13 100644 --- a/src/cam/drm.h +++ b/src/cam/drm.h @@ -149,12 +149,14 @@ public: Crtc(Device *dev, const drmModeCrtc *crtc, unsigned int index); unsigned int index() const { return index_; } + uint32_t clock() const { return crtc_->mode.clock; } const std::vector &planes() const { return planes_; } private: friend Device; unsigned int index_; + const drmModeCrtc *crtc_; std::vector planes_; }; diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp index d30fba78..aa0b7a3c 100644 --- a/src/cam/kms_sink.cpp +++ b/src/cam/kms_sink.cpp @@ -166,6 +166,10 @@ int KMSSink::configurePipeline(const libcamera::PixelFormat &format) */ for (const DRM::Encoder *encoder : connector_->encoders()) { for (const DRM::Crtc *crtc : encoder->possibleCrtcs()) { + if (!crtc->clock()) { + continue; + } + for (const DRM::Plane *plane : crtc->planes()) { if (plane->type() != DRM::Plane::TypePrimary) continue;