diff options
author | Max Thrun <bear24rw@gmail.com> | 2010-02-27 15:20:20 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-17 23:46:54 -0400 |
commit | 8b7fbda484176b46a7760fd474d605ca5152c86d (patch) | |
tree | 8a5cdb950bfd79ea261b20a087af00b5afc33689 | |
parent | 0c41acf158b61577dd8e50ba00f3cadabdc3c756 (diff) |
V4L/DVB: gspca - ov534: Fix autogain control, enable it by default
* Use 'agc' instead of 'autogain' in the code so to align the naming
as in AEC/AWB.
* Tweak brightness and contrast default values.
* Fix setting/resetting registers values for AGC.
* Set actual gain back when disabling AGC.
* Skip setting GAIN register when AGC is enabled.
* Enable AGC by default.
Note that as Auto Gain Control is now enabled by default, if you are
using the driver for visual computing applications you might need to
disable it explicitly in your software.
Signed-off-by: Max Thrun <bear24rw@gmail.com>
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Jean-François Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/gspca/ov534.c | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/drivers/media/video/gspca/ov534.c b/drivers/media/video/gspca/ov534.c index 186827a0d276..4058e224d6a4 100644 --- a/drivers/media/video/gspca/ov534.c +++ b/drivers/media/video/gspca/ov534.c | |||
@@ -60,7 +60,7 @@ struct sd { | |||
60 | u8 contrast; | 60 | u8 contrast; |
61 | u8 gain; | 61 | u8 gain; |
62 | u8 exposure; | 62 | u8 exposure; |
63 | u8 autogain; | 63 | u8 agc; |
64 | u8 awb; | 64 | u8 awb; |
65 | s8 sharpness; | 65 | s8 sharpness; |
66 | u8 hflip; | 66 | u8 hflip; |
@@ -73,8 +73,8 @@ static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val); | |||
73 | static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val); | 73 | static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val); |
74 | static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val); | 74 | static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val); |
75 | static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val); | 75 | static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val); |
76 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); | 76 | static int sd_setagc(struct gspca_dev *gspca_dev, __s32 val); |
77 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); | 77 | static int sd_getagc(struct gspca_dev *gspca_dev, __s32 *val); |
78 | static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val); | 78 | static int sd_setsharpness(struct gspca_dev *gspca_dev, __s32 val); |
79 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); | 79 | static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val); |
80 | static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val); | 80 | static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val); |
@@ -97,7 +97,7 @@ static const struct ctrl sd_ctrls[] = { | |||
97 | .minimum = 0, | 97 | .minimum = 0, |
98 | .maximum = 255, | 98 | .maximum = 255, |
99 | .step = 1, | 99 | .step = 1, |
100 | #define BRIGHTNESS_DEF 20 | 100 | #define BRIGHTNESS_DEF 0 |
101 | .default_value = BRIGHTNESS_DEF, | 101 | .default_value = BRIGHTNESS_DEF, |
102 | }, | 102 | }, |
103 | .set = sd_setbrightness, | 103 | .set = sd_setbrightness, |
@@ -111,7 +111,7 @@ static const struct ctrl sd_ctrls[] = { | |||
111 | .minimum = 0, | 111 | .minimum = 0, |
112 | .maximum = 255, | 112 | .maximum = 255, |
113 | .step = 1, | 113 | .step = 1, |
114 | #define CONTRAST_DEF 37 | 114 | #define CONTRAST_DEF 32 |
115 | .default_value = CONTRAST_DEF, | 115 | .default_value = CONTRAST_DEF, |
116 | }, | 116 | }, |
117 | .set = sd_setcontrast, | 117 | .set = sd_setcontrast, |
@@ -149,15 +149,15 @@ static const struct ctrl sd_ctrls[] = { | |||
149 | { | 149 | { |
150 | .id = V4L2_CID_AUTOGAIN, | 150 | .id = V4L2_CID_AUTOGAIN, |
151 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 151 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
152 | .name = "Autogain", | 152 | .name = "Auto Gain", |
153 | .minimum = 0, | 153 | .minimum = 0, |
154 | .maximum = 1, | 154 | .maximum = 1, |
155 | .step = 1, | 155 | .step = 1, |
156 | #define AUTOGAIN_DEF 0 | 156 | #define AGC_DEF 1 |
157 | .default_value = AUTOGAIN_DEF, | 157 | .default_value = AGC_DEF, |
158 | }, | 158 | }, |
159 | .set = sd_setautogain, | 159 | .set = sd_setagc, |
160 | .get = sd_getautogain, | 160 | .get = sd_getagc, |
161 | }, | 161 | }, |
162 | #define AWB_IDX 5 | 162 | #define AWB_IDX 5 |
163 | { /* 5 */ | 163 | { /* 5 */ |
@@ -639,6 +639,9 @@ static void setgain(struct gspca_dev *gspca_dev) | |||
639 | struct sd *sd = (struct sd *) gspca_dev; | 639 | struct sd *sd = (struct sd *) gspca_dev; |
640 | u8 val; | 640 | u8 val; |
641 | 641 | ||
642 | if (sd->agc) | ||
643 | return; | ||
644 | |||
642 | val = sd->gain; | 645 | val = sd->gain; |
643 | switch (val & 0x30) { | 646 | switch (val & 0x30) { |
644 | case 0x00: | 647 | case 0x00: |
@@ -671,18 +674,22 @@ static void setexposure(struct gspca_dev *gspca_dev) | |||
671 | sccb_reg_write(gspca_dev, 0x10, val << 1); | 674 | sccb_reg_write(gspca_dev, 0x10, val << 1); |
672 | } | 675 | } |
673 | 676 | ||
674 | static void setautogain(struct gspca_dev *gspca_dev) | 677 | static void setagc(struct gspca_dev *gspca_dev) |
675 | { | 678 | { |
676 | struct sd *sd = (struct sd *) gspca_dev; | 679 | struct sd *sd = (struct sd *) gspca_dev; |
677 | 680 | ||
678 | if (sd->autogain) { | 681 | if (sd->agc) { |
679 | sccb_reg_write(gspca_dev, 0x13, 0xf7); /* AGC,AEC,AWB ON */ | 682 | sccb_reg_write(gspca_dev, 0x13, |
683 | sccb_reg_read(gspca_dev, 0x13) | 0x04); | ||
680 | sccb_reg_write(gspca_dev, 0x64, | 684 | sccb_reg_write(gspca_dev, 0x64, |
681 | sccb_reg_read(gspca_dev, 0x64) | 0x03); | 685 | sccb_reg_read(gspca_dev, 0x64) | 0x03); |
682 | } else { | 686 | } else { |
683 | sccb_reg_write(gspca_dev, 0x13, 0xf0); /* AGC,AEC,AWB OFF */ | 687 | sccb_reg_write(gspca_dev, 0x13, |
688 | sccb_reg_read(gspca_dev, 0x13) & ~0x04); | ||
684 | sccb_reg_write(gspca_dev, 0x64, | 689 | sccb_reg_write(gspca_dev, 0x64, |
685 | sccb_reg_read(gspca_dev, 0x64) & 0xfc); | 690 | sccb_reg_read(gspca_dev, 0x64) & ~0x03); |
691 | |||
692 | setgain(gspca_dev); | ||
686 | } | 693 | } |
687 | } | 694 | } |
688 | 695 | ||
@@ -753,8 +760,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
753 | sd->contrast = CONTRAST_DEF; | 760 | sd->contrast = CONTRAST_DEF; |
754 | sd->gain = GAIN_DEF; | 761 | sd->gain = GAIN_DEF; |
755 | sd->exposure = EXPO_DEF; | 762 | sd->exposure = EXPO_DEF; |
756 | #if AUTOGAIN_DEF != 0 | 763 | #if AGC_DEF != 0 |
757 | sd->autogain = AUTOGAIN_DEF; | 764 | sd->agc = AGC_DEF; |
758 | #else | 765 | #else |
759 | gspca_dev->ctrl_inac |= (1 << AWB_IDX); | 766 | gspca_dev->ctrl_inac |= (1 << AWB_IDX); |
760 | #endif | 767 | #endif |
@@ -829,7 +836,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
829 | } | 836 | } |
830 | set_frame_rate(gspca_dev); | 837 | set_frame_rate(gspca_dev); |
831 | 838 | ||
832 | setautogain(gspca_dev); | 839 | setagc(gspca_dev); |
833 | setawb(gspca_dev); | 840 | setawb(gspca_dev); |
834 | setgain(gspca_dev); | 841 | setgain(gspca_dev); |
835 | setexposure(gspca_dev); | 842 | setexposure(gspca_dev); |
@@ -1014,11 +1021,11 @@ static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val) | |||
1014 | return 0; | 1021 | return 0; |
1015 | } | 1022 | } |
1016 | 1023 | ||
1017 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) | 1024 | static int sd_setagc(struct gspca_dev *gspca_dev, __s32 val) |
1018 | { | 1025 | { |
1019 | struct sd *sd = (struct sd *) gspca_dev; | 1026 | struct sd *sd = (struct sd *) gspca_dev; |
1020 | 1027 | ||
1021 | sd->autogain = val; | 1028 | sd->agc = val; |
1022 | 1029 | ||
1023 | if (gspca_dev->streaming) { | 1030 | if (gspca_dev->streaming) { |
1024 | 1031 | ||
@@ -1028,16 +1035,16 @@ static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) | |||
1028 | gspca_dev->ctrl_inac &= ~(1 << AWB_IDX); | 1035 | gspca_dev->ctrl_inac &= ~(1 << AWB_IDX); |
1029 | else | 1036 | else |
1030 | gspca_dev->ctrl_inac |= (1 << AWB_IDX); | 1037 | gspca_dev->ctrl_inac |= (1 << AWB_IDX); |
1031 | setautogain(gspca_dev); | 1038 | setagc(gspca_dev); |
1032 | } | 1039 | } |
1033 | return 0; | 1040 | return 0; |
1034 | } | 1041 | } |
1035 | 1042 | ||
1036 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val) | 1043 | static int sd_getagc(struct gspca_dev *gspca_dev, __s32 *val) |
1037 | { | 1044 | { |
1038 | struct sd *sd = (struct sd *) gspca_dev; | 1045 | struct sd *sd = (struct sd *) gspca_dev; |
1039 | 1046 | ||
1040 | *val = sd->autogain; | 1047 | *val = sd->agc; |
1041 | return 0; | 1048 | return 0; |
1042 | } | 1049 | } |
1043 | 1050 | ||