Mailing List archive

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

[linux-dvb] Re: insmod saa7146_core.o debug = 3 for WinTV-NOVA-t



On Wednesday 17 July 2002 14:14, mocm@metzlerbros.de wrote:
> Alexander Nasonov writes:
>  >    pesfilter.pid = 8192;
>  >    pesfilter.input = DMX_IN_FRONTEND;
>  >    pesfilter.output = DMX_OUT_TAP;
>  >    pesfilter.pesType = DMX_PES_OTHER;
>  >    pesfilter.flags = DMX_IMMEDIATE_START;
>
> As I wrote yesterday, pid = 8192 doesn't work with DMX_OUT_TAP because
> it means you want the entire TS and that can only be sent to
> DMX_OUT_TS_TAP. Since there is no pid = 8192 the filter will never
> find it. Only in the case of the dvr device we introduced this pid to
> account for the ability of the budget cards to deliver the entire TS.
>
> Marcus

It doesn't help.

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <ctype.h>

#include <linux/dvb/frontend.h>
#include <linux/dvb/dmx.h>


static
int setup_demux()
{
   char buf[188];
   int fd, br, slp, i, j;
   struct dmxPesFilterParams pesfilter;

   fd = open("/dev/dvb/adapter0/demux0", O_RDWR | O_NONBLOCK);
   
   if(fd < 0)
   {
      perror("open(\"/dev/dvb/adapter0/demux0\")");
      return -1;
   }

   memset(&pesfilter, 0, sizeof(pesfilter));
   pesfilter.pid = 8192; 
   pesfilter.input = DMX_IN_FRONTEND;
   pesfilter.output = DMX_OUT_TS_TAP;
   pesfilter.pesType = DMX_PES_OTHER;
   pesfilter.flags = DMX_IMMEDIATE_START;

   if(ioctl(fd, DMX_SET_PES_FILTER, &pesfilter) < 0)
   {
      perror("ioctl(DMX_SET_PES_FILTER)");
      return -1;
   }

   return fd;
}

static
int read_dvr()
{
   char buf[188];
   int fd, br, i;

   fd = open("/dev/dvb/adapter0/dvr0", O_RDONLY | O_NONBLOCK);
   
   if(fd < 0)
   {
      perror("open(\"/dev/dvb/adapter0/dvr0\")");
      return -1;
   }

   for(i = 0; i < 7; ++i)
   {
      br = read(fd, buf, 188);
      if(br == -1)
         perror("read(\"/dev/dvb/adapter0/dvr0\")");
      else
         printf("%d bytes read\n", br);
      
      sleep(1);
   }
   
   return fd;
}

static
int setup_frontend ()
{
   struct dvb_frontend_parameters frontend;
   int fd, retr;
   FrontendStatus status;
   uint16_t snr, signal;
   uint32_t ber, uncorrected_blocks;
   char sstatus[32]; 

   memset(&frontend, 0, sizeof(frontend));
   frontend.frequency = 578000000;
   frontend.inversion = INVERSION_OFF;
   frontend.u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
   frontend.u.ofdm.code_rate_LP = FEC_1_2;
   frontend.u.ofdm.code_rate_HP = FEC_1_2;
   frontend.u.ofdm.constellation = QAM_64;
   frontend.u.ofdm.transmission_mode = TRANSMISSION_MODE_2K;
   frontend.u.ofdm.guard_interval = GUARD_INTERVAL_1_32;
   frontend.u.ofdm.hierarchy_information = HIERARCHY_NONE;

   fd = open ("/dev/dvb/adapter0/frontend0", O_RDWR | O_NONBLOCK);
   if(fd < 0) {
      perror("open(\"/dev/dvb/adapter0/frontend0\")");
      return -1;
   }

   if(ioctl (fd, FE_SET_FRONTEND, &frontend) == -1)
      perror("ioctl(FE_SET_FRONTEND)");

   retr = 0;
   do {
      status = 0;
      signal = 0;
      snr = 0;
      ber = 0;
      uncorrected_blocks = 0;
      
      if(ioctl (fd, FE_READ_STATUS, &status) == -1)
         perror("ioctl(FE_READ_STATUS)");
      if(ioctl (fd, FE_READ_SIGNAL_STRENGTH, &signal) == -1)
         perror("ioctl(FE_READ_SIGNAL_STRENGTH)");
      if(ioctl (fd, FE_READ_SNR, &snr) == -1)
         perror("ioctl(FE_READ_SNR)");
      if(ioctl (fd, FE_READ_BER, &ber) == -1)
         perror("ioctl(FE_READ_BER)");
      if(ioctl (fd, FE_READ_UNCORRECTED_BLOCKS, &uncorrected_blocks) == -1)
         perror("ioctl(FE_READ_UNCORRECTED_BLOCKS)");

      strcpy(sstatus, "");
      if(status & FE_HAS_SIGNAL) strcat(sstatus, "SI.");
      if(status & FE_HAS_CARRIER) strcat(sstatus, "C.");
      if(status & FE_HAS_VITERBI) strcat(sstatus, "V.");
      if(status & FE_HAS_SYNC) strcat(sstatus, "SY.");
      if(status & FE_HAS_LOCK) strcat(sstatus, "L.");
      if(status & FE_TIMEDOUT) strcat(sstatus, "T.");
      if(sstatus[0] != '\0') sstatus[strlen(sstatus) - 1] = '\0'; // kill 
trailing dot
      
      printf ("%12s | signal %04x | snr %04x | ber %08x | unc %08x | ",
	      sstatus, signal, snr, ber, uncorrected_blocks);

      if (status & FE_HAS_LOCK)
      {
         printf ("lock");
	 retr++;
      }

      printf ("\n");
      sleep (1);
      
   } while (retr < 5);


   return fd;
}

int main (int argc, char **argv)
{
   int frontend_fd, demux_fd, dvr_fd;
   frontend_fd = setup_frontend();
   demux_fd = setup_demux();
   close(frontend_fd); // frontend_fd and demux_fd can be closed
   close(demux_fd);   // after dvr_fd but it doesn't help too!
   
   dvr_fd = read_dvr();
   close(dvr_fd);
}

-- 
Best regards,
Alexander Nasonov
Fraunhofer Gesellschaft


--
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.



Home | Main Index | Thread Index