提交 535ec214 编写于 作者: L Laurent Pinchart 提交者: Mauro Carvalho Chehab

[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: NLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: NMauro Carvalho Chehab <m.chehab@samsung.com>
上级 8bf54c43
...@@ -647,6 +647,28 @@ static int mt9p031_set_crop(struct v4l2_subdev *subdev, ...@@ -647,6 +647,28 @@ static int mt9p031_set_crop(struct v4l2_subdev *subdev,
#define V4L2_CID_BLC_ANALOG_OFFSET (V4L2_CID_USER_BASE | 0x1004) #define V4L2_CID_BLC_ANALOG_OFFSET (V4L2_CID_USER_BASE | 0x1004)
#define V4L2_CID_BLC_DIGITAL_OFFSET (V4L2_CID_USER_BASE | 0x1005) #define V4L2_CID_BLC_DIGITAL_OFFSET (V4L2_CID_USER_BASE | 0x1005)
static int mt9p031_restore_blc(struct mt9p031 *mt9p031)
{
struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev);
int ret;
if (mt9p031->blc_auto->cur.val != 0) {
ret = mt9p031_set_mode2(mt9p031, 0,
MT9P031_READ_MODE_2_ROW_BLC);
if (ret < 0)
return ret;
}
if (mt9p031->blc_offset->cur.val != 0) {
ret = mt9p031_write(client, MT9P031_ROW_BLACK_TARGET,
mt9p031->blc_offset->cur.val);
if (ret < 0)
return ret;
}
return 0;
}
static int mt9p031_s_ctrl(struct v4l2_ctrl *ctrl) static int mt9p031_s_ctrl(struct v4l2_ctrl *ctrl)
{ {
struct mt9p031 *mt9p031 = struct mt9p031 *mt9p031 =
...@@ -722,16 +744,10 @@ static int mt9p031_s_ctrl(struct v4l2_ctrl *ctrl) ...@@ -722,16 +744,10 @@ static int mt9p031_s_ctrl(struct v4l2_ctrl *ctrl)
if (!ctrl->val) { if (!ctrl->val) {
/* Restore the BLC settings. */ /* Restore the BLC settings. */
if (mt9p031->blc_auto->cur.val != 0) { ret = mt9p031_restore_blc(mt9p031);
ret = mt9p031_s_ctrl(mt9p031->blc_auto);
if (ret < 0) if (ret < 0)
return ret; return ret;
}
if (mt9p031->blc_offset->cur.val != 0) {
ret = mt9p031_s_ctrl(mt9p031->blc_offset);
if (ret < 0)
return ret;
}
return mt9p031_write(client, MT9P031_TEST_PATTERN, return mt9p031_write(client, MT9P031_TEST_PATTERN,
MT9P031_TEST_PATTERN_DISABLE); MT9P031_TEST_PATTERN_DISABLE);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册