Commit graph

663 commits

Author SHA1 Message Date
Antti Palosaari d5eec231be [media] rtl2832_sdr: refcount to rtl28xxu
We are consumer of DVB frontend provided by rtl28xxu module. Due to
that we must use refcount to ensure none could remove rtl28xxu when
we are alive (or when we are streaming, if more fine-grained
refcounting is wanted).

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:22:24 -02:00
Antti Palosaari a08c378119 [media] rtl2832: implement sleep
Put demod to soft reset in order to save power when sleep. That drops
power usage ~30mA @5V on USB dongle I tested. In real life it does
not matter much as USB IF powers off demod too, but now it is done
twice - demod and USB IF.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:20:02 -02:00
Antti Palosaari 75c24005ee [media] rtl2832: claim copyright and module author
I have implemented tons of things for that driver, more than anyone
else, so lets claim copyright and module authorship.

Cc: Thomas Mair <thomas.mair86@gmail.com>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:19:24 -02:00
Antti Palosaari cd559e0b13 [media] rtl2832: cleanups and minor changes
Remove all the stuff that is not needed anymore. Rename variable.
Remove extra new lines.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:18:51 -02:00
Antti Palosaari 3bda2bf1f8 [media] rtl2832_sdr: cleanups
Small cleanups. Remove unneeded variables. Some checkpatch issues.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:18:03 -02:00
Antti Palosaari e4e78693a1 [media] rtl2832_sdr: fix logging
Pass correct device, platform device, for logging system in order
to format printouts correctly.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:17:24 -02:00
Antti Palosaari 63bdab5d31 [media] rtl2832_sdr: convert to platform driver
That SDR driver module was abusing DVB frontend SEC (satellite
equipment controller) device and due to that it was also using
legacy DVB binding. Platform bus is pseudo-bus provided by kernel
driver model and it fits cases like that, where any other busses
are not suitable.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:15:43 -02:00
Antti Palosaari 725b7f3046 [media] rtl2832_sdr: rename state variable from 's' to 'dev'
'dev' sounds better than 's' for such variable.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:13:17 -02:00
Antti Palosaari 0aa32ef9b3 [media] rtl2832: provide register IO callbacks
Provide register read and write callbacks for SDR module.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:12:34 -02:00
Antti Palosaari eec21beb35 [media] rtl2832: merge reg page as a part of reg address
Chips uses 8-bit register addresses with 5 pages. Extend register
address by using register page as a first byte of address, defining
virtual register addresses. That is common method of handling
register pages and regmap also uses it. Remove page + address
conversion glue which was there for regmap.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:12:07 -02:00
Antti Palosaari 5e5d52a00f [media] rtl2832: remove unneeded software reset from init()
There is no need to do software reset on init() as it is done a bit
later on end of set_frontend(). Software reset usually means
restarting (resetting to starting point) chip internal state machine
(FSM). Naturally it is done after all parameters are programmed.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:11:17 -02:00
Antti Palosaari dcadb82a7a [media] rtl2832: use regmap reg cache
Enable regmap register cache in order to reduce IO.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:10:54 -02:00
Antti Palosaari 4b01e01a81 [media] rtl2832: implement PID filter
Implement PID filter. This demod has PID filter size of 32 PIDs.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:09:56 -02:00
Antti Palosaari 1c7da405c6 [media] rtl2832: define more demod lock statuses
Demod lock flags are derived from demod state machine states. States
are running from 1 to 11, where highest state 11 means demod is
fully locked and streaming. Naturally smaller state numbers means
there is some partial locks.

Define now state 10 as missing synch and lock.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:09:19 -02:00
Antti Palosaari c65dbf652d [media] rtl2832: drop FE i2c gate control support
We don't need it anymore as all users are using muxed I2C adapter.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:08:37 -02:00
Antti Palosaari 25ef9f5547 [media] rtl2832: implement DVBv5 signal strength statistics
Estimate signal strength from IF digital AGC.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:07:43 -02:00
Antti Palosaari 084330b746 [media] rtl2832: wrap DVBv5 BER to DVBv3
Change legacy DVBv3 read BER to return values calculated by DVBv5
statistics.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:07:22 -02:00
Antti Palosaari f7caf93fb8 [media] rtl2832: wrap DVBv5 CNR to DVBv3 SNR
Change legacy DVBv3 read SNR to return values calculated by DVBv5
statistics.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:07:01 -02:00
Antti Palosaari 6b4fd01804 [media] rtl2832: implement DVBv5 BER statistic
DVBv5 BER.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:06:30 -02:00
Antti Palosaari 19d273d635 [media] rtl2832: implement DVBv5 CNR statistic
DVBv5 CNR.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:06:07 -02:00
Antti Palosaari d10165815b [media] rtl2832: convert to regmap API
Use regmap to cover register access routines.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:05:33 -02:00
Antti Palosaari e1174d788a [media] rtl2832: move all configuration to platform data struct
Move all needed configuration values to platform data structure
and remove old configuration code where possible.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:03:41 -02:00
Antti Palosaari 6e6aac6525 [media] rtl2832: enhance / fix logging
Pass correct device pointer to dev_* logging functions in order
print logs correctly.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:03:04 -02:00
Antti Palosaari 038c6f240e [media] rtl2832: rename driver state variable from 'priv' to 'dev'
Rename it device state variable to dev. Both priv and dev are very
common terms for such variable in kernel, but I like use dev in
order to keep drivers consistent.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:02:19 -02:00
Antti Palosaari ac32ee42cc [media] rtl2832: remove exported resources
Exported resources are not needed anymore as all users are using
callbacks carried via platform data. Due to that we will remove
those.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:01:25 -02:00
Antti Palosaari 6f5f6ee24e [media] rtl2832: add platform data callbacks for exported resources
Add callback for all of those functions which are currently
exported using EXPORT_SYMBOL. That allows us convert every user to
callbacks and eventually all exported symbols could be removed.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:00:05 -02:00
Antti Palosaari 15d37f3824 [media] rtl2830: convert to regmap API
Use regmap to cover register access routines.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 15:59:19 -02:00
Antti Palosaari fd4cfa8bb1 [media] rtl2830: implement own I2C locking
Own I2C locking is needed due to two special reasons:
1) Chips uses multiple register pages/banks on single I2C slave.
Page is changed via I2C register access.
2) Chip offers muxed/gated I2C adapter for tuner. Gate/mux is
controlled by I2C register access.

Due to these reasons, I2C locking did not fit very well.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 15:54:59 -02:00
Antti Palosaari df70ddad81 [media] rtl2830: implement PID filter
Implement PID filter.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:56:50 -02:00
Antti Palosaari 6dcfe3cc2e [media] rtl2830: wrap DVBv5 CNR to DVBv3 SNR
Change legacy DVBv3 read SNR to return values calculated by DVBv5
statistics.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:56:14 -02:00
Antti Palosaari f491391cc3 [media] rtl2830: wrap DVBv5 BER to DVBv3
Change legacy DVBv3 read BER to return values calculated by DVBv5
statistics.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:55:51 -02:00
Antti Palosaari d512e28651 [media] rtl2830: wrap DVBv5 signal strength to DVBv3
Change legacy DVBv3 signal strength to return values calculated by
DVBv5 statistics.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:55:28 -02:00
Antti Palosaari 5bb11ca586 [media] rtl2830: implement DVBv5 BER statistic
DVBv5 BER.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:55:08 -02:00
Antti Palosaari 871f70252b [media] rtl2830: implement DVBv5 signal strength statistics
Estimate signal strength from IF AGC.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:54:35 -02:00
Antti Palosaari 47b4dbfff1 [media] rtl2830: implement DVBv5 CNR statistic
DVBv5 CNR.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:53:53 -02:00
Antti Palosaari 947debb4f2 [media] rtl2830: style related changes
Trivial changes proposed by checkpatch.pl and some more.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:53:06 -02:00
Antti Palosaari b8cb50d237 [media] rtl2830: get rid of internal config data
Remove internal config and use configuration values directly from
the platform data.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:52:25 -02:00
Antti Palosaari 7cc3932889 [media] rtl2830: fix logging
Pass correct device for dev_foo() logging in order to print logs
correctly.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:51:39 -02:00
Antti Palosaari 1f153c4d88 [media] rtl2830: carry pointer to I2C client for every function
As a I2C driver struct i2c_client is top level structure representing
the driver. Use it as parameter to carry all needed information for
each function in order to simplify things.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:51:08 -02:00
Antti Palosaari f544f100ac [media] rtl2830: rename 'priv' to 'dev'
Use name 'dev' for device state instance as it is more common and
also one letter shorter.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:50:02 -02:00
Antti Palosaari aba4e34a78 [media] rtl2830: get rid of legacy DVB driver binding
Remove legacy DVB binding as all users are using I2C binding.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:48:44 -02:00
Antti Palosaari 28c0879939 [media] rtl2830: convert driver to kernel I2C model
Convert driver to kernel I2C model. Old DVB proprietary model is
still left there also.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:47:32 -02:00
Mauro Carvalho Chehab 901c4ad64c [media] dib8000: upd_demod_gain_period should be u32
X-Patchwork-Delegate: m.chehab@samsung.com
As shown at the code, upd_demod_gain_period is used to write
to two 16-bit registers:
    dib8000_write_word(state, 1946, upd_demod_gain_period & 0xFFFF);
    dib8000_write_word(state, 1947, reg | (1<<14) | ((upd_demod_gain_period >> 16) & 0xFF));

So, it should be declared as u32.

This fixes the following smatch warning:
	drivers/media/dvb-frontends/dib8000.c:1282 dib8000_agc_startup() warn: right shifting more than type allows

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 13:21:25 -02:00
Antti Palosaari c32b281628 [media] si2168: change firmware variable name and type
Rename firmware variable from fw_file to fw_name and change its type
from u8 to const char as request_firmware() input defines.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-01-29 18:46:05 -02:00
Antti Palosaari 9b7839c306 [media] si2168: print chip version
Print chip version once using log level into when init() is called.
Remove cold/warm state printing as those are not very useful.

old printing:
si2168 6-0064: found a 'Silicon Labs Si2168' in cold state
si2168 6-0064: downloading firmware from file 'dvb-demod-si2168-b40-01.fw'
si2168 6-0064: firmware version: 4.0.11
si2168 6-0064: found a 'Silicon Labs Si2168' in warm state

new printing:
si2168 6-0064: found a 'Silicon Labs Si2168-B40'
si2168 6-0064: downloading firmware from file 'dvb-demod-si2168-b40-01.fw'
si2168 6-0064: firmware version: 4.0.11

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-01-29 18:45:36 -02:00
Antti Palosaari 58f6693fa1 [media] si2168: remove unneeded fw variable initialization
commit 034e1ec0ce
si2168: One function call less in si2168_init() after error detection

That commit added goto label for error path to release firmware,
but forgets to remove variable NULL set. Remove those now.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-01-29 18:44:43 -02:00
Antti Palosaari 68c16a76c6 [media] si2168: enhance firmware download routine
All known old firmware firmware formats are downloaded using 8 byte
chunks. Reject firmware if it could not be divided to 8 byte chunks
and because of that we could simplify some calculations. Now both
supported firmware download routines are rather similar.

Cc: Olli Salonen <olli.salonen@iki.fi>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-01-29 18:44:00 -02:00
Antti Palosaari 1ee5e7dd5e [media] si2168: add own goto label for kzalloc failure
Use own label for kzalloc failure in which does not call kfree().
kfree() could be called with NULL, but it is still better to have
own label which skips unnecessary kfree().

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-01-29 18:43:16 -02:00
Antti Palosaari e5dd1100c7 [media] si2168: change stream id debug log formatter
Change formatter from signed to unsigned as stream_id is 32bit
unsigned variable.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-01-29 18:42:43 -02:00
Antti Palosaari 955e0ab8ce [media] si2168: change firmware version print from debug to info
Even firmware version is not needed to know, it is still interesting
and useful to know some cases. Due to that increase its printing to
info log level.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-01-29 18:42:12 -02:00