Commit Graph

614037 Commits

Author SHA1 Message Date
Sean Young
a38d8fc1eb UPSTREAM: media: lirc: improve locking
Once rc_unregister_device() has been called, no driver function
should be called.

This prevents some nasty race conditions with an ioctl calls
driver functions when the driver specific data has been freed.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 4957133fe3)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:28 +08:00
Sean Young
6be6aef8c2 UPSTREAM: media: lirc: allow lirc device to be opened more than once
This makes it possible for lircd to read from a lirc chardev, and not
keep it busy.

Note that this changes the default for timeout reports to on. lircd
already enables timeout reports when it opens a lirc device, leaving
them on until the next reboot.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 7e45d660e4)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:28 +08:00
Sean Young
e45c042b42 UPSTREAM: media: rc: move ir-lirc-codec.c contents into lirc_dev.c
Since removing the lirc kapi, ir-lirc-codec.c only contains lirc fops
so the file name is no longer correct. By moving its content into
lirc_dev.c the ugly extern struct lirc_fops is not longer needed,
and everything lirc related is in one file.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 42e0442f8a)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:28 +08:00
Sean Young
59a4307490 UPSTREAM: media: lirc: scancode rc devices should have a lirc device too
Now that the lirc interface supports scancodes, RC scancode devices
can also have a lirc device. The only receiving feature they will have
enabled is LIRC_CAN_REC_SCANCODE.

Note that CEC devices have no lirc device, since they can be controlled
from their /dev/cecN chardev.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 62d6f1994b)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:27 +08:00
Sean Young
6734f80341 UPSTREAM: media: lirc: ensure lirc device receives nec repeats
The lirc device should get lirc repeats whether there is a keymap
match or not.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit b66218fddf)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:27 +08:00
Sean Young
de27c5a7ce UPSTREAM: media: lirc: implement reading scancode
This implements LIRC_MODE_SCANCODE reading from the lirc device. The
scancode can be read from the input device too, but with this interface
you get the rc protocol, keycode, toggle and repeat status in addition
to just the scancode.

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

	mode = LIRC_MODE_SCANCODE;
	if (ioctl(fd, LIRC_SET_REC_MODE, &mode)) {
		// kernel too old or lirc does not support transmit
	}
	struct lirc_scancode scancode;
	while (read(fd, &scancode, sizeof(scancode)) == sizeof(scancode)) {
		printf("protocol:%d scancode:0x%x toggle:%d repeat:%d\n",
			scancode.rc_proto, scancode.scancode,
			!!(scancode.flags & LIRC_SCANCODE_FLAG_TOGGLE),
			!!(scancode.flags & LIRC_SCANCODE_FLAG_REPEAT));
	}
	close(fd);
}

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit de142c3241)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:27 +08:00
Sean Young
027c4f0dfe UPSTREAM: media: lirc: remove last remnants of lirc kapi
rc-core has replaced the lirc kapi many years ago, and now with the last
driver ported to rc-core, we can finally remove it.

Note this has no effect on userspace.

All future IR drivers should use the rc-core api.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit a6ddd4fecb)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:27 +08:00
Sean Young
15529f6b0e UPSTREAM: media: lirc: remove name from lirc_dev
This is a duplicate of rcdev->driver_name.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit bf01c82474)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:26 +08:00
Sean Young
8393f09cc0 UPSTREAM: media: lirc: create rc-core open and close lirc functions
Replace the generic kernel lirc api with ones which use rc-core, further
reducing the lirc_dev members.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 111429fb73)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:26 +08:00
Sean Young
9c761aedd1 UPSTREAM: media: lirc: do not call close() or open() on unregistered devices
If a lirc chardev is held open after a device is unplugged, rc_close()
will be called after rc_unregister_device(). The driver is not expecting
any calls at this point, and the iguanair driver causes an oops in
this scenario.

rc_open() can be called when the device is removed too, by calling open
on the chardev whilst the device is being removed.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit cb84343fce)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:26 +08:00
Sean Young
414df6823c UPSTREAM: media: lirc: move lirc_dev->attached to rc_dev->registered
This is done to further remove the lirc kernel api. Ensure that every
fops checks for this.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 7790e81f7e)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:26 +08:00
Sean Young
47a46f59c3 UPSTREAM: media: lirc: use kfifo rather than lirc_buffer for raw IR
Since the only mode lirc devices can handle is raw IR, handle this
in a plain kfifo.

Remove lirc_buffer since this is no longer needed.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 71695aff9f)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:26 +08:00
Sean Young
64a21bc88a UPSTREAM: media: lirc: merge lirc_dev_fop_ioctl and ir_lirc_ioctl
Calculate lirc features when necessary, and add LIRC_{S,G}ET_REC_MODE
cases to ir_lirc_ioctl.

This makes lirc_dev_fop_ioctl() unnecessary since all cases are
already handled by ir_lirc_ioctl().

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 95bc71e199)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:25 +08:00
Sean Young
4e3af12eea UPSTREAM: media: rc: document and fix rc_validate_scancode()
For some IR protocols, some scancode values not valid, i.e. they're part
of a different protocol variant.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 6b514c4a50)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:25 +08:00
Sean Young
f2808059bb UPSTREAM: media: lirc: validate scancode for transmit
Ensure we reject an attempt to transmit invalid scancodes.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 49a4b36ada)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:25 +08:00
Sean Young
69805c0578 UPSTREAM: media: lirc: lirc interface should not be a raw decoder
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>
(cherry picked from commit a60d64b15c)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>

 Conflicts:
	drivers/media/rc/Makefile
	drivers/media/rc/ir-lirc-codec.c
	include/media/rc-core.h
2018-12-10 20:36:25 +08:00
Sean Young
b88789d194 UPSTREAM: media: rc: auto load encoder if necessary
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>
(cherry picked from commit 0d39ab0b62)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:25 +08:00
Sean Young
b9c91b5a79 UPSTREAM: media: lirc: use the correct carrier for scancode transmit
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>
(cherry picked from commit cdfaa01c1c)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:24 +08:00
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