Unverified Commit ba5c1649 authored by Maxime Ripard's avatar Maxime Ripard
Browse files

drm: Rename plane atomic_check state names



Most drivers call the argument to the plane atomic_check hook simply
state, which is going to conflict with the global atomic state in a
later rework. Let's rename it to new_plane_state (or new_state depending
on the convention used in the driver).

This was done using the coccinelle script below, and built tested:

@ plane_atomic_func @
identifier helpers;
identifier func;
@@

 static const struct drm_plane_helper_funcs helpers = {
 	.atomic_check = func,
 };

@ has_old_state @
identifier plane_atomic_func.func;
identifier plane;
expression e;
symbol old_state;
symbol state;
@@

 func(struct drm_plane *plane, struct drm_plane_state *state)
 {
 	...
 	struct drm_plane_state *old_state = e;
 	...
 }

@ depends on has_old_state @
identifier plane_atomic_func.func;
identifier plane;
symbol old_state;
@@

 func(struct drm_plane *plane,
-	struct drm_plane_state *state
+	struct drm_plane_state *new_state
     )
 {
 	<+...
-	state
+	new_state
	...+>
 }

@ has_state @
identifier plane_atomic_func.func;
identifier plane;
symbol state;
@@

 func(struct drm_plane *plane, struct drm_plane_state *state)
 {
 	...
 }

@ depends on has_state @
identifier plane_atomic_func.func;
identifier plane;
symbol old_state;
@@

 func(struct drm_plane *plane,
-	struct drm_plane_state *state
+	struct drm_plane_state *new_plane_state
     )
 {
 	<+...
-	state
+	new_plane_state
	...+>
 }

Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-2-maxime@cerno.tech
parent 5ddb0bd4
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -6432,7 +6432,7 @@ static int dm_plane_helper_check_state(struct drm_plane_state *state,
}

static int dm_plane_atomic_check(struct drm_plane *plane,
				 struct drm_plane_state *state)
				 struct drm_plane_state *new_plane_state)
{
	struct amdgpu_device *adev = drm_to_adev(plane->dev);
	struct dc *dc = adev->dm.dc;
@@ -6441,23 +6441,24 @@ static int dm_plane_atomic_check(struct drm_plane *plane,
	struct drm_crtc_state *new_crtc_state;
	int ret;

	trace_amdgpu_dm_plane_atomic_check(state);
	trace_amdgpu_dm_plane_atomic_check(new_plane_state);

	dm_plane_state = to_dm_plane_state(state);
	dm_plane_state = to_dm_plane_state(new_plane_state);

	if (!dm_plane_state->dc_state)
		return 0;

	new_crtc_state =
		drm_atomic_get_new_crtc_state(state->state, state->crtc);
		drm_atomic_get_new_crtc_state(new_plane_state->state,
					      new_plane_state->crtc);
	if (!new_crtc_state)
		return -EINVAL;

	ret = dm_plane_helper_check_state(state, new_crtc_state);
	ret = dm_plane_helper_check_state(new_plane_state, new_crtc_state);
	if (ret)
		return ret;

	ret = fill_dc_scaling_info(state, &scaling_info);
	ret = fill_dc_scaling_info(new_plane_state, &scaling_info);
	if (ret)
		return ret;

+6 −5
Original line number Diff line number Diff line
@@ -69,20 +69,21 @@ komeda_plane_init_data_flow(struct drm_plane_state *st,
 */
static int
komeda_plane_atomic_check(struct drm_plane *plane,
			  struct drm_plane_state *state)
			  struct drm_plane_state *new_plane_state)
{
	struct komeda_plane *kplane = to_kplane(plane);
	struct komeda_plane_state *kplane_st = to_kplane_st(state);
	struct komeda_plane_state *kplane_st = to_kplane_st(new_plane_state);
	struct komeda_layer *layer = kplane->layer;
	struct drm_crtc_state *crtc_st;
	struct komeda_crtc_state *kcrtc_st;
	struct komeda_data_flow_cfg dflow;
	int err;

	if (!state->crtc || !state->fb)
	if (!new_plane_state->crtc || !new_plane_state->fb)
		return 0;

	crtc_st = drm_atomic_get_crtc_state(state->state, state->crtc);
	crtc_st = drm_atomic_get_crtc_state(new_plane_state->state,
					    new_plane_state->crtc);
	if (IS_ERR(crtc_st) || !crtc_st->enable) {
		DRM_DEBUG_ATOMIC("Cannot update plane on a disabled CRTC.\n");
		return -EINVAL;
@@ -94,7 +95,7 @@ komeda_plane_atomic_check(struct drm_plane *plane,

	kcrtc_st = to_kcrtc_st(crtc_st);

	err = komeda_plane_init_data_flow(state, kcrtc_st, &dflow);
	err = komeda_plane_init_data_flow(new_plane_state, kcrtc_st, &dflow);
	if (err)
		return err;

+10 −8
Original line number Diff line number Diff line
@@ -229,12 +229,12 @@ static const struct drm_crtc_helper_funcs hdlcd_crtc_helper_funcs = {
};

static int hdlcd_plane_atomic_check(struct drm_plane *plane,
				    struct drm_plane_state *state)
				    struct drm_plane_state *new_plane_state)
{
	int i;
	struct drm_crtc *crtc;
	struct drm_crtc_state *crtc_state;
	u32 src_h = state->src_h >> 16;
	u32 src_h = new_plane_state->src_h >> 16;

	/* only the HDLCD_REG_FB_LINE_COUNT register has a limit */
	if (src_h >= HDLCD_MAX_YRES) {
@@ -242,11 +242,13 @@ static int hdlcd_plane_atomic_check(struct drm_plane *plane,
		return -EINVAL;
	}

	for_each_new_crtc_in_state(state->state, crtc, crtc_state, i) {
	for_each_new_crtc_in_state(new_plane_state->state, crtc, crtc_state,
				   i) {
		/* we cannot disable the plane while the CRTC is active */
		if (!state->fb && crtc_state->active)
		if (!new_plane_state->fb && crtc_state->active)
			return -EINVAL;
		return drm_atomic_helper_check_plane_state(state, crtc_state,
		return drm_atomic_helper_check_plane_state(new_plane_state,
							   crtc_state,
							   DRM_PLANE_HELPER_NO_SCALING,
							   DRM_PLANE_HELPER_NO_SCALING,
							   false, true);
+18 −18
Original line number Diff line number Diff line
@@ -502,20 +502,20 @@ static void malidp_de_prefetch_settings(struct malidp_plane *mp,
}

static int malidp_de_plane_check(struct drm_plane *plane,
				 struct drm_plane_state *state)
				 struct drm_plane_state *new_plane_state)
{
	struct malidp_plane *mp = to_malidp_plane(plane);
	struct malidp_plane_state *ms = to_malidp_plane_state(state);
	bool rotated = state->rotation & MALIDP_ROTATED_MASK;
	struct malidp_plane_state *ms = to_malidp_plane_state(new_plane_state);
	bool rotated = new_plane_state->rotation & MALIDP_ROTATED_MASK;
	struct drm_framebuffer *fb;
	u16 pixel_alpha = state->pixel_blend_mode;
	u16 pixel_alpha = new_plane_state->pixel_blend_mode;
	int i, ret;
	unsigned int block_w, block_h;

	if (!state->crtc || WARN_ON(!state->fb))
	if (!new_plane_state->crtc || WARN_ON(!new_plane_state->fb))
		return 0;

	fb = state->fb;
	fb = new_plane_state->fb;

	ms->format = malidp_hw_get_format_id(&mp->hwdev->hw->map,
					     mp->layer->id, fb->format->format,
@@ -541,15 +541,15 @@ static int malidp_de_plane_check(struct drm_plane *plane,
		DRM_DEBUG_KMS("Buffer width/height needs to be a multiple of tile sizes");
		return -EINVAL;
	}
	if ((state->src_x >> 16) % block_w || (state->src_y >> 16) % block_h) {
	if ((new_plane_state->src_x >> 16) % block_w || (new_plane_state->src_y >> 16) % block_h) {
		DRM_DEBUG_KMS("Plane src_x/src_y needs to be a multiple of tile sizes");
		return -EINVAL;
	}

	if ((state->crtc_w > mp->hwdev->max_line_size) ||
	    (state->crtc_h > mp->hwdev->max_line_size) ||
	    (state->crtc_w < mp->hwdev->min_line_size) ||
	    (state->crtc_h < mp->hwdev->min_line_size))
	if ((new_plane_state->crtc_w > mp->hwdev->max_line_size) ||
	    (new_plane_state->crtc_h > mp->hwdev->max_line_size) ||
	    (new_plane_state->crtc_w < mp->hwdev->min_line_size) ||
	    (new_plane_state->crtc_h < mp->hwdev->min_line_size))
		return -EINVAL;

	/*
@@ -559,15 +559,15 @@ static int malidp_de_plane_check(struct drm_plane *plane,
	 */
	if (ms->n_planes == 3 &&
	    !(mp->hwdev->hw->features & MALIDP_DEVICE_LV_HAS_3_STRIDES) &&
	    (state->fb->pitches[1] != state->fb->pitches[2]))
	    (new_plane_state->fb->pitches[1] != new_plane_state->fb->pitches[2]))
		return -EINVAL;

	ret = malidp_se_check_scaling(mp, state);
	ret = malidp_se_check_scaling(mp, new_plane_state);
	if (ret)
		return ret;

	/* validate the rotation constraints for each layer */
	if (state->rotation != DRM_MODE_ROTATE_0) {
	if (new_plane_state->rotation != DRM_MODE_ROTATE_0) {
		if (mp->layer->rot == ROTATE_NONE)
			return -EINVAL;
		if ((mp->layer->rot == ROTATE_COMPRESSED) && !(fb->modifier))
@@ -588,11 +588,11 @@ static int malidp_de_plane_check(struct drm_plane *plane,
	}

	ms->rotmem_size = 0;
	if (state->rotation & MALIDP_ROTATED_MASK) {
	if (new_plane_state->rotation & MALIDP_ROTATED_MASK) {
		int val;

		val = mp->hwdev->hw->rotmem_required(mp->hwdev, state->crtc_w,
						     state->crtc_h,
		val = mp->hwdev->hw->rotmem_required(mp->hwdev, new_plane_state->crtc_w,
						     new_plane_state->crtc_h,
						     fb->format->format,
						     !!(fb->modifier));
		if (val < 0)
@@ -602,7 +602,7 @@ static int malidp_de_plane_check(struct drm_plane *plane,
	}

	/* HW can't support plane + pixel blending */
	if ((state->alpha != DRM_BLEND_ALPHA_OPAQUE) &&
	if ((new_plane_state->alpha != DRM_BLEND_ALPHA_OPAQUE) &&
	    (pixel_alpha != DRM_MODE_BLEND_PIXEL_NONE) &&
	    fb->format->has_alpha)
		return -EINVAL;
+22 −19
Original line number Diff line number Diff line
@@ -106,50 +106,53 @@ void armada_drm_plane_cleanup_fb(struct drm_plane *plane,
}

int armada_drm_plane_atomic_check(struct drm_plane *plane,
	struct drm_plane_state *state)
	struct drm_plane_state *new_plane_state)
{
	struct armada_plane_state *st = to_armada_plane_state(state);
	struct drm_crtc *crtc = state->crtc;
	struct armada_plane_state *st = to_armada_plane_state(new_plane_state);
	struct drm_crtc *crtc = new_plane_state->crtc;
	struct drm_crtc_state *crtc_state;
	bool interlace;
	int ret;

	if (!state->fb || WARN_ON(!state->crtc)) {
		state->visible = false;
	if (!new_plane_state->fb || WARN_ON(!new_plane_state->crtc)) {
		new_plane_state->visible = false;
		return 0;
	}

	if (state->state)
		crtc_state = drm_atomic_get_existing_crtc_state(state->state, crtc);
	if (new_plane_state->state)
		crtc_state = drm_atomic_get_existing_crtc_state(new_plane_state->state,
								crtc);
	else
		crtc_state = crtc->state;

	ret = drm_atomic_helper_check_plane_state(state, crtc_state, 0,
	ret = drm_atomic_helper_check_plane_state(new_plane_state, crtc_state,
						  0,
						  INT_MAX, true, false);
	if (ret)
		return ret;

	interlace = crtc_state->adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE;
	if (interlace) {
		if ((state->dst.y1 | state->dst.y2) & 1)
		if ((new_plane_state->dst.y1 | new_plane_state->dst.y2) & 1)
			return -EINVAL;
		st->src_hw = drm_rect_height(&state->src) >> 17;
		st->dst_yx = state->dst.y1 >> 1;
		st->dst_hw = drm_rect_height(&state->dst) >> 1;
		st->src_hw = drm_rect_height(&new_plane_state->src) >> 17;
		st->dst_yx = new_plane_state->dst.y1 >> 1;
		st->dst_hw = drm_rect_height(&new_plane_state->dst) >> 1;
	} else {
		st->src_hw = drm_rect_height(&state->src) >> 16;
		st->dst_yx = state->dst.y1;
		st->dst_hw = drm_rect_height(&state->dst);
		st->src_hw = drm_rect_height(&new_plane_state->src) >> 16;
		st->dst_yx = new_plane_state->dst.y1;
		st->dst_hw = drm_rect_height(&new_plane_state->dst);
	}

	st->src_hw <<= 16;
	st->src_hw |= drm_rect_width(&state->src) >> 16;
	st->src_hw |= drm_rect_width(&new_plane_state->src) >> 16;
	st->dst_yx <<= 16;
	st->dst_yx |= state->dst.x1 & 0x0000ffff;
	st->dst_yx |= new_plane_state->dst.x1 & 0x0000ffff;
	st->dst_hw <<= 16;
	st->dst_hw |= drm_rect_width(&state->dst) & 0x0000ffff;
	st->dst_hw |= drm_rect_width(&new_plane_state->dst) & 0x0000ffff;

	armada_drm_plane_calc(state, st->addrs, st->pitches, interlace);
	armada_drm_plane_calc(new_plane_state, st->addrs, st->pitches,
			      interlace);
	st->interlace = interlace;

	return 0;
Loading