Jiri Slaby wrote:
# HG changeset patch # User Jiri Slaby jirislaby@gmail.com # Date 1191670121 -7200 # Node ID 3d81ec3f07e5b08a85add9e2319d7d5a2ba2895d # Parent 96e25bd5d144be49618335ae7130c8cde0230bf9 v4l2_extension: codingstyle approaching
this patch shouldn't contain any functional changes. only changes in whitespace, printk's loglevel, some optimisations (NULL == x to x == NULL), cast from/to void * removal, superfluous parenthesis removal etc.
Signed-off-by: Jiri Slaby jirislaby@gmail.com
diff --git a/linux/drivers/media/video/v4l2_extension/v4l2_extension-core.c b/linux/drivers/media/video/v4l2_extension/v4l2_extension-core.c --- a/linux/drivers/media/video/v4l2_extension/v4l2_extension-core.c +++ b/linux/drivers/media/video/v4l2_extension/v4l2_extension-core.c @@ -1,6 +1,4 @@ /*
- v4l2 extension module - extends some video device drivers
- coreutils part
@@ -24,12 +22,14 @@ #include "v4l2_extension.h"
/* ------------------------------------------------------------------ */ -#define dprintk(level,fmt, arg...) if (core_debug >= level) \
- printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg)
+#define dprintk(level, fmt, arg...) do { \
- if (core_debug >= level) \
printk(KERN_DEBUG "%s/0: " fmt, core->name, ## arg); \
+} while (0)
-static unsigned int core_debug = 0; -module_param(core_debug,int,0644); -MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); +static unsigned int core_debug; +module_param(core_debug, int, 0644); +MODULE_PARM_DESC(core_debug, "enable debug messages [core]");
/*
- Local variables:
diff --git a/linux/drivers/media/video/v4l2_extension/v4l2_extension-hlp.c b/linux/drivers/media/video/v4l2_extension/v4l2_extension-hlp.c --- a/linux/drivers/media/video/v4l2_extension/v4l2_extension-hlp.c +++ b/linux/drivers/media/video/v4l2_extension/v4l2_extension-hlp.c @@ -1,6 +1,4 @@ /*
- v4l2 extension module - extends some video device drivers
- helper daemon interface part
@@ -26,7 +24,7 @@ #define HELPER_IF_NAME "v4l2_extension"
/* helper_daemon states if the helper daemon has opened the driver */ -static int helper_daemon=0; +static unsigned int helper_daemon; static struct mutex helper_daemon_lock;
/* device management stuff */ @@ -38,9 +36,9 @@ static int helper_major;
- Helper daemon interface operations
*/
int v4l2ext_hlp_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) {
unsigned int cmd, unsigned long arg)
+{ return 0; }
@@ -54,32 +52,33 @@ static unsigned int v4l2ext_hlp_poll(str static unsigned int v4l2ext_hlp_poll(struct file *file, poll_table *wait) { struct helperd *dev = file->private_data;
- poll_wait(file, &dev->waitqueue, wait);
- return POLLIN | POLLRDNORM;
}
-static int v4l2ext_hlp_open(struct inode *inode, struct file *file) {
- struct helperd *dev = NULL;
+static int v4l2ext_hlp_open(struct inode *inode, struct file *file) +{
- struct helperd *dev;
- if(helper_daemon==1) {
- if (helper_daemon == 1) { return -EBUSY;
- }
- else {
- } else { mutex_lock(&helper_daemon_lock); /* Helper daemon is here */ helper_daemon = 1; mutex_unlock(&helper_daemon_lock); } /* allocate and initialize device private data structure */
- dev = kzalloc(sizeof(*dev),GFP_KERNEL);
- if (NULL == dev) {
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (dev == NULL) { printk("cannot allocate device.\n"); return -ENOMEM; }
init_waitqueue_head(&dev->waitqueue); file->private_data = dev;
return 0;
return 0;
} @@ -107,12 +106,12 @@ static const struct file_operations v4l2 .ioctl = v4l2ext_hlp_ioctl };
-int v4l2ext_hlp_init(void) {
+int v4l2ext_hlp_init(void) +{ /* Unnamed device creation */ helper_major = register_chrdev(0, HELPER_IF_NAME, &v4l2ext_hlp_fops);
- if(helper_major<0) {
printk(KERN_WARNING "v4l2_extension: unable to get major 0\n");
- if (helper_major < 0) {
return -EIO; }printk(KERN_WARNING "v4l2_extension: unable to get major\n");
diff --git a/linux/drivers/media/video/v4l2_extension/v4l2_extension-video.c b/linux/drivers/media/video/v4l2_extension/v4l2_extension-video.c --- a/linux/drivers/media/video/v4l2_extension/v4l2_extension-video.c +++ b/linux/drivers/media/video/v4l2_extension/v4l2_extension-video.c @@ -1,6 +1,4 @@ /*
- v4l2 extension module - extends some video device drivers
- v4l ioctl handling part
@@ -37,21 +35,23 @@ MODULE_LICENSE("GPL");
/* ------------------------------------------------------------------ */
-static unsigned int video_debug = 0; -module_param(video_debug,int,0644); +static unsigned int video_debug; +module_param(video_debug, int, 0644); MODULE_PARM_DESC(video_debug,"enable debug messages [video]");
-#define dprintk(level,fmt, arg...) if (video_debug >= level) \
- printk(KERN_DEBUG "v4l2_extension: " fmt, ## arg)
+#define dprintk(level,fmt, arg...) do { \
- if (video_debug >= level) \
printk(KERN_DEBUG "v4l2_extension: " fmt, ## arg); \
+} while (0)
static DEFINE_MUTEX(v4l2ext_lock); /* Device list management stuff. One entry per managed device */ static LIST_HEAD(v4l2ext_devlist); /* Bitmask marking allocated devices from 0 to V4L2EXT_MAXDEV */ /* This is useful for limiting the number of managed devices */ -static unsigned long v4l2ext_devused=0;
-static unsigned int video_nr[] = {[0 ... (V4L2EXT_MAXDEV - 1)] = UNSET }; +static unsigned long v4l2ext_devused;
+static unsigned int video_nr[] = { [0 ... (V4L2EXT_MAXDEV - 1)] = UNSET };
/* ------------------------------------------------------------------ */ /* Standard device driver I/O entry points implementation */ @@ -69,23 +69,23 @@ static int video_open(struct inode *inod list_for_each(list,&v4l2ext_devlist) { h = list_entry(list, struct v4l2ext, devlist); if (h->vdev->minor == minor) {
dev = h;
} }dev = h;
- if (NULL == dev)
- if (dev == NULL) return -ENODEV;
- file->private_data=dev;
- dprintk(1,"open %d\n",minor);
file->private_data = dev;
dprintk(1, "open %d\n", minor);
/* Now calling the base v4l2 driver's open to lock the device */ /* we pass a fake file structure that will be used each time a base v4l2 driver's entry point will need to be called */ base_dev = dev->base_vdev;
- if(base_dev->fops->open)
- if (base_dev->fops->open) return base_dev->fops->open(dev->fake_file.f_dentry->d_inode,
&(dev->fake_file));
else return -EINVAL;&dev->fake_file);
} @@ -96,8 +96,8 @@ video_read(struct file *file, char __use struct v4l2ext *dev = file->private_data; struct video_device *base_dev = dev->base_vdev;
- if(base_dev->fops->read)
return base_dev->fops->read(&(dev->fake_file),data,count,ppos);
- if (base_dev->fops->read)
else return -EINVAL;return base_dev->fops->read(&dev->fake_file, data, count, ppos);
} @@ -108,8 +108,8 @@ video_poll(struct file *file, struct pol struct v4l2ext *dev = file->private_data; struct video_device *base_dev = dev->base_vdev;
- if(base_dev->fops->poll)
return base_dev->fops->poll(&(dev->fake_file),wait);
- if (base_dev->fops->poll)
else return -EINVAL;return base_dev->fops->poll(&dev->fake_file,wait);
} @@ -119,21 +119,21 @@ static int video_release(struct inode *i struct v4l2ext *dev = file->private_data; struct video_device *base_dev = dev->base_vdev;
- if(base_dev->fops->release)
- if (base_dev->fops->release) return base_dev->fops->release(dev->fake_file.f_dentry->d_inode,
&(dev->fake_file));
else return -EINVAL;&dev->fake_file);
}
static int -video_mmap(struct file *file, struct vm_area_struct * vma) +video_mmap(struct file *file, struct vm_area_struct *vma) { struct v4l2ext *dev = file->private_data; struct video_device *base_dev = dev->base_vdev;
- if(base_dev->fops->mmap)
return base_dev->fops->mmap(&(dev->fake_file),vma);
- if (base_dev->fops->mmap)
else return -EINVAL;return base_dev->fops->mmap(&dev->fake_file, vma);
} @@ -141,248 +141,248 @@ video_mmap(struct file *file, struct vm_ /* ------------------------------------------------------------------ */ /* Specific v4l ioctl implementation using video_ioctl2 facility */ /* ------------------------------------------------------------------ */ -static int vidioc_querycap (struct file *file, void *priv, +static int vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *vc) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- int ret=0;
struct v4l2ext *dev = priv;
struct video_device *base_dev = dev->base_vdev;
int ret = 0;
/* FIXME: should call the helper daemon to extend capabilities */
- if(base_dev->vidioc_querycap) {
ret = base_dev->vidioc_querycap(&(dev->fake_file),
- if (base_dev->vidioc_querycap) {
ret = base_dev->vidioc_querycap(&dev->fake_file, dev->fake_file.private_data, vc);
strlcpy(vc->driver,dev->vdev->name,sizeof(vc->driver));
} return ret;strlcpy(vc->driver, dev->vdev->name, sizeof(vc->driver));
}
-static int vidioc_g_input (struct file *file, void *priv, unsigned int *input) -{
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_g_input)
return base_dev->vidioc_g_input(&(dev->fake_file),
+static int vidioc_g_input(struct file *file, void *priv, unsigned int *input) +{
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_g_input)
else return -EINVAL;return base_dev->vidioc_g_input(&dev->fake_file, dev->fake_file.private_data, input);
}
-static int vidioc_enum_input (struct file *file, void *priv, +static int vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *vi) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_enum_input)
return base_dev->vidioc_enum_input(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_enum_input)
else return -EINVAL;return base_dev->vidioc_enum_input(&dev->fake_file, dev->fake_file.private_data, vi);
}
-static int vidioc_s_input (struct file *file, void *priv, unsigned int input) -{
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_s_input)
return base_dev->vidioc_s_input(&(dev->fake_file),
+static int vidioc_s_input(struct file *file, void *priv, unsigned int input) +{
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_s_input)
else return -EINVAL;return base_dev->vidioc_s_input(&dev->fake_file, dev->fake_file.private_data, input);
}
-static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) -{
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_s_std)
return base_dev->vidioc_s_std(&(dev->fake_file),
+static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *id) +{
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_s_std)
else return -EINVAL;return base_dev->vidioc_s_std(&dev->fake_file, dev->fake_file.private_data, id);
}
-static int vidioc_g_tuner (struct file *file, void *priv, +static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *vt) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_g_tuner)
return base_dev->vidioc_g_tuner(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_g_tuner)
else return -EINVAL;return base_dev->vidioc_g_tuner(&dev->fake_file, dev->fake_file.private_data, vt);
}
-static int vidioc_s_tuner (struct file *file, void *priv, +static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *vt) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_s_tuner)
return base_dev->vidioc_s_tuner(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_s_tuner)
else return -EINVAL;return base_dev->vidioc_s_tuner(&dev->fake_file, dev->fake_file.private_data, vt);
}
-static int vidioc_g_frequency (struct file *file, void *priv, +static int vidioc_g_frequency(struct file *file, void *priv, struct v4l2_frequency *freq) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_g_frequency)
return base_dev->vidioc_g_frequency(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_g_frequency)
else return -EINVAL;return base_dev->vidioc_g_frequency(&dev->fake_file, dev->fake_file.private_data, freq);
}
-static int vidioc_s_frequency (struct file *file, void *priv, +static int vidioc_s_frequency(struct file *file, void *priv, struct v4l2_frequency *freq) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_s_frequency)
return base_dev->vidioc_s_frequency(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_s_frequency)
else return -EINVAL;return base_dev->vidioc_s_frequency(&dev->fake_file, dev->fake_file.private_data, freq);
}
-static int vidioc_g_audio (struct file *file, void *priv, struct v4l2_audio *a) -{
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_g_audio)
return base_dev->vidioc_g_audio(&(dev->fake_file),
+static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a) +{
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_g_audio)
else return -EINVAL;return base_dev->vidioc_g_audio(&dev->fake_file, dev->fake_file.private_data, a);
}
-static int vidioc_s_audio (struct file *file, void *priv, struct v4l2_audio *a) -{
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_s_audio)
return base_dev->vidioc_s_audio(&(dev->fake_file),
+static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a) +{
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_s_audio)
else return -EINVAL;return base_dev->vidioc_s_audio(&dev->fake_file, dev->fake_file.private_data, a);
}
-static int vidioc_queryctrl (struct file *file, void *priv, +static int vidioc_queryctrl(struct file *file, void *priv, struct v4l2_queryctrl *ctrl) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_queryctrl)
return base_dev->vidioc_queryctrl(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_queryctrl)
else return -EINVAL;return base_dev->vidioc_queryctrl(&dev->fake_file, dev->fake_file.private_data, ctrl);
}
-static int vidioc_g_ctrl (struct file *file, void *priv, +static int vidioc_g_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_g_ctrl)
return base_dev->vidioc_g_ctrl(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_g_ctrl)
else return -EINVAL;return base_dev->vidioc_g_ctrl(&dev->fake_file, dev->fake_file.private_data, ctrl);
}
-static int vidioc_s_ctrl (struct file *file, void *priv, +static int vidioc_s_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_s_ctrl)
return base_dev->vidioc_s_ctrl(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_s_ctrl)
else return -EINVAL;return base_dev->vidioc_s_ctrl(&dev->fake_file, dev->fake_file.private_data, ctrl);
}
-static int vidioc_reqbufs (struct file *file, +static int vidioc_reqbufs(struct file *file, void *priv, struct v4l2_requestbuffers *vr) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_reqbufs)
return base_dev->vidioc_reqbufs(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_reqbufs)
else return -EINVAL;return base_dev->vidioc_reqbufs(&dev->fake_file, dev->fake_file.private_data, vr);
}
-static int vidioc_querybuf (struct file *file, +static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *vb) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_querybuf)
return base_dev->vidioc_querybuf(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_querybuf)
else return -EINVAL;return base_dev->vidioc_querybuf(&dev->fake_file, dev->fake_file.private_data, vb);
}
-static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *vb) -{
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_qbuf)
return base_dev->vidioc_qbuf(&(dev->fake_file),
+static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *vb) +{
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_qbuf)
else return -EINVAL;return base_dev->vidioc_qbuf(&dev->fake_file, dev->fake_file.private_data, vb);
}
-static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *vb) -{
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_dqbuf)
return base_dev->vidioc_dqbuf(&(dev->fake_file),
+static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *vb) +{
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_dqbuf)
elsereturn base_dev->vidioc_dqbuf(&dev->fake_file, dev->fake_file.private_data, vb);
@@ -392,11 +392,11 @@ static int vidioc_streamon(struct file * static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type type) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_streamon)
return base_dev->vidioc_streamon(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_streamon)
elsereturn base_dev->vidioc_streamon(&dev->fake_file, dev->fake_file.private_data, type);
@@ -406,53 +406,53 @@ static int vidioc_streamoff(struct file static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type type) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_streamoff)
return base_dev->vidioc_streamoff(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_streamoff)
else return -EINVAL;return base_dev->vidioc_streamoff(&dev->fake_file, dev->fake_file.private_data, type);
}
-static int vidioc_enum_fmt_cap (struct file *file, void *priv, +static int vidioc_enum_fmt_cap(struct file *file, void *priv, struct v4l2_fmtdesc *vfd) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_enum_fmt_cap)
return base_dev->vidioc_enum_fmt_cap(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_enum_fmt_cap)
else return -EINVAL;return base_dev->vidioc_enum_fmt_cap(&dev->fake_file, dev->fake_file.private_data, vfd);
}
-static int vidioc_g_fmt_cap (struct file *file, void *priv, +static int vidioc_g_fmt_cap(struct file *file, void *priv, struct v4l2_format *vf) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_g_fmt_cap)
return base_dev->vidioc_g_fmt_cap(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_g_fmt_cap)
else return -EINVAL;return base_dev->vidioc_g_fmt_cap(&dev->fake_file, dev->fake_file.private_data, vf);
}
-static int vidioc_try_fmt_cap (struct file *file, void *priv, +static int vidioc_try_fmt_cap(struct file *file, void *priv, struct v4l2_format *vf) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_try_fmt_cap)
return base_dev->vidioc_try_fmt_cap(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_try_fmt_cap)
elsereturn base_dev->vidioc_try_fmt_cap(&dev->fake_file, dev->fake_file.private_data, vf);
@@ -462,11 +462,11 @@ static int vidioc_s_fmt_cap(struct file static int vidioc_s_fmt_cap(struct file *file, void *priv, struct v4l2_format *vf) {
- struct v4l2ext *dev = (struct v4l2ext *)priv;
- struct video_device *base_dev = dev->base_vdev;
- if(base_dev->vidioc_s_fmt_cap)
return base_dev->vidioc_s_fmt_cap(&(dev->fake_file),
- struct v4l2ext *dev = priv;
- struct video_device *base_dev = dev->base_vdev;
- if (base_dev->vidioc_s_fmt_cap)
elsereturn base_dev->vidioc_s_fmt_cap(&dev->fake_file, dev->fake_file.private_data, vf);
@@ -477,62 +477,61 @@ static int vidioc_s_fmt_cap(struct file /* ----------------------------------------------------------- */ /* exported stuff */
-static const struct file_operations video_fops = -{
- .owner = THIS_MODULE,
- .open = video_open,
- .release = video_release,
- .read = video_read,
- .poll = video_poll,
- .mmap = video_mmap,
- .ioctl = video_ioctl2,
- .llseek = no_llseek,
+static const struct file_operations video_fops = {
- .owner = THIS_MODULE,
- .open = video_open,
- .release = video_release,
- .read = video_read,
- .poll = video_poll,
- .mmap = video_mmap,
- .ioctl = video_ioctl2,
- .llseek = no_llseek,
};
static struct video_device v4l2ext_video_template = {
- .owner = THIS_MODULE,
- .type = 0, /* filled dynamically */
- .hardware = 0, /* filled dynamically */
- .fops = &video_fops,
- .name = "",
- .release = video_device_release,
- .minor = -1,
- .vidioc_querycap = vidioc_querycap,
- .vidioc_enum_fmt_cap = vidioc_enum_fmt_cap,
- .vidioc_g_fmt_cap = vidioc_g_fmt_cap,
- .vidioc_try_fmt_cap = vidioc_try_fmt_cap,
- .vidioc_s_fmt_cap = vidioc_s_fmt_cap,
- .vidioc_reqbufs = vidioc_reqbufs,
- .vidioc_querybuf = vidioc_querybuf,
- .vidioc_qbuf = vidioc_qbuf,
- .vidioc_dqbuf = vidioc_dqbuf,
- .vidioc_s_std = vidioc_s_std,
- .vidioc_enum_input = vidioc_enum_input,
- .vidioc_g_input = vidioc_g_input,
- .vidioc_s_input = vidioc_s_input,
- .vidioc_queryctrl = vidioc_queryctrl,
- .vidioc_g_audio = vidioc_g_audio,
- .vidioc_g_audio = vidioc_s_audio,
- .vidioc_g_ctrl = vidioc_g_ctrl,
- .vidioc_s_ctrl = vidioc_s_ctrl,
- .vidioc_streamon = vidioc_streamon,
- .vidioc_streamoff = vidioc_streamoff,
- .owner = THIS_MODULE,
- .type = 0, /* filled dynamically */
- .hardware = 0, /* filled dynamically */
- .fops = &video_fops,
- .name = "",
- .release = video_device_release,
- .minor = -1,
- .vidioc_querycap = vidioc_querycap,
- .vidioc_enum_fmt_cap = vidioc_enum_fmt_cap,
- .vidioc_g_fmt_cap = vidioc_g_fmt_cap,
- .vidioc_try_fmt_cap = vidioc_try_fmt_cap,
- .vidioc_s_fmt_cap = vidioc_s_fmt_cap,
- .vidioc_reqbufs = vidioc_reqbufs,
- .vidioc_querybuf = vidioc_querybuf,
- .vidioc_qbuf = vidioc_qbuf,
- .vidioc_dqbuf = vidioc_dqbuf,
- .vidioc_s_std = vidioc_s_std,
- .vidioc_enum_input = vidioc_enum_input,
- .vidioc_g_input = vidioc_g_input,
- .vidioc_s_input = vidioc_s_input,
- .vidioc_queryctrl = vidioc_queryctrl,
- .vidioc_g_audio = vidioc_g_audio,
- .vidioc_g_audio = vidioc_s_audio,
- .vidioc_g_ctrl = vidioc_g_ctrl,
- .vidioc_s_ctrl = vidioc_s_ctrl,
- .vidioc_streamon = vidioc_streamon,
- .vidioc_streamoff = vidioc_streamoff,
#ifdef CONFIG_VIDEO_V4L1_COMPAT -/* .vidiocgmbuf = vidiocgmbuf, */ +/* .vidiocgmbuf = vidiocgmbuf, */ #endif
- .vidioc_g_tuner = vidioc_g_tuner,
- .vidioc_s_tuner = vidioc_s_tuner,
- .vidioc_g_frequency = vidioc_g_frequency,
- .vidioc_s_frequency = vidioc_s_frequency,
- .tvnorms = 0,
- .current_norm = 0
- .vidioc_g_tuner = vidioc_g_tuner,
- .vidioc_s_tuner = vidioc_s_tuner,
- .vidioc_g_frequency = vidioc_g_frequency,
- .vidioc_s_frequency = vidioc_s_frequency,
- .tvnorms = 0,
- .current_norm = 0
};
/* ----------------------------------------------------------- */
static int v4l2ext_init(void) {
- printk(KERN_INFO "v4l2 extension module version %d.%d.%d loaded\n",
- printk(KERN_INFO "v4l2 extension module version %d.%d.%d loaded\n", (V4L2EXT_VERSION_CODE >> 16) & 0xff, (V4L2EXT_VERSION_CODE >> 8) & 0xff, V4L2EXT_VERSION_CODE & 0xff);
@@ -552,7 +551,7 @@ static void v4l2ext_fini(void) v4l2ext_hlp_fini();
/* remove any registered base v4l structure */
- list_for_each(list,&v4l2ext_devlist) {
- list_for_each(list, &v4l2ext_devlist) { h = list_entry(list, struct v4l2ext, devlist); v4l2ext_unregister(h->base_vdev); }
@@ -566,28 +565,28 @@ int v4l2ext_register(struct video_device struct v4l2ext *dev = NULL; struct inode *fake_inode = NULL; int nr;
- int ret=0;
int ret = 0;
mutex_lock(&v4l2ext_lock); /* check if we have not reached the maximum number of devices this extended driver can manage */
- nr=find_first_zero_bit(&v4l2ext_devused,V4L2EXT_MAXDEV);
- nr = find_first_zero_bit(&v4l2ext_devused, V4L2EXT_MAXDEV); if (nr >= V4L2EXT_MAXDEV) {
printk("This driver supports only %d device creations\n",
V4L2EXT_MAXDEV);
ret=-ENOSPC;
printk(KERN_ERR "This driver supports only %d device "
"creations\n", V4L2EXT_MAXDEV);
ret = -ENOSPC;
goto out_unlock; }
/* reserve this entry */
- v4l2ext_devused|=1<<nr;
v4l2ext_devused |= 1 << nr;
mutex_unlock(&v4l2ext_lock);
/* allocate and initialize device private data structure */
- dev = kzalloc(sizeof(*dev),GFP_KERNEL);
- if (NULL == dev) {
printk("cannot allocate device.\n");
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
- if (dev == NULL) {
ret = -ENOMEM; goto out_free; }printk(KERN_ERR "cannot allocate device.\n");
@@ -597,17 +596,17 @@ int v4l2ext_register(struct video_device
/* fill the fake parameters that will be passed to the v4l2 base driver entry point */
- fake_inode = kzalloc(sizeof(struct inode),GFP_KERNEL);
- if(NULL == fake_inode) {
printk("cannot allocate fake inode.\n");
- fake_inode = kzalloc(sizeof(struct inode), GFP_KERNEL);
- if (fake_inode == NULL) {
ret = -ENOMEM; goto out_free; } fake_inode->i_rdev = MKDEV(VIDEO_MAJOR, base_vdev->minor); dev->fake_file.f_dentry = kzalloc(sizeof(struct dentry), GFP_KERNEL);printk(KERN_ERR "cannot allocate fake inode.\n");
- if(NULL == dev->fake_file.f_dentry) {
printk("cannot allocate fake f_dentry.\n");
- if (dev->fake_file.f_dentry == NULL) {
ret = -ENOMEM; goto out_free; }printk(KERN_ERR "cannot allocate fake f_dentry.\n");
@@ -615,8 +614,8 @@ int v4l2ext_register(struct video_device
/* allocate and fill v4l2 device struct */ dev->vdev = video_device_alloc();
- if (NULL == dev->vdev) {
printk("cannot allocate video_device.\n");
- if (dev->vdev == NULL) {
ret = -ENOMEM; goto out_free; }printk(KERN_ERR "cannot allocate video_device.\n");
@@ -631,32 +630,34 @@ int v4l2ext_register(struct video_device dev->vdev->minor = -1; dev->vdev->dev = NULL; /* prefix with "Ext." the base device name */
- strcpy(dev->vdev->name,"Ext. ");
- strncpy(dev->vdev->name+5,
- strcpy(dev->vdev->name, "Ext. ");
- strncpy(dev->vdev->name + 5, base_vdev->name,
sizeof(dev->vdev->name)-5);
- if ((ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER,
video_nr[dev->dev_nr]))) {
printk("error on registering video device [%d].\n",
sizeof(dev->vdev->name) - 5);
- ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER,
video_nr[dev->dev_nr]);
- if (ret) {
printk(KERN_ERR "error on registering video device [%d].\n", dev->dev_nr);
ret=-ENODEV;
ret = -ENODEV;
goto out_free; }
mutex_lock(&v4l2ext_lock);
- list_add_tail(&dev->devlist,&v4l2ext_devlist);
list_add_tail(&dev->devlist, &v4l2ext_devlist);
mutex_unlock(&v4l2ext_lock);
- printk("v4l2_extension: Added (%s) driver extension\n",
printk(KERN_INFO "v4l2_extension: Added (%s) driver extension\n", dev->vdev->name);
return 0;
/* Error case, cleanup what must be cleaned */ out_free:
- v4l2ext_devused&=~(1<<nr);
- if(dev) video_device_release(dev->vdev);
- v4l2ext_devused &= ~(1 << nr);
- if (dev)
kfree(dev); kfree(fake_inode); kfree(dev->fake_file.f_dentry);video_device_release(dev->vdev);
@@ -672,7 +673,7 @@ void v4l2ext_unregister(struct video_dev void v4l2ext_unregister(struct video_device *base_vdev) { struct v4l2ext *h;
- struct v4l2ext *dev=NULL;
struct v4l2ext *dev = NULL; struct list_head *list;
mutex_lock(&v4l2ext_lock);
@@ -686,24 +687,23 @@ void v4l2ext_unregister(struct video_dev dev = h; } }
- if(dev != NULL) {
- if (dev != NULL) { list_del(&dev->devlist);
v4l2ext_devused&=~(1<<dev->dev_nr);
v4l2ext_devused &= ~(1 << dev->dev_nr);
/* unregister the corresponding v4l2 extended device entry point */ video_unregister_device(dev->vdev);
printk("V4l2 extension: Removed (%s) extension\n",
kfree(dev->fake_file.f_dentry->d_inode); kfree(dev->fake_file.f_dentry); kfree(dev);printk(KERN_INFO "V4l2 extension: Removed (%s) extension\n", base_vdev->name);
- }
- else {
printk("V4l2 extension: could not find any %s extension!\n",
base_vdev->name);
} else {
printk(KERN_ERR "V4l2 extension: could not find any %s "
"extension!\n", base_vdev->name);
}
mutex_unlock(&v4l2ext_lock);
diff --git a/linux/drivers/media/video/v4l2_extension/v4l2_extension.h b/linux/drivers/media/video/v4l2_extension/v4l2_extension.h --- a/linux/drivers/media/video/v4l2_extension/v4l2_extension.h +++ b/linux/drivers/media/video/v4l2_extension/v4l2_extension.h @@ -1,5 +1,4 @@ /*
- v4l2 extension module - extends some video device drivers to provide
standard video formats using userspace helper
daemon
Patch committed at http://linuxtv.org/hg/~tmerle/v4l2_extension/
Thierry