drm/meson: Add support for components
This patch adds support for optional components connected through the Device Tree endpoints scheme. Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
This commit is contained in:
parent
8437d59ab3
commit
a41e82e6c4
|
@ -24,6 +24,7 @@
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
|
#include <linux/component.h>
|
||||||
#include <linux/of_graph.h>
|
#include <linux/of_graph.h>
|
||||||
|
|
||||||
#include <drm/drmP.h>
|
#include <drm/drmP.h>
|
||||||
|
@ -150,9 +151,9 @@ static struct regmap_config meson_regmap_config = {
|
||||||
.max_register = 0x1000,
|
.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 meson_drm *priv;
|
||||||
struct drm_device *drm;
|
struct drm_device *drm;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
|
@ -215,6 +216,15 @@ static int meson_drv_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
drm_vblank_init(drm, 1);
|
drm_vblank_init(drm, 1);
|
||||||
drm_mode_config_init(drm);
|
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 */
|
/* Encoder Initialization */
|
||||||
|
|
||||||
|
@ -222,11 +232,11 @@ static int meson_drv_probe(struct platform_device *pdev)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto free_drm;
|
goto free_drm;
|
||||||
|
|
||||||
/* Hardware Initialization */
|
ret = component_bind_all(drm->dev, drm);
|
||||||
|
if (ret) {
|
||||||
meson_venc_init(priv);
|
dev_err(drm->dev, "Couldn't bind all components\n");
|
||||||
meson_vpp_init(priv);
|
goto free_drm;
|
||||||
meson_viu_init(priv);
|
}
|
||||||
|
|
||||||
ret = meson_plane_create(priv);
|
ret = meson_plane_create(priv);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -241,9 +251,6 @@ static int meson_drv_probe(struct platform_device *pdev)
|
||||||
goto free_drm;
|
goto free_drm;
|
||||||
|
|
||||||
drm_mode_config_reset(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,
|
priv->fbdev = drm_fbdev_cma_init(drm, 32,
|
||||||
drm->mode_config.num_connector);
|
drm->mode_config.num_connector);
|
||||||
|
@ -268,9 +275,9 @@ static int meson_drv_probe(struct platform_device *pdev)
|
||||||
return ret;
|
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;
|
struct meson_drm *priv = drm->dev_private;
|
||||||
|
|
||||||
drm_dev_unregister(drm);
|
drm_dev_unregister(drm);
|
||||||
|
@ -280,9 +287,88 @@ static int meson_drv_remove(struct platform_device *pdev)
|
||||||
drm_vblank_cleanup(drm);
|
drm_vblank_cleanup(drm);
|
||||||
drm_dev_unref(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) {
|
||||||
|
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[] = {
|
static const struct of_device_id dt_match[] = {
|
||||||
{ .compatible = "amlogic,meson-gxbb-vpu" },
|
{ .compatible = "amlogic,meson-gxbb-vpu" },
|
||||||
{ .compatible = "amlogic,meson-gxl-vpu" },
|
{ .compatible = "amlogic,meson-gxl-vpu" },
|
||||||
|
@ -293,7 +379,6 @@ MODULE_DEVICE_TABLE(of, dt_match);
|
||||||
|
|
||||||
static struct platform_driver meson_drm_platform_driver = {
|
static struct platform_driver meson_drm_platform_driver = {
|
||||||
.probe = meson_drv_probe,
|
.probe = meson_drv_probe,
|
||||||
.remove = meson_drv_remove,
|
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "meson-drm",
|
.name = "meson-drm",
|
||||||
.of_match_table = dt_match,
|
.of_match_table = dt_match,
|
||||||
|
|
Loading…
Reference in New Issue