[linux-dvb] DVB API process question

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

 




I am writing a channel scanning program for my DVB API based video card (HD3000)
in an attempt to better understand the API.  I had it working on FC4 (kernel
2.6.14) but it is behaving differently on Suse10 (kernel 2.6.13).

Here is the function I have written:

static void scan_loop_dvb(int fe_fd, int dmx_fd, int dvr_fd,
			  FILE* out_file, int s_chan, int e_chan)
{
  int i,j;
  int ioctlval;
  struct dmx_pes_filter_params flt;
  struct dvb_frontend_parameters fe_param;
  fe_status_t status;
  unsigned int signal;


  flt.pid = 0x2000;
  flt.input = DMX_IN_FRONTEND;
  flt.output = DMX_OUT_TS_TAP;
  flt.pes_type = DMX_PES_OTHER;
  flt.flags = 0;

  for (i=s_chan; i<=e_chan; i++) {

    fe_param.frequency = ntsc_dvb[i]*1000000;
    fe_param.u.vsb.modulation = VSB_8;

    if (ioctl(fe_fd, FE_SET_FRONTEND, &fe_param) < 0) {
      perror("TUNING FRONTEND");
      return;
    }
    fprintf (stderr, "channel = %d\n",i);

    for(j=0;j<4;j++) {
      ioctlval = ioctl(fe_fd,FE_READ_STATUS,&status);
      if (ioctlval != 0) {
        fprintf(stderr, "bad IOCTL call in first loop\n");
      }
    }
    for(j=0;j<4;j++) {
      ioctlval = ioctl(fe_fd,FE_READ_STATUS,&status);
      if (ioctlval != 0) {
        fprintf(stderr, "bad IOCTL call to status in 2nd loop\n");
      }
      ioctlval = ioctl(fe_fd, FE_READ_SIGNAL_STRENGTH, &signal);
      if (ioctlval != 0) {
        fprintf(stderr, "bad IOCTL call to sig-strength in 2nd loop\n");
      }
      signal /= 655;
      if((status & FE_HAS_LOCK) && signal > 20) {
	ioctlval = ioctl(fe_fd,FE_READ_STATUS,&status);
	ioctlval = ioctl(fe_fd, FE_READ_SIGNAL_STRENGTH, &signal);
	signal /= 655;
	fprintf(stderr, "Signal: %d\n", signal);
	if (signal > 60) {
	  if (ioctl(dmx_fd, DMX_SET_PES_FILTER, &flt) < 0) {
	    perror("DMX_SET_PES_FILTER");
	    return;
	  }
	  if (ioctl(dmx_fd, DMX_START, 0) < 0) {
	    perror("DMX_START");
	    return;
	  }

	  ts_loop(dvr_fd); // Scan transport stream for program info

	  if (ioctl(dmx_fd, DMX_STOP, 0) < 0) {
	    perror("DMX_STOP");
	    return;
	  }
	} else {
	  continue;
	}
	print_info(out_file, i, fe_param.frequency);
	break;
      }
    }
  }
}

When I call this function under kernel 2.6.13 I will get/find all of the
information on the first tuned channel.  After that, no station will "tune" and
pass the signal strength test.  My main question is: "is this a correct usage of
the API?"  I've been through the API documentation several times and to the best
of my understanding came up with this function.  All help is appreciated and
like I said earlier it works differently between 2.6.13 and 2.6.14.  I don't
know what might be different in the driver between those kernel releases.

Thanks in advance,

Rusty


[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux