hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/media/v4l2-core/v4l2-event.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * v4l2-event.c
34 *
....@@ -6,15 +7,6 @@
67 * Copyright (C) 2009--2010 Nokia Corporation.
78 *
89 * 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.
1810 */
1911
2012 #include <media/v4l2-dev.h>
....@@ -35,6 +27,7 @@
3527 static int __v4l2_event_dequeue(struct v4l2_fh *fh, struct v4l2_event *event)
3628 {
3729 struct v4l2_kevent *kev;
30
+ struct timespec64 ts;
3831 unsigned long flags;
3932
4033 spin_lock_irqsave(&fh->vdev->fh_lock, flags);
....@@ -52,6 +45,9 @@
5245
5346 kev->event.pending = fh->navailable;
5447 *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;
5551 kev->sev->first = sev_pos(kev->sev, 1);
5652 kev->sev->in_use--;
5753
....@@ -103,8 +99,8 @@
10399 return NULL;
104100 }
105101
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)
108104 {
109105 struct v4l2_subscribed_event *sev;
110106 struct v4l2_kevent *kev;
....@@ -144,7 +140,7 @@
144140 if (copy_payload)
145141 kev->event.u = ev->u;
146142 kev->event.id = ev->id;
147
- kev->event.timestamp = *ts;
143
+ kev->ts = ts;
148144 kev->event.sequence = fh->sequence;
149145 sev->in_use++;
150146 list_add_tail(&kev->list, &fh->available);
....@@ -158,17 +154,17 @@
158154 {
159155 struct v4l2_fh *fh;
160156 unsigned long flags;
161
- struct timespec timestamp;
157
+ u64 ts;
162158
163159 if (vdev == NULL)
164160 return;
165161
166
- ktime_get_ts(&timestamp);
162
+ ts = ktime_get_ns();
167163
168164 spin_lock_irqsave(&vdev->fh_lock, flags);
169165
170166 list_for_each_entry(fh, &vdev->fh_list, list)
171
- __v4l2_event_queue_fh(fh, ev, &timestamp);
167
+ __v4l2_event_queue_fh(fh, ev, ts);
172168
173169 spin_unlock_irqrestore(&vdev->fh_lock, flags);
174170 }
....@@ -177,12 +173,10 @@
177173 void v4l2_event_queue_fh(struct v4l2_fh *fh, const struct v4l2_event *ev)
178174 {
179175 unsigned long flags;
180
- struct timespec timestamp;
181
-
182
- ktime_get_ts(&timestamp);
176
+ u64 ts = ktime_get_ns();
183177
184178 spin_lock_irqsave(&fh->vdev->fh_lock, flags);
185
- __v4l2_event_queue_fh(fh, ev, &timestamp);
179
+ __v4l2_event_queue_fh(fh, ev, ts);
186180 spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
187181 }
188182 EXPORT_SYMBOL_GPL(v4l2_event_queue_fh);