aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-04-27 12:06:26 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-07 15:14:34 -0400
commitccab75e2831301a03ca1b126aa7375025dc50c88 (patch)
tree2cc6861e2b61a4defb547aeee8ea26c87af34ce4 /drivers
parenta5340ce50092e5458e1da489e06bc55398a76315 (diff)
[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: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/gspca/pac7311.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index d4c6ad2f1156..81f018406bbd 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -70,6 +70,8 @@ enum e_ctrl {
70struct sd { 70struct sd {
71 struct gspca_dev gspca_dev; /* !! must be the first item */ 71 struct gspca_dev gspca_dev; /* !! must be the first item */
72 struct gspca_ctrl ctrls[NCTRLS]; 72 struct gspca_ctrl ctrls[NCTRLS];
73 int exp_too_low_cnt;
74 int exp_too_high_cnt;
73 75
74 u8 sof_read; 76 u8 sof_read;
75 u8 autogain_ignore_frames; 77 u8 autogain_ignore_frames;
@@ -81,7 +83,6 @@ struct sd {
81static void setcontrast(struct gspca_dev *gspca_dev); 83static void setcontrast(struct gspca_dev *gspca_dev);
82static void setgain(struct gspca_dev *gspca_dev); 84static void setgain(struct gspca_dev *gspca_dev);
83static void setexposure(struct gspca_dev *gspca_dev); 85static void setexposure(struct gspca_dev *gspca_dev);
84static void setautogain(struct gspca_dev *gspca_dev);
85static void sethvflip(struct gspca_dev *gspca_dev); 86static void sethvflip(struct gspca_dev *gspca_dev);
86 87
87static const struct ctrl sd_ctrls[] = { 88static const struct ctrl sd_ctrls[] = {
@@ -106,7 +107,6 @@ static const struct ctrl sd_ctrls[] = {
106 .maximum = 244, 107 .maximum = 244,
107 .step = 1, 108 .step = 1,
108 .default_value = 122, 109 .default_value = 122,
109#define GAIN_KNEE 244 /* Gain seems to cause little noise on the 7311 */
110 }, 110 },
111 .set_control = setgain, 111 .set_control = setgain,
112 }, 112 },
@@ -118,8 +118,7 @@ static const struct ctrl sd_ctrls[] = {
118 .minimum = 2, 118 .minimum = 2,
119 .maximum = 63, 119 .maximum = 63,
120 .step = 1, 120 .step = 1,
121 .default_value = 2, /* 30 fps */ 121 .default_value = 3, /* 20 fps, avoid using high compr. */
122#define EXPOSURE_KNEE 6 /* 10 fps */
123 }, 122 },
124 .set_control = setexposure, 123 .set_control = setexposure,
125 }, 124 },
@@ -133,7 +132,6 @@ static const struct ctrl sd_ctrls[] = {
133 .step = 1, 132 .step = 1,
134 .default_value = 1, 133 .default_value = 1,
135 }, 134 },
136 .set_control = setautogain,
137 }, 135 },
138[HFLIP] = { 136[HFLIP] = {
139 { 137 {
@@ -497,7 +495,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
497 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */ 495 reg_w(gspca_dev, 0x78, 0x44); /* Bit_0=start stream, Bit_6=LED */
498} 496}
499 497
500#define WANT_REGULAR_AUTOGAIN 498#define WANT_COARSE_EXPO_AUTOGAIN
501#include "autogain_functions.h" 499#include "autogain_functions.h"
502 500
503static void do_autogain(struct gspca_dev *gspca_dev) 501static void do_autogain(struct gspca_dev *gspca_dev)
@@ -514,8 +512,8 @@ static void do_autogain(struct gspca_dev *gspca_dev)
514 512
515 if (sd->autogain_ignore_frames > 0) 513 if (sd->autogain_ignore_frames > 0)
516 sd->autogain_ignore_frames--; 514 sd->autogain_ignore_frames--;
517 else if (auto_gain_n_exposure(gspca_dev, avg_lum, desired_lum, 515 else if (coarse_grained_expo_autogain(gspca_dev, avg_lum, desired_lum,
518 deadzone, GAIN_KNEE, EXPOSURE_KNEE)) 516 deadzone))
519 sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES; 517 sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES;
520} 518}
521 519
@@ -619,22 +617,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
619 gspca_frame_add(gspca_dev, INTER_PACKET, data, len); 617 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
620} 618}
621 619
622static void setautogain(struct gspca_dev *gspca_dev)
623{
624 struct sd *sd = (struct sd *) gspca_dev;
625
626 if (sd->ctrls[AUTOGAIN].val) {
627 sd->ctrls[EXPOSURE].val = 2;
628 sd->ctrls[GAIN].val = 122;
629 if (gspca_dev->streaming) {
630 sd->autogain_ignore_frames =
631 PAC_AUTOGAIN_IGNORE_FRAMES;
632 setexposure(gspca_dev);
633 setgain(gspca_dev);
634 }
635 }
636}
637
638#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE) 620#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
639static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 621static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
640 u8 *data, /* interrupt packet data */ 622 u8 *data, /* interrupt packet data */