diff options
author | Erik Andr?n <erik.andren@gmail.com> | 2009-01-13 11:55:52 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-06-16 17:20:32 -0400 |
commit | b933d585baf6f6432ca5dd3f6d415ffa145e2c25 (patch) | |
tree | 0d69ac76c8ac28cef6ce1f6ef35b29c2cb892f9d | |
parent | dd9ce84a773f9c9919a3c59291e82ec0e8803ecc (diff) |
V4L/DVB (11523): gspca - m5602-po1030: Add private green balance control
Signed-off-by: Erik Andr?n <erik.andren@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_po1030.c | 54 | ||||
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_po1030.h | 1 | ||||
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_sensor.h | 2 |
3 files changed, 56 insertions, 1 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_po1030.c b/drivers/media/video/gspca/m5602/m5602_po1030.c index e32d03a2cf94..ee8e496090a2 100644 --- a/drivers/media/video/gspca/m5602/m5602_po1030.c +++ b/drivers/media/video/gspca/m5602/m5602_po1030.c | |||
@@ -26,6 +26,8 @@ static int po1030_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val); | |||
26 | static int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val); | 26 | static int po1030_set_red_balance(struct gspca_dev *gspca_dev, __s32 val); |
27 | static int po1030_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val); | 27 | static int po1030_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val); |
28 | static int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val); | 28 | static int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val); |
29 | static int po1030_get_green_balance(struct gspca_dev *gspca_dev, __s32 *val); | ||
30 | static int po1030_set_green_balance(struct gspca_dev *gspca_dev, __s32 val); | ||
29 | static int po1030_get_hflip(struct gspca_dev *gspca_dev, __s32 *val); | 31 | static int po1030_get_hflip(struct gspca_dev *gspca_dev, __s32 *val); |
30 | static int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val); | 32 | static int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val); |
31 | static int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val); | 33 | static int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val); |
@@ -169,7 +171,21 @@ const static struct ctrl po1030_ctrls[] = { | |||
169 | .set = po1030_set_auto_exposure, | 171 | .set = po1030_set_auto_exposure, |
170 | .get = po1030_get_auto_exposure | 172 | .get = po1030_get_auto_exposure |
171 | }, | 173 | }, |
172 | 174 | #define GREEN_BALANCE_IDX 8 | |
175 | { | ||
176 | { | ||
177 | .id = M5602_V4L2_CID_GREEN_BALANCE, | ||
178 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
179 | .name = "green balance", | ||
180 | .minimum = 0x00, | ||
181 | .maximum = 0xff, | ||
182 | .step = 0x1, | ||
183 | .default_value = PO1030_GREEN_GAIN_DEFAULT, | ||
184 | .flags = V4L2_CTRL_FLAG_SLIDER | ||
185 | }, | ||
186 | .set = po1030_set_green_balance, | ||
187 | .get = po1030_get_green_balance | ||
188 | }, | ||
173 | }; | 189 | }; |
174 | 190 | ||
175 | static void po1030_dump_registers(struct sd *sd); | 191 | static void po1030_dump_registers(struct sd *sd); |
@@ -288,6 +304,11 @@ int po1030_init(struct sd *sd) | |||
288 | if (err < 0) | 304 | if (err < 0) |
289 | return err; | 305 | return err; |
290 | 306 | ||
307 | err = po1030_set_green_balance(&sd->gspca_dev, | ||
308 | sensor_settings[GREEN_BALANCE_IDX]); | ||
309 | if (err < 0) | ||
310 | return err; | ||
311 | |||
291 | err = po1030_set_auto_white_balance(&sd->gspca_dev, | 312 | err = po1030_set_auto_white_balance(&sd->gspca_dev, |
292 | sensor_settings[AUTO_WHITE_BALANCE_IDX]); | 313 | sensor_settings[AUTO_WHITE_BALANCE_IDX]); |
293 | if (err < 0) | 314 | if (err < 0) |
@@ -499,6 +520,37 @@ static int po1030_set_blue_balance(struct gspca_dev *gspca_dev, __s32 val) | |||
499 | return err; | 520 | return err; |
500 | } | 521 | } |
501 | 522 | ||
523 | static int po1030_get_green_balance(struct gspca_dev *gspca_dev, __s32 *val) | ||
524 | { | ||
525 | struct sd *sd = (struct sd *) gspca_dev; | ||
526 | s32 *sensor_settings = sd->sensor_priv; | ||
527 | |||
528 | *val = sensor_settings[GREEN_BALANCE_IDX]; | ||
529 | PDEBUG(D_V4L2, "Read green gain %d", *val); | ||
530 | |||
531 | return 0; | ||
532 | } | ||
533 | |||
534 | static int po1030_set_green_balance(struct gspca_dev *gspca_dev, __s32 val) | ||
535 | { | ||
536 | struct sd *sd = (struct sd *) gspca_dev; | ||
537 | s32 *sensor_settings = sd->sensor_priv; | ||
538 | u8 i2c_data; | ||
539 | int err; | ||
540 | |||
541 | sensor_settings[GREEN_BALANCE_IDX] = val; | ||
542 | i2c_data = val & 0xff; | ||
543 | PDEBUG(D_V4L2, "Set green gain to %d", i2c_data); | ||
544 | |||
545 | err = m5602_write_sensor(sd, PO1030_GREEN_1_GAIN, | ||
546 | &i2c_data, 1); | ||
547 | if (err < 0) | ||
548 | return err; | ||
549 | |||
550 | return m5602_write_sensor(sd, PO1030_GREEN_2_GAIN, | ||
551 | &i2c_data, 1); | ||
552 | } | ||
553 | |||
502 | static int po1030_get_auto_white_balance(struct gspca_dev *gspca_dev, | 554 | static int po1030_get_auto_white_balance(struct gspca_dev *gspca_dev, |
503 | __s32 *val) | 555 | __s32 *val) |
504 | { | 556 | { |
diff --git a/drivers/media/video/gspca/m5602/m5602_po1030.h b/drivers/media/video/gspca/m5602/m5602_po1030.h index 3ecacf0ed484..0b2dab038a6f 100644 --- a/drivers/media/video/gspca/m5602/m5602_po1030.h +++ b/drivers/media/video/gspca/m5602/m5602_po1030.h | |||
@@ -139,6 +139,7 @@ | |||
139 | #define PO1030_EXPOSURE_DEFAULT 0x0085 | 139 | #define PO1030_EXPOSURE_DEFAULT 0x0085 |
140 | #define PO1030_BLUE_GAIN_DEFAULT 0x36 | 140 | #define PO1030_BLUE_GAIN_DEFAULT 0x36 |
141 | #define PO1030_RED_GAIN_DEFAULT 0x36 | 141 | #define PO1030_RED_GAIN_DEFAULT 0x36 |
142 | #define PO1030_GREEN_GAIN_DEFAULT 0x40 | ||
142 | 143 | ||
143 | /*****************************************************************************/ | 144 | /*****************************************************************************/ |
144 | 145 | ||
diff --git a/drivers/media/video/gspca/m5602/m5602_sensor.h b/drivers/media/video/gspca/m5602/m5602_sensor.h index 987dcb23ec68..5b76b6b62152 100644 --- a/drivers/media/video/gspca/m5602/m5602_sensor.h +++ b/drivers/media/video/gspca/m5602/m5602_sensor.h | |||
@@ -21,6 +21,8 @@ | |||
21 | 21 | ||
22 | #include "m5602_bridge.h" | 22 | #include "m5602_bridge.h" |
23 | 23 | ||
24 | #define M5602_V4L2_CID_GREEN_BALANCE (V4L2_CID_PRIVATE_BASE + 0) | ||
25 | |||
24 | /* Enumerates all supported sensors */ | 26 | /* Enumerates all supported sensors */ |
25 | enum sensors { | 27 | enum sensors { |
26 | OV9650_SENSOR = 1, | 28 | OV9650_SENSOR = 1, |