From patchwork Thu Oct 28 15:47:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Curtin X-Patchwork-Id: 14406 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 5499DBF415 for ; Thu, 28 Oct 2021 15:47:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 41C93600BA; Thu, 28 Oct 2021 17:47:13 +0200 (CEST) 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="AYxEMOns"; 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 D7D6D600B5 for ; Thu, 28 Oct 2021 17:47:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635436029; 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=SEg20IqA7hpAe955Ml6b0M8foz2Mvi76Cv12myjT9sI=; b=AYxEMOnsKoBizi8Fb4hRhC1k2tS+tGfybF5WqBciGpaTL04+vwglbmlnXJ6FiRcnML/+N0 EDhtWhTX0nxdrdog3oZPhaOImpu8XxB37JXZ2+PLLcsKleWn5Aa7PXdtMNUDsaOgF8g+/C pbClEK/+vJ8N4wliodi4ZjmAG4Tq5dc= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-164-5WDTjYMZMJKWbtP-vcsAcA-1; Thu, 28 Oct 2021 11:47:08 -0400 X-MC-Unique: 5WDTjYMZMJKWbtP-vcsAcA-1 Received: by mail-wm1-f72.google.com with SMTP id z137-20020a1c7e8f000000b0030cd1800d86so2555568wmc.2 for ; Thu, 28 Oct 2021 08:47:08 -0700 (PDT) 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=SEg20IqA7hpAe955Ml6b0M8foz2Mvi76Cv12myjT9sI=; b=S6dVzIa0Op0cXKN+20qsNQz8+dtTWRw8WzzfOsNyb6xT3/HZYORVkNMSqrZjIi010T vWwsKJU5eOt2htFvoUfYY9QclqU8yeGgUF111H8lAMB00f83kEzyZTjk+E0rq9C6xayg YZUXlFesRBbFgpXXU/o0dct76gPwTOX++VtgqCOwtn9dBMGBW1C9/inCJm3uhXnQWncB y52HLkS2mnZdAgmh47JlW5jLFugnIwbZLrtpQVRvuoCGBDbL4Bh1Wv/FjgjhcGDQ6/N8 qJCwpM53JBvOMUI+8QxVoqDH+H+rDIU+tCIrGXciD9MoqYyH8XjqFjiJ+sAioLiIuEZV SMBQ== X-Gm-Message-State: AOAM530UPCX9Mng5jl51OnWTpMyD0l4C8JkcxvmrMTc3x0blvCow1S1k dTe6hg8yObcwCcquEjT+PBXM7n/oDcsgeE14xWR31Hrvbf6u+XOK+oUZWn8Im7syRE2pDuNrQHu YNaNQcYMEPiIkpUBxKQQ7MfXjT05mlhCUSvxCkpS4+DXXVYztv+N1nUhQ/40z5aAljV06O0G0d9 z4xQPbT+oL X-Received: by 2002:adf:eec7:: with SMTP id a7mr6832675wrp.192.1635436026959; Thu, 28 Oct 2021 08:47:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwm+tfwVQVa95yA+z/1LXf1CmYDkN/xapMvF4Z/HqevpQfI5kAsf/wbEFQcqgrMBC2H7qOLcQ== X-Received: by 2002:adf:eec7:: with SMTP id a7mr6832634wrp.192.1635436026668; Thu, 28 Oct 2021 08:47:06 -0700 (PDT) Received: from curtine-ThinkPad-P1-Gen-3.Home ([2001:8a0:6724:4500:dc68:d331:1862:9fcb]) by smtp.gmail.com with ESMTPSA id k63sm6679482wme.22.2021.10.28.08.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 08:47:06 -0700 (PDT) From: Eric Curtin To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Oct 2021 16:47:01 +0100 Message-Id: <20211028154701.36020-1-ecurtin@redhat.com> X-Mailer: git-send-email 2.31.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] Add option to list displays 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" xrand --query isn't always available and does not always display all conneted connectors. Signed-off-by: Eric Curtin --- src/cam/main.cpp | 31 ++++++++++++++++++++++++++----- src/cam/main.h | 3 +++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/cam/main.cpp b/src/cam/main.cpp index c7f664b9..319cbf4d 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -15,6 +15,11 @@ #include #include "camera_session.h" + +#ifdef HAVE_KMS +#include "drm.h" +#endif + #include "event_loop.h" #include "main.h" #include "options.h" @@ -137,6 +142,7 @@ int CamApp::parseOptions(int argc, char *argv[]) "Display viewfinder through DRM/KMS on specified connector", "display", ArgumentOptional, "connector", false, OptCamera); + parser.addOption(OptListDisplays, OptionNone, "List all displays", "list-displays"); #endif parser.addOption(OptFile, OptionString, "Write captured frames to disk\n" @@ -202,7 +208,22 @@ int CamApp::run() } } - /* 2. Create the camera sessions. */ +#ifdef HAVE_KMS + /* 2. List all displays. */ + if (options_.isSet(OptListDisplays)) { + std::cout << "Available displays:" << std::endl; + + DRM::Device dev; + dev.init(); + for (const DRM::Connector &conn : dev.connectors()) { + if (conn.status() == DRM::Connector::Connected) { + std::cout << conn.name() << std::endl; + } + } + } +#endif + + /* 3. Create the camera sessions. */ std::vector> sessions; if (options_.isSet(OptCamera)) { @@ -229,7 +250,7 @@ int CamApp::run() } } - /* 3. Print camera information. */ + /* 4. Print camera information. */ if (options_.isSet(OptListControls) || options_.isSet(OptListProperties) || options_.isSet(OptInfo)) { @@ -243,7 +264,7 @@ int CamApp::run() } } - /* 4. Start capture. */ + /* 5. Start capture. */ for (const auto &session : sessions) { if (!session->options().isSet(OptCapture)) continue; @@ -257,7 +278,7 @@ int CamApp::run() loopUsers_++; } - /* 5. Enable hotplug monitoring. */ + /* 6. Enable hotplug monitoring. */ if (options_.isSet(OptMonitor)) { std::cout << "Monitoring new hotplug and unplug events" << std::endl; std::cout << "Press Ctrl-C to interrupt" << std::endl; @@ -271,7 +292,7 @@ int CamApp::run() if (loopUsers_) loop_.exec(); - /* 6. Stop capture. */ + /* 7. Stop capture. */ for (const auto &session : sessions) { if (!session->options().isSet(OptCapture)) continue; diff --git a/src/cam/main.h b/src/cam/main.h index 1c2fab76..72050d27 100644 --- a/src/cam/main.h +++ b/src/cam/main.h @@ -21,6 +21,9 @@ enum { OptListControls = 256, OptStrictFormats = 257, OptMetadata = 258, +#ifdef HAVE_KMS + OptListDisplays = 259 +#endif }; #endif /* __CAM_MAIN_H__ */