platform/kernel/linux-3.10.git
9 years agoupstream: [media] v4l2-dv-timings: fix GTF calculation
Martin Bugge [Thu, 23 Jan 2014 09:40:00 +0000 (06:40 -0300)]
upstream: [media] v4l2-dv-timings: fix GTF calculation

Round off image width to nearest 8 (GTF_CELL_GRAN)

A source sending a GTF (Generalized Timing Formula) format have no means of
signalling image width. The assumed aspect ratio may result in an odd image
width but according to the standard image width should be in multiple of 8.

Cc: Mats Randgaard <matrandg@cisco.com>
Signed-off-by: Martin Bugge <marbugge@cisco.com>
Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] Revert "[media] videobuf_vm_{open,close} race fixes"
Hans Verkuil [Fri, 3 Jan 2014 11:10:49 +0000 (08:10 -0300)]
upstream: [media] Revert "[media] videobuf_vm_{open,close} race fixes"

This reverts commit a242f426108c284049a69710f871cc9f11b13e61.

That commit actually caused deadlocks, rather then fixing them.

If ext_lock is set to NULL (otherwise videobuf_queue_lock doesn't do
anything), then you get this deadlock:

The driver's mmap function calls videobuf_mmap_mapper which calls
videobuf_queue_lock on q. videobuf_mmap_mapper calls  __videobuf_mmap_mapper,
__videobuf_mmap_mapper calls videobuf_vm_open and videobuf_vm_open
calls videobuf_queue_lock on q (introduced by above patch): deadlocked.

This affects drivers using dma-contig and dma-vmalloc. Only dma-sg is
not affected since it doesn't call videobuf_vm_open from __videobuf_mmap_mapper.

Most drivers these days have a non-NULL ext_lock. Those that still use
NULL there are all fairly obscure drivers, which is why this hasn't been
seen earlier.

Since everything worked perfectly fine for many years I prefer to just
revert this patch rather than trying to fix it. videobuf is quite fragile
and I rather not touch it too much. Work is (slowly) progressing to move
everything over to vb2 or at the very least use non-NULL ext_lock in
videobuf.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: <stable@vger.kernel.org> # for v3.11 and up
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Reported-by: Pete Eberlein <pete@sensoray.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] media: v4l2-dev: fix video device index assignment
Marek Szyprowski [Tue, 3 Dec 2013 13:14:29 +0000 (10:14 -0300)]
upstream: [media] media: v4l2-dev: fix video device index assignment

The side effect of commit 1056e4388b045 ("v4l2-dev: Fix race condition on
__video_register_device") is the increased number of index value assigned
on video_device registration. Before that commit video_devices were
numbered from 0, after it, the indexes starts from 1, because get_index()
always count the device, which is being registered. Some device drivers
rely on video_device index number for internal purposes, i.e. s5p-mfc
driver stopped working after that patch. This patch restores the old method
of numbering the video_device indexes.

Cc: stable@vger.kernel.org # for v3.12
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Ricardo Ribalda <ricardo.ribalda@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: media: core: Don't use i2c_client->driver
Lars-Peter Clausen [Sun, 29 Sep 2013 08:51:01 +0000 (10:51 +0200)]
upstream: media: core: Don't use i2c_client->driver

The 'driver' field of the i2c_client struct is redundant and is going to be
removed. The results of the expressions 'client->driver.driver->field' and
'client->dev.driver->field' are identical, so replace all occurrences of the
former with the later.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
9 years agoupstream: [media] v4l2-dv-timings: add callback to handle exceptions
Hans Verkuil [Mon, 19 Aug 2013 14:21:50 +0000 (11:21 -0300)]
upstream: [media] v4l2-dv-timings: add callback to handle exceptions

In most cases the v4l2_bt_timings_cap struct has all the information
necessary to determine valid timings, but occasionally there are exceptions.
Add a callback function to be able to test for those exceptions.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] v4l2-dv-timings: rename v4l2_dv_valid_timings to v4l2_valid_dv_timings
Hans Verkuil [Mon, 19 Aug 2013 13:23:33 +0000 (10:23 -0300)]
upstream: [media] v4l2-dv-timings: rename v4l2_dv_valid_timings to v4l2_valid_dv_timings

All other functions follow the v4l2_<foo>_dv_timings pattern, do the same for
this function.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] v4l2-dv-timings: export the timings list
Hans Verkuil [Mon, 19 Aug 2013 13:19:54 +0000 (10:19 -0300)]
upstream: [media] v4l2-dv-timings: export the timings list

Some drivers need to be able to access the full list of timings.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] v4l2-dev: Fix race condition on __video_register_device
Ricardo Ribalda [Tue, 13 Aug 2013 14:04:06 +0000 (11:04 -0300)]
upstream: [media] v4l2-dev: Fix race condition on __video_register_device

When 2 devices are registered at the same time, in Part 2 both will get
the same minor number, making Part6 crash, because it cannot create a
create a device with a duplicated minor:
[    7.157648] ------------[ cut here ]------------
[    7.157666] WARNING: at fs/sysfs/dir.c:530 sysfs_add_one+0xbd/0xe0()
[    7.157669] sysfs: cannot create duplicate filename '/dev/char/81:1'
[    7.157672] Modules linked in: qtec_xform(+) qt5023_video(+) videobuf2_vmalloc videobuf2_dma_sg videobuf2_memops videobuf2_core gpio_xilinx(+) qtec_white qtec_cmosis(+) qtec_pcie qt5023
[    7.157694] CPU: 0 PID: 120 Comm: systemd-udevd Not tainted 3.10.0-qtec-standard #8
[    7.157698] Hardware name: QTechnology QT5022/QT5022, BIOS PM_2.1.0.309 X64 05/23/2013
[    7.157702]  0000000000000009 ffff8801788358e8 ffffffff8176c487 ffff880178835928
[    7.157707]  ffffffff8106f6f0 ffff880175759770 00000000ffffffef ffff880175759930
[    7.157712]  ffff8801788359e8 ffff880178bff000 ffff880175759930 ffff880178835988
[    7.157718] Call Trace:
[    7.157728]  [<ffffffff8176c487>] dump_stack+0x19/0x1b
[    7.157735]  [<ffffffff8106f6f0>] warn_slowpath_common+0x70/0xa0
[    7.157740]  [<ffffffff8106f7d6>] warn_slowpath_fmt+0x46/0x50
[    7.157746]  [<ffffffff81324b35>] ? strlcat+0x65/0x90
[    7.157750]  [<ffffffff811d516d>] sysfs_add_one+0xbd/0xe0
[    7.157755]  [<ffffffff811d5c6b>] sysfs_do_create_link_sd+0xdb/0x200
[    7.157760]  [<ffffffff811d5db1>] sysfs_create_link+0x21/0x40
[    7.157765]  [<ffffffff813e277b>] device_add+0x21b/0x6d0
[    7.157772]  [<ffffffff813f2985>] ? pm_runtime_init+0xe5/0xf0
[    7.157776]  [<ffffffff813e2c4e>] device_register+0x1e/0x30
[    7.157782]  [<ffffffff8153e8c3>] __video_register_device+0x313/0x610
[    7.157791]  [<ffffffffa00957c5>] qtec_xform_probe+0x465/0x7a4 [qtec_xform]
[    7.157797]  [<ffffffff813e7b13>] platform_drv_probe+0x43/0x80
[    7.157802]  [<ffffffff813e531a>] ? driver_sysfs_add+0x7a/0xb0
[    7.157807]  [<ffffffff813e584b>] driver_probe_device+0x8b/0x3a0
[    7.157812]  [<ffffffff813e5c0b>] __driver_attach+0xab/0xb0
[    7.157816]  [<ffffffff813e5b60>] ? driver_probe_device+0x3a0/0x3a0
[    7.157820]  [<ffffffff813e37fd>] bus_for_each_dev+0x5d/0xa0
[    7.157825]  [<ffffffff813e529e>] driver_attach+0x1e/0x20
[    7.157829]  [<ffffffff813e4d3e>] bus_add_driver+0x10e/0x280
[    7.157833]  [<ffffffffa0099000>] ? 0xffffffffa0098fff
[    7.157837]  [<ffffffffa0099000>] ? 0xffffffffa0098fff
[    7.157842]  [<ffffffff813e6317>] driver_register+0x77/0x170
[    7.157848]  [<ffffffff81151bcc>] ? __vunmap+0x9c/0x110
[    7.157852]  [<ffffffffa0099000>] ? 0xffffffffa0098fff
[    7.157857]  [<ffffffff813e7236>] platform_driver_register+0x46/0x50
[    7.157863]  [<ffffffffa0099010>] qtec_xform_plat_driver_init+0x10/0x12 [qtec_xform]
[    7.157869]  [<ffffffff810002ea>] do_one_initcall+0xea/0x1a0
[    7.157875]  [<ffffffff810cf1f1>] load_module+0x1a91/0x2630
[    7.157880]  [<ffffffff8133bee0>] ? ddebug_proc_show+0xe0/0xe0
[    7.157887]  [<ffffffff817760f2>] ? page_fault+0x22/0x30
[    7.157892]  [<ffffffff810cfe7a>] SyS_init_module+0xea/0x140
[    7.157898]  [<ffffffff8177e5b9>] tracesys+0xd0/0xd5
[    7.157902] ---[ end trace 660cc3a65a4bf01b ]---
[    7.157939] __video_register_device: device_register failed

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Acked-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] v4l2-device: check if already unregistered
Hans Verkuil [Wed, 12 Jun 2013 09:04:04 +0000 (06:04 -0300)]
upstream: [media] v4l2-device: check if already unregistered

It was possible to unregister an already unregistered v4l2_device struct.
Add a check whether that already happened and just return if that was
the case.
Also refuse to register a v4l2_device if both the dev and name fields are
empty. A warning was already produced in that case, but since the name field
is now used to detect whether or not the v4l2_device was already unregistered
this particular combination should be rejected.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
9 years agoupstream: [media] videobuf_vm_{open,close} race fixes
Al Viro [Thu, 9 May 2013 18:03:33 +0000 (15:03 -0300)]
upstream: [media] videobuf_vm_{open,close} race fixes

just use videobuf_queue_lock(map->q) to protect map->count; vm_area_operations
->open() and ->close() are called just under vma->vm_mm->mmap_sem, which
doesn't help the drivers at all, since clonal VMAs are normally in different
address spaces...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
9 years agoupstream: [media] v4l: Helper function for obtaining timestamps
Sakari Ailus [Sat, 15 Sep 2012 10:51:47 +0000 (07:51 -0300)]
upstream: [media] v4l: Helper function for obtaining timestamps

v4l2_get_timestamp() produces a monotonic timestamp but unlike
ktime_get_ts(), it uses struct timeval instead of struct timespec, saving
the drivers the conversion job when getting timestamps for v4l2_buffer's
timestamp field.

Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
9 years agoupstream: [media] media: v4l2-ctrl: add a helper function to add standard control...
Lad, Prabhakar [Tue, 18 Sep 2012 18:54:38 +0000 (15:54 -0300)]
upstream: [media] media: v4l2-ctrl: add a helper function to add standard control with driver specific menu

Add helper function v4l2_ctrl_new_std_menu_items(), which adds
a standard menu control, with driver specific menu.

Signed-off-by: Lad, Prabhakar <prabhakar.lad@ti.com>
Signed-off-by: Manjunath Hadli <manjunath.hadli@ti.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
9 years agoupstream: [media] v4l2: make vidioc_(un)subscribe_event const
Hans Verkuil [Tue, 4 Sep 2012 14:46:09 +0000 (11:46 -0300)]
upstream: [media] v4l2: make vidioc_(un)subscribe_event const

Write-only ioctls should have a const argument in the ioctl op.
Do this conversion for vidioc_(un)subscribe_event.
Adding const for write-only ioctls was decided during the 2012 Media Workshop.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
9 years agoupstream: [media] drxk_hard: Remove most 80-cols checkpatch warnings
Mauro Carvalho Chehab [Sun, 28 Apr 2013 14:47:51 +0000 (11:47 -0300)]
upstream: [media] drxk_hard: Remove most 80-cols checkpatch warnings

X-Patchwork-Delegate: mchehab@redhat.com
There are a few cases where breaking the code into separate
lines make it worse to read. However, on several places,
breaking it to make checkpatch.pl happier is OK and improves
code readability.
So, break longer lines where that won't cause harm.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Conflicts:
drivers/media/dvb-frontends/drxk_hard.c

9 years agoupstream: [media] si2168: add copyright and license
Antti Palosaari [Tue, 15 Apr 2014 00:55:12 +0000 (21:55 -0300)]
upstream: [media] si2168: add copyright and license

Add copyright and license for each file.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] si2168: add support for DVB-C (annex A version)
Antti Palosaari [Sat, 12 Apr 2014 04:58:32 +0000 (01:58 -0300)]
upstream: [media] si2168: add support for DVB-C (annex A version)

Add support for DVB-C (annex A version).

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] si2168: add support for DVB-T2
Antti Palosaari [Fri, 11 Apr 2014 23:35:27 +0000 (20:35 -0300)]
upstream: [media] si2168: add support for DVB-T2

Add support for DVB-T2.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] lgdt3305: include sleep functionality in lgdt3304_ops
Shuah Khan [Fri, 21 Mar 2014 02:05:50 +0000 (23:05 -0300)]
upstream: [media] lgdt3305: include sleep functionality in lgdt3304_ops

Add sleep ops to lgdt3304_ops to invoke lgdt3305_sleep() to be called
from dvb_frontend_suspend(). lgdt3305_soft_reset() is called for both
3304 and 3305 devices. soft_reset and sleep touch LGDT3305_GEN_CTRL_3
on 3304 and 3305 devices. Hence, adding sleep to lgdt3304_ops will help
suspend 3304 properly from dvb_frontend_suspend().

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: use customise option correctly
Paul Bolle [Sat, 5 Apr 2014 15:20:02 +0000 (12:20 -0300)]
upstream: [media] drx-j: use customise option correctly

The Kconfig entry for "Micronas DRX-J demodulator" defaults to modular
if DVB_FE_CUSTOMISE is set. But that Kconfig symbol was replaced with
MEDIA_SUBDRV_AUTOSELECT as of v3.7. So use the new symbol. And negate
the logic, because MEDIA_SUBDRV_AUTOSELECT's logic is the opposite of
the former logic.

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] af9033: implement PID filter
Antti Palosaari [Thu, 13 Feb 2014 18:40:59 +0000 (15:40 -0300)]
upstream: [media] af9033: implement PID filter

Implement PID filter and export it via symbol.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] m88ds3103: remove dead code
Antti Palosaari [Sat, 1 Feb 2014 14:57:50 +0000 (11:57 -0300)]
upstream: [media] m88ds3103: remove dead code

Coverity CID 1166050: Dead default in switch (DEADCODE)

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx39xyj: fix 64 bit division on 32 bit arch
Gianluca Gennari [Tue, 11 Mar 2014 13:41:47 +0000 (10:41 -0300)]
upstream: [media] drx39xyj: fix 64 bit division on 32 bit arch

Fix this linker warning:
WARNING: "__divdi3" [media_build/v4l/drx39xyj.ko] undefined!

[m.chehab@samsung.com: add include for asm/div64.h]
Signed-off-by: Gianluca Gennari <gennarone@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: drx-j: Fix post-BER calculus on QAM modulation
Mauro Carvalho Chehab [Tue, 11 Mar 2014 10:43:54 +0000 (07:43 -0300)]
upstream: drx-j: Fix post-BER calculus on QAM modulation

There are two troubles there:
1) the bit error measure were not accumulating;
2) it was missing the bit count.

Fix them.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: drx-j: use ber_count var
Mauro Carvalho Chehab [Tue, 11 Mar 2014 10:34:44 +0000 (07:34 -0300)]
upstream: drx-j: use ber_count var

drivers/media/dvb-frontends/drx39xyj/drxj.c: In function 'ctrl_get_qam_sig_quality':
drivers/media/dvb-frontends/drx39xyj/drxj.c:9468:6: warning: variable 'ber_cnt' set but not used [-Wunused-but-set-variable]
  u32 ber_cnt = 0; /* BER count */
      ^

By reading the comment, it is said that BER should be calculated as:
qam_pre_rs_ber = frac_times1e6( ber_cnt, rs_bit_cnt );

Also, it makes sense to take the mantissa into account, so fix the
code to do what's commented.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: enable DVBv5 stats
Mauro Carvalho Chehab [Mon, 10 Mar 2014 11:22:34 +0000 (08:22 -0300)]
upstream: [media] drx-j: enable DVBv5 stats

Now that everything is set, let's enable DVBv5 stats, for
applications that support it.

DVBv3 apps will still work.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Fix detection of no signal
Mauro Carvalho Chehab [Mon, 10 Mar 2014 11:18:31 +0000 (08:18 -0300)]
upstream: [media] drx-j: Fix detection of no signal

When the signal is 7, it means that no signal was received.

Value experimentally measured.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: properly handle bit counts on stats
Mauro Carvalho Chehab [Mon, 10 Mar 2014 11:08:53 +0000 (08:08 -0300)]
upstream: [media] drx-j: properly handle bit counts on stats

Instead of just assuming that the min resolution is 1E-6,
pass both bit error and bit counts for userspace to calculate
BER. The same applies for PER, for 8VSB. It is not clear how
to get the packet count for QAM. So, for now, don't expose PER
for QAM.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Prepare to use DVBv5 stats
Mauro Carvalho Chehab [Sun, 9 Mar 2014 20:46:01 +0000 (17:46 -0300)]
upstream: [media] drx-j: Prepare to use DVBv5 stats

Convert the stats internally to use DVBv5. For now, it will keep
showing everything via DVBv3 API only, as the .len value were
not initialized.

That allows testing if the new stats code didn't break anything.

A latter patch will add the final bits for the DVBv5 stats to
fully work.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: re-add get_sig_strength()
Mauro Carvalho Chehab [Sun, 9 Mar 2014 20:37:27 +0000 (17:37 -0300)]
upstream: [media] drx-j: re-add get_sig_strength()

We'll need to use this function. Restore it from the
git history.

This function will be used on the next patch.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Don't use "state" for DVB lock state
Mauro Carvalho Chehab [Sun, 9 Mar 2014 20:30:48 +0000 (17:30 -0300)]
upstream: [media] drx-j: Don't use "state" for DVB lock state

State is already used on other places for the state struct.
Don't use it here, to avoid troubles with latter patches.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: get rid of some unused vars
Mauro Carvalho Chehab [Sun, 9 Mar 2014 13:47:01 +0000 (10:47 -0300)]
upstream: [media] drx-j: get rid of some unused vars

As reported when compiled with W=1:

drivers/media/dvb-frontends/drx39xyj/drxj.c: In function ‘ctrl_set_channel’:
drivers/media/dvb-frontends/drx39xyj/drxj.c:10340:26: warning: variable ‘common_attr’ set but not used [-Wunused-but-set-variable]
  struct drx_common_attr *common_attr = NULL;
                          ^
drivers/media/dvb-frontends/drx39xyj/drxj.c:10336:6: warning: variable ‘intermediate_freq’ set but not used [-Wunused-but-set-variable]
  s32 intermediate_freq = 0;

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: propagate returned error from request_firmware()
Mauro Carvalho Chehab [Sun, 9 Mar 2014 13:36:24 +0000 (10:36 -0300)]
upstream: [media] drx-j: propagate returned error from request_firmware()

Fix a smatch warning:
drivers/media/dvb-frontends/drx39xyj/drxj.c:11711 drx_ctrl_u_code() info: why not propagate 'rc' from request_firmware() instead of (-2)?

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Fix usage of drxj_close()
Mauro Carvalho Chehab [Sun, 9 Mar 2014 13:33:54 +0000 (10:33 -0300)]
upstream: [media] drx-j: Fix usage of drxj_close()

This function is currently not used. However, it was meant to
be called at device release. So, add it there.

While here, remove the bad check, as reported by Dan, as
smatch warning:
drivers/media/dvb-frontends/drx39xyj/drxj.c:20041 drxj_close() warn: variable dereferenced before check 'demod' (see line 20036)

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: remove external symbols
Mauro Carvalho Chehab [Sun, 9 Mar 2014 13:33:19 +0000 (10:33 -0300)]
upstream: [media] drx-j: remove external symbols

This driver doesn't export any external symbol, except for
the attach() method.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: get rid of dead code
Mauro Carvalho Chehab [Sun, 9 Mar 2014 10:34:51 +0000 (07:34 -0300)]
upstream: [media] drx-j: get rid of dead code

There are large chunks of code at drx-j that aren't used. Most
of them are due to analog TV support. Well, just enabling them
won't make analog support work, as devices with DRX and analog
support requires an extra chip (avf4910).

We don't have drivers for it, nor the current device that uses
this frontend has support for analog TV.

So, let's just get rid of this code. If latter needed, this
patch can easily be reverted from git history.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: don't use mc_info before checking if its not NULL
Mauro Carvalho Chehab [Sun, 9 Mar 2014 13:10:19 +0000 (10:10 -0300)]
upstream: [media] drx-j: don't use mc_info before checking if its not NULL

smatch warning:
drivers/media/dvb-frontends/drx39xyj/drxj.c:20803 drx_ctrl_u_code() warn: variable dereferenced before check 'mc_info' (see line 20800)

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx39xxj.h: Fix undefined reference to attach function
Mauro Carvalho Chehab [Sun, 9 Mar 2014 12:46:39 +0000 (09:46 -0300)]
upstream: [media] drx39xxj.h: Fix undefined reference to attach function

As reported by the kbuild test robot <fengguang.wu@intel.com>:

drivers/built-in.o: In function `em28xx_dvb_init':
    em28xx-dvb.c:(.text+0x876f2c): undefined reference to `drx39xxj_attach'

That happens when CONFIG_VIDEO_EM28XX_DVB is selected, and neither
CONFIG_MEDIA_SUBDRV_AUTOSELECT or DVB_DRX39XYJ is selected.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Fix dubious usage of "&" instead of "&&"
Mauro Carvalho Chehab [Sun, 9 Mar 2014 12:36:59 +0000 (09:36 -0300)]
upstream: [media] drx-j: Fix dubious usage of "&" instead of "&&"

Fixes the following warnings:
drivers/media/dvb-frontends/drx39xyj/drxj.c:16764:68: warning: dubious: x & !y
drivers/media/dvb-frontends/drx39xyj/drxj.c:16778:68: warning: dubious: x & !y
drivers/media/dvb-frontends/drx39xyj/drxj.c:16797:68: warning: dubious: x & !y

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Don't use 0 as NULL
Mauro Carvalho Chehab [Sun, 9 Mar 2014 12:32:58 +0000 (09:32 -0300)]
upstream: [media] drx-j: Don't use 0 as NULL

Fixes the following warnings:
drivers/media/dvb-frontends/drx39xyj/drxj.c:1679:65: warning: Using plain integer as NULL pointer
drivers/media/dvb-frontends/drx39xyj/drxj.c:1679:71: warning: Using plain integer as NULL pointer
drivers/media/dvb-frontends/drx39xyj/drxj.c:1681:52: warning: Using plain integer as NULL pointer
drivers/media/dvb-frontends/drx39xyj/drxj.c:1681:58: warning: Using plain integer as NULL pointer

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: drxj_default_aud_data_g can be static
Fengguang Wu [Sun, 9 Mar 2014 12:08:30 +0000 (09:08 -0300)]
upstream: [media] drx-j: drxj_default_aud_data_g can be static

Fix sparse warning:
drivers/media/dvb-frontends/drx39xyj/drxj.c:1039:16: sparse: symbol 'drxj_default_aud_data_g' was not declared. Should it be static?

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: set it to serial mode by default
Mauro Carvalho Chehab [Mon, 3 Mar 2014 09:13:17 +0000 (06:13 -0300)]
upstream: [media] drx-j: set it to serial mode by default

Currently, there's just one device using this frontend: PCTV 80e,
and it works on serial mode.

Change the default here to serial mode. If we add more devices,
then this option should be set via config structure.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Properly initialize mpeg struct before using it
Mauro Carvalho Chehab [Sun, 2 Mar 2014 14:01:11 +0000 (11:01 -0300)]
upstream: [media] drx-j: Properly initialize mpeg struct before using it

The cfg_mpeg_output has more fields than what it is initialized
when the code is called. Be sure to initialize everything before
use, in order to avoid random behaviors.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: disable OOB
Mauro Carvalho Chehab [Sun, 2 Mar 2014 12:52:34 +0000 (09:52 -0300)]
upstream: [media] drx-j: disable OOB

Just like the windows driver, disable OOB after setting the driver
version.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: fix boot failure due to null pointer dereference
Shuah Khan [Fri, 28 Feb 2014 21:23:02 +0000 (18:23 -0300)]
upstream: [media] drx-j: fix boot failure due to null pointer dereference

DJH_DEBUG only code path in drxbsp_i2c_write_read() dereferences
w_dev_addr and subsequently w_dev_addr->user_data->i2c which results
in failure during boot. This patch fixes the null pointer derefence
bug as well as the following compile errors:

  LD      arch/x86/built-in.o
  CC      drivers/media/dvb-frontends/drx39xyj/drxj.o
drivers/media/dvb-frontends/drx39xyj/drxj.c: In function ‘drxbsp_i2c_write_read’:
drivers/media/dvb-frontends/drx39xyj/drxj.c:1558:25: error: redeclaration of ‘state’ with no linkage
  struct drx39xxj_state *state = w_dev_addr->user_data;
                         ^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1512:25: note: previous declaration of ‘state’ was here
  struct drx39xxj_state *state;
                         ^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1558:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  struct drx39xxj_state *state = w_dev_addr->user_data;
  ^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1560:17: error: redeclaration of ‘msg’ with no linkage
  struct i2c_msg msg[2] = {
                 ^
drivers/media/dvb-frontends/drx39xyj/drxj.c:1513:17: note: previous declaration of ‘msg’ was here
  struct i2c_msg msg[2];
                 ^

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: remove return that prevents DJH_DEBUG code to run
Shuah Khan [Fri, 28 Feb 2014 21:23:01 +0000 (18:23 -0300)]
upstream: [media] drx-j: remove return that prevents DJH_DEBUG code to run

drxbsp_i2c_write_read() has return that prevents DJH_DEBUG code to run.
Remove it.

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: fix pr_dbg undefined compile errors when DJH_DEBUG is defined
Shuah Khan [Fri, 28 Feb 2014 21:23:00 +0000 (18:23 -0300)]
upstream: [media] drx-j: fix pr_dbg undefined compile errors when DJH_DEBUG is defined

drxj.c fails to compile with the following errors when DJH_DEBUG
is defined.

drivers/media/dvb-frontends/drx39xyj/drxj.c:1567:2: error: implicit declaration of function ‘pr_dbg’ [-Werror=implicit-function-declaration]
  pr_dbg("drx3933 i2c operation addr=%x i2c=%p, wc=%x rc=%x\n",
  ^

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: be sure to do a full software reset
Mauro Carvalho Chehab [Thu, 27 Feb 2014 11:48:44 +0000 (08:48 -0300)]
upstream: [media] drx-j: be sure to do a full software reset

Mimic what windows driver does here: it writes 0x07 to
SIO_CC_SOFT_RST__A, instead of just 0x03.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: be sure to send the powerup command at device open
Mauro Carvalho Chehab [Thu, 27 Feb 2014 08:35:13 +0000 (05:35 -0300)]
upstream: [media] drx-j: be sure to send the powerup command at device open

As drxj_close puts the device in powerdown, we need to power it up
properly at drxj_open.

This is the behavior noticed at the Windows driver.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Use single master mode
Mauro Carvalho Chehab [Thu, 27 Feb 2014 06:34:17 +0000 (03:34 -0300)]
upstream: [media] drx-j: Use single master mode

There are no other I2C masters here. Also, the Windows driver uses
this mode (and both drxd and drxk Kernel drivers). So, switch
to it.

That helps to compare the logs between the Linux driver and the
Windows one.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Allow userspace control of LNA
Mauro Carvalho Chehab [Sun, 16 Feb 2014 03:38:44 +0000 (00:38 -0300)]
upstream: [media] drx-j: Allow userspace control of LNA

Instead of just disabling the LNA every time, allow to control it from
userspace.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: get rid of function wrappers
Mauro Carvalho Chehab [Mon, 27 Jan 2014 05:33:18 +0000 (02:33 -0300)]
upstream: [media] drx-j: get rid of function wrappers

On several places, the I2C functions are just wrappers to others.

Get rid of it.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: get rid of struct drx_dap_fasi_funct_g
Mauro Carvalho Chehab [Mon, 27 Jan 2014 05:24:25 +0000 (02:24 -0300)]
upstream: [media] drx-j: get rid of struct drx_dap_fasi_funct_g

This struct contains the first abstraction layer for the I2C
access routines. Get rid of it.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: get rid of drx_dap_fasi.c
Mauro Carvalho Chehab [Mon, 27 Jan 2014 05:14:14 +0000 (02:14 -0300)]
upstream: [media] drx-j: get rid of drx_dap_fasi.c

This file contains an abstract layer for the I2C transfer
functions. Get rid of it, merging it at drxj. This will allow
to remove another abstraction layer there, making the code
easier to read, and removing the functions that just return
-EIO.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: get rid of function prototypes at drx_dap_fasi.c
Mauro Carvalho Chehab [Mon, 27 Jan 2014 05:07:01 +0000 (02:07 -0300)]
upstream: [media] drx-j: get rid of function prototypes at drx_dap_fasi.c

Reorder functions and data at drx_dap_fasi.c, in order to avoid
having function prototypes.

This is in preparation to merge this code inside drxj, removing
some duplicated bits there, and getting rid of yet another
abstraction layer.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Get rid of I2C protocol version
Mauro Carvalho Chehab [Mon, 27 Jan 2014 05:01:40 +0000 (02:01 -0300)]
upstream: [media] drx-j: Get rid of I2C protocol version

This is not used anywere. Get rid of it.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Fix qam/256 mode
Mauro Carvalho Chehab [Sun, 26 Jan 2014 19:41:51 +0000 (16:41 -0300)]
upstream: [media] drx-j: Fix qam/256 mode

QAM/256 currently doesn't work, as the code is only called if
channel->mirror is DRX_MIRROR_AUTO, but a prevous if prevents
this condition to happen.

While here, returns -EINVAL to not supported QAM modes and
simplify the code, reducing the number of indents.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: remove some unused data
Mauro Carvalho Chehab [Sun, 26 Jan 2014 19:07:53 +0000 (16:07 -0300)]
upstream: [media] drx-j: remove some unused data

Those struct data aren't used anymore. Get rid of them.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: use the proper timeout code on scu_command
Mauro Carvalho Chehab [Sun, 26 Jan 2014 18:55:57 +0000 (15:55 -0300)]
upstream: [media] drx-j: use the proper timeout code on scu_command

Checking if a time is after another one can have issues, as
times are generally u32 wide.

Use the proper macros for that at scu_command().

It should be noticed that other places also use jiffies
calculus on an improper way. This should be fixed too,
but the logic there is more complex. So, let's do it in
separate patches.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: call ctrl_set_standard even if a standard is powered
Mauro Carvalho Chehab [Sun, 26 Jan 2014 18:39:06 +0000 (15:39 -0300)]
upstream: [media] drx-j: call ctrl_set_standard even if a standard is powered

Modulation and other parameters might have changed. So, better
to call ctrl_set_standard() even if the device is already
powered.

That helps to put the device into a sane state, if something
got wrong on a previous set_frontend call.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: avoid calling power_down_foo twice
Mauro Carvalho Chehab [Sun, 26 Jan 2014 18:30:53 +0000 (15:30 -0300)]
upstream: [media] drx-j: avoid calling power_down_foo twice

When switching from one video standard to another one,
power_down_vsb is called twice. Well, as the device is already
in power_down mode, the second call always fail. This causes that
any subsequent frontend set to fail as well:

[145074.501243] drx39xyj:power_down_vsb: called
[145089.195396] drx39xyj:power_down_vsb: error -5
[145089.195404] drx39xyj:ctrl_set_standard: error -5
[145089.195417] drx39xyj:drx39xxj_set_frontend: Failed to set standard! result=fffffffb
[145089.195470] drx39xyj:ctrl_sig_quality: error -5
[145089.195473] drx39xyj:drx39xxj_read_ber: drx39xxj: could not get ber!
[145089.195475] drx39xyj:ctrl_sig_quality: error -5
[145089.195477] drx39xyj:drx39xxj_read_signal_strength: drx39xxj: could not get signal strength!
[145089.195479] drx39xyj:ctrl_sig_quality: error -5
[145089.195480] drx39xyj:drx39xxj_read_snr: drx39xxj: could not read snr!
[145089.195482] drx39xyj:ctrl_sig_quality: error -5
[145089.195484] drx39xyj:drx39xxj_read_ucblocks: drx39xxj: could not get uc blocks!
[145089.195498] drx39xyj:ctrl_sig_quality: error -5
[145089.195500] drx39xyj:drx39xxj_read_ber: drx39xxj: could not get ber!
[145089.195502] drx39xyj:ctrl_sig_quality: error -5
[145089.195503] drx39xyj:drx39xxj_read_signal_strength: drx39xxj: could not get signal strength!
[145089.195505] drx39xyj:ctrl_sig_quality: error -5
[145089.195506] drx39xyj:drx39xxj_read_snr: drx39xxj: could not read snr!
[145089.195508] drx39xyj:ctrl_sig_quality: error -5
[145089.195510] drx39xyj:drx39xxj_read_ucblocks: drx39xxj: could not get uc blocks!
[145090.196291] drx39xyj:drx39xxj_read_status: drx39xxj: could not get lock status!
[145090.196508] drx39xyj:ctrl_sig_quality: error -5
[145090.196511] drx39xyj:drx39xxj_read_ber: drx39xxj: could not get ber!
[145090.196514] drx39xyj:ctrl_sig_quality: error -5
[145090.196515] drx39xyj:drx39xxj_read_signal_strength: drx39xxj: could not get signal strength!
[145090.196518] drx39xyj:ctrl_sig_quality: error -5
[145090.196519] drx39xyj:drx39xxj_read_snr: drx39xxj: could not read snr!
[145090.196522] drx39xyj:ctrl_sig_quality: error -5
[145090.196523] drx39xyj:drx39xxj_read_ucblocks: drx39xxj: could not get uc blocks!
[145090.196553] drx39xyj:ctrl_sig_quality: error -5
[145090.196554] drx39xyj:drx39xxj_read_ber: drx39xxj: could not get ber!
[145090.196557] drx39xyj:ctrl_sig_quality: error -5
[145090.196558] drx39xyj:drx39xxj_read_signal_strength: drx39xxj: could not get signal strength!
[145090.196560] drx39xyj:ctrl_sig_quality: error -5
[145090.196562] drx39xyj:drx39xxj_read_snr: drx39xxj: could not read snr!
[145090.196564] drx39xyj:ctrl_sig_quality: error -5
[145090.196565] drx39xyj:drx39xxj_read_ucblocks: drx39xxj: could not get uc blocks!
[145091.119265] drx39xyj:ctrl_sig_quality: error -5
[145091.119271] drx39xyj:drx39xxj_read_ber: drx39xxj: could not get ber!
[145091.119274] drx39xyj:ctrl_sig_quality: error -5
[145091.119276] drx39xyj:drx39xxj_read_signal_strength: drx39xxj: could not get signal strength!
[145091.119278] drx39xyj:ctrl_sig_quality: error -5
[145091.119280] drx39xyj:drx39xxj_read_snr: drx39xxj: could not read snr!
[145091.119282] drx39xyj:ctrl_sig_quality: error -5
[145091.119283] drx39xyj:drx39xxj_read_ucblocks: drx39xxj: could not get uc blocks!

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: be sure to use tuner's IF
Mauro Carvalho Chehab [Sun, 26 Jan 2014 18:02:25 +0000 (15:02 -0300)]
upstream: [media] drx-j: be sure to use tuner's IF

Instead of just hardcoding an IF value of 5MHz, use the one
provided by the tuner, with can be different for QAM and
VSB.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: get rid of tuner dummy get/set frequency
Mauro Carvalho Chehab [Sun, 26 Jan 2014 17:54:08 +0000 (14:54 -0300)]
upstream: [media] drx-j: get rid of tuner dummy get/set frequency

Those functions will never be used with Linux DVB binding.

Get rid of them.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: remove some ugly bindings from drx39xxj_dummy.c
Mauro Carvalho Chehab [Sun, 26 Jan 2014 17:23:24 +0000 (14:23 -0300)]
upstream: [media] drx-j: remove some ugly bindings from drx39xxj_dummy.c

This file does an ugly binding between drxj and DVB frontend.

Remove most of the functions there. We still need to get rid of
get_frequency and set_frequency, but such patch is a little more
complex, as it should also remove some previous tuner bindings.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: comment or remove unused code
Mauro Carvalho Chehab [Fri, 24 Jan 2014 16:16:16 +0000 (13:16 -0300)]
upstream: [media] drx-j: comment or remove unused code

In order to avoid warnings and to remove dead code, remove
the functions that don't make sense to happen, while commenting
the others that might still be useful some day.

That reduced a lot the text size:

Before:

   text    data     bss     dec     hex filename
  58419    2916       4   61339    ef9b drivers/media/dvb-frontends/drx39xyj/drx39xyj.ko

After:
   text    data     bss     dec     hex filename
  78331    2916       4   81251   13d63 drivers/media/dvb-frontends/drx39xyj/drx39xyj.ko

Without any functional changes.

It could be make sense latter to remove those drivers or to
move them into an analog-specific part of the driver.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: get rid of drxj_ctrl()
Mauro Carvalho Chehab [Fri, 24 Jan 2014 16:00:08 +0000 (13:00 -0300)]
upstream: [media] drx-j: get rid of drxj_ctrl()

With this change, we finally got rid of all abstraction
layers on this driver.

This patch also fixes the LNA GPIO settings, as the original
code were using a wrong control name for it.

This patch exposes the several functions that aren't used.
Some of them are related to analog demod that might be
used some day, but others will likely never be needed, as
they don't fit on Linux media APIs.

Latter patches will clean up this mess.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: move drx39xxj into drxj.c
Mauro Carvalho Chehab [Fri, 24 Jan 2014 15:25:04 +0000 (12:25 -0300)]
upstream: [media] drx-j: move drx39xxj into drxj.c

While drxj is already too big, moving the code there will
make easier to get rid of the drxj_ctrl function.

It will also help to detect and remove the unused functions,
helping to remove lots of dead code there.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: get rid of the remaining drx generic functions
Mauro Carvalho Chehab [Fri, 24 Jan 2014 15:21:17 +0000 (12:21 -0300)]
upstream: [media] drx-j: get rid of the remaining drx generic functions

Get rid of drx_open and drx_close, as those are just wrapper
functions to drxj_open/drxj_close.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: get rid of drx_ctrl
Mauro Carvalho Chehab [Fri, 24 Jan 2014 14:14:17 +0000 (11:14 -0300)]
upstream: [media] drx-j: get rid of drx_ctrl

This function is used only as an abstraction layer to call the
two firmware functions. Remove it.

As a bonus, the drx_ctrl_function is now unused and can be
removed.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Remove duplicated firmware upload code
Mauro Carvalho Chehab [Fri, 24 Jan 2014 10:49:29 +0000 (07:49 -0300)]
upstream: [media] drx-j: Remove duplicated firmware upload code

Remove the duplicated firmware upload code that was commented
inside drxj.c.

This code is not used, and will not work anyway, as it doesn't
download the firmware from userspace.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Avoid any regressions by preserving old behavior
Mauro Carvalho Chehab [Fri, 24 Jan 2014 09:31:03 +0000 (06:31 -0300)]
upstream: [media] drx-j: Avoid any regressions by preserving old behavior

The version is initialized with zero at drx_driver.c. Keep it,
in order to avoid the risk of causing any regression.

While here, remove the drx_driver.h from drxj, as this is not
required there.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: get rid of drx_driver.c
Mauro Carvalho Chehab [Fri, 24 Jan 2014 09:25:07 +0000 (06:25 -0300)]
upstream: [media] drx-j: get rid of drx_driver.c

This file contains just the firmware load code, that it is also
somewhat duplicated at drxj.c.

Move the code into there. Latter patches will remove the
duplicated code.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: prepend function names with drx_ at drx_driver.c
Mauro Carvalho Chehab [Fri, 24 Jan 2014 09:15:46 +0000 (06:15 -0300)]
upstream: [media] drx-j: prepend function names with drx_ at drx_driver.c

In order to prepare to get rid of drx_driver.c, prepend all functions
there with drx_.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Some cleanups at drx_driver.c source
Mauro Carvalho Chehab [Wed, 22 Jan 2014 13:21:55 +0000 (10:21 -0300)]
upstream: [media] drx-j: Some cleanups at drx_driver.c source

This is mostly CodingStyle fixes and improvements.

No functional changes.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Allow standard selection
Mauro Carvalho Chehab [Sun, 19 Jan 2014 15:08:36 +0000 (12:08 -0300)]
upstream: [media] drx-j: Allow standard selection

ClearQAM is currently not working. Add support for it too.
Unlikely other ATSC tuners, though, this device will not
auto-detect between ATSC and ClearQAM. So, the delivery
system should be properly set.

Also, this frontend seems to also support DVB-C annex A/C. Add
experimental support for them.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: reset the DVB scan configuration at powerup
Mauro Carvalho Chehab [Sun, 19 Jan 2014 13:31:47 +0000 (10:31 -0300)]
upstream: [media] drx-j: reset the DVB scan configuration at powerup

Without this fixup, the DRX-J will not be properly initialized,
loosing several PIDs.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: get rid of its own be??_to_cpu() implementation
Mauro Carvalho Chehab [Sun, 19 Jan 2014 13:06:43 +0000 (10:06 -0300)]
upstream: [media] drx-j: get rid of its own be??_to_cpu() implementation

Instead of handling endiannes with its own internal way, use the
already existing macros.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: remove unused code from drx_driver.c
Mauro Carvalho Chehab [Sun, 19 Jan 2014 12:50:18 +0000 (09:50 -0300)]
upstream: [media] drx-j: remove unused code from drx_driver.c

There are several drx-j code there that are never used, as
they don't even fit into Linux DVB subystem model.

Remove them, in order to simplify the code.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Split firmware size check from the main routine
Mauro Carvalho Chehab [Sat, 18 Jan 2014 22:11:11 +0000 (19:11 -0300)]
upstream: [media] drx-j: Split firmware size check from the main routine

The firmware upload routine is already complex enough. Split the
first loop that verifies the firmware size into a separate routine,
making the code more readable.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: dynamically load the firmware
Mauro Carvalho Chehab [Sat, 18 Jan 2014 14:13:02 +0000 (11:13 -0300)]
upstream: [media] drx-j: dynamically load the firmware

Instead of hardcoding the firmware files together with the driver,
use request_firmware() way, loading it from userspace.

The firmware files are placed at:
http://linuxtv.org/downloads/firmware/#8

And they'll be latter submitted to linux-firmware git tree.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Be sure that all allocated data are properly initialized
Mauro Carvalho Chehab [Sat, 18 Jan 2014 14:12:46 +0000 (11:12 -0300)]
upstream: [media] drx-j: Be sure that all allocated data are properly initialized

The state struct is allocated without cleaning the memory.
This causes random bugs.

Clean it, and move the memcpy functions just below each kalloc,
to be clearer that all those data are properly filled.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Fix release and error path on drx39xxj.c
Mauro Carvalho Chehab [Sat, 18 Jan 2014 10:38:30 +0000 (07:38 -0300)]
upstream: [media] drx-j: Fix release and error path on drx39xxj.c

There are memory leaks on both DVB release and
dvb attach error path. Fix them.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: remove the useless microcode_size
Mauro Carvalho Chehab [Fri, 17 Jan 2014 19:02:09 +0000 (16:02 -0300)]
upstream: [media] drx-j: remove the useless microcode_size

This var is not used. Remove it from the code, as we'll now be
converting the driver to load the firmware from an external
file.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: make checkpatch.pl happy
Mauro Carvalho Chehab [Fri, 17 Jan 2014 14:51:52 +0000 (11:51 -0300)]
upstream: [media] drx-j: make checkpatch.pl happy

Fix the remaining checkpatch.pl compliants at drxj.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: remove drxj_options.h
Mauro Carvalho Chehab [Fri, 17 Jan 2014 16:50:08 +0000 (13:50 -0300)]
upstream: [media] drx-j: remove drxj_options.h

This file is empty (actually, all commented there). So, remove it.

We should latter remove those macros too, or convert them into
a struct to allow dynamically enable the options during device
probing time.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: remove typedefs at drx_driver.c
Mauro Carvalho Chehab [Fri, 17 Jan 2014 15:51:14 +0000 (12:51 -0300)]
upstream: [media] drx-j: remove typedefs at drx_driver.c

Get rid of another typedef defined on this driver.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: get rid of some ugly macros
Mauro Carvalho Chehab [Fri, 17 Jan 2014 15:20:41 +0000 (12:20 -0300)]
upstream: [media] drx-j: get rid of some ugly macros

There are several get/set macros that are bogus: they just
call another macro and do either:
x = FOO(d)
or
FOO(d) = x

As checkpatch complains about that, and replacing all of them
are as easy as running a small coccinelle script, get rid
of all of them.

Script used:

@@
expression d, x;
@@
-DRX_SET_MIRRORFREQSPECT(d, x);
+DRX_ATTR_MIRRORFREQSPECT(d) = x;

@@
expression d, x;
@@
-DRX_GET_MIRRORFREQSPECT(d, x);
+x = DRX_ATTR_MIRRORFREQSPECT(d);

@@
expression d, x;
@@
-DRX_SET_CURRENTPOWERMODE(d, x);
+DRX_ATTR_CURRENTPOWERMODE(d) = x;

@@
expression d, x;
@@
-DRX_GET_CURRENTPOWERMODE(d, x);
+x = DRX_ATTR_CURRENTPOWERMODE(d);

@@
expression d, x;
@@
-DRX_SET_MICROCODE(d, x);
+DRX_ATTR_MICROCODE(d) = x;

@@
expression d, x;
@@
-DRX_GET_MICROCODE(d, x);
+x = DRX_ATTR_MICROCODE(d);

@@
expression d, x;
@@
-DRX_SET_MICROCODESIZE(d, x);
+DRX_ATTR_MICROCODESIZE(d) = x;

@@
expression d, x;
@@
-DRX_GET_MICROCODESIZE(d, x);
+x = DRX_ATTR_MICROCODESIZE(d);

@@
expression d, x;
@@
-DRX_SET_VERIFYMICROCODE(d, x);
+DRX_ATTR_VERIFYMICROCODE(d) = x;

@@
expression d, x;
@@
-DRX_GET_VERIFYMICROCODE(d, x);
+x = DRX_ATTR_VERIFYMICROCODE(d);

@@
expression d, x;
@@
-DRX_SET_MCVERTYPE(d, x);
+DRX_ATTR_MCRECORD(d).aux_type = x;

@@
expression d, x;
@@
-DRX_GET_MCVERTYPE(d, x);
+x = DRX_ATTR_MCRECORD(d).aux_type;

@@
expression d, x;
@@
-DRX_SET_MCDEV(d, x);
+DRX_ATTR_MCRECORD(d).mc_dev_type = x;

@@
expression d, x;
@@
-DRX_GET_MCDEV(d, x);
+x = DRX_ATTR_MCRECORD(d).mc_dev_type;

@@
expression d, x;
@@
-DRX_SET_MCVERSION(d, x);
+DRX_ATTR_MCRECORD(d).mc_version = x;

@@
expression d, x;
@@
-DRX_GET_MCVERSION(d, x);
+x = DRX_ATTR_MCRECORD(d).mc_version;

@@
expression d, x;
@@
-DRX_SET_MCPATCH(d, x);
+DRX_ATTR_MCRECORD(d).mc_base_version = x;

@@
expression d, x;
@@
-DRX_GET_MCPATCH(d, x);
+x = DRX_ATTR_MCRECORD(d).mc_base_version;

@@
expression d, x;
@@
-DRX_SET_I2CADDR(d, x);
+DRX_ATTR_I2CADDR(d) = x;

@@
expression d, x;
@@
-DRX_GET_I2CADDR(d, x);
+x = DRX_ATTR_I2CADDR(d);

@@
expression d, x;
@@
-DRX_SET_I2CDEVID(d, x);
+DRX_ATTR_I2CDEVID(d) = x;

@@
expression d, x;
@@
-DRX_GET_I2CDEVID(d, x);
+x = DRX_ATTR_I2CDEVID(d);

@@
expression d, x;
@@
-DRX_SET_USEBOOTLOADER(d, x);
+DRX_ATTR_USEBOOTLOADER(d) = x;

@@
expression d, x;
@@
-DRX_GET_USEBOOTLOADER(d, x);
+x = DRX_ATTR_USEBOOTLOADER(d);

@@
expression d, x;
@@
-DRX_SET_CURRENTSTANDARD(d, x);
+DRX_ATTR_CURRENTSTANDARD(d) = x;

@@
expression d, x;
@@
-DRX_GET_CURRENTSTANDARD(d, x);
+x = DRX_ATTR_CURRENTSTANDARD(d);

@@
expression d, x;
@@
-DRX_SET_PREVSTANDARD(d, x);
+DRX_ATTR_PREVSTANDARD(d) = x;

@@
expression d, x;
@@
-DRX_GET_PREVSTANDARD(d, x);
+x = DRX_ATTR_PREVSTANDARD(d);

@@
expression d, x;
@@
-DRX_SET_CACHESTANDARD(d, x);
+DRX_ATTR_CACHESTANDARD(d) = x;

@@
expression d, x;
@@
-DRX_GET_CACHESTANDARD(d, x);
+x = DRX_ATTR_CACHESTANDARD(d);

@@
expression d, x;
@@
-DRX_SET_CURRENTCHANNEL(d, x);
+DRX_ATTR_CURRENTCHANNEL(d) = x;

@@
expression d, x;
@@
-DRX_GET_CURRENTCHANNEL(d, x);
+x = DRX_ATTR_CURRENTCHANNEL(d);

@@
expression d, x;
@@
-DRX_SET_ISOPENED(d, x);
+DRX_ATTR_ISOPENED(d) = x;

@@
expression d, x;
@@
-DRX_GET_ISOPENED(d, x);
+x = DRX_ATTR_ISOPENED(d);

@@
expression d, x;
@@
-DRX_SET_TUNER(d, x);
+DRX_ATTR_TUNER(d) = x;

@@
expression d, x;
@@
-DRX_GET_TUNER(d, x);
+x = DRX_ATTR_TUNER(d);

@@
expression d, x;
@@
-DRX_SET_CAPABILITIES(d, x);
+DRX_ATTR_CAPABILITIES(d) = x;

@@
expression d, x;
@@
-DRX_GET_CAPABILITIES(d, x);
+x = DRX_ATTR_CAPABILITIES(d);

@@
expression d, x;
@@
-DRX_SET_PRODUCTID(d, x);
+DRX_ATTR_PRODUCTID(d) = x;

@@
expression d, x;
@@
-DRX_GET_PRODUCTID(d, x);
+x = DRX_ATTR_PRODUCTID(d);

@@
expression d, x;
@@
-DRX_SET_MFX(d, x);
+DRX_ATTR_PRODUCTID(d) = x;

@@
expression d, x;
@@
-DRX_GET_MFX(d, x);
+x = DRX_ATTR_PRODUCTID(d);

@@
expression d, x;
@@
-DRX_SET_INTERMEDIATEFREQ(d, x);
+DRX_ATTR_INTERMEDIATEFREQ(d) = x;

@@
expression d, x;
@@
-DRX_GET_INTERMEDIATEFREQ(d, x);
+x = DRX_ATTR_INTERMEDIATEFREQ(d);

@@
expression d, x;
@@
-DRX_SET_SYSCLOCKFREQ(d, x);
+DRX_ATTR_SYSCLOCKFREQ(d) = x;

@@
expression d, x;
@@
-DRX_GET_SYSCLOCKFREQ(d, x);
+x = DRX_ATTR_SYSCLOCKFREQ(d);

@@
expression d, x;
@@
-DRX_SET_TUNERRFAGCPOL(d, x);
+DRX_ATTR_TUNERRFAGCPOL(d) = x;

@@
expression d, x;
@@
-DRX_GET_TUNERRFAGCPOL(d, x);
+x = DRX_ATTR_TUNERRFAGCPOL(d);

@@
expression d, x;
@@
-DRX_SET_TUNERIFAGCPOL(d, x);
+DRX_ATTR_TUNERIFAGCPOL(d) = x;

@@
expression d, x;
@@
-DRX_GET_TUNERIFAGCPOL(d, x);
+x = DRX_ATTR_TUNERIFAGCPOL(d);

@@
expression d, x;
@@
-DRX_SET_TUNERSLOWMODE(d, x);
+DRX_ATTR_TUNERSLOWMODE(d) = x;

@@
expression d, x;
@@
-DRX_GET_TUNERSLOWMODE(d, x);
+x = DRX_ATTR_TUNERSLOWMODE(d);

@@
expression d, x;
@@
-DRX_SET_TUNERPORTNR(d, x);
+DRX_ATTR_TUNERSPORTNR(d) = x;

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Replace printk's by pr_foo()
Mauro Carvalho Chehab [Fri, 17 Jan 2014 14:36:17 +0000 (11:36 -0300)]
upstream: [media] drx-j: Replace printk's by pr_foo()

Instead of using printk's, use the pr_foo() macros.

That fixes some checkpatch warnings and provide a better error,
warning and debug support.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Use the Linux error codes
Mauro Carvalho Chehab [Fri, 17 Jan 2014 13:18:16 +0000 (10:18 -0300)]
upstream: [media] drx-j: Use the Linux error codes

Instead of defining its own set of error codes, use the linux
native ones.

Please note that this patch made a "stupid" error code mapping, just
replacing the codes with the closest one. In special, -EIO is being
used on several places. I'm pretty sure this could be better assigned,
but a change like that would require lots o time and efforts, without
much benefit.

So lets do adjstments at the error codes latter, when we have more
time.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: CodingStyle fixups on drxj.c
Mauro Carvalho Chehab [Fri, 17 Jan 2014 10:12:28 +0000 (07:12 -0300)]
upstream: [media] drx-j: CodingStyle fixups on drxj.c

Fix almost all checkpatch.pl warnings/errors on drxj.c, except for:
- 80 cols whitespacing;
- too many leading tabs;
- a false positive at DRXJ_16TO8() macro.
- static char array declaration should probably be static const char
  as adding "const" would cause warnings.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Remove typedefs in drxj.c
Mauro Carvalho Chehab [Fri, 17 Jan 2014 10:00:31 +0000 (07:00 -0300)]
upstream: [media] drx-j: Remove typedefs in drxj.c

Remove three typedefs from drxj.c, using the following script:

use File::Find;
use strict;

my $dir = shift or die "need a dir";
my $type = shift or die "need type";
my $var = shift or die "need var";

sub handle_file {
my $file = shift;

my $out;

open IN, $file or die "can't open $file";
$out .= $_ while (<IN>);
close IN;

$out =~ s/\btypedef\s+($type)\s+\{([\d\D]+?)\s*\}\s+\b($var)[^\;]+\;/$type $var \{\2\};/;

        # This replaces the typedef declaration for a simple struct declaration - style 1

        # This replaces the typedef declaration for a simple struct declaration - style 2

# Replace struct occurrences

$out =~ s,\b($var)_t\s+,$type \1 ,g;
$out =~ s,\bp_*($var)_t\s+,$type \1 *,g;
$out =~ s,\b($var)_t\b,$type \1,g;
$out =~ s,\bp_*($var)_t\b,$type \1 *,g;

open OUT, ">$file" or die "can't open $file";
print OUT $out;
close OUT;
}

sub parse_dir {
my $file = $File::Find::name;

return if (!($file =~ /.[ch]$/));

handle_file $file;
}

find({wanted => \&parse_dir, no_chdir => 1}, $dir);

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: More CamelCase fixups
Mauro Carvalho Chehab [Fri, 17 Jan 2014 09:47:04 +0000 (06:47 -0300)]
upstream: [media] drx-j: More CamelCase fixups

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Simplify logic expressions
Mauro Carvalho Chehab [Fri, 17 Jan 2014 09:40:47 +0000 (06:40 -0300)]
upstream: [media] drx-j: Simplify logic expressions

Don't need to test boolean x == true or x == false.

That makes the code more compact.

patch generated with make coccicheck and manually reviewed.

While here, remove uneeded ';'.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: don't use parenthesis on return
Mauro Carvalho Chehab [Fri, 17 Jan 2014 09:28:28 +0000 (06:28 -0300)]
upstream: [media] drx-j: don't use parenthesis on return

CodingStyle fix: don't use parenthesis on return, as it is not
a function.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: replace the ugly CHK_ERROR() macro
Mauro Carvalho Chehab [Thu, 16 Jan 2014 22:41:13 +0000 (19:41 -0300)]
upstream: [media] drx-j: replace the ugly CHK_ERROR() macro

Using return and goto inside macros is ugly and makes harder to
understand the code and the labels. Remove those macros, and add
a proper error debug message, when something bad happens.

This was generated using the following coccinelle script:

@@
@@
-DUMMY_READ();
+do {
+ u16 dummy;
+ RR16(demod->my_i2c_dev_addr, SCU_RAM_VERSION_HI__A, &dummy);
+} while (0);

@@
expression dev, addr, val;
@@
-WR16(dev, addr, val)
+CHK_ERROR(DRXJ_DAP.write_reg16func(dev, addr, val, 0))

@@
expression dev, addr, val;
@@
-RR16(dev, addr, val)
+CHK_ERROR(DRXJ_DAP.read_reg16func(dev, addr, val, 0))

@@
expression dev, addr, val;
@@
-WR32(dev, addr, val)
+CHK_ERROR(DRXJ_DAP.write_reg32func(dev, addr, val, 0))

@@
expression dev, addr, val;
@@
-RR32(dev, addr, val)
+CHK_ERROR(DRXJ_DAP.read_reg32func(dev, addr, val, 0))

@@
expression dev, addr, val, block;
@@
-WRB(dev, addr, val, block)
+CHK_ERROR(DRXJ_DAP.write_block_func(dev, addr, val, block, 0))

@@
expression dev, addr, val, block;
@@
-RRB(dev, addr, val, block)
+CHK_ERROR(DRXJ_DAP.read_block_func(dev, addr, val, block, 0))

@@
expression dev, addr, val;
@@
-BCWR16(dev, addr, val)
+CHK_ERROR(DRXJ_DAP.write_reg16func(dev, addr, val, DRXDAP_FASI_BROADCAST))

@@
expression dev, addr, val;
@@
-ARR32(dev, addr, val)
+CHK_ERROR(drxj_dap_atomic_read_reg32(dev, addr, val, 0))

@@
expression dev, addr, val;
@@
-SARR16(dev, addr, val)
+CHK_ERROR(drxj_dap_scu_atomic_read_reg16(dev, addr, val, 0))

@@
expression x;
@@
-CHK_ERROR(x);
+rc = x;
+if (rc != DRX_STS_OK) {
+ pr_err("error %d\n", rc);
+ goto rw_error;
+}

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Don't use buffer if an error occurs
Mauro Carvalho Chehab [Thu, 16 Jan 2014 19:34:03 +0000 (16:34 -0300)]
upstream: [media] drx-j: Don't use buffer if an error occurs

drivers/media/dvb-frontends/drx39xyj/drxj.c: In function ‘drxj_dap_scu_atomic_read_reg16’:
drivers/media/dvb-frontends/drx39xyj/drxj.c:4170:9: warning: ‘*((void *)&buf+1)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  word = (u16) (buf[0] + (buf[1] << 8));
         ^
drivers/media/dvb-frontends/drx39xyj/drxj.c:4170:9: warning: ‘buf’ may be used uninitialized in this function [-Wmaybe-uninitialized]
drivers/media/dvb-frontends/drx39xyj/drxj.c: In function ‘drxj_dap_atomic_read_reg32.isra.59’:
drivers/media/dvb-frontends/drx39xyj/drxj.c:2186:7: warning: ‘*((void *)&buf+3)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  word = (u32) buf[3];
       ^
drivers/media/dvb-frontends/drx39xyj/drxj.c:2188:10: warning: ‘*((void *)&buf+2)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  word |= (u32) buf[2];
          ^
drivers/media/dvb-frontends/drx39xyj/drxj.c:2190:10: warning: ‘*((void *)&buf+1)’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  word |= (u32) buf[1];
          ^
drivers/media/dvb-frontends/drx39xyj/drxj.c:2192:10: warning: ‘buf’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  word |= (u32) buf[0];
          ^

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: a few more CodingStyle fixups
Mauro Carvalho Chehab [Thu, 16 Jan 2014 18:56:51 +0000 (15:56 -0300)]
upstream: [media] drx-j: a few more CodingStyle fixups

Some whitespace cleanups.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Get rid of typedefs on drxh.h
Mauro Carvalho Chehab [Thu, 16 Jan 2014 18:33:14 +0000 (15:33 -0300)]
upstream: [media] drx-j: Get rid of typedefs on drxh.h

This were fixed with the help of this small perl script:

#!/usr/bin/perl
my $dir = shift or die "need a dir";
my $type = shift or die "need type";
my $var = shift or die "need var";
sub handle_file {
my $file = shift;
my $out;
open IN, $file or die "can't open $file";
$out .= $_ while (<IN>);
close IN;
$out =~ s/\btypedef\s+($type)\s+\{([\d\D]+?)\s*\}\s+\b($var)[^\;]+\;/$type $var \{\2\};/;
$out =~ s,\b($var)_t\s+,$type \1 ,g;
$out =~ s,\bp_*($var)_t\s+,$type \1 *,g;
$out =~ s,\b($var)_t\b,$type \1,g;
$out =~ s,\bp_*($var)_t\b,$type \1 *,g;
open OUT, ">$file" or die "can't open $file";
print OUT $out;
close OUT;
}
sub parse_dir {
my $file = $File::Find::name;
return if (!($file =~ /.[ch]$/));
handle_file $file;
}
find({wanted => \&parse_dir, no_chdir => 1}, $dir);

Some manual work were needed.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: get rid of typedefs in drx_driver.h
Mauro Carvalho Chehab [Thu, 16 Jan 2014 15:51:36 +0000 (12:51 -0300)]
upstream: [media] drx-j: get rid of typedefs in drx_driver.h

Most of the changes were done with scripts like:
for i in drivers/media/dvb-frontends/drx39xyj/*.[ch]; do perl -ne '$var = "drx_sig_quality"; s,\b($var)_t\s+,struct \1 ,g; s,\bp_*($var)_t\s+,struct \1 *,g; s,\b($var)_t\b,struct \1,g; s,\bp_*($var)_t\b,struct \1 *,g; print $_' <$i >a && mv a $i; done

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: Get rid of drx39xyj/bsp_tuner.h
Mauro Carvalho Chehab [Thu, 16 Jan 2014 15:17:27 +0000 (12:17 -0300)]
upstream: [media] drx-j: Get rid of drx39xyj/bsp_tuner.h

This file is not used anywhere. Drop it.

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
9 years agoupstream: [media] drx-j: make a few functions static
Mauro Carvalho Chehab [Thu, 16 Jan 2014 15:20:38 +0000 (12:20 -0300)]
upstream: [media] drx-j: make a few functions static

drivers/media/dvb-frontends/drx39xyj/drx_driver.c:181:7: warning: no previous prototype for 'get_scan_context' [-Wmissing-prototypes]
 void *get_scan_context(pdrx_demod_instance_t demod, void *scan_context)

drivers/media/dvb-frontends/drx39xyj/drx_driver.c: At top level:
drivers/media/dvb-frontends/drx39xyj/drx_driver.c:842:5: warning: no previous prototype for 'ctrl_dump_registers' [-Wmissing-prototypes]
 int ctrl_dump_registers(pdrx_demod_instance_t demod,

Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>