Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: i2c: imx219: Fix 1920x1080 mode to use 1:1 pixel aspect ratio

Commit 0af46fbc333d ("media: i2c: imx219: Calculate crop rectangle
dynamically") meant that the 1920x1080 mode switched from using no
binning to using vertical binning but no horizontal binning, which
resulted in stretched pixels.

Until proper controls are available to independently select horizontal
and vertical binning, restore the original 1:1 pixel aspect ratio by
forcing binning to be uniform in both directions.

Cc: stable@vger.kernel.org
Fixes: 0af46fbc333d ("media: i2c: imx219: Calculate crop rectangle dynamically")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
[Add comment & reword commit message]
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>

authored by

Dave Stevenson and committed by
Hans Verkuil
9ef6e4db c423487b

+6 -3
+6 -3
drivers/media/i2c/imx219.c
··· 856 856 const struct imx219_mode *mode; 857 857 struct v4l2_mbus_framefmt *format; 858 858 struct v4l2_rect *crop; 859 - u8 bin_h, bin_v; 859 + u8 bin_h, bin_v, binning; 860 860 u32 prev_line_len; 861 861 862 862 format = v4l2_subdev_state_get_format(state, 0); ··· 877 877 bin_h = min(IMX219_PIXEL_ARRAY_WIDTH / format->width, 2U); 878 878 bin_v = min(IMX219_PIXEL_ARRAY_HEIGHT / format->height, 2U); 879 879 880 + /* Ensure bin_h and bin_v are same to avoid 1:2 or 2:1 stretching */ 881 + binning = min(bin_h, bin_v); 882 + 880 883 crop = v4l2_subdev_state_get_crop(state, 0); 881 - crop->width = format->width * bin_h; 882 - crop->height = format->height * bin_v; 884 + crop->width = format->width * binning; 885 + crop->height = format->height * binning; 883 886 crop->left = (IMX219_NATIVE_WIDTH - crop->width) / 2; 884 887 crop->top = (IMX219_NATIVE_HEIGHT - crop->height) / 2; 885 888