Re: [PATCH] Implement V4L2_CAP_STREAMING for zr364xx driver

2009-07-17 Thread Antoine Jacquet

Hi,

Lamarque Vieira Souza wrote:

Em Quinta-feira 16 Julho 2009, Mauro Carvalho Chehab escreveu:

Em Wed, 15 Jul 2009 20:54:55 -0300

[...]

+   if (pipe_info->state != 0) {
+   if (usb_submit_urb(pipe_info->stream_urb, GFP_KERNEL))
+   dev_err(&cam->udev->dev, "error submitting urb\n");
+   } else {
+   DBG("read pipe complete state 0\n");
+   }

Hmm...  for the usb_submit_urb() call that happens during IRQ context
(while you're receiving stream), you need to use:
urb->status = usb_submit_urb(pipe_info->stream_urb, GFP_ATOMIC);

otherwise, you may get the errors that Antoine is reporting


	Ok, changed to GPF_ATOMIC. Could someone test this for me since I was not 
able to reproduce this problem? The new patch is here 
http://bach.metasys.com.br/~lamarque/zr364xx/zr364xx.c-streaming.patch-v4l-
dvb-20090716 . I upload it to avoid bloating the mailing-list with a 40k 
patch.


I confirm it fixes the issue.
I will upload the patch to my branch and send a pull request to Mauro.

Thanks and best regards,

Antoine

--
Antoine "Royale" Jacquet
http://royale.zerezo.com
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Implement V4L2_CAP_STREAMING for zr364xx driver

2009-07-16 Thread Lamarque Vieira Souza
Em Quinta-feira 16 Julho 2009, Mauro Carvalho Chehab escreveu:
> Em Wed, 15 Jul 2009 20:54:55 -0300
>
> Lamarque Vieira Souza  escreveu:
> > This patch implements V4L2_CAP_STREAMING for the zr364xx driver, by
> > converting the driver to use videobuf. This version is synced with
> > v4l-dvb as of 15/Jul/2009.
> >
> > Tested with Creative PC-CAM 880.
> >
> > It basically:
> > . implements V4L2_CAP_STREAMING using videobuf;
> >
> > . re-implements V4L2_CAP_READWRITE using videobuf;
> >
> > . copies cam->udev->product to the card field of the v4l2_capability
> > struct. That gives more information to the users about the webcam;
> >
> > . moves the brightness setting code from before requesting a frame (in
> > read_frame) to the vidioc_s_ctrl ioctl. This way the brightness code is
> > executed only when the application requests a change in brightness and
> > not before every frame read;
> >
> > . comments part of zr364xx_vidioc_try_fmt_vid_cap that says that Skype +
> > libv4l do not work.
> >
> > This patch fixes zr364xx for applications such as mplayer,
> > Kopete+libv4l and Skype+libv4l can make use of the webcam that comes
> > with zr364xx chip.
> >
> > Signed-off-by: Lamarque V. Souza 
> > ---
> >
> > diff -r c300798213a9 linux/drivers/media/video/zr364xx.c
> > --- a/linux/drivers/media/video/zr364xx.c   Sun Jul 05 19:08:55 2009 -0300
> > +++ b/linux/drivers/media/video/zr364xx.c   Wed Jul 15 20:50:34 2009 -0300
> > @@ -1,5 +1,5 @@
> >  /*
> > - * Zoran 364xx based USB webcam module version 0.72
> > + * Zoran 364xx based USB webcam module version 0.73
> >   *
> >   * Allows you to use your USB webcam with V4L2 applications
> >   * This is still in heavy developpement !
> > @@ -10,6 +10,8 @@
> >   * Heavily inspired by usb-skeleton.c, vicam.c, cpia.c and spca50x.c
> > drivers * V4L2 version inspired by meye.c driver
> >   *
> > + * Some video buffer code by Lamarque based on s2255drv.c and vivi.c
> > drivers. + *
>
> Maybe the better example for it is em28xx-video, where we firstly used
> videobuf on usb devices.

I will take a look at em28xx-video. I used s2255drv.c and vivi.c 
because 
their code organization are similar to zr364xx.c, so it was easier to know 
what to do.

> > +static void free_buffer(struct videobuf_queue *vq, struct zr364xx_buffer
> > *buf)
> > +{
> > +   DBG("%s\n", __func__);
> > +
> > +   /*Lamarque: is this really needed? Sometimes this blocks rmmod forever
> > +* after running Skype on an AMD64 system. */
> > +   /*videobuf_waiton(&buf->vb, 0, 0);*/
>
> Answering to your note, take a look at em28xx-video implementation:
>
> /* We used to wait for the buffer to finish here, but this didn't
> work because, as we were keeping the state as VIDEOBUF_QUEUED,
> videobuf_queue_cancel marked it as finished for us.
>(Also, it could wedge forever if the hardware was
> misconfigured.)
>
>This should be safe; by the time we get here, the buffer isn't
>queued anymore. If we ever start marking the buffers as
>VIDEOBUF_ACTIVE, it won't be, though.
> */
> spin_lock_irqsave(&dev->slock, flags);
> if (dev->isoc_ctl.buf == buf)
> dev->isoc_ctl.buf = NULL;
> spin_unlock_irqrestore(&dev->slock, flags);

Yes, the comment answers my question. There is no similar code in 
zr364xx.c 
like the one above. zr364xx_camera does not have a member with zr364xxx_buffer 
type (the equivalent type of dev->isoc_ctl.buf).

> > +   if (pipe_info->state != 0) {
> > +   if (usb_submit_urb(pipe_info->stream_urb, GFP_KERNEL))
> > +   dev_err(&cam->udev->dev, "error submitting urb\n");
> > +   } else {
> > +   DBG("read pipe complete state 0\n");
> > +   }
>
> Hmm...  for the usb_submit_urb() call that happens during IRQ context
> (while you're receiving stream), you need to use:
> urb->status = usb_submit_urb(pipe_info->stream_urb, GFP_ATOMIC);
>
> otherwise, you may get the errors that Antoine is reporting

Ok, changed to GPF_ATOMIC. Could someone test this for me since I was 
not 
able to reproduce this problem? The new patch is here 
http://bach.metasys.com.br/~lamarque/zr364xx/zr364xx.c-streaming.patch-v4l-
dvb-20090716 . I upload it to avoid bloating the mailing-list with a 40k 
patch.

I have computer here with dual core processor but no display. I need to 
get a 
DVI <-> VGA adaptor to plug my DVI LCD on it, when I get one I am going to 
test the changes with SMP enabled.

-- 
Lamarque V. Souza
http://www.geographicguide.com/brazil.htm
Linux User #57137 - http://counter.li.org/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] Implement V4L2_CAP_STREAMING for zr364xx driver

2009-07-16 Thread Karicheri, Muralidharan
Mauro,

Thanks. That was what I was thinking, but just want to see what issues I might 
face on the way. I am starting the work on DM6467 capture driver and you would 
be getting a patch soon for review in the mailing list.

Regards,
Murali Karicheri
Software Design Engineer
Texas Instruments Inc.
>-Original Message-
>From: linux-media-ow...@vger.kernel.org [mailto:linux-media-
>ow...@vger.kernel.org] On Behalf Of Mauro Carvalho Chehab
>Sent: Thursday, July 16, 2009 11:45 AM
>To: Lamarque Vieira Souza
>Cc: Antoine Jacquet; linux-media@vger.kernel.org; video4linux-
>l...@redhat.com
>Subject: Re: [PATCH] Implement V4L2_CAP_STREAMING for zr364xx driver
>
>Em Wed, 15 Jul 2009 20:54:55 -0300
>Lamarque Vieira Souza  escreveu:
>
>> This patch implements V4L2_CAP_STREAMING for the zr364xx driver, by
>> converting the driver to use videobuf. This version is synced with v4l-
>dvb as
>> of 15/Jul/2009.
>>
>> Tested with Creative PC-CAM 880.
>>
>> It basically:
>> . implements V4L2_CAP_STREAMING using videobuf;
>>
>> . re-implements V4L2_CAP_READWRITE using videobuf;
>>
>> . copies cam->udev->product to the card field of the v4l2_capability
>struct.
>> That gives more information to the users about the webcam;
>>
>> . moves the brightness setting code from before requesting a frame (in
>> read_frame) to the vidioc_s_ctrl ioctl. This way the brightness code is
>> executed only when the application requests a change in brightness and
>> not before every frame read;
>>
>> . comments part of zr364xx_vidioc_try_fmt_vid_cap that says that Skype +
>> libv4l do not work.
>>
>> This patch fixes zr364xx for applications such as mplayer,
>> Kopete+libv4l and Skype+libv4l can make use of the webcam that comes
>> with zr364xx chip.
>>
>> Signed-off-by: Lamarque V. Souza 
>> ---
>>
>> diff -r c300798213a9 linux/drivers/media/video/zr364xx.c
>> --- a/linux/drivers/media/video/zr364xx.cSun Jul 05 19:08:55 2009 -
>0300
>> +++ b/linux/drivers/media/video/zr364xx.cWed Jul 15 20:50:34 2009 -
>0300
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Zoran 364xx based USB webcam module version 0.72
>> + * Zoran 364xx based USB webcam module version 0.73
>>   *
>>   * Allows you to use your USB webcam with V4L2 applications
>>   * This is still in heavy developpement !
>> @@ -10,6 +10,8 @@
>>   * Heavily inspired by usb-skeleton.c, vicam.c, cpia.c and spca50x.c
>drivers
>>   * V4L2 version inspired by meye.c driver
>>   *
>> + * Some video buffer code by Lamarque based on s2255drv.c and vivi.c
>drivers.
>> + *
>
>Maybe the better example for it is em28xx-video, where we firstly used
>videobuf
>on usb devices.
>
>> +static void free_buffer(struct videobuf_queue *vq, struct zr364xx_buffer
>> *buf)
>> +{
>> +DBG("%s\n", __func__);
>> +
>> +/*Lamarque: is this really needed? Sometimes this blocks rmmod
>forever
>> + * after running Skype on an AMD64 system. */
>> +/*videobuf_waiton(&buf->vb, 0, 0);*/
>
>Answering to your note, take a look at em28xx-video implementation:
>
>/* We used to wait for the buffer to finish here, but this didn't
>work
>   because, as we were keeping the state as VIDEOBUF_QUEUED,
>   videobuf_queue_cancel marked it as finished for us.
>   (Also, it could wedge forever if the hardware was
>misconfigured.)
>
>   This should be safe; by the time we get here, the buffer isn't
>   queued anymore. If we ever start marking the buffers as
>   VIDEOBUF_ACTIVE, it won't be, though.
>*/
>spin_lock_irqsave(&dev->slock, flags);
>if (dev->isoc_ctl.buf == buf)
>dev->isoc_ctl.buf = NULL;
>spin_unlock_irqrestore(&dev->slock, flags);
>
>> +if (pipe_info->state != 0) {
>> +if (usb_submit_urb(pipe_info->stream_urb, GFP_KERNEL))
>> +dev_err(&cam->udev->dev, "error submitting urb\n");
>> +} else {
>> +DBG("read pipe complete state 0\n");
>> +}
>
>Hmm...  for the usb_submit_urb() call that happens during IRQ context
>(while
>you're receiving stream), you need to use:
>urb->status = usb_submit_urb(pipe_info->stream_urb, GFP_ATOMIC);
>
>otherwise, you may get the errors that Antoine is reporting
>
>
>
>Cheers,
>Mauro
>--
>To unsubscribe from this list: send the line "unsubscribe linux-media" in
>the body of a message to majord...@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Implement V4L2_CAP_STREAMING for zr364xx driver

2009-07-16 Thread Mauro Carvalho Chehab
Em Wed, 15 Jul 2009 20:54:55 -0300
Lamarque Vieira Souza  escreveu:

> This patch implements V4L2_CAP_STREAMING for the zr364xx driver, by
> converting the driver to use videobuf. This version is synced with v4l-dvb as 
> of 15/Jul/2009.
> 
> Tested with Creative PC-CAM 880.
> 
> It basically:
> . implements V4L2_CAP_STREAMING using videobuf;
> 
> . re-implements V4L2_CAP_READWRITE using videobuf;
> 
> . copies cam->udev->product to the card field of the v4l2_capability struct.
> That gives more information to the users about the webcam;
> 
> . moves the brightness setting code from before requesting a frame (in
> read_frame) to the vidioc_s_ctrl ioctl. This way the brightness code is
> executed only when the application requests a change in brightness and
> not before every frame read;
> 
> . comments part of zr364xx_vidioc_try_fmt_vid_cap that says that Skype + 
> libv4l do not work.
> 
> This patch fixes zr364xx for applications such as mplayer,
> Kopete+libv4l and Skype+libv4l can make use of the webcam that comes
> with zr364xx chip.
> 
> Signed-off-by: Lamarque V. Souza 
> ---
> 
> diff -r c300798213a9 linux/drivers/media/video/zr364xx.c
> --- a/linux/drivers/media/video/zr364xx.c Sun Jul 05 19:08:55 2009 -0300
> +++ b/linux/drivers/media/video/zr364xx.c Wed Jul 15 20:50:34 2009 -0300
> @@ -1,5 +1,5 @@
>  /*
> - * Zoran 364xx based USB webcam module version 0.72
> + * Zoran 364xx based USB webcam module version 0.73
>   *
>   * Allows you to use your USB webcam with V4L2 applications
>   * This is still in heavy developpement !
> @@ -10,6 +10,8 @@
>   * Heavily inspired by usb-skeleton.c, vicam.c, cpia.c and spca50x.c drivers
>   * V4L2 version inspired by meye.c driver
>   *
> + * Some video buffer code by Lamarque based on s2255drv.c and vivi.c drivers.
> + *

Maybe the better example for it is em28xx-video, where we firstly used videobuf
on usb devices.

> +static void free_buffer(struct videobuf_queue *vq, struct zr364xx_buffer 
> *buf)
> +{
> + DBG("%s\n", __func__);
> +
> + /*Lamarque: is this really needed? Sometimes this blocks rmmod forever
> +  * after running Skype on an AMD64 system. */
> + /*videobuf_waiton(&buf->vb, 0, 0);*/

Answering to your note, take a look at em28xx-video implementation:

/* We used to wait for the buffer to finish here, but this didn't work
   because, as we were keeping the state as VIDEOBUF_QUEUED,
   videobuf_queue_cancel marked it as finished for us.
   (Also, it could wedge forever if the hardware was misconfigured.)

   This should be safe; by the time we get here, the buffer isn't
   queued anymore. If we ever start marking the buffers as
   VIDEOBUF_ACTIVE, it won't be, though.
*/
spin_lock_irqsave(&dev->slock, flags);
if (dev->isoc_ctl.buf == buf)
dev->isoc_ctl.buf = NULL;
spin_unlock_irqrestore(&dev->slock, flags);

> + if (pipe_info->state != 0) {
> + if (usb_submit_urb(pipe_info->stream_urb, GFP_KERNEL))
> + dev_err(&cam->udev->dev, "error submitting urb\n");
> + } else {
> + DBG("read pipe complete state 0\n");
> + }

Hmm...  for the usb_submit_urb() call that happens during IRQ context (while
you're receiving stream), you need to use:
urb->status = usb_submit_urb(pipe_info->stream_urb, GFP_ATOMIC);

otherwise, you may get the errors that Antoine is reporting



Cheers,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Implement V4L2_CAP_STREAMING for zr364xx driver

2009-07-16 Thread Lamarque Vieira Souza
Em Quinta-feira 16 Julho 2009, Antoine Jacquet escreveu:
> Thanks,
>
> I successfully applied your patch and tested it with mplayer.
> However I have the following trace each time I capture a frame:

No, I do not have this problem neither in 2.6.28 (vanilla), 2.6.29.3 
(vanilla 
source and v4l-dvb) and 2.6.30.1 (vanilla and v4l-dvb). My notebook is single 
core, maybe this problem is related to SMP. I will try to test the patch on a 
dual core processor.

> [  523.477064] BUG: scheduling while atomic: swapper/0/0x1001
> [  523.477390] Modules linked in: zr364xx videodev v4l1_compat
> v4l2_compat_ioctl32 videobuf_vmalloc videobuf_core binfmt_misc ipv6 fuse
> ntfs it87 hwmon_vid snd_intel8x0 snd_ac97_codec ac97_bus snd_pcm_oss
> snd_mixer_oss snd_pcm snd_seq_dummy snd_seq_oss snd_seq_midi_event
> snd_seq snd_timer snd_seq_device pcspkr snd snd_page_alloc
> [  523.477390] CPU 0:
> [  523.477390] Modules linked in: zr364xx videodev v4l1_compat
> v4l2_compat_ioctl32 videobuf_vmalloc videobuf_core binfmt_misc ipv6 fuse
> ntfs it87 hwmon_vid snd_intel8x0 snd_ac97_codec ac97_bus snd_pcm_oss
> snd_mixer_oss snd_pcm snd_seq_dummy snd_seq_oss snd_seq_midi_event
> snd_seq snd_timer snd_seq_device pcspkr snd snd_page_alloc
> [  523.477390] Pid: 0, comm: swapper Not tainted 2.6.30.1 #1 Aspire T160
> [  523.477390] RIP: 0010:[]  []
> default_idle+0x54/0x90
> [  523.477390] RSP: 0018:807e3f38  EFLAGS: 0246
> [  523.477390] RAX: 807e3fd8 RBX:  RCX:
> 
> [  523.477390] RDX:  RSI: 0001 RDI:
> 8078d010
> [  523.477390] RBP: 8020b60e R08:  R09:
> 
> [  523.477390] R10: 000f423d R11:  R12:
> 88003f87d180
> [  523.477390] R13:  R14: 88003e1e9940 R15:
> 88003f87d180
> [  523.477390] FS:  7f40f871e730() GS:80789000()
> knlGS:
> [  523.477390] CS:  0010 DS: 0018 ES: 0018 CR0: 8005003b
> [  523.477390] CR2: 7f099e8c2008 CR3: 3c16c000 CR4:
> 06e0
> [  523.477390] DR0:  DR1:  DR2:
> 
> [  523.477390] DR3:  DR6: 0ff0 DR7:
> 0400
> [  523.477390] Call Trace:
> [  523.477390]  [] ? notifier_call_chain+0x29/0x4c
> [  523.477390]  [] ? cpu_idle+0x23/0x5b
> [  523.477390]  [] ? start_kernel+0x2e8/0x2f4
> [  523.477390]  [] ? x86_64_start_kernel+0xe5/0xeb
>
> I can trigger it each time I read a frame, for example using dd on
> /dev/video0.
> Did you have the same behavior?
>
> Regards,
>
> Antoine
>
> Lamarque Vieira Souza wrote:
> > This patch implements V4L2_CAP_STREAMING for the zr364xx driver, by
> > converting the driver to use videobuf. This version is synced with
> > v4l-dvb as of 15/Jul/2009.
> >
> > Tested with Creative PC-CAM 880.
> >
> > It basically:
> > . implements V4L2_CAP_STREAMING using videobuf;
> >
> > . re-implements V4L2_CAP_READWRITE using videobuf;
> >
> > . copies cam->udev->product to the card field of the v4l2_capability
> > struct. That gives more information to the users about the webcam;
> >
> > . moves the brightness setting code from before requesting a frame (in
> > read_frame) to the vidioc_s_ctrl ioctl. This way the brightness code is
> > executed only when the application requests a change in brightness and
> > not before every frame read;
> >
> > . comments part of zr364xx_vidioc_try_fmt_vid_cap that says that Skype +
> > libv4l do not work.
> >
> > This patch fixes zr364xx for applications such as mplayer,
> > Kopete+libv4l and Skype+libv4l can make use of the webcam that comes
> > with zr364xx chip.
> >
> > Signed-off-by: Lamarque V. Souza 
> > ---


-- 
Lamarque V. Souza
http://www.geographicguide.com/brazil.htm
Linux User #57137 - http://counter.li.org/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Implement V4L2_CAP_STREAMING for zr364xx driver

2009-07-16 Thread Antoine Jacquet

Thanks,

I successfully applied your patch and tested it with mplayer.
However I have the following trace each time I capture a frame:

[  523.477064] BUG: scheduling while atomic: swapper/0/0x1001
[  523.477390] Modules linked in: zr364xx videodev v4l1_compat 
v4l2_compat_ioctl32 videobuf_vmalloc videobuf_core binfmt_misc ipv6 fuse 
ntfs it87 hwmon_vid snd_intel8x0 snd_ac97_codec ac97_bus snd_pcm_oss 
snd_mixer_oss snd_pcm snd_seq_dummy snd_seq_oss snd_seq_midi_event 
snd_seq snd_timer snd_seq_device pcspkr snd snd_page_alloc

[  523.477390] CPU 0:
[  523.477390] Modules linked in: zr364xx videodev v4l1_compat 
v4l2_compat_ioctl32 videobuf_vmalloc videobuf_core binfmt_misc ipv6 fuse 
ntfs it87 hwmon_vid snd_intel8x0 snd_ac97_codec ac97_bus snd_pcm_oss 
snd_mixer_oss snd_pcm snd_seq_dummy snd_seq_oss snd_seq_midi_event 
snd_seq snd_timer snd_seq_device pcspkr snd snd_page_alloc

[  523.477390] Pid: 0, comm: swapper Not tainted 2.6.30.1 #1 Aspire T160
[  523.477390] RIP: 0010:[]  [] 
default_idle+0x54/0x90

[  523.477390] RSP: 0018:807e3f38  EFLAGS: 0246
[  523.477390] RAX: 807e3fd8 RBX:  RCX: 

[  523.477390] RDX:  RSI: 0001 RDI: 
8078d010
[  523.477390] RBP: 8020b60e R08:  R09: 

[  523.477390] R10: 000f423d R11:  R12: 
88003f87d180
[  523.477390] R13:  R14: 88003e1e9940 R15: 
88003f87d180
[  523.477390] FS:  7f40f871e730() GS:80789000() 
knlGS:

[  523.477390] CS:  0010 DS: 0018 ES: 0018 CR0: 8005003b
[  523.477390] CR2: 7f099e8c2008 CR3: 3c16c000 CR4: 
06e0
[  523.477390] DR0:  DR1:  DR2: 

[  523.477390] DR3:  DR6: 0ff0 DR7: 
0400

[  523.477390] Call Trace:
[  523.477390]  [] ? notifier_call_chain+0x29/0x4c
[  523.477390]  [] ? cpu_idle+0x23/0x5b
[  523.477390]  [] ? start_kernel+0x2e8/0x2f4
[  523.477390]  [] ? x86_64_start_kernel+0xe5/0xeb

I can trigger it each time I read a frame, for example using dd on 
/dev/video0.

Did you have the same behavior?

Regards,

Antoine


Lamarque Vieira Souza wrote:

This patch implements V4L2_CAP_STREAMING for the zr364xx driver, by
converting the driver to use videobuf. This version is synced with v4l-dvb as 
of 15/Jul/2009.


Tested with Creative PC-CAM 880.

It basically:
. implements V4L2_CAP_STREAMING using videobuf;

. re-implements V4L2_CAP_READWRITE using videobuf;

. copies cam->udev->product to the card field of the v4l2_capability struct.
That gives more information to the users about the webcam;

. moves the brightness setting code from before requesting a frame (in
read_frame) to the vidioc_s_ctrl ioctl. This way the brightness code is
executed only when the application requests a change in brightness and
not before every frame read;

. comments part of zr364xx_vidioc_try_fmt_vid_cap that says that Skype + 
libv4l do not work.


This patch fixes zr364xx for applications such as mplayer,
Kopete+libv4l and Skype+libv4l can make use of the webcam that comes
with zr364xx chip.

Signed-off-by: Lamarque V. Souza 
---

diff -r c300798213a9 linux/drivers/media/video/zr364xx.c
--- a/linux/drivers/media/video/zr364xx.c   Sun Jul 05 19:08:55 2009 -0300
+++ b/linux/drivers/media/video/zr364xx.c   Wed Jul 15 20:50:34 2009 -0300
@@ -1,5 +1,5 @@
 /*
- * Zoran 364xx based USB webcam module version 0.72
+ * Zoran 364xx based USB webcam module version 0.73
  *
  * Allows you to use your USB webcam with V4L2 applications
  * This is still in heavy developpement !
@@ -10,6 +10,8 @@
  * Heavily inspired by usb-skeleton.c, vicam.c, cpia.c and spca50x.c drivers
  * V4L2 version inspired by meye.c driver
  *
+ * Some video buffer code by Lamarque based on s2255drv.c and vivi.c drivers.
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -35,25 +37,34 @@
 #include 
 #include 
 #include 
+#include 
 #include "compat.h"
 
 
 /* Version Information */

-#define DRIVER_VERSION "v0.72"
+#define DRIVER_VERSION "v0.73"
+#define ZR364_VERSION_CODE KERNEL_VERSION(0, 7, 3)
 #define DRIVER_AUTHOR "Antoine Jacquet, http://royale.zerezo.com/";
 #define DRIVER_DESC "Zoran 364xx"
 
 
 /* Camera */

-#define FRAMES 2
+#define FRAMES 1
 #define MAX_FRAME_SIZE 10
 #define BUFFER_SIZE 0x1000
 #define CTRL_TIMEOUT 500
 
+#define ZR364XX_DEF_BUFS	4

+#define ZR364XX_READ_IDLE  0
+#define ZR364XX_READ_FRAME 1
 
 /* Debug macro */

-#define DBG(x...) if (debug) printk(KERN_INFO KBUILD_MODNAME x)
-
+#define DBG(fmt, args...) \
+   do { \
+   if (debug) { \
+   printk(KERN_INFO KBUILD_MODNAME " " fmt, ##args); \
+   } \
+   } 

[PATCH] Implement V4L2_CAP_STREAMING for zr364xx driver

2009-07-15 Thread Lamarque Vieira Souza
This patch implements V4L2_CAP_STREAMING for the zr364xx driver, by
converting the driver to use videobuf. This version is synced with v4l-dvb as 
of 15/Jul/2009.

Tested with Creative PC-CAM 880.

It basically:
. implements V4L2_CAP_STREAMING using videobuf;

. re-implements V4L2_CAP_READWRITE using videobuf;

. copies cam->udev->product to the card field of the v4l2_capability struct.
That gives more information to the users about the webcam;

. moves the brightness setting code from before requesting a frame (in
read_frame) to the vidioc_s_ctrl ioctl. This way the brightness code is
executed only when the application requests a change in brightness and
not before every frame read;

. comments part of zr364xx_vidioc_try_fmt_vid_cap that says that Skype + 
libv4l do not work.

This patch fixes zr364xx for applications such as mplayer,
Kopete+libv4l and Skype+libv4l can make use of the webcam that comes
with zr364xx chip.

Signed-off-by: Lamarque V. Souza 
---

diff -r c300798213a9 linux/drivers/media/video/zr364xx.c
--- a/linux/drivers/media/video/zr364xx.c   Sun Jul 05 19:08:55 2009 -0300
+++ b/linux/drivers/media/video/zr364xx.c   Wed Jul 15 20:50:34 2009 -0300
@@ -1,5 +1,5 @@
 /*
- * Zoran 364xx based USB webcam module version 0.72
+ * Zoran 364xx based USB webcam module version 0.73
  *
  * Allows you to use your USB webcam with V4L2 applications
  * This is still in heavy developpement !
@@ -10,6 +10,8 @@
  * Heavily inspired by usb-skeleton.c, vicam.c, cpia.c and spca50x.c drivers
  * V4L2 version inspired by meye.c driver
  *
+ * Some video buffer code by Lamarque based on s2255drv.c and vivi.c drivers.
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -35,25 +37,34 @@
 #include 
 #include 
 #include 
+#include 
 #include "compat.h"
 
 
 /* Version Information */
-#define DRIVER_VERSION "v0.72"
+#define DRIVER_VERSION "v0.73"
+#define ZR364_VERSION_CODE KERNEL_VERSION(0, 7, 3)
 #define DRIVER_AUTHOR "Antoine Jacquet, http://royale.zerezo.com/";
 #define DRIVER_DESC "Zoran 364xx"
 
 
 /* Camera */
-#define FRAMES 2
+#define FRAMES 1
 #define MAX_FRAME_SIZE 10
 #define BUFFER_SIZE 0x1000
 #define CTRL_TIMEOUT 500
 
+#define ZR364XX_DEF_BUFS   4
+#define ZR364XX_READ_IDLE  0
+#define ZR364XX_READ_FRAME 1
 
 /* Debug macro */
-#define DBG(x...) if (debug) printk(KERN_INFO KBUILD_MODNAME x)
-
+#define DBG(fmt, args...) \
+   do { \
+   if (debug) { \
+   printk(KERN_INFO KBUILD_MODNAME " " fmt, ##args); \
+   } \
+   } while (0)
 
 /* Init methods, need to find nicer names for these
  * the exact names of the chipsets would be the best if someone finds it */
@@ -102,24 +113,93 @@
 
 MODULE_DEVICE_TABLE(usb, device_table);
 
+struct zr364xx_mode {
+   u32 color;  /* output video color format */
+   u32 brightness; /* brightness */
+};
+
+/* frame structure */
+struct zr364xx_framei {
+   unsigned long ulState;  /* ulState:ZR364XX_READ_IDLE,
+  ZR364XX_READ_FRAME */
+   void *lpvbits;  /* image data */
+   unsigned long cur_size; /* current data copied to it */
+};
+
+/* image buffer structure */
+struct zr364xx_bufferi {
+   unsigned long dwFrames; /* number of frames in buffer */
+   struct zr364xx_framei frame[FRAMES];/* array of FRAME structures */
+};
+
+struct zr364xx_dmaqueue {
+   struct list_headactive;
+   struct zr364xx_camera   *cam;
+};
+
+struct zr364xx_pipeinfo {
+   u32 transfer_size;
+   u8 *transfer_buffer;
+   u32 state;
+   void *stream_urb;
+   void *cam;  /* back pointer to zr364xx_camera struct */
+   u32 err_count;
+   u32 idx;
+};
+
+struct zr364xx_fmt {
+   char *name;
+   u32 fourcc;
+   int depth;
+};
+
+/* image formats.  */
+static const struct zr364xx_fmt formats[] = {
+   {
+   .name = "JPG",
+   .fourcc = V4L2_PIX_FMT_JPEG,
+   .depth = 24
+   }
+};
 
 /* Camera stuff */
 struct zr364xx_camera {
struct usb_device *udev;/* save off the usb device pointer */
struct usb_interface *interface;/* the interface for this device */
struct video_device *vdev;  /* v4l video device */
-   u8 *framebuf;
int nb;
-   unsigned char *buffer;
+   struct zr364xx_bufferi  buffer;
int skip;
-   int brightness;
int width;
int height;
int method;
struct mutex lock;
+   struct mutex open_lock;
int users;
+
+   spinlock_t  slock;
+   struct zr364xx_dmaqueue vidq;
+   int resources;
+   int last_frame;
+   int cur_frame;
+   unsigned long

Re: [PATCH] Implement V4L2_CAP_STREAMING for zr364xx driver

2009-07-15 Thread Antoine Jacquet

Hi,

Sorry for the very late answer, I did not have time to work on my driver 
during the past months.
I managed to apply your patch to my current hg tree, but since it is 5 
months out of sync with the main tree, I am having issues to merge your 
work.
Could you send a patch against the current main tree ( 
http://linuxtv.org/hg/v4l-dvb/ ) so I can test your patch?


Thanks a lot and sorry again.

Regards,

Antoine


Lamarque Vieira Souza wrote:
	Hi guys. Any news about this patch? I really think is important to make 
zr364xx driver works with libv4l, mplayer, kopete and skype. Maintaining this 
patch out of tree is also troublesome for me, I would really appreciate if you 
could add it to the tree. If there is any problem with the patch let me know 
that will fix it.


Em Thursday 02 July 2009, Lamarque Vieira Souza escreveu:

Hi all,

I have noticed the patch mentioned in the subject was not included in
2.6.30. Do you plan to add it to 2.6.31?

Em Saturday 28 March 2009, Lamarque Vieira Souza escreveu:

This patch implements V4L2_CAP_STREAMING for the zr364xx driver, by
converting the driver to use videobuf.

Tested with Creative PC-CAM 880.

It basically:
. implements V4L2_CAP_STREAMING using videobuf;

. re-implements V4L2_CAP_READWRITE using videobuf;

. copies cam->udev->product to the card field of the v4l2_capability
struct. That gives more information to the users about the webcam;

. moves the brightness setting code from before requesting a frame (in
read_frame) to the vidioc_s_ctrl ioctl. This way the brightness code is
executed only when the application requests a change in brightness and
not before every frame read;

. comments part of zr364xx_vidioc_try_fmt_vid_cap that says that Skype +
libv4l do not work.

This patch fixes zr364xx for applications such as mplayer,
Kopete+libv4l and Skype+libv4l can make use of the webcam that comes
with zr364xx chip.

Signed-off-by: Lamarque V. Souza 
---

--- v4l-dvb/linux/drivers/media/video/zr364xx.c 2009-03-27
15:18:54.050413997 -0300
+++ v4l-dvb/linux-lvs/drivers/media/video/zr364xx.c 2009-03-27
15:22:47.914414277 -0300

... stripped off to not bloat the e-mail.






--
Antoine "Royale" Jacquet
http://royale.zerezo.com
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Implement V4L2_CAP_STREAMING for zr364xx driver

2009-07-11 Thread Lamarque Vieira Souza
Hi guys. Any news about this patch? I really think is important to make 
zr364xx driver works with libv4l, mplayer, kopete and skype. Maintaining this 
patch out of tree is also troublesome for me, I would really appreciate if you 
could add it to the tree. If there is any problem with the patch let me know 
that will fix it.

Em Thursday 02 July 2009, Lamarque Vieira Souza escreveu:
>   Hi all,
>
>   I have noticed the patch mentioned in the subject was not included in
> 2.6.30. Do you plan to add it to 2.6.31?
>
> Em Saturday 28 March 2009, Lamarque Vieira Souza escreveu:
> > This patch implements V4L2_CAP_STREAMING for the zr364xx driver, by
> > converting the driver to use videobuf.
> >
> > Tested with Creative PC-CAM 880.
> >
> > It basically:
> > . implements V4L2_CAP_STREAMING using videobuf;
> >
> > . re-implements V4L2_CAP_READWRITE using videobuf;
> >
> > . copies cam->udev->product to the card field of the v4l2_capability
> > struct. That gives more information to the users about the webcam;
> >
> > . moves the brightness setting code from before requesting a frame (in
> > read_frame) to the vidioc_s_ctrl ioctl. This way the brightness code is
> > executed only when the application requests a change in brightness and
> > not before every frame read;
> >
> > . comments part of zr364xx_vidioc_try_fmt_vid_cap that says that Skype +
> > libv4l do not work.
> >
> > This patch fixes zr364xx for applications such as mplayer,
> > Kopete+libv4l and Skype+libv4l can make use of the webcam that comes
> > with zr364xx chip.
> >
> > Signed-off-by: Lamarque V. Souza 
> > ---
> >
> > --- v4l-dvb/linux/drivers/media/video/zr364xx.c 2009-03-27
> > 15:18:54.050413997 -0300
> > +++ v4l-dvb/linux-lvs/drivers/media/video/zr364xx.c 2009-03-27
> > 15:22:47.914414277 -0300
>
> ... stripped off to not bloat the e-mail.


-- 
Lamarque V. Souza
http://www.geographicguide.com/brazil.htm
Linux User #57137 - http://counter.li.org/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Implement V4L2_CAP_STREAMING for zr364xx driver

2009-07-02 Thread Lamarque Vieira Souza
Hi all,

I have noticed the patch mentioned in the subject was not included in 
2.6.30. 
Do you plan to add it to 2.6.31?

Em Saturday 28 March 2009, Lamarque Vieira Souza escreveu:
> This patch implements V4L2_CAP_STREAMING for the zr364xx driver, by
> converting the driver to use videobuf.
>
> Tested with Creative PC-CAM 880.
>
> It basically:
> . implements V4L2_CAP_STREAMING using videobuf;
>
> . re-implements V4L2_CAP_READWRITE using videobuf;
>
> . copies cam->udev->product to the card field of the v4l2_capability
> struct. That gives more information to the users about the webcam;
>
> . moves the brightness setting code from before requesting a frame (in
> read_frame) to the vidioc_s_ctrl ioctl. This way the brightness code is
> executed only when the application requests a change in brightness and
> not before every frame read;
>
> . comments part of zr364xx_vidioc_try_fmt_vid_cap that says that Skype +
> libv4l do not work.
>
> This patch fixes zr364xx for applications such as mplayer,
> Kopete+libv4l and Skype+libv4l can make use of the webcam that comes
> with zr364xx chip.
>
> Signed-off-by: Lamarque V. Souza 
> ---
>
> --- v4l-dvb/linux/drivers/media/video/zr364xx.c   2009-03-27
> 15:18:54.050413997 -0300
> +++ v4l-dvb/linux-lvs/drivers/media/video/zr364xx.c   2009-03-27
> 15:22:47.914414277 -0300
... stripped off to not bloat the e-mail.

-- 
Lamarque V. Souza
http://www.geographicguide.com/brazil.htm
Linux User #57137 - http://counter.li.org/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Implement V4L2_CAP_STREAMING for zr364xx driver

2009-03-28 Thread Lamarque Vieira Souza
Em Saturday 28 March 2009, Hans de Goede escreveu:
> On 03/28/2009 11:11 AM, Lamarque Vieira Souza wrote:
> > This patch implements V4L2_CAP_STREAMING for the zr364xx driver, by
> > converting the driver to use videobuf.
> >
> > Tested with Creative PC-CAM 880.
> >
> > It basically:
> > . implements V4L2_CAP_STREAMING using videobuf;
> >
> > . re-implements V4L2_CAP_READWRITE using videobuf;
> >
> > . copies cam->udev->product to the card field of the v4l2_capability
> > struct. That gives more information to the users about the webcam;
> >
> > . moves the brightness setting code from before requesting a frame (in
> > read_frame) to the vidioc_s_ctrl ioctl. This way the brightness code is
> > executed only when the application requests a change in brightness and
> > not before every frame read;
> >
> > . comments part of zr364xx_vidioc_try_fmt_vid_cap that says that Skype +
> > libv4l do not work.
>
> Note that this may make things work, but is not correct, applications
> which properly honor the field value may get bitten by this. The correct
> fix is to unconditionally set the field value to V4L2_FIELD_NONE.

The part of zr364xx_vidioc_try_fmt_vid_cap which was commented was the 
"if" 
that checks the field value, now the driver does not do the check, it always 
set the field value to V4L2_FIELD_NONE, since that is the only value that the 
card accepts.

> > This patch fixes zr364xx for applications such as mplayer,
> > Kopete+libv4l and Skype+libv4l can make use of the webcam that comes
> > with zr364xx chip.
> >
> > Signed-off-by: Lamarque V. Souza
>
> 
>
> Regards,
>
> Hans


-- 
Lamarque V. Souza
http://www.geographicguide.com/brazil.htm
Linux User #57137 - http://counter.li.org/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Implement V4L2_CAP_STREAMING for zr364xx driver

2009-03-28 Thread Hans de Goede

On 03/28/2009 11:11 AM, Lamarque Vieira Souza wrote:

This patch implements V4L2_CAP_STREAMING for the zr364xx driver, by
converting the driver to use videobuf.

Tested with Creative PC-CAM 880.

It basically:
. implements V4L2_CAP_STREAMING using videobuf;

. re-implements V4L2_CAP_READWRITE using videobuf;

. copies cam->udev->product to the card field of the v4l2_capability struct.
That gives more information to the users about the webcam;

. moves the brightness setting code from before requesting a frame (in
read_frame) to the vidioc_s_ctrl ioctl. This way the brightness code is
executed only when the application requests a change in brightness and
not before every frame read;

. comments part of zr364xx_vidioc_try_fmt_vid_cap that says that Skype +
libv4l do not work.



Note that this may make things work, but is not correct, applications
which properly honor the field value may get bitten by this. The correct
fix is to unconditionally set the field value to V4L2_FIELD_NONE.



This patch fixes zr364xx for applications such as mplayer,
Kopete+libv4l and Skype+libv4l can make use of the webcam that comes
with zr364xx chip.

Signed-off-by: Lamarque V. Souza




Regards,

Hans
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Implement V4L2_CAP_STREAMING for zr364xx driver

2009-03-28 Thread Lamarque Vieira Souza
This patch implements V4L2_CAP_STREAMING for the zr364xx driver, by
converting the driver to use videobuf.

Tested with Creative PC-CAM 880.

It basically:
. implements V4L2_CAP_STREAMING using videobuf;

. re-implements V4L2_CAP_READWRITE using videobuf;

. copies cam->udev->product to the card field of the v4l2_capability struct.
That gives more information to the users about the webcam;

. moves the brightness setting code from before requesting a frame (in
read_frame) to the vidioc_s_ctrl ioctl. This way the brightness code is
executed only when the application requests a change in brightness and
not before every frame read;

. comments part of zr364xx_vidioc_try_fmt_vid_cap that says that Skype + 
libv4l do not work.

This patch fixes zr364xx for applications such as mplayer,
Kopete+libv4l and Skype+libv4l can make use of the webcam that comes
with zr364xx chip.

Signed-off-by: Lamarque V. Souza 
---

--- v4l-dvb/linux/drivers/media/video/zr364xx.c 2009-03-27 15:18:54.050413997 
-0300
+++ v4l-dvb/linux-lvs/drivers/media/video/zr364xx.c 2009-03-27 
15:22:47.914414277 -0300
@@ -1,5 +1,5 @@
 /*
- * Zoran 364xx based USB webcam module version 0.72
+ * Zoran 364xx based USB webcam module version 0.73
  *
  * Allows you to use your USB webcam with V4L2 applications
  * This is still in heavy developpement !
@@ -10,6 +10,8 @@
  * Heavily inspired by usb-skeleton.c, vicam.c, cpia.c and spca50x.c drivers
  * V4L2 version inspired by meye.c driver
  *
+ * Some video buffer code by Lamarque based on s2255drv.c and vivi.c drivers.
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -25,7 +27,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-
 #include 
 #include 
 #include 
@@ -36,25 +37,34 @@
 #include 
 #include 
 #include 
+#include 
 #include "compat.h"
 
 
 /* Version Information */
-#define DRIVER_VERSION "v0.72"
+#define DRIVER_VERSION "v0.73"
+#define ZR364_VERSION_CODE KERNEL_VERSION(0, 7, 3)
 #define DRIVER_AUTHOR "Antoine Jacquet, http://royale.zerezo.com/";
 #define DRIVER_DESC "Zoran 364xx"
 
 
 /* Camera */
-#define FRAMES 2
+#define FRAMES 1
 #define MAX_FRAME_SIZE 10
 #define BUFFER_SIZE 0x1000
 #define CTRL_TIMEOUT 500
 
+#define ZR364XX_DEF_BUFS   4
+#define ZR364XX_READ_IDLE  0
+#define ZR364XX_READ_FRAME 1
 
 /* Debug macro */
-#define DBG(x...) if (debug) printk(KERN_INFO KBUILD_MODNAME x)
-
+#define DBG(fmt, args...) \
+   do { \
+   if (debug) { \
+   printk(KERN_INFO KBUILD_MODNAME " " fmt, ##args); \
+   } \
+   } while (0)
 
 /* Init methods, need to find nicer names for these
  * the exact names of the chipsets would be the best if someone finds it */
@@ -103,24 +113,97 @@ static struct usb_device_id device_table
 
 MODULE_DEVICE_TABLE(usb, device_table);
 
+struct zr364xx_mode {
+   u32 color;  /* output video color format */
+   u32 brightness; /* brightness */
+};
+
+/* frame structure */
+struct zr364xx_framei {
+   unsigned long ulState;  /* ulState:ZR364XX_READ_IDLE,
+  ZR364XX_READ_FRAME */
+   void *lpvbits;  /* image data */
+   unsigned long cur_size; /* current data copied to it */
+};
+
+/* image buffer structure */
+struct zr364xx_bufferi {
+   unsigned long dwFrames; /* number of frames in buffer */
+   struct zr364xx_framei frame[FRAMES];/* array of FRAME structures */
+};
+
+struct zr364xx_dmaqueue {
+   struct list_headactive;
+   struct zr364xx_camera   *cam;
+};
+
+struct zr364xx_pipeinfo {
+   u32 transfer_size;
+   u8 *transfer_buffer;
+   u32 transfer_flags;;
+   u32 state;
+   u32 prev_state;
+   u32 urb_size;
+   void *stream_urb;
+   void *cam;  /* back pointer to zr364xx_camera struct */
+   u32 err_count;
+   u32 idx;
+   u32 priority_set;
+};
+
+struct zr364xx_fmt {
+   char *name;
+   u32 fourcc;
+   int depth;
+};
+
+/* image formats.  */
+static const struct zr364xx_fmt formats[] = {
+   {
+   .name = "JPG",
+   .fourcc = V4L2_PIX_FMT_JPEG,
+   .depth = 24
+   }
+};
 
 /* Camera stuff */
 struct zr364xx_camera {
struct usb_device *udev;/* save off the usb device pointer */
struct usb_interface *interface;/* the interface for this device */
struct video_device *vdev;  /* v4l video device */
-   u8 *framebuf;
int nb;
-   unsigned char *buffer;
+   struct zr364xx_bufferi  buffer;
int skip;
-   int brightness;
int width;
int height;
int method;
struct mutex lock;
+   struct mutex open_lock;
int users;
+
+   spinlock_t  slock;
+