summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/ttpci-budget/budget-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/drivers/media/dvb/ttpci-budget/budget-core.c')
-rw-r--r--linux/drivers/media/dvb/ttpci-budget/budget-core.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/linux/drivers/media/dvb/ttpci-budget/budget-core.c b/linux/drivers/media/dvb/ttpci-budget/budget-core.c
index 1d899c3d9..87642fc3f 100644
--- a/linux/drivers/media/dvb/ttpci-budget/budget-core.c
+++ b/linux/drivers/media/dvb/ttpci-budget/budget-core.c
@@ -107,30 +107,32 @@ static void vpeirq (unsigned long data)
{
struct budget_s *budget = (struct budget_s*) data;
u8 *mem=(u8 *)(budget->grabbing);
- int num;
- u32 dmapos;
+ u32 olddma = budget->ttbp;
+ u32 newdma = saa7146_read(budget->dev, PCI_VDP3);
- dmapos=saa7146_read(budget->dev, PCI_VDP3);
- dmapos-=(dmapos%188);
+ /* nearest lower position divisible by 188 */
+ newdma -= newdma % 188;
- if (dmapos >= TS_BUFLEN)
+ if (newdma >= TS_BUFLEN)
return;
- if (dmapos > budget->ttbp) {
- mem+=budget->ttbp;
- num=(dmapos-budget->ttbp)/188;
- } else {
- if (budget->feeding && mem[budget->ttbp]==0x47)
- dvb_dmx_swfilter_packets(&budget->demux,
- mem+budget->ttbp, 1024-budget->ttbp/188);
+ budget->ttbp = newdma;
+
+ if(budget->feeding == 0 || newdma == olddma)
+ return;
- num=dmapos/188;
+ if (newdma > olddma) { /* no wraparound, dump olddma..newdma */
+ if(mem[olddma] == 0x47)
+ dvb_dmx_swfilter_packets(&budget->demux,
+ mem+olddma, (newdma-olddma) / 188);
+ } else { /* wraparound, dump olddma..buflen and 0..newdma */
+ if(mem[olddma] == 0x47)
+ dvb_dmx_swfilter_packets(&budget->demux,
+ mem+olddma, (TS_BUFLEN-olddma) / 188);
+ if(mem[0] == 0x47)
+ dvb_dmx_swfilter_packets(&budget->demux,
+ mem, newdma / 188);
}
-
- budget->ttbp=dmapos;
-
- if (budget->feeding && mem[0]==0x47)
- dvb_dmx_swfilter_packets(&budget->demux, mem, num);
}
/* TS_PACKETS is minumum number of accumulated 188-byte packets