Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 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 | |
Mauro Carvalho Chehab | 38ee04f | 2006-08-08 09:10:01 -0300 | [diff] [blame] | 12 | #define OBSOLETE_DEVDATA 1 /* to be removed soon */ |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 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 */ |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 19 | #include <linux/videodev2.h> |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 20 | |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 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 | |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 37 | struct v4l2_ioctl_callbacks; |
| 38 | |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 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 | */ |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 44 | |
| 45 | struct video_device |
| 46 | { |
| 47 | /* device ops */ |
Mauro Carvalho Chehab | 5e87efa | 2006-06-05 10:26:32 -0300 | [diff] [blame] | 48 | const struct file_operations *fops; |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 49 | |
Kay Sievers | 54bd5b6 | 2007-10-08 16:26:13 -0300 | [diff] [blame] | 50 | /* sysfs */ |
Hans Verkuil | 22a04f1 | 2008-07-20 06:35:02 -0300 | [diff] [blame] | 51 | struct device dev; /* v4l device */ |
Hans Verkuil | 5e85e73 | 2008-07-20 06:31:39 -0300 | [diff] [blame] | 52 | struct device *parent; /* device parent */ |
Kay Sievers | 54bd5b6 | 2007-10-08 16:26:13 -0300 | [diff] [blame] | 53 | |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 54 | /* device info */ |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 55 | char name[32]; |
Hans Verkuil | 0ea6bc8 | 2008-07-26 08:26:43 -0300 | [diff] [blame] | 56 | int vfl_type; |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 57 | int minor; |
Hans Verkuil | de1e575 | 2008-07-26 08:37:58 -0300 | [diff] [blame] | 58 | /* attribute to differentiate multiple indices on one physical device */ |
brandon@ifup.org | 539a755 | 2008-06-20 22:58:53 -0300 | [diff] [blame] | 59 | int index; |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 60 | |
Hans Verkuil | 22a04f1 | 2008-07-20 06:35:02 -0300 | [diff] [blame] | 61 | int debug; /* Activates debug level*/ |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 62 | |
| 63 | /* Video standard vars */ |
Mauro Carvalho Chehab | e75f9ce | 2006-11-20 13:19:20 -0300 | [diff] [blame] | 64 | v4l2_std_id tvnorms; /* Supported tv norms */ |
| 65 | v4l2_std_id current_norm; /* Current tvnorm */ |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 66 | |
| 67 | /* callbacks */ |
| 68 | void (*release)(struct video_device *vfd); |
| 69 | |
| 70 | /* ioctl callbacks */ |
Hans Verkuil | a399810 | 2008-07-21 02:57:38 -0300 | [diff] [blame] | 71 | const struct v4l2_ioctl_ops *ioctl_ops; |
Trent Piepho | dbbff48 | 2007-01-22 23:31:53 -0300 | [diff] [blame] | 72 | |
Hans Verkuil | 9c39d7e | 2008-07-21 07:51:45 -0300 | [diff] [blame] | 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; |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 79 | #endif |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 80 | }; |
| 81 | |
Linus Torvalds | e90ff92 | 2007-09-13 21:09:01 -0300 | [diff] [blame] | 82 | /* Class-dev to video-device */ |
Hans Verkuil | 22a04f1 | 2008-07-20 06:35:02 -0300 | [diff] [blame] | 83 | #define to_video_device(cd) container_of(cd, struct video_device, dev) |
Linus Torvalds | e90ff92 | 2007-09-13 21:09:01 -0300 | [diff] [blame] | 84 | |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 85 | /* Version 2 functions */ |
| 86 | extern int video_register_device(struct video_device *vfd, int type, int nr); |
brandon@ifup.org | 539a755 | 2008-06-20 22:58:53 -0300 | [diff] [blame] | 87 | int video_register_device_index(struct video_device *vfd, int type, int nr, |
| 88 | int index); |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 89 | void video_unregister_device(struct video_device *); |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 90 | |
| 91 | /* helper functions to alloc / release struct video_device, the |
| 92 | later can be used for video_device->release() */ |
| 93 | struct video_device *video_device_alloc(void); |
| 94 | void video_device_release(struct video_device *vfd); |
| 95 | |
Hans Verkuil | 9c39d7e | 2008-07-21 07:51:45 -0300 | [diff] [blame] | 96 | #ifdef OBSOLETE_DEVDATA /* to be removed soon */ |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 97 | /* helper functions to access driver private data. */ |
| 98 | static inline void *video_get_drvdata(struct video_device *dev) |
| 99 | { |
| 100 | return dev->priv; |
| 101 | } |
| 102 | |
| 103 | static inline void video_set_drvdata(struct video_device *dev, void *data) |
| 104 | { |
| 105 | dev->priv = data; |
| 106 | } |
Mauro Carvalho Chehab | 38ee04f | 2006-08-08 09:10:01 -0300 | [diff] [blame] | 107 | |
Mauro Carvalho Chehab | 38ee04f | 2006-08-08 09:10:01 -0300 | [diff] [blame] | 108 | /* Obsolete stuff - Still needed for radio devices and obsolete drivers */ |
| 109 | extern struct video_device* video_devdata(struct file*); |
Mauro Carvalho Chehab | 38ee04f | 2006-08-08 09:10:01 -0300 | [diff] [blame] | 110 | #endif |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 111 | |
| 112 | #endif /* _V4L2_DEV_H */ |