{"id":15303,"url":"https://patchwork.libcamera.org/api/1.1/patches/15303/?format=json","web_url":"https://patchwork.libcamera.org/patch/15303/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220130235821.48076-7-djrscally@gmail.com>","date":"2022-01-30T23:58:21","name":"[libcamera-devel,v2,6/6] media: v4l2-async: Create links during v4l2_async_match_notify()","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"bac0b1cf89715167e25e153650fc29ca734638be","submitter":{"id":90,"url":"https://patchwork.libcamera.org/api/1.1/people/90/?format=json","name":"Daniel Scally","email":"djrscally@gmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15303/mbox/","series":[{"id":2904,"url":"https://patchwork.libcamera.org/api/1.1/series/2904/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2904","date":"2022-01-30T23:58:15","name":"Introduce ancillary links","version":2,"mbox":"https://patchwork.libcamera.org/series/2904/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15303/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15303/checks/","tags":{},"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 575CDBDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 30 Jan 2022 23:59:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0606B609F0;\n\tMon, 31 Jan 2022 00:59:16 +0100 (CET)","from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com\n\t[IPv6:2a00:1450:4864:20::42a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A97BB609DD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 31 Jan 2022 00:59:11 +0100 (CET)","by mail-wr1-x42a.google.com with SMTP id c23so22070673wrb.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 30 Jan 2022 15:59:11 -0800 (PST)","from localhost.localdomain\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161])\n\tby smtp.gmail.com with ESMTPSA id\n\t11sm11993663wrb.30.2022.01.30.15.59.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 30 Jan 2022 15:59:11 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"aohO9Go1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=TsRQ3SVohkOtQPdF+FWJeJ2VqSG/vDGg0tiEtAOREIM=;\n\tb=aohO9Go1mMW0DmLUPrYqXyicUFMJyZx4iDGeZkMMH8GF1eUI891taRf+dpuYnTxhEX\n\tZFRrGidCc9f73wRKfXxEhsjQS0qStKvs17lQwTHDBiEy8fI3K8PuS2qSFmgyw/sRJGdC\n\tZm2rx+Kj2uhaOtV03ubWuiu3LVs2QKTchhGZ1bXO8WD+VkaEgBOCpvjdqghPrenpEysp\n\tKUMhdmDBMZRvjCv8bwRrf+M2A5eU0uJouxa3FlY72PHTjKKz6ElsQ5GQ9Ka6aeOuKMB5\n\tHUtsfgsFtsMtQfpgty6LXJLLUoOBhINN7GHBNpRAOidPljzo6NT9SknApF3l9J6wTqDn\n\tc+KA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=TsRQ3SVohkOtQPdF+FWJeJ2VqSG/vDGg0tiEtAOREIM=;\n\tb=LMkB7KpJuo1wQz/194wnGgWCRxf4r28XaSzCxFJadp4E1J9EsqMi66mV9NuPEWYHpa\n\tCRFKL6oaX2VPwbqOzrwVo60FDvzenrDZrBNsNU5hphseAWdqkje1houT7uEgMLkUhR7+\n\tpLEv0li3XIaraF0vlhdX68tXnmGjH9P0wTbIWSfM9BcUdaE2ALoetl8h4pa0FztpYVOH\n\toWCoBX7K0QVQSxTq7RrqGCNZSR9lbek15SXROosAWo/MtzsJbnyVmxA7IkLV7tNWqOVX\n\t/Y57G43RX4aVQt+My9gxpBD6rN+TUaT9WYMcE2b2003Vr61c+K8gTuExV+qOv7jYLCiZ\n\tOR0w==","X-Gm-Message-State":"AOAM532Fk2wy4DPc63N53db2oQviP+incBquZsa7BBF4kVYB45TMF0mh\n\tYAPOqapjN+6PA8x1KhMwtFI=","X-Google-Smtp-Source":"ABdhPJwo/8lAg1VcbfXGIKrXktZ/0c3eyIE8YP3e9uMMRaMJeJw2RBTuNYgQGzIvJ8PpwWybXlIm4w==","X-Received":"by 2002:a5d:4889:: with SMTP id\n\tg9mr14979816wrq.400.1643587151468; \n\tSun, 30 Jan 2022 15:59:11 -0800 (PST)","From":"Daniel Scally <djrscally@gmail.com>","To":"linux-media@vger.kernel.org,\n\tlibcamera-devel@lists.libcamera.org","Date":"Sun, 30 Jan 2022 23:58:21 +0000","Message-Id":"<20220130235821.48076-7-djrscally@gmail.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20220130235821.48076-1-djrscally@gmail.com>","References":"<20220130235821.48076-1-djrscally@gmail.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 6/6] media: v4l2-async: Create links\n\tduring 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>","Cc":"sakari.ailus@linux.intel.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Upon an async fwnode match, there's some typical behaviour that the\nnotifier and matching subdev will want to do. For example, a notifier\nrepresenting a sensor matching to an async subdev representing its\nVCM will want to create an ancillary link to expose that relationship\nto userspace.\n\nTo avoid lots of code in individual drivers, try to build these links\nwithin v4l2 core.\n\nSigned-off-by: Daniel Scally <djrscally@gmail.com>\n---\nChanges since v1:\n\n\t- Added #ifdef guards for CONFIG_MEDIA_CONTROLLER\n\t- Some spelling and nomenclature cleanup (Laurent)\n\nChanges since the rfc:\n\n\t- None\n\n drivers/media/v4l2-core/v4l2-async.c | 56 ++++++++++++++++++++++++++++\n 1 file changed, 56 insertions(+)","diff":"diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c\nindex 0404267f1ae4..8980534e755e 100644\n--- a/drivers/media/v4l2-core/v4l2-async.c\n+++ b/drivers/media/v4l2-core/v4l2-async.c\n@@ -275,6 +275,50 @@ 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\n+__v4l2_async_create_ancillary_link(struct v4l2_async_notifier *notifier,\n+\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 -EINVAL;\n+\n+\tlink = media_create_ancillary_link(&notifier->sd->entity, &sd->entity);\n+\n+#endif\n+\n+\treturn IS_ERR(link) ? PTR_ERR(link) : 0;\n+}\n+\n+/*\n+ * Create links on behalf of the notifier and subdev, where it's obvious what\n+ * should be done. At the moment, we only support cases where the notifier\n+ * is a camera sensor and the subdev is a lens controller.\n+ *\n+ * TODO: Create data links if the notifier's function is\n+ * MEDIA_ENT_F_VID_IF_BRIDGE and the subdev's is MEDIA_ENT_F_CAM_SENSOR.\n+ */\n+static int v4l2_async_try_create_links(struct v4l2_async_notifier *notifier,\n+\t\t\t\t       struct v4l2_subdev *sd)\n+{\n+#if IS_ENABLED(CONFIG_MEDIA_CONTROLLER)\n+\n+\tif (!notifier->sd)\n+\t\treturn 0;\n+\n+\tswitch (notifier->sd->entity.function) {\n+\tcase MEDIA_ENT_F_CAM_SENSOR:\n+\t\treturn __v4l2_async_create_ancillary_link(notifier, sd);\n+\t}\n+\n+#endif\n+\treturn 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 +337,18 @@ 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_try_create_links(notifier, sd);\n+\tif (ret) {\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;\n","prefixes":["libcamera-devel","v2","6/6"]}