drm/msm: Use device graph to parse connected panels
Subsystems (4)
v2 cover drm/msm: Use device graph to parse connected panels
drm/msm currently relies on phandles/child nodes to get data about connected panels to LVDS and DSI. This method has known limitations.
Use device graphs in DT to represent the connections between the encoder outputs and the panels. Use of_graph helpers in the driver to get the panel device node.
The usage of device graphs should also simplify management in dual dsi mode. I haven't tried this out yet, though.
changes in v2:
- Fix usage of of_node_put()
Archit Taneja (3):
drm/msm: dsi host: add missing of_node_put()
drm/msm: dsi host: Use device graph parsing to parse connected panel drm/msm: mdp4 lvds: get panel node via of graph parsing
Documentation/devicetree/bindings/drm/msm/dsi.txt | 15 ++++++ drivers/gpu/drm/msm/dsi/dsi_host.c | 62 ++++++++++++++++++----- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 33 ++++++++---- drivers/gpu/drm/msm/msm_drv.h | 1 + 4 files changed, 88 insertions(+), 23 deletions(-)
Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 1/3 drm/msm: dsi host: add missing of_node_put()
Decrement device node refcount if of_get_child_by_name is successfully called.
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/dsi/dsi_host.c +5 -1
@@ -1586,8 +1586,12 @@ int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer) node =of_get_child_by_name (msm_host->pdev->dev.of_node,"panel" );if (node) { -if (!of_drm_find_panel (node)) +if (!of_drm_find_panel (node)) { +of_node_put (node);return -EPROBE_DEFER ; + } + +of_node_put (node); } } }
Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 2/3 drm/msm: dsi host: Use device graph parsing to parse connected panel
In reply to Archit TanejaThe dsi host looks for the connected panel node by parsing for a child named 'panel'. This hierarchy isn't very flexible. The connected panel is forced to be a child to the dsi host, and hence, a mipi dsi device. This isn't suitable for dsi devices that don't use mipi dsi as their control bus.
Follow the of_graph approach of creating ports and endpoints to represent the connections between the dsi host and the panel connected to it. In our case, the dsi host will only have one output port, linked to the panel's input port.
Update DT binding documentation with device graph usage info.
--- Documentation/devicetree/bindings/drm/msm/dsi.txt | 15 ++++++ drivers/gpu/drm/msm/dsi/dsi_host.c | 66 ++++++++++++++++------- 2 files changed, 63 insertions(+), 18 deletions(-)
Documentation/devicetree/bindings/drm/msm/dsi.txt +15 -0
@@ -25,6 +25,9 @@ Required properties: - vddio-supply: phandle to vdd-io regulator device node - vdda-supply: phandle to vdda regulator device node - qcom,dsi-phy: phandle to DSI PHY device node +- port: DSI controller output port. This contains one endpoint subnode, with its + remote-endpoint set to the phandle of the connected panel's endpoint. + See Documentation/devicetree/bindings/graph.txt for device graph info. Optional properties: - panel@0: Node of panel connected to this DSI controller.
@@ -101,6 +104,18 @@ Example: power-supply = <...>; backlight = <...>; + + port { + panel_in: endpoint { + remote-endpoint = <&dsi0_out>; + }; + }; + }; + + port { + dsi0_out: endpoint { + remote-endpoint = <&panel_in>; + }; }; };
drivers/gpu/drm/msm/dsi/dsi_host.c +48 -18
105 lines not on this page · raw message
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
PATCH v2 3/3 drm/msm: mdp4 lvds: get panel node via of graph parsing
In reply to Archit TanejaWe currently get the output connected to LVDS by looking for a phandle called 'qcom,lvds-panel' under the mdp DT node.
Use the more standard of_graph approach to create an lvds output port, and retrieve the panel node from the port's endpoint data.
--- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 33 ++++++++++++++++++++++++--------- drivers/gpu/drm/msm/msm_drv.h | 1 + 2 files changed, 25 insertions(+), 9 deletions(-)
drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c +24 -9
@@ -241,22 +241,37 @@ int mdp4_enable(struct mdp4_kms *mdp4_kms) }#ifdef CONFIG_OF -static struct drm_panel *detect_panel (struct drm_device *dev,const char *name) +static struct drm_panel *detect_panel (struct drm_device *dev) { -struct device_node *n; +struct device_node *endpoint, *panel_node; +struct device_node *np = dev->dev->of_node;struct drm_panel *panel =NULL ; - n =of_parse_phandle (dev->dev->of_node, name,0 ); -if (n) { - panel =of_drm_find_panel (n); -if (!panel) - panel =ERR_PTR (-EPROBE_DEFER ); + endpoint =of_graph_get_next_endpoint (np,NULL ); +if (IS_ERR (endpoint)) { +dev_err (dev->dev,"no valid endpoint\n" ); +return ERR_CAST (endpoint); + } + + panel_node =of_graph_get_remote_port_parent (endpoint); +if (IS_ERR (panel_node)) { +dev_err (dev->dev,"no valid panel node\n" ); +of_node_put (endpoint); +return ERR_CAST (panel_node); + } + +of_node_put (endpoint); + + panel =of_drm_find_panel (panel_node); +if (IS_ERR (panel)) { +of_node_put (panel_node); +return ERR_PTR (-EPROBE_DEFER ); }return panel; }#else -static struct drm_panel *detect_panel (struct drm_device *dev,const char *name) +static struct drm_panel *detect_panel (struct drm_device *dev) {// ??? maybe use a module param to specify which panel is attached? }
@@ -294,7 +309,7 @@ static int modeset_init(struct mdp4_kms *mdp4_kms)* Setup the LCDC/LVDS path: RGB2 -> DMA_P -> LCDC -> LVDS: */ - panel =detect_panel (dev,"qcom,lvds-panel" ); + panel =detect_panel (dev);if (IS_ERR (panel)) { ret =PTR_ERR (panel);dev_err (dev->dev,"failed to detect LVDS panel: %d\n" , ret);
drivers/gpu/drm/msm/msm_drv.h +1 -0
@@ -30,6 +30,7 @@#include <linux/list.h> #include <linux/iommu.h> #include <linux/types.h> +#include <linux/of_graph.h> #include <asm/sizes.h> #ifndef CONFIG_OF
Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
v3 cover drm/msm: Use device graph to parse connected panels
In reply to Archit Tanejadrm/msm currently relies on phandles/child nodes to get data about connected panels to LVDS and DSI. This method has known limitations.
Use device graphs in DT to represent the connections between the encoder outputs and the panels. Use of_graph helpers in the driver to get the panel device node.
The usage of device graphs should also simplify management in dual dsi mode. I haven't tried this out yet, though.
changes in v3:
- Some changes suggested by Hai
- error handling when using of_graph helpers
changes in v2:
- Fix usage of of_node_put()
Archit Taneja (3):
drm/msm: dsi host: add missing of_node_put()
drm/msm: dsi host: Use device graph parsing to parse connected panel drm/msm: mdp4 lvds: get panel node via of graph parsing
Documentation/devicetree/bindings/drm/msm/dsi.txt | 15 +++++ drivers/gpu/drm/msm/dsi/dsi_host.c | 68 ++++++++++++++++++----- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 33 ++++++++--- drivers/gpu/drm/msm/msm_drv.h | 1 + 4 files changed, 93 insertions(+), 24 deletions(-)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
PATCH v3 1/3 drm/msm: dsi host: add missing of_node_put()
Decrement device node refcount if of_get_child_by_name is successfully called.
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/dsi/dsi_host.c +5 -1
@@ -1582,8 +1582,12 @@ int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer) node =of_get_child_by_name (msm_host->pdev->dev.of_node,"panel" );if (node) { -if (!of_drm_find_panel (node)) +if (!of_drm_find_panel (node)) { +of_node_put (node);return -EPROBE_DEFER ; + } + +of_node_put (node); } } }
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
PATCH v3 2/3 drm/msm: dsi host: Use device graph parsing to parse connected panel
In reply to Archit TanejaThe dsi host looks for the connected panel node by parsing for a child named 'panel'. This hierarchy isn't very flexible. The connected panel is forced to be a child to the dsi host, and hence, a mipi dsi device. This isn't suitable for dsi devices that don't use mipi dsi as their control bus.
Follow the of_graph approach of creating ports and endpoints to represent the connections between the dsi host and the panel connected to it. In our case, the dsi host will only have one output port, linked to the panel's input port.
Update DT binding documentation with device graph usage info.
v3:
- Fix return value checks of of_graph_* calls.
- Don't make port a mandatory DT property
- Fix defer check when no panel node specified
- Rename parse_dt func to align with other dsi_host funcs
--- Documentation/devicetree/bindings/drm/msm/dsi.txt | 15 +++++ drivers/gpu/drm/msm/dsi/dsi_host.c | 72 +++++++++++++++++------ 2 files changed, 68 insertions(+), 19 deletions(-)
Documentation/devicetree/bindings/drm/msm/dsi.txt +15 -0
@@ -38,6 +38,9 @@ Optional properties: driving a 2-DSI panel whose 2 links need receive command simultaneously. - interrupt-parent: phandle to the MDP block if the interrupt signal is routed through MDP block +- port: DSI controller output port. This contains one endpoint subnode, with its + remote-endpoint set to the phandle of the connected panel's endpoint. + See Documentation/devicetree/bindings/graph.txt for device graph info. DSI PHY: Required properties:
@@ -101,6 +104,18 @@ Example: power-supply = <...>; backlight = <...>; + + port { + panel_in: endpoint { + remote-endpoint = <&dsi0_out>; + }; + }; + }; + + port { + dsi0_out: endpoint { + remote-endpoint = <&panel_in>; + }; }; };
drivers/gpu/drm/msm/dsi/dsi_host.c +53 -19
112 lines not on this page · raw message
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
PATCH v3 3/3 drm/msm: mdp4 lvds: get panel node via of graph parsing
In reply to Archit TanejaWe currently get the output connected to LVDS by looking for a phandle called 'qcom,lvds-panel' under the mdp DT node.
Use the more standard of_graph approach to create an lvds output port, and retrieve the panel node from the port's endpoint data.
v3
- Fix return value checks of of_graph_* calls.
--- drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 33 ++++++++++++++++++++++++--------- drivers/gpu/drm/msm/msm_drv.h | 1 + 2 files changed, 25 insertions(+), 9 deletions(-)
drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c +24 -9
@@ -241,22 +241,37 @@ int mdp4_enable(struct mdp4_kms *mdp4_kms) }#ifdef CONFIG_OF -static struct drm_panel *detect_panel (struct drm_device *dev,const char *name) +static struct drm_panel *detect_panel (struct drm_device *dev) { -struct device_node *n; +struct device_node *endpoint, *panel_node; +struct device_node *np = dev->dev->of_node;struct drm_panel *panel =NULL ; - n =of_parse_phandle (dev->dev->of_node, name,0 ); -if (n) { - panel =of_drm_find_panel (n); -if (!panel) - panel =ERR_PTR (-EPROBE_DEFER ); + endpoint =of_graph_get_next_endpoint (np,NULL ); +if (!endpoint) { +dev_err (dev->dev,"no valid endpoint\n" ); +return ERR_PTR (-ENODEV ); + } + + panel_node =of_graph_get_remote_port_parent (endpoint); +if (!panel_node) { +dev_err (dev->dev,"no valid panel node\n" ); +of_node_put (endpoint); +return ERR_PTR (-ENODEV ); + } + +of_node_put (endpoint); + + panel =of_drm_find_panel (panel_node); +if (!panel) { +of_node_put (panel_node); +return ERR_PTR (-EPROBE_DEFER ); }return panel; }#else -static struct drm_panel *detect_panel (struct drm_device *dev,const char *name) +static struct drm_panel *detect_panel (struct drm_device *dev) {// ??? maybe use a module param to specify which panel is attached? }
@@ -294,7 +309,7 @@ static int modeset_init(struct mdp4_kms *mdp4_kms)* Setup the LCDC/LVDS path: RGB2 -> DMA_P -> LCDC -> LVDS: */ - panel =detect_panel (dev,"qcom,lvds-panel" ); + panel =detect_panel (dev);if (IS_ERR (panel)) { ret =PTR_ERR (panel);dev_err (dev->dev,"failed to detect LVDS panel: %d\n" , ret);
drivers/gpu/drm/msm/msm_drv.h +1 -0
@@ -30,6 +30,7 @@#include <linux/list.h> #include <linux/iommu.h> #include <linux/types.h> +#include <linux/of_graph.h> #include <asm/sizes.h> #ifndef CONFIG_OF
Signature · 7 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel