Пример #1
0
bool Frontend_DVBS::SetTuneParams( Transponder &t )
{
  int satpos = GetCurrentPort( )->GetPortNum( );
  int lnb = dvb_sat_search_lnb( LNB.c_str( ));
  if( lnb < 0 )
  {
    LogError( "Unknown LNB '%s'", LNB.c_str( ));
    t.SetState( Transponder::State_TuningFailed );
    t.SaveConfig( );
    return false;
  }

  // FIXME: we should never use fe->* directly, use functions...
  //
  fe->sat_number = satpos % 3;
  fe->lnb = dvb_sat_get_lnb( lnb ); // FIXME: put to ptroperties in v4l
  fe->diseqc_wait = 0;
  fe->freq_bpf = 0;

  return true;
}
Пример #2
0
bool Frontend::Tune( Transponder &t )
{
  if( !IsPresent( ))
  {
    LogWarn( "device not present '%s'", name.c_str( ));
    return false;
  }
  Lock( );
  if( transponder )
  {
    if( transponder == &t )
    {
      usecount++;
      Unlock( );
      return true;
    }
    Log( "Frontend busy" );
    Unlock( );
    return false;
  }

  if( !Open( ))
  {
    Unlock( );
    return false;
  }

  state = State_Tuning;
  transponder = &t;
  usecount++;
  Unlock( );

  t.SetState( Transponder::State_Tuning );
  Log( "Tuning %s", t.toString( ).c_str( ));

  uint8_t signal, noise;
  LogWarn( "dvb_set_compat_delivery_system %d", t.GetDelSys( ));
  int r = dvb_set_compat_delivery_system( fe, t.GetDelSys( ));
  if( r != 0 )
  {
    LogError( "dvb_set_compat_delivery_system return %d", r );
    goto fail;
  }

  SetTuneParams( t );
  t.GetParams( fe );
  LogWarn( "dvb_estimate_freq_shift");
  dvb_estimate_freq_shift( fe );

  r = dvb_fe_set_parms( fe );
  if( r != 0 )
  {
    LogError( "dvb_fe_set_parms failed with %d.", r );
    dvb_fe_prt_parms( fe );
    goto fail;
  }
  dvb_fe_prt_parms( fe );

	/* As the DVB core emulates it, better to always use auto */
	dvb_fe_store_parm(fe, DTV_INVERSION, INVERSION_AUTO);

	uint32_t freq;
	dvb_fe_retrieve_parm(fe, DTV_FREQUENCY, &freq);
	dvb_fe_prt_parms(fe);

  if( !GetLockStatus( signal, noise, tune_timeout ))
  {
    LogError( "Tuning failed" );
    goto fail;
  }

  t.SetState( Transponder::State_Tuned );
  t.SetSignal( signal, noise );
  return true;

fail:
  t.SetState( Transponder::State_TuningFailed );
  t.SaveConfig( );
  Release( );
  return false;
}