Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5321432pxv; Wed, 7 Jul 2021 00:37:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzu6e5h3Tz8SBaVawWC6uk3h6Mkx6CoLQz3MOk1RIYD5cGyYpoLGS8QqoQz9CNg39jKUYI9 X-Received: by 2002:a6b:f41a:: with SMTP id i26mr18658499iog.162.1625643448459; Wed, 07 Jul 2021 00:37:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625643448; cv=none; d=google.com; s=arc-20160816; b=x9vxj265jTPWVuHDF7lWdoNShjPi+1Hp/FsViCT6Oy77apd74Ct6Px2u3bBl/By0IA 87NCUQAgyqyKxq7oa0uj7a6pYprzUHka0f2qSKJVfTG+IEDzQdVN6iTSs/Rh81TixSL3 7cbGBihOak9Cln6iRtTNqvIWa3My0sSxxp4fuc0Gx7257On/CkTWBGPG/4+lPQo26yi6 quXdciqdTA4UZY4o7walKeN3oJw1vZu9RdsaGnYwmPX6g7Clzaw4Yspxi8i2n0VN/9+q kE7mxqUD6uRUzMgGRI6Kqn+VIb8+Hs4CtDFwlGK6DvMK6kzNChOyFHoCq98JRPCUS9ED T8Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=o+DOXYaLhuexH0DTEP+mN+AuQ2RorTj6+9m3uAihWSo=; b=huE4C//09C9Bk7YDVl/0c7R76frR4MVba2wZgBaj/rQnZis8GI1U816hD03sKuWO8t rhCl3WZmWNubgPxApfpYaQD5Z73Uyy5hOjKmhETHCJ3sEDCgaoNTSMacGgeYM3ivi21V Wejs+wg67NlJasdWbeIQgklaHNfqmmhwKkBTVXT89AZC25S+uU9Q1H1xPQrNdtZ6WOaB J68h7+FvpIMN6NBzeBu7sxcCkzGg9ldIXaIk7IWTJ930F3VhgajL+/ZXzsNSi7eCtChj VAmv3nsZQaE7vlMbCAe/PgKddgdvw+oTJlATCQ8zzIsqHC5NyRi5rsB++qLNIbp4pCvz fcwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EcdqyIk2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b7si23353517ile.135.2021.07.07.00.37.17; Wed, 07 Jul 2021 00:37:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EcdqyIk2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231142AbhGGHiE (ORCPT + 99 others); Wed, 7 Jul 2021 03:38:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231132AbhGGHiD (ORCPT ); Wed, 7 Jul 2021 03:38:03 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9CAAC06175F for ; Wed, 7 Jul 2021 00:35:22 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id h1-20020a17090a3d01b0290172d33bb8bcso3183069pjc.0 for ; Wed, 07 Jul 2021 00:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o+DOXYaLhuexH0DTEP+mN+AuQ2RorTj6+9m3uAihWSo=; b=EcdqyIk2NW70w0Z7UNj55PxSMt/fdYXmWaot0zjGUXjAP+tMifFgMDAfSgvNUXZCUZ 5pS7ykBRJErpdLwUilHQDJlpNf7l9k9LuHZabTtlkmwrCxdyU3YFylwPzlMfmuZJ0mAd rmB0B08++4xpfg98vEmkMCe9PJXo+FaESLaZw= 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=o+DOXYaLhuexH0DTEP+mN+AuQ2RorTj6+9m3uAihWSo=; b=jJ07vRA61+M3s4DcpFHHAELPOKrXR8TL1nloguZmGcqnXmOLHpzqONq9rxD13ePaAr iVrCm1sVFeudrt+DXxxICmjN0/L+OGbQym7DOx85GN4Qhs0LveSI96qBQEsBOFhcpLnF rU0NsreAeQNHbcR/H/as9U/oFK9SxZcFZ/ImAvqpyH8R1uDaY+gIar7LzNscUzdyPp2Q /WVCP+Z4fa26srVi349oLwCgvcjVBYAPqoxtvd+QB1+Ax7LC7unQJgvzAct/HjS0ioMC 0PCNk8mZap9fYP12803l5s/OFX0CU4AFnzL6vIS9tdrIPG89oqyTj20lcaM98eXLRQAs Rclg== X-Gm-Message-State: AOAM531FGRsc1BYQ67BeqlMyh3aT3r5YWQ0oMgR2lF0MFsMrRZNiH4lw UdF4yd6cL4fHGQLoeptIDsMa0xk0dpp0kA== X-Received: by 2002:a17:902:8601:b029:11c:4b4:e967 with SMTP id f1-20020a1709028601b029011c04b4e967mr20390465plo.75.1625643322093; Wed, 07 Jul 2021 00:35:22 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:ccb9:d95f:4dac:dbc4]) by smtp.gmail.com with UTF8SMTPSA id d2sm21506853pgh.59.2021.07.07.00.35.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Jul 2021 00:35:21 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: houlong.wei@mediatek.com, enric.balletbo@collabora.com, wenst@chromium.org, yong.wu@mediatek.com, chunkuang.hu@kernel.org, Eizan Miyamoto , Andrew-CT Chen , Matthias Brugger , Mauro Carvalho Chehab , Minghsiu Tsai , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v4 7/8] media: mtk-mdp: use mdp-rdma0 alias to point to MDP master Date: Wed, 7 Jul 2021 17:34:09 +1000 Message-Id: <20210707173108.v4.7.I2049e180dca12e0d1b3178bfc7292dcf9e05ac28@changeid> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog In-Reply-To: <20210707073410.999625-1-eizan@chromium.org> References: <20210707073410.999625-1-eizan@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ... Instead of depending on the presence of a mediatek,vpu property in the device node. That property was originally added to link to the vpu node so that the mtk_mdp_core driver could pass the right device to vpu_wdt_reg_handler(). However in a previous patch in this series, the driver has been modified to search the device tree for that node instead. That property was also used to indicate the primary MDP device, so that it can be passed to the V4L2 subsystem as well as register it to be used when setting up queues in the open() callback for the filesystem device node that is created. In this case, assuming that the primary MDP device is the one with a specific alias seems useable because the alternative is to add a property to the device tree which doesn't actually represent any facet of hardware (i.e., this being the primary MDP device is a software decision). In other words, this solution is equally as arbitrary, but at least it doesn't add a property to a device node where said property is unrelated to the hardware present. Signed-off-by: Eizan Miyamoto --- (no changes since v1) drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 47 ++++++++++++++----- drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 6 +++ 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c index 59911ee063c1..2a71c582d8b1 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c @@ -141,22 +141,48 @@ void mtk_mdp_comp_clock_off(struct mtk_mdp_comp *comp) } } +/* + * The MDP master device node is identified by the device tree alias + * "mdp-rdma0". + */ +static int is_mdp_master(struct device *dev) +{ + struct device_node *aliases, *mdp_rdma0_node; + const char *mdp_rdma0_path; + + if (!dev->of_node) + return 0; + + aliases = of_find_node_by_path("/aliases"); + if (!aliases) { + dev_err(dev, "no aliases found for mdp-rdma0"); + return 0; + } + + mdp_rdma0_path = of_get_property(aliases, "mdp-rdma0", NULL); + if (!mdp_rdma0_path) { + dev_err(dev, "get mdp-rdma0 property of /aliases failed"); + return 0; + } + + mdp_rdma0_node = of_find_node_by_path(mdp_rdma0_path); + if (!mdp_rdma0_node) { + dev_err(dev, "path resolution failed for %s", mdp_rdma0_path); + return 0; + } + + return dev->of_node == mdp_rdma0_node; +} + static int mtk_mdp_comp_bind(struct device *dev, struct device *master, void *data) { struct mtk_mdp_comp *comp = dev_get_drvdata(dev); struct mtk_mdp_dev *mdp = data; - struct device_node *vpu_node; mtk_mdp_register_component(mdp, comp); - /* - * If this component has a "mediatek-vpu" property, it is responsible for - * notifying the mdp master driver about it so it can be further initialized - * later. - */ - vpu_node = of_parse_phandle(dev->of_node, "mediatek,vpu", 0); - if (vpu_node) { + if (is_mdp_master(dev)) { int ret; ret = v4l2_device_register(dev, &mdp->v4l2_dev); @@ -172,9 +198,8 @@ static int mtk_mdp_comp_bind(struct device *dev, struct device *master, } /* - * presence of the "mediatek,vpu" property in a device node - * indicates that it is the primary MDP rdma device and MDP DMA - * ops should be handled by its DMA callbacks. + * MDP DMA ops will be handled by the DMA callbacks associated with this + * device; */ mdp->rdma_dev = dev; } diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c index 523e3c2798e1..be7d35b3e3ff 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c @@ -157,6 +157,12 @@ static int mtk_mdp_master_bind(struct device *dev) goto err_component_bind_all; } + if (mdp->rdma_dev == NULL) { + dev_err(dev, "Primary MDP device not found"); + status = -ENODEV; + goto err_component_bind_all; + } + vpu_node = of_find_node_by_name(NULL, "vpu"); if (!vpu_node) { dev_err(dev, "unable to find vpu node"); -- 2.32.0.93.g670b81a890-goog