diff options
author | Marton Nemeth <nm127@freemail.hu> | 2009-11-08 04:35:12 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-05 18:41:39 -0200 |
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 e7a4ced86e9..f8bf6a63f04 100644 --- a/drivers/media/video/gspca/pac7302.c +++ b/drivers/media/video/gspca/pac7302.c @@ -57,6 +57,7 @@ 0 | 0x0f..0x20 | setcolors() 0 | 0xa2..0xab | setbrightcont() 0 | 0xc5 | setredbalance() + 0 | 0xc6 | setwhitebalance() 0 | 0xc7 | setbluebalance() 0 | 0xdc | setbrightcont(), setcolors() 3 | 0x02 | setexposure() @@ -80,6 +81,7 @@ struct sd { unsigned char brightness; unsigned char contrast; unsigned char colors; + unsigned char white_balance; unsigned char red_balance; unsigned char blue_balance; unsigned char gain; @@ -101,6 +103,8 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val); static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val); static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); +static int sd_setwhitebalance(struct gspca_dev *gspca_dev, __s32 val); +static int sd_getwhitebalance(struct gspca_dev *gspca_dev, __s32 *val); static int sd_setredbalance(struct gspca_dev *gspca_dev, __s32 val); static int sd_getredbalance(struct gspca_dev *gspca_dev, __s32 *val); static int sd_setbluebalance(struct gspca_dev *gspca_dev, __s32 val); @@ -167,6 +171,20 @@ static struct ctrl sd_ctrls[] = { }, { { + .id = V4L2_CID_WHITE_BALANCE_TEMPERATURE, + .type = V4L2_CTRL_TYPE_INTEGER, + .name = "White Balance", + .minimum = 0, + .maximum = 255, + .step = 1, +#define WHITEBALANCE_DEF 4 + .default_value = WHITEBALANCE_DEF, + }, + .set = sd_setwhitebalance, + .get = sd_getwhitebalance, + }, + { + { .id = V4L2_CID_RED_BALANCE, .type = V4L2_CTRL_TYPE_INTEGER, .name = "Red", @@ -525,6 +543,7 @@ static int sd_config(struct gspca_dev *gspca_dev, sd->brightness = BRIGHTNESS_DEF; sd->contrast = CONTRAST_DEF; sd->colors = COLOR_DEF; + sd->white_balance = WHITEBALANCE_DEF; sd->red_balance = REDBALANCE_DEF; sd->blue_balance = BLUEBALANCE_DEF; sd->gain = GAIN_DEF; @@ -595,6 +614,21 @@ static int setcolors(struct gspca_dev *gspca_dev) return ret; } +static int setwhitebalance(struct gspca_dev *gspca_dev) +{ + struct sd *sd = (struct sd *) gspca_dev; + int ret; + + ret = reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ + if (0 <= ret) + ret = reg_w(gspca_dev, 0xc6, sd->white_balance); + + if (0 <= ret) + ret = reg_w(gspca_dev, 0xdc, 0x01); + PDEBUG(D_CONF|D_STREAM, "white_balance: %i", sd->white_balance); + return ret; +} + static int setredbalance(struct gspca_dev *gspca_dev) { struct sd *sd = (struct sd *) gspca_dev; @@ -706,6 +740,8 @@ static int sd_start(struct gspca_dev *gspca_dev) if (0 <= ret) ret = setcolors(gspca_dev); if (0 <= ret) + ret = setwhitebalance(gspca_dev); + if (0 <= ret) ret = setredbalance(gspca_dev); if (0 <= ret) ret = setbluebalance(gspca_dev); @@ -941,6 +977,27 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) return 0; } +static int sd_setwhitebalance(struct gspca_dev *gspca_dev, __s32 val) +{ + struct sd *sd = (struct sd *) gspca_dev; + int ret = 0; + + sd->white_balance = val; + if (gspca_dev->streaming) + ret = setwhitebalance(gspca_dev); + if (0 <= ret) + ret = 0; + return ret; +} + +static int sd_getwhitebalance(struct gspca_dev *gspca_dev, __s32 *val) +{ + struct sd *sd = (struct sd *) gspca_dev; + + *val = sd->white_balance; + return 0; +} + static int sd_setredbalance(struct gspca_dev *gspca_dev, __s32 val) { struct sd *sd = (struct sd *) gspca_dev; |