35 s32 gain, orig_gain, exposure, orig_exposure;
46 steps =
abs(desired_avg_lum - avg_lum) / deadzone;
48 PDEBUG(D_FRAM,
"autogain: lum: %d, desired: %d, steps: %d",
49 avg_lum, desired_avg_lum, steps);
51 for (i = 0; i <
steps; i++) {
52 if (avg_lum > desired_avg_lum) {
55 else if (exposure > exposure_knee)
57 else if (gain > gspca_dev->
gain->default_value)
59 else if (exposure > gspca_dev->
exposure->minimum)
61 else if (gain > gspca_dev->
gain->minimum)
66 if (gain < gspca_dev->gain->default_value)
68 else if (exposure < exposure_knee)
70 else if (gain < gain_knee)
72 else if (exposure < gspca_dev->exposure->maximum)
74 else if (gain < gspca_dev->gain->maximum)
81 if (gain != orig_gain) {
85 if (exposure != orig_exposure) {
91 PDEBUG(D_FRAM,
"autogain: changed gain: %d, expo: %d",
115 s32 gain_low, gain_high,
gain, orig_gain, exposure, orig_exposure;
124 gain_low = (gspca_dev->
gain->maximum - gspca_dev->
gain->minimum) /
125 5 * 2 + gspca_dev->
gain->minimum;
126 gain_high = (gspca_dev->
gain->maximum - gspca_dev->
gain->minimum) /
127 5 * 4 + gspca_dev->
gain->minimum;
131 steps = (desired_avg_lum - avg_lum) / deadzone;
133 PDEBUG(D_FRAM,
"autogain: lum: %d, desired: %d, steps: %d",
134 avg_lum, desired_avg_lum, steps);
136 if ((gain + steps) > gain_high &&
137 exposure < gspca_dev->exposure->maximum) {
141 }
else if ((gain + steps) < gain_low &&
142 exposure > gspca_dev->
exposure->minimum) {
148 if (gain > gspca_dev->
gain->maximum)
149 gain = gspca_dev->
gain->maximum;
150 else if (gain < gspca_dev->gain->minimum)
151 gain = gspca_dev->
gain->minimum;
164 if (gain != orig_gain) {
168 if (exposure != orig_exposure) {
174 PDEBUG(D_FRAM,
"autogain: changed gain: %d, expo: %d",