[{"id":22096,"web_url":"https://patchwork.libcamera.org/comment/22096/","msgid":"<YflsBIkUNY01PdBA@pendragon.ideasonboard.com>","date":"2022-02-01T17:21:08","subject":"Re: [libcamera-devel] [PATCH v4] v4l2: Provide libcamerify wrapper\n\tscript","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nOn Tue, Feb 01, 2022 at 05:18:20PM +0000, Kieran Bingham wrote:\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>  \t/dev/video0\n> \n>  platform/vimc.0 Sensor B (libcamera:1):\n>  \t/dev/video2\n>  \t/dev/video3\n>  \t/dev/video4\n> \n> Specifying '-d' once before the command to run will enable V4L2Compat\n> layer debug output from libcamera.\n> \n> Specifying '-d' twice will enable all debug levels from all libcamera\n> components and provide a very detailed log for analysis.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n> v4:\n>  - Fix up forgotten cleanup in the meson.build and remove path summary.\n> \n>  src/v4l2/libcamerify.in | 47 +++++++++++++++++++++++++++++++++++++++++\n>  src/v4l2/meson.build    | 11 ++++++++++\n>  2 files changed, 58 insertions(+)\n>  create mode 100755 src/v4l2/libcamerify.in\n> \n> diff --git a/src/v4l2/libcamerify.in b/src/v4l2/libcamerify.in\n> new file mode 100755\n> index 000000000000..c4ea273fa627\n> --- /dev/null\n> +++ b/src/v4l2/libcamerify.in\n> @@ -0,0 +1,47 @@\n> +#!/bin/sh\n> +# SPDX-License-Identifier: GPL-2.0-or-later\n> +\n> +help() {\n> +\techo \"$0: Load an application with libcamera V4L2 compatibility layer preload\"\n> +\techo \" $0 [OPTIONS...] executable [args]\"\n> +\techo \" -d, --debug\tIncrease log level\"\n> +}\n> +\n> +debug=0\n> +while [ $# -gt 0 ]; do\n> +\tcase $1 in\n> +\t\t-d|--debug)\n> +\t\t\tdebug=$((debug+1))\n> +\t\t\t;;\n> +\t\t-h)\n> +\t\t\thelp;\n> +\t\t\texit 0\n> +\t\t\t;;\n> +\t\t--)\n> +\t\t\tshift;\n> +\t\t\tbreak;;\n> +\t\t-*)\n> +\t\t\techo \"Unrecognised option: $1\";\n> +\t\t\thelp;\n> +\t\t\texit 1\n> +\t\t\t;;\n> +\t\t*)\n> +\t\t\tbreak\n> +\t\t\t;;\n> +\tesac\n> +\tshift\n> +done\n> +\n> +[ $debug -gt 0 ] && loglevel=V4L2Compat:0\n> +[ $debug -gt 1 ] && loglevel=0\n> +[ \"$loglevel\" != \"\" ] && export LIBCAMERA_LOG_LEVELS=$loglevel\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..6e587488cd3a 100644\n> --- a/src/v4l2/meson.build\n> +++ b/src/v4l2/meson.build\n> @@ -33,3 +33,14 @@ 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\ns/layer/layer./\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\n> +cdata = configuration_data()\n> +cdata.set('LIBCAMERA_V4L2_SO', get_option('prefix') / get_option('libdir') / 'v4l2-compat.so')\n> +\n> +configure_file(input : 'libcamerify.in',\n> +               output : 'libcamerify',\n> +               configuration : cdata,\n> +               install_dir : get_option('bindir'))","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 66CDCBDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Feb 2022 17:21:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C1F31609E2;\n\tTue,  1 Feb 2022 18:21:33 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 637C3609B9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Feb 2022 18:21:32 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D5674332;\n\tTue,  1 Feb 2022 18:21:31 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"OR+C5Z0d\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1643736092;\n\tbh=m9doh0TOCFgQacCAr5JWN+m6DhaquHMWjLqgkaDVtpY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=OR+C5Z0dyYze1ke6Nb36yjCWRL7LiN9XGzS9zFT+CdmVqY2oEuuy5DFZ2eL7VRpRF\n\t8PBFbGF1MKfKKuJ09ZjJJM3qyXgo9AN9thAMMBiLSKunbv7qrMqCM9cksyJlLUe8yZ\n\tyrNh9GtuOPsIvAtQrQPBQ5jgvbjyY5MKyAi+mfk8=","Date":"Tue, 1 Feb 2022 19:21:08 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<YflsBIkUNY01PdBA@pendragon.ideasonboard.com>","References":"<20220201171820.399574-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220201171820.399574-1-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v4] v4l2: Provide libcamerify 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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22101,"web_url":"https://patchwork.libcamera.org/comment/22101/","msgid":"<20220202114925.GB174255@pyrite.rasen.tech>","date":"2022-02-02T11:49:25","subject":"Re: [libcamera-devel] [PATCH v4] v4l2: Provide libcamerify wrapper\n\tscript","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Kieran,\n\nOn Tue, Feb 01, 2022 at 05:18:20PM +0000, Kieran Bingham wrote:\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>  \t/dev/video0\n> \n>  platform/vimc.0 Sensor B (libcamera:1):\n>  \t/dev/video2\n>  \t/dev/video3\n>  \t/dev/video4\n> \n> Specifying '-d' once before the command to run will enable V4L2Compat\n> layer debug output from libcamera.\n> \n> Specifying '-d' twice will enable all debug levels from all libcamera\n> components and provide a very detailed log for analysis.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n> v4:\n>  - Fix up forgotten cleanup in the meson.build and remove path summary.\n> \n>  src/v4l2/libcamerify.in | 47 +++++++++++++++++++++++++++++++++++++++++\n>  src/v4l2/meson.build    | 11 ++++++++++\n>  2 files changed, 58 insertions(+)\n>  create mode 100755 src/v4l2/libcamerify.in\n> \n> diff --git a/src/v4l2/libcamerify.in b/src/v4l2/libcamerify.in\n> new file mode 100755\n> index 000000000000..c4ea273fa627\n> --- /dev/null\n> +++ b/src/v4l2/libcamerify.in\n> @@ -0,0 +1,47 @@\n> +#!/bin/sh\n> +# SPDX-License-Identifier: GPL-2.0-or-later\n> +\n> +help() {\n> +\techo \"$0: Load an application with libcamera V4L2 compatibility layer preload\"\n> +\techo \" $0 [OPTIONS...] executable [args]\"\n> +\techo \" -d, --debug\tIncrease log level\"\n> +}\n> +\n> +debug=0\n> +while [ $# -gt 0 ]; do\n> +\tcase $1 in\n> +\t\t-d|--debug)\n> +\t\t\tdebug=$((debug+1))\n> +\t\t\t;;\n> +\t\t-h)\n> +\t\t\thelp;\n> +\t\t\texit 0\n> +\t\t\t;;\n> +\t\t--)\n> +\t\t\tshift;\n> +\t\t\tbreak;;\n> +\t\t-*)\n> +\t\t\techo \"Unrecognised option: $1\";\n> +\t\t\thelp;\n> +\t\t\texit 1\n> +\t\t\t;;\n> +\t\t*)\n> +\t\t\tbreak\n> +\t\t\t;;\n> +\tesac\n> +\tshift\n> +done\n> +\n> +[ $debug -gt 0 ] && loglevel=V4L2Compat:0\n> +[ $debug -gt 1 ] && loglevel=0\n> +[ \"$loglevel\" != \"\" ] && export LIBCAMERA_LOG_LEVELS=$loglevel\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..6e587488cd3a 100644\n> --- a/src/v4l2/meson.build\n> +++ b/src/v4l2/meson.build\n> @@ -33,3 +33,14 @@ 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> +cdata = configuration_data()\n> +cdata.set('LIBCAMERA_V4L2_SO', get_option('prefix') / get_option('libdir') / 'v4l2-compat.so')\n> +\n> +configure_file(input : 'libcamerify.in',\n> +               output : 'libcamerify',\n> +               configuration : cdata,\n> +               install_dir : get_option('bindir'))\n> -- \n> 2.32.0\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 9895ABF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  2 Feb 2022 11:49:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0A402609B5;\n\tWed,  2 Feb 2022 12:49:34 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AC235609B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  2 Feb 2022 12:49:32 +0100 (CET)","from pyrite.rasen.tech (h175-177-042-148.catv02.itscom.jp\n\t[175.177.42.148])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2EAC22F3;\n\tWed,  2 Feb 2022 12:49:30 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"iIrxEM6C\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1643802572;\n\tbh=4bWSHfhIAeu1mKtg0QlQ62Rh5O87KP9vxEWMfjWzrnU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=iIrxEM6CcrMrgKM6YtVekw+dEGAQoFFelrz6Ha/qemesdmEn2PBd7kSGSm/uJtFdy\n\tCTWSSlpL7VJ38sGoYQokoM89kCFkFKMMaznwGJamXI2IRaln6sGX3C8XF8zviyRjxo\n\tRtwL6XEsl29+GBdLzDU3eaGYOb4hlQ4+864u6DyM=","Date":"Wed, 2 Feb 2022 20:49:25 +0900","From":"paul.elder@ideasonboard.com","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<20220202114925.GB174255@pyrite.rasen.tech>","References":"<20220201171820.399574-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20220201171820.399574-1-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v4] v4l2: Provide libcamerify 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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]