On Mon Mar 23 16:33:31 2026 +0800, Guoniu Zhou wrote:
> The ISI hardware rounds the actual output size up to an integer, as
> described in i.MX93 Reference Manual section 57.7.8 (Channel 0 Scale
> Factor). The scale factor must be calculated to ensure the theoretical
> output value rounds up to exactly the desired size.
> 
> Fixes: cf21f328fcaf ("media: nxp: Add i.MX8 ISI driver")
> Cc: [email protected]
> Signed-off-by: Guoniu Zhou <[email protected]>
> Reviewed-by: Laurent Pinchart <[email protected]>
> Link: https://patch.msgid.link/[email protected]
> Signed-off-by: Laurent Pinchart <[email protected]>
> Signed-off-by: Hans Verkuil <[email protected]>

Patch committed.

Thanks,
Hans Verkuil

 drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

---

diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c 
b/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c
index 0187d4ab97e8..16b20ea2d1db 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c
@@ -112,7 +112,14 @@ static u32 mxc_isi_channel_scaling_ratio(unsigned int 
from, unsigned int to,
        else
                *dec = 8;
 
-       return min_t(u32, from * 0x1000 / (to * *dec), ISI_DOWNSCALE_THRESHOLD);
+       /*
+        * The ISI rounds output dimensions up to the next integer (i.MX93 RM
+        * section 57.7.8). Calculate the scale factor such that the theoretical
+        * output (input / scale_factor) rounds up to exactly the desired
+        * output.
+        */
+       return min_t(u32, DIV_ROUND_UP(from * 0x1000, to * *dec),
+                    ISI_DOWNSCALE_THRESHOLD);
 }
 
 static void mxc_isi_channel_set_scaling(struct mxc_isi_pipe *pipe,
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to