diff options
author | Manu Abraham <abraham.manu@gmail.com> | 2009-12-04 03:06:00 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-01-17 08:55:33 -0500 |
commit | 8ce571f5e7eb7186f676af3b60af7980c2fc7929 (patch) | |
tree | ac5be0858f6690b9b60c7dd7158b28b9cc207a26 | |
parent | fadfa070d30434dd228362c933827eb6ce137f2d (diff) |
V4L/DVB (13736): [Mantis] Implement CAM Plug IN and Unplug events
Sigh! how i wish things were simpler ...
Signed-off-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/dvb/mantis/mantis_link.h | 8 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_pcmcia.c | 66 |
2 files changed, 74 insertions, 0 deletions
diff --git a/drivers/media/dvb/mantis/mantis_link.h b/drivers/media/dvb/mantis/mantis_link.h index 2d9b64f6937a..c6b32229edde 100644 --- a/drivers/media/dvb/mantis/mantis_link.h +++ b/drivers/media/dvb/mantis/mantis_link.h | |||
@@ -31,6 +31,12 @@ struct mantis_slot { | |||
31 | u32 timeout; | 31 | u32 timeout; |
32 | }; | 32 | }; |
33 | 33 | ||
34 | /* Physical layer */ | ||
35 | enum mantis_slot_state { | ||
36 | MODULE_INSERTED = 3, | ||
37 | MODULE_XTRACTED = 4 | ||
38 | }; | ||
39 | |||
34 | struct mantis_ca { | 40 | struct mantis_ca { |
35 | struct mantis_slot slot; | 41 | struct mantis_slot slot; |
36 | 42 | ||
@@ -44,6 +50,8 @@ struct mantis_ca { | |||
44 | 50 | ||
45 | enum mantis_sbuf_status sbuf_status; | 51 | enum mantis_sbuf_status sbuf_status; |
46 | 52 | ||
53 | enum mantis_slot_state slot_state; | ||
54 | |||
47 | struct dvb_device *ca_dev; | 55 | struct dvb_device *ca_dev; |
48 | void *ca_priv; | 56 | void *ca_priv; |
49 | }; | 57 | }; |
diff --git a/drivers/media/dvb/mantis/mantis_pcmcia.c b/drivers/media/dvb/mantis/mantis_pcmcia.c index 63f9621a90b7..960123f1ed44 100644 --- a/drivers/media/dvb/mantis/mantis_pcmcia.c +++ b/drivers/media/dvb/mantis/mantis_pcmcia.c | |||
@@ -19,11 +19,75 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "mantis_common.h" | 21 | #include "mantis_common.h" |
22 | #include "mantis_link.h" /* temporary due to physical layer stuff */ | ||
23 | |||
24 | /* | ||
25 | * If Slot state is already PLUG_IN event and we are called | ||
26 | * again, definitely it is jitter alone | ||
27 | */ | ||
28 | void mantis_event_cam_plugin(struct mantis_ca *ca) | ||
29 | { | ||
30 | struct mantis_pci *mantis = ca->ca_priv; | ||
31 | |||
32 | u32 gpif_irqcfg; | ||
33 | |||
34 | if (ca->slot_state == MODULE_XTRACTED) { | ||
35 | dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Event: CAM Plugged IN: Adapter(%d) Slot(0)", mantis->num); | ||
36 | udelay(50); | ||
37 | mmwrite(0xda000000, MANTIS_CARD_RESET); | ||
38 | gpif_irqcfg = mmread(MANTIS_GPIF_IRQCFG); | ||
39 | gpif_irqcfg |= MANTIS_MASK_PLUGOUT; | ||
40 | gpif_irqcfg &= ~MANTIS_MASK_PLUGIN; | ||
41 | mmwrite(gpif_irqcfg, MANTIS_GPIF_IRQCFG); | ||
42 | udelay(500); | ||
43 | ca->slot_state = MODULE_INSERTED; | ||
44 | } | ||
45 | udelay(100); | ||
46 | } | ||
47 | |||
48 | /* | ||
49 | * If Slot state is already UN_PLUG event and we are called | ||
50 | * again, definitely it is jitter alone | ||
51 | */ | ||
52 | void mantis_event_cam_unplug(struct mantis_ca *ca) | ||
53 | { | ||
54 | struct mantis_pci *mantis = ca->ca_priv; | ||
55 | |||
56 | u32 gpif_irqcfg; | ||
57 | |||
58 | if (ca->slot_state == MODULE_INSERTED) { | ||
59 | dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Event: CAM Unplugged: Adapter(%d) Slot(0)", mantis->num); | ||
60 | udelay(50); | ||
61 | mmwrite(0x00da0000, MANTIS_CARD_RESET); | ||
62 | gpif_irqcfg = mmread(MANTIS_GPIF_IRQCFG); | ||
63 | gpif_irqcfg |= MANTIS_MASK_PLUGIN; | ||
64 | gpif_irqcfg &= ~MANTIS_MASK_PLUGOUT; | ||
65 | mmwrite(gpif_irqcfg, MANTIS_GPIF_IRQCFG); | ||
66 | udelay(500); | ||
67 | ca->slot_state = MODULE_XTRACTED; | ||
68 | } | ||
69 | udelay(100); | ||
70 | } | ||
22 | 71 | ||
23 | int mantis_pcmcia_init(struct mantis_ca *ca) | 72 | int mantis_pcmcia_init(struct mantis_ca *ca) |
24 | { | 73 | { |
25 | struct mantis_pci *mantis = ca->ca_priv; | 74 | struct mantis_pci *mantis = ca->ca_priv; |
26 | 75 | ||
76 | u32 gpif_stat, card_stat; | ||
77 | |||
78 | gpif_stat = mmread(MANTIS_GPIF_STATUS); | ||
79 | card_stat = mmread(MANTIS_GPIF_IRQCFG); | ||
80 | |||
81 | if (gpif_stat & MANTIS_GPIF_DETSTAT) { | ||
82 | dprintk(mantis->verbose, MANTIS_DEBUG, 1, "CAM found on Adapter(%d) Slot(0)", mantis->num); | ||
83 | mmwrite(card_stat | MANTIS_MASK_PLUGOUT, MANTIS_GPIF_IRQCFG); | ||
84 | ca->slot_state = MODULE_INSERTED; | ||
85 | } else { | ||
86 | dprintk(mantis->verbose, MANTIS_DEBUG, 1, "Empty Slot on Adapter(%d) Slot(0)", mantis->num); | ||
87 | mmwrite(card_stat | MANTIS_MASK_PLUGIN, MANTIS_GPIF_IRQCFG); | ||
88 | ca->slot_state = MODULE_XTRACTED; | ||
89 | } | ||
90 | |||
27 | return 0; | 91 | return 0; |
28 | } | 92 | } |
29 | 93 | ||
@@ -31,4 +95,6 @@ void mantis_pcmcia_exit(struct mantis_ca *ca) | |||
31 | { | 95 | { |
32 | struct mantis_pci *mantis = ca->ca_priv; | 96 | struct mantis_pci *mantis = ca->ca_priv; |
33 | 97 | ||
98 | mmwrite(mmread(MANTIS_GPIF_STATUS) & (~MANTIS_CARD_PLUGOUT | ~MANTIS_CARD_PLUGIN), MANTIS_GPIF_STATUS); | ||
99 | mmwrite(mmread(MANTIS_INT_MASK) & ~MANTIS_INT_IRQ0, MANTIS_INT_MASK); | ||
34 | } | 100 | } |