public inbox for linux-rockchip@lists.infradead.org
 help / color / mirror / Atom feed
From: Sandy Huang <hjc@rock-chips.com>
To: Heiko Stuebner <heiko@sntech.de>
Cc: linux-rockchip@lists.infradead.org, seanpaul@chromium.org,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v8 1/3] drm/rockchip: add function to check if endpoint is a subdriver
Date: Fri, 31 Aug 2018 09:41:29 +0800	[thread overview]
Message-ID: <ad6135e6-e2d4-7b97-3d77-4aa085270960@rock-chips.com> (raw)
In-Reply-To: <20180830211207.10480-2-heiko@sntech.de>


在 2018/8/31 5:12, Heiko Stuebner 写道:
> To be able to have both internal subdrivers and external bridge
> drivers as output endpoints of vops, add a function to be able
> to distinguish these.
> 
> changes in v8:
> - improved function documentation
> - better error handling
> - put calls for node and pdev references
> changes in v6:
> - added function to check subdriver vs. bridge
> 
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> ---
>   drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 48 +++++++++++++++++++++
>   drivers/gpu/drm/rockchip/rockchip_drm_drv.h |  1 +
>   2 files changed, 49 insertions(+)
> 
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index 1d9c4a9201c8..5864cb452c5c 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -24,6 +24,7 @@
>   #include <linux/pm_runtime.h>
>   #include <linux/module.h>
>   #include <linux/of_graph.h>
> +#include <linux/of_platform.h>
>   #include <linux/component.h>
>   #include <linux/console.h>
>   #include <linux/iommu.h>
> @@ -267,6 +268,53 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = {
>   static struct platform_driver *rockchip_sub_drivers[MAX_ROCKCHIP_SUB_DRIVERS];
>   static int num_rockchip_sub_drivers;
>   
> +/*
> + * Check if a vop endpoint is leading to a rockchip subdriver or bridge.
> + * Should be called from the component bind stage of the drivers
> + * to ensure that all subdrivers are probed.
> + *
> + * @ep: endpoint of a rockchip vop
> + *
> + * returns true if subdriver, false if external bridge and -ENODEV
> + * if remote port does not contain a device.
> + */
> +int rockchip_drm_endpoint_is_subdriver(struct device_node *ep)
> +{
> +	struct device_node *node = of_graph_get_remote_port_parent(ep);
> +	struct platform_device *pdev;
> +	struct device_driver *drv;
> +	int i;
> +
> +	if (!node)
> +		return -ENODEV;
> +
> +	/* status disabled will prevent creation of platform-devices */
> +	pdev = of_find_device_by_node(node);
> +	of_node_put(node);
> +	if (!pdev)
> +		return -ENODEV;
> +
> +	/*
> +	 * All rockchip subdrivers have probed at this point, so
> +	 * any device not having a driver now is an external bridge.
> +	 */
> +	drv = pdev->dev.driver;
> +	if (!drv) {
> +		platform_device_put(pdev);
> +		return false;
> +	}
> +
> +	for (i = 0; i < num_rockchip_sub_drivers; i++) {
> +		if (rockchip_sub_drivers[i] == to_platform_driver(drv)) {
> +			platform_device_put(pdev);
> +			return true;
> +		}
> +	}
> +
> +	platform_device_put(pdev);
> +	return false;
> +}
> +
>   static int compare_dev(struct device *dev, void *data)
>   {
>   	return dev == (struct device *)data;
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
> index d67ad0a3cf36..21a023a97bb8 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
> @@ -64,6 +64,7 @@ void rockchip_drm_dma_detach_device(struct drm_device *drm_dev,
>   				    struct device *dev);
>   int rockchip_drm_wait_vact_end(struct drm_crtc *crtc, unsigned int mstimeout);
>   
> +int rockchip_drm_endpoint_is_subdriver(struct device_node *ep);
>   extern struct platform_driver cdn_dp_driver;
>   extern struct platform_driver dw_hdmi_rockchip_pltfm_driver;
>   extern struct platform_driver dw_mipi_dsi_driver;
> 

Reviewed-by Sandy Huang <hjc@rock-chips.com>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-08-31  1:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-30 21:12 [PATCH v8 0/3] Add support rockchip RGB output interface Heiko Stuebner
2018-08-30 21:12 ` [PATCH v8 1/3] drm/rockchip: add function to check if endpoint is a subdriver Heiko Stuebner
2018-08-31  1:41   ` Sandy Huang [this message]
2018-08-30 21:12 ` [PATCH v8 2/3] drm/rockchip: Add support for Rockchip Soc RGB output interface Heiko Stuebner
     [not found]   ` <20180830211207.10480-3-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
2019-01-18  0:40     ` [v8, " Thomas Gleixner
     [not found]       ` <alpine.DEB.2.21.1901180131510.1647-ecDvlHI5BZPZikZi3RtOZ1XZhhPuCNm+@public.gmane.org>
2019-01-18 12:34         ` Heiko Stuebner
2019-01-24 11:41           ` sandy.huang
2018-08-30 21:12 ` [PATCH v8 3/3] drm/rockchip: Add directly output rgb feature for px30 Heiko Stuebner
2018-09-05 11:05 ` [PATCH v8 0/3] Add support rockchip RGB output interface Heiko Stuebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ad6135e6-e2d4-7b97-3d77-4aa085270960@rock-chips.com \
    --to=hjc@rock-chips.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=heiko@sntech.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=seanpaul@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox