1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-04 18:22:02 +02:00

video: rockchip: Add video bridge support to VOP driver

This is used for video output using video bridge implementation of
MIPI-DSI, like with the recently added dw_mipi_dsi_rockchip.c
driver.

The original code path when the UCLASS_DISPLAY device is found is
untouched. The video bridge branch is taken only when the
UCLASS_VIDEO_BRIDGE device is found at the remote endpoint's parent.

This was tested to work on Pinephone Pro.

Signed-off-by: Ondrej Jirman <megi@xff.cz>
Cc: Anatolij Gustschin <agust@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Philipp Tomsich <philipp.tomsich@vrull.eu>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Chris Morgan <macromorgan@hotmail.com>
This commit is contained in:
Ondrej Jirman
2023-05-21 17:14:29 +02:00
parent c3f80d9366
commit a259c15d4d
2 changed files with 74 additions and 21 deletions

View File

@@ -10,6 +10,9 @@
menuconfig VIDEO_ROCKCHIP menuconfig VIDEO_ROCKCHIP
bool "Enable Rockchip Video Support" bool "Enable Rockchip Video Support"
select VIDEO_BRIDGE
select VIDEO_MIPI_DSI
select PANEL
depends on VIDEO depends on VIDEO
help help
Rockchip SoCs provide video output capabilities for High-Definition Rockchip SoCs provide video output capabilities for High-Definition

View File

@@ -10,10 +10,13 @@
#include <dm/device_compat.h> #include <dm/device_compat.h>
#include <edid.h> #include <edid.h>
#include <log.h> #include <log.h>
#include <mipi_dsi.h>
#include <panel.h>
#include <regmap.h> #include <regmap.h>
#include <reset.h> #include <reset.h>
#include <syscon.h> #include <syscon.h>
#include <video.h> #include <video.h>
#include <video_bridge.h>
#include <asm/global_data.h> #include <asm/global_data.h>
#include <asm/gpio.h> #include <asm/gpio.h>
#include <asm/io.h> #include <asm/io.h>
@@ -27,6 +30,7 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/err.h> #include <linux/err.h>
#include <power/regulator.h> #include <power/regulator.h>
#include "rk_vop.h" #include "rk_vop.h"
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
@@ -257,6 +261,9 @@ static int rk_display_init(struct udevice *dev, ulong fbbase, ofnode ep_node)
ofnode remote; ofnode remote;
const char *compat; const char *compat;
struct reset_ctl dclk_rst; struct reset_ctl dclk_rst;
struct udevice *bridge;
//struct mipi_dsi_device *dsi;
struct udevice *panel;
debug("%s(%s, 0x%lx, %s)\n", __func__, debug("%s(%s, 0x%lx, %s)\n", __func__,
dev_read_name(dev), fbbase, ofnode_get_name(ep_node)); dev_read_name(dev), fbbase, ofnode_get_name(ep_node));
@@ -298,6 +305,10 @@ static int rk_display_init(struct udevice *dev, ulong fbbase, ofnode ep_node)
return -EINVAL; return -EINVAL;
} }
uclass_find_device_by_ofnode(UCLASS_VIDEO_BRIDGE, remote, &bridge);
if (bridge)
break;
uclass_find_device_by_ofnode(UCLASS_DISPLAY, remote, &disp); uclass_find_device_by_ofnode(UCLASS_DISPLAY, remote, &disp);
if (disp) if (disp)
break; break;
@@ -326,27 +337,57 @@ static int rk_display_init(struct udevice *dev, ulong fbbase, ofnode ep_node)
} }
debug("vop_id=%d\n", vop_id); debug("vop_id=%d\n", vop_id);
disp_uc_plat = dev_get_uclass_plat(disp); if (bridge) {
debug("Found device '%s', disp_uc_priv=%p\n", disp->name, disp_uc_plat); /* video bridge detected, probe it */
if (display_in_use(disp)) { ret = device_probe(bridge);
debug(" - device in use\n"); if (ret) {
return -EBUSY; printf("%s: device '%s' bridge won't probe (ret=%d)\n",
} __func__, dev->name, ret);
return ret;
}
/* Attach the DSI controller and the display to the bridge. */
ret = video_bridge_attach(bridge);
if (ret) {
printf("Failed to attach video bridge: %d\n", ret);
return ret;
}
disp_uc_plat->source_id = remote_vop_id; /* Get the panel device (TODO: fetch it from the bridge somehow) */
disp_uc_plat->src_dev = dev; ret = uclass_first_device_err(UCLASS_PANEL, &panel);
if (ret) {
printf("Panel device error: %d\n", ret);
return ret;
}
ret = panel_get_display_timing(panel, &timing);
if (ret) {
debug("%s: Failed to read timings\n", __func__);
return ret;
}
} else {
disp_uc_plat = dev_get_uclass_plat(disp);
debug("Found device '%s', disp_uc_priv=%p\n", disp->name, disp_uc_plat);
if (display_in_use(disp)) {
debug(" - device in use\n");
return -EBUSY;
}
ret = device_probe(disp); disp_uc_plat->source_id = remote_vop_id;
if (ret) { disp_uc_plat->src_dev = dev;
debug("%s: device '%s' display won't probe (ret=%d)\n",
__func__, dev->name, ret);
return ret;
}
ret = display_read_timing(disp, &timing); ret = device_probe(disp);
if (ret) { if (ret) {
debug("%s: Failed to read timings\n", __func__); debug("%s: device '%s' display won't probe (ret=%d)\n",
return ret; __func__, dev->name, ret);
return ret;
}
ret = display_read_timing(disp, &timing);
if (ret) {
debug("%s: Failed to read timings\n", __func__);
return ret;
}
} }
ret = clk_get_by_index(dev, 1, &clk); ret = clk_get_by_index(dev, 1, &clk);
@@ -383,9 +424,18 @@ static int rk_display_init(struct udevice *dev, ulong fbbase, ofnode ep_node)
rkvop_enable(dev, fbbase, 1 << l2bpp, &timing, &dclk_rst); rkvop_enable(dev, fbbase, 1 << l2bpp, &timing, &dclk_rst);
ret = display_enable(disp, 1 << l2bpp, &timing); if (bridge) {
if (ret) /* Attach the DSI controller and the display to the bridge. */
return ret; ret = video_bridge_set_backlight(bridge, 60);
if (ret) {
printf("Failed to start the video bridge: %d\n", ret);
return ret;
}
} else {
ret = display_enable(disp, 1 << l2bpp, &timing);
if (ret)
return ret;
}
uc_priv->xsize = timing.hactive.typ; uc_priv->xsize = timing.hactive.typ;
uc_priv->ysize = timing.vactive.typ; uc_priv->ysize = timing.vactive.typ;