summaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/ov9281.c
diff options
context:
space:
mode:
authorAndrew Chew <achew@nvidia.com>2017-09-28 18:06:56 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-10-10 23:14:26 -0400
commitc7e4f7fc2638ee3e1cfbc28d91cd3eaf9f876e18 (patch)
tree316dad35c2376a0165303228d2caf21d74a73219 /drivers/media/i2c/ov9281.c
parent2474dff8f9e4d5db03149800b796d7e0b12505a4 (diff)
media: i2c: ov9281: Use frame period for sleep
This only applies to an ov9281 configured as an fsync slave. We need to sleep at least as long as the frame sampling period after making the fsync slave start streaming (we are assuming that the fsync master is already started and is generating the fsin signal). Previously, we were hardcoding the time to sleep based on a frame rate of 120fps. Instead, calculate the frame sampling period based on our frame length setting. Bug 1982522 Change-Id: I7d5c99c59e3eaf6a5016a3de02fc89e5b769b0aa Signed-off-by: Andrew Chew <achew@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1570497 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com> Reviewed-by: Xia Yang <xiay@nvidia.com> Reviewed-by: Raymond Poudrier <rapoudrier@nvidia.com> GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'drivers/media/i2c/ov9281.c')
-rw-r--r--drivers/media/i2c/ov9281.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/media/i2c/ov9281.c b/drivers/media/i2c/ov9281.c
index 6c17983cb..2e505cb8a 100644
--- a/drivers/media/i2c/ov9281.c
+++ b/drivers/media/i2c/ov9281.c
@@ -90,6 +90,7 @@
90#define OV9281_DEFAULT_FRAME_LENGTH 0x071C 90#define OV9281_DEFAULT_FRAME_LENGTH 0x071C
91#define OV9281_MIN_FRAME_LENGTH 0x0001 91#define OV9281_MIN_FRAME_LENGTH 0x0001
92#define OV9281_MAX_FRAME_LENGTH 0xFFFF 92#define OV9281_MAX_FRAME_LENGTH 0xFFFF
93#define OV9281_FRAME_LENGTH_1SEC (0x40d * 120) /* TODO: try to calc */
93 94
94#define OV9281_MIN_EXPOSURE_COARSE 0x00000001 95#define OV9281_MIN_EXPOSURE_COARSE 0x00000001
95#define OV9281_MAX_EXPOSURE_COARSE 0x000FFFFF 96#define OV9281_MAX_EXPOSURE_COARSE 0x000FFFFF
@@ -124,6 +125,7 @@ struct ov9281 {
124 125
125 s32 group_hold_prev; 126 s32 group_hold_prev;
126 bool group_hold_en; 127 bool group_hold_en;
128 int frame_period_ms;
127 struct regmap *regmap; 129 struct regmap *regmap;
128 struct camera_common_data *s_data; 130 struct camera_common_data *s_data;
129 struct camera_common_pdata *pdata; 131 struct camera_common_pdata *pdata;
@@ -467,6 +469,11 @@ static int ov9281_set_frame_length(struct ov9281 *priv, s32 val)
467 if (err) 469 if (err)
468 goto fail; 470 goto fail;
469 471
472 priv->frame_period_ms = (frame_length * 1000) /
473 OV9281_FRAME_LENGTH_1SEC;
474 dev_dbg(&priv->i2c_client->dev,
475 "%s: frame_period_ms: %d\n", __func__, priv->frame_period_ms);
476
470 return 0; 477 return 0;
471 478
472fail: 479fail:
@@ -702,11 +709,11 @@ static int ov9281_s_stream(struct v4l2_subdev *sd, int enable)
702 * camera host. So, after starting streaming, we assume fsync 709 * camera host. So, after starting streaming, we assume fsync
703 * master has already been told to start streaming, and we wait some 710 * master has already been told to start streaming, and we wait some
704 * amount of time in order to skip the possible short frame. The 711 * amount of time in order to skip the possible short frame. The
705 * length of time to wait should be at least our sample period. 712 * length of time to wait should be at least our frame period.
706 * Assume worse case of 120fps (8.3ms), and add a bit more. 713 * Add a little bit extra as a safety margin.
707 */ 714 */
708 if (priv->fsync == OV9281_FSYNC_SLAVE) 715 if (priv->fsync == OV9281_FSYNC_SLAVE)
709 msleep_range(10); 716 msleep_range(priv->frame_period_ms + 10);
710 717
711 return 0; 718 return 0;
712 719