media: imx: imx7-media-csi: Get rid of superfluous call to imx7_csi_mbus_fm t_to_pix_fmt

Fabio Estevam festevam at gmail.com
Thu Jul 20 12:09:10 PDT 2023


On Thu, Jul 20, 2023 at 3:47 PM Fabio Estevam <festevam at gmail.com> wrote:

> Does it work if we do like this?
>
> --- a/drivers/media/platform/nxp/imx7-media-csi.c
> +++ b/drivers/media/platform/nxp/imx7-media-csi.c
> @@ -1108,6 +1108,17 @@ static int imx7_csi_video_g_fmt_vid_cap(struct
> file *file, void *fh,
>         return 0;
>  }
>
> +/* borrowed from drivers/media/v4l2-core/v4l2-common.c */
> +static unsigned int clamp_roundup(unsigned int x, unsigned int min,
> +                                 unsigned int max, unsigned int alignment)
> +{
> +       x = clamp(x, min, max);
> +       if (alignment)
> +               x = round_up(x, alignment);
> +
> +       return x;
> +}
> +
>  static const struct imx7_csi_pixfmt *
>  __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt,
>                          struct v4l2_rect *compose)
> @@ -1137,8 +1148,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);
> +       pixfmt->width = clamp_roundup(pixfmt->width, 1, 0xffff, walign);
> +       pixfmt->height = clamp_roundup(pixfmt->height, 1, 0xffff, walign);

Actually the height should be:

pixfmt->height = clamp_roundup(pixfmt->height, 1, 0xffff, 1);



More information about the linux-arm-kernel mailing list