Exemplo n.º 1
0
main(int argc, char **argv)
{
	int fd_sec;
	struct secStatus sec_state;
	struct secCmdSequence seq;
	struct secCommand cmd;
	struct secDiseqcCmd diseqc;

	if((fd_sec = open("/dev/ost/sec0",O_RDWR)) < 0){
		perror("SEC DEVICE: ");
		return -1;
	}
//	SecResetOverload(fd_sec);
//	SecGetStatus (fd_sec, &sec_state);
//	SecSetVoltage(fd_sec, SEC_VOLTAGE_13_5);
//        SecSetTone(fd_sec, SEC_TONE_ON);       
        SecGetStatus (fd_sec, &sec_state);
/*
	diseqc.addr=0x10;
	diseqc.cmd=0x38;
	diseqc.numParams=1;
	diseqc.params[0]=0xF3;
*/
//F3 / 51 == H 

	cmd.type=SEC_CMDTYPE_DISEQC;
	cmd.u.diseqc=diseqc;
        
	seq.voltage=SEC_VOLTAGE_18;

	seq.miniCommand=SEC_MINI_NONE;
	seq.continuousTone=SEC_TONE_ON;
	seq.numCommands=1;
	seq.commands=&cmd;	

//	SecSendSequence(fd_sec, &seq);
	close(fd_sec);
}
Exemplo n.º 2
0
static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int srate, char pol, int tone,
	fe_spectral_inversion_t specInv, unsigned int diseqc, fe_modulation_t modulation, fe_code_rate_t HP_CodeRate,
	fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth,
	fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout)
{
  int res, hi_lo, dfd;
#ifdef HAVE_DVB_HEAD
  struct dvb_frontend_parameters feparams;
  struct dvb_frontend_info fe_info;
#else
  FrontendParameters feparams;
  FrontendInfo fe_info;
  FrontendEvent event;
  struct secStatus sec_state;
#endif


  mp_msg(MSGT_DEMUX, MSGL_V,  "TUNE_IT, fd_frontend %d, fd_sec %d\nfreq %lu, srate %lu, pol %c, tone %i, specInv, diseqc %u, fe_modulation_t modulation,fe_code_rate_t HP_CodeRate, fe_transmit_mode_t TransmissionMode,fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth\n",
    fd_frontend, fd_sec, (long unsigned int)freq, (long unsigned int)srate, pol, tone, diseqc);


  memset(&feparams, 0, sizeof(feparams));
  if ( (res = ioctl(fd_frontend,FE_GET_INFO, &fe_info) < 0))
  {
        mp_msg(MSGT_DEMUX, MSGL_FATAL, "FE_GET_INFO FAILED\n");
        return -1;
  }


#ifdef HAVE_DVB_HEAD
  mp_msg(MSGT_DEMUX, MSGL_V, "Using DVB card \"%s\"\n", fe_info.name);
#endif

  switch(fe_info.type)
  {
    case FE_OFDM:
#ifdef HAVE_DVB_HEAD
      if (freq < 1000000) freq*=1000UL;
      feparams.frequency=freq;
      feparams.inversion=specInv;
      feparams.u.ofdm.bandwidth=bandwidth;
      feparams.u.ofdm.code_rate_HP=HP_CodeRate;
      feparams.u.ofdm.code_rate_LP=LP_CodeRate;
      feparams.u.ofdm.constellation=modulation;
      feparams.u.ofdm.transmission_mode=TransmissionMode;
      feparams.u.ofdm.guard_interval=guardInterval;
      feparams.u.ofdm.hierarchy_information=hier;
#else
      if (freq < 1000000) freq*=1000UL;
      feparams.Frequency=freq;
      feparams.Inversion=specInv;
      feparams.u.ofdm.bandWidth=bandwidth;
      feparams.u.ofdm.HP_CodeRate=HP_CodeRate;
      feparams.u.ofdm.LP_CodeRate=LP_CodeRate;
      feparams.u.ofdm.Constellation=modulation;
      feparams.u.ofdm.TransmissionMode=TransmissionMode;
      feparams.u.ofdm.guardInterval=guardInterval;
      feparams.u.ofdm.HierarchyInformation=hier;
#endif
      mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-T to %d Hz, bandwidth: %d\n",freq, bandwidth);
      break;
    case FE_QPSK:
      if (freq > 2200000)
      {
        // this must be an absolute frequency
        if (freq < SLOF)
        {
#ifdef HAVE_DVB_HEAD
          freq = feparams.frequency=(freq-LOF1);
#else
          freq = feparams.Frequency=(freq-LOF1);
#endif
          hi_lo = 0;
        }
        else
        {
#ifdef HAVE_DVB_HEAD
          freq = feparams.frequency=(freq-LOF2);
#else
          freq = feparams.Frequency=(freq-LOF2);
#endif
          hi_lo = 1;
        }
      }
      else
      {
        // this is an L-Band frequency
#ifdef HAVE_DVB_HEAD
       feparams.frequency=freq;
#else
       feparams.Frequency=freq;
#endif
      }

#ifdef HAVE_DVB_HEAD
      feparams.inversion=specInv;
      feparams.u.qpsk.symbol_rate=srate;
      feparams.u.qpsk.fec_inner=HP_CodeRate;
      dfd = fd_frontend;
#else
      feparams.Inversion=specInv;
      feparams.u.qpsk.SymbolRate=srate;
      feparams.u.qpsk.FEC_inner=HP_CodeRate;
      dfd = fd_sec;
#endif

      mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-S to Freq: %u, Pol: %c Srate: %d, 22kHz: %s, LNB:  %d\n",freq,pol,srate,hi_lo ? "on" : "off", diseqc);

      if(do_diseqc(dfd, diseqc, (pol == 'V' ? 1 : 0), hi_lo) == 0)
          mp_msg(MSGT_DEMUX, MSGL_V, "DISEQC SETTING SUCCEDED\n");
      else
      {
          mp_msg(MSGT_DEMUX, MSGL_ERR, "DISEQC SETTING FAILED\n");
          return -1;
      }
      break;
    case FE_QAM:
      mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-C to %d, srate=%d\n",freq,srate);
#ifdef HAVE_DVB_HEAD
      feparams.frequency=freq;
      feparams.inversion=specInv;
      feparams.u.qam.symbol_rate = srate;
      feparams.u.qam.fec_inner = HP_CodeRate;
      feparams.u.qam.modulation = modulation;
#else
      feparams.Frequency=freq;
      feparams.Inversion=specInv;
      feparams.u.qam.SymbolRate = srate;
      feparams.u.qam.FEC_inner = HP_CodeRate;
      feparams.u.qam.QAM = modulation;
#endif
      break;
#ifdef DVB_ATSC
    case FE_ATSC:
      mp_msg(MSGT_DEMUX, MSGL_V, "tuning ATSC to %d, modulation=%d\n",freq,modulation);
      feparams.frequency=freq;
      feparams.u.vsb.modulation = modulation;
      break;
#endif
    default:
      mp_msg(MSGT_DEMUX, MSGL_V, "Unknown FE type. Aborting\n");
      return 0;
  }
  usleep(100000);

#ifndef HAVE_DVB_HEAD
  if (fd_sec) SecGetStatus(fd_sec, &sec_state);
  while(1)
  {
    if(ioctl(fd_frontend, FE_GET_EVENT, &event) == -1)
    break;
  }
#endif

  if(ioctl(fd_frontend,FE_SET_FRONTEND,&feparams) < 0)
  {
    mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR tuning channel\n");
    return -1;
  }

  return(check_status(fd_frontend, timeout));
}