summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/video.c17
-rw-r--r--sys/kern/kern_sysctl.c30
-rw-r--r--sys/sys/sysctl.h17
3 files changed, 60 insertions, 4 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);
}
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 82010e3ee1c..d462926fea2 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.384 2020/12/07 16:55:29 mpi Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.385 2020/12/28 18:28:11 mglocker Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -114,6 +114,7 @@
#endif
#include "audio.h"
+#include "video.h"
#include "pf.h"
extern struct forkstat forkstat;
@@ -125,6 +126,9 @@ extern long numvnodes;
#if NAUDIO > 0
extern int audio_record_enable;
#endif
+#if NVIDEO > 0
+extern int video_record_enable;
+#endif
int allowkmem;
int allowdt;
@@ -141,6 +145,9 @@ int sysctl_cptime2(int *, u_int, void *, size_t *, void *, size_t);
#if NAUDIO > 0
int sysctl_audio(int *, u_int, void *, size_t *, void *, size_t);
#endif
+#if NVIDEO > 0
+int sysctl_video(int *, u_int, void *, size_t *, void *, size_t);
+#endif
int sysctl_cpustats(int *, u_int, void *, size_t *, void *, size_t);
int sysctl_utc_offset(void *, size_t *, void *, size_t);
@@ -379,6 +386,7 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
case KERN_FILE:
case KERN_WITNESS:
case KERN_AUDIO:
+ case KERN_VIDEO:
case KERN_CPUSTATS:
break;
default:
@@ -642,6 +650,11 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
return (sysctl_audio(name + 1, namelen - 1, oldp, oldlenp,
newp, newlen));
#endif
+#if NVIDEO > 0
+ case KERN_VIDEO:
+ return (sysctl_video(name + 1, namelen - 1, oldp, oldlenp,
+ newp, newlen));
+#endif
case KERN_CPUSTATS:
return (sysctl_cpustats(name + 1, namelen - 1, oldp, oldlenp,
newp, newlen));
@@ -2443,6 +2456,21 @@ sysctl_audio(int *name, u_int namelen, void *oldp, size_t *oldlenp,
}
#endif
+#if NVIDEO > 0
+int
+sysctl_video(int *name, u_int namelen, void *oldp, size_t *oldlenp,
+ void *newp, size_t newlen)
+{
+ if (namelen != 1)
+ return (ENOTDIR);
+
+ if (name[0] != KERN_VIDEO_RECORD)
+ return (ENOENT);
+
+ return (sysctl_int(oldp, oldlenp, newp, newlen, &video_record_enable));
+}
+#endif
+
int
sysctl_cpustats(int *name, u_int namelen, void *oldp, size_t *oldlenp,
void *newp, size_t newlen)
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index b7693973185..acec065eea6 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.h,v 1.212 2020/11/07 05:24:20 gnezdo Exp $ */
+/* $OpenBSD: sysctl.h,v 1.213 2020/12/28 18:28:11 mglocker Exp $ */
/* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */
/*
@@ -189,7 +189,8 @@ struct ctlname {
#define KERN_PFSTATUS 86 /* struct: pf status and stats */
#define KERN_TIMEOUT_STATS 87 /* struct: timeout status and stats */
#define KERN_UTC_OFFSET 88 /* int: adjust RTC time to UTC */
-#define KERN_MAXID 89 /* number of valid kern ids */
+#define KERN_VIDEO 89 /* struct: video properties */
+#define KERN_MAXID 90 /* number of valid kern ids */
#define CTL_KERN_NAMES { \
{ 0, 0 }, \
@@ -281,6 +282,7 @@ struct ctlname {
{ "pfstatus", CTLTYPE_STRUCT }, \
{ "timeout_stats", CTLTYPE_STRUCT }, \
{ "utc_offset", CTLTYPE_INT }, \
+ { "video", CTLTYPE_STRUCT }, \
}
/*
@@ -323,6 +325,17 @@ struct ctlname {
}
/*
+ * KERN_VIDEO
+ */
+#define KERN_VIDEO_RECORD 1
+#define KERN_VIDEO_MAXID 2
+
+#define CTL_KERN_VIDEO_NAMES { \
+ { 0, 0 }, \
+ { "record", CTLTYPE_INT }, \
+}
+
+/*
* KERN_WITNESS
*/
#define KERN_WITNESS_WATCH 1 /* int: operating mode */