diff options
author | Erik Andr?n <erik.andren@gmail.com> | 2009-01-14 01:37:03 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-06-16 17:20:33 -0400 |
commit | 7ee4629092aa2982a3fbb9cfb3691637b55b4a40 (patch) | |
tree | e000f06302edc667b0d9555c2617ed9f42b30671 | |
parent | 3290d40206ce122058a1f1f56dfce3d2000107b3 (diff) |
V4L/DVB (11530): gspca - m5602-s5k4aa: Add brightness v4l2 ctrl
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_s5k4aa.c | 54 | ||||
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_s5k4aa.h | 8 |
2 files changed, 56 insertions, 6 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c index 4ecba9b2a5a4..404439fa4bb8 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c +++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c | |||
@@ -28,6 +28,8 @@ static int s5k4aa_get_gain(struct gspca_dev *gspca_dev, __s32 *val); | |||
28 | static int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val); | 28 | static int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val); |
29 | static int s5k4aa_get_noise(struct gspca_dev *gspca_dev, __s32 *val); | 29 | static int s5k4aa_get_noise(struct gspca_dev *gspca_dev, __s32 *val); |
30 | static int s5k4aa_set_noise(struct gspca_dev *gspca_dev, __s32 val); | 30 | static int s5k4aa_set_noise(struct gspca_dev *gspca_dev, __s32 val); |
31 | static int s5k4aa_get_brightness(struct gspca_dev *gspca_dev, __s32 *val); | ||
32 | static int s5k4aa_set_brightness(struct gspca_dev *gspca_dev, __s32 val); | ||
31 | 33 | ||
32 | static | 34 | static |
33 | const | 35 | const |
@@ -113,7 +115,7 @@ const static struct ctrl s5k4aa_ctrls[] = { | |||
113 | .minimum = 0, | 115 | .minimum = 0, |
114 | .maximum = 127, | 116 | .maximum = 127, |
115 | .step = 1, | 117 | .step = 1, |
116 | .default_value = DEFAULT_GAIN_2, | 118 | .default_value = S5K4AA_DEFAULT_GAIN, |
117 | .flags = V4L2_CTRL_FLAG_SLIDER | 119 | .flags = V4L2_CTRL_FLAG_SLIDER |
118 | }, | 120 | }, |
119 | .set = s5k4aa_set_gain, | 121 | .set = s5k4aa_set_gain, |
@@ -148,6 +150,21 @@ const static struct ctrl s5k4aa_ctrls[] = { | |||
148 | .set = s5k4aa_set_noise, | 150 | .set = s5k4aa_set_noise, |
149 | .get = s5k4aa_get_noise | 151 | .get = s5k4aa_get_noise |
150 | }, | 152 | }, |
153 | #define BRIGHTNESS_IDX 5 | ||
154 | { | ||
155 | { | ||
156 | .id = V4L2_CID_BRIGHTNESS, | ||
157 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
158 | .name = "Brightness", | ||
159 | .minimum = 0, | ||
160 | .maximum = 0x1f, | ||
161 | .step = 1, | ||
162 | .default_value = S5K4AA_DEFAULT_BRIGHTNESS, | ||
163 | }, | ||
164 | .set = s5k4aa_set_brightness, | ||
165 | .get = s5k4aa_get_brightness | ||
166 | }, | ||
167 | |||
151 | }; | 168 | }; |
152 | 169 | ||
153 | static void s5k4aa_dump_registers(struct sd *sd); | 170 | static void s5k4aa_dump_registers(struct sd *sd); |
@@ -320,6 +337,11 @@ int s5k4aa_init(struct sd *sd) | |||
320 | if (err < 0) | 337 | if (err < 0) |
321 | return err; | 338 | return err; |
322 | 339 | ||
340 | err = s5k4aa_set_brightness(&sd->gspca_dev, | ||
341 | sensor_settings[BRIGHTNESS_IDX]); | ||
342 | if (err < 0) | ||
343 | return err; | ||
344 | |||
323 | err = s5k4aa_set_noise(&sd->gspca_dev, sensor_settings[NOISE_SUPP_IDX]); | 345 | err = s5k4aa_set_noise(&sd->gspca_dev, sensor_settings[NOISE_SUPP_IDX]); |
324 | if (err < 0) | 346 | if (err < 0) |
325 | return err; | 347 | return err; |
@@ -508,11 +530,39 @@ static int s5k4aa_set_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
508 | return err; | 530 | return err; |
509 | 531 | ||
510 | data = val & 0xff; | 532 | data = val & 0xff; |
511 | err = m5602_write_sensor(sd, S5K4AA_GAIN_2, &data, 1); | 533 | err = m5602_write_sensor(sd, S5K4AA_GAIN, &data, 1); |
512 | 534 | ||
513 | return err; | 535 | return err; |
514 | } | 536 | } |
515 | 537 | ||
538 | static int s5k4aa_get_brightness(struct gspca_dev *gspca_dev, __s32 *val) | ||
539 | { | ||
540 | struct sd *sd = (struct sd *) gspca_dev; | ||
541 | s32 *sensor_settings = sd->sensor_priv; | ||
542 | |||
543 | *val = sensor_settings[BRIGHTNESS_IDX]; | ||
544 | PDEBUG(D_V4L2, "Read brightness %d", *val); | ||
545 | return 0; | ||
546 | } | ||
547 | |||
548 | static int s5k4aa_set_brightness(struct gspca_dev *gspca_dev, __s32 val) | ||
549 | { | ||
550 | struct sd *sd = (struct sd *) gspca_dev; | ||
551 | s32 *sensor_settings = sd->sensor_priv; | ||
552 | u8 data = S5K4AA_PAGE_MAP_2; | ||
553 | int err; | ||
554 | |||
555 | sensor_settings[BRIGHTNESS_IDX] = val; | ||
556 | |||
557 | PDEBUG(D_V4L2, "Set brightness to %d", val); | ||
558 | err = m5602_write_sensor(sd, S5K4AA_PAGE_MAP, &data, 1); | ||
559 | if (err < 0) | ||
560 | return err; | ||
561 | |||
562 | data = val & 0xff; | ||
563 | return m5602_write_sensor(sd, S5K4AA_BRIGHTNESS, &data, 1); | ||
564 | } | ||
565 | |||
516 | static int s5k4aa_get_noise(struct gspca_dev *gspca_dev, __s32 *val) | 566 | static int s5k4aa_get_noise(struct gspca_dev *gspca_dev, __s32 *val) |
517 | { | 567 | { |
518 | struct sd *sd = (struct sd *) gspca_dev; | 568 | struct sd *sd = (struct sd *) gspca_dev; |
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h index 8299f216c20d..2349174ad666 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.h +++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.h | |||
@@ -47,8 +47,8 @@ | |||
47 | #define S5K4AA_H_BLANK_LO__ 0x1e | 47 | #define S5K4AA_H_BLANK_LO__ 0x1e |
48 | #define S5K4AA_EXPOSURE_HI 0x17 | 48 | #define S5K4AA_EXPOSURE_HI 0x17 |
49 | #define S5K4AA_EXPOSURE_LO 0x18 | 49 | #define S5K4AA_EXPOSURE_LO 0x18 |
50 | #define S5K4AA_GAIN_1 0x1f /* (digital?) gain : 5 bits */ | 50 | #define S5K4AA_BRIGHTNESS 0x1f /* (digital?) gain : 5 bits */ |
51 | #define S5K4AA_GAIN_2 0x20 /* (analogue?) gain : 7 bits */ | 51 | #define S5K4AA_GAIN 0x20 /* (analogue?) gain : 7 bits */ |
52 | #define S5K4AA_NOISE_SUPP 0x37 | 52 | #define S5K4AA_NOISE_SUPP 0x37 |
53 | 53 | ||
54 | #define S5K4AA_RM_ROW_SKIP_4X 0x08 | 54 | #define S5K4AA_RM_ROW_SKIP_4X 0x08 |
@@ -58,7 +58,8 @@ | |||
58 | #define S5K4AA_RM_H_FLIP 0x40 | 58 | #define S5K4AA_RM_H_FLIP 0x40 |
59 | #define S5K4AA_RM_V_FLIP 0x80 | 59 | #define S5K4AA_RM_V_FLIP 0x80 |
60 | 60 | ||
61 | #define DEFAULT_GAIN_2 0x5f | 61 | #define S5K4AA_DEFAULT_GAIN 0x5f |
62 | #define S5K4AA_DEFAULT_BRIGHTNESS 0x10 | ||
62 | 63 | ||
63 | /*****************************************************************************/ | 64 | /*****************************************************************************/ |
64 | 65 | ||
@@ -303,7 +304,6 @@ static const unsigned char VGA_s5k4aa[][4] = | |||
303 | {SENSOR, 0x12, 0xc3, 0x00}, | 304 | {SENSOR, 0x12, 0xc3, 0x00}, |
304 | {SENSOR, S5K4AA_PAGE_MAP, 0x02, 0x00}, | 305 | {SENSOR, S5K4AA_PAGE_MAP, 0x02, 0x00}, |
305 | {SENSOR, 0x02, 0x0e, 0x00}, | 306 | {SENSOR, 0x02, 0x0e, 0x00}, |
306 | {SENSOR, S5K4AA_GAIN_1, 0x10, 0x00}, | ||
307 | }; | 307 | }; |
308 | 308 | ||
309 | #endif | 309 | #endif |