Commit 78e53303 authored by Dom Cobley's avatar Dom Cobley Committed by Maxime Ripard

drm/vc4: Correct lbm size and calculation

LBM base address is measured in units of pixels per cycle.
That is 4 for 2711 (hvs5) and 2 for 2708.

We are wasting 75% of lbm by indexing without the scaling.
But we were also using too high a size for the lbm resulting
in partial corruption (right hand side) of vertically
scaled images, usually at 4K or lower resolutions with more layers.

The physical RAM of LBM on 2711 is 8 * 1920 * 16 * 12-bit
(pixels are stored 12-bits per component regardless of format).

The LBM address indexes work in units of pixels per clock,
so for 4 pixels per clock that means we have 32 * 1920 = 60K

Fixes: c54619b0 ("drm/vc4: Add support for the BCM2711 HVS5")
Signed-off-by: default avatarDom Cobley <popcornmix@gmail.com>
Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
Reviewed-by: default avatarDave Stevenson <dave.stevenson@raspberrypi.com>
Tested-By: default avatarLucas Nussbaum <lucas@debian.org>
Tested-By: default avatarRyutaroh Matsumoto <ryutaroh@ict.e.titech.ac.jp>
Link: https://patchwork.freedesktop.org/patch/msgid/20210121105759.1262699-1-maxime@cerno.tech
parent a37eef63
...@@ -620,11 +620,11 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data) ...@@ -620,11 +620,11 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
* for now we just allocate globally. * for now we just allocate globally.
*/ */
if (!hvs->hvs5) if (!hvs->hvs5)
/* 96kB */ /* 48k words of 2x12-bit pixels */
drm_mm_init(&hvs->lbm_mm, 0, 96 * 1024); drm_mm_init(&hvs->lbm_mm, 0, 48 * 1024);
else else
/* 70k words */ /* 60k words of 4x12-bit pixels */
drm_mm_init(&hvs->lbm_mm, 0, 70 * 2 * 1024); drm_mm_init(&hvs->lbm_mm, 0, 60 * 1024);
/* Upload filter kernels. We only have the one for now, so we /* Upload filter kernels. We only have the one for now, so we
* keep it around for the lifetime of the driver. * keep it around for the lifetime of the driver.
......
...@@ -437,6 +437,7 @@ static void vc4_write_ppf(struct vc4_plane_state *vc4_state, u32 src, u32 dst) ...@@ -437,6 +437,7 @@ static void vc4_write_ppf(struct vc4_plane_state *vc4_state, u32 src, u32 dst)
static u32 vc4_lbm_size(struct drm_plane_state *state) static u32 vc4_lbm_size(struct drm_plane_state *state)
{ {
struct vc4_plane_state *vc4_state = to_vc4_plane_state(state); struct vc4_plane_state *vc4_state = to_vc4_plane_state(state);
struct vc4_dev *vc4 = to_vc4_dev(state->plane->dev);
u32 pix_per_line; u32 pix_per_line;
u32 lbm; u32 lbm;
...@@ -472,7 +473,11 @@ static u32 vc4_lbm_size(struct drm_plane_state *state) ...@@ -472,7 +473,11 @@ static u32 vc4_lbm_size(struct drm_plane_state *state)
lbm = pix_per_line * 16; lbm = pix_per_line * 16;
} }
lbm = roundup(lbm, 32); /* Align it to 64 or 128 (hvs5) bytes */
lbm = roundup(lbm, vc4->hvs->hvs5 ? 128 : 64);
/* Each "word" of the LBM memory contains 2 or 4 (hvs5) pixels */
lbm /= vc4->hvs->hvs5 ? 4 : 2;
return lbm; return lbm;
} }
......
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