Skip to content

Commit 885ee4d

Browse files
Guoniu Zhougregkh
authored andcommitted
media: nxp: imx8-isi: Fix scale factor calculation for hardware rounding
commit 5eb54da upstream. 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: cf21f32 ("media: nxp: Add i.MX8 ISI driver") Cc: stable@vger.kernel.org Signed-off-by: Guoniu Zhou <guoniu.zhou@nxp.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Link: https://patch.msgid.link/20260323-isi-v3-2-8df53b24e622@oss.nxp.com Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ba7e1b0 commit 885ee4d

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

drivers/media/platform/nxp/imx8-isi/imx8-isi-hw.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,14 @@ static u32 mxc_isi_channel_scaling_ratio(unsigned int from, unsigned int to,
112112
else
113113
*dec = 8;
114114

115-
return min_t(u32, from * 0x1000 / (to * *dec), ISI_DOWNSCALE_THRESHOLD);
115+
/*
116+
* The ISI rounds output dimensions up to the next integer (i.MX93 RM
117+
* section 57.7.8). Calculate the scale factor such that the theoretical
118+
* output (input / scale_factor) rounds up to exactly the desired
119+
* output.
120+
*/
121+
return min_t(u32, DIV_ROUND_UP(from * 0x1000, to * *dec),
122+
ISI_DOWNSCALE_THRESHOLD);
116123
}
117124

118125
static void mxc_isi_channel_set_scaling(struct mxc_isi_pipe *pipe,

0 commit comments

Comments
 (0)