dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
To: Maxime Ripard <mripard@kernel.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
	dri-devel@lists.freedesktop.org
Cc: Dave Stevenson <dave.stevenson@raspberrypi.com>
Subject: [PATCH 30/31] drm/vc4: Move the buffer offset out of the vc4_plane_state
Date: Thu, 20 Jun 2024 16:46:31 +0100	[thread overview]
Message-ID: <20240620154632.4125308-31-dave.stevenson@raspberrypi.com> (raw)
In-Reply-To: <20240620154632.4125308-1-dave.stevenson@raspberrypi.com>

The offset fields in vc4_plane_state are described as being
the offset for each buffer in the bo, however it is used to
store the complete DMA address that is then written into the
register.

The DMA address including the fb ofset  can be retrieved
using drm_fb_dma_get_gem_addr, and the offset adjustment due to
clipping is local to vc4_plane_mode_set.
Drop the offset field from the state, and compute the complete
DMA address in vc4_plane_mode_set.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 drivers/gpu/drm/vc4/vc4_drv.h   |  5 ----
 drivers/gpu/drm/vc4/vc4_plane.c | 51 +++++++++++++--------------------
 2 files changed, 20 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index 7a9faea748e6..c6be1997f1c7 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -421,11 +421,6 @@ struct vc4_plane_state {
 	bool is_unity;
 	bool is_yuv;
 
-	/* Offset to start scanning out from the start of the plane's
-	 * BO.
-	 */
-	u32 offsets[3];
-
 	/* Our allocation in LBM for temporary storage during scaling. */
 	struct drm_mm_node lbm;
 
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
index 4c61ef4f4142..ba6e86d62a77 100644
--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -450,12 +450,11 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
 {
 	struct vc4_plane_state *vc4_state = to_vc4_plane_state(state);
 	struct drm_framebuffer *fb = state->fb;
-	struct drm_gem_dma_object *bo;
 	int num_planes = fb->format->num_planes;
 	struct drm_crtc_state *crtc_state;
 	u32 h_subsample = fb->format->hsub;
 	u32 v_subsample = fb->format->vsub;
-	int i, ret;
+	int ret;
 
 	crtc_state = drm_atomic_get_existing_crtc_state(state->state,
 							state->crtc);
@@ -469,11 +468,6 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
 	if (ret)
 		return ret;
 
-	for (i = 0; i < num_planes; i++) {
-		bo = drm_fb_dma_get_gem_obj(fb, i);
-		vc4_state->offsets[i] = bo->dma_addr + fb->offsets[i];
-	}
-
 	vc4_state->src_x = state->src.x1;
 	vc4_state->src_y = state->src.y1;
 	vc4_state->src_w[0] = state->src.x2 - vc4_state->src_x;
@@ -902,6 +896,7 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
 	u32 width, height;
 	u32 hvs_format = format->hvs;
 	unsigned int rotation;
+	u32 offsets[3] = { 0 };
 	int ret, i;
 
 	if (vc4_state->dlist_initialized)
@@ -949,13 +944,8 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
 		 * out.
 		 */
 		for (i = 0; i < num_planes; i++) {
-			vc4_state->offsets[i] += src_y /
-						 (i ? v_subsample : 1) *
-						 fb->pitches[i];
-
-			vc4_state->offsets[i] += src_x /
-						 (i ? h_subsample : 1) *
-						 fb->format->cpp[i];
+			offsets[i] += src_y / (i ? v_subsample : 1) * fb->pitches[i];
+			offsets[i] += src_x / (i ? h_subsample : 1) * fb->format->cpp[i];
 		}
 
 		break;
@@ -1010,19 +1000,18 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
 			   VC4_SET_FIELD(y_off, SCALER_PITCH0_TILE_Y_OFFSET) |
 			   VC4_SET_FIELD(tiles_l, SCALER_PITCH0_TILE_WIDTH_L) |
 			   VC4_SET_FIELD(tiles_r, SCALER_PITCH0_TILE_WIDTH_R));
-		vc4_state->offsets[0] += tiles_t * (tiles_w << tile_size_shift);
-		vc4_state->offsets[0] += subtile_y << 8;
-		vc4_state->offsets[0] += utile_y << 4;
+		offsets[0] += tiles_t * (tiles_w << tile_size_shift);
+		offsets[0] += subtile_y << 8;
+		offsets[0] += utile_y << 4;
 
 		/* Rows of tiles alternate left-to-right and right-to-left. */
 		if (tiles_t & 1) {
 			pitch0 |= SCALER_PITCH0_TILE_INITIAL_LINE_DIR;
-			vc4_state->offsets[0] += (tiles_w - tiles_l) <<
-						 tile_size_shift;
-			vc4_state->offsets[0] -= (1 + !tile_y) << 10;
+			offsets[0] += (tiles_w - tiles_l) << tile_size_shift;
+			offsets[0] -= (1 + !tile_y) << 10;
 		} else {
-			vc4_state->offsets[0] += tiles_l << tile_size_shift;
-			vc4_state->offsets[0] += tile_y << 10;
+			offsets[0] += tiles_l << tile_size_shift;
+			offsets[0] += tile_y << 10;
 		}
 
 		break;
@@ -1111,11 +1100,9 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
 
 			tile = src_x / pix_per_tile;
 
-			vc4_state->offsets[i] += param * tile_w * tile;
-			vc4_state->offsets[i] += src_y /
-						 (i ? v_subsample : 1) *
-						 tile_w;
-			vc4_state->offsets[i] += x_off & ~(i ? 1 : 0);
+			offsets[i] += param * tile_w * tile;
+			offsets[i] += src_y / (i ? v_subsample : 1) * tile_w;
+			offsets[i] += x_off & ~(i ? 1 : 0);
 		}
 
 		pitch0 = VC4_SET_FIELD(param, SCALER_TILE_HEIGHT);
@@ -1261,8 +1248,12 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
 	 * The pointers may be any byte address.
 	 */
 	vc4_state->ptr0_offset[0] = vc4_state->dlist_count;
-	for (i = 0; i < num_planes; i++)
-		vc4_dlist_write(vc4_state, vc4_state->offsets[i]);
+
+	for (i = 0; i < num_planes; i++) {
+		struct drm_gem_dma_object *bo = drm_fb_dma_get_gem_obj(fb, i);
+
+		vc4_dlist_write(vc4_state, bo->dma_addr + fb->offsets[i] + offsets[i]);
+	}
 
 	/* Pointer Context Word 0/1/2: Written by the HVS */
 	for (i = 0; i < num_planes; i++)
@@ -1525,8 +1516,6 @@ static void vc4_plane_atomic_async_update(struct drm_plane *plane,
 	       sizeof(vc4_state->y_scaling));
 	vc4_state->is_unity = new_vc4_state->is_unity;
 	vc4_state->is_yuv = new_vc4_state->is_yuv;
-	memcpy(vc4_state->offsets, new_vc4_state->offsets,
-	       sizeof(vc4_state->offsets));
 	vc4_state->needs_bg_fill = new_vc4_state->needs_bg_fill;
 
 	/* Update the current vc4_state pos0, pos2 and ptr0 dlist entries. */
-- 
2.34.1


  parent reply	other threads:[~2024-06-20 15:47 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-20 15:46 [PATCH 00/31] Preparatory patches for BCM2712 (Pi5) support Dave Stevenson
2024-06-20 15:46 ` [PATCH 01/31] drm/vc4: vc4_plane: Keep fractional source coords inside state Dave Stevenson
2024-06-20 15:46 ` [PATCH 02/31] drm/vc4: Handle fractional coordinates using the phase field Dave Stevenson
2024-06-20 15:46 ` [PATCH 03/31] drm/vc4: Force trigger of dlist update on margins change Dave Stevenson
2024-06-20 15:46 ` [PATCH 04/31] drm/vc4: hdmi: Avoid log spam for audio start failure Dave Stevenson
2024-06-20 15:46 ` [PATCH 05/31] drm/vc4_plane: Add support for YUV444 formats Dave Stevenson
2024-06-21  8:57   ` Maxime Ripard
2024-06-21  9:56     ` Dave Stevenson
2024-06-20 15:46 ` [PATCH 06/31] drm/vc4: Set AXI panic modes for the HVS Dave Stevenson
2024-06-20 15:46 ` [PATCH 07/31] drm/vc4: Limit max_bpc to 8 on Pi0-3 Dave Stevenson
2024-06-20 15:46 ` [PATCH 08/31] drm/vc4: hdmi: Increase audio MAI fifo dreq threshold Dave Stevenson
2024-06-20 15:46 ` [PATCH 09/31] drm/vc4: hdmi: Warn if writing to an unknown HDMI register Dave Stevenson
2024-06-20 15:46 ` [PATCH 10/31] drm/vc4: hvs: More logging for dlist generation Dave Stevenson
2024-06-20 15:46 ` [PATCH 11/31] drm/vc4: hvs: Print error if we fail an allocation Dave Stevenson
2024-06-20 15:46 ` [PATCH 12/31] drm/vc4: plane: Add more debugging for LBM allocation Dave Stevenson
2024-06-20 15:46 ` [PATCH 13/31] drm/vc4: plane: Use return variable in atomic_check Dave Stevenson
2024-06-20 15:46 ` [PATCH 14/31] drm/vc4: crtc: Move assigned_channel to a variable Dave Stevenson
2024-06-20 15:46 ` [PATCH 15/31] drm/vc4: Don't write gamma luts on 2711 Dave Stevenson
2024-06-20 15:46 ` [PATCH 16/31] drm/vc4: UV planes vertical scaling must always be enabled Dave Stevenson
2024-06-20 15:46 ` [PATCH 17/31] drm/vc4: hdmi: Avoid hang with debug registers when suspended Dave Stevenson
2024-06-20 15:46 ` [PATCH 18/31] drm/vc4: Fix dlist debug not resetting the next entry pointer Dave Stevenson
2024-06-20 15:46 ` [PATCH 19/31] drm/vc4: Remove incorrect limit from hvs_dlist debugfs function Dave Stevenson
2024-06-20 15:46 ` [PATCH 20/31] drm/vc4: hvs: Remove ABORT_ON_EMPTY flag Dave Stevenson
2024-06-20 15:46 ` [PATCH 21/31] drm/vc4: Introduce generation number enum Dave Stevenson
2024-06-20 15:46 ` [PATCH 22/31] drm/vc4: Make v3d paths unavailable on any generation newer than vc4 Dave Stevenson
2024-06-20 15:46 ` [PATCH 23/31] drm/vc4: hvs: Use switch statement to simplify vc4_hvs_get_fifo_from_output Dave Stevenson
2024-06-20 15:46 ` [PATCH 24/31] drm/vc4: hvs: Create hw_init function Dave Stevenson
2024-06-20 15:46 ` [PATCH 25/31] drm/vc4: hvs: Create cob_init function Dave Stevenson
2024-06-20 15:46 ` [PATCH 26/31] drm/vc4: hvs: Rename hvs_regs list Dave Stevenson
2024-06-20 15:46 ` [PATCH 27/31] drm/vc4: plane: Change ptr0_offset to an array Dave Stevenson
2024-06-20 15:46 ` [PATCH 28/31] drm/vc4: hvs: Rework LBM alignment Dave Stevenson
2024-06-20 15:46 ` [PATCH 29/31] drm/vc4: hvs: Change prototype of __vc4_hvs_alloc to pass registers Dave Stevenson
2024-06-20 15:46 ` Dave Stevenson [this message]
2024-06-20 15:46 ` [PATCH 31/31] drm/vc4: Enable SCALER_CONTROL early in HVS init Dave Stevenson
2024-06-21  8:55 ` [PATCH 00/31] Preparatory patches for BCM2712 (Pi5) support Maxime Ripard
2024-06-21 10:16   ` Dave Stevenson
2024-06-24 14:19     ` Maxime Ripard
2024-06-24 14:45       ` Dave Stevenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240620154632.4125308-31-dave.stevenson@raspberrypi.com \
    --to=dave.stevenson@raspberrypi.com \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox