diff mbox series

[2/2] media: imx: imx7-media-csi: Fix applying format constraints

Message ID 20230720074129.3680269-2-alexander.stein@ew.tq-group.com (mailing list archive)
State New, archived
Headers show
Series [1/2] media: imx: imx7-media-csi: Move stepwise framesize into a dedicated struct | expand

Commit Message

Alexander Stein July 20, 2023, 7:41 a.m. UTC
v4l_bound_align_image aligns to a multiple power of 2 of walign, but the
result only needs to be a multiple of walign. Fix this by using
v4l2_apply_frmsize_constraints() instead.

Reported-by: Tim Harvey <tharvey@gateworks.com>
Fixes: 6f482c4729d9 ("media: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fmt_to_pix_fmt")
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
Tim,
can you please test if this fixes your problem?
Apparently this issue only arises under specific conditions, e.g. 640/480/8bpp.
This issue does not show up for 640/480/10bpp.

 drivers/media/platform/nxp/imx7-media-csi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alexander Stein July 20, 2023, 10:19 a.m. UTC | #1
Am Donnerstag, 20. Juli 2023, 09:41:29 CEST schrieb Alexander Stein:
> v4l_bound_align_image aligns to a multiple power of 2 of walign, but the
> result only needs to be a multiple of walign. Fix this by using
> v4l2_apply_frmsize_constraints() instead.
> 
> Reported-by: Tim Harvey <tharvey@gateworks.com>
> Fixes: 6f482c4729d9 ("media: imx: imx7-media-csi: Get rid of superfluous
> call to imx7_csi_mbus_fmt_to_pix_fmt") Signed-off-by: Alexander Stein
> <alexander.stein@ew.tq-group.com>
> ---
> Tim,
> can you please test if this fixes your problem?
> Apparently this issue only arises under specific conditions, e.g.
> 640/480/8bpp. This issue does not show up for 640/480/10bpp.
> 
>  drivers/media/platform/nxp/imx7-media-csi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/nxp/imx7-media-csi.c
> b/drivers/media/platform/nxp/imx7-media-csi.c index
> 73f8f2a35422..523e5f039a5a 100644
> --- a/drivers/media/platform/nxp/imx7-media-csi.c
> +++ b/drivers/media/platform/nxp/imx7-media-csi.c
> @@ -1141,8 +1141,8 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format
> *pixfmt, * TODO: Implement configurable stride support.
>  	 */
>  	walign = 8 * 8 / cc->bpp;
> -	v4l_bound_align_image(&pixfmt->width, 1, 0xffff, walign,
> -			      &pixfmt->height, 1, 0xffff, 1, 0);
> +	v4l2_apply_frmsize_constraints(&pixfmt->width, &pixfmt->height,
> +				       &imx7_csi_frmsize_stepwise);

Meh, this essentially removes the walign constraint. I need some more coffee 
and this some more work.

Sorry for the noise
Alexander

> 
>  	pixfmt->bytesperline = pixfmt->width * cc->bpp / 8;
>  	pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
kernel test robot July 20, 2023, 4:43 p.m. UTC | #2
Hi Alexander,

kernel test robot noticed the following build warnings:

[auto build test WARNING on media-tree/master]
[also build test WARNING on linus/master v6.5-rc2 next-20230720]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Alexander-Stein/media-imx-imx7-media-csi-Fix-applying-format-constraints/20230720-154426
base:   git://linuxtv.org/media_tree.git master
patch link:    https://lore.kernel.org/r/20230720074129.3680269-2-alexander.stein%40ew.tq-group.com
patch subject: [PATCH 2/2] media: imx: imx7-media-csi: Fix applying format constraints
config: arm-allmodconfig (https://download.01.org/0day-ci/archive/20230721/202307210050.s7hfCvwG-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230721/202307210050.s7hfCvwG-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307210050.s7hfCvwG-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/media/platform/nxp/imx7-media-csi.c: In function '__imx7_csi_video_try_fmt':
>> drivers/media/platform/nxp/imx7-media-csi.c:1120:13: warning: variable 'walign' set but not used [-Wunused-but-set-variable]
    1120 |         u32 walign;
         |             ^~~~~~

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for SM_GCC_8350
   Depends on [n]: COMMON_CLK [=y] && COMMON_CLK_QCOM [=m] && (ARM64 || COMPILE_TEST [=n])
   Selected by [m]:
   - SM_VIDEOCC_8350 [=m] && COMMON_CLK [=y] && COMMON_CLK_QCOM [=m]
   WARNING: unmet direct dependencies detected for SM_GCC_8450
   Depends on [n]: COMMON_CLK [=y] && COMMON_CLK_QCOM [=m] && (ARM64 || COMPILE_TEST [=n])
   Selected by [m]:
   - SM_GPUCC_8450 [=m] && COMMON_CLK [=y] && COMMON_CLK_QCOM [=m]
   - SM_VIDEOCC_8450 [=m] && COMMON_CLK [=y] && COMMON_CLK_QCOM [=m]
   WARNING: unmet direct dependencies detected for SM_GCC_8550
   Depends on [n]: COMMON_CLK [=y] && COMMON_CLK_QCOM [=m] && (ARM64 || COMPILE_TEST [=n])
   Selected by [m]:
   - SM_GPUCC_8550 [=m] && COMMON_CLK [=y] && COMMON_CLK_QCOM [=m]
   - SM_VIDEOCC_8550 [=m] && COMMON_CLK [=y] && COMMON_CLK_QCOM [=m]


vim +/walign +1120 drivers/media/platform/nxp/imx7-media-csi.c

01ac6b7542872e drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1114  
e352833d32e693 drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1115  static const struct imx7_csi_pixfmt *
31959b981c231f drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1116  __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
31959b981c231f drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1117  			 struct v4l2_rect *compose)
01ac6b7542872e drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1118  {
e352833d32e693 drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1119  	const struct imx7_csi_pixfmt *cc;
bef1bb620ca693 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19 @1120  	u32 walign;
01ac6b7542872e drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1121  
6f482c4729d904 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19  1122  	if (compose) {
6f482c4729d904 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19  1123  		compose->width = pixfmt->width;
6f482c4729d904 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19  1124  		compose->height = pixfmt->height;
6f482c4729d904 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19  1125  	}
6f482c4729d904 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19  1126  
01ac6b7542872e drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1127  	/*
01ac6b7542872e drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1128  	 * Find the pixel format, default to the first supported format if not
01ac6b7542872e drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1129  	 * found.
01ac6b7542872e drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1130  	 */
2d35c1ff83c095 drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-10  1131  	cc = imx7_csi_find_pixel_format(pixfmt->pixelformat);
01ac6b7542872e drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1132  	if (!cc) {
a1a60e7ac274dc drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-10  1133  		pixfmt->pixelformat = IMX7_CSI_DEF_PIX_FORMAT;
2d35c1ff83c095 drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-10  1134  		cc = imx7_csi_find_pixel_format(pixfmt->pixelformat);
01ac6b7542872e drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1135  	}
01ac6b7542872e drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1136  
6f482c4729d904 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19  1137  	/*
bef1bb620ca693 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19  1138  	 * The width alignment is 8 bytes as indicated by the
bef1bb620ca693 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19  1139  	 * CSI_IMAG_PARA.IMAGE_WIDTH documentation. Convert it to pixels.
6f482c4729d904 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19  1140  	 *
bef1bb620ca693 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19  1141  	 * TODO: Implement configurable stride support.
6f482c4729d904 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19  1142  	 */
bef1bb620ca693 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19  1143  	walign = 8 * 8 / cc->bpp;
75ab3b3196c39c drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-07-20  1144  	v4l2_apply_frmsize_constraints(&pixfmt->width, &pixfmt->height,
75ab3b3196c39c drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-07-20  1145  				       &imx7_csi_frmsize_stepwise);
01ac6b7542872e drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1146  
6f482c4729d904 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19  1147  	pixfmt->bytesperline = pixfmt->width * cc->bpp / 8;
6f482c4729d904 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19  1148  	pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
79bb4c7df8af76 drivers/media/platform/nxp/imx7-media-csi.c Alexander Stein  2023-04-19  1149  	pixfmt->field = V4L2_FIELD_NONE;
01ac6b7542872e drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1150  
01ac6b7542872e drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1151  	return cc;
01ac6b7542872e drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1152  }
01ac6b7542872e drivers/staging/media/imx/imx7-media-csi.c  Laurent Pinchart 2022-05-09  1153
diff mbox series

Patch

diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
index 73f8f2a35422..523e5f039a5a 100644
--- a/drivers/media/platform/nxp/imx7-media-csi.c
+++ b/drivers/media/platform/nxp/imx7-media-csi.c
@@ -1141,8 +1141,8 @@  __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
 	 * TODO: Implement configurable stride support.
 	 */
 	walign = 8 * 8 / cc->bpp;
-	v4l_bound_align_image(&pixfmt->width, 1, 0xffff, walign,
-			      &pixfmt->height, 1, 0xffff, 1, 0);
+	v4l2_apply_frmsize_constraints(&pixfmt->width, &pixfmt->height,
+				       &imx7_csi_frmsize_stepwise);
 
 	pixfmt->bytesperline = pixfmt->width * cc->bpp / 8;
 	pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;