-/* $OpenBSD: video.c,v 1.17 2008/07/19 06:39:00 mglocker Exp $ */
+/* $OpenBSD: video.c,v 1.18 2008/07/23 22:10:21 mglocker Exp $ */
/*
* Copyright (c) 2008 Robert Nagy <robert@openbsd.org>
* Copyright (c) 2008 Marcus Glocker <mglocker@openbsd.org>
sc->hw_if == NULL)
return (ENXIO);
+ if (sc->sc_open & VIDEO_OPEN)
+ return (EBUSY);
+ sc->sc_open |= VIDEO_OPEN;
+
sc->sc_start_read = 0;
if (sc->hw_if->open != NULL)
videoclose(dev_t dev, int flags, int fmt, struct proc *p)
{
struct video_softc *sc;
+ int r = 0;
sc = video_cd.cd_devs[VIDEOUNIT(dev)];
if (sc->hw_if->close != NULL)
- return (sc->hw_if->close(sc->hw_hdl));
- else
- return (0);
+ r = sc->hw_if->close(sc->hw_hdl);
+
+ sc->sc_open &= ~VIDEO_OPEN;
+
+ return (r);
}
int
-/* $OpenBSD: videovar.h,v 1.5 2008/06/13 05:00:32 mglocker Exp $ */
+/* $OpenBSD: videovar.h,v 1.6 2008/07/23 22:10:21 mglocker Exp $ */
/*
* Copyright (c) 2008 Robert Nagy <robert@openbsd.org>
* Copyright (c) 2008 Marcus Glocker <mglocker@openbsd.org>
struct device *sc_dev; /* hardware device struct */
struct video_hw_if *hw_if; /* hardware interface */
char sc_dying; /* device detached */
+#define VIDEO_OPEN 0x01
+ char sc_open;
int sc_fsize;
uint8_t *sc_fbuffer;