Commit ff139560 authored by CK Hu's avatar CK Hu Committed by Chun-Kuang Hu
Browse files

drm/mediatek: Move mtk_ddp_comp_init() from sub driver to DRM driver



Some ddp component exist in both display path and other path, so
sub driver should not directly call DRM driver's function. Moving
mtk_ddp_comp_init() from sub driver to DRM driver to achieve this.

Signed-off-by: default avatarCK Hu <ck.hu@mediatek.com>
Signed-off-by: default avatarChun-Kuang Hu <chunkuang.hu@kernel.org>
parent 1d33f13a
Loading
Loading
Loading
Loading
+0 −35
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ struct mtk_disp_color_data {
 * @data: platform colour driver data
 */
struct mtk_disp_color {
	struct mtk_ddp_comp			ddp_comp;
	struct drm_crtc				*crtc;
	struct clk				*clk;
	void __iomem				*regs;
@@ -81,27 +80,12 @@ void mtk_color_start(struct device *dev)
static int mtk_disp_color_bind(struct device *dev, struct device *master,
			       void *data)
{
	struct mtk_disp_color *priv = dev_get_drvdata(dev);
	struct drm_device *drm_dev = data;
	int ret;

	ret = mtk_ddp_comp_register(drm_dev, &priv->ddp_comp);
	if (ret < 0) {
		dev_err(dev, "Failed to register component %pOF: %d\n",
			dev->of_node, ret);
		return ret;
	}

	return 0;
}

static void mtk_disp_color_unbind(struct device *dev, struct device *master,
				  void *data)
{
	struct mtk_disp_color *priv = dev_get_drvdata(dev);
	struct drm_device *drm_dev = data;

	mtk_ddp_comp_unregister(drm_dev, &priv->ddp_comp);
}

static const struct component_ops mtk_disp_color_component_ops = {
@@ -114,7 +98,6 @@ static int mtk_disp_color_probe(struct platform_device *pdev)
	struct device *dev = &pdev->dev;
	struct mtk_disp_color *priv;
	struct resource *res;
	int comp_id;
	int ret;

	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -139,23 +122,7 @@ static int mtk_disp_color_probe(struct platform_device *pdev)
		dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
#endif

	comp_id = mtk_ddp_comp_get_id(dev->of_node, MTK_DISP_COLOR);
	if (comp_id < 0) {
		dev_err(dev, "Failed to identify by alias: %d\n", comp_id);
		return comp_id;
	}

	ret = mtk_ddp_comp_init(dev->of_node, &priv->ddp_comp, comp_id);
	if (ret) {
		if (ret != -EPROBE_DEFER)
			dev_err(dev, "Failed to initialize component: %d\n",
				ret);

		return ret;
	}

	priv->data = of_device_get_match_data(dev);

	platform_set_drvdata(pdev, priv);

	ret = component_add(dev, &mtk_disp_color_component_ops);
@@ -167,8 +134,6 @@ static int mtk_disp_color_probe(struct platform_device *pdev)

static int mtk_disp_color_remove(struct platform_device *pdev)
{
	component_del(&pdev->dev, &mtk_disp_color_component_ops);

	return 0;
}

+0 −38
Original line number Diff line number Diff line
@@ -71,7 +71,6 @@ struct mtk_disp_ovl_data {
 * @data: platform data
 */
struct mtk_disp_ovl {
	struct mtk_ddp_comp		ddp_comp;
	struct drm_crtc			*crtc;
	struct clk			*clk;
	void __iomem			*regs;
@@ -342,27 +341,12 @@ void mtk_ovl_bgclr_in_off(struct device *dev)
static int mtk_disp_ovl_bind(struct device *dev, struct device *master,
			     void *data)
{
	struct mtk_disp_ovl *priv = dev_get_drvdata(dev);
	struct drm_device *drm_dev = data;
	int ret;

	ret = mtk_ddp_comp_register(drm_dev, &priv->ddp_comp);
	if (ret < 0) {
		dev_err(dev, "Failed to register component %pOF: %d\n",
			dev->of_node, ret);
		return ret;
	}

	return 0;
}

static void mtk_disp_ovl_unbind(struct device *dev, struct device *master,
				void *data)
{
	struct mtk_disp_ovl *priv = dev_get_drvdata(dev);
	struct drm_device *drm_dev = data;

	mtk_ddp_comp_unregister(drm_dev, &priv->ddp_comp);
}

static const struct component_ops mtk_disp_ovl_component_ops = {
@@ -375,7 +359,6 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
	struct device *dev = &pdev->dev;
	struct mtk_disp_ovl *priv;
	struct resource *res;
	int comp_id;
	int irq;
	int ret;

@@ -406,25 +389,6 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
#endif

	priv->data = of_device_get_match_data(dev);

	comp_id = mtk_ddp_comp_get_id(dev->of_node,
				      priv->data->layer_nr == 4 ?
				      MTK_DISP_OVL :
				      MTK_DISP_OVL_2L);
	if (comp_id < 0) {
		dev_err(dev, "Failed to identify by alias: %d\n", comp_id);
		return comp_id;
	}

	ret = mtk_ddp_comp_init(dev->of_node, &priv->ddp_comp, comp_id);
	if (ret) {
		if (ret != -EPROBE_DEFER)
			dev_err(dev, "Failed to initialize component: %d\n",
				ret);

		return ret;
	}

	platform_set_drvdata(pdev, priv);

	ret = devm_request_irq(dev, irq, mtk_disp_ovl_irq_handler,
@@ -443,8 +407,6 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)

static int mtk_disp_ovl_remove(struct platform_device *pdev)
{
	component_del(&pdev->dev, &mtk_disp_ovl_component_ops);

	return 0;
}

+0 −32
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ struct mtk_disp_rdma_data {
 * @data: local driver data
 */
struct mtk_disp_rdma {
	struct mtk_ddp_comp		ddp_comp;
	struct clk			*clk;
	void __iomem			*regs;
	struct cmdq_client_reg		cmdq_reg;
@@ -250,17 +249,6 @@ void mtk_rdma_layer_config(struct device *dev, unsigned int idx,
static int mtk_disp_rdma_bind(struct device *dev, struct device *master,
			      void *data)
{
	struct mtk_disp_rdma *priv = dev_get_drvdata(dev);
	struct drm_device *drm_dev = data;
	int ret;

	ret = mtk_ddp_comp_register(drm_dev, &priv->ddp_comp);
	if (ret < 0) {
		dev_err(dev, "Failed to register component %pOF: %d\n",
			dev->of_node, ret);
		return ret;
	}

	return 0;

}
@@ -268,10 +256,6 @@ static int mtk_disp_rdma_bind(struct device *dev, struct device *master,
static void mtk_disp_rdma_unbind(struct device *dev, struct device *master,
				 void *data)
{
	struct mtk_disp_rdma *priv = dev_get_drvdata(dev);
	struct drm_device *drm_dev = data;

	mtk_ddp_comp_unregister(drm_dev, &priv->ddp_comp);
}

static const struct component_ops mtk_disp_rdma_component_ops = {
@@ -284,7 +268,6 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev)
	struct device *dev = &pdev->dev;
	struct mtk_disp_rdma *priv;
	struct resource *res;
	int comp_id;
	int irq;
	int ret;

@@ -314,21 +297,6 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev)
		dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
#endif

	comp_id = mtk_ddp_comp_get_id(dev->of_node, MTK_DISP_RDMA);
	if (comp_id < 0) {
		dev_err(dev, "Failed to identify by alias: %d\n", comp_id);
		return comp_id;
	}

	ret = mtk_ddp_comp_init(dev->of_node, &priv->ddp_comp, comp_id);
	if (ret) {
		if (ret != -EPROBE_DEFER)
			dev_err(dev, "Failed to initialize component: %d\n",
				ret);

		return ret;
	}

	/* Disable and clear pending interrupts */
	writel(0x0, priv->regs + DISP_REG_RDMA_INT_ENABLE);
	writel(0x0, priv->regs + DISP_REG_RDMA_INT_STATUS);
+2 −27
Original line number Diff line number Diff line
@@ -63,7 +63,6 @@ enum mtk_dpi_out_color_format {
};

struct mtk_dpi {
	struct mtk_ddp_comp ddp_comp;
	struct drm_encoder encoder;
	struct drm_bridge bridge;
	struct drm_bridge *next_bridge;
@@ -583,21 +582,14 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data)
	struct drm_device *drm_dev = data;
	int ret;

	ret = mtk_ddp_comp_register(drm_dev, &dpi->ddp_comp);
	if (ret < 0) {
		dev_err(dev, "Failed to register component %pOF: %d\n",
			dev->of_node, ret);
		return ret;
	}

	ret = drm_simple_encoder_init(drm_dev, &dpi->encoder,
				      DRM_MODE_ENCODER_TMDS);
	if (ret) {
		dev_err(dev, "Failed to initialize decoder: %d\n", ret);
		goto err_unregister;
		return ret;
	}

	dpi->encoder.possible_crtcs = mtk_drm_find_possible_crtc_by_comp(drm_dev, dpi->ddp_comp);
	dpi->encoder.possible_crtcs = mtk_drm_find_possible_crtc_by_comp(drm_dev, dpi->dev);

	ret = drm_bridge_attach(&dpi->encoder, &dpi->bridge, NULL, 0);
	if (ret) {
@@ -614,8 +606,6 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data)

err_cleanup:
	drm_encoder_cleanup(&dpi->encoder);
err_unregister:
	mtk_ddp_comp_unregister(drm_dev, &dpi->ddp_comp);
	return ret;
}

@@ -623,10 +613,8 @@ static void mtk_dpi_unbind(struct device *dev, struct device *master,
			   void *data)
{
	struct mtk_dpi *dpi = dev_get_drvdata(dev);
	struct drm_device *drm_dev = data;

	drm_encoder_cleanup(&dpi->encoder);
	mtk_ddp_comp_unregister(drm_dev, &dpi->ddp_comp);
}

static const struct component_ops mtk_dpi_component_ops = {
@@ -687,7 +675,6 @@ static int mtk_dpi_probe(struct platform_device *pdev)
	struct device *dev = &pdev->dev;
	struct mtk_dpi *dpi;
	struct resource *mem;
	int comp_id;
	int ret;

	dpi = devm_kzalloc(dev, sizeof(*dpi), GFP_KERNEL);
@@ -765,18 +752,6 @@ static int mtk_dpi_probe(struct platform_device *pdev)

	dev_info(dev, "Found bridge node: %pOF\n", dpi->next_bridge->of_node);

	comp_id = mtk_ddp_comp_get_id(dev->of_node, MTK_DPI);
	if (comp_id < 0) {
		dev_err(dev, "Failed to identify by alias: %d\n", comp_id);
		return comp_id;
	}

	ret = mtk_ddp_comp_init(dev->of_node, &dpi->ddp_comp, comp_id);
	if (ret) {
		dev_err(dev, "Failed to initialize component: %d\n", ret);
		return ret;
	}

	platform_set_drvdata(pdev, dpi);

	dpi->bridge.funcs = &mtk_dpi_bridge_funcs;
+1 −1
Original line number Diff line number Diff line
@@ -786,7 +786,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
		struct device_node *node;

		node = priv->comp_node[comp_id];
		comp = priv->ddp_comp[comp_id];
		comp = &priv->ddp_comp[comp_id];
		if (!comp) {
			dev_err(dev, "Component %pOF not initialized\n", node);
			ret = -ENODEV;
Loading