.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * v4l2-event.c |
---|
3 | 4 | * |
---|
.. | .. |
---|
6 | 7 | * Copyright (C) 2009--2010 Nokia Corporation. |
---|
7 | 8 | * |
---|
8 | 9 | * Contact: Sakari Ailus <sakari.ailus@iki.fi> |
---|
9 | | - * |
---|
10 | | - * This program is free software; you can redistribute it and/or |
---|
11 | | - * modify it under the terms of the GNU General Public License |
---|
12 | | - * version 2 as published by the Free Software Foundation. |
---|
13 | | - * |
---|
14 | | - * This program is distributed in the hope that it will be useful, but |
---|
15 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
17 | | - * General Public License for more details. |
---|
18 | 10 | */ |
---|
19 | 11 | |
---|
20 | 12 | #include <media/v4l2-dev.h> |
---|
.. | .. |
---|
35 | 27 | static int __v4l2_event_dequeue(struct v4l2_fh *fh, struct v4l2_event *event) |
---|
36 | 28 | { |
---|
37 | 29 | struct v4l2_kevent *kev; |
---|
| 30 | + struct timespec64 ts; |
---|
38 | 31 | unsigned long flags; |
---|
39 | 32 | |
---|
40 | 33 | spin_lock_irqsave(&fh->vdev->fh_lock, flags); |
---|
.. | .. |
---|
52 | 45 | |
---|
53 | 46 | kev->event.pending = fh->navailable; |
---|
54 | 47 | *event = kev->event; |
---|
| 48 | + ts = ns_to_timespec64(kev->ts); |
---|
| 49 | + event->timestamp.tv_sec = ts.tv_sec; |
---|
| 50 | + event->timestamp.tv_nsec = ts.tv_nsec; |
---|
55 | 51 | kev->sev->first = sev_pos(kev->sev, 1); |
---|
56 | 52 | kev->sev->in_use--; |
---|
57 | 53 | |
---|
.. | .. |
---|
103 | 99 | return NULL; |
---|
104 | 100 | } |
---|
105 | 101 | |
---|
106 | | -static void __v4l2_event_queue_fh(struct v4l2_fh *fh, const struct v4l2_event *ev, |
---|
107 | | - const struct timespec *ts) |
---|
| 102 | +static void __v4l2_event_queue_fh(struct v4l2_fh *fh, |
---|
| 103 | + const struct v4l2_event *ev, u64 ts) |
---|
108 | 104 | { |
---|
109 | 105 | struct v4l2_subscribed_event *sev; |
---|
110 | 106 | struct v4l2_kevent *kev; |
---|
.. | .. |
---|
144 | 140 | if (copy_payload) |
---|
145 | 141 | kev->event.u = ev->u; |
---|
146 | 142 | kev->event.id = ev->id; |
---|
147 | | - kev->event.timestamp = *ts; |
---|
| 143 | + kev->ts = ts; |
---|
148 | 144 | kev->event.sequence = fh->sequence; |
---|
149 | 145 | sev->in_use++; |
---|
150 | 146 | list_add_tail(&kev->list, &fh->available); |
---|
.. | .. |
---|
158 | 154 | { |
---|
159 | 155 | struct v4l2_fh *fh; |
---|
160 | 156 | unsigned long flags; |
---|
161 | | - struct timespec timestamp; |
---|
| 157 | + u64 ts; |
---|
162 | 158 | |
---|
163 | 159 | if (vdev == NULL) |
---|
164 | 160 | return; |
---|
165 | 161 | |
---|
166 | | - ktime_get_ts(×tamp); |
---|
| 162 | + ts = ktime_get_ns(); |
---|
167 | 163 | |
---|
168 | 164 | spin_lock_irqsave(&vdev->fh_lock, flags); |
---|
169 | 165 | |
---|
170 | 166 | list_for_each_entry(fh, &vdev->fh_list, list) |
---|
171 | | - __v4l2_event_queue_fh(fh, ev, ×tamp); |
---|
| 167 | + __v4l2_event_queue_fh(fh, ev, ts); |
---|
172 | 168 | |
---|
173 | 169 | spin_unlock_irqrestore(&vdev->fh_lock, flags); |
---|
174 | 170 | } |
---|
.. | .. |
---|
177 | 173 | void v4l2_event_queue_fh(struct v4l2_fh *fh, const struct v4l2_event *ev) |
---|
178 | 174 | { |
---|
179 | 175 | unsigned long flags; |
---|
180 | | - struct timespec timestamp; |
---|
181 | | - |
---|
182 | | - ktime_get_ts(×tamp); |
---|
| 176 | + u64 ts = ktime_get_ns(); |
---|
183 | 177 | |
---|
184 | 178 | spin_lock_irqsave(&fh->vdev->fh_lock, flags); |
---|
185 | | - __v4l2_event_queue_fh(fh, ev, ×tamp); |
---|
| 179 | + __v4l2_event_queue_fh(fh, ev, ts); |
---|
186 | 180 | spin_unlock_irqrestore(&fh->vdev->fh_lock, flags); |
---|
187 | 181 | } |
---|
188 | 182 | EXPORT_SYMBOL_GPL(v4l2_event_queue_fh); |
---|