Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 306327
b: refs/heads/master
c: 2421b3d
h: refs/heads/master
i:
  306325: 1dae642
  306323: 2590170
  306319: 1e39f71
v: v3
  • Loading branch information
Hans de Goede authored and Mauro Carvalho Chehab committed May 14, 2012
1 parent 21c0863 commit b2a838c
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 92 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0413d3b286076b052f624275897d243d5865e0d2
refs/heads/master: 2421b3dd7c5069938543cc1d6599fd29c52ac147
89 changes: 0 additions & 89 deletions trunk/drivers/media/video/gspca/gspca.c
Original file line number Diff line number Diff line change
Expand Up @@ -2435,95 +2435,6 @@ int gspca_resume(struct usb_interface *intf)
}
EXPORT_SYMBOL(gspca_resume);
#endif
/* -- cam driver utility functions -- */

/* auto gain and exposure algorithm based on the knee algorithm described here:
http://ytse.tricolour.net/docs/LowLightOptimization.html
Returns 0 if no changes were made, 1 if the gain and or exposure settings
where changed. */
int gspca_auto_gain_n_exposure(struct gspca_dev *gspca_dev, int avg_lum,
int desired_avg_lum, int deadzone, int gain_knee, int exposure_knee)
{
int i, steps, gain, orig_gain, exposure, orig_exposure, autogain;
const struct ctrl *gain_ctrl = NULL;
const struct ctrl *exposure_ctrl = NULL;
const struct ctrl *autogain_ctrl = NULL;
int retval = 0;

for (i = 0; i < gspca_dev->sd_desc->nctrls; i++) {
if (gspca_dev->ctrl_dis & (1 << i))
continue;
if (gspca_dev->sd_desc->ctrls[i].qctrl.id == V4L2_CID_GAIN)
gain_ctrl = &gspca_dev->sd_desc->ctrls[i];
if (gspca_dev->sd_desc->ctrls[i].qctrl.id == V4L2_CID_EXPOSURE)
exposure_ctrl = &gspca_dev->sd_desc->ctrls[i];
if (gspca_dev->sd_desc->ctrls[i].qctrl.id == V4L2_CID_AUTOGAIN)
autogain_ctrl = &gspca_dev->sd_desc->ctrls[i];
}
if (!gain_ctrl || !exposure_ctrl || !autogain_ctrl) {
PDEBUG(D_ERR, "Error: gspca_auto_gain_n_exposure called "
"on cam without (auto)gain/exposure");
return 0;
}

if (gain_ctrl->get(gspca_dev, &gain) ||
exposure_ctrl->get(gspca_dev, &exposure) ||
autogain_ctrl->get(gspca_dev, &autogain) || !autogain)
return 0;

orig_gain = gain;
orig_exposure = exposure;

/* If we are of a multiple of deadzone, do multiple steps to reach the
desired lumination fast (with the risc of a slight overshoot) */
steps = abs(desired_avg_lum - avg_lum) / deadzone;

PDEBUG(D_FRAM, "autogain: lum: %d, desired: %d, steps: %d",
avg_lum, desired_avg_lum, steps);

for (i = 0; i < steps; i++) {
if (avg_lum > desired_avg_lum) {
if (gain > gain_knee)
gain--;
else if (exposure > exposure_knee)
exposure--;
else if (gain > gain_ctrl->qctrl.default_value)
gain--;
else if (exposure > exposure_ctrl->qctrl.minimum)
exposure--;
else if (gain > gain_ctrl->qctrl.minimum)
gain--;
else
break;
} else {
if (gain < gain_ctrl->qctrl.default_value)
gain++;
else if (exposure < exposure_knee)
exposure++;
else if (gain < gain_knee)
gain++;
else if (exposure < exposure_ctrl->qctrl.maximum)
exposure++;
else if (gain < gain_ctrl->qctrl.maximum)
gain++;
else
break;
}
}

if (gain != orig_gain) {
gain_ctrl->set(gspca_dev, gain);
retval = 1;
}
if (exposure != orig_exposure) {
exposure_ctrl->set(gspca_dev, exposure);
retval = 1;
}

return retval;
}
EXPORT_SYMBOL(gspca_auto_gain_n_exposure);

/* -- module insert / remove -- */
static int __init gspca_init(void)
Expand Down
2 changes: 0 additions & 2 deletions trunk/drivers/media/video/gspca/gspca.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ void gspca_frame_add(struct gspca_dev *gspca_dev,
int gspca_suspend(struct usb_interface *intf, pm_message_t message);
int gspca_resume(struct usb_interface *intf);
#endif
int gspca_auto_gain_n_exposure(struct gspca_dev *gspca_dev, int avg_lum,
int desired_avg_lum, int deadzone, int gain_knee, int exposure_knee);
int gspca_expo_autogain(struct gspca_dev *gspca_dev, int avg_lum,
int desired_avg_lum, int deadzone, int gain_knee, int exposure_knee);
int gspca_coarse_grained_expo_autogain(struct gspca_dev *gspca_dev,
Expand Down

0 comments on commit b2a838c

Please sign in to comment.