aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Boettcher <pb@linuxtv.org>2005-07-07 20:57:49 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-07 21:23:56 -0400
commit64221be7b9006338e4a45228f013e467ee4bf045 (patch)
treeacf137799c31c966f6d8083aee39c27f331905ab
parent2819639b5630cd26d399ee0481be9a752280cf4d (diff)
[PATCH] dvb: flexcop: woraround irq stop problem
The flexcop chip often stops generating interrupts after some hours of operation. Apparently this can be fixed by resetting register block 0x300 at each channel change (this is not detailed in the flexcop data books). This patch also restructures DMA handling and adds a bit of debug code for the irq problem in case it still happens for someone. Signed-off-by: Patrick Boettcher <pb@linuxtv.org> Signed-off-by: Johannes Stezenbach <js@linuxtv.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/media/dvb/b2c2/flexcop-common.h6
-rw-r--r--drivers/media/dvb/b2c2/flexcop-dma.c165
-rw-r--r--drivers/media/dvb/b2c2/flexcop-hw-filter.c12
-rw-r--r--drivers/media/dvb/b2c2/flexcop-misc.c12
-rw-r--r--drivers/media/dvb/b2c2/flexcop-pci.c122
-rw-r--r--drivers/media/dvb/b2c2/flexcop.c34
-rw-r--r--drivers/media/dvb/b2c2/flexcop.h1
-rw-r--r--drivers/media/dvb/b2c2/flexcop_ibi_value_be.h9
-rw-r--r--drivers/media/dvb/b2c2/flexcop_ibi_value_le.h9
9 files changed, 274 insertions, 96 deletions
diff --git a/drivers/media/dvb/b2c2/flexcop-common.h b/drivers/media/dvb/b2c2/flexcop-common.h
index 773d158032d..a94912ac187 100644
--- a/drivers/media/dvb/b2c2/flexcop-common.h
+++ b/drivers/media/dvb/b2c2/flexcop-common.h
@@ -108,6 +108,8 @@ void flexcop_device_kfree(struct flexcop_device*);
108int flexcop_device_initialize(struct flexcop_device*); 108int flexcop_device_initialize(struct flexcop_device*);
109void flexcop_device_exit(struct flexcop_device *fc); 109void flexcop_device_exit(struct flexcop_device *fc);
110 110
111void flexcop_reset_block_300(struct flexcop_device *fc);
112
111/* from flexcop-dma.c */ 113/* from flexcop-dma.c */
112int flexcop_dma_allocate(struct pci_dev *pdev, struct flexcop_dma *dma, u32 size); 114int flexcop_dma_allocate(struct pci_dev *pdev, struct flexcop_dma *dma, u32 size);
113void flexcop_dma_free(struct flexcop_dma *dma); 115void flexcop_dma_free(struct flexcop_dma *dma);
@@ -115,7 +117,8 @@ void flexcop_dma_free(struct flexcop_dma *dma);
115int flexcop_dma_control_timer_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff); 117int flexcop_dma_control_timer_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff);
116int flexcop_dma_control_size_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff); 118int flexcop_dma_control_size_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff);
117int flexcop_dma_control_packet_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff); 119int flexcop_dma_control_packet_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff);
118int flexcop_dma_config(struct flexcop_device *fc, struct flexcop_dma *dma, flexcop_dma_index_t dma_idx,flexcop_dma_addr_index_t index); 120int flexcop_dma_config(struct flexcop_device *fc, struct flexcop_dma *dma, flexcop_dma_index_t dma_idx);
121int flexcop_dma_xfer_control(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, flexcop_dma_addr_index_t index, int onoff);
119int flexcop_dma_config_timer(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 cycles); 122int flexcop_dma_config_timer(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 cycles);
120int flexcop_dma_config_packet_count(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 packets); 123int flexcop_dma_config_packet_count(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 packets);
121 124
@@ -151,6 +154,7 @@ int flexcop_sram_init(struct flexcop_device *fc);
151/* from flexcop-misc.c */ 154/* from flexcop-misc.c */
152void flexcop_determine_revision(struct flexcop_device *fc); 155void flexcop_determine_revision(struct flexcop_device *fc);
153void flexcop_device_name(struct flexcop_device *fc,const char *prefix,const char *suffix); 156void flexcop_device_name(struct flexcop_device *fc,const char *prefix,const char *suffix);
157void flexcop_dump_reg(struct flexcop_device *fc, flexcop_ibi_register reg, int num);
154 158
155/* from flexcop-hw-filter.c */ 159/* from flexcop-hw-filter.c */
156int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *dvbdmxfeed, int onoff); 160int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *dvbdmxfeed, int onoff);
diff --git a/drivers/media/dvb/b2c2/flexcop-dma.c b/drivers/media/dvb/b2c2/flexcop-dma.c
index 8d270607536..cf4ed1df608 100644
--- a/drivers/media/dvb/b2c2/flexcop-dma.c
+++ b/drivers/media/dvb/b2c2/flexcop-dma.c
@@ -37,22 +37,90 @@ void flexcop_dma_free(struct flexcop_dma *dma)
37} 37}
38EXPORT_SYMBOL(flexcop_dma_free); 38EXPORT_SYMBOL(flexcop_dma_free);
39 39
40int flexcop_dma_control_timer_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff) 40int flexcop_dma_config(struct flexcop_device *fc,
41 struct flexcop_dma *dma,
42 flexcop_dma_index_t dma_idx)
41{ 43{
42 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208); 44 flexcop_ibi_value v0x0,v0x4,v0xc;
45 v0x0.raw = v0x4.raw = v0xc.raw = 0;
43 46
44 if (no & FC_DMA_1) 47 v0x0.dma_0x0.dma_address0 = dma->dma_addr0 >> 2;
45 v.ctrl_208.DMA1_Timer_Enable_sig = onoff; 48 v0xc.dma_0xc.dma_address1 = dma->dma_addr1 >> 2;
49 v0x4.dma_0x4_write.dma_addr_size = dma->size / 4;
46 50
47 if (no & FC_DMA_2) 51 if ((dma_idx & FC_DMA_1) == dma_idx) {
48 v.ctrl_208.DMA2_Timer_Enable_sig = onoff; 52 fc->write_ibi_reg(fc,dma1_000,v0x0);
53 fc->write_ibi_reg(fc,dma1_004,v0x4);
54 fc->write_ibi_reg(fc,dma1_00c,v0xc);
55 } else if ((dma_idx & FC_DMA_2) == dma_idx) {
56 fc->write_ibi_reg(fc,dma2_010,v0x0);
57 fc->write_ibi_reg(fc,dma2_014,v0x4);
58 fc->write_ibi_reg(fc,dma2_01c,v0xc);
59 } else {
60 err("either DMA1 or DMA2 can be configured at the within one flexcop_dma_config call.");
61 return -EINVAL;
62 }
49 63
50 fc->write_ibi_reg(fc,ctrl_208,v);
51 return 0; 64 return 0;
52} 65}
53EXPORT_SYMBOL(flexcop_dma_control_timer_irq); 66EXPORT_SYMBOL(flexcop_dma_config);
67
68/* start the DMA transfers, but not the DMA IRQs */
69int flexcop_dma_xfer_control(struct flexcop_device *fc,
70 flexcop_dma_index_t dma_idx,
71 flexcop_dma_addr_index_t index,
72 int onoff)
73{
74 flexcop_ibi_value v0x0,v0xc;
75 flexcop_ibi_register r0x0,r0xc;
76
77 if ((dma_idx & FC_DMA_1) == dma_idx) {
78 r0x0 = dma1_000;
79 r0xc = dma1_00c;
80 } else if ((dma_idx & FC_DMA_2) == dma_idx) {
81 r0x0 = dma2_010;
82 r0xc = dma2_01c;
83 } else {
84 err("either transfer DMA1 or DMA2 can be started within one flexcop_dma_xfer_control call.");
85 return -EINVAL;
86 }
87
88 v0x0 = fc->read_ibi_reg(fc,r0x0);
89 v0xc = fc->read_ibi_reg(fc,r0xc);
90
91 deb_rdump("reg: %03x: %x\n",r0x0,v0x0.raw);
92 deb_rdump("reg: %03x: %x\n",r0xc,v0xc.raw);
93
94 if (index & FC_DMA_SUBADDR_0)
95 v0x0.dma_0x0.dma_0start = onoff;
96
97 if (index & FC_DMA_SUBADDR_1)
98 v0xc.dma_0xc.dma_1start = onoff;
99
100 fc->write_ibi_reg(fc,r0x0,v0x0);
101 fc->write_ibi_reg(fc,r0xc,v0xc);
102
103 deb_rdump("reg: %03x: %x\n",r0x0,v0x0.raw);
104 deb_rdump("reg: %03x: %x\n",r0xc,v0xc.raw);
105 return 0;
106}
107EXPORT_SYMBOL(flexcop_dma_xfer_control);
108
109static int flexcop_dma_remap(struct flexcop_device *fc,
110 flexcop_dma_index_t dma_idx,
111 int onoff)
112{
113 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_00c : dma2_01c;
114 flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
115 deb_info("%s\n",__FUNCTION__);
116 v.dma_0xc.remap_enable = onoff;
117 fc->write_ibi_reg(fc,r,v);
118 return 0;
119}
54 120
55int flexcop_dma_control_size_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff) 121int flexcop_dma_control_size_irq(struct flexcop_device *fc,
122 flexcop_dma_index_t no,
123 int onoff)
56{ 124{
57 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208); 125 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208);
58 126
@@ -67,75 +135,64 @@ int flexcop_dma_control_size_irq(struct flexcop_device *fc, flexcop_dma_index_t
67} 135}
68EXPORT_SYMBOL(flexcop_dma_control_size_irq); 136EXPORT_SYMBOL(flexcop_dma_control_size_irq);
69 137
70int flexcop_dma_control_packet_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff) 138int flexcop_dma_control_timer_irq(struct flexcop_device *fc,
139 flexcop_dma_index_t no,
140 int onoff)
71{ 141{
72 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208); 142 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208);
73 143
74 if (no & FC_DMA_1) 144 if (no & FC_DMA_1)
75 v.ctrl_208.DMA1_Size_IRQ_Enable_sig = onoff; 145 v.ctrl_208.DMA1_Timer_Enable_sig = onoff;
76 146
77 if (no & FC_DMA_2) 147 if (no & FC_DMA_2)
78 v.ctrl_208.DMA2_Size_IRQ_Enable_sig = onoff; 148 v.ctrl_208.DMA2_Timer_Enable_sig = onoff;
79 149
80 fc->write_ibi_reg(fc,ctrl_208,v); 150 fc->write_ibi_reg(fc,ctrl_208,v);
81 return 0; 151 return 0;
82} 152}
83EXPORT_SYMBOL(flexcop_dma_control_packet_irq); 153EXPORT_SYMBOL(flexcop_dma_control_timer_irq);
84 154
85int flexcop_dma_config(struct flexcop_device *fc, struct flexcop_dma *dma, flexcop_dma_index_t dma_idx,flexcop_dma_addr_index_t index) 155/* 1 cycles = 1.97 msec */
156int flexcop_dma_config_timer(struct flexcop_device *fc,
157 flexcop_dma_index_t dma_idx,
158 u8 cycles)
86{ 159{
160 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014;
161 flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
87 162
88 flexcop_ibi_value v0x0,v0x4,v0xc; 163 flexcop_dma_remap(fc,dma_idx,0);
89 v0x0.raw = v0x4.raw = v0xc.raw = 0;
90
91 v0x0.dma_0x0.dma_address0 = dma->dma_addr0 >> 2;
92 v0xc.dma_0xc.dma_address1 = dma->dma_addr1 >> 2;
93 v0x4.dma_0x4_write.dma_addr_size = dma->size / 4;
94
95 if (index & FC_DMA_SUBADDR_0)
96 v0x0.dma_0x0.dma_0start = 1;
97
98 if (index & FC_DMA_SUBADDR_1)
99 v0xc.dma_0xc.dma_1start = 1;
100
101 if (dma_idx & FC_DMA_1) {
102 fc->write_ibi_reg(fc,dma1_000,v0x0);
103 fc->write_ibi_reg(fc,dma1_004,v0x4);
104 fc->write_ibi_reg(fc,dma1_00c,v0xc);
105 } else { /* (dma_idx & FC_DMA_2) */
106 fc->write_ibi_reg(fc,dma2_010,v0x0);
107 fc->write_ibi_reg(fc,dma2_014,v0x4);
108 fc->write_ibi_reg(fc,dma2_01c,v0xc);
109 }
110
111 return 0;
112}
113EXPORT_SYMBOL(flexcop_dma_config);
114 164
115static int flexcop_dma_remap(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, int onoff) 165 deb_info("%s\n",__FUNCTION__);
116{ 166 v.dma_0x4_write.dmatimer = cycles;
117 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_00c : dma2_01c;
118 flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
119 v.dma_0xc.remap_enable = onoff;
120 fc->write_ibi_reg(fc,r,v); 167 fc->write_ibi_reg(fc,r,v);
121 return 0; 168 return 0;
122} 169}
170EXPORT_SYMBOL(flexcop_dma_config_timer);
123 171
124/* 1 cycles = 1.97 msec */ 172/* packet IRQ does not exist in FCII or FCIIb - according to data book and tests */
125int flexcop_dma_config_timer(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 cycles) 173int flexcop_dma_control_packet_irq(struct flexcop_device *fc,
174 flexcop_dma_index_t no,
175 int onoff)
126{ 176{
127 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014; 177 flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208);
128 flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
129 178
130 flexcop_dma_remap(fc,dma_idx,0); 179 deb_rdump("reg: %03x: %x\n",ctrl_208,v.raw);
180 if (no & FC_DMA_1)
181 v.ctrl_208.DMA1_Size_IRQ_Enable_sig = onoff;
182
183 if (no & FC_DMA_2)
184 v.ctrl_208.DMA2_Size_IRQ_Enable_sig = onoff;
185
186 fc->write_ibi_reg(fc,ctrl_208,v);
187 deb_rdump("reg: %03x: %x\n",ctrl_208,v.raw);
131 188
132 v.dma_0x4_write.dmatimer = cycles >> 1;
133 fc->write_ibi_reg(fc,r,v);
134 return 0; 189 return 0;
135} 190}
136EXPORT_SYMBOL(flexcop_dma_config_timer); 191EXPORT_SYMBOL(flexcop_dma_control_packet_irq);
137 192
138int flexcop_dma_config_packet_count(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 packets) 193int flexcop_dma_config_packet_count(struct flexcop_device *fc,
194 flexcop_dma_index_t dma_idx,
195 u8 packets)
139{ 196{
140 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014; 197 flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014;
141 flexcop_ibi_value v = fc->read_ibi_reg(fc,r); 198 flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
diff --git a/drivers/media/dvb/b2c2/flexcop-hw-filter.c b/drivers/media/dvb/b2c2/flexcop-hw-filter.c
index 2baf43d3ce8..75cf237196e 100644
--- a/drivers/media/dvb/b2c2/flexcop-hw-filter.c
+++ b/drivers/media/dvb/b2c2/flexcop-hw-filter.c
@@ -10,6 +10,8 @@
10static void flexcop_rcv_data_ctrl(struct flexcop_device *fc, int onoff) 10static void flexcop_rcv_data_ctrl(struct flexcop_device *fc, int onoff)
11{ 11{
12 flexcop_set_ibi_value(ctrl_208,Rcv_Data_sig,onoff); 12 flexcop_set_ibi_value(ctrl_208,Rcv_Data_sig,onoff);
13
14 deb_ts("rcv_data is now: '%s'\n",onoff ? "on" : "off");
13} 15}
14 16
15void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff) 17void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff)
@@ -151,7 +153,7 @@ int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *d
151{ 153{
152 int max_pid_filter = 6 + fc->has_32_hw_pid_filter*32; 154 int max_pid_filter = 6 + fc->has_32_hw_pid_filter*32;
153 155
154 fc->feedcount += onoff ? 1 : -1; 156 fc->feedcount += onoff ? 1 : -1; /* the number of PIDs/Feed currently requested */
155 if (dvbdmxfeed->index >= max_pid_filter) 157 if (dvbdmxfeed->index >= max_pid_filter)
156 fc->extra_feedcount += onoff ? 1 : -1; 158 fc->extra_feedcount += onoff ? 1 : -1;
157 159
@@ -178,8 +180,14 @@ int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *d
178 /* if it was the first or last feed request change the stream-status */ 180 /* if it was the first or last feed request change the stream-status */
179 if (fc->feedcount == onoff) { 181 if (fc->feedcount == onoff) {
180 flexcop_rcv_data_ctrl(fc,onoff); 182 flexcop_rcv_data_ctrl(fc,onoff);
181 if (fc->stream_control) 183 if (fc->stream_control) /* device specific stream control */
182 fc->stream_control(fc,onoff); 184 fc->stream_control(fc,onoff);
185
186 /* feeding stopped -> reset the flexcop filter*/
187 if (onoff == 0) {
188 flexcop_reset_block_300(fc);
189 flexcop_hw_filter_init(fc);
190 }
183 } 191 }
184 192
185 return 0; 193 return 0;
diff --git a/drivers/media/dvb/b2c2/flexcop-misc.c b/drivers/media/dvb/b2c2/flexcop-misc.c
index 23082545651..3a08d38b318 100644
--- a/drivers/media/dvb/b2c2/flexcop-misc.c
+++ b/drivers/media/dvb/b2c2/flexcop-misc.c
@@ -65,3 +65,15 @@ void flexcop_device_name(struct flexcop_device *fc,const char *prefix,const
65 flexcop_device_names[fc->dev_type],flexcop_bus_names[fc->bus_type], 65 flexcop_device_names[fc->dev_type],flexcop_bus_names[fc->bus_type],
66 flexcop_revision_names[fc->rev],suffix); 66 flexcop_revision_names[fc->rev],suffix);
67} 67}
68
69void flexcop_dump_reg(struct flexcop_device *fc, flexcop_ibi_register reg, int num)
70{
71 flexcop_ibi_value v;
72 int i;
73 for (i = 0; i < num; i++) {
74 v = fc->read_ibi_reg(fc,reg+4*i);
75 deb_rdump("0x%03x: %08x, ",reg+4*i, v.raw);
76 }
77 deb_rdump("\n");
78}
79EXPORT_SYMBOL(flexcop_dump_reg);
diff --git a/drivers/media/dvb/b2c2/flexcop-pci.c b/drivers/media/dvb/b2c2/flexcop-pci.c
index ed717c0073d..a436d5584ea 100644
--- a/drivers/media/dvb/b2c2/flexcop-pci.c
+++ b/drivers/media/dvb/b2c2/flexcop-pci.c
@@ -13,6 +13,10 @@ static int enable_pid_filtering = 1;
13module_param(enable_pid_filtering, int, 0444); 13module_param(enable_pid_filtering, int, 0444);
14MODULE_PARM_DESC(enable_pid_filtering, "enable hardware pid filtering: supported values: 0 (fullts), 1"); 14MODULE_PARM_DESC(enable_pid_filtering, "enable hardware pid filtering: supported values: 0 (fullts), 1");
15 15
16static int irq_chk_intv;
17module_param(irq_chk_intv, int, 0644);
18MODULE_PARM_DESC(irq_chk_intv, "set the interval for IRQ watchdog (currently just debugging).");
19
16#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG 20#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
17#define dprintk(level,args...) \ 21#define dprintk(level,args...) \
18 do { if ((debug & level)) printk(args); } while (0) 22 do { if ((debug & level)) printk(args); } while (0)
@@ -26,6 +30,7 @@ MODULE_PARM_DESC(enable_pid_filtering, "enable hardware pid filtering: supported
26#define deb_reg(args...) dprintk(0x02,args) 30#define deb_reg(args...) dprintk(0x02,args)
27#define deb_ts(args...) dprintk(0x04,args) 31#define deb_ts(args...) dprintk(0x04,args)
28#define deb_irq(args...) dprintk(0x08,args) 32#define deb_irq(args...) dprintk(0x08,args)
33#define deb_chk(args...) dprintk(0x10,args)
29 34
30static int debug = 0; 35static int debug = 0;
31module_param(debug, int, 0644); 36module_param(debug, int, 0644);
@@ -56,6 +61,10 @@ struct flexcop_pci {
56 61
57 spinlock_t irq_lock; 62 spinlock_t irq_lock;
58 63
64 unsigned long last_irq;
65
66 struct work_struct irq_check_work;
67
59 struct flexcop_device *fc_dev; 68 struct flexcop_device *fc_dev;
60}; 69};
61 70
@@ -88,18 +97,55 @@ static int flexcop_pci_write_ibi_reg(struct flexcop_device *fc, flexcop_ibi_regi
88 return 0; 97 return 0;
89} 98}
90 99
100static void flexcop_pci_irq_check_work(void *data)
101{
102 struct flexcop_pci *fc_pci = data;
103 struct flexcop_device *fc = fc_pci->fc_dev;
104
105 flexcop_ibi_value v = fc->read_ibi_reg(fc,sram_dest_reg_714);
106
107 flexcop_dump_reg(fc_pci->fc_dev,dma1_000,4);
108
109 if (v.sram_dest_reg_714.net_ovflow_error)
110 deb_chk("sram net_ovflow_error\n");
111 if (v.sram_dest_reg_714.media_ovflow_error)
112 deb_chk("sram media_ovflow_error\n");
113 if (v.sram_dest_reg_714.cai_ovflow_error)
114 deb_chk("sram cai_ovflow_error\n");
115 if (v.sram_dest_reg_714.cai_ovflow_error)
116 deb_chk("sram cai_ovflow_error\n");
117
118 schedule_delayed_work(&fc_pci->irq_check_work,
119 msecs_to_jiffies(irq_chk_intv < 100 ? 100 : irq_chk_intv));
120}
121
91/* When PID filtering is turned on, we use the timer IRQ, because small amounts 122/* When PID filtering is turned on, we use the timer IRQ, because small amounts
92 * of data need to be passed to the user space instantly as well. When PID 123 * of data need to be passed to the user space instantly as well. When PID
93 * filtering is turned off, we use the page-change-IRQ */ 124 * filtering is turned off, we use the page-change-IRQ */
94static irqreturn_t flexcop_pci_irq(int irq, void *dev_id, struct pt_regs *regs) 125static irqreturn_t flexcop_pci_isr(int irq, void *dev_id, struct pt_regs *regs)
95{ 126{
96 struct flexcop_pci *fc_pci = dev_id; 127 struct flexcop_pci *fc_pci = dev_id;
97 struct flexcop_device *fc = fc_pci->fc_dev; 128 struct flexcop_device *fc = fc_pci->fc_dev;
98 flexcop_ibi_value v = fc->read_ibi_reg(fc,irq_20c); 129 flexcop_ibi_value v;
99 irqreturn_t ret = IRQ_HANDLED; 130 irqreturn_t ret = IRQ_HANDLED;
100 131
101 spin_lock_irq(&fc_pci->irq_lock); 132 spin_lock_irq(&fc_pci->irq_lock);
102 133
134 v = fc->read_ibi_reg(fc,irq_20c);
135
136 /* errors */
137 if (v.irq_20c.Data_receiver_error)
138 deb_chk("data receiver error\n");
139 if (v.irq_20c.Continuity_error_flag)
140 deb_chk("Contunuity error flag is set\n");
141 if (v.irq_20c.LLC_SNAP_FLAG_set)
142 deb_chk("LLC_SNAP_FLAG_set is set\n");
143 if (v.irq_20c.Transport_Error)
144 deb_chk("Transport error\n");
145
146 if ((fc_pci->count % 1000) == 0)
147 deb_chk("%d valid irq took place so far\n",fc_pci->count);
148
103 if (v.irq_20c.DMA1_IRQ_Status == 1) { 149 if (v.irq_20c.DMA1_IRQ_Status == 1) {
104 if (fc_pci->active_dma1_addr == 0) 150 if (fc_pci->active_dma1_addr == 0)
105 flexcop_pass_dmx_packets(fc_pci->fc_dev,fc_pci->dma[0].cpu_addr0,fc_pci->dma[0].size / 188); 151 flexcop_pass_dmx_packets(fc_pci->fc_dev,fc_pci->dma[0].cpu_addr0,fc_pci->dma[0].size / 188);
@@ -115,8 +161,9 @@ static irqreturn_t flexcop_pci_irq(int irq, void *dev_id, struct pt_regs *regs)
115 fc->read_ibi_reg(fc,dma1_008).dma_0x8.dma_cur_addr << 2; 161 fc->read_ibi_reg(fc,dma1_008).dma_0x8.dma_cur_addr << 2;
116 u32 cur_pos = cur_addr - fc_pci->dma[0].dma_addr0; 162 u32 cur_pos = cur_addr - fc_pci->dma[0].dma_addr0;
117 163
118 deb_irq("irq: %08x cur_addr: %08x: cur_pos: %08x, last_cur_pos: %08x ", 164 deb_irq("%u irq: %08x cur_addr: %08x: cur_pos: %08x, last_cur_pos: %08x ",
119 v.raw,cur_addr,cur_pos,fc_pci->last_dma1_cur_pos); 165 jiffies_to_usecs(jiffies - fc_pci->last_irq),v.raw,cur_addr,cur_pos,fc_pci->last_dma1_cur_pos);
166 fc_pci->last_irq = jiffies;
120 167
121 /* buffer end was reached, restarted from the beginning 168 /* buffer end was reached, restarted from the beginning
122 * pass the data from last_cur_pos to the buffer end to the demux 169 * pass the data from last_cur_pos to the buffer end to the demux
@@ -127,7 +174,6 @@ static irqreturn_t flexcop_pci_irq(int irq, void *dev_id, struct pt_regs *regs)
127 fc_pci->dma[0].cpu_addr0 + fc_pci->last_dma1_cur_pos, 174 fc_pci->dma[0].cpu_addr0 + fc_pci->last_dma1_cur_pos,
128 (fc_pci->dma[0].size*2) - fc_pci->last_dma1_cur_pos); 175 (fc_pci->dma[0].size*2) - fc_pci->last_dma1_cur_pos);
129 fc_pci->last_dma1_cur_pos = 0; 176 fc_pci->last_dma1_cur_pos = 0;
130 fc_pci->count = 0;
131 } 177 }
132 178
133 if (cur_pos > fc_pci->last_dma1_cur_pos) { 179 if (cur_pos > fc_pci->last_dma1_cur_pos) {
@@ -139,16 +185,14 @@ static irqreturn_t flexcop_pci_irq(int irq, void *dev_id, struct pt_regs *regs)
139 deb_irq("\n"); 185 deb_irq("\n");
140 186
141 fc_pci->last_dma1_cur_pos = cur_pos; 187 fc_pci->last_dma1_cur_pos = cur_pos;
142 } else 188 fc_pci->count++;
189 } else {
190 deb_irq("isr for flexcop called, apparently without reason (%08x)\n",v.raw);
143 ret = IRQ_NONE; 191 ret = IRQ_NONE;
192 }
144 193
145 spin_unlock_irq(&fc_pci->irq_lock); 194 spin_unlock_irq(&fc_pci->irq_lock);
146 195
147/* packet count would be ideal for hw filtering, but it isn't working. Either
148 * the data book is wrong, or I'm unable to read it correctly */
149
150/* if (v.irq_20c.DMA1_Size_IRQ_Status == 1) { packet counter */
151
152 return ret; 196 return ret;
153} 197}
154 198
@@ -156,30 +200,35 @@ static int flexcop_pci_stream_control(struct flexcop_device *fc, int onoff)
156{ 200{
157 struct flexcop_pci *fc_pci = fc->bus_specific; 201 struct flexcop_pci *fc_pci = fc->bus_specific;
158 if (onoff) { 202 if (onoff) {
159 flexcop_dma_config(fc,&fc_pci->dma[0],FC_DMA_1,FC_DMA_SUBADDR_0 | FC_DMA_SUBADDR_1); 203 flexcop_dma_config(fc,&fc_pci->dma[0],FC_DMA_1);
160 flexcop_dma_config(fc,&fc_pci->dma[1],FC_DMA_2,FC_DMA_SUBADDR_0 | FC_DMA_SUBADDR_1); 204 flexcop_dma_config(fc,&fc_pci->dma[1],FC_DMA_2);
161 flexcop_dma_config_timer(fc,FC_DMA_1,1);
162 205
163 if (fc_pci->fc_dev->pid_filtering) { 206 flexcop_dma_config_timer(fc,FC_DMA_1,0);
164 fc_pci->last_dma1_cur_pos = 0;
165 flexcop_dma_control_timer_irq(fc,FC_DMA_1,1);
166 } else {
167 fc_pci->active_dma1_addr = 0;
168 flexcop_dma_control_size_irq(fc,FC_DMA_1,1);
169 }
170 207
171/* flexcop_dma_config_packet_count(fc,FC_DMA_1,0xc0); 208 flexcop_dma_xfer_control(fc,FC_DMA_1,FC_DMA_SUBADDR_0 | FC_DMA_SUBADDR_1,1);
172 flexcop_dma_control_packet_irq(fc,FC_DMA_1,1); */ 209 deb_irq("DMA xfer enabled\n");
173 210
174 deb_irq("irqs enabled\n"); 211 fc_pci->last_dma1_cur_pos = 0;
212 flexcop_dma_control_timer_irq(fc,FC_DMA_1,1);
213 deb_irq("IRQ enabled\n");
214
215// fc_pci->active_dma1_addr = 0;
216// flexcop_dma_control_size_irq(fc,FC_DMA_1,1);
217
218 if (irq_chk_intv > 0)
219 schedule_delayed_work(&fc_pci->irq_check_work,
220 msecs_to_jiffies(irq_chk_intv < 100 ? 100 : irq_chk_intv));
175 } else { 221 } else {
176 if (fc_pci->fc_dev->pid_filtering) 222 if (irq_chk_intv > 0)
177 flexcop_dma_control_timer_irq(fc,FC_DMA_1,0); 223 cancel_delayed_work(&fc_pci->irq_check_work);
178 else 224
179 flexcop_dma_control_size_irq(fc,FC_DMA_1,0); 225 flexcop_dma_control_timer_irq(fc,FC_DMA_1,0);
226 deb_irq("IRQ disabled\n");
180 227
181// flexcop_dma_control_packet_irq(fc,FC_DMA_1,0); 228// flexcop_dma_control_size_irq(fc,FC_DMA_1,0);
182 deb_irq("irqs disabled\n"); 229
230 flexcop_dma_xfer_control(fc,FC_DMA_1,FC_DMA_SUBADDR_0 | FC_DMA_SUBADDR_1,0);
231 deb_irq("DMA xfer disabled\n");
183 } 232 }
184 233
185 return 0; 234 return 0;
@@ -198,6 +247,7 @@ static int flexcop_pci_dma_init(struct flexcop_pci *fc_pci)
198 flexcop_sram_set_dest(fc_pci->fc_dev,FC_SRAM_DEST_CAO | FC_SRAM_DEST_CAI, FC_SRAM_DEST_TARGET_DMA2); 247 flexcop_sram_set_dest(fc_pci->fc_dev,FC_SRAM_DEST_CAO | FC_SRAM_DEST_CAI, FC_SRAM_DEST_TARGET_DMA2);
199 248
200 fc_pci->init_state |= FC_PCI_DMA_INIT; 249 fc_pci->init_state |= FC_PCI_DMA_INIT;
250
201 goto success; 251 goto success;
202dma1_free: 252dma1_free:
203 flexcop_dma_free(&fc_pci->dma[0]); 253 flexcop_dma_free(&fc_pci->dma[0]);
@@ -244,7 +294,7 @@ static int flexcop_pci_init(struct flexcop_pci *fc_pci)
244 294
245 pci_set_drvdata(fc_pci->pdev, fc_pci); 295 pci_set_drvdata(fc_pci->pdev, fc_pci);
246 296
247 if ((ret = request_irq(fc_pci->pdev->irq, flexcop_pci_irq, 297 if ((ret = request_irq(fc_pci->pdev->irq, flexcop_pci_isr,
248 SA_SHIRQ, DRIVER_NAME, fc_pci)) != 0) 298 SA_SHIRQ, DRIVER_NAME, fc_pci)) != 0)
249 goto err_pci_iounmap; 299 goto err_pci_iounmap;
250 300
@@ -324,6 +374,8 @@ static int flexcop_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
324 if ((ret = flexcop_pci_dma_init(fc_pci)) != 0) 374 if ((ret = flexcop_pci_dma_init(fc_pci)) != 0)
325 goto err_fc_exit; 375 goto err_fc_exit;
326 376
377 INIT_WORK(&fc_pci->irq_check_work, flexcop_pci_irq_check_work, fc_pci);
378
327 goto success; 379 goto success;
328err_fc_exit: 380err_fc_exit:
329 flexcop_device_exit(fc); 381 flexcop_device_exit(fc);
@@ -350,17 +402,17 @@ static void flexcop_pci_remove(struct pci_dev *pdev)
350 402
351static struct pci_device_id flexcop_pci_tbl[] = { 403static struct pci_device_id flexcop_pci_tbl[] = {
352 { PCI_DEVICE(0x13d0, 0x2103) }, 404 { PCI_DEVICE(0x13d0, 0x2103) },
353/* { PCI_DEVICE(0x13d0, 0x2200) }, PCI FlexCopIII ? */ 405/* { PCI_DEVICE(0x13d0, 0x2200) }, ? */
354 { }, 406 { },
355}; 407};
356 408
357MODULE_DEVICE_TABLE(pci, flexcop_pci_tbl); 409MODULE_DEVICE_TABLE(pci, flexcop_pci_tbl);
358 410
359static struct pci_driver flexcop_pci_driver = { 411static struct pci_driver flexcop_pci_driver = {
360 .name = "Technisat/B2C2 FlexCop II/IIb/III PCI", 412 .name = "Technisat/B2C2 FlexCop II/IIb PCI",
361 .id_table = flexcop_pci_tbl, 413 .id_table = flexcop_pci_tbl,
362 .probe = flexcop_pci_probe, 414 .probe = flexcop_pci_probe,
363 .remove = flexcop_pci_remove, 415 .remove = flexcop_pci_remove,
364}; 416};
365 417
366static int __init flexcop_pci_module_init(void) 418static int __init flexcop_pci_module_init(void)
diff --git a/drivers/media/dvb/b2c2/flexcop.c b/drivers/media/dvb/b2c2/flexcop.c
index 8b5d14dd36e..12873d43540 100644
--- a/drivers/media/dvb/b2c2/flexcop.c
+++ b/drivers/media/dvb/b2c2/flexcop.c
@@ -46,7 +46,7 @@
46 46
47int b2c2_flexcop_debug; 47int b2c2_flexcop_debug;
48module_param_named(debug, b2c2_flexcop_debug, int, 0644); 48module_param_named(debug, b2c2_flexcop_debug, int, 0644);
49MODULE_PARM_DESC(debug, "set debug level (1=info,2=tuner,4=i2c,8=ts,16=sram (|-able))." DEBSTATUS); 49MODULE_PARM_DESC(debug, "set debug level (1=info,2=tuner,4=i2c,8=ts,16=sram,32=reg (|-able))." DEBSTATUS);
50#undef DEBSTATUS 50#undef DEBSTATUS
51 51
52/* global zero for ibi values */ 52/* global zero for ibi values */
@@ -173,9 +173,20 @@ static void flexcop_reset(struct flexcop_device *fc)
173 fc->write_ibi_reg(fc,ctrl_208,ibi_zero); 173 fc->write_ibi_reg(fc,ctrl_208,ibi_zero);
174 174
175 v210.raw = 0; 175 v210.raw = 0;
176 v210.sw_reset_210.reset_blocks = 0xff; 176 v210.sw_reset_210.reset_block_000 = 1;
177 v210.sw_reset_210.reset_block_100 = 1;
178 v210.sw_reset_210.reset_block_200 = 1;
179 v210.sw_reset_210.reset_block_300 = 1;
180 v210.sw_reset_210.reset_block_400 = 1;
181 v210.sw_reset_210.reset_block_500 = 1;
182 v210.sw_reset_210.reset_block_600 = 1;
183 v210.sw_reset_210.reset_block_700 = 1;
177 v210.sw_reset_210.Block_reset_enable = 0xb2; 184 v210.sw_reset_210.Block_reset_enable = 0xb2;
185
186 v210.sw_reset_210.Special_controls = 0xc259;
187
178 fc->write_ibi_reg(fc,sw_reset_210,v210); 188 fc->write_ibi_reg(fc,sw_reset_210,v210);
189 msleep(1);
179 190
180/* reset the periphical devices */ 191/* reset the periphical devices */
181 192
@@ -186,6 +197,25 @@ static void flexcop_reset(struct flexcop_device *fc)
186 fc->write_ibi_reg(fc,misc_204,v204); 197 fc->write_ibi_reg(fc,misc_204,v204);
187} 198}
188 199
200void flexcop_reset_block_300(struct flexcop_device *fc)
201{
202 flexcop_ibi_value v208_save = fc->read_ibi_reg(fc,ctrl_208),
203 v210 = fc->read_ibi_reg(fc,sw_reset_210);
204
205 deb_rdump("208: %08x, 210: %08x\n",v208_save.raw,v210.raw);
206
207 fc->write_ibi_reg(fc,ctrl_208,ibi_zero);
208
209 v210.sw_reset_210.reset_block_300 = 1;
210 v210.sw_reset_210.Block_reset_enable = 0xb2;
211
212 fc->write_ibi_reg(fc,sw_reset_210,v210);
213 msleep(1);
214
215 fc->write_ibi_reg(fc,ctrl_208,v208_save);
216}
217EXPORT_SYMBOL(flexcop_reset_block_300);
218
189struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len) 219struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len)
190{ 220{
191 void *bus; 221 void *bus;
diff --git a/drivers/media/dvb/b2c2/flexcop.h b/drivers/media/dvb/b2c2/flexcop.h
index caa343a97bd..0cebe1d92e0 100644
--- a/drivers/media/dvb/b2c2/flexcop.h
+++ b/drivers/media/dvb/b2c2/flexcop.h
@@ -26,5 +26,6 @@ extern int b2c2_flexcop_debug;
26#define deb_i2c(args...) dprintk(0x04,args) 26#define deb_i2c(args...) dprintk(0x04,args)
27#define deb_ts(args...) dprintk(0x08,args) 27#define deb_ts(args...) dprintk(0x08,args)
28#define deb_sram(args...) dprintk(0x10,args) 28#define deb_sram(args...) dprintk(0x10,args)
29#define deb_rdump(args...) dprintk(0x20,args)
29 30
30#endif 31#endif
diff --git a/drivers/media/dvb/b2c2/flexcop_ibi_value_be.h b/drivers/media/dvb/b2c2/flexcop_ibi_value_be.h
index bf3cb5a71fb..ed9a6756b19 100644
--- a/drivers/media/dvb/b2c2/flexcop_ibi_value_be.h
+++ b/drivers/media/dvb/b2c2/flexcop_ibi_value_be.h
@@ -152,7 +152,14 @@ typedef union {
152 struct { 152 struct {
153 u32 Special_controls :16; 153 u32 Special_controls :16;
154 u32 Block_reset_enable : 8; 154 u32 Block_reset_enable : 8;
155 u32 reset_blocks : 8; 155 u32 reset_block_700 : 1;
156 u32 reset_block_600 : 1;
157 u32 reset_block_500 : 1;
158 u32 reset_block_400 : 1;
159 u32 reset_block_300 : 1;
160 u32 reset_block_200 : 1;
161 u32 reset_block_100 : 1;
162 u32 reset_block_000 : 1;
156 } sw_reset_210; 163 } sw_reset_210;
157 164
158 struct { 165 struct {
diff --git a/drivers/media/dvb/b2c2/flexcop_ibi_value_le.h b/drivers/media/dvb/b2c2/flexcop_ibi_value_le.h
index bd4528d747d..49f2315b6e5 100644
--- a/drivers/media/dvb/b2c2/flexcop_ibi_value_le.h
+++ b/drivers/media/dvb/b2c2/flexcop_ibi_value_le.h
@@ -150,7 +150,14 @@ typedef union {
150 } irq_20c; 150 } irq_20c;
151 151
152 struct { 152 struct {
153 u32 reset_blocks : 8; 153 u32 reset_block_000 : 1;
154 u32 reset_block_100 : 1;
155 u32 reset_block_200 : 1;
156 u32 reset_block_300 : 1;
157 u32 reset_block_400 : 1;
158 u32 reset_block_500 : 1;
159 u32 reset_block_600 : 1;
160 u32 reset_block_700 : 1;
154 u32 Block_reset_enable : 8; 161 u32 Block_reset_enable : 8;
155 u32 Special_controls :16; 162 u32 Special_controls :16;
156 } sw_reset_210; 163 } sw_reset_210;