diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2020-12-14 11:47:37 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-12-14 11:47:37 -0800 |
commit | fab0fca1da5cdc48be051715cd9787df04fdce3a (patch) | |
tree | 5d1228cdd22bdd0675090349cf41aeef53e8a14c /drivers/media/rc | |
parent | ae1985b50afaf76aaa09946ee36b59eaecb2ffae (diff) | |
parent | 7ea4d23293300ca2f225595849a4fe444fb80ea4 (diff) |
Merge tag 'media/v5.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab:
- some rework at the uAPI pixel format docs
- the smiapp driver has started to gain support for MIPI CSS camera
sensors and was renamed
- two new sensor drivers: ov02a10 and ov9734
- Meson gained a driver for the 2D acceleration unit
- Rockchip rkisp1 driver was promoted from staging
- Cedrus driver gained support for VP8
- two new remote controller keymaps were added
- the usual set of fixes cleanups and driver improvements
* tag 'media/v5.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (447 commits)
media: ccs: Add support for obtaining C-PHY configuration from firmware
media: ccs-pll: Print pixel rates
media: ccs: Print written register values
media: ccs: Add support for DDR OP SYS and OP PIX clocks
media: ccs-pll: Add support for DDR OP system and pixel clocks
media: ccs: Dual PLL support
media: ccs-pll: Add trivial dual PLL support
media: ccs-pll: Separate VT divisor limit calculation from the rest
media: ccs-pll: Fix VT post-PLL divisor calculation
media: ccs-pll: Make VT divisors 16-bit
media: ccs-pll: Rework bounds checks
media: ccs-pll: Print relevant information on PLL tree
media: ccs-pll: Better separate OP and VT sub-tree calculation
media: ccs-pll: Check for derating and overrating, support non-derating sensors
media: ccs-pll: Split off VT subtree calculation
media: ccs-pll: Add C-PHY support
media: ccs-pll: Add sanity checks
media: ccs-pll: Add support flexible OP PLL pixel clock divider
media: ccs-pll: Support two cycles per pixel on OP domain
media: ccs-pll: Add support for extended input PLL clock divider
...
Diffstat (limited to 'drivers/media/rc')
-rw-r--r-- | drivers/media/rc/keymaps/Makefile | 2 | ||||
-rw-r--r-- | drivers/media/rc/keymaps/rc-khamsin.c | 75 | ||||
-rw-r--r-- | drivers/media/rc/keymaps/rc-pine64.c | 65 | ||||
-rw-r--r-- | drivers/media/rc/lirc_dev.c | 3 | ||||
-rw-r--r-- | drivers/media/rc/sunxi-cir.c | 50 |
5 files changed, 186 insertions, 9 deletions
diff --git a/drivers/media/rc/keymaps/Makefile b/drivers/media/rc/keymaps/Makefile index aaa1bf81d00d..b252a1d2ebd6 100644 --- a/drivers/media/rc/keymaps/Makefile +++ b/drivers/media/rc/keymaps/Makefile @@ -60,6 +60,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \ rc-it913x-v2.o \ rc-kaiomy.o \ rc-khadas.o \ + rc-khamsin.o \ rc-kworld-315u.o \ rc-kworld-pc150u.o \ rc-kworld-plus-tv-analog.o \ @@ -79,6 +80,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \ rc-npgtech.o \ rc-odroid.o \ rc-pctv-sedna.o \ + rc-pine64.o \ rc-pinnacle-color.o \ rc-pinnacle-grey.o \ rc-pinnacle-pctv-hd.o \ diff --git a/drivers/media/rc/keymaps/rc-khamsin.c b/drivers/media/rc/keymaps/rc-khamsin.c new file mode 100644 index 000000000000..0c98c2faacff --- /dev/null +++ b/drivers/media/rc/keymaps/rc-khamsin.c @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0+ +// Copyright (c) 2020 Christian Hewitt + +#include <media/rc-map.h> +#include <linux/module.h> + +/* + * KHAMSIN is an IR/Bluetooth RCU supplied with the SmartLabs + * SML-5442TW DVB-S/VOD box. The RCU has separate IR (TV) and + * BT (STB) modes. This keymap suppors the IR controls. + */ + +static struct rc_map_table khamsin[] = { + { 0x70702, KEY_POWER}, + + { 0x70701, KEY_VIDEO}, // source + + { 0x7076c, KEY_RED}, + { 0x70714, KEY_GREEN}, + { 0x70715, KEY_YELLOW}, + { 0x70716, KEY_BLUE}, + + { 0x7071a, KEY_MENU}, + { 0x7074f, KEY_EPG}, + + { 0x70760, KEY_UP }, + { 0x70761, KEY_DOWN }, + { 0x70765, KEY_LEFT }, + { 0x70762, KEY_RIGHT }, + { 0x70768, KEY_ENTER }, + + { 0x7072d, KEY_ESC }, // back + + { 0x70707, KEY_VOLUMEUP }, + { 0x7070b, KEY_VOLUMEDOWN }, + { 0x7070f, KEY_MUTE }, + { 0x70712, KEY_CHANNELUP }, + { 0x70710, KEY_CHANNELDOWN }, + + { 0x70704, KEY_1 }, + { 0x70705, KEY_2 }, + { 0x70706, KEY_3 }, + { 0x70708, KEY_4 }, + { 0x70709, KEY_5 }, + { 0x7070a, KEY_6 }, + { 0x7070c, KEY_7 }, + { 0x7070d, KEY_8 }, + { 0x7070e, KEY_9 }, + { 0x70711, KEY_0 }, +}; + +static struct rc_map_list khamsin_map = { + .map = { + .scan = khamsin, + .size = ARRAY_SIZE(khamsin), + .rc_proto = RC_PROTO_NECX, + .name = RC_MAP_KHAMSIN, + } +}; + +static int __init init_rc_map_khamsin(void) +{ + return rc_map_register(&khamsin_map); +} + +static void __exit exit_rc_map_khamsin(void) +{ + rc_map_unregister(&khamsin_map); +} + +module_init(init_rc_map_khamsin) +module_exit(exit_rc_map_khamsin) + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Christian Hewitt <christianshewitt@gmail.com>"); diff --git a/drivers/media/rc/keymaps/rc-pine64.c b/drivers/media/rc/keymaps/rc-pine64.c new file mode 100644 index 000000000000..9b2bdbbce04e --- /dev/null +++ b/drivers/media/rc/keymaps/rc-pine64.c @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0+ + +// Keytable for the Pine64 IR Remote Controller +// Copyright (c) 2017 Jonas Karlman + +#include <media/rc-map.h> +#include <linux/module.h> + +static struct rc_map_table pine64[] = { + { 0x40404d, KEY_POWER }, + { 0x40401f, KEY_WWW }, + { 0x40400a, KEY_MUTE }, + + { 0x404017, KEY_VOLUMEDOWN }, + { 0x404018, KEY_VOLUMEUP }, + + { 0x404010, KEY_LEFT }, + { 0x404011, KEY_RIGHT }, + { 0x40400b, KEY_UP }, + { 0x40400e, KEY_DOWN }, + { 0x40400d, KEY_OK }, + + { 0x40401d, KEY_MENU }, + { 0x40401a, KEY_HOME }, + + { 0x404045, KEY_BACK }, + + { 0x404001, KEY_NUMERIC_1 }, + { 0x404002, KEY_NUMERIC_2 }, + { 0x404003, KEY_NUMERIC_3 }, + { 0x404004, KEY_NUMERIC_4 }, + { 0x404005, KEY_NUMERIC_5 }, + { 0x404006, KEY_NUMERIC_6 }, + { 0x404007, KEY_NUMERIC_7 }, + { 0x404008, KEY_NUMERIC_8 }, + { 0x404009, KEY_NUMERIC_9 }, + { 0x40400c, KEY_BACKSPACE }, + { 0x404000, KEY_NUMERIC_0 }, + { 0x404047, KEY_EPG }, // mouse +}; + +static struct rc_map_list pine64_map = { + .map = { + .scan = pine64, + .size = ARRAY_SIZE(pine64), + .rc_proto = RC_PROTO_NECX, + .name = RC_MAP_PINE64, + } +}; + +static int __init init_rc_map_pine64(void) +{ + return rc_map_register(&pine64_map); +} + +static void __exit exit_rc_map_pine64(void) +{ + rc_map_unregister(&pine64_map); +} + +module_init(init_rc_map_pine64) +module_exit(exit_rc_map_pine64) + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Jonas Karlman"); diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 220363b9a868..116daf90c858 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -263,7 +263,8 @@ static ssize_t lirc_transmit(struct file *file, const char __user *buf, goto out_unlock; } - if (scan.flags || scan.keycode || scan.timestamp) { + if (scan.flags || scan.keycode || scan.timestamp || + scan.rc_proto > RC_PROTO_MAX) { ret = -EINVAL; goto out_unlock; } diff --git a/drivers/media/rc/sunxi-cir.c b/drivers/media/rc/sunxi-cir.c index ddee6ee37bab..8555c7798706 100644 --- a/drivers/media/rc/sunxi-cir.c +++ b/drivers/media/rc/sunxi-cir.c @@ -73,10 +73,6 @@ #define SUNXI_IR_BASE_CLK 8000000 /* Noise threshold in samples */ #define SUNXI_IR_RXNOISE 1 -/* Idle Threshold in samples */ -#define SUNXI_IR_RXIDLE 20 -/* Time after which device stops sending data in ms */ -#define SUNXI_IR_TIMEOUT 120 /** * struct sunxi_ir_quirks - Differences between SoC variants. @@ -137,6 +133,8 @@ static irqreturn_t sunxi_ir_irq(int irqno, void *dev_id) } else if (status & REG_RXSTA_RPE) { ir_raw_event_set_idle(ir->rc, true); ir_raw_event_handle(ir->rc); + } else { + ir_raw_event_handle(ir->rc); } spin_unlock(&ir->ir_lock); @@ -144,6 +142,41 @@ static irqreturn_t sunxi_ir_irq(int irqno, void *dev_id) return IRQ_HANDLED; } +/* Convert idle threshold to usec */ +static unsigned int sunxi_ithr_to_usec(unsigned int base_clk, unsigned int ithr) +{ + return DIV_ROUND_CLOSEST(USEC_PER_SEC * (ithr + 1), + base_clk / (128 * 64)); +} + +/* Convert usec to idle threshold */ +static unsigned int sunxi_usec_to_ithr(unsigned int base_clk, unsigned int usec) +{ + /* make sure we don't end up with a timeout less than requested */ + return DIV_ROUND_UP((base_clk / (128 * 64)) * usec, USEC_PER_SEC) - 1; +} + +static int sunxi_ir_set_timeout(struct rc_dev *rc_dev, unsigned int timeout) +{ + struct sunxi_ir *ir = rc_dev->priv; + unsigned int base_clk = clk_get_rate(ir->clk); + unsigned long flags; + + unsigned int ithr = sunxi_usec_to_ithr(base_clk, timeout); + + dev_dbg(rc_dev->dev.parent, "setting idle threshold to %u\n", ithr); + + spin_lock_irqsave(&ir->ir_lock, flags); + /* Set noise threshold and idle threshold */ + writel(REG_CIR_NTHR(SUNXI_IR_RXNOISE) | REG_CIR_ITHR(ithr), + ir->base + SUNXI_IR_CIR_REG); + spin_unlock_irqrestore(&ir->ir_lock, flags); + + rc_dev->timeout = sunxi_ithr_to_usec(base_clk, ithr); + + return 0; +} + static int sunxi_ir_probe(struct platform_device *pdev) { int ret = 0; @@ -240,9 +273,11 @@ static int sunxi_ir_probe(struct platform_device *pdev) ir->rc->map_name = ir->map_name ?: RC_MAP_EMPTY; ir->rc->dev.parent = dev; ir->rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; - /* Frequency after IR internal divider with sample period in ns */ + /* Frequency after IR internal divider with sample period in us */ ir->rc->rx_resolution = (USEC_PER_SEC / (b_clk_freq / 64)); - ir->rc->timeout = MS_TO_US(SUNXI_IR_TIMEOUT); + ir->rc->min_timeout = sunxi_ithr_to_usec(b_clk_freq, 0); + ir->rc->max_timeout = sunxi_ithr_to_usec(b_clk_freq, 255); + ir->rc->s_timeout = sunxi_ir_set_timeout; ir->rc->driver_name = SUNXI_IR_DEV; ret = rc_register_device(ir->rc); @@ -270,8 +305,7 @@ static int sunxi_ir_probe(struct platform_device *pdev) writel(REG_CTL_MD, ir->base+SUNXI_IR_CTL_REG); /* Set noise threshold and idle threshold */ - writel(REG_CIR_NTHR(SUNXI_IR_RXNOISE)|REG_CIR_ITHR(SUNXI_IR_RXIDLE), - ir->base + SUNXI_IR_CIR_REG); + sunxi_ir_set_timeout(ir->rc, IR_DEFAULT_TIMEOUT); /* Invert Input Signal */ writel(REG_RXCTL_RPPI, ir->base + SUNXI_IR_RXCTL_REG); |