From 8a41c9688c1224f01bfebc06e796e973f79eaf29 Mon Sep 17 00:00:00 2001 From: Davor Emard Date: Wed, 12 Feb 2003 16:44:53 +0000 Subject: Vpeirq is rewritten for readability, keeping all the logic and functionality the same. Now it will be easier for someone to review it and understand what vpeirq() does. --- linux/drivers/media/dvb/ttpci-budget/budget-core.c | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'linux/drivers/media/dvb') 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 -- cgit v1.2.3