[{"id":37180,"web_url":"https://patchwork.libcamera.org/comment/37180/","msgid":"<176476561315.890597.17339941066700938925@ping.linuxembedded.co.uk>","date":"2025-12-03T12:40:13","subject":"Re: [PATCH v3 2/4] libcamera: device_enumerator: Support regex to\n\tmatch entity names","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Jacopo Mondi (2025-12-03 09:14:22)\n> From: Daniel Scally <dan.scally@ideasonboard.com>\n> \n> Some entities in a media graph have names that might differ from\n> implementation to implementation; for example the Camera Receiver\n> Unit and CSI-2 receiver on the RZ/V2H(P) SoC have entities with names\n> that include their address, in the form \"csi-16000400.csi2\". Passing\n> that entity name to DeviceMatch is too inflexible given it would only\n> work if that specific CSI-2 receiver were the one being used.\n> \n> Add an overload for DeviceMatch::add() such that users can pass in a\n> std::regex instead of a string. Update DeviceMatch::match() to check\n> for entities that are matched by the regular expressions added with\n> the new overload after checking for any exact matches from the vector\n> of strings. This allows us to use regex to match on patterns like\n> \"csi-[0-9a-f]{8}.csi2\".\n> \n> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> \n> ---\n> Changes in v3:\n> - As suggested by Barnabas accept an std::regex in add() instead of a\n>   reference and move it into the entityRegexs_ vector\n> \n> - Exit early in DeviceMatch::match()\n> \n>         for (const MediaEntity *entity : device->entities()) {\n>                 if (!std::regex_search(entity->name(), nameRegex))\n>                         continue;\n> \n>                 if (found) {\n> \n>                 }\n>         }\n> \n>   Compared to\n> \n>         for (const MediaEntity *entity : device->entities()) {\n>                 if (std::regex_search(entity->name(), nameRegex)) {\n>                         if (found) {\n> \n>                         }\n>                 }\n>         }\n> \n> - Invert the error logic when deviceNode is empty\n> \n>         if (entity->deviceNode().empty()) {\n>                 LOG(DeviceEnumerator, Debug)\n>                         << \"Skip \" << entity->name()\n>                         << \": no device node\";\n>                 continue;\n>         }\n> \n>         found = true;\n> \n>   Compared to\n> \n>         if (!entity->deviceNode().empty()) {\n>                 found = true;\n>         } else {\n>                  LOG(DeviceEnumerator, Debug)\n>                         << \"Skip \" << entity->name()\n>                         << \": no device node\";\n>         }\n> \n> Changes in v2:\n> \n>     - Instead of replacing the existing ::add() function and\n>       matching process with regex, add an overload for ::add()\n>       that takes a regex and incorporate that into ::match()\n>       alongside the existing functionality.\n> ---\n>  include/libcamera/internal/device_enumerator.h |  3 ++\n>  src/libcamera/device_enumerator.cpp            | 39 +++++++++++++++++++++++++-\n>  2 files changed, 41 insertions(+), 1 deletion(-)\n> \n> diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h\n> index db3532a9887af913ceee20cbba3f945e56e7b61d..fa8806b0c2a47ab89fdc74fe01ef77bf2e68abb1 100644\n> --- a/include/libcamera/internal/device_enumerator.h\n> +++ b/include/libcamera/internal/device_enumerator.h\n> @@ -11,6 +11,7 @@\n>  #include <string>\n>  #include <vector>\n>  \n> +#include <libcamera/base/regex.h>\n>  #include <libcamera/base/signal.h>\n>  \n>  namespace libcamera {\n> @@ -23,12 +24,14 @@ public:\n>         DeviceMatch(const std::string &driver);\n>  \n>         void add(const std::string &entity);\n> +       void add(const std::regex entity);\n>  \n>         bool match(const MediaDevice *device) const;\n>  \n>  private:\n>         std::string driver_;\n>         std::vector<std::string> entities_;\n> +       std::vector<std::regex> entityRegexs_;\n>  };\n>  \n>  class DeviceEnumerator\n> diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\n> index ae17862f676310ef568e5331106ed661e84b5130..2911d5f0385f9765a2eafce2085d1fd627d94b95 100644\n> --- a/src/libcamera/device_enumerator.cpp\n> +++ b/src/libcamera/device_enumerator.cpp\n> @@ -53,7 +53,8 @@ LOG_DEFINE_CATEGORY(DeviceEnumerator)\n>   *\n>   * A DeviceMatch is created with a specific Linux device driver in mind,\n>   * therefore the name of the driver is a required property. One or more Entity\n> - * names can be added as match criteria.\n> + * names (or regular expressions designed to match an entity name) can be added\n> + * as match criteria.\n>   *\n>   * Pipeline handlers are recommended to add entities to DeviceMatch as\n>   * appropriate to ensure that the media device they need can be uniquely\n> @@ -81,6 +82,15 @@ void DeviceMatch::add(const std::string &entity)\n>         entities_.push_back(entity);\n>  }\n>  \n> +/**\n> + * \\brief Add a regex to match a media entity name to the search pattern\n> + * \\param[in] entity The regex intended to match to an entity in the media graph\n> + */\n> +void DeviceMatch::add(const std::regex entity)\n> +{\n> +       entityRegexs_.push_back(std::move(entity));\n> +}\n> +\n>  /**\n>   * \\brief Compare a search pattern with a media device\n>   * \\param[in] device The media device\n> @@ -116,6 +126,33 @@ bool DeviceMatch::match(const MediaDevice *device) const\n>                         return false;\n>         }\n>  \n> +       for (const std::regex &nameRegex : entityRegexs_) {\n> +               bool found = false;\n> +\n> +               for (const MediaEntity *entity : device->entities()) {\n> +                       if (!std::regex_search(entity->name(), nameRegex))\n> +                               continue;\n> +\n> +                       if (found) {\n> +                               LOG(DeviceEnumerator, Error)\n> +                                       << \"Multiple entities match regex\";\n> +                               return false;\n> +                       }\n> +\n> +                       if (entity->deviceNode().empty()) {\n> +                               LOG(DeviceEnumerator, Debug)\n> +                                       << \"Skip \" << entity->name()\n> +                                       << \": no device node\";\n> +                               continue;\n> +                       }\n> +\n> +                       found = true;\n> +               }\n> +\n> +               if (!found)\n> +                       return false;\n> +       }\n> +\n>         return true;\n>  }\n>  \n> \n> -- \n> 2.51.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 CE878C3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  3 Dec 2025 12:40:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EC13560F39;\n\tWed,  3 Dec 2025 13:40: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 9BB37609D8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  3 Dec 2025 13:40:16 +0100 (CET)","from pendragon.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 631261574;\n\tWed,  3 Dec 2025 13:38:01 +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=\"QGxOf7iA\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1764765481;\n\tbh=dOb12ZAGjZ6TzVmXR1IQDvP/5iDE4RcLBQRwmsTbCxw=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=QGxOf7iAocwsg3VeEbTS9FD/AakRhqosHICBLgPrCvh9L2gEetKUNF0FfSGOedn/H\n\tncIVZiguXx0kZXJ/zvrcigF2wzyBd7mnIFq8JmUaBHAhcHOPhycbG/IkRqr4eLoc9I\n\t4HUxxGpmJfsAojS1E/nC6pFlpqMIPsyUq6fkCjOE=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251203-rzv2h-pre-v3-2-1493e0638626@ideasonboard.com>","References":"<20251203-rzv2h-pre-v3-0-1493e0638626@ideasonboard.com>\n\t<20251203-rzv2h-pre-v3-2-1493e0638626@ideasonboard.com>","Subject":"Re: [PATCH v3 2/4] libcamera: device_enumerator: Support regex to\n\tmatch entity names","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Daniel Scally <dan.scally@ideasonboard.com>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 03 Dec 2025 12:40:13 +0000","Message-ID":"<176476561315.890597.17339941066700938925@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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":37204,"web_url":"https://patchwork.libcamera.org/comment/37204/","msgid":"<72286ec6-2748-420c-9bea-5e0865ab5afc@ideasonboard.com>","date":"2025-12-03T20:29:56","subject":"Re: [PATCH v3 2/4] libcamera: device_enumerator: Support regex to\n\tmatch entity names","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2025. 12. 03. 10:14 keltezéssel, Jacopo Mondi írta:\n> From: Daniel Scally <dan.scally@ideasonboard.com>\n> \n> Some entities in a media graph have names that might differ from\n> implementation to implementation; for example the Camera Receiver\n> Unit and CSI-2 receiver on the RZ/V2H(P) SoC have entities with names\n> that include their address, in the form \"csi-16000400.csi2\". Passing\n> that entity name to DeviceMatch is too inflexible given it would only\n> work if that specific CSI-2 receiver were the one being used.\n> \n> Add an overload for DeviceMatch::add() such that users can pass in a\n> std::regex instead of a string. Update DeviceMatch::match() to check\n> for entities that are matched by the regular expressions added with\n> the new overload after checking for any exact matches from the vector\n> of strings. This allows us to use regex to match on patterns like\n> \"csi-[0-9a-f]{8}.csi2\".\n> \n> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> \n> ---\n> [...]\n> diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\n> index ae17862f676310ef568e5331106ed661e84b5130..2911d5f0385f9765a2eafce2085d1fd627d94b95 100644\n> --- a/src/libcamera/device_enumerator.cpp\n> +++ b/src/libcamera/device_enumerator.cpp\n> @@ -53,7 +53,8 @@ LOG_DEFINE_CATEGORY(DeviceEnumerator)\n>    *\n>    * A DeviceMatch is created with a specific Linux device driver in mind,\n>    * therefore the name of the driver is a required property. One or more Entity\n> - * names can be added as match criteria.\n> + * names (or regular expressions designed to match an entity name) can be added\n> + * as match criteria.\n>    *\n>    * Pipeline handlers are recommended to add entities to DeviceMatch as\n>    * appropriate to ensure that the media device they need can be uniquely\n> @@ -81,6 +82,15 @@ void DeviceMatch::add(const std::string &entity)\n>   \tentities_.push_back(entity);\n>   }\n>   \n> +/**\n> + * \\brief Add a regex to match a media entity name to the search pattern\n> + * \\param[in] entity The regex intended to match to an entity in the media graph\n> + */\n> +void DeviceMatch::add(const std::regex entity)\n\nPlease drop the `const`.\n\n\n> +{\n> +\tentityRegexs_.push_back(std::move(entity));\n> +}\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 96B64BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  3 Dec 2025 20:30:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6C9CD61022;\n\tWed,  3 Dec 2025 21:30:04 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6F057609D8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  3 Dec 2025 21:30:03 +0100 (CET)","from [192.168.33.26] (185.182.214.221.nat.pool.zt.hu\n\t[185.182.214.221])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3375F11D5;\n\tWed,  3 Dec 2025 21:27:45 +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=\"q+scJ21u\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1764793667;\n\tbh=bi7b+Nj34pVhIRzCcGNrJzbokgHcpE6bb8p5M0e08/I=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=q+scJ21uO9K2oBEje/k2IjA28T8c7iRYIecXm9MvtqNgSTbUuDdyDUBcSpi4L9uNX\n\tTotyNUAVP/ekEdwJ3GO/12ntZw7r1FFEbOEABoLwHrHhgQiQ25hCP15H0EARVGfAZ7\n\t1nXHND2/e7v83vi80ZCgzZ6K20qIGz9kgowbyGq0=","Message-ID":"<72286ec6-2748-420c-9bea-5e0865ab5afc@ideasonboard.com>","Date":"Wed, 3 Dec 2025 21:29:56 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v3 2/4] libcamera: device_enumerator: Support regex to\n\tmatch entity names","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tDaniel Scally <dan.scally@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20251203-rzv2h-pre-v3-0-1493e0638626@ideasonboard.com>\n\t<20251203-rzv2h-pre-v3-2-1493e0638626@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":"<20251203-rzv2h-pre-v3-2-1493e0638626@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":37210,"web_url":"https://patchwork.libcamera.org/comment/37210/","msgid":"<dipjcml45g6ocd4dfhltwg2qaapyscfju4fc3ajafeuuuz2zbp@c4cbosbamswx>","date":"2025-12-04T09:55:06","subject":"Re: [PATCH v3 2/4] libcamera: device_enumerator: Support regex to\n\tmatch entity names","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Barnabás\n\nOn Wed, Dec 03, 2025 at 09:29:56PM +0100, Barnabás Pőcze wrote:\n> 2025. 12. 03. 10:14 keltezéssel, Jacopo Mondi írta:\n> > From: Daniel Scally <dan.scally@ideasonboard.com>\n> >\n> > Some entities in a media graph have names that might differ from\n> > implementation to implementation; for example the Camera Receiver\n> > Unit and CSI-2 receiver on the RZ/V2H(P) SoC have entities with names\n> > that include their address, in the form \"csi-16000400.csi2\". Passing\n> > that entity name to DeviceMatch is too inflexible given it would only\n> > work if that specific CSI-2 receiver were the one being used.\n> >\n> > Add an overload for DeviceMatch::add() such that users can pass in a\n> > std::regex instead of a string. Update DeviceMatch::match() to check\n> > for entities that are matched by the regular expressions added with\n> > the new overload after checking for any exact matches from the vector\n> > of strings. This allows us to use regex to match on patterns like\n> > \"csi-[0-9a-f]{8}.csi2\".\n> >\n> > Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n> > Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> >\n> > ---\n> > [...]\n> > diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\n> > index ae17862f676310ef568e5331106ed661e84b5130..2911d5f0385f9765a2eafce2085d1fd627d94b95 100644\n> > --- a/src/libcamera/device_enumerator.cpp\n> > +++ b/src/libcamera/device_enumerator.cpp\n> > @@ -53,7 +53,8 @@ LOG_DEFINE_CATEGORY(DeviceEnumerator)\n> >    *\n> >    * A DeviceMatch is created with a specific Linux device driver in mind,\n> >    * therefore the name of the driver is a required property. One or more Entity\n> > - * names can be added as match criteria.\n> > + * names (or regular expressions designed to match an entity name) can be added\n> > + * as match criteria.\n> >    *\n> >    * Pipeline handlers are recommended to add entities to DeviceMatch as\n> >    * appropriate to ensure that the media device they need can be uniquely\n> > @@ -81,6 +82,15 @@ void DeviceMatch::add(const std::string &entity)\n> >   \tentities_.push_back(entity);\n> >   }\n> > +/**\n> > + * \\brief Add a regex to match a media entity name to the search pattern\n> > + * \\param[in] entity The regex intended to match to an entity in the media graph\n> > + */\n> > +void DeviceMatch::add(const std::regex entity)\n>\n> Please drop the `const`.\n>\n\nThanks, this is indeed a leftover.\n\nWith this fixed, can I push the series or would you like me to resend\nit ?\n\nThanks\n  j\n\n>\n> > +{\n> > +\tentityRegexs_.push_back(std::move(entity));\n> > +}\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 1D84FC3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Dec 2025 09:55:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1CC97610B3;\n\tThu,  4 Dec 2025 10:55:12 +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 25FDE6069A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Dec 2025 10:55:10 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2001:b07:6462:5de2:153:f9b8:5024:faa2])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4B83FD7;\n\tThu,  4 Dec 2025 10:52:54 +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=\"Xvf+bItk\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1764841974;\n\tbh=PpS0aRFoz/DqYKIgaERrh9/qT1PTT/hQoqLQmEaNg/s=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Xvf+bItkyPhdwGoSFNmrm/AR+blfvX5OWmSkBF5ym9YXMZ0WArflFH2IOTZcfoxRU\n\tt97D5zsbdHQFLfxoH5QiaiQwYfmqi8rDkiETIOWnE6OuuVMHNGIFF8JAuvN5wiFCk0\n\trbYTz/XXE1obNl5JiaXQ7WzlfSOmjpCVrXz46Wzk=","Date":"Thu, 4 Dec 2025 10:55:06 +0100","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>, \n\tDaniel Scally <dan.scally@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v3 2/4] libcamera: device_enumerator: Support regex to\n\tmatch entity names","Message-ID":"<dipjcml45g6ocd4dfhltwg2qaapyscfju4fc3ajafeuuuz2zbp@c4cbosbamswx>","References":"<20251203-rzv2h-pre-v3-0-1493e0638626@ideasonboard.com>\n\t<20251203-rzv2h-pre-v3-2-1493e0638626@ideasonboard.com>\n\t<72286ec6-2748-420c-9bea-5e0865ab5afc@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<72286ec6-2748-420c-9bea-5e0865ab5afc@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>"}},{"id":37211,"web_url":"https://patchwork.libcamera.org/comment/37211/","msgid":"<4baefb4e-2ea9-4e15-b819-394319ef7310@ideasonboard.com>","date":"2025-12-04T09:58:40","subject":"Re: [PATCH v3 2/4] libcamera: device_enumerator: Support regex to\n\tmatch entity names","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2025. 12. 04. 10:55 keltezéssel, Jacopo Mondi írta:\n> Hi Barnabás\n> \n> On Wed, Dec 03, 2025 at 09:29:56PM +0100, Barnabás Pőcze wrote:\n>> 2025. 12. 03. 10:14 keltezéssel, Jacopo Mondi írta:\n>>> From: Daniel Scally <dan.scally@ideasonboard.com>\n>>>\n>>> Some entities in a media graph have names that might differ from\n>>> implementation to implementation; for example the Camera Receiver\n>>> Unit and CSI-2 receiver on the RZ/V2H(P) SoC have entities with names\n>>> that include their address, in the form \"csi-16000400.csi2\". Passing\n>>> that entity name to DeviceMatch is too inflexible given it would only\n>>> work if that specific CSI-2 receiver were the one being used.\n>>>\n>>> Add an overload for DeviceMatch::add() such that users can pass in a\n>>> std::regex instead of a string. Update DeviceMatch::match() to check\n>>> for entities that are matched by the regular expressions added with\n>>> the new overload after checking for any exact matches from the vector\n>>> of strings. This allows us to use regex to match on patterns like\n>>> \"csi-[0-9a-f]{8}.csi2\".\n>>>\n>>> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n>>> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n>>> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n>>>\n>>> ---\n>>> [...]\n>>> diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\n>>> index ae17862f676310ef568e5331106ed661e84b5130..2911d5f0385f9765a2eafce2085d1fd627d94b95 100644\n>>> --- a/src/libcamera/device_enumerator.cpp\n>>> +++ b/src/libcamera/device_enumerator.cpp\n>>> @@ -53,7 +53,8 @@ LOG_DEFINE_CATEGORY(DeviceEnumerator)\n>>>     *\n>>>     * A DeviceMatch is created with a specific Linux device driver in mind,\n>>>     * therefore the name of the driver is a required property. One or more Entity\n>>> - * names can be added as match criteria.\n>>> + * names (or regular expressions designed to match an entity name) can be added\n>>> + * as match criteria.\n>>>     *\n>>>     * Pipeline handlers are recommended to add entities to DeviceMatch as\n>>>     * appropriate to ensure that the media device they need can be uniquely\n>>> @@ -81,6 +82,15 @@ void DeviceMatch::add(const std::string &entity)\n>>>    \tentities_.push_back(entity);\n>>>    }\n>>> +/**\n>>> + * \\brief Add a regex to match a media entity name to the search pattern\n>>> + * \\param[in] entity The regex intended to match to an entity in the media graph\n>>> + */\n>>> +void DeviceMatch::add(const std::regex entity)\n>>\n>> Please drop the `const`.\n>>\n> \n> Thanks, this is indeed a leftover.\n> \n> With this fixed, can I push the series or would you like me to resend\n> it ?\n\nI think so, no more comments from me.\n\n\n> \n> Thanks\n>    j\n> \n>>\n>>> +{\n>>> +\tentityRegexs_.push_back(std::move(entity));\n>>> +}\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 CF8F1BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Dec 2025 09:58:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 23F5E610A6;\n\tThu,  4 Dec 2025 10:58:47 +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 10FCF6069A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Dec 2025 10:58:45 +0100 (CET)","from [192.168.33.28] (185.182.214.221.nat.pool.zt.hu\n\t[185.182.214.221])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 48A15D7;\n\tThu,  4 Dec 2025 10:56:29 +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=\"rQ3hNC49\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1764842189;\n\tbh=R2qlNpobHyrxDuDMQGQB5LQxSmWBfGmnzx3JlDcMqT0=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=rQ3hNC49ubX/C054XKr+MHCZIdxrbBt5Mn0gMHt9ePZQJ/SjtFc6FW3Gx1J2/fW/k\n\t6q78MIRxV6bC/vGsJPRaJbXqQGsxuM+3C5R5dBPpOjdqfdV433IGuARq5L1RGubv1p\n\tFr5E8xAQ9hc842JTb6gG0Zyp7cA9E+jHwFBuoQak=","Message-ID":"<4baefb4e-2ea9-4e15-b819-394319ef7310@ideasonboard.com>","Date":"Thu, 4 Dec 2025 10:58:40 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v3 2/4] libcamera: device_enumerator: Support regex to\n\tmatch entity names","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"Daniel Scally <dan.scally@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20251203-rzv2h-pre-v3-0-1493e0638626@ideasonboard.com>\n\t<20251203-rzv2h-pre-v3-2-1493e0638626@ideasonboard.com>\n\t<72286ec6-2748-420c-9bea-5e0865ab5afc@ideasonboard.com>\n\t<dipjcml45g6ocd4dfhltwg2qaapyscfju4fc3ajafeuuuz2zbp@c4cbosbamswx>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<dipjcml45g6ocd4dfhltwg2qaapyscfju4fc3ajafeuuuz2zbp@c4cbosbamswx>","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>"}}]