kernel: bump 5.4 to 5.4.143
[openwrt/staging/wigyori.git] / target / linux / bcm27xx / patches-5.4 / 950-0758-media-bcm2835-isp-fix-bytes-per-line-calculations-fo.patch
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
5 for some image formats
6
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.
12
13 Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
14 ---
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(-)
18
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)
24 {
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;
29 + else
30 + return ALIGN((width * fmt->depth) >> 3, fmt->bytesperline_align);
31 }
32
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
37 }, {
38 .fourcc = V4L2_PIX_FMT_YUYV,
39 .depth = 16,
40 - .bytesperline_align = 32,
41 + .bytesperline_align = 64,
42 .flags = 0,
43 .mmal_fmt = MMAL_ENCODING_YUYV,
44 .size_multiplier_x2 = 2,
45 @@ -80,7 +80,7 @@ static const struct bcm2835_isp_fmt supp
46 }, {
47 .fourcc = V4L2_PIX_FMT_UYVY,
48 .depth = 16,
49 - .bytesperline_align = 32,
50 + .bytesperline_align = 64,
51 .flags = 0,
52 .mmal_fmt = MMAL_ENCODING_UYVY,
53 .size_multiplier_x2 = 2,
54 @@ -89,7 +89,7 @@ static const struct bcm2835_isp_fmt supp
55 }, {
56 .fourcc = V4L2_PIX_FMT_YVYU,
57 .depth = 16,
58 - .bytesperline_align = 32,
59 + .bytesperline_align = 64,
60 .flags = 0,
61 .mmal_fmt = MMAL_ENCODING_YVYU,
62 .size_multiplier_x2 = 2,
63 @@ -98,7 +98,7 @@ static const struct bcm2835_isp_fmt supp
64 }, {
65 .fourcc = V4L2_PIX_FMT_VYUY,
66 .depth = 16,
67 - .bytesperline_align = 32,
68 + .bytesperline_align = 64,
69 .flags = 0,
70 .mmal_fmt = MMAL_ENCODING_VYUY,
71 .size_multiplier_x2 = 2,
72 @@ -135,7 +135,7 @@ static const struct bcm2835_isp_fmt supp
73 }, {
74 .fourcc = V4L2_PIX_FMT_ABGR32,
75 .depth = 32,
76 - .bytesperline_align = 32,
77 + .bytesperline_align = 64,
78 .flags = 0,
79 .mmal_fmt = MMAL_ENCODING_BGRA,
80 .size_multiplier_x2 = 2,