Skip to contentSkip to conversation

Add gspca subdriver for Speedlink VAD Laplace (EM2765+OV2640)

PATCH Superseded Frank Schäfer 1 participant 2 messages Mar 16, 2012 – Mar 21, 2012 1 message not in the archive Media (V4L/DVB)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add gspca subdriver for Speedlink VAD Laplace (EM2765+OV2640)

This patch is the result of 3 months of reverse engineering work.
It is NOT intended for kernel inclusion.
No decision has been made yet wether support for this device should be added this way or as enhancement/modification of the em28xx driver. Hence the main purpose of this patch is to provide an insight into the charactersitics and functionality of this device. Anyway, I would be glad to get some feedback concerning form and content of the code, becausse I'm still a newbie to kernel programming.

The driver is feature complete and working stable, but some cleanups are outstanding (see coments). For a better understanding of the device, see http://linuxtv.org/wiki/index.php/VAD_Laplace

---
 drivers/media/video/gspca/Kconfig  |    9 +
 drivers/media/video/gspca/Makefile |    2 +
 drivers/media/video/gspca/em27xx.c | 1822 ++++++++++++++++++++++++++++++++++++
 drivers/media/video/gspca/gspca.c  |    5 +-
 4 files changed, 1836 insertions(+), 2 deletions(-)
 create mode 100644 drivers/media/video/gspca/em27xx.c
drivers/media/video/gspca/Kconfig +9 -0
index dfe268b..02c0c2a 100644
@@ -50,6 +50,15 @@ config USB_GSPCA_CPIA1
 	  To compile this driver as a module, choose M here: the
 	  module will be called gspca_cpia1.
 
+config USB_GSPCA_EM27XX
+	tristate "EM27xx USB Camera Driver"
+	depends on VIDEO_V4L2 && USB_GSPCA
+	help
+	  Say Y here if you want support for EM27xx cameras.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called gspca_em27xx.
+
 config USB_GSPCA_ETOMS
 	tristate "Etoms USB Camera Driver"
 	depends on VIDEO_V4L2 && USB_GSPCA
drivers/media/video/gspca/Makefile +2 -0
index 79ebe46..8c2bd29 100644
@@ -2,6 +2,7 @@ obj-$(CONFIG_USB_GSPCA)          += gspca_main.o
 obj-$(CONFIG_USB_GSPCA_BENQ)     += gspca_benq.o
 obj-$(CONFIG_USB_GSPCA_CONEX)    += gspca_conex.o
 obj-$(CONFIG_USB_GSPCA_CPIA1)    += gspca_cpia1.o
+obj-$(CONFIG_USB_GSPCA_EM27XX)   += gspca_em27xx.o
 obj-$(CONFIG_USB_GSPCA_ETOMS)    += gspca_etoms.o
 obj-$(CONFIG_USB_GSPCA_FINEPIX)  += gspca_finepix.o
 obj-$(CONFIG_USB_GSPCA_JEILINJ)  += gspca_jeilinj.o
@@ -47,6 +48,7 @@ gspca_main-objs     := gspca.o
 gspca_benq-objs     := benq.o
 gspca_conex-objs    := conex.o
 gspca_cpia1-objs    := cpia1.o
+gspca_em27xx-objs   := em27xx.o
 gspca_etoms-objs    := etoms.o
 gspca_finepix-objs  := finepix.o
 gspca_jeilinj-objs  := jeilinj.o
drivers/media/video/gspca/em27xx.c new file +1822 -0

1,822 lines not on this page · raw message

drivers/media/video/gspca/gspca.c +3 -2
index ca5a2b1..4414c09 100644
@@ -2348,6 +2348,9 @@ int gspca_dev_probe2(struct usb_interface *intf,
 	gspca_dev->nbufread = 2;
 	gspca_dev->empty_packet = -1;	/* don't check the empty packets */
 
+	mutex_init(&gspca_dev->usb_lock);
+	mutex_init(&gspca_dev->queue_lock);
+	
 	/* configure the subdriver and initialize the USB device */
 	ret = sd_desc->config(gspca_dev, id);
 	if (ret < 0)
@@ -2363,8 +2366,6 @@ int gspca_dev_probe2(struct usb_interface *intf,
 	if (ret)
 		goto out;
 
-	mutex_init(&gspca_dev->usb_lock);
-	mutex_init(&gspca_dev->queue_lock);
 	init_waitqueue_head(&gspca_dev->wq);
 
 	/* init video stuff */
Signature · 1 line
1.7.7

A message that is not in the archive (sent off-list or not yet received): 20120317141125.25774742@tele

#2 lore raw

Am 17.03.2012 14:11, schrieb Jean-Francois Moine:

Quoted 37 lines
Quoted 1 line · On Fri, 16 Mar 2012 23:15:45 +0100 Frank Schäfer…

Anyway, I would be glad to get some feedback concerning form and content of the code, becausse I'm still a newbie to kernel programming.

Hi Frank,

I agree that writing a new gspca subdriver is easier than extending some other video driver...

Here are some remarks:

- you should not start the workqueue button_check immediately because the webcam hardware is not fully initialized in sd_config(). Instead, you may check gspca_dev->present or have a greater delay (1s) in sd_config(). This also avoids to patch the gspca main.

- usually, the sensor reset ('12 80' for Omnivision - 2nd item in ov2640_init) asks for some time. So, a little delay (200 ms) is welcome.

- I am not sure that looping on usb_control_msg() on read or write error does help.

- the debug flags D_USBI and D_USBO are no more available. It is easier to use usbmon to trace the exchanges.

- using the new control mechanism removes a lot of code (see stk014.c).

- using the gspca variable 'usb_err' avoids testing each USB write (during probe, you may use a flag to skip printing error messages).

- in the form:

- you must use

module_usb_driver(sd_driver);

Quoted 9 lines

to replace the module stuff.

- don't use C++ comments

- the code may be optimized, as replacing the sequences of write_prop_single() calls by a loop and a table.

Best regards.

Hi Jean-Francois,

thanks for your remarks !
I will incoorporate them in case that a decision for a gspca subdriver is made.

Regards,
Frank