diff options
author | Grégory Lardière <spmf2004-m560x@yahoo.fr> | 2009-02-12 01:40:29 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-06-16 17:20:52 -0400 |
commit | 9bc738fb5392f0733529e26d9bb70c8b3d5637ff (patch) | |
tree | b77564cd9298774f2758427dc029b05e0ee24e4a /drivers | |
parent | 60d52cecedf7b55bed07d59ab6039ae066f01124 (diff) |
V4L/DVB (11689): gspca - m5602-s5k4aa: Fixup the vflip/hflip
Ensure that the hflip and vflip is consistent when the sensor needs to
be vflip quirked or not.
Signed-off-by: Grégory Lardière <spmf2004-m560x@yahoo.fr>
Signed-off-by: Erik Andrén <erik.andren@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_s5k4aa.c | 110 |
1 files changed, 41 insertions, 69 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c index b5a9ddb2d218..31a8ba00623f 100644 --- a/drivers/media/video/gspca/m5602/m5602_s5k4aa.c +++ b/drivers/media/video/gspca/m5602/m5602_s5k4aa.c | |||
@@ -266,6 +266,7 @@ int s5k4aa_start(struct sd *sd) | |||
266 | int i, err = 0; | 266 | int i, err = 0; |
267 | u8 data[2]; | 267 | u8 data[2]; |
268 | struct cam *cam = &sd->gspca_dev.cam; | 268 | struct cam *cam = &sd->gspca_dev.cam; |
269 | s32 *sensor_settings = sd->sensor_priv; | ||
269 | 270 | ||
270 | switch (cam->cam_mode[sd->gspca_dev.curr_mode].width) { | 271 | switch (cam->cam_mode[sd->gspca_dev.curr_mode].width) { |
271 | case 1280: | 272 | case 1280: |
@@ -340,13 +341,37 @@ int s5k4aa_start(struct sd *sd) | |||
340 | return err; | 341 | return err; |
341 | break; | 342 | break; |
342 | } | 343 | } |
343 | return err; | 344 | if (err < 0) |
345 | return err; | ||
346 | |||
347 | err = s5k4aa_set_exposure(&sd->gspca_dev, | ||
348 | sensor_settings[EXPOSURE_IDX]); | ||
349 | if (err < 0) | ||
350 | return err; | ||
351 | |||
352 | err = s5k4aa_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]); | ||
353 | if (err < 0) | ||
354 | return err; | ||
355 | |||
356 | err = s5k4aa_set_brightness(&sd->gspca_dev, | ||
357 | sensor_settings[BRIGHTNESS_IDX]); | ||
358 | if (err < 0) | ||
359 | return err; | ||
360 | |||
361 | err = s5k4aa_set_noise(&sd->gspca_dev, sensor_settings[NOISE_SUPP_IDX]); | ||
362 | if (err < 0) | ||
363 | return err; | ||
364 | |||
365 | err = s5k4aa_set_vflip(&sd->gspca_dev, sensor_settings[VFLIP_IDX]); | ||
366 | if (err < 0) | ||
367 | return err; | ||
368 | |||
369 | return s5k4aa_set_hflip(&sd->gspca_dev, sensor_settings[HFLIP_IDX]); | ||
344 | } | 370 | } |
345 | 371 | ||
346 | int s5k4aa_init(struct sd *sd) | 372 | int s5k4aa_init(struct sd *sd) |
347 | { | 373 | { |
348 | int i, err = 0; | 374 | int i, err = 0; |
349 | s32 *sensor_settings = sd->sensor_priv; | ||
350 | 375 | ||
351 | for (i = 0; i < ARRAY_SIZE(init_s5k4aa) && !err; i++) { | 376 | for (i = 0; i < ARRAY_SIZE(init_s5k4aa) && !err; i++) { |
352 | u8 data[2] = {0x00, 0x00}; | 377 | u8 data[2] = {0x00, 0x00}; |
@@ -379,25 +404,7 @@ int s5k4aa_init(struct sd *sd) | |||
379 | if (dump_sensor) | 404 | if (dump_sensor) |
380 | s5k4aa_dump_registers(sd); | 405 | s5k4aa_dump_registers(sd); |
381 | 406 | ||
382 | err = s5k4aa_set_exposure(&sd->gspca_dev, | 407 | return err; |
383 | sensor_settings[EXPOSURE_IDX]); | ||
384 | if (err < 0) | ||
385 | return err; | ||
386 | |||
387 | err = s5k4aa_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]); | ||
388 | if (err < 0) | ||
389 | return err; | ||
390 | |||
391 | err = s5k4aa_set_brightness(&sd->gspca_dev, | ||
392 | sensor_settings[BRIGHTNESS_IDX]); | ||
393 | if (err < 0) | ||
394 | return err; | ||
395 | |||
396 | err = s5k4aa_set_vflip(&sd->gspca_dev, sensor_settings[VFLIP_IDX]); | ||
397 | if (err < 0) | ||
398 | return err; | ||
399 | |||
400 | return s5k4aa_set_hflip(&sd->gspca_dev, sensor_settings[HFLIP_IDX]); | ||
401 | } | 408 | } |
402 | 409 | ||
403 | static int s5k4aa_get_exposure(struct gspca_dev *gspca_dev, __s32 *val) | 410 | static int s5k4aa_get_exposure(struct gspca_dev *gspca_dev, __s32 *val) |
@@ -465,36 +472,19 @@ static int s5k4aa_set_vflip(struct gspca_dev *gspca_dev, __s32 val) | |||
465 | if (err < 0) | 472 | if (err < 0) |
466 | return err; | 473 | return err; |
467 | 474 | ||
468 | if (dmi_check_system(s5k4aa_vflip_dmi_table)) { | 475 | if (dmi_check_system(s5k4aa_vflip_dmi_table)) |
469 | val = !val; | 476 | val = !val; |
470 | data = (data & 0x3f) | | ||
471 | (!sensor_settings[HFLIP_IDX] << 6) | | ||
472 | ((val & 0x01) << 7); | ||
473 | } else { | ||
474 | data = (data & 0x3f) | | ||
475 | (sensor_settings[HFLIP_IDX] << 6) | | ||
476 | ((val & 0x01) << 7); | ||
477 | } | ||
478 | 477 | ||
478 | data = ((data & ~S5K4AA_RM_V_FLIP) | ((val & 0x01) << 7)); | ||
479 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); | 479 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); |
480 | if (err < 0) | 480 | if (err < 0) |
481 | return err; | 481 | return err; |
482 | 482 | ||
483 | if (val) { | 483 | err = m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); |
484 | err = m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); | 484 | if (err < 0) |
485 | if (err < 0) | 485 | return err; |
486 | return err; | 486 | data = (data & 0xfe) | !val; |
487 | 487 | err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); | |
488 | data++; | ||
489 | err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); | ||
490 | } else { | ||
491 | err = m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); | ||
492 | if (err < 0) | ||
493 | return err; | ||
494 | |||
495 | data--; | ||
496 | err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1); | ||
497 | } | ||
498 | return err; | 488 | return err; |
499 | } | 489 | } |
500 | 490 | ||
@@ -530,37 +520,19 @@ static int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val) | |||
530 | if (err < 0) | 520 | if (err < 0) |
531 | return err; | 521 | return err; |
532 | 522 | ||
533 | if (dmi_check_system(s5k4aa_vflip_dmi_table)) { | 523 | if (dmi_check_system(s5k4aa_vflip_dmi_table)) |
534 | val = !val; | 524 | val = !val; |
535 | data = (data & 0x3f) | | ||
536 | (!sensor_settings[VFLIP_IDX] << 7) | | ||
537 | ((val & 0x01) << 6); | ||
538 | } else { | ||
539 | data = (data & 0x3f) | | ||
540 | (sensor_settings[VFLIP_IDX] << 7) | | ||
541 | ((val & 0x01) << 6); | ||
542 | } | ||
543 | 525 | ||
544 | data = ((data & ~S5K4AA_RM_H_FLIP) | ((val & 0x01) << 6)); | 526 | data = ((data & ~S5K4AA_RM_H_FLIP) | ((val & 0x01) << 6)); |
545 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); | 527 | err = m5602_write_sensor(sd, S5K4AA_READ_MODE, &data, 1); |
546 | if (err < 0) | 528 | if (err < 0) |
547 | return err; | 529 | return err; |
548 | 530 | ||
549 | if (val) { | 531 | err = m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); |
550 | err = m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); | 532 | if (err < 0) |
551 | if (err < 0) | 533 | return err; |
552 | return err; | 534 | data = (data & 0xfe) | !val; |
553 | data++; | 535 | err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); |
554 | err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); | ||
555 | if (err < 0) | ||
556 | return err; | ||
557 | } else { | ||
558 | err = m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); | ||
559 | if (err < 0) | ||
560 | return err; | ||
561 | data--; | ||
562 | err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1); | ||
563 | } | ||
564 | return err; | 536 | return err; |
565 | } | 537 | } |
566 | 538 | ||