From patchwork Wed Mar 2 22:03:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 15402 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 21A89BE08A for ; Wed, 2 Mar 2022 22:03:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C918861185; Wed, 2 Mar 2022 23:03:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XUyuvemJ"; dkim-atps=neutral Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 05BE661176 for ; Wed, 2 Mar 2022 23:03:19 +0100 (CET) Received: by mail-wr1-x42b.google.com with SMTP id b5so4927730wrr.2 for ; Wed, 02 Mar 2022 14:03:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7+FTeVrGz7SDdPY4UPOaMR4mAYUB8c53cmn+nXuAyMQ=; b=XUyuvemJYa0uAPOj7k1G9IzitT9VXfDcKWXDcEhdYDSJCfn/HU7OkbxGM5iO6MemUb lV3mCqItMcPQB0EK6wYMqh7ToMdUlCmyNIhbOWG1fJ/aru63wO0k/xKZwjJS2/QDq4dk RopjcHiTUEMSXcJhj/x9l16gFI7wpJ7hI/zdL++voTzJR3Gy18mSFaXypTqxOcByPaao XzD4+mib6HCoy6psPvbeTt4gr8KJ6sMpsmMSN8i5ccTPLm3R6h6K/iHrT3v03XaaSJKo e20Gjg7+bHyOjUWXiSB0dF5XWNH0ftXbJ1PdvkypVpJCMhg5aAM6efH1HSus13BfdXOV PuiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7+FTeVrGz7SDdPY4UPOaMR4mAYUB8c53cmn+nXuAyMQ=; b=FEIUURXgSgsiHl0xlad1d6k0DOTa1fItURr0dJworN0zbOyj3x+MU/IOiGMvsX4YNq rZTLu/rFR/tKaRE2BEdfyeORAOOa58vIu/bTfWQFO/IZcAxTXelC1EKxBhM4FGyhTtwd 8MDlj1FOHjnai6ZrWq+42uxpreEcJYEKGCSZagoRS4cQJ6DqjzRIoriT6Ut2Yqg81ufU kz5pZqfh1b1LYu2hUOFttiA7ym3sPYBZCHIwIY4p7LDxV/1E4S0patZTWGBMyMOHW+St XLg+KdnjdMuCyT9oOvSYfNF5z0CxrNeaheYgx/gdYw8bHuCVRE1lxFKz4SK1lqOQoSal zOjQ== X-Gm-Message-State: AOAM533qOC8R6+dQNQYq+hlcKcW1+KBcHVdjC1+VQb9Ghv+BewROkVEg 3wN0sMZdSqX4Sx3FQO4FB58= X-Google-Smtp-Source: ABdhPJz1z6DPBD7bhcCCeO9fFebsmUH9yJLSFoHKDSYe79QR+HkAQD7iFfp63LfGerWLD27PjJv+Hg== X-Received: by 2002:a5d:4310:0:b0:1ef:fb60:e1d8 with SMTP id h16-20020a5d4310000000b001effb60e1d8mr9095465wrq.92.1646258598715; Wed, 02 Mar 2022 14:03:18 -0800 (PST) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id l16-20020a05600c4f1000b0033383cdeea1sm229258wmq.10.2022.03.02.14.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 14:03:18 -0800 (PST) From: Daniel Scally To: linux-media@vger.kernel.org, libcamera-devel@lists.libcamera.org Date: Wed, 2 Mar 2022 22:03:04 +0000 Message-Id: <20220302220304.1327896-6-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220302220304.1327896-1-djrscally@gmail.com> References: <20220302220304.1327896-1-djrscally@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 5/5] media: v4l2-async: Create links during v4l2_async_match_notify() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sakari.ailus@linux.intel.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Upon an async fwnode match, there's some typical behaviour that the notifier and matching subdev will want to do. For example, a notifier representing a sensor matching to an async subdev representing its VCM will want to create an ancillary link to expose that relationship to userspace. To avoid lots of code in individual drivers, try to build these links within v4l2 core. Signed-off-by: Daniel Scally Reviewed-by: Jean-Michel Hautbois Reviewed-by: Laurent Pinchart --- Changes since v2: - Stopped checking the notifier entity's function when creating the new links, and just create them whenever the subdev entity's function is either a lens controller or a flash. (Sakari) Changes since v1: - Added #ifdef guards for CONFIG_MEDIA_CONTROLLER - Some spelling and nomenclature cleanup (Laurent) Changes since the rfc: - None drivers/media/v4l2-core/v4l2-async.c | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 0404267f1ae4..436bd6900fd8 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -275,6 +275,24 @@ v4l2_async_nf_try_complete(struct v4l2_async_notifier *notifier) static int v4l2_async_nf_try_all_subdevs(struct v4l2_async_notifier *notifier); +static int v4l2_async_create_ancillary_links(struct v4l2_async_notifier *n, + struct v4l2_subdev *sd) +{ + struct media_link *link = NULL; + +#if IS_ENABLED(CONFIG_MEDIA_CONTROLLER) + + if (sd->entity.function != MEDIA_ENT_F_LENS && + sd->entity.function != MEDIA_ENT_F_FLASH) + return 0; + + link = media_create_ancillary_link(&n->sd->entity, &sd->entity); + +#endif + + return IS_ERR(link) ? PTR_ERR(link) : 0; +} + static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier, struct v4l2_device *v4l2_dev, struct v4l2_subdev *sd, @@ -293,6 +311,19 @@ static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier, return ret; } + /* + * Depending of the function of the entities involved, we may want to + * create links between them (for example between a sensor and its lens + * or between a sensor's source pad and the connected device's sink + * pad). + */ + ret = v4l2_async_create_ancillary_links(notifier, sd); + if (ret) { + v4l2_async_nf_call_unbind(notifier, sd, asd); + v4l2_device_unregister_subdev(sd); + return ret; + } + /* Remove from the waiting list */ list_del(&asd->list); sd->asd = asd;