From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Atif Niyaz <atifniyaz@google.com>
Cc: Atif Niyaz <atifniyaz11@gmail.com>,
Siarhei Vishniakou <svv@google.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] input: API for Setting a Timestamp from a Driver
Date: Thu, 25 Jul 2019 08:27:28 +0300 [thread overview]
Message-ID: <20190725052728.GA874@penguin> (raw)
In-Reply-To: <20190718194133.64034-1-atifniyaz@google.com>
Hi Atif,
On Thu, Jul 18, 2019 at 12:41:33PM -0700, Atif Niyaz wrote:
> @@ -150,16 +143,19 @@ static void __evdev_flush_queue(struct evdev_client *client, unsigned int type)
> static void __evdev_queue_syn_dropped(struct evdev_client *client)
> {
> struct input_event ev;
> - ktime_t time;
> struct timespec64 ts;
> + ktime_t *time = input_get_timestamp(client->evdev->handle.dev);
>
> - time = client->clk_type == EV_CLK_REAL ?
> - ktime_get_real() :
> - client->clk_type == EV_CLK_MONO ?
> - ktime_get() :
> - ktime_get_boottime();
> + switch (client->clk_type) {
> + case INPUT_CLK_REAL:
> + case INPUT_CLK_MONO:
> + ts = ktime_to_timespec64(time[client->clk_type]);
> + break;
> + default:
> + ts = ktime_to_timespec64(time[INPUT_CLK_BOOT]);
> + break;
Since we trust client->clk_type be valid in evdev_event() we can also
trust it here. I replaced the switch statement with:
ts = ktime_to_timespec64(ev_time[client->clkk_type]);
> + }
>
> - ts = ktime_to_timespec64(time);
> ev.input_event_sec = ts.tv_sec;
> ev.input_event_usec = ts.tv_nsec / NSEC_PER_USEC;
> ev.type = EV_SYN;
> @@ -185,21 +181,21 @@ static void evdev_queue_syn_dropped(struct evdev_client *client)
> spin_unlock_irqrestore(&client->buffer_lock, flags);
> }
>
> -static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid)
> +static int evdev_set_clk_type(struct evdev_client *client, clockid_t clkid)
The data passed to evdev_set_clk_type() is an integer with values that
coincide with the enum's values, so I kept the type of parameter as it
was.
> +/**
> + * input_set_timestamp - set timestamp for input events
> + * @dev: input device to set timestamp for
> + * @timestamp: the time at which the event has occurred
> + * in CLOCK_MONOTONIC
> + *
> + * This function is intended to provide to the input system a more
> + * accurate time of when an event actually occurred. The driver should
> + * call this function as soon as a timestamp is acquired ensuring
> + * clock conversions in input_set_timestamp are done correctly.
> + *
> + * The system entering a suspend between timestamp acquisition and
> + * calling input_set_timestamp can result in inaccurate conversions.
> + *
> + */
> +static inline void input_set_timestamp(struct input_dev *dev,
> + ktime_t timestamp)
> +{
> + dev->timestamp[INPUT_CLK_MONO] = timestamp;
> + dev->timestamp[INPUT_CLK_REAL] = ktime_mono_to_real(timestamp);
> + dev->timestamp[INPUT_CLK_BOOT] = ktime_mono_to_any(
> + timestamp, TK_OFFS_BOOT);
> +}
I moved this input input.c, together with input_get_timestamp().
Applied, thank you.
--
Dmitry
prev parent reply other threads:[~2019-07-25 5:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-18 19:41 [PATCH v2] input: API for Setting a Timestamp from a Driver Atif Niyaz
2019-07-25 5:27 ` Dmitry Torokhov [this message]
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=20190725052728.GA874@penguin \
--to=dmitry.torokhov@gmail.com \
--cc=atifniyaz11@gmail.com \
--cc=atifniyaz@google.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=svv@google.com \
/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