From patchwork Tue Jan 4 22:51:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 15245 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 B9F3DBE080 for ; Tue, 4 Jan 2022 22:51:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E933F604F5; Tue, 4 Jan 2022 23:51:53 +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="WnqcVx8t"; 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 8FB0C604F4 for ; Tue, 4 Jan 2022 23:51:51 +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 0E94E501; Tue, 4 Jan 2022 23:51:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1641336711; bh=io7EGYhkYQIS4eyJbHThy2HIUuSQIENEysSND0VkofM=; h=From:To:Cc:Subject:Date:From; b=WnqcVx8tjhUSL/avMlMaB4WBTewCLyQ/35z5s+0rhLiSoYHLv/Vbf0oqH/4IuHwU3 Fr/FgwFbwpWwbpXTlhWQCxAL8CB7v+//DOmKJhT02Kio2uMdyWc7CVa07MfHlSAJQQ uf78lCAZj8BFnYDrBE2bAI6smHNRhN1Z5R2lBYV8= From: Kieran Bingham To: libcamera devel Date: Tue, 4 Jan 2022 22:51:47 +0000 Message-Id: <20220104225147.1340786-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] v4l2: Provide libcamera-v4l2 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: $ libcamera-v4l2 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 Signed-off-by: Kieran Bingham --- This will install 'libcamera-v4l2' in the bindir (/usr/bin/) alongside cam. src/v4l2/libcamera-v4l2.in | 11 +++++++++++ src/v4l2/meson.build | 14 ++++++++++++++ 2 files changed, 25 insertions(+) create mode 100755 src/v4l2/libcamera-v4l2.in diff --git a/src/v4l2/libcamera-v4l2.in b/src/v4l2/libcamera-v4l2.in new file mode 100755 index 000000000000..e8f77ec6d784 --- /dev/null +++ b/src/v4l2/libcamera-v4l2.in @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ "$LD_PRELOAD" = "" ] ; then + LD_PRELOAD='@LIBCAMERA_V4L2_SO@' +else + LD_PRELOAD="$LD_PRELOAD "'@LIBCAMERA_V4L2_SO@' +fi + +export LD_PRELOAD + +exec "$@" diff --git a/src/v4l2/meson.build b/src/v4l2/meson.build index f78497b6799b..3b17668e8df5 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 : 'libcamera-v4l2.in', + output : 'libcamera-v4l2', + configuration : config_h, + install_dir : get_option('bindir'))