[Intel-gfx] [PATCH v2] drm/i915/display: assume some pixelrate for src smaller than 1
Imre Deak
imre.deak at intel.com
Wed Jan 11 00:31:56 UTC 2023
On Tue, Jan 10, 2023 at 11:27:33PM +0200, Imre Deak wrote:
> On Sun, Jan 08, 2023 at 01:30:44PM +0200, Juha-Pekka Heikkila wrote:
> > intel_adjusted_rate() didn't take into account src rectangle
> > can be less than 1 in with or height.
>
> Thanks for catching this.
>
> > Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> > ---
> > drivers/gpu/drm/i915/display/intel_atomic_plane.c | 8 +++++---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > index 10e1fc9d0698..cd24d069b6eb 100644
> > --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > @@ -144,7 +144,7 @@ unsigned int intel_adjusted_rate(const struct drm_rect *src,
> > const struct drm_rect *dst,
> > unsigned int rate)
> > {
> > - unsigned int src_w, src_h, dst_w, dst_h;
> > + unsigned int src_w, src_h, dst_w, dst_h, dst_wh;
> >
> > src_w = drm_rect_width(src) >> 16;
> > src_h = drm_rect_height(src) >> 16;
> > @@ -155,8 +155,10 @@ unsigned int intel_adjusted_rate(const struct drm_rect *src,
> > dst_w = min(src_w, dst_w);
> > dst_h = min(src_h, dst_h);
> >
> > - return DIV_ROUND_UP_ULL(mul_u32_u32(rate, src_w * src_h),
> > - dst_w * dst_h);
> > + /* in case src contained only fractional part */
> > + dst_wh = max(dst_w * dst_h, 1U);
> > +
> > + return DIV_ROUND_UP_ULL(mul_u32_u32(rate, src_w * src_h), dst_wh);
>
> The div-by-zero is avoided, but we'd return a 0 rate which doesn't look
> ok to me. I'd round up instead of down when converting src_w/h from
> fixed point to int above.
Looking at this more, src height < 1 isn't supported by the HW. I think
this config should be rejected already by skl_check_main_surface(), as
it's done on all other platforms.
> > }
> >
> > unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state,
> > --
> > 2.39.0
> >
More information about the Intel-gfx
mailing list