[{"id":21946,"web_url":"https://patchwork.libcamera.org/comment/21946/","msgid":"<164133704716.1286136.3162486397703191335@Monstersaurus>","date":"2022-01-04T22:57:27","subject":"Re: [libcamera-devel] [PATCH] v4l2: Provide libcamera-v4l2 wrapper\n\tscript","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"I should have mentioned, this was heavily inspired by Wim Taymans\nimplementation at\n  https://github.com/PipeWire/pipewire/blob/master/pipewire-v4l2/src/pw-v4l2.in\n\nWhere I think their V4L2 layer was inspired by ours ;-)\n--\nKieran\n\n\nQuoting Kieran Bingham (2022-01-04 22:51:47)\n> Support easier usage of the v4l2 compatibility layer with a script that\n> handles the LD_PRELOAD for applications.\n> \n> The wrapper can be prefixed to launch any application with the preload\n> set:\n> \n>  $ libcamera-v4l2 v4l2-ctl --list-devices\n>  \\_SB_.PCI0.GP13.XHC0.RHUB.PRT4- (libcamera:0):\n>         /dev/video0\n> \n>  platform/vimc.0 Sensor B (libcamera:1):\n>         /dev/video2\n>         /dev/video3\n>         /dev/video4\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n> \n> This will install 'libcamera-v4l2' in the bindir (/usr/bin/) alongside\n> cam.\n> \n>  src/v4l2/libcamera-v4l2.in | 11 +++++++++++\n>  src/v4l2/meson.build       | 14 ++++++++++++++\n>  2 files changed, 25 insertions(+)\n>  create mode 100755 src/v4l2/libcamera-v4l2.in\n> \n> diff --git a/src/v4l2/libcamera-v4l2.in b/src/v4l2/libcamera-v4l2.in\n> new file mode 100755\n> index 000000000000..e8f77ec6d784\n> --- /dev/null\n> +++ b/src/v4l2/libcamera-v4l2.in\n> @@ -0,0 +1,11 @@\n> +#!/bin/sh\n> +\n> +if [ \"$LD_PRELOAD\" = \"\" ] ; then\n> +   LD_PRELOAD='@LIBCAMERA_V4L2_SO@'\n> +else\n> +   LD_PRELOAD=\"$LD_PRELOAD \"'@LIBCAMERA_V4L2_SO@'\n> +fi\n> +\n> +export LD_PRELOAD\n> +\n> +exec \"$@\"\n> diff --git a/src/v4l2/meson.build b/src/v4l2/meson.build\n> index f78497b6799b..3b17668e8df5 100644\n> --- a/src/v4l2/meson.build\n> +++ b/src/v4l2/meson.build\n> @@ -33,3 +33,17 @@ v4l2_compat = shared_library('v4l2-compat',\n>                               install : true,\n>                               dependencies : [libcamera_private, libdl],\n>                               cpp_args : v4l2_compat_cpp_args)\n> +\n> +# Provide a wrapper script to support easily loading applications with the V4L2\n> +# adaptation layer\n> +\n> +config_h.set('LIBCAMERA_V4L2_SO', get_option('prefix') / get_option('libdir') / 'v4l2-compat.so')\n> +\n> +summary({\n> +    'LIBCAMERA_V4L2_SO' : config_h.get('LIBCAMERA_V4L2_SO'),\n> +}, section : 'Paths')\n> +\n> +configure_file(input : 'libcamera-v4l2.in',\n> +               output : 'libcamera-v4l2',\n> +               configuration : config_h,\n> +               install_dir : get_option('bindir'))\n> -- \n> 2.30.2\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 5E3D7BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  4 Jan 2022 22:57:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B619860921;\n\tTue,  4 Jan 2022 23:57:31 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4F7D8604F4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  4 Jan 2022 23:57:30 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DA5D6501\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  4 Jan 2022 23:57:29 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"h6q6KD7M\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1641337050;\n\tbh=EGq41xVXb5xz9QGD/TYnUnaXit2/DQ5ECN/s4mBZEr8=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=h6q6KD7MYTJ5/fpnISbBk/9Fm9sornNDPpHvaQRasfOW9hEFp5Ss5RZOwQi61FOl+\n\tCVlHHuydxAmdxm1lgAErTdcta9IR9RnZGtn05WhNio/FO0od2KtWBsf/tktmkLQexM\n\t2+8GPf5akGBhL9NimJby37d1RHcto/VSmRKLVFJQ=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220104225147.1340786-1-kieran.bingham@ideasonboard.com>","References":"<20220104225147.1340786-1-kieran.bingham@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Tue, 04 Jan 2022 22:57:27 +0000","Message-ID":"<164133704716.1286136.3162486397703191335@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH] v4l2: Provide libcamera-v4l2 wrapper\n\tscript","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]