linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aniruddha Bhattacharyya <aniruddha.aot@gmail.com>
To: linux-c-programming@vger.kernel.org
Cc: Aniruddha Bhattacharyya <aniruddha.aot@gmail.com>
Subject: UVCVideo - Webcam not stopping after opening and closing the device file /dev/video0
Date: Wed, 22 Aug 2012 02:32:25 +0530	[thread overview]
Message-ID: <CAOXuEsyMr0BEMoOGDismRQyvs7fxX-JDjOEvnFeffDOgTewqxw@mail.gmail.com> (raw)

Hi,


Sorry for interrupting.

I have a (174f:5a35) Syntek Sonix 1.3MPixel USB 2.0 Camera (Most
probably based on ov9655  chipset/sensor) on a Asus laptop (G1Sn).
The device is working fine when required.
But unfortunately, it automatically gets started (green light
indicator goes on) after each page refresh in web browsers having some
flash content.

As per my understanding,

1) The flash player tries to check for webcam existence. It opens
/dev/video0 device file and after doing it's probing it closes the
device.
  Opening the device switched it on and green light stays on.
2) Unfortunately the device is kept awake even after the flash player
closes the device handle.

Trace returns following output during this:
[116432.340419] uvcvideo: uvc_v4l2_open
[116432.388332] uvcvideo: Resuming interface 0
[116432.388338] uvcvideo: Resuming interface 1
[116432.723761] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QUERYCAP)
[116432.723780] uvcvideo: uvc_v4l2_release
[116433.589880] uvcvideo: uvc_v4l2_open
[116433.589916] uvcvideo: uvc_v4l2_ioctl(VIDIOC_QUERYCAP)
[116433.589934] uvcvideo: uvc_v4l2_release
[116435.804067] uvcvideo: Suspending interface 1
[116435.804073] uvcvideo: Suspending interface 0

lsusb output:
Bus 001 Device 002: ID 174f:5a35 Syntek Sonix 1.3MPixel USB 2.0 Camera


So,I wrote a test program using v4l2,
What I did is, I opened the device (it switches on the usb cam) and I
never asked for starting the streaming.
Then, unless I did this before closing the device handle it'll keep
the device on :

    type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    xioctl(fd, VIDIOC_STREAMOFF, &type);




So the following code will switch on the device and keep it going
forever: (unless I do the above)
void test()
{
     char     *dev_name = "/dev/video0";
     int fd;
     enum v4l2_buf_type              type;


     fd = v4l2_open(dev_name,  O_RDWR | O_NONBLOCK , 0);
                        //switches on the device
     if (fd < 0) {
          perror("Cannot open device /dev/video0 : ");
          exit(EXIT_FAILURE);
     }

    //IMP: Only way to stop this behavior is to uncomment the following..
    // type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    // xioctl(fd, VIDIOC_STREAMOFF, &type);              //only way to

       switch it off

     v4l2_close(fd);      //never stops the device
}






My question is, is it the proper behavior? IMHO, It is switching on
the webcam unnecessarily,

What I can do to stop this ? Currently I had to write a daemon to do
this manually after 10-15 minutes.



[Kernel: Linux aniruddha-G1Sn 3.2.0-23-generic #36-Ubuntu SMP Tue Apr
10 20:39:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Linux Mint13]


Thanking you,
Aniruddha Bhattacharyya

                 reply	other threads:[~2012-08-21 21:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOXuEsyMr0BEMoOGDismRQyvs7fxX-JDjOEvnFeffDOgTewqxw@mail.gmail.com \
    --to=aniruddha.aot@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).