1 From 36a1512b06d8bbfdb05bc9279684177c88ea11af 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/222] bcm2835 camera planar/packed stride length
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.
10 Signed-off-by: Garrett Wilson <g@floft.net>
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(-)
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
20 static struct mmal_fmt formats[] = {
22 - .name = "4:2:0, packed YUV",
23 + .name = "4:2:0, planar, YUV",
24 .fourcc = V4L2_PIX_FMT_YUV420,
26 .mmal = MMAL_ENCODING_I420,
28 .mmal_component = MMAL_COMPONENT_CAMERA,
32 .name = "4:2:2, packed, YUYV",
33 @@ -102,6 +103,7 @@ static struct mmal_fmt formats[] = {
34 .mmal = MMAL_ENCODING_YUYV,
36 .mmal_component = MMAL_COMPONENT_CAMERA,
41 @@ -110,6 +112,7 @@ static struct mmal_fmt formats[] = {
42 .mmal = MMAL_ENCODING_BGR24,
44 .mmal_component = MMAL_COMPONENT_CAMERA,
49 @@ -118,6 +121,7 @@ static struct mmal_fmt formats[] = {
50 .mmal = MMAL_ENCODING_JPEG,
52 .mmal_component = MMAL_COMPONENT_IMAGE_ENCODE,
57 @@ -126,6 +130,7 @@ static struct mmal_fmt formats[] = {
58 .mmal = MMAL_ENCODING_H264,
60 .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE,
65 @@ -134,6 +139,7 @@ static struct mmal_fmt formats[] = {
66 .mmal = MMAL_ENCODING_MJPEG,
68 .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE,
72 .name = "4:2:2, packed, YVYU",
73 @@ -142,6 +148,7 @@ static struct mmal_fmt formats[] = {
74 .mmal = MMAL_ENCODING_YVYU,
76 .mmal_component = MMAL_COMPONENT_CAMERA,
80 .name = "4:2:2, packed, VYUY",
81 @@ -150,6 +157,7 @@ static struct mmal_fmt formats[] = {
82 .mmal = MMAL_ENCODING_VYUY,
84 .mmal_component = MMAL_COMPONENT_CAMERA,
88 .name = "4:2:2, packed, UYVY",
89 @@ -158,14 +166,16 @@ static struct mmal_fmt formats[] = {
90 .mmal = MMAL_ENCODING_UYVY,
92 .mmal_component = MMAL_COMPONENT_CAMERA,
96 - .name = "4:2:0, packed, NV12",
97 + .name = "4:2:0, planar, NV12",
98 .fourcc = V4L2_PIX_FMT_NV12,
100 .mmal = MMAL_ENCODING_NV12,
102 .mmal_component = MMAL_COMPONENT_CAMERA,
106 .name = "RGB24 (BE)",
107 @@ -174,22 +184,25 @@ static struct mmal_fmt formats[] = {
108 .mmal = MMAL_ENCODING_RGB24,
110 .mmal_component = MMAL_COMPONENT_CAMERA,
114 - .name = "4:2:0, packed YVU",
115 + .name = "4:2:0, planar, YVU",
116 .fourcc = V4L2_PIX_FMT_YVU420,
118 .mmal = MMAL_ENCODING_YV12,
120 .mmal_component = MMAL_COMPONENT_CAMERA,
124 - .name = "4:2:0, packed, NV21",
125 + .name = "4:2:0, planar, NV21",
126 .fourcc = V4L2_PIX_FMT_NV21,
128 .mmal = MMAL_ENCODING_NV21,
130 .mmal_component = MMAL_COMPONENT_CAMERA,
134 .name = "RGB32 (BE)",
135 @@ -198,6 +211,7 @@ static struct mmal_fmt formats[] = {
136 .mmal = MMAL_ENCODING_BGRA,
138 .mmal_component = MMAL_COMPONENT_CAMERA,
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
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;
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 {
166 u32 mmal_component; /* MMAL component index to be used to encode */
167 + u32 ybbp; /* depth of first Y plane for planar formats */
170 /* buffer for one video frame */