[media] airspy: fix error handling on start streaming

Free all reserved USB buffers and URBs on failure. Return all queued
buffers to vb2 with state queued on error case.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] airspy: coding style issues

Fix issues reported by checkpatch.pl.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] airspy: logging changes

Kernel logging system needs pointer to usb interface device in
order to print names and bus numbers properly. There was wrong
device pointer given and log printings wasn't correct.

Remove some debug logging from v4l2 ioctl functions. v4l2 core debug
prints almost same information when enabled.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] airspy: remove unneeded spinlock irq flags initialization

There is no need to init flags before calling spin_lock_irqsave().
spin_lock_irqsave is a macro which stores value to 'flags'.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] airspy: enhance sample rate debug calculation precision

Sample rate calculation gives a little bit too large results because
in real life there was around one milliseconds (~one usb packet) too
much data for given time. Calculate time more accurate in order to
provide better results.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] msi2500: logging changes

Kernel logging system needs pointer to usb interface device in
order to print names and bus numbers properly. There was wrong
device pointer given and log printings wasn't correct.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] msi001: logging changes

Remove function name from debug logs. Logging system could add it
automatically.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] msi2500: remove unneeded spinlock irq flags initialization

There is no need to init flags before calling spin_lock_irqsave().
spin_lock_irqsave is macro which stores value to 'flags'.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] e4000: logging changes

Remove function name from debug logs. Logging system could add it
automatically.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] rtl2832_sdr: remove unneeded spinlock irq flags initialization

There is no need to init flags before calling spin_lock_irqsave().
spin_lock_irqsave is macro which stores value to 'flags'

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] rtl2832_sdr: enhance sample rate debug calculation precision

Sample rate calculation gives a little bit too large results because
in real life there was around one milliseconds (~one usb packet) too
much data for given time. Calculate time more accurate in order to
provide better results.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] rtl2832_sdr: logging changes

Remove function name from debug logs. Logging system could add it
automatically.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] si2157: change command for sleep

Instead of sending command 13 to the tuner, send command 16 when sleeping. This
behaviour is observed when using manufacturer provided binary-only Linux driver
for TechnoTrend CT2-4400 (Windows driver does not do power management).

The issue with command 13 is that firmware loading is necessary after that.
This is not an issue with tuners that do not require firmware, but starting
streaming after sleep on an Si2158 takes noticeable time as firmware is
loaded on resume.

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] si2157: avoid firmware loading if it has been loaded previously

Add a variable into state to keep track if firmware has been loaded or not.
Skip firmware loading in case it is already loaded (resume from sleep).

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] si2168: avoid firmware loading if it has been loaded previously

Add a variable to keep track if firmware is loaded or not and skip parts of the
initialization if fw is already loaded. Resume from sleep with a different
command compared to initial power up and run command 85 after resume command.
This behaviour is observed when using manufacturer provided binary-only si2168
driver for TechnoTrend CT2-4400.

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] tda18212: add support for slave chip version

There is 2 different versions of that chip available, master and
slave. Slave is used only on dual tuner devices with master tuner.
Laser printing top of chip is 18212/M or 18212/S according to chip
version.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] coda: coda-bit: Include "<linux/slab.h>"

coda-bit uses kmalloc/kfree functions, so the slab header needs to be included
in order to fix the following build errors:

drivers/media/platform/coda/coda-bit.c: In function 'coda_fill_bitstream':
drivers/media/platform/coda/coda-bit.c:231:4: error: implicit declaration of function 'kmalloc' [-Werror=implicit-function-declaration]
drivers/media/platform/coda/coda-bit.c: In function 'coda_alloc_framebuffers':
drivers/media/platform/coda/coda-bit.c:312:3: error: implicit declaration of function 'kfree' [-Werror=implicit-function-declaration]

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] get_dvb_firmware: Update firmware of ITEtech IT9135

IT9135 firmware update.

Signed-off-by: Bimow Chen <Bimow.Chen@ite.com.tw>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] af9033: provide dyn0_clk clock source

AF903x/IT913x demod provides clock source(s). It seems that this
clock source is used for integrated RF tuner of IT913x. It is
enabled by default, but firmware disables it automatically when
suspend is requested (suspend_flag (0x004c) + trigger_ofsm
(0x0000)). Automatic disable behavior seems to be similar for both
AF903x and IT913x I tested, though there is no likely any real
clock user in a case of AF903x.

Cc: Bimow Chen <Bimow.Chen@ite.com.tw>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] af9035: enable AF9033 demod clock source for IT9135

Integrated RF tuner of IT9135 is connected to demod clock source
named dyn0_clk. Enable that clock source in order to provide stable
clock early enough.

Cc: Bimow Chen <Bimow.Chen@ite.com.tw>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>