[{"id":22249,"web_url":"https://patchwork.libcamera.org/comment/22249/","msgid":"<b2d41731-bc1d-c63f-db28-75869e7c34f4@gmail.com>","date":"2022-03-09T15:46:28","subject":"Re: [libcamera-devel] [PATCH v3 5/5] media: v4l2-async: Create\n\tlinks during v4l2_async_match_notify()","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Hi !\n\nThanks for the patch !\n\nOn 02/03/2022 23:03, Daniel Scally wrote:\n> Upon an async fwnode match, there's some typical behaviour that the\n> notifier and matching subdev will want to do. For example, a notifier\n> representing a sensor matching to an async subdev representing its\n> VCM will want to create an ancillary link to expose that relationship\n> to userspace.\n> \n> To avoid lots of code in individual drivers, try to build these links\n> within v4l2 core.\n> \n> Signed-off-by: Daniel Scally <djrscally@gmail.com>\n\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n\n> ---\n> \n> Changes since v2:\n> \n> \t- Stopped checking the notifier entity's function when creating the new\n> \tlinks, and just create them whenever the subdev entity's function is either\n> \ta lens controller or a flash. (Sakari)\n> \n> Changes since v1:\n> \n> \t- Added #ifdef guards for CONFIG_MEDIA_CONTROLLER\n> \t- Some spelling and nomenclature cleanup (Laurent)\n> \n> Changes since the rfc:\n> \n> \t- None\n> \n>   drivers/media/v4l2-core/v4l2-async.c | 31 ++++++++++++++++++++++++++++\n>   1 file changed, 31 insertions(+)\n> \n> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c\n> index 0404267f1ae4..436bd6900fd8 100644\n> --- a/drivers/media/v4l2-core/v4l2-async.c\n> +++ b/drivers/media/v4l2-core/v4l2-async.c\n> @@ -275,6 +275,24 @@ v4l2_async_nf_try_complete(struct v4l2_async_notifier *notifier)\n>   static int\n>   v4l2_async_nf_try_all_subdevs(struct v4l2_async_notifier *notifier);\n>   \n> +static int v4l2_async_create_ancillary_links(struct v4l2_async_notifier *n,\n> +\t\t\t\t\t     struct v4l2_subdev *sd)\n> +{\n> +\tstruct media_link *link = NULL;\n> +\n> +#if IS_ENABLED(CONFIG_MEDIA_CONTROLLER)\n> +\n> +\tif (sd->entity.function != MEDIA_ENT_F_LENS &&\n> +\t    sd->entity.function != MEDIA_ENT_F_FLASH)\n> +\t\treturn 0;\n> +\n> +\tlink = media_create_ancillary_link(&n->sd->entity, &sd->entity);\n> +\n> +#endif\n> +\n> +\treturn IS_ERR(link) ? PTR_ERR(link) : 0;\n> +}\n> +\n>   static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier,\n>   \t\t\t\t   struct v4l2_device *v4l2_dev,\n>   \t\t\t\t   struct v4l2_subdev *sd,\n> @@ -293,6 +311,19 @@ static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier,\n>   \t\treturn ret;\n>   \t}\n>   \n> +\t/*\n> +\t * Depending of the function of the entities involved, we may want to\n> +\t * create links between them (for example between a sensor and its lens\n> +\t * or between a sensor's source pad and the connected device's sink\n> +\t * pad).\n> +\t */\n> +\tret = v4l2_async_create_ancillary_links(notifier, sd);\n> +\tif (ret) {\n> +\t\tv4l2_async_nf_call_unbind(notifier, sd, asd);\n> +\t\tv4l2_device_unregister_subdev(sd);\n> +\t\treturn ret;\n> +\t}\n> +\n>   \t/* Remove from the waiting list */\n>   \tlist_del(&asd->list);\n>   \tsd->asd = asd;","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 9BDC7BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  9 Mar 2022 15:46:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 56E4661189;\n\tWed,  9 Mar 2022 16:46:34 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 30C1C60475\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Mar 2022 16:46:32 +0100 (CET)","from [IPV6:2a01:e0a:169:7140:3734:287e:1a7f:9772] (unknown\n\t[IPv6:2a01:e0a:169:7140:3734:287e:1a7f:9772])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BF4C4A50;\n\tWed,  9 Mar 2022 16:46:31 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1646840794;\n\tbh=P+2Mt69akyFAOyIlUjKNmiavQVkbY+usV6Yd5T4ev+4=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=GhrAv0lxZMtLWqhme4PbfMVLu+lXbkJXqe+6Q6W3UhlsDkDbtWfkMxpO4QsmfUXQc\n\txAqMM255vqzAfYOMovNGYjVAvK4Qka9ijy/5gbBy36kguJnKW1z1jaSifaZNUSZYc1\n\tsQUXrsWAJ1Co5q7MNNvb1yGtcfm225HG2qiq0cu8FlGI5KDfNI3w9I5ozF8fUqsLuH\n\tNvhIZiWZb7ka44lwKI5R6+oo4zWNMdIP29dDVpoz2Pa5APjn5nDNTMqUDJN4kJGMtB\n\tUXyzbpW/b5ZiihUbNhmHl0HJKTsmPKYDOlvJ6Fo3BxdReGHiL4Fuk0t5Y5crQKTdRP\n\t51Uvz/OsoATqg==","Message-ID":"<b2d41731-bc1d-c63f-db28-75869e7c34f4@gmail.com>","Date":"Wed, 9 Mar 2022 16:46:28 +0100","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.5.0","Content-Language":"en-US","To":"Daniel Scally <djrscally@gmail.com>, linux-media@vger.kernel.org,\n\tlibcamera-devel@lists.libcamera.org","References":"<20220302220304.1327896-1-djrscally@gmail.com>\n\t<20220302220304.1327896-6-djrscally@gmail.com>","In-Reply-To":"<20220302220304.1327896-6-djrscally@gmail.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v3 5/5] media: v4l2-async: Create\n\tlinks during v4l2_async_match_notify()","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>","From":"Jean-Michel Hautbois via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Jean-Michel Hautbois <jeanmichel.hautbois@gmail.com>","Cc":"sakari.ailus@linux.intel.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22284,"web_url":"https://patchwork.libcamera.org/comment/22284/","msgid":"<YjEn1tMZ4O8vup5e@pendragon.ideasonboard.com>","date":"2022-03-15T23:57:10","subject":"Re: [libcamera-devel] [PATCH v3 5/5] media: v4l2-async: Create\n\tlinks during v4l2_async_match_notify()","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Hi Dan,\n\nThank you for the patch.\n\nOn Wed, Mar 02, 2022 at 10:03:04PM +0000, Daniel Scally wrote:\n> Upon an async fwnode match, there's some typical behaviour that the\n> notifier and matching subdev will want to do. For example, a notifier\n> representing a sensor matching to an async subdev representing its\n> VCM will want to create an ancillary link to expose that relationship\n> to userspace.\n> \n> To avoid lots of code in individual drivers, try to build these links\n> within v4l2 core.\n> \n> Signed-off-by: Daniel Scally <djrscally@gmail.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n> \n> Changes since v2:\n> \n> \t- Stopped checking the notifier entity's function when creating the new\n> \tlinks, and just create them whenever the subdev entity's function is either\n> \ta lens controller or a flash. (Sakari)\n> \n> Changes since v1:\n> \n> \t- Added #ifdef guards for CONFIG_MEDIA_CONTROLLER\n> \t- Some spelling and nomenclature cleanup (Laurent)\n> \n> Changes since the rfc:\n> \n> \t- None\n> \n>  drivers/media/v4l2-core/v4l2-async.c | 31 ++++++++++++++++++++++++++++\n>  1 file changed, 31 insertions(+)\n> \n> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c\n> index 0404267f1ae4..436bd6900fd8 100644\n> --- a/drivers/media/v4l2-core/v4l2-async.c\n> +++ b/drivers/media/v4l2-core/v4l2-async.c\n> @@ -275,6 +275,24 @@ v4l2_async_nf_try_complete(struct v4l2_async_notifier *notifier)\n>  static int\n>  v4l2_async_nf_try_all_subdevs(struct v4l2_async_notifier *notifier);\n>  \n> +static int v4l2_async_create_ancillary_links(struct v4l2_async_notifier *n,\n> +\t\t\t\t\t     struct v4l2_subdev *sd)\n> +{\n> +\tstruct media_link *link = NULL;\n> +\n> +#if IS_ENABLED(CONFIG_MEDIA_CONTROLLER)\n> +\n> +\tif (sd->entity.function != MEDIA_ENT_F_LENS &&\n> +\t    sd->entity.function != MEDIA_ENT_F_FLASH)\n> +\t\treturn 0;\n> +\n> +\tlink = media_create_ancillary_link(&n->sd->entity, &sd->entity);\n> +\n> +#endif\n> +\n> +\treturn IS_ERR(link) ? PTR_ERR(link) : 0;\n> +}\n> +\n>  static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier,\n>  \t\t\t\t   struct v4l2_device *v4l2_dev,\n>  \t\t\t\t   struct v4l2_subdev *sd,\n> @@ -293,6 +311,19 @@ static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier,\n>  \t\treturn ret;\n>  \t}\n>  \n> +\t/*\n> +\t * Depending of the function of the entities involved, we may want to\n> +\t * create links between them (for example between a sensor and its lens\n> +\t * or between a sensor's source pad and the connected device's sink\n> +\t * pad).\n> +\t */\n> +\tret = v4l2_async_create_ancillary_links(notifier, sd);\n> +\tif (ret) {\n> +\t\tv4l2_async_nf_call_unbind(notifier, sd, asd);\n> +\t\tv4l2_device_unregister_subdev(sd);\n> +\t\treturn ret;\n> +\t}\n> +\n>  \t/* Remove from the waiting list */\n>  \tlist_del(&asd->list);\n>  \tsd->asd = asd;","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 00C2EBDE17\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 15 Mar 2022 23:57:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 36EC4610F8;\n\tWed, 16 Mar 2022 00:57:33 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C0EBC604DC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 16 Mar 2022 00:57:28 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1C187A67;\n\tWed, 16 Mar 2022 00:57:28 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647388653;\n\tbh=0H7ZHZHlOnyteW5l9VvECWwbV+cCuaRhVPfrerh95Q0=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=YI3dO5HC8JCJnH4GMzVu/g6DPidFnM6HcuPTkDdmukSDreNujbn6OmoJ/7N7zjZbQ\n\tT84JlwKgrP7p0JcY+X9wcRTtvTJVGwP3rJRJWB7kCiBg+bMZvl3wYGReRDEso+hTeV\n\tJoe4RZ1aGsFIh0i/v59AMs4f6SAJ8v77586Vs1PFGOtfy+F+ulJFA9gIF2z7Lkk5x5\n\tZLVMm8e7iOq4haH1zuPaxR2+rRCM5fNxddEK7O2ri5KgLSU3Ei98p4jjYDfJuIui8K\n\tXq9lt3o4pEjSM0py2xM0YRS+ZucaoxcMpW3N3qNH8W+Olna0+62nV9BRBc+Ns68vg4\n\tOMd5Y5d9SOc8g==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1647388648;\n\tbh=0H7ZHZHlOnyteW5l9VvECWwbV+cCuaRhVPfrerh95Q0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=GCTDXOZDjYWt/nz5c+8TejhQCqekW0OIPSP+sJRmVIcX6MyALNJyDjALr3iobsAU5\n\tvP1Bpg/QL9Ao8+xPZX4rFYBuaRJivOSKygCFI7y6Kq6CbOa8ybPeVPmfCVsvixRYr1\n\tL4XOk3rgtp2vi7+IEGK/Mn4ndypUQkbY1Eg0sJP4="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"GCTDXOZD\"; dkim-atps=neutral","Date":"Wed, 16 Mar 2022 01:57:10 +0200","To":"Daniel Scally <djrscally@gmail.com>","Message-ID":"<YjEn1tMZ4O8vup5e@pendragon.ideasonboard.com>","References":"<20220302220304.1327896-1-djrscally@gmail.com>\n\t<20220302220304.1327896-6-djrscally@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220302220304.1327896-6-djrscally@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v3 5/5] media: v4l2-async: Create\n\tlinks during v4l2_async_match_notify()","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, sakari.ailus@linux.intel.com,\n\tlinux-media@vger.kernel.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]