* PATCH: some pac7302 autogain improvements
@ 2008-08-26 14:30 Hans de Goede
0 siblings, 0 replies; only message in thread
From: Hans de Goede @ 2008-08-26 14:30 UTC (permalink / raw)
To: Jean-Francois Moine; +Cc: Linux and Kernel Video
[-- 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-08-26 14:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-26 14:30 PATCH: some pac7302 autogain improvements Hans de Goede
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.