Commit Graph

12 Commits (d913d6303072ca194919d851e6743ad8c3a7563d)

Author SHA1 Message Date
Mike Isely 794b16072e V4L/DVB (7321): pvrusb2: Rework context handling and initialization
This change significantly rearranges pvr2_context level initialization
and operation:

1. A new kernel thread is set up for management of the context.

2. Destruction of the pvr2_context instance is moved into the kernel
   thread.  No other context is able to remove the instance; doing
   this simplifies lock handling.

3. The callback into pvrusb2-main, which is used to trigger
   initialization of each interface, is now issued from this kernel
   thread.  Previously it had been indirectly issued out of the work
   queue thread in pvr2_hdw, which led to deadlock issues if the
   interface needed to change a control setting (which in turn
   requires dispatch of another work queue entry).

4. Callbacks into the interfaces (via the pvr2_channel structure) are
   now issued strictly from this thread.  The net result of this is
   that such callback functions can now also safely operate driver
   controls without deadlocking the work queue.  (At the moment this
   is not actually a problem, but I'm anticipating issues with this in
   the future).

5. There is no longer any need for anyone to enter / exit the
   pvr2_context structure.  Implementation of the kernel thread here
   allows this all to be internal now, simplifying other logic.

6. A very very longstanding issue involving a mutex deadlock between
   the pvrusb2 driver and v4l should now be solved.  The deadlock
   involved the pvr2_context mutex and a globals-protecting mutex in
   v4l.  During initialization the driver would take the pvr2_context
   mutex first then the v4l2 interface would register with v4l and
   implicitly take the v4l mutex.  Later when v4l would call back into
   the driver, the two mutexes could possibly be taken in the opposite
   order, a situation that can lead to deadlock.  In practice this
   really wasn't an issue unless a v4l app tried to start VERY early
   after the driver appeared.  However it still needed to be solved,
   and with the use of the kernel thread relieving need for
   pvr2_context mutex, the problem should be finally solved.

Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2008-04-24 14:07:48 -03:00
Mike Isely c4a8828ddb V4L/DVB (7319): pvrusb2: Close potential race condition during initialization
There is a callback that is issued to into pvr2_context from pvr2_hdw
after initialization is done.  There was a probability that this
callback could get missed.  Fixed.

Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2008-04-24 14:07:48 -03:00
Mike Isely 99a6acf9a7 V4L/DVB (7306): pvrusb2: Fix oops possible when claiming a NULL stream
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2008-04-24 14:07:47 -03:00
Matthew Wilcox d3135846f6 drivers: Remove unnecessary inclusions of asm/semaphore.h
None of these files use any of the functionality promised by
asm/semaphore.h.  It's possible that they rely on it dragging in some
unrelated header file, but I can't build all these files, so we'll have
fix any build failures as they come up.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
2008-04-18 22:16:32 -04:00
Mike Isely 681c739944 V4L/DVB (6691): pvrusb2: Rework pipeline state control
This is a new implementation for video pipeline control within the
pvrusb2 driver.  Actual start/stop of the pipeline is moved to the
driver's kernel thread.  Pipeline stages are controlled autonomously
based on surrounding pipeline or application control state.  Kernel
thread management is also cleaned up and moved into the internal
control structure of the driver, solving a set up / tear down race
along the way.  Better failure recovery is implemented with this new
control strategy.  Also with this change comes better control of the
cx23416 encoder, building on additional information learned about the
peculiarities of controlling this part (this information was the
original trigger for this rework).  With this change, overall encoder
stability should be considerably improved.  Yes, this is a large
change for this driver, but due to the nature of the feature being
worked on, the changes are fairly pervasive and would be difficult to
break into smaller pieces with any semblence of step-wise stability.

Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2008-01-25 19:03:01 -02:00
Mike Isely 747f07961e V4L/DVB (6205): pvrusb2: Fix oops in error leg cleanup
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-10-09 22:14:30 -03:00
Mike Isely ca545f7c39 V4L/DVB (5091): Pvrusb2: Use kzalloc in place of kmalloc/memset pairs
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-02-21 13:34:41 -02:00
Mike Isely 62f5fdace7 V4L/DVB (5052): Pvrusb2: Remove stream claiming hack from /dev/radio
Trying to temporarily check that the stream is not claimed during open
of the radio device is at best a race condition.  What's to stop
another app from claiming the stream anyway the instant after the
check is done?  The implementation for this was dicey anyway.  So it's
removed.  The only "price" for this is that if /dev/radioX is opened
while streaming video, then the video stream is just going to switch
to radio mode anyway.  If a user does this, he gets what he expects...

Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-02-21 13:34:33 -02:00
Pantelis Koukousoulas 99cfdf5cc6 V4L/DVB (5038): Pvrusb2: Implement stream claim checking function
Add (and expose) a new function, pvr2_channel_check_stream_no_lock(), in
pvrusb2-context.c. This is hopefully the last V4L2 interface related patch
to change anything outside pvrusb2-v4l2.c.

We need this to implement the open() for the radio device. The reason is
that within the *enter_context() section of open() we need to ensure nobody
is streaming and if we cannot, we should cleanup after ourselves and return
 -EBUSY. We cannot just use claim_stream() because:

   1) That would cause a deadlock trying to re-acquire the context lock
   2) We only need to ensure that nobody is streaming. We don't need to
      actually acquire the stream.

Again, this is a kinda ugly patch. Feel free to improve.

Signed-off-by: Pantelis Koukousoulas <pakt223@freemail.gr>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-02-21 13:34:23 -02:00
David Howells c4028958b6 WorkStruct: make allyesconfig
Fix up for make allyesconfig.

Signed-Off-By: David Howells <dhowells@redhat.com>
2006-11-22 14:57:56 +00:00
Mike Isely a0fd1cb171 V4L/DVB (4288): Clean out a zillion sparse warnings in pvrusb2
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2006-06-30 15:59:50 -03:00
Mike Isely d855497edb V4L/DVB (4228a): pvrusb2 to kernel 2.6.18
Implement V4L2 driver for the Hauppauge PVR USB2 TV tuner.

The Hauppauge PVR USB2 is a USB connected TV tuner with an embedded
cx23416 hardware MPEG2 encoder.  There are two major variants of this
device; this driver handles both.  Any V4L2 application which
understands MPEG2 video stream data should be able to work with this
device.

Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2006-06-27 00:17:15 -03:00