Skip to content

Commit 74a3dba

Browse files
committed
drm/imx: ipuv3-plane: add zpos property
Add a zpos property to planes. Call drm_atomic_helper_check() instead of calling drm_atomic_helper_check_modeset() and drm_atomic_check_planes() manually. This effectively adds a call to drm_atomic_normalize_zpos() before checking planes. Reorder atomic update to allow changing plane zpos without modeset. Note that the initial zpos is set in ipu_plane_state_reset(). The initial value set in ipu_plane_init() is just for show. The zpos parameter of drm_plane_create_zpos_property() is ignored because the newly created plane do not have state yet. Signed-off-by: Philipp Zabel <[email protected]> Tested-by: Marius Vlad <[email protected]>
1 parent 70e8a0c commit 74a3dba

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed

drivers/gpu/drm/imx/imx-drm-core.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ static int imx_drm_atomic_check(struct drm_device *dev,
4949
{
5050
int ret;
5151

52-
ret = drm_atomic_helper_check_modeset(dev, state);
53-
if (ret)
54-
return ret;
55-
56-
ret = drm_atomic_helper_check_planes(dev, state);
52+
ret = drm_atomic_helper_check(dev, state);
5753
if (ret)
5854
return ret;
5955

@@ -229,6 +225,7 @@ static int imx_drm_bind(struct device *dev)
229225
drm->mode_config.funcs = &imx_drm_mode_config_funcs;
230226
drm->mode_config.helper_private = &imx_drm_mode_config_helpers;
231227
drm->mode_config.allow_fb_modifiers = true;
228+
drm->mode_config.normalize_zpos = true;
232229

233230
drm_mode_config_init(drm);
234231

drivers/gpu/drm/imx/ipuv3-plane.c

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ static void ipu_plane_destroy(struct drm_plane *plane)
273273

274274
static void ipu_plane_state_reset(struct drm_plane *plane)
275275
{
276+
unsigned int zpos = (plane->type == DRM_PLANE_TYPE_PRIMARY) ? 0 : 1;
276277
struct ipu_plane_state *ipu_state;
277278

278279
if (plane->state) {
@@ -284,8 +285,11 @@ static void ipu_plane_state_reset(struct drm_plane *plane)
284285

285286
ipu_state = kzalloc(sizeof(*ipu_state), GFP_KERNEL);
286287

287-
if (ipu_state)
288+
if (ipu_state) {
288289
__drm_atomic_helper_plane_reset(plane, &ipu_state->base);
290+
ipu_state->base.zpos = zpos;
291+
ipu_state->base.normalized_zpos = zpos;
292+
}
289293
}
290294

291295
static struct drm_plane_state *
@@ -560,6 +564,25 @@ static void ipu_plane_atomic_update(struct drm_plane *plane,
560564
if (ipu_plane->dp_flow == IPU_DP_FLOW_SYNC_FG)
561565
ipu_dp_set_window_pos(ipu_plane->dp, dst->x1, dst->y1);
562566

567+
switch (ipu_plane->dp_flow) {
568+
case IPU_DP_FLOW_SYNC_BG:
569+
if (state->normalized_zpos == 1) {
570+
ipu_dp_set_global_alpha(ipu_plane->dp,
571+
!fb->format->has_alpha, 0xff,
572+
true);
573+
} else {
574+
ipu_dp_set_global_alpha(ipu_plane->dp, true, 0, true);
575+
}
576+
break;
577+
case IPU_DP_FLOW_SYNC_FG:
578+
if (state->normalized_zpos == 1) {
579+
ipu_dp_set_global_alpha(ipu_plane->dp,
580+
!fb->format->has_alpha, 0xff,
581+
false);
582+
}
583+
break;
584+
}
585+
563586
eba = drm_plane_state_to_eba(state, 0);
564587

565588
/*
@@ -596,34 +619,11 @@ static void ipu_plane_atomic_update(struct drm_plane *plane,
596619
switch (ipu_plane->dp_flow) {
597620
case IPU_DP_FLOW_SYNC_BG:
598621
ipu_dp_setup_channel(ipu_plane->dp, ics, IPUV3_COLORSPACE_RGB);
599-
ipu_dp_set_global_alpha(ipu_plane->dp, true, 0, true);
600622
break;
601623
case IPU_DP_FLOW_SYNC_FG:
602624
ipu_dp_setup_channel(ipu_plane->dp, ics,
603625
IPUV3_COLORSPACE_UNKNOWN);
604-
/* Enable local alpha on partial plane */
605-
switch (fb->format->format) {
606-
case DRM_FORMAT_ARGB1555:
607-
case DRM_FORMAT_ABGR1555:
608-
case DRM_FORMAT_RGBA5551:
609-
case DRM_FORMAT_BGRA5551:
610-
case DRM_FORMAT_ARGB4444:
611-
case DRM_FORMAT_ARGB8888:
612-
case DRM_FORMAT_ABGR8888:
613-
case DRM_FORMAT_RGBA8888:
614-
case DRM_FORMAT_BGRA8888:
615-
case DRM_FORMAT_RGB565_A8:
616-
case DRM_FORMAT_BGR565_A8:
617-
case DRM_FORMAT_RGB888_A8:
618-
case DRM_FORMAT_BGR888_A8:
619-
case DRM_FORMAT_RGBX8888_A8:
620-
case DRM_FORMAT_BGRX8888_A8:
621-
ipu_dp_set_global_alpha(ipu_plane->dp, false, 0, false);
622-
break;
623-
default:
624-
ipu_dp_set_global_alpha(ipu_plane->dp, true, 0, true);
625-
break;
626-
}
626+
break;
627627
}
628628

629629
ipu_dmfc_config_wait4eot(ipu_plane->dmfc, drm_rect_width(dst));
@@ -826,6 +826,7 @@ struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
826826
{
827827
struct ipu_plane *ipu_plane;
828828
const uint64_t *modifiers = ipu_format_modifiers;
829+
unsigned int zpos = (type == DRM_PLANE_TYPE_PRIMARY) ? 0 : 1;
829830
int ret;
830831

831832
DRM_DEBUG_KMS("channel %d, dp flow %d, possible_crtcs=0x%x\n",
@@ -856,5 +857,10 @@ struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
856857

857858
drm_plane_helper_add(&ipu_plane->base, &ipu_plane_helper_funcs);
858859

860+
if (dp == IPU_DP_FLOW_SYNC_BG || dp == IPU_DP_FLOW_SYNC_FG)
861+
drm_plane_create_zpos_property(&ipu_plane->base, zpos, 0, 1);
862+
else
863+
drm_plane_create_zpos_immutable_property(&ipu_plane->base, 0);
864+
859865
return ipu_plane;
860866
}

0 commit comments

Comments
 (0)