Commit graph

85 commits

Author SHA1 Message Date
Heiner Kallweit c1500ba0b6 [media] media: rc: remove unneeded code
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-12-03 15:01:11 -02:00
Heiner Kallweit 53df877717 [media] media: rc: constify struct proto_names
Declare struct proto_names and its member name as const.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-11-19 11:38:14 -02:00
Heiner Kallweit 9f0bf366d7 [media] media: rc: preparation for on-demand decoder module loading
Prepare on-demand decoder module loading by adding a module_name member
to struct proto_names and introducing the related load function.

After this patch of the series the decoder modules are still loaded
unconditionally.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-11-19 11:37:40 -02:00
Heiner Kallweit 4dc0e908a5 [media] media: rc-core: simplify logging in rc_register_device
Simplify the logging.

I had some doubts about using the elvis operator as it's GNU extension.
However GNU extensions are explicitely allowed and this operator is
used at several places in the kernel code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-11-19 09:38:19 -02:00
Russell King 2ff56fadd9 [media] rc: allow rc modules to be loaded if rc-main is not a module
rc-main mistakenly uses #ifdef MODULE to determine whether it should
load the rc keymap modules.  This symbol is only defined if rc-main
is being built as a module itself, and bears no relation to whether
the rc keymaps are modules.

Fix this to use CONFIG_MODULES instead.

Fixes: 631493ecac ("[media] rc-core: merge rc-map.c into rc-main.c")

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-11-19 08:41:06 -02:00
Linus Torvalds 9cfcc658da media updates for v4.3-rc1
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJV6ifEAAoJEAhfPr2O5OEVn5kP/i2jM1tWcmV/ZEBKGAN0jpRk
 5Y/Q+rnXvOpIJSQC3dEkweoBymVMclSgSB/wFSWCZtp5MaB8KrH4/2uc3UvolF91
 7bqXt+fCUacMbDQyaabMCR83mz9tdOJLd5sf0ABqBgXGfwh5uXmBPaYBzmcYvKcW
 4D89MFUpaFDPARTs9rdpVyr0aPRU4GcN0R3snRO9Ly+cQnyV/RxPf9NqCgnI+yPq
 +NvA9ScUBcBt62piSIGR4egcAR8boxYC+0r57340S21/JVMvsHQ3ok9b1aT8/rtd
 Yl24FkcKrRV0ShN5S1RmW5DLH/HRGabuMjkiEz9xq52FGD2sQQda0At58dWivsa4
 XYdxS9UUfb9Z+qyeMdmCl1MUFRrV2G4H6VItP+GKyT3UZLEDcLl6hBg3SkyWxWB4
 CSO5WuRThiIB86OVcIaREftzqDy5HdvH3ZKRD7QrW0DItGVjQwV5j6gvwqO9OEXs
 99BnSohyKwUBonumE2ZtFGGhIwIomllrMSqg991bPH9+13bg/rPxUqntkPrVap/9
 cV3qKO8ZFrz5UInBnR1U83l60ZK7rV4G6AVMSMKpM9XVK9TDKryAUN9Mhj5XWRH8
 hbma89TQVdhdrITtt27uzj8F622cvZvxd1BqDBR8DjKVvtv/E2GPzJrAj7GHe3/o
 NgzP5fF6X2Si32GNb7J8
 =cIed
 -----END PGP SIGNATURE-----

Merge tag 'media/v4.3-1' of 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-09-05 18:21:14 -07:00
David Härdeman 3a03b86fdc Revert "[media] rc: rc-core: Add support for encode_wakeup drivers"
This reverts commit 0d830b2d12.

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-19 07:03:00 -03:00
David Härdeman dd6ff6a05b [media] rc-core: improve the lirc protocol reporting
Commit 275ddb40bc removed the lirc
"protocol" but kept backwards compatibility by always listing
the protocol as present and enabled. This patch further improves
the logic by only listing the protocol if the lirc module is loaded
(or if lirc is builtin).

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-08-11 13:18:13 -03:00
David Härdeman 275ddb40bc [media] rc-core: remove the LIRC "protocol"
The LIRC protocol was always a bad fit and if we're ever going to expose
protocol numbers in a user-space API, it'd be better to get rid of the
LIRC "protocol" first.

The sysfs API is kept backwards compatible by always listing the lirc
protocol as present and enabled.

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-07-06 08:26:15 -03:00
David Härdeman fcb1309786 [media] rc-core: use an IDA rather than a bitmap
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>
2015-07-06 08:26:15 -03:00
David Härdeman a66b0c41ad [media] rc-core: fix remove uevent generation
The input_dev is already gone when the rc device is being unregistered
so checking for its presence only means that no remove uevent will be
generated.

Cc: stable@kernel.org
Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-07-06 08:26:14 -03:00
James Hogan 0d830b2d12 [media] rc: rc-core: Add support for encode_wakeup drivers
Add support in rc-core for drivers which implement the wakeup scancode
filter by encoding the scancode using the raw IR encoders. This is by
way of rc_dev::encode_wakeup which should be set to true to make the
allowed wakeup protocols the same as the set of raw IR encoders.

As well as updating the sysfs interface to know which wakeup protocols
are allowed for encode_wakeup drivers, also ensure that the IR
decoders/encoders are loaded when an encode_wakeup driver is registered.

Signed-off-by: James Hogan <james@albanarts.com>
Signed-off-by: Antti Seppälä <a.seppala@gmail.com>
Cc: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-05-14 14:34:53 -03:00
Mauro Carvalho Chehab 81b7d14e32 [media] rc: fix bad indenting
drivers/media/rc/rc-main.c:749 rc_close() warn: inconsistent indenting

There's an extra space there.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 13:13:36 -03:00
James Hogan 983c5bd26b [media] rc-main: Re-apply filter for no-op protocol change
Since commit da6e162d6a ("[media] rc-core: simplify sysfs code"), when
the IR protocol is set using the sysfs interface to the same set of
protocols that are already set, store_protocols() does not refresh the
scancode filter with the new protocol, even if it has already called the
change_protocol() callback successfully. This results in the filter
being disabled in the hardware and not re-enabled until the filter is
set again using sysfs.

Fix in store_protocols() by still re-applying the filter whenever the
change_protocol() driver callback succeeded.

The problem can be reproduced with the img-ir driver by setting a
filter, and then setting the protocol to the same protocol that is
already set:
$ echo nec > protocols
$ echo 0xffff > filter_mask
$ echo nec > protocols

After this, messages which don't match the filter were still being
received.

Fixes: da6e162d6a ("[media] rc-core: simplify sysfs code")

Reported-by: Sifan Naeem <sifan.naeem@imgtec.com>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: David Härdeman <david@hardeman.nu>
Cc: <stable@vger.kernel.org> # v3.17+
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-12-23 16:21:45 -02:00
Markus Elfring 3dd94f00f0 [media] rc: Deletion of unnecessary checks before two function calls
The functions input_free_device() and rc_close() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-11-25 13:30:38 -02:00
Mauro Carvalho Chehab 47a09af68b Merge tag 'v3.18-rc4' into patchwork
Needed due to some important regression fixes at RC core.

* commit 'v3.18-rc4': (587 commits)
  Linux 3.18-rc4
  ARM: dts: zynq: Enable PL clocks for Parallella
  tiny: rename ENABLE_DEV_COREDUMP to ALLOW_DEV_COREDUMP
  tiny: reverse logic for DISABLE_DEV_COREDUMP
  i2c: core: Dispose OF IRQ mapping at client removal time
  i2c: at91: don't account as iowait
  i2c: remove FSF address
  USB: Update default usb-storage delay_use value in kernel-parameters.txt
  sysfs: driver core: Fix glue dir race condition by gdp_mutex
  MIPS: Fix build with binutils 2.24.51+
  xfs: track bulkstat progress by agino
  xfs: bulkstat error handling is broken
  xfs: bulkstat main loop logic is a mess
  xfs: bulkstat chunk-formatter has issues
  xfs: bulkstat chunk formatting cursor is broken
  xfs: bulkstat btree walk doesn't terminate
  mm: Fix comment before truncate_setsize()
  USB: cdc-acm: add quirk for control-line state requests
  tty: Fix pty master poll() after slave closes v2
  MIPS: R3000: Fix debug output for Virtual page number
  ...

Conflicts:
	drivers/media/rc/rc-main.c
2014-11-11 08:37:35 -02:00
Mauro Carvalho Chehab fb9b1641ba [media] rc-main: Fix rc_type handling
As reported by smatch:
	drivers/media/rc/rc-main.c:1426 rc_register_device() warn: should '1 << rc_map->rc_type' be a 64 bit type?

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-11-05 09:28:01 -02:00
Tomas Melin 37fa8716e2 [media] rc-main: fix lockdep splash for rc-main
lockdep reports a potential circular dependecy deadlock when registering input device.

Unlock mutex rc_dev->lock prior to calling ir_raw_event_register to avoid the circular
dependency since that function also calls input_register_device and rc_open.

 ======================================================
 [ INFO: possible circular locking dependency detected ]
 3.17.0-rc7+ #24 Not tainted
 -------------------------------------------------------
 modprobe/647 is trying to acquire lock:
  (input_mutex){+.+.+.}, at: [<ffffffff812ed81c>] input_register_device+0x2ba/0x381

 but task is already holding lock:
  (ir_raw_handler_lock){+.+.+.}, at: [<ffffffff813186ed>] ir_raw_event_register+0x102/0x190

 which lock already depends on the new lock.

[cut text]

 other info that might help us debug this:

 Chain exists of:
   input_mutex --> &dev->lock --> ir_raw_handler_lock

  Possible unsafe locking scenario:

        CPU0                    CPU1
        ----                    ----
   lock(ir_raw_handler_lock);
                                lock(&dev->lock);
                                lock(ir_raw_handler_lock);
   lock(input_mutex);

  *** DEADLOCK ***

 4 locks held by modprobe/647:
  #0:  (&dev->mutex){......}, at: [<ffffffff812d19f3>] device_lock+0xf/0x11
  #1:  (&dev->mutex){......}, at: [<ffffffff812d19f3>] device_lock+0xf/0x11
  #2:  (&dev->lock){+.+.+.}, at: [<ffffffff81317fff>] rc_register_device+0x55d/0x58a
  #3:  (ir_raw_handler_lock){+.+.+.}, at: [<ffffffff813186ed>] ir_raw_event_register+0x102/0x190

 stack backtrace:
 CPU: 0 PID: 647 Comm: modprobe Not tainted 3.17.0-rc7+ #24

 Call Trace:
  [<ffffffff81489d6a>] dump_stack+0x46/0x58
  [<ffffffff81487699>] print_circular_bug+0x1f8/0x209
  [<ffffffff81074353>] __lock_acquire+0xb54/0xeda
  [<ffffffff81080f17>] ? console_unlock+0x34d/0x399
  [<ffffffff81074c01>] lock_acquire+0xd9/0x111
  [<ffffffff812ed81c>] ? input_register_device+0x2ba/0x381
  [<ffffffff8148e650>] mutex_lock_interruptible_nested+0x57/0x381
  [<ffffffff812ed81c>] ? input_register_device+0x2ba/0x381
  [<ffffffff81124e03>] ? kfree+0x7c/0x96
  [<ffffffff812ed81c>] ? input_register_device+0x2ba/0x381
  [<ffffffff81072531>] ? trace_hardirqs_on+0xd/0xf
  [<ffffffff812ed81c>] input_register_device+0x2ba/0x381
  [<ffffffff8131a537>] ir_mce_kbd_register+0x109/0x139
  [<ffffffff81318728>] ir_raw_event_register+0x13d/0x190
  [<ffffffff81317e40>] rc_register_device+0x39e/0x58a
  [<ffffffff81072531>] ? trace_hardirqs_on+0xd/0xf
  [<ffffffffa00cf2e3>] nvt_probe+0x5ad/0xd52 [nuvoton_cir]
  [<ffffffffa00ced36>] ? nvt_resume+0x80/0x80 [nuvoton_cir]
  [<ffffffff81296003>] pnp_device_probe+0x8c/0xa9
  [<ffffffff812d1b94>] ? driver_sysfs_add+0x6e/0x93
  [<ffffffff812d203a>] driver_probe_device+0xa1/0x1e3
  [<ffffffff812d217c>] ? driver_probe_device+0x1e3/0x1e3
  [<ffffffff812d21ca>] __driver_attach+0x4e/0x6f
  [<ffffffff812d075b>] bus_for_each_dev+0x5a/0x8c
  [<ffffffff812d1b24>] driver_attach+0x19/0x1b
  [<ffffffff812d1879>] bus_add_driver+0xf1/0x1d6
  [<ffffffff812d2817>] driver_register+0x87/0xbe
  [<ffffffffa0120000>] ? 0xffffffffa0120000
  [<ffffffff81295da4>] pnp_register_driver+0x1c/0x1e
  [<ffffffffa0120010>] nvt_init+0x10/0x1000 [nuvoton_cir]
  [<ffffffff8100030e>] do_one_initcall+0xea/0x18c
  [<ffffffff8111497f>] ? __vunmap+0x9d/0xc7
  [<ffffffff810a3ca1>] load_module+0x1c21/0x1f2c
  [<ffffffff810a0bce>] ? show_initstate+0x44/0x44
  [<ffffffff810a404e>] SyS_init_module+0xa2/0xb1
  [<ffffffff81490ed2>] system_call_fastpath+0x16/0x1b

Signed-off-by: Tomas Melin <tomas.melin@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-10-30 16:57:43 -02:00
Tomas Melin 14edb59333 [media] rc-core: fix protocol_change regression in ir_raw_event_register
IR receiver using nuvoton-cir and lirc required additional configuration
steps after upgrade from kernel 3.16 to 3.17-rcX. Bisected regression to
commit da6e162d6a ("[media] rc-core:
simplify sysfs code").

The regression comes from adding function change_protocol in ir-raw.c.
It changes behaviour so that only the protocol enabled by driver's
map_name will be active after registration. This breaks user space
behaviour, lirc does not get key press signals anymore.

Enable lirc protocol by default for ir raw decoders to restore original
behaviour.

Cc: stable@vger.kernel.org # for v3.17
Signed-off-by: Tomas Melin <tomas.melin@iki.fi>
Acked-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-10-30 09:09:28 -02:00
Mauro Carvalho Chehab d24b69fc6b [media] rc-main: allow raw protocol drivers to restrict the allowed protos
On some hardware (au0828/au8522), the hardware is broken with
regards to the initial pulse detection. So, the driver needs to
produce a fake start pulse. That limits the acceptable protocols,
as it is not possible to produce a fake pulse that would cover
all supported protocols.

So, allow the driver to explicitly set the allowed protocols.

If the driver doesn't specify, keep the old behavior.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-07-30 15:45:48 -03:00
Marcel J.E. Mol 1dee9b59d6 [media] rc: Add support for decoding XMP protocol
This protocol is found on Dreambox remotes

[m.chehab@samsung.com: CodingStyle fixes and conflict fix]
Signed-off-by: Marcel Mol <marcel@mesa.nl>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-07-26 19:38:04 -03:00
David Härdeman 9d2f1d3cde [media] rc-core: rename dev->scanmask to dev->scancode_mask
We already have dev->scancode_filter and dev->scancode_wakeup_filter
so rename dev->scanmask to dev->scancode_mask for consistency.

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-07-25 19:10:43 -03:00
David Härdeman c5540fbb9d [media] rc-core: remove protocol arrays
The basic API of rc-core used to be:

	dev = rc_allocate_device();
	dev->x = a;
	dev->y = b;
	dev->z = c;
	rc_register_device();

which is a pretty common pattern in the kernel, after the introduction of
protocol arrays the API looks something like:

	dev = rc_allocate_device();
	dev->x = a;
	rc_set_allowed_protocols(dev, RC_BIT_X);
	dev->z = c;
	rc_register_device();

There's no real need for the protocols to be an array, so change it
back to be consistent (and in preparation for the following patches).

[m.chehab@samsung.com: added missing changes at some files]
Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-07-25 19:10:43 -03:00
David Härdeman da6e162d6a [media] rc-core: simplify sysfs code
Simplify and cleanup the sysfs code a bit.

[m.chehab@samsung.com: rebased and fixed a CodingStyle issue]
Signed-off-by: David Härdeman <david@hardeman.nu>

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-07-23 22:01:35 -03:00
David Härdeman 120703f9eb [media] rc-core: document the protocol type
Right now the protocol information is not preserved, rc-core gets handed a
scancode but has no idea which protocol it corresponds to.

This patch (which required reading through the source/keymap for all drivers,
not fun) makes the protocol information explicit which is important
documentation and makes it easier to e.g. support multiple protocols with one
decoder (think rc5 and rc-streamzap). The information isn't used yet so there
should be no functional changes.

[m.chehab@samsung.com: rebased, added cxusb and removed bad whitespacing]
Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-07-23 21:50:48 -03:00
David Härdeman 99b0f3c96c [media] rc-core: remove generic scancode filter
The generic scancode filtering has questionable value and makes it
impossible to determine from userspace if there is an actual
scancode hw filter present or not.

So revert the generic parts.

Based on a patch from James Hogan <james.hogan@imgtec.com>, but this
version also makes sure that only the valid sysfs files are created
in the first place.

Signed-off-by: David Härdeman <david@hardeman.nu>
Acked-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-04-06 11:30:29 -03:00
David Härdeman 23c843b5eb [media] rc-core: split dev->s_filter
Overloading dev->s_filter to do two different functions (set wakeup filters
and generic hardware filters) makes it impossible to tell what the
hardware actually supports, so create a separate dev->s_wakeup_filter and
make the distinction explicit.

Signed-off-by: David Härdeman <david@hardeman.nu>
Acked-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-04-06 11:30:25 -03:00
Kees Cook 8ea5488a91 [media] media: rc-core: use %s in rc_map_get() module load
rc_map_get() takes a single string literal for the module to load,
so make sure it cannot be used as a format string in the call to
request_module().

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-13 11:32:28 -03:00
James Hogan 262912335c [media] rc-main: fix missing unlock if no devno left
While playing with make coccicheck I noticed this message:
drivers/media/rc/rc-main.c:1245:3-9: preceding lock on line 1238

It was introduced by commit 587d1b06e0 ([media] rc-core: reuse device
numbers) which returns -ENOMEM after a mutex_lock without first
unlocking it when there are no more device numbers left. The added code
doesn't depend on the device lock, so move it before the lock is taken.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11 15:56:32 -03:00
James Hogan 6bea25af14 [media] rc-main: automatically refresh filter on protocol change
When either of the normal or wakeup filter protocols are changed,
refresh the corresponding scancode filter, i.e. try and set the same
scancode filter with the new protocol. If that fails clear the filter
instead.

If no protocol was selected the filter is just cleared, and if no
s_filter callback exists the filter is left unmodified.

Similarly clear the filter mask when the filter is set if no protocol is
currently selected.

This simplifies driver code which no longer has to explicitly worry
about modifying the filter on a protocol change. This also allows the
change_wakeup_protocol callback to be omitted entirely if there is only
a single available wakeup protocol at a time, since selecting no
protocol will automatically clear the wakeup filter, disabling wakeup.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Antti Seppälä <a.seppala@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11 13:29:52 -03:00
James Hogan ab88c66dea [media] rc: add wakeup_protocols sysfs file
Add a wakeup_protocols sysfs file which controls the new
rc_dev::enabled_protocols[RC_FILTER_WAKEUP], which is the mask of
protocols that are used for the wakeup filter.

A new RC driver callback change_wakeup_protocol() is called to change
the wakeup protocol mask.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Antti Seppälä <a.seppala@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11 13:28:20 -03:00
James Hogan acff5f2473 [media] rc: add allowed/enabled wakeup protocol masks
Only a single allowed and enabled protocol mask currently exists in
struct rc_dev, however to support a separate wakeup filter protocol two
of each are needed, ideally as an array.

Therefore make both rc_dev::allowed_protos and rc_dev::enabled_protocols
arrays, update all users to reference the first element
(RC_FILTER_NORMAL), and add a couple more helper functions for drivers
to use for setting the allowed and enabled wakeup protocols.

We also rename allowed_protos to allowed_protocols while we're at it,
which is more consistent with enabled_protocols.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Antti Seppälä <a.seppala@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11 13:25:49 -03:00
James Hogan b8c7d91508 [media] rc-main: add generic scancode filtering
Add generic scancode filtering of RC input events, and fall back to
permitting any RC_FILTER_NORMAL scancode filter to be set if no s_filter
callback exists. This allows raw IR decoder events to be filtered, and
potentially allows hardware decoders to set looser filters and rely on
generic code to filter out the corner cases.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Antti Seppälä <a.seppala@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11 13:21:40 -03:00
James Hogan 7b802ce7e8 [media] rc-main: store_filter: pass errors to userland
Propagate errors returned by drivers from the s_filter callback back to
userland when updating scancode filters. This allows userland to see
when the filter couldn't be updated, usually because it's not a valid
filter for the hardware.

Previously the filter was being updated conditionally on success of
s_filter, but the write always reported success back to userland.

Reported-by: Antti Seppälä <a.seppala@gmail.com>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-11 12:13:23 -03:00
Mauro Carvalho Chehab 37e59f876b [media, edac] Change my email address
There are several left overs with my old email address.
Remove their occurrences and add myself at CREDITS, to
allow people to be able to reach me on my new addresses.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-02-07 08:03:07 -02:00
James Hogan 00942d1a1b [media] media: rc: add sysfs scancode filtering interface
Add and document a generic sysfs based scancode filtering interface for
making use of IR data matching hardware to filter out uninteresting
scancodes. Two filters exist, one for normal operation and one for
filtering scancodes which are permitted to wake the system from suspend.

The following files are added to /sys/class/rc/rc?/:
 - filter: normal scancode filter value
 - filter_mask: normal scancode filter mask
 - wakeup_filter: wakeup scancode filter value
 - wakeup_filter_mask: wakeup scancode filter mask

A new s_filter() driver callback is added which must arrange for the
specified filter to be applied at the right time. Drivers can convert
the scancode filter into a raw IR data filter, which can be applied
immediately or later (for wake up filters).

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: linux-media@vger.kernel.org
Cc: Rob Landley <rob@landley.net>
Cc: linux-doc@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-02-06 09:18:57 -02:00
James Hogan 38f2a21435 [media] media: rc: add Sharp infrared protocol
Add Sharp infrared protocol constants RC_TYPE_SHARP and RC_BIT_SHARP.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-02-04 13:11:52 -02:00
James Hogan 70a2f9120f [media] media: rc: only turn on LED if keypress generated
Since v3.12, specifically 153a60bb0f ([media] rc: add feedback led
trigger for rc keypresses), an LED trigger is activated on IR keydown
whether or not a keypress is generated (i.e. even if there's no matching
keycode). However the repeat and keyup logic isn't used unless there is
a keypress, which results in non-keypress keydown events turning on the
LED and not turning it off again.

On the assumption that the intent was for the LED only to light up on
valid key presses (you probably don't want it lighting up for the wrong
remote control for example), move the led_trigger_event() call inside
the keycode check.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Acked-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-02-04 13:09:00 -02:00
Fengguang Wu 692a228e9a [media] rc-core: ir_core_dev_number can be static
Fix sparse warning:
	drivers/media/rc/rc-main.c:27:1: sparse: symbol 'ir_core_dev_number' was not declared. Should it be static?

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-02-04 13:04:19 -02:00
Mauro Carvalho Chehab 587d1b06e0 [media] rc-core: reuse device numbers
Before changeset d8b4b5822f, the remote controller device numbers
were released when the device were unregistered. That helped to maintain
some sanity, as, when USB devices are replugged, the remote controller
would get the same number.

Restore the same behaviour.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-01-15 11:46:37 -02:00
Juergen Lock f02dcdd178 [media] media: rc: rdev->open or rdev->close can be NULL
At least technisat-usb2.c doesn't set these...

Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2013-08-23 05:41:23 -03:00
Sean Young 153a60bb0f [media] rc: add feedback led trigger for rc keypresses
Many devices with an ir receiver also have a feedback led. Add the
led trigger to support this.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2013-08-22 11:46:46 -03:00
Srinivas Kandagatla 8b2ff32049 [media] media: rc: Add rc_open/close and use count to rc_dev
This patch adds user count to rc_dev structure, the reason to add this
new member is to allow other code like lirc to open rc device directly.
In the existing code, rc device is only opened by input subsystem which
works ok if we have any input drivers to match. But in case like lirc
where there will be no input driver, rc device will be never opened.
Having this user count variable will be usefull to allow rc device to be
opened from code other than rc-main.
This patch also adds rc_open and rc_close functions for other drivers
like lirc to open and close rc devices. This functions safely increment
and decrement the user count. Other driver wanting to open rc device
should call rc_open and rc_close, rather than directly modifying the
rc_dev structure.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2013-07-31 16:28:01 -03:00
David Härdeman 9719afae5e [media] rc-core: don't treat dev->rc_map.rc_type as a bitmap
store_protocols() treats dev->rc_map.rc_type as a bitmap which is wrong for
two reasons. First of all, it is pretty bogus to change the protocol type of
the keymap just because the hardware has been asked to decode a different
protocol.
Second, dev->rc_map.rc_type is an enum (i.e. a single protocol) as pointed
out by James Hogan <james.hogan@imgtec.com>.
Fix both issues by introducing a separate enabled_protocols member to
struct rc_dev.

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-23 11:25:54 -03:00
David Härdeman 40fc5325e1 [media] rc-core: rename ir_input_class to rc_class
The name is already misleading and will be more so in the future as the
connection to the input subsystem is obscured away further.

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-19 15:26:59 -03:00
David Härdeman e76d4ce49f [media] rc-core: initialize rc-core earlier if built-in
rc-core is a subsystem so it should be registered earlier if built into the
kernel.

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-19 15:26:37 -03:00
Dan Carpenter afe5624b14 [media] rc: unlock on error in store_protocols()
This error path is missing the unlock.

[mchehab@redhat.com: Merged two equal patches into one]
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Acked-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-27 13:59:02 -02:00
Dan Carpenter 30ebc5e44d [media] rc: unlock on error in show_protocols()
We recently introduced a new return -ENODEV in this function but we need
to unlock before returning.

[mchehab@redhat.com: found two patches with the same fix. Merged SOB's/acks into one patch]
Acked-by: Herton R. Krzesinski <herton.krzesinski@canonical.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable@vger.kernel.org
Signed-off-by: Douglas Bagnall <douglas@paradise.net.nz>

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-26 12:02:13 -02:00
David Härdeman c003ab1bed [media] rc-core: add separate defines for protocol bitmaps and numbers
The RC_TYPE_* defines are currently used both where a single protocol is
expected and where a bitmap of protocols is expected.

Functions like rc_keydown() and functions which add/remove entries to the
keytable want a single protocol. Future userspace APIs would also
benefit from numeric protocols (rather than bitmap ones). Keytables are
smaller if they can use a small(ish) integer rather than a bitmap.

Other functions or struct members (e.g. allowed_protos,
enabled_protocols, etc) accept multiple protocols and need a bitmap.

Using different types reduces the risk of programmer error. Using a
protocol enum whereever possible also makes for a more future-proof
user-space API as we don't need to worry about a sufficient number of
bits being available (e.g. in structs used for ioctl() calls).

The use of both a number and a corresponding bit is dalso one in e.g.
the input subsystem as well (see all the references to set/clear bit when
changing keytables for example).

This patch separate the different usages in preparation for
upcoming patches.

Where a single protocol is expected, enum rc_type is used; where one or more
protocol(s) are expected, something like u64 is used.

The patch has been rewritten so that the format of the sysfs "protocols"
file is no longer altered (at the loss of some detail). The file itself
should probably be deprecated in the future though.

Signed-off-by: David Härdeman <david@hardeman.nu>
Cc: Andy Walls <awalls@md.metrocast.net>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>
Cc: Antti Palosaari <crope@iki.fi>
Cc: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-10-27 11:49:51 -02:00
Douglas Bagnall 720bb6436f [media] Avoid sysfs oops when an rc_dev's raw device is absent
For some reason, when the lirc daemon learns that a usb remote control
has been unplugged, it wants to read the sysfs attributes of the
disappearing device. This is useful for uncovering transient
inconsistencies, but less so for keeping the system running when such
inconsistencies exist.

Under some circumstances (like every time I unplug my dvb stick from
my laptop), lirc catches an rc_dev whose raw event handler has been
removed (presumably by ir_raw_event_unregister), and proceeds to
interrogate the raw protocols supported by the NULL pointer.

This patch avoids the NULL dereference, and ignores the issue of how
this state of affairs came about in the first place.

Version 2 incorporates changes recommended by Mauro Carvalho Chehab
(-ENODEV instead of -EINVAL, and a signed-off-by).

Signed-off-by: Douglas Bagnall <douglas@paradise.net.nz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-07-30 21:15:32 -03:00