Commit e12e5263 authored by Rob Clark's avatar Rob Clark

drm/msm/dpu: clean up some impossibilities

Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
Reviewed-by: default avatarAbhinav Kumar <abhinavk@codeaurora.org>
parent fd630ae9
...@@ -265,11 +265,6 @@ enum dpu_intf_mode dpu_crtc_get_intf_mode(struct drm_crtc *crtc) ...@@ -265,11 +265,6 @@ enum dpu_intf_mode dpu_crtc_get_intf_mode(struct drm_crtc *crtc)
{ {
struct drm_encoder *encoder; struct drm_encoder *encoder;
if (!crtc) {
DPU_ERROR("invalid crtc\n");
return INTF_MODE_NONE;
}
/* /*
* TODO: This function is called from dpu debugfs and as part of atomic * TODO: This function is called from dpu debugfs and as part of atomic
* check. When called from debugfs, the crtc->mutex must be held to * check. When called from debugfs, the crtc->mutex must be held to
...@@ -457,7 +452,6 @@ static void _dpu_crtc_setup_cp_blocks(struct drm_crtc *crtc) ...@@ -457,7 +452,6 @@ static void _dpu_crtc_setup_cp_blocks(struct drm_crtc *crtc)
struct dpu_crtc_mixer *mixer = cstate->mixers; struct dpu_crtc_mixer *mixer = cstate->mixers;
struct dpu_hw_pcc_cfg cfg; struct dpu_hw_pcc_cfg cfg;
struct dpu_hw_ctl *ctl; struct dpu_hw_ctl *ctl;
struct dpu_hw_mixer *lm;
struct dpu_hw_dspp *dspp; struct dpu_hw_dspp *dspp;
int i; int i;
...@@ -467,7 +461,6 @@ static void _dpu_crtc_setup_cp_blocks(struct drm_crtc *crtc) ...@@ -467,7 +461,6 @@ static void _dpu_crtc_setup_cp_blocks(struct drm_crtc *crtc)
for (i = 0; i < cstate->num_mixers; i++) { for (i = 0; i < cstate->num_mixers; i++) {
ctl = mixer[i].lm_ctl; ctl = mixer[i].lm_ctl;
lm = mixer[i].hw_lm;
dspp = mixer[i].hw_dspp; dspp = mixer[i].hw_dspp;
if (!dspp || !dspp->ops.setup_pcc) if (!dspp || !dspp->ops.setup_pcc)
...@@ -496,16 +489,8 @@ static void _dpu_crtc_setup_cp_blocks(struct drm_crtc *crtc) ...@@ -496,16 +489,8 @@ static void _dpu_crtc_setup_cp_blocks(struct drm_crtc *crtc)
static void dpu_crtc_atomic_begin(struct drm_crtc *crtc, static void dpu_crtc_atomic_begin(struct drm_crtc *crtc,
struct drm_crtc_state *old_state) struct drm_crtc_state *old_state)
{ {
struct dpu_crtc *dpu_crtc; struct dpu_crtc_state *cstate = to_dpu_crtc_state(crtc->state);
struct dpu_crtc_state *cstate;
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct drm_device *dev;
unsigned long flags;
if (!crtc) {
DPU_ERROR("invalid crtc\n");
return;
}
if (!crtc->state->enable) { if (!crtc->state->enable) {
DPU_DEBUG("crtc%d -> enable %d, skip atomic_begin\n", DPU_DEBUG("crtc%d -> enable %d, skip atomic_begin\n",
...@@ -515,21 +500,8 @@ static void dpu_crtc_atomic_begin(struct drm_crtc *crtc, ...@@ -515,21 +500,8 @@ static void dpu_crtc_atomic_begin(struct drm_crtc *crtc,
DPU_DEBUG("crtc%d\n", crtc->base.id); DPU_DEBUG("crtc%d\n", crtc->base.id);
dpu_crtc = to_dpu_crtc(crtc);
cstate = to_dpu_crtc_state(crtc->state);
dev = crtc->dev;
_dpu_crtc_setup_lm_bounds(crtc, crtc->state); _dpu_crtc_setup_lm_bounds(crtc, crtc->state);
if (dpu_crtc->event) {
WARN_ON(dpu_crtc->event);
} else {
spin_lock_irqsave(&dev->event_lock, flags);
dpu_crtc->event = crtc->state->event;
crtc->state->event = NULL;
spin_unlock_irqrestore(&dev->event_lock, flags);
}
/* encoder will trigger pending mask now */ /* encoder will trigger pending mask now */
drm_for_each_encoder_mask(encoder, crtc->dev, crtc->state->encoder_mask) drm_for_each_encoder_mask(encoder, crtc->dev, crtc->state->encoder_mask)
dpu_encoder_trigger_kickoff_pending(encoder); dpu_encoder_trigger_kickoff_pending(encoder);
...@@ -583,14 +555,11 @@ static void dpu_crtc_atomic_flush(struct drm_crtc *crtc, ...@@ -583,14 +555,11 @@ static void dpu_crtc_atomic_flush(struct drm_crtc *crtc,
return; return;
} }
if (dpu_crtc->event) { WARN_ON(dpu_crtc->event);
DPU_DEBUG("already received dpu_crtc->event\n"); spin_lock_irqsave(&dev->event_lock, flags);
} else { dpu_crtc->event = crtc->state->event;
spin_lock_irqsave(&dev->event_lock, flags); crtc->state->event = NULL;
dpu_crtc->event = crtc->state->event; spin_unlock_irqrestore(&dev->event_lock, flags);
crtc->state->event = NULL;
spin_unlock_irqrestore(&dev->event_lock, flags);
}
/* /*
* If no mixers has been allocated in dpu_crtc_atomic_check(), * If no mixers has been allocated in dpu_crtc_atomic_check(),
...@@ -635,14 +604,7 @@ static void dpu_crtc_atomic_flush(struct drm_crtc *crtc, ...@@ -635,14 +604,7 @@ static void dpu_crtc_atomic_flush(struct drm_crtc *crtc,
static void dpu_crtc_destroy_state(struct drm_crtc *crtc, static void dpu_crtc_destroy_state(struct drm_crtc *crtc,
struct drm_crtc_state *state) struct drm_crtc_state *state)
{ {
struct dpu_crtc_state *cstate; struct dpu_crtc_state *cstate = to_dpu_crtc_state(state);
if (!crtc || !state) {
DPU_ERROR("invalid argument(s)\n");
return;
}
cstate = to_dpu_crtc_state(state);
DPU_DEBUG("crtc%d\n", crtc->base.id); DPU_DEBUG("crtc%d\n", crtc->base.id);
...@@ -731,14 +693,8 @@ static void dpu_crtc_reset(struct drm_crtc *crtc) ...@@ -731,14 +693,8 @@ static void dpu_crtc_reset(struct drm_crtc *crtc)
*/ */
static struct drm_crtc_state *dpu_crtc_duplicate_state(struct drm_crtc *crtc) static struct drm_crtc_state *dpu_crtc_duplicate_state(struct drm_crtc *crtc)
{ {
struct dpu_crtc_state *cstate, *old_cstate; struct dpu_crtc_state *cstate, *old_cstate = to_dpu_crtc_state(crtc->state);
if (!crtc || !crtc->state) {
DPU_ERROR("invalid argument(s)\n");
return NULL;
}
old_cstate = to_dpu_crtc_state(crtc->state);
cstate = kmemdup(old_cstate, sizeof(*old_cstate), GFP_KERNEL); cstate = kmemdup(old_cstate, sizeof(*old_cstate), GFP_KERNEL);
if (!cstate) { if (!cstate) {
DPU_ERROR("failed to allocate state\n"); DPU_ERROR("failed to allocate state\n");
...@@ -754,19 +710,12 @@ static struct drm_crtc_state *dpu_crtc_duplicate_state(struct drm_crtc *crtc) ...@@ -754,19 +710,12 @@ static struct drm_crtc_state *dpu_crtc_duplicate_state(struct drm_crtc *crtc)
static void dpu_crtc_disable(struct drm_crtc *crtc, static void dpu_crtc_disable(struct drm_crtc *crtc,
struct drm_crtc_state *old_crtc_state) struct drm_crtc_state *old_crtc_state)
{ {
struct dpu_crtc *dpu_crtc; struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
struct dpu_crtc_state *cstate; struct dpu_crtc_state *cstate = to_dpu_crtc_state(crtc->state);
struct drm_encoder *encoder; struct drm_encoder *encoder;
unsigned long flags; unsigned long flags;
bool release_bandwidth = false; bool release_bandwidth = false;
if (!crtc || !crtc->state) {
DPU_ERROR("invalid crtc\n");
return;
}
dpu_crtc = to_dpu_crtc(crtc);
cstate = to_dpu_crtc_state(crtc->state);
DRM_DEBUG_KMS("crtc%d\n", crtc->base.id); DRM_DEBUG_KMS("crtc%d\n", crtc->base.id);
/* Disable/save vblank irq handling */ /* Disable/save vblank irq handling */
...@@ -825,19 +774,13 @@ static void dpu_crtc_disable(struct drm_crtc *crtc, ...@@ -825,19 +774,13 @@ static void dpu_crtc_disable(struct drm_crtc *crtc,
static void dpu_crtc_enable(struct drm_crtc *crtc, static void dpu_crtc_enable(struct drm_crtc *crtc,
struct drm_crtc_state *old_crtc_state) struct drm_crtc_state *old_crtc_state)
{ {
struct dpu_crtc *dpu_crtc; struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
struct drm_encoder *encoder; struct drm_encoder *encoder;
bool request_bandwidth = false; bool request_bandwidth = false;
if (!crtc) {
DPU_ERROR("invalid crtc\n");
return;
}
pm_runtime_get_sync(crtc->dev->dev); pm_runtime_get_sync(crtc->dev->dev);
DRM_DEBUG_KMS("crtc%d\n", crtc->base.id); DRM_DEBUG_KMS("crtc%d\n", crtc->base.id);
dpu_crtc = to_dpu_crtc(crtc);
drm_for_each_encoder_mask(encoder, crtc->dev, crtc->state->encoder_mask) { drm_for_each_encoder_mask(encoder, crtc->dev, crtc->state->encoder_mask) {
/* in video mode, we hold an extra bandwidth reference /* in video mode, we hold an extra bandwidth reference
...@@ -873,9 +816,9 @@ struct plane_state { ...@@ -873,9 +816,9 @@ struct plane_state {
static int dpu_crtc_atomic_check(struct drm_crtc *crtc, static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
struct drm_crtc_state *state) struct drm_crtc_state *state)
{ {
struct dpu_crtc *dpu_crtc; struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
struct dpu_crtc_state *cstate = to_dpu_crtc_state(state);
struct plane_state *pstates; struct plane_state *pstates;
struct dpu_crtc_state *cstate;
const struct drm_plane_state *pstate; const struct drm_plane_state *pstate;
struct drm_plane *plane; struct drm_plane *plane;
...@@ -889,16 +832,8 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc, ...@@ -889,16 +832,8 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
int left_zpos_cnt = 0, right_zpos_cnt = 0; int left_zpos_cnt = 0, right_zpos_cnt = 0;
struct drm_rect crtc_rect = { 0 }; struct drm_rect crtc_rect = { 0 };
if (!crtc) {
DPU_ERROR("invalid crtc\n");
return -EINVAL;
}
pstates = kzalloc(sizeof(*pstates) * DPU_STAGE_MAX * 4, GFP_KERNEL); pstates = kzalloc(sizeof(*pstates) * DPU_STAGE_MAX * 4, GFP_KERNEL);
dpu_crtc = to_dpu_crtc(crtc);
cstate = to_dpu_crtc_state(state);
if (!state->enable || !state->active) { if (!state->enable || !state->active) {
DPU_DEBUG("crtc%d -> enable %d, active %d, skip atomic_check\n", DPU_DEBUG("crtc%d -> enable %d, active %d, skip atomic_check\n",
crtc->base.id, state->enable, state->active); crtc->base.id, state->enable, state->active);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment