drm/vc4: Fix negative X/Y positioning of planes
Subsystems (3)
cover drm/vc4: Fix negative X/Y positioning of planes
Hello Eric,
This is an attempt at fixing support for negative X/Y positioning of various FB formats. I kept you as the author since I started from your initial work and fixed a few things + split the changes in several commits. Let me know if that's a problem, and I change the author.
This series has been tested with a modified modetest (support for this modifier has been added).
Note that I plan to test/debug support for negative X/Y positioning of SANDXX planes.
Regards,
Boris
Eric Anholt (5):
drm/vc4: Fix TILE_Y_OFFSET definitions
drm/vc4: Define missing PICTH0_SINK_PIX field
drm/vc4: Use drm_atomic_helper_check_plane_state() to simplify the
logic
drm/vc4: Move ->offsets[] adjustment out of
setup_clipping_and_scaling()
drm/vc4: Fix negative X/Y positioning of planes using T_TILES modifier
drivers/gpu/drm/vc4/vc4_drv.h | 9 -- drivers/gpu/drm/vc4/vc4_plane.c | 272 ++++++++++++++++++++++++---------------- drivers/gpu/drm/vc4/vc4_regs.h | 8 +- 3 files changed, 170 insertions(+), 119 deletions(-)
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/5 drm/vc4: Fix TILE_Y_OFFSET definitions
From: Eric Anholt <[email protected]>
Y_OFFSET field starts at bit 8 not 7.
--- drivers/gpu/drm/vc4/vc4_regs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_regs.h +2 -2
@@ -1043,8 +1043,8 @@ enum hvs_pixel_format {#define SCALER_PITCH0_TILE_LINE_DIR BIT(15)#define SCALER_PITCH0_TILE_INITIAL_LINE_DIR BIT(14)/* Y offset within a tile. */ -#define SCALER_PITCH0_TILE_Y_OFFSET_MASK VC4_MASK(13, 7) -#define SCALER_PITCH0_TILE_Y_OFFSET_SHIFT 7 +#define SCALER_PITCH0_TILE_Y_OFFSET_MASK VC4_MASK(13, 8) +#define SCALER_PITCH0_TILE_Y_OFFSET_SHIFT 8#define SCALER_PITCH0_TILE_WIDTH_R_MASK VC4_MASK(6, 0)#define SCALER_PITCH0_TILE_WIDTH_R_SHIFT 0
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/5 drm/vc4: Define missing PICTH0_SINK_PIX field
In reply to Boris BrezillonFrom: Eric Anholt <[email protected]>
This is needed to support X/Y negative placement of planes using T-format buffers.
--- drivers/gpu/drm/vc4/vc4_regs.h | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/vc4/vc4_regs.h +4 -0
@@ -1037,6 +1037,10 @@ enum hvs_pixel_format {#define SCALER_TILE_HEIGHT_MASK VC4_MASK(15, 0)#define SCALER_TILE_HEIGHT_SHIFT 0 +/* Common PITCH0 fields */ +#define SCALER_PITCH0_SINK_PIX_MASK VC4_MASK(31, 26) +#define SCALER_PITCH0_SINK_PIX_SHIFT 26 +/* PITCH0 fields for T-tiled. */ #define SCALER_PITCH0_TILE_WIDTH_L_MASK VC4_MASK(22, 16)#define SCALER_PITCH0_TILE_WIDTH_L_SHIFT 16
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/5 drm/vc4: Use drm_atomic_helper_check_plane_state() to simplify the logic
In reply to Boris BrezillonFrom: Eric Anholt <[email protected]>
drm_atomic_helper_check_plane_state() takes care of checking the scaling capabilities and calculating the clipped X/Y offsets for us.
Rely on this function instead of open-coding the logic. While at it, we get rid of a few fields in vc4_plane_state that can be easily extracted from drm_plane_state.
Incidentally, it seems to fix a problem we had with negative X/Y positioning of YUV planes.
--- drivers/gpu/drm/vc4/vc4_drv.h | 9 -- drivers/gpu/drm/vc4/vc4_plane.c | 210 +++++++++++++++++++++------------------- 2 files changed, 111 insertions(+), 108 deletions(-)
drivers/gpu/drm/vc4/vc4_drv.h +0 -9
@@ -344,17 +344,8 @@ struct vc4_plane_state {*/ u32 __iomem *hw_dlist; -/* Clipped coordinates of the plane on the display. */ -int crtc_x, crtc_y, crtc_w, crtc_h; -/* Clipped area being scanned from in the FB. */ -u32 src_x, src_y; - -u32 src_w[2 ], src_h[2 ]; -/* Scaling selection for the RGB/Y plane and the Cb/Cr planes. */ enum vc4_scaling_mode x_scaling[2 ], y_scaling[2 ]; -bool is_unity; -bool is_yuv;/* Offset to start scanning out from the start of the plane's * BO.
drivers/gpu/drm/vc4/vc4_plane.c +111 -99
319 lines not on this page · raw message
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/5 drm/vc4: Move ->offsets[] adjustment out of setup_clipping_and_scaling()
In reply to Boris BrezillonFrom: Eric Anholt <[email protected]>
The offset adjustment depends on the framebuffer modified, so let's just move this operation in the DRM_FORMAT_MOD_LINEAR case inside vc4_plane_mode_set().
This we'll be able to fix offset calculation for DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED and DRM_FORMAT_MOD_BROADCOM_SANDXXX.
--- drivers/gpu/drm/vc4/vc4_plane.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/vc4/vc4_plane.c +15 -8
@@ -354,14 +354,6 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state) vc4_state->y_scaling[1 ] =VC4_SCALING_NONE ; } -/* Adjust the base pointer to the first pixel to be scanned 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]; - } -return 0 ; }
@@ -476,6 +468,7 @@ static int vc4_plane_mode_set(struct drm_plane *plane,u64 base_format_mod =fourcc_mod_broadcom_mod (fb->modifier);int num_planes =drm_format_num_planes (format->drm);u32 src_x, src_y, crtc_h, crtc_w, src_h, src_w; +u32 h_subsample, v_subsample;bool mix_plane_alpha;bool covers_screen;u32 scl0, scl1, pitch0;
@@ -527,11 +520,25 @@ static int vc4_plane_mode_set(struct drm_plane *plane, src_y = state->src.y1 >>16 ; src_w = (state->src.x2 - state->src.x1) >>16 ; src_h = (state->src.y2 - state->src.y1) >>16 ; + h_subsample =drm_format_horz_chroma_subsampling (format->drm); + v_subsample =drm_format_vert_chroma_subsampling (format->drm);switch (base_format_mod) {case DRM_FORMAT_MOD_LINEAR : tiling =SCALER_CTL0_TILING_LINEAR ; pitch0 =VC4_SET_FIELD (fb->pitches[0 ],SCALER_SRC_PITCH ); + +/* Adjust the base pointer to the first pixel to be scanned +* 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]; + }break ;case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED : {
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/5 drm/vc4: Fix negative X/Y positioning of planes using T_TILES modifier
In reply to Boris BrezillonFrom: Eric Anholt <[email protected]>
X/Y positioning of T-format buffers is quite tricky and the current implementation was failing to position a plane using this format correctly when the X, Y or both X and Y offsets were negative.
---
Hi Eric,
I kept the SoB and authorship since you're the original author, but I also significantly reworked the code, so I'd be more confident if you could have a close look at this code.
It's been tested with a modified modetest (one that supports generating T-format buffers) and it seems to work fine with any kind of negative X/Y offset (both when starting on an even or an odd tile row).
Also, I intentionally did not add a Fixes and Cc-stable to this commit because it depends on a rework we've done in vc4_plane_setup_clipping_and_scaling() which cannot be easily backported.
What I could do though is add a patch that rejects all negative crtc_{x,y}.
Regards,
Boris
--- drivers/gpu/drm/vc4/vc4_plane.c | 51 +++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-)
drivers/gpu/drm/vc4/vc4_plane.c +44 -7
@@ -539,22 +539,59 @@ static int vc4_plane_mode_set(struct drm_plane *plane, (i ? h_subsample :1 ) * fb->format->cpp[i]; } +break ;case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED : { -/* For T-tiled, the FB pitch is "how many bytes from -* one row to the next, such that pitch * tile_h == -* tile_size * tiles_per_row." -*/ u32 tile_size_shift =12 ;/* T tiles are 4kb */ +/* Whole-tile offsets, mostly for setting the pitch. */ +u32 tile_w_shift = fb->format->cpp[0 ] ==2 ?6 :5 ;u32 tile_h_shift =5 ;/* 16 and 32bpp are 32 pixels high */ +u32 tile_w_mask = (1 << tile_w_shift) -1 ; +/* The height mask on 32-bit-per-pixel tiles is 63, i.e. 2 +* times the height (in pixels) of a 4k tile. I just assumed +* this is also true for other RGB formats, but maybe it's not. +*/ +u32 tile_h_mask = (2 << tile_h_shift) -1 ; +/* For T-tiled, the FB pitch is "how many bytes from one row to +* the next, such that +* +* pitch * tile_h == tile_size * tiles_per_row +*/ u32 tiles_w = fb->pitches[0 ] >> (tile_size_shift - tile_h_shift); +u32 tiles_l = src_x >> tile_w_shift; +u32 tiles_r = tiles_w - tiles_l; +u32 tiles_t = src_y >> tile_h_shift; +/* Intra-tile offsets, which modify the base address (the +* SCALER_PITCH0_TILE_Y_OFFSET tells HVS how to walk from that +* base address). +*/ +u32 tile_y = (src_y >>4 ) &1 ; +u32 subtile_y = (src_y >>2 ) &3 ; +u32 utile_y = src_y &3 ; +u32 x_off = src_x & tile_w_mask; +u32 y_off = src_y & tile_h_mask; tiling =SCALER_CTL0_TILING_256B_OR_T ; + pitch0 = (VC4_SET_FIELD (x_off,SCALER_PITCH0_SINK_PIX ) | +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 ; + +/* 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 ; + }else { + vc4_state->offsets[0 ] += tiles_l << tile_size_shift; + vc4_state->offsets[0 ] += tile_y <<10 ; + } - pitch0 = (VC4_SET_FIELD (0 ,SCALER_PITCH0_TILE_Y_OFFSET ) | -VC4_SET_FIELD (0 ,SCALER_PITCH0_TILE_WIDTH_L ) | -VC4_SET_FIELD (tiles_w,SCALER_PITCH0_TILE_WIDTH_R ));break ; }
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/5] drm/vc4: Define missing PICTH0_SINK_PIX field
In reply to Boris BrezillonQuoted 1 line · Boris Brezillon
From: Eric Anholt <[email protected]>
In the subject, s/PICTH/PITCH/
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/5] drm/vc4: Use drm_atomic_helper_check_plane_state() to simplify the logic
In reply to Boris BrezillonQuoted 12 lines · Boris Brezillon
From: Eric Anholt <[email protected]>
drm_atomic_helper_check_plane_state()takes care of checking the scaling capabilities and calculating the clipped X/Y offsets for us.Rely on this function instead of open-coding the logic. While at it, we get rid of a few fields in
vc4_plane_statethat can be easily extracted fromdrm_plane_state.Incidentally, it seems to fix a problem we had with negative X/Y positioning of YUV planes.
Quoted 6 lines
Signed-off-by Eric Anholt <[email protected]>Signed-off-by Boris Brezillon <[email protected]>--- drivers/gpu/drm/vc4/vc4_drv.h | 9 -- drivers/gpu/drm/vc4/vc4_plane.c | 210 +++++++++++++++++++++------------------- 2 files changed, 111 insertions(+), 108 deletions(-)
I feel like you ought to grab authorship of this patch -- you've made a bunch of good changes since my WIP patch.
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 341
Quoted 9 lines
drivers/gpu/drm/vc4/vc4_plane.c +2
-6if (num_planes >1 ) { - vc4_state->is_yuv = true; - - h_subsample =drm_format_horz_chroma_subsampling (format); - v_subsample =drm_format_vert_chroma_subsampling (format); - vc4_state->src_w[1 ] = vc4_state->src_w[0 ] / h_subsample; - vc4_state->src_h[1 ] = vc4_state->src_h[0 ] / v_subsample; + src_w /= h_subsample; + src_h /= v_subsample;
I'm a little nervous about leaving src_w/src_h divided after this block, in case we end up using them in some other calculation in a later change. Could we just move the divide into the vc4_get_scaling_mode() call?
In general, I'm not enthusiastic about having src_w computations in 5 places now. Was keeping it in the vc4 state that much of a problem?
I'm not saying no, but copy-and-paste of these kinds of calculations are also a frequent source of bugs when you miss a x->y or w->h change.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 5/5] drm/vc4: Fix negative X/Y positioning of planes using T_TILES modifier
In reply to Boris BrezillonQuoted 5 lines · Boris Brezillon
From: Eric Anholt <[email protected]>
X/Y positioning of T-format buffers is quite tricky and the current implementation was failing to position a plane using this format correctly when the X, Y or both X and Y offsets were negative.
Wait, were things working for you with even postivie X/Y offsets on T? Because it wasn't for me, and I think the tile_h_mask change is important for making positive work.
Quoted 8 lines
Signed-off-by Eric Anholt <[email protected]>Signed-off-by Boris Brezillon <[email protected]>---
Hi Eric,I kept the SoB and authorship since you're the original author, but I also significantly reworked the code, so I'd be more confident if you could have a close look at this code.
I think you should definitely grab authorship on this one. You did the work to make it actually work.
Quoted 6 lines
Also, I intentionally did not add a Fixes and Cc-stable to this commit because it depends on a rework we've done in
vc4_plane_setup_clipping_and_scaling()which cannot be easily backported.
What I could do though is add a patch that rejects all negative crtc_{x,y}.
Agreed. Given that we're trying to fix a bug that nobody else has reported to me yet, I think we can skip dealing with this for stable.
Quoted 20 lines
--- drivers/gpu/drm/vc4/vc4_plane.c | 51 +++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-)drivers/gpu/drm/vc4/vc4_plane.c +1
-4@@ -539,22 +539,59 @@ static int vc4_plane_mode_set(struct drm_plane *plane, (i ? h_subsample :1 ) * fb->format->cpp[i]; } +break ;case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED : { -/* For T-tiled, the FB pitch is "how many bytes from -* one row to the next, such that pitch * tile_h == -* tile_size * tiles_per_row." -*/
drivers/gpu/drm/vc4/vc4_plane.c static int vc4_plane_mode_set(struct drm_plane *plane, · line 555
Quoted 10 lines
drivers/gpu/drm/vc4/vc4_plane.c +8
-0u32 tile_size_shift =12 ;/* T tiles are 4kb */ +/* Whole-tile offsets, mostly for setting the pitch. */ +u32 tile_w_shift = fb->format->cpp[0 ] ==2 ?6 :5 ;u32 tile_h_shift =5 ;/* 16 and 32bpp are 32 pixels high */ +u32 tile_w_mask = (1 << tile_w_shift) -1 ; +/* The height mask on 32-bit-per-pixel tiles is 63, i.e. 2 +* times the height (in pixels) of a 4k tile. I just assumed +* this is also true for other RGB formats, but maybe it's not. +*/ +u32 tile_h_mask = (2 << tile_h_shift) -1 ;
Only 2 and 4-byte formats are supported for T format, and tiles are 32 pixels high for both of those.
Other than that,
I have a comment on patch 3 I'd like to sort out, but other than that I'm pleased with this whole series. Thanks for persevering on it!
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/5] drm/vc4: Use drm_atomic_helper_check_plane_state() to simplify the logic
In reply to Eric AnholtQuoted 39 lines · On Fri, 27 Jul 2018 13:38:08 -0700 Eric Anholt <[email protected]> wrote:
Quoted 12 lines · Boris Brezillon
From: Eric Anholt <[email protected]>
drm_atomic_helper_check_plane_state()takes care of checking the scaling capabilities and calculating the clipped X/Y offsets for us.Rely on this function instead of open-coding the logic. While at it, we get rid of a few fields in
vc4_plane_statethat can be easily extracted fromdrm_plane_state.Incidentally, it seems to fix a problem we had with negative X/Y positioning of YUV planes.
Quoted 6 lines
Signed-off-by Eric Anholt <[email protected]>Signed-off-by Boris Brezillon <[email protected]>--- drivers/gpu/drm/vc4/vc4_drv.h | 9 -- drivers/gpu/drm/vc4/vc4_plane.c | 210 +++++++++++++++++++++------------------- 2 files changed, 111 insertions(+), 108 deletions(-)I feel like you ought to grab authorship of this patch -- you've made a bunch of good changes since my WIP patch.
drivers/gpu/drm/vc4/vc4_plane.c static u32 vc4_get_scl_field(struct drm_plane_state *state, int plane) · line 341
Quoted 9 lines
drivers/gpu/drm/vc4/vc4_plane.c +2
-6if (num_planes >1 ) { - vc4_state->is_yuv = true; - - h_subsample =drm_format_horz_chroma_subsampling (format); - v_subsample =drm_format_vert_chroma_subsampling (format); - vc4_state->src_w[1 ] = vc4_state->src_w[0 ] / h_subsample; - vc4_state->src_h[1 ] = vc4_state->src_h[0 ] / v_subsample; + src_w /= h_subsample; + src_h /= v_subsample;I'm a little nervous about leaving src_w/src_h divided after this block, in case we end up using them in some other calculation in a later change. Could we just move the divide into the
vc4_get_scaling_mode()call?
Quoted 2 lines
In general, I'm not enthusiastic about having
src_wcomputations in 5 places now. Was keeping it in the vc4 state that much of a problem?
No strong objection to keeping ->src_{h,w}[] arrays in vc4_plane_state.
Quoted 3 lines
I'm not saying no, but copy-and-paste of these kinds of calculations are also a frequent source of bugs when you miss a
x->yorw->hchange.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/5] drm/vc4: Move ->offsets[] adjustment out of setup_clipping_and_scaling()
In reply to Boris BrezillonQuoted 3 lines · On Wed, 25 Jul 2018 17:32:08 +0200 Boris Brezillon…
From: Eric Anholt <[email protected]>
The offset adjustment depends on the framebuffer modified, so let's
^ modifier
Quoted 4 lines
just move this operation in the
DRM_FORMAT_MOD_LINEARcase insidevc4_plane_mode_set().This we'll be able to fix offset calculation for
^ Thanks to this, we'll ...
Quoted 51 lines
DRM_FORMAT_MOD_BROADCOM_VC4_T_TILEDandDRM_FORMAT_MOD_BROADCOM_SANDXXX.Signed-off-by Eric Anholt <[email protected]>Signed-off-by Boris Brezillon <[email protected]>--- drivers/gpu/drm/vc4/vc4_plane.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)drivers/gpu/drm/vc4/vc4_plane.c +8
-8@@ -354,14 +354,6 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state) vc4_state->y_scaling[1 ] =VC4_SCALING_NONE ; } -/* Adjust the base pointer to the first pixel to be scanned 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]; - } -return 0 ; }@@ -476,6 +468,7 @@ static int vc4_plane_mode_set(struct drm_plane *plane,u64 base_format_mod =fourcc_mod_broadcom_mod (fb->modifier);int num_planes =drm_format_num_planes (format->drm);u32 src_x, src_y, crtc_h, crtc_w, src_h, src_w; +u32 h_subsample, v_subsample;bool mix_plane_alpha;bool covers_screen;u32 scl0, scl1, pitch0;@@ -527,11 +520,25 @@ static int vc4_plane_mode_set(struct drm_plane *plane, src_y = state->src.y1 >>16 ; src_w = (state->src.x2 - state->src.x1) >>16 ; src_h = (state->src.y2 - state->src.y1) >>16 ; + h_subsample =drm_format_horz_chroma_subsampling (format->drm); + v_subsample =drm_format_vert_chroma_subsampling (format->drm);switch (base_format_mod) {case DRM_FORMAT_MOD_LINEAR : tiling =SCALER_CTL0_TILING_LINEAR ; pitch0 =VC4_SET_FIELD (fb->pitches[0 ],SCALER_SRC_PITCH ); + +/* Adjust the base pointer to the first pixel to be scanned +* out. +*/ +for (i =0 ; i < num_planes; i++) {
drivers/gpu/drm/vc4/vc4_plane.c static int vc4_plane_mode_set(struct drm_plane *plane, · line 544
Quoted 10 lines
drivers/gpu/drm/vc4/vc4_plane.c +7
-0+ 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]; + }break ;case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED : {
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 5/5] drm/vc4: Fix negative X/Y positioning of planes using T_TILES modifier
In reply to Eric AnholtQuoted 11 lines · On Fri, 27 Jul 2018 13:46:31 -0700 Eric Anholt <[email protected]> wrote:
Quoted 5 lines · Boris Brezillon
From: Eric Anholt <[email protected]>
X/Y positioning of T-format buffers is quite tricky and the current implementation was failing to position a plane using this format correctly when the X, Y or both X and Y offsets were negative.
Wait, were things working for you with even postivie X/Y offsets on T? Because it wasn't for me, and I think the
tile_h_maskchange is important for making positive work.
Not so sure. I've done so many tests that I don't remember which exact setups were working and which ones were not. I'll test again before sending v2 and adjust the commit message accordingly.
Quoted 6 lines
Quoted 6 lines
Signed-off-by Eric Anholt <[email protected]>Signed-off-by Boris Brezillon <[email protected]>---
Hi Eric,
Quoted 7 lines
Quoted 3 lines
I kept the SoB and authorship since you're the original author, but I also significantly reworked the code, so I'd be more confident if you could have a close look at this code.
I think you should definitely grab authorship on this one. You did the work to make it actually work.
I will. Thanks.
Quoted 44 lines
Quoted 6 lines
Also, I intentionally did not add a Fixes and Cc-stable to this commit because it depends on a rework we've done in
vc4_plane_setup_clipping_and_scaling()which cannot be easily backported.
What I could do though is add a patch that rejects all negative crtc_{x,y}.Agreed. Given that we're trying to fix a bug that nobody else has reported to me yet, I think we can skip dealing with this for stable.
Quoted 20 lines
--- drivers/gpu/drm/vc4/vc4_plane.c | 51 +++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-)drivers/gpu/drm/vc4/vc4_plane.c +1
-4@@ -539,22 +539,59 @@ static int vc4_plane_mode_set(struct drm_plane *plane, (i ? h_subsample :1 ) * fb->format->cpp[i]; } +break ;case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED : { -/* For T-tiled, the FB pitch is "how many bytes from -* one row to the next, such that pitch * tile_h == -* tile_size * tiles_per_row." -*/ drivers/gpu/drm/vc4/vc4_plane.c static int vc4_plane_mode_set(struct drm_plane *plane, · line 555
Quoted 10 lines
drivers/gpu/drm/vc4/vc4_plane.c +8
-0u32 tile_size_shift =12 ;/* T tiles are 4kb */ +/* Whole-tile offsets, mostly for setting the pitch. */ +u32 tile_w_shift = fb->format->cpp[0 ] ==2 ?6 :5 ;u32 tile_h_shift =5 ;/* 16 and 32bpp are 32 pixels high */ +u32 tile_w_mask = (1 << tile_w_shift) -1 ; +/* The height mask on 32-bit-per-pixel tiles is 63, i.e. 2 +* times the height (in pixels) of a 4k tile. I just assumed +* this is also true for other RGB formats, but maybe it's not. +*/ +u32 tile_h_mask = (2 << tile_h_shift) -1 ;Only 2 and 4-byte formats are supported for T format, and tiles are 32 pixels high for both of those.
Quoted 5 lines
Other than that,
Reviewed-by Eric Anholt <[email protected]>I have a comment on patch 3 I'd like to sort out,
I'll address that one in v2.
Quoted 2 lines
but other than that
I'm pleased with this whole series. Thanks for persevering on it!
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 5/5] drm/vc4: Fix negative X/Y positioning of planes using T_TILES modifier
In reply to Eric AnholtQuoted 9 lines · On Fri, 27 Jul 2018 13:46:31 -0700 Eric Anholt <[email protected]> wrote:
Quoted 5 lines · Boris Brezillon
From: Eric Anholt <[email protected]>
X/Y positioning of T-format buffers is quite tricky and the current implementation was failing to position a plane using this format correctly when the X, Y or both X and Y offsets were negative.
Wait, were things working for you with even postivie X/Y offsets on T?
I think I was talking about crtc_x/y, while you were probably talking about src_x/y. If you have src_x/y = 0 and crtc_x/y >= 0 it works fine, if you have src_x/y = 0 and crtc_x/y < 0 it doesn't work, and if you have src_x/y != 0 it doesn't work either.
Quoted 2 lines
Because it wasn't for me, and I think the
tile_h_maskchange is important for making positive work.
Yes, for positive src_x/y it does matter. I'll clarify that in my commit message.
Quoted 48 lines
Quoted 9 lines
Signed-off-by Eric Anholt <[email protected]>Signed-off-by Boris Brezillon <[email protected]>---
Hi Eric,I kept the SoB and authorship since you're the original author, but I also significantly reworked the code, so I'd be more confident if you could have a close look at this code.
I think you should definitely grab authorship on this one. You did the work to make it actually work.
Quoted 6 lines
Also, I intentionally did not add a Fixes and Cc-stable to this commit because it depends on a rework we've done in
vc4_plane_setup_clipping_and_scaling()which cannot be easily backported.
What I could do though is add a patch that rejects all negative crtc_{x,y}.Agreed. Given that we're trying to fix a bug that nobody else has reported to me yet, I think we can skip dealing with this for stable.
Quoted 25 lines
--- drivers/gpu/drm/vc4/vc4_plane.c | 51 +++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-)drivers/gpu/drm/vc4/vc4_plane.c +4
-4@@ -539,22 +539,59 @@ static int vc4_plane_mode_set(struct drm_plane *plane, (i ? h_subsample :1 ) * fb->format->cpp[i]; } +break ;case DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED : { -/* For T-tiled, the FB pitch is "how many bytes from -* one row to the next, such that pitch * tile_h == -* tile_size * tiles_per_row." -*/ u32 tile_size_shift =12 ;/* T tiles are 4kb */ +/* Whole-tile offsets, mostly for setting the pitch. */ +u32 tile_w_shift = fb->format->cpp[0 ] ==2 ?6 :5 ;u32 tile_h_shift =5 ;/* 16 and 32bpp are 32 pixels high */ +u32 tile_w_mask = (1 << tile_w_shift) -1 ;
Quoted 8 lines
drivers/gpu/drm/vc4/vc4_plane.c static int vc4_plane_mode_set(struct drm_plane *plane, · line 555
Quoted 5 lines
drivers/gpu/drm/vc4/vc4_plane.c +5
-0+/* The height mask on 32-bit-per-pixel tiles is 63, i.e. 2 +* times the height (in pixels) of a 4k tile. I just assumed +* this is also true for other RGB formats, but maybe it's not. +*/ +u32 tile_h_mask = (2 << tile_h_shift) -1 ;Only 2 and 4-byte formats are supported for T format, and tiles are 32 pixels high for both of those.
Okay, I'll drop the second sentence then.
Quoted 7 lines
Other than that,
Reviewed-by Eric Anholt <[email protected]>I have a comment on patch 3 I'd like to sort out, but other than that I'm pleased with this whole series. Thanks for persevering on it!
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel