diff options
author | Laurent Pinchart | 2023-09-23 22:49:06 +0300 |
---|---|---|
committer | Hans Verkuil | 2023-10-12 09:46:38 +0200 |
commit | d13fabf08d7cf4439d8f2f477458c7c353aebe87 (patch) | |
tree | c6af4e0e532231029692fb918501b8e3f0218a85 /drivers | |
parent | e09b03627643e1f40bfaacf29be0de7df1c8c05d (diff) |
media: rkisp1: resizer: Fix resizer disable check when starting stream
The resizer is used to scale the image, but also to change the
subsampling of YUV formats. Both the luma and chroma dimensions need to
be taken into account to decide whether or not to enable the resizer.
The current implementation disables the resizer if the chroma vertical
size isn't changed, which would be the case when scaling up by a factor
of 2 vertically while at the same time converting from YUV 4:2:2 to
4:2:0. Fix it by checking the luma sizes too.
While at it, reflow and clarify comments in the function.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c index 92ae2d2e0f12..28ecc7347d54 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c @@ -284,8 +284,8 @@ static void rkisp1_rsz_config(struct rkisp1_resizer *rsz, src_yuv_info = rkisp1_rsz_get_yuv_mbus_info(src_fmt->code); /* - * The resizer only works on yuv formats, - * so return if it is bayer format. + * The resizer only works on yuv formats, so return if it is bayer + * format. */ if (!sink_yuv_info) { rkisp1_rsz_disable(rsz, when); @@ -299,15 +299,15 @@ static void rkisp1_rsz_config(struct rkisp1_resizer *rsz, src_y.width = src_fmt->width; src_y.height = src_fmt->height; + src_c.width = src_y.width / src_yuv_info->hdiv; + src_c.height = src_y.height / src_yuv_info->vdiv; /* * The resizer is used not only to change the dimensions of the frame - * but also to change the scale for YUV formats, - * (4:2:2 -> 4:2:0 for example). So the width/height of the CbCr - * streams should be set according to the media bus format in the src pad. + * but also to change the subsampling for YUV formats (for instance + * converting from 4:2:2 to 4:2:0). Check both the luma and chroma + * dimensions to decide whether or not to enable the resizer. */ - src_c.width = src_y.width / src_yuv_info->hdiv; - src_c.height = src_y.height / src_yuv_info->vdiv; dev_dbg(rsz->rkisp1->dev, "stream %u rsz/scale: Y %ux%u -> %ux%u, CbCr %ux%u -> %ux%u\n", @@ -315,12 +315,13 @@ static void rkisp1_rsz_config(struct rkisp1_resizer *rsz, src_fmt->width, src_fmt->height, sink_c.width, sink_c.height, src_c.width, src_c.height); - if (sink_c.width == src_c.width && sink_c.height == src_c.height) { + if (sink_y->width == src_y.width && sink_y->height == src_y.height && + sink_c.width == src_c.width && sink_c.height == src_c.height) { rkisp1_rsz_disable(rsz, when); return; } - /* set values in the hw */ + /* Set values in the hardware. */ rkisp1_rsz_config_regs(rsz, sink_y, &sink_c, &src_y, &src_c, when); } |