Commit graph

1310 commits

Author SHA1 Message Date
Dan Carpenter 47bdf7c6d6 media: dib8000: remove some bogus dead code
This function is broken.  It sets the wrong front_end to NULL.  But it's
not used, so let's just delete it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-27 08:47:00 -04:00
Dan Carpenter 5af478341f media: dib9000: delete some unused broken code
The dib9000_remove_slave_frontend() function isn't used.

I was reviewing it because my static checker claims it writes one
element beyond the end of the array.  That's a false positive.  What it
actually does is, if there are two or more front ends, then it prints a
debug message to say that it removed the first one, stored in
state->fe[1], and then it "removes" (scare quotes on purpose) the second
one, stored in state->fe[2].  Deleting a front end from the middle is
not really supported and breaks code like dib9000_release() which
assumes the first NULL front end marks the end of the list.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-27 08:46:42 -04:00
Gustavo A. R. Silva 87c0148671 media: dib0090: fix duplicated code for different branches
Refactor code in order to avoid identical code for different branches.

This issue was detected with the help of Coccinelle.

Addresses-Coverity-ID: 1226795

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-27 07:51:30 -04:00
Daniel Scheller c67215263e media: dvb-frontends/stv0367: remove QAM_AUTO from ddb_fe_ops
Since the cab_* codepath doesn't recognize QAM_AUTO, don't announce that
it is supported when it really isn't. Fixes ie. w_scan from
unconditionally using QAM_AUTO on DVB-C scans.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-27 07:01:03 -04:00
Daniel Scheller e5d9ce4dde media: dvb-frontends/stv0910: change minsymrate to 100Ksyms/s
The demodulator supports symbol rates as low as 100Ksyms/s - the demod
setup in start() already handles such low symbol rates and reviewers
of stv0910 equipped cards even found and tested transponders with
SRs in that range. So, announce this in the fe_ops.

Cc: Ralph Metzler <rjkm@metzlerbros.de>
Cc: Richard Scobie <r.scobie@clear.net.nz>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-27 06:42:53 -04:00
Daniel Scheller 6b852620fa media: dvb-frontends/stv0910: release lock on gate_ctrl() failure
Whenever write_reg() fails to open/close the demod's I2C gate, release the
lock to avoid deadlocking situations. If I2c gate open failed, there's no
need to hold a lock, and if close fails, the mutex_unlock() at the end of
the function is never reached, leaving the mutex_lock in locked state,
which in turn will cause potential for deadlocks. Thus, release the lock
on failure.

While we're touching gate_ctrl(), add some explanation about the need for
locking and the shared I2C bus/gate.

Cc: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-27 06:35:13 -04:00
Jemma Denson 214824156c media: isl6421: add checks for current overflow
This Kaffeine's BZ:
	https://bugs.kde.org/show_bug.cgi?id=374693

affects SkyStar S2 PCI DVB-S/S2 rev 3.3 device. It could be due to
a Kernel bug.

While checking the Isil 6421, comparing with its manual, available at:

	http://www.intersil.com/content/dam/Intersil/documents/isl6/isl6421a.pdf

It was noticed that, if the output load is highly capacitive, a different approach
is recomended when energizing the LNBf.

Also, it is possible to detect if a current overload is happening, by checking an
special flag.

Add support for it.

Tested on Skystar S2. Changes respect override_or option so should still work fine
on cx88 based cards which disable dynamic current limit.

Changes since v1:
v2 - fixed incorrect checking of i2c return values
v3 - fix if logic to check if dcl needs re-enabling
   - respect override_or values which aim to disable dcl
   - only do long sleep on overload if dcl enabled
   - add short sleep before re-enabling dcl
   - only check overload and potentially return EINVAL if device is on
v4 - revert v3 sleep logic changes to remove tuning delays

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jemma Denson <jdenson@gmail.com>
2017-08-20 10:20:30 -04:00
Daniel Scheller 7112b490af media: stv6111: return NULL instead of plain integer
Fixes:
  stv6111.c:665:24: warning: Using plain integer as NULL pointer

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 10:15:39 -04:00
Daniel Scheller c16ad5de39 media: stv0910: declare global list_head stvlist static
Cleans up smatch warning:
symbol 'stvlist' was not declared. Should it be static?

Patch originally submitted by Colin Ian King <colin.king@canonical.com>,
remainder after the merge of all other stv0910 fixes.

Cc: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 10:15:34 -04:00
Daniel Scheller 381a28be48 media: dvb-frontends/cxd2841er: update moddesc wrt new chip support
Since the driver now recognizes and supports more chip variants, reflect
this fact in the module description accordingly.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 07:43:43 -04:00
Daniel Scheller 0758ecdbd8 media: dvb-frontends/stv0910: fix mask for scramblingcode setup
The scrambling code has 4 bits. Fix the mask accordingly.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 07:29:54 -04:00
Daniel Scheller f0e72c29fd media: dvb-frontends/stv0910: fix FE_HAS_LOCK check order in tune()
It should first read the status and then check if FE has lock.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 07:29:10 -04:00
Daniel Scheller 3c4e04153f media: dvb-frontends: MaxLinear MxL5xx DVB-S/S2 tuner-demodulator driver
This adds the frontend driver for the MaxLinear MxL5xx family of tuner-
demodulators, as used on Digital Devices MaxS4/8 four/eight-tuner cards.

The driver was picked from the dddvb vendor driver package and - judging
solely from the diff - has undergone a 100% rework:

 - Silly #define's used to pass multiple values to functions were
   expanded. This resulted in macro/register names not being usable
   anymore for such occurences, but makes the code WAY more read-,
   understand- and maintainable.
 - CamelCase was changed to kernel_case
 - All typedef were removed
 - Overall code style was fixed, besides >80char lines in _defs.h and
   _regs.h, checkpatch is happy.
 - Also, signal stat acquisition was made to comply with the DVB API
   ways to do these things.

Permission to reuse and mainline the driver code was formally granted by
Ralph Metzler <rjkm@metzlerbros.de>.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 07:25:09 -04:00
Daniel Scheller 20e671dff9 media: dvb-frontends/stv{0910,6111}: constify tables
Mark lookup tables and fe_ops things const so the compiler can put them
into .rodata.

While at it, improve name and identifier strings (moddesc, fe_ops).

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 07:20:57 -04:00
Daniel Scheller 85e36b47ea media: dvb-frontends/stv6111: cosmetics: comments fixup, misc
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 07:20:28 -04:00
Daniel Scheller 2af07a49dd media: dvb-frontends/stv6111: coding style cleanup
Fix up all remainders reported by checkpatch-strict.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 07:20:04 -04:00
Daniel Scheller 4f979d5cf0 media: dvb-frontends/stv0910: cosmetics: fixup comments, misc
Fix up block comment style, whitespaces, c++ style comments et al.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 07:19:37 -04:00
Daniel Scheller ddb6a90dcd media: dvb-frontends/stv0910: further coding style cleanup
Fixes up all remainders reported by "checkpatch.pl --strict"

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 07:14:09 -04:00
Daniel Scheller 448461af0e media: dvb-frontends/stv0910: implement diseqc_send_burst
This implements the diseqc_send_burst frontend op to support sending
mini-DISEQC bursts. Picked up from dddvb's driver package where this
specific block was disabled via #if 0/#endif, but is still working
according to feedback from upstream, so add it.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 07:13:19 -04:00
Daniel Scheller 399196ed06 media: dvb-frontends/stv0910: fix STR assignment, remove unneeded var
According to the documentation, FE_SCALE_DECIBEL values should be assigned
to .svalue and not .uvalue, so let's do this. While at it, remove the
unneeded strength var from read_signal_strength().

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 07:11:06 -04:00
Gustavo A. R. Silva 488e27ad81 media: dvb-frontends: mb86a16: remove useless variables in signal_det()
Remove useless variables wait_t and wait_sym and code related.

Also, fix some coding style issues.

Addresses-Coverity-ID: 1226947

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 16:29:11 -04:00
Daniel Scheller d105d08344 media: dvb-frontends/stv0367: improve QAM fe_status
While cab_state->state gives a quite accurate indication of the demod
signal status, it might be incorrect if cab_algo() wasn't able to
determine the exact status, with cab_algo() being the only place where
this status was updated from, and it is only called upon tuning to new
parameters passed to set_frontend(). Thus, the status will be wrong
until the demod is retuned. With the cab_signal_type parsing in
read_status(), this results in unusual fe_states like FE_HAS_SIGNAL |
FE_HAS_CARRIER | FE_HAS_LOCK, which, while userspace applications check
for FE_HAS_LOCK and work fine, leads to missing CNR or UCB stats.

Fix this by re-reading CAB_FSM_STATUS and updating cab_state->state() in
read_status(). While at it, refactor the fsm/qamfeclock and the
fsm->signaltype parsing into separate functions to make things cleaner
and deduplicate code. Also, assume full QAM FEC lock equals full
FE_STATUS.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 15:16:48 -04:00
Colin Ian King 6e4e4447d4 media: dib0090: make const array dib0090_tuning_table_cband_7090e_aci static
Don't populate array dib0090_tuning_table_cband_7090e_aci on the stack but
instead make it static. Makes the object code smaller by over 180 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
  40052	   7320	    192	  47564	   b9cc dib0090.o

After:
   text	   data	    bss	    dec	    hex	filename
  39780	   7408	    192	  47380	   b914	dib0090.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 15:08:12 -04:00
Colin Ian King 679cfbb158 media: drxj: make several const arrays static
Don't populate const arrays on the stack but instead make them static.
Makes the object code smaller by over 1800 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
  94100	   9160	      0	 103260	  1935c	drxj.o

After:
   text	   data	    bss	    dec	    hex	filename
  91044	  10400	      0	 101444	  18c44	drxj.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 15:07:50 -04:00
Colin Ian King 7f0337086e media: drxd: make const arrays slowIncrDecLUT and fastIncrDecLUT static
Don't populate arrays slowIncrDecLUT and fastIncrDecLUT on the stack but
instead make them static. Makes the object code smaller by over 100 bytes:

   text	   data	    bss	    dec	    hex	filename
  27776	    832	     64	  28672	   7000	drxd_hard.o

   text	   data	    bss	    dec	    hex	filename
  27530	    976	     64	  28570	   6f9a	drxd_hard.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 15:07:28 -04:00
Daniel Scheller bd2355b8ef media: dvb-frontends/cxd2841er: do sleep on delivery system change
Discovered using w_scan when scanning DVB-T/T2: When w_scan goes from -T
to -T2, it does so without stopping the frontend using .sleep. Due to
this, the demod operation mode isn't re-setup, but as it still is in
STATE_ACTIVE_TC, PLP and T2 Profile are set up, but only retune_active()
is called, leaving the demod in T mode, thus not operable on any T2
frequency.

Fix this by putting the demod to sleep if priv->system isn't equal to
p->delsys. To properly accomplish this, sleep_tc() is split into
sleep_tc() and shutdown_tc(), where sleep_tc() will only perform the
sleep operation, while shutdown_tc() additionally performs the full
demod shutdown (to keep the behaviour when the .sleep FE_OP is called).

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 15:06:45 -04:00
Colin Ian King 3802c1bc2c media: dvb-frontends/cxd2841er: make several arrays static
Don't populate arrays on the stack but make them static.  Makes
the object code smaller:

Before:
   text	   data	    bss	    dec	    hex	filename
  89299	  21704	     64	 111067	  1b1db	cxd2841er.o

After:
   text	   data	    bss	    dec	    hex	filename
  85823	  23432	     64	 109319	  1ab07	cxd2841er.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 15:03:07 -04:00
Gustavo A. R. Silva 6ac8b81ec9 media: cx24123: constify i2c_algorithm structure
Check for i2c_algorithm structures that are only stored in
the algo field of an i2c_adapter structure. This field is
declared const, so i2c_algorithm structures that have this
property can be declared as const also.

This issue was identified using Coccinelle and the following
semantic patch:

@r disable optional_qualifier@
identifier i;
position p;
@@
static struct i2c_algorithm i@p = { ... };

@ok@
identifier r.i;
struct i2c_adapter e;
position p;
@@
e.algo = &i@p;

@bad@
position p != {r.p,ok.p};
identifier r.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct i2c_algorithm i = { ... };

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 14:58:27 -04:00
Gustavo A. R. Silva c51df136e5 media: zd1301_demod: constify i2c_algorithm structure
Check for i2c_algorithm structures that are only stored in
the algo field of an i2c_adapter structure. This field is
declared const, so i2c_algorithm structures that have this
property can be declared as const also.

This issue was identified using Coccinelle and the following
semantic patch:

@r disable optional_qualifier@
identifier i;
position p;
@@
static struct i2c_algorithm i@p = { ... };

@ok@
identifier r.i;
struct i2c_adapter e;
position p;
@@
e.algo = &i@p;

@bad@
position p != {r.p,ok.p};
identifier r.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct i2c_algorithm i = { ... };

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 14:58:10 -04:00
Gustavo A. R. Silva 28e83542cd media: dib8000: constify i2c_algorithm structure
Check for i2c_algorithm structures that are only stored in
the algo field of an i2c_adapter structure. This field is
declared const, so i2c_algorithm structures that have this
property can be declared as const also.

This issue was identified using Coccinelle and the following
semantic patch:

@r disable optional_qualifier@
identifier i;
position p;
@@
static struct i2c_algorithm i@p = { ... };

@ok@
identifier r.i;
struct i2c_adapter e;
position p;
@@
e.algo = &i@p;

@bad@
position p != {r.p,ok.p};
identifier r.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct i2c_algorithm i = { ... };

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 14:57:52 -04:00
Gustavo A. R. Silva 053aa4a833 media: s5h1420: constify i2c_algorithm structure
Check for i2c_algorithm structures that are only stored in
the algo field of an i2c_adapter structure. This field is
declared const, so i2c_algorithm structures that have this
property can be declared as const also.

This issue was identified using Coccinelle and the following
semantic patch:

@r disable optional_qualifier@
identifier i;
position p;
@@
static struct i2c_algorithm i@p = { ... };

@ok@
identifier r.i;
struct i2c_adapter e;
position p;
@@
e.algo = &i@p;

@bad@
position p != {r.p,ok.p};
identifier r.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct i2c_algorithm i = { ... };

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 14:57:35 -04:00
Gustavo A. R. Silva a76f094a47 media: dib7000p: constify i2c_algorithm structure
Check for i2c_algorithm structures that are only stored in
the algo field of an i2c_adapter structure. This field is
declared const, so i2c_algorithm structures that have this
property can be declared as const also.

This issue was identified using Coccinelle and the following
semantic patch:

@r disable optional_qualifier@
identifier i;
position p;
@@
static struct i2c_algorithm i@p = { ... };

@ok@
identifier r.i;
struct i2c_adapter e;
position p;
@@
e.algo = &i@p;

@bad@
position p != {r.p,ok.p};
identifier r.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct i2c_algorithm i = { ... };

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 14:57:19 -04:00
Gustavo A. R. Silva 19779f4052 media: dib9000: constify i2c_algorithm structure
Check for i2c_algorithm structures that are only stored in
the algo field of an i2c_adapter structure. This field is
declared const, so i2c_algorithm structures that have this
property can be declared as const also.

This issue was identified using Coccinelle and the following
semantic patch:

@r disable optional_qualifier@
identifier i;
position p;
@@
static struct i2c_algorithm i@p = { ... };

@ok@
identifier r.i;
struct i2c_adapter e;
position p;
@@
e.algo = &i@p;

@bad@
position p != {r.p,ok.p};
identifier r.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct i2c_algorithm i = { ... };

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 14:53:16 -04:00
Daniel Scheller 3658ea39f9 media: dvb-frontends/stv0367: DDB frontend status inquiry fixup
Return 0 instead of -EINVAL in get_frontend if no demod mode is active.
This fixes ie. dvb-fe-tool getting confused and assuming a DVBv3 FE on idle
frontends when the FE has been put to sleep using sleep().

Also, in read_status(), don't immediately return when no demod is active,
so the remaining code has a chance to clear the signal statistics.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 14:06:56 -04:00
Daniel Scheller 44173fda45 media: dvb-frontends: add ST STV6111 DVB-S/S2 tuner frontend driver
This adds a frontend driver for the ST STV6111 DVB-S/S2 tuners. Like the
stv0910 demod frontend driver, this driver originates from the Digital
Devices' dddvb vendor driver package as of version 0.9.29, and was cleaned
up aswell. No functionality had to be removed though. Any camel case has
been converted to kernel_case, fixup patch has been proposed upstream.

Permission to reuse and mainline the driver code was formally granted by
Ralph Metzler <rjkm@metzlerbros.de>.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Tested-by: Richard Scobie <r.scobie@clear.net.nz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 13:04:25 -04:00
Daniel Scheller 2f4675c003 media: dvb-frontends/stv0910: Add missing set_frontend fe-op
This was missing from the frontend_ops.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Tested-by: Richard Scobie <r.scobie@clear.net.nz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 13:00:09 -04:00
Daniel Scheller 19bb3b718f media: dvb-frontends/stv0910: Add demod-only signal strength reporting
Original code at least has some signed/unsigned issues, resulting in
values like 32dBm. Implement signal strength readout to work without
asking the attached tuner, and use a lookup table instead of log calc.
Values reported appear plausible, gathered from feedback from several
testers.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Tested-by: Richard Scobie <r.scobie@clear.net.nz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 12:59:50 -04:00
Daniel Scheller ea71c62bde media: dvb-frontends/stv0910: add multistream (ISI) and PLS capabilities
Implements stream_id filter and scrambling code setup in start() and also
sets FE_CAN_MULTISTREAM in frontend_ops. This enables the driver to
properly receive and handle multistream transponders, functionality has
been reported working fine by testers with access to such streams, in
conjunction with VDR on the userspace side.

The code snippet originates from the original vendor's dddvb driver
package and has been made working properly with the current in-kernel
DVB core API.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Tested-by: Richard Scobie <r.scobie@clear.net.nz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 12:59:03 -04:00
Daniel Scheller 13c8148962 media: dvb-frontends/stv0910: Fix possible buffer overflow
Fixes smatch error:

  drivers/media/dvb-frontends/stv0910.c:715 dvbs2_nbch() error: buffer overflow 'nbch[fectype]' 2 <= 28

Also, fixes the nbch array table by adding the DUMMY_PLF element at the top
to match the enums (table element order was off by one before).

Patch sent upstream aswell.

Cc: Ralph Metzler <rjkm@metzlerbros.de>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Tested-by: Richard Scobie <r.scobie@clear.net.nz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 12:57:59 -04:00
Daniel Scheller cd21b33494 media: dvb-frontends: add ST STV0910 DVB-S/S2 demodulator frontend driver
This adds a multi frontend driver for the ST STV0910 DVB-S/S2 demodulator
frontends. The driver code originates from the Digital Devices' dddvb
vendor driver package as of version 0.9.29, and has been cleaned up from
core API usage which isn't supported yet in the kernel, and additionally
all obvious style issues have been resolved. All camel case and allcaps
have been converted to kernel_case and lowercase. Patches have been sent
to the vendor package maintainers to fix this aswell. Signal statistics
acquisition has been refactored to comply with standards.

Permission to reuse and mainline the driver code was formally granted by
Ralph Metzler <rjkm@metzlerbros.de>.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Tested-by: Richard Scobie <r.scobie@clear.net.nz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-07-20 12:57:11 -04:00
Mauro Carvalho Chehab 430e29d9c0 media: dvb-frontends/stv0367: Improve DVB-C/T frontend status
The stv0367 driver provide a lot of status on its state machine.
Change the logic to provide more information about frontend locking
status. Also, while any detailed status isn't available, provide a more
complete FE_STATUS for DVB-T.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
2017-06-25 10:48:45 -03:00
Daniel Scheller 006fe8ee88 media: dvb-frontends/stv0367: DVB-C signal strength statistics
Provide QAM/DVB-C signal strength in decibel scale. Values returned from
stv0367cab_get_rf_lvl() are good but need to be multiplied as they're in
1dBm precision.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-25 09:10:44 -03:00
Daniel Scheller 87b4671074 media: dvb-frontends/stv0367: update UCB readout condition logic
Since the other statistics are read when fe_status conditions are TRUE,
change the ucblocks readout logic to match this aswell.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-25 09:10:06 -03:00
Mauro Carvalho Chehab f5a1ba833d media: stv0367: prevent division by zero
While there's a test at the SNR calculus to avoid division by
zero, it will still follow the path that would do the division.
So, add a missing break there.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-25 09:07:45 -03:00
Daniel Scheller d394ad12c2 media: dvb-frontends/stv0367: SNR DVBv5 statistics for DVB-C and T
Add signal-to-noise-ratio as provided by the demodulator in decibel scale.
QAM/DVB-C needs some intlog calculation to have usable dB values, OFDM/
DVB-T values from the demod look alright already and are provided as-is.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-25 09:06:32 -03:00
Daniel Scheller 8982735f8d media: dvb-frontends/cxd2841er: require STATE_ACTIVE_* for agc readout
When the demod driver puts the demod into sleep or shutdown state and it's
status is then polled e.g. via "dvb-fe-tool -m", i2c errors are printed
to the kernel log. If the last delsys was DVB-T/T2:

  cxd2841er: i2c wr failed=-5 addr=6c reg=00 len=1
  cxd2841er: i2c rd failed=-5 addr=6c reg=26

and if it was DVB-C:

  cxd2841er: i2c wr failed=-5 addr=6c reg=00 len=1
  cxd2841er: i2c rd failed=-5 addr=6c reg=49

This happens when read_status unconditionally calls into the
read_signal_strength() function which triggers the read_agc_gain_*()
functions, where these registered are polled.

This isn't a critical thing since when the demod is active again, no more
such errors are logged, however this might make users suspecting defects.

Fix this by requiring STATE_ACTIVE_* in priv->state. If it isn't in any
active state, additionally set the strength scale to NOT_AVAILABLE.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-25 09:05:26 -03:00
Daniel Scheller b138afda3c media: dvb-frontends/stv0367: split SNR determination into functions
The read_snr() functions currently do some magic to return relative scale
values when called. Split out register readouts into separate functions
so the functionality can be reused in some other way.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-24 17:42:47 -03:00
Daniel Scheller 4043eb2325 media: dvb-frontends/stv0367: initial DDB DVBv5 stats, implement ucblocks
This adds the basics to stv0367ddb_read_status() to be able to properly
provide signal statistics in DVBv5 format. Also adds UCB readout and
provides those values. Also, don't return -EINVAL in ddb_read_status()
if active_demod_state indicates no delivery system.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-24 17:42:18 -03:00
Daniel Scheller e1bdf02488 media: dvb-frontends/lnbh25: improve kernellog output
Use dev_dbg() in conjunction with the %*ph format macro to print the vmon
status debug, thus hiding continuous hexdumping from default log levels.
Also, change the attach success log line from error to info severity.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-24 17:05:19 -03:00
Martin Kepplinger e1d00cddfb media: dvb-frontends: drx39xyj: remove obsolete sign extend macros
DRX_S9TOS16 and DRX_S24TODRXFREQ are simply not used. Furthermore,
sign_extend32() should be used for sign extension. (Also, the comment
describing DRX_S24TODRXFREQ was wrong). So remove these macros.

Signed-off-by: Martin Kepplinger <martink@posteo.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-24 16:01:32 -03:00
Mauro Carvalho Chehab 1250a85b1b media: Replace initalized ->initialized
While committing a change on em28xx, I got a warning of a
typo there. So, fix it on em28xx and on two other media drivers
with the same typo.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-24 15:46:24 -03:00
Daniel Scheller f9c1e254e1 media: dvb-frontends/stv0367: deduplicate DDB dvb_frontend_ops caps
Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-24 10:47:18 -03:00
Antti Palosaari cdd19b526f [media] af9013: refactor power control
Move power-up and power-down functionality to init/sleep ops and
get rid of old function.

Fixes and simplifies power-up functionality slightly.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:35:08 -03:00
Antti Palosaari 96700d248e [media] af9013: refactor firmware download routine
Refactor firmware download routine.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:28:37 -03:00
Antti Palosaari b2c9523775 [media] af9013: remove unneeded register writes
Removed register writes are already chip defaults, are not required,
are set later or belong to AF9015 USB interface.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:25:40 -03:00
Antti Palosaari eaa455f023 [media] af9013: add configurable TS output pin
On serial TS mode output pin could be selected from D0 or D7.
Add configuration option to for it.

Rename TS mode config option prefix from AF9013_TS_ to AF9013_TS_MODE_.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:24:54 -03:00
Antti Palosaari d029799b2f [media] af9013: add dvbv5 cnr
Add support for DVBv5 CNR.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:23:14 -03:00
Antti Palosaari bf69e07262 [media] af9013: fix error handling
Use typical (return 0/goto err/return err) error handling everywhere.
Add missing error handling where missing.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:22:50 -03:00
Antti Palosaari f458a1bc67 [media] af9013: convert to regmap api
Use regmap for register access. Own low level i2c read and write
routines for regmap is still needed because chip uses single command
byte in addition to typical i2c register access.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:22:11 -03:00
Antti Palosaari cbb2a2999c [media] af9013: fix logging
We can simplify logging as we now have a proper i2c client
to pass for kernel dev_* logging functions.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:18:51 -03:00
Antti Palosaari 903b0e58d8 [media] af9013: use kernel 64-bit division
Replace own binary division with 64-bit multiply and division.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:17:15 -03:00
Antti Palosaari 82d1ce3eba [media] af9013: add i2c client bindings
Add kernel i2c driver bindings.
That allows dev_* logging, regmap and more.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:15:58 -03:00
Antti Palosaari a4e2b6fe0e [media] af9013: move config values directly under driver state
It shorten, as typed chars, access to config values as there is one
pointer less. Also, when config/platform data is passed to driver there
could be some values that are not relevant to store state as such or
not needed to store at all.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:13:14 -03:00
Gustavo A. R. Silva 88c0530f65 [media] af9013: add check on af9013_wr_regs() return value
Check return value from call to af9013_wr_regs(), so in case of
error print debug message and return.

Addresses-Coverity-ID: 1227035

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 10:07:37 -03:00
Daniel Scheller df61f828d4 [media] dvb-frontends/cxd2841er: improved snr reporting
On DVB-T/T2 at least, SNR might be reported as >2500dB, which not only is
just wrong but also ridiculous, so fix this by improving the conversion
of the register value.

The INTLOG10X100 function/macro and the way the values are converted were
both taken from DD's cxd2843 driver.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:56:51 -03:00
Daniel Scheller bf51bbb044 [media] dvb-frontends/cxd2841er: more configurable TSBITS
Bits 3 and 4 of the TSCONFIG register are important for certain hardware
constellations, in that they need to be zeroed. Add a configuration flag
to toggle this.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:56:11 -03:00
Daniel Scheller 14fd86290d [media] dvb-frontends/cxd2841er: configurable IFAGCNEG
Adds a flag to enable or disable the IFAGCNEG bit in cxd2841er_init_tc().

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:55:41 -03:00
Daniel Scheller e3943aa6d8 [media] dvb-frontends/cxd2841er: make lock wait in set_fe_tc() optional
Don't wait for FE_HAS_LOCK in set_frontend_tc() and thus don't hammer the
lock status register with inquiries when CXD2841ER_NO_WAIT_LOCK is set
in the configuration, which also unneccessarily blocks applications until
a TS LOCK has been acquired. Rather, API and applications will check for
a TS LOCK by utilising the tune fe_op, read_status and get_frontend ops,
which is sufficient.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:55:07 -03:00
Daniel Scheller 763f857e40 [media] dvb-frontends/cxd2841er: optionally tune earlier in set_frontend()
When AUTO_IFHZ is set and the tuner is supposed to provide proper IF speed
values, it should be possible to have the tuner setup take place before
the demod is configured, else the demod might be configured with either
wrong (old), or even no values at all, which obviously will cause issues.
To set this behaviour in the most flexible way, this is done with a
separate flag instead of making this depend on AUTO_IFHZ.

It should be evaluated if tuning shouldn't take place earlier in all cases
and hardware constellations.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:54:17 -03:00
Daniel Scheller 7afe510ab2 [media] dvb-frontends/cxd2841er: make ASCOT use optional
The Sony CXD28xx demods may have other tuner types attached to them (e.g.
NXP TDA18212), so don't mandatorily configure and enable the ASCOT
functionality, but make this conditional by a config flag.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:50:06 -03:00
Daniel Scheller 03ab1bd5c2 [media] dvb-frontends/cxd2841er: TS_SERIAL config flag
Some constellations work/need a serial TS transport mode. This adds a flag
that will toggle set up of such mode.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:46:53 -03:00
Daniel Scheller 4b866c4e65 [media] dvb-frontends/cxd2841er: support IF speed calc from tuner values
Add a AUTO_IFHZ flag and a function that will read IF speed values from any
attached tuner if the tuner supports this and if AUTO_IFHZ is enabled, and
else the passed default value (which probably matches Sony ASCOT tuners)
will be passed back. The returned value is then used to calculate the iffeq
which the demod will be programmed with.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:46:22 -03:00
Daniel Scheller c7518d13f7 [media] dvb-frontends/cxd2841er: make call to i2c_gate_ctrl optional
Some cards/bridges wrap i2c_gate_ctrl handling with a mutex_lock(). This is
e.g. done in ddbridge to protect against concurrent tuner access with
regards to the dual tuner HW, where concurrent tuner reconfiguration can
result in tuning fails or bad reception quality. When the tuner driver
additionally tries to open the I2C gate (which e.g. the tda18212 driver
does) when the demod already did this, this will lead to a deadlock. This
makes the calls to i2c_gatectrl from the demod driver optional when the
flag is set, leaving this to the tuner driver. For readability reasons and
to not have the check duplicated multiple times, the setup is factored
into cxd2841er_tuner_set().

This commit also updates the netup card driver (which seems to be the only
consumer of the cxd2841er as of now).

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:45:20 -03:00
Daniel Scheller 050863aac0 [media] dvb-frontends/cxd2841er: add variable for configuration flags
Throughout the patch series some configuration flags will be added to the
demod driver. This patch prepares this by adding the flags var to
struct cxd2841er_config, which will serve as a bitmask to toggle various
options and behaviour in the driver.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:44:22 -03:00
Daniel Scheller cbc85a4736 [media] dvb-frontends/cxd2841er: replace IFFREQ calc macros into functions
The way the MAKE_IFFREQ_CONFIG macros are written make it impossible to
pass regular integers for iffreq calculation, since this will cause "SSE
register return with SSE disabled" compile errors. This changes the
calculation into C functions which also might help when debugging. Also,
expand all passed frequencies from MHz to Hz scale.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:42:09 -03:00
Daniel Scheller 1ecda28c0d [media] dvb-frontends/cxd2841er: support CXD2837/38/43ER demods/Chip IDs
Those demods are programmed in the same way as the CXD2841ER/54ER and can
be handled by this driver. Support added in a way matching the existing
code, supported delivery systems are set according to what each demod
supports.

Updates the type string setting used for printing the "attaching..." log
line aswell.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:40:55 -03:00
Daniel Scheller 6ccf821c34 [media] dvb-frontends/cxd2841er: immediately unfreeze regs when done
Do unfreeze_regs() directly when accessing the demod registers is done,
and don't have multiple unfreeze's on different conditions, which even
can get prone to errors.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:40:04 -03:00
Daniel Scheller 725e93eba1 [media] dvb-frontends/cxd2841er: do I2C reads in one go
Doing the I2C read operation with two calls to i2c_transfer() causes the
exclusive I2C bus lock of the underlying adapter to be released. While this
isn't an issue if only one demodulator is attached to the bus, having two
or even more causes troubles in that concurrent accesses to the different
demods will cause all kinds of issues due to wrong data being returned on
read operations (for example, the TS config register will be set wrong).
This changes the read_regs() function to do the operation in one go (by
calling i2c_transfer with the whole msg list instead of one by one) to not
loose the I2C bus lock, fixing all sorts of random runtime failures.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:39:27 -03:00
Daniel Scheller 5d6d93a123 [media] dvb-frontends/cxd2841er: remove kernel log spam in non-debug levels
This moves the I2C debug dump into the preceding dev_dbg() call by
utilising the %*ph format macro and removes the call to
print_hex_debug_bytes().

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:38:41 -03:00
Daniel Scheller dbbac11e1d [media] dvb-frontends/stv0367: add Digital Devices compatibility
This - in conjunction with the previous changes - makes it possible to use
the STV0367 DVB-C/T demodulator driver with Digital Devices hardware having
this demodulator soldered on them (namely CineCTv6 bridges and some earlier
DuoFlex CT addon modules).

The changes do the following:

- add a third *_attach function which will make use of a third frontend_ops
  struct which announces both -C and -T support (the same as with DD's own
  driver stv0367dd). This is necessary to support both delivery systems
  on one FE without having to do large conversions to VB2 or the need to
  select either -C or -T mode via modparams and the like. Additionally,
  the frontend_ops point to new "glue" functions which will then call into
  the existing functionality depending on the active delivery system/demod
  state (all used functionality works almost OOTB).
- Demod initialisation has been ported from stv0367dd. DD's driver always
  does a full init of both OFDM and QAM cores, with some additional things.
  The active delivery system is remembered and upon switch, the Demod will
  be reconfigured to work in OFDM or QAM mode (that's what the ddb_setup_XX
  functions are used for). Note that in QAM mode, the DD demods work with
  an IC speed of 58Mhz. It's not very good to perform full reinits upon
  Demod mode changes since in very rare occasions this can lead to the I2C
  interface or the whole Demod to crash, requiring a powercycle, thus the
  flag to perform full reinit is set to disabled.
- A little enum is added for named identifiers of the current Demod state.

Initialisation code/register writes originate from stv0367dd. Permission
to reuse was formally granted by Ralph Metzler <rjkm@metzlerbros.de>.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:27:52 -03:00
Daniel Scheller 2cafa6b288 [media] dvb-frontends/stv0367: add defaults for use w/DD-branded devices
Digital Devices uses defaults tables in their stv0367dd demod driver
variant which differ in a few registers, at least enough that no stable
operation can be provided with the tables already present in the driver
(init succeeds and DVB reception works but at least when the driver is
reloaded using rmmod/modprobe, the demod goes into a crashed state in a
way it doesn't react on any I2C command anymore, while even more
side-effects may occur), so there's a good reason to better have another
set of defaults.

Defaults originating from the stv0367dd driver. Permission to reuse them
was formally granted by Ralph Metzler <rjkm@metzlerbros.de>.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:26:16 -03:00
Daniel Scheller 8b39f07621 [media] dvb-frontends/stv0367: fix symbol rate conditions in cab_SetQamSize()
The values used for comparing symbol rates and the resulting conditional
reg writes seem wrong (rates multiplied by ten), so fix those values.
While this doesn't seem to influence operation, it should be fixed anyway.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:24:57 -03:00
Daniel Scheller cae7a901cd [media] dvb-frontends/stv0367: selectable QAM FEC Lock status register
In some configurations (due to different PIN config, wiring or so), the
QAM FECLock might be signalled using a different register than
F367CAB_QAMFEC_LOCK (e.g. F367CAB_DESCR_SYNCSTATE on Digital Devices hw),
so make that register selectable.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:24:19 -03:00
Daniel Scheller b16338e3d3 [media] dvb-frontends/stv0367: support reading if_khz from tuner config
Currently, if_khz is set and provided using the configuration var in
struct stv0367_config. However, in some constellations, the value might be
different for differing channel bandwidths or even -T and -C operation.
When e.g. used in conjunction with TDA18212 tuners, the tuner frontend
might be aware of the different freqs. This factors if_khz retrieval in a
function, which checks a new flag if an automatic retrieval attempt should
be made, and if the tuner provides it, use it whenever needed.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:23:41 -03:00
Daniel Scheller 7718dcf06e [media] dvb-frontends/stv0367: make full reinit on set_frontend() optional
Every time dvb_frontend_ops.set_frontend() is called, an almost full reinit
of the demodulator will be performed. While this might cause a slight delay
when switching channels due to all involved tables being rewritten, it can
even be dangerous in certain causes in that the demod may lock up and
requires to be powercycled (this can happen on Digital Devices hardware).
So this adds a flag if it should be done, and to not change behaviour with
existing card support, it'll be enabled in all cases.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:22:39 -03:00
Daniel Scheller 8a9c07359c [media] dvb-frontends/stv0367: make PLLSETUP a function, add 58MHz IC speed
This moves the PLL SETUP code from stv0367ter_init() into a dedicated
function, and also make it possible to configure 58Mhz IC speed at
27MHz Xtal (used on STV0367-based DDB cards/modules in QAM mode).

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:21:49 -03:00
Daniel Scheller 8881ceb86f [media] dvb-frontends/stv0367: move out tables, support multiple tab variants
Move the *ter and *cab st_register tables into a separate header file and
additionally organize them via a multidimensional array, allowing to add
more tables with differing init values, and also prepare for a base init
table which should contain general setup values. Also add a state var to
store the table triplet to be used.

Also fixes three minor style problems reported by checkpatch.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:21:14 -03:00
Daniel Scheller 41727cbb20 [media] dvb-frontends/stv0367: refactor defaults table handling
Change defaults table writing so tables can be of dynamic length without
having to keep track of their lengths by adding and evaluating an end
marker (reg 0x0000), also move table writing to a dedicated function to
remove code duplication. Additionally mark st_register tables const since
they're used read-only.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:19:58 -03:00
Daniel Scheller df5a38e913 [media] dvb-frontends/stv0367: print CPAMP status only if stv_debug is enabled
The CPAMP log lines generated in stv0367_ter_check_cpamp() are printed
everytime tuning succeeds or fails, quite cluttering the normal kernel log.
Use dprintk() instead of printk(KERN_ERR...) so that if the information is
needed, it'll be printed when the stv_debug modparam is enabled.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:18:43 -03:00
Daniel Scheller f61c2991e6 [media] dvb-frontends/stv0367: add flag to make i2c_gatectrl optional
Some hardware and bridges (namely ddbridge) require that tuner access is
limited to one concurrent access and wrap i2c gate control with a
mutex_lock when attaching frontends. According to vendor information, this
is required as concurrent tuner reconfiguration can interfere each other
and at worst cause tuning fails or bad reception quality.

If the demod driver does gate_ctrl before setting up tuner parameters, and
the tuner does another I2C enable, it will deadlock forever when gate_ctrl
is wrapped into the mutex_lock. This adds a flag and a conditional before
triggering gate_ctrl in the demodulator driver.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-20 09:18:16 -03:00
Devin Heitmueller d7590b5704 [media] au8522: Set the initial modulation
We need to set the initial modulation on driver setup, or else any
calls to GET_FRONTEND prior to the first SET_FRONTEND call will get
back garbage.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-06 07:51:33 -03:00
Devin Heitmueller b01052ab09 [media] au8522: fix lock detection to be more reliable
Only looking at the lock register causes the status to float
between locked and not locked when there is no signal.  So improve
the logic to also examine the state of the FSC PLL, which results
in the lock status being consistently reported.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-06 07:50:19 -03:00
Devin Heitmueller 6211d28eab [media] au8522 Remove 0x4 bit for register reads
The second highest bit in the register value is an indicator to do
a register read, so remove it since now au8522_regread() inserts
the bit automatically.

Also remove a stray instance where we were actually trying to write
to the I2C status register, which was actually a read.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-06 07:49:40 -03:00
Devin Heitmueller d6f79a915f [media] au8522: remove leading bit for register writes
The leading bit in register values is actually an indicator as to
whether to perform a read or write, so remove the bit from the
register values, since the au8522_writereg() is now responsible
for adding this bit automatically.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-06 07:49:07 -03:00
Devin Heitmueller 678de4b430 [media] au8522: remove note about VBI not being implemented
I got this working a couple of years ago.  Remove it from the
list of known issues.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-06 07:48:07 -03:00
Devin Heitmueller 427de05cf2 [media] au8522: rework setup of audio routing
The original code was based on my reverse engineering of an I2C trace
of the Windows driver.  Now that I know what the registers actually do,
restructure the code a bit, removing some unneeded register programming
and fixing the sequencing of operations.

This reduces the time it takes to change inputs from 1300ms down to
600ms (as measured by "time v4l2-ctl -i 0")

Note this does not address outstanding issues related to the management
of the module clocks and power control for the various blocks, which
will be done in a separate patch.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-06 07:47:40 -03:00
Devin Heitmueller bb750c7b4c [media] au8522: don't touch i2c master registers on au8522
Some stray lines got inserted into the driver when I reverse engineered
the I2C traffic (at the time I didn't know what the registers did).

It turns up these registers muck with the onboard I2C master, which
we don't use since we instead use the I2C gate.  Remove the lines
which can actually interfere with the operation of the bus.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-06 07:46:37 -03:00
Devin Heitmueller c70b18f72b [media] au8522: don't attempt to configure unsupported VBI slicer
Since we don't suppoort sliced VBI with the au0828/au8522, there is
no need to configure the au8522 VBI slicer, which because of the
coefficients requires a large amount of i2c traffic.

Remove the relevant code.  Note that this has no effect on raw VBI
support, which is currently the only supported way to access VBI on
this device.

Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-06 07:45:56 -03:00
Mauro Carvalho Chehab 06eeefe8e3 [media] media drivers: annotate fall-through
Avoid warnings like those:

drivers/media/pci/ddbridge/ddbridge-core.c: In function 'dvb_input_detach':
drivers/media/pci/ddbridge/ddbridge-core.c:787:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
   if (input->fe) {
      ^
drivers/media/pci/ddbridge/ddbridge-core.c:792:2: note: here
  case 4:
  ^~~~
...

On several cases, it is just that gcc 7.1 is not capable of
understanding the comment, but on other places, we need an
annotation.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-05-19 07:10:03 -03:00
Mauro Carvalho Chehab 17992979f6 [media] bcm3510: fix handling of VSB16 modulation
There's a missing break for VSB16 modulation logic, with would
cause it to return -EINVAL, instead of handling it.

Fix it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-05-19 07:07:43 -03:00
Joe Perches 8ac1ed7914 treewide: spelling: correct diffrent[iate] and banlance typos
Add these misspellings to scripts/spelling.txt too

Link: http://lkml.kernel.org/r/962aace119675e5fe87be2a88ddac1a5486f8e60.1490931810.git.joe@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-05-08 17:15:13 -07:00
Linus Torvalds c6a677c6f3 Staging/IIO patches for 4.12-rc1
Here is the big staging tree update for 4.12-rc1.  And it's a big one,
 adding about 350k new lines of crap^Wcode, mostly all in a big dump of
 media drivers from Intel.  But there's other new drivers in here as
 well, yet-another-wifi driver, new IIO drivers, and a new crypto
 accelerator.  We also deleted a bunch of stuff, mostly in patch
 cleanups, but also the Android ION code has shrunk a lot, and the
 Android low memory killer driver was finally deleted, much to the
 celebration of the -mm developers.
 
 All of these have been in linux-next with a few build issues that will
 show up when you merge to your tree, I'll follow up with fixes for those
 after this gets merged.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWQzzlQ8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ylNMgCcD+GoaF/Ml7YnULRl2GG/526II78AnitZ8qjd
 rPqeowMIewYu9fgckLUc
 =7rzO
 -----END PGP SIGNATURE-----

Merge tag 'staging-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging/IIO updates from Greg KH:
 "Here is the big staging tree update for 4.12-rc1.

  It's a big one, adding about 350k new lines of crap^Wcode, mostly all
  in a big dump of media drivers from Intel. But there's other new
  drivers in here as well, yet-another-wifi driver, new IIO drivers, and
  a new crypto accelerator.

  We also deleted a bunch of stuff, mostly in patch cleanups, but also
  the Android ION code has shrunk a lot, and the Android low memory
  killer driver was finally deleted, much to the celebration of the -mm
  developers.

  All of these have been in linux-next with a few build issues that will
  show up when you merge to your tree"

Merge conflicts in the new rtl8723bs driver (due to the wifi changes
this merge window) handled as per linux-next, courtesy of Stephen
Rothwell.

* tag 'staging-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1182 commits)
  staging: fsl-mc/dpio: add cpu <--> LE conversion for dpaa2_fd
  staging: ks7010: remove line continuations in quoted strings
  staging: vt6656: use tabs instead of spaces
  staging: android: ion: Fix unnecessary initialization of static variable
  staging: media: atomisp: fix range checking on clk_num
  staging: media: atomisp: fix misspelled word in comment
  staging: media: atomisp: kmap() can't fail
  staging: atomisp: remove #ifdef for runtime PM functions
  staging: atomisp: satm include directory is gone
  atomisp: remove some more unused files
  atomisp: remove hmm_load/store/clear indirections
  atomisp: kill off mmgr_free
  atomisp: clean up the hmm init/cleanup indirections
  atomisp: handle allocation calls before init in the hmm layer
  staging: fsl-dpaa2/eth: Add maintainer for Ethernet driver
  staging: fsl-dpaa2/eth: Add TODO file
  staging: fsl-dpaa2/eth: Add trace points
  staging: fsl-dpaa2/eth: Add driver specific stats
  staging: fsl-dpaa2/eth: Add ethtool support
  staging: fsl-dpaa2/eth: Add Freescale DPAA2 Ethernet driver
  ...
2017-05-05 18:16:23 -07:00
Linus Torvalds e87d51ac61 media updates for v4.12-rc1
-----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJZDHJ4AAoJEAhfPr2O5OEVdwAP/jAmT+Bu7gXfgcrrmHNpivx4
 knyyGlmpoazPT4WbNvBkqCdYESXpJowQgzOMagRi2zSEqnylCgAFvZ/CF6imGJDd
 0r1ahK6JE9sBSw2Y531h8t7IESmEFaDCOdg4W91lCMa76goZoSjWTDhv6xx1nQId
 d77lHhbAKctQI7VdBA1KlCdrvn5QKmNKsJHMGWJbXv/zNWube8Lk6ZAeqJ2Q2Efk
 yzrjQiXpYKVcG6tnI6BSp+rkzRYshO7vs+xw37RcCPfzf9YgHd9Olp9FDegzmRrd
 gJ1UudEpGPFZ6RIiOJLUkurPEdfAiSVMUG7jEimgRwsu0+QEURuVHF0HiTA2XjVX
 5jKJSobOQQzc14b1d42eIMDBsqEP2/Bll4BBjy7VHzyAcxh3Jpo8Fqoe0Jq/gmio
 jP11RHt5XRrqPmyBoApigxffDSizqNhT+yoOr5G/2EJza/L7rH9SuGALa0OPql6o
 OVJyfSit02Eco7ccrcqxp2s6fqFGXBwso6U9aSKyiG2xqXLb/g1GkacOt1TjMCHU
 OnuWR/1RjizGyxoom5Y0WhnPcLEJ4x1cVtU8tuqAx2K4YhRFsH5e27gQCXPynm1Z
 8yC2DA4+3w57U5uYAGUlZP6/Mo+KGVET83OtNHnmOZ8qH55CzFbp8TTF+iMMmLHm
 ZkXCS1/1Iwt+ykNymFLn
 =Snzj
 -----END PGP SIGNATURE-----

Merge tag 'media/v4.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media

Pull media updates from Mauro Carvalho Chehab:
 "Media updates for v4.12-rc1:

   - new driver to support mediatek jpeg in hardware codec

   - rc-lirc, s5p-cec and st-cec staging drivers got promoted

   - hardware histogram support for vsp1 driver

   - added Virtual Media Controller driver, to make easier to test the
     media controller

   - added a new CEC driver (rainshadow-cec)

   - removed two staging LIRC drivers for obscure hardware that are too
     obsolete

   - added support for Intel SR300 Depth camera

   - some improvements at CEC and RC core

   - lots of driver cleanups, improvements all over the tree

  With this series, we're finally getting rid of the LIRC staging
  driver. There's just one left (lirc_zilog), with require more care,
  as part of its functionality (IR RX) is already provided by another
  driver. Work in progress to convert it on the proper way"

* tag 'media/v4.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (304 commits)
  [media] ov2640: print error if devm_*_optional*() fails
  [media] atmel-isc: Fix the static checker warning
  [media] ov2640: add support for MEDIA_BUS_FMT_YVYU8_2X8 and MEDIA_BUS_FMT_VYUY8_2X8
  [media] ov2640: fix vflip control
  [media] ov2640: fix duplicate width+height returning from ov2640_select_win()
  [media] ov2640: add missing write to size change preamble
  [media] ov2640: add information about DSP register 0xc7
  [media] ov2640: improve banding filter register definitions/documentation
  [media] ov2640: fix init sequence alignment
  [media] ov2640: make GPIOLIB an optional dependency
  [media] xc5000: fix spelling mistake: "calibration"
  [media] vidioc-queryctrl.rst: fix menu/int menu references
  [media] media-entity: only call dev_dbg_obj if mdev is not NULL
  [media] pixfmt-meta-vsp1-hgo.rst: remove spurious '-'
  [media] mtk-vcodec: avoid warnings because of empty macros
  [media] coda: bump maximum number of internal framebuffers to 17
  [media] media: mtk-vcodec: remove informative log
  [media] subdev-formats.rst: remove spurious '-'
  [media] dw2102: limit messages to buffer size
  [media] ttusb2: limit messages to buffer size
  ...
2017-05-05 17:34:57 -07:00
Daniel Scheller 158f0328af [media] dvb-frontends/cxd2841er: define symbol_rate_min/max in T/C fe-ops
Fixes "w_scan -f c" complaining with

  This dvb driver is *buggy*: the symbol rate limits are undefined - please
  report to linuxtv.org)

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Acked-by: Abylay Ospan <aospan@netup.ru>
Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-18 12:10:42 -03:00
Daniel Scheller b73bb2ab97 [media] dvb-frontends/drxk: don't log errors on unsupported operation mode
When fe_ops.read_status is called and no channel is tuned (yet), the
subsequent calls to get_lock_status() causes the kernel log to be filled
with

    drxk: Error -22 on get_lock_status

which either means a NULL pointer was passed for the p_lock_status var,
or neither QAM nor OFDM/DVBT operation mode are active. Instead of
filling the kernel log in the latter case, print out a message to the debug
level and return 0 (this isn't used in the calling drxk_get_stats() anyway).

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-17 17:07:57 -03:00
Antti Palosaari 0fc66c1949 [media] mn88472: implement PER statistics
Implement DVBv5 PER.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-10 12:44:26 -03:00
Antti Palosaari c635a5e2cf [media] mn88472: implement cnr statistics
Implement DVBv5 CNR.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-10 12:43:54 -03:00
Antti Palosaari 61d7c6aa4f [media] mn88472: implement signal strength statistics
Implement DVBv5 signal strength on relative scale.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-04-10 12:43:12 -03:00
Mauro Carvalho Chehab 7ca0ef3da0 Linux 4.11-rc5
-----BEGIN PGP SIGNATURE-----
 
 iQEcBAABAgAGBQJY4ZYkAAoJEHm+PkMAQRiGsq4H/R4PMXDoe2XhSSk7IoT97pXV
 /A8np/scAPjzEgYUidbb54OSqWwsPRuPGWONTFeSrE2u0L4wln/REI91jg7QetLq
 IisncExlYeJ/XQ+iO0ZZh9fLbqwIlEJFdSXmyIFr3m/TBxe8a61C8j93oNgM1tHT
 yuwzlq7c3sLq2hsmUG2HyL2kJsEfRasv4Rk0yhFuti12zVsBoTW4qmZuMauq+gdf
 f7cSYgiHhPTdb2o+azg5O7uYNHaQQBxdUMlIuhhYtVOUq+pFDO23SLHSFIW2NwOm
 Zn5R6CFSrLsCw0Bx0v8Xlc151QUbaRK4h9lhUhkBr6d3uNShU1NQ9JojpSvYwBo=
 =vP6E
 -----END PGP SIGNATURE-----

Merge tag 'v4.11-rc5' into patchwork

Linux 4.11-rc5

* tag 'v4.11-rc5': (1168 commits)
  Linux 4.11-rc5
  tty: pl011: fix earlycon work-around for QDF2400 erratum 44
  kasan: do not sanitize kexec purgatory
  drivers/rapidio/devices/tsi721.c: make module parameter variable name unique
  mm/hugetlb.c: don't call region_abort if region_chg fails
  kasan: report only the first error by default
  hugetlbfs: initialize shared policy as part of inode allocation
  mm: fix section name for .data..ro_after_init
  mm, hugetlb: use pte_present() instead of pmd_present() in follow_huge_pmd()
  mm: workingset: fix premature shadow node shrinking with cgroups
  mm: rmap: fix huge file mmap accounting in the memcg stats
  mm: move mm_percpu_wq initialization earlier
  mm: migrate: fix remove_migration_pte() for ksm pages
  nfs: flexfiles: fix kernel OOPS if MDS returns unsupported DS type
  NFSv4.1 fix infinite loop on IO BAD_STATEID error
  serial: 8250_EXAR: fix duplicate Kconfig text and add missing help text
  tty/serial: atmel: fix TX path in atmel_console_write()
  tty/serial: atmel: fix race condition (TX+DMA)
  serial: mxs-auart: Fix baudrate calculation
  irqchip/mips-gic: Fix Local compare interrupt
  ...
2017-04-04 11:11:43 -03:00
Greg Kroah-Hartman 1c816bad41 Merge 4.11-rc4 into staging-next
We need the IIO fixes in here as well to handle merge issues.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-27 09:11:25 +02:00
Masanari Iida 0a95160ed3 treewide: Fix typos in printk
This patch fix some spelling typos found in printk.

[jkosina@suse.cz: drop arch/arm64/kernel/hibernate.c that was already
 in place]
Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2017-03-24 15:24:00 +01:00
Arushi Singhal 95fab47ba2 staging: dvb-frontends: removed code in comments.
Commenting out Code is a Bad Idea.
Comments are their to explain the code and how the code achieves its
goal and as codes in the comments  does not explain what the code is
doing so there is no use of commenting them.
So in this patch codes in the comments are removed.

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-16 11:17:07 +09:00
Masahiro Yamada 505d3085d7 scripts/spelling.txt: add "overide" pattern and fix typo instances
Fix typos and add the following to the scripts/spelling.txt:

  overide||override

While we are here, fix the doubled "address" in the touched line
Documentation/devicetree/bindings/regulator/ti-abb-regulator.txt.

Also, fix the comment block style in the touched hunks in
drivers/media/dvb-frontends/drx39xyj/drx_driver.h.

Link: http://lkml.kernel.org/r/1481573103-11329-21-git-send-email-yamada.masahiro@socionext.com
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-03-09 17:01:09 -08:00
Mauro Carvalho Chehab 700ea5e0e0 Linux 4.11-rc1
-----BEGIN PGP SIGNATURE-----
 
 iQEcBAABAgAGBQJYvHxaAAoJEHm+PkMAQRiGqd8H/1tNYYnkk57WROf2pg4dpT/k
 jK25fO0pC5AzwRd6TGM5I/Pg4Gh+eoXnO/mTiBJwxcvQY09cV2cW+1Pz7R/MLTfY
 lVU4CmQbM96JN1Wz44WS7H25ByYfWChbPmRzSiA0IjdJvm+C7vWFK0cf18i+EbbE
 pHFbFcIlwPx9cGVQQ7YWN5IGJU0mUYK51n1IHMcjHdMDJdBWtS1rjM+mk/O5ZBl/
 p0OpcO9P5HXhljy4xDgHn6uotTvjB/aZudyfsg7b/sGtIX5GKxXHLOAu7x2kM+a7
 G6+L+48GfjHbt6VEdWA8YmFxyl+se3IG0uIVXTz78cVWfOsd33bCE3s0mOhWFVc=
 =kYFG
 -----END PGP SIGNATURE-----

Merge tag 'v4.11-rc1' into patchwork

Linux 4.11-rc1

* tag 'v4.11-rc1': (10730 commits)
  Linux 4.11-rc1
  strparser: destroy workqueue on module exit
  Documentation/sphinx: fix primary_domain configuration
  docs: Fix htmldocs build failure
  doc/ko_KR/memory-barriers: Update control-dependencies section
  pcieaer doc: update the link
  Documentation: Update path to sysrq.txt
  sfc: fix IPID endianness in TSOv2
  sfc: avoid max() in array size
  rds: remove unnecessary returned value check
  rxrpc: Fix potential NULL-pointer exception
  nfp: correct DMA direction in XDP DMA sync
  nfp: don't tell FW about the reserved buffer space
  net: ethernet: bgmac: mac address change bug
  net: ethernet: bgmac: init sequence bug
  xen-netback: don't vfree() queues under spinlock
  xen-netback: keep a local pointer for vif in backend_disconnect()
  netfilter: nf_tables: don't call nfnetlink_set_err() if nfnetlink_send() fails
  netfilter: nft_set_rbtree: incorrect assumption on lower interval lookups
  netfilter: nf_conntrack_sip: fix wrong memory initialisation
  ...
2017-03-06 06:49:34 -03:00
Evgeny Plehov 50d6446207 [media] si2168: Si2168-D60 support
Support for new demod version.

Signed-off-by: Evgeny Plehov <EvgenyPlehov@ukr.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-03-03 08:39:48 -03:00
Alexey Dobriyan 5b5e0928f7 lib/vsprintf.c: remove %Z support
Now that %z is standartised in C99 there is no reason to support %Z.
Unlike %L it doesn't even make format strings smaller.

Use BUILD_BUG_ON in a couple ATM drivers.

In case anyone didn't notice lib/vsprintf.o is about half of SLUB which
is in my opinion is quite an achievement.  Hopefully this patch inspires
someone else to trim vsprintf.c more.

Link: http://lkml.kernel.org/r/20170103230126.GA30170@avx2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-27 18:43:47 -08:00
Masahiro Yamada 2c14960100 scripts/spelling.txt: add "configuartion" pattern and fix typo instances
Fix typos and add the following to the scripts/spelling.txt:

  configuartion||configuration

While we are here, fix the "ouput" as well in the touched hunk in
drivers/media/dvb-frontends/drx39xyj/drx_driver.h.

Link: http://lkml.kernel.org/r/1481573103-11329-23-git-send-email-yamada.masahiro@socionext.com
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-02-27 18:43:47 -08:00
Arnd Bergmann 0d1270df83 [media] zd1301: fix building interface driver without demodulator
If the USB driver is enabled but the demodulator is not, we get a link error:

ERROR: "zd1301_demod_get_dvb_frontend" [drivers/media/usb/dvb-usb-v2/zd1301.ko] undefined!
ERROR: "zd1301_demod_get_i2c_adapter" [drivers/media/usb/dvb-usb-v2/zd1301.ko] undefined!

Such a configuration obviously makes no sense, but we should not fail
the build.  This tries to mimic what we have for other drivers by turning
the build failure into a runtime failure.

Alternatively we could use an unconditional 'select' or 'depends on' to enforce
a sane configuration.

Fixes: 47d65372b3 ("[media] zd1301_demod: ZyDAS ZD1301 DVB-T demodulator driver")
Fixes: 992b39872b ("[media] zd1301: ZyDAS ZD1301 DVB USB interface driver")

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-08 11:59:39 -02:00
Bhumika Goyal dd93e79c60 [media] media: dvb-frontends: constify vb2_ops structure
Declare vb2_ops structure as const as it is only stored in
the ops field of a vb2_queue structure. This field is of type
const, so vb2_ops structures having same properties can be made
const too.
Done using Coccinelle:

@r1 disable optional_qualifier@
identifier i;
position p;
@@
static struct vb2_ops i@p={...};

@ok1@
identifier r1.i;
position p;
struct sta2x11_vip vip;
struct vb2_queue q;
@@
(
vip.vb_vidq.ops=&i@p
|
q.ops=&i@p
)

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct vb2_ops i;

File size details of media/dvb-frontends/rtl2832_sdr.o file remains the
same before and after applying the patch.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-03 14:23:39 -02:00
Kevin Cheng 4f75189024 [media] lgdt3306a: support i2c mux for use by em28xx
Adds an i2c mux to the lgdt3306a demodulator.  This was done to support
the Hauppauge WinTV-dualHD 01595 USB TV tuner (em28xx), which utilizes two
si2157 tuners behind gate control.

Signed-off-by: Kevin Cheng <kcheng@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-03 13:45:48 -02:00
Martin Wache 5332b62637 [media] dib7000p: avoid division by zero
dib7000p_read_word() may return zero on i2c errors, resulting in
dib7000p_get_internal_freq() returning zero.
So don't divide by the result of dib7000p_get_internal_freq()
without checking it for zero in dib7000p_set_dds().

On one of my machines the device
ID 2304:0229 Pinnacle Systems, Inc. PCTV Dual DVB-T 2001e
about once a day/every two days gets into a state, where
most (all?) I2C reads return with an error. Tuning during this
state will result in a divide by zero without this patch.
This patch doesn't fix the root cause for the device getting
into a bad state, but it allows me to unload/reload the drivers,
bringing it back into a usable state.

Signed-off-by: Martin Wache <M.Wache@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-03 10:54:20 -02:00
Antti Palosaari 38611529a0 [media] MAINTAINERS: remove hd29l2
Remove unused demod driver. Device that used it never went public.

If someone later decide to add support for a device using this
chipset, it should be easy enough to retrieve it from git
history.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-03 07:01:00 -02:00
Antti Palosaari 47d65372b3 [media] zd1301_demod: ZyDAS ZD1301 DVB-T demodulator driver
ZyDAS ZD1301 is chip having USB interface and DVB-T demodulator
integrated. This driver is for demodulator part.
Driver is very reduced, just basic demodulator functionality, no
statistics at all. It registers as a platform driver to driver core.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-02-03 06:45:35 -02:00
Antti Palosaari 239dd6164c [media] af9033: estimate cnr from formula
Use formulas for cnr estimates and get rid of old lut-based estimate.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-31 10:52:23 -02:00
Antti Palosaari 3461831adc [media] af9033: return regmap for integrated IT913x tuner driver
IT9130 series contains integrated tuner driver, which uses that
demodulator address space. Return regmap in order to allow it913x
driver communication.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-31 10:48:14 -02:00
Antti Palosaari 81e1991255 [media] af9033: style related and minor changes
Fix coding style and other small issues.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-31 10:47:28 -02:00
Antti Palosaari c2feb9ffce [media] af9033: use 64-bit div macro where possible
Replace Booth's binary division algo with 64-bit multiply and division.
Fix related IF calculations.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-31 10:43:40 -02:00
Antti Palosaari bc85d5e2fa [media] af9033: convert to regmap api
Use regmap to cover I2C register operations.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-31 10:35:42 -02:00
Antti Palosaari c62d29c817 [media] si2168: implement ucb statistics
Implement DVBv5 UCB. Only uncorrected blocks are currently counted.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-31 10:26:52 -02:00
Antti Palosaari 8393c00369 [media] si2168: implement ber statistics
Implement DVBv5 BER.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-31 10:26:23 -02:00
Antti Palosaari 0ffb94b6cc [media] cxd2820r: fix gpio null pointer dereference
Setting GPIOs during probe causes null pointer deference when
GPIOLIB was not selected by Kconfig. Initialize driver private
field before calling set gpios.

It is regressing bug since 4.9.

Fixes: 07fdf7d9f1 ("[media] cxd2820r: add I2C driver bindings")

Reported-by: Chris Rankin <rankincj@gmail.com>
Tested-by: Chris Rankin <rankincj@gmail.com>
Tested-by: Håkan Lennestål <hakan.lennestal@gmail.com>
Cc: <stable@vger.kernel.org> # v4.9+
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-31 08:45:41 -02:00
Colin Ian King f8d5219dcd [media] dvb-frontends: fix spelling mistake on cx24123_pll_calcutate
trivial fix to spelling mistake of function name in err message,
should be cx24123_pll_calculate instead of cx24123_pll_calcutate.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-30 15:44:42 -02:00
Sakari Ailus bcb63314e2 [media] media: Drop FSF's postal address from the source code files
Drop the FSF's postal address from the source code files that typically
contain mostly the license text. Of the 628 removed instances, 578 are
outdated.

The patch has been created with the following command without manual edits:

git grep -l "675 Mass Ave\|59 Temple Place\|51 Franklin St" -- \
	drivers/media/ include/media|while read i; do i=$i perl -e '
open(F,"< $ENV{i}");
$a=join("", <F>);
$a =~ s/[ \t]*\*\n.*You should.*\n.*along with.*\n.*(\n.*USA.*$)?\n//m
	&& $a =~ s/(^.*)Or, (point your browser to) /$1To obtain the license, $2\n$1/m;
close(F);
open(F, "> $ENV{i}");
print F $a;
close(F);'; done

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
2017-01-27 11:38:09 -02:00
Antti Palosaari 40eca140c4 [media] mn88473: add DVB-T2 PLP support
Adds PLP ID filtering for DVB-T2.

It is untested as I don't have any signal having PLP ID other than 0.
There is only 2 extra registers, 0x32 and 0x36 on bank2, that are
programmed for DVB-T2 but not for DVB-T and all the rest are
programmed similarly - so it is likely PLP.

Pridvorov reported successfully testing it in Russia with m-PLP streams,
on both Vladivostok and Moskow.

Tested-by: "Придворов Андрей (Pridvorov  Andrey)" <ua0lnj@bk.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-12-27 14:00:15 -02:00
Antti Palosaari 365fe4e0ce [media] mn88472: fix chip id check on probe
A register used to identify chip during probe was overwritten during
firmware download and due to that later probe's for warm chip were
failing. Detect chip from the another register, which is located on
different register bank 2.

Fixes: 94d0eaa419 ("[media] mn88472: move out of staging to media")

Cc: <stable@vger.kernel.org> # v4.8+
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-12-01 12:47:22 -02:00
Antti Palosaari d930b5b5bf [media] mn88473: fix chip id check on probe
A register used to identify chip during probe was overwritten during
firmware download and due to that later probe's for warm chip were
failing. Detect chip from the another register, which is located on
different register bank 2.

Fixes: 7908fad99a ("[media] mn88473: finalize driver")

Cc: <stable@vger.kernel.org> # v4.8+
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-12-01 12:47:02 -02:00
Arnd Bergmann a19e160d10 [media] dvb: remove unused systime() function
The systime function uses struct timespec, which we want to stop
using in the kernel because it overflows in 2038. Fortunately,
this use in dibx000_common is in a function that is never called,
so we can just remove it.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-23 12:58:10 -02:00
Joerg Riechardt 386701892b [media] stv090x: use lookup tables for carrier/noise ratio
The stv090x driver uses the lookup table for signal strength already,
with this patch we use the lookup tables for carrier/noise ratio as well.
This has the advantage, that values for DVB-S and DVB-S2 are now
corresponding, while before they were way off. The values are now
proportional to real carrier/noise ratio, while before they were
corresponding to register values. So now applications are able to give
the user real carrier/noise ratio.

Because the output has to be within 0x0000...0xFFFF the three negative
values for DVB-S2 are omitted. This is no significant loss, because
reception is lost at 7.5 dB already (TT S2-1600, Cine S2), so the
negative values are not really important, and also for DVB-S they don´t
exist.

Signed-off-by: Joerg Riechardt <j.riechardt@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-23 12:41:49 -02:00
Antti Palosaari 69ace6ee3e [media] mn88473: refactor and fix statistics
Remove DVB-T2 BER as it does not work at all and I didn't find
how to fix.

Fix DVB-T and DVB-C BER. It seems to return new some realistic
looking values.

Use (1 << 24) base for CNR calculations to keep it in line with
dvb logarithm functions.

Move all statistic logic to mn88473_read_status() function.

Use regmap_bulk_read() for reading multiple registers as a one go.

Many more and less minor changes.

Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-22 16:04:30 -02:00
Martin Blumenstingl 61393b0732 [media] mn88473: add DVBv5 statistics support
Implement DVBv5 statistics support for DVB-T, DVB-T2 and DVB-C. All
information was taken from the LinuxTV wiki, where Benjamin Larsson has
documented all registers:
https://www.linuxtv.org/wiki/index.php/Panasonic_MN88472

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-22 16:00:26 -02:00
Mauro Carvalho Chehab f2709c206d Revert "[media] dvb_frontend: merge duplicate dvb_tuner_ops.release implementations"
While this patch sounded a good idea, unfortunately, it causes
bad dependencies, as drivers that would otherwise work without
the DVB core will now break:

ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/tea5767.ko] undefined!
ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/tea5761.ko] undefined!
ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/tda827x.ko] undefined!
ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/tda18218.ko] undefined!
ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/qt1010.ko] undefined!
ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/mt2266.ko] undefined!
ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/mt20xx.ko] undefined!
ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/mt2060.ko] undefined!
ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/mc44s803.ko] undefined!
ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/fc0013.ko] undefined!
ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/fc0012.ko] undefined!
ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/fc0011.ko] undefined!

So, we have to revert it.

Note: as the argument for the release ops changed from "int"
to "void", we needed to change it at the revert patch, to
avoid compilation issues like:
	drivers/media/tuners/tea5767.c:437:23: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
	  .release           = tea5767_release,
	                       ^~~~~~~~~~~~~~~

This reverts commit 22a613e898.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 20:44:33 -02:00
Mauro Carvalho Chehab a4afb3ed43 [media] Kconfig: fix breakages when DVB_CORE is not selected
On some weird randconfigs, it is possible to select DVB
drivers, without having the DVB_CORE:

CONFIG_DVB_AU8522=m
CONFIG_DVB_AU8522_V4L=m
CONFIG_DVB_TUNER_DIB0090=m

This was never supposed to work, but changeset 22a613e898
("[media] dvb_frontend: merge duplicate dvb_tuner_ops.release implementations")
caused it to be exposed:

   drivers/built-in.o: In function `fc0011_attach':
   (.text+0x1598fb): undefined reference to `dvb_tuner_simple_release'
   drivers/built-in.o:(.rodata+0x55e58): undefined reference to `dvb_tuner_simple_release'
   drivers/built-in.o:(.rodata+0x57398): undefined reference to `dvb_tuner_simple_release'

Fixes: 22a613e898 ("[media] dvb_frontend: merge duplicate dvb_tuner_ops.release implementations")
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 17:59:17 -02:00
Max Kellermann f686c14364 [media] stb0899: move code to "detach" callback
Ensure that STB0899_POSTPROC_GPIO_POWER is set synchronously.

Signed-off-by: Max Kellermann <max.kellermann@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 15:10:41 -02:00
Max Kellermann 194ced7a5a [media] dvb_frontend: tuner_ops.release returns void
It is not clear what this return value means.  All implemenations
return 0, and the one caller ignores the value.  Let's remove this
useless return value completely.

Signed-off-by: Max Kellermann <max.kellermann@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 15:07:26 -02:00
Max Kellermann 22a613e898 [media] dvb_frontend: merge duplicate dvb_tuner_ops.release implementations
Most release callback functions are identical: free the "tuner_priv"
and clear it.  Let's eliminate some bloat by providing this simple
implementation in the dvb_frontend library.

Signed-off-by: Max Kellermann <max.kellermann@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 15:05:44 -02:00
Max Kellermann bd336e6344 [media] dvb: make DVB frontend *_ops instances "const"
These are immutable.  Making them "const" allows the compiler to move
them to the "rodata" section.

Note that cxd2841er_t_c_ops cannot be made "const", because
cxd2841er_attach() modifies it.  Ouch!

[mchehab@s-opensource.com: fix merge conflicts]
Signed-off-by: Max Kellermann <max.kellermann@gmail.com>

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 15:00:22 -02:00
Mauro Carvalho Chehab 0a6dc89ae4 [media] dibx000_common: use pr_foo() instead of printk()
The dprintk() macro relies on continuation lines. This is not
a good practice and will break after commit 563873318d
("Merge branch 'printk-cleanups'").

So, instead of directly calling printk(), use pr_foo() macros,
adding a \n leading char on each macro call.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 10:01:56 -02:00
Mauro Carvalho Chehab 3dd722622f [media] dib9000: use pr_foo() instead of printk()
The dprintk() macro relies on continuation lines. This is not
a good practice and will break after commit 563873318d
("Merge branch 'printk-cleanups'").

So, instead of directly calling printk(), use pr_foo() macros,
adding a\n leading char on each macro call.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 10:01:02 -02:00
Mauro Carvalho Chehab 8af16adfbb [media] dib8000: use pr_foo() instead of printk()
The dprintk() macro relies on continuation lines. This is not
a good practice and will break after commit 563873318d
("Merge branch 'printk-cleanups'").

So, instead of directly calling printk(), use pr_foo() macros,
adding a\n leading char on each macro call.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 09:59:38 -02:00
Mauro Carvalho Chehab 5a0e2a4e93 [media] dib7000p: use pr_foo() instead of printk()
The dprintk() macro relies on continuation lines. This is not
a good practice and will break after commit 563873318d
("Merge branch 'printk-cleanups'").

So, instead of directly calling printk(), use pr_foo() macros,
adding a \n leading char on each macro call.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 09:57:10 -02:00
Mauro Carvalho Chehab 7570227724 [media] dib7000m: use pr_foo() instead of printk()
The dprintk() macro relies on continuation lines. This is not
a good practice and will break after commit 563873318d
("Merge branch 'printk-cleanups'").

So, instead of directly calling printk(), use pr_foo() macros,
adding a \n leading char on each macro call.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 09:55:50 -02:00
Mauro Carvalho Chehab 441d54e343 [media] dib3000mc: use pr_foo() instead of printk()
The dprintk() macro relies on continuation lines. This is not
a good practice and will break after commit 563873318d
("Merge branch 'printk-cleanups'").

So, instead of directly calling printk(), use pr_foo() macros,
adding a \n leading char on each macro call.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 09:48:42 -02:00
Mauro Carvalho Chehab 585e3227ec [media] dib3000mb: use pr_foo() instead of printk()
The dprintk() macro relies on continuation lines. This is not
a good practice and will break after commit 563873318d
("Merge branch 'printk-cleanups'").

So, instead of directly calling printk(), use pr_foo() macros,
adding a \n leading char on each macro call.

The frontend settings also rely on continuation lines. Change
it to avoid the need of adding pr_cont() calls.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 09:47:48 -02:00
Mauro Carvalho Chehab 4bd1a8ddad [media] dib0090: use pr_foo() instead of printk()
The dprintk() macro relies on continuation lines. This is not
a good practice and will break after commit 563873318d
("Merge branch 'printk-cleanups").

So, instead of directly calling printk(), use pr_foo() macros,
adding a \n leading char on each macro call.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 09:44:48 -02:00
Mauro Carvalho Chehab fb11cbd1a9 [media] dib0070: use pr_foo() instead of printk()
The dprintk() macro relies on continuation lines. This is not
a good practice and will break after commit 563873318d
("Merge branch 'printk-cleanups").

So, instead of directly calling printk(), use pr_foo() macros,
adding a \n leading char on each macro call.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 09:43:55 -02:00
Mauro Carvalho Chehab f1dc10b6e1 gp8psk-fe: add missing MODULE_foo() macros
This file was converted to a separate module at commit 7a0786c19d
("gp8psk: Fix DVB frontend attach"), because the DVB attach routines
require it to work.  However, I forgot to copy the MODULE_foo() macros
from the original module, causing this warning:

    WARNING: modpost: missing MODULE_LICENSE() in drivers/media/dvb-frontends/gp8psk-fe.o

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Fixes: 7a0786c19d ("gp8psk: Fix DVB frontend attach")
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-11-18 08:06:38 -02:00
Mauro Carvalho Chehab fed9d8f3cd [media] stv090x: get rid of continuation lines
This driver has printk continuation lines for debugging purposes.
Since commit 563873318d ("Merge branch 'printk-cleanups'")',
this won't work as expected anymore.

So, use %*ph and get rid of it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 07:56:23 -02:00
Mauro Carvalho Chehab a8cd47d360 [media] stb0899_drv: get rid of continuation lines
This driver has printk continuation lines for debugging purposes.
Since commit 563873318d ("Merge branch 'printk-cleanups'")',
this won't work as expected anymore.

So, use %*ph and get rid of it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18 07:55:38 -02:00
Mauro Carvalho Chehab 36f94a5cf0 Linux 4.9-rc5
-----BEGIN PGP SIGNATURE-----
 
 iQEcBAABAgAGBQJYKLHHAAoJEHm+PkMAQRiGOqoH/iTmywTeevTpx4jbEb8u3LAR
 Bi1ACuBjJKJgYemRPdnH9e1/6nHRkw8EhwUIb2Jv4pyRb+pV2ssxy5sRinY8k9qw
 9pRf+DS9158c5Mc5lZTc3wnRMs49+zowgGpzUjw2HIFoq3E3H0bYpsCl144e4Y8z
 0R6jDKL/YXa9tzVVDTjHG9aG/l0Anc2VzFnWSalNhX5W2PSKc2QtticR3+kTVnA3
 oP4q5UCymdwrZ33XLVldmHqE3n9m8wKGn+gBUMCoJwt5DVRSjqXeT+IkmLdESHEH
 2GyFBE120coYLxTN8CAB4Wa/Woyr0VG6OJvX+Lq3zbnehjteAGOXHzBwYrIOsGc=
 =EwHz
 -----END PGP SIGNATURE-----

Merge tag 'v4.9-rc5' into patchwork

Linux 4.9-rc5

* tag 'v4.9-rc5': (1102 commits)
  Linux 4.9-rc5
  gp8psk: Fix DVB frontend attach
  gp8psk: fix gp8psk_usb_in_op() logic
  dvb-usb: move data_mutex to struct dvb_usb_device
  iio: maxim_thermocouple: detect invalid storage size in read()
  aoe: fix crash in page count manipulation
  lightnvm: invalid offset calculation for lba_shift
  Kbuild: enable -Wmaybe-uninitialized warnings by default
  pcmcia: fix return value of soc_pcmcia_regulator_set
  infiniband: shut up a maybe-uninitialized warning
  crypto: aesni: shut up -Wmaybe-uninitialized warning
  rc: print correct variable for z8f0811
  dib0700: fix nec repeat handling
  s390: pci: don't print uninitialized data for debugging
  nios2: fix timer initcall return value
  x86: apm: avoid uninitialized data
  NFSv4.1: work around -Wmaybe-uninitialized warning
  Kbuild: enable -Wmaybe-uninitialized warning for "make W=1"
  lib/stackdepot: export save/fetch stack for drivers
  mm: kmemleak: scan .data.ro_after_init
  ...
2016-11-16 16:42:27 -02:00
Markus Elfring 68226b4dfa [media] dvb-tc90522: Rename a jump label in tc90522_probe()
Adjust a jump label according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-16 12:16:52 -02:00
Markus Elfring d2dc12d6c8 [media] dvb-tc90522: Use kmalloc_array() in tc90522_master_xfer()
A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-16 12:16:20 -02:00
Mauro Carvalho Chehab 7a0786c19d gp8psk: Fix DVB frontend attach
The DVB binding schema at the DVB core assumes that the frontend is a
separate driver.  Faling to do that causes OOPS when the module is
removed, as it tries to do a symbol_put_addr on an internal symbol,
causing craches like:

    WARNING: CPU: 1 PID: 28102 at kernel/module.c:1108 module_put+0x57/0x70
    Modules linked in: dvb_usb_gp8psk(-) dvb_usb dvb_core nvidia_drm(PO) nvidia_modeset(PO) snd_hda_codec_hdmi snd_hda_intel snd_hda_codec snd_hwdep snd_hda_core snd_pcm snd_timer snd soundcore nvidia(PO) [last unloaded: rc_core]
    CPU: 1 PID: 28102 Comm: rmmod Tainted: P        WC O 4.8.4-build.1 #1
    Hardware name: MSI MS-7309/MS-7309, BIOS V1.12 02/23/2009
    Call Trace:
       dump_stack+0x44/0x64
       __warn+0xfa/0x120
       module_put+0x57/0x70
       module_put+0x57/0x70
       warn_slowpath_null+0x23/0x30
       module_put+0x57/0x70
       gp8psk_fe_set_frontend+0x460/0x460 [dvb_usb_gp8psk]
       symbol_put_addr+0x27/0x50
       dvb_usb_adapter_frontend_exit+0x3a/0x70 [dvb_usb]

From Derek's tests:
    "Attach bug is fixed, tuning works, module unloads without
     crashing. Everything seems ok!"

Reported-by: Derek <user.vdr@gmail.com>
Tested-by: Derek <user.vdr@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-11-13 10:02:22 -08:00
Nicolas Iooss 19157003ab [media] mb86a20s: always initialize a return value
In mb86a20s_read_status_and_stats(), when mb86a20s_read_status() fails,
the function returns the value in variable rc without initializing it
first. Fix this by propagating the error code from variable status_nr.

This bug has been found using clang and -Wsometimes-uninitialized
warning flag.

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-24 17:16:56 -02:00
Colin Ian King c0b34ab141 [media] cx24120: do not allow an invalid delivery system types
cx24120_set_frontend currently allows invalid delivery system types
other than SYS_DVBS2 and SYS_DVBS.  Fix this by returning -EINVAL
for invalid values.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Jemma Denson <jdenson@gmail.com>
2016-10-24 17:00:42 -02:00
Mauro Carvalho Chehab 4bd69e7b9c [media] dvb-frontends: don't break long lines
Due to the 80-cols restrictions, and latter due to checkpatch
warnings, several strings were broken into multiple lines. This
is not considered a good practice anymore, as it makes harder
to grep for strings at the source code.

As we're right now fixing other drivers due to KERN_CONT, we need
to be able to identify what printk strings don't end with a "\n".
It is a way easier to detect those if we don't break long lines.

So, join those continuation lines.

The patch was generated via the script below, and manually
adjusted if needed.

</script>
use Text::Tabs;
while (<>) {
	if ($next ne "") {
		$c=$_;
		if ($c =~ /^\s+\"(.*)/) {
			$c2=$1;
			$next =~ s/\"\n$//;
			$n = expand($next);
			$funpos = index($n, '(');
			$pos = index($c2, '",');
			if ($funpos && $pos > 0) {
				$s1 = substr $c2, 0, $pos + 2;
				$s2 = ' ' x ($funpos + 1) . substr $c2, $pos + 2;
				$s2 =~ s/^\s+//;

				$s2 = ' ' x ($funpos + 1) . $s2 if ($s2 ne "");

				print unexpand("$next$s1\n");
				print unexpand("$s2\n") if ($s2 ne "");
			} else {
				print "$next$c2\n";
			}
			$next="";
			next;
		} else {
			print $next;
		}
		$next="";
	} else {
		if (m/\"$/) {
			if (!m/\\n\"$/) {
				$next=$_;
				next;
			}
		}
	}
	print $_;
}
</script>

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-21 10:01:56 -02:00
Mauro Carvalho Chehab cc5ad2b659 [media] nxt6000: use pr_foo() macros instead of printk()
Replace printk() macros by their pr_foo() counterparts and
use pr_cont() for the continuation lines.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-21 08:51:32 -02:00
Mauro Carvalho Chehab 5479a582de [media] dvb-pll: use pr_foo() macros instead of printk()
Replace printk() macros by their pr_foo() counterparts.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-21 08:51:31 -02:00
Linus Torvalds a379f71a30 Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton:

 - a few block updates that fell in my lap

 - lib/ updates

 - checkpatch

 - autofs

 - ipc

 - a ton of misc other things

* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (100 commits)
  mm: split gfp_mask and mapping flags into separate fields
  fs: use mapping_set_error instead of opencoded set_bit
  treewide: remove redundant #include <linux/kconfig.h>
  hung_task: allow hung_task_panic when hung_task_warnings is 0
  kthread: add kerneldoc for kthread_create()
  kthread: better support freezable kthread workers
  kthread: allow to modify delayed kthread work
  kthread: allow to cancel kthread work
  kthread: initial support for delayed kthread work
  kthread: detect when a kthread work is used by more workers
  kthread: add kthread_destroy_worker()
  kthread: add kthread_create_worker*()
  kthread: allow to call __kthread_create_on_node() with va_list args
  kthread/smpboot: do not park in kthread_create_on_cpu()
  kthread: kthread worker API cleanup
  kthread: rename probe_kthread_data() to kthread_probe_data()
  scripts/tags.sh: enable code completion in VIM
  mm: kmemleak: avoid using __va() on addresses that don't have a lowmem mapping
  kdump, vmcoreinfo: report memory sections virtual addresses
  ipc/sem.c: add cond_resched in exit_sme
  ...
2016-10-11 17:34:10 -07:00
Masahiro Yamada 97139d4a6f treewide: remove redundant #include <linux/kconfig.h>
Kernel source files need not include <linux/kconfig.h> explicitly
because the top Makefile forces to include it with:

  -include $(srctree)/include/linux/kconfig.h

This commit removes explicit includes except the following:

  * arch/s390/include/asm/facilities_src.h
  * tools/testing/radix-tree/linux/kernel.h

These two are used for host programs.

Link: http://lkml.kernel.org/r/1473656164-11929-1-git-send-email-yamada.masahiro@socionext.com
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-10-11 15:06:33 -07:00
Matthias Schwarzott e3ea5e9448 [media] si2165: switch to regmap
This avoids some low-level operations.
It has the benefit that now register values van be read from /sys/kernel/debug/regmap
The maximum register value is just a guess - all higher addresses read as zero.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 12:56:35 -03:00
Matthias Schwarzott aa15544909 [media] si2165: use i2c_client->dev instead of i2c_adapter->dev for logging
Now that there is a i2c_client, use the more specific dev for logging.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 12:56:15 -03:00
Matthias Schwarzott 81fd533a97 [media] si2165: Remove legacy attach
Now that all users of legacy attach are converted it can be removed.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 12:55:49 -03:00
Matthias Schwarzott 7cd785adc4 [media] si2165: support i2c_client attach
Afterwards it is possible to convert attaching in card drivers.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 12:54:00 -03:00
Matthias Schwarzott 2df9dda07f [media] si2165: avoid division by zero
When si2165_init fails, the clk values in state are still at zero.
But the dvb-core ignores the return value of init will call tune
afterwards.
This will trigger a division by zero when tuning.
At least check for the variables to be non-zero before dividing.

This happened for a system with WinTV HVR-4400 PCIe-card after suspend-to-disk.
Do suspend-to-disk without accessing the DVB device before.
After wakeup try to tune.
si2165_init fails at checking the chip_mode and aborts.
Then si2165_set_if_freq_shift will fail with div-by-zero.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 12:53:22 -03:00
Abylay Ospan dd14523a8e [media] lgdt3306a: remove 20*50 msec unnecessary timeout
inside lgdt3306a_search we reading demod status 20 times with 50 msec sleep after each read.
This gives us more than 1 sec of delay. Removing this delay should not affect demod functionality.

Signed-off-by: Abylay Ospan <aospan@netup.ru>
Acked-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 12:52:04 -03:00
Abylay Ospan af4cc4629f [media] cxd2841er: force 8MHz bandwidth for DVB-C if specified bw not supported
if specified DVB-C bandwidth not supported then force 8MHz.
Should work for most cases.

Signed-off-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 12:47:57 -03:00
Abylay Ospan 0854df79f4 [media] cxd2841er: BER and SNR reading for ISDB-T
Added function to read BER for ISDB-T
Also SNR values fixed for ISDB-T

Signed-off-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 12:39:00 -03:00
Abylay Ospan 4a86bc1008 [media] cxd2841er: freeze/unfreeze registers when reading stats
ensure multiple separate register reads are from the same snapshot

Signed-off-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 12:31:30 -03:00
Antti Palosaari 43e2ea63eb [media] cxd2820r: convert to regmap api
Use regmap for I2C register access.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 10:43:09 -03:00
Antti Palosaari d51dc91761 [media] cxd2820r: improve lock detection
Check demod and ts locks and report lock status according to those.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 10:42:21 -03:00
Antti Palosaari c98975f92c [media] cxd2820r: correct logging
Use correct device for logging functions as we now have it due to
proper I2C client bindings.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 10:41:53 -03:00
Antti Palosaari 07fdf7d9f1 [media] cxd2820r: add I2C driver bindings
Add I2C driver bindings in order to support proper I2C driver
registration with driver core.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 10:41:15 -03:00
Antti Palosaari 4aa4fd86bc [media] cxd2820r: wrap legacy DVBv3 statistics via DVBv5 statistics
Return DVBv5 statistics via legacy DVBv3 API.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 10:40:29 -03:00
Antti Palosaari 90d5d2e3f0 [media] cxd2820r: dvbv5 statistics for DVB-C
Implement dvbv5 statistics for DVB-C.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 10:40:01 -03:00
Antti Palosaari 91171fb63e [media] cxd2820r: dvbv5 statistics for DVB-T2
Implement dvbv5 statistics for DVB-T2.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 10:39:36 -03:00
Antti Palosaari 2832fd3177 [media] cxd2820r: dvbv5 statistics for DVB-T
Implement dvbv5 statistics for DVB-T.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 10:39:06 -03:00
Antti Palosaari fcd09f6592 [media] cxd2820r: improve IF frequency setting
Use 64-bit calculation.

Return error if tuner does not provide get_if_frequency() callback.
All currently used tuners has it.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 10:38:41 -03:00
Colin Ian King f86548cf53 [media] lgdt3306a: fix spelling mistake "supportted" -> "supported"
Trivial fix to spelling mistake in pr_warn message.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-19 16:27:40 -03:00
Julia Lawall 14c4bf3c6f [media] dvb-frontends: constify dvb_tuner_ops structures
These structures are only used to copy into other structures, so declare
them as const.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct dvb_tuner_ops i@p = { ... };

@ok1@
identifier r.i;
expression e;
position p;
@@
e = i@p

@ok2@
identifier r.i;
expression e1, e2;
position p;
@@
memcpy(e1, &i@p, e2)

@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
struct dvb_tuner_ops e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct dvb_tuner_ops i = { ... };
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-19 16:22:55 -03:00
Mauro Carvalho Chehab 505a0ea706 [media] mb86a20s: fix demod settings
With the current settings, only one channel locks properly.
That's likely because, when this driver was written, Brazil
were still using experimental transmissions.

Change it to reproduce the settings used by the newer drivers.
That makes it lock on other channels.

Tested with both PixelView SBTVD Hybrid (cx231xx-based) and
C3Tech Digital Duo HDTV/SDTV (em28xx-based) devices.

Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-05 15:26:30 -03:00
Mauro Carvalho Chehab dafb65fb98 [media] mb86a20s: fix the locking logic
On this frontend, it takes a while to start output normal
TS data. That only happens on state S9. On S8, the TS output
is enabled, but it is not reliable enough.

However, the zigzag loop is too fast to let it sync.

As, on practical tests, the zigzag software loop doesn't
seem to be helping, but just slowing down the tuning, let's
switch to hardware algorithm, as the tuners used on such
devices are capable of work with frequency drifts without
any help from software.

Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-05 15:26:29 -03:00
Wolfram Sang 832fbe077c media: dvb-frontends: rtl2832_sdr: don't print error when allocating urb fails
kmalloc will print enough information in case of failure.

Signed-off-by: Wolfram Sang <wsa-dev@sang-engineering.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-08-30 19:13:52 +02:00
Colin Ian King fd3223966c [media] helene: fix memory leak when heleno_x_pon fails
The error return path of failed calls to heleno_x_pon leak
memory because priv is not kfree'd.  Fix this by kfree'ing
priv before returning.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-08-24 16:54:54 -03:00
Christophe JAILLET d259a5eed9 [media] drxd_hard: Add missing error code assignment before test
It is likely that checking the result of the 2nd 'read16' is expected here.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-08-24 16:22:16 -03:00
Wolfram Sang 20ff0166a5 [media] media: dvb-frontends: rtl2832_sdr: don't print error when allocating urb fails
kmalloc will print enough information in case of failure.

Signed-off-by: Wolfram Sang <wsa-dev@sang-engineering.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-08-24 08:46:41 -03:00
Arnd Bergmann bb9bd87808 drivers/media/dvb-frontends/cxd2841er.c: avoid misleading gcc warning
The addition of jump label support in dynamic_debug caused an unexpected
warning in exactly one file in the kernel:

  drivers/media/dvb-frontends/cxd2841er.c: In function 'cxd2841er_tune_tc':
  include/linux/dynamic_debug.h:134:3: error: 'carrier_offset' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     __dynamic_dev_dbg(&descriptor, dev, fmt, \
     ^~~~~~~~~~~~~~~~~
  drivers/media/dvb-frontends/cxd2841er.c:3177:11: note: 'carrier_offset' was declared here
    int ret, carrier_offset;
             ^~~~~~~~~~~~~~

The problem seems to be that the compiler gets confused by the extra
conditionals in static_branch_unlikely, to the point where it can no
longer keep track of which branches have already been taken, and it
doesn't realize that this variable is now always initialized when it
gets used.

I have done lots of randconfig kernel builds and could not find any
other file with this behavior, so I assume it's a rare enough glitch
that we don't need to change the jump label support but instead just
work around the warning in the driver.

To achieve that, I'm moving the check for the return value into the
switch() statement, which is an obvious transformation, but is enough to
un-confuse the compiler here.  The resulting code is not as nice to
read, but at least we retain the behavior of warning if it gets changed
to actually access an uninitialized carrier offset value in the future.

Link: http://lkml.kernel.org/r/20160713204342.1221511-1-arnd@arndb.de
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Abylay Ospan <aospan@netup.ru>
Cc: Sergey Kozlov <serjk@netup.ru>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Jason Baron <jbaron@akamai.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-08-04 08:50:07 -04:00
Abylay Ospan e05b1872f2 [media] cxd2841er: Reading SNR for DVB-C added
Now driver returns correct values for DVB-C:
 SNR (in dB)

[mchehab@s-opensource.com: fix a new function to be static]
Signed-off-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-16 07:01:31 -03:00
Abylay Ospan a6f330cbb3 [media] cxd2841er: Reading BER and UCB for DVB-C added
now driver returns correct values for DVB-C:
 BER (post_bit_count and post_bit_error values)
 UCB (count of uncorrected errors)
also, some code cleanup was done - checkpatch.pl now is happy

Signed-off-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-16 06:59:43 -03:00
Abylay Ospan 997bdc0c8e [media] cxd2841er: fix switch-case for DVB-C
DVB-C should use cxd2841er_read_agc_gain_c() to get the gain. The same
function is used for all DVB-C annex delivery systems.

Signed-off-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-16 06:58:59 -03:00
Mauro Carvalho Chehab 313a7dfb23 [media] cxd2841er: fix signal strength scale for ISDB-T
The scale for ISDB-T was wrong too: it was inverted, and
on a relative scale.

Use a linear interpolation to make it look better.
The formula was empirically determined, using 3 frequencies
(175 MHz, 410 MHz and 800 MHz), measuring from -50dBm to
-12dBm in steps of 0.5dB.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-16 06:56:28 -03:00