From patchwork Tue Jan 22 23:45:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 342 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5AA2060C83 for ; Wed, 23 Jan 2019 00:46:44 +0100 (CET) X-Halon-ID: ec8c39d8-1e9f-11e9-911a-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id ec8c39d8-1e9f-11e9-911a-0050569116f7; Wed, 23 Jan 2019 00:46:22 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 23 Jan 2019 00:45:05 +0100 Message-Id: <20190122234505.32634-9-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190122234505.32634-1-niklas.soderlund@ragnatech.se> References: <20190122234505.32634-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 8/8] [POC] cam: add hack option to staticly configure a pipeline X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jan 2019 23:46:44 -0000 This is a hack prof of concept to try out the application API to query a camera about its streams and then proceed to use that information to configure a static resolution of 640x480. Not-yet-Signed-off-by: Niklas Söderlund --- src/cam/main.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/cam/main.cpp b/src/cam/main.cpp index 22211670c6250887..6ff6dc978d91d323 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -21,6 +21,7 @@ enum { OptCamera = 'c', OptHelp = 'h', OptList = 'l', + OptStreamsConfig = 'C', }; static int parseOptions(int argc, char *argv[]) @@ -32,6 +33,7 @@ static int parseOptions(int argc, char *argv[]) "camera"); parser.addOption(OptHelp, "Display this help message", "help"); parser.addOption(OptList, "List all cameras", "list"); + parser.addOption(OptStreamsConfig, "Configure the first stream to 640x480", "hack-config"); options = std::move(parser.parse(argc, argv)); if (!options.valid()) @@ -79,6 +81,42 @@ int main(int argc, char **argv) } } + if (options.isSet(OptStreamsConfig)) { + if (!options.isSet(OptCamera)) { + std::cout << "Can't configure stream, no camera selected" << std::endl; + goto out; + } + + std::shared_ptr cam = cm->get(options[OptCamera]); + if (!cam) { + std::cout << "Camera " << options[OptCamera] + << " not found" << std::endl; + goto out; + } + + std::vector streams = cam->streams(); + if (streams.size() != 1) { + std::cout << "Camera have " << streams.size() << + " streams, I only know how to work with 1" << std::endl; + goto out; + } + + StreamConfiguration config = StreamConfiguration(streams.front()); + config.setDimension(640, 480); + + std::vector configs; + configs.push_back(&config); + + if (cam->acquire()) { + std::cout << "Failed to acquire camera" << std::endl; + goto out; + } + + if (cam->configure(configs)) + std::cout << "Failed to configure camera" << std::endl; + } + +out: cm->stop(); return 0;