diff options
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/gspca/tv8532.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/drivers/media/video/gspca/tv8532.c b/drivers/media/video/gspca/tv8532.c index 2316838ebc14..420dde9ef6fa 100644 --- a/drivers/media/video/gspca/tv8532.c +++ b/drivers/media/video/gspca/tv8532.c | |||
@@ -31,6 +31,7 @@ struct sd { | |||
31 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 31 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
32 | 32 | ||
33 | __u16 brightness; | 33 | __u16 brightness; |
34 | __u16 gain; | ||
34 | 35 | ||
35 | __u8 packet; | 36 | __u8 packet; |
36 | }; | 37 | }; |
@@ -38,6 +39,8 @@ struct sd { | |||
38 | /* V4L2 controls supported by the driver */ | 39 | /* V4L2 controls supported by the driver */ |
39 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); | 40 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val); |
40 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); | 41 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val); |
42 | static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val); | ||
43 | static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val); | ||
41 | 44 | ||
42 | static const struct ctrl sd_ctrls[] = { | 45 | static const struct ctrl sd_ctrls[] = { |
43 | { | 46 | { |
@@ -54,6 +57,20 @@ static const struct ctrl sd_ctrls[] = { | |||
54 | .set = sd_setbrightness, | 57 | .set = sd_setbrightness, |
55 | .get = sd_getbrightness, | 58 | .get = sd_getbrightness, |
56 | }, | 59 | }, |
60 | { | ||
61 | { | ||
62 | .id = V4L2_CID_GAIN, | ||
63 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
64 | .name = "Gain", | ||
65 | .minimum = 0, | ||
66 | .maximum = 0x7ff, | ||
67 | .step = 1, | ||
68 | #define GAIN_DEF 0x100 | ||
69 | .default_value = GAIN_DEF, | ||
70 | }, | ||
71 | .set = sd_setgain, | ||
72 | .get = sd_getgain, | ||
73 | }, | ||
57 | }; | 74 | }; |
58 | 75 | ||
59 | static const struct v4l2_pix_format sif_mode[] = { | 76 | static const struct v4l2_pix_format sif_mode[] = { |
@@ -92,6 +109,14 @@ static const struct v4l2_pix_format sif_mode[] = { | |||
92 | #define R14_AD_ROW_BEGINL 0x14 | 109 | #define R14_AD_ROW_BEGINL 0x14 |
93 | #define R15_AD_ROWBEGINH 0x15 | 110 | #define R15_AD_ROWBEGINH 0x15 |
94 | #define R1C_AD_EXPOSE_TIMEL 0x1c | 111 | #define R1C_AD_EXPOSE_TIMEL 0x1c |
112 | #define R20_GAIN_G1L 0x20 | ||
113 | #define R21_GAIN_G1H 0x21 | ||
114 | #define R22_GAIN_RL 0x22 | ||
115 | #define R23_GAIN_RH 0x23 | ||
116 | #define R24_GAIN_BL 0x24 | ||
117 | #define R25_GAIN_BH 0x25 | ||
118 | #define R26_GAIN_G2L 0x26 | ||
119 | #define R27_GAIN_G2H 0x27 | ||
95 | #define R28_QUANT 0x28 | 120 | #define R28_QUANT 0x28 |
96 | #define R29_LINE 0x29 | 121 | #define R29_LINE 0x29 |
97 | #define R2C_POLARITY 0x2c | 122 | #define R2C_POLARITY 0x2c |
@@ -185,6 +210,7 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
185 | cam->nmodes = ARRAY_SIZE(sif_mode); | 210 | cam->nmodes = ARRAY_SIZE(sif_mode); |
186 | 211 | ||
187 | sd->brightness = BRIGHTNESS_DEF; | 212 | sd->brightness = BRIGHTNESS_DEF; |
213 | sd->gain = GAIN_DEF; | ||
188 | return 0; | 214 | return 0; |
189 | } | 215 | } |
190 | 216 | ||
@@ -224,6 +250,16 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
224 | /* 0x84 */ | 250 | /* 0x84 */ |
225 | } | 251 | } |
226 | 252 | ||
253 | static void setgain(struct gspca_dev *gspca_dev) | ||
254 | { | ||
255 | struct sd *sd = (struct sd *) gspca_dev; | ||
256 | |||
257 | reg_w2(gspca_dev, R20_GAIN_G1L, sd->gain); | ||
258 | reg_w2(gspca_dev, R22_GAIN_RL, sd->gain); | ||
259 | reg_w2(gspca_dev, R24_GAIN_BL, sd->gain); | ||
260 | reg_w2(gspca_dev, R26_GAIN_G2L, sd->gain); | ||
261 | } | ||
262 | |||
227 | /* -- start the camera -- */ | 263 | /* -- start the camera -- */ |
228 | static int sd_start(struct gspca_dev *gspca_dev) | 264 | static int sd_start(struct gspca_dev *gspca_dev) |
229 | { | 265 | { |
@@ -254,6 +290,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
254 | tv_8532_setReg(gspca_dev); | 290 | tv_8532_setReg(gspca_dev); |
255 | 291 | ||
256 | setbrightness(gspca_dev); | 292 | setbrightness(gspca_dev); |
293 | setgain(gspca_dev); | ||
257 | 294 | ||
258 | /************************************************/ | 295 | /************************************************/ |
259 | reg_w1(gspca_dev, R31_UPD, 0x01); /* update registers */ | 296 | reg_w1(gspca_dev, R31_UPD, 0x01); /* update registers */ |
@@ -320,6 +357,24 @@ static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) | |||
320 | return 0; | 357 | return 0; |
321 | } | 358 | } |
322 | 359 | ||
360 | static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val) | ||
361 | { | ||
362 | struct sd *sd = (struct sd *) gspca_dev; | ||
363 | |||
364 | sd->gain = val; | ||
365 | if (gspca_dev->streaming) | ||
366 | setgain(gspca_dev); | ||
367 | return 0; | ||
368 | } | ||
369 | |||
370 | static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val) | ||
371 | { | ||
372 | struct sd *sd = (struct sd *) gspca_dev; | ||
373 | |||
374 | *val = sd->gain; | ||
375 | return 0; | ||
376 | } | ||
377 | |||
323 | /* sub-driver description */ | 378 | /* sub-driver description */ |
324 | static const struct sd_desc sd_desc = { | 379 | static const struct sd_desc sd_desc = { |
325 | .name = MODULE_NAME, | 380 | .name = MODULE_NAME, |