Commit Graph

614113 Commits

Author SHA1 Message Date
Hu Kejun
88f7ff2b04 media: i2c: add ov2718 driver with hdr and linear mode
Change-Id: I534793509a0f607e46822763e97b07d33a138dcb
Signed-off-by: Hu Kejun <william.hu@rock-chips.com>
2018-12-12 17:24:29 +08:00
Hu Kejun
784baba614 media: rockchip: isp1: add ioctl for hdr
Change-Id: I6aa26828a1da063be9f24cd02c5fefd84988d04a
Signed-off-by: Hu Kejun <william.hu@rock-chips.com>
2018-12-12 17:24:29 +08:00
Hu Kejun
c0202e0bc5 media: spi: add driver for rk1608
Change-Id: I8508668fcd1e35c49fe581875fcf9045e004ae9c
Signed-off-by: Hu Kejun <william.hu@rock-chips.com>
2018-12-12 17:24:29 +08:00
Wang Panzhenzhuan
642bed250f media: i2c: add gc2355 driver for rkisp1
Change-Id: I500c7133fa98b5b98d074408d4f08c39f57f5c38
Signed-off-by: Wang Panzhenzhuan <randy.wang@rock-chips.com>
2018-12-12 15:31:45 +08:00
Bin Yang
444ca5e657 arm64: dts: rockchip: fix vbus-5v-gpios flags for rk3399 platforms
Fusb302 driver uses gpiod_set_value() to control VBUS, so vbus-5v-gpios
flags should be used correctly in device tree.

Change-Id: Ie7f0d1d290750bbf4207c1bc5665e4a0427a7a97
Signed-off-by: Bin Yang <yangbin@rock-chips.com>
2018-12-12 15:04:03 +08:00
Bin Yang
a45a91483c mfd/fusb302: cleanup vbus gpio
Currently driver uses gpiod_set_raw_value() to control VBUS, which unable
to parse flags 'GPIO_ACTIVE_LOW' in device tree. We cannot ensure that
vbus-gpio will be designed to active-high in all products. So we should
use the gpiod_set_value() to control VBUS, and also gpio flags be used
correctly in device tree synchronously.

Change-Id: I94d143dde7b44d89b5593fbb5014859fedb83b04
Signed-off-by: Bin Yang <yangbin@rock-chips.com>
2018-12-12 15:04:03 +08:00
Elaine Zhang
4604ed7218 clk: rockchip: rk3399: export SCLK_I2SOUT_SRC clk ID for i2s
Change-Id: Ifbcea830e5f49946c1feea3f51d125e6ed566d5f
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2018-12-12 15:03:25 +08:00
Russell King
b5eac72e73 UPSTREAM: ARM: spectre-v1: mitigate user accesses
Spectre variant 1 attacks are about this sequence of pseudo-code:

	index = load(user-manipulated pointer);
	access(base + index * stride);

In order for the cache side-channel to work, the access() must me made
to memory which userspace can detect whether cache lines have been
loaded.  On 32-bit ARM, this must be either user accessible memory, or
a kernel mapping of that same user accessible memory.

The problem occurs when the load() speculatively loads privileged data,
and the subsequent access() is made to user accessible memory.

Any load() which makes use of a user-maniplated pointer is a potential
problem if the data it has loaded is used in a subsequent access.  This
also applies for the access() if the data loaded by that access is used
by a subsequent access.

Harden the get_user() accessors against Spectre attacks by forcing out
of bounds addresses to a NULL pointer.  This prevents get_user() being
used as the load() step above.  As a side effect, put_user() will also
be affected even though it isn't implicated.

Also harden copy_from_user() by redoing the bounds check within the
arm_copy_from_user() code, and NULLing the pointer if out of bounds.

Change-Id: I7598d2a637267b5979a7013cf450a80caaa2044f
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
(cherry picked from commit a3c0f84765)
2018-12-12 11:05:36 +08:00
Russell King
042dc8706f UPSTREAM: ARM: spectre-v1: use get_user() for __get_user()
Fixing __get_user() for spectre variant 1 is not sane: we would have to
add address space bounds checking in order to validate that the location
should be accessed, and then zero the address if found to be invalid.

Since __get_user() is supposed to avoid the bounds check, and this is
exactly what get_user() does, there's no point having two different
implementations that are doing the same thing.  So, when the Spectre
workarounds are required, make __get_user() an alias of get_user().

Change-Id: I32e38a7635961822ffadaad256caf9a34268bd2a
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
(cherry picked from commit b1cd0a1480)
2018-12-12 11:05:36 +08:00
Russell King
ef18c704fd UPSTREAM: ARM: use __inttype() in get_user()
Borrow the x86 implementation of __inttype() to use in get_user() to
select an integer type suitable to temporarily hold the result value.
This is necessary to avoid propagating the volatile nature of the
result argument, which can cause the following warning:

lib/iov_iter.c:413:5: warning: optimization may eliminate reads and/or writes to register variables [-Wvolatile-register-var]

Change-Id: I2663f38f5a278c8406793dc7c8b88403ee6918b1
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
(cherry picked from commit d09fbb327d)
2018-12-12 11:05:36 +08:00
Russell King
f34156cac3 UPSTREAM: ARM: oabi-compat: copy semops using __copy_from_user()
__get_user_error() is used as a fast accessor to make copying structure
members as efficient as possible.  However, with software PAN and the
recent Spectre variant 1, the efficiency is reduced as these are no
longer fast accessors.

In the case of software PAN, it has to switch the domain register around
each access, and with Spectre variant 1, it would have to repeat the
access_ok() check for each access.

Rather than using __get_user_error() to copy each semops element member,
copy each semops element in full using __copy_from_user().

Change-Id: I7174992c0c63cb5f4f191b1961519e0d3c7a72e5
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
(cherry picked from commit 8c8484a1c1)
2018-12-12 11:05:36 +08:00
Russell King
e64f679fe3 UPSTREAM: ARM: vfp: use __copy_from_user() when restoring VFP state
__get_user_error() is used as a fast accessor to make copying structure
members in the signal handling path as efficient as possible.  However,
with software PAN and the recent Spectre variant 1, the efficiency is
reduced as these are no longer fast accessors.

In the case of software PAN, it has to switch the domain register around
each access, and with Spectre variant 1, it would have to repeat the
access_ok() check for each access.

Use __copy_from_user() rather than __get_user_err() for individual
members when restoring VFP state.

Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
(cherry picked from commit 42019fc50d)

Change-Id: I978369093e075213b01e27aff3c633acfb3592be
2018-12-12 11:05:36 +08:00
Russell King
607844100f UPSTREAM: ARM: signal: copy registers using __copy_from_user()
__get_user_error() is used as a fast accessor to make copying structure
members in the signal handling path as efficient as possible.  However,
with software PAN and the recent Spectre variant 1, the efficiency is
reduced as these are no longer fast accessors.

In the case of software PAN, it has to switch the domain register around
each access, and with Spectre variant 1, it would have to repeat the
access_ok() check for each access.

It becomes much more efficient to use __copy_from_user() instead, so
let's use this for the ARM integer registers.

Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
(cherry picked from commit c32cd419d6)

Change-Id: I3e285582bedc3973ca0cc08d63562d71aad2f520
2018-12-12 11:05:36 +08:00
Russell King
44bca95698 UPSTREAM: ARM: spectre-v1: fix syscall entry
Prevent speculation at the syscall table decoding by clamping the index
used to zero on invalid system call numbers, and using the csdb
speculative barrier.

Change-Id: Idce90686d2e49703c5794c81b9bc9a41d93cc658
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Boot-tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
(cherry picked from commit 10573ae547)
2018-12-12 11:05:36 +08:00
Russell King
7a633b2249 UPSTREAM: ARM: spectre-v1: add array_index_mask_nospec() implementation
Add an implementation of the array_index_mask_nospec() function for
mitigating Spectre variant 1 throughout the kernel.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Boot-tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Tony Lindgren <tony@atomide.com>
(cherry picked from commit 1d4238c56f)

Change-Id: I69fc8c673578a937a06cfdf85ae73492d25d069f
2018-12-12 11:05:35 +08:00
Russell King
76e84854a6 UPSTREAM: ARM: spectre-v1: add speculation barrier (csdb) macros
Add assembly and C macros for the new CSDB instruction.

Change-Id: If7ff45e33cc2386702b6e76636a6c5fa665dccdd
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Boot-tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
(cherry picked from commit a78d156587)
2018-12-12 11:05:35 +08:00
Russell King
58d750babb UPSTREAM: ARM: spectre: add Kconfig symbol for CPUs vulnerable to Spectre
Add a Kconfig symbol for CPUs which are vulnerable to the Spectre
attacks.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Boot-tested-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Tony Lindgren <tony@atomide.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
(cherry picked from commit c58d237d08)

Change-Id: I69c87355f2f691f0679df63e3d2cdf5570e5e35b
2018-12-12 11:05:35 +08:00
Hans Verkuil
d1dbde442d UPSTREAM: [media] media Kconfig: improve the spi integration
The SPI driver looked a bit lonely in the config menu, and it didn't
support the autoselect. Shift things around a bit so it looks more logical.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 8283a09299)

Change-Id: I8f67aa29dffe477b349b0a503b6db7abfd2357ec
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
2018-12-11 17:33:28 +08:00
Charles-Antoine Couret
dc08c1afb9 UPSTREAM: [media] Add GS1662 driver, a video serializer
You can read datasheet here:
http://www.c-dis.net/media/871/GS1662_Datasheet.pdf

It's a component which supports HD and SD CEA or SDI formats
to SDI output. It's configured through SPI bus.

GS1662 driver is implemented as v4l2 subdev.

Signed-off-by: Charles-Antoine Couret <charles-antoine.couret@nexvision.fr>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 7aae6e2df1)

Change-Id: I1ae9065fc91aae13c4498eece89458831e20499d
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
2018-12-11 17:32:16 +08:00
Lin Jianhua
65f4a3e028 ARM: dts: rockchip: add voice module boards v11 for RK3308
Separate the power supply to arm&logic, arm freq support 1.2G,
disable vad and include rk3308k.dtsi

Change-Id: I91516773e74fd098117bfdcf8213803e19cf7527
Signed-off-by: Lin Jianhua <linjh@rock-chips.com>
2018-12-11 17:20:17 +08:00
Lin Jianhua
60c60b8c57 ARM64: dts: rockchip: rk3308: add rk3308k dtsi use to support wide temperature chip
Ambient temperature range: -20~85
Supported chips: RK3308K/RK3308GK/RK3308BK/RK3308HK

Change-Id: I40f23e20b2323a5a7d93cd022382b5eda9b6a3a0
Signed-off-by: Lin Jianhua <linjh@rock-chips.com>
2018-12-11 17:20:07 +08:00
XiaoDong Huang
ec2157254d arm64: rk1808_linux_defconfig: enable CONFIG_PINCTRL_RK805
Change-Id: Ie96bf3b38cb9db86ad1a5ba203033a242abb48f6
Signed-off-by: XiaoDong Huang <derrick.huang@rock-chips.com>
2018-12-11 17:04:52 +08:00
Simon Xue
81094fad08 PCI: rockchip: Add support for PCIe dma transfer function
Change-Id: Ie577d9816205c1e6d04ba666d68a6c7e57efa12d
Signed-off-by: Simon Xue <xxm@rock-chips.com>
2018-12-11 16:07:26 +08:00
Hu Kejun
df8183eff9 media: rockchip: isp1: add vs irq handle
Change-Id: I94e4a22316c3e5a6feea42d4698ceadc21aa82b4
Signed-off-by: Hu Kejun <william.hu@rock-chips.com>
2018-12-11 14:25:47 +08:00
William Wu
d5a3e8be19 usb: gadget: Kconfig: disable CONFIG_USB_CONFIGFS_F_UVC_ROCKCHIP
If we enable CONFIG_USB_CONFIGFS_F_UVC_ROCKCHIP, the userspace
must update the data length of v4l2_event to 4100 synchronously.
Because we don't modify the v4l2_event struct in the userspace
by default, so disable this config. You can enable this config
if you have modified the data length of v4l2_event to 4100 in
the userspace.

Change-Id: I68c354b2d8acba669b5c7bf1a425fdc34c05f1e5
Signed-off-by: William Wu <william.wu@rock-chips.com>
2018-12-11 11:48:23 +08:00
William Wu
fda83c6dbf phy: rockchip-inno-usb2: add bypass uart cfgs for rk1808
This patch adds bypass uart cfgs for rk1808 USB 3.0 OTG
port. In addition, please note that it needs to set the
uart2 rx/tx io selection in the reg "BUS_GRF_IOFUNC_CON0"
bit 15:14.

Change-Id: I77ea461be299c0454f5caee1349110b6f2714c30
Signed-off-by: William Wu <william.wu@rock-chips.com>
2018-12-11 11:17:40 +08:00
Arnd Bergmann
5ae861fe4e UPSTREAM: rc: print correct variable for z8f0811
A recent rework accidentally left a debugging printk untouched while
changing the meaning of the variables, leading to an uninitialized
variable being printed:

  drivers/media/i2c/ir-kbd-i2c.c: In function 'get_key_haup_common':
  drivers/media/i2c/ir-kbd-i2c.c:62:2: error: 'toggle' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This prints the correct one instead, as we did before the patch.

Change-Id: Ia9b59c8fcbdfaf792ea7d4c9bcf93c94cf76d9d5
Fixes: 00bb820755 ("[media] rc: Hauppauge z8f0811 can decode RC6")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
(cherry picked from commit 9cdbe14fb4)
2018-12-11 09:22:22 +08:00
Sean Young
6c10a2ac71 UPSTREAM: media: rc: ensure close() is called on rc_unregister_device
If userspace has an open file descriptor on the rc input device or lirc
device when rc_unregister_device() is called, then the rc close() is
never called.

This ensures that the receiver is turned off on the nuvoton-cir driver
during shutdown.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
(cherry picked from commit 8e782fcf78)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:38 +08:00
Sean Young
3a811ff882 UPSTREAM: media: rc: cec devices do not have a lirc chardev
This fixes an oops in ir_lirc_scancode_event().

BUG: unable to handle kernel NULL pointer dereference at 0000000000000038
PGD 0 P4D 0
Oops: 0000 [#1] SMP PTI
CPU: 9 PID: 27687 Comm: kworker/9:2 Tainted: P           OE 4.18.12-200.fc28.x86_64 #1
Hardware name: Supermicro C7X99-OCE-F/C7X99-OCE-F, BIOS 2.1a 06/15/2018
Workqueue: events pulse8_irq_work_handler [pulse8_cec]
RIP: 0010:ir_lirc_scancode_event+0x3d/0xb0 [rc_core]
Code: 8d ae b4 07 00 00 49 81 c6 b8 07 00 00 53 e8 4a df c3 d5 48 89 ef 49 89 45 00 e8 4e 84 41 d6 49 8b 1e 49 89 c4 4c 39 f3 74 58 <8b> 43 38 8b 53 40 89 c1 2b 4b 3c 39 ca 72 41 21 d0 49 8b 7d 00 49
RSP: 0018:ffffaa10e3c07d58 EFLAGS: 00010017
RAX: 0000000000000002 RBX: 0000000000000000 RCX: 0000000000000018
RDX: 0000000000000001 RSI: 00316245397fa93c RDI: ffff966d31c8d7b4
RBP: ffff966d31c8d7b4 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000003 R11: ffffaa10e3c07e28 R12: 0000000000000002
R13: ffffaa10e3c07d88 R14: ffff966d31c8d7b8 R15: 0000000000000073
FS:  0000000000000000(0000) GS:ffff966d3f440000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000038 CR3: 00000009d820a003 CR4: 00000000003606e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 ir_do_keydown+0x75/0x260 [rc_core]
 rc_keydown+0x54/0xc0 [rc_core]
 cec_received_msg_ts+0xaa8/0xaf0 [cec]
 process_one_work+0x1a1/0x350
 worker_thread+0x30/0x380
 ? pwq_unbound_release_workfn+0xd0/0xd0
 kthread+0x112/0x130
 ? kthread_create_worker_on_cpu+0x70/0x70
 ret_from_fork+0x35/0x40
Modules linked in: rc_tt_1500 dvb_usb_dvbsky dvb_usb_v2 uas usb_storage fuse vhost_net vhost tap xt_CHECKSUM iptable_mangle ip6t_REJECT nf_reject_ipv6 tun 8021q garp mrp xt_nat macvlan xfs devlink ebta
 si2157 si2168 cx25840 cx23885 kvm altera_ci tda18271 joydev ir_rc6_decoder rc_rc6_mce crct10dif_pclmul crc32_pclmul ghash_clmulni_intel intel_cstate intel_uncore altera_stapl m88ds3103 tveeprom cx2341
 mxm_wmi igb crc32c_intel megaraid_sas dca i2c_algo_bit wmi vfio_pci irqbypass vfio_virqfd vfio_iommu_type1 vfio i2c_dev
CR2: 0000000000000038

Cc: <stable@vger.kernel.org> # v4.16+
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
(cherry picked from commit e5bb9d3d75)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:38 +08:00
Sean Young
c28bc4978f UPSTREAM: media: rc: mce_kbd: input events via rc-core's input device
There is no need to create another input device.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
(cherry picked from commit 158bc148a3)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:38 +08:00
Sean Young
cc81c28284 UPSTREAM: media: rc: imon: report mouse events using rc-core's input device
There is no need to create another input device.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
(cherry picked from commit 0ac5a603a7)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:38 +08:00
Sean Young
804cd51b63 UPSTREAM: media: rc: some events are dropped by userspace
libevdev (which is used by libinput) gets a list of keycodes from the
input device on creation. Any events with keycodes which are not in this
list are silently dropped. So, set all keycodes on device creation since
we do not know which will be used if the keymap changes.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
(cherry picked from commit fec225a043)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:38 +08:00
Matthias Reichl
ade8ed67db UPSTREAM: media: rc: ir-rc6-decoder: enable toggle bit for Kathrein RCU-676 remote
The Kathrein RCU-676 remote uses the 32-bit rc6 protocol and toggles
bit 15 (0x8000) on repeated button presses, like MCE remotes.

Add it's customer code 0x80460000 to the 32-bit rc6 toggle
handling code to get proper scancodes and toggle reports.

Signed-off-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
(cherry picked from commit 85e4af0a7a)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:38 +08:00
Sean Young
143c24afef UPSTREAM: media: rc: Remove init_ir_raw_event and DEFINE_IR_RAW_EVENT macros
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 cafa0010cd ("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>
(cherry picked from commit 183e19f5b9)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>

 Conflicts:
	drivers/media/pci/cx88/cx88-input.c
	drivers/media/rc/imon_raw.c
	drivers/media/rc/mceusb.c
	drivers/media/rc/meson-ir.c
	drivers/media/rc/mtk-cir.c
	drivers/media/rc/redrat3.c
	drivers/media/rc/sir_ir.c
	drivers/media/rc/st_rc.c
2018-12-10 20:36:38 +08:00
Sean Young
fc9e98f3fc UPSTREAM: media: rc: read out of bounds if bpf reports high protocol number
The repeat period is read from a static array. If a keydown event is
reported from bpf with a high protocol number, we read out of bounds. This
is unlikely to end up with a reasonable repeat period at the best of times,
in which case no timely key up event is generated.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
(cherry picked from commit f5dbee6e38)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:38 +08:00
Sean Young
e0497bc497 UPSTREAM: media: rc: be less noisy when driver misbehaves
Since commit 48231f289e ("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>
(cherry picked from commit 0ca54b2905)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:38 +08:00
Sean Young
dee540153a UPSTREAM: media: rc: ensure input/lirc device can be opened after register
Since commit cb84343fce ("media: lirc: do not call close() or open() on
unregistered devices") rc_open() will return -ENODEV if rcdev->registered
is false. Ensure this is set before we register the input device and the
lirc device, else we have a short window where the neither the lirc or
input device can be opened.

Fixes: cb84343fce ("media: lirc: do not call close() or open() on unregistered devices")

Cc: stable@vger.kernel.org # v4.16+
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
(cherry picked from commit d7832cd2a3)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:37 +08:00
Sean Young
96037450cd UPSTREAM: media: rc: decoders do not need to check for transitions
Drivers should never produce consecutive pulse or space raw events. Should
that occur, we would have bigger problems than this code is trying to
guard against.

Note that we already log an error should a driver misbehave.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
(cherry picked from commit 09161a0552)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:37 +08:00
Sean Young
af5a6b5454 UPSTREAM: media: rc: drivers should produce alternate pulse and space timing events
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>
(cherry picked from commit 48231f289e)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:37 +08:00
Sean Young
ff7e976e81 UPSTREAM: media: rc: default to idle on at startup or after reset
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>
(cherry picked from commit e0d51e6cef)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:37 +08:00
Sean Young
a9055a4c42 UPSTREAM: media: rc: imon decoder: support the stick
The iMON PAD controller has a analog stick, which can be switched to
keyboard mode (cursor keys) or work as a crappy mouse.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
(cherry picked from commit f9d94a10da)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:36 +08:00
Sean Young
3af841c4fb UPSTREAM: media: rc: only register protocol for rc device if enabled
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>
(cherry picked from commit c00cb587a2)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:36 +08:00
Sean Young
4be3197aab UPSTREAM: media: rc: mce_kbd decoder: fix race condition
The MCE keyboard sends both key down and key up events. We have a timeout
handler mce_kbd_rx_timeout() in case the keyup event is never received;
however, this may race with new key down events from occurring.

The race is that key down scancode arrives and key down events are
generated. The timeout handler races this and generates key up events
straight afterwards. Since the keyboard generates scancodes every 100ms,
most likely the keys will be repeated 100ms later, and now we have new
key down events and the user sees duplicate key presses.

Reported-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 53a62800ef)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:36 +08:00
Sean Young
d654f0960b UPSTREAM: media: rc: mce_kbd decoder: remove superfluous call to input_sync
There is nothing to sync in this code path.

Reported-by: Matthias Reichl <hias@horus.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit cb5bd0575c)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:36 +08:00
Sean Young
cbe653a9bb UPSTREAM: media: rc: mce_kbd decoder: fix stuck keys
The MCE Remote sends a 0 scancode when keys are released. If this is not
received or decoded, then keys can get "stuck"; the keyup event is not
sent since the input_sync() is missing from the timeout handler.

Cc: stable@vger.kernel.org
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 63039c29f7)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:35 +08:00
Sean Young
0fc74b0c0a UPSTREAM: media: rc: mce_kbd protocol encodes two scancodes
If two keys are pressed, then both keys are encoded in the scancode. This
makes the mce keyboard more responsive.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 539327608d)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:35 +08:00
Sean Young
ac57e7f177 UPSTREAM: media: rc: per-protocol repeat period and minimum keyup timer
Each IR protocol has its own repeat period. We can minimise the keyup
timer to be the protocol period + IR timeout. This makes keys less
"sticky" and makes IR more reactive and nicer to use.

This feature was previously attempted in commit d57ea877af ("media: rc:
per-protocol repeat period"), but that did not take the IR timeout into
account, and had to be reverted.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 284922562b)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:35 +08:00
Sean Young
2d30eda71d UPSTREAM: media: rc: mce_kbd decoder: low timeout values cause double keydowns
The mce keyboard repeats pressed keys every 100ms. If the IR timeout
is set to less than that, we send key up events before the repeat
arrives, so we have key up/key down for each IR repeat.

The keyboard ends any sequence with a 0 scancode, in which case all keys
are cleared so there is no need to run the timeout timer: it only exists
for the case that the final 0 was not received.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit c421c62a4a)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:35 +08:00
Sean Young
d43c56cdfd UPSTREAM: media: rc: add ioctl to get the current timeout
Since the kernel now modifies the timeout, make it possible to retrieve
the current value.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
(cherry picked from commit 95d1544eb6)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>

 Conflicts:
	Documentation/media/uapi/rc/lirc-set-rec-timeout.rst
2018-12-10 20:36:35 +08:00
Sean Young
3822f577e6 UPSTREAM: media: rc: set timeout to smallest value required by enabled protocols
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>
(cherry picked from commit a86d6df84a)
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
2018-12-10 20:36:35 +08:00