[PATCH 11/11] drm/bridge: tc358768: Add DRM_BRIDGE_ATTACH_NO_CONNECTOR support
Tomi Valkeinen
tomi.valkeinen at ideasonboard.com
Mon Aug 14 13:29:22 UTC 2023
Hi Sam,
On 14/08/2023 13:10, Sam Ravnborg wrote:
> Hi Tomi,
>
>> From c13c691bd8826b978325575be9a87f577b83b86b Mon Sep 17 00:00:00 2001
>> From: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
>> Date: Mon, 14 Aug 2023 13:02:23 +0300
>> Subject: [PATCH] drm/bridge: tc358768: fix 'Add DRM_BRIDGE_ATTACH_NO_CONNECTOR
>> support'
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
>> ---
>> drivers/gpu/drm/bridge/tc358768.c | 56 +++++++++++++------------------
>> 1 file changed, 24 insertions(+), 32 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/bridge/tc358768.c b/drivers/gpu/drm/bridge/tc358768.c
>> index 82ea4d9a814a..9705ce1bd028 100644
>> --- a/drivers/gpu/drm/bridge/tc358768.c
>> +++ b/drivers/gpu/drm/bridge/tc358768.c
>> @@ -455,8 +455,6 @@ static int tc358768_dsi_host_detach(struct mipi_dsi_host *host,
>> struct tc358768_priv *priv = dsi_host_to_tc358768(host);
>>
>> drm_bridge_remove(&priv->bridge);
>> - if (priv->output.panel)
>> - drm_panel_bridge_remove(priv->output.next_bridge);
>>
>> return 0;
>> }
>> @@ -531,49 +529,42 @@ static int tc358768_bridge_attach(struct drm_bridge *bridge,
>> enum drm_bridge_attach_flags flags)
>> {
>> struct tc358768_priv *priv = bridge_to_tc358768(bridge);
>> + struct drm_bridge *next_bridge;
>> + struct drm_panel *panel;
>> + int ret;
>>
>> if (!drm_core_check_feature(bridge->dev, DRIVER_ATOMIC)) {
>> dev_err(priv->dev, "needs atomic updates support\n");
>> return -ENOTSUPP;
>> }
>>
>> - if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
>> - struct device_node *node;
>> -
>> - /* Get the next bridge, connected to port at 1. */
>> - node = of_graph_get_remote_node(priv->dev->of_node, 1, -1);
>> - if (!node)
>> - return -ENODEV;
>> -
>> - priv->output.next_bridge = of_drm_find_bridge(node);
>> - of_node_put(node);
>> - if (!priv->output.next_bridge)
>> - return -EPROBE_DEFER;
>> - } else {
>> - struct drm_bridge *bridge;
>> - struct drm_panel *panel;
>> - int ret;
>> -
>> - ret = drm_of_find_panel_or_bridge(priv->dev->of_node, 1, 0,
>> - &panel, &bridge);
>> - if (ret)
>> - return ret;
>> -
>> - if (panel) {
>> - bridge = drm_panel_bridge_add_typed(panel,
>> - DRM_MODE_CONNECTOR_DSI);
>> - if (IS_ERR(bridge))
>> - return PTR_ERR(bridge);
>> - }
>> + ret = drm_of_find_panel_or_bridge(priv->dev->of_node, 1, -1, &panel,
>> + &next_bridge);
>
> I think the right way is to wrap the panel in a bridge,
> so something like:
>
> next_bridge = devm_drm_of_get_bridge(dev, priv->dev->of_node, 1, -1)
>
> if (IS_ERR(next_bridge))
> return ...
> priv->output.next_bridge = next_bridge;
I tried that, but I had trouble with the cleanup side.
In the fixup patch I attached in my reply to Maxim I used
drm_of_find_panel_or_bridge() + drm_panel_bridge_add_typed(), and on
bridge_detach callback I used drm_panel_bridge_remove() (if there is a
panel). This worked for me, but it does feel like a bit too much work
for a driver to do.
Tomi
More information about the dri-devel
mailing list