brcm2708: remove linux 3.18 support
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.1 / 0151-bcm2835-camera-planar-packed-stride-length.patch
1 From 273b9fb93e4b2cfff7aeff8ea559219c2755ee95 Mon Sep 17 00:00:00 2001
2 From: Garrett <g@floft.net>
3 Date: Thu, 2 Jul 2015 19:32:04 -0500
4 Subject: [PATCH 151/171] bcm2835 camera planar/packed stride length
5
6 Added a field to the mmal_fmt struct used to compute the bytes per line
7 when using a particular format. This results in the correct stride being
8 calculated even when the format is planar.
9
10 Signed-off-by: Garrett Wilson <g@floft.net>
11 ---
12 drivers/media/platform/bcm2835/bcm2835-camera.c | 26 +++++++++++++++++++------
13 drivers/media/platform/bcm2835/mmal-common.h | 1 +
14 2 files changed, 21 insertions(+), 6 deletions(-)
15
16 --- a/drivers/media/platform/bcm2835/bcm2835-camera.c
17 +++ b/drivers/media/platform/bcm2835/bcm2835-camera.c
18 @@ -88,12 +88,13 @@ static const struct v4l2_fract
19 /* video formats */
20 static struct mmal_fmt formats[] = {
21 {
22 - .name = "4:2:0, packed YUV",
23 + .name = "4:2:0, planar, YUV",
24 .fourcc = V4L2_PIX_FMT_YUV420,
25 .flags = 0,
26 .mmal = MMAL_ENCODING_I420,
27 .depth = 12,
28 .mmal_component = MMAL_COMPONENT_CAMERA,
29 + .ybbp = 1,
30 },
31 {
32 .name = "4:2:2, packed, YUYV",
33 @@ -102,6 +103,7 @@ static struct mmal_fmt formats[] = {
34 .mmal = MMAL_ENCODING_YUYV,
35 .depth = 16,
36 .mmal_component = MMAL_COMPONENT_CAMERA,
37 + .ybbp = 2,
38 },
39 {
40 .name = "RGB24 (LE)",
41 @@ -110,6 +112,7 @@ static struct mmal_fmt formats[] = {
42 .mmal = MMAL_ENCODING_BGR24,
43 .depth = 24,
44 .mmal_component = MMAL_COMPONENT_CAMERA,
45 + .ybbp = 3,
46 },
47 {
48 .name = "JPEG",
49 @@ -118,6 +121,7 @@ static struct mmal_fmt formats[] = {
50 .mmal = MMAL_ENCODING_JPEG,
51 .depth = 8,
52 .mmal_component = MMAL_COMPONENT_IMAGE_ENCODE,
53 + .ybbp = 0,
54 },
55 {
56 .name = "H264",
57 @@ -126,6 +130,7 @@ static struct mmal_fmt formats[] = {
58 .mmal = MMAL_ENCODING_H264,
59 .depth = 8,
60 .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE,
61 + .ybbp = 0,
62 },
63 {
64 .name = "MJPEG",
65 @@ -134,6 +139,7 @@ static struct mmal_fmt formats[] = {
66 .mmal = MMAL_ENCODING_MJPEG,
67 .depth = 8,
68 .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE,
69 + .ybbp = 0,
70 },
71 {
72 .name = "4:2:2, packed, YVYU",
73 @@ -142,6 +148,7 @@ static struct mmal_fmt formats[] = {
74 .mmal = MMAL_ENCODING_YVYU,
75 .depth = 16,
76 .mmal_component = MMAL_COMPONENT_CAMERA,
77 + .ybbp = 2,
78 },
79 {
80 .name = "4:2:2, packed, VYUY",
81 @@ -150,6 +157,7 @@ static struct mmal_fmt formats[] = {
82 .mmal = MMAL_ENCODING_VYUY,
83 .depth = 16,
84 .mmal_component = MMAL_COMPONENT_CAMERA,
85 + .ybbp = 2,
86 },
87 {
88 .name = "4:2:2, packed, UYVY",
89 @@ -158,14 +166,16 @@ static struct mmal_fmt formats[] = {
90 .mmal = MMAL_ENCODING_UYVY,
91 .depth = 16,
92 .mmal_component = MMAL_COMPONENT_CAMERA,
93 + .ybbp = 2,
94 },
95 {
96 - .name = "4:2:0, packed, NV12",
97 + .name = "4:2:0, planar, NV12",
98 .fourcc = V4L2_PIX_FMT_NV12,
99 .flags = 0,
100 .mmal = MMAL_ENCODING_NV12,
101 .depth = 12,
102 .mmal_component = MMAL_COMPONENT_CAMERA,
103 + .ybbp = 1,
104 },
105 {
106 .name = "RGB24 (BE)",
107 @@ -174,22 +184,25 @@ static struct mmal_fmt formats[] = {
108 .mmal = MMAL_ENCODING_RGB24,
109 .depth = 24,
110 .mmal_component = MMAL_COMPONENT_CAMERA,
111 + .ybbp = 3,
112 },
113 {
114 - .name = "4:2:0, packed YVU",
115 + .name = "4:2:0, planar, YVU",
116 .fourcc = V4L2_PIX_FMT_YVU420,
117 .flags = 0,
118 .mmal = MMAL_ENCODING_YV12,
119 .depth = 12,
120 .mmal_component = MMAL_COMPONENT_CAMERA,
121 + .ybbp = 1,
122 },
123 {
124 - .name = "4:2:0, packed, NV21",
125 + .name = "4:2:0, planar, NV21",
126 .fourcc = V4L2_PIX_FMT_NV21,
127 .flags = 0,
128 .mmal = MMAL_ENCODING_NV21,
129 .depth = 12,
130 .mmal_component = MMAL_COMPONENT_CAMERA,
131 + .ybbp = 1,
132 },
133 {
134 .name = "RGB32 (BE)",
135 @@ -198,6 +211,7 @@ static struct mmal_fmt formats[] = {
136 .mmal = MMAL_ENCODING_BGRA,
137 .depth = 32,
138 .mmal_component = MMAL_COMPONENT_CAMERA,
139 + .ybbp = 4,
140 },
141 };
142
143 @@ -771,7 +785,7 @@ static int vidioc_g_fbuf(struct file *fi
144 a->fmt.width = preview_port->es.video.width;
145 a->fmt.height = preview_port->es.video.height;
146 a->fmt.pixelformat = V4L2_PIX_FMT_YUV420;
147 - a->fmt.bytesperline = (preview_port->es.video.width * 3)>>1;
148 + a->fmt.bytesperline = preview_port->es.video.width;
149 a->fmt.sizeimage = (preview_port->es.video.width *
150 preview_port->es.video.height * 3)>>1;
151 a->fmt.colorspace = V4L2_COLORSPACE_SMPTE170M;
152 @@ -894,7 +908,7 @@ static int vidioc_try_fmt_vid_cap(struct
153
154 v4l_bound_align_image(&f->fmt.pix.width, MIN_WIDTH, MAX_WIDTH, 1,
155 &f->fmt.pix.height, MIN_HEIGHT, MAX_HEIGHT, 1, 0);
156 - f->fmt.pix.bytesperline = (f->fmt.pix.width * mfmt->depth)>>3;
157 + f->fmt.pix.bytesperline = f->fmt.pix.width * mfmt->ybbp;
158
159 /* Image buffer has to be padded to allow for alignment, even though
160 * we then remove that padding before delivering the buffer.
161 --- a/drivers/media/platform/bcm2835/mmal-common.h
162 +++ b/drivers/media/platform/bcm2835/mmal-common.h
163 @@ -30,6 +30,7 @@ struct mmal_fmt {
164 u32 mmal;
165 int depth;
166 u32 mmal_component; /* MMAL component index to be used to encode */
167 + u32 ybbp; /* depth of first Y plane for planar formats */
168 };
169
170 /* buffer for one video frame */