Hello, After a [big] while, here is the helper daemon creation. It does nothing but wait for a driver event. There is no uplink event sent to it yet. The helper daemon is in v4l2-apps/v4l2ext_helper and is launched automatically via a udev rule. It is needed to compile and install it before use.
The basic requirement to connect a v4l2 driver to this helper daemon is to use video_ioctl2 facility. Well, if the driver is already v4l2 compliant this is a small step (see the usbvision example) If you want to adapt a driver to experiment this infrastructure, please tell me, I may help to do that.
This patch is committed here to ease the code review: http://linuxtv.org/hg/~tmerle/v4l2_extension/
Cheers, Thierry
Patch: v4l2_extension: creation of the helper daemon
Signed-off-by: Thierry Merle thierry.merle@free.fr
On 10/03/2007 09:49 PM, Thierry Merle wrote:
Hello, After a [big] while, here is the helper daemon creation. It does nothing but wait for a driver event. There is no uplink event sent to it yet. The helper daemon is in v4l2-apps/v4l2ext_helper and is launched automatically via a udev rule. It is needed to compile and install it before use.
The basic requirement to connect a v4l2 driver to this helper daemon is to use video_ioctl2 facility. Well, if the driver is already v4l2 compliant this is a small step (see the usbvision example) If you want to adapt a driver to experiment this infrastructure, please tell me, I may help to do that.
This patch is committed here to ease the code review: http://linuxtv.org/hg/~tmerle/v4l2_extension/
Thanks for you work on it, my $0.02 follows
+static int v4l2ext_hlp_open(struct inode *inode, struct file *file) { + struct helperd *dev = NULL; + + if(helper_daemon==1) { + return -EBUSY; + } + else { + mutex_lock(&helper_daemon_lock); + /* Helper daemon is here */ + helper_daemon = 1; + mutex_unlock(&helper_daemon_lock); + }
this is racy. mutex_lock also the test, otherwise if(helper_daemon==1) "no" | | - re-scheduled switch if(helper_daemon==1) "no" helper_daemon = 1; i'm the one | | ... re-scheduled switch helper_daemon = 1; and so am I
+ /* allocate and initialize device private data structure */ + dev = kzalloc(sizeof(*dev),GFP_KERNEL); + if (NULL == dev) {
better dev == NULL (some arch's optimisations)
+ printk("cannot allocate device.\n");
some KERN_ prefix
+ return -ENOMEM; + } + + init_waitqueue_head(&dev->waitqueue); + file->private_data = dev; + return 0; + + return 0;
:)
[...] + /* 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"); + return -EIO; + } + + /* create a driver class in order to automate udev */ + helper_class = class_create(THIS_MODULE, HELPER_IF_NAME); + if (!helper_class)
unregister_chrdev() here.
+ return -EINVAL; + + class_device_create(helper_class, + NULL, + MKDEV(helper_major, 0), + NULL, HELPER_IF_NAME); + + mutex_init(&helper_daemon_lock);
you should init it before register_chrdev (before you potentionally may use it).
Patch: v4l2_extension: creation of the helper daemon
Signed-off-by: Thierry Merle thierry.merle@free.fr
regards,