V4L/DVB (13738): [Mantis] Enable IRQ0 events

Signed-off-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/dvb/mantis/mantis_ca.c b/drivers/media/dvb/mantis/mantis_ca.c
index 6e440d3..e6de3c9 100644
--- a/drivers/media/dvb/mantis/mantis_ca.c
+++ b/drivers/media/dvb/mantis/mantis_ca.c
@@ -93,12 +93,12 @@
 	}
 
 	ca->ca_priv = mantis;
-	mantis->mantis_ca = ca;
-	mantis_evmgr_init(ca);
 
 	dprintk(verbose, MANTIS_ERROR, 0, "CA: Registering Mantis Adapter(%d) Slot(0)\n", mantis->num);
 	if (dvb_register_device(dvb_adapter, &dvbdev, &mantis_ca, ca, DVB_DEVICE_CA) == 0) {
 		ca->ca_dev = dvbdev;
+		mantis->mantis_ca = ca;
+		mantis_evmgr_init(ca);
 		return ca->ca_dev;
 	}
 	return 0;
diff --git a/drivers/media/dvb/mantis/mantis_dvb.c b/drivers/media/dvb/mantis/mantis_dvb.c
index 9634b97..3325b59 100644
--- a/drivers/media/dvb/mantis/mantis_dvb.c
+++ b/drivers/media/dvb/mantis/mantis_dvb.c
@@ -190,6 +190,8 @@
 	dvb_net_init(&mantis->dvb_adapter, &mantis->dvbnet, &mantis->demux.dmx);
 	tasklet_init(&mantis->tasklet, mantis_dma_xfer, (unsigned long) mantis);
 	mantis_frontend_init(mantis);
+	mantis_ca_init(mantis);
+
 	return 0;
 
 	/*	Error conditions ..	*/
diff --git a/drivers/media/dvb/mantis/mantis_evm.c b/drivers/media/dvb/mantis/mantis_evm.c
index c4a1c89..d81068d 100644
--- a/drivers/media/dvb/mantis/mantis_evm.c
+++ b/drivers/media/dvb/mantis/mantis_evm.c
@@ -33,14 +33,14 @@
 
 	if (gpif_stat & MANTIS_GPIF_DETSTAT) {
 		if (gpif_stat & MANTIS_CARD_PLUGIN) {
-			dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num);
+			dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num);
 			mmwrite(0xdada0000, MANTIS_CARD_RESET);
 			// Plugin call here
 			gpif_stat = 0; // crude !
 		}
 	} else {
 		if (gpif_stat & MANTIS_CARD_PLUGOUT) {
-			dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num);
+			dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Unplug", mantis->num);
 			mmwrite(0xdada0000, MANTIS_CARD_RESET);
 			// Unplug call here
 			gpif_stat = 0; // crude !
@@ -48,34 +48,34 @@
 	}
 
 	if (gpif_stat & MANTIS_GPIF_EXTIRQ)
-		dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num);
+		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num);
 
 	if (gpif_stat & MANTIS_SBUF_WSTO)
-		dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num);
+		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num);
 
 	if (gpif_stat & MANTIS_GPIF_OTHERR)
-		dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num);
+		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num);
 
 	if (gpif_stat & MANTIS_SBUF_OVFLW)
-		dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num);
+		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Overflow", mantis->num);
 
 	if (gpif_stat & MANTIS_GPIF_BRRDY) {
-		dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num);
+		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num);
 		ca->sbuf_status = MANTIS_SBUF_DATA_AVAIL;
 		if (ca->hif_job_queue & MANTIS_HIF_MEMRD)
 			wake_up(&ca->hif_brrdyw_wq);
 	}
 	if (gpif_stat & MANTIS_GPIF_WRACK)
-		dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Slave Write ACK", mantis->num);
+		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Slave Write ACK", mantis->num);
 
 	if (gpif_stat & MANTIS_GPIF_INTSTAT)
-		dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num);
+		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): GPIF IRQ", mantis->num);
 
 	if (gpif_stat & MANTIS_SBUF_EMPTY)
-		dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num);
+		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Empty", mantis->num);
 
 	if (gpif_stat & MANTIS_SBUF_OPDONE) {
-		dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num);
+		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer operation complete", mantis->num);
 		if (ca->hif_job_queue) {
 			wake_up(&ca->hif_opdone_wq);
 			ca->hif_event = MANTIS_SBUF_OPDONE;
@@ -87,7 +87,7 @@
 {
 	struct mantis_pci *mantis = ca->ca_priv;
 
-	dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager");
+	dprintk(verbose, MANTIS_DEBUG, 1, "Initializing Mantis Host I/F Event manager");
 	tasklet_init(&ca->hif_evm_tasklet, mantis_hifevm_tasklet, (unsigned long) ca);
 
 	mantis_pcmcia_init(ca);
@@ -99,7 +99,7 @@
 {
 	struct mantis_pci *mantis = ca->ca_priv;
 
-	dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting");
+	dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Host I/F Event manager exiting");
 	tasklet_kill(&ca->hif_evm_tasklet);
 
 	mantis_pcmcia_exit(ca);
diff --git a/drivers/media/dvb/mantis/mantis_pci.c b/drivers/media/dvb/mantis/mantis_pci.c
index 402f866..814c6ac 100644
--- a/drivers/media/dvb/mantis/mantis_pci.c
+++ b/drivers/media/dvb/mantis/mantis_pci.c
@@ -54,12 +54,15 @@
 {
 	u32 stat = 0, mask = 0, lstat = 0, mstat = 0;
 	struct mantis_pci *mantis;
+	struct mantis_ca *ca;
 
 	mantis = (struct mantis_pci *) dev_id;
 	if (unlikely(mantis == NULL)) {
 		dprintk(verbose, MANTIS_ERROR, 1, "Mantis == NULL");
 		return IRQ_NONE;
 	}
+	ca = mantis->mantis_ca;
+
 	stat = mmread(MANTIS_INT_STAT);
 	mask = mmread(MANTIS_INT_MASK);
 	mstat = lstat = stat & ~MANTIS_INT_RISCSTAT;
@@ -72,14 +75,9 @@
 	if (stat & MANTIS_INT_RISCEN) {
 		dprintk(verbose, MANTIS_DEBUG, 0, "* DMA enabl *");
 	}
-	if (stat & MANTIS_INT_I2CRACK) {
-		dprintk(verbose, MANTIS_DEBUG, 0, "* I2C R-ACK *");
-	}
-	if (stat & MANTIS_INT_PCMCIA7) {
-		dprintk(verbose, MANTIS_DEBUG, 0, "* PCMCIA-07 *");
-	}
 	if (stat & MANTIS_INT_IRQ0) {
 		dprintk(verbose, MANTIS_DEBUG, 0, "* INT IRQ-0 *");
+		tasklet_schedule(&ca->hif_evm_tasklet);
 	}
 	if (stat & MANTIS_INT_IRQ1) {
 		dprintk(verbose, MANTIS_DEBUG, 0, "* INT IRQ-1 *");
diff --git a/drivers/media/dvb/mantis/mantis_pcmcia.c b/drivers/media/dvb/mantis/mantis_pcmcia.c
index 960123f..47cc720 100644
--- a/drivers/media/dvb/mantis/mantis_pcmcia.c
+++ b/drivers/media/dvb/mantis/mantis_pcmcia.c
@@ -32,7 +32,7 @@
 	u32 gpif_irqcfg;
 
 	if (ca->slot_state == MODULE_XTRACTED) {
-		dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Event: CAM Plugged IN: Adapter(%d) Slot(0)", mantis->num);
+		dprintk(verbose, MANTIS_DEBUG, 1, "Event: CAM Plugged IN: Adapter(%d) Slot(0)", mantis->num);
 		udelay(50);
 		mmwrite(0xda000000, MANTIS_CARD_RESET);
 		gpif_irqcfg  = mmread(MANTIS_GPIF_IRQCFG);
@@ -56,7 +56,7 @@
 	u32 gpif_irqcfg;
 
 	if (ca->slot_state == MODULE_INSERTED) {
-		dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Event: CAM Unplugged: Adapter(%d) Slot(0)", mantis->num);
+		dprintk(verbose, MANTIS_DEBUG, 1, "Event: CAM Unplugged: Adapter(%d) Slot(0)", mantis->num);
 		udelay(50);
 		mmwrite(0x00da0000, MANTIS_CARD_RESET);
 		gpif_irqcfg  = mmread(MANTIS_GPIF_IRQCFG);
@@ -75,15 +75,16 @@
 
 	u32 gpif_stat, card_stat;
 
+	mmwrite(mmread(MANTIS_INT_MASK) | MANTIS_INT_IRQ0, MANTIS_INT_MASK);
 	gpif_stat = mmread(MANTIS_GPIF_STATUS);
 	card_stat = mmread(MANTIS_GPIF_IRQCFG);
 
 	if (gpif_stat & MANTIS_GPIF_DETSTAT) {
-		dprintk(mantis->verbose, MANTIS_DEBUG, 1, "CAM found on Adapter(%d) Slot(0)", mantis->num);
+		dprintk(verbose, MANTIS_DEBUG, 1, "CAM found on Adapter(%d) Slot(0)", mantis->num);
 		mmwrite(card_stat | MANTIS_MASK_PLUGOUT, MANTIS_GPIF_IRQCFG);
 		ca->slot_state = MODULE_INSERTED;
 	} else {
-		dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Empty Slot on Adapter(%d) Slot(0)", mantis->num);
+		dprintk(verbose, MANTIS_DEBUG, 1, "Empty Slot on Adapter(%d) Slot(0)", mantis->num);
 		mmwrite(card_stat | MANTIS_MASK_PLUGIN, MANTIS_GPIF_IRQCFG);
 		ca->slot_state = MODULE_XTRACTED;
 	}