Skip to content

Commit b148928

Browse files
boddobrobclark
authored andcommitted
drm/msm/mdp5: Update mdp5_pipe_assign to spit out both planes
We currently call mdp5_pipe_assign() twice to assign the left and right hwpipes for our drm_plane. When merging 2 hwpipes, there are a few constraints that we need to keep in mind: - Only the same types of SSPPs are preferred. I.e, a RGB pipe should be paired with another RGB pipe, VIG with VIG etc. - The hwpipe staged on the left should have a higher priority than the hwpipe staged on the right. The priorities are as follows: VIG0 > VIG1 > VIG2 > VIG3 RGB0 > RGB1 > RGB2 > RGB3 DMA0 > DMA1 We can't apply these constraints easily if mdp5_pipe_assign() is called twice. Update mdp5_pipe_assign() to find both hwpipes in one go, and add the extra constraints needed. Signed-off-by: Archit Taneja <architt@codeaurora.org> Signed-off-by: Rob Clark <robdclark@gmail.com>
1 parent 9866601 commit b148928

File tree

3 files changed

+57
-20
lines changed

3 files changed

+57
-20
lines changed

drivers/gpu/drm/msm/mdp/mdp5/mdp5_pipe.c

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@
1919

2020
int mdp5_pipe_assign(struct drm_atomic_state *s, struct drm_plane *plane,
2121
uint32_t caps, uint32_t blkcfg,
22-
struct mdp5_hw_pipe **hwpipe)
22+
struct mdp5_hw_pipe **hwpipe,
23+
struct mdp5_hw_pipe **r_hwpipe)
2324
{
2425
struct msm_drm_private *priv = s->dev->dev_private;
2526
struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms));
2627
struct mdp5_state *state;
2728
struct mdp5_hw_pipe_state *old_state, *new_state;
28-
int i;
29+
int i, j;
2930

3031
state = mdp5_get_state(s);
3132
if (IS_ERR(state))
@@ -65,16 +66,46 @@ int mdp5_pipe_assign(struct drm_atomic_state *s, struct drm_plane *plane,
6566
* fewest unneeded caps bits set:
6667
*/
6768
if (!(*hwpipe) || (hweight_long(cur->caps & ~caps) <
68-
hweight_long((*hwpipe)->caps & ~caps)))
69-
*hwpipe = cur;
69+
hweight_long((*hwpipe)->caps & ~caps))) {
70+
bool r_found = false;
71+
72+
if (r_hwpipe) {
73+
for (j = i + 1; j < mdp5_kms->num_hwpipes;
74+
j++) {
75+
struct mdp5_hw_pipe *r_cur =
76+
mdp5_kms->hwpipes[j];
77+
78+
/* reject different types of hwpipes */
79+
if (r_cur->caps != cur->caps)
80+
continue;
81+
82+
/* respect priority, eg. VIG0 > VIG1 */
83+
if (cur->pipe > r_cur->pipe)
84+
continue;
85+
86+
*r_hwpipe = r_cur;
87+
r_found = true;
88+
break;
89+
}
90+
}
91+
92+
if (!r_hwpipe || r_found)
93+
*hwpipe = cur;
94+
}
7095
}
7196

7297
if (!(*hwpipe))
7398
return -ENOMEM;
7499

100+
if (r_hwpipe && !(*r_hwpipe))
101+
return -ENOMEM;
102+
75103
if (mdp5_kms->smp) {
76104
int ret;
77105

106+
/* We don't support SMP and 2 hwpipes/plane together */
107+
WARN_ON(r_hwpipe);
108+
78109
DBG("%s: alloc SMP blocks", (*hwpipe)->name);
79110
ret = mdp5_smp_assign(mdp5_kms->smp, &state->smp,
80111
(*hwpipe)->pipe, blkcfg);
@@ -88,6 +119,12 @@ int mdp5_pipe_assign(struct drm_atomic_state *s, struct drm_plane *plane,
88119
(*hwpipe)->name, plane->name, caps);
89120
new_state->hwpipe_to_plane[(*hwpipe)->idx] = plane;
90121

122+
if (r_hwpipe) {
123+
DBG("%s: assign to right of plane %s for caps %x",
124+
(*r_hwpipe)->name, plane->name, caps);
125+
new_state->hwpipe_to_plane[(*r_hwpipe)->idx] = plane;
126+
}
127+
91128
return 0;
92129
}
93130

drivers/gpu/drm/msm/mdp/mdp5/mdp5_pipe.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ struct mdp5_hw_pipe_state {
4444
struct drm_plane *hwpipe_to_plane[SSPP_MAX];
4545
};
4646

47-
int
48-
mdp5_pipe_assign(struct drm_atomic_state *s, struct drm_plane *plane,
49-
uint32_t caps, uint32_t blkcfg, struct mdp5_hw_pipe **hwpipe);
47+
int mdp5_pipe_assign(struct drm_atomic_state *s, struct drm_plane *plane,
48+
uint32_t caps, uint32_t blkcfg,
49+
struct mdp5_hw_pipe **hwpipe,
50+
struct mdp5_hw_pipe **r_hwpipe);
5051
void mdp5_pipe_release(struct drm_atomic_state *s, struct mdp5_hw_pipe *hwpipe);
5152

5253
struct mdp5_hw_pipe *mdp5_pipe_init(enum mdp5_pipe pipe,

drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -393,31 +393,30 @@ static int mdp5_plane_atomic_check_with_state(struct drm_crtc_state *crtc_state,
393393
struct mdp5_hw_pipe *old_hwpipe = mdp5_state->hwpipe;
394394
struct mdp5_hw_pipe *old_right_hwpipe =
395395
mdp5_state->r_hwpipe;
396+
struct mdp5_hw_pipe *new_hwpipe = NULL;
397+
struct mdp5_hw_pipe *new_right_hwpipe = NULL;
396398

397399
ret = mdp5_pipe_assign(state->state, plane, caps,
398-
blkcfg, &mdp5_state->hwpipe);
400+
blkcfg, &new_hwpipe,
401+
need_right_hwpipe ?
402+
&new_right_hwpipe : NULL);
399403
if (ret) {
400-
DBG("%s: failed to assign hwpipe!", plane->name);
404+
DBG("%s: failed to assign hwpipe(s)!",
405+
plane->name);
401406
return ret;
402407
}
403408

404-
if (need_right_hwpipe) {
405-
ret = mdp5_pipe_assign(state->state, plane,
406-
caps, blkcfg,
407-
&mdp5_state->r_hwpipe);
408-
if (ret) {
409-
DBG("%s: failed to assign right hwpipe",
410-
plane->name);
411-
return ret;
412-
}
413-
} else {
409+
mdp5_state->hwpipe = new_hwpipe;
410+
if (need_right_hwpipe)
411+
mdp5_state->r_hwpipe = new_right_hwpipe;
412+
else
414413
/*
415414
* set it to NULL so that the driver knows we
416415
* don't have a right hwpipe when committing a
417416
* new state
418417
*/
419418
mdp5_state->r_hwpipe = NULL;
420-
}
419+
421420

422421
mdp5_pipe_release(state->state, old_hwpipe);
423422
mdp5_pipe_release(state->state, old_right_hwpipe);

0 commit comments

Comments
 (0)