summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFinley Xiao <finley.xiao@rock-chips.com>2019-01-08 20:10:59 +0800
committerTao Huang <huangtao@rock-chips.com>2019-01-23 18:38:55 +0800
commit65848fcd2563f813feb758dd33177c0f84cfdef8 (patch)
tree944cc8a5bd7cb6f12357a221960dac38920d3c60
parent99797bc22a3055033db030ec364cd33a867fde4d (diff)
drm/rockchip: vop: Add support to calculate plane number
Change-Id: I9bad1743d5965724d403a27dc5e27ec28d872815 Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com> Signed-off-by: Sandy Huang <hjc@rock-chips.com>
-rw-r--r--drivers/gpu/drm/rockchip/rockchip_drm_drv.h4
-rw-r--r--drivers/gpu/drm/rockchip/rockchip_drm_fb.c12
-rw-r--r--drivers/gpu/drm/rockchip/rockchip_drm_vop.c5
3 files changed, 16 insertions, 5 deletions
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
index 757a50d702e4..87078dc83bea 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
@@ -44,7 +44,8 @@ struct rockchip_crtc_funcs {
int (*enable_vblank)(struct drm_crtc *crtc);
void (*disable_vblank)(struct drm_crtc *crtc);
size_t (*bandwidth)(struct drm_crtc *crtc,
- struct drm_crtc_state *crtc_state);
+ struct drm_crtc_state *crtc_state,
+ unsigned int *plane_num_total);
void (*cancel_pending_vblank)(struct drm_crtc *crtc, struct drm_file *file_priv);
int (*debugfs_init)(struct drm_minor *minor, struct drm_crtc *crtc);
int (*debugfs_dump)(struct drm_crtc *crtc, struct seq_file *s);
@@ -71,6 +72,7 @@ struct rockchip_atomic_commit {
struct drm_atomic_state *state;
struct drm_device *dev;
size_t bandwidth;
+ unsigned int plane_num;
};
struct rockchip_dclk_pll {
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
index eb6ba3763eb5..cc4449ee345a 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
@@ -223,7 +223,8 @@ static void rockchip_drm_output_poll_changed(struct drm_device *dev)
static int rockchip_drm_bandwidth_atomic_check(struct drm_device *dev,
struct drm_atomic_state *state,
- size_t *bandwidth)
+ size_t *bandwidth,
+ unsigned int *plane_num)
{
struct rockchip_drm_private *priv = dev->dev_private;
struct drm_crtc_state *crtc_state;
@@ -232,11 +233,13 @@ static int rockchip_drm_bandwidth_atomic_check(struct drm_device *dev,
int i, ret = 0;
*bandwidth = 0;
+ *plane_num = 0;
for_each_crtc_in_state(state, crtc, crtc_state, i) {
funcs = priv->crtc_funcs[drm_crtc_index(crtc)];
if (funcs && funcs->bandwidth)
- *bandwidth += funcs->bandwidth(crtc, crtc_state);
+ *bandwidth += funcs->bandwidth(crtc, crtc_state,
+ plane_num);
}
/*
@@ -329,6 +332,7 @@ static int rockchip_drm_atomic_commit(struct drm_device *dev,
struct rockchip_drm_private *private = dev->dev_private;
struct rockchip_atomic_commit *commit;
size_t bandwidth;
+ unsigned int plane_num;
int ret;
ret = drm_atomic_helper_setup_commit(state, false);
@@ -339,7 +343,8 @@ static int rockchip_drm_atomic_commit(struct drm_device *dev,
if (ret)
return ret;
- ret = rockchip_drm_bandwidth_atomic_check(dev, state, &bandwidth);
+ ret = rockchip_drm_bandwidth_atomic_check(dev, state, &bandwidth,
+ &plane_num);
if (ret) {
/*
* TODO:
@@ -357,6 +362,7 @@ static int rockchip_drm_atomic_commit(struct drm_device *dev,
commit->dev = dev;
commit->state = state;
commit->bandwidth = bandwidth;
+ commit->plane_num = plane_num;
if (async) {
mutex_lock(&private->commit_lock);
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index f349494ef09f..9c2e2379512c 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -2386,7 +2386,8 @@ static u64 vop_calc_max_bandwidth(struct vop_bandwidth *bw, int start,
}
static size_t vop_crtc_bandwidth(struct drm_crtc *crtc,
- struct drm_crtc_state *crtc_state)
+ struct drm_crtc_state *crtc_state,
+ unsigned int *plane_num_total)
{
struct drm_atomic_state *state = crtc_state->state;
struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
@@ -2408,6 +2409,8 @@ static size_t vop_crtc_bandwidth(struct drm_crtc *crtc,
continue;
plane_num++;
}
+ if (plane_num_total)
+ *plane_num_total += plane_num;
pbandwidth = kmalloc_array(plane_num, sizeof(*pbandwidth),
GFP_KERNEL);
if (!pbandwidth)