From patchwork Wed Oct 27 10:04:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Curtin X-Patchwork-Id: 14364 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 30638BDB1C for ; Wed, 27 Oct 2021 10:04:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 62C636487F; Wed, 27 Oct 2021 12:04:52 +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="dyhXrimc"; 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 67CC460123 for ; Wed, 27 Oct 2021 12:04:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635329089; 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=dyhXrimcbval2VmdR2RMzCAx1VL6l9Kou9EAuf/JxJlnkDnAyVX+u46CEbxxCNKabG5oYm HjRLKbNszX8j1KK/sd69LHiPLDWsTptpqI/bzs2VXRQftuN3JaFGa0+7xU4cCf+r8Y2Yq3 yGNT1csxDLyKnW+RWi9VCkr0e7dIHH4= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-322-gWhfY46AOCqLtQUxQlnVhA-1; Wed, 27 Oct 2021 06:04:48 -0400 X-MC-Unique: gWhfY46AOCqLtQUxQlnVhA-1 Received: by mail-wr1-f69.google.com with SMTP id y16-20020a5d4710000000b0017440201e67so14997wrq.1 for ; Wed, 27 Oct 2021 03:04:47 -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=CwNxHg/l4XDIqFhVEtCPbo4Htw6BSrnn/FI1lENHQE1ZERWzshMW7uO3uuM8/fVoqP EOVzK9XWfpONlBJKAgFHolqyM/QG0NTdiZZVrBw6p8MwJKygWuqei7ltNtcXMizHGwB8 WhXnFp8rGbDkyZFwm0H8Qzr04NhkymSoqdDxFwKF2jERRqvLTh7Rx2+FbP7A6xeCQicF J0GsWSXltSjKXENan1kB31NRtFZ8K0LM6RNTrnfXno5nYguiFV7YP2TXCg4+XiartcCa WfHI3PK5K4l75b76gSRpmADaa6VELceHlGTsc+3h4DCd2+qLwgyP1tPOwCSr5KImzk3+ lSfQ== X-Gm-Message-State: AOAM533qwYieLfFFrpuynhCU874bmjbVzjQ6+DISTio0PplaVttc0rE6 JfO4a29TWfOKx/KQ4HoyzFeRKwli5VwEe6BGN+eMZyYrWJcjnvgCO1UaEDZq7kaj+urkoKNry9k hwYYn7fNcvhtk4CR1gf8g38JBawce5VOiGnlNq6NAe9p/dxmi1sM5aXX+WKi1kn0uRMcHz4ibg6 XkGXgpltYG X-Received: by 2002:a7b:ce98:: with SMTP id q24mr4777306wmj.72.1635329086450; Wed, 27 Oct 2021 03:04:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlg6rLMpGD4mqvgRRKHb1Cup8FTdv2hyw6LjsT2goX4QWp+QF7b9nDhkNgmvAnTtUYHuW/MQ== X-Received: by 2002:a7b:ce98:: with SMTP id q24mr4777276wmj.72.1635329086045; Wed, 27 Oct 2021 03:04:46 -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 m31sm2939905wms.25.2021.10.27.03.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 03:04:45 -0700 (PDT) From: Eric Curtin To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Oct 2021 11:04:41 +0100 Message-Id: <20211027100441.18248-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__ */