Commit Graph

614019 Commits

Author SHA1 Message Date
Sean Young
23d520c7b6 UPSTREAM: media: lirc: implement scancode sending
This introduces a new lirc mode: scancode. Any device which can send raw IR
can now also send scancodes.

int main()
{
	int mode, fd = open("/dev/lirc0", O_RDWR);

        mode = LIRC_MODE_SCANCODE;
	if (ioctl(fd, LIRC_SET_SEND_MODE, &mode)) {
		// kernel too old or lirc does not support transmit
	}
	struct lirc_scancode scancode = {
		.scancode = 0x1e3d,
		.rc_proto = RC_PROTO_RC5,
	};
	write(fd, &scancode, sizeof(scancode));
	close(fd);
}

The other fields of lirc_scancode must be set to 0.

Note that toggle (rc5, rc6) and repeats (nec) are not implemented. Nor is
there a method for holding down a key for a period.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 9b6192589b)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:24 +08:00
Sean Young
399617ff19 UPSTREAM: media: lirc: remove LIRCCODE and LIRC_GET_LENGTH
LIRCCODE is a lirc mode where a driver produces driver-dependent
codes for receive and transmit. No driver uses this any more. The
LIRC_GET_LENGTH ioctl was used for this mode only.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 4e3cd001fd)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:24 +08:00
Sean Young
9893fd05e5 UPSTREAM: media: rc: partial revert of "media: rc: per-protocol repeat period"
Since commit d57ea877af ("media: rc: per-protocol repeat period"), most
IR protocols have a lower keyup timeout. This causes problems on the
ite-cir, which has default IR timeout of 200ms.

Since the IR decoders read the trailing space, with a IR timeout of 200ms,
the last keydown will have at least a delay of 200ms. This is more than
the protocol timeout of e.g. rc-6 (which is 164ms). As a result the last
IR will be interpreted as a new keydown event, and we get two keypresses.

Revert the protocol timeout to 250ms, except for cec which needs a timeout
of 550ms.

Fixes: d57ea877af ("media: rc: per-protocol repeat period")

Cc: <stable@vger.kernel.org> # 4.14
Reported-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Sean Young <sean@mess.org>
Tested-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 67f0f15ad5)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:24 +08:00
Sean Young
28d6842922 UPSTREAM: media: rc: pwm-ir-tx needs OF
Without device tree, there is no way to use this driver.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 2d726aaab2)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:23 +08:00
Sean Young
538d59085f UPSTREAM: media: rc: gpio-ir-tx does not work without devicetree or gpiolib
If the kernel is built without device tree, this driver cannot be
used and without gpiolib it cannot control any gpio pin.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 5288879390)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:23 +08:00
Sean Young
623cac3bcb UPSTREAM: media: rc: nec decoder should not send both repeat and keycode
When receiving an nec repeat, rc_repeat() is called and then rc_keydown()
with the last decoded scancode. That last call is redundant.

Fixes: 265a2988d2 ("media: rc-core: consistent use of rc_repeat()")

Cc: <stable@vger.kernel.org> # v4.14
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 829bbf2688)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:23 +08:00
David Härdeman
77425ec5d0 UPSTREAM: media: lirc_dev: remove min_timeout and max_timeout
There are no users of this functionality (ir-lirc-codec.c has its own
implementation and lirc_zilog.c doesn't use it) so remove it.

This only affects users of the lirc kapi, not rc-core drivers.

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>
(cherry picked from commit 2265425fd9)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:23 +08:00
Ladislav Michl
ea1de491d6 UPSTREAM: [media] media: rc: fix gpio-ir-receiver build failure
The 0-day robot reports:

   drivers/media/rc/gpio-ir-recv.c: In function 'gpio_ir_recv_irq':
>> drivers/media/rc/gpio-ir-recv.c:38:8: error: implicit declaration of function 'gpiod_get_value' [-Werror=implicit-function-declaration]

Fixes: eed008e605 ("[media] media: rc: gpio-ir-recv: use gpiolib API")

For some reason only partial patch was applied. Also include
gpio/consumer.h otherwise compile test fails.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Acked-by: Sean Young <sean@mess.org>
(cherry picked from commit c130107721)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:22 +08:00
Marc Gonzalez
22ad50e3ef UPSTREAM: [media] media: rc: Delete duplicate debug message
ir_setkeytable() and ir_create_table() print the same debug message.
Delete the one in ir_setkeytable()

Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit d7a6795b1d)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:22 +08:00
Thomas Meyer
b830c29acb UPSTREAM: [media] media: rc: Use bsearch library function
Replace self coded binary search, by existing library version.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 8ca01d4f95)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:22 +08:00
Ladislav Michl
6c29e901de UPSTREAM: [media] media: rc: gpio-ir-recv: use gpiolib API
Gpiolib API is preferred way to access gpios.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit eed008e605)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:22 +08:00
Ladislav Michl
6d6f379819 UPSTREAM: [media] media: rc: gpio-ir-recv: remove gpio_ir_recv_platform_data
gpio_ir_recv_platform_data are not used anywhere in kernel tree,
so remove it.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 5c95878f61)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>

 Conflicts:
	drivers/media/rc/gpio-ir-recv.c
2018-12-10 20:36:21 +08:00
Ladislav Michl
a5b9babec2 UPSTREAM: [media] media: rc: gpio-ir-recv: use KBUILD_MODNAME
There already is standard macro providing driver name, use it.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 916d1c9fd4)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:21 +08:00
Ladislav Michl
6144201075 UPSTREAM: [media] media: rc: gpio-ir-recv: use devm_request_irq
Use of devm_request_irq simplifies error unwinding and as
free_irq was the last user of driver remove function,
remove it too.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 1a2a60b1af)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:21 +08:00
Ladislav Michl
e07d5a82d6 UPSTREAM: [media] media: rc: gpio-ir-recv: do not allow threaded interrupt handler
Requesting any context irq is not actually great idea since threaded
interrupt handler is run at too unpredictable time which turns
timing information wrong. Fix it by requesting regular interrupt.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 375929f9f4)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:21 +08:00
Ladislav Michl
746af9ae16 UPSTREAM: [media] media: rc: gpio-ir-recv: use devm_rc_register_device
Use of devm_rc_register_device simplifies error unwinding.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 52ea799107)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:21 +08:00
Ladislav Michl
315cfb4957 UPSTREAM: [media] media: rc: gpio-ir-recv: use devm_gpio_request_one
Use of devm_gpio_request_one simplifies error unwinding.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit fcca09edb9)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:21 +08:00
Ladislav Michl
e59f994f56 UPSTREAM: [media] media: rc: gpio-ir-recv: use devm_rc_allocate_device
Use of devm_rc_allocate_device simplifies error unwinding.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit f4940b563f)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:21 +08:00
Ladislav Michl
cdc4ee6569 UPSTREAM: [media] media: rc: gpio-ir-recv: use devm_kzalloc
Use of devm_kzalloc simplifies error unwinding.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 08d94274b8)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:21 +08:00
Ladislav Michl
2683388bfc UPSTREAM: [media] media: rc: gpio-ir-recv: use helper variable to access device info
Using explicit struct device variable makes code a bit more readable.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 94d40b2ff2)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:21 +08:00
Sean Young
c3ba568430 UPSTREAM: [media] media: rc: include device name in rc udev event
This name is also stored in the input's device name, but that
is not available in TX only hardware (no input device).

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit b9f407e31c)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:21 +08:00
Sean Young
34e21ec59f UPSTREAM: [media] media: rc: if protocols can't be changed, don't be writable
If the protocols of an rc device cannot be changed, ensure the sysfs
file is not writable.

This makes it possible to detect this from userspace, so ir-keytable
can deal with case without giving an error.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 6d75db305b)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:21 +08:00
Sean Young
f3fcf6c2e3 UPSTREAM: [media] media: rc: ensure that protocols are enabled for scancode drivers
rc scancode drivers without change_protocol should have all
protocols enabled at all time. This was only true for cec and
ir-kbd-i2c.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 831c4c81e8)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:21 +08:00
Bhumika Goyal
0f1f033030 UPSTREAM: [media] media: rc: make device_type const
Make this const as it is only stored in the type field of a device
structure, which is const.
Done using Coccinelle.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit f03f02f9d2)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:20 +08:00
David Härdeman
5dbc1afcf0 UPSTREAM: [media] media: lirc_dev: merge struct irctl into struct lirc_dev
The use of two separate structs (lirc_dev aka lirc_driver and irctl) makes
it much harder to follow the proper lifetime of the various structs and
necessitates hacks such as keeping a copy of struct lirc_dev inside
struct irctl.

Merging the two structs means that lirc_dev can properly manage the
lifetime of the resulting struct and simplifies the code at the same time.

[mchehab@s-opensource.com: fix merge conflict]
Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit b15e39379f)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:20 +08:00
David Härdeman
383df79f16 UPSTREAM: [media] media: lirc_dev: introduce lirc_allocate_device and lirc_free_device
Introduce two new functions so that the API for lirc_dev matches that
of the rc-core and input subsystems.

This means that lirc_dev structs are managed using the usual four
functions:

lirc_allocate_device
lirc_free_device
lirc_register_device
lirc_unregister_device

The functions are pretty simplistic at this point, later patches will put
more flesh on the bones of both.

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Sean Young <sean@mess.org>
(cherry picked from commit 6ecccc379b)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:20 +08:00
David Härdeman
836b902c28 UPSTREAM: [media] media: rename struct lirc_driver to struct lirc_dev
This is in preparation for the later patches which do away with
struct irctl entirely.

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 5ddc9c098d)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:20 +08:00
David Härdeman
3cecaddef9 UPSTREAM: [media] media: lirc_dev: use an IDA instead of an array to keep track of registered devices
Using the kernel-provided IDA simplifies the code and makes it possible
to remove the lirc_dev_lock mutex.

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 46c8f47711)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:20 +08:00
David Härdeman
d7978b7f41 UPSTREAM: [media] media: lirc_dev: sanitize locking
Use the irctl mutex for all device operations and only use lirc_dev_lock
to protect the irctls array. Also, make sure that the device is alive
early in each fops function before doing anything else.

Since this patch touches nearly every line where the irctl mutex is
taken/released, it also renames the mutex at the same time (the name
irctl_lock will be misleading once struct irctl goes away in later
patches).

[mchehab@s-opensource.com: fix a merge conflict]
Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 3381b779a7)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:20 +08:00
David Härdeman
6fe87b34ae UPSTREAM: [media] media: lirc_dev: change irctl->attached to be a boolean
The "attached" member of struct irctl is a boolean value, so let the code
reflect that.

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 3bce557236)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:20 +08:00
David Härdeman
e883d1aca1 UPSTREAM: [media] media: lirc_dev: make chunk_size and buffer_size mandatory
Make setting chunk_size and buffer_size mandatory for drivers which
expect lirc_dev to allocate the lirc_buffer (i.e. ir-lirc-codec) and
don't set them in lirc-zilog (which creates its own buffer).

Also remove an unnecessary copy of chunk_size in struct irctl (the
same information is already available from struct lirc_buffer).

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit b145ef94f6)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:20 +08:00
David Härdeman
6f62f1f22f UPSTREAM: [media] media: lirc_dev: make better use of file->private_data
By making better use of file->private_data in lirc_dev we can avoid
digging around in the irctls[] array, thereby simplifying the code.

External drivers need to use lirc_get_pdata() instead of mucking around
in file->private_data.

The newly introduced lirc_init_pdata() function isn't very elegant, but
it's a stopgap measure which can be removed once lirc_zilog is converted
to rc-core.

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 615cd3fe6c)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:20 +08:00
David Härdeman
29cf9e0f4b UPSTREAM: [media] media: lirc_dev: use cdev_device_add() helper function
Replace calls to cdev_add() and device_add() with the cdev_device_add()
helper function.

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit 0510d81081)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:20 +08:00
David Härdeman
949b870dca UPSTREAM: [media] media: lirc_dev: remove support for manually specifying minor number
All users of lirc_register_driver() uses dynamic minor allocation,
therefore we can remove the ability to explicitly request a given number.

This changes the function prototype of lirc_unregister_driver() to also
take a struct lirc_driver pointer as the sole argument.

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit c3c6dd750e)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>

 Conflicts:
	drivers/staging/media/lirc/lirc_zilog.c
2018-12-10 20:36:19 +08:00
David Härdeman
e152352354 UPSTREAM: [media] media: lirc_dev: clarify error handling
If an error is generated, it is more logical to error out ASAP.

Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
(cherry picked from commit de226ec8a6)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:19 +08:00
Sean Young
00615701b5 UPSTREAM: media: Revert "[media] lirc_dev: remove superfluous get/put_device() calls"
This reverts commit 5be2b76a9c.

Only when the lirc device is freed, should we drop our reference to
rc_dev, else we the rc_dev is freed to early. If userspace has
a file descriptor open during unplug, it goes bang.

==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x7bb/0x1e10
Read of size 8 at addr ffff8801d7d61ed0 by task ir-rec/2609

-snip-
 mutex_lock_nested+0x1b/0x20
 ? mutex_lock_nested+0x1b/0x20
 rc_close.part.6+0x20/0x60 [rc_core]
 rc_close+0x13/0x20 [rc_core]
 lirc_dev_fop_close+0x62/0xd0 [lirc_dev]
 __fput+0x236/0x410
 ? fput+0xb0/0xb0
 ? do_raw_spin_trylock+0x110/0x110
 ? set_rq_offline.part.70+0xa0/0xa0
 ____fput+0xe/0x10
 task_work_run+0x116/0x180
 ? task_work_cancel+0x170/0x170
 ? _raw_spin_unlock+0x27/0x40
 ? switch_task_namespaces+0x5f/0x90
 do_exit+0x68b/0xe80

Cc: stable@vger.kernel.org # For Kernel 4.13
Fixes: 5be2b76a9c ("[media] lirc_dev: remove superfluous get/put_device() calls")
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit a607f51e5a)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:19 +08:00
Sean Young
9b1d0f5a29 UPSTREAM: media: serial_ir: fix tx timing calculation on 32-bit
Move the calculation to where it is needed, so the result doesn't
need to be stored in the device struct.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit fce4b371fe)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:19 +08:00
Sean Young
23c49dc84d UPSTREAM: media: rc: gpio-ir-tx: use ktime accessor functions
Prefer using accessor functions so we are not dependent on the ktime_t
type.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 766cbb3189)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:18 +08:00
Jasmin Jessich
b06b2e68c5 UPSTREAM: media: rc: use ktime accessor functions
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>
(cherry picked from commit 800846c4d9)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:18 +08:00
Sean Young
6f41c681fa UPSTREAM: media: rc: rename RC_TYPE_* to RC_PROTO_* and RC_BIT_* to RC_PROTO_BIT_*
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>
(cherry picked from commit 6d741bfed5)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>

 Conflicts:
	drivers/media/cec/cec-adap.c
	drivers/media/cec/cec-core.c
	drivers/media/pci/cx23885/cx23885-input.c
	drivers/media/pci/cx88/cx88-input.c
	drivers/media/pci/saa7134/saa7134-input.c
	drivers/media/rc/imon.c
	drivers/media/rc/keymaps/rc-cec.c
	drivers/media/rc/keymaps/rc-d680-dmb.c
	drivers/media/rc/keymaps/rc-dtt200u.c
	drivers/media/rc/keymaps/rc-dvico-mce.c
	drivers/media/rc/keymaps/rc-dvico-portable.c
	drivers/media/rc/keymaps/rc-zx-irdec.c
	drivers/media/rc/meson-ir.c
	drivers/media/rc/mtk-cir.c
	drivers/media/rc/nuvoton-cir.c
	drivers/media/rc/redrat3.c
	drivers/media/rc/sir_ir.c
	drivers/media/rc/winbond-cir.c
	drivers/media/rc/zx-irdec.c
	drivers/media/usb/dvb-usb/cxusb.c
	drivers/media/usb/dvb-usb/dib0700_devices.c
	drivers/media/usb/dvb-usb/dtt200u.c
	drivers/media/usb/em28xx/em28xx-input.c
	drivers/media/usb/tm6000/tm6000-input.c
2018-12-10 20:36:18 +08:00
Sean Young
bee30dffae UPSTREAM: media: rc: mce kbd decoder not needed for IR TX drivers
Without this patch, an input device is created which is not necessary.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 219cb08ac0)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:17 +08:00
Sean Young
1570846906 UPSTREAM: [media] rc: Hauppauge z8f0811 can decode RC6
The hardware does not decode the 16, 20 or 24 bit variety.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 00bb820755)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:17 +08:00
Sean Young
7bc3853a1e UPSTREAM: media: rc: per-protocol repeat period
CEC needs a keypress timeout of 550ms, which is too high for the IR
protocols. Also fill in known repeat times, with 50ms error margin.

Also, combine all protocol data into one structure.

Signed-off-by: Sean Young <sean@mess.org>
Suggested-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit d57ea877af)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:17 +08:00
Sean Young
64ecc586a3 UPSTREAM: media: rc: ensure we do not read out of bounds
If rc_validate_filter() is called for CEC or XMP, then we would read
beyond the end of the array.

Suggested-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 2168b416c8)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:17 +08:00
Sean Young
458c747605 UPSTREAM: media: rc: simplify ir_raw_event_store_edge()
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: 3f5c4c7332 ("[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>
(cherry picked from commit 86fe1ac0d5)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:16 +08:00
Sean Young
0a134379b8 UPSTREAM: media: rc: saa7134: add trailing space for timely decoding
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: 3f5c4c7332 ("[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>
(cherry picked from commit 48b2de1971)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:16 +08:00
Sean Young
79a7118986 UPSTREAM: media: rc-core: improve ir_raw_store_edge() handling
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>
(cherry picked from commit e5e26439d1)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:16 +08:00
Shawn Guo
0c579e8e21 UPSTREAM: media: rc: ir-nec-decoder: move scancode composing code into a shared function
The NEC scancode composing and protocol type detection in
ir_nec_decode() is generic enough to be a shared function.  Let's create
an inline function in rc-core.h, so that other remote control drivers
can reuse this function to save some code.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit e8ffda7862)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:16 +08:00
Sean Young
6247790751 UPSTREAM: media: rc: pwm-ir-tx: add new driver
This is new driver which uses pwm, so it is more power-efficient
than the bit banging gpio-ir-tx driver.

Signed-off-by: Sean Young <sean@mess.org>
Reviewed-by: Pavel Machek <pavel@ucw.cz>
Tested-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit db3df8765e)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:16 +08:00
Sean Young
ffa989ad0f UPSTREAM: media: rc: gpio-ir-tx: add new driver
This is a simple bit-banging GPIO IR TX driver.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 24d79ebc6c)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:16 +08:00