[{"id":22082,"web_url":"https://patchwork.libcamera.org/comment/22082/","msgid":"<YfjfVH/LK+QDjAcf@pendragon.ideasonboard.com>","date":"2022-02-01T07:20:52","subject":"Re: [libcamera-devel] [PATCH v2] 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 Mon, Jan 31, 2022 at 09:07:57PM +0000, Kieran Bingham wrote:\n> Support easier usage of the v4l2 compatibility layer with a script that\n\ns/v4l2/V4L2/\n\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>  $ libcamerify 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> v2:\n>  - rename to libcamerify (from libcamera-v4l2)\n>  - add extending support for setting debug log levels.\n> \n> \n>  src/v4l2/libcamerify.in | 34 ++++++++++++++++++++++++++++++++++\n>  src/v4l2/meson.build    | 14 ++++++++++++++\n>  2 files changed, 48 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..161f5e49190e\n> --- /dev/null\n> +++ b/src/v4l2/libcamerify.in\n> @@ -0,0 +1,34 @@\n> +#!/bin/sh\n\nLicense ?\n\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\nCan you move this just before the exec call, to avoid LD_PRELOADing the\nlibrary in other commands executed by thie script ?\n\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> +\texit 1;\n> +}\n> +\n> +debug=0\n> +while [ $# -gt 0 ]; do\n> +\tcase $1 in\n> +\t\t-d|--debug) debug=$((debug+1));;\n> +\t\t-h) help; break;;\n\n\"break\" should be \"exit 0\".\n\n> +\t\t--) shift; break;;\n> +\t\t-*) echo \"Unrecognised option: $1\"; help; break;;\n\nSame here.\n\n> +\t\t*) break;;\n\nI'd find this more readable:\n\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\tbreak\n\t\t\t;;\n\t\t--)\n\t\t\tshift\n\t\t\tbreak\n\t\t\t;;\n\t\t-*)\n\t\t\techo \"Unrecognised option: $1\"\n\t\t\thelp\n\t\t\tbreak\n\t\t\t;;\n\t\t*)\n\t\t\tbreak\n\t\t\t;;\n\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> +exec \"$@\"\n> diff --git a/src/v4l2/meson.build b/src/v4l2/meson.build\n> index f78497b6799b..07ff9a6939d2 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\nI don't think this should be added to config.h. Can you create a\nseparate variable ?\n\ncdata = configuration_data()\ncdata.set('LIBCAMERA_V4L2_SO', get_option('prefix') / get_option('libdir') / 'v4l2-compat.so')\n\nI also wonder if we could use v4l2_compat.name() instead of\n'v4l2-compat.so' (but that's only available starting in meson 0.54).\n\n> +\n> +summary({\n> +    'LIBCAMERA_V4L2_SO' : config_h.get('LIBCAMERA_V4L2_SO'),\n> +}, section : 'Paths')\n\nI would have skipped this. It's a bit out of place, with all the other\npaths being directories.\n\n> +\n> +configure_file(input : 'libcamerify.in',\n> +               output : 'libcamerify',\n> +               configuration : config_h,\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 3AB3BBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Feb 2022 07:21:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 671B4609AC;\n\tTue,  1 Feb 2022 08:21:17 +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 D1FA6604F1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Feb 2022 08:21:15 +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 4E57D332;\n\tTue,  1 Feb 2022 08:21:15 +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=\"iRBw3k31\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1643700075;\n\tbh=ZpUgtRdoYuOns+lHlwz05BQKqH/YYh82IlCGaKwxGr0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=iRBw3k31B+lQ0c+plpZgoBC4bKnG7uy+fSPtqCB3zmTBCk6HbzFdCp/5sbcKMBAM2\n\tFZnSaEPZVBVbv9h/xXWfhit3+62ecc7YzdSk/jlAsaHhpi3xiEnY8wD/GOyPT0ofIR\n\t7rjVSRi9NG3ME1y8/7w6RcVLehlKRLVFGYpgo6r4=","Date":"Tue, 1 Feb 2022 09:20:52 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<YfjfVH/LK+QDjAcf@pendragon.ideasonboard.com>","References":"<20220131210757.105299-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220131210757.105299-1-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2] 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":22092,"web_url":"https://patchwork.libcamera.org/comment/22092/","msgid":"<164371116680.208029.1363712483854379206@Monstersaurus>","date":"2022-02-01T10:26:06","subject":"Re: [libcamera-devel] [PATCH v2] v4l2: Provide libcamerify wrapper\n\tscript","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2022-02-01 07:20:52)\n> Hi Kieran,\n> \n> Thank you for the patch.\n> \n> On Mon, Jan 31, 2022 at 09:07:57PM +0000, Kieran Bingham wrote:\n> > Support easier usage of the v4l2 compatibility layer with a script that\n> \n> s/v4l2/V4L2/\n> \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> >  $ libcamerify 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> > 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> > v2:\n> >  - rename to libcamerify (from libcamera-v4l2)\n> >  - add extending support for setting debug log levels.\n> > \n> > \n> >  src/v4l2/libcamerify.in | 34 ++++++++++++++++++++++++++++++++++\n> >  src/v4l2/meson.build    | 14 ++++++++++++++\n> >  2 files changed, 48 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..161f5e49190e\n> > --- /dev/null\n> > +++ b/src/v4l2/libcamerify.in\n> > @@ -0,0 +1,34 @@\n> > +#!/bin/sh\n> \n> License ?\n> \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> Can you move this just before the exec call, to avoid LD_PRELOADing the\n> library in other commands executed by thie script ?\n\nEeep yes. How did I miss that.\n\n> \n> > +\n> > +help() {\n> > +     echo \"$0: Load an application with libcamera V4L2 compatibility layer preload\"\n> > +     echo \" $0 [OPTIONS...] executable [args]\"\n> > +     echo \" -d, --debug      Increase log level\"\n> > +     exit 1;\n> > +}\n> > +\n> > +debug=0\n> > +while [ $# -gt 0 ]; do\n> > +     case $1 in\n> > +             -d|--debug) debug=$((debug+1));;\n> > +             -h) help; break;;\n> \n> \"break\" should be \"exit 0\".\n\nhelp() was already calling exit 1;, but yes, I can move that in here.\n\n\n> \n> > +             --) shift; break;;\n> > +             -*) echo \"Unrecognised option: $1\"; help; break;;\n> \n> Same here.\n> \n> > +             *) break;;\n> \n> I'd find this more readable:\n> \n>                 -d|--debug)\n>                         debug=$((debug+1))\n>                         ;;\n>                 -h)\n>                         help\n>                         break\n>                         ;;\n>                 --)\n>                         shift\n>                         break\n>                         ;;\n>                 -*)\n>                         echo \"Unrecognised option: $1\"\n>                         help\n>                         break\n>                         ;;\n>                 *)\n>                         break\n>                         ;;\n> \n\nsure\n\n> > +     esac\n> > +     shift\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> > +exec \"$@\"\n> > diff --git a/src/v4l2/meson.build b/src/v4l2/meson.build\n> > index f78497b6799b..07ff9a6939d2 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> I don't think this should be added to config.h. Can you create a\n> separate variable ?\n> \n> cdata = configuration_data()\n> cdata.set('LIBCAMERA_V4L2_SO', get_option('prefix') / get_option('libdir') / 'v4l2-compat.so')\n> \n> I also wonder if we could use v4l2_compat.name() instead of\n> 'v4l2-compat.so' (but that's only available starting in meson 0.54).\n\nI also asked in IRC #meson about this, hoping I could get a binary\ntarget to tell me it's full installation path but alas...\n\n> \n> > +\n> > +summary({\n> > +    'LIBCAMERA_V4L2_SO' : config_h.get('LIBCAMERA_V4L2_SO'),\n> > +}, section : 'Paths')\n> \n> I would have skipped this. It's a bit out of place, with all the other\n> paths being directories.\n\nBut it's also a path/file that (at least without this script) people need to\nknow, so that tehy can do LD_PRELOAD= themselves.\n\nI can drop it though, as I expect this script will help exactly those\nusers.\n\n\n> > +\n> > +configure_file(input : 'libcamerify.in',\n> > +               output : 'libcamerify',\n> > +               configuration : config_h,\n> > +               install_dir : get_option('bindir'))\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 C6115BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Feb 2022 10:26:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 18E86609E2;\n\tTue,  1 Feb 2022 11:26:11 +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 9605D609AF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Feb 2022 11:26:09 +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 282B1332;\n\tTue,  1 Feb 2022 11:26:09 +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=\"TAlGo2vs\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1643711169;\n\tbh=1GX5ExNbhsFBHMEz8OGtjPhyEEyG/XJum87eVc0fiZI=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=TAlGo2vsPYnqHX0HJQi3yau9LdkGLPy+HliW22vKcrFnInAhUXkdTRB33+A9FUXbW\n\tPsxs8JZywRBbaAq+0flTUHijWAwmDOXXT17IRM6oBW9FF9heXSBdLow++jfIIdrU0h\n\tPmvUKpmjidjKBVj2IVIQ8RtMEwb1BEIn52yconHE=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<YfjfVH/LK+QDjAcf@pendragon.ideasonboard.com>","References":"<20220131210757.105299-1-kieran.bingham@ideasonboard.com>\n\t<YfjfVH/LK+QDjAcf@pendragon.ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Date":"Tue, 01 Feb 2022 10:26:06 +0000","Message-ID":"<164371116680.208029.1363712483854379206@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v2] 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":22094,"web_url":"https://patchwork.libcamera.org/comment/22094/","msgid":"<YfkNbWonelNca+7/@pendragon.ideasonboard.com>","date":"2022-02-01T10:37:33","subject":"Re: [libcamera-devel] [PATCH v2] 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\nOn Tue, Feb 01, 2022 at 10:26:06AM +0000, Kieran Bingham wrote:\n> Quoting Laurent Pinchart (2022-02-01 07:20:52)\n> > On Mon, Jan 31, 2022 at 09:07:57PM +0000, Kieran Bingham wrote:\n> > > Support easier usage of the v4l2 compatibility layer with a script that\n> > \n> > s/v4l2/V4L2/\n> > \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> > >  $ libcamerify 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> > > 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> > > v2:\n> > >  - rename to libcamerify (from libcamera-v4l2)\n> > >  - add extending support for setting debug log levels.\n> > > \n> > > \n> > >  src/v4l2/libcamerify.in | 34 ++++++++++++++++++++++++++++++++++\n> > >  src/v4l2/meson.build    | 14 ++++++++++++++\n> > >  2 files changed, 48 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..161f5e49190e\n> > > --- /dev/null\n> > > +++ b/src/v4l2/libcamerify.in\n> > > @@ -0,0 +1,34 @@\n> > > +#!/bin/sh\n> > \n> > License ?\n> > \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> > Can you move this just before the exec call, to avoid LD_PRELOADing the\n> > library in other commands executed by thie script ?\n> \n> Eeep yes. How did I miss that.\n> \n> > > +\n> > > +help() {\n> > > +     echo \"$0: Load an application with libcamera V4L2 compatibility layer preload\"\n> > > +     echo \" $0 [OPTIONS...] executable [args]\"\n> > > +     echo \" -d, --debug      Increase log level\"\n> > > +     exit 1;\n> > > +}\n> > > +\n> > > +debug=0\n> > > +while [ $# -gt 0 ]; do\n> > > +     case $1 in\n> > > +             -d|--debug) debug=$((debug+1));;\n> > > +             -h) help; break;;\n> > \n> > \"break\" should be \"exit 0\".\n> \n> help() was already calling exit 1;, but yes, I can move that in here.\n\nAh yes I didn't notice. Do applications typically return an error status\nwith -h (\"exit 1\") or a success status (\"exit 0\") ? I usually code the\nlatter, but I may be wrong.\n\n> > > +             --) shift; break;;\n> > > +             -*) echo \"Unrecognised option: $1\"; help; break;;\n> > \n> > Same here.\n\nHere it should be \"exit 1\".\n\n> > > +             *) break;;\n> > \n> > I'd find this more readable:\n> > \n> >                 -d|--debug)\n> >                         debug=$((debug+1))\n> >                         ;;\n> >                 -h)\n> >                         help\n> >                         break\n> >                         ;;\n> >                 --)\n> >                         shift\n> >                         break\n> >                         ;;\n> >                 -*)\n> >                         echo \"Unrecognised option: $1\"\n> >                         help\n> >                         break\n> >                         ;;\n> >                 *)\n> >                         break\n> >                         ;;\n> > \n> \n> sure\n> \n> > > +     esac\n> > > +     shift\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> > > +exec \"$@\"\n> > > diff --git a/src/v4l2/meson.build b/src/v4l2/meson.build\n> > > index f78497b6799b..07ff9a6939d2 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> > I don't think this should be added to config.h. Can you create a\n> > separate variable ?\n> > \n> > cdata = configuration_data()\n> > cdata.set('LIBCAMERA_V4L2_SO', get_option('prefix') / get_option('libdir') / 'v4l2-compat.so')\n> > \n> > I also wonder if we could use v4l2_compat.name() instead of\n> > 'v4l2-compat.so' (but that's only available starting in meson 0.54).\n> \n> I also asked in IRC #meson about this, hoping I could get a binary\n> target to tell me it's full installation path but alas...\n> \n> > > +\n> > > +summary({\n> > > +    'LIBCAMERA_V4L2_SO' : config_h.get('LIBCAMERA_V4L2_SO'),\n> > > +}, section : 'Paths')\n> > \n> > I would have skipped this. It's a bit out of place, with all the other\n> > paths being directories.\n> \n> But it's also a path/file that (at least without this script) people need to\n> know, so that tehy can do LD_PRELOAD= themselves.\n> \n> I can drop it though, as I expect this script will help exactly those\n> users.\n\nThat was my thinking too, as there's now a script, the binary path is\nless important.\n\n> > > +\n> > > +configure_file(input : 'libcamerify.in',\n> > > +               output : 'libcamerify',\n> > > +               configuration : config_h,\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 E8C3EBDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Feb 2022 10:37:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 57A7A609C9;\n\tTue,  1 Feb 2022 11:37:58 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C4B6E609AF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Feb 2022 11:37:56 +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 498B3332;\n\tTue,  1 Feb 2022 11:37:56 +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=\"ucZ1sTwp\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1643711876;\n\tbh=gOL6XtXIOPfE1qe4unuQ+4Qs3xO8GqNEwbkIsXJyC0g=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ucZ1sTwpQdu0auWfKW1lQf9wlnsQjFh+NnlPZDyWSbmuBEY1OJqdW3jTgUW2y6vOA\n\tY2JE4fA+Mfi5F4MeNeEhNZYJduegqm6ZBEMfj+RV8lgiktw6oJecMFTkMMHpZEUP29\n\tYo58CRQqfdRuFFaFbMNYWwsgwHidMQVDHr7Stzc0=","Date":"Tue, 1 Feb 2022 12:37:33 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<YfkNbWonelNca+7/@pendragon.ideasonboard.com>","References":"<20220131210757.105299-1-kieran.bingham@ideasonboard.com>\n\t<YfjfVH/LK+QDjAcf@pendragon.ideasonboard.com>\n\t<164371116680.208029.1363712483854379206@Monstersaurus>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<164371116680.208029.1363712483854379206@Monstersaurus>","Subject":"Re: [libcamera-devel] [PATCH v2] 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>"}}]