From: Hans de Goede <j.w.r.degoede@hhs.nl>
To: Jean-Francois Moine <moinejf@free.fr>
Cc: Linux and Kernel Video <video4linux-list@redhat.com>
Subject: PATCH: some pac7302 autogain improvements
Date: Tue, 26 Aug 2008 16:30:02 +0200 [thread overview]
Message-ID: <48B4136A.1060901@hhs.nl> (raw)
[-- Attachment #1: Type: text/plain, Size: 113 bytes --]
Hi,
The attached patch stops the pac7302 autogain from oscilating under certain
circumstances.
Regards,
Hans
[-- Attachment #2: gspca-pac7302-autogain-tweaks.patch --]
[-- Type: text/plain, Size: 3282 bytes --]
Stop the pac7302 autogain from oscilating under certain circumstances.
Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl>
diff -r 1cf9e4187e0a linux/drivers/media/video/gspca/pac7311.c
--- a/linux/drivers/media/video/gspca/pac7311.c Tue Aug 26 12:34:35 2008 +0200
+++ b/linux/drivers/media/video/gspca/pac7311.c Tue Aug 26 16:06:32 2008 +0200
@@ -39,7 +39,7 @@
Address Description
0x02 Clock divider 2-63, fps =~ 60 / val. Must be a multiple of 3 on
- the 7302, so one of 3, 6, 9, ...
+ the 7302, so one of 3, 6, 9, ..., except when between 6 and 12?
-/0x0f Master gain 1-245, low value = high gain
0x10/- Master gain 0-31
-/0x10 Another gain 0-15, limited influence (1-2x gain I guess)
@@ -640,8 +640,9 @@
if (sd->sensor == SENSOR_PAC7302) {
/* On the pac7302 reg2 MUST be a multiple of 3, so round it to
- the nearest multiple of 3 */
- reg = ((reg + 1) / 3) * 3;
+ the nearest multiple of 3, except when between 6 and 12? */
+ if (reg < 6 || reg > 12)
+ reg = ((reg + 1) / 3) * 3;
reg_w(gspca_dev, 0xff, 0x03); /* page 3 */
reg_w(gspca_dev, 0x02, reg);
} else {
@@ -780,20 +781,32 @@
{
struct sd *sd = (struct sd *) gspca_dev;
int avg_lum = atomic_read(&sd->avg_lum);
- int desired_lum;
+ int desired_lum, deadzone;
if (avg_lum == -1)
return;
- if (sd->sensor == SENSOR_PAC7302)
- desired_lum = 70 + sd->brightness * 2;
- else
+ 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;
+ }
if (sd->autogain_ignore_frames > 0)
sd->autogain_ignore_frames--;
else if (gspca_auto_gain_n_exposure(gspca_dev, avg_lum, desired_lum,
- 10, GAIN_KNEE, EXPOSURE_KNEE))
+ deadzone, GAIN_KNEE, EXPOSURE_KNEE))
sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES;
}
@@ -821,7 +834,11 @@
int n, lum_offset, footer_length;
if (sd->sensor == SENSOR_PAC7302) {
- lum_offset = 34 + sizeof pac_sof_marker;
+ /* 6 bytes after the FF D9 EOF marker a number of lumination
+ bytes are send corresponding to different parts of the
+ image, the 14th and 15th byte after the EOF seem to
+ correspond to the center of the image */
+ lum_offset = 61 + sizeof pac_sof_marker;
footer_length = 74;
} else {
lum_offset = 24 + sizeof pac_sof_marker;
@@ -848,18 +865,11 @@
/* Get average lumination */
if (gspca_dev->last_packet_type == LAST_PACKET &&
- n >= lum_offset) {
- if (sd->sensor == SENSOR_PAC7302)
- atomic_set(&sd->avg_lum,
- (data[-lum_offset] << 8) |
+ n >= lum_offset)
+ atomic_set(&sd->avg_lum, data[-lum_offset] +
data[-lum_offset + 1]);
- else
- atomic_set(&sd->avg_lum,
- data[-lum_offset] +
- data[-lum_offset + 1]);
- } else {
+ else
atomic_set(&sd->avg_lum, -1);
- }
/* Start the new frame with the jpeg header */
gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
[-- Attachment #3: Type: text/plain, Size: 164 bytes --]
--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
reply other threads:[~2008-08-26 14:19 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=48B4136A.1060901@hhs.nl \
--to=j.w.r.degoede@hhs.nl \
--cc=moinejf@free.fr \
--cc=video4linux-list@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.