From af6c53b9060c2b4a4bda8215ea3cba0d94b5610f Mon Sep 17 00:00:00 2001 From: Wenjia Zhou Date: Fri, 14 Jul 2017 19:35:59 -0700 Subject: [PATCH] WAR:media:i2c:ov5693: add flip and mirror setting mode table enable mirror, WAR by unmirror it. Bug 200292212 Change-Id: I17ab87946c17d45813f9b76cf5ebb2918d00da03 Signed-off-by: Wenjia Zhou Reviewed-on: https://git-master.nvidia.com/r/1520873 Reviewed-by: Michelle Bourland GVS: Gerrit_Virtual_Submit Reviewed-by: Sean Pieper Reviewed-by: Jihoon Bang --- drivers/media/i2c/ov5693.c | 20 ++++++++++++++++++-- include/media/camera_common.h | 2 ++ include/media/ov5693.h | 4 ++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c index 605586d12abd..aa9e7feb35c9 100644 --- a/drivers/media/i2c/ov5693.c +++ b/drivers/media/i2c/ov5693.c @@ -499,6 +499,7 @@ static int ov5693_s_stream(struct v4l2_subdev *sd, int enable) struct v4l2_control control; int err; u32 frame_time; + u8 val; dev_dbg(&client->dev, "%s++\n", __func__); @@ -570,7 +571,20 @@ static int ov5693_s_stream(struct v4l2_subdev *sd, int enable) err = ov5693_write_table(priv, mode_table[OV5693_MODE_START_STREAM]); if (err) goto exit; - + if (priv->pdata->v_flip) { + ov5693_read_reg(priv->s_data, OV5693_TIMING_REG20, &val); + ov5693_write_reg(priv->s_data, OV5693_TIMING_REG20, + val | VERTICAL_FLIP); + } + if (priv->pdata->h_mirror) { + ov5693_read_reg(priv->s_data, OV5693_TIMING_REG21, &val); + ov5693_write_reg(priv->s_data, OV5693_TIMING_REG21, + val | HORIZONTAL_MIRROR_MASK); + } else { + ov5693_read_reg(priv->s_data, OV5693_TIMING_REG21, &val); + ov5693_write_reg(priv->s_data, OV5693_TIMING_REG21, + val & (~HORIZONTAL_MIRROR_MASK)); + } if (test_mode) err = ov5693_write_table(priv, mode_table[OV5693_MODE_TEST_PATTERN]); @@ -1331,7 +1345,9 @@ static struct camera_common_pdata *ov5693_parse_dt(struct i2c_client *client) board_priv_pdata->has_eeprom = of_property_read_bool(node, "has-eeprom"); - + board_priv_pdata->v_flip= of_property_read_bool(node, "vertical-flip"); + board_priv_pdata->h_mirror = of_property_read_bool(node, + "horizontal-mirror"); return board_priv_pdata; error: diff --git a/include/media/camera_common.h b/include/media/camera_common.h index 6b2e8753d9a8..5c5a17e345b0 100644 --- a/include/media/camera_common.h +++ b/include/media/camera_common.h @@ -125,6 +125,8 @@ struct camera_common_pdata { bool use_cam_gpio; bool has_eeprom; struct camera_common_mode_info *mode_info; + bool v_flip; + bool h_mirror; }; struct camera_common_eeprom_data { diff --git a/include/media/ov5693.h b/include/media/ov5693.h index e8f94859cef4..f16495603965 100644 --- a/include/media/ov5693.h +++ b/include/media/ov5693.h @@ -80,6 +80,10 @@ #define OV5693_GAIN_ADDR_MSB 0x350A #define OV5693_GAIN_ADDR_LSB 0x350B #define OV5693_GROUP_HOLD_ADDR 0x3208 +#define OV5693_TIMING_REG20 0x3820 +#define VERTICAL_FLIP ((0x1 << 1) | (0x1 << 6)) +#define OV5693_TIMING_REG21 0x3821 +#define HORIZONTAL_MIRROR_MASK (0x3 << 1) struct ov5693_mode { int res_x; -- 2.39.2