kernel: bump 4.14 to 4.14.93
[openwrt/staging/chunkeey.git] / target / linux / brcm2708 / patches-4.14 / 950-0367-staging-bcm2835-camera-Skip-ISP-pass-to-eliminate-pa.patch
1 From 7efa934859d354d8c331d2c99a6126020ce0310d Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <6by9@users.noreply.github.com>
3 Date: Thu, 10 May 2018 12:42:07 -0700
4 Subject: [PATCH 367/454] staging: bcm2835-camera: Skip ISP pass to eliminate
5 padding.
6
7 commit dd9bb50522733befceac9cbe0b68f5ad4e5106ff upstream.
8
9 Interleaved RGB and single plane YUV formats can be delivered by the
10 GPU without the secondary step of removing padding, as the
11 bytesperline field can be set appropriately.
12
13 Planar YUV needs the GPU to still remove padding, as there is no way
14 to report that there is padding between the planes (ie on the height).
15 The multi-planar formats are NOT applicable, as there is no easy way
16 to make them contiguous in memory (ie one large allocation that gets
17 broken up). The whole task is passed across to videobuf2 which has no
18 notion of that requirement.
19
20 v2: Changes by anholt from the downstream driver: Flag two more planar
21 formats as needing padding removal, and remove broken userspace
22 workaround.
23
24 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
25 Signed-off-by: Eric Anholt <eric@anholt.net>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27 ---
28 .../bcm2835-camera/bcm2835-camera.c | 44 ++++++++++++++-----
29 .../bcm2835-camera/mmal-common.h | 3 ++
30 2 files changed, 35 insertions(+), 12 deletions(-)
31
32 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
33 +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
34 @@ -88,6 +88,7 @@ static struct mmal_fmt formats[] = {
35 .depth = 12,
36 .mmal_component = MMAL_COMPONENT_CAMERA,
37 .ybbp = 1,
38 + .remove_padding = 1,
39 },
40 {
41 .name = "4:2:2, packed, YUYV",
42 @@ -97,6 +98,7 @@ static struct mmal_fmt formats[] = {
43 .depth = 16,
44 .mmal_component = MMAL_COMPONENT_CAMERA,
45 .ybbp = 2,
46 + .remove_padding = 0,
47 },
48 {
49 .name = "RGB24 (LE)",
50 @@ -106,6 +108,7 @@ static struct mmal_fmt formats[] = {
51 .depth = 24,
52 .mmal_component = MMAL_COMPONENT_CAMERA,
53 .ybbp = 3,
54 + .remove_padding = 0,
55 },
56 {
57 .name = "JPEG",
58 @@ -115,6 +118,7 @@ static struct mmal_fmt formats[] = {
59 .depth = 8,
60 .mmal_component = MMAL_COMPONENT_IMAGE_ENCODE,
61 .ybbp = 0,
62 + .remove_padding = 0,
63 },
64 {
65 .name = "H264",
66 @@ -124,6 +128,7 @@ static struct mmal_fmt formats[] = {
67 .depth = 8,
68 .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE,
69 .ybbp = 0,
70 + .remove_padding = 0,
71 },
72 {
73 .name = "MJPEG",
74 @@ -133,6 +138,7 @@ static struct mmal_fmt formats[] = {
75 .depth = 8,
76 .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE,
77 .ybbp = 0,
78 + .remove_padding = 0,
79 },
80 {
81 .name = "4:2:2, packed, YVYU",
82 @@ -142,6 +148,7 @@ static struct mmal_fmt formats[] = {
83 .depth = 16,
84 .mmal_component = MMAL_COMPONENT_CAMERA,
85 .ybbp = 2,
86 + .remove_padding = 0,
87 },
88 {
89 .name = "4:2:2, packed, VYUY",
90 @@ -151,6 +158,7 @@ static struct mmal_fmt formats[] = {
91 .depth = 16,
92 .mmal_component = MMAL_COMPONENT_CAMERA,
93 .ybbp = 2,
94 + .remove_padding = 0,
95 },
96 {
97 .name = "4:2:2, packed, UYVY",
98 @@ -160,6 +168,7 @@ static struct mmal_fmt formats[] = {
99 .depth = 16,
100 .mmal_component = MMAL_COMPONENT_CAMERA,
101 .ybbp = 2,
102 + .remove_padding = 0,
103 },
104 {
105 .name = "4:2:0, planar, NV12",
106 @@ -169,6 +178,7 @@ static struct mmal_fmt formats[] = {
107 .depth = 12,
108 .mmal_component = MMAL_COMPONENT_CAMERA,
109 .ybbp = 1,
110 + .remove_padding = 1,
111 },
112 {
113 .name = "RGB24 (BE)",
114 @@ -178,6 +188,7 @@ static struct mmal_fmt formats[] = {
115 .depth = 24,
116 .mmal_component = MMAL_COMPONENT_CAMERA,
117 .ybbp = 3,
118 + .remove_padding = 0,
119 },
120 {
121 .name = "4:2:0, planar, YVU",
122 @@ -187,6 +198,7 @@ static struct mmal_fmt formats[] = {
123 .depth = 12,
124 .mmal_component = MMAL_COMPONENT_CAMERA,
125 .ybbp = 1,
126 + .remove_padding = 1,
127 },
128 {
129 .name = "4:2:0, planar, NV21",
130 @@ -196,6 +208,7 @@ static struct mmal_fmt formats[] = {
131 .depth = 12,
132 .mmal_component = MMAL_COMPONENT_CAMERA,
133 .ybbp = 1,
134 + .remove_padding = 1,
135 },
136 {
137 .name = "RGB32 (BE)",
138 @@ -205,6 +218,7 @@ static struct mmal_fmt formats[] = {
139 .depth = 32,
140 .mmal_component = MMAL_COMPONENT_CAMERA,
141 .ybbp = 4,
142 + .remove_padding = 0,
143 },
144 };
145
146 @@ -962,9 +976,19 @@ static int vidioc_try_fmt_vid_cap(struct
147 &f->fmt.pix.height, MIN_HEIGHT, dev->max_height,
148 1, 0);
149 f->fmt.pix.bytesperline = f->fmt.pix.width * mfmt->ybbp;
150 + if (!mfmt->remove_padding) {
151 + int align_mask = ((32 * mfmt->depth) >> 3) - 1;
152 + /* GPU isn't removing padding, so stride is aligned to 32 */
153 + f->fmt.pix.bytesperline =
154 + (f->fmt.pix.bytesperline + align_mask) & ~align_mask;
155 + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
156 + "Not removing padding, so bytes/line = %d, "
157 + "(align_mask %d)\n",
158 + f->fmt.pix.bytesperline, align_mask);
159 + }
160
161 /* Image buffer has to be padded to allow for alignment, even though
162 - * we then remove that padding before delivering the buffer.
163 + * we sometimes then remove that padding before delivering the buffer.
164 */
165 f->fmt.pix.sizeimage = ((f->fmt.pix.height + 15) & ~15) *
166 (((f->fmt.pix.width + 31) & ~31) * mfmt->depth) >> 3;
167 @@ -997,6 +1021,7 @@ static int mmal_setup_components(struct
168 struct vchiq_mmal_port *port = NULL, *camera_port = NULL;
169 struct vchiq_mmal_component *encode_component = NULL;
170 struct mmal_fmt *mfmt = get_format(f);
171 + u32 remove_padding;
172
173 BUG_ON(!mfmt);
174
175 @@ -1065,6 +1090,12 @@ static int mmal_setup_components(struct
176 camera_port->format.encoding = MMAL_ENCODING_RGB24;
177 }
178
179 + remove_padding = mfmt->remove_padding;
180 + vchiq_mmal_port_parameter_set(dev->instance,
181 + camera_port,
182 + MMAL_PARAMETER_NO_IMAGE_PADDING,
183 + &remove_padding, sizeof(remove_padding));
184 +
185 camera_port->format.encoding_variant = 0;
186 camera_port->es.video.width = f->fmt.pix.width;
187 camera_port->es.video.height = f->fmt.pix.height;
188 @@ -1542,7 +1573,6 @@ static int __init mmal_init(struct bm283
189 {
190 int ret;
191 struct mmal_es_format_local *format;
192 - u32 bool_true = 1;
193 u32 supported_encodings[MAX_SUPPORTED_ENCODINGS];
194 int param_size;
195 struct vchiq_mmal_component *camera;
196 @@ -1626,11 +1656,6 @@ static int __init mmal_init(struct bm283
197 format->es->video.frame_rate.num = 0; /* Rely on fps_range */
198 format->es->video.frame_rate.den = 1;
199
200 - vchiq_mmal_port_parameter_set(dev->instance,
201 - &camera->output[MMAL_CAMERA_PORT_VIDEO],
202 - MMAL_PARAMETER_NO_IMAGE_PADDING,
203 - &bool_true, sizeof(bool_true));
204 -
205 format = &camera->output[MMAL_CAMERA_PORT_CAPTURE].format;
206
207 format->encoding = MMAL_ENCODING_OPAQUE;
208 @@ -1652,11 +1677,6 @@ static int __init mmal_init(struct bm283
209 dev->capture.enc_profile = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH;
210 dev->capture.enc_level = V4L2_MPEG_VIDEO_H264_LEVEL_4_0;
211
212 - vchiq_mmal_port_parameter_set(dev->instance,
213 - &camera->output[MMAL_CAMERA_PORT_CAPTURE],
214 - MMAL_PARAMETER_NO_IMAGE_PADDING,
215 - &bool_true, sizeof(bool_true));
216 -
217 /* get the preview component ready */
218 ret = vchiq_mmal_component_init(
219 dev->instance, "ril.video_render",
220 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h
221 +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h
222 @@ -31,6 +31,9 @@ struct mmal_fmt {
223 int depth;
224 u32 mmal_component; /* MMAL component index to be used to encode */
225 u32 ybbp; /* depth of first Y plane for planar formats */
226 + bool remove_padding; /* Does the GPU have to remove padding,
227 + * or can we do hide padding via bytesperline.
228 + */
229 };
230
231 /* buffer for one video frame */