mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-09 06:14:34 +02:00
of_drm_find_bridge() is deprecated. Move to its replacement
of_drm_find_and_get_bridge() which gets a bridge reference, and ensure it
is put when done.
omapdss_device_init_output() can take one bridge pointer in out->bridge or
two pointers in out->bridge and out->next_bridge. Ensure each has a
corresponding drm_bridge_get() and add drm_bridge_put() calls in the
cleanup code.
Also slightly change the initial code assigning out->panel and out->bridge
to ensure and clarify that either out->panel or out->bridge is set in the
function prologue, not both. If both were set, the 'if (out->panel){...}'
code that follows would overwrite out->bridge without having put the
reference.
Finally, take a reference in case a panel_bridge is added using
drm_panel_bridge_add(). This ensures we always need to put a reference,
which came either from of_drm_find_and_get_bridge() or by the
drm_panel_bridge_add+drm_bridge_get() branch.
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20260402-drm-bridge-alloc-getput-drm_of_find_bridge-4-v4-4-421781c8c061@bootlin.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
140 lines
3.1 KiB
C
140 lines
3.1 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com/
|
|
* Author: Archit Taneja <archit@ti.com>
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/of.h>
|
|
#include <linux/of_graph.h>
|
|
|
|
#include <drm/drm_bridge.h>
|
|
#include <drm/drm_panel.h>
|
|
|
|
#include "dss.h"
|
|
#include "omapdss.h"
|
|
|
|
int omapdss_device_init_output(struct omap_dss_device *out,
|
|
struct drm_bridge *local_bridge)
|
|
{
|
|
struct device_node *remote_node;
|
|
int ret;
|
|
|
|
remote_node = of_graph_get_remote_node(out->dev->of_node,
|
|
out->of_port, 0);
|
|
if (!remote_node) {
|
|
dev_dbg(out->dev, "failed to find video sink\n");
|
|
return 0;
|
|
}
|
|
|
|
out->panel = of_drm_find_panel(remote_node);
|
|
if (IS_ERR(out->panel))
|
|
out->panel = NULL;
|
|
|
|
if (!out->panel)
|
|
out->bridge = of_drm_find_and_get_bridge(remote_node);
|
|
|
|
of_node_put(remote_node);
|
|
|
|
if (out->panel) {
|
|
struct drm_bridge *bridge;
|
|
|
|
bridge = drm_panel_bridge_add(out->panel);
|
|
if (IS_ERR(bridge)) {
|
|
dev_err(out->dev,
|
|
"unable to create panel bridge (%ld)\n",
|
|
PTR_ERR(bridge));
|
|
ret = PTR_ERR(bridge);
|
|
goto error;
|
|
}
|
|
|
|
out->bridge = drm_bridge_get(bridge);
|
|
}
|
|
|
|
if (local_bridge) {
|
|
if (!out->bridge) {
|
|
ret = -EPROBE_DEFER;
|
|
goto error;
|
|
}
|
|
|
|
out->next_bridge = out->bridge;
|
|
out->bridge = drm_bridge_get(local_bridge);
|
|
}
|
|
|
|
if (!out->bridge) {
|
|
ret = -EPROBE_DEFER;
|
|
goto error;
|
|
}
|
|
|
|
return 0;
|
|
|
|
error:
|
|
omapdss_device_cleanup_output(out);
|
|
return ret;
|
|
}
|
|
|
|
void omapdss_device_cleanup_output(struct omap_dss_device *out)
|
|
{
|
|
if (out->bridge && out->panel)
|
|
drm_panel_bridge_remove(out->next_bridge ?
|
|
out->next_bridge : out->bridge);
|
|
|
|
drm_bridge_put(out->next_bridge);
|
|
drm_bridge_put(out->bridge);
|
|
}
|
|
|
|
void dss_mgr_set_timings(struct omap_dss_device *dssdev,
|
|
const struct videomode *vm)
|
|
{
|
|
omap_crtc_dss_set_timings(dssdev->dss->mgr_ops_priv,
|
|
dssdev->dispc_channel, vm);
|
|
}
|
|
|
|
void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
|
|
const struct dss_lcd_mgr_config *config)
|
|
{
|
|
omap_crtc_dss_set_lcd_config(dssdev->dss->mgr_ops_priv,
|
|
dssdev->dispc_channel, config);
|
|
}
|
|
|
|
int dss_mgr_enable(struct omap_dss_device *dssdev)
|
|
{
|
|
return omap_crtc_dss_enable(dssdev->dss->mgr_ops_priv,
|
|
dssdev->dispc_channel);
|
|
}
|
|
|
|
void dss_mgr_disable(struct omap_dss_device *dssdev)
|
|
{
|
|
omap_crtc_dss_disable(dssdev->dss->mgr_ops_priv,
|
|
dssdev->dispc_channel);
|
|
}
|
|
|
|
void dss_mgr_start_update(struct omap_dss_device *dssdev)
|
|
{
|
|
omap_crtc_dss_start_update(dssdev->dss->mgr_ops_priv,
|
|
dssdev->dispc_channel);
|
|
}
|
|
|
|
int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
|
|
void (*handler)(void *), void *data)
|
|
{
|
|
struct dss_device *dss = dssdev->dss;
|
|
|
|
return omap_crtc_dss_register_framedone(dss->mgr_ops_priv,
|
|
dssdev->dispc_channel,
|
|
handler, data);
|
|
}
|
|
|
|
void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
|
|
void (*handler)(void *), void *data)
|
|
{
|
|
struct dss_device *dss = dssdev->dss;
|
|
|
|
omap_crtc_dss_unregister_framedone(dss->mgr_ops_priv,
|
|
dssdev->dispc_channel,
|
|
handler, data);
|
|
}
|