Re: Coordinating concurrent users of v4l2 devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Ronald Bultje <rbultje@xxxxxxxxxxxxxxxxxxx> writes:

> Maybe you'd want to add a exclusivity-flag to open() - O_EXCL (see
> bits/fcntl.h). I'm not sure whether this is done via file_ops or whether
> the driver should do this itself. In the latter case, I don't think any
> driver currently implements it. In the first case, it
> works-out-of-the-box.

The drivers must look at O_EXCL I think.  At least th floppy drivers
open function (where you can get exclusive access using O_EXCL) has
some checks in there.

But I think that wouldn't fix the issue.  With v4l2 there is no
difference between /dev/video and /dev/vbi.  /dev/vbi is just a
backward compatibility thing which gives you a /dev/video file handle
which is in vbi mode by default.  If nxtvepg has /dev/vbi open and
reads from that device, open(/dev/video,O_EXCL) will fail.

The problem isn't that nxtvepg wants exclusive access, it wants just
play nice and not upset the user running some tv app in parallel by
switching to another tv channel.

> > The ideal solution to this problem I would imagine is to introduce
> > priority levels associated with each open.
> 
> Nah... All opens should be equal, imho. Priority levels is just too much
> work for driver writers, and too much can (and will) go wrong.

I agree that priority levels are likely to complex.

One way to fix it would be to add a "how many users has this device"
ioctl.  That would be simple and likely do the job in most cases, but
it also introduces races which isn't that nice.

Another way would be to have some kind of O_EXCL flag, but at ioctl
level.  So nxtvepg could set that for the S_FREQUENCY ioctl and the
driver would refuse the switch with -EBUSY if there is more than one
file handle open at that time.

  Gerd

-- 
Weil die späten Diskussionen nicht mal mehr den Rotwein lohnen.
				-- Wacholder in "Melanie"





[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux