[{"id":34642,"web_url":"https://patchwork.libcamera.org/comment/34642/","msgid":"<20250625221841.GA710@pendragon.ideasonboard.com>","date":"2025-06-25T22:18:41","subject":"Re: [PATCH v1 0/2] Use regular expressions for entity name matching","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Wed, Jun 25, 2025 at 04:53:06PM +0100, Daniel Scally wrote:\n> There are a couple of places in libcamera that fetch a MediaEntity\n> from a MediaDevice using the entity's name. This has raised an issue\n> lately on the RZ/V2H platforms, as the drivers for some of the\n> hardware give the entities that they create names that incorporate\n> things like the memory address for the hardware's registers. If we\n> simply use those names as-is then the pipeline handler would only\n> work for the instance of the hardware that's at the hard-coded\n> address and not any of the others.\n\nThis raises a few questions:\n\n- Should drivers do that ?\n- If not, can we fix them ?\n\nEntities exist in the context of a media graph. Including addresses in\nentity names seems pointless if the address is already conveyed by the\nmedia device, and it makes userspace more complex (as shown by this\nseries).\n\nIf a media graph contains multiple entities of the same type, they need\nto be differentiated. Some drivers use an index (e.g. indexing video\ndevices at the output of a CSI-2 receiver). Other use addresses, which\nmay be the best option when there is no intrinsic index (e.g. two\nidentical CSI-2 RX connected to the same ISP).\n\nStill brainstorming, I wonder if that case should be handled by exposing\na bus info for entities, in addition to their names. That would be a\nmore complex API extension though, and would require updates in some\nuserspace tools. In any case, I think we need to document the entity\nnaming best practices in the kernel.\n\n> To work around the issue, this series updates libcamera to use regex\n> matching when searching for a MediaEntity by name. Existing call\n> sites which just pass a normal string should work unaffected, but new\n> call sites could use a string that builds a valid regular expression\n> instead.\n> \n> Daniel Scally (2):\n>   libcamera: device_enumerator: Use regex to match entity names\n>   libcamera: media_device: Use a regex to match entity name\n> \n>  .../libcamera/internal/device_enumerator.h    |  3 ++-\n>  src/libcamera/device_enumerator.cpp           | 27 ++++++++++---------\n>  src/libcamera/media_device.cpp                | 12 ++++++---\n>  src/libcamera/v4l2_subdevice.cpp              |  4 +--\n>  4 files changed, 26 insertions(+), 20 deletions(-)","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 47362C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 25 Jun 2025 22:19:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AAC4768DF3;\n\tThu, 26 Jun 2025 00:19:05 +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 C5AC261534\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Jun 2025 00:19:03 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 1BACC6BE;\n\tThu, 26 Jun 2025 00:18:45 +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=\"JOHfIrbc\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750889925;\n\tbh=1HEtJMzQCRJFmE/3aou5kUTLoY1QkpJ6jIPxjfSFSH0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=JOHfIrbc3+NeclVg5Gm83ax1xWajK/nu4gqe1aMwLa7UxTk06F8fab6+s8T8fDjoF\n\tsWSErehL6Ic+4iszwqM9c3rk7ppKLQ/XNBQh2XhrKtVjT9crbJL7b4mzg55xZIlF0+\n\tI+KlHFqiHylJdRkmu6ShKp+kPjSSVJkEPXfI8fF8=","Date":"Thu, 26 Jun 2025 01:18:41 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Daniel Scally <dan.scally@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1 0/2] Use regular expressions for entity name matching","Message-ID":"<20250625221841.GA710@pendragon.ideasonboard.com>","References":"<20250625155308.2325438-1-dan.scally@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20250625155308.2325438-1-dan.scally@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":34646,"web_url":"https://patchwork.libcamera.org/comment/34646/","msgid":"<0586707d-d243-41f7-ab38-996542a07054@ideasonboard.com>","date":"2025-06-26T09:33:17","subject":"Re: [PATCH v1 0/2] Use regular expressions for entity name matching","submitter":{"id":156,"url":"https://patchwork.libcamera.org/api/people/156/","name":"Dan Scally","email":"dan.scally@ideasonboard.com"},"content":"Hi Laurent\n\nOn 25/06/2025 23:18, Laurent Pinchart wrote:\n> On Wed, Jun 25, 2025 at 04:53:06PM +0100, Daniel Scally wrote:\n>> There are a couple of places in libcamera that fetch a MediaEntity\n>> from a MediaDevice using the entity's name. This has raised an issue\n>> lately on the RZ/V2H platforms, as the drivers for some of the\n>> hardware give the entities that they create names that incorporate\n>> things like the memory address for the hardware's registers. If we\n>> simply use those names as-is then the pipeline handler would only\n>> work for the instance of the hardware that's at the hard-coded\n>> address and not any of the others.\n> This raises a few questions:\n>\n> - Should drivers do that ?\nIdeally not\n> - If not, can we fix them ?\n\n\nWe can take the addresses out sure, but is it still worth making some allowance for poorly behaved \ndrivers?\n\n> Entities exist in the context of a media graph. Including addresses in\n> entity names seems pointless if the address is already conveyed by the\n> media device, and it makes userspace more complex (as shown by this\n> series).\n>\n> If a media graph contains multiple entities of the same type, they need\n> to be differentiated. Some drivers use an index (e.g. indexing video\n> devices at the output of a CSI-2 receiver). Other use addresses, which\n> may be the best option when there is no intrinsic index (e.g. two\n> identical CSI-2 RX connected to the same ISP).\nSeparate graphs in this case, which makes it difficult to index them given there'll be no \ninteraction between the different instances of the driver - I guess that's why they chose address.\n>\n> Still brainstorming, I wonder if that case should be handled by exposing\n> a bus info for entities, in addition to their names. That would be a\n> more complex API extension though, and would require updates in some\n> userspace tools. In any case, I think we need to document the entity\n> naming best practices in the kernel.\n\nThe media device does expose a bus_info field already which might be sufficient? At least in this \ncase it is; it contains the address of the CRU instance but since there's a 1:1 relationship between \nthe CRU and CSI it's enough to identify which of the four physical devices the media_device relates to.\n\n\nThanks\n\nDan\n\n>> To work around the issue, this series updates libcamera to use regex\n>> matching when searching for a MediaEntity by name. Existing call\n>> sites which just pass a normal string should work unaffected, but new\n>> call sites could use a string that builds a valid regular expression\n>> instead.\n>>\n>> Daniel Scally (2):\n>>    libcamera: device_enumerator: Use regex to match entity names\n>>    libcamera: media_device: Use a regex to match entity name\n>>\n>>   .../libcamera/internal/device_enumerator.h    |  3 ++-\n>>   src/libcamera/device_enumerator.cpp           | 27 ++++++++++---------\n>>   src/libcamera/media_device.cpp                | 12 ++++++---\n>>   src/libcamera/v4l2_subdevice.cpp              |  4 +--\n>>   4 files changed, 26 insertions(+), 20 deletions(-)","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 750EAC3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 Jun 2025 09:33:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E5FA262C44;\n\tThu, 26 Jun 2025 11:33:21 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 621D762C44\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Jun 2025 11:33:20 +0200 (CEST)","from [192.168.0.43]\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8157E11DA;\n\tThu, 26 Jun 2025 11:33:01 +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=\"lqxil7JU\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750930381;\n\tbh=dOYZOIGw05Ka8mJIlyf8wSe5gRyVSFyucaNHdXECFn4=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=lqxil7JU2LFdz1pukMAnWZUImOkMiFMAjkRE8EbEkOEplgvN5B2tsJgHzVxzH1w2n\n\tq2PlpDwFAsIXJ+Y3djBWbmzvfWs2OTqQ4GN1nOj+vzrFwdLq67KmWyIOL6Mn7b1lDe\n\t7Xt6Yh0TWRsiu2/1LErKiQQGjw4KWChizPb+9/mg=","Message-ID":"<0586707d-d243-41f7-ab38-996542a07054@ideasonboard.com>","Date":"Thu, 26 Jun 2025 10:33:17 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v1 0/2] Use regular expressions for entity name matching","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","References":"<20250625155308.2325438-1-dan.scally@ideasonboard.com>\n\t<20250625221841.GA710@pendragon.ideasonboard.com>","Content-Language":"en-US","From":"Dan Scally <dan.scally@ideasonboard.com>","Autocrypt":"addr=dan.scally@ideasonboard.com; keydata=\n\txsFNBGLydlEBEADa5O2s0AbUguprfvXOQun/0a8y2Vk6BqkQALgeD6KnXSWwaoCULp18etYW\n\tB31bfgrdphXQ5kUQibB0ADK8DERB4wrzrUb5CMxLBFE7mQty+v5NsP0OFNK9XTaAOcmD+Ove\n\teIjYvqurAaro91jrRVrS1gBRxIFqyPgNvwwL+alMZhn3/2jU2uvBmuRrgnc/e9cHKiuT3Dtq\n\tMHGPKL2m+plk+7tjMoQFfexoQ1JKugHAjxAhJfrkXh6uS6rc01bYCyo7ybzg53m1HLFJdNGX\n\tsUKR+dQpBs3SY4s66tc1sREJqdYyTsSZf80HjIeJjU/hRunRo4NjRIJwhvnK1GyjOvvuCKVU\n\tRWpY8dNjNu5OeAfdrlvFJOxIE9M8JuYCQTMULqd1NuzbpFMjc9524U3Cngs589T7qUMPb1H1\n\tNTA81LmtJ6Y+IV5/kiTUANflpzBwhu18Ok7kGyCq2a2jsOcVmk8gZNs04gyjuj8JziYwwLbf\n\tvzABwpFVcS8aR+nHIZV1HtOzyw8CsL8OySc3K9y+Y0NRpziMRvutrppzgyMb9V+N31mK9Mxl\n\t1YkgaTl4ciNWpdfUe0yxH03OCuHi3922qhPLF4XX5LN+NaVw5Xz2o3eeWklXdouxwV7QlN33\n\tu4+u2FWzKxDqO6WLQGjxPE0mVB4Gh5Pa1Vb0ct9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x7qfrmd901\n\tD+N9SjIwrbVhhSyUXYnSUb8F+9g2RDY42Sk7GcYxIeON4VzKqWM7hpkXZ47pkK0YodO+dRKM\n\tyMcoUWrTK0Uz6UzUGKoJVbxmSW/EJLEGoI5p3NWxWtScEVv8mO49gqQdrRIOheZycDmHnItt\n\t9Qjv00uFhEwv2YfiyGk6iGF2W40s2pH2t6oeuGgmiZ7g6d0MEK8Ql/4zPItvr1c1rpwpXUC1\n\tu1kQWgtnNjFHX3KiYdqjcZeRBiry1X0zY+4Y24wUU0KsEewJwjhmCKAsju1RpdlPg2kC","In-Reply-To":"<20250625221841.GA710@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","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":34647,"web_url":"https://patchwork.libcamera.org/comment/34647/","msgid":"<3e019c7d-ebd5-4975-95ae-f2450fb2b783@ideasonboard.com>","date":"2025-06-26T10:15:03","subject":"Re: [PATCH v1 0/2] Use regular expressions for entity name matching","submitter":{"id":156,"url":"https://patchwork.libcamera.org/api/people/156/","name":"Dan Scally","email":"dan.scally@ideasonboard.com"},"content":"Hi Laurent\n\nOn 26/06/2025 10:33, Dan Scally wrote:\n> Hi Laurent\n>\n> On 25/06/2025 23:18, Laurent Pinchart wrote:\n>> On Wed, Jun 25, 2025 at 04:53:06PM +0100, Daniel Scally wrote:\n>>> There are a couple of places in libcamera that fetch a MediaEntity\n>>> from a MediaDevice using the entity's name. This has raised an issue\n>>> lately on the RZ/V2H platforms, as the drivers for some of the\n>>> hardware give the entities that they create names that incorporate\n>>> things like the memory address for the hardware's registers. If we\n>>> simply use those names as-is then the pipeline handler would only\n>>> work for the instance of the hardware that's at the hard-coded\n>>> address and not any of the others.\n>> This raises a few questions:\n>>\n>> - Should drivers do that ?\n> Ideally not\n>> - If not, can we fix them ?\n>\n>\n> We can take the addresses out sure, but is it still worth making some allowance for poorly behaved \n> drivers?\n\n\n...or thinking about it, _can_ we change them? Would they not count as part of the Kernel's public APIs?\n\n>\n>> Entities exist in the context of a media graph. Including addresses in\n>> entity names seems pointless if the address is already conveyed by the\n>> media device, and it makes userspace more complex (as shown by this\n>> series).\n>>\n>> If a media graph contains multiple entities of the same type, they need\n>> to be differentiated. Some drivers use an index (e.g. indexing video\n>> devices at the output of a CSI-2 receiver). Other use addresses, which\n>> may be the best option when there is no intrinsic index (e.g. two\n>> identical CSI-2 RX connected to the same ISP).\n> Separate graphs in this case, which makes it difficult to index them given there'll be no \n> interaction between the different instances of the driver - I guess that's why they chose address.\n>>\n>> Still brainstorming, I wonder if that case should be handled by exposing\n>> a bus info for entities, in addition to their names. That would be a\n>> more complex API extension though, and would require updates in some\n>> userspace tools. In any case, I think we need to document the entity\n>> naming best practices in the kernel.\n>\n> The media device does expose a bus_info field already which might be sufficient? At least in this \n> case it is; it contains the address of the CRU instance but since there's a 1:1 relationship \n> between the CRU and CSI it's enough to identify which of the four physical devices the \n> media_device relates to.\n>\n>\n> Thanks\n>\n> Dan\n>\n>>> To work around the issue, this series updates libcamera to use regex\n>>> matching when searching for a MediaEntity by name. Existing call\n>>> sites which just pass a normal string should work unaffected, but new\n>>> call sites could use a string that builds a valid regular expression\n>>> instead.\n>>>\n>>> Daniel Scally (2):\n>>>    libcamera: device_enumerator: Use regex to match entity names\n>>>    libcamera: media_device: Use a regex to match entity name\n>>>\n>>>   .../libcamera/internal/device_enumerator.h    |  3 ++-\n>>>   src/libcamera/device_enumerator.cpp           | 27 ++++++++++---------\n>>>   src/libcamera/media_device.cpp                | 12 ++++++---\n>>>   src/libcamera/v4l2_subdevice.cpp              |  4 +--\n>>>   4 files changed, 26 insertions(+), 20 deletions(-)","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 47704BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 Jun 2025 10:15:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D58EC68DF6;\n\tThu, 26 Jun 2025 12:15:08 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D79A768DE8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Jun 2025 12:15:06 +0200 (CEST)","from [192.168.0.43]\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 071AB743\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Jun 2025 12:14:47 +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=\"ITTIVeiZ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750932888;\n\tbh=wZsymDPpHbiCvsjvb6fmfYTeeGMw420vzxCzmbEUfVk=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=ITTIVeiZt717aBDD0tniMCCVxg3AWW70/o55PIplnpJJHaPs+FWMk4XjLMjABMez2\n\tvf/K3LqNOuCMlJDXxr3w+nD9QGt2ektoPlUkxp0HKifAJnEsizgVOigyfKP8hITJaw\n\t7Bx+9fcEM/NY34DQ1KFSlPq8KBl+sM8oGNPdmWTQ=","Message-ID":"<3e019c7d-ebd5-4975-95ae-f2450fb2b783@ideasonboard.com>","Date":"Thu, 26 Jun 2025 11:15:03 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v1 0/2] Use regular expressions for entity name matching","To":"libcamera-devel@lists.libcamera.org","References":"<20250625155308.2325438-1-dan.scally@ideasonboard.com>\n\t<20250625221841.GA710@pendragon.ideasonboard.com>\n\t<0586707d-d243-41f7-ab38-996542a07054@ideasonboard.com>","Content-Language":"en-US","From":"Dan Scally <dan.scally@ideasonboard.com>","Autocrypt":"addr=dan.scally@ideasonboard.com; keydata=\n\txsFNBGLydlEBEADa5O2s0AbUguprfvXOQun/0a8y2Vk6BqkQALgeD6KnXSWwaoCULp18etYW\n\tB31bfgrdphXQ5kUQibB0ADK8DERB4wrzrUb5CMxLBFE7mQty+v5NsP0OFNK9XTaAOcmD+Ove\n\teIjYvqurAaro91jrRVrS1gBRxIFqyPgNvwwL+alMZhn3/2jU2uvBmuRrgnc/e9cHKiuT3Dtq\n\tMHGPKL2m+plk+7tjMoQFfexoQ1JKugHAjxAhJfrkXh6uS6rc01bYCyo7ybzg53m1HLFJdNGX\n\tsUKR+dQpBs3SY4s66tc1sREJqdYyTsSZf80HjIeJjU/hRunRo4NjRIJwhvnK1GyjOvvuCKVU\n\tRWpY8dNjNu5OeAfdrlvFJOxIE9M8JuYCQTMULqd1NuzbpFMjc9524U3Cngs589T7qUMPb1H1\n\tNTA81LmtJ6Y+IV5/kiTUANflpzBwhu18Ok7kGyC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l1ur2JzOC\n\tFHRpGadlNzKDE3fEdoMobxHB3Lm6FDml5GyBAA8+dQYVI0oDwJ3gpZPZ0J5Vx9RbqXe8RDuR\n\tdu90hvCJkq7/tzSQ0GeD3BwXb9/R/A4dVXhaDd91Q1qQXidI+2jwhx8iqiYxbT+DoAUkQRQy\n\txBtoCM1CxH7u45URUgD//fxYr3D4B1SlonA6vdaEdHZOGwECnDpTxecENMbz/Bx7qfrmd901\n\tD+N9SjIwrbVhhSyUXYnSUb8F+9g2RDY42Sk7GcYxIeON4VzKqWM7hpkXZ47pkK0YodO+dRKM\n\tyMcoUWrTK0Uz6UzUGKoJVbxmSW/EJLEGoI5p3NWxWtScEVv8mO49gqQdrRIOheZycDmHnItt\n\t9Qjv00uFhEwv2YfiyGk6iGF2W40s2pH2t6oeuGgmiZ7g6d0MEK8Ql/4zPItvr1c1rpwpXUC1\n\tu1kQWgtnNjFHX3KiYdqjcZeRBiry1X0zY+4Y24wUU0KsEewJwjhmCKAsju1RpdlPg2kC","In-Reply-To":"<0586707d-d243-41f7-ab38-996542a07054@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":34648,"web_url":"https://patchwork.libcamera.org/comment/34648/","msgid":"<20250626101952.GF8738@pendragon.ideasonboard.com>","date":"2025-06-26T10:19:52","subject":"Re: [PATCH v1 0/2] Use regular expressions for entity name matching","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, Jun 26, 2025 at 10:33:17AM +0100, Daniel Scally wrote:\n> On 25/06/2025 23:18, Laurent Pinchart wrote:\n> > On Wed, Jun 25, 2025 at 04:53:06PM +0100, Daniel Scally wrote:\n> >> There are a couple of places in libcamera that fetch a MediaEntity\n> >> from a MediaDevice using the entity's name. This has raised an issue\n> >> lately on the RZ/V2H platforms, as the drivers for some of the\n> >> hardware give the entities that they create names that incorporate\n> >> things like the memory address for the hardware's registers. If we\n> >> simply use those names as-is then the pipeline handler would only\n> >> work for the instance of the hardware that's at the hard-coded\n> >> address and not any of the others.\n> > \n> > This raises a few questions:\n> >\n> > - Should drivers do that ?\n>\n> Ideally not\n>\n> > - If not, can we fix them ?\n> \n> We can take the addresses out sure, but is it still worth making some\n> allowance for poorly behaved drivers?\n\nIn my experience, by being more strict in libcamera we can ensure that\ndrivers stop behaving poorly. Of course we may need to support existing\ndrivers that we can't change without breaking userspace, but for new\ndrivers we should do things right in the kernel.\n\n> > Entities exist in the context of a media graph. Including addresses in\n> > entity names seems pointless if the address is already conveyed by the\n> > media device, and it makes userspace more complex (as shown by this\n> > series).\n> >\n> > If a media graph contains multiple entities of the same type, they need\n> > to be differentiated. Some drivers use an index (e.g. indexing video\n> > devices at the output of a CSI-2 receiver). Other use addresses, which\n> > may be the best option when there is no intrinsic index (e.g. two\n> > identical CSI-2 RX connected to the same ISP).\n>\n> Separate graphs in this case, which makes it difficult to index them\n> given there'll be no interaction between the different instances of\n> the driver - I guess that's why they chose address.\n\nA separate media graph is not always possible. Think of the i.MX8MP for\ninstance, we have two CSI-2 receivers connected to the ISI, in a single\nmedia graph. We can't use indices for the CSI-2 receiver entity names as\nthere's no intrinsic index.\n\n> > Still brainstorming, I wonder if that case should be handled by exposing\n> > a bus info for entities, in addition to their names. That would be a\n> > more complex API extension though, and would require updates in some\n> > userspace tools. In any case, I think we need to document the entity\n> > naming best practices in the kernel.\n> \n> The media device does expose a bus_info field already which might be\n> sufficient? At least in this case it is; it contains the address of\n> the CRU instance but since there's a 1:1 relationship between the CRU\n> and CSI it's enough to identify which of the four physical devices the\n> media_device relates to.\n\nThe media device bus_info is for the whole media device. In the above\ni.MX8MP ISI example, it won't solve our problem.\n\n> >> To work around the issue, this series updates libcamera to use regex\n> >> matching when searching for a MediaEntity by name. Existing call\n> >> sites which just pass a normal string should work unaffected, but new\n> >> call sites could use a string that builds a valid regular expression\n> >> instead.\n> >>\n> >> Daniel Scally (2):\n> >>    libcamera: device_enumerator: Use regex to match entity names\n> >>    libcamera: media_device: Use a regex to match entity name\n> >>\n> >>   .../libcamera/internal/device_enumerator.h    |  3 ++-\n> >>   src/libcamera/device_enumerator.cpp           | 27 ++++++++++---------\n> >>   src/libcamera/media_device.cpp                | 12 ++++++---\n> >>   src/libcamera/v4l2_subdevice.cpp              |  4 +--\n> >>   4 files changed, 26 insertions(+), 20 deletions(-)","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 6861EC3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 Jun 2025 10:20:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E3EB268DF6;\n\tThu, 26 Jun 2025 12:20:18 +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 F310368DE8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Jun 2025 12:20:16 +0200 (CEST)","from pendragon.ideasonboard.com (85-76-34-12-nat.elisa-mobile.fi\n\t[85.76.34.12])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id C7150743;\n\tThu, 26 Jun 2025 12:19:57 +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=\"RuJNhFEO\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750933198;\n\tbh=4r+Wf3mNmSZ3+MyUL7re0s7kswkZCYzTISwyJYPzT4Y=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=RuJNhFEOKRSqFm7Mqae7CPec0MUKtXt5UkKQxOqB7Mj8Z5TR1xqYKoNWSzFj2Lvbb\n\t/iKWjdDmchncPbvvqjx8BkfTw6PrQIBu9w+r+JSc4YxdLKqR+7UNvQFnIWQgE/vVvi\n\tG0/1DxJHicgdMT+dULTUDlbNodfa1Z3e+By8Fyys=","Date":"Thu, 26 Jun 2025 13:19:52 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Dan Scally <dan.scally@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1 0/2] Use regular expressions for entity name matching","Message-ID":"<20250626101952.GF8738@pendragon.ideasonboard.com>","References":"<20250625155308.2325438-1-dan.scally@ideasonboard.com>\n\t<20250625221841.GA710@pendragon.ideasonboard.com>\n\t<0586707d-d243-41f7-ab38-996542a07054@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<0586707d-d243-41f7-ab38-996542a07054@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>"}}]