aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-5.4/950-0758-media-bcm2835-isp-fix-bytes-per-line-calculations-fo.patch
blob: 7f4943f9ab2810ae504f8affc6a70f257e3328ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
From 5b07adb57e04530dc571c2a4a1aeea4b7bc57723 Mon Sep 17 00:00:00 2001
From: David Plowman <david.plowman@raspberrypi.com>
Date: Fri, 29 May 2020 14:36:56 +0100
Subject: [PATCH] media: bcm2835-isp: fix bytes per line calculations
 for some image formats

The bytes per line numbers calculated by get_bytesperline was not
matching the equivalent calculation being performed by the VideoCore
(mostly by the calculate_pitch function there), resulting in failures
to set the image format with some image width values. This patches up
the RGB24 and YUYV type formats to match the VideoCore calculation.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
---
 .../vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c       |  6 +++++-
 .../vc04_services/bcm2835-isp/bcm2835_isp_fmts.h       | 10 +++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)

--- a/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
+++ b/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
@@ -676,7 +676,11 @@ struct bcm2835_isp_fmt *get_default_form
 static inline unsigned int get_bytesperline(int width,
 					    const struct bcm2835_isp_fmt *fmt)
 {
-	return ALIGN((width * fmt->depth) >> 3, fmt->bytesperline_align);
+	/* GPU aligns 24bpp images to a multiple of 32 pixels (not bytes). */
+	if (fmt->depth == 24)
+		return ALIGN(width, 32) * 3;
+	else
+		return ALIGN((width * fmt->depth) >> 3, fmt->bytesperline_align);
 }
 
 static inline unsigned int get_sizeimage(int bpl, int width, int height,
--- a/drivers/staging/vc04_services/bcm2835-isp/bcm2835_isp_fmts.h
+++ b/drivers/staging/vc04_services/bcm2835-isp/bcm2835_isp_fmts.h
@@ -71,7 +71,7 @@ static const struct bcm2835_isp_fmt supp
 	}, {
 		.fourcc		    = V4L2_PIX_FMT_YUYV,
 		.depth		    = 16,
-		.bytesperline_align = 32,
+		.bytesperline_align = 64,
 		.flags		    = 0,
 		.mmal_fmt	    = MMAL_ENCODING_YUYV,
 		.size_multiplier_x2 = 2,
@@ -80,7 +80,7 @@ static const struct bcm2835_isp_fmt supp
 	}, {
 		.fourcc		    = V4L2_PIX_FMT_UYVY,
 		.depth		    = 16,
-		.bytesperline_align = 32,
+		.bytesperline_align = 64,
 		.flags		    = 0,
 		.mmal_fmt	    = MMAL_ENCODING_UYVY,
 		.size_multiplier_x2 = 2,
@@ -89,7 +89,7 @@ static const struct bcm2835_isp_fmt supp
 	}, {
 		.fourcc		    = V4L2_PIX_FMT_YVYU,
 		.depth		    = 16,
-		.bytesperline_align = 32,
+		.bytesperline_align = 64,
 		.flags		    = 0,
 		.mmal_fmt	    = MMAL_ENCODING_YVYU,
 		.size_multiplier_x2 = 2,
@@ -98,7 +98,7 @@ static const struct bcm2835_isp_fmt supp
 	}, {
 		.fourcc		    = V4L2_PIX_FMT_VYUY,
 		.depth		    = 16,
-		.bytesperline_align = 32,
+		.bytesperline_align = 64,
 		.flags		    = 0,
 		.mmal_fmt	    = MMAL_ENCODING_VYUY,
 		.size_multiplier_x2 = 2,
@@ -135,7 +135,7 @@ static const struct bcm2835_isp_fmt supp
 	}, {
 		.fourcc		    = V4L2_PIX_FMT_ABGR32,
 		.depth		    = 32,
-		.bytesperline_align = 32,
+		.bytesperline_align = 64,
 		.flags		    = 0,
 		.mmal_fmt	    = MMAL_ENCODING_BGRA,
 		.size_multiplier_x2 = 2,