summaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb-core/dvb_frontend.c
Commit message (Collapse)AuthorAgeFilesLines
* Revert "[media] dvb_frontend: merge duplicate dvb_tuner_ops.release ↵Mauro Carvalho Chehab2016-11-181-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | implementations" While this patch sounded a good idea, unfortunately, it causes bad dependencies, as drivers that would otherwise work without the DVB core will now break: ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/tea5767.ko] undefined! ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/tea5761.ko] undefined! ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/tda827x.ko] undefined! ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/tda18218.ko] undefined! ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/qt1010.ko] undefined! ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/mt2266.ko] undefined! ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/mt20xx.ko] undefined! ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/mt2060.ko] undefined! ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/mc44s803.ko] undefined! ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/fc0013.ko] undefined! ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/fc0012.ko] undefined! ERROR: "dvb_tuner_simple_release" [drivers/media/tuners/fc0011.ko] undefined! So, we have to revert it. Note: as the argument for the release ops changed from "int" to "void", we needed to change it at the revert patch, to avoid compilation issues like: drivers/media/tuners/tea5767.c:437:23: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .release = tea5767_release, ^~~~~~~~~~~~~~~ This reverts commit 22a613e89825ea7a3984a968463cc6d425bd8856. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb_frontend: move kref to struct dvb_frontendMax Kellermann2016-11-181-16/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit amends my old commit fe35637b0a9f ("[media] dvb_frontend: eliminate blocking wait in dvb_unregister_frontend()"), which added kref to struct dvb_frontend_private. It turned out that there are several use-after-free bugs left, which affect the struct dvb_frontend. Protecting it with kref also protects struct dvb_frontend_private, so we can simply move it. This is how the use-after-free looks like in KASAN: BUG: KASAN: use-after-free in string+0x60/0xb1 at addr ffff880033bd9fc0 Read of size 1 by task kworker/0:2/617 CPU: 0 PID: 617 Comm: kworker/0:2 Not tainted 4.8.0-rc1-hosting+ #60 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Workqueue: usb_hub_wq hub_event 0000000000000000 ffff880033757218 ffffffff81394e50 ffff880033bd9fd0 ffff880035c03b00 ffff880033757240 ffffffff811f271d ffff880033bd9fc0 1ffff1000677b3f8 ffffed000677b3f8 ffff8800337572b8 ffffffff811f2afe Call Trace: [...] [<ffffffff813a2d2f>] vsnprintf+0x39d/0x7e9 [<ffffffff813993f9>] add_uevent_var+0x10f/0x1dc [<ffffffff814fe5ca>] rc_dev_uevent+0x55/0x6f [<ffffffff814438f8>] dev_uevent+0x2e1/0x316 [<ffffffff81399744>] kobject_uevent_env+0x27e/0x701 [<ffffffff81399bd2>] kobject_uevent+0xb/0xd [<ffffffff81443445>] device_del+0x322/0x383 [<ffffffff81500c0c>] rc_unregister_device+0x98/0xc3 [<ffffffff81508fb4>] dvb_usb_remote_exit+0x7a/0x90 [<ffffffff81506157>] dvb_usb_exit+0x1d/0xe5 [<ffffffff81506e90>] dvb_usb_device_exit+0x69/0x7d [<ffffffff8150a181>] pctv452e_usb_disconnect+0x7b/0x80 [...] Object at ffff880033bd9fc0, in cache kmalloc-16 size: 16 Allocated: [...] Freed: PID = 617 [...] [<ffffffff811f034c>] kfree+0xd9/0x166 [<ffffffff814fe513>] ir_free_table+0x2f/0x51 [<ffffffff81500bc1>] rc_unregister_device+0x4d/0xc3 [<ffffffff81508fb4>] dvb_usb_remote_exit+0x7a/0x90 [<ffffffff81506157>] dvb_usb_exit+0x1d/0xe5 [<ffffffff81506e90>] dvb_usb_device_exit+0x69/0x7d [<ffffffff8150a181>] pctv452e_usb_disconnect+0x7b/0x80 Another one: BUG: KASAN: use-after-free in do_sys_poll+0x336/0x6b8 at addr ffff88003563fcc0 Read of size 8 by task tuner on fronte/1042 CPU: 1 PID: 1042 Comm: tuner on fronte Tainted: G B 4.8.0-rc1-hosting+ #60 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 0000000000000000 ffff88003353f910 ffffffff81394e50 ffff88003563fd80 ffff880035c03200 ffff88003353f938 ffffffff811f271d ffff88003563fc80 1ffff10006ac7f98 ffffed0006ac7f98 ffff88003353f9b0 ffffffff811f2afe Call Trace: [...] [<ffffffff812289b3>] do_sys_poll+0x336/0x6b8 [...] [<ffffffff81228ed9>] SyS_poll+0xa9/0x194 [...] Object at ffff88003563fc80, in cache kmalloc-256 size: 256 Allocated: [...] Freed: PID = 617 [...] [<ffffffff811f034c>] kfree+0xd9/0x166 [<ffffffff814eb60d>] dvb_unregister_device+0xd6/0xe5 [<ffffffff814fa4ed>] dvb_unregister_frontend+0x4b/0x66 [<ffffffff8150810b>] dvb_usb_adapter_frontend_exit+0x69/0xac [<ffffffff8150617d>] dvb_usb_exit+0x43/0xe5 [<ffffffff81506e90>] dvb_usb_device_exit+0x69/0x7d [<ffffffff8150a181>] pctv452e_usb_disconnect+0x7b/0x80 Signed-off-by: Max Kellermann <max.kellermann@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb_frontend: add "detach" callbackMax Kellermann2016-11-181-0/+1
| | | | | | | | | Prepare for making "release" asynchronous (via kref). Some operations may need to be run synchronously in dvb_frontend_detach(), and that's why we need a "detach" callback. Signed-off-by: Max Kellermann <max.kellermann@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb_frontend: merge the two dvb_frontend_detach() versionsMax Kellermann2016-11-181-30/+12
| | | | | | | | This code duplication is confusing and error prone. Let's merge them by moving the release/dvb_detach call into one function with one Signed-off-by: Max Kellermann <max.kellermann@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb_frontend: tuner_ops.release returns voidMax Kellermann2016-11-181-2/+1
| | | | | | | | | It is not clear what this return value means. All implemenations return 0, and the one caller ignores the value. Let's remove this useless return value completely. Signed-off-by: Max Kellermann <max.kellermann@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb_frontend: merge duplicate dvb_tuner_ops.release implementationsMax Kellermann2016-11-181-0/+9
| | | | | | | | | Most release callback functions are identical: free the "tuner_priv" and clear it. Let's eliminate some bloat by providing this simple implementation in the dvb_frontend library. Signed-off-by: Max Kellermann <max.kellermann@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] squash lines for simple wrapper functionsMasahiro Yamada2016-11-161-6/+2
| | | | | | | | Remove unneeded variables and assignments. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb-core: use pr_foo() instead of printk()Mauro Carvalho Chehab2016-10-211-3/+9
| | | | | | | | The dvb-core directly calls printk() without using the modern printk macros, or using the proper printk levels. Change it to use pr_foo(). Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb_frontend: Use memdup_user() rather than duplicating its ↵Markus Elfring2016-08-241-22/+6
| | | | | | | | | | | | | | | | | | implementation * Reuse existing functionality from memdup_user() instead of keeping duplicate source code. This issue was detected by using the Coccinelle software. * Return directly if this copy operation failed. * Replace the specification of data structures by pointer dereferences to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] dvb_frontend: eliminate blocking wait in dvb_unregister_frontend()Max Kellermann2016-07-131-8/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The wait_event() call in dvb_unregister_frontend() waits synchronously for other tasks to free a file descriptor, but it does that while holding several mutexes. That alone is a bad idea, but if one user process happens to keep a (defunct) file descriptor open indefinitely, the kernel will correctly detect a hung task: INFO: task kworker/0:1:314 blocked for more than 30 seconds. Not tainted 4.7.0-rc1-hosting+ #50 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. kworker/0:1 D ffff88003daf7a50 0 314 2 0x00000000 Workqueue: usb_hub_wq hub_event ffff88003daf7a50 0000000000000296 ffff88003daf7a30 ffff88003fc13f98 ffff88003dadce00 ffff88003daf8000 ffff88003e3fc010 ffff88003d48d4f8 ffff88003e3b5030 ffff88003e3f8898 ffff88003daf7a68 ffffffff810cf860 Call Trace: [<ffffffff810cf860>] schedule+0x30/0x80 [<ffffffff812f88d3>] dvb_unregister_frontend+0x93/0xc0 [<ffffffff8107a000>] ? __wake_up_common+0x80/0x80 [<ffffffff813019c7>] dvb_usb_adapter_frontend_exit+0x37/0x70 [<ffffffff81300614>] dvb_usb_exit+0x34/0xb0 [<ffffffff81300d4a>] dvb_usb_device_exit+0x3a/0x50 [<ffffffff81302dc2>] pctv452e_usb_disconnect+0x52/0x60 [<ffffffff81295a07>] usb_unbind_interface+0x67/0x1e0 [<ffffffff810609f3>] ? __blocking_notifier_call_chain+0x53/0x70 [<ffffffff8127ba67>] __device_release_driver+0x77/0x110 [<ffffffff8127c2d3>] device_release_driver+0x23/0x30 [<ffffffff8127ab5d>] bus_remove_device+0x10d/0x150 [<ffffffff8127879b>] device_del+0x13b/0x260 [<ffffffff81299dea>] ? usb_remove_ep_devs+0x1a/0x30 [<ffffffff8129468e>] usb_disable_device+0x9e/0x1e0 [<ffffffff8128bb09>] usb_disconnect+0x89/0x260 [<ffffffff8128db8d>] hub_event+0x30d/0xfc0 [<ffffffff81059475>] process_one_work+0x1c5/0x4a0 [<ffffffff8105940c>] ? process_one_work+0x15c/0x4a0 [<ffffffff81059799>] worker_thread+0x49/0x480 [<ffffffff81059750>] ? process_one_work+0x4a0/0x4a0 [<ffffffff81059750>] ? process_one_work+0x4a0/0x4a0 [<ffffffff8105f65e>] kthread+0xee/0x110 [<ffffffff810400bf>] ret_from_fork+0x1f/0x40 [<ffffffff8105f570>] ? __kthread_unpark+0x70/0x70 5 locks held by kworker/0:1/314: #0: ("usb_hub_wq"){......}, at: [<ffffffff8105940c>] process_one_work+0x15c/0x4a0 #1: ((&hub->events)){......}, at: [<ffffffff8105940c>] process_one_work+0x15c/0x4a0 #2: (&dev->mutex){......}, at: [<ffffffff8128d8cb>] hub_event+0x4b/0xfc0 #3: (&dev->mutex){......}, at: [<ffffffff8128bad2>] usb_disconnect+0x52/0x260 #4: (&dev->mutex){......}, at: [<ffffffff8127c2cb>] device_release_driver+0x1b/0x30 This patch removes the blocking wait, and postpones the kfree() call until all file handles have been closed by using struct kref. Signed-off-by: Max Kellermann <max@duempel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: dvb-frontend invoke enable/disable_source handlersShuah Khan2016-02-271-114/+21
| | | | | | | | | | | | | | Change dvb frontend to check if tuner is free when device opened in RW mode. Call to enable_source handler either returns with an active pipeline to tuner or error if tuner is busy. Tuner is released when frontend is released calling the disable_source handler. Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] dvb_frontend: Don't let drivers to trash data at cacheMauro Carvalho Chehab2016-02-041-8/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* [media] dvb_frontend: pass the props cache to get_frontend() as argMauro Carvalho Chehab2016-02-041-1/+1
| | | | | | | | | | | | | | | | | 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>
* [media] dvb_frontend: add props argument to dtv_get_frontend()Mauro Carvalho Chehab2016-02-041-12/+18
| | | | | | | | | | | 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>
* [media] dvb_frontend: print DTV property dump also for SET_PROPERTYMauro Carvalho Chehab2016-02-041-6/+14
| | | | | | | | | 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>
* [media] dvb-frontend: Use boottimeAbhilash Jindal2016-02-011-4/+4
| | | | | | | | | | | 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>
* [media] dvb: modify core to implement interfaces/entities at MC new genMauro Carvalho Chehab2016-01-111-1/+1
| | | | | | | | | | 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>
* [media] media: convert links from array to listMauro Carvalho Chehab2016-01-111-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* [media] fix dvb_frontend_sleep_until() logicMauro Carvalho Chehab2015-11-191-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* [media] media: dvb-core: Don't force CAN_INVERSION_AUTO in oneshot modeMalcolm Priestley2015-11-181-3/+3
| | | | | | | | | | | | | | | | | | 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>
* [media] dvb_frontend: resume tone and voltageMauro Carvalho Chehab2015-11-171-0/+5
| | | | | | | | 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>
* [media] dvb: document dvb_frontend_sleep_until()Mauro Carvalho Chehab2015-11-171-4/+5
| | | | | | | | | | | 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>
* [media] dvb: Use DVBFE_ALGO_HW where applicableMauro Carvalho Chehab2015-08-221-1/+0
| | | | | | | | | | | | | | 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>
* [media] dvb-core: prevent some corruption the legacy ioctlDan Carpenter2015-06-101-1/+7
| | | | | | | | 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>
* [media] dvb-frontend: Replace timeval with ktime_tTina Ruchandani2015-06-091-30/+11
| | | | | | | | | | | | | | | | 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>
* [media] dvb: Get rid of typedev usage for enumsMauro Carvalho Chehab2015-06-091-11/+16
| | | | | | | | | | | | | | | | | 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/*
* [media] dvb-core: fix 32-bit overflow during bandwidth calculationAntti Palosaari2015-05-201-1/+1
| | | | | | | | | 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>
* [media] dvb-frontend: remove a warningMauro Carvalho Chehab2015-02-261-0/+2
| | | | | | | | | | | | | 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>
* [media] dvb core: only start media entity if not NULLMauro Carvalho Chehab2015-02-231-2/+3
| | | | | | | | | | | 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>
* [media] dvb_frontend: start media pipeline while thread is runningMauro Carvalho Chehab2015-02-131-2/+24
| | | | | | | | 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>
* [media] dvb-frontend: enable tuner link when the FE thread startsMauro Carvalho Chehab2015-02-131-0/+94
| | | | | | | | 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>
* [media] dvb_frontend: add media controller support for DVB frontendMauro Carvalho Chehab2015-02-131-1/+4
| | | | | | | 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>
* [media] dvb-core: set default properties of ISDB-SAkihiro Tsukada2014-11-031-0/+6
| | | | | Signed-off-by: Akihiro Tsukada <tskd08@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] dvb_frontend: Fix __user namespaceMauro Carvalho Chehab2014-09-261-11/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* [media] dvb_frontend: estimate bandwidth also for DVB-S/S2/TurboMauro Carvalho Chehab2014-08-261-0/+17
| | | | | | | | | 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>
* [media] dvb-frontend: add core support for tuner suspend/resumeMauro Carvalho Chehab2014-08-211-2/+6
| | | | | | | | | | | | | | | | | 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>
* [media] media: dvb-core add new flag exit flag value for resumeShuah Khan2014-07-261-0/+2
| | | | | | | | | | | | | | 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>
* [media] media: dvb-core move fe exit flag from fepriv to fe for driver accessShuah Khan2014-07-261-15/+11
| | | | | | | | | | | | | 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>
* [media] dvbdev: add a dvb_detach() macroMauro Carvalho Chehab2014-06-171-4/+4
| | | | | | | | | | | 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>
* [media] dvb_frontend: Fix possible read out of boundsOle Ernst2014-03-121-4/+4
| | | | | | | 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>
* [media] dvb_frontend: better handle lna set errorsMauro Carvalho Chehab2014-03-041-0/+2
| | | | | | | 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>
* Merge branch 'for-linus' of ↵Linus Torvalds2013-05-011-4/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 ...
| * dvb_frontend: don't mess with ->f_op in ->release()Al Viro2013-04-291-4/+1
| | | | | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* | [media] dvb-core: don't clear stats at DTV_CLEARMauro Carvalho Chehab2013-03-211-1/+1
| | | | | | | | | | | | The stats are cleared by the frontend. Don't do it at DTV_CLEAR. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* | [media] dvb_frontend: Simplify the emulation logicMauro Carvalho Chehab2013-03-181-110/+109
| | | | | | | | | | | | | | | | 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>
* | [media] dvb-frontend: split set_delivery_system()Mauro Carvalho Chehab2013-03-181-129/+165
|/ | | | | | | | | | 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>
* Merge branch 'v4l_for_linus' of ↵Linus Torvalds2013-02-241-6/+53
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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" ...
| * [media] dvb_frontend: print a msg if a property doesn't existMauro Carvalho Chehab2013-01-231-0/+3
| | | | | | | | | | | | | | | | | | 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>
| * [media] dvb: the core logic to handle the DVBv5 QoS propertiesMauro Carvalho Chehab2013-01-231-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * [media] dvb-core: Replace memcpy with struct assignmentEzequiel Garcia2012-12-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
OpenPOWER on IntegriCloud