Skip to content

Commit bdfb3cb

Browse files
Mark Yaock_zhang
authored andcommitted
drm/rockchip: vop: add display input/output limit
Change-Id: If218ca6d2de5c05b6f8ed417cefa437c62c31935 Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
1 parent 093e72b commit bdfb3cb

3 files changed

Lines changed: 64 additions & 5 deletions

File tree

drivers/gpu/drm/rockchip/rockchip_drm_vop.c

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,11 +467,6 @@ static void scl_vop_cal_scl_fac(struct vop *vop, struct vop_win *win,
467467
if (!win->phy->scl)
468468
return;
469469

470-
if (dst_w > 3840) {
471-
DRM_ERROR("Maximum destination width (3840) exceeded\n");
472-
return;
473-
}
474-
475470
if (!win->phy->scl->ext) {
476471
VOP_SCL_SET(vop, win, scale_yrgb_x,
477472
scl_cal_scale2(src_w, dst_w));
@@ -1074,6 +1069,8 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
10741069
struct vop_win *win = to_vop_win(plane);
10751070
struct vop_plane_state *vop_plane_state = to_vop_plane_state(state);
10761071
struct drm_crtc_state *crtc_state;
1072+
const struct vop_data *vop_data;
1073+
struct vop *vop;
10771074
bool visible;
10781075
int ret;
10791076
struct drm_rect *dest = &vop_plane_state->dest;
@@ -1126,6 +1123,29 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
11261123
if (vop_plane_state->format < 0)
11271124
return vop_plane_state->format;
11281125

1126+
vop = to_vop(crtc);
1127+
vop_data = vop->data;
1128+
1129+
if (drm_rect_width(src) >> 16 > vop_data->max_input_fb.width ||
1130+
drm_rect_height(src) >> 16 > vop_data->max_input_fb.height) {
1131+
DRM_ERROR("Invalid source: %dx%d. max input: %dx%d\n",
1132+
drm_rect_width(src) >> 16,
1133+
drm_rect_height(src) >> 16,
1134+
vop_data->max_input_fb.width,
1135+
vop_data->max_input_fb.height);
1136+
return -EINVAL;
1137+
}
1138+
1139+
if (drm_rect_width(dest) >> 16 > vop_data->max_input_fb.width ||
1140+
drm_rect_height(dest) >> 16 > vop_data->max_input_fb.height) {
1141+
DRM_ERROR("Invalid destination: %dx%d. max output: %dx%d\n",
1142+
drm_rect_width(dest),
1143+
drm_rect_height(dest),
1144+
vop_data->max_output_fb.width,
1145+
vop_data->max_output_fb.height);
1146+
return -EINVAL;
1147+
}
1148+
11291149
/*
11301150
* Src.x1 can be odd when do clip, but yuv plane start point
11311151
* need align with 2 pixel.
@@ -1478,6 +1498,11 @@ static bool vop_crtc_mode_fixup(struct drm_crtc *crtc,
14781498
struct drm_display_mode *adjusted_mode)
14791499
{
14801500
struct vop *vop = to_vop(crtc);
1501+
const struct vop_data *vop_data = vop->data;
1502+
1503+
if (mode->hdisplay > vop_data->max_disably_output.width ||
1504+
mode->vdisplay > vop_data->max_disably_output.height)
1505+
return false;
14811506

14821507
adjusted_mode->clock =
14831508
clk_round_rate(vop->dclk, mode->clock * 1000) / 1000;

drivers/gpu/drm/rockchip/rockchip_drm_vop.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ struct vop_win_data {
246246
#define VOP_FEATURE_OUTPUT_10BIT BIT(0)
247247
#define VOP_FEATURE_AFBDC BIT(1)
248248

249+
struct vop_rect {
250+
int width;
251+
int height;
252+
};
253+
249254
struct vop_data {
250255
const struct vop_reg_data *init_table;
251256
unsigned int table_size;
@@ -255,6 +260,9 @@ struct vop_data {
255260
const struct vop_csc_table *csc_table;
256261
unsigned int win_size;
257262
uint32_t version;
263+
struct vop_rect max_input_fb;
264+
struct vop_rect max_output_fb;
265+
struct vop_rect max_disably_output;
258266
u64 feature;
259267
};
260268

drivers/gpu/drm/rockchip/rockchip_vop_reg.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,14 @@ static const struct vop_intr rk3288_vop_intr = {
262262
static const struct vop_data rk3288_vop = {
263263
.version = VOP_VERSION(3, 1),
264264
.feature = VOP_FEATURE_OUTPUT_10BIT,
265+
.max_input_fb = { 4096, 8192},
266+
.max_output_fb = { 3840, 2160},
267+
/*
268+
* TODO: rk3288 have two vop, big one support 3840x2160,
269+
* little one only support 2560x1600.
270+
* Now force use 3840x2160.
271+
*/
272+
.max_disably_output = { 3840, 2160},
265273
.intr = &rk3288_vop_intr,
266274
.ctrl = &rk3288_ctrl_data,
267275
.win = rk3288_vop_win_data,
@@ -365,6 +373,9 @@ static const struct vop_win_data rk3368_vop_win_data[] = {
365373
static const struct vop_data rk3368_vop = {
366374
.version = VOP_VERSION(3, 2),
367375
.feature = VOP_FEATURE_OUTPUT_10BIT,
376+
.max_input_fb = { 4096, 8192},
377+
.max_output_fb = { 4096, 2160},
378+
.max_disably_output = { 4096, 2160},
368379
.intr = &rk3368_vop_intr,
369380
.ctrl = &rk3288_ctrl_data,
370381
.win = rk3368_vop_win_data,
@@ -384,6 +395,9 @@ static const struct vop_intr rk3366_vop_intr = {
384395
static const struct vop_data rk3366_vop = {
385396
.version = VOP_VERSION(3, 4),
386397
.feature = VOP_FEATURE_OUTPUT_10BIT,
398+
.max_input_fb = { 4096, 8192},
399+
.max_output_fb = { 4096, 2160},
400+
.max_disably_output = { 4096, 2160},
387401
.intr = &rk3366_vop_intr,
388402
.ctrl = &rk3288_ctrl_data,
389403
.win = rk3368_vop_win_data,
@@ -493,6 +507,9 @@ static const struct vop_data rk3399_vop_big = {
493507
.version = VOP_VERSION(3, 5),
494508
.csc_table = &rk3399_csc_table,
495509
.feature = VOP_FEATURE_OUTPUT_10BIT | VOP_FEATURE_AFBDC,
510+
.max_input_fb = { 4096, 8192},
511+
.max_output_fb = { 4096, 2160},
512+
.max_disably_output = { 4096, 2160},
496513
.intr = &rk3366_vop_intr,
497514
.ctrl = &rk3288_ctrl_data,
498515
.win = rk3399_vop_win_data,
@@ -514,6 +531,9 @@ static const struct vop_win_data rk3399_vop_lit_win_data[] = {
514531
static const struct vop_data rk3399_vop_lit = {
515532
.version = VOP_VERSION(3, 6),
516533
.csc_table = &rk3399_csc_table,
534+
.max_input_fb = { 4096, 8192},
535+
.max_output_fb = { 2560, 1600},
536+
.max_disably_output = { 2560, 1600},
517537
.intr = &rk3366_vop_intr,
518538
.ctrl = &rk3288_ctrl_data,
519539
.win = rk3399_vop_lit_win_data,
@@ -523,6 +543,9 @@ static const struct vop_data rk3399_vop_lit = {
523543
static const struct vop_data rk322x_vop = {
524544
.version = VOP_VERSION(3, 7),
525545
.feature = VOP_FEATURE_OUTPUT_10BIT,
546+
.max_input_fb = { 4096, 8192},
547+
.max_output_fb = { 4096, 2160},
548+
.max_disably_output = { 4096, 2160},
526549
.intr = &rk3366_vop_intr,
527550
.ctrl = &rk3288_ctrl_data,
528551
.win = rk3368_vop_win_data,
@@ -607,6 +630,9 @@ static const struct vop_ctrl rk3036_ctrl_data = {
607630

608631
static const struct vop_data rk3036_vop = {
609632
.version = VOP_VERSION(2, 2),
633+
.max_input_fb = { 1920, 1080},
634+
.max_output_fb = { 1920, 1080},
635+
.max_disably_output = { 1920, 1080},
610636
.ctrl = &rk3036_ctrl_data,
611637
.intr = &rk3036_intr,
612638
.win = rk3036_vop_win_data,

0 commit comments

Comments
 (0)