These changes are required with the addition of digital television support
for the Hauppauge HVR1900 & HVR1950, the OnAir Creator and Sasem USB HDTV
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This patch contains the following cleanups:
- make the following needlessly global function static:
- pvr2_hdw_set_cur_freq()
- #if 0 the following unused global functions:
- pvr2_hdw_get_state_name()
- pvr2_hdw_get_debug_info_unlocked()
- pvr2_hdw_get_debug_info_locked()
Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Apparently the kernel developers no longer consider it proper
etiquette to use __FUNCTION__; everyone must instead use __func__
(even though it breaks with older compilers). And worse still, actual
effort is being expended to sweep this change throughout the kernel
source tree. Don't these people have better things to do? So...
Completely clean out all use of __FUNCTION__ from the pvrusb2 driver
(it was just in the sysfs interface). I'm not going to use __func__
either. So there.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The pvrusb2 driver was getting had by this scenario:
1. Task A calls kthread_stop() for task B.
2. Before exiting, then Task B calls kthread_stop() for task C.
The problem is, kthread_stop() wants to allocate an internal resource
to itself (i.e. acquire a lock), which won't be released until
kthread_stop() returns. But kthread_stop() won't return until task B
is dead. But task B won't die until it finishes its call to
kthread_stop() for task C, and that will block waiting on the resource
already allocated inside task A. Deadlock.
With the pvrusb2 driver, task A is the caller to pvr_exit(), task B is
the control thread run inside of pvrusb2-context.c, and task C is any
worker thread run inside of pvrusb2-hdw.c.
This problem got introduced by the previous threading setup change,
which was itself an attempt to fix a module tear-down race (which it
actually did fix). The lesson here is that a task being waited on as
part of a kthread_stop() simply cannot be allow to also issue a
kthread_stop() - or we make sure not to issue the enclosing
kthread_stop() until we know that the inner kthread_stop() has
completed first. The solution for the pvrusb2 driver is some hackish
code which changes the main control thread tear down into a two step
process. This then makes it possible to delay issuing the
kthread_stop() on the control thread until after we know that
everything has been torn down first. (And yes, we really need that
kthread_stop() because it's the only way to safely guarantee that a
module-referencing kernel thread has safely returned back out of the
module before we finally remove the module.)
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Earlier fix to handle DVB feed thread aborts was overly-aggressive.
We can take better advantage of what kthread_stop() can do. This
change simplifies things.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
If a disconnect happens before initialization is completed, the
pvrusb2 driver can accidentally touch dangling pointers. The whole
initialization function must be protected by the big_lock, and once
inside that lock, the initialization function should abort if it is
discovered that a disconnect has already taken place.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The pvrusb2 driver - for basically forever - was not enforcing a
proper module tear-down. Kernel threads are used inside the driver
and all must be gone before the module can be safely removed. This
changeset reimplements a chunk of pvrusb2-context.c to enforce this
correctly. Unfortunately this is not a simple fix. The new
implementation also cuts back on kernel thread usage; instead of there
being 1 control thread per instance now it's just 1 control thread
shared by all instances. (By dropping to a single thread then the
module exit function can block on its shutdown and the thread itself
can monitor and cleanly shut down all of the other instances first.)
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Implement timed measurement of encoder operation for the first time it
is run. This allows the driver to note when the encoder has been run
successfully for at least 1/4 second. On top of that implement
various bits to ensure that the encoder has been run once before
digital streaming for OnAir devices. This is done via several core
state machine tweaks.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Some tuners seem to not work in digital mode unless the encoder is
healthy. Implement a device attribute to represent this flag and
modify the core state machines to enforce this requirement.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
If the device fails to stream, the feed thread will block forever
waiting for buffers. But while in this state it was not looking for
an exit condition from the driver DVB interface. This caused the
thread to jam. Implement a new stop flag (which will be set
appropriately) to tell the thread to stop.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
When the DVB interface is not compiled, the pvr2_dvb_props struct is
not available - so it really should be ifdef'ed out as well. This
didn't cause an error because in this context its usage was as an
opaque pointer. But it really shouldn't be present at all if DVB is
not enabled.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The commands to start / stop USB streaming for an analog device are
fairly standard, owing to the fact that all supported devices
apparently started from the same common reference design. However
with digital mode, the commands seem to vary by vendor. This change
makes that variance more explicit. It also cleans up a related
problem for OnAir devices which prevented digital mode from working at
all.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Numerous places in the driver need to issue simple commands to the FX2
microcontroller (e.g. only 1 or 2 bytes, no reply needed). Previously
each place that did this, had to take lock, set up a central buffer,
and call the function to perform the handshake. This change puts
these steps into a single spot. This also has the effect of removing
the need to mess with the control lock from numerous places in the
code.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Implement a mechanism in the pvrusb2 driver for gathering statistics
on the stream buffering, including bytes transferred, buffers handled,
buffers in flight, etc. This is useful for debugging certain classes
of streaming issues and for determining if the buffer pool size is
generally correct for the driver.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Don't trigger a pathway state change if it's already been triggered
(eliminates some wasted processing and some debug output noise)
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Move pvr2_dvb_adapter usage out of the pvrusb2 driver core - it's
really private to the pvrusb2-dvb module and nothing outside of the
dvb implementation should care about it. Creation / destruction of
the pvr2_dvb_adapter instance is now contained entirely within
pvrusb2-dvb.c.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
In the end we'd like the dvb interface to always be present - even for
analog devices (via the mpeg encoder). However right now pvrusb2-dvb
won't operate correctly if the hardware doesn't have a digital tuner,
so don't initialize the DVB interface unless we know we have a digital
tuner.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Other pvrusb2-dvb changes have made the digital_up flag obsolete. So
kill it.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Rather than making an explicit call to tear down the pvrusb2-dvb
module, use the callback in the pvr2_channel structure. This has the
advantage that now tear-down only happens when it makes sense. The
previous implementation had scenarios where it was possible for the
tear-down call to happen without a prior initialization.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Eliminate the need for a separate pvr2_dvb_fh; since in the DVB
context there can only ever be a single instance then there is no need
for a separate instance to handle streaming state. This simplifies
the module. Also move streaming start/stop out of the feed thread and
into the driver's main context - which makes it possible for streaming
start up failures to be detected by the DVB core.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The pvrusb2-dvb feed thread cannot be allowed to exit by itself
without first waiting for kthread_should_stop() to return true.
Otherwise the driver will have a dangling task_struct context, which
will cause a very nasty kernel oops.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
start work on streaming / buffer handling code to feed the software demux
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This function is just a skeleton for now -
a placeholder to remind us to fix it.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Add basic framework for the DVB API. This is enough to control the
tuner & demod of the digital frontend, but the stream & buffer handling
is still missing.
Additional note from Mike Isely <isely@pobox.com> - also, since these
changes are still very experimental arrange for DVB changes to be
compiled in via new CONFIG_VIDEO_PVRUSB2_DVB option, for now.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Due to the patch order change, pvrusb2 were broken. So, changeset
4c3b01f711 were applied at mainstream to fix.
After the pvrusb2 changes, this patch is no longer required and should be
reverted.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Fix use of a non-int (size_t) being passed in a printf width field.
This benign issue has apparently been around for a long time, but went
undetected until now.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
TUNER_PHILIPS_ATSC is an ambiguous name for a tuner. Rename it to
TUNER_PHILIPS_FCV1236D to be more descriptive.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The pvrusb2 driver normally picks up the default video standard from the
eeprom on Hauppauge devices, but the OnAir HDTV and OnAir Creator are not
Hauppauge devices, and do not store this information in any eeprom.
These devices support NTSC/ATSC, so we should use NTSC by default when in
analog mode.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The C99 specification states in section 6.11.5:
The placement of a storage-class specifier other than at the
beginning of the declaration specifiers in a declaration is an
obsolescent feature.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
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>
The pvrusb2 tear-down logic was clearing two timers before stopping
its internal work queue. That left a tiny window open where the work
queue might run after the timers are stopped, possibly starting them
again. This could lead to dangling pointers and an oops. Solution:
Kill the work queue first, then delete the timers.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
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>
Buffer size for printing pvrusb2 video standard strings was too small
before. This is cosmetic; the printing logic is not able to overrun a
too-short buffer.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The pvrusb2 driver dynamically generates an enumeration of support
video standard combinations based on which video standard bits are
set. ATSC modes don't fall into this since they are by nature not
analog. The pvrusb2 driver has been warning about an inability to
classify ATSC standards. This change causes the classification
algorithm to ignore any ATSC standards (such things are better handled
elsewhere anyway).
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The pvrusb2 driver has used hardcoded logic to control the LED on the
device. However this is really Hauppauge-specific behavior. This
change defines a new device attribute for LED control and sets things
up appropriately for Hauppauge devices.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Most of this originates from Michael Krufky <mkrufky@linuxtv.org>;
these changes move LED control into separate functions. This is the
first step in new work to make LED control a device-specific attribute.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The encoder is not a part of the pipeline when in digital mode, so
streaming is OK in this case even when the encoder's firmware is not
loaded. Modify the driver core handling of this scenario to permit
streaming.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This is a major pvrusb2 change. The driver core has an algorithm that
is used to cleanly sequence the changes needed to enable / disable
video streaming. The algorithm had originally been written for analog
streaming, but when in digital mode the pipeline is considerably
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Unlike analog control, control of the digital side is not nearly as
uniform among different devices. So we have to specify the correct
digital control scheme as a new device attribute.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This code is actually part of a larger set from Mike Krufky
<mkrufky@linuxtv.org>, to support ATSC streaming from within the
pvrusb2 driver. More to come...
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Call pvr2_hdw_cmd_powerdown to power down the device
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Previously the pvrusb2 driver just started with the default input to
be "television". But if the device doesn't support an analog tuner
then this default must be different. New logic here selects a
reasonable default based on the actual valid set of available inputs.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
When an enumeration control is changed, the pvrusb2 driver assumed
that the enumeration values were continuous. That is no longer true;
this change allows for properly input validation even when not all
enumeration values are legal (which can happen with input selection
based on what the hardware supports).
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Now that the pvrusb2 driver can dynamically choose which inputs to
make available depending on the hardware, the enumeration of input
choices is no longer a contiguous range of integers. Unfortunately
this causes a problem in the v4l2 implementation since the input
enumeration requires continuity in the API. This change implements a
mapping in order to preserve the v4l2 interface requirement.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The v4l2 implementation in pvru2b2 must produce a sane answer when
asked, when the input choice is set to dtv.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This follows from defining the available inputs as device attributes.
This change causes the driver to adjust its list of inputs based on
those attributes. Now, for example, the FM radio will appear as a
choice only if the hardware supports an FM radio.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Different devices support different input types. Up until now we've
really been assuming that everyone has an analog tuner, an FM radio,
composite, and s-video inputs. But as we add other devices, these
assumptions are no longer true. The way to deal with this is to
define the available inputs as additional device attributes, so that
the driver can adjust its internal behavior accordingly.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
- Static memory is always initialized with 0.
- Replaced in some cases C99 comments for /* */
Signed-off-by: Douglas Schilling Landgraf <dougsland@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
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>
Fix broken build due to patch order dependency. A future patch requires
the lines that break the current build. Disable those lines for now.
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Create a device description and enable autodetection for
Hauppauge WinTV PVR-USB2 Model 75xxx
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The pvrusb2 driver tries to keep all device specific attributes in a
single data structure in one source file. This change further cleans
up how that table is set up. We now try to group everything together
for each specific device, and the number of symbols exported from this
module has now been reduced to a single global.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
pvrusb2: When a per-device-type default video standard is declared,
handle it in such a way that it can be correctly and unambiguously
reported in the system log.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
pvrusb2: Eliminate use of volatile in pipeline control state
variables. These were all cases of paranoia; upon further review the
overall mechanism employed here should not require use of volatile.
This had originally been done out of paranoia, and I have since been
convinced that the paranoia is not required.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
pvrusb2: Remove use of volatile for command sequencer; these variables
are set by interrupt-context code and we check their state in such a
manner that there should be no race conditions. This had originally
been done out of paranoia, and I have since been convinced that the
paranoia is not required.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This adds a default video standard setting to the pvr2_device_desc
structure for describing device types. With this change it is
possible to set a reasonable default standard based on device type.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This changeset allows the pvrusb2 driver to operate a new device type
("GOTVIEW USB2.0 DVD2"). Changes amount to defining a new routing
scheme for the device and adding appropriate table entries into
pvrusb2-devattr.c.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
The pvrusb2 driver has been successfully recovering from a crashed
encoder now for over 2 years. I think it's time to reduce the
perceived severity of the warning message. While I'd still very much
like to stop these crashes, the recovery logic is solid enough that
the problem is effectively benign. No point in panicing the users
over it.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
For Hauppauge 24xxx devices, the IR receiver is a custom piece of
logic that is very specific to the device. The pvrusb2 driver can
virtualize this to make it look like a more normal IR receiver found
in other Hauppauge devices. The decision of whether or not to enable
this virtualization however is a device-specific attribute, thus this
changeset.
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>