Skip to content

Commit d13fabf

Browse files
pinchartlHans Verkuil
authored andcommitted
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 <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent e09b036 commit d13fabf

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ static void rkisp1_rsz_config(struct rkisp1_resizer *rsz,
284284
src_yuv_info = rkisp1_rsz_get_yuv_mbus_info(src_fmt->code);
285285

286286
/*
287-
* The resizer only works on yuv formats,
288-
* so return if it is bayer format.
287+
* The resizer only works on yuv formats, so return if it is bayer
288+
* format.
289289
*/
290290
if (!sink_yuv_info) {
291291
rkisp1_rsz_disable(rsz, when);
@@ -299,28 +299,29 @@ static void rkisp1_rsz_config(struct rkisp1_resizer *rsz,
299299

300300
src_y.width = src_fmt->width;
301301
src_y.height = src_fmt->height;
302+
src_c.width = src_y.width / src_yuv_info->hdiv;
303+
src_c.height = src_y.height / src_yuv_info->vdiv;
302304

303305
/*
304306
* The resizer is used not only to change the dimensions of the frame
305-
* but also to change the scale for YUV formats,
306-
* (4:2:2 -> 4:2:0 for example). So the width/height of the CbCr
307-
* streams should be set according to the media bus format in the src pad.
307+
* but also to change the subsampling for YUV formats (for instance
308+
* converting from 4:2:2 to 4:2:0). Check both the luma and chroma
309+
* dimensions to decide whether or not to enable the resizer.
308310
*/
309-
src_c.width = src_y.width / src_yuv_info->hdiv;
310-
src_c.height = src_y.height / src_yuv_info->vdiv;
311311

312312
dev_dbg(rsz->rkisp1->dev,
313313
"stream %u rsz/scale: Y %ux%u -> %ux%u, CbCr %ux%u -> %ux%u\n",
314314
rsz->id, sink_y->width, sink_y->height,
315315
src_fmt->width, src_fmt->height,
316316
sink_c.width, sink_c.height, src_c.width, src_c.height);
317317

318-
if (sink_c.width == src_c.width && sink_c.height == src_c.height) {
318+
if (sink_y->width == src_y.width && sink_y->height == src_y.height &&
319+
sink_c.width == src_c.width && sink_c.height == src_c.height) {
319320
rkisp1_rsz_disable(rsz, when);
320321
return;
321322
}
322323

323-
/* set values in the hw */
324+
/* Set values in the hardware. */
324325
rkisp1_rsz_config_regs(rsz, sink_y, &sink_c, &src_y, &src_c, when);
325326
}
326327

0 commit comments

Comments
 (0)