The reason for this resend is because I forget to add some bridge maintainers. So adding them and collect the actual tags.
The mtk-dpi driver still uses the drm_encoder API which is now somewhat deprecated. We started to move all the Mediatek drivers to the drm_bridge API, like we did for the mtk-dsi driver [1], this is another small step to be able to fully convert the DRM Mediatek drivers to the drm_bridge API. A dummy drm_encoder is maintained in the mtk-dpi driver but the end goal is move all the dummy drm_encoder (mtk-dsi, mtk-dpi, etc) to the main mtk_drm_drv driver.
[1] https://lore.kernel.org/patchwork/project/lkml/list/?series=441559
Enric Balletbo i Serra (3): drm/mediatek: mtk_dpi: Rename bridge to next_bridge drm/mediatek: mtk_dpi: Convert to bridge driver drm/mediatek: mtk_dpi: Use simple encoder
drivers/gpu/drm/mediatek/mtk_dpi.c | 84 ++++++++++++++---------------- 1 file changed, 39 insertions(+), 45 deletions(-)
This is really a cosmetic change just to make a bit more readable the code after convert the driver to drm_bridge. The bridge variable name will be used by the encoder drm_bridge, and the chained bridge will be named next_bridge.
Signed-off-by: Enric Balletbo i Serra enric.balletbo@collabora.com Reviewed-by: Chun-Kuang Hu chunkuang.hu@kernel.org ---
drivers/gpu/drm/mediatek/mtk_dpi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index 7fbfa95bab09..7112125dc3d1 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -61,7 +61,7 @@ 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; void __iomem *regs; struct device *dev; struct clk *engine_clk; @@ -607,7 +607,7 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data) /* Currently DPI0 is fixed to be driven by OVL1 */ dpi->encoder.possible_crtcs = BIT(1);
- ret = drm_bridge_attach(&dpi->encoder, dpi->bridge, NULL, 0); + ret = drm_bridge_attach(&dpi->encoder, dpi->next_bridge, NULL, 0); if (ret) { dev_err(dev, "Failed to attach bridge: %d\n", ret); goto err_cleanup; @@ -747,11 +747,11 @@ static int mtk_dpi_probe(struct platform_device *pdev) }
ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0, - NULL, &dpi->bridge); + NULL, &dpi->next_bridge); if (ret) return ret;
- dev_info(dev, "Found bridge node: %pOF\n", dpi->bridge->of_node); + 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) {
On Mon, 18 May 2020 19:39:07 +0200 Enric Balletbo i Serra enric.balletbo@collabora.com wrote:
This is really a cosmetic change just to make a bit more readable the code after convert the driver to drm_bridge. The bridge variable name will be used by the encoder drm_bridge, and the chained bridge will be named next_bridge.
Signed-off-by: Enric Balletbo i Serra enric.balletbo@collabora.com Reviewed-by: Chun-Kuang Hu chunkuang.hu@kernel.org
drivers/gpu/drm/mediatek/mtk_dpi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index 7fbfa95bab09..7112125dc3d1 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -61,7 +61,7 @@ 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;
Did you consider moving the drm_of_find_panel_or_bridge() call to mtk_dpi_bind() so you can get rid of this field?
This makes we realize there's no refcounting on bridges, which means the bridge can vanish between the drm_of_find_panel_or_bridge() and drm_bridge_attach() calls :-/.
void __iomem *regs; struct device *dev; struct clk *engine_clk; @@ -607,7 +607,7 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data) /* Currently DPI0 is fixed to be driven by OVL1 */ dpi->encoder.possible_crtcs = BIT(1);
- ret = drm_bridge_attach(&dpi->encoder, dpi->bridge, NULL, 0);
- ret = drm_bridge_attach(&dpi->encoder, dpi->next_bridge, NULL, 0); if (ret) { dev_err(dev, "Failed to attach bridge: %d\n", ret); goto err_cleanup;
@@ -747,11 +747,11 @@ static int mtk_dpi_probe(struct platform_device *pdev) }
ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
NULL, &dpi->bridge);
if (ret) return ret;NULL, &dpi->next_bridge);
- dev_info(dev, "Found bridge node: %pOF\n", dpi->bridge->of_node);
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) {
On Wed, 1 Jul 2020 13:23:03 +0200 Boris Brezillon boris.brezillon@collabora.com wrote:
On Mon, 18 May 2020 19:39:07 +0200 Enric Balletbo i Serra enric.balletbo@collabora.com wrote:
This is really a cosmetic change just to make a bit more readable the code after convert the driver to drm_bridge. The bridge variable name will be used by the encoder drm_bridge, and the chained bridge will be named next_bridge.
Signed-off-by: Enric Balletbo i Serra enric.balletbo@collabora.com Reviewed-by: Chun-Kuang Hu chunkuang.hu@kernel.org
drivers/gpu/drm/mediatek/mtk_dpi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index 7fbfa95bab09..7112125dc3d1 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -61,7 +61,7 @@ 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;
Did you consider moving the drm_of_find_panel_or_bridge() call to mtk_dpi_bind() so you can get rid of this field?
Nevermind, you need it in patch 2 for the recursive call to drm_bridge_attach().
This makes we realize there's no refcounting on bridges, which means the bridge can vanish between the drm_of_find_panel_or_bridge() and drm_bridge_attach() calls :-/.
void __iomem *regs; struct device *dev; struct clk *engine_clk; @@ -607,7 +607,7 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data) /* Currently DPI0 is fixed to be driven by OVL1 */ dpi->encoder.possible_crtcs = BIT(1);
- ret = drm_bridge_attach(&dpi->encoder, dpi->bridge, NULL, 0);
- ret = drm_bridge_attach(&dpi->encoder, dpi->next_bridge, NULL, 0); if (ret) { dev_err(dev, "Failed to attach bridge: %d\n", ret); goto err_cleanup;
@@ -747,11 +747,11 @@ static int mtk_dpi_probe(struct platform_device *pdev) }
ret = drm_of_find_panel_or_bridge(dev->of_node, 0, 0,
NULL, &dpi->bridge);
if (ret) return ret;NULL, &dpi->next_bridge);
- dev_info(dev, "Found bridge node: %pOF\n", dpi->bridge->of_node);
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) {
Convert mtk_dpi to a bridge driver with built-in encoder support for compatibility with existing component drivers.
Signed-off-by: Enric Balletbo i Serra enric.balletbo@collabora.com Reviewed-by: Chun-Kuang Hu chunkuang.hu@kernel.org ---
drivers/gpu/drm/mediatek/mtk_dpi.c | 66 +++++++++++++++--------------- 1 file changed, 34 insertions(+), 32 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index 7112125dc3d1..baad198c69eb 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -61,6 +61,7 @@ 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; void __iomem *regs; struct device *dev; @@ -77,9 +78,9 @@ struct mtk_dpi { int refcount; };
-static inline struct mtk_dpi *mtk_dpi_from_encoder(struct drm_encoder *e) +static inline struct mtk_dpi *bridge_to_dpi(struct drm_bridge *b) { - return container_of(e, struct mtk_dpi, encoder); + return container_of(b, struct mtk_dpi, bridge); }
enum mtk_dpi_polarity { @@ -518,50 +519,44 @@ static const struct drm_encoder_funcs mtk_dpi_encoder_funcs = { .destroy = mtk_dpi_encoder_destroy, };
-static bool mtk_dpi_encoder_mode_fixup(struct drm_encoder *encoder, - const struct drm_display_mode *mode, - struct drm_display_mode *adjusted_mode) +static int mtk_dpi_bridge_attach(struct drm_bridge *bridge, + enum drm_bridge_attach_flags flags) { - return true; + struct mtk_dpi *dpi = bridge_to_dpi(bridge); + + return drm_bridge_attach(bridge->encoder, dpi->next_bridge, + &dpi->bridge, flags); }
-static void mtk_dpi_encoder_mode_set(struct drm_encoder *encoder, - struct drm_display_mode *mode, - struct drm_display_mode *adjusted_mode) +static void mtk_dpi_bridge_mode_set(struct drm_bridge *bridge, + const struct drm_display_mode *mode, + const struct drm_display_mode *adjusted_mode) { - struct mtk_dpi *dpi = mtk_dpi_from_encoder(encoder); + struct mtk_dpi *dpi = bridge_to_dpi(bridge);
drm_mode_copy(&dpi->mode, adjusted_mode); }
-static void mtk_dpi_encoder_disable(struct drm_encoder *encoder) +static void mtk_dpi_bridge_disable(struct drm_bridge *bridge) { - struct mtk_dpi *dpi = mtk_dpi_from_encoder(encoder); + struct mtk_dpi *dpi = bridge_to_dpi(bridge);
mtk_dpi_power_off(dpi); }
-static void mtk_dpi_encoder_enable(struct drm_encoder *encoder) +static void mtk_dpi_bridge_enable(struct drm_bridge *bridge) { - struct mtk_dpi *dpi = mtk_dpi_from_encoder(encoder); + struct mtk_dpi *dpi = bridge_to_dpi(bridge);
mtk_dpi_power_on(dpi); mtk_dpi_set_display_mode(dpi, &dpi->mode); }
-static int mtk_dpi_atomic_check(struct drm_encoder *encoder, - struct drm_crtc_state *crtc_state, - struct drm_connector_state *conn_state) -{ - return 0; -} - -static const struct drm_encoder_helper_funcs mtk_dpi_encoder_helper_funcs = { - .mode_fixup = mtk_dpi_encoder_mode_fixup, - .mode_set = mtk_dpi_encoder_mode_set, - .disable = mtk_dpi_encoder_disable, - .enable = mtk_dpi_encoder_enable, - .atomic_check = mtk_dpi_atomic_check, +static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = { + .attach = mtk_dpi_bridge_attach, + .mode_set = mtk_dpi_bridge_mode_set, + .disable = mtk_dpi_bridge_disable, + .enable = mtk_dpi_bridge_enable, };
static void mtk_dpi_start(struct mtk_ddp_comp *comp) @@ -602,16 +597,13 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data) dev_err(dev, "Failed to initialize decoder: %d\n", ret); goto err_unregister; } - drm_encoder_helper_add(&dpi->encoder, &mtk_dpi_encoder_helper_funcs);
/* Currently DPI0 is fixed to be driven by OVL1 */ dpi->encoder.possible_crtcs = BIT(1);
- ret = drm_bridge_attach(&dpi->encoder, dpi->next_bridge, NULL, 0); - if (ret) { - dev_err(dev, "Failed to attach bridge: %d\n", ret); + ret = drm_bridge_attach(&dpi->encoder, &dpi->bridge, NULL, 0); + if (ret) goto err_cleanup; - }
dpi->bit_num = MTK_DPI_OUT_BIT_NUM_8BITS; dpi->channel_swap = MTK_DPI_OUT_CHANNEL_SWAP_RGB; @@ -768,8 +760,15 @@ static int mtk_dpi_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dpi);
+ dpi->bridge.funcs = &mtk_dpi_bridge_funcs; + dpi->bridge.of_node = dev->of_node; + dpi->bridge.type = DRM_MODE_CONNECTOR_DPI; + + drm_bridge_add(&dpi->bridge); + ret = component_add(dev, &mtk_dpi_component_ops); if (ret) { + drm_bridge_remove(&dpi->bridge); dev_err(dev, "Failed to add component: %d\n", ret); return ret; } @@ -779,7 +778,10 @@ static int mtk_dpi_probe(struct platform_device *pdev)
static int mtk_dpi_remove(struct platform_device *pdev) { + struct mtk_dpi *dpi = platform_get_drvdata(pdev); + component_del(&pdev->dev, &mtk_dpi_component_ops); + drm_bridge_remove(&dpi->bridge);
return 0; }
On Mon, 18 May 2020 19:39:08 +0200 Enric Balletbo i Serra enric.balletbo@collabora.com wrote:
Convert mtk_dpi to a bridge driver with built-in encoder support for compatibility with existing component drivers.
Signed-off-by: Enric Balletbo i Serra enric.balletbo@collabora.com Reviewed-by: Chun-Kuang Hu chunkuang.hu@kernel.org
drivers/gpu/drm/mediatek/mtk_dpi.c | 66 +++++++++++++++--------------- 1 file changed, 34 insertions(+), 32 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index 7112125dc3d1..baad198c69eb 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -61,6 +61,7 @@ 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; void __iomem *regs; struct device *dev;
@@ -77,9 +78,9 @@ struct mtk_dpi { int refcount; };
-static inline struct mtk_dpi *mtk_dpi_from_encoder(struct drm_encoder *e) +static inline struct mtk_dpi *bridge_to_dpi(struct drm_bridge *b) {
- return container_of(e, struct mtk_dpi, encoder);
- return container_of(b, struct mtk_dpi, bridge);
}
enum mtk_dpi_polarity { @@ -518,50 +519,44 @@ static const struct drm_encoder_funcs mtk_dpi_encoder_funcs = { .destroy = mtk_dpi_encoder_destroy, };
-static bool mtk_dpi_encoder_mode_fixup(struct drm_encoder *encoder,
const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
+static int mtk_dpi_bridge_attach(struct drm_bridge *bridge,
enum drm_bridge_attach_flags flags)
{
- return true;
- struct mtk_dpi *dpi = bridge_to_dpi(bridge);
- return drm_bridge_attach(bridge->encoder, dpi->next_bridge,
&dpi->bridge, flags);
}
-static void mtk_dpi_encoder_mode_set(struct drm_encoder *encoder,
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
+static void mtk_dpi_bridge_mode_set(struct drm_bridge *bridge,
const struct drm_display_mode *mode,
const struct drm_display_mode *adjusted_mode)
{
- struct mtk_dpi *dpi = mtk_dpi_from_encoder(encoder);
struct mtk_dpi *dpi = bridge_to_dpi(bridge);
drm_mode_copy(&dpi->mode, adjusted_mode);
}
-static void mtk_dpi_encoder_disable(struct drm_encoder *encoder) +static void mtk_dpi_bridge_disable(struct drm_bridge *bridge) {
- struct mtk_dpi *dpi = mtk_dpi_from_encoder(encoder);
struct mtk_dpi *dpi = bridge_to_dpi(bridge);
mtk_dpi_power_off(dpi);
}
-static void mtk_dpi_encoder_enable(struct drm_encoder *encoder) +static void mtk_dpi_bridge_enable(struct drm_bridge *bridge) {
- struct mtk_dpi *dpi = mtk_dpi_from_encoder(encoder);
struct mtk_dpi *dpi = bridge_to_dpi(bridge);
mtk_dpi_power_on(dpi); mtk_dpi_set_display_mode(dpi, &dpi->mode);
}
-static int mtk_dpi_atomic_check(struct drm_encoder *encoder,
struct drm_crtc_state *crtc_state,
struct drm_connector_state *conn_state)
-{
- return 0;
-}
-static const struct drm_encoder_helper_funcs mtk_dpi_encoder_helper_funcs = {
- .mode_fixup = mtk_dpi_encoder_mode_fixup,
- .mode_set = mtk_dpi_encoder_mode_set,
- .disable = mtk_dpi_encoder_disable,
- .enable = mtk_dpi_encoder_enable,
- .atomic_check = mtk_dpi_atomic_check,
+static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = {
- .attach = mtk_dpi_bridge_attach,
- .mode_set = mtk_dpi_bridge_mode_set,
- .disable = mtk_dpi_bridge_disable,
- .enable = mtk_dpi_bridge_enable,
};
static void mtk_dpi_start(struct mtk_ddp_comp *comp) @@ -602,16 +597,13 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data) dev_err(dev, "Failed to initialize decoder: %d\n", ret); goto err_unregister; }
drm_encoder_helper_add(&dpi->encoder, &mtk_dpi_encoder_helper_funcs);
/* Currently DPI0 is fixed to be driven by OVL1 */ dpi->encoder.possible_crtcs = BIT(1);
ret = drm_bridge_attach(&dpi->encoder, dpi->next_bridge, NULL, 0);
if (ret) {
dev_err(dev, "Failed to attach bridge: %d\n", ret);
Any reason your decided to drop this error message? If there's one, this should probably happen in a separate patch.
- ret = drm_bridge_attach(&dpi->encoder, &dpi->bridge, NULL, 0);
- if (ret) goto err_cleanup;
}
dpi->bit_num = MTK_DPI_OUT_BIT_NUM_8BITS; dpi->channel_swap = MTK_DPI_OUT_CHANNEL_SWAP_RGB;
@@ -768,8 +760,15 @@ static int mtk_dpi_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dpi);
- dpi->bridge.funcs = &mtk_dpi_bridge_funcs;
- dpi->bridge.of_node = dev->of_node;
- dpi->bridge.type = DRM_MODE_CONNECTOR_DPI;
- drm_bridge_add(&dpi->bridge);
I wonder if it's really useful to add the bridge when it's private (you don't want this bridge to be added to external bridge chains).
- ret = component_add(dev, &mtk_dpi_component_ops); if (ret) {
dev_err(dev, "Failed to add component: %d\n", ret); return ret; }drm_bridge_remove(&dpi->bridge);
@@ -779,7 +778,10 @@ static int mtk_dpi_probe(struct platform_device *pdev)
static int mtk_dpi_remove(struct platform_device *pdev) {
struct mtk_dpi *dpi = platform_get_drvdata(pdev);
component_del(&pdev->dev, &mtk_dpi_component_ops);
drm_bridge_remove(&dpi->bridge);
return 0;
}
Hi Boris,
Thank you for review the patch.
On 1/7/20 13:51, Boris Brezillon wrote:
On Mon, 18 May 2020 19:39:08 +0200 Enric Balletbo i Serra enric.balletbo@collabora.com wrote:
Convert mtk_dpi to a bridge driver with built-in encoder support for compatibility with existing component drivers.
Signed-off-by: Enric Balletbo i Serra enric.balletbo@collabora.com Reviewed-by: Chun-Kuang Hu chunkuang.hu@kernel.org
drivers/gpu/drm/mediatek/mtk_dpi.c | 66 +++++++++++++++--------------- 1 file changed, 34 insertions(+), 32 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index 7112125dc3d1..baad198c69eb 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -61,6 +61,7 @@ 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; void __iomem *regs; struct device *dev;
@@ -77,9 +78,9 @@ struct mtk_dpi { int refcount; };
-static inline struct mtk_dpi *mtk_dpi_from_encoder(struct drm_encoder *e) +static inline struct mtk_dpi *bridge_to_dpi(struct drm_bridge *b) {
- return container_of(e, struct mtk_dpi, encoder);
- return container_of(b, struct mtk_dpi, bridge);
}
enum mtk_dpi_polarity { @@ -518,50 +519,44 @@ static const struct drm_encoder_funcs mtk_dpi_encoder_funcs = { .destroy = mtk_dpi_encoder_destroy, };
-static bool mtk_dpi_encoder_mode_fixup(struct drm_encoder *encoder,
const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
+static int mtk_dpi_bridge_attach(struct drm_bridge *bridge,
enum drm_bridge_attach_flags flags)
{
- return true;
- struct mtk_dpi *dpi = bridge_to_dpi(bridge);
- return drm_bridge_attach(bridge->encoder, dpi->next_bridge,
&dpi->bridge, flags);
}
-static void mtk_dpi_encoder_mode_set(struct drm_encoder *encoder,
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
+static void mtk_dpi_bridge_mode_set(struct drm_bridge *bridge,
const struct drm_display_mode *mode,
const struct drm_display_mode *adjusted_mode)
{
- struct mtk_dpi *dpi = mtk_dpi_from_encoder(encoder);
struct mtk_dpi *dpi = bridge_to_dpi(bridge);
drm_mode_copy(&dpi->mode, adjusted_mode);
}
-static void mtk_dpi_encoder_disable(struct drm_encoder *encoder) +static void mtk_dpi_bridge_disable(struct drm_bridge *bridge) {
- struct mtk_dpi *dpi = mtk_dpi_from_encoder(encoder);
struct mtk_dpi *dpi = bridge_to_dpi(bridge);
mtk_dpi_power_off(dpi);
}
-static void mtk_dpi_encoder_enable(struct drm_encoder *encoder) +static void mtk_dpi_bridge_enable(struct drm_bridge *bridge) {
- struct mtk_dpi *dpi = mtk_dpi_from_encoder(encoder);
struct mtk_dpi *dpi = bridge_to_dpi(bridge);
mtk_dpi_power_on(dpi); mtk_dpi_set_display_mode(dpi, &dpi->mode);
}
-static int mtk_dpi_atomic_check(struct drm_encoder *encoder,
struct drm_crtc_state *crtc_state,
struct drm_connector_state *conn_state)
-{
- return 0;
-}
-static const struct drm_encoder_helper_funcs mtk_dpi_encoder_helper_funcs = {
- .mode_fixup = mtk_dpi_encoder_mode_fixup,
- .mode_set = mtk_dpi_encoder_mode_set,
- .disable = mtk_dpi_encoder_disable,
- .enable = mtk_dpi_encoder_enable,
- .atomic_check = mtk_dpi_atomic_check,
+static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = {
- .attach = mtk_dpi_bridge_attach,
- .mode_set = mtk_dpi_bridge_mode_set,
- .disable = mtk_dpi_bridge_disable,
- .enable = mtk_dpi_bridge_enable,
};
static void mtk_dpi_start(struct mtk_ddp_comp *comp) @@ -602,16 +597,13 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data) dev_err(dev, "Failed to initialize decoder: %d\n", ret); goto err_unregister; }
drm_encoder_helper_add(&dpi->encoder, &mtk_dpi_encoder_helper_funcs);
/* Currently DPI0 is fixed to be driven by OVL1 */ dpi->encoder.possible_crtcs = BIT(1);
ret = drm_bridge_attach(&dpi->encoder, dpi->next_bridge, NULL, 0);
if (ret) {
dev_err(dev, "Failed to attach bridge: %d\n", ret);
Any reason your decided to drop this error message? If there's one, this should probably happen in a separate patch.
Right, I'll maintain the error in next version.
- ret = drm_bridge_attach(&dpi->encoder, &dpi->bridge, NULL, 0);
- if (ret) goto err_cleanup;
}
dpi->bit_num = MTK_DPI_OUT_BIT_NUM_8BITS; dpi->channel_swap = MTK_DPI_OUT_CHANNEL_SWAP_RGB;
@@ -768,8 +760,15 @@ static int mtk_dpi_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dpi);
- dpi->bridge.funcs = &mtk_dpi_bridge_funcs;
- dpi->bridge.of_node = dev->of_node;
- dpi->bridge.type = DRM_MODE_CONNECTOR_DPI;
- drm_bridge_add(&dpi->bridge);
I wonder if it's really useful to add the bridge when it's private (you don't want this bridge to be added to external bridge chains).
- ret = component_add(dev, &mtk_dpi_component_ops); if (ret) {
dev_err(dev, "Failed to add component: %d\n", ret); return ret; }drm_bridge_remove(&dpi->bridge);
@@ -779,7 +778,10 @@ static int mtk_dpi_probe(struct platform_device *pdev)
static int mtk_dpi_remove(struct platform_device *pdev) {
struct mtk_dpi *dpi = platform_get_drvdata(pdev);
component_del(&pdev->dev, &mtk_dpi_component_ops);
drm_bridge_remove(&dpi->bridge);
return 0;
}
The mtk_dpi driver uses an empty implementation for its encoder. Replace the code with the generic simple encoder.
Signed-off-by: Enric Balletbo i Serra enric.balletbo@collabora.com Reviewed-by: Chun-Kuang Hu chunkuang.hu@kernel.org ---
drivers/gpu/drm/mediatek/mtk_dpi.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index baad198c69eb..80778b2aac2a 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -20,6 +20,7 @@ #include <drm/drm_bridge.h> #include <drm/drm_crtc.h> #include <drm/drm_of.h> +#include <drm/drm_simple_kms_helper.h>
#include "mtk_dpi_regs.h" #include "mtk_drm_ddp_comp.h" @@ -510,15 +511,6 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, return 0; }
-static void mtk_dpi_encoder_destroy(struct drm_encoder *encoder) -{ - drm_encoder_cleanup(encoder); -} - -static const struct drm_encoder_funcs mtk_dpi_encoder_funcs = { - .destroy = mtk_dpi_encoder_destroy, -}; - static int mtk_dpi_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { @@ -591,8 +583,8 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data) return ret; }
- ret = drm_encoder_init(drm_dev, &dpi->encoder, &mtk_dpi_encoder_funcs, - DRM_MODE_ENCODER_TMDS, NULL); + 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;
On Mon, 18 May 2020 19:39:09 +0200 Enric Balletbo i Serra enric.balletbo@collabora.com wrote:
The mtk_dpi driver uses an empty implementation for its encoder. Replace the code with the generic simple encoder.
Signed-off-by: Enric Balletbo i Serra enric.balletbo@collabora.com Reviewed-by: Chun-Kuang Hu chunkuang.hu@kernel.org
drivers/gpu/drm/mediatek/mtk_dpi.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index baad198c69eb..80778b2aac2a 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -20,6 +20,7 @@ #include <drm/drm_bridge.h> #include <drm/drm_crtc.h> #include <drm/drm_of.h> +#include <drm/drm_simple_kms_helper.h>
#include "mtk_dpi_regs.h" #include "mtk_drm_ddp_comp.h" @@ -510,15 +511,6 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, return 0; }
-static void mtk_dpi_encoder_destroy(struct drm_encoder *encoder) -{
- drm_encoder_cleanup(encoder);
-}
-static const struct drm_encoder_funcs mtk_dpi_encoder_funcs = {
- .destroy = mtk_dpi_encoder_destroy,
-};
static int mtk_dpi_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { @@ -591,8 +583,8 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data) return ret; }
- ret = drm_encoder_init(drm_dev, &dpi->encoder, &mtk_dpi_encoder_funcs,
DRM_MODE_ENCODER_TMDS, NULL);
- ret = drm_simple_encoder_init(drm_dev, &dpi->encoder,
DRM_MODE_ENCODER_TMDS);
Not related to this change, but shouldn't we have DRM_MODE_ENCODER_DPI here?
if (ret) { dev_err(dev, "Failed to initialize decoder: %d\n", ret); goto err_unregister;
Hi Boris,
Thank you to spend some time to review the patches.
On 1/7/20 13:41, Boris Brezillon wrote:
On Mon, 18 May 2020 19:39:09 +0200 Enric Balletbo i Serra enric.balletbo@collabora.com wrote:
The mtk_dpi driver uses an empty implementation for its encoder. Replace the code with the generic simple encoder.
Signed-off-by: Enric Balletbo i Serra enric.balletbo@collabora.com Reviewed-by: Chun-Kuang Hu chunkuang.hu@kernel.org
drivers/gpu/drm/mediatek/mtk_dpi.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index baad198c69eb..80778b2aac2a 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -20,6 +20,7 @@ #include <drm/drm_bridge.h> #include <drm/drm_crtc.h> #include <drm/drm_of.h> +#include <drm/drm_simple_kms_helper.h>
#include "mtk_dpi_regs.h" #include "mtk_drm_ddp_comp.h" @@ -510,15 +511,6 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, return 0; }
-static void mtk_dpi_encoder_destroy(struct drm_encoder *encoder) -{
- drm_encoder_cleanup(encoder);
-}
-static const struct drm_encoder_funcs mtk_dpi_encoder_funcs = {
- .destroy = mtk_dpi_encoder_destroy,
-};
static int mtk_dpi_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { @@ -591,8 +583,8 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data) return ret; }
- ret = drm_encoder_init(drm_dev, &dpi->encoder, &mtk_dpi_encoder_funcs,
DRM_MODE_ENCODER_TMDS, NULL);
- ret = drm_simple_encoder_init(drm_dev, &dpi->encoder,
DRM_MODE_ENCODER_TMDS);
Not related to this change, but shouldn't we have DRM_MODE_ENCODER_DPI here?
Right, I'll add a patch to fix this.
if (ret) { dev_err(dev, "Failed to initialize decoder: %d\n", ret); goto err_unregister;
Hi again,
On 8/7/20 17:12, Enric Balletbo i Serra wrote:
Hi Boris,
Thank you to spend some time to review the patches.
On 1/7/20 13:41, Boris Brezillon wrote:
On Mon, 18 May 2020 19:39:09 +0200 Enric Balletbo i Serra enric.balletbo@collabora.com wrote:
The mtk_dpi driver uses an empty implementation for its encoder. Replace the code with the generic simple encoder.
Signed-off-by: Enric Balletbo i Serra enric.balletbo@collabora.com Reviewed-by: Chun-Kuang Hu chunkuang.hu@kernel.org
drivers/gpu/drm/mediatek/mtk_dpi.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index baad198c69eb..80778b2aac2a 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -20,6 +20,7 @@ #include <drm/drm_bridge.h> #include <drm/drm_crtc.h> #include <drm/drm_of.h> +#include <drm/drm_simple_kms_helper.h>
#include "mtk_dpi_regs.h" #include "mtk_drm_ddp_comp.h" @@ -510,15 +511,6 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi, return 0; }
-static void mtk_dpi_encoder_destroy(struct drm_encoder *encoder) -{
- drm_encoder_cleanup(encoder);
-}
-static const struct drm_encoder_funcs mtk_dpi_encoder_funcs = {
- .destroy = mtk_dpi_encoder_destroy,
-};
static int mtk_dpi_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { @@ -591,8 +583,8 @@ static int mtk_dpi_bind(struct device *dev, struct device *master, void *data) return ret; }
- ret = drm_encoder_init(drm_dev, &dpi->encoder, &mtk_dpi_encoder_funcs,
DRM_MODE_ENCODER_TMDS, NULL);
- ret = drm_simple_encoder_init(drm_dev, &dpi->encoder,
DRM_MODE_ENCODER_TMDS);
Not related to this change, but shouldn't we have DRM_MODE_ENCODER_DPI here?
Thinking a bit more about this and this patchset in general, I think I'll drop this patch from the series, at the end, all the encoder creation stuff should be moved to mtk_drm_drv.
Right, I'll add a patch to fix this.
if (ret) { dev_err(dev, "Failed to initialize decoder: %d\n", ret); goto err_unregister;
Hi,
On 18/5/20 19:39, Enric Balletbo i Serra wrote:
The reason for this resend is because I forget to add some bridge maintainers. So adding them and collect the actual tags.
The mtk-dpi driver still uses the drm_encoder API which is now somewhat deprecated. We started to move all the Mediatek drivers to the drm_bridge API, like we did for the mtk-dsi driver [1], this is another small step to be able to fully convert the DRM Mediatek drivers to the drm_bridge API. A dummy drm_encoder is maintained in the mtk-dpi driver but the end goal is move all the dummy drm_encoder (mtk-dsi, mtk-dpi, etc) to the main mtk_drm_drv driver.
[1] https://lore.kernel.org/patchwork/project/lkml/list/?series=441559
Enric Balletbo i Serra (3): drm/mediatek: mtk_dpi: Rename bridge to next_bridge drm/mediatek: mtk_dpi: Convert to bridge driver drm/mediatek: mtk_dpi: Use simple encoder
drivers/gpu/drm/mediatek/mtk_dpi.c | 84 ++++++++++++++----------------
A gentle ping, I think this patchset still is missing a reviewed tag from bridge maintainers if is fine.
Thanks, Enric
1 file changed, 39 insertions(+), 45 deletions(-)
dri-devel@lists.freedesktop.org