1 From 01a1601512893ce9a3353e1686a95a9861f3d685 Mon Sep 17 00:00:00 2001
2 From: Naushir Patuck <naush@raspberrypi.com>
3 Date: Fri, 1 May 2020 14:15:24 +0100
4 Subject: [PATCH] staging: vc04_services: ISP: Add enum_framesizes
7 This is used to enumerate available frame sizes on all nodes
8 apart from statistics output.
10 Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
12 .../bcm2835-isp/bcm2835-v4l2-isp.c | 48 +++++++++++++++++--
13 .../bcm2835-isp/bcm2835_isp_fmts.h | 29 +++++++++++
14 2 files changed, 72 insertions(+), 5 deletions(-)
16 --- a/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
17 +++ b/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
18 @@ -227,8 +227,9 @@ static const struct bcm2835_isp_fmt *get
22 -static struct bcm2835_isp_fmt *find_format(struct v4l2_format *f,
23 - struct bcm2835_isp_node *node)
25 +struct bcm2835_isp_fmt *find_format_by_fourcc(unsigned int fourcc,
26 + struct bcm2835_isp_node *node)
28 struct bcm2835_isp_fmt_list *fmts = &node->supported_fmts;
29 struct bcm2835_isp_fmt *fmt;
30 @@ -236,15 +237,22 @@ static struct bcm2835_isp_fmt *find_form
32 for (i = 0; i < fmts->num_entries; i++) {
34 - if (fmt->fourcc == (node_is_stats(node) ?
35 - f->fmt.meta.dataformat :
36 - f->fmt.pix.pixelformat))
37 + if (fmt->fourcc == fourcc)
44 +static struct bcm2835_isp_fmt *find_format(struct v4l2_format *f,
45 + struct bcm2835_isp_node *node)
47 + return find_format_by_fourcc(node_is_stats(node) ?
48 + f->fmt.meta.dataformat :
49 + f->fmt.pix.pixelformat,
53 /* vb2_to_mmal_buffer() - converts vb2 buffer header to MMAL
55 * Copies all the required fields from a VB2 buffer to the MMAL buffer header,
56 @@ -892,6 +900,35 @@ static int bcm2835_isp_node_enum_fmt(str
60 +static int bcm2835_isp_enum_framesizes(struct file *file, void *priv,
61 + struct v4l2_frmsizeenum *fsize)
63 + struct bcm2835_isp_node *node = video_drvdata(file);
64 + struct bcm2835_isp_dev *dev = node_get_dev(node);
65 + struct bcm2835_isp_fmt *fmt;
67 + if (node_is_stats(node) || fsize->index)
70 + fmt = find_format_by_fourcc(fsize->pixel_format, node);
72 + v4l2_err(&dev->v4l2_dev, "Invalid pixel code: %x\n",
73 + fsize->pixel_format);
77 + fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
78 + fsize->stepwise.min_width = MIN_DIM;
79 + fsize->stepwise.max_width = MAX_DIM;
80 + fsize->stepwise.step_width = fmt->step_size;
82 + fsize->stepwise.min_height = MIN_DIM;
83 + fsize->stepwise.max_height = MAX_DIM;
84 + fsize->stepwise.step_height = fmt->step_size;
89 static int bcm2835_isp_node_try_fmt(struct file *file, void *priv,
90 struct v4l2_format *f)
92 @@ -1046,6 +1083,7 @@ static const struct v4l2_ioctl_ops bcm28
93 .vidioc_enum_fmt_vid_cap = bcm2835_isp_node_enum_fmt,
94 .vidioc_enum_fmt_vid_out = bcm2835_isp_node_enum_fmt,
95 .vidioc_enum_fmt_meta_cap = bcm2835_isp_node_enum_fmt,
96 + .vidioc_enum_framesizes = bcm2835_isp_enum_framesizes,
98 .vidioc_reqbufs = vb2_ioctl_reqbufs,
99 .vidioc_querybuf = vb2_ioctl_querybuf,
100 --- a/drivers/staging/vc04_services/bcm2835-isp/bcm2835_isp_fmts.h
101 +++ b/drivers/staging/vc04_services/bcm2835-isp/bcm2835_isp_fmts.h
102 @@ -22,6 +22,7 @@ struct bcm2835_isp_fmt {
104 int size_multiplier_x2;
105 enum v4l2_colorspace colorspace;
106 + unsigned int step_size;
109 struct bcm2835_isp_fmt_list {
110 @@ -39,6 +40,7 @@ static const struct bcm2835_isp_fmt supp
111 .mmal_fmt = MMAL_ENCODING_I420,
112 .size_multiplier_x2 = 3,
113 .colorspace = V4L2_COLORSPACE_SMPTE170M,
116 .fourcc = V4L2_PIX_FMT_YVU420,
118 @@ -47,6 +49,7 @@ static const struct bcm2835_isp_fmt supp
119 .mmal_fmt = MMAL_ENCODING_YV12,
120 .size_multiplier_x2 = 3,
121 .colorspace = V4L2_COLORSPACE_SMPTE170M,
124 .fourcc = V4L2_PIX_FMT_NV12,
126 @@ -55,6 +58,7 @@ static const struct bcm2835_isp_fmt supp
127 .mmal_fmt = MMAL_ENCODING_NV12,
128 .size_multiplier_x2 = 3,
129 .colorspace = V4L2_COLORSPACE_SMPTE170M,
132 .fourcc = V4L2_PIX_FMT_NV21,
134 @@ -63,6 +67,7 @@ static const struct bcm2835_isp_fmt supp
135 .mmal_fmt = MMAL_ENCODING_NV21,
136 .size_multiplier_x2 = 3,
137 .colorspace = V4L2_COLORSPACE_SMPTE170M,
140 .fourcc = V4L2_PIX_FMT_YUYV,
142 @@ -71,6 +76,7 @@ static const struct bcm2835_isp_fmt supp
143 .mmal_fmt = MMAL_ENCODING_YUYV,
144 .size_multiplier_x2 = 2,
145 .colorspace = V4L2_COLORSPACE_SMPTE170M,
148 .fourcc = V4L2_PIX_FMT_UYVY,
150 @@ -79,6 +85,7 @@ static const struct bcm2835_isp_fmt supp
151 .mmal_fmt = MMAL_ENCODING_UYVY,
152 .size_multiplier_x2 = 2,
153 .colorspace = V4L2_COLORSPACE_SMPTE170M,
156 .fourcc = V4L2_PIX_FMT_YVYU,
158 @@ -87,6 +94,7 @@ static const struct bcm2835_isp_fmt supp
159 .mmal_fmt = MMAL_ENCODING_YVYU,
160 .size_multiplier_x2 = 2,
161 .colorspace = V4L2_COLORSPACE_SMPTE170M,
164 .fourcc = V4L2_PIX_FMT_VYUY,
166 @@ -95,6 +103,7 @@ static const struct bcm2835_isp_fmt supp
167 .mmal_fmt = MMAL_ENCODING_VYUY,
168 .size_multiplier_x2 = 2,
169 .colorspace = V4L2_COLORSPACE_SMPTE170M,
173 .fourcc = V4L2_PIX_FMT_RGB24,
174 @@ -104,6 +113,7 @@ static const struct bcm2835_isp_fmt supp
175 .mmal_fmt = MMAL_ENCODING_RGB24,
176 .size_multiplier_x2 = 2,
177 .colorspace = V4L2_COLORSPACE_SRGB,
180 .fourcc = V4L2_PIX_FMT_RGB565,
182 @@ -112,6 +122,7 @@ static const struct bcm2835_isp_fmt supp
183 .mmal_fmt = MMAL_ENCODING_RGB16,
184 .size_multiplier_x2 = 2,
185 .colorspace = V4L2_COLORSPACE_SRGB,
188 .fourcc = V4L2_PIX_FMT_BGR24,
190 @@ -120,6 +131,7 @@ static const struct bcm2835_isp_fmt supp
191 .mmal_fmt = MMAL_ENCODING_BGR24,
192 .size_multiplier_x2 = 2,
193 .colorspace = V4L2_COLORSPACE_SRGB,
196 .fourcc = V4L2_PIX_FMT_ABGR32,
198 @@ -128,6 +140,7 @@ static const struct bcm2835_isp_fmt supp
199 .mmal_fmt = MMAL_ENCODING_BGRA,
200 .size_multiplier_x2 = 2,
201 .colorspace = V4L2_COLORSPACE_SRGB,
206 @@ -138,6 +151,7 @@ static const struct bcm2835_isp_fmt supp
207 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB8,
208 .size_multiplier_x2 = 2,
209 .colorspace = V4L2_COLORSPACE_RAW,
212 .fourcc = V4L2_PIX_FMT_SBGGR8,
214 @@ -146,6 +160,7 @@ static const struct bcm2835_isp_fmt supp
215 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR8,
216 .size_multiplier_x2 = 2,
217 .colorspace = V4L2_COLORSPACE_RAW,
220 .fourcc = V4L2_PIX_FMT_SGRBG8,
222 @@ -154,6 +169,7 @@ static const struct bcm2835_isp_fmt supp
223 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG8,
224 .size_multiplier_x2 = 2,
225 .colorspace = V4L2_COLORSPACE_RAW,
228 .fourcc = V4L2_PIX_FMT_SGBRG8,
230 @@ -162,6 +178,7 @@ static const struct bcm2835_isp_fmt supp
231 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG8,
232 .size_multiplier_x2 = 2,
233 .colorspace = V4L2_COLORSPACE_RAW,
237 .fourcc = V4L2_PIX_FMT_SRGGB10P,
238 @@ -171,6 +188,7 @@ static const struct bcm2835_isp_fmt supp
239 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB10P,
240 .size_multiplier_x2 = 2,
241 .colorspace = V4L2_COLORSPACE_RAW,
244 .fourcc = V4L2_PIX_FMT_SBGGR10P,
246 @@ -179,6 +197,7 @@ static const struct bcm2835_isp_fmt supp
247 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR10P,
248 .size_multiplier_x2 = 2,
249 .colorspace = V4L2_COLORSPACE_RAW,
252 .fourcc = V4L2_PIX_FMT_SGRBG10P,
254 @@ -187,6 +206,7 @@ static const struct bcm2835_isp_fmt supp
255 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG10P,
256 .size_multiplier_x2 = 2,
257 .colorspace = V4L2_COLORSPACE_RAW,
260 .fourcc = V4L2_PIX_FMT_SGBRG10P,
262 @@ -195,6 +215,7 @@ static const struct bcm2835_isp_fmt supp
263 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG10P,
264 .size_multiplier_x2 = 2,
265 .colorspace = V4L2_COLORSPACE_RAW,
269 .fourcc = V4L2_PIX_FMT_SRGGB12P,
270 @@ -204,6 +225,7 @@ static const struct bcm2835_isp_fmt supp
271 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB12P,
272 .size_multiplier_x2 = 2,
273 .colorspace = V4L2_COLORSPACE_RAW,
276 .fourcc = V4L2_PIX_FMT_SBGGR12P,
278 @@ -212,6 +234,7 @@ static const struct bcm2835_isp_fmt supp
279 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR12P,
280 .size_multiplier_x2 = 2,
281 .colorspace = V4L2_COLORSPACE_RAW,
284 .fourcc = V4L2_PIX_FMT_SGRBG12P,
286 @@ -220,6 +243,7 @@ static const struct bcm2835_isp_fmt supp
287 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG12P,
288 .size_multiplier_x2 = 2,
289 .colorspace = V4L2_COLORSPACE_RAW,
292 .fourcc = V4L2_PIX_FMT_SGBRG12P,
294 @@ -228,6 +252,7 @@ static const struct bcm2835_isp_fmt supp
295 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG12P,
296 .size_multiplier_x2 = 2,
297 .colorspace = V4L2_COLORSPACE_RAW,
301 .fourcc = V4L2_PIX_FMT_SRGGB16,
302 @@ -237,6 +262,7 @@ static const struct bcm2835_isp_fmt supp
303 .mmal_fmt = MMAL_ENCODING_BAYER_SRGGB16,
304 .size_multiplier_x2 = 2,
305 .colorspace = V4L2_COLORSPACE_RAW,
308 .fourcc = V4L2_PIX_FMT_SBGGR16,
310 @@ -245,6 +271,7 @@ static const struct bcm2835_isp_fmt supp
311 .mmal_fmt = MMAL_ENCODING_BAYER_SBGGR16,
312 .size_multiplier_x2 = 2,
313 .colorspace = V4L2_COLORSPACE_RAW,
316 .fourcc = V4L2_PIX_FMT_SGRBG16,
318 @@ -253,6 +280,7 @@ static const struct bcm2835_isp_fmt supp
319 .mmal_fmt = MMAL_ENCODING_BAYER_SGRBG16,
320 .size_multiplier_x2 = 2,
321 .colorspace = V4L2_COLORSPACE_RAW,
324 .fourcc = V4L2_PIX_FMT_SGBRG16,
326 @@ -261,6 +289,7 @@ static const struct bcm2835_isp_fmt supp
327 .mmal_fmt = MMAL_ENCODING_BAYER_SGBRG16,
328 .size_multiplier_x2 = 2,
329 .colorspace = V4L2_COLORSPACE_RAW,
332 /* ISP statistics format */
333 .fourcc = V4L2_META_FMT_BCM2835_ISP_STATS,