0e3442713cbbd5ce60315d5cc2f770cbd3a4022f
[openwrt/staging/pepe2k.git] /
1 From 4660f99fbaa2836cd5f041c42c49c7d883cf5497 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Fri, 30 Nov 2018 16:00:54 +0000
4 Subject: [PATCH 446/454] staging: bcm2835-camera: Fix stride on RGB3/BGR3
5 formats
6
7 RGB3/BGR3 end up being 3 bytes per pixel, which meant that
8 the alignment code ended up trying to align using bitmasking
9 with a mask of 96.
10 That doesn't work, so switch to an arithmetic alignment for
11 those formats.
12
13 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
14 ---
15 .../bcm2835-camera/bcm2835-camera.c | 26 ++++++++++++++-----
16 1 file changed, 20 insertions(+), 6 deletions(-)
17
18 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
19 +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
20 @@ -1020,13 +1020,27 @@ static int vidioc_try_fmt_vid_cap(struct
21 1, 0);
22 f->fmt.pix.bytesperline = f->fmt.pix.width * mfmt->ybbp;
23 if (!mfmt->remove_padding) {
24 - int align_mask = ((32 * mfmt->depth) >> 3) - 1;
25 - /* GPU isn't removing padding, so stride is aligned to 32 */
26 - f->fmt.pix.bytesperline =
27 - (f->fmt.pix.bytesperline + align_mask) & ~align_mask;
28 + if (mfmt->depth == 24) {
29 + /*
30 + * 24bpp is a pain as we can't use simple masking.
31 + * Min stride is width aligned to 16, times 24bpp.
32 + */
33 + f->fmt.pix.bytesperline =
34 + ((f->fmt.pix.width + 15) & ~15) * 3;
35 + } else {
36 + /*
37 + * GPU isn't removing padding, so stride is aligned to
38 + * 32
39 + */
40 + int align_mask = ((32 * mfmt->depth) >> 3) - 1;
41 +
42 + f->fmt.pix.bytesperline =
43 + (f->fmt.pix.bytesperline + align_mask) &
44 + ~align_mask;
45 + }
46 v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
47 - "Not removing padding, so bytes/line = %d, (align_mask %d)\n",
48 - f->fmt.pix.bytesperline, align_mask);
49 + "Not removing padding, so bytes/line = %d\n",
50 + f->fmt.pix.bytesperline);
51 }
52
53 /* Image buffer has to be padded to allow for alignment, even though