diff options
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_s5k83a.c | 92 | ||||
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_s5k83a.h | 58 |
2 files changed, 140 insertions, 10 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.c b/drivers/media/video/gspca/m5602/m5602_s5k83a.c index c1ff967b1c3..b4b33c2d049 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k83a.c +++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.c | |||
@@ -321,7 +321,7 @@ int s5k83a_get_gain(struct gspca_dev *gspca_dev, __s32 *val) | |||
321 | 321 | ||
322 | int s5k83a_set_gain(struct gspca_dev *gspca_dev, __s32 val) | 322 | int s5k83a_set_gain(struct gspca_dev *gspca_dev, __s32 val) |
323 | { | 323 | { |
324 | int err = 0; | 324 | int err; |
325 | u8 data[2]; | 325 | u8 data[2]; |
326 | struct sd *sd = (struct sd *) gspca_dev; | 326 | struct sd *sd = (struct sd *) gspca_dev; |
327 | 327 | ||
@@ -331,3 +331,93 @@ int s5k83a_set_gain(struct gspca_dev *gspca_dev, __s32 val) | |||
331 | 331 | ||
332 | return (err < 0) ? err : 0; | 332 | return (err < 0) ? err : 0; |
333 | } | 333 | } |
334 | |||
335 | int s5k83a_get_vflip(struct gspca_dev *gspca_dev, __s32 *val) | ||
336 | { | ||
337 | int err; | ||
338 | u8 data[1]; | ||
339 | struct sd *sd = (struct sd *) gspca_dev; | ||
340 | |||
341 | data[0] = 0x05; | ||
342 | err = s5k83a_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); | ||
343 | if (err < 0) | ||
344 | return err; | ||
345 | |||
346 | err = s5k83a_read_sensor(sd, S5K83A_FLIP, data, 1); | ||
347 | *val = (data[0] | 0x40) ? 1 : 0; | ||
348 | |||
349 | return (err < 0) ? err : 0; | ||
350 | } | ||
351 | |||
352 | int s5k83a_set_vflip(struct gspca_dev *gspca_dev, __s32 val) | ||
353 | { | ||
354 | int err; | ||
355 | u8 data[1]; | ||
356 | struct sd *sd = (struct sd *) gspca_dev; | ||
357 | |||
358 | data[0] = 0x05; | ||
359 | err = s5k83a_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); | ||
360 | if (err < 0) | ||
361 | return err; | ||
362 | |||
363 | err = s5k83a_read_sensor(sd, S5K83A_FLIP, data, 1); | ||
364 | if (err < 0) | ||
365 | return err; | ||
366 | |||
367 | /* set or zero six bit, seven is hflip */ | ||
368 | data[0] = (val) ? (data[0] & 0x80) | 0x40 | S5K83A_FLIP_MASK | ||
369 | : (data[0] & 0x80) | S5K83A_FLIP_MASK; | ||
370 | err = s5k83a_write_sensor(sd, S5K83A_FLIP, data, 1); | ||
371 | if (err < 0) | ||
372 | return err; | ||
373 | |||
374 | data[0] = (val) ? 0x0b : 0x0a; | ||
375 | err = s5k83a_write_sensor(sd, S5K83A_VFLIP_TUNE, data, 1); | ||
376 | |||
377 | return (err < 0) ? err : 0; | ||
378 | } | ||
379 | |||
380 | int s5k83a_get_hflip(struct gspca_dev *gspca_dev, __s32 *val) | ||
381 | { | ||
382 | int err; | ||
383 | u8 data[1]; | ||
384 | struct sd *sd = (struct sd *) gspca_dev; | ||
385 | |||
386 | data[0] = 0x05; | ||
387 | err = s5k83a_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); | ||
388 | if (err < 0) | ||
389 | return err; | ||
390 | |||
391 | err = s5k83a_read_sensor(sd, S5K83A_FLIP, data, 1); | ||
392 | *val = (data[0] | 0x80) ? 1 : 0; | ||
393 | |||
394 | return (err < 0) ? err : 0; | ||
395 | } | ||
396 | |||
397 | int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val) | ||
398 | { | ||
399 | int err; | ||
400 | u8 data[1]; | ||
401 | struct sd *sd = (struct sd *) gspca_dev; | ||
402 | |||
403 | data[0] = 0x05; | ||
404 | err = s5k83a_write_sensor(sd, S5K83A_PAGE_MAP, data, 1); | ||
405 | if (err < 0) | ||
406 | return err; | ||
407 | |||
408 | err = s5k83a_read_sensor(sd, S5K83A_FLIP, data, 1); | ||
409 | if (err < 0) | ||
410 | return err; | ||
411 | |||
412 | /* set or zero seven bit, six is vflip */ | ||
413 | data[0] = (val) ? (data[0] & 0x40) | 0x80 | S5K83A_FLIP_MASK | ||
414 | : (data[0] & 0x40) | S5K83A_FLIP_MASK; | ||
415 | err = s5k83a_write_sensor(sd, S5K83A_FLIP, data, 1); | ||
416 | if (err < 0) | ||
417 | return err; | ||
418 | |||
419 | data[0] = (val) ? 0x0a : 0x0b; | ||
420 | err = s5k83a_write_sensor(sd, S5K83A_HFLIP_TUNE, data, 1); | ||
421 | |||
422 | return (err < 0) ? err : 0; | ||
423 | } | ||
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.h b/drivers/media/video/gspca/m5602/m5602_s5k83a.h index a57f623d80c..833708eb5a4 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k83a.h +++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.h | |||
@@ -21,15 +21,20 @@ | |||
21 | 21 | ||
22 | #include "m5602_sensor.h" | 22 | #include "m5602_sensor.h" |
23 | 23 | ||
24 | #define S5K83A_PAGE_MAP 0xec | 24 | #define S5K83A_FLIP 0x01 |
25 | #define S5K83A_GAIN 0x18 | 25 | #define S5K83A_HFLIP_TUNE 0x03 |
26 | #define S5K83A_VFLIP_TUNE 0x05 | ||
26 | #define S5K83A_WHITENESS 0x0a | 27 | #define S5K83A_WHITENESS 0x0a |
27 | #define S5K83A_BRIGHTNESS 0x1b | 28 | #define S5K83A_GAIN 0x18 |
29 | #define S5K83A_BRIGHTNESS 0x1b | ||
30 | #define S5K83A_PAGE_MAP 0xec | ||
28 | 31 | ||
29 | #define S5K83A_DEFAULT_BRIGHTNESS 0x71 | 32 | #define S5K83A_DEFAULT_BRIGHTNESS 0x71 |
30 | #define S5K83A_DEFAULT_WHITENESS 0x7e | 33 | #define S5K83A_DEFAULT_WHITENESS 0x7e |
31 | #define S5K83A_DEFAULT_GAIN 0x00 | 34 | #define S5K83A_DEFAULT_GAIN 0x00 |
32 | #define S5K83A_MAXIMUM_GAIN 0x3c | 35 | #define S5K83A_MAXIMUM_GAIN 0x3c |
36 | #define S5K83A_FLIP_MASK 0x10 | ||
37 | |||
33 | 38 | ||
34 | /*****************************************************************************/ | 39 | /*****************************************************************************/ |
35 | 40 | ||
@@ -56,6 +61,11 @@ int s5k83a_set_whiteness(struct gspca_dev *gspca_dev, __s32 val); | |||
56 | int s5k83a_get_whiteness(struct gspca_dev *gspca_dev, __s32 *val); | 61 | int s5k83a_get_whiteness(struct gspca_dev *gspca_dev, __s32 *val); |
57 | int s5k83a_set_gain(struct gspca_dev *gspca_dev, __s32 val); | 62 | int s5k83a_set_gain(struct gspca_dev *gspca_dev, __s32 val); |
58 | int s5k83a_get_gain(struct gspca_dev *gspca_dev, __s32 *val); | 63 | int s5k83a_get_gain(struct gspca_dev *gspca_dev, __s32 *val); |
64 | int s5k83a_get_vflip(struct gspca_dev *gspca_dev, __s32 *val); | ||
65 | int s5k83a_set_vflip(struct gspca_dev *gspca_dev, __s32 val); | ||
66 | int s5k83a_get_hflip(struct gspca_dev *gspca_dev, __s32 *val); | ||
67 | int s5k83a_set_hflip(struct gspca_dev *gspca_dev, __s32 val); | ||
68 | |||
59 | 69 | ||
60 | static struct m5602_sensor s5k83a = { | 70 | static struct m5602_sensor s5k83a = { |
61 | .name = "S5K83A", | 71 | .name = "S5K83A", |
@@ -65,7 +75,7 @@ static struct m5602_sensor s5k83a = { | |||
65 | .read_sensor = s5k83a_read_sensor, | 75 | .read_sensor = s5k83a_read_sensor, |
66 | .write_sensor = s5k83a_write_sensor, | 76 | .write_sensor = s5k83a_write_sensor, |
67 | .i2c_slave_id = 0x5a, | 77 | .i2c_slave_id = 0x5a, |
68 | .nctrls = 3, | 78 | .nctrls = 5, |
69 | .ctrls = { | 79 | .ctrls = { |
70 | { | 80 | { |
71 | { | 81 | { |
@@ -107,7 +117,31 @@ static struct m5602_sensor s5k83a = { | |||
107 | }, | 117 | }, |
108 | .set = s5k83a_set_gain, | 118 | .set = s5k83a_set_gain, |
109 | .get = s5k83a_get_gain | 119 | .get = s5k83a_get_gain |
110 | } | 120 | }, { |
121 | { | ||
122 | .id = V4L2_CID_HFLIP, | ||
123 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
124 | .name = "horizontal flip", | ||
125 | .minimum = 0, | ||
126 | .maximum = 1, | ||
127 | .step = 1, | ||
128 | .default_value = 0 | ||
129 | }, | ||
130 | .set = s5k83a_set_hflip, | ||
131 | .get = s5k83a_get_hflip | ||
132 | }, { | ||
133 | { | ||
134 | .id = V4L2_CID_VFLIP, | ||
135 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
136 | .name = "vertical flip", | ||
137 | .minimum = 0, | ||
138 | .maximum = 1, | ||
139 | .step = 1, | ||
140 | .default_value = 0 | ||
141 | }, | ||
142 | .set = s5k83a_set_vflip, | ||
143 | .get = s5k83a_get_vflip | ||
144 | } | ||
111 | }, | 145 | }, |
112 | .nmodes = 1, | 146 | .nmodes = 1, |
113 | .modes = { | 147 | .modes = { |
@@ -121,7 +155,6 @@ static struct m5602_sensor s5k83a = { | |||
121 | .bytesperline = M5602_DEFAULT_FRAME_WIDTH, | 155 | .bytesperline = M5602_DEFAULT_FRAME_WIDTH, |
122 | .colorspace = V4L2_COLORSPACE_SRGB, | 156 | .colorspace = V4L2_COLORSPACE_SRGB, |
123 | .priv = 1 | 157 | .priv = 1 |
124 | |||
125 | } | 158 | } |
126 | } | 159 | } |
127 | }; | 160 | }; |
@@ -438,7 +471,14 @@ static const unsigned char init_s5k83a[][4] = | |||
438 | {SENSOR, S5K83A_WHITENESS, S5K83A_DEFAULT_WHITENESS, 0x00}, | 471 | {SENSOR, S5K83A_WHITENESS, S5K83A_DEFAULT_WHITENESS, 0x00}, |
439 | 472 | ||
440 | /* set default gain */ | 473 | /* set default gain */ |
441 | {SENSOR_LONG, 0x18, 0x00, S5K83A_DEFAULT_GAIN} | 474 | {SENSOR_LONG, 0x18, 0x00, S5K83A_DEFAULT_GAIN}, |
475 | |||
476 | /* set default flip */ | ||
477 | {SENSOR, S5K83A_PAGE_MAP, 0x05, 0x00}, | ||
478 | {SENSOR, S5K83A_FLIP, 0x00 | S5K83A_FLIP_MASK, 0x00}, | ||
479 | {SENSOR, S5K83A_HFLIP_TUNE, 0x0b, 0x00}, | ||
480 | {SENSOR, S5K83A_VFLIP_TUNE, 0x0a, 0x00} | ||
481 | |||
442 | }; | 482 | }; |
443 | 483 | ||
444 | #endif | 484 | #endif |