Just a small patch that fixed a problem that prevents sn9c20x driver to work with multiple cams.
Regards Vasily
From 5077fe668336dd71ee7a1ec5bb917e4bffd59fd3 Mon Sep 17 00:00:00 2001 From: Vasily Khoruzhick <[email protected]> Date: Wed, 7 Jan 2009 17:57:21 +0200 Subject: [PATCH] Added old_yavg field to the camera struct, removed static variable old_yavg. Soft AE should work now with multiple cams Signed-off-by: Vasily Khoruzhick <[email protected]> --- sn9c20x-dev.c | 16 ++++++++-------- sn9c20x.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sn9c20x-dev.c b/sn9c20x-dev.c index 5b9fd8e..e0d4e13 100644 --- a/sn9c20x-dev.c +++ b/sn9c20x-dev.c @@ -114,6 +114,7 @@ int sn9c20x_initialize_sensor(struct usb_sn9c20x *dev) dev->camera.max_yavg = 150; dev->camera.min_stable_yavg = 70; dev->camera.max_stable_yavg = 140; + dev->camera.old_yavg = -1; /* Probe sensor first if sensor set to probe*/ if (dev->camera.sensor == PROBE_SENSOR) { @@ -290,7 +291,6 @@ int dev_sn9c20x_button_detection(struct usb_sn9c20x *dev) int dev_sn9c20x_perform_soft_ae(struct usb_sn9c20x *dev) { int yavg; - static int old_yavg = -1; int koef = 100, new_exp, i; yavg = -1; i = 10; @@ -299,7 +299,7 @@ int dev_sn9c20x_perform_soft_ae(struct usb_sn9c20x *dev) return -1; yavg = atomic_read(&dev->camera.yavg); - UDIA_INFO("Sensor YAVG: %d\n", yavg); + UDIA_DEBUG("Sensor YAVG: %d\n", yavg); if (yavg < 0) { /* Can't get YAVG - we have nothing to do */ return -1; @@ -310,13 +310,13 @@ int dev_sn9c20x_perform_soft_ae(struct usb_sn9c20x *dev) /* yavg can't be 0 - in that way new_exp == infinity */ if (yavg == 0) yavg = 1; - if (old_yavg != -1) { + if (dev->camera.old_yavg != -1) { /* Previous correction was made to make image darker, * but we made it too dark. Calculating our error * and taking it into account. * Usually error is 0.7 - 2, so we multiply it by 100 */ - if (old_yavg > dev->camera.max_yavg) + if (dev->camera.old_yavg > dev->camera.max_yavg) koef = 100 * dev->camera. min_stable_yavg / yavg; else @@ -335,7 +335,7 @@ int dev_sn9c20x_perform_soft_ae(struct usb_sn9c20x *dev) if (new_exp < 0x1) new_exp = 1; - old_yavg = yavg; + dev->camera.old_yavg = yavg; /* Applying new exposure */ dev->vsettings.exposure = new_exp; @@ -347,14 +347,14 @@ int dev_sn9c20x_perform_soft_ae(struct usb_sn9c20x *dev) /* yavg can't be 0 - in that way new_exp == infinity */ if (yavg == 0) yavg = 1; - if (old_yavg != -1) { + if (dev->camera.old_yavg != -1) { /* Previous correction was made to make image brighter, * but we made it too bright. Calculating our error * and taking it into account. * Usually error is 0.7 - 2, so we multiply it by 100 */ - if (old_yavg < dev->camera.min_yavg) + if (dev->camera.old_yavg < dev->camera.min_yavg) koef = 100 * yavg / dev->camera. max_stable_yavg; else @@ -373,7 +373,7 @@ int dev_sn9c20x_perform_soft_ae(struct usb_sn9c20x *dev) if (new_exp < 0x1) new_exp = 1; - old_yavg = yavg; + dev->camera.old_yavg = yavg; /* Applying new exposure */ dev->vsettings.exposure = new_exp; diff --git a/sn9c20x.h b/sn9c20x.h index 061a4e9..b463624 100644 --- a/sn9c20x.h +++ b/sn9c20x.h @@ -370,7 +370,7 @@ struct sn9c20x_camera { __u8 i2c_flags; __u8 address; - int min_yavg, max_yavg, min_stable_yavg, max_stable_yavg; + int min_yavg, max_yavg, min_stable_yavg, max_stable_yavg, old_yavg; atomic_t yavg; -- 1.6.0.6
signature.asc
Description: This is a digitally signed message part.
