Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] vpeirq() optimization and cleanup



HI,

This is my proposal for cleaning up the vpeirq()
from fidbirq leftovers. It does everything the same as 
current vpeirq(), but it's written more cleanly.

My goal is to have the code efficient, a bit commented
and easy to follow, so if somebody wants to inspect
some function he doesn't have to study it for 10 days
until he figures out what it actually does.

Next, it is a intermediate step for further improved
0x47 syncing. I will remove 0x47 sync's from vpeirq()
because these things belongs really to sw_demux.

There should be done some intelligent 0x47 sync finding
to minimize the packet loss in case of lost sync.

Emard
diff -pur /home/loader/src/dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget-core.c dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget-core.c
--- /home/loader/src/dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget-core.c	Fri Feb  7 20:57:15 2003
+++ dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget-core.c	Wed Feb 12 00:08:07 2003
@@ -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);
-
-               num=dmapos/188;
+	budget->ttbp = newdma;
+	
+	if(budget->feeding == 0 || newdma == olddma)
+		return;
+
+        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 
static void vpeirq (unsigned long data)
{
        struct budget_s *budget = (struct budget_s*) data;
        u8 *mem=(u8 *)(budget->grabbing);
        u32 olddma = budget->ttbp;
        u32 newdma = saa7146_read(budget->dev, PCI_VDP3);

        /* nearest lower position divisible by 188 */
        newdma -= newdma % 188;

        if (newdma >= TS_BUFLEN)
                return;

	budget->ttbp = newdma;
	
	if(budget->feeding == 0 || newdma == olddma)
		return;

        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);
        }
}

Home | Main Index | Thread Index