Apply bridge-connector for the Rockchip DW-HDMI driver
Subsystems (8)
cover Apply bridge-connector for the Rockchip DW-HDMI driver
This patch series depends on and must be applied after:
https://lore.kernel.org/all/[email protected]/
(Series [v3,00/11] drm/mxsfb/lcdif: use DRM_BRIDGE_ATTACH_NO_CONNECTOR and the bridge-connector)
Patch 1: Make DRM_BRIDGE_ATTACH_NO_CONNECTOR optional for platforms that call
dw_hdmi_bind() to attach the dw-hdmi bridge.
Patch 2: Allow &dw_hdmi_plat_data.output_port = 0 without the attach flag
DRM_BRIDGE_ATTACH_NO_CONNECTOR for dw-hdmi bridge.
Patch 3: Apply bridge-connector for Rockchip dw-hdmi driver, so that connector
management is unified under bridge-connector. Treat dw-hdmi purely as a bridge without using its own connector helper functions, which partially overlaps with the bridge helper.
Patch 4: Add next bridge support for Rockchip dw-hdmi driver, so that it can
support both the HDMI connector and additional bridge chips.
Damon Ding (4):
drm/bridge: dw-hdmi: Pass bridge attach flags for dw_hdmi_bind() drm/bridge: dw-hdmi: Allow &dw_hdmi_plat_data.output_port = 0 without
DRM_BRIDGE_ATTACH_NO_CONNECTOR
drm/rockchip: dw_hdmi: Apply DRM_BRIDGE_ATTACH_NO_CONNECTOR and the
bridge-connector
drm/rockchip: dw_hdmi: Support to find the next bridge
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 10 +++---- drivers/gpu/drm/rockchip/Kconfig | 1 + drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 33 ++++++++++++++++++--- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 2 +- include/drm/bridge/dw_hdmi.h | 4 ++- 5 files changed, 39 insertions(+), 11 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/4 drm/bridge: dw-hdmi: Pass bridge attach flags for dw_hdmi_bind()
For Rockchip and Allwinner platforms, the HDMI encoder attaches the dw-hdmi bridge via dw_hdmi_bind(). This additional bridge attach flag serves as preparation for the Rockchip dw-hdmi driver to support the bridge-connector framework.
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 5 +++-- drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 2 +- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 2 +- include/drm/bridge/dw_hdmi.h | 4 +++- 4 files changed, 8 insertions(+), 5 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +3 -2
@@ -3619,7 +3619,8 @@ EXPORT_SYMBOL_GPL(dw_hdmi_remove);*/ struct dw_hdmi *dw_hdmi_bind (struct platform_device *pdev,struct drm_encoder *encoder, -const struct dw_hdmi_plat_data *plat_data) +const struct dw_hdmi_plat_data *plat_data, +enum drm_bridge_attach_flags flags) {struct dw_hdmi *hdmi;int ret;
@@ -3628,7 +3629,7 @@ struct dw_hdmi *dw_hdmi_bind(struct platform_device *pdev,if (IS_ERR (hdmi))return hdmi; - ret =drm_bridge_attach (encoder, &hdmi->bridge,NULL ,0 ); + ret =drm_bridge_attach (encoder, &hdmi->bridge,NULL , flags);if (ret) {dw_hdmi_remove (hdmi);return ERR_PTR (ret);
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +1 -1
@@ -608,7 +608,7 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,platform_set_drvdata (pdev, hdmi); - hdmi->hdmi =dw_hdmi_bind (pdev, encoder, plat_data); + hdmi->hdmi =dw_hdmi_bind (pdev, encoder, plat_data,0 );/* * If dw_hdmi_bind() fails we'll never call dw_hdmi_unbind(),
drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +1 -1
@@ -188,7 +188,7 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,platform_set_drvdata (pdev, hdmi); - hdmi->hdmi =dw_hdmi_bind (pdev, encoder, plat_data); + hdmi->hdmi =dw_hdmi_bind (pdev, encoder, plat_data,0 );/* * If dw_hdmi_bind() fails we'll never call dw_hdmi_unbind(),
include/drm/bridge/dw_hdmi.h +3 -1
@@ -6,6 +6,7 @@#ifndef __DW_HDMI__#define __DW_HDMI__ +#include <drm/drm_bridge.h> #include <sound/hdmi-codec.h> struct drm_display_info ;
@@ -182,7 +183,8 @@ void dw_hdmi_remove(struct dw_hdmi *hdmi);void dw_hdmi_unbind (struct dw_hdmi *hdmi);struct dw_hdmi *dw_hdmi_bind (struct platform_device *pdev,struct drm_encoder *encoder, -const struct dw_hdmi_plat_data *plat_data); +const struct dw_hdmi_plat_data *plat_data, +enum drm_bridge_attach_flags flags);void dw_hdmi_resume (struct dw_hdmi *hdmi);
Signature · 1 line
2.34.1
Jonas Karlman
reviewerRe: [PATCH v1 1/4] drm/bridge: dw-hdmi: Pass bridge attach flags for dw_hdmi_bind()
Hi Damon,
Quoted 4 lines · Damon Ding
For Rockchip and Allwinner platforms, the HDMI encoder attaches the dw-hdmi bridge via
dw_hdmi_bind(). This additional bridge attach flag serves as preparation for the Rockchip dw-hdmi driver to support the bridge-connector framework.
We should not extend the dw_hdmi_bind() function with a new flag.
Each driver can instead call dw_hdmi_probe() and drm_bridge_attach() on their own, similar as the other dw-hdmi drivers that currently use the bridge connector.
Regards,
Jonas
Quoted 80 lines
Signed-off-by Damon Ding <[email protected]>--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 5 +++-- drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 2 +- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 2 +- include/drm/bridge/dw_hdmi.h | 4 +++- 4 files changed, 8 insertions(+), 5 deletions(-)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +3
-2@@ -3619,7 +3619,8 @@ EXPORT_SYMBOL_GPL(dw_hdmi_remove);*/ struct dw_hdmi *dw_hdmi_bind (struct platform_device *pdev,struct drm_encoder *encoder, -const struct dw_hdmi_plat_data *plat_data) +const struct dw_hdmi_plat_data *plat_data, +enum drm_bridge_attach_flags flags) {struct dw_hdmi *hdmi;int ret;@@ -3628,7 +3629,7 @@ struct dw_hdmi *dw_hdmi_bind(struct platform_device *pdev,if (IS_ERR (hdmi))return hdmi; - ret =drm_bridge_attach (encoder, &hdmi->bridge,NULL ,0 ); + ret =drm_bridge_attach (encoder, &hdmi->bridge,NULL , flags);if (ret) {dw_hdmi_remove (hdmi);return ERR_PTR (ret);drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +1
-1@@ -608,7 +608,7 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,platform_set_drvdata (pdev, hdmi); - hdmi->hdmi =dw_hdmi_bind (pdev, encoder, plat_data); + hdmi->hdmi =dw_hdmi_bind (pdev, encoder, plat_data,0 );/* * If dw_hdmi_bind() fails we'll never call dw_hdmi_unbind(), drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +1
-1@@ -188,7 +188,7 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,platform_set_drvdata (pdev, hdmi); - hdmi->hdmi =dw_hdmi_bind (pdev, encoder, plat_data); + hdmi->hdmi =dw_hdmi_bind (pdev, encoder, plat_data,0 );/* * If dw_hdmi_bind() fails we'll never call dw_hdmi_unbind(), include/drm/bridge/dw_hdmi.h +3
-1@@ -6,6 +6,7 @@#ifndef __DW_HDMI__#define __DW_HDMI__ +#include <drm/drm_bridge.h> #include <sound/hdmi-codec.h> struct drm_display_info ;@@ -182,7 +183,8 @@ void dw_hdmi_remove(struct dw_hdmi *hdmi);void dw_hdmi_unbind (struct dw_hdmi *hdmi);struct dw_hdmi *dw_hdmi_bind (struct platform_device *pdev,struct drm_encoder *encoder, -const struct dw_hdmi_plat_data *plat_data); +const struct dw_hdmi_plat_data *plat_data, +enum drm_bridge_attach_flags flags);void dw_hdmi_resume (struct dw_hdmi *hdmi);
PATCH 2/4 drm/bridge: dw-hdmi: Allow &dw_hdmi_plat_data.output_port = 0 without DRM_BRIDGE_ATTACH_NO_CONNECTOR
In reply to Damon DingIn the previous commit, Luca split the dw-hdmi attach process into two cases:
A. hdmi->plat_data->output_port = 0:
the HDMI output (port@1) in device tree is not used
B. hdmi->plat_data->output_port = 1:
the HDMI output (port@1) is parsed to find the next bridge
For Rockchip, many older platforms (RK3288, RK3399, etc.) only support case A by default. They can support DRM_BRIDGE_ATTACH_NO_CONNECTOR flag after adapting to the bridge connector helper. Relax this constraint in preparation for Rockchip dw-hdmi bridge-connector adaptation.
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2 -3
@@ -2912,9 +2912,8 @@ static int dw_hdmi_bridge_attach(struct drm_bridge *bridge, {struct dw_hdmi *hdmi = bridge->driver_private; -/* DRM_BRIDGE_ATTACH_NO_CONNECTOR requires a remote-endpoint to the next bridge */ -if (WARN_ON ((flags &DRM_BRIDGE_ATTACH_NO_CONNECTOR ) && !hdmi->plat_data->output_port)) -return -EINVAL ; +if ((flags &DRM_BRIDGE_ATTACH_NO_CONNECTOR ) && !hdmi->plat_data->output_port) +return 0 ;if (flags &DRM_BRIDGE_ATTACH_NO_CONNECTOR ) { struct device_node *remote __free(device_node) =
Signature · 1 line
2.34.1
Luca Ceresoli
reviewerRe: [PATCH v1 2/4] drm/bridge: dw-hdmi: Allow &dw_hdmi_plat_data.output_port = 0 without DRM_BRIDGE_ATTACH_NO_CONNECTOR
Hello Damon,
Quoted 26 lines · Damon Ding
In the previous commit, Luca split the dw-hdmi attach process into two cases:
A.
hdmi->plat_data->output_port= 0:
the HDMI output (port@1) in device tree is not usedB.
hdmi->plat_data->output_port= 1:
the HDMI output (port@1) is parsed to find the next bridgeFor Rockchip, many older platforms (RK3288, RK3399, etc.) only support case A by default. They can support
DRM_BRIDGE_ATTACH_NO_CONNECTORflag after adapting to the bridge connector helper. Relax this constraint in preparation for Rockchip dw-hdmi bridge-connector adaptation.Signed-off-by Damon Ding <[email protected]>--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0
-0@@ -2912,9 +2912,8 @@ static int dw_hdmi_bridge_attach(struct drm_bridge *bridge, {
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static int dw_hdmi_bridge_attach(struct drm_bridge *bridge, · line 2919
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2
-3struct dw_hdmi *hdmi = bridge->driver_private; -/* DRM_BRIDGE_ATTACH_NO_CONNECTOR requires a remote-endpoint to the next bridge */ -if (WARN_ON ((flags &DRM_BRIDGE_ATTACH_NO_CONNECTOR ) && !hdmi->plat_data->output_port)) -return -EINVAL ; +if ((flags &DRM_BRIDGE_ATTACH_NO_CONNECTOR ) && !hdmi->plat_data->output_port) +return 0 ;if (flags &DRM_BRIDGE_ATTACH_NO_CONNECTOR ) { struct device_node *remote __free(device_node) =
My understanding is that a hdmi-connector node is required in DT when using drm_bridge_connector and DRM_BRIDGE_ATTACH_NO_CONNECTOR. Among others, it is necessary to expose the correct connector type instead of defaulting to DRM_MODE_CONNECTOR_HDMIA.
@Dmitry, others, can you confirm or deny the above?
If I'm correct, then the right way to support DRM_BRIDGE_ATTACH_NO_CONNECTOR here is adding an hdmi-connector node in DT, perhaps reusing the device tree overlay I proposed in [0].
[0] https://lore.kernel.org/lkml/[email protected]/
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
PATCH 3/4 drm/rockchip: dw_hdmi: Apply DRM_BRIDGE_ATTACH_NO_CONNECTOR and the bridge-connector
In reply to Damon DingConvert this driver to DRM_BRIDGE_ATTACH_NO_CONNECTOR and to the drm_bridge_connector framework which is the current DRM bridge best practice.
--- drivers/gpu/drm/rockchip/Kconfig | 1 + drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)
drivers/gpu/drm/rockchip/Kconfig +1 -0
@@ -76,6 +76,7 @@ config ROCKCHIP_DW_DP config ROCKCHIP_DW_HDMI bool "Rockchip specific extensions for Synopsys DW HDMI" + select DRM_BRIDGE_CONNECTOR help This selects support for Rockchip SoC specific extensions for the Synopsys DesignWare HDMI driver. If you want to
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +15 -4
@@ -13,6 +13,7 @@#include <linux/regulator/consumer.h> #include <drm/bridge/dw_hdmi.h> +#include <drm/drm_bridge_connector.h> #include <drm/drm_edid.h> #include <drm/drm_of.h> #include <drm/drm_probe_helper.h>
@@ -542,6 +543,7 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,struct drm_device *drm = data;struct drm_encoder *encoder;struct rockchip_hdmi *hdmi; +struct drm_connector *connector;int ret;if (!pdev->dev.of_node)
@@ -608,7 +610,7 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,platform_set_drvdata (pdev, hdmi); - hdmi->hdmi =dw_hdmi_bind (pdev, encoder, plat_data,0 ); + hdmi->hdmi =dw_hdmi_bind (pdev, encoder, plat_data,DRM_BRIDGE_ATTACH_NO_CONNECTOR );/* * If dw_hdmi_bind() fails we'll never call dw_hdmi_unbind(),
@@ -616,12 +618,21 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,*/ if (IS_ERR (hdmi->hdmi)) { ret =PTR_ERR (hdmi->hdmi); - goto err_bind; + goto err_cleanup_encoder; } -return 0 ; + connector =drm_bridge_connector_init (drm, encoder); +if (IS_ERR (connector)) { + ret =PTR_ERR (connector); +dev_err (hdmi->dev,"Failed to initialize bridge_connector\n" ); + goto err_unbind_bridge; + } -err_bind: +return drm_connector_attach_encoder (connector, encoder); + +err_unbind_bridge: +dw_hdmi_unbind (hdmi->hdmi); +err_cleanup_encoder:drm_encoder_cleanup (encoder);return ret;
Signature · 1 line
2.34.1
Jonas Karlman
reviewerRe: [PATCH v1 3/4] drm/rockchip: dw_hdmi: Apply DRM_BRIDGE_ATTACH_NO_CONNECTOR and the bridge-connector
Hi Damon,
Quoted 3 lines · Damon Ding
Convert this driver to
DRM_BRIDGE_ATTACH_NO_CONNECTORand to thedrm_bridge_connectorframework which is the current DRM bridge best practice.
Changing to use the bridge connector at this stage will cause the Rockchip platform to drop features the dw-hdmi connector currently only can provide, e.g. a CEC notifier, some connector properties and more.
I am also currently working on a multi series effort to:
- phy: rockchip: inno-hdmi: Change TMDS rate handling to configure() ops [v2]
- drm/rockchip: dw_hdmi: Misc cleanup and propagate bus format [v1]
- drm: bridge: dw_hdmi: Misc enable/disable, CEC and EDID cleanup [v5]
- drm/bridge: dw-hdmi: Improve input/output bus format handling
- drm/bridge: dw-hdmi: Convert to a HDMI bridge and use of bridge connector
- drm/bridge: dw-hdmi: Add and use tmds_char_rate_valid() plat data ops
- drm/meson: hdmi: Misc cleanup and use CEC notifier helpers
- drm/rockchip: dw_hdmi: Enable YCbCr and Deep Color modes
Link to snapshot: https://github.com/Kwiboo/linux-rockchip/commits/next-20260508-rk-hdmi-v3/
Part of that effort include to fully convert the dw-hdmi bridge into a HDMI bridge, something that is required to fully be able to replace all features currently provided by the use of the dw-hdmi connector.
In that effort I have also taken a different approach and instead replace the dw-hdmi connector with the bridge connector directly from inside the dw-hdmi bridge driver.
Regards,
Jonas
Quoted 72 lines
Signed-off-by Damon Ding <[email protected]>--- drivers/gpu/drm/rockchip/Kconfig | 1 + drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)drivers/gpu/drm/rockchip/Kconfig +1
-0@@ -76,6 +76,7 @@ config ROCKCHIP_DW_DP config ROCKCHIP_DW_HDMI bool "Rockchip specific extensions for Synopsys DW HDMI" + select DRM_BRIDGE_CONNECTOR help This selects support for Rockchip SoC specific extensions for the Synopsys DesignWare HDMI driver. If you want todrivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +15
-4@@ -13,6 +13,7 @@#include <linux/regulator/consumer.h> #include <drm/bridge/dw_hdmi.h> +#include <drm/drm_bridge_connector.h> #include <drm/drm_edid.h> #include <drm/drm_of.h> #include <drm/drm_probe_helper.h> @@ -542,6 +543,7 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,struct drm_device *drm = data;struct drm_encoder *encoder;struct rockchip_hdmi *hdmi; +struct drm_connector *connector;int ret;if (!pdev->dev.of_node)@@ -608,7 +610,7 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,platform_set_drvdata (pdev, hdmi); - hdmi->hdmi =dw_hdmi_bind (pdev, encoder, plat_data,0 ); + hdmi->hdmi =dw_hdmi_bind (pdev, encoder, plat_data,DRM_BRIDGE_ATTACH_NO_CONNECTOR );/* * If dw_hdmi_bind() fails we'll never call dw_hdmi_unbind(), @@ -616,12 +618,21 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,*/ if (IS_ERR (hdmi->hdmi)) { ret =PTR_ERR (hdmi->hdmi); - goto err_bind; + goto err_cleanup_encoder; } -return 0 ; + connector =drm_bridge_connector_init (drm, encoder); +if (IS_ERR (connector)) { + ret =PTR_ERR (connector); +dev_err (hdmi->dev,"Failed to initialize bridge_connector\n" ); + goto err_unbind_bridge; + } -err_bind: +return drm_connector_attach_encoder (connector, encoder); + +err_unbind_bridge: +dw_hdmi_unbind (hdmi->hdmi); +err_cleanup_encoder:drm_encoder_cleanup (encoder);return ret;
PATCH 4/4 drm/rockchip: dw_hdmi: Support to find the next bridge
In reply to Damon DingIf there is a remote node connected to the HDMI output (port@1), the &dw_hdmi_plat_data.output_port should be set to 1. This patch allows Rockchip dw-hdmi to support the hdmi-connector and the next bridge.
--- drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +14 -0
@@ -544,6 +544,8 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,struct drm_encoder *encoder;struct rockchip_hdmi *hdmi;struct drm_connector *connector; +struct device_node *remote; +struct drm_bridge *next_bridge;int ret;if (!pdev->dev.of_node)
@@ -610,6 +612,18 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,platform_set_drvdata (pdev, hdmi); + remote =of_graph_get_remote_node (hdmi->dev->of_node,1 ,-1 ); +if (remote) { +of_node_put (remote); + + ret =drm_of_find_panel_or_bridge (hdmi->dev->of_node,1 ,0 , +NULL , &next_bridge); +if (ret && ret != -ENODEV ) + goto err_cleanup_encoder; + + plat_data->output_port =1 ; + } + hdmi->hdmi =dw_hdmi_bind (pdev, encoder, plat_data,DRM_BRIDGE_ATTACH_NO_CONNECTOR );/*
Signature · 1 line
2.34.1