1 From 5b07adb57e04530dc571c2a4a1aeea4b7bc57723 Mon Sep 17 00:00:00 2001
2 From: David Plowman <david.plowman@raspberrypi.com>
3 Date: Fri, 29 May 2020 14:36:56 +0100
4 Subject: [PATCH] media: bcm2835-isp: fix bytes per line calculations
7 The bytes per line numbers calculated by get_bytesperline was not
8 matching the equivalent calculation being performed by the VideoCore
9 (mostly by the calculate_pitch function there), resulting in failures
10 to set the image format with some image width values. This patches up
11 the RGB24 and YUYV type formats to match the VideoCore calculation.
13 Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
15 .../vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c | 6 +++++-
16 .../vc04_services/bcm2835-isp/bcm2835_isp_fmts.h | 10 +++++-----
17 2 files changed, 10 insertions(+), 6 deletions(-)
19 --- a/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
20 +++ b/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
21 @@ -676,7 +676,11 @@ struct bcm2835_isp_fmt *get_default_form
22 static inline unsigned int get_bytesperline(int width,
23 const struct bcm2835_isp_fmt *fmt)
25 - return ALIGN((width * fmt->depth) >> 3, fmt->bytesperline_align);
26 + /* GPU aligns 24bpp images to a multiple of 32 pixels (not bytes). */
27 + if (fmt->depth == 24)
28 + return ALIGN(width, 32) * 3;
30 + return ALIGN((width * fmt->depth) >> 3, fmt->bytesperline_align);
33 static inline unsigned int get_sizeimage(int bpl, int width, int height,
34 --- a/drivers/staging/vc04_services/bcm2835-isp/bcm2835_isp_fmts.h
35 +++ b/drivers/staging/vc04_services/bcm2835-isp/bcm2835_isp_fmts.h
36 @@ -71,7 +71,7 @@ static const struct bcm2835_isp_fmt supp
38 .fourcc = V4L2_PIX_FMT_YUYV,
40 - .bytesperline_align = 32,
41 + .bytesperline_align = 64,
43 .mmal_fmt = MMAL_ENCODING_YUYV,
44 .size_multiplier_x2 = 2,
45 @@ -80,7 +80,7 @@ static const struct bcm2835_isp_fmt supp
47 .fourcc = V4L2_PIX_FMT_UYVY,
49 - .bytesperline_align = 32,
50 + .bytesperline_align = 64,
52 .mmal_fmt = MMAL_ENCODING_UYVY,
53 .size_multiplier_x2 = 2,
54 @@ -89,7 +89,7 @@ static const struct bcm2835_isp_fmt supp
56 .fourcc = V4L2_PIX_FMT_YVYU,
58 - .bytesperline_align = 32,
59 + .bytesperline_align = 64,
61 .mmal_fmt = MMAL_ENCODING_YVYU,
62 .size_multiplier_x2 = 2,
63 @@ -98,7 +98,7 @@ static const struct bcm2835_isp_fmt supp
65 .fourcc = V4L2_PIX_FMT_VYUY,
67 - .bytesperline_align = 32,
68 + .bytesperline_align = 64,
70 .mmal_fmt = MMAL_ENCODING_VYUY,
71 .size_multiplier_x2 = 2,
72 @@ -135,7 +135,7 @@ static const struct bcm2835_isp_fmt supp
74 .fourcc = V4L2_PIX_FMT_ABGR32,
76 - .bytesperline_align = 32,
77 + .bytesperline_align = 64,
79 .mmal_fmt = MMAL_ENCODING_BGRA,
80 .size_multiplier_x2 = 2,