V4L/DVB (7541): em28xx: Some fixes to videobuf

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.

Signed-off-by: Aidan Thornton <makosoft@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7542): em28xx: Fix some warnings

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7543): Fix capture start/stop and timeout

Also removes the dead restart_video_queue() function

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7544): em28xx: Fix timeout code

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7545): em28xx: Fix CodingStyle errors and most warnings introduced by videobuf

The last videobuf changes introduced several CodingStyle errors. Fixes all those
errors, as reported by checkpatch.pl

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7547): em28xx: Fix a broken lock

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
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.

Signed-off-by: Aidan Thornton <makosoft@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7549): em28xx: some small cleanups

- Remove dead code;
- Fix a few CodingStyle issues;
- Prints frame number, if debug is enabled.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7550): em28xx: Fix a possible memory leak

I did notice a possible memory leak since iolock is could possibly be
called before a buffer has been freed.

This ensure s_fmt isn't called while the queue is busy thereby avoiding
iolock on already allocated buffers.

Signed-off-by: Brandon Philips <bphilips@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7551): vivi: Add a missing \n

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7552): videbuf-vmalloc: Corrects mmap code

There were some bugs on 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.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7553): videobuf-vmalloc: fix STREAMOFF/STREAMON

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.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7554): videobuf-dma-sg: Remove unused flag

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7555): em28xx: remove timeout

It seems that we don't need a timeout for em28xx.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7556): em28xx: fix locking on vidioc_s_fmt_cap

Currently, vidioc_s_fmt_cap is allowed even if streaming is running on some
other fh. This is likely to cause issues.

Block use of vidioc_s_fmt_cap if someone else has claimed access to the device.

Signed-off-by: Aidan Thornton <makosoft@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7557): em28xx: honour video_debug modprobe parameter

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7558): videobuf: Improve command output for debug purposes

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7559): em28xx: Fills the entire buffer, before getting another one

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7560): videodev: Some printk fixes

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
V4L/DVB (7561): videobuf-vmalloc: stop streaming before unmap

Before the patch, there were a risk of freeing and unmapping userspace memory,
while there were pending requests.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>