videodev redesign -- #3
Hi,
A new batch of patches for 2.5.5-pre1 is available from
http://bytesex.org/patches/2.5/
New are the video_exclusive_open/release functions. While fixing the radio drivers I've noticed they all had open/close functions doing exactly the same, so I've moved that to videodev.c ...
The full description of the patches and the videodev patch itself are below...
Gerd
=========================== [ cut here ] ===========================
Patch descriptions
------------------
00_*
Some trivial build fixes (might be present or not ...).
10_videodev
videodev.[ch] redesign. It does:
* drop the function pointers (read/write/mmap/poll/...) from struct video_device, use struct file_operations directly instead. Dispatching to different drivers by minor number is done the same way soundcore.o handles this: swap file->f_fops at open() time.
* also drop the now obsolete video_red/write/mmap/poll/... functions from videodev.c
* provide a video_generic_ioctl() function which can (and should) be used by v4l drivers to handle copying from and to userspace.
* provide video_exclusive_open/release functions which can be used by v4l drivers to make sure only one process at a time opens the device. They can be hooked directly into struct file_operations if some driver has nothing to initialize at open time (which is true for many drivers in drivers/media/radio/).
20_*
Patches to adopt drivers to the new videodev interface. For now I've fixed all drivers below drivers/media/, unless they are broken due to virt_to_bus() being gone anyway.
ov511 updates are here:
http://alpha.dyndns.org/ov511/download.html
The other USB cam drivers are not updated yet.
30_bttv-i2c
Update the small bttv i2c helper modules (tuner, tvaudio, msp3400, ...) to the latest versions (bttv 0.7.x).
31_bttv
Major bttv update (0.7.x => 0.8.x). Changes:
* Uses new videodev interface.
* Rewrite of the drivers core code (memory management, capture code paths, ...), drops lot of historical cruft.
* v4l2 support (compile time option, needs additional v4l2 patch to work actually).
patch-<version>
[x] all of the above
=========================== [ cut here ] ===========================
include/linux/videodev.h +42 -17
@@ -4,6 +4,18 @@#include <linux/types.h> #include <linux/version.h> +#if 0 +/* +* v4l2 is still work-in-progress, integration planed for 2.5.x +* v4l2 project homepage: http://www.thedirks.org/v4l2/ +* patches available from: http://bytesex.org/patches/ +*/ +# define HAVE_V4L2 1 +# include <linux/videodev2.h> +#else +# undef HAVE_V4L2 +#endif +#ifdef __KERNEL__#include <linux/poll.h>
@@ -13,24 +25,25 @@struct video_device {struct module *owner; -char name[32 ]; -int type; +char name[32 ]; +int type;/* v4l1 */ +int type2;/* v4l2 */ int hardware; +int minor; -int (*open)(struct video_device *,int mode); -void (*close)(struct video_device *); -long (*read)(struct video_device *,char *,unsigned long ,int noblock); -/* Do we need a write method ? */ -long (*write)(struct video_device *,const char *,unsigned long ,int noblock); -#if LINUX_VERSION_CODE >=0x020100 -unsigned int (*poll)(struct video_device *,struct file *,poll_table *); -#endif -int (*ioctl)(struct video_device *,unsigned int ,void *); -int (*mmap)(struct vm_area_struct *vma,struct video_device *,const char *,unsigned long ); -int (*initialize)(struct video_device *); +/* new interface -- we will use file_operations directly +* like soundcore does. +* kernel_ioctl() will be called by video_generic_ioctl. +* video_generic_ioctl() does the userspace copying of the +* ioctl arguments */ +struct file_operations *fops; +int (*kernel_ioctl)(struct inode *inode,struct file *file, +unsigned int cmd,void *arg);void *priv;/* Used to be 'private' but that upsets C++ */ -int busy; -int minor; + +/* for videodev.c intenal usage -- don't touch */ +int users; +struct semaphore lock;devfs_handle_t devfs_handle; };
@@ -43,8 +56,13 @@#define VFL_TYPE_VTX 3extern void video_unregister_device (struct video_device *); -#endif +extern struct video_device *video_devdata (struct file *); +extern int video_exclusive_open (struct inode *inode,struct file *file); +extern int video_exclusive_release (struct inode *inode,struct file *file); +extern int video_generic_ioctl (struct inode *inode,struct file *file, +unsigned int cmd,unsigned long arg); +#endif /* __KERNEL__ */ #define VID_TYPE_CAPTURE 1/* Can capture */ #define VID_TYPE_TUNER 2/* Can tune */
@@ -150,6 +168,7 @@#define VIDEO_AUDIO_VOLUME 4#define VIDEO_AUDIO_BASS 8#define VIDEO_AUDIO_TREBLE 16 +#define VIDEO_AUDIO_BALANCE 32char name[16 ];#define VIDEO_SOUND_MONO 1#define VIDEO_SOUND_STEREO 2
@@ -379,4 +398,10 @@#define VID_HARDWARE_MEYE 32/* Sony Vaio MotionEye cameras */ #define VID_HARDWARE_CPIA2 33 -#endif +#endif /* __LINUX_VIDEODEV_H */ + +/* +* Local variables: +* c-basic-offset: 8 +* End: +*/
drivers/media/video/videodev.c +98 -129
323 lines not on this page · raw message