public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: "Németh Márton" <nm127@freemail.hu>
To: Jean-Francois Moine <moinejf@free.fr>,
	Hans de Goede <hdegoede@redhat.com>,
	V4L Mailing List <linux-media@vger.kernel.org>
Cc: Thomas Kaiser <thomas@kaiser-linux.li>,
	Theodore Kilgore <kilgota@auburn.edu>,
	Kyle Guinn <elyk03@gmail.com>
Subject: [PATCH 09/21] gspca pac7302/pac7311: separate dq_callback
Date: Sun, 01 Nov 2009 00:14:51 +0100	[thread overview]
Message-ID: <4AECC4EB.7070504@freemail.hu> (raw)

From: Márton Németh <nm127@freemail.hu>

Separate the dq_callback function. Remove the run-time decision for
PAC7302 and PAC7311 sensors.

Signed-off-by: Márton Németh <nm127@freemail.hu>
Cc: Thomas Kaiser <thomas@kaiser-linux.li>
Cc: Theodore Kilgore <kilgota@auburn.edu>
Cc: Kyle Guinn <elyk03@gmail.com>
---
diff -uprN i/drivers/media/video/gspca/pac7311.c j/drivers/media/video/gspca/pac7311.c
--- i/drivers/media/video/gspca/pac7311.c	2009-10-30 17:59:39.000000000 +0100
+++ j/drivers/media/video/gspca/pac7311.c	2009-10-30 18:00:55.000000000 +0100
@@ -820,7 +820,7 @@ static void pac7311_sd_stop0(struct gspc
 /* Include pac common sof detection functions */
 #include "pac_common.h"

-static void do_autogain(struct gspca_dev *gspca_dev)
+static void pac7302_do_autogain(struct gspca_dev *gspca_dev)
 {
 	struct sd *sd = (struct sd *) gspca_dev;
 	int avg_lum = atomic_read(&sd->avg_lum);
@@ -829,22 +829,36 @@ static void do_autogain(struct gspca_dev
 	if (avg_lum == -1)
 		return;

-	if (sd->sensor == SENSOR_PAC7302) {
-		desired_lum = 270 + sd->brightness * 4;
-		/* Hack hack, with the 7202 the first exposure step is
-		   pretty large, so if we're about to make the first
-		   exposure increase make the deadzone large to avoid
-		   oscilating */
-		if (desired_lum > avg_lum && sd->gain == GAIN_DEF &&
-				sd->exposure > EXPOSURE_DEF &&
-				sd->exposure < 42)
-			deadzone = 90;
-		else
-			deadzone = 30;
-	} else {
-		desired_lum = 200;
-		deadzone = 20;
-	}
+	desired_lum = 270 + sd->brightness * 4;
+	/* Hack hack, with the 7202 the first exposure step is
+	   pretty large, so if we're about to make the first
+	   exposure increase make the deadzone large to avoid
+	   oscilating */
+	if (desired_lum > avg_lum && sd->gain == GAIN_DEF &&
+			sd->exposure > EXPOSURE_DEF &&
+			sd->exposure < 42)
+		deadzone = 90;
+	else
+		deadzone = 30;
+
+	if (sd->autogain_ignore_frames > 0)
+		sd->autogain_ignore_frames--;
+	else if (gspca_auto_gain_n_exposure(gspca_dev, avg_lum, desired_lum,
+			deadzone, GAIN_KNEE, EXPOSURE_KNEE))
+		sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES;
+}
+
+static void pac7311_do_autogain(struct gspca_dev *gspca_dev)
+{
+	struct sd *sd = (struct sd *) gspca_dev;
+	int avg_lum = atomic_read(&sd->avg_lum);
+	int desired_lum, deadzone;
+
+	if (avg_lum == -1)
+		return;
+
+	desired_lum = 200;
+	deadzone = 20;

 	if (sd->autogain_ignore_frames > 0)
 		sd->autogain_ignore_frames--;
@@ -1180,7 +1194,7 @@ static struct sd_desc pac7302_sd_desc =
 	.stopN = pac7302_sd_stopN,
 	.stop0 = pac7302_sd_stop0,
 	.pkt_scan = pac7302_sd_pkt_scan,
-	.dq_callback = do_autogain,
+	.dq_callback = pac7302_do_autogain,
 };

 /* sub-driver description for pac7311 */
@@ -1194,7 +1208,7 @@ static struct sd_desc pac7311_sd_desc =
 	.stopN = pac7311_sd_stopN,
 	.stop0 = pac7311_sd_stop0,
 	.pkt_scan = pac7311_sd_pkt_scan,
-	.dq_callback = do_autogain,
+	.dq_callback = pac7311_do_autogain,
 };

 /* -- module initialisation -- */

                 reply	other threads:[~2009-10-31 23:14 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=4AECC4EB.7070504@freemail.hu \
    --to=nm127@freemail.hu \
    --cc=elyk03@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=kilgota@auburn.edu \
    --cc=linux-media@vger.kernel.org \
    --cc=moinejf@free.fr \
    --cc=thomas@kaiser-linux.li \
    /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