From: Seongyong Park <euphoriccatface@gmail.com>
To: linux-media@vger.kernel.org
Cc: Matt Ranostay <matt.ranostay@konsulko.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Seongyong Park <euphoriccatface@gmail.com>
Subject: [PATCH 1/2] media: video-i2c: frame delay based on last frame's end time
Date: Sun, 16 May 2021 20:09:01 +0900 [thread overview]
Message-ID: <20210516110902.784-1-euphoriccatface@gmail.com> (raw)
Current implementation calculates frame delay based on the time of
start of the loop. This inevitably causes the loop delay to be
slightly longer than the actual measurement period, thus skipping a frame
every now and then.
However, MLX90640 should ideally be working without a frame skip.
Each measurement step updates half of the pixels in the frame
(every other pixel in default "chess mode", and every other row
in "interleave mode"), while additional coefficient data (25th & 26th row)
updates every step. The compensational coefficient data only corresponds
with the pixels updated in the same step.
In short, if a frame is skipped, then half of a frame loses correction
information and becomes garbage data.
Signed-off-by: Seongyong Park <euphoriccatface@gmail.com>
---
drivers/media/i2c/video-i2c.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c
index 0465832a4..2ccb08335 100644
--- a/drivers/media/i2c/video-i2c.c
+++ b/drivers/media/i2c/video-i2c.c
@@ -445,14 +445,16 @@ static int video_i2c_thread_vid_cap(void *priv)
struct video_i2c_data *data = priv;
unsigned int delay = mult_frac(HZ, data->frame_interval.numerator,
data->frame_interval.denominator);
+ unsigned long end_jiffies = jiffies;
set_freezable();
do {
- unsigned long start_jiffies = jiffies;
struct video_i2c_buffer *vid_cap_buf = NULL;
int schedule_delay;
+ end_jiffies += delay;
+
try_to_freeze();
spin_lock(&data->slock);
@@ -477,10 +479,9 @@ static int video_i2c_thread_vid_cap(void *priv)
VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
}
- schedule_delay = delay - (jiffies - start_jiffies);
-
- if (time_after(jiffies, start_jiffies + delay))
- schedule_delay = delay;
+ schedule_delay = end_jiffies - jiffies;
+ while (schedule_delay <= 0)
+ schedule_delay += delay;
schedule_timeout_interruptible(schedule_delay);
} while (!kthread_should_stop());
--
2.31.1
next prev reply other threads:[~2021-05-16 11:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-05 11:54 [PATCH V2 0/2] media: video-i2c: additional support for Melexis MLX90640 Seongyong Park
2021-05-16 11:09 ` Seongyong Park [this message]
2021-05-16 11:09 ` [PATCH 2/2] media: video-i2c: append register data on MLX90640's frame Seongyong Park
2021-05-16 20:48 ` Matt Ranostay
2021-05-17 1:39 ` Seongyong Park
2021-05-17 23:40 ` Matt Ranostay
2021-05-16 20:13 ` [PATCH 1/2] media: video-i2c: frame delay based on last frame's end time Matt Ranostay
2021-05-19 3:45 ` [PATCH V2 2/2] media: video-i2c: append register data on MLX90640's frame Seongyong Park
2021-06-05 11:54 ` Seongyong Park
2021-06-05 11:54 ` [PATCH 1/2] media: video-i2c: frame delay based on last frame's end time Seongyong Park
2021-06-05 14:00 ` Mauro Carvalho Chehab
2021-06-05 14:53 ` Mauro Carvalho Chehab
2021-06-06 7:20 ` Seongyong Park
2021-06-06 11:00 ` Mauro Carvalho Chehab
2021-06-06 15:06 ` Seongyong Park
2021-06-06 19:18 ` Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210516110902.784-1-euphoriccatface@gmail.com \
--to=euphoriccatface@gmail.com \
--cc=linux-media@vger.kernel.org \
--cc=matt.ranostay@konsulko.com \
--cc=mchehab@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.