blob: c557eb5ebf6b5d11c57bbf15fe604306cef1a4c5 [file] [log] [blame]
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001/*
2 * Copyright (C) 2008-2009 Texas Instruments Inc
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Driver name : VPFE Capture driver
19 * VPFE Capture driver allows applications to capture and stream video
20 * frames on DaVinci SoCs (DM6446, DM355 etc) from a YUV source such as
21 * TVP5146 or Raw Bayer RGB image data from an image sensor
22 * such as Microns' MT9T001, MT9T031 etc.
23 *
24 * These SoCs have, in common, a Video Processing Subsystem (VPSS) that
25 * consists of a Video Processing Front End (VPFE) for capturing
26 * video/raw image data and Video Processing Back End (VPBE) for displaying
27 * YUV data through an in-built analog encoder or Digital LCD port. This
28 * driver is for capture through VPFE. A typical EVM using these SoCs have
29 * following high level configuration.
30 *
31 *
32 * decoder(TVP5146/ YUV/
33 * MT9T001) --> Raw Bayer RGB ---> MUX -> VPFE (CCDC/ISIF)
34 * data input | |
35 * V |
36 * SDRAM |
37 * V
38 * Image Processor
39 * |
40 * V
41 * SDRAM
42 * The data flow happens from a decoder connected to the VPFE over a
43 * YUV embedded (BT.656/BT.1120) or separate sync or raw bayer rgb interface
44 * and to the input of VPFE through an optional MUX (if more inputs are
45 * to be interfaced on the EVM). The input data is first passed through
46 * CCDC (CCD Controller, a.k.a Image Sensor Interface, ISIF). The CCDC
47 * does very little or no processing on YUV data and does pre-process Raw
48 * Bayer RGB data through modules such as Defect Pixel Correction (DFC)
49 * Color Space Conversion (CSC), data gain/offset etc. After this, data
50 * can be written to SDRAM or can be connected to the image processing
51 * block such as IPIPE (on DM355 only).
52 *
53 * Features supported
54 * - MMAP IO
55 * - Capture using TVP5146 over BT.656
56 * - support for interfacing decoders using sub device model
57 * - Work with DM355 or DM6446 CCDC to do Raw Bayer RGB/YUV
58 * data capture to SDRAM.
59 * TODO list
60 * - Support multiple REQBUF after open
61 * - Support for de-allocating buffers through REQBUF
62 * - Support for Raw Bayer RGB capture
63 * - Support for chaining Image Processor
64 * - Support for static allocation of buffers
65 * - Support for USERPTR IO
66 * - Support for STREAMON before QBUF
67 * - Support for control ioctls
68 */
69#include <linux/module.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090070#include <linux/slab.h>
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -030071#include <linux/init.h>
72#include <linux/platform_device.h>
73#include <linux/interrupt.h>
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -030074#include <media/v4l2-common.h>
75#include <linux/io.h>
76#include <media/davinci/vpfe_capture.h>
77#include "ccdc_hw_device.h"
78
79static int debug;
80static u32 numbuffers = 3;
81static u32 bufsize = (720 * 576 * 2);
82
83module_param(numbuffers, uint, S_IRUGO);
84module_param(bufsize, uint, S_IRUGO);
85module_param(debug, int, 0644);
86
87MODULE_PARM_DESC(numbuffers, "buffer count (default:3)");
88MODULE_PARM_DESC(bufsize, "buffer size in bytes (default:720 x 576 x 2)");
89MODULE_PARM_DESC(debug, "Debug level 0-1");
90
91MODULE_DESCRIPTION("VPFE Video for Linux Capture Driver");
92MODULE_LICENSE("GPL");
93MODULE_AUTHOR("Texas Instruments");
94
95/* standard information */
96struct vpfe_standard {
97 v4l2_std_id std_id;
98 unsigned int width;
99 unsigned int height;
100 struct v4l2_fract pixelaspect;
101 /* 0 - progressive, 1 - interlaced */
102 int frame_format;
103};
104
105/* ccdc configuration */
106struct ccdc_config {
107 /* This make sure vpfe is probed and ready to go */
108 int vpfe_probed;
109 /* name of ccdc device */
110 char name[32];
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300111};
112
113/* data structures */
114static struct vpfe_config_params config_params = {
115 .min_numbuffers = 3,
116 .numbuffers = 3,
117 .min_bufsize = 720 * 480 * 2,
118 .device_bufsize = 720 * 576 * 2,
119};
120
121/* ccdc device registered */
122static struct ccdc_hw_device *ccdc_dev;
123/* lock for accessing ccdc information */
124static DEFINE_MUTEX(ccdc_lock);
125/* ccdc configuration */
126static struct ccdc_config *ccdc_cfg;
127
128const struct vpfe_standard vpfe_standards[] = {
129 {V4L2_STD_525_60, 720, 480, {11, 10}, 1},
130 {V4L2_STD_625_50, 720, 576, {54, 59}, 1},
131};
132
133/* Used when raw Bayer image from ccdc is directly captured to SDRAM */
134static const struct vpfe_pixel_format vpfe_pix_fmts[] = {
135 {
136 .fmtdesc = {
137 .index = 0,
138 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
139 .description = "Bayer GrRBGb 8bit A-Law compr.",
140 .pixelformat = V4L2_PIX_FMT_SBGGR8,
141 },
142 .bpp = 1,
143 },
144 {
145 .fmtdesc = {
146 .index = 1,
147 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
148 .description = "Bayer GrRBGb - 16bit",
149 .pixelformat = V4L2_PIX_FMT_SBGGR16,
150 },
151 .bpp = 2,
152 },
153 {
154 .fmtdesc = {
155 .index = 2,
156 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
157 .description = "Bayer GrRBGb 8bit DPCM compr.",
158 .pixelformat = V4L2_PIX_FMT_SGRBG10DPCM8,
159 },
160 .bpp = 1,
161 },
162 {
163 .fmtdesc = {
164 .index = 3,
165 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
166 .description = "YCbCr 4:2:2 Interleaved UYVY",
167 .pixelformat = V4L2_PIX_FMT_UYVY,
168 },
169 .bpp = 2,
170 },
171 {
172 .fmtdesc = {
173 .index = 4,
174 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
175 .description = "YCbCr 4:2:2 Interleaved YUYV",
176 .pixelformat = V4L2_PIX_FMT_YUYV,
177 },
178 .bpp = 2,
179 },
180 {
181 .fmtdesc = {
182 .index = 5,
183 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
184 .description = "Y/CbCr 4:2:0 - Semi planar",
185 .pixelformat = V4L2_PIX_FMT_NV12,
186 },
187 .bpp = 1,
188 },
189};
190
191/*
192 * vpfe_lookup_pix_format()
193 * lookup an entry in the vpfe pix format table based on pix_format
194 */
195static const struct vpfe_pixel_format *vpfe_lookup_pix_format(u32 pix_format)
196{
197 int i;
198
199 for (i = 0; i < ARRAY_SIZE(vpfe_pix_fmts); i++) {
200 if (pix_format == vpfe_pix_fmts[i].fmtdesc.pixelformat)
201 return &vpfe_pix_fmts[i];
202 }
203 return NULL;
204}
205
206/*
207 * vpfe_register_ccdc_device. CCDC module calls this to
208 * register with vpfe capture
209 */
210int vpfe_register_ccdc_device(struct ccdc_hw_device *dev)
211{
212 int ret = 0;
213 printk(KERN_NOTICE "vpfe_register_ccdc_device: %s\n", dev->name);
214
215 BUG_ON(!dev->hw_ops.open);
216 BUG_ON(!dev->hw_ops.enable);
217 BUG_ON(!dev->hw_ops.set_hw_if_params);
218 BUG_ON(!dev->hw_ops.configure);
219 BUG_ON(!dev->hw_ops.set_buftype);
220 BUG_ON(!dev->hw_ops.get_buftype);
221 BUG_ON(!dev->hw_ops.enum_pix);
222 BUG_ON(!dev->hw_ops.set_frame_format);
223 BUG_ON(!dev->hw_ops.get_frame_format);
224 BUG_ON(!dev->hw_ops.get_pixel_format);
225 BUG_ON(!dev->hw_ops.set_pixel_format);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300226 BUG_ON(!dev->hw_ops.set_image_window);
227 BUG_ON(!dev->hw_ops.get_image_window);
228 BUG_ON(!dev->hw_ops.get_line_length);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300229 BUG_ON(!dev->hw_ops.getfid);
230
231 mutex_lock(&ccdc_lock);
232 if (NULL == ccdc_cfg) {
233 /*
234 * TODO. Will this ever happen? if so, we need to fix it.
235 * Proabably we need to add the request to a linked list and
236 * walk through it during vpfe probe
237 */
238 printk(KERN_ERR "vpfe capture not initialized\n");
Muralidharan Karicheri51444ea2010-01-13 20:27:05 -0300239 ret = -EFAULT;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300240 goto unlock;
241 }
242
243 if (strcmp(dev->name, ccdc_cfg->name)) {
244 /* ignore this ccdc */
Muralidharan Karicheri51444ea2010-01-13 20:27:05 -0300245 ret = -EINVAL;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300246 goto unlock;
247 }
248
249 if (ccdc_dev) {
250 printk(KERN_ERR "ccdc already registered\n");
Muralidharan Karicheri51444ea2010-01-13 20:27:05 -0300251 ret = -EINVAL;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300252 goto unlock;
253 }
254
255 ccdc_dev = dev;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300256unlock:
257 mutex_unlock(&ccdc_lock);
258 return ret;
259}
260EXPORT_SYMBOL(vpfe_register_ccdc_device);
261
262/*
263 * vpfe_unregister_ccdc_device. CCDC module calls this to
264 * unregister with vpfe capture
265 */
266void vpfe_unregister_ccdc_device(struct ccdc_hw_device *dev)
267{
268 if (NULL == dev) {
269 printk(KERN_ERR "invalid ccdc device ptr\n");
270 return;
271 }
272
273 printk(KERN_NOTICE "vpfe_unregister_ccdc_device, dev->name = %s\n",
274 dev->name);
275
276 if (strcmp(dev->name, ccdc_cfg->name)) {
277 /* ignore this ccdc */
278 return;
279 }
280
281 mutex_lock(&ccdc_lock);
282 ccdc_dev = NULL;
283 mutex_unlock(&ccdc_lock);
284 return;
285}
286EXPORT_SYMBOL(vpfe_unregister_ccdc_device);
287
288/*
289 * vpfe_get_ccdc_image_format - Get image parameters based on CCDC settings
290 */
291static int vpfe_get_ccdc_image_format(struct vpfe_device *vpfe_dev,
292 struct v4l2_format *f)
293{
294 struct v4l2_rect image_win;
295 enum ccdc_buftype buf_type;
296 enum ccdc_frmfmt frm_fmt;
297
298 memset(f, 0, sizeof(*f));
299 f->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
300 ccdc_dev->hw_ops.get_image_window(&image_win);
301 f->fmt.pix.width = image_win.width;
302 f->fmt.pix.height = image_win.height;
303 f->fmt.pix.bytesperline = ccdc_dev->hw_ops.get_line_length();
304 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline *
305 f->fmt.pix.height;
306 buf_type = ccdc_dev->hw_ops.get_buftype();
307 f->fmt.pix.pixelformat = ccdc_dev->hw_ops.get_pixel_format();
308 frm_fmt = ccdc_dev->hw_ops.get_frame_format();
309 if (frm_fmt == CCDC_FRMFMT_PROGRESSIVE)
310 f->fmt.pix.field = V4L2_FIELD_NONE;
311 else if (frm_fmt == CCDC_FRMFMT_INTERLACED) {
312 if (buf_type == CCDC_BUFTYPE_FLD_INTERLEAVED)
313 f->fmt.pix.field = V4L2_FIELD_INTERLACED;
314 else if (buf_type == CCDC_BUFTYPE_FLD_SEPARATED)
315 f->fmt.pix.field = V4L2_FIELD_SEQ_TB;
316 else {
317 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf_type\n");
318 return -EINVAL;
319 }
320 } else {
321 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid frm_fmt\n");
322 return -EINVAL;
323 }
324 return 0;
325}
326
327/*
328 * vpfe_config_ccdc_image_format()
329 * For a pix format, configure ccdc to setup the capture
330 */
331static int vpfe_config_ccdc_image_format(struct vpfe_device *vpfe_dev)
332{
333 enum ccdc_frmfmt frm_fmt = CCDC_FRMFMT_INTERLACED;
334 int ret = 0;
335
336 if (ccdc_dev->hw_ops.set_pixel_format(
337 vpfe_dev->fmt.fmt.pix.pixelformat) < 0) {
338 v4l2_err(&vpfe_dev->v4l2_dev,
339 "couldn't set pix format in ccdc\n");
340 return -EINVAL;
341 }
342 /* configure the image window */
343 ccdc_dev->hw_ops.set_image_window(&vpfe_dev->crop);
344
345 switch (vpfe_dev->fmt.fmt.pix.field) {
346 case V4L2_FIELD_INTERLACED:
347 /* do nothing, since it is default */
348 ret = ccdc_dev->hw_ops.set_buftype(
349 CCDC_BUFTYPE_FLD_INTERLEAVED);
350 break;
351 case V4L2_FIELD_NONE:
352 frm_fmt = CCDC_FRMFMT_PROGRESSIVE;
353 /* buffer type only applicable for interlaced scan */
354 break;
355 case V4L2_FIELD_SEQ_TB:
356 ret = ccdc_dev->hw_ops.set_buftype(
357 CCDC_BUFTYPE_FLD_SEPARATED);
358 break;
359 default:
360 return -EINVAL;
361 }
362
363 /* set the frame format */
364 if (!ret)
365 ret = ccdc_dev->hw_ops.set_frame_format(frm_fmt);
366 return ret;
367}
368/*
369 * vpfe_config_image_format()
370 * For a given standard, this functions sets up the default
371 * pix format & crop values in the vpfe device and ccdc. It first
372 * starts with defaults based values from the standard table.
Hans Verkuild3ca7752010-08-07 06:49:33 -0300373 * It then checks if sub device support g_mbus_fmt and then override the
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300374 * values based on that.Sets crop values to match with scan resolution
375 * starting at 0,0. It calls vpfe_config_ccdc_image_format() set the
376 * values in ccdc
377 */
378static int vpfe_config_image_format(struct vpfe_device *vpfe_dev,
Hans Verkuil314527a2013-03-15 06:10:40 -0300379 v4l2_std_id std_id)
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300380{
381 struct vpfe_subdev_info *sdinfo = vpfe_dev->current_subdev;
Hans Verkuild3ca7752010-08-07 06:49:33 -0300382 struct v4l2_mbus_framefmt mbus_fmt;
383 struct v4l2_pix_format *pix = &vpfe_dev->fmt.fmt.pix;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300384 int i, ret = 0;
385
386 for (i = 0; i < ARRAY_SIZE(vpfe_standards); i++) {
Hans Verkuil314527a2013-03-15 06:10:40 -0300387 if (vpfe_standards[i].std_id & std_id) {
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300388 vpfe_dev->std_info.active_pixels =
389 vpfe_standards[i].width;
390 vpfe_dev->std_info.active_lines =
391 vpfe_standards[i].height;
392 vpfe_dev->std_info.frame_format =
393 vpfe_standards[i].frame_format;
394 vpfe_dev->std_index = i;
395 break;
396 }
397 }
398
399 if (i == ARRAY_SIZE(vpfe_standards)) {
400 v4l2_err(&vpfe_dev->v4l2_dev, "standard not supported\n");
401 return -EINVAL;
402 }
403
404 vpfe_dev->crop.top = 0;
405 vpfe_dev->crop.left = 0;
406 vpfe_dev->crop.width = vpfe_dev->std_info.active_pixels;
407 vpfe_dev->crop.height = vpfe_dev->std_info.active_lines;
Hans Verkuild3ca7752010-08-07 06:49:33 -0300408 pix->width = vpfe_dev->crop.width;
409 pix->height = vpfe_dev->crop.height;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300410
411 /* first field and frame format based on standard frame format */
412 if (vpfe_dev->std_info.frame_format) {
Hans Verkuild3ca7752010-08-07 06:49:33 -0300413 pix->field = V4L2_FIELD_INTERLACED;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300414 /* assume V4L2_PIX_FMT_UYVY as default */
Hans Verkuild3ca7752010-08-07 06:49:33 -0300415 pix->pixelformat = V4L2_PIX_FMT_UYVY;
416 v4l2_fill_mbus_format(&mbus_fmt, pix,
417 V4L2_MBUS_FMT_YUYV10_2X10);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300418 } else {
Hans Verkuild3ca7752010-08-07 06:49:33 -0300419 pix->field = V4L2_FIELD_NONE;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300420 /* assume V4L2_PIX_FMT_SBGGR8 */
Hans Verkuild3ca7752010-08-07 06:49:33 -0300421 pix->pixelformat = V4L2_PIX_FMT_SBGGR8;
422 v4l2_fill_mbus_format(&mbus_fmt, pix,
423 V4L2_MBUS_FMT_SBGGR8_1X8);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300424 }
425
Hans Verkuild3ca7752010-08-07 06:49:33 -0300426 /* if sub device supports g_mbus_fmt, override the defaults */
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300427 ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev,
Hans Verkuild3ca7752010-08-07 06:49:33 -0300428 sdinfo->grp_id, video, g_mbus_fmt, &mbus_fmt);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300429
430 if (ret && ret != -ENOIOCTLCMD) {
431 v4l2_err(&vpfe_dev->v4l2_dev,
Hans Verkuild3ca7752010-08-07 06:49:33 -0300432 "error in getting g_mbus_fmt from sub device\n");
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300433 return ret;
434 }
Hans Verkuild3ca7752010-08-07 06:49:33 -0300435 v4l2_fill_pix_format(pix, &mbus_fmt);
436 pix->bytesperline = pix->width * 2;
437 pix->sizeimage = pix->bytesperline * pix->height;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300438
439 /* Sets the values in CCDC */
440 ret = vpfe_config_ccdc_image_format(vpfe_dev);
441 if (ret)
442 return ret;
443
444 /* Update the values of sizeimage and bytesperline */
445 if (!ret) {
Hans Verkuild3ca7752010-08-07 06:49:33 -0300446 pix->bytesperline = ccdc_dev->hw_ops.get_line_length();
447 pix->sizeimage = pix->bytesperline * pix->height;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300448 }
449 return ret;
450}
451
452static int vpfe_initialize_device(struct vpfe_device *vpfe_dev)
453{
454 int ret = 0;
455
456 /* set first input of current subdevice as the current input */
457 vpfe_dev->current_input = 0;
458
459 /* set default standard */
460 vpfe_dev->std_index = 0;
461
462 /* Configure the default format information */
463 ret = vpfe_config_image_format(vpfe_dev,
Hans Verkuil314527a2013-03-15 06:10:40 -0300464 vpfe_standards[vpfe_dev->std_index].std_id);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300465 if (ret)
466 return ret;
467
468 /* now open the ccdc device to initialize it */
469 mutex_lock(&ccdc_lock);
470 if (NULL == ccdc_dev) {
471 v4l2_err(&vpfe_dev->v4l2_dev, "ccdc device not registered\n");
472 ret = -ENODEV;
473 goto unlock;
474 }
475
476 if (!try_module_get(ccdc_dev->owner)) {
477 v4l2_err(&vpfe_dev->v4l2_dev, "Couldn't lock ccdc module\n");
478 ret = -ENODEV;
479 goto unlock;
480 }
481 ret = ccdc_dev->hw_ops.open(vpfe_dev->pdev);
482 if (!ret)
483 vpfe_dev->initialized = 1;
Vaibhav Hiremath085b54a2010-03-27 09:37:07 -0300484
485 /* Clear all VPFE/CCDC interrupts */
486 if (vpfe_dev->cfg->clr_intr)
487 vpfe_dev->cfg->clr_intr(-1);
488
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300489unlock:
490 mutex_unlock(&ccdc_lock);
491 return ret;
492}
493
494/*
495 * vpfe_open : It creates object of file handle structure and
496 * stores it in private_data member of filepointer
497 */
498static int vpfe_open(struct file *file)
499{
500 struct vpfe_device *vpfe_dev = video_drvdata(file);
Lad, Prabhakar3bdaa382014-03-22 08:39:24 -0300501 struct video_device *vdev = video_devdata(file);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300502 struct vpfe_fh *fh;
503
504 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_open\n");
505
506 if (!vpfe_dev->cfg->num_subdevs) {
507 v4l2_err(&vpfe_dev->v4l2_dev, "No decoder registered\n");
508 return -ENODEV;
509 }
510
511 /* Allocate memory for the file handle object */
512 fh = kmalloc(sizeof(struct vpfe_fh), GFP_KERNEL);
513 if (NULL == fh) {
514 v4l2_err(&vpfe_dev->v4l2_dev,
515 "unable to allocate memory for file handle object\n");
516 return -ENOMEM;
517 }
518 /* store pointer to fh in private_data member of file */
519 file->private_data = fh;
520 fh->vpfe_dev = vpfe_dev;
Lad, Prabhakar3bdaa382014-03-22 08:39:24 -0300521 v4l2_fh_init(&fh->fh, vdev);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300522 mutex_lock(&vpfe_dev->lock);
523 /* If decoder is not initialized. initialize it */
524 if (!vpfe_dev->initialized) {
525 if (vpfe_initialize_device(vpfe_dev)) {
526 mutex_unlock(&vpfe_dev->lock);
527 return -ENODEV;
528 }
529 }
530 /* Increment device usrs counter */
531 vpfe_dev->usrs++;
532 /* Set io_allowed member to false */
533 fh->io_allowed = 0;
Lad, Prabhakar3bdaa382014-03-22 08:39:24 -0300534 v4l2_fh_add(&fh->fh);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300535 mutex_unlock(&vpfe_dev->lock);
536 return 0;
537}
538
539static void vpfe_schedule_next_buffer(struct vpfe_device *vpfe_dev)
540{
541 unsigned long addr;
542
543 vpfe_dev->next_frm = list_entry(vpfe_dev->dma_queue.next,
544 struct videobuf_buffer, queue);
545 list_del(&vpfe_dev->next_frm->queue);
546 vpfe_dev->next_frm->state = VIDEOBUF_ACTIVE;
547 addr = videobuf_to_dma_contig(vpfe_dev->next_frm);
Vaibhav Hiremath844cc0d2010-03-27 09:37:23 -0300548
549 ccdc_dev->hw_ops.setfbaddr(addr);
550}
551
552static void vpfe_schedule_bottom_field(struct vpfe_device *vpfe_dev)
553{
554 unsigned long addr;
555
556 addr = videobuf_to_dma_contig(vpfe_dev->cur_frm);
557 addr += vpfe_dev->field_off;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300558 ccdc_dev->hw_ops.setfbaddr(addr);
559}
560
561static void vpfe_process_buffer_complete(struct vpfe_device *vpfe_dev)
562{
Sakari Ailus8e6057b2012-09-15 15:14:42 -0300563 v4l2_get_timestamp(&vpfe_dev->cur_frm->ts);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300564 vpfe_dev->cur_frm->state = VIDEOBUF_DONE;
565 vpfe_dev->cur_frm->size = vpfe_dev->fmt.fmt.pix.sizeimage;
566 wake_up_interruptible(&vpfe_dev->cur_frm->done);
567 vpfe_dev->cur_frm = vpfe_dev->next_frm;
568}
569
570/* ISR for VINT0*/
571static irqreturn_t vpfe_isr(int irq, void *dev_id)
572{
573 struct vpfe_device *vpfe_dev = dev_id;
574 enum v4l2_field field;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300575 int fid;
576
577 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "\nStarting vpfe_isr...\n");
578 field = vpfe_dev->fmt.fmt.pix.field;
579
580 /* if streaming not started, don't do anything */
581 if (!vpfe_dev->started)
Vaibhav Hiremath085b54a2010-03-27 09:37:07 -0300582 goto clear_intr;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300583
584 /* only for 6446 this will be applicable */
585 if (NULL != ccdc_dev->hw_ops.reset)
586 ccdc_dev->hw_ops.reset();
587
588 if (field == V4L2_FIELD_NONE) {
589 /* handle progressive frame capture */
590 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
591 "frame format is progressive...\n");
592 if (vpfe_dev->cur_frm != vpfe_dev->next_frm)
593 vpfe_process_buffer_complete(vpfe_dev);
Vaibhav Hiremath085b54a2010-03-27 09:37:07 -0300594 goto clear_intr;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300595 }
596
597 /* interlaced or TB capture check which field we are in hardware */
598 fid = ccdc_dev->hw_ops.getfid();
599
600 /* switch the software maintained field id */
601 vpfe_dev->field_id ^= 1;
602 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "field id = %x:%x.\n",
603 fid, vpfe_dev->field_id);
604 if (fid == vpfe_dev->field_id) {
605 /* we are in-sync here,continue */
606 if (fid == 0) {
607 /*
608 * One frame is just being captured. If the next frame
609 * is available, release the current frame and move on
610 */
611 if (vpfe_dev->cur_frm != vpfe_dev->next_frm)
612 vpfe_process_buffer_complete(vpfe_dev);
613 /*
614 * based on whether the two fields are stored
615 * interleavely or separately in memory, reconfigure
616 * the CCDC memory address
617 */
618 if (field == V4L2_FIELD_SEQ_TB) {
Vaibhav Hiremath844cc0d2010-03-27 09:37:23 -0300619 vpfe_schedule_bottom_field(vpfe_dev);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300620 }
Vaibhav Hiremath085b54a2010-03-27 09:37:07 -0300621 goto clear_intr;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300622 }
623 /*
624 * if one field is just being captured configure
625 * the next frame get the next frame from the empty
626 * queue if no frame is available hold on to the
627 * current buffer
628 */
629 spin_lock(&vpfe_dev->dma_queue_lock);
630 if (!list_empty(&vpfe_dev->dma_queue) &&
631 vpfe_dev->cur_frm == vpfe_dev->next_frm)
632 vpfe_schedule_next_buffer(vpfe_dev);
633 spin_unlock(&vpfe_dev->dma_queue_lock);
634 } else if (fid == 0) {
635 /*
636 * out of sync. Recover from any hardware out-of-sync.
637 * May loose one frame
638 */
639 vpfe_dev->field_id = fid;
640 }
Vaibhav Hiremath085b54a2010-03-27 09:37:07 -0300641clear_intr:
642 if (vpfe_dev->cfg->clr_intr)
643 vpfe_dev->cfg->clr_intr(irq);
644
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300645 return IRQ_HANDLED;
646}
647
648/* vdint1_isr - isr handler for VINT1 interrupt */
649static irqreturn_t vdint1_isr(int irq, void *dev_id)
650{
651 struct vpfe_device *vpfe_dev = dev_id;
652
653 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "\nInside vdint1_isr...\n");
654
655 /* if streaming not started, don't do anything */
Vaibhav Hiremath085b54a2010-03-27 09:37:07 -0300656 if (!vpfe_dev->started) {
657 if (vpfe_dev->cfg->clr_intr)
658 vpfe_dev->cfg->clr_intr(irq);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300659 return IRQ_HANDLED;
Vaibhav Hiremath085b54a2010-03-27 09:37:07 -0300660 }
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300661
662 spin_lock(&vpfe_dev->dma_queue_lock);
663 if ((vpfe_dev->fmt.fmt.pix.field == V4L2_FIELD_NONE) &&
664 !list_empty(&vpfe_dev->dma_queue) &&
665 vpfe_dev->cur_frm == vpfe_dev->next_frm)
666 vpfe_schedule_next_buffer(vpfe_dev);
667 spin_unlock(&vpfe_dev->dma_queue_lock);
Vaibhav Hiremath085b54a2010-03-27 09:37:07 -0300668
669 if (vpfe_dev->cfg->clr_intr)
670 vpfe_dev->cfg->clr_intr(irq);
671
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300672 return IRQ_HANDLED;
673}
674
675static void vpfe_detach_irq(struct vpfe_device *vpfe_dev)
676{
677 enum ccdc_frmfmt frame_format;
678
679 frame_format = ccdc_dev->hw_ops.get_frame_format();
680 if (frame_format == CCDC_FRMFMT_PROGRESSIVE)
Vaibhav Hiremath1ead6962009-11-09 09:15:07 -0300681 free_irq(vpfe_dev->ccdc_irq1, vpfe_dev);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300682}
683
684static int vpfe_attach_irq(struct vpfe_device *vpfe_dev)
685{
686 enum ccdc_frmfmt frame_format;
687
688 frame_format = ccdc_dev->hw_ops.get_frame_format();
689 if (frame_format == CCDC_FRMFMT_PROGRESSIVE) {
690 return request_irq(vpfe_dev->ccdc_irq1, vdint1_isr,
Michael Opdenackerd8c279a2013-09-08 23:30:11 -0300691 0, "vpfe_capture1",
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300692 vpfe_dev);
693 }
694 return 0;
695}
696
697/* vpfe_stop_ccdc_capture: stop streaming in ccdc/isif */
698static void vpfe_stop_ccdc_capture(struct vpfe_device *vpfe_dev)
699{
700 vpfe_dev->started = 0;
701 ccdc_dev->hw_ops.enable(0);
702 if (ccdc_dev->hw_ops.enable_out_to_sdram)
703 ccdc_dev->hw_ops.enable_out_to_sdram(0);
704}
705
706/*
707 * vpfe_release : This function deletes buffer queue, frees the
708 * buffers and the vpfe file handle
709 */
710static int vpfe_release(struct file *file)
711{
712 struct vpfe_device *vpfe_dev = video_drvdata(file);
713 struct vpfe_fh *fh = file->private_data;
714 struct vpfe_subdev_info *sdinfo;
715 int ret;
716
717 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_release\n");
718
719 /* Get the device lock */
720 mutex_lock(&vpfe_dev->lock);
721 /* if this instance is doing IO */
722 if (fh->io_allowed) {
723 if (vpfe_dev->started) {
724 sdinfo = vpfe_dev->current_subdev;
725 ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev,
726 sdinfo->grp_id,
727 video, s_stream, 0);
728 if (ret && (ret != -ENOIOCTLCMD))
729 v4l2_err(&vpfe_dev->v4l2_dev,
730 "stream off failed in subdev\n");
731 vpfe_stop_ccdc_capture(vpfe_dev);
732 vpfe_detach_irq(vpfe_dev);
733 videobuf_streamoff(&vpfe_dev->buffer_queue);
734 }
735 vpfe_dev->io_usrs = 0;
736 vpfe_dev->numbuffers = config_params.numbuffers;
Lad, Prabhakarc1d1e402014-03-23 02:44:11 -0300737 videobuf_stop(&vpfe_dev->buffer_queue);
738 videobuf_mmap_free(&vpfe_dev->buffer_queue);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300739 }
740
741 /* Decrement device usrs counter */
742 vpfe_dev->usrs--;
Lad, Prabhakar3bdaa382014-03-22 08:39:24 -0300743 v4l2_fh_del(&fh->fh);
744 v4l2_fh_exit(&fh->fh);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300745 /* If this is the last file handle */
746 if (!vpfe_dev->usrs) {
747 vpfe_dev->initialized = 0;
748 if (ccdc_dev->hw_ops.close)
749 ccdc_dev->hw_ops.close(vpfe_dev->pdev);
750 module_put(ccdc_dev->owner);
751 }
752 mutex_unlock(&vpfe_dev->lock);
753 file->private_data = NULL;
754 /* Free memory allocated to file handle object */
755 kfree(fh);
756 return 0;
757}
758
759/*
760 * vpfe_mmap : It is used to map kernel space buffers
761 * into user spaces
762 */
763static int vpfe_mmap(struct file *file, struct vm_area_struct *vma)
764{
765 /* Get the device object and file handle object */
766 struct vpfe_device *vpfe_dev = video_drvdata(file);
767
768 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_mmap\n");
769
770 return videobuf_mmap_mapper(&vpfe_dev->buffer_queue, vma);
771}
772
773/*
774 * vpfe_poll: It is used for select/poll system call
775 */
776static unsigned int vpfe_poll(struct file *file, poll_table *wait)
777{
778 struct vpfe_device *vpfe_dev = video_drvdata(file);
779
780 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_poll\n");
781
782 if (vpfe_dev->started)
783 return videobuf_poll_stream(file,
784 &vpfe_dev->buffer_queue, wait);
785 return 0;
786}
787
788/* vpfe capture driver file operations */
789static const struct v4l2_file_operations vpfe_fops = {
790 .owner = THIS_MODULE,
791 .open = vpfe_open,
792 .release = vpfe_release,
793 .unlocked_ioctl = video_ioctl2,
794 .mmap = vpfe_mmap,
795 .poll = vpfe_poll
796};
797
798/*
799 * vpfe_check_format()
800 * This function adjust the input pixel format as per hardware
801 * capabilities and update the same in pixfmt.
802 * Following algorithm used :-
803 *
804 * If given pixformat is not in the vpfe list of pix formats or not
805 * supported by the hardware, current value of pixformat in the device
806 * is used
807 * If given field is not supported, then current field is used. If field
808 * is different from current, then it is matched with that from sub device.
809 * Minimum height is 2 lines for interlaced or tb field and 1 line for
810 * progressive. Maximum height is clamped to active active lines of scan
811 * Minimum width is 32 bytes in memory and width is clamped to active
812 * pixels of scan.
813 * bytesperline is a multiple of 32.
814 */
815static const struct vpfe_pixel_format *
816 vpfe_check_format(struct vpfe_device *vpfe_dev,
817 struct v4l2_pix_format *pixfmt)
818{
819 u32 min_height = 1, min_width = 32, max_width, max_height;
820 const struct vpfe_pixel_format *vpfe_pix_fmt;
821 u32 pix;
822 int temp, found;
823
824 vpfe_pix_fmt = vpfe_lookup_pix_format(pixfmt->pixelformat);
825 if (NULL == vpfe_pix_fmt) {
826 /*
827 * use current pixel format in the vpfe device. We
828 * will find this pix format in the table
829 */
830 pixfmt->pixelformat = vpfe_dev->fmt.fmt.pix.pixelformat;
831 vpfe_pix_fmt = vpfe_lookup_pix_format(pixfmt->pixelformat);
832 }
833
834 /* check if hw supports it */
835 temp = 0;
836 found = 0;
837 while (ccdc_dev->hw_ops.enum_pix(&pix, temp) >= 0) {
838 if (vpfe_pix_fmt->fmtdesc.pixelformat == pix) {
839 found = 1;
840 break;
841 }
842 temp++;
843 }
844
845 if (!found) {
846 /* use current pixel format */
847 pixfmt->pixelformat = vpfe_dev->fmt.fmt.pix.pixelformat;
848 /*
849 * Since this is currently used in the vpfe device, we
850 * will find this pix format in the table
851 */
852 vpfe_pix_fmt = vpfe_lookup_pix_format(pixfmt->pixelformat);
853 }
854
855 /* check what field format is supported */
856 if (pixfmt->field == V4L2_FIELD_ANY) {
857 /* if field is any, use current value as default */
858 pixfmt->field = vpfe_dev->fmt.fmt.pix.field;
859 }
860
861 /*
862 * if field is not same as current field in the vpfe device
863 * try matching the field with the sub device field
864 */
865 if (vpfe_dev->fmt.fmt.pix.field != pixfmt->field) {
866 /*
867 * If field value is not in the supported fields, use current
868 * field used in the device as default
869 */
870 switch (pixfmt->field) {
871 case V4L2_FIELD_INTERLACED:
872 case V4L2_FIELD_SEQ_TB:
873 /* if sub device is supporting progressive, use that */
874 if (!vpfe_dev->std_info.frame_format)
875 pixfmt->field = V4L2_FIELD_NONE;
876 break;
877 case V4L2_FIELD_NONE:
878 if (vpfe_dev->std_info.frame_format)
879 pixfmt->field = V4L2_FIELD_INTERLACED;
880 break;
881
882 default:
883 /* use current field as default */
884 pixfmt->field = vpfe_dev->fmt.fmt.pix.field;
885 break;
886 }
887 }
888
889 /* Now adjust image resolutions supported */
890 if (pixfmt->field == V4L2_FIELD_INTERLACED ||
891 pixfmt->field == V4L2_FIELD_SEQ_TB)
892 min_height = 2;
893
894 max_width = vpfe_dev->std_info.active_pixels;
895 max_height = vpfe_dev->std_info.active_lines;
896 min_width /= vpfe_pix_fmt->bpp;
897
898 v4l2_info(&vpfe_dev->v4l2_dev, "width = %d, height = %d, bpp = %d\n",
899 pixfmt->width, pixfmt->height, vpfe_pix_fmt->bpp);
900
901 pixfmt->width = clamp((pixfmt->width), min_width, max_width);
902 pixfmt->height = clamp((pixfmt->height), min_height, max_height);
903
904 /* If interlaced, adjust height to be a multiple of 2 */
905 if (pixfmt->field == V4L2_FIELD_INTERLACED)
906 pixfmt->height &= (~1);
907 /*
908 * recalculate bytesperline and sizeimage since width
909 * and height might have changed
910 */
911 pixfmt->bytesperline = (((pixfmt->width * vpfe_pix_fmt->bpp) + 31)
912 & ~31);
913 if (pixfmt->pixelformat == V4L2_PIX_FMT_NV12)
914 pixfmt->sizeimage =
915 pixfmt->bytesperline * pixfmt->height +
916 ((pixfmt->bytesperline * pixfmt->height) >> 1);
917 else
918 pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
919
920 v4l2_info(&vpfe_dev->v4l2_dev, "adjusted width = %d, height ="
921 " %d, bpp = %d, bytesperline = %d, sizeimage = %d\n",
922 pixfmt->width, pixfmt->height, vpfe_pix_fmt->bpp,
923 pixfmt->bytesperline, pixfmt->sizeimage);
924 return vpfe_pix_fmt;
925}
926
927static int vpfe_querycap(struct file *file, void *priv,
928 struct v4l2_capability *cap)
929{
930 struct vpfe_device *vpfe_dev = video_drvdata(file);
931
932 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querycap\n");
933
934 cap->version = VPFE_CAPTURE_VERSION_CODE;
935 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
936 strlcpy(cap->driver, CAPTURE_DRV_NAME, sizeof(cap->driver));
937 strlcpy(cap->bus_info, "VPFE", sizeof(cap->bus_info));
938 strlcpy(cap->card, vpfe_dev->cfg->card_name, sizeof(cap->card));
939 return 0;
940}
941
942static int vpfe_g_fmt_vid_cap(struct file *file, void *priv,
943 struct v4l2_format *fmt)
944{
945 struct vpfe_device *vpfe_dev = video_drvdata(file);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300946
947 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_fmt_vid_cap\n");
948 /* Fill in the information about format */
949 *fmt = vpfe_dev->fmt;
Mauro Carvalho Chehabb80cefb2014-09-03 15:39:46 -0300950 return 0;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -0300951}
952
953static int vpfe_enum_fmt_vid_cap(struct file *file, void *priv,
954 struct v4l2_fmtdesc *fmt)
955{
956 struct vpfe_device *vpfe_dev = video_drvdata(file);
957 const struct vpfe_pixel_format *pix_fmt;
958 int temp_index;
959 u32 pix;
960
961 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_enum_fmt_vid_cap\n");
962
963 if (ccdc_dev->hw_ops.enum_pix(&pix, fmt->index) < 0)
964 return -EINVAL;
965
966 /* Fill in the information about format */
967 pix_fmt = vpfe_lookup_pix_format(pix);
968 if (NULL != pix_fmt) {
969 temp_index = fmt->index;
970 *fmt = pix_fmt->fmtdesc;
971 fmt->index = temp_index;
972 return 0;
973 }
974 return -EINVAL;
975}
976
977static int vpfe_s_fmt_vid_cap(struct file *file, void *priv,
978 struct v4l2_format *fmt)
979{
980 struct vpfe_device *vpfe_dev = video_drvdata(file);
981 const struct vpfe_pixel_format *pix_fmts;
982 int ret = 0;
983
984 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_fmt_vid_cap\n");
985
986 /* If streaming is started, return error */
987 if (vpfe_dev->started) {
988 v4l2_err(&vpfe_dev->v4l2_dev, "Streaming is started\n");
989 return -EBUSY;
990 }
991
992 /* Check for valid frame format */
993 pix_fmts = vpfe_check_format(vpfe_dev, &fmt->fmt.pix);
994
995 if (NULL == pix_fmts)
996 return -EINVAL;
997
998 /* store the pixel format in the device object */
999 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1000 if (ret)
1001 return ret;
1002
1003 /* First detach any IRQ if currently attached */
1004 vpfe_detach_irq(vpfe_dev);
1005 vpfe_dev->fmt = *fmt;
1006 /* set image capture parameters in the ccdc */
1007 ret = vpfe_config_ccdc_image_format(vpfe_dev);
1008 mutex_unlock(&vpfe_dev->lock);
1009 return ret;
1010}
1011
1012static int vpfe_try_fmt_vid_cap(struct file *file, void *priv,
1013 struct v4l2_format *f)
1014{
1015 struct vpfe_device *vpfe_dev = video_drvdata(file);
1016 const struct vpfe_pixel_format *pix_fmts;
1017
1018 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_try_fmt_vid_cap\n");
1019
1020 pix_fmts = vpfe_check_format(vpfe_dev, &f->fmt.pix);
1021 if (NULL == pix_fmts)
1022 return -EINVAL;
1023 return 0;
1024}
1025
1026/*
1027 * vpfe_get_subdev_input_index - Get subdev index and subdev input index for a
1028 * given app input index
1029 */
1030static int vpfe_get_subdev_input_index(struct vpfe_device *vpfe_dev,
1031 int *subdev_index,
1032 int *subdev_input_index,
1033 int app_input_index)
1034{
1035 struct vpfe_config *cfg = vpfe_dev->cfg;
1036 struct vpfe_subdev_info *sdinfo;
1037 int i, j = 0;
1038
1039 for (i = 0; i < cfg->num_subdevs; i++) {
1040 sdinfo = &cfg->sub_devs[i];
1041 if (app_input_index < (j + sdinfo->num_inputs)) {
1042 *subdev_index = i;
1043 *subdev_input_index = app_input_index - j;
1044 return 0;
1045 }
1046 j += sdinfo->num_inputs;
1047 }
1048 return -EINVAL;
1049}
1050
1051/*
1052 * vpfe_get_app_input - Get app input index for a given subdev input index
1053 * driver stores the input index of the current sub device and translate it
1054 * when application request the current input
1055 */
1056static int vpfe_get_app_input_index(struct vpfe_device *vpfe_dev,
1057 int *app_input_index)
1058{
1059 struct vpfe_config *cfg = vpfe_dev->cfg;
1060 struct vpfe_subdev_info *sdinfo;
1061 int i, j = 0;
1062
1063 for (i = 0; i < cfg->num_subdevs; i++) {
1064 sdinfo = &cfg->sub_devs[i];
1065 if (!strcmp(sdinfo->name, vpfe_dev->current_subdev->name)) {
1066 if (vpfe_dev->current_input >= sdinfo->num_inputs)
1067 return -1;
1068 *app_input_index = j + vpfe_dev->current_input;
1069 return 0;
1070 }
1071 j += sdinfo->num_inputs;
1072 }
1073 return -EINVAL;
1074}
1075
1076static int vpfe_enum_input(struct file *file, void *priv,
1077 struct v4l2_input *inp)
1078{
1079 struct vpfe_device *vpfe_dev = video_drvdata(file);
1080 struct vpfe_subdev_info *sdinfo;
1081 int subdev, index ;
1082
1083 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_enum_input\n");
1084
1085 if (vpfe_get_subdev_input_index(vpfe_dev,
1086 &subdev,
1087 &index,
1088 inp->index) < 0) {
1089 v4l2_err(&vpfe_dev->v4l2_dev, "input information not found"
1090 " for the subdev\n");
1091 return -EINVAL;
1092 }
1093 sdinfo = &vpfe_dev->cfg->sub_devs[subdev];
1094 memcpy(inp, &sdinfo->inputs[index], sizeof(struct v4l2_input));
1095 return 0;
1096}
1097
1098static int vpfe_g_input(struct file *file, void *priv, unsigned int *index)
1099{
1100 struct vpfe_device *vpfe_dev = video_drvdata(file);
1101
1102 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_input\n");
1103
1104 return vpfe_get_app_input_index(vpfe_dev, index);
1105}
1106
1107
1108static int vpfe_s_input(struct file *file, void *priv, unsigned int index)
1109{
1110 struct vpfe_device *vpfe_dev = video_drvdata(file);
Hans Verkuil6f55dba2013-03-04 05:48:43 -03001111 struct v4l2_subdev *sd;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001112 struct vpfe_subdev_info *sdinfo;
1113 int subdev_index, inp_index;
1114 struct vpfe_route *route;
1115 u32 input = 0, output = 0;
1116 int ret = -EINVAL;
1117
1118 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_input\n");
1119
1120 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1121 if (ret)
1122 return ret;
1123
1124 /*
1125 * If streaming is started return device busy
1126 * error
1127 */
1128 if (vpfe_dev->started) {
1129 v4l2_err(&vpfe_dev->v4l2_dev, "Streaming is on\n");
1130 ret = -EBUSY;
1131 goto unlock_out;
1132 }
Peter Senna Tschudin9a888ba2012-09-04 08:05:03 -03001133 ret = vpfe_get_subdev_input_index(vpfe_dev,
1134 &subdev_index,
1135 &inp_index,
1136 index);
1137 if (ret < 0) {
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001138 v4l2_err(&vpfe_dev->v4l2_dev, "invalid input index\n");
1139 goto unlock_out;
1140 }
1141
1142 sdinfo = &vpfe_dev->cfg->sub_devs[subdev_index];
Hans Verkuil6f55dba2013-03-04 05:48:43 -03001143 sd = vpfe_dev->sd[subdev_index];
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001144 route = &sdinfo->routes[inp_index];
1145 if (route && sdinfo->can_route) {
1146 input = route->input;
1147 output = route->output;
1148 }
1149
Hans Verkuil6f55dba2013-03-04 05:48:43 -03001150 if (sd)
1151 ret = v4l2_subdev_call(sd, video, s_routing, input, output, 0);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001152
1153 if (ret) {
1154 v4l2_err(&vpfe_dev->v4l2_dev,
1155 "vpfe_doioctl:error in setting input in decoder\n");
1156 ret = -EINVAL;
1157 goto unlock_out;
1158 }
1159 vpfe_dev->current_subdev = sdinfo;
Hans Verkuil6f55dba2013-03-04 05:48:43 -03001160 if (sd)
1161 vpfe_dev->v4l2_dev.ctrl_handler = sd->ctrl_handler;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001162 vpfe_dev->current_input = index;
1163 vpfe_dev->std_index = 0;
1164
1165 /* set the bus/interface parameter for the sub device in ccdc */
1166 ret = ccdc_dev->hw_ops.set_hw_if_params(&sdinfo->ccdc_if_params);
1167 if (ret)
1168 goto unlock_out;
1169
1170 /* set the default image parameters in the device */
1171 ret = vpfe_config_image_format(vpfe_dev,
Hans Verkuil314527a2013-03-15 06:10:40 -03001172 vpfe_standards[vpfe_dev->std_index].std_id);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001173unlock_out:
1174 mutex_unlock(&vpfe_dev->lock);
1175 return ret;
1176}
1177
1178static int vpfe_querystd(struct file *file, void *priv, v4l2_std_id *std_id)
1179{
1180 struct vpfe_device *vpfe_dev = video_drvdata(file);
1181 struct vpfe_subdev_info *sdinfo;
1182 int ret = 0;
1183
1184 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querystd\n");
1185
1186 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1187 sdinfo = vpfe_dev->current_subdev;
1188 if (ret)
1189 return ret;
1190 /* Call querystd function of decoder device */
1191 ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev, sdinfo->grp_id,
1192 video, querystd, std_id);
1193 mutex_unlock(&vpfe_dev->lock);
1194 return ret;
1195}
1196
Hans Verkuil314527a2013-03-15 06:10:40 -03001197static int vpfe_s_std(struct file *file, void *priv, v4l2_std_id std_id)
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001198{
1199 struct vpfe_device *vpfe_dev = video_drvdata(file);
1200 struct vpfe_subdev_info *sdinfo;
1201 int ret = 0;
1202
1203 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_std\n");
1204
1205 /* Call decoder driver function to set the standard */
1206 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1207 if (ret)
1208 return ret;
1209
1210 sdinfo = vpfe_dev->current_subdev;
1211 /* If streaming is started, return device busy error */
1212 if (vpfe_dev->started) {
1213 v4l2_err(&vpfe_dev->v4l2_dev, "streaming is started\n");
1214 ret = -EBUSY;
1215 goto unlock_out;
1216 }
1217
1218 ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev, sdinfo->grp_id,
Laurent Pinchart8774bed2014-04-28 16:53:01 -03001219 video, s_std, std_id);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001220 if (ret < 0) {
1221 v4l2_err(&vpfe_dev->v4l2_dev, "Failed to set standard\n");
1222 goto unlock_out;
1223 }
1224 ret = vpfe_config_image_format(vpfe_dev, std_id);
1225
1226unlock_out:
1227 mutex_unlock(&vpfe_dev->lock);
1228 return ret;
1229}
1230
1231static int vpfe_g_std(struct file *file, void *priv, v4l2_std_id *std_id)
1232{
1233 struct vpfe_device *vpfe_dev = video_drvdata(file);
1234
1235 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_std\n");
1236
1237 *std_id = vpfe_standards[vpfe_dev->std_index].std_id;
1238 return 0;
1239}
1240/*
1241 * Videobuf operations
1242 */
1243static int vpfe_videobuf_setup(struct videobuf_queue *vq,
1244 unsigned int *count,
1245 unsigned int *size)
1246{
1247 struct vpfe_fh *fh = vq->priv_data;
1248 struct vpfe_device *vpfe_dev = fh->vpfe_dev;
1249
1250 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_buffer_setup\n");
Vaibhav Hiremath844cc0d2010-03-27 09:37:23 -03001251 *size = vpfe_dev->fmt.fmt.pix.sizeimage;
1252 if (vpfe_dev->memory == V4L2_MEMORY_MMAP &&
1253 vpfe_dev->fmt.fmt.pix.sizeimage > config_params.device_bufsize)
1254 *size = config_params.device_bufsize;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001255
1256 if (*count < config_params.min_numbuffers)
1257 *count = config_params.min_numbuffers;
1258 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1259 "count=%d, size=%d\n", *count, *size);
1260 return 0;
1261}
1262
1263static int vpfe_videobuf_prepare(struct videobuf_queue *vq,
1264 struct videobuf_buffer *vb,
1265 enum v4l2_field field)
1266{
1267 struct vpfe_fh *fh = vq->priv_data;
1268 struct vpfe_device *vpfe_dev = fh->vpfe_dev;
Vaibhav Hiremath844cc0d2010-03-27 09:37:23 -03001269 unsigned long addr;
1270 int ret;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001271
1272 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_buffer_prepare\n");
1273
1274 /* If buffer is not initialized, initialize it */
1275 if (VIDEOBUF_NEEDS_INIT == vb->state) {
1276 vb->width = vpfe_dev->fmt.fmt.pix.width;
1277 vb->height = vpfe_dev->fmt.fmt.pix.height;
1278 vb->size = vpfe_dev->fmt.fmt.pix.sizeimage;
1279 vb->field = field;
Vaibhav Hiremath844cc0d2010-03-27 09:37:23 -03001280
Joe Perchesb1dc6142010-11-15 00:04:28 -03001281 ret = videobuf_iolock(vq, vb, NULL);
Vaibhav Hiremath844cc0d2010-03-27 09:37:23 -03001282 if (ret < 0)
1283 return ret;
1284
1285 addr = videobuf_to_dma_contig(vb);
1286 /* Make sure user addresses are aligned to 32 bytes */
1287 if (!ALIGN(addr, 32))
1288 return -EINVAL;
1289
1290 vb->state = VIDEOBUF_PREPARED;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001291 }
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001292 return 0;
1293}
1294
1295static void vpfe_videobuf_queue(struct videobuf_queue *vq,
1296 struct videobuf_buffer *vb)
1297{
1298 /* Get the file handle object and device object */
1299 struct vpfe_fh *fh = vq->priv_data;
1300 struct vpfe_device *vpfe_dev = fh->vpfe_dev;
1301 unsigned long flags;
1302
1303 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_buffer_queue\n");
1304
1305 /* add the buffer to the DMA queue */
1306 spin_lock_irqsave(&vpfe_dev->dma_queue_lock, flags);
1307 list_add_tail(&vb->queue, &vpfe_dev->dma_queue);
1308 spin_unlock_irqrestore(&vpfe_dev->dma_queue_lock, flags);
1309
1310 /* Change state of the buffer */
1311 vb->state = VIDEOBUF_QUEUED;
1312}
1313
1314static void vpfe_videobuf_release(struct videobuf_queue *vq,
1315 struct videobuf_buffer *vb)
1316{
1317 struct vpfe_fh *fh = vq->priv_data;
1318 struct vpfe_device *vpfe_dev = fh->vpfe_dev;
1319 unsigned long flags;
1320
1321 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_videobuf_release\n");
1322
1323 /*
1324 * We need to flush the buffer from the dma queue since
1325 * they are de-allocated
1326 */
1327 spin_lock_irqsave(&vpfe_dev->dma_queue_lock, flags);
1328 INIT_LIST_HEAD(&vpfe_dev->dma_queue);
1329 spin_unlock_irqrestore(&vpfe_dev->dma_queue_lock, flags);
1330 videobuf_dma_contig_free(vq, vb);
1331 vb->state = VIDEOBUF_NEEDS_INIT;
1332}
1333
1334static struct videobuf_queue_ops vpfe_videobuf_qops = {
1335 .buf_setup = vpfe_videobuf_setup,
1336 .buf_prepare = vpfe_videobuf_prepare,
1337 .buf_queue = vpfe_videobuf_queue,
1338 .buf_release = vpfe_videobuf_release,
1339};
1340
1341/*
1342 * vpfe_reqbufs. currently support REQBUF only once opening
1343 * the device.
1344 */
1345static int vpfe_reqbufs(struct file *file, void *priv,
1346 struct v4l2_requestbuffers *req_buf)
1347{
1348 struct vpfe_device *vpfe_dev = video_drvdata(file);
1349 struct vpfe_fh *fh = file->private_data;
1350 int ret = 0;
1351
1352 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_reqbufs\n");
1353
1354 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != req_buf->type) {
1355 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buffer type\n");
1356 return -EINVAL;
1357 }
1358
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001359 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1360 if (ret)
1361 return ret;
1362
1363 if (vpfe_dev->io_usrs != 0) {
1364 v4l2_err(&vpfe_dev->v4l2_dev, "Only one IO user allowed\n");
1365 ret = -EBUSY;
1366 goto unlock_out;
1367 }
1368
1369 vpfe_dev->memory = req_buf->memory;
1370 videobuf_queue_dma_contig_init(&vpfe_dev->buffer_queue,
1371 &vpfe_videobuf_qops,
Vaibhav Hiremath204e6ea2009-11-09 09:07:36 -03001372 vpfe_dev->pdev,
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001373 &vpfe_dev->irqlock,
1374 req_buf->type,
1375 vpfe_dev->fmt.fmt.pix.field,
1376 sizeof(struct videobuf_buffer),
Hans Verkuile3cfd442010-09-30 09:18:52 -03001377 fh, NULL);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001378
1379 fh->io_allowed = 1;
1380 vpfe_dev->io_usrs = 1;
1381 INIT_LIST_HEAD(&vpfe_dev->dma_queue);
1382 ret = videobuf_reqbufs(&vpfe_dev->buffer_queue, req_buf);
1383unlock_out:
1384 mutex_unlock(&vpfe_dev->lock);
1385 return ret;
1386}
1387
1388static int vpfe_querybuf(struct file *file, void *priv,
1389 struct v4l2_buffer *buf)
1390{
1391 struct vpfe_device *vpfe_dev = video_drvdata(file);
1392
1393 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querybuf\n");
1394
1395 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != buf->type) {
1396 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n");
1397 return -EINVAL;
1398 }
1399
1400 if (vpfe_dev->memory != V4L2_MEMORY_MMAP) {
1401 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid memory\n");
1402 return -EINVAL;
1403 }
1404 /* Call videobuf_querybuf to get information */
1405 return videobuf_querybuf(&vpfe_dev->buffer_queue, buf);
1406}
1407
1408static int vpfe_qbuf(struct file *file, void *priv,
1409 struct v4l2_buffer *p)
1410{
1411 struct vpfe_device *vpfe_dev = video_drvdata(file);
1412 struct vpfe_fh *fh = file->private_data;
1413
1414 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_qbuf\n");
1415
1416 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != p->type) {
1417 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n");
1418 return -EINVAL;
1419 }
1420
1421 /*
1422 * If this file handle is not allowed to do IO,
1423 * return error
1424 */
1425 if (!fh->io_allowed) {
1426 v4l2_err(&vpfe_dev->v4l2_dev, "fh->io_allowed\n");
1427 return -EACCES;
1428 }
1429 return videobuf_qbuf(&vpfe_dev->buffer_queue, p);
1430}
1431
1432static int vpfe_dqbuf(struct file *file, void *priv,
1433 struct v4l2_buffer *buf)
1434{
1435 struct vpfe_device *vpfe_dev = video_drvdata(file);
1436
1437 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_dqbuf\n");
1438
1439 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != buf->type) {
1440 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n");
1441 return -EINVAL;
1442 }
1443 return videobuf_dqbuf(&vpfe_dev->buffer_queue,
1444 buf, file->f_flags & O_NONBLOCK);
1445}
1446
1447/*
1448 * vpfe_calculate_offsets : This function calculates buffers offset
1449 * for top and bottom field
1450 */
1451static void vpfe_calculate_offsets(struct vpfe_device *vpfe_dev)
1452{
1453 struct v4l2_rect image_win;
1454
1455 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_calculate_offsets\n");
1456
1457 ccdc_dev->hw_ops.get_image_window(&image_win);
1458 vpfe_dev->field_off = image_win.height * image_win.width;
1459}
1460
1461/* vpfe_start_ccdc_capture: start streaming in ccdc/isif */
1462static void vpfe_start_ccdc_capture(struct vpfe_device *vpfe_dev)
1463{
1464 ccdc_dev->hw_ops.enable(1);
1465 if (ccdc_dev->hw_ops.enable_out_to_sdram)
1466 ccdc_dev->hw_ops.enable_out_to_sdram(1);
1467 vpfe_dev->started = 1;
1468}
1469
1470/*
1471 * vpfe_streamon. Assume the DMA queue is not empty.
1472 * application is expected to call QBUF before calling
1473 * this ioctl. If not, driver returns error
1474 */
1475static int vpfe_streamon(struct file *file, void *priv,
1476 enum v4l2_buf_type buf_type)
1477{
1478 struct vpfe_device *vpfe_dev = video_drvdata(file);
1479 struct vpfe_fh *fh = file->private_data;
1480 struct vpfe_subdev_info *sdinfo;
1481 unsigned long addr;
1482 int ret = 0;
1483
1484 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_streamon\n");
1485
1486 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != buf_type) {
1487 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n");
1488 return -EINVAL;
1489 }
1490
1491 /* If file handle is not allowed IO, return error */
1492 if (!fh->io_allowed) {
1493 v4l2_err(&vpfe_dev->v4l2_dev, "fh->io_allowed\n");
1494 return -EACCES;
1495 }
1496
1497 sdinfo = vpfe_dev->current_subdev;
1498 ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev, sdinfo->grp_id,
1499 video, s_stream, 1);
1500
1501 if (ret && (ret != -ENOIOCTLCMD)) {
1502 v4l2_err(&vpfe_dev->v4l2_dev, "stream on failed in subdev\n");
1503 return -EINVAL;
1504 }
1505
1506 /* If buffer queue is empty, return error */
1507 if (list_empty(&vpfe_dev->buffer_queue.stream)) {
1508 v4l2_err(&vpfe_dev->v4l2_dev, "buffer queue is empty\n");
1509 return -EIO;
1510 }
1511
1512 /* Call videobuf_streamon to start streaming * in videobuf */
1513 ret = videobuf_streamon(&vpfe_dev->buffer_queue);
1514 if (ret)
1515 return ret;
1516
1517
1518 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1519 if (ret)
1520 goto streamoff;
1521 /* Get the next frame from the buffer queue */
1522 vpfe_dev->next_frm = list_entry(vpfe_dev->dma_queue.next,
1523 struct videobuf_buffer, queue);
1524 vpfe_dev->cur_frm = vpfe_dev->next_frm;
1525 /* Remove buffer from the buffer queue */
1526 list_del(&vpfe_dev->cur_frm->queue);
1527 /* Mark state of the current frame to active */
1528 vpfe_dev->cur_frm->state = VIDEOBUF_ACTIVE;
1529 /* Initialize field_id and started member */
1530 vpfe_dev->field_id = 0;
1531 addr = videobuf_to_dma_contig(vpfe_dev->cur_frm);
1532
1533 /* Calculate field offset */
1534 vpfe_calculate_offsets(vpfe_dev);
1535
1536 if (vpfe_attach_irq(vpfe_dev) < 0) {
1537 v4l2_err(&vpfe_dev->v4l2_dev,
1538 "Error in attaching interrupt handle\n");
1539 ret = -EFAULT;
1540 goto unlock_out;
1541 }
1542 if (ccdc_dev->hw_ops.configure() < 0) {
1543 v4l2_err(&vpfe_dev->v4l2_dev,
1544 "Error in configuring ccdc\n");
1545 ret = -EINVAL;
1546 goto unlock_out;
1547 }
1548 ccdc_dev->hw_ops.setfbaddr((unsigned long)(addr));
1549 vpfe_start_ccdc_capture(vpfe_dev);
1550 mutex_unlock(&vpfe_dev->lock);
1551 return ret;
1552unlock_out:
1553 mutex_unlock(&vpfe_dev->lock);
1554streamoff:
1555 ret = videobuf_streamoff(&vpfe_dev->buffer_queue);
1556 return ret;
1557}
1558
1559static int vpfe_streamoff(struct file *file, void *priv,
1560 enum v4l2_buf_type buf_type)
1561{
1562 struct vpfe_device *vpfe_dev = video_drvdata(file);
1563 struct vpfe_fh *fh = file->private_data;
1564 struct vpfe_subdev_info *sdinfo;
1565 int ret = 0;
1566
1567 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_streamoff\n");
1568
1569 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != buf_type) {
1570 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n");
1571 return -EINVAL;
1572 }
1573
1574 /* If io is allowed for this file handle, return error */
1575 if (!fh->io_allowed) {
1576 v4l2_err(&vpfe_dev->v4l2_dev, "fh->io_allowed\n");
1577 return -EACCES;
1578 }
1579
1580 /* If streaming is not started, return error */
1581 if (!vpfe_dev->started) {
1582 v4l2_err(&vpfe_dev->v4l2_dev, "device started\n");
1583 return -EINVAL;
1584 }
1585
1586 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1587 if (ret)
1588 return ret;
1589
1590 vpfe_stop_ccdc_capture(vpfe_dev);
1591 vpfe_detach_irq(vpfe_dev);
1592
1593 sdinfo = vpfe_dev->current_subdev;
1594 ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev, sdinfo->grp_id,
1595 video, s_stream, 0);
1596
1597 if (ret && (ret != -ENOIOCTLCMD))
1598 v4l2_err(&vpfe_dev->v4l2_dev, "stream off failed in subdev\n");
1599 ret = videobuf_streamoff(&vpfe_dev->buffer_queue);
1600 mutex_unlock(&vpfe_dev->lock);
1601 return ret;
1602}
1603
1604static int vpfe_cropcap(struct file *file, void *priv,
1605 struct v4l2_cropcap *crop)
1606{
1607 struct vpfe_device *vpfe_dev = video_drvdata(file);
1608
1609 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_cropcap\n");
1610
Roel Kluin0b66cf92009-11-04 14:16:25 -03001611 if (vpfe_dev->std_index >= ARRAY_SIZE(vpfe_standards))
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001612 return -EINVAL;
1613
1614 memset(crop, 0, sizeof(struct v4l2_cropcap));
1615 crop->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1616 crop->bounds.width = crop->defrect.width =
1617 vpfe_standards[vpfe_dev->std_index].width;
1618 crop->bounds.height = crop->defrect.height =
1619 vpfe_standards[vpfe_dev->std_index].height;
1620 crop->pixelaspect = vpfe_standards[vpfe_dev->std_index].pixelaspect;
1621 return 0;
1622}
1623
1624static int vpfe_g_crop(struct file *file, void *priv,
1625 struct v4l2_crop *crop)
1626{
1627 struct vpfe_device *vpfe_dev = video_drvdata(file);
1628
1629 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_crop\n");
1630
1631 crop->c = vpfe_dev->crop;
1632 return 0;
1633}
1634
1635static int vpfe_s_crop(struct file *file, void *priv,
Hans Verkuil4f996592012-09-05 05:10:48 -03001636 const struct v4l2_crop *crop)
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001637{
1638 struct vpfe_device *vpfe_dev = video_drvdata(file);
Lad, Prabhakar8b6faac2012-10-01 08:52:48 -03001639 struct v4l2_rect rect = crop->c;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001640 int ret = 0;
1641
1642 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_crop\n");
1643
1644 if (vpfe_dev->started) {
1645 /* make sure streaming is not started */
1646 v4l2_err(&vpfe_dev->v4l2_dev,
1647 "Cannot change crop when streaming is ON\n");
1648 return -EBUSY;
1649 }
1650
1651 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1652 if (ret)
1653 return ret;
1654
Lad, Prabhakar8b6faac2012-10-01 08:52:48 -03001655 if (rect.top < 0 || rect.left < 0) {
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001656 v4l2_err(&vpfe_dev->v4l2_dev,
1657 "doesn't support negative values for top & left\n");
1658 ret = -EINVAL;
1659 goto unlock_out;
1660 }
1661
Lucas De Marchi25985ed2011-03-30 22:57:33 -03001662 /* adjust the width to 16 pixel boundary */
Lad, Prabhakar8b6faac2012-10-01 08:52:48 -03001663 rect.width = ((rect.width + 15) & ~0xf);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001664
1665 /* make sure parameters are valid */
Lad, Prabhakar8b6faac2012-10-01 08:52:48 -03001666 if ((rect.left + rect.width >
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001667 vpfe_dev->std_info.active_pixels) ||
Lad, Prabhakar8b6faac2012-10-01 08:52:48 -03001668 (rect.top + rect.height >
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001669 vpfe_dev->std_info.active_lines)) {
1670 v4l2_err(&vpfe_dev->v4l2_dev, "Error in S_CROP params\n");
1671 ret = -EINVAL;
1672 goto unlock_out;
1673 }
Lad, Prabhakar8b6faac2012-10-01 08:52:48 -03001674 ccdc_dev->hw_ops.set_image_window(&rect);
1675 vpfe_dev->fmt.fmt.pix.width = rect.width;
1676 vpfe_dev->fmt.fmt.pix.height = rect.height;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001677 vpfe_dev->fmt.fmt.pix.bytesperline =
1678 ccdc_dev->hw_ops.get_line_length();
1679 vpfe_dev->fmt.fmt.pix.sizeimage =
1680 vpfe_dev->fmt.fmt.pix.bytesperline *
1681 vpfe_dev->fmt.fmt.pix.height;
Lad, Prabhakar8b6faac2012-10-01 08:52:48 -03001682 vpfe_dev->crop = rect;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001683unlock_out:
1684 mutex_unlock(&vpfe_dev->lock);
1685 return ret;
1686}
1687
1688
1689static long vpfe_param_handler(struct file *file, void *priv,
Mauro Carvalho Chehab6d43be72013-03-26 08:04:52 -03001690 bool valid_prio, unsigned int cmd, void *param)
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001691{
1692 struct vpfe_device *vpfe_dev = video_drvdata(file);
1693 int ret = 0;
1694
Muralidharan Karicheri6a4f0622010-03-18 11:44:12 -03001695 v4l2_dbg(2, debug, &vpfe_dev->v4l2_dev, "vpfe_param_handler\n");
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001696
1697 if (vpfe_dev->started) {
1698 /* only allowed if streaming is not started */
Muralidharan Karicheri6a4f0622010-03-18 11:44:12 -03001699 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1700 "device already started\n");
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001701 return -EBUSY;
1702 }
1703
1704 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1705 if (ret)
1706 return ret;
1707
1708 switch (cmd) {
1709 case VPFE_CMD_S_CCDC_RAW_PARAMS:
1710 v4l2_warn(&vpfe_dev->v4l2_dev,
1711 "VPFE_CMD_S_CCDC_RAW_PARAMS: experimental ioctl\n");
Muralidharan Karicheri6a4f0622010-03-18 11:44:12 -03001712 if (ccdc_dev->hw_ops.set_params) {
1713 ret = ccdc_dev->hw_ops.set_params(param);
1714 if (ret) {
1715 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1716 "Error setting parameters in CCDC\n");
1717 goto unlock_out;
1718 }
Peter Senna Tschudin9a888ba2012-09-04 08:05:03 -03001719 ret = vpfe_get_ccdc_image_format(vpfe_dev,
1720 &vpfe_dev->fmt);
1721 if (ret < 0) {
Muralidharan Karicheri6a4f0622010-03-18 11:44:12 -03001722 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1723 "Invalid image format at CCDC\n");
1724 goto unlock_out;
1725 }
1726 } else {
1727 ret = -EINVAL;
1728 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1729 "VPFE_CMD_S_CCDC_RAW_PARAMS not supported\n");
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001730 }
1731 break;
1732 default:
Hans Verkuild1c754a2012-04-19 12:36:03 -03001733 ret = -ENOTTY;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001734 }
1735unlock_out:
1736 mutex_unlock(&vpfe_dev->lock);
1737 return ret;
1738}
1739
1740
1741/* vpfe capture ioctl operations */
1742static const struct v4l2_ioctl_ops vpfe_ioctl_ops = {
1743 .vidioc_querycap = vpfe_querycap,
1744 .vidioc_g_fmt_vid_cap = vpfe_g_fmt_vid_cap,
1745 .vidioc_enum_fmt_vid_cap = vpfe_enum_fmt_vid_cap,
1746 .vidioc_s_fmt_vid_cap = vpfe_s_fmt_vid_cap,
1747 .vidioc_try_fmt_vid_cap = vpfe_try_fmt_vid_cap,
1748 .vidioc_enum_input = vpfe_enum_input,
1749 .vidioc_g_input = vpfe_g_input,
1750 .vidioc_s_input = vpfe_s_input,
1751 .vidioc_querystd = vpfe_querystd,
1752 .vidioc_s_std = vpfe_s_std,
1753 .vidioc_g_std = vpfe_g_std,
1754 .vidioc_reqbufs = vpfe_reqbufs,
1755 .vidioc_querybuf = vpfe_querybuf,
1756 .vidioc_qbuf = vpfe_qbuf,
1757 .vidioc_dqbuf = vpfe_dqbuf,
1758 .vidioc_streamon = vpfe_streamon,
1759 .vidioc_streamoff = vpfe_streamoff,
1760 .vidioc_cropcap = vpfe_cropcap,
1761 .vidioc_g_crop = vpfe_g_crop,
1762 .vidioc_s_crop = vpfe_s_crop,
1763 .vidioc_default = vpfe_param_handler,
1764};
1765
1766static struct vpfe_device *vpfe_initialize(void)
1767{
1768 struct vpfe_device *vpfe_dev;
1769
1770 /* Default number of buffers should be 3 */
1771 if ((numbuffers > 0) &&
1772 (numbuffers < config_params.min_numbuffers))
1773 numbuffers = config_params.min_numbuffers;
1774
1775 /*
1776 * Set buffer size to min buffers size if invalid buffer size is
1777 * given
1778 */
1779 if (bufsize < config_params.min_bufsize)
1780 bufsize = config_params.min_bufsize;
1781
1782 config_params.numbuffers = numbuffers;
1783
1784 if (numbuffers)
1785 config_params.device_bufsize = bufsize;
1786
1787 /* Allocate memory for device objects */
1788 vpfe_dev = kzalloc(sizeof(*vpfe_dev), GFP_KERNEL);
1789
1790 return vpfe_dev;
1791}
1792
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001793/*
1794 * vpfe_probe : This function creates device entries by register
1795 * itself to the V4L2 driver and initializes fields of each
1796 * device objects
1797 */
Greg Kroah-Hartman4c62e972012-12-21 13:17:53 -08001798static int vpfe_probe(struct platform_device *pdev)
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001799{
1800 struct vpfe_subdev_info *sdinfo;
1801 struct vpfe_config *vpfe_cfg;
1802 struct resource *res1;
1803 struct vpfe_device *vpfe_dev;
1804 struct i2c_adapter *i2c_adap;
1805 struct video_device *vfd;
1806 int ret = -ENOMEM, i, j;
1807 int num_subdevs = 0;
1808
1809 /* Get the pointer to the device object */
1810 vpfe_dev = vpfe_initialize();
1811
1812 if (!vpfe_dev) {
1813 v4l2_err(pdev->dev.driver,
1814 "Failed to allocate memory for vpfe_dev\n");
1815 return ret;
1816 }
1817
1818 vpfe_dev->pdev = &pdev->dev;
1819
1820 if (NULL == pdev->dev.platform_data) {
1821 v4l2_err(pdev->dev.driver, "Unable to get vpfe config\n");
Muralidharan Karicheri51444ea2010-01-13 20:27:05 -03001822 ret = -ENODEV;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001823 goto probe_free_dev_mem;
1824 }
1825
1826 vpfe_cfg = pdev->dev.platform_data;
1827 vpfe_dev->cfg = vpfe_cfg;
1828 if (NULL == vpfe_cfg->ccdc ||
1829 NULL == vpfe_cfg->card_name ||
1830 NULL == vpfe_cfg->sub_devs) {
1831 v4l2_err(pdev->dev.driver, "null ptr in vpfe_cfg\n");
1832 ret = -ENOENT;
1833 goto probe_free_dev_mem;
1834 }
1835
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001836 /* Allocate memory for ccdc configuration */
1837 ccdc_cfg = kmalloc(sizeof(struct ccdc_config), GFP_KERNEL);
1838 if (NULL == ccdc_cfg) {
1839 v4l2_err(pdev->dev.driver,
1840 "Memory allocation failed for ccdc_cfg\n");
Lad, Prabhakar39e219d2013-05-10 00:48:38 -03001841 goto probe_free_dev_mem;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001842 }
1843
Dan Carpenter2b080c52010-04-07 06:21:05 -03001844 mutex_lock(&ccdc_lock);
1845
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001846 strncpy(ccdc_cfg->name, vpfe_cfg->ccdc, 32);
1847 /* Get VINT0 irq resource */
1848 res1 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1849 if (!res1) {
1850 v4l2_err(pdev->dev.driver,
1851 "Unable to get interrupt for VINT0\n");
Muralidharan Karicheri51444ea2010-01-13 20:27:05 -03001852 ret = -ENODEV;
1853 goto probe_free_ccdc_cfg_mem;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001854 }
1855 vpfe_dev->ccdc_irq0 = res1->start;
1856
1857 /* Get VINT1 irq resource */
Muralidharan Karicheri51444ea2010-01-13 20:27:05 -03001858 res1 = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001859 if (!res1) {
1860 v4l2_err(pdev->dev.driver,
1861 "Unable to get interrupt for VINT1\n");
Muralidharan Karicheri51444ea2010-01-13 20:27:05 -03001862 ret = -ENODEV;
1863 goto probe_free_ccdc_cfg_mem;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001864 }
1865 vpfe_dev->ccdc_irq1 = res1->start;
1866
Michael Opdenackerd8c279a2013-09-08 23:30:11 -03001867 ret = request_irq(vpfe_dev->ccdc_irq0, vpfe_isr, 0,
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001868 "vpfe_capture0", vpfe_dev);
1869
1870 if (0 != ret) {
1871 v4l2_err(pdev->dev.driver, "Unable to request interrupt\n");
Muralidharan Karicheri51444ea2010-01-13 20:27:05 -03001872 goto probe_free_ccdc_cfg_mem;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001873 }
1874
1875 /* Allocate memory for video device */
1876 vfd = video_device_alloc();
1877 if (NULL == vfd) {
1878 ret = -ENOMEM;
Muralidharan Karicheri51444ea2010-01-13 20:27:05 -03001879 v4l2_err(pdev->dev.driver, "Unable to alloc video device\n");
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001880 goto probe_out_release_irq;
1881 }
1882
1883 /* Initialize field of video device */
1884 vfd->release = video_device_release;
1885 vfd->fops = &vpfe_fops;
1886 vfd->ioctl_ops = &vpfe_ioctl_ops;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001887 vfd->tvnorms = 0;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001888 vfd->v4l2_dev = &vpfe_dev->v4l2_dev;
1889 snprintf(vfd->name, sizeof(vfd->name),
1890 "%s_V%d.%d.%d",
1891 CAPTURE_DRV_NAME,
1892 (VPFE_CAPTURE_VERSION_CODE >> 16) & 0xff,
1893 (VPFE_CAPTURE_VERSION_CODE >> 8) & 0xff,
1894 (VPFE_CAPTURE_VERSION_CODE) & 0xff);
1895 /* Set video_dev to the video device */
1896 vpfe_dev->video_dev = vfd;
1897
1898 ret = v4l2_device_register(&pdev->dev, &vpfe_dev->v4l2_dev);
1899 if (ret) {
1900 v4l2_err(pdev->dev.driver,
1901 "Unable to register v4l2 device.\n");
1902 goto probe_out_video_release;
1903 }
1904 v4l2_info(&vpfe_dev->v4l2_dev, "v4l2 device registered\n");
1905 spin_lock_init(&vpfe_dev->irqlock);
1906 spin_lock_init(&vpfe_dev->dma_queue_lock);
1907 mutex_init(&vpfe_dev->lock);
1908
1909 /* Initialize field of the device objects */
1910 vpfe_dev->numbuffers = config_params.numbuffers;
1911
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001912 /* register video device */
1913 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1914 "trying to register vpfe device.\n");
1915 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
Mauro Carvalho Chehab212bdba2014-08-22 06:38:14 -05001916 "video_dev=%p\n", &vpfe_dev->video_dev);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001917 vpfe_dev->fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1918 ret = video_register_device(vpfe_dev->video_dev,
1919 VFL_TYPE_GRABBER, -1);
1920
1921 if (ret) {
1922 v4l2_err(pdev->dev.driver,
1923 "Unable to register video device.\n");
1924 goto probe_out_v4l2_unregister;
1925 }
1926
1927 v4l2_info(&vpfe_dev->v4l2_dev, "video device registered\n");
1928 /* set the driver data in platform device */
1929 platform_set_drvdata(pdev, vpfe_dev);
1930 /* set driver private data */
1931 video_set_drvdata(vpfe_dev->video_dev, vpfe_dev);
Vaibhav Hiremath14cbaaf2009-11-09 09:14:16 -03001932 i2c_adap = i2c_get_adapter(vpfe_cfg->i2c_adapter_id);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001933 num_subdevs = vpfe_cfg->num_subdevs;
1934 vpfe_dev->sd = kmalloc(sizeof(struct v4l2_subdev *) * num_subdevs,
1935 GFP_KERNEL);
1936 if (NULL == vpfe_dev->sd) {
1937 v4l2_err(&vpfe_dev->v4l2_dev,
1938 "unable to allocate memory for subdevice pointers\n");
1939 ret = -ENOMEM;
1940 goto probe_out_video_unregister;
1941 }
1942
1943 for (i = 0; i < num_subdevs; i++) {
1944 struct v4l2_input *inps;
1945
1946 sdinfo = &vpfe_cfg->sub_devs[i];
1947
1948 /* Load up the subdevice */
1949 vpfe_dev->sd[i] =
1950 v4l2_i2c_new_subdev_board(&vpfe_dev->v4l2_dev,
1951 i2c_adap,
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001952 &sdinfo->board_info,
1953 NULL);
1954 if (vpfe_dev->sd[i]) {
1955 v4l2_info(&vpfe_dev->v4l2_dev,
1956 "v4l2 sub device %s registered\n",
1957 sdinfo->name);
1958 vpfe_dev->sd[i]->grp_id = sdinfo->grp_id;
1959 /* update tvnorms from the sub devices */
1960 for (j = 0; j < sdinfo->num_inputs; j++) {
1961 inps = &sdinfo->inputs[j];
1962 vfd->tvnorms |= inps->std;
1963 }
1964 } else {
1965 v4l2_info(&vpfe_dev->v4l2_dev,
1966 "v4l2 sub device %s register fails\n",
1967 sdinfo->name);
1968 goto probe_sd_out;
1969 }
1970 }
1971
1972 /* set first sub device as current one */
1973 vpfe_dev->current_subdev = &vpfe_cfg->sub_devs[0];
Hans Verkuil6f55dba2013-03-04 05:48:43 -03001974 vpfe_dev->v4l2_dev.ctrl_handler = vpfe_dev->sd[0]->ctrl_handler;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001975
1976 /* We have at least one sub device to work with */
1977 mutex_unlock(&ccdc_lock);
1978 return 0;
1979
1980probe_sd_out:
1981 kfree(vpfe_dev->sd);
1982probe_out_video_unregister:
1983 video_unregister_device(vpfe_dev->video_dev);
1984probe_out_v4l2_unregister:
1985 v4l2_device_unregister(&vpfe_dev->v4l2_dev);
1986probe_out_video_release:
Laurent Pinchartf0813b42009-11-27 13:57:30 -03001987 if (!video_is_registered(vpfe_dev->video_dev))
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001988 video_device_release(vpfe_dev->video_dev);
1989probe_out_release_irq:
1990 free_irq(vpfe_dev->ccdc_irq0, vpfe_dev);
Muralidharan Karicheri51444ea2010-01-13 20:27:05 -03001991probe_free_ccdc_cfg_mem:
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001992 kfree(ccdc_cfg);
Murali Karicheriab51bec2010-03-01 19:54:02 -03001993 mutex_unlock(&ccdc_lock);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03001994probe_free_dev_mem:
1995 kfree(vpfe_dev);
1996 return ret;
1997}
1998
1999/*
2000 * vpfe_remove : It un-register device from V4L2 driver
2001 */
Greg Kroah-Hartman4c62e972012-12-21 13:17:53 -08002002static int vpfe_remove(struct platform_device *pdev)
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03002003{
2004 struct vpfe_device *vpfe_dev = platform_get_drvdata(pdev);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03002005
2006 v4l2_info(pdev->dev.driver, "vpfe_remove\n");
2007
2008 free_irq(vpfe_dev->ccdc_irq0, vpfe_dev);
2009 kfree(vpfe_dev->sd);
2010 v4l2_device_unregister(&vpfe_dev->v4l2_dev);
2011 video_unregister_device(vpfe_dev->video_dev);
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03002012 kfree(vpfe_dev);
2013 kfree(ccdc_cfg);
2014 return 0;
2015}
2016
Vaibhav Hiremathaa2dc902010-03-27 09:37:16 -03002017static int vpfe_suspend(struct device *dev)
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03002018{
Vaibhav Hiremathaa2dc902010-03-27 09:37:16 -03002019 return 0;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03002020}
2021
Vaibhav Hiremathaa2dc902010-03-27 09:37:16 -03002022static int vpfe_resume(struct device *dev)
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03002023{
Vaibhav Hiremathaa2dc902010-03-27 09:37:16 -03002024 return 0;
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03002025}
2026
Alexey Dobriyan47145212009-12-14 18:00:08 -08002027static const struct dev_pm_ops vpfe_dev_pm_ops = {
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03002028 .suspend = vpfe_suspend,
2029 .resume = vpfe_resume,
2030};
2031
Lad, Prabhakara1b3a6c2012-08-14 01:23:09 -03002032static struct platform_driver vpfe_driver = {
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03002033 .driver = {
2034 .name = CAPTURE_DRV_NAME,
2035 .owner = THIS_MODULE,
2036 .pm = &vpfe_dev_pm_ops,
2037 },
2038 .probe = vpfe_probe,
Greg Kroah-Hartman4c62e972012-12-21 13:17:53 -08002039 .remove = vpfe_remove,
Muralidharan Karicheri7da8a6c2009-07-06 15:04:12 -03002040};
2041
Axel Lin1d6629b2012-01-10 03:21:49 -03002042module_platform_driver(vpfe_driver);