blob: 21419da44cb60341a2efb7563efb3fdc4858d5a8 [file] [log] [blame]
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -03001/*
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
Mauro Carvalho Chehab38ee04f2006-08-08 09:10:01 -030012#define OBSOLETE_DEVDATA 1 /* to be removed soon */
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030013
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 */
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030019#include <linux/videodev2.h>
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030020
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030021#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
Hans Verkuila3998102008-07-21 02:57:38 -030037struct v4l2_ioctl_callbacks;
38
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030039/*
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 */
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030044
45struct video_device
46{
47 /* device ops */
Mauro Carvalho Chehab5e87efa2006-06-05 10:26:32 -030048 const struct file_operations *fops;
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030049
Kay Sievers54bd5b62007-10-08 16:26:13 -030050 /* sysfs */
Hans Verkuil22a04f12008-07-20 06:35:02 -030051 struct device dev; /* v4l device */
Hans Verkuil5e85e732008-07-20 06:31:39 -030052 struct device *parent; /* device parent */
Kay Sievers54bd5b62007-10-08 16:26:13 -030053
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030054 /* device info */
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030055 char name[32];
Hans Verkuil0ea6bc82008-07-26 08:26:43 -030056 int vfl_type;
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030057 int minor;
brandon@ifup.org539a7552008-06-20 22:58:53 -030058 /* attribute to diferentiate multiple indexs on one physical device */
59 int index;
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030060
Hans Verkuil22a04f12008-07-20 06:35:02 -030061 int debug; /* Activates debug level*/
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030062
63 /* Video standard vars */
Mauro Carvalho Chehabe75f9ce2006-11-20 13:19:20 -030064 v4l2_std_id tvnorms; /* Supported tv norms */
65 v4l2_std_id current_norm; /* Current tvnorm */
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030066
67 /* callbacks */
68 void (*release)(struct video_device *vfd);
69
70 /* ioctl callbacks */
Hans Verkuila3998102008-07-21 02:57:38 -030071 const struct v4l2_ioctl_ops *ioctl_ops;
Trent Piephodbbff482007-01-22 23:31:53 -030072
Hans Verkuil9c39d7e2008-07-21 07:51:45 -030073#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;
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030079#endif
80
81 /* for videodev.c intenal usage -- please don't touch */
82 int users; /* video_exclusive_{open|close} ... */
83 struct mutex lock; /* ... helper function uses these */
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030084};
85
Linus Torvaldse90ff922007-09-13 21:09:01 -030086/* Class-dev to video-device */
Hans Verkuil22a04f12008-07-20 06:35:02 -030087#define to_video_device(cd) container_of(cd, struct video_device, dev)
Linus Torvaldse90ff922007-09-13 21:09:01 -030088
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030089/* Version 2 functions */
90extern int video_register_device(struct video_device *vfd, int type, int nr);
brandon@ifup.org539a7552008-06-20 22:58:53 -030091int video_register_device_index(struct video_device *vfd, int type, int nr,
92 int index);
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030093void video_unregister_device(struct video_device *);
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030094
95/* helper functions to alloc / release struct video_device, the
96 later can be used for video_device->release() */
97struct video_device *video_device_alloc(void);
98void video_device_release(struct video_device *vfd);
99
Hans Verkuil9c39d7e2008-07-21 07:51:45 -0300100#ifdef OBSOLETE_DEVDATA /* to be removed soon */
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -0300101/* helper functions to access driver private data. */
102static inline void *video_get_drvdata(struct video_device *dev)
103{
104 return dev->priv;
105}
106
107static inline void video_set_drvdata(struct video_device *dev, void *data)
108{
109 dev->priv = data;
110}
Mauro Carvalho Chehab38ee04f2006-08-08 09:10:01 -0300111
Mauro Carvalho Chehab38ee04f2006-08-08 09:10:01 -0300112/* Obsolete stuff - Still needed for radio devices and obsolete drivers */
113extern struct video_device* video_devdata(struct file*);
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -0300114extern int video_exclusive_open(struct inode *inode, struct file *file);
115extern int video_exclusive_release(struct inode *inode, struct file *file);
Mauro Carvalho Chehab38ee04f2006-08-08 09:10:01 -0300116#endif
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -0300117
118#endif /* _V4L2_DEV_H */