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
7 commit dd9bb50522733befceac9cbe0b68f5ad4e5106ff upstream.
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.
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.
20 v2: Changes by anholt from the downstream driver: Flag two more planar
21 formats as needing padding removal, and remove broken userspace
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>
28 .../bcm2835-camera/bcm2835-camera.c | 44 ++++++++++++++-----
29 .../bcm2835-camera/mmal-common.h | 3 ++
30 2 files changed, 35 insertions(+), 12 deletions(-)
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[] = {
36 .mmal_component = MMAL_COMPONENT_CAMERA,
38 + .remove_padding = 1,
41 .name = "4:2:2, packed, YUYV",
42 @@ -97,6 +98,7 @@ static struct mmal_fmt formats[] = {
44 .mmal_component = MMAL_COMPONENT_CAMERA,
46 + .remove_padding = 0,
50 @@ -106,6 +108,7 @@ static struct mmal_fmt formats[] = {
52 .mmal_component = MMAL_COMPONENT_CAMERA,
54 + .remove_padding = 0,
58 @@ -115,6 +118,7 @@ static struct mmal_fmt formats[] = {
60 .mmal_component = MMAL_COMPONENT_IMAGE_ENCODE,
62 + .remove_padding = 0,
66 @@ -124,6 +128,7 @@ static struct mmal_fmt formats[] = {
68 .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE,
70 + .remove_padding = 0,
74 @@ -133,6 +138,7 @@ static struct mmal_fmt formats[] = {
76 .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE,
78 + .remove_padding = 0,
81 .name = "4:2:2, packed, YVYU",
82 @@ -142,6 +148,7 @@ static struct mmal_fmt formats[] = {
84 .mmal_component = MMAL_COMPONENT_CAMERA,
86 + .remove_padding = 0,
89 .name = "4:2:2, packed, VYUY",
90 @@ -151,6 +158,7 @@ static struct mmal_fmt formats[] = {
92 .mmal_component = MMAL_COMPONENT_CAMERA,
94 + .remove_padding = 0,
97 .name = "4:2:2, packed, UYVY",
98 @@ -160,6 +168,7 @@ static struct mmal_fmt formats[] = {
100 .mmal_component = MMAL_COMPONENT_CAMERA,
102 + .remove_padding = 0,
105 .name = "4:2:0, planar, NV12",
106 @@ -169,6 +178,7 @@ static struct mmal_fmt formats[] = {
108 .mmal_component = MMAL_COMPONENT_CAMERA,
110 + .remove_padding = 1,
113 .name = "RGB24 (BE)",
114 @@ -178,6 +188,7 @@ static struct mmal_fmt formats[] = {
116 .mmal_component = MMAL_COMPONENT_CAMERA,
118 + .remove_padding = 0,
121 .name = "4:2:0, planar, YVU",
122 @@ -187,6 +198,7 @@ static struct mmal_fmt formats[] = {
124 .mmal_component = MMAL_COMPONENT_CAMERA,
126 + .remove_padding = 1,
129 .name = "4:2:0, planar, NV21",
130 @@ -196,6 +208,7 @@ static struct mmal_fmt formats[] = {
132 .mmal_component = MMAL_COMPONENT_CAMERA,
134 + .remove_padding = 1,
137 .name = "RGB32 (BE)",
138 @@ -205,6 +218,7 @@ static struct mmal_fmt formats[] = {
140 .mmal_component = MMAL_COMPONENT_CAMERA,
142 + .remove_padding = 0,
146 @@ -962,9 +976,19 @@ static int vidioc_try_fmt_vid_cap(struct
147 &f->fmt.pix.height, MIN_HEIGHT, dev->max_height,
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);
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.
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;
175 @@ -1065,6 +1090,12 @@ static int mmal_setup_components(struct
176 camera_port->format.encoding = MMAL_ENCODING_RGB24;
179 + remove_padding = mfmt->remove_padding;
180 + vchiq_mmal_port_parameter_set(dev->instance,
182 + MMAL_PARAMETER_NO_IMAGE_PADDING,
183 + &remove_padding, sizeof(remove_padding));
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
191 struct mmal_es_format_local *format;
193 u32 supported_encodings[MAX_SUPPORTED_ENCODINGS];
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;
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));
205 format = &camera->output[MMAL_CAMERA_PORT_CAPTURE].format;
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;
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));
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 {
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.
231 /* buffer for one video frame */