These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / media / pci / mantis / mantis_cards.c
index 801fc55..cdefffc 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/slab.h>
 #include <asm/irq.h>
 #include <linux/interrupt.h>
+#include <media/rc-map.h>
 
 #include "dmxdev.h"
 #include "dvbdev.h"
@@ -49,6 +50,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);
@@ -114,6 +116,10 @@ static irqreturn_t mantis_irq_handler(int irq, void *dev_id)
        }
        if (stat & MANTIS_INT_IRQ1) {
                dprintk(MANTIS_DEBUG, 0, "<%s>", label[2]);
+               spin_lock(&mantis->intmask_lock);
+               mmwrite(mmread(MANTIS_INT_MASK) & ~MANTIS_INT_IRQ1,
+                       MANTIS_INT_MASK);
+               spin_unlock(&mantis->intmask_lock);
                schedule_work(&mantis->uart_work);
        }
        if (stat & MANTIS_INT_OCERR) {
@@ -162,6 +168,7 @@ static irqreturn_t mantis_irq_handler(int irq, void *dev_id)
 static int mantis_pci_probe(struct pci_dev *pdev,
                            const struct pci_device_id *pci_id)
 {
+       struct mantis_pci_drvdata *drvdata;
        struct mantis_pci *mantis;
        struct mantis_hwconfig *config;
        int err = 0;
@@ -169,84 +176,91 @@ static int mantis_pci_probe(struct pci_dev *pdev,
        mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL);
        if (mantis == NULL) {
                printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
-               err = -ENOMEM;
-               goto fail0;
+               return -ENOMEM;
        }
 
+       drvdata                 = (void *)pci_id->driver_data;
        mantis->num             = devs;
        mantis->verbose         = verbose;
        mantis->pdev            = pdev;
-       config                  = (struct mantis_hwconfig *) pci_id->driver_data;
+       config                  = drvdata->hwconfig;
        config->irq_handler     = &mantis_irq_handler;
        mantis->hwconfig        = config;
+       mantis->rc_map_name     = drvdata->rc_map_name;
+
+       spin_lock_init(&mantis->intmask_lock);
 
        err = mantis_pci_init(mantis);
        if (err) {
                dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI initialization failed <%d>", err);
-               goto fail1;
+               goto err_free_mantis;
        }
 
        err = mantis_stream_control(mantis, STREAM_TO_HIF);
        if (err < 0) {
                dprintk(MANTIS_ERROR, 1, "ERROR: Mantis stream control failed <%d>", err);
-               goto fail1;
+               goto err_pci_exit;
        }
 
        err = mantis_i2c_init(mantis);
        if (err < 0) {
                dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C initialization failed <%d>", err);
-               goto fail2;
+               goto err_pci_exit;
        }
 
        err = mantis_get_mac(mantis);
        if (err < 0) {
                dprintk(MANTIS_ERROR, 1, "ERROR: Mantis MAC address read failed <%d>", err);
-               goto fail2;
+               goto err_i2c_exit;
        }
 
        err = mantis_dma_init(mantis);
        if (err < 0) {
                dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA initialization failed <%d>", err);
-               goto fail3;
+               goto err_i2c_exit;
        }
 
        err = mantis_dvb_init(mantis);
        if (err < 0) {
                dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err);
-               goto fail4;
+               goto err_dma_exit;
+       }
+
+       err = mantis_input_init(mantis);
+       if (err < 0) {
+               dprintk(MANTIS_ERROR, 1,
+                       "ERROR: Mantis DVB initialization failed <%d>", err);
+               goto err_dvb_exit;
        }
+
        err = mantis_uart_init(mantis);
        if (err < 0) {
                dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART initialization failed <%d>", err);
-               goto fail6;
+               goto err_input_exit;
        }
 
        devs++;
 
-       return err;
+       return 0;
 
+err_input_exit:
+       mantis_input_exit(mantis);
 
-       dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART exit! <%d>", err);
-       mantis_uart_exit(mantis);
+err_dvb_exit:
+       mantis_dvb_exit(mantis);
 
-fail6:
-fail4:
-       dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA exit! <%d>", err);
+err_dma_exit:
        mantis_dma_exit(mantis);
 
-fail3:
-       dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C exit! <%d>", err);
+err_i2c_exit:
        mantis_i2c_exit(mantis);
 
-fail2:
-       dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI exit! <%d>", err);
+err_pci_exit:
        mantis_pci_exit(mantis);
 
-fail1:
-       dprintk(MANTIS_ERROR, 1, "ERROR: Mantis free! <%d>", err);
+err_free_mantis:
        kfree(mantis);
 
-fail0:
        return err;
 }
 
@@ -257,6 +271,7 @@ static void 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);
@@ -267,17 +282,28 @@ static void mantis_pci_remove(struct pci_dev *pdev)
 }
 
 static struct pci_device_id mantis_pci_table[] = {
-       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1033_DVB_S, &vp1033_config),
-       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1034_DVB_S, &vp1034_config),
-       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1041_DVB_S2, &vp1041_config),
-       MAKE_ENTRY(TECHNISAT, SKYSTAR_HD2_10, &vp1041_config),
-       MAKE_ENTRY(TECHNISAT, SKYSTAR_HD2_20, &vp1041_config),
-       MAKE_ENTRY(TERRATEC, CINERGY_S2_PCI_HD, &vp1041_config),
-       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_2033_DVB_C, &vp2033_config),
-       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_2040_DVB_C, &vp2040_config),
-       MAKE_ENTRY(TECHNISAT, CABLESTAR_HD2, &vp2040_config),
-       MAKE_ENTRY(TERRATEC, CINERGY_C, &vp2040_config),
-       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3030_DVB_T, &vp3030_config),
+       MAKE_ENTRY(TECHNISAT, CABLESTAR_HD2, &vp2040_config,
+                  RC_MAP_TECHNISAT_TS35),
+       MAKE_ENTRY(TECHNISAT, SKYSTAR_HD2_10, &vp1041_config,
+                  NULL),
+       MAKE_ENTRY(TECHNISAT, SKYSTAR_HD2_20, &vp1041_config,
+                  NULL),
+       MAKE_ENTRY(TERRATEC, CINERGY_C, &vp2040_config,
+                  RC_MAP_TERRATEC_CINERGY_C_PCI),
+       MAKE_ENTRY(TERRATEC, CINERGY_S2_PCI_HD, &vp1041_config,
+                  RC_MAP_TERRATEC_CINERGY_S2_HD),
+       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1033_DVB_S, &vp1033_config,
+                  NULL),
+       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1034_DVB_S, &vp1034_config,
+                  NULL),
+       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_1041_DVB_S2, &vp1041_config,
+                  RC_MAP_TWINHAN_DTV_CAB_CI),
+       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_2033_DVB_C, &vp2033_config,
+                  RC_MAP_TWINHAN_DTV_CAB_CI),
+       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_2040_DVB_C, &vp2040_config,
+                  NULL),
+       MAKE_ENTRY(TWINHAN_TECHNOLOGIES, MANTIS_VP_3030_DVB_T, &vp3030_config,
+                  NULL),
        { }
 };