Add support for OmniVision OV534 based USB cameras.
PATCH 1/1 Add support for OmniVision OV534 based USB cameras.
Adds suport for OmniVision OV534 based cameras:
- Hercules Blog Webcam
- Hercules Dualpix HD Webcam
- Sony HD PS3 Eye (SLEH 00201)
Currently only supports 640x480 YUYV non-interlaced output.
---
linux/Documentation/video4linux/ov534.txt new file +30 -0
@@ -0,0 +1,30 @@ +OmniVision OV534 USB2.0 Camera driver. +Written by Mark Ferrell <majortrips--a.t--gmail.com> + +The OV534 is the chipset used by the Hercules Blog Webcam and Hercules Dualpix +HD Webcam. A variation of this chip, the ov538, is used Sony's HD PS3 Eye +(SLEH 00201). There is currently no known public information about what is +different between the ov534 and the ov538. + +The original code for initializating the camera and retrieving an image from it +was written by Jim Paris on ps2dev.org and submitted under the GPL. It is my +understanding that Jim sniffed the USB traffic to see what the Playstation3 was +sending to the camera to initialize it and to start/stop captures. + +The V4L interface of the driver was based on the vivi driver with the only +functionality changes being the addition of USB support, the addition of Jim's +control code, and a rewrite of the buffer fill code to pull directly from the +camera. + +The ov534 outputs frames in YUYV format, non-interlaced, at 640x480. This +format does not yet have wide support among user-land applications. Though at +the time of this writing xawtv was known to work correctly. + +Online information about the ov534 claims that it is capable of handling +320x240 resolutions as well as supporting JPEG compression, but the commands to +toggle the size and compression are currently unknown. + +If you use the camera with Xawtv you need to force the output resolution to +640x480 with the geometry command. i.e. xawtv -geometry 640x480 + +Good Luck
linux/drivers/media/video/Kconfig +11 -0
@@ -970,6 +970,17 @@ config USB_S2255 Say Y here if you want support for the Sensoray 2255 USB device. This driver can be compiled as a module, called s2255drv. +config USB_OV534 + tristate "USB OV534 Camera support" + depends on VIDEO_V4L2 + select VIDEOBUF_VMALLOC + default n + help + Say Y here if you want support for OV534 based USB cameras. + Hercules Blog Webcam, Hercules Dualpix HD Webcam, and the + Sony HD Eye for PS3 (SLEH 00201). + This driver can be compiled as a module, called ov534. + endif # V4L_USB_DRIVERS endif # VIDEO_CAPTURE_DRIVERS
linux/drivers/media/video/Makefile +1 -0
@@ -110,6 +110,7 @@ obj-$(CONFIG_VIDEO_TCM825X) += tcm825x.o obj-$(CONFIG_USB_DABUSB) += dabusb.o obj-$(CONFIG_USB_OV511) += ov511.o +obj-$(CONFIG_USB_OV534) += ov534.o obj-$(CONFIG_USB_SE401) += se401.o obj-$(CONFIG_USB_STV680) += stv680.o obj-$(CONFIG_USB_W9968CF) += w9968cf.o
linux/drivers/media/video/ov534.c new file +1411 -0
1,411 lines not on this page · raw message
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 8 lines · [email protected] wrote:
Adds suport for OmniVision OV534 based cameras:
- Hercules Blog Webcam
- Hercules Dualpix HD Webcam
- Sony HD PS3 Eye (SLEH 00201)Currently only supports 640x480 YUYV non-interlaced output.
Signed-off-by Mark Ferrell <[email protected]>
Hi Mark,
Have you taken a look at the ov519 driver which is currently in gspca, which is
in 2.6.27rc1 and more general (latest version) available here:
http://linuxtv.org/hg/~jfrancois/gspca/
That driver does do jpeg, maybe it can give some clues. gspca is a webcam driver framework. Would you consider porting your driver to gspca, I (we ?) really want to see all usb webcam drivers start using the gspca framework to share as much code as possible.
linux/Documentation/video4linux/ov534.txt line 22
Quoted 4 lines
linux/Documentation/video4linux/ov534.txt new file +4
-0+The ov534 outputs frames in YUYV format, non-interlaced, at 640x480. This +format does not yet have wide support among user-land applications. Though at +the time of this writing xawtv was known to work correctly. +
This (custom cam formats) was a big problem with gspca too, for this I've written libv4l, which is a library which does format conversion from many cam specific formats to more general formats in userspace. A joined effort between Debian, Suse and Fedora is currently working on making all v4l apps use libv4l, patches have already been written for gstreamer (cheese), pwlib (ekiga) and xawtv.
For more on libv4l see:
http://hansdegoede.livejournal.com/3636.html
http://linuxtv.org/v4lwiki/index.php/Libv4l_Progress
Maybe you can write a patch to add YUYV input support to libv4l, if you do that please base your work on the latest version which is available here:
http://linuxtv.org/hg/~hgoede/v4l-dvb
Regards,
Hans
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 10 lines · Hans de Goede
Quoted 6 lines · [email protected] wrote:
Adds suport for OmniVision OV534 based cameras:
- Hercules Blog Webcam
- Hercules Dualpix HD Webcam
- Sony HD PS3 Eye (SLEH 00201)
Currently only supports 640x480 YUYV non-interlaced output.Signed-off-by Mark Ferrell <[email protected]>Hi Mark,
Quoted 8 lines
Have you taken a look at the ov519 driver which is currently in gspca, which is in 2.6.27rc1 and more general (latest version) available here:
http://linuxtv.org/hg/~jfrancois/gspca/That driver does do jpeg, maybe it can give some clues. gspca is a webcam driver framework. Would you consider porting your driver to gspca, I (we ?) really want to see all usb webcam drivers start using the gspca framework to share as much code as possible.
I would definitely be willing to merge the code into an existing driver, though I was under the impression that the gspca core was for ISOC based USB devices. The ov534's imagine end-point is bulk transfer, with the audio endpoints being isoc.
Quoted 13 lines
Review
Quoted 5 lines
(quoted diff) +2
-0+The ov534 outputs frames in YUYV format, non-interlaced, at 640x480. This +format does not yet have wide support among user-land applications.Though at
(quoted diff) +2
-0+the time of this writing xawtv was known to work correctly. +This (custom cam formats) was a big problem with gspca too, for this I've written libv4l, which is a library which does format conversion from many cam specific formats to more general formats in userspace. A joined effort between Debian, Suse and Fedora is currently working on making all v4l apps use libv4l, patches have already been written for gstreamer (cheese), pwlib (ekiga) and xawtv.
Quoted 7 lines
For more on libv4l see:
http://hansdegoede.livejournal.com/3636.html
http://linuxtv.org/v4lwiki/index.php/Libv4l_ProgressMaybe you can write a patch to add YUYV input support to libv4l, if you do that please base your work on the latest version which is available here:
http://linuxtv.org/hg/~hgoede/v4l-dvb
Thanks, will take a look.
-- Mark Ferrell
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 19 lines · Mark Ferrell
Quoted 9 lines · Hans de Goede
Quoted 6 lines · [email protected] wrote:
Adds suport for OmniVision OV534 based cameras:
- Hercules Blog Webcam
- Hercules Dualpix HD Webcam
- Sony HD PS3 Eye (SLEH 00201)
Currently only supports 640x480 YUYV non-interlaced output.Signed-off-by Mark Ferrell <[email protected]>Hi Mark,
Quoted 8 lines
Have you taken a look at the ov519 driver which is currently in gspca, which is in 2.6.27rc1 and more general (latest version) available here:
http://linuxtv.org/hg/~jfrancois/gspca/That driver does do jpeg, maybe it can give some clues. gspca is a webcam driver framework. Would you consider porting your driver to gspca, I (we ?) really want to see all usb webcam drivers start using the gspca framework to share as much code as possible.
Quoted 5 lines
I would definitely be willing to merge the code into an existing driver, though I was under the impression that the gspca core was for ISOC based USB devices. The ov534's imagine end-point is bulk transfer, with the audio endpoints being isoc.
Ah yes it is I didn't know non isoc cams existed, so thats why your driver is so small I already was sorta missing the isoc setup stufff :)
In that case its fine as is. Mauro as this is a new driver and looks clean (and uses videobuf) any chance this can get merged for 2.6.27 ?
I'll work together with Mark on getting YUYV support added to libv4l so that userspace support is taken care of.
Quoted 16 lines
Quoted 16 lines
Review
Quoted 5 lines
(quoted diff) +2
-0+The ov534 outputs frames in YUYV format, non-interlaced, at 640x480. This +format does not yet have wide support among user-land applications.Though at
(quoted diff) +2
-0+the time of this writing xawtv was known to work correctly. +This (custom cam formats) was a big problem with gspca too, for this I've written libv4l, which is a library which does format conversion from many cam specific formats to more general formats in userspace. A joined effort between Debian, Suse and Fedora is currently working on making all v4l apps use libv4l, patches have already been written for gstreamer (cheese), pwlib (ekiga) and xawtv.
For more on libv4l see:
http://hansdegoede.livejournal.com/3636.html
http://linuxtv.org/v4lwiki/index.php/Libv4l_Progress
Quoted 6 lines
Quoted 3 lines
Maybe you can write a patch to add YUYV input support to libv4l, if you do that please base your work on the latest version which is available here:
http://linuxtv.org/hg/~hgoede/v4l-dvbThanks, will take a look.
Let me know how it goes. I'll gladly help where I can, but I prefer people with hardware to test to write the actual code. All you need todo is add support for YUYV to libv4lconvert/libv4lconvert.c and add a file under libv4lconvert with the actual conversion routines. Also take a good look at libv4lconvert/rgbyuv.c for some good inspiration for the YUV->RGB conversion routines.
Regards,
Hans
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
On Sat, 16 Aug 2008 10:03:13 +0200
Quoted 8 lines
Quoted 5 lines
I would definitely be willing to merge the code into an existing driver, though I was under the impression that the gspca core was for ISOC based USB devices. The ov534's imagine end-point is bulk transfer, with the audio endpoints being isoc.
Ah yes it is I didn't know non isoc cams existed, so thats why your driver is so small I already was sorta missing the isoc setup stufff :)
The usage of videobuf simplifies a lot the driver logic. That's why it is so small :)
I think it would be good if gspca could also use videobuf in the future.
Quoted 2 lines
In that case its fine as is. Mauro as this is a new driver and looks clean (and uses videobuf) any chance this can get merged for 2.6.27 ?
Maybe. I'll see when I receive Mark updates.
Cheers,
Mauro
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 9 lines · Mauro Carvalho Chehab
On Sat, 16 Aug 2008 10:03:13 +0200
Quoted 8 lines
Quoted 5 lines
I would definitely be willing to merge the code into an existing driver, though I was under the impression that the gspca core was for ISOC based USB devices. The ov534's imagine end-point is bulk transfer, with the audio endpoints being isoc.
Ah yes it is I didn't know non isoc cams existed, so thats why your driver is so small I already was sorta missing the isoc setup stufff :)
Hello Mauro and Hans,
The code for bulk transfer existed in the first versions, but, as no webcam used it, I removed. It should be easy to put it back.
Quoted 3 lines
The usage of videobuf simplifies a lot the driver logic. That's why it is so small :)
I think it would be good if gspca could also use videobuf in the future.
I think that videobuf is rather complex for handling usually less than 8 buffers (max = 16 in gspca) and it asks for a mutex at irq level. My buffer handling also offers a very small memory overhead...
Cheers.
Signature · 8 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ -- video4linux-list mailing list Unsubscribe mailto:[email protected]?subject=unsubscribe https://www.redhat.com/mailman/listinfo/video4linux-list
Hi Mark,
First of all, please review your patch with checkpatch.pl. I've seen a few non-compliances.
If you're using -hg tree, this is as simple as doing: make checkpatch. Otherwise, you can use v4l/scripts/checkpatch.pl <my patch>
I have also a few other comments:
linux/drivers/media/video/ov534.c line 288
Quoted 1 line
linux/drivers/media/video/ov534.c new file +1
-0+switch (data &0xFF ) {
The better is that all hexadecimal values to be on lowercase.
linux/drivers/media/video/ov534.c line 318
Quoted 7 lines
linux/drivers/media/video/ov534.c new file +7
-0+static void ov534_setup (struct usb_device *udev) +{ +ov534_reg_verify_write (udev,0xe7 ,0x3a ); + +ov534_reg_write (udev,OV534_REG_ADDRESS ,0x60 ); +ov534_reg_write (udev,OV534_REG_ADDRESS ,0x60 ); +ov534_reg_write (udev,OV534_REG_ADDRESS ,0x60 );
Hmm... three times the same write?
linux/drivers/media/video/ov534.c line 321
Quoted 3 lines
linux/drivers/media/video/ov534.c new file +3
-0+ov534_reg_write (udev,OV534_REG_ADDRESS ,0x42 ); + +ov534_reg_verify_write (udev,0xc2 ,0x0c );
...
linux/drivers/media/video/ov534.c line 331
Quoted 1 line
linux/drivers/media/video/ov534.c new file +1
-0+ov534_reg_verify_write (udev,0xe7 ,0x3e );
It is generally better and smaller to have a table instead of those long init sequences.
linux/drivers/media/video/ov534.c line 503
Quoted 6 lines
linux/drivers/media/video/ov534.c new file +5
-0+static void ov534_fillbuff (struct ov534_dev *dev,struct ov534_buffer *buf) +{ + tmpbuf =kmalloc (size +4 ,GFP_ATOMIC ); +if (!tmpbuf) +return ;
It would be better if you allocate the buffer at videobuf prep routines, instead of doing this for every buffer fill. Is there any reason why you just don't use vbuf instead of doing double buffering?
Quoted 10 lines
linux/drivers/media/video/ov534.c new file +10
-0+/* Updates stream time */ + + dev->ms +=jiffies_to_msecs (jiffies-dev->jiffies); + dev->jiffies = jiffies; +if (dev->ms >=1000 ) { + dev->ms -=1000 ; + dev->s++; +if (dev->s >=60 ) { + dev->s -=60 ; + dev->m++;
linux/drivers/media/video/ov534.c line 539
Quoted 10 lines
linux/drivers/media/video/ov534.c new file +10
-0+if (dev->m >60 ) { + dev->m -=60 ; + dev->h++; +if (dev->h >24 ) + dev->h -=24 ; + } + } + } +sprintf (dev->timestr,"%02d:%02d:%02d:%03d" , + dev->h, dev->m, dev->s, dev->ms);
You don't need the above. This is at vivi just because we want to print a timestamp at the video. Just remove it and timestr from dev.
I also didn't see any code to provide S1/S3 hibernation. This is probably not needed at vivi (since there's no hardware registers to be saved/restored - yet
- I never tried to do suspend/resume with vivi working), but for sure this is needed for real devices ;) I suggest you to take a look, for example, at cafe_ccic, for its implementation (it is inside #ifdef CONFIG_PM).
Cheers,
Mauro
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 8 lines · Mauro Carvalho Chehab
Hi Mark,
First of all, please review your patch with checkpatch.pl. I've seen a few non-compliances.
If you're using -hg tree, this is as simple as doing: make checkpatch. Otherwise, you can use
v4l/scripts/checkpatch.pl<my patch>
Thanks, ran make checkpatch and fixed the issues reported.
Quoted 5 lines
I have also a few other comments:
Quoted 1 line
+ switch (data &
0xFF) {The better is that all hexadecimal values to be on lowercase.
Agreed and corrected.
Quoted 9 lines
linux/drivers/media/video/ov534.c line 318
Quoted 7 lines
linux/drivers/media/video/ov534.c new file +7
-0+static void ov534_setup (struct usb_device *udev) +{ +ov534_reg_verify_write (udev,0xe7 ,0x3a ); + +ov534_reg_write (udev,OV534_REG_ADDRESS ,0x60 ); +ov534_reg_write (udev,OV534_REG_ADDRESS ,0x60 ); +ov534_reg_write (udev,OV534_REG_ADDRESS ,0x60 );Hmm... three times the same write?
Supposedly it requires 3 writes of 0x60 followed by a write of 0x42 to initialize the sensor. That particularly register sequence at one point existed as ov534_sccb_init(), but it was only ever called once and so it got moved into the general init. It may need to get split out again once more is known about configuring the camera. Outside of initialization all that is known is how to toggle the led and how to get images from the camera. Setting up the output modes and controlling the sensor is still unknown unfortunately.
Quoted 7 lines
linux/drivers/media/video/ov534.c line 321
Quoted 3 lines
linux/drivers/media/video/ov534.c new file +3
-0+ov534_reg_write (udev,OV534_REG_ADDRESS ,0x42 ); + +ov534_reg_verify_write (udev,0xc2 ,0x0c );...Quoted 1 line
+
ov534_reg_verify_write(udev, 0xe7,0x3e);It is generally better and smaller to have a table instead of those long init sequences.
Will do.
Quoted 8 lines
linux/drivers/media/video/ov534.c line 503
Quoted 6 lines
linux/drivers/media/video/ov534.c new file +5
-0+static void ov534_fillbuff (struct ov534_dev *dev,struct ov534_buffer *buf) +{ + tmpbuf =kmalloc (size +4 ,GFP_ATOMIC ); +if (!tmpbuf) +return ;It would be better if you allocate the buffer at videobuf prep routines, instead of doing this for every buffer fill. Is there any reason why you just don't use vbuf instead of doing double buffering?
Attempting to bulk transfer directly to the vbuf resulted in a deadlock. I went back to the tmpbuf until I could figure out a better solution as I am not partial to the double buffering at all.
Quoted 21 lines
Quoted 10 lines
linux/drivers/media/video/ov534.c new file +10
-0+/* Updates stream time */ + + dev->ms +=jiffies_to_msecs (jiffies-dev->jiffies); + dev->jiffies = jiffies; +if (dev->ms >=1000 ) { + dev->ms -=1000 ; + dev->s++; +if (dev->s >=60 ) { + dev->s -=60 ; + dev->m++;linux/drivers/media/video/ov534.c line 539
Quoted 10 lines
linux/drivers/media/video/ov534.c new file +10
-0+if (dev->m >60 ) { + dev->m -=60 ; + dev->h++; +if (dev->h >24 ) + dev->h -=24 ; + } + } + } +sprintf (dev->timestr,"%02d:%02d:%02d:%03d" , + dev->h, dev->m, dev->s, dev->ms);
Quoted 2 lines
You don't need the above. This is at vivi just because we want to print a timestamp at the video. Just remove it and timestr from dev.
Done
Quoted 5 lines
I also didn't see any code to provide S1/S3 hibernation. This is probably not needed at vivi (since there's no hardware registers to be saved/restored - yet
- I never tried to do suspend/resume with vivi working), but for sure this is needed for real devices ;) I suggest you to take a look, for example, atcafe_ccic, for its implementation (it is inside #ifdefCONFIG_PM).
Will do
--
Mark
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 1 line · On Sat, 16 Aug 2008 07:13:37 -0500 "Mark Ferrell" <[email protected]> wrote:
Done
Mark,
Any news?
Cheers,
Mauro
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 6 lines · On Wed, 5 Nov 2008 20:31:14 -0200 Mauro Carvalho Chehab…
Quoted 1 line · On Sat, 16 Aug 2008 07:13:37 -0500 "Mark Ferrell" <[email protected]> wrote:
Done
Quoted 7 lines
Mark,
Any news?
Cheers,
Mauro
Hi,
Actually I've started a port of this driver to gspca as an exercise. You can find a rough preview here:
http://shell.studenti.unina.it/~ospite/tmp/gspca_ov534-20081111-1733.tar.bz2
I tried to (ab)use gpsca infrastructure for bulk transfers, the driver is quite essential but it works acceptably well, for now, even if I still loose fames because of some bug.
The driver needs the attached changes (or any better equivalent) to gspca bulk transfers code.
Could these changes break other drivers which work with bulk transfers?
Thanks,
Antonio Ospite
Use gspca itself for usb communication when using bulk transfers. Let the subdriver define the number of URBs to submit.
drivers/media/video/gspca/gspca.c +13 -2
@@ -200,6 +200,7 @@ static void bulk_irq(struct urb *urb {struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context;struct gspca_frame *frame; +int st;PDEBUG (D_PACK ,"bulk irq" );if (!gspca_dev->streaming)
@@ -223,6 +224,11 @@ static void bulk_irq(struct urb *urb urb->transfer_buffer, urb->actual_length); } +/* resubmit the URB */ + urb->status =0 ; + st =usb_submit_urb (urb,GFP_ATOMIC ); +if (st <0 ) +PDEBUG (D_ERR |D_PACK ,"usb_submit_urb() ret %d" , st); }/*
@@ -520,11 +526,11 @@ static int create_urbs(struct gspca_dev *gspca_dev, nurbs =DEF_NURBS ; }else {/* bulk */ npkt =0 ; - bsize = gspca_dev->cam. bulk_size; + bsize = gspca_dev->cam.bulk_size;if (bsize ==0 ) bsize = psize;PDEBUG (D_STREAM ,"bulk bsize:%d" , bsize); - nurbs =1 ; + nurbs = gspca_dev->cam.bulk_nurbs; } gspca_dev->nurbs = nurbs;
@@ -607,8 +613,10 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev)atomic_set (&gspca_dev->nevent,0 );/* bulk transfers are started by the subdriver */ +/* XXX: find a way to esplicitly skip submitting urbs if (gspca_dev->alt == 0) break; +*/ /* submit the URBs */ for (n =0 ; n < gspca_dev->nurbs; n++) {
@@ -1855,6 +1863,9 @@ int gspca_dev_probe(struct usb_interface *intf, ret = gspca_dev->sd_desc->config (gspca_dev, id);if (ret <0 ) goto out; +if (!gspca_dev->cam.bulk_nurbs) + gspca_dev->cam.bulk_nurbs =1 ; + ret = gspca_dev->sd_desc->init (gspca_dev);if (ret <0 ) goto out;
drivers/media/video/gspca/gspca.h +1 -0
@@ -56,6 +56,7 @@ extern int gspca_debug;/* device information - set at probe time */ struct cam {int bulk_size;/* buffer size when image transfer by bulk */ +int bulk_nurbs;/* number of URBs to use in bulk mode*/ struct v4l2_pix_format *cam_mode;/* size nmodes */ char nmodes;__u8 epaddr;
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 5 lines · On Tue, 11 Nov 2008 18:42:00 +0100 Antonio Ospite <[email protected]>…
Actually I've started a port of this driver to gspca as an exercise. You can find a rough preview here:
http://shell.studenti.unina.it/~ospite/tmp/gspca_ov534-20081111-1733.tar.bz2
And here's the direct link to the file, sorry for the tarball:
http://shell.studenti.unina.it/~ospite/tmp/gspca_ov534-20081111-1733/ov534.c
Quoted 6 lines
I tried to (ab)use gpsca infrastructure for bulk transfers, the driver is quite essential but it works acceptably well, for now, even if I still loose fames because of some bug.
The driver needs the attached changes (or any better equivalent) to gspca bulk transfers code.
I forgot to say that the changes are against linux-2.6.28-rc4 from linus git tree.
Regards,
Antonio Ospite
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Hi,
I'll the real technical reply-ing to Jean Francois Moine, who knows the gspca bulk code a lot better then I do.
Quoted 4 lines · Antonio Ospite
Quoted 1 line · On Tue, 11 Nov 2008 18:42:00 +0100 Antonio Ospite <[email protected]>…
Actually I've started a port of this driver to gspca as an exercise.
Thanks, good work! Did this reduce the driver in size, iow do you think it makes writing usb webcam driver easy, any improvements we could make?
Quoted 7 lines
And here's the direct link to the file, sorry for the tarball:
http://shell.studenti.unina.it/~ospite/tmp/gspca_ov534-20081111-1733/ov534.cQuoted 4 lines
I tried to (ab)use gpsca infrastructure for bulk transfers, the driver is quite essential but it works acceptably well, for now, even if I still loose fames because of some bug.
Quoted 6 lines
Quoted 2 lines
The driver needs the attached changes (or any better equivalent) to gspca bulk transfers code.
I forgot to say that the changes are against linux-2.6.28-rc4 from linus git tree.
If you do gspca based drivers, you will want to use jfmoine's tree as a base:
http://linuxtv.org/hg/~jfrancois/gspca/
Use "hg clone http://linuxtv.org/hg/~jfrancois/gspca/" to get it. hint if you don't have the hg command it is part of mercurial.
Regards,
Hans
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 7 lines · On Tue, 11 Nov 2008 21:01:02 +0100 Hans de Goede <[email protected]> wrote:
Quoted 3 lines
Quoted 1 line · Antonio Ospite
Actually I've started a port of this driver to gspca as an exercise.
Thanks, good work! Did this reduce the driver in size, iow do you think it makes writing usb webcam driver easy, any improvements we could make?
Well, with my hacks to gspca.c the ov534 driver has become really trivial. The source has shrunk from 33K to 13K. But these hacks could not be accepted though :) But, yes, the opinion on gspca is positive.
The improvement that I always dream to see is to have bridge and sensor drivers split, so sensor drivers can be shared, a-la soc_camera, I mean. Bringing that idea to the extreme, one could think even to share sensor drivers with the soc_camera framework itself, but I only have this abstract suggestion, no idea at all about how it can be done, sorry. Could it be a GSoC project for next summer?
Quoted 7 lines
Quoted 3 lines
I forgot to say that the changes are against linux-2.6.28-rc4 from linus git tree.
If you do gspca based drivers, you will want to use jfmoine's tree as a base:
http://linuxtv.org/hg/~jfrancois/gspca/
Quoted 6 lines
Use "hg clone http://linuxtv.org/hg/~jfrancois/gspca/" to get it. hint if you don't have the hg command it is part of mercurial.
Regards,
Hans
Thanks, will try that.
Regards,
Antonio Ospite
Signature · 7 lines
A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail? Web site: http://www.studenti.unina.it/~ospite Public key: http://www.studenti.unina.it/~ospite/aopubkey.asc
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 3 lines · Antonio Ospite
Well, with my hacks to
gspca.cthe ov534 driver has become really trivial. The source has shrunk from 33K to 13K. But these hacks could not be accepted though :) But, yes, the opinion on gspca is positive.
Hello Antonio,
Thank you for your opinion.
I looked again at your subdriver, and it seems good to me. So forget about mine which is too buggy.
About your hacks to gspca, there are good and bad ideas. The good idea is to have the bulk_nurbs parameter. The bad idea is to force it to one when no set. To preserve the compatibility, the bulk_nurbs may be set to some value for webcams which accept permanent bulk read, the submit being done by gspca. For the other webcams, as those in finepix, a null bulk_nurbs will indicate that the bulk read requests are done by the subdriver. Is it OK for you?
Also, I saw a little problem in your subdriver: in pkt_scan, you use a static variable (count). This does not work with many active webcams and also after stop / restart streaming. Instead, you may know the current byte count using the frame values data and data_end.
Quoted 4 lines
The improvement that I always dream to see is to have bridge and sensor
drivers split, so sensor drivers can be shared, a-lasoc_camera, I mean.
There were many threads about this subject, but I could not find many common values for a same sensor with different bridges in gspca...
Quoted 5 lines
Bringing that idea to the extreme, one could think even to share sensor
drivers with thesoc_cameraframework itself, but I only have this abstract suggestion, no idea at all about how it can be done, sorry. Could it be a GSoC project for next summer?
Why not?
Signature · 8 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ -- video4linux-list mailing list Unsubscribe mailto:[email protected]?subject=unsubscribe https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 12 lines · On Thu, 13 Nov 2008 12:33:58 +0100 Jean-Francois Moine <[email protected]> wrote:
Quoted 3 lines · Antonio Ospite
Well, with my hacks to
gspca.cthe ov534 driver has become really trivial. The source has shrunk from 33K to 13K. But these hacks could not be accepted though :) But, yes, the opinion on gspca is positive.Hello Antonio,
Thank you for your opinion.
I looked again at your subdriver, and it seems good to me. So forget about mine which is too buggy.
Quoted 8 lines
About your hacks to gspca, there are good and bad ideas. The good idea is to have the
bulk_nurbsparameter. The bad idea is to force it to one when no set. To preserve the compatibility, thebulk_nurbsmay be set to some value for webcams which accept permanent bulk read, the submit being done by gspca. For the other webcams, as those in finepix, a nullbulk_nurbswill indicate that the bulk read requests are done by the subdriver. Is it OK for you?
So (cam->bulk_nurbs == 0) would mean that the subdriver takes care of usb tranfers, right? That would also imply that bulk_irq() is not set for these drivers and sd_pkt_scan() is never called which looks fair to me.
If this is really ok I'll update my changes and send for review.
Quoted 5 lines
Also, I saw a little problem in your subdriver: in
pkt_scan, you use a static variable (count). This does not work with many active webcams and also after stop / restart streaming. Instead, you may know the current byte count using the frame values data anddata_end.
I'll take a look at that too, thanks for the hints.
Regards,
Antonio Ospite
Signature · 7 lines
A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail? Web site: http://www.studenti.unina.it/~ospite Public key: http://www.studenti.unina.it/~ospite/aopubkey.asc
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 4 lines · Antonio Ospite
So (
cam->bulk_nurbs== 0) would mean that the subdriver takes care of usb tranfers, right? That would also imply thatbulk_irq()is not set for these drivers andsd_pkt_scan()is never called which looks fair to me.
[snip]
Yes. In the finepix subdriver, the 'complete' function of the URB is changed to a local function which does the packet analysis and restarts the next transfer after a delay.
I attached the patch of the main driver.
Cheers.
Signature · 2 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/
linux/drivers/media/video/gspca/gspca.c +15 -4
@@ -213,6 +213,7 @@ {struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context;struct gspca_frame *frame; +int st;PDEBUG (D_PACK ,"bulk irq" );if (!gspca_dev->streaming)
@@ -235,6 +236,13 @@ frame, urb->transfer_buffer, urb->actual_length); + } + +/* resubmit the URB */ +if (gspca_dev->cam.bulk_nurbs !=0 ) { + st =usb_submit_urb (urb,GFP_ATOMIC ); +if (st <0 ) +PDEBUG (D_ERR |D_PACK ,"usb_submit_urb() ret %d" , st); } }
@@ -533,11 +541,14 @@ nurbs =DEF_NURBS ; }else {/* bulk */ npkt =0 ; - bsize = gspca_dev->cam. bulk_size; + bsize = gspca_dev->cam.bulk_size;if (bsize ==0 ) bsize = psize;PDEBUG (D_STREAM ,"bulk bsize:%d" , bsize); - nurbs =1 ; +if (gspca_dev->cam.bulk_nurbs !=0 ) + nurbs = gspca_dev->cam.bulk_nurbs; +else + nurbs =1 ; } gspca_dev->nurbs = nurbs;
@@ -625,8 +636,8 @@ gspca_dev->streaming =1 ;atomic_set (&gspca_dev->nevent,0 ); -/* bulk transfers are started by the subdriver */ -if (gspca_dev->alt ==0 ) +/* some bulk transfers are started by the subdriver */ +if (gspca_dev->alt ==0 && gspca_dev->cam.bulk_nurbs ==0 )break ;/* submit the URBs */
linux/drivers/media/video/gspca/gspca.h +4 -0
@@ -58,6 +58,10 @@int bulk_size;/* buffer size when image transfer by bulk */ struct v4l2_pix_format *cam_mode;/* size nmodes */ char nmodes; +__u8 bulk_nurbs;/* number of URBs in bulk mode +* - cannot be > MAX_NURBS +* - when 0 and bulk_size != 0 means +* 1 URB and submit done by subdriver */ __u8 epaddr; };
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 6 lines · On Thu, 13 Nov 2008 19:30:59 +0100 Jean-Francois Moine <[email protected]> wrote:
Quoted 4 lines · Antonio Ospite
So (
cam->bulk_nurbs== 0) would mean that the subdriver takes care of usb tranfers, right? That would also imply thatbulk_irq()is not set for these drivers andsd_pkt_scan()is never called which looks fair to me.
Quoted 8 lines
[snip]Yes. In the finepix subdriver, the 'complete' function of the URB is changed to a local function which does the packet analysis and restarts the next transfer after a delay.
I attached the patch of the main driver.
Many thanks Jean-Francois, any ETA of this change in mainline? Some comments inlined
Regards,
Antonio Ospite
Quoted 21 lines
Cheers.
Signature · 7 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ [gspca_bulk.patch text/x-patch (1,9KB)] diff -r 417024f56f55 linux/drivers/media/video/gspca/gspca.clinux/drivers/media/video/gspca/gspca.c +1
-0@@ -213,6 +213,7 @@ {struct gspca_dev *gspca_dev = (struct gspca_dev *) urb->context;struct gspca_frame *frame; +int st;PDEBUG (D_PACK ,"bulk irq" );if (!gspca_dev->streaming)
linux/drivers/media/video/gspca/gspca.c line 242
Quoted 7 lines
linux/drivers/media/video/gspca/gspca.c +4
-0@@ -235,6 +236,13 @@ frame, urb->transfer_buffer, urb->actual_length); + } + +/* resubmit the URB */ +if (gspca_dev->cam.bulk_nurbs !=0 ) {
Just to be sure: this check is still needed because bulk_irq() can be still called even for drivers like finepix, right?
I am not sure I've fully understood the code path here, maybe I should look better at what the finepix driver does, sorry, does it still uses the urb initialized in create_urbs(), even if it drives the submission manually?
Quoted 8 lines
linux/drivers/media/video/gspca/gspca.c +3
-0+ st =usb_submit_urb (urb,GFP_ATOMIC ); +if (st <0 ) +PDEBUG (D_ERR |D_PACK ,"usb_submit_urb() ret %d" , st); } }@@ -533,11 +541,14 @@ nurbs =DEF_NURBS ;
linux/drivers/media/video/gspca/gspca.c line 549
Quoted 10 lines
linux/drivers/media/video/gspca/gspca.c +3
-2}else {/* bulk */ npkt =0 ; - bsize = gspca_dev->cam. bulk_size; + bsize = gspca_dev->cam.bulk_size;if (bsize ==0 ) bsize = psize;PDEBUG (D_STREAM ,"bulk bsize:%d" , bsize); - nurbs =1 ; +if (gspca_dev->cam.bulk_nurbs !=0 ) + nurbs = gspca_dev->cam.bulk_nurbs;
should we set this to min(gspca_dev->cam.bulk_nurbs, MAX_NURBS) ?
Quoted 31 lines
linux/drivers/media/video/gspca/gspca.c +4
-2+else + nurbs =1 ; } gspca_dev->nurbs = nurbs;@@ -625,8 +636,8 @@ gspca_dev->streaming =1 ;atomic_set (&gspca_dev->nevent,0 ); -/* bulk transfers are started by the subdriver */ -if (gspca_dev->alt ==0 ) +/* some bulk transfers are started by the subdriver */ +if (gspca_dev->alt ==0 && gspca_dev->cam.bulk_nurbs ==0 )break ;/* submit the URBs */ diff -r
417024f56f55linux/drivers/media/video/gspca/gspca.hlinux/drivers/media/video/gspca/gspca.h +4
-0@@ -58,6 +58,10 @@int bulk_size;/* buffer size when image transfer by bulk */ struct v4l2_pix_format *cam_mode;/* size nmodes */ char nmodes; +__u8 bulk_nurbs;/* number of URBs in bulk mode +* - cannot be > MAX_NURBS +* - when 0 and bulk_size != 0 means +* 1 URB and submit done by subdriver */ __u8 epaddr; };
Signature · 7 lines
A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail? Web site: http://www.studenti.unina.it/~ospite Public key: http://www.studenti.unina.it/~ospite/aopubkey.asc
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 3 lines · Antonio Ospite
Quoted 1 line
I attached the patch of the main driver.
Many thanks Jean-Francois, any ETA of this change in mainline?
Sorry, what do you mean by ETA? I uploaded the patch to my repository with you as the author.
[snip]
Quoted 5 lines
linux/drivers/media/video/gspca/gspca.c line 242
Quoted 2 lines
linux/drivers/media/video/gspca/gspca.c +2
-0+/* resubmit the URB */ +if (gspca_dev->cam.bulk_nurbs !=0 ) {Just to be sure: this check is still needed because
bulk_irq()can be still called even for drivers like finepix, right?
Yes, the subdriver may use the bulk_irq or have an other function. This is the case for finepix which may receive normal(!) URB errors.
Quoted 4 lines
I am not sure I've fully understood the code path here, maybe I should look better at what the finepix driver does, sorry, does it still uses the urb initialized in
create_urbs(), even if it drives the submission manually?
Yes. The URB is created and destroyed by the main driver. Only the submission and optionally the IRQ treatment are done by the subdriver.
[snip]
Quoted 4 lines
linux/drivers/media/video/gspca/gspca.c line 549
Quoted 2 lines
linux/drivers/media/video/gspca/gspca.c +2
-0+if (gspca_dev->cam.bulk_nurbs !=0 ) + nurbs = gspca_dev->cam.bulk_nurbs;should we set this to
min(gspca_dev->cam.bulk_nurbs, MAX_NURBS)?
Yes, we should, but, if a greater value is set, the subdriver will crash at the first development test...
Regards.
Signature · 8 lines
Ken ar c'hentañ | ** Breizh ha Linux atav! ** Jef | http://moinejf.free.fr/ -- video4linux-list mailing list Unsubscribe mailto:[email protected]?subject=unsubscribe https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 8 lines · On Fri, 14 Nov 2008 11:55:30 +0100 Jean-Francois Moine <[email protected]> wrote:
Quoted 3 lines · Antonio Ospite
Quoted 1 line
I attached the patch of the main driver.
Many thanks Jean-Francois, any ETA of this change in mainline?
Sorry, what do you mean by ETA? I uploaded the patch to my repository with you as the author.
ETA: Estimated Time of Arrival.
I wondered if you had an idea about when the change will hit Linus tree, just that.
Quoted 8 lines
Quoted 4 lines
linux/drivers/media/video/gspca/gspca.c line 549
Quoted 2 lines
linux/drivers/media/video/gspca/gspca.c +2
-0+if (gspca_dev->cam.bulk_nurbs !=0 ) + nurbs = gspca_dev->cam.bulk_nurbs;should we set this to
min(gspca_dev->cam.bulk_nurbs, MAX_NURBS)?Yes, we should, but, if a greater value is set, the subdriver will crash at the first development test...
Ok, if you think that having subdriver crash during development is ok, then it is perfectly fine with me too.
Back to ov534 now :)
Regards,
Antonio Ospite
Signature · 7 lines
A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail? Web site: http://www.studenti.unina.it/~ospite Public key: http://www.studenti.unina.it/~ospite/aopubkey.asc
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list