* [linux-dvb] Mantis VP-2040 (Terratec Cinergy C PCI) Remote Control Support
@ 2008-06-05 13:34 Sebastian B
2008-06-05 14:09 ` Roland Scheidegger
0 siblings, 1 reply; 3+ messages in thread
From: Sebastian B @ 2008-06-05 13:34 UTC (permalink / raw)
To: linux-dvb
[-- Attachment #1.1: Type: text/plain, Size: 1025 bytes --]
Hello,
I'm quite new to this mailing list. So maybe somebody posted something
similar but I haven't found it here.
I have a Terratec Cinergy C PCI. AFAIK this is an clone of Mantis VP-2040.
I'm using the mantis driver from http://jusst.de/hg/mantis.
Unfortunately there's no remote control support for any mantis chip type.
So I wrote a patch for the mantis driver version 0b04be0c088a which enables
remote control support for Mantis VP-2040.
The patch is basically an extension of the remote patch for the VP-2033 I
found on this mailing list.
It's not perfect yet, but it's working without any problems on my system.
Here's how it works:
1. Download version 0b04be0c088a from http://jusst.de/hg/mantis
2. tar jfx mantis-0b04be0c088a.tar.bz2
3. cd mantis-0b04be0c088a
4. patch -p1 < mantis-patch-0b04be0c088a
5. compile and install it like usually
If somebody has any improvements or suggestions, please let me know.
Maybe Manu can add remote control support in future releases?
Best Regards,
Sebastian
[-- Attachment #1.2: Type: text/html, Size: 1269 bytes --]
[-- Attachment #2: mantis-patch-0b04be0c088a --]
[-- Type: application/octet-stream, Size: 12255 bytes --]
diff -Naur mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/Makefile mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/Makefile
--- mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/Makefile 2008-05-28 11:25:23.000000000 +0200
+++ mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/Makefile 2008-06-04 23:21:14.000000000 +0200
@@ -12,7 +12,8 @@
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 -Naur mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_common.h mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_common.h
--- mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_common.h 2008-05-28 11:25:23.000000000 +0200
+++ mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_common.h 2008-06-04 23:21:14.000000000 +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,20 @@
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;
+ struct ir_input_state ir;
};
struct mantis_pci {
@@ -142,6 +158,9 @@
u32 gpif_status;
struct mantis_ca *mantis_ca;
+
+ /* RC */
+ struct mantis_ir ir;
};
#define MANTIS_HIF_STATUS (mantis->gpio_status << 12)
diff -Naur mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_core.c mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_core.c
--- mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_core.c 2008-05-28 11:25:23.000000000 +0200
+++ mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_core.c 2008-06-04 23:21:14.000000000 +0200
@@ -165,6 +165,10 @@
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 -Naur mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_core.h mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_core.h
--- mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_core.h 2008-05-28 11:25:23.000000000 +0200
+++ mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_core.h 2008-06-04 23:21:14.000000000 +0200
@@ -53,5 +53,7 @@
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);
#endif //__MANTIS_CORE_H
diff -Naur mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_pci.c mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_pci.c
--- mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_pci.c 2008-05-28 11:25:23.000000000 +0200
+++ mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_pci.c 2008-06-04 23:21:14.000000000 +0200
@@ -94,6 +94,22 @@
}
if (stat & MANTIS_INT_IRQ1) {
dprintk(verbose, MANTIS_DEBUG, 0, "* INT IRQ-1 *");
+
+ //a nasty trick to read the IR code
+ //for some reason the memory gets corrupted
+ //this is a work around for this problem
+ u32 i = 0;
+ for(i = 0; i < 1024; ++i)
+ {
+ u32 val = mmread(0xe8);
+ //only use value if memory isn't corrupted
+ if ((val != 0) && (val != 0x80))
+ {
+ mantis->ir.ir_last_code = val;
+ break;
+ }
+
+ }
}
if (stat & MANTIS_INT_OCERR) {
dprintk(verbose, MANTIS_DEBUG, 0, "* INT OCERR *");
diff -Naur mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_rc.c mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_rc.c
--- mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_rc.c 1970-01-01 01:00:00.000000000 +0100
+++ mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_rc.c 2008-06-04 23:21:14.000000000 +0200
@@ -0,0 +1,218 @@
+#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_vp3030.h"
+
+#define POLL_FREQ (HZ/10)
+
+/* 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 CAB-CI 2040 */
+IR_KEYTAB_TYPE ir_codes_mantis_vp2040[IR_KEYTAB_SIZE] = {
+ [ 0x1e ] = KEY_HOME,
+ [ 0x3e ] = KEY_POWER,
+ [ 0x1d ] = KEY_MENU, // actually DVD MENU
+ [ 0x1c ] = KEY_SUBTITLE, // actually DVD SUBTITLE
+ [ 0x1b ] = KEY_TEXT, // TELETEXT
+ [ 0x1a ] = KEY_DELETE,
+
+ [ 0x34 ] = KEY_SWITCHVIDEOMODE, // actually AV
+ [ 0x32 ] = KEY_AB,
+
+ [ 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,
+ [ 0x33 ] = KEY_0,
+
+ [ 0x19 ] = KEY_TV,
+ [ 0x18 ] = KEY_DVD,
+ [ 0x16 ] = KEY_VIDEO,
+ [ 0x15 ] = KEY_TUNER, //actually MUSIC
+ [ 0x14 ] = KEY_SCREEN, //actually PIC
+
+ [ 0x2d ] = KEY_OK,
+ [ 0x2f ] = KEY_UP,
+ [ 0x2b ] = KEY_DOWN,
+ [ 0x2e ] = KEY_LEFT,
+ [ 0x2c ] = KEY_RIGHT,
+
+ [ 0x30 ] = KEY_EPG,
+ [ 0x29 ] = KEY_INFO,
+ [ 0x12 ] = KEY_BACK,
+
+ [ 0x23 ] = KEY_VOLUMEUP,
+ [ 0x21 ] = KEY_VOLUMEDOWN,
+
+ [ 0x24 ] = KEY_CHANNELUP,
+ [ 0x20 ] = KEY_CHANNELDOWN,
+
+ [ 0x13 ] = KEY_PLAY,
+ [ 0x22 ] = KEY_MUTE,
+
+ [ 0x28 ] = KEY_RED,
+ [ 0x27 ] = KEY_GREEN,
+ [ 0x26 ] = KEY_YELLOW,
+ [ 0x25 ] = KEY_BLUE,
+
+ [ 0x07 ] = KEY_RECORD,
+ [ 0x17 ] = KEY_STOP,
+ [ 0x1F ] = KEY_PAUSE,
+
+ [ 0x0B ] = KEY_LAST,
+ [ 0x11 ] = KEY_REWIND,
+ [ 0x10 ] = KEY_FASTFORWARD,
+ [ 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 ir_input_state *ir = &mantis->ir.ir;
+
+ u32 lastkey = mantis->ir.ir_last_code;
+
+ if (lastkey != -1) {
+ ir_input_keydown(mantis->ir.rc_dev, ir, lastkey, 0);
+ mantis->ir.ir_last_code = -1;
+ } else {
+ ir_input_nokey(mantis->ir.rc_dev, ir);
+ }
+ schedule_delayed_work(&mantis->ir.rc_query_work, POLL_FREQ);
+}
+
+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;
+ }
+
+ schedule_delayed_work(&mir->rc_query_work, POLL_FREQ);
+ return 0;
+}
+
+int mantis_rc_exit(struct mantis_pci *mantis)
+{
+ mmwrite(mmread(MANTIS_INT_MASK) & (~MANTIS_INT_IRQ1), MANTIS_INT_MASK);
+
+ cancel_delayed_work(&mantis->ir.rc_query_work);
+ input_unregister_device(mantis->ir.rc_dev);
+ dprintk(verbose, MANTIS_DEBUG, 1, "RC unregistered");
+ return 0;
+}
diff -Naur mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_rc.h mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_rc.h
--- mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_rc.h 1970-01-01 01:00:00.000000000 +0100
+++ mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_rc.h 2008-06-04 23:21:14.000000000 +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];
diff -Naur mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_vp2033.c mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_vp2033.c
--- mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_vp2033.c 2008-05-28 11:25:23.000000000 +0200
+++ mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_vp2033.c 2008-06-04 23:21:14.000000000 +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 @@
.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 -Naur mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_vp2040.c mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_vp2040.c
--- mantis-0b04be0c088a/linux/drivers/media/dvb/mantis/mantis_vp2040.c 2008-05-28 11:25:23.000000000 +0200
+++ mantis-2008-05-28-rc/linux/drivers/media/dvb/mantis/mantis_vp2040.c 2008-06-04 23:21:14.000000000 +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 @@
.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 = {
[-- Attachment #3: Type: text/plain, Size: 150 bytes --]
_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [linux-dvb] Mantis VP-2040 (Terratec Cinergy C PCI) Remote Control Support
2008-06-05 13:34 [linux-dvb] Mantis VP-2040 (Terratec Cinergy C PCI) Remote Control Support Sebastian B
@ 2008-06-05 14:09 ` Roland Scheidegger
2008-06-06 9:37 ` Sebastian B
0 siblings, 1 reply; 3+ messages in thread
From: Roland Scheidegger @ 2008-06-05 14:09 UTC (permalink / raw)
To: Sebastian B; +Cc: linux-dvb
On 05.06.2008 15:34, Sebastian B wrote:
>
> Hello,
>
> I'm quite new to this mailing list. So maybe somebody posted something
> similar but I haven't found it here.
You are indeed late to the party :-)
http://www.linuxtv.org/pipermail/linux-dvb/2008-May/026102.html
>
> It's not perfect yet, but it's working without any problems on my system.
I wonder what's up with the memory corruption you mentioned, I didn't
see anything like that.
> Maybe Manu can add remote control support in future releases?
I agree this would be really great so people don't come up with
basically the same patches over and over again :-).
Roland
_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [linux-dvb] Mantis VP-2040 (Terratec Cinergy C PCI) Remote Control Support
2008-06-05 14:09 ` Roland Scheidegger
@ 2008-06-06 9:37 ` Sebastian B
0 siblings, 0 replies; 3+ messages in thread
From: Sebastian B @ 2008-06-06 9:37 UTC (permalink / raw)
To: Roland Scheidegger; +Cc: linux-dvb
[-- Attachment #1.1: Type: text/plain, Size: 1175 bytes --]
Hello,
Guess, I didn't search hard enough for a solution ;-)
Regarding the memory corruption:
I don't know what's causing that problem.
If I check for the IR value only one time, I sometimes receive the value
0x00 and 0x80 which is obviously invalid.
So the only way I know of is to check for the IR value several times to get
the right one.
Does somebody know what's happening there?
Best Regards
Sebastian
On Thu, Jun 5, 2008 at 4:09 PM, Roland Scheidegger
<rscheidegger_lists@hispeed.ch> wrote:
> On 05.06.2008 15:34, Sebastian B wrote:
> >
> > Hello,
> >
> > I'm quite new to this mailing list. So maybe somebody posted something
> > similar but I haven't found it here.
> You are indeed late to the party :-)
> http://www.linuxtv.org/pipermail/linux-dvb/2008-May/026102.html
>
> >
> > It's not perfect yet, but it's working without any problems on my system.
> I wonder what's up with the memory corruption you mentioned, I didn't
> see anything like that.
>
>
> > Maybe Manu can add remote control support in future releases?
> I agree this would be really great so people don't come up with
> basically the same patches over and over again :-).
>
> Roland
>
[-- Attachment #1.2: Type: text/html, Size: 1728 bytes --]
[-- Attachment #2: Type: text/plain, Size: 150 bytes --]
_______________________________________________
linux-dvb mailing list
linux-dvb@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-06-06 9:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-05 13:34 [linux-dvb] Mantis VP-2040 (Terratec Cinergy C PCI) Remote Control Support Sebastian B
2008-06-05 14:09 ` Roland Scheidegger
2008-06-06 9:37 ` Sebastian B
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox