Commit graph

102 commits

Author SHA1 Message Date
Mauro Carvalho Chehab bb31d2381c [media] dvb_frontend: Don't let drivers to trash data at cache
GET_FRONTEND and G_PROPERTY can be called anytime, even when the
tuner/demod is not fully locked. However, several parameters
returned by those calls are available only after the demod get
VITERBI lock.

While several drivers do the right thing by checking the status before
returning the parameter, some drivers simply blindly update the
DTV properties cache without checking if the registers at the
hardware contain valid values.

Due to that, programs that call G_PROPERTY (or GET_FRONTEND)
before having a tuner lock may interfere at the zigzag logic,
as the DVB kthread calls the set_frontend() callback several
times, to fine tune the frequency and to identify if the signal
is inverted or not.

While the drivers should be fixed to report the right status,
we should prevent that such bugs would actually interfere at the
device operation.

So, let's use a separate var for userspace calls to get frontend.

As we copy the content of the cache, this should not cause any
troubles.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2016-02-04 16:27:41 -02: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 2ea9a08d59 [media] dvb_frontend: add props argument to dtv_get_frontend()
Instead of implicitly using the DTV cache properties at
dtv_get_frontend(), pass it as an additional argument.

This patch prepares to use a separate cache for G_PROPERTY,
in order to avoid it to mangle with the DVB thread
zigzag logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2016-02-04 09:45:14 -02:00
Mauro Carvalho Chehab c29ebb64a5 [media] dvb_frontend: print DTV property dump also for SET_PROPERTY
When debugging troubles with DTV properties get/set, it is
important to be able to see not only the properties from get, but
also the ones from set. So, improve the dumps to allow reporting
both.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2016-02-04 09:06:38 -02:00
Abhilash Jindal 6b3f99989e [media] dvb-frontend: Use boottime
Wall time obtained from ktime_get_real is susceptible to sudden jumps due to
user setting the time or due to NTP.  Boot time is constantly increasing time
better suited for comparing two timestamps.

[mchehab@osg.samsung.com: fix trivial merge conflicts]
Signed-off-by: Abhilash Jindal <klock.android@gmail.com>

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2016-02-01 13:35:29 -02:00
Mauro Carvalho Chehab df2f94e563 [media] dvb: modify core to implement interfaces/entities at MC new gen
The Media Controller New Generation redefines the types for both
interfaces and entities to be used on DVB. Make the needed
changes at the DVB core for all interfaces, entities and
data and interface links to appear in the graph.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2016-01-11 12:18:52 -02:00
Mauro Carvalho Chehab 57208e5e25 [media] media: convert links from array to list
The entire logic that represent graph links were developed on a
time where there were no needs to dynamic remove links. So,
although links are created/removed one by one via some
functions, they're stored as an array inside the entity struct.

As the array may grow, there's a logic inside the code that
checks if the amount of space is not enough to store
the needed links. If it isn't the core uses krealloc()
to change the size of the link, with is bad, as it
leaves the memory fragmented.

So, convert links into a list.

Also, currently,  both source and sink entities need the link
at the graph traversal logic inside media_entity. So there's
a logic duplicating all links. That makes it to spend
twice the memory needed. This is not a big deal for today's
usage, where the number of links are not big.

Yet, if during the MC workshop discussions, it was said that
IIO graphs could have up to 4,000 entities. So, we may
want to remove the duplication on some future. The problem
is that it would require a separate linked list to store
the backlinks inside the entity, or to use a more complex
algorithm to do graph backlink traversal, with is something
that the current graph traversal inside the core can't cope
with. So, let's postpone a such change if/when it is actually
needed.

It should also be noticed that the media_link structure uses
44 bytes on 32-bit architectures and 84 bytes on 64-bit
architecture. It will thus be allocated out of the 64-bytes and
96-bytes pools respectively. That's a 12.5% memory waste on
64-bit architectures and 31.25% on 32-bit architecture.
A linked list is less efficient than an array in this case, but
this could later be optimized if we can get rid of the reverse
links (with would reduce memory allocation by 50%).

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2016-01-11 12:18:46 -02:00
Mauro Carvalho Chehab a733a41a50 [media] fix dvb_frontend_sleep_until() logic
As pointed by Laurent Navet:
	"Calling ktime_add_us() seems useless as is only useful
	 for it's return value which is ignored."

That's reported by coverity CID 1309761.

Laurent proposed to just remove ktime_add_us, but the fact is that
the logic of this function is broken. Instead, we need to use the
value of the timeout, and ensure that it will work on the loops
to emulate the legacy DiSEqC ioctl (FE_DISHNETWORK_SEND_LEGACY_CMD).

Please notice that the logic was also broken if, for any reason,
msleep() would sleep a little less than what it was expected, as
newdelta would be smaller than delta, and udelay() would not be called.

It should also be noticed that nobody noticed that trouble before
likely because the FE_DISHNETWORK_SEND_LEGACY_CMD is not used
anymore by modern DVB applications.

Reported-by: Laurent Navet <laurent.navet@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-11-19 11:57:08 -02:00
Malcolm Priestley c9d57de610 [media] media: dvb-core: Don't force CAN_INVERSION_AUTO in oneshot mode
When in FE_TUNE_MODE_ONESHOT the frontend must report
the actual capabilities so user can take appropriate
action.

With frontends that can't do auto inversion this is done
by dvb-core automatically so CAN_INVERSION_AUTO is valid.

However, when in FE_TUNE_MODE_ONESHOT this is not true.

So only set FE_CAN_INVERSION_AUTO in modes other than
FE_TUNE_MODE_ONESHOT

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-11-18 13:27:03 -02:00
Mauro Carvalho Chehab 3663b31b69 [media] dvb_frontend: resume tone and voltage
As SEC tone and voltage could have changed during
suspend(), restore them to their previous values at
resume().

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-11-17 06:40:31 -02:00
Mauro Carvalho Chehab 4deea4cb47 [media] dvb: document dvb_frontend_sleep_until()
This function is used mainly at the DVB core, in order to provide
emulation for a legacy ioctl. The only current exception is
the stv0299 driver, with takes more than 8ms to switch voltage,
breaking the emulation for FE_DISHNETWORK_SEND_LEGACY_CMD.

Document that.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-11-17 06:37:16 -02:00
Mauro Carvalho Chehab 27460adc07 [media] dvb: Use DVBFE_ALGO_HW where applicable
The dvb_frontend.c core defines a FE_ALGO_HW symbol that it is
never used. Also, both cx24123 returns 1 to get_algo() callback
instead of using DVBFE_ALGO_HW.

Probably, those are some left overs from some code cleanup.

Let's stop returning magic numbers and use the proper macro
value.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Acked-by: Jonathan Corbet <corbet@lwn.net>
2015-08-22 14:52:58 -03:00
Dan Carpenter 8d7e506350 [media] dvb-core: prevent some corruption the legacy ioctl
Quite a few of the ->diseqc_send_master_cmd() implementations don't
check cmd->msg_len so it can lead to memory corruption.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-06-10 11:47:56 -03:00
Tina Ruchandani 9056a23ba1 [media] dvb-frontend: Replace timeval with ktime_t
struct timeval uses a 32-bit seconds representation which will
overflow in the year 2038 and beyond. This patch replaces
the usage of struct timeval with ktime_t which is a 64-bit
timestamp and is year 2038 safe.
This patch is part of a larger attempt to remove all instances
of 32-bit timekeeping variables (timeval, timespec, time_t)
which are not year 2038 safe, from the kernel.

[mchehab@osg.samsung.com: add a missing parenthesis, breaking compilation]
Suggested-by: Arnd Bergmann <arndb@arndb.de>
Signed-off-by: Tina Ruchandani <ruchandani.tina@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-06-09 21:09:51 -03: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
Antti Palosaari 2a80f29642 [media] dvb-core: fix 32-bit overflow during bandwidth calculation
Frontend bandwidth calculation overflows on very high DVB-S/S2
symbol rates. Use mult_frac() macro in order to keep calculation
correct.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-05-20 14:01:46 -03:00
Mauro Carvalho Chehab c1bd57d30b [media] dvb-frontend: remove a warning
if CONFIG_MEDIA_CONTROLLER_DVB is not selected, it is now
producing this warning:

drivers/media/dvb-core/dvb_frontend.c: In function ‘dvb_frontend_thread’:
drivers/media/dvb-core/dvb_frontend.c:695:6: warning: unused variable ‘ret’ [-Wunused-variable]
  int ret;
      ^

Reported-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-26 08:43:29 -03:00
Mauro Carvalho Chehab 8a26a258bd [media] dvb core: only start media entity if not NULL
The logic there tries to start the media entity even if it
doesn't exist, causing this bug:

	[  314.356162] BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
	[  314.356202] IP: [<ffffffffa02ef74c>] media_entity_pipeline_start+0x1c/0x390 [media]

Reported-by: Gert-Jan van der Stroom <gjstroom@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-23 16:10:54 -03:00
Mauro Carvalho Chehab 135f9be919 [media] dvb_frontend: start media pipeline while thread is running
While the DVB thread is running, the media pipeline should be
streaming. This should prevent any attempt of using the analog
TV while digital TV is working, and vice-versa.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-13 21:10:17 -02:00
Mauro Carvalho Chehab 9239effd53 [media] dvb-frontend: enable tuner link when the FE thread starts
If the dvb frontend thread starts, the tuner should be switched
to the frontend. Add a code that ensures that this will happen,
using the media controller.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-13 21:10:16 -02:00
Mauro Carvalho Chehab c1b31b1e82 [media] dvb_frontend: add media controller support for DVB frontend
Now that the dvb core is capable of registering devices via the
media controller, add support for the DVB frontend devices.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-02-13 21:10:13 -02:00
Akihiro Tsukada 8e281fafda [media] dvb-core: set default properties of ISDB-S
Signed-off-by: Akihiro Tsukada <tskd08@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-11-03 16:40:09 -02:00
Mauro Carvalho Chehab 71d1b2bec0 [media] dvb_frontend: Fix __user namespace
As reported by smatch:

drivers/media/dvb-core/dvb_frontend.c:1960:45: warning: incorrect type in argument 2 (different address spaces)
drivers/media/dvb-core/dvb_frontend.c:1960:45:    expected void const [noderef] <asn:1>*from
drivers/media/dvb-core/dvb_frontend.c:1960:45:    got struct dtv_property *[noderef] <asn:1>props
drivers/media/dvb-core/dvb_frontend.c:1992:45: warning: incorrect type in argument 2 (different address spaces)
drivers/media/dvb-core/dvb_frontend.c:1992:45:    expected void const [noderef] <asn:1>*from
drivers/media/dvb-core/dvb_frontend.c:1992:45:    got struct dtv_property *[noderef] <asn:1>props
drivers/media/dvb-core/dvb_frontend.c:2014:38: warning: incorrect type in argument 1 (different address spaces)
drivers/media/dvb-core/dvb_frontend.c:2014:38:    expected void [noderef] <asn:1>*to
drivers/media/dvb-core/dvb_frontend.c:2014:38:    got struct dtv_property *[noderef] <asn:1>props
drivers/media/dvb-core/dvb_frontend.c:1946:17: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:1947:17: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:1951:22: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:1951:42: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:1954:31: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:1960:41: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:1960:54: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:1965:33: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:1978:17: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:1979:17: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:1983:22: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:1983:42: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:1986:31: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:1992:41: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:1992:54: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:2007:33: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:2014:34: warning: dereference of noderef expression
drivers/media/dvb-core/dvb_frontend.c:2014:52: warning: dereference of noderef expression

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-26 06:47:52 -03:00
Mauro Carvalho Chehab c623ed6316 [media] dvb_frontend: estimate bandwidth also for DVB-S/S2/Turbo
The needed bandwidth can be estimated using the symbol rate and
the rolloff factor. This could be useful for the frontend drivers,
as they don't need to calculate it themselves.

Reported-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-08-26 18:52:04 -03:00
Mauro Carvalho Chehab 59d7889ae4 [media] dvb-frontend: add core support for tuner suspend/resume
While several tuners have some sort of suspend/resume
implementation, this is currently mangled with an optional
.sleep callback that it is also used to put the device on
low power mode.

Not all drivers implement it, as returning the driver from
low power may require to re-load the firmware, with takes
some time. Also, some drivers may delay it.

So, the more coherent is to add two new optional callbacks
that will let the tuners to directy implement suspend and
resume callbacks if they need.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-08-21 15:25:09 -05:00
Shuah Khan 87cd0fa811 [media] media: dvb-core add new flag exit flag value for resume
Some fe drivers will have to do additional initialization
in their fe ops.init interfaces when called during resume.
Without the additional initialization, fe and tuner driver
resume fails. A new fe exit flag value DVB_FE_DEVICE_RESUME
is necessary to detect resume case. This patch adds a new
define and changes dvb_frontend_resume() to set it prior to
calling fe init and tuner init calls and resets it back to
DVB_FE_NO_EXIT once fe and tuner init is done.

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-07-26 11:20:10 -03:00
Shuah Khan 18ed2860cb [media] media: dvb-core move fe exit flag from fepriv to fe for driver access
Some fe drivers attempt to access the device for power control from
their release routines. When release routines are called after device
is disconnected, the attempts fail. fe drivers should avoid accessing
the device, from their release interfaces when called from disconnect
path. dvb-frontend maintains exit flag to keep track when fe device is
disconnected in its private data structures. Export the flag in fe to
enable drivers to check the device status from their release interfaces.

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-07-26 11:17:15 -03:00
Mauro Carvalho Chehab 4647f48708 [media] dvbdev: add a dvb_detach() macro
The dvb_attach() was unbalanced, as there was no dvb_dettach. Ok,
on current cases, the dettach is done by dvbdev, but that are some
future corner cases where we may need to do this before registering
the frontend.

So, add a dvb_detach() and use it at dvb_frontend.c.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-06-17 12:04:47 -03:00
Ole Ernst 0123f29caf [media] dvb_frontend: Fix possible read out of bounds
Check if index is within bounds _before_ accessing the value.

Signed-off-by: Ole Ernst <olebowle@gmx.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-12 10:21:09 -03:00
Mauro Carvalho Chehab e6876692ca [media] dvb_frontend: better handle lna set errors
If an attempt to set LNA fails, restore the cache to LNA_AUTO,
in order to make it to reflect the current LNA status.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-04 14:19:34 -03:00
Linus Torvalds 20b4fb4852 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull VFS updates from Al Viro,

Misc cleanups all over the place, mainly wrt /proc interfaces (switch
create_proc_entry to proc_create(), get rid of the deprecated
create_proc_read_entry() in favor of using proc_create_data() and
seq_file etc).

7kloc removed.

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (204 commits)
  don't bother with deferred freeing of fdtables
  proc: Move non-public stuff from linux/proc_fs.h to fs/proc/internal.h
  proc: Make the PROC_I() and PDE() macros internal to procfs
  proc: Supply a function to remove a proc entry by PDE
  take cgroup_open() and cpuset_open() to fs/proc/base.c
  ppc: Clean up scanlog
  ppc: Clean up rtas_flash driver somewhat
  hostap: proc: Use remove_proc_subtree()
  drm: proc: Use remove_proc_subtree()
  drm: proc: Use minor->index to label things, not PDE->name
  drm: Constify drm_proc_list[]
  zoran: Don't print proc_dir_entry data in debug
  reiserfs: Don't access the proc_dir_entry in r_open(), r_start() r_show()
  proc: Supply an accessor for getting the data from a PDE's parent
  airo: Use remove_proc_subtree()
  rtl8192u: Don't need to save device proc dir PDE
  rtl8187se: Use a dir under /proc/net/r8180/
  proc: Add proc_mkdir_data()
  proc: Move some bits from linux/proc_fs.h to linux/{of.h,signal.h,tty.h}
  proc: Move PDE_NET() to fs/proc/proc_net.c
  ...
2013-05-01 17:51:54 -07:00
Al Viro 03feee373f dvb_frontend: don't mess with ->f_op in ->release()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2013-04-29 15:41:47 -04:00
Mauro Carvalho Chehab 808d24d6c0 [media] dvb-core: don't clear stats at DTV_CLEAR
The stats are cleared by the frontend. Don't do it at DTV_CLEAR.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-21 10:27:35 -03:00
Mauro Carvalho Chehab 52dee392f4 [media] dvb_frontend: Simplify the emulation logic
The current logic was broken and too complex; while it works
fine for DVB-S2/DVB-S, it is broken for ISDB-T.
Make the logic simpler, fixes it for ISDB-T and make it clearer.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-18 20:33:03 -03:00
Mauro Carvalho Chehab be431b16c6 [media] dvb-frontend: split set_delivery_system()
This function is complex, and has different workflows, one for
DVBv3 calls, and another one for DVBv5 calls. Break it into 3
functions, in order to make easier to understand what each
block does.
No functional changes so far. A few comments got improved.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-18 20:30:36 -03:00
Linus Torvalds 21fbd5809a Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab:

 - Some cleanups at V4L2 documentation

 - new drivers: ts2020 frontend, ov9650 sensor, s5c73m3 sensor,
   sh-mobile veu mem2mem driver, radio-ma901, davinci_vpfe staging
   driver

 - Lots of missing MAINTAINERS entries added

 - several em28xx driver improvements, including its conversion to
   videobuf2

 - several fixups on drivers to make them to better comply with the API

 - DVB core: add support for DVBv5 stats, allowing the implementation of
   statistics for new standards like ISDB

 - mb86a20s: add statistics to the driver

 - lots of new board additions, cleanups, and driver improvements.

* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (596 commits)
  [media] media: Add 0x3009 USB PID to ttusb2 driver (fixed diff)
  [media] rtl28xxu: Add USB IDs for Compro VideoMate U620F
  [media] em28xx: add usb id for terratec h5 rev. 3
  [media] media: rc: gpio-ir-recv: add support for device tree parsing
  [media] mceusb: move check earlier to make smatch happy
  [media] radio-si470x doc: add info about v4l2-ctl and sox+alsa
  [media] staging: media: Remove unnecessary OOM messages
  [media] sh_vou: Use vou_dev instead of vou_file wherever possible
  [media] sh_vou: Use video_drvdata()
  [media] drivers/media/platform/soc_camera/pxa_camera.c: use devm_ functions
  [media] mt9t112: mt9t111 format set up differs from mt9t112
  [media] sh-mobile-ceu-camera: fix SHARPNESS control default
  Revert "[media] fc0011: Return early, if the frequency is already tuned"
  [media] cx18/ivtv: fix regression: remove __init from a non-init function
  [media] em28xx: fix analog streaming with USB bulk transfers
  [media] stv0900: remove unnecessary null pointer check
  [media] fc0011: Return early, if the frequency is already tuned
  [media] fc0011: Add some sanity checks and cleanups
  [media] fc0011: Fix xin value clamping
  Revert "[media] [PATH,1/2] mxl5007 move reset to attach"
  ...
2013-02-24 17:35:10 -08:00
Mauro Carvalho Chehab ac89758697 Revert "[media] dvb_frontend: return -ENOTTY for unimplement IOCTL"
As reported by Klaus Schmidinger:
 "In VDR I use an ioctl() call with FE_READ_UNCORRECTED_BLOCKS on a
  device (using stb0899).  After this call I check 'errno' for
  EOPNOTSUPP to determine whether this device supports this call.  This
  used to work just fine, until a few months ago I noticed that my
  devices using stb0899 didn't display their signal quality in VDR's OSD
  any more.  After further investigation I found that
  ioctl(FE_READ_UNCORRECTED_BLOCKS) no longer returns EOPNOTSUPP, but
  rather ENOTTY.  And since I stop getting the signal quality in case
  any unknown errno value appears, this broke my signal quality query
  function."

While the changes reflect what is there at:

  http://comments.gmane.org/gmane.linux.kernel/1235728

it does cause regression on userspace.  So, revert it to stop the
damage.

This reverts commit 177ffe506c ("[media] dvb_frontend: return -ENOTTY
for unimplement IOCTL").

Reported-by: Klaus Schmidinger <Klaus.Schmidinger@tvdr.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-15 12:11:23 -08:00
Mauro Carvalho Chehab 94a93e5f85 [media] dvb_frontend: print a msg if a property doesn't exist
If userspace calls a property that doesn't exist, it currently
just returns -EINVAL. However, this is more likely a problem at
the userspace application, calling it with a non-existing property.
So, add a debug message to help tracking it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-01-23 19:10:57 -02:00
Mauro Carvalho Chehab 7cd4ece58f [media] dvb: the core logic to handle the DVBv5 QoS properties
Add the logic to poll, reset counters and report the QoS stats
to the end user.
The idea is that the core will periodically poll the frontend for
the stats. The frontend may return -EBUSY, if the previous collect
didn't finish, or it may fill the cached data.
The value returned to the end user is always the cached data.

Reviewed-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-01-23 19:09:52 -02:00
Ezequiel Garcia b9b1b3a8f7 [media] dvb-core: Replace memcpy with struct assignment
This kind of memcpy() is error-prone. Its replacement with a struct
assignment is prefered because it's type-safe and much easier to read.
Found by coccinelle. Hand patched and reviewed.
Tested by compilation only.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
identifier struct_name;
struct struct_name to;
struct struct_name from;
expression E;
@@
-memcpy(&(to), &(from), E);
+to = from;
// </smpl>

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-27 19:02:57 -02:00
Juergen Lock 6ae2322455 [media] dvb_frontend: fix ioctls failing if frontend open/closed too fast
That likely fixes this MythTV ticket:
	http://code.mythtv.org/trac/ticket/10830
(which btw affects all usb tuners I tested as well, pctv452e,
dib0700, af9015)  pctv452e is still possibly broken with MythTV
even after this fix; it does work with VDR here tho despite I2C
errors.
Reduced testcase:
	http://people.freebsd.org/~nox/tmp/ioctltst.c
Thanx to devinheitmueller and crope from #linuxtv for helping with
this fix! :)

Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-27 15:43:17 -02:00
Mauro Carvalho Chehab e6ea0b9178 [media] dvb_frontend: Don't declare values twice at a table
drivers/media/dvb-core/dvb_frontend.c:1032:2: warning: initialized field overwritten [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1032:2: warning: (near initialization for 'dtv_cmds[36]') [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1033:2: warning: initialized field overwritten [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1033:2: warning: (near initialization for 'dtv_cmds[37]') [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1034:2: warning: initialized field overwritten [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1034:2: warning: (near initialization for 'dtv_cmds[38]') [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1035:2: warning: initialized field overwritten [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1035:2: warning: (near initialization for 'dtv_cmds[39]') [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1036:2: warning: initialized field overwritten [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1036:2: warning: (near initialization for 'dtv_cmds[40]') [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1037:2: warning: initialized field overwritten [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1037:2: warning: (near initialization for 'dtv_cmds[60]') [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1045:2: warning: initialized field overwritten [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1045:2: warning: (near initialization for 'dtv_cmds[46]') [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1051:2: warning: initialized field overwritten [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1051:2: warning: (near initialization for 'dtv_cmds[52]') [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1060:2: warning: initialized field overwritten [-Woverride-init]
drivers/media/dvb-core/dvb_frontend.c:1060:2: warning: (near initialization for 'dtv_cmds[61]') [-Woverride-init]

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-10-28 07:38:39 -02:00
Antti Palosaari 33eebec55c [media] dvb: LNA implementation changes
* use dvb property cache
* implement get (thus API minor++)
* PCTV 290e: 1=LNA ON, all the other values LNA OFF
  Also fix PCTV 290e LNA comment, it is disabled by default
Hans and Mauro proposed use of cache implementation of get as they
were planning to extend LNA usage for analog side too.

Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Reported-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-10-07 10:27:49 -03:00
Peter Senna Tschudin c2c1b4156a [media] drivers/media: Remove unnecessary semicolon
A simplified version of the semantic patch that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@r1@
statement S;
position p,p1;
@@
S@p1;@p
@script:python r2@
p << r1.p;
p1 << r1.p1;
@@
if p[0].line != p1[0].line_end:
        cocci.include_match(False)
@@
position r1.p;
@@
-;@p
// </smpl>

[mchehab@redhat.com: some hunks got bitroted; applied only the
 ones that succeeds]
Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
[crope@iki.fi: For my drivers a8293, af9013, af9015, af9035]
Acked-by: Antti Palosaari <crope@iki.fi>
Reviewed-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-10-07 09:15:18 -03:00
Antti Palosaari 8a2697abc1 [media] add LNA support for DVB API
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-09-27 14:28:09 -03:00
Antti Palosaari 48caa6f129 [media] dvb_frontend: do not allow statistic IOCTLs when sleeping
Demodulator cannot perform statistic IOCTLs when it is not tuned.
Return -EAGAIN in such case.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-09-27 14:23:10 -03:00
Evgeny Plehov 287cefd096 [media] dvb_frontend: add multistream support
Unify multistream support at the DVBAPI: several delivery systems
allow it. Yet, each one had its own name. So, instead of adding
a third version of this field, remove the per-standard naming,
unifying it into a common name.

The legacy code number can still be used by old applications.

Version increased to 5.8.

[mchehab@redhat.com: joined the va1j5jf007s patch, in order to
 avoid compilation breakage]
Signed-off-by: Evgeny Plehov <EvgenyPlehov@ukr.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-09-23 20:59:32 -03:00
Antti Palosaari 177ffe506c [media] dvb_frontend: return -ENOTTY for unimplement IOCTL
Earlier it was returning -EOPNOTSUPP.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-09-10 11:14:35 -03:00
Antti Palosaari 36bdbc3fff [media] dvb_frontend: use Kernel dev_* logging
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-09-10 11:13:23 -03:00
Antti Palosaari 06bae1227a [media] dvb_frontend: implement suspend / resume
Move initial suspend / resume support from dvb_usb_v2 to dvb_frontend
as it is dvb general feature that could be used all dvb devices.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-08-15 19:18:43 -03:00
Antti Palosaari 6304a60eb8 [media] dvb_core: export function to perform retune
We need to retune when resume from suspend.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-08-15 19:15:45 -03:00
Mauro Carvalho Chehab 3d6c2bc08a [media] dvb: move the dvb core one level up
just like the V4L2 core, move the DVB core to drivers/media, as the
intention is to get rid of both "video" and "dvb" directories.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-08-13 23:08:14 -03:00
Renamed from drivers/media/dvb/dvb-core/dvb_frontend.c (Browse further)