Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp915701imd; Thu, 1 Nov 2018 07:32:27 -0700 (PDT) X-Google-Smtp-Source: AJdET5fOkAYC3W5K8REIDvP7pNUDw0O2EheqZTgGFRMujzJz9rdW+QiqugS53404uOMOAv8kM0sD X-Received: by 2002:a62:89d7:: with SMTP id n84-v6mr8036015pfk.255.1541082747432; Thu, 01 Nov 2018 07:32:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541082747; cv=none; d=google.com; s=arc-20160816; b=zYC96IS0eMyBx9Qz0+sG5Bxlr5aqfF2wL2Pc/1qUVgo7QFStqKuyvZdt//2vAfZB9C UynGXW2/rpOdH9wQMHnVT2SI1jxiJ8WQCX8slOYJ5xtk7JJkYcuLReqVWu7TTBczz2wl b3WwjvJszI/mgdTSE5YBVzo/ERwRteT7b62Y+4durky8LN0J7UAoFOQ2HOSoYHwOPWqW Juzzgm2+axaIokqZjzibpkLkafBubtgb5Ce+sIN4Wl2BsKqKoE2gARgULbtn2u5xqEGH uhCJipddmmB14Mjw/b+kSWvjO1Fws9PBeSYcoiwfHTJdhTLGihGaO+KY9mw2xAVEH7FV X/ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=OvOiUtWG8Duts/WcGpmokgnW9ez6MB+usziPACy9+Ls=; b=ZcUyAG9RgUo7cGCRWGrE5zKUmgG7nL+HQ5uWw/Z7VH/KJbcuxsCS517LFPI8ovYQtC Tj/mYbqHvI3pw7TLqT765QcBH23Bor980GFIBm7bpXtY52u/FyH8Q6LjYNMh5lVB8a6x B//zN9IuCXgdi502Gudn8hPluJRLNPU2uwIjv47+BtIJhlTaM5nbQlBhlg4FOiUlSzj8 EpSU4zTmOCyxPoEPKkE89o3r29UW29FOTJ9JFy1+gy3TeuAnm4JFAku8o3MQavR3C1Yz rr2zFaEcaomn9V3T2h6ViduFuSiXpH+DvU5gpV3CnhLDOkZH7UyXkG3153MbKZ36ae1h W6kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jd3KvYvp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si18745035pll.361.2018.11.01.07.32.11; Thu, 01 Nov 2018 07:32:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jd3KvYvp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728723AbeKAXdx (ORCPT + 99 others); Thu, 1 Nov 2018 19:33:53 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:42085 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728016AbeKAXdx (ORCPT ); Thu, 1 Nov 2018 19:33:53 -0400 Received: by mail-yb1-f195.google.com with SMTP id o204-v6so8179665yba.9 for ; Thu, 01 Nov 2018 07:30:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OvOiUtWG8Duts/WcGpmokgnW9ez6MB+usziPACy9+Ls=; b=jd3KvYvpo9myxoLMJAiu9o4OVUEAi9vur0s8zChcu4KaU2RKO8z4+kQA2Hel6MHsjB DSU8OwhURxA824SXKbzbqXbKgzPDyHw0BEDEFFgejopBpqNhpRSywgnygjoluD4SqKOB ZY8yJm4ZFWefRKKtjCiFPHroQ1RJryIvv6maI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OvOiUtWG8Duts/WcGpmokgnW9ez6MB+usziPACy9+Ls=; b=OF2flfv7S5RtXptxVyqFhVEdEKDJkHzTmHPQ2qh2XT48rTV/Z5FXFNirTs6ZdSsrBF IP9XIALoA7iEElJbdydDbWXLLFlBtwXQ+KzV8Fb9R8zrQ+5KX9YsNofjkKJdfIJ3fpKE MrLv3McX5xfxSmmvB8fYcJgwT5/QxlbY9OW2ETihd1zvFluo76qaQ1H6UXE6kHvfeXzZ xo2LG3woSlDxz9Pm5DeWuvD9lEy6qFaG/dz/hagEHRd84suZUDBN5jXYmFfIjtpD+WEr VxVgUwyAfhOWaSYTq/pijlUZyfuyxYt3BO/d0zfhN/l0EUlJrhOjYNjPczchDEjS64/8 DzWg== X-Gm-Message-State: AGRZ1gKLoGVV+mkSpOXTaMMFU6wU2HyuJdnhfePcBkr+YiM1AuVXrr9O aIeBkJyx4C9tNrZ1A3o7S/bs4rjYJ9E= X-Received: by 2002:a5b:c45:: with SMTP id d5-v6mr7550711ybr.366.1541082639934; Thu, 01 Nov 2018 07:30:39 -0700 (PDT) Received: from mail-yw1-f54.google.com (mail-yw1-f54.google.com. [209.85.161.54]) by smtp.gmail.com with ESMTPSA id s187-v6sm8039742ywe.10.2018.11.01.07.30.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Nov 2018 07:30:39 -0700 (PDT) Received: by mail-yw1-f54.google.com with SMTP id i185-v6so7960265ywa.12 for ; Thu, 01 Nov 2018 07:30:39 -0700 (PDT) X-Received: by 2002:a81:4786:: with SMTP id u128-v6mr7808191ywa.164.1541082638529; Thu, 01 Nov 2018 07:30:38 -0700 (PDT) MIME-Version: 1.0 References: <20181017075242.21790-1-henryhsu@chromium.org> <1610184.U7oo9Z4Yep@avalon> In-Reply-To: <1610184.U7oo9Z4Yep@avalon> From: Tomasz Figa Date: Thu, 1 Nov 2018 23:30:26 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] media: uvcvideo: Add boottime clock support To: Laurent Pinchart Cc: Alexandru Stan , Gwendal Grignou , Heng-Ruey Hsu , Mauro Carvalho Chehab , Linux Media Mailing List , Linux Kernel Mailing List , Ricky Liang , linux-iio@vger.kernel.org, Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 1, 2018 at 11:03 PM Laurent Pinchart wrote: > > Hi Alexandru, > > On Thursday, 18 October 2018 20:28:06 EET Alexandru M Stan wrote: > > On Wed, Oct 17, 2018 at 9:31 PM, Tomasz Figa wrote: > > > On Thu, Oct 18, 2018 at 5:50 AM Laurent Pinchart wrote: > > >> On Wednesday, 17 October 2018 11:28:52 EEST Tomasz Figa wrote: > > >>> On Wed, Oct 17, 2018 at 5:02 PM Laurent Pinchart wrote: > > >>>> On Wednesday, 17 October 2018 10:52:42 EEST Heng-Ruey Hsu wrote: > > >>>>> Android requires camera timestamps to be reported with > > >>>>> CLOCK_BOOTTIME to sync timestamp with other sensor sources. > > >>>> > > >>>> What's the rationale behind this, why can't CLOCK_MONOTONIC work ? If > > >>>> the monotonic clock has shortcomings that make its use impossible for > > >>>> proper synchronization, then we should consider switching to > > >>>> CLOCK_BOOTTIME globally in V4L2, not in selected drivers only. > > >>> > > >>> CLOCK_BOOTTIME includes the time spent in suspend, while > > >>> CLOCK_MONOTONIC doesn't. I can imagine the former being much more > > >>> useful for anything that cares about the actual, long term, time > > >>> tracking. Especially important since suspend is a very common event on > > >>> Android and doesn't stop the time flow there, i.e. applications might > > >>> wake up the device to perform various tasks at necessary times. > > >> > > >> Sure, but this patch mentions timestamp synchronization with other > > >> sensors, and from that point of view, I'd like to know what is wrong with > > >> the monotonic clock if all devices use it. > > > > > > AFAIK the sensors mentioned there are not camera sensors, but rather > > > things we normally put under IIO, e.g. accelerometers, gyroscopes and > > > so on. I'm not sure how IIO deals with timestamps, but Android seems > > > to operate in the CLOCK_BOTTIME domain. Let me add some IIO folks. > > > > > > Gwendal, Alexandru, do you think you could shed some light on how we > > > handle IIO sensors timestamps across the kernel, Chrome OS and > > > Android? > > > > On our devices of interest have a specialized "sensor" that comes via > > IIO (from the EC, cros-ec-ring driver) that can be used to more > > accurately timestamp each frame (since it's recorded with very low > > jitter by a realtime-ish OS). In some high level userspace thing > > (specifically the Android Camera HAL) we try to pick the best > > timestamp from the IIO, whatever's closest to what the V4L stuff gives > > us. > > > > I guess the Android convention is for sensor timestamps to be in > > CLOCK_BOOTTIME (maybe because it likes sleeping so much). There's > > probably no advantage to using one over the other, but the important > > thing is that they have to be the same, otherwise the closest match > > logic would fail. > > That's my understanding too, I don't think CLOCK_BOOTTIME really brings much > benefit in this case, I think it does have a significant benefit. CLOCK_MONOTONIC stops when the device is sleeping, but the sensors can still capture various actions. We would lose the time keeping of those actions if we use CLOCK_MONOTONIC. > but it's important than all timestamps use the same > clock. The question is thus which clock we should select. Mainline mostly uses > CLOCK_MONOTONIC, and Android CLOCK_BOOTTIME. Would you like to submit patches > to switch Android to CLOCK_MONOTONIC ? :-) Is it Android using CLOCK_BOOTTIME or the sensors (IIO?). I have almost zero familiarity with the IIO subsystem and was hoping someone from there could comment on what time domain is used for those sensors. Best regards, Tomasz