summaryrefslogtreecommitdiff
path: root/drivers/media/rc/rc-ir-raw.c
AgeCommit message (Collapse)AuthorFilesLines
2022-01-28media: rc-core: rename ir_raw_event_reset to ir_raw_event_overflowSean Young1-2/+0
The driver report a reset event when the hardware reports and overflow. There is no reason to have a generic "reset" event. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
2020-09-03media: rc: rename ir_lirc_* functions to lirc_*Sean Young1-1/+1
Remove pointless ir_ prefix. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2020-09-03media: rc: harmonize infrared durations to microsecondsSean Young1-7/+7
rc-core kapi uses nanoseconds for infrared durations for receiving, and microseconds for sending. The uapi already uses microseconds for both, so this patch does not change the uapi. Infrared durations do not need nanosecond resolution. IR protocols do not have durations shorter than about 100 microseconds. Some IR hardware offers 250 microseconds resolution, which is sufficient for most protocols. Better hardware has 50 microsecond resolution and is enough for every protocol I am aware off. Unify on microseconds everywhere. This simplifies the code since less conversion between microseconds and nanoseconds needs to be done. This affects: - rx_resolution member of struct rc_dev - timeout member of struct rc_dev - duration member in struct ir_raw_event Cc: "Bruno Prémont" <bonbons@linux-vserver.org> Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl> Cc: Maxim Levitsky <maximlevitsky@gmail.com> Cc: Patrick Lerda <patrick9876@free.fr> Cc: Kevin Hilman <khilman@baylibre.com> Cc: Neil Armstrong <narmstrong@baylibre.com> Cc: Jerome Brunet <jbrunet@baylibre.com> Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Cc: Sean Wang <sean.wang@mediatek.com> Cc: Matthias Brugger <matthias.bgg@gmail.com> Cc: Patrice Chotard <patrice.chotard@st.com> Cc: Maxime Ripard <mripard@kernel.org> Cc: Chen-Yu Tsai <wens@csie.org> Cc: "David Härdeman" <david@hardeman.nu> Cc: Benjamin Valentin <benpicco@googlemail.com> Cc: Antti Palosaari <crope@iki.fi> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2019-03-01media: rc: fix several typosMauro Carvalho Chehab1-1/+1
Use codespell to fix lots of typos over frontends. Manually verified to avoid false-positives. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Acked-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-10-04media: rc: Remove init_ir_raw_event and DEFINE_IR_RAW_EVENT macrosSean Young1-6/+6
This can be done with c99 initializers, which makes the code cleaner and more transparent. It does require gcc 4.6, because of this bug in earlier versions: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10676 Since commit cafa0010cd51 ("Raise the minimum required gcc version to 4.6"), this is the case. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-06-27media: rc: be less noisy when driver misbehavesSean Young1-4/+4
Since commit 48231f289e52 ("media: rc: drivers should produce alternate pulse and space timing events"), on meson-ir we are regularly producing errors. Reduce to warning level and only warn once to avoid flooding the log. A proper fix for meson-ir is going to be too large for v4.18. Signed-off-by: Sean Young <sean@mess.org> Cc: stable@vger.kernel.org # 4.17+ Tested-by: Jerome Brunet <jbrunet@baylibre.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-06-07Merge tag 'media/v4.18-2' of ↵Linus Torvalds1-17/+64
git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media Pull media updates from Mauro Carvalho Chehab: - remove of atomisp driver from staging, as nobody would have time to dedicate huge efforts to fix all the problems there. Also, we have a feeling that the driver may not even run the way it is. - move Zoran driver to staging, in order to be either fixed to use VB2 and the proper media kAPIs or to be removed - remove videobuf-dvb driver, with is unused for a while - some V4L2 documentation fixes/improvements - new sensor drivers: imx258 and ov7251 - a new driver was added to allow using I2C transparent drivers - several improvements at the ddbridge driver - several improvements at the ISDB pt1 driver, making it more coherent with the DVB framework - added a new platform driver for MIPI CSI-2 RX: cadence - now, all media drivers can be compiled on x86 with COMPILE_TEST - almost all media drivers now build on non-x86 architectures with COMPILE_TEST - lots of other random stuff: cleanups, support for new board models, bug fixes, etc * tag 'media/v4.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (464 commits) media: omap2: fix compile-testing with FB_OMAP2=m media: media/radio/Kconfig: add back RADIO_ISA media: v4l2-ioctl.c: fix missing unlock in __video_do_ioctl() media: pxa_camera: ignore -ENOIOCTLCMD from v4l2_subdev_call for s_power media: arch: sh: migor: Fix TW9910 PDN gpio media: staging: tegra-vde: Reset VDE regardless of memory client resetting failure media: marvel-ccic: mmp: select VIDEOBUF2_VMALLOC/DMA_CONTIG media: marvel-ccic: allow ccic and mmp drivers to coexist media: uvcvideo: Prevent setting unavailable flags media: ddbridge: conditionally enable fast TS for stv0910-equipped bridges media: dvb-frontends/stv0910: make TS speed configurable media: ddbridge/mci: add identifiers to function definition arguments media: ddbridge/mci: protect against out-of-bounds array access in stop() media: rc: ensure input/lirc device can be opened after register media: rc: nuvoton: Keep device enabled during reg init media: rc: nuvoton: Keep track of users on CIR enable/disable media: rc: nuvoton: Tweak the interrupt enabling dance media: uvcvideo: Support realtek's UVC 1.5 device media: uvcvideo: Fix driver reference counting media: gspca_zc3xx: Enable short exposure times for OV7648 ...
2018-05-30media: rc: introduce BPF_PROG_LIRC_MODE2Sean Young1-2/+10
Add support for BPF_PROG_LIRC_MODE2. This type of BPF program can call rc_keydown() to reported decoded IR scancodes, or rc_repeat() to report that the last key should be repeated. The bpf program can be attached to using the bpf(BPF_PROG_ATTACH) syscall; the target_fd must be the /dev/lircN device. Acked-by: Yonghong Song <yhs@fb.com> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2018-05-14media: rc: drivers should produce alternate pulse and space timing eventsSean Young1-4/+15
Report an error if this is not the case or any problem with the generated raw events. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-14media: rc: default to idle on at startup or after resetSean Young1-0/+1
Any spaces events received after a reset or startup should be discarded, so ensure the rc device is in idle mode. This also makes it much easier to detect incorrect raw events, as we will do in a following commit. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-04media: rc: only register protocol for rc device if enabledSean Young1-12/+18
The raw_register function exists to create input devices associated with that IR protocol. If the mce_kbd module is loaded, then every rc device will have mce_kbd input devices, even if the protocol is not enabled. Change this to call the register function to when the protocol is enabled. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-04-20media: rc: set timeout to smallest value required by enabled protocolsSean Young1-1/+30
The longer the IR timeout, the longer the rc device waits until delivering the trailing space. So, by reducing this timeout, we reduce the delay for the last scancode to be delivered. Note that the lirc daemon disables all protocols, in which case we revert back to the default value. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-21media: rc: meson-ir: add timeout on idleSean Young1-3/+27
Meson doesn't seem to be able to generate timeout events in hardware. So install a software timer to generate the timeout events required by the decoders to prevent "ghost keypresses". Reported-by: Matthias Reichl <hias@horus.com> Tested-by: Matthias Reichl <hias@horus.com> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-27media: rc: fix race condition in ir_raw_event_store_edge() handlingSean Young1-3/+21
There is a possible race condition between the IR timeout being generated from the timer, and new IR arriving. This could result in the timeout being added to the kfifo after new IR arrives. On top of that, there is concurrent write access to the kfifo from ir_raw_event_store_edge() and the timer. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-14media: rc: remove IR_dprintk() from rc-coreSean Young1-3/+3
Use dev_dbg() rather than custom debug function. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-01-23media: rc: do not remove first bit if leader pulse is presentSean Young1-1/+0
The rc5 protocol does not have a leading pulse or space, but we encode the first bit using a single leading pulse. For other protocols, the leading pulse or space does not represent any bit. So, don't remove the first bit if a leading pulse is present. Cc: Antti Seppälä <a.seppala@gmail.com> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-01-23media: rc: clean up leader pulse/space for manchester encodingSean Young1-7/+5
The IR rc6 encoder sends the header using manchester encoding using 0 bits, which causes the following: UBSAN: Undefined behaviour in drivers/media/rc/rc-ir-raw.c:247:6 shift exponent 4294967295 is too large for 64-bit type 'long long unsigned int' So, allow the leader code to send a pulse and space and remove the unused pulse_space_start field. Cc: Antti Seppälä <a.seppala@gmail.com> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-14media: lirc: lirc interface should not be a raw decoderSean Young1-19/+5
The lirc user interface exists as a raw decoder, which does not make much sense for transmit-only devices. In addition, we want to have lirc char devices for devices which do not use raw IR, i.e. scancode only devices. Note that rc-code, lirc_dev, ir-lirc-codec are now calling functions of each other, so they've been merged into one module rc-core to avoid circular dependencies. Since ir-lirc-codec no longer exists as separate codec module, there is no need for RC_DRIVER_IR_RAW_TX type drivers to call ir_raw_event_register(). Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-14media: rc: auto load encoder if necessarySean Young1-0/+2
When sending scancodes, load the encoder if we need it. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-14media: lirc: use the correct carrier for scancode transmitSean Young1-0/+30
If the lirc device supports it, set the carrier for the protocol. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-11media: rc: add SPDX identifiers to the code I wroteMauro Carvalho Chehab1-13/+4
As we're now using SPDX identifiers, on the several media drivers I wrote, add the proper SPDX, identifying the license I meant. As we're now using the short license, it doesn't make sense to keep the original license text. Also, fix MODULE_LICENSE to properly identify GPL v2. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-11-27media: rc-ir-raw: cleanup kernel-doc markupsMauro Carvalho Chehab1-1/+1
Cleanup those warnings: drivers/media/rc/rc-ir-raw.c:141: warning: No description found for parameter 'ev' drivers/media/rc/rc-ir-raw.c:141: warning: Excess function parameter 'type' description in 'ir_raw_event_store_with_filter' Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-10-31media: rc: Convert timers to use timer_setup()Kees Cook1-4/+4
In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Cc: Maxim Levitsky <maximlevitsky@gmail.com> Cc: James Hogan <jhogan@kernel.org> Cc: Hans Verkuil <hans.verkuil@cisco.com> Cc: "Antti Seppälä" <a.seppala@gmail.com> Cc: Heiner Kallweit <hkallweit1@gmail.com> Cc: "David Härdeman" <david@hardeman.nu> Cc: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-31media: rc: use ktime accessor functionsJasmin Jessich1-5/+6
Prefer using accessor functions so we are not dependent on the ktime_t type. Signed-off-by: Jasmin Jessich <jasmin@anw.at> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20media: rc: rename RC_TYPE_* to RC_PROTO_* and RC_BIT_* to RC_PROTO_BIT_*Sean Young1-2/+2
RC_TYPE is confusing and it's just the protocol. So rename it. Suggested-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Sean Young <sean@mess.org> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20media: rc: simplify ir_raw_event_store_edge()Sean Young1-26/+5
Since commit 12749b198fa4 ("[media] rc: saa7134: add trailing space for timely decoding"), the workaround of inserting reset events is no longer needed. Note that the initial reset is not needed either; other rc-core drivers that don't use ir_raw_event_store_edge() never call this at all. Verified on a HVR-1150 and Raspberry Pi. Fixes: 3f5c4c73322e ("[media] rc: fix ghost keypresses with certain hw") Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20media: rc: saa7134: add trailing space for timely decodingSean Young1-1/+18
The gpio-ir-recv driver adds timeouts which the saa7134 lacks; this causes keypress not to arrive, and to only arrive once more IR is received. This is what the commit below calls "ghost keypresses", and that commit does not solve the issue completely. This makes the IR on the HVR-1150 much more reliable and responsive. Fixes: 3f5c4c73322e ("[media] rc: fix ghost keypresses with certain hw") Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-08-20media: rc-core: improve ir_raw_store_edge() handlingSean Young1-0/+15
The gpio-ir-recv driver does many wakeups (once per edge); the saa7134 driver has special handling to only wakeup 15ms after the first edge. Make this part of rc-core so gpio-ir-recv also benefits from this (so a rc-5 keypress now causes 3 wakeups rather than 24). Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-13[media] rc-core: cleanup rc_register_deviceDavid Härdeman1-12/+24
The device core infrastructure is based on the presumption that once a driver calls device_add(), it must be ready to accept userspace interaction. This requires splitting rc_setup_rx_device() into two functions and reorganizing rc_register_device() so that as much work as possible is performed before calling device_add(). Signed-off-by: David Härdeman <david@hardeman.nu> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-04[media] rc-core: race condition during ir_raw_event_register()Sean Young1-5/+8
A rc device can call ir_raw_event_handle() after rc_allocate_device(), but before rc_register_device() has completed. This is racey because rcdev->raw is set before rcdev->raw->thread has a valid value. Cc: stable@kernel.org Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-03-24[media] mce_kbd: add encoderSean Young1-3/+3
Split the protocol into two variants, one for keyboard and one for mouse data. Note that the mce_kbd protocol cannot be used on the igorplugusb, since the IR is too long. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-30[media] rc-ir-raw: do not generate any receiving thread for raw transmittersAndi Shyti1-5/+11
Raw IR transmitters do not need any thread listening for occurring events. Check the driver type before running the thread. Signed-off-by: Andi Shyti <andi.shyti@samsung.com> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-30[media] rc: ir-sony-decoder: Add encode capabilitySean Young1-0/+64
Add the capability to encode Sony scancodes as raw events. Sony uses pulse length rather than pulse distance. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-30[media] rc: rc-ir-raw: Add pulse-distance modulation helperJames Hogan1-0/+59
Add IR encoding helper for pulse-distance modulation as used by the NEC protocol. Signed-off-by: James Hogan <james@albanarts.com> Signed-off-by: Sean Young <sean@mess.org> Cc: Antti Seppälä <a.seppala@gmail.com> Cc: David Härdeman <david@hardeman.nu> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-30[media] rc: rc-ir-raw: Add Manchester encoder (phase encoder) helperAntti Seppälä1-0/+85
Adding a simple Manchester encoder to rc-core. Manchester coding is used by at least RC-5 and RC-6 protocols and their variants. Signed-off-by: Antti Seppälä <a.seppala@gmail.com> Signed-off-by: James Hogan <james@albanarts.com> Signed-off-by: Sean Young <sean@mess.org> Cc: David Härdeman <david@hardeman.nu> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-30[media] rc: rc-ir-raw: Add scancode encoder callbackJames Hogan1-0/+37
Add a callback to raw ir handlers for encoding and modulating a scancode to a set of raw events. This could be used for transmit, or for converting a wakeup scancode to a form that is more suitable for raw hardware wake up filters. Signed-off-by: James Hogan <james@albanarts.com> Signed-off-by: Antti Seppälä <a.seppala@gmail.com> Signed-off-by: Sean Young <sean@mess.org> Cc: David Härdeman <david@hardeman.nu> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-30[media] rc: change wakeup_protocols to list all protocol variantsSean Young1-1/+0
For IR wakeup, a driver has to program the hardware to wakeup at a specific IR sequence, so it makes no sense to allow multiple wakeup protocols to be selected. In the same manner the sysfs interface only allows one scancode to be provided. In addition, we need to know the specific variant of the protocol. In short, these changes are made to the wakeup_protocols sysfs entry: - list all the protocol variants rather than the protocol groups, e.g. "nec nec-x nec-32" rather than just "nec". - only allow one protocol variant to be selected rather than multiple - wakeup_filter can only be set once a protocol has been selected in wakeup_protocols. This is an API change, however the only user of this API is the img-ir, but the wakeup code was never merged to mainline, so it was never used. Signed-off-by: Sean Young <sean@mess.org> Cc: James Hogan <james.hogan@imgtec.com> Cc: Sifan Naeem <sifan.naeem@imgtec.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-01-30[media] rc: refactor raw handler kthreadHeiner Kallweit1-29/+17
I think we can get rid of the spinlock protecting the kthread from being interrupted by a wakeup in certain parts. Even with the current implementation of the kthread the only lost wakeup scenario could happen if the wakeup occurs between the kfifo_len check and setting the state to TASK_INTERRUPTIBLE. In the changed version we could lose a wakeup if it occurs between processing the fifo content and setting the state to TASK_INTERRUPTIBLE. This scenario is covered by an additional check for available events in the fifo and setting the state to TASK_RUNNING in this case. In addition the changed version flushes the kfifo before ending when the kthread is stopped. With this patch we gain: - Get rid of the spinlock - Simplify code - Don't grep / release the mutex for each individual event but just once for the complete fifo content. This reduces overhead if a driver e.g. triggers processing after writing the content of a hw fifo to the kfifo. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-24[media] rc: ir-raw: change type of available_protocols to atomic64_tHeiner Kallweit1-13/+4
Changing available_protocols to atomic64_t allows to get rid of the mutex protecting access to the variable. This helps to simplify the code. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-22[media] media: rc: fix deadlock when module ir_lirc_codec is removedHeiner Kallweit1-2/+7
When removing module ir_lirc_codec I got this deadlock warning. Fix this by introducing a separate mutex to protect access to available_protocols instead of using ir_raw_handler_lock for this purpose. ====================================================== [ INFO: possible circular locking dependency detected ] 4.7.0-next-20160729 #1 Not tainted ------------------------------------------------------- rmmod/2542 is trying to acquire lock: (&dev->lock){+.+.+.}, at: [<ffffffffa03b1267>] ir_raw_handler_unregister+0x77/0xd0 [rc_core] but task is already holding lock: (ir_raw_handler_lock){+.+.+.}, at: [<ffffffffa03b1212>] ir_raw_handler_unregister+0x22/0xd0 [rc_core] which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (ir_raw_handler_lock){+.+.+.}: [<ffffffff810ab1f2>] lock_acquire+0xb2/0x1e0 [<ffffffff815c087f>] mutex_lock_nested+0x5f/0x360 [<ffffffffa03b1403>] ir_raw_get_allowed_protocols+0x13/0x30 [rc_core] [<ffffffffa03af8ea>] store_protocols+0x2fa/0x480 [rc_core] [<ffffffff8143e143>] dev_attr_store+0x13/0x20 [<ffffffff81213c50>] sysfs_kf_write+0x40/0x50 [<ffffffff81212f60>] kernfs_fop_write+0x150/0x1e0 [<ffffffff81197613>] __vfs_write+0x23/0x120 [<ffffffff81198740>] vfs_write+0xb0/0x190 [<ffffffff81199a34>] SyS_write+0x44/0xa0 [<ffffffff815c55a5>] entry_SYSCALL_64_fastpath+0x18/0xa8 -> #0 (&dev->lock){+.+.+.}: [<ffffffff810aac8c>] __lock_acquire+0x10fc/0x1270 [<ffffffff810ab1f2>] lock_acquire+0xb2/0x1e0 [<ffffffff815c087f>] mutex_lock_nested+0x5f/0x360 [<ffffffffa03b1267>] ir_raw_handler_unregister+0x77/0xd0 [rc_core] [<ffffffffa03c8c05>] ir_lirc_codec_exit+0x10/0x12 [ir_lirc_codec] [<ffffffff810e1b88>] SyS_delete_module+0x168/0x220 [<ffffffff815c55a5>] entry_SYSCALL_64_fastpath+0x18/0xa8 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(ir_raw_handler_lock); lock(&dev->lock); lock(ir_raw_handler_lock); lock(&dev->lock); *** DEADLOCK *** 1 lock held by rmmod/2542: #0: (ir_raw_handler_lock){+.+.+.}, at: [<ffffffffa03b1212>] ir_raw_handler_unregister+0x22/0xd0 [rc_core] stack backtrace: CPU: 0 PID: 2542 Comm: rmmod Not tainted 4.7.0-next-20160729 #1 Hardware name: ZOTAC ZBOX-CI321NANO/ZBOX-CI321NANO, BIOS B246P105 06/01/2015 0000000000000000 ffff88006e607cc0 ffffffff812715f5 ffffffff8232b230 ffffffff8232b230 ffff88006e607d00 ffffffff810a846e 00000000790107f0 ffff880079010818 ffff8800790107f0 1efeb9f4f0dd2e6f ffff880079010000 Call Trace: [<ffffffff812715f5>] dump_stack+0x68/0x93 [<ffffffff810a846e>] print_circular_bug+0x1be/0x210 [<ffffffff810aac8c>] __lock_acquire+0x10fc/0x1270 [<ffffffff810bcead>] ? debug_lockdep_rcu_enabled+0x1d/0x20 [<ffffffff810ab1f2>] lock_acquire+0xb2/0x1e0 [<ffffffffa03b1267>] ? ir_raw_handler_unregister+0x77/0xd0 [rc_core] [<ffffffff815c087f>] mutex_lock_nested+0x5f/0x360 [<ffffffffa03b1267>] ? ir_raw_handler_unregister+0x77/0xd0 [rc_core] [<ffffffff810a980e>] ? trace_hardirqs_on_caller+0xee/0x1b0 [<ffffffffa03b1267>] ir_raw_handler_unregister+0x77/0xd0 [rc_core] [<ffffffffa03c8c05>] ir_lirc_codec_exit+0x10/0x12 [ir_lirc_codec] [<ffffffff810e1b88>] SyS_delete_module+0x168/0x220 [<ffffffff815c55a5>] entry_SYSCALL_64_fastpath+0x18/0xa8 Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-01-25[media] media: rc: raw: improve FIFO handlingHeiner Kallweit1-15/+8
The FIFO is used for ir_raw_event records, however for some historic reason the FIFO is used on a per byte basis. IMHO this adds unneeded complexity. Therefore set up the FIFO for ir_raw_event records. This also allows to define the FIFO statically as part of ir_raw_event_ctrl instead of having to allocate the FIFO dynamically. In addition: - When writing into the FIFO and it's full return ENOSPC instead of ENOMEM thus making it easier to tell between "FIFO full" and "Dynamic memory allocation failed" when the error is propagated to a higher level. Also add an error message. - When reading from the FIFO check whether it's empty. This is not strictly needed here but kfifo_out is annotated "must check" anyway. Successfully tested it with the nuvoton-cir driver. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-12-03[media] media: rc: remove unneeded codeHeiner Kallweit1-10/+0
Now that that the decoder modules are loaded on-demand we can move loading the lirc module to rc_register_device directly and remove unneeded functions and comments. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
2015-11-19[media] media: rc: move check whether a protocol is enabled to the coreHeiner Kallweit1-1/+3
Checking whether a protocol is enabled and calling the related decoder functions should be done by the rc core, not the protocol handlers. Properly handle lirc considering that no protocol bit is set for lirc. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-11-19[media] media: rc: load decoder modules on-demandHeiner Kallweit1-10/+0
Remove code for unconditional decoder module loading (except lirc). Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-11-19[media] media: rc: fix decoder module unloadingHeiner Kallweit1-3/+14
Currently, if a decoder module is unloadad, the respective protocol is still shown as enabled (if it was enabled before). Fix this by resetting the respective protocol bits if a decoder module is unloaded. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-05Merge tag 'media/v4.3-1' of ↵Linus Torvalds1-1/+1
git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media Pull media updates from Mauro Carvalho Chehab: - new DVB frontend drivers: ascot2e, cxd2841er, horus3a, lnbh25 - new HDMI capture driver: tc358743 - new driver for NetUP DVB new boards (netup_unidvb) - IR support for DVBSky cards (smipcie-ir) - Coda driver has gain macroblock tiling support - Renesas R-Car gains JPEG codec driver - new DVB platform driver for STi boards: c8sectpfe - added documentation for the media core kABI to device-drivers DocBook - lots of driver fixups, cleanups and improvements * tag 'media/v4.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (297 commits) [media] c8sectpfe: Remove select on undefined LIBELF_32 [media] i2c: fix platform_no_drv_owner.cocci warnings [media] cx231xx: Use wake_up_interruptible() instead of wake_up_interruptible_nr() [media] tc358743: only queue subdev notifications if devnode is set [media] tc358743: add missing Kconfig dependency/select [media] c8sectpfe: Use %pad to print 'dma_addr_t' [media] DocBook media: Fix typo "the the" in xml files [media] tc358743: make reset gpio optional [media] tc358743: set direction of reset gpio using devm_gpiod_get [media] dvbdev: document most of the functions/data structs [media] dvb_frontend.h: document the struct dvb_frontend [media] dvb-frontend.h: document struct dtv_frontend_properties [media] dvb-frontend.h: document struct dvb_frontend_ops [media] dvb: Use DVBFE_ALGO_HW where applicable [media] dvb_frontend.h: document struct analog_demod_ops [media] dvb_frontend.h: Document struct dvb_tuner_ops [media] Docbook: Document struct analog_parameters [media] dvb_frontend.h: get rid of dvbfe_modcod [media] add documentation for struct dvb_tuner_info [media] dvb_frontend: document dvb_frontend_tune_settings ...
2015-08-19Revert "[media] rc: rc-ir-raw: Add scancode encoder callback"David Härdeman1-37/+0
This reverts commit 9869da5bacc5c9b865a183bd36c04be76cdd325d. The current code is not mature enough, the API should allow a single protocol to be specified. Also, the current code contains heuristics that will depend on module load order. Signed-off-by: David Härdeman <david@hardeman.nu> Acked-by: Antti Seppälä <a.seppala@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-08-19Revert "[media] rc: rc-ir-raw: Add Manchester encoder (phase encoder) helper"David Härdeman1-85/+0
This reverts commit 1d971d927efa2e10194c96ed0475b6d6054342d8. The current code is not mature enough, the API should allow a single protocol to be specified. Also, the current code contains heuristics that will depend on module load order. Signed-off-by: David Härdeman <david@hardeman.nu> Acked-by: Antti Seppälä <a.seppala@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-08-19Revert "[media] rc: rc-core: Add support for encode_wakeup drivers"David Härdeman1-17/+0
This reverts commit 0d830b2d1295fee82546d57185da5a6604f11ae2. The current code is not mature enough, the API should allow a single protocol to be specified. Also, the current code contains heuristics that will depend on module load order. Signed-off-by: David Härdeman <david@hardeman.nu> Acked-by: Antti Seppälä <a.seppala@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-07-06[media] rc-core: use an IDA rather than a bitmapDavid Härdeman1-1/+1
This patch changes rc-core to use the kernel facilities that are already available for handling unique numbers instead of rolling its own bitmap stuff. Signed-off-by: David Härdeman <david@hardeman.nu> Tested-by: Stefan Lippers-Hollmann <s.l-h@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>