V4L/DVB (8782): v4l2-dev: add video_device_release_empty
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / media / v4l2-dev.h
CommitLineData
401998fa
MCC
1/*
2 *
3 * V 4 L 2 D R I V E R H E L P E R A P I
4 *
5 * Moved from videodev2.h
6 *
7 * Some commonly needed functions for drivers (v4l2-common.o module)
8 */
9#ifndef _V4L2_DEV_H
10#define _V4L2_DEV_H
11
38ee04f0 12#define OBSOLETE_DEVDATA 1 /* to be removed soon */
401998fa
MCC
13
14#include <linux/poll.h>
15#include <linux/fs.h>
16#include <linux/device.h>
17#include <linux/mutex.h>
18#include <linux/compiler.h> /* need __user */
401998fa 19#include <linux/videodev2.h>
401998fa 20
401998fa
MCC
21#define VIDEO_MAJOR 81
22/* Minor device allocation */
23#define MINOR_VFL_TYPE_GRABBER_MIN 0
24#define MINOR_VFL_TYPE_GRABBER_MAX 63
25#define MINOR_VFL_TYPE_RADIO_MIN 64
26#define MINOR_VFL_TYPE_RADIO_MAX 127
27#define MINOR_VFL_TYPE_VTX_MIN 192
28#define MINOR_VFL_TYPE_VTX_MAX 223
29#define MINOR_VFL_TYPE_VBI_MIN 224
30#define MINOR_VFL_TYPE_VBI_MAX 255
31
32#define VFL_TYPE_GRABBER 0
33#define VFL_TYPE_VBI 1
34#define VFL_TYPE_RADIO 2
35#define VFL_TYPE_VTX 3
36
a399810c
HV
37struct v4l2_ioctl_callbacks;
38
401998fa
MCC
39/*
40 * Newer version of video_device, handled by videodev2.c
41 * This version moves redundant code from video device code to
42 * the common handler
43 */
401998fa
MCC
44
45struct video_device
46{
47 /* device ops */
5e87efa3 48 const struct file_operations *fops;
401998fa 49
54bd5b66 50 /* sysfs */
22a04f10 51 struct device dev; /* v4l device */
5e85e732 52 struct device *parent; /* device parent */
54bd5b66 53
401998fa 54 /* device info */
401998fa 55 char name[32];
0ea6bc8d 56 int vfl_type;
401998fa 57 int minor;
de1e575d 58 /* attribute to differentiate multiple indices on one physical device */
539a7555 59 int index;
401998fa 60
22a04f10 61 int debug; /* Activates debug level*/
401998fa
MCC
62
63 /* Video standard vars */
e75f9cee
MCC
64 v4l2_std_id tvnorms; /* Supported tv norms */
65 v4l2_std_id current_norm; /* Current tvnorm */
401998fa
MCC
66
67 /* callbacks */
68 void (*release)(struct video_device *vfd);
69
70 /* ioctl callbacks */
a399810c 71 const struct v4l2_ioctl_ops *ioctl_ops;
dbbff48f 72
9c39d7ea
HV
73#ifdef OBSOLETE_DEVDATA /* to be removed soon */
74 /* dev->driver_data will be used instead some day.
75 * Use the video_{get|set}_drvdata() helper functions,
76 * so the switch over will be transparent for you.
77 * Or use {pci|usb}_{get|set}_drvdata() directly. */
78 void *priv;
401998fa 79#endif
401998fa
MCC
80};
81
e90ff923 82/* Class-dev to video-device */
22a04f10 83#define to_video_device(cd) container_of(cd, struct video_device, dev)
e90ff923 84
401998fa
MCC
85/* Version 2 functions */
86extern int video_register_device(struct video_device *vfd, int type, int nr);
539a7555 87int video_register_device_index(struct video_device *vfd, int type, int nr,
88 int index);
401998fa 89void video_unregister_device(struct video_device *);
401998fa
MCC
90
91/* helper functions to alloc / release struct video_device, the
92 later can be used for video_device->release() */
93struct video_device *video_device_alloc(void);
f9e86b5e 94/* this release function frees the vfd pointer */
401998fa 95void video_device_release(struct video_device *vfd);
f9e86b5e
HV
96/* this release function does nothing, use when the video_device is a
97 static global struct. Note that having a static video_device is
98 a dubious construction at best. */
99void video_device_release_empty(struct video_device *vfd);
401998fa 100
9c39d7ea 101#ifdef OBSOLETE_DEVDATA /* to be removed soon */
401998fa
MCC
102/* helper functions to access driver private data. */
103static inline void *video_get_drvdata(struct video_device *dev)
104{
105 return dev->priv;
106}
107
108static inline void video_set_drvdata(struct video_device *dev, void *data)
109{
110 dev->priv = data;
111}
38ee04f0 112
38ee04f0
MCC
113/* Obsolete stuff - Still needed for radio devices and obsolete drivers */
114extern struct video_device* video_devdata(struct file*);
38ee04f0 115#endif
401998fa
MCC
116
117#endif /* _V4L2_DEV_H */