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#include <linux/module.h>
70#include <linux/slab.h>
71#include <linux/init.h>
72#include <linux/platform_device.h>
73#include <linux/interrupt.h>
74#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
96struct vpfe_standard {
97 v4l2_std_id std_id;
98 unsigned int width;
99 unsigned int height;
100 struct v4l2_fract pixelaspect;
101
102 int frame_format;
103};
104
105
106struct ccdc_config {
107
108 int vpfe_probed;
109
110 char name[32];
111};
112
113
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
122static struct ccdc_hw_device *ccdc_dev;
123
124static DEFINE_MUTEX(ccdc_lock);
125
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
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
193
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
208
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);
226 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);
229 BUG_ON(!dev->hw_ops.getfid);
230
231 mutex_lock(&ccdc_lock);
232 if (NULL == ccdc_cfg) {
233
234
235
236
237
238 printk(KERN_ERR "vpfe capture not initialized\n");
239 ret = -EFAULT;
240 goto unlock;
241 }
242
243 if (strcmp(dev->name, ccdc_cfg->name)) {
244
245 ret = -EINVAL;
246 goto unlock;
247 }
248
249 if (ccdc_dev) {
250 printk(KERN_ERR "ccdc already registered\n");
251 ret = -EINVAL;
252 goto unlock;
253 }
254
255 ccdc_dev = dev;
256unlock:
257 mutex_unlock(&ccdc_lock);
258 return ret;
259}
260EXPORT_SYMBOL(vpfe_register_ccdc_device);
261
262
263
264
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
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
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
329
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
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
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
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
364 if (!ret)
365 ret = ccdc_dev->hw_ops.set_frame_format(frm_fmt);
366 return ret;
367}
368
369
370
371
372
373
374
375
376
377
378static int vpfe_config_image_format(struct vpfe_device *vpfe_dev,
379 const v4l2_std_id *std_id)
380{
381 struct vpfe_subdev_info *sdinfo = vpfe_dev->current_subdev;
382 struct v4l2_mbus_framefmt mbus_fmt;
383 struct v4l2_pix_format *pix = &vpfe_dev->fmt.fmt.pix;
384 int i, ret = 0;
385
386 for (i = 0; i < ARRAY_SIZE(vpfe_standards); i++) {
387 if (vpfe_standards[i].std_id & *std_id) {
388 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;
408 pix->width = vpfe_dev->crop.width;
409 pix->height = vpfe_dev->crop.height;
410
411
412 if (vpfe_dev->std_info.frame_format) {
413 pix->field = V4L2_FIELD_INTERLACED;
414
415 pix->pixelformat = V4L2_PIX_FMT_UYVY;
416 v4l2_fill_mbus_format(&mbus_fmt, pix,
417 V4L2_MBUS_FMT_YUYV10_2X10);
418 } else {
419 pix->field = V4L2_FIELD_NONE;
420
421 pix->pixelformat = V4L2_PIX_FMT_SBGGR8;
422 v4l2_fill_mbus_format(&mbus_fmt, pix,
423 V4L2_MBUS_FMT_SBGGR8_1X8);
424 }
425
426
427 ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev,
428 sdinfo->grp_id, video, g_mbus_fmt, &mbus_fmt);
429
430 if (ret && ret != -ENOIOCTLCMD) {
431 v4l2_err(&vpfe_dev->v4l2_dev,
432 "error in getting g_mbus_fmt from sub device\n");
433 return ret;
434 }
435 v4l2_fill_pix_format(pix, &mbus_fmt);
436 pix->bytesperline = pix->width * 2;
437 pix->sizeimage = pix->bytesperline * pix->height;
438
439
440 ret = vpfe_config_ccdc_image_format(vpfe_dev);
441 if (ret)
442 return ret;
443
444
445 if (!ret) {
446 pix->bytesperline = ccdc_dev->hw_ops.get_line_length();
447 pix->sizeimage = pix->bytesperline * pix->height;
448 }
449 return ret;
450}
451
452static int vpfe_initialize_device(struct vpfe_device *vpfe_dev)
453{
454 int ret = 0;
455
456
457 vpfe_dev->current_input = 0;
458
459
460 vpfe_dev->std_index = 0;
461
462
463 ret = vpfe_config_image_format(vpfe_dev,
464 &vpfe_standards[vpfe_dev->std_index].std_id);
465 if (ret)
466 return ret;
467
468
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;
484
485
486 if (vpfe_dev->cfg->clr_intr)
487 vpfe_dev->cfg->clr_intr(-1);
488
489unlock:
490 mutex_unlock(&ccdc_lock);
491 return ret;
492}
493
494
495
496
497
498static int vpfe_open(struct file *file)
499{
500 struct vpfe_device *vpfe_dev = video_drvdata(file);
501 struct vpfe_fh *fh;
502
503 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_open\n");
504
505 if (!vpfe_dev->cfg->num_subdevs) {
506 v4l2_err(&vpfe_dev->v4l2_dev, "No decoder registered\n");
507 return -ENODEV;
508 }
509
510
511 fh = kmalloc(sizeof(struct vpfe_fh), GFP_KERNEL);
512 if (NULL == fh) {
513 v4l2_err(&vpfe_dev->v4l2_dev,
514 "unable to allocate memory for file handle object\n");
515 return -ENOMEM;
516 }
517
518 file->private_data = fh;
519 fh->vpfe_dev = vpfe_dev;
520 mutex_lock(&vpfe_dev->lock);
521
522 if (!vpfe_dev->initialized) {
523 if (vpfe_initialize_device(vpfe_dev)) {
524 mutex_unlock(&vpfe_dev->lock);
525 return -ENODEV;
526 }
527 }
528
529 vpfe_dev->usrs++;
530
531 fh->io_allowed = 0;
532
533 fh->prio = V4L2_PRIORITY_UNSET;
534 v4l2_prio_open(&vpfe_dev->prio, &fh->prio);
535 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);
548
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;
558 ccdc_dev->hw_ops.setfbaddr(addr);
559}
560
561static void vpfe_process_buffer_complete(struct vpfe_device *vpfe_dev)
562{
563 v4l2_get_timestamp(&vpfe_dev->cur_frm->ts);
564 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
571static irqreturn_t vpfe_isr(int irq, void *dev_id)
572{
573 struct vpfe_device *vpfe_dev = dev_id;
574 enum v4l2_field field;
575 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
581 if (!vpfe_dev->started)
582 goto clear_intr;
583
584
585 if (NULL != ccdc_dev->hw_ops.reset)
586 ccdc_dev->hw_ops.reset();
587
588 if (field == V4L2_FIELD_NONE) {
589
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);
594 goto clear_intr;
595 }
596
597
598 fid = ccdc_dev->hw_ops.getfid();
599
600
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
606 if (fid == 0) {
607
608
609
610
611 if (vpfe_dev->cur_frm != vpfe_dev->next_frm)
612 vpfe_process_buffer_complete(vpfe_dev);
613
614
615
616
617
618 if (field == V4L2_FIELD_SEQ_TB) {
619 vpfe_schedule_bottom_field(vpfe_dev);
620 }
621 goto clear_intr;
622 }
623
624
625
626
627
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
637
638
639 vpfe_dev->field_id = fid;
640 }
641clear_intr:
642 if (vpfe_dev->cfg->clr_intr)
643 vpfe_dev->cfg->clr_intr(irq);
644
645 return IRQ_HANDLED;
646}
647
648
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
656 if (!vpfe_dev->started) {
657 if (vpfe_dev->cfg->clr_intr)
658 vpfe_dev->cfg->clr_intr(irq);
659 return IRQ_HANDLED;
660 }
661
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);
668
669 if (vpfe_dev->cfg->clr_intr)
670 vpfe_dev->cfg->clr_intr(irq);
671
672 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)
681 free_irq(vpfe_dev->ccdc_irq1, vpfe_dev);
682}
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,
691 IRQF_DISABLED, "vpfe_capture1",
692 vpfe_dev);
693 }
694 return 0;
695}
696
697
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
708
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
720 mutex_lock(&vpfe_dev->lock);
721
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;
737 }
738
739
740 vpfe_dev->usrs--;
741
742 v4l2_prio_close(&vpfe_dev->prio, fh->prio);
743
744 if (!vpfe_dev->usrs) {
745 vpfe_dev->initialized = 0;
746 if (ccdc_dev->hw_ops.close)
747 ccdc_dev->hw_ops.close(vpfe_dev->pdev);
748 module_put(ccdc_dev->owner);
749 }
750 mutex_unlock(&vpfe_dev->lock);
751 file->private_data = NULL;
752
753 kfree(fh);
754 return 0;
755}
756
757
758
759
760
761static int vpfe_mmap(struct file *file, struct vm_area_struct *vma)
762{
763
764 struct vpfe_device *vpfe_dev = video_drvdata(file);
765
766 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_mmap\n");
767
768 return videobuf_mmap_mapper(&vpfe_dev->buffer_queue, vma);
769}
770
771
772
773
774static unsigned int vpfe_poll(struct file *file, poll_table *wait)
775{
776 struct vpfe_device *vpfe_dev = video_drvdata(file);
777
778 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_poll\n");
779
780 if (vpfe_dev->started)
781 return videobuf_poll_stream(file,
782 &vpfe_dev->buffer_queue, wait);
783 return 0;
784}
785
786
787static const struct v4l2_file_operations vpfe_fops = {
788 .owner = THIS_MODULE,
789 .open = vpfe_open,
790 .release = vpfe_release,
791 .unlocked_ioctl = video_ioctl2,
792 .mmap = vpfe_mmap,
793 .poll = vpfe_poll
794};
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813static const struct vpfe_pixel_format *
814 vpfe_check_format(struct vpfe_device *vpfe_dev,
815 struct v4l2_pix_format *pixfmt)
816{
817 u32 min_height = 1, min_width = 32, max_width, max_height;
818 const struct vpfe_pixel_format *vpfe_pix_fmt;
819 u32 pix;
820 int temp, found;
821
822 vpfe_pix_fmt = vpfe_lookup_pix_format(pixfmt->pixelformat);
823 if (NULL == vpfe_pix_fmt) {
824
825
826
827
828 pixfmt->pixelformat = vpfe_dev->fmt.fmt.pix.pixelformat;
829 vpfe_pix_fmt = vpfe_lookup_pix_format(pixfmt->pixelformat);
830 }
831
832
833 temp = 0;
834 found = 0;
835 while (ccdc_dev->hw_ops.enum_pix(&pix, temp) >= 0) {
836 if (vpfe_pix_fmt->fmtdesc.pixelformat == pix) {
837 found = 1;
838 break;
839 }
840 temp++;
841 }
842
843 if (!found) {
844
845 pixfmt->pixelformat = vpfe_dev->fmt.fmt.pix.pixelformat;
846
847
848
849
850 vpfe_pix_fmt = vpfe_lookup_pix_format(pixfmt->pixelformat);
851 }
852
853
854 if (pixfmt->field == V4L2_FIELD_ANY) {
855
856 pixfmt->field = vpfe_dev->fmt.fmt.pix.field;
857 }
858
859
860
861
862
863 if (vpfe_dev->fmt.fmt.pix.field != pixfmt->field) {
864
865
866
867
868 switch (pixfmt->field) {
869 case V4L2_FIELD_INTERLACED:
870 case V4L2_FIELD_SEQ_TB:
871
872 if (!vpfe_dev->std_info.frame_format)
873 pixfmt->field = V4L2_FIELD_NONE;
874 break;
875 case V4L2_FIELD_NONE:
876 if (vpfe_dev->std_info.frame_format)
877 pixfmt->field = V4L2_FIELD_INTERLACED;
878 break;
879
880 default:
881
882 pixfmt->field = vpfe_dev->fmt.fmt.pix.field;
883 break;
884 }
885 }
886
887
888 if (pixfmt->field == V4L2_FIELD_INTERLACED ||
889 pixfmt->field == V4L2_FIELD_SEQ_TB)
890 min_height = 2;
891
892 max_width = vpfe_dev->std_info.active_pixels;
893 max_height = vpfe_dev->std_info.active_lines;
894 min_width /= vpfe_pix_fmt->bpp;
895
896 v4l2_info(&vpfe_dev->v4l2_dev, "width = %d, height = %d, bpp = %d\n",
897 pixfmt->width, pixfmt->height, vpfe_pix_fmt->bpp);
898
899 pixfmt->width = clamp((pixfmt->width), min_width, max_width);
900 pixfmt->height = clamp((pixfmt->height), min_height, max_height);
901
902
903 if (pixfmt->field == V4L2_FIELD_INTERLACED)
904 pixfmt->height &= (~1);
905
906
907
908
909 pixfmt->bytesperline = (((pixfmt->width * vpfe_pix_fmt->bpp) + 31)
910 & ~31);
911 if (pixfmt->pixelformat == V4L2_PIX_FMT_NV12)
912 pixfmt->sizeimage =
913 pixfmt->bytesperline * pixfmt->height +
914 ((pixfmt->bytesperline * pixfmt->height) >> 1);
915 else
916 pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
917
918 v4l2_info(&vpfe_dev->v4l2_dev, "adjusted width = %d, height ="
919 " %d, bpp = %d, bytesperline = %d, sizeimage = %d\n",
920 pixfmt->width, pixfmt->height, vpfe_pix_fmt->bpp,
921 pixfmt->bytesperline, pixfmt->sizeimage);
922 return vpfe_pix_fmt;
923}
924
925static int vpfe_querycap(struct file *file, void *priv,
926 struct v4l2_capability *cap)
927{
928 struct vpfe_device *vpfe_dev = video_drvdata(file);
929
930 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querycap\n");
931
932 cap->version = VPFE_CAPTURE_VERSION_CODE;
933 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
934 strlcpy(cap->driver, CAPTURE_DRV_NAME, sizeof(cap->driver));
935 strlcpy(cap->bus_info, "VPFE", sizeof(cap->bus_info));
936 strlcpy(cap->card, vpfe_dev->cfg->card_name, sizeof(cap->card));
937 return 0;
938}
939
940static int vpfe_g_fmt_vid_cap(struct file *file, void *priv,
941 struct v4l2_format *fmt)
942{
943 struct vpfe_device *vpfe_dev = video_drvdata(file);
944 int ret = 0;
945
946 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_fmt_vid_cap\n");
947
948 *fmt = vpfe_dev->fmt;
949 return ret;
950}
951
952static int vpfe_enum_fmt_vid_cap(struct file *file, void *priv,
953 struct v4l2_fmtdesc *fmt)
954{
955 struct vpfe_device *vpfe_dev = video_drvdata(file);
956 const struct vpfe_pixel_format *pix_fmt;
957 int temp_index;
958 u32 pix;
959
960 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_enum_fmt_vid_cap\n");
961
962 if (ccdc_dev->hw_ops.enum_pix(&pix, fmt->index) < 0)
963 return -EINVAL;
964
965
966 pix_fmt = vpfe_lookup_pix_format(pix);
967 if (NULL != pix_fmt) {
968 temp_index = fmt->index;
969 *fmt = pix_fmt->fmtdesc;
970 fmt->index = temp_index;
971 return 0;
972 }
973 return -EINVAL;
974}
975
976static int vpfe_s_fmt_vid_cap(struct file *file, void *priv,
977 struct v4l2_format *fmt)
978{
979 struct vpfe_device *vpfe_dev = video_drvdata(file);
980 const struct vpfe_pixel_format *pix_fmts;
981 int ret = 0;
982
983 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_fmt_vid_cap\n");
984
985
986 if (vpfe_dev->started) {
987 v4l2_err(&vpfe_dev->v4l2_dev, "Streaming is started\n");
988 return -EBUSY;
989 }
990
991
992 pix_fmts = vpfe_check_format(vpfe_dev, &fmt->fmt.pix);
993
994 if (NULL == pix_fmts)
995 return -EINVAL;
996
997
998 ret = mutex_lock_interruptible(&vpfe_dev->lock);
999 if (ret)
1000 return ret;
1001
1002
1003 vpfe_detach_irq(vpfe_dev);
1004 vpfe_dev->fmt = *fmt;
1005
1006 ret = vpfe_config_ccdc_image_format(vpfe_dev);
1007 mutex_unlock(&vpfe_dev->lock);
1008 return ret;
1009}
1010
1011static int vpfe_try_fmt_vid_cap(struct file *file, void *priv,
1012 struct v4l2_format *f)
1013{
1014 struct vpfe_device *vpfe_dev = video_drvdata(file);
1015 const struct vpfe_pixel_format *pix_fmts;
1016
1017 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_try_fmt_vid_cap\n");
1018
1019 pix_fmts = vpfe_check_format(vpfe_dev, &f->fmt.pix);
1020 if (NULL == pix_fmts)
1021 return -EINVAL;
1022 return 0;
1023}
1024
1025
1026
1027
1028
1029static int vpfe_get_subdev_input_index(struct vpfe_device *vpfe_dev,
1030 int *subdev_index,
1031 int *subdev_input_index,
1032 int app_input_index)
1033{
1034 struct vpfe_config *cfg = vpfe_dev->cfg;
1035 struct vpfe_subdev_info *sdinfo;
1036 int i, j = 0;
1037
1038 for (i = 0; i < cfg->num_subdevs; i++) {
1039 sdinfo = &cfg->sub_devs[i];
1040 if (app_input_index < (j + sdinfo->num_inputs)) {
1041 *subdev_index = i;
1042 *subdev_input_index = app_input_index - j;
1043 return 0;
1044 }
1045 j += sdinfo->num_inputs;
1046 }
1047 return -EINVAL;
1048}
1049
1050
1051
1052
1053
1054
1055static int vpfe_get_app_input_index(struct vpfe_device *vpfe_dev,
1056 int *app_input_index)
1057{
1058 struct vpfe_config *cfg = vpfe_dev->cfg;
1059 struct vpfe_subdev_info *sdinfo;
1060 int i, j = 0;
1061
1062 for (i = 0; i < cfg->num_subdevs; i++) {
1063 sdinfo = &cfg->sub_devs[i];
1064 if (!strcmp(sdinfo->name, vpfe_dev->current_subdev->name)) {
1065 if (vpfe_dev->current_input >= sdinfo->num_inputs)
1066 return -1;
1067 *app_input_index = j + vpfe_dev->current_input;
1068 return 0;
1069 }
1070 j += sdinfo->num_inputs;
1071 }
1072 return -EINVAL;
1073}
1074
1075static int vpfe_enum_input(struct file *file, void *priv,
1076 struct v4l2_input *inp)
1077{
1078 struct vpfe_device *vpfe_dev = video_drvdata(file);
1079 struct vpfe_subdev_info *sdinfo;
1080 int subdev, index ;
1081
1082 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_enum_input\n");
1083
1084 if (vpfe_get_subdev_input_index(vpfe_dev,
1085 &subdev,
1086 &index,
1087 inp->index) < 0) {
1088 v4l2_err(&vpfe_dev->v4l2_dev, "input information not found"
1089 " for the subdev\n");
1090 return -EINVAL;
1091 }
1092 sdinfo = &vpfe_dev->cfg->sub_devs[subdev];
1093 memcpy(inp, &sdinfo->inputs[index], sizeof(struct v4l2_input));
1094 return 0;
1095}
1096
1097static int vpfe_g_input(struct file *file, void *priv, unsigned int *index)
1098{
1099 struct vpfe_device *vpfe_dev = video_drvdata(file);
1100
1101 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_input\n");
1102
1103 return vpfe_get_app_input_index(vpfe_dev, index);
1104}
1105
1106
1107static int vpfe_s_input(struct file *file, void *priv, unsigned int index)
1108{
1109 struct vpfe_device *vpfe_dev = video_drvdata(file);
1110 struct vpfe_subdev_info *sdinfo;
1111 int subdev_index, inp_index;
1112 struct vpfe_route *route;
1113 u32 input = 0, output = 0;
1114 int ret = -EINVAL;
1115
1116 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_input\n");
1117
1118 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1119 if (ret)
1120 return ret;
1121
1122
1123
1124
1125
1126 if (vpfe_dev->started) {
1127 v4l2_err(&vpfe_dev->v4l2_dev, "Streaming is on\n");
1128 ret = -EBUSY;
1129 goto unlock_out;
1130 }
1131 ret = vpfe_get_subdev_input_index(vpfe_dev,
1132 &subdev_index,
1133 &inp_index,
1134 index);
1135 if (ret < 0) {
1136 v4l2_err(&vpfe_dev->v4l2_dev, "invalid input index\n");
1137 goto unlock_out;
1138 }
1139
1140 sdinfo = &vpfe_dev->cfg->sub_devs[subdev_index];
1141 route = &sdinfo->routes[inp_index];
1142 if (route && sdinfo->can_route) {
1143 input = route->input;
1144 output = route->output;
1145 }
1146
1147 ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev, sdinfo->grp_id,
1148 video, s_routing, input, output, 0);
1149
1150 if (ret) {
1151 v4l2_err(&vpfe_dev->v4l2_dev,
1152 "vpfe_doioctl:error in setting input in decoder\n");
1153 ret = -EINVAL;
1154 goto unlock_out;
1155 }
1156 vpfe_dev->current_subdev = sdinfo;
1157 vpfe_dev->current_input = index;
1158 vpfe_dev->std_index = 0;
1159
1160
1161 ret = ccdc_dev->hw_ops.set_hw_if_params(&sdinfo->ccdc_if_params);
1162 if (ret)
1163 goto unlock_out;
1164
1165
1166 ret = vpfe_config_image_format(vpfe_dev,
1167 &vpfe_standards[vpfe_dev->std_index].std_id);
1168unlock_out:
1169 mutex_unlock(&vpfe_dev->lock);
1170 return ret;
1171}
1172
1173static int vpfe_querystd(struct file *file, void *priv, v4l2_std_id *std_id)
1174{
1175 struct vpfe_device *vpfe_dev = video_drvdata(file);
1176 struct vpfe_subdev_info *sdinfo;
1177 int ret = 0;
1178
1179 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querystd\n");
1180
1181 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1182 sdinfo = vpfe_dev->current_subdev;
1183 if (ret)
1184 return ret;
1185
1186 ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev, sdinfo->grp_id,
1187 video, querystd, std_id);
1188 mutex_unlock(&vpfe_dev->lock);
1189 return ret;
1190}
1191
1192static int vpfe_s_std(struct file *file, void *priv, v4l2_std_id *std_id)
1193{
1194 struct vpfe_device *vpfe_dev = video_drvdata(file);
1195 struct vpfe_subdev_info *sdinfo;
1196 int ret = 0;
1197
1198 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_std\n");
1199
1200
1201 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1202 if (ret)
1203 return ret;
1204
1205 sdinfo = vpfe_dev->current_subdev;
1206
1207 if (vpfe_dev->started) {
1208 v4l2_err(&vpfe_dev->v4l2_dev, "streaming is started\n");
1209 ret = -EBUSY;
1210 goto unlock_out;
1211 }
1212
1213 ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev, sdinfo->grp_id,
1214 core, s_std, *std_id);
1215 if (ret < 0) {
1216 v4l2_err(&vpfe_dev->v4l2_dev, "Failed to set standard\n");
1217 goto unlock_out;
1218 }
1219 ret = vpfe_config_image_format(vpfe_dev, std_id);
1220
1221unlock_out:
1222 mutex_unlock(&vpfe_dev->lock);
1223 return ret;
1224}
1225
1226static int vpfe_g_std(struct file *file, void *priv, v4l2_std_id *std_id)
1227{
1228 struct vpfe_device *vpfe_dev = video_drvdata(file);
1229
1230 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_std\n");
1231
1232 *std_id = vpfe_standards[vpfe_dev->std_index].std_id;
1233 return 0;
1234}
1235
1236
1237
1238static int vpfe_videobuf_setup(struct videobuf_queue *vq,
1239 unsigned int *count,
1240 unsigned int *size)
1241{
1242 struct vpfe_fh *fh = vq->priv_data;
1243 struct vpfe_device *vpfe_dev = fh->vpfe_dev;
1244
1245 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_buffer_setup\n");
1246 *size = vpfe_dev->fmt.fmt.pix.sizeimage;
1247 if (vpfe_dev->memory == V4L2_MEMORY_MMAP &&
1248 vpfe_dev->fmt.fmt.pix.sizeimage > config_params.device_bufsize)
1249 *size = config_params.device_bufsize;
1250
1251 if (*count < config_params.min_numbuffers)
1252 *count = config_params.min_numbuffers;
1253 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1254 "count=%d, size=%d\n", *count, *size);
1255 return 0;
1256}
1257
1258static int vpfe_videobuf_prepare(struct videobuf_queue *vq,
1259 struct videobuf_buffer *vb,
1260 enum v4l2_field field)
1261{
1262 struct vpfe_fh *fh = vq->priv_data;
1263 struct vpfe_device *vpfe_dev = fh->vpfe_dev;
1264 unsigned long addr;
1265 int ret;
1266
1267 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_buffer_prepare\n");
1268
1269
1270 if (VIDEOBUF_NEEDS_INIT == vb->state) {
1271 vb->width = vpfe_dev->fmt.fmt.pix.width;
1272 vb->height = vpfe_dev->fmt.fmt.pix.height;
1273 vb->size = vpfe_dev->fmt.fmt.pix.sizeimage;
1274 vb->field = field;
1275
1276 ret = videobuf_iolock(vq, vb, NULL);
1277 if (ret < 0)
1278 return ret;
1279
1280 addr = videobuf_to_dma_contig(vb);
1281
1282 if (!ALIGN(addr, 32))
1283 return -EINVAL;
1284
1285 vb->state = VIDEOBUF_PREPARED;
1286 }
1287 return 0;
1288}
1289
1290static void vpfe_videobuf_queue(struct videobuf_queue *vq,
1291 struct videobuf_buffer *vb)
1292{
1293
1294 struct vpfe_fh *fh = vq->priv_data;
1295 struct vpfe_device *vpfe_dev = fh->vpfe_dev;
1296 unsigned long flags;
1297
1298 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_buffer_queue\n");
1299
1300
1301 spin_lock_irqsave(&vpfe_dev->dma_queue_lock, flags);
1302 list_add_tail(&vb->queue, &vpfe_dev->dma_queue);
1303 spin_unlock_irqrestore(&vpfe_dev->dma_queue_lock, flags);
1304
1305
1306 vb->state = VIDEOBUF_QUEUED;
1307}
1308
1309static void vpfe_videobuf_release(struct videobuf_queue *vq,
1310 struct videobuf_buffer *vb)
1311{
1312 struct vpfe_fh *fh = vq->priv_data;
1313 struct vpfe_device *vpfe_dev = fh->vpfe_dev;
1314 unsigned long flags;
1315
1316 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_videobuf_release\n");
1317
1318
1319
1320
1321
1322 spin_lock_irqsave(&vpfe_dev->dma_queue_lock, flags);
1323 INIT_LIST_HEAD(&vpfe_dev->dma_queue);
1324 spin_unlock_irqrestore(&vpfe_dev->dma_queue_lock, flags);
1325 videobuf_dma_contig_free(vq, vb);
1326 vb->state = VIDEOBUF_NEEDS_INIT;
1327}
1328
1329static struct videobuf_queue_ops vpfe_videobuf_qops = {
1330 .buf_setup = vpfe_videobuf_setup,
1331 .buf_prepare = vpfe_videobuf_prepare,
1332 .buf_queue = vpfe_videobuf_queue,
1333 .buf_release = vpfe_videobuf_release,
1334};
1335
1336
1337
1338
1339
1340static int vpfe_reqbufs(struct file *file, void *priv,
1341 struct v4l2_requestbuffers *req_buf)
1342{
1343 struct vpfe_device *vpfe_dev = video_drvdata(file);
1344 struct vpfe_fh *fh = file->private_data;
1345 int ret = 0;
1346
1347 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_reqbufs\n");
1348
1349 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != req_buf->type) {
1350 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buffer type\n");
1351 return -EINVAL;
1352 }
1353
1354 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1355 if (ret)
1356 return ret;
1357
1358 if (vpfe_dev->io_usrs != 0) {
1359 v4l2_err(&vpfe_dev->v4l2_dev, "Only one IO user allowed\n");
1360 ret = -EBUSY;
1361 goto unlock_out;
1362 }
1363
1364 vpfe_dev->memory = req_buf->memory;
1365 videobuf_queue_dma_contig_init(&vpfe_dev->buffer_queue,
1366 &vpfe_videobuf_qops,
1367 vpfe_dev->pdev,
1368 &vpfe_dev->irqlock,
1369 req_buf->type,
1370 vpfe_dev->fmt.fmt.pix.field,
1371 sizeof(struct videobuf_buffer),
1372 fh, NULL);
1373
1374 fh->io_allowed = 1;
1375 vpfe_dev->io_usrs = 1;
1376 INIT_LIST_HEAD(&vpfe_dev->dma_queue);
1377 ret = videobuf_reqbufs(&vpfe_dev->buffer_queue, req_buf);
1378unlock_out:
1379 mutex_unlock(&vpfe_dev->lock);
1380 return ret;
1381}
1382
1383static int vpfe_querybuf(struct file *file, void *priv,
1384 struct v4l2_buffer *buf)
1385{
1386 struct vpfe_device *vpfe_dev = video_drvdata(file);
1387
1388 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_querybuf\n");
1389
1390 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != buf->type) {
1391 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n");
1392 return -EINVAL;
1393 }
1394
1395 if (vpfe_dev->memory != V4L2_MEMORY_MMAP) {
1396 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid memory\n");
1397 return -EINVAL;
1398 }
1399
1400 return videobuf_querybuf(&vpfe_dev->buffer_queue, buf);
1401}
1402
1403static int vpfe_qbuf(struct file *file, void *priv,
1404 struct v4l2_buffer *p)
1405{
1406 struct vpfe_device *vpfe_dev = video_drvdata(file);
1407 struct vpfe_fh *fh = file->private_data;
1408
1409 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_qbuf\n");
1410
1411 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != p->type) {
1412 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n");
1413 return -EINVAL;
1414 }
1415
1416
1417
1418
1419
1420 if (!fh->io_allowed) {
1421 v4l2_err(&vpfe_dev->v4l2_dev, "fh->io_allowed\n");
1422 return -EACCES;
1423 }
1424 return videobuf_qbuf(&vpfe_dev->buffer_queue, p);
1425}
1426
1427static int vpfe_dqbuf(struct file *file, void *priv,
1428 struct v4l2_buffer *buf)
1429{
1430 struct vpfe_device *vpfe_dev = video_drvdata(file);
1431
1432 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_dqbuf\n");
1433
1434 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != buf->type) {
1435 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n");
1436 return -EINVAL;
1437 }
1438 return videobuf_dqbuf(&vpfe_dev->buffer_queue,
1439 buf, file->f_flags & O_NONBLOCK);
1440}
1441
1442static int vpfe_queryctrl(struct file *file, void *priv,
1443 struct v4l2_queryctrl *qctrl)
1444{
1445 struct vpfe_device *vpfe_dev = video_drvdata(file);
1446 struct vpfe_subdev_info *sdinfo;
1447
1448 sdinfo = vpfe_dev->current_subdev;
1449
1450 return v4l2_device_call_until_err(&vpfe_dev->v4l2_dev, sdinfo->grp_id,
1451 core, queryctrl, qctrl);
1452
1453}
1454
1455static int vpfe_g_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl)
1456{
1457 struct vpfe_device *vpfe_dev = video_drvdata(file);
1458 struct vpfe_subdev_info *sdinfo;
1459
1460 sdinfo = vpfe_dev->current_subdev;
1461
1462 return v4l2_device_call_until_err(&vpfe_dev->v4l2_dev, sdinfo->grp_id,
1463 core, g_ctrl, ctrl);
1464}
1465
1466static int vpfe_s_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl)
1467{
1468 struct vpfe_device *vpfe_dev = video_drvdata(file);
1469 struct vpfe_subdev_info *sdinfo;
1470
1471 sdinfo = vpfe_dev->current_subdev;
1472
1473 return v4l2_device_call_until_err(&vpfe_dev->v4l2_dev, sdinfo->grp_id,
1474 core, s_ctrl, ctrl);
1475}
1476
1477
1478
1479
1480
1481static void vpfe_calculate_offsets(struct vpfe_device *vpfe_dev)
1482{
1483 struct v4l2_rect image_win;
1484
1485 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_calculate_offsets\n");
1486
1487 ccdc_dev->hw_ops.get_image_window(&image_win);
1488 vpfe_dev->field_off = image_win.height * image_win.width;
1489}
1490
1491
1492static void vpfe_start_ccdc_capture(struct vpfe_device *vpfe_dev)
1493{
1494 ccdc_dev->hw_ops.enable(1);
1495 if (ccdc_dev->hw_ops.enable_out_to_sdram)
1496 ccdc_dev->hw_ops.enable_out_to_sdram(1);
1497 vpfe_dev->started = 1;
1498}
1499
1500
1501
1502
1503
1504
1505static int vpfe_streamon(struct file *file, void *priv,
1506 enum v4l2_buf_type buf_type)
1507{
1508 struct vpfe_device *vpfe_dev = video_drvdata(file);
1509 struct vpfe_fh *fh = file->private_data;
1510 struct vpfe_subdev_info *sdinfo;
1511 unsigned long addr;
1512 int ret = 0;
1513
1514 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_streamon\n");
1515
1516 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != buf_type) {
1517 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n");
1518 return -EINVAL;
1519 }
1520
1521
1522 if (!fh->io_allowed) {
1523 v4l2_err(&vpfe_dev->v4l2_dev, "fh->io_allowed\n");
1524 return -EACCES;
1525 }
1526
1527 sdinfo = vpfe_dev->current_subdev;
1528 ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev, sdinfo->grp_id,
1529 video, s_stream, 1);
1530
1531 if (ret && (ret != -ENOIOCTLCMD)) {
1532 v4l2_err(&vpfe_dev->v4l2_dev, "stream on failed in subdev\n");
1533 return -EINVAL;
1534 }
1535
1536
1537 if (list_empty(&vpfe_dev->buffer_queue.stream)) {
1538 v4l2_err(&vpfe_dev->v4l2_dev, "buffer queue is empty\n");
1539 return -EIO;
1540 }
1541
1542
1543 ret = videobuf_streamon(&vpfe_dev->buffer_queue);
1544 if (ret)
1545 return ret;
1546
1547
1548 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1549 if (ret)
1550 goto streamoff;
1551
1552 vpfe_dev->next_frm = list_entry(vpfe_dev->dma_queue.next,
1553 struct videobuf_buffer, queue);
1554 vpfe_dev->cur_frm = vpfe_dev->next_frm;
1555
1556 list_del(&vpfe_dev->cur_frm->queue);
1557
1558 vpfe_dev->cur_frm->state = VIDEOBUF_ACTIVE;
1559
1560 vpfe_dev->field_id = 0;
1561 addr = videobuf_to_dma_contig(vpfe_dev->cur_frm);
1562
1563
1564 vpfe_calculate_offsets(vpfe_dev);
1565
1566 if (vpfe_attach_irq(vpfe_dev) < 0) {
1567 v4l2_err(&vpfe_dev->v4l2_dev,
1568 "Error in attaching interrupt handle\n");
1569 ret = -EFAULT;
1570 goto unlock_out;
1571 }
1572 if (ccdc_dev->hw_ops.configure() < 0) {
1573 v4l2_err(&vpfe_dev->v4l2_dev,
1574 "Error in configuring ccdc\n");
1575 ret = -EINVAL;
1576 goto unlock_out;
1577 }
1578 ccdc_dev->hw_ops.setfbaddr((unsigned long)(addr));
1579 vpfe_start_ccdc_capture(vpfe_dev);
1580 mutex_unlock(&vpfe_dev->lock);
1581 return ret;
1582unlock_out:
1583 mutex_unlock(&vpfe_dev->lock);
1584streamoff:
1585 ret = videobuf_streamoff(&vpfe_dev->buffer_queue);
1586 return ret;
1587}
1588
1589static int vpfe_streamoff(struct file *file, void *priv,
1590 enum v4l2_buf_type buf_type)
1591{
1592 struct vpfe_device *vpfe_dev = video_drvdata(file);
1593 struct vpfe_fh *fh = file->private_data;
1594 struct vpfe_subdev_info *sdinfo;
1595 int ret = 0;
1596
1597 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_streamoff\n");
1598
1599 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != buf_type) {
1600 v4l2_err(&vpfe_dev->v4l2_dev, "Invalid buf type\n");
1601 return -EINVAL;
1602 }
1603
1604
1605 if (!fh->io_allowed) {
1606 v4l2_err(&vpfe_dev->v4l2_dev, "fh->io_allowed\n");
1607 return -EACCES;
1608 }
1609
1610
1611 if (!vpfe_dev->started) {
1612 v4l2_err(&vpfe_dev->v4l2_dev, "device started\n");
1613 return -EINVAL;
1614 }
1615
1616 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1617 if (ret)
1618 return ret;
1619
1620 vpfe_stop_ccdc_capture(vpfe_dev);
1621 vpfe_detach_irq(vpfe_dev);
1622
1623 sdinfo = vpfe_dev->current_subdev;
1624 ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev, sdinfo->grp_id,
1625 video, s_stream, 0);
1626
1627 if (ret && (ret != -ENOIOCTLCMD))
1628 v4l2_err(&vpfe_dev->v4l2_dev, "stream off failed in subdev\n");
1629 ret = videobuf_streamoff(&vpfe_dev->buffer_queue);
1630 mutex_unlock(&vpfe_dev->lock);
1631 return ret;
1632}
1633
1634static int vpfe_cropcap(struct file *file, void *priv,
1635 struct v4l2_cropcap *crop)
1636{
1637 struct vpfe_device *vpfe_dev = video_drvdata(file);
1638
1639 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_cropcap\n");
1640
1641 if (vpfe_dev->std_index >= ARRAY_SIZE(vpfe_standards))
1642 return -EINVAL;
1643
1644 memset(crop, 0, sizeof(struct v4l2_cropcap));
1645 crop->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1646 crop->bounds.width = crop->defrect.width =
1647 vpfe_standards[vpfe_dev->std_index].width;
1648 crop->bounds.height = crop->defrect.height =
1649 vpfe_standards[vpfe_dev->std_index].height;
1650 crop->pixelaspect = vpfe_standards[vpfe_dev->std_index].pixelaspect;
1651 return 0;
1652}
1653
1654static int vpfe_g_crop(struct file *file, void *priv,
1655 struct v4l2_crop *crop)
1656{
1657 struct vpfe_device *vpfe_dev = video_drvdata(file);
1658
1659 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_crop\n");
1660
1661 crop->c = vpfe_dev->crop;
1662 return 0;
1663}
1664
1665static int vpfe_s_crop(struct file *file, void *priv,
1666 const struct v4l2_crop *crop)
1667{
1668 struct vpfe_device *vpfe_dev = video_drvdata(file);
1669 struct v4l2_rect rect = crop->c;
1670 int ret = 0;
1671
1672 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_crop\n");
1673
1674 if (vpfe_dev->started) {
1675
1676 v4l2_err(&vpfe_dev->v4l2_dev,
1677 "Cannot change crop when streaming is ON\n");
1678 return -EBUSY;
1679 }
1680
1681 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1682 if (ret)
1683 return ret;
1684
1685 if (rect.top < 0 || rect.left < 0) {
1686 v4l2_err(&vpfe_dev->v4l2_dev,
1687 "doesn't support negative values for top & left\n");
1688 ret = -EINVAL;
1689 goto unlock_out;
1690 }
1691
1692
1693 rect.width = ((rect.width + 15) & ~0xf);
1694
1695
1696 if ((rect.left + rect.width >
1697 vpfe_dev->std_info.active_pixels) ||
1698 (rect.top + rect.height >
1699 vpfe_dev->std_info.active_lines)) {
1700 v4l2_err(&vpfe_dev->v4l2_dev, "Error in S_CROP params\n");
1701 ret = -EINVAL;
1702 goto unlock_out;
1703 }
1704 ccdc_dev->hw_ops.set_image_window(&rect);
1705 vpfe_dev->fmt.fmt.pix.width = rect.width;
1706 vpfe_dev->fmt.fmt.pix.height = rect.height;
1707 vpfe_dev->fmt.fmt.pix.bytesperline =
1708 ccdc_dev->hw_ops.get_line_length();
1709 vpfe_dev->fmt.fmt.pix.sizeimage =
1710 vpfe_dev->fmt.fmt.pix.bytesperline *
1711 vpfe_dev->fmt.fmt.pix.height;
1712 vpfe_dev->crop = rect;
1713unlock_out:
1714 mutex_unlock(&vpfe_dev->lock);
1715 return ret;
1716}
1717
1718
1719static long vpfe_param_handler(struct file *file, void *priv,
1720 bool valid_prio, int cmd, void *param)
1721{
1722 struct vpfe_device *vpfe_dev = video_drvdata(file);
1723 int ret = 0;
1724
1725 v4l2_dbg(2, debug, &vpfe_dev->v4l2_dev, "vpfe_param_handler\n");
1726
1727 if (vpfe_dev->started) {
1728
1729 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1730 "device already started\n");
1731 return -EBUSY;
1732 }
1733
1734 ret = mutex_lock_interruptible(&vpfe_dev->lock);
1735 if (ret)
1736 return ret;
1737
1738 switch (cmd) {
1739 case VPFE_CMD_S_CCDC_RAW_PARAMS:
1740 v4l2_warn(&vpfe_dev->v4l2_dev,
1741 "VPFE_CMD_S_CCDC_RAW_PARAMS: experimental ioctl\n");
1742 if (ccdc_dev->hw_ops.set_params) {
1743 ret = ccdc_dev->hw_ops.set_params(param);
1744 if (ret) {
1745 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1746 "Error setting parameters in CCDC\n");
1747 goto unlock_out;
1748 }
1749 ret = vpfe_get_ccdc_image_format(vpfe_dev,
1750 &vpfe_dev->fmt);
1751 if (ret < 0) {
1752 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1753 "Invalid image format at CCDC\n");
1754 goto unlock_out;
1755 }
1756 } else {
1757 ret = -EINVAL;
1758 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1759 "VPFE_CMD_S_CCDC_RAW_PARAMS not supported\n");
1760 }
1761 break;
1762 default:
1763 ret = -ENOTTY;
1764 }
1765unlock_out:
1766 mutex_unlock(&vpfe_dev->lock);
1767 return ret;
1768}
1769
1770
1771
1772static const struct v4l2_ioctl_ops vpfe_ioctl_ops = {
1773 .vidioc_querycap = vpfe_querycap,
1774 .vidioc_g_fmt_vid_cap = vpfe_g_fmt_vid_cap,
1775 .vidioc_enum_fmt_vid_cap = vpfe_enum_fmt_vid_cap,
1776 .vidioc_s_fmt_vid_cap = vpfe_s_fmt_vid_cap,
1777 .vidioc_try_fmt_vid_cap = vpfe_try_fmt_vid_cap,
1778 .vidioc_enum_input = vpfe_enum_input,
1779 .vidioc_g_input = vpfe_g_input,
1780 .vidioc_s_input = vpfe_s_input,
1781 .vidioc_querystd = vpfe_querystd,
1782 .vidioc_s_std = vpfe_s_std,
1783 .vidioc_g_std = vpfe_g_std,
1784 .vidioc_queryctrl = vpfe_queryctrl,
1785 .vidioc_g_ctrl = vpfe_g_ctrl,
1786 .vidioc_s_ctrl = vpfe_s_ctrl,
1787 .vidioc_reqbufs = vpfe_reqbufs,
1788 .vidioc_querybuf = vpfe_querybuf,
1789 .vidioc_qbuf = vpfe_qbuf,
1790 .vidioc_dqbuf = vpfe_dqbuf,
1791 .vidioc_streamon = vpfe_streamon,
1792 .vidioc_streamoff = vpfe_streamoff,
1793 .vidioc_cropcap = vpfe_cropcap,
1794 .vidioc_g_crop = vpfe_g_crop,
1795 .vidioc_s_crop = vpfe_s_crop,
1796 .vidioc_default = vpfe_param_handler,
1797};
1798
1799static struct vpfe_device *vpfe_initialize(void)
1800{
1801 struct vpfe_device *vpfe_dev;
1802
1803
1804 if ((numbuffers > 0) &&
1805 (numbuffers < config_params.min_numbuffers))
1806 numbuffers = config_params.min_numbuffers;
1807
1808
1809
1810
1811
1812 if (bufsize < config_params.min_bufsize)
1813 bufsize = config_params.min_bufsize;
1814
1815 config_params.numbuffers = numbuffers;
1816
1817 if (numbuffers)
1818 config_params.device_bufsize = bufsize;
1819
1820
1821 vpfe_dev = kzalloc(sizeof(*vpfe_dev), GFP_KERNEL);
1822
1823 return vpfe_dev;
1824}
1825
1826
1827
1828
1829
1830
1831static int vpfe_probe(struct platform_device *pdev)
1832{
1833 struct vpfe_subdev_info *sdinfo;
1834 struct vpfe_config *vpfe_cfg;
1835 struct resource *res1;
1836 struct vpfe_device *vpfe_dev;
1837 struct i2c_adapter *i2c_adap;
1838 struct video_device *vfd;
1839 int ret = -ENOMEM, i, j;
1840 int num_subdevs = 0;
1841
1842
1843 vpfe_dev = vpfe_initialize();
1844
1845 if (!vpfe_dev) {
1846 v4l2_err(pdev->dev.driver,
1847 "Failed to allocate memory for vpfe_dev\n");
1848 return ret;
1849 }
1850
1851 vpfe_dev->pdev = &pdev->dev;
1852
1853 if (NULL == pdev->dev.platform_data) {
1854 v4l2_err(pdev->dev.driver, "Unable to get vpfe config\n");
1855 ret = -ENODEV;
1856 goto probe_free_dev_mem;
1857 }
1858
1859 vpfe_cfg = pdev->dev.platform_data;
1860 vpfe_dev->cfg = vpfe_cfg;
1861 if (NULL == vpfe_cfg->ccdc ||
1862 NULL == vpfe_cfg->card_name ||
1863 NULL == vpfe_cfg->sub_devs) {
1864 v4l2_err(pdev->dev.driver, "null ptr in vpfe_cfg\n");
1865 ret = -ENOENT;
1866 goto probe_free_dev_mem;
1867 }
1868
1869
1870 ccdc_cfg = kmalloc(sizeof(struct ccdc_config), GFP_KERNEL);
1871 if (NULL == ccdc_cfg) {
1872 v4l2_err(pdev->dev.driver,
1873 "Memory allocation failed for ccdc_cfg\n");
1874 goto probe_free_lock;
1875 }
1876
1877 mutex_lock(&ccdc_lock);
1878
1879 strncpy(ccdc_cfg->name, vpfe_cfg->ccdc, 32);
1880
1881 res1 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1882 if (!res1) {
1883 v4l2_err(pdev->dev.driver,
1884 "Unable to get interrupt for VINT0\n");
1885 ret = -ENODEV;
1886 goto probe_free_ccdc_cfg_mem;
1887 }
1888 vpfe_dev->ccdc_irq0 = res1->start;
1889
1890
1891 res1 = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
1892 if (!res1) {
1893 v4l2_err(pdev->dev.driver,
1894 "Unable to get interrupt for VINT1\n");
1895 ret = -ENODEV;
1896 goto probe_free_ccdc_cfg_mem;
1897 }
1898 vpfe_dev->ccdc_irq1 = res1->start;
1899
1900 ret = request_irq(vpfe_dev->ccdc_irq0, vpfe_isr, IRQF_DISABLED,
1901 "vpfe_capture0", vpfe_dev);
1902
1903 if (0 != ret) {
1904 v4l2_err(pdev->dev.driver, "Unable to request interrupt\n");
1905 goto probe_free_ccdc_cfg_mem;
1906 }
1907
1908
1909 vfd = video_device_alloc();
1910 if (NULL == vfd) {
1911 ret = -ENOMEM;
1912 v4l2_err(pdev->dev.driver, "Unable to alloc video device\n");
1913 goto probe_out_release_irq;
1914 }
1915
1916
1917 vfd->release = video_device_release;
1918 vfd->fops = &vpfe_fops;
1919 vfd->ioctl_ops = &vpfe_ioctl_ops;
1920 vfd->tvnorms = 0;
1921 vfd->current_norm = V4L2_STD_PAL;
1922 vfd->v4l2_dev = &vpfe_dev->v4l2_dev;
1923 snprintf(vfd->name, sizeof(vfd->name),
1924 "%s_V%d.%d.%d",
1925 CAPTURE_DRV_NAME,
1926 (VPFE_CAPTURE_VERSION_CODE >> 16) & 0xff,
1927 (VPFE_CAPTURE_VERSION_CODE >> 8) & 0xff,
1928 (VPFE_CAPTURE_VERSION_CODE) & 0xff);
1929
1930 vpfe_dev->video_dev = vfd;
1931
1932 ret = v4l2_device_register(&pdev->dev, &vpfe_dev->v4l2_dev);
1933 if (ret) {
1934 v4l2_err(pdev->dev.driver,
1935 "Unable to register v4l2 device.\n");
1936 goto probe_out_video_release;
1937 }
1938 v4l2_info(&vpfe_dev->v4l2_dev, "v4l2 device registered\n");
1939 spin_lock_init(&vpfe_dev->irqlock);
1940 spin_lock_init(&vpfe_dev->dma_queue_lock);
1941 mutex_init(&vpfe_dev->lock);
1942
1943
1944 vpfe_dev->numbuffers = config_params.numbuffers;
1945
1946
1947 v4l2_prio_init(&vpfe_dev->prio);
1948
1949 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1950 "trying to register vpfe device.\n");
1951 v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev,
1952 "video_dev=%x\n", (int)&vpfe_dev->video_dev);
1953 vpfe_dev->fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1954 ret = video_register_device(vpfe_dev->video_dev,
1955 VFL_TYPE_GRABBER, -1);
1956
1957 if (ret) {
1958 v4l2_err(pdev->dev.driver,
1959 "Unable to register video device.\n");
1960 goto probe_out_v4l2_unregister;
1961 }
1962
1963 v4l2_info(&vpfe_dev->v4l2_dev, "video device registered\n");
1964
1965 platform_set_drvdata(pdev, vpfe_dev);
1966
1967 video_set_drvdata(vpfe_dev->video_dev, vpfe_dev);
1968 i2c_adap = i2c_get_adapter(vpfe_cfg->i2c_adapter_id);
1969 num_subdevs = vpfe_cfg->num_subdevs;
1970 vpfe_dev->sd = kmalloc(sizeof(struct v4l2_subdev *) * num_subdevs,
1971 GFP_KERNEL);
1972 if (NULL == vpfe_dev->sd) {
1973 v4l2_err(&vpfe_dev->v4l2_dev,
1974 "unable to allocate memory for subdevice pointers\n");
1975 ret = -ENOMEM;
1976 goto probe_out_video_unregister;
1977 }
1978
1979 for (i = 0; i < num_subdevs; i++) {
1980 struct v4l2_input *inps;
1981
1982 sdinfo = &vpfe_cfg->sub_devs[i];
1983
1984
1985 vpfe_dev->sd[i] =
1986 v4l2_i2c_new_subdev_board(&vpfe_dev->v4l2_dev,
1987 i2c_adap,
1988 &sdinfo->board_info,
1989 NULL);
1990 if (vpfe_dev->sd[i]) {
1991 v4l2_info(&vpfe_dev->v4l2_dev,
1992 "v4l2 sub device %s registered\n",
1993 sdinfo->name);
1994 vpfe_dev->sd[i]->grp_id = sdinfo->grp_id;
1995
1996 for (j = 0; j < sdinfo->num_inputs; j++) {
1997 inps = &sdinfo->inputs[j];
1998 vfd->tvnorms |= inps->std;
1999 }
2000 } else {
2001 v4l2_info(&vpfe_dev->v4l2_dev,
2002 "v4l2 sub device %s register fails\n",
2003 sdinfo->name);
2004 goto probe_sd_out;
2005 }
2006 }
2007
2008
2009 vpfe_dev->current_subdev = &vpfe_cfg->sub_devs[0];
2010
2011
2012 mutex_unlock(&ccdc_lock);
2013 return 0;
2014
2015probe_sd_out:
2016 kfree(vpfe_dev->sd);
2017probe_out_video_unregister:
2018 video_unregister_device(vpfe_dev->video_dev);
2019probe_out_v4l2_unregister:
2020 v4l2_device_unregister(&vpfe_dev->v4l2_dev);
2021probe_out_video_release:
2022 if (!video_is_registered(vpfe_dev->video_dev))
2023 video_device_release(vpfe_dev->video_dev);
2024probe_out_release_irq:
2025 free_irq(vpfe_dev->ccdc_irq0, vpfe_dev);
2026probe_free_ccdc_cfg_mem:
2027 kfree(ccdc_cfg);
2028probe_free_lock:
2029 mutex_unlock(&ccdc_lock);
2030probe_free_dev_mem:
2031 kfree(vpfe_dev);
2032 return ret;
2033}
2034
2035
2036
2037
2038static int vpfe_remove(struct platform_device *pdev)
2039{
2040 struct vpfe_device *vpfe_dev = platform_get_drvdata(pdev);
2041
2042 v4l2_info(pdev->dev.driver, "vpfe_remove\n");
2043
2044 free_irq(vpfe_dev->ccdc_irq0, vpfe_dev);
2045 kfree(vpfe_dev->sd);
2046 v4l2_device_unregister(&vpfe_dev->v4l2_dev);
2047 video_unregister_device(vpfe_dev->video_dev);
2048 kfree(vpfe_dev);
2049 kfree(ccdc_cfg);
2050 return 0;
2051}
2052
2053static int vpfe_suspend(struct device *dev)
2054{
2055 return 0;
2056}
2057
2058static int vpfe_resume(struct device *dev)
2059{
2060 return 0;
2061}
2062
2063static const struct dev_pm_ops vpfe_dev_pm_ops = {
2064 .suspend = vpfe_suspend,
2065 .resume = vpfe_resume,
2066};
2067
2068static struct platform_driver vpfe_driver = {
2069 .driver = {
2070 .name = CAPTURE_DRV_NAME,
2071 .owner = THIS_MODULE,
2072 .pm = &vpfe_dev_pm_ops,
2073 },
2074 .probe = vpfe_probe,
2075 .remove = vpfe_remove,
2076};
2077
2078module_platform_driver(vpfe_driver);
2079