[media] v4l: subdev: Add device node support
[firefly-linux-kernel-4.4.55.git] / drivers / media / video / v4l2-subdev.c
1 /*
2  *  V4L2 subdevice support.
3  *
4  *  Copyright (C) 2010 Nokia Corporation
5  *
6  *  Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include <linux/types.h>
23 #include <linux/ioctl.h>
24 #include <linux/videodev2.h>
25
26 #include <media/v4l2-device.h>
27 #include <media/v4l2-ioctl.h>
28
29 static int subdev_open(struct file *file)
30 {
31         return 0;
32 }
33
34 static int subdev_close(struct file *file)
35 {
36         return 0;
37 }
38
39 static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
40 {
41         switch (cmd) {
42         default:
43                 return -ENOIOCTLCMD;
44         }
45
46         return 0;
47 }
48
49 static long subdev_ioctl(struct file *file, unsigned int cmd,
50         unsigned long arg)
51 {
52         return video_usercopy(file, cmd, arg, subdev_do_ioctl);
53 }
54
55 const struct v4l2_file_operations v4l2_subdev_fops = {
56         .owner = THIS_MODULE,
57         .open = subdev_open,
58         .unlocked_ioctl = subdev_ioctl,
59         .release = subdev_close,
60 };