There are some fields that are just caching some calculus for buffer
size. The calculus were moved to the places it were needed and the now
unused fields were removed.
V4L/DVB (7566): videobuf-dvb: allow its usage with videobuf-vmalloc
videobuf-dvb were still using a function that were videobuf-dma-sg
dependent. This patch creates a generic handler for this function. This
way, videobuf-dvb can now work with all videobuf implementations.
This patch fixes three related issues and a fourth trivial one:
- Use buffers even if no-one's currently waiting for them (fixes
underrun issues);
- Don't return incomplete/mangled frames at the start of streaming and
in the case of buffer underruns;
- Fix an issue which could cause the driver to write to a buffer that's
been freed after videobuf_queue_cancel is called (exposed by the
previous two fixes - for some reason, ignoring buffers that weren't
being waited on worked around the issue);
- Fix a bug which could cause only one field to be filled in the first
buffer (or first few buffers) after streaming is started.
There are some cases where nobody is waiting for a buffer. Due to the
lack of check, if you try to abort the userspace app, machine were
hanging, since IRQ were trying to use a buffer that were disallocated.
Brandon Philips [Fri, 28 Mar 2008 17:18:33 +0000 (10:18 -0700)]
V4L/DVB (7562): videobuf: Require spinlocks for all videobuf users
A spinlock is necessary for queue_cancel to work with every driver in the tree.
Otherwise a race exists between IRQ handlers removing buffers from the queue
and queue_cancel invalidating the queue.
There were a small bug on videobuf-vmalloc that were preventing STREAMOFF to
work. The issue is that vmalloc'ed mmaped memory should only be freed after
being sure that there aren't any mmap usage. Otherwise, the memory remap will
stop working, and the userspace won't receive any frames.
This bug were affecting some userspace applications, like tvtime.
After this patch, tvtime started to work again with the drivers that use
videobuf-vmalloc.
Basically, remap were called with a wrong parameter. Due to that, a later remap
were needed, generating the need of some hacks on videobuf-vmalloc and
videobuf-core.
This patch fixes the remap and removes the hacks.
TODO:
- V4L2_MEMORY_USERPTR is not implemented yet. This method should be
properly implemented, in order to work with a few userspace applications.
- The driver also doesn't implement V4L2_MEMORY_OVERLAY. This method is used
only by a few applications, and are becaming obsolete, due to the increment
of cpu performance. So, most apps prefer to retrieve data to an internal
buffer, doing some processing like de-interlacing.
V4L/DVB (7548): Various fixes for the em28xx videobuf code
- Aborting buffer_filled if no-one's waiting on the waitqueue probably isn't
what we want, since just because no-one's waiting for it now doesn't mean they
wouldn't dequeue it in time. (vivi gets away with this, possibly because it
can fill each buffer much faster.)
- The first BUG_ON(lencopy <= 0); really isn't worth causing a kernel panic
over, especially since there are some reasons why it could trigger in normal use.
- The top and botom frames are actually the wrong way around.
It fixes a couple of minor bugs, comments out a bogus BUG_ON, sets fh->type
correctly, uses dev->width and dev->height for now, and adds a missing spinlock
init (nasty - caused a system lockup). It also adds some debug code which
probably isn't all that useful. I haven't tested this version of the patch yet,
though, so I'm not sure what you can expect if you try it.
Also, the preliminary tests, made on a single core 1.5 MHz Centrino showed
that CPU usage reduced from 42%-75% to 28%-33% (reports from "top") command.
A test with time command presented an even better result:
This is the performance tests I did, running code_example to get 1,000 frames
@29.995 Hz (about 35 seconds of stream), tested on a i386 machine, running at
1,5GHz:
The old driver:
$ time -f "%E: %Us User time, %Ss Kernel time, %P CPU used" ./capture_example
0:34.21: 8.22s User time, 25.16s Kernel time, 97% CPU used
The videobuf-based driver:
$ time -f "%E: %Us User time, %Ss Kernel time, %P CPU used" ./capture_example
0:35.36: 0.01s User time, 0.05s Kernel time, 0% CPU used
Conclusion:
The time consumption to receive the stream where reduced from about 33.38
seconds to 0.05 seconds.
Janne Grunau [Wed, 9 Apr 2008 22:13:13 +0000 (19:13 -0300)]
V4L/DVB (7538): Adds selectable adapter numbers as per module option
The adapter_nr module options can be used to allocate static adapter
numbers on a driver level. It avoids problems with changing DVB apapter
numbers after warm/cold boot or device unplugging and repluging.
Each driver holds DVB_MAX_ADAPTER long array of the preferred order of
adapter numbers.
options dvb-usb-dib0700 adapter_nr=7,6,5,4,3,2,1,0 would result in a
reversed allocation of adapter numbers.
With adapter_nr=2,5 it tries first to get adapter number 2 and 5. If
both are already in use it will allocate the lowest free adapter number.
Signed-off-by: Janne Grunau <janne-dvb@grunau.be> Acked-by: Hermann Pitton <hermann.pitton@arcor.de> Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Hans Verkuil [Wed, 9 Apr 2008 09:26:17 +0000 (06:26 -0300)]
V4L/DVB (7535): saa717x: add new audio/video decoder i2c driver
Added the last remaining out-of-tree kernel driver from the ivtv project.
The saa717x is used in several Japanese cards and a Russian card. The
driver is not complete in that only NTSC is supported and no PAL/SECAM.
V4L/DVB (7531): budget-av: Fix CI interface on (some) KNC1 DVBS cards
Quoting the commit introducing reinitialise_demod (3984 / by adq):
"These cards [KNC1 DVBT and DVBC] need special handling for CI - reinitialising the frontend
device when the CI module is reset."
Apparently my 1894:0010 also needs that fix, because once you initialise CI/CAM you lose lock.
Signed-off-by: Christoph Pfister <pfister@linuxtv.org> Signed-off-by: Oliver Endriss <o.endriss@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7530): budget-av: Fix support for certain cams
The current ci implementation doesn't accept 0xff when reading data bytes (address == 0),
thus breaks cams which report a buffer size of 0x--ff like my orion one.
Remove the 0xff check altogether, because validation is really the job of a higher layer.
Signed-off-by: Christoph Pfister <pfister@linuxtv.org> Signed-off-by: Oliver Endriss <o.endriss@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7493): videobuf: Avoid deadlock with QBUF and bring up to spec for empty queue
Add a waitqueue to wait on when there are no buffers in the buffer queue.
DQBUF waits on this queue without holding vb_lock to allow a QBUF to happen.
Once a buffer has been queued we recheck that the queue is still streaming and
wait on the new buffer's waitqueue while holding the vb_lock. The driver
should come along in a timely manner and put the buffer into its next state
finishing the DQBUF.
By implementing this waitqueue it also brings the videobuf DQBUF up to spec and
it now blocks on O_NONBLOCK even when no buffers have been queued via QBUF:
"By default VIDIOC_DQBUF blocks when no buffer is in the outgoing queue."
- V4L2 spec
V4L/DVB (7492): vivi: Simplify the vivi driver and avoid deadlocks
vivi previously had a very complex queuing system and held spinlocks while
doing copy_to_user, kmalloc, etc. This caused the driver to easily deadlock
when a multi-threaded application used it and revealed bugs in videobuf too.
This replaces the copy_to_user with memcpy since we were never copying to user
space addresses. And makes the kmalloc atomic.
V4L/DVB (7489): videobuf-vmalloc.c: Remove buf_release from videobuf_vm_close
Remove the buf_release on vm_close because it will lead to a buffer being
released multiple times since all buffers are already freed under the two
possible cases: device close or STREAMOFF.
tuner-simple is the only module that uses tuner-types - these will be
merged to a single module in the future. For now, build both of them
if TUNER_SIMPLE is selected.
This fixes the following build warning, if tuner-simple is selected
without tuner-types:
V4L/DVB (7474): support key repeat with dib0700 ir receiver
This patch enables support for repeating last event when a key is holded
down with dib0700 devices. It works with rc5 and nec remotes.
It also fixes an annoying bug that floods kernel log with "Unknown key"
messages after each keypress. This happened because the driver was not
resetting infrared register after each poll so it kept polling last key
even if nothing was being pressed. Fixing this, (calling rc_setup after
each poll), permits to implement key repeat.
Signed-off-by: Filippo Argiolas <filippo.argiolas at gmail.com> Signed-off-by: Patrick Boettcher <pb@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7470): CX24123: preparing support for CX24113 tuner
To support a new device based on CX24123 (using the CX24113-tuner) the following was done:
- added two parameters to de-select the internal PLL-driver (for CX24108) and a AGC-function callback.
- added a virtual i2c-adapter which allow simple access behind the i2c-gate
- cleanup up some code
Signed-off-by: Patrick Boettcher <pb@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7469): Preparation for supporting new devices, cleanup and saneness
To prepare the support for new device to the flexcop-family some preparation and cleanups was done + some saneness:
- created an i2c-adapter for each i2c-port available. Easier usage for devices with several device on different i2c-busses
- initialize i2c before doing the eeprom read
- changed the way to attach the different frontends, easier to read now
- enabled support for i2c-devices having no register address (1-byte access)
Signed-off-by: Patrick Boettcher <pb@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Frej Drejhammar [Mon, 24 Mar 2008 01:43:25 +0000 (22:43 -0300)]
V4L/DVB (7463): cx88: Enable color killer by default
An enabled color killer will not degrade picture quality for color
input signals, only suppress bogus color information on
black-and-white input. Therefore enable it by default.
Frej Drejhammar [Mon, 24 Mar 2008 01:43:24 +0000 (22:43 -0300)]
V4L/DVB (7454): cx88: Add user control for color killer
The cx2388x family has a color killer. This patch implements the
V4L2_CID_COLOR_KILLER control for the cx2388x family. By default the
color killer is disabled, as in previous versions of the driver.
Frej Drejhammar [Mon, 24 Mar 2008 01:43:22 +0000 (22:43 -0300)]
V4L/DVB (7452): cx88: Enable chroma AGC by default for all non-SECAM modes
An enabled chroma AGC will not degrade picture quality if enabled on a
color PAL or NTSC signal with nominal signal levels. It will give a
significant color reproduction improvement if the chroma signals
diverge from nominal levels. Therefore enable chroma AGC by default
for PAL and NTSC standards.
Frej Drejhammar [Mon, 24 Mar 2008 01:43:21 +0000 (22:43 -0300)]
V4L/DVB (7451): cx88: Add user control for chroma AGC
The cx2388x family has support for chroma AGC. This patch implements a
the V4L2_CID_CHROMA_AGC control for the cx2388x family. By default
chroma AGC is disabled, as in previous versions of the driver.
Marton Balint [Wed, 26 Mar 2008 05:07:35 +0000 (02:07 -0300)]
V4L/DVB (7449): cx88: fix oops on module removal caused by IR worker
If the IR worker is not stopped before the removal of the cx88xx module,
an OOPS may occur, because the worker function cx88_ir_work gets called.
So stop the ir worker.
This board has a s5h1409 demod, plus a xc30x8 tuner (probably, xc3018).
This patch adds proper support for radio, video, s-video, composite and ATSC.
However, support for radio and video depends on having s5h1409 i2c gate open,
otherwise, xc30x8 chip won't be visible.
For a better support, some rework is needed on cx88 driver, to allow adding
xc30x8 to i2c bus without sending i2c 0 byte reading to 0xc2 address.
Thanks to Vanessa Ezekowitz <vanessaezekowitz@gmail.com> for helping to figure
out the proper parameters for s5h1409 and the GPIO pins used by each
configuration.
Mike Isely [Sat, 8 Mar 2008 07:02:20 +0000 (04:02 -0300)]
V4L/DVB (7447): pvrusb2: Fix compilation warning
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>
Michael Krufky [Tue, 22 Apr 2008 17:46:25 +0000 (14:46 -0300)]
V4L/DVB (7440): dvb-bt8xx: fix build error
Fix the following build error:
In file included from dvb-bt8xx.c:35:
dvb-bt8xx.h:42:26: error: tuner-simple.h: No such file or directory
dvb-bt8xx.c: In function 'frontend_init':
dvb-bt8xx.c:612: error: 'simple_tuner_attach' undeclared (first use in this function)
dvb-bt8xx.c:612: error: (Each undeclared identifier is reported only once
dvb-bt8xx.c:612: error: for each function it appears in.)
dvb-bt8xx.c:612: warning: type defaults to 'int' in declaration of '__a'
dvb-bt8xx.c:612: warning: type defaults to 'int' in declaration of 'type name'
dvb-bt8xx.c:612: warning: cast from pointer to integer of different size
dvb-bt8xx.c:612: warning: type defaults to 'int' in declaration of 'type name'
dvb-bt8xx.c:612: warning: cast from pointer to integer of different size
dvb-bt8xx.c:612: error: called object '__a' is not a function
dvb-bt8xx.c:696: warning: type defaults to 'int' in declaration of '__a'
dvb-bt8xx.c:696: warning: type defaults to 'int' in declaration of 'type name'
dvb-bt8xx.c:696: warning: cast from pointer to integer of different size
dvb-bt8xx.c:696: warning: type defaults to 'int' in declaration of 'type name'
dvb-bt8xx.c:696: warning: cast from pointer to integer of different size
dvb-bt8xx.c:696: error: called object '__a' is not a function
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>