Commit ccab75e2 authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab

[media] gspca_pac7311: Switch to coarse expo autogain algorithm

We can only control the clockdivider to control exposure on the pac7311,
making our expo control coarse, switch to an autogain algorithm optimized for
this.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent a5340ce5
...@@ -70,6 +70,8 @@ enum e_ctrl { ...@@ -70,6 +70,8 @@ enum e_ctrl {
struct sd { struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */ struct gspca_dev gspca_dev; /* !! must be the first item */
struct gspca_ctrl ctrls[NCTRLS]; struct gspca_ctrl ctrls[NCTRLS];
int exp_too_low_cnt;
int exp_too_high_cnt;
u8 sof_read; u8 sof_read;
u8 autogain_ignore_frames; u8 autogain_ignore_frames;
...@@ -81,7 +83,6 @@ struct sd { ...@@ -81,7 +83,6 @@ struct sd {
static void setcontrast(struct gspca_dev *gspca_dev); static void setcontrast(struct gspca_dev *gspca_dev);
static void setgain(struct gspca_dev *gspca_dev); static void setgain(struct gspca_dev *gspca_dev);
static void setexposure(struct gspca_dev *gspca_dev); static void setexposure(struct gspca_dev *gspca_dev);
static void setautogain(struct gspca_dev *gspca_dev);
static void sethvflip(struct gspca_dev *gspca_dev); static void sethvflip(struct gspca_dev *gspca_dev);
static const struct ctrl sd_ctrls[] = { static const struct ctrl sd_ctrls[] = {
...@@ -106,7 +107,6 @@ static const struct ctrl sd_ctrls[] = { ...@@ -106,7 +107,6 @@ static const struct ctrl sd_ctrls[] = {
.maximum = 244, .maximum = 244,
.step = 1, .step = 1,
.default_value = 122, .default_value = 122,
#define GAIN_KNEE 244 /* Gain seems to cause little noise on the 7311 */
}, },
.set_control = setgain, .set_control = setgain,
}, },
...@@ -118,8 +118,7 @@ static const struct ctrl sd_ctrls[] = { ...@@ -118,8 +118,7 @@ static const struct ctrl sd_ctrls[] = {
.minimum = 2, .minimum = 2,
.maximum = 63, .maximum = 63,
.step = 1, .step = 1,
.default_value = 2, /* 30 fps */ .default_value = 3, /* 20 fps, avoid using high compr. */
#define EXPOSURE_KNEE 6 /* 10 fps */
}, },
.set_control = setexposure, .set_control = setexposure,
}, },
...@@ -133,7 +132,6 @@ static const struct ctrl sd_ctrls[] = { ...@@ -133,7 +132,6 @@ static const struct ctrl sd_ctrls[] = {
.step = 1, .step = 1,
.default_value = 1, .default_value = 1,
}, },
.set_control = setautogain,
}, },
[HFLIP] = { [HFLIP] = {
{ {
...@@ -497,7 +495,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev) ...@@ -497,7 +495,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */ reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */
} }
#define WANT_REGULAR_AUTOGAIN #define WANT_COARSE_EXPO_AUTOGAIN
#include "autogain_functions.h" #include "autogain_functions.h"
static void do_autogain(struct gspca_dev *gspca_dev) static void do_autogain(struct gspca_dev *gspca_dev)
...@@ -514,8 +512,8 @@ static void do_autogain(struct gspca_dev *gspca_dev) ...@@ -514,8 +512,8 @@ static void do_autogain(struct gspca_dev *gspca_dev)
if (sd->autogain_ignore_frames > 0) if (sd->autogain_ignore_frames > 0)
sd->autogain_ignore_frames--; sd->autogain_ignore_frames--;
else if (auto_gain_n_exposure(gspca_dev, avg_lum, desired_lum, else if (coarse_grained_expo_autogain(gspca_dev, avg_lum, desired_lum,
deadzone, GAIN_KNEE, EXPOSURE_KNEE)) deadzone))
sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES; sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES;
} }
...@@ -619,22 +617,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, ...@@ -619,22 +617,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
gspca_frame_add(gspca_dev, INTER_PACKET, data, len); gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
} }
static void setautogain(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
if (sd->ctrls[AUTOGAIN].val) {
sd->ctrls[EXPOSURE].val = 2;
sd->ctrls[GAIN].val = 122;
if (gspca_dev->streaming) {
sd->autogain_ignore_frames =
PAC_AUTOGAIN_IGNORE_FRAMES;
setexposure(gspca_dev);
setgain(gspca_dev);
}
}
}
#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) #if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
u8 *data, /* interrupt packet data */ u8 *data, /* interrupt packet data */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment