platform/kernel/linux-3.10.git
9 years agoupstream: [media] tda10071: do not check tuner PLL lock on read_status()
Antti Palosaari [Tue, 11 Feb 2014 03:17:37 +0000 (00:17 -0300)]
upstream: [media] tda10071: do not check tuner PLL lock on read_status()

Tuner PLL lock flag was mapped to FE_HAS_SIGNAL, which is wrong. PLL
lock has nothing to do with received signal. In real life that flag
is always set.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] tda10071: remove a duplicative test
Dan Carpenter [Thu, 30 Jan 2014 12:00:34 +0000 (09:00 -0300)]
upstream: [media] tda10071: remove a duplicative test

"ret" is an error code here, we already tested that.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Antti Palosaari <crope@iki.fi>
Reviewed-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] rtl28xxu: add ID [0ccd:00b4] TerraTec NOXON DAB Stick (rev 3)
Till Dörges [Tue, 11 Feb 2014 20:27:57 +0000 (17:27 -0300)]
upstream: [media] rtl28xxu: add ID [0ccd:00b4] TerraTec NOXON DAB Stick (rev 3)

I've got the following DAB USB stick that also works fine with the
DVB_USB_RTL28XXU driver after I added its USB ID:
Bus 001 Device 009: ID 0ccd:00b4 TerraTec Electronic GmbH

[crope@iki.fi: apply patch partly manually]
Signed-off-by: Till Dörges <till@doerges.net>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: dma-buf: avoid using IS_ERR_OR_NULL
Colin Cross [Sat, 21 Dec 2013 00:43:50 +0000 (16:43 -0800)]
upstream: dma-buf: avoid using IS_ERR_OR_NULL

dma_buf_map_attachment and dma_buf_vmap can return NULL or
ERR_PTR on a error.  This encourages a common buggy pattern in
callers:
sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
if (IS_ERR_OR_NULL(sgt))
                return PTR_ERR(sgt);

This causes the caller to return 0 on an error.  IS_ERR_OR_NULL
is almost always a sign of poorly-defined error handling.

This patch converts dma_buf_map_attachment to always return
ERR_PTR, and fixes the callers that incorrectly handled NULL.
There are a few more callers that were not checking for NULL
at all, which would have dereferenced a NULL pointer later.
There are also a few more callers that correctly handled NULL
and ERR_PTR differently, I left those alone but they could also
be modified to delete the NULL check.

This patch also converts dma_buf_vmap to always return NULL.
All the callers to dma_buf_vmap only check for NULL, and would
have dereferenced an ERR_PTR and panic'd if one was ever
returned. This is not consistent with the rest of the dma buf
APIs, but matches the expectations of all of the callers.

Signed-off-by: Colin Cross <ccross@android.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoupstream: [media, edac] Change my email address
Mauro Carvalho Chehab [Fri, 7 Feb 2014 10:03:07 +0000 (08:03 -0200)]
upstream: [media, edac] Change my email address

There are several left overs with my old email address.
Remove their occurrences and add myself at CREDITS, to
allow people to be able to reach me on my new addresses.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] nuvoton-cir: Don't touch PS/2 interrupts while initializing
Antti Seppälä [Sat, 25 Jan 2014 09:57:46 +0000 (06:57 -0300)]
upstream: [media] nuvoton-cir: Don't touch PS/2 interrupts while initializing

There are reports[1] that on some motherboards loading the nuvoton-cir
disables PS/2 keyboard input. This is caused by an erroneous write of
CIR_INTR_MOUSE_IRQ_BIT to ACPI control register.

According to datasheet the write enables mouse power management event
interrupts which will probably have ill effects if the motherboard has
only one PS/2 port with keyboard in it.

The cir hardware does not need mouse interrupts to function and should
not touch them. This patch removes the illegal writes and registry
definitions.

[1] http://ubuntuforums.org/showthread.php?t=2106277&p=12461912&mode=threaded#post12461912

Reported-by: Bruno Maire <bruno.maire@besonet.ch>
Tested-by: Bruno Maire <bruno.maire@besonet.ch>
Signed-off-by: Antti Seppälä <a.seppala@gmail.com>
Acked-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] cx23885: Fix tuning regression for TeVii S471
Joakim Hernberg [Fri, 31 Jan 2014 10:15:48 +0000 (07:15 -0300)]
upstream: [media] cx23885: Fix tuning regression for TeVii S471

When tuning to 10818V on Astra 28E2, the system tunes to 11343V
instead. This is a regression in the S471 driver introduced with the
changeset: b43ea8068d2090cb1e44632c8a938ab40d2c7419 [media] cx23885:
Fix TeVii S471 regression since introduction of ts2020.

Suggested-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Signed-off-by: Joakim Hernberg <jhernberg@alchemy.lu>
Tested-by: Mark Clarkstone <hello@markclarkstone.co.uk>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] mceusb: improve error logging
Sean Young [Mon, 20 Jan 2014 22:10:44 +0000 (19:10 -0300)]
upstream: [media] mceusb: improve error logging

A number of recent bug reports involve usb_submit_urb() failing which was
only reported with debug parameter on. In addition, remove custom debug
function.

[m.chehab@samsung.com: patch rebased, as one of the patches on this
 series need changes]
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] iguanair: simplify tx loop
Sean Young [Mon, 20 Jan 2014 22:10:39 +0000 (19:10 -0300)]
upstream: [media] iguanair: simplify tx loop

Make the code simpler.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] iguanair: explain tx carrier setup
Sean Young [Mon, 20 Jan 2014 22:10:38 +0000 (19:10 -0300)]
upstream: [media] iguanair: explain tx carrier setup

Just comments. No functional changes.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] em28xx-i2c: fix the error code for unknown errors
Frank Schaefer [Sun, 19 Jan 2014 21:48:35 +0000 (18:48 -0300)]
upstream: [media] em28xx-i2c: fix the error code for unknown errors

Commit e63b009d6e "em28xx-i2c: Fix error code for I2C error transfers"
changed the code to return -ETIMEDOUT on all unknown errors.
But the proper error code for unknown errors is -EIO.
So only report -ETIMEDOUT in case of the errors 0x02 and 0x04, which
are according to Mauro Carvalho Chehab's tests related to i2c clock
stretching and return -EIO for the rest.

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-i2c: fix the i2c error description strings for -ENXIO
Frank Schaefer [Sun, 19 Jan 2014 21:48:34 +0000 (18:48 -0300)]
upstream: [media] em28xx-i2c: fix the i2c error description strings for -ENXIO

Commit d845fb3ae5 "em28xx-i2c: add timeout debug information if i2c_debug enabled"
has added wrong error descriptions for -ENXIO.
The strings are also missing terminating newline characters, which breaks the
output format.

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: do not call em28xx_init_camera() if the device has...
Frank Schaefer [Fri, 17 Jan 2014 17:45:32 +0000 (14:45 -0300)]
upstream: [media] em28xx-v4l: do not call em28xx_init_camera() if the device has no sensor

This avoids the unnecessary temporary registration of a dummy V4L2 clock.

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-camera: fix return value checks on sensor probing
Frank Schaefer [Fri, 17 Jan 2014 17:45:31 +0000 (14:45 -0300)]
upstream: [media] em28xx-camera: fix return value checks on sensor probing

Since commit e63b009d6e the returned error code in case of not connected/responding
i2c clients is ENXIO isntead of ENODEV, which causes several error messages on
sensor probing.
Fix the i2c return value checks on sensor probing to silence these warnings.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] media: rc: add raw decoder for Sharp protocol
James Hogan [Fri, 17 Jan 2014 13:58:48 +0000 (10:58 -0300)]
upstream: [media] media: rc: add raw decoder for Sharp protocol

Add a raw decoder for the Sharp protocol. It uses a pulse distance
modulation with a pulse of 320us and a bit period of 2ms for a logical 1
and 1ms for a logical 0. The first part of the message consists of a
5-bit address, an 8-bit command, and two other bits, followed by a 40ms
gap before the echo message which is an inverted version of the main
message except for the address bits.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: linux-media@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] media: rc: add Sharp infrared protocol
James Hogan [Fri, 17 Jan 2014 13:58:47 +0000 (10:58 -0300)]
upstream: [media] media: rc: add Sharp infrared protocol

Add Sharp infrared protocol constants RC_TYPE_SHARP and RC_BIT_SHARP.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] media: rc: only turn on LED if keypress generated
James Hogan [Thu, 16 Jan 2014 22:56:22 +0000 (19:56 -0300)]
upstream: [media] media: rc: only turn on LED if keypress generated

Since v3.12, specifically 153a60bb0fac ([media] rc: add feedback led
trigger for rc keypresses), an LED trigger is activated on IR keydown
whether or not a keypress is generated (i.e. even if there's no matching
keycode). However the repeat and keyup logic isn't used unless there is
a keypress, which results in non-keypress keydown events turning on the
LED and not turning it off again.

On the assumption that the intent was for the LED only to light up on
valid key presses (you probably don't want it lighting up for the wrong
remote control for example), move the led_trigger_event() call inside
the keycode check.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Acked-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] FE_READ_SNR and FE_READ_SIGNAL_STRENGTH docs
Georgi Chorbadzhiyski [Thu, 16 Jan 2014 15:07:11 +0000 (12:07 -0300)]
upstream: [media] FE_READ_SNR and FE_READ_SIGNAL_STRENGTH docs

Around 01/14/2014 06:07 PM, Mauro Carvalho Chehab scribbled:
> Em Tue, 14 Jan 2014 17:55:19 +0200
> Georgi Chorbadzhiyski <gf@unixsol.org> escreveu:
>> Around 01/14/2014 05:30 PM, Mauro Carvalho Chehab scribbled:
>>> Em Tue, 14 Jan 2014 17:16:10 +0200
>>> Georgi Chorbadzhiyski <gf@unixsol.org> escreveu:
>>>
>>>> Hi guys, I'm confused the documentation on:
>>>>
>>>> http://linuxtv.org/downloads/v4l-dvb-apis/frontend_fcalls.html#FE_READ_SNR
>>>> http://linuxtv.org/downloads/v4l-dvb-apis/frontend_fcalls.html#FE_READ_SIGNAL_STRENGTH
>>>>
>>>> states that these ioctls return int16_t values but frontend.h states:
>>>>
>>>> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/dvb/frontend.h
>>>>
>>>> #define FE_READ_SIGNAL_STRENGTH  _IOR('o', 71, __u16)
>>>> #define FE_READ_SNR              _IOR('o', 72, __u16)
>>>>
>>>> So which one is true?
>>>
>>> Documentation is wrong. The returned values are unsigned. Would you mind send
>>> us a patch fixing it?
>>
>> I would be happy to, but I can't find the repo that holds the documentation.
>
> It is in the Kernel tree, under Documentation/DocBook/media/dvb.

The attached file contains the discussed documentation fixes.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] DocBook media: drop the old incorrect packed RGB table
Hans Verkuil [Tue, 7 Jan 2014 13:01:27 +0000 (10:01 -0300)]
upstream: [media] DocBook media: drop the old incorrect packed RGB table

The old table is most definitely wrong. All applications and all
drivers that I have ever tested follow the corrected table. Furthermore,
that's what all applications expect as well. Any drivers that do not
follow the corrected table are broken and should be fixed.

This patch drops the old table and replaces it with the corrected
table. This should prevent a lot of confusion.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] DocBook media: update three sections of common.xml
Hans Verkuil [Tue, 7 Jan 2014 12:39:57 +0000 (09:39 -0300)]
upstream: [media] DocBook media: update three sections of common.xml

Updates for the "Tuners and Modulators", "Video Standards" and
"Digital Video (DV) Timings" sections.

Besides lots of trivial little fixes the main changes are:

- Remove two footnotes from "Video Standards": the first is a discussion
  of alternative methods of setting standards, which is pretty pointless
  since the standards API is effectively frozen anyway, and the second
  points to 'rationale' that makes little or no sense to me.

- Clarify a few things in the "Digital Video (DV) Timings" section.
  It was awkwardly formatted as well: there used to be a list with
  multiple bullets that has been reduced to a single item, so drop the
  list and rewrite that text.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] DocBook media: Cleanup some sections at common.xml
Hans Verkuil [Tue, 7 Jan 2014 11:17:35 +0000 (08:17 -0300)]
upstream: [media] DocBook media: Cleanup some sections at common.xml

Updates sections "Querying Capabilities", "Application Priority",
"Video Inputs and Outputs" and "Audio Inputs and Outputs".

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] DocBook media: update copyright years and Introduction
Hans Verkuil [Tue, 7 Jan 2014 09:46:37 +0000 (06:46 -0300)]
upstream: [media] DocBook media: update copyright years and Introduction

It's now 2014, so update those copyright years. Also fix a typo in the introduction
and mention that this document also covers output, codec and remote control
devices.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] v4l2-dv-timings.h: add new 4K DMT resolutions
Hans Verkuil [Fri, 31 Jan 2014 13:32:15 +0000 (10:32 -0300)]
upstream: [media] v4l2-dv-timings.h: add new 4K DMT resolutions

VESA added two new DMT timings in their latest standard document. Add these
to v4l2-dv-timings.h.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] s2255drv: checkpatch fix: coding style fix
sensoray-dev [Wed, 29 Jan 2014 18:24:07 +0000 (15:24 -0300)]
upstream: [media] s2255drv: checkpatch fix: coding style fix

Fixes all style warnings from scripts/checkpatch -f

Signed-off-by: Dean Anderson <linux-dev@sensoray.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] radio-keene: Use module_usb_driver
Sachin Kamat [Mon, 27 Jan 2014 11:56:02 +0000 (08:56 -0300)]
upstream: [media] radio-keene: Use module_usb_driver

module_usb_driver eliminates the boilerplate and makes the code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] s3c-camif: Remove use of deprecated V4L2_CTRL_FLAG_DISABLED
Hans Verkuil [Mon, 20 Jan 2014 09:27:09 +0000 (06:27 -0300)]
upstream: [media] s3c-camif: Remove use of deprecated V4L2_CTRL_FLAG_DISABLED

I came across this while checking the kernel use of V4L2_CTRL_FLAG_DISABLED.

This flag should not be used with the control framework. Instead, just don't
add the control at all.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] hdpvr: Fix memory leak in debug
Masanari Iida [Fri, 17 Jan 2014 16:38:00 +0000 (13:38 -0300)]
upstream: [media] hdpvr: Fix memory leak in debug

cppcheck reported memory leak in device_authorizatio()
within hdpvr-core.c.
When the debug option is specified and the code jump to
"unlock:" label, print_buf was not freed.
Confirm the module succesfully compiled without error.

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] mxl111sf: Fix unintentional garbage stack read
Dave Jones [Thu, 30 Jan 2014 03:11:33 +0000 (00:11 -0300)]
upstream: [media] mxl111sf: Fix unintentional garbage stack read

mxl111sf_read_reg takes an address of a variable to write to as an argument.
drivers/media/usb/dvb-usb-v2/mxl111sf-gpio.c:mxl111sf_config_pin_mux_modes
passes several uninitialized stack variables to this routine, expecting
them to be filled in.  In the event that something unexpected happens when
reading from the chip, we end up doing a pr_debug of the value passed in,
revealing whatever garbage happened to be on the stack.

Change the pr_debug to match what happens in the 'success' case, where we
assign buf[1] to *data.

Spotted with Coverity (Bugs 731910 through 731917)

Signed-off-by: Dave Jones <davej@fedoraproject.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] cx24117: use a valid dev pointer for dev_err printout
Andi Shyti [Thu, 30 Jan 2014 03:06:41 +0000 (00:06 -0300)]
upstream: [media] cx24117: use a valid dev pointer for dev_err printout

Don't use '&state->priv->i2c->dev' reference to device because
state is still 'NULL'. Use '&i2c->dev' instead.

This bug has been reported by scan.coverity.com

Signed-off-by: Andi Shyti <andi@etezian.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Cc: vger@stable.kernel.org
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] cx24117: remove dead code in always 'false' if statement
Andi Shyti [Thu, 30 Jan 2014 03:05:01 +0000 (00:05 -0300)]
upstream: [media] cx24117: remove dead code in always 'false' if statement

At this point of the execution in the function cx24117_attach()
demod cannot be '0'. In that case the function returns earlier
with an error value ('NULL'). Remove the if statement.

This error has been reported by scan.coverity.com

Signed-off-by: Andi Shyti <andi@etezian.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] update Michael Krufky's email address
Michael Krufky [Thu, 30 Jan 2014 02:10:11 +0000 (23:10 -0300)]
upstream: [media] update Michael Krufky's email address

I am no longer available at the kernellabs.com or m1k.net email
addresses.  Update each instance of my email to my linuxtv.org
account.

Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
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>