linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arvydas Sidorenko <asido4@gmail.com>
To: mchehab@infradead.org
Cc: asido4@gmail.com, hverkuil@xs4all.nl, arnd@arndb.de,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andrea Anacleto <andreaanacleto@libero.it>
Subject: [PATCH] drivers/media/video/stk-webcam.c: webcam LED bug fix [IMPROVED]
Date: Wed, 21 Sep 2011 16:58:31 +0200	[thread overview]
Message-ID: <1316617111-14548-1-git-send-email-asido4@gmail.com> (raw)

This is an improved version of the patch I sent a little ago.

The problem was:
	On my DC-1125 webcam chip from Syntek, whenever the webcam turns
	on, the LED light on it is turned on also and never turns off again unless
	system is shut downed or restarted.

The previous version seemed to break some other laptop webcam work. Thanks
to Andrea Anacleto for the bug report and solution.

Signed-off-by: Andrea Anacleto <andreaanacleto@libero.it>
Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
---
 drivers/media/video/stk-webcam.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index d1a2cef..af57d80 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -55,6 +55,8 @@ MODULE_AUTHOR("Jaime Velasco Juan <jsagarribay@gmail.com> and Nicolas VIVIEN");
 MODULE_DESCRIPTION("Syntek DC1125 webcam driver");
 
 
+/* bool for webcam LED management */
+int first_init = 1;
 
 /* Some cameras have audio interfaces, we aren't interested in those */
 static struct usb_device_id stkwebcam_table[] = {
@@ -561,6 +563,12 @@ static int v4l_stk_open(struct file *fp)
 	if (dev == NULL || !is_present(dev)) {
 		return -ENXIO;
 	}
+
+	if (!first_init)
+		stk_camera_write_reg(dev, 0x0, 0x24);
+	else
+		first_init = 0;
+
 	fp->private_data = dev;
 	usb_autopm_get_interface(dev->interface);
 
@@ -574,6 +582,7 @@ static int v4l_stk_release(struct file *fp)
 	if (dev->owner == fp) {
 		stk_stop_stream(dev);
 		stk_free_buffers(dev);
+		stk_camera_write_reg(dev, 0x0, 0x49); /* turn off the LED */
 		dev->owner = NULL;
 	}
 
@@ -1350,6 +1359,7 @@ static int stk_camera_resume(struct usb_interface *intf)
 		return 0;
 	unset_initialised(dev);
 	stk_initialise(dev);
+	stk_camera_write_reg(dev, 0x0, 0x49);
 	stk_setup_format(dev);
 	if (is_streaming(dev))
 		stk_start_stream(dev);
-- 
1.7.4.4


                 reply	other threads:[~2011-09-21 15:04 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=1316617111-14548-1-git-send-email-asido4@gmail.com \
    --to=asido4@gmail.com \
    --cc=andreaanacleto@libero.it \
    --cc=arnd@arndb.de \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.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 NNTP newsgroup(s).