blob: 23df00919ae8718c227df2a0bbbec8dca98f4fc7 [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;
Hans Verkuilde1e5752008-07-26 08:37:58 -030058 /* attribute to differentiate multiple indices on one physical device */
brandon@ifup.org539a7552008-06-20 22:58:53 -030059 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
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030080};
81
Linus Torvaldse90ff922007-09-13 21:09:01 -030082/* Class-dev to video-device */
Hans Verkuil22a04f12008-07-20 06:35:02 -030083#define to_video_device(cd) container_of(cd, struct video_device, dev)
Linus Torvaldse90ff922007-09-13 21:09:01 -030084
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030085/* Version 2 functions */
Hans Verkuile138c592008-08-23 06:38:11 -030086int __must_check video_register_device(struct video_device *vfd, int type, int nr);
87int __must_check video_register_device_index(struct video_device *vfd, int type, int nr,
brandon@ifup.org539a7552008-06-20 22:58:53 -030088 int index);
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030089void video_unregister_device(struct video_device *);
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030090
91/* helper functions to alloc / release struct video_device, the
92 later can be used for video_device->release() */
Hans Verkuile138c592008-08-23 06:38:11 -030093struct video_device * __must_check video_device_alloc(void);
Hans Verkuilf9e86b52008-08-23 05:47:41 -030094/* this release function frees the vfd pointer */
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030095void video_device_release(struct video_device *vfd);
Hans Verkuilf9e86b52008-08-23 05:47:41 -030096/* 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);
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -0300100
Hans Verkuil9c39d7e2008-07-21 07:51:45 -0300101#ifdef OBSOLETE_DEVDATA /* to be removed soon */
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -0300102/* 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}
Mauro Carvalho Chehab38ee04f2006-08-08 09:10:01 -0300112
Mauro Carvalho Chehab38ee04f2006-08-08 09:10:01 -0300113/* Obsolete stuff - Still needed for radio devices and obsolete drivers */
114extern struct video_device* video_devdata(struct file*);
Mauro Carvalho Chehab38ee04f2006-08-08 09:10:01 -0300115#endif
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -0300116
117#endif /* _V4L2_DEV_H */