Add remote control support for mantis
Subsystems (2)
PATCH 1/1 Add remote control support for mantis
Add remote control support for mantis driver
--- drivers/media/dvb/mantis/hopper_cards.c | 2 +- drivers/media/dvb/mantis/mantis_cards.c | 27 +++- drivers/media/dvb/mantis/mantis_common.h | 23 ++- drivers/media/dvb/mantis/mantis_input.c | 168 +++++++------------- drivers/media/dvb/mantis/mantis_input.h | 28 ++++ drivers/media/dvb/mantis/mantis_uart.c | 18 +-- drivers/media/dvb/mantis/mantis_vp1041.c | 20 +++ drivers/media/dvb/mantis/mantis_vp2033.c | 4 + drivers/media/dvb/mantis/mantis_vp2040.c | 4 + drivers/media/rc/keymaps/Makefile | 3 + .../media/rc/keymaps/rc-terratec-cinergy-c-pci.c | 85 ++++++++++ .../media/rc/keymaps/rc-terratec-cinergy-s2-hd.c | 85 ++++++++++ drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c | 95 +++++++++++ include/media/rc-map.h | 3 + 14 files changed, 438 insertions(+), 127 deletions(-) create mode 100644 drivers/media/dvb/mantis/mantis_input.h create mode 100644 drivers/media/rc/keymaps/rc-terratec-cinergy-c-pci.c create mode 100644 drivers/media/rc/keymaps/rc-terratec-cinergy-s2-hd.c create mode 100644 drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c
(quoted diff) +0 -0
b/drivers/media/dvb/mantis/hopper_cards.c
index 1402062..0b76664 100644
drivers/media/dvb/mantis/hopper_cards.c +0 -0
@@ -107,7 +107,7 @@ static irqreturn_t hopper_irq_handler(int irq, void
*dev_id)
}
if (stat & MANTIS_INT_IRQ1) {
dprintk(MANTIS_DEBUG, 0, "<%s>", label[2]);
- schedule_work(&mantis->uart_work);
+ tasklet_schedule(&mantis->uart_tasklet);
}
if (stat & MANTIS_INT_OCERR) {
dprintk(MANTIS_DEBUG, 0, "<%s>", label[3]);
(quoted diff) +0 -0
b/drivers/media/dvb/mantis/mantis_cards.c
index 05cbb9d..8eca749 100644
drivers/media/dvb/mantis/mantis_cards.c +1 -0
@@ -49,6 +49,7 @@#include "mantis_pci.h" #include "mantis_i2c.h" #include "mantis_reg.h" +#include "mantis_input.h" static unsigned int verbose;module_param (verbose, int,0644 );
@@ -115,7 +116,7 @@ static irqreturn_t mantis_irq_handler(int irq, void
*dev_id)
}
if (stat & MANTIS_INT_IRQ1) {
dprintk(MANTIS_DEBUG, 0, "<%s>", label[2]);
- schedule_work(&mantis->uart_work);
+ tasklet_schedule(&mantis->uart_tasklet);
}
if (stat & MANTIS_INT_OCERR) {
dprintk(MANTIS_DEBUG, 0, "<%s>", label[3]);
@@ -180,6 +181,14 @@ static int __devinit mantis_pci_probe(struct pci_dev *pdev, const struct pci_dev
config->irq_handler = &mantis_irq_handler;
mantis->hwconfig = config;
+ if (mantis->hwconfig->config_init != NULL) {
+ dprintk(MANTIS_ERROR, 1,
+ "Mantis-subsystem: vendor:0x%04x, device:0x%04x\n",
+ mantis->pdev->subsystem_vendor,
+ mantis->pdev->subsystem_device);
+ mantis->hwconfig->config_init(mantis);
+ }
+
err = mantis_pci_init(mantis);
if (err) {
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI initialization
failed <%d>", err);
@@ -215,21 +224,32 @@ static int __devinit mantis_pci_probe(struct pci_dev *pdev, const struct pci_dev
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization
failed <%d>", err);
goto fail4;
}
+
+ err = mantis_input_init(mantis);
+ if (err < 0) {
+ dprintk(MANTIS_ERROR, 1, "ERROR: Mantis INPUT initialization
failed <%d>", err);
+ goto fail6;
+ }
+
+
err = mantis_uart_init(mantis);
if (err < 0) {
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART initialization
failed <%d>", err);
- goto fail6;
+ goto fail7;
}
devs++;
return err;
-
+fail7:
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART exit! <%d>", err); mantis_uart_exit(mantis);
fail6:
+ dprintk(MANTIS_ERROR, 1, "ERROR: Mantis INPUT exit! <%d>", err);
+ mantis_input_exit(mantis);
+
fail4:
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA exit! <%d>", err); mantis_dma_exit(mantis);
@@ -257,6 +277,7 @@ static void __devexit mantis_pci_remove(struct pci_dev *pdev)
if (mantis) {
mantis_uart_exit(mantis);
+ mantis_input_exit(mantis);
mantis_dvb_exit(mantis);
mantis_dma_exit(mantis);
mantis_i2c_exit(mantis);
(quoted diff) +0 -0
b/drivers/media/dvb/mantis/mantis_common.h
index bd400d2..a61046d 100644
drivers/media/dvb/mantis/mantis_common.h +6 -0
@@ -23,6 +23,9 @@#include <linux/mutex.h> #include <linux/workqueue.h> +#include <linux/input.h> +#include <linux/spinlock.h> +#include <media/rc-core.h> #include "mantis_uart.h"
@@ -91,8 +94,12 @@ struct mantis_hwconfig {enum mantis_parity parity;u32 bytes; +char *ir_codes; +void (*ir_work)(struct mantis_pci *mantis,u8 buf[]); +irqreturn_t (*irq_handler)(int irq,void *dev_id); int (*frontend_init)(struct mantis_pci *mantis, struct dvb_frontend
*fe);
+ void (*config_init)(struct mantis_pci *mantis);
u8 power;
u8 reset;
@@ -100,6 +107,12 @@ struct mantis_hwconfig {
enum mantis_i2c_mode i2c_mode;
};
+struct mantis_ir {
+ struct rc_dev *rc_dev;
+ char rc_name[80];
+ char rc_phys[80];
+};
+
struct mantis_pci {
unsigned int verbose;
@@ -167,13 +180,11 @@ struct mantis_pci {
struct mantis_ca *mantis_ca;
- wait_queue_head_t uart_wq;
- struct work_struct uart_work;
- spinlock_t uart_lock;
+ struct tasklet_struct uart_tasklet;
+
+ /* Remote Control handling */
+ struct mantis_ir rc;
- struct rc_dev *rc;
- char input_name[80];
- char input_phys[80];
};
#define MANTIS_HIF_STATUS (mantis->gpio_status)
(quoted diff) +0 -0
b/drivers/media/dvb/mantis/mantis_input.c
index db6d54d..615429d 100644
drivers/media/dvb/mantis/mantis_input.c +6 -82
109 lines not on this page · raw message
mantis->hwconfig->model_name);
- sprintf(mantis->input_phys, "pci-%s/ir0", pci_name(mantis->pdev));
-
- dev->input_name = mantis->input_name; - dev->input_phys = mantis->input_phys; - dev->input_id.bustype = BUS_PCI; - dev->input_id.vendor = mantis->vendor_id; - dev->input_id.product = mantis->device_id; - dev->input_id.version = 1; - dev->driver_name = MODULE_NAME; - dev->map_name = RC_MAP_MANTIS; - dev->dev.parent = &mantis->pdev->dev;
+ rc_dev = rc_allocate_device();
+ if (!rc_dev) {
+ dprintk(MANTIS_ERROR, 1, "Input device allocate failed");
+ return -ENOMEM;
+ }
- err = rc_register_device(dev);
+ 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));
+
+ dprintk(MANTIS_ERROR, 1, "Input device %s PCI: %s",
+ mir->rc_name, mir->rc_phys);
+
+ rc_dev->input_name = mir->rc_name;
+ rc_dev->input_phys = mir->rc_phys;
+ rc_dev->input_id.bustype = BUS_PCI;
+ rc_dev->input_id.vendor = mantis->vendor_id;
+ rc_dev->input_id.product = mantis->device_id;
+ rc_dev->input_id.version = 1;
+ rc_dev->priv = mir;
+ rc_dev->driver_name = MODULE_NAME;
+ rc_dev->driver_type = RC_DRIVER_SCANCODE;
+ rc_dev->map_name = mantis->hwconfig->ir_codes;
+ rc_dev->allowed_protos = RC_TYPE_UNKNOWN;
+
+ err = rc_register_device(rc_dev);
if (err) {
dprintk(MANTIS_ERROR, 1, "IR device registration failed, ret
= %d", err);
- goto out_dev;
+ mir->rc_dev = NULL;
+ rc_free_device(rc_dev);
+ return -ENODEV;
}
- mantis->rc = dev;
+ dprintk(MANTIS_INFO, 1, "Input device registered");
return 0;
-
-out_dev:
- rc_free_device(dev);
-out_map:
- rc_map_unregister(&ir_mantis_map);
-out:
- return err;
}
+EXPORT_SYMBOL_GPL(mantis_input_init);
-int mantis_exit(struct mantis_pci *mantis)
+void mantis_input_exit(struct mantis_pci *mantis)
{
- rc_unregister_device(mantis->rc);
- rc_map_unregister(&ir_mantis_map);
- return 0;
+ struct rc_dev *rc_dev = mantis->rc.rc_dev;
+
+ if (!rc_dev)
+ return;
+
+ rc_unregister_device(rc_dev);
+ mantis->rc.rc_dev = NULL;
}
+EXPORT_SYMBOL_GPL(mantis_input_exit);
+
+void mantis_input_process(struct mantis_pci *mantis, u8 buf[]) +{
+ struct mantis_hwconfig *config = mantis->hwconfig;
+ struct mantis_ir *mir = &mantis->rc;
+ int i;
+ for (i = 0; i < (config->bytes + 1); i++) {
+ dprintk(MANTIS_ERROR, 0, "RC Input Sendkey:%d <%02x>\n", i,
buf[i]);
+ rc_keydown(mir->rc_dev, buf[i], 0);
+ }
+
+}
+EXPORT_SYMBOL_GPL(mantis_input_process);
(quoted diff) +0 -0
b/drivers/media/dvb/mantis/mantis_input.h
new file mode 100644
index 0000000..a00666f
drivers/media/dvb/mantis/mantis_input.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +Mantis PCI bridge driver + +Copyright (C) Manu Abraham ([email protected]) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that 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, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef __MANTIS_INPUT_H +#define __MANTIS_INPUT_H + +extern int mantis_input_init (struct mantis_pci *mantis); +extern void mantis_input_exit (struct mantis_pci *mantis); +extern void mantis_input_process (struct mantis_pci *mantis,u8 buf[]); + +#endif /* __MANTIS_INPUT_H */
(quoted diff) +0 -0
b/drivers/media/dvb/mantis/mantis_uart.c
index f807c8b..f6f343e 100644
drivers/media/dvb/mantis/mantis_uart.c +2 -3
@@ -19,7 +19,6 @@*/ #include <linux/kernel.h> -#include <linux/spinlock.h> #include <linux/signal.h> #include <linux/sched.h>
@@ -34,6 +33,7 @@#include "mantis_common.h" #include "mantis_reg.h" #include "mantis_uart.h" +#include "mantis_input.h" struct mantis_uart_params {enum mantis_baud baud_rate;
@@ -90,9 +90,9 @@ int mantis_uart_read(struct mantis_pci *mantis, u8 *data)return 0 ; } -static void mantis_uart_work (struct work_struct *work) +void mantis_uart_work (unsigned long data) { - struct mantis_pci *mantis = container_of(work, struct mantis_pci,
uart_work);
+ struct mantis_pci *mantis = (struct mantis_pci *) data;
struct mantis_hwconfig *config = mantis->hwconfig;
u8 buf[16];
int i;
@@ -101,8 +101,10 @@ static void mantis_uart_work(struct work_struct *work)
for (i = 0; i < (config->bytes + 1); i++)
dprintk(MANTIS_INFO, 1, "UART BUF:%d <%02x> ", i, buf[i]);
-
dprintk(MANTIS_DEBUG, 0, "\n");
+
+ if (config->ir_work)
+ config->ir_work(mantis, buf);
}
static int mantis_uart_setup(struct mantis_pci *mantis,
@@ -151,10 +153,8 @@ int mantis_uart_init(struct mantis_pci *mantis)
rates[params.baud_rate].string, parity[params.parity].string);
- init_waitqueue_head(&mantis->uart_wq);
- spin_lock_init(&mantis->uart_lock);
-
- INIT_WORK(&mantis->uart_work, mantis_uart_work);
+ tasklet_init(&mantis->uart_tasklet, mantis_uart_work,
+ (unsigned long) mantis);
/* disable interrupt */ mmwrite(mmread(MANTIS_UART_CTL) & 0xffef, MANTIS_UART_CTL);
@@ -171,7 +171,6 @@ int mantis_uart_init(struct mantis_pci *mantis)
mmwrite(mmread(MANTIS_INT_MASK) | 0x800, MANTIS_INT_MASK); mmwrite(mmread(MANTIS_UART_CTL) | MANTIS_UART_RXINT,MANTIS_UART_CTL);
- schedule_work(&mantis->uart_work);
dprintk(MANTIS_DEBUG, 1, "UART successfully initialized");
return 0;
@@ -182,6 +181,5 @@ void mantis_uart_exit(struct mantis_pci *mantis)
{
/* disable interrupt */ mmwrite(mmread(MANTIS_UART_CTL) & 0xffef, MANTIS_UART_CTL);
- flush_work_sync(&mantis->uart_work);
}
EXPORT_SYMBOL_GPL(mantis_uart_exit);
(quoted diff) +0 -0
b/drivers/media/dvb/mantis/mantis_vp1041.c
index 38a436c..dec4fb1 100644
drivers/media/dvb/mantis/mantis_vp1041.c +3 -0
@@ -21,6 +21,8 @@#include <linux/signal.h> #include <linux/sched.h> #include <linux/interrupt.h> +#include <linux/pci.h> +#include "dmxdev.h" #include "dvbdev.h"
@@ -29,6 +31,7 @@#include "dvb_net.h" #include "mantis_common.h" +#include "mantis_input.h" #include "mantis_ioc.h" #include "mantis_dvb.h" #include "mantis_vp1041.h"
@@ -343,6 +346,20 @@ static int vp1041_frontend_init(struct mantis_pci
*mantis, struct dvb_frontend *
return 0;
}
+static void vp1041_config_init(struct mantis_pci *mantis) +{
+ struct mantis_hwconfig *config = mantis->hwconfig;
+
+ switch (mantis->pdev->subsystem_vendor) {
+ case TWINHAN_TECHNOLOGIES:
+ if (mantis->pdev->subsystem_device == MANTIS_VP_1041_DVB_S2)
+ config->ir_codes = RC_MAP_TWINHAN_DTV_CAB_CI;
+ break;
+ default:
+ config->ir_codes = RC_MAP_TERRATEC_CINERGY_S2_HD;
+ }
+}
+
struct mantis_hwconfig vp1041_config = {
.model_name = MANTIS_MODEL_NAME,
.dev_type = MANTIS_DEV_TYPE,
@@ -352,6 +369,9 @@ struct mantis_hwconfig vp1041_config = {
.parity = MANTIS_PARITY_NONE,
.bytes = 0,
+ .ir_work = mantis_input_process,
+
+ .config_init = vp1041_config_init,
.frontend_init = vp1041_frontend_init,
.power = GPIF_A12,
.reset = GPIF_A13,
(quoted diff) +0 -0
b/drivers/media/dvb/mantis/mantis_vp2033.c
index 06da0dd..20a9823 100644
drivers/media/dvb/mantis/mantis_vp2033.c +4 -0
@@ -30,6 +30,7 @@#include "tda1002x.h" #include "mantis_common.h" +#include "mantis_input.h" #include "mantis_ioc.h" #include "mantis_dvb.h" #include "mantis_vp2033.h"
@@ -181,6 +182,9 @@ struct mantis_hwconfig vp2033_config = { .parity = MANTIS_PARITY_NONE, .bytes = 0, + .ir_codes = RC_MAP_TWINHAN_DTV_CAB_CI, + .ir_work = mantis_input_process, + .frontend_init = vp2033_frontend_init, .power = GPIF_A12, .reset = GPIF_A13,
(quoted diff) +0 -0
b/drivers/media/dvb/mantis/mantis_vp2040.c
index f72b137..8c4da6b 100644
drivers/media/dvb/mantis/mantis_vp2040.c +4 -0
@@ -30,6 +30,7 @@#include "tda1002x.h" #include "mantis_common.h" +#include "mantis_input.h" #include "mantis_ioc.h" #include "mantis_dvb.h" #include "mantis_vp2040.h"
@@ -180,6 +181,9 @@ struct mantis_hwconfig vp2040_config = { .parity = MANTIS_PARITY_NONE, .bytes = 0, + .ir_codes = RC_MAP_TERRATEC_CINERGY_C_PCI, + .ir_work = mantis_input_process, + .frontend_init = vp2040_frontend_init, .power = GPIF_A12, .reset = GPIF_A13,
(quoted diff) +0 -0
b/drivers/media/rc/keymaps/Makefile
index b57fc83..1237262 100644
drivers/media/rc/keymaps/Makefile +3 -0
@@ -73,6 +73,8 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \ rc-streamzap.o \ rc-tbs-nec.o \ rc-technisat-usb2.o \ + rc-terratec-cinergy-c-pci.o \ + rc-terratec-cinergy-s2-hd.o \ rc-terratec-cinergy-xs.o \ rc-terratec-slim.o \ rc-terratec-slim-2.o \
@@ -81,6 +83,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \ rc-total-media-in-hand.o \ rc-trekstor.o \ rc-tt-1500.o \ + rc-twinhan-dtv-cab-ci.o \ rc-twinhan1027.o \ rc-videomate-m1f.o \ rc-videomate-s350.o \
(quoted diff) +0 -0
b/drivers/media/rc/keymaps/rc-terratec-cinergy-c-pci.c new file mode 100644
index 0000000..a381a4c
drivers/media/rc/keymaps/rc-terratec-cinergy-c-pci.c new file +85 -0
85 lines not on this page · raw message
(quoted diff) +0 -0
b/drivers/media/rc/keymaps/rc-terratec-cinergy-s2-hd.c new file mode 100644
index 0000000..9d59c2e
drivers/media/rc/keymaps/rc-terratec-cinergy-s2-hd.c new file +85 -0
85 lines not on this page · raw message
(quoted diff) +0 -0
b/drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c new file mode 100644
index 0000000..2b30374
drivers/media/rc/keymaps/rc-twinhan-dtv-cab-ci.c new file +95 -0
95 lines not on this page · raw message
include/media/rc-map.h +3 -0
@@ -132,6 +132,8 @@ void rc_map_init(void);#define RC_MAP_STREAMZAP "rc-streamzap"#define RC_MAP_TBS_NEC "rc-tbs-nec"#define RC_MAP_TECHNISAT_USB2 "rc-technisat-usb2" +#define RC_MAP_TERRATEC_CINERGY_C_PCI "rc-terratec-cinergy-c-pci" +#define RC_MAP_TERRATEC_CINERGY_S2_HD "rc-terratec-cinergy-s2-hd"#define RC_MAP_TERRATEC_CINERGY_XS "rc-terratec-cinergy-xs"#define RC_MAP_TERRATEC_SLIM "rc-terratec-slim"#define RC_MAP_TERRATEC_SLIM_2 "rc-terratec-slim-2"
@@ -140,6 +142,7 @@ void rc_map_init(void);#define RC_MAP_TOTAL_MEDIA_IN_HAND "rc-total-media-in-hand"#define RC_MAP_TREKSTOR "rc-trekstor"#define RC_MAP_TT_1500 "rc-tt-1500" +#define RC_MAP_TWINHAN_DTV_CAB_CI "rc-twinhan-dtv-cab-ci"#define RC_MAP_TWINHAN_VP1027_DVBS "rc-twinhan1027"#define RC_MAP_VIDEOMATE_M1F "rc-videomate-m1f"#define RC_MAP_VIDEOMATE_S350 "rc-videomate-s350"
Signature · 1 line
1.7.0.4
Quoted 1 line · Christoph Pinkl
X-Mailer: Microsoft Office Outlook 12.0
This will not work.
Use git-send-email or a working email client. See
http://www.kernel.org/doc/Documentation/email-clients.txt for further hints.
Bjørn