Patch for DVBset

Jean-Paul Saman saman at natlab.research.philips.com
Wed Mar 20 14:08:17 CET 2002


The DVBset program needs a little patch to:
+ find the correct PAT and extract correct PMT's, therefor some TS 
headerfields error checking is added
+ work with DVB-0.9.4-cvs version of the DVB drivers from linuxtv.org. 
This patch is tested against cvs archive of 20020318, but should also 
work for stable DVB-0.9.4 version.

The patch is tested against the CVS version of the DVB drivers of date 
2002 March 18 with kernel 2.4.18 and the preemp-patch. It should work 
with any 2.4.x kernel

----------------

Kind greetings,

Jean-Paul Saman

Software Architect

e-mail (work): saman at natlab.research.philips.com
phone  (work): 040 27 42909
------------------------------------------------------------
Ordina TA,
Science Park Eindhoven 5602, Postbus 293, 5600 AG Eindhoven
e-mail : jean-paul.saman at ordina.nl
phone  : 040 2601200
fax    : 040 2601199

---------------- THE PATCH FILE INCLUDED ------------------------------

diff -X ignore.files -urN DVBset/Makefile DVBset-0.0.1a.jps/Makefile
--- DVBset/Makefile	Mon Feb 25 16:38:49 2002
+++ DVBset-0.0.1a.jps/Makefile	Fri Mar 15 16:06:18 2002
@@ -8,8 +8,7 @@
  CFLAGS += -g

  # Include Path
-#CFLAGS += -I /usr/src/DVB-0.9.3/ost/include
-CFLAGS += -I /usr/src/DVB-0.9.3/ost/include
+CFLAGS += -I /usr/src/DVB-0.9.4/ost/include

  # To generate the dependencies
  DFLAGS += -MM
diff -X ignore.files -urN DVBset/diagnose.c DVBset-0.0.1a.jps/diagnose.c
--- DVBset/diagnose.c	Sun Nov 11 15:40:03 2001
+++ DVBset-0.0.1a.jps/diagnose.c	Fri Mar 15 16:18:23 2002
@@ -11,22 +11,20 @@

  #include "./diagnose.h"

-#define QPSK "/dev/ost/qpskfe"
+#define FRONTEND "/dev/ost/frontend"

-
-feStatus diagnose()
+FrontendStatus diagnose()
  {
-        feStatus stat;
+        FrontendStatus stat;
          int front;

          /* Open the frontend device */
-        if((front = open(QPSK,O_RDWR)) < 0)
+        if((front = open(FRONTEND,O_RDWR)) < 0)
          {
            perror("FRONTEND DEVICE: ");
            return -1;
          }
-
-
+
          ioctl(front,FE_READ_STATUS,&stat);

          if (stat & FE_HAS_POWER)
@@ -39,7 +37,7 @@
            printf("  Diagnose: Frontend has signal\n");
          }

-        if (stat & QPSK_SPECTRUM_INV)
+        if (stat & FE_SPECTRUM_INV)
          {
            printf("  Diagnose: Frontend has set spectrum inverse\n");
          }
@@ -49,7 +47,7 @@
            printf("  Diagnose: Frontend successfully locked to a DVB 
signal\n");
          }

-        if (stat & TUNER_HAS_LOCK)
+        if (stat & FE_TUNER_HAS_LOCK)
          {
            printf("  Diagnose: Tuner has a frequency lock\n");
          }
diff -X ignore.files -urN DVBset/diagnose.h DVBset-0.0.1a.jps/diagnose.h
--- DVBset/diagnose.h	Sun Nov  4 20:49:25 2001
+++ DVBset-0.0.1a.jps/diagnose.h	Fri Mar 15 16:33:48 2002
@@ -1 +1 @@
-feStatus diagnose();
+FrontendStatus diagnose();
diff -X ignore.files -urN DVBset/filters.c DVBset-0.0.1a.jps/filters.c
--- DVBset/filters.c	Tue Feb 26 09:50:22 2002
+++ DVBset-0.0.1a.jps/filters.c	Tue Feb 26 10:46:36 2002
@@ -105,6 +105,7 @@
      perror("  DEMUX DEVICE: ");
      return -1;
    }
+
    if(set_pat_filter(demuxPAT))
    {
      printf("  Filters: Setting PAT filter failed, aborting\n");
@@ -117,6 +118,7 @@
      perror("  DEMUX DEVICE: ");
      return -1;
    }
+
    if(set_other_filter(pmtPID,demuxPMT))
    {
      printf("  Setting PMT filter failed, aborting\n");
@@ -138,16 +140,16 @@
      switch (pstream->type)
      {
        case VIDEO:
- 
	printf( "Video PID %d set for demux nr %d\n", pstream->PID, i );		
+        printf ("Video PID %d set for demux %d\n", pstream->PID, i );
          rc=set_video_filter(pstream->PID,demux[i]);
          break;
        case AUDIO1:
        case AUDIO2:
- 
	printf( "Audio PID %d set for demux nr %d\n", pstream->PID, i );		
+        printf ("Audio PID %d set for demux %d\n", pstream->PID, i );
          rc=set_audio_filter(pstream->PID,demux[i]);
          break;
        default:
- 
	printf( "Other PID %d set for demux nr %d\n", pstream->PID, i );		
+        printf ("Other PID %d set for demux %d\n", pstream->PID, i );
          rc=set_other_filter(pstream->PID,demux[i]);
      }
      if(rc)
diff -X ignore.files -urN DVBset/main.c DVBset-0.0.1a.jps/main.c
--- DVBset/main.c	Thu Feb 28 10:34:16 2002
+++ DVBset-0.0.1a.jps/main.c	Fri Mar 15 16:24:32 2002
@@ -24,7 +24,6 @@
  /***************************** PARAMETERS 
**********************************/
  //#define FREQ 12553000                     /* Frequency you want to 
lock on */
  #define FREQ 12670000
-//#define FREQ 12168000
  #define DISEQC 0                            /* Wether you should use 
Diseqc*/
  #define POL 0                     /* Transponder polarisation H(1) or 
V(0) */
  //#define SRATE 27500000                                      /* 
Symbol rate */
diff -X ignore.files -urN DVBset/pat.c DVBset-0.0.1a.jps/pat.c
--- DVBset/pat.c	Thu Feb 21 14:19:45 2002
+++ DVBset-0.0.1a.jps/pat.c	Wed Mar 20 10:55:56 2002
@@ -40,8 +40,7 @@
    {
      sPAT->progs[k].Id = (ts[13+4*k] << 8) | ts[14+4*k] ;
  	  sPAT->progs[k].pmtPid = ((ts[15+4*k]&0x1f) << 8) + ts[16+4*k] ;
-    printf("  Found program id: %x %d pmtpid: %x\n", sPAT->progs[k].Id,
- 
					sPAT->progs[k].Id,
+    printf("  Found program id: %x pmtpid: %x\n", sPAT->progs[k].Id,
                                                  sPAT->progs[k].pmtPid);
    }
    /* And then ....
@@ -77,7 +76,6 @@
      return NULL;
    }

-
    /* Wait for data, read the pat, stop filtering */
    pfd[0].fd=dvr;
    pfd[0].events=POLLIN;
@@ -87,7 +85,23 @@
      {
        if(read(dvr, buf, 188)==188)
        {
- 
sPAT=DecodePAT(buf);
+ 
// check for TS start code
+ 
// Expecting a TS header with 0x47 syncbyte at byte 0
+ 
// and next 3 bits are not interesting
+  	// followed by 13 bits PID which should be zero
+ 
// PID = 0 means PAT table with PMT content.
+ 
if ((buf[0] == 0x47) &&(((buf[1]&0x20)==0)&&(buf[2]==0)))
+ 
{
+ 
   sPAT=DecodePAT(buf);
+ 
}
+ 
else
+ 
{
+        	  printf("Corrupted TS packet found \n");
+ 
   printf("INFO: Sync byte is 0x%x, expected 0x47\n", buf[0] );
+          	  printf("INFO: PAT PID is 0x%x, expected 0x0\n", 
((buf[1]&0x20) + buf[2]));
+ 
   printf("\n");
+        	  sPAT=NULL;
+ 
}
        }
        else
        {
@@ -101,28 +115,41 @@
    return sPAT;
  }

+#define MAX_RETRIES 10
  struct program* select_program ()
  {
+  unsigned int nretries = 0;
    unsigned int prog_id;
    unsigned int i;
    struct pat* sPAT;

-  if((sPAT=getPAT())==NULL)
+  while (((sPAT=getPAT())==NULL) && (nretries<MAX_RETRIES))
    {
+    nretries ++;
      printf("  Pat: Unable to catch the PAT\n");
+    printf("  Pat: Retrying %d times to get PAT\n", nretries);
      printf("\n");
-    return NULL;
    }
-
-  printf("  Select program: ");
-  scanf("%x", &prog_id);
-  for(i=0; i<sPAT->nprogs; i++)
+
+  if (sPAT != NULL)
    {
-    if(sPAT->progs[i].Id==prog_id)
+    printf("  Select program: ");
+    scanf("%x", &prog_id);
+    for(i=0; i<sPAT->nprogs; i++)
      {
-      return &sPAT->progs[i];
+      if(sPAT->progs[i].Id==prog_id)
+      {
+        return &sPAT->progs[i];
+      }
      }
    }
+  else
+  {
+    printf("  Pat: Unable to catch the PAT\n");
+    printf("  Pat: Giving up .. committing suicide\n");
+    printf("\n");
+  }
+
    printf("  No such program id in PAT\n");
    return NULL;
  }
diff -X ignore.files -urN DVBset/qpsk.c DVBset-0.0.1a.jps/qpsk.c
--- DVBset/qpsk.c	Sun Nov 11 15:40:42 2001
+++ DVBset-0.0.1a.jps/qpsk.c	Fri Mar 15 16:38:40 2002
@@ -12,19 +12,19 @@

  #include <ost/frontend.h>

-#define QPSK "/dev/ost/qpskfe"
+#define FRONTEND "/dev/ost/frontend"

  static int check_qpsk(int front);

  int set_qpsk_channel (int freq, int srate, int fec,\
                        int lnb_lof1, int lnb_lof2, int lnb_slof)
  {
-  struct qpskParameters qpsk;
+  FrontendParameters fep;
    int front;
    int rc;

    /* Open the frontend device */
-  if((front = open(QPSK,O_RDWR)) < 0)
+  if((front = open(FRONTEND,O_RDWR)) < 0)
    {
      perror("  FRONTEND DEVICE: ");
      return -1;
@@ -32,14 +32,15 @@

    /* Set the frequency of the transponder, taking into account the
       local frequencies of the LNB */
-  qpsk.iFrequency = (freq < lnb_slof) ? freq - lnb_lof1 : freq - lnb_lof2;
+  fep.Frequency = (freq < lnb_slof) ? freq - lnb_lof1 : freq - lnb_lof2;

   /* Set symbol rate and FEC */
-  qpsk.SymbolRate = srate;
-  qpsk.FEC_inner = fec;
+  fep.u.qpsk.SymbolRate = srate;
+//  fep.u.qpsk.FEC_inner = fec;
+  fep.u.qpsk.FEC_inner = FEC_AUTO;

    /* Now send it all to the frontend device */
-  if (ioctl(front, QPSK_TUNE, &qpsk) < 0)
+  if (ioctl(front, FE_SET_FRONTEND, &fep) < 0)
    {
      perror("  FRONTEND TUNE: ");
      return -1;
@@ -62,8 +63,8 @@
  static int check_qpsk(int front)
  {
    struct pollfd pfd[1];
-  struct qpskEvent event;
-  /* poll for QPSK event to check if tuning worked */
+  FrontendEvent event;
+  /* poll for Frontend event to check if tuning worked */
    pfd[0].fd = front;
    pfd[0].events = POLLIN;

@@ -71,10 +72,10 @@
    {
      if (pfd[0].revents & POLLIN)
      {
-      printf("  FrontEnd: Getting QPSK event\n");
-      if ( ioctl(front, QPSK_GET_EVENT, &event) == -EBUFFEROVERFLOW)
+      printf("  FrontEnd: Getting FRONTEND event\n");
+      if ( ioctl(front, FE_GET_FRONTEND, &event) == -EBUFFEROVERFLOW)
        {
-        perror("  FrontEnd: qpsk get event");
+        perror("  FrontEnd: FRONTEND get event");
          return -1;
        }



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: DVBset-0.0.1a-DVB-0.9.4-cvs-20020318.patch
Url: http://mailman.videolan.org/pipermail/vls-devel/attachments/20020320/52524181/attachment.txt 


More information about the vls-devel mailing list