[PATCH 1/1] media: nec-decoder: remove trailer_space state

2018-04-20 Thread Vladislav Zhurba
From: Daniel Fu <dan...@nvidia.com>

Remove STATE_TRAILER_SPACE from state machine.
Causing 2 issue:
- can not decode the keycode, if it didn't following with
  another keycode/repeat code
- will generate one more code in current logic.
  i.e. key_right + repeat code + key_left + repeat code.
  expect: key_right, key_left.
  Result: key_right, key_right, key_right.
  Reason: when receive repeat code of key_right, state machine will
  stay in STATE_TRAILER_SPACE state, then wait for a new interrupt,
  if an interrupt came after keyup_timer, then will generate another
  fake key.

According to the NEC protocol, it don't need a trailer space. Remove it.

Signed-off-by: Daniel Fu <dan...@nvidia.com>
Signed-off-by: Vladislav Zhurba <vzhu...@nvidia.com>
---
 drivers/media/rc/ir-nec-decoder.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/media/rc/ir-nec-decoder.c 
b/drivers/media/rc/ir-nec-decoder.c
index 21647b809e6f..760b66affd1a 100644
--- a/drivers/media/rc/ir-nec-decoder.c
+++ b/drivers/media/rc/ir-nec-decoder.c
@@ -128,16 +128,6 @@ static int ir_nec_decode(struct rc_dev *dev, struct 
ir_raw_event ev)
if (!eq_margin(ev.duration, NEC_TRAILER_PULSE, NEC_UNIT / 2))
break;
 
-   data->state = STATE_TRAILER_SPACE;
-   return 0;
-
-   case STATE_TRAILER_SPACE:
-   if (ev.pulse)
-   break;
-
-   if (!geq_margin(ev.duration, NEC_TRAILER_SPACE, NEC_UNIT / 2))
-   break;
-
if (data->count == NEC_NBITS) {
address = bitrev8((data->bits >> 24) & 0xff);
not_address = bitrev8((data->bits >> 16) & 0xff);
-- 
2.16.2



[PATCH 1/1] media: rc: Add NVIDIA IR keymapping

2018-04-20 Thread Vladislav Zhurba
From: Jun Yan <ju...@nvidia.com>

Add keymap with NEC and SONY12 protocol for NVIDIA IR

Signed-off-by: Jun Yan <ju...@nvidia.com>
Signed-off-by: marting <mart...@nvidia.com>
Signed-off-by: Daniel Fu <dan...@nvidia.com>
Signed-off-by: Vladislav Zhurba <vzhu...@nvidia.com>
---
 drivers/media/rc/keymaps/Makefile|  2 +
 drivers/media/rc/keymaps/rc-nvidia-nec.c | 66 
 drivers/media/rc/keymaps/rc-nvidia.c | 66 
 include/media/rc-map.h   |  2 +
 4 files changed, 136 insertions(+)
 create mode 100644 drivers/media/rc/keymaps/rc-nvidia-nec.c
 create mode 100644 drivers/media/rc/keymaps/rc-nvidia.c

diff --git a/drivers/media/rc/keymaps/Makefile 
b/drivers/media/rc/keymaps/Makefile
index d6b913a3032d..1d08500462fd 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -75,6 +75,8 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
rc-nec-terratec-cinergy-xs.o \
rc-norwood.o \
rc-npgtech.o \
+   rc-nvidia.o \
+   rc-nvidia-nec.o \
rc-pctv-sedna.o \
rc-pinnacle-color.o \
rc-pinnacle-grey.o \
diff --git a/drivers/media/rc/keymaps/rc-nvidia-nec.c 
b/drivers/media/rc/keymaps/rc-nvidia-nec.c
new file mode 100644
index ..c910a2a683f6
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-nvidia-nec.c
@@ -0,0 +1,66 @@
+/* Keytable for NVIDIA Remote Controller
+ *
+ * Copyright (c) 2014-2018, NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+#include 
+#include 
+
+static struct rc_map_table foster_table[] = {
+   { 0x807e12, KEY_VOLUMEUP },
+   { 0x807e15, KEY_VOLUMEDOWN },
+   { 0x807e0c, KEY_UP },
+   { 0x807e0e, KEY_DOWN },
+   { 0x807e0b, KEY_LEFT },
+   { 0x807e0d, KEY_RIGHT },
+   { 0x807e09, KEY_HOMEPAGE },
+   { 0x807e06, KEY_POWER },
+   { 0x807e03, KEY_SELECT },
+   { 0x807e02, KEY_BACK },
+   { 0x807e14, KEY_MUTE },
+   { 0x807e20, KEY_PLAYPAUSE },
+   { 0x807e11, KEY_PLAYCD },
+   { 0x807e08, KEY_PAUSECD },
+   { 0x807e07, KEY_STOP },
+   { 0x807e0f, KEY_FASTFORWARD },
+   { 0x807e0a, KEY_REWIND },
+   { 0x807e41, KEY_SLEEP },
+   { 0x807e45, KEY_WAKEUP },
+};
+
+static struct rc_map_list nvidia_map = {
+   .map = {
+   .scan = foster_table,
+   .size = ARRAY_SIZE(foster_table),
+   .rc_type = RC_TYPE_NEC,
+   .name = RC_MAP_NVIDIA_NEC,
+   }
+};
+
+static int __init init_rc_map_nvidia(void)
+{
+   return rc_map_register(_map);
+}
+
+static void __exit exit_rc_map_nvidia(void)
+{
+   rc_map_unregister(_map);
+}
+
+module_init(init_rc_map_nvidia);
+module_exit(exit_rc_map_nvidia);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Daniel Fu <dan...@nvidia.com>");
diff --git a/drivers/media/rc/keymaps/rc-nvidia.c 
b/drivers/media/rc/keymaps/rc-nvidia.c
new file mode 100644
index ..9767d85a6c9e
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-nvidia.c
@@ -0,0 +1,66 @@
+/* Keytable for NVIDIA Remote Controller
+ *
+ * Copyright (c) 2014-2018, NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+#include 
+#include 
+
+static struct rc_map_table foster_table[] = {
+   { 0x10009, KEY_0 },
+   { 0x1, KEY_1 },
+   { 0x10001, KEY_2 },
+   { 0x10002, KEY_3 },
+   { 0x10003, KEY_4 },
+   { 0x10004, KEY_5 },
+   { 0x10005, KEY_6 },
+   { 0x10006, KEY_7 },
+   { 0x10007, KEY_8 },
+   { 0x10008, KEY_9 },
+   { 0x10012, KEY_VOLUMEUP },
+

[PATCH 0/1] Add two IR keymaps for NVIDIA devices

2018-04-20 Thread Vladislav Zhurba
Adds two IR keymaps for NVIDIA devices.
The RC types are SONY12 and NEC.

Jun Yan (1):
  media: rc: Add NVIDIA IR keymapping

 drivers/media/rc/keymaps/Makefile|  2 +
 drivers/media/rc/keymaps/rc-nvidia-nec.c | 66 
 drivers/media/rc/keymaps/rc-nvidia.c | 66 
 include/media/rc-map.h   |  2 +
 4 files changed, 136 insertions(+)
 create mode 100644 drivers/media/rc/keymaps/rc-nvidia-nec.c
 create mode 100644 drivers/media/rc/keymaps/rc-nvidia.c

-- 
2.17.0