Skip to content

Commit 301618e

Browse files
Andy Yanmmind
authored andcommitted
drm/rockchip: vop2: Introduce vop hardware version
There is a version number hardcoded in the VOP VERSION_INFO register, and the version number increments sequentially based on the production order of the SoC. So using this version number to distinguish different VOP features will simplify the code. Signed-off-by: Andy Yan <[email protected]> Tested-by: Michael Riesch <[email protected]> # on RK3568 Tested-by: Detlev Casanova <[email protected]> Signed-off-by: Heiko Stuebner <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 5439c4f commit 301618e

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

drivers/gpu/drm/rockchip/rockchip_drm_vop2.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ static bool vop2_output_uv_swap(u32 bus_format, u32 output_mode)
355355

356356
static bool vop2_output_rg_swap(struct vop2 *vop2, u32 bus_format)
357357
{
358-
if (vop2->data->soc_id == 3588) {
358+
if (vop2->version == VOP_VERSION_RK3588) {
359359
if (bus_format == MEDIA_BUS_FMT_YUV8_1X24 ||
360360
bus_format == MEDIA_BUS_FMT_YUV10_1X30)
361361
return true;
@@ -408,7 +408,7 @@ static bool rockchip_vop2_mod_supported(struct drm_plane *plane, u32 format,
408408
if (modifier == DRM_FORMAT_MOD_INVALID)
409409
return false;
410410

411-
if (vop2->data->soc_id == 3568 || vop2->data->soc_id == 3566) {
411+
if (vop2->version == VOP_VERSION_RK3568) {
412412
if (vop2_cluster_window(win)) {
413413
if (modifier == DRM_FORMAT_MOD_LINEAR) {
414414
drm_dbg_kms(vop2->drm,
@@ -419,7 +419,7 @@ static bool rockchip_vop2_mod_supported(struct drm_plane *plane, u32 format,
419419
}
420420

421421
if (format == DRM_FORMAT_XRGB2101010 || format == DRM_FORMAT_XBGR2101010) {
422-
if (vop2->data->soc_id == 3588) {
422+
if (vop2->version == VOP_VERSION_RK3588) {
423423
if (!rockchip_afbc(plane, modifier)) {
424424
drm_dbg_kms(vop2->drm, "Only support 32 bpp format with afbc\n");
425425
return false;
@@ -818,6 +818,7 @@ static void rk3588_vop2_power_domain_enable_all(struct vop2 *vop2)
818818
static void vop2_enable(struct vop2 *vop2)
819819
{
820820
int ret;
821+
u32 version;
821822

822823
ret = pm_runtime_resume_and_get(vop2->dev);
823824
if (ret < 0) {
@@ -837,10 +838,20 @@ static void vop2_enable(struct vop2 *vop2)
837838
return;
838839
}
839840

841+
version = vop2_readl(vop2, RK3568_VERSION_INFO);
842+
if (version != vop2->version) {
843+
drm_err(vop2->drm, "Hardware version(0x%08x) mismatch\n", version);
844+
return;
845+
}
846+
847+
/*
848+
* rk3566 share the same vop version with rk3568, so
849+
* we need to use soc_id for identification here.
850+
*/
840851
if (vop2->data->soc_id == 3566)
841852
vop2_writel(vop2, RK3568_OTP_WIN_EN, 1);
842853

843-
if (vop2->data->soc_id == 3588)
854+
if (vop2->version == VOP_VERSION_RK3588)
844855
rk3588_vop2_power_domain_enable_all(vop2);
845856

846857
vop2_writel(vop2, RK3568_REG_CFG_DONE, RK3568_REG_CFG_DONE__GLB_CFG_DONE_EN);
@@ -921,7 +932,7 @@ static void vop2_vp_dsp_lut_update_enable(struct vop2_video_port *vp)
921932

922933
static inline bool vop2_supports_seamless_gamma_lut_update(struct vop2 *vop2)
923934
{
924-
return (vop2->data->soc_id != 3566 && vop2->data->soc_id != 3568);
935+
return vop2->version != VOP_VERSION_RK3568;
925936
}
926937

927938
static bool vop2_gamma_lut_in_use(struct vop2 *vop2, struct vop2_video_port *vp)
@@ -1263,7 +1274,7 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
12631274
&fb->format->format,
12641275
afbc_en ? "AFBC" : "", &yrgb_mst);
12651276

1266-
if (vop2->data->soc_id > 3568) {
1277+
if (vop2->version > VOP_VERSION_RK3568) {
12671278
vop2_win_write(win, VOP2_WIN_AXI_BUS_ID, win->data->axi_bus_id);
12681279
vop2_win_write(win, VOP2_WIN_AXI_YRGB_R_ID, win->data->axi_yrgb_r_id);
12691280
vop2_win_write(win, VOP2_WIN_AXI_UV_R_ID, win->data->axi_uv_r_id);
@@ -1323,7 +1334,7 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
13231334
* this bit is gating disable, we should write 1 to
13241335
* disable gating when enable afbc.
13251336
*/
1326-
if (vop2->data->soc_id == 3566 || vop2->data->soc_id == 3568)
1337+
if (vop2->version == VOP_VERSION_RK3568)
13271338
vop2_win_write(win, VOP2_WIN_AFBC_AUTO_GATING_EN, 0);
13281339
else
13291340
vop2_win_write(win, VOP2_WIN_AFBC_AUTO_GATING_EN, 1);
@@ -2534,6 +2545,7 @@ static int vop2_bind(struct device *dev, struct device *master, void *data)
25342545
vop2->dev = dev;
25352546
vop2->data = vop2_data;
25362547
vop2->ops = vop2_data->ops;
2548+
vop2->version = vop2_data->version;
25372549
vop2->drm = drm;
25382550

25392551
dev_set_drvdata(dev, vop2);

drivers/gpu/drm/rockchip/rockchip_drm_vop2.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
#include "rockchip_drm_drv.h"
1414
#include "rockchip_drm_vop.h"
1515

16+
#define VOP2_VERSION(major, minor, build) ((major) << 24 | (minor) << 16 | (build))
17+
18+
/* The VOP version of new SoC is bigger than the old */
19+
#define VOP_VERSION_RK3568 VOP2_VERSION(0x40, 0x15, 0x8023)
20+
#define VOP_VERSION_RK3588 VOP2_VERSION(0x40, 0x17, 0x6786)
21+
#define VOP_VERSION_RK3528 VOP2_VERSION(0x50, 0x17, 0x1263)
22+
#define VOP_VERSION_RK3562 VOP2_VERSION(0x50, 0x17, 0x4350)
23+
#define VOP_VERSION_RK3576 VOP2_VERSION(0x50, 0x19, 0x9765)
24+
1625
#define VOP2_VP_FEATURE_OUTPUT_10BIT BIT(0)
1726

1827
#define VOP2_FEATURE_HAS_SYS_GRF BIT(0)
@@ -243,6 +252,7 @@ struct vop2_ops {
243252
struct vop2_data {
244253
u8 nr_vps;
245254
u64 feature;
255+
u32 version;
246256
const struct vop2_ops *ops;
247257
const struct vop2_win_data *win;
248258
const struct vop2_video_port_data *vp;
@@ -260,6 +270,7 @@ struct vop2_data {
260270
};
261271

262272
struct vop2 {
273+
u32 version;
263274
struct device *dev;
264275
struct drm_device *drm;
265276
struct vop2_video_port vps[ROCKCHIP_MAX_CRTC];

drivers/gpu/drm/rockchip/rockchip_vop2_reg.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,7 @@ static const struct vop2_ops rk3588_vop_ops = {
16271627
};
16281628

16291629
static const struct vop2_data rk3566_vop = {
1630+
.version = VOP_VERSION_RK3568,
16301631
.feature = VOP2_FEATURE_HAS_SYS_GRF,
16311632
.nr_vps = 3,
16321633
.max_input = { 4096, 2304 },
@@ -1645,6 +1646,7 @@ static const struct vop2_data rk3566_vop = {
16451646
};
16461647

16471648
static const struct vop2_data rk3568_vop = {
1649+
.version = VOP_VERSION_RK3568,
16481650
.feature = VOP2_FEATURE_HAS_SYS_GRF,
16491651
.nr_vps = 3,
16501652
.max_input = { 4096, 2304 },
@@ -1663,6 +1665,7 @@ static const struct vop2_data rk3568_vop = {
16631665
};
16641666

16651667
static const struct vop2_data rk3588_vop = {
1668+
.version = VOP_VERSION_RK3588,
16661669
.feature = VOP2_FEATURE_HAS_SYS_GRF | VOP2_FEATURE_HAS_VO1_GRF |
16671670
VOP2_FEATURE_HAS_VOP_GRF | VOP2_FEATURE_HAS_SYS_PMU,
16681671
.nr_vps = 4,

0 commit comments

Comments
 (0)