diff options
author | Márton Németh <nm127@freemail.hu> | 2009-11-07 13:15:56 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-05 15:41:38 -0500 |
commit | 265a8098e75e156985abfaac250ee4f2b407f863 (patch) | |
tree | 0eb60f1488c2948bd3d830225537bc7e6b9d5921 /drivers/media/video/gspca | |
parent | d5aa3856fd09ad0ea04619d6cba31192dac08e84 (diff) |
V4L/DVB (13385): gspca - pac7302: Add red and blue balance control.
The valid values for these controls are 0..3 (lower two bits) which was
identified by trial and error on Labtec Webcam 2200 (USB ID 093a:2626).
The upper 6 bits are ignored on page 0, registers 0xc5 and 0xc7 by the camera.
Signed-off-by: Márton Németh <nm127@freemail.hu>
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca')
-rw-r--r-- | drivers/media/video/gspca/pac7302.c | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/drivers/media/video/gspca/pac7302.c b/drivers/media/video/gspca/pac7302.c index ec2930871d1f..e7a4ced86e9b 100644 --- a/drivers/media/video/gspca/pac7302.c +++ b/drivers/media/video/gspca/pac7302.c | |||
@@ -49,6 +49,20 @@ | |||
49 | -/0x27 Seems to toggle various gains on / off, Setting bit 7 seems to | 49 | -/0x27 Seems to toggle various gains on / off, Setting bit 7 seems to |
50 | completely disable the analog amplification block. Set to 0x68 | 50 | completely disable the analog amplification block. Set to 0x68 |
51 | for max gain, 0x14 for minimal gain. | 51 | for max gain, 0x14 for minimal gain. |
52 | |||
53 | The registers are accessed in the following functions: | ||
54 | |||
55 | Page | Register | Function | ||
56 | -----+------------+--------------------------------------------------- | ||
57 | 0 | 0x0f..0x20 | setcolors() | ||
58 | 0 | 0xa2..0xab | setbrightcont() | ||
59 | 0 | 0xc5 | setredbalance() | ||
60 | 0 | 0xc7 | setbluebalance() | ||
61 | 0 | 0xdc | setbrightcont(), setcolors() | ||
62 | 3 | 0x02 | setexposure() | ||
63 | 3 | 0x10 | setgain() | ||
64 | 3 | 0x11 | setcolors(), setgain(), setexposure(), sethvflip() | ||
65 | 3 | 0x21 | sethvflip() | ||
52 | */ | 66 | */ |
53 | 67 | ||
54 | #define MODULE_NAME "pac7302" | 68 | #define MODULE_NAME "pac7302" |
@@ -66,6 +80,8 @@ struct sd { | |||
66 | unsigned char brightness; | 80 | unsigned char brightness; |
67 | unsigned char contrast; | 81 | unsigned char contrast; |
68 | unsigned char colors; | 82 | unsigned char colors; |
83 | unsigned char red_balance; | ||
84 | unsigned char blue_balance; | ||
69 | unsigned char gain; | 85 | unsigned char gain; |
70 | unsigned char exposure; | 86 | unsigned char exposure; |
71 | unsigned char autogain; | 87 | unsigned char autogain; |
@@ -85,6 +101,10 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); | |||
85 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); | 101 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); |
86 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); | 102 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); |
87 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); | 103 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); |
104 | static int sd_setredbalance(struct gspca_dev *gspca_dev, __s32 val); | ||
105 | static int sd_getredbalance(struct gspca_dev *gspca_dev, __s32 *val); | ||
106 | static int sd_setbluebalance(struct gspca_dev *gspca_dev, __s32 val); | ||
107 | static int sd_getbluebalance(struct gspca_dev *gspca_dev, __s32 *val); | ||
88 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); | 108 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); |
89 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); | 109 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); |
90 | static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val); | 110 | static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val); |
@@ -145,6 +165,34 @@ static struct ctrl sd_ctrls[] = { | |||
145 | .set = sd_setcolors, | 165 | .set = sd_setcolors, |
146 | .get = sd_getcolors, | 166 | .get = sd_getcolors, |
147 | }, | 167 | }, |
168 | { | ||
169 | { | ||
170 | .id = V4L2_CID_RED_BALANCE, | ||
171 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
172 | .name = "Red", | ||
173 | .minimum = 0, | ||
174 | .maximum = 3, | ||
175 | .step = 1, | ||
176 | #define REDBALANCE_DEF 1 | ||
177 | .default_value = REDBALANCE_DEF, | ||
178 | }, | ||
179 | .set = sd_setredbalance, | ||
180 | .get = sd_getredbalance, | ||
181 | }, | ||
182 | { | ||
183 | { | ||
184 | .id = V4L2_CID_BLUE_BALANCE, | ||
185 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
186 | .name = "Blue", | ||
187 | .minimum = 0, | ||
188 | .maximum = 3, | ||
189 | .step = 1, | ||
190 | #define BLUEBALANCE_DEF 1 | ||
191 | .default_value = BLUEBALANCE_DEF, | ||
192 | }, | ||
193 | .set = sd_setbluebalance, | ||
194 | .get = sd_getbluebalance, | ||
195 | }, | ||
148 | /* All controls below are for both the 7302 and the 7311 */ | 196 | /* All controls below are for both the 7302 and the 7311 */ |
149 | { | 197 | { |
150 | { | 198 | { |
@@ -477,6 +525,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
477 | sd->brightness = BRIGHTNESS_DEF; | 525 | sd->brightness = BRIGHTNESS_DEF; |
478 | sd->contrast = CONTRAST_DEF; | 526 | sd->contrast = CONTRAST_DEF; |
479 | sd->colors = COLOR_DEF; | 527 | sd->colors = COLOR_DEF; |
528 | sd->red_balance = REDBALANCE_DEF; | ||
529 | sd->blue_balance = BLUEBALANCE_DEF; | ||
480 | sd->gain = GAIN_DEF; | 530 | sd->gain = GAIN_DEF; |
481 | sd->exposure = EXPOSURE_DEF; | 531 | sd->exposure = EXPOSURE_DEF; |
482 | sd->autogain = AUTOGAIN_DEF; | 532 | sd->autogain = AUTOGAIN_DEF; |
@@ -545,6 +595,36 @@ static int setcolors(struct gspca_dev *gspca_dev) | |||
545 | return ret; | 595 | return ret; |
546 | } | 596 | } |
547 | 597 | ||
598 | static int setredbalance(struct gspca_dev *gspca_dev) | ||
599 | { | ||
600 | struct sd *sd = (struct sd *) gspca_dev; | ||
601 | int ret; | ||
602 | |||
603 | ret = reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ | ||
604 | if (0 <= ret) | ||
605 | ret = reg_w(gspca_dev, 0xc5, sd->red_balance); | ||
606 | |||
607 | if (0 <= ret) | ||
608 | ret = reg_w(gspca_dev, 0xdc, 0x01); | ||
609 | PDEBUG(D_CONF|D_STREAM, "red_balance: %i", sd->red_balance); | ||
610 | return ret; | ||
611 | } | ||
612 | |||
613 | static int setbluebalance(struct gspca_dev *gspca_dev) | ||
614 | { | ||
615 | struct sd *sd = (struct sd *) gspca_dev; | ||
616 | int ret; | ||
617 | |||
618 | ret = reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ | ||
619 | if (0 <= ret) | ||
620 | ret = reg_w(gspca_dev, 0xc7, sd->blue_balance); | ||
621 | |||
622 | if (0 <= ret) | ||
623 | ret = reg_w(gspca_dev, 0xdc, 0x01); | ||
624 | PDEBUG(D_CONF|D_STREAM, "blue_balance: %i", sd->blue_balance); | ||
625 | return ret; | ||
626 | } | ||
627 | |||
548 | static int setgain(struct gspca_dev *gspca_dev) | 628 | static int setgain(struct gspca_dev *gspca_dev) |
549 | { | 629 | { |
550 | struct sd *sd = (struct sd *) gspca_dev; | 630 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -626,6 +706,10 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
626 | if (0 <= ret) | 706 | if (0 <= ret) |
627 | ret = setcolors(gspca_dev); | 707 | ret = setcolors(gspca_dev); |
628 | if (0 <= ret) | 708 | if (0 <= ret) |
709 | ret = setredbalance(gspca_dev); | ||
710 | if (0 <= ret) | ||
711 | ret = setbluebalance(gspca_dev); | ||
712 | if (0 <= ret) | ||
629 | setgain(gspca_dev); | 713 | setgain(gspca_dev); |
630 | if (0 <= ret) | 714 | if (0 <= ret) |
631 | setexposure(gspca_dev); | 715 | setexposure(gspca_dev); |
@@ -857,6 +941,48 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) | |||
857 | return 0; | 941 | return 0; |
858 | } | 942 | } |
859 | 943 | ||
944 | static int sd_setredbalance(struct gspca_dev *gspca_dev, __s32 val) | ||
945 | { | ||
946 | struct sd *sd = (struct sd *) gspca_dev; | ||
947 | int ret = 0; | ||
948 | |||
949 | sd->red_balance = val; | ||
950 | if (gspca_dev->streaming) | ||
951 | ret = setredbalance(gspca_dev); | ||
952 | if (0 <= ret) | ||
953 | ret = 0; | ||
954 | return ret; | ||
955 | } | ||
956 | |||
957 | static int sd_getredbalance(struct gspca_dev *gspca_dev, __s32 *val) | ||
958 | { | ||
959 | struct sd *sd = (struct sd *) gspca_dev; | ||
960 | |||
961 | *val = sd->red_balance; | ||
962 | return 0; | ||
963 | } | ||
964 | |||
965 | static int sd_setbluebalance(struct gspca_dev *gspca_dev, __s32 val) | ||
966 | { | ||
967 | struct sd *sd = (struct sd *) gspca_dev; | ||
968 | int ret = 0; | ||
969 | |||
970 | sd->blue_balance = val; | ||
971 | if (gspca_dev->streaming) | ||
972 | ret = setbluebalance(gspca_dev); | ||
973 | if (0 <= ret) | ||
974 | ret = 0; | ||
975 | return ret; | ||
976 | } | ||
977 | |||
978 | static int sd_getbluebalance(struct gspca_dev *gspca_dev, __s32 *val) | ||
979 | { | ||
980 | struct sd *sd = (struct sd *) gspca_dev; | ||
981 | |||
982 | *val = sd->blue_balance; | ||
983 | return 0; | ||
984 | } | ||
985 | |||
860 | static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val) | 986 | static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val) |
861 | { | 987 | { |
862 | struct sd *sd = (struct sd *) gspca_dev; | 988 | struct sd *sd = (struct sd *) gspca_dev; |