From: narmstrong@baylibre.com (Neil Armstrong)
To: linus-amlogic@lists.infradead.org
Subject: [PATCH v2 03/13] drm/meson: Add support for components
Date: Tue, 4 Apr 2017 11:08:26 +0200 [thread overview]
Message-ID: <e0a88828-3fab-1a3e-ed1e-7a91d94358d4@baylibre.com> (raw)
In-Reply-To: <20170404085931.7sv3k7lwgt6klu37@phenom.ffwll.local>
On 04/04/2017 10:59 AM, Daniel Vetter wrote:
> On Tue, Mar 21, 2017 at 04:25:40PM +0100, Neil Armstrong wrote:
>> This patch adds support for optional components connected through the
>> Device Tree endpoints scheme.
>>
>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>> ---
>> drivers/gpu/drm/meson/meson_drv.c | 113 +++++++++++++++++++++++++++++++++-----
>> 1 file changed, 99 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
>> index bc562a0..a2e9f56 100644
>> --- a/drivers/gpu/drm/meson/meson_drv.c
>> +++ b/drivers/gpu/drm/meson/meson_drv.c
>> @@ -24,6 +24,7 @@
>> #include <linux/module.h>
>> #include <linux/mutex.h>
>> #include <linux/platform_device.h>
>> +#include <linux/component.h>
>> #include <linux/of_graph.h>
>>
>> #include <drm/drmP.h>
>> @@ -150,9 +151,9 @@ static bool meson_vpu_has_available_connectors(struct device *dev)
>> .max_register = 0x1000,
>> };
>>
>> -static int meson_drv_probe(struct platform_device *pdev)
>> +static int meson_drv_bind(struct device *dev)
>> {
>> - struct device *dev = &pdev->dev;
>> + struct platform_device *pdev = to_platform_device(dev);
>> struct meson_drm *priv;
>> struct drm_device *drm;
>> struct resource *res;
>> @@ -215,6 +216,15 @@ static int meson_drv_probe(struct platform_device *pdev)
>>
>> drm_vblank_init(drm, 1);
>> drm_mode_config_init(drm);
>> + drm->mode_config.max_width = 3840;
>> + drm->mode_config.max_height = 2160;
>> + drm->mode_config.funcs = &meson_mode_config_funcs;
>> +
>> + /* Hardware Initialization */
>> +
>> + meson_venc_init(priv);
>> + meson_vpp_init(priv);
>> + meson_viu_init(priv);
>>
>> /* Encoder Initialization */
>>
>> @@ -222,11 +232,11 @@ static int meson_drv_probe(struct platform_device *pdev)
>> if (ret)
>> goto free_drm;
>>
>> - /* Hardware Initialization */
>> -
>> - meson_venc_init(priv);
>> - meson_vpp_init(priv);
>> - meson_viu_init(priv);
>> + ret = component_bind_all(drm->dev, drm);
>> + if (ret) {
>> + dev_err(drm->dev, "Couldn't bind all components\n");
>> + goto free_drm;
>> + }
>>
>> ret = meson_plane_create(priv);
>> if (ret)
>> @@ -241,9 +251,6 @@ static int meson_drv_probe(struct platform_device *pdev)
>> goto free_drm;
>>
>> drm_mode_config_reset(drm);
>> - drm->mode_config.max_width = 8192;
>> - drm->mode_config.max_height = 8192;
>> - drm->mode_config.funcs = &meson_mode_config_funcs;
>>
>> priv->fbdev = drm_fbdev_cma_init(drm, 32,
>> drm->mode_config.num_connector);
>> @@ -268,9 +275,9 @@ static int meson_drv_probe(struct platform_device *pdev)
>> return ret;
>> }
>>
>> -static int meson_drv_remove(struct platform_device *pdev)
>> +static void meson_drv_unbind(struct device *dev)
>> {
>> - struct drm_device *drm = dev_get_drvdata(&pdev->dev);
>> + struct drm_device *drm = dev_get_drvdata(dev);
>> struct meson_drm *priv = drm->dev_private;
>>
>> drm_dev_unregister(drm);
>> @@ -280,9 +287,88 @@ static int meson_drv_remove(struct platform_device *pdev)
>> drm_vblank_cleanup(drm);
>> drm_dev_unref(drm);
>>
>> - return 0;
>> }
>>
>> +static const struct component_master_ops meson_drv_master_ops = {
>> + .bind = meson_drv_bind,
>> + .unbind = meson_drv_unbind,
>> +};
>> +
>> +static int compare_of(struct device *dev, void *data)
>> +{
>> + DRM_DEBUG_DRIVER("Comparing of node %s with %s\n",
>> + of_node_full_name(dev->of_node),
>> + of_node_full_name(data));
>> +
>> + return dev->of_node == data;
>> +}
>> +
>> +/* Possible connectors nodes to ignore */
>> +static const struct of_device_id connectors_match[] = {
>> + { .compatible = "composite-video-connector" },
>> + { .compatible = "svideo-connector" },
>> + { .compatible = "hdmi-connector" },
>> + { .compatible = "dvi-connector" },
>> + {}
>> +};
>> +
>> +static int meson_probe_remote(struct platform_device *pdev,
>> + struct component_match **match,
>> + struct device_node *parent,
>> + struct device_node *remote)
>> +{
>> + struct device_node *ep, *remote_node;
>> + int count = 1;
>> +
>> + /* If node is a connector, return and do not add to match table */
>> + if (of_match_node(connectors_match, remote))
>> + return 1;
>> +
>> + component_match_add(&pdev->dev, match, compare_of, remote);
>> +
>> + for_each_endpoint_of_node(remote, ep) {
>> + remote_node = of_graph_get_remote_port_parent(ep);
>> + if (!remote_node ||
>> + remote_node == parent || /* Ignore parent endpoint */
>> + !of_device_is_available(remote_node))
>> + continue;
>> +
>> + count += meson_probe_remote(pdev, match, remote, remote_node);
>> +
>> + of_node_put(remote_node);
>> + }
>> +
>> + return count;
>> +}
>> +
>> +static int meson_drv_probe(struct platform_device *pdev)
>> +{
>> + struct component_match *match = NULL;
>> + struct device_node *np = pdev->dev.of_node;
>> + struct device_node *ep, *remote;
>> + int count = 0;
>> +
>> + for_each_endpoint_of_node(np, ep) {
>> + remote = of_graph_get_remote_port_parent(ep);
>> + if (!remote || !of_device_is_available(remote))
>> + continue;
>> +
>> + count += meson_probe_remote(pdev, &match, np, remote);
>> + }
>> +
>> + /* If some endpoints were found, initialize the nodes */
>> + if (count) {
>
> What if you have more than 1 endpoint described, but module load order
> conspires against you to only initialize 1 at first?
As I understood, the component_bind_all() will fail until all modules are loaded
even in wrong order, no ?
I tested with multiple combinations and it worked like a charm... maybe I missed
something here !
Thanks,
Neil
> -Daniel
>
>> + dev_info(&pdev->dev, "Queued %d outputs on vpu\n", count);
>> +
>> + return component_master_add_with_match(&pdev->dev,
>> + &meson_drv_master_ops,
>> + match);
>> + }
>> +
>> + /* If no output endpoints were available, simply bail out */
>> + return 0;
>> +};
>> +
>> static const struct of_device_id dt_match[] = {
>> { .compatible = "amlogic,meson-gxbb-vpu" },
>> { .compatible = "amlogic,meson-gxl-vpu" },
>> @@ -293,7 +379,6 @@ static int meson_drv_remove(struct platform_device *pdev)
>>
>> static struct platform_driver meson_drm_platform_driver = {
>> .probe = meson_drv_probe,
>> - .remove = meson_drv_remove,
>> .driver = {
>> .name = "meson-drm",
>> .of_match_table = dt_match,
>> --
>> 1.9.1
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
next prev parent reply other threads:[~2017-04-04 9:08 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-21 15:25 [PATCH v2 00/13] drm/meson: Initial support for HDMI Output Neil Armstrong
2017-03-21 15:25 ` [PATCH v2 01/13] drm/meson: Use crtc_state for hdisplay and fix atomic flush/enable sync for vsync commit Neil Armstrong
2017-04-04 8:49 ` Daniel Vetter
2017-03-21 15:25 ` [PATCH v2 02/13] drm/meson: Add missing HDMI register Neil Armstrong
2017-03-21 15:25 ` [PATCH v2 03/13] drm/meson: Add support for components Neil Armstrong
2017-04-04 8:59 ` Daniel Vetter
2017-04-04 9:08 ` Neil Armstrong [this message]
2017-04-04 9:09 ` Daniel Vetter
2017-03-21 15:25 ` [PATCH v2 04/13] drm/meson: venc_cvbs: no more return -ENODEV if CVBS is not available Neil Armstrong
2017-03-21 15:25 ` [PATCH v2 05/13] drm/meson: add support for HDMI clock support Neil Armstrong
2017-03-21 15:25 ` [PATCH v2 06/13] drm/meson: Add support for HDMI venc modes and settings Neil Armstrong
2017-03-21 15:25 ` [PATCH v2 07/13] drm/meson: Add support for HDMI encoder and DW-HDMI bridge + PHY Neil Armstrong
2017-04-04 8:57 ` Daniel Vetter
2017-04-04 9:16 ` Neil Armstrong
2017-04-04 13:50 ` Daniel Vetter
2017-03-21 15:25 ` [PATCH v2 08/13] ARM64: dts: meson-gx: Add shared CMA dma memory pool Neil Armstrong
2017-04-04 8:41 ` Neil Armstrong
2017-04-04 11:57 ` Kevin Hilman
2017-03-21 15:25 ` [PATCH v2 09/13] ARM64: dts: meson-gx: Add support for HDMI output Neil Armstrong
2017-04-04 8:10 ` Neil Armstrong
2017-04-04 11:57 ` Kevin Hilman
2017-03-21 15:25 ` [PATCH v2 10/13] dt-bindings: Add bindings for the Amlogic Meson dw-hdmi extension Neil Armstrong
2017-03-21 15:25 ` [PATCH v2 11/13] drm/meson: Convert existing documentation to actual kerneldoc Neil Armstrong
2017-03-21 15:25 ` [PATCH v2 12/13] drm/meson: Add RST to bring together kerneldoc Neil Armstrong
2017-04-04 9:00 ` Daniel Vetter
2017-04-04 9:17 ` Neil Armstrong
2017-03-21 15:25 ` [PATCH v2 13/13] MAINTAINERS: update files for Amlogic DRM Driver Neil Armstrong
2017-04-04 9:01 ` Daniel Vetter
2017-04-04 9:18 ` Neil Armstrong
2017-04-04 9:04 ` [PATCH v2 00/13] drm/meson: Initial support for HDMI Output Daniel Vetter
2017-04-04 9:21 ` Neil Armstrong
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=e0a88828-3fab-1a3e-ed1e-7a91d94358d4@baylibre.com \
--to=narmstrong@baylibre.com \
--cc=linus-amlogic@lists.infradead.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
all inboxes | Powered by JetHome®