aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/mt9p031.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2014-05-08 09:03:37 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-05-23 13:54:04 -0400
commit535ec214e23adaf72c775938e9e9c6c1cf6fc5b9 (patch)
treef7e12186791b49a774326bf3bd77a3a86a7cd943 /drivers/media/i2c/mt9p031.c
parent8bf54c4321dd6c57d4117f425890e5c6d49c103a (diff)
[media] mt9p031: Fix BLC configuration restore when disabling test pattern
Auto BLC and BLC digital offset are disabled when enabling the test pattern and must be restored when disabling it. The driver does so by calling the set control handler on the auto BLC and BLC offset controls, but this programs the hardware with the new value of those controls, not the current value. Fix this by writing to the registers directly. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/i2c/mt9p031.c')
-rw-r--r--drivers/media/i2c/mt9p031.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 9102b2346f7c..e18797ff7faf 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -647,6 +647,28 @@ static int mt9p031_set_crop(struct v4l2_subdev *subdev,
647#define V4L2_CID_BLC_ANALOG_OFFSET (V4L2_CID_USER_BASE | 0x1004) 647#define V4L2_CID_BLC_ANALOG_OFFSET (V4L2_CID_USER_BASE | 0x1004)
648#define V4L2_CID_BLC_DIGITAL_OFFSET (V4L2_CID_USER_BASE | 0x1005) 648#define V4L2_CID_BLC_DIGITAL_OFFSET (V4L2_CID_USER_BASE | 0x1005)
649 649
650static int mt9p031_restore_blc(struct mt9p031 *mt9p031)
651{
652 struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev);
653 int ret;
654
655 if (mt9p031->blc_auto->cur.val != 0) {
656 ret = mt9p031_set_mode2(mt9p031, 0,
657 MT9P031_READ_MODE_2_ROW_BLC);
658 if (ret < 0)
659 return ret;
660 }
661
662 if (mt9p031->blc_offset->cur.val != 0) {
663 ret = mt9p031_write(client, MT9P031_ROW_BLACK_TARGET,
664 mt9p031->blc_offset->cur.val);
665 if (ret < 0)
666 return ret;
667 }
668
669 return 0;
670}
671
650static int mt9p031_s_ctrl(struct v4l2_ctrl *ctrl) 672static int mt9p031_s_ctrl(struct v4l2_ctrl *ctrl)
651{ 673{
652 struct mt9p031 *mt9p031 = 674 struct mt9p031 *mt9p031 =
@@ -722,16 +744,10 @@ static int mt9p031_s_ctrl(struct v4l2_ctrl *ctrl)
722 744
723 if (!ctrl->val) { 745 if (!ctrl->val) {
724 /* Restore the BLC settings. */ 746 /* Restore the BLC settings. */
725 if (mt9p031->blc_auto->cur.val != 0) { 747 ret = mt9p031_restore_blc(mt9p031);
726 ret = mt9p031_s_ctrl(mt9p031->blc_auto); 748 if (ret < 0)
727 if (ret < 0) 749 return ret;
728 return ret; 750
729 }
730 if (mt9p031->blc_offset->cur.val != 0) {
731 ret = mt9p031_s_ctrl(mt9p031->blc_offset);
732 if (ret < 0)
733 return ret;
734 }
735 return mt9p031_write(client, MT9P031_TEST_PATTERN, 751 return mt9p031_write(client, MT9P031_TEST_PATTERN,
736 MT9P031_TEST_PATTERN_DISABLE); 752 MT9P031_TEST_PATTERN_DISABLE);
737 } 753 }