[{"id":36437,"web_url":"https://patchwork.libcamera.org/comment/36437/","msgid":"<176131068482.127060.5004836554761576612@isaac-ThinkPad-T16-Gen-2>","date":"2025-10-24T12:58:04","subject":"Re: [PATCH v2 01/35] libcamera: v4l2: Support fromEntityName with\n\tshared_ptr<MediaDevice>","submitter":{"id":215,"url":"https://patchwork.libcamera.org/api/people/215/","name":"Isaac Scott","email":"isaac.scott@ideasonboard.com"},"content":"Hi Stefan,\n\nThank you for the patch!\n\nQuoting Stefan Klug (2025-10-23 15:48:02)\n> From: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> To facilitate expanding the use of a shared_ptr<MediaDevice> in\n> preference of a raw MediaDevice* pointer, add an additional\n> implementation for fromEntityName for both of v4l2_videodevice and\n> v4l2_subdevice to support this type.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n>  include/libcamera/internal/v4l2_subdevice.h   |  2 ++\n>  include/libcamera/internal/v4l2_videodevice.h |  2 ++\n>  src/libcamera/v4l2_subdevice.cpp              | 15 +++++++++++++++\n>  src/libcamera/v4l2_videodevice.cpp            | 15 +++++++++++++++\n>  4 files changed, 34 insertions(+)\n> \n> diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\n> index c1cde1df2e36..d1c8b838d49b 100644\n> --- a/include/libcamera/internal/v4l2_subdevice.h\n> +++ b/include/libcamera/internal/v4l2_subdevice.h\n> @@ -163,6 +163,8 @@ public:\n>  \n>         static std::unique_ptr<V4L2Subdevice>\n>         fromEntityName(const MediaDevice *media, const std::string &entity);\n> +       static std::unique_ptr<V4L2Subdevice>\n> +       fromEntityName(std::shared_ptr<const MediaDevice>, const std::string &entity);\n>  \n>  protected:\n>         std::string logPrefix() const override;\n> diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\n> index 6caafc4dcf08..4f80f7176174 100644\n> --- a/include/libcamera/internal/v4l2_videodevice.h\n> +++ b/include/libcamera/internal/v4l2_videodevice.h\n> @@ -228,6 +228,8 @@ public:\n>  \n>         static std::unique_ptr<V4L2VideoDevice>\n>         fromEntityName(const MediaDevice *media, const std::string &entity);\n> +       static std::unique_ptr<V4L2VideoDevice>\n> +       fromEntityName(std::shared_ptr<const MediaDevice>, const std::string &entity);\n>  \n>         V4L2PixelFormat toV4L2PixelFormat(const PixelFormat &pixelFormat) const;\n>  \n> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> index 31a2ac72a7ee..1825e9e55ca4 100644\n> --- a/src/libcamera/v4l2_subdevice.cpp\n> +++ b/src/libcamera/v4l2_subdevice.cpp\n> @@ -1768,6 +1768,21 @@ V4L2Subdevice::fromEntityName(const MediaDevice *media,\n>         return std::make_unique<V4L2Subdevice>(mediaEntity);\n>  }\n>  \n> +/**\n> + * \\brief Create a new video subdevice instance from \\a entity in media device\n> + * \\a media\n> + * \\param[in] media The media device where the entity is registered\n> + * \\param[in] entity The media entity name\n> + *\n> + * \\return A newly created V4L2Subdevice on success, nullptr otherwise\n> + */\n> +std::unique_ptr<V4L2Subdevice>\n> +V4L2Subdevice::fromEntityName(std::shared_ptr<const MediaDevice> media,\n> +                             const std::string &entity)\n> +{\n> +       return fromEntityName(media.get(), entity);\n> +}\n> +\n>  std::string V4L2Subdevice::logPrefix() const\n>  {\n>         return \"'\" + entity_->name() + \"'\";\n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index 7b48d911db73..9be5cfbc0395 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -2114,6 +2114,21 @@ V4L2VideoDevice::fromEntityName(const MediaDevice *media,\n>         return std::make_unique<V4L2VideoDevice>(mediaEntity);\n>  }\n>  \n> +/**\n> + * \\brief Create a new video device instance from \\a entity in media device\n> + * \\a media\n> + * \\param[in] media The media device where the entity is registered\n> + * \\param[in] entity The media entity name\n> + *\n> + * \\return A newly created V4L2VideoDevice on success, nullptr otherwise\n> + */\n> +std::unique_ptr<V4L2VideoDevice>\n> +V4L2VideoDevice::fromEntityName(std::shared_ptr<const MediaDevice> media,\n> +                               const std::string &entity)\n> +{\n> +       return fromEntityName(media.get(), entity);\n> +}\n\nReviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>\n\n> +\n>  /**\n>   * \\brief Convert \\a PixelFormat to a V4L2PixelFormat supported by the device\n>   * \\param[in] pixelFormat The PixelFormat to convert\n> -- \n> 2.48.1\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 C3160C3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Oct 2025 12:58:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C480F6096D;\n\tFri, 24 Oct 2025 14:58:09 +0200 (CEST)","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 E646960964\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Oct 2025 14:58:07 +0200 (CEST)","from thinkpad.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C2E5D1AA6;\n\tFri, 24 Oct 2025 14:56:21 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"gaDK9PP5\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761310581;\n\tbh=n1YxrYK/LiW2F6zyVCYxOvOIm/ywne1eDhEJymKLKPQ=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=gaDK9PP5SGhYoemsQN3vvnY8nezKKkLXIJaIQJ+HhlqVIIBWBf1GKDoEloVBDG2zo\n\tq2dmdPX13Jp5UzeizaOFyo79Eq8yIZhHqkXsAG9hBbMxjewwAA+a2ZWLktf7Gbxf56\n\tFpiA5b/e4Pwk1VQHDeL6O7aR5AeX9l20IPWkyrX8=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251023144841.403689-2-stefan.klug@ideasonboard.com>","References":"<20251023144841.403689-1-stefan.klug@ideasonboard.com>\n\t<20251023144841.403689-2-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v2 01/35] libcamera: v4l2: Support fromEntityName with\n\tshared_ptr<MediaDevice>","From":"Isaac Scott <isaac.scott@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 24 Oct 2025 13:58:04 +0100","Message-ID":"<176131068482.127060.5004836554761576612@isaac-ThinkPad-T16-Gen-2>","User-Agent":"alot/0.10","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>"}},{"id":36439,"web_url":"https://patchwork.libcamera.org/comment/36439/","msgid":"<03165d99-a1bd-4601-9276-4202b42ce474@ideasonboard.com>","date":"2025-10-24T13:39:30","subject":"Re: [PATCH v2 01/35] libcamera: v4l2: Support fromEntityName with\n\tshared_ptr<MediaDevice>","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n2025. 10. 23. 16:48 keltezéssel, Stefan Klug írta:\n> From: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> To facilitate expanding the use of a shared_ptr<MediaDevice> in\n> preference of a raw MediaDevice* pointer, add an additional\n> implementation for fromEntityName for both of v4l2_videodevice and\n> v4l2_subdevice to support this type.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n>   include/libcamera/internal/v4l2_subdevice.h   |  2 ++\n>   include/libcamera/internal/v4l2_videodevice.h |  2 ++\n>   src/libcamera/v4l2_subdevice.cpp              | 15 +++++++++++++++\n>   src/libcamera/v4l2_videodevice.cpp            | 15 +++++++++++++++\n>   4 files changed, 34 insertions(+)\n> \n> diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\n> index c1cde1df2e36..d1c8b838d49b 100644\n> --- a/include/libcamera/internal/v4l2_subdevice.h\n> +++ b/include/libcamera/internal/v4l2_subdevice.h\n> @@ -163,6 +163,8 @@ public:\n>   \n>   \tstatic std::unique_ptr<V4L2Subdevice>\n>   \tfromEntityName(const MediaDevice *media, const std::string &entity);\n> +\tstatic std::unique_ptr<V4L2Subdevice>\n> +\tfromEntityName(std::shared_ptr<const MediaDevice>, const std::string &entity);\n\nThis should be `const std::shared_ptr<const MediaDevice> &` at least to avoid making a copy.\n\nAlso:\n\n   template<typename T, std::enable_if_t<!std::is_convertible_v<const T&, const MediaDevice *>> * = nullptr>\n   static auto\n   fromEntityName(const T &ptr, const std::string &entity)\n     -> decltype(fromEntityName(static_cast<const MediaDevice *>(std::addressof(*ptr)), entity))\n   {\n     return fromEntityName(static_cast<const MediaDevice *>(std::addressof(*ptr)), entity);\n   }\n\nand now it works with anything that has an appropriate `operator*`.\n\nBut generally it does not seem that inconvenient to have to retrieve the raw pointer. And\n`fromEntityName()` really does not need `std::shared_ptr`. So unless I'm missing something\nI think maybe we should keep the raw pointer overload in any case, and either (a) add a generic\noverload or (b) add a specific overload for shared_ptr or (c) just manually use `.get()`.\n\n\nRegards,\nBarnabás Pőcze\n\n\n>   \n>   protected:\n>   \tstd::string logPrefix() const override;\n> diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\n> index 6caafc4dcf08..4f80f7176174 100644\n> --- a/include/libcamera/internal/v4l2_videodevice.h\n> +++ b/include/libcamera/internal/v4l2_videodevice.h\n> @@ -228,6 +228,8 @@ public:\n>   \n>   \tstatic std::unique_ptr<V4L2VideoDevice>\n>   \tfromEntityName(const MediaDevice *media, const std::string &entity);\n> +\tstatic std::unique_ptr<V4L2VideoDevice>\n> +\tfromEntityName(std::shared_ptr<const MediaDevice>, const std::string &entity);\n>   \n>   \tV4L2PixelFormat toV4L2PixelFormat(const PixelFormat &pixelFormat) const;\n>   \n> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> index 31a2ac72a7ee..1825e9e55ca4 100644\n> --- a/src/libcamera/v4l2_subdevice.cpp\n> +++ b/src/libcamera/v4l2_subdevice.cpp\n> @@ -1768,6 +1768,21 @@ V4L2Subdevice::fromEntityName(const MediaDevice *media,\n>   \treturn std::make_unique<V4L2Subdevice>(mediaEntity);\n>   }\n>   \n> +/**\n> + * \\brief Create a new video subdevice instance from \\a entity in media device\n> + * \\a media\n> + * \\param[in] media The media device where the entity is registered\n> + * \\param[in] entity The media entity name\n> + *\n> + * \\return A newly created V4L2Subdevice on success, nullptr otherwise\n> + */\n> +std::unique_ptr<V4L2Subdevice>\n> +V4L2Subdevice::fromEntityName(std::shared_ptr<const MediaDevice> media,\n> +\t\t\t      const std::string &entity)\n> +{\n> +\treturn fromEntityName(media.get(), entity);\n> +}\n> +\n>   std::string V4L2Subdevice::logPrefix() const\n>   {\n>   \treturn \"'\" + entity_->name() + \"'\";\n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index 7b48d911db73..9be5cfbc0395 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -2114,6 +2114,21 @@ V4L2VideoDevice::fromEntityName(const MediaDevice *media,\n>   \treturn std::make_unique<V4L2VideoDevice>(mediaEntity);\n>   }\n>   \n> +/**\n> + * \\brief Create a new video device instance from \\a entity in media device\n> + * \\a media\n> + * \\param[in] media The media device where the entity is registered\n> + * \\param[in] entity The media entity name\n> + *\n> + * \\return A newly created V4L2VideoDevice on success, nullptr otherwise\n> + */\n> +std::unique_ptr<V4L2VideoDevice>\n> +V4L2VideoDevice::fromEntityName(std::shared_ptr<const MediaDevice> media,\n> +\t\t\t\tconst std::string &entity)\n> +{\n> +\treturn fromEntityName(media.get(), entity);\n> +}\n> +\n>   /**\n>    * \\brief Convert \\a PixelFormat to a V4L2PixelFormat supported by the device\n>    * \\param[in] pixelFormat The PixelFormat to convert","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 F259FBE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Oct 2025 13:39:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5B30060979;\n\tFri, 24 Oct 2025 15:39:37 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6B5E16096B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Oct 2025 15:39:35 +0200 (CEST)","from [192.168.33.13] (185.221.141.231.nat.pool.zt.hu\n\t[185.221.141.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 111FE1BF4;\n\tFri, 24 Oct 2025 15:37:49 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Ea6g0dOY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761313069;\n\tbh=tyTGlKnZU4exNX/PTrU386/lvB5X7+NK+9duryHub00=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=Ea6g0dOYvH4SCOqJxdRQvLh5p9TlSl9NmsDZd5+mXdrgsymWW+WOL6vQNXnsNOAoK\n\tBUZaEj/awTCq8Y0DT6bp0RNeSz7xp/CP9vSCtcvHpu/L+4PB1RwPq1PNxUdu3sXefC\n\tvAoBfU1ik1/oJHH+OzqBnmX0isB2wIfM0psANTcE=","Message-ID":"<03165d99-a1bd-4601-9276-4202b42ce474@ideasonboard.com>","Date":"Fri, 24 Oct 2025 15:39:30 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2 01/35] libcamera: v4l2: Support fromEntityName with\n\tshared_ptr<MediaDevice>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","References":"<20251023144841.403689-1-stefan.klug@ideasonboard.com>\n\t<20251023144841.403689-2-stefan.klug@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20251023144841.403689-2-stefan.klug@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>"}},{"id":36512,"web_url":"https://patchwork.libcamera.org/comment/36512/","msgid":"<20251028101659.GE13023@pendragon.ideasonboard.com>","date":"2025-10-28T10:16:59","subject":"Re: [PATCH v2 01/35] libcamera: v4l2: Support fromEntityName with\n\tshared_ptr<MediaDevice>","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Fri, Oct 24, 2025 at 03:39:30PM +0200, Barnabás Pőcze wrote:\n> Hi\n> \n> 2025. 10. 23. 16:48 keltezéssel, Stefan Klug írta:\n> > From: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > \n> > To facilitate expanding the use of a shared_ptr<MediaDevice> in\n> > preference of a raw MediaDevice* pointer, add an additional\n> > implementation for fromEntityName for both of v4l2_videodevice and\n> > v4l2_subdevice to support this type.\n> > \n> > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> > ---\n> >   include/libcamera/internal/v4l2_subdevice.h   |  2 ++\n> >   include/libcamera/internal/v4l2_videodevice.h |  2 ++\n> >   src/libcamera/v4l2_subdevice.cpp              | 15 +++++++++++++++\n> >   src/libcamera/v4l2_videodevice.cpp            | 15 +++++++++++++++\n> >   4 files changed, 34 insertions(+)\n> > \n> > diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\n> > index c1cde1df2e36..d1c8b838d49b 100644\n> > --- a/include/libcamera/internal/v4l2_subdevice.h\n> > +++ b/include/libcamera/internal/v4l2_subdevice.h\n> > @@ -163,6 +163,8 @@ public:\n> >   \n> >   \tstatic std::unique_ptr<V4L2Subdevice>\n> >   \tfromEntityName(const MediaDevice *media, const std::string &entity);\n> > +\tstatic std::unique_ptr<V4L2Subdevice>\n> > +\tfromEntityName(std::shared_ptr<const MediaDevice>, const std::string &entity);\n> \n> This should be `const std::shared_ptr<const MediaDevice> &` at least to avoid making a copy.\n> \n> Also:\n> \n>    template<typename T, std::enable_if_t<!std::is_convertible_v<const T&, const MediaDevice *>> * = nullptr>\n>    static auto\n>    fromEntityName(const T &ptr, const std::string &entity)\n>      -> decltype(fromEntityName(static_cast<const MediaDevice *>(std::addressof(*ptr)), entity))\n>    {\n>      return fromEntityName(static_cast<const MediaDevice *>(std::addressof(*ptr)), entity);\n>    }\n> \n> and now it works with anything that has an appropriate `operator*`.\n> \n> But generally it does not seem that inconvenient to have to retrieve the raw pointer. And\n> `fromEntityName()` really does not need `std::shared_ptr`. So unless I'm missing something\n> I think maybe we should keep the raw pointer overload in any case, and either (a) add a generic\n> overload or (b) add a specific overload for shared_ptr or (c) just manually use `.get()`.\n\nI agree, I don't think adding a .get() or * in the caller is a big\nissue. As the fromEntityName() function does not need a shared pointer,\nI wouldn't add this overload.\n\n> >   \n> >   protected:\n> >   \tstd::string logPrefix() const override;\n> > diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\n> > index 6caafc4dcf08..4f80f7176174 100644\n> > --- a/include/libcamera/internal/v4l2_videodevice.h\n> > +++ b/include/libcamera/internal/v4l2_videodevice.h\n> > @@ -228,6 +228,8 @@ public:\n> >   \n> >   \tstatic std::unique_ptr<V4L2VideoDevice>\n> >   \tfromEntityName(const MediaDevice *media, const std::string &entity);\n> > +\tstatic std::unique_ptr<V4L2VideoDevice>\n> > +\tfromEntityName(std::shared_ptr<const MediaDevice>, const std::string &entity);\n> >   \n> >   \tV4L2PixelFormat toV4L2PixelFormat(const PixelFormat &pixelFormat) const;\n> >   \n> > diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> > index 31a2ac72a7ee..1825e9e55ca4 100644\n> > --- a/src/libcamera/v4l2_subdevice.cpp\n> > +++ b/src/libcamera/v4l2_subdevice.cpp\n> > @@ -1768,6 +1768,21 @@ V4L2Subdevice::fromEntityName(const MediaDevice *media,\n> >   \treturn std::make_unique<V4L2Subdevice>(mediaEntity);\n> >   }\n> >   \n> > +/**\n> > + * \\brief Create a new video subdevice instance from \\a entity in media device\n> > + * \\a media\n> > + * \\param[in] media The media device where the entity is registered\n> > + * \\param[in] entity The media entity name\n> > + *\n> > + * \\return A newly created V4L2Subdevice on success, nullptr otherwise\n> > + */\n> > +std::unique_ptr<V4L2Subdevice>\n> > +V4L2Subdevice::fromEntityName(std::shared_ptr<const MediaDevice> media,\n> > +\t\t\t      const std::string &entity)\n> > +{\n> > +\treturn fromEntityName(media.get(), entity);\n> > +}\n> > +\n> >   std::string V4L2Subdevice::logPrefix() const\n> >   {\n> >   \treturn \"'\" + entity_->name() + \"'\";\n> > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> > index 7b48d911db73..9be5cfbc0395 100644\n> > --- a/src/libcamera/v4l2_videodevice.cpp\n> > +++ b/src/libcamera/v4l2_videodevice.cpp\n> > @@ -2114,6 +2114,21 @@ V4L2VideoDevice::fromEntityName(const MediaDevice *media,\n> >   \treturn std::make_unique<V4L2VideoDevice>(mediaEntity);\n> >   }\n> >   \n> > +/**\n> > + * \\brief Create a new video device instance from \\a entity in media device\n> > + * \\a media\n> > + * \\param[in] media The media device where the entity is registered\n> > + * \\param[in] entity The media entity name\n> > + *\n> > + * \\return A newly created V4L2VideoDevice on success, nullptr otherwise\n> > + */\n> > +std::unique_ptr<V4L2VideoDevice>\n> > +V4L2VideoDevice::fromEntityName(std::shared_ptr<const MediaDevice> media,\n> > +\t\t\t\tconst std::string &entity)\n> > +{\n> > +\treturn fromEntityName(media.get(), entity);\n> > +}\n> > +\n> >   /**\n> >    * \\brief Convert \\a PixelFormat to a V4L2PixelFormat supported by the device\n> >    * \\param[in] pixelFormat The PixelFormat to convert","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 70D6DC3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Oct 2025 10:17:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0A3D3607BC;\n\tTue, 28 Oct 2025 11:17:15 +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 184AE603ED\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Oct 2025 11:17:13 +0100 (CET)","from pendragon.ideasonboard.com (unknown [193.209.96.36])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 7206016CD; \n\tTue, 28 Oct 2025 11:15:24 +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=\"Ruq9iMjp\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761646524;\n\tbh=X14zIMUtPrURQuGUu78ZL/tSRBe1YPip2/OZvjfcbe0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Ruq9iMjpWZCRSrXwzC6bvr0tuTFrbCrTTR2pepnknqGG6GCKq/NfCjsgEb0xz4qEU\n\tk1bGO/LGZHiVA9JZj+Jfa/mnR16848OkLFad2bIlmBgkpOgDkvMfr1pwRMNxHwquq3\n\tSpSB+YBl4Gzffzw+zL2HeeEkWZwcMmp+Si1VbMdE=","Date":"Tue, 28 Oct 2025 12:16:59 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","Subject":"Re: [PATCH v2 01/35] libcamera: v4l2: Support fromEntityName with\n\tshared_ptr<MediaDevice>","Message-ID":"<20251028101659.GE13023@pendragon.ideasonboard.com>","References":"<20251023144841.403689-1-stefan.klug@ideasonboard.com>\n\t<20251023144841.403689-2-stefan.klug@ideasonboard.com>\n\t<03165d99-a1bd-4601-9276-4202b42ce474@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<03165d99-a1bd-4601-9276-4202b42ce474@ideasonboard.com>","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>"}}]