blob: e472b5d07a55b244c9aafdb02cd626d8d17f6666 [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 */
86extern int video_register_device(struct video_device *vfd, int type, int nr);
brandon@ifup.org539a7552008-06-20 22:58:53 -030087int video_register_device_index(struct video_device *vfd, int type, int nr,
88 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() */
93struct video_device *video_device_alloc(void);
94void video_device_release(struct video_device *vfd);
95
Hans Verkuil9c39d7e2008-07-21 07:51:45 -030096#ifdef OBSOLETE_DEVDATA /* to be removed soon */
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -030097/* helper functions to access driver private data. */
98static inline void *video_get_drvdata(struct video_device *dev)
99{
100 return dev->priv;
101}
102
103static inline void video_set_drvdata(struct video_device *dev, void *data)
104{
105 dev->priv = data;
106}
Mauro Carvalho Chehab38ee04f2006-08-08 09:10:01 -0300107
Mauro Carvalho Chehab38ee04f2006-08-08 09:10:01 -0300108/* Obsolete stuff - Still needed for radio devices and obsolete drivers */
109extern struct video_device* video_devdata(struct file*);
Mauro Carvalho Chehab38ee04f2006-08-08 09:10:01 -0300110#endif
Mauro Carvalho Chehab401998f2006-06-04 10:06:18 -0300111
112#endif /* _V4L2_DEV_H */