drm/rockchip: migrate to common dw-mipi-dsi bridge and dual-dsi
Subsystems (6)
Heiko Stuebner
maintainerv5 cover drm/rockchip: migrate to common dw-mipi-dsi bridge and dual-dsi
The Rockchip DSI driver was separate till now, not using the common bridge driver that was introduced a bit later. So this series migrates over to use that common bridge driver and then also adds support for dual-dsi to both the bridge and Rockchip glue code.
The bridge-migration itself is based on Nickeys earlier v8 work, but adapted to current kernels and with a new split between probe and bind, so that we do not create and drop the dsi-host on each deferred bind attempt.
changes in v2:
- rebase against newer drm code (dsi-bridge+rockchip changes)
- add SPDX header to new glue driver
- expect regular interface lanes from panel (like 4) not the double number Similar to tegra
- keep links to both master and slave
changes in v3:
- don't defer in bridge_attach, instead add ability to check for finalized panel attachement, for example in bind
- address bridge-conversion comments from Andrzej:
- include ordering
- moved hwaccess from mode_set to enable callback
- move pllref_clk enablement to bind (needed by bridge mode_set->lane_mbps)
- limited slave settings to dw_mipi_dsi_set_slave
- address dual-dsi comments from Philippe:
- remove unneeded separate variables
- remove unneeded second slave settings
- disable slave before master
- lane-sum calculation comments
changes in v4:
- rebase against some legacy rockchip-dsi changes
- add dsi-component only after panel has attached to dsi host This solves quite some concurrency problems that happen when trying to determine dsi-panel availability
changes in v5:
- use driver-internal method to find second host
- drop of-graph based dsi method for it
Unchanged from review comments:
- kept dw_mipi_dsi_bind, as the dsi->bridge member is only part of the bridge drivers struct, so not accessible from glue drivers
- kept dual-dsi handling that mimicks tegra
Heiko Stuebner (4):
drm/bridge/synopsys: dsi: move mipi_dsi_host_unregister to
__dw_mipi_dsi_remove
drm/bridge/synopsys: dsi: don't call __dw_mipi_dsi_probe from
dw_mipi_dsi_bind
drm/bridge/synopsys: dsi: add ability to have glue-specific attach and
detach
drm/rockchip: dsi: add dual mipi support
Nickey Yang (3):
dt-bindings: display: rockchip: update DSI controller drm/rockchip: dsi: migrate to use dw-mipi-dsi bridge driver drm/bridge/synopsys: dsi: add dual-dsi support
.../display/rockchip/dw_mipi_dsi_rockchip.txt | 23 +- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 114 +- drivers/gpu/drm/rockchip/Kconfig | 2 +- drivers/gpu/drm/rockchip/Makefile | 2 +- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 1044 +++++++++++++ drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 1349 ----------------- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 3 +- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 + drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 4 + drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 1 + include/drm/bridge/dw_mipi_dsi.h | 14 +- 12 files changed, 1182 insertions(+), 1379 deletions(-) create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerPATCH v5 1/7 drm/bridge/synopsys: dsi: move mipi_dsi_host_unregister to __dw_mipi_dsi_remove
Right now the host is only unregistered when the driver is used via the bridge api and not via the component api, leading to the host staying registered in cases like probe deferral.
So move the host unregister to the general remove function, so that it gets cleaned up in all cases.
--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +2 -2
@@ -941,6 +941,8 @@ __dw_mipi_dsi_probe(struct platform_device *pdev,static void __dw_mipi_dsi_remove (struct dw_mipi_dsi *dsi) { +mipi_dsi_host_unregister (&dsi->dsi_host); +pm_runtime_disable (dsi->dev); }
@@ -957,8 +959,6 @@ EXPORT_SYMBOL_GPL(dw_mipi_dsi_probe);void dw_mipi_dsi_remove (struct dw_mipi_dsi *dsi) { -mipi_dsi_host_unregister (&dsi->dsi_host); -__dw_mipi_dsi_remove (dsi); }EXPORT_SYMBOL_GPL (dw_mipi_dsi_remove);
Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerPATCH v5 2/7 drm/bridge/synopsys: dsi: don't call __dw_mipi_dsi_probe from dw_mipi_dsi_bind
In reply to Heiko Stuebner__dw_mipi_dsi_probe() does all the grabbing of resources and does it using devm-helpers. So this is happening on each try of master bringup possibly slowing down things a lot.
Drivers using the component framework may instead want to call dw_mipi_dsi_probe separately in their probe function to setup resources early. That way the dsi bus also gets created earlier and also not recreated on each bind-try, so that attached panels can load their modules and be probed way before the bridge-attach in the bind call.
So drop the call to __dw_mipi_dsi_probe and modify the function to take a struct dw_mipi_dsi instead of the platform-device.
--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 15 +++------------ include/drm/bridge/dw_mipi_dsi.h | 5 +---- 2 files changed, 4 insertions(+), 16 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +3 -12
@@ -966,31 +966,22 @@ EXPORT_SYMBOL_GPL(dw_mipi_dsi_remove);/* * Bind/unbind API, used from platforms based on the component framework. */ -struct dw_mipi_dsi * -dw_mipi_dsi_bind (struct platform_device *pdev,struct drm_encoder *encoder, -const struct dw_mipi_dsi_plat_data *plat_data) +int dw_mipi_dsi_bind (struct dw_mipi_dsi *dsi,struct drm_encoder *encoder) { -struct dw_mipi_dsi *dsi;int ret; - dsi =__dw_mipi_dsi_probe (pdev, plat_data); -if (IS_ERR (dsi)) -return dsi; - ret =drm_bridge_attach (encoder, &dsi->bridge,NULL );if (ret) { -dw_mipi_dsi_remove (dsi);DRM_ERROR ("Failed to initialize bridge with drm\n" ); -return ERR_PTR (ret); +return ret; } -return dsi; +return ret; }EXPORT_SYMBOL_GPL (dw_mipi_dsi_bind);void dw_mipi_dsi_unbind (struct dw_mipi_dsi *dsi) { -__dw_mipi_dsi_remove (dsi); }EXPORT_SYMBOL_GPL (dw_mipi_dsi_unbind);
include/drm/bridge/dw_mipi_dsi.h +1 -4
@@ -35,10 +35,7 @@ struct dw_mipi_dsi *dw_mipi_dsi_probe(struct platform_device *pdev,const struct dw_mipi_dsi_plat_data *plat_data);void dw_mipi_dsi_remove (struct dw_mipi_dsi *dsi); -struct dw_mipi_dsi *dw_mipi_dsi_bind (struct platform_device *pdev, -struct drm_encoder *encoder, -const struct dw_mipi_dsi_plat_data - *plat_data); +int dw_mipi_dsi_bind (struct dw_mipi_dsi *dsi,struct drm_encoder *encoder);void dw_mipi_dsi_unbind (struct dw_mipi_dsi *dsi);#endif /* __DW_MIPI_DSI__ */
Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerPATCH v5 3/7 drm/bridge/synopsys: dsi: add ability to have glue-specific attach and detach
In reply to Heiko StuebnerWith the regular means of adding the dsi-component in probe it creates a race condition with the panel probing, as the panel device only gets created after the dsi-bus got created.
When the panel-driver is build as a module it currently fails hard as the panel cannot be probed directly:
dw_mipi_dsi_bind()
__dw_mipi_dsi_probe()
creates dsi bus
creates panel device
triggers panel module load
panel not probed (module not loaded or panel probe slow)
drm_bridge_attach
fails with -EINVAL due to empty panel_bridge
Additionally the panel probing can run concurrently with dsi bringup making it possible that the panel can already be found but dsi-attach hasn't finished running.
To solve that cleanly we may want to only create the component after the panel has finished probing, by calling component_add from the host-attach dsi callback.
As that is specific to glue drivers, add a new struct for host_ops so that glue drivers can tell the bridge to call specific functions after the common host-attach and before the common host-detach run.
--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 15 +++++++++++++++ include/drm/bridge/dw_mipi_dsi.h | 8 ++++++++ 2 files changed, 23 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +15 -0
@@ -270,6 +270,7 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) {struct dw_mipi_dsi *dsi =host_to_dsi (host); +const struct dw_mipi_dsi_plat_data *pdata = dsi->plat_data;struct drm_bridge *bridge;struct drm_panel *panel;int ret;
@@ -300,6 +301,12 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,drm_bridge_add (&dsi->bridge); +if (pdata->host_ops && pdata->host_ops->attach) { + ret = pdata->host_ops->attach (pdata->priv_data, device); +if (ret <0 ) +return ret; + } +return 0 ; }
@@ -307,6 +314,14 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) {struct dw_mipi_dsi *dsi =host_to_dsi (host); +const struct dw_mipi_dsi_plat_data *pdata = dsi->plat_data; +int ret; + +if (pdata->host_ops && pdata->host_ops->detach) { + ret = pdata->host_ops->detach (pdata->priv_data, device); +if (ret <0 ) +return ret; + }drm_of_panel_bridge_remove (host->dev->of_node,1 ,0 );
include/drm/bridge/dw_mipi_dsi.h +8 -0
@@ -19,6 +19,13 @@ struct dw_mipi_dsi_phy_ops { unsigned int *lane_mbps); }; +struct dw_mipi_dsi_host_ops { +int (*attach)(void *priv_data, +struct mipi_dsi_device *dsi); +int (*detach)(void *priv_data, +struct mipi_dsi_device *dsi); +}; +struct dw_mipi_dsi_plat_data {void __iomem *base;unsigned int max_data_lanes;
@@ -27,6 +34,7 @@ struct dw_mipi_dsi_plat_data { const struct drm_display_mode *mode);const struct dw_mipi_dsi_phy_ops *phy_ops; +const struct dw_mipi_dsi_host_ops *host_ops;void *priv_data; };
Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 20180821140515.22246-1-heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org
PATCH v5 4/7 dt-bindings: display: rockchip: update DSI controller
From: Nickey Yang <[email protected]>
This patch update describe panel/port links, including unit addresses in documentation of device tree bindings for the rockchip DSI controller based on the Synopsys DesignWare MIPI DSI host controller.
--- .../display/rockchip/dw_mipi_dsi_rockchip.txt | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/display/rockchip/dw_mipi_dsi_rockchip.txt +21 -2
@@ -14,6 +14,8 @@ Required properties: - rockchip,grf: this soc should set GRF regs to mux vopl/vopb. - ports: contain a port node with endpoint definitions as defined in [2]. For vopb,set the reg = <0> and set the reg = <1> for vopl. +- video port 0 for the VOP input, the remote endpoint maybe vopb or vopl +- video port 1 for either a panel or subsequent encoder Optional properties: - power-domains: a phandle to mipi dsi power domain node.
@@ -40,11 +42,12 @@ Example: ports { #address-cells = <1>; #size-cells = <0>; - reg = <1>; - mipi_in: port { + mipi_in: port@0 { + reg = <0>; #address-cells = <1>; #size-cells = <0>; + mipi_in_vopb: endpoint@0 { reg = <0>; remote-endpoint = <&vopb_out_mipi>;
@@ -54,6 +57,16 @@ Example: remote-endpoint = <&vopl_out_mipi>; }; }; + + mipi_out: port@1 { + reg = <1>; + #address-cells = <1>; + #size-cells = <0>; + + mipi_out_panel: endpoint { + remote-endpoint = <&panel_in_mipi>; + }; + }; }; panel {
@@ -64,5 +77,11 @@ Example: pinctrl-names = "default"; pinctrl-0 = <&lcd_en>; backlight = <&backlight>; + + port { + panel_in_mipi: endpoint { + remote-endpoint = <&mipi_out_panel>; + }; + }; }; };
Signature · 1 line
2.17.0
PATCH v5 5/7 drm/rockchip: dsi: migrate to use dw-mipi-dsi bridge driver
In reply to a message not in the archiveFrom: Nickey Yang <[email protected]>
Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare MIPI DSI host controller bridge and remove the old separate one.
changes:
v2:
add err_pllref, remove unnecessary encoder.enable & disable correct spelling mistakes
v3:
call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind() fix typo, use of_device_get_match_data(),
change some bind() logic into probe()
add 'dev_set_drvdata()'
v4:
return -EINVAL when can not get best_freq
add a clarifying comment when get vco
add review tag
v5:
keep our power domain enabled while touching GRF
v6:
change func name dw_mipi_encoder_disable to dw_mipi_dsi_encoder_disable
v7:
none
v8: Heiko
add Archit's Review tag
adapt to recent changes in the original rockchip-dsi driver beautify grf-handling
split hw-setup (resources, dsi-host) from bind into probe
v2-new: Heiko
add SPDX header instead of license blurb
drop old versioning to not confuse people
v3-new: Heiko
include ordering
moved hwaccess from mode_set to enable callback
move pllref_clk enablement to bind (needed by bridge mode_set->lane_mbps)
v4-new: Heiko
rebase against recent rockchip-dsi changes
move to call component_add in the new glue host-attach
--- drivers/gpu/drm/rockchip/Kconfig | 2 +- drivers/gpu/drm/rockchip/Makefile | 2 +- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 939 ++++++++++++ drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 1349 ----------------- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 +- 6 files changed, 943 insertions(+), 1353 deletions(-) create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
drivers/gpu/drm/rockchip/Kconfig +1 -1
@@ -7,7 +7,7 @@ config DRM_ROCKCHIP select VIDEOMODE_HELPERS select DRM_ANALOGIX_DP if ROCKCHIP_ANALOGIX_DP select DRM_DW_HDMI if ROCKCHIP_DW_HDMI - select DRM_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI + select DRM_DW_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI select SND_SOC_HDMI_CODEC if ROCKCHIP_CDN_DP && SND_SOC help Choose this option if you have a Rockchip soc chipset.
drivers/gpu/drm/rockchip/Makefile +1 -1
@@ -11,7 +11,7 @@ rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += rockchip_drm_fbdev.o rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o rockchipdrm-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o cdn-dp-reg.o rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o -rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o +rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi-rockchip.o rockchipdrm-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi.o rockchipdrm-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c new file +939 -0
939 lines not on this page · raw message
drivers/gpu/drm/rockchip/dw-mipi-dsi.c deleted +0 -1349
1,349 lines not on this page · raw message
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -1
@@ -435,7 +435,7 @@ static int __init rockchip_drm_init(void)ADD_ROCKCHIP_SUB_DRIVER (cdn_dp_driver,CONFIG_ROCKCHIP_CDN_DP );ADD_ROCKCHIP_SUB_DRIVER (dw_hdmi_rockchip_pltfm_driver,CONFIG_ROCKCHIP_DW_HDMI ); -ADD_ROCKCHIP_SUB_DRIVER (dw_mipi_dsi_driver, +ADD_ROCKCHIP_SUB_DRIVER (dw_mipi_dsi_rockchip_driver,CONFIG_ROCKCHIP_DW_MIPI_DSI );ADD_ROCKCHIP_SUB_DRIVER (inno_hdmi_driver,CONFIG_ROCKCHIP_INNO_HDMI );
drivers/gpu/drm/rockchip/rockchip_drm_drv.h +1 -1
@@ -66,7 +66,7 @@ int rockchip_drm_wait_vact_end(struct drm_crtc *crtc, unsigned int mstimeout);extern struct platform_driver cdn_dp_driver;extern struct platform_driver dw_hdmi_rockchip_pltfm_driver; -extern struct platform_driver dw_mipi_dsi_driver; +extern struct platform_driver dw_mipi_dsi_rockchip_driver;extern struct platform_driver inno_hdmi_driver;extern struct platform_driver rockchip_dp_driver;extern struct platform_driver rockchip_lvds_driver;
Signature · 1 line
2.17.0
Hi Heiko,
Quoted 29 lines · Heiko Stuebner
The Rockchip DSI driver was separate till now, not using the common bridge driver that was introduced a bit later. So this series migrates over to use that common bridge driver and then also adds support for dual-dsi to both the bridge and Rockchip glue code.
The bridge-migration itself is based on Nickeys earlier v8 work, but adapted to current kernels and with a new split between probe and bind, so that we do not create and drop the dsi-host on each deferred bind attempt.
changes in v2:
- rebase against newer drm code (dsi-bridge+rockchip changes)
- add SPDX header to new glue driver
- expect regular interface lanes from panel (like 4) not the double number Similar to tegra
- keep links to both master and slave
changes in v3:
- don't defer inbridge_attach, instead add ability to check for finalized panel attachement, for example in bind
- address bridge-conversion comments from Andrzej:
- include ordering
- moved hwaccess frommode_setto enable callback
- movepllref_clkenablement to bind (needed by bridgemode_set->lane_mbps)
- limited slave settings todw_mipi_dsi_set_slave
- address dual-dsi comments from Philippe:
- remove unneeded separate variables
- remove unneeded second slave settings
- disable slave before master
- lane-sum calculation comments
Quoted 8 lines
changes in v4:
- rebase against some legacy rockchip-dsi changes
- add dsi-component only after panel has attached to dsi host This solves quite some concurrency problems that happen when trying to determine dsi-panel availability
changes in v5:
- use driver-internal method to find second host
- drop of-graph based dsi method for it
FYI, Yannick tested successfully the v5 version on stm32 boards. Note that drm stm32 drivers do not use bind/unbind & dual-dsi so this email is simply to share with you this minor information: "v5 patch does not break stm32 dsi", hope it helps a little.
Many thanks,
Philippe :-)
Quoted 37 lines
Unchanged from review comments:
- keptdw_mipi_dsi_bind, as thedsi->bridgemember is only part of the bridge drivers struct, so not accessible from glue drivers
- kept dual-dsi handling that mimicks tegraHeiko Stuebner (4):
drm/bridge/synopsys: dsi: movemipi_dsi_host_unregisterto
__dw_mipi_dsi_remove
drm/bridge/synopsys: dsi: don't call__dw_mipi_dsi_probefrom
dw_mipi_dsi_bind
drm/bridge/synopsys: dsi: add ability to have glue-specific attach and
detach
drm/rockchip: dsi: add dual mipi supportNickey Yang (3):
dt-bindings: display: rockchip: update DSI controller drm/rockchip: dsi: migrate to use dw-mipi-dsi bridge driver drm/bridge/synopsys: dsi: add dual-dsi support.../display/rockchip/dw_mipi_dsi_rockchip.txt | 23 +- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 114 +- drivers/gpu/drm/rockchip/Kconfig | 2 +- drivers/gpu/drm/rockchip/Makefile | 2 +- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 1044 +++++++++++++ drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 1349 ----------------- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 3 +- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 + drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 4 + drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 1 + include/drm/bridge/dw_mipi_dsi.h | 14 +- 12 files changed, 1182 insertions(+), 1379 deletions(-)create mode 100644
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.cdelete mode 100644drivers/gpu/drm/rockchip/dw-mipi-dsi.c
Heiko Stuebner
maintainerPATCH v5 6/7 drm/bridge/synopsys: dsi: add dual-dsi support
In reply to Heiko StuebnerFrom: Nickey Yang <[email protected]>
Allow to also drive a slave dw-mipi-dsi controller in a dual-dsi setup. This will require additional implementation-specific code to look up the slave instance and do specific setup. Also will probably need code in the specific crtcs as dual-dsi does not equal two separate dsi outputs.
To activate, the implementation-specific code should set the slave using dw_mipi_dsi_set_slave() before calling __dw_mipi_dsi_bind().
v2:
- expect real interface number of lanes
- keep links to both master and slave
v3:
- remove unneeded separate variables
- remove unneeded second slave settings
- disable slave before master
- lane-sum calculation comments
--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 80 +++++++++++++++++-- include/drm/bridge/dw_mipi_dsi.h | 1 + 2 files changed, 75 insertions(+), 6 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +74 -6
@@ -230,9 +230,20 @@ struct dw_mipi_dsi {u32 format;unsigned long mode_flags; +struct dw_mipi_dsi *master;/* dual-dsi master ptr */ +struct dw_mipi_dsi *slave;/* dual-dsi slave ptr */ +const struct dw_mipi_dsi_plat_data *plat_data; }; +/* +* Check if either a link to a master or slave is present +*/ +static inline bool dw_mipi_is_dual_mode (struct dw_mipi_dsi *dsi) +{ +return dsi->slave || dsi->master; +} +/* * The controller should generate 2 frames before * preparing the peripheral.
@@ -456,10 +467,17 @@ static ssize_t dw_mipi_dsi_host_transfer(struct mipi_dsi_host *host, }dw_mipi_message_config (dsi, msg); +if (dsi->slave) +dw_mipi_message_config (dsi->slave, msg); ret =dw_mipi_dsi_write (dsi, &packet);if (ret)return ret; +if (dsi->slave) { + ret =dw_mipi_dsi_write (dsi->slave, &packet); +if (ret) +return ret; + }if (msg->rx_buf && msg->rx_len) { ret =dw_mipi_dsi_read (dsi, msg);
@@ -598,7 +616,11 @@ static void dw_mipi_dsi_video_packet_config(struct dw_mipi_dsi *dsi,* DSI_VNPCR.NPSIZE... especially because this driver supports * non-burst video modes, see dw_mipi_dsi_video_mode_config()... */ -dsi_write (dsi,DSI_VID_PKT_SIZE ,VID_PKT_SIZE (mode->hdisplay)); + +dsi_write (dsi,DSI_VID_PKT_SIZE , +dw_mipi_is_dual_mode (dsi) ? +VID_PKT_SIZE (mode->hdisplay /2 ) : +VID_PKT_SIZE (mode->hdisplay)); }static void dw_mipi_dsi_command_mode_config (struct dw_mipi_dsi *dsi)
@@ -770,24 +792,43 @@ static void dw_mipi_dsi_bridge_post_disable(struct drm_bridge *bridge)*/ dsi->panel_bridge->funcs->post_disable (dsi->panel_bridge); +if (dsi->slave) { +dw_mipi_dsi_disable (dsi->slave); +clk_disable_unprepare (dsi->slave->pclk); +pm_runtime_put (dsi->slave->dev); + }dw_mipi_dsi_disable (dsi); +clk_disable_unprepare (dsi->pclk);pm_runtime_put (dsi->dev); } -static void dw_mipi_dsi_bridge_mode_set (struct drm_bridge *bridge, -struct drm_display_mode *mode, -struct drm_display_mode *adjusted_mode) +static unsigned int dw_mipi_dsi_get_lanes (struct dw_mipi_dsi *dsi) +{ +/* this instance is the slave, so add the master's lanes */ +if (dsi->master) +return dsi->master->lanes + dsi->lanes; + +/* this instance is the master, so add the slave's lanes */ +if (dsi->slave) +return dsi->lanes + dsi->slave->lanes; + +/* single-dsi, so no other instance to consider */ +return dsi->lanes; +} + +static void dw_mipi_dsi_mode_set (struct dw_mipi_dsi *dsi, +struct drm_display_mode *adjusted_mode) { -struct dw_mipi_dsi *dsi =bridge_to_dsi (bridge);const struct dw_mipi_dsi_phy_ops *phy_ops = dsi->plat_data->phy_ops;void *priv_data = dsi->plat_data->priv_data;int ret; +u32 lanes =dw_mipi_dsi_get_lanes (dsi);clk_prepare_enable (dsi->pclk); ret = phy_ops->get_lane_mbps (priv_data, adjusted_mode, dsi->mode_flags, - dsi->lanes, dsi->format, &dsi->lane_mbps); + lanes, dsi->format, &dsi->lane_mbps);if (ret)DRM_DEBUG_DRIVER ("Phy get_lane_mbps() failed\n" );
@@ -819,12 +860,25 @@ static void dw_mipi_dsi_bridge_mode_set(struct drm_bridge *bridge,dw_mipi_dsi_set_mode (dsi,0 ); } +static void dw_mipi_dsi_bridge_mode_set (struct drm_bridge *bridge, +struct drm_display_mode *mode, +struct drm_display_mode *adjusted_mode) +{ +struct dw_mipi_dsi *dsi =bridge_to_dsi (bridge); + +dw_mipi_dsi_mode_set (dsi, adjusted_mode); +if (dsi->slave) +dw_mipi_dsi_mode_set (dsi->slave, adjusted_mode); +} +static void dw_mipi_dsi_bridge_enable (struct drm_bridge *bridge) {struct dw_mipi_dsi *dsi =bridge_to_dsi (bridge);/* Switch to video mode for panel-bridge enable & panel enable */ dw_mipi_dsi_set_mode (dsi,MIPI_DSI_MODE_VIDEO ); +if (dsi->slave) +dw_mipi_dsi_set_mode (dsi->slave,MIPI_DSI_MODE_VIDEO ); } static enum drm_mode_status
@@ -961,6 +1015,20 @@ static void __dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi)pm_runtime_disable (dsi->dev); } +void dw_mipi_dsi_set_slave (struct dw_mipi_dsi *dsi,struct dw_mipi_dsi *slave) +{ +/* introduce controllers to each other */ + dsi->slave = slave; + dsi->slave->master = dsi; + +/* migrate settings for already attached displays */ + dsi->slave->lanes = dsi->lanes; + dsi->slave->channel = dsi->channel; + dsi->slave->format = dsi->format; + dsi->slave->mode_flags = dsi->mode_flags; +} +EXPORT_SYMBOL_GPL (dw_mipi_dsi_set_slave); +/* * Probe/remove API, used from platforms based on the DRM bridge API. */
include/drm/bridge/dw_mipi_dsi.h +1 -0
@@ -45,5 +45,6 @@ struct dw_mipi_dsi *dw_mipi_dsi_probe(struct platform_device *pdev,void dw_mipi_dsi_remove (struct dw_mipi_dsi *dsi);int dw_mipi_dsi_bind (struct dw_mipi_dsi *dsi,struct drm_encoder *encoder);void dw_mipi_dsi_unbind (struct dw_mipi_dsi *dsi); +void dw_mipi_dsi_set_slave (struct dw_mipi_dsi *dsi,struct dw_mipi_dsi *slave);#endif /* __DW_MIPI_DSI__ */
Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v5 6/7] drm/bridge/synopsys: dsi: add dual-dsi support
Quoted 20 lines · Heiko Stuebner
From: Nickey Yang <[email protected]>
Allow to also drive a slave dw-mipi-dsi controller in a dual-dsi setup. This will require additional implementation-specific code to look up the slave instance and do specific setup. Also will probably need code in the specific crtcs as dual-dsi does not equal two separate dsi outputs.
To activate, the implementation-specific code should set the slave using
dw_mipi_dsi_set_slave()before calling__dw_mipi_dsi_bind().v2:
- expect real interface number of lanes
- keep links to both master and slave
v3:
- remove unneeded separate variables
- remove unneeded second slave settings
- disable slave before master
- lane-sum calculation comments
Quoted 3 lines
Signed-off-by Nickey Yang <[email protected]>Signed-off-by Heiko Stuebner <[email protected]>Tested-by Philippe Cornu <[email protected]>
--
Regards
Andrzej
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerPATCH v5 7/7 drm/rockchip: dsi: add dual mipi support
In reply to Heiko StuebnerAdd the Rockchip-sepcific dual-dsi setup and hook it into the VOP as well. As described in the general dual-dsi devicetree binding, the panel should define two input ports and point each of them to one of the used dsi- controllers, as well as declare one of them as clock-master. This is used to determine the dual-dsi state and get access to both controller instances.
v4:
add component directly in probe when adding empty dsi slave controller
v5:
use driver-internal mechanism to find dual dsi slave
--- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 105 ++++++++++++++++++ drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 1 + drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 + drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 4 + drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 1 + 5 files changed, 114 insertions(+)
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +105 -0
@@ -218,6 +218,10 @@ struct dw_mipi_dsi_rockchip {struct clk *grf_clk;struct clk *phy_cfg_clk; +/* dual-channel */ +bool is_slave; +struct dw_mipi_dsi_rockchip *slave; +unsigned int lane_mbps;/* per lane */ u16 input_div;u16 feedback_div;
@@ -226,6 +230,7 @@ struct dw_mipi_dsi_rockchip {struct dw_mipi_dsi *dmd;const struct rockchip_dw_dsi_chip_data *cdata;struct dw_mipi_dsi_plat_data pdata; +int devcnt; };struct dphy_pll_parameter_map {
@@ -602,6 +607,8 @@ dw_mipi_dsi_encoder_atomic_check(struct drm_encoder *encoder, } s->output_type =DRM_MODE_CONNECTOR_DSI ; +if (dsi->slave) + s->output_flags =ROCKCHIP_OUTPUT_DSI_DUAL ;return 0 ; }
@@ -617,6 +624,8 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder)return ;pm_runtime_get_sync (dsi->dev); +if (dsi->slave) +pm_runtime_get_sync (dsi->slave->dev);/* * For the RK3399, the clk of grf must be enabled before writing grf
@@ -630,6 +639,8 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder) }dw_mipi_dsi_rockchip_config (dsi, mux); +if (dsi->slave) +dw_mipi_dsi_rockchip_config (dsi->slave, mux);clk_disable_unprepare (dsi->grf_clk); }
@@ -638,6 +649,8 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder) {struct dw_mipi_dsi_rockchip *dsi =to_dsi (encoder); +if (dsi->slave) +pm_runtime_put (dsi->slave->dev);pm_runtime_put (dsi->dev); }
@@ -673,14 +686,76 @@ static int rockchip_dsi_drm_create_encoder(struct dw_mipi_dsi_rockchip *dsi,return 0 ; } +static int dw_mipi_dsi_rockchip_match_second (struct device *dev,void *data) +{ +struct dw_mipi_dsi_rockchip *dsi = data; +struct drm_bridge *bridge1, *bridge2; +struct drm_panel *panel1, *panel2; +int ret; + +if (dsi->dev->of_node == dev->of_node) +return 0 ; + + ret =drm_of_find_panel_or_bridge (dsi->dev->of_node,1 ,0 , + &panel1, &bridge1); +if (ret) +return ret; + + ret =drm_of_find_panel_or_bridge (dev->of_node,1 ,0 , + &panel2, &bridge2); +if (ret) +return ret; + +return (panel1 == panel2) && (bridge1 == bridge2); +} +static int dw_mipi_dsi_rockchip_bind (struct device *dev,struct device *master,void *data) {struct dw_mipi_dsi_rockchip *dsi =dev_get_drvdata (dev);struct drm_device *drm_dev = data; +struct device *second; +bool master1, master2;int ret; + second =driver_find_device (dsi->dev->driver,NULL , dsi, + dw_mipi_dsi_rockchip_match_second); +if (IS_ERR (second)) +return PTR_ERR (second); + +if (second) { + master1 =of_property_read_bool (dsi->dev->of_node, +"clock-master" ); + master2 =of_property_read_bool (second->of_node, +"clock-master" ); + +if (master1 && master2) { +DRM_DEV_ERROR (dsi->dev,"only one clock-master allowed\n" ); +return -EINVAL ; + } + +if (!master1 && !master2) { +DRM_DEV_ERROR (dsi->dev,"no clock-master defined\n" ); +return -EINVAL ; + } + +/* we are the slave in dual-DSI */ +if (!master1) { + dsi->is_slave = true; +return 0 ; + } + + dsi->slave =dev_get_drvdata (second); +if (!dsi->slave) { +DRM_DEV_ERROR (dev,"could not get slaves data\n" ); +return -ENODEV ; + } + + dsi->slave->is_slave = true; +dw_mipi_dsi_set_slave (dsi->dmd, dsi->slave->dmd); + } + ret =clk_prepare_enable (dsi->pllref_clk);if (ret) {DRM_DEV_ERROR (dev,"Failed to enable pllref_clk: %d\n" , ret);
@@ -708,6 +783,9 @@ static void dw_mipi_dsi_rockchip_unbind(struct device *dev, {struct dw_mipi_dsi_rockchip *dsi =dev_get_drvdata (dev); +if (dsi->is_slave) +return ; +dw_mipi_dsi_unbind (dsi->dmd);clk_disable_unprepare (dsi->pllref_clk);
@@ -749,6 +827,14 @@ static const struct dw_mipi_dsi_host_ops dw_mipi_dsi_rockchip_host_ops = { .detach = dw_mipi_dsi_rockchip_host_detach, }; +static int dw_mipi_dsi_rockchip_cnt_dev (struct device *dev,void *data) +{ +struct dw_mipi_dsi_rockchip *dsi = data; + + dsi->devcnt++; +return 0 ; +} +static int dw_mipi_dsi_rockchip_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -835,6 +921,22 @@ static int dw_mipi_dsi_rockchip_probe(struct platform_device *pdev) goto err_clkdisable; } +/* +* All dsi child devices will have been created, so we can check +* their number and add the component here if there will be no +* host-attach call. +*/ +device_for_each_child (dsi->dev, dsi, dw_mipi_dsi_rockchip_cnt_dev); +if (dsi->devcnt ==0 ) { + ret =component_add (dsi->dev, &dw_mipi_dsi_rockchip_ops); +if (ret) { +DRM_DEV_ERROR (dsi->dev,"Failed to register component: %d\n" , + ret); +dw_mipi_dsi_remove (dsi->dmd); + goto err_clkdisable; + } + } +return 0 ; err_clkdisable:
@@ -846,6 +948,9 @@ static int dw_mipi_dsi_rockchip_remove(struct platform_device *pdev) {struct dw_mipi_dsi_rockchip *dsi =platform_get_drvdata (pdev); +if (dsi->devcnt ==0 ) +component_del (dsi->dev, &dw_mipi_dsi_rockchip_ops); +dw_mipi_dsi_remove (dsi->dmd);return 0 ;
drivers/gpu/drm/rockchip/rockchip_drm_drv.h +1 -0
@@ -37,6 +37,7 @@ struct rockchip_crtc_state {int output_type;int output_mode;int output_bpc; +int output_flags; };#define to_rockchip_crtc_state (s) \ container_of(s, struct rockchip_crtc_state, base)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +3 -0
@@ -910,6 +910,7 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc, pin_pol |= (adjusted_mode->flags &DRM_MODE_FLAG_PVSYNC ) ?BIT (VSYNC_POSITIVE ) :0 ;VOP_REG_SET (vop, output, pin_pol, pin_pol); +VOP_REG_SET (vop, output, mipi_dual_channel_en,0 );switch (s->output_type) {case DRM_MODE_CONNECTOR_LVDS :
@@ -927,6 +928,8 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc,case DRM_MODE_CONNECTOR_DSI :VOP_REG_SET (vop, output, mipi_pin_pol, pin_pol);VOP_REG_SET (vop, output, mipi_en,1 ); +VOP_REG_SET (vop, output, mipi_dual_channel_en, + !!(s->output_flags &ROCKCHIP_OUTPUT_DSI_DUAL ));break ;case DRM_MODE_CONNECTOR_DisplayPort: pin_pol &= ~BIT (DCLK_INVERT );
drivers/gpu/drm/rockchip/rockchip_drm_vop.h +4 -0
@@ -60,6 +60,7 @@ struct vop_output {struct vop_reg edp_en;struct vop_reg hdmi_en;struct vop_reg mipi_en; +struct vop_reg mipi_dual_channel_en;struct vop_reg rgb_en; };
@@ -213,6 +214,9 @@ struct vop_data {/* for use special outface */ #define ROCKCHIP_OUT_MODE_AAAA 15 +/* output flags */ +#define ROCKCHIP_OUTPUT_DSI_DUAL BIT(0) +enum alpha_mode {ALPHA_STRAIGHT ,ALPHA_INVERSE ,
drivers/gpu/drm/rockchip/rockchip_vop_reg.c +1 -0
@@ -543,6 +543,7 @@ static const struct vop_output rk3399_output = { .hdmi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 13), .edp_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 14), .mipi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 15), + .mipi_dual_channel_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 3), };static const struct vop_data rk3399_vop_big = {
Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v5 7/7] drm/rockchip: dsi: add dual mipi support
Quoted 108 lines · Heiko Stuebner
Add the Rockchip-sepcific dual-dsi setup and hook it into the VOP as well. As described in the general dual-dsi devicetree binding, the panel should define two input ports and point each of them to one of the used dsi- controllers, as well as declare one of them as clock-master. This is used to determine the dual-dsi state and get access to both controller instances.
Signed-off-by Heiko Stuebner <[email protected]>v4:
add component directly in probe when adding empty dsi slave controller
v5:
use driver-internal mechanism to find dual dsi slave--- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 105 ++++++++++++++++++ drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 1 + drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 + drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 4 + drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 1 + 5 files changed, 114 insertions(+)drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +36
-0@@ -218,6 +218,10 @@ struct dw_mipi_dsi_rockchip {struct clk *grf_clk;struct clk *phy_cfg_clk; +/* dual-channel */ +bool is_slave; +struct dw_mipi_dsi_rockchip *slave; +unsigned int lane_mbps;/* per lane */ u16 input_div;u16 feedback_div;@@ -226,6 +230,7 @@ struct dw_mipi_dsi_rockchip {struct dw_mipi_dsi *dmd;const struct rockchip_dw_dsi_chip_data *cdata;struct dw_mipi_dsi_plat_data pdata; +int devcnt; };struct dphy_pll_parameter_map {@@ -602,6 +607,8 @@ dw_mipi_dsi_encoder_atomic_check(struct drm_encoder *encoder, } s->output_type =DRM_MODE_CONNECTOR_DSI ; +if (dsi->slave) + s->output_flags =ROCKCHIP_OUTPUT_DSI_DUAL ;return 0 ; }@@ -617,6 +624,8 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder)return ;pm_runtime_get_sync (dsi->dev); +if (dsi->slave) +pm_runtime_get_sync (dsi->slave->dev);/* * For the RK3399, the clk of grf must be enabled before writing grf @@ -630,6 +639,8 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder) }dw_mipi_dsi_rockchip_config (dsi, mux); +if (dsi->slave) +dw_mipi_dsi_rockchip_config (dsi->slave, mux);clk_disable_unprepare (dsi->grf_clk); }@@ -638,6 +649,8 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder) {struct dw_mipi_dsi_rockchip *dsi =to_dsi (encoder); +if (dsi->slave) +pm_runtime_put (dsi->slave->dev);pm_runtime_put (dsi->dev); }@@ -673,14 +686,76 @@ static int rockchip_dsi_drm_create_encoder(struct dw_mipi_dsi_rockchip *dsi,return 0 ; } +static int dw_mipi_dsi_rockchip_match_second (struct device *dev,void *data) +{ +struct dw_mipi_dsi_rockchip *dsi = data; +struct drm_bridge *bridge1, *bridge2; +struct drm_panel *panel1, *panel2; +int ret; + +if (dsi->dev->of_node == dev->of_node) +return 0 ; + + ret =drm_of_find_panel_or_bridge (dsi->dev->of_node,1 ,0 , + &panel1, &bridge1); +if (ret) +return ret; + + ret =drm_of_find_panel_or_bridge (dev->of_node,1 ,0 , + &panel2, &bridge2); +if (ret) +return ret; + +return (panel1 == panel2) && (bridge1 == bridge2); +} + static int dw_mipi_dsi_rockchip_bind(struct device *dev, struct device *master,
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c static int rockchip_dsi_drm_create_encoder(struct dw_mipi_dsi_rockchip *dsi, · line 723
Quoted 10 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +4
-0void *data) {struct dw_mipi_dsi_rockchip *dsi =dev_get_drvdata (dev);struct drm_device *drm_dev = data; +struct device *second; +bool master1, master2;int ret; + second =driver_find_device (dsi->dev->driver,NULL , dsi, + dw_mipi_dsi_rockchip_match_second);
This function performs get_device on the matched device, so you should probably call somewhere put_device to make the counter balanced. I hope second device is somehow guarded by component framework from being unbound in unexpected moments (ie. when in use by master).
Quoted 64 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +46
-0+if (IS_ERR (second)) +return PTR_ERR (second); + +if (second) { + master1 =of_property_read_bool (dsi->dev->of_node, +"clock-master" ); + master2 =of_property_read_bool (second->of_node, +"clock-master" ); + +if (master1 && master2) { +DRM_DEV_ERROR (dsi->dev,"only one clock-master allowed\n" ); +return -EINVAL ; + } + +if (!master1 && !master2) { +DRM_DEV_ERROR (dsi->dev,"no clock-master defined\n" ); +return -EINVAL ; + } + +/* we are the slave in dual-DSI */ +if (!master1) { + dsi->is_slave = true; +return 0 ; + } + + dsi->slave =dev_get_drvdata (second); +if (!dsi->slave) { +DRM_DEV_ERROR (dev,"could not get slaves data\n" ); +return -ENODEV ; + } + + dsi->slave->is_slave = true; +dw_mipi_dsi_set_slave (dsi->dmd, dsi->slave->dmd); + } + ret =clk_prepare_enable (dsi->pllref_clk);if (ret) {DRM_DEV_ERROR (dev,"Failed to enable pllref_clk: %d\n" , ret);@@ -708,6 +783,9 @@ static void dw_mipi_dsi_rockchip_unbind(struct device *dev, {struct dw_mipi_dsi_rockchip *dsi =dev_get_drvdata (dev); +if (dsi->is_slave) +return ; +dw_mipi_dsi_unbind (dsi->dmd);clk_disable_unprepare (dsi->pllref_clk);@@ -749,6 +827,14 @@ static const struct dw_mipi_dsi_host_ops dw_mipi_dsi_rockchip_host_ops = { .detach = dw_mipi_dsi_rockchip_host_detach, }; +static int dw_mipi_dsi_rockchip_cnt_dev (struct device *dev,void *data) +{ +struct dw_mipi_dsi_rockchip *dsi = data; + + dsi->devcnt++; +return 0 ; +} +static int dw_mipi_dsi_rockchip_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c static int dw_mipi_dsi_rockchip_probe(struct platform_device *pdev) · line 927
Quoted 7 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +4
-0@@ -835,6 +921,22 @@ static int dw_mipi_dsi_rockchip_probe(struct platform_device *pdev) goto err_clkdisable; } +/* +* All dsi child devices will have been created, so we can check +* their number and add the component here if there will be no +* host-attach call.
I guess you mean that in this point all child devices have been created (remove 'will'), but it may be false assumption, there is always possibility to create device on the fly - see mipi_dsi_device_register_full. You cannot assume that in certain point in time there will be no more devices on the bus.
I am not sure of the purpose of this code. Why do you want to behave differently if there are no child devs?
Regards
Andrzej
Quoted 85 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +15
-0+*/ +device_for_each_child (dsi->dev, dsi, dw_mipi_dsi_rockchip_cnt_dev); +if (dsi->devcnt ==0 ) { + ret =component_add (dsi->dev, &dw_mipi_dsi_rockchip_ops); +if (ret) { +DRM_DEV_ERROR (dsi->dev,"Failed to register component: %d\n" , + ret); +dw_mipi_dsi_remove (dsi->dmd); + goto err_clkdisable; + } + } +return 0 ; err_clkdisable:@@ -846,6 +948,9 @@ static int dw_mipi_dsi_rockchip_remove(struct platform_device *pdev) {struct dw_mipi_dsi_rockchip *dsi =platform_get_drvdata (pdev); +if (dsi->devcnt ==0 ) +component_del (dsi->dev, &dw_mipi_dsi_rockchip_ops); +dw_mipi_dsi_remove (dsi->dmd);return 0 ;drivers/gpu/drm/rockchip/rockchip_drm_drv.h +1
-0@@ -37,6 +37,7 @@ struct rockchip_crtc_state {int output_type;int output_mode;int output_bpc; +int output_flags; };#define to_rockchip_crtc_state (s) \ container_of(s, struct rockchip_crtc_state, base)drivers/gpu/drm/rockchip/rockchip_drm_vop.c +3
-0@@ -910,6 +910,7 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc, pin_pol |= (adjusted_mode->flags &DRM_MODE_FLAG_PVSYNC ) ?BIT (VSYNC_POSITIVE ) :0 ;VOP_REG_SET (vop, output, pin_pol, pin_pol); +VOP_REG_SET (vop, output, mipi_dual_channel_en,0 );switch (s->output_type) {case DRM_MODE_CONNECTOR_LVDS :@@ -927,6 +928,8 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc,case DRM_MODE_CONNECTOR_DSI :VOP_REG_SET (vop, output, mipi_pin_pol, pin_pol);VOP_REG_SET (vop, output, mipi_en,1 ); +VOP_REG_SET (vop, output, mipi_dual_channel_en, + !!(s->output_flags &ROCKCHIP_OUTPUT_DSI_DUAL ));break ;case DRM_MODE_CONNECTOR_DisplayPort: pin_pol &= ~BIT (DCLK_INVERT );drivers/gpu/drm/rockchip/rockchip_drm_vop.h +4
-0@@ -60,6 +60,7 @@ struct vop_output {struct vop_reg edp_en;struct vop_reg hdmi_en;struct vop_reg mipi_en; +struct vop_reg mipi_dual_channel_en;struct vop_reg rgb_en; };@@ -213,6 +214,9 @@ struct vop_data {/* for use special outface */ #define ROCKCHIP_OUT_MODE_AAAA 15 +/* output flags */ +#define ROCKCHIP_OUTPUT_DSI_DUAL BIT(0) +enum alpha_mode {ALPHA_STRAIGHT ,ALPHA_INVERSE ,drivers/gpu/drm/rockchip/rockchip_vop_reg.c +0
-0
drivers/gpu/drm/rockchip/rockchip_vop_reg.c static const struct vop_output rk3399_output = { · line 549
Quoted 7 lines
drivers/gpu/drm/rockchip/rockchip_vop_reg.c +1
-0@@ -543,6 +543,7 @@ static const struct vop_output rk3399_output = { .hdmi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 13), .edp_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 14), .mipi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 15), + .mipi_dual_channel_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 3), };static const struct vop_data rk3399_vop_big = {
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerRe: [PATCH v5 7/7] drm/rockchip: dsi: add dual mipi support
Hi Andrzej,
Am Montag, 27. August 2018, 13:34:07 CEST schrieb Andrzej Hajda:
Quoted 117 lines · Heiko Stuebner
Quoted 116 lines
Add the Rockchip-sepcific dual-dsi setup and hook it into the VOP as well. As described in the general dual-dsi devicetree binding, the panel should define two input ports and point each of them to one of the used dsi- controllers, as well as declare one of them as clock-master. This is used to determine the dual-dsi state and get access to both controller instances.
Signed-off-by Heiko Stuebner <[email protected]>v4:
add component directly in probe when adding empty dsi slave controller
v5:
use driver-internal mechanism to find dual dsi slave--- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 105 ++++++++++++++++++ drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 1 + drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 + drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 4 + drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 1 + 5 files changed, 114 insertions(+)drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +38
-0@@ -218,6 +218,10 @@ struct dw_mipi_dsi_rockchip {struct clk *grf_clk;struct clk *phy_cfg_clk; +/* dual-channel */ +bool is_slave; +struct dw_mipi_dsi_rockchip *slave; +unsigned int lane_mbps;/* per lane */ u16 input_div;u16 feedback_div;@@ -226,6 +230,7 @@ struct dw_mipi_dsi_rockchip {struct dw_mipi_dsi *dmd;const struct rockchip_dw_dsi_chip_data *cdata;struct dw_mipi_dsi_plat_data pdata; +int devcnt; };struct dphy_pll_parameter_map {@@ -602,6 +607,8 @@ dw_mipi_dsi_encoder_atomic_check(struct drm_encoder *encoder, } s->output_type =DRM_MODE_CONNECTOR_DSI ; +if (dsi->slave) + s->output_flags =ROCKCHIP_OUTPUT_DSI_DUAL ;return 0 ; }@@ -617,6 +624,8 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder)return ;pm_runtime_get_sync (dsi->dev); +if (dsi->slave) +pm_runtime_get_sync (dsi->slave->dev);/* * For the RK3399, the clk of grf must be enabled before writing grf @@ -630,6 +639,8 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder) }dw_mipi_dsi_rockchip_config (dsi, mux); +if (dsi->slave) +dw_mipi_dsi_rockchip_config (dsi->slave, mux);clk_disable_unprepare (dsi->grf_clk); }@@ -638,6 +649,8 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder) {struct dw_mipi_dsi_rockchip *dsi =to_dsi (encoder); +if (dsi->slave) +pm_runtime_put (dsi->slave->dev);pm_runtime_put (dsi->dev); }@@ -673,14 +686,76 @@ static int rockchip_dsi_drm_create_encoder(struct dw_mipi_dsi_rockchip *dsi,return 0 ; } +static int dw_mipi_dsi_rockchip_match_second (struct device *dev,void *data) +{ +struct dw_mipi_dsi_rockchip *dsi = data; +struct drm_bridge *bridge1, *bridge2; +struct drm_panel *panel1, *panel2; +int ret; + +if (dsi->dev->of_node == dev->of_node) +return 0 ; + + ret =drm_of_find_panel_or_bridge (dsi->dev->of_node,1 ,0 , + &panel1, &bridge1); +if (ret) +return ret; + + ret =drm_of_find_panel_or_bridge (dev->of_node,1 ,0 , + &panel2, &bridge2); +if (ret) +return ret; + +return (panel1 == panel2) && (bridge1 == bridge2); +} +static int dw_mipi_dsi_rockchip_bind (struct device *dev,struct device *master,void *data) {struct dw_mipi_dsi_rockchip *dsi =dev_get_drvdata (dev);struct drm_device *drm_dev = data; +struct device *second; +bool master1, master2;int ret;
Quoted 7 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c static int rockchip_dsi_drm_create_encoder(struct dw_mipi_dsi_rockchip *dsi, · line 723
Quoted 2 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +2
-0+ second =driver_find_device (dsi->dev->driver,NULL , dsi, + dw_mipi_dsi_rockchip_match_second);This function performs
get_deviceon the matched device, so you should probably call somewhereput_deviceto make the counter balanced. I hope second device is somehow guarded by component framework from being unbound in unexpected moments (ie. when in use by master).
Thanks for that catch, I'll add the put_device.
Quoted 78 lines
Quoted 64 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +46
-0+if (IS_ERR (second)) +return PTR_ERR (second); + +if (second) { + master1 =of_property_read_bool (dsi->dev->of_node, +"clock-master" ); + master2 =of_property_read_bool (second->of_node, +"clock-master" ); + +if (master1 && master2) { +DRM_DEV_ERROR (dsi->dev,"only one clock-master allowed\n" ); +return -EINVAL ; + } + +if (!master1 && !master2) { +DRM_DEV_ERROR (dsi->dev,"no clock-master defined\n" ); +return -EINVAL ; + } + +/* we are the slave in dual-DSI */ +if (!master1) { + dsi->is_slave = true; +return 0 ; + } + + dsi->slave =dev_get_drvdata (second); +if (!dsi->slave) { +DRM_DEV_ERROR (dev,"could not get slaves data\n" ); +return -ENODEV ; + } + + dsi->slave->is_slave = true; +dw_mipi_dsi_set_slave (dsi->dmd, dsi->slave->dmd); + } + ret =clk_prepare_enable (dsi->pllref_clk);if (ret) {DRM_DEV_ERROR (dev,"Failed to enable pllref_clk: %d\n" , ret);@@ -708,6 +783,9 @@ static void dw_mipi_dsi_rockchip_unbind(struct device *dev, {struct dw_mipi_dsi_rockchip *dsi =dev_get_drvdata (dev); +if (dsi->is_slave) +return ; +dw_mipi_dsi_unbind (dsi->dmd);clk_disable_unprepare (dsi->pllref_clk);@@ -749,6 +827,14 @@ static const struct dw_mipi_dsi_host_ops dw_mipi_dsi_rockchip_host_ops = { .detach = dw_mipi_dsi_rockchip_host_detach, }; +static int dw_mipi_dsi_rockchip_cnt_dev (struct device *dev,void *data) +{ +struct dw_mipi_dsi_rockchip *dsi = data; + + dsi->devcnt++; +return 0 ; +} +static int dw_mipi_dsi_rockchip_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c static int dw_mipi_dsi_rockchip_probe(struct platform_device *pdev) · line 927
Quoted 7 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +4
-0@@ -835,6 +921,22 @@ static int dw_mipi_dsi_rockchip_probe(struct platform_device *pdev) goto err_clkdisable; } +/* +* All dsi child devices will have been created, so we can check +* their number and add the component here if there will be no +* host-attach call. I guess you mean that in this point all child devices have been created (remove 'will'), but it may be false assumption, there is always possibility to create device on the fly - see
mipi_dsi_device_register_full. You cannot assume that in certain point in time there will be no more devices on the bus.
Quoted 2 lines
I am not sure of the purpose of this code. Why do you want to behave differently if there are no child devs?
That's all related to the suggestion of doing component_add in the host-attach callback. If the device doesn't have active children its component will never get added and the whole drm component structure will wait forever and never probe the drm driver, hence add the component when no child will be present.
[This is of course part of handling my empty dsi slave].
I don't think the whole dw-dsi driver currently expects more than one device to exist, while the DSI bus can address multiple devices.
With the changes in this series with component_add being called from dsi-attach, this creates even more issues with multiple devices, as component_add and component_del would be called multiple times for each dsi device on the bus.
Should I simply go back to my deferral if no panel found, or do you have another sugestion?
Thanks
Heiko
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v5 7/7] drm/rockchip: dsi: add dual mipi support
Quoted 206 lines · Heiko Stuebner
Hi Andrzej,
Am Montag, 27. August 2018, 13:34:07 CEST schrieb Andrzej Hajda:
Quoted 117 lines · Heiko Stuebner
Quoted 116 lines
Add the Rockchip-sepcific dual-dsi setup and hook it into the VOP as well. As described in the general dual-dsi devicetree binding, the panel should define two input ports and point each of them to one of the used dsi- controllers, as well as declare one of them as clock-master. This is used to determine the dual-dsi state and get access to both controller instances.
Signed-off-by Heiko Stuebner <[email protected]>v4:
add component directly in probe when adding empty dsi slave controller
v5:
use driver-internal mechanism to find dual dsi slave--- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 105 ++++++++++++++++++ drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 1 + drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 + drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 4 + drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 1 + 5 files changed, 114 insertions(+)drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +38
-0@@ -218,6 +218,10 @@ struct dw_mipi_dsi_rockchip {struct clk *grf_clk;struct clk *phy_cfg_clk; +/* dual-channel */ +bool is_slave; +struct dw_mipi_dsi_rockchip *slave; +unsigned int lane_mbps;/* per lane */ u16 input_div;u16 feedback_div;@@ -226,6 +230,7 @@ struct dw_mipi_dsi_rockchip {struct dw_mipi_dsi *dmd;const struct rockchip_dw_dsi_chip_data *cdata;struct dw_mipi_dsi_plat_data pdata; +int devcnt; };struct dphy_pll_parameter_map {@@ -602,6 +607,8 @@ dw_mipi_dsi_encoder_atomic_check(struct drm_encoder *encoder, } s->output_type =DRM_MODE_CONNECTOR_DSI ; +if (dsi->slave) + s->output_flags =ROCKCHIP_OUTPUT_DSI_DUAL ;return 0 ; }@@ -617,6 +624,8 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder)return ;pm_runtime_get_sync (dsi->dev); +if (dsi->slave) +pm_runtime_get_sync (dsi->slave->dev);/* * For the RK3399, the clk of grf must be enabled before writing grf @@ -630,6 +639,8 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder) }dw_mipi_dsi_rockchip_config (dsi, mux); +if (dsi->slave) +dw_mipi_dsi_rockchip_config (dsi->slave, mux);clk_disable_unprepare (dsi->grf_clk); }@@ -638,6 +649,8 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder) {struct dw_mipi_dsi_rockchip *dsi =to_dsi (encoder); +if (dsi->slave) +pm_runtime_put (dsi->slave->dev);pm_runtime_put (dsi->dev); }@@ -673,14 +686,76 @@ static int rockchip_dsi_drm_create_encoder(struct dw_mipi_dsi_rockchip *dsi,return 0 ; } +static int dw_mipi_dsi_rockchip_match_second (struct device *dev,void *data) +{ +struct dw_mipi_dsi_rockchip *dsi = data; +struct drm_bridge *bridge1, *bridge2; +struct drm_panel *panel1, *panel2; +int ret; + +if (dsi->dev->of_node == dev->of_node) +return 0 ; + + ret =drm_of_find_panel_or_bridge (dsi->dev->of_node,1 ,0 , + &panel1, &bridge1); +if (ret) +return ret; + + ret =drm_of_find_panel_or_bridge (dev->of_node,1 ,0 , + &panel2, &bridge2); +if (ret) +return ret; + +return (panel1 == panel2) && (bridge1 == bridge2); +} +static int dw_mipi_dsi_rockchip_bind (struct device *dev,struct device *master,void *data) {struct dw_mipi_dsi_rockchip *dsi =dev_get_drvdata (dev);struct drm_device *drm_dev = data; +struct device *second; +bool master1, master2;int ret;Quoted 6 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c static int rockchip_dsi_drm_create_encoder(struct dw_mipi_dsi_rockchip *dsi, · line 723
Quoted 2 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +2
-0+ second =driver_find_device (dsi->dev->driver,NULL , dsi, + dw_mipi_dsi_rockchip_match_second);This function performs
get_deviceon the matched device, so you should probably call somewhereput_deviceto make the counter balanced. I hope second device is somehow guarded by component framework from being unbound in unexpected moments (ie. when in use by master).Thanks for that catch, I'll add the
put_device.Quoted 77 lines
Quoted 64 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +46
-0+if (IS_ERR (second)) +return PTR_ERR (second); + +if (second) { + master1 =of_property_read_bool (dsi->dev->of_node, +"clock-master" ); + master2 =of_property_read_bool (second->of_node, +"clock-master" ); + +if (master1 && master2) { +DRM_DEV_ERROR (dsi->dev,"only one clock-master allowed\n" ); +return -EINVAL ; + } + +if (!master1 && !master2) { +DRM_DEV_ERROR (dsi->dev,"no clock-master defined\n" ); +return -EINVAL ; + } + +/* we are the slave in dual-DSI */ +if (!master1) { + dsi->is_slave = true; +return 0 ; + } + + dsi->slave =dev_get_drvdata (second); +if (!dsi->slave) { +DRM_DEV_ERROR (dev,"could not get slaves data\n" ); +return -ENODEV ; + } + + dsi->slave->is_slave = true; +dw_mipi_dsi_set_slave (dsi->dmd, dsi->slave->dmd); + } + ret =clk_prepare_enable (dsi->pllref_clk);if (ret) {DRM_DEV_ERROR (dev,"Failed to enable pllref_clk: %d\n" , ret);@@ -708,6 +783,9 @@ static void dw_mipi_dsi_rockchip_unbind(struct device *dev, {struct dw_mipi_dsi_rockchip *dsi =dev_get_drvdata (dev); +if (dsi->is_slave) +return ; +dw_mipi_dsi_unbind (dsi->dmd);clk_disable_unprepare (dsi->pllref_clk);@@ -749,6 +827,14 @@ static const struct dw_mipi_dsi_host_ops dw_mipi_dsi_rockchip_host_ops = { .detach = dw_mipi_dsi_rockchip_host_detach, }; +static int dw_mipi_dsi_rockchip_cnt_dev (struct device *dev,void *data) +{ +struct dw_mipi_dsi_rockchip *dsi = data; + + dsi->devcnt++; +return 0 ; +} +static int dw_mipi_dsi_rockchip_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c static int dw_mipi_dsi_rockchip_probe(struct platform_device *pdev) · line 927
Quoted 7 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +4
-0@@ -835,6 +921,22 @@ static int dw_mipi_dsi_rockchip_probe(struct platform_device *pdev) goto err_clkdisable; } +/* +* All dsi child devices will have been created, so we can check +* their number and add the component here if there will be no +* host-attach call. I guess you mean that in this point all child devices have been created (remove 'will'), but it may be false assumption, there is always possibility to create device on the fly - see
mipi_dsi_device_register_full. You cannot assume that in certain point in time there will be no more devices on the bus.
Quoted 7 lines
Quoted 2 lines
I am not sure of the purpose of this code. Why do you want to behave differently if there are no child devs?
That's all related to the suggestion of doing
component_addin the host-attach callback. If the device doesn't have active children its component will never get added and the whole drm component structure will wait forever and never probe the drm driver, hence add the component when no child will be present.
What wrong with it? If the resource is required, then consumer should wait for it, if there is a problem with provider it can be forever, I think it is clear and fair rule.
Quoted 1 line
[This is of course part of handling my empty dsi slave].
Could you elaborate it? If dsi slave has no downstream device why is it active at all?
Quoted 8 lines
I don't think the whole dw-dsi driver currently expects more than one device to exist, while the DSI bus can address multiple devices.
With the changes in this series with
component_addbeing called from dsi-attach, this creates even more issues with multiple devices, ascomponent_addandcomponent_delwould be called multiple times for each dsi device on the bus.
No, there is no rule of calling component_add every time from attach. The rule is to call component_add just when all required resources are gathered. If it can happen in dsi-attach call then it should be called from there. If you expect more devices on dsi bus you should call it on gathering the last one expected. But do you really have more than one dsi device attached to the same dsi master, if not I wouldn't care too much about only theoretical issues.
Regards
Andrzej
Quoted 10 lines
Should I simply go back to my deferral if no panel found, or do you have another sugestion?
Thanks
Heiko
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerRe: [PATCH v5 7/7] drm/rockchip: dsi: add dual mipi support
Hi Andrzej
Am Freitag, 21. September 2018, 08:11:16 CEST schrieb Andrzej Hajda:
Quoted 215 lines · Heiko Stuebner
Quoted 206 lines
Hi Andrzej,
Am Montag, 27. August 2018, 13:34:07 CEST schrieb Andrzej Hajda:
Quoted 117 lines · Heiko Stuebner
Quoted 116 lines
Add the Rockchip-sepcific dual-dsi setup and hook it into the VOP as well. As described in the general dual-dsi devicetree binding, the panel should define two input ports and point each of them to one of the used dsi- controllers, as well as declare one of them as clock-master. This is used to determine the dual-dsi state and get access to both controller instances.
Signed-off-by Heiko Stuebner <[email protected]>v4:
add component directly in probe when adding empty dsi slave controller
v5:
use driver-internal mechanism to find dual dsi slave--- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 105 ++++++++++++++++++ drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 1 + drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 + drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 4 + drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 1 + 5 files changed, 114 insertions(+)drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +38
-0@@ -218,6 +218,10 @@ struct dw_mipi_dsi_rockchip {struct clk *grf_clk;struct clk *phy_cfg_clk; +/* dual-channel */ +bool is_slave; +struct dw_mipi_dsi_rockchip *slave; +unsigned int lane_mbps;/* per lane */ u16 input_div;u16 feedback_div;@@ -226,6 +230,7 @@ struct dw_mipi_dsi_rockchip {struct dw_mipi_dsi *dmd;const struct rockchip_dw_dsi_chip_data *cdata;struct dw_mipi_dsi_plat_data pdata; +int devcnt; };struct dphy_pll_parameter_map {@@ -602,6 +607,8 @@ dw_mipi_dsi_encoder_atomic_check(struct drm_encoder *encoder, } s->output_type =DRM_MODE_CONNECTOR_DSI ; +if (dsi->slave) + s->output_flags =ROCKCHIP_OUTPUT_DSI_DUAL ;return 0 ; }@@ -617,6 +624,8 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder)return ;pm_runtime_get_sync (dsi->dev); +if (dsi->slave) +pm_runtime_get_sync (dsi->slave->dev);/* * For the RK3399, the clk of grf must be enabled before writing grf @@ -630,6 +639,8 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder) }dw_mipi_dsi_rockchip_config (dsi, mux); +if (dsi->slave) +dw_mipi_dsi_rockchip_config (dsi->slave, mux);clk_disable_unprepare (dsi->grf_clk); }@@ -638,6 +649,8 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder) {struct dw_mipi_dsi_rockchip *dsi =to_dsi (encoder); +if (dsi->slave) +pm_runtime_put (dsi->slave->dev);pm_runtime_put (dsi->dev); }@@ -673,14 +686,76 @@ static int rockchip_dsi_drm_create_encoder(struct dw_mipi_dsi_rockchip *dsi,return 0 ; } +static int dw_mipi_dsi_rockchip_match_second (struct device *dev,void *data) +{ +struct dw_mipi_dsi_rockchip *dsi = data; +struct drm_bridge *bridge1, *bridge2; +struct drm_panel *panel1, *panel2; +int ret; + +if (dsi->dev->of_node == dev->of_node) +return 0 ; + + ret =drm_of_find_panel_or_bridge (dsi->dev->of_node,1 ,0 , + &panel1, &bridge1); +if (ret) +return ret; + + ret =drm_of_find_panel_or_bridge (dev->of_node,1 ,0 , + &panel2, &bridge2); +if (ret) +return ret; + +return (panel1 == panel2) && (bridge1 == bridge2); +} +static int dw_mipi_dsi_rockchip_bind (struct device *dev,struct device *master,void *data) {struct dw_mipi_dsi_rockchip *dsi =dev_get_drvdata (dev);struct drm_device *drm_dev = data; +struct device *second; +bool master1, master2;int ret;Quoted 6 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c static int rockchip_dsi_drm_create_encoder(struct dw_mipi_dsi_rockchip *dsi, · line 723
Quoted 2 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +2
-0+ second =driver_find_device (dsi->dev->driver,NULL , dsi, + dw_mipi_dsi_rockchip_match_second);This function performs
get_deviceon the matched device, so you should probably call somewhereput_deviceto make the counter balanced. I hope second device is somehow guarded by component framework from being unbound in unexpected moments (ie. when in use by master).Thanks for that catch, I'll add the
put_device.Quoted 77 lines
Quoted 64 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +46
-0+if (IS_ERR (second)) +return PTR_ERR (second); + +if (second) { + master1 =of_property_read_bool (dsi->dev->of_node, +"clock-master" ); + master2 =of_property_read_bool (second->of_node, +"clock-master" ); + +if (master1 && master2) { +DRM_DEV_ERROR (dsi->dev,"only one clock-master allowed\n" ); +return -EINVAL ; + } + +if (!master1 && !master2) { +DRM_DEV_ERROR (dsi->dev,"no clock-master defined\n" ); +return -EINVAL ; + } + +/* we are the slave in dual-DSI */ +if (!master1) { + dsi->is_slave = true; +return 0 ; + } + + dsi->slave =dev_get_drvdata (second); +if (!dsi->slave) { +DRM_DEV_ERROR (dev,"could not get slaves data\n" ); +return -ENODEV ; + } + + dsi->slave->is_slave = true; +dw_mipi_dsi_set_slave (dsi->dmd, dsi->slave->dmd); + } + ret =clk_prepare_enable (dsi->pllref_clk);if (ret) {DRM_DEV_ERROR (dev,"Failed to enable pllref_clk: %d\n" , ret);@@ -708,6 +783,9 @@ static void dw_mipi_dsi_rockchip_unbind(struct device *dev, {struct dw_mipi_dsi_rockchip *dsi =dev_get_drvdata (dev); +if (dsi->is_slave) +return ; +dw_mipi_dsi_unbind (dsi->dmd);clk_disable_unprepare (dsi->pllref_clk);@@ -749,6 +827,14 @@ static const struct dw_mipi_dsi_host_ops dw_mipi_dsi_rockchip_host_ops = { .detach = dw_mipi_dsi_rockchip_host_detach, }; +static int dw_mipi_dsi_rockchip_cnt_dev (struct device *dev,void *data) +{ +struct dw_mipi_dsi_rockchip *dsi = data; + + dsi->devcnt++; +return 0 ; +} +static int dw_mipi_dsi_rockchip_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c static int dw_mipi_dsi_rockchip_probe(struct platform_device *pdev) · line 927
Quoted 7 lines
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +4
-0@@ -835,6 +921,22 @@ static int dw_mipi_dsi_rockchip_probe(struct platform_device *pdev) goto err_clkdisable; } +/* +* All dsi child devices will have been created, so we can check +* their number and add the component here if there will be no +* host-attach call. I guess you mean that in this point all child devices have been created (remove 'will'), but it may be false assumption, there is always possibility to create device on the fly - see
mipi_dsi_device_register_full. You cannot assume that in certain point in time there will be no more devices on the bus.Quoted 7 lines
Quoted 2 lines
I am not sure of the purpose of this code. Why do you want to behave differently if there are no child devs?
That's all related to the suggestion of doing
component_addin the host-attach callback. If the device doesn't have active children its component will never get added and the whole drm component structure will wait forever and never probe the drm driver, hence add the component when no child will be present.
Quoted 8 lines
What wrong with it? If the resource is required, then consumer should wait for it, if there is a problem with provider it can be forever, I think it is clear and fair rule.
Quoted 1 line
[This is of course part of handling my empty dsi slave].
Could you elaborate it? If dsi slave has no downstream device why is it active at all?
As in all instances before, you were right on pointing out the flaw here :-) DSI devices can of course also sit on completely other buses, like i2c and attach from there by creating their own dsi device on the bus.
I've prepared v6 which should address that in a more elegant manner while keeping the component_attach in the host-attach callback.
Thanks
Heiko
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel