diff -r cd1fc4c7f1d8 linux/drivers/media/dvb/mantis/Makefile
--- a/linux/drivers/media/dvb/mantis/Makefile	Sat May 10 22:48:56 2008 +0400
+++ b/linux/drivers/media/dvb/mantis/Makefile	Fri Apr 18 18:30:22 2008 +0200
@@ -12,7 +12,8 @@ mantis-objs = 	mantis_core.o	\
 		mantis_vp1041.o	\
 		mantis_vp2033.o	\
 		mantis_vp2040.o	\
-		mantis_vp3030.o
+		mantis_vp3030.o \
+		mantis_rc.o
 
 obj-$(CONFIG_DVB_MANTIS) += mantis.o
 
diff -r cd1fc4c7f1d8 linux/drivers/media/dvb/mantis/mantis_common.h
--- a/linux/drivers/media/dvb/mantis/mantis_common.h	Sat May 10 22:48:56 2008 +0400
+++ b/linux/drivers/media/dvb/mantis/mantis_common.h	Thu May 15 04:24:59 2008 +0200
@@ -26,6 +26,8 @@
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/mutex.h>
+#include <linux/input.h>
+#include <media/ir-common.h>
 
 #include "dvbdev.h"
 #include "dvb_demux.h"
@@ -74,6 +76,21 @@ struct mantis_hwconfig {
 	char			*model_name;
 	char			*dev_type;
 	u32			ts_size;
+	IR_KEYTAB_TYPE		*ir_codes;
+};
+
+struct mantis_ir {
+	struct input_dev	*rc_dev;
+	char			rc_name[80];
+	char			rc_phys[80];
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+	struct work_struct	rc_query_work;
+#else
+	struct delayed_work	rc_query_work;
+#endif
+	u32			ir_last_code;
+	u32			ir_last_irq;
+	struct ir_input_state	ir;
 };
 
 struct mantis_pci {
@@ -139,6 +156,9 @@ struct mantis_pci {
 	 /*	A12 A13 A14		*/
 	int			gpio_status;
 
+        /*       RC                     */
+	struct mantis_ir	ir;
+
 	struct mantis_ca	*mantis_ca;
 };
 
diff -r cd1fc4c7f1d8 linux/drivers/media/dvb/mantis/mantis_core.c
--- a/linux/drivers/media/dvb/mantis/mantis_core.c	Sat May 10 22:48:56 2008 +0400
+++ b/linux/drivers/media/dvb/mantis/mantis_core.c	Mon May 12 15:32:23 2008 +0200
@@ -164,6 +164,10 @@ int mantis_core_init(struct mantis_pci *
 		dprintk(verbose, MANTIS_DEBUG, 1, "Mantis DVB init failed");
 		return err;
 	}
+	if ((err = mantis_rc_init(mantis)) < 0) {
+		dprintk(verbose, MANTIS_DEBUG, 1, "mantis RC init failed");
+		return err;
+	}
 
 	return 0;
 }
diff -r cd1fc4c7f1d8 linux/drivers/media/dvb/mantis/mantis_core.h
--- a/linux/drivers/media/dvb/mantis/mantis_core.h	Sat May 10 22:48:56 2008 +0400
+++ b/linux/drivers/media/dvb/mantis/mantis_core.h	Sat Apr 12 02:59:11 2008 +0200
@@ -53,6 +53,8 @@ extern int mantis_i2c_exit(struct mantis
 extern int mantis_i2c_exit(struct mantis_pci *mantis);
 extern int mantis_core_init(struct mantis_pci *mantis);
 extern int mantis_core_exit(struct mantis_pci *mantis);
+extern int mantis_rc_init(struct mantis_pci *mantis);
+extern int mantis_rc_exit(struct mantis_pci *mantis);
 //extern void mantis_fe_powerup(struct mantis_pci *mantis);
 //extern void mantis_fe_powerdown(struct mantis_pci *mantis);
 //extern void mantis_fe_reset(struct dvb_frontend *fe);
diff -r cd1fc4c7f1d8 linux/drivers/media/dvb/mantis/mantis_pci.c
--- a/linux/drivers/media/dvb/mantis/mantis_pci.c	Sat May 10 22:48:56 2008 +0400
+++ b/linux/drivers/media/dvb/mantis/mantis_pci.c	Thu May 15 04:23:08 2008 +0200
@@ -65,6 +65,7 @@ static irqreturn_t mantis_pci_irq(int ir
 
 	stat = mmread(MANTIS_INT_STAT);
 	mask = mmread(MANTIS_INT_MASK);
+
 	mstat = lstat = stat & ~MANTIS_INT_RISCSTAT;
 	if (!(stat & mask))
 		return IRQ_NONE;
@@ -72,6 +73,7 @@ static irqreturn_t mantis_pci_irq(int ir
 	mantis->mantis_int_stat = stat;
 	mantis->mantis_int_mask = mask;
 	dprintk(verbose, MANTIS_DEBUG, 0, "=== Interrupts[%04x/%04x]= [", stat, mask);
+
 	if (stat & MANTIS_INT_RISCEN) {
 		dprintk(verbose, MANTIS_DEBUG, 0, "* DMA enabl *");
 	}
@@ -81,6 +83,11 @@ static irqreturn_t mantis_pci_irq(int ir
 	}
 	if (stat & MANTIS_INT_IRQ1) {
 		dprintk(verbose, MANTIS_DEBUG, 0, "* INT IRQ-1 *");
+		dprintk(verbose, MANTIS_DEBUG, 0, "ir repeat msec %u", jiffies_to_msecs(jiffies - mantis->ir.ir_last_irq));
+		mantis->ir.ir_last_irq = jiffies;
+		/* note value must be read here or we'll get irq storm */
+		mantis->ir.ir_last_code = mmread(0xe8);
+		schedule_delayed_work(&mantis->ir.rc_query_work, 0);
 	}
 	if (stat & MANTIS_INT_OCERR) {
 		dprintk(verbose, MANTIS_DEBUG, 0, "* INT OCERR *");
@@ -243,6 +250,7 @@ static void __devexit mantis_pci_remove(
 		dprintk(verbose, MANTIS_ERROR, 1, "Aeio, Mantis NULL ptr");
 		return;
 	}
+	mantis_rc_exit(mantis);
 	mantis_core_exit(mantis);
 	dprintk(verbose, MANTIS_ERROR, 1, "Removing -->Mantis irq: %d, latency: %d\n memory: 0x%lx, mmio: 0x%p",
 		pdev->irq, mantis->latency, mantis->mantis_addr,
diff -r cd1fc4c7f1d8 linux/drivers/media/dvb/mantis/mantis_vp2033.c
--- a/linux/drivers/media/dvb/mantis/mantis_vp2033.c	Sat May 10 22:48:56 2008 +0400
+++ b/linux/drivers/media/dvb/mantis/mantis_vp2033.c	Thu May 15 04:23:00 2008 +0200
@@ -20,6 +20,7 @@
 
 #include "mantis_common.h"
 #include "mantis_vp2033.h"
+#include "mantis_rc.h"
 
 #define MANTIS_MODEL_NAME	"VP-2033"
 #define MANTIS_DEV_TYPE		"DVB-C"
@@ -28,6 +29,7 @@ struct mantis_hwconfig vp2033_mantis_con
 	.model_name	= MANTIS_MODEL_NAME,
 	.dev_type	= MANTIS_DEV_TYPE,
 	.ts_size	= MANTIS_TS_204,
+	.ir_codes       = ir_codes_mantis_vp2033,
 };
 
 struct tda1002x_config philips_cu1216_config = {
diff -r cd1fc4c7f1d8 linux/drivers/media/dvb/mantis/mantis_vp2040.c
--- a/linux/drivers/media/dvb/mantis/mantis_vp2040.c	Sat May 10 22:48:56 2008 +0400
+++ b/linux/drivers/media/dvb/mantis/mantis_vp2040.c	Thu May 15 04:20:26 2008 +0200
@@ -20,6 +20,7 @@
 
 #include "mantis_common.h"
 #include "mantis_vp2040.h"
+#include "mantis_rc.h"
 
 #define MANTIS_MODEL_NAME	"VP-2040"
 #define MANTIS_DEV_TYPE		"DVB-C"
@@ -28,6 +29,7 @@ struct mantis_hwconfig vp2040_mantis_con
 	.model_name	= MANTIS_MODEL_NAME,
 	.dev_type	= MANTIS_DEV_TYPE,
 	.ts_size	= MANTIS_TS_204,
+	.ir_codes	= ir_codes_mantis_vp2040,
 };
 
 struct tda1002x_config tda10023_cu1216_config = {
diff -r cd1fc4c7f1d8 linux/drivers/media/dvb/mantis/mantis_rc.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux/drivers/media/dvb/mantis/mantis_rc.c	Sat May 17 00:48:36 2008 +0200
@@ -0,0 +1,204 @@
+#include <linux/bitops.h>
+#include "mantis_common.h"
+#include "mantis_core.h"
+
+#include "dmxdev.h"
+#include "dvbdev.h"
+#include "dvb_demux.h"
+#include "dvb_frontend.h"
+#include "mantis_vp1033.h"
+#include "mantis_vp1034.h"
+#include "mantis_vp2033.h"
+#include "mantis_vp2040.h"
+#include "mantis_vp3030.h"
+
+/* Twinhan CAB-CI 2033 */
+IR_KEYTAB_TYPE ir_codes_mantis_vp2033[IR_KEYTAB_SIZE] = {
+	[ 0x29 ] = KEY_POWER,
+	[ 0x28 ] = KEY_FAVORITES,
+	[ 0x30 ] = KEY_TEXT,
+	[ 0x17 ] = KEY_INFO,          // Preview 
+	[ 0x23 ] = KEY_EPG,
+	[ 0x3b ] = KEY_F22,           // Record List
+
+	[ 0x3c ] = KEY_1, 
+	[ 0x3e ] = KEY_2,
+	[ 0x39 ] = KEY_3,
+	[ 0x36 ] = KEY_4,
+	[ 0x22 ] = KEY_5,
+	[ 0x20 ] = KEY_6,
+	[ 0x32 ] = KEY_7,
+	[ 0x26 ] = KEY_8,
+	[ 0x24 ] = KEY_9,
+	[ 0x2a ] = KEY_0,
+
+	[ 0x33 ] = KEY_CANCEL,
+	[ 0x2c ] = KEY_BACK,
+	[ 0x15 ] = KEY_CLEAR,
+	[ 0x3f ] = KEY_TAB,
+	[ 0x10 ] = KEY_ENTER,
+	[ 0x14 ] = KEY_UP,
+	[ 0x0d ] = KEY_RIGHT,
+	[ 0x0e ] = KEY_DOWN,
+	[ 0x11 ] = KEY_LEFT,
+
+	[ 0x21 ] = KEY_VOLUMEUP,
+	[ 0x35 ] = KEY_VOLUMEDOWN,
+	[ 0x3d ] = KEY_CHANNELDOWN,
+	[ 0x3a ] = KEY_CHANNELUP,
+	[ 0x2e ] = KEY_RECORD,
+	[ 0x2b ] = KEY_PLAY,
+	[ 0x13 ] = KEY_PAUSE,
+	[ 0x25 ] = KEY_STOP,
+
+	[ 0x1f ] = KEY_REWIND,
+	[ 0x2d ] = KEY_FASTFORWARD,
+	[ 0x1e ] = KEY_PREVIOUS,        // Replay |<
+	[ 0x1d ] = KEY_NEXT,            // Skip   >|
+
+	[ 0x0b ] = KEY_CAMERA,          // Capture
+	[ 0x0f ] = KEY_LANGUAGE,         // SAP
+	[ 0x18 ] = KEY_MODE,             // PIP
+	[ 0x12 ] = KEY_ZOOM,            // Full screen,
+	[ 0x1c ] = KEY_SUBTITLE,
+	[ 0x2f ] = KEY_MUTE,
+	[ 0x16 ] = KEY_F20,              // L/R,
+	[ 0x38 ] = KEY_F21,              // Hibernate,
+
+	[ 0x37 ] = KEY_SWITCHVIDEOMODE, // A/V
+	[ 0x31 ] = KEY_AGAIN,           // Recall,
+	[ 0x1a ] = KEY_KPPLUS,          // Zoom+,
+	[ 0x19 ] = KEY_KPMINUS,         // Zoom-,
+	[ 0x27 ] = KEY_RED,
+	[ 0x0C ] = KEY_GREEN,
+	[ 0x01 ] = KEY_YELLOW,
+	[ 0x00 ] = KEY_BLUE,
+
+};
+
+/* Twinhan mantis vp2040 - terratec cinergy c */
+IR_KEYTAB_TYPE ir_codes_mantis_vp2040[IR_KEYTAB_SIZE] = {
+	[ 0x3e ] = KEY_POWER,
+	[ 0x3d ] = KEY_1,
+	[ 0x3c ] = KEY_2,
+	[ 0x3b ] = KEY_3,
+	[ 0x3a ] = KEY_4,
+	[ 0x39 ] = KEY_5,
+	[ 0x38 ] = KEY_6,
+	[ 0x37 ] = KEY_7,
+	[ 0x36 ] = KEY_8,
+	[ 0x35 ] = KEY_9,
+	[ 0x34 ] = KEY_VIDEO_NEXT, /* AV */
+	[ 0x33 ] = KEY_0,
+	[ 0x32 ] = KEY_REFRESH,
+	[ 0x30 ] = KEY_EPG,
+	[ 0x2f ] = KEY_UP,
+	[ 0x2e ] = KEY_LEFT,
+	[ 0x2d ] = KEY_OK,
+	[ 0x2c ] = KEY_RIGHT,
+	[ 0x2b ] = KEY_DOWN,
+	[ 0x29 ] = KEY_INFO,
+	[ 0x28 ] = KEY_RED,
+	[ 0x27 ] = KEY_GREEN,
+	[ 0x26 ] = KEY_YELLOW,
+	[ 0x25 ] = KEY_BLUE,
+	[ 0x24 ] = KEY_CHANNELUP,
+	[ 0x23 ] = KEY_VOLUMEUP,
+	[ 0x22 ] = KEY_MUTE,
+	[ 0x21 ] = KEY_VOLUMEDOWN,
+	[ 0x20 ] = KEY_CHANNELDOWN,
+	[ 0x1f ] = KEY_PAUSE,
+	[ 0x1e ] = KEY_HOME,
+	[ 0x1d ] = KEY_MENU, /* DVD Menu */
+	[ 0x1c ] = KEY_SUBTITLE,
+	[ 0x1b ] = KEY_TEXT, /* Teletext */
+	[ 0x1a ] = KEY_DELETE,
+	[ 0x19 ] = KEY_TV,
+	[ 0x18 ] = KEY_DVD,
+	[ 0x17 ] = KEY_STOP,
+	[ 0x16 ] = KEY_VIDEO,
+	[ 0x15 ] = KEY_AUDIO, /* Music */
+	[ 0x14 ] = KEY_SCREEN, /* Pic */
+	[ 0x13 ] = KEY_PLAY,
+	[ 0x12 ] = KEY_BACK,
+	[ 0x11 ] = KEY_REWIND,
+	[ 0x10 ] = KEY_FASTFORWARD,
+	[ 0x0b ] = KEY_PREVIOUS,
+	[ 0x07 ] = KEY_RECORD,
+	[ 0x03 ] = KEY_NEXT,
+
+};
+
+
+void mantis_query_rc(struct work_struct *work)
+{
+	struct mantis_pci *mantis =
+		container_of(work, struct mantis_pci, ir.rc_query_work.work);
+	struct mantis_ir *mir = &mantis->ir;
+	struct ir_input_state *ir = &mantis->ir.ir;
+
+	u32 currkey = mir->ir_last_code;
+
+	ir_input_keydown(mir->rc_dev, ir, currkey, 0);
+	ir_input_nokey(mir->rc_dev, ir);
+
+}
+
+int mantis_rc_init(struct mantis_pci *mantis)
+{
+	struct input_dev *rc_dev;
+	struct mantis_ir *mir = &mantis->ir;
+	struct ir_input_state *ir = &mir->ir;
+	int err;
+
+	if (!mantis->hwconfig->ir_codes) {
+		dprintk(verbose, MANTIS_DEBUG, 1, "No RC codes available");
+		return 0;
+	}
+
+	mmwrite(mmread(MANTIS_INT_MASK) | MANTIS_INT_IRQ1, MANTIS_INT_MASK);
+
+	rc_dev = input_allocate_device();
+	if (!rc_dev) {
+		dprintk(verbose, MANTIS_ERROR, 1, "dvb_rc_init failed");
+		return -ENOENT;
+	}
+
+	mir->rc_dev = rc_dev;
+
+	snprintf(mir->rc_name, sizeof(mir->rc_name), 
+		 "Mantis %s IR Receiver", mantis->hwconfig->model_name);
+	snprintf(mir->rc_phys, sizeof(mir->rc_phys), 
+		 "pci-%s/ir0", pci_name(mantis->pdev));
+
+	rc_dev->name = mir->rc_name;
+	rc_dev->phys = mir->rc_phys;
+
+	ir_input_init(rc_dev, ir, IR_TYPE_OTHER, mantis->hwconfig->ir_codes);
+
+	rc_dev->id.bustype = BUS_PCI;
+	rc_dev->id.vendor  = mantis->vendor_id;
+	rc_dev->id.product = mantis->device_id;
+	rc_dev->id.version = 1;
+	rc_dev->cdev.dev = &mantis->pdev->dev;
+
+	INIT_DELAYED_WORK(&mir->rc_query_work, mantis_query_rc);
+
+	err = input_register_device(rc_dev);
+	if (err) {
+		dprintk(verbose, MANTIS_ERROR, 1, "rc registering failed");
+		return -ENOENT;
+	}
+
+	return 0;
+}
+
+int mantis_rc_exit(struct mantis_pci *mantis)
+{
+	mmwrite(mmread(MANTIS_INT_MASK) & (~MANTIS_INT_IRQ1), MANTIS_INT_MASK);
+
+	cancel_rearming_delayed_work(&mantis->ir.rc_query_work);
+	input_unregister_device(mantis->ir.rc_dev);
+	dprintk(verbose, MANTIS_DEBUG, 1, "RC unregistered");
+	return 0;
+}
diff -r cd1fc4c7f1d8 linux/drivers/media/dvb/mantis/mantis_rc.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/linux/drivers/media/dvb/mantis/mantis_rc.h	Sat May 03 02:53:11 2008 +0200
@@ -0,0 +1,2 @@
+extern IR_KEYTAB_TYPE ir_codes_mantis_vp2033[IR_KEYTAB_SIZE];
+extern IR_KEYTAB_TYPE ir_codes_mantis_vp2040[IR_KEYTAB_SIZE];
