diff options
author | Marton Nemeth <nm127@freemail.hu> | 2009-11-08 02:35:12 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-05 15:41:39 -0500 |
commit | 23fbee6f88d59b4edca0855242d55e5b7cfc2401 (patch) | |
tree | b9015f3c9b44429727a774ef3d023fd65d07493c /drivers/media/video/gspca | |
parent | b760812ed78c93249ac7957fedb87ba9c3ca3906 (diff) |
V4L/DVB (13388): gspca - pac7302: Add white balance control.
Signed-off-by: Marton Nemeth <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 | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/drivers/media/video/gspca/pac7302.c b/drivers/media/video/gspca/pac7302.c index e7a4ced86e9b..f8bf6a63f042 100644 --- a/drivers/media/video/gspca/pac7302.c +++ b/drivers/media/video/gspca/pac7302.c | |||
@@ -57,6 +57,7 @@ | |||
57 | 0 | 0x0f..0x20 | setcolors() | 57 | 0 | 0x0f..0x20 | setcolors() |
58 | 0 | 0xa2..0xab | setbrightcont() | 58 | 0 | 0xa2..0xab | setbrightcont() |
59 | 0 | 0xc5 | setredbalance() | 59 | 0 | 0xc5 | setredbalance() |
60 | 0 | 0xc6 | setwhitebalance() | ||
60 | 0 | 0xc7 | setbluebalance() | 61 | 0 | 0xc7 | setbluebalance() |
61 | 0 | 0xdc | setbrightcont(), setcolors() | 62 | 0 | 0xdc | setbrightcont(), setcolors() |
62 | 3 | 0x02 | setexposure() | 63 | 3 | 0x02 | setexposure() |
@@ -80,6 +81,7 @@ struct sd { | |||
80 | unsigned char brightness; | 81 | unsigned char brightness; |
81 | unsigned char contrast; | 82 | unsigned char contrast; |
82 | unsigned char colors; | 83 | unsigned char colors; |
84 | unsigned char white_balance; | ||
83 | unsigned char red_balance; | 85 | unsigned char red_balance; |
84 | unsigned char blue_balance; | 86 | unsigned char blue_balance; |
85 | unsigned char gain; | 87 | unsigned char gain; |
@@ -101,6 +103,8 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); | |||
101 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); | 103 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); |
102 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); | 104 | static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); |
103 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); | 105 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); |
106 | static int sd_setwhitebalance(struct gspca_dev *gspca_dev, __s32 val); | ||
107 | static int sd_getwhitebalance(struct gspca_dev *gspca_dev, __s32 *val); | ||
104 | static int sd_setredbalance(struct gspca_dev *gspca_dev, __s32 val); | 108 | static int sd_setredbalance(struct gspca_dev *gspca_dev, __s32 val); |
105 | static int sd_getredbalance(struct gspca_dev *gspca_dev, __s32 *val); | 109 | static int sd_getredbalance(struct gspca_dev *gspca_dev, __s32 *val); |
106 | static int sd_setbluebalance(struct gspca_dev *gspca_dev, __s32 val); | 110 | static int sd_setbluebalance(struct gspca_dev *gspca_dev, __s32 val); |
@@ -167,6 +171,20 @@ static struct ctrl sd_ctrls[] = { | |||
167 | }, | 171 | }, |
168 | { | 172 | { |
169 | { | 173 | { |
174 | .id = V4L2_CID_WHITE_BALANCE_TEMPERATURE, | ||
175 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
176 | .name = "White Balance", | ||
177 | .minimum = 0, | ||
178 | .maximum = 255, | ||
179 | .step = 1, | ||
180 | #define WHITEBALANCE_DEF 4 | ||
181 | .default_value = WHITEBALANCE_DEF, | ||
182 | }, | ||
183 | .set = sd_setwhitebalance, | ||
184 | .get = sd_getwhitebalance, | ||
185 | }, | ||
186 | { | ||
187 | { | ||
170 | .id = V4L2_CID_RED_BALANCE, | 188 | .id = V4L2_CID_RED_BALANCE, |
171 | .type = V4L2_CTRL_TYPE_INTEGER, | 189 | .type = V4L2_CTRL_TYPE_INTEGER, |
172 | .name = "Red", | 190 | .name = "Red", |
@@ -525,6 +543,7 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
525 | sd->brightness = BRIGHTNESS_DEF; | 543 | sd->brightness = BRIGHTNESS_DEF; |
526 | sd->contrast = CONTRAST_DEF; | 544 | sd->contrast = CONTRAST_DEF; |
527 | sd->colors = COLOR_DEF; | 545 | sd->colors = COLOR_DEF; |
546 | sd->white_balance = WHITEBALANCE_DEF; | ||
528 | sd->red_balance = REDBALANCE_DEF; | 547 | sd->red_balance = REDBALANCE_DEF; |
529 | sd->blue_balance = BLUEBALANCE_DEF; | 548 | sd->blue_balance = BLUEBALANCE_DEF; |
530 | sd->gain = GAIN_DEF; | 549 | sd->gain = GAIN_DEF; |
@@ -595,6 +614,21 @@ static int setcolors(struct gspca_dev *gspca_dev) | |||
595 | return ret; | 614 | return ret; |
596 | } | 615 | } |
597 | 616 | ||
617 | static int setwhitebalance(struct gspca_dev *gspca_dev) | ||
618 | { | ||
619 | struct sd *sd = (struct sd *) gspca_dev; | ||
620 | int ret; | ||
621 | |||
622 | ret = reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ | ||
623 | if (0 <= ret) | ||
624 | ret = reg_w(gspca_dev, 0xc6, sd->white_balance); | ||
625 | |||
626 | if (0 <= ret) | ||
627 | ret = reg_w(gspca_dev, 0xdc, 0x01); | ||
628 | PDEBUG(D_CONF|D_STREAM, "white_balance: %i", sd->white_balance); | ||
629 | return ret; | ||
630 | } | ||
631 | |||
598 | static int setredbalance(struct gspca_dev *gspca_dev) | 632 | static int setredbalance(struct gspca_dev *gspca_dev) |
599 | { | 633 | { |
600 | struct sd *sd = (struct sd *) gspca_dev; | 634 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -706,6 +740,8 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
706 | if (0 <= ret) | 740 | if (0 <= ret) |
707 | ret = setcolors(gspca_dev); | 741 | ret = setcolors(gspca_dev); |
708 | if (0 <= ret) | 742 | if (0 <= ret) |
743 | ret = setwhitebalance(gspca_dev); | ||
744 | if (0 <= ret) | ||
709 | ret = setredbalance(gspca_dev); | 745 | ret = setredbalance(gspca_dev); |
710 | if (0 <= ret) | 746 | if (0 <= ret) |
711 | ret = setbluebalance(gspca_dev); | 747 | ret = setbluebalance(gspca_dev); |
@@ -941,6 +977,27 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) | |||
941 | return 0; | 977 | return 0; |
942 | } | 978 | } |
943 | 979 | ||
980 | static int sd_setwhitebalance(struct gspca_dev *gspca_dev, __s32 val) | ||
981 | { | ||
982 | struct sd *sd = (struct sd *) gspca_dev; | ||
983 | int ret = 0; | ||
984 | |||
985 | sd->white_balance = val; | ||
986 | if (gspca_dev->streaming) | ||
987 | ret = setwhitebalance(gspca_dev); | ||
988 | if (0 <= ret) | ||
989 | ret = 0; | ||
990 | return ret; | ||
991 | } | ||
992 | |||
993 | static int sd_getwhitebalance(struct gspca_dev *gspca_dev, __s32 *val) | ||
994 | { | ||
995 | struct sd *sd = (struct sd *) gspca_dev; | ||
996 | |||
997 | *val = sd->white_balance; | ||
998 | return 0; | ||
999 | } | ||
1000 | |||
944 | static int sd_setredbalance(struct gspca_dev *gspca_dev, __s32 val) | 1001 | static int sd_setredbalance(struct gspca_dev *gspca_dev, __s32 val) |
945 | { | 1002 | { |
946 | struct sd *sd = (struct sd *) gspca_dev; | 1003 | struct sd *sd = (struct sd *) gspca_dev; |