To stop further mailing, go here or write:
PinPointMediaServices, 4255 E. Charleston Blvd. Suite D-345 Las Vegas. NV 89104
PinPointMediaServices, 4255 E. Charleston Blvd. Suite D-345 Las Vegas. NV 89104
Patch says it all. Comments appreciated, but please keep me on CC: as I'm not subscribed to LKML. Cheers From dea35acfe9ef161fb44cc0efbbd700472f5f1bc9 Mon Sep 17 00:00:00 2001 From: Bastien Nocera < had ... @ > Date: Tue, 2 Dec 2008 19:03:06 +0000 Subject: [PATCH] [ov511] Export snapshot button through input layer Register an input device with one button, and for the supported OV511 webcams, poll and check whether the snapshot button has been pressed on each new frame. --- drivers/media/video/ov511.c | 84 +++++++++++++++++++++++++++++++++++++++++- drivers/media/video/ov511.h | 1 + 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c index 210f124..bad665b 100644 --- a/drivers/media/video/ov511.c +++ b/drivers/media/video/ov511.c @@ -352,6 +352,73 @@ rvfree(void *mem, unsigned long size) /********************************************************************** * + * Input device + * + **********************************************************************/ +#ifdef CONFIG_OV511_INPUT_EVDEV +#warn foobar +static int ov511_input_init(struct usb_ov511 *ov) +{ + struct usb_device *udev = ov->udev; + struct input_dev *input; + char *phys = NULL; + int ret; + + input = input_allocate_device(); + if (input == NULL) + return -ENOMEM; + + phys = kmalloc(6 + strlen(udev->bus->bus_name) + strlen(udev->devpath), + GFP_KERNEL); + if (phys == NULL) { + ret = -ENOMEM; + goto error; + } + sprintf(phys, "usb-%s-%s", udev->bus->bus_name, udev->devpath); + + input->name = ov->name; + input->phys = phys; + usb_to_input_id(udev, &input->id); + input->dev.parent = &ov->intf->dev; + + set_bit(EV_KEY, input->evbit); + set_bit(KEY_CAMERA, input->keybit); + + if ((ret = input_register_device(input)) < 0) + goto error; + + ov->key_input = input; + return 0; + +error: + input_free_device(input); + kfree(phys); + return ret; +} + +static void ov511_input_cleanup(struct usb_ov511 *ov) +{ + if (ov->key_input) + input_unregister_device(ov->key_input); +} + +static void ov511_input_report_key(struct usb_ov511 *ov, unsigned int code, + int value) +{ + if (ov->key_input) { + input_report_key(ov->key_input, code, value); + input_sync(ov->key_input); + } +} + +#else +#define ov511_input_init(dev) 0 +#define ov511_input_cleanup(dev) +#define ov511_input_report_key(dev, code, value) +