Commit d6b68511 authored by Sowjanya Komatineni's avatar Sowjanya Komatineni Committed by Mauro Carvalho Chehab

media: tegra-video: Fix channel format alignment

Pixel format width is mistakenly aligned to surface align bytes
and altering width to aligned value may force sensor mode change
other than the requested one and also cause mismatch in width
programmed between sensor and vi which can lead to capture errors.

This patch removes width alignment and clamps width as per Tegra
minimum and maximum limits.
Signed-off-by: default avatarSowjanya Komatineni <skomatineni@nvidia.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 2dc73489
...@@ -359,25 +359,15 @@ static void tegra_channel_fmt_align(struct tegra_vi_channel *chan, ...@@ -359,25 +359,15 @@ static void tegra_channel_fmt_align(struct tegra_vi_channel *chan,
struct v4l2_pix_format *pix, struct v4l2_pix_format *pix,
unsigned int bpp) unsigned int bpp)
{ {
unsigned int align;
unsigned int min_width;
unsigned int max_width;
unsigned int width;
unsigned int min_bpl; unsigned int min_bpl;
unsigned int max_bpl; unsigned int max_bpl;
unsigned int bpl; unsigned int bpl;
/* /*
* The transfer alignment requirements are expressed in bytes. Compute * The transfer alignment requirements are expressed in bytes.
* minimum and maximum values, clamp the requested width and convert * Clamp the requested width and height to the limits.
* it back to pixels. Use bytesperline to adjust the width.
*/ */
align = lcm(SURFACE_ALIGN_BYTES, bpp); pix->width = clamp(pix->width, TEGRA_MIN_WIDTH, TEGRA_MAX_WIDTH);
min_width = roundup(TEGRA_MIN_WIDTH, align);
max_width = rounddown(TEGRA_MAX_WIDTH, align);
width = roundup(pix->width * bpp, align);
pix->width = clamp(width, min_width, max_width) / bpp;
pix->height = clamp(pix->height, TEGRA_MIN_HEIGHT, TEGRA_MAX_HEIGHT); pix->height = clamp(pix->height, TEGRA_MIN_HEIGHT, TEGRA_MAX_HEIGHT);
/* Clamp the requested bytes per line value. If the maximum bytes per /* Clamp the requested bytes per line value. If the maximum bytes per
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment