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 13:24, mocm@metzlerbros.de wrote:
> Are you sure, that you get any data, i.e. that everything is tuned
> correctly?
> I think tzap will give you a thorough status report when tuning to a
> channel. You will just have to change one of the channel files to fit
> to your setup. Or hack it, so that the entire TS will be sent to the
> dvr device.
>
> You could also use ntuxzap, but I am not sure if it works with DVB-T
> because I can't test it. There is also a sample dvbrc for DVB-T.
>
> Marcus

My test program is based on tzap. You can find sources below.
Note that I use special hardware to generate high-frequency
signal for my DVB-T card. May be driver assumes that something
called X is presented while this X is not generated by hardware?
Refer to
http://www.linuxtv.org/mailinglists/linux-dvb/2002/07-2002/msg00053.html
for my hardware configuration.

Program output:

        SI.C | signal 2929 | snr 1f1f | ber 0000a1fa | unc 0000001c | 
 SI.C.V.SY.L | signal 2929 | snr c6c6 | ber 00000a54 | unc 00000000 | lock
 SI.C.V.SY.L | signal 2929 | snr c0c0 | ber 00000ad5 | unc 00000000 | lock
 SI.C.V.SY.L | signal 2929 | snr c0c0 | ber 00000b82 | unc 00000000 | lock
 SI.C.V.SY.L | signal 2929 | snr bfbf | ber 00000ce5 | unc 00000000 | lock
 SI.C.V.SY.L | signal 2929 | snr c2c2 | ber 000009e5 | unc 00000000 | lock
read("/dev/dvb/adapter0/demux0"): Resource temporarily unavailable
read("/dev/dvb/adapter0/demux0"): Resource temporarily unavailable
read("/dev/dvb/adapter0/demux0"): Resource temporarily unavailable
read("/dev/dvb/adapter0/demux0"): Resource temporarily unavailable
read("/dev/dvb/adapter0/demux0"): Resource temporarily unavailable
read("/dev/dvb/adapter0/demux0"): Resource temporarily unavailable
read("/dev/dvb/adapter0/demux0"): Resource temporarily unavailable

Program source:

#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_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;
   }

   for(i = 0; i < 7; ++i)
   {
      br = read(fd, buf, 188);
      if(br == -1)
         perror("read(\"/dev/dvb/adapter0/demux0\")");
      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;
   frontend_fd = setup_frontend ();
   demux_fd = setup_demux ();
   close(frontend_fd);
   close(demux_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