From patchwork Mon Jan 31 21:07:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 15304 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 17071BF415 for ; Mon, 31 Jan 2022 21:08:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5A0B6609AF; Mon, 31 Jan 2022 22:08:03 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RuS5Z75Z"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5B5E4609AC for ; Mon, 31 Jan 2022 22:08:01 +0100 (CET) Received: from Monstersaurus.ksquared.org.uk.beta.tailscale.net (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E4D04D97; Mon, 31 Jan 2022 22:08:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1643663281; bh=sdvXI1mERAYn6dKCzuC+HynsGZb8TG//bQi5gjIC50k=; h=From:To:Cc:Subject:Date:From; b=RuS5Z75ZZqDPMsKlh/J2yt7gPsUWPV0UFPF6/oEFDYnR4VL2QsE+Sx1WRJZzwgL24 fMUvhNlxmt25iz/n4l8+IPamqaWkAOPsjcA226aZpvw9kF/MGuCUcu//cXP2qD6tf0 J+WwVwq7XNH7lm398VW5wvUiS+9/YyuvATSp3LCs= From: Kieran Bingham To: libcamera devel Date: Mon, 31 Jan 2022 21:07:57 +0000 Message-Id: <20220131210757.105299-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] v4l2: Provide libcamerify wrapper script 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" Support easier usage of the v4l2 compatibility layer with a script that handles the LD_PRELOAD for applications. The wrapper can be prefixed to launch any application with the preload set: $ libcamerify v4l2-ctl --list-devices \_SB_.PCI0.GP13.XHC0.RHUB.PRT4- (libcamera:0): /dev/video0 platform/vimc.0 Sensor B (libcamera:1): /dev/video2 /dev/video3 /dev/video4 Specifying '-d' once before the command to run will enable V4L2Compat layer debug output from libcamera. Specifying '-d' twice will enable all debug levels from all libcamera components and provide a very detailed log for analysis. Signed-off-by: Kieran Bingham --- v2: - rename to libcamerify (from libcamera-v4l2) - add extending support for setting debug log levels. src/v4l2/libcamerify.in | 34 ++++++++++++++++++++++++++++++++++ src/v4l2/meson.build | 14 ++++++++++++++ 2 files changed, 48 insertions(+) create mode 100755 src/v4l2/libcamerify.in diff --git a/src/v4l2/libcamerify.in b/src/v4l2/libcamerify.in new file mode 100755 index 000000000000..161f5e49190e --- /dev/null +++ b/src/v4l2/libcamerify.in @@ -0,0 +1,34 @@ +#!/bin/sh + +if [ "$LD_PRELOAD" = "" ] ; then + LD_PRELOAD='@LIBCAMERA_V4L2_SO@' +else + LD_PRELOAD="$LD_PRELOAD "'@LIBCAMERA_V4L2_SO@' +fi + +export LD_PRELOAD + +help() { + echo "$0: Load an application with libcamera V4L2 compatibility layer preload" + echo " $0 [OPTIONS...] executable [args]" + echo " -d, --debug Increase log level" + exit 1; +} + +debug=0 +while [ $# -gt 0 ]; do + case $1 in + -d|--debug) debug=$((debug+1));; + -h) help; break;; + --) shift; break;; + -*) echo "Unrecognised option: $1"; help; break;; + *) break;; + esac + shift +done + +[ $debug -gt 0 ] && loglevel=V4L2Compat:0 +[ $debug -gt 1 ] && loglevel=0 +[ "$loglevel" != "" ] && export LIBCAMERA_LOG_LEVELS=$loglevel + +exec "$@" diff --git a/src/v4l2/meson.build b/src/v4l2/meson.build index f78497b6799b..07ff9a6939d2 100644 --- a/src/v4l2/meson.build +++ b/src/v4l2/meson.build @@ -33,3 +33,17 @@ v4l2_compat = shared_library('v4l2-compat', install : true, dependencies : [libcamera_private, libdl], cpp_args : v4l2_compat_cpp_args) + +# Provide a wrapper script to support easily loading applications with the V4L2 +# adaptation layer + +config_h.set('LIBCAMERA_V4L2_SO', get_option('prefix') / get_option('libdir') / 'v4l2-compat.so') + +summary({ + 'LIBCAMERA_V4L2_SO' : config_h.get('LIBCAMERA_V4L2_SO'), +}, section : 'Paths') + +configure_file(input : 'libcamerify.in', + output : 'libcamerify', + configuration : config_h, + install_dir : get_option('bindir'))