Commit Graph

129 Commits

Author SHA1 Message Date
Johan Hovold f3cae04bd4 media: rtl28xxu: fix zero-length control request
commit 76f22c93b209c811bd489950f17f8839adb31901 upstream.

The direction of the pipe argument must match the request-type direction
bit or control requests may fail depending on the host-controller-driver
implementation.

Control transfers without a data stage are treated as OUT requests by
the USB stack and should be using usb_sndctrlpipe(). Failing to do so
will now trigger a warning.

The driver uses a zero-length i2c-read request for type detection so
update the control-request code to use usb_sndctrlpipe() in this case.

Note that actually trying to read the i2c register in question does not
work as the register might not exist (e.g. depending on the demodulator)
as reported by Eero Lehtinen <debiangamer2@gmail.com>.

Reported-by: syzbot+faf11bbadc5a372564da@syzkaller.appspotmail.com
Reported-by: Eero Lehtinen <debiangamer2@gmail.com>
Tested-by: Eero Lehtinen <debiangamer2@gmail.com>
Fixes: d0f232e823 ("[media] rtl28xxu: add heuristic to detect chip type")
Cc: stable@vger.kernel.org      # 4.0
Cc: Antti Palosaari <crope@iki.fi>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-08-12 13:21:01 +02:00
Thomas Gleixner 1621633323 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 1
Based on 2 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version this program is distributed in the
  hope that it will be useful but without any warranty without even
  the implied warranty of merchantability or fitness for a particular
  purpose see the gnu general public license for more details you
  should have received a copy of the gnu general public license along
  with this program if not write to the free software foundation inc
  51 franklin street fifth floor boston ma 02110 1301 usa

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option [no]_[pad]_[ctrl] any later version this program is
  distributed in the hope that it will be useful but without any
  warranty without even the implied warranty of merchantability or
  fitness for a particular purpose see the gnu general public license
  for more details you should have received a copy of the gnu general
  public license along with this program if not write to the free
  software foundation inc 51 franklin street fifth floor boston ma
  02110 1301 usa

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 176 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Jilayne Lovejoy <opensource@jilayne.com>
Reviewed-by: Steve Winslow <swinslow@gmail.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190519154040.652910950@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-21 11:28:39 +02:00
Nikita Gerasimov d695eb5b3b media: rtl28xxu: add support for Sony CXD2837ER slave demod
Since 2018 some new revisions of RTL2832P based devices having
Sony CXD2837ER as a slave demodulator instead of Panasonic MN88473.
CXD2837ER handled in DVB_CXD2841ER module but it's has a lack of control.
So slave demod has to be reseted by GPIO0 before detecting to woke up
CXD2837ER.

Signed-off-by: Nikita Gerasimov <nikitych@yandex.ru>
Cc: Antti Palosaari <crope@iki.fi>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-12-05 03:21:45 -05:00
Sean Young 183e19f5b9 media: rc: Remove init_ir_raw_event and DEFINE_IR_RAW_EVENT macros
This can be done with c99 initializers, which makes the code cleaner
and more transparent. It does require gcc 4.6, because of this bug
in earlier versions:

	https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10676

Since commit cafa0010cd ("Raise the minimum required gcc version to
4.6"), this is the case.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-04 14:22:27 -04:00
Mauro Carvalho Chehab c0decac19d media: use strscpy() instead of strlcpy()
The implementation of strscpy() is more robust and safer.

That's now the recommended way to copy NUL terminated strings.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-09-11 13:32:17 -04:00
Mauro Carvalho Chehab 845b978a87 media: rtl28xxu: be sure that it won't go past the array size
smatch warns that the RC query code could go past the array size:

	drivers/media/usb/dvb-usb-v2/rtl28xxu.c:1757 rtl2832u_rc_query() error: buffer overflow 'buf' 128 <= 130
	drivers/media/usb/dvb-usb-v2/rtl28xxu.c:1758 rtl2832u_rc_query() error: buffer overflow 'buf' 128 <= 130

The driver logic gets the length of the IR RX buffer with:

        ret = rtl28xxu_rd_reg(d, IR_RX_BC, &buf[0]);
	...
        len = buf[0];

In thesis, this could range between 0 and 255 [1].

While this should never happen in practice, due to hardware limits,
smatch is right when it complains about that, as there's nothing at
the logic that would prevent it. So, if for whatever reason, buf[0]
gets filled by rtl28xx read functions with a value bigger than 128,
it will go past the array.

So, add an explicit check.

[1] I've no idea why smatch thinks that the maximum value is 130.
I double-checked the code several times. Was unable to find any
reason for assuming 130. Perhaps smatch is not properly parsing
u8 here?

Fixes: b5cbaa43a6 ("[media] rtl28xx: initial support for rtl2832u")
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-08-08 10:57:14 -04:00
Colin Ian King bab4cb30db media: rtl28xxu: make array rc_nec_tab static const
Don't populate the array rc_nec_tab on the stack, instead make it
static const. Makes the object code smaller by over 620 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
  49511	  17040	     64	  66615	  10437	rtl28xxu.o

After:
   text	   data	    bss	    dec	    hex	filename
  48825	  17104	     64	  65993	  101c9	rtl28xxu.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-09-23 08:28:28 -04:00
Sean Young 6d741bfed5 media: rc: rename RC_TYPE_* to RC_PROTO_* and RC_BIT_* to RC_PROTO_BIT_*
RC_TYPE is confusing and it's just the protocol. So rename it.

Suggested-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sean Young <sean@mess.org>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20 10:02:48 -04:00
Sean Young 8c34b5c4c8 [media] rc: raw IR drivers cannot handle cec, unknown or other
unknown and other are for IR protocols for which we have no decoder,
so the raw IR drivers have no chance of generating them. cec is not
an IR protocol.

Signed-off-by: Sean Young <sean@mess.org>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Bruno Prémont <bonbons@linux-vserver.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-30 12:40:50 -02:00
Sean Young 2ceeca0499 [media] rc: split nec protocol into its three variants
Currently we do not know what variant (bit length) of the nec protocol
is used, other than from guessing from the length of the scancode. Now
nec will be handled the same way as the sony protocol or the rc6 protocol;
one variant per bit length.

In the future we might want to expose the rc protocol type to userspace
and we don't want to be introducing this world of pain into userspace
too.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22 11:46:49 -03:00
Antti Palosaari 734fd634a6 [media] rtl28xxu: increase failed I2C msg repeat count to 3
1 and 2 wasn't enough for mn88472 chip on Astrometa device,
so increase it to 3.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2016-06-07 15:39:46 -03:00
Peter Rosin 1cf79db28e [media] rtl2832: change the i2c gate to be mux-locked
The root i2c adapter lock is then no longer held by the i2c mux during
accesses behind the i2c gate, and such accesses need to take that lock
just like any other ordinary i2c accesses do.

So, declare the i2c gate mux-locked, and zap the regmap overrides
that makes the i2c accesses unlocked and use plain old regmap
accesses. This also removes the need for the regmap wrappers used by
rtl2832_sdr, so deconvolute the code further and provide the regmap
handle directly instead of the wrapper functions.

Tested-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2016-05-04 22:40:02 +02:00
Antti Palosaari d884acad4f [media] rtl2832: improve slave TS control
Add callback parameter to select enable / disable slave TS and use
it when slave demod is in use.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2016-03-03 09:26:49 -03:00
Antti Palosaari 4c7cad4bbf [media] rtl28xxu: retry failed i2c messages
Sometimes i2c transfer fails. That happens especially when large
amount of data is written sequentially eg. firmware download.
Problem arises with both integrated rtl2832 demod and external
mn88472 demod, which is clear indicator it is busy i2c bus issue.
Use i2c core retry logic in order fix the issue by repeating failed
message. Another solution which also works is to add ~100us delay
between i2c messages - but repeating sounds more elegant and does
not cause any extra delay for success cases.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2016-02-01 09:20:24 -02:00
Antti Palosaari 31d60f1bc5 [media] rtl28xxu: return demod reg page from driver cache
Return current active rtl2830/rtl2832 register page from the driver
cache in order to reduce I2C I/O. Register page is already cached
due to I2C write needs.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-12-23 14:11:02 -02:00
Linus Torvalds b037865754 media updates for v4.4-rc1
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJWOJZoAAoJEAhfPr2O5OEVmjYP/0RnfVjvRDtx0RxHDmvsowlt
 sHyrm5C7VME06b4J3O9qpC7PbMCAalvSkYp+bbxF+b//9EfwjvRER+NR8ebgn1Mw
 1NQKMtCusWRf4RzI+9osB3pFYgg/cYG2nKl0QVCXHL6xZszEQ9dBrFHEEHfVe8db
 JU1fGuF6TQNJdYgsVNMN9rStRB0vj3urfehLjB+E138VzDAnzPNA7I7Z4xsWWJw3
 V+J7CWLN1xW9IT59LXtRjbD/aCF9KrAmGigS0nCtDz7XVRPh+ZoXQLD073uLP2L3
 uYxOmadvc5+5iVwUP4zSsJ6+vw9kLr6Q30sNtLP7V+VkCSlCQNTOePLavB5T8qVY
 M2qALvwWjujtoSEjZHr7TqrlEpio98OSy1dNJ8GmuOb3UUAKocNN8sGG8h2nR/BR
 wv2OL/XPNcyB2LV6HeHZz9JiXB+rTbyXEN8CP2cD8ruGhNM5haak3d2l4FYszRXr
 /a/5JlYAcNrJii6PAXHyBtm6l0C4GPiAk3HQhII2fTErRr8fpln/G5AfaKjun5H8
 1Rbxx5JP+5qSHozmz2hNb4w92qqtPugj7qqu7sHCbwKLhh2Aspwo12GkN9acOIsI
 Kn1U/DWMRrkyptJAxBihsrEX3BXeQdNOPydKfMYEM7qE8EfTDM0uaIFQ+KVWCmNA
 Qh2TXAp6CZiuBvaqKzyl
 =sR0p
 -----END PGP SIGNATURE-----

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

Pull media updates from Mauro Carvalho Chehab:
 "Media updates, including:

   - Lots of improvements at the kABI documentation
   - Split of Videobuf2 into a common part and a V4L2 specific one
   - Split of the VB2 tracing events into a separate header file
   - s5p-mfc got support for Exynos 5433
   - v4l2 fixes for 64-bits alignment when running 32 bits userspace
     on ARM
   - Added support for SDR radio transmitter at core, vivid and hackrf
     drivers
   - Some y2038 fixups
   - Some improvements at V4L2 colorspace support
   - saa7164 converted to use the V4L2 core control framework
   - several new boards additions, cleanups and fixups

  PS: There are two patches for scripts/kernel-doc that are needed by
  the documentation patches on Media.  Jon is OK on merging those via
  my tree"

* tag 'media/v4.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (146 commits)
  [media] c8sectpfe: Remove select on CONFIG_FW_LOADER_USER_HELPER_FALLBACK
  [media] DocBook media: update copyright/version numbers
  [media] ivtv: Convert to get_user_pages_unlocked()
  [media] media/v4l2-ctrls: fix setting autocluster to manual with VIDIOC_S_CTRL
  [media] DocBook media: Fix a typo in encoder cmd
  [media] DocBook: add SDR specific info to G_MODULATOR / S_MODULATOR
  [media] DocBook: add SDR specific info to G_TUNER / S_TUNER
  [media] hackrf: do not set human readable name for formats
  [media] hackrf: add support for transmitter
  [media] hackrf: switch to single function which configures everything
  [media] hackrf: add control for RF amplifier
  [media] DocBook: add modulator type field
  [media] v4l: add type field to v4l2_modulator struct
  [media] DocBook: document SDR transmitter
  [media] v4l2: add support for SDR transmitter
  [media] DocBook: document tuner RF gain control
  [media] v4l2: add RF gain control
  [media] v4l2: rename V4L2_TUNER_ADC to V4L2_TUNER_SDR
  [media] media/vivid-osd: fix info leak in ioctl
  [media] media: videobuf2: Move v4l2-specific stuff to videobuf2-v4l2
  ...
2015-11-05 12:05:15 -08:00
Antti Palosaari d18ca5b7ce [media] rtl28xxu: fix control message flaws
Add lock to prevent concurrent access for control message as control
message function uses shared buffer. Without the lock there may be
remote control polling which messes the buffer causing IO errors.
Increase buffer size and add check for maximum supported message
length.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=103391
Fixes: c56222a6b2 ("[media] rtl28xxu: move usb buffers to state")

Cc: <stable@vger.kernel.org> # 4.0+
Signed-off-by: Antti Palosaari <crope@iki.fi>
2015-10-22 15:48:27 -02:00
Graham Eccleston 702c287082 [media] Compro U650F support
Added Compro U650F to the rtl28xxu devices.

Signed-off-by: Graham Eccleston <grahameccleston_@hotmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-10-03 09:36:55 -03:00
Antti Palosaari 9ea964f369 [media] rtl28xxu: load SDR module for fc2580 based devices
Load rtl2832_sdr driver for devices having fc2580 tuner.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-05-18 15:59:35 -03:00
Antti Palosaari 7e33f8a282 [media] rtl28xxu: set correct FC2580 tuner for RTL2832 demod
rtl2832 demod driver has support for FC2580 tuner config, no need to
abuse FC0012 settings anymore.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-05-18 15:56:19 -03:00
Antti Palosaari 88ffe55ae3 [media] rtl28xxu: bind tua9001 using I2C binding
Change tua9001 driver from media binding to I2C client binding.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-05-18 15:52:36 -03:00
Antti Palosaari 35fc0e0fcb [media] rtl28xxu: bind fc2580 using I2C binding
Change fc2580 driver from media binding to I2C client binding.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-05-18 15:45:55 -03:00
Wei Yongjun 250d2ff016 [media] rtl28xxu: fix return value check in rtl2832u_tuner_attach()
In case of error, the function platform_device_register_data() returns
ERR_PTR() and never returns NULL. The NULL test in the return value check
should be replaced with IS_ERR().

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-05-12 13:27:22 -03:00
Olli Salonen 699dcffc52 [media] rtl2832: add support for GoTView MasterHD 3 USB tuner
GoTView MasterHD 3 is a DVB-T2/C USB 2.0 tuner.

It's based on the following components:
- USB bridge: RTL2832P (contains also DVB-T demodulator)
- Demodulator: Si2168-A30
- Tuner: Si2148-A20

The demodulator and the tuner will need firmwares. The Si2148 uses Si2158
firmware. Antti has the firmwares available for download:
http://palosaari.fi/linux/v4l-dvb/firmware/

Do note that for DVB-T either of the demodulators can be used. DVB-C and
DVB-T2 are only supported by the Si2168 demodulator. The driver will
register 2 frontends for the same adapter. Frontend 0 will be the RTL2832
demodulator and frontend 1 will be the Si2168 demodulator. The same
tuner is used for both.

As a consequence of the above, it's recommended to use application that
does implement proper DVBv5 support.

For some reason, the old I2C write method sporadically fails. Thus the
need for an option to only use the new I2C write method supported by the
RTL2832.

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-05-12 13:25:35 -03:00
Olli Salonen d744a0cb8a [media] rtl28xxu: add I2C read without write
Add support for I2C read operation without a preceeding write.

While here, change the error code to EOPNOTSUPP in case an
unsupported I2C operation is attempted.

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-05-12 13:21:29 -03:00
Mauro Carvalho Chehab 676ee36be0 Merge branch 'patchwork' into v4l_for_linus
* patchwork: (404 commits)
  [media] uvcvideo: add support for VIDIOC_QUERY_EXT_CTRL
  [media] uvcvideo: fix cropcap v4l2-compliance failure
  [media] media: omap3isp: remove unused clkdev
  [media] coda: Add tracing support
  [media] coda: drop dma_sync_single_for_device in coda_bitstream_queue
  [media] coda: fix fill bitstream errors in nonstreaming case
  [media] coda: call SEQ_END when the first queue is stopped
  [media] coda: fail to start streaming if userspace set invalid formats
  [media] coda: remove duplicate error messages for buffer allocations
  [media] coda: move parameter buffer in together with context buffer allocation
  [media] coda: allocate bitstream buffer from REQBUFS, size depends on the format
  [media] coda: allocate per-context buffers from REQBUFS
  [media] coda: use strlcpy instead of snprintf
  [media] coda: bitstream payload is unsigned
  [media] coda: fix double call to debugfs_remove
  [media] coda: check kasprintf return value in coda_open
  [media] coda: bitrate can only be set in kbps steps
  [media] v4l2-mem2mem: no need to initialize b in v4l2_m2m_next_buf and v4l2_m2m_buf_remove
  [media] s5p-mfc: set allow_zero_bytesused flag for vb2_queue_init
  [media] coda: set allow_zero_bytesused flag for vb2_queue_init
  ...
2015-04-21 06:12:35 -03:00
Christian Dale 09f50121e3 [media] WinFast DTV2000 DS Plus
Add Leadtek WinFast DTV2000DS Plus device based on Realtek RTL2832U.

I have not tested the remote, but it is the Y04G0051 model.

Signed-off-by: Christian Dale <kernel@techmunk.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-08 15:41:58 -03:00
Dimitris Lampridis 882302c859 [media] rtl28xxu: add support for Turbo-X DTT2000
ID 1b80:d3a4 Afatech

Simply added the PID (0xd3a4) of this DVB-T USB device to the list of rtl2832u-supported devices. VID (0x1b80) is same as KWORLD2.

Tested and verified to work in amd64 with kernels 3.13.0 and 3.16.0.

Signed-off-by: Dimitris Lampridis <dlampridis@logikonlabs.com>
Reviewed-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-08 13:14:38 -03:00
Benjamin Larsson 021cd2d21b [media] mn88472: add ts mode and ts clock to driver
Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
Reviewed-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-08 06:54:41 -03:00
Benjamin Larsson 46cf707482 [media] rtl28xxu: lower the rc poll time to mitigate i2c transfer errors
The Astrometa device has issues with i2c transfers. Lowering the
poll time somehow makes these errors disappear.

Signed-off-by: Benjamin Larsson <benjamin@southpole.se>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 21:51:37 -03:00
Antti Palosaari b18042a673 [media] rtl28xxu: return success for unimplemented FE callback
Return success for FE callback on case we don't have any special
implementation. fc0013 tuner driver calls that callback in order to
switch antenna input, even we don't provide antenna switch.
Returning error caused fc0013 driver given up tuning.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-02 18:27:14 -03:00
Mauro Carvalho Chehab e181b1f190 [media] rtl28xxu: properly initialize pdata
As complained by smatch:
	drivers/media/usb/dvb-usb-v2/rtl28xxu.c:1159 rtl2832u_tuner_attach() info: 'pdata' is not actually initialized (unreached code).

Cc: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:38:48 -02:00
Antti Palosaari 670ef05f82 [media] rtl28xxu: correct reg access routine name prefixes
Use rtl28xxu_ prefix for all register access routine names.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:27:33 -02:00
Antti Palosaari 723abfd787 [media] rtl28xxu: merge rtl2831u and rtl2832u properties
As all the callbacks are already same we could merge device
properties struct too and save space.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:27:04 -02:00
Antti Palosaari de701f0ff1 [media] rtl28xxu: merge chip type specific all callbacks
Merge all chip type specific prefixed (rtl2831u_ and rtl2832u_)
callback to top level callback prefixed as rtl28xxu_.

rtl2831u_foo() => rtl28xxu_foo()
rtl2832u_foo() => rtl28xxu_foo()

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:26:37 -02:00
Antti Palosaari d0f232e823 [media] rtl28xxu: add heuristic to detect chip type
Detect automatically whether chip is old RTL2831U or newer
RTL2832U/RTL2832P. Detection is based I2C command that is found only
from newer RTL2832U models.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:25:24 -02:00
Antti Palosaari c56222a6b2 [media] rtl28xxu: move usb buffers to state
Buffer needed for USB control message is small so move it to state
and get rid of alloc/free used for each control message.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:24:49 -02:00
Antti Palosaari 5ba4ca1a14 [media] rtl28xxu: fix logging
Pass correct device pointer to dev_* logging in order to print
module name and bus id correctly.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:24:15 -02:00
Antti Palosaari 9a02e8fdef [media] rtl28xxu: rename state variable 'priv' to 'dev'
I prefer dev over priv and I want keep all my drivers in line with
that.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:23:58 -02:00
Antti Palosaari 6a53fa2350 [media] rtl28xxu: do not refcount rtl2832_sdr module
This driver, rtl28xxu, offers frontend service for rtl2832_sdr
module, thus we are producer and rtl2832_sdr module is consumer.
Due to that, reference counting should be done in way rtl2832_sdr
takes refrence to rtl28xxu. Remove wrong refcount.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:21:48 -02:00
Antti Palosaari a6f62431a0 [media] rtl28xxu: simplify FE callback handling
Logic is so simple that there is no idea to separate tuner selection to
own function, instead do it in a callback and get rid of one function.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:21:19 -02:00
Antti Palosaari 1dbbdceeb6 [media] rtl28xxu: fix DVB FE callback
DVB FE callback functionality went broken after I moved tuners to
demod muxed I2C adapter. That happens because driver state was
carried by I2C adapter and when mux is used there is one adapter
more in a chain.
USB adapter <-> I2C adapter <-> 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:20:46 -02:00
Antti Palosaari 488be13a5e [media] rtl28xxu: use master I2C adapter for slave demods
Both mn88472 and mn88473 slave demods are connected to master I2C
bus, not the bus behind master demod I2C gate like tuners. Use
correct bus.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:16:47 -02:00
Antti Palosaari a2f7f220df [media] rtl28xxu: switch SDR module to platform driver
RTL2832 SDR module implements kernel platform driver. Change old
binding to that one.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:16:17 -02:00
Antti Palosaari e20b0cf2f3 [media] rtl28xxu: add support for RTL2832U/RTL2832 PID filter
RTL2832 demod integrated into RTL2832U has PID filter. PID filtering
is provided by rtl2832 demod driver. Add support for it.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:10:19 -02:00
Antti Palosaari 164f3d2a83 [media] rtl28xxu: use demod mux I2C adapter for every tuner
Tuners are connected to demod I2C adapter. Use that muxed adapter
for each tuner. That allows us to get rid of hackish FE gate control
solution.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:08:16 -02:00
Antti Palosaari de0a5f1132 [media] rtl28xxu: use platform data config for rtl2832 demod
Use platform data configuration for rtl2832 demod driver. Old
configuration are still left as it is used for rtl2832_sdr driver.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:04:13 -02:00
Antti Palosaari 77a2e76b85 [media] rtl28xxu: use rtl2832 demod callbacks accessing its resources
Switch demod resource use from exported symbols to callbacks its
provides.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-03 16:01:04 -02:00
Antti Palosaari d9bd3fa6ec [media] rtl28xxu: add support for RTL2831U/RTL2830 PID filter
RTL2830 demod integrated to RTL2831U has PID filter. PID filtering
is provided by rtl2830 demod driver. Add support for it.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:57:21 -02:00
Antti Palosaari c0ceac97d2 [media] rtl28xxu: use I2C binding for RTL2830 demod driver
rtl2830 driver supports now I2C model too. Start using it.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-02 17:48:20 -02:00