[{"id":173,"web_url":"https://patchwork.libcamera.org/comment/173/","msgid":"<20190102101554.47eymgdjoc72mdzg@uno.localdomain>","date":"2019-01-02T10:15:54","subject":"Re: [libcamera-devel] [PATCH 1/3] libcamera: media_device: Add\n\tDeviceInfo features","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n   thanks for re-submitting these patches\n\nOn Wed, Jan 02, 2019 at 02:49:01AM +0200, Laurent Pinchart wrote:\n> From: Jacopo Mondi <jacopo@jmondi.org>\n>\n> Add the features of the DeviceInfo class needed to replace it with\n> MediaDevice.\n>\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/libcamera/include/media_device.h |  5 +++\n>  src/libcamera/media_device.cpp       | 52 ++++++++++++++++++++++++++--\n>  2 files changed, 55 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h\n> index d787be391882..3fcdb4b4d5f8 100644\n> --- a/src/libcamera/include/media_device.h\n> +++ b/src/libcamera/include/media_device.h\n> @@ -24,6 +24,10 @@ public:\n>  \tMediaDevice(const std::string &devnode);\n>  \t~MediaDevice();\n>\n> +\tbool acquire();\n> +\tvoid release() { acquired_ = false; }\n> +\tbool busy() const { return acquired_; }\n> +\n>  \tint open();\n>  \tvoid close();\n>\n> @@ -41,6 +45,7 @@ private:\n>  \tstd::string devnode_;\n>  \tint fd_;\n>  \tbool valid_;\n> +\tbool acquired_;\n>\n>  \tstd::map<unsigned int, MediaObject *> objects_;\n>  \tMediaObject *object(unsigned int id);\n> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\n> index 1bd4f43a0c79..605e504be124 100644\n> --- a/src/libcamera/media_device.cpp\n> +++ b/src/libcamera/media_device.cpp\n> @@ -52,7 +52,11 @@ namespace libcamera {\n>   * controller device node. It can be closed at any time with a call to close().\n>   * This will not invalidate the media graph and all cached media objects remain\n>   * valid and can be accessed normally. The device can then be later reopened if\n> - * needed to perform other operations that interact with the device node.\n> + * needed to perform other operations that interect with the device node.\n\ns/interect/interact/\n\n> + *\n> + * Media device can be claimed for exclusive use with acquire(), released with\n> + * release() and tested with busy(). This mechanism is aimed at pipeline\n> + * managers to claim media devices they support during enumeration.\n>   */\n>\n>  /**\n> @@ -63,7 +67,7 @@ namespace libcamera {\n>   * populated with open() and populate() before the media graph can be queried.\n>   */\n>  MediaDevice::MediaDevice(const std::string &devnode)\n> -\t: devnode_(devnode), fd_(-1), valid_(false)\n> +\t: devnode_(devnode), fd_(-1), valid_(false), acquired_(false)\n>  {\n>  }\n>\n> @@ -74,6 +78,50 @@ MediaDevice::~MediaDevice()\n>  \tclear();\n>  }\n>\n> +/**\n> + * \\brief Claim a device for exclusive use\n> + *\n> + * The device claiming mechanism offers simple media device access arbitration\n> + * between multiple users. When the media device is created, it is available to\n> + * all users. Users can query the media graph to determine whether they can\n> + * support the device and, if they do, claim the device for exclusive use. Other\n> + * users are then expected to skip over media devices in use as reported by the\n> + * busy() function.\n> + *\n> + * Once claimed the device shall be released by its user when not needed anymore\n> + * by calling the release() function.\n> + *\n> + * Exclusive access is only guaranteed if all users of the media device abide by\n\ns/by/to ?\n\n> + * the device claiming mechanism, as it isn't enforced by the media device\n> + * itself.\n> + *\n> + * \\return true if the device was successfully claimed, or false if it was\n> + * already in use\n> + * \\sa release(), busy()\n> + */\n> +bool MediaDevice::acquire()\n> +{\n> +\tif (acquired_)\n> +\t\treturn false;\n> +\n> +\tacquired_ = true;\n> +\treturn true;\n> +}\n> +\n> +/**\n> + * \\fn MediaDevice::release()\n> + * \\brief Release a device previously claimed for exclusive use\n> + * \\sa acquire(), busy()\n> + */\n> +\n> +/**\n> + * \\fn MediaDevice::busy()\n> + * \\brief Check if a device is in use\n> + * \\return true if the device has been claimed for exclusive user, or false if\n\ns/user/use\n\n> + * it is available\n> + * \\sa acquire(), release()\n> + */\n> +\n\nWith this minor things addressed, please push\n\nThanks\n   j\n\n\n>  /**\n>   * \\brief Open a media device and retrieve device information\n>   *\n> --\n> Regards,\n>\n> Laurent Pinchart\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8527F60B30\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  2 Jan 2019 11:15:50 +0100 (CET)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 0D163C0018;\n\tWed,  2 Jan 2019 10:15:49 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Wed, 2 Jan 2019 11:15:54 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190102101554.47eymgdjoc72mdzg@uno.localdomain>","References":"<20190102004903.24190-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"opd63s4knvvku7pd\"","Content-Disposition":"inline","In-Reply-To":"<20190102004903.24190-1-laurent.pinchart@ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH 1/3] libcamera: media_device: Add\n\tDeviceInfo features","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Wed, 02 Jan 2019 10:15:50 -0000"}},{"id":187,"web_url":"https://patchwork.libcamera.org/comment/187/","msgid":"<1932084.J8gY53uWr1@avalon>","date":"2019-01-02T10:38:30","subject":"Re: [libcamera-devel] [PATCH 1/3] libcamera: media_device: Add\n\tDeviceInfo features","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Wednesday, 2 January 2019 12:15:54 EET Jacopo Mondi wrote:\n> Hi Laurent,\n>    thanks for re-submitting these patches\n> \n> On Wed, Jan 02, 2019 at 02:49:01AM +0200, Laurent Pinchart wrote:\n> > From: Jacopo Mondi <jacopo@jmondi.org>\n> > \n> > Add the features of the DeviceInfo class needed to replace it with\n> > MediaDevice.\n> > \n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> > \n> >  src/libcamera/include/media_device.h |  5 +++\n> >  src/libcamera/media_device.cpp       | 52 ++++++++++++++++++++++++++--\n> >  2 files changed, 55 insertions(+), 2 deletions(-)\n> > \n> > diff --git a/src/libcamera/include/media_device.h\n> > b/src/libcamera/include/media_device.h index d787be391882..3fcdb4b4d5f8\n> > 100644\n> > --- a/src/libcamera/include/media_device.h\n> > +++ b/src/libcamera/include/media_device.h\n> > \n> > @@ -24,6 +24,10 @@ public:\n> >  \tMediaDevice(const std::string &devnode);\n> >  \t~MediaDevice();\n> > \n> > +\tbool acquire();\n> > +\tvoid release() { acquired_ = false; }\n> > +\tbool busy() const { return acquired_; }\n> > +\n> > \n> >  \tint open();\n> >  \tvoid close();\n> > \n> > @@ -41,6 +45,7 @@ private:\n> >  \tstd::string devnode_;\n> >  \tint fd_;\n> >  \tbool valid_;\n> > \n> > +\tbool acquired_;\n> > \n> >  \tstd::map<unsigned int, MediaObject *> objects_;\n> >  \tMediaObject *object(unsigned int id);\n> > \n> > diff --git a/src/libcamera/media_device.cpp\n> > b/src/libcamera/media_device.cpp index 1bd4f43a0c79..605e504be124 100644\n> > --- a/src/libcamera/media_device.cpp\n> > +++ b/src/libcamera/media_device.cpp\n> > @@ -52,7 +52,11 @@ namespace libcamera {\n> > \n> >   * controller device node. It can be closed at any time with a call to\n> >   close(). * This will not invalidate the media graph and all cached\n> >   media objects remain * valid and can be accessed normally. The device\n> >   can then be later reopened if> \n> > - * needed to perform other operations that interact with the device node.\n> > + * needed to perform other operations that interect with the device node.\n> \n> s/interect/interact/\n\nChange dropped.\n\n> > + *\n> > + * Media device can be claimed for exclusive use with acquire(), released\n> > with + * release() and tested with busy(). This mechanism is aimed at\n> > pipeline + * managers to claim media devices they support during\n> > enumeration.\n> >   */\n> >  \n> >  /**\n> > @@ -63,7 +67,7 @@ namespace libcamera {\n> >   * populated with open() and populate() before the media graph can be\n> >   queried. */\n> >  MediaDevice::MediaDevice(const std::string &devnode)\n> > -\t: devnode_(devnode), fd_(-1), valid_(false)\n> > +\t: devnode_(devnode), fd_(-1), valid_(false), acquired_(false)\n> >  {\n> >  }\n> > \n> > @@ -74,6 +78,50 @@ MediaDevice::~MediaDevice()\n> >  \tclear();\n> >  }\n> > \n> > +/**\n> > + * \\brief Claim a device for exclusive use\n> > + *\n> > + * The device claiming mechanism offers simple media device access\n> > arbitration + * between multiple users. When the media device is created,\n> > it is available to + * all users. Users can query the media graph to\n> > determine whether they can + * support the device and, if they do, claim\n> > the device for exclusive use. Other + * users are then expected to skip\n> > over media devices in use as reported by the + * busy() function.\n> > + *\n> > + * Once claimed the device shall be released by its user when not needed\n> > anymore + * by calling the release() function.\n> > + *\n> > + * Exclusive access is only guaranteed if all users of the media device\n> > abide by\n> s/by/to ?\n\nNo, abide by :)\n\nhttp://www.wordreference.com/enit/abide\n\n> > + * the device claiming mechanism, as it isn't enforced by the media\n> > device\n> > + * itself.\n> > + *\n> > + * \\return true if the device was successfully claimed, or false if it\n> > was\n> > + * already in use\n> > + * \\sa release(), busy()\n> > + */\n> > +bool MediaDevice::acquire()\n> > +{\n> > +\tif (acquired_)\n> > +\t\treturn false;\n> > +\n> > +\tacquired_ = true;\n> > +\treturn true;\n> > +}\n> > +\n> > +/**\n> > + * \\fn MediaDevice::release()\n> > + * \\brief Release a device previously claimed for exclusive use\n> > + * \\sa acquire(), busy()\n> > + */\n> > +\n> > +/**\n> > + * \\fn MediaDevice::busy()\n> > + * \\brief Check if a device is in use\n> > + * \\return true if the device has been claimed for exclusive user, or\n> > false if\n> \n> s/user/use\n\nFixed.\n\n> > + * it is available\n> > + * \\sa acquire(), release()\n> > + */\n> > +\n> \n> With this minor things addressed, please push\n> \n> >  /**\n> >   * \\brief Open a media device and retrieve device information\n> >   *","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2815460B13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  3 Jan 2019 09:28:32 +0100 (CET)","from avalon.localnet (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5099E505;\n\tThu,  3 Jan 2019 09:28:31 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1546504111;\n\tbh=oXSkr6NUy1u5/vZMnpv6cancPUi7xaJLKO43tMXVEQc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=YPfrdTdD4ZxP8QLV7se9iPNR5rJRtU2lbXe5JI6Lh+rNDtlS+5k3EkGhY8THG1SRo\n\tI2mTPeI6IQGSwiPL8j9d1W4gxnCDagzP8gw0zt6tiNvYdU9GK44FhfiBiCbRvS0lt6\n\tbbo+gxbRfVQ5qFnEuoCaaUbqGUwpHR/n5KOclJaQ=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Date":"Wed, 02 Jan 2019 12:38:30 +0200","Message-ID":"<1932084.J8gY53uWr1@avalon>","Organization":"Ideas on Board Oy","In-Reply-To":"<20190102101554.47eymgdjoc72mdzg@uno.localdomain>","References":"<20190102004903.24190-1-laurent.pinchart@ideasonboard.com>\n\t<20190102101554.47eymgdjoc72mdzg@uno.localdomain>","MIME-Version":"1.0","Content-Transfer-Encoding":"7Bit","Content-Type":"text/plain; charset=\"us-ascii\"","Subject":"Re: [libcamera-devel] [PATCH 1/3] libcamera: media_device: Add\n\tDeviceInfo features","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Thu, 03 Jan 2019 08:28:32 -0000"}}]