From: Marcus Glocker Subject: Re: sys/utvfu, sys/uvideo: clearify used timestamps To: "Kirill A. Korinsky" Cc: tech@openbsd.org Date: Tue, 25 Feb 2025 21:01:18 +0100 On Tue, Feb 25, 2025 at 07:11:49PM GMT, Kirill A. Korinsky wrote: > tech@, > > I'd like to clearify which timestamps have we used in v4l2 buffers in > both drivers: utvfu and uvideo, which uses the same logic. > > V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC and V4L2_BUF_FLAG_TSTAMP_SRC_EOF mean > that timestamp has been taken from CLOCK_MONOTONIC when the last pixel > of the frame was read from device, and not before the first one. > > Thus, I had explicity unset V4L2_BUF_FLAG_TIMECODE bit if application > requested it, because it isn't supported. > > Ok? ok mglocker@ > Index: sys/dev/usb/utvfu.c > =================================================================== > RCS file: /home/cvs/src/sys/dev/usb/utvfu.c,v > diff -u -p -r1.22 utvfu.c > --- sys/dev/usb/utvfu.c 15 Jan 2025 20:34:50 -0000 1.22 > +++ sys/dev/usb/utvfu.c 25 Feb 2025 17:45:24 -0000 > @@ -1378,7 +1378,12 @@ utvfu_mmap_queue(struct utvfu_softc *sc, > sc->sc_mmap[i].v4l2_buf.bytesused = len; > > /* timestamp it */ > - getmicrotime(&sc->sc_mmap[i].v4l2_buf.timestamp); > + getmicrouptime(&sc->sc_mmap[i].v4l2_buf.timestamp); > + sc->sc_mmap[i].v4l2_buf.flags &= ~V4L2_BUF_FLAG_TIMESTAMP_MASK; > + sc->sc_mmap[i].v4l2_buf.flags |= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; > + sc->sc_mmap[i].v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; > + sc->sc_mmap[i].v4l2_buf.flags |= V4L2_BUF_FLAG_TSTAMP_SRC_EOF; > + sc->sc_mmap[i].v4l2_buf.flags &= ~V4L2_BUF_FLAG_TIMECODE; > > /* appropriately set/clear flags */ > sc->sc_mmap[i].v4l2_buf.flags &= ~V4L2_BUF_FLAG_QUEUED; > Index: sys/dev/usb/uvideo.c > =================================================================== > RCS file: /home/cvs/src/sys/dev/usb/uvideo.c,v > diff -u -p -r1.242 uvideo.c > --- sys/dev/usb/uvideo.c 24 Feb 2025 21:24:54 -0000 1.242 > +++ sys/dev/usb/uvideo.c 25 Feb 2025 17:45:14 -0000 > @@ -2426,7 +2426,12 @@ uvideo_mmap_queue(struct uvideo_softc *s > sc->sc_mmap[i].v4l2_buf.bytesused = len; > > /* timestamp it */ > - getmicrotime(&sc->sc_mmap[i].v4l2_buf.timestamp); > + getmicrouptime(&sc->sc_mmap[i].v4l2_buf.timestamp); > + sc->sc_mmap[i].v4l2_buf.flags &= ~V4L2_BUF_FLAG_TIMESTAMP_MASK; > + sc->sc_mmap[i].v4l2_buf.flags |= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; > + sc->sc_mmap[i].v4l2_buf.flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; > + sc->sc_mmap[i].v4l2_buf.flags |= V4L2_BUF_FLAG_TSTAMP_SRC_EOF; > + sc->sc_mmap[i].v4l2_buf.flags &= ~V4L2_BUF_FLAG_TIMECODE; > > /* forward error bit */ > sc->sc_mmap[i].v4l2_buf.flags &= ~V4L2_BUF_FLAG_ERROR; >