From patchwork Sun Mar 15 10:27:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 11438829 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0A1B1667 for ; Sun, 15 Mar 2020 10:27:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A040F2073E for ; Sun, 15 Mar 2020 10:27:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="am6oQ6Qg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728251AbgCOK1j (ORCPT ); Sun, 15 Mar 2020 06:27:39 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:38745 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728141AbgCOK1j (ORCPT ); Sun, 15 Mar 2020 06:27:39 -0400 Received: by mail-wr1-f65.google.com with SMTP id x11so12801859wrv.5; Sun, 15 Mar 2020 03:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FwtzcC8IW9tEsin9GPZR2uWGtkHPFjBYYOq6bNXXxpw=; b=am6oQ6Qgb8gpvC5ELOHohR0HLqW9UAY/kQkNaQvn8HLe8PvWC2l8xjIRpb0arNo/AN SkCp7IoCdBWOBuMl10wBbc5uhI3Nky+R90bR0IGIku2/0yCo1Uf4cPXISFZJSnKZSFk0 IJthdtVEEMVnd2YVE39B8FUq/eVWPv8e/cuJxxCJw6AjIH9RXxPi9U+l0M54NsxzwT8P YKcaURK+XLvfN1l08nMNEjMgyokzsdPd6KwxLozvfdk/t56395aei9foEvOZrHyMHctb +1gHLK/gp3d+DFD45UMLOIJWpFW6DSDmMadtP7Gx/ZjL30gmMdq2bKvDAchsSankBWhK xxGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FwtzcC8IW9tEsin9GPZR2uWGtkHPFjBYYOq6bNXXxpw=; b=U4WyqCDYy+3KvKSypTfvzlDornB2aX3qgEUkXAOg/EEPl0wiRXMu8garMCQEu+BnG5 BAf0K8O14zV4x4LP2s+iUdyhj8WFUshIoEFMddeSDKvTL4ujakjWx+d8TyCNqxjB8GsL kM4HmZ739HGshKKA8N1/xJRw6WH8+NN680KY3py+X951xT8H8NFe1OUZxjFahDNVQB35 h1m8sPqVBioKdij1kmVmvppfaK8jJSoe402CdngxwKqsoUGHBh9a63n5pIugLaqHN8ar I1Pr6sTvoOum/SV/qcqKtLlrBUeXwuRU5Bd8ePkleu8E0JWM0D6yWJr9rrvpWDzPdoOI oAhQ== X-Gm-Message-State: ANhLgQ11ge5I6XMYhfmgkl/XBjHjzpbQHQ8GdVlWCO2hn94+0Sgeknwq 9DwZIkHuKKORZOPhNoShamg= X-Google-Smtp-Source: ADFU+vuJv4kBkZEOnJbIlq3eEi685L26EqBo3hYHwhnfeY9y/Gz0D/sNPSZrEhapWICATb4anJxfPQ== X-Received: by 2002:adf:b19e:: with SMTP id q30mr28969014wra.163.1584268057577; Sun, 15 Mar 2020 03:27:37 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2510:d000:2c12:3438:7cb7:556d]) by smtp.gmail.com with ESMTPSA id z129sm25765190wmb.7.2020.03.15.03.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2020 03:27:36 -0700 (PDT) From: Lad Prabhakar X-Google-Original-From: Lad Prabhakar To: Niklas , Mauro Carvalho Chehab , Sakari Ailus , Laurent Pinchart , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Lad Prabhakar Subject: [PATCH 1/2] media: v4l2-async: Pass pointer to struct v4l2_subdev in match_custom callback Date: Sun, 15 Mar 2020 10:27:23 +0000 Message-Id: <20200315102724.26850-2-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200315102724.26850-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20200315102724.26850-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Passing a pointer to struct device for the match_custom callback is of no use as in the bridge driver to match the fwnode, so instead pass the struct v4l2_subdev pointer so that the bridge driver has enough information to match against the subdevices. Signed-off-by: Lad Prabhakar --- drivers/media/v4l2-core/v4l2-async.c | 2 +- include/media/v4l2-async.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 8bde33c21ce4..f897d4025f97 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -80,7 +80,7 @@ static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) /* Match always */ return true; - return asd->match.custom.match(sd->dev, asd); + return asd->match.custom.match(sd, asd); } static LIST_HEAD(subdev_list); diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index 8319284c93cb..8c014e3bbd6c 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -86,8 +86,8 @@ struct v4l2_async_subdev { unsigned short address; } i2c; struct { - bool (*match)(struct device *dev, - struct v4l2_async_subdev *sd); + bool (*match)(struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd); void *priv; } custom; } match; From patchwork Sun Mar 15 10:27:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 11438835 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C87D1890 for ; Sun, 15 Mar 2020 10:27:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 29C8B206E9 for ; Sun, 15 Mar 2020 10:27:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cMHf4rPn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728141AbgCOK1l (ORCPT ); Sun, 15 Mar 2020 06:27:41 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:55808 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728234AbgCOK1l (ORCPT ); Sun, 15 Mar 2020 06:27:41 -0400 Received: by mail-wm1-f68.google.com with SMTP id 6so14454833wmi.5; Sun, 15 Mar 2020 03:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=isehurdj5wn3c+W0oK2ewJ+9tH4P/AOAlMD4rcT40Og=; b=cMHf4rPne7z6O1NtW/tIDnS7Ed17XFMOs7//4UgHUIMFSKXY4IPBOQSu+lO3Wu2Tgd bvbCn1+z0NWM1+d6IdOnjyRV5glDnal6/TcJFM6hGQ90+2Uuglxw4lhhDZt29/mkaP5t OTcYItOdIdng2dK9o6wnwnBu08nDgLMKnqTDNtMK0yaTEVsMVniNW1D6IKmhMO5VbabB wNwuDFRh2IZuZbEuuWvGw00Gz6D4qTqr1fu9Zm9KecZiLClNwakimQfgtz7uhRveiKva R9ogkTAYud88FKChCyJ38m9F3NeX/G7N2AUwUn8Vl6uU1yWtXIXFeSoCzgZ2B8LtPcXv dlZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=isehurdj5wn3c+W0oK2ewJ+9tH4P/AOAlMD4rcT40Og=; b=lrQjWiVvD1279DAd4WNqrXJKeH3Kt4ymg4TWonJ3Y/N6n1OZd1/UszrrF3rDnAk96J l58/dNZSVBonP0nuAsipuDkJEM/Wb05K5BQk8lu6kvkxZx9VliComfDxvl5r/DJzW36f 8oYJfnKy6jX/EKc2ZeSt9ZMigNhxaRFJHKqQgn9ZhP+15JQMaOnIYDHJkjUDG71j9NTI s2Jqa78V1UqB3cpXFW0ozli/zeo2cVUhjEy/33tD4KeUHNLeFc31b6VTnEobnr6AUOo9 WUnPxPwjB5zW9hnnVjD3B69ZHue0jEyITuRhcar8TNss9BVncNmyirlVAxnMipOTPa01 OUIw== X-Gm-Message-State: ANhLgQ3C6Eeseq0v7FvHuoSGRRC5H03YcyOUxarbqEqsS0XGcMC2AJDa fwWpxtIR/f954659JMiL5gk= X-Google-Smtp-Source: ADFU+vtn37wVG0Czz5ac7f88DgLlkYZBCN3tu4vX7BZfFUoq59AvFNtKNfD9qN2LgEeLwpkzLITj3w== X-Received: by 2002:a1c:dc55:: with SMTP id t82mr21131825wmg.6.1584268058919; Sun, 15 Mar 2020 03:27:38 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2510:d000:2c12:3438:7cb7:556d]) by smtp.gmail.com with ESMTPSA id z129sm25765190wmb.7.2020.03.15.03.27.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2020 03:27:38 -0700 (PDT) From: Lad Prabhakar X-Google-Original-From: Lad Prabhakar To: Niklas , Mauro Carvalho Chehab , Sakari Ailus , Laurent Pinchart , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Lad Prabhakar Subject: [PATCH 2/2] media: rcar-csi2: Let the driver handle fwnode matching using match_custom callback Date: Sun, 15 Mar 2020 10:27:24 +0000 Message-Id: <20200315102724.26850-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200315102724.26850-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20200315102724.26850-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The rcar-csi2 driver uses the v4l2-async framework to do endpoint matching instead of node matching. This is needed as it needs to work with the adv748x driver which register it self in v4l2-async using endpoints instead of nodes. The reason for this is that from a single DT node it creates multiple subdevices, one for each endpoint. But when using subdevs which register itself in v4l2-async using nodes, the rcar-csi2 driver failed to find the matching endpoint because the match.fwnode was pointing to remote endpoint instead of remote parent port. This commit adds support in rcar-csi2 driver to handle both the cases where subdev registers in v4l2-async using endpoints/nodes, by using match_type as V4L2_ASYNC_MATCH_CUSTOM and implementing the match() callback to compare the fwnode of either remote/parent. Signed-off-by: Lad Prabhakar --- drivers/media/platform/rcar-vin/rcar-csi2.c | 46 +++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c index faa9fb23a2e9..1bbf05e9f025 100644 --- a/drivers/media/platform/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c @@ -808,6 +808,46 @@ static int rcsi2_parse_v4l2(struct rcar_csi2 *priv, return 0; } +static bool rcsi2_asd_match(struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct rcar_csi2 *priv = (struct rcar_csi2 *)asd->match.custom.priv; + struct fwnode_handle *remote_endpoint; + struct fwnode_handle *subdev_endpoint; + struct device_node *np; + bool matched = false; + + np = of_graph_get_endpoint_by_regs(priv->dev->of_node, 0, 0); + if (!np) { + dev_err(priv->dev, "Not connected to subdevice\n"); + return matched; + } + + remote_endpoint = + fwnode_graph_get_remote_endpoint(of_fwnode_handle(np)); + if (!remote_endpoint) { + dev_err(priv->dev, "Failed to get remote endpoint\n"); + of_node_put(np); + return matched; + } + of_node_put(np); + + if (sd->fwnode != dev_fwnode(sd->dev)) { + if (remote_endpoint == sd->fwnode) + matched = true; + } else { + subdev_endpoint = + fwnode_graph_get_next_endpoint(dev_fwnode(sd->dev), NULL); + if (remote_endpoint == subdev_endpoint) + matched = true; + fwnode_handle_put(subdev_endpoint); + } + + fwnode_handle_put(remote_endpoint); + + return matched; +} + static int rcsi2_parse_dt(struct rcar_csi2 *priv) { struct device_node *ep; @@ -833,9 +873,9 @@ static int rcsi2_parse_dt(struct rcar_csi2 *priv) return ret; } - priv->asd.match.fwnode = - fwnode_graph_get_remote_endpoint(of_fwnode_handle(ep)); - priv->asd.match_type = V4L2_ASYNC_MATCH_FWNODE; + priv->asd.match.custom.match = &rcsi2_asd_match; + priv->asd.match.custom.priv = priv; + priv->asd.match_type = V4L2_ASYNC_MATCH_CUSTOM; of_node_put(ep);