platform/kernel/linux-3.10.git
9 years agoupstream: [media] vb2: Check if there are buffers before streamon
Ricardo Ribalda [Wed, 8 Jan 2014 08:01:33 +0000 (05:01 -0300)]
upstream: [media] vb2: Check if there are buffers before streamon

This patch adds a test preventing streamon() if there is no buffer
ready.

Without this patch, a user could call streamon() before
preparing any buffer. This leads to a situation where if he calls
close() before calling streamoff() the device is kept streaming.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] Revert "[media] videobuf_vm_{open,close} race fixes"
Hans Verkuil [Fri, 3 Jan 2014 11:10:49 +0000 (08:10 -0300)]
upstream: [media] Revert "[media] videobuf_vm_{open,close} race fixes"

This reverts commit a242f426108c284049a69710f871cc9f11b13e61.

That commit actually caused deadlocks, rather then fixing them.

If ext_lock is set to NULL (otherwise videobuf_queue_lock doesn't do
anything), then you get this deadlock:

The driver's mmap function calls videobuf_mmap_mapper which calls
videobuf_queue_lock on q. videobuf_mmap_mapper calls  __videobuf_mmap_mapper,
__videobuf_mmap_mapper calls videobuf_vm_open and videobuf_vm_open
calls videobuf_queue_lock on q (introduced by above patch): deadlocked.

This affects drivers using dma-contig and dma-vmalloc. Only dma-sg is
not affected since it doesn't call videobuf_vm_open from __videobuf_mmap_mapper.

Most drivers these days have a non-NULL ext_lock. Those that still use
NULL there are all fairly obscure drivers, which is why this hasn't been
seen earlier.

Since everything worked perfectly fine for many years I prefer to just
revert this patch rather than trying to fix it. videobuf is quite fragile
and I rather not touch it too much. Work is (slowly) progressing to move
everything over to vb2 or at the very least use non-NULL ext_lock in
videobuf.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: <stable@vger.kernel.org> # for v3.11 and up
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Reported-by: Pete Eberlein <pete@sensoray.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] go7007-loader: fix usb_dev leak
Alexey Khoroshilov [Fri, 20 Dec 2013 19:17:32 +0000 (16:17 -0300)]
upstream: [media] go7007-loader: fix usb_dev leak

There is usb_get_dev() in go7007_loader_probe(),
but there is no usb_put_dev() anywhere.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] media: v4l2-dev: fix video device index assignment
Marek Szyprowski [Tue, 3 Dec 2013 13:14:29 +0000 (10:14 -0300)]
upstream: [media] media: v4l2-dev: fix video device index assignment

The side effect of commit 1056e4388b045 ("v4l2-dev: Fix race condition on
__video_register_device") is the increased number of index value assigned
on video_device registration. Before that commit video_devices were
numbered from 0, after it, the indexes starts from 1, because get_index()
always count the device, which is being registered. Some device drivers
rely on video_device index number for internal purposes, i.e. s5p-mfc
driver stopped working after that patch. This patch restores the old method
of numbering the video_device indexes.

Cc: stable@vger.kernel.org # for v3.12
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Ricardo Ribalda <ricardo.ribalda@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] Staging: media: Fix line length exceeding 80 characters in as102_drv.c
Monam Agarwal [Tue, 14 Jan 2014 14:27:08 +0000 (11:27 -0300)]
upstream: [media] Staging: media: Fix line length exceeding 80 characters in as102_drv.c

This patch fixes the following checkpatch.pl warning in as102/as102_drv.c
WARNING: line over 80 characters in the file

Signed-off-by: Monam Agarwal <monamagarwal123@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] Staging: media: Fix line length exceeding 80 characters in as102_fe.c
Monam Agarwal [Tue, 14 Jan 2014 12:02:42 +0000 (09:02 -0300)]
upstream: [media] Staging: media: Fix line length exceeding 80 characters in as102_fe.c

This patch fixes the following checkpatch.pl issues in
as102/as102_fe.c
WARNING: line over 80 characters

Signed-off-by: Monam Agarwal <monamagarwal123@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] Staging: media: Fix quoted string split across line in as102_fe.c
Monam Agarwal [Tue, 14 Jan 2014 12:01:14 +0000 (09:01 -0300)]
upstream: [media] Staging: media: Fix quoted string split across line in as102_fe.c

This patch fixes the following checkpatch.pl issues in
as102/as102_fe.c
WARNING: quoted string split across lines

Signed-off-by: Monam Agarwal <monamagarwal123@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] media: st-rc: Add reset support
Srinivas Kandagatla [Tue, 14 Jan 2014 11:04:21 +0000 (08:04 -0300)]
upstream: [media] media: st-rc: Add reset support

Some of the SOCs hold the IRB IP in softreset state by default.
For this IP to work driver needs to bring it out of softreset.
This patch adds support to reset the IP via reset framework.

Without this patch the driver can not work with SoCs which holds the IP
in softreset.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] m2m-deinterlace: fix allocated struct type
Jassi Brar [Sun, 12 Jan 2014 11:21:28 +0000 (08:21 -0300)]
upstream: [media] m2m-deinterlace: fix allocated struct type

'xt' points to a dma_interleaved_template and not a dma_async_tx_descriptor.

Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] radio-usb-si4713: fix sparse non static symbol warnings
Wei Yongjun [Wed, 15 Jan 2014 02:46:06 +0000 (23:46 -0300)]
upstream: [media] radio-usb-si4713: fix sparse non static symbol warnings

Fixes the following sparse warnings:

drivers/media/radio/si4713/radio-usb-si4713.c:226:31: warning:
 symbol 'start_seq' was not declared. Should it be static?
drivers/media/radio/si4713/radio-usb-si4713.c:291:29: warning:
 symbol 'command_table' was not declared. Should it be static?

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-audio: remove needless check before usb_free_coherent()
Wei Yongjun [Wed, 15 Jan 2014 05:52:12 +0000 (02:52 -0300)]
upstream: [media] em28xx-audio: remove needless check before usb_free_coherent()

usb_free_coherent() is safe with NULL addr and this check is
not required.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-audio: provide an error code when URB submit fails
Mauro Carvalho Chehab [Tue, 14 Jan 2014 17:34:13 +0000 (14:34 -0300)]
upstream: [media] em28xx-audio: provide an error code when URB submit fails

Instead of just saying:
[ 1646.412419] em2882/3 #0: submit of audio urb failed
Print the reason why it failed, to help debugging and fixing it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: fix check for audio only usb interfaces when changing the...
Frank Schaefer [Mon, 13 Jan 2014 22:02:07 +0000 (19:02 -0300)]
upstream: [media] em28xx: fix check for audio only usb interfaces when changing the usb alternate setting

Previously, we've been assuming that the video endpoints are always at usb
interface 0. Hence, if vendor audio endpoints are provided at a separate
interface, they were supposed to be at interface number > 0.
Instead of checking for (interface number > 0) to determine if an interface
is a pure audio interface, dev->is_audio_only should be checked.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: fix usb alternate setting for analog and digital video...
Frank Schaefer [Mon, 13 Jan 2014 22:02:06 +0000 (19:02 -0300)]
upstream: [media] em28xx: fix usb alternate setting for analog and digital video endpoints > 0

The current code assumes that the analog + digital video endpoints are always at
interface number 0 when changing the alternate setting.
This seems to work fine for most existing devices.
However, at least the SpeedLink VAD Laplace webcam has the video endpoint on
interface number 3 (which fortunately doesn't cause any trouble because ist uses
bulk transfers only).
We already consider the actual interface number for audio endpoints, so
rename the the audio_ifnum variable and use it for all device types.
Also get get rid of a pointless (ifnum < 0) in em28xx-audio.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: Fix usb diconnect logic
Mauro Carvalho Chehab [Mon, 13 Jan 2014 01:44:23 +0000 (22:44 -0300)]
upstream: [media] em28xx: Fix usb diconnect logic

Now that everything is extension, the usb disconnect logic should
be the same.

While here, fix the device name.

Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Tested-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: print a message at disconnect
Mauro Carvalho Chehab [Sun, 12 Jan 2014 22:22:07 +0000 (19:22 -0300)]
upstream: [media] em28xx: print a message at disconnect

That helps to identify if something fails and explain why em28xx
struct is not freed (if it ever happens).

Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Tested-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-audio: disconnect before freeing URBs
Mauro Carvalho Chehab [Sun, 12 Jan 2014 21:14:05 +0000 (18:14 -0300)]
upstream: [media] em28xx-audio: disconnect before freeing URBs

URBs might be in usage. Disconnect the device before freeing
them.

Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Tested-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-audio: simplify error handling
Mauro Carvalho Chehab [Sun, 12 Jan 2014 20:20:31 +0000 (17:20 -0300)]
upstream: [media] em28xx-audio: simplify error handling

Cleanup the error handling code at em28xx-audio init.

Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Tested-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-audio: fix return code on device disconnect
Mauro Carvalho Chehab [Sun, 12 Jan 2014 15:57:08 +0000 (12:57 -0300)]
upstream: [media] em28xx-audio: fix return code on device disconnect

Alsa has an special non-negative return code to indicate device removal
at snd_em28xx_capture_pointer(). Use it, instead of an error code.

Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Tested-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: move v4l2_device_disconnect() call from the core to the...
Frank Schaefer [Sun, 12 Jan 2014 16:24:21 +0000 (13:24 -0300)]
upstream: [media] em28xx: move v4l2_device_disconnect() call from the core to the v4l extension

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: move usb transfer uninit on device disconnect from the...
Frank Schaefer [Sun, 12 Jan 2014 16:24:20 +0000 (13:24 -0300)]
upstream: [media] em28xx: move usb transfer uninit on device disconnect from the core to the v4l-extension

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: move usb buffer pre-allocation and transfer uninit from...
Frank Schaefer [Sun, 12 Jan 2014 16:24:19 +0000 (13:24 -0300)]
upstream: [media] em28xx: move usb buffer pre-allocation and transfer uninit from the core to the dvb extension

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-v4l: fix device initialization in em28xx_v4l2_open() for...
Frank Schaefer [Sun, 12 Jan 2014 16:24:18 +0000 (13:24 -0300)]
upstream: [media] em28xx-v4l: fix device initialization in em28xx_v4l2_open() for radio and VBI mode

- bail out on unsupported VFL_TYPE
- em28xx_set_mode() needs to be called for VBI and radio mode, too
- em28xx_wake_i2c() needs to be called for VBI and radio mode, too
- em28xx_resolution_set() also needs to be called for VBI

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] tea575x: Fix build with ARCH=c6x
Mauro Carvalho Chehab [Mon, 13 Jan 2014 17:54:59 +0000 (15:54 -0200)]
upstream: [media] tea575x: Fix build with ARCH=c6x

In file included from /devel/v4l/temp/include/asm-generic/page.h:23:0,
                 from /devel/v4l/temp/arch/c6x/include/asm/page.h:9,
                 from /devel/v4l/temp/include/asm-generic/io.h:14,
                 from arch/c6x/include/generated/asm/io.h:1,
                 from /devel/v4l/temp/drivers/media/radio/tea575x.c:23:
/devel/v4l/temp/arch/c6x/include/asm/setup.h:17:27: error: unknown type name ‘phys_addr_t’
 extern int c6x_add_memory(phys_addr_t start, unsigned long size);

It seems that, on such arch, the includes from asm/ should be
after the ones from linux/.

The proper fix would be to patch the arch files, but, as
this fix is trivial, apply it. Also, we generally put the
asm includes after the linux ones, anyway.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] dib8000: Fix a few warnings when compiled for avr32
Mauro Carvalho Chehab [Mon, 13 Jan 2014 17:14:33 +0000 (15:14 -0200)]
upstream: [media] dib8000: Fix a few warnings when compiled for avr32

drivers/media/dvb-frontends/dib8000.c: In function 'dib8000_get_time_us':
drivers/media/dvb-frontends/dib8000.c:3957: warning: 'interleaving' may be used uninitialized in this function
drivers/media/dvb-frontends/dib8000.c:3956: warning: 'rate_denum' may be used uninitialized in this function

Those are actually false positives, but it doesn't hurt cleaning them.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] dib8000: Properly represent long long integers
Mauro Carvalho Chehab [Mon, 13 Jan 2014 17:05:44 +0000 (15:05 -0200)]
upstream: [media] dib8000: Properly represent long long integers

When compiling with avr32, it gets those errors:

drivers/media/dvb-frontends/dib8000.c: In function 'dib8000_get_stats':
drivers/media/dvb-frontends/dib8000.c:4121: warning: integer constant is too large for 'long' type

Fix integer representation to avoid overflow.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] radio-usb-si4713: make si4713_register_i2c_adapter static
Mauro Carvalho Chehab [Mon, 13 Jan 2014 13:34:37 +0000 (11:34 -0200)]
upstream: [media] radio-usb-si4713: make si4713_register_i2c_adapter static

This function isn't used nowhere outside the same .c file.
Fixes this warning:

drivers/media/radio/si4713/radio-usb-si4713.c:418:5: warning: no previous prototype for 'si4713_register_i2c_adapter' [-Wmissing-prototypes]
 int si4713_register_i2c_adapter(struct si4713_usb_device *radio)
     ^

Cc: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] sh_vou: comment unused vars
Mauro Carvalho Chehab [Mon, 13 Jan 2014 13:30:26 +0000 (11:30 -0200)]
upstream: [media] sh_vou: comment unused vars

Fix two warns below, by commenting the unused code:

drivers/media/platform/sh_vou.c: In function 'sh_vou_configure_geometry':
drivers/media/platform/sh_vou.c:446:49: warning: variable 'height_max' set but not used [-Wunused-but-set-variable]
  unsigned int black_left, black_top, width_max, height_max,
                                                 ^
drivers/media/platform/sh_vou.c: In function 'sh_vou_isr':
drivers/media/platform/sh_vou.c:1056:13: warning: variable 'side' set but not used [-Wunused-but-set-variable]
  static int side;
             ^

Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: fsl-viu: adjust for OF based clock lookup
Gerhard Sittig [Sat, 30 Nov 2013 22:51:33 +0000 (23:51 +0100)]
upstream: fsl-viu: adjust for OF based clock lookup

after device tree based clock lookup became available, the VIU driver
need no longer use the previous global "viu_clk" name, but should use
the "ipg" clock name specific to the OF node

Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: linux-media@vger.kernel.org
Signed-off-by: Gerhard Sittig <gsi@denx.de>
Signed-off-by: Anatolij Gustschin <agust@denx.de>
9 years agoupstream: [media] em28xx-audio: return -ENODEV when the device is disconnected
Mauro Carvalho Chehab [Sun, 12 Jan 2014 13:21:42 +0000 (10:21 -0300)]
upstream: [media] em28xx-audio: return -ENODEV when the device is disconnected

If em28xx is disconnected, return -ENODEV to all PCM callbacks.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-audio: split URB initialization code
Mauro Carvalho Chehab [Sun, 12 Jan 2014 13:10:34 +0000 (10:10 -0300)]
upstream: [media] em28xx-audio: split URB initialization code

The URB calculus code may eventually be moved to some other
place, like at pcm open, if it ends by needing more setups, like
working with different bit rates, or different audio latency.

So, move it into a separate routine. That also makes the code
more readable.

No functional changes.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-audio: don't wait for lock in non-block mode
Mauro Carvalho Chehab [Sun, 12 Jan 2014 12:22:29 +0000 (09:22 -0300)]
upstream: [media] em28xx-audio: don't wait for lock in non-block mode

Pulseaudio has the bad habit of stopping a streaming audio if
a device, opened in non-block mode, waits.

It is impossible to avoid em28xx to wait, as it will send commands
via I2C, and other I2C operations may be happening (firmware
transfers, Remote Controller polling, etc). Yet, as each em28xx
subdriver locks em28xx-dev to protect the access to the hardware,
it is possible to minimize the audio glitches by returning -EAGAIN
to pulseaudio, if the lock is already taken by another subdriver.

Reported-by: Antti Palosaari <crope@iki.fi>
Tested-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-audio: fix the period size in bytes
Mauro Carvalho Chehab [Fri, 10 Jan 2014 16:29:16 +0000 (13:29 -0300)]
upstream: [media] em28xx-audio: fix the period size in bytes

If the period size is wrong, userspace will assume a wrong delay
any may negociate an inadequate value.

The em28xx devices use 8 for URB interval, in microframes,
and the driver programs it to have 64 packets.

That means that the IRQ sampling period is 125 * 8 * 64,
with is equal to 64 ms.

So, that's the minimal latency with the current settings. It is
possible to program a lower latency, by using less than 64 packets,
but that increases the amount of bandwitdh used, and the number of
IRQ events per second.

In any case, in order to support it, the driver logic should be
changed to fill those parameters in realtime.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-audio: don't hardcode audio URB calculus
Mauro Carvalho Chehab [Fri, 10 Jan 2014 08:53:24 +0000 (05:53 -0300)]
upstream: [media] em28xx-audio: don't hardcode audio URB calculus

The current code hardcodes the number of audio URBs, the number
of packets per URB and the maximum URB size.

This is not a good idea, as it:

- wastes more bandwidth than necessary, by using a very
  large number of packets;

- those constants are bound to an specific scenario, with
  a bandwidth of 48 kHz;

- don't take the maximum endpoint size into account;

- with urb->interval = 1 on xHCI, those constraints cause a "funny"
  setup: URBs with 64 packets inside, with only 24 bytes total. E. g.
  a complete waste of space.

Change the code to do dynamic URB audio calculus and allocation.

For now, use the same constraints as used before this patch, to
avoid regressions.

A good scenario (tested) seems to use those defines, instead:

#define EM28XX_MAX_AUDIO_BUFS          8
#define EM28XX_MIN_AUDIO_PACKETS       2

But let's not do such change here, letting the optimization to
happen on latter patches, after more tests.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-audio: Fix error path
Mauro Carvalho Chehab [Fri, 10 Jan 2014 09:59:09 +0000 (06:59 -0300)]
upstream: [media] em28xx-audio: Fix error path

De-allocate memory and free sound if an error happens.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-audio: use bInterval on em28xx-audio
Mauro Carvalho Chehab [Fri, 10 Jan 2014 08:43:09 +0000 (05:43 -0300)]
upstream: [media] em28xx-audio: use bInterval on em28xx-audio

Just filling urb->interval with 1 is wrong, and causes a different
behaviour with xHCI.

With EHCI, the URB size is typically 192 bytes. However, as
xHCI specifies intervals in microframes, the URB size becomes
too short (24 bytes).

With this patch, the interval will be properly initialized, and
the device will behave the same if connected into a xHCI or an
EHCI device port.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-i2c: add timeout debug information if i2c_debug enabled
Mauro Carvalho Chehab [Mon, 6 Jan 2014 12:17:53 +0000 (09:17 -0300)]
upstream: [media] em28xx-i2c: add timeout debug information if i2c_debug enabled

If i2c_debug is enabled, we splicitly want to know when a
device fails with timeout.

If i2c_debug==2, this is already provided, for each I2C transfer
that fails.

However, most of the time, we don't need to go that far. We just
want to know that I2C transfers fail.

So, add such errors for normal (ret == 0x10) I2C aborted timeouts.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-i2c: cleanup I2C debug messages
Mauro Carvalho Chehab [Sat, 28 Dec 2013 11:23:30 +0000 (08:23 -0300)]
upstream: [media] em28xx-i2c: cleanup I2C debug messages

The I2C output messages is too polluted. Clean it a little
bit, by:
- use the proper core support for memory dumps;
- hide most stuff under the i2c_debug umbrella;
- add the missing KERN_CONT where needed;
- use 2 levels or verbosity. Only the second one
  will show the I2C transfer data.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-i2c: Fix error code for I2C error transfers
Mauro Carvalho Chehab [Sat, 4 Jan 2014 08:42:11 +0000 (05:42 -0300)]
upstream: [media] em28xx-i2c: Fix error code for I2C error transfers

Follow the error codes for I2C as described at Documentation/i2c/fault-codes.

In the case of the I2C status register (0x05), this is mapped into:

- ENXIO - when reg 05 returns 0x10
- ETIMEDOUT - when the device is not temporarily not responding
      (e. g. reg 05 returning something not 0x10 or 0x00)
- EIO - for generic I/O errors that don't fit into the above.

In the specific case of 0-byte reads, used only during I2C device
probing, it keeps returning -ENODEV.

TODO: return EBUSY when reg 05 returns 0x20 on em2874 and upper.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: convert i2c wait completion logic to use jiffies
Mauro Carvalho Chehab [Sat, 4 Jan 2014 08:42:11 +0000 (05:42 -0300)]
upstream: [media] em28xx: convert i2c wait completion logic to use jiffies

The I2C wait completion/timeout logic currently assumes that
msleep(5) will wait exaclty 5 ms. This is not true at all,
as it depends on CONFIG_HZ.

Convert it to use jiffies, in order to not wait for more time
than needed.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: properly implement AC97 wait code
Mauro Carvalho Chehab [Fri, 27 Dec 2013 03:28:57 +0000 (00:28 -0300)]
upstream: [media] em28xx: properly implement AC97 wait code

Instead of assuming that msleep() is precise, use a jiffies
based code to wait for AC97 to be available.

Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] tuner-xc2028: Don't read status if device is powered down
Mauro Carvalho Chehab [Mon, 6 Jan 2014 09:52:43 +0000 (06:52 -0300)]
upstream: [media] tuner-xc2028: Don't read status if device is powered down

That removes those timeout errors:

[ 3675.930940] xc2028 19-0061: Device is Xceive 3028 version 1.0, firmware version 2.7
[ 3676.060487] xc2028 19-0061: divisor= 00 00 8d d0 (freq=567.250)
[ 3676.349449] xc2028 19-0061: Putting xc2028/3028 into poweroff mode.
[ 3698.247645] xc2028 19-0061: xc2028_get_reg 0002 called
[ 3698.253276] em2860 #0: I2C transfer timeout on writing to addr 0xc2
[ 3698.253301] xc2028 19-0061: i2c input error: rc = -121 (should be 2)
[ 3698.253327] xc2028 19-0061: xc2028_signal called
[ 3698.253339] xc2028 19-0061: xc2028_get_reg 0002 called
[ 3698.259283] em2860 #0: I2C transfer timeout on writing to addr 0xc2
[ 3698.259312] xc2028 19-0061: i2c input error: rc = -121 (should be 2)

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] tuner-xc2028: Don't try to sleep twice
Mauro Carvalho Chehab [Mon, 6 Jan 2014 09:39:51 +0000 (06:39 -0300)]
upstream: [media] tuner-xc2028: Don't try to sleep twice

Only send a power down command for the device if it is not already
in power down state. That prevents a timeout when trying to talk
with the device.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-audio: allocate URBs at device driver init
Mauro Carvalho Chehab [Sun, 29 Dec 2013 00:16:26 +0000 (21:16 -0300)]
upstream: [media] em28xx-audio: allocate URBs at device driver init

Instead of allocating/deallocating URBs and transfer buffers
every time stream is started/stopped, just do it once.

That reduces the memory allocation pressure and makes the
code that start/stop streaming a way simpler.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: use usb_alloc_coherent() for audio
Mauro Carvalho Chehab [Sat, 28 Dec 2013 14:47:16 +0000 (11:47 -0300)]
upstream: [media] em28xx: use usb_alloc_coherent() for audio

Instead of allocating transfer buffers with kmalloc() use
usb_alloc_coherent().

This patch should make it work also with ARM CPUs.

Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] cx231xx: add support for a CX23103 Video Grabber USB
Links (Markus) [Sat, 4 Jan 2014 22:44:34 +0000 (19:44 -0300)]
upstream: [media] cx231xx: add support for a CX23103 Video Grabber USB

Add a new USB ID to the driver.

Signed-off-by: Links (Markus) <help.markus+git@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] vb2: Fix comment in __qbuf_dmabuf
Laurent Pinchart [Wed, 1 Jan 2014 12:10:48 +0000 (09:10 -0300)]
upstream: [media] vb2: Fix comment in __qbuf_dmabuf

The comment incorrectly explains that the code verifies information
provided by userspace, while verification has been performed earlier in
reality. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] m88rs2000: Correct m88rs2000_get_fec
Malcolm Priestley [Sat, 28 Dec 2013 17:04:51 +0000 (14:04 -0300)]
upstream: [media] m88rs2000: Correct m88rs2000_get_fec

Value of fec is achieved by the upper nibble bits 6,7 & 8.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] m88rs2000: Correct m88rs2000_set_fec settings
Malcolm Priestley [Sat, 28 Dec 2013 17:02:44 +0000 (14:02 -0300)]
upstream: [media] m88rs2000: Correct m88rs2000_set_fec settings

Register 0x70 is used to set fec, register 0x76 is used to get fec

Register 0x76 is set to 0x8.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] m88rs2000: correct read status lock value
Malcolm Priestley [Sat, 28 Dec 2013 17:00:40 +0000 (14:00 -0300)]
upstream: [media] m88rs2000: correct read status lock value

The correct lock values is when bits of the value 0xee are set.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] e4000: fix error return code
Julia Lawall [Sun, 29 Dec 2013 22:47:35 +0000 (19:47 -0300)]
upstream: [media] e4000: fix error return code

Set the return variable to an error code as done elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
    when != &ret
*if(...)
{
  ... when != ret = e2
      when forall
 return ret;
}

// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] ec168: fix error return code
Julia Lawall [Sun, 29 Dec 2013 22:47:18 +0000 (19:47 -0300)]
upstream: [media] ec168: fix error return code

The rest of the function uses ret to store the return value, even setting
ret to i a few lines before this, so return ret instead of i.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
    when != &ret
*if(...)
{
  ... when != ret = e2
      when forall
 return ret;
}

// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] as102: fix leaks at failure paths in as102_usb_probe()
Alexey Khoroshilov [Fri, 27 Dec 2013 21:18:39 +0000 (18:18 -0300)]
upstream: [media] as102: fix leaks at failure paths in as102_usb_probe()

Failure handling is incomplete in as102_usb_probe().
The patch implements proper resource deallocations.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] cx231xx: Add missing KERN_CONT to i2c debug prints
Matthias Schwarzott [Mon, 23 Dec 2013 11:12:21 +0000 (08:12 -0300)]
upstream: [media] cx231xx: Add missing KERN_CONT to i2c debug prints

Fix continuation lines.

[m.chehab@samsung.com: This was actually part of a v2 patch meant to
 fix i2c debug prints. As version 1 was already applied, I'm applying
 here the diff and fixing the patch subject/description]

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] omap3isp: ccdc: Don't hang when the SBL fails to become idle
Laurent Pinchart [Mon, 9 Dec 2013 14:13:13 +0000 (11:13 -0300)]
upstream: [media] omap3isp: ccdc: Don't hang when the SBL fails to become idle

Under abnormal conditions (such as glitches on the HSYNC/VSYNC signals)
the CCDC output SBL can fail to become idle. The driver currently logs
this condition to the kernel log and doesn't restart the CCDC. This
results in CCDC video capture hanging without any notification to
userspace.

Cancel the pipeline and mark the CCDC as crashed instead of hanging.
Userspace will be notified of the problem and will then be able to close
and reopen the device to trigger a reset of the ISP.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] omap3isp: Refactor modules stop failure handling
Laurent Pinchart [Mon, 16 Dec 2013 02:49:42 +0000 (23:49 -0300)]
upstream: [media] omap3isp: Refactor modules stop failure handling

Modules failing to stop are fatal errors for the preview engine only.
Flag that condition separately from the other stop failures to prepare
support for more fatal errors.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] omap3isp: Cancel streaming when a fatal error occurs
Laurent Pinchart [Mon, 9 Dec 2013 14:36:51 +0000 (11:36 -0300)]
upstream: [media] omap3isp: Cancel streaming when a fatal error occurs

When a fatal error that prevents any further video streaming occurs in a
pipeline, all queued buffers must be marked as erroneous and new buffers
must be prevented from being queued. Implement this behaviour with a new
omap3isp_pipeline_cancel_stream() function that can be used by
submodules to cancel streaming.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] export em28xx_release_resources() symbol
Mauro Carvalho Chehab [Tue, 7 Jan 2014 10:05:01 +0000 (08:05 -0200)]
upstream: [media] export em28xx_release_resources() symbol

As reported by the kbuild test robot:

All error/warnings:

>> ERROR: "em28xx_release_resources" [drivers/media/usb/em28xx/em28xx-v4l.ko] undefined!

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] media: Remove OOM message after input_allocate_device
Joe Perches [Wed, 23 Oct 2013 19:14:51 +0000 (16:14 -0300)]
upstream: [media] media: Remove OOM message after input_allocate_device

Emitting an OOM message isn't necessary after input_allocate_device
as there's a generic OOM and a dump_stack already done.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] fix coccinelle warnings
Fengguang Wu [Fri, 20 Dec 2013 10:16:47 +0000 (07:16 -0300)]
upstream: [media] fix coccinelle warnings

drivers/staging/media/bcm2048/radio-bcm2048.c:2255:3-4: Unneeded semicolon

 Removes unneeded semicolon.

Generated by: coccinelle/misc/semicolon.cocci

CC: Hans Verkuil <hans.verkuil@cisco.com>
CC: Mauro Carvalho Chehab <m.chehab@samsung.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] fix coccinelle warnings
Fengguang Wu [Fri, 20 Dec 2013 10:16:42 +0000 (07:16 -0300)]
upstream: [media] fix coccinelle warnings

drivers/staging/media/bcm2048/radio-bcm2048.c:2632:1-7: Replace memcpy with struct assignment
/c/kernel-tests/src/cocci/drivers/staging/media/bcm2048/radio-bcm2048.c:744:1-7: Replace memcpy with struct assignment
/c/kernel-tests/src/cocci/drivers/staging/media/bcm2048/radio-bcm2048.c:2360:3-9: Replace memcpy with struct assignment

Generated by: coccinelle/misc/memcpy-assign.cocci

CC: Hans Verkuil <hans.verkuil@cisco.com>
CC: Mauro Carvalho Chehab <m.chehab@samsung.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] saa7134: don't set vfd->debug
Hans Verkuil [Sat, 14 Dec 2013 11:28:37 +0000 (08:28 -0300)]
upstream: [media] saa7134: don't set vfd->debug

You can set this through sysfs, so don't mix the two.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] saa6588: add support for non-blocking mode
Hans Verkuil [Sat, 14 Dec 2013 11:28:36 +0000 (08:28 -0300)]
upstream: [media] saa6588: add support for non-blocking mode

saa6588 always blocked while waiting for data, even if the filehandle
was in non-blocking mode.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] saa6588: remove unused CMD_OPEN
Hans Verkuil [Sat, 14 Dec 2013 11:28:35 +0000 (08:28 -0300)]
upstream: [media] saa6588: remove unused CMD_OPEN

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] saa6752hs: drop compat control code
Hans Verkuil [Sat, 14 Dec 2013 11:28:30 +0000 (08:28 -0300)]
upstream: [media] saa6752hs: drop compat control code

The saa7134 driver is now converted to the control framework, so drop the
control compat code in saa6752hs.c.

Also add 'const' to several static arrays.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] saa7134: use V4L2_IN_ST_NO_SIGNAL instead of NO_SYNC
Hans Verkuil [Sat, 14 Dec 2013 11:28:29 +0000 (08:28 -0300)]
upstream: [media] saa7134: use V4L2_IN_ST_NO_SIGNAL instead of NO_SYNC

NO_SYNC was meant for DVB and shouldn't be used anymore.

In this case NO_SIGNAL is a good alternative.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] DocBook: drop the word 'only'
Hans Verkuil [Fri, 13 Dec 2013 16:13:46 +0000 (13:13 -0300)]
upstream: [media] DocBook: drop the word 'only'

There are already video output drivers that allow STREAMON without
any buffers queued, and with the change in vb2 there are now more
drivers like that.

So saying "The ioctl will succeed only when at least one output
buffer is in the incoming queue." isn't true. Just drop the word
'only'. We cannot say that it will also work if no output buffers are
queued as long as not all drivers are converted to vb2.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] vb2: Improve file I/O emulation to handle buffers in any order
Hans Verkuil [Fri, 13 Dec 2013 16:13:45 +0000 (13:13 -0300)]
upstream: [media] vb2: Improve file I/O emulation to handle buffers in any order

videobuf2 file I/O emulation assumed that buffers dequeued from the
driver would return in the order they were enqueued in the driver.

Improve the file I/O emulator's book-keeping to remove this assumption.

Also set the buf->size properly if a write() dequeues a buffer and the
VB2_FILEIO_WRITE_IMMEDIATELY flag is set.

Based on an initial patch by Andy Walls.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Andy Walls <awalls@md.metrocast.net>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] vb2: return ENOBUFS in start_streaming in case of too few buffers
Hans Verkuil [Fri, 13 Dec 2013 16:13:44 +0000 (13:13 -0300)]
upstream: [media] vb2: return ENOBUFS in start_streaming in case of too few buffers

This works together with the retry_start_streaming mechanism to allow userspace
to start streaming even if not all required buffers have been queued.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Cc: Tomasz Stanislawski <t.stanislaws@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Kamil Debski <k.debski@samsung.com>
Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] vb2: don't set index, don't start streaming for write()
Hans Verkuil [Fri, 13 Dec 2013 16:13:43 +0000 (13:13 -0300)]
upstream: [media] vb2: don't set index, don't start streaming for write()

Two fixes:

- there is no need to set the index when calling dqbuf: dqbuf will
  overwrite it.
- __vb2_init_fileio already starts streaming for write(), so there is
  no need to do it again in __vb2_perform_fileio. It can never have
  worked anyway: either __vb2_init_fileio succeeds in starting streaming
  or it is never going to happen.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] vb2: retry start_streaming in case of insufficient buffers
Hans Verkuil [Fri, 13 Dec 2013 16:13:42 +0000 (13:13 -0300)]
upstream: [media] vb2: retry start_streaming in case of insufficient buffers

If start_streaming returns -ENOBUFS, then it will be retried the next time
a buffer is queued. This means applications no longer need to know how many
buffers need to be queued before STREAMON can be called. This is particularly
useful for output stream I/O.

If a DMA engine needs at least X buffers before it can start streaming, then
for applications to get a buffer out as soon as possible they need to know
the minimum number of buffers to queue before STREAMON can be called. You can't
just try STREAMON after every buffer since on failure STREAMON will dequeue
all your buffers. (Is that a bug or a feature? Frankly, I'm not sure).

This patch simplifies applications substantially: they can just call STREAMON
at the beginning and then start queuing buffers and the DMA engine will
kick in automagically once enough buffers are available.

This also fixes using write() to stream video: the fileio implementation
calls streamon without having any queued buffers, which will fail today for
any driver that requires a minimum number of buffers.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] vb2: remove the 'fileio = NULL' hack
Hans Verkuil [Fri, 13 Dec 2013 16:13:41 +0000 (13:13 -0300)]
upstream: [media] vb2: remove the 'fileio = NULL' hack

The read/write implementation in vb2 reuses existing vb2 functions, but
it sets q->fileio to NULL before calling them in order to skip the
'q->fileio != NULL' check.

This works today due to the synchronous nature of read/write, but it
1) is ugly, and 2) will fail in an asynchronous use-case such as a
thread queuing and dequeuing buffers. This last example will be necessary
in order to implement vb2 DVB support.

This patch removes the hack by splitting up the dqbuf/qbuf/streamon/streamoff
functions into an external and an internal version. The external version
checks q->fileio and then calls the internal version. The read/write
implementation now just uses the internal version, removing the need to
set q->fileio to NULL.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] vb2: fix race condition between REQBUFS and QBUF/PREPARE_BUF
Hans Verkuil [Fri, 13 Dec 2013 16:13:40 +0000 (13:13 -0300)]
upstream: [media] vb2: fix race condition between REQBUFS and QBUF/PREPARE_BUF

When preparing a buffer the queue lock is released for a short while
if the memory mode is USERPTR (see __buf_prepare for the details), which
would allow a race with a REQBUFS which can free the buffers. Removing the
buffers from underneath __buf_prepare is obviously a bad idea, so we
check if any of the buffers is in the state PREPARING, and if so we
just return -EAGAIN.

If this happens, then the application does something really strange. The
REQBUFS call can be retried safely, since this situation is transient.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] vb2: simplify qbuf/prepare_buf by removing callback
Hans Verkuil [Fri, 13 Dec 2013 16:13:39 +0000 (13:13 -0300)]
upstream: [media] vb2: simplify qbuf/prepare_buf by removing callback

The callback used to merge the common code of the qbuf/prepare_buf
code can be removed now that the mmap_sem handling is pushed down to
__buf_prepare(). This makes the code more readable.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] videobuf2: Fix CodingStyle
Mauro Carvalho Chehab [Tue, 7 Jan 2014 09:03:09 +0000 (07:03 -0200)]
upstream: [media] videobuf2: Fix CodingStyle

Changeset b18a8ff29d80 added a comment violating the 80cols max size,
with no good reason.

Fix it.

Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] vb2: push the mmap semaphore down to __buf_prepare()
Hans Verkuil [Fri, 13 Dec 2013 16:13:38 +0000 (13:13 -0300)]
upstream: [media] vb2: push the mmap semaphore down to __buf_prepare()

Rather than taking the mmap semaphore at a relatively high-level function,
push it down to the place where it is really needed.

It was placed in vb2_queue_or_prepare_buf() to prevent racing with other
vb2 calls. The only way I can see that a race can happen is when two
threads queue the same buffer. The solution for that it to introduce
a PREPARING state.

Moving it down offers opportunities to simplify the code.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] v4l: ti-vpe: Add a type specifier to describe vpdma data format...
Archit Taneja [Thu, 12 Dec 2013 08:36:04 +0000 (05:36 -0300)]
upstream: [media] v4l: ti-vpe: Add a type specifier to describe vpdma data format type

The struct vpdma_data_format holds the color format depth and the data_type
value needed to be programmed in the data descriptors. However, it doesn't
tell what type of color format is it, i.e, whether it is RGB, YUV or Misc.

This information is needed when by vpdma library when forming descriptors. We
modify the depth parameter for the chroma portion of the NV12 format. For this,
we check if the data_type value is C420. This isn't sufficient as there are
many YUV and RGB vpdma formats which have the same data_type value. Hence, we
need to hold the type of the color format for the above case, and possibly more
cases in the future.

Signed-off-by: Archit Taneja <archit@ti.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] Documentation/DocBook/media/v4l: fix typo, s/packet/packed/
Antonio Ospite [Mon, 16 Dec 2013 08:16:46 +0000 (05:16 -0300)]
upstream: [media] Documentation/DocBook/media/v4l: fix typo, s/packet/packed/

Change "packet" to "packed" where the doc is talking about packed data
formats.

Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] Documentation/DocBook/media/v4l/subdev-formats.xml: fix a typo
Antonio Ospite [Mon, 16 Dec 2013 08:16:45 +0000 (05:16 -0300)]
upstream: [media] Documentation/DocBook/media/v4l/subdev-formats.xml: fix a typo

The xref to the v4l2-mbus-pixelcode-yuv8 table gets rendered as "Table
4.22, “YUV Formats”", so use the verb in the third person singular
because it refers to "Table":
  s/list/lists/

Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] cx231xx: fix i2c debug prints
Matthias Schwarzott [Thu, 12 Dec 2013 20:41:10 +0000 (17:41 -0300)]
upstream: [media] cx231xx: fix i2c debug prints

Do not shift the already 7bit i2c address.
Print a message also for write+read transactions.
For write+read, print the read buffer correctly instead of using the write
buffer.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] cx231xx: Add missing selects for MEDIA_SUBDRV_AUTOSELECT
Matthias Schwarzott [Thu, 12 Dec 2013 20:41:09 +0000 (17:41 -0300)]
upstream: [media] cx231xx: Add missing selects for MEDIA_SUBDRV_AUTOSELECT

The two drivers LGDT3305 and TDA18271C2DD were not autoselected, so the
cx231xx_dvb module could not be loaded when MEDIA_SUBDRV_AUTOSELECT=y.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] adv7604: return immediately if the new timings are equal to what...
Mats Randgaard [Thu, 12 Dec 2013 13:13:35 +0000 (10:13 -0300)]
upstream: [media] adv7604: return immediately if the new timings are equal to what is configured

Signed-off-by: Mats Randgaard <matrandg@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] adv7604: set restart_stdi_once flag when signal is lost
Martin Bugge [Thu, 5 Dec 2013 13:34:46 +0000 (10:34 -0300)]
upstream: [media] adv7604: set restart_stdi_once flag when signal is lost

If the restart_stdi_once trick fails to find a valid
format the flag was never reset.

Signed-off-by: Martin Bugge <marbugge@cisco.com>
Cc: Mats Randgaard <matrandg@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] adv7604: adv7604_s_register clean up
Hans Verkuil [Tue, 10 Dec 2013 13:02:43 +0000 (10:02 -0300)]
upstream: [media] adv7604: adv7604_s_register clean up

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] adv7604: support 1366x768 DMT Reduced Blanking
Martin Bugge [Thu, 5 Dec 2013 13:01:17 +0000 (10:01 -0300)]
upstream: [media] adv7604: support 1366x768 DMT Reduced Blanking

Signed-off-by: Martin Bugge <marbugge@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] adv7511: verify EDID header
Martin Bugge [Tue, 17 Dec 2013 12:17:10 +0000 (09:17 -0300)]
upstream: [media] adv7511: verify EDID header

Ignore EDID's where the header is wrong.

Signed-off-by: Martin Bugge <marbugge@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] adv7511: add VIC and audio CTS/N values to log_status
Martin Bugge [Thu, 5 Dec 2013 12:06:29 +0000 (09:06 -0300)]
upstream: [media] adv7511: add VIC and audio CTS/N values to log_status

Improve status logging.

Signed-off-by: Martin Bugge <marbugge@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] adv7511: disable register reset by HPD
Martin Bugge [Thu, 5 Dec 2013 12:02:20 +0000 (09:02 -0300)]
upstream: [media] adv7511: disable register reset by HPD

Whenever the hotplug pin is pulled low the chip resets a whole bunch
of registers. It turns out that this can be turned off on the adv7511.
Do so, as this 'feature' introduces race conditions in setting up
registers, particular when the hotplug pin bounces a lot.

Signed-off-by: Martin Bugge <marbugge@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] ad9389b: retry setup if the state is inconsistent
Martin Bugge [Tue, 10 Dec 2013 12:00:05 +0000 (09:00 -0300)]
upstream: [media] ad9389b: retry setup if the state is inconsistent

Retry setup if the device is powered off when it should be powered on. This
state can be caused by rapid hotplug toggles.

Signed-off-by: Martin Bugge <marbugge@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] ad9389b: remove rx-sense irq dependency
Martin Bugge [Tue, 10 Dec 2013 11:58:13 +0000 (08:58 -0300)]
upstream: [media] ad9389b: remove rx-sense irq dependency

Removed dependency on rx-sense interrupt, it's a leftover from obsolete
code. Removing this simplifies the code.

Signed-off-by: Martin Bugge <marbugge@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] ad9389b: whitespace changes to improve readability
Martin Bugge [Thu, 5 Dec 2013 10:55:42 +0000 (07:55 -0300)]
upstream: [media] ad9389b: whitespace changes to improve readability

Signed-off-by: Martin Bugge <marbugge@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] ad9389b: verify EDID header
Mats Randgaard [Thu, 5 Dec 2013 10:33:08 +0000 (07:33 -0300)]
upstream: [media] ad9389b: verify EDID header

Ignore EDIDs where the header is wrong.

Signed-off-by: Mats Randgaard <matrandg@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: only initialize extensions on the main interface
Mauro Carvalho Chehab [Mon, 6 Jan 2014 08:50:07 +0000 (05:50 -0300)]
upstream: [media] em28xx: only initialize extensions on the main interface

For devices with a separated audio-only interface (em2860), call
em28xx_init_extension() only once.

That fixes a bug with Kworld 305U (eb1a:e305):

    [  658.730715] em2860 #0: V4L2 video device registered as video1
    [  658.730728] em2860 #0: V4L2 VBI device registered as vbi0
    [  658.736907] em2860 #0: Remote control support is not available for this card.
    [  658.736965] em2860 #1: Remote control support is not available for this card.
    [  658.737230] ------------[ cut here ]------------
    [  658.737246] WARNING: CPU: 2 PID: 60 at lib/list_debug.c:36 __list_add+0x8a/0xc0()
    [  658.737256] list_add double add: new=ffff8800a9a40410, prev=ffff8800a9a40410, next=ffffffffa08720d0.
    [  658.737266] Modules linked in: tuner_xc2028 netconsole rc_hauppauge em28xx_rc rc_core tuner_simple tuner_types tda9887 tda8290 tuner tvp5150 msp3400 em28xx_v4l em28xx tveeprom
 v4l2_common fuse ccm nf_conntrack_netbios_ns nf_conntrack_broadcast ipt_MASQUERADE ip6t_REJECT xt_conntrack ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6tabl
e_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw ip6table_filter ip6_tables iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4
nf_nat nf_conntrack iptable_mangle iptable_security bnep iptable_raw vfat fat arc4 iwldvm mac80211 x86_pkg_temp_thermal coretemp kvm_intel nfsd iwlwifi snd_hda_codec_hdmi kvm snd_hda
_codec_realtek snd_hda_intel snd_hda_codec auth_rpcgss nfs_acl cfg80211 lockd snd_hwdep snd_seq btusb sunrpc crc32_pclmul bluetooth crc32c_intel snd_seq_device snd_pcm uvcvideo r8169
 ghash_clmulni_intel videobuf2_vmalloc videobuf2_memops videobuf2_core snd_page_alloc snd_timer snd videodev mei_me iTCO_wdt mii shpchp joydev mei media iTCO_vendor_support lpc_ich m
icrocode soundcore rfkill serio_raw i2c_i801 mfd_core nouveau i915 ttm i2c_algo_bit drm_kms_helper drm i2c_core mxm_wmi wmi video
    [  658.738601] CPU: 2 PID: 60 Comm: kworker/2:1 Not tainted 3.13.0-rc1+ #18
    [  658.738611] Hardware name: SAMSUNG ELECTRONICS CO., LTD. 550P5C/550P7C/SAMSUNG_NP1234567890, BIOS P04ABI.013.130220.dg 02/20/2013
    [  658.738624] Workqueue: events request_module_async [em28xx]
    [  658.738646]  0000000000000009 ffff8802209dfc68 ffffffff816a3c96 ffff8802209dfcb0
    [  658.738700]  ffff8802209dfca0 ffffffff8106aaad ffff8800a9a40410 ffffffffa08720d0
    [  658.738754]  ffff8800a9a40410 0000000000000000 0000000000000080 ffff8802209dfd00
    [  658.738814] Call Trace:
    [  658.738836]  [<ffffffff816a3c96>] dump_stack+0x45/0x56
    [  658.738851]  [<ffffffff8106aaad>] warn_slowpath_common+0x7d/0xa0
    [  658.738864]  [<ffffffff8106ab1c>] warn_slowpath_fmt+0x4c/0x50
    [  658.738880]  [<ffffffffa0868a7d>] ? em28xx_init_extension+0x1d/0x80 [em28xx]
    [  658.738898]  [<ffffffff81343b8a>] __list_add+0x8a/0xc0
    [  658.738911]  [<ffffffffa0868a98>] em28xx_init_extension+0x38/0x80 [em28xx]
    [  658.738927]  [<ffffffffa086a059>] request_module_async+0x19/0x110 [em28xx]
    [  658.738942]  [<ffffffff810873b5>] process_one_work+0x1f5/0x510
    [  658.738954]  [<ffffffff81087353>] ? process_one_work+0x193/0x510
    [  658.738967]  [<ffffffff810880bb>] worker_thread+0x11b/0x3a0
    [  658.738979]  [<ffffffff81087fa0>] ? manage_workers.isra.24+0x2b0/0x2b0
    [  658.738992]  [<ffffffff8108ea2f>] kthread+0xff/0x120
    [  658.739005]  [<ffffffff8108e930>] ? kthread_create_on_node+0x250/0x250
    [  658.739017]  [<ffffffff816b517c>] ret_from_fork+0x7c/0xb0
    [  658.739029]  [<ffffffff8108e930>] ? kthread_create_on_node+0x250/0x250
    [  658.739040] ---[ end trace c1acd24b354108de ]---
    [  658.739051] em2860 #1: Remote control support is not available for this card.
    [  658.742407] em28xx-audio.c: probing for em28xx Audio Vendor Class
    [  658.742429] em28xx-audio.c: Copyright (C) 2006 Markus Rechberger
    [  658.742440] em28xx-audio.c: Copyright (C) 2007-2011 Mauro Carvalho Chehab
    [  658.744798] em28xx-audio.c: probing for em28xx Audio Vendor Class
    [  658.744823] em28xx-audio.c: Copyright (C) 2006 Markus Rechberger
    [  658.744836] em28xx-audio.c: Copyright (C) 2007-2011 Mauro Carvalho Chehab
    [  658.746849] em28xx-audio.c: probing for em28xx Audio Vendor Class
    [  658.746863] em28xx-audio.c: Copyright (C) 2006 Markus Rechberger
    [  658.746874] em28xx-audio.c: Copyright (C) 2007-2011 Mauro Carvalho Chehab
    ...

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: prevent registering wrong interfaces for audio-only
Mauro Carvalho Chehab [Mon, 6 Jan 2014 08:27:47 +0000 (05:27 -0300)]
upstream: [media] em28xx: prevent registering wrong interfaces for audio-only

A few devices (em2860) use a separate interface for audio only
Audio Vendor Class USB. That interface should not be used by
Remote Controller, Analog TV or Digital TV.

Prevents initializing all non-audio extensions for the audio
only interface.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: unify module version
Mauro Carvalho Chehab [Fri, 27 Dec 2013 14:14:59 +0000 (11:14 -0300)]
upstream: [media] em28xx: unify module version

Use the same module version on all em28xx sub-modules, and use
the same naming convention to describe the driver.

Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: check if a device has audio earlier
Mauro Carvalho Chehab [Fri, 27 Dec 2013 03:16:13 +0000 (00:16 -0300)]
upstream: [media] em28xx: check if a device has audio earlier

Better to split chipset detection from the audio setup. So, move the
detection code to em28xx_init_dev().

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: improve extension information messages
Mauro Carvalho Chehab [Thu, 26 Dec 2013 15:41:03 +0000 (12:41 -0300)]
upstream: [media] em28xx: improve extension information messages

Add a message with consistent prints before and after each
extension initialization, and provide a better text for module
load.

While here, add a missing sanity check for extension finish
code at em28xx-v4l extension.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: make em28xx-video to be a separate module
Mauro Carvalho Chehab [Sun, 22 Dec 2013 16:27:02 +0000 (13:27 -0300)]
upstream: [media] em28xx: make em28xx-video to be a separate module

Now that all analog-specific code are at em28xx-video, convert
it into an em28xx extension and load it as a separate module.

Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Tested-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: unregister i2c bus 0 if bus 1 fails to register
Mauro Carvalho Chehab [Sun, 5 Jan 2014 11:43:40 +0000 (08:43 -0300)]
upstream: [media] em28xx: unregister i2c bus 0 if bus 1 fails to register

Fix the error handling logic, making it to unregister i2c bus 0, in
case of a failure to register the second bus.

Reported-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx: move analog-specific init to em28xx-video
Mauro Carvalho Chehab [Sun, 22 Dec 2013 16:16:49 +0000 (13:16 -0300)]
upstream: [media] em28xx: move analog-specific init to em28xx-video

There are several init code inside em28xx-cards that are actually
part of analog initialization. Move the code to em28x-video, in
order to remove part of the mess.

In thesis, no functional changes so far.

Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>