mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heng-Ruey Hsu <henryhsu@chromium.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	jcliang@chromium.org, tfiga@chromium.org,
	Heng-Ruey Hsu <henryhsu@chromium.org>
Subject: [PATCH] media: uvcvideo: Add boottime clock support
Date: Wed, 17 Oct 2018 15:52:42 +0800	[thread overview]
Message-ID: <20181017075242.21790-1-henryhsu@chromium.org> (raw)

Android requires camera timestamps to be reported with
CLOCK_BOOTTIME to sync timestamp with other sensor sources.

Signed-off-by: Heng-Ruey Hsu <henryhsu@chromium.org>
---
 drivers/media/usb/uvc/uvc_driver.c | 4 ++++
 drivers/media/usb/uvc/uvc_video.c  | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index d46dc432456c..a9658f38c586 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -2287,6 +2287,8 @@ static int uvc_clock_param_get(char *buffer, const struct kernel_param *kp)
 {
 	if (uvc_clock_param == CLOCK_MONOTONIC)
 		return sprintf(buffer, "CLOCK_MONOTONIC");
+	else if (uvc_clock_param == CLOCK_BOOTTIME)
+		return sprintf(buffer, "CLOCK_BOOTTIME");
 	else
 		return sprintf(buffer, "CLOCK_REALTIME");
 }
@@ -2298,6 +2300,8 @@ static int uvc_clock_param_set(const char *val, const struct kernel_param *kp)
 
 	if (strcasecmp(val, "monotonic") == 0)
 		uvc_clock_param = CLOCK_MONOTONIC;
+	else if (strcasecmp(val, "boottime") == 0)
+		uvc_clock_param = CLOCK_BOOTTIME;
 	else if (strcasecmp(val, "realtime") == 0)
 		uvc_clock_param = CLOCK_REALTIME;
 	else
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 86a99f461fd8..d4248d5cd9cd 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -425,6 +425,8 @@ static inline ktime_t uvc_video_get_time(void)
 {
 	if (uvc_clock_param == CLOCK_MONOTONIC)
 		return ktime_get();
+	else if (uvc_clock_param == CLOCK_BOOTTIME)
+		return ktime_get_boottime();
 	else
 		return ktime_get_real();
 }
-- 
2.19.1.331.ge82ca0e54c-goog


             reply	other threads:[~2018-10-17  7:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-17  7:52 Heng-Ruey Hsu [this message]
2018-10-17  8:02 ` Laurent Pinchart
2018-10-17  8:28   ` Tomasz Figa
2018-10-17 20:50     ` Laurent Pinchart
2018-10-18  4:31       ` Tomasz Figa
2018-10-18 17:28         ` Alexandru M Stan
2018-11-01 14:03           ` Laurent Pinchart
2018-11-01 14:30             ` Tomasz Figa
2018-11-01 15:03               ` Lars-Peter Clausen
2018-11-23 14:46                 ` Tomasz Figa
2019-03-06  6:09                   ` Tomasz Figa
2019-03-13  1:24                   ` Laurent Pinchart
2019-03-13  2:38                     ` Tomasz Figa
2019-08-06  4:15                       ` Tomasz Figa
2019-08-06  8:34                         ` Kieran Bingham
2019-08-07 13:38                           ` Tomasz Figa

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=20181017075242.21790-1-henryhsu@chromium.org \
    --to=henryhsu@chromium.org \
    --cc=jcliang@chromium.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=tfiga@chromium.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®