Commit graph

42 commits

Author SHA1 Message Date
Kangjie Lu c9b7d8f252 media: lgdt3306a: fix a missing check of return value
If lgdt3306a_read_reg() fails, the read data in "val" is incorrect, thus
shouldn't be further used. The fix inserts a check for the return value
of lgdt3306a_read_reg(). If it fails, goto fail.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2019-01-16 11:43:48 -05:00
zhong jiang 2c4746cf45 media: dvb-frontends: Use kmemdup instead of duplicating its function
kmemdup has implemented the function that kmalloc() + memcpy().
We prefer to kmemdup rather than code opened implementation.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-12-03 13:27:55 -05:00
Mauro Carvalho Chehab f1b1eabff0 media: dvb: represent min/max/step/tolerance freqs in Hz
Right now, satellite frontend drivers specify frequencies in kHz,
while terrestrial/cable ones specify in Hz. That's confusing
for developers.

However, the main problem is that universal frontends capable
of handling both satellite and non-satelite delivery systems
are appearing. We end by needing to hack the drivers in
order to support such hybrid frontends.

So, convert everything to specify frontend frequencies in Hz.

Tested-by: Katsuhiro Suzuki <suzuki.katsuhiro@socionext.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-08-02 18:10:48 -04:00
Luc Van Oostenryck f172fe9fd8 media: lgdt3306a: fix lgdt3306a_search()'s return type
The method dvb_frontend_ops::search() is defined as
returning an 'enum dvbfe_search', but the implementation in this
driver returns an 'int'.

Fix this by returning 'enum dvbfe_search' in this driver too.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Acked-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-05 10:21:17 -04:00
Brad Love f6618cc8b4 media: lgdt3306a: remove symbol count mismatch fix
This symbol mismatch is handled by NULL'ing out the release
callback if the driver is loaded as an i2c device.

This patch reverts:
- commit 94448e21cf ("media: lgdt3306a: Fix a double kfree on i2c
  device remove")
- commit 835d66173a ("media: lgdt3306a: Fix module count mismatch
  on usb unplug")

The symbol count mismatch is handled by:
- commit 5b3a8e9069 ("media: lgdt3306a: Set fe ops.release to
  NULL if probed")

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-07 03:58:48 -05:00
Brad Love e7f4d7516a media: lgdt3306a: Announce successful creation
The driver is near silent, this adds a simple announcement at the
end of probe after the chip has been detected and upgrades a debug
message to error if probe has failed.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-06 07:25:55 -05:00
Brad Love 94448e21cf media: lgdt3306a: Fix a double kfree on i2c device remove
Both lgdt33606a_release and lgdt3306a_remove kfree state, but _release is
called first, then _remove operates on states members before kfree'ing it.
This can lead to random oops/GPF/etc on USB disconnect.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-06 04:40:02 -05:00
Brad Love 835d66173a media: lgdt3306a: Fix module count mismatch on usb unplug
When used as an i2c device there is a module usage count mismatch on
removal, preventing the driver from being used thereafter. dvb_attach
increments the usage count so it is properly balanced on removal.

On disconnect of Hauppauge SoloHD/DualHD before:

lsmod | grep lgdt3306a
lgdt3306a              28672  -1
i2c_mux                16384  1 lgdt3306a

On disconnect of Hauppauge SoloHD/DualHD after:

lsmod | grep lgdt3306a
lgdt3306a              28672  0
i2c_mux                16384  1 lgdt3306a

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-06 04:39:30 -05:00
Brad Love 4966c0c5c6 media: lgdt3306a: Add QAM AUTO support
As configured currently, modulation in the driver is set to auto detect,
no matter what the user sets modulation to. This leads to both QAM64
and QAM256 having the same effect. QAM AUTO is explicitly added here for
compatibility with scanning software who can use AUTO instead of doing
essentially the same scan twice.
Also included is a module option to enforce a specific QAM modulation if
desired. The true modulation is read before calculating the snr.
Changes are backwards compatible with current behaviour.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-06 04:37:30 -05:00
Brad Love 4c7c3f9b1a media: lgdt3306a: QAM streaming improvement
Add some register updates required for stable viewing
on Cablevision in NY. Does not adversely affect other providers.

Changes since v1:
- Change upper case hex to lower case.

Signed-off-by: Brad Love <brad@nextdimension.cc>
Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-06 04:35:51 -05:00
Brad Love 5b3a8e9069 media: lgdt3306a: Set fe ops.release to NULL if probed
If release is part of frontend ops then it is called in the
course of dvb_frontend_detach. The process also decrements
the module usage count. The problem is if the lgdt3306a
driver is reached via i2c_new_device, then when it is
eventually destroyed remove is called, which further
decrements the module usage count to negative. After this
occurs the driver is in a bad state and no longer works.
Also fixed by NULLing out the release callback is a double
kfree of state, which introduces arbitrary oopses/GPF.
This problem is only currently reachable via the em28xx driver.

On disconnect of Hauppauge SoloHD before:

lsmod | grep lgdt3306a
lgdt3306a              28672  -1
i2c_mux                16384  1 lgdt3306a

On disconnect of Hauppauge SoloHD after:

lsmod | grep lgdt3306a
lgdt3306a              28672  0
i2c_mux                16384  1 lgdt3306a

Signed-off-by: Brad Love <brad@nextdimension.cc>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-06 04:35:28 -05:00
Mauro Carvalho Chehab fada193559 media: move dvb kAPI headers to include/media
Except for DVB, all media kAPI headers are at include/media.

Move the headers to it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-28 13:16:01 -05:00
Thomas Meyer 1f679ff6c7 media: lgdt3306a: Use ARRAY_SIZE macro
Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
yourself.
Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
/ARRAY_SIZE(\1)/g' and manual check/verification.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-09-23 08:29:08 -04: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
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
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
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
Mauro Carvalho Chehab 7e3e68bcfd [media] dvb_frontend: pass the props cache to get_frontend() as arg
Instead of using the DTV properties cache directly, pass the get
frontend data as an argument. For now, everything should remain
the same, but the next patch will prevent get_frontend to
affect the global cache.

This is needed because several drivers don't care enough to only
change the properties if locked. Due to that, calling
G_PROPERTY before locking on those drivers will make them to
never lock. Ok, those drivers are crap and should never be
merged like that, but the core should not rely that the drivers
would be doing the right thing.

Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2016-02-04 16:27:30 -02:00
Mauro Carvalho Chehab 0df289a209 [media] dvb: Get rid of typedev usage for enums
The DVB API was originally defined using typedefs. This is against
Kernel CodingStyle, and there's no good usage here. While we can't
remove its usage on userspace, we can avoid its usage in Kernelspace.

So, let's do it.

This patch was generated by this shell script:

	for j in $(grep typedef include/uapi/linux/dvb/frontend.h |cut -d' ' -f 3); do for i in $(find drivers/media -name '*.[ch]' -type f) $(find drivers/staging/media -name '*.[ch]' -type f); do sed "s,${j}_t,enum $j," <$i >a && mv a $i; done; done

While here, make CodingStyle fixes on the affected lines.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Acked-by: Stefan Richter <stefanr@s5r6.in-berlin.de> # for drivers/media/firewire/*
2015-06-09 17:47:35 -03:00
Mauro Carvalho Chehab 16afc67216 [media] lgdt3306a: fix indentation
drivers/media/dvb-frontends/lgdt3306a.c:2104 lgdt3306a_DumpRegs() warn: inconsistent indenting

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 13:45:10 -03:00
Mauro Carvalho Chehab 95f22c5aae [media] lgdt3306a: Minor source code cleanups
Fix a few minor CodingStyle issues at the source code:
	- Use proper multi-line comments;
	- Align the log tables;
	- Remove the .type from dvb_frontend_ops, since this is not
	  needed anymore (since the drivers conversion to DVBv5);
	- Remove emacs format macro.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:15 -03:00
Mauro Carvalho Chehab 534f4364f9 [media] lgdt3306a: Break long lines
Fix most of checkpatch warnings like:
	WARNING: line over 80 characters

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:15 -03:00
Mauro Carvalho Chehab 9369fe012d [media] lgdt3306a: constify log tables
Ideally, we should be replacing this function by intlog10().

While we don't do that, let's at least constify the tables,
in order to remove its code footfrint, and get rid of nelems.

This also fixes a few 80-cols CodingStyle warnings.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:14 -03:00
Mauro Carvalho Chehab c9897649db [media] lbdt3306a: remove uneeded braces
WARNING: braces {} are not necessary for any arm of this statement
+		if (ret == 0) {
[...]
+		} else {
[...]

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:14 -03:00
Mauro Carvalho Chehab b4e43e959b [media] lgdt3306a: Don't use else were not needed
Get rid of the remaining checkpatch.pl warnings:
	WARNING: braces {} are not necessary for any arm of this statement

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:14 -03:00
Mauro Carvalho Chehab b1a88c713a [media] lbdt3306a: simplify the lock status check
The logic there is too complex and it looks like an inifite
loop.

So, simplify the logic and implement it as a for loop.

This gets rid of the following checkpatch.pl warnings:

WARNING: else is not generally useful after a break or return
+			return LG3306_UNLOCK;
+		} else {

WARNING: else is not generally useful after a break or return
+			return LG3306_UNLOCK;
+		} else {

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:13 -03:00
Mauro Carvalho Chehab 097117cab5 [media] lbdt3306a: rework at printk macros
Use pr_foo() where there's a direct replacement. For debug, use
custom-made macros, for now, as there are 3 different debug levels.

We should get rid of those some day, specially since several such
macros can be just removed, as Kernel trace would provide about
the same output.

This gets rid of some checkpatch errors:

WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then dev_info(dev, ... then pr_info(...  to printk(KERN_INFO ...
+#define lg_info(fmt, arg...)	printk(KERN_INFO "lgdt3306a: " fmt, ##arg)

ERROR: Macros with complex values should be enclosed in parentheses
+#define lg_dbg(fmt, arg...) if (debug & DBG_INFO)			\
+				lg_printk(KERN_DEBUG,         fmt, ##arg)

ERROR: Macros with complex values should be enclosed in parentheses
+#define lg_reg(fmt, arg...) if (debug & DBG_REG)			\
+				lg_printk(KERN_DEBUG,         fmt, ##arg)

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:13 -03:00
Mauro Carvalho Chehab e2c47fa7dd [media] lgdt3306a: Remove FSF address
Fix this CodingStyle error:

	ERROR: Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so ag$
	#56: FILE: drivers/media/dvb-frontends/lgdt3306a.c:19:
	+ *    along with this program; if not, write to the Free Software$

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:13 -03:00
Mauro Carvalho Chehab ee0133eea0 [media] lgdt3306a: properly handle I/O errors
Fixes the following smatch errors:

drivers/media/dvb-frontends/lgdt3306a.c: In function 'lgdt3306a_set_if':
drivers/media/dvb-frontends/lgdt3306a.c:695:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
  int ret;
      ^
drivers/media/dvb-frontends/lgdt3306a.c: In function 'lgdt3306a_monitor_vsb':
drivers/media/dvb-frontends/lgdt3306a.c:1033:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
  int ret;
      ^
drivers/media/dvb-frontends/lgdt3306a.c: In function 'lgdt3306a_check_oper_mode':
drivers/media/dvb-frontends/lgdt3306a.c:1082:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
  int ret;
      ^
drivers/media/dvb-frontends/lgdt3306a.c: In function 'lgdt3306a_check_lock_status':
drivers/media/dvb-frontends/lgdt3306a.c:1109:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
  int ret;
      ^
drivers/media/dvb-frontends/lgdt3306a.c: In function 'lgdt3306a_check_neverlock_status':
drivers/media/dvb-frontends/lgdt3306a.c:1185:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
  int ret;
      ^
drivers/media/dvb-frontends/lgdt3306a.c: In function 'lgdt3306a_pre_monitoring':
drivers/media/dvb-frontends/lgdt3306a.c:1199:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
  int ret;
      ^
drivers/media/dvb-frontends/lgdt3306a.c: In function 'lgdt3306a_get_packet_error':
drivers/media/dvb-frontends/lgdt3306a.c:1310:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
  int ret;
      ^

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:12 -03:00
Mauro Carvalho Chehab a132fef816 [media] lgdt3306a: don't go past the buffer
As warned by smatch:
	drivers/media/dvb-frontends/lgdt3306a.c:1354 log10_x1000() error: buffer overflow 'valx_x10' 14 <= 14
	drivers/media/dvb-frontends/lgdt3306a.c:1355 log10_x1000() error: buffer overflow 'log10x_x1000' 14 <= 14

There's a potential of returning a value out of the buffer. Fix it.

While here, remove the ugly braced block.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:12 -03:00
Mauro Carvalho Chehab c43e651205 [media] lgdt3306a: Use IS_ENABLED() for attach function
Simplify the check if CONFIG_DVB_LGDT3306A is enabled, use the
IS_ENABLED() macro, just like the other frontend modules.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:12 -03:00
Mauro Carvalho Chehab 4937ba94a0 [media] lgdt3306a: Use hexadecimal values in lowercase
While this is not a mandatory rule at the CodingStyle, we prefer
hexadecimal values in lowercase. Currently, there's a mix of lowercase
and uppercase ons at lgdt3306a. So, convert all to lowercase with this
small script:

	perl -ne 'if (m,0x([\dA-F]+),) { $o=$1; $n=lc $1; s,0x($o),0x$n, } print $_'

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:11 -03:00
Michael Ira Krufky 34a5a2f811 [media] lgdt3306a: more small whitespace cleanups
Just CodingStyle. No functional changes.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:11 -03:00
Michael Ira Krufky 831a91120a [media] lgdt3306a: typo fix
fix WARNING: 'supress' may be misspelled - perhaps 'suppress'?

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:11 -03:00
Michael Ira Krufky cb4671c87f [media] lgdt3306a: fix WARNING: please, no spaces at the start of a line
Properly indent register initialization tables.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:10 -03:00
Michael Ira Krufky 6da7ac9857 [media] lgdt3306a: fix ERROR: do not use C99 // comments
Replace C99 comments by /* */ blocks.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:10 -03:00
Michael Ira Krufky f883d603d4 [media] lgdt3306a: do not add new typedefs
We should not be using typedefs at the Kernel, as this makes harder
for reviewers to understand the code.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:10 -03:00
Michael Ira Krufky ae21e44777 [media] lgdt3306a: fix ERROR: do not use assignment in if condition
Just CodingStyle fix.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:09 -03:00
Michael Ira Krufky ebd9175ea4 [media] lgdt3306a: move EXPORT_SYMBOL to be just after function
Fixes CodingStyle error:
	WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:09 -03:00
Michael Ira Krufky c714efe458 [media] lgdt3306a: remove unnecessary 'else'
No need for an else, as the previous if will return.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:09 -03:00
Michael Ira Krufky 8e8cd34eaa [media] lgdt3306a: clean up whitespace & unneeded brackets
No functional changes.

Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:08 -03:00
Fred Richter b63b36fa44 [media] DVB: add support for LG Electronics LGDT3306A ATSC/QAM-B Demodulator
This ATSC/QAM-B demodulator is used by several new devices.

Add support for it. Other patches will fix CodingStyle issues.

Signed-off-by: Fred Richter <frichter@hauppauge.com>
Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-03 10:34:08 -03:00