History log of /drivers/media/video/bt8xx/bttv-driver.c
Revision Date Author Comments
e2ecb257eebd8525029f43fcb4f922c4976dba53 02-Feb-2012 Hans Verkuil <hans.verkuil@cisco.com> [media] v4l2: standardize log start/end message

For drivers that properly use the v4l2 framework (i.e. set v4l2_dev in the
video_device struct), the start and end messages of VIDIOC_LOG_STATUS are
now generated automatically. People tended to forget these, but the v4l2-ctl
tool scans for these messages, and it also makes it easier to read the status
output in the kernel log.

The cx18, ivtv and bttv drivers were changed since they no longer need to
log these start/end messages.

In saa7164 two empty log_status functions were removed.

Also added a helper function to v4l2-ctrl.c that can be used as the
vidioc_log_status callback if all you need to do is to log the current control
values. This is now used by pwc and vivi.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Steven Toth <stoth@kernellabs.com>
Cc: Andy Walls <awalls@md.metrocast.net>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
c540d9f13d1f0f6913434b0b8241bb6270818769 06-Nov-2011 Peter De Schrijver <p2@psychaos.be> [media] bt8xx: add support for PCI device ID 0x36c

add support for conexant PCI device 0x36c. Seems to be fully compatible with
the currently supported chips, yet the chip has different PCI ID.

Signed-off-by: Peter De Schrijver <p2@psychaos.be>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
8af443e581ab57a6a38f595eb40be3514ea55195 22-Aug-2011 Joe Perches <joe@perches.com> [media] bt8xx: Use current logging styles

This converts some messages that were emitted at
KERN_INFO to KERN_DEBUG. All of these messages
were guarded by bttv_debug tests.

Add pr_fmt.
Convert printks to pr_<level>
Convert printks without KERN_<level> to appropriate pr_<level>.
Removed embedded prefixes when pr_fmt was added.
Whitespace cleanups when around other conversions.
Macros coded with if statements should be do { if... } while (0)
so the macros can be used in other if tests.
Use ##__VA_ARGS__ for variadic macro as well.
Coalesce format strings.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1990d50b58bef127a647005fdcada6d07081d3ef 24-Jun-2011 Mauro Carvalho Chehab <mchehab@redhat.com> [media] Stop using linux/version.h on most video drivers

All the modified drivers didn't have any version increment since
Jan, 1 2011. Several of them didn't have any version increment
for a long time, even having new features and important bug fixes
happening.

As we're now filling the QUERYCAP version with the current Kernel
Release, we don't need to maintain a per-driver version control
anymore. So, let's just use the default.

In order to preserve the Kernel module version history, a
KERNEL_VERSION() macro were added to all modified drivers, and
the extraver number were incremented.

I opted to preserve the per-driver version control to a few
pwc, pvrusb2, s2255, s5p-fimc and sh_vou.

A few drivers are still using the legacy way to handle ioctl's.
So, we can't do such change on them, otherwise, they'll break.
Those are: uvc, et61x251 and sn9c102.

The rationale is that the per-driver version control seems to be
actively maintained on those.

Yet, I think that the better for them would be to just use the
default version numbering, instead of doing that by themselves.

While here, removed a few uneeded include linux/version.h

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
a024c1a6b274e11596d124619e43c25560f64c01 12-Jun-2011 Hans Verkuil <hans.verkuil@cisco.com> [media] bttv: fix s_tuner for radio

Fix typo: g_tuner should have been s_tuner.

Tested with a bttv card.

Cc: stable@kernel.org
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
abd34d8d6b213c792c1a06fd75488595c5fb6d3f 21-Mar-2011 Bjørn Mork <bjorn@mork.no> [media] use pci_dev->revision

pci_setup_device() has saved the PCI revision in the pci_dev
struct since Linux 2.6.23. Use it.

Cc: Auke Kok <auke-jan.h.kok@intel.com>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
b9218f2f15cdff8991ba041993bf40962c49fdd0 27-Dec-2010 Hans Verkuil <hverkuil@xs4all.nl> [media] saa6588: rename rds.h to saa6588.h

The naming of the media/rds.h header suggested that it was a generic
RDS header, when in fact it is just a saa6588 module API that is
internal to the kernel.

Rename the header and the struct and defines in it to make this clear.

Also removed the header include in radio-si470x.h (not used anymore)
and from ioctl-number.txt (it's internal to the kernel and never called
from userspace).

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
08af245de0cf6ab5f4ed008ee2bb99273774fce0 24-Dec-2010 Hans Verkuil <hverkuil@xs4all.nl> [media] V4L: remove V4L1 compatibility mode

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
b7c7a4bed8d695933ae172031556de9de30ae598 28-Nov-2010 Mauro Carvalho Chehab <mchehab@redhat.com> [media] bttv: remove custom_irq and gpioq from bttv struct

The RC5 old decoder used custom_irq to indicate the need of handling
the IRQ on a different way. Instead of doing it, let the core just call the
bttv input IRQ handler, and add the code there to call the legacy decoder.

While here, remove the gpioq waitqueue, as this is not used anywhere, and
add a debug msg to help removing the legacy RC5 code.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
707bcf326bd50c875d82bd2e7c31dcfb92b7e813 24-Dec-2010 Tejun Heo <tj@kernel.org> media/video: explicitly flush request_module work

Video drivers request submodules using a work during probe and calls
flush_scheduled_work() on exit to make sure the work is complete
before being unloaded. This patch makes these drivers flush the work
directly instead of using flush_scheduled_work().

While at it, relocate request_submodules() call in saa7134_initdev()
right right before successful return as in other drivers to avoid
failing after the work is scheduled and returning failure without the
work still active.

This is in preparation for the deprecation of flush_scheduled_work().

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
692e42df12e8427219958468301f3d03ca5f0f0d 17-Dec-2010 Brandon Philips <brandon@ifup.org> [media] bttv: remove unneeded locking comments

After Mauro's "bttv: Fix locking issues due to BKL removal code" there
are a number of comments that are no longer needed about lock ordering.
Remove them.

Signed-off-by: Brandon Philips <bphilips@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
587f0d5d6d44e3529028bf197d424f866fb2411d 15-Dec-2010 Mauro Carvalho Chehab <mchehab@infradead.org> [media] bttv: fix mutex use before init (BZ#24602)

Fix a regression where bttv driver causes oopses when loading, since it
were using some non-initialized mutexes. While it would be possible to
fix the issue, there are some other lock troubles, like to the presence of
lock code at free_btres_lock().

It is possible to fix, but the better is to just use the core-assisted
locking schema. This way, V4L2 core will serialize access to all
ioctl's/open/close/mmap/read/poll operations, avoiding to have two
processes accessing the hardware at the same time. Also, as there's just
one lock, instead of 3, there's no risk of dead locks.

The net result is a cleaner code, with just one lock.

Reported-by: Dan Carpenter <error27@gmail.com>
Reported-by: Brandon Philips<brandon@ifup.org>
Reported-by: Chris Clayton <chris2553@googlemail.com>
Reported-by: Torsten Kaiser <just.for.lkml@googlemail.com>
Tested-by: Chris Clayton <chris2553@googlemail.com>
Tested-by: Torsten Kaiser <just.for.lkml@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
451a3c24b0135bce54542009b5fde43846c7cf67 17-Nov-2010 Arnd Bergmann <arnd@arndb.de> BKL: remove extraneous #include <smp_lock.h>

The big kernel lock has been removed from all these files at some point,
leaving only the #include.

Remove this too as a cleanup.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
08bff03ed697a583612b62a6ac566bd5bce98012 20-Sep-2010 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB: videobuf: add ext_lock argument to the queue init functions

Add an ext_lock argument to the videobuf init functions. This allows
drivers to pass the vdev->lock pointer (or any other externally held lock)
to videobuf. For now all drivers just pass NULL.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
8979e9d42b87648fd89bcc5d8b3157a8f3f4dfdb 15-Sep-2010 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB: bttv: use unlocked ioctl

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
c37db91fd0d42d27141b6c49b768070df29e1c5e 15-Sep-2010 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB: bttv: fix driver lock and remove explicit calls to BKL

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
ca960bfe136844952041d2e7dc030a6d4d5c7469 18-Sep-2010 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB: bttv: Fix mutex unbalance at bttv_poll

Don't do double mutex_unlock when reading a stream at bttv_poll.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
8822f0d60b7cd550465e7d07dbe02084f5476d91 14-Sep-2010 Mauro Carvalho Chehab <mchehab@redhat.com> V4L/DVB: bttv-driver: document functions using mutex_lock

There are a few ancillary static routines used by ioctl functions
that takes bttv lock internally. As we'll be adding the same lock
for all ioctl's that need, we need to properly document them, to
avoid doing double locks

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
ffb4877ba013f94322083f77cbb05b35c2a218aa 01-May-2010 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB: v4l2-common: simplify prio utility functions

v4l2_prio_init/open/close returned an int when in fact they would
always return 0. Make these void functions.

v4l2_prio_close and v4l2_prio_check pass an enum v4l2_priority as a
pointer for no good reason. Replace with a normal enum v4l2_priority
argument.

These changes will simplify the work of moving priority handling into
the v4l core.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
530d2d32068eaf3616e0ce9e58a5fde5701c3380 01-May-2010 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB: bttv: remove bogus prio check in g_frequency

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
dab7e3106ddd6cbc3b55301228407b9d17ce7773 21-Mar-2010 Andreas Bombe <aeb@debian.org> V4L/DVB: V4L2: Replace loops for finding max buffers in VIDIOC_REQBUFS callbacks

Due to obvious copy and paste coding a number of video capture drivers
which implement a limit on the buffer memory decremented the user
supplied buffer count in a while loop until it reaches an acceptable
value.

This is a silly thing to do when the maximum value can be directly
computed.

Signed-off-by: Andreas Bombe <aeb@debian.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
5a0e3ad6af8660be21ca98a971cd00f331318c05 24-Mar-2010 Tejun Heo <tj@kernel.org> include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
d90a4ae4ae5a5e535782ab090507898e042db81a 16-Feb-2010 Jean Delvare <khali@linux-fr.org> V4L/DVB: bttv: Let the user disable IR support

Add a new module parameter "disable_ir" to disable IR support. Several
other drivers do that already, and this can be very handy for
debugging purposes.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2434466432464110b5307757e0285dd41f15512e 19-Feb-2010 Jean Delvare <khali@linux-fr.org> V4L/DVB: bttv: Move I2C IR initialization

Move I2C IR initialization from just after I2C bus setup to right
before non-I2C IR initialization. This avoids the case where an I2C IR
device is blocking audio support (at least the PV951 suffers from
this). It is also more logical to group IR support together,
regardless of the connectivity.

This fixes bug #15184:
http://bugzilla.kernel.org/show_bug.cgi?id=15184

Signed-off-by: Jean Delvare <khali@linux-fr.org>
CC: stable@kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
327ae59757f2e56fd3fc2b11acbd0a7c4070f4e8 27-Nov-2009 Laurent Pinchart <laurent.pinchart@ideasonboard.com> V4L/DVB (13557): v4l: Remove unneeded video_device::minor usage in drivers

The video_device::minor field is used where it shouldn't, either to

- test for error conditions that can't happen anymore with the current
v4l-dvb core,
- store the value in a driver private field that isn't used anymore,
- check the video device type where video_device::vfl_type should be
used, or
- create the name of a kernel thread that should get a stable name.

Remove or fix those use cases.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
46b21094cee16bc7e531d7d6cd66fb5ea05065d4 10-Dec-2009 Laurent Pinchart <laurent.pinchart@ideasonboard.com> V4L/DVB (13556): v4l: Remove unneeded video_device::minor assignments

Now that the video_device registration is tested using
video_is_registered(), drivers don't need to initialize the
video_device::minor field to -1 anymore.

Remove those unneeded assignments.

[mchehab.redhat.com: removed tm6000 changes as tm6000 is not ready yet for submission even on staging]

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
50462eb065e12f45851a9959a90d46b758944552 10-Dec-2009 Laurent Pinchart <laurent.pinchart@ideasonboard.com> V4L/DVB (13555): v4l: Use video_device_node_name() instead of the minor number

Instead of using the minor number in kernel log messages, use the device
node name as returned by the video_device_node_name() function. This
makes debug, informational and error messages easier to understand for
end users.

[mchehab.redhat.com: removed tm6000 changes as tm6000 is not ready yet for submission even on staging]

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
f0813b4c9f7ffbeaddcba1c08a1812f7ff30e1b7 27-Nov-2009 Laurent Pinchart <laurent.pinchart@ideasonboard.com> V4L/DVB (13553): v4l: Use the video_is_registered function in device drivers

Fix all device drivers to use the video_is_registered function instead
of checking video_device::minor.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
38c7c036036c6260606a2a833aaad3794ca22499 27-Nov-2009 Laurent Pinchart <laurent.pinchart@ideasonboard.com> V4L/DVB (13550): v4l: Use the new video_device_node_name function

Fix all device drivers to use the new video_device_node_name function.

This also strips kernel log messages from the "/dev/" prefix, has the device
node location is a userspace policy decision unknown to the kernel.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2de26c0a4a218a351bb1970eeaddf2905b47ff13 21-Sep-2009 Mike Isely <isely@pobox.com> V4L/DVB (13170): bttv: Fix reversed polarity error when switching video standard

The bttv driver function which handles switching of the video standard
(set_tvnorm() in bttv-driver.c) includes a check which can optionally
also reset the cropping configuration to a default value. It is
"optional" based on a comparison of the cropcap parameters of the
previous vs the newly requested video standard. The comparison is
being done with a memcmp(), a function which only returns a true value
if the comparison actually fails.

This if-statement appears to have been written to assume wrong
memcmp() semantics. That is, it was re-initializing the cropping
configuration only if the new video standard did NOT have different
cropcap values. That doesn't make any sense. One definitely should
reset things if the cropcap parameters are different - if there's any
comparison to made at all.

The effect of this problem was that a transition from, say, PAL to
NTSC would leave in place old cropping setup that made sense for the
PAL geometry but not for NTSC. If the application doesn't care about
cropping it also won't try to reset the cropping configuration,
resulting in an improperly cropped video frame. In the case I was
testing this actually caused black video frames to be displayed.

Another interesting effect of this bug is that if one does something
which does NOT change the video standard and this function is run,
then the cropping setup gets reset anyway - again because of the
backwards comparison. It turns out that just running anything which
merely opens and closes the video device node (e.g. v4l-info) will
cause this to happen. One can argue that simply opening the device
node and not doing anything to it should not mess with any of its
state - but because of this behavior, any TV app which does such
things (e.g. xawtv) probably therefore doesn't see the problem.

The solution is to fix the sense of the if-statement. It's easy to
see how this mistake could have been made given how memcmp() works.
The patch is therefore removal of a single "!" character from the
if-statement in set_tvnorm in bttv-driver.c.

Signed-off-by: Mike Isely <isely@pobox.com>
CC: stable@kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
66349b4e7ab3825dbfc167a5f0309792a587adb7 21-Sep-2009 Mike Isely <isely@pobox.com> V4L/DVB (13169): bttv: Fix potential out-of-order field processing

There is a subtle interaction in the bttv driver which can result in
fields being repeatedly processed out of order. This is a problem
specifically when running in V4L2_FIELD_ALTERNATE mode (probably the
most common case).

1. The determination of which fields are associated with which buffers
happens in videobuf, before the bttv driver gets a chance to queue the
corresponding DMA. Thus by the point when the DMA is queued for a
given buffer, the algorithm has to do the queuing based on the
buffer's already assigned field type - not based on which field is
"next" in the video stream.

2. The driver normally tries to queue both the top and bottom fields
at the same time (see bttv_irq_next_video()). It tries to sort out
top vs bottom by looking at the field type for the next 2 available
buffers and assigning them appropriately.

3. However the bttv driver *always* actually processes the top field
first. There's even an interrupt set aside for specifically
recognizing when the top field has been processed so that it can be
marked done even while the bottom field is still being DMAed.

Given all of the above, if one gets into a situation where
bttv_irq_next_video() gets entered when the first available buffer has
been pre-associated as a bottom field, then the function is going to
process the buffers out of order. That first available buffer will be
put into the bottom field slot and the buffer after that will be put
into the top field slot. Problem is, since the top field is always
processed first by the driver, then that second buffer (the one after
the first available buffer) will be the first one to be finished.
Because of the strict fifo handling of all video buffers, then that
top field won't be seen by the app until after the bottom field is
also processed. Worse still, the app will get back the
chronologically later bottom field first, *before* the top field is
received. The buffer's timestamps will even be backwards.

While not fatal to most TV apps, this behavior can subtlely degrade
userspace deinterlacing (probably will cause jitter). That's probably
why it has gone unnoticed. But it will also cause serious problems if
the app in question discards all but the latest received buffer (a
latency minimizing tactic) - causing one field to only ever be
displayed since the other is now always late. Unfortunately once you
get into this state, you're stuck this way - because having consumed
two buffers, now the next time around the "first" available buffer
will again be a bottom field and the same thing happens.

How can we get into this state? In a perfect world, where there's
always a few free buffers queued to the driver, it should be
impossible. However if something disrupts streaming, e.g. if the
userspace app can't queue free buffers fast enough for a moment due
perhaps to a CPU scheduling glitch, then the driver can get
momentarily starved and some number of fields will be dropped. That's
OK. But if an odd number of fields get dropped, then that "first"
available buffer might be the bottom field and now we're stuck...

This patch fixes that problem by deliberately only setting up a single
field for one frame if we don't get a top field as the first available
buffer. By purposely skipping the other field, then we only handle a
single buffer thus bringing things back into proper sync (i.e. top
field first) for the next frame. To do this we just drop the few
lines in bttv_irq_next_video() that attempt to set up the second
buffer when that second buffer isn't for the bottom field.

This is definitely a problem in when in V4L2_FIELD_ALTERNATE mode. In
the other modes this change either has no effect or doesn't harm
things any further anyway.

Signed-off-by: Mike Isely <isely@pobox.com>
CC: stable@kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
6a052c84342dd047226ecad0e1aa4e4b37d45a6c 20-Jun-2009 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (12214): bttv: set RDS capability if applicable.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
76e9741d1d7deb332abbbc3d8fc4c55154e2c180 05-Jul-2009 Joe Perches <joe@perches.com> V4L/DVB (12204): bttv and meye: Use PCI_VDEVICE

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2c90577841a76f1935ff3437ffb552b41f5c28fa 20-Jul-2009 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (12300): bttv: fix regression: tvaudio must be loaded before tuner

Both tvaudio and the tuner share i2c address 0x42. The tvaudio module can
check whether it really is a tda9840, but the tuner can't. So the tvaudio
module must be loaded before the tuner module. This was also the case for
2.6.29, but the order was swapped in 2.6.30.

Thanks to Krzysztof Grygiencz for reporting and testing this.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
405f55712dfe464b3240d7816cc4fe4174831be2 11-Jul-2009 Alexey Dobriyan <adobriyan@gmail.com> headers: smp_lock.h redux

* Remove smp_lock.h from files which don't need it (including some headers!)
* Add smp_lock.h to files which do need it
* Make smp_lock.h include conditional in hardirq.h
It's needed only for one kernel_locked() usage which is under CONFIG_PREEMPT

This will make hardirq.h inclusion cheaper for every PREEMPT=n config
(which includes allmodconfig/allyesconfig, BTW)

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
9fd6418a6a7655b69cfa0ae27a3639a6d0b2924f 16-Jun-2009 Figo.zhang <figo1802@gmail.com> V4L/DVB (12004): poll method lose race condition

bttv-driver.c,cx23885-video.c,cx88-video.c: poll method lose race condition for capture video.

Signed-off-by: Figo.zhang <figo1802@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
f41b6961566b2cd038ad91568882f8fc1feac160 28-May-2009 Filipe Rosset <rosset.filipe@gmail.com> V4L/DVB (11895): bt8xx: remove always false if

Remove always false if over unsigned int variable

Signed-off-by: Filipe Rosset <rosset.filipe@gmail.com>
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
6ecdf92d211fb37a905fce5d0a8668c831764abc 18-May-2009 figo.zhang <figo.zhang@kolorific.com> V4L/DVB (11853): minor have assigned value twice

The variable minor have assigned value twice, the first time is in the
initial "video_device" data struct in those drivers, pls see
saa7134-video.c,line 2503.

---

Signed-off-by: Figo.zhang <figo.zhang@kolorific.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
284901a90a9e0b812ca3f5f852cbbfb60d10249d 07-Apr-2009 Yang Hongyang <yanghy@cn.fujitsu.com> dma-mapping: replace all DMA_32BIT_MASK macro with DMA_BIT_MASK(32)

Replace all DMA_32BIT_MASK macro with DMA_BIT_MASK(32)

Signed-off-by: Yang Hongyang<yanghy@cn.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
5325b4272a53b43f55b82cc369c310c2fcacdca1 02-Apr-2009 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (11380): v4l2-subdev: change s_routing prototype

It is no longer needed to use a struct pointer as argument, since v4l2_subdev
doesn't require that ioctl-like approach anymore. Instead just pass the input,
output and config (new!) arguments directly.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
f41737ece472cd803ffb24ac9f5d6fdd1d871341 01-Apr-2009 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (11370): v4l2-subdev: move s_std from tuner to core.

s_std didn't belong in the tuner ops. Stricly speaking it should be part of
the video ops, but it is used by audio and tuner devices as well, so it is
more efficient to make it part of the core ops.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
859f0277a6c3ba59b0a5a1eb183f8f6ce661a95d 28-Mar-2009 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (11278): bttv: convert to v4l2_subdev since i2c autoprobing will disappear.

Since i2c autoprobing will disappear bttv needs to be converted to use
v4l2_subdev instead.

Without autoprobing the autoload module option has become obsolete. A warning
is generated if it is set, but it is otherwise ignored.

Since the bttv card definitions are of questionable value a new option was
introduced to allow the user to control which audio module is selected:
msp3400, tda7432 or tvaudio (or none at all).

By default bttv will use the card definitions and fallback on tvaudio as the
last resort.

If no audio device was found a warning is printed.

The saa6588 RDS device is now also explicitly probed since it is no longer
possible to autoprobe it. A new saa6588 module option was added to override
the card definition since I suspect more cards have this device than one
would guess from the card definitions.

Note that the probe addresses of the i2c modules are hardcoded in this
driver. Once all v4l drivers are converted to v4l2_subdev this will be
cleaned up. Such data belongs in an i2c driver header.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
601bc2984508e8b70a604167229f4f687eae63bb 29-Mar-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (11262): bttv: Remove buffer type check from vidioc_g_parm

The v4l2-ioctl core only allows buffer types for which the corresponding
->vidioc_try_fmt_xxx() methods are defined to be used with
vidioc_(q|dq|query)bufs(), vidioc_reqbufs() and now vidioc_(s|g)_parm.

The driver was only allowing VIDEO_CAPTURE buffers for g_parm, but since
the driver defines ->vidioc_try_fmt_vid_overlay() and
->vidioc_try_fmt_vbi_cap() it will now allow VIDEO_OVERLAY and VBI_CAPTURE
buffers as well. This should be fine as the driver only fills in the frame
rate field, which is just as valid for video overlay and vbi capture as it
is for video capture.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
74fc7bd9cec0ccdbea23659208492ec7ffc58297 14-Mar-2009 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (11046): bttv: convert to v4l2_device.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
522a5f1430bb85ca00928b99caf3892023ad9632 04-Mar-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (10815): bttv: Don't need to zero ioctl parameter fields

The v4l2 core code in v4l2_ioctl will zero out the structure the driver is
supposed to fill in for read-only ioctls. For read/write ioctls, all the
fields which aren't supplied from userspace will be zeroed out.

Zeroing code is removed from enum_input and g_tuner.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
51f0b8d57af501624ee55e8ca15d09d5bdc2b0dd 04-Mar-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (10813): v4l2: New function v4l2_video_std_frame_period

Some code was calling v4l2_video_std_construct() when all it cared about
was the frame period. So make a function that just returns that and have
v4l2_video_std_construct() use it.

At this point there are no users of v4l2_video_std_construct() left outside
of v4l2-ioctl, so it could be un-exported and made static.

Change v4l2_video_std_construct() so that it doesn't zero out the struct
v4l2_standard passed in. It's already been zeroed out in the common ioctl
code.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
4b10d3b626922ffa2387905a230b12450281a12d 29-Jan-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (10568): bttv: dynamically allocate device data

The bttv driver had static array of structures for up to 16 possible bttv
devices, even though few users have more than one or two. The structures
were quite large and this resulted in a huge BSS segment.

Change the driver to allocate the bttv device data dynamically, which
changes "struct bttv bttvs[BTTV_MAX]" to "struct bttv *bttvs[BTTV_MAX]".
It would be nice to get ride of "bttvs" entirely but there are some
complications with gpio access from the audio & mpeg drivers.

To help bttvs removal along anyway, I changed the open() methods use the
video device's drvdata to get the driver data instead of looking it up in
the bttvs array. This is also more efficient. Some WARN_ON()s are added
in cases the device node exists by the bttv device doesn't, which I don't
think should be possible.

The gpio access functions need to check if bttvs[card] is NULL now. Though
calling them on a non-existent card in the first place is wrong, but hard
to solve given the fundamental problems in how the gpio access code works.

This patch reduces the bss size by 66560 bytes on ia32. Overall change is a
reduction of 66398 bytes, as the WARN_ON()s add some 198 bytes.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
6f98700a5bb8d218162b04db1b8a3921a0dcc7ce 29-Jan-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (10567): bttv: shrink muxsel data in card database

Over half of the card database was used to store muxsel data. 64 bytes
were used to store one 32 bit word for each of up to 16 inputs.

The Bt8x8 only has two bits to control its mux, so muxsel data for 16
inputs will fit into a single 32 bit word. There were a couple cards that
had special muxsel data that didn't fit in two bits, but I cleaned them up
in earlier patches.

Unfortunately, C doesn't allow us to have an array of bit fields. This
makes initializing the structure more of a pain. But with some cpp magic,
we can do it by changing:
.muxsel = { 2, 3, 0, 1 },
.muxsel = { 2, 2, 2, 2, 3, 3, 3, 3, 1, 1 },
Into:
.muxsel = MUXSEL(2, 3, 0, 1),
.muxsel = MUXSEL(2, 2, 2, 2, 3, 3, 3, 3, 1, 1),

That's not so bad. MUXSEL is a fancy macro that packs the arguments (of
which there can be one to sixteen!) into a single word two bits at a time.
It's a compile time constant (a variadic function wouldn't be) so we can
use it to initialize the structure. It's important the the arguments to
the macro only be plain decimal integers. Stuff like "0x01", "(2)", or
"MUX3" won't work properly.

I also created an accessor function, bttv_muxsel(btv, input), that gets the
mux bits for the selected input. It makes it cleaner to change the way the
muxsel data is stored.

This patch doesn't change the code size and decreases the datasegment by
9440 bytes.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
5221e21e5ecd3aebd2e8e3234bd18883ce720945 29-Jan-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (10562): bttv: rework the way digital inputs are indicated

The code was using a muxsel value of -1U to indicate a digital input. A
couple places in were checking of muxsel < 0 to detect this, which doesn't
work of course because muxsel is unsigned and can't be negative.

Only a couple cards had digital inputs and it was always the last one, so
for the card database create a one bit field that indicates the last input
is digital. On init, this is used to set a new field in the bttv struct to
the digital input's number or UNSET for none. This makes it easier to
check if the current input is digital.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
abb0362f49c361f71b5aa6d244d4847145ed53c1 29-Jan-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (10560): bttv: make tuner card info more consistent

The bttv card database structure had a "tuner" field that was the input
number of the tuner input or UNSET for no tuner. However, the only values
it could ever be are 0 and UNSET. Having a tuner on an input other than 0
didn't work and was never used.

There is also a "tuner_type" field that can be set to TUNER_ABSENT to
indicate no tuner, which makes "tuner = UNSET" redundant. In many cases,
tuner_type was set to UNSET when there was no tuner, which isn't quite
correct. tuner_type == UNSET is supposed to mean the tuner type isn't yet
known.

So, I changed cards where "tuner == UNSET" to always have tuner_type of
TUNER_ABSENT. At this point the tuner field is redundant, so I deleted it.

I have the card setup code set the card's tuner_type (not the card type's
tuner_type!) to TUNER_ABSENT if it hasn't yet been set at the end of the
setup code. Various places that check if the card has a tuner will now
look for this instead of checking the card type's "tuner" field.

Also autoload the tuner module before issuing the TUNER_SET_TYPE_ADDR I2C
client call instead of after issuing it.

Overall, on ia32 this decreases compiled code size by about 24 bytes and
reduces the data size by 640 bytes.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
72134a6d5199c3f5c8efe914e49072bde95948b3 29-Jan-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (10559): bttv: Fix TDA9880 norm setting code

The code to set the norm for the TDA9880 analog demod was comparing
btv->norm, an index into the bttv driver's norm array, to V4L2_STD_NTSC,
which is a bit flag that's part of the V4L2 API. This doesn't work of
course and results in the PAL path always being taken.

What's more, it modified the bttv_tvcards[] entries for cards using the
TDA9880. This is wrong because changing the norm on one card will also
affect other cards of the same type. Writing to bttv_tvcards is also bad
because it should be read-only or even devinitdata.

Changing the norm would also cause the audio to become unmuted.

Have the code get called for both norm setting and audio input setting
(which where the gpios are set) to avoid needed to modify bttv_tvcards.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
4ef2ccc2611456667ea78c6f418ce87e1fa9fac5 29-Jan-2009 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (10558): bttv: norm value should be unsigned

The norm value in the driver is an index into an array and the the driver
doesn't allow it to be negative or otherwise invalid. It should be
unsigned but wasn't in all places.

Fix some structs and functions to have the norm be unsigned. Get rid of
useless checks for "< 0". Most of the driver code can't handle a norm
value that's out of range, so change some ">= BTTV_TVNORMS" checks to
BUG_ON(). There's no point in silently ignoring invalid driver state just
to crash because of it later.

Reported-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
b15dd79ea06b04a7ecee95f62ce7b6a3547dbb0a 02-Jan-2009 Udo Steinberg <udo@hypervisor.org> V4L/DVB (10173): Missing v4l2_prio_close in radio_release

The radio_release function of the BTTV driver is missing a call to
v4l2_prio_close. As a result, after the radio device has been opened at
least once (e.g., by HAL during bootup), v4l2_priority will never drop below
V4L2_PRIORITY_INTERACTIVE again. With the following patch against 2.6.28,
applications that run with V4L2_PRIORITY_BACKGROUND are able to open devices
again. Previous Linux versions are affected as well.

Signed-off-by: Udo Steinberg <udo@hypervisor.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
aecde8b53b8ee1330a5a8206200f0d6b8845a6e0 30-Dec-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (10141): v4l2: debugging API changed to match against driver name instead of ID.

Since the i2c driver ID will be removed in the near future we have to
modify the v4l2 debugging API to use the driver name instead of driver ID.

Note that this API is not used in applications other than v4l2-dbg.cpp
as it is for debugging and testing only.

Should anyone use the old VIDIOC_G_CHIP_IDENT, then this will be logged
with a warning that it is deprecated and will be removed in 2.6.30.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
bec43661b1dc0075b7445223ba775674133b164d 30-Dec-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (10135): v4l2: introduce v4l2_file_operations.

Introduce a struct v4l2_file_operations for v4l2 drivers.

Remove the unnecessary inode argument.

Move compat32 handling (and llseek) into the v4l2-dev core: this is now
handled in the v4l2 core and no longer in the drivers themselves.

Note that this changeset reverts an earlier patch that changed the return
type of__video_ioctl2 from int to long. This change will be reinstated
later in a much improved version.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
c6330fb86fd0fed98b7e0d5792881a77b778fefc 19-Oct-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (9327): v4l: use video_device.num instead of minor in video%d

The kernel number of a v4l2 node (e.g. videoX, radioX or vbiX) is now
independent of the minor number. So instead of using the minor field
of the video_device struct one has to use the num field: this always
contains the kernel number of the device node.

I forgot about this when I did the v4l2 core change, so this patch
converts all drivers that use it in one go. Luckily the change is
trivial.

Cc: michael@mihu.de
Cc: mchehab@infradead.org
Cc: corbet@lwn.net
Cc: luca.risolia@studio.unibo.it
Cc: isely@pobox.com
Cc: pe1rxq@amsat.org
Cc: royale@zerezo.com
Cc: mkrufky@linuxtv.org
Cc: stoth@linuxtv.org
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
3c7b933bea2ee380d54b57b99dee42b1726a4eaa 03-Oct-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (9160): v4l: remove vidioc_enum_fmt_vbi_cap

Remove the vidioc_enum_fmt_vbi_cap ops: it was scheduled for removal in
2.6.28 since the v4l2 specification says that V4L2_BUF_TYPE_VBI_CAPTURE should
not support VIDIOC_ENUM_FMT. It's also pretty pointless.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
176c2f34157a8d8b252c8f0bc242457c971b06a1 07-Sep-2008 Jean Delvare <khali@linux-fr.org> V4L/DVB (8956): bttv: Turn video_nr, vbi_nr and radio_nr into arrays

With video_nr, vbi_nr and radio_nr being simple integers, it is not
possible to use these parameters on a system with multiple bttv
adapters (which happens to be my case.) video_register_device() will
always fail on the second and later adapters. Turn these parameters
into arrays, as many other V4L drivers are already doing, so that they
can be used on such systems.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
eb1b27bd86db6f9f73d6db973b18f31790a3d410 30-Aug-2008 Jean Delvare <khali@linux-fr.org> V4L/DVB (8879): bttv: Don't unmask VPRES interrupt

When the input is set to tuner and no antenna is connected, the BT848
can flood VPRES interrupts. So we don't want to enable this type of
interrupts when the input it set to tuner.

As we don't do anything when receiving such an interrupt anyway, the
easiest fix is to simply not unmask this specific interrupt.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
b46a9c8b7a8a77f28773816fd2afa1186743457d 05-Aug-2008 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (8627): Fix mute on bttv driver

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
d56dc61265d2527a63ab5b0f03199a43cd89ca36 30-Jul-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (8613): v4l: move BKL down to the driver level.

The BKL is now moved from the video_open function in v4l2-dev.c to the
various drivers. It seems about a third of the drivers already has a
lock of some sort protecting the open(), another third uses
video_exclusive_open (yuck!) and the last third required adding the
BKL in their open function.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
c37396c19403e249f12626187d51e92c915f2bc9 07-Sep-2008 Jean Delvare <khali@linux-fr.org> V4L/DVB (8955): bttv: Prevent NULL pointer dereference in radio_open

Fix the following crash in the bttv driver:

BUG: unable to handle kernel NULL pointer dereference at 000000000000036c
IP: [<ffffffffa037860a>] radio_open+0x3a/0x170 [bttv]

This happens because radio_open assumes that all present bttv devices
have a radio function. If a bttv device without radio and one with
radio are installed on the same system, and the one without radio is
registered first, then radio_open checks for the radio device number
of a bttv device that has no radio function, and this breaks. All we
have to do to fix it is to skip bttv devices without a radio function.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
c6eb8eafdba4ad18b4520a0d28a38bc9e61883ea 03-Sep-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (8757): v4l-dvb: fix a bunch of sparse warnings

Fixed a lot of sparse warnings: mostly warnings about shadowed variables
and signed/unsigned mismatches.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
0ea6bc8d43c9ee3c5384bea184eab020927a5b2c 26-Jul-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (8523): v4l2-dev: remove unused type and type2 field from video_device

The type and type2 fields were unused and so could be removed.
Instead add a vfl_type field that contains the type of the video
device.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
a399810ca69d9d4bd30ab8c1678c7439e567f90b 21-Jul-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (8482): videodev: move all ioctl callbacks to a new v4l2_ioctl_ops struct

All ioctl callbacks are now stored in a new v4l2_ioctl_ops struct. Drivers fill in
a const struct v4l2_ioctl_ops and video_device just contains a const pointer to it.

This ensures a clean separation between the const ops struct and the non-const
video_device struct.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
35ea11ff84719b1bfab2909903a9640a86552fd1 20-Jul-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (8430): videodev: move some functions from v4l2-dev.h to v4l2-common.h or v4l2-ioctl.h

The functions in a header should not belong to another module. The prio functions
belong to v4l2-common.c, so move them to v4l2-common.h.

The ioctl functions belong to v4l2-ioctl.c, so create a new v4l2-ioctl.h header
and move those functions to it.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
22a04f106346c3af019135f2de3cabf9ac41c3ba 20-Jul-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (8429): videodev: renamed 'class_dev' to 'dev'

The class_dev field is a normal device, not a class device. This is very
confusing and now that the old 'dev' field has been renamed to 'parent'
we can rename 'class_dev' to just 'dev'.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
5e85e732f0ed56aa97a3ba26ac2b93ffe597a208 20-Jul-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (8428): videodev: rename 'dev' to 'parent'

The field 'dev' is not the video device, but the parent of the video device.
Rename accordingly.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
3aa7110e1c415c38c42ef77be0ef2c7a888b9e16 22-Jun-2008 Al Viro <viro@ftp.linux.org.uk> V4L/DVB (8132): bt8xx endianness annotations and fixes

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
1d0a436256dc1aecfad901bcd4432dac1cabe6b2 23-Jun-2008 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (8110): bttv: allow debug ioctl's

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
78b526a43561d7e5e702ba27948e422dfbc4bea1 28-May-2008 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (7949): videodev: renamed the vidioc_*_fmt_* callbacks

The naming for the callbacks that handle the VIDIOC_ENUM_FMT and
VIDIOC_S/G/TRY_FMT ioctls was very confusing. Renamed it to match
the v4l2_buf_type name.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
81b2dbcad86732ffc02bad87aa25c4651199fc77 20-May-2008 Arjan van de Ven <arjan@linux.intel.com> Fix a deadlock in the bttv driver

vidiocgmbuf() does this:
mutex_lock(&fh->cap.vb_lock);
retval = videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize,
V4L2_MEMORY_MMAP);

and videobuf_mmap_setup() then just does
mutex_lock(&q->vb_lock);
ret = __videobuf_mmap_setup(q, bcount, bsize, memory);
mutex_unlock(&q->vb_lock);

which is an obvious double-take deadlock.

This patch fixes this by having vidiocgmbuf() just call the
__videobuf_mmap_setup function instead.

Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Reported-by: Koos Vriezen <koos.vriezen@gmail.com>
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
b9bc07a006ae94d7b3dd5db873bcf10ceb749253 10-Apr-2008 Robert Fitzsimons <robfitz@273k.net> V4L/DVB (7579): bttv: Fix memory leak in radio_release

Fix the leak of the bttv_fh structure allocated in radio_open which
was introduced by commit 5cd3955cb8adfc1edf481e9e1cb2289db50ccacb.

Signed-off-by: Robert Fitzsimons <robfitz@273k.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
d69b2e41a5f6d934d01cc62f314697a60356b466 02-Apr-2008 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (7462): bttv: Fix some API non-compliances for some audio/input V4L2 calls

Thanks to Cyrill Gorcunov <gorcunov@gmail.com> for pointing this
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
0705135e59f8503e4dade4b3580fed77b1743b7c 22-Apr-2008 Guennadi Liakhovetski <g.liakhovetski@pengutronix.de> V4L/DVB (7237): Convert videobuf-dma-sg to generic DMA API

videobuf-dma-sg does not need to depend on PCI. Switch it to using generic
DMA API, convert all affected drivers, relax Kconfig restriction, improve
compile-time type checking, fix some Coding Style violations while at it.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
1a002ebf60c011ed6574b8e3ed9aa85f1ead6a95 01-Apr-2008 Cyrill Gorcunov <gorcunov@gmail.com> V4L/DVB (7461): bttv: fix missed index check

We should check for proper index first

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
c137918978889fa4711d286e0a8ca3d93fdcb991 01-Apr-2008 Robert Fitzsimons <robfitz@273k.net> V4L/DVB (7400): bttv: Add a radio compat_ioctl file operation

Signed-off-by: Robert Fitzsimons <robfitz@273k.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
1b0690134ec5dafb523a951a8756bb8735382fec 01-Apr-2008 Robert Fitzsimons <robfitz@273k.net> V4L/DVB (7278): bttv: Re-enable radio tuner support for VIDIOCGFREQ/VIDIOCSFREQ ioctls

Signed-off-by: Robert Fitzsimons <robfitz@273k.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
5cd3955cb8adfc1edf481e9e1cb2289db50ccacb 01-Apr-2008 Robert Fitzsimons <robfitz@273k.net> V4L/DVB (7277): bttv: Re-enabling radio support requires the use of struct bttv_fh

A number of the radio tuner ioctl functions are shared with the TV
tuner, these functions require a struct bttv_fh data structure to be
allocated and initialized.

Signed-off-by: Robert Fitzsimons <robfitz@273k.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
e8d35932e9942dffcc96c03f539d7e261d641bfd 23-Feb-2008 Harvey Harrison <harvey.harrison@gmail.com> V4L/DVB (7236): bttv: struct member initialized twice

fixes sparse warning:
drivers/media/video/bt8xx/bttv-driver.c:3391:3: warning: Initializer entry defined twice
drivers/media/video/bt8xx/bttv-driver.c:3392:3: also defined here

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
7c018804c0900e7be18507f1eb24e631aa9816ea 13-Feb-2008 Robert Fitzsimons <robfitz@273k.net> V4L/DVB (7197): bttv: Fix overlay divide error

The initial work to convert the bttv driver to V4L2 "Partial conversion
from V4L1 to V4L2" (e84619b17440ccca4e4db7583d126c4189b987e5), missed
the line which set the appropriate overlay crop structure in the newly
allocated bttv_buffer. This then causes a divide error in the
bttv_calc_geo function.

Signed-off-by: Robert Fitzsimons <robfitz@273k.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
64f9477f95bf5d4ba49dc3988d47a15bc06bb5da 31-Jan-2008 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (7121): Renames videobuf lock to vb_lock

This helps to identify where vb_lock is being used, and find missusages of the
locks.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
438468359e1db16a7d1925fc4f2519a044bbf7dd 14-Jan-2008 Zoltan Devai <zdevai@gmail.com> V4L/DVB (7037): Fix build breakage of the bttv driver, when advanced debugging is not enabled

Signed-off-by: Zoltan Devai <zdevai@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
9134be0376e7527afa4f2574253ff02ca80d5b47 28-Dec-2007 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (6914): Fix a few issues at the bttv conversion

bttv driver is working as previously. An additional gain of about 1,5Kb were
obtained with the driver conversion to vidioc_ioctl2:

text data bss dec hex filename
89208 40244 57556 187008 2da80 old/bttv.ko
88960 38740 57556 185256 2d3a8 new/bttv.ko

(measured on a x86_64)

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
04a94d3ca25030d7c1fa27f3db3b90eb5a7985b0 28-Dec-2007 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (6913): Preserve the previous order to make easier to check the conversion

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
e5ae3db461f2de1f4fb455bc73c059c0b97b1230 28-Dec-2007 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (6912): Replace vidioc_ to bttv_

Since there are a few vidioc_ functions that were exported, rename those
functions to bttv_ in order to avoid poluting namespace.

The other functions were also renamed, to standardize inside the driver.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
402aa76aa5e57801b4db5ccf8c7beea9f580bb1b 28-Dec-2007 Douglas Schilling Landgraf <dougsland@gmail.com> V4L/DVB (6911): Converted bttv to use video_ioctl2

Signed-off-by: Douglas Schilling Landgraf <dougsland@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
9e7e85ebaeba22979209268423f5aae8a352df4c 17-Dec-2007 Akinobu Mita <akinobu.mita@gmail.com> V4L/DVB (6848): bttv: check pci_register_driver() error

Check pci_register_driver() error in module_init.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
0fc0686e64d21a6abded96af2b1a895dfa8b2530 07-Nov-2007 Brandon Philips <brandon@ifup.org> V4L/DVB (6600): V4L: videobuf: don't chew up namespace STATE_.*, convert to VIDEOBUF_

s/STATE_NEEDS_INIT/VIDEOBUF_NEEDS_INIT/g
s/STATE_PREPARED/VIDEOBUF_PREPARED/g
s/STATE_QUEUED/VIDEOBUF_QUEUED/g
s/STATE_ACTIVE/VIDEOBUF_ACTIVE/g
s/STATE_DONE/VIDEOBUF_DONE/g
s/STATE_ERROR/VIDEOBUF_ERROR/g
s/STATE_IDLE/VIDEOBUF_IDLE/g

Signed-off-by: Brandon Philips <bphilips@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
4b9b936f278163614543d66f8e8c93d5484dd148 25-Aug-2006 Nickolay V. Shmyrev <nshmyrev@yandex.ru> V4L/DVB (6416): Split hooks on volume and audio mode and rework their handling

Also convert audio_mode_gpio functions from audio_hook

Signed-off-by: Nickolay V. Shmyrev <nshmyrev@yandex.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
40c6e683a238c561db00c4fdfead43cb3b19d75f 26-Oct-2007 Nickolay V. Shmyrev <nshmyrev@yandex.ru> V4L/DVB (6415): Restructurize volume hook and drop unused mute hook

Signed-off-by: Nickolay V. Shmyrev <nshmyrev@yandex.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
de5bec6bb57e88db7efa49c6f7de0794ae67d06a 26-Oct-2007 Nickolay V. Shmyrev <nshmyrev@yandex.ru> V4L/DVB (6414): Remove bass, treble and balance from audio hook since they are unused

Signed-off-by: Nickolay V. Shmyrev <nshmyrev@yandex.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
5b261016f04eb5df1e1e652794f1f4d7dd072566 25-Aug-2006 Nickolay V. Shmyrev <nshmyrev@yandex.ru> V4L/DVB (6413): Forward VIDIOCGAUDIO and VIDIOCSAUDIO through v4l1-compat

Signed-off-by: Nickolay V. Shmyrev <nshmyrev@yandex.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
c96dd0710685a0932c16ecc351621af3fe0cb2c7 26-Oct-2007 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (6411): remove V4L1 from being compiled when V4L2 only is selected

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
e84619b17440ccca4e4db7583d126c4189b987e5 26-Oct-2007 Nickolay V. Shmyrev <nshmyrev@yandex.ru> V4L/DVB (6410): Partial conversion from V4L1 to V4L2

This is part of the old V4L1->V4L2 bttv patch, ported to current tree
by Mauro Carvalho Chehab <mchehab@infradead.org>

Signed-off-by: Nickolay V. Shmyrev <nshmyrev@yandex.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
302f61ad5db0e6a4c265e1f6454c102e2283a926 26-Oct-2007 Nickolay V. Shmyrev <nshmyrev@yandex.ru> V4L/DVB (6409): Cleanup: removed i2c_vidiocschan

This is part of the old V4L1->V4L2 bttv patch, ported to current tree
by Mauro Carvalho Chehab <mchehab@infradead.org>

Signed-off-by: Nickolay V. Shmyrev <nshmyrev@yandex.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
d9030f573031244dcffee026cc5e7e2f96f972ce 06-Jan-2008 Gregor Jasny <gjasny@web.de> V4L/DVB (6944a): Fix Regression VIDIOCGMBUF ioctl hangs on bttv driver

Fix bttv VIDIOCGMBUF locking like done in commit
820eacd84cff23b76693f4be1e28feb672f4488f.

Signed-off-by: Gregor Jasny <gjasny@web.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
7d44e8921851f460bcacb3ade432a4f5ada20fb6 11-Dec-2007 Adrian Bunk <bunk@kernel.org> V4L/DVB (6797): bt8xx/ section fixes

This patch fixes the following section mismatch with CONFIG_HOTPLUG=n:

<-- snip -->

...
...

<-- snip -->

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
053fcb6014eef31c2674d344c704118e0ac229ef 14-Nov-2007 Brandon Philips <brandon@ifup.org> V4L/DVB (6602): V4L: Convert videobuf drivers to videobuf_stop

Drivers were using cookie cutter code for stopping the read/stream. Use the
new videobuf_stop function which is lock safe.

Signed-off-by: Brandon Philips <bphilips@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
a8ab68bffe3fe7b8e9ff963ea321d283fc77ac5f 22-Oct-2007 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (6392): bttv: Update initial image size when set via V4L1 VIDIOCMCAPTURE

The V4L1 spec says that the image size should be with with VIDIOCSWIN before
requesting buffers with VIDIOCGMBUF and capturing into them with
VIDIOCMCAPTURE.

But it seems that many apps don't do this. They set the size using the fields
in the VIDIOCMCAPTURE ioctl. The driver doesn't know what size to capture
until it actually starts to capture. In particular, it doesn't know what size
to capture until it has already mmap the captured buffers. Which is quite
stupid. Why V4L1 has size and format fields for VIDIOCMCAPTURE I have no idea.

Many drivers don't support this, including those using v4l1-compat.

The bttv does, which is probably the only reason such broken software is so
prevalent.

But, the driver doesn't adjust its idea of what size is being captured when it
is set this way. If you try to query the driver's current setting with
v4l2-ctl, it won't be correct.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
35378434e739ac869d0146a47133a0f9d6fd2ee8 22-Oct-2007 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (6391): bttv: SPICT ioctl doesn't work with vlc

The bttv driver instists that the depth specified in the call to VIDIOCSPICT
match the pixel format specified in the same call.

vlc doesn't set the depth field, which makes the SPICT ioctl always fail.

The V4L1 standard is not clear on how most operation are supposed to work, and
this is no exception. The depth field would appear to be entirely redundant,
as the pixel format specifies a specific depth. It could be that this field
was only meant for output from the *G*PICT ioctl and should be ignored in
*S*PICT. This is in fact what the v4l1-compat wrapper does.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
22c4a4e98ece0eaff13b3d0ac73c5283013eb6b1 15-Oct-2007 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (6320): v4l core: remove the unused .hardware V4L1 field

struct video_device used to define a .hardware field. While
initialized on severl drivers, this field is never used inside V4L.
However, drivers using it need to include the old V4L1 header.

This seems to cause compilation troubles with some random configs.
Better just to remove it from all drivers.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
49ee718ef51f4d938f80f67207e1bfa2a38897a4 05-Oct-2007 Brandon Philips <bphilips@suse.de> V4L/DVB (6305): V4L: videobuf-core.c avoid NULL dereferences in videobuf-core

The return value of videobuf_alloc() is unchecked but this function will
return NULL on an error. Check for NULL and make videobuf_reqbufs()
return the number of successfully allocated buffers.

Also, fix saa7146_video.c and bttv-driver.c to use this returned
buffer count.

Tested against the vivi driver. Not tested against saa7146 or bt8xx
devices.

Signed-off-by: Brandon Philips <bphilips@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
54bd5b66c87d14e250f108aad1228b905d6882f6 08-Oct-2007 Kay Sievers <kay.sievers@vrfy.org> V4L/DVB (6293): V4L: convert struct class_device to struct device

The currently used "struct class_device" will be removed from the
kernel. Here is a patch that converts all users in drivers/media/video/
to struct device.

Reviewed-by: Thierry Merle <thierry.merle@free.fr>
Reviewed-by: Mike Isely <isely@pobox.com>
Reviewed-by: Luca Risolia <luca.risolia@studio.unibo.it>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
c1accaa21bdef38ec0f36eaaf7ce3384fff9d0c5 23-Aug-2007 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (6252): Adapt drivers to use the newer videobuf modules

PCI-dependent videobuf_foo methods were renamed as videobuf_pci_foo.

Also, videobuf_dmabuf is now part of videobuf-dma-sg private struct.
So, to access it, a subroutine call is needed.

This patch renames all occurences of those function calls to be
consistent with the video-buf split.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
http://thread.gmane.org/gmane.comp.video.video4linux/34978/focus=34981
Reviewed-by: Ricardo Cerqueira <v4l@cerqueira.org>
9c12224a607a4b22ab86784e3394b52810b9507c 21-Aug-2007 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (6079): Cleanup: remove linux/moduleparam.h from drivers/media files

Since at least kernel 2.6.12-rc2, module.h includes moduleparm.h. This
patch removes all occurences of moduleparm.h from drivers/media files.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
55c0d1005a0e5f590f71f918e49bdc81362f93a6 29-Jun-2007 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (5807): Bttv: Add support for DBG_[SG]_REGISTER ioctls

Adds the advanced debugging register read/write ioctl support to the bttv
driver.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
434b25263a236c9dd980617d69863ba0eff8c744 25-Jun-2007 Wade Berrier <wberrier@gmail.com> V4L/DVB (5785): Revisited: 3dfx Voodoo TV 200 (US)

Fix support for 3dfx Voodoo TV 200 variant

Signed-off-by: Wade Berrier <wberrier@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
333408f21590d50397f3004e3f87070fa8f52c51 03-Jul-2007 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (5808): Bttv: fix v4l1 breaking the driver

If one uses a V4L *one* application, such as vlc or mplayer's v4l driver, as
the first user after the driver is loaded, the driver wedges itself and will
never capture properly. Even if one uses a V4L2 application later, it still
won't work.

If one uses a V4L *two* application first, such as tvtime or mplayer's v4l2
driver, then the driver will be ok. One can then run a V4L1 application, and
it will work.

It turns out the problem is with norm changing and the crop support that was
added in 2.6.21. The driver defaults to PAL, and keeps the last norm it was
set too across opens. If one changes the norm via V4L1, the cropping
parameters are not reset like they should be, and they'll remain broken across
device opens.

This patch removes the direct setting of btv->tvnorm in the V4L1 ioctl
VIDIOCSCHAN handler. The norm is set via the existing call to set_input(),
which calls set_tvnorm(), which will reset the cropping values now that it is
able to detect the norm change.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
f992a497c71981e215b1415759fc13593ed2919f 24-Mar-2007 Jarod Wilson <jwilson@redhat.com> V4L/DVB (5482): Bttv: automatically load dvb-bt8xx for bttv cards with dvb

This patch causes the bttv driver to automatically load the dvb-bt8xx module
for bttv/dvb hybrid cards. Successfully tested with a pcHDTV HD-2000 card.
This patch is based on the recent patches to enable autoloading of cx88-dvb,
cx88-blackbird and saa7134-dvb.

Signed-off-by: Jarod Wilson <jwilson@redhat.com>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
feaba7a96dd02f2fc0d1fe5c2148d79444db0717 26-Jan-2007 Michael Schimek <mschimek@gmx.at> V4L/DVB (5156): Fix: dma free is being called with wrong arguments

Functions buffer_release() in bttv-driver.c and
vbi_buffer_release() in bttv-vbi.c are ending with:
bttv_dma_free(&fh->cap,fh->btv,buf);

For vbi it seems to be wrong. Both functions should end with:

bttv_dma_free(q,fh->btv,buf);
Thanks to Peter Schlaf <peter.schlaf@web.de> for pointing this.

Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
e5bd0260e7d3d806e66c12859f50733dca43bbcf 18-Jan-2007 Michael Schimek <mschimek@gmx.at> V4L/DVB (5077): Bttv cropping support

Adds the missing VIDIOC_CROPCAP, G_CROP and S_CROP ioctls, permitting
applications to capture or overlay a subsection of the picture or to
extend the capture window beyond active video, into the VBI area and the
horizontal blanking. VBI capturing can start and end on any line,
including the picture area, and apps can capture different lines of each
field and single fields.
For compatibility with existing applications, the open() function
resets the cropping and VBI capturing parameters and a VIDIOC_S_CROP
call is necessary to actually enable cropping.
Regrettably in PAL-M, PAL-N, PAL-Nc and NTSC-JP mode the maximum image
width will increase from 640 and 768 to 747 and 923 pixels respectively.
Like the VBI changes however, this should only affect applications which
depend on former driver limitations, such as never getting more than 640
pixels regardless of the requested width.
Also, new freedoms require additional checks for conflicts and some
applications may not expect an EBUSY error from the VIDIOC_QBUF and
VIDIOCMCAPTURE ioctls. These errors should be rare though.
So far, the patch has been tested on a UP machine with a bt878 in PAL-
BGHI and NTSC-M mode using xawtv, tvtime, mplayer/mencoder, zapping/
libzvbi and these tools: http://zapping.sf.net/bttv-crop-test.tar.bz2
I'd be grateful about comments or bug reports.

Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
fa027c2a0a0d6d1df6b29ee99048502c93da0dd4 12-Feb-2007 Arjan van de Ven <arjan@linux.intel.com> [PATCH] mark struct file_operations const 4

Many struct file_operations in the kernel can be "const". Marking them const
moves these to the .rodata section, which avoids false sharing with potential
dirty data. In addition it'll catch accidental writes at compile time to
these shared resources.

[akpm@sdl.org: dvb fix]
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
5f1693fe82b499a3306993020ef14011ed0420d0 20-Dec-2006 Akinobu Mita <akinobu.mita@gmail.com> V4L/DVB (4997): Bttv: delete duplicated ioremap()

ioremap() is called twice to same resource.
The returen value of first one is not error-checked.
second one is complely ignored.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
5d9d171aaed2e0b1c5caac96efd4d4150eec97e1 14-Nov-2006 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (4825): FIX bug 5760: audio were not working on some bttv drivers

This fixes a bug introduced by the -git commit:
bbf7871e1cd58b89f77b1152f457250c6e94b614

It seems that some bttv apps can't work fine when audioset=0.
Thanks to Christian Casteyde <casteyde.christian@free.fr> for pointing this.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
7d12e780e003f93433d49ce78cfedf4b4c52adc5 05-Oct-2006 David Howells <dhowells@redhat.com> IRQ: Maintain regs pointer globally rather than passing to IRQ handlers

Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.

The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).

Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.

Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.

I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.

This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:

struct pt_regs *old_regs = set_irq_regs(regs);

And put the old one back at the end:

set_irq_regs(old_regs);

Don't pass regs through to generic_handle_irq() or __do_IRQ().

In timer_interrupt(), this sort of change will be necessary:

- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);

I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().

Some notes on the interrupt handling in the drivers:

(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.

(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.

(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.

Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
17bc98a41ae0ef82bab502ec1f9224ec5fcbe764 13-Aug-2006 Alexey Dobriyan <adobriyan@gmail.com> V4L/DVB (4499): CONFIG_PM=n slim: drivers/media/video/*

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
a2b9e3e74a8edbc4a9d266cc54cd30266215fbdf 08-Aug-2006 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (4490): Whitespace cleanup

from whitespace cleaning script

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
3702627899db1d6a818c6e0b4ba5205f94bfbef4 06-Aug-2006 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (4474): On some cases, depth were not returned.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
d94fc9a08e51432d0d5fc0f74a4f705d7b49c251 29-Jul-2006 Trent Piepho <xyzzy@speakeasy.org> V4L/DVB (4368): Bttv: use class_device_create_file and handle errors

Revert bttv-driver.c from video_device_create_file() to use
class_device_create_file() again. video_device_create_file() is only
available when V4L1 is on.
Proper error checking is added for failure of class_device_create_file().
Will print error message and unroll partially created sysfs entries.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
3117beec7e43f91ce156cacf033a712c7e22737d 19-Jul-2006 Michael Krufky <mkrufky@linuxtv.org> V4L/DVB (4316): Check __must_check warnings


Check __must_check warnings for class_device_register and class_device_create_file

video_device_create_file was declared as a void, but instead should
return the int value of class_device_create_file.

Move the check from bttv-driver.c into v4l2-dev.h, because all other
callers of video_device_create_file must also be checked.

Replace the call to class_device_create_file in videodev.c with
video_device_create_file, as defined in v4l2-dev.h, so that the
return value of class_device_create_file will be checked.

Check the return value of class_device_register in videodev.c and
pvrusb2-sysfs.c

Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
c526e224e4075eff788a992f59bc4a9006b12923 15-Jul-2006 Randy Dunlap <rdunlap@xenotime.net> V4L/DVB (4298): Check all __must_check warnings in bttv.

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
8076fe32a7db9a6628589ffa372808e4ba25d222 02-Jul-2006 Thomas Gleixner <tglx@linutronix.de> [PATCH] irq-flags: media: Use the new IRQF_ constants

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
228aef63d9a5f4ddc9cc9213215e789f35f2cd00 13-Jun-2006 Greg Kroah-Hartman <gregkh@suse.de> [PATCH] 64bit resource: fix up printks for resources in video drivers

This is needed if we wish to change the size of the resource structures.

Based on an original patch from Vivek Goyal <vgoyal@in.ibm.com>

Cc: Vivek Goyal <vgoyal@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
07151724a35e8e70f1aa64ce30a5a3f5c1ad49a3 01-Apr-2006 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (3702): Make msp3400 routing defines more consistent

Renamed various msp3400 routing defines to be more consistent and less
confusing. Esp. the MSP_DSP_OUT defines were confusing since it is really
a DSP input.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
3bbe5a83996c0a669250d91421eef054f3a30595 01-Apr-2006 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (3697): More msp3400 and bttv fixes

- remove obsolete VIDIOC_S_INPUT i2c call in bttv
- translate VIDIOCSFREQ to VIDIOC_S_FREQUENCY in i2c call
- improve muting during carrier scan in msp3400
- don't start scan unless really needed.
- no longer reset chip for msp3400c/d.
- remove v4l2 check in tuner-core (radio stops after using the TV)
- add missing VIDIOC_INT_ strings in v4l2-common.c

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
0020d3ef915fc01a0184bc96eeb3c240bded5d8e 31-Mar-2006 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (3693): Fix msp3400c and bttv stereo/mono/bilingual detection/handling

- msp3400c did not detect the second carrier, thus being always mono.
- properly mute the msp3400c while detecting the carrier.
- fix checks on the presence of scart2/3 inputs and scart 2 output.
- implement proper audio mode fallbacks for msp3400c/d, identical to the
way msp3400g works.
- MODE_STEREO no longer produces dual languages when set for a bilingual
transmission, instead it falls back to LANG1. Use LANG1_LANG2 to hear
both languages of a bilingual transmission. This is much more intuitive
for the user and is in accordance with the preferred usage in the v4l2
specification.
- bttv tried to implement v4l2 calls with v4l1 calls to the i2c devices,
completely mangling the audmode/rxsubchans handling. v4l2 calls now do
v4l2 calls to the i2c devices.
- fixed broken i2c_vidiocschan in bttv.
- add start/end lines to LOG_STATUS.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
301e22d69140898eddd38a9134da711cb5dfc170 18-Mar-2006 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (3584): Implement V4L2_TUNER_MODE_LANG1_LANG2 audio mode

Add a new audio mode V4L2_TUNER_MODE_LANG1_LANG2 (used by VIDIOC_G/S_TUNER).
This mode allows the user to select both languages of a bilingual transmission,
one language on the left, one on the right audio channel. If there is no
bilingual transmission, or it is not supported, then this mode should act like
V4L2_TUNER_MODE_STEREO.
This mode is introduced for PVR-like drivers where it is useful to be able to
record both languages of a bilingual broadcast.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2474ed444b475614ef795523076be7cc8437ae00 19-Mar-2006 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (3582): Implement correct msp3400 input/output routing

- implement VIDIOC_INT_S_AUDIO_ROUTING for msp3400 and tvaudio
- use the new command in bttv, pvrusb2 and em28xx.
- remove the now obsolete MSP_SET_MATRIX from msp3400 (yeah!)
- remove the obsolete VIDIOC_S_AUDIO from msp3400.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
8bf2f8e747700419cc5bbc56c4496774eb8f2f1f 19-Mar-2006 Hans Verkuil <hverkuil@xs4all.nl> V4L/DVB (3577): Cleanup audio input handling

Cleanup audio input handling in bttv and tvaudio:
- inputs were specified that were never used
- mute was handled as a special input which led to confusing code
- confusing naming made it difficult to see if the setting was for
i2c or gpio.
The old audiochip.h input names moved to tvaudio.h. Currently this
is used both by tvaudio and msp3400 until the msp3400 implements the
new msp3400-specific inputs.
Detect in bttv the tvaudio and msp3400 i2c clients and use these
client pointers to set the inputs directly instead of broadcasting the
command.
Removed AUDC_SET_INPUT. Now replaced by VIDIOC_S_AUDIO. This will be
replaced again later by the new ROUTING commands.
Removed VIDIOC_G_AUDIO implementations in i2c drivers: this command is
a user level command and not to be used internally. It wasn't called at
all anyway.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
fa3fcceb30eb8a3cb2ac299c207c6f89b9aed379 24-Mar-2006 Mauro Carvalho Chehab <mchehab@infradead.org> V4L/DVB (3546): Fix Compilation after moving bttv code

- Missing a Makefile for bt8xx
- rds.h were at wrong directory, since it is a global header for an internal
interface
- tda7432 and tda9875 were dependent from bttv.h
- bttv.h were holding i2c addresses

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
faecfb1760325613debd8df9b9374ce4a28c01d9 17-Mar-2006 Manu Abraham <manu@linuxtv.org> V4L/DVB (3539): Move bttv fragments to bt8xx/

Signed-off-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>