diff options
author | Marcus Glocker <mglocker@cvs.openbsd.org> | 2020-12-28 18:28:12 +0000 |
---|---|---|
committer | Marcus Glocker <mglocker@cvs.openbsd.org> | 2020-12-28 18:28:12 +0000 |
commit | 3dd0b871bb6d5c34fea0429d87ee38297d97ca66 (patch) | |
tree | d6da6d1e7a3f746a8f4b173b6583302c61f20012 /sys/dev/video.c | |
parent | 1ba7442cb2c5be7aab3975ef0ec3be7dc8abc6d2 (diff) |
Analog to the the kern.audio.record sysctl parameter for audio(4)
devices, introduce kern.video.record for video(4) devices. By default
kern.video.record will be set to zero, blanking all data delivered
by device drivers which attach to video(4).
The idea was initially proposed by
Laurence Tratt <laurie AT tratt DOT net>.
ok mpi@
Diffstat (limited to 'sys/dev/video.c')
-rw-r--r-- | sys/dev/video.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/sys/dev/video.c b/sys/dev/video.c index 8f345357295..43e9e16386d 100644 --- a/sys/dev/video.c +++ b/sys/dev/video.c @@ -1,4 +1,4 @@ -/* $OpenBSD: video.c,v 1.45 2020/12/25 12:59:52 visa Exp $ */ +/* $OpenBSD: video.c,v 1.46 2020/12/28 18:28:11 mglocker Exp $ */ /* * Copyright (c) 2008 Robert Nagy <robert@openbsd.org> @@ -51,6 +51,7 @@ struct video_softc { int sc_fsize; uint8_t *sc_fbuffer; + caddr_t sc_fbuffer_mmap; size_t sc_fbufferlen; int sc_vidmode; /* access mode */ #define VIDMODE_NONE 0 @@ -78,6 +79,11 @@ struct cfdriver video_cd = { NULL, "video", DV_DULL }; +/* + * Global flag to control if video recording is enabled by kern.video.record. + */ +int video_record_enable = 0; + int videoprobe(struct device *parent, void *match, void *aux) { @@ -191,6 +197,8 @@ videoread(dev_t dev, struct uio *uio, int ioflag) /* move no more than 1 frame to userland, as per specification */ size = ulmin(uio->uio_resid, sc->sc_fsize); + if (!video_record_enable) + bzero(sc->sc_fbuffer, size); error = uiomove(sc->sc_fbuffer, size, uio); sc->sc_frames_ready--; if (error) @@ -205,6 +213,7 @@ int videoioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) { struct video_softc *sc; + struct v4l2_buffer *vb = (struct v4l2_buffer *)data; int unit, error; unit = VIDEOUNIT(dev); @@ -299,6 +308,8 @@ videoioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) } error = (sc->hw_if->dqbuf)(sc->hw_hdl, (struct v4l2_buffer *)data); + if (!video_record_enable) + bzero(sc->sc_fbuffer_mmap + vb->m.offset, vb->length); sc->sc_frames_ready--; break; case VIDIOC_STREAMON: @@ -409,6 +420,10 @@ videommap(dev_t dev, off_t off, int prot) panic("videommap: invalid page"); sc->sc_vidmode = VIDMODE_MMAP; + /* store frame buffer base address for later blanking */ + if (off == 0) + sc->sc_fbuffer_mmap = p; + return (pa); } |